Changes in / [fe7b281:a1e67dd]
- 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) (546 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) (8 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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) … … 364 363 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 365 364 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 366 ControlStruct/ForExprMutator.cc \ 367 ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \ 365 ControlStruct/ForExprMutator.cc GenPoly/Box.cc \ 368 366 GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ 369 367 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ … … 405 403 SynTree/AddStmtVisitor.cc SynTree/TypeSubstitution.cc \ 406 404 SynTree/Attribute.cc Tuples/TupleAssignment.cc \ 407 Tuples/ NameMatcher.cc405 Tuples/TupleExpansion.cc 408 406 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 409 407 ${cfa_cpplib_PROGRAMS}} … … 540 538 ControlStruct/$(DEPDIR)/$(am__dirstamp) 541 539 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT): \ 542 ControlStruct/$(am__dirstamp) \543 ControlStruct/$(DEPDIR)/$(am__dirstamp)544 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT): \545 540 ControlStruct/$(am__dirstamp) \ 546 541 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 776 771 Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT): \ 777 772 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 778 Tuples/driver_cfa_cpp- NameMatcher.$(OBJEXT): Tuples/$(am__dirstamp)\779 Tuples/$( DEPDIR)/$(am__dirstamp)773 Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT): \ 774 Tuples/$(am__dirstamp) Tuples/$(DEPDIR)/$(am__dirstamp) 780 775 driver/$(am__dirstamp): 781 776 @$(MKDIR_P) driver … … 799 794 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) 800 795 -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) 801 -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)802 796 -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) 803 797 -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) … … 886 880 -rm -f SynTree/driver_cfa_cpp-VoidType.$(OBJEXT) 887 881 -rm -f SynTree/driver_cfa_cpp-ZeroOneType.$(OBJEXT) 888 -rm -f Tuples/driver_cfa_cpp-NameMatcher.$(OBJEXT)889 882 -rm -f Tuples/driver_cfa_cpp-TupleAssignment.$(OBJEXT) 883 -rm -f Tuples/driver_cfa_cpp-TupleExpansion.$(OBJEXT) 890 884 891 885 distclean-compile: … … 906 900 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ 907 901 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Po@am__quote@ 908 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po@am__quote@909 902 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@ 910 903 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@ … … 993 986 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 994 987 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ 995 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po@am__quote@996 988 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleAssignment.Po@am__quote@ 989 @AMDEP_TRUE@@am__include@ @am__quote@Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po@am__quote@ 997 990 998 991 .cc.o: … … 1236 1229 @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` 1237 1230 1238 ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc1239 @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.cc1240 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po1241 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.o' libtool=no @AMDEPBACKSLASH@1242 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1243 @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.cc1244 1245 ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc1246 @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`1247 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po1248 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj' libtool=no @AMDEPBACKSLASH@1249 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1250 @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`1251 1252 1231 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1253 1232 @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 … … 2440 2419 @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` 2441 2420 2442 Tuples/driver_cfa_cpp- NameMatcher.o: Tuples/NameMatcher.cc2443 @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.cc2444 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp- NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po2445 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/ NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.o' libtool=no @AMDEPBACKSLASH@2446 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2447 @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.cc2448 2449 Tuples/driver_cfa_cpp- NameMatcher.obj: Tuples/NameMatcher.cc2450 @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`2451 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp- NameMatcher.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-NameMatcher.Po2452 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/ NameMatcher.cc' object='Tuples/driver_cfa_cpp-NameMatcher.obj' libtool=no @AMDEPBACKSLASH@2453 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2454 @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`2421 Tuples/driver_cfa_cpp-TupleExpansion.o: Tuples/TupleExpansion.cc 2422 @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 2423 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po 2424 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.o' libtool=no @AMDEPBACKSLASH@ 2425 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2426 @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 2427 2428 Tuples/driver_cfa_cpp-TupleExpansion.obj: Tuples/TupleExpansion.cc 2429 @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` 2430 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Tpo Tuples/$(DEPDIR)/driver_cfa_cpp-TupleExpansion.Po 2431 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='Tuples/TupleExpansion.cc' object='Tuples/driver_cfa_cpp-TupleExpansion.obj' libtool=no @AMDEPBACKSLASH@ 2432 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2433 @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` 2455 2434 2456 2435 .ll.cc: -
src/Parser/ExpressionNode.cc
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 1023 1023 static const yytype_uint16 yyrline[] = 1024 1024 { 1025 0, 30 2, 302, 306, 313, 314, 315, 319, 320, 321,1026 32 5, 326, 330, 331, 335, 336, 340, 344, 345, 356,1027 35 8, 360, 362, 367, 368, 374, 378, 380, 381, 382,1028 38 4, 385, 387, 389, 391, 400, 401, 407, 408, 412,1029 41 3, 417, 421, 423, 425, 427, 432, 434, 438, 441,1030 44 3, 445, 450, 463, 465, 467, 469, 471, 473, 475,1031 4 77, 479, 481, 483, 490, 491, 497, 498, 499, 500,1032 50 4, 505, 507, 512, 513, 515, 517, 522, 523, 525,1033 53 0, 531, 533, 538, 539, 541, 543, 545, 550, 551,1034 55 3, 558, 559, 564, 565, 570, 571, 576, 577, 582,1035 58 3, 588, 589, 592, 594, 599, 604, 605, 607, 613,1036 61 4, 618, 619, 620, 621, 622, 623, 624, 625, 626,1037 6 27, 628, 629, 635, 637, 639, 641, 646, 647, 652,1038 65 3, 659, 660, 666, 667, 668, 669, 670, 671, 672,1039 67 3, 674, 684, 691, 693, 703, 704, 709, 711, 717,1040 7 19, 723, 724, 729, 734, 737, 739, 741, 751, 753,1041 76 4, 765, 767, 771, 773, 777, 778, 783, 784, 788,1042 79 3, 794, 798, 800, 806, 807, 811, 813, 815, 817,1043 82 3, 824, 828, 830, 835, 837, 839, 844, 846, 851,1044 85 3, 857, 860, 864, 867, 871, 873, 875, 877, 882,1045 88 4, 886, 891, 893, 895, 897, 899, 904, 906, 908,1046 91 0, 915, 927, 928, 933, 935, 940, 944, 946, 948,1047 95 0, 952, 958, 959, 965, 966, 970, 971, 976, 978,1048 98 4, 985, 987, 992, 997, 1007, 1009, 1013, 1014, 1019,1049 102 1, 1025, 1026, 1030, 1032, 1036, 1037, 1041, 1042, 1046,1050 10 47, 1062, 1063, 1064, 1065, 1066, 1070, 1075, 1082, 1092,1051 1 097, 1102, 1110, 1115, 1120, 1125, 1130, 1138, 1160, 1165,1052 117 2, 1174, 1181, 1186, 1191, 1202, 1207, 1212, 1217, 1222,1053 123 1, 1236, 1244, 1245, 1246, 1247, 1253, 1258, 1266, 1267,1054 12 68, 1269, 1273, 1274, 1275, 1276, 1281, 1282, 1291, 1292,1055 1 297, 1298, 1303, 1305, 1307, 1309, 1311, 1314, 1313, 1325,1056 132 6, 1328, 1338, 1339, 1344, 1346, 1348, 1350, 1352, 1355,1057 13 57, 1360, 1365, 1367, 1369, 1371, 1373, 1375, 1377, 1379,1058 138 1, 1383, 1385, 1387, 1389, 1395, 1396, 1398, 1400, 1402,1059 14 07, 1408, 1414, 1415, 1417, 1419, 1424, 1426, 1428, 1430,1060 143 5, 1436, 1438, 1440, 1445, 1446, 1448, 1453, 1454, 1456,1061 14 58, 1463, 1465, 1467, 1472, 1473, 1477, 1479, 1485, 1484,1062 14 88, 1490, 1495, 1497, 1503, 1504, 1509, 1510, 1512, 1513,1063 152 2, 1523, 1525, 1527, 1532, 1534, 1540, 1541, 1543, 1546,1064 15 49, 1554, 1555, 1560, 1565, 1569, 1571, 1577, 1576, 1583,1065 158 5, 1591, 1592, 1600, 1601, 1605, 1606, 1607, 1609, 1611,1066 16 18, 1619, 1621, 1623, 1628, 1629, 1635, 1636, 1640, 1641,1067 164 6, 1647, 1648, 1650, 1658, 1659, 1661, 1664, 1666, 1670,1068 167 1, 1672, 1674, 1676, 1680, 1685, 1693, 1694, 1703, 1705,1069 171 0, 1711, 1712, 1716, 1717, 1718, 1722, 1723, 1724, 1728,1070 17 29, 1730, 1735, 1736, 1737, 1738, 1744, 1745, 1747, 1752,1071 175 3, 1758, 1759, 1760, 1761, 1762, 1777, 1778, 1783, 1784,1072 179 0, 1792, 1795, 1797, 1799, 1822, 1823, 1825, 1827, 1832,1073 183 3, 1835, 1840, 1845, 1846, 1852, 1851, 1855, 1859, 1861,1074 186 3, 1869, 1870, 1875, 1880, 1882, 1887, 1889, 1890, 1892,1075 1 897, 1899, 1901, 1906, 1908, 1913, 1918, 1926, 1932, 1931,1076 194 5, 1946, 1951, 1952, 1956, 1961, 1966, 1974, 1979, 1990,1077 199 1, 1996, 1997, 2003, 2004, 2008, 2009, 2010, 2013, 2012,1078 202 3, 2032, 2038, 2044, 2053, 2059, 2065, 2071, 2077, 2085,1079 209 1, 2099, 2105, 2114, 2115, 2116, 2120, 2124, 2126, 2131,1080 213 2, 2136, 2137, 2142, 2148, 2149, 2152, 2154, 2155, 2159,1081 216 0, 2161, 2162, 2196, 2198, 2199, 2201, 2206, 2211, 2216,1082 22 18, 2220, 2225, 2227, 2229, 2231, 2236, 2238, 2247, 2249,1083 225 0, 2255, 2257, 2259, 2264, 2266, 2268, 2273, 2275, 2277,1084 228 6, 2287, 2288, 2292, 2294, 2296, 2301, 2303, 2305, 2310,1085 231 2, 2314, 2329, 2331, 2332, 2334, 2339, 2340, 2345, 2347,1086 23 49, 2354, 2356, 2358, 2360, 2365, 2367, 2369, 2379, 2381,1087 238 2, 2384, 2389, 2391, 2393, 2398, 2400, 2402, 2404, 2409,1088 241 1, 2413, 2444, 2446, 2447, 2449, 2454, 2459, 2467, 2469,1089 247 1, 2476, 2478, 2483, 2485, 2499, 2500, 2502, 2507, 2509,1090 251 1, 2513, 2515, 2520, 2521, 2523, 2525, 2530, 2532, 2534,1091 254 0, 2542, 2544, 2548, 2550, 2552, 2554, 2568, 2569, 2571,1092 257 6, 2578, 2580, 2582, 2584, 2589, 2590, 2592, 2594, 2599,1093 260 1, 2603, 2609, 2610, 2612, 2621, 2624, 2626, 2629, 2631,1094 263 3, 2646, 2647, 2649, 2654, 2656, 2658, 2660, 2662, 2667,1095 26 68, 2670, 2672, 2677, 2679, 2687, 2688, 2689, 2694, 2695,1096 2 699, 2701, 2703, 2705, 2707, 2709, 2716, 2718, 2720, 2722,1097 272 4, 2727, 2729, 2731, 2733, 2735, 2740, 2742, 2744, 2749,1098 277 5, 2776, 2778, 2782, 2783, 2787, 2789, 2791, 2793, 2795,1099 2 797, 2804, 2806, 2808, 2810, 2812, 2814, 2819, 2824, 2826,1100 28 28, 2846, 2848, 2853, 28541025 0, 301, 301, 305, 312, 313, 314, 318, 319, 320, 1026 324, 325, 329, 330, 334, 335, 339, 343, 344, 355, 1027 357, 359, 361, 366, 367, 373, 377, 379, 381, 383, 1028 385, 387, 389, 391, 393, 402, 403, 409, 410, 414, 1029 415, 419, 422, 424, 426, 428, 433, 436, 441, 444, 1030 446, 448, 453, 466, 468, 470, 472, 474, 476, 478, 1031 480, 482, 484, 486, 493, 494, 500, 501, 502, 503, 1032 507, 508, 510, 515, 516, 518, 520, 525, 526, 528, 1033 533, 534, 536, 541, 542, 544, 546, 548, 553, 554, 1034 556, 561, 562, 567, 568, 573, 574, 579, 580, 585, 1035 586, 591, 592, 595, 597, 602, 607, 608, 610, 616, 1036 617, 621, 622, 623, 624, 625, 626, 627, 628, 629, 1037 630, 631, 632, 638, 640, 642, 644, 649, 650, 655, 1038 656, 662, 663, 669, 670, 671, 672, 673, 674, 675, 1039 676, 677, 687, 694, 696, 706, 707, 712, 714, 720, 1040 722, 726, 727, 732, 737, 740, 742, 744, 754, 756, 1041 767, 768, 770, 774, 776, 780, 781, 786, 787, 791, 1042 796, 797, 801, 803, 809, 810, 814, 816, 818, 820, 1043 826, 827, 831, 833, 838, 840, 842, 847, 849, 854, 1044 856, 860, 863, 867, 870, 874, 876, 878, 880, 885, 1045 887, 889, 894, 896, 898, 900, 902, 907, 909, 911, 1046 913, 918, 930, 931, 936, 938, 943, 947, 949, 951, 1047 953, 955, 961, 962, 968, 969, 973, 974, 979, 981, 1048 987, 988, 990, 995, 1000, 1010, 1012, 1016, 1017, 1022, 1049 1024, 1028, 1029, 1033, 1035, 1039, 1040, 1044, 1045, 1049, 1050 1050, 1065, 1066, 1067, 1068, 1069, 1073, 1078, 1085, 1095, 1051 1100, 1105, 1113, 1118, 1123, 1128, 1133, 1141, 1163, 1168, 1052 1175, 1177, 1184, 1189, 1194, 1205, 1210, 1215, 1220, 1225, 1053 1234, 1239, 1247, 1248, 1249, 1250, 1256, 1261, 1269, 1270, 1054 1271, 1272, 1276, 1277, 1278, 1279, 1284, 1285, 1294, 1295, 1055 1300, 1301, 1306, 1308, 1310, 1312, 1314, 1317, 1316, 1328, 1056 1329, 1331, 1341, 1342, 1347, 1349, 1351, 1353, 1355, 1358, 1057 1360, 1363, 1368, 1370, 1372, 1374, 1376, 1378, 1380, 1382, 1058 1384, 1386, 1388, 1390, 1392, 1398, 1399, 1401, 1403, 1405, 1059 1410, 1411, 1417, 1418, 1420, 1422, 1427, 1429, 1431, 1433, 1060 1438, 1439, 1441, 1443, 1448, 1449, 1451, 1456, 1457, 1459, 1061 1461, 1466, 1468, 1470, 1475, 1476, 1480, 1482, 1488, 1487, 1062 1491, 1493, 1498, 1500, 1506, 1507, 1512, 1513, 1515, 1516, 1063 1525, 1526, 1528, 1530, 1535, 1537, 1543, 1544, 1546, 1549, 1064 1552, 1557, 1558, 1563, 1568, 1572, 1574, 1580, 1579, 1586, 1065 1588, 1594, 1595, 1603, 1604, 1608, 1609, 1610, 1612, 1614, 1066 1621, 1622, 1624, 1626, 1631, 1632, 1638, 1639, 1643, 1644, 1067 1649, 1650, 1651, 1653, 1661, 1662, 1664, 1667, 1669, 1673, 1068 1674, 1675, 1677, 1679, 1683, 1688, 1696, 1697, 1706, 1708, 1069 1713, 1714, 1715, 1719, 1720, 1721, 1725, 1726, 1727, 1731, 1070 1732, 1733, 1738, 1739, 1740, 1741, 1747, 1748, 1750, 1755, 1071 1756, 1761, 1762, 1763, 1764, 1765, 1780, 1781, 1786, 1787, 1072 1793, 1795, 1798, 1800, 1802, 1825, 1826, 1828, 1830, 1835, 1073 1836, 1838, 1843, 1848, 1849, 1855, 1854, 1858, 1862, 1864, 1074 1866, 1872, 1873, 1878, 1883, 1885, 1890, 1892, 1893, 1895, 1075 1900, 1902, 1904, 1909, 1911, 1916, 1921, 1929, 1935, 1934, 1076 1948, 1949, 1954, 1955, 1959, 1964, 1969, 1977, 1982, 1993, 1077 1994, 1999, 2000, 2006, 2007, 2011, 2012, 2013, 2016, 2015, 1078 2026, 2035, 2041, 2047, 2056, 2062, 2068, 2074, 2080, 2088, 1079 2094, 2102, 2108, 2117, 2118, 2119, 2123, 2127, 2129, 2134, 1080 2135, 2139, 2140, 2145, 2151, 2152, 2155, 2157, 2158, 2162, 1081 2163, 2164, 2165, 2199, 2201, 2202, 2204, 2209, 2214, 2219, 1082 2221, 2223, 2228, 2230, 2232, 2234, 2239, 2241, 2250, 2252, 1083 2253, 2258, 2260, 2262, 2267, 2269, 2271, 2276, 2278, 2280, 1084 2289, 2290, 2291, 2295, 2297, 2299, 2304, 2306, 2308, 2313, 1085 2315, 2317, 2332, 2334, 2335, 2337, 2342, 2343, 2348, 2350, 1086 2352, 2357, 2359, 2361, 2363, 2368, 2370, 2372, 2382, 2384, 1087 2385, 2387, 2392, 2394, 2396, 2401, 2403, 2405, 2407, 2412, 1088 2414, 2416, 2447, 2449, 2450, 2452, 2457, 2462, 2470, 2472, 1089 2474, 2479, 2481, 2486, 2488, 2502, 2503, 2505, 2510, 2512, 1090 2514, 2516, 2518, 2523, 2524, 2526, 2528, 2533, 2535, 2537, 1091 2543, 2545, 2547, 2551, 2553, 2555, 2557, 2571, 2572, 2574, 1092 2579, 2581, 2583, 2585, 2587, 2592, 2593, 2595, 2597, 2602, 1093 2604, 2606, 2612, 2613, 2615, 2624, 2627, 2629, 2632, 2634, 1094 2636, 2649, 2650, 2652, 2657, 2659, 2661, 2663, 2665, 2670, 1095 2671, 2673, 2675, 2680, 2682, 2690, 2691, 2692, 2697, 2698, 1096 2702, 2704, 2706, 2708, 2710, 2712, 2719, 2721, 2723, 2725, 1097 2727, 2730, 2732, 2734, 2736, 2738, 2743, 2745, 2747, 2752, 1098 2778, 2779, 2781, 2785, 2786, 2790, 2792, 2794, 2796, 2798, 1099 2800, 2807, 2809, 2811, 2813, 2815, 2817, 2822, 2827, 2829, 1100 2831, 2849, 2851, 2856, 2857 1101 1101 }; 1102 1102 #endif … … 4977 4977 4978 4978 /* Line 1806 of yacc.c */ 4979 #line 30 2"parser.yy"4979 #line 301 "parser.yy" 4980 4980 { typedefTable.enterScope(); } 4981 4981 break; … … 4984 4984 4985 4985 /* Line 1806 of yacc.c */ 4986 #line 30 6"parser.yy"4986 #line 305 "parser.yy" 4987 4987 { typedefTable.leaveScope(); } 4988 4988 break; … … 4991 4991 4992 4992 /* Line 1806 of yacc.c */ 4993 #line 312 "parser.yy" 4994 { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); } 4995 break; 4996 4997 case 5: 4998 4999 /* Line 1806 of yacc.c */ 4993 5000 #line 313 "parser.yy" 4994 { (yyval.en) = new ExpressionNode( build_constant Integer( *(yyvsp[(1) - (1)].tok) ) ); }4995 break; 4996 4997 case 5:5001 { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); } 5002 break; 5003 5004 case 6: 4998 5005 4999 5006 /* Line 1806 of yacc.c */ 5000 5007 #line 314 "parser.yy" 5001 { (yyval.en) = new ExpressionNode( build_constantFloat( *(yyvsp[(1) - (1)].tok) ) ); }5002 break;5003 5004 case 6:5005 5006 /* Line 1806 of yacc.c */5007 #line 315 "parser.yy"5008 5008 { (yyval.en) = new ExpressionNode( build_constantChar( *(yyvsp[(1) - (1)].tok) ) ); } 5009 5009 break; … … 5012 5012 5013 5013 /* Line 1806 of yacc.c */ 5014 #line 3 40"parser.yy"5014 #line 339 "parser.yy" 5015 5015 { (yyval.constant) = build_constantStr( *(yyvsp[(1) - (1)].str) ); } 5016 5016 break; … … 5019 5019 5020 5020 /* Line 1806 of yacc.c */ 5021 #line 34 4"parser.yy"5021 #line 343 "parser.yy" 5022 5022 { (yyval.str) = (yyvsp[(1) - (1)].tok); } 5023 5023 break; … … 5026 5026 5027 5027 /* Line 1806 of yacc.c */ 5028 #line 34 6"parser.yy"5028 #line 345 "parser.yy" 5029 5029 { 5030 5030 appendStr( (yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].tok) ); // append 2nd juxtaposed string to 1st … … 5037 5037 5038 5038 /* Line 1806 of yacc.c */ 5039 #line 35 7"parser.yy"5039 #line 356 "parser.yy" 5040 5040 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); } 5041 5041 break; … … 5044 5044 5045 5045 /* Line 1806 of yacc.c */ 5046 #line 35 9"parser.yy"5046 #line 358 "parser.yy" 5047 5047 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); } 5048 5048 break; … … 5051 5051 5052 5052 /* Line 1806 of yacc.c */ 5053 #line 36 1"parser.yy"5053 #line 360 "parser.yy" 5054 5054 { (yyval.en) = (yyvsp[(2) - (3)].en); } 5055 5055 break; … … 5058 5058 5059 5059 /* Line 1806 of yacc.c */ 5060 #line 36 3"parser.yy"5060 #line 362 "parser.yy" 5061 5061 { (yyval.en) = new ExpressionNode( build_valexpr( (yyvsp[(2) - (3)].sn) ) ); } 5062 5062 break; … … 5065 5065 5066 5066 /* Line 1806 of yacc.c */ 5067 #line 37 3"parser.yy"5067 #line 372 "parser.yy" 5068 5068 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Index, (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en) ) ); } 5069 5069 break; … … 5072 5072 5073 5073 /* Line 1806 of yacc.c */ 5074 #line 37 5"parser.yy"5074 #line 374 "parser.yy" 5075 5075 { (yyval.en) = new ExpressionNode( build_func( (yyvsp[(1) - (4)].en), (yyvsp[(3) - (4)].en) ) ); } 5076 5076 break; … … 5079 5079 5080 5080 /* Line 1806 of yacc.c */ 5081 #line 37 9"parser.yy"5081 #line 378 "parser.yy" 5082 5082 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); } 5083 5083 break; 5084 5084 5085 case 27: 5086 5087 /* Line 1806 of yacc.c */ 5088 #line 380 "parser.yy" 5089 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 5090 break; 5091 5092 case 28: 5093 5094 /* Line 1806 of yacc.c */ 5095 #line 382 "parser.yy" 5096 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), build_constantInteger( *(yyvsp[(3) - (3)].tok) ) ) ); } 5097 break; 5098 5085 5099 case 29: 5086 5100 5087 5101 /* Line 1806 of yacc.c */ 5088 #line 38 3"parser.yy"5102 #line 384 "parser.yy" 5089 5103 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), build_varref( (yyvsp[(3) - (3)].tok) ) ) ); } 5090 5104 break; 5091 5105 5106 case 30: 5107 5108 /* Line 1806 of yacc.c */ 5109 #line 386 "parser.yy" 5110 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 5111 break; 5112 5092 5113 case 31: 5093 5114 5094 5115 /* Line 1806 of yacc.c */ 5095 #line 38 6"parser.yy"5116 #line 388 "parser.yy" 5096 5117 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, (yyvsp[(1) - (2)].en) ) ); } 5097 5118 break; … … 5100 5121 5101 5122 /* Line 1806 of yacc.c */ 5102 #line 3 88"parser.yy"5123 #line 390 "parser.yy" 5103 5124 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, (yyvsp[(1) - (2)].en) ) ); } 5104 5125 break; … … 5107 5128 5108 5129 /* Line 1806 of yacc.c */ 5109 #line 39 0"parser.yy"5130 #line 392 "parser.yy" 5110 5131 { (yyval.en) = new ExpressionNode( build_compoundLiteral( (yyvsp[(2) - (7)].decl), new InitializerNode( (yyvsp[(5) - (7)].in), true ) ) ); } 5111 5132 break; … … 5114 5135 5115 5136 /* Line 1806 of yacc.c */ 5116 #line 39 2"parser.yy"5137 #line 394 "parser.yy" 5117 5138 { 5118 5139 Token fn; … … 5125 5146 5126 5147 /* Line 1806 of yacc.c */ 5127 #line 40 2"parser.yy"5148 #line 404 "parser.yy" 5128 5149 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); } 5129 5150 break; … … 5132 5153 5133 5154 /* Line 1806 of yacc.c */ 5134 #line 40 7"parser.yy"5155 #line 409 "parser.yy" 5135 5156 { (yyval.en) = 0; } 5136 5157 break; … … 5139 5160 5140 5161 /* Line 1806 of yacc.c */ 5141 #line 41 3"parser.yy"5162 #line 415 "parser.yy" 5142 5163 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 5143 5164 break; 5144 5165 5145 case 41: 5146 5147 /* Line 1806 of yacc.c */ 5148 #line 420 "parser.yy" 5166 case 42: 5167 5168 /* Line 1806 of yacc.c */ 5169 #line 423 "parser.yy" 5170 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); } 5171 break; 5172 5173 case 43: 5174 5175 /* Line 1806 of yacc.c */ 5176 #line 425 "parser.yy" 5177 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 5178 break; 5179 5180 case 44: 5181 5182 /* Line 1806 of yacc.c */ 5183 #line 427 "parser.yy" 5184 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (3)].en), maybeMoveBuild<Expression>( (yyvsp[(3) - (3)].en) ) ) ); } 5185 break; 5186 5187 case 45: 5188 5189 /* Line 1806 of yacc.c */ 5190 #line 429 "parser.yy" 5191 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(1) - (7)].en), build_tuple( (yyvsp[(5) - (7)].en) ) ) ); } 5192 break; 5193 5194 case 46: 5195 5196 /* Line 1806 of yacc.c */ 5197 #line 434 "parser.yy" 5149 5198 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (1)].tok) ) ); } 5150 5199 break; 5151 5200 5152 case 42: 5153 5154 /* Line 1806 of yacc.c */ 5155 #line 422 "parser.yy" 5156 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); } 5157 break; 5158 5159 case 43: 5160 5161 /* Line 1806 of yacc.c */ 5162 #line 424 "parser.yy" 5163 { (yyval.en) = new ExpressionNode( build_fieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); } 5164 break; 5165 5166 case 44: 5167 5168 /* Line 1806 of yacc.c */ 5169 #line 426 "parser.yy" 5170 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(3) - (3)].en), build_varref( (yyvsp[(1) - (3)].tok) ) ) ); } 5171 break; 5172 5173 case 45: 5174 5175 /* Line 1806 of yacc.c */ 5176 #line 428 "parser.yy" 5177 { (yyval.en) = new ExpressionNode( build_pfieldSel( (yyvsp[(5) - (7)].en), build_varref( (yyvsp[(1) - (7)].tok) ) ) ); } 5201 case 47: 5202 5203 /* Line 1806 of yacc.c */ 5204 #line 437 "parser.yy" 5205 { (yyval.en) = new ExpressionNode( build_constantInteger( *(yyvsp[(1) - (1)].tok) ) ); } 5178 5206 break; 5179 5207 … … 5181 5209 5182 5210 /* Line 1806 of yacc.c */ 5183 #line 44 2"parser.yy"5211 #line 445 "parser.yy" 5184 5212 { (yyval.en) = (yyvsp[(1) - (1)].en); } 5185 5213 break; … … 5188 5216 5189 5217 /* Line 1806 of yacc.c */ 5190 #line 44 4"parser.yy"5218 #line 447 "parser.yy" 5191 5219 { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); } 5192 5220 break; … … 5195 5223 5196 5224 /* Line 1806 of yacc.c */ 5197 #line 44 6"parser.yy"5225 #line 449 "parser.yy" 5198 5226 { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); } 5199 5227 break; … … 5202 5230 5203 5231 /* Line 1806 of yacc.c */ 5204 #line 45 1"parser.yy"5232 #line 454 "parser.yy" 5205 5233 { 5206 5234 switch ( (yyvsp[(1) - (2)].op) ) { … … 5220 5248 5221 5249 /* Line 1806 of yacc.c */ 5222 #line 46 4"parser.yy"5250 #line 467 "parser.yy" 5223 5251 { (yyval.en) = new ExpressionNode( build_unary_val( (yyvsp[(1) - (2)].op), (yyvsp[(2) - (2)].en) ) ); } 5224 5252 break; … … 5227 5255 5228 5256 /* Line 1806 of yacc.c */ 5229 #line 46 6"parser.yy"5257 #line 469 "parser.yy" 5230 5258 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Incr, (yyvsp[(2) - (2)].en) ) ); } 5231 5259 break; … … 5234 5262 5235 5263 /* Line 1806 of yacc.c */ 5236 #line 4 68"parser.yy"5264 #line 471 "parser.yy" 5237 5265 { (yyval.en) = new ExpressionNode( build_unary_ptr( OperKinds::Decr, (yyvsp[(2) - (2)].en) ) ); } 5238 5266 break; … … 5241 5269 5242 5270 /* Line 1806 of yacc.c */ 5243 #line 47 0"parser.yy"5271 #line 473 "parser.yy" 5244 5272 { (yyval.en) = new ExpressionNode( build_sizeOfexpr( (yyvsp[(2) - (2)].en) ) ); } 5245 5273 break; … … 5248 5276 5249 5277 /* Line 1806 of yacc.c */ 5250 #line 47 2"parser.yy"5278 #line 475 "parser.yy" 5251 5279 { (yyval.en) = new ExpressionNode( build_sizeOftype( (yyvsp[(3) - (4)].decl) ) ); } 5252 5280 break; … … 5255 5283 5256 5284 /* Line 1806 of yacc.c */ 5257 #line 47 4"parser.yy"5285 #line 477 "parser.yy" 5258 5286 { (yyval.en) = new ExpressionNode( build_alignOfexpr( (yyvsp[(2) - (2)].en) ) ); } 5259 5287 break; … … 5262 5290 5263 5291 /* Line 1806 of yacc.c */ 5264 #line 47 6"parser.yy"5292 #line 479 "parser.yy" 5265 5293 { (yyval.en) = new ExpressionNode( build_alignOftype( (yyvsp[(3) - (4)].decl) ) ); } 5266 5294 break; … … 5269 5297 5270 5298 /* Line 1806 of yacc.c */ 5271 #line 4 78"parser.yy"5299 #line 481 "parser.yy" 5272 5300 { (yyval.en) = new ExpressionNode( build_offsetOf( (yyvsp[(3) - (6)].decl), build_varref( (yyvsp[(5) - (6)].tok) ) ) ); } 5273 5301 break; … … 5276 5304 5277 5305 /* Line 1806 of yacc.c */ 5278 #line 48 0"parser.yy"5306 #line 483 "parser.yy" 5279 5307 { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (1)].tok) ), nullptr ) ); } 5280 5308 break; … … 5283 5311 5284 5312 /* Line 1806 of yacc.c */ 5285 #line 48 2"parser.yy"5313 #line 485 "parser.yy" 5286 5314 { (yyval.en) = new ExpressionNode( build_attrexpr( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ) ); } 5287 5315 break; … … 5290 5318 5291 5319 /* Line 1806 of yacc.c */ 5292 #line 48 4"parser.yy"5320 #line 487 "parser.yy" 5293 5321 { (yyval.en) = new ExpressionNode( build_attrtype( build_varref( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].decl) ) ); } 5294 5322 break; … … 5297 5325 5298 5326 /* Line 1806 of yacc.c */ 5299 #line 49 0"parser.yy"5327 #line 493 "parser.yy" 5300 5328 { (yyval.op) = OperKinds::PointTo; } 5301 5329 break; … … 5304 5332 5305 5333 /* Line 1806 of yacc.c */ 5306 #line 49 1"parser.yy"5334 #line 494 "parser.yy" 5307 5335 { (yyval.op) = OperKinds::AddressOf; } 5308 5336 break; … … 5311 5339 5312 5340 /* Line 1806 of yacc.c */ 5313 #line 497"parser.yy"5341 #line 500 "parser.yy" 5314 5342 { (yyval.op) = OperKinds::UnPlus; } 5315 5343 break; … … 5318 5346 5319 5347 /* Line 1806 of yacc.c */ 5320 #line 498"parser.yy"5348 #line 501 "parser.yy" 5321 5349 { (yyval.op) = OperKinds::UnMinus; } 5322 5350 break; … … 5325 5353 5326 5354 /* Line 1806 of yacc.c */ 5327 #line 499"parser.yy"5355 #line 502 "parser.yy" 5328 5356 { (yyval.op) = OperKinds::Neg; } 5329 5357 break; … … 5332 5360 5333 5361 /* Line 1806 of yacc.c */ 5334 #line 50 0"parser.yy"5362 #line 503 "parser.yy" 5335 5363 { (yyval.op) = OperKinds::BitNeg; } 5336 5364 break; … … 5339 5367 5340 5368 /* Line 1806 of yacc.c */ 5341 #line 50 6"parser.yy"5369 #line 509 "parser.yy" 5342 5370 { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); } 5343 5371 break; … … 5346 5374 5347 5375 /* Line 1806 of yacc.c */ 5348 #line 5 08"parser.yy"5376 #line 511 "parser.yy" 5349 5377 { (yyval.en) = new ExpressionNode( build_cast( (yyvsp[(2) - (4)].decl), (yyvsp[(4) - (4)].en) ) ); } 5350 5378 break; … … 5353 5381 5354 5382 /* Line 1806 of yacc.c */ 5355 #line 51 4"parser.yy"5383 #line 517 "parser.yy" 5356 5384 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5357 5385 break; … … 5360 5388 5361 5389 /* Line 1806 of yacc.c */ 5362 #line 51 6"parser.yy"5390 #line 519 "parser.yy" 5363 5391 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5364 5392 break; … … 5367 5395 5368 5396 /* Line 1806 of yacc.c */ 5369 #line 5 18"parser.yy"5397 #line 521 "parser.yy" 5370 5398 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5371 5399 break; … … 5374 5402 5375 5403 /* Line 1806 of yacc.c */ 5376 #line 52 4"parser.yy"5404 #line 527 "parser.yy" 5377 5405 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5378 5406 break; … … 5381 5409 5382 5410 /* Line 1806 of yacc.c */ 5383 #line 52 6"parser.yy"5411 #line 529 "parser.yy" 5384 5412 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5385 5413 break; … … 5388 5416 5389 5417 /* Line 1806 of yacc.c */ 5390 #line 53 2"parser.yy"5418 #line 535 "parser.yy" 5391 5419 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5392 5420 break; … … 5395 5423 5396 5424 /* Line 1806 of yacc.c */ 5397 #line 53 4"parser.yy"5425 #line 537 "parser.yy" 5398 5426 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5399 5427 break; … … 5402 5430 5403 5431 /* Line 1806 of yacc.c */ 5404 #line 54 0"parser.yy"5432 #line 543 "parser.yy" 5405 5433 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5406 5434 break; … … 5409 5437 5410 5438 /* Line 1806 of yacc.c */ 5411 #line 54 2"parser.yy"5439 #line 545 "parser.yy" 5412 5440 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5413 5441 break; … … 5416 5444 5417 5445 /* Line 1806 of yacc.c */ 5418 #line 54 4"parser.yy"5446 #line 547 "parser.yy" 5419 5447 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5420 5448 break; … … 5423 5451 5424 5452 /* Line 1806 of yacc.c */ 5425 #line 54 6"parser.yy"5453 #line 549 "parser.yy" 5426 5454 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5427 5455 break; … … 5430 5458 5431 5459 /* Line 1806 of yacc.c */ 5432 #line 55 2"parser.yy"5460 #line 555 "parser.yy" 5433 5461 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5434 5462 break; … … 5437 5465 5438 5466 /* Line 1806 of yacc.c */ 5439 #line 55 4"parser.yy"5467 #line 557 "parser.yy" 5440 5468 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5441 5469 break; … … 5444 5472 5445 5473 /* Line 1806 of yacc.c */ 5446 #line 56 0"parser.yy"5474 #line 563 "parser.yy" 5447 5475 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5448 5476 break; … … 5451 5479 5452 5480 /* Line 1806 of yacc.c */ 5453 #line 56 6"parser.yy"5481 #line 569 "parser.yy" 5454 5482 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5455 5483 break; … … 5458 5486 5459 5487 /* Line 1806 of yacc.c */ 5460 #line 57 2"parser.yy"5488 #line 575 "parser.yy" 5461 5489 { (yyval.en) = new ExpressionNode( build_binary_val( OperKinds::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5462 5490 break; … … 5465 5493 5466 5494 /* Line 1806 of yacc.c */ 5467 #line 5 78"parser.yy"5495 #line 581 "parser.yy" 5468 5496 { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); } 5469 5497 break; … … 5472 5500 5473 5501 /* Line 1806 of yacc.c */ 5474 #line 58 4"parser.yy"5502 #line 587 "parser.yy" 5475 5503 { (yyval.en) = new ExpressionNode( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); } 5476 5504 break; … … 5479 5507 5480 5508 /* Line 1806 of yacc.c */ 5481 #line 59 0"parser.yy"5509 #line 593 "parser.yy" 5482 5510 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); } 5483 5511 break; … … 5486 5514 5487 5515 /* Line 1806 of yacc.c */ 5488 #line 59 3"parser.yy"5516 #line 596 "parser.yy" 5489 5517 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (4)].en), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ) ); } 5490 5518 break; … … 5493 5521 5494 5522 /* Line 1806 of yacc.c */ 5495 #line 59 5"parser.yy"5523 #line 598 "parser.yy" 5496 5524 { (yyval.en) = new ExpressionNode( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); } 5497 5525 break; … … 5500 5528 5501 5529 /* Line 1806 of yacc.c */ 5502 #line 60 6"parser.yy"5530 #line 609 "parser.yy" 5503 5531 { (yyval.en) = new ExpressionNode( build_binary_ptr( (yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5504 5532 break; … … 5507 5535 5508 5536 /* Line 1806 of yacc.c */ 5509 #line 6 08"parser.yy"5537 #line 611 "parser.yy" 5510 5538 { (yyval.en) = ( (yyvsp[(2) - (2)].en) == 0 ) ? (yyvsp[(1) - (2)].en) : new ExpressionNode( build_binary_ptr( OperKinds::Assign, (yyvsp[(1) - (2)].en), (yyvsp[(2) - (2)].en) ) ); } 5511 5539 break; … … 5514 5542 5515 5543 /* Line 1806 of yacc.c */ 5516 #line 61 3"parser.yy"5544 #line 616 "parser.yy" 5517 5545 { (yyval.en) = nullptr; } 5518 5546 break; … … 5521 5549 5522 5550 /* Line 1806 of yacc.c */ 5523 #line 6 18"parser.yy"5551 #line 621 "parser.yy" 5524 5552 { (yyval.op) = OperKinds::Assign; } 5525 5553 break; … … 5528 5556 5529 5557 /* Line 1806 of yacc.c */ 5530 #line 6 19"parser.yy"5558 #line 622 "parser.yy" 5531 5559 { (yyval.op) = OperKinds::AtAssn; } 5532 5560 break; … … 5535 5563 5536 5564 /* Line 1806 of yacc.c */ 5537 #line 62 0"parser.yy"5565 #line 623 "parser.yy" 5538 5566 { (yyval.op) = OperKinds::MulAssn; } 5539 5567 break; … … 5542 5570 5543 5571 /* Line 1806 of yacc.c */ 5544 #line 62 1"parser.yy"5572 #line 624 "parser.yy" 5545 5573 { (yyval.op) = OperKinds::DivAssn; } 5546 5574 break; … … 5549 5577 5550 5578 /* Line 1806 of yacc.c */ 5551 #line 62 2"parser.yy"5579 #line 625 "parser.yy" 5552 5580 { (yyval.op) = OperKinds::ModAssn; } 5553 5581 break; … … 5556 5584 5557 5585 /* Line 1806 of yacc.c */ 5558 #line 62 3"parser.yy"5586 #line 626 "parser.yy" 5559 5587 { (yyval.op) = OperKinds::PlusAssn; } 5560 5588 break; … … 5563 5591 5564 5592 /* Line 1806 of yacc.c */ 5565 #line 62 4"parser.yy"5593 #line 627 "parser.yy" 5566 5594 { (yyval.op) = OperKinds::MinusAssn; } 5567 5595 break; … … 5570 5598 5571 5599 /* Line 1806 of yacc.c */ 5572 #line 62 5"parser.yy"5600 #line 628 "parser.yy" 5573 5601 { (yyval.op) = OperKinds::LSAssn; } 5574 5602 break; … … 5577 5605 5578 5606 /* Line 1806 of yacc.c */ 5579 #line 62 6"parser.yy"5607 #line 629 "parser.yy" 5580 5608 { (yyval.op) = OperKinds::RSAssn; } 5581 5609 break; … … 5584 5612 5585 5613 /* Line 1806 of yacc.c */ 5586 #line 6 27"parser.yy"5614 #line 630 "parser.yy" 5587 5615 { (yyval.op) = OperKinds::AndAssn; } 5588 5616 break; … … 5591 5619 5592 5620 /* Line 1806 of yacc.c */ 5593 #line 6 28"parser.yy"5621 #line 631 "parser.yy" 5594 5622 { (yyval.op) = OperKinds::ERAssn; } 5595 5623 break; … … 5598 5626 5599 5627 /* Line 1806 of yacc.c */ 5600 #line 6 29"parser.yy"5628 #line 632 "parser.yy" 5601 5629 { (yyval.op) = OperKinds::OrAssn; } 5602 5630 break; … … 5605 5633 5606 5634 /* Line 1806 of yacc.c */ 5607 #line 63 6"parser.yy"5635 #line 639 "parser.yy" 5608 5636 { (yyval.en) = new ExpressionNode( build_tuple() ); } 5609 5637 break; … … 5612 5640 5613 5641 /* Line 1806 of yacc.c */ 5614 #line 6 38"parser.yy"5642 #line 641 "parser.yy" 5615 5643 { (yyval.en) = new ExpressionNode( build_tuple( (yyvsp[(3) - (5)].en) ) ); } 5616 5644 break; … … 5619 5647 5620 5648 /* Line 1806 of yacc.c */ 5621 #line 64 0"parser.yy"5649 #line 643 "parser.yy" 5622 5650 { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( (yyvsp[(4) - (6)].en) ) ) ); } 5623 5651 break; … … 5626 5654 5627 5655 /* Line 1806 of yacc.c */ 5628 #line 64 2"parser.yy"5656 #line 645 "parser.yy" 5629 5657 { (yyval.en) = new ExpressionNode( build_tuple( (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_last( (yyvsp[(5) - (7)].en) ) ) ); } 5630 5658 break; … … 5633 5661 5634 5662 /* Line 1806 of yacc.c */ 5635 #line 6 48"parser.yy"5663 #line 651 "parser.yy" 5636 5664 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 5637 5665 break; … … 5640 5668 5641 5669 /* Line 1806 of yacc.c */ 5642 #line 65 4"parser.yy"5670 #line 657 "parser.yy" 5643 5671 { (yyval.en) = new ExpressionNode( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5644 5672 break; … … 5647 5675 5648 5676 /* Line 1806 of yacc.c */ 5649 #line 6 59"parser.yy"5677 #line 662 "parser.yy" 5650 5678 { (yyval.en) = 0; } 5651 5679 break; … … 5654 5682 5655 5683 /* Line 1806 of yacc.c */ 5656 #line 6 68"parser.yy"5684 #line 671 "parser.yy" 5657 5685 { (yyval.sn) = (yyvsp[(1) - (1)].sn); } 5658 5686 break; … … 5661 5689 5662 5690 /* Line 1806 of yacc.c */ 5663 #line 67 5"parser.yy"5691 #line 678 "parser.yy" 5664 5692 { 5665 5693 Token fn; … … 5672 5700 5673 5701 /* Line 1806 of yacc.c */ 5674 #line 68 5"parser.yy"5702 #line 688 "parser.yy" 5675 5703 { 5676 5704 (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) ); … … 5681 5709 5682 5710 /* Line 1806 of yacc.c */ 5683 #line 69 2"parser.yy"5711 #line 695 "parser.yy" 5684 5712 { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); } 5685 5713 break; … … 5688 5716 5689 5717 /* Line 1806 of yacc.c */ 5690 #line 699"parser.yy"5718 #line 702 "parser.yy" 5691 5719 { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); } 5692 5720 break; … … 5695 5723 5696 5724 /* Line 1806 of yacc.c */ 5697 #line 70 5"parser.yy"5725 #line 708 "parser.yy" 5698 5726 { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } } 5699 5727 break; … … 5702 5730 5703 5731 /* Line 1806 of yacc.c */ 5704 #line 71 0"parser.yy"5732 #line 713 "parser.yy" 5705 5733 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5706 5734 break; … … 5709 5737 5710 5738 /* Line 1806 of yacc.c */ 5711 #line 71 2"parser.yy"5739 #line 715 "parser.yy" 5712 5740 { // mark all fields in list 5713 5741 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 5720 5748 5721 5749 /* Line 1806 of yacc.c */ 5722 #line 7 18"parser.yy"5750 #line 721 "parser.yy" 5723 5751 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5724 5752 break; … … 5727 5755 5728 5756 /* Line 1806 of yacc.c */ 5729 #line 72 5"parser.yy"5757 #line 728 "parser.yy" 5730 5758 { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } } 5731 5759 break; … … 5734 5762 5735 5763 /* Line 1806 of yacc.c */ 5736 #line 73 0"parser.yy"5764 #line 733 "parser.yy" 5737 5765 { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); } 5738 5766 break; … … 5741 5769 5742 5770 /* Line 1806 of yacc.c */ 5743 #line 73 6"parser.yy"5771 #line 739 "parser.yy" 5744 5772 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); } 5745 5773 break; … … 5748 5776 5749 5777 /* Line 1806 of yacc.c */ 5750 #line 7 38"parser.yy"5778 #line 741 "parser.yy" 5751 5779 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); } 5752 5780 break; … … 5755 5783 5756 5784 /* Line 1806 of yacc.c */ 5757 #line 74 0"parser.yy"5785 #line 743 "parser.yy" 5758 5786 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5759 5787 break; … … 5762 5790 5763 5791 /* Line 1806 of yacc.c */ 5764 #line 74 2"parser.yy"5792 #line 745 "parser.yy" 5765 5793 { 5766 5794 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); … … 5777 5805 5778 5806 /* Line 1806 of yacc.c */ 5779 #line 75 2"parser.yy"5807 #line 755 "parser.yy" 5780 5808 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5781 5809 break; … … 5784 5812 5785 5813 /* Line 1806 of yacc.c */ 5786 #line 75 4"parser.yy"5814 #line 757 "parser.yy" 5787 5815 { 5788 5816 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); … … 5794 5822 5795 5823 /* Line 1806 of yacc.c */ 5796 #line 76 4"parser.yy"5824 #line 767 "parser.yy" 5797 5825 { (yyval.en) = (yyvsp[(1) - (1)].en); } 5798 5826 break; … … 5801 5829 5802 5830 /* Line 1806 of yacc.c */ 5803 #line 76 6"parser.yy"5831 #line 769 "parser.yy" 5804 5832 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5805 5833 break; … … 5808 5836 5809 5837 /* Line 1806 of yacc.c */ 5810 #line 77 1"parser.yy"5838 #line 774 "parser.yy" 5811 5839 { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); } 5812 5840 break; … … 5815 5843 5816 5844 /* Line 1806 of yacc.c */ 5817 #line 77 3"parser.yy"5845 #line 776 "parser.yy" 5818 5846 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); } 5819 5847 break; … … 5822 5850 5823 5851 /* Line 1806 of yacc.c */ 5824 #line 7 77"parser.yy"5852 #line 780 "parser.yy" 5825 5853 { (yyval.sn) = (yyvsp[(2) - (3)].sn); } 5826 5854 break; … … 5829 5857 5830 5858 /* Line 1806 of yacc.c */ 5831 #line 7 78"parser.yy"5859 #line 781 "parser.yy" 5832 5860 { (yyval.sn) = new StatementNode( build_default() ); } 5833 5861 break; … … 5836 5864 5837 5865 /* Line 1806 of yacc.c */ 5838 #line 78 4"parser.yy"5866 #line 787 "parser.yy" 5839 5867 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_last( (yyvsp[(2) - (2)].sn) )); } 5840 5868 break; … … 5843 5871 5844 5872 /* Line 1806 of yacc.c */ 5845 #line 7 88"parser.yy"5873 #line 791 "parser.yy" 5846 5874 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5847 5875 break; … … 5850 5878 5851 5879 /* Line 1806 of yacc.c */ 5852 #line 79 3"parser.yy"5880 #line 796 "parser.yy" 5853 5881 { (yyval.sn) = 0; } 5854 5882 break; … … 5857 5885 5858 5886 /* Line 1806 of yacc.c */ 5859 #line 799"parser.yy"5887 #line 802 "parser.yy" 5860 5888 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5861 5889 break; … … 5864 5892 5865 5893 /* Line 1806 of yacc.c */ 5866 #line 80 1"parser.yy"5894 #line 804 "parser.yy" 5867 5895 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); } 5868 5896 break; … … 5871 5899 5872 5900 /* Line 1806 of yacc.c */ 5873 #line 80 6"parser.yy"5901 #line 809 "parser.yy" 5874 5902 { (yyval.sn) = 0; } 5875 5903 break; … … 5878 5906 5879 5907 /* Line 1806 of yacc.c */ 5880 #line 81 2"parser.yy"5908 #line 815 "parser.yy" 5881 5909 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); } 5882 5910 break; … … 5885 5913 5886 5914 /* Line 1806 of yacc.c */ 5887 #line 81 4"parser.yy"5915 #line 817 "parser.yy" 5888 5916 { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); } 5889 5917 break; … … 5892 5920 5893 5921 /* Line 1806 of yacc.c */ 5894 #line 81 6"parser.yy"5922 #line 819 "parser.yy" 5895 5923 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); } 5896 5924 break; … … 5899 5927 5900 5928 /* Line 1806 of yacc.c */ 5901 #line 8 18"parser.yy"5929 #line 821 "parser.yy" 5902 5930 { (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) ) ) ) ) ) ); } 5903 5931 break; … … 5906 5934 5907 5935 /* Line 1806 of yacc.c */ 5908 #line 82 3"parser.yy"5936 #line 826 "parser.yy" 5909 5937 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); } 5910 5938 break; … … 5913 5941 5914 5942 /* Line 1806 of yacc.c */ 5915 #line 8 29"parser.yy"5943 #line 832 "parser.yy" 5916 5944 { (yyval.sn) = 0; } 5917 5945 break; … … 5920 5948 5921 5949 /* Line 1806 of yacc.c */ 5922 #line 83 1"parser.yy"5950 #line 834 "parser.yy" 5923 5951 { (yyval.sn) = 0; } 5924 5952 break; … … 5927 5955 5928 5956 /* Line 1806 of yacc.c */ 5929 #line 83 6"parser.yy"5957 #line 839 "parser.yy" 5930 5958 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5931 5959 break; … … 5934 5962 5935 5963 /* Line 1806 of yacc.c */ 5936 #line 8 38"parser.yy"5964 #line 841 "parser.yy" 5937 5965 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn), true ) ); } 5938 5966 break; … … 5941 5969 5942 5970 /* Line 1806 of yacc.c */ 5943 #line 84 0"parser.yy"5971 #line 843 "parser.yy" 5944 5972 { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); } 5945 5973 break; … … 5948 5976 5949 5977 /* Line 1806 of yacc.c */ 5950 #line 84 5"parser.yy"5978 #line 848 "parser.yy" 5951 5979 { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); } 5952 5980 break; … … 5955 5983 5956 5984 /* Line 1806 of yacc.c */ 5957 #line 8 47"parser.yy"5985 #line 850 "parser.yy" 5958 5986 { (yyval.fctl) = new ForCtl( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); } 5959 5987 break; … … 5962 5990 5963 5991 /* Line 1806 of yacc.c */ 5964 #line 85 2"parser.yy"5992 #line 855 "parser.yy" 5965 5993 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); } 5966 5994 break; … … 5969 5997 5970 5998 /* Line 1806 of yacc.c */ 5971 #line 85 6"parser.yy"5999 #line 859 "parser.yy" 5972 6000 { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); } 5973 6001 break; … … 5976 6004 5977 6005 /* Line 1806 of yacc.c */ 5978 #line 8 59"parser.yy"6006 #line 862 "parser.yy" 5979 6007 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Continue ) ); } 5980 6008 break; … … 5983 6011 5984 6012 /* Line 1806 of yacc.c */ 5985 #line 86 3"parser.yy"6013 #line 866 "parser.yy" 5986 6014 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); } 5987 6015 break; … … 5990 6018 5991 6019 /* Line 1806 of yacc.c */ 5992 #line 86 6"parser.yy"6020 #line 869 "parser.yy" 5993 6021 { (yyval.sn) = new StatementNode( build_branch( BranchStmt::Break ) ); } 5994 6022 break; … … 5997 6025 5998 6026 /* Line 1806 of yacc.c */ 5999 #line 87 0"parser.yy"6027 #line 873 "parser.yy" 6000 6028 { (yyval.sn) = new StatementNode( build_branch( (yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); } 6001 6029 break; … … 6004 6032 6005 6033 /* Line 1806 of yacc.c */ 6006 #line 87 2"parser.yy"6034 #line 875 "parser.yy" 6007 6035 { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); } 6008 6036 break; … … 6011 6039 6012 6040 /* Line 1806 of yacc.c */ 6013 #line 87 4"parser.yy"6041 #line 877 "parser.yy" 6014 6042 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 6015 6043 break; … … 6018 6046 6019 6047 /* Line 1806 of yacc.c */ 6020 #line 87 6"parser.yy"6048 #line 879 "parser.yy" 6021 6049 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 6022 6050 break; … … 6025 6053 6026 6054 /* Line 1806 of yacc.c */ 6027 #line 8 78"parser.yy"6055 #line 881 "parser.yy" 6028 6056 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); } 6029 6057 break; … … 6032 6060 6033 6061 /* Line 1806 of yacc.c */ 6034 #line 88 3"parser.yy"6062 #line 886 "parser.yy" 6035 6063 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); } 6036 6064 break; … … 6039 6067 6040 6068 /* Line 1806 of yacc.c */ 6041 #line 88 5"parser.yy"6069 #line 888 "parser.yy" 6042 6070 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); } 6043 6071 break; … … 6046 6074 6047 6075 /* Line 1806 of yacc.c */ 6048 #line 8 87"parser.yy"6076 #line 890 "parser.yy" 6049 6077 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); } 6050 6078 break; … … 6053 6081 6054 6082 /* Line 1806 of yacc.c */ 6055 #line 89 4"parser.yy"6083 #line 897 "parser.yy" 6056 6084 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 6057 6085 break; … … 6060 6088 6061 6089 /* Line 1806 of yacc.c */ 6062 #line 89 6"parser.yy"6090 #line 899 "parser.yy" 6063 6091 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 6064 6092 break; … … 6067 6095 6068 6096 /* Line 1806 of yacc.c */ 6069 #line 898"parser.yy"6097 #line 901 "parser.yy" 6070 6098 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 6071 6099 break; … … 6074 6102 6075 6103 /* Line 1806 of yacc.c */ 6076 #line 90 0"parser.yy"6104 #line 903 "parser.yy" 6077 6105 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 6078 6106 break; … … 6081 6109 6082 6110 /* Line 1806 of yacc.c */ 6083 #line 90 5"parser.yy"6111 #line 908 "parser.yy" 6084 6112 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 6085 6113 break; … … 6088 6116 6089 6117 /* Line 1806 of yacc.c */ 6090 #line 9 07"parser.yy"6118 #line 910 "parser.yy" 6091 6119 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 6092 6120 break; … … 6095 6123 6096 6124 /* Line 1806 of yacc.c */ 6097 #line 9 09"parser.yy"6125 #line 912 "parser.yy" 6098 6126 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 6099 6127 break; … … 6102 6130 6103 6131 /* Line 1806 of yacc.c */ 6104 #line 91 1"parser.yy"6132 #line 914 "parser.yy" 6105 6133 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 6106 6134 break; … … 6109 6137 6110 6138 /* Line 1806 of yacc.c */ 6111 #line 91 6"parser.yy"6139 #line 919 "parser.yy" 6112 6140 { 6113 6141 (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) ); … … 6118 6146 6119 6147 /* Line 1806 of yacc.c */ 6120 #line 9 29"parser.yy"6148 #line 932 "parser.yy" 6121 6149 { 6122 6150 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6128 6156 6129 6157 /* Line 1806 of yacc.c */ 6130 #line 93 4"parser.yy"6158 #line 937 "parser.yy" 6131 6159 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 6132 6160 break; … … 6135 6163 6136 6164 /* Line 1806 of yacc.c */ 6137 #line 93 6"parser.yy"6165 #line 939 "parser.yy" 6138 6166 { 6139 6167 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6145 6173 6146 6174 /* Line 1806 of yacc.c */ 6147 #line 94 5"parser.yy"6175 #line 948 "parser.yy" 6148 6176 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); } 6149 6177 break; … … 6152 6180 6153 6181 /* Line 1806 of yacc.c */ 6154 #line 9 47"parser.yy"6182 #line 950 "parser.yy" 6155 6183 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); } 6156 6184 break; … … 6159 6187 6160 6188 /* Line 1806 of yacc.c */ 6161 #line 9 49"parser.yy"6189 #line 952 "parser.yy" 6162 6190 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); } 6163 6191 break; … … 6166 6194 6167 6195 /* Line 1806 of yacc.c */ 6168 #line 95 1"parser.yy"6196 #line 954 "parser.yy" 6169 6197 { (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) ) ); } 6170 6198 break; … … 6173 6201 6174 6202 /* Line 1806 of yacc.c */ 6175 #line 95 3"parser.yy"6203 #line 956 "parser.yy" 6176 6204 { (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) ) ); } 6177 6205 break; … … 6180 6208 6181 6209 /* Line 1806 of yacc.c */ 6182 #line 9 58"parser.yy"6210 #line 961 "parser.yy" 6183 6211 { (yyval.flag) = false; } 6184 6212 break; … … 6187 6215 6188 6216 /* Line 1806 of yacc.c */ 6189 #line 96 0"parser.yy"6217 #line 963 "parser.yy" 6190 6218 { (yyval.flag) = true; } 6191 6219 break; … … 6194 6222 6195 6223 /* Line 1806 of yacc.c */ 6196 #line 96 5"parser.yy"6224 #line 968 "parser.yy" 6197 6225 { (yyval.en) = 0; } 6198 6226 break; … … 6201 6229 6202 6230 /* Line 1806 of yacc.c */ 6203 #line 97 2"parser.yy"6231 #line 975 "parser.yy" 6204 6232 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) ); } 6205 6233 break; … … 6208 6236 6209 6237 /* Line 1806 of yacc.c */ 6210 #line 9 77"parser.yy"6238 #line 980 "parser.yy" 6211 6239 { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); } 6212 6240 break; … … 6215 6243 6216 6244 /* Line 1806 of yacc.c */ 6217 #line 9 79"parser.yy"6245 #line 982 "parser.yy" 6218 6246 { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); } 6219 6247 break; … … 6222 6250 6223 6251 /* Line 1806 of yacc.c */ 6224 #line 98 4"parser.yy"6252 #line 987 "parser.yy" 6225 6253 { (yyval.en) = 0; } 6226 6254 break; … … 6229 6257 6230 6258 /* Line 1806 of yacc.c */ 6231 #line 98 6"parser.yy"6259 #line 989 "parser.yy" 6232 6260 { (yyval.en) = new ExpressionNode( (yyvsp[(1) - (1)].constant) ); } 6233 6261 break; … … 6236 6264 6237 6265 /* Line 1806 of yacc.c */ 6238 #line 9 88"parser.yy"6266 #line 991 "parser.yy" 6239 6267 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( (yyvsp[(3) - (3)].constant) ) ); } 6240 6268 break; … … 6243 6271 6244 6272 /* Line 1806 of yacc.c */ 6245 #line 99 3"parser.yy"6273 #line 996 "parser.yy" 6246 6274 { 6247 6275 (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) ); … … 6253 6281 6254 6282 /* Line 1806 of yacc.c */ 6255 #line 998"parser.yy"6283 #line 1001 "parser.yy" 6256 6284 { 6257 6285 (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) ); … … 6263 6291 6264 6292 /* Line 1806 of yacc.c */ 6265 #line 10 08"parser.yy"6293 #line 1011 "parser.yy" 6266 6294 { (yyval.decl) = 0; } 6267 6295 break; … … 6270 6298 6271 6299 /* Line 1806 of yacc.c */ 6272 #line 101 5"parser.yy"6300 #line 1018 "parser.yy" 6273 6301 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6274 6302 break; … … 6277 6305 6278 6306 /* Line 1806 of yacc.c */ 6279 #line 102 0"parser.yy"6307 #line 1023 "parser.yy" 6280 6308 { (yyval.decl) = 0; } 6281 6309 break; … … 6284 6312 6285 6313 /* Line 1806 of yacc.c */ 6286 #line 10 27"parser.yy"6314 #line 1030 "parser.yy" 6287 6315 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6288 6316 break; … … 6291 6319 6292 6320 /* Line 1806 of yacc.c */ 6293 #line 104 1"parser.yy"6321 #line 1044 "parser.yy" 6294 6322 {} 6295 6323 break; … … 6298 6326 6299 6327 /* Line 1806 of yacc.c */ 6300 #line 104 2"parser.yy"6328 #line 1045 "parser.yy" 6301 6329 {} 6302 6330 break; … … 6305 6333 6306 6334 /* Line 1806 of yacc.c */ 6307 #line 107 1"parser.yy"6335 #line 1074 "parser.yy" 6308 6336 { 6309 6337 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6315 6343 6316 6344 /* Line 1806 of yacc.c */ 6317 #line 10 78"parser.yy"6345 #line 1081 "parser.yy" 6318 6346 { 6319 6347 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6325 6353 6326 6354 /* Line 1806 of yacc.c */ 6327 #line 108 3"parser.yy"6355 #line 1086 "parser.yy" 6328 6356 { 6329 6357 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID ); … … 6335 6363 6336 6364 /* Line 1806 of yacc.c */ 6337 #line 109 3"parser.yy"6365 #line 1096 "parser.yy" 6338 6366 { 6339 6367 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6345 6373 6346 6374 /* Line 1806 of yacc.c */ 6347 #line 1 098"parser.yy"6375 #line 1101 "parser.yy" 6348 6376 { 6349 6377 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6355 6383 6356 6384 /* Line 1806 of yacc.c */ 6357 #line 110 3"parser.yy"6385 #line 1106 "parser.yy" 6358 6386 { 6359 6387 typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) ); … … 6365 6393 6366 6394 /* Line 1806 of yacc.c */ 6367 #line 111 1"parser.yy"6395 #line 1114 "parser.yy" 6368 6396 { 6369 6397 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6375 6403 6376 6404 /* Line 1806 of yacc.c */ 6377 #line 111 6"parser.yy"6405 #line 1119 "parser.yy" 6378 6406 { 6379 6407 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6385 6413 6386 6414 /* Line 1806 of yacc.c */ 6387 #line 112 1"parser.yy"6415 #line 1124 "parser.yy" 6388 6416 { 6389 6417 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6395 6423 6396 6424 /* Line 1806 of yacc.c */ 6397 #line 112 6"parser.yy"6425 #line 1129 "parser.yy" 6398 6426 { 6399 6427 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6405 6433 6406 6434 /* Line 1806 of yacc.c */ 6407 #line 113 1"parser.yy"6435 #line 1134 "parser.yy" 6408 6436 { 6409 6437 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 6415 6443 6416 6444 /* Line 1806 of yacc.c */ 6417 #line 11 39"parser.yy"6445 #line 1142 "parser.yy" 6418 6446 { 6419 6447 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(3) - (8)].tok), DeclarationNode::newTuple( 0 ), (yyvsp[(6) - (8)].decl), 0, true ); … … 6424 6452 6425 6453 /* Line 1806 of yacc.c */ 6426 #line 116 2"parser.yy"6454 #line 1165 "parser.yy" 6427 6455 { 6428 6456 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6433 6461 6434 6462 /* Line 1806 of yacc.c */ 6435 #line 116 6"parser.yy"6463 #line 1169 "parser.yy" 6436 6464 { 6437 6465 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6442 6470 6443 6471 /* Line 1806 of yacc.c */ 6444 #line 117 3"parser.yy"6472 #line 1176 "parser.yy" 6445 6473 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 6446 6474 break; … … 6449 6477 6450 6478 /* Line 1806 of yacc.c */ 6451 #line 11 77"parser.yy"6479 #line 1180 "parser.yy" 6452 6480 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); } 6453 6481 break; … … 6456 6484 6457 6485 /* Line 1806 of yacc.c */ 6458 #line 118 2"parser.yy"6486 #line 1185 "parser.yy" 6459 6487 { 6460 6488 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6466 6494 6467 6495 /* Line 1806 of yacc.c */ 6468 #line 11 87"parser.yy"6496 #line 1190 "parser.yy" 6469 6497 { 6470 6498 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6476 6504 6477 6505 /* Line 1806 of yacc.c */ 6478 #line 119 2"parser.yy"6506 #line 1195 "parser.yy" 6479 6507 { 6480 6508 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD ); … … 6486 6514 6487 6515 /* Line 1806 of yacc.c */ 6488 #line 120 3"parser.yy"6516 #line 1206 "parser.yy" 6489 6517 { 6490 6518 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6496 6524 6497 6525 /* Line 1806 of yacc.c */ 6498 #line 12 08"parser.yy"6526 #line 1211 "parser.yy" 6499 6527 { 6500 6528 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6506 6534 6507 6535 /* Line 1806 of yacc.c */ 6508 #line 121 3"parser.yy"6536 #line 1216 "parser.yy" 6509 6537 { 6510 6538 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6516 6544 6517 6545 /* Line 1806 of yacc.c */ 6518 #line 12 18"parser.yy"6546 #line 1221 "parser.yy" 6519 6547 { 6520 6548 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6526 6554 6527 6555 /* Line 1806 of yacc.c */ 6528 #line 122 3"parser.yy"6556 #line 1226 "parser.yy" 6529 6557 { 6530 6558 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6536 6564 6537 6565 /* Line 1806 of yacc.c */ 6538 #line 123 2"parser.yy"6566 #line 1235 "parser.yy" 6539 6567 { 6540 6568 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD ); … … 6546 6574 6547 6575 /* Line 1806 of yacc.c */ 6548 #line 12 37"parser.yy"6576 #line 1240 "parser.yy" 6549 6577 { 6550 6578 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD ); … … 6556 6584 6557 6585 /* Line 1806 of yacc.c */ 6558 #line 125 4"parser.yy"6586 #line 1257 "parser.yy" 6559 6587 { 6560 6588 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6566 6594 6567 6595 /* Line 1806 of yacc.c */ 6568 #line 12 59"parser.yy"6596 #line 1262 "parser.yy" 6569 6597 { 6570 6598 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6576 6604 6577 6605 /* Line 1806 of yacc.c */ 6578 #line 128 1"parser.yy"6606 #line 1284 "parser.yy" 6579 6607 { (yyval.decl) = 0; } 6580 6608 break; … … 6583 6611 6584 6612 /* Line 1806 of yacc.c */ 6585 #line 129 3"parser.yy"6613 #line 1296 "parser.yy" 6586 6614 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6587 6615 break; … … 6590 6618 6591 6619 /* Line 1806 of yacc.c */ 6592 #line 130 4"parser.yy"6620 #line 1307 "parser.yy" 6593 6621 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); } 6594 6622 break; … … 6597 6625 6598 6626 /* Line 1806 of yacc.c */ 6599 #line 130 6"parser.yy"6627 #line 1309 "parser.yy" 6600 6628 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); } 6601 6629 break; … … 6604 6632 6605 6633 /* Line 1806 of yacc.c */ 6606 #line 13 08"parser.yy"6634 #line 1311 "parser.yy" 6607 6635 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); } 6608 6636 break; … … 6611 6639 6612 6640 /* Line 1806 of yacc.c */ 6613 #line 131 0"parser.yy"6641 #line 1313 "parser.yy" 6614 6642 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 6615 6643 break; … … 6618 6646 6619 6647 /* Line 1806 of yacc.c */ 6620 #line 131 2"parser.yy"6648 #line 1315 "parser.yy" 6621 6649 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); } 6622 6650 break; … … 6625 6653 6626 6654 /* Line 1806 of yacc.c */ 6627 #line 131 4"parser.yy"6655 #line 1317 "parser.yy" 6628 6656 { 6629 6657 typedefTable.enterScope(); … … 6634 6662 6635 6663 /* Line 1806 of yacc.c */ 6636 #line 13 18"parser.yy"6664 #line 1321 "parser.yy" 6637 6665 { 6638 6666 typedefTable.leaveScope(); … … 6644 6672 6645 6673 /* Line 1806 of yacc.c */ 6646 #line 13 27"parser.yy"6674 #line 1330 "parser.yy" 6647 6675 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6648 6676 break; … … 6651 6679 6652 6680 /* Line 1806 of yacc.c */ 6653 #line 13 29"parser.yy"6681 #line 1332 "parser.yy" 6654 6682 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6655 6683 break; … … 6658 6686 6659 6687 /* Line 1806 of yacc.c */ 6660 #line 134 0"parser.yy"6688 #line 1343 "parser.yy" 6661 6689 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6662 6690 break; … … 6665 6693 6666 6694 /* Line 1806 of yacc.c */ 6667 #line 134 5"parser.yy"6695 #line 1348 "parser.yy" 6668 6696 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } 6669 6697 break; … … 6672 6700 6673 6701 /* Line 1806 of yacc.c */ 6674 #line 13 47"parser.yy"6702 #line 1350 "parser.yy" 6675 6703 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); } 6676 6704 break; … … 6679 6707 6680 6708 /* Line 1806 of yacc.c */ 6681 #line 13 49"parser.yy"6709 #line 1352 "parser.yy" 6682 6710 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); } 6683 6711 break; … … 6686 6714 6687 6715 /* Line 1806 of yacc.c */ 6688 #line 135 1"parser.yy"6716 #line 1354 "parser.yy" 6689 6717 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 6690 6718 break; … … 6693 6721 6694 6722 /* Line 1806 of yacc.c */ 6695 #line 135 4"parser.yy"6723 #line 1357 "parser.yy" 6696 6724 { (yyval.decl) = new DeclarationNode; (yyval.decl)->isInline = true; } 6697 6725 break; … … 6700 6728 6701 6729 /* Line 1806 of yacc.c */ 6702 #line 135 6"parser.yy"6730 #line 1359 "parser.yy" 6703 6731 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 6704 6732 break; … … 6707 6735 6708 6736 /* Line 1806 of yacc.c */ 6709 #line 13 59"parser.yy"6737 #line 1362 "parser.yy" 6710 6738 { (yyval.decl) = new DeclarationNode; (yyval.decl)->isNoreturn = true; } 6711 6739 break; … … 6714 6742 6715 6743 /* Line 1806 of yacc.c */ 6716 #line 136 1"parser.yy"6744 #line 1364 "parser.yy" 6717 6745 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 6718 6746 break; … … 6721 6749 6722 6750 /* Line 1806 of yacc.c */ 6723 #line 136 6"parser.yy"6751 #line 1369 "parser.yy" 6724 6752 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); } 6725 6753 break; … … 6728 6756 6729 6757 /* Line 1806 of yacc.c */ 6730 #line 13 68"parser.yy"6758 #line 1371 "parser.yy" 6731 6759 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); } 6732 6760 break; … … 6735 6763 6736 6764 /* Line 1806 of yacc.c */ 6737 #line 137 0"parser.yy"6765 #line 1373 "parser.yy" 6738 6766 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); } 6739 6767 break; … … 6742 6770 6743 6771 /* Line 1806 of yacc.c */ 6744 #line 137 2"parser.yy"6772 #line 1375 "parser.yy" 6745 6773 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); } 6746 6774 break; … … 6749 6777 6750 6778 /* Line 1806 of yacc.c */ 6751 #line 137 4"parser.yy"6779 #line 1377 "parser.yy" 6752 6780 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Long ); } 6753 6781 break; … … 6756 6784 6757 6785 /* Line 1806 of yacc.c */ 6758 #line 137 6"parser.yy"6786 #line 1379 "parser.yy" 6759 6787 { (yyval.decl) = DeclarationNode::newLength( DeclarationNode::Short ); } 6760 6788 break; … … 6763 6791 6764 6792 /* Line 1806 of yacc.c */ 6765 #line 13 78"parser.yy"6793 #line 1381 "parser.yy" 6766 6794 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Signed ); } 6767 6795 break; … … 6770 6798 6771 6799 /* Line 1806 of yacc.c */ 6772 #line 138 0"parser.yy"6800 #line 1383 "parser.yy" 6773 6801 { (yyval.decl) = DeclarationNode::newSignedNess( DeclarationNode::Unsigned ); } 6774 6802 break; … … 6777 6805 6778 6806 /* Line 1806 of yacc.c */ 6779 #line 138 2"parser.yy"6807 #line 1385 "parser.yy" 6780 6808 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); } 6781 6809 break; … … 6784 6812 6785 6813 /* Line 1806 of yacc.c */ 6786 #line 138 4"parser.yy"6814 #line 1387 "parser.yy" 6787 6815 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 6788 6816 break; … … 6791 6819 6792 6820 /* Line 1806 of yacc.c */ 6793 #line 138 6"parser.yy"6821 #line 1389 "parser.yy" 6794 6822 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Complex ); } 6795 6823 break; … … 6798 6826 6799 6827 /* Line 1806 of yacc.c */ 6800 #line 13 88"parser.yy"6828 #line 1391 "parser.yy" 6801 6829 { (yyval.decl) = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 6802 6830 break; … … 6805 6833 6806 6834 /* Line 1806 of yacc.c */ 6807 #line 139 0"parser.yy"6835 #line 1393 "parser.yy" 6808 6836 { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 6809 6837 break; … … 6812 6840 6813 6841 /* Line 1806 of yacc.c */ 6814 #line 1 397"parser.yy"6842 #line 1400 "parser.yy" 6815 6843 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6816 6844 break; … … 6819 6847 6820 6848 /* Line 1806 of yacc.c */ 6821 #line 1 399"parser.yy"6849 #line 1402 "parser.yy" 6822 6850 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6823 6851 break; … … 6826 6854 6827 6855 /* Line 1806 of yacc.c */ 6828 #line 140 1"parser.yy"6856 #line 1404 "parser.yy" 6829 6857 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6830 6858 break; … … 6833 6861 6834 6862 /* Line 1806 of yacc.c */ 6835 #line 140 3"parser.yy"6863 #line 1406 "parser.yy" 6836 6864 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); } 6837 6865 break; … … 6840 6868 6841 6869 /* Line 1806 of yacc.c */ 6842 #line 14 09"parser.yy"6870 #line 1412 "parser.yy" 6843 6871 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6844 6872 break; … … 6847 6875 6848 6876 /* Line 1806 of yacc.c */ 6849 #line 141 6"parser.yy"6877 #line 1419 "parser.yy" 6850 6878 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6851 6879 break; … … 6854 6882 6855 6883 /* Line 1806 of yacc.c */ 6856 #line 14 18"parser.yy"6884 #line 1421 "parser.yy" 6857 6885 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6858 6886 break; … … 6861 6889 6862 6890 /* Line 1806 of yacc.c */ 6863 #line 142 0"parser.yy"6891 #line 1423 "parser.yy" 6864 6892 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); } 6865 6893 break; … … 6868 6896 6869 6897 /* Line 1806 of yacc.c */ 6870 #line 142 5"parser.yy"6898 #line 1428 "parser.yy" 6871 6899 { (yyval.decl) = (yyvsp[(3) - (4)].decl); } 6872 6900 break; … … 6875 6903 6876 6904 /* Line 1806 of yacc.c */ 6877 #line 14 27"parser.yy"6905 #line 1430 "parser.yy" 6878 6906 { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); } 6879 6907 break; … … 6882 6910 6883 6911 /* Line 1806 of yacc.c */ 6884 #line 14 29"parser.yy"6912 #line 1432 "parser.yy" 6885 6913 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); } 6886 6914 break; … … 6889 6917 6890 6918 /* Line 1806 of yacc.c */ 6891 #line 143 1"parser.yy"6919 #line 1434 "parser.yy" 6892 6920 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 6893 6921 break; … … 6896 6924 6897 6925 /* Line 1806 of yacc.c */ 6898 #line 14 37"parser.yy"6926 #line 1440 "parser.yy" 6899 6927 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6900 6928 break; … … 6903 6931 6904 6932 /* Line 1806 of yacc.c */ 6905 #line 14 39"parser.yy"6933 #line 1442 "parser.yy" 6906 6934 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6907 6935 break; … … 6910 6938 6911 6939 /* Line 1806 of yacc.c */ 6912 #line 144 1"parser.yy"6940 #line 1444 "parser.yy" 6913 6941 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6914 6942 break; … … 6917 6945 6918 6946 /* Line 1806 of yacc.c */ 6919 #line 14 47"parser.yy"6947 #line 1450 "parser.yy" 6920 6948 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6921 6949 break; … … 6924 6952 6925 6953 /* Line 1806 of yacc.c */ 6926 #line 14 49"parser.yy"6954 #line 1452 "parser.yy" 6927 6955 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6928 6956 break; … … 6931 6959 6932 6960 /* Line 1806 of yacc.c */ 6933 #line 145 5"parser.yy"6961 #line 1458 "parser.yy" 6934 6962 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6935 6963 break; … … 6938 6966 6939 6967 /* Line 1806 of yacc.c */ 6940 #line 14 57"parser.yy"6968 #line 1460 "parser.yy" 6941 6969 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6942 6970 break; … … 6945 6973 6946 6974 /* Line 1806 of yacc.c */ 6947 #line 14 59"parser.yy"6975 #line 1462 "parser.yy" 6948 6976 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6949 6977 break; … … 6952 6980 6953 6981 /* Line 1806 of yacc.c */ 6954 #line 146 4"parser.yy"6982 #line 1467 "parser.yy" 6955 6983 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); } 6956 6984 break; … … 6959 6987 6960 6988 /* Line 1806 of yacc.c */ 6961 #line 146 6"parser.yy"6989 #line 1469 "parser.yy" 6962 6990 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 6963 6991 break; … … 6966 6994 6967 6995 /* Line 1806 of yacc.c */ 6968 #line 14 68"parser.yy"6996 #line 1471 "parser.yy" 6969 6997 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6970 6998 break; … … 6973 7001 6974 7002 /* Line 1806 of yacc.c */ 6975 #line 14 78"parser.yy"7003 #line 1481 "parser.yy" 6976 7004 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), nullptr, nullptr, (yyvsp[(3) - (4)].decl), true ); } 6977 7005 break; … … 6980 7008 6981 7009 /* Line 1806 of yacc.c */ 6982 #line 148 0"parser.yy"7010 #line 1483 "parser.yy" 6983 7011 { 6984 7012 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 6990 7018 6991 7019 /* Line 1806 of yacc.c */ 6992 #line 148 5"parser.yy"7020 #line 1488 "parser.yy" 6993 7021 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 6994 7022 break; … … 6997 7025 6998 7026 /* Line 1806 of yacc.c */ 6999 #line 14 87"parser.yy"7027 #line 1490 "parser.yy" 7000 7028 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), nullptr, (yyvsp[(5) - (6)].decl), true ); } 7001 7029 break; … … 7004 7032 7005 7033 /* Line 1806 of yacc.c */ 7006 #line 14 89"parser.yy"7034 #line 1492 "parser.yy" 7007 7035 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), nullptr, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); } 7008 7036 break; … … 7011 7039 7012 7040 /* Line 1806 of yacc.c */ 7013 #line 149 1"parser.yy"7041 #line 1494 "parser.yy" 7014 7042 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 7015 7043 break; … … 7018 7046 7019 7047 /* Line 1806 of yacc.c */ 7020 #line 149 6"parser.yy"7048 #line 1499 "parser.yy" 7021 7049 { (yyval.aggKey) = DeclarationNode::Struct; } 7022 7050 break; … … 7025 7053 7026 7054 /* Line 1806 of yacc.c */ 7027 #line 1 498"parser.yy"7055 #line 1501 "parser.yy" 7028 7056 { (yyval.aggKey) = DeclarationNode::Union; } 7029 7057 break; … … 7032 7060 7033 7061 /* Line 1806 of yacc.c */ 7034 #line 150 3"parser.yy"7062 #line 1506 "parser.yy" 7035 7063 { (yyval.decl) = 0; } 7036 7064 break; … … 7039 7067 7040 7068 /* Line 1806 of yacc.c */ 7041 #line 150 5"parser.yy"7069 #line 1508 "parser.yy" 7042 7070 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 7043 7071 break; … … 7046 7074 7047 7075 /* Line 1806 of yacc.c */ 7048 #line 151 1"parser.yy"7076 #line 1514 "parser.yy" 7049 7077 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); } 7050 7078 break; … … 7053 7081 7054 7082 /* Line 1806 of yacc.c */ 7055 #line 151 4"parser.yy"7083 #line 1517 "parser.yy" 7056 7084 { // mark all fields in list 7057 7085 for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 7064 7092 7065 7093 /* Line 1806 of yacc.c */ 7066 #line 152 4"parser.yy"7094 #line 1527 "parser.yy" 7067 7095 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); } 7068 7096 break; … … 7071 7099 7072 7100 /* Line 1806 of yacc.c */ 7073 #line 152 6"parser.yy"7101 #line 1529 "parser.yy" 7074 7102 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); } 7075 7103 break; … … 7078 7106 7079 7107 /* Line 1806 of yacc.c */ 7080 #line 15 28"parser.yy"7108 #line 1531 "parser.yy" 7081 7109 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); } 7082 7110 break; … … 7085 7113 7086 7114 /* Line 1806 of yacc.c */ 7087 #line 153 3"parser.yy"7115 #line 1536 "parser.yy" 7088 7116 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7089 7117 break; … … 7092 7120 7093 7121 /* Line 1806 of yacc.c */ 7094 #line 153 5"parser.yy"7122 #line 1538 "parser.yy" 7095 7123 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); } 7096 7124 break; … … 7099 7127 7100 7128 /* Line 1806 of yacc.c */ 7101 #line 154 0"parser.yy"7129 #line 1543 "parser.yy" 7102 7130 { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ } 7103 7131 break; … … 7106 7134 7107 7135 /* Line 1806 of yacc.c */ 7108 #line 154 2"parser.yy"7136 #line 1545 "parser.yy" 7109 7137 { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); } 7110 7138 break; 7111 7139 7112 7140 case 388: 7113 7114 /* Line 1806 of yacc.c */7115 #line 1545 "parser.yy"7116 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); }7117 break;7118 7119 case 389:7120 7141 7121 7142 /* Line 1806 of yacc.c */ … … 7124 7145 break; 7125 7146 7147 case 389: 7148 7149 /* Line 1806 of yacc.c */ 7150 #line 1551 "parser.yy" 7151 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 7152 break; 7153 7126 7154 case 391: 7127 7155 7128 7156 /* Line 1806 of yacc.c */ 7129 #line 155 4"parser.yy"7157 #line 1557 "parser.yy" 7130 7158 { (yyval.en) = 0; } 7131 7159 break; … … 7134 7162 7135 7163 /* Line 1806 of yacc.c */ 7136 #line 155 6"parser.yy"7164 #line 1559 "parser.yy" 7137 7165 { (yyval.en) = (yyvsp[(1) - (1)].en); } 7138 7166 break; … … 7141 7169 7142 7170 /* Line 1806 of yacc.c */ 7143 #line 156 1"parser.yy"7171 #line 1564 "parser.yy" 7144 7172 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7145 7173 break; … … 7148 7176 7149 7177 /* Line 1806 of yacc.c */ 7150 #line 157 0"parser.yy"7178 #line 1573 "parser.yy" 7151 7179 { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(3) - (5)].decl) ); } 7152 7180 break; … … 7155 7183 7156 7184 /* Line 1806 of yacc.c */ 7157 #line 157 2"parser.yy"7185 #line 1575 "parser.yy" 7158 7186 { 7159 7187 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 7165 7193 7166 7194 /* Line 1806 of yacc.c */ 7167 #line 15 77"parser.yy"7195 #line 1580 "parser.yy" 7168 7196 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 7169 7197 break; … … 7172 7200 7173 7201 /* Line 1806 of yacc.c */ 7174 #line 15 79"parser.yy"7202 #line 1582 "parser.yy" 7175 7203 { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); } 7176 7204 break; … … 7179 7207 7180 7208 /* Line 1806 of yacc.c */ 7181 #line 158 4"parser.yy"7209 #line 1587 "parser.yy" 7182 7210 { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); } 7183 7211 break; … … 7186 7214 7187 7215 /* Line 1806 of yacc.c */ 7188 #line 158 6"parser.yy"7216 #line 1589 "parser.yy" 7189 7217 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); } 7190 7218 break; … … 7193 7221 7194 7222 /* Line 1806 of yacc.c */ 7195 #line 159 1"parser.yy"7223 #line 1594 "parser.yy" 7196 7224 { (yyval.en) = 0; } 7197 7225 break; … … 7200 7228 7201 7229 /* Line 1806 of yacc.c */ 7202 #line 159 3"parser.yy"7230 #line 1596 "parser.yy" 7203 7231 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7204 7232 break; … … 7207 7235 7208 7236 /* Line 1806 of yacc.c */ 7209 #line 160 0"parser.yy"7237 #line 1603 "parser.yy" 7210 7238 { (yyval.decl) = 0; } 7211 7239 break; … … 7214 7242 7215 7243 /* Line 1806 of yacc.c */ 7216 #line 16 08"parser.yy"7244 #line 1611 "parser.yy" 7217 7245 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7218 7246 break; … … 7221 7249 7222 7250 /* Line 1806 of yacc.c */ 7223 #line 161 0"parser.yy"7251 #line 1613 "parser.yy" 7224 7252 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7225 7253 break; … … 7228 7256 7229 7257 /* Line 1806 of yacc.c */ 7230 #line 161 2"parser.yy"7258 #line 1615 "parser.yy" 7231 7259 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7232 7260 break; … … 7235 7263 7236 7264 /* Line 1806 of yacc.c */ 7237 #line 162 0"parser.yy"7265 #line 1623 "parser.yy" 7238 7266 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7239 7267 break; … … 7242 7270 7243 7271 /* Line 1806 of yacc.c */ 7244 #line 162 2"parser.yy"7272 #line 1625 "parser.yy" 7245 7273 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7246 7274 break; … … 7249 7277 7250 7278 /* Line 1806 of yacc.c */ 7251 #line 162 4"parser.yy"7279 #line 1627 "parser.yy" 7252 7280 { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); } 7253 7281 break; … … 7256 7284 7257 7285 /* Line 1806 of yacc.c */ 7258 #line 163 0"parser.yy"7286 #line 1633 "parser.yy" 7259 7287 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7260 7288 break; … … 7263 7291 7264 7292 /* Line 1806 of yacc.c */ 7265 #line 163 5"parser.yy"7293 #line 1638 "parser.yy" 7266 7294 { (yyval.decl) = 0; } 7267 7295 break; … … 7270 7298 7271 7299 /* Line 1806 of yacc.c */ 7272 #line 164 2"parser.yy"7300 #line 1645 "parser.yy" 7273 7301 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7274 7302 break; … … 7277 7305 7278 7306 /* Line 1806 of yacc.c */ 7279 #line 16 49"parser.yy"7307 #line 1652 "parser.yy" 7280 7308 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7281 7309 break; … … 7284 7312 7285 7313 /* Line 1806 of yacc.c */ 7286 #line 165 1"parser.yy"7314 #line 1654 "parser.yy" 7287 7315 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7288 7316 break; 7289 7317 7290 7318 case 425: 7291 7292 /* Line 1806 of yacc.c */7293 #line 1660 "parser.yy"7294 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); }7295 break;7296 7297 case 426:7298 7319 7299 7320 /* Line 1806 of yacc.c */ … … 7302 7323 break; 7303 7324 7325 case 426: 7326 7327 /* Line 1806 of yacc.c */ 7328 #line 1666 "parser.yy" 7329 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7330 break; 7331 7304 7332 case 427: 7305 7333 7306 7334 /* Line 1806 of yacc.c */ 7307 #line 166 5"parser.yy"7335 #line 1668 "parser.yy" 7308 7336 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); } 7309 7337 break; … … 7312 7340 7313 7341 /* Line 1806 of yacc.c */ 7314 #line 167 5"parser.yy"7342 #line 1678 "parser.yy" 7315 7343 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7316 7344 break; … … 7319 7347 7320 7348 /* Line 1806 of yacc.c */ 7321 #line 168 1"parser.yy"7349 #line 1684 "parser.yy" 7322 7350 { 7323 7351 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7329 7357 7330 7358 /* Line 1806 of yacc.c */ 7331 #line 168 6"parser.yy"7359 #line 1689 "parser.yy" 7332 7360 { 7333 7361 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7339 7367 7340 7368 /* Line 1806 of yacc.c */ 7341 #line 169 5"parser.yy"7369 #line 1698 "parser.yy" 7342 7370 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7343 7371 break; … … 7346 7374 7347 7375 /* Line 1806 of yacc.c */ 7348 #line 170 4"parser.yy"7376 #line 1707 "parser.yy" 7349 7377 { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); } 7350 7378 break; … … 7353 7381 7354 7382 /* Line 1806 of yacc.c */ 7355 #line 170 6"parser.yy"7383 #line 1709 "parser.yy" 7356 7384 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); } 7357 7385 break; … … 7360 7388 7361 7389 /* Line 1806 of yacc.c */ 7362 #line 173 1"parser.yy"7390 #line 1734 "parser.yy" 7363 7391 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7364 7392 break; … … 7367 7395 7368 7396 /* Line 1806 of yacc.c */ 7369 #line 17 39"parser.yy"7397 #line 1742 "parser.yy" 7370 7398 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7371 7399 break; … … 7374 7402 7375 7403 /* Line 1806 of yacc.c */ 7376 #line 174 4"parser.yy"7404 #line 1747 "parser.yy" 7377 7405 { (yyval.in) = 0; } 7378 7406 break; … … 7381 7409 7382 7410 /* Line 1806 of yacc.c */ 7383 #line 174 6"parser.yy"7411 #line 1749 "parser.yy" 7384 7412 { (yyval.in) = (yyvsp[(2) - (2)].in); } 7385 7413 break; … … 7388 7416 7389 7417 /* Line 1806 of yacc.c */ 7390 #line 17 48"parser.yy"7418 #line 1751 "parser.yy" 7391 7419 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); } 7392 7420 break; … … 7395 7423 7396 7424 /* Line 1806 of yacc.c */ 7397 #line 175 2"parser.yy"7425 #line 1755 "parser.yy" 7398 7426 { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); } 7399 7427 break; … … 7402 7430 7403 7431 /* Line 1806 of yacc.c */ 7404 #line 175 3"parser.yy"7432 #line 1756 "parser.yy" 7405 7433 { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); } 7406 7434 break; … … 7409 7437 7410 7438 /* Line 1806 of yacc.c */ 7411 #line 17 58"parser.yy"7439 #line 1761 "parser.yy" 7412 7440 { (yyval.in) = 0; } 7413 7441 break; … … 7416 7444 7417 7445 /* Line 1806 of yacc.c */ 7418 #line 176 0"parser.yy"7446 #line 1763 "parser.yy" 7419 7447 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); } 7420 7448 break; … … 7423 7451 7424 7452 /* Line 1806 of yacc.c */ 7425 #line 176 1"parser.yy"7453 #line 1764 "parser.yy" 7426 7454 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_last( (yyvsp[(3) - (3)].in) ) ); } 7427 7455 break; … … 7430 7458 7431 7459 /* Line 1806 of yacc.c */ 7432 #line 176 3"parser.yy"7460 #line 1766 "parser.yy" 7433 7461 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_last( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); } 7434 7462 break; … … 7437 7465 7438 7466 /* Line 1806 of yacc.c */ 7439 #line 17 79"parser.yy"7467 #line 1782 "parser.yy" 7440 7468 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(1) - (2)].tok) ) ); } 7441 7469 break; … … 7444 7472 7445 7473 /* Line 1806 of yacc.c */ 7446 #line 178 5"parser.yy"7474 #line 1788 "parser.yy" 7447 7475 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_last( (yyvsp[(2) - (2)].en) ) ); } 7448 7476 break; … … 7451 7479 7452 7480 /* Line 1806 of yacc.c */ 7453 #line 179 1"parser.yy"7481 #line 1794 "parser.yy" 7454 7482 { (yyval.en) = new ExpressionNode( build_varref( (yyvsp[(2) - (2)].tok) ) ); } 7455 7483 break; … … 7458 7486 7459 7487 /* Line 1806 of yacc.c */ 7460 #line 179 4"parser.yy"7488 #line 1797 "parser.yy" 7461 7489 { (yyval.en) = (yyvsp[(3) - (5)].en); } 7462 7490 break; … … 7465 7493 7466 7494 /* Line 1806 of yacc.c */ 7467 #line 179 6"parser.yy"7495 #line 1799 "parser.yy" 7468 7496 { (yyval.en) = (yyvsp[(3) - (5)].en); } 7469 7497 break; … … 7472 7500 7473 7501 /* Line 1806 of yacc.c */ 7474 #line 1 798"parser.yy"7502 #line 1801 "parser.yy" 7475 7503 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ); } 7476 7504 break; … … 7479 7507 7480 7508 /* Line 1806 of yacc.c */ 7481 #line 180 0"parser.yy"7509 #line 1803 "parser.yy" 7482 7510 { (yyval.en) = (yyvsp[(4) - (6)].en); } 7483 7511 break; … … 7486 7514 7487 7515 /* Line 1806 of yacc.c */ 7488 #line 182 4"parser.yy"7516 #line 1827 "parser.yy" 7489 7517 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7490 7518 break; … … 7493 7521 7494 7522 /* Line 1806 of yacc.c */ 7495 #line 182 6"parser.yy"7523 #line 1829 "parser.yy" 7496 7524 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7497 7525 break; … … 7500 7528 7501 7529 /* Line 1806 of yacc.c */ 7502 #line 18 28"parser.yy"7530 #line 1831 "parser.yy" 7503 7531 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7504 7532 break; … … 7507 7535 7508 7536 /* Line 1806 of yacc.c */ 7509 #line 183 4"parser.yy"7537 #line 1837 "parser.yy" 7510 7538 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7511 7539 break; … … 7514 7542 7515 7543 /* Line 1806 of yacc.c */ 7516 #line 183 6"parser.yy"7544 #line 1839 "parser.yy" 7517 7545 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7518 7546 break; … … 7521 7549 7522 7550 /* Line 1806 of yacc.c */ 7523 #line 184 1"parser.yy"7551 #line 1844 "parser.yy" 7524 7552 { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 7525 7553 break; … … 7528 7556 7529 7557 /* Line 1806 of yacc.c */ 7530 #line 18 47"parser.yy"7558 #line 1850 "parser.yy" 7531 7559 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); } 7532 7560 break; … … 7535 7563 7536 7564 /* Line 1806 of yacc.c */ 7537 #line 185 2"parser.yy"7565 #line 1855 "parser.yy" 7538 7566 { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); } 7539 7567 break; … … 7542 7570 7543 7571 /* Line 1806 of yacc.c */ 7544 #line 185 4"parser.yy"7572 #line 1857 "parser.yy" 7545 7573 { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); } 7546 7574 break; … … 7549 7577 7550 7578 /* Line 1806 of yacc.c */ 7551 #line 186 0"parser.yy"7579 #line 1863 "parser.yy" 7552 7580 { (yyval.tclass) = DeclarationNode::Otype; } 7553 7581 break; … … 7556 7584 7557 7585 /* Line 1806 of yacc.c */ 7558 #line 186 2"parser.yy"7586 #line 1865 "parser.yy" 7559 7587 { (yyval.tclass) = DeclarationNode::Ftype; } 7560 7588 break; … … 7563 7591 7564 7592 /* Line 1806 of yacc.c */ 7565 #line 186 4"parser.yy"7593 #line 1867 "parser.yy" 7566 7594 { (yyval.tclass) = DeclarationNode::Dtype; } 7567 7595 break; … … 7570 7598 7571 7599 /* Line 1806 of yacc.c */ 7572 #line 18 69"parser.yy"7600 #line 1872 "parser.yy" 7573 7601 { (yyval.decl) = 0; } 7574 7602 break; … … 7577 7605 7578 7606 /* Line 1806 of yacc.c */ 7579 #line 187 1"parser.yy"7607 #line 1874 "parser.yy" 7580 7608 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 7581 7609 break; … … 7584 7612 7585 7613 /* Line 1806 of yacc.c */ 7586 #line 187 6"parser.yy"7614 #line 1879 "parser.yy" 7587 7615 { 7588 7616 typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) ); … … 7594 7622 7595 7623 /* Line 1806 of yacc.c */ 7596 #line 188 1"parser.yy"7624 #line 1884 "parser.yy" 7597 7625 { (yyval.decl) = (yyvsp[(4) - (5)].decl); } 7598 7626 break; … … 7601 7629 7602 7630 /* Line 1806 of yacc.c */ 7603 #line 188 3"parser.yy"7631 #line 1886 "parser.yy" 7604 7632 { (yyval.decl) = 0; } 7605 7633 break; … … 7608 7636 7609 7637 /* Line 1806 of yacc.c */ 7610 #line 18 88"parser.yy"7638 #line 1891 "parser.yy" 7611 7639 { (yyval.en) = new ExpressionNode( build_typevalue( (yyvsp[(1) - (1)].decl) ) ); } 7612 7640 break; … … 7615 7643 7616 7644 /* Line 1806 of yacc.c */ 7617 #line 189 1"parser.yy"7645 #line 1894 "parser.yy" 7618 7646 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( new ExpressionNode( build_typevalue( (yyvsp[(3) - (3)].decl) ) ) ) ); } 7619 7647 break; … … 7622 7650 7623 7651 /* Line 1806 of yacc.c */ 7624 #line 189 3"parser.yy"7652 #line 1896 "parser.yy" 7625 7653 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_last( (yyvsp[(3) - (3)].en) )); } 7626 7654 break; … … 7629 7657 7630 7658 /* Line 1806 of yacc.c */ 7631 #line 1 898"parser.yy"7659 #line 1901 "parser.yy" 7632 7660 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 7633 7661 break; … … 7636 7664 7637 7665 /* Line 1806 of yacc.c */ 7638 #line 190 0"parser.yy"7666 #line 1903 "parser.yy" 7639 7667 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); } 7640 7668 break; … … 7643 7671 7644 7672 /* Line 1806 of yacc.c */ 7645 #line 190 2"parser.yy"7673 #line 1905 "parser.yy" 7646 7674 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); } 7647 7675 break; … … 7650 7678 7651 7679 /* Line 1806 of yacc.c */ 7652 #line 19 07"parser.yy"7680 #line 1910 "parser.yy" 7653 7681 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); } 7654 7682 break; … … 7657 7685 7658 7686 /* Line 1806 of yacc.c */ 7659 #line 19 09"parser.yy"7687 #line 1912 "parser.yy" 7660 7688 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); } 7661 7689 break; … … 7664 7692 7665 7693 /* Line 1806 of yacc.c */ 7666 #line 191 4"parser.yy"7694 #line 1917 "parser.yy" 7667 7695 { 7668 7696 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD ); … … 7674 7702 7675 7703 /* Line 1806 of yacc.c */ 7676 #line 19 19"parser.yy"7704 #line 1922 "parser.yy" 7677 7705 { 7678 7706 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG ); … … 7684 7712 7685 7713 /* Line 1806 of yacc.c */ 7686 #line 19 27"parser.yy"7714 #line 1930 "parser.yy" 7687 7715 { 7688 7716 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID ); … … 7694 7722 7695 7723 /* Line 1806 of yacc.c */ 7696 #line 193 2"parser.yy"7724 #line 1935 "parser.yy" 7697 7725 { 7698 7726 typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) ); … … 7704 7732 7705 7733 /* Line 1806 of yacc.c */ 7706 #line 19 37"parser.yy"7734 #line 1940 "parser.yy" 7707 7735 { 7708 7736 typedefTable.leaveTrait(); … … 7715 7743 7716 7744 /* Line 1806 of yacc.c */ 7717 #line 19 47"parser.yy"7745 #line 1950 "parser.yy" 7718 7746 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 7719 7747 break; … … 7722 7750 7723 7751 /* Line 1806 of yacc.c */ 7724 #line 19 57"parser.yy"7752 #line 1960 "parser.yy" 7725 7753 { 7726 7754 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7732 7760 7733 7761 /* Line 1806 of yacc.c */ 7734 #line 196 2"parser.yy"7762 #line 1965 "parser.yy" 7735 7763 { 7736 7764 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7742 7770 7743 7771 /* Line 1806 of yacc.c */ 7744 #line 19 67"parser.yy"7772 #line 1970 "parser.yy" 7745 7773 { 7746 7774 typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 7752 7780 7753 7781 /* Line 1806 of yacc.c */ 7754 #line 197 5"parser.yy"7782 #line 1978 "parser.yy" 7755 7783 { 7756 7784 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7762 7790 7763 7791 /* Line 1806 of yacc.c */ 7764 #line 198 0"parser.yy"7792 #line 1983 "parser.yy" 7765 7793 { 7766 7794 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7772 7800 7773 7801 /* Line 1806 of yacc.c */ 7774 #line 199 0"parser.yy"7802 #line 1993 "parser.yy" 7775 7803 {} 7776 7804 break; … … 7779 7807 7780 7808 /* Line 1806 of yacc.c */ 7781 #line 199 2"parser.yy"7809 #line 1995 "parser.yy" 7782 7810 { parseTree = parseTree != nullptr ? parseTree->appendList( (yyvsp[(1) - (1)].decl) ) : (yyvsp[(1) - (1)].decl); } 7783 7811 break; … … 7786 7814 7787 7815 /* Line 1806 of yacc.c */ 7788 #line 1998"parser.yy"7816 #line 2001 "parser.yy" 7789 7817 { (yyval.decl) = (yyvsp[(1) - (3)].decl) != nullptr ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); } 7790 7818 break; … … 7793 7821 7794 7822 /* Line 1806 of yacc.c */ 7795 #line 200 3"parser.yy"7823 #line 2006 "parser.yy" 7796 7824 { (yyval.decl) = 0; } 7797 7825 break; … … 7800 7828 7801 7829 /* Line 1806 of yacc.c */ 7802 #line 201 1"parser.yy"7830 #line 2014 "parser.yy" 7803 7831 {} 7804 7832 break; … … 7807 7835 7808 7836 /* Line 1806 of yacc.c */ 7809 #line 201 3"parser.yy"7837 #line 2016 "parser.yy" 7810 7838 { 7811 7839 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" … … 7817 7845 7818 7846 /* Line 1806 of yacc.c */ 7819 #line 20 18"parser.yy"7847 #line 2021 "parser.yy" 7820 7848 { 7821 7849 linkage = linkageStack.top(); … … 7828 7856 7829 7857 /* Line 1806 of yacc.c */ 7830 #line 202 4"parser.yy"7858 #line 2027 "parser.yy" 7831 7859 { // mark all fields in list 7832 7860 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) … … 7839 7867 7840 7868 /* Line 1806 of yacc.c */ 7841 #line 20 39"parser.yy"7869 #line 2042 "parser.yy" 7842 7870 { 7843 7871 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7850 7878 7851 7879 /* Line 1806 of yacc.c */ 7852 #line 204 5"parser.yy"7880 #line 2048 "parser.yy" 7853 7881 { 7854 7882 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7861 7889 7862 7890 /* Line 1806 of yacc.c */ 7863 #line 205 4"parser.yy"7891 #line 2057 "parser.yy" 7864 7892 { 7865 7893 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7872 7900 7873 7901 /* Line 1806 of yacc.c */ 7874 #line 206 0"parser.yy"7902 #line 2063 "parser.yy" 7875 7903 { 7876 7904 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7883 7911 7884 7912 /* Line 1806 of yacc.c */ 7885 #line 206 6"parser.yy"7913 #line 2069 "parser.yy" 7886 7914 { 7887 7915 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7894 7922 7895 7923 /* Line 1806 of yacc.c */ 7896 #line 207 2"parser.yy"7924 #line 2075 "parser.yy" 7897 7925 { 7898 7926 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7905 7933 7906 7934 /* Line 1806 of yacc.c */ 7907 #line 20 78"parser.yy"7935 #line 2081 "parser.yy" 7908 7936 { 7909 7937 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7916 7944 7917 7945 /* Line 1806 of yacc.c */ 7918 #line 208 6"parser.yy"7946 #line 2089 "parser.yy" 7919 7947 { 7920 7948 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7927 7955 7928 7956 /* Line 1806 of yacc.c */ 7929 #line 209 2"parser.yy"7957 #line 2095 "parser.yy" 7930 7958 { 7931 7959 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7938 7966 7939 7967 /* Line 1806 of yacc.c */ 7940 #line 210 0"parser.yy"7968 #line 2103 "parser.yy" 7941 7969 { 7942 7970 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7949 7977 7950 7978 /* Line 1806 of yacc.c */ 7951 #line 210 6"parser.yy"7979 #line 2109 "parser.yy" 7952 7980 { 7953 7981 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7960 7988 7961 7989 /* Line 1806 of yacc.c */ 7962 #line 212 1"parser.yy"7990 #line 2124 "parser.yy" 7963 7991 { (yyval.en) = new ExpressionNode( build_range( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 7964 7992 break; … … 7967 7995 7968 7996 /* Line 1806 of yacc.c */ 7969 #line 212 6"parser.yy"7997 #line 2129 "parser.yy" 7970 7998 { delete (yyvsp[(3) - (5)].str); } 7971 7999 break; … … 7974 8002 7975 8003 /* Line 1806 of yacc.c */ 7976 #line 213 1"parser.yy"8004 #line 2134 "parser.yy" 7977 8005 { (yyval.decl) = 0; } 7978 8006 break; … … 7981 8009 7982 8010 /* Line 1806 of yacc.c */ 7983 #line 21 38"parser.yy"8011 #line 2141 "parser.yy" 7984 8012 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7985 8013 break; … … 7988 8016 7989 8017 /* Line 1806 of yacc.c */ 7990 #line 214 4"parser.yy"8018 #line 2147 "parser.yy" 7991 8019 { (yyval.decl) = 0; } 7992 8020 break; … … 7995 8023 7996 8024 /* Line 1806 of yacc.c */ 7997 #line 215 5"parser.yy"8025 #line 2158 "parser.yy" 7998 8026 { delete (yyvsp[(3) - (4)].en); } 7999 8027 break; … … 8002 8030 8003 8031 /* Line 1806 of yacc.c */ 8004 #line 21 59"parser.yy"8032 #line 2162 "parser.yy" 8005 8033 { delete (yyvsp[(1) - (1)].tok); } 8006 8034 break; … … 8009 8037 8010 8038 /* Line 1806 of yacc.c */ 8011 #line 216 0"parser.yy"8039 #line 2163 "parser.yy" 8012 8040 { delete (yyvsp[(1) - (1)].decl); } 8013 8041 break; … … 8016 8044 8017 8045 /* Line 1806 of yacc.c */ 8018 #line 216 1"parser.yy"8046 #line 2164 "parser.yy" 8019 8047 { delete (yyvsp[(1) - (1)].decl); } 8020 8048 break; … … 8023 8051 8024 8052 /* Line 1806 of yacc.c */ 8025 #line 216 2"parser.yy"8053 #line 2165 "parser.yy" 8026 8054 { delete (yyvsp[(1) - (1)].decl); } 8027 8055 break; 8028 8056 8029 8057 case 563: 8030 8031 /* Line 1806 of yacc.c */8032 #line 2197 "parser.yy"8033 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }8034 break;8035 8036 case 565:8037 8058 8038 8059 /* Line 1806 of yacc.c */ … … 8041 8062 break; 8042 8063 8064 case 565: 8065 8066 /* Line 1806 of yacc.c */ 8067 #line 2203 "parser.yy" 8068 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8069 break; 8070 8043 8071 case 566: 8044 8072 8045 8073 /* Line 1806 of yacc.c */ 8046 #line 220 2"parser.yy"8074 #line 2205 "parser.yy" 8047 8075 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8048 8076 break; … … 8051 8079 8052 8080 /* Line 1806 of yacc.c */ 8053 #line 22 07"parser.yy"8081 #line 2210 "parser.yy" 8054 8082 { 8055 8083 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8061 8089 8062 8090 /* Line 1806 of yacc.c */ 8063 #line 221 2"parser.yy"8091 #line 2215 "parser.yy" 8064 8092 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8065 8093 break; … … 8068 8096 8069 8097 /* Line 1806 of yacc.c */ 8070 #line 22 17"parser.yy"8098 #line 2220 "parser.yy" 8071 8099 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8072 8100 break; … … 8075 8103 8076 8104 /* Line 1806 of yacc.c */ 8077 #line 22 19"parser.yy"8105 #line 2222 "parser.yy" 8078 8106 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8079 8107 break; … … 8082 8110 8083 8111 /* Line 1806 of yacc.c */ 8084 #line 222 1"parser.yy"8112 #line 2224 "parser.yy" 8085 8113 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8086 8114 break; … … 8089 8117 8090 8118 /* Line 1806 of yacc.c */ 8091 #line 222 6"parser.yy"8119 #line 2229 "parser.yy" 8092 8120 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8093 8121 break; … … 8096 8124 8097 8125 /* Line 1806 of yacc.c */ 8098 #line 22 28"parser.yy"8126 #line 2231 "parser.yy" 8099 8127 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8100 8128 break; … … 8103 8131 8104 8132 /* Line 1806 of yacc.c */ 8105 #line 223 0"parser.yy"8133 #line 2233 "parser.yy" 8106 8134 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8107 8135 break; … … 8110 8138 8111 8139 /* Line 1806 of yacc.c */ 8112 #line 223 2"parser.yy"8140 #line 2235 "parser.yy" 8113 8141 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8114 8142 break; … … 8117 8145 8118 8146 /* Line 1806 of yacc.c */ 8119 #line 22 37"parser.yy"8147 #line 2240 "parser.yy" 8120 8148 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8121 8149 break; … … 8124 8152 8125 8153 /* Line 1806 of yacc.c */ 8126 #line 22 39"parser.yy"8154 #line 2242 "parser.yy" 8127 8155 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8128 8156 break; 8129 8157 8130 8158 case 578: 8131 8132 /* Line 1806 of yacc.c */8133 #line 2248 "parser.yy"8134 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }8135 break;8136 8137 case 580:8138 8159 8139 8160 /* Line 1806 of yacc.c */ … … 8142 8163 break; 8143 8164 8165 case 580: 8166 8167 /* Line 1806 of yacc.c */ 8168 #line 2254 "parser.yy" 8169 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8170 break; 8171 8144 8172 case 581: 8145 8173 8146 8174 /* Line 1806 of yacc.c */ 8147 #line 225 6"parser.yy"8175 #line 2259 "parser.yy" 8148 8176 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8149 8177 break; … … 8152 8180 8153 8181 /* Line 1806 of yacc.c */ 8154 #line 22 58"parser.yy"8182 #line 2261 "parser.yy" 8155 8183 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8156 8184 break; … … 8159 8187 8160 8188 /* Line 1806 of yacc.c */ 8161 #line 226 0"parser.yy"8189 #line 2263 "parser.yy" 8162 8190 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8163 8191 break; … … 8166 8194 8167 8195 /* Line 1806 of yacc.c */ 8168 #line 226 5"parser.yy"8196 #line 2268 "parser.yy" 8169 8197 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8170 8198 break; … … 8173 8201 8174 8202 /* Line 1806 of yacc.c */ 8175 #line 22 67"parser.yy"8203 #line 2270 "parser.yy" 8176 8204 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8177 8205 break; … … 8180 8208 8181 8209 /* Line 1806 of yacc.c */ 8182 #line 22 69"parser.yy"8210 #line 2272 "parser.yy" 8183 8211 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8184 8212 break; … … 8187 8215 8188 8216 /* Line 1806 of yacc.c */ 8189 #line 227 4"parser.yy"8217 #line 2277 "parser.yy" 8190 8218 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8191 8219 break; … … 8194 8222 8195 8223 /* Line 1806 of yacc.c */ 8196 #line 227 6"parser.yy"8224 #line 2279 "parser.yy" 8197 8225 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8198 8226 break; … … 8201 8229 8202 8230 /* Line 1806 of yacc.c */ 8203 #line 22 78"parser.yy"8231 #line 2281 "parser.yy" 8204 8232 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8205 8233 break; … … 8208 8236 8209 8237 /* Line 1806 of yacc.c */ 8210 #line 229 3"parser.yy"8238 #line 2296 "parser.yy" 8211 8239 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); } 8212 8240 break; … … 8215 8243 8216 8244 /* Line 1806 of yacc.c */ 8217 #line 229 5"parser.yy"8245 #line 2298 "parser.yy" 8218 8246 { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); } 8219 8247 break; … … 8222 8250 8223 8251 /* Line 1806 of yacc.c */ 8224 #line 2 297"parser.yy"8252 #line 2300 "parser.yy" 8225 8253 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8226 8254 break; … … 8229 8257 8230 8258 /* Line 1806 of yacc.c */ 8231 #line 230 2"parser.yy"8259 #line 2305 "parser.yy" 8232 8260 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8233 8261 break; … … 8236 8264 8237 8265 /* Line 1806 of yacc.c */ 8238 #line 230 4"parser.yy"8266 #line 2307 "parser.yy" 8239 8267 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8240 8268 break; … … 8243 8271 8244 8272 /* Line 1806 of yacc.c */ 8245 #line 230 6"parser.yy"8273 #line 2309 "parser.yy" 8246 8274 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8247 8275 break; … … 8250 8278 8251 8279 /* Line 1806 of yacc.c */ 8252 #line 231 1"parser.yy"8280 #line 2314 "parser.yy" 8253 8281 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8254 8282 break; … … 8257 8285 8258 8286 /* Line 1806 of yacc.c */ 8259 #line 231 3"parser.yy"8287 #line 2316 "parser.yy" 8260 8288 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8261 8289 break; … … 8264 8292 8265 8293 /* Line 1806 of yacc.c */ 8266 #line 231 5"parser.yy"8294 #line 2318 "parser.yy" 8267 8295 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8268 8296 break; 8269 8297 8270 8298 case 602: 8271 8272 /* Line 1806 of yacc.c */8273 #line 2330 "parser.yy"8274 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }8275 break;8276 8277 case 604:8278 8299 8279 8300 /* Line 1806 of yacc.c */ … … 8282 8303 break; 8283 8304 8305 case 604: 8306 8307 /* Line 1806 of yacc.c */ 8308 #line 2336 "parser.yy" 8309 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8310 break; 8311 8284 8312 case 605: 8285 8313 8286 8314 /* Line 1806 of yacc.c */ 8287 #line 233 5"parser.yy"8315 #line 2338 "parser.yy" 8288 8316 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8289 8317 break; … … 8292 8320 8293 8321 /* Line 1806 of yacc.c */ 8294 #line 234 1"parser.yy"8322 #line 2344 "parser.yy" 8295 8323 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8296 8324 break; … … 8299 8327 8300 8328 /* Line 1806 of yacc.c */ 8301 #line 234 6"parser.yy"8329 #line 2349 "parser.yy" 8302 8330 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8303 8331 break; … … 8306 8334 8307 8335 /* Line 1806 of yacc.c */ 8308 #line 23 48"parser.yy"8336 #line 2351 "parser.yy" 8309 8337 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8310 8338 break; … … 8313 8341 8314 8342 /* Line 1806 of yacc.c */ 8315 #line 235 0"parser.yy"8343 #line 2353 "parser.yy" 8316 8344 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8317 8345 break; … … 8320 8348 8321 8349 /* Line 1806 of yacc.c */ 8322 #line 235 5"parser.yy"8350 #line 2358 "parser.yy" 8323 8351 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8324 8352 break; … … 8327 8355 8328 8356 /* Line 1806 of yacc.c */ 8329 #line 23 57"parser.yy"8357 #line 2360 "parser.yy" 8330 8358 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8331 8359 break; … … 8334 8362 8335 8363 /* Line 1806 of yacc.c */ 8336 #line 23 59"parser.yy"8364 #line 2362 "parser.yy" 8337 8365 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8338 8366 break; … … 8341 8369 8342 8370 /* Line 1806 of yacc.c */ 8343 #line 236 1"parser.yy"8371 #line 2364 "parser.yy" 8344 8372 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8345 8373 break; … … 8348 8376 8349 8377 /* Line 1806 of yacc.c */ 8350 #line 236 6"parser.yy"8378 #line 2369 "parser.yy" 8351 8379 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8352 8380 break; … … 8355 8383 8356 8384 /* Line 1806 of yacc.c */ 8357 #line 23 68"parser.yy"8385 #line 2371 "parser.yy" 8358 8386 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8359 8387 break; … … 8362 8390 8363 8391 /* Line 1806 of yacc.c */ 8364 #line 237 0"parser.yy"8392 #line 2373 "parser.yy" 8365 8393 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8366 8394 break; 8367 8395 8368 8396 case 618: 8369 8370 /* Line 1806 of yacc.c */8371 #line 2380 "parser.yy"8372 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }8373 break;8374 8375 case 620:8376 8397 8377 8398 /* Line 1806 of yacc.c */ … … 8380 8401 break; 8381 8402 8403 case 620: 8404 8405 /* Line 1806 of yacc.c */ 8406 #line 2386 "parser.yy" 8407 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8408 break; 8409 8382 8410 case 621: 8383 8411 8384 8412 /* Line 1806 of yacc.c */ 8385 #line 238 5"parser.yy"8413 #line 2388 "parser.yy" 8386 8414 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8387 8415 break; … … 8390 8418 8391 8419 /* Line 1806 of yacc.c */ 8392 #line 239 0"parser.yy"8420 #line 2393 "parser.yy" 8393 8421 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8394 8422 break; … … 8397 8425 8398 8426 /* Line 1806 of yacc.c */ 8399 #line 239 2"parser.yy"8427 #line 2395 "parser.yy" 8400 8428 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8401 8429 break; … … 8404 8432 8405 8433 /* Line 1806 of yacc.c */ 8406 #line 239 4"parser.yy"8434 #line 2397 "parser.yy" 8407 8435 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8408 8436 break; … … 8411 8439 8412 8440 /* Line 1806 of yacc.c */ 8413 #line 2 399"parser.yy"8441 #line 2402 "parser.yy" 8414 8442 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8415 8443 break; … … 8418 8446 8419 8447 /* Line 1806 of yacc.c */ 8420 #line 240 1"parser.yy"8448 #line 2404 "parser.yy" 8421 8449 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8422 8450 break; … … 8425 8453 8426 8454 /* Line 1806 of yacc.c */ 8427 #line 240 3"parser.yy"8455 #line 2406 "parser.yy" 8428 8456 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8429 8457 break; … … 8432 8460 8433 8461 /* Line 1806 of yacc.c */ 8434 #line 240 5"parser.yy"8462 #line 2408 "parser.yy" 8435 8463 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8436 8464 break; … … 8439 8467 8440 8468 /* Line 1806 of yacc.c */ 8441 #line 241 0"parser.yy"8469 #line 2413 "parser.yy" 8442 8470 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8443 8471 break; … … 8446 8474 8447 8475 /* Line 1806 of yacc.c */ 8448 #line 241 2"parser.yy"8476 #line 2415 "parser.yy" 8449 8477 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8450 8478 break; … … 8453 8481 8454 8482 /* Line 1806 of yacc.c */ 8455 #line 241 4"parser.yy"8483 #line 2417 "parser.yy" 8456 8484 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8457 8485 break; 8458 8486 8459 8487 case 632: 8460 8461 /* Line 1806 of yacc.c */8462 #line 2445 "parser.yy"8463 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); }8464 break;8465 8466 case 634:8467 8488 8468 8489 /* Line 1806 of yacc.c */ … … 8471 8492 break; 8472 8493 8494 case 634: 8495 8496 /* Line 1806 of yacc.c */ 8497 #line 2451 "parser.yy" 8498 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8499 break; 8500 8473 8501 case 635: 8474 8502 8475 8503 /* Line 1806 of yacc.c */ 8476 #line 245 0"parser.yy"8504 #line 2453 "parser.yy" 8477 8505 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8478 8506 break; … … 8481 8509 8482 8510 /* Line 1806 of yacc.c */ 8483 #line 245 5"parser.yy"8511 #line 2458 "parser.yy" 8484 8512 { 8485 8513 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8491 8519 8492 8520 /* Line 1806 of yacc.c */ 8493 #line 246 0"parser.yy"8521 #line 2463 "parser.yy" 8494 8522 { 8495 8523 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8501 8529 8502 8530 /* Line 1806 of yacc.c */ 8503 #line 24 68"parser.yy"8531 #line 2471 "parser.yy" 8504 8532 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8505 8533 break; … … 8508 8536 8509 8537 /* Line 1806 of yacc.c */ 8510 #line 247 0"parser.yy"8538 #line 2473 "parser.yy" 8511 8539 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8512 8540 break; … … 8515 8543 8516 8544 /* Line 1806 of yacc.c */ 8517 #line 247 2"parser.yy"8545 #line 2475 "parser.yy" 8518 8546 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8519 8547 break; … … 8522 8550 8523 8551 /* Line 1806 of yacc.c */ 8524 #line 24 77"parser.yy"8552 #line 2480 "parser.yy" 8525 8553 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8526 8554 break; … … 8529 8557 8530 8558 /* Line 1806 of yacc.c */ 8531 #line 24 79"parser.yy"8559 #line 2482 "parser.yy" 8532 8560 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8533 8561 break; … … 8536 8564 8537 8565 /* Line 1806 of yacc.c */ 8538 #line 248 4"parser.yy"8566 #line 2487 "parser.yy" 8539 8567 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8540 8568 break; … … 8543 8571 8544 8572 /* Line 1806 of yacc.c */ 8545 #line 248 6"parser.yy"8573 #line 2489 "parser.yy" 8546 8574 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8547 8575 break; … … 8550 8578 8551 8579 /* Line 1806 of yacc.c */ 8552 #line 250 1"parser.yy"8580 #line 2504 "parser.yy" 8553 8581 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8554 8582 break; … … 8557 8585 8558 8586 /* Line 1806 of yacc.c */ 8559 #line 250 3"parser.yy"8587 #line 2506 "parser.yy" 8560 8588 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8561 8589 break; … … 8564 8592 8565 8593 /* Line 1806 of yacc.c */ 8566 #line 25 08"parser.yy"8594 #line 2511 "parser.yy" 8567 8595 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8568 8596 break; … … 8571 8599 8572 8600 /* Line 1806 of yacc.c */ 8573 #line 251 0"parser.yy"8601 #line 2513 "parser.yy" 8574 8602 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8575 8603 break; … … 8578 8606 8579 8607 /* Line 1806 of yacc.c */ 8580 #line 251 2"parser.yy"8608 #line 2515 "parser.yy" 8581 8609 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8582 8610 break; … … 8585 8613 8586 8614 /* Line 1806 of yacc.c */ 8587 #line 251 4"parser.yy"8615 #line 2517 "parser.yy" 8588 8616 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8589 8617 break; … … 8592 8620 8593 8621 /* Line 1806 of yacc.c */ 8594 #line 251 6"parser.yy"8622 #line 2519 "parser.yy" 8595 8623 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8596 8624 break; … … 8599 8627 8600 8628 /* Line 1806 of yacc.c */ 8601 #line 252 2"parser.yy"8629 #line 2525 "parser.yy" 8602 8630 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8603 8631 break; … … 8606 8634 8607 8635 /* Line 1806 of yacc.c */ 8608 #line 252 4"parser.yy"8636 #line 2527 "parser.yy" 8609 8637 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8610 8638 break; … … 8613 8641 8614 8642 /* Line 1806 of yacc.c */ 8615 #line 252 6"parser.yy"8643 #line 2529 "parser.yy" 8616 8644 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8617 8645 break; … … 8620 8648 8621 8649 /* Line 1806 of yacc.c */ 8622 #line 253 1"parser.yy"8650 #line 2534 "parser.yy" 8623 8651 { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); } 8624 8652 break; … … 8627 8655 8628 8656 /* Line 1806 of yacc.c */ 8629 #line 253 3"parser.yy"8657 #line 2536 "parser.yy" 8630 8658 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8631 8659 break; … … 8634 8662 8635 8663 /* Line 1806 of yacc.c */ 8636 #line 253 5"parser.yy"8664 #line 2538 "parser.yy" 8637 8665 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8638 8666 break; … … 8641 8669 8642 8670 /* Line 1806 of yacc.c */ 8643 #line 254 1"parser.yy"8671 #line 2544 "parser.yy" 8644 8672 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8645 8673 break; … … 8648 8676 8649 8677 /* Line 1806 of yacc.c */ 8650 #line 254 3"parser.yy"8678 #line 2546 "parser.yy" 8651 8679 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); } 8652 8680 break; … … 8655 8683 8656 8684 /* Line 1806 of yacc.c */ 8657 #line 25 49"parser.yy"8685 #line 2552 "parser.yy" 8658 8686 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); } 8659 8687 break; … … 8662 8690 8663 8691 /* Line 1806 of yacc.c */ 8664 #line 255 1"parser.yy"8692 #line 2554 "parser.yy" 8665 8693 { (yyval.decl) = DeclarationNode::newVarArray( 0 ); } 8666 8694 break; … … 8669 8697 8670 8698 /* Line 1806 of yacc.c */ 8671 #line 255 3"parser.yy"8699 #line 2556 "parser.yy" 8672 8700 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); } 8673 8701 break; … … 8676 8704 8677 8705 /* Line 1806 of yacc.c */ 8678 #line 255 5"parser.yy"8706 #line 2558 "parser.yy" 8679 8707 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); } 8680 8708 break; … … 8683 8711 8684 8712 /* Line 1806 of yacc.c */ 8685 #line 257 0"parser.yy"8713 #line 2573 "parser.yy" 8686 8714 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8687 8715 break; … … 8690 8718 8691 8719 /* Line 1806 of yacc.c */ 8692 #line 257 2"parser.yy"8720 #line 2575 "parser.yy" 8693 8721 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8694 8722 break; … … 8697 8725 8698 8726 /* Line 1806 of yacc.c */ 8699 #line 25 77"parser.yy"8727 #line 2580 "parser.yy" 8700 8728 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8701 8729 break; … … 8704 8732 8705 8733 /* Line 1806 of yacc.c */ 8706 #line 25 79"parser.yy"8734 #line 2582 "parser.yy" 8707 8735 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8708 8736 break; … … 8711 8739 8712 8740 /* Line 1806 of yacc.c */ 8713 #line 258 1"parser.yy"8741 #line 2584 "parser.yy" 8714 8742 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8715 8743 break; … … 8718 8746 8719 8747 /* Line 1806 of yacc.c */ 8720 #line 258 3"parser.yy"8748 #line 2586 "parser.yy" 8721 8749 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8722 8750 break; … … 8725 8753 8726 8754 /* Line 1806 of yacc.c */ 8727 #line 258 5"parser.yy"8755 #line 2588 "parser.yy" 8728 8756 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8729 8757 break; … … 8732 8760 8733 8761 /* Line 1806 of yacc.c */ 8734 #line 259 1"parser.yy"8762 #line 2594 "parser.yy" 8735 8763 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8736 8764 break; … … 8739 8767 8740 8768 /* Line 1806 of yacc.c */ 8741 #line 259 3"parser.yy"8769 #line 2596 "parser.yy" 8742 8770 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8743 8771 break; … … 8746 8774 8747 8775 /* Line 1806 of yacc.c */ 8748 #line 259 5"parser.yy"8776 #line 2598 "parser.yy" 8749 8777 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8750 8778 break; … … 8753 8781 8754 8782 /* Line 1806 of yacc.c */ 8755 #line 260 0"parser.yy"8783 #line 2603 "parser.yy" 8756 8784 { (yyval.decl) = DeclarationNode::newFunction( nullptr, nullptr, (yyvsp[(3) - (5)].decl), nullptr ); } 8757 8785 break; … … 8760 8788 8761 8789 /* Line 1806 of yacc.c */ 8762 #line 260 2"parser.yy"8790 #line 2605 "parser.yy" 8763 8791 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8764 8792 break; … … 8767 8795 8768 8796 /* Line 1806 of yacc.c */ 8769 #line 260 4"parser.yy"8797 #line 2607 "parser.yy" 8770 8798 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8771 8799 break; … … 8774 8802 8775 8803 /* Line 1806 of yacc.c */ 8776 #line 261 1"parser.yy"8804 #line 2614 "parser.yy" 8777 8805 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8778 8806 break; … … 8781 8809 8782 8810 /* Line 1806 of yacc.c */ 8783 #line 262 2"parser.yy"8811 #line 2625 "parser.yy" 8784 8812 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8785 8813 break; … … 8788 8816 8789 8817 /* Line 1806 of yacc.c */ 8790 #line 262 5"parser.yy"8818 #line 2628 "parser.yy" 8791 8819 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 8792 8820 break; … … 8795 8823 8796 8824 /* Line 1806 of yacc.c */ 8797 #line 26 27"parser.yy"8825 #line 2630 "parser.yy" 8798 8826 { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); } 8799 8827 break; … … 8802 8830 8803 8831 /* Line 1806 of yacc.c */ 8804 #line 263 0"parser.yy"8832 #line 2633 "parser.yy" 8805 8833 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 8806 8834 break; … … 8809 8837 8810 8838 /* Line 1806 of yacc.c */ 8811 #line 263 2"parser.yy"8839 #line 2635 "parser.yy" 8812 8840 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); } 8813 8841 break; … … 8816 8844 8817 8845 /* Line 1806 of yacc.c */ 8818 #line 263 4"parser.yy"8846 #line 2637 "parser.yy" 8819 8847 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); } 8820 8848 break; … … 8823 8851 8824 8852 /* Line 1806 of yacc.c */ 8825 #line 26 48"parser.yy"8853 #line 2651 "parser.yy" 8826 8854 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8827 8855 break; … … 8830 8858 8831 8859 /* Line 1806 of yacc.c */ 8832 #line 265 0"parser.yy"8860 #line 2653 "parser.yy" 8833 8861 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8834 8862 break; … … 8837 8865 8838 8866 /* Line 1806 of yacc.c */ 8839 #line 265 5"parser.yy"8867 #line 2658 "parser.yy" 8840 8868 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8841 8869 break; … … 8844 8872 8845 8873 /* Line 1806 of yacc.c */ 8846 #line 26 57"parser.yy"8874 #line 2660 "parser.yy" 8847 8875 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8848 8876 break; … … 8851 8879 8852 8880 /* Line 1806 of yacc.c */ 8853 #line 26 59"parser.yy"8881 #line 2662 "parser.yy" 8854 8882 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8855 8883 break; … … 8858 8886 8859 8887 /* Line 1806 of yacc.c */ 8860 #line 266 1"parser.yy"8888 #line 2664 "parser.yy" 8861 8889 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8862 8890 break; … … 8865 8893 8866 8894 /* Line 1806 of yacc.c */ 8867 #line 266 3"parser.yy"8895 #line 2666 "parser.yy" 8868 8896 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8869 8897 break; … … 8872 8900 8873 8901 /* Line 1806 of yacc.c */ 8874 #line 26 69"parser.yy"8902 #line 2672 "parser.yy" 8875 8903 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8876 8904 break; … … 8879 8907 8880 8908 /* Line 1806 of yacc.c */ 8881 #line 267 1"parser.yy"8909 #line 2674 "parser.yy" 8882 8910 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8883 8911 break; … … 8886 8914 8887 8915 /* Line 1806 of yacc.c */ 8888 #line 267 3"parser.yy"8916 #line 2676 "parser.yy" 8889 8917 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8890 8918 break; … … 8893 8921 8894 8922 /* Line 1806 of yacc.c */ 8895 #line 26 78"parser.yy"8923 #line 2681 "parser.yy" 8896 8924 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8897 8925 break; … … 8900 8928 8901 8929 /* Line 1806 of yacc.c */ 8902 #line 268 0"parser.yy"8930 #line 2683 "parser.yy" 8903 8931 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8904 8932 break; … … 8907 8935 8908 8936 /* Line 1806 of yacc.c */ 8909 #line 269 0"parser.yy"8937 #line 2693 "parser.yy" 8910 8938 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 8911 8939 break; … … 8914 8942 8915 8943 /* Line 1806 of yacc.c */ 8916 #line 270 0"parser.yy"8944 #line 2703 "parser.yy" 8917 8945 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8918 8946 break; … … 8921 8949 8922 8950 /* Line 1806 of yacc.c */ 8923 #line 270 2"parser.yy"8951 #line 2705 "parser.yy" 8924 8952 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8925 8953 break; … … 8928 8956 8929 8957 /* Line 1806 of yacc.c */ 8930 #line 270 4"parser.yy"8958 #line 2707 "parser.yy" 8931 8959 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8932 8960 break; … … 8935 8963 8936 8964 /* Line 1806 of yacc.c */ 8937 #line 270 6"parser.yy"8965 #line 2709 "parser.yy" 8938 8966 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8939 8967 break; … … 8942 8970 8943 8971 /* Line 1806 of yacc.c */ 8944 #line 27 08"parser.yy"8972 #line 2711 "parser.yy" 8945 8973 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 8946 8974 break; … … 8949 8977 8950 8978 /* Line 1806 of yacc.c */ 8951 #line 271 0"parser.yy"8979 #line 2713 "parser.yy" 8952 8980 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 8953 8981 break; … … 8956 8984 8957 8985 /* Line 1806 of yacc.c */ 8958 #line 27 17"parser.yy"8986 #line 2720 "parser.yy" 8959 8987 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8960 8988 break; … … 8963 8991 8964 8992 /* Line 1806 of yacc.c */ 8965 #line 27 19"parser.yy"8993 #line 2722 "parser.yy" 8966 8994 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8967 8995 break; … … 8970 8998 8971 8999 /* Line 1806 of yacc.c */ 8972 #line 272 1"parser.yy"9000 #line 2724 "parser.yy" 8973 9001 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8974 9002 break; … … 8977 9005 8978 9006 /* Line 1806 of yacc.c */ 8979 #line 272 3"parser.yy"9007 #line 2726 "parser.yy" 8980 9008 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 8981 9009 break; … … 8984 9012 8985 9013 /* Line 1806 of yacc.c */ 8986 #line 272 5"parser.yy"9014 #line 2728 "parser.yy" 8987 9015 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 8988 9016 break; … … 8991 9019 8992 9020 /* Line 1806 of yacc.c */ 8993 #line 27 28"parser.yy"9021 #line 2731 "parser.yy" 8994 9022 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 8995 9023 break; … … 8998 9026 8999 9027 /* Line 1806 of yacc.c */ 9000 #line 273 0"parser.yy"9028 #line 2733 "parser.yy" 9001 9029 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9002 9030 break; … … 9005 9033 9006 9034 /* Line 1806 of yacc.c */ 9007 #line 273 2"parser.yy"9035 #line 2735 "parser.yy" 9008 9036 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9009 9037 break; … … 9012 9040 9013 9041 /* Line 1806 of yacc.c */ 9014 #line 273 4"parser.yy"9042 #line 2737 "parser.yy" 9015 9043 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 9016 9044 break; … … 9019 9047 9020 9048 /* Line 1806 of yacc.c */ 9021 #line 273 6"parser.yy"9049 #line 2739 "parser.yy" 9022 9050 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9023 9051 break; … … 9026 9054 9027 9055 /* Line 1806 of yacc.c */ 9028 #line 274 1"parser.yy"9056 #line 2744 "parser.yy" 9029 9057 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 9030 9058 break; … … 9033 9061 9034 9062 /* Line 1806 of yacc.c */ 9035 #line 274 3"parser.yy"9063 #line 2746 "parser.yy" 9036 9064 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 9037 9065 break; … … 9040 9068 9041 9069 /* Line 1806 of yacc.c */ 9042 #line 27 48"parser.yy"9070 #line 2751 "parser.yy" 9043 9071 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); } 9044 9072 break; … … 9047 9075 9048 9076 /* Line 1806 of yacc.c */ 9049 #line 275 0"parser.yy"9077 #line 2753 "parser.yy" 9050 9078 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); } 9051 9079 break; … … 9054 9082 9055 9083 /* Line 1806 of yacc.c */ 9056 #line 27 77"parser.yy"9084 #line 2780 "parser.yy" 9057 9085 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 9058 9086 break; … … 9061 9089 9062 9090 /* Line 1806 of yacc.c */ 9063 #line 27 88"parser.yy"9091 #line 2791 "parser.yy" 9064 9092 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9065 9093 break; … … 9068 9096 9069 9097 /* Line 1806 of yacc.c */ 9070 #line 279 0"parser.yy"9098 #line 2793 "parser.yy" 9071 9099 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9072 9100 break; … … 9075 9103 9076 9104 /* Line 1806 of yacc.c */ 9077 #line 279 2"parser.yy"9105 #line 2795 "parser.yy" 9078 9106 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9079 9107 break; … … 9082 9110 9083 9111 /* Line 1806 of yacc.c */ 9084 #line 279 4"parser.yy"9112 #line 2797 "parser.yy" 9085 9113 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9086 9114 break; … … 9089 9117 9090 9118 /* Line 1806 of yacc.c */ 9091 #line 279 6"parser.yy"9119 #line 2799 "parser.yy" 9092 9120 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9093 9121 break; … … 9096 9124 9097 9125 /* Line 1806 of yacc.c */ 9098 #line 2 798"parser.yy"9126 #line 2801 "parser.yy" 9099 9127 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9100 9128 break; … … 9103 9131 9104 9132 /* Line 1806 of yacc.c */ 9105 #line 280 5"parser.yy"9133 #line 2808 "parser.yy" 9106 9134 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9107 9135 break; … … 9110 9138 9111 9139 /* Line 1806 of yacc.c */ 9112 #line 28 07"parser.yy"9140 #line 2810 "parser.yy" 9113 9141 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9114 9142 break; … … 9117 9145 9118 9146 /* Line 1806 of yacc.c */ 9119 #line 28 09"parser.yy"9147 #line 2812 "parser.yy" 9120 9148 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9121 9149 break; … … 9124 9152 9125 9153 /* Line 1806 of yacc.c */ 9126 #line 281 1"parser.yy"9154 #line 2814 "parser.yy" 9127 9155 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9128 9156 break; … … 9131 9159 9132 9160 /* Line 1806 of yacc.c */ 9133 #line 281 3"parser.yy"9161 #line 2816 "parser.yy" 9134 9162 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 9135 9163 break; … … 9138 9166 9139 9167 /* Line 1806 of yacc.c */ 9140 #line 281 5"parser.yy"9168 #line 2818 "parser.yy" 9141 9169 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9142 9170 break; … … 9145 9173 9146 9174 /* Line 1806 of yacc.c */ 9147 #line 282 0"parser.yy"9175 #line 2823 "parser.yy" 9148 9176 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 9149 9177 break; … … 9152 9180 9153 9181 /* Line 1806 of yacc.c */ 9154 #line 282 5"parser.yy"9182 #line 2828 "parser.yy" 9155 9183 { (yyval.decl) = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), (yyvsp[(4) - (5)].decl), nullptr ); } 9156 9184 break; … … 9159 9187 9160 9188 /* Line 1806 of yacc.c */ 9161 #line 28 27"parser.yy"9189 #line 2830 "parser.yy" 9162 9190 { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); } 9163 9191 break; … … 9166 9194 9167 9195 /* Line 1806 of yacc.c */ 9168 #line 28 29"parser.yy"9196 #line 2832 "parser.yy" 9169 9197 { (yyval.decl) = DeclarationNode::newFunction( nullptr, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), nullptr ); } 9170 9198 break; … … 9173 9201 9174 9202 /* Line 1806 of yacc.c */ 9175 #line 285 3"parser.yy"9203 #line 2856 "parser.yy" 9176 9204 { (yyval.en) = 0; } 9177 9205 break; … … 9180 9208 9181 9209 /* Line 1806 of yacc.c */ 9182 #line 285 5"parser.yy"9210 #line 2858 "parser.yy" 9183 9211 { (yyval.en) = (yyvsp[(2) - (2)].en); } 9184 9212 break; … … 9187 9215 9188 9216 /* Line 1806 of yacc.c */ 9189 #line 9 190"Parser/parser.cc"9217 #line 9218 "Parser/parser.cc" 9190 9218 default: break; 9191 9219 } … … 9418 9446 9419 9447 /* Line 2067 of yacc.c */ 9420 #line 28 58"parser.yy"9448 #line 2861 "parser.yy" 9421 9449 9422 9450 // ----end of grammar---- -
src/Parser/parser.yy
rfe7b281 ra1e67dd 195 195 196 196 %type<decl> field_declaration field_declaration_list field_declarator field_declaring_list 197 %type<en> field field_list 198 %type<tok> field_name 197 %type<en> field field_list field_name 199 198 200 199 %type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr … … 379 378 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 380 379 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 380 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 381 381 | postfix_expression '.' INTEGERconstant 382 { $$ = new ExpressionNode( build_fieldSel( $1, build_constantInteger( *$3 ) ) ); } 382 383 | postfix_expression ARROW no_attr_identifier 383 384 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 384 385 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector 386 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 385 387 | postfix_expression ICR 386 388 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); } … … 418 420 // ambiguity with .0 so space required after field-selection, e.g. 419 421 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1; 420 { $$ = new ExpressionNode( build_varref( $1 ) ); }421 422 | field_name '.' field 422 { $$ = new ExpressionNode( build_fieldSel( $ 3, build_varref( $1) ) ); }423 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 423 424 | field_name '.' '[' push field_list pop ']' 424 { $$ = new ExpressionNode( build_fieldSel( $ 5, build_varref( $1) ) ); }425 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); } 425 426 | field_name ARROW field 426 { $$ = new ExpressionNode( build_pfieldSel( $ 3, build_varref( $1) ) ); }427 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); } 427 428 | field_name ARROW '[' push field_list pop ']' 428 { $$ = new ExpressionNode( build_pfieldSel( $ 5, build_varref( $1) ) ); }429 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); } 429 430 ; 430 431 431 432 field_name: 432 433 no_attr_identifier 434 { $$ = new ExpressionNode( build_varref( $1 ) ); } 433 435 // x.1, x.[0, 0.0] 434 436 | INTEGERconstant 437 { $$ = new ExpressionNode( build_constantInteger( *$1 ) ); } 435 438 ; 436 439 -
src/ResolvExpr/Alternative.cc
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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" … … 64 63 } 65 64 65 Cost sumCost( const AltList &in ) { 66 Cost total; 67 for ( AltList::const_iterator i = in.begin(); i != in.end(); ++i ) { 68 total += i->cost; 69 } 70 return total; 71 } 72 66 73 namespace { 67 74 void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) { … … 76 83 out.push_back( i->expr->clone() ); 77 84 } 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 85 } 87 86 … … 101 100 PruneStruct current( candidate ); 102 101 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();102 { 103 Type * newType = candidate->expr->get_result()->clone(); 105 104 candidate->env.apply( newType ); 106 mangleName += SymTab::Mangler::mangle( newType );105 mangleName = SymTab::Mangler::mangle( newType ); 107 106 delete newType; 108 107 } … … 133 132 if ( ! target->second.isAmbiguous ) { 134 133 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 } 134 alt.env.applyFree( alt.expr->get_result() ); 138 135 *out++ = alt; 139 136 } 140 137 } 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 138 } 170 139 171 140 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 } 141 expr->get_result()->accept( global_renamer ); 175 142 } 176 143 } … … 204 171 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 205 172 if ( adjust ) { 206 adjustExprType List( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );173 adjustExprType( i->expr->get_result(), i->env, indexer ); 207 174 } 208 175 } … … 241 208 242 209 template< typename StructOrUnionType > 243 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ) { 210 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 211 212 // by this point, member must be a name expr 213 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); 214 const std::string & name = nameExpr->get_name(); 244 215 std::list< Declaration* > members; 245 216 aggInst->lookup( name, members ); … … 254 225 } 255 226 227 void AlternativeFinder::addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 228 if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) { 229 // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning 230 // xxx - this should be improved by memoizing the value of constant exprs 231 // during parsing and reusing that information here. 232 std::stringstream ss( constantExpr->get_constant()->get_value() ); 233 int val; 234 std::string tmp; 235 if ( ss >> val && ! (ss >> tmp) ) { 236 if ( val >= 0 && (unsigned int)val < tupleType->size() ) { 237 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 238 } // if 239 } // if 240 } // if 241 } 242 256 243 void AlternativeFinder::visit( ApplicationExpr *applicationExpr ) { 257 244 alternatives.push_back( Alternative( applicationExpr->clone(), env, Cost::zero ) ); … … 259 246 260 247 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 ); 248 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr ); 249 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 250 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 267 251 268 252 Cost convCost( 0, 0, 0 ); … … 270 254 std::list< DeclarationWithType* >::iterator formal = formals.begin(); 271 255 std::list< Expression* >& actuals = appExpr->get_args(); 256 257 std::list< Type * > formalTypes; 258 std::list< Type * >::iterator formalType = formalTypes.end(); 259 272 260 for ( std::list< Expression* >::iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 261 273 262 PRINT( 274 263 std::cerr << "actual expression:" << std::endl; 275 264 (*actualExpr)->print( std::cerr, 8 ); 276 265 std::cerr << "--- results are" << std::endl; 277 printAll( (*actualExpr)->get_results(),std::cerr, 8 );266 (*actualExpr)->get_result()->print( std::cerr, 8 ); 278 267 ) 279 268 std::list< DeclarationWithType* >::iterator startFormal = formal; 280 269 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; 270 std::list< Type * > flatActualTypes; 271 flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) ); 272 for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) { 273 274 275 // tuple handling code 276 if ( formalType == formalTypes.end() ) { 277 // the type of the formal parameter may be a tuple type. To make this easier to work with, 278 // flatten the tuple type and traverse the resulting list of types, incrementing the formal 279 // iterator once its types have been extracted. Once a particular formal parameter's type has 280 // been exhausted load the next formal parameter's type. 281 if ( formal == formals.end() ) { 282 if ( function->get_isVarArgs() ) { 283 convCost += Cost( 1, 0, 0 ); 284 break; 285 } else { 286 return Cost::infinity; 287 } 288 288 } 289 formalTypes.clear(); 290 flatten( (*formal)->get_type(), back_inserter( formalTypes ) ); 291 formalType = formalTypes.begin(); 292 ++formal; 289 293 } 294 290 295 PRINT( 291 296 std::cerr << std::endl << "converting "; 292 (*actual )->print( std::cerr, 8 );297 (*actualType)->print( std::cerr, 8 ); 293 298 std::cerr << std::endl << " to "; 294 299 (*formal)->get_type()->print( std::cerr, 8 ); 295 300 ) 296 Cost newCost = conversionCost( *actual , (*formal)->get_type(), indexer, alt.env );301 Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env ); 297 302 PRINT( 298 303 std::cerr << std::endl << "cost is" << newCost << std::endl; … … 305 310 actualCost += newCost; 306 311 307 convCost += Cost( 0, polyCost( (*formal)->get_type(), alt.env, indexer ) + polyCost( *actual, alt.env, indexer ), 0 );308 309 formal ++;312 convCost += Cost( 0, polyCost( *formalType, alt.env, indexer ) + polyCost( *actualType, alt.env, indexer ), 0 ); 313 314 formalType++; 310 315 } 311 316 if ( actualCost != Cost( 0, 0, 0 ) ) { … … 356 361 /// Adds type variables to the open variable set and marks their assertions 357 362 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 ) {363 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 359 364 unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind(); 360 365 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) { … … 365 370 } 366 371 367 bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave ) { 372 /// instantiate a single argument by matching actuals from [actualIt, actualEnd) against formalType, 373 /// producing expression(s) in out and their total cost in cost. 374 template< typename AltIterator, typename OutputIterator > 375 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 ) { 376 if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) { 377 // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType 378 TupleExpr * tupleExpr = new TupleExpr(); 379 for ( Type * type : *tupleType ) { 380 if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs() ) ) ) { 381 delete tupleExpr; 382 return false; 383 } 384 } 385 tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) ); 386 *out++ = tupleExpr; 387 } else if ( actualIt != actualEnd ) { 388 // both actualType and formalType are atomic (non-tuple) types - if they unify 389 // then accept actual as an argument, otherwise return false (fail to instantiate argument) 390 Expression * actual = actualIt->expr; 391 Type * actualType = actual->get_result(); 392 PRINT( 393 std::cerr << "formal type is "; 394 formalType->print( std::cerr ); 395 std::cerr << std::endl << "actual type is "; 396 actualType->print( std::cerr ); 397 std::cerr << std::endl; 398 ) 399 if ( ! unify( formalType, actualType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 400 return false; 401 } 402 // move the expression from the alternative to the output iterator 403 *out++ = actual; 404 actualIt->expr = nullptr; 405 cost += actualIt->cost; 406 ++actualIt; 407 } else { 408 // End of actuals - Handle default values 409 if ( SingleInit *si = dynamic_cast<SingleInit *>( defaultValue )) { 410 // so far, only constant expressions are accepted as default values 411 if ( ConstantExpr *cnstexpr = dynamic_cast<ConstantExpr *>( si->get_value()) ) { 412 if ( Constant *cnst = dynamic_cast<Constant *>( cnstexpr->get_constant() ) ) { 413 if ( unify( formalType, cnst->get_type(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 414 // xxx - Don't know if this is right 415 *out++ = cnstexpr->clone(); 416 return true; 417 } // if 418 } // if 419 } // if 420 } // if 421 return false; 422 } // if 423 return true; 424 } 425 426 bool AlternativeFinder::instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ) { 368 427 simpleCombineEnvironments( actuals.begin(), actuals.end(), resultEnv ); 369 428 // make sure we don't widen any existing bindings … … 373 432 resultEnv.extractOpenVars( openVars ); 374 433 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; 434 // flatten actuals so that each actual has an atomic (non-tuple) type 435 AltList exploded; 436 Tuples::explode( actuals, back_inserter( exploded ) ); 437 438 AltList::iterator actualExpr = exploded.begin(); 439 AltList::iterator actualEnd = exploded.end(); 440 for ( DeclarationWithType * formal : formals ) { 441 // match flattened actuals with formal parameters - actuals will be grouped to match 442 // with formals as appropriate 443 Cost cost; 444 std::list< Expression * > newExprs; 445 ObjectDecl * obj = safe_dynamic_cast< ObjectDecl * >( formal ); 446 if ( ! instantiateArgument( obj->get_type(), obj->get_init(), actualExpr, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( newExprs ) ) ) { 447 deleteAll( newExprs ); 448 return false; 449 } 450 // success - produce argument as a new alternative 451 assert( newExprs.size() == 1 ); 452 out.push_back( Alternative( newExprs.front(), resultEnv, cost ) ); 453 } 454 if ( actualExpr != actualEnd ) { 455 // there are still actuals remaining, but we've run out of formal parameters to match against 456 // this is okay only if the function is variadic 457 if ( ! isVarArgs ) { 458 return false; 459 } 460 out.splice( out.end(), exploded, actualExpr, actualEnd ); 416 461 } 417 462 return true; … … 500 545 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 501 546 Expression *varExpr = new VariableExpr( candDecl ); 502 deleteAll( varExpr->get_results() ); 503 varExpr->get_results().clear(); 504 varExpr->get_results().push_front( adjType->clone() ); 547 delete varExpr->get_result(); 548 varExpr->set_result( adjType->clone() ); 505 549 PRINT( 506 550 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; … … 545 589 546 590 template< typename OutputIterator > 547 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out ) {591 void AlternativeFinder::makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ) { 548 592 OpenVarSet openVars; 549 593 AssertionSet resultNeed, resultHave; 550 594 TypeEnvironment resultEnv; 551 595 makeUnifiableVars( funcType, openVars, resultNeed ); 552 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave ) ) { 596 AltList instantiatedActuals; // filled by instantiate function 597 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) { 553 598 ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() ); 554 Alternative newAlt( appExpr, resultEnv, sumCost( actualAlt) );555 makeExprList( actualAlt, appExpr->get_args() );599 Alternative newAlt( appExpr, resultEnv, sumCost( instantiatedActuals ) ); 600 makeExprList( instantiatedActuals, appExpr->get_args() ); 556 601 PRINT( 557 602 std::cerr << "need assertions:" << std::endl; … … 574 619 PointerType pt( Type::Qualifiers(), v.clone() ); 575 620 UntypedExpr *vexpr = untypedExpr->clone(); 576 vexpr-> get_results().push_front( pt.clone() );621 vexpr->set_result( pt.clone() ); 577 622 alternatives.push_back( Alternative( vexpr, env, Cost()) ); 578 623 return; … … 587 632 combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) ); 588 633 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 ... 634 // take care of possible tuple assignments 635 // if not tuple assignment, assignment is taken care of as a normal function call 636 Tuples::handleTupleAssignment( *this, untypedExpr, possibilities ); 594 637 595 638 AltList candidates; … … 604 647 // check if the type is pointer to function 605 648 PointerType *pointer; 606 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {649 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) { 607 650 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 608 651 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 640 683 // check if the type is pointer to function 641 684 PointerType *pointer; 642 if ( funcOp->expr->get_results().size() == 1 643 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 685 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) { 644 686 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 645 687 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 665 707 666 708 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 ); 709 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr ); 710 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 711 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 673 712 std::cerr << "Case +++++++++++++" << std::endl; 674 713 std::cerr << "formals are:" << std::endl; … … 692 731 693 732 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; 733 // xxx - recurse into tuples? 734 return expr->has_result() && expr->get_result()->get_isLvalue(); 698 735 } 699 736 … … 709 746 710 747 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 748 Type *& toType = castExpr->get_result(); 749 toType = resolveTypeof( toType, indexer ); 750 SymTab::validateType( toType, &indexer ); 751 adjustExprType( toType, env, indexer ); 716 752 717 753 AlternativeFinder finder( indexer, env ); … … 727 763 // that are cast directly. The candidate is invalid if it has fewer results than there are types to cast 728 764 // to. 729 int discardedValues = (*i).expr->get_result s().size() - castExpr->get_results().size();765 int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size(); 730 766 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() ); 767 // xxx - may need to go into tuple types and extract relavent types and use unifyList 733 768 // 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 ); 769 unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer ); 770 Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env ); 740 771 if ( thisCost != Cost::infinity ) { 741 772 // count one safe conversion for each value that is thrown away … … 760 791 761 792 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 } // if793 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) { 794 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 795 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) { 796 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 797 } else if ( TupleType * tupleType = dynamic_cast< TupleType * >( agg->expr->get_result() ) ) { 798 addTupleMembers( tupleType, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 768 799 } // if 769 800 } // for … … 791 822 renameTypes( alternatives.back().expr ); 792 823 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) { 793 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 824 NameExpr nameExpr( "" ); 825 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 794 826 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) { 795 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, "" ); 827 NameExpr nameExpr( "" ); 828 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 796 829 } // if 797 830 } // for … … 894 927 alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) ); 895 928 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() );929 alternatives.back().expr->set_result( (*i)->get_type()->clone() ); 897 930 } // for 898 931 } // if … … 917 950 finder.find( attrExpr->get_expr() ); 918 951 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 );952 if ( choice->expr->get_result()->size() == 1 ) { 953 resolveAttr(*i, function, choice->expr->get_result(), choice->env ); 921 954 } // fi 922 955 } // for … … 960 993 AssertionSet needAssertions, haveAssertions; 961 994 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) ) {995 Type* commonType; 996 if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 964 997 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 998 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() ); 974 999 newAlt.expr = newExpr; 975 1000 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 999 1024 TupleExpr *newExpr = new TupleExpr; 1000 1025 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 1026 newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) ); 1006 1027 1007 1028 TypeEnvironment compositeEnv; … … 1024 1045 } 1025 1046 } 1047 1048 void AlternativeFinder::visit( TupleIndexExpr *tupleExpr ) { 1049 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) ); 1050 } 1051 1052 void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) { 1053 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) ); 1054 } 1055 1056 void AlternativeFinder::visit( UniqueExpr *unqExpr ) { 1057 AlternativeFinder finder( indexer, env ); 1058 finder.findWithAdjustment( unqExpr->get_expr() ); 1059 for ( Alternative & alt : finder.alternatives ) { 1060 // xxx - it's possible that this won't always do the right thing, i.e. two UniqueExprs 1061 // with the same ID may resolve to different expressions. If this ever happens, it might be necessary 1062 // to try to select an alternative here (i.e. error is there is not a unique min-cost expression). 1063 // One other thought is to to resolve each ID once and map the IDs to resolved expressions, 1064 // but this isn't as simple as it sounds since the alternative is not selected here, meaning it might 1065 // require complicated tracking throughout the system. 1066 1067 // brand the new UniqueExprs with the same id so that they are recognized as the same expression by the expansion pass 1068 alternatives.push_back( Alternative( new UniqueExpr( alt.expr->clone(), unqExpr->get_id() ), env, Cost::zero ) ); 1069 } 1070 } 1071 1026 1072 } // namespace ResolvExpr 1027 1073 -
src/ResolvExpr/AlternativeFinder.h
rfe7b281 ra1e67dd 67 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 68 virtual void visit( ConstructorExpr * ctorExpr ); 69 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 69 virtual void visit( TupleIndexExpr *tupleExpr ); 70 virtual void visit( TupleAssignExpr *tupleExpr ); 71 virtual void visit( UniqueExpr *unqExpr ); 72 /// Runs a new alternative finder on each element in [begin, end) 73 /// and writes each alternative finder to out. 70 74 template< typename InputIterator, typename OutputIterator > 71 75 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 72 76 73 private:74 77 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 75 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name ); 78 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 79 /// Adds alternatives for member expressions where the left side has tuple type 80 void addTupleMembers( TupleType * tupleType, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 76 81 /// Adds alternatives for offsetof expressions, given the base type and name of the member 77 82 template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name ); 78 bool instantiateFunction( std::list< DeclarationWithType* >& formals, /*const*/ AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave);83 bool instantiateFunction( std::list< DeclarationWithType* >& formals, const AltList &actuals, bool isVarArgs, OpenVarSet& openVars, TypeEnvironment &resultEnv, AssertionSet &resultNeed, AssertionSet &resultHave, AltList & out ); 79 84 template< typename OutputIterator > 80 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, AltList &actualAlt, OutputIterator out );85 void makeFunctionAlternatives( const Alternative &func, FunctionType *funcType, const AltList &actualAlt, OutputIterator out ); 81 86 template< typename OutputIterator > 82 87 void inferParameters( const AssertionSet &need, AssertionSet &have, const Alternative &newAlt, OpenVarSet &openVars, OutputIterator out ); … … 89 94 90 95 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 96 97 template< typename InputIterator, typename OutputIterator > 98 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 99 AltList alternatives; 100 101 // select the alternatives that have the minimum parameter cost 102 Cost minCost = Cost::infinity; 103 for ( InputIterator i = begin; i != end; ++i ) { 104 if ( i->cost < minCost ) { 105 minCost = i->cost; 106 i->cost = i->cvtCost; 107 alternatives.clear(); 108 alternatives.push_back( *i ); 109 } else if ( i->cost == minCost ) { 110 i->cost = i->cvtCost; 111 alternatives.push_back( *i ); 112 } 113 } 114 std::copy( alternatives.begin(), alternatives.end(), out ); 115 } 116 117 Cost sumCost( const AltList &in ); 118 119 template< typename InputIterator > 120 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { 121 while ( begin != end ) { 122 result.simpleCombine( (*begin++).env ); 123 } 124 } 91 125 } // namespace ResolvExpr 92 126 -
src/ResolvExpr/AlternativePrinter.cc
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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" … … 37 38 38 39 virtual void visit( FunctionDecl *functionDecl ); 39 virtual void visit( ObjectDecl * functionDecl );40 virtual void visit( ObjectDecl *objectDecl ); 40 41 virtual void visit( TypeDecl *typeDecl ); 41 42 virtual void visit( EnumDecl * enumDecl ); … … 67 68 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 68 69 void fallbackInit( ConstructorInit * ctorInit ); 69 std::list< Type * >functionReturn;70 Type * functionReturn; 70 71 Type *initContext; 71 72 Type *switchType; … … 157 158 const TypeEnvironment *newEnv = 0; 158 159 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() ) ) {160 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) { 160 161 if ( newExpr ) { 161 162 throw SemanticError( "Too many interpretations for case control expression", untyped ); … … 234 235 Type *new_type = resolveTypeof( functionDecl->get_type(), *this ); 235 236 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 237 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 238 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 241 239 SymTab::Indexer::visit( functionDecl ); 242 functionReturn = oldFunctionReturn;243 240 } 244 241 … … 338 335 void Resolver::visit( ReturnStmt *returnStmt ) { 339 336 if ( returnStmt->get_expr() ) { 340 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() ); 341 cloneAll( functionReturn, castExpr->get_results() ); 337 CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() ); 342 338 Expression *newExpr = findSingleExpression( castExpr, *this ); 343 339 delete castExpr; … … 384 380 if ( isCharType( at->get_base() ) ) { 385 381 // check if the resolved type is char * 386 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result s().front() ) ) {382 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) { 387 383 if ( isCharType( pt->get_base() ) ) { 388 384 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; … … 446 442 (*iter)->accept( *this ); 447 443 } // for 444 } else if ( TupleType * tt = dynamic_cast< TupleType * > ( initContext ) ) { 445 for ( Type * t : *tt ) { 446 if ( iter == end ) break; 447 initContext = t; 448 (*iter++)->accept( *this ); 449 } 448 450 } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) { 449 451 resolveAggrInit( st->get_baseStruct(), iter, end ); -
src/ResolvExpr/TypeEnvironment.cc
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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* ), 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 } 592 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), id( other.id ) { 593 } 594 UniqueExpr::~UniqueExpr() { 595 if ( expr.unique() ) { 596 delete *expr; 597 } 598 } 599 void UniqueExpr::print( std::ostream &os, int indent ) const { 600 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' ); 601 get_expr()->print( os, indent+2 ); 565 602 } 566 603 -
src/SynTree/Expression.h
rfe7b281 ra1e67dd 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 int get_id() const { return id; } 745 746 virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); } 747 virtual void accept( Visitor &v ) { v.visit( this ); } 748 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 749 virtual void print( std::ostream &os, int indent = 0 ) const; 750 private: 751 std::shared_ptr< Expression * > expr; 752 int id; 753 static long long count; 672 754 }; 673 755 -
src/SynTree/Initializer.h
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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, 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(), 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
rfe7b281 ra1e67dd 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
rfe7b281 ra1e67dd 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.