Changeset d104b02


Ignore:
Timestamp:
Aug 22, 2017, 5:38:49 PM (7 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:
5ccb10d
Parents:
9f10c4b8
git-author:
Rob Schluntz <rschlunt@…> (08/22/17 17:38:35)
git-committer:
Rob Schluntz <rschlunt@…> (08/22/17 17:38:49)
Message:

Add codegen for TupleAssignExpr?, UniqueExpr? and remove lvalue cast special case

Location:
src/CodeGen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r9f10c4b8 rd104b02  
    547547                if ( castExpr->get_result()->isVoid() ) {
    548548                        output << "(void)" ;
    549                 } else if ( ! castExpr->get_result()->get_lvalue() ) {
    550                         // at least one result type of cast, but not an lvalue
     549                } else {
     550                        // at least one result type of cast.
     551                        // Note: previously, lvalue casts were skipped. Since it's now impossible for the user to write
     552                        // an lvalue cast, this has been taken out.
    551553                        output << "(";
    552554                        output << genType( castExpr->get_result(), "", pretty, genC );
    553555                        output << ")";
    554                 } else {
    555                         // otherwise, the cast is to an lvalue type, so the cast should be dropped, since the result of a cast is
    556                         // never an lvalue in C
    557556                } // if
    558557                castExpr->get_arg()->accept( *this );
     
    679678        }
    680679
     680        void CodeGenerator::visit( TupleAssignExpr * tupleExpr ) {
     681                assertf( ! genC, "TupleAssignExpr should not reach code generation." );
     682                tupleExpr->stmtExpr->accept( *this );
     683        }
     684
    681685        void CodeGenerator::visit( UntypedTupleExpr * tupleExpr ) {
    682686                assertf( ! genC, "UntypedTupleExpr should not reach code generation." );
     
    726730                output << "(" << genType( compLitExpr->get_result(), "", pretty, genC ) << ")";
    727731                compLitExpr->get_initializer()->accept( *this );
     732        }
     733
     734        void CodeGenerator::visit( UniqueExpr * unqExpr ) {
     735                assertf( ! genC, "Unique expressions should not reach code generation." );
     736                output << "unq<" << unqExpr->get_id() << ">{ ";
     737                unqExpr->get_expr()->accept( *this );
     738                output << " }";
    728739        }
    729740
  • src/CodeGen/CodeGenerator.h

    r9f10c4b8 rd104b02  
    7777                virtual void visit( CommaExpr *commaExpr );
    7878                virtual void visit( CompoundLiteralExpr *compLitExpr );
     79                virtual void visit( UniqueExpr * );
     80                virtual void visit( TupleAssignExpr * tupleExpr );
    7981                virtual void visit( UntypedTupleExpr *tupleExpr );
    8082                virtual void visit( TupleExpr *tupleExpr );
  • src/CodeGen/GenType.cc

    r9f10c4b8 rd104b02  
    287287                        typeString = "_Atomic " + typeString;
    288288                } // if
     289                if ( type->get_lvalue() && ! genC ) {
     290                        // when not generating C code, print lvalue for debugging.
     291                        typeString = "lvalue " + typeString;
     292                }
    289293        }
    290294} // namespace CodeGen
Note: See TracChangeset for help on using the changeset viewer.