Changes in / [84118d8:b726084]
- Location:
- src
- Files:
-
- 12 added
- 5 deleted
- 62 edited
-
CodeGen/CodeGenerator.cc (modified) (4 diffs)
-
CodeGen/CodeGenerator.h (modified) (1 diff)
-
CodeGen/GenType.cc (modified) (1 diff)
-
Common/utility.h (modified) (2 diffs)
-
ControlStruct/LabelTypeChecker.cc (deleted)
-
ControlStruct/LabelTypeChecker.h (deleted)
-
ControlStruct/Mutate.cc (modified) (2 diffs)
-
ControlStruct/module.mk (modified) (2 diffs)
-
GenPoly/Box.cc (modified) (26 diffs)
-
GenPoly/CopyParams.cc (modified) (1 diff)
-
GenPoly/FindFunction.cc (modified) (2 diffs)
-
GenPoly/GenPoly.cc (modified) (3 diffs)
-
GenPoly/Lvalue.cc (modified) (8 diffs)
-
GenPoly/Specialize.cc (modified) (4 diffs)
-
InitTweak/FixInit.cc (modified) (15 diffs)
-
InitTweak/GenInit.cc (modified) (10 diffs)
-
InitTweak/GenInit.h (modified) (2 diffs)
-
InitTweak/InitTweak.cc (modified) (3 diffs)
-
Makefile.in (modified) (14 diffs)
-
Parser/ExpressionNode.cc (modified) (2 diffs)
-
Parser/ParseNode.h (modified) (3 diffs)
-
Parser/TypeData.cc (modified) (2 diffs)
-
Parser/parser.cc (modified) (550 diffs)
-
Parser/parser.yy (modified) (3 diffs)
-
ResolvExpr/Alternative.cc (modified) (5 diffs)
-
ResolvExpr/Alternative.h (modified) (3 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (31 diffs)
-
ResolvExpr/AlternativeFinder.h (modified) (2 diffs)
-
ResolvExpr/AlternativePrinter.cc (modified) (2 diffs)
-
ResolvExpr/ConversionCost.cc (modified) (1 diff)
-
ResolvExpr/FindOpenVars.cc (modified) (3 diffs)
-
ResolvExpr/RenameVars.cc (modified) (2 diffs)
-
ResolvExpr/ResolveTypeof.cc (modified) (2 diffs)
-
ResolvExpr/Resolver.cc (modified) (7 diffs)
-
ResolvExpr/TypeEnvironment.cc (modified) (1 diff)
-
ResolvExpr/TypeEnvironment.h (modified) (1 diff)
-
ResolvExpr/Unify.cc (modified) (1 diff)
-
ResolvExpr/typeops.h (modified) (6 diffs)
-
SymTab/Autogen.cc (modified) (1 diff)
-
SymTab/Indexer.cc (modified) (12 diffs)
-
SymTab/Indexer.h (modified) (1 diff)
-
SymTab/Mangler.cc (modified) (4 diffs)
-
SymTab/Validate.cc (modified) (3 diffs)
-
SynTree/AddressExpr.cc (modified) (2 diffs)
-
SynTree/ApplicationExpr.cc (modified) (2 diffs)
-
SynTree/CommaExpr.cc (modified) (1 diff)
-
SynTree/CompoundStmt.cc (modified) (2 diffs)
-
SynTree/Expression.cc (modified) (21 diffs)
-
SynTree/Expression.h (modified) (9 diffs)
-
SynTree/Initializer.h (modified) (1 diff)
-
SynTree/Mutator.cc (modified) (20 diffs)
-
SynTree/Mutator.h (modified) (2 diffs)
-
SynTree/ReferenceToType.cc (modified) (1 diff)
-
SynTree/SynTree.h (modified) (2 diffs)
-
SynTree/TupleExpr.cc (modified) (3 diffs)
-
SynTree/TupleType.cc (modified) (2 diffs)
-
SynTree/Type.h (modified) (8 diffs)
-
SynTree/TypeSubstitution.cc (modified) (3 diffs)
-
SynTree/VarExprReplacer.cc (added)
-
SynTree/VarExprReplacer.h (added)
-
SynTree/Visitor.cc (modified) (11 diffs)
-
SynTree/Visitor.h (modified) (2 diffs)
-
SynTree/module.mk (modified) (1 diff)
-
Tuples/Explode.cc (added)
-
Tuples/Explode.h (added)
-
Tuples/NameMatcher.cc (deleted)
-
Tuples/NameMatcher.h (deleted)
-
Tuples/TupleAssignment.cc (modified) (3 diffs)
-
Tuples/TupleAssignment.h (deleted)
-
Tuples/TupleExpansion.cc (added)
-
Tuples/Tuples.h (added)
-
Tuples/module.mk (modified) (2 diffs)
-
main.cc (modified) (4 diffs)
-
tests/.expect/tupleAssign.txt (added)
-
tests/.expect/tupleFunction.txt (added)
-
tests/.expect/tupleMember.txt (added)
-
tests/tupleAssign.c (added)
-
tests/tupleFunction.c (added)
-
tests/tupleMember.c (added)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r84118d8 rb726084 307 307 } else { 308 308 // no address-of operator, so must be a pointer - add dereference 309 // NOTE: if the assertion starts to trigger, check that the application expr isn't being shared. 310 // Since its arguments are modified here, this assertion most commonly triggers when the application 311 // is visited multiple times. 309 312 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 310 313 newExpr->get_args().push_back( *arg ); 311 assert( (*arg)->get_results().size() == 1 ); 312 Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() ); 313 assert( type ); 314 newExpr->get_results().push_back( type->clone() ); 314 Type * type = InitTweak::getPointerBase( (*arg)->get_result() ); 315 assertf( type, "First argument to a derefence must be a pointer. Ensure that expressions are not being shared." ); 316 newExpr->set_result( type->clone() ); 315 317 *arg = newExpr; 316 318 } // if … … 527 529 extension( castExpr ); 528 530 output << "("; 529 if ( castExpr->get_result s().empty() ) {531 if ( castExpr->get_result()->isVoid() ) { 530 532 output << "(void)" ; 531 } else if ( ! castExpr->get_result s().front()->get_isLvalue() ) {533 } else if ( ! castExpr->get_result()->get_isLvalue() ) { 532 534 // at least one result type of cast, but not an lvalue 533 535 output << "("; 534 output << genType( castExpr->get_result s().front(), "" );536 output << genType( castExpr->get_result(), "" ); 535 537 output << ")"; 536 538 } else { … … 640 642 } 641 643 642 void CodeGenerator::visit( TupleExpr * tupleExpr ) { }644 void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); } 643 645 644 646 void CodeGenerator::visit( TypeExpr * typeExpr ) {} … … 654 656 asmExpr->get_operand()->accept( *this ); 655 657 output << " )"; 658 } 659 660 void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) { 661 assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) ); 662 output << "(" << genType( compLitExpr->get_type(), "" ) << ")"; 663 compLitExpr->get_initializer()->accept( *this ); 664 } 665 666 void CodeGenerator::visit( StmtExpr * stmtExpr ) { 667 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids(); 668 output << "({" << std::endl; 669 cur_indent += CodeGenerator::tabsize; 670 unsigned int numStmts = stmts.size(); 671 unsigned int i = 0; 672 for ( Statement * stmt : stmts ) { 673 output << indent << printLabels( stmt->get_labels() ); 674 if ( i+1 == numStmts ) { 675 // last statement in a statement expression needs to be handled specially - 676 // cannot cast to void, otherwise the expression statement has no value 677 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) { 678 exprStmt->get_expr()->accept( *this ); 679 output << ";" << endl; 680 ++i; 681 break; 682 } 683 } 684 stmt->accept( *this ); 685 output << endl; 686 if ( wantSpacing( stmt ) ) { 687 output << endl; 688 } // if 689 ++i; 690 } 691 cur_indent -= CodeGenerator::tabsize; 692 output << indent << "})"; 656 693 } 657 694 -
src/CodeGen/CodeGenerator.h
r84118d8 rb726084 70 70 virtual void visit( ConditionalExpr *conditionalExpr ); 71 71 virtual void visit( CommaExpr *commaExpr ); 72 virtual void visit( CompoundLiteralExpr *compLitExpr ); 72 73 virtual void visit( TupleExpr *tupleExpr ); 73 74 virtual void visit( TypeExpr *typeExpr ); 74 75 virtual void visit( AsmExpr * ); 76 virtual void visit( StmtExpr * ); 75 77 76 78 //*** Statements -
src/CodeGen/GenType.cc
r84118d8 rb726084 227 227 typeString = "_Atomic " + typeString; 228 228 } // if 229 if ( type->get_isAttribute() ) {230 typeString = "__attribute(( )) " + typeString;231 } // if232 229 } 233 230 } // namespace CodeGen -
src/Common/utility.h
r84118d8 rb726084 148 148 } 149 149 150 // replace element of list with all elements of another list 150 151 template< typename T > 151 152 void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) { … … 158 159 159 160 return; 161 } 162 163 // replace range of a list with a single element 164 template< typename T > 165 void replace( std::list< T > &org, typename std::list< T >::iterator begin, typename std::list< T >::iterator end, const T & with ) { 166 org.insert( begin, with ); 167 org.erase( begin, end ); 160 168 } 161 169 -
src/ControlStruct/Mutate.cc
r84118d8 rb726084 23 23 #include "MLEMutator.h" 24 24 #include "ForExprMutator.h" 25 #include "LabelTypeChecker.h"26 25 //#include "ExceptMutator.h" 27 26 … … 41 40 42 41 //ExceptMutator exc; 43 // LabelTypeChecker lbl;44 42 45 43 mutateAll( translationUnit, formut ); 46 44 acceptAll( translationUnit, lfix ); 47 45 //mutateAll( translationUnit, exc ); 48 //acceptAll( translationUnit, lbl );49 46 } 50 47 } // namespace CodeGen -
src/ControlStruct/module.mk
r84118d8 rb726084 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 19 19 ControlStruct/MLEMutator.cc \ 20 20 ControlStruct/Mutate.cc \ 21 ControlStruct/ForExprMutator.cc \ 22 ControlStruct/LabelTypeChecker.cc 21 ControlStruct/ForExprMutator.cc 23 22 -
src/GenPoly/Box.cc
r84118d8 rb726084 113 113 void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ); 114 114 /// Stores assignment operators from assertion list in local map of assignment operations 115 void findTypeOps( const std::list< TypeDecl *>&forall );115 void findTypeOps( const Type::ForallList &forall ); 116 116 void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ); 117 117 FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars ); … … 619 619 } 620 620 621 void Pass1::findTypeOps( const std::list< TypeDecl *>&forall ) {621 void Pass1::findTypeOps( const Type::ForallList &forall ) { 622 622 // what if a nested function uses an assignment operator? 623 623 // assignOps.clear(); 624 for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) {624 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) { 625 625 for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 626 626 std::string typeName; … … 687 687 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 688 688 std::list< FunctionType *> functions; 689 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {689 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 690 690 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 691 691 findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter ); … … 789 789 790 790 // add size/align for generic types to parameter list 791 if ( appExpr->get_function()->get_results().empty() ) return;792 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result s().front() );791 if ( ! appExpr->get_function()->has_result() ) return; 792 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() ); 793 793 assert( funcType ); 794 794 … … 806 806 for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) { 807 807 VariableExpr *fnArgBase = getBaseVar( *fnArg ); 808 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;809 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result s().front(), arg, exprTyVars, seenTypes );808 if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results 809 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes ); 810 810 } 811 811 } … … 897 897 Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 898 898 appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) ); 899 appExpr->set_function( new NameExpr( adapterName ) ); 899 appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr 900 900 901 901 return ret; … … 903 903 904 904 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 905 assert( ! arg->get_results().empty() );905 assert( arg->has_result() ); 906 906 if ( isPolyType( param, exprTyVars ) ) { 907 if ( isPolyType( arg->get_result s().front() ) ) {907 if ( isPolyType( arg->get_result() ) ) { 908 908 // if the argument's type is polymorphic, we don't need to box again! 909 909 return; 910 } else if ( arg->get_result s().front()->get_isLvalue() ) {910 } else if ( arg->get_result()->get_isLvalue() ) { 911 911 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 912 912 // xxx - need to test that this code is still reachable … … 953 953 void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) { 954 954 std::list< Expression *>::iterator cur = arg; 955 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {955 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 956 956 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 957 957 InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() ); … … 994 994 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 995 995 deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) ); 996 deref-> get_results().push_back( arg->get_type()->clone() );996 deref->set_result( arg->get_type()->clone() ); 997 997 return deref; 998 998 } // if … … 1020 1020 Statement *bodyStmt; 1021 1021 1022 std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin();1023 std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin();1024 std::list< TypeDecl *>::iterator realTyParam = adaptee->get_forall().begin();1022 Type::ForallList::iterator tyArg = realType->get_forall().begin(); 1023 Type::ForallList::iterator tyParam = adapterType->get_forall().begin(); 1024 Type::ForallList::iterator realTyParam = adaptee->get_forall().begin(); 1025 1025 for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) { 1026 1026 assert( tyArg != realType->get_forall().end() ); … … 1071 1071 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 1072 1072 std::list< FunctionType *> functions; 1073 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {1073 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 1074 1074 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 1075 1075 findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter ); … … 1131 1131 } // if 1132 1132 addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) ); 1133 addAssign-> get_results().front() = appExpr->get_results().front()->clone();1133 addAssign->set_result( appExpr->get_result()->clone() ); 1134 1134 if ( appExpr->get_env() ) { 1135 1135 addAssign->set_env( appExpr->get_env() ); … … 1145 1145 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) { 1146 1146 if ( varExpr->get_var()->get_name() == "?[?]" ) { 1147 assert( ! appExpr->get_results().empty() );1147 assert( appExpr->has_result() ); 1148 1148 assert( appExpr->get_args().size() == 2 ); 1149 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result s().front(), scopeTyVars, env );1150 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result s().front(), scopeTyVars, env );1149 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env ); 1150 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env ); 1151 1151 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers 1152 1152 UntypedExpr *ret = 0; … … 1168 1168 } // if 1169 1169 if ( baseType1 || baseType2 ) { 1170 ret-> get_results().push_front( appExpr->get_results().front()->clone() );1170 ret->set_result( appExpr->get_result()->clone() ); 1171 1171 if ( appExpr->get_env() ) { 1172 1172 ret->set_env( appExpr->get_env() ); … … 1178 1178 } // if 1179 1179 } else if ( varExpr->get_var()->get_name() == "*?" ) { 1180 assert( ! appExpr->get_results().empty() );1180 assert( appExpr->has_result() ); 1181 1181 assert( ! appExpr->get_args().empty() ); 1182 if ( isPolyType( appExpr->get_result s().front(), scopeTyVars, env ) ) {1182 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { 1183 1183 Expression *ret = appExpr->get_args().front(); 1184 delete ret->get_result s().front();1185 ret-> get_results().front() = appExpr->get_results().front()->clone();1184 delete ret->get_result(); 1185 ret->set_result( appExpr->get_result()->clone() ); 1186 1186 if ( appExpr->get_env() ) { 1187 1187 ret->set_env( appExpr->get_env() ); … … 1193 1193 } // if 1194 1194 } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) { 1195 assert( ! appExpr->get_results().empty() );1195 assert( appExpr->has_result() ); 1196 1196 assert( appExpr->get_args().size() == 1 ); 1197 if ( Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env ) ) {1198 Type *tempType = appExpr->get_result s().front()->clone();1197 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { 1198 Type *tempType = appExpr->get_result()->clone(); 1199 1199 if ( env ) { 1200 1200 env->apply( tempType ); … … 1213 1213 } // if 1214 1214 } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) { 1215 assert( ! appExpr->get_results().empty() );1215 assert( appExpr->has_result() ); 1216 1216 assert( appExpr->get_args().size() == 1 ); 1217 if ( Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env ) ) {1217 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { 1218 1218 return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" ); 1219 1219 } // if 1220 1220 } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) { 1221 assert( ! appExpr->get_results().empty() );1221 assert( appExpr->has_result() ); 1222 1222 assert( appExpr->get_args().size() == 2 ); 1223 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result s().front(), scopeTyVars, env );1224 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result s().front(), scopeTyVars, env );1223 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env ); 1224 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env ); 1225 1225 if ( baseType1 && baseType2 ) { 1226 1226 UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) ); 1227 1227 divide->get_args().push_back( appExpr ); 1228 1228 divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) ); 1229 divide-> get_results().push_front( appExpr->get_results().front()->clone() );1229 divide->set_result( appExpr->get_result()->clone() ); 1230 1230 if ( appExpr->get_env() ) { 1231 1231 divide->set_env( appExpr->get_env() ); … … 1245 1245 } // if 1246 1246 } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) { 1247 assert( ! appExpr->get_results().empty() );1247 assert( appExpr->has_result() ); 1248 1248 assert( appExpr->get_args().size() == 2 ); 1249 Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env );1249 Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ); 1250 1250 if ( baseType ) { 1251 1251 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); … … 1273 1273 useRetval = oldUseRetval; 1274 1274 1275 assert( ! appExpr->get_function()->get_results().empty() ); 1276 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1277 assert( pointer ); 1278 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1279 assert( function ); 1275 assert( appExpr->get_function()->has_result() ); 1276 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() ); 1277 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() ); 1280 1278 1281 1279 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1315 1313 1316 1314 Expression *Pass1::mutate( UntypedExpr *expr ) { 1317 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {1315 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1318 1316 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1319 1317 if ( name->get_name() == "*?" ) { … … 1329 1327 1330 1328 Expression *Pass1::mutate( AddressExpr *addrExpr ) { 1331 assert( ! addrExpr->get_arg()->get_results().empty() );1329 assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() ); 1332 1330 1333 1331 bool needs = false; 1334 1332 if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) { 1335 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {1333 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1336 1334 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1337 1335 if ( name->get_name() == "*?" ) { 1338 1336 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 1339 assert( ! appExpr->get_function()->get_results().empty() ); 1340 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1341 assert( pointer ); 1342 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1343 assert( function ); 1337 assert( appExpr->get_function()->has_result() ); 1338 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() ); 1339 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() ); 1344 1340 needs = needsAdapter( function, scopeTyVars ); 1345 1341 } // if … … 1350 1346 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward 1351 1347 // out of the if condition. 1352 bool polytype = isPolyType( addrExpr->get_arg()->get_result s().front(), scopeTyVars, env );1348 bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env ); 1353 1349 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1354 1350 if ( polytype || needs ) { 1355 1351 Expression *ret = addrExpr->get_arg(); 1356 delete ret->get_result s().front();1357 ret-> get_results().front() = addrExpr->get_results().front()->clone();1352 delete ret->get_result(); 1353 ret->set_result( addrExpr->get_result()->clone() ); 1358 1354 addrExpr->set_arg( 0 ); 1359 1355 delete addrExpr; … … 1393 1389 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1394 1390 if ( retval && returnStmt->get_expr() ) { 1395 assert( ! returnStmt->get_expr()->get_results().empty() );1391 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() ); 1396 1392 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 1397 1393 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { … … 1427 1423 // find each of its needed secondary assignment operators 1428 1424 std::list< Expression* > &tyParams = refType->get_parameters(); 1429 std::list< TypeDecl* >&forallParams = functionDecl->get_type()->get_forall();1425 Type::ForallList &forallParams = functionDecl->get_type()->get_forall(); 1430 1426 std::list< Expression* >::const_iterator tyIt = tyParams.begin(); 1431 std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();1427 Type::ForallList::const_iterator forallIt = forallParams.begin(); 1432 1428 for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) { 1433 1429 // Add appropriate mapping to assignment expression environment … … 1473 1469 // replace return statement with appropriate assignment to out parameter 1474 1470 Expression *retParm = new NameExpr( retval->get_name() ); 1475 retParm-> get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );1471 retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) ); 1476 1472 assignExpr->get_args().push_back( retParm ); 1477 1473 assignExpr->get_args().push_back( returnStmt->get_expr() ); … … 1603 1599 ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, 1604 1600 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); 1605 for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {1601 for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { 1606 1602 ObjectDecl *sizeParm, *alignParm; 1607 1603 // add all size and alignment parameters to parameter list -
src/GenPoly/CopyParams.cc
r84118d8 rb726084 54 54 std::map< std::string, DeclarationWithType* > assignOps; 55 55 // assume the assignment operator is the first assert param after any "type" parameter 56 for ( std::list< TypeDecl* >::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {56 for ( Type::ForallList::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) { 57 57 if ( (*tyVar)->get_kind() == TypeDecl::Any ) { 58 58 assert( !(*tyVar)->get_assertions().empty() ); -
src/GenPoly/FindFunction.cc
r84118d8 rb726084 29 29 virtual Type *mutate( PointerType *pointerType ); 30 30 private: 31 void handleForall( const std::list< TypeDecl* >&forall );31 void handleForall( const Type::ForallList &forall ); 32 32 33 33 std::list< FunctionType* > &functions; … … 51 51 } 52 52 53 void FindFunction::handleForall( const std::list< TypeDecl* >&forall ) {54 for ( std::list< TypeDecl* >::const_iterator i = forall.begin(); i != forall.end(); ++i ) {53 void FindFunction::handleForall( const Type::ForallList &forall ) { 54 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) { 55 55 TyVarMap::iterator var = tyVars.find( (*i)->get_name() ); 56 56 if ( var != tyVars.end() ) { -
src/GenPoly/GenPoly.cc
r84118d8 rb726084 110 110 ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &forallTypes ) { 111 111 if ( function->get_returnVals().empty() ) return 0; 112 112 113 113 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes ); 114 114 } … … 127 127 // } // if 128 128 if ( isDynRet( adaptee, tyVars ) ) return true; 129 129 130 130 for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) { 131 131 // if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) { … … 228 228 229 229 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) { 230 for ( std::list< TypeDecl* >::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {230 for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) { 231 231 assert( *tyVar ); 232 232 tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind(); -
src/GenPoly/Lvalue.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Lvalue.cc -- 7 // Lvalue.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 41 41 public: 42 42 Pass1(); 43 43 44 44 virtual Expression *mutate( ApplicationExpr *appExpr ); 45 45 virtual Statement *mutate( ReturnStmt *appExpr ); … … 55 55 private: 56 56 }; 57 58 /// GCC-like Generalized Lvalues (which have since been removed from GCC) 59 /// https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Lvalues.html#Lvalues 60 /// Replaces &(a,b) with (a, &b), &(a ? b : c) with (a ? &b : &c) 61 class GeneralizedLvalue : public Mutator { 62 typedef Mutator Parent; 63 64 virtual Expression * mutate( AddressExpr * addressExpr ); 65 }; 57 66 } // namespace 58 67 … … 60 69 Pass1 p1; 61 70 Pass2 p2; 71 GeneralizedLvalue genLval; 62 72 mutateAll( translationUnit, p1 ); 63 73 acceptAll( translationUnit, p2 ); 74 mutateAll( translationUnit, genLval ); 64 75 } 65 76 … … 99 110 appExpr->get_function()->acceptMutator( *this ); 100 111 mutateAll( appExpr->get_args(), *this ); 101 102 assert( ! appExpr->get_function()->get_results().empty() );103 112 104 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 105 assert( pointer ); 106 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 107 assert( function ); 113 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 114 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 108 115 109 116 Type *funType = isLvalueRet( function ); 110 117 if ( funType && ! isIntrinsicApp( appExpr ) ) { 111 118 Expression *expr = appExpr; 112 Type *appType = appExpr->get_result s().front();119 Type *appType = appExpr->get_result(); 113 120 if ( isPolyType( funType ) && ! isPolyType( appType ) ) { 114 121 // make sure cast for polymorphic type is inside dereference … … 116 123 } 117 124 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 118 deref-> get_results().push_back( appType->clone() );119 appExpr-> get_results().front() = new PointerType( Type::Qualifiers(), appType);125 deref->set_result( appType->clone() ); 126 appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) ); 120 127 deref->get_args().push_back( expr ); 121 128 return deref; … … 127 134 Statement * Pass1::mutate(ReturnStmt *retStmt) { 128 135 if ( retval && retStmt->get_expr() ) { 129 assert( ! retStmt->get_expr()->get_results().empty() ); 130 if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) { 136 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) { 131 137 // ***** Code Removal ***** because casts may be stripped already 132 138 … … 155 161 retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) ); 156 162 } // if 157 163 158 164 Visitor::visit( funType ); 165 } 166 167 Expression * GeneralizedLvalue::mutate( AddressExpr * addrExpr ) { 168 addrExpr = safe_dynamic_cast< AddressExpr * >( Parent::mutate( addrExpr ) ); 169 if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( addrExpr->get_arg() ) ) { 170 Expression * arg1 = commaExpr->get_arg1()->clone(); 171 Expression * arg2 = commaExpr->get_arg2()->clone(); 172 delete addrExpr; 173 return new CommaExpr( arg1, new AddressExpr( arg2 ) ); 174 } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( addrExpr->get_arg() ) ) { 175 Expression * arg1 = condExpr->get_arg1()->clone(); 176 Expression * arg2 = condExpr->get_arg2()->clone(); 177 Expression * arg3 = condExpr->get_arg3()->clone(); 178 delete addrExpr; 179 return new ConditionalExpr( arg1, new AddressExpr( arg2 ), new AddressExpr( arg3 ) ); 180 } 181 return addrExpr; 159 182 } 160 183 } // namespace -
src/GenPoly/Specialize.cc
r84118d8 rb726084 148 148 149 149 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 150 assert ( ! actual->get_results().empty() ); // using front, should have this assert151 if ( needsSpecialization( formalType, actual->get_result s().front(), env ) ) {150 assertf( actual->has_result(), "attempting to specialize an untyped expression" ); 151 if ( needsSpecialization( formalType, actual->get_result(), env ) ) { 152 152 FunctionType *funType; 153 153 if ( ( funType = getFunctionType( formalType ) ) ) { … … 172 172 void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) { 173 173 // create thunks for the explicit parameters 174 assert( ! appExpr->get_function()->get_results().empty() );175 FunctionType *function = getFunctionType( appExpr->get_function()->get_result s().front() );174 assert( appExpr->get_function()->has_result() ); 175 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() ); 176 176 assert( function ); 177 177 std::list< DeclarationWithType* >::iterator formal; … … 201 201 Expression * Specialize::mutate( AddressExpr *addrExpr ) { 202 202 addrExpr->get_arg()->acceptMutator( *this ); 203 assert( ! addrExpr->get_results().empty() );204 addrExpr->set_arg( doSpecialization( addrExpr->get_result s().front(), addrExpr->get_arg() ) );203 assert( addrExpr->has_result() ); 204 addrExpr->set_arg( doSpecialization( addrExpr->get_result(), addrExpr->get_arg() ) ); 205 205 return addrExpr; 206 206 } … … 208 208 Expression * Specialize::mutate( CastExpr *castExpr ) { 209 209 castExpr->get_arg()->acceptMutator( *this ); 210 if ( castExpr->get_result s().empty() ) {210 if ( castExpr->get_result()->isVoid() ) { 211 211 // can't specialize if we don't have a return value 212 212 return castExpr; 213 213 } 214 Expression *specialized = doSpecialization( castExpr->get_result s().front(), castExpr->get_arg() );214 Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() ); 215 215 if ( specialized != castExpr->get_arg() ) { 216 216 // assume here that the specialization incorporates the cast -
src/InitTweak/FixInit.cc
r84118d8 rb726084 18 18 #include <iterator> 19 19 #include <algorithm> 20 #include <unordered_map> 21 #include <unordered_set> 20 22 #include "InitTweak.h" 21 23 #include "FixInit.h" … … 35 37 #include "GenPoly/DeclMutator.h" 36 38 #include "SynTree/AddStmtVisitor.h" 37 #include "CodeGen/GenType.h" // for warning s38 39 bool ctordtorp = false; 40 bool ctorp = false; 41 bool cpctorp = false; 42 bool dtorp = false; 39 #include "CodeGen/GenType.h" // for warning/error messages 40 41 bool ctordtorp = false; // print all debug 42 bool ctorp = false; // print ctor debug 43 bool cpctorp = false; // print copy ctor debug 44 bool dtorp = false; // print dtor debug 43 45 #define PRINT( text ) if ( ctordtorp ) { text } 44 46 #define CP_CTOR_PRINT( text ) if ( ctordtorp || cpctorp ) { text } … … 47 49 namespace InitTweak { 48 50 namespace { 49 const std::list<Label> noLabels;50 const std::list<Expression*> noDesignators;51 52 51 class InsertImplicitCalls final : public GenPoly::PolyMutator { 53 52 public: … … 67 66 static void resolveImplicitCalls( std::list< Declaration * > & translationUnit ); 68 67 69 using SymTab::Indexer::visit; 68 typedef SymTab::Indexer Parent; 69 using Parent::visit; 70 70 71 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 72 virtual void visit( UniqueExpr * unqExpr ); 71 73 72 74 /// create and resolve ctor/dtor expression: fname(var, [cpArg]) 73 ApplicationExpr * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL ); 75 Expression * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL ); 76 Expression * makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg = NULL ); 74 77 /// true if type does not need to be copy constructed to ensure correctness 75 bool skipCopyConstruct( Type * ); 78 bool skipCopyConstruct( Type * type ); 79 void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ); 80 void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ); 76 81 private: 77 82 TypeSubstitution * env; … … 183 188 using GenPoly::PolyMutator::mutate; 184 189 virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 190 virtual Expression * mutate( UniqueExpr * unqExpr ) override; 185 191 }; 186 192 … … 368 374 } 369 375 370 ApplicationExpr* ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {376 Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) { 371 377 assert( var ); 378 return makeCtorDtor( fname, new AddressExpr( new VariableExpr( var ) ), cpArg ); 379 } 380 381 Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg ) { 382 assert( thisArg ); 372 383 UntypedExpr * untyped = new UntypedExpr( new NameExpr( fname ) ); 373 untyped->get_args().push_back( new AddressExpr( new VariableExpr( var ) ));384 untyped->get_args().push_back( thisArg ); 374 385 if (cpArg) untyped->get_args().push_back( cpArg->clone() ); 375 386 … … 378 389 // (VariableExpr and already resolved expression) 379 390 CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; ) 380 ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) ); 391 Expression * resolved = ResolvExpr::findVoidExpression( untyped, *this ); 392 assert( resolved ); 381 393 if ( resolved->get_env() ) { 382 394 env->add( *resolved->get_env() ); 383 395 } // if 384 396 385 assert( resolved );386 397 delete untyped; 387 398 return resolved; 388 399 } 389 400 401 void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) { 402 static UniqueName tempNamer("_tmp_cp"); 403 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; ) 404 assert( arg->has_result() ); 405 Type * result = arg->get_result(); 406 if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types 407 408 // type may involve type variables, so apply type substitution to get temporary variable's actual type 409 result = result->clone(); 410 impCpCtorExpr->get_env()->apply( result ); 411 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 412 tmp->get_type()->set_isConst( false ); 413 414 // create and resolve copy constructor 415 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; ) 416 Expression * cpCtor = makeCtorDtor( "?{}", tmp, arg ); 417 418 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( cpCtor ) ) { 419 // if the chosen constructor is intrinsic, the copy is unnecessary, so 420 // don't create the temporary and don't call the copy constructor 421 VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() ); 422 assert( function ); 423 if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return; 424 } 425 426 // replace argument to function call with temporary 427 arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) ); 428 impCpCtorExpr->get_tempDecls().push_back( tmp ); 429 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) ); 430 } 431 432 void ResolveCopyCtors::destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ) { 433 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", new AddressExpr( ret ) ) ); 434 } 435 390 436 void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) { 391 static UniqueName tempNamer("_tmp_cp");392 static UniqueName retNamer("_tmp_cp_ret");393 394 437 CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; ) 395 Visitor::visit( impCpCtorExpr );438 Parent::visit( impCpCtorExpr ); 396 439 env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer... 397 440 … … 400 443 // take each argument and attempt to copy construct it. 401 444 for ( Expression * & arg : appExpr->get_args() ) { 402 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; ) 403 // xxx - need to handle tuple arguments 404 assert( ! arg->get_results().empty() ); 405 Type * result = arg->get_results().front(); 406 if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types 407 // type may involve type variables, so apply type substitution to get temporary variable's actual type 408 result = result->clone(); 409 impCpCtorExpr->get_env()->apply( result ); 410 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 411 tmp->get_type()->set_isConst( false ); 412 413 // create and resolve copy constructor 414 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; ) 415 ApplicationExpr * cpCtor = makeCtorDtor( "?{}", tmp, arg ); 416 417 // if the chosen constructor is intrinsic, the copy is unnecessary, so 418 // don't create the temporary and don't call the copy constructor 419 VariableExpr * function = dynamic_cast< VariableExpr * >( cpCtor->get_function() ); 420 assert( function ); 421 if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) { 422 // replace argument to function call with temporary 423 arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) ); 424 impCpCtorExpr->get_tempDecls().push_back( tmp ); 425 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) ); 426 } // if 445 copyConstructArg( arg, impCpCtorExpr ); 427 446 } // for 428 447 … … 434 453 // level. Trying to pass that environment along. 435 454 callExpr->set_env( impCpCtorExpr->get_env()->clone() ); 436 for ( Type * result : appExpr->get_results() ) { 455 Type * result = appExpr->get_result(); 456 if ( ! result->isVoid() ) { 457 static UniqueName retNamer("_tmp_cp_ret"); 437 458 result = result->clone(); 438 459 impCpCtorExpr->get_env()->apply( result ); … … 441 462 impCpCtorExpr->get_returnDecls().push_back( ret ); 442 463 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 443 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) ); 464 if ( ! result->get_isLvalue() ) { 465 // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary 466 destructRet( new VariableExpr( ret ), impCpCtorExpr ); 467 } 444 468 } // for 445 469 CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; ) 470 } 471 472 void ResolveCopyCtors::visit( UniqueExpr * unqExpr ) { 473 static std::unordered_set< int > vars; 474 if ( vars.count( unqExpr->get_id() ) ) { 475 // xxx - hack to prevent double-handling of unique exprs, otherwise too many temporary variables and destructors are generated 476 return; 477 } 478 479 Parent::visit( unqExpr ); 480 // it should never be necessary to wrap a void-returning expression in a UniqueExpr - if this assumption changes, this needs to be rethought 481 assert( unqExpr->get_result() ); 482 if ( ImplicitCopyCtorExpr * impCpCtorExpr = dynamic_cast<ImplicitCopyCtorExpr*>( unqExpr->get_expr() ) ) { 483 // note the variable used as the result from the call 484 assert( impCpCtorExpr->get_result() && impCpCtorExpr->get_returnDecls().size() == 1 ); 485 unqExpr->set_var( new VariableExpr( impCpCtorExpr->get_returnDecls().front() ) ); 486 } else { 487 // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression 488 unqExpr->set_object( new ObjectDecl( toString("_unq_expr_", unqExpr->get_id()), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) ); 489 unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) ); 490 } 491 vars.insert( unqExpr->get_id() ); 446 492 } 447 493 … … 490 536 // know the result type of the assignment is the type of the LHS (minus the pointer), so 491 537 // add that onto the assignment expression so that later steps have the necessary information 492 assign-> add_result( returnDecl->get_type()->clone() );538 assign->set_result( returnDecl->get_type()->clone() ); 493 539 494 540 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 495 if ( callExpr->get_result s().front()->get_isLvalue() ) {541 if ( callExpr->get_result()->get_isLvalue() ) { 496 542 // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning 497 543 // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the … … 500 546 // an AddressExpr. Effectively, this turns 501 547 // lvalue T f(); 502 // &*f() 548 // &*f(); 503 549 // into 550 // T * f(); 504 551 // T * tmp_cp_retN; 505 // tmp_cp_ret_N = &*(tmp_cp_ret_N = &*f(), tmp_cp_ret);552 // &*(tmp_cp_retN = &*f(), tmp_cp_retN); // the first * and second & are generated here 506 553 // which work out in terms of types, but is pretty messy. It would be nice to find a better way. 507 554 assign->get_args().back() = new AddressExpr( assign->get_args().back() ); 508 555 509 Type * resultType = returnDecl->get_type()->clone();510 556 returnDecl->set_type( new PointerType( Type::Qualifiers(), returnDecl->get_type() ) ); 511 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 512 deref->get_args().push_back( retExpr ); 513 deref->add_result( resultType ); 514 retExpr = deref; 557 retExpr->set_result( new PointerType( Type::Qualifiers(), retExpr->get_result() ) ); 558 retExpr = UntypedExpr::createDeref( retExpr ); 515 559 } // if 516 560 retExpr->set_env( env->clone() ); … … 519 563 return callExpr; 520 564 } // if 565 } 566 567 Expression * FixCopyCtors::mutate( UniqueExpr * unqExpr ) { 568 static std::unordered_map< int, UniqueExpr * > unqMap; 569 static std::unordered_set< int > addDeref; 570 // has to be done to clean up ImplicitCopyCtorExpr nodes, even when this node was skipped in previous passes 571 unqExpr = safe_dynamic_cast< UniqueExpr * >( Parent::mutate( unqExpr ) ); 572 if ( unqMap.count( unqExpr->get_id() ) ) { 573 // take data from other UniqueExpr to ensure consistency 574 delete unqExpr->get_expr(); 575 unqExpr->set_expr( unqMap[unqExpr->get_id()]->get_expr()->clone() ); 576 delete unqExpr->get_result(); 577 unqExpr->set_result( maybeClone( unqExpr->get_expr()->get_result() ) ); 578 if ( addDeref.count( unqExpr->get_id() ) ) { 579 // other UniqueExpr was dereferenced because it was an lvalue return, so this one should be too 580 return UntypedExpr::createDeref( unqExpr ); 581 } 582 return unqExpr; 583 } 584 unqMap[unqExpr->get_id()] = unqExpr; 585 if ( UntypedExpr * deref = dynamic_cast< UntypedExpr * >( unqExpr->get_expr() ) ) { 586 // unique expression is now a dereference, because the inner expression is an lvalue returning function call. 587 // Normalize the expression by dereferencing the unique expression, rather than the inner expression 588 // (i.e. move the dereference out a level) 589 assert( getFunctionName( deref ) == "*?" ); 590 unqExpr->set_expr( getCallArg( deref, 0 ) ); 591 getCallArg( deref, 0 ) = unqExpr; 592 addDeref.insert( unqExpr->get_id() ); 593 return deref; 594 } 595 return unqExpr; 521 596 } 522 597 … … 950 1025 Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) { 951 1026 static UniqueName tempNamer( "_tmp_ctor_expr" ); 952 assert( ctorExpr->get_results().size() == 1 ); 953 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr ); 1027 // xxx - is the size check necessary? 1028 assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 ); 1029 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr ); 954 1030 addDeclaration( tmp ); 955 1031 … … 963 1039 assign->get_args().push_back( new VariableExpr( tmp ) ); 964 1040 assign->get_args().push_back( firstArg ); 965 cloneAll( ctorExpr->get_results(), assign->get_results() );1041 assign->set_result( ctorExpr->get_result()->clone() ); 966 1042 firstArg = assign; 967 1043 -
src/InitTweak/GenInit.cc
r84118d8 rb726084 29 29 #include "GenPoly/DeclMutator.h" 30 30 #include "GenPoly/ScopedSet.h" 31 #include "ResolvExpr/typeops.h" 31 32 32 33 namespace InitTweak { … … 50 51 51 52 protected: 52 std::list<DeclarationWithType*> returnVals;53 FunctionType * ftype; 53 54 UniqueName tempNamer; 54 55 std::string funcName; … … 86 87 87 88 bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed 89 bool isManaged( Type * type ) const; // determine if type is managed 88 90 void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor 89 91 GenPoly::ScopedSet< std::string > managedTypes; … … 136 138 137 139 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) { 138 // update for multiple return values140 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 139 141 assert( returnVals.size() == 0 || returnVals.size() == 1 ); 140 142 // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address … … 158 160 159 161 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 160 ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals ); 162 // xxx - need to handle named return values - this pass may need to happen 163 // after resolution? the ordering is tricky because return statements must be 164 // constructed - the simplest way to do that (while also handling multiple 165 // returns) is to structure the returnVals into a tuple, as done here. 166 // however, if the tuple return value is structured before resolution, 167 // it's difficult to resolve named return values, since the name is lost 168 // in conversion to a tuple. this might be easiest to deal with 169 // after reference types are added, as it may then be possible to 170 // uniformly move named return values to the parameter list directly 171 ValueGuard< FunctionType * > oldFtype( ftype ); 161 172 ValueGuard< std::string > oldFuncName( funcName ); 162 173 163 FunctionType * type = functionDecl->get_functionType(); 164 returnVals = type->get_returnVals(); 174 ftype = functionDecl->get_functionType(); 175 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals(); 176 if ( retVals.size() > 1 ) { 177 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 178 ObjectDecl * newRet = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 179 retVals.clear(); 180 retVals.push_back( newRet ); 181 } 165 182 funcName = functionDecl->get_name(); 166 183 DeclarationWithType * decl = Mutator::mutate( functionDecl ); … … 222 239 } 223 240 241 bool CtorDtor::isManaged( Type * type ) const { 242 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) { 243 // tuple is also managed if any of its components are managed 244 if ( std::any_of( tupleType->get_types().begin(), tupleType->get_types().end(), [&](Type * type) { return isManaged( type ); }) ) { 245 return true; 246 } 247 } 248 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end(); 249 } 250 224 251 bool CtorDtor::isManaged( ObjectDecl * objDecl ) const { 225 252 Type * type = objDecl->get_type(); … … 227 254 type = at->get_base(); 228 255 } 229 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();256 return isManaged( type ); 230 257 } 231 258 … … 238 265 managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) ); 239 266 } 267 } 268 269 ConstructorInit * genCtorInit( ObjectDecl * objDecl ) { 270 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor 271 // for each constructable object 272 std::list< Statement * > ctor; 273 std::list< Statement * > dtor; 274 275 InitExpander srcParam( objDecl->get_init() ); 276 InitExpander nullParam( (Initializer *)NULL ); 277 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl ); 278 SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false ); 279 280 // Currently genImplicitCall produces a single Statement - a CompoundStmt 281 // which wraps everything that needs to happen. As such, it's technically 282 // possible to use a Statement ** in the above calls, but this is inherently 283 // unsafe, so instead we take the slightly less efficient route, but will be 284 // immediately informed if somehow the above assumption is broken. In this case, 285 // we could always wrap the list of statements at this point with a CompoundStmt, 286 // but it seems reasonable at the moment for this to be done by genImplicitCall 287 // itself. It is possible that genImplicitCall produces no statements (e.g. if 288 // an array type does not have a dimension). In this case, it's fine to ignore 289 // the object for the purposes of construction. 290 assert( ctor.size() == dtor.size() && ctor.size() <= 1 ); 291 if ( ctor.size() == 1 ) { 292 // need to remember init expression, in case no ctors exist 293 // if ctor does exist, want to use ctor expression instead of init 294 // push this decision to the resolver 295 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) ); 296 return new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ); 297 } 298 return nullptr; 240 299 } 241 300 … … 250 309 if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl ); 251 310 252 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor 253 // for each constructable object 254 std::list< Statement * > ctor; 255 std::list< Statement * > dtor; 256 257 InitExpander srcParam( objDecl->get_init() ); 258 InitExpander nullParam( (Initializer *)NULL ); 259 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl ); 260 SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false ); 261 262 // Currently genImplicitCall produces a single Statement - a CompoundStmt 263 // which wraps everything that needs to happen. As such, it's technically 264 // possible to use a Statement ** in the above calls, but this is inherently 265 // unsafe, so instead we take the slightly less efficient route, but will be 266 // immediately informed if somehow the above assumption is broken. In this case, 267 // we could always wrap the list of statements at this point with a CompoundStmt, 268 // but it seems reasonable at the moment for this to be done by genImplicitCall 269 // itself. It is possible that genImplicitCall produces no statements (e.g. if 270 // an array type does not have a dimension). In this case, it's fine to ignore 271 // the object for the purposes of construction. 272 assert( ctor.size() == dtor.size() && ctor.size() <= 1 ); 273 if ( ctor.size() == 1 ) { 274 // need to remember init expression, in case no ctors exist 275 // if ctor does exist, want to use ctor expression instead of init 276 // push this decision to the resolver 277 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) ); 278 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) ); 279 } 311 objDecl->set_init( genCtorInit( objDecl ) ); 280 312 } 281 313 return Parent::mutate( objDecl ); … … 290 322 managedTypes.beginScope(); 291 323 // go through assertions and recursively add seen ctor/dtors 292 for ( TypeDecl *tyDecl : functionDecl->get_functionType()->get_forall() ) {324 for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) { 293 325 for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) { 294 326 assertion = assertion->acceptMutator( *this ); -
src/InitTweak/GenInit.h
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // RemoveInit.h --7 // GenInit.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 27 27 /// Adds return value temporaries and wraps Initializers in ConstructorInit nodes 28 28 void genInit( std::list< Declaration * > & translationUnit ); 29 30 /// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer 31 ConstructorInit * genCtorInit( ObjectDecl * objDecl ); 29 32 } // namespace 30 33 -
src/InitTweak/InitTweak.cc
r84118d8 rb726084 340 340 return allofCtorDtor( stmt, []( Expression * callExpr ){ 341 341 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 342 assert( ! appExpr->get_function()->get_results().empty() ); 343 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() ); 342 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() ); 344 343 assert( funcType ); 345 344 return funcType->get_parameters().size() == 1; … … 388 387 return memberExpr->get_member()->get_name(); 389 388 } else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) { 390 return memberExpr->get_member();389 return funcName( memberExpr->get_member() ); 391 390 } else { 392 391 assertf( false, "Unexpected expression type being called as a function in call expression" ); … … 451 450 // virtual void visit( LogicalExpr *logicalExpr ); 452 451 // virtual void visit( ConditionalExpr *conditionalExpr ); 453 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }454 virtual void visit( SolvedTupleExpr *tupleExpr ) { isConstExpr = false; }455 452 virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; } 456 453 virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; } 457 454 virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; } 458 455 virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; } 456 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; } 457 virtual void visit( TupleAssignExpr *tupleExpr ) { isConstExpr = false; } 459 458 460 459 bool isConstExpr; -
src/Makefile.in
r84118d8 rb726084 105 105 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 106 106 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ 107 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \108 107 GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \ 109 108 GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \ … … 190 189 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \ 191 190 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \ 191 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT) \ 192 192 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \ 193 Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT) 193 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) \ 194 Tuples/driver_cfa_cpp-Explode.$(OBJEXT) 194 195 am_driver_cfa_cpp_OBJECTS = $(am__objects_1) 195 196 driver_cfa_cpp_OBJECTS = $(am_driver_cfa_cpp_OBJECTS) … … 364 365 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 365 366 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 366 ControlStruct/ForExprMutator.cc \ 367 ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \ 367 ControlStruct/ForExprMutator.cc GenPoly/Box.cc \ 368 368 GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ 369 369 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ … … 404 404 SynTree/Initializer.cc SynTree/Visitor.cc SynTree/Mutator.cc \ 405 405 SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \ 406 SynTree/Attribute.cc Tuples/TupleAssignment.cc \ 407 Tuples/NameMatcher.cc 406 SynTree/Attribute.cc SynTree/VarExprReplacer.cc \ 407 Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \ 408 Tuples/Explode.cc 408 409 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 409 410 ${cfa_cpplib_PROGRAMS}} … … 541 542 ControlStruct/$(DEPDIR)/$(am__dirstamp) 542 543 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT): \ 543 ControlStruct/$(am__dirstamp) \544 ControlStruct/$(DEPDIR)/$(am__dirstamp)545 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT): \546 544 ControlStruct/$(am__dirstamp) \ 547 545 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 769 767 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT): SynTree/$(am__dirstamp) \ 770 768 SynTree/$(DEPDIR)/$(am__dirstamp) 769 SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT): \ 770 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp) 771 771 Tuples/$(am__dirstamp): 772 772 @$(MKDIR_P) Tuples … … 777 777 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT): \ 778 778 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 779 Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp) \ 779 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT): \ 780 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 781 Tuples/driver_cfa_cpp-Explode.$(OBJEXT): Tuples/$(am__dirstamp) \ 780 782 Tuples/$(DEPDIR)/$(am__dirstamp) 781 783 driver/$(am__dirstamp): … … 800 802 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) 801 803 -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) 802 -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)803 804 -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) 804 805 -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) … … 884 885 -rm -f SynTree/driver_cfa_cpp-TypeofType.$(OBJEXT) 885 886 -rm -f SynTree/driver_cfa_cpp-VarArgsType.$(OBJEXT) 887 -rm -f SynTree/driver_cfa_cpp-VarExprReplacer.$(OBJEXT) 886 888 -rm -f SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) 887 889 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) 888 890 -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) 889 -rm -f Tuples/driver_cfa_cpp- NameMatcher.$(OBJEXT)891 -rm -f Tuples/driver_cfa_cpp-Explode.$(OBJEXT) 890 892 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) 893 -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) 891 894 892 895 distclean-compile: … … 907 910 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ 908 911 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Po@am__quote@ 909 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po@am__quote@910 912 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@ 911 913 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@ … … 991 993 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-TypeofType.Po@am__quote@ 992 994 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@ 995 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po@am__quote@ 993 996 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@ 994 997 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 995 998 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ 996 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp- NameMatcher.Po@am__quote@999 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Po@am__quote@ 997 1000 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ 1001 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@ 998 1002 999 1003 .cc.o: … … 1237 1241 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ForExprMutator.obj `if test -f 'ControlStruct/ForExprMutator.cc'; then $(CYGPATH_W) 'ControlStruct/ForExprMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ForExprMutator.cc'; fi` 1238 1242 1239 ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc1240 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc1241 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po1242 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.o' libtool=no @AMDEPBACKSLASH@1243 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1244 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc1245 1246 ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc1247 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`1248 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po1249 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj' libtool=no @AMDEPBACKSLASH@1250 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1251 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi`1252 1253 1243 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1254 1244 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc … … 2427 2417 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Attribute.obj `if test -f 'SynTree/Attribute.cc'; then $(CYGPATH_W) 'SynTree/Attribute.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Attribute.cc'; fi` 2428 2418 2419 SynTree/driver_cfa_cpp-VarExprReplacer.o: SynTree/VarExprReplacer.cc 2420 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc 2421 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po 2422 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.o' libtool=no @AMDEPBACKSLASH@ 2423 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2424 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.o `test -f 'SynTree/VarExprReplacer.cc' || echo '$(srcdir)/'`SynTree/VarExprReplacer.cc 2425 2426 SynTree/driver_cfa_cpp-VarExprReplacer.obj: SynTree/VarExprReplacer.cc 2427 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-VarExprReplacer.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi` 2428 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po 2429 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='SynTree/VarExprReplacer.cc' object='SynTree/driver_cfa_cpp-VarExprReplacer.obj' libtool=no @AMDEPBACKSLASH@ 2430 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2431 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-VarExprReplacer.obj `if test -f 'SynTree/VarExprReplacer.cc'; then $(CYGPATH_W) 'SynTree/VarExprReplacer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/VarExprReplacer.cc'; fi` 2432 2429 2433 Tuples/driver_cfa_cpp-TupleAssignment.o: Tuples/TupleAssignment.cc 2430 2434 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleAssignment.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Tpo -c -o Tuples/driver_cfa_cpp-TupleAssignment.o `test -f 'Tuples/TupleAssignment.cc' || echo '$(srcdir)/'`Tuples/TupleAssignment.cc … … 2441 2445 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleAssignment.obj `if test -f 'Tuples/TupleAssignment.cc'; then $(CYGPATH_W) 'Tuples/TupleAssignment.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleAssignment.cc'; fi` 2442 2446 2443 Tuples/driver_cfa_cpp-NameMatcher.o: Tuples/NameMatcher.cc 2444 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-NameMatcher.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo -c -o Tuples/driver_cfa_cpp-NameMatcher.o `test -f 'Tuples/NameMatcher.cc' || echo '$(srcdir)/'`Tuples/NameMatcher.cc 2445 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po 2446 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.o' libtool=no @AMDEPBACKSLASH@ 2447 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2448 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-NameMatcher.o `test -f 'Tuples/NameMatcher.cc' || echo '$(srcdir)/'`Tuples/NameMatcher.cc 2449 2450 Tuples/driver_cfa_cpp-NameMatcher.obj: Tuples/NameMatcher.cc 2451 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-NameMatcher.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo -c -o Tuples/driver_cfa_cpp-NameMatcher.obj `if test -f 'Tuples/NameMatcher.cc'; then $(CYGPATH_W) 'Tuples/NameMatcher.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/NameMatcher.cc'; fi` 2452 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po 2453 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.obj' libtool=no @AMDEPBACKSLASH@ 2454 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2455 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-NameMatcher.obj `if test -f 'Tuples/NameMatcher.cc'; then $(CYGPATH_W) 'Tuples/NameMatcher.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/NameMatcher.cc'; fi` 2447 Tuples/driver_cfa_cpp-TupleExpansion.o: Tuples/TupleExpansion.cc 2448 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleExpansion.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo -c -o Tuples/driver_cfa_cpp-TupleExpansion.o `test -f 'Tuples/TupleExpansion.cc' || echo '$(srcdir)/'`Tuples/TupleExpansion.cc 2449 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po 2450 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.o' libtool=no @AMDEPBACKSLASH@ 2451 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2452 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleExpansion.o `test -f 'Tuples/TupleExpansion.cc' || echo '$(srcdir)/'`Tuples/TupleExpansion.cc 2453 2454 Tuples/driver_cfa_cpp-TupleExpansion.obj: Tuples/TupleExpansion.cc 2455 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-TupleExpansion.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo -c -o Tuples/driver_cfa_cpp-TupleExpansion.obj `if test -f 'Tuples/TupleExpansion.cc'; then $(CYGPATH_W) 'Tuples/TupleExpansion.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleExpansion.cc'; fi` 2456 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po 2457 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.obj' libtool=no @AMDEPBACKSLASH@ 2458 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2459 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-TupleExpansion.obj `if test -f 'Tuples/TupleExpansion.cc'; then $(CYGPATH_W) 'Tuples/TupleExpansion.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/TupleExpansion.cc'; fi` 2460 2461 Tuples/driver_cfa_cpp-Explode.o: Tuples/Explode.cc 2462 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-Explode.o -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo -c -o Tuples/driver_cfa_cpp-Explode.o `test -f 'Tuples/Explode.cc' || echo '$(srcdir)/'`Tuples/Explode.cc 2463 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Po 2464 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/Explode.cc' object='Tuples/driver_cfa_cpp-Explode.o' libtool=no @AMDEPBACKSLASH@ 2465 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2466 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Explode.o `test -f 'Tuples/Explode.cc' || echo '$(srcdir)/'`Tuples/Explode.cc 2467 2468 Tuples/driver_cfa_cpp-Explode.obj: Tuples/Explode.cc 2469 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Tuples/driver_cfa_cpp-Explode.obj -MD -MP -MF Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo -c -o Tuples/driver_cfa_cpp-Explode.obj `if test -f 'Tuples/Explode.cc'; then $(CYGPATH_W) 'Tuples/Explode.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Explode.cc'; fi` 2470 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-Explode.Po 2471 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/Explode.cc' object='Tuples/driver_cfa_cpp-Explode.obj' libtool=no @AMDEPBACKSLASH@ 2472 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2473 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o Tuples/driver_cfa_cpp-Explode.obj `if test -f 'Tuples/Explode.cc'; then $(CYGPATH_W) 'Tuples/Explode.cc'; else $(CYGPATH_W) '$(srcdir)/Tuples/Explode.cc'; fi` 2456 2474 2457 2475 .ll.cc: -
src/Parser/ExpressionNode.cc
r84118d8 rb726084 172 172 } // build_constantStr 173 173 174 Expression * build_field_name_FLOATINGconstant( const std::string & str ) { 175 // str is of the form A.B -> separate at the . and return member expression 176 int a, b; 177 char dot; 178 std::stringstream ss( str ); 179 ss >> a >> dot >> b; 180 UntypedMemberExpr * ret = new UntypedMemberExpr( 181 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( b ) ) ), 182 new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::SignedInt ), toString( a ) ) ) ); 183 delete &str; 184 return ret; 185 } // build_field_name_FLOATINGconstant 186 187 Expression * make_field_name_fraction_constants( Expression * fieldName, Expression * fracts ) { 188 if ( fracts ) { 189 if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * >( fracts ) ) { 190 memberExpr->set_member( make_field_name_fraction_constants( fieldName, memberExpr->get_aggregate() ) ); 191 return memberExpr; 192 } else { 193 return new UntypedMemberExpr( fracts, fieldName ); 194 } 195 } 196 return fieldName; 197 } // make_field_name_fraction_constants 198 199 Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts ) { 200 return make_field_name_fraction_constants( fieldName, maybeMoveBuild< Expression >( fracts ) ); 201 } // build_field_name_fraction_constants 202 203 Expression * build_field_name_REALFRACTIONconstant( const std::string & str ) { 204 assert( str[0] == '.' ); 205 Expression * ret = build_constantInteger( *new std::string( str.substr(1) ) ); 206 delete &str; 207 return ret; 208 } // build_field_name_REALFRACTIONconstant 209 210 Expression * build_field_name_REALDECIMALconstant( const std::string & str ) { 211 assert( str[str.size()-1] == '.' ); 212 Expression * ret = build_constantInteger( *new std::string( str.substr( 0, str.size()-1 ) ) ); 213 delete &str; 214 return ret; 215 } // build_field_name_REALDECIMALconstant 216 174 217 NameExpr * build_varref( const string *name, bool labelp ) { 175 218 NameExpr *expr = new NameExpr( *name, nullptr ); … … 198 241 } 199 242 200 Expression *build_fieldSel( ExpressionNode *expr_node, NameExpr *member ) { 201 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeMoveBuild< Expression >(expr_node) ); 202 delete member; 203 return ret; 204 } 205 206 Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) { 243 Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) { 244 UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) ); 245 return ret; 246 } 247 248 Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) { 207 249 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 208 250 deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) ); 209 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref ); 210 delete member; 251 UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref ); 211 252 return ret; 212 253 } -
src/Parser/ParseNode.h
r84118d8 rb726084 155 155 Expression * build_constantChar( const std::string &str ); 156 156 ConstantExpr * build_constantStr( const std::string &str ); 157 Expression * build_field_name_FLOATINGconstant( const std::string & str ); 158 Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts ); 159 Expression * build_field_name_REALFRACTIONconstant( const std::string & str ); 160 Expression * build_field_name_REALDECIMALconstant( const std::string & str ); 157 161 158 162 NameExpr * build_varref( const std::string * name, bool labelp = false ); … … 160 164 161 165 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 162 Expression * build_fieldSel( ExpressionNode * expr_node, NameExpr* member );163 Expression * build_pfieldSel( ExpressionNode * expr_node, NameExpr* member );166 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); 167 Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ); 164 168 Expression * build_addressOf( ExpressionNode * expr_node ); 165 169 Expression * build_sizeOfexpr( ExpressionNode * expr_node ); … … 383 387 //############################################################################## 384 388 385 template< typename SynTreeType, typename NodeType >386 void buildList( const NodeType * firstNode, std::list< SynTreeType *> &outputList ) {389 template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args > 390 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) { 387 391 SemanticError errors; 388 std::back_insert_iterator< std::list< SynTreeType *> > out( outputList );392 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList ); 389 393 const NodeType * cur = firstNode; 390 394 -
src/Parser/TypeData.cc
r84118d8 rb726084 385 385 } // TypeData::print 386 386 387 void buildForall( const DeclarationNode * firstNode, list< TypeDecl* > &outputList ) { 387 template< typename ForallList > 388 void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) { 388 389 buildList( firstNode, outputList ); 389 for ( list< TypeDecl* >::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 390 if ( (*i)->get_kind() == TypeDecl::Any ) { 390 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) { 391 TypeDecl * td = static_cast<TypeDecl*>(*i); 392 if ( td->get_kind() == TypeDecl::Any ) { 391 393 // add assertion parameters to `type' tyvars in reverse order 392 394 // add dtor: void ^?{}(T *) 393 395 FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false ); 394 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );395 (*i)->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );396 dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 397 td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) ); 396 398 397 399 // add copy ctor: void ?{}(T *, T) 398 400 FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false ); 399 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );400 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );401 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );401 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 402 copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 403 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) ); 402 404 403 405 // add default ctor: void ?{}(T *) 404 406 FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false ); 405 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );406 (*i)->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );407 ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 408 td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) ); 407 409 408 410 // add assignment operator: T * ?=?(T *, T) 409 411 FunctionType * assignType = new FunctionType( Type::Qualifiers(), false ); 410 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ) ), nullptr ) );411 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );412 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), (*i)->get_name(), *i ), nullptr ) );413 (*i)->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );412 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) ); 413 assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 414 assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) ); 415 td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) ); 414 416 } // if 415 417 } // for … … 515 517 // character types. The implementation shall define char to have the same range, representation, and behavior as 516 518 // either signed char or unsigned char. 517 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 519 static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 518 520 519 521 if ( td->length != DeclarationNode::NoLength ) { -
src/Parser/parser.cc
r84118d8 rb726084 1026 1026 static const yytype_uint16 yyrline[] = 1027 1027 { 1028 0, 30 6, 306, 310, 317, 318, 319, 320, 321, 325,1029 32 6, 327, 331, 332, 336, 337, 341, 342, 346, 350,1030 35 1, 362, 364, 366, 367, 369, 374, 375, 381, 383,1031 38 5, 386, 387, 389, 390, 392, 394, 396, 405, 406,1032 41 2, 413, 417, 418, 422, 424, 426, 428, 430, 432,1033 43 4, 439, 441, 443, 447, 449, 453, 456, 458, 460,1034 4 65, 478, 480, 482, 484, 486, 488, 490, 492, 494,1035 496, 498, 505, 506, 512, 513, 514, 515, 519, 520,1036 5 27, 528, 530, 532, 537, 538, 540, 545, 546, 548,1037 55 3, 554, 556, 558, 560, 565, 566, 568, 573, 574,1038 5 79, 580, 585, 586, 591, 592, 597, 598, 603, 604,1039 6 07, 614, 619, 620, 628, 629, 633, 634, 635, 636,1040 6 37, 638, 639, 640, 641, 642, 643, 644, 654, 656,1041 66 1, 662, 667, 668, 674, 675, 681, 682, 683, 684,1042 6 85, 686, 687, 688, 689, 699, 706, 708, 718, 719,1043 7 24, 726, 732, 734, 738, 739, 744, 749, 752, 754,1044 7 56, 766, 768, 779, 780, 782, 786, 788, 792, 793,1045 798, 799, 803, 808, 809, 813, 815, 821, 822, 826,1046 8 28, 830, 832, 838, 839, 843, 845, 850, 852, 854,1047 8 59, 861, 866, 868, 872, 875, 879, 882, 886, 888,1048 89 0, 892, 897, 899, 901, 906, 908, 910, 912, 914,1049 9 19, 921, 923, 925, 930, 942, 943, 948, 950, 955,1050 9 59, 961, 963, 965, 967, 973, 974, 980, 981, 985,1051 9 86, 991, 993, 999, 1000, 1002, 1007, 1012, 1022, 1024,1052 10 28, 1029, 1034, 1036, 1040, 1041, 1045, 1047, 1051, 1052,1053 10 56, 1057, 1061, 1062, 1077, 1078, 1079, 1080, 1081, 1085,1054 109 0, 1097, 1107, 1112, 1117, 1125, 1130, 1135, 1140, 1145,1055 11 75, 1180, 1187, 1189, 1196, 1201, 1206, 1217, 1222, 1227,1056 123 2, 1237, 1246, 1251, 1259, 1260, 1261, 1262, 1268, 1273,1057 128 1, 1282, 1283, 1284, 1288, 1289, 1290, 1291, 1296, 1297,1058 13 06, 1307, 1312, 1313, 1318, 1320, 1322, 1324, 1326, 1329,1059 13 28, 1340, 1341, 1343, 1353, 1354, 1359, 1361, 1363, 1365,1060 13 67, 1370, 1372, 1375, 1380, 1382, 1384, 1386, 1388, 1390,1061 139 2, 1394, 1396, 1398, 1400, 1402, 1404, 1410, 1411, 1413,1062 14 15, 1417, 1422, 1423, 1429, 1430, 1432, 1434, 1439, 1441,1063 144 3, 1445, 1450, 1451, 1453, 1455, 1460, 1461, 1463, 1468,1064 14 69, 1471, 1473, 1478, 1480, 1482, 1487, 1488, 1492, 1494,1065 150 0, 1499, 1503, 1505, 1510, 1512, 1518, 1519, 1524, 1525,1066 15 27, 1528, 1537, 1538, 1540, 1542, 1547, 1549, 1555, 1556,1067 15 58, 1561, 1564, 1569, 1570, 1575, 1580, 1584, 1586, 1592,1068 159 1, 1598, 1600, 1606, 1607, 1615, 1616, 1620, 1621, 1622,1069 16 24, 1626, 1633, 1634, 1636, 1638, 1643, 1644, 1650, 1651,1070 16 55, 1656, 1661, 1662, 1663, 1665, 1673, 1674, 1676, 1679,1071 168 1, 1685, 1686, 1687, 1689, 1691, 1695, 1700, 1708, 1709,1072 17 18, 1720, 1725, 1726, 1727, 1731, 1732, 1733, 1737, 1738,1073 17 39, 1743, 1744, 1745, 1750, 1751, 1752, 1753, 1759, 1760,1074 176 2, 1767, 1768, 1773, 1774, 1775, 1776, 1777, 1792, 1793,1075 1 798, 1799, 1805, 1807, 1810, 1812, 1814, 1837, 1838, 1840,1076 184 2, 1847, 1848, 1850, 1855, 1860, 1861, 1867, 1866, 1870,1077 18 74, 1876, 1878, 1884, 1885, 1890, 1895, 1897, 1902, 1904,1078 19 05, 1907, 1912, 1914, 1916, 1921, 1923, 1928, 1933, 1941,1079 19 47, 1946, 1960, 1961, 1966, 1967, 1971, 1976, 1981, 1989,1080 1994, 2005, 2006, 2011, 2012, 2018, 2019, 2023, 2024, 2025,1081 20 28, 2027, 2038, 2047, 2053, 2059, 2068, 2074, 2080, 2086,1082 209 2, 2100, 2106, 2114, 2120, 2129, 2130, 2131, 2135, 2139,1083 214 1, 2146, 2147, 2151, 2152, 2157, 2163, 2164, 2167, 2169,1084 217 0, 2174, 2175, 2176, 2177, 2211, 2213, 2214, 2216, 2221,1085 22 26, 2231, 2233, 2235, 2240, 2242, 2244, 2246, 2251, 2253,1086 226 2, 2264, 2265, 2270, 2272, 2274, 2279, 2281, 2283, 2288,1087 229 0, 2292, 2301, 2302, 2303, 2307, 2309, 2311, 2316, 2318,1088 232 0, 2325, 2327, 2329, 2344, 2346, 2347, 2349, 2354, 2355,1089 236 0, 2362, 2364, 2369, 2371, 2373, 2375, 2380, 2382, 2384,1090 2 394, 2396, 2397, 2399, 2404, 2406, 2408, 2413, 2415, 2417,1091 24 19, 2424, 2426, 2428, 2459, 2461, 2462, 2464, 2469, 2474,1092 248 2, 2484, 2486, 2491, 2493, 2498, 2500, 2514, 2515, 2517,1093 252 2, 2524, 2526, 2528, 2530, 2535, 2536, 2538, 2540, 2545,1094 25 47, 2549, 2555, 2557, 2559, 2563, 2565, 2567, 2569, 2583,1095 25 84, 2586, 2591, 2593, 2595, 2597, 2599, 2604, 2605, 2607,1096 26 09, 2614, 2616, 2618, 2624, 2625, 2627, 2636, 2639, 2641,1097 26 44, 2646, 2648, 2661, 2662, 2664, 2669, 2671, 2673, 2675,1098 26 77, 2682, 2683, 2685, 2687, 2692, 2694, 2702, 2703, 2704,1099 27 09, 2710, 2714, 2716, 2718, 2720, 2722, 2724, 2731, 2733,1100 27 35, 2737, 2739, 2742, 2744, 2746, 2748, 2750, 2755, 2757,1101 27 59, 2764, 2790, 2791, 2793, 2797, 2798, 2802, 2804, 2806,1102 28 08, 2810, 2812, 2819, 2821, 2823, 2825, 2827, 2829, 2834,1103 284 1, 2843, 2861, 2863, 2868, 28691028 0, 305, 305, 309, 316, 317, 318, 319, 320, 324, 1029 325, 326, 330, 331, 335, 336, 340, 341, 345, 349, 1030 350, 361, 363, 365, 366, 368, 373, 374, 380, 382, 1031 384, 386, 388, 390, 392, 394, 396, 398, 407, 408, 1032 414, 415, 419, 420, 424, 425, 427, 429, 431, 433, 1033 435, 440, 442, 444, 450, 451, 459, 462, 464, 466, 1034 471, 484, 486, 488, 490, 492, 494, 496, 498, 500, 1035 502, 504, 511, 512, 518, 519, 520, 521, 525, 526, 1036 533, 534, 536, 538, 543, 544, 546, 551, 552, 554, 1037 559, 560, 562, 564, 566, 571, 572, 574, 579, 580, 1038 585, 586, 591, 592, 597, 598, 603, 604, 609, 610, 1039 613, 620, 625, 626, 634, 635, 639, 640, 641, 642, 1040 643, 644, 645, 646, 647, 648, 649, 650, 660, 662, 1041 667, 668, 673, 674, 680, 681, 687, 688, 689, 690, 1042 691, 692, 693, 694, 695, 705, 712, 714, 724, 725, 1043 730, 732, 738, 740, 744, 745, 750, 755, 758, 760, 1044 762, 772, 774, 785, 786, 788, 792, 794, 798, 799, 1045 804, 805, 809, 814, 815, 819, 821, 827, 828, 832, 1046 834, 836, 838, 844, 845, 849, 851, 856, 858, 860, 1047 865, 867, 872, 874, 878, 881, 885, 888, 892, 894, 1048 896, 898, 903, 905, 907, 912, 914, 916, 918, 920, 1049 925, 927, 929, 931, 936, 948, 949, 954, 956, 961, 1050 965, 967, 969, 971, 973, 979, 980, 986, 987, 991, 1051 992, 997, 999, 1005, 1006, 1008, 1013, 1018, 1028, 1030, 1052 1034, 1035, 1040, 1042, 1046, 1047, 1051, 1053, 1057, 1058, 1053 1062, 1063, 1067, 1068, 1083, 1084, 1085, 1086, 1087, 1091, 1054 1096, 1103, 1113, 1118, 1123, 1131, 1136, 1141, 1146, 1151, 1055 1181, 1186, 1193, 1195, 1202, 1207, 1212, 1223, 1228, 1233, 1056 1238, 1243, 1252, 1257, 1265, 1266, 1267, 1268, 1274, 1279, 1057 1287, 1288, 1289, 1290, 1294, 1295, 1296, 1297, 1302, 1303, 1058 1312, 1313, 1318, 1319, 1324, 1326, 1328, 1330, 1332, 1335, 1059 1334, 1346, 1347, 1349, 1359, 1360, 1365, 1367, 1369, 1371, 1060 1373, 1376, 1378, 1381, 1386, 1388, 1390, 1392, 1394, 1396, 1061 1398, 1400, 1402, 1404, 1406, 1408, 1410, 1416, 1417, 1419, 1062 1421, 1423, 1428, 1429, 1435, 1436, 1438, 1440, 1445, 1447, 1063 1449, 1451, 1456, 1457, 1459, 1461, 1466, 1467, 1469, 1474, 1064 1475, 1477, 1479, 1484, 1486, 1488, 1493, 1494, 1498, 1500, 1065 1506, 1505, 1509, 1511, 1516, 1518, 1524, 1525, 1530, 1531, 1066 1533, 1534, 1543, 1544, 1546, 1548, 1553, 1555, 1561, 1562, 1067 1564, 1567, 1570, 1575, 1576, 1581, 1586, 1590, 1592, 1598, 1068 1597, 1604, 1606, 1612, 1613, 1621, 1622, 1626, 1627, 1628, 1069 1630, 1632, 1639, 1640, 1642, 1644, 1649, 1650, 1656, 1657, 1070 1661, 1662, 1667, 1668, 1669, 1671, 1679, 1680, 1682, 1685, 1071 1687, 1691, 1692, 1693, 1695, 1697, 1701, 1706, 1714, 1715, 1072 1724, 1726, 1731, 1732, 1733, 1737, 1738, 1739, 1743, 1744, 1073 1745, 1749, 1750, 1751, 1756, 1757, 1758, 1759, 1765, 1766, 1074 1768, 1773, 1774, 1779, 1780, 1781, 1782, 1783, 1798, 1799, 1075 1804, 1805, 1811, 1813, 1816, 1818, 1820, 1843, 1844, 1846, 1076 1848, 1853, 1854, 1856, 1861, 1866, 1867, 1873, 1872, 1876, 1077 1880, 1882, 1884, 1890, 1891, 1896, 1901, 1903, 1908, 1910, 1078 1911, 1913, 1918, 1920, 1922, 1927, 1929, 1934, 1939, 1947, 1079 1953, 1952, 1966, 1967, 1972, 1973, 1977, 1982, 1987, 1995, 1080 2000, 2011, 2012, 2017, 2018, 2024, 2025, 2029, 2030, 2031, 1081 2034, 2033, 2044, 2053, 2059, 2065, 2074, 2080, 2086, 2092, 1082 2098, 2106, 2112, 2120, 2126, 2135, 2136, 2137, 2141, 2145, 1083 2147, 2152, 2153, 2157, 2158, 2163, 2169, 2170, 2173, 2175, 1084 2176, 2180, 2181, 2182, 2183, 2217, 2219, 2220, 2222, 2227, 1085 2232, 2237, 2239, 2241, 2246, 2248, 2250, 2252, 2257, 2259, 1086 2268, 2270, 2271, 2276, 2278, 2280, 2285, 2287, 2289, 2294, 1087 2296, 2298, 2307, 2308, 2309, 2313, 2315, 2317, 2322, 2324, 1088 2326, 2331, 2333, 2335, 2350, 2352, 2353, 2355, 2360, 2361, 1089 2366, 2368, 2370, 2375, 2377, 2379, 2381, 2386, 2388, 2390, 1090 2400, 2402, 2403, 2405, 2410, 2412, 2414, 2419, 2421, 2423, 1091 2425, 2430, 2432, 2434, 2465, 2467, 2468, 2470, 2475, 2480, 1092 2488, 2490, 2492, 2497, 2499, 2504, 2506, 2520, 2521, 2523, 1093 2528, 2530, 2532, 2534, 2536, 2541, 2542, 2544, 2546, 2551, 1094 2553, 2555, 2561, 2563, 2565, 2569, 2571, 2573, 2575, 2589, 1095 2590, 2592, 2597, 2599, 2601, 2603, 2605, 2610, 2611, 2613, 1096 2615, 2620, 2622, 2624, 2630, 2631, 2633, 2642, 2645, 2647, 1097 2650, 2652, 2654, 2667, 2668, 2670, 2675, 2677, 2679, 2681, 1098 2683, 2688, 2689, 2691, 2693, 2698, 2700, 2708, 2709, 2710, 1099 2715, 2716, 2720, 2722, 2724, 2726, 2728, 2730, 2737, 2739, 1100 2741, 2743, 2745, 2748, 2750, 2752, 2754, 2756, 2761, 2763, 1101 2765, 2770, 2796, 2797, 2799, 2803, 2804, 2808, 2810, 2812, 1102 2814, 2816, 2818, 2825, 2827, 2829, 2831, 2833, 2835, 2840, 1103 2847, 2849, 2867, 2869, 2874, 2875 1104 1104 }; 1105 1105 #endif … … 4851 4851 4852 4852 /* Line 1806 of yacc.c */ 4853 #line 30 6"parser.yy"4853 #line 305 "parser.yy" 4854 4854 { typedefTable.enterScope(); } 4855 4855 break; … … 4858 4858 4859 4859 /* Line 1806 of yacc.c */ 4860 #line 3 10"parser.yy"4860 #line 309 "parser.yy" 4861 4861 { typedefTable.leaveScope(); } 4862 4862 break; … … 4865 4865 4866 4866 /* Line 1806 of yacc.c */ 4867 #line 316 "parser.yy" 4868 { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); } 4869 break; 4870 4871 case 5: 4872 4873 /* Line 1806 of yacc.c */ 4867 4874 #line 317 "parser.yy" 4868 { (yyval.en) = new ExpressionNode( build_constant Integer( *(yyvsp[(1) - (1)].tok) ) ); }4869 break; 4870 4871 case 5:4875 { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); } 4876 break; 4877 4878 case 6: 4872 4879 4873 4880 /* Line 1806 of yacc.c */ … … 4876 4883 break; 4877 4884 4878 case 6:4885 case 7: 4879 4886 4880 4887 /* Line 1806 of yacc.c */ … … 4883 4890 break; 4884 4891 4885 case 7:4892 case 8: 4886 4893 4887 4894 /* Line 1806 of yacc.c */ 4888 4895 #line 320 "parser.yy" 4889 { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); }4890 break;4891 4892 case 8:4893 4894 /* Line 1806 of yacc.c */4895 #line 321 "parser.yy"4896 4896 { (yyval.en) = new ExpressionNode( build_constantChar( *(yyvsp[(1) - (1)].tok) ) ); } 4897 4897 break; … … 4900 4900 4901 4901 /* Line 1806 of yacc.c */ 4902 #line 34 6"parser.yy"4902 #line 345 "parser.yy" 4903 4903 { (yyval.constant) = build_constantStr( *(yyvsp[(1) - (1)].str) ); } 4904 4904 break; … … 4907 4907 4908 4908 /* Line 1806 of yacc.c */ 4909 #line 3 50"parser.yy"4909 #line 349 "parser.yy" 4910 4910 { (yyval.str) = (yyvsp[(1) - (1)].tok); } 4911 4911 break; … … 4914 4914 4915 4915 /* Line 1806 of yacc.c */ 4916 #line 35 2"parser.yy"4916 #line 351 "parser.yy" 4917 4917 { 4918 4918 appendStr( (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].tok) ); // append 2nd juxtaposed string to 1st … … 4925 4925 4926 4926 /* Line 1806 of yacc.c */ 4927 #line 36 3"parser.yy"4927 #line 362 "parser.yy" 4928 4928 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); } 4929 4929 break; … … 4932 4932 4933 4933 /* Line 1806 of yacc.c */ 4934 #line 36 5"parser.yy"4934 #line 364 "parser.yy" 4935 4935 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); } 4936 4936 break; … … 4939 4939 4940 4940 /* Line 1806 of yacc.c */ 4941 #line 36 8"parser.yy"4941 #line 367 "parser.yy" 4942 4942 { (yyval.en) = (yyvsp[(2) - (3)].en); } 4943 4943 break; … … 4946 4946 4947 4947 /* Line 1806 of yacc.c */ 4948 #line 3 70"parser.yy"4948 #line 369 "parser.yy" 4949 4949 { (yyval.en) = new ExpressionNode( build_valexpr( (yyvsp[(2) - (3)].sn) ) ); } 4950 4950 break; … … 4953 4953 4954 4954 /* Line 1806 of yacc.c */ 4955 #line 3 80"parser.yy"4955 #line 379 "parser.yy" 4956 4956 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Index, (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en) ) ); } 4957 4957 break; … … 4960 4960 4961 4961 /* Line 1806 of yacc.c */ 4962 #line 38 2"parser.yy"4962 #line 381 "parser.yy" 4963 4963 { (yyval.en) = new ExpressionNode( build_func( (yyvsp[(1) - (4)].en), (yyvsp[(3) - (4)].en) ) ); } 4964 4964 break; … … 4967 4967 4968 4968 /* Line 1806 of yacc.c */ 4969 #line 38 4"parser.yy"4969 #line 383 "parser.yy" 4970 4970 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); } 4971 4971 break; 4972 4972 4973 case 30: 4974 4975 /* Line 1806 of yacc.c */ 4976 #line 385 "parser.yy" 4977 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 4978 break; 4979 4980 case 31: 4981 4982 /* Line 1806 of yacc.c */ 4983 #line 387 "parser.yy" 4984 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (2)].en), build_field_name_REALFRACTIONconstant( *(yyvsp[(2) - (2)].tok) ) ) ); } 4985 break; 4986 4973 4987 case 32: 4974 4988 4975 4989 /* Line 1806 of yacc.c */ 4976 #line 38 8"parser.yy"4990 #line 389 "parser.yy" 4977 4991 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); } 4978 4992 break; 4979 4993 4994 case 33: 4995 4996 /* Line 1806 of yacc.c */ 4997 #line 391 "parser.yy" 4998 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 4999 break; 5000 4980 5001 case 34: 4981 5002 4982 5003 /* Line 1806 of yacc.c */ 4983 #line 39 1"parser.yy"5004 #line 393 "parser.yy" 4984 5005 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, (yyvsp[(1) - (2)].en) ) ); } 4985 5006 break; … … 4988 5009 4989 5010 /* Line 1806 of yacc.c */ 4990 #line 39 3"parser.yy"5011 #line 395 "parser.yy" 4991 5012 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, (yyvsp[(1) - (2)].en) ) ); } 4992 5013 break; … … 4995 5016 4996 5017 /* Line 1806 of yacc.c */ 4997 #line 39 5"parser.yy"5018 #line 397 "parser.yy" 4998 5019 { (yyval.en) = new ExpressionNode( build_compoundLiteral( (yyvsp[(2) - (7)].decl), new InitializerNode( (yyvsp[(5) - (7)].in), true ) ) ); } 4999 5020 break; … … 5002 5023 5003 5024 /* Line 1806 of yacc.c */ 5004 #line 39 7"parser.yy"5025 #line 399 "parser.yy" 5005 5026 { 5006 5027 Token fn; … … 5013 5034 5014 5035 /* Line 1806 of yacc.c */ 5015 #line 40 7"parser.yy"5036 #line 409 "parser.yy" 5016 5037 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); } 5017 5038 break; … … 5020 5041 5021 5042 /* Line 1806 of yacc.c */ 5022 #line 41 2"parser.yy"5043 #line 414 "parser.yy" 5023 5044 { (yyval.en) = 0; } 5024 5045 break; … … 5027 5048 5028 5049 /* Line 1806 of yacc.c */ 5029 #line 4 18"parser.yy"5050 #line 420 "parser.yy" 5030 5051 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 5031 5052 break; 5032 5053 5033 case 44:5034 5035 /* Line 1806 of yacc.c */5036 #line 423 "parser.yy"5037 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); }5038 break;5039 5040 5054 case 45: 5041 5055 5042 5056 /* Line 1806 of yacc.c */ 5043 #line 42 5"parser.yy"5044 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(2) - (2)].en), build_varref( (yyvsp[(1) - (2)].tok) ) ) ); }5057 #line 426 "parser.yy" 5058 { (yyval.en) = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *(yyvsp[(1) - (2)].tok) ) ), maybeMoveBuild<Expression>( (yyvsp[(2) - (2)].en) ) ) ); } 5045 5059 break; 5046 5060 … … 5048 5062 5049 5063 /* Line 1806 of yacc.c */ 5050 #line 42 7"parser.yy"5051 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(4) - (6)].en), build_varref( (yyvsp[(1) - (6)].tok) ) ) ); }5064 #line 428 "parser.yy" 5065 { (yyval.en) = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *(yyvsp[(1) - (6)].tok) ) ), build_tuple( (yyvsp[(4) - (6)].en) ) ) ); } 5052 5066 break; 5053 5067 … … 5055 5069 5056 5070 /* Line 1806 of yacc.c */ 5057 #line 4 29"parser.yy"5058 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[( 3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }5071 #line 430 "parser.yy" 5072 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); } 5059 5073 break; 5060 5074 … … 5062 5076 5063 5077 /* Line 1806 of yacc.c */ 5064 #line 43 1"parser.yy"5065 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[( 5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }5078 #line 432 "parser.yy" 5079 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 5066 5080 break; 5067 5081 … … 5069 5083 5070 5084 /* Line 1806 of yacc.c */ 5071 #line 43 3"parser.yy"5072 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[( 3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); }5085 #line 434 "parser.yy" 5086 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); } 5073 5087 break; 5074 5088 … … 5076 5090 5077 5091 /* Line 1806 of yacc.c */ 5078 #line 43 5"parser.yy"5079 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[( 5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); }5092 #line 436 "parser.yy" 5093 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 5080 5094 break; 5081 5095 … … 5083 5097 5084 5098 /* Line 1806 of yacc.c */ 5085 #line 44 0"parser.yy"5086 { (yyval. tok) = (yyvsp[(1) - (2)].tok); }5099 #line 441 "parser.yy" 5100 { (yyval.en) = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *(yyvsp[(1) - (2)].tok) ), (yyvsp[(2) - (2)].en) ) ); } 5087 5101 break; 5088 5102 … … 5090 5104 5091 5105 /* Line 1806 of yacc.c */ 5092 #line 44 2"parser.yy"5093 { (yyval. tok) = (yyvsp[(1) - (2)].tok); }5106 #line 443 "parser.yy" 5107 { (yyval.en) = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *(yyvsp[(1) - (2)].tok) ), (yyvsp[(2) - (2)].en) ) ); } 5094 5108 break; 5095 5109 … … 5097 5111 5098 5112 /* Line 1806 of yacc.c */ 5099 #line 444 "parser.yy" 5100 { (yyval.tok) = (yyvsp[(1) - (2)].tok); } 5113 #line 445 "parser.yy" 5114 { (yyval.en) = new ExpressionNode( build_field_name_fraction_constants( build_varref( (yyvsp[(1) - (2)].tok) ), (yyvsp[(2) - (2)].en) ) ); } 5115 break; 5116 5117 case 54: 5118 5119 /* Line 1806 of yacc.c */ 5120 #line 450 "parser.yy" 5121 { (yyval.en) = nullptr; } 5122 break; 5123 5124 case 55: 5125 5126 /* Line 1806 of yacc.c */ 5127 #line 452 "parser.yy" 5128 { 5129 Expression * constant = build_field_name_REALFRACTIONconstant( *(yyvsp[(2) - (2)].tok) ); 5130 (yyval.en) = (yyvsp[(1) - (2)].en) != nullptr ? new ExpressionNode( build_fieldSel( (yyvsp[(1) - (2)].en), constant ) ) : new ExpressionNode( constant ); 5131 } 5101 5132 break; 5102 5133 … … 5104 5135 5105 5136 /* Line 1806 of yacc.c */ 5106 #line 4 57"parser.yy"5137 #line 463 "parser.yy" 5107 5138 { (yyval.en) = (yyvsp[(1) - (1)].en); } 5108 5139 break; … … 5111 5142 5112 5143 /* Line 1806 of yacc.c */ 5113 #line 4 59"parser.yy"5144 #line 465 "parser.yy" 5114 5145 { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); } 5115 5146 break; … … 5118 5149 5119 5150 /* Line 1806 of yacc.c */ 5120 #line 46 1"parser.yy"5151 #line 467 "parser.yy" 5121 5152 { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); } 5122 5153 break; … … 5125 5156 5126 5157 /* Line 1806 of yacc.c */ 5127 #line 4 66"parser.yy"5158 #line 472 "parser.yy" 5128 5159 { 5129 5160 switch ( (yyvsp[(1) - (2)].op) ) { … … 5143 5174 5144 5175 /* Line 1806 of yacc.c */ 5145 #line 4 79"parser.yy"5176 #line 485 "parser.yy" 5146 5177 { (yyval.en) = new ExpressionNode( build_unary_val( (yyvsp[(1) - (2)].op), (yyvsp[(2) - (2)].en) ) ); } 5147 5178 break; … … 5150 5181 5151 5182 /* Line 1806 of yacc.c */ 5152 #line 48 1"parser.yy"5183 #line 487 "parser.yy" 5153 5184 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Incr, (yyvsp[(2) - (2)].en) ) ); } 5154 5185 break; … … 5157 5188 5158 5189 /* Line 1806 of yacc.c */ 5159 #line 48 3"parser.yy"5190 #line 489 "parser.yy" 5160 5191 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Decr, (yyvsp[(2) - (2)].en) ) ); } 5161 5192 break; … … 5164 5195 5165 5196 /* Line 1806 of yacc.c */ 5166 #line 4 85"parser.yy"5197 #line 491 "parser.yy" 5167 5198 { (yyval.en) = new ExpressionNode( build_sizeOfexpr( (yyvsp[(2) - (2)].en) ) ); } 5168 5199 break; … … 5171 5202 5172 5203 /* Line 1806 of yacc.c */ 5173 #line 4 87"parser.yy"5204 #line 493 "parser.yy" 5174 5205 { (yyval.en) = new ExpressionNode( build_sizeOftype( (yyvsp[(3) - (4)].decl) ) ); } 5175 5206 break; … … 5178 5209 5179 5210 /* Line 1806 of yacc.c */ 5180 #line 4 89"parser.yy"5211 #line 495 "parser.yy" 5181 5212 { (yyval.en) = new ExpressionNode( build_alignOfexpr( (yyvsp[(2) - (2)].en) ) ); } 5182 5213 break; … … 5185 5216 5186 5217 /* Line 1806 of yacc.c */ 5187 #line 49 1"parser.yy"5218 #line 497 "parser.yy" 5188 5219 { (yyval.en) = new ExpressionNode( build_alignOftype( (yyvsp[(3) - (4)].decl) ) ); } 5189 5220 break; … … 5192 5223 5193 5224 /* Line 1806 of yacc.c */ 5194 #line 49 3"parser.yy"5225 #line 499 "parser.yy" 5195 5226 { (yyval.en) = new ExpressionNode( build_offsetOf( (yyvsp[(3) - (6)].decl), build_varref( (yyvsp[(5) - (6)].tok) ) ) ); } 5196 5227 break; … … 5199 5230 5200 5231 /* Line 1806 of yacc.c */ 5201 #line 495"parser.yy"5232 #line 501 "parser.yy" 5202 5233 { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (1)].tok) ), nullptr ) ); } 5203 5234 break; … … 5206 5237 5207 5238 /* Line 1806 of yacc.c */ 5208 #line 497"parser.yy"5239 #line 503 "parser.yy" 5209 5240 { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ) ); } 5210 5241 break; … … 5213 5244 5214 5245 /* Line 1806 of yacc.c */ 5215 #line 499"parser.yy"5246 #line 505 "parser.yy" 5216 5247 { (yyval.en) = new ExpressionNode( build_attrtype( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].decl) ) ); } 5217 5248 break; … … 5220 5251 5221 5252 /* Line 1806 of yacc.c */ 5222 #line 5 05"parser.yy"5253 #line 511 "parser.yy" 5223 5254 { (yyval.op) = OperKinds::PointTo; } 5224 5255 break; … … 5227 5258 5228 5259 /* Line 1806 of yacc.c */ 5229 #line 5 06"parser.yy"5260 #line 512 "parser.yy" 5230 5261 { (yyval.op) = OperKinds::AddressOf; } 5231 5262 break; … … 5234 5265 5235 5266 /* Line 1806 of yacc.c */ 5236 #line 51 2"parser.yy"5267 #line 518 "parser.yy" 5237 5268 { (yyval.op) = OperKinds::UnPlus; } 5238 5269 break; … … 5241 5272 5242 5273 /* Line 1806 of yacc.c */ 5243 #line 51 3"parser.yy"5274 #line 519 "parser.yy" 5244 5275 { (yyval.op) = OperKinds::UnMinus; } 5245 5276 break; … … 5248 5279 5249 5280 /* Line 1806 of yacc.c */ 5250 #line 5 14"parser.yy"5281 #line 520 "parser.yy" 5251 5282 { (yyval.op) = OperKinds::Neg; } 5252 5283 break; … … 5255 5286 5256 5287 /* Line 1806 of yacc.c */ 5257 #line 5 15"parser.yy"5288 #line 521 "parser.yy" 5258 5289 { (yyval.op) = OperKinds::BitNeg; } 5259 5290 break; … … 5262 5293 5263 5294 /* Line 1806 of yacc.c */ 5264 #line 52 1"parser.yy"5295 #line 527 "parser.yy" 5265 5296 { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); } 5266 5297 break; … … 5269 5300 5270 5301 /* Line 1806 of yacc.c */ 5271 #line 5 29"parser.yy"5302 #line 535 "parser.yy" 5272 5303 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5273 5304 break; … … 5276 5307 5277 5308 /* Line 1806 of yacc.c */ 5278 #line 53 1"parser.yy"5309 #line 537 "parser.yy" 5279 5310 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5280 5311 break; … … 5283 5314 5284 5315 /* Line 1806 of yacc.c */ 5285 #line 53 3"parser.yy"5316 #line 539 "parser.yy" 5286 5317 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5287 5318 break; … … 5290 5321 5291 5322 /* Line 1806 of yacc.c */ 5292 #line 5 39"parser.yy"5323 #line 545 "parser.yy" 5293 5324 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5294 5325 break; … … 5297 5328 5298 5329 /* Line 1806 of yacc.c */ 5299 #line 54 1"parser.yy"5330 #line 547 "parser.yy" 5300 5331 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5301 5332 break; … … 5304 5335 5305 5336 /* Line 1806 of yacc.c */ 5306 #line 5 47"parser.yy"5337 #line 553 "parser.yy" 5307 5338 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5308 5339 break; … … 5311 5342 5312 5343 /* Line 1806 of yacc.c */ 5313 #line 5 49"parser.yy"5344 #line 555 "parser.yy" 5314 5345 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5315 5346 break; … … 5318 5349 5319 5350 /* Line 1806 of yacc.c */ 5320 #line 5 55"parser.yy"5351 #line 561 "parser.yy" 5321 5352 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5322 5353 break; … … 5325 5356 5326 5357 /* Line 1806 of yacc.c */ 5327 #line 5 57"parser.yy"5358 #line 563 "parser.yy" 5328 5359 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5329 5360 break; … … 5332 5363 5333 5364 /* Line 1806 of yacc.c */ 5334 #line 5 59"parser.yy"5365 #line 565 "parser.yy" 5335 5366 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5336 5367 break; … … 5339 5370 5340 5371 /* Line 1806 of yacc.c */ 5341 #line 56 1"parser.yy"5372 #line 567 "parser.yy" 5342 5373 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5343 5374 break; … … 5346 5377 5347 5378 /* Line 1806 of yacc.c */ 5348 #line 5 67"parser.yy"5379 #line 573 "parser.yy" 5349 5380 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5350 5381 break; … … 5353 5384 5354 5385 /* Line 1806 of yacc.c */ 5355 #line 5 69"parser.yy"5386 #line 575 "parser.yy" 5356 5387 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5357 5388 break; … … 5360 5391 5361 5392 /* Line 1806 of yacc.c */ 5362 #line 5 75"parser.yy"5393 #line 581 "parser.yy" 5363 5394 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5364 5395 break; … … 5367 5398 5368 5399 /* Line 1806 of yacc.c */ 5369 #line 58 1"parser.yy"5400 #line 587 "parser.yy" 5370 5401 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5371 5402 break; … … 5374 5405 5375 5406 /* Line 1806 of yacc.c */ 5376 #line 5 87"parser.yy"5407 #line 593 "parser.yy" 5377 5408 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5378 5409 break; … … 5381 5412 5382 5413 /* Line 1806 of yacc.c */ 5383 #line 59 3"parser.yy"5414 #line 599 "parser.yy" 5384 5415 { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); } 5385 5416 break; … … 5388 5419 5389 5420 /* Line 1806 of yacc.c */ 5390 #line 599"parser.yy"5421 #line 605 "parser.yy" 5391 5422 { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); } 5392 5423 break; … … 5395 5426 5396 5427 /* Line 1806 of yacc.c */ 5397 #line 6 05"parser.yy"5428 #line 611 "parser.yy" 5398 5429 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); } 5399 5430 break; … … 5402 5433 5403 5434 /* Line 1806 of yacc.c */ 5404 #line 6 08"parser.yy"5435 #line 614 "parser.yy" 5405 5436 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); } 5406 5437 break; … … 5409 5440 5410 5441 /* Line 1806 of yacc.c */ 5411 #line 62 1"parser.yy"5442 #line 627 "parser.yy" 5412 5443 { (yyval.en) = new ExpressionNode( build_binary_ptr( (yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5413 5444 break; … … 5416 5447 5417 5448 /* Line 1806 of yacc.c */ 5418 #line 6 28"parser.yy"5449 #line 634 "parser.yy" 5419 5450 { (yyval.en) = nullptr; } 5420 5451 break; … … 5423 5454 5424 5455 /* Line 1806 of yacc.c */ 5425 #line 63 3"parser.yy"5456 #line 639 "parser.yy" 5426 5457 { (yyval.op) = OperKinds::Assign; } 5427 5458 break; … … 5430 5461 5431 5462 /* Line 1806 of yacc.c */ 5432 #line 6 34"parser.yy"5463 #line 640 "parser.yy" 5433 5464 { (yyval.op) = OperKinds::AtAssn; } 5434 5465 break; … … 5437 5468 5438 5469 /* Line 1806 of yacc.c */ 5439 #line 6 35"parser.yy"5470 #line 641 "parser.yy" 5440 5471 { (yyval.op) = OperKinds::MulAssn; } 5441 5472 break; … … 5444 5475 5445 5476 /* Line 1806 of yacc.c */ 5446 #line 6 36"parser.yy"5477 #line 642 "parser.yy" 5447 5478 { (yyval.op) = OperKinds::DivAssn; } 5448 5479 break; … … 5451 5482 5452 5483 /* Line 1806 of yacc.c */ 5453 #line 6 37"parser.yy"5484 #line 643 "parser.yy" 5454 5485 { (yyval.op) = OperKinds::ModAssn; } 5455 5486 break; … … 5458 5489 5459 5490 /* Line 1806 of yacc.c */ 5460 #line 6 38"parser.yy"5491 #line 644 "parser.yy" 5461 5492 { (yyval.op) = OperKinds::PlusAssn; } 5462 5493 break; … … 5465 5496 5466 5497 /* Line 1806 of yacc.c */ 5467 #line 6 39"parser.yy"5498 #line 645 "parser.yy" 5468 5499 { (yyval.op) = OperKinds::MinusAssn; } 5469 5500 break; … … 5472 5503 5473 5504 /* Line 1806 of yacc.c */ 5474 #line 64 0"parser.yy"5505 #line 646 "parser.yy" 5475 5506 { (yyval.op) = OperKinds::LSAssn; } 5476 5507 break; … … 5479 5510 5480 5511 /* Line 1806 of yacc.c */ 5481 #line 64 1"parser.yy"5512 #line 647 "parser.yy" 5482 5513 { (yyval.op) = OperKinds::RSAssn; } 5483 5514 break; … … 5486 5517 5487 5518 /* Line 1806 of yacc.c */ 5488 #line 64 2"parser.yy"5519 #line 648 "parser.yy" 5489 5520 { (yyval.op) = OperKinds::AndAssn; } 5490 5521 break; … … 5493 5524 5494 5525 /* Line 1806 of yacc.c */ 5495 #line 64 3"parser.yy"5526 #line 649 "parser.yy" 5496 5527 { (yyval.op) = OperKinds::ERAssn; } 5497 5528 break; … … 5500 5531 5501 5532 /* Line 1806 of yacc.c */ 5502 #line 6 44"parser.yy"5533 #line 650 "parser.yy" 5503 5534 { (yyval.op) = OperKinds::OrAssn; } 5504 5535 break; … … 5507 5538 5508 5539 /* Line 1806 of yacc.c */ 5509 #line 6 55"parser.yy"5540 #line 661 "parser.yy" 5510 5541 { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( (yyvsp[(4) - (6)].en) ) ) ); } 5511 5542 break; … … 5514 5545 5515 5546 /* Line 1806 of yacc.c */ 5516 #line 6 57"parser.yy"5547 #line 663 "parser.yy" 5517 5548 { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_last( (yyvsp[(5) - (7)].en) ) ) ); } 5518 5549 break; … … 5521 5552 5522 5553 /* Line 1806 of yacc.c */ 5523 #line 66 3"parser.yy"5554 #line 669 "parser.yy" 5524 5555 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 5525 5556 break; … … 5528 5559 5529 5560 /* Line 1806 of yacc.c */ 5530 #line 6 69"parser.yy"5561 #line 675 "parser.yy" 5531 5562 { (yyval.en) = new ExpressionNode( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5532 5563 break; … … 5535 5566 5536 5567 /* Line 1806 of yacc.c */ 5537 #line 6 74"parser.yy"5568 #line 680 "parser.yy" 5538 5569 { (yyval.en) = 0; } 5539 5570 break; … … 5542 5573 5543 5574 /* Line 1806 of yacc.c */ 5544 #line 68 3"parser.yy"5575 #line 689 "parser.yy" 5545 5576 { (yyval.sn) = (yyvsp[(1) - (1)].sn); } 5546 5577 break; … … 5549 5580 5550 5581 /* Line 1806 of yacc.c */ 5551 #line 69 0"parser.yy"5582 #line 696 "parser.yy" 5552 5583 { 5553 5584 Token fn; … … 5560 5591 5561 5592 /* Line 1806 of yacc.c */ 5562 #line 70 0"parser.yy"5593 #line 706 "parser.yy" 5563 5594 { 5564 5595 (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) ); … … 5569 5600 5570 5601 /* Line 1806 of yacc.c */ 5571 #line 7 07"parser.yy"5602 #line 713 "parser.yy" 5572 5603 { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); } 5573 5604 break; … … 5576 5607 5577 5608 /* Line 1806 of yacc.c */ 5578 #line 7 14"parser.yy"5609 #line 720 "parser.yy" 5579 5610 { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); } 5580 5611 break; … … 5583 5614 5584 5615 /* Line 1806 of yacc.c */ 5585 #line 72 0"parser.yy"5616 #line 726 "parser.yy" 5586 5617 { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } } 5587 5618 break; … … 5590 5621 5591 5622 /* Line 1806 of yacc.c */ 5592 #line 7 25"parser.yy"5623 #line 731 "parser.yy" 5593 5624 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5594 5625 break; … … 5597 5628 5598 5629 /* Line 1806 of yacc.c */ 5599 #line 7 27"parser.yy"5630 #line 733 "parser.yy" 5600 5631 { // mark all fields in list 5601 5632 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 5608 5639 5609 5640 /* Line 1806 of yacc.c */ 5610 #line 73 3"parser.yy"5641 #line 739 "parser.yy" 5611 5642 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5612 5643 break; … … 5615 5646 5616 5647 /* Line 1806 of yacc.c */ 5617 #line 74 0"parser.yy"5648 #line 746 "parser.yy" 5618 5649 { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } } 5619 5650 break; … … 5622 5653 5623 5654 /* Line 1806 of yacc.c */ 5624 #line 7 45"parser.yy"5655 #line 751 "parser.yy" 5625 5656 { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); } 5626 5657 break; … … 5629 5660 5630 5661 /* Line 1806 of yacc.c */ 5631 #line 75 1"parser.yy"5662 #line 757 "parser.yy" 5632 5663 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); } 5633 5664 break; … … 5636 5667 5637 5668 /* Line 1806 of yacc.c */ 5638 #line 75 3"parser.yy"5669 #line 759 "parser.yy" 5639 5670 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); } 5640 5671 break; … … 5643 5674 5644 5675 /* Line 1806 of yacc.c */ 5645 #line 7 55"parser.yy"5676 #line 761 "parser.yy" 5646 5677 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5647 5678 break; … … 5650 5681 5651 5682 /* Line 1806 of yacc.c */ 5652 #line 7 57"parser.yy"5683 #line 763 "parser.yy" 5653 5684 { 5654 5685 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); … … 5665 5696 5666 5697 /* Line 1806 of yacc.c */ 5667 #line 7 67"parser.yy"5698 #line 773 "parser.yy" 5668 5699 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5669 5700 break; … … 5672 5703 5673 5704 /* Line 1806 of yacc.c */ 5674 #line 7 69"parser.yy"5705 #line 775 "parser.yy" 5675 5706 { 5676 5707 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); … … 5682 5713 5683 5714 /* Line 1806 of yacc.c */ 5684 #line 7 79"parser.yy"5715 #line 785 "parser.yy" 5685 5716 { (yyval.en) = (yyvsp[(1) - (1)].en); } 5686 5717 break; … … 5689 5720 5690 5721 /* Line 1806 of yacc.c */ 5691 #line 78 1"parser.yy"5722 #line 787 "parser.yy" 5692 5723 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5693 5724 break; … … 5696 5727 5697 5728 /* Line 1806 of yacc.c */ 5698 #line 7 86"parser.yy"5729 #line 792 "parser.yy" 5699 5730 { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); } 5700 5731 break; … … 5703 5734 5704 5735 /* Line 1806 of yacc.c */ 5705 #line 7 88"parser.yy"5736 #line 794 "parser.yy" 5706 5737 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); } 5707 5738 break; … … 5710 5741 5711 5742 /* Line 1806 of yacc.c */ 5712 #line 79 2"parser.yy"5743 #line 798 "parser.yy" 5713 5744 { (yyval.sn) = (yyvsp[(2) - (3)].sn); } 5714 5745 break; … … 5717 5748 5718 5749 /* Line 1806 of yacc.c */ 5719 #line 79 3"parser.yy"5750 #line 799 "parser.yy" 5720 5751 { (yyval.sn) = new StatementNode( build_default() ); } 5721 5752 break; … … 5724 5755 5725 5756 /* Line 1806 of yacc.c */ 5726 #line 799"parser.yy"5757 #line 805 "parser.yy" 5727 5758 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) )); } 5728 5759 break; … … 5731 5762 5732 5763 /* Line 1806 of yacc.c */ 5733 #line 80 3"parser.yy"5764 #line 809 "parser.yy" 5734 5765 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5735 5766 break; … … 5738 5769 5739 5770 /* Line 1806 of yacc.c */ 5740 #line 8 08"parser.yy"5771 #line 814 "parser.yy" 5741 5772 { (yyval.sn) = 0; } 5742 5773 break; … … 5745 5776 5746 5777 /* Line 1806 of yacc.c */ 5747 #line 8 14"parser.yy"5778 #line 820 "parser.yy" 5748 5779 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5749 5780 break; … … 5752 5783 5753 5784 /* Line 1806 of yacc.c */ 5754 #line 8 16"parser.yy"5785 #line 822 "parser.yy" 5755 5786 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); } 5756 5787 break; … … 5759 5790 5760 5791 /* Line 1806 of yacc.c */ 5761 #line 82 1"parser.yy"5792 #line 827 "parser.yy" 5762 5793 { (yyval.sn) = 0; } 5763 5794 break; … … 5766 5797 5767 5798 /* Line 1806 of yacc.c */ 5768 #line 8 27"parser.yy"5799 #line 833 "parser.yy" 5769 5800 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); } 5770 5801 break; … … 5773 5804 5774 5805 /* Line 1806 of yacc.c */ 5775 #line 8 29"parser.yy"5806 #line 835 "parser.yy" 5776 5807 { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); } 5777 5808 break; … … 5780 5811 5781 5812 /* Line 1806 of yacc.c */ 5782 #line 83 1"parser.yy"5813 #line 837 "parser.yy" 5783 5814 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); } 5784 5815 break; … … 5787 5818 5788 5819 /* Line 1806 of yacc.c */ 5789 #line 83 3"parser.yy"5820 #line 839 "parser.yy" 5790 5821 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(3) - (4)].sn)->set_last( (yyvsp[(4) - (4)].sn) ) ) ) ) ) ); } 5791 5822 break; … … 5794 5825 5795 5826 /* Line 1806 of yacc.c */ 5796 #line 8 38"parser.yy"5827 #line 844 "parser.yy" 5797 5828 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); } 5798 5829 break; … … 5801 5832 5802 5833 /* Line 1806 of yacc.c */ 5803 #line 8 44"parser.yy"5834 #line 850 "parser.yy" 5804 5835 { (yyval.sn) = 0; } 5805 5836 break; … … 5808 5839 5809 5840 /* Line 1806 of yacc.c */ 5810 #line 8 46"parser.yy"5841 #line 852 "parser.yy" 5811 5842 { (yyval.sn) = 0; } 5812 5843 break; … … 5815 5846 5816 5847 /* Line 1806 of yacc.c */ 5817 #line 85 1"parser.yy"5848 #line 857 "parser.yy" 5818 5849 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5819 5850 break; … … 5822 5853 5823 5854 /* Line 1806 of yacc.c */ 5824 #line 85 3"parser.yy"5855 #line 859 "parser.yy" 5825 5856 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); } 5826 5857 break; … … 5829 5860 5830 5861 /* Line 1806 of yacc.c */ 5831 #line 8 55"parser.yy"5862 #line 861 "parser.yy" 5832 5863 { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); } 5833 5864 break; … … 5836 5867 5837 5868 /* Line 1806 of yacc.c */ 5838 #line 86 0"parser.yy"5869 #line 866 "parser.yy" 5839 5870 { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); } 5840 5871 break; … … 5843 5874 5844 5875 /* Line 1806 of yacc.c */ 5845 #line 86 2"parser.yy"5876 #line 868 "parser.yy" 5846 5877 { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); } 5847 5878 break; … … 5850 5881 5851 5882 /* Line 1806 of yacc.c */ 5852 #line 8 67"parser.yy"5883 #line 873 "parser.yy" 5853 5884 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); } 5854 5885 break; … … 5857 5888 5858 5889 /* Line 1806 of yacc.c */ 5859 #line 87 1"parser.yy"5890 #line 877 "parser.yy" 5860 5891 { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); } 5861 5892 break; … … 5864 5895 5865 5896 /* Line 1806 of yacc.c */ 5866 #line 8 74"parser.yy"5897 #line 880 "parser.yy" 5867 5898 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Continue ) ); } 5868 5899 break; … … 5871 5902 5872 5903 /* Line 1806 of yacc.c */ 5873 #line 8 78"parser.yy"5904 #line 884 "parser.yy" 5874 5905 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); } 5875 5906 break; … … 5878 5909 5879 5910 /* Line 1806 of yacc.c */ 5880 #line 88 1"parser.yy"5911 #line 887 "parser.yy" 5881 5912 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); } 5882 5913 break; … … 5885 5916 5886 5917 /* Line 1806 of yacc.c */ 5887 #line 8 85"parser.yy"5918 #line 891 "parser.yy" 5888 5919 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); } 5889 5920 break; … … 5892 5923 5893 5924 /* Line 1806 of yacc.c */ 5894 #line 8 87"parser.yy"5925 #line 893 "parser.yy" 5895 5926 { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); } 5896 5927 break; … … 5899 5930 5900 5931 /* Line 1806 of yacc.c */ 5901 #line 8 89"parser.yy"5932 #line 895 "parser.yy" 5902 5933 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 5903 5934 break; … … 5906 5937 5907 5938 /* Line 1806 of yacc.c */ 5908 #line 89 1"parser.yy"5939 #line 897 "parser.yy" 5909 5940 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 5910 5941 break; … … 5913 5944 5914 5945 /* Line 1806 of yacc.c */ 5915 #line 89 3"parser.yy"5946 #line 899 "parser.yy" 5916 5947 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); } 5917 5948 break; … … 5920 5951 5921 5952 /* Line 1806 of yacc.c */ 5922 #line 898"parser.yy"5953 #line 904 "parser.yy" 5923 5954 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); } 5924 5955 break; … … 5927 5958 5928 5959 /* Line 1806 of yacc.c */ 5929 #line 90 0"parser.yy"5960 #line 906 "parser.yy" 5930 5961 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); } 5931 5962 break; … … 5934 5965 5935 5966 /* Line 1806 of yacc.c */ 5936 #line 90 2"parser.yy"5967 #line 908 "parser.yy" 5937 5968 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); } 5938 5969 break; … … 5941 5972 5942 5973 /* Line 1806 of yacc.c */ 5943 #line 9 09"parser.yy"5974 #line 915 "parser.yy" 5944 5975 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 5945 5976 break; … … 5948 5979 5949 5980 /* Line 1806 of yacc.c */ 5950 #line 91 1"parser.yy"5981 #line 917 "parser.yy" 5951 5982 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 5952 5983 break; … … 5955 5986 5956 5987 /* Line 1806 of yacc.c */ 5957 #line 91 3"parser.yy"5988 #line 919 "parser.yy" 5958 5989 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 5959 5990 break; … … 5962 5993 5963 5994 /* Line 1806 of yacc.c */ 5964 #line 9 15"parser.yy"5995 #line 921 "parser.yy" 5965 5996 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 5966 5997 break; … … 5969 6000 5970 6001 /* Line 1806 of yacc.c */ 5971 #line 92 0"parser.yy"6002 #line 926 "parser.yy" 5972 6003 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 5973 6004 break; … … 5976 6007 5977 6008 /* Line 1806 of yacc.c */ 5978 #line 92 2"parser.yy"6009 #line 928 "parser.yy" 5979 6010 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 5980 6011 break; … … 5983 6014 5984 6015 /* Line 1806 of yacc.c */ 5985 #line 9 24"parser.yy"6016 #line 930 "parser.yy" 5986 6017 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 5987 6018 break; … … 5990 6021 5991 6022 /* Line 1806 of yacc.c */ 5992 #line 9 26"parser.yy"6023 #line 932 "parser.yy" 5993 6024 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 5994 6025 break; … … 5997 6028 5998 6029 /* Line 1806 of yacc.c */ 5999 #line 93 1"parser.yy"6030 #line 937 "parser.yy" 6000 6031 { 6001 6032 (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) ); … … 6006 6037 6007 6038 /* Line 1806 of yacc.c */ 6008 #line 9 44"parser.yy"6039 #line 950 "parser.yy" 6009 6040 { 6010 6041 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6016 6047 6017 6048 /* Line 1806 of yacc.c */ 6018 #line 9 49"parser.yy"6049 #line 955 "parser.yy" 6019 6050 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 6020 6051 break; … … 6023 6054 6024 6055 /* Line 1806 of yacc.c */ 6025 #line 95 1"parser.yy"6056 #line 957 "parser.yy" 6026 6057 { 6027 6058 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6033 6064 6034 6065 /* Line 1806 of yacc.c */ 6035 #line 96 0"parser.yy"6066 #line 966 "parser.yy" 6036 6067 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); } 6037 6068 break; … … 6040 6071 6041 6072 /* Line 1806 of yacc.c */ 6042 #line 96 2"parser.yy"6073 #line 968 "parser.yy" 6043 6074 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); } 6044 6075 break; … … 6047 6078 6048 6079 /* Line 1806 of yacc.c */ 6049 #line 9 64"parser.yy"6080 #line 970 "parser.yy" 6050 6081 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); } 6051 6082 break; … … 6054 6085 6055 6086 /* Line 1806 of yacc.c */ 6056 #line 9 66"parser.yy"6087 #line 972 "parser.yy" 6057 6088 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ) ); } 6058 6089 break; … … 6061 6092 6062 6093 /* Line 1806 of yacc.c */ 6063 #line 9 68"parser.yy"6094 #line 974 "parser.yy" 6064 6095 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ) ); } 6065 6096 break; … … 6068 6099 6069 6100 /* Line 1806 of yacc.c */ 6070 #line 97 3"parser.yy"6101 #line 979 "parser.yy" 6071 6102 { (yyval.flag) = false; } 6072 6103 break; … … 6075 6106 6076 6107 /* Line 1806 of yacc.c */ 6077 #line 9 75"parser.yy"6108 #line 981 "parser.yy" 6078 6109 { (yyval.flag) = true; } 6079 6110 break; … … 6082 6113 6083 6114 /* Line 1806 of yacc.c */ 6084 #line 98 0"parser.yy"6115 #line 986 "parser.yy" 6085 6116 { (yyval.en) = 0; } 6086 6117 break; … … 6089 6120 6090 6121 /* Line 1806 of yacc.c */ 6091 #line 9 87"parser.yy"6122 #line 993 "parser.yy" 6092 6123 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 6093 6124 break; … … 6096 6127 6097 6128 /* Line 1806 of yacc.c */ 6098 #line 99 2"parser.yy"6129 #line 998 "parser.yy" 6099 6130 { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); } 6100 6131 break; … … 6103 6134 6104 6135 /* Line 1806 of yacc.c */ 6105 #line 994"parser.yy"6136 #line 1000 "parser.yy" 6106 6137 { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); } 6107 6138 break; … … 6110 6141 6111 6142 /* Line 1806 of yacc.c */ 6112 #line 999"parser.yy"6143 #line 1005 "parser.yy" 6113 6144 { (yyval.en) = 0; } 6114 6145 break; … … 6117 6148 6118 6149 /* Line 1806 of yacc.c */ 6119 #line 100 1"parser.yy"6150 #line 1007 "parser.yy" 6120 6151 { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); } 6121 6152 break; … … 6124 6155 6125 6156 /* Line 1806 of yacc.c */ 6126 #line 100 3"parser.yy"6157 #line 1009 "parser.yy" 6127 6158 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( (yyvsp[(3) - (3)].constant) ) ); } 6128 6159 break; … … 6131 6162 6132 6163 /* Line 1806 of yacc.c */ 6133 #line 10 08"parser.yy"6164 #line 1014 "parser.yy" 6134 6165 { 6135 6166 (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) ); … … 6141 6172 6142 6173 /* Line 1806 of yacc.c */ 6143 #line 101 3"parser.yy"6174 #line 1019 "parser.yy" 6144 6175 { 6145 6176 (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) ); … … 6151 6182 6152 6183 /* Line 1806 of yacc.c */ 6153 #line 102 3"parser.yy"6184 #line 1029 "parser.yy" 6154 6185 { (yyval.decl) = 0; } 6155 6186 break; … … 6158 6189 6159 6190 /* Line 1806 of yacc.c */ 6160 #line 103 0"parser.yy"6191 #line 1036 "parser.yy" 6161 6192 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6162 6193 break; … … 6165 6196 6166 6197 /* Line 1806 of yacc.c */ 6167 #line 10 35"parser.yy"6198 #line 1041 "parser.yy" 6168 6199 { (yyval.decl) = 0; } 6169 6200 break; … … 6172 6203 6173 6204 /* Line 1806 of yacc.c */ 6174 #line 104 2"parser.yy"6205 #line 1048 "parser.yy" 6175 6206 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6176 6207 break; … … 6179 6210 6180 6211 /* Line 1806 of yacc.c */ 6181 #line 10 56"parser.yy"6212 #line 1062 "parser.yy" 6182 6213 {} 6183 6214 break; … … 6186 6217 6187 6218 /* Line 1806 of yacc.c */ 6188 #line 10 57"parser.yy"6219 #line 1063 "parser.yy" 6189 6220 {} 6190 6221 break; … … 6193 6224 6194 6225 /* Line 1806 of yacc.c */ 6195 #line 10 86"parser.yy"6226 #line 1092 "parser.yy" 6196 6227 { 6197 6228 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6203 6234 6204 6235 /* Line 1806 of yacc.c */ 6205 #line 109 3"parser.yy"6236 #line 1099 "parser.yy" 6206 6237 { 6207 6238 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6213 6244 6214 6245 /* Line 1806 of yacc.c */ 6215 #line 1 098"parser.yy"6246 #line 1104 "parser.yy" 6216 6247 { 6217 6248 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID ); … … 6223 6254 6224 6255 /* Line 1806 of yacc.c */ 6225 #line 11 08"parser.yy"6256 #line 1114 "parser.yy" 6226 6257 { 6227 6258 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6233 6264 6234 6265 /* Line 1806 of yacc.c */ 6235 #line 111 3"parser.yy"6266 #line 1119 "parser.yy" 6236 6267 { 6237 6268 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6243 6274 6244 6275 /* Line 1806 of yacc.c */ 6245 #line 11 18"parser.yy"6276 #line 1124 "parser.yy" 6246 6277 { 6247 6278 typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) ); … … 6253 6284 6254 6285 /* Line 1806 of yacc.c */ 6255 #line 11 26"parser.yy"6286 #line 1132 "parser.yy" 6256 6287 { 6257 6288 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6263 6294 6264 6295 /* Line 1806 of yacc.c */ 6265 #line 113 1"parser.yy"6296 #line 1137 "parser.yy" 6266 6297 { 6267 6298 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6273 6304 6274 6305 /* Line 1806 of yacc.c */ 6275 #line 11 36"parser.yy"6306 #line 1142 "parser.yy" 6276 6307 { 6277 6308 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6283 6314 6284 6315 /* Line 1806 of yacc.c */ 6285 #line 114 1"parser.yy"6316 #line 1147 "parser.yy" 6286 6317 { 6287 6318 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6293 6324 6294 6325 /* Line 1806 of yacc.c */ 6295 #line 11 46"parser.yy"6326 #line 1152 "parser.yy" 6296 6327 { 6297 6328 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 6303 6334 6304 6335 /* Line 1806 of yacc.c */ 6305 #line 11 77"parser.yy"6336 #line 1183 "parser.yy" 6306 6337 { 6307 6338 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6312 6343 6313 6344 /* Line 1806 of yacc.c */ 6314 #line 118 1"parser.yy"6345 #line 1187 "parser.yy" 6315 6346 { 6316 6347 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6321 6352 6322 6353 /* Line 1806 of yacc.c */ 6323 #line 11 88"parser.yy"6354 #line 1194 "parser.yy" 6324 6355 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 6325 6356 break; … … 6328 6359 6329 6360 /* Line 1806 of yacc.c */ 6330 #line 119 2"parser.yy"6361 #line 1198 "parser.yy" 6331 6362 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); } 6332 6363 break; … … 6335 6366 6336 6367 /* Line 1806 of yacc.c */ 6337 #line 1 197"parser.yy"6368 #line 1203 "parser.yy" 6338 6369 { 6339 6370 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6345 6376 6346 6377 /* Line 1806 of yacc.c */ 6347 #line 120 2"parser.yy"6378 #line 1208 "parser.yy" 6348 6379 { 6349 6380 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6355 6386 6356 6387 /* Line 1806 of yacc.c */ 6357 #line 12 07"parser.yy"6388 #line 1213 "parser.yy" 6358 6389 { 6359 6390 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD ); … … 6365 6396 6366 6397 /* Line 1806 of yacc.c */ 6367 #line 12 18"parser.yy"6398 #line 1224 "parser.yy" 6368 6399 { 6369 6400 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6375 6406 6376 6407 /* Line 1806 of yacc.c */ 6377 #line 122 3"parser.yy"6408 #line 1229 "parser.yy" 6378 6409 { 6379 6410 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6385 6416 6386 6417 /* Line 1806 of yacc.c */ 6387 #line 12 28"parser.yy"6418 #line 1234 "parser.yy" 6388 6419 { 6389 6420 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6395 6426 6396 6427 /* Line 1806 of yacc.c */ 6397 #line 123 3"parser.yy"6428 #line 1239 "parser.yy" 6398 6429 { 6399 6430 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6405 6436 6406 6437 /* Line 1806 of yacc.c */ 6407 #line 12 38"parser.yy"6438 #line 1244 "parser.yy" 6408 6439 { 6409 6440 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6415 6446 6416 6447 /* Line 1806 of yacc.c */ 6417 #line 12 47"parser.yy"6448 #line 1253 "parser.yy" 6418 6449 { 6419 6450 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD ); … … 6425 6456 6426 6457 /* Line 1806 of yacc.c */ 6427 #line 125 2"parser.yy"6458 #line 1258 "parser.yy" 6428 6459 { 6429 6460 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD ); … … 6435 6466 6436 6467 /* Line 1806 of yacc.c */ 6437 #line 12 69"parser.yy"6468 #line 1275 "parser.yy" 6438 6469 { 6439 6470 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6445 6476 6446 6477 /* Line 1806 of yacc.c */ 6447 #line 12 74"parser.yy"6478 #line 1280 "parser.yy" 6448 6479 { 6449 6480 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6455 6486 6456 6487 /* Line 1806 of yacc.c */ 6457 #line 1 296"parser.yy"6488 #line 1302 "parser.yy" 6458 6489 { (yyval.decl) = 0; } 6459 6490 break; … … 6462 6493 6463 6494 /* Line 1806 of yacc.c */ 6464 #line 13 08"parser.yy"6495 #line 1314 "parser.yy" 6465 6496 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6466 6497 break; … … 6469 6500 6470 6501 /* Line 1806 of yacc.c */ 6471 #line 13 19"parser.yy"6502 #line 1325 "parser.yy" 6472 6503 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); } 6473 6504 break; … … 6476 6507 6477 6508 /* Line 1806 of yacc.c */ 6478 #line 132 1"parser.yy"6509 #line 1327 "parser.yy" 6479 6510 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); } 6480 6511 break; … … 6483 6514 6484 6515 /* Line 1806 of yacc.c */ 6485 #line 132 3"parser.yy"6516 #line 1329 "parser.yy" 6486 6517 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); } 6487 6518 break; … … 6490 6521 6491 6522 /* Line 1806 of yacc.c */ 6492 #line 13 25"parser.yy"6523 #line 1331 "parser.yy" 6493 6524 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 6494 6525 break; … … 6497 6528 6498 6529 /* Line 1806 of yacc.c */ 6499 #line 13 27"parser.yy"6530 #line 1333 "parser.yy" 6500 6531 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); } 6501 6532 break; … … 6504 6535 6505 6536 /* Line 1806 of yacc.c */ 6506 #line 13 29"parser.yy"6537 #line 1335 "parser.yy" 6507 6538 { 6508 6539 typedefTable.enterScope(); … … 6513 6544 6514 6545 /* Line 1806 of yacc.c */ 6515 #line 133 3"parser.yy"6546 #line 1339 "parser.yy" 6516 6547 { 6517 6548 typedefTable.leaveScope(); … … 6523 6554 6524 6555 /* Line 1806 of yacc.c */ 6525 #line 134 2"parser.yy"6556 #line 1348 "parser.yy" 6526 6557 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6527 6558 break; … … 6530 6561 6531 6562 /* Line 1806 of yacc.c */ 6532 #line 13 44"parser.yy"6563 #line 1350 "parser.yy" 6533 6564 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6534 6565 break; … … 6537 6568 6538 6569 /* Line 1806 of yacc.c */ 6539 #line 13 55"parser.yy"6570 #line 1361 "parser.yy" 6540 6571 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6541 6572 break; … … 6544 6575 6545 6576 /* Line 1806 of yacc.c */ 6546 #line 136 0"parser.yy"6577 #line 1366 "parser.yy" 6547 6578 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } 6548 6579 break; … … 6551 6582 6552 6583 /* Line 1806 of yacc.c */ 6553 #line 136 2"parser.yy"6584 #line 1368 "parser.yy" 6554 6585 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); } 6555 6586 break; … … 6558 6589 6559 6590 /* Line 1806 of yacc.c */ 6560 #line 13 64"parser.yy"6591 #line 1370 "parser.yy" 6561 6592 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); } 6562 6593 break; … … 6565 6596 6566 6597 /* Line 1806 of yacc.c */ 6567 #line 13 66"parser.yy"6598 #line 1372 "parser.yy" 6568 6599 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 6569 6600 break; … … 6572 6603 6573 6604 /* Line 1806 of yacc.c */ 6574 #line 13 69"parser.yy"6605 #line 1375 "parser.yy" 6575 6606 { (yyval.decl) = new DeclarationNode; (yyval.decl)->isInline = true; } 6576 6607 break; … … 6579 6610 6580 6611 /* Line 1806 of yacc.c */ 6581 #line 137 1"parser.yy"6612 #line 1377 "parser.yy" 6582 6613 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 6583 6614 break; … … 6586 6617 6587 6618 /* Line 1806 of yacc.c */ 6588 #line 13 74"parser.yy"6619 #line 1380 "parser.yy" 6589 6620 { (yyval.decl) = new DeclarationNode; (yyval.decl)->isNoreturn = true; } 6590 6621 break; … … 6593 6624 6594 6625 /* Line 1806 of yacc.c */ 6595 #line 13 76"parser.yy"6626 #line 1382 "parser.yy" 6596 6627 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 6597 6628 break; … … 6600 6631 6601 6632 /* Line 1806 of yacc.c */ 6602 #line 138 1"parser.yy"6633 #line 1387 "parser.yy" 6603 6634 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); } 6604 6635 break; … … 6607 6638 6608 6639 /* Line 1806 of yacc.c */ 6609 #line 138 3"parser.yy"6640 #line 1389 "parser.yy" 6610 6641 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); } 6611 6642 break; … … 6614 6645 6615 6646 /* Line 1806 of yacc.c */ 6616 #line 13 85"parser.yy"6647 #line 1391 "parser.yy" 6617 6648 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); } 6618 6649 break; … … 6621 6652 6622 6653 /* Line 1806 of yacc.c */ 6623 #line 13 87"parser.yy"6654 #line 1393 "parser.yy" 6624 6655 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); } 6625 6656 break; … … 6628 6659 6629 6660 /* Line 1806 of yacc.c */ 6630 #line 13 89"parser.yy"6661 #line 1395 "parser.yy" 6631 6662 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); } 6632 6663 break; … … 6635 6666 6636 6667 /* Line 1806 of yacc.c */ 6637 #line 139 1"parser.yy"6668 #line 1397 "parser.yy" 6638 6669 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); } 6639 6670 break; … … 6642 6673 6643 6674 /* Line 1806 of yacc.c */ 6644 #line 139 3"parser.yy"6675 #line 1399 "parser.yy" 6645 6676 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 6646 6677 break; … … 6649 6680 6650 6681 /* Line 1806 of yacc.c */ 6651 #line 1 395"parser.yy"6682 #line 1401 "parser.yy" 6652 6683 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 6653 6684 break; … … 6656 6687 6657 6688 /* Line 1806 of yacc.c */ 6658 #line 1 397"parser.yy"6689 #line 1403 "parser.yy" 6659 6690 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); } 6660 6691 break; … … 6663 6694 6664 6695 /* Line 1806 of yacc.c */ 6665 #line 1 399"parser.yy"6696 #line 1405 "parser.yy" 6666 6697 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 6667 6698 break; … … 6670 6701 6671 6702 /* Line 1806 of yacc.c */ 6672 #line 140 1"parser.yy"6703 #line 1407 "parser.yy" 6673 6704 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 6674 6705 break; … … 6677 6708 6678 6709 /* Line 1806 of yacc.c */ 6679 #line 140 3"parser.yy"6710 #line 1409 "parser.yy" 6680 6711 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 6681 6712 break; … … 6684 6715 6685 6716 /* Line 1806 of yacc.c */ 6686 #line 14 05"parser.yy"6717 #line 1411 "parser.yy" 6687 6718 { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 6688 6719 break; … … 6691 6722 6692 6723 /* Line 1806 of yacc.c */ 6693 #line 141 2"parser.yy"6724 #line 1418 "parser.yy" 6694 6725 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6695 6726 break; … … 6698 6729 6699 6730 /* Line 1806 of yacc.c */ 6700 #line 14 14"parser.yy"6731 #line 1420 "parser.yy" 6701 6732 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6702 6733 break; … … 6705 6736 6706 6737 /* Line 1806 of yacc.c */ 6707 #line 14 16"parser.yy"6738 #line 1422 "parser.yy" 6708 6739 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6709 6740 break; … … 6712 6743 6713 6744 /* Line 1806 of yacc.c */ 6714 #line 14 18"parser.yy"6745 #line 1424 "parser.yy" 6715 6746 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); } 6716 6747 break; … … 6719 6750 6720 6751 /* Line 1806 of yacc.c */ 6721 #line 14 24"parser.yy"6752 #line 1430 "parser.yy" 6722 6753 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6723 6754 break; … … 6726 6757 6727 6758 /* Line 1806 of yacc.c */ 6728 #line 143 1"parser.yy"6759 #line 1437 "parser.yy" 6729 6760 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6730 6761 break; … … 6733 6764 6734 6765 /* Line 1806 of yacc.c */ 6735 #line 143 3"parser.yy"6766 #line 1439 "parser.yy" 6736 6767 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6737 6768 break; … … 6740 6771 6741 6772 /* Line 1806 of yacc.c */ 6742 #line 14 35"parser.yy"6773 #line 1441 "parser.yy" 6743 6774 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); } 6744 6775 break; … … 6747 6778 6748 6779 /* Line 1806 of yacc.c */ 6749 #line 144 0"parser.yy"6780 #line 1446 "parser.yy" 6750 6781 { (yyval.decl) = (yyvsp[(3) - (4)].decl); } 6751 6782 break; … … 6754 6785 6755 6786 /* Line 1806 of yacc.c */ 6756 #line 144 2"parser.yy"6787 #line 1448 "parser.yy" 6757 6788 { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); } 6758 6789 break; … … 6761 6792 6762 6793 /* Line 1806 of yacc.c */ 6763 #line 14 44"parser.yy"6794 #line 1450 "parser.yy" 6764 6795 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); } 6765 6796 break; … … 6768 6799 6769 6800 /* Line 1806 of yacc.c */ 6770 #line 14 46"parser.yy"6801 #line 1452 "parser.yy" 6771 6802 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 6772 6803 break; … … 6775 6806 6776 6807 /* Line 1806 of yacc.c */ 6777 #line 145 2"parser.yy"6808 #line 1458 "parser.yy" 6778 6809 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6779 6810 break; … … 6782 6813 6783 6814 /* Line 1806 of yacc.c */ 6784 #line 14 54"parser.yy"6815 #line 1460 "parser.yy" 6785 6816 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6786 6817 break; … … 6789 6820 6790 6821 /* Line 1806 of yacc.c */ 6791 #line 14 56"parser.yy"6822 #line 1462 "parser.yy" 6792 6823 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6793 6824 break; … … 6796 6827 6797 6828 /* Line 1806 of yacc.c */ 6798 #line 146 2"parser.yy"6829 #line 1468 "parser.yy" 6799 6830 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6800 6831 break; … … 6803 6834 6804 6835 /* Line 1806 of yacc.c */ 6805 #line 14 64"parser.yy"6836 #line 1470 "parser.yy" 6806 6837 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6807 6838 break; … … 6810 6841 6811 6842 /* Line 1806 of yacc.c */ 6812 #line 147 0"parser.yy"6843 #line 1476 "parser.yy" 6813 6844 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6814 6845 break; … … 6817 6848 6818 6849 /* Line 1806 of yacc.c */ 6819 #line 147 2"parser.yy"6850 #line 1478 "parser.yy" 6820 6851 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6821 6852 break; … … 6824 6855 6825 6856 /* Line 1806 of yacc.c */ 6826 #line 14 74"parser.yy"6857 #line 1480 "parser.yy" 6827 6858 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6828 6859 break; … … 6831 6862 6832 6863 /* Line 1806 of yacc.c */ 6833 #line 14 79"parser.yy"6864 #line 1485 "parser.yy" 6834 6865 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); } 6835 6866 break; … … 6838 6869 6839 6870 /* Line 1806 of yacc.c */ 6840 #line 148 1"parser.yy"6871 #line 1487 "parser.yy" 6841 6872 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6842 6873 break; … … 6845 6876 6846 6877 /* Line 1806 of yacc.c */ 6847 #line 148 3"parser.yy"6878 #line 1489 "parser.yy" 6848 6879 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6849 6880 break; … … 6852 6883 6853 6884 /* Line 1806 of yacc.c */ 6854 #line 149 3"parser.yy"6885 #line 1499 "parser.yy" 6855 6886 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), nullptr, nullptr, (yyvsp[(3) - (4)].decl), true ); } 6856 6887 break; … … 6859 6890 6860 6891 /* Line 1806 of yacc.c */ 6861 #line 1 495"parser.yy"6892 #line 1501 "parser.yy" 6862 6893 { 6863 6894 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 6869 6900 6870 6901 /* Line 1806 of yacc.c */ 6871 #line 150 0"parser.yy"6902 #line 1506 "parser.yy" 6872 6903 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 6873 6904 break; … … 6876 6907 6877 6908 /* Line 1806 of yacc.c */ 6878 #line 150 2"parser.yy"6909 #line 1508 "parser.yy" 6879 6910 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), nullptr, (yyvsp[(5) - (6)].decl), true ); } 6880 6911 break; … … 6883 6914 6884 6915 /* Line 1806 of yacc.c */ 6885 #line 15 04"parser.yy"6916 #line 1510 "parser.yy" 6886 6917 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), nullptr, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); } 6887 6918 break; … … 6890 6921 6891 6922 /* Line 1806 of yacc.c */ 6892 #line 15 06"parser.yy"6923 #line 1512 "parser.yy" 6893 6924 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 6894 6925 break; … … 6897 6928 6898 6929 /* Line 1806 of yacc.c */ 6899 #line 151 1"parser.yy"6930 #line 1517 "parser.yy" 6900 6931 { (yyval.aggKey) = DeclarationNode::Struct; } 6901 6932 break; … … 6904 6935 6905 6936 /* Line 1806 of yacc.c */ 6906 #line 151 3"parser.yy"6937 #line 1519 "parser.yy" 6907 6938 { (yyval.aggKey) = DeclarationNode::Union; } 6908 6939 break; … … 6911 6942 6912 6943 /* Line 1806 of yacc.c */ 6913 #line 15 18"parser.yy"6944 #line 1524 "parser.yy" 6914 6945 { (yyval.decl) = 0; } 6915 6946 break; … … 6918 6949 6919 6950 /* Line 1806 of yacc.c */ 6920 #line 152 0"parser.yy"6951 #line 1526 "parser.yy" 6921 6952 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 6922 6953 break; … … 6925 6956 6926 6957 /* Line 1806 of yacc.c */ 6927 #line 15 26"parser.yy"6958 #line 1532 "parser.yy" 6928 6959 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); } 6929 6960 break; … … 6932 6963 6933 6964 /* Line 1806 of yacc.c */ 6934 #line 15 29"parser.yy"6965 #line 1535 "parser.yy" 6935 6966 { // mark all fields in list 6936 6967 for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 6943 6974 6944 6975 /* Line 1806 of yacc.c */ 6945 #line 15 39"parser.yy"6976 #line 1545 "parser.yy" 6946 6977 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); } 6947 6978 break; … … 6950 6981 6951 6982 /* Line 1806 of yacc.c */ 6952 #line 154 1"parser.yy"6983 #line 1547 "parser.yy" 6953 6984 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); } 6954 6985 break; … … 6957 6988 6958 6989 /* Line 1806 of yacc.c */ 6959 #line 154 3"parser.yy"6990 #line 1549 "parser.yy" 6960 6991 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); } 6961 6992 break; … … 6964 6995 6965 6996 /* Line 1806 of yacc.c */ 6966 #line 15 48"parser.yy"6997 #line 1554 "parser.yy" 6967 6998 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 6968 6999 break; … … 6971 7002 6972 7003 /* Line 1806 of yacc.c */ 6973 #line 155 0"parser.yy"7004 #line 1556 "parser.yy" 6974 7005 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); } 6975 7006 break; … … 6978 7009 6979 7010 /* Line 1806 of yacc.c */ 6980 #line 15 55"parser.yy"7011 #line 1561 "parser.yy" 6981 7012 { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ } 6982 7013 break; … … 6985 7016 6986 7017 /* Line 1806 of yacc.c */ 6987 #line 15 57"parser.yy"7018 #line 1563 "parser.yy" 6988 7019 { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); } 6989 7020 break; … … 6992 7023 6993 7024 /* Line 1806 of yacc.c */ 6994 #line 156 0"parser.yy"7025 #line 1566 "parser.yy" 6995 7026 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 6996 7027 break; … … 6999 7030 7000 7031 /* Line 1806 of yacc.c */ 7001 #line 156 3"parser.yy"7032 #line 1569 "parser.yy" 7002 7033 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 7003 7034 break; … … 7006 7037 7007 7038 /* Line 1806 of yacc.c */ 7008 #line 15 69"parser.yy"7039 #line 1575 "parser.yy" 7009 7040 { (yyval.en) = 0; } 7010 7041 break; … … 7013 7044 7014 7045 /* Line 1806 of yacc.c */ 7015 #line 157 1"parser.yy"7046 #line 1577 "parser.yy" 7016 7047 { (yyval.en) = (yyvsp[(1) - (1)].en); } 7017 7048 break; … … 7020 7051 7021 7052 /* Line 1806 of yacc.c */ 7022 #line 15 76"parser.yy"7053 #line 1582 "parser.yy" 7023 7054 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7024 7055 break; … … 7027 7058 7028 7059 /* Line 1806 of yacc.c */ 7029 #line 15 85"parser.yy"7060 #line 1591 "parser.yy" 7030 7061 { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(3) - (5)].decl) ); } 7031 7062 break; … … 7034 7065 7035 7066 /* Line 1806 of yacc.c */ 7036 #line 15 87"parser.yy"7067 #line 1593 "parser.yy" 7037 7068 { 7038 7069 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 7044 7075 7045 7076 /* Line 1806 of yacc.c */ 7046 #line 159 2"parser.yy"7077 #line 1598 "parser.yy" 7047 7078 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 7048 7079 break; … … 7051 7082 7052 7083 /* Line 1806 of yacc.c */ 7053 #line 1 594"parser.yy"7084 #line 1600 "parser.yy" 7054 7085 { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); } 7055 7086 break; … … 7058 7089 7059 7090 /* Line 1806 of yacc.c */ 7060 #line 1 599"parser.yy"7091 #line 1605 "parser.yy" 7061 7092 { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); } 7062 7093 break; … … 7065 7096 7066 7097 /* Line 1806 of yacc.c */ 7067 #line 160 1"parser.yy"7098 #line 1607 "parser.yy" 7068 7099 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); } 7069 7100 break; … … 7072 7103 7073 7104 /* Line 1806 of yacc.c */ 7074 #line 16 06"parser.yy"7105 #line 1612 "parser.yy" 7075 7106 { (yyval.en) = 0; } 7076 7107 break; … … 7079 7110 7080 7111 /* Line 1806 of yacc.c */ 7081 #line 16 08"parser.yy"7112 #line 1614 "parser.yy" 7082 7113 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7083 7114 break; … … 7086 7117 7087 7118 /* Line 1806 of yacc.c */ 7088 #line 16 15"parser.yy"7119 #line 1621 "parser.yy" 7089 7120 { (yyval.decl) = 0; } 7090 7121 break; … … 7093 7124 7094 7125 /* Line 1806 of yacc.c */ 7095 #line 162 3"parser.yy"7126 #line 1629 "parser.yy" 7096 7127 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7097 7128 break; … … 7100 7131 7101 7132 /* Line 1806 of yacc.c */ 7102 #line 16 25"parser.yy"7133 #line 1631 "parser.yy" 7103 7134 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7104 7135 break; … … 7107 7138 7108 7139 /* Line 1806 of yacc.c */ 7109 #line 16 27"parser.yy"7140 #line 1633 "parser.yy" 7110 7141 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7111 7142 break; … … 7114 7145 7115 7146 /* Line 1806 of yacc.c */ 7116 #line 16 35"parser.yy"7147 #line 1641 "parser.yy" 7117 7148 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7118 7149 break; … … 7121 7152 7122 7153 /* Line 1806 of yacc.c */ 7123 #line 16 37"parser.yy"7154 #line 1643 "parser.yy" 7124 7155 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7125 7156 break; … … 7128 7159 7129 7160 /* Line 1806 of yacc.c */ 7130 #line 16 39"parser.yy"7161 #line 1645 "parser.yy" 7131 7162 { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); } 7132 7163 break; … … 7135 7166 7136 7167 /* Line 1806 of yacc.c */ 7137 #line 16 45"parser.yy"7168 #line 1651 "parser.yy" 7138 7169 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7139 7170 break; … … 7142 7173 7143 7174 /* Line 1806 of yacc.c */ 7144 #line 165 0"parser.yy"7175 #line 1656 "parser.yy" 7145 7176 { (yyval.decl) = 0; } 7146 7177 break; … … 7149 7180 7150 7181 /* Line 1806 of yacc.c */ 7151 #line 16 57"parser.yy"7182 #line 1663 "parser.yy" 7152 7183 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7153 7184 break; … … 7156 7187 7157 7188 /* Line 1806 of yacc.c */ 7158 #line 16 64"parser.yy"7189 #line 1670 "parser.yy" 7159 7190 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7160 7191 break; … … 7163 7194 7164 7195 /* Line 1806 of yacc.c */ 7165 #line 16 66"parser.yy"7196 #line 1672 "parser.yy" 7166 7197 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7167 7198 break; … … 7170 7201 7171 7202 /* Line 1806 of yacc.c */ 7172 #line 16 75"parser.yy"7203 #line 1681 "parser.yy" 7173 7204 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7174 7205 break; … … 7177 7208 7178 7209 /* Line 1806 of yacc.c */ 7179 #line 16 78"parser.yy"7210 #line 1684 "parser.yy" 7180 7211 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7181 7212 break; … … 7184 7215 7185 7216 /* Line 1806 of yacc.c */ 7186 #line 168 0"parser.yy"7217 #line 1686 "parser.yy" 7187 7218 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); } 7188 7219 break; … … 7191 7222 7192 7223 /* Line 1806 of yacc.c */ 7193 #line 169 0"parser.yy"7224 #line 1696 "parser.yy" 7194 7225 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7195 7226 break; … … 7198 7229 7199 7230 /* Line 1806 of yacc.c */ 7200 #line 1 696"parser.yy"7231 #line 1702 "parser.yy" 7201 7232 { 7202 7233 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7208 7239 7209 7240 /* Line 1806 of yacc.c */ 7210 #line 170 1"parser.yy"7241 #line 1707 "parser.yy" 7211 7242 { 7212 7243 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7218 7249 7219 7250 /* Line 1806 of yacc.c */ 7220 #line 171 0"parser.yy"7251 #line 1716 "parser.yy" 7221 7252 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7222 7253 break; … … 7225 7256 7226 7257 /* Line 1806 of yacc.c */ 7227 #line 17 19"parser.yy"7258 #line 1725 "parser.yy" 7228 7259 { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); } 7229 7260 break; … … 7232 7263 7233 7264 /* Line 1806 of yacc.c */ 7234 #line 172 1"parser.yy"7265 #line 1727 "parser.yy" 7235 7266 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); } 7236 7267 break; … … 7239 7270 7240 7271 /* Line 1806 of yacc.c */ 7241 #line 17 46"parser.yy"7272 #line 1752 "parser.yy" 7242 7273 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7243 7274 break; … … 7246 7277 7247 7278 /* Line 1806 of yacc.c */ 7248 #line 17 54"parser.yy"7279 #line 1760 "parser.yy" 7249 7280 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7250 7281 break; … … 7253 7284 7254 7285 /* Line 1806 of yacc.c */ 7255 #line 17 59"parser.yy"7286 #line 1765 "parser.yy" 7256 7287 { (yyval.in) = 0; } 7257 7288 break; … … 7260 7291 7261 7292 /* Line 1806 of yacc.c */ 7262 #line 176 1"parser.yy"7293 #line 1767 "parser.yy" 7263 7294 { (yyval.in) = (yyvsp[(2) - (2)].in); } 7264 7295 break; … … 7267 7298 7268 7299 /* Line 1806 of yacc.c */ 7269 #line 176 3"parser.yy"7300 #line 1769 "parser.yy" 7270 7301 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); } 7271 7302 break; … … 7274 7305 7275 7306 /* Line 1806 of yacc.c */ 7276 #line 17 67"parser.yy"7307 #line 1773 "parser.yy" 7277 7308 { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); } 7278 7309 break; … … 7281 7312 7282 7313 /* Line 1806 of yacc.c */ 7283 #line 17 68"parser.yy"7314 #line 1774 "parser.yy" 7284 7315 { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); } 7285 7316 break; … … 7288 7319 7289 7320 /* Line 1806 of yacc.c */ 7290 #line 177 3"parser.yy"7321 #line 1779 "parser.yy" 7291 7322 { (yyval.in) = 0; } 7292 7323 break; … … 7295 7326 7296 7327 /* Line 1806 of yacc.c */ 7297 #line 17 75"parser.yy"7328 #line 1781 "parser.yy" 7298 7329 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); } 7299 7330 break; … … 7302 7333 7303 7334 /* Line 1806 of yacc.c */ 7304 #line 17 76"parser.yy"7335 #line 1782 "parser.yy" 7305 7336 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); } 7306 7337 break; … … 7309 7340 7310 7341 /* Line 1806 of yacc.c */ 7311 #line 17 78"parser.yy"7342 #line 1784 "parser.yy" 7312 7343 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_last( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); } 7313 7344 break; … … 7316 7347 7317 7348 /* Line 1806 of yacc.c */ 7318 #line 1 794"parser.yy"7349 #line 1800 "parser.yy" 7319 7350 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); } 7320 7351 break; … … 7323 7354 7324 7355 /* Line 1806 of yacc.c */ 7325 #line 180 0"parser.yy"7356 #line 1806 "parser.yy" 7326 7357 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_last( (yyvsp[(2) - (2)].en) ) ); } 7327 7358 break; … … 7330 7361 7331 7362 /* Line 1806 of yacc.c */ 7332 #line 18 06"parser.yy"7363 #line 1812 "parser.yy" 7333 7364 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); } 7334 7365 break; … … 7337 7368 7338 7369 /* Line 1806 of yacc.c */ 7339 #line 18 09"parser.yy"7370 #line 1815 "parser.yy" 7340 7371 { (yyval.en) = (yyvsp[(3) - (5)].en); } 7341 7372 break; … … 7344 7375 7345 7376 /* Line 1806 of yacc.c */ 7346 #line 181 1"parser.yy"7377 #line 1817 "parser.yy" 7347 7378 { (yyval.en) = (yyvsp[(3) - (5)].en); } 7348 7379 break; … … 7351 7382 7352 7383 /* Line 1806 of yacc.c */ 7353 #line 181 3"parser.yy"7384 #line 1819 "parser.yy" 7354 7385 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ); } 7355 7386 break; … … 7358 7389 7359 7390 /* Line 1806 of yacc.c */ 7360 #line 18 15"parser.yy"7391 #line 1821 "parser.yy" 7361 7392 { (yyval.en) = (yyvsp[(4) - (6)].en); } 7362 7393 break; … … 7365 7396 7366 7397 /* Line 1806 of yacc.c */ 7367 #line 18 39"parser.yy"7398 #line 1845 "parser.yy" 7368 7399 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7369 7400 break; … … 7372 7403 7373 7404 /* Line 1806 of yacc.c */ 7374 #line 184 1"parser.yy"7405 #line 1847 "parser.yy" 7375 7406 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7376 7407 break; … … 7379 7410 7380 7411 /* Line 1806 of yacc.c */ 7381 #line 184 3"parser.yy"7412 #line 1849 "parser.yy" 7382 7413 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7383 7414 break; … … 7386 7417 7387 7418 /* Line 1806 of yacc.c */ 7388 #line 18 49"parser.yy"7419 #line 1855 "parser.yy" 7389 7420 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7390 7421 break; … … 7393 7424 7394 7425 /* Line 1806 of yacc.c */ 7395 #line 185 1"parser.yy"7426 #line 1857 "parser.yy" 7396 7427 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7397 7428 break; … … 7400 7431 7401 7432 /* Line 1806 of yacc.c */ 7402 #line 18 56"parser.yy"7433 #line 1862 "parser.yy" 7403 7434 { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 7404 7435 break; … … 7407 7438 7408 7439 /* Line 1806 of yacc.c */ 7409 #line 186 2"parser.yy"7440 #line 1868 "parser.yy" 7410 7441 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); } 7411 7442 break; … … 7414 7445 7415 7446 /* Line 1806 of yacc.c */ 7416 #line 18 67"parser.yy"7447 #line 1873 "parser.yy" 7417 7448 { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); } 7418 7449 break; … … 7421 7452 7422 7453 /* Line 1806 of yacc.c */ 7423 #line 18 69"parser.yy"7454 #line 1875 "parser.yy" 7424 7455 { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); } 7425 7456 break; … … 7428 7459 7429 7460 /* Line 1806 of yacc.c */ 7430 #line 18 75"parser.yy"7461 #line 1881 "parser.yy" 7431 7462 { (yyval.tclass) = DeclarationNode::Otype; } 7432 7463 break; … … 7435 7466 7436 7467 /* Line 1806 of yacc.c */ 7437 #line 18 77"parser.yy"7468 #line 1883 "parser.yy" 7438 7469 { (yyval.tclass) = DeclarationNode::Ftype; } 7439 7470 break; … … 7442 7473 7443 7474 /* Line 1806 of yacc.c */ 7444 #line 18 79"parser.yy"7475 #line 1885 "parser.yy" 7445 7476 { (yyval.tclass) = DeclarationNode::Dtype; } 7446 7477 break; … … 7449 7480 7450 7481 /* Line 1806 of yacc.c */ 7451 #line 18 84"parser.yy"7482 #line 1890 "parser.yy" 7452 7483 { (yyval.decl) = 0; } 7453 7484 break; … … 7456 7487 7457 7488 /* Line 1806 of yacc.c */ 7458 #line 18 86"parser.yy"7489 #line 1892 "parser.yy" 7459 7490 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 7460 7491 break; … … 7463 7494 7464 7495 /* Line 1806 of yacc.c */ 7465 #line 189 1"parser.yy"7496 #line 1897 "parser.yy" 7466 7497 { 7467 7498 typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) ); … … 7473 7504 7474 7505 /* Line 1806 of yacc.c */ 7475 #line 1 896"parser.yy"7506 #line 1902 "parser.yy" 7476 7507 { (yyval.decl) = (yyvsp[(4) - (5)].decl); } 7477 7508 break; … … 7480 7511 7481 7512 /* Line 1806 of yacc.c */ 7482 #line 1 898"parser.yy"7513 #line 1904 "parser.yy" 7483 7514 { (yyval.decl) = 0; } 7484 7515 break; … … 7487 7518 7488 7519 /* Line 1806 of yacc.c */ 7489 #line 190 3"parser.yy"7520 #line 1909 "parser.yy" 7490 7521 { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); } 7491 7522 break; … … 7494 7525 7495 7526 /* Line 1806 of yacc.c */ 7496 #line 19 06"parser.yy"7527 #line 1912 "parser.yy" 7497 7528 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( build_typevalue( (yyvsp[(3) - (3)].decl) ) ) ) ); } 7498 7529 break; … … 7501 7532 7502 7533 /* Line 1806 of yacc.c */ 7503 #line 19 08"parser.yy"7534 #line 1914 "parser.yy" 7504 7535 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); } 7505 7536 break; … … 7508 7539 7509 7540 /* Line 1806 of yacc.c */ 7510 #line 191 3"parser.yy"7541 #line 1919 "parser.yy" 7511 7542 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 7512 7543 break; … … 7515 7546 7516 7547 /* Line 1806 of yacc.c */ 7517 #line 19 15"parser.yy"7548 #line 1921 "parser.yy" 7518 7549 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); } 7519 7550 break; … … 7522 7553 7523 7554 /* Line 1806 of yacc.c */ 7524 #line 19 17"parser.yy"7555 #line 1923 "parser.yy" 7525 7556 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); } 7526 7557 break; … … 7529 7560 7530 7561 /* Line 1806 of yacc.c */ 7531 #line 192 2"parser.yy"7562 #line 1928 "parser.yy" 7532 7563 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); } 7533 7564 break; … … 7536 7567 7537 7568 /* Line 1806 of yacc.c */ 7538 #line 19 24"parser.yy"7569 #line 1930 "parser.yy" 7539 7570 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); } 7540 7571 break; … … 7543 7574 7544 7575 /* Line 1806 of yacc.c */ 7545 #line 19 29"parser.yy"7576 #line 1935 "parser.yy" 7546 7577 { 7547 7578 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD ); … … 7553 7584 7554 7585 /* Line 1806 of yacc.c */ 7555 #line 19 34"parser.yy"7586 #line 1940 "parser.yy" 7556 7587 { 7557 7588 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG ); … … 7563 7594 7564 7595 /* Line 1806 of yacc.c */ 7565 #line 194 2"parser.yy"7596 #line 1948 "parser.yy" 7566 7597 { 7567 7598 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID ); … … 7573 7604 7574 7605 /* Line 1806 of yacc.c */ 7575 #line 19 47"parser.yy"7606 #line 1953 "parser.yy" 7576 7607 { 7577 7608 typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) ); … … 7583 7614 7584 7615 /* Line 1806 of yacc.c */ 7585 #line 195 2"parser.yy"7616 #line 1958 "parser.yy" 7586 7617 { 7587 7618 typedefTable.leaveTrait(); … … 7594 7625 7595 7626 /* Line 1806 of yacc.c */ 7596 #line 196 2"parser.yy"7627 #line 1968 "parser.yy" 7597 7628 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 7598 7629 break; … … 7601 7632 7602 7633 /* Line 1806 of yacc.c */ 7603 #line 197 2"parser.yy"7634 #line 1978 "parser.yy" 7604 7635 { 7605 7636 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7611 7642 7612 7643 /* Line 1806 of yacc.c */ 7613 #line 19 77"parser.yy"7644 #line 1983 "parser.yy" 7614 7645 { 7615 7646 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7621 7652 7622 7653 /* Line 1806 of yacc.c */ 7623 #line 198 2"parser.yy"7654 #line 1988 "parser.yy" 7624 7655 { 7625 7656 typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 7631 7662 7632 7663 /* Line 1806 of yacc.c */ 7633 #line 199 0"parser.yy"7664 #line 1996 "parser.yy" 7634 7665 { 7635 7666 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7641 7672 7642 7673 /* Line 1806 of yacc.c */ 7643 #line 1995"parser.yy"7674 #line 2001 "parser.yy" 7644 7675 { 7645 7676 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7651 7682 7652 7683 /* Line 1806 of yacc.c */ 7653 #line 20 05"parser.yy"7684 #line 2011 "parser.yy" 7654 7685 {} 7655 7686 break; … … 7658 7689 7659 7690 /* Line 1806 of yacc.c */ 7660 #line 20 07"parser.yy"7691 #line 2013 "parser.yy" 7661 7692 { parseTree = parseTree != nullptr ? parseTree->appendList( (yyvsp[(1) - (1)].decl) ) : (yyvsp[(1) - (1)].decl); } 7662 7693 break; … … 7665 7696 7666 7697 /* Line 1806 of yacc.c */ 7667 #line 201 3"parser.yy"7698 #line 2019 "parser.yy" 7668 7699 { (yyval.decl) = (yyvsp[(1) - (3)].decl) != nullptr ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); } 7669 7700 break; … … 7672 7703 7673 7704 /* Line 1806 of yacc.c */ 7674 #line 20 18"parser.yy"7705 #line 2024 "parser.yy" 7675 7706 { (yyval.decl) = 0; } 7676 7707 break; … … 7679 7710 7680 7711 /* Line 1806 of yacc.c */ 7681 #line 20 26"parser.yy"7712 #line 2032 "parser.yy" 7682 7713 {} 7683 7714 break; … … 7686 7717 7687 7718 /* Line 1806 of yacc.c */ 7688 #line 20 28"parser.yy"7719 #line 2034 "parser.yy" 7689 7720 { 7690 7721 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" … … 7696 7727 7697 7728 /* Line 1806 of yacc.c */ 7698 #line 203 3"parser.yy"7729 #line 2039 "parser.yy" 7699 7730 { 7700 7731 linkage = linkageStack.top(); … … 7707 7738 7708 7739 /* Line 1806 of yacc.c */ 7709 #line 20 39"parser.yy"7740 #line 2045 "parser.yy" 7710 7741 { // mark all fields in list 7711 7742 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 7718 7749 7719 7750 /* Line 1806 of yacc.c */ 7720 #line 20 54"parser.yy"7751 #line 2060 "parser.yy" 7721 7752 { 7722 7753 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7729 7760 7730 7761 /* Line 1806 of yacc.c */ 7731 #line 206 0"parser.yy"7762 #line 2066 "parser.yy" 7732 7763 { 7733 7764 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7740 7771 7741 7772 /* Line 1806 of yacc.c */ 7742 #line 20 69"parser.yy"7773 #line 2075 "parser.yy" 7743 7774 { 7744 7775 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7751 7782 7752 7783 /* Line 1806 of yacc.c */ 7753 #line 20 75"parser.yy"7784 #line 2081 "parser.yy" 7754 7785 { 7755 7786 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7760 7791 7761 7792 case 538: 7762 7763 /* Line 1806 of yacc.c */7764 #line 2081 "parser.yy"7765 {7766 typedefTable.addToEnclosingScope( TypedefTable::ID );7767 typedefTable.leaveScope();7768 (yyval.decl) = (yyvsp[(2) - (3)].decl)->addFunctionBody( (yyvsp[(3) - (3)].sn) )->addQualifiers( (yyvsp[(1) - (3)].decl) );7769 }7770 break;7771 7772 case 539:7773 7793 7774 7794 /* Line 1806 of yacc.c */ … … 7781 7801 break; 7782 7802 7803 case 539: 7804 7805 /* Line 1806 of yacc.c */ 7806 #line 2093 "parser.yy" 7807 { 7808 typedefTable.addToEnclosingScope( TypedefTable::ID ); 7809 typedefTable.leaveScope(); 7810 (yyval.decl) = (yyvsp[(2) - (3)].decl)->addFunctionBody( (yyvsp[(3) - (3)].sn) )->addQualifiers( (yyvsp[(1) - (3)].decl) ); 7811 } 7812 break; 7813 7783 7814 case 540: 7784 7815 7785 7816 /* Line 1806 of yacc.c */ 7786 #line 209 3"parser.yy"7817 #line 2099 "parser.yy" 7787 7818 { 7788 7819 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7795 7826 7796 7827 /* Line 1806 of yacc.c */ 7797 #line 210 1"parser.yy"7828 #line 2107 "parser.yy" 7798 7829 { 7799 7830 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7806 7837 7807 7838 /* Line 1806 of yacc.c */ 7808 #line 21 07"parser.yy"7839 #line 2113 "parser.yy" 7809 7840 { 7810 7841 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7817 7848 7818 7849 /* Line 1806 of yacc.c */ 7819 #line 21 15"parser.yy"7850 #line 2121 "parser.yy" 7820 7851 { 7821 7852 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7828 7859 7829 7860 /* Line 1806 of yacc.c */ 7830 #line 212 1"parser.yy"7861 #line 2127 "parser.yy" 7831 7862 { 7832 7863 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7839 7870 7840 7871 /* Line 1806 of yacc.c */ 7841 #line 21 36"parser.yy"7872 #line 2142 "parser.yy" 7842 7873 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 7843 7874 break; … … 7846 7877 7847 7878 /* Line 1806 of yacc.c */ 7848 #line 214 1"parser.yy"7879 #line 2147 "parser.yy" 7849 7880 { delete (yyvsp[(3) - (5)].str); } 7850 7881 break; … … 7853 7884 7854 7885 /* Line 1806 of yacc.c */ 7855 #line 21 46"parser.yy"7886 #line 2152 "parser.yy" 7856 7887 { (yyval.decl) = 0; } 7857 7888 break; … … 7860 7891 7861 7892 /* Line 1806 of yacc.c */ 7862 #line 215 3"parser.yy"7893 #line 2159 "parser.yy" 7863 7894 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7864 7895 break; … … 7867 7898 7868 7899 /* Line 1806 of yacc.c */ 7869 #line 21 59"parser.yy"7900 #line 2165 "parser.yy" 7870 7901 { (yyval.decl) = 0; } 7871 7902 break; … … 7874 7905 7875 7906 /* Line 1806 of yacc.c */ 7876 #line 217 0"parser.yy"7907 #line 2176 "parser.yy" 7877 7908 { delete (yyvsp[(3) - (4)].en); } 7878 7909 break; … … 7881 7912 7882 7913 /* Line 1806 of yacc.c */ 7883 #line 21 74"parser.yy"7914 #line 2180 "parser.yy" 7884 7915 { delete (yyvsp[(1) - (1)].tok); } 7885 7916 break; … … 7888 7919 7889 7920 /* Line 1806 of yacc.c */ 7890 #line 21 75"parser.yy"7921 #line 2181 "parser.yy" 7891 7922 { delete (yyvsp[(1) - (1)].decl); } 7892 7923 break; … … 7895 7926 7896 7927 /* Line 1806 of yacc.c */ 7897 #line 21 76"parser.yy"7928 #line 2182 "parser.yy" 7898 7929 { delete (yyvsp[(1) - (1)].decl); } 7899 7930 break; … … 7902 7933 7903 7934 /* Line 1806 of yacc.c */ 7904 #line 21 77"parser.yy"7935 #line 2183 "parser.yy" 7905 7936 { delete (yyvsp[(1) - (1)].decl); } 7906 7937 break; … … 7909 7940 7910 7941 /* Line 1806 of yacc.c */ 7911 #line 221 2"parser.yy"7942 #line 2218 "parser.yy" 7912 7943 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7913 7944 break; … … 7916 7947 7917 7948 /* Line 1806 of yacc.c */ 7918 #line 22 15"parser.yy"7949 #line 2221 "parser.yy" 7919 7950 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7920 7951 break; … … 7923 7954 7924 7955 /* Line 1806 of yacc.c */ 7925 #line 22 17"parser.yy"7956 #line 2223 "parser.yy" 7926 7957 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7927 7958 break; … … 7930 7961 7931 7962 /* Line 1806 of yacc.c */ 7932 #line 222 2"parser.yy"7963 #line 2228 "parser.yy" 7933 7964 { 7934 7965 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 7940 7971 7941 7972 /* Line 1806 of yacc.c */ 7942 #line 22 27"parser.yy"7973 #line 2233 "parser.yy" 7943 7974 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 7944 7975 break; … … 7947 7978 7948 7979 /* Line 1806 of yacc.c */ 7949 #line 223 2"parser.yy"7980 #line 2238 "parser.yy" 7950 7981 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 7951 7982 break; … … 7954 7985 7955 7986 /* Line 1806 of yacc.c */ 7956 #line 22 34"parser.yy"7987 #line 2240 "parser.yy" 7957 7988 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 7958 7989 break; … … 7961 7992 7962 7993 /* Line 1806 of yacc.c */ 7963 #line 22 36"parser.yy"7994 #line 2242 "parser.yy" 7964 7995 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 7965 7996 break; … … 7968 7999 7969 8000 /* Line 1806 of yacc.c */ 7970 #line 224 1"parser.yy"8001 #line 2247 "parser.yy" 7971 8002 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 7972 8003 break; … … 7975 8006 7976 8007 /* Line 1806 of yacc.c */ 7977 #line 224 3"parser.yy"8008 #line 2249 "parser.yy" 7978 8009 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 7979 8010 break; … … 7982 8013 7983 8014 /* Line 1806 of yacc.c */ 7984 #line 22 45"parser.yy"8015 #line 2251 "parser.yy" 7985 8016 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 7986 8017 break; … … 7989 8020 7990 8021 /* Line 1806 of yacc.c */ 7991 #line 22 47"parser.yy"8022 #line 2253 "parser.yy" 7992 8023 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 7993 8024 break; … … 7996 8027 7997 8028 /* Line 1806 of yacc.c */ 7998 #line 225 2"parser.yy"8029 #line 2258 "parser.yy" 7999 8030 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8000 8031 break; … … 8003 8034 8004 8035 /* Line 1806 of yacc.c */ 8005 #line 22 54"parser.yy"8036 #line 2260 "parser.yy" 8006 8037 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8007 8038 break; … … 8010 8041 8011 8042 /* Line 1806 of yacc.c */ 8012 #line 226 3"parser.yy"8043 #line 2269 "parser.yy" 8013 8044 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8014 8045 break; … … 8017 8048 8018 8049 /* Line 1806 of yacc.c */ 8019 #line 22 66"parser.yy"8050 #line 2272 "parser.yy" 8020 8051 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8021 8052 break; … … 8024 8055 8025 8056 /* Line 1806 of yacc.c */ 8026 #line 227 1"parser.yy"8057 #line 2277 "parser.yy" 8027 8058 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8028 8059 break; … … 8031 8062 8032 8063 /* Line 1806 of yacc.c */ 8033 #line 227 3"parser.yy"8064 #line 2279 "parser.yy" 8034 8065 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8035 8066 break; … … 8038 8069 8039 8070 /* Line 1806 of yacc.c */ 8040 #line 22 75"parser.yy"8071 #line 2281 "parser.yy" 8041 8072 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8042 8073 break; … … 8045 8076 8046 8077 /* Line 1806 of yacc.c */ 8047 #line 228 0"parser.yy"8078 #line 2286 "parser.yy" 8048 8079 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8049 8080 break; … … 8052 8083 8053 8084 /* Line 1806 of yacc.c */ 8054 #line 228 2"parser.yy"8085 #line 2288 "parser.yy" 8055 8086 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8056 8087 break; … … 8059 8090 8060 8091 /* Line 1806 of yacc.c */ 8061 #line 22 84"parser.yy"8092 #line 2290 "parser.yy" 8062 8093 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8063 8094 break; … … 8066 8097 8067 8098 /* Line 1806 of yacc.c */ 8068 #line 22 89"parser.yy"8099 #line 2295 "parser.yy" 8069 8100 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8070 8101 break; … … 8073 8104 8074 8105 /* Line 1806 of yacc.c */ 8075 #line 229 1"parser.yy"8106 #line 2297 "parser.yy" 8076 8107 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8077 8108 break; … … 8080 8111 8081 8112 /* Line 1806 of yacc.c */ 8082 #line 229 3"parser.yy"8113 #line 2299 "parser.yy" 8083 8114 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8084 8115 break; … … 8087 8118 8088 8119 /* Line 1806 of yacc.c */ 8089 #line 23 08"parser.yy"8120 #line 2314 "parser.yy" 8090 8121 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); } 8091 8122 break; … … 8094 8125 8095 8126 /* Line 1806 of yacc.c */ 8096 #line 231 0"parser.yy"8127 #line 2316 "parser.yy" 8097 8128 { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); } 8098 8129 break; … … 8101 8132 8102 8133 /* Line 1806 of yacc.c */ 8103 #line 231 2"parser.yy"8134 #line 2318 "parser.yy" 8104 8135 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8105 8136 break; … … 8108 8139 8109 8140 /* Line 1806 of yacc.c */ 8110 #line 23 17"parser.yy"8141 #line 2323 "parser.yy" 8111 8142 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8112 8143 break; … … 8115 8146 8116 8147 /* Line 1806 of yacc.c */ 8117 #line 23 19"parser.yy"8148 #line 2325 "parser.yy" 8118 8149 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8119 8150 break; … … 8122 8153 8123 8154 /* Line 1806 of yacc.c */ 8124 #line 232 1"parser.yy"8155 #line 2327 "parser.yy" 8125 8156 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8126 8157 break; … … 8129 8160 8130 8161 /* Line 1806 of yacc.c */ 8131 #line 23 26"parser.yy"8162 #line 2332 "parser.yy" 8132 8163 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8133 8164 break; … … 8136 8167 8137 8168 /* Line 1806 of yacc.c */ 8138 #line 23 28"parser.yy"8169 #line 2334 "parser.yy" 8139 8170 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8140 8171 break; … … 8143 8174 8144 8175 /* Line 1806 of yacc.c */ 8145 #line 233 0"parser.yy"8176 #line 2336 "parser.yy" 8146 8177 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8147 8178 break; … … 8150 8181 8151 8182 /* Line 1806 of yacc.c */ 8152 #line 23 45"parser.yy"8183 #line 2351 "parser.yy" 8153 8184 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8154 8185 break; … … 8157 8188 8158 8189 /* Line 1806 of yacc.c */ 8159 #line 23 48"parser.yy"8190 #line 2354 "parser.yy" 8160 8191 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8161 8192 break; … … 8164 8195 8165 8196 /* Line 1806 of yacc.c */ 8166 #line 235 0"parser.yy"8197 #line 2356 "parser.yy" 8167 8198 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8168 8199 break; … … 8171 8202 8172 8203 /* Line 1806 of yacc.c */ 8173 #line 23 56"parser.yy"8204 #line 2362 "parser.yy" 8174 8205 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8175 8206 break; … … 8178 8209 8179 8210 /* Line 1806 of yacc.c */ 8180 #line 236 1"parser.yy"8211 #line 2367 "parser.yy" 8181 8212 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8182 8213 break; … … 8185 8216 8186 8217 /* Line 1806 of yacc.c */ 8187 #line 236 3"parser.yy"8218 #line 2369 "parser.yy" 8188 8219 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8189 8220 break; … … 8192 8223 8193 8224 /* Line 1806 of yacc.c */ 8194 #line 23 65"parser.yy"8225 #line 2371 "parser.yy" 8195 8226 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8196 8227 break; … … 8199 8230 8200 8231 /* Line 1806 of yacc.c */ 8201 #line 237 0"parser.yy"8232 #line 2376 "parser.yy" 8202 8233 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8203 8234 break; … … 8206 8237 8207 8238 /* Line 1806 of yacc.c */ 8208 #line 237 2"parser.yy"8239 #line 2378 "parser.yy" 8209 8240 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8210 8241 break; … … 8213 8244 8214 8245 /* Line 1806 of yacc.c */ 8215 #line 23 74"parser.yy"8246 #line 2380 "parser.yy" 8216 8247 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8217 8248 break; … … 8220 8251 8221 8252 /* Line 1806 of yacc.c */ 8222 #line 23 76"parser.yy"8253 #line 2382 "parser.yy" 8223 8254 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8224 8255 break; … … 8227 8258 8228 8259 /* Line 1806 of yacc.c */ 8229 #line 238 1"parser.yy"8260 #line 2387 "parser.yy" 8230 8261 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8231 8262 break; … … 8234 8265 8235 8266 /* Line 1806 of yacc.c */ 8236 #line 238 3"parser.yy"8267 #line 2389 "parser.yy" 8237 8268 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8238 8269 break; … … 8241 8272 8242 8273 /* Line 1806 of yacc.c */ 8243 #line 23 85"parser.yy"8274 #line 2391 "parser.yy" 8244 8275 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8245 8276 break; … … 8248 8279 8249 8280 /* Line 1806 of yacc.c */ 8250 #line 2 395"parser.yy"8281 #line 2401 "parser.yy" 8251 8282 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8252 8283 break; … … 8255 8286 8256 8287 /* Line 1806 of yacc.c */ 8257 #line 2 398"parser.yy"8288 #line 2404 "parser.yy" 8258 8289 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8259 8290 break; … … 8262 8293 8263 8294 /* Line 1806 of yacc.c */ 8264 #line 240 0"parser.yy"8295 #line 2406 "parser.yy" 8265 8296 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8266 8297 break; … … 8269 8300 8270 8301 /* Line 1806 of yacc.c */ 8271 #line 24 05"parser.yy"8302 #line 2411 "parser.yy" 8272 8303 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8273 8304 break; … … 8276 8307 8277 8308 /* Line 1806 of yacc.c */ 8278 #line 24 07"parser.yy"8309 #line 2413 "parser.yy" 8279 8310 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8280 8311 break; … … 8283 8314 8284 8315 /* Line 1806 of yacc.c */ 8285 #line 24 09"parser.yy"8316 #line 2415 "parser.yy" 8286 8317 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8287 8318 break; … … 8290 8321 8291 8322 /* Line 1806 of yacc.c */ 8292 #line 24 14"parser.yy"8323 #line 2420 "parser.yy" 8293 8324 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8294 8325 break; … … 8297 8328 8298 8329 /* Line 1806 of yacc.c */ 8299 #line 24 16"parser.yy"8330 #line 2422 "parser.yy" 8300 8331 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8301 8332 break; … … 8304 8335 8305 8336 /* Line 1806 of yacc.c */ 8306 #line 24 18"parser.yy"8337 #line 2424 "parser.yy" 8307 8338 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8308 8339 break; … … 8311 8342 8312 8343 /* Line 1806 of yacc.c */ 8313 #line 242 0"parser.yy"8344 #line 2426 "parser.yy" 8314 8345 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8315 8346 break; … … 8318 8349 8319 8350 /* Line 1806 of yacc.c */ 8320 #line 24 25"parser.yy"8351 #line 2431 "parser.yy" 8321 8352 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8322 8353 break; … … 8325 8356 8326 8357 /* Line 1806 of yacc.c */ 8327 #line 24 27"parser.yy"8358 #line 2433 "parser.yy" 8328 8359 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8329 8360 break; … … 8332 8363 8333 8364 /* Line 1806 of yacc.c */ 8334 #line 24 29"parser.yy"8365 #line 2435 "parser.yy" 8335 8366 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8336 8367 break; … … 8339 8370 8340 8371 /* Line 1806 of yacc.c */ 8341 #line 246 0"parser.yy"8372 #line 2466 "parser.yy" 8342 8373 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8343 8374 break; … … 8346 8377 8347 8378 /* Line 1806 of yacc.c */ 8348 #line 246 3"parser.yy"8379 #line 2469 "parser.yy" 8349 8380 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8350 8381 break; … … 8353 8384 8354 8385 /* Line 1806 of yacc.c */ 8355 #line 24 65"parser.yy"8386 #line 2471 "parser.yy" 8356 8387 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8357 8388 break; … … 8360 8391 8361 8392 /* Line 1806 of yacc.c */ 8362 #line 247 0"parser.yy"8393 #line 2476 "parser.yy" 8363 8394 { 8364 8395 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8370 8401 8371 8402 /* Line 1806 of yacc.c */ 8372 #line 24 75"parser.yy"8403 #line 2481 "parser.yy" 8373 8404 { 8374 8405 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8380 8411 8381 8412 /* Line 1806 of yacc.c */ 8382 #line 248 3"parser.yy"8413 #line 2489 "parser.yy" 8383 8414 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8384 8415 break; … … 8387 8418 8388 8419 /* Line 1806 of yacc.c */ 8389 #line 24 85"parser.yy"8420 #line 2491 "parser.yy" 8390 8421 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8391 8422 break; … … 8394 8425 8395 8426 /* Line 1806 of yacc.c */ 8396 #line 24 87"parser.yy"8427 #line 2493 "parser.yy" 8397 8428 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8398 8429 break; … … 8401 8432 8402 8433 /* Line 1806 of yacc.c */ 8403 #line 249 2"parser.yy"8434 #line 2498 "parser.yy" 8404 8435 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8405 8436 break; … … 8408 8439 8409 8440 /* Line 1806 of yacc.c */ 8410 #line 2 494"parser.yy"8441 #line 2500 "parser.yy" 8411 8442 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8412 8443 break; … … 8415 8446 8416 8447 /* Line 1806 of yacc.c */ 8417 #line 2 499"parser.yy"8448 #line 2505 "parser.yy" 8418 8449 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8419 8450 break; … … 8422 8453 8423 8454 /* Line 1806 of yacc.c */ 8424 #line 250 1"parser.yy"8455 #line 2507 "parser.yy" 8425 8456 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8426 8457 break; … … 8429 8460 8430 8461 /* Line 1806 of yacc.c */ 8431 #line 25 16"parser.yy"8462 #line 2522 "parser.yy" 8432 8463 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8433 8464 break; … … 8436 8467 8437 8468 /* Line 1806 of yacc.c */ 8438 #line 25 18"parser.yy"8469 #line 2524 "parser.yy" 8439 8470 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8440 8471 break; … … 8443 8474 8444 8475 /* Line 1806 of yacc.c */ 8445 #line 252 3"parser.yy"8476 #line 2529 "parser.yy" 8446 8477 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8447 8478 break; … … 8450 8481 8451 8482 /* Line 1806 of yacc.c */ 8452 #line 25 25"parser.yy"8483 #line 2531 "parser.yy" 8453 8484 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8454 8485 break; … … 8457 8488 8458 8489 /* Line 1806 of yacc.c */ 8459 #line 25 27"parser.yy"8490 #line 2533 "parser.yy" 8460 8491 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8461 8492 break; … … 8464 8495 8465 8496 /* Line 1806 of yacc.c */ 8466 #line 25 29"parser.yy"8497 #line 2535 "parser.yy" 8467 8498 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8468 8499 break; … … 8471 8502 8472 8503 /* Line 1806 of yacc.c */ 8473 #line 253 1"parser.yy"8504 #line 2537 "parser.yy" 8474 8505 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8475 8506 break; … … 8478 8509 8479 8510 /* Line 1806 of yacc.c */ 8480 #line 25 37"parser.yy"8511 #line 2543 "parser.yy" 8481 8512 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8482 8513 break; … … 8485 8516 8486 8517 /* Line 1806 of yacc.c */ 8487 #line 25 39"parser.yy"8518 #line 2545 "parser.yy" 8488 8519 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8489 8520 break; … … 8492 8523 8493 8524 /* Line 1806 of yacc.c */ 8494 #line 254 1"parser.yy"8525 #line 2547 "parser.yy" 8495 8526 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8496 8527 break; … … 8499 8530 8500 8531 /* Line 1806 of yacc.c */ 8501 #line 25 46"parser.yy"8532 #line 2552 "parser.yy" 8502 8533 { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); } 8503 8534 break; … … 8506 8537 8507 8538 /* Line 1806 of yacc.c */ 8508 #line 25 48"parser.yy"8539 #line 2554 "parser.yy" 8509 8540 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8510 8541 break; … … 8513 8544 8514 8545 /* Line 1806 of yacc.c */ 8515 #line 255 0"parser.yy"8546 #line 2556 "parser.yy" 8516 8547 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8517 8548 break; … … 8520 8551 8521 8552 /* Line 1806 of yacc.c */ 8522 #line 25 56"parser.yy"8553 #line 2562 "parser.yy" 8523 8554 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8524 8555 break; … … 8527 8558 8528 8559 /* Line 1806 of yacc.c */ 8529 #line 25 58"parser.yy"8560 #line 2564 "parser.yy" 8530 8561 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); } 8531 8562 break; … … 8534 8565 8535 8566 /* Line 1806 of yacc.c */ 8536 #line 25 64"parser.yy"8567 #line 2570 "parser.yy" 8537 8568 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); } 8538 8569 break; … … 8541 8572 8542 8573 /* Line 1806 of yacc.c */ 8543 #line 25 66"parser.yy"8574 #line 2572 "parser.yy" 8544 8575 { (yyval.decl) = DeclarationNode::newVarArray( 0 ); } 8545 8576 break; … … 8548 8579 8549 8580 /* Line 1806 of yacc.c */ 8550 #line 25 68"parser.yy"8581 #line 2574 "parser.yy" 8551 8582 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); } 8552 8583 break; … … 8555 8586 8556 8587 /* Line 1806 of yacc.c */ 8557 #line 257 0"parser.yy"8588 #line 2576 "parser.yy" 8558 8589 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); } 8559 8590 break; … … 8562 8593 8563 8594 /* Line 1806 of yacc.c */ 8564 #line 25 85"parser.yy"8595 #line 2591 "parser.yy" 8565 8596 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8566 8597 break; … … 8569 8600 8570 8601 /* Line 1806 of yacc.c */ 8571 #line 25 87"parser.yy"8602 #line 2593 "parser.yy" 8572 8603 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8573 8604 break; … … 8576 8607 8577 8608 /* Line 1806 of yacc.c */ 8578 #line 259 2"parser.yy"8609 #line 2598 "parser.yy" 8579 8610 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8580 8611 break; … … 8583 8614 8584 8615 /* Line 1806 of yacc.c */ 8585 #line 2 594"parser.yy"8616 #line 2600 "parser.yy" 8586 8617 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8587 8618 break; … … 8590 8621 8591 8622 /* Line 1806 of yacc.c */ 8592 #line 2 596"parser.yy"8623 #line 2602 "parser.yy" 8593 8624 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8594 8625 break; … … 8597 8628 8598 8629 /* Line 1806 of yacc.c */ 8599 #line 2 598"parser.yy"8630 #line 2604 "parser.yy" 8600 8631 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8601 8632 break; … … 8604 8635 8605 8636 /* Line 1806 of yacc.c */ 8606 #line 260 0"parser.yy"8637 #line 2606 "parser.yy" 8607 8638 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8608 8639 break; … … 8611 8642 8612 8643 /* Line 1806 of yacc.c */ 8613 #line 26 06"parser.yy"8644 #line 2612 "parser.yy" 8614 8645 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8615 8646 break; … … 8618 8649 8619 8650 /* Line 1806 of yacc.c */ 8620 #line 26 08"parser.yy"8651 #line 2614 "parser.yy" 8621 8652 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8622 8653 break; … … 8625 8656 8626 8657 /* Line 1806 of yacc.c */ 8627 #line 261 0"parser.yy"8658 #line 2616 "parser.yy" 8628 8659 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8629 8660 break; … … 8632 8663 8633 8664 /* Line 1806 of yacc.c */ 8634 #line 26 15"parser.yy"8665 #line 2621 "parser.yy" 8635 8666 { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); } 8636 8667 break; … … 8639 8670 8640 8671 /* Line 1806 of yacc.c */ 8641 #line 26 17"parser.yy"8672 #line 2623 "parser.yy" 8642 8673 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8643 8674 break; … … 8646 8677 8647 8678 /* Line 1806 of yacc.c */ 8648 #line 26 19"parser.yy"8679 #line 2625 "parser.yy" 8649 8680 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8650 8681 break; … … 8653 8684 8654 8685 /* Line 1806 of yacc.c */ 8655 #line 26 26"parser.yy"8686 #line 2632 "parser.yy" 8656 8687 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8657 8688 break; … … 8660 8691 8661 8692 /* Line 1806 of yacc.c */ 8662 #line 26 37"parser.yy"8693 #line 2643 "parser.yy" 8663 8694 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8664 8695 break; … … 8667 8698 8668 8699 /* Line 1806 of yacc.c */ 8669 #line 264 0"parser.yy"8700 #line 2646 "parser.yy" 8670 8701 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 8671 8702 break; … … 8674 8705 8675 8706 /* Line 1806 of yacc.c */ 8676 #line 264 2"parser.yy"8707 #line 2648 "parser.yy" 8677 8708 { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); } 8678 8709 break; … … 8681 8712 8682 8713 /* Line 1806 of yacc.c */ 8683 #line 26 45"parser.yy"8714 #line 2651 "parser.yy" 8684 8715 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 8685 8716 break; … … 8688 8719 8689 8720 /* Line 1806 of yacc.c */ 8690 #line 26 47"parser.yy"8721 #line 2653 "parser.yy" 8691 8722 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); } 8692 8723 break; … … 8695 8726 8696 8727 /* Line 1806 of yacc.c */ 8697 #line 26 49"parser.yy"8728 #line 2655 "parser.yy" 8698 8729 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); } 8699 8730 break; … … 8702 8733 8703 8734 /* Line 1806 of yacc.c */ 8704 #line 266 3"parser.yy"8735 #line 2669 "parser.yy" 8705 8736 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8706 8737 break; … … 8709 8740 8710 8741 /* Line 1806 of yacc.c */ 8711 #line 26 65"parser.yy"8742 #line 2671 "parser.yy" 8712 8743 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8713 8744 break; … … 8716 8747 8717 8748 /* Line 1806 of yacc.c */ 8718 #line 267 0"parser.yy"8749 #line 2676 "parser.yy" 8719 8750 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8720 8751 break; … … 8723 8754 8724 8755 /* Line 1806 of yacc.c */ 8725 #line 267 2"parser.yy"8756 #line 2678 "parser.yy" 8726 8757 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8727 8758 break; … … 8730 8761 8731 8762 /* Line 1806 of yacc.c */ 8732 #line 26 74"parser.yy"8763 #line 2680 "parser.yy" 8733 8764 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8734 8765 break; … … 8737 8768 8738 8769 /* Line 1806 of yacc.c */ 8739 #line 26 76"parser.yy"8770 #line 2682 "parser.yy" 8740 8771 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8741 8772 break; … … 8744 8775 8745 8776 /* Line 1806 of yacc.c */ 8746 #line 26 78"parser.yy"8777 #line 2684 "parser.yy" 8747 8778 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8748 8779 break; … … 8751 8782 8752 8783 /* Line 1806 of yacc.c */ 8753 #line 26 84"parser.yy"8784 #line 2690 "parser.yy" 8754 8785 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8755 8786 break; … … 8758 8789 8759 8790 /* Line 1806 of yacc.c */ 8760 #line 26 86"parser.yy"8791 #line 2692 "parser.yy" 8761 8792 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8762 8793 break; … … 8765 8796 8766 8797 /* Line 1806 of yacc.c */ 8767 #line 26 88"parser.yy"8798 #line 2694 "parser.yy" 8768 8799 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8769 8800 break; … … 8772 8803 8773 8804 /* Line 1806 of yacc.c */ 8774 #line 269 3"parser.yy"8805 #line 2699 "parser.yy" 8775 8806 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8776 8807 break; … … 8779 8810 8780 8811 /* Line 1806 of yacc.c */ 8781 #line 2 695"parser.yy"8812 #line 2701 "parser.yy" 8782 8813 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8783 8814 break; … … 8786 8817 8787 8818 /* Line 1806 of yacc.c */ 8788 #line 27 05"parser.yy"8819 #line 2711 "parser.yy" 8789 8820 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 8790 8821 break; … … 8793 8824 8794 8825 /* Line 1806 of yacc.c */ 8795 #line 27 15"parser.yy"8826 #line 2721 "parser.yy" 8796 8827 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8797 8828 break; … … 8800 8831 8801 8832 /* Line 1806 of yacc.c */ 8802 #line 27 17"parser.yy"8833 #line 2723 "parser.yy" 8803 8834 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8804 8835 break; … … 8807 8838 8808 8839 /* Line 1806 of yacc.c */ 8809 #line 27 19"parser.yy"8840 #line 2725 "parser.yy" 8810 8841 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8811 8842 break; … … 8814 8845 8815 8846 /* Line 1806 of yacc.c */ 8816 #line 272 1"parser.yy"8847 #line 2727 "parser.yy" 8817 8848 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8818 8849 break; … … 8821 8852 8822 8853 /* Line 1806 of yacc.c */ 8823 #line 272 3"parser.yy"8854 #line 2729 "parser.yy" 8824 8855 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8825 8856 break; … … 8828 8859 8829 8860 /* Line 1806 of yacc.c */ 8830 #line 27 25"parser.yy"8861 #line 2731 "parser.yy" 8831 8862 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8832 8863 break; … … 8835 8866 8836 8867 /* Line 1806 of yacc.c */ 8837 #line 273 2"parser.yy"8868 #line 2738 "parser.yy" 8838 8869 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8839 8870 break; 8840 8871 8841 8872 case 719: 8842 8843 /* Line 1806 of yacc.c */8844 #line 2734 "parser.yy"8845 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }8846 break;8847 8848 case 720:8849 8850 /* Line 1806 of yacc.c */8851 #line 2736 "parser.yy"8852 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }8853 break;8854 8855 case 721:8856 8857 /* Line 1806 of yacc.c */8858 #line 2738 "parser.yy"8859 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }8860 break;8861 8862 case 722:8863 8873 8864 8874 /* Line 1806 of yacc.c */ … … 8867 8877 break; 8868 8878 8879 case 720: 8880 8881 /* Line 1806 of yacc.c */ 8882 #line 2742 "parser.yy" 8883 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8884 break; 8885 8886 case 721: 8887 8888 /* Line 1806 of yacc.c */ 8889 #line 2744 "parser.yy" 8890 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 8891 break; 8892 8893 case 722: 8894 8895 /* Line 1806 of yacc.c */ 8896 #line 2746 "parser.yy" 8897 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8898 break; 8899 8869 8900 case 723: 8870 8901 8871 8902 /* Line 1806 of yacc.c */ 8872 #line 274 3"parser.yy"8903 #line 2749 "parser.yy" 8873 8904 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8874 8905 break; 8875 8906 8876 8907 case 724: 8877 8878 /* Line 1806 of yacc.c */8879 #line 2745 "parser.yy"8880 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }8881 break;8882 8883 case 725:8884 8885 /* Line 1806 of yacc.c */8886 #line 2747 "parser.yy"8887 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }8888 break;8889 8890 case 726:8891 8892 /* Line 1806 of yacc.c */8893 #line 2749 "parser.yy"8894 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }8895 break;8896 8897 case 727:8898 8908 8899 8909 /* Line 1806 of yacc.c */ … … 8902 8912 break; 8903 8913 8914 case 725: 8915 8916 /* Line 1806 of yacc.c */ 8917 #line 2753 "parser.yy" 8918 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8919 break; 8920 8921 case 726: 8922 8923 /* Line 1806 of yacc.c */ 8924 #line 2755 "parser.yy" 8925 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 8926 break; 8927 8928 case 727: 8929 8930 /* Line 1806 of yacc.c */ 8931 #line 2757 "parser.yy" 8932 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8933 break; 8934 8904 8935 case 728: 8905 8936 8906 8937 /* Line 1806 of yacc.c */ 8907 #line 27 56"parser.yy"8938 #line 2762 "parser.yy" 8908 8939 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 8909 8940 break; … … 8912 8943 8913 8944 /* Line 1806 of yacc.c */ 8914 #line 27 58"parser.yy"8945 #line 2764 "parser.yy" 8915 8946 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 8916 8947 break; … … 8919 8950 8920 8951 /* Line 1806 of yacc.c */ 8921 #line 276 3"parser.yy"8952 #line 2769 "parser.yy" 8922 8953 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); } 8923 8954 break; … … 8926 8957 8927 8958 /* Line 1806 of yacc.c */ 8928 #line 27 65"parser.yy"8959 #line 2771 "parser.yy" 8929 8960 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); } 8930 8961 break; … … 8933 8964 8934 8965 /* Line 1806 of yacc.c */ 8935 #line 279 2"parser.yy"8966 #line 2798 "parser.yy" 8936 8967 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 8937 8968 break; … … 8940 8971 8941 8972 /* Line 1806 of yacc.c */ 8942 #line 280 3"parser.yy"8973 #line 2809 "parser.yy" 8943 8974 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8944 8975 break; … … 8947 8978 8948 8979 /* Line 1806 of yacc.c */ 8949 #line 28 05"parser.yy"8980 #line 2811 "parser.yy" 8950 8981 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8951 8982 break; … … 8954 8985 8955 8986 /* Line 1806 of yacc.c */ 8956 #line 28 07"parser.yy"8987 #line 2813 "parser.yy" 8957 8988 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8958 8989 break; … … 8961 8992 8962 8993 /* Line 1806 of yacc.c */ 8963 #line 28 09"parser.yy"8994 #line 2815 "parser.yy" 8964 8995 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8965 8996 break; … … 8968 8999 8969 9000 /* Line 1806 of yacc.c */ 8970 #line 281 1"parser.yy"9001 #line 2817 "parser.yy" 8971 9002 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8972 9003 break; … … 8975 9006 8976 9007 /* Line 1806 of yacc.c */ 8977 #line 281 3"parser.yy"9008 #line 2819 "parser.yy" 8978 9009 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8979 9010 break; 8980 9011 8981 9012 case 743: 8982 8983 /* Line 1806 of yacc.c */8984 #line 2820 "parser.yy"8985 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }8986 break;8987 8988 case 744:8989 8990 /* Line 1806 of yacc.c */8991 #line 2822 "parser.yy"8992 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }8993 break;8994 8995 case 745:8996 8997 /* Line 1806 of yacc.c */8998 #line 2824 "parser.yy"8999 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }9000 break;9001 9002 case 746:9003 9013 9004 9014 /* Line 1806 of yacc.c */ … … 9007 9017 break; 9008 9018 9009 case 74 7:9019 case 744: 9010 9020 9011 9021 /* Line 1806 of yacc.c */ … … 9014 9024 break; 9015 9025 9016 case 74 8:9026 case 745: 9017 9027 9018 9028 /* Line 1806 of yacc.c */ … … 9021 9031 break; 9022 9032 9033 case 746: 9034 9035 /* Line 1806 of yacc.c */ 9036 #line 2832 "parser.yy" 9037 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9038 break; 9039 9040 case 747: 9041 9042 /* Line 1806 of yacc.c */ 9043 #line 2834 "parser.yy" 9044 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9045 break; 9046 9047 case 748: 9048 9049 /* Line 1806 of yacc.c */ 9050 #line 2836 "parser.yy" 9051 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9052 break; 9053 9023 9054 case 749: 9024 9055 9025 9056 /* Line 1806 of yacc.c */ 9026 #line 28 35"parser.yy"9057 #line 2841 "parser.yy" 9027 9058 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 9028 9059 break; … … 9031 9062 9032 9063 /* Line 1806 of yacc.c */ 9033 #line 284 2"parser.yy"9064 #line 2848 "parser.yy" 9034 9065 { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); } 9035 9066 break; … … 9038 9069 9039 9070 /* Line 1806 of yacc.c */ 9040 #line 28 44"parser.yy"9071 #line 2850 "parser.yy" 9041 9072 { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); } 9042 9073 break; … … 9045 9076 9046 9077 /* Line 1806 of yacc.c */ 9047 #line 28 68"parser.yy"9078 #line 2874 "parser.yy" 9048 9079 { (yyval.en) = 0; } 9049 9080 break; … … 9052 9083 9053 9084 /* Line 1806 of yacc.c */ 9054 #line 287 0"parser.yy"9085 #line 2876 "parser.yy" 9055 9086 { (yyval.en) = (yyvsp[(2) - (2)].en); } 9056 9087 break; … … 9059 9090 9060 9091 /* Line 1806 of yacc.c */ 9061 #line 90 62"Parser/parser.cc"9092 #line 9093 "Parser/parser.cc" 9062 9093 default: break; 9063 9094 } … … 9290 9321 9291 9322 /* Line 2067 of yacc.c */ 9292 #line 287 3"parser.yy"9323 #line 2879 "parser.yy" 9293 9324 9294 9325 // ----end of grammar---- -
src/Parser/parser.yy
r84118d8 rb726084 199 199 200 200 %type<decl> field_declaration field_declaration_list field_declarator field_declaring_list 201 %type<en> field field_list 202 %type<tok> field_name 201 %type<en> field field_list field_name fraction_constants 203 202 204 203 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 384 383 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 385 384 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 385 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 386 386 | postfix_expression REALFRACTIONconstant // CFA, tuple index 387 { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_REALFRACTIONconstant( *$2 ) ) ); } 387 388 | postfix_expression ARROW no_attr_identifier 388 389 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 389 390 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector 391 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 390 392 | postfix_expression ICR 391 393 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); } … … 421 423 field: // CFA, tuple field selector 422 424 field_name 423 { $$ = new ExpressionNode( build_varref( $1 ) ); }424 425 | REALDECIMALconstant field 425 { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1) ) ); }426 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); } 426 427 | REALDECIMALconstant '[' push field_list pop ']' 427 { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1) ) ); }428 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *$1 ) ), build_tuple( $4 ) ) ); } 428 429 | field_name '.' field 429 { $$ = new ExpressionNode( build_fieldSel( $ 3, build_varref( $1) ) ); }430 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 430 431 | field_name '.' '[' push field_list pop ']' 431 { $$ = new ExpressionNode( build_fieldSel( $ 5, build_varref( $1) ) ); }432 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 432 433 | field_name ARROW field 433 { $$ = new ExpressionNode( build_pfieldSel( $ 3, build_varref( $1) ) ); }434 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 434 435 | field_name ARROW '[' push field_list pop ']' 435 { $$ = new ExpressionNode( build_pfieldSel( $ 5, build_varref( $1) ) ); }436 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 436 437 ; 437 438 438 439 field_name: 439 440 INTEGERconstant fraction_constants 440 { $$ = $1; }441 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); } 441 442 | FLOATINGconstant fraction_constants 442 { $$ = $1; }443 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 443 444 | no_attr_identifier fraction_constants 444 { $$ = $1; }445 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); } 445 446 ; 446 447 447 448 fraction_constants: 448 449 // empty 450 { $$ = nullptr; } 449 451 | fraction_constants REALFRACTIONconstant 452 { 453 Expression * constant = build_field_name_REALFRACTIONconstant( *$2 ); 454 $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( $1, constant ) ) : new ExpressionNode( constant ); 455 } 450 456 ; 451 457 -
src/ResolvExpr/Alternative.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Alternative.cc -- 7 // Alternative.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 12 12 // Last Modified On : Sat May 16 23:54:23 2015 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #include "Alternative.h" … … 20 20 21 21 namespace ResolvExpr { 22 Alternative::Alternative() : expr( 0 ) {}22 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {} 23 23 24 24 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost ) … … 35 35 if ( &other == this ) return *this; 36 36 initialize( other, *this ); 37 return *this; 38 } 39 40 Alternative::Alternative( Alternative && other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( other.expr ), env( other.env ) { 41 other.expr = nullptr; 42 } 43 44 Alternative & Alternative::operator=( Alternative && other ) { 45 if ( &other == this ) return *this; 46 delete expr; 47 cost = other.cost; 48 cvtCost = other.cvtCost; 49 expr = other.expr; 50 env = other.env; 51 other.expr = nullptr; 37 52 return *this; 38 53 } … … 54 69 expr->print( os, indent ); 55 70 os << "(types:" << std::endl; 56 printAll( expr->get_results(), os, indent + 4 ); 57 os << ")" << std::endl; 71 os << std::string( indent+4, ' ' ); 72 expr->get_result()->print( os, indent + 4 ); 73 os << std::endl << ")" << std::endl; 58 74 } else { 59 75 os << "Null expression!" << std::endl; -
src/ResolvExpr/Alternative.h
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Alternative.h -- 7 // Alternative.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 12 12 // Last Modified On : Sat May 16 23:54:39 2015 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #ifndef ALTERNATIVE_H … … 32 32 Alternative( const Alternative &other ); 33 33 Alternative &operator=( const Alternative &other ); 34 Alternative( Alternative && other ); 35 Alternative &operator=( Alternative && other ); 34 36 ~Alternative(); 35 37 36 38 void initialize( const Alternative &src, Alternative &dest ); 37 39 38 40 void print( std::ostream &os, int indent = 0 ) const; 39 41 40 42 Cost cost; 41 43 Cost cvtCost; -
src/ResolvExpr/AlternativeFinder.cc
r84118d8 rb726084 38 38 #include "SynTree/TypeSubstitution.h" 39 39 #include "SymTab/Validate.h" 40 #include "Tuples/Tuple Assignment.h"41 #include "Tuples/ NameMatcher.h"40 #include "Tuples/Tuples.h" 41 #include "Tuples/Explode.h" 42 42 #include "Common/utility.h" 43 43 #include "InitTweak/InitTweak.h" 44 #include "InitTweak/GenInit.h" 44 45 #include "ResolveTypeof.h" 45 46 … … 64 65 } 65 66 67 Cost sumCost( const AltList &in ) { 68 Cost total; 69 for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) { 70 total += i->cost; 71 } 72 return total; 73 } 74 66 75 namespace { 67 76 void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) { … … 76 85 out.push_back( i->expr->clone() ); 77 86 } 78 }79 80 Cost sumCost( const AltList &in ) {81 Cost total;82 for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) {83 total += i->cost;84 }85 return total;86 87 } 87 88 … … 101 102 PruneStruct current( candidate ); 102 103 std::string mangleName; 103 for ( std::list< Type* >::const_iterator retType = candidate->expr->get_results().begin(); retType != candidate->expr->get_results().end(); ++retType ){104 Type * newType = (*retType)->clone();104 { 105 Type * newType = candidate->expr->get_result()->clone(); 105 106 candidate->env.apply( newType ); 106 mangleName += SymTab::Mangler::mangle( newType );107 mangleName = SymTab::Mangler::mangle( newType ); 107 108 delete newType; 108 109 } … … 133 134 if ( ! target->second.isAmbiguous ) { 134 135 Alternative &alt = *target->second.candidate; 135 for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) { 136 alt.env.applyFree( *result ); 137 } 136 alt.env.applyFree( alt.expr->get_result() ); 138 137 *out++ = alt; 139 138 } 140 139 } 141 142 }143 144 template< typename InputIterator, typename OutputIterator >145 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {146 AltList alternatives;147 148 // select the alternatives that have the minimum parameter cost149 Cost minCost = Cost::infinity;150 for ( AltList::iterator i = begin; i != end; ++i ) {151 if ( i->cost < minCost ) {152 minCost = i->cost;153 i->cost = i->cvtCost;154 alternatives.clear();155 alternatives.push_back( *i );156 } else if ( i->cost == minCost ) {157 i->cost = i->cvtCost;158 alternatives.push_back( *i );159 }160 }161 std::copy( alternatives.begin(), alternatives.end(), out );162 }163 164 template< typename InputIterator >165 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {166 while ( begin != end ) {167 result.simpleCombine( (*begin++).env );168 }169 140 } 170 141 171 142 void renameTypes( Expression *expr ) { 172 for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) { 173 (*i)->accept( global_renamer ); 174 } 143 expr->get_result()->accept( global_renamer ); 175 144 } 176 145 } … … 204 173 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 205 174 if ( adjust ) { 206 adjustExprType List( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );175 adjustExprType( i->expr->get_result(), i->env, indexer ); 207 176 } 208 177 } … … 240 209 } 241 210 211 // std::unordered_map< Expression *, UniqueExpr * > ; 212 242 213 template< typename StructOrUnionType > 243 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) { 214 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 215 // by this point, member must be a name expr 216 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); 217 const std::string & name = nameExpr->get_name(); 244 218 std::list< Declaration* > members; 245 219 aggInst->lookup( name, members ); … … 254 228 } 255 229 230 void AlternativeFinder::addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 231 if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) { 232 // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning 233 // xxx - this should be improved by memoizing the value of constant exprs 234 // during parsing and reusing that information here. 235 std::stringstream ss( constantExpr->get_constant()->get_value() ); 236 int val; 237 std::string tmp; 238 if ( ss >> val && ! (ss >> tmp) ) { 239 if ( val >= 0 && (unsigned int)val < tupleType->size() ) { 240 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 241 } // if 242 } // if 243 } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) { 244 // xxx - temporary hack until 0/1 are int constants 245 if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) { 246 std::stringstream ss( nameExpr->get_name() ); 247 int val; 248 ss >> val; 249 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 250 } 251 } // if 252 } 253 256 254 void AlternativeFinder::visit( ApplicationExpr *applicationExpr ) { 257 255 alternatives.push_back( Alternative( applicationExpr->clone(), env, Cost::zero ) ); … … 259 257 260 258 Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) { 261 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( alt.expr ); 262 assert( appExpr ); 263 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 264 assert( pointer ); 265 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 266 assert( function ); 259 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr ); 260 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 261 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 267 262 268 263 Cost convCost( 0, 0, 0 ); … … 270 265 std::list< DeclarationWithType* >::iterator formal = formals.begin(); 271 266 std::list< Expression* >& actuals = appExpr->get_args(); 267 268 std::list< Type * > formalTypes; 269 std::list< Type * >::iterator formalType = formalTypes.end(); 270 272 271 for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 272 273 273 PRINT( 274 274 std::cerr << "actual expression:" << std::endl; 275 275 (*actualExpr)->print( std::cerr, 8 ); 276 276 std::cerr << "--- results are" << std::endl; 277 printAll( (*actualExpr)->get_results(),std::cerr, 8 );277 (*actualExpr)->get_result()->print( std::cerr, 8 ); 278 278 ) 279 279 std::list< DeclarationWithType* >::iterator startFormal = formal; 280 280 Cost actualCost; 281 for ( std::list< Type* >::iterator actual = (*actualExpr)->get_results().begin(); actual != (*actualExpr)->get_results().end(); ++actual ) { 282 if ( formal == formals.end() ) { 283 if ( function->get_isVarArgs() ) { 284 convCost += Cost( 1, 0, 0 ); 285 break; 286 } else { 287 return Cost::infinity; 281 std::list< Type * > flatActualTypes; 282 flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) ); 283 for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) { 284 285 286 // tuple handling code 287 if ( formalType == formalTypes.end() ) { 288 // the type of the formal parameter may be a tuple type. To make this easier to work with, 289 // flatten the tuple type and traverse the resulting list of types, incrementing the formal 290 // iterator once its types have been extracted. Once a particular formal parameter's type has 291 // been exhausted load the next formal parameter's type. 292 if ( formal == formals.end() ) { 293 if ( function->get_isVarArgs() ) { 294 convCost += Cost( 1, 0, 0 ); 295 break; 296 } else { 297 return Cost::infinity; 298 } 288 299 } 300 formalTypes.clear(); 301 flatten( (*formal)->get_type(), back_inserter( formalTypes ) ); 302 formalType = formalTypes.begin(); 303 ++formal; 289 304 } 305 290 306 PRINT( 291 307 std::cerr << std::endl << "converting "; 292 (*actual )->print( std::cerr, 8 );308 (*actualType)->print( std::cerr, 8 ); 293 309 std::cerr << std::endl << " to "; 294 310 (*formal)->get_type()->print( std::cerr, 8 ); 295 311 ) 296 Cost newCost = conversionCost( *actual , (*formal)->get_type(), indexer, alt.env );312 Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env ); 297 313 PRINT( 298 314 std::cerr << std::endl << "cost is" << newCost << std::endl; … … 305 321 actualCost += newCost; 306 322 307 convCost += Cost( 0, polyCost( (*formal)->get_type(), alt.env, indexer ) + polyCost( *actual, alt.env, indexer ), 0 );308 309 formal ++;323 convCost += Cost( 0, polyCost( *formalType, alt.env, indexer ) + polyCost( *actualType, alt.env, indexer ), 0 ); 324 325 formalType++; 310 326 } 311 327 if ( actualCost != Cost( 0, 0, 0 ) ) { … … 356 372 /// Adds type variables to the open variable set and marks their assertions 357 373 void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) { 358 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {374 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 359 375 unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind(); 360 376 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) { … … 365 381 } 366 382 367 bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ) { 383 /// instantiate a single argument by matching actuals from [actualIt, actualEnd) against formalType, 384 /// producing expression(s) in out and their total cost in cost. 385 template< typename AltIterator, typename OutputIterator > 386 bool instantiateArgument( Type * formalType, Initializer * defaultValue, AltIterator & actualIt, AltIterator actualEnd, OpenVarSet & openVars, TypeEnvironment & resultEnv, AssertionSet & resultNeed, AssertionSet & resultHave, const SymTab::Indexer & indexer, Cost & cost, OutputIterator out ) { 387 if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) { 388 // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType 389 TupleExpr * tupleExpr = new TupleExpr(); 390 for ( Type * type : *tupleType ) { 391 if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs() ) ) ) { 392 delete tupleExpr; 393 return false; 394 } 395 } 396 tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) ); 397 *out++ = tupleExpr; 398 } else if ( actualIt != actualEnd ) { 399 // both actualType and formalType are atomic (non-tuple) types - if they unify 400 // then accept actual as an argument, otherwise return false (fail to instantiate argument) 401 Expression * actual = actualIt->expr; 402 Type * actualType = actual->get_result(); 403 PRINT( 404 std::cerr << "formal type is "; 405 formalType->print( std::cerr ); 406 std::cerr << std::endl << "actual type is "; 407 actualType->print( std::cerr ); 408 std::cerr << std::endl; 409 ) 410 if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 411 return false; 412 } 413 // move the expression from the alternative to the output iterator 414 *out++ = actual; 415 actualIt->expr = nullptr; 416 cost += actualIt->cost; 417 ++actualIt; 418 } else { 419 // End of actuals - Handle default values 420 if ( SingleInit *si = dynamic_cast<SingleInit *>( defaultValue )) { 421 // so far, only constant expressions are accepted as default values 422 if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) { 423 if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) { 424 if ( unify( formalType, cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 425 // xxx - Don't know if this is right 426 *out++ = cnstexpr->clone(); 427 return true; 428 } // if 429 } // if 430 } // if 431 } // if 432 return false; 433 } // if 434 return true; 435 } 436 437 bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ) { 368 438 simpleCombineEnvironments( actuals.begin(), actuals.end(), resultEnv ); 369 439 // make sure we don't widen any existing bindings … … 373 443 resultEnv.extractOpenVars( openVars ); 374 444 375 /* 376 Tuples::NameMatcher matcher( formals ); 377 try { 378 matcher.match( actuals ); 379 } catch ( Tuples::NoMatch &e ) { 380 std::cerr << "Alternative doesn't match: " << e.message << std::endl; 381 } 382 */ 383 std::list< DeclarationWithType* >::iterator formal = formals.begin(); 384 for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 385 for ( std::list< Type* >::iterator actual = actualExpr->expr->get_results().begin(); actual != actualExpr->expr->get_results().end(); ++actual ) { 386 if ( formal == formals.end() ) { 387 return isVarArgs; 388 } 389 PRINT( 390 std::cerr << "formal type is "; 391 (*formal)->get_type()->print( std::cerr ); 392 std::cerr << std::endl << "actual type is "; 393 (*actual)->print( std::cerr ); 394 std::cerr << std::endl; 395 ) 396 if ( ! unify( (*formal)->get_type(), *actual, resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 397 return false; 398 } 399 formal++; 400 } 401 } 402 // Handling of default values 403 while ( formal != formals.end() ) { 404 if ( ObjectDecl *od = dynamic_cast<ObjectDecl *>( *formal ) ) 405 if ( SingleInit *si = dynamic_cast<SingleInit *>( od->get_init() )) 406 // so far, only constant expressions are accepted as default values 407 if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) 408 if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) 409 if ( unify( (*formal)->get_type(), cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 410 // XXX Don't know if this is right 411 actuals.push_back( Alternative( cnstexpr->clone(), env, Cost::zero ) ); 412 formal++; 413 if ( formal == formals.end()) break; 414 } 415 return false; 445 // flatten actuals so that each actual has an atomic (non-tuple) type 446 AltList exploded; 447 Tuples::explode( actuals, indexer, back_inserter( exploded ) ); 448 449 AltList::iterator actualExpr = exploded.begin(); 450 AltList::iterator actualEnd = exploded.end(); 451 for ( DeclarationWithType * formal : formals ) { 452 // match flattened actuals with formal parameters - actuals will be grouped to match 453 // with formals as appropriate 454 Cost cost; 455 std::list< Expression * > newExprs; 456 ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal ); 457 if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) { 458 deleteAll( newExprs ); 459 return false; 460 } 461 // success - produce argument as a new alternative 462 assert( newExprs.size() == 1 ); 463 out.push_back( Alternative( newExprs.front(), resultEnv, cost ) ); 464 } 465 if ( actualExpr != actualEnd ) { 466 // there are still actuals remaining, but we've run out of formal parameters to match against 467 // this is okay only if the function is variadic 468 if ( ! isVarArgs ) { 469 return false; 470 } 471 out.splice( out.end(), exploded, actualExpr, actualEnd ); 416 472 } 417 473 return true; … … 500 556 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 501 557 Expression *varExpr = new VariableExpr( candDecl ); 502 deleteAll( varExpr->get_results() ); 503 varExpr->get_results().clear(); 504 varExpr->get_results().push_front( adjType->clone() ); 558 delete varExpr->get_result(); 559 varExpr->set_result( adjType->clone() ); 505 560 PRINT( 506 561 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; … … 545 600 546 601 template< typename OutputIterator > 547 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ) {602 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ) { 548 603 OpenVarSet openVars; 549 604 AssertionSet resultNeed, resultHave; 550 605 TypeEnvironment resultEnv; 551 606 makeUnifiableVars( funcType, openVars, resultNeed ); 552 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave ) ) { 607 AltList instantiatedActuals; // filled by instantiate function 608 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) { 553 609 ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() ); 554 Alternative newAlt( appExpr, resultEnv, sumCost( actualAlt) );555 makeExprList( actualAlt, appExpr->get_args() );610 Alternative newAlt( appExpr, resultEnv, sumCost( instantiatedActuals ) ); 611 makeExprList( instantiatedActuals, appExpr->get_args() ); 556 612 PRINT( 557 613 std::cerr << "need assertions:" << std::endl; … … 574 630 PointerType pt( Type::Qualifiers(), v.clone() ); 575 631 UntypedExpr *vexpr = untypedExpr->clone(); 576 vexpr-> get_results().push_front( pt.clone() );632 vexpr->set_result( pt.clone() ); 577 633 alternatives.push_back( Alternative( vexpr, env, Cost()) ); 578 634 return; … … 587 643 combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) ); 588 644 589 Tuples::TupleAssignSpotter tassign( this ); 590 if ( tassign.isTupleAssignment( untypedExpr, possibilities ) ) { 591 // take care of possible tuple assignments, or discard expression 592 return; 593 } // else ... 645 // take care of possible tuple assignments 646 // if not tuple assignment, assignment is taken care of as a normal function call 647 Tuples::handleTupleAssignment( *this, untypedExpr, possibilities ); 594 648 595 649 AltList candidates; … … 604 658 // check if the type is pointer to function 605 659 PointerType *pointer; 606 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {660 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) { 607 661 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 608 662 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 640 694 // check if the type is pointer to function 641 695 PointerType *pointer; 642 if ( funcOp->expr->get_results().size() == 1 643 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 696 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) { 644 697 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 645 698 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 665 718 666 719 PRINT( 667 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( withFunc->expr ); 668 assert( appExpr ); 669 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 670 assert( pointer ); 671 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 672 assert( function ); 720 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr ); 721 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 722 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 673 723 std::cerr << "Case +++++++++++++" << std::endl; 674 724 std::cerr << "formals are:" << std::endl; … … 692 742 693 743 bool isLvalue( Expression *expr ) { 694 for ( std::list< Type* >::const_iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) { 695 if ( !(*i)->get_isLvalue() ) return false; 696 } // for 697 return true; 744 // xxx - recurse into tuples? 745 return expr->has_result() && expr->get_result()->get_isLvalue(); 698 746 } 699 747 … … 709 757 710 758 void AlternativeFinder::visit( CastExpr *castExpr ) { 711 for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) { 712 *i = resolveTypeof( *i, indexer ); 713 SymTab::validateType( *i, &indexer ); 714 adjustExprType( *i, env, indexer ); 715 } // for 759 Type *& toType = castExpr->get_result(); 760 toType = resolveTypeof( toType, indexer ); 761 SymTab::validateType( toType, &indexer ); 762 adjustExprType( toType, env, indexer ); 716 763 717 764 AlternativeFinder finder( indexer, env ); … … 727 774 // that are cast directly. The candidate is invalid if it has fewer results than there are types to cast 728 775 // to. 729 int discardedValues = (*i).expr->get_result s().size() - castExpr->get_results().size();776 int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size(); 730 777 if ( discardedValues < 0 ) continue; 731 std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin(); 732 std::advance( candidate_end, castExpr->get_results().size() ); 778 // xxx - may need to go into tuple types and extract relavent types and use unifyList 733 779 // unification run for side-effects 734 unifyList( castExpr->get_results().begin(), castExpr->get_results().end(), 735 (*i).expr->get_results().begin(), candidate_end, 736 i->env, needAssertions, haveAssertions, openVars, indexer ); 737 Cost thisCost = castCostList( (*i).expr->get_results().begin(), candidate_end, 738 castExpr->get_results().begin(), castExpr->get_results().end(), 739 indexer, i->env ); 780 unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer ); 781 Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env ); 740 782 if ( thisCost != Cost::infinity ) { 741 783 // count one safe conversion for each value that is thrown away … … 760 802 761 803 for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) { 762 if ( agg->expr->get_results().size() == 1) {763 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) {764 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );765 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) {766 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() );767 } // if804 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) { 805 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 806 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) { 807 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 808 } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( agg->expr->get_result() ) ) { 809 addTupleMembers( tupleType, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 768 810 } // if 769 811 } // for … … 791 833 renameTypes( alternatives.back().expr ); 792 834 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) { 793 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 835 NameExpr nameExpr( "" ); 836 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 794 837 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) { 795 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 838 NameExpr nameExpr( "" ); 839 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 796 840 } // if 797 841 } // for … … 894 938 alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) ); 895 939 for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) { 896 alternatives.back().expr-> get_results().push_back( (*i)->get_type()->clone() );940 alternatives.back().expr->set_result( (*i)->get_type()->clone() ); 897 941 } // for 898 942 } // if … … 917 961 finder.find( attrExpr->get_expr() ); 918 962 for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) { 919 if ( choice->expr->get_result s().size() == 1 ) {920 resolveAttr(*i, function, choice->expr->get_result s().front(), choice->env );963 if ( choice->expr->get_result()->size() == 1 ) { 964 resolveAttr(*i, function, choice->expr->get_result(), choice->env ); 921 965 } // fi 922 966 } // for … … 960 1004 AssertionSet needAssertions, haveAssertions; 961 1005 Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost ); 962 std::list< Type* > commonTypes;963 if ( unify List( second->expr->get_results().begin(), second->expr->get_results().end(), third->expr->get_results().begin(), third->expr->get_results().end(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonTypes) ) {1006 Type* commonType; 1007 if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 964 1008 ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() ); 965 std::list< Type* >::const_iterator original = second->expr->get_results().begin(); 966 std::list< Type* >::const_iterator commonType = commonTypes.begin(); 967 for ( ; original != second->expr->get_results().end() && commonType != commonTypes.end(); ++original, ++commonType ) { 968 if ( *commonType ) { 969 newExpr->get_results().push_back( *commonType ); 970 } else { 971 newExpr->get_results().push_back( (*original)->clone() ); 972 } // if 973 } // for 1009 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() ); 974 1010 newAlt.expr = newExpr; 975 1011 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 999 1035 TupleExpr *newExpr = new TupleExpr; 1000 1036 makeExprList( *i, newExpr->get_exprs() ); 1001 for ( std::list< Expression* >::const_iterator resultExpr = newExpr->get_exprs().begin(); resultExpr != newExpr->get_exprs().end(); ++resultExpr ) { 1002 for ( std::list< Type* >::const_iterator resultType = (*resultExpr)->get_results().begin(); resultType != (*resultExpr)->get_results().end(); ++resultType ) { 1003 newExpr->get_results().push_back( (*resultType)->clone() ); 1004 } // for 1005 } // for 1037 newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) ); 1006 1038 1007 1039 TypeEnvironment compositeEnv; … … 1024 1056 } 1025 1057 } 1058 1059 void AlternativeFinder::visit( TupleIndexExpr *tupleExpr ) { 1060 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) ); 1061 } 1062 1063 void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) { 1064 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) ); 1065 } 1066 1067 void AlternativeFinder::visit( UniqueExpr *unqExpr ) { 1068 AlternativeFinder finder( indexer, env ); 1069 finder.findWithAdjustment( unqExpr->get_expr() ); 1070 for ( Alternative & alt : finder.alternatives ) { 1071 // ensure that the id is passed on to the UniqueExpr alternative so that the expressions are "linked" 1072 UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr->clone(), unqExpr->get_id() ); 1073 alternatives.push_back( Alternative( newUnqExpr, alt.env, alt.cost ) ); 1074 } 1075 } 1076 1026 1077 } // namespace ResolvExpr 1027 1078 -
src/ResolvExpr/AlternativeFinder.h
r84118d8 rb726084 67 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 68 virtual void visit( ConstructorExpr * ctorExpr ); 69 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 69 virtual void visit( TupleIndexExpr *tupleExpr ); 70 virtual void visit( TupleAssignExpr *tupleExpr ); 71 virtual void visit( UniqueExpr *unqExpr ); 72 /// Runs a new alternative finder on each element in [begin, end) 73 /// and writes each alternative finder to out. 70 74 template< typename InputIterator, typename OutputIterator > 71 75 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 72 76 73 private:74 77 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 75 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ); 78 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 79 /// Adds alternatives for member expressions where the left side has tuple type 80 void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 76 81 /// Adds alternatives for offsetof expressions, given the base type and name of the member 77 82 template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name ); 78 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave);83 bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ); 79 84 template< typename OutputIterator > 80 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );85 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ); 81 86 template< typename OutputIterator > 82 87 void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ); … … 89 94 90 95 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 96 97 template< typename InputIterator, typename OutputIterator > 98 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 99 AltList alternatives; 100 101 // select the alternatives that have the minimum parameter cost 102 Cost minCost = Cost::infinity; 103 for ( InputIterator i = begin; i != end; ++i ) { 104 if ( i->cost < minCost ) { 105 minCost = i->cost; 106 i->cost = i->cvtCost; 107 alternatives.clear(); 108 alternatives.push_back( *i ); 109 } else if ( i->cost == minCost ) { 110 i->cost = i->cvtCost; 111 alternatives.push_back( *i ); 112 } 113 } 114 std::copy( alternatives.begin(), alternatives.end(), out ); 115 } 116 117 Cost sumCost( const AltList &in ); 118 119 template< typename InputIterator > 120 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { 121 while ( begin != end ) { 122 result.simpleCombine( (*begin++).env ); 123 } 124 } 91 125 } // namespace ResolvExpr 92 126 -
src/ResolvExpr/AlternativePrinter.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AlternativePrinter.cc -- 7 // AlternativePrinter.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 33 33 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) { 34 34 os << "Alternative " << count++ << " ==============" << std::endl; 35 printAll( i->expr->get_results(),os );35 i->expr->get_result()->print( os ); 36 36 // i->print( os ); 37 37 os << std::endl; -
src/ResolvExpr/ConversionCost.cc
r84118d8 rb726084 240 240 std::list< Type* >::const_iterator srcIt = tupleType->get_types().begin(); 241 241 std::list< Type* >::const_iterator destIt = destAsTuple->get_types().begin(); 242 while ( srcIt != tupleType->get_types().end() ) {242 while ( srcIt != tupleType->get_types().end() && destIt != destAsTuple->get_types().end() ) { 243 243 Cost newCost = conversionCost( *srcIt++, *destIt++, indexer, env ); 244 244 if ( newCost == Cost::infinity ) { -
src/ResolvExpr/FindOpenVars.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FindOpenVars.cc -- 7 // FindOpenVars.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 47 47 void FindOpenVars::common_action( Type *type ) { 48 48 if ( nextIsOpen ) { 49 for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {49 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 50 50 openVars[ (*i)->get_name() ] = (*i)->get_kind(); 51 51 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { … … 56 56 } 57 57 } else { 58 for ( std::list< TypeDecl* >::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {58 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 59 59 closedVars[ (*i)->get_name() ] = (*i)->get_kind(); 60 60 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { -
src/ResolvExpr/RenameVars.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // RenameVars.cc -- 7 // RenameVars.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 125 125 mapStack.push_front( mapStack.front() ); 126 126 // renames all "forall" type names to `_${level}_${name}' 127 for ( std::list< TypeDecl* >::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {127 for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 128 128 std::ostringstream output; 129 129 output << "_" << level << "_" << (*i)->get_name(); -
src/ResolvExpr/ResolveTypeof.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ResolveTypeof.cc -- 7 // ResolveTypeof.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 58 58 if ( typeofType->get_expr() ) { 59 59 Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer ); 60 assert( newExpr->get_results().size() > 0 ); 61 Type *newType; 62 if ( newExpr->get_results().size() > 1 ) { 63 TupleType *tupleType = new TupleType( Type::Qualifiers() ); 64 cloneAll( newExpr->get_results(), tupleType->get_types() ); 65 newType = tupleType; 66 } else { 67 newType = newExpr->get_results().front()->clone(); 68 } // if 60 assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() ); 61 Type *newType = newExpr->get_result(); 69 62 delete typeofType; 70 63 return newType; -
src/ResolvExpr/Resolver.cc
r84118d8 rb726084 19 19 #include "RenameVars.h" 20 20 #include "ResolveTypeof.h" 21 #include "typeops.h" 21 22 #include "SynTree/Statement.h" 22 23 #include "SynTree/Type.h" … … 68 69 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 69 70 void fallbackInit( ConstructorInit * ctorInit ); 70 std::list< Type * > functionReturn; 71 Type *initContext; 71 72 Type * functionReturn = nullptr; 73 Type *initContext = nullptr; 74 Type *switchType = nullptr; 72 75 bool inEnumDecl = false; 73 76 }; … … 157 160 const TypeEnvironment *newEnv = 0; 158 161 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) { 159 if ( i->expr->get_result s().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {162 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) { 160 163 if ( newExpr ) { 161 164 throw SemanticError( "Too many interpretations for case control expression", untyped ); … … 234 237 Type *new_type = resolveTypeof( functionDecl->get_type(), *this ); 235 238 functionDecl->set_type( new_type ); 236 std::list< Type * > oldFunctionReturn = functionReturn; 237 functionReturn.clear(); 238 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) { 239 functionReturn.push_back( (*i)->get_type() ); 240 } // for 239 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 240 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 241 241 SymTab::Indexer::visit( functionDecl ); 242 functionReturn = oldFunctionReturn;243 242 } 244 243 … … 338 337 void Resolver::visit( ReturnStmt *returnStmt ) { 339 338 if ( returnStmt->get_expr() ) { 340 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() ); 341 cloneAll( functionReturn, castExpr->get_results() ); 339 CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() ); 342 340 Expression *newExpr = findSingleExpression( castExpr, *this ); 343 341 delete castExpr; … … 384 382 if ( isCharType( at->get_base() ) ) { 385 383 // check if the resolved type is char * 386 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result s().front() ) ) {384 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) { 387 385 if ( isCharType( pt->get_base() ) ) { 388 386 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; … … 446 444 (*iter)->accept( *this ); 447 445 } // for 446 } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) { 447 for ( Type * t : *tt ) { 448 if ( iter == end ) break; 449 initContext = t; 450 (*iter++)->accept( *this ); 451 } 448 452 } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) { 449 453 resolveAggrInit( st->get_baseStruct(), iter, end ); -
src/ResolvExpr/TypeEnvironment.cc
r84118d8 rb726084 158 158 } 159 159 160 void TypeEnvironment::add( const std::list< TypeDecl* >&tyDecls ) {161 for ( std::list< TypeDecl* >::const_iterator i = tyDecls.begin(); i != tyDecls.end(); ++i ) {160 void TypeEnvironment::add( const Type::ForallList &tyDecls ) { 161 for ( Type::ForallList::const_iterator i = tyDecls.begin(); i != tyDecls.end(); ++i ) { 162 162 EqvClass newClass; 163 163 newClass.vars.insert( (*i)->get_name() ); -
src/ResolvExpr/TypeEnvironment.h
r84118d8 rb726084 55 55 bool lookup( const std::string &var, EqvClass &eqvClass ) const; 56 56 void add( const EqvClass &eqvClass ); 57 void add( const std::list< TypeDecl* >&tyDecls );57 void add( const Type::ForallList &tyDecls ); 58 58 template< typename SynTreeClass > int apply( SynTreeClass *&type ) const; 59 59 template< typename SynTreeClass > int applyFree( SynTreeClass *&type ) const; -
src/ResolvExpr/Unify.cc
r84118d8 rb726084 597 597 } 598 598 599 // xxx - compute once and store in the FunctionType? 600 Type * extractResultType( FunctionType * function ) { 601 if ( function->get_returnVals().size() == 0 ) { 602 return new VoidType( Type::Qualifiers() ); 603 } else if ( function->get_returnVals().size() == 1 ) { 604 return function->get_returnVals().front()->get_type()->clone(); 605 } else { 606 TupleType * tupleType = new TupleType( Type::Qualifiers() ); 607 for ( DeclarationWithType * decl : function->get_returnVals() ) { 608 tupleType->get_types().push_back( decl->get_type()->clone() ); 609 } // for 610 return tupleType; 611 } 612 } 599 613 } // namespace ResolvExpr 600 614 -
src/ResolvExpr/typeops.h
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // typeops.h -- 7 // typeops.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 30 30 typedef typename InputIterator::value_type SetType; 31 31 typedef typename std::list< typename SetType::value_type > ListType; 32 32 33 33 if ( begin == end ) { 34 34 *out++ = ListType(); 35 35 return; 36 36 } // if 37 37 38 38 InputIterator current = begin; 39 39 begin++; … … 41 41 std::list< ListType > recursiveResult; 42 42 combos( begin, end, back_inserter( recursiveResult ) ); 43 43 44 44 for ( typename std::list< ListType >::const_iterator i = recursiveResult.begin(); i != recursiveResult.end(); ++i ) { 45 45 for ( typename ListType::const_iterator j = current->begin(); j != current->end(); ++j ) { … … 52 52 } // for 53 53 } 54 54 55 55 // in AdjustExprType.cc 56 56 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function … … 144 144 } 145 145 146 /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value. 147 Type * extractResultType( FunctionType * functionType ); 148 146 149 // in CommonType.cc 147 150 Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars ); … … 152 155 // in Occurs.cc 153 156 bool occurs( Type *type, std::string varName, const TypeEnvironment &env ); 157 158 // flatten tuple type into list of types 159 template< typename OutputIterator > 160 void flatten( Type * type, OutputIterator out ) { 161 if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) { 162 for ( Type * t : tupleType->get_types() ) { 163 flatten( t, out ); 164 } 165 } else { 166 *out++ = type; 167 } 168 } 154 169 } // namespace ResolvExpr 155 170 -
src/SymTab/Autogen.cc
r84118d8 rb726084 116 116 // This happens before function pointer type conversion, so need to do it manually here 117 117 VariableExpr * assignVarExpr = new VariableExpr( assignDecl ); 118 Type * & assignVarExprType = assignVarExpr->get_results().front();118 Type * assignVarExprType = assignVarExpr->get_result(); 119 119 assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType ); 120 assignVarExpr->set_result( assignVarExprType ); 120 121 ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr ); 121 122 assignExpr->get_args().push_back( new VariableExpr( dstParam ) ); -
src/SymTab/Indexer.cc
r84118d8 rb726084 40 40 41 41 namespace SymTab { 42 template< typename Container, typename VisitorType >43 inline void accept AllNewScope( Container &container, VisitorType &visitor ) {42 template< typename TreeType, typename VisitorType > 43 inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) { 44 44 visitor.enterScope(); 45 acceptAll( container, visitor );45 maybeAccept( tree, visitor ); 46 46 visitor.leaveScope(); 47 47 } … … 143 143 for ( DeclarationWithType * decl : copy ) { 144 144 if ( FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl ) ) { 145 std::list< DeclarationWithType * > params = function->get_functionType()->get_parameters();145 std::list< DeclarationWithType * > & params = function->get_functionType()->get_parameters(); 146 146 assert( ! params.empty() ); 147 147 // use base type of pointer, so that qualifiers on the pointer type aren't considered. … … 337 337 338 338 void Indexer::visit( ApplicationExpr *applicationExpr ) { 339 accept AllNewScope( applicationExpr->get_results(), *this );339 acceptNewScope( applicationExpr->get_result(), *this ); 340 340 maybeAccept( applicationExpr->get_function(), *this ); 341 341 acceptAll( applicationExpr->get_args(), *this ); … … 343 343 344 344 void Indexer::visit( UntypedExpr *untypedExpr ) { 345 accept AllNewScope( untypedExpr->get_results(), *this );345 acceptNewScope( untypedExpr->get_result(), *this ); 346 346 acceptAll( untypedExpr->get_args(), *this ); 347 347 } 348 348 349 349 void Indexer::visit( NameExpr *nameExpr ) { 350 accept AllNewScope( nameExpr->get_results(), *this );350 acceptNewScope( nameExpr->get_result(), *this ); 351 351 } 352 352 353 353 void Indexer::visit( AddressExpr *addressExpr ) { 354 accept AllNewScope( addressExpr->get_results(), *this );354 acceptNewScope( addressExpr->get_result(), *this ); 355 355 maybeAccept( addressExpr->get_arg(), *this ); 356 356 } 357 357 358 358 void Indexer::visit( LabelAddressExpr *labAddressExpr ) { 359 accept AllNewScope( labAddressExpr->get_results(), *this );359 acceptNewScope( labAddressExpr->get_result(), *this ); 360 360 maybeAccept( labAddressExpr->get_arg(), *this ); 361 361 } 362 362 363 363 void Indexer::visit( CastExpr *castExpr ) { 364 accept AllNewScope( castExpr->get_results(), *this );364 acceptNewScope( castExpr->get_result(), *this ); 365 365 maybeAccept( castExpr->get_arg(), *this ); 366 366 } 367 367 368 368 void Indexer::visit( UntypedMemberExpr *memberExpr ) { 369 accept AllNewScope( memberExpr->get_results(), *this );369 acceptNewScope( memberExpr->get_result(), *this ); 370 370 maybeAccept( memberExpr->get_aggregate(), *this ); 371 371 } 372 372 373 373 void Indexer::visit( MemberExpr *memberExpr ) { 374 accept AllNewScope( memberExpr->get_results(), *this );374 acceptNewScope( memberExpr->get_result(), *this ); 375 375 maybeAccept( memberExpr->get_aggregate(), *this ); 376 376 } 377 377 378 378 void Indexer::visit( VariableExpr *variableExpr ) { 379 accept AllNewScope( variableExpr->get_results(), *this );379 acceptNewScope( variableExpr->get_result(), *this ); 380 380 } 381 381 382 382 void Indexer::visit( ConstantExpr *constantExpr ) { 383 accept AllNewScope( constantExpr->get_results(), *this );383 acceptNewScope( constantExpr->get_result(), *this ); 384 384 maybeAccept( constantExpr->get_constant(), *this ); 385 385 } 386 386 387 387 void Indexer::visit( SizeofExpr *sizeofExpr ) { 388 accept AllNewScope( sizeofExpr->get_results(), *this );388 acceptNewScope( sizeofExpr->get_result(), *this ); 389 389 if ( sizeofExpr->get_isType() ) { 390 390 maybeAccept( sizeofExpr->get_type(), *this ); … … 395 395 396 396 void Indexer::visit( AlignofExpr *alignofExpr ) { 397 accept AllNewScope( alignofExpr->get_results(), *this );397 acceptNewScope( alignofExpr->get_result(), *this ); 398 398 if ( alignofExpr->get_isType() ) { 399 399 maybeAccept( alignofExpr->get_type(), *this ); … … 404 404 405 405 void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) { 406 accept AllNewScope( offsetofExpr->get_results(), *this );406 acceptNewScope( offsetofExpr->get_result(), *this ); 407 407 maybeAccept( offsetofExpr->get_type(), *this ); 408 408 } 409 409 410 410 void Indexer::visit( OffsetofExpr *offsetofExpr ) { 411 accept AllNewScope( offsetofExpr->get_results(), *this );411 acceptNewScope( offsetofExpr->get_result(), *this ); 412 412 maybeAccept( offsetofExpr->get_type(), *this ); 413 413 maybeAccept( offsetofExpr->get_member(), *this ); … … 415 415 416 416 void Indexer::visit( OffsetPackExpr *offsetPackExpr ) { 417 accept AllNewScope( offsetPackExpr->get_results(), *this );417 acceptNewScope( offsetPackExpr->get_result(), *this ); 418 418 maybeAccept( offsetPackExpr->get_type(), *this ); 419 419 } 420 420 421 421 void Indexer::visit( AttrExpr *attrExpr ) { 422 accept AllNewScope( attrExpr->get_results(), *this );422 acceptNewScope( attrExpr->get_result(), *this ); 423 423 if ( attrExpr->get_isType() ) { 424 424 maybeAccept( attrExpr->get_type(), *this ); … … 429 429 430 430 void Indexer::visit( LogicalExpr *logicalExpr ) { 431 accept AllNewScope( logicalExpr->get_results(), *this );431 acceptNewScope( logicalExpr->get_result(), *this ); 432 432 maybeAccept( logicalExpr->get_arg1(), *this ); 433 433 maybeAccept( logicalExpr->get_arg2(), *this ); … … 435 435 436 436 void Indexer::visit( ConditionalExpr *conditionalExpr ) { 437 accept AllNewScope( conditionalExpr->get_results(), *this );437 acceptNewScope( conditionalExpr->get_result(), *this ); 438 438 maybeAccept( conditionalExpr->get_arg1(), *this ); 439 439 maybeAccept( conditionalExpr->get_arg2(), *this ); … … 442 442 443 443 void Indexer::visit( CommaExpr *commaExpr ) { 444 accept AllNewScope( commaExpr->get_results(), *this );444 acceptNewScope( commaExpr->get_result(), *this ); 445 445 maybeAccept( commaExpr->get_arg1(), *this ); 446 446 maybeAccept( commaExpr->get_arg2(), *this ); … … 448 448 449 449 void Indexer::visit( TupleExpr *tupleExpr ) { 450 accept AllNewScope( tupleExpr->get_results(), *this );450 acceptNewScope( tupleExpr->get_result(), *this ); 451 451 acceptAll( tupleExpr->get_exprs(), *this ); 452 452 } 453 453 454 void Indexer::visit( SolvedTupleExpr *tupleExpr ) { 455 acceptAllNewScope( tupleExpr->get_results(), *this ); 456 acceptAll( tupleExpr->get_exprs(), *this ); 454 void Indexer::visit( TupleAssignExpr *tupleExpr ) { 455 acceptNewScope( tupleExpr->get_result(), *this ); 456 enterScope(); 457 acceptAll( tupleExpr->get_tempDecls(), *this ); 458 acceptAll( tupleExpr->get_assigns(), *this ); 459 leaveScope(); 457 460 } 458 461 459 462 void Indexer::visit( TypeExpr *typeExpr ) { 460 accept AllNewScope( typeExpr->get_results(), *this );463 acceptNewScope( typeExpr->get_result(), *this ); 461 464 maybeAccept( typeExpr->get_type(), *this ); 462 465 } … … 469 472 470 473 void Indexer::visit( UntypedValofExpr *valofExpr ) { 471 accept AllNewScope( valofExpr->get_results(), *this );474 acceptNewScope( valofExpr->get_result(), *this ); 472 475 maybeAccept( valofExpr->get_body(), *this ); 473 476 } -
src/SymTab/Indexer.h
r84118d8 rb726084 64 64 virtual void visit( ConditionalExpr *conditionalExpr ); 65 65 virtual void visit( CommaExpr *commaExpr ); 66 virtual void visit( TupleExpr *tupleExpr );67 virtual void visit( SolvedTupleExpr *tupleExpr );68 66 virtual void visit( TypeExpr *typeExpr ); 69 67 virtual void visit( AsmExpr *asmExpr ); 70 68 virtual void visit( UntypedValofExpr *valofExpr ); 69 virtual void visit( TupleExpr *tupleExpr ); 70 virtual void visit( TupleAssignExpr *tupleExpr ); 71 71 72 72 virtual void visit( TraitInstType *contextInst ); -
src/SymTab/Mangler.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Mangler.cc -- 7 // Mangler.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 35 35 return mangler.get_mangleName(); 36 36 } 37 37 38 38 Mangler::Mangler( bool mangleOverridable, bool typeMode ) 39 39 : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ), typeMode( typeMode ) {} 40 40 41 41 Mangler::Mangler( const Mangler &rhs ) : mangleName() { 42 42 varNums = rhs.varNums; … … 115 115 "Ir", // LongDoubleImaginary 116 116 }; 117 117 118 118 printQualifiers( basicType ); 119 119 mangleName << btLetter[ basicType->get_kind() ]; … … 253 253 // skip if not including qualifiers 254 254 if ( typeMode ) return; 255 255 256 256 if ( ! type->get_forall().empty() ) { 257 257 std::list< std::string > assertionNames; 258 258 int tcount = 0, dcount = 0, fcount = 0; 259 259 mangleName << "A"; 260 for ( std::list< TypeDecl* >::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {260 for ( Type::ForallList::iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 261 261 switch ( (*i)->get_kind() ) { 262 262 case TypeDecl::Any: -
src/SymTab/Validate.cc
r84118d8 rb726084 23 23 // - All enumeration constants have type EnumInstType. 24 24 // 25 // - The type "void" never occurs in lists of function parameter or return types ; neither do tuple types. A function26 // taking no arguments has no argument types , and tuples are flattened.25 // - The type "void" never occurs in lists of function parameter or return types. A function 26 // taking no arguments has no argument types. 27 27 // 28 28 // - No context instances exist; they are all replaced by the set of declarations signified by the context, instantiated … … 243 243 return dynamic_cast< StructDecl * >( decl ) || dynamic_cast< UnionDecl * >( decl ); 244 244 } 245 245 // xxx - shouldn't this be declsToAddBefore? 246 246 template< typename AggDecl > 247 247 void HoistStruct::handleAggregate( AggDecl *aggregateDecl ) { … … 431 431 /// Fix up assertions 432 432 void forallFixer( Type *func ) { 433 for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {433 for ( Type::ForallList::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) { 434 434 std::list< DeclarationWithType * > toBeDone, nextRound; 435 435 toBeDone.splice( toBeDone.end(), (*type )->get_assertions() ); -
src/SynTree/AddressExpr.cc
r84118d8 rb726084 19 19 20 20 AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) { 21 for ( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i) {22 get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) );23 } // for21 if ( arg->has_result() ) { 22 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) ); 23 } 24 24 } 25 25 … … 35 35 if ( arg ) { 36 36 os << std::string( indent+2, ' ' ); 37 arg->print( os, indent+2 );37 arg->print( os, indent+2 ); 38 38 } // if 39 39 } -
src/SynTree/ApplicationExpr.cc
r84118d8 rb726084 21 21 #include "TypeSubstitution.h" 22 22 #include "Common/utility.h" 23 23 #include "ResolvExpr/typeops.h" 24 24 25 25 ParamEntry::ParamEntry( const ParamEntry &other ) : … … 43 43 44 44 ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) { 45 PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() ); 46 assert( pointer ); 47 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 48 assert( function ); 45 PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() ); 46 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 49 47 50 for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) {51 get_results().push_back( (*i)->get_type()->clone() ); 52 } // for48 set_result( ResolvExpr::extractResultType( function ) ); 49 50 assert( has_result() ); 53 51 } 54 52 -
src/SynTree/CommaExpr.cc
r84118d8 rb726084 23 23 // to false on all result types. Actually doing this causes some strange things 24 24 // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into. 25 cloneAll( arg2->get_results(), get_results() ); 26 // for ( Type *& type : get_results() ) { 27 // type->set_isLvalue( false ); 28 // } 25 set_result( maybeClone( arg2->get_result() ) ); 26 // get_type->set_isLvalue( false ); 29 27 } 30 28 -
src/SynTree/CompoundStmt.cc
r84118d8 rb726084 20 20 #include "Expression.h" 21 21 #include "Declaration.h" 22 #include "SynTree/VarExprReplacer.h" 22 23 23 24 using std::string; 24 25 using std::endl; 25 26 class VarExprReplacer : public Visitor {27 public:28 typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;29 private:30 const DeclMap & declMap;31 public:32 VarExprReplacer( const DeclMap & declMap ) : declMap( declMap ) {}33 34 // replace variable with new node from decl map35 virtual void visit( VariableExpr * varExpr ) {36 if ( declMap.count( varExpr->get_var() ) ) {37 varExpr->set_var( declMap.at( varExpr->get_var() ) );38 }39 }40 };41 42 26 43 27 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) { … … 47 31 cloneAll( other.kids, kids ); 48 32 49 // when cloning a compound statement, we may end up cloning declarations which 50 // are referred to by VariableExprs throughout the block. Cloning a VariableExpr 51 // does a shallow copy, so the VariableExpr will end up pointing to the original 52 // declaration. If the original declaration is deleted, e.g. because the original 53 // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case, 54 // find all DeclarationWithType nodes (since a VariableExpr must point to a 55 // DeclarationWithType) in the original CompoundStmt and map them to the cloned 56 // node in the new CompoundStmt ('this'), then replace the Declarations referred to 57 // by each VariableExpr according to the constructed map. Note that only the declarations 58 // in the current level are collected into the map, because child CompoundStmts will 59 // recursively execute this routine. There may be more efficient ways of doing 60 // this. 61 VarExprReplacer::DeclMap declMap; 62 std::list< Statement * >::const_iterator origit = other.kids.begin(); 63 for ( Statement * s : kids ) { 64 assert( origit != other.kids.end() ); 65 if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) { 66 DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( *origit ); 67 assert( origDeclStmt ); 68 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) { 69 DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ); 70 assert( origdwt ); 71 declMap[ origdwt ] = dwt; 72 } 73 } 74 } 75 if ( ! declMap.empty() ) { 76 VarExprReplacer replacer( declMap ); 77 accept( replacer ); 78 } 33 // when cloning a compound statement, we may end up cloning declarations which 34 // are referred to by VariableExprs throughout the block. Cloning a VariableExpr 35 // does a shallow copy, so the VariableExpr will end up pointing to the original 36 // declaration. If the original declaration is deleted, e.g. because the original 37 // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case, 38 // find all DeclarationWithType nodes (since a VariableExpr must point to a 39 // DeclarationWithType) in the original CompoundStmt and map them to the cloned 40 // node in the new CompoundStmt ('this'), then replace the Declarations referred to 41 // by each VariableExpr according to the constructed map. Note that only the declarations 42 // in the current level are collected into the map, because child CompoundStmts will 43 // recursively execute this routine. There may be more efficient ways of doing 44 // this. 45 VarExprReplacer::DeclMap declMap; 46 std::list< Statement * >::const_iterator origit = other.kids.begin(); 47 for ( Statement * s : kids ) { 48 assert( origit != other.kids.end() ); 49 Statement * origStmt = *origit++; 50 if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) { 51 DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( origStmt ); 52 assert( origDeclStmt ); 53 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) { 54 DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ); 55 assert( origdwt ); 56 assert( dwt->get_name() == origdwt->get_name() ); 57 declMap[ origdwt ] = dwt; 58 } 59 } 60 } 61 if ( ! declMap.empty() ) { 62 VarExprReplacer replacer( declMap ); 63 accept( replacer ); 64 } 79 65 } 80 66 -
src/SynTree/Expression.cc
r84118d8 rb726084 31 31 32 32 33 Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {} 34 35 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 36 cloneAll( other.results, results ); 33 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {} 34 35 Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 37 36 } 38 37 … … 40 39 delete env; 41 40 delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix 42 deleteAll( results ); 43 } 44 45 void Expression::add_result( Type *t ) { 46 if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) { 47 std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) ); 48 } else { 49 results.push_back(t); 50 } // if 41 delete result; 51 42 } 52 43 … … 68 59 69 60 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) { 70 add_result( constant.get_type()->clone() );61 set_result( constant.get_type()->clone() ); 71 62 } 72 63 … … 85 76 assert( var ); 86 77 assert( var->get_type() ); 87 add_result( var->get_type()->clone() ); 88 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { 89 (*i)->set_isLvalue( true ); 90 } // for 78 Type * type = var->get_type()->clone(); 79 type->set_isLvalue( true ); 80 set_result( type ); 91 81 } 92 82 … … 110 100 SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) : 111 101 Expression( _aname ), expr(expr_), type(0), isType(false) { 112 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );102 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 113 103 } 114 104 115 105 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) : 116 106 Expression( _aname ), expr(0), type(type_), isType(true) { 117 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );107 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 118 108 } 119 109 … … 141 131 AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) : 142 132 Expression( _aname ), expr(expr_), type(0), isType(false) { 143 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );133 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 144 134 } 145 135 146 136 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) : 147 137 Expression( _aname ), expr(0), type(type_), isType(true) { 148 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );138 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 149 139 } 150 140 … … 172 162 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) : 173 163 Expression( _aname ), type(type_), member(member_) { 174 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );164 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 175 165 } 176 166 … … 197 187 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) : 198 188 Expression( _aname ), type(type_), member(member_) { 199 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );189 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 200 190 } 201 191 … … 229 219 230 220 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 231 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );221 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 232 222 } 233 223 … … 284 274 285 275 CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) { 286 add_result(toType);276 set_result(toType); 287 277 } 288 278 289 279 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) { 280 set_result( new VoidType( Type::Qualifiers() ) ); 290 281 } 291 282 … … 303 294 arg->print(os, indent+2); 304 295 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 305 if ( results.empty() ) { 306 os << std::string( indent+2, ' ' ) << "nothing" << std::endl; 296 os << std::string( indent+2, ' ' ); 297 if ( result->isVoid() ) { 298 os << "nothing"; 307 299 } else { 308 printAll(results, os, indent+2);300 result->print( os, indent+2 ); 309 301 } // if 310 Expression::print( os, indent ); 311 } 312 313 UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) : 302 os << std::endl; 303 Expression::print( os, indent ); 304 } 305 306 UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) : 314 307 Expression( _aname ), member(_member), aggregate(_aggregate) {} 315 308 316 309 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) : 317 Expression( other ), member( other.member), aggregate( maybeClone( other.aggregate ) ) {310 Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) { 318 311 } 319 312 320 313 UntypedMemberExpr::~UntypedMemberExpr() { 321 314 delete aggregate; 315 delete member; 322 316 } 323 317 324 318 void UntypedMemberExpr::print( std::ostream &os, int indent ) const { 325 os << "Untyped Member Expression, with field: " << get_member(); 319 os << "Untyped Member Expression, with field: " << std::endl; 320 os << std::string( indent+2, ' ' ); 321 get_member()->print(os, indent+4); 322 os << std::string( indent+2, ' ' ); 326 323 327 324 Expression *agg = get_aggregate(); 328 os << " , from aggregate: ";325 os << "from aggregate: " << std::endl; 329 326 if (agg != 0) { 330 os << std::string( indent + 2, ' ' );331 agg->print(os, indent + 2);327 os << std::string( indent + 4, ' ' ); 328 agg->print(os, indent + 4); 332 329 } 333 330 os << std::string( indent+2, ' ' ); … … 338 335 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 339 336 Expression( _aname ), member(_member), aggregate(_aggregate) { 340 add_result( member->get_type()->clone() ); 341 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { 342 (*i)->set_isLvalue( true ); 343 } // for 337 set_result( member->get_type()->clone() ); 338 get_result()->set_isLvalue( true ); 344 339 } 345 340 … … 372 367 } 373 368 374 375 UntypedExpr::UntypedExpr( Expression *_function, Expression *_aname ) : Expression( _aname ), function( _function) {}369 UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) : 370 Expression( _aname ), function(_function), args(_args) {} 376 371 377 372 UntypedExpr::UntypedExpr( const UntypedExpr &other ) : … … 380 375 } 381 376 382 UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :383 Expression( _aname ), function(_function), args(_args) {}384 385 377 UntypedExpr::~UntypedExpr() { 386 378 delete function; 387 379 deleteAll( args ); 388 380 } 381 382 UntypedExpr * UntypedExpr::createDeref( Expression * expr ) { 383 UntypedExpr * ret = new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ expr } ); 384 if ( Type * type = expr->get_result() ) { 385 Type * base = InitTweak::getPointerBase( type ); 386 if ( ! base ) { 387 std::cerr << type << std::endl; 388 } 389 assertf( base, "expected pointer type in dereference\n" ); 390 ret->set_result( maybeClone( base ) ); 391 } 392 return ret; 393 } 394 395 UntypedExpr * UntypedExpr::createAssign( Expression * arg1, Expression * arg2 ) { 396 assert( arg1 && arg2 ); 397 UntypedExpr * ret = new UntypedExpr( new NameExpr( "?=?" ), std::list< Expression * >{ arg1, arg2 } ); 398 if ( arg1->get_result() && arg2->get_result() ) { 399 // if both expressions are typed, assumes that this assignment is a C bitwise assignment, 400 // so the result is the type of the RHS 401 ret->set_result( arg2->get_result()->clone() ); 402 } 403 return ret; 404 } 405 389 406 390 407 void UntypedExpr::print( std::ostream &os, int indent ) const { … … 419 436 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) : 420 437 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) { 421 add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );438 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 422 439 } 423 440 … … 454 471 455 472 void ConditionalExpr::print( std::ostream &os, int indent ) const { 456 os << std::string( indent, ' ' ) << "Conditional expression on: " << std::endl; 473 os << "Conditional expression on: " << std::endl; 474 os << std::string( indent+2, ' ' ); 457 475 arg1->print( os, indent+2 ); 458 476 os << std::string( indent, ' ' ) << "First alternative:" << std::endl; 477 os << std::string( indent+2, ' ' ); 459 478 arg2->print( os, indent+2 ); 460 479 os << std::string( indent, ' ' ) << "Second alternative:" << std::endl; 480 os << std::string( indent+2, ' ' ); 461 481 arg3->print( os, indent+2 ); 462 482 os << std::endl; … … 477 497 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 478 498 assert( callExpr ); 479 cloneAll( callExpr->get_results(), results ); 499 assert( callExpr->has_result() ); 500 set_result( callExpr->get_result()->clone() ); 480 501 } 481 502 … … 510 531 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 511 532 assert( arg ); 512 cloneAll( arg->get_results(), results);533 set_result( maybeClone( arg->get_result() ) ); 513 534 } 514 535 … … 530 551 531 552 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 532 add_result( type->clone() ); 533 } 534 535 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 553 assert( type && initializer ); 554 set_result( type->clone() ); 555 } 556 557 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {} 536 558 537 559 CompoundLiteralExpr::~CompoundLiteralExpr() { … … 542 564 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 543 565 os << "Compound Literal Expression: " << std::endl; 544 if ( type ) type->print( os, indent + 2 ); 545 if ( initializer ) initializer->print( os, indent + 2 ); 566 os << std::string( indent+2, ' ' ); 567 type->print( os, indent + 2 ); 568 os << std::string( indent+2, ' ' ); 569 initializer->print( os, indent + 2 ); 546 570 } 547 571 … … 557 581 558 582 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 559 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}583 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} 560 584 void RangeExpr::print( std::ostream &os, int indent ) const { 561 os << std::string( indent, ' ' ) <<"Range Expression: ";585 os << "Range Expression: "; 562 586 low->print( os, indent ); 563 587 os << " ... "; 564 588 high->print( os, indent ); 589 } 590 591 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) { 592 assert( statements ); 593 std::list< Statement * > & body = statements->get_kids(); 594 if ( ! body.empty() ) { 595 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 596 set_result( maybeClone( exprStmt->get_expr()->get_result() ) ); 597 } 598 } 599 } 600 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {} 601 StmtExpr::~StmtExpr() { 602 delete statements; 603 } 604 void StmtExpr::print( std::ostream &os, int indent ) const { 605 os << "Statement Expression: " << std::endl << std::string( indent, ' ' ); 606 statements->print( os, indent+2 ); 607 } 608 609 610 long long UniqueExpr::count = 0; 611 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) { 612 assert( expr ); 613 assert( count != -1 ); 614 if ( id == -1 ) id = count++; 615 if ( expr->get_result() ) { 616 set_result( expr->get_result()->clone() ); 617 } 618 } 619 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 620 } 621 UniqueExpr::~UniqueExpr() { 622 delete expr; 623 delete object; 624 delete var; 625 } 626 void UniqueExpr::print( std::ostream &os, int indent ) const { 627 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' ); 628 get_expr()->print( os, indent+2 ); 629 if ( get_object() ) { 630 os << " with decl: "; 631 get_object()->printShort( os, indent+2 ); 632 } 565 633 } 566 634 -
src/SynTree/Expression.h
r84118d8 rb726084 32 32 virtual ~Expression(); 33 33 34 std::list<Type *>& get_results() { return results; } 35 void add_result( Type *t ); 34 Type *& get_result() { return result; } 35 void set_result( Type *newValue ) { result = newValue; } 36 bool has_result() const { return result != nullptr; } 36 37 37 38 TypeSubstitution *get_env() const { return env; } … … 47 48 virtual void print( std::ostream &os, int indent = 0 ) const; 48 49 protected: 49 std::list<Type *> results;50 Type * result; 50 51 TypeSubstitution *env; 51 52 Expression* argName; // if expression is used as an argument, it can be "designated" by this name … … 98 99 class UntypedExpr : public Expression { 99 100 public: 100 UntypedExpr( Expression *function, Expression *_aname = nullptr );101 UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr ); 101 102 UntypedExpr( const UntypedExpr &other ); 102 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr );103 103 virtual ~UntypedExpr(); 104 104 … … 111 111 std::list<Expression*>& get_args() { return args; } 112 112 113 static UntypedExpr * createDeref( Expression * arg ); 114 static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 ); 115 113 116 virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); } 114 117 virtual void accept( Visitor &v ) { v.visit( this ); } … … 200 203 class UntypedMemberExpr : public Expression { 201 204 public: 202 UntypedMemberExpr( std::stringmember, Expression *aggregate, Expression *_aname = nullptr );205 UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr ); 203 206 UntypedMemberExpr( const UntypedMemberExpr &other ); 204 207 virtual ~UntypedMemberExpr(); 205 208 206 std::stringget_member() const { return member; }207 void set_member( const std::string &newValue ) { member = newValue; }209 Expression * get_member() const { return member; } 210 void set_member( Expression * newValue ) { member = newValue; } 208 211 Expression *get_aggregate() const { return aggregate; } 209 212 void set_aggregate( Expression *newValue ) { aggregate = newValue; } … … 214 217 virtual void print( std::ostream &os, int indent = 0 ) const; 215 218 private: 216 std::stringmember;219 Expression *member; 217 220 Expression *aggregate; 218 221 }; … … 483 486 }; 484 487 485 /// TupleExpr represents a tuple expression ( [a, b, c] )486 class TupleExpr : public Expression {487 public:488 TupleExpr( Expression *_aname = nullptr );489 TupleExpr( const TupleExpr &other );490 virtual ~TupleExpr();491 492 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }493 std::list<Expression*>& get_exprs() { return exprs; }494 495 virtual TupleExpr *clone() const { return new TupleExpr( *this ); }496 virtual void accept( Visitor &v ) { v.visit( this ); }497 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }498 virtual void print( std::ostream &os, int indent = 0 ) const;499 private:500 std::list<Expression*> exprs;501 };502 503 /// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on504 class SolvedTupleExpr : public Expression {505 public:506 SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {}507 SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr );508 SolvedTupleExpr( const SolvedTupleExpr &other );509 virtual ~SolvedTupleExpr() {}510 511 std::list<Expression*> &get_exprs() { return exprs; }512 513 virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }514 virtual void accept( Visitor &v ) { v.visit( this ); }515 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }516 virtual void print( std::ostream &os, int indent = 0 ) const;517 private:518 std::list<Expression*> exprs;519 };520 521 488 /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) 522 489 class TypeExpr : public Expression { … … 618 585 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 586 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr();587 virtual ~CompoundLiteralExpr(); 621 588 622 589 Type * get_type() const { return type; } … … 670 637 private: 671 638 Expression *low, *high; 639 }; 640 641 /// TupleExpr represents a tuple expression ( [a, b, c] ) 642 class TupleExpr : public Expression { 643 public: 644 TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr ); 645 TupleExpr( const TupleExpr &other ); 646 virtual ~TupleExpr(); 647 648 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; } 649 std::list<Expression*>& get_exprs() { return exprs; } 650 651 virtual TupleExpr *clone() const { return new TupleExpr( *this ); } 652 virtual void accept( Visitor &v ) { v.visit( this ); } 653 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 654 virtual void print( std::ostream &os, int indent = 0 ) const; 655 private: 656 std::list<Expression*> exprs; 657 }; 658 659 /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer 660 class TupleIndexExpr : public Expression { 661 public: 662 TupleIndexExpr( Expression * tuple, unsigned int index ); 663 TupleIndexExpr( const TupleIndexExpr &other ); 664 virtual ~TupleIndexExpr(); 665 666 Expression * get_tuple() const { return tuple; } 667 int get_index() const { return index; } 668 TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; } 669 TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; } 670 671 virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); } 672 virtual void accept( Visitor &v ) { v.visit( this ); } 673 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 674 virtual void print( std::ostream &os, int indent = 0 ) const; 675 private: 676 Expression * tuple; 677 unsigned int index; 678 }; 679 680 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer 681 class MemberTupleExpr : public Expression { 682 public: 683 MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr ); 684 MemberTupleExpr( const MemberTupleExpr &other ); 685 virtual ~MemberTupleExpr(); 686 687 Expression * get_member() const { return member; } 688 Expression * get_aggregate() const { return aggregate; } 689 MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; } 690 MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; } 691 692 virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); } 693 virtual void accept( Visitor &v ) { v.visit( this ); } 694 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 695 virtual void print( std::ostream &os, int indent = 0 ) const; 696 private: 697 Expression * member; 698 Expression * aggregate; 699 }; 700 701 /// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression 702 class TupleAssignExpr : public Expression { 703 public: 704 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); 705 TupleAssignExpr( const TupleAssignExpr &other ); 706 virtual ~TupleAssignExpr(); 707 708 std::list< Expression * > & get_assigns() { return assigns; } 709 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 710 711 virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); } 712 virtual void accept( Visitor &v ) { v.visit( this ); } 713 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 714 virtual void print( std::ostream &os, int indent = 0 ) const; 715 private: 716 std::list< Expression * > assigns; // assignment expressions that use tempDecls 717 std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs 718 }; 719 720 /// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; }) 721 class StmtExpr : public Expression { 722 public: 723 StmtExpr( CompoundStmt *statements ); 724 StmtExpr( const StmtExpr & other ); 725 virtual ~StmtExpr(); 726 727 CompoundStmt * get_statements() const { return statements; } 728 StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } 729 730 virtual StmtExpr *clone() const { return new StmtExpr( *this ); } 731 virtual void accept( Visitor &v ) { v.visit( this ); } 732 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 733 virtual void print( std::ostream &os, int indent = 0 ) const; 734 private: 735 CompoundStmt * statements; 736 }; 737 738 class UniqueExpr : public Expression { 739 public: 740 UniqueExpr( Expression * expr, long long idVal = -1 ); 741 UniqueExpr( const UniqueExpr & other ); 742 ~UniqueExpr(); 743 744 Expression * get_expr() const { return expr; } 745 UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } 746 747 ObjectDecl * get_object() const { return object; } 748 UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; } 749 750 VariableExpr * get_var() const { return var; } 751 UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; } 752 753 int get_id() const { return id; } 754 755 virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); } 756 virtual void accept( Visitor &v ) { v.visit( this ); } 757 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 758 virtual void print( std::ostream &os, int indent = 0 ) const; 759 private: 760 Expression * expr; 761 ObjectDecl * object; 762 VariableExpr * var; 763 int id; 764 static long long count; 672 765 }; 673 766 -
src/SynTree/Initializer.h
r84118d8 rb726084 23 23 24 24 #include <cassert> 25 26 const std::list<Expression*> noDesignators; 25 27 26 28 // Initializer: base class for object initializers (provide default values) -
src/SynTree/Mutator.cc
r84118d8 rb726084 178 178 179 179 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) { 180 mutateAll( applicationExpr->get_results(), *this);180 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) ); 181 181 applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) ); 182 182 mutateAll( applicationExpr->get_args(), *this ); … … 185 185 186 186 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) { 187 mutateAll( untypedExpr->get_results(), *this);187 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) ); 188 188 mutateAll( untypedExpr->get_args(), *this ); 189 189 return untypedExpr; … … 191 191 192 192 Expression *Mutator::mutate( NameExpr *nameExpr ) { 193 mutateAll( nameExpr->get_results(), *this);193 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) ); 194 194 return nameExpr; 195 195 } 196 196 197 197 Expression *Mutator::mutate( AddressExpr *addressExpr ) { 198 mutateAll( addressExpr->get_results(), *this);198 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) ); 199 199 addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) ); 200 200 return addressExpr; … … 202 202 203 203 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) { 204 mutateAll( labelAddressExpr->get_results(), *this);204 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) ); 205 205 labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) ); 206 206 return labelAddressExpr; … … 208 208 209 209 Expression *Mutator::mutate( CastExpr *castExpr ) { 210 mutateAll( castExpr->get_results(), *this);210 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); 211 211 castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) ); 212 212 return castExpr; … … 214 214 215 215 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) { 216 mutateAll( memberExpr->get_results(), *this ); 216 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 217 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); 218 memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) ); 219 return memberExpr; 220 } 221 222 Expression *Mutator::mutate( MemberExpr *memberExpr ) { 223 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 217 224 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); 218 225 return memberExpr; 219 226 } 220 227 221 Expression *Mutator::mutate( MemberExpr *memberExpr ) {222 mutateAll( memberExpr->get_results(), *this );223 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );224 return memberExpr;225 }226 227 228 Expression *Mutator::mutate( VariableExpr *variableExpr ) { 228 mutateAll( variableExpr->get_results(), *this);229 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); 229 230 return variableExpr; 230 231 } 231 232 232 233 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 233 mutateAll( constantExpr->get_results(), *this);234 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); 234 235 // maybeMutate( constantExpr->get_constant(), *this ) 235 236 return constantExpr; … … 237 238 238 239 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 239 mutateAll( sizeofExpr->get_results(), *this);240 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) ); 240 241 if ( sizeofExpr->get_isType() ) { 241 242 sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) ); … … 247 248 248 249 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) { 249 mutateAll( alignofExpr->get_results(), *this);250 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) ); 250 251 if ( alignofExpr->get_isType() ) { 251 252 alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) ); … … 257 258 258 259 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 259 mutateAll( offsetofExpr->get_results(), *this);260 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 260 261 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 261 262 return offsetofExpr; … … 263 264 264 265 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 265 mutateAll( offsetofExpr->get_results(), *this);266 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 266 267 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 267 268 offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) ); … … 270 271 271 272 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 272 mutateAll( offsetPackExpr->get_results(), *this);273 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) ); 273 274 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); 274 275 return offsetPackExpr; … … 276 277 277 278 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 278 mutateAll( attrExpr->get_results(), *this);279 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) ); 279 280 if ( attrExpr->get_isType() ) { 280 281 attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) ); … … 286 287 287 288 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) { 288 mutateAll( logicalExpr->get_results(), *this);289 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) ); 289 290 logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) ); 290 291 logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) ); … … 293 294 294 295 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) { 295 mutateAll( conditionalExpr->get_results(), *this);296 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) ); 296 297 conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) ); 297 298 conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) ); … … 301 302 302 303 Expression *Mutator::mutate( CommaExpr *commaExpr ) { 303 mutateAll( commaExpr->get_results(), *this);304 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) ); 304 305 commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) ); 305 306 commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) ); … … 307 308 } 308 309 309 Expression *Mutator::mutate( TupleExpr *tupleExpr ) {310 mutateAll( tupleExpr->get_results(), *this );311 mutateAll( tupleExpr->get_exprs(), *this );312 return tupleExpr;313 }314 315 Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) {316 mutateAll( tupleExpr->get_results(), *this );317 mutateAll( tupleExpr->get_exprs(), *this );318 return tupleExpr;319 }320 321 310 Expression *Mutator::mutate( TypeExpr *typeExpr ) { 322 mutateAll( typeExpr->get_results(), *this);311 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) ); 323 312 typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) ); 324 313 return typeExpr; … … 340 329 341 330 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 342 mutateAll( ctorExpr->get_results(), *this);331 ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) ); 343 332 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); 344 333 return ctorExpr; … … 346 335 347 336 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 348 mutateAll( compLitExpr->get_results(), *this);337 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) ); 349 338 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); 350 339 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); … … 353 342 354 343 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 355 mutateAll( valofExpr->get_results(), *this);344 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) ); 356 345 return valofExpr; 357 346 } … … 361 350 rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) ); 362 351 return rangeExpr; 352 } 353 354 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 355 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 356 mutateAll( tupleExpr->get_exprs(), *this ); 357 return tupleExpr; 358 } 359 360 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) { 361 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 362 tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) ); 363 return tupleExpr; 364 } 365 366 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) { 367 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 368 tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) ); 369 tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) ); 370 return tupleExpr; 371 } 372 373 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 374 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) ); 375 mutateAll( assignExpr->get_tempDecls(), *this ); 376 mutateAll( assignExpr->get_assigns(), *this ); 377 return assignExpr; 378 } 379 380 Expression *Mutator::mutate( StmtExpr *stmtExpr ) { 381 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); 382 stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) ); 383 return stmtExpr; 384 } 385 386 Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) { 387 uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) ); 388 uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) ); 389 return uniqueExpr; 363 390 } 364 391 -
src/SynTree/Mutator.h
r84118d8 rb726084 71 71 virtual Expression* mutate( ConditionalExpr *conditionalExpr ); 72 72 virtual Expression* mutate( CommaExpr *commaExpr ); 73 virtual Expression* mutate( TupleExpr *tupleExpr );74 virtual Expression* mutate( SolvedTupleExpr *tupleExpr );75 73 virtual Expression* mutate( TypeExpr *typeExpr ); 76 74 virtual Expression* mutate( AsmExpr *asmExpr ); … … 80 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 81 79 virtual Expression* mutate( RangeExpr *rangeExpr ); 80 virtual Expression* mutate( TupleExpr *tupleExpr ); 81 virtual Expression* mutate( TupleIndexExpr *tupleExpr ); 82 virtual Expression* mutate( MemberTupleExpr *tupleExpr ); 83 virtual Expression* mutate( TupleAssignExpr *assignExpr ); 84 virtual Expression* mutate( StmtExpr * stmtExpr ); 85 virtual Expression* mutate( UniqueExpr * uniqueExpr ); 82 86 83 87 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/ReferenceToType.cc
r84118d8 rb726084 56 56 } 57 57 } // namespace 58 59 StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct ) : Parent( tq, baseStruct->get_name() ), baseStruct( baseStruct ) {} 58 60 59 61 std::string StructInstType::typeString() const { return "struct"; } -
src/SynTree/SynTree.h
r84118d8 rb726084 76 76 class ConditionalExpr; 77 77 class CommaExpr; 78 class TupleExpr;79 class SolvedTupleExpr;80 78 class TypeExpr; 81 79 class AsmExpr; … … 85 83 class UntypedValofExpr; 86 84 class RangeExpr; 85 class TupleExpr; 86 class TupleIndexExpr; 87 class MemberTupleExpr; 88 class TupleAssignExpr; 89 class StmtExpr; 90 class UniqueExpr; 87 91 88 92 class Type; -
src/SynTree/TupleExpr.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleExpr.cc -- 7 // TupleExpr.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 16 16 #include "Expression.h" 17 17 #include "Common/utility.h" 18 #include "Type.h" 19 #include "Declaration.h" 20 #include "Tuples/Tuples.h" 21 #include "VarExprReplacer.h" 18 22 19 TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) { 23 TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) { 24 if ( ! exprs.empty() ) { 25 if ( std::all_of( exprs.begin(), exprs.end(), [](Expression * expr) { return expr->get_result(); } ) ) { 26 set_result( Tuples::makeTupleType( exprs ) ); 27 } 28 } 20 29 } 21 30 … … 29 38 30 39 void TupleExpr::print( std::ostream &os, int indent ) const { 31 os << std::string( indent, ' ' ) <<"Tuple:" << std::endl;40 os << "Tuple:" << std::endl; 32 41 printAll( exprs, os, indent+2 ); 33 42 Expression::print( os, indent ); 34 43 } 35 44 36 SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) { 37 std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs)); 45 TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) : tuple( tuple ), index( index ) { 46 TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() ); 47 assert( type->size() > index ); 48 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 49 get_result()->set_isLvalue( type->get_isLvalue() ); 38 50 } 39 51 40 SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) { 41 cloneAll( other.exprs, exprs ); 52 TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) { 42 53 } 43 54 44 void SolvedTupleExpr::print( std::ostream &os, int indent ) const { 45 os << std::string( indent, ' ' ) << "Solved Tuple:" << std::endl; 46 printAll( exprs, os, indent+2 ); 55 TupleIndexExpr::~TupleIndexExpr() { 56 delete tuple; 57 } 58 59 void TupleIndexExpr::print( std::ostream &os, int indent ) const { 60 os << "Tuple Index Expression, with tuple:" << std::endl; 61 os << std::string( indent+2, ' ' ); 62 tuple->print( os, indent+2 ); 63 os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl; 47 64 Expression::print( os, indent ); 48 65 } 66 67 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) { 68 set_result( maybeClone( member->get_result() ) ); // xxx - ??? 69 } 70 71 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) { 72 } 73 74 MemberTupleExpr::~MemberTupleExpr() { 75 delete member; 76 delete aggregate; 77 } 78 79 void MemberTupleExpr::print( std::ostream &os, int indent ) const { 80 os << "Member Tuple Expression, with aggregate:" << std::endl; 81 os << std::string( indent+2, ' ' ); 82 aggregate->print( os, indent+2 ); 83 os << std::string( indent+2, ' ' ) << "with member: " << std::endl; 84 os << std::string( indent+2, ' ' ); 85 member->print( os, indent+2 ); 86 Expression::print( os, indent ); 87 } 88 89 90 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) { 91 set_result( Tuples::makeTupleType( assigns ) ); 92 } 93 94 TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ) { 95 cloneAll( other.assigns, assigns ); 96 cloneAll( other.tempDecls, tempDecls ); 97 98 // clone needs to go into assigns and replace tempDecls 99 VarExprReplacer::DeclMap declMap; 100 std::list< ObjectDecl * >::const_iterator origit = other.tempDecls.begin(); 101 for ( ObjectDecl * temp : tempDecls ) { 102 assert( origit != other.tempDecls.end() ); 103 ObjectDecl * origTemp = *origit++; 104 assert( origTemp ); 105 assert( temp->get_name() == origTemp->get_name() ); 106 declMap[ origTemp ] = temp; 107 } 108 if ( ! declMap.empty() ) { 109 VarExprReplacer replacer( declMap ); 110 for ( Expression * assn : assigns ) { 111 assn->accept( replacer ); 112 } 113 } 114 } 115 116 TupleAssignExpr::~TupleAssignExpr() { 117 deleteAll( assigns ); 118 // deleteAll( tempDecls ); 119 } 120 121 void TupleAssignExpr::print( std::ostream &os, int indent ) const { 122 os << "Tuple Assignment Expression, with temporaries:" << std::endl; 123 printAll( tempDecls, os, indent+4 ); 124 os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl; 125 printAll( assigns, os, indent+4 ); 126 Expression::print( os, indent ); 127 } 128 129 49 130 50 131 // Local Variables: // -
src/SynTree/TupleType.cc
r84118d8 rb726084 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleType.cc -- 7 // TupleType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 17 17 #include "Common/utility.h" 18 18 19 TupleType::TupleType( const Type::Qualifiers &tq ) : Type( tq) {19 TupleType::TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types ) : Type( tq ), types( types ) { 20 20 } 21 21 -
src/SynTree/Type.h
r84118d8 rb726084 20 20 #include "Visitor.h" 21 21 #include "Mutator.h" 22 #include "Common/utility.h" 22 23 23 24 class Type { … … 27 28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {} 28 29 30 Qualifiers &operator&=( const Qualifiers &other ); 29 31 Qualifiers &operator+=( const Qualifiers &other ); 30 32 Qualifiers &operator-=( const Qualifiers &other ); … … 63 65 void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } 64 66 void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; } 65 std::list<TypeDecl*>& get_forall() { return forall; } 67 68 typedef std::list<TypeDecl *> ForallList; 69 ForallList& get_forall() { return forall; } 70 71 /// How many elemental types are represented by this type 72 virtual unsigned size() const { return 1; }; 73 virtual bool isVoid() const { return size() == 0; } 66 74 67 75 virtual Type *clone() const = 0; … … 71 79 private: 72 80 Qualifiers tq; 73 std::list<TypeDecl*>forall;81 ForallList forall; 74 82 }; 75 83 … … 77 85 public: 78 86 VoidType( const Type::Qualifiers &tq ); 87 88 virtual unsigned size() const { return 0; }; 79 89 80 90 virtual VoidType *clone() const { return new VoidType( *this ); } … … 234 244 public: 235 245 StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {} 246 StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct ); 236 247 StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {} 237 248 … … 348 359 class TupleType : public Type { 349 360 public: 350 TupleType( const Type::Qualifiers &tq );361 TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() ); 351 362 TupleType( const TupleType& ); 352 363 virtual ~TupleType(); 353 364 365 typedef std::list<Type*> value_type; 366 typedef value_type::iterator iterator; 367 354 368 std::list<Type*>& get_types() { return types; } 369 virtual unsigned size() const { return types.size(); }; 370 371 iterator begin() { return types.begin(); } 372 iterator end() { return types.end(); } 355 373 356 374 virtual TupleType *clone() const { return new TupleType( *this ); } … … 442 460 }; 443 461 462 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) { 463 isConst &= other.isConst; 464 isVolatile &= other.isVolatile; 465 isRestrict &= other.isRestrict; 466 isLvalue &= other.isLvalue; 467 isAtomic &= other.isAtomic; 468 return *this; 469 } 470 444 471 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 445 472 isConst |= other.isConst; -
src/SynTree/TypeSubstitution.cc
r84118d8 rb726084 72 72 Type *TypeSubstitution::lookup( std::string formalType ) const { 73 73 TypeEnvType::const_iterator i = typeEnv.find( formalType ); 74 74 75 75 // break on not in substitution set 76 76 if ( i == typeEnv.end() ) return 0; 77 77 78 78 // attempt to transitively follow TypeInstType links. 79 79 while ( TypeInstType *actualType = dynamic_cast< TypeInstType* >( i->second ) ) { 80 80 const std::string& typeName = actualType->get_name(); 81 81 82 82 // break cycles in the transitive follow 83 83 if ( formalType == typeName ) break; 84 84 85 85 // Look for the type this maps to, returning previous mapping if none-such 86 86 i = typeEnv.find( typeName ); 87 87 if ( i == typeEnv.end() ) return actualType; 88 88 } 89 89 90 90 // return type from substitution set 91 91 return i->second; 92 92 93 93 #if 0 94 94 if ( i == typeEnv.end() ) { … … 149 149 // bind type variables from forall-qualifiers 150 150 if ( freeOnly ) { 151 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {151 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 152 152 boundVars.insert( (*tyvar )->get_name() ); 153 153 } // for … … 163 163 // bind type variables from forall-qualifiers 164 164 if ( freeOnly ) { 165 for ( std::list< TypeDecl* >::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {165 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 166 166 boundVars.insert( (*tyvar )->get_name() ); 167 167 } // for -
src/SynTree/Visitor.cc
r84118d8 rb726084 150 150 151 151 void Visitor::visit( ApplicationExpr *applicationExpr ) { 152 acceptAll( applicationExpr->get_results(), *this );152 maybeAccept( applicationExpr->get_result(), *this ); 153 153 maybeAccept( applicationExpr->get_function(), *this ); 154 154 acceptAll( applicationExpr->get_args(), *this ); … … 156 156 157 157 void Visitor::visit( UntypedExpr *untypedExpr ) { 158 acceptAll( untypedExpr->get_results(), *this );158 maybeAccept( untypedExpr->get_result(), *this ); 159 159 acceptAll( untypedExpr->get_args(), *this ); 160 160 } 161 161 162 162 void Visitor::visit( NameExpr *nameExpr ) { 163 acceptAll( nameExpr->get_results(), *this );163 maybeAccept( nameExpr->get_result(), *this ); 164 164 } 165 165 166 166 void Visitor::visit( AddressExpr *addressExpr ) { 167 acceptAll( addressExpr->get_results(), *this );167 maybeAccept( addressExpr->get_result(), *this ); 168 168 maybeAccept( addressExpr->get_arg(), *this ); 169 169 } 170 170 171 171 void Visitor::visit( LabelAddressExpr *labAddressExpr ) { 172 acceptAll( labAddressExpr->get_results(), *this );172 maybeAccept( labAddressExpr->get_result(), *this ); 173 173 maybeAccept( labAddressExpr->get_arg(), *this ); 174 174 } 175 175 176 176 void Visitor::visit( CastExpr *castExpr ) { 177 acceptAll( castExpr->get_results(), *this );177 maybeAccept( castExpr->get_result(), *this ); 178 178 maybeAccept( castExpr->get_arg(), *this ); 179 179 } 180 180 181 181 void Visitor::visit( UntypedMemberExpr *memberExpr ) { 182 acceptAll( memberExpr->get_results(), *this );182 maybeAccept( memberExpr->get_result(), *this ); 183 183 maybeAccept( memberExpr->get_aggregate(), *this ); 184 maybeAccept( memberExpr->get_member(), *this ); 184 185 } 185 186 186 187 void Visitor::visit( MemberExpr *memberExpr ) { 187 acceptAll( memberExpr->get_results(), *this );188 maybeAccept( memberExpr->get_result(), *this ); 188 189 maybeAccept( memberExpr->get_aggregate(), *this ); 189 190 } 190 191 191 192 void Visitor::visit( VariableExpr *variableExpr ) { 192 acceptAll( variableExpr->get_results(), *this );193 maybeAccept( variableExpr->get_result(), *this ); 193 194 } 194 195 195 196 void Visitor::visit( ConstantExpr *constantExpr ) { 196 acceptAll( constantExpr->get_results(), *this );197 maybeAccept( constantExpr->get_result(), *this ); 197 198 maybeAccept( constantExpr->get_constant(), *this ); 198 199 } 199 200 200 201 void Visitor::visit( SizeofExpr *sizeofExpr ) { 201 acceptAll( sizeofExpr->get_results(), *this );202 maybeAccept( sizeofExpr->get_result(), *this ); 202 203 if ( sizeofExpr->get_isType() ) { 203 204 maybeAccept( sizeofExpr->get_type(), *this ); … … 208 209 209 210 void Visitor::visit( AlignofExpr *alignofExpr ) { 210 acceptAll( alignofExpr->get_results(), *this );211 maybeAccept( alignofExpr->get_result(), *this ); 211 212 if ( alignofExpr->get_isType() ) { 212 213 maybeAccept( alignofExpr->get_type(), *this ); … … 217 218 218 219 void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) { 219 acceptAll( offsetofExpr->get_results(), *this );220 maybeAccept( offsetofExpr->get_result(), *this ); 220 221 maybeAccept( offsetofExpr->get_type(), *this ); 221 222 } 222 223 223 224 void Visitor::visit( OffsetofExpr *offsetofExpr ) { 224 acceptAll( offsetofExpr->get_results(), *this );225 maybeAccept( offsetofExpr->get_result(), *this ); 225 226 maybeAccept( offsetofExpr->get_type(), *this ); 226 227 maybeAccept( offsetofExpr->get_member(), *this ); … … 228 229 229 230 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) { 230 acceptAll( offsetPackExpr->get_results(), *this );231 maybeAccept( offsetPackExpr->get_result(), *this ); 231 232 maybeAccept( offsetPackExpr->get_type(), *this ); 232 233 } 233 234 234 235 void Visitor::visit( AttrExpr *attrExpr ) { 235 acceptAll( attrExpr->get_results(), *this );236 maybeAccept( attrExpr->get_result(), *this ); 236 237 if ( attrExpr->get_isType() ) { 237 238 maybeAccept( attrExpr->get_type(), *this ); … … 242 243 243 244 void Visitor::visit( LogicalExpr *logicalExpr ) { 244 acceptAll( logicalExpr->get_results(), *this );245 maybeAccept( logicalExpr->get_result(), *this ); 245 246 maybeAccept( logicalExpr->get_arg1(), *this ); 246 247 maybeAccept( logicalExpr->get_arg2(), *this ); … … 248 249 249 250 void Visitor::visit( ConditionalExpr *conditionalExpr ) { 250 acceptAll( conditionalExpr->get_results(), *this );251 maybeAccept( conditionalExpr->get_result(), *this ); 251 252 maybeAccept( conditionalExpr->get_arg1(), *this ); 252 253 maybeAccept( conditionalExpr->get_arg2(), *this ); … … 255 256 256 257 void Visitor::visit( CommaExpr *commaExpr ) { 257 acceptAll( commaExpr->get_results(), *this );258 maybeAccept( commaExpr->get_result(), *this ); 258 259 maybeAccept( commaExpr->get_arg1(), *this ); 259 260 maybeAccept( commaExpr->get_arg2(), *this ); 260 261 } 261 262 262 void Visitor::visit( TupleExpr *tupleExpr ) {263 acceptAll( tupleExpr->get_results(), *this );264 acceptAll( tupleExpr->get_exprs(), *this );265 }266 267 void Visitor::visit( SolvedTupleExpr *tupleExpr ) {268 acceptAll( tupleExpr->get_results(), *this );269 acceptAll( tupleExpr->get_exprs(), *this );270 }271 272 263 void Visitor::visit( TypeExpr *typeExpr ) { 273 acceptAll( typeExpr->get_results(), *this );264 maybeAccept( typeExpr->get_result(), *this ); 274 265 maybeAccept( typeExpr->get_type(), *this ); 275 266 } … … 288 279 289 280 void Visitor::visit( ConstructorExpr * ctorExpr ) { 290 acceptAll( ctorExpr->get_results(), *this );281 maybeAccept( ctorExpr->get_result(), *this ); 291 282 maybeAccept( ctorExpr->get_callExpr(), *this ); 292 283 } 293 284 294 285 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 295 acceptAll( compLitExpr->get_results(), *this );286 maybeAccept( compLitExpr->get_result(), *this ); 296 287 maybeAccept( compLitExpr->get_type(), *this ); 297 288 maybeAccept( compLitExpr->get_initializer(), *this ); … … 299 290 300 291 void Visitor::visit( UntypedValofExpr *valofExpr ) { 301 acceptAll( valofExpr->get_results(), *this );292 maybeAccept( valofExpr->get_result(), *this ); 302 293 maybeAccept( valofExpr->get_body(), *this ); 303 294 } … … 306 297 maybeAccept( rangeExpr->get_low(), *this ); 307 298 maybeAccept( rangeExpr->get_high(), *this ); 299 } 300 301 void Visitor::visit( TupleExpr *tupleExpr ) { 302 maybeAccept( tupleExpr->get_result(), *this ); 303 acceptAll( tupleExpr->get_exprs(), *this ); 304 } 305 306 void Visitor::visit( TupleIndexExpr *tupleExpr ) { 307 maybeAccept( tupleExpr->get_result(), *this ); 308 maybeAccept( tupleExpr->get_tuple(), *this ); 309 } 310 311 void Visitor::visit( MemberTupleExpr *tupleExpr ) { 312 maybeAccept( tupleExpr->get_result(), *this ); 313 maybeAccept( tupleExpr->get_member(), *this ); 314 maybeAccept( tupleExpr->get_aggregate(), *this ); 315 } 316 317 void Visitor::visit( TupleAssignExpr *assignExpr ) { 318 maybeAccept( assignExpr->get_result(), *this ); 319 acceptAll( assignExpr->get_tempDecls(), *this ); 320 acceptAll( assignExpr->get_assigns(), *this ); 321 } 322 323 void Visitor::visit( StmtExpr *stmtExpr ) { 324 maybeAccept( stmtExpr->get_result(), *this ); 325 maybeAccept( stmtExpr->get_statements(), *this ); 326 } 327 328 void Visitor::visit( UniqueExpr *uniqueExpr ) { 329 maybeAccept( uniqueExpr->get_result(), *this ); 330 maybeAccept( uniqueExpr->get_expr(), *this ); 308 331 } 309 332 -
src/SynTree/Visitor.h
r84118d8 rb726084 71 71 virtual void visit( ConditionalExpr *conditionalExpr ); 72 72 virtual void visit( CommaExpr *commaExpr ); 73 virtual void visit( TupleExpr *tupleExpr );74 virtual void visit( SolvedTupleExpr *tupleExpr );75 73 virtual void visit( TypeExpr *typeExpr ); 76 74 virtual void visit( AsmExpr *asmExpr ); … … 80 78 virtual void visit( UntypedValofExpr *valofExpr ); 81 79 virtual void visit( RangeExpr *rangeExpr ); 80 virtual void visit( TupleExpr *tupleExpr ); 81 virtual void visit( TupleIndexExpr *tupleExpr ); 82 virtual void visit( MemberTupleExpr *tupleExpr ); 83 virtual void visit( TupleAssignExpr *assignExpr ); 84 virtual void visit( StmtExpr * stmtExpr ); 85 virtual void visit( UniqueExpr * uniqueExpr ); 82 86 83 87 virtual void visit( VoidType *basicType ); -
src/SynTree/module.mk
r84118d8 rb726084 49 49 SynTree/AddStmtVisitor.cc \ 50 50 SynTree/TypeSubstitution.cc \ 51 SynTree/Attribute.cc 51 SynTree/Attribute.cc \ 52 SynTree/VarExprReplacer.cc 52 53 -
src/Tuples/TupleAssignment.cc
r84118d8 rb726084 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon May 18 15:02:53 201511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Nov 9 13:48:42 2016 13 13 // Update Count : 2 14 14 // … … 18 18 #include "ResolvExpr/typeops.h" 19 19 #include "SynTree/Expression.h" 20 #include "TupleAssignment.h" 20 #include "SynTree/Initializer.h" 21 #include "Tuples.h" 22 #include "Explode.h" 21 23 #include "Common/SemanticError.h" 24 #include "InitTweak/InitTweak.h" 22 25 23 26 #include <functional> … … 27 30 #include <cassert> 28 31 #include <set> 32 #include <unordered_set> 29 33 30 34 namespace Tuples { 31 TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f ) 32 : currentFinder(f), matcher(0), hasMatched( false ) {} 33 34 bool TupleAssignSpotter::pointsToTuple( Expression *expr ) { 35 class TupleAssignSpotter { 36 public: 37 // dispatcher for Tuple (multiple and mass) assignment operations 38 TupleAssignSpotter( ResolvExpr::AlternativeFinder & ); 39 void spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ); 40 41 private: 42 void match(); 43 44 struct Matcher { 45 public: 46 Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ); 47 virtual ~Matcher() {} 48 virtual void match( std::list< Expression * > &out ) = 0; 49 ResolvExpr::AltList lhs, rhs; 50 TupleAssignSpotter &spotter; 51 std::list< ObjectDecl * > tmpDecls; 52 }; 53 54 struct MassAssignMatcher : public Matcher { 55 public: 56 MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ); 57 virtual void match( std::list< Expression * > &out ); 58 }; 59 60 struct MultipleAssignMatcher : public Matcher { 61 public: 62 MultipleAssignMatcher( TupleAssignSpotter &spot, const ResolvExpr::AltList & alts ); 63 virtual void match( std::list< Expression * > &out ); 64 }; 65 66 ResolvExpr::AlternativeFinder ¤tFinder; 67 std::string fname; 68 std::unique_ptr< Matcher > matcher; 69 }; 70 71 /// true if expr is an expression of tuple type, i.e. a tuple expression, tuple variable, or MRV (multiple-return-value) function 72 bool isTuple( Expression *expr ) { 73 if ( ! expr ) return false; 74 assert( expr->has_result() ); 75 return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1; 76 } 77 78 template< typename AltIter > 79 bool isMultAssign( AltIter begin, AltIter end ) { 80 // multiple assignment if more than one alternative in the range or if 81 // the alternative is a tuple 82 if ( begin == end ) return false; 83 if ( isTuple( begin->expr ) ) return true; 84 return ++begin != end; 85 } 86 87 bool pointsToTuple( Expression *expr ) { 35 88 // also check for function returning tuple of reference types 36 if (AddressExpr *addr = dynamic_cast<AddressExpr *>(expr) ) 37 if ( isTuple(addr->get_arg() ) ) 38 return true; 89 if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { 90 return pointsToTuple( castExpr->get_arg() ); 91 } else if ( AddressExpr *addr = dynamic_cast< AddressExpr * >( expr) ) { 92 return isTuple( addr->get_arg() ); 93 } 39 94 return false; 40 95 } 41 96 42 bool TupleAssignSpotter::isTupleVar( DeclarationWithType *decl ) { 43 if ( dynamic_cast<TupleType *>(decl->get_type()) ) 44 return true; 45 return false; 46 } 47 48 bool TupleAssignSpotter::isTuple( Expression *expr, bool isRight ) { 49 // true if `expr' is an expression returning a tuple: tuple, tuple variable or MRV function 50 if ( ! expr ) return false; 51 52 if ( dynamic_cast<TupleExpr *>(expr) ) 53 return true; 54 else if ( VariableExpr *var = dynamic_cast<VariableExpr *>(expr) ) { 55 if ( isTupleVar(var->get_var()) ) 56 return true; 57 } 58 59 return false; 60 } 61 62 bool TupleAssignSpotter::match() { 63 assert ( matcher != 0 ); 64 65 std::list< Expression * > new_assigns; 66 if ( ! matcher->match(new_assigns) ) 67 return false; 68 69 if ( new_assigns.empty() ) return false; 70 /*return */matcher->solve( new_assigns ); 71 if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) { 72 // now resolve new assignments 73 std::list< Expression * > solved_assigns; 74 ResolvExpr::AltList solved_alts; 75 assert( currentFinder != 0 ); 76 77 ResolvExpr::AltList current; 78 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) { 79 //try { 80 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() ); 81 finder.findWithAdjustment(*i); 82 // prune expressions that don't coincide with 83 ResolvExpr::AltList alts = finder.get_alternatives(); 84 assert( alts.size() == 1 ); 85 assert(alts.front().expr != 0 ); 86 current.push_back( finder.get_alternatives().front() ); 87 solved_assigns.push_back( alts.front().expr->clone() ); 88 //solved_assigns.back()->print(std::cerr); 89 /*} catch( ... ) { 90 continue; // no reasonable alternative found 91 }*/ 92 } 93 options.add_option( current ); 94 95 return true; 96 } else { // mass assignment 97 //if ( new_assigns.empty() ) return false; 98 std::list< Expression * > solved_assigns; 99 ResolvExpr::AltList solved_alts; 100 assert( currentFinder != 0 ); 101 102 ResolvExpr::AltList current; 103 if ( optMass.empty() ) { 104 for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i ) 105 optMass.push_back( ResolvExpr::AltList() ); 106 } 107 int cnt = 0; 108 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) { 109 110 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() ); 111 finder.findWithAdjustment(*i); 112 ResolvExpr::AltList alts = finder.get_alternatives(); 113 assert( alts.size() == 1 ); 114 assert(alts.front().expr != 0 ); 115 current.push_back( finder.get_alternatives().front() ); 116 optMass[cnt].push_back( finder.get_alternatives().front() ); 117 solved_assigns.push_back( alts.front().expr->clone() ); 118 } 119 120 return true; 121 } 122 123 return false; 124 } 125 126 bool TupleAssignSpotter::isMVR( Expression *expr ) { 127 if ( expr->get_results().size() > 1 ) { 128 // MVR processing 129 return true; 130 } 131 return false; 132 } 133 134 bool TupleAssignSpotter::isTupleAssignment( UntypedExpr * expr, std::list<ResolvExpr::AltList> &possibilities ) { 135 if ( NameExpr *assgnop = dynamic_cast< NameExpr * >(expr->get_function()) ) { 136 137 if ( assgnop->get_name() == std::string("?=?") ) { 138 139 for ( std::list<ResolvExpr::AltList>::iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) { 140 assert( ali->size() == 2 ); 141 ResolvExpr::AltList::iterator opit = ali->begin(); 142 ResolvExpr::Alternative op1 = *opit, op2 = *(++opit); 143 144 if ( pointsToTuple(op1.expr) ) { // also handles tuple vars 145 if ( isTuple( op2.expr, true ) ) 146 matcher = new MultipleAssignMatcher(op1.expr, op2.expr); 147 else if ( isMVR( op2.expr ) ) { 148 // handle MVR differently 149 } else 97 void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) { 98 TupleAssignSpotter spotter( currentFinder ); 99 spotter.spot( expr, possibilities ); 100 } 101 102 TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder &f ) 103 : currentFinder(f) {} 104 105 void TupleAssignSpotter::spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) { 106 if ( NameExpr *op = dynamic_cast< NameExpr * >(expr->get_function()) ) { 107 if ( InitTweak::isCtorDtorAssign( op->get_name() ) ) { 108 fname = op->get_name(); 109 for ( std::list<ResolvExpr::AltList>::const_iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) { 110 if ( ali->size() == 0 ) continue; // AlternativeFinder will natrually handle this case, if it's legal 111 if ( ali->size() <= 1 && InitTweak::isAssignment( op->get_name() ) ) { 112 // what does it mean if an assignment takes 1 argument? maybe someone defined such a function, in which case AlternativeFinder will naturally handle it 113 continue; 114 } 115 116 assert( ! ali->empty() ); 117 // grab args 2-N and group into a TupleExpr 118 const ResolvExpr::Alternative & alt1 = ali->front(); 119 auto begin = std::next(ali->begin(), 1), end = ali->end(); 120 if ( pointsToTuple(alt1.expr) ) { 121 if ( isMultAssign( begin, end ) ) { 122 matcher.reset( new MultipleAssignMatcher( *this, *ali ) ); 123 } else { 150 124 // mass assignment 151 matcher = new MassAssignMatcher(op1.expr, op2.expr); 152 153 std::list< ResolvExpr::AltList > options; 154 if ( match() ) 155 /* 156 if ( hasMatched ) { 157 // throw SemanticError("Ambiguous tuple assignment"); 158 } else {*/ 159 // Matched for the first time 160 hasMatched = true; 161 /*} */ 162 } /* else if ( isTuple( op2 ) ) 163 throw SemanticError("Inapplicable tuple assignment."); 164 */ 165 } 166 167 if ( hasMatched ) { 168 if ( dynamic_cast<TupleAssignSpotter::MultipleAssignMatcher *>( matcher ) ) { 169 //options.print( std::cerr ); 170 std::list< ResolvExpr::AltList >best = options.get_best(); 171 if ( best.size() == 1 ) { 172 std::list<Expression *> solved_assigns; 173 for ( ResolvExpr::AltList::iterator i = best.front().begin(); i != best.front().end(); ++i ) { 174 solved_assigns.push_back( i->expr ); 175 } 176 /* assigning cost zero? */ 177 currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MULTIPLE*/), currentFinder->get_environ(), ResolvExpr::Cost() ) ); 125 matcher.reset( new MassAssignMatcher( *this, *ali ) ); 178 126 } 179 } else { 180 assert( ! optMass.empty() ); 181 ResolvExpr::AltList winners; 182 for ( std::vector< ResolvExpr::AltList >::iterator i = optMass.begin(); i != optMass.end(); ++i ) 183 findMinCostAlt( i->begin(), i->end(), back_inserter(winners) ); 184 185 std::list< Expression *> solved_assigns; 186 for ( ResolvExpr::AltList::iterator i = winners.begin(); i != winners.end(); ++i ) 187 solved_assigns.push_back( i->expr ); 188 currentFinder->get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns/*, SolvedTupleExpr::MASS*/), currentFinder->get_environ(), ResolvExpr::Cost() ) ); 127 match(); 189 128 } 190 129 } 191 130 } 192 131 } 193 return hasMatched; 194 } 195 196 void TupleAssignSpotter::Matcher::init( Expression *_lhs, Expression *_rhs ) { 197 lhs.clear(); 198 if (AddressExpr *addr = dynamic_cast<AddressExpr *>(_lhs) ) 199 if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(addr->get_arg()) ) 200 std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(lhs) ); 201 202 rhs.clear(); 203 } 204 205 TupleAssignSpotter::Matcher::Matcher( /*TupleAssignSpotter &spot,*/ Expression *_lhs, Expression *_rhs ) /*: own_spotter(spot) */{ 206 init(_lhs,_rhs); 207 } 208 209 TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( Expression *_lhs, Expression *_rhs )/* : own_spotter(spot) */{ 210 init(_lhs,_rhs); 211 212 if ( TupleExpr *tuple = dynamic_cast<TupleExpr *>(_rhs) ) 213 std::copy( tuple->get_exprs().begin(), tuple->get_exprs().end(), back_inserter(rhs) ); 214 } 215 216 UntypedExpr *TupleAssignSpotter::Matcher::createAssgn( Expression *left, Expression *right ) { 217 if ( left && right ) { 218 std::list< Expression * > args; 219 args.push_back(new AddressExpr(left->clone())); args.push_back(right->clone()); 220 return new UntypedExpr(new NameExpr("?=?"), args); 221 } else 222 throw 0; // xxx - diagnose the problem 223 } 224 225 bool TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) { 226 if ( lhs.empty() || (rhs.size() != 1) ) return false; 227 228 for ( std::list< Expression * >::iterator l = lhs.begin(); l != lhs.end(); l++ ) { 229 std::list< Expression * > args; 230 args.push_back( new AddressExpr(*l) ); 231 args.push_back( rhs.front() ); 232 out.push_back( new UntypedExpr(new NameExpr("?=?"), args) ); 233 } 234 235 return true; 236 } 237 238 bool TupleAssignSpotter::MassAssignMatcher::solve( std::list< Expression * > &assigns ) { 239 /* 240 std::list< Expression * > solved_assigns; 241 ResolvExpr::AltList solved_alts; 242 assert( currentFinder != 0 ); 243 244 ResolvExpr::AltList current; 245 if ( optMass.empty() ) { 246 for ( std::list< Expression * >::size_type i = 0; i != new_assigns.size(); ++i ) 247 optMass.push_back( ResolvExpr::AltList() ); 248 } 249 int cnt = 0; 250 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i, cnt++ ) { 251 252 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() ); 253 finder.findWithAdjustment(*i); 254 ResolvExpr::AltList alts = finder.get_alternatives(); 255 assert( alts.size() == 1 ); 256 assert(alts.front().expr != 0 ); 257 current.push_back( finder.get_alternatives().front() ); 258 optMass[cnt].push_back( finder.get_alternatives().front() ); 259 solved_assigns.push_back( alts.front().expr->clone() ); 260 } 261 */ 262 return true; 263 } 264 265 bool TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) { 266 // need more complicated matching 132 } 133 134 void TupleAssignSpotter::match() { 135 assert ( matcher != 0 ); 136 137 std::list< Expression * > new_assigns; 138 matcher->match( new_assigns ); 139 140 if ( new_assigns.empty() ) return; 141 ResolvExpr::AltList current; 142 // now resolve new assignments 143 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) { 144 ResolvExpr::AlternativeFinder finder( currentFinder.get_indexer(), currentFinder.get_environ() ); 145 try { 146 finder.findWithAdjustment(*i); 147 } catch (...) { 148 return; // xxx - no match should not mean failure, it just means this particular tuple assignment isn't valid 149 } 150 // prune expressions that don't coincide with 151 ResolvExpr::AltList alts = finder.get_alternatives(); 152 assert( alts.size() == 1 ); 153 assert( alts.front().expr != 0 ); 154 current.push_back( alts.front() ); 155 } 156 157 // extract expressions from the assignment alternatives to produce a list of assignments that 158 // together form a single alternative 159 std::list< Expression *> solved_assigns; 160 for ( ResolvExpr::Alternative & alt : current ) { 161 solved_assigns.push_back( alt.expr->clone() ); 162 } 163 // xxx - need to do this?? 164 ResolvExpr::TypeEnvironment compositeEnv; 165 simpleCombineEnvironments( current.begin(), current.end(), compositeEnv ); 166 currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), compositeEnv, ResolvExpr::sumCost( current ) ) ); 167 } 168 169 TupleAssignSpotter::Matcher::Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList &alts ) : spotter(spotter) { 170 assert( ! alts.empty() ); 171 ResolvExpr::Alternative lhsAlt = alts.front(); 172 // peel off the cast that exists on ctor/dtor expressions 173 bool isCast = false; 174 if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( lhsAlt.expr ) ) { 175 lhsAlt.expr = castExpr->get_arg(); 176 castExpr->set_arg( nullptr ); 177 delete castExpr; 178 isCast = true; 179 } 180 181 // explode the lhs so that each field of the tuple-valued-expr is assigned. 182 explode( lhsAlt, spotter.currentFinder.get_indexer(), back_inserter(lhs) ); 183 184 // and finally, re-add the cast to each lhs expr, so that qualified tuple fields can be constructed 185 if ( isCast ) { 186 for ( ResolvExpr::Alternative & alt : lhs ) { 187 Expression *& expr = alt.expr; 188 Type * castType = expr->get_result()->clone(); 189 Type * type = InitTweak::getPointerBase( castType ); 190 assert( type ); 191 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true); 192 type->set_isLvalue( true ); // xxx - might not need this 193 expr = new CastExpr( expr, castType ); 194 } 195 } 196 } 197 198 TupleAssignSpotter::MassAssignMatcher::MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) { 199 assert( alts.size() == 1 || alts.size() == 2 ); 200 if ( alts.size() == 2 ) { 201 rhs.push_back( alts.back() ); 202 } 203 } 204 205 TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) { 206 // explode the rhs so that each field of the tuple-valued-expr is assigned. 207 explode( std::next(alts.begin(), 1), alts.end(), spotter.currentFinder.get_indexer(), back_inserter(rhs) ); 208 } 209 210 UntypedExpr * createFunc( const std::string &fname, ObjectDecl *left, ObjectDecl *right ) { 211 assert( left ); 212 std::list< Expression * > args; 213 args.push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( left ) ) ) ); 214 // args.push_back( new AddressExpr( new VariableExpr( left ) ) ); 215 if ( right ) args.push_back( new VariableExpr( right ) ); 216 return new UntypedExpr( new NameExpr( fname ), args ); 217 } 218 219 ObjectDecl * newObject( UniqueName & namer, Expression * expr ) { 220 assert( expr->has_result() && ! expr->get_result()->isVoid() ); 221 return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 222 } 223 224 void TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) { 225 static UniqueName lhsNamer( "__massassign_L" ); 226 static UniqueName rhsNamer( "__massassign_R" ); 227 assert ( ! lhs.empty() && rhs.size() <= 1); 228 229 ObjectDecl * rtmp = rhs.size() == 1 ? newObject( rhsNamer, rhs.front().expr ) : nullptr; 230 for ( ResolvExpr::Alternative & lhsAlt : lhs ) { 231 ObjectDecl * ltmp = newObject( lhsNamer, lhsAlt.expr ); 232 out.push_back( createFunc( spotter.fname, ltmp, rtmp ) ); 233 tmpDecls.push_back( ltmp ); 234 } 235 if ( rtmp ) tmpDecls.push_back( rtmp ); 236 } 237 238 void TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) { 239 static UniqueName lhsNamer( "__multassign_L" ); 240 static UniqueName rhsNamer( "__multassign_R" ); 241 242 // xxx - need more complicated matching? 267 243 if ( lhs.size() == rhs.size() ) { 268 zipWith( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), back_inserter(out), TupleAssignSpotter::Matcher::createAssgn ); 269 return true; 270 } //else 271 //std::cerr << "The length of (left, right) is: (" << lhs.size() << "," << rhs.size() << ")" << std::endl;*/ 272 return false; 273 } 274 275 bool TupleAssignSpotter::MultipleAssignMatcher::solve( std::list< Expression * > &assigns ) { 276 /* 277 std::list< Expression * > solved_assigns; 278 ResolvExpr::AltList solved_alts; 279 assert( currentFinder != 0 ); 280 281 ResolvExpr::AltList current; 282 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) { 283 //try { 284 ResolvExpr::AlternativeFinder finder( currentFinder->get_indexer(), currentFinder->get_environ() ); 285 finder.findWithAdjustment(*i); 286 // prune expressions that don't coincide with 287 ResolvExpr::AltList alts = finder.get_alternatives(); 288 assert( alts.size() == 1 ); 289 assert(alts.front().expr != 0 ); 290 current.push_back( finder.get_alternatives().front() ); 291 solved_assigns.push_back( alts.front().expr->clone() ); 292 //solved_assigns.back()->print(std::cerr); 293 //} catch( ... ) { 294 //continue; // no reasonable alternative found 295 //} 296 } 297 options.add_option( current ); 298 */ 299 300 return true; 301 } 302 303 void TupleAssignSpotter::Options::add_option( ResolvExpr::AltList &opt ) { 304 using namespace std; 305 306 options.push_back( opt ); 307 /* 308 vector< Cost > costs; 309 costs.reserve( opt.size() ); 310 transform( opt.begin(), opt.end(), back_inserter(costs), ptr_fun(extract_cost) ); 311 */ 312 // transpose matrix 313 if ( costMatrix.empty() ) 314 for ( unsigned int i = 0; i< opt.size(); ++i) 315 costMatrix.push_back( vector<ResolvExpr::Cost>() ); 316 317 int cnt = 0; 318 for ( ResolvExpr::AltList::iterator i = opt.begin(); i != opt.end(); ++i, cnt++ ) 319 costMatrix[cnt].push_back( i->cost ); 320 321 return; 322 } 323 324 std::list< ResolvExpr::AltList > TupleAssignSpotter::Options::get_best() { 325 using namespace std; 326 using namespace ResolvExpr; 327 list< ResolvExpr::AltList > ret; 328 list< multiset<int> > solns; 329 for ( vector< vector<Cost> >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) { 330 list<int> current; 331 findMinCost( i->begin(), i->end(), back_inserter(current) ); 332 solns.push_back( multiset<int>(current.begin(), current.end()) ); 333 } 334 // need to combine 335 multiset<int> result; 336 lift_intersection( solns.begin(), solns.end(), inserter( result, result.begin() ) ); 337 if ( result.size() != 1 ) 338 throw SemanticError("Ambiguous tuple expression"); 339 ret.push_back(get_option( *(result.begin() ))); 340 return ret; 341 } 342 343 void TupleAssignSpotter::Options::print( std::ostream &ostr ) { 344 using namespace std; 345 346 for ( vector< vector < ResolvExpr::Cost > >::iterator i = costMatrix.begin(); i != costMatrix.end(); ++i ) { 347 for ( vector < ResolvExpr::Cost >::iterator j = i->begin(); j != i->end(); ++j ) 348 ostr << *j << " " ; 349 ostr << std::endl; 350 } // for 351 return; 352 } 353 354 ResolvExpr::Cost extract_cost( ResolvExpr::Alternative &alt ) { 355 return alt.cost; 356 } 357 358 template< typename InputIterator, typename OutputIterator > 359 void TupleAssignSpotter::Options::findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 360 using namespace ResolvExpr; 361 std::list<int> alternatives; 362 363 // select the alternatives that have the minimum parameter cost 364 Cost minCost = Cost::infinity; 365 unsigned int index = 0; 366 for ( InputIterator i = begin; i != end; ++i, index++ ) { 367 if ( *i < minCost ) { 368 minCost = *i; 369 alternatives.clear(); 370 alternatives.push_back( index ); 371 } else if ( *i == minCost ) { 372 alternatives.push_back( index ); 373 } 374 } 375 std::copy( alternatives.begin(), alternatives.end(), out ); 376 } 377 378 template< class InputIterator, class OutputIterator > 379 void TupleAssignSpotter::Options::lift_intersection( InputIterator begin, InputIterator end, OutputIterator out ) { 380 if ( begin == end ) return; 381 InputIterator test = begin; 382 383 if (++test == end) 384 { copy(begin->begin(), begin->end(), out); return; } 385 386 387 std::multiset<int> cur; // InputIterator::value_type::value_type 388 copy( begin->begin(), begin->end(), inserter( cur, cur.begin() ) ); 389 390 while ( test != end ) { 391 std::multiset<int> temp; 392 set_intersection( cur.begin(), cur.end(), test->begin(), test->end(), inserter(temp,temp.begin()) ); 393 cur.clear(); 394 copy( temp.begin(), temp.end(), inserter(cur,cur.begin())); 395 ++test; 396 } 397 398 copy( cur.begin(), cur.end(), out ); 399 return; 400 } 401 402 ResolvExpr::AltList TupleAssignSpotter::Options::get_option( std::list< ResolvExpr::AltList >::size_type index ) { 403 if ( index >= options.size() ) 404 throw 0; // XXX 405 std::list< ResolvExpr::AltList >::iterator it = options.begin(); 406 for ( std::list< ResolvExpr::AltList >::size_type i = 0; i < index; ++i, ++it ); 407 return *it; 244 std::list< ObjectDecl * > ltmp; 245 std::list< ObjectDecl * > rtmp; 246 std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), []( ResolvExpr::Alternative & alt ){ 247 return newObject( lhsNamer, alt.expr ); 248 }); 249 std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), []( ResolvExpr::Alternative & alt ){ 250 return newObject( rhsNamer, alt.expr ); 251 }); 252 zipWith( ltmp.begin(), ltmp.end(), rtmp.begin(), rtmp.end(), back_inserter(out), [&](ObjectDecl * obj1, ObjectDecl * obj2 ) { return createFunc(spotter.fname, obj1, obj2); } ); 253 tmpDecls.splice( tmpDecls.end(), ltmp ); 254 tmpDecls.splice( tmpDecls.end(), rtmp ); 255 } 408 256 } 409 257 } // namespace Tuples -
src/Tuples/module.mk
r84118d8 rb726084 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 16 16 17 17 SRC += Tuples/TupleAssignment.cc \ 18 Tuples/NameMatcher.cc 18 Tuples/TupleExpansion.cc \ 19 Tuples/Explode.cc -
src/main.cc
r84118d8 rb726084 43 43 #include "Common/UnimplementedError.h" 44 44 #include "../config.h" 45 #include "Tuples/Tuples.h" 45 46 46 47 using namespace std; … … 236 237 OPTPRINT( "tweakInit" ) 237 238 InitTweak::genInit( translationUnit ); 238 239 OPTPRINT( "expandMemberTuples" ); 240 Tuples::expandMemberTuples( translationUnit ); 239 241 if ( libcfap ) { 240 242 // generate the bodies of cfa library functions … … 261 263 return 0; 262 264 } // if 265 266 OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 267 Tuples::expandUniqueExpr( translationUnit ); 263 268 264 269 OPTPRINT("instantiateGenerics") … … 277 282 OPTPRINT( "box" ) 278 283 GenPoly::box( translationUnit ); 284 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this? 285 Tuples::expandTuples( translationUnit ); 279 286 280 287 // print tree right before code generation
Note:
See TracChangeset
for help on using the changeset viewer.