Changeset 2c57025 for src/GenPoly
- Timestamp:
- Nov 25, 2016, 6:11:03 PM (8 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:
- 0f35657
- Parents:
- 186fd86
- Location:
- src/GenPoly
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/GenPoly/Box.cc ¶
r186fd86 r2c57025 275 275 276 276 for ( std::list< TypeDecl* >::const_iterator decl = decls.begin(); decl != decls.end(); ++decl ) { 277 if ( (*decl)-> get_kind() == TypeDecl::Any) {277 if ( (*decl)->isComplete() ) { 278 278 otypeDecls.push_back( *decl ); 279 279 } … … 719 719 720 720 TypeDecl *Pass1::mutate( TypeDecl *typeDecl ) { 721 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();721 addToTyVarMap( typeDecl, scopeTyVars ); 722 722 return Mutator::mutate( typeDecl ); 723 723 } … … 774 774 ResolvExpr::EqvClass eqvClass; 775 775 assert( env ); 776 if ( tyParm->second == TypeDecl::Any) {776 if ( tyParm->second.isComplete ) { 777 777 Type *concrete = env->lookup( tyParm->first ); 778 778 if ( concrete ) { … … 1278 1278 std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin(); 1279 1279 1280 TyVarMap exprTyVars( (TypeDecl::Kind)-1);1280 TyVarMap exprTyVars( TypeDecl::Data{} ); 1281 1281 makeTyVarMap( function, exprTyVars ); 1282 1282 ReferenceToType *dynRetType = isDynRet( function, exprTyVars ); … … 1428 1428 1429 1429 // skip non-otype parameters (ftype/dtype) 1430 // xxx - should this check whether the type is complete instead? 1430 1431 if ( (*forallIt)->get_kind() != TypeDecl::Any ) continue; 1431 1432 … … 1553 1554 1554 1555 TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) { 1555 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1556 addToTyVarMap( typeDecl, scopeTyVars ); 1556 1557 if ( typeDecl->get_base() ) { 1557 1558 return handleDecl( typeDecl, typeDecl->get_base() ); … … 1597 1598 ObjectDecl *sizeParm, *alignParm; 1598 1599 // add all size and alignment parameters to parameter list 1599 if ( (*tyParm)-> get_kind() == TypeDecl::Any) {1600 if ( (*tyParm)->isComplete() ) { 1600 1601 TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm ); 1601 1602 std::string parmName = mangleType( &parmType ); … … 1706 1707 1707 1708 TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) { 1708 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1709 addToTyVarMap( typeDecl, scopeTyVars ); 1709 1710 return Parent::mutate( typeDecl ); 1710 1711 } … … 1870 1871 for ( ; baseParam != baseParams.end() && typeParam != typeParams.end(); ++baseParam, ++typeParam ) { 1871 1872 // skip non-otype parameters 1872 if ( (*baseParam)->get_kind() != TypeDecl::Any) continue;1873 if ( ! (*baseParam)->isComplete() ) continue; 1873 1874 TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( *typeParam ); 1874 1875 assert( typeExpr && "all otype parameters should be type expressions" ); … … 2082 2083 // Initializer *init = 0; 2083 2084 // std::list< Expression *> designators; 2084 // scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();2085 // addToTyVarMap( typeDecl, scopeTyVars ); 2085 2086 // if ( typeDecl->get_base() ) { 2086 2087 // init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators ); … … 2088 2089 // return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init ); 2089 2090 2090 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();2091 addToTyVarMap( typeDecl, scopeTyVars ); 2091 2092 return Mutator::mutate( typeDecl ); 2092 2093 } -
TabularUnified src/GenPoly/GenPoly.cc ¶
r186fd86 r2c57025 97 97 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 98 98 auto var = tyVars.find( typeInst->get_name() ); 99 if ( var != tyVars.end() && var->second == TypeDecl::Any) {99 if ( var != tyVars.end() && var->second.isComplete ) { 100 100 return typeInst; 101 101 } … … 117 117 if ( function->get_returnVals().empty() ) return 0; 118 118 119 TyVarMap forallTypes( (TypeDecl::Kind)-1);119 TyVarMap forallTypes( TypeDecl::Data{} ); 120 120 makeTyVarMap( function, forallTypes ); 121 121 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes ); … … 227 227 } 228 228 229 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ) { 230 tyVarMap[ tyVar->get_name() ] = TypeDecl::Data{ tyVar }; 231 } 232 229 233 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) { 230 234 for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) { 231 235 assert( *tyVar ); 232 tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();236 addToTyVarMap( *tyVar, tyVarMap ); 233 237 } 234 238 if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) { -
TabularUnified src/GenPoly/GenPoly.h ¶
r186fd86 r2c57025 30 30 31 31 namespace GenPoly { 32 typedef ErasableScopedMap< std::string, TypeDecl:: Kind> TyVarMap;32 typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap; 33 33 34 34 /// Replaces a TypeInstType by its referrent in the environment, if applicable … … 74 74 VariableExpr *getBaseVar( Expression *expr, int *levels = 0 ); 75 75 76 /// Adds the type variable `tyVar` to `tyVarMap` 77 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ); 78 76 79 /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap` 77 80 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ); -
TabularUnified src/GenPoly/InstantiateGeneric.cc ¶
r186fd86 r2c57025 284 284 // set concDecl to new type, insert type declaration into statements to add 285 285 concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) ); 286 concDecl->set_body( inst->get_baseStruct()->has_body() ); 286 287 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 287 288 DeclMutator::addDeclaration( concDecl ); … … 337 338 // set concDecl to new type, insert type declaration into statements to add 338 339 concDecl = new UnionDecl( typeNamer.newName( inst->get_name() ) ); 340 concDecl->set_body( inst->get_baseUnion()->has_body() ); 339 341 substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 340 342 DeclMutator::addDeclaration( concDecl ); -
TabularUnified src/GenPoly/PolyMutator.cc ¶
r186fd86 r2c57025 23 23 24 24 namespace GenPoly { 25 namespace { 26 const std::list<Label> noLabels; 27 } 28 29 PolyMutator::PolyMutator() : scopeTyVars( (TypeDecl::Kind)-1 ), env( 0 ) {} 25 PolyMutator::PolyMutator() : scopeTyVars( TypeDecl::Data{} ), env( 0 ) {} 30 26 31 27 void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) { -
TabularUnified src/GenPoly/ScrubTyVars.cc ¶
r186fd86 r2c57025 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ScrubTyVars.cc -- 7 // ScrubTyVars.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 28 28 TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() ); 29 29 if ( tyVar != tyVars.end() ) { 30 switch ( tyVar->second ) {30 switch ( tyVar->second.kind ) { 31 31 case TypeDecl::Any: 32 32 case TypeDecl::Dtype: … … 52 52 return ty; 53 53 } 54 54 55 55 Type * ScrubTyVars::mutate( StructInstType *structInst ) { 56 56 return mutateAggregateType( structInst );
Note: See TracChangeset
for help on using the changeset viewer.