Changeset c14cff1
- Timestamp:
- Feb 25, 2016, 5:16:15 PM (7 years ago)
- Branches:
- 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, with_gc
- Children:
- 071a31a
- Parents:
- a9a259c (diff), ac1ed49 (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
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/GenType.cc
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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 } … … 935 962 TyVarMap exprTyVars; 936 963 makeTyVarMap( function, exprTyVars ); 937 ReferenceToType *polyRetType = 0;938 939 if ( polyRetType = isPolyRet( function )) {964 ReferenceToType *polyRetType = isPolyRet( function ); 965 966 if ( polyRetType ) { 940 967 ret = addPolyRetParam( appExpr, function, polyRetType, arg ); 941 968 } else if ( needsAdapter( function, scopeTyVars ) ) { … … 1043 1070 } else if ( ReferenceToType *refType = dynamic_cast< ReferenceToType *>( retval->get_type() ) ) { 1044 1071 // find assignment operator for generic type 1045 ScopedMap< std::string, DeclarationWithType *>::const_iterator assignIter = scopedAssignOps.find( refType->get_name());1046 if ( assignIter == scopedAssignOps.end()) {1072 DeclarationWithType *functionDecl = scopedAssignOps.find( refType ); 1073 if ( ! functionDecl ) { 1047 1074 throw SemanticError( "Attempt to return dtype or ftype generic object in ", returnStmt->get_expr() ); 1048 1075 } 1049 1076 1050 1077 // wrap it up in an application expression 1051 DeclarationWithType *functionDecl = assignIter->second;1052 1078 assignExpr = new ApplicationExpr( wrapFunctionDecl( functionDecl ) ); 1053 1079 assignExpr->set_env( env->clone() ); … … 1064 1090 assert( ! asserts.empty() && "Type param needs assignment operator assertion" ); 1065 1091 DeclarationWithType *actualDecl = asserts.front(); 1066 ReferenceToType *actualType = isAssignment( actualDecl );1092 TypeInstType *actualType = isTypeInstAssignment( actualDecl ); 1067 1093 assert( actualType && "First assertion of type with assertions should be assignment operator" ); 1068 1094 TypeExpr *formalTypeExpr = dynamic_cast< TypeExpr* >( *tyIt ); … … 1078 1104 } 1079 1105 assertAssign = assertAssignIt->second; 1080 //assignExpr->get_env()->add( formalTypeInstType->get_name(), actualType ); 1081 } else if ( ReferenceToType *formalReferenceType = dynamic_cast< ReferenceToType* >( formalType ) ) { 1082 ScopedMap< std::string, DeclarationWithType *>::const_iterator assertAssignIt = scopedAssignOps.find( formalReferenceType->get_name() ); 1083 if ( assertAssignIt == scopedAssignOps.end() ) { 1084 throw SemanticError( "No assignment operation found for ", formalReferenceType ); 1106 } else { 1107 assertAssign = scopedAssignOps.find( formalType ); 1108 if ( ! assertAssign ) { 1109 throw SemanticError( "No assignment operation found for ", formalType ); 1085 1110 } 1086 assertAssign = assertAssignIt->second; 1087 } else assert( false && "returning polymorphic types with non struct/polymorphic parameters not yet supported" ); 1111 } 1088 1112 1089 1113 … … 1425 1449 assert( newMemberExpr ); 1426 1450 1427 // wrap pointer members in appropriate cast 1428 if ( dynamic_cast< PointerType* >( memberExpr->get_member()->get_type() ) ) { 1429 CastExpr *ptrCastExpr = new CastExpr( newMemberExpr, new PointerType( Type::Qualifiers(), new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ) ) ); 1451 Type *memberType = memberExpr->get_member()->get_type(); 1452 if ( ! isPolyType( memberType, scopeTyVars ) ) { 1453 // 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 1454 CastExpr *ptrCastExpr = new CastExpr( newMemberExpr, new PointerType( Type::Qualifiers(), memberType->clone() ) ); 1430 1455 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 1431 1456 derefExpr->get_args().push_back( ptrCastExpr ); -
src/Makefile.in
ra9a259c rc14cff1 172 172 SynTree/driver_cfa_cpp-TypeofType.$(OBJEXT) \ 173 173 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT) \ 174 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) \ 174 175 SynTree/driver_cfa_cpp-Constant.$(OBJEXT) \ 175 176 SynTree/driver_cfa_cpp-Expression.$(OBJEXT) \ … … 370 371 SynTree/ArrayType.cc SynTree/FunctionType.cc \ 371 372 SynTree/ReferenceToType.cc SynTree/TupleType.cc \ 372 SynTree/TypeofType.cc SynTree/AttrType.cc SynTree/Constant.cc \ 373 SynTree/TypeofType.cc SynTree/AttrType.cc \ 374 SynTree/VarArgsType.cc SynTree/Constant.cc \ 373 375 SynTree/Expression.cc SynTree/TupleExpr.cc \ 374 376 SynTree/CommaExpr.cc SynTree/TypeExpr.cc \ … … 706 708 SynTree/driver_cfa_cpp-AttrType.$(OBJEXT): SynTree/$(am__dirstamp) \ 707 709 SynTree/$(DEPDIR)/$(am__dirstamp) 710 SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT): SynTree/$(am__dirstamp) \ 711 SynTree/$(DEPDIR)/$(am__dirstamp) 708 712 SynTree/driver_cfa_cpp-Constant.$(OBJEXT): SynTree/$(am__dirstamp) \ 709 713 SynTree/$(DEPDIR)/$(am__dirstamp) … … 871 875 -rm -f SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) 872 876 -rm -f SynTree/driver_cfa_cpp-TypeofType.$(OBJEXT) 877 -rm -f SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) 873 878 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 874 879 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) … … 979 984 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeSubstitution.Po@am__quote@ 980 985 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeofType.Po@am__quote@ 986 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@ 981 987 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 982 988 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ … … 2067 2073 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2068 2074 @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` 2075 2076 SynTree/driver_cfa_cpp-VarArgsType.o: SynTree/VarArgsType.cc 2077 @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 2078 @am__fastdepCXX_TRUE@ $(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po 2079 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SynTree/VarArgsType.cc' object='SynTree/driver_cfa_cpp-VarArgsType.o' libtool=no @AMDEPBACKSLASH@ 2080 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2081 @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 2082 2083 SynTree/driver_cfa_cpp-VarArgsType.obj: SynTree/VarArgsType.cc 2084 @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` 2085 @am__fastdepCXX_TRUE@ $(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po 2086 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SynTree/VarArgsType.cc' object='SynTree/driver_cfa_cpp-VarArgsType.obj' libtool=no @AMDEPBACKSLASH@ 2087 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2088 @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` 2069 2089 2070 2090 SynTree/driver_cfa_cpp-Constant.o: SynTree/Constant.cc -
src/ResolvExpr/AdjustExprType.cc
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Unify.cc -- 7 // Unify.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 38 38 WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; } 39 39 operator bool() { return widenFirst && widenSecond; } 40 40 41 41 bool widenFirst : 1, widenSecond : 1; 42 42 }; … … 45 45 public: 46 46 Unify( Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 47 47 48 48 bool get_result() const { return result; } 49 49 private: … … 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 ); … … 78 79 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common ); 79 80 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 80 81 81 82 bool typesCompatible( Type *first, Type *second, const SymTab::Indexer &indexer, const TypeEnvironment &env ) { 82 83 TypeEnvironment newEnv; … … 136 137 case TypeDecl::Dtype: 137 138 return ! isFtype( type, indexer ); 138 139 139 140 case TypeDecl::Ftype: 140 141 return isFtype( type, indexer ); … … 195 196 bool widen1 = false, widen2 = false; 196 197 Type *type1 = 0, *type2 = 0; 197 198 198 199 if ( env.lookup( var1->get_name(), class1 ) ) { 199 200 hasClass1 = true; … … 216 217 widen2 = widenMode.widenSecond && class2.allowWidening; 217 218 } // if 218 219 219 220 if ( type1 && type2 ) { 220 221 // std::cout << "has type1 && type2" << std::endl; … … 435 436 // to unify, array types must both be VLA or both not VLA 436 437 // and must both have a dimension expression or not have a dimension 437 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() 438 && ((arrayType->get_dimension() != 0 && otherArray->get_dimension() != 0) 439 || (arrayType->get_dimension() == 0 && otherArray->get_dimension() == 0))) { 438 if ( otherArray && arrayType->get_isVarLen() == otherArray->get_isVarLen() ) { 440 439 441 440 // not positive this is correct in all cases, but it's needed for typedefs … … 448 447 ConstantExpr * ce1 = dynamic_cast< ConstantExpr * >( arrayType->get_dimension() ); 449 448 ConstantExpr * ce2 = dynamic_cast< ConstantExpr * >( otherArray->get_dimension() ); 450 assert(ce1 && ce2); 451 452 Constant * c1 = ce1->get_constant(); 453 Constant * c2 = ce2->get_constant(); 454 455 if ( c1->get_value() != c2->get_value() ) { 456 // does not unify if the dimension is different 457 return; 449 // see C11 Reference Manual 6.7.6.2.6 450 // two array types with size specifiers that are integer constant expressions are 451 // compatible if both size specifiers have the same constant value 452 if ( ce1 && ce2 ) { 453 Constant * c1 = ce1->get_constant(); 454 Constant * c2 = ce2->get_constant(); 455 456 if ( c1->get_value() != c2->get_value() ) { 457 // does not unify if the dimension is different 458 return; 459 } 458 460 } 459 461 } … … 484 486 485 487 if ( unifyDeclList( functionType->get_parameters().begin(), functionType->get_parameters().end(), otherFunction->get_parameters().begin(), otherFunction->get_parameters().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) { 486 488 487 489 if ( unifyDeclList( functionType->get_returnVals().begin(), functionType->get_returnVals().end(), otherFunction->get_returnVals().begin(), otherFunction->get_returnVals().end(), env, needAssertions, haveAssertions, openVars, indexer ) ) { 488 490 … … 582 584 } 583 585 586 void Unify::visit(VarArgsType *varArgsType) { 587 result = dynamic_cast< VarArgsType* >( type2 ); 588 } 589 584 590 } // namespace ResolvExpr 585 591 -
src/SymTab/FixFunction.cc
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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/Expression.cc
ra9a259c rc14cff1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Expression.cc -- 7 // Expression.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 422 422 } 423 423 424 AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {} 425 426 424 427 void AsmExpr::print( std::ostream &os, int indent ) const { 425 428 os << "Asm Expression: " << std::endl; … … 429 432 } 430 433 434 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 435 436 UntypedValofExpr::~UntypedValofExpr() { delete body; } 437 431 438 void UntypedValofExpr::print( std::ostream &os, int indent ) const { 432 439 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl; … … 434 441 get_body()->print( os, indent + 2 ); 435 442 } 443 444 436 445 437 446 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
ra9a259c rc14cff1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Expression.h -- 7 // Expression.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 155 155 }; 156 156 157 // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack 157 158 class LabelAddressExpr : public Expression { 158 159 public: 159 160 LabelAddressExpr( Expression *arg ); 160 LabelAddressExpr( const AddressExpr &other );161 LabelAddressExpr( const LabelAddressExpr &other ); 161 162 virtual ~LabelAddressExpr(); 162 163 … … 251 252 }; 252 253 253 /// ConstantExpr represents an expression that simply refers to the value of a constant 254 /// ConstantExpr represents an expression that simply refers to the value of a constant 254 255 class ConstantExpr : public Expression { 255 256 public: … … 515 516 public: 516 517 AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 518 AsmExpr( const AsmExpr & other ); 517 519 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; 518 520 … … 541 543 public: 542 544 UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {} 543 virtual ~UntypedValofExpr() {} 545 UntypedValofExpr( const UntypedValofExpr & other ); 546 virtual ~UntypedValofExpr(); 544 547 545 548 Expression *get_value(); -
src/SynTree/Mutator.cc
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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/Statement.cc
ra9a259c rc14cff1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Statement.cc -- 7 // Statement.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 36 36 ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ) : Statement( _labels ), expr( _expr ) {} 37 37 38 ExprStmt::~ExprStmt() {} 38 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 39 40 ExprStmt::~ExprStmt() { 41 delete expr; 42 } 39 43 40 44 void ExprStmt::print( std::ostream &os, int indent ) const { 41 45 os << string( indent, ' ' ) << "Expression Statement:" << endl; 42 46 expr->print( os, indent + 2 ); 43 } 47 } 44 48 45 49 46 50 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} 51 52 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { 53 cloneAll( other.output, output ); 54 cloneAll( other.input, input ); 55 cloneAll( other.clobber, clobber ); 56 } 47 57 48 58 AsmStmt::~AsmStmt() { … … 60 70 os << endl << std::string( indent, ' ' ) << "output: " << endl; 61 71 printAll( output, os, indent + 2 ); 62 } // if 72 } // if 63 73 if ( ! input.empty() ) { 64 74 os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' ); … … 69 79 printAll( clobber, os, indent + 2 ); 70 80 } // if 71 } 81 } 72 82 73 83 … … 93 103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {} 94 104 105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {} 106 95 107 ReturnStmt::~ReturnStmt() { 96 108 delete expr; … … 106 118 Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {} 107 119 120 IfStmt::IfStmt( const IfStmt & other ) : 121 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {} 122 108 123 IfStmt::~IfStmt() {} 109 124 … … 123 138 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ): 124 139 Statement( _labels ), condition( _condition ), branches( _branches ) { 140 } 141 142 SwitchStmt::SwitchStmt( const SwitchStmt & other ): 143 Statement( other ), condition( maybeClone( other.condition ) ) { 144 cloneAll( other.branches, branches ); 125 145 } 126 146 … … 145 165 } 146 166 147 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 167 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 148 168 Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) { 149 169 if ( isDefault() && condition != 0 ) 150 170 throw SemanticError("default with conditions"); 171 } 172 173 CaseStmt::CaseStmt( const CaseStmt & other ) : 174 Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) { 175 cloneAll( other.stmts, stmts ); 151 176 } 152 177 … … 181 206 } 182 207 208 ChooseStmt::ChooseStmt( const ChooseStmt & other ): 209 Statement( other ), condition( maybeClone( other.condition ) ) { 210 cloneAll( other.branches, branches ); 211 } 212 183 213 ChooseStmt::~ChooseStmt() { 184 214 delete condition; … … 208 238 } 209 239 240 WhileStmt::WhileStmt( const WhileStmt & other ): 241 Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) { 242 } 243 210 244 WhileStmt::~WhileStmt() { 211 245 delete body; … … 223 257 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ): 224 258 Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) { 259 } 260 261 ForStmt::ForStmt( const ForStmt & other ): 262 Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ) { 263 cloneAll( other.initialization, initialization ); 264 225 265 } 226 266 … … 241 281 os << string( indent, ' ' ) << "For Statement" << endl ; 242 282 243 os << string( indent + 2, ' ' ) << "initialization: \n"; 283 os << string( indent + 2, ' ' ) << "initialization: \n"; 244 284 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) { 245 285 (*it)->print( os, indent + 4 ); 246 286 } 247 287 248 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 288 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 249 289 if ( condition != 0 ) 250 290 condition->print( os, indent + 4 ); 251 291 252 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 292 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 253 293 if ( increment != 0 ) 254 294 increment->print( os, indent + 4 ); 255 295 256 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 296 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 257 297 if ( body != 0 ) 258 298 body->print( os, indent + 4 ); … … 265 305 } 266 306 267 TryStmt::TryStmt( const TryStmt &other ) : Statement( other.labels ) { 268 block = other.block; 269 std::copy( other.handlers.begin(), other.handlers.end(), back_inserter( handlers ) ); 270 finallyBlock = other.finallyBlock; 307 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { 308 cloneAll( other.handlers, handlers ); 271 309 } 272 310 … … 294 332 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) : 295 333 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest ) { 334 } 335 336 CatchStmt::CatchStmt( const CatchStmt & other ) : 337 Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) { 296 338 } 297 339 … … 319 361 } 320 362 363 FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) { 364 } 365 321 366 FinallyStmt::~FinallyStmt() { 322 367 delete block; … … 331 376 NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {} 332 377 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} 333 NullStmt::~NullStmt() {}334 378 335 379 void NullStmt::print( std::ostream &os, int indent ) const { -
src/SynTree/Statement.h
ra9a259c rc14cff1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Statement.h -- 7 // Statement.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 57 57 public: 58 58 ExprStmt( std::list<Label> labels, Expression *expr ); 59 ExprStmt( const ExprStmt &other ); 59 60 virtual ~ExprStmt(); 60 61 … … 73 74 public: 74 75 AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 76 AsmStmt( const AsmStmt &other ); 75 77 virtual ~AsmStmt(); 76 78 … … 103 105 public: 104 106 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 107 IfStmt( const IfStmt &other ); 105 108 virtual ~IfStmt(); 106 109 … … 111 114 Statement *get_elsePart() { return elsePart; } 112 115 void set_elsePart( Statement *newValue ) { elsePart = newValue; } 113 116 114 117 virtual IfStmt *clone() const { return new IfStmt( *this ); } 115 118 virtual void accept( Visitor &v ) { v.visit( this ); } … … 125 128 public: 126 129 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 130 SwitchStmt( const SwitchStmt &other ); 127 131 virtual ~SwitchStmt(); 128 132 … … 146 150 public: 147 151 ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 152 ChooseStmt( const ChooseStmt &other ); 148 153 virtual ~ChooseStmt(); 149 154 … … 177 182 class CaseStmt : public Statement { 178 183 public: 179 CaseStmt( std::list<Label> labels, Expression *conditions, 184 CaseStmt( std::list<Label> labels, Expression *conditions, 180 185 std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 186 CaseStmt( const CaseStmt &other ); 181 187 virtual ~CaseStmt(); 182 188 … … 192 198 std::list<Statement *> &get_statements() { return stmts; } 193 199 void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; } 194 200 195 201 virtual void accept( Visitor &v ) { v.visit( this ); } 196 202 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 208 214 WhileStmt( std::list<Label> labels, Expression *condition, 209 215 Statement *body, bool isDoWhile = false ); 216 WhileStmt( const WhileStmt &other ); 210 217 virtual ~WhileStmt(); 211 218 … … 216 223 bool get_isDoWhile() { return isDoWhile; } 217 224 void set_isDoWhile( bool newValue ) { isDoWhile = newValue; } 218 225 219 226 virtual WhileStmt *clone() const { return new WhileStmt( *this ); } 220 227 virtual void accept( Visitor &v ) { v.visit( this ); } … … 231 238 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 232 239 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 240 ForStmt( const ForStmt &other ); 233 241 virtual ~ForStmt(); 234 242 … … 241 249 Statement *get_body() { return body; } 242 250 void set_body( Statement *newValue ) { body = newValue; } 243 251 244 252 virtual ForStmt *clone() const { return new ForStmt( *this ); } 245 253 virtual void accept( Visitor &v ) { v.visit( this ); } … … 259 267 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); 260 268 BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError); 261 virtual ~BranchStmt() {}262 269 263 270 Label get_originalTarget() { return originalTarget; } 264 271 Label get_target() { return target; } 265 272 void set_target( Label newValue ) { target = newValue; } 266 273 267 274 Expression *get_computedTarget() { return computedTarget; } 268 275 void set_target( Expression * newValue ) { computedTarget = newValue; } … … 286 293 public: 287 294 ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false ); 295 ReturnStmt( const ReturnStmt &other ); 288 296 virtual ~ReturnStmt(); 289 297 290 298 Expression *get_expr() { return expr; } 291 299 void set_expr( Expression *newValue ) { expr = newValue; } 292 300 293 301 virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); } 294 302 virtual void accept( Visitor &v ) { v.visit( this ); } … … 305 313 NullStmt(); 306 314 NullStmt( std::list<Label> labels ); 307 virtual ~NullStmt();308 315 309 316 virtual NullStmt *clone() const { return new NullStmt( *this ); } … … 311 318 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 312 319 virtual void print( std::ostream &os, int indent = 0 ) const; 313 314 private: 315 }; 316 317 class TryStmt : public Statement { 320 321 private: 322 }; 323 324 class TryStmt : public Statement { 318 325 public: 319 326 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 ); … … 332 339 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 333 340 virtual void print( std::ostream &os, int indent = 0 ) const; 334 341 335 342 private: 336 343 CompoundStmt *block; 337 344 std::list<Statement *> handlers; 338 345 FinallyStmt *finallyBlock; 339 }; 346 }; 340 347 341 348 class CatchStmt : public Statement { 342 349 public: 343 350 CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false ); 351 CatchStmt( const CatchStmt &other ); 344 352 virtual ~CatchStmt(); 345 353 … … 349 357 Statement *get_body() { return body; } 350 358 void set_body( Statement *newValue ) { body = newValue; } 351 359 352 360 virtual CatchStmt *clone() const { return new CatchStmt( *this ); } 353 361 virtual void accept( Visitor &v ) { v.visit( this ); } 354 362 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 355 363 virtual void print( std::ostream &os, int indent = 0 ) const; 356 364 357 365 private: 358 366 Declaration *decl; … … 361 369 }; 362 370 363 class FinallyStmt : public Statement { 371 class FinallyStmt : public Statement { 364 372 public: 365 373 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 374 FinallyStmt( const FinallyStmt &other ); 366 375 virtual ~FinallyStmt(); 367 376 368 377 CompoundStmt *get_block() const { return block; } 369 378 void set_block( CompoundStmt *newValue ) { block = newValue; } 370 379 371 380 virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); } 372 381 virtual void accept( Visitor &v ) { v.visit( this ); } … … 375 384 private: 376 385 CompoundStmt *block; 377 }; 386 }; 378 387 379 388 -
src/SynTree/SynTree.h
ra9a259c rc14cff1 97 97 class TypeofType; 98 98 class AttrType; 99 class VarArgsType; 99 100 100 101 class Initializer; -
src/SynTree/Type.h
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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
ra9a259c rc14cff1 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.