Changeset 141b786 for src/ResolvExpr


Ignore:
Timestamp:
Nov 9, 2016, 2:21:05 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:
b726084
Parents:
23bb1b9
Message:

rework UniqueExpr?, handle UniqueExpr? in FixInit?, fix translation for UniqueExprs?, refactor explode functions and fix AddressExpr? distribution over exploded tuple exprs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r23bb1b9 r141b786  
    3939#include "SymTab/Validate.h"
    4040#include "Tuples/Tuples.h"
     41#include "Tuples/Explode.h"
    4142#include "Common/utility.h"
    4243#include "InitTweak/InitTweak.h"
     
    240241                                } // if
    241242                        } // if
     243                } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) {
     244                        // xxx - temporary hack until 0/1 are int constants
     245                        if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) {
     246                                std::stringstream ss( nameExpr->get_name() );
     247                                int val;
     248                                ss >> val;
     249                                alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );
     250                        }
    242251                } // if
    243252        }
     
    10571066
    10581067        void AlternativeFinder::visit( UniqueExpr *unqExpr ) {
    1059                 // this won't work because the unqExprs wont share an expression anymore...
    10601068                AlternativeFinder finder( indexer, env );
    10611069                finder.findWithAdjustment( unqExpr->get_expr() );
    10621070                for ( Alternative & alt : finder.alternatives ) {
    1063                         // xxx - attach a resolved ConstructorInit node?
    1064                         // xxx - is it possible to make the objDecl's type const?
    1065                         static UniqueName tempNamer( "_unq_expr_" );
    1066                         ObjectDecl * objDecl = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, alt.expr->get_result()->clone(), nullptr );
    1067                         // must be done on two lines because genCtorInit accesses objDecl's fields
    1068                         objDecl->set_init( InitTweak::genCtorInit( objDecl ) );
    1069 
     1071                        // ensure that the id is passed on to the UniqueExpr alternative so that the expressions are "linked"
    10701072                        UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr->clone(), unqExpr->get_id() );
    1071                         newUnqExpr->set_object( objDecl );
    1072 
    1073                         resolveObject( indexer, objDecl );
    1074 
    1075                         alternatives.push_back( Alternative( newUnqExpr, env, Cost::zero ) );
     1073                        alternatives.push_back( Alternative( newUnqExpr, alt.env, alt.cost ) );
    10761074                }
    10771075        }
Note: See TracChangeset for help on using the changeset viewer.