Changes in / [47a8d17:3f0c6a5]
- Location:
- src
- Files:
-
- 2 added
- 5 deleted
- 60 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) (6 diffs)
-
GenPoly/Specialize.cc (modified) (4 diffs)
-
InitTweak/FixInit.cc (modified) (12 diffs)
-
InitTweak/GenInit.cc (modified) (10 diffs)
-
InitTweak/GenInit.h (modified) (2 diffs)
-
InitTweak/InitTweak.cc (modified) (3 diffs)
-
Makefile.in (modified) (12 diffs)
-
Parser/ExpressionNode.cc (modified) (1 diff)
-
Parser/ParseNode.h (modified) (2 diffs)
-
Parser/TypeData.cc (modified) (2 diffs)
-
Parser/parser.cc (modified) (559 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) (9 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) (2 diffs)
-
SynTree/AddressExpr.cc (modified) (2 diffs)
-
SynTree/ApplicationExpr.cc (modified) (2 diffs)
-
SynTree/CommaExpr.cc (modified) (1 diff)
-
SynTree/Expression.cc (modified) (20 diffs)
-
SynTree/Expression.h (modified) (8 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/Visitor.cc (modified) (11 diffs)
-
SynTree/Visitor.h (modified) (2 diffs)
-
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)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r47a8d17 r3f0c6a5 309 309 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 310 310 newExpr->get_args().push_back( *arg ); 311 assert( (*arg)->get_results().size() == 1 ); 312 Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() ); 311 Type * type = InitTweak::getPointerBase( (*arg)->get_result() ); 313 312 assert( type ); 314 newExpr-> get_results().push_back( type->clone() );313 newExpr->set_result( type->clone() ); 315 314 *arg = newExpr; 316 315 } // if … … 527 526 extension( castExpr ); 528 527 output << "("; 529 if ( castExpr->get_result s().empty() ) {528 if ( castExpr->get_result()->isVoid() ) { 530 529 output << "(void)" ; 531 } else if ( ! castExpr->get_result s().front()->get_isLvalue() ) {530 } else if ( ! castExpr->get_result()->get_isLvalue() ) { 532 531 // at least one result type of cast, but not an lvalue 533 532 output << "("; 534 output << genType( castExpr->get_result s().front(), "" );533 output << genType( castExpr->get_result(), "" ); 535 534 output << ")"; 536 535 } else { … … 640 639 } 641 640 642 void CodeGenerator::visit( TupleExpr * tupleExpr ) { }641 void CodeGenerator::visit( TupleExpr * tupleExpr ) { assert( false ); } 643 642 644 643 void CodeGenerator::visit( TypeExpr * typeExpr ) {} … … 654 653 asmExpr->get_operand()->accept( *this ); 655 654 output << " )"; 655 } 656 657 void CodeGenerator::visit( CompoundLiteralExpr *compLitExpr ) { 658 assert( compLitExpr->get_type() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) ); 659 output << "(" << genType( compLitExpr->get_type(), "" ) << ")"; 660 compLitExpr->get_initializer()->accept( *this ); 661 } 662 663 void CodeGenerator::visit( StmtExpr * stmtExpr ) { 664 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids(); 665 output << "({" << std::endl; 666 cur_indent += CodeGenerator::tabsize; 667 unsigned int numStmts = stmts.size(); 668 unsigned int i = 0; 669 for ( Statement * stmt : stmts ) { 670 output << indent << printLabels( stmt->get_labels() ); 671 if ( i+1 == numStmts ) { 672 // last statement in a statement expression needs to be handled specially - 673 // cannot cast to void, otherwise the expression statement has no value 674 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) { 675 exprStmt->get_expr()->accept( *this ); 676 output << ";" << endl; 677 ++i; 678 break; 679 } 680 } 681 stmt->accept( *this ); 682 output << endl; 683 if ( wantSpacing( stmt ) ) { 684 output << endl; 685 } // if 686 ++i; 687 } 688 cur_indent -= CodeGenerator::tabsize; 689 output << indent << "})"; 656 690 } 657 691 -
src/CodeGen/CodeGenerator.h
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 110 110 void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ); 111 111 /// Stores assignment operators from assertion list in local map of assignment operations 112 void findTypeOps( const std::list< TypeDecl *>&forall );112 void findTypeOps( const Type::ForallList &forall ); 113 113 void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ); 114 114 FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars ); … … 612 612 } 613 613 614 void Pass1::findTypeOps( const std::list< TypeDecl *>&forall ) {614 void Pass1::findTypeOps( const Type::ForallList &forall ) { 615 615 // what if a nested function uses an assignment operator? 616 616 // assignOps.clear(); 617 for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) {617 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) { 618 618 for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 619 619 std::string typeName; … … 680 680 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 681 681 std::list< FunctionType *> functions; 682 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {682 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 683 683 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 684 684 findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter ); … … 782 782 783 783 // add size/align for generic types to parameter list 784 if ( appExpr->get_function()->get_results().empty() ) return;785 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result s().front() );784 if ( ! appExpr->get_function()->has_result() ) return; 785 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result() ); 786 786 assert( funcType ); 787 787 … … 799 799 for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) { 800 800 VariableExpr *fnArgBase = getBaseVar( *fnArg ); 801 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue;802 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result s().front(), arg, exprTyVars, seenTypes );801 if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results 802 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes ); 803 803 } 804 804 } … … 890 890 Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 891 891 appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) ); 892 appExpr->set_function( new NameExpr( adapterName ) ); 892 appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr 893 893 894 894 return ret; … … 896 896 897 897 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 898 assert( ! arg->get_results().empty() );898 assert( arg->has_result() ); 899 899 if ( isPolyType( param, exprTyVars ) ) { 900 if ( isPolyType( arg->get_result s().front() ) ) {900 if ( isPolyType( arg->get_result() ) ) { 901 901 // if the argument's type is polymorphic, we don't need to box again! 902 902 return; 903 } else if ( arg->get_result s().front()->get_isLvalue() ) {903 } else if ( arg->get_result()->get_isLvalue() ) { 904 904 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 905 905 // xxx - need to test that this code is still reachable … … 946 946 void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) { 947 947 std::list< Expression *>::iterator cur = arg; 948 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {948 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 949 949 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 950 950 InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() ); … … 987 987 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 988 988 deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) ); 989 deref-> get_results().push_back( arg->get_type()->clone() );989 deref->set_result( arg->get_type()->clone() ); 990 990 return deref; 991 991 } // if … … 1013 1013 Statement *bodyStmt; 1014 1014 1015 std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin();1016 std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin();1017 std::list< TypeDecl *>::iterator realTyParam = adaptee->get_forall().begin();1015 Type::ForallList::iterator tyArg = realType->get_forall().begin(); 1016 Type::ForallList::iterator tyParam = adapterType->get_forall().begin(); 1017 Type::ForallList::iterator realTyParam = adaptee->get_forall().begin(); 1018 1018 for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) { 1019 1019 assert( tyArg != realType->get_forall().end() ); … … 1064 1064 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 1065 1065 std::list< FunctionType *> functions; 1066 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {1066 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 1067 1067 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 1068 1068 findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter ); … … 1124 1124 } // if 1125 1125 addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) ); 1126 addAssign-> get_results().front() = appExpr->get_results().front()->clone();1126 addAssign->set_result( appExpr->get_result()->clone() ); 1127 1127 if ( appExpr->get_env() ) { 1128 1128 addAssign->set_env( appExpr->get_env() ); … … 1138 1138 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) { 1139 1139 if ( varExpr->get_var()->get_name() == "?[?]" ) { 1140 assert( ! appExpr->get_results().empty() );1140 assert( appExpr->has_result() ); 1141 1141 assert( appExpr->get_args().size() == 2 ); 1142 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result s().front(), scopeTyVars, env );1143 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result s().front(), scopeTyVars, env );1142 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env ); 1143 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env ); 1144 1144 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers 1145 1145 UntypedExpr *ret = 0; … … 1161 1161 } // if 1162 1162 if ( baseType1 || baseType2 ) { 1163 ret-> get_results().push_front( appExpr->get_results().front()->clone() );1163 ret->set_result( appExpr->get_result()->clone() ); 1164 1164 if ( appExpr->get_env() ) { 1165 1165 ret->set_env( appExpr->get_env() ); … … 1171 1171 } // if 1172 1172 } else if ( varExpr->get_var()->get_name() == "*?" ) { 1173 assert( ! appExpr->get_results().empty() );1173 assert( appExpr->has_result() ); 1174 1174 assert( ! appExpr->get_args().empty() ); 1175 if ( isPolyType( appExpr->get_result s().front(), scopeTyVars, env ) ) {1175 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { 1176 1176 Expression *ret = appExpr->get_args().front(); 1177 delete ret->get_result s().front();1178 ret-> get_results().front() = appExpr->get_results().front()->clone();1177 delete ret->get_result(); 1178 ret->set_result( appExpr->get_result()->clone() ); 1179 1179 if ( appExpr->get_env() ) { 1180 1180 ret->set_env( appExpr->get_env() ); … … 1186 1186 } // if 1187 1187 } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) { 1188 assert( ! appExpr->get_results().empty() );1188 assert( appExpr->has_result() ); 1189 1189 assert( appExpr->get_args().size() == 1 ); 1190 if ( Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env ) ) {1191 Type *tempType = appExpr->get_result s().front()->clone();1190 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { 1191 Type *tempType = appExpr->get_result()->clone(); 1192 1192 if ( env ) { 1193 1193 env->apply( tempType ); … … 1206 1206 } // if 1207 1207 } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) { 1208 assert( ! appExpr->get_results().empty() );1208 assert( appExpr->has_result() ); 1209 1209 assert( appExpr->get_args().size() == 1 ); 1210 if ( Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env ) ) {1210 if ( Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ) ) { 1211 1211 return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" ); 1212 1212 } // if 1213 1213 } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) { 1214 assert( ! appExpr->get_results().empty() );1214 assert( appExpr->has_result() ); 1215 1215 assert( appExpr->get_args().size() == 2 ); 1216 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result s().front(), scopeTyVars, env );1217 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result s().front(), scopeTyVars, env );1216 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result(), scopeTyVars, env ); 1217 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result(), scopeTyVars, env ); 1218 1218 if ( baseType1 && baseType2 ) { 1219 1219 UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) ); 1220 1220 divide->get_args().push_back( appExpr ); 1221 1221 divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) ); 1222 divide-> get_results().push_front( appExpr->get_results().front()->clone() );1222 divide->set_result( appExpr->get_result()->clone() ); 1223 1223 if ( appExpr->get_env() ) { 1224 1224 divide->set_env( appExpr->get_env() ); … … 1238 1238 } // if 1239 1239 } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) { 1240 assert( ! appExpr->get_results().empty() );1240 assert( appExpr->has_result() ); 1241 1241 assert( appExpr->get_args().size() == 2 ); 1242 Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env );1242 Type *baseType = isPolyPtr( appExpr->get_result(), scopeTyVars, env ); 1243 1243 if ( baseType ) { 1244 1244 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); … … 1266 1266 useRetval = oldUseRetval; 1267 1267 1268 assert( ! appExpr->get_function()->get_results().empty() ); 1269 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1270 assert( pointer ); 1271 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1272 assert( function ); 1268 assert( appExpr->get_function()->has_result() ); 1269 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() ); 1270 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() ); 1273 1271 1274 1272 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1308 1306 1309 1307 Expression *Pass1::mutate( UntypedExpr *expr ) { 1310 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {1308 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1311 1309 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1312 1310 if ( name->get_name() == "*?" ) { … … 1322 1320 1323 1321 Expression *Pass1::mutate( AddressExpr *addrExpr ) { 1324 assert( ! addrExpr->get_arg()->get_results().empty() );1322 assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() ); 1325 1323 1326 1324 bool needs = false; 1327 1325 if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) { 1328 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {1326 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1329 1327 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1330 1328 if ( name->get_name() == "*?" ) { 1331 1329 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 1332 assert( ! appExpr->get_function()->get_results().empty() ); 1333 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1334 assert( pointer ); 1335 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1336 assert( function ); 1330 assert( appExpr->get_function()->has_result() ); 1331 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() ); 1332 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() ); 1337 1333 needs = needsAdapter( function, scopeTyVars ); 1338 1334 } // if … … 1343 1339 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward 1344 1340 // out of the if condition. 1345 bool polytype = isPolyType( addrExpr->get_arg()->get_result s().front(), scopeTyVars, env );1341 bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env ); 1346 1342 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1347 1343 if ( polytype || needs ) { 1348 1344 Expression *ret = addrExpr->get_arg(); 1349 delete ret->get_result s().front();1350 ret-> get_results().front() = addrExpr->get_results().front()->clone();1345 delete ret->get_result(); 1346 ret->set_result( addrExpr->get_result()->clone() ); 1351 1347 addrExpr->set_arg( 0 ); 1352 1348 delete addrExpr; … … 1386 1382 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1387 1383 if ( retval && returnStmt->get_expr() ) { 1388 assert( ! returnStmt->get_expr()->get_results().empty() );1384 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() ); 1389 1385 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 1390 1386 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { … … 1420 1416 // find each of its needed secondary assignment operators 1421 1417 std::list< Expression* > &tyParams = refType->get_parameters(); 1422 std::list< TypeDecl* >&forallParams = functionDecl->get_type()->get_forall();1418 Type::ForallList &forallParams = functionDecl->get_type()->get_forall(); 1423 1419 std::list< Expression* >::const_iterator tyIt = tyParams.begin(); 1424 std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin();1420 Type::ForallList::const_iterator forallIt = forallParams.begin(); 1425 1421 for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) { 1426 1422 // Add appropriate mapping to assignment expression environment … … 1466 1462 // replace return statement with appropriate assignment to out parameter 1467 1463 Expression *retParm = new NameExpr( retval->get_name() ); 1468 retParm-> get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );1464 retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) ); 1469 1465 assignExpr->get_args().push_back( retParm ); 1470 1466 assignExpr->get_args().push_back( returnStmt->get_expr() ); … … 1596 1592 ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, 1597 1593 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); 1598 for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {1594 for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { 1599 1595 ObjectDecl *sizeParm, *alignParm; 1600 1596 // add all size and alignment parameters to parameter list -
src/GenPoly/CopyParams.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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 ); … … 99 99 appExpr->get_function()->acceptMutator( *this ); 100 100 mutateAll( appExpr->get_args(), *this ); 101 102 assert( ! appExpr->get_function()->get_results().empty() );103 101 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 ); 102 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 103 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 108 104 109 105 Type *funType = isLvalueRet( function ); 110 106 if ( funType && ! isIntrinsicApp( appExpr ) ) { 111 107 Expression *expr = appExpr; 112 Type *appType = appExpr->get_result s().front();108 Type *appType = appExpr->get_result(); 113 109 if ( isPolyType( funType ) && ! isPolyType( appType ) ) { 114 110 // make sure cast for polymorphic type is inside dereference … … 116 112 } 117 113 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 118 deref-> get_results().push_back( appType->clone() );119 appExpr-> get_results().front() = new PointerType( Type::Qualifiers(), appType);114 deref->set_result( appType->clone() ); 115 appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) ); 120 116 deref->get_args().push_back( expr ); 121 117 return deref; … … 127 123 Statement * Pass1::mutate(ReturnStmt *retStmt) { 128 124 if ( retval && retStmt->get_expr() ) { 129 assert( ! retStmt->get_expr()->get_results().empty() ); 130 if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) { 125 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) { 131 126 // ***** Code Removal ***** because casts may be stripped already 132 127 … … 155 150 retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) ); 156 151 } // if 157 152 158 153 Visitor::visit( funType ); 159 154 } -
src/GenPoly/Specialize.cc
r47a8d17 r3f0c6a5 147 147 148 148 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 149 assert( ! actual->get_results().empty() ); // using front, should have this assert150 if ( needsSpecialization( formalType, actual->get_result s().front(), env ) ) {149 assert( actual->has_result() ); 150 if ( needsSpecialization( formalType, actual->get_result(), env ) ) { 151 151 FunctionType *funType; 152 152 if ( ( funType = getFunctionType( formalType ) ) ) { … … 171 171 void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) { 172 172 // create thunks for the explicit parameters 173 assert( ! appExpr->get_function()->get_results().empty() );174 FunctionType *function = getFunctionType( appExpr->get_function()->get_result s().front() );173 assert( appExpr->get_function()->has_result() ); 174 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() ); 175 175 assert( function ); 176 176 std::list< DeclarationWithType* >::iterator formal; … … 200 200 Expression * Specialize::mutate( AddressExpr *addrExpr ) { 201 201 addrExpr->get_arg()->acceptMutator( *this ); 202 assert( ! addrExpr->get_results().empty() );203 addrExpr->set_arg( doSpecialization( addrExpr->get_result s().front(), addrExpr->get_arg() ) );202 assert( addrExpr->has_result() ); 203 addrExpr->set_arg( doSpecialization( addrExpr->get_result(), addrExpr->get_arg() ) ); 204 204 return addrExpr; 205 205 } … … 207 207 Expression * Specialize::mutate( CastExpr *castExpr ) { 208 208 castExpr->get_arg()->acceptMutator( *this ); 209 if ( castExpr->get_result s().empty() ) {209 if ( castExpr->get_result()->isVoid() ) { 210 210 // can't specialize if we don't have a return value 211 211 return castExpr; 212 212 } 213 Expression *specialized = doSpecialization( castExpr->get_result s().front(), castExpr->get_arg() );213 Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() ); 214 214 if ( specialized != castExpr->get_arg() ) { 215 215 // assume here that the specialization incorporates the cast -
src/InitTweak/FixInit.cc
r47a8d17 r3f0c6a5 35 35 #include "GenPoly/DeclMutator.h" 36 36 #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; 37 #include "CodeGen/GenType.h" // for warning/error messages 38 39 bool ctordtorp = false; // print all debug 40 bool ctorp = false; // print ctor debug 41 bool cpctorp = false; // print copy ctor debug 42 bool dtorp = false; // print dtor debug 43 43 #define PRINT( text ) if ( ctordtorp ) { text } 44 44 #define CP_CTOR_PRINT( text ) if ( ctordtorp || cpctorp ) { text } … … 47 47 namespace InitTweak { 48 48 namespace { 49 const std::list<Label> noLabels;50 const std::list<Expression*> noDesignators;51 52 49 class InsertImplicitCalls : public GenPoly::PolyMutator { 53 50 public: … … 69 66 70 67 /// create and resolve ctor/dtor expression: fname(var, [cpArg]) 71 ApplicationExpr * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL ); 68 Expression * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL ); 69 Expression * makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg = NULL ); 72 70 /// true if type does not need to be copy constructed to ensure correctness 73 bool skipCopyConstruct( Type * ); 71 bool skipCopyConstruct( Type * type ); 72 void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ); 73 void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ); 74 74 private: 75 75 TypeSubstitution * env; … … 357 357 } 358 358 359 ApplicationExpr* ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {359 Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) { 360 360 assert( var ); 361 return makeCtorDtor( fname, new AddressExpr( new VariableExpr( var ) ), cpArg ); 362 } 363 364 Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, Expression * thisArg, Expression * cpArg ) { 365 assert( thisArg ); 361 366 UntypedExpr * untyped = new UntypedExpr( new NameExpr( fname ) ); 362 untyped->get_args().push_back( new AddressExpr( new VariableExpr( var ) ));367 untyped->get_args().push_back( thisArg ); 363 368 if (cpArg) untyped->get_args().push_back( cpArg->clone() ); 364 369 … … 367 372 // (VariableExpr and already resolved expression) 368 373 CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; ) 369 ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) ); 374 Expression * resolved = ResolvExpr::findVoidExpression( untyped, *this ); 375 assert( resolved ); 370 376 if ( resolved->get_env() ) { 371 377 env->add( *resolved->get_env() ); 372 378 } // if 373 379 374 assert( resolved );375 380 delete untyped; 376 381 return resolved; 377 382 } 378 383 384 void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) { 385 static UniqueName tempNamer("_tmp_cp"); 386 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; ) 387 assert( arg->has_result() ); 388 Type * result = arg->get_result(); 389 if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types 390 391 // type may involve type variables, so apply type substitution to get temporary variable's actual type 392 result = result->clone(); 393 impCpCtorExpr->get_env()->apply( result ); 394 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 395 tmp->get_type()->set_isConst( false ); 396 397 // create and resolve copy constructor 398 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; ) 399 Expression * cpCtor = makeCtorDtor( "?{}", tmp, arg ); 400 401 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( cpCtor ) ) { 402 // if the chosen constructor is intrinsic, the copy is unnecessary, so 403 // don't create the temporary and don't call the copy constructor 404 VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() ); 405 assert( function ); 406 if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return; 407 } 408 409 // replace argument to function call with temporary 410 arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) ); 411 impCpCtorExpr->get_tempDecls().push_back( tmp ); 412 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) ); 413 } 414 415 void ResolveCopyCtors::destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ) { 416 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", new AddressExpr( ret ) ) ); 417 } 418 379 419 void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) { 380 static UniqueName tempNamer("_tmp_cp");381 static UniqueName retNamer("_tmp_cp_ret");382 383 420 CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; ) 384 421 Visitor::visit( impCpCtorExpr ); … … 389 426 // take each argument and attempt to copy construct it. 390 427 for ( Expression * & arg : appExpr->get_args() ) { 391 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; ) 392 // xxx - need to handle tuple arguments 393 assert( ! arg->get_results().empty() ); 394 Type * result = arg->get_results().front(); 395 if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types 396 // type may involve type variables, so apply type substitution to get temporary variable's actual type 397 result = result->clone(); 398 impCpCtorExpr->get_env()->apply( result ); 399 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 400 tmp->get_type()->set_isConst( false ); 401 402 // create and resolve copy constructor 403 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; ) 404 ApplicationExpr * cpCtor = makeCtorDtor( "?{}", tmp, arg ); 405 406 // if the chosen constructor is intrinsic, the copy is unnecessary, so 407 // don't create the temporary and don't call the copy constructor 408 VariableExpr * function = dynamic_cast< VariableExpr * >( cpCtor->get_function() ); 409 assert( function ); 410 if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) { 411 // replace argument to function call with temporary 412 arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) ); 413 impCpCtorExpr->get_tempDecls().push_back( tmp ); 414 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) ); 415 } // if 428 copyConstructArg( arg, impCpCtorExpr ); 416 429 } // for 417 430 … … 423 436 // level. Trying to pass that environment along. 424 437 callExpr->set_env( impCpCtorExpr->get_env()->clone() ); 425 for ( Type * result : appExpr->get_results() ) { 438 Type * result = appExpr->get_result(); 439 if ( ! result->isVoid() ) { 440 static UniqueName retNamer("_tmp_cp_ret"); 426 441 result = result->clone(); 427 442 impCpCtorExpr->get_env()->apply( result ); … … 430 445 impCpCtorExpr->get_returnDecls().push_back( ret ); 431 446 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 432 impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ));447 destructRet( new VariableExpr( ret ) , impCpCtorExpr ); 433 448 } // for 434 449 CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; ) … … 479 494 // know the result type of the assignment is the type of the LHS (minus the pointer), so 480 495 // add that onto the assignment expression so that later steps have the necessary information 481 assign-> add_result( returnDecl->get_type()->clone() );496 assign->set_result( returnDecl->get_type()->clone() ); 482 497 483 498 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 484 if ( callExpr->get_result s().front()->get_isLvalue() ) {499 if ( callExpr->get_result()->get_isLvalue() ) { 485 500 // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning 486 501 // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the … … 500 515 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 501 516 deref->get_args().push_back( retExpr ); 502 deref-> add_result( resultType );517 deref->set_result( resultType ); 503 518 retExpr = deref; 504 519 } // if … … 939 954 Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) { 940 955 static UniqueName tempNamer( "_tmp_ctor_expr" ); 941 assert( ctorExpr->get_results().size() == 1 ); 942 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr ); 956 // xxx - is the size check necessary? 957 assert( ctorExpr->has_result() && ctorExpr->get_result()->size() == 1 ); 958 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr ); 943 959 addDeclaration( tmp ); 944 960 … … 952 968 assign->get_args().push_back( new VariableExpr( tmp ) ); 953 969 assign->get_args().push_back( firstArg ); 954 cloneAll( ctorExpr->get_results(), assign->get_results() );970 assign->set_result( ctorExpr->get_result()->clone() ); 955 971 firstArg = assign; 956 972 -
src/InitTweak/GenInit.cc
r47a8d17 r3f0c6a5 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; … … 134 136 135 137 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) { 136 // update for multiple return values138 std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals(); 137 139 assert( returnVals.size() == 0 || returnVals.size() == 1 ); 138 140 // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address … … 156 158 157 159 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 158 ValueGuard< std::list<DeclarationWithType*> > oldReturnVals( returnVals ); 160 // xxx - need to handle named return values - this pass may need to happen 161 // after resolution? the ordering is tricky because return statements must be 162 // constructed - the simplest way to do that (while also handling multiple 163 // returns) is to structure the returnVals into a tuple, as done here. 164 // however, if the tuple return value is structured before resolution, 165 // it's difficult to resolve named return values, since the name is lost 166 // in conversion to a tuple. this might be easiest to deal with 167 // after reference types are added, as it may then be possible to 168 // uniformly move named return values to the parameter list directly 169 ValueGuard< FunctionType * > oldFtype( ftype ); 159 170 ValueGuard< std::string > oldFuncName( funcName ); 160 171 161 FunctionType * type = functionDecl->get_functionType(); 162 returnVals = type->get_returnVals(); 172 ftype = functionDecl->get_functionType(); 173 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals(); 174 if ( retVals.size() > 1 ) { 175 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 176 ObjectDecl * newRet = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 177 retVals.clear(); 178 retVals.push_back( newRet ); 179 } 163 180 funcName = functionDecl->get_name(); 164 181 DeclarationWithType * decl = Mutator::mutate( functionDecl ); … … 220 237 } 221 238 239 bool CtorDtor::isManaged( Type * type ) const { 240 if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) { 241 // tuple is also managed if any of its components are managed 242 if ( std::any_of( tupleType->get_types().begin(), tupleType->get_types().end(), [&](Type * type) { return isManaged( type ); }) ) { 243 return true; 244 } 245 } 246 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end(); 247 } 248 222 249 bool CtorDtor::isManaged( ObjectDecl * objDecl ) const { 223 250 Type * type = objDecl->get_type(); … … 225 252 type = at->get_base(); 226 253 } 227 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();254 return isManaged( type ); 228 255 } 229 256 … … 236 263 managedTypes.insert( SymTab::Mangler::mangle( type->get_base() ) ); 237 264 } 265 } 266 267 ConstructorInit * genCtorInit( ObjectDecl * objDecl ) { 268 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor 269 // for each constructable object 270 std::list< Statement * > ctor; 271 std::list< Statement * > dtor; 272 273 InitExpander srcParam( objDecl->get_init() ); 274 InitExpander nullParam( (Initializer *)NULL ); 275 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl ); 276 SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false ); 277 278 // Currently genImplicitCall produces a single Statement - a CompoundStmt 279 // which wraps everything that needs to happen. As such, it's technically 280 // possible to use a Statement ** in the above calls, but this is inherently 281 // unsafe, so instead we take the slightly less efficient route, but will be 282 // immediately informed if somehow the above assumption is broken. In this case, 283 // we could always wrap the list of statements at this point with a CompoundStmt, 284 // but it seems reasonable at the moment for this to be done by genImplicitCall 285 // itself. It is possible that genImplicitCall produces no statements (e.g. if 286 // an array type does not have a dimension). In this case, it's fine to ignore 287 // the object for the purposes of construction. 288 assert( ctor.size() == dtor.size() && ctor.size() <= 1 ); 289 if ( ctor.size() == 1 ) { 290 // need to remember init expression, in case no ctors exist 291 // if ctor does exist, want to use ctor expression instead of init 292 // push this decision to the resolver 293 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) ); 294 return new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ); 295 } 296 return nullptr; 238 297 } 239 298 … … 248 307 if ( ! checkInitDepth( objDecl ) ) throw SemanticError( "Managed object's initializer is too deep ", objDecl ); 249 308 250 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor 251 // for each constructable object 252 std::list< Statement * > ctor; 253 std::list< Statement * > dtor; 254 255 InitExpander srcParam( objDecl->get_init() ); 256 InitExpander nullParam( (Initializer *)NULL ); 257 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl ); 258 SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false ); 259 260 // Currently genImplicitCall produces a single Statement - a CompoundStmt 261 // which wraps everything that needs to happen. As such, it's technically 262 // possible to use a Statement ** in the above calls, but this is inherently 263 // unsafe, so instead we take the slightly less efficient route, but will be 264 // immediately informed if somehow the above assumption is broken. In this case, 265 // we could always wrap the list of statements at this point with a CompoundStmt, 266 // but it seems reasonable at the moment for this to be done by genImplicitCall 267 // itself. It is possible that genImplicitCall produces no statements (e.g. if 268 // an array type does not have a dimension). In this case, it's fine to ignore 269 // the object for the purposes of construction. 270 assert( ctor.size() == dtor.size() && ctor.size() <= 1 ); 271 if ( ctor.size() == 1 ) { 272 // need to remember init expression, in case no ctors exist 273 // if ctor does exist, want to use ctor expression instead of init 274 // push this decision to the resolver 275 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) ); 276 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) ); 277 } 309 objDecl->set_init( genCtorInit( objDecl ) ); 278 310 } 279 311 return Parent::mutate( objDecl ); … … 288 320 managedTypes.beginScope(); 289 321 // go through assertions and recursively add seen ctor/dtors 290 for ( TypeDecl *tyDecl : functionDecl->get_functionType()->get_forall() ) {322 for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) { 291 323 for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) { 292 324 assertion = assertion->acceptMutator( *this ); -
src/InitTweak/GenInit.h
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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) \ … … 191 190 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \ 192 191 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) \ 193 Tuples/driver_cfa_cpp- NameMatcher.$(OBJEXT)192 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) 194 193 am_driver_cfa_cpp_OBJECTS = $(am__objects_1) 195 194 driver_cfa_cpp_OBJECTS = $(am_driver_cfa_cpp_OBJECTS) … … 365 364 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 366 365 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 367 ControlStruct/ForExprMutator.cc \ 368 ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \ 366 ControlStruct/ForExprMutator.cc GenPoly/Box.cc \ 369 367 GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ 370 368 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ … … 406 404 SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \ 407 405 SynTree/Attribute.cc Tuples/TupleAssignment.cc \ 408 Tuples/ NameMatcher.cc406 Tuples/TupleExpansion.cc 409 407 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 410 408 ${cfa_cpplib_PROGRAMS}} … … 541 539 ControlStruct/$(DEPDIR)/$(am__dirstamp) 542 540 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT): \ 543 ControlStruct/$(am__dirstamp) \544 ControlStruct/$(DEPDIR)/$(am__dirstamp)545 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT): \546 541 ControlStruct/$(am__dirstamp) \ 547 542 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 777 772 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT): \ 778 773 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 779 Tuples/driver_cfa_cpp- NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp)\780 Tuples/$( DEPDIR)/$(am__dirstamp)774 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT): \ 775 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 781 776 driver/$(am__dirstamp): 782 777 @$(MKDIR_P) driver … … 800 795 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) 801 796 -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) 802 -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)803 797 -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) 804 798 -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) … … 887 881 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) 888 882 -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) 889 -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)890 883 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) 884 -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) 891 885 892 886 distclean-compile: … … 907 901 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ 908 902 @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 903 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@ 911 904 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@ … … 994 987 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 995 988 @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@997 989 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ 990 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@ 998 991 999 992 .cc.o: … … 1237 1230 @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 1231 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 1232 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1254 1233 @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 … … 2441 2420 @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 2421 2443 Tuples/driver_cfa_cpp- NameMatcher.o: Tuples/NameMatcher.cc2444 @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.cc2445 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp- NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po2446 @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.cc2449 2450 Tuples/driver_cfa_cpp- NameMatcher.obj: Tuples/NameMatcher.cc2451 @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.Po2453 @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`2422 Tuples/driver_cfa_cpp-TupleExpansion.o: Tuples/TupleExpansion.cc 2423 @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 2424 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po 2425 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.o' libtool=no @AMDEPBACKSLASH@ 2426 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2427 @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 2428 2429 Tuples/driver_cfa_cpp-TupleExpansion.obj: Tuples/TupleExpansion.cc 2430 @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` 2431 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po 2432 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.obj' libtool=no @AMDEPBACKSLASH@ 2433 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2434 @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` 2456 2435 2457 2436 .ll.cc: -
src/Parser/ExpressionNode.cc
r47a8d17 r3f0c6a5 198 198 } 199 199 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 ) { 200 Expression *build_fieldSel( ExpressionNode *expr_node, Expression *member ) { 201 UntypedMemberExpr *ret = new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) ); 202 return ret; 203 } 204 205 Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) { 207 206 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 208 207 deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) ); 209 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref ); 210 delete member; 208 UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref ); 211 209 return ret; 212 210 } -
src/Parser/ParseNode.h
r47a8d17 r3f0c6a5 160 160 161 161 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 );162 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); 163 Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ); 164 164 Expression * build_addressOf( ExpressionNode * expr_node ); 165 165 Expression * build_sizeOfexpr( ExpressionNode * expr_node ); … … 383 383 //############################################################################## 384 384 385 template< typename SynTreeType, typename NodeType >386 void buildList( const NodeType * firstNode, std::list< SynTreeType *> &outputList ) {385 template< typename SynTreeType, typename NodeType, template< typename, typename...> class Container, typename... Args > 386 void buildList( const NodeType * firstNode, Container< SynTreeType *, Args... > &outputList ) { 387 387 SemanticError errors; 388 std::back_insert_iterator< std::list< SynTreeType *> > out( outputList );388 std::back_insert_iterator< Container< SynTreeType *, Args... > > out( outputList ); 389 389 const NodeType * cur = firstNode; 390 390 -
src/Parser/TypeData.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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 46 5, 478, 480, 482, 484, 486, 488, 490, 492, 494,1035 49 6, 498, 505, 506, 512, 513, 514, 515, 519, 520,1036 52 7, 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 60 7, 614, 619, 620, 628, 629, 633, 634, 635, 636,1040 63 7, 638, 639, 640, 641, 642, 643, 644, 654, 656,1041 66 1, 662, 667, 668, 674, 675, 681, 682, 683, 684,1042 68 5, 686, 687, 688, 689, 699, 706, 708, 718, 719,1043 72 4, 726, 732, 734, 738, 739, 744, 749, 752, 754,1044 75 6, 766, 768, 779, 780, 782, 786, 788, 792, 793,1045 79 8, 799, 803, 808, 809, 813, 815, 821, 822, 826,1046 82 8, 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 98 6, 991, 993, 999, 1000, 1002, 1007, 1012, 1022, 1024,1052 102 8, 1029, 1034, 1036, 1040, 1041, 1045, 1047, 1051, 1052,1053 105 6, 1057, 1061, 1062, 1077, 1078, 1079, 1080, 1081, 1085,1054 109 0, 1097, 1107, 1112, 1117, 1125, 1130, 1135, 1140, 1145,1055 117 5, 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 130 6, 1307, 1312, 1313, 1318, 1320, 1322, 1324, 1326, 1329,1059 132 8, 1340, 1341, 1343, 1353, 1354, 1359, 1361, 1363, 1365,1060 136 7, 1370, 1372, 1375, 1380, 1382, 1384, 1386, 1388, 1390,1061 139 2, 1394, 1396, 1398, 1400, 1402, 1404, 1410, 1411, 1413,1062 141 5, 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 152 7, 1528, 1537, 1538, 1540, 1542, 1547, 1549, 1555, 1556,1067 155 8, 1561, 1564, 1569, 1570, 1575, 1580, 1584, 1586, 1592,1068 159 1, 1598, 1600, 1606, 1607, 1615, 1616, 1620, 1621, 1622,1069 162 4, 1626, 1633, 1634, 1636, 1638, 1643, 1644, 1650, 1651,1070 165 5, 1656, 1661, 1662, 1663, 1665, 1673, 1674, 1676, 1679,1071 168 1, 1685, 1686, 1687, 1689, 1691, 1695, 1700, 1708, 1709,1072 171 8, 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 179 8, 1799, 1805, 1807, 1810, 1812, 1814, 1837, 1838, 1840,1076 184 2, 1847, 1848, 1850, 1855, 1860, 1861, 1867, 1866, 1870,1077 187 4, 1876, 1878, 1884, 1885, 1890, 1895, 1897, 1902, 1904,1078 190 5, 1907, 1912, 1914, 1916, 1921, 1923, 1928, 1933, 1941,1079 194 7, 1946, 1960, 1961, 1966, 1967, 1971, 1976, 1981, 1989,1080 199 4, 2005, 2006, 2011, 2012, 2018, 2019, 2023, 2024, 2025,1081 202 8, 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 222 6, 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 239 4, 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 254 7, 2549, 2555, 2557, 2559, 2563, 2565, 2567, 2569, 2583,1095 258 4, 2586, 2591, 2593, 2595, 2597, 2599, 2604, 2605, 2607,1096 26 09, 2614, 2616, 2618, 2624, 2625, 2627, 2636, 2639, 2641,1097 264 4, 2646, 2648, 2661, 2662, 2664, 2669, 2671, 2673, 2675,1098 267 7, 2682, 2683, 2685, 2687, 2692, 2694, 2702, 2703, 2704,1099 27 09, 2710, 2714, 2716, 2718, 2720, 2722, 2724, 2731, 2733,1100 273 5, 2737, 2739, 2742, 2744, 2746, 2748, 2750, 2755, 2757,1101 27 59, 2764, 2790, 2791, 2793, 2797, 2798, 2802, 2804, 2806,1102 280 8, 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, 448, 450, 454, 457, 459, 461, 1034 466, 479, 481, 483, 485, 487, 489, 491, 493, 495, 1035 497, 499, 506, 507, 513, 514, 515, 516, 520, 521, 1036 528, 529, 531, 533, 538, 539, 541, 546, 547, 549, 1037 554, 555, 557, 559, 561, 566, 567, 569, 574, 575, 1038 580, 581, 586, 587, 592, 593, 598, 599, 604, 605, 1039 608, 615, 620, 621, 629, 630, 634, 635, 636, 637, 1040 638, 639, 640, 641, 642, 643, 644, 645, 655, 657, 1041 662, 663, 668, 669, 675, 676, 682, 683, 684, 685, 1042 686, 687, 688, 689, 690, 700, 707, 709, 719, 720, 1043 725, 727, 733, 735, 739, 740, 745, 750, 753, 755, 1044 757, 767, 769, 780, 781, 783, 787, 789, 793, 794, 1045 799, 800, 804, 809, 810, 814, 816, 822, 823, 827, 1046 829, 831, 833, 839, 840, 844, 846, 851, 853, 855, 1047 860, 862, 867, 869, 873, 876, 880, 883, 887, 889, 1048 891, 893, 898, 900, 902, 907, 909, 911, 913, 915, 1049 920, 922, 924, 926, 931, 943, 944, 949, 951, 956, 1050 960, 962, 964, 966, 968, 974, 975, 981, 982, 986, 1051 987, 992, 994, 1000, 1001, 1003, 1008, 1013, 1023, 1025, 1052 1029, 1030, 1035, 1037, 1041, 1042, 1046, 1048, 1052, 1053, 1053 1057, 1058, 1062, 1063, 1078, 1079, 1080, 1081, 1082, 1086, 1054 1091, 1098, 1108, 1113, 1118, 1126, 1131, 1136, 1141, 1146, 1055 1176, 1181, 1188, 1190, 1197, 1202, 1207, 1218, 1223, 1228, 1056 1233, 1238, 1247, 1252, 1260, 1261, 1262, 1263, 1269, 1274, 1057 1282, 1283, 1284, 1285, 1289, 1290, 1291, 1292, 1297, 1298, 1058 1307, 1308, 1313, 1314, 1319, 1321, 1323, 1325, 1327, 1330, 1059 1329, 1341, 1342, 1344, 1354, 1355, 1360, 1362, 1364, 1366, 1060 1368, 1371, 1373, 1376, 1381, 1383, 1385, 1387, 1389, 1391, 1061 1393, 1395, 1397, 1399, 1401, 1403, 1405, 1411, 1412, 1414, 1062 1416, 1418, 1423, 1424, 1430, 1431, 1433, 1435, 1440, 1442, 1063 1444, 1446, 1451, 1452, 1454, 1456, 1461, 1462, 1464, 1469, 1064 1470, 1472, 1474, 1479, 1481, 1483, 1488, 1489, 1493, 1495, 1065 1501, 1500, 1504, 1506, 1511, 1513, 1519, 1520, 1525, 1526, 1066 1528, 1529, 1538, 1539, 1541, 1543, 1548, 1550, 1556, 1557, 1067 1559, 1562, 1565, 1570, 1571, 1576, 1581, 1585, 1587, 1593, 1068 1592, 1599, 1601, 1607, 1608, 1616, 1617, 1621, 1622, 1623, 1069 1625, 1627, 1634, 1635, 1637, 1639, 1644, 1645, 1651, 1652, 1070 1656, 1657, 1662, 1663, 1664, 1666, 1674, 1675, 1677, 1680, 1071 1682, 1686, 1687, 1688, 1690, 1692, 1696, 1701, 1709, 1710, 1072 1719, 1721, 1726, 1727, 1728, 1732, 1733, 1734, 1738, 1739, 1073 1740, 1744, 1745, 1746, 1751, 1752, 1753, 1754, 1760, 1761, 1074 1763, 1768, 1769, 1774, 1775, 1776, 1777, 1778, 1793, 1794, 1075 1799, 1800, 1806, 1808, 1811, 1813, 1815, 1838, 1839, 1841, 1076 1843, 1848, 1849, 1851, 1856, 1861, 1862, 1868, 1867, 1871, 1077 1875, 1877, 1879, 1885, 1886, 1891, 1896, 1898, 1903, 1905, 1078 1906, 1908, 1913, 1915, 1917, 1922, 1924, 1929, 1934, 1942, 1079 1948, 1947, 1961, 1962, 1967, 1968, 1972, 1977, 1982, 1990, 1080 1995, 2006, 2007, 2012, 2013, 2019, 2020, 2024, 2025, 2026, 1081 2029, 2028, 2039, 2048, 2054, 2060, 2069, 2075, 2081, 2087, 1082 2093, 2101, 2107, 2115, 2121, 2130, 2131, 2132, 2136, 2140, 1083 2142, 2147, 2148, 2152, 2153, 2158, 2164, 2165, 2168, 2170, 1084 2171, 2175, 2176, 2177, 2178, 2212, 2214, 2215, 2217, 2222, 1085 2227, 2232, 2234, 2236, 2241, 2243, 2245, 2247, 2252, 2254, 1086 2263, 2265, 2266, 2271, 2273, 2275, 2280, 2282, 2284, 2289, 1087 2291, 2293, 2302, 2303, 2304, 2308, 2310, 2312, 2317, 2319, 1088 2321, 2326, 2328, 2330, 2345, 2347, 2348, 2350, 2355, 2356, 1089 2361, 2363, 2365, 2370, 2372, 2374, 2376, 2381, 2383, 2385, 1090 2395, 2397, 2398, 2400, 2405, 2407, 2409, 2414, 2416, 2418, 1091 2420, 2425, 2427, 2429, 2460, 2462, 2463, 2465, 2470, 2475, 1092 2483, 2485, 2487, 2492, 2494, 2499, 2501, 2515, 2516, 2518, 1093 2523, 2525, 2527, 2529, 2531, 2536, 2537, 2539, 2541, 2546, 1094 2548, 2550, 2556, 2558, 2560, 2564, 2566, 2568, 2570, 2584, 1095 2585, 2587, 2592, 2594, 2596, 2598, 2600, 2605, 2606, 2608, 1096 2610, 2615, 2617, 2619, 2625, 2626, 2628, 2637, 2640, 2642, 1097 2645, 2647, 2649, 2662, 2663, 2665, 2670, 2672, 2674, 2676, 1098 2678, 2683, 2684, 2686, 2688, 2693, 2695, 2703, 2704, 2705, 1099 2710, 2711, 2715, 2717, 2719, 2721, 2723, 2725, 2732, 2734, 1100 2736, 2738, 2740, 2743, 2745, 2747, 2749, 2751, 2756, 2758, 1101 2760, 2765, 2791, 2792, 2794, 2798, 2799, 2803, 2805, 2807, 1102 2809, 2811, 2813, 2820, 2822, 2824, 2826, 2828, 2830, 2835, 1103 2842, 2844, 2862, 2864, 2869, 2870 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_constantInteger( *(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_constantInteger( *(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_constantInteger( *(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_constantInteger( *(yyvsp[(1) - (2)].tok) ) ); } 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_constantInteger( *(yyvsp[(1) - (2)].tok) ) ); } 5094 5108 break; 5095 5109 … … 5097 5111 5098 5112 /* Line 1806 of yacc.c */ 5099 #line 44 4"parser.yy"5100 { (yyval. tok) = (yyvsp[(1) - (2)].tok); }5113 #line 445 "parser.yy" 5114 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); } 5101 5115 break; 5102 5116 … … 5104 5118 5105 5119 /* Line 1806 of yacc.c */ 5106 #line 45 7"parser.yy"5120 #line 458 "parser.yy" 5107 5121 { (yyval.en) = (yyvsp[(1) - (1)].en); } 5108 5122 break; … … 5111 5125 5112 5126 /* Line 1806 of yacc.c */ 5113 #line 4 59"parser.yy"5127 #line 460 "parser.yy" 5114 5128 { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); } 5115 5129 break; … … 5118 5132 5119 5133 /* Line 1806 of yacc.c */ 5120 #line 46 1"parser.yy"5134 #line 462 "parser.yy" 5121 5135 { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); } 5122 5136 break; … … 5125 5139 5126 5140 /* Line 1806 of yacc.c */ 5127 #line 46 6"parser.yy"5141 #line 467 "parser.yy" 5128 5142 { 5129 5143 switch ( (yyvsp[(1) - (2)].op) ) { … … 5143 5157 5144 5158 /* Line 1806 of yacc.c */ 5145 #line 4 79"parser.yy"5159 #line 480 "parser.yy" 5146 5160 { (yyval.en) = new ExpressionNode( build_unary_val( (yyvsp[(1) - (2)].op), (yyvsp[(2) - (2)].en) ) ); } 5147 5161 break; … … 5150 5164 5151 5165 /* Line 1806 of yacc.c */ 5152 #line 48 1"parser.yy"5166 #line 482 "parser.yy" 5153 5167 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Incr, (yyvsp[(2) - (2)].en) ) ); } 5154 5168 break; … … 5157 5171 5158 5172 /* Line 1806 of yacc.c */ 5159 #line 48 3"parser.yy"5173 #line 484 "parser.yy" 5160 5174 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Decr, (yyvsp[(2) - (2)].en) ) ); } 5161 5175 break; … … 5164 5178 5165 5179 /* Line 1806 of yacc.c */ 5166 #line 48 5"parser.yy"5180 #line 486 "parser.yy" 5167 5181 { (yyval.en) = new ExpressionNode( build_sizeOfexpr( (yyvsp[(2) - (2)].en) ) ); } 5168 5182 break; … … 5171 5185 5172 5186 /* Line 1806 of yacc.c */ 5173 #line 48 7"parser.yy"5187 #line 488 "parser.yy" 5174 5188 { (yyval.en) = new ExpressionNode( build_sizeOftype( (yyvsp[(3) - (4)].decl) ) ); } 5175 5189 break; … … 5178 5192 5179 5193 /* Line 1806 of yacc.c */ 5180 #line 4 89"parser.yy"5194 #line 490 "parser.yy" 5181 5195 { (yyval.en) = new ExpressionNode( build_alignOfexpr( (yyvsp[(2) - (2)].en) ) ); } 5182 5196 break; … … 5185 5199 5186 5200 /* Line 1806 of yacc.c */ 5187 #line 49 1"parser.yy"5201 #line 492 "parser.yy" 5188 5202 { (yyval.en) = new ExpressionNode( build_alignOftype( (yyvsp[(3) - (4)].decl) ) ); } 5189 5203 break; … … 5192 5206 5193 5207 /* Line 1806 of yacc.c */ 5194 #line 49 3"parser.yy"5208 #line 494 "parser.yy" 5195 5209 { (yyval.en) = new ExpressionNode( build_offsetOf( (yyvsp[(3) - (6)].decl), build_varref( (yyvsp[(5) - (6)].tok) ) ) ); } 5196 5210 break; … … 5199 5213 5200 5214 /* Line 1806 of yacc.c */ 5201 #line 49 5"parser.yy"5215 #line 496 "parser.yy" 5202 5216 { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (1)].tok) ), nullptr ) ); } 5203 5217 break; … … 5206 5220 5207 5221 /* Line 1806 of yacc.c */ 5208 #line 49 7"parser.yy"5222 #line 498 "parser.yy" 5209 5223 { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ) ); } 5210 5224 break; … … 5213 5227 5214 5228 /* Line 1806 of yacc.c */ 5215 #line 499"parser.yy"5229 #line 500 "parser.yy" 5216 5230 { (yyval.en) = new ExpressionNode( build_attrtype( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].decl) ) ); } 5217 5231 break; … … 5220 5234 5221 5235 /* Line 1806 of yacc.c */ 5222 #line 50 5"parser.yy"5236 #line 506 "parser.yy" 5223 5237 { (yyval.op) = OperKinds::PointTo; } 5224 5238 break; … … 5227 5241 5228 5242 /* Line 1806 of yacc.c */ 5229 #line 50 6"parser.yy"5243 #line 507 "parser.yy" 5230 5244 { (yyval.op) = OperKinds::AddressOf; } 5231 5245 break; … … 5234 5248 5235 5249 /* Line 1806 of yacc.c */ 5236 #line 51 2"parser.yy"5250 #line 513 "parser.yy" 5237 5251 { (yyval.op) = OperKinds::UnPlus; } 5238 5252 break; … … 5241 5255 5242 5256 /* Line 1806 of yacc.c */ 5243 #line 51 3"parser.yy"5257 #line 514 "parser.yy" 5244 5258 { (yyval.op) = OperKinds::UnMinus; } 5245 5259 break; … … 5248 5262 5249 5263 /* Line 1806 of yacc.c */ 5250 #line 51 4"parser.yy"5264 #line 515 "parser.yy" 5251 5265 { (yyval.op) = OperKinds::Neg; } 5252 5266 break; … … 5255 5269 5256 5270 /* Line 1806 of yacc.c */ 5257 #line 51 5"parser.yy"5271 #line 516 "parser.yy" 5258 5272 { (yyval.op) = OperKinds::BitNeg; } 5259 5273 break; … … 5262 5276 5263 5277 /* Line 1806 of yacc.c */ 5264 #line 52 1"parser.yy"5278 #line 522 "parser.yy" 5265 5279 { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); } 5266 5280 break; … … 5269 5283 5270 5284 /* Line 1806 of yacc.c */ 5271 #line 5 29"parser.yy"5285 #line 530 "parser.yy" 5272 5286 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5273 5287 break; … … 5276 5290 5277 5291 /* Line 1806 of yacc.c */ 5278 #line 53 1"parser.yy"5292 #line 532 "parser.yy" 5279 5293 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5280 5294 break; … … 5283 5297 5284 5298 /* Line 1806 of yacc.c */ 5285 #line 53 3"parser.yy"5299 #line 534 "parser.yy" 5286 5300 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5287 5301 break; … … 5290 5304 5291 5305 /* Line 1806 of yacc.c */ 5292 #line 5 39"parser.yy"5306 #line 540 "parser.yy" 5293 5307 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5294 5308 break; … … 5297 5311 5298 5312 /* Line 1806 of yacc.c */ 5299 #line 54 1"parser.yy"5313 #line 542 "parser.yy" 5300 5314 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5301 5315 break; … … 5304 5318 5305 5319 /* Line 1806 of yacc.c */ 5306 #line 54 7"parser.yy"5320 #line 548 "parser.yy" 5307 5321 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5308 5322 break; … … 5311 5325 5312 5326 /* Line 1806 of yacc.c */ 5313 #line 5 49"parser.yy"5327 #line 550 "parser.yy" 5314 5328 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5315 5329 break; … … 5318 5332 5319 5333 /* Line 1806 of yacc.c */ 5320 #line 55 5"parser.yy"5334 #line 556 "parser.yy" 5321 5335 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5322 5336 break; … … 5325 5339 5326 5340 /* Line 1806 of yacc.c */ 5327 #line 55 7"parser.yy"5341 #line 558 "parser.yy" 5328 5342 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5329 5343 break; … … 5332 5346 5333 5347 /* Line 1806 of yacc.c */ 5334 #line 5 59"parser.yy"5348 #line 560 "parser.yy" 5335 5349 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5336 5350 break; … … 5339 5353 5340 5354 /* Line 1806 of yacc.c */ 5341 #line 56 1"parser.yy"5355 #line 562 "parser.yy" 5342 5356 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5343 5357 break; … … 5346 5360 5347 5361 /* Line 1806 of yacc.c */ 5348 #line 56 7"parser.yy"5362 #line 568 "parser.yy" 5349 5363 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5350 5364 break; … … 5353 5367 5354 5368 /* Line 1806 of yacc.c */ 5355 #line 5 69"parser.yy"5369 #line 570 "parser.yy" 5356 5370 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5357 5371 break; … … 5360 5374 5361 5375 /* Line 1806 of yacc.c */ 5362 #line 57 5"parser.yy"5376 #line 576 "parser.yy" 5363 5377 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5364 5378 break; … … 5367 5381 5368 5382 /* Line 1806 of yacc.c */ 5369 #line 58 1"parser.yy"5383 #line 582 "parser.yy" 5370 5384 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5371 5385 break; … … 5374 5388 5375 5389 /* Line 1806 of yacc.c */ 5376 #line 58 7"parser.yy"5390 #line 588 "parser.yy" 5377 5391 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5378 5392 break; … … 5381 5395 5382 5396 /* Line 1806 of yacc.c */ 5383 #line 59 3"parser.yy"5397 #line 594 "parser.yy" 5384 5398 { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); } 5385 5399 break; … … 5388 5402 5389 5403 /* Line 1806 of yacc.c */ 5390 #line 599"parser.yy"5404 #line 600 "parser.yy" 5391 5405 { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); } 5392 5406 break; … … 5395 5409 5396 5410 /* Line 1806 of yacc.c */ 5397 #line 60 5"parser.yy"5411 #line 606 "parser.yy" 5398 5412 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); } 5399 5413 break; … … 5402 5416 5403 5417 /* Line 1806 of yacc.c */ 5404 #line 60 8"parser.yy"5418 #line 609 "parser.yy" 5405 5419 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); } 5406 5420 break; … … 5409 5423 5410 5424 /* Line 1806 of yacc.c */ 5411 #line 62 1"parser.yy"5425 #line 622 "parser.yy" 5412 5426 { (yyval.en) = new ExpressionNode( build_binary_ptr( (yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5413 5427 break; … … 5416 5430 5417 5431 /* Line 1806 of yacc.c */ 5418 #line 62 8"parser.yy"5432 #line 629 "parser.yy" 5419 5433 { (yyval.en) = nullptr; } 5420 5434 break; … … 5423 5437 5424 5438 /* Line 1806 of yacc.c */ 5425 #line 63 3"parser.yy"5439 #line 634 "parser.yy" 5426 5440 { (yyval.op) = OperKinds::Assign; } 5427 5441 break; … … 5430 5444 5431 5445 /* Line 1806 of yacc.c */ 5432 #line 63 4"parser.yy"5446 #line 635 "parser.yy" 5433 5447 { (yyval.op) = OperKinds::AtAssn; } 5434 5448 break; … … 5437 5451 5438 5452 /* Line 1806 of yacc.c */ 5439 #line 63 5"parser.yy"5453 #line 636 "parser.yy" 5440 5454 { (yyval.op) = OperKinds::MulAssn; } 5441 5455 break; … … 5444 5458 5445 5459 /* Line 1806 of yacc.c */ 5446 #line 63 6"parser.yy"5460 #line 637 "parser.yy" 5447 5461 { (yyval.op) = OperKinds::DivAssn; } 5448 5462 break; … … 5451 5465 5452 5466 /* Line 1806 of yacc.c */ 5453 #line 63 7"parser.yy"5467 #line 638 "parser.yy" 5454 5468 { (yyval.op) = OperKinds::ModAssn; } 5455 5469 break; … … 5458 5472 5459 5473 /* Line 1806 of yacc.c */ 5460 #line 63 8"parser.yy"5474 #line 639 "parser.yy" 5461 5475 { (yyval.op) = OperKinds::PlusAssn; } 5462 5476 break; … … 5465 5479 5466 5480 /* Line 1806 of yacc.c */ 5467 #line 6 39"parser.yy"5481 #line 640 "parser.yy" 5468 5482 { (yyval.op) = OperKinds::MinusAssn; } 5469 5483 break; … … 5472 5486 5473 5487 /* Line 1806 of yacc.c */ 5474 #line 64 0"parser.yy"5488 #line 641 "parser.yy" 5475 5489 { (yyval.op) = OperKinds::LSAssn; } 5476 5490 break; … … 5479 5493 5480 5494 /* Line 1806 of yacc.c */ 5481 #line 64 1"parser.yy"5495 #line 642 "parser.yy" 5482 5496 { (yyval.op) = OperKinds::RSAssn; } 5483 5497 break; … … 5486 5500 5487 5501 /* Line 1806 of yacc.c */ 5488 #line 64 2"parser.yy"5502 #line 643 "parser.yy" 5489 5503 { (yyval.op) = OperKinds::AndAssn; } 5490 5504 break; … … 5493 5507 5494 5508 /* Line 1806 of yacc.c */ 5495 #line 64 3"parser.yy"5509 #line 644 "parser.yy" 5496 5510 { (yyval.op) = OperKinds::ERAssn; } 5497 5511 break; … … 5500 5514 5501 5515 /* Line 1806 of yacc.c */ 5502 #line 64 4"parser.yy"5516 #line 645 "parser.yy" 5503 5517 { (yyval.op) = OperKinds::OrAssn; } 5504 5518 break; … … 5507 5521 5508 5522 /* Line 1806 of yacc.c */ 5509 #line 65 5"parser.yy"5523 #line 656 "parser.yy" 5510 5524 { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( (yyvsp[(4) - (6)].en) ) ) ); } 5511 5525 break; … … 5514 5528 5515 5529 /* Line 1806 of yacc.c */ 5516 #line 65 7"parser.yy"5530 #line 658 "parser.yy" 5517 5531 { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_last( (yyvsp[(5) - (7)].en) ) ) ); } 5518 5532 break; … … 5521 5535 5522 5536 /* Line 1806 of yacc.c */ 5523 #line 66 3"parser.yy"5537 #line 664 "parser.yy" 5524 5538 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 5525 5539 break; … … 5528 5542 5529 5543 /* Line 1806 of yacc.c */ 5530 #line 6 69"parser.yy"5544 #line 670 "parser.yy" 5531 5545 { (yyval.en) = new ExpressionNode( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5532 5546 break; … … 5535 5549 5536 5550 /* Line 1806 of yacc.c */ 5537 #line 67 4"parser.yy"5551 #line 675 "parser.yy" 5538 5552 { (yyval.en) = 0; } 5539 5553 break; … … 5542 5556 5543 5557 /* Line 1806 of yacc.c */ 5544 #line 68 3"parser.yy"5558 #line 684 "parser.yy" 5545 5559 { (yyval.sn) = (yyvsp[(1) - (1)].sn); } 5546 5560 break; … … 5549 5563 5550 5564 /* Line 1806 of yacc.c */ 5551 #line 69 0"parser.yy"5565 #line 691 "parser.yy" 5552 5566 { 5553 5567 Token fn; … … 5560 5574 5561 5575 /* Line 1806 of yacc.c */ 5562 #line 70 0"parser.yy"5576 #line 701 "parser.yy" 5563 5577 { 5564 5578 (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) ); … … 5569 5583 5570 5584 /* Line 1806 of yacc.c */ 5571 #line 70 7"parser.yy"5585 #line 708 "parser.yy" 5572 5586 { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); } 5573 5587 break; … … 5576 5590 5577 5591 /* Line 1806 of yacc.c */ 5578 #line 71 4"parser.yy"5592 #line 715 "parser.yy" 5579 5593 { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); } 5580 5594 break; … … 5583 5597 5584 5598 /* Line 1806 of yacc.c */ 5585 #line 72 0"parser.yy"5599 #line 721 "parser.yy" 5586 5600 { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } } 5587 5601 break; … … 5590 5604 5591 5605 /* Line 1806 of yacc.c */ 5592 #line 72 5"parser.yy"5606 #line 726 "parser.yy" 5593 5607 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5594 5608 break; … … 5597 5611 5598 5612 /* Line 1806 of yacc.c */ 5599 #line 72 7"parser.yy"5613 #line 728 "parser.yy" 5600 5614 { // mark all fields in list 5601 5615 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 5608 5622 5609 5623 /* Line 1806 of yacc.c */ 5610 #line 73 3"parser.yy"5624 #line 734 "parser.yy" 5611 5625 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5612 5626 break; … … 5615 5629 5616 5630 /* Line 1806 of yacc.c */ 5617 #line 74 0"parser.yy"5631 #line 741 "parser.yy" 5618 5632 { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } } 5619 5633 break; … … 5622 5636 5623 5637 /* Line 1806 of yacc.c */ 5624 #line 74 5"parser.yy"5638 #line 746 "parser.yy" 5625 5639 { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); } 5626 5640 break; … … 5629 5643 5630 5644 /* Line 1806 of yacc.c */ 5631 #line 75 1"parser.yy"5645 #line 752 "parser.yy" 5632 5646 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); } 5633 5647 break; … … 5636 5650 5637 5651 /* Line 1806 of yacc.c */ 5638 #line 75 3"parser.yy"5652 #line 754 "parser.yy" 5639 5653 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); } 5640 5654 break; … … 5643 5657 5644 5658 /* Line 1806 of yacc.c */ 5645 #line 75 5"parser.yy"5659 #line 756 "parser.yy" 5646 5660 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5647 5661 break; … … 5650 5664 5651 5665 /* Line 1806 of yacc.c */ 5652 #line 75 7"parser.yy"5666 #line 758 "parser.yy" 5653 5667 { 5654 5668 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); … … 5665 5679 5666 5680 /* Line 1806 of yacc.c */ 5667 #line 76 7"parser.yy"5681 #line 768 "parser.yy" 5668 5682 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5669 5683 break; … … 5672 5686 5673 5687 /* Line 1806 of yacc.c */ 5674 #line 7 69"parser.yy"5688 #line 770 "parser.yy" 5675 5689 { 5676 5690 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); … … 5682 5696 5683 5697 /* Line 1806 of yacc.c */ 5684 #line 7 79"parser.yy"5698 #line 780 "parser.yy" 5685 5699 { (yyval.en) = (yyvsp[(1) - (1)].en); } 5686 5700 break; … … 5689 5703 5690 5704 /* Line 1806 of yacc.c */ 5691 #line 78 1"parser.yy"5705 #line 782 "parser.yy" 5692 5706 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5693 5707 break; … … 5696 5710 5697 5711 /* Line 1806 of yacc.c */ 5698 #line 78 6"parser.yy"5712 #line 787 "parser.yy" 5699 5713 { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); } 5700 5714 break; … … 5703 5717 5704 5718 /* Line 1806 of yacc.c */ 5705 #line 78 8"parser.yy"5719 #line 789 "parser.yy" 5706 5720 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); } 5707 5721 break; … … 5710 5724 5711 5725 /* Line 1806 of yacc.c */ 5712 #line 79 2"parser.yy"5726 #line 793 "parser.yy" 5713 5727 { (yyval.sn) = (yyvsp[(2) - (3)].sn); } 5714 5728 break; … … 5717 5731 5718 5732 /* Line 1806 of yacc.c */ 5719 #line 79 3"parser.yy"5733 #line 794 "parser.yy" 5720 5734 { (yyval.sn) = new StatementNode( build_default() ); } 5721 5735 break; … … 5724 5738 5725 5739 /* Line 1806 of yacc.c */ 5726 #line 799"parser.yy"5740 #line 800 "parser.yy" 5727 5741 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) )); } 5728 5742 break; … … 5731 5745 5732 5746 /* Line 1806 of yacc.c */ 5733 #line 80 3"parser.yy"5747 #line 804 "parser.yy" 5734 5748 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5735 5749 break; … … 5738 5752 5739 5753 /* Line 1806 of yacc.c */ 5740 #line 80 8"parser.yy"5754 #line 809 "parser.yy" 5741 5755 { (yyval.sn) = 0; } 5742 5756 break; … … 5745 5759 5746 5760 /* Line 1806 of yacc.c */ 5747 #line 81 4"parser.yy"5761 #line 815 "parser.yy" 5748 5762 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5749 5763 break; … … 5752 5766 5753 5767 /* Line 1806 of yacc.c */ 5754 #line 81 6"parser.yy"5768 #line 817 "parser.yy" 5755 5769 { (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 5770 break; … … 5759 5773 5760 5774 /* Line 1806 of yacc.c */ 5761 #line 82 1"parser.yy"5775 #line 822 "parser.yy" 5762 5776 { (yyval.sn) = 0; } 5763 5777 break; … … 5766 5780 5767 5781 /* Line 1806 of yacc.c */ 5768 #line 82 7"parser.yy"5782 #line 828 "parser.yy" 5769 5783 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); } 5770 5784 break; … … 5773 5787 5774 5788 /* Line 1806 of yacc.c */ 5775 #line 8 29"parser.yy"5789 #line 830 "parser.yy" 5776 5790 { (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 5791 break; … … 5780 5794 5781 5795 /* Line 1806 of yacc.c */ 5782 #line 83 1"parser.yy"5796 #line 832 "parser.yy" 5783 5797 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); } 5784 5798 break; … … 5787 5801 5788 5802 /* Line 1806 of yacc.c */ 5789 #line 83 3"parser.yy"5803 #line 834 "parser.yy" 5790 5804 { (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 5805 break; … … 5794 5808 5795 5809 /* Line 1806 of yacc.c */ 5796 #line 83 8"parser.yy"5810 #line 839 "parser.yy" 5797 5811 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); } 5798 5812 break; … … 5801 5815 5802 5816 /* Line 1806 of yacc.c */ 5803 #line 84 4"parser.yy"5817 #line 845 "parser.yy" 5804 5818 { (yyval.sn) = 0; } 5805 5819 break; … … 5808 5822 5809 5823 /* Line 1806 of yacc.c */ 5810 #line 84 6"parser.yy"5824 #line 847 "parser.yy" 5811 5825 { (yyval.sn) = 0; } 5812 5826 break; … … 5815 5829 5816 5830 /* Line 1806 of yacc.c */ 5817 #line 85 1"parser.yy"5831 #line 852 "parser.yy" 5818 5832 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5819 5833 break; … … 5822 5836 5823 5837 /* Line 1806 of yacc.c */ 5824 #line 85 3"parser.yy"5838 #line 854 "parser.yy" 5825 5839 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); } 5826 5840 break; … … 5829 5843 5830 5844 /* Line 1806 of yacc.c */ 5831 #line 85 5"parser.yy"5845 #line 856 "parser.yy" 5832 5846 { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); } 5833 5847 break; … … 5836 5850 5837 5851 /* Line 1806 of yacc.c */ 5838 #line 86 0"parser.yy"5852 #line 861 "parser.yy" 5839 5853 { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); } 5840 5854 break; … … 5843 5857 5844 5858 /* Line 1806 of yacc.c */ 5845 #line 86 2"parser.yy"5859 #line 863 "parser.yy" 5846 5860 { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); } 5847 5861 break; … … 5850 5864 5851 5865 /* Line 1806 of yacc.c */ 5852 #line 86 7"parser.yy"5866 #line 868 "parser.yy" 5853 5867 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); } 5854 5868 break; … … 5857 5871 5858 5872 /* Line 1806 of yacc.c */ 5859 #line 87 1"parser.yy"5873 #line 872 "parser.yy" 5860 5874 { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); } 5861 5875 break; … … 5864 5878 5865 5879 /* Line 1806 of yacc.c */ 5866 #line 87 4"parser.yy"5880 #line 875 "parser.yy" 5867 5881 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Continue ) ); } 5868 5882 break; … … 5871 5885 5872 5886 /* Line 1806 of yacc.c */ 5873 #line 87 8"parser.yy"5887 #line 879 "parser.yy" 5874 5888 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); } 5875 5889 break; … … 5878 5892 5879 5893 /* Line 1806 of yacc.c */ 5880 #line 88 1"parser.yy"5894 #line 882 "parser.yy" 5881 5895 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); } 5882 5896 break; … … 5885 5899 5886 5900 /* Line 1806 of yacc.c */ 5887 #line 88 5"parser.yy"5901 #line 886 "parser.yy" 5888 5902 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); } 5889 5903 break; … … 5892 5906 5893 5907 /* Line 1806 of yacc.c */ 5894 #line 88 7"parser.yy"5908 #line 888 "parser.yy" 5895 5909 { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); } 5896 5910 break; … … 5899 5913 5900 5914 /* Line 1806 of yacc.c */ 5901 #line 8 89"parser.yy"5915 #line 890 "parser.yy" 5902 5916 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 5903 5917 break; … … 5906 5920 5907 5921 /* Line 1806 of yacc.c */ 5908 #line 89 1"parser.yy"5922 #line 892 "parser.yy" 5909 5923 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 5910 5924 break; … … 5913 5927 5914 5928 /* Line 1806 of yacc.c */ 5915 #line 89 3"parser.yy"5929 #line 894 "parser.yy" 5916 5930 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); } 5917 5931 break; … … 5920 5934 5921 5935 /* Line 1806 of yacc.c */ 5922 #line 89 8"parser.yy"5936 #line 899 "parser.yy" 5923 5937 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); } 5924 5938 break; … … 5927 5941 5928 5942 /* Line 1806 of yacc.c */ 5929 #line 90 0"parser.yy"5943 #line 901 "parser.yy" 5930 5944 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); } 5931 5945 break; … … 5934 5948 5935 5949 /* Line 1806 of yacc.c */ 5936 #line 90 2"parser.yy"5950 #line 903 "parser.yy" 5937 5951 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); } 5938 5952 break; … … 5941 5955 5942 5956 /* Line 1806 of yacc.c */ 5943 #line 9 09"parser.yy"5957 #line 910 "parser.yy" 5944 5958 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 5945 5959 break; … … 5948 5962 5949 5963 /* Line 1806 of yacc.c */ 5950 #line 91 1"parser.yy"5964 #line 912 "parser.yy" 5951 5965 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 5952 5966 break; … … 5955 5969 5956 5970 /* Line 1806 of yacc.c */ 5957 #line 91 3"parser.yy"5971 #line 914 "parser.yy" 5958 5972 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 5959 5973 break; … … 5962 5976 5963 5977 /* Line 1806 of yacc.c */ 5964 #line 91 5"parser.yy"5978 #line 916 "parser.yy" 5965 5979 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 5966 5980 break; … … 5969 5983 5970 5984 /* Line 1806 of yacc.c */ 5971 #line 92 0"parser.yy"5985 #line 921 "parser.yy" 5972 5986 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 5973 5987 break; … … 5976 5990 5977 5991 /* Line 1806 of yacc.c */ 5978 #line 92 2"parser.yy"5992 #line 923 "parser.yy" 5979 5993 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 5980 5994 break; … … 5983 5997 5984 5998 /* Line 1806 of yacc.c */ 5985 #line 92 4"parser.yy"5999 #line 925 "parser.yy" 5986 6000 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 5987 6001 break; … … 5990 6004 5991 6005 /* Line 1806 of yacc.c */ 5992 #line 92 6"parser.yy"6006 #line 927 "parser.yy" 5993 6007 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 5994 6008 break; … … 5997 6011 5998 6012 /* Line 1806 of yacc.c */ 5999 #line 93 1"parser.yy"6013 #line 932 "parser.yy" 6000 6014 { 6001 6015 (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) ); … … 6006 6020 6007 6021 /* Line 1806 of yacc.c */ 6008 #line 94 4"parser.yy"6022 #line 945 "parser.yy" 6009 6023 { 6010 6024 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6016 6030 6017 6031 /* Line 1806 of yacc.c */ 6018 #line 9 49"parser.yy"6032 #line 950 "parser.yy" 6019 6033 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 6020 6034 break; … … 6023 6037 6024 6038 /* Line 1806 of yacc.c */ 6025 #line 95 1"parser.yy"6039 #line 952 "parser.yy" 6026 6040 { 6027 6041 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6033 6047 6034 6048 /* Line 1806 of yacc.c */ 6035 #line 96 0"parser.yy"6049 #line 961 "parser.yy" 6036 6050 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); } 6037 6051 break; … … 6040 6054 6041 6055 /* Line 1806 of yacc.c */ 6042 #line 96 2"parser.yy"6056 #line 963 "parser.yy" 6043 6057 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); } 6044 6058 break; … … 6047 6061 6048 6062 /* Line 1806 of yacc.c */ 6049 #line 96 4"parser.yy"6063 #line 965 "parser.yy" 6050 6064 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); } 6051 6065 break; … … 6054 6068 6055 6069 /* Line 1806 of yacc.c */ 6056 #line 96 6"parser.yy"6070 #line 967 "parser.yy" 6057 6071 { (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 6072 break; … … 6061 6075 6062 6076 /* Line 1806 of yacc.c */ 6063 #line 96 8"parser.yy"6077 #line 969 "parser.yy" 6064 6078 { (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 6079 break; … … 6068 6082 6069 6083 /* Line 1806 of yacc.c */ 6070 #line 97 3"parser.yy"6084 #line 974 "parser.yy" 6071 6085 { (yyval.flag) = false; } 6072 6086 break; … … 6075 6089 6076 6090 /* Line 1806 of yacc.c */ 6077 #line 97 5"parser.yy"6091 #line 976 "parser.yy" 6078 6092 { (yyval.flag) = true; } 6079 6093 break; … … 6082 6096 6083 6097 /* Line 1806 of yacc.c */ 6084 #line 98 0"parser.yy"6098 #line 981 "parser.yy" 6085 6099 { (yyval.en) = 0; } 6086 6100 break; … … 6089 6103 6090 6104 /* Line 1806 of yacc.c */ 6091 #line 98 7"parser.yy"6105 #line 988 "parser.yy" 6092 6106 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 6093 6107 break; … … 6096 6110 6097 6111 /* Line 1806 of yacc.c */ 6098 #line 99 2"parser.yy"6112 #line 993 "parser.yy" 6099 6113 { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); } 6100 6114 break; … … 6103 6117 6104 6118 /* Line 1806 of yacc.c */ 6105 #line 99 4"parser.yy"6119 #line 995 "parser.yy" 6106 6120 { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); } 6107 6121 break; … … 6110 6124 6111 6125 /* Line 1806 of yacc.c */ 6112 #line 999"parser.yy"6126 #line 1000 "parser.yy" 6113 6127 { (yyval.en) = 0; } 6114 6128 break; … … 6117 6131 6118 6132 /* Line 1806 of yacc.c */ 6119 #line 100 1"parser.yy"6133 #line 1002 "parser.yy" 6120 6134 { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); } 6121 6135 break; … … 6124 6138 6125 6139 /* Line 1806 of yacc.c */ 6126 #line 100 3"parser.yy"6140 #line 1004 "parser.yy" 6127 6141 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( (yyvsp[(3) - (3)].constant) ) ); } 6128 6142 break; … … 6131 6145 6132 6146 /* Line 1806 of yacc.c */ 6133 #line 100 8"parser.yy"6147 #line 1009 "parser.yy" 6134 6148 { 6135 6149 (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) ); … … 6141 6155 6142 6156 /* Line 1806 of yacc.c */ 6143 #line 101 3"parser.yy"6157 #line 1014 "parser.yy" 6144 6158 { 6145 6159 (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) ); … … 6151 6165 6152 6166 /* Line 1806 of yacc.c */ 6153 #line 102 3"parser.yy"6167 #line 1024 "parser.yy" 6154 6168 { (yyval.decl) = 0; } 6155 6169 break; … … 6158 6172 6159 6173 /* Line 1806 of yacc.c */ 6160 #line 103 0"parser.yy"6174 #line 1031 "parser.yy" 6161 6175 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6162 6176 break; … … 6165 6179 6166 6180 /* Line 1806 of yacc.c */ 6167 #line 103 5"parser.yy"6181 #line 1036 "parser.yy" 6168 6182 { (yyval.decl) = 0; } 6169 6183 break; … … 6172 6186 6173 6187 /* Line 1806 of yacc.c */ 6174 #line 104 2"parser.yy"6188 #line 1043 "parser.yy" 6175 6189 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6176 6190 break; 6177 6191 6178 6192 case 250: 6179 6180 /* Line 1806 of yacc.c */6181 #line 1056 "parser.yy"6182 {}6183 break;6184 6185 case 251:6186 6193 6187 6194 /* Line 1806 of yacc.c */ … … 6190 6197 break; 6191 6198 6199 case 251: 6200 6201 /* Line 1806 of yacc.c */ 6202 #line 1058 "parser.yy" 6203 {} 6204 break; 6205 6192 6206 case 259: 6193 6207 6194 6208 /* Line 1806 of yacc.c */ 6195 #line 108 6"parser.yy"6209 #line 1087 "parser.yy" 6196 6210 { 6197 6211 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6203 6217 6204 6218 /* Line 1806 of yacc.c */ 6205 #line 109 3"parser.yy"6219 #line 1094 "parser.yy" 6206 6220 { 6207 6221 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6213 6227 6214 6228 /* Line 1806 of yacc.c */ 6215 #line 109 8"parser.yy"6229 #line 1099 "parser.yy" 6216 6230 { 6217 6231 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID ); … … 6223 6237 6224 6238 /* Line 1806 of yacc.c */ 6225 #line 110 8"parser.yy"6239 #line 1109 "parser.yy" 6226 6240 { 6227 6241 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6233 6247 6234 6248 /* Line 1806 of yacc.c */ 6235 #line 111 3"parser.yy"6249 #line 1114 "parser.yy" 6236 6250 { 6237 6251 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6243 6257 6244 6258 /* Line 1806 of yacc.c */ 6245 #line 111 8"parser.yy"6259 #line 1119 "parser.yy" 6246 6260 { 6247 6261 typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) ); … … 6253 6267 6254 6268 /* Line 1806 of yacc.c */ 6255 #line 112 6"parser.yy"6269 #line 1127 "parser.yy" 6256 6270 { 6257 6271 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6263 6277 6264 6278 /* Line 1806 of yacc.c */ 6265 #line 113 1"parser.yy"6279 #line 1132 "parser.yy" 6266 6280 { 6267 6281 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6273 6287 6274 6288 /* Line 1806 of yacc.c */ 6275 #line 113 6"parser.yy"6289 #line 1137 "parser.yy" 6276 6290 { 6277 6291 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6283 6297 6284 6298 /* Line 1806 of yacc.c */ 6285 #line 114 1"parser.yy"6299 #line 1142 "parser.yy" 6286 6300 { 6287 6301 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6293 6307 6294 6308 /* Line 1806 of yacc.c */ 6295 #line 114 6"parser.yy"6309 #line 1147 "parser.yy" 6296 6310 { 6297 6311 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 6303 6317 6304 6318 /* Line 1806 of yacc.c */ 6305 #line 117 7"parser.yy"6319 #line 1178 "parser.yy" 6306 6320 { 6307 6321 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6312 6326 6313 6327 /* Line 1806 of yacc.c */ 6314 #line 118 1"parser.yy"6328 #line 1182 "parser.yy" 6315 6329 { 6316 6330 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6321 6335 6322 6336 /* Line 1806 of yacc.c */ 6323 #line 118 8"parser.yy"6337 #line 1189 "parser.yy" 6324 6338 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 6325 6339 break; … … 6328 6342 6329 6343 /* Line 1806 of yacc.c */ 6330 #line 119 2"parser.yy"6344 #line 1193 "parser.yy" 6331 6345 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); } 6332 6346 break; … … 6335 6349 6336 6350 /* Line 1806 of yacc.c */ 6337 #line 119 7"parser.yy"6351 #line 1198 "parser.yy" 6338 6352 { 6339 6353 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6345 6359 6346 6360 /* Line 1806 of yacc.c */ 6347 #line 120 2"parser.yy"6361 #line 1203 "parser.yy" 6348 6362 { 6349 6363 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6355 6369 6356 6370 /* Line 1806 of yacc.c */ 6357 #line 120 7"parser.yy"6371 #line 1208 "parser.yy" 6358 6372 { 6359 6373 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD ); … … 6365 6379 6366 6380 /* Line 1806 of yacc.c */ 6367 #line 121 8"parser.yy"6381 #line 1219 "parser.yy" 6368 6382 { 6369 6383 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6375 6389 6376 6390 /* Line 1806 of yacc.c */ 6377 #line 122 3"parser.yy"6391 #line 1224 "parser.yy" 6378 6392 { 6379 6393 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6385 6399 6386 6400 /* Line 1806 of yacc.c */ 6387 #line 122 8"parser.yy"6401 #line 1229 "parser.yy" 6388 6402 { 6389 6403 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6395 6409 6396 6410 /* Line 1806 of yacc.c */ 6397 #line 123 3"parser.yy"6411 #line 1234 "parser.yy" 6398 6412 { 6399 6413 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6405 6419 6406 6420 /* Line 1806 of yacc.c */ 6407 #line 123 8"parser.yy"6421 #line 1239 "parser.yy" 6408 6422 { 6409 6423 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6415 6429 6416 6430 /* Line 1806 of yacc.c */ 6417 #line 124 7"parser.yy"6431 #line 1248 "parser.yy" 6418 6432 { 6419 6433 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD ); … … 6425 6439 6426 6440 /* Line 1806 of yacc.c */ 6427 #line 125 2"parser.yy"6441 #line 1253 "parser.yy" 6428 6442 { 6429 6443 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD ); … … 6435 6449 6436 6450 /* Line 1806 of yacc.c */ 6437 #line 12 69"parser.yy"6451 #line 1270 "parser.yy" 6438 6452 { 6439 6453 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6445 6459 6446 6460 /* Line 1806 of yacc.c */ 6447 #line 127 4"parser.yy"6461 #line 1275 "parser.yy" 6448 6462 { 6449 6463 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6455 6469 6456 6470 /* Line 1806 of yacc.c */ 6457 #line 129 6"parser.yy"6471 #line 1297 "parser.yy" 6458 6472 { (yyval.decl) = 0; } 6459 6473 break; … … 6462 6476 6463 6477 /* Line 1806 of yacc.c */ 6464 #line 130 8"parser.yy"6478 #line 1309 "parser.yy" 6465 6479 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6466 6480 break; … … 6469 6483 6470 6484 /* Line 1806 of yacc.c */ 6471 #line 13 19"parser.yy"6485 #line 1320 "parser.yy" 6472 6486 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); } 6473 6487 break; … … 6476 6490 6477 6491 /* Line 1806 of yacc.c */ 6478 #line 132 1"parser.yy"6492 #line 1322 "parser.yy" 6479 6493 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); } 6480 6494 break; … … 6483 6497 6484 6498 /* Line 1806 of yacc.c */ 6485 #line 132 3"parser.yy"6499 #line 1324 "parser.yy" 6486 6500 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); } 6487 6501 break; … … 6490 6504 6491 6505 /* Line 1806 of yacc.c */ 6492 #line 132 5"parser.yy"6506 #line 1326 "parser.yy" 6493 6507 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 6494 6508 break; … … 6497 6511 6498 6512 /* Line 1806 of yacc.c */ 6499 #line 132 7"parser.yy"6513 #line 1328 "parser.yy" 6500 6514 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); } 6501 6515 break; … … 6504 6518 6505 6519 /* Line 1806 of yacc.c */ 6506 #line 13 29"parser.yy"6520 #line 1330 "parser.yy" 6507 6521 { 6508 6522 typedefTable.enterScope(); … … 6513 6527 6514 6528 /* Line 1806 of yacc.c */ 6515 #line 133 3"parser.yy"6529 #line 1334 "parser.yy" 6516 6530 { 6517 6531 typedefTable.leaveScope(); … … 6523 6537 6524 6538 /* Line 1806 of yacc.c */ 6525 #line 134 2"parser.yy"6539 #line 1343 "parser.yy" 6526 6540 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6527 6541 break; … … 6530 6544 6531 6545 /* Line 1806 of yacc.c */ 6532 #line 134 4"parser.yy"6546 #line 1345 "parser.yy" 6533 6547 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6534 6548 break; … … 6537 6551 6538 6552 /* Line 1806 of yacc.c */ 6539 #line 135 5"parser.yy"6553 #line 1356 "parser.yy" 6540 6554 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6541 6555 break; … … 6544 6558 6545 6559 /* Line 1806 of yacc.c */ 6546 #line 136 0"parser.yy"6560 #line 1361 "parser.yy" 6547 6561 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } 6548 6562 break; … … 6551 6565 6552 6566 /* Line 1806 of yacc.c */ 6553 #line 136 2"parser.yy"6567 #line 1363 "parser.yy" 6554 6568 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); } 6555 6569 break; … … 6558 6572 6559 6573 /* Line 1806 of yacc.c */ 6560 #line 136 4"parser.yy"6574 #line 1365 "parser.yy" 6561 6575 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); } 6562 6576 break; … … 6565 6579 6566 6580 /* Line 1806 of yacc.c */ 6567 #line 136 6"parser.yy"6581 #line 1367 "parser.yy" 6568 6582 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 6569 6583 break; … … 6572 6586 6573 6587 /* Line 1806 of yacc.c */ 6574 #line 13 69"parser.yy"6588 #line 1370 "parser.yy" 6575 6589 { (yyval.decl) = new DeclarationNode; (yyval.decl)->isInline = true; } 6576 6590 break; … … 6579 6593 6580 6594 /* Line 1806 of yacc.c */ 6581 #line 137 1"parser.yy"6595 #line 1372 "parser.yy" 6582 6596 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 6583 6597 break; … … 6586 6600 6587 6601 /* Line 1806 of yacc.c */ 6588 #line 137 4"parser.yy"6602 #line 1375 "parser.yy" 6589 6603 { (yyval.decl) = new DeclarationNode; (yyval.decl)->isNoreturn = true; } 6590 6604 break; … … 6593 6607 6594 6608 /* Line 1806 of yacc.c */ 6595 #line 137 6"parser.yy"6609 #line 1377 "parser.yy" 6596 6610 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 6597 6611 break; … … 6600 6614 6601 6615 /* Line 1806 of yacc.c */ 6602 #line 138 1"parser.yy"6616 #line 1382 "parser.yy" 6603 6617 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); } 6604 6618 break; … … 6607 6621 6608 6622 /* Line 1806 of yacc.c */ 6609 #line 138 3"parser.yy"6623 #line 1384 "parser.yy" 6610 6624 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); } 6611 6625 break; … … 6614 6628 6615 6629 /* Line 1806 of yacc.c */ 6616 #line 138 5"parser.yy"6630 #line 1386 "parser.yy" 6617 6631 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); } 6618 6632 break; … … 6621 6635 6622 6636 /* Line 1806 of yacc.c */ 6623 #line 138 7"parser.yy"6637 #line 1388 "parser.yy" 6624 6638 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); } 6625 6639 break; … … 6628 6642 6629 6643 /* Line 1806 of yacc.c */ 6630 #line 13 89"parser.yy"6644 #line 1390 "parser.yy" 6631 6645 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); } 6632 6646 break; … … 6635 6649 6636 6650 /* Line 1806 of yacc.c */ 6637 #line 139 1"parser.yy"6651 #line 1392 "parser.yy" 6638 6652 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); } 6639 6653 break; … … 6642 6656 6643 6657 /* Line 1806 of yacc.c */ 6644 #line 139 3"parser.yy"6658 #line 1394 "parser.yy" 6645 6659 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 6646 6660 break; … … 6649 6663 6650 6664 /* Line 1806 of yacc.c */ 6651 #line 139 5"parser.yy"6665 #line 1396 "parser.yy" 6652 6666 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 6653 6667 break; … … 6656 6670 6657 6671 /* Line 1806 of yacc.c */ 6658 #line 139 7"parser.yy"6672 #line 1398 "parser.yy" 6659 6673 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); } 6660 6674 break; … … 6663 6677 6664 6678 /* Line 1806 of yacc.c */ 6665 #line 1 399"parser.yy"6679 #line 1400 "parser.yy" 6666 6680 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 6667 6681 break; … … 6670 6684 6671 6685 /* Line 1806 of yacc.c */ 6672 #line 140 1"parser.yy"6686 #line 1402 "parser.yy" 6673 6687 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 6674 6688 break; … … 6677 6691 6678 6692 /* Line 1806 of yacc.c */ 6679 #line 140 3"parser.yy"6693 #line 1404 "parser.yy" 6680 6694 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 6681 6695 break; … … 6684 6698 6685 6699 /* Line 1806 of yacc.c */ 6686 #line 140 5"parser.yy"6700 #line 1406 "parser.yy" 6687 6701 { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 6688 6702 break; … … 6691 6705 6692 6706 /* Line 1806 of yacc.c */ 6693 #line 141 2"parser.yy"6707 #line 1413 "parser.yy" 6694 6708 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6695 6709 break; … … 6698 6712 6699 6713 /* Line 1806 of yacc.c */ 6700 #line 141 4"parser.yy"6714 #line 1415 "parser.yy" 6701 6715 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6702 6716 break; … … 6705 6719 6706 6720 /* Line 1806 of yacc.c */ 6707 #line 141 6"parser.yy"6721 #line 1417 "parser.yy" 6708 6722 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6709 6723 break; … … 6712 6726 6713 6727 /* Line 1806 of yacc.c */ 6714 #line 141 8"parser.yy"6728 #line 1419 "parser.yy" 6715 6729 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); } 6716 6730 break; … … 6719 6733 6720 6734 /* Line 1806 of yacc.c */ 6721 #line 142 4"parser.yy"6735 #line 1425 "parser.yy" 6722 6736 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6723 6737 break; … … 6726 6740 6727 6741 /* Line 1806 of yacc.c */ 6728 #line 143 1"parser.yy"6742 #line 1432 "parser.yy" 6729 6743 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6730 6744 break; … … 6733 6747 6734 6748 /* Line 1806 of yacc.c */ 6735 #line 143 3"parser.yy"6749 #line 1434 "parser.yy" 6736 6750 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6737 6751 break; … … 6740 6754 6741 6755 /* Line 1806 of yacc.c */ 6742 #line 143 5"parser.yy"6756 #line 1436 "parser.yy" 6743 6757 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); } 6744 6758 break; … … 6747 6761 6748 6762 /* Line 1806 of yacc.c */ 6749 #line 144 0"parser.yy"6763 #line 1441 "parser.yy" 6750 6764 { (yyval.decl) = (yyvsp[(3) - (4)].decl); } 6751 6765 break; … … 6754 6768 6755 6769 /* Line 1806 of yacc.c */ 6756 #line 144 2"parser.yy"6770 #line 1443 "parser.yy" 6757 6771 { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); } 6758 6772 break; … … 6761 6775 6762 6776 /* Line 1806 of yacc.c */ 6763 #line 144 4"parser.yy"6777 #line 1445 "parser.yy" 6764 6778 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); } 6765 6779 break; … … 6768 6782 6769 6783 /* Line 1806 of yacc.c */ 6770 #line 144 6"parser.yy"6784 #line 1447 "parser.yy" 6771 6785 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 6772 6786 break; … … 6775 6789 6776 6790 /* Line 1806 of yacc.c */ 6777 #line 145 2"parser.yy"6791 #line 1453 "parser.yy" 6778 6792 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6779 6793 break; … … 6782 6796 6783 6797 /* Line 1806 of yacc.c */ 6784 #line 145 4"parser.yy"6798 #line 1455 "parser.yy" 6785 6799 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6786 6800 break; … … 6789 6803 6790 6804 /* Line 1806 of yacc.c */ 6791 #line 145 6"parser.yy"6805 #line 1457 "parser.yy" 6792 6806 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6793 6807 break; … … 6796 6810 6797 6811 /* Line 1806 of yacc.c */ 6798 #line 146 2"parser.yy"6812 #line 1463 "parser.yy" 6799 6813 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6800 6814 break; … … 6803 6817 6804 6818 /* Line 1806 of yacc.c */ 6805 #line 146 4"parser.yy"6819 #line 1465 "parser.yy" 6806 6820 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6807 6821 break; … … 6810 6824 6811 6825 /* Line 1806 of yacc.c */ 6812 #line 147 0"parser.yy"6826 #line 1471 "parser.yy" 6813 6827 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6814 6828 break; … … 6817 6831 6818 6832 /* Line 1806 of yacc.c */ 6819 #line 147 2"parser.yy"6833 #line 1473 "parser.yy" 6820 6834 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6821 6835 break; … … 6824 6838 6825 6839 /* Line 1806 of yacc.c */ 6826 #line 147 4"parser.yy"6840 #line 1475 "parser.yy" 6827 6841 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6828 6842 break; … … 6831 6845 6832 6846 /* Line 1806 of yacc.c */ 6833 #line 14 79"parser.yy"6847 #line 1480 "parser.yy" 6834 6848 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); } 6835 6849 break; … … 6838 6852 6839 6853 /* Line 1806 of yacc.c */ 6840 #line 148 1"parser.yy"6854 #line 1482 "parser.yy" 6841 6855 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6842 6856 break; … … 6845 6859 6846 6860 /* Line 1806 of yacc.c */ 6847 #line 148 3"parser.yy"6861 #line 1484 "parser.yy" 6848 6862 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6849 6863 break; … … 6852 6866 6853 6867 /* Line 1806 of yacc.c */ 6854 #line 149 3"parser.yy"6868 #line 1494 "parser.yy" 6855 6869 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), nullptr, nullptr, (yyvsp[(3) - (4)].decl), true ); } 6856 6870 break; … … 6859 6873 6860 6874 /* Line 1806 of yacc.c */ 6861 #line 149 5"parser.yy"6875 #line 1496 "parser.yy" 6862 6876 { 6863 6877 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 6869 6883 6870 6884 /* Line 1806 of yacc.c */ 6871 #line 150 0"parser.yy"6885 #line 1501 "parser.yy" 6872 6886 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 6873 6887 break; … … 6876 6890 6877 6891 /* Line 1806 of yacc.c */ 6878 #line 150 2"parser.yy"6892 #line 1503 "parser.yy" 6879 6893 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), nullptr, (yyvsp[(5) - (6)].decl), true ); } 6880 6894 break; … … 6883 6897 6884 6898 /* Line 1806 of yacc.c */ 6885 #line 150 4"parser.yy"6899 #line 1505 "parser.yy" 6886 6900 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), nullptr, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); } 6887 6901 break; … … 6890 6904 6891 6905 /* Line 1806 of yacc.c */ 6892 #line 150 6"parser.yy"6906 #line 1507 "parser.yy" 6893 6907 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 6894 6908 break; … … 6897 6911 6898 6912 /* Line 1806 of yacc.c */ 6899 #line 151 1"parser.yy"6913 #line 1512 "parser.yy" 6900 6914 { (yyval.aggKey) = DeclarationNode::Struct; } 6901 6915 break; … … 6904 6918 6905 6919 /* Line 1806 of yacc.c */ 6906 #line 151 3"parser.yy"6920 #line 1514 "parser.yy" 6907 6921 { (yyval.aggKey) = DeclarationNode::Union; } 6908 6922 break; … … 6911 6925 6912 6926 /* Line 1806 of yacc.c */ 6913 #line 151 8"parser.yy"6927 #line 1519 "parser.yy" 6914 6928 { (yyval.decl) = 0; } 6915 6929 break; … … 6918 6932 6919 6933 /* Line 1806 of yacc.c */ 6920 #line 152 0"parser.yy"6934 #line 1521 "parser.yy" 6921 6935 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 6922 6936 break; … … 6925 6939 6926 6940 /* Line 1806 of yacc.c */ 6927 #line 152 6"parser.yy"6941 #line 1527 "parser.yy" 6928 6942 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); } 6929 6943 break; … … 6932 6946 6933 6947 /* Line 1806 of yacc.c */ 6934 #line 15 29"parser.yy"6948 #line 1530 "parser.yy" 6935 6949 { // mark all fields in list 6936 6950 for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 6943 6957 6944 6958 /* Line 1806 of yacc.c */ 6945 #line 15 39"parser.yy"6959 #line 1540 "parser.yy" 6946 6960 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); } 6947 6961 break; … … 6950 6964 6951 6965 /* Line 1806 of yacc.c */ 6952 #line 154 1"parser.yy"6966 #line 1542 "parser.yy" 6953 6967 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); } 6954 6968 break; … … 6957 6971 6958 6972 /* Line 1806 of yacc.c */ 6959 #line 154 3"parser.yy"6973 #line 1544 "parser.yy" 6960 6974 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); } 6961 6975 break; … … 6964 6978 6965 6979 /* Line 1806 of yacc.c */ 6966 #line 154 8"parser.yy"6980 #line 1549 "parser.yy" 6967 6981 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 6968 6982 break; … … 6971 6985 6972 6986 /* Line 1806 of yacc.c */ 6973 #line 155 0"parser.yy"6987 #line 1551 "parser.yy" 6974 6988 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); } 6975 6989 break; … … 6978 6992 6979 6993 /* Line 1806 of yacc.c */ 6980 #line 155 5"parser.yy"6994 #line 1556 "parser.yy" 6981 6995 { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ } 6982 6996 break; … … 6985 6999 6986 7000 /* Line 1806 of yacc.c */ 6987 #line 155 7"parser.yy"7001 #line 1558 "parser.yy" 6988 7002 { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); } 6989 7003 break; … … 6992 7006 6993 7007 /* Line 1806 of yacc.c */ 6994 #line 156 0"parser.yy"7008 #line 1561 "parser.yy" 6995 7009 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 6996 7010 break; … … 6999 7013 7000 7014 /* Line 1806 of yacc.c */ 7001 #line 156 3"parser.yy"7015 #line 1564 "parser.yy" 7002 7016 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 7003 7017 break; … … 7006 7020 7007 7021 /* Line 1806 of yacc.c */ 7008 #line 15 69"parser.yy"7022 #line 1570 "parser.yy" 7009 7023 { (yyval.en) = 0; } 7010 7024 break; … … 7013 7027 7014 7028 /* Line 1806 of yacc.c */ 7015 #line 157 1"parser.yy"7029 #line 1572 "parser.yy" 7016 7030 { (yyval.en) = (yyvsp[(1) - (1)].en); } 7017 7031 break; … … 7020 7034 7021 7035 /* Line 1806 of yacc.c */ 7022 #line 157 6"parser.yy"7036 #line 1577 "parser.yy" 7023 7037 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7024 7038 break; … … 7027 7041 7028 7042 /* Line 1806 of yacc.c */ 7029 #line 158 5"parser.yy"7043 #line 1586 "parser.yy" 7030 7044 { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(3) - (5)].decl) ); } 7031 7045 break; … … 7034 7048 7035 7049 /* Line 1806 of yacc.c */ 7036 #line 158 7"parser.yy"7050 #line 1588 "parser.yy" 7037 7051 { 7038 7052 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 7044 7058 7045 7059 /* Line 1806 of yacc.c */ 7046 #line 159 2"parser.yy"7060 #line 1593 "parser.yy" 7047 7061 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 7048 7062 break; … … 7051 7065 7052 7066 /* Line 1806 of yacc.c */ 7053 #line 159 4"parser.yy"7067 #line 1595 "parser.yy" 7054 7068 { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); } 7055 7069 break; … … 7058 7072 7059 7073 /* Line 1806 of yacc.c */ 7060 #line 1 599"parser.yy"7074 #line 1600 "parser.yy" 7061 7075 { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); } 7062 7076 break; … … 7065 7079 7066 7080 /* Line 1806 of yacc.c */ 7067 #line 160 1"parser.yy"7081 #line 1602 "parser.yy" 7068 7082 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); } 7069 7083 break; … … 7072 7086 7073 7087 /* Line 1806 of yacc.c */ 7074 #line 160 6"parser.yy"7088 #line 1607 "parser.yy" 7075 7089 { (yyval.en) = 0; } 7076 7090 break; … … 7079 7093 7080 7094 /* Line 1806 of yacc.c */ 7081 #line 160 8"parser.yy"7095 #line 1609 "parser.yy" 7082 7096 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7083 7097 break; … … 7086 7100 7087 7101 /* Line 1806 of yacc.c */ 7088 #line 161 5"parser.yy"7102 #line 1616 "parser.yy" 7089 7103 { (yyval.decl) = 0; } 7090 7104 break; … … 7093 7107 7094 7108 /* Line 1806 of yacc.c */ 7095 #line 162 3"parser.yy"7109 #line 1624 "parser.yy" 7096 7110 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7097 7111 break; … … 7100 7114 7101 7115 /* Line 1806 of yacc.c */ 7102 #line 162 5"parser.yy"7116 #line 1626 "parser.yy" 7103 7117 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7104 7118 break; … … 7107 7121 7108 7122 /* Line 1806 of yacc.c */ 7109 #line 162 7"parser.yy"7123 #line 1628 "parser.yy" 7110 7124 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7111 7125 break; … … 7114 7128 7115 7129 /* Line 1806 of yacc.c */ 7116 #line 163 5"parser.yy"7130 #line 1636 "parser.yy" 7117 7131 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7118 7132 break; … … 7121 7135 7122 7136 /* Line 1806 of yacc.c */ 7123 #line 163 7"parser.yy"7137 #line 1638 "parser.yy" 7124 7138 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7125 7139 break; … … 7128 7142 7129 7143 /* Line 1806 of yacc.c */ 7130 #line 16 39"parser.yy"7144 #line 1640 "parser.yy" 7131 7145 { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); } 7132 7146 break; … … 7135 7149 7136 7150 /* Line 1806 of yacc.c */ 7137 #line 164 5"parser.yy"7151 #line 1646 "parser.yy" 7138 7152 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7139 7153 break; … … 7142 7156 7143 7157 /* Line 1806 of yacc.c */ 7144 #line 165 0"parser.yy"7158 #line 1651 "parser.yy" 7145 7159 { (yyval.decl) = 0; } 7146 7160 break; … … 7149 7163 7150 7164 /* Line 1806 of yacc.c */ 7151 #line 165 7"parser.yy"7165 #line 1658 "parser.yy" 7152 7166 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7153 7167 break; … … 7156 7170 7157 7171 /* Line 1806 of yacc.c */ 7158 #line 166 4"parser.yy"7172 #line 1665 "parser.yy" 7159 7173 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7160 7174 break; … … 7163 7177 7164 7178 /* Line 1806 of yacc.c */ 7165 #line 166 6"parser.yy"7179 #line 1667 "parser.yy" 7166 7180 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7167 7181 break; … … 7170 7184 7171 7185 /* Line 1806 of yacc.c */ 7172 #line 167 5"parser.yy"7186 #line 1676 "parser.yy" 7173 7187 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7174 7188 break; … … 7177 7191 7178 7192 /* Line 1806 of yacc.c */ 7179 #line 167 8"parser.yy"7193 #line 1679 "parser.yy" 7180 7194 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7181 7195 break; … … 7184 7198 7185 7199 /* Line 1806 of yacc.c */ 7186 #line 168 0"parser.yy"7200 #line 1681 "parser.yy" 7187 7201 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); } 7188 7202 break; … … 7191 7205 7192 7206 /* Line 1806 of yacc.c */ 7193 #line 169 0"parser.yy"7207 #line 1691 "parser.yy" 7194 7208 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7195 7209 break; … … 7198 7212 7199 7213 /* Line 1806 of yacc.c */ 7200 #line 169 6"parser.yy"7214 #line 1697 "parser.yy" 7201 7215 { 7202 7216 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7208 7222 7209 7223 /* Line 1806 of yacc.c */ 7210 #line 170 1"parser.yy"7224 #line 1702 "parser.yy" 7211 7225 { 7212 7226 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7218 7232 7219 7233 /* Line 1806 of yacc.c */ 7220 #line 171 0"parser.yy"7234 #line 1711 "parser.yy" 7221 7235 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7222 7236 break; … … 7225 7239 7226 7240 /* Line 1806 of yacc.c */ 7227 #line 17 19"parser.yy"7241 #line 1720 "parser.yy" 7228 7242 { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); } 7229 7243 break; … … 7232 7246 7233 7247 /* Line 1806 of yacc.c */ 7234 #line 172 1"parser.yy"7248 #line 1722 "parser.yy" 7235 7249 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); } 7236 7250 break; … … 7239 7253 7240 7254 /* Line 1806 of yacc.c */ 7241 #line 174 6"parser.yy"7255 #line 1747 "parser.yy" 7242 7256 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7243 7257 break; … … 7246 7260 7247 7261 /* Line 1806 of yacc.c */ 7248 #line 175 4"parser.yy"7262 #line 1755 "parser.yy" 7249 7263 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7250 7264 break; … … 7253 7267 7254 7268 /* Line 1806 of yacc.c */ 7255 #line 17 59"parser.yy"7269 #line 1760 "parser.yy" 7256 7270 { (yyval.in) = 0; } 7257 7271 break; … … 7260 7274 7261 7275 /* Line 1806 of yacc.c */ 7262 #line 176 1"parser.yy"7276 #line 1762 "parser.yy" 7263 7277 { (yyval.in) = (yyvsp[(2) - (2)].in); } 7264 7278 break; … … 7267 7281 7268 7282 /* Line 1806 of yacc.c */ 7269 #line 176 3"parser.yy"7283 #line 1764 "parser.yy" 7270 7284 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); } 7271 7285 break; … … 7274 7288 7275 7289 /* Line 1806 of yacc.c */ 7276 #line 176 7"parser.yy"7290 #line 1768 "parser.yy" 7277 7291 { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); } 7278 7292 break; … … 7281 7295 7282 7296 /* Line 1806 of yacc.c */ 7283 #line 176 8"parser.yy"7297 #line 1769 "parser.yy" 7284 7298 { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); } 7285 7299 break; … … 7288 7302 7289 7303 /* Line 1806 of yacc.c */ 7290 #line 177 3"parser.yy"7304 #line 1774 "parser.yy" 7291 7305 { (yyval.in) = 0; } 7292 7306 break; … … 7295 7309 7296 7310 /* Line 1806 of yacc.c */ 7297 #line 177 5"parser.yy"7311 #line 1776 "parser.yy" 7298 7312 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); } 7299 7313 break; … … 7302 7316 7303 7317 /* Line 1806 of yacc.c */ 7304 #line 177 6"parser.yy"7318 #line 1777 "parser.yy" 7305 7319 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); } 7306 7320 break; … … 7309 7323 7310 7324 /* Line 1806 of yacc.c */ 7311 #line 177 8"parser.yy"7325 #line 1779 "parser.yy" 7312 7326 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_last( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); } 7313 7327 break; … … 7316 7330 7317 7331 /* Line 1806 of yacc.c */ 7318 #line 179 4"parser.yy"7332 #line 1795 "parser.yy" 7319 7333 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); } 7320 7334 break; … … 7323 7337 7324 7338 /* Line 1806 of yacc.c */ 7325 #line 180 0"parser.yy"7339 #line 1801 "parser.yy" 7326 7340 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_last( (yyvsp[(2) - (2)].en) ) ); } 7327 7341 break; … … 7330 7344 7331 7345 /* Line 1806 of yacc.c */ 7332 #line 180 6"parser.yy"7346 #line 1807 "parser.yy" 7333 7347 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); } 7334 7348 break; … … 7337 7351 7338 7352 /* Line 1806 of yacc.c */ 7339 #line 18 09"parser.yy"7353 #line 1810 "parser.yy" 7340 7354 { (yyval.en) = (yyvsp[(3) - (5)].en); } 7341 7355 break; … … 7344 7358 7345 7359 /* Line 1806 of yacc.c */ 7346 #line 181 1"parser.yy"7360 #line 1812 "parser.yy" 7347 7361 { (yyval.en) = (yyvsp[(3) - (5)].en); } 7348 7362 break; … … 7351 7365 7352 7366 /* Line 1806 of yacc.c */ 7353 #line 181 3"parser.yy"7367 #line 1814 "parser.yy" 7354 7368 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ); } 7355 7369 break; … … 7358 7372 7359 7373 /* Line 1806 of yacc.c */ 7360 #line 181 5"parser.yy"7374 #line 1816 "parser.yy" 7361 7375 { (yyval.en) = (yyvsp[(4) - (6)].en); } 7362 7376 break; … … 7365 7379 7366 7380 /* Line 1806 of yacc.c */ 7367 #line 18 39"parser.yy"7381 #line 1840 "parser.yy" 7368 7382 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7369 7383 break; … … 7372 7386 7373 7387 /* Line 1806 of yacc.c */ 7374 #line 184 1"parser.yy"7388 #line 1842 "parser.yy" 7375 7389 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7376 7390 break; … … 7379 7393 7380 7394 /* Line 1806 of yacc.c */ 7381 #line 184 3"parser.yy"7395 #line 1844 "parser.yy" 7382 7396 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7383 7397 break; … … 7386 7400 7387 7401 /* Line 1806 of yacc.c */ 7388 #line 18 49"parser.yy"7402 #line 1850 "parser.yy" 7389 7403 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7390 7404 break; … … 7393 7407 7394 7408 /* Line 1806 of yacc.c */ 7395 #line 185 1"parser.yy"7409 #line 1852 "parser.yy" 7396 7410 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7397 7411 break; … … 7400 7414 7401 7415 /* Line 1806 of yacc.c */ 7402 #line 185 6"parser.yy"7416 #line 1857 "parser.yy" 7403 7417 { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 7404 7418 break; … … 7407 7421 7408 7422 /* Line 1806 of yacc.c */ 7409 #line 186 2"parser.yy"7423 #line 1863 "parser.yy" 7410 7424 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); } 7411 7425 break; … … 7414 7428 7415 7429 /* Line 1806 of yacc.c */ 7416 #line 186 7"parser.yy"7430 #line 1868 "parser.yy" 7417 7431 { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); } 7418 7432 break; … … 7421 7435 7422 7436 /* Line 1806 of yacc.c */ 7423 #line 18 69"parser.yy"7437 #line 1870 "parser.yy" 7424 7438 { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); } 7425 7439 break; … … 7428 7442 7429 7443 /* Line 1806 of yacc.c */ 7430 #line 187 5"parser.yy"7444 #line 1876 "parser.yy" 7431 7445 { (yyval.tclass) = DeclarationNode::Otype; } 7432 7446 break; … … 7435 7449 7436 7450 /* Line 1806 of yacc.c */ 7437 #line 187 7"parser.yy"7451 #line 1878 "parser.yy" 7438 7452 { (yyval.tclass) = DeclarationNode::Ftype; } 7439 7453 break; … … 7442 7456 7443 7457 /* Line 1806 of yacc.c */ 7444 #line 18 79"parser.yy"7458 #line 1880 "parser.yy" 7445 7459 { (yyval.tclass) = DeclarationNode::Dtype; } 7446 7460 break; … … 7449 7463 7450 7464 /* Line 1806 of yacc.c */ 7451 #line 188 4"parser.yy"7465 #line 1885 "parser.yy" 7452 7466 { (yyval.decl) = 0; } 7453 7467 break; … … 7456 7470 7457 7471 /* Line 1806 of yacc.c */ 7458 #line 188 6"parser.yy"7472 #line 1887 "parser.yy" 7459 7473 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 7460 7474 break; … … 7463 7477 7464 7478 /* Line 1806 of yacc.c */ 7465 #line 189 1"parser.yy"7479 #line 1892 "parser.yy" 7466 7480 { 7467 7481 typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) ); … … 7473 7487 7474 7488 /* Line 1806 of yacc.c */ 7475 #line 189 6"parser.yy"7489 #line 1897 "parser.yy" 7476 7490 { (yyval.decl) = (yyvsp[(4) - (5)].decl); } 7477 7491 break; … … 7480 7494 7481 7495 /* Line 1806 of yacc.c */ 7482 #line 189 8"parser.yy"7496 #line 1899 "parser.yy" 7483 7497 { (yyval.decl) = 0; } 7484 7498 break; … … 7487 7501 7488 7502 /* Line 1806 of yacc.c */ 7489 #line 190 3"parser.yy"7503 #line 1904 "parser.yy" 7490 7504 { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); } 7491 7505 break; … … 7494 7508 7495 7509 /* Line 1806 of yacc.c */ 7496 #line 190 6"parser.yy"7510 #line 1907 "parser.yy" 7497 7511 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( build_typevalue( (yyvsp[(3) - (3)].decl) ) ) ) ); } 7498 7512 break; … … 7501 7515 7502 7516 /* Line 1806 of yacc.c */ 7503 #line 190 8"parser.yy"7517 #line 1909 "parser.yy" 7504 7518 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); } 7505 7519 break; … … 7508 7522 7509 7523 /* Line 1806 of yacc.c */ 7510 #line 191 3"parser.yy"7524 #line 1914 "parser.yy" 7511 7525 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 7512 7526 break; … … 7515 7529 7516 7530 /* Line 1806 of yacc.c */ 7517 #line 191 5"parser.yy"7531 #line 1916 "parser.yy" 7518 7532 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); } 7519 7533 break; … … 7522 7536 7523 7537 /* Line 1806 of yacc.c */ 7524 #line 191 7"parser.yy"7538 #line 1918 "parser.yy" 7525 7539 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); } 7526 7540 break; … … 7529 7543 7530 7544 /* Line 1806 of yacc.c */ 7531 #line 192 2"parser.yy"7545 #line 1923 "parser.yy" 7532 7546 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); } 7533 7547 break; … … 7536 7550 7537 7551 /* Line 1806 of yacc.c */ 7538 #line 192 4"parser.yy"7552 #line 1925 "parser.yy" 7539 7553 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); } 7540 7554 break; … … 7543 7557 7544 7558 /* Line 1806 of yacc.c */ 7545 #line 19 29"parser.yy"7559 #line 1930 "parser.yy" 7546 7560 { 7547 7561 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD ); … … 7553 7567 7554 7568 /* Line 1806 of yacc.c */ 7555 #line 193 4"parser.yy"7569 #line 1935 "parser.yy" 7556 7570 { 7557 7571 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG ); … … 7563 7577 7564 7578 /* Line 1806 of yacc.c */ 7565 #line 194 2"parser.yy"7579 #line 1943 "parser.yy" 7566 7580 { 7567 7581 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID ); … … 7573 7587 7574 7588 /* Line 1806 of yacc.c */ 7575 #line 194 7"parser.yy"7589 #line 1948 "parser.yy" 7576 7590 { 7577 7591 typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) ); … … 7583 7597 7584 7598 /* Line 1806 of yacc.c */ 7585 #line 195 2"parser.yy"7599 #line 1953 "parser.yy" 7586 7600 { 7587 7601 typedefTable.leaveTrait(); … … 7594 7608 7595 7609 /* Line 1806 of yacc.c */ 7596 #line 196 2"parser.yy"7610 #line 1963 "parser.yy" 7597 7611 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 7598 7612 break; … … 7601 7615 7602 7616 /* Line 1806 of yacc.c */ 7603 #line 197 2"parser.yy"7617 #line 1973 "parser.yy" 7604 7618 { 7605 7619 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7611 7625 7612 7626 /* Line 1806 of yacc.c */ 7613 #line 197 7"parser.yy"7627 #line 1978 "parser.yy" 7614 7628 { 7615 7629 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7621 7635 7622 7636 /* Line 1806 of yacc.c */ 7623 #line 198 2"parser.yy"7637 #line 1983 "parser.yy" 7624 7638 { 7625 7639 typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 7631 7645 7632 7646 /* Line 1806 of yacc.c */ 7633 #line 199 0"parser.yy"7647 #line 1991 "parser.yy" 7634 7648 { 7635 7649 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7641 7655 7642 7656 /* Line 1806 of yacc.c */ 7643 #line 199 5"parser.yy"7657 #line 1996 "parser.yy" 7644 7658 { 7645 7659 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7651 7665 7652 7666 /* Line 1806 of yacc.c */ 7653 #line 200 5"parser.yy"7667 #line 2006 "parser.yy" 7654 7668 {} 7655 7669 break; … … 7658 7672 7659 7673 /* Line 1806 of yacc.c */ 7660 #line 200 7"parser.yy"7674 #line 2008 "parser.yy" 7661 7675 { parseTree = parseTree != nullptr ? parseTree->appendList( (yyvsp[(1) - (1)].decl) ) : (yyvsp[(1) - (1)].decl); } 7662 7676 break; … … 7665 7679 7666 7680 /* Line 1806 of yacc.c */ 7667 #line 201 3"parser.yy"7681 #line 2014 "parser.yy" 7668 7682 { (yyval.decl) = (yyvsp[(1) - (3)].decl) != nullptr ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); } 7669 7683 break; … … 7672 7686 7673 7687 /* Line 1806 of yacc.c */ 7674 #line 201 8"parser.yy"7688 #line 2019 "parser.yy" 7675 7689 { (yyval.decl) = 0; } 7676 7690 break; … … 7679 7693 7680 7694 /* Line 1806 of yacc.c */ 7681 #line 202 6"parser.yy"7695 #line 2027 "parser.yy" 7682 7696 {} 7683 7697 break; … … 7686 7700 7687 7701 /* Line 1806 of yacc.c */ 7688 #line 202 8"parser.yy"7702 #line 2029 "parser.yy" 7689 7703 { 7690 7704 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" … … 7696 7710 7697 7711 /* Line 1806 of yacc.c */ 7698 #line 203 3"parser.yy"7712 #line 2034 "parser.yy" 7699 7713 { 7700 7714 linkage = linkageStack.top(); … … 7707 7721 7708 7722 /* Line 1806 of yacc.c */ 7709 #line 20 39"parser.yy"7723 #line 2040 "parser.yy" 7710 7724 { // mark all fields in list 7711 7725 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 7718 7732 7719 7733 /* Line 1806 of yacc.c */ 7720 #line 205 4"parser.yy"7734 #line 2055 "parser.yy" 7721 7735 { 7722 7736 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7729 7743 7730 7744 /* Line 1806 of yacc.c */ 7731 #line 206 0"parser.yy"7745 #line 2061 "parser.yy" 7732 7746 { 7733 7747 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7740 7754 7741 7755 /* Line 1806 of yacc.c */ 7742 #line 20 69"parser.yy"7756 #line 2070 "parser.yy" 7743 7757 { 7744 7758 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7751 7765 7752 7766 /* Line 1806 of yacc.c */ 7753 #line 207 5"parser.yy"7767 #line 2076 "parser.yy" 7754 7768 { 7755 7769 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7762 7776 7763 7777 /* Line 1806 of yacc.c */ 7764 #line 208 1"parser.yy"7778 #line 2082 "parser.yy" 7765 7779 { 7766 7780 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7773 7787 7774 7788 /* Line 1806 of yacc.c */ 7775 #line 208 7"parser.yy"7789 #line 2088 "parser.yy" 7776 7790 { 7777 7791 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7784 7798 7785 7799 /* Line 1806 of yacc.c */ 7786 #line 209 3"parser.yy"7800 #line 2094 "parser.yy" 7787 7801 { 7788 7802 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7795 7809 7796 7810 /* Line 1806 of yacc.c */ 7797 #line 210 1"parser.yy"7811 #line 2102 "parser.yy" 7798 7812 { 7799 7813 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7806 7820 7807 7821 /* Line 1806 of yacc.c */ 7808 #line 210 7"parser.yy"7822 #line 2108 "parser.yy" 7809 7823 { 7810 7824 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7817 7831 7818 7832 /* Line 1806 of yacc.c */ 7819 #line 211 5"parser.yy"7833 #line 2116 "parser.yy" 7820 7834 { 7821 7835 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7828 7842 7829 7843 /* Line 1806 of yacc.c */ 7830 #line 212 1"parser.yy"7844 #line 2122 "parser.yy" 7831 7845 { 7832 7846 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7839 7853 7840 7854 /* Line 1806 of yacc.c */ 7841 #line 213 6"parser.yy"7855 #line 2137 "parser.yy" 7842 7856 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 7843 7857 break; … … 7846 7860 7847 7861 /* Line 1806 of yacc.c */ 7848 #line 214 1"parser.yy"7862 #line 2142 "parser.yy" 7849 7863 { delete (yyvsp[(3) - (5)].str); } 7850 7864 break; … … 7853 7867 7854 7868 /* Line 1806 of yacc.c */ 7855 #line 214 6"parser.yy"7869 #line 2147 "parser.yy" 7856 7870 { (yyval.decl) = 0; } 7857 7871 break; … … 7860 7874 7861 7875 /* Line 1806 of yacc.c */ 7862 #line 215 3"parser.yy"7876 #line 2154 "parser.yy" 7863 7877 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7864 7878 break; … … 7867 7881 7868 7882 /* Line 1806 of yacc.c */ 7869 #line 21 59"parser.yy"7883 #line 2160 "parser.yy" 7870 7884 { (yyval.decl) = 0; } 7871 7885 break; … … 7874 7888 7875 7889 /* Line 1806 of yacc.c */ 7876 #line 217 0"parser.yy"7890 #line 2171 "parser.yy" 7877 7891 { delete (yyvsp[(3) - (4)].en); } 7878 7892 break; … … 7881 7895 7882 7896 /* Line 1806 of yacc.c */ 7883 #line 217 4"parser.yy"7897 #line 2175 "parser.yy" 7884 7898 { delete (yyvsp[(1) - (1)].tok); } 7885 7899 break; 7886 7900 7887 7901 case 562: 7888 7889 /* Line 1806 of yacc.c */7890 #line 2175 "parser.yy"7891 { delete (yyvsp[(1) - (1)].decl); }7892 break;7893 7894 case 563:7895 7902 7896 7903 /* Line 1806 of yacc.c */ … … 7899 7906 break; 7900 7907 7901 case 56 4:7908 case 563: 7902 7909 7903 7910 /* Line 1806 of yacc.c */ … … 7906 7913 break; 7907 7914 7915 case 564: 7916 7917 /* Line 1806 of yacc.c */ 7918 #line 2178 "parser.yy" 7919 { delete (yyvsp[(1) - (1)].decl); } 7920 break; 7921 7908 7922 case 565: 7909 7923 7910 7924 /* Line 1806 of yacc.c */ 7911 #line 221 2"parser.yy"7925 #line 2213 "parser.yy" 7912 7926 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7913 7927 break; … … 7916 7930 7917 7931 /* Line 1806 of yacc.c */ 7918 #line 221 5"parser.yy"7932 #line 2216 "parser.yy" 7919 7933 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7920 7934 break; … … 7923 7937 7924 7938 /* Line 1806 of yacc.c */ 7925 #line 221 7"parser.yy"7939 #line 2218 "parser.yy" 7926 7940 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7927 7941 break; … … 7930 7944 7931 7945 /* Line 1806 of yacc.c */ 7932 #line 222 2"parser.yy"7946 #line 2223 "parser.yy" 7933 7947 { 7934 7948 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 7940 7954 7941 7955 /* Line 1806 of yacc.c */ 7942 #line 222 7"parser.yy"7956 #line 2228 "parser.yy" 7943 7957 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 7944 7958 break; … … 7947 7961 7948 7962 /* Line 1806 of yacc.c */ 7949 #line 223 2"parser.yy"7963 #line 2233 "parser.yy" 7950 7964 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 7951 7965 break; … … 7954 7968 7955 7969 /* Line 1806 of yacc.c */ 7956 #line 223 4"parser.yy"7970 #line 2235 "parser.yy" 7957 7971 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 7958 7972 break; … … 7961 7975 7962 7976 /* Line 1806 of yacc.c */ 7963 #line 223 6"parser.yy"7977 #line 2237 "parser.yy" 7964 7978 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 7965 7979 break; … … 7968 7982 7969 7983 /* Line 1806 of yacc.c */ 7970 #line 224 1"parser.yy"7984 #line 2242 "parser.yy" 7971 7985 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 7972 7986 break; … … 7975 7989 7976 7990 /* Line 1806 of yacc.c */ 7977 #line 224 3"parser.yy"7991 #line 2244 "parser.yy" 7978 7992 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 7979 7993 break; … … 7982 7996 7983 7997 /* Line 1806 of yacc.c */ 7984 #line 224 5"parser.yy"7998 #line 2246 "parser.yy" 7985 7999 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 7986 8000 break; … … 7989 8003 7990 8004 /* Line 1806 of yacc.c */ 7991 #line 224 7"parser.yy"8005 #line 2248 "parser.yy" 7992 8006 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 7993 8007 break; … … 7996 8010 7997 8011 /* Line 1806 of yacc.c */ 7998 #line 225 2"parser.yy"8012 #line 2253 "parser.yy" 7999 8013 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8000 8014 break; … … 8003 8017 8004 8018 /* Line 1806 of yacc.c */ 8005 #line 225 4"parser.yy"8019 #line 2255 "parser.yy" 8006 8020 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8007 8021 break; … … 8010 8024 8011 8025 /* Line 1806 of yacc.c */ 8012 #line 226 3"parser.yy"8026 #line 2264 "parser.yy" 8013 8027 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8014 8028 break; … … 8017 8031 8018 8032 /* Line 1806 of yacc.c */ 8019 #line 226 6"parser.yy"8033 #line 2267 "parser.yy" 8020 8034 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8021 8035 break; … … 8024 8038 8025 8039 /* Line 1806 of yacc.c */ 8026 #line 227 1"parser.yy"8040 #line 2272 "parser.yy" 8027 8041 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8028 8042 break; … … 8031 8045 8032 8046 /* Line 1806 of yacc.c */ 8033 #line 227 3"parser.yy"8047 #line 2274 "parser.yy" 8034 8048 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8035 8049 break; … … 8038 8052 8039 8053 /* Line 1806 of yacc.c */ 8040 #line 227 5"parser.yy"8054 #line 2276 "parser.yy" 8041 8055 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8042 8056 break; … … 8045 8059 8046 8060 /* Line 1806 of yacc.c */ 8047 #line 228 0"parser.yy"8061 #line 2281 "parser.yy" 8048 8062 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8049 8063 break; … … 8052 8066 8053 8067 /* Line 1806 of yacc.c */ 8054 #line 228 2"parser.yy"8068 #line 2283 "parser.yy" 8055 8069 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8056 8070 break; … … 8059 8073 8060 8074 /* Line 1806 of yacc.c */ 8061 #line 228 4"parser.yy"8075 #line 2285 "parser.yy" 8062 8076 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8063 8077 break; … … 8066 8080 8067 8081 /* Line 1806 of yacc.c */ 8068 #line 22 89"parser.yy"8082 #line 2290 "parser.yy" 8069 8083 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8070 8084 break; … … 8073 8087 8074 8088 /* Line 1806 of yacc.c */ 8075 #line 229 1"parser.yy"8089 #line 2292 "parser.yy" 8076 8090 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8077 8091 break; … … 8080 8094 8081 8095 /* Line 1806 of yacc.c */ 8082 #line 229 3"parser.yy"8096 #line 2294 "parser.yy" 8083 8097 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8084 8098 break; … … 8087 8101 8088 8102 /* Line 1806 of yacc.c */ 8089 #line 230 8"parser.yy"8103 #line 2309 "parser.yy" 8090 8104 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); } 8091 8105 break; … … 8094 8108 8095 8109 /* Line 1806 of yacc.c */ 8096 #line 231 0"parser.yy"8110 #line 2311 "parser.yy" 8097 8111 { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); } 8098 8112 break; … … 8101 8115 8102 8116 /* Line 1806 of yacc.c */ 8103 #line 231 2"parser.yy"8117 #line 2313 "parser.yy" 8104 8118 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8105 8119 break; … … 8108 8122 8109 8123 /* Line 1806 of yacc.c */ 8110 #line 231 7"parser.yy"8124 #line 2318 "parser.yy" 8111 8125 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8112 8126 break; … … 8115 8129 8116 8130 /* Line 1806 of yacc.c */ 8117 #line 23 19"parser.yy"8131 #line 2320 "parser.yy" 8118 8132 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8119 8133 break; … … 8122 8136 8123 8137 /* Line 1806 of yacc.c */ 8124 #line 232 1"parser.yy"8138 #line 2322 "parser.yy" 8125 8139 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8126 8140 break; … … 8129 8143 8130 8144 /* Line 1806 of yacc.c */ 8131 #line 232 6"parser.yy"8145 #line 2327 "parser.yy" 8132 8146 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8133 8147 break; … … 8136 8150 8137 8151 /* Line 1806 of yacc.c */ 8138 #line 232 8"parser.yy"8152 #line 2329 "parser.yy" 8139 8153 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8140 8154 break; … … 8143 8157 8144 8158 /* Line 1806 of yacc.c */ 8145 #line 233 0"parser.yy"8159 #line 2331 "parser.yy" 8146 8160 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8147 8161 break; … … 8150 8164 8151 8165 /* Line 1806 of yacc.c */ 8152 #line 234 5"parser.yy"8166 #line 2346 "parser.yy" 8153 8167 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8154 8168 break; … … 8157 8171 8158 8172 /* Line 1806 of yacc.c */ 8159 #line 234 8"parser.yy"8173 #line 2349 "parser.yy" 8160 8174 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8161 8175 break; … … 8164 8178 8165 8179 /* Line 1806 of yacc.c */ 8166 #line 235 0"parser.yy"8180 #line 2351 "parser.yy" 8167 8181 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8168 8182 break; … … 8171 8185 8172 8186 /* Line 1806 of yacc.c */ 8173 #line 235 6"parser.yy"8187 #line 2357 "parser.yy" 8174 8188 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8175 8189 break; … … 8178 8192 8179 8193 /* Line 1806 of yacc.c */ 8180 #line 236 1"parser.yy"8194 #line 2362 "parser.yy" 8181 8195 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8182 8196 break; … … 8185 8199 8186 8200 /* Line 1806 of yacc.c */ 8187 #line 236 3"parser.yy"8201 #line 2364 "parser.yy" 8188 8202 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8189 8203 break; … … 8192 8206 8193 8207 /* Line 1806 of yacc.c */ 8194 #line 236 5"parser.yy"8208 #line 2366 "parser.yy" 8195 8209 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8196 8210 break; … … 8199 8213 8200 8214 /* Line 1806 of yacc.c */ 8201 #line 237 0"parser.yy"8215 #line 2371 "parser.yy" 8202 8216 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8203 8217 break; … … 8206 8220 8207 8221 /* Line 1806 of yacc.c */ 8208 #line 237 2"parser.yy"8222 #line 2373 "parser.yy" 8209 8223 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8210 8224 break; … … 8213 8227 8214 8228 /* Line 1806 of yacc.c */ 8215 #line 237 4"parser.yy"8229 #line 2375 "parser.yy" 8216 8230 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8217 8231 break; … … 8220 8234 8221 8235 /* Line 1806 of yacc.c */ 8222 #line 237 6"parser.yy"8236 #line 2377 "parser.yy" 8223 8237 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8224 8238 break; … … 8227 8241 8228 8242 /* Line 1806 of yacc.c */ 8229 #line 238 1"parser.yy"8243 #line 2382 "parser.yy" 8230 8244 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8231 8245 break; … … 8234 8248 8235 8249 /* Line 1806 of yacc.c */ 8236 #line 238 3"parser.yy"8250 #line 2384 "parser.yy" 8237 8251 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8238 8252 break; … … 8241 8255 8242 8256 /* Line 1806 of yacc.c */ 8243 #line 238 5"parser.yy"8257 #line 2386 "parser.yy" 8244 8258 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8245 8259 break; … … 8248 8262 8249 8263 /* Line 1806 of yacc.c */ 8250 #line 239 5"parser.yy"8264 #line 2396 "parser.yy" 8251 8265 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8252 8266 break; … … 8255 8269 8256 8270 /* Line 1806 of yacc.c */ 8257 #line 239 8"parser.yy"8271 #line 2399 "parser.yy" 8258 8272 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8259 8273 break; … … 8262 8276 8263 8277 /* Line 1806 of yacc.c */ 8264 #line 240 0"parser.yy"8278 #line 2401 "parser.yy" 8265 8279 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8266 8280 break; … … 8269 8283 8270 8284 /* Line 1806 of yacc.c */ 8271 #line 240 5"parser.yy"8285 #line 2406 "parser.yy" 8272 8286 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8273 8287 break; … … 8276 8290 8277 8291 /* Line 1806 of yacc.c */ 8278 #line 240 7"parser.yy"8292 #line 2408 "parser.yy" 8279 8293 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8280 8294 break; … … 8283 8297 8284 8298 /* Line 1806 of yacc.c */ 8285 #line 24 09"parser.yy"8299 #line 2410 "parser.yy" 8286 8300 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8287 8301 break; … … 8290 8304 8291 8305 /* Line 1806 of yacc.c */ 8292 #line 241 4"parser.yy"8306 #line 2415 "parser.yy" 8293 8307 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8294 8308 break; … … 8297 8311 8298 8312 /* Line 1806 of yacc.c */ 8299 #line 241 6"parser.yy"8313 #line 2417 "parser.yy" 8300 8314 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8301 8315 break; … … 8304 8318 8305 8319 /* Line 1806 of yacc.c */ 8306 #line 241 8"parser.yy"8320 #line 2419 "parser.yy" 8307 8321 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8308 8322 break; … … 8311 8325 8312 8326 /* Line 1806 of yacc.c */ 8313 #line 242 0"parser.yy"8327 #line 2421 "parser.yy" 8314 8328 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8315 8329 break; … … 8318 8332 8319 8333 /* Line 1806 of yacc.c */ 8320 #line 242 5"parser.yy"8334 #line 2426 "parser.yy" 8321 8335 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8322 8336 break; … … 8325 8339 8326 8340 /* Line 1806 of yacc.c */ 8327 #line 242 7"parser.yy"8341 #line 2428 "parser.yy" 8328 8342 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8329 8343 break; … … 8332 8346 8333 8347 /* Line 1806 of yacc.c */ 8334 #line 24 29"parser.yy"8348 #line 2430 "parser.yy" 8335 8349 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8336 8350 break; … … 8339 8353 8340 8354 /* Line 1806 of yacc.c */ 8341 #line 246 0"parser.yy"8355 #line 2461 "parser.yy" 8342 8356 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8343 8357 break; … … 8346 8360 8347 8361 /* Line 1806 of yacc.c */ 8348 #line 246 3"parser.yy"8362 #line 2464 "parser.yy" 8349 8363 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8350 8364 break; … … 8353 8367 8354 8368 /* Line 1806 of yacc.c */ 8355 #line 246 5"parser.yy"8369 #line 2466 "parser.yy" 8356 8370 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8357 8371 break; … … 8360 8374 8361 8375 /* Line 1806 of yacc.c */ 8362 #line 247 0"parser.yy"8376 #line 2471 "parser.yy" 8363 8377 { 8364 8378 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8370 8384 8371 8385 /* Line 1806 of yacc.c */ 8372 #line 247 5"parser.yy"8386 #line 2476 "parser.yy" 8373 8387 { 8374 8388 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8380 8394 8381 8395 /* Line 1806 of yacc.c */ 8382 #line 248 3"parser.yy"8396 #line 2484 "parser.yy" 8383 8397 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8384 8398 break; … … 8387 8401 8388 8402 /* Line 1806 of yacc.c */ 8389 #line 248 5"parser.yy"8403 #line 2486 "parser.yy" 8390 8404 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8391 8405 break; … … 8394 8408 8395 8409 /* Line 1806 of yacc.c */ 8396 #line 248 7"parser.yy"8410 #line 2488 "parser.yy" 8397 8411 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8398 8412 break; … … 8401 8415 8402 8416 /* Line 1806 of yacc.c */ 8403 #line 249 2"parser.yy"8417 #line 2493 "parser.yy" 8404 8418 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8405 8419 break; … … 8408 8422 8409 8423 /* Line 1806 of yacc.c */ 8410 #line 249 4"parser.yy"8424 #line 2495 "parser.yy" 8411 8425 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8412 8426 break; … … 8415 8429 8416 8430 /* Line 1806 of yacc.c */ 8417 #line 2 499"parser.yy"8431 #line 2500 "parser.yy" 8418 8432 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8419 8433 break; … … 8422 8436 8423 8437 /* Line 1806 of yacc.c */ 8424 #line 250 1"parser.yy"8438 #line 2502 "parser.yy" 8425 8439 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8426 8440 break; … … 8429 8443 8430 8444 /* Line 1806 of yacc.c */ 8431 #line 251 6"parser.yy"8445 #line 2517 "parser.yy" 8432 8446 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8433 8447 break; … … 8436 8450 8437 8451 /* Line 1806 of yacc.c */ 8438 #line 251 8"parser.yy"8452 #line 2519 "parser.yy" 8439 8453 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8440 8454 break; … … 8443 8457 8444 8458 /* Line 1806 of yacc.c */ 8445 #line 252 3"parser.yy"8459 #line 2524 "parser.yy" 8446 8460 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8447 8461 break; … … 8450 8464 8451 8465 /* Line 1806 of yacc.c */ 8452 #line 252 5"parser.yy"8466 #line 2526 "parser.yy" 8453 8467 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8454 8468 break; … … 8457 8471 8458 8472 /* Line 1806 of yacc.c */ 8459 #line 252 7"parser.yy"8473 #line 2528 "parser.yy" 8460 8474 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8461 8475 break; … … 8464 8478 8465 8479 /* Line 1806 of yacc.c */ 8466 #line 25 29"parser.yy"8480 #line 2530 "parser.yy" 8467 8481 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8468 8482 break; … … 8471 8485 8472 8486 /* Line 1806 of yacc.c */ 8473 #line 253 1"parser.yy"8487 #line 2532 "parser.yy" 8474 8488 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8475 8489 break; … … 8478 8492 8479 8493 /* Line 1806 of yacc.c */ 8480 #line 253 7"parser.yy"8494 #line 2538 "parser.yy" 8481 8495 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8482 8496 break; … … 8485 8499 8486 8500 /* Line 1806 of yacc.c */ 8487 #line 25 39"parser.yy"8501 #line 2540 "parser.yy" 8488 8502 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8489 8503 break; … … 8492 8506 8493 8507 /* Line 1806 of yacc.c */ 8494 #line 254 1"parser.yy"8508 #line 2542 "parser.yy" 8495 8509 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8496 8510 break; … … 8499 8513 8500 8514 /* Line 1806 of yacc.c */ 8501 #line 254 6"parser.yy"8515 #line 2547 "parser.yy" 8502 8516 { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); } 8503 8517 break; … … 8506 8520 8507 8521 /* Line 1806 of yacc.c */ 8508 #line 254 8"parser.yy"8522 #line 2549 "parser.yy" 8509 8523 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8510 8524 break; … … 8513 8527 8514 8528 /* Line 1806 of yacc.c */ 8515 #line 255 0"parser.yy"8529 #line 2551 "parser.yy" 8516 8530 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8517 8531 break; … … 8520 8534 8521 8535 /* Line 1806 of yacc.c */ 8522 #line 255 6"parser.yy"8536 #line 2557 "parser.yy" 8523 8537 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8524 8538 break; … … 8527 8541 8528 8542 /* Line 1806 of yacc.c */ 8529 #line 255 8"parser.yy"8543 #line 2559 "parser.yy" 8530 8544 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); } 8531 8545 break; … … 8534 8548 8535 8549 /* Line 1806 of yacc.c */ 8536 #line 256 4"parser.yy"8550 #line 2565 "parser.yy" 8537 8551 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); } 8538 8552 break; … … 8541 8555 8542 8556 /* Line 1806 of yacc.c */ 8543 #line 256 6"parser.yy"8557 #line 2567 "parser.yy" 8544 8558 { (yyval.decl) = DeclarationNode::newVarArray( 0 ); } 8545 8559 break; … … 8548 8562 8549 8563 /* Line 1806 of yacc.c */ 8550 #line 256 8"parser.yy"8564 #line 2569 "parser.yy" 8551 8565 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); } 8552 8566 break; … … 8555 8569 8556 8570 /* Line 1806 of yacc.c */ 8557 #line 257 0"parser.yy"8571 #line 2571 "parser.yy" 8558 8572 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); } 8559 8573 break; … … 8562 8576 8563 8577 /* Line 1806 of yacc.c */ 8564 #line 258 5"parser.yy"8578 #line 2586 "parser.yy" 8565 8579 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8566 8580 break; … … 8569 8583 8570 8584 /* Line 1806 of yacc.c */ 8571 #line 258 7"parser.yy"8585 #line 2588 "parser.yy" 8572 8586 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8573 8587 break; … … 8576 8590 8577 8591 /* Line 1806 of yacc.c */ 8578 #line 259 2"parser.yy"8592 #line 2593 "parser.yy" 8579 8593 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8580 8594 break; … … 8583 8597 8584 8598 /* Line 1806 of yacc.c */ 8585 #line 259 4"parser.yy"8599 #line 2595 "parser.yy" 8586 8600 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8587 8601 break; … … 8590 8604 8591 8605 /* Line 1806 of yacc.c */ 8592 #line 259 6"parser.yy"8606 #line 2597 "parser.yy" 8593 8607 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8594 8608 break; … … 8597 8611 8598 8612 /* Line 1806 of yacc.c */ 8599 #line 259 8"parser.yy"8613 #line 2599 "parser.yy" 8600 8614 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8601 8615 break; … … 8604 8618 8605 8619 /* Line 1806 of yacc.c */ 8606 #line 260 0"parser.yy"8620 #line 2601 "parser.yy" 8607 8621 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8608 8622 break; … … 8611 8625 8612 8626 /* Line 1806 of yacc.c */ 8613 #line 260 6"parser.yy"8627 #line 2607 "parser.yy" 8614 8628 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8615 8629 break; … … 8618 8632 8619 8633 /* Line 1806 of yacc.c */ 8620 #line 260 8"parser.yy"8634 #line 2609 "parser.yy" 8621 8635 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8622 8636 break; … … 8625 8639 8626 8640 /* Line 1806 of yacc.c */ 8627 #line 261 0"parser.yy"8641 #line 2611 "parser.yy" 8628 8642 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8629 8643 break; … … 8632 8646 8633 8647 /* Line 1806 of yacc.c */ 8634 #line 261 5"parser.yy"8648 #line 2616 "parser.yy" 8635 8649 { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); } 8636 8650 break; … … 8639 8653 8640 8654 /* Line 1806 of yacc.c */ 8641 #line 261 7"parser.yy"8655 #line 2618 "parser.yy" 8642 8656 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8643 8657 break; … … 8646 8660 8647 8661 /* Line 1806 of yacc.c */ 8648 #line 26 19"parser.yy"8662 #line 2620 "parser.yy" 8649 8663 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8650 8664 break; … … 8653 8667 8654 8668 /* Line 1806 of yacc.c */ 8655 #line 262 6"parser.yy"8669 #line 2627 "parser.yy" 8656 8670 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8657 8671 break; … … 8660 8674 8661 8675 /* Line 1806 of yacc.c */ 8662 #line 263 7"parser.yy"8676 #line 2638 "parser.yy" 8663 8677 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8664 8678 break; … … 8667 8681 8668 8682 /* Line 1806 of yacc.c */ 8669 #line 264 0"parser.yy"8683 #line 2641 "parser.yy" 8670 8684 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 8671 8685 break; … … 8674 8688 8675 8689 /* Line 1806 of yacc.c */ 8676 #line 264 2"parser.yy"8690 #line 2643 "parser.yy" 8677 8691 { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); } 8678 8692 break; … … 8681 8695 8682 8696 /* Line 1806 of yacc.c */ 8683 #line 264 5"parser.yy"8697 #line 2646 "parser.yy" 8684 8698 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 8685 8699 break; … … 8688 8702 8689 8703 /* Line 1806 of yacc.c */ 8690 #line 264 7"parser.yy"8704 #line 2648 "parser.yy" 8691 8705 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); } 8692 8706 break; … … 8695 8709 8696 8710 /* Line 1806 of yacc.c */ 8697 #line 26 49"parser.yy"8711 #line 2650 "parser.yy" 8698 8712 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); } 8699 8713 break; … … 8702 8716 8703 8717 /* Line 1806 of yacc.c */ 8704 #line 266 3"parser.yy"8718 #line 2664 "parser.yy" 8705 8719 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8706 8720 break; … … 8709 8723 8710 8724 /* Line 1806 of yacc.c */ 8711 #line 266 5"parser.yy"8725 #line 2666 "parser.yy" 8712 8726 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8713 8727 break; … … 8716 8730 8717 8731 /* Line 1806 of yacc.c */ 8718 #line 267 0"parser.yy"8732 #line 2671 "parser.yy" 8719 8733 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8720 8734 break; … … 8723 8737 8724 8738 /* Line 1806 of yacc.c */ 8725 #line 267 2"parser.yy"8739 #line 2673 "parser.yy" 8726 8740 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8727 8741 break; … … 8730 8744 8731 8745 /* Line 1806 of yacc.c */ 8732 #line 267 4"parser.yy"8746 #line 2675 "parser.yy" 8733 8747 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8734 8748 break; … … 8737 8751 8738 8752 /* Line 1806 of yacc.c */ 8739 #line 267 6"parser.yy"8753 #line 2677 "parser.yy" 8740 8754 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8741 8755 break; … … 8744 8758 8745 8759 /* Line 1806 of yacc.c */ 8746 #line 267 8"parser.yy"8760 #line 2679 "parser.yy" 8747 8761 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8748 8762 break; … … 8751 8765 8752 8766 /* Line 1806 of yacc.c */ 8753 #line 268 4"parser.yy"8767 #line 2685 "parser.yy" 8754 8768 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8755 8769 break; … … 8758 8772 8759 8773 /* Line 1806 of yacc.c */ 8760 #line 268 6"parser.yy"8774 #line 2687 "parser.yy" 8761 8775 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8762 8776 break; … … 8765 8779 8766 8780 /* Line 1806 of yacc.c */ 8767 #line 268 8"parser.yy"8781 #line 2689 "parser.yy" 8768 8782 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8769 8783 break; … … 8772 8786 8773 8787 /* Line 1806 of yacc.c */ 8774 #line 269 3"parser.yy"8788 #line 2694 "parser.yy" 8775 8789 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8776 8790 break; … … 8779 8793 8780 8794 /* Line 1806 of yacc.c */ 8781 #line 269 5"parser.yy"8795 #line 2696 "parser.yy" 8782 8796 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8783 8797 break; … … 8786 8800 8787 8801 /* Line 1806 of yacc.c */ 8788 #line 270 5"parser.yy"8802 #line 2706 "parser.yy" 8789 8803 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 8790 8804 break; … … 8793 8807 8794 8808 /* Line 1806 of yacc.c */ 8795 #line 271 5"parser.yy"8809 #line 2716 "parser.yy" 8796 8810 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8797 8811 break; … … 8800 8814 8801 8815 /* Line 1806 of yacc.c */ 8802 #line 271 7"parser.yy"8816 #line 2718 "parser.yy" 8803 8817 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8804 8818 break; … … 8807 8821 8808 8822 /* Line 1806 of yacc.c */ 8809 #line 27 19"parser.yy"8823 #line 2720 "parser.yy" 8810 8824 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8811 8825 break; … … 8814 8828 8815 8829 /* Line 1806 of yacc.c */ 8816 #line 272 1"parser.yy"8830 #line 2722 "parser.yy" 8817 8831 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8818 8832 break; … … 8821 8835 8822 8836 /* Line 1806 of yacc.c */ 8823 #line 272 3"parser.yy"8837 #line 2724 "parser.yy" 8824 8838 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8825 8839 break; … … 8828 8842 8829 8843 /* Line 1806 of yacc.c */ 8830 #line 272 5"parser.yy"8844 #line 2726 "parser.yy" 8831 8845 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8832 8846 break; … … 8835 8849 8836 8850 /* Line 1806 of yacc.c */ 8837 #line 273 2"parser.yy"8851 #line 2733 "parser.yy" 8838 8852 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8839 8853 break; … … 8842 8856 8843 8857 /* Line 1806 of yacc.c */ 8844 #line 273 4"parser.yy"8858 #line 2735 "parser.yy" 8845 8859 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8846 8860 break; … … 8849 8863 8850 8864 /* Line 1806 of yacc.c */ 8851 #line 273 6"parser.yy"8865 #line 2737 "parser.yy" 8852 8866 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8853 8867 break; … … 8856 8870 8857 8871 /* Line 1806 of yacc.c */ 8858 #line 273 8"parser.yy"8872 #line 2739 "parser.yy" 8859 8873 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 8860 8874 break; … … 8863 8877 8864 8878 /* Line 1806 of yacc.c */ 8865 #line 274 0"parser.yy"8879 #line 2741 "parser.yy" 8866 8880 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8867 8881 break; … … 8870 8884 8871 8885 /* Line 1806 of yacc.c */ 8872 #line 274 3"parser.yy"8886 #line 2744 "parser.yy" 8873 8887 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8874 8888 break; … … 8877 8891 8878 8892 /* Line 1806 of yacc.c */ 8879 #line 274 5"parser.yy"8893 #line 2746 "parser.yy" 8880 8894 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8881 8895 break; … … 8884 8898 8885 8899 /* Line 1806 of yacc.c */ 8886 #line 274 7"parser.yy"8900 #line 2748 "parser.yy" 8887 8901 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8888 8902 break; … … 8891 8905 8892 8906 /* Line 1806 of yacc.c */ 8893 #line 27 49"parser.yy"8907 #line 2750 "parser.yy" 8894 8908 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 8895 8909 break; … … 8898 8912 8899 8913 /* Line 1806 of yacc.c */ 8900 #line 275 1"parser.yy"8914 #line 2752 "parser.yy" 8901 8915 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8902 8916 break; … … 8905 8919 8906 8920 /* Line 1806 of yacc.c */ 8907 #line 275 6"parser.yy"8921 #line 2757 "parser.yy" 8908 8922 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 8909 8923 break; … … 8912 8926 8913 8927 /* Line 1806 of yacc.c */ 8914 #line 275 8"parser.yy"8928 #line 2759 "parser.yy" 8915 8929 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 8916 8930 break; … … 8919 8933 8920 8934 /* Line 1806 of yacc.c */ 8921 #line 276 3"parser.yy"8935 #line 2764 "parser.yy" 8922 8936 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); } 8923 8937 break; … … 8926 8940 8927 8941 /* Line 1806 of yacc.c */ 8928 #line 276 5"parser.yy"8942 #line 2766 "parser.yy" 8929 8943 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); } 8930 8944 break; … … 8933 8947 8934 8948 /* Line 1806 of yacc.c */ 8935 #line 279 2"parser.yy"8949 #line 2793 "parser.yy" 8936 8950 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 8937 8951 break; … … 8940 8954 8941 8955 /* Line 1806 of yacc.c */ 8942 #line 280 3"parser.yy"8956 #line 2804 "parser.yy" 8943 8957 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8944 8958 break; … … 8947 8961 8948 8962 /* Line 1806 of yacc.c */ 8949 #line 280 5"parser.yy"8963 #line 2806 "parser.yy" 8950 8964 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8951 8965 break; … … 8954 8968 8955 8969 /* Line 1806 of yacc.c */ 8956 #line 280 7"parser.yy"8970 #line 2808 "parser.yy" 8957 8971 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8958 8972 break; … … 8961 8975 8962 8976 /* Line 1806 of yacc.c */ 8963 #line 28 09"parser.yy"8977 #line 2810 "parser.yy" 8964 8978 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8965 8979 break; … … 8968 8982 8969 8983 /* Line 1806 of yacc.c */ 8970 #line 281 1"parser.yy"8984 #line 2812 "parser.yy" 8971 8985 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8972 8986 break; … … 8975 8989 8976 8990 /* Line 1806 of yacc.c */ 8977 #line 281 3"parser.yy"8991 #line 2814 "parser.yy" 8978 8992 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8979 8993 break; … … 8982 8996 8983 8997 /* Line 1806 of yacc.c */ 8984 #line 282 0"parser.yy"8998 #line 2821 "parser.yy" 8985 8999 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 8986 9000 break; … … 8989 9003 8990 9004 /* Line 1806 of yacc.c */ 8991 #line 282 2"parser.yy"9005 #line 2823 "parser.yy" 8992 9006 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 8993 9007 break; … … 8996 9010 8997 9011 /* Line 1806 of yacc.c */ 8998 #line 282 4"parser.yy"9012 #line 2825 "parser.yy" 8999 9013 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9000 9014 break; … … 9003 9017 9004 9018 /* Line 1806 of yacc.c */ 9005 #line 282 6"parser.yy"9019 #line 2827 "parser.yy" 9006 9020 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9007 9021 break; … … 9010 9024 9011 9025 /* Line 1806 of yacc.c */ 9012 #line 282 8"parser.yy"9026 #line 2829 "parser.yy" 9013 9027 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9014 9028 break; … … 9017 9031 9018 9032 /* Line 1806 of yacc.c */ 9019 #line 283 0"parser.yy"9033 #line 2831 "parser.yy" 9020 9034 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9021 9035 break; … … 9024 9038 9025 9039 /* Line 1806 of yacc.c */ 9026 #line 283 5"parser.yy"9040 #line 2836 "parser.yy" 9027 9041 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 9028 9042 break; … … 9031 9045 9032 9046 /* Line 1806 of yacc.c */ 9033 #line 284 2"parser.yy"9047 #line 2843 "parser.yy" 9034 9048 { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); } 9035 9049 break; … … 9038 9052 9039 9053 /* Line 1806 of yacc.c */ 9040 #line 284 4"parser.yy"9054 #line 2845 "parser.yy" 9041 9055 { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); } 9042 9056 break; … … 9045 9059 9046 9060 /* Line 1806 of yacc.c */ 9047 #line 286 8"parser.yy"9061 #line 2869 "parser.yy" 9048 9062 { (yyval.en) = 0; } 9049 9063 break; … … 9052 9066 9053 9067 /* Line 1806 of yacc.c */ 9054 #line 287 0"parser.yy"9068 #line 2871 "parser.yy" 9055 9069 { (yyval.en) = (yyvsp[(2) - (2)].en); } 9056 9070 break; … … 9059 9073 9060 9074 /* Line 1806 of yacc.c */ 9061 #line 90 62"Parser/parser.cc"9075 #line 9076 "Parser/parser.cc" 9062 9076 default: break; 9063 9077 } … … 9290 9304 9291 9305 /* Line 2067 of yacc.c */ 9292 #line 287 3"parser.yy"9306 #line 2874 "parser.yy" 9293 9307 9294 9308 // ----end of grammar---- -
src/Parser/parser.yy
r47a8d17 r3f0c6a5 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 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_constantInteger( *$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 425 | REALDECIMALconstant field 426 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_constantInteger( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); } 427 | REALDECIMALconstant '[' push field_list pop ']' 428 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_constantInteger( *$1 ) ), build_tuple( $4 ) ) ); } 429 | field_name '.' field 430 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 431 | field_name '.' '[' push field_list pop ']' 432 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 433 | field_name ARROW field 434 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 435 | field_name ARROW '[' push field_list pop ']' 436 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 437 ; 438 439 field_name: // ... use $2 440 INTEGERconstant fraction_constants 441 { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 442 | FLOATINGconstant fraction_constants 443 { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 444 | no_attr_identifier fraction_constants 423 445 { $$ = new ExpressionNode( build_varref( $1 ) ); } 424 | REALDECIMALconstant field425 { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1 ) ) ); }426 | REALDECIMALconstant '[' push field_list pop ']'427 { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1 ) ) ); }428 | field_name '.' field429 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }430 | field_name '.' '[' push field_list pop ']'431 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }432 | field_name ARROW field433 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }434 | field_name ARROW '[' push field_list pop ']'435 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }436 ;437 438 field_name:439 INTEGERconstant fraction_constants440 { $$ = $1; }441 | FLOATINGconstant fraction_constants442 { $$ = $1; }443 | no_attr_identifier fraction_constants444 { $$ = $1; }445 446 ; 446 447 -
src/ResolvExpr/Alternative.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 38 38 #include "SynTree/TypeSubstitution.h" 39 39 #include "SymTab/Validate.h" 40 #include "Tuples/TupleAssignment.h" 41 #include "Tuples/NameMatcher.h" 40 #include "Tuples/Tuples.h" 42 41 #include "Common/utility.h" 43 42 #include "InitTweak/InitTweak.h" 43 #include "InitTweak/GenInit.h" 44 44 #include "ResolveTypeof.h" 45 45 … … 64 64 } 65 65 66 Cost sumCost( const AltList &in ) { 67 Cost total; 68 for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) { 69 total += i->cost; 70 } 71 return total; 72 } 73 66 74 namespace { 67 75 void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) { … … 76 84 out.push_back( i->expr->clone() ); 77 85 } 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 86 } 87 87 … … 101 101 PruneStruct current( candidate ); 102 102 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();103 { 104 Type * newType = candidate->expr->get_result()->clone(); 105 105 candidate->env.apply( newType ); 106 mangleName += SymTab::Mangler::mangle( newType );106 mangleName = SymTab::Mangler::mangle( newType ); 107 107 delete newType; 108 108 } … … 133 133 if ( ! target->second.isAmbiguous ) { 134 134 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 } 135 alt.env.applyFree( alt.expr->get_result() ); 138 136 *out++ = alt; 139 137 } 140 138 } 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 139 } 170 140 171 141 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 } 142 expr->get_result()->accept( global_renamer ); 175 143 } 176 144 } … … 204 172 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 205 173 if ( adjust ) { 206 adjustExprType List( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );174 adjustExprType( i->expr->get_result(), i->env, indexer ); 207 175 } 208 176 } … … 240 208 } 241 209 210 // std::unordered_map< Expression *, UniqueExpr * > ; 211 242 212 template< typename StructOrUnionType > 243 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) { 213 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 214 // by this point, member must be a name expr 215 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); 216 const std::string & name = nameExpr->get_name(); 244 217 std::list< Declaration* > members; 245 218 aggInst->lookup( name, members ); … … 254 227 } 255 228 229 void AlternativeFinder::addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 230 if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) { 231 // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning 232 // xxx - this should be improved by memoizing the value of constant exprs 233 // during parsing and reusing that information here. 234 std::stringstream ss( constantExpr->get_constant()->get_value() ); 235 int val; 236 std::string tmp; 237 if ( ss >> val && ! (ss >> tmp) ) { 238 if ( val >= 0 && (unsigned int)val < tupleType->size() ) { 239 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 240 } // if 241 } // if 242 } // if 243 } 244 256 245 void AlternativeFinder::visit( ApplicationExpr *applicationExpr ) { 257 246 alternatives.push_back( Alternative( applicationExpr->clone(), env, Cost::zero ) ); … … 259 248 260 249 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 ); 250 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr ); 251 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 252 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 267 253 268 254 Cost convCost( 0, 0, 0 ); … … 270 256 std::list< DeclarationWithType* >::iterator formal = formals.begin(); 271 257 std::list< Expression* >& actuals = appExpr->get_args(); 258 259 std::list< Type * > formalTypes; 260 std::list< Type * >::iterator formalType = formalTypes.end(); 261 272 262 for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 263 273 264 PRINT( 274 265 std::cerr << "actual expression:" << std::endl; 275 266 (*actualExpr)->print( std::cerr, 8 ); 276 267 std::cerr << "--- results are" << std::endl; 277 printAll( (*actualExpr)->get_results(),std::cerr, 8 );268 (*actualExpr)->get_result()->print( std::cerr, 8 ); 278 269 ) 279 270 std::list< DeclarationWithType* >::iterator startFormal = formal; 280 271 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; 272 std::list< Type * > flatActualTypes; 273 flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) ); 274 for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) { 275 276 277 // tuple handling code 278 if ( formalType == formalTypes.end() ) { 279 // the type of the formal parameter may be a tuple type. To make this easier to work with, 280 // flatten the tuple type and traverse the resulting list of types, incrementing the formal 281 // iterator once its types have been extracted. Once a particular formal parameter's type has 282 // been exhausted load the next formal parameter's type. 283 if ( formal == formals.end() ) { 284 if ( function->get_isVarArgs() ) { 285 convCost += Cost( 1, 0, 0 ); 286 break; 287 } else { 288 return Cost::infinity; 289 } 288 290 } 291 formalTypes.clear(); 292 flatten( (*formal)->get_type(), back_inserter( formalTypes ) ); 293 formalType = formalTypes.begin(); 294 ++formal; 289 295 } 296 290 297 PRINT( 291 298 std::cerr << std::endl << "converting "; 292 (*actual )->print( std::cerr, 8 );299 (*actualType)->print( std::cerr, 8 ); 293 300 std::cerr << std::endl << " to "; 294 301 (*formal)->get_type()->print( std::cerr, 8 ); 295 302 ) 296 Cost newCost = conversionCost( *actual , (*formal)->get_type(), indexer, alt.env );303 Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env ); 297 304 PRINT( 298 305 std::cerr << std::endl << "cost is" << newCost << std::endl; … … 305 312 actualCost += newCost; 306 313 307 convCost += Cost( 0, polyCost( (*formal)->get_type(), alt.env, indexer ) + polyCost( *actual, alt.env, indexer ), 0 );308 309 formal ++;314 convCost += Cost( 0, polyCost( *formalType, alt.env, indexer ) + polyCost( *actualType, alt.env, indexer ), 0 ); 315 316 formalType++; 310 317 } 311 318 if ( actualCost != Cost( 0, 0, 0 ) ) { … … 356 363 /// Adds type variables to the open variable set and marks their assertions 357 364 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 ) {365 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 359 366 unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind(); 360 367 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) { … … 365 372 } 366 373 367 bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ) { 374 /// instantiate a single argument by matching actuals from [actualIt, actualEnd) against formalType, 375 /// producing expression(s) in out and their total cost in cost. 376 template< typename AltIterator, typename OutputIterator > 377 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 ) { 378 if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) { 379 // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType 380 TupleExpr * tupleExpr = new TupleExpr(); 381 for ( Type * type : *tupleType ) { 382 if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs() ) ) ) { 383 delete tupleExpr; 384 return false; 385 } 386 } 387 tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) ); 388 *out++ = tupleExpr; 389 } else if ( actualIt != actualEnd ) { 390 // both actualType and formalType are atomic (non-tuple) types - if they unify 391 // then accept actual as an argument, otherwise return false (fail to instantiate argument) 392 Expression * actual = actualIt->expr; 393 Type * actualType = actual->get_result(); 394 PRINT( 395 std::cerr << "formal type is "; 396 formalType->print( std::cerr ); 397 std::cerr << std::endl << "actual type is "; 398 actualType->print( std::cerr ); 399 std::cerr << std::endl; 400 ) 401 if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 402 return false; 403 } 404 // move the expression from the alternative to the output iterator 405 *out++ = actual; 406 actualIt->expr = nullptr; 407 cost += actualIt->cost; 408 ++actualIt; 409 } else { 410 // End of actuals - Handle default values 411 if ( SingleInit *si = dynamic_cast<SingleInit *>( defaultValue )) { 412 // so far, only constant expressions are accepted as default values 413 if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) { 414 if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) { 415 if ( unify( formalType, cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 416 // xxx - Don't know if this is right 417 *out++ = cnstexpr->clone(); 418 return true; 419 } // if 420 } // if 421 } // if 422 } // if 423 return false; 424 } // if 425 return true; 426 } 427 428 bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ) { 368 429 simpleCombineEnvironments( actuals.begin(), actuals.end(), resultEnv ); 369 430 // make sure we don't widen any existing bindings … … 373 434 resultEnv.extractOpenVars( openVars ); 374 435 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; 436 // flatten actuals so that each actual has an atomic (non-tuple) type 437 AltList exploded; 438 Tuples::explode( actuals, indexer, back_inserter( exploded ) ); 439 440 AltList::iterator actualExpr = exploded.begin(); 441 AltList::iterator actualEnd = exploded.end(); 442 for ( DeclarationWithType * formal : formals ) { 443 // match flattened actuals with formal parameters - actuals will be grouped to match 444 // with formals as appropriate 445 Cost cost; 446 std::list< Expression * > newExprs; 447 ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal ); 448 if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) { 449 deleteAll( newExprs ); 450 return false; 451 } 452 // success - produce argument as a new alternative 453 assert( newExprs.size() == 1 ); 454 out.push_back( Alternative( newExprs.front(), resultEnv, cost ) ); 455 } 456 if ( actualExpr != actualEnd ) { 457 // there are still actuals remaining, but we've run out of formal parameters to match against 458 // this is okay only if the function is variadic 459 if ( ! isVarArgs ) { 460 return false; 461 } 462 out.splice( out.end(), exploded, actualExpr, actualEnd ); 416 463 } 417 464 return true; … … 500 547 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 501 548 Expression *varExpr = new VariableExpr( candDecl ); 502 deleteAll( varExpr->get_results() ); 503 varExpr->get_results().clear(); 504 varExpr->get_results().push_front( adjType->clone() ); 549 delete varExpr->get_result(); 550 varExpr->set_result( adjType->clone() ); 505 551 PRINT( 506 552 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; … … 545 591 546 592 template< typename OutputIterator > 547 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ) {593 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ) { 548 594 OpenVarSet openVars; 549 595 AssertionSet resultNeed, resultHave; 550 596 TypeEnvironment resultEnv; 551 597 makeUnifiableVars( funcType, openVars, resultNeed ); 552 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave ) ) { 598 AltList instantiatedActuals; // filled by instantiate function 599 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) { 553 600 ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() ); 554 Alternative newAlt( appExpr, resultEnv, sumCost( actualAlt) );555 makeExprList( actualAlt, appExpr->get_args() );601 Alternative newAlt( appExpr, resultEnv, sumCost( instantiatedActuals ) ); 602 makeExprList( instantiatedActuals, appExpr->get_args() ); 556 603 PRINT( 557 604 std::cerr << "need assertions:" << std::endl; … … 574 621 PointerType pt( Type::Qualifiers(), v.clone() ); 575 622 UntypedExpr *vexpr = untypedExpr->clone(); 576 vexpr-> get_results().push_front( pt.clone() );623 vexpr->set_result( pt.clone() ); 577 624 alternatives.push_back( Alternative( vexpr, env, Cost()) ); 578 625 return; … … 587 634 combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) ); 588 635 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 ... 636 // take care of possible tuple assignments 637 // if not tuple assignment, assignment is taken care of as a normal function call 638 Tuples::handleTupleAssignment( *this, untypedExpr, possibilities ); 594 639 595 640 AltList candidates; … … 604 649 // check if the type is pointer to function 605 650 PointerType *pointer; 606 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {651 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) { 607 652 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 608 653 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 640 685 // check if the type is pointer to function 641 686 PointerType *pointer; 642 if ( funcOp->expr->get_results().size() == 1 643 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 687 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) { 644 688 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 645 689 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 665 709 666 710 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 ); 711 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr ); 712 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 713 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 673 714 std::cerr << "Case +++++++++++++" << std::endl; 674 715 std::cerr << "formals are:" << std::endl; … … 692 733 693 734 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; 735 // xxx - recurse into tuples? 736 return expr->has_result() && expr->get_result()->get_isLvalue(); 698 737 } 699 738 … … 709 748 710 749 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 750 Type *& toType = castExpr->get_result(); 751 toType = resolveTypeof( toType, indexer ); 752 SymTab::validateType( toType, &indexer ); 753 adjustExprType( toType, env, indexer ); 716 754 717 755 AlternativeFinder finder( indexer, env ); … … 727 765 // that are cast directly. The candidate is invalid if it has fewer results than there are types to cast 728 766 // to. 729 int discardedValues = (*i).expr->get_result s().size() - castExpr->get_results().size();767 int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size(); 730 768 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() ); 769 // xxx - may need to go into tuple types and extract relavent types and use unifyList 733 770 // 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 ); 771 unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer ); 772 Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env ); 740 773 if ( thisCost != Cost::infinity ) { 741 774 // count one safe conversion for each value that is thrown away … … 760 793 761 794 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 } // if795 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) { 796 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 797 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) { 798 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 799 } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( agg->expr->get_result() ) ) { 800 addTupleMembers( tupleType, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 768 801 } // if 769 802 } // for … … 791 824 renameTypes( alternatives.back().expr ); 792 825 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) { 793 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 826 NameExpr nameExpr( "" ); 827 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 794 828 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) { 795 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 829 NameExpr nameExpr( "" ); 830 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 796 831 } // if 797 832 } // for … … 894 929 alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) ); 895 930 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() );931 alternatives.back().expr->set_result( (*i)->get_type()->clone() ); 897 932 } // for 898 933 } // if … … 917 952 finder.find( attrExpr->get_expr() ); 918 953 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 );954 if ( choice->expr->get_result()->size() == 1 ) { 955 resolveAttr(*i, function, choice->expr->get_result(), choice->env ); 921 956 } // fi 922 957 } // for … … 960 995 AssertionSet needAssertions, haveAssertions; 961 996 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) ) {997 Type* commonType; 998 if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 964 999 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 1000 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() ); 974 1001 newAlt.expr = newExpr; 975 1002 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 999 1026 TupleExpr *newExpr = new TupleExpr; 1000 1027 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 1028 newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) ); 1006 1029 1007 1030 TypeEnvironment compositeEnv; … … 1024 1047 } 1025 1048 } 1049 1050 void AlternativeFinder::visit( TupleIndexExpr *tupleExpr ) { 1051 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) ); 1052 } 1053 1054 void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) { 1055 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) ); 1056 } 1057 1058 void AlternativeFinder::visit( UniqueExpr *unqExpr ) { 1059 // this won't work because the unqExprs wont share an expression anymore... 1060 AlternativeFinder finder( indexer, env ); 1061 finder.findWithAdjustment( unqExpr->get_expr() ); 1062 for ( Alternative & alt : finder.alternatives ) { 1063 // xxx - attach a resolved ConstructorInit node? 1064 // xxx - is it possible to make the objDecl's type const? 1065 static UniqueName tempNamer( "_unq_expr_" ); 1066 ObjectDecl * objDecl = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, alt.expr->get_result()->clone(), nullptr ); 1067 // must be done on two lines because genCtorInit accesses objDecl's fields 1068 objDecl->set_init( InitTweak::genCtorInit( objDecl ) ); 1069 1070 UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr->clone(), unqExpr->get_id() ); 1071 newUnqExpr->set_object( objDecl ); 1072 1073 resolveObject( indexer, objDecl ); 1074 1075 alternatives.push_back( Alternative( newUnqExpr, env, Cost::zero ) ); 1076 } 1077 } 1078 1026 1079 } // namespace ResolvExpr 1027 1080 -
src/ResolvExpr/AlternativeFinder.h
r47a8d17 r3f0c6a5 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 void resolveObject( const SymTab::Indexer & indexer, ObjectDecl * objectDecl ); 98 99 template< typename InputIterator, typename OutputIterator > 100 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 101 AltList alternatives; 102 103 // select the alternatives that have the minimum parameter cost 104 Cost minCost = Cost::infinity; 105 for ( InputIterator i = begin; i != end; ++i ) { 106 if ( i->cost < minCost ) { 107 minCost = i->cost; 108 i->cost = i->cvtCost; 109 alternatives.clear(); 110 alternatives.push_back( *i ); 111 } else if ( i->cost == minCost ) { 112 i->cost = i->cvtCost; 113 alternatives.push_back( *i ); 114 } 115 } 116 std::copy( alternatives.begin(), alternatives.end(), out ); 117 } 118 119 Cost sumCost( const AltList &in ); 120 121 template< typename InputIterator > 122 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { 123 while ( begin != end ) { 124 result.simpleCombine( (*begin++).env ); 125 } 126 } 91 127 } // namespace ResolvExpr 92 128 -
src/ResolvExpr/AlternativePrinter.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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" … … 34 35 class Resolver : public SymTab::Indexer { 35 36 public: 36 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 37 Resolver() : SymTab::Indexer( false ) {} 38 Resolver( const SymTab::Indexer & indexer ) : SymTab::Indexer( indexer ) {} 37 39 38 40 virtual void visit( FunctionDecl *functionDecl ); 39 virtual void visit( ObjectDecl * functionDecl );41 virtual void visit( ObjectDecl *objectDecl ); 40 42 virtual void visit( TypeDecl *typeDecl ); 41 43 virtual void visit( EnumDecl * enumDecl ); … … 67 69 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 68 70 void fallbackInit( ConstructorInit * ctorInit ); 69 std::list< Type * > functionReturn;70 Type *initContext ;71 Type *switchType ;71 Type * functionReturn = nullptr; 72 Type *initContext = nullptr; 73 Type *switchType = nullptr; 72 74 bool inEnumDecl = false; 73 75 }; … … 157 159 const TypeEnvironment *newEnv = 0; 158 160 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() ) ) {161 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) { 160 162 if ( newExpr ) { 161 163 throw SemanticError( "Too many interpretations for case control expression", untyped ); … … 234 236 Type *new_type = resolveTypeof( functionDecl->get_type(), *this ); 235 237 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 238 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 239 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 241 240 SymTab::Indexer::visit( functionDecl ); 242 functionReturn = oldFunctionReturn;243 241 } 244 242 … … 338 336 void Resolver::visit( ReturnStmt *returnStmt ) { 339 337 if ( returnStmt->get_expr() ) { 340 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() ); 341 cloneAll( functionReturn, castExpr->get_results() ); 338 CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() ); 342 339 Expression *newExpr = findSingleExpression( castExpr, *this ); 343 340 delete castExpr; … … 384 381 if ( isCharType( at->get_base() ) ) { 385 382 // check if the resolved type is char * 386 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result s().front() ) ) {383 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) { 387 384 if ( isCharType( pt->get_base() ) ) { 388 385 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; … … 446 443 (*iter)->accept( *this ); 447 444 } // for 445 } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) { 446 for ( Type * t : *tt ) { 447 if ( iter == end ) break; 448 initContext = t; 449 (*iter++)->accept( *this ); 450 } 448 451 } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) { 449 452 resolveAggrInit( st->get_baseStruct(), iter, end ); … … 530 533 } 531 534 535 void resolveObject( const SymTab::Indexer & indexer, ObjectDecl * objectDecl ) { 536 Resolver resolver( indexer ); 537 objectDecl->accept( resolver ); 538 } 539 532 540 void Resolver::visit( ConstructorInit *ctorInit ) { 533 541 // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit -
src/ResolvExpr/TypeEnvironment.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 598 598 } 599 599 600 // xxx - compute once and store in the FunctionType? 601 Type * extractResultType( FunctionType * function ) { 602 if ( function->get_returnVals().size() == 0 ) { 603 return new VoidType( Type::Qualifiers() ); 604 } else if ( function->get_returnVals().size() == 1 ) { 605 return function->get_returnVals().front()->get_type()->clone(); 606 } else { 607 TupleType * tupleType = new TupleType( Type::Qualifiers() ); 608 for ( DeclarationWithType * decl : function->get_returnVals() ) { 609 tupleType->get_types().push_back( decl->get_type()->clone() ); 610 } // for 611 return tupleType; 612 } 613 } 600 614 } // namespace ResolvExpr 601 615 -
src/ResolvExpr/typeops.h
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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 … … 429 429 /// Fix up assertions 430 430 void forallFixer( Type *func ) { 431 for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) {431 for ( Type::ForallList::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) { 432 432 std::list< DeclarationWithType * > toBeDone, nextRound; 433 433 toBeDone.splice( toBeDone.end(), (*type )->get_assertions() ); -
src/SynTree/AddressExpr.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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/Expression.cc
r47a8d17 r3f0c6a5 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 ) : … … 379 374 cloneAll( other.args, args ); 380 375 } 381 382 UntypedExpr::UntypedExpr( Expression *_function, std::list<Expression *> &_args, Expression *_aname ) :383 Expression( _aname ), function(_function), args(_args) {}384 376 385 377 UntypedExpr::~UntypedExpr() { … … 419 411 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) : 420 412 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) { 421 add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );413 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 422 414 } 423 415 … … 477 469 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 478 470 assert( callExpr ); 479 cloneAll( callExpr->get_results(), results ); 471 assert( callExpr->has_result() ); 472 set_result( callExpr->get_result()->clone() ); 480 473 } 481 474 … … 510 503 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 511 504 assert( arg ); 512 cloneAll( arg->get_results(), results);505 set_result( maybeClone( arg->get_result() ) ); 513 506 } 514 507 … … 530 523 531 524 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 ) ) {} 525 assert( type && initializer ); 526 set_result( type->clone() ); 527 } 528 529 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( other.type->clone() ), initializer( other.initializer->clone() ) {} 536 530 537 531 CompoundLiteralExpr::~CompoundLiteralExpr() { … … 542 536 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 543 537 os << "Compound Literal Expression: " << std::endl; 544 if ( type ) type->print( os, indent + 2 ); 545 if ( initializer ) initializer->print( os, indent + 2 ); 538 os << std::string( indent+2, ' ' ); 539 type->print( os, indent + 2 ); 540 os << std::string( indent+2, ' ' ); 541 initializer->print( os, indent + 2 ); 546 542 } 547 543 … … 557 553 558 554 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 559 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {}555 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} 560 556 void RangeExpr::print( std::ostream &os, int indent ) const { 561 os << std::string( indent, ' ' ) <<"Range Expression: ";557 os << "Range Expression: "; 562 558 low->print( os, indent ); 563 559 os << " ... "; 564 560 high->print( os, indent ); 561 } 562 563 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) { 564 assert( statements ); 565 std::list< Statement * > & body = statements->get_kids(); 566 if ( ! body.empty() ) { 567 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 568 set_result( maybeClone( exprStmt->get_expr()->get_result() ) ); 569 } 570 } 571 } 572 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {} 573 StmtExpr::~StmtExpr() { 574 delete statements; 575 } 576 void StmtExpr::print( std::ostream &os, int indent ) const { 577 os << "Statement Expression: " << std::endl << std::string( indent, ' ' ); 578 statements->print( os, indent+2 ); 579 } 580 581 582 long long UniqueExpr::count = 0; 583 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), object( new ObjectDecl* ), id( idVal ) { 584 assert( count != -1 ); 585 if ( id == -1 ) id = count++; 586 set_expr( expr ); 587 assert( expr ); 588 if ( expr->get_result() ) { 589 set_result( expr->get_result()->clone() ); 590 } 591 set_object( nullptr ); 592 } 593 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), object( other.object ), id( other.id ) { 594 } 595 UniqueExpr::~UniqueExpr() { 596 if ( expr.unique() ) { 597 delete *expr; 598 } 599 if ( object.unique() ) { 600 delete *object; 601 } 602 } 603 void UniqueExpr::print( std::ostream &os, int indent ) const { 604 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' ); 605 get_expr()->print( os, indent+2 ); 606 if ( get_object() ) { 607 os << " with decl: "; 608 get_object()->printShort( os, indent+2 ); 609 } 565 610 } 566 611 -
src/SynTree/Expression.h
r47a8d17 r3f0c6a5 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 … … 200 200 class UntypedMemberExpr : public Expression { 201 201 public: 202 UntypedMemberExpr( std::stringmember, Expression *aggregate, Expression *_aname = nullptr );202 UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr ); 203 203 UntypedMemberExpr( const UntypedMemberExpr &other ); 204 204 virtual ~UntypedMemberExpr(); 205 205 206 std::stringget_member() const { return member; }207 void set_member( const std::string &newValue ) { member = newValue; }206 Expression * get_member() const { return member; } 207 void set_member( Expression * newValue ) { member = newValue; } 208 208 Expression *get_aggregate() const { return aggregate; } 209 209 void set_aggregate( Expression *newValue ) { aggregate = newValue; } … … 214 214 virtual void print( std::ostream &os, int indent = 0 ) const; 215 215 private: 216 std::stringmember;216 Expression *member; 217 217 Expression *aggregate; 218 218 }; … … 483 483 }; 484 484 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 485 /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) 522 486 class TypeExpr : public Expression { … … 618 582 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 583 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr();584 virtual ~CompoundLiteralExpr(); 621 585 622 586 Type * get_type() const { return type; } … … 670 634 private: 671 635 Expression *low, *high; 636 }; 637 638 /// TupleExpr represents a tuple expression ( [a, b, c] ) 639 class TupleExpr : public Expression { 640 public: 641 TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr ); 642 TupleExpr( const TupleExpr &other ); 643 virtual ~TupleExpr(); 644 645 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; } 646 std::list<Expression*>& get_exprs() { return exprs; } 647 648 virtual TupleExpr *clone() const { return new TupleExpr( *this ); } 649 virtual void accept( Visitor &v ) { v.visit( this ); } 650 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 651 virtual void print( std::ostream &os, int indent = 0 ) const; 652 private: 653 std::list<Expression*> exprs; 654 }; 655 656 /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer 657 class TupleIndexExpr : public Expression { 658 public: 659 TupleIndexExpr( Expression * tuple, unsigned int index ); 660 TupleIndexExpr( const TupleIndexExpr &other ); 661 virtual ~TupleIndexExpr(); 662 663 Expression * get_tuple() const { return tuple; } 664 int get_index() const { return index; } 665 TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; } 666 TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; } 667 668 virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); } 669 virtual void accept( Visitor &v ) { v.visit( this ); } 670 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 671 virtual void print( std::ostream &os, int indent = 0 ) const; 672 private: 673 Expression * tuple; 674 unsigned int index; 675 }; 676 677 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer 678 class MemberTupleExpr : public Expression { 679 public: 680 MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr ); 681 MemberTupleExpr( const MemberTupleExpr &other ); 682 virtual ~MemberTupleExpr(); 683 684 Expression * get_member() const { return member; } 685 Expression * get_aggregate() const { return aggregate; } 686 MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; } 687 MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; } 688 689 virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); } 690 virtual void accept( Visitor &v ) { v.visit( this ); } 691 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 692 virtual void print( std::ostream &os, int indent = 0 ) const; 693 private: 694 Expression * member; 695 Expression * aggregate; 696 }; 697 698 /// 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 699 class TupleAssignExpr : public Expression { 700 public: 701 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); 702 TupleAssignExpr( const TupleAssignExpr &other ); 703 virtual ~TupleAssignExpr(); 704 705 std::list< Expression * > & get_assigns() { return assigns; } 706 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 707 708 virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); } 709 virtual void accept( Visitor &v ) { v.visit( this ); } 710 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 711 virtual void print( std::ostream &os, int indent = 0 ) const; 712 private: 713 std::list< Expression * > assigns; // assignment expressions that use tempDecls 714 std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs 715 }; 716 717 /// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; }) 718 class StmtExpr : public Expression { 719 public: 720 StmtExpr( CompoundStmt *statements ); 721 StmtExpr( const StmtExpr & other ); 722 virtual ~StmtExpr(); 723 724 CompoundStmt * get_statements() const { return statements; } 725 StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } 726 727 virtual StmtExpr *clone() const { return new StmtExpr( *this ); } 728 virtual void accept( Visitor &v ) { v.visit( this ); } 729 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 730 virtual void print( std::ostream &os, int indent = 0 ) const; 731 private: 732 CompoundStmt * statements; 733 }; 734 735 class UniqueExpr : public Expression { 736 public: 737 UniqueExpr( Expression * expr, long long idVal = -1 ); 738 UniqueExpr( const UniqueExpr & other ); 739 ~UniqueExpr(); 740 741 Expression * get_expr() const { return *expr; } 742 UniqueExpr * set_expr( Expression * newValue ) { *expr = newValue; return this; } 743 744 ObjectDecl * get_object() const { return *object; } 745 UniqueExpr * set_object( ObjectDecl * newValue ) { *object = newValue; return this; } 746 747 int get_id() const { return id; } 748 749 virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); } 750 virtual void accept( Visitor &v ) { v.visit( this ); } 751 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 752 virtual void print( std::ostream &os, int indent = 0 ) const; 753 private: 754 std::shared_ptr< Expression * > expr; 755 std::shared_ptr< ObjectDecl * > object; 756 int id; 757 static long long count; 672 758 }; 673 759 -
src/SynTree/Initializer.h
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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" 18 21 19 TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) { 22 TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) { 23 if ( ! exprs.empty() ) { 24 if ( std::all_of( exprs.begin(), exprs.end(), [](Expression * expr) { return expr->get_result(); } ) ) { 25 set_result( Tuples::makeTupleType( exprs ) ); 26 } 27 } 20 28 } 21 29 … … 29 37 30 38 void TupleExpr::print( std::ostream &os, int indent ) const { 31 os << std::string( indent, ' ' ) <<"Tuple:" << std::endl;39 os << "Tuple:" << std::endl; 32 40 printAll( exprs, os, indent+2 ); 33 41 Expression::print( os, indent ); 34 42 } 35 43 36 SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) { 37 std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs)); 44 TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) : tuple( tuple ), index( index ) { 45 TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() ); 46 assert( type->size() > index ); 47 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 48 get_result()->set_isLvalue( type->get_isLvalue() ); 38 49 } 39 50 40 SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) { 41 cloneAll( other.exprs, exprs ); 51 TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) { 42 52 } 43 53 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 ); 54 TupleIndexExpr::~TupleIndexExpr() { 55 delete tuple; 56 } 57 58 void TupleIndexExpr::print( std::ostream &os, int indent ) const { 59 os << "Tuple Index Expression, with tuple:" << std::endl; 60 os << std::string( indent+2, ' ' ); 61 tuple->print( os, indent+2 ); 62 os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl; 47 63 Expression::print( os, indent ); 48 64 } 65 66 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) { 67 set_result( maybeClone( member->get_result() ) ); // xxx - ??? 68 } 69 70 MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) { 71 } 72 73 MemberTupleExpr::~MemberTupleExpr() { 74 delete member; 75 delete aggregate; 76 } 77 78 void MemberTupleExpr::print( std::ostream &os, int indent ) const { 79 os << "Member Tuple Expression, with aggregate:" << std::endl; 80 os << std::string( indent+2, ' ' ); 81 aggregate->print( os, indent+2 ); 82 os << std::string( indent+2, ' ' ) << "with member: " << std::endl; 83 os << std::string( indent+2, ' ' ); 84 member->print( os, indent+2 ); 85 Expression::print( os, indent ); 86 } 87 88 89 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) { 90 set_result( Tuples::makeTupleType( assigns ) ); 91 } 92 93 TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ), tempDecls( other.tempDecls ) /* temporary */ { 94 cloneAll( other.assigns, assigns ); 95 // xxx - clone needs to go into assigns and replace tempDecls 96 } 97 98 TupleAssignExpr::~TupleAssignExpr() { 99 deleteAll( assigns ); 100 // deleteAll( tempDecls ); 101 } 102 103 void TupleAssignExpr::print( std::ostream &os, int indent ) const { 104 os << "Tuple Assignment Expression, with temporaries:" << std::endl; 105 printAll( tempDecls, os, indent+4 ); 106 os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl; 107 printAll( assigns, os, indent+4 ); 108 Expression::print( os, indent ); 109 } 110 111 49 112 50 113 // Local Variables: // -
src/SynTree/TupleType.cc
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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
r47a8d17 r3f0c6a5 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/Tuples/TupleAssignment.cc
r47a8d17 r3f0c6a5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleAssignment.cc -- 7 // TupleAssignment.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 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" 21 22 #include "Common/SemanticError.h" 23 #include "InitTweak/InitTweak.h" 22 24 23 25 #include <functional> … … 27 29 #include <cassert> 28 30 #include <set> 31 #include <unordered_set> 29 32 30 33 namespace Tuples { 31 TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder *f = 0 ) 32 : currentFinder(f), matcher(0), hasMatched( false ) {} 33 34 bool TupleAssignSpotter::pointsToTuple( Expression *expr ) { 34 class TupleAssignSpotter { 35 public: 36 // dispatcher for Tuple (multiple and mass) assignment operations 37 TupleAssignSpotter( ResolvExpr::AlternativeFinder & ); 38 void spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ); 39 40 private: 41 void match(); 42 43 struct Matcher { 44 public: 45 Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ); 46 virtual ~Matcher() {} 47 virtual void match( std::list< Expression * > &out ) = 0; 48 ResolvExpr::AltList lhs, rhs; 49 TupleAssignSpotter &spotter; 50 std::list< ObjectDecl * > tmpDecls; 51 }; 52 53 struct MassAssignMatcher : public Matcher { 54 public: 55 MassAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ); 56 virtual void match( std::list< Expression * > &out ); 57 }; 58 59 struct MultipleAssignMatcher : public Matcher { 60 public: 61 MultipleAssignMatcher( TupleAssignSpotter &spot, const ResolvExpr::AltList & alts ); 62 virtual void match( std::list< Expression * > &out ); 63 }; 64 65 ResolvExpr::AlternativeFinder ¤tFinder; 66 std::string fname; 67 std::unique_ptr< Matcher > matcher; 68 }; 69 70 /// true if expr is an expression of tuple type, i.e. a tuple expression, tuple variable, or MRV (multiple-return-value) function 71 bool isTuple( Expression *expr ) { 72 if ( ! expr ) return false; 73 assert( expr->has_result() ); 74 return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1; 75 } 76 77 template< typename AltIter > 78 bool isMultAssign( AltIter begin, AltIter end ) { 79 // multiple assignment if more than one alternative in the range or if 80 // the alternative is a tuple 81 if ( begin == end ) return false; 82 if ( isTuple( begin->expr ) ) return true; 83 return ++begin != end; 84 } 85 86 bool pointsToTuple( Expression *expr ) { 35 87 // 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; 88 if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { 89 return pointsToTuple( castExpr->get_arg() ); 90 } else if ( AddressExpr *addr = dynamic_cast< AddressExpr * >( expr) ) { 91 return isTuple( addr->get_arg() ); 92 } 39 93 return false; 40 94 } 41 95 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 96 void handleTupleAssignment( ResolvExpr::AlternativeFinder & currentFinder, UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) { 97 TupleAssignSpotter spotter( currentFinder ); 98 spotter.spot( expr, possibilities ); 99 } 100 101 TupleAssignSpotter::TupleAssignSpotter( ResolvExpr::AlternativeFinder &f ) 102 : currentFinder(f) {} 103 104 void TupleAssignSpotter::spot( UntypedExpr * expr, const std::list<ResolvExpr::AltList> &possibilities ) { 105 if ( NameExpr *op = dynamic_cast< NameExpr * >(expr->get_function()) ) { 106 if ( InitTweak::isCtorDtorAssign( op->get_name() ) ) { 107 fname = op->get_name(); 108 for ( std::list<ResolvExpr::AltList>::const_iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) { 109 if ( ali->size() == 0 ) continue; // AlternativeFinder will natrually handle this case, if it's legal 110 if ( ali->size() <= 1 && InitTweak::isAssignment( op->get_name() ) ) { 111 // what does it mean if an assignment takes 1 argument? maybe someone defined such a function, in which case AlternativeFinder will naturally handle it 112 continue; 113 } 114 115 assert( ! ali->empty() ); 116 // grab args 2-N and group into a TupleExpr 117 const ResolvExpr::Alternative & alt1 = ali->front(); 118 auto begin = std::next(ali->begin(), 1), end = ali->end(); 119 if ( pointsToTuple(alt1.expr) ) { 120 if ( isMultAssign( begin, end ) ) { 121 matcher.reset( new MultipleAssignMatcher( *this, *ali ) ); 122 } else { 150 123 // 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() ) ); 124 matcher.reset( new MassAssignMatcher( *this, *ali ) ); 178 125 } 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() ) ); 126 match(); 189 127 } 190 128 } 191 129 } 192 130 } 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 131 } 132 133 void TupleAssignSpotter::match() { 134 assert ( matcher != 0 ); 135 136 std::list< Expression * > new_assigns; 137 matcher->match( new_assigns ); 138 139 if ( new_assigns.empty() ) return; 140 ResolvExpr::AltList current; 141 // now resolve new assignments 142 for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) { 143 ResolvExpr::AlternativeFinder finder( currentFinder.get_indexer(), currentFinder.get_environ() ); 144 try { 145 finder.findWithAdjustment(*i); 146 } catch (...) { 147 return; // xxx - no match should not mean failure, it just means this particular tuple assignment isn't valid 148 } 149 // prune expressions that don't coincide with 150 ResolvExpr::AltList alts = finder.get_alternatives(); 151 assert( alts.size() == 1 ); 152 assert( alts.front().expr != 0 ); 153 current.push_back( alts.front() ); 154 } 155 156 // extract expressions from the assignment alternatives to produce a list of assignments that 157 // together form a single alternative 158 std::list< Expression *> solved_assigns; 159 for ( ResolvExpr::Alternative & alt : current ) { 160 solved_assigns.push_back( alt.expr->clone() ); 161 } 162 // xxx - need to do this?? 163 ResolvExpr::TypeEnvironment compositeEnv; 164 simpleCombineEnvironments( current.begin(), current.end(), compositeEnv ); 165 currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), compositeEnv, ResolvExpr::sumCost( current ) ) ); 166 } 167 168 TupleAssignSpotter::Matcher::Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList &alts ) : spotter(spotter) { 169 assert( ! alts.empty() ); 170 ResolvExpr::Alternative lhsAlt = alts.front(); 171 // peel off the cast that exists on ctor/dtor expressions 172 bool isCast = false; 173 if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( lhsAlt.expr ) ) { 174 lhsAlt.expr = castExpr->get_arg(); 175 castExpr->set_arg( nullptr ); 176 delete castExpr; 177 isCast = true; 178 } 179 180 // explode the lhs so that each field of the tuple-valued-expr is assigned. 181 explode( lhsAlt, spotter.currentFinder.get_indexer(), back_inserter(lhs) ); 182 // and finally, re-add the cast to each lhs expr, so that qualified tuple fields can be constructed 183 if ( isCast ) { 184 for ( ResolvExpr::Alternative & alt : lhs ) { 185 Expression *& expr = alt.expr; 186 Type * castType = expr->get_result()->clone(); 187 Type * type = InitTweak::getPointerBase( castType ); 188 assert( type ); 189 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true); 190 type->set_isLvalue( true ); // xxx - might not need this 191 expr = new CastExpr( expr, castType ); 192 } 193 } 194 // } 195 } 196 197 TupleAssignSpotter::MassAssignMatcher::MassAssignMatcher( TupleAssignSpotter &spotter,const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) { 198 assert( alts.size() == 1 || alts.size() == 2 ); 199 if ( alts.size() == 2 ) { 200 rhs.push_back( alts.back() ); 201 } 202 } 203 204 TupleAssignSpotter::MultipleAssignMatcher::MultipleAssignMatcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList & alts ) : Matcher( spotter, alts ) { 205 // explode the rhs so that each field of the tuple-valued-expr is assigned. 206 explode( std::next(alts.begin(), 1), alts.end(), spotter.currentFinder.get_indexer(), back_inserter(rhs) ); 207 } 208 209 UntypedExpr * createFunc( const std::string &fname, ObjectDecl *left, ObjectDecl *right ) { 210 assert( left ); 211 std::list< Expression * > args; 212 args.push_back( new AddressExpr( new UntypedExpr( new NameExpr("*?"), std::list< Expression * >{ new VariableExpr( left ) } ) ) ); 213 // args.push_back( new AddressExpr( new VariableExpr( left ) ) ); 214 if ( right ) args.push_back( new VariableExpr( right ) ); 215 return new UntypedExpr( new NameExpr( fname ), args ); 216 } 217 218 ObjectDecl * newObject( UniqueName & namer, Expression * expr ) { 219 assert( expr->has_result() && ! expr->get_result()->isVoid() ); 220 return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 221 } 222 223 void TupleAssignSpotter::MassAssignMatcher::match( std::list< Expression * > &out ) { 224 static UniqueName lhsNamer( "__massassign_L" ); 225 static UniqueName rhsNamer( "__massassign_R" ); 226 assert ( ! lhs.empty() && rhs.size() <= 1); 227 228 ObjectDecl * rtmp = rhs.size() == 1 ? newObject( rhsNamer, rhs.front().expr ) : nullptr; 229 for ( ResolvExpr::Alternative & lhsAlt : lhs ) { 230 ObjectDecl * ltmp = newObject( lhsNamer, lhsAlt.expr ); 231 out.push_back( createFunc( spotter.fname, ltmp, rtmp ) ); 232 tmpDecls.push_back( ltmp ); 233 } 234 if ( rtmp ) tmpDecls.push_back( rtmp ); 235 } 236 237 void TupleAssignSpotter::MultipleAssignMatcher::match( std::list< Expression * > &out ) { 238 static UniqueName lhsNamer( "__multassign_L" ); 239 static UniqueName rhsNamer( "__multassign_R" ); 240 // xxx - need more complicated matching? 267 241 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; 242 std::list< ObjectDecl * > ltmp; 243 std::list< ObjectDecl * > rtmp; 244 std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), []( ResolvExpr::Alternative & alt ){ 245 return newObject( lhsNamer, alt.expr ); 246 }); 247 std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), []( ResolvExpr::Alternative & alt ){ 248 return newObject( rhsNamer, alt.expr ); 249 }); 250 zipWith( ltmp.begin(), ltmp.end(), rtmp.begin(), rtmp.end(), back_inserter(out), [&](ObjectDecl * obj1, ObjectDecl * obj2 ) { return createFunc(spotter.fname, obj1, obj2); } ); 251 tmpDecls.splice( tmpDecls.end(), ltmp ); 252 tmpDecls.splice( tmpDecls.end(), rtmp ); 253 } 408 254 } 409 255 } // namespace Tuples -
src/Tuples/module.mk
r47a8d17 r3f0c6a5 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.cc18 Tuples/TupleExpansion.cc -
src/main.cc
r47a8d17 r3f0c6a5 42 42 #include "Common/UnimplementedError.h" 43 43 #include "../config.h" 44 #include "Tuples/Tuples.h" 44 45 45 46 using namespace std; … … 231 232 OPTPRINT( "tweakInit" ) 232 233 InitTweak::genInit( translationUnit ); 233 234 OPTPRINT( "expandMemberTuples" ); 235 Tuples::expandMemberTuples( translationUnit ); 234 236 if ( libcfap ) { 235 237 // generate the bodies of cfa library functions … … 248 250 return 0; 249 251 } // if 252 253 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 254 Tuples::expandUniqueExpr( translationUnit ); 250 255 251 256 // fix ObjectDecl - replaces ConstructorInit nodes … … 272 277 OPTPRINT( "box" ) 273 278 GenPoly::box( translationUnit ); 279 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this? 280 Tuples::expandTuples( translationUnit ); 274 281 275 282 // print tree right before code generation
Note:
See TracChangeset
for help on using the changeset viewer.