Changeset f32c7f4 for src


Ignore:
Timestamp:
Aug 12, 2015, 2:35:51 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
4550bcf
Parents:
d60ccbf
git-author:
Rob Schluntz <rschlunt@…> (08/12/15 14:33:29)
git-committer:
Rob Schluntz <rschlunt@…> (08/12/15 14:35:51)
Message:

fixed codegen for designators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rd60ccbf rf32c7f4  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jul 27 14:40:06 2015
    13 // Update Count     : 218
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Aug 12 14:33:52 2015
     13// Update Count     : 222
    1414//
    1515
     
    190190                if ( designators.size() == 0 ) return;
    191191                for ( DesignatorList::iterator iter = designators.begin(); iter != designators.end(); ++iter ) {
    192                         // if expression is a name, then initializing aggregate member, if constant expression then array
    193192                        if ( NameExpr * nm = dynamic_cast< NameExpr * >( *iter ) ) {
    194                                 if ( nm->get_name() == "0" || nm->get_name() == "1" ) {
    195                                         // except if name is 0 or 1...
    196                                         output << "[";
    197                                         nm->accept( *this );
    198                                         output << "]";
    199                                 } else {
    200                                         output << ".";
    201                                         nm->accept( *this );
    202                                 }
    203                         } else if ( dynamic_cast< ConstantExpr * >( *iter ) ) {
     193                                // if expression is a name, then initializing aggregate member
     194                                output << ".";
     195                                (*iter)->accept( *this );
     196                        } else {
     197                                // if not a simple name, it has to be a constant expression, i.e. an array designator
    204198                                output << "[";
    205199                                (*iter)->accept( *this );
    206200                                output << "]";
    207                         } else {
    208                                 assert(0);
    209201                        }
    210202                }
Note: See TracChangeset for help on using the changeset viewer.