- Timestamp:
- Oct 19, 2017, 11:15:35 AM (7 years ago)
- 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:
- 9dbf7c8
- Parents:
- ab4bff5
- git-author:
- Rob Schluntz <rschlunt@…> (10/17/17 12:09:24)
- git-committer:
- Rob Schluntz <rschlunt@…> (10/19/17 11:15:35)
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/CopyParams.cc
rab4bff5 r582ee28 53 53 54 54 void CopyParams::visit( FunctionDecl *funcDecl ) { 55 if ( funcDecl-> get_statements()) {56 funcDecl-> get_statements()->accept( *this );55 if ( funcDecl->statements ) { 56 funcDecl->statements->accept( *this ); 57 57 58 58 if ( ! modVars.empty() ) { … … 60 60 // xxx - this needs to use constructors, not assignment operators 61 61 // assume the assignment operator is the first assert param after any "type" parameter 62 for ( Type::ForallList::const_iterator tyVar = funcDecl-> get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {62 for ( Type::ForallList::const_iterator tyVar = funcDecl->type->forall.begin(); tyVar != funcDecl->type->forall.end(); ++tyVar ) { 63 63 if ( (*tyVar)->get_kind() == TypeDecl::Any ) { 64 assert( !(*tyVar)-> get_assertions().empty() );65 assert( (*tyVar)-> get_assertions().front()->get_name()== "?=?" );66 assignOps[ (*tyVar)-> get_name() ] = (*tyVar)->get_assertions().front();64 assert( !(*tyVar)->assertions.empty() ); 65 assert( (*tyVar)->assertions.front()->name == "?=?" ); 66 assignOps[ (*tyVar)->name ] = (*tyVar)->assertions.front(); 67 67 } // if 68 68 } // for 69 for ( std::list< DeclarationWithType* >::iterator param = funcDecl-> get_functionType()->get_parameters().begin(); param != funcDecl->get_functionType()->get_parameters().end(); ++param ) {69 for ( std::list< DeclarationWithType* >::iterator param = funcDecl->type->parameters.begin(); param != funcDecl->type->parameters.end(); ++param ) { 70 70 std::set< UniqueId >::const_iterator var = modVars.find( (*param)->get_uniqueId() ); 71 71 if ( var != modVars.end() ) { 72 72 TypeInstType *typeInst = dynamic_cast< TypeInstType* >( (*param)->get_type() ); 73 assert ( typeInst);74 std::map< std::string, DeclarationWithType* >::const_iterator assignOp = assignOps.find( typeInst-> get_name());73 assertf( typeInst, "Found in modVars for function %s: unique id: %u, %s", funcDecl->name.c_str(), (*param)->get_uniqueId(), toString( *param ).c_str() ); 74 std::map< std::string, DeclarationWithType* >::const_iterator assignOp = assignOps.find( typeInst->name ); 75 75 if ( assignOp != assignOps.end() ) { 76 76 DeclarationWithType *oldParam = *param; … … 78 78 (*param)->set_mangleName( namer.newName( (*param)->get_mangleName() ) ); 79 79 ApplicationExpr *assign = new ApplicationExpr( new VariableExpr( assignOp->second ) ); 80 assign-> get_args().push_back( new VariableExpr( oldParam ) );81 assign-> get_args().push_back( new VariableExpr( *param ) );82 funcDecl-> get_statements()->get_kids().push_front( new ExprStmt( noLabels, assign ) );83 funcDecl-> get_statements()->get_kids().push_front( new DeclStmt( noLabels, oldParam ) );80 assign->args.push_back( new VariableExpr( oldParam ) ); 81 assign->args.push_back( new VariableExpr( *param ) ); 82 funcDecl->statements->push_front( new ExprStmt( noLabels, assign ) ); 83 funcDecl->statements->push_front( new DeclStmt( noLabels, oldParam ) ); 84 84 } // if 85 85 modVars.erase( var ); … … 97 97 // every parameter of TypeInstType* when visiting the FunctionDecl. 98 98 void CopyParams::visit( AddressExpr *addrExpr ) { 99 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( addrExpr->get_arg() ) ) { 100 if ( dynamic_cast< TypeInstType* >( varExpr->get_var()->get_type() ) ) { 101 modVars.insert( varExpr->get_var()->get_uniqueId() ); 99 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( addrExpr->arg ) ) { 100 if ( dynamic_cast< TypeInstType* >( varExpr->var->get_type() ) ) { 101 assertf( varExpr->var->get_uniqueId(), "Address-taken variable does not have a unique ID: %s", toString( varExpr->var ).c_str() ); 102 modVars.insert( varExpr->var->get_uniqueId() ); 103 std::cerr << "added unique id: " << varExpr->var->get_uniqueId() << " var: " << varExpr->var << std::endl; 102 104 } // if 103 105 } // if -
src/SymTab/Autogen.cc
rab4bff5 r582ee28 523 523 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 524 524 ObjectDecl * srcParam = strict_dynamic_cast<ObjectDecl *>( ctor->type->parameters.back() ); 525 srcParam->fixUniqueId(); 525 526 ObjectDecl * dstParam = InitTweak::getParamThis( ctor->type ); 526 527 makeMemberOp( srcParam, dstParam, back_inserter( ctor->statements->kids ) ); -
src/SynTree/Declaration.cc
rab4bff5 r582ee28 42 42 43 43 void Declaration::fixUniqueId() { 44 // don't need to set unique ID twice 45 if ( uniqueId ) return; 44 46 uniqueId = ++lastUniqueId; 45 47 idMap[ uniqueId ] = this;
Note: See TracChangeset
for help on using the changeset viewer.