Changeset 62423350 for src/CodeGen


Ignore:
Timestamp:
Jun 29, 2017, 5:06:24 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
a12d5aa
Parents:
bb1cd95
Message:

Big push on designations and initialization: works with generic types, tuples, arrays, tests pass.
Refactor guard_value_impl.
Add list of declarations to TupleType?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rbb1cd95 r62423350  
    292292                if ( designators.size() == 0 ) return;
    293293                for ( Expression * des : designators ) {
    294                         if ( dynamic_cast< ConstantExpr * >( des ) ) {
    295                                 // if expression is a ConstantExpr, then initializing array element
     294                        if ( dynamic_cast< NameExpr * >( des ) || dynamic_cast< VariableExpr * >( des ) ) {
     295                                // if expression is a NameExpr or VariableExpr, then initializing aggregate member
     296                                output << ".";
     297                                des->accept( *this );
     298                        } else {
     299                                // otherwise, it has to be a ConstantExpr or CastExpr, initializing array eleemnt
    296300                                output << "[";
    297301                                des->accept( *this );
    298302                                output << "]";
    299                         } else {
    300                                 // if not a ConstantExpr, it has to be a NameExpr or VariableExpr, initializing aggregate member
    301                                 output << ".";
    302                                 des->accept( *this );
    303303                        } // if
    304304                } // for
Note: See TracChangeset for help on using the changeset viewer.