Changeset b7778c1 for src/GenPoly
- Timestamp:
- Oct 4, 2017, 3:31:43 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:
- 3364962
- Parents:
- 3628765 (diff), bb9d8e8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/GenPoly
- Files:
-
- 3 edited
-
Box.cc (modified) (9 diffs)
-
FindFunction.cc (modified) (6 diffs)
-
Specialize.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r3628765 rb7778c1 600 600 601 601 // add size/align for generic types to parameter list 602 if ( ! appExpr->get_function()-> has_result()) return;602 if ( ! appExpr->get_function()->result ) return; 603 603 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() ); 604 604 assert( funcType ); … … 714 714 715 715 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 716 assertf( arg-> has_result(), "arg does not have result: %s", toString( arg ).c_str() );716 assertf( arg->result, "arg does not have result: %s", toString( arg ).c_str() ); 717 717 if ( isPolyType( param, exprTyVars ) ) { 718 718 Type * newType = arg->get_result()->clone(); … … 965 965 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) { 966 966 if ( varExpr->get_var()->get_name() == "?[?]" ) { 967 assert( appExpr-> has_result());967 assert( appExpr->result ); 968 968 assert( appExpr->get_args().size() == 2 ); 969 969 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env ); … … 999 999 } // if 1000 1000 } else if ( varExpr->get_var()->get_name() == "*?" ) { 1001 assert( appExpr-> has_result());1001 assert( appExpr->result ); 1002 1002 assert( ! appExpr->get_args().empty() ); 1003 1003 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { … … 1016 1016 } // if 1017 1017 } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) { 1018 assert( appExpr-> has_result());1018 assert( appExpr->result ); 1019 1019 assert( appExpr->get_args().size() == 1 ); 1020 1020 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { … … 1036 1036 } // if 1037 1037 } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) { 1038 assert( appExpr-> has_result());1038 assert( appExpr->result ); 1039 1039 assert( appExpr->get_args().size() == 1 ); 1040 1040 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { … … 1042 1042 } // if 1043 1043 } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) { 1044 assert( appExpr-> has_result());1044 assert( appExpr->result ); 1045 1045 assert( appExpr->get_args().size() == 2 ); 1046 1046 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env ); … … 1068 1068 } // if 1069 1069 } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) { 1070 assert( appExpr-> has_result());1070 assert( appExpr->result ); 1071 1071 assert( appExpr->get_args().size() == 2 ); 1072 1072 Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ); … … 1162 1162 void Pass1::premutate( AddressExpr * ) { visit_children = false; } 1163 1163 Expression * Pass1::postmutate( AddressExpr * addrExpr ) { 1164 assert( addrExpr->get_arg()-> has_result()&& ! addrExpr->get_arg()->get_result()->isVoid() );1164 assert( addrExpr->get_arg()->result && ! addrExpr->get_arg()->get_result()->isVoid() ); 1165 1165 1166 1166 bool needs = false; 1167 1167 if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) { 1168 if ( expr-> has_result()&& isPolyType( expr->get_result(), scopeTyVars, env ) ) {1168 if ( expr->result && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1169 1169 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1170 1170 if ( name->get_name() == "*?" ) { 1171 1171 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 1172 assert( appExpr->get_function()-> has_result());1172 assert( appExpr->get_function()->result ); 1173 1173 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() ); 1174 1174 assert( function ); -
src/GenPoly/FindFunction.cc
r3628765 rb7778c1 18 18 #include <utility> // for pair 19 19 20 #include "Common/PassVisitor.h" // for PassVisitor 20 21 #include "Common/SemanticError.h" // for SemanticError 21 22 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::iterator … … 27 28 28 29 namespace GenPoly { 29 class FindFunction : public Mutator{30 class FindFunction : public WithGuards, public WithVisitorRef<FindFunction>, public WithShortCircuiting { 30 31 public: 31 32 FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate ); 32 33 33 virtual Type *mutate( FunctionType *functionType ); 34 virtual Type *mutate( PointerType *pointerType ); 34 void premutate( FunctionType * functionType ); 35 Type * postmutate( FunctionType * functionType ); 36 void premutate( PointerType * pointerType ); 35 37 private: 36 38 void handleForall( const Type::ForallList &forall ); … … 43 45 44 46 void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) { 45 FindFunctionfinder( functions, tyVars, false, predicate );47 PassVisitor<FindFunction> finder( functions, tyVars, false, predicate ); 46 48 type->acceptMutator( finder ); 47 49 } 48 50 49 51 void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) { 50 FindFunctionfinder( functions, tyVars, true, predicate );52 PassVisitor<FindFunction> finder( functions, tyVars, true, predicate ); 51 53 type = type->acceptMutator( finder ); 52 54 } … … 57 59 58 60 void FindFunction::handleForall( const Type::ForallList &forall ) { 59 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i) {60 TyVarMap::iterator var = tyVars.find( (*i)->get_name());61 for ( const Declaration * td : forall ) { 62 TyVarMap::iterator var = tyVars.find( td->name ); 61 63 if ( var != tyVars.end() ) { 62 64 tyVars.erase( var->first ); … … 65 67 } 66 68 67 Type * FindFunction::mutate( FunctionType *functionType ) { 68 tyVars.beginScope(); 69 void FindFunction::premutate( FunctionType * functionType ) { 70 visit_children = false; 71 GuardScope( tyVars ); 69 72 handleForall( functionType->get_forall() ); 70 mutateAll( functionType->get_returnVals(), *this ); 73 mutateAll( functionType->get_returnVals(), *visitor ); 74 } 75 76 Type * FindFunction::postmutate( FunctionType * functionType ) { 71 77 Type *ret = functionType; 72 78 if ( predicate( functionType, tyVars ) ) { … … 77 83 } // if 78 84 } // if 79 tyVars.endScope();80 85 return ret; 81 86 } 82 87 83 Type * FindFunction::mutate( PointerType *pointerType ) {84 tyVars.beginScope();88 void FindFunction::premutate( PointerType * pointerType ) { 89 GuardScope( tyVars ); 85 90 handleForall( pointerType->get_forall() ); 86 Type *ret = Mutator::mutate( pointerType );87 tyVars.endScope();88 return ret;89 91 } 90 92 } // namespace GenPoly -
src/GenPoly/Specialize.cc
r3628765 rb7778c1 147 147 148 148 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 149 assertf( actual-> has_result(), "attempting to specialize an untyped expression" );149 assertf( actual->result, "attempting to specialize an untyped expression" ); 150 150 if ( needsSpecialization( formalType, actual->get_result(), env ) ) { 151 151 if ( FunctionType *funType = getFunctionType( formalType ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.