Changeset e01559c for src/GenPoly/Box.cc


Ignore:
Timestamp:
Jul 30, 2015, 4:06:11 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:
e497c1d
Parents:
e766208
Message:

fix initialization of polymorphic value objects so that initializer is done only once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    re766208 re01559c  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jun 24 16:19:07 2015
    13 // Update Count     : 10
     12// Last Modified On : Thu Jul 30 14:35:40 2015
     13// Update Count     : 54
    1414//
    1515
     
    10511051                        if ( ObjectDecl *objectDecl = dynamic_cast< ObjectDecl *>( declStmt->get_decl() ) ) {
    10521052                                if ( isPolyVal( objectDecl->get_type(), scopeTyVars ) ) {
     1053                                        // change initialization of a polymorphic value object
     1054                                        // to allocate storage with alloca
    10531055                                        TypeInstType *typeInst = dynamic_cast< TypeInstType *>( objectDecl->get_type() );
    10541056                                        assert( typeInst );
    10551057                                        UntypedExpr *alloc = new UntypedExpr( new NameExpr( "__builtin_alloca" ) );
    10561058                                        alloc->get_args().push_back( new NameExpr( typeInst->get_name() ) );
    1057                                         UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
    1058                                         assign->get_args().push_back( new VariableExpr( objectDecl ) );
    1059                                         assign->get_args().push_back( alloc );
    1060                                         stmtsToAddAfter.push_back( new ExprStmt( noLabels, assign ) );
     1059
     1060                                        delete objectDecl->get_init();
     1061
     1062                                        std::list<Expression*> designators;
     1063                                        objectDecl->set_init( new SingleInit( alloc, designators ) );
    10611064                                }
    10621065                        }
Note: See TracChangeset for help on using the changeset viewer.