Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    ra0c7dc36 re612146c  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Aug 18 15:34:00 2017
    13 // Update Count     : 488
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Sep  3 20:42:52 2017
     13// Update Count     : 490
    1414//
    1515#include "CodeGenerator.h"
     
    5959
    6060        void CodeGenerator::asmName( DeclarationWithType * decl ) {
    61                 if ( ConstantExpr * asmName = decl->get_asmName() ) {
     61                if ( ConstantExpr * asmName = dynamic_cast<ConstantExpr *>(decl->get_asmName()) ) {
    6262                        output << " asm ( " << asmName->get_constant()->get_value() << " )";
    6363                } // if
     
    258258
    259259        void CodeGenerator::visit( TraitDecl * traitDecl ) {
    260                 assertf( ! genC, "TraitDecls should not reach code generation." );
     260                assertf( ! genC, "TraitDecl nodes should not reach code generation." );
    261261                extension( traitDecl );
    262262                handleAggregate( traitDecl, "trait " );
     
    271271
    272272        void CodeGenerator::visit( TypeDecl * typeDecl ) {
    273                 assertf( ! genC, "TypeDecls should not reach code generation." );
    274                 output << typeDecl->genTypeString() << " " << typeDecl->get_name();
    275                 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) {
    276                         output << " | sized(" << typeDecl->get_name() << ")";
    277                 }
    278                 if ( ! typeDecl->get_assertions().empty() ) {
    279                         output << " | { ";
    280                         genCommaList( typeDecl->get_assertions().begin(), typeDecl->get_assertions().end() );
    281                         output << " }";
     273                if ( genC ) {
     274                        // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
     275                        // still to be done
     276                        extension( typeDecl );
     277                        output << "extern unsigned long " << typeDecl->get_name();
     278                        if ( typeDecl->get_base() ) {
     279                                output << " = sizeof( " << genType( typeDecl->get_base(), "", pretty, genC ) << " )";
     280                        } // if
     281                } else {
     282                        output << typeDecl->genTypeString() << " " << typeDecl->get_name();
     283                        if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) {
     284                                output << " | sized(" << typeDecl->get_name() << ")";
     285                        }
     286                        if ( ! typeDecl->get_assertions().empty() ) {
     287                                output << " | { ";
     288                                genCommaList( typeDecl->get_assertions().begin(), typeDecl->get_assertions().end() );
     289                                output << " }";
     290                        }
    282291                }
    283292        }
Note: See TracChangeset for help on using the changeset viewer.