Changeset ac1ed49
- Timestamp:
- Feb 25, 2016, 5:14:15 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, 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:
- 33e6a2cc, 90c3b1c, c14cff1
- Parents:
- 41a2620 (diff), 44b7088 (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
- Files:
-
- 2 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
r41a2620 rac1ed49 39 39 virtual void visit( EnumInstType *enumInst ); 40 40 virtual void visit( TypeInstType *typeInst ); 41 virtual void visit( VarArgsType *varArgsType ); 41 42 42 43 private: … … 191 192 } 192 193 194 void GenType::visit( VarArgsType *varArgsType ) { 195 typeString = "__builtin_va_list " + typeString; 196 // don't handle qualifiers, var args pack shouldn't have any 197 } 198 193 199 void GenType::handleQualifiers( Type *type ) { 194 200 if ( type->get_isConst() ) { -
src/GenPoly/Box.cc
r41a2620 rac1ed49 25 25 #include "PolyMutator.h" 26 26 #include "FindFunction.h" 27 #include "ScopedMap.h"28 27 #include "ScrubTyVars.h" 29 28 … … 38 37 39 38 #include "ResolvExpr/TypeEnvironment.h" 39 #include "ResolvExpr/TypeMap.h" 40 #include "ResolvExpr/typeops.h" 40 41 41 42 #include "SymTab/Mangler.h" … … 101 102 typedef std::map< std::string, DeclarationWithType *> AdapterMap; 102 103 std::map< std::string, DeclarationWithType *> assignOps; 103 ScopedMap< std::string, DeclarationWithType *> scopedAssignOps;104 ResolvExpr::TypeMap< DeclarationWithType > scopedAssignOps; 104 105 std::stack< AdapterMap > adapters; 105 106 DeclarationWithType *retval; … … 248 249 } 249 250 250 /// returns T if the given declaration is: (*?=?)(T *, T) for some T (return not checked, but maybe should be), NULL otherwise251 ReferenceToType *isAssignment( DeclarationWithType *decl ) {251 /// Returns T if the given declaration is (*?=?)(T *, T) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise 252 TypeInstType *isTypeInstAssignment( DeclarationWithType *decl ) { 252 253 if ( decl->get_name() == "?=?" ) { 253 254 if ( FunctionType *funType = getFunctionType( decl->get_type() ) ) { 254 255 if ( funType->get_parameters().size() == 2 ) { 255 256 if ( PointerType *pointer = dynamic_cast< PointerType *>( funType->get_parameters().front()->get_type() ) ) { 256 if ( ReferenceToType *refType = dynamic_cast< ReferenceToType *>( pointer->get_base() ) ) {257 if ( ReferenceToType *refType2 = dynamic_cast< ReferenceToType *>( funType->get_parameters().back()->get_type() ) ) {257 if ( TypeInstType *refType = dynamic_cast< TypeInstType *>( pointer->get_base() ) ) { 258 if ( TypeInstType *refType2 = dynamic_cast< TypeInstType *>( funType->get_parameters().back()->get_type() ) ) { 258 259 if ( refType->get_name() == refType2->get_name() ) { 259 260 return refType; … … 267 268 return 0; 268 269 } 270 271 /// returns T if the given declaration is: (*?=?)(T *, T) for some type T (return not checked, but maybe should be), NULL otherwise 272 /// Only picks assignments where neither parameter is cv-qualified 273 Type *isAssignment( DeclarationWithType *decl ) { 274 if ( decl->get_name() == "?=?" ) { 275 if ( FunctionType *funType = getFunctionType( decl->get_type() ) ) { 276 if ( funType->get_parameters().size() == 2 ) { 277 Type::Qualifiers defaultQualifiers; 278 Type *paramType1 = funType->get_parameters().front()->get_type(); 279 if ( paramType1->get_qualifiers() != defaultQualifiers ) return 0; 280 Type *paramType2 = funType->get_parameters().back()->get_type(); 281 if ( paramType2->get_qualifiers() != defaultQualifiers ) return 0; 282 283 if ( PointerType *pointerType = dynamic_cast< PointerType* >( paramType1 ) ) { 284 Type *baseType1 = pointerType->get_base(); 285 if ( baseType1->get_qualifiers() != defaultQualifiers ) return 0; 286 SymTab::Indexer dummy; 287 if ( ResolvExpr::typesCompatible( baseType1, paramType2, dummy ) ) { 288 return baseType1; 289 } // if 290 } // if 291 } // if 292 } // if 293 } // if 294 return 0; 295 } 269 296 270 297 void Pass1::findAssignOps( const std::list< TypeDecl *> &forall ) { … … 274 301 for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 275 302 std::string typeName; 276 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( isAssignment( *assert )) ) {303 if ( TypeInstType *typeInst = isTypeInstAssignment( *assert ) ) { 277 304 assignOps[ typeInst->get_name() ] = *assert; 278 305 } // if … … 283 310 DeclarationWithType *Pass1::mutate( FunctionDecl *functionDecl ) { 284 311 // if this is a polymorphic assignment function, put it in the map for this scope 285 if ( ReferenceToType *refType = isAssignment( functionDecl ) ) {286 if ( ! dynamic_cast< TypeInstType* >( refType ) ) {287 scopedAssignOps.insert( refType->get_name(), functionDecl );312 if ( Type *assignedType = isAssignment( functionDecl ) ) { 313 if ( ! dynamic_cast< TypeInstType* >( assignedType ) ) { 314 scopedAssignOps.insert( assignedType, functionDecl ); 288 315 } 289 316 } … … 934 961 TyVarMap exprTyVars; 935 962 makeTyVarMap( function, exprTyVars ); 936 ReferenceToType *polyRetType = 0;937 938 if ( polyRetType = isPolyRet( function )) {963 ReferenceToType *polyRetType = isPolyRet( function ); 964 965 if ( polyRetType ) { 939 966 ret = addPolyRetParam( appExpr, function, polyRetType, arg ); 940 967 } else if ( needsAdapter( function, scopeTyVars ) ) { … … 1042 1069 } else if ( ReferenceToType *refType = dynamic_cast< ReferenceToType *>( retval->get_type() ) ) { 1043 1070 // find assignment operator for generic type 1044 ScopedMap< std::string, DeclarationWithType *>::const_iterator assignIter = scopedAssignOps.find( refType->get_name());1045 if ( assignIter == scopedAssignOps.end()) {1071 DeclarationWithType *functionDecl = scopedAssignOps.find( refType ); 1072 if ( ! functionDecl ) { 1046 1073 throw SemanticError( "Attempt to return dtype or ftype generic object in ", returnStmt->get_expr() ); 1047 1074 } 1048 1075 1049 1076 // wrap it up in an application expression 1050 DeclarationWithType *functionDecl = assignIter->second;1051 1077 assignExpr = new ApplicationExpr( wrapFunctionDecl( functionDecl ) ); 1052 1078 assignExpr->set_env( env->clone() ); … … 1063 1089 assert( ! asserts.empty() && "Type param needs assignment operator assertion" ); 1064 1090 DeclarationWithType *actualDecl = asserts.front(); 1065 ReferenceToType *actualType = isAssignment( actualDecl );1091 TypeInstType *actualType = isTypeInstAssignment( actualDecl ); 1066 1092 assert( actualType && "First assertion of type with assertions should be assignment operator" ); 1067 1093 TypeExpr *formalTypeExpr = dynamic_cast< TypeExpr* >( *tyIt ); … … 1077 1103 } 1078 1104 assertAssign = assertAssignIt->second; 1079 //assignExpr->get_env()->add( formalTypeInstType->get_name(), actualType ); 1080 } else if ( ReferenceToType *formalReferenceType = dynamic_cast< ReferenceToType* >( formalType ) ) { 1081 ScopedMap< std::string, DeclarationWithType *>::const_iterator assertAssignIt = scopedAssignOps.find( formalReferenceType->get_name() ); 1082 if ( assertAssignIt == scopedAssignOps.end() ) { 1083 throw SemanticError( "No assignment operation found for ", formalReferenceType ); 1105 } else { 1106 assertAssign = scopedAssignOps.find( formalType ); 1107 if ( ! assertAssign ) { 1108 throw SemanticError( "No assignment operation found for ", formalType ); 1084 1109 } 1085 assertAssign = assertAssignIt->second; 1086 } else assert( false && "returning polymorphic types with non struct/polymorphic parameters not yet supported" ); 1110 } 1087 1111 1088 1112 … … 1424 1448 assert( newMemberExpr ); 1425 1449 1426 // wrap pointer members in appropriate cast 1427 if ( dynamic_cast< PointerType* >( memberExpr->get_member()->get_type() ) ) { 1428 CastExpr *ptrCastExpr = new CastExpr( newMemberExpr, new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ) ) ); 1450 Type *memberType = memberExpr->get_member()->get_type(); 1451 if ( ! isPolyType( memberType, scopeTyVars ) ) { 1452 // Not all members of a polymorphic type are themselves of polymorphic type; in this case the member expression should be wrapped and dereferenced to form an lvalue 1453 CastExpr *ptrCastExpr = new CastExpr( newMemberExpr, new PointerType( Type::Qualifiers(), memberType->clone() ) ); 1429 1454 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 1430 1455 derefExpr->get_args().push_back( ptrCastExpr ); -
src/Makefile.in
r41a2620 rac1ed49 171 171 SynTree/driver_cfa_cpp-TypeofType.$(OBJEXT) \ 172 172 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \ 173 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \ 173 174 SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \ 174 175 SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \ … … 369 370 SynTree/ArrayType.cc SynTree/FunctionType.cc \ 370 371 SynTree/ReferenceToType.cc SynTree/TupleType.cc \ 371 SynTree/TypeofType.cc SynTree/AttrType.cc SynTree/Constant.cc \ 372 SynTree/TypeofType.cc SynTree/AttrType.cc \ 373 SynTree/VarArgsType.cc SynTree/Constant.cc \ 372 374 SynTree/Expression.cc SynTree/TupleExpr.cc \ 373 375 SynTree/CommaExpr.cc SynTree/TypeExpr.cc \ … … 703 705 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT): SynTree/$(am__dirstamp) \ 704 706 SynTree/$(DEPDIR)/$(am__dirstamp) 707 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 708 SynTree/$(DEPDIR)/$(am__dirstamp) 705 709 SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \ 706 710 SynTree/$(DEPDIR)/$(am__dirstamp) … … 867 871 -rm -f SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) 868 872 -rm -f SynTree/driver_cfa_cpp-TypeofType.$(OBJEXT) 873 -rm -f SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) 869 874 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 870 875 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) … … 974 979 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeSubstitution.Po@am__quote@ 975 980 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeofType.Po@am__quote@ 981 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@ 976 982 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 977 983 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ … … 2048 2054 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2049 2055 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-AttrType.obj `if test -f 'SynTree/AttrType.cc'; then $(CYGPATH_W) 'SynTree/AttrType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/AttrType.cc'; fi` 2056 2057 SynTree/driver_cfa_cpp-VarArgsType.o: SynTree/VarArgsType.cc 2058 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarArgsType.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Tpo -c -o SynTree/driver_cfa_cpp-VarArgsType.o `test -f 'SynTree/VarArgsType.cc' || echo '$(srcdir)/'`SynTree/VarArgsType.cc 2059 @am__fastdepCXX_TRUE@ $(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po 2060 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SynTree/VarArgsType.cc' object='SynTree/driver_cfa_cpp-VarArgsType.o' libtool=no @AMDEPBACKSLASH@ 2061 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2062 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarArgsType.o `test -f 'SynTree/VarArgsType.cc' || echo '$(srcdir)/'`SynTree/VarArgsType.cc 2063 2064 SynTree/driver_cfa_cpp-VarArgsType.obj: SynTree/VarArgsType.cc 2065 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarArgsType.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Tpo -c -o SynTree/driver_cfa_cpp-VarArgsType.obj `if test -f 'SynTree/VarArgsType.cc'; then $(CYGPATH_W) 'SynTree/VarArgsType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarArgsType.cc'; fi` 2066 @am__fastdepCXX_TRUE@ $(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po 2067 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SynTree/VarArgsType.cc' object='SynTree/driver_cfa_cpp-VarArgsType.obj' libtool=no @AMDEPBACKSLASH@ 2068 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2069 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarArgsType.obj `if test -f 'SynTree/VarArgsType.cc'; then $(CYGPATH_W) 'SynTree/VarArgsType.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarArgsType.cc'; fi` 2050 2070 2051 2071 SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc -
src/ResolvExpr/AdjustExprType.cc
r41a2620 rac1ed49 36 36 virtual Type* mutate( TypeInstType *aggregateUseType ); 37 37 virtual Type* mutate( TupleType *tupleType ); 38 virtual Type* mutate( VarArgsType *varArgsType ); 38 39 39 40 const TypeEnvironment &env; … … 111 112 return tupleType; 112 113 } 114 115 Type *AdjustExprType::mutate( VarArgsType *varArgsType ) { 116 return varArgsType; 117 } 113 118 } // namespace ResolvExpr 114 119 -
src/ResolvExpr/AlternativeFinder.cc
r41a2620 rac1ed49 572 572 573 573 AltList candidates; 574 SemanticError errors; 574 575 575 576 for ( AltList::const_iterator func = funcFinder.alternatives.begin(); func != funcFinder.alternatives.end(); ++func ) { 576 PRINT( 577 std::cerr << "working on alternative: " << std::endl; 578 func->print( std::cerr, 8 ); 579 ) 580 // check if the type is pointer to function 581 PointerType *pointer; 582 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) { 583 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 584 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 585 // XXX 586 //Designators::check_alternative( function, *actualAlt ); 587 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) ); 588 } 589 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( pointer->get_base() ) ) { 590 EqvClass eqvClass; 591 if ( func->env.lookup( typeInst->get_name(), eqvClass ) && eqvClass.type ) { 592 if ( FunctionType *function = dynamic_cast< FunctionType* >( eqvClass.type ) ) { 593 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 594 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) ); 595 } // for 577 try { 578 PRINT( 579 std::cerr << "working on alternative: " << std::endl; 580 func->print( std::cerr, 8 ); 581 ) 582 // check if the type is pointer to function 583 PointerType *pointer; 584 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) { 585 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 586 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 587 // XXX 588 //Designators::check_alternative( function, *actualAlt ); 589 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) ); 590 } 591 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( pointer->get_base() ) ) { 592 EqvClass eqvClass; 593 if ( func->env.lookup( typeInst->get_name(), eqvClass ) && eqvClass.type ) { 594 if ( FunctionType *function = dynamic_cast< FunctionType* >( eqvClass.type ) ) { 595 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 596 makeFunctionAlternatives( *func, function, *actualAlt, std::back_inserter( candidates ) ); 597 } // for 598 } // if 596 599 } // if 597 600 } // if 601 } else { 602 // seek a function operator that's compatible 603 if ( ! doneInit ) { 604 doneInit = true; 605 NameExpr *opExpr = new NameExpr( "?()" ); 606 try { 607 funcOpFinder.findWithAdjustment( opExpr ); 608 } catch( SemanticError &e ) { 609 // it's ok if there aren't any defined function ops 610 } 611 PRINT( 612 std::cerr << "known function ops:" << std::endl; 613 printAlts( funcOpFinder.alternatives, std::cerr, 8 ); 614 ) 615 } 616 617 for ( AltList::const_iterator funcOp = funcOpFinder.alternatives.begin(); funcOp != funcOpFinder.alternatives.end(); ++funcOp ) { 618 // check if the type is pointer to function 619 PointerType *pointer; 620 if ( funcOp->expr->get_results().size() == 1 621 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 622 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 623 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 624 AltList currentAlt; 625 currentAlt.push_back( *func ); 626 currentAlt.insert( currentAlt.end(), actualAlt->begin(), actualAlt->end() ); 627 makeFunctionAlternatives( *funcOp, function, currentAlt, std::back_inserter( candidates ) ); 628 } // for 629 } // if 630 } // if 631 } // for 598 632 } // if 599 } else { 600 // seek a function operator that's compatible 601 if ( ! doneInit ) { 602 doneInit = true; 603 NameExpr *opExpr = new NameExpr( "?()" ); 604 try { 605 funcOpFinder.findWithAdjustment( opExpr ); 606 } catch( SemanticError &e ) { 607 // it's ok if there aren't any defined function ops 608 } 609 PRINT( 610 std::cerr << "known function ops:" << std::endl; 611 printAlts( funcOpFinder.alternatives, std::cerr, 8 ); 612 ) 613 } 614 615 for ( AltList::const_iterator funcOp = funcOpFinder.alternatives.begin(); funcOp != funcOpFinder.alternatives.end(); ++funcOp ) { 616 // check if the type is pointer to function 617 PointerType *pointer; 618 if ( funcOp->expr->get_results().size() == 1 619 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 620 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 621 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { 622 AltList currentAlt; 623 currentAlt.push_back( *func ); 624 currentAlt.insert( currentAlt.end(), actualAlt->begin(), actualAlt->end() ); 625 makeFunctionAlternatives( *funcOp, function, currentAlt, std::back_inserter( candidates ) ); 626 } // for 627 } // if 628 } // if 629 } // for 630 } // if 631 } // for 633 } catch ( SemanticError &e ) { 634 errors.append( e ); 635 } 636 } // for 637 638 // Implement SFINAE; resolution errors are only errors if there aren't any non-erroneous resolutions 639 if ( candidates.empty() && ! errors.isEmpty() ) { throw errors; } 632 640 633 641 for ( AltList::iterator withFunc = candidates.begin(); withFunc != candidates.end(); ++withFunc ) { -
src/ResolvExpr/CommonType.cc
r41a2620 rac1ed49 38 38 virtual void visit( TypeInstType *aggregateUseType ); 39 39 virtual void visit( TupleType *tupleType ); 40 virtual void visit( VarArgsType *varArgsType ); 40 41 41 42 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 213 214 void CommonType::visit( TupleType *tupleType ) { 214 215 } 216 217 void CommonType::visit( VarArgsType *varArgsType ) { 218 } 215 219 } // namespace ResolvExpr 216 220 -
src/ResolvExpr/ConversionCost.cc
r41a2620 rac1ed49 247 247 } // if 248 248 } 249 250 void ConversionCost::visit(VarArgsType *varArgsType) { 251 if ( VarArgsType *destAsVarArgs = dynamic_cast< VarArgsType* >( dest ) ) { 252 cost = Cost::zero; 253 } 254 } 249 255 } // namespace ResolvExpr 250 256 -
src/ResolvExpr/ConversionCost.h
r41a2620 rac1ed49 40 40 virtual void visit(TypeInstType *aggregateUseType); 41 41 virtual void visit(TupleType *tupleType); 42 virtual void visit(VarArgsType *varArgsType); 42 43 protected: 43 44 Type *dest; -
src/ResolvExpr/PtrsAssignable.cc
r41a2620 rac1ed49 38 38 virtual void visit( TypeInstType *inst ); 39 39 virtual void visit( TupleType *tupleType ); 40 virtual void visit( VarArgsType *varArgsType ); 40 41 private: 41 42 Type *dest; … … 137 138 /// } 138 139 } 140 141 void PtrsAssignable::visit( VarArgsType *varArgsType ) { 142 } 139 143 } // namespace ResolvExpr 140 144 -
src/ResolvExpr/PtrsCastable.cc
r41a2620 rac1ed49 39 39 virtual void visit(TypeInstType *inst); 40 40 virtual void visit(TupleType *tupleType); 41 virtual void visit(VarArgsType *varArgsType); 41 42 private: 42 43 Type *dest; … … 139 140 result = objectCast( dest, env, indexer ); 140 141 } 142 143 void PtrsCastable::visit(VarArgsType *varArgsType) { 144 result = objectCast( dest, env, indexer ); 145 } 141 146 } // namespace ResolvExpr 142 147 -
src/ResolvExpr/RenameVars.cc
r41a2620 rac1ed49 113 113 } 114 114 115 void RenameVars::visit( VarArgsType *varArgsType ) { 116 typeBefore( varArgsType ); 117 typeAfter( varArgsType ); 118 } 119 115 120 void RenameVars::typeBefore( Type *type ) { 116 121 if ( ! type->get_forall().empty() ) { -
src/ResolvExpr/RenameVars.h
r41a2620 rac1ed49 43 43 virtual void visit( TypeInstType *aggregateUseType ); 44 44 virtual void visit( TupleType *tupleType ); 45 virtual void visit( VarArgsType *varArgsType ); 45 46 46 47 void typeBefore( Type *type ); -
src/ResolvExpr/Unify.cc
r41a2620 rac1ed49 59 59 virtual void visit(TypeInstType *aggregateUseType); 60 60 virtual void visit(TupleType *tupleType); 61 virtual void visit(VarArgsType *varArgsType); 61 62 62 63 template< typename RefType > void handleRefType( RefType *inst, Type *other ); … … 583 584 } 584 585 586 void Unify::visit(VarArgsType *varArgsType) { 587 result = dynamic_cast< VarArgsType* >( type2 ); 588 } 589 585 590 } // namespace ResolvExpr 586 591 -
src/SymTab/FixFunction.cc
r41a2620 rac1ed49 72 72 return tupleType; 73 73 } 74 75 Type * FixFunction::mutate(VarArgsType *varArgsType) { 76 return varArgsType; 77 } 74 78 } // namespace SymTab 75 79 -
src/SymTab/FixFunction.h
r41a2620 rac1ed49 41 41 virtual Type* mutate(TypeInstType *aggregateUseType); 42 42 virtual Type* mutate(TupleType *tupleType); 43 virtual Type* mutate(VarArgsType *varArgsType); 43 44 44 45 bool isVoid; -
src/SymTab/ImplementationType.cc
r41a2620 rac1ed49 40 40 virtual void visit(TypeInstType *aggregateUseType); 41 41 virtual void visit(TupleType *tupleType); 42 virtual void visit(VarArgsType *varArgsType); 42 43 43 44 Type *result; // synthesized … … 116 117 result = newType; 117 118 } 119 120 void ImplementationType::visit(VarArgsType *varArgsType) { 121 } 118 122 } // namespace SymTab 119 123 -
src/SymTab/Mangler.cc
r41a2620 rac1ed49 224 224 acceptAll( tupleType->get_types(), *this ); 225 225 mangleName << "_"; 226 } 227 228 void Mangler::visit( VarArgsType *varArgsType ) { 229 mangleName << "VARGS"; 226 230 } 227 231 -
src/SymTab/Mangler.h
r41a2620 rac1ed49 45 45 virtual void visit( TypeInstType *aggregateUseType ); 46 46 virtual void visit( TupleType *tupleType ); 47 virtual void visit( VarArgsType *varArgsType ); 47 48 48 49 std::string get_mangleName() { return mangleName.str(); } -
src/SymTab/TypeEquality.cc
r41a2620 rac1ed49 41 41 virtual void visit( EnumInstType *enumInst ); 42 42 virtual void visit( TypeInstType *typeInst ); 43 virtual void visit( VarArgsType *varArgsType ); 43 44 44 45 void handleQualifiers( Type * t ); … … 191 192 } 192 193 } 194 195 void TypeEquality::visit( VarArgsType *varArgsType ) { 196 // don't handle qualifiers; var args pack shouldn't have any 197 if ( ! dynamic_cast< VarArgsType * >( other ) ) { 198 result = false; 199 } 200 } 193 201 } // namespace SymTab -
src/SynTree/Mutator.cc
r41a2620 rac1ed49 421 421 } 422 422 423 Type *Mutator::mutate( VarArgsType *varArgsType ) { 424 mutateAll( varArgsType->get_forall(), *this ); 425 return varArgsType; 426 } 427 423 428 Initializer *Mutator::mutate( SingleInit *singleInit ) { 424 429 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); -
src/SynTree/Mutator.h
r41a2620 rac1ed49 90 90 virtual Type* mutate( TypeofType *typeofType ); 91 91 virtual Type* mutate( AttrType *attrType ); 92 virtual Type* mutate( VarArgsType *varArgsType ); 92 93 93 94 virtual Initializer* mutate( SingleInit *singleInit ); -
src/SynTree/SynTree.h
r41a2620 rac1ed49 97 97 class TypeofType; 98 98 class AttrType; 99 class VarArgsType; 99 100 100 101 class Initializer; -
src/SynTree/Type.h
r41a2620 rac1ed49 400 400 }; 401 401 402 /// Represents the GCC built-in varargs type 403 class VarArgsType : public Type { 404 VarArgsType(); 405 406 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } 407 virtual void accept( Visitor &v ) { v.visit( this ); } 408 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 409 virtual void print( std::ostream &os, int indent = 0 ) const; 410 }; 411 402 412 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 403 413 isConst |= other.isConst; -
src/SynTree/TypeSubstitution.cc
r41a2620 rac1ed49 198 198 } 199 199 200 Type * TypeSubstitution::mutate( VarArgsType *varArgsType ) { 201 return handleType( varArgsType ); 202 } 203 200 204 void TypeSubstitution::print( std::ostream &os, int indent ) const { 201 205 os << std::string( indent, ' ' ) << "Types:" << std::endl; -
src/SynTree/TypeSubstitution.h
r41a2620 rac1ed49 74 74 virtual Type* mutate(ContextInstType *aggregateUseType); 75 75 virtual Type* mutate(TupleType *tupleType); 76 virtual Type* mutate(VarArgsType *varArgsType); 76 77 77 78 // TODO: worry about traversing into a forall-qualified function type or type decl with assertions -
src/SynTree/Visitor.cc
r41a2620 rac1ed49 355 355 } 356 356 357 void Visitor::visit( VarArgsType *varArgsType ) { 358 acceptAll( varArgsType->get_forall(), *this ); 359 } 360 357 361 void Visitor::visit( SingleInit *singleInit ) { 358 362 singleInit->get_value()->accept( *this ); -
src/SynTree/Visitor.h
r41a2620 rac1ed49 90 90 virtual void visit( TypeofType *typeofType ); 91 91 virtual void visit( AttrType *attrType ); 92 virtual void visit( VarArgsType *varArgsType ); 92 93 93 94 virtual void visit( SingleInit *singleInit ); -
src/SynTree/module.mk
r41a2620 rac1ed49 25 25 SynTree/TypeofType.cc \ 26 26 SynTree/AttrType.cc \ 27 SynTree/VarArgsType.cc \ 27 28 SynTree/Constant.cc \ 28 29 SynTree/Expression.cc \
Note: See TracChangeset
for help on using the changeset viewer.