Changeset c331406
- Timestamp:
- Aug 5, 2016, 11:03:04 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- a2f920f
- Parents:
- 5070fe4 (diff), 1b0020a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 2 deleted
- 60 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/aaron_comp_II/comp_II.tex
r5070fe4 rc331406 156 156 157 157 forall(otype M | has_magnitude(M)) 158 int sgn( M m ) {158 M abs( M m ) { 159 159 M zero = 0; // uses zero_t constructor from trait 160 if ( m < zero ) return -1; 161 if ( zero < m ) return 1; 162 return 0; 163 } 164 165 // TODO write another function 166 \end{lstlisting} 160 return m < zero ? -m : m; 161 } 162 163 forall(otype M | has_magnitude(M)) 164 M max_magnitude( M a, M b ) { 165 M aa = abs(a), ab = abs(b); 166 return aa < ab ? b : a; 167 } 168 \end{lstlisting} 169 170 Semantically, a trait is merely a named list of type assertions, but they can be used in many of the same situations where an interface in Java or an abstract base class in \CC would be used. 171 Unlike Java interfaces or \CC base classes, \CFA types do not explicitly state any inheritance relationship to traits they satisfy; this can be considered a form of structural inheritance, similar to interface implementation in Go, as opposed to the nominal inheritance model of Java and \CC. 172 % TODO talk about modelling of nominal inheritance with structural inheritance, possibility of investigating some resolver algorithms that require nominal 167 173 168 174 \subsection{Name Overloading} -
src/CodeGen/CodeGenerator.cc
r5070fe4 rc331406 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : 12 // Last Modified On : Sun Jul 31 08:42:18201613 // Update Count : 3 4511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 4 13:35:30 2016 13 // Update Count : 352 14 14 // 15 15 … … 48 48 } 49 49 50 void CodeGenerator::extension( Expression * expr ) {50 void CodeGenerator::extension( Expression * expr ) { 51 51 if ( expr->get_extension() ) { 52 52 output << "__extension__ "; … … 54 54 } // extension 55 55 56 void CodeGenerator::extension( Declaration * decl ) {56 void CodeGenerator::extension( Declaration * decl ) { 57 57 if ( decl->get_extension() ) { 58 58 output << "__extension__ "; … … 73 73 } 74 74 75 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter & printLabels ) {75 ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter & printLabels ) { 76 76 std::list< Label > & labs = *printLabels.labels; 77 77 // l.unique(); // assumes a sorted list. Why not use set? Does order matter? … … 79 79 output << l.get_name() + ": "; 80 80 printLabels.cg.genAttributes( l.get_attributes() ); 81 } 81 } // for 82 82 return output; 83 83 } 84 84 85 CodeGenerator::CodeGenerator( std::ostream & os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {}86 87 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )85 CodeGenerator::CodeGenerator( std::ostream & os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {} 86 87 CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp ) 88 88 : indent( *this), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 89 89 //output << std::string( init ); 90 90 } 91 91 92 CodeGenerator::CodeGenerator( std::ostream & os, char *init, int indentation, bool infunp )92 CodeGenerator::CodeGenerator( std::ostream & os, char * init, int indentation, bool infunp ) 93 93 : indent( *this ), cur_indent( indentation ), insideFunction( infunp ), output( os ), printLabels( *this ) { 94 94 //output << std::string( init ); 95 95 } 96 96 97 string mangleName( DeclarationWithType * decl ) {97 string mangleName( DeclarationWithType * decl ) { 98 98 if ( decl->get_mangleName() != "" ) { 99 99 // need to incorporate scope level in order to differentiate names for destructors … … 112 112 genCommaList( attr->get_parameters().begin(), attr->get_parameters().end() ); 113 113 output << ")"; 114 } 114 } // if 115 115 output << ","; 116 } 116 } // for 117 117 output << ")) "; 118 } 118 } // if 119 119 } 120 120 121 121 122 122 //*** Declarations 123 void CodeGenerator::visit( FunctionDecl * functionDecl ) {123 void CodeGenerator::visit( FunctionDecl * functionDecl ) { 124 124 extension( functionDecl ); 125 125 genAttributes( functionDecl->get_attributes() ); … … 146 146 } 147 147 148 void CodeGenerator::visit( ObjectDecl * objectDecl ) {148 void CodeGenerator::visit( ObjectDecl * objectDecl ) { 149 149 extension( objectDecl ); 150 genAttributes( objectDecl->get_attributes() ); 151 150 152 handleStorageClass( objectDecl ); 151 153 output << genType( objectDecl->get_type(), mangleName( objectDecl ) ); … … 162 164 } 163 165 164 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) {166 void CodeGenerator::handleAggregate( AggregateDecl * aggDecl ) { 165 167 if ( aggDecl->get_name() != "" ) 166 168 output << aggDecl->get_name(); 167 169 168 std::list< Declaration * > & memb = aggDecl->get_members();170 std::list< Declaration * > & memb = aggDecl->get_members(); 169 171 if ( ! memb.empty() ) { 170 172 // if ( aggDecl->has_body() ) { 171 // std::list< Declaration * > & memb = aggDecl->get_members();173 // std::list< Declaration * > & memb = aggDecl->get_members(); 172 174 output << " {" << endl; 173 175 … … 185 187 } 186 188 187 void CodeGenerator::visit( StructDecl * structDecl ) {189 void CodeGenerator::visit( StructDecl * structDecl ) { 188 190 extension( structDecl ); 189 191 output << "struct "; … … 191 193 } 192 194 193 void CodeGenerator::visit( UnionDecl * unionDecl ) {195 void CodeGenerator::visit( UnionDecl * unionDecl ) { 194 196 extension( unionDecl ); 195 197 output << "union "; … … 197 199 } 198 200 199 void CodeGenerator::visit( EnumDecl * enumDecl ) {201 void CodeGenerator::visit( EnumDecl * enumDecl ) { 200 202 extension( enumDecl ); 201 203 output << "enum "; … … 211 213 cur_indent += CodeGenerator::tabsize; 212 214 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 213 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );215 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); 214 216 assert( obj ); 215 217 output << indent << mangleName( obj ); … … 227 229 } 228 230 229 void CodeGenerator::visit( TraitDecl * traitDecl ) {}230 231 void CodeGenerator::visit( TypedefDecl * typeDecl ) {231 void CodeGenerator::visit( TraitDecl * traitDecl ) {} 232 233 void CodeGenerator::visit( TypedefDecl * typeDecl ) { 232 234 assert( false && "Typedefs are removed and substituted in earlier passes." ); 233 235 //output << "typedef "; … … 235 237 } 236 238 237 void CodeGenerator::visit( TypeDecl * typeDecl ) {239 void CodeGenerator::visit( TypeDecl * typeDecl ) { 238 240 // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes, 239 241 // still to be done … … 263 265 } 264 266 265 void CodeGenerator::visit( SingleInit * init ) {267 void CodeGenerator::visit( SingleInit * init ) { 266 268 printDesignators( init->get_designators() ); 267 269 init->get_value()->accept( *this ); 268 270 } 269 271 270 void CodeGenerator::visit( ListInit * init ) {272 void CodeGenerator::visit( ListInit * init ) { 271 273 printDesignators( init->get_designators() ); 272 274 output << "{ "; 273 if ( init->begin _initializers() == init->end_initializers() ) {275 if ( init->begin() == init->end() ) { 274 276 // illegal to leave initializer list empty for scalar initializers, but always legal to have 0 275 277 output << "0"; 276 278 } else { 277 genCommaList( init->begin _initializers(), init->end_initializers() );278 } 279 genCommaList( init->begin(), init->end() ); 280 } // if 279 281 output << " }"; 280 282 } 281 283 282 void CodeGenerator::visit( Constant * constant ) {284 void CodeGenerator::visit( Constant * constant ) { 283 285 output << constant->get_value() ; 284 286 } 285 287 286 288 //*** Expressions 287 void CodeGenerator::visit( ApplicationExpr * applicationExpr ) {289 void CodeGenerator::visit( ApplicationExpr * applicationExpr ) { 288 290 extension( applicationExpr ); 289 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {291 if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) { 290 292 OperatorInfo opInfo; 291 293 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( varExpr->get_var()->get_name(), opInfo ) ) { … … 299 301 { 300 302 assert( arg != applicationExpr->get_args().end() ); 301 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) {303 if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 302 304 // remove & from first assignment/ctor argument 303 305 *arg = addrExpr->get_arg(); 304 306 } else { 305 307 // no address-of operator, so must be a pointer - add dereference 306 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) );308 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 307 309 newExpr->get_args().push_back( *arg ); 308 310 assert( (*arg)->get_results().size() == 1 ); … … 352 354 // no constructors with 0 or more than 2 parameters 353 355 assert( false ); 354 } 356 } // if 355 357 break; 356 358 … … 401 403 } 402 404 403 void CodeGenerator::visit( UntypedExpr * untypedExpr ) {405 void CodeGenerator::visit( UntypedExpr * untypedExpr ) { 404 406 extension( untypedExpr ); 405 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {407 if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) { 406 408 OperatorInfo opInfo; 407 409 if ( operatorLookup( nameExpr->get_name(), opInfo ) ) { … … 472 474 } // switch 473 475 } else { 474 if ( nameExpr->get_name() == " Range" ) { // case V1 ... V2 or case V1~V2476 if ( nameExpr->get_name() == "..." ) { // case V1 ... V2 or case V1~V2 475 477 assert( untypedExpr->get_args().size() == 2 ); 476 478 (*untypedExpr->get_args().begin())->accept( *this ); … … 492 494 } 493 495 494 void CodeGenerator::visit( NameExpr *nameExpr ) { 496 void CodeGenerator::visit( RangeExpr * rangeExpr ) { 497 rangeExpr->get_low()->accept( *this ); 498 output << " ... "; 499 rangeExpr->get_high()->accept( *this ); 500 } 501 502 void CodeGenerator::visit( NameExpr * nameExpr ) { 495 503 extension( nameExpr ); 496 504 OperatorInfo opInfo; … … 503 511 } 504 512 505 void CodeGenerator::visit( AddressExpr * addressExpr ) {513 void CodeGenerator::visit( AddressExpr * addressExpr ) { 506 514 extension( addressExpr ); 507 515 output << "(&"; 508 516 // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address 509 if ( VariableExpr * variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) {517 if ( VariableExpr * variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) { 510 518 output << mangleName( variableExpr->get_var() ); 511 519 } else { … … 515 523 } 516 524 517 void CodeGenerator::visit( CastExpr * castExpr ) {525 void CodeGenerator::visit( CastExpr * castExpr ) { 518 526 extension( castExpr ); 519 527 output << "("; … … 533 541 } 534 542 535 void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) {543 void CodeGenerator::visit( UntypedMemberExpr * memberExpr ) { 536 544 assert( false ); 537 545 } 538 546 539 void CodeGenerator::visit( MemberExpr * memberExpr ) {547 void CodeGenerator::visit( MemberExpr * memberExpr ) { 540 548 extension( memberExpr ); 541 549 memberExpr->get_aggregate()->accept( *this ); … … 543 551 } 544 552 545 void CodeGenerator::visit( VariableExpr * variableExpr ) {553 void CodeGenerator::visit( VariableExpr * variableExpr ) { 546 554 extension( variableExpr ); 547 555 OperatorInfo opInfo; … … 553 561 } 554 562 555 void CodeGenerator::visit( ConstantExpr * constantExpr ) {563 void CodeGenerator::visit( ConstantExpr * constantExpr ) { 556 564 assert( constantExpr->get_constant() ); 557 565 extension( constantExpr ); … … 559 567 } 560 568 561 void CodeGenerator::visit( SizeofExpr * sizeofExpr ) {569 void CodeGenerator::visit( SizeofExpr * sizeofExpr ) { 562 570 extension( sizeofExpr ); 563 571 output << "sizeof("; … … 570 578 } 571 579 572 void CodeGenerator::visit( AlignofExpr * alignofExpr ) {580 void CodeGenerator::visit( AlignofExpr * alignofExpr ) { 573 581 // use GCC extension to avoid bumping std to C11 574 582 extension( alignofExpr ); … … 582 590 } 583 591 584 void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) {592 void CodeGenerator::visit( UntypedOffsetofExpr * offsetofExpr ) { 585 593 assert( false && "UntypedOffsetofExpr should not reach code generation." ); 586 594 } 587 595 588 void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) {596 void CodeGenerator::visit( OffsetofExpr * offsetofExpr ) { 589 597 // use GCC builtin 590 598 output << "__builtin_offsetof("; … … 594 602 } 595 603 596 void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) {604 void CodeGenerator::visit( OffsetPackExpr * offsetPackExpr ) { 597 605 assert( false && "OffsetPackExpr should not reach code generation." ); 598 606 } 599 607 600 void CodeGenerator::visit( LogicalExpr * logicalExpr ) {608 void CodeGenerator::visit( LogicalExpr * logicalExpr ) { 601 609 extension( logicalExpr ); 602 610 output << "("; … … 611 619 } 612 620 613 void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) {621 void CodeGenerator::visit( ConditionalExpr * conditionalExpr ) { 614 622 extension( conditionalExpr ); 615 623 output << "("; … … 622 630 } 623 631 624 void CodeGenerator::visit( CommaExpr * commaExpr ) {632 void CodeGenerator::visit( CommaExpr * commaExpr ) { 625 633 extension( commaExpr ); 626 634 output << "("; … … 631 639 } 632 640 633 void CodeGenerator::visit( TupleExpr * tupleExpr ) {}634 635 void CodeGenerator::visit( TypeExpr * typeExpr ) {}636 637 void CodeGenerator::visit( AsmExpr * asmExpr ) {641 void CodeGenerator::visit( TupleExpr * tupleExpr ) {} 642 643 void CodeGenerator::visit( TypeExpr * typeExpr ) {} 644 645 void CodeGenerator::visit( AsmExpr * asmExpr ) { 638 646 if ( asmExpr->get_inout() ) { 639 647 output << "[ "; … … 648 656 649 657 //*** Statements 650 void CodeGenerator::visit( CompoundStmt * compoundStmt ) {658 void CodeGenerator::visit( CompoundStmt * compoundStmt ) { 651 659 std::list<Statement*> ks = compoundStmt->get_kids(); 652 660 output << "{" << endl; … … 662 670 output << endl; 663 671 } // if 664 } 672 } // for 665 673 cur_indent -= CodeGenerator::tabsize; 666 674 … … 668 676 } 669 677 670 void CodeGenerator::visit( ExprStmt * exprStmt ) {678 void CodeGenerator::visit( ExprStmt * exprStmt ) { 671 679 assert( exprStmt ); 672 680 // cast the top-level expression to void to reduce gcc warnings. … … 676 684 } 677 685 678 void CodeGenerator::visit( AsmStmt * asmStmt ) {686 void CodeGenerator::visit( AsmStmt * asmStmt ) { 679 687 output << "asm "; 680 688 if ( asmStmt->get_voltile() ) output << "volatile "; … … 699 707 } 700 708 701 void CodeGenerator::visit( IfStmt * ifStmt ) {709 void CodeGenerator::visit( IfStmt * ifStmt ) { 702 710 output << "if ( "; 703 711 ifStmt->get_condition()->accept( *this ); … … 712 720 } 713 721 714 void CodeGenerator::visit( SwitchStmt * switchStmt ) {722 void CodeGenerator::visit( SwitchStmt * switchStmt ) { 715 723 output << "switch ( " ; 716 724 switchStmt->get_condition()->accept( *this ); … … 719 727 output << "{" << std::endl; 720 728 cur_indent += CodeGenerator::tabsize; 721 722 acceptAll( switchStmt->get_branches(), *this ); 723 729 acceptAll( switchStmt->get_statements(), *this ); 724 730 cur_indent -= CodeGenerator::tabsize; 725 726 731 output << indent << "}"; 727 732 } 728 733 729 void CodeGenerator::visit( CaseStmt * caseStmt ) {734 void CodeGenerator::visit( CaseStmt * caseStmt ) { 730 735 output << indent; 731 736 if ( caseStmt->isDefault()) { … … 748 753 } 749 754 750 void CodeGenerator::visit( BranchStmt * branchStmt ) {755 void CodeGenerator::visit( BranchStmt * branchStmt ) { 751 756 switch ( branchStmt->get_type()) { 752 757 case BranchStmt::Goto: … … 771 776 772 777 773 void CodeGenerator::visit( ReturnStmt * returnStmt ) {778 void CodeGenerator::visit( ReturnStmt * returnStmt ) { 774 779 output << "return "; 775 780 maybeAccept( returnStmt->get_expr(), *this ); … … 777 782 } 778 783 779 void CodeGenerator::visit( WhileStmt * whileStmt ) {784 void CodeGenerator::visit( WhileStmt * whileStmt ) { 780 785 if ( whileStmt->get_isDoWhile() ) { 781 786 output << "do" ; … … 799 804 } 800 805 801 void CodeGenerator::visit( ForStmt * forStmt ) {806 void CodeGenerator::visit( ForStmt * forStmt ) { 802 807 // initialization is always hoisted, so don't bother doing anything with that 803 808 output << "for (;"; … … 821 826 } 822 827 823 void CodeGenerator::visit( NullStmt * nullStmt ) {828 void CodeGenerator::visit( NullStmt * nullStmt ) { 824 829 //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() ); 825 830 output << "/* null statement */ ;"; 826 831 } 827 832 828 void CodeGenerator::visit( DeclStmt * declStmt ) {833 void CodeGenerator::visit( DeclStmt * declStmt ) { 829 834 declStmt->get_decl()->accept( *this ); 830 835 … … 834 839 } 835 840 836 void CodeGenerator::handleStorageClass( Declaration * decl ) {841 void CodeGenerator::handleStorageClass( Declaration * decl ) { 837 842 switch ( decl->get_storageClass() ) { 838 843 case DeclarationNode::Extern: -
src/CodeGen/CodeGenerator.h
r5070fe4 rc331406 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 30 11:10:42201613 // Update Count : 3 712 // Last Modified On : Thu Aug 4 13:37:07 2016 13 // Update Count : 38 14 14 // 15 15 … … 54 54 virtual void visit( ApplicationExpr *applicationExpr ); 55 55 virtual void visit( UntypedExpr *untypedExpr ); 56 virtual void visit( RangeExpr * rangeExpr ); 56 57 virtual void visit( NameExpr *nameExpr ); 57 58 virtual void visit( AddressExpr *addressExpr ); -
src/ControlStruct/MLEMutator.cc
r5070fe4 rc331406 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:36:51201613 // Update Count : 19712 // Last Modified On : Thu Aug 4 11:21:32 2016 13 // Update Count : 202 14 14 // 15 15 … … 128 128 Label brkLabel = generator->newLabel("switchBreak"); 129 129 enclosingControlStructures.push_back( Entry(switchStmt, brkLabel) ); 130 mutateAll( switchStmt->get_ branches(), *this );130 mutateAll( switchStmt->get_statements(), *this ); 131 131 132 132 Entry &e = enclosingControlStructures.back(); … … 138 138 // switch should be CastStmts), append the exit label + break to the last case statement; create a default 139 139 // case if there are no cases 140 std::list< Statement * > & branches = switchStmt->get_branches();141 if ( branches.empty() ) {142 branches.push_back( CaseStmt::makeDefault() );143 } // if 144 145 if ( CaseStmt * c = dynamic_cast< CaseStmt * >( branches.back() ) ) {140 std::list< Statement * > &statements = switchStmt->get_statements(); 141 if ( statements.empty() ) { 142 statements.push_back( CaseStmt::makeDefault() ); 143 } // if 144 145 if ( CaseStmt * c = dynamic_cast< CaseStmt * >( statements.back() ) ) { 146 146 std::list<Label> temp; temp.push_back( brkLabel ); 147 147 c->get_statements().push_back( new BranchStmt( temp, Label("brkLabel"), BranchStmt::Break ) ); 148 } else assert(0); // as of this point, all branches of a switch are still CaseStmts148 } else assert(0); // as of this point, all statements of a switch are still CaseStmts 149 149 } // if 150 150 -
src/ControlStruct/Mutate.cc
r5070fe4 rc331406 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:37:45201613 // Update Count : 812 // Last Modified On : Thu Aug 4 11:39:08 2016 13 // Update Count : 9 14 14 // 15 15 … … 22 22 #include "LabelFixer.h" 23 23 #include "MLEMutator.h" 24 #include "CaseRangeMutator.h"25 24 #include "ForExprMutator.h" 26 25 #include "LabelTypeChecker.h" … … 41 40 LabelFixer lfix; 42 41 43 // expand case ranges and turn fallthru into a null statement44 CaseRangeMutator ranges;45 46 42 //ExceptMutator exc; 47 43 // LabelTypeChecker lbl; … … 49 45 mutateAll( translationUnit, formut ); 50 46 acceptAll( translationUnit, lfix ); 51 mutateAll( translationUnit, ranges );52 47 //mutateAll( translationUnit, exc ); 53 48 //acceptAll( translationUnit, lbl ); -
src/ControlStruct/module.mk
r5070fe4 rc331406 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : T ue Jul 12 17:40:31201614 ## Update Count : 213 ## Last Modified On : Thu Aug 4 11:38:06 2016 14 ## Update Count : 3 15 15 ############################################################################### 16 16 … … 18 18 ControlStruct/LabelFixer.cc \ 19 19 ControlStruct/MLEMutator.cc \ 20 ControlStruct/CaseRangeMutator.cc \21 20 ControlStruct/Mutate.cc \ 22 21 ControlStruct/ForExprMutator.cc \ -
src/GenPoly/DeclMutator.cc
r5070fe4 rc331406 10 10 // Created On : Fri Nov 27 14:44:00 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:38:46201613 // Update Count : 212 // Last Modified On : Thu Aug 4 11:16:43 2016 13 // Update Count : 3 14 14 // 15 15 … … 163 163 Statement* DeclMutator::mutate(SwitchStmt *switchStmt) { 164 164 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 165 mutateAll( switchStmt->get_ branches(), *this );165 mutateAll( switchStmt->get_statements(), *this ); 166 166 return switchStmt; 167 167 } -
src/GenPoly/DeclMutator.h
r5070fe4 rc331406 28 28 class DeclMutator : public Mutator { 29 29 public: 30 typedef Mutator Parent; 31 30 32 DeclMutator(); 31 33 virtual ~DeclMutator(); 32 34 35 using Parent::mutate; 33 36 virtual CompoundStmt* mutate(CompoundStmt *compoundStmt); 34 37 virtual Statement* mutate(IfStmt *ifStmt); … … 42 45 /// Mutates a list of declarations with this visitor 43 46 void mutateDeclarationList(std::list< Declaration* >& decls); 44 47 45 48 /// Called on entry to a new scope; overriders should call this as a super-class call 46 49 virtual void doBeginScope(); -
src/GenPoly/PolyMutator.cc
r5070fe4 rc331406 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:39:32 201613 // Update Count : 1 212 // Last Modified On : Thu Aug 4 11:26:22 2016 13 // Update Count : 16 14 14 // 15 15 … … 99 99 100 100 Statement * PolyMutator::mutate(SwitchStmt *switchStmt) { 101 mutateStatementList( switchStmt->get_ branches() );101 mutateStatementList( switchStmt->get_statements() ); 102 102 switchStmt->set_condition( mutateExpression( switchStmt->get_condition() ) ); 103 103 return switchStmt; -
src/GenPoly/Specialize.cc
r5070fe4 rc331406 31 31 #include "Common/UniqueName.h" 32 32 #include "Common/utility.h" 33 #include "InitTweak/InitTweak.h" 33 34 34 35 namespace GenPoly { … … 184 185 mutateAll( appExpr->get_args(), *this ); 185 186 186 // create thunks for the inferred parameters 187 for ( InferredParams::iterator inferParam = appExpr->get_inferParams().begin(); inferParam != appExpr->get_inferParams().end(); ++inferParam ) { 188 inferParam->second.expr = doSpecialization( inferParam->second.formalType, inferParam->second.expr, &appExpr->get_inferParams() ); 189 } 190 191 handleExplicitParams( appExpr ); 187 if ( ! InitTweak::isIntrinsicCallExpr( appExpr ) ) { 188 // create thunks for the inferred parameters 189 // don't need to do this for intrinsic calls, because they aren't actually passed 190 for ( InferredParams::iterator inferParam = appExpr->get_inferParams().begin(); inferParam != appExpr->get_inferParams().end(); ++inferParam ) { 191 inferParam->second.expr = doSpecialization( inferParam->second.formalType, inferParam->second.expr, &appExpr->get_inferParams() ); 192 } 193 194 handleExplicitParams( appExpr ); 195 } 192 196 193 197 return appExpr; -
src/InitTweak/FixGlobalInit.cc
r5070fe4 rc331406 46 46 FunctionDecl * destroyFunction; 47 47 }; 48 49 class ConstExprChecker : public Visitor {50 public:51 ConstExprChecker() : isConstExpr( true ) {}52 53 virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; }54 virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; }55 virtual void visit( NameExpr *nameExpr ) { isConstExpr = false; }56 virtual void visit( CastExpr *castExpr ) { isConstExpr = false; }57 virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; }58 virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; }59 virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; }60 virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; }61 virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ }62 // these might be okay?63 // virtual void visit( SizeofExpr *sizeofExpr );64 // virtual void visit( AlignofExpr *alignofExpr );65 // virtual void visit( UntypedOffsetofExpr *offsetofExpr );66 // virtual void visit( OffsetofExpr *offsetofExpr );67 // virtual void visit( OffsetPackExpr *offsetPackExpr );68 // virtual void visit( AttrExpr *attrExpr );69 // virtual void visit( CommaExpr *commaExpr );70 // virtual void visit( LogicalExpr *logicalExpr );71 // virtual void visit( ConditionalExpr *conditionalExpr );72 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; }73 virtual void visit( SolvedTupleExpr *tupleExpr ) { isConstExpr = false; }74 virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; }75 virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; }76 virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; }77 virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; }78 79 bool isConstExpr;80 };81 82 bool isConstExpr( Initializer * init ) {83 if ( init ) {84 ConstExprChecker checker;85 init->accept( checker );86 return checker.isConstExpr;87 } // if88 // for all intents and purposes, no initializer means const expr89 return true;90 }91 48 92 49 void fixGlobalInit( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ) { … … 140 97 std::list< Statement * > & destroyStatements = destroyFunction->get_statements()->get_kids(); 141 98 142 if ( ! tryConstruct( objDecl ) ) return; // don't construct @= or designated objects143 if ( objDecl->get_storageClass() == DeclarationNode::Extern ) return;144 99 // C allows you to initialize objects with constant expressions 145 100 // xxx - this is an optimization. Need to first resolve constructors before we decide … … 147 102 // if ( isConstExpr( objDecl->get_init() ) ) return; 148 103 149 if ( dynamic_cast< ArrayType * > ( objDecl->get_type() ) ) { 150 // xxx - initialize each element of the array 151 } else { 152 // steal initializer from object and attach it to a new temporary 153 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, objDecl->get_type()->clone(), objDecl->get_init() ); 154 objDecl->set_init( NULL ); 155 initStatements.push_back( new DeclStmt( noLabels, newObj ) ); 104 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 105 // a decision should have been made by the resolver, so ctor and init are not both non-NULL 106 assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() ); 156 107 157 // copy construct objDecl using temporary 158 UntypedExpr * init = new UntypedExpr( new NameExpr( "?{}" ) ); 159 init->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) ); 160 init->get_args().push_back( new VariableExpr( newObj ) ); 161 initStatements.push_back( new ImplicitCtorDtorStmt( new ExprStmt( noLabels, init ) ) ); 162 163 // add destructor calls to global destroy function 164 UntypedExpr * destroy = new UntypedExpr( new NameExpr( "^?{}" ) ); 165 destroy->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) ); 166 destroyStatements.push_front( new ImplicitCtorDtorStmt( new ExprStmt( noLabels, destroy ) ) ); 108 Statement * dtor = ctorInit->get_dtor(); 109 if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) { 110 // don't need to call intrinsic dtor, because it does nothing, but 111 // non-intrinsic dtors must be called 112 destroyStatements.push_front( dtor ); 113 ctorInit->set_dtor( NULL ); 114 } // if 115 if ( Statement * ctor = ctorInit->get_ctor() ) { 116 initStatements.push_back( ctor ); 117 objDecl->set_init( NULL ); 118 ctorInit->set_ctor( NULL ); 119 } else if ( Initializer * init = ctorInit->get_init() ) { 120 objDecl->set_init( init ); 121 ctorInit->set_init( NULL ); 122 } else { 123 // no constructor and no initializer, which is okay 124 objDecl->set_init( NULL ); 125 } // if 126 delete ctorInit; 167 127 } // if 168 128 } -
src/InitTweak/FixInit.cc
r5070fe4 rc331406 18 18 #include <iterator> 19 19 #include <algorithm> 20 #include "InitTweak.h" 20 21 #include "FixInit.h" 21 #include " InitTweak.h"22 #include "FixGlobalInit.h" 22 23 #include "ResolvExpr/Resolver.h" 23 24 #include "ResolvExpr/typeops.h" … … 25 26 #include "SynTree/Type.h" 26 27 #include "SynTree/Expression.h" 28 #include "SynTree/Attribute.h" 27 29 #include "SynTree/Statement.h" 28 30 #include "SynTree/Initializer.h" … … 83 85 }; 84 86 87 // debug 85 88 struct printSet { 86 89 typedef ObjDeclCollector::ObjectSet ObjectSet; … … 159 162 160 163 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ); 164 165 std::list< Declaration * > staticDtorDecls; 161 166 }; 162 167 … … 171 176 } // namespace 172 177 173 void fix( std::list< Declaration * > & translationUnit ) { 178 void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) { 179 // fixes ConstructorInit for global variables. should happen before fixInitializers. 180 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); 181 174 182 InsertImplicitCalls::insert( translationUnit ); 175 183 ResolveCopyCtors::resolveImplicitCalls( translationUnit ); … … 194 202 void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) { 195 203 FixInit fixer; 196 mutateAll( translationUnit, fixer ); 204 205 // can't use mutateAll, because need to insert declarations at top-level 206 // can't use DeclMutator, because sometimes need to insert IfStmt, etc. 207 SemanticError errors; 208 for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) { 209 try { 210 *i = maybeMutate( *i, fixer ); 211 translationUnit.splice( i, fixer.staticDtorDecls ); 212 } catch( SemanticError &e ) { 213 errors.append( e ); 214 } // try 215 } // for 216 if ( ! errors.isEmpty() ) { 217 throw errors; 218 } // if 197 219 } 198 220 … … 422 444 if ( Statement * ctor = ctorInit->get_ctor() ) { 423 445 if ( objDecl->get_storageClass() == DeclarationNode::Static ) { 446 // originally wanted to take advantage of gcc nested functions, but 447 // we get memory errors with this approach. To remedy this, the static 448 // variable is hoisted when the destructor needs to be called. 449 // 424 450 // generate: 425 // static bool __objName_uninitialized = true; 426 // if (__objName_uninitialized) { 427 // __ctor(__objName); 428 // void dtor_atexit() { 429 // __dtor(__objName); 451 // static T __objName_static_varN; 452 // void __objName_dtor_atexitN() { 453 // __dtor__...; 454 // } 455 // int f(...) { 456 // ... 457 // static bool __objName_uninitialized = true; 458 // if (__objName_uninitialized) { 459 // __ctor(__objName); 460 // __objName_uninitialized = false; 461 // atexit(__objName_dtor_atexitN); 430 462 // } 431 // on_exit(dtorOnExit, &__objName); 432 // __objName_uninitialized = false; 463 // ... 433 464 // } 434 465 435 // generate first line 466 static UniqueName dtorCallerNamer( "_dtor_atexit" ); 467 468 // static bool __objName_uninitialized = true 436 469 BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool ); 437 470 SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators ); … … 439 472 isUninitializedVar->fixUniqueId(); 440 473 441 // void dtor_atexit(...) {...}442 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + "_dtor_atexit", DeclarationNode::NoStorageClass, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false );443 dtorCaller->fixUniqueId();444 dtorCaller->get_statements()->get_kids().push_back( ctorInit->get_dtor()->clone() );445 446 // on_exit(dtor_atexit);447 UntypedExpr * callAtexit = new UntypedExpr( new NameExpr( "atexit" ) );448 callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) );449 450 474 // __objName_uninitialized = false; 451 475 UntypedExpr * setTrue = new UntypedExpr( new NameExpr( "?=?" ) ); … … 457 481 std::list< Statement * > & body = initStmts->get_kids(); 458 482 body.push_back( ctor ); 459 body.push_back( new DeclStmt( noLabels, dtorCaller ) );460 body.push_back( new ExprStmt( noLabels, callAtexit ) );461 483 body.push_back( new ExprStmt( noLabels, setTrue ) ); 462 484 … … 465 487 stmtsToAddAfter.push_back( new DeclStmt( noLabels, isUninitializedVar ) ); 466 488 stmtsToAddAfter.push_back( ifStmt ); 489 490 if ( ctorInit->get_dtor() ) { 491 // if the object has a non-trivial destructor, have to 492 // hoist it and the object into the global space and 493 // call the destructor function with atexit. 494 495 Statement * dtorStmt = ctorInit->get_dtor()->clone(); 496 497 // void __objName_dtor_atexitN(...) {...} 498 FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false ); 499 dtorCaller->fixUniqueId(); 500 dtorCaller->get_statements()->get_kids().push_back( dtorStmt ); 501 502 // atexit(dtor_atexit); 503 UntypedExpr * callAtexit = new UntypedExpr( new NameExpr( "atexit" ) ); 504 callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) ); 505 506 body.push_back( new ExprStmt( noLabels, callAtexit ) ); 507 508 // hoist variable and dtor caller decls to list of decls that will be added into global scope 509 staticDtorDecls.push_back( objDecl ); 510 staticDtorDecls.push_back( dtorCaller ); 511 512 // need to rename object uniquely since it now appears 513 // at global scope and there could be multiple function-scoped 514 // static variables with the same name in different functions. 515 static UniqueName staticNamer( "_static_var" ); 516 objDecl->set_mangleName( objDecl->get_mangleName() + staticNamer.newName() ); 517 518 objDecl->set_init( NULL ); 519 ctorInit->set_ctor( NULL ); 520 delete ctorInit; 521 522 // xxx - temporary hack: need to return a declaration, but want to hoist the current object out of this scope 523 // create a new object which is never used 524 static UniqueName dummyNamer( "_dummy" ); 525 ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), DeclarationNode::Static, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } ); 526 return dummy; 527 } 467 528 } else { 468 529 stmtsToAddAfter.push_back( ctor ); … … 524 585 assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() ); 525 586 Statement * dtor = ctorInit->get_dtor(); 526 if ( dtor && ! isIn strinsicSingleArgCallStmt( dtor ) ) {587 if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) { 527 588 // don't need to call intrinsic dtor, because it does nothing, but 528 589 // non-intrinsic dtors must be called -
src/InitTweak/FixInit.h
r5070fe4 rc331406 27 27 /// replace constructor initializers with expression statements 28 28 /// and unwrap basic C-style initializers 29 void fix( std::list< Declaration * > & translationUnit );29 void fix( std::list< Declaration * > & translationUnit, const std::string & name, bool inLibrary ); 30 30 } // namespace 31 31 -
src/InitTweak/GenInit.cc
r5070fe4 rc331406 26 26 #include "SymTab/Autogen.h" 27 27 #include "GenPoly/PolyMutator.h" 28 #include "GenPoly/DeclMutator.h" 28 29 29 30 namespace InitTweak { … … 55 56 public: 56 57 /// create constructor and destructor statements for object declarations. 57 /// Destructors are inserted directly into the code, whereas constructors58 /// will be added in after the resolver has run so that the initializer expression59 /// is only removed if a constructor is found58 /// the actual call statements will be added in after the resolver has run 59 /// so that the initializer expression is only removed if a constructor is found 60 /// and the same destructor call is inserted in all of the appropriate locations. 60 61 static void generateCtorDtor( std::list< Declaration * > &translationUnit ); 61 62 CtorDtor() : inFunction( false ) {}63 62 64 63 virtual DeclarationWithType * mutate( ObjectDecl * ); 65 64 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 66 virtual Declaration* mutate( StructDecl *aggregateDecl ); 67 virtual Declaration* mutate( UnionDecl *aggregateDecl ); 68 virtual Declaration* mutate( EnumDecl *aggregateDecl ); 69 virtual Declaration* mutate( TraitDecl *aggregateDecl ); 70 virtual TypeDecl* mutate( TypeDecl *typeDecl ); 71 virtual Declaration* mutate( TypedefDecl *typeDecl ); 72 73 virtual Type * mutate( FunctionType *funcType ); 65 // should not traverse into any of these declarations to find objects 66 // that need to be constructed or destructed 67 virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; } 68 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; } 69 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; } 70 virtual Declaration* mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; } 71 virtual TypeDecl* mutate( TypeDecl *typeDecl ) { return typeDecl; } 72 virtual Declaration* mutate( TypedefDecl *typeDecl ) { return typeDecl; } 73 74 virtual Type * mutate( FunctionType *funcType ) { return funcType; } 74 75 75 76 protected: 76 bool inFunction; 77 }; 78 79 class HoistArrayDimension : public GenPoly::DeclMutator { 80 public: 81 typedef GenPoly::DeclMutator Parent; 82 83 /// hoist dimension from array types in object declaration so that it uses a single 84 /// const variable of type size_t, so that side effecting array dimensions are only 85 /// computed once. 86 static void hoistArrayDimension( std::list< Declaration * > & translationUnit ); 87 88 private: 89 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ); 90 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 91 // should not traverse into any of these declarations to find objects 92 // that need to be constructed or destructed 93 virtual Declaration* mutate( StructDecl *aggregateDecl ) { return aggregateDecl; } 94 virtual Declaration* mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; } 95 virtual Declaration* mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; } 96 virtual Declaration* mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; } 97 virtual TypeDecl* mutate( TypeDecl *typeDecl ) { return typeDecl; } 98 virtual Declaration* mutate( TypedefDecl *typeDecl ) { return typeDecl; } 99 100 virtual Type* mutate( FunctionType *funcType ) { return funcType; } 101 102 void hoist( Type * type ); 103 104 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass; 105 bool inFunction = false; 77 106 }; 78 107 79 108 void genInit( std::list< Declaration * > & translationUnit ) { 80 109 ReturnFixer::makeReturnTemp( translationUnit ); 110 HoistArrayDimension::hoistArrayDimension( translationUnit ); 81 111 CtorDtor::generateCtorDtor( translationUnit ); 82 112 } … … 124 154 } 125 155 156 // precompute array dimension expression, because constructor generation may duplicate it, 157 // which would be incorrect if it is a side-effecting computation. 158 void HoistArrayDimension::hoistArrayDimension( std::list< Declaration * > & translationUnit ) { 159 HoistArrayDimension hoister; 160 hoister.mutateDeclarationList( translationUnit ); 161 } 162 163 DeclarationWithType * HoistArrayDimension::mutate( ObjectDecl * objectDecl ) { 164 storageclass = objectDecl->get_storageClass(); 165 DeclarationWithType * temp = Parent::mutate( objectDecl ); 166 hoist( objectDecl->get_type() ); 167 storageclass = DeclarationNode::NoStorageClass; 168 return temp; 169 } 170 171 void HoistArrayDimension::hoist( Type * type ) { 172 // if in function, generate const size_t var 173 static UniqueName dimensionName( "_array_dim" ); 174 175 // C doesn't allow variable sized arrays at global scope or for static variables, 176 // so don't hoist dimension. 177 if ( ! inFunction ) return; 178 if ( storageclass == DeclarationNode::Static ) return; 179 180 if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) { 181 if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist? 182 183 // don't need to hoist dimension if it's a constexpr - only need to if there's potential 184 // for side effects. 185 if ( isConstExpr( arrayType->get_dimension() ) ) return; 186 187 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageclass, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) ); 188 arrayDimension->get_type()->set_isConst( true ); 189 190 arrayType->set_dimension( new VariableExpr( arrayDimension ) ); 191 addDeclaration( arrayDimension ); 192 193 hoist( arrayType->get_base() ); 194 return; 195 } 196 } 197 198 DeclarationWithType * HoistArrayDimension::mutate( FunctionDecl *functionDecl ) { 199 bool oldInFunc = inFunction; 200 inFunction = true; 201 DeclarationWithType * decl = Parent::mutate( functionDecl ); 202 inFunction = oldInFunc; 203 return decl; 204 } 126 205 127 206 void CtorDtor::generateCtorDtor( std::list< Declaration * > & translationUnit ) { … … 130 209 } 131 210 132 namespace {133 Expression * makeCtorDtorExpr( std::string name, ObjectDecl * objDecl, std::list< Expression * > args ) {134 UntypedExpr * expr = new UntypedExpr( new NameExpr( name ) );135 expr->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );136 expr->get_args().splice( expr->get_args().end(), args );137 return expr;138 }139 }140 141 211 DeclarationWithType * CtorDtor::mutate( ObjectDecl * objDecl ) { 142 // hands off if designated or if @=212 // hands off if designated, if @=, or if extern 143 213 if ( tryConstruct( objDecl ) ) { 144 if ( inFunction ) { 145 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) { 146 // call into makeArrayFunction from validate.cc to generate calls to ctor/dtor for each element of array 147 // TODO: walk initializer and generate appropriate copy ctor if element has initializer 148 std::list< Expression * > args = makeInitList( objDecl->get_init() ); 149 if ( args.empty() ) { 150 std::list< Statement * > ctor; 151 std::list< Statement * > dtor; 152 153 SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "?{}", back_inserter( ctor ) ); 154 SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "^?{}", front_inserter( dtor ), false ); 155 156 // Currently makeArrayFunction produces a single Statement - a CompoundStmt 157 // which wraps everything that needs to happen. As such, it's technically 158 // possible to use a Statement ** in the above calls, but this is inherently 159 // unsafe, so instead we take the slightly less efficient route, but will be 160 // immediately informed if somehow the above assumption is broken. In this case, 161 // we could always wrap the list of statements at this point with a CompoundStmt, 162 // but it seems reasonable at the moment for this to be done by makeArrayFunction 163 // itself 164 assert( ctor.size() == 1 && dynamic_cast< ImplicitCtorDtorStmt * >( ctor.front() ) ); 165 assert( dtor.size() == 1 && dynamic_cast< ImplicitCtorDtorStmt * >( dtor.front() ) ); 166 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) ); 167 } else { 168 // array came with an initializer list: initialize each element 169 // may have more initializers than elements in the array - need to check at each index that 170 // we haven't exceeded size. This requires precomputing the size because it might be a side-effecting 171 // computation. 172 // may have fewer initializers than eleemnts in the array - need to default construct 173 // remaining elements. 174 // might be able to merge this with the case above. 175 } 176 } else { 177 // it's sufficient to attempt to call the ctor/dtor for the given object and its initializer 178 Expression * ctor = makeCtorDtorExpr( "?{}", objDecl, makeInitList( objDecl->get_init() ) ); 179 Expression * dtor = makeCtorDtorExpr( "^?{}", objDecl, std::list< Expression * >() ); 180 181 // need to remember init expression, in case no ctors exist 182 // if ctor does exist, want to use ctor expression instead of init 183 // push this decision to the resolver 184 ExprStmt * ctorStmt = new ExprStmt( noLabels, ctor ); 185 ExprStmt * dtorStmt = new ExprStmt( noLabels, dtor ); 186 objDecl->set_init( new ConstructorInit( new ImplicitCtorDtorStmt( ctorStmt ), new ImplicitCtorDtorStmt( dtorStmt ), objDecl->get_init() ) ); 187 } 214 // call into genImplicitCall from Autogen.h to generate calls to ctor/dtor 215 // for each constructable object 216 std::list< Statement * > ctor; 217 std::list< Statement * > dtor; 218 219 InitExpander srcParam( objDecl->get_init() ); 220 InitExpander nullParam( (Initializer *)NULL ); 221 SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl ); 222 SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false ); 223 224 // Currently genImplicitCall produces a single Statement - a CompoundStmt 225 // which wraps everything that needs to happen. As such, it's technically 226 // possible to use a Statement ** in the above calls, but this is inherently 227 // unsafe, so instead we take the slightly less efficient route, but will be 228 // immediately informed if somehow the above assumption is broken. In this case, 229 // we could always wrap the list of statements at this point with a CompoundStmt, 230 // but it seems reasonable at the moment for this to be done by genImplicitCall 231 // itself. It is possible that genImplicitCall produces no statements (e.g. if 232 // an array type does not have a dimension). In this case, it's fine to ignore 233 // the object for the purposes of construction. 234 assert( ctor.size() == dtor.size() && ctor.size() <= 1 ); 235 if ( ctor.size() == 1 ) { 236 // need to remember init expression, in case no ctors exist 237 // if ctor does exist, want to use ctor expression instead of init 238 // push this decision to the resolver 239 assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) ); 240 objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) ); 188 241 } 189 242 } … … 193 246 DeclarationWithType * CtorDtor::mutate( FunctionDecl *functionDecl ) { 194 247 // parameters should not be constructed and destructed, so don't mutate FunctionType 195 bool oldInFunc = inFunction;196 248 mutateAll( functionDecl->get_oldDecls(), *this ); 197 inFunction = true;198 249 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) ); 199 inFunction = oldInFunc;200 250 return functionDecl; 201 251 } 202 203 // should not traverse into any of these declarations to find objects204 // that need to be constructed or destructed205 Declaration* CtorDtor::mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }206 Declaration* CtorDtor::mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }207 Declaration* CtorDtor::mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }208 Declaration* CtorDtor::mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; }209 TypeDecl* CtorDtor::mutate( TypeDecl *typeDecl ) { return typeDecl; }210 Declaration* CtorDtor::mutate( TypedefDecl *typeDecl ) { return typeDecl; }211 Type* CtorDtor::mutate( FunctionType *funcType ) { return funcType; }212 213 252 } // namespace InitTweak 214 253 -
src/InitTweak/InitTweak.cc
r5070fe4 rc331406 1 #include <algorithm> 1 2 #include "InitTweak.h" 2 3 #include "SynTree/Visitor.h" … … 4 5 #include "SynTree/Initializer.h" 5 6 #include "SynTree/Expression.h" 7 #include "SynTree/Attribute.h" 6 8 #include "GenPoly/GenPoly.h" 7 9 … … 20 22 }; 21 23 22 class Init Expander : public Visitor {24 class InitFlattener : public Visitor { 23 25 public: 24 InitExpander() {}25 26 virtual void visit( SingleInit * singleInit ); 26 27 virtual void visit( ListInit * listInit ); … … 28 29 }; 29 30 30 void Init Expander::visit( SingleInit * singleInit ) {31 void InitFlattener::visit( SingleInit * singleInit ) { 31 32 argList.push_back( singleInit->get_value()->clone() ); 32 33 } 33 34 34 void Init Expander::visit( ListInit * listInit ) {35 // xxx - for now, assume nonested list inits36 std::list<Initializer*>::iterator it = listInit->begin _initializers();37 for ( ; it != listInit->end _initializers(); ++it ) {35 void InitFlattener::visit( ListInit * listInit ) { 36 // flatten nested list inits 37 std::list<Initializer*>::iterator it = listInit->begin(); 38 for ( ; it != listInit->end(); ++it ) { 38 39 (*it)->accept( *this ); 39 40 } … … 42 43 43 44 std::list< Expression * > makeInitList( Initializer * init ) { 44 Init Expander expander;45 maybeAccept( init, expander );46 return expander.argList;45 InitFlattener flattener; 46 maybeAccept( init, flattener ); 47 return flattener.argList; 47 48 } 48 49 … … 53 54 } 54 55 56 class InitExpander::ExpanderImpl { 57 public: 58 virtual std::list< Expression * > next( std::list< Expression * > & indices ) = 0; 59 virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices ) = 0; 60 }; 61 62 class InitImpl : public InitExpander::ExpanderImpl { 63 public: 64 InitImpl( Initializer * init ) : init( init ) {} 65 66 virtual std::list< Expression * > next( std::list< Expression * > & indices ) { 67 // this is wrong, but just a placeholder for now 68 // if ( ! flattened ) flatten( indices ); 69 // return ! inits.empty() ? makeInitList( inits.front() ) : std::list< Expression * >(); 70 return makeInitList( init ); 71 } 72 73 virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices ); 74 private: 75 Initializer * init; 76 }; 77 78 class ExprImpl : public InitExpander::ExpanderImpl { 79 public: 80 ExprImpl( Expression * expr ) : arg( expr ) {} 81 82 virtual std::list< Expression * > next( std::list< Expression * > & indices ) { 83 std::list< Expression * > ret; 84 Expression * expr = maybeClone( arg ); 85 if ( expr ) { 86 for ( std::list< Expression * >::reverse_iterator it = indices.rbegin(); it != indices.rend(); ++it ) { 87 // go through indices and layer on subscript exprs ?[?] 88 ++it; 89 UntypedExpr * subscriptExpr = new UntypedExpr( new NameExpr( "?[?]") ); 90 subscriptExpr->get_args().push_back( expr ); 91 subscriptExpr->get_args().push_back( (*it)->clone() ); 92 expr = subscriptExpr; 93 } 94 ret.push_back( expr ); 95 } 96 return ret; 97 } 98 99 virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices ); 100 private: 101 Expression * arg; 102 }; 103 104 InitExpander::InitExpander( Initializer * init ) : expander( new InitImpl( init ) ) {} 105 106 InitExpander::InitExpander( Expression * expr ) : expander( new ExprImpl( expr ) ) {} 107 108 std::list< Expression * > InitExpander::operator*() { 109 return cur; 110 } 111 112 InitExpander & InitExpander::operator++() { 113 cur = expander->next( indices ); 114 return *this; 115 } 116 117 // use array indices list to build switch statement 118 void InitExpander::addArrayIndex( Expression * index, Expression * dimension ) { 119 indices.push_back( index ); 120 indices.push_back( dimension ); 121 } 122 123 void InitExpander::clearArrayIndices() { 124 indices.clear(); 125 } 126 127 namespace { 128 /// given index i, dimension d, initializer init, and callExpr f, generates 129 /// if (i < d) f(..., init) 130 /// ++i; 131 /// so that only elements within the range of the array are constructed 132 template< typename OutIterator > 133 void buildCallExpr( UntypedExpr * callExpr, Expression * index, Expression * dimension, Initializer * init, OutIterator out ) { 134 UntypedExpr * cond = new UntypedExpr( new NameExpr( "?<?") ); 135 cond->get_args().push_back( index->clone() ); 136 cond->get_args().push_back( dimension->clone() ); 137 138 std::list< Expression * > args = makeInitList( init ); 139 callExpr->get_args().splice( callExpr->get_args().end(), args ); 140 141 *out++ = new IfStmt( noLabels, cond, new ExprStmt( noLabels, callExpr ), NULL ); 142 143 UntypedExpr * increment = new UntypedExpr( new NameExpr( "++?" ) ); 144 increment->get_args().push_back( new AddressExpr( index->clone() ) ); 145 *out++ = new ExprStmt( noLabels, increment ); 146 } 147 148 template< typename OutIterator > 149 void build( UntypedExpr * callExpr, InitExpander::IndexList::iterator idx, InitExpander::IndexList::iterator idxEnd, Initializer * init, OutIterator out ) { 150 if ( idx == idxEnd ) return; 151 Expression * index = *idx++; 152 assert( idx != idxEnd ); 153 Expression * dimension = *idx++; 154 155 // xxx - may want to eventually issue a warning here if we can detect 156 // that the number of elements exceeds to dimension of the array 157 if ( idx == idxEnd ) { 158 if ( ListInit * listInit = dynamic_cast< ListInit * >( init ) ) { 159 for ( Initializer * init : *listInit ) { 160 buildCallExpr( callExpr->clone(), index, dimension, init, out ); 161 } 162 } else { 163 buildCallExpr( callExpr->clone(), index, dimension, init, out ); 164 } 165 } else { 166 std::list< Statement * > branches; 167 168 unsigned long cond = 0; 169 ListInit * listInit = dynamic_cast< ListInit * >( init ); 170 if ( ! listInit ) { 171 // xxx - this shouldn't be an error, but need a way to 172 // terminate without creating output, so should catch this error 173 throw SemanticError( "unbalanced list initializers" ); 174 } 175 176 static UniqueName targetLabel( "L__autogen__" ); 177 Label switchLabel( targetLabel.newName(), 0, std::list< Attribute * >{ new Attribute("unused") } ); 178 for ( Initializer * init : *listInit ) { 179 Expression * condition; 180 // check for designations 181 // if ( init-> ) { 182 condition = new ConstantExpr( Constant::from_ulong( cond ) ); 183 ++cond; 184 // } else { 185 // condition = // ... take designation 186 // cond = // ... take designation+1 187 // } 188 std::list< Statement * > stmts; 189 build( callExpr, idx, idxEnd, init, back_inserter( stmts ) ); 190 stmts.push_back( new BranchStmt( noLabels, switchLabel, BranchStmt::Break ) ); 191 CaseStmt * caseStmt = new CaseStmt( noLabels, condition, stmts ); 192 branches.push_back( caseStmt ); 193 } 194 *out++ = new SwitchStmt( noLabels, index->clone(), branches ); 195 *out++ = new NullStmt( std::list<Label>{ switchLabel } ); 196 } 197 } 198 } 199 200 // if array came with an initializer list: initialize each element 201 // may have more initializers than elements in the array - need to check at each index that 202 // we haven't exceeded size. 203 // may have fewer initializers than elements in the array - need to default construct 204 // remaining elements. 205 // To accomplish this, generate switch statement, consuming all of expander's elements 206 Statement * InitImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) { 207 if ( ! init ) return NULL; 208 CompoundStmt * block = new CompoundStmt( noLabels ); 209 build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) ); 210 if ( block->get_kids().empty() ) { 211 delete block; 212 return NULL; 213 } else { 214 init = NULL; // init was consumed in creating the list init 215 return block; 216 } 217 } 218 219 Statement * ExprImpl::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) { 220 return NULL; 221 } 222 223 Statement * InitExpander::buildListInit( UntypedExpr * dst ) { 224 return expander->buildListInit( dst, indices ); 225 } 226 55 227 bool tryConstruct( ObjectDecl * objDecl ) { 56 228 return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) && 57 229 (objDecl->get_init() == NULL || 58 230 ( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() )) && 59 ! isDesignated( objDecl->get_init() ); 231 ! isDesignated( objDecl->get_init() ) 232 && objDecl->get_storageClass() != DeclarationNode::Extern; 233 } 234 235 class CallFinder : public Visitor { 236 public: 237 typedef Visitor Parent; 238 CallFinder( const std::list< std::string > & names ) : names( names ) {} 239 240 virtual void visit( ApplicationExpr * appExpr ) { 241 handleCallExpr( appExpr ); 242 } 243 244 virtual void visit( UntypedExpr * untypedExpr ) { 245 handleCallExpr( untypedExpr ); 246 } 247 248 std::list< Expression * > * matches; 249 private: 250 const std::list< std::string > names; 251 252 template< typename CallExpr > 253 void handleCallExpr( CallExpr * expr ) { 254 Parent::visit( expr ); 255 std::string fname = getFunctionName( expr ); 256 if ( std::find( names.begin(), names.end(), fname ) != names.end() ) { 257 matches->push_back( expr ); 258 } 259 } 260 }; 261 262 void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches ) { 263 static CallFinder finder( std::list< std::string >{ "?{}", "^?{}" } ); 264 finder.matches = &matches; 265 maybeAccept( stmt, finder ); 60 266 } 61 267 62 268 Expression * getCtorDtorCall( Statement * stmt ) { 63 if ( stmt == NULL ) return NULL; 64 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) { 65 return exprStmt->get_expr(); 66 } else if ( CompoundStmt * compoundStmt = dynamic_cast< CompoundStmt * >( stmt ) ) { 67 // could also be a compound statement with a loop, in the case of an array 68 if( compoundStmt->get_kids().size() == 2 ) { 69 // loop variable and loop 70 ForStmt * forStmt = dynamic_cast< ForStmt * >( compoundStmt->get_kids().back() ); 71 assert( forStmt && forStmt->get_body() ); 72 return getCtorDtorCall( forStmt->get_body() ); 73 } else if ( compoundStmt->get_kids().size() == 1 ) { 74 // should be the call statement, but in any case there's only one option 75 return getCtorDtorCall( compoundStmt->get_kids().front() ); 76 } else { 77 assert( false && "too many statements in compoundStmt for getCtorDtorCall" ); 78 } 79 } if ( ImplicitCtorDtorStmt * impCtorDtorStmt = dynamic_cast< ImplicitCtorDtorStmt * > ( stmt ) ) { 80 return getCtorDtorCall( impCtorDtorStmt->get_callStmt() ); 81 } else { 82 // should never get here 83 assert( false && "encountered unknown call statement" ); 84 } 85 } 86 87 bool isInstrinsicSingleArgCallStmt( Statement * stmt ) { 88 Expression * callExpr = getCtorDtorCall( stmt ); 89 if ( ! callExpr ) return false; 90 ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( callExpr ); 91 assert( appExpr ); 92 VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() ); 269 std::list< Expression * > matches; 270 collectCtorDtorCalls( stmt, matches ); 271 assert( matches.size() <= 1 ); 272 return matches.size() == 1 ? matches.front() : NULL; 273 } 274 275 namespace { 276 VariableExpr * getCalledFunction( ApplicationExpr * appExpr ) { 277 assert( appExpr ); 278 // xxx - it's possible this can be other things, e.g. MemberExpr, so this is insufficient 279 return dynamic_cast< VariableExpr * >( appExpr->get_function() ); 280 } 281 } 282 283 ApplicationExpr * isIntrinsicCallExpr( Expression * expr ) { 284 ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr ); 285 if ( ! appExpr ) return NULL; 286 VariableExpr * function = getCalledFunction( appExpr ); 93 287 assert( function ); 94 288 // check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor 95 289 // will call all member dtors, and some members may have a user defined dtor. 96 FunctionType * funcType = GenPoly::getFunctionType( function->get_var()->get_type() ); 97 assert( funcType ); 98 return function->get_var()->get_linkage() == LinkageSpec::Intrinsic && funcType->get_parameters().size() == 1; 290 return function->get_var()->get_linkage() == LinkageSpec::Intrinsic ? appExpr : NULL; 291 } 292 293 bool isIntrinsicSingleArgCallStmt( Statement * stmt ) { 294 std::list< Expression * > callExprs; 295 collectCtorDtorCalls( stmt, callExprs ); 296 // if ( callExprs.empty() ) return false; // xxx - do I still need this check? 297 return std::all_of( callExprs.begin(), callExprs.end(), []( Expression * callExpr ){ 298 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 299 assert( ! appExpr->get_function()->get_results().empty() ); 300 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() ); 301 assert( funcType ); 302 return funcType->get_parameters().size() == 1; 303 } 304 return false; 305 }); 99 306 } 100 307 … … 160 367 else return NULL; 161 368 } 369 370 class ConstExprChecker : public Visitor { 371 public: 372 ConstExprChecker() : isConstExpr( true ) {} 373 374 virtual void visit( ApplicationExpr *applicationExpr ) { isConstExpr = false; } 375 virtual void visit( UntypedExpr *untypedExpr ) { isConstExpr = false; } 376 virtual void visit( NameExpr *nameExpr ) { isConstExpr = false; } 377 virtual void visit( CastExpr *castExpr ) { isConstExpr = false; } 378 virtual void visit( LabelAddressExpr *labAddressExpr ) { isConstExpr = false; } 379 virtual void visit( UntypedMemberExpr *memberExpr ) { isConstExpr = false; } 380 virtual void visit( MemberExpr *memberExpr ) { isConstExpr = false; } 381 virtual void visit( VariableExpr *variableExpr ) { isConstExpr = false; } 382 virtual void visit( ConstantExpr *constantExpr ) { /* bottom out */ } 383 // these might be okay? 384 // virtual void visit( SizeofExpr *sizeofExpr ); 385 // virtual void visit( AlignofExpr *alignofExpr ); 386 // virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 387 // virtual void visit( OffsetofExpr *offsetofExpr ); 388 // virtual void visit( OffsetPackExpr *offsetPackExpr ); 389 // virtual void visit( AttrExpr *attrExpr ); 390 // virtual void visit( CommaExpr *commaExpr ); 391 // virtual void visit( LogicalExpr *logicalExpr ); 392 // virtual void visit( ConditionalExpr *conditionalExpr ); 393 virtual void visit( TupleExpr *tupleExpr ) { isConstExpr = false; } 394 virtual void visit( SolvedTupleExpr *tupleExpr ) { isConstExpr = false; } 395 virtual void visit( TypeExpr *typeExpr ) { isConstExpr = false; } 396 virtual void visit( AsmExpr *asmExpr ) { isConstExpr = false; } 397 virtual void visit( UntypedValofExpr *valofExpr ) { isConstExpr = false; } 398 virtual void visit( CompoundLiteralExpr *compLitExpr ) { isConstExpr = false; } 399 400 bool isConstExpr; 401 }; 402 403 bool isConstExpr( Expression * expr ) { 404 if ( expr ) { 405 ConstExprChecker checker; 406 expr->accept( checker ); 407 return checker.isConstExpr; 408 } 409 return true; 410 } 411 412 bool isConstExpr( Initializer * init ) { 413 if ( init ) { 414 ConstExprChecker checker; 415 init->accept( checker ); 416 return checker.isConstExpr; 417 } // if 418 // for all intents and purposes, no initializer means const expr 419 return true; 420 } 421 162 422 } -
src/InitTweak/InitTweak.h
r5070fe4 rc331406 26 26 // helper functions for initialization 27 27 namespace InitTweak { 28 29 28 /// transform Initializer into an argument list that can be passed to a call expression 29 std::list< Expression * > makeInitList( Initializer * init ); 30 30 31 32 31 /// True if the resolver should try to construct objDecl 32 bool tryConstruct( ObjectDecl * objDecl ); 33 33 34 35 34 /// True if the Initializer contains designations 35 bool isDesignated( Initializer * init ); 36 36 37 /// True if stmt is a call statement where the function called is intrinsic and takes one parameter. 38 /// Intended to be used for default ctor/dtor calls, but might have use elsewhere. 39 /// Currently has assertions that make it less than fully general. 40 bool isInstrinsicSingleArgCallStmt( Statement * expr ); 37 /// Non-Null if expr is a call expression whose target function is intrinsic 38 ApplicationExpr * isIntrinsicCallExpr( Expression * expr ); 41 39 42 /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call 43 Expression * getCtorDtorCall( Statement * stmt ); 40 /// True if stmt is a call statement where the function called is intrinsic and takes one parameter. 41 /// Intended to be used for default ctor/dtor calls, but might have use elsewhere. 42 /// Currently has assertions that make it less than fully general. 43 bool isIntrinsicSingleArgCallStmt( Statement * expr ); 44 44 45 /// returns the name of the function being called 46 std::string getFunctionName( Expression * expr);45 /// get all Ctor/Dtor call expressions from a Statement 46 void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches ); 47 47 48 /// returns the argument to a call expression in position N indexed from 0 49 Expression *& getCallArg( Expression * callExpr, unsigned int pos);48 /// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call 49 Expression * getCtorDtorCall( Statement * stmt ); 50 50 51 /// returns the base type of a PointerType or ArrayType, else returns NULL 52 Type * getPointerBase( Type *);51 /// returns the name of the function being called 52 std::string getFunctionName( Expression * expr ); 53 53 54 /// returns the argument if it is a PointerType or ArrayType, else returns NULL 55 Type * isPointerType( Type * ); 54 /// returns the argument to a call expression in position N indexed from 0 55 Expression *& getCallArg( Expression * callExpr, unsigned int pos ); 56 57 /// returns the base type of a PointerType or ArrayType, else returns NULL 58 Type * getPointerBase( Type * ); 59 60 /// returns the argument if it is a PointerType or ArrayType, else returns NULL 61 Type * isPointerType( Type * ); 62 63 /// returns true if expr is trivially a compile-time constant 64 bool isConstExpr( Expression * expr ); 65 bool isConstExpr( Initializer * init ); 66 67 class InitExpander { 68 public: 69 // expand by stepping through init to get each list of arguments 70 InitExpander( Initializer * init ); 71 72 // always expand to expr 73 InitExpander( Expression * expr ); 74 75 // iterator-like interface 76 std::list< Expression * > operator*(); 77 InitExpander & operator++(); 78 79 // builds statement which has the same semantics as a C-style list initializer 80 // (for array initializers) using callExpr as the base expression to perform initialization 81 Statement * buildListInit( UntypedExpr * callExpr ); 82 void addArrayIndex( Expression * index, Expression * dimension ); 83 void clearArrayIndices(); 84 85 class ExpanderImpl; 86 private: 87 std::shared_ptr< ExpanderImpl > expander; 88 std::list< Expression * > cur; 89 90 // invariant: list of size 2N (elements come in pairs [index, dimension]) 91 typedef std::list< Expression * > IndexList; 92 IndexList indices; 93 }; 56 94 } // namespace 57 95 -
src/Makefile.in
r5070fe4 rc331406 108 108 ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) \ 109 109 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) \ 110 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT) \111 110 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 112 111 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ … … 373 372 Common/SemanticError.cc Common/UniqueName.cc \ 374 373 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 375 ControlStruct/MLEMutator.cc ControlStruct/ CaseRangeMutator.cc \376 ControlStruct/ Mutate.cc ControlStruct/ForExprMutator.cc \374 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 375 ControlStruct/ForExprMutator.cc \ 377 376 ControlStruct/LabelTypeChecker.cc Designators/Processor.cc \ 378 377 GenPoly/Box.cc GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ … … 543 542 ControlStruct/$(DEPDIR)/$(am__dirstamp) 544 543 ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT): \ 545 ControlStruct/$(am__dirstamp) \546 ControlStruct/$(DEPDIR)/$(am__dirstamp)547 ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT): \548 544 ControlStruct/$(am__dirstamp) \ 549 545 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 823 819 -rm -f Common/driver_cfa_cpp-SemanticError.$(OBJEXT) 824 820 -rm -f Common/driver_cfa_cpp-UniqueName.$(OBJEXT) 825 -rm -f ControlStruct/driver_cfa_cpp-CaseRangeMutator.$(OBJEXT)826 821 -rm -f ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) 827 822 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) … … 934 929 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-SemanticError.Po@am__quote@ 935 930 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/driver_cfa_cpp-UniqueName.Po@am__quote@ 936 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po@am__quote@937 931 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-ForExprMutator.Po@am__quote@ 938 932 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ … … 1217 1211 @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-MLEMutator.obj `if test -f 'ControlStruct/MLEMutator.cc'; then $(CYGPATH_W) 'ControlStruct/MLEMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/MLEMutator.cc'; fi` 1218 1212 1219 ControlStruct/driver_cfa_cpp-CaseRangeMutator.o: ControlStruct/CaseRangeMutator.cc1220 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-CaseRangeMutator.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.o `test -f 'ControlStruct/CaseRangeMutator.cc' || echo '$(srcdir)/'`ControlStruct/CaseRangeMutator.cc1221 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po1222 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/CaseRangeMutator.cc' object='ControlStruct/driver_cfa_cpp-CaseRangeMutator.o' libtool=no @AMDEPBACKSLASH@1223 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1224 @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-CaseRangeMutator.o `test -f 'ControlStruct/CaseRangeMutator.cc' || echo '$(srcdir)/'`ControlStruct/CaseRangeMutator.cc1225 1226 ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj: ControlStruct/CaseRangeMutator.cc1227 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo -c -o ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj `if test -f 'ControlStruct/CaseRangeMutator.cc'; then $(CYGPATH_W) 'ControlStruct/CaseRangeMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/CaseRangeMutator.cc'; fi`1228 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-CaseRangeMutator.Po1229 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/CaseRangeMutator.cc' object='ControlStruct/driver_cfa_cpp-CaseRangeMutator.obj' libtool=no @AMDEPBACKSLASH@1230 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@1231 @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-CaseRangeMutator.obj `if test -f 'ControlStruct/CaseRangeMutator.cc'; then $(CYGPATH_W) 'ControlStruct/CaseRangeMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/CaseRangeMutator.cc'; fi`1232 1233 1213 ControlStruct/driver_cfa_cpp-Mutate.o: ControlStruct/Mutate.cc 1234 1214 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-Mutate.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Tpo -c -o ControlStruct/driver_cfa_cpp-Mutate.o `test -f 'ControlStruct/Mutate.cc' || echo '$(srcdir)/'`ControlStruct/Mutate.cc -
src/Parser/ExpressionNode.cc
r5070fe4 rc331406 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 5 13:41:55201613 // Update Count : 3 2012 // Last Modified On : Fri Aug 5 07:56:23 2016 13 // Update Count : 375 14 14 // 15 15 … … 83 83 } 84 84 85 CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ) {86 return new CommaExprNode( this, exp );87 }85 // CommaExprNode *ExpressionNode::add_to_list( ExpressionNode *exp ) { 86 // return new CommaExprNode( this, exp ); 87 // } 88 88 89 89 //############################################################################## … … 246 246 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 247 247 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", 248 "?[?]", "FieldSel", "PFieldSel", " Range",248 "?[?]", "FieldSel", "PFieldSel", "...", 249 249 // monadic 250 250 "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--", "&&" … … 258 258 OperatorNode::~OperatorNode() {} 259 259 260 OperatorNode::Type OperatorNode::get_type( void ) const {260 OperatorNode::Type OperatorNode::get_type( void ) const { 261 261 return type; 262 262 } … … 311 311 } 312 312 313 #include "Common/utility.h" 313 314 Expression *build_cast( TypeValueNode * arg, ExpressionNode *expr_node ) { 315 DeclarationNode *decl_node = arg->get_decl(); 316 317 Type *targetType = decl_node->buildType(); 318 if ( dynamic_cast< VoidType* >( targetType ) ) { 319 delete targetType; 320 return new CastExpr( maybeBuild<Expression>(expr_node) ); 321 } else { 322 return new CastExpr( maybeBuild<Expression>(expr_node), targetType ); 323 } // if 324 } 325 326 Expression *build_fieldSel( ExpressionNode *expr_node, VarRefNode *member ) { 327 NameExpr* memberExpr = dynamic_cast<NameExpr*> ( maybeBuild<Expression>( member) ); 328 assert( memberExpr ); 329 UntypedMemberExpr *ret = new UntypedMemberExpr( memberExpr->get_name(), maybeBuild<Expression>(expr_node) ); 330 delete member; 331 return ret; 332 } 333 334 Expression *build_pfieldSel( ExpressionNode *expr_node, VarRefNode *member ) { 335 NameExpr* memberExpr = dynamic_cast<NameExpr*> ( maybeBuild<Expression>( member) ); 336 assert( memberExpr ); 337 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 338 deref->get_args().push_back( maybeBuild<Expression>(expr_node) ); 339 UntypedMemberExpr *ret = new UntypedMemberExpr( memberExpr->get_name(), deref ); 340 delete member; 341 return ret; 342 } 343 344 Expression *build_addressOf( ExpressionNode *expr_node ) { 345 return new AddressExpr( maybeBuild<Expression>(expr_node) ); 346 } 347 Expression *build_sizeOf( ExpressionNode *expr_node ) { 348 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( expr_node ) ) { 349 return new SizeofExpr( arg->get_decl()->buildType() ); 350 } else { 351 return new SizeofExpr( maybeBuild<Expression>(expr_node) ); 352 } // if 353 } 354 Expression *build_alignOf( ExpressionNode *expr_node ) { 355 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( expr_node ) ) { 356 return new AlignofExpr( arg->get_decl()->buildType() ); 357 } else { 358 return new AlignofExpr( maybeBuild<Expression>(expr_node) ); 359 } // if 360 } 361 Expression *build_offsetOf( TypeValueNode * arg, VarRefNode *member ) { 362 NameExpr *memberExpr = dynamic_cast<NameExpr *>( maybeBuild<Expression>( member ) ); 363 assert( memberExpr ); 364 return new UntypedOffsetofExpr( arg->get_decl()->buildType(), memberExpr->get_name() ); 365 } 366 367 Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) { 368 return new LogicalExpr( notZeroExpr( maybeBuild<Expression>(expr_node1) ), notZeroExpr( maybeBuild<Expression>(expr_node2) ), kind ); 369 } 370 371 Expression *build_opr1( OperatorNode::Type op, ExpressionNode *expr_node ) { 372 std::list<Expression *> args; 373 args.push_back( new AddressExpr( maybeBuild<Expression>(expr_node) ) ); 374 return new UntypedExpr( new NameExpr( opName[ op ] ), args ); 375 } 376 Expression *build_opr2( OperatorNode::Type op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 377 std::list<Expression *> args; 378 args.push_back( maybeBuild<Expression>(expr_node1) ); 379 args.push_back( maybeBuild<Expression>(expr_node2) ); 380 return new UntypedExpr( new NameExpr( opName[ op ] ), args ); 381 } 382 383 Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) { 384 return new ConditionalExpr( notZeroExpr( maybeBuild<Expression>(expr_node1) ), maybeBuild<Expression>(expr_node2), maybeBuild<Expression>(expr_node3) ); 385 } 386 387 Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) { 388 return new CommaExpr( maybeBuild<Expression>(expr_node1), maybeBuild<Expression>(expr_node2) ); 389 } 390 391 CompositeExprNode2::CompositeExprNode2( Expression *expr ) : expr( expr ) {} 392 CompositeExprNode2::CompositeExprNode2( const CompositeExprNode2 &other ) : expr( other.expr->clone() ) {} 393 CompositeExprNode2::~CompositeExprNode2() { delete expr; } 394 void CompositeExprNode2::print( std::ostream &, int indent ) const { assert( false ); } 395 void CompositeExprNode2::printOneLine( std::ostream &, int indent ) const { assert( false ); } 396 314 397 315 398 Expression *CompositeExprNode::build() const { … … 323 406 } // if 324 407 325 switch ( op->get_type()) { 326 case OperatorNode::Incr: 327 case OperatorNode::Decr: 328 case OperatorNode::IncrPost: 329 case OperatorNode::DecrPost: 408 switch ( op->get_type() ) { 330 409 case OperatorNode::Assign: 331 410 case OperatorNode::MulAssn: … … 339 418 case OperatorNode::ERAssn: 340 419 case OperatorNode::OrAssn: 341 // the rewrite rules for these expressions specify that the first argument has its address taken342 420 assert( ! args.empty() ); 343 421 args.front() = new AddressExpr( args.front() ); 344 break;345 default: // do nothing346 ;347 } // switch348 349 switch ( op->get_type() ) {350 case OperatorNode::Incr:351 case OperatorNode::Decr:352 case OperatorNode::IncrPost:353 case OperatorNode::DecrPost:354 case OperatorNode::Assign:355 case OperatorNode::MulAssn:356 case OperatorNode::DivAssn:357 case OperatorNode::ModAssn:358 case OperatorNode::PlusAssn:359 case OperatorNode::MinusAssn:360 case OperatorNode::LSAssn:361 case OperatorNode::RSAssn:362 case OperatorNode::AndAssn:363 case OperatorNode::ERAssn:364 case OperatorNode::OrAssn:365 case OperatorNode::Plus:366 case OperatorNode::Minus:367 case OperatorNode::Mul:368 case OperatorNode::Div:369 case OperatorNode::Mod:370 case OperatorNode::BitOr:371 case OperatorNode::BitAnd:372 case OperatorNode::Xor:373 case OperatorNode::LShift:374 case OperatorNode::RShift:375 case OperatorNode::LThan:376 case OperatorNode::GThan:377 case OperatorNode::LEThan:378 case OperatorNode::GEThan:379 case OperatorNode::Eq:380 case OperatorNode::Neq:381 case OperatorNode::Index:382 case OperatorNode::Range:383 422 case OperatorNode::UnPlus: 384 423 case OperatorNode::UnMinus: … … 388 427 case OperatorNode::LabelAddress: 389 428 return new UntypedExpr( new NameExpr( opName[ op->get_type() ] ), args ); 390 case OperatorNode::AddressOf: 391 assert( args.size() == 1 ); 392 assert( args.front() ); 393 394 return new AddressExpr( args.front() ); 395 case OperatorNode::Cast: 396 { 397 TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()); 398 assert( arg ); 399 400 DeclarationNode *decl_node = arg->get_decl(); 401 ExpressionNode *expr_node = dynamic_cast<ExpressionNode *>( arg->get_link()); 402 403 Type *targetType = decl_node->buildType(); 404 if ( dynamic_cast< VoidType* >( targetType ) ) { 405 delete targetType; 406 return new CastExpr( maybeBuild<Expression>(expr_node), maybeBuild< Expression >( get_argName() ) ); 407 } else { 408 return new CastExpr( maybeBuild<Expression>(expr_node),targetType, maybeBuild< Expression >( get_argName() ) ); 409 } // if 410 } 411 case OperatorNode::FieldSel: 412 { 413 assert( args.size() == 2 ); 414 415 NameExpr *member = dynamic_cast<NameExpr *>( args.back()); 416 // TupleExpr *memberTup = dynamic_cast<TupleExpr *>( args.back()); 417 418 if ( member != 0 ) { 419 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), args.front()); 420 delete member; 421 return ret; 422 /* else if ( memberTup != 0 ) 423 { 424 UntypedMemberExpr *ret = new UntypedMemberExpr( memberTup->get_name(), args.front()); 425 delete member; 426 return ret; 427 } */ 428 } else 429 assert( false ); 430 } 431 case OperatorNode::PFieldSel: 432 { 433 assert( args.size() == 2 ); 434 435 NameExpr *member = dynamic_cast<NameExpr *>( args.back()); // modify for Tuples xxx 436 assert( member != 0 ); 437 438 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 439 deref->get_args().push_back( args.front() ); 440 441 UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref ); 442 delete member; 443 return ret; 444 } 445 case OperatorNode::SizeOf: 446 { 447 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()) ) { 448 return new SizeofExpr( arg->get_decl()->buildType()); 449 } else { 450 return new SizeofExpr( args.front()); 451 } // if 452 } 453 case OperatorNode::AlignOf: 454 { 455 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()) ) { 456 return new AlignofExpr( arg->get_decl()->buildType()); 457 } else { 458 return new AlignofExpr( args.front()); 459 } // if 460 } 461 case OperatorNode::OffsetOf: 462 { 463 assert( args.size() == 2 ); 464 465 if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args() ) ) { 466 NameExpr *member = dynamic_cast<NameExpr *>( args.back() ); 467 assert( member != 0 ); 468 469 return new UntypedOffsetofExpr( arg->get_decl()->buildType(), member->get_name() ); 470 } else assert( false ); 471 } 429 472 430 case OperatorNode::Attr: 473 431 { 474 VarRefNode *var = dynamic_cast<VarRefNode *>( get_args() );432 VarRefNode *var = dynamic_cast<VarRefNode *>( get_args() ); 475 433 assert( var ); 476 434 if ( ! get_args()->get_link() ) { 477 435 return new AttrExpr( maybeBuild<Expression>(var), ( Expression*)0); 478 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link() ) ) {479 return new AttrExpr( maybeBuild<Expression>(var), arg->get_decl()->buildType() );436 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link() ) ) { 437 return new AttrExpr( maybeBuild<Expression>(var), arg->get_decl()->buildType() ); 480 438 } else { 481 return new AttrExpr( maybeBuild<Expression>(var), args.back() );439 return new AttrExpr( maybeBuild<Expression>(var), args.back() ); 482 440 } // if 483 441 } 484 case OperatorNode::Or:485 case OperatorNode::And:486 assert( args.size() == 2);487 return new LogicalExpr( notZeroExpr( args.front() ), notZeroExpr( args.back() ), ( op->get_type() == OperatorNode::And ) );488 442 case OperatorNode::Cond: 489 443 { … … 497 451 case OperatorNode::NCond: 498 452 throw UnimplementedError( "GNU 2-argument conditional expression" ); 499 case OperatorNode::Comma:500 {501 assert( args.size() == 2);502 std::list< Expression * >::const_iterator i = args.begin();503 Expression *ret = *i++;504 while ( i != args.end() ) {505 ret = new CommaExpr( ret, *i++ );506 }507 return ret;508 }509 453 // Tuples 510 454 case OperatorNode::TupleC: … … 515 459 } 516 460 default: 517 // shouldn't happen 518 assert( false ); 461 assert( ((void)"CompositeExprNode::build", false) ); 519 462 return 0; 520 463 } // switch … … 605 548 606 549 void LabelNode::printOneLine( std::ostream &os, int indent ) const {} 607 608 //##############################################################################609 610 CommaExprNode::CommaExprNode(): CompositeExprNode( new OperatorNode( OperatorNode::Comma )) {}611 612 CommaExprNode::CommaExprNode( ExpressionNode *exp ) : CompositeExprNode( new OperatorNode( OperatorNode::Comma ), exp ) {613 }614 615 CommaExprNode::CommaExprNode( ExpressionNode *exp1, ExpressionNode *exp2) : CompositeExprNode( new OperatorNode( OperatorNode::Comma ), exp1, exp2) {616 }617 618 CommaExprNode *CommaExprNode::add_to_list( ExpressionNode *exp ) {619 add_arg( exp );620 621 return this;622 }623 624 CommaExprNode::CommaExprNode( const CommaExprNode &other ) : CompositeExprNode( other ) {625 }626 550 627 551 //############################################################################## … … 774 698 } 775 699 776 777 700 ExpressionNode *flattenCommas( ExpressionNode *list ) { 778 701 if ( CompositeExprNode *composite = dynamic_cast< CompositeExprNode * >( list ) ) { -
src/Parser/ParseNode.h
r5070fe4 rc331406 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 24 02:17:00201613 // Update Count : 2 6912 // Last Modified On : Fri Aug 5 07:49:32 2016 13 // Update Count : 288 14 14 // 15 15 … … 77 77 virtual ExpressionNode *clone() const = 0; 78 78 79 virtual CommaExprNode *add_to_list( ExpressionNode * );79 // virtual CommaExprNode *add_to_list( ExpressionNode * ); 80 80 81 81 ExpressionNode *get_argName() const { return argName; } … … 225 225 }; 226 226 227 Expression *build_cast( TypeValueNode * arg, ExpressionNode *expr_node ); 228 Expression *build_fieldSel( ExpressionNode *expr_node, VarRefNode *member ); 229 Expression *build_pfieldSel( ExpressionNode *expr_node, VarRefNode *member ); 230 Expression *build_addressOf( ExpressionNode *expr_node ); 231 Expression *build_sizeOf( ExpressionNode *expr_node ); 232 Expression *build_alignOf( ExpressionNode *expr_node ); 233 Expression *build_offsetOf( TypeValueNode * arg, VarRefNode *member ); 234 Expression *build_and( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ); 235 Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ); 236 Expression *build_opr1( OperatorNode::Type op, ExpressionNode *expr_node ); 237 Expression *build_opr2( OperatorNode::Type op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ); 238 Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ); 239 Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ); 240 241 class CompositeExprNode2 : public ExpressionNode { 242 public: 243 CompositeExprNode2( Expression *expr ); 244 CompositeExprNode2( const CompositeExprNode2 &other ); 245 virtual ~CompositeExprNode2(); 246 247 virtual CompositeExprNode2 *clone() const { return new CompositeExprNode2( *this ); } 248 virtual Expression *build() const { return expr->clone(); } 249 250 virtual void print( std::ostream &, int indent = 0) const; 251 virtual void printOneLine( std::ostream &, int indent = 0) const; 252 private: 253 Expression *expr; 254 }; 255 227 256 class CompositeExprNode : public ExpressionNode { 228 257 public: … … 290 319 private: 291 320 std::list< Label > labels; 292 };293 294 class CommaExprNode : public CompositeExprNode {295 public:296 CommaExprNode();297 CommaExprNode( ExpressionNode * );298 CommaExprNode( ExpressionNode *, ExpressionNode * );299 CommaExprNode( const CommaExprNode &other );300 301 virtual CommaExprNode *add_to_list( ExpressionNode * );302 virtual CommaExprNode *clone() const { return new CommaExprNode( *this ); }303 321 }; 304 322 … … 485 503 std::string get_target() const; 486 504 487 StatementNode *add_controlexp( ExpressionNode * );505 // StatementNode *add_controlexp( ExpressionNode * ); 488 506 StatementNode *append_block( StatementNode * ); 489 507 StatementNode *append_last_case( StatementNode * ); … … 531 549 ConstantNode *clobber; 532 550 std::list< Label > gotolabels; 533 };534 535 class NullStmtNode : public CompoundStmtNode {536 public:537 Statement *build() const;538 void print( std::ostream &, int indent = 0 ) const;539 551 }; 540 552 -
src/Parser/StatementNode.cc
r5070fe4 rc331406 107 107 } 108 108 109 StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) {110 if ( control && e )111 control->add_to_list( e ); // xxx - check this112 return this;113 }109 // StatementNode *StatementNode::add_controlexp( ExpressionNode *e ) { 110 // if ( control && e ) 111 // control->add_to_list( e ); // xxx - check this 112 // return this; 113 // } 114 114 115 115 StatementNode *StatementNode::append_block( StatementNode *stmt ) { … … 417 417 } 418 418 419 420 void NullStmtNode::print( ostream &os, int indent ) const {421 os << string( indent, ' ' ) << "Null Statement:" << endl;422 }423 424 Statement *NullStmtNode::build() const {425 return new NullStmt;426 }427 428 419 // Local Variables: // 429 420 // tab-width: 4 // -
src/Parser/TypeData.cc
r5070fe4 rc331406 510 510 return buildVariable(); 511 511 } else { 512 return new ObjectDecl( name, sc, linkage, bitfieldWidth, build(), init, isInline, isNoreturn );512 return new ObjectDecl( name, sc, linkage, bitfieldWidth, build(), init, std::list< Attribute * >(), isInline, isNoreturn ); 513 513 } // if 514 514 return 0; -
src/Parser/parser.cc
r5070fe4 rc331406 354 354 LabelNode *label; 355 355 InitializerNode *in; 356 OperatorNode::Type op; 356 357 bool flag; 357 358 … … 359 360 360 361 /* Line 293 of yacc.c */ 361 #line 36 2"Parser/parser.cc"362 #line 363 "Parser/parser.cc" 362 363 } YYSTYPE; 363 364 # define YYSTYPE_IS_TRIVIAL 1 … … 371 372 372 373 /* Line 343 of yacc.c */ 373 #line 37 4"Parser/parser.cc"374 #line 375 "Parser/parser.cc" 374 375 375 376 #ifdef short … … 1016 1017 static const yytype_uint16 yyrline[] = 1017 1018 { 1018 0, 29 0, 290, 296, 305, 306, 307, 311, 312, 313,1019 31 7, 318, 322, 323, 327, 328, 332, 333, 339, 341,1020 34 3, 345, 350, 351, 357, 361, 363, 364, 366, 367,1021 3 69, 371, 373, 381, 382, 388, 389, 390, 395, 397,1022 40 2, 403, 407, 411, 413, 415, 417, 422, 425, 427,1023 4 29, 431, 436, 438, 440, 442, 444, 446, 448, 450,1024 45 2, 454, 456, 463, 464, 466, 470, 471, 472, 473,1025 4 77, 478, 480, 485, 486, 488, 490, 495, 496, 498,1026 50 3, 504, 506, 511, 512, 514, 516, 518, 523, 524,1027 52 6, 531, 532, 537, 538, 543, 544, 549, 550, 555,1028 55 6, 561, 562, 564, 566, 571, 576, 577, 579, 581,1029 5 87, 588, 594, 596, 598, 600, 605, 606, 611, 612,1030 61 3, 614, 615, 616, 617, 618, 619, 620, 624, 625,1031 63 1, 632, 638, 639, 640, 641, 642, 643, 644, 645,1032 6 46, 656, 663, 665, 675, 676, 681, 683, 689, 691,1033 695, 696, 701, 706, 709, 711, 713, 722, 724, 735,1034 7 36, 738, 742, 743, 748, 749, 754, 755, 759, 764,1035 7 65, 769, 771, 777, 778, 782, 784, 786, 788, 794,1036 795, 799, 801, 806, 808, 810, 815, 817, 822, 824,1037 8 28, 831, 835, 838, 842, 844, 848, 850, 857, 859,1038 86 1, 870, 872, 874, 876, 878, 883, 885, 887, 889,1039 894, 907, 908, 913, 915, 920, 924, 926, 928, 930,1040 93 2, 938, 939, 945, 946, 950, 951, 956, 958, 964,1041 9 65, 967, 972, 974, 981, 983, 987, 988, 993, 995,1042 999, 1000, 1004, 1006, 1010, 1011, 1015, 1016, 1020, 1021,1043 10 36, 1037, 1038, 1039, 1040, 1044, 1049, 1056, 1066, 1071,1044 10 76, 1084, 1089, 1094, 1099, 1104, 1112, 1134, 1139, 1146,1045 11 48, 1155, 1160, 1165, 1176, 1181, 1186, 1191, 1196, 1205,1046 121 0, 1218, 1219, 1220, 1221, 1227, 1232, 1240, 1241, 1242,1047 124 3, 1247, 1248, 1249, 1250, 1255, 1256, 1265, 1266, 1271,1048 127 2, 1277, 1279, 1281, 1283, 1285, 1288, 1287, 1299, 1300,1049 130 2, 1312, 1313, 1318, 1322, 1324, 1326, 1328, 1330, 1332,1050 13 34, 1336, 1341, 1343, 1345, 1347, 1349, 1351, 1353, 1355,1051 13 57, 1359, 1361, 1363, 1365, 1371, 1372, 1374, 1376, 1378,1052 138 3, 1384, 1390, 1391, 1393, 1395, 1400, 1402, 1404, 1406,1053 141 1, 1412, 1414, 1416, 1421, 1422, 1424, 1429, 1430, 1432,1054 14 34, 1439, 1441, 1443, 1448, 1449, 1453, 1455, 1461, 1460,1055 14 64, 1466, 1471, 1473, 1479, 1480, 1485, 1486, 1488, 1489,1056 1 498, 1499, 1501, 1503, 1508, 1510, 1516, 1517, 1519, 1522,1057 15 25, 1530, 1531, 1536, 1541, 1545, 1547, 1553, 1552, 1559,1058 156 1, 1567, 1568, 1576, 1577, 1581, 1582, 1583, 1585, 1587,1059 1 594, 1595, 1597, 1599, 1604, 1605, 1611, 1612, 1616, 1617,1060 162 2, 1623, 1624, 1626, 1634, 1635, 1637, 1640, 1642, 1646,1061 16 47, 1648, 1650, 1652, 1656, 1661, 1669, 1670, 1679, 1681,1062 16 86, 1687, 1688, 1692, 1693, 1694, 1698, 1699, 1700, 1704,1063 17 05, 1706, 1711, 1712, 1713, 1714, 1720, 1721, 1723, 1728,1064 17 29, 1734, 1735, 1736, 1737, 1738, 1753, 1754, 1759, 1760,1065 17 68, 1770, 1772, 1775, 1777, 1779, 1802, 1803, 1805, 1807,1066 181 2, 1813, 1815, 1820, 1825, 1826, 1832, 1831, 1835, 1839,1067 184 1, 1843, 1849, 1850, 1855, 1860, 1862, 1867, 1869, 1870,1068 187 2, 1877, 1879, 1881, 1886, 1888, 1893, 1898, 1906, 1912,1069 191 1, 1925, 1926, 1931, 1932, 1936, 1941, 1946, 1954, 1959,1070 197 0, 1971, 1982, 1983, 1989, 1990, 1994, 1995, 1996, 1999,1071 1998, 2009, 2018, 2024, 2030, 2039, 2045, 2051, 2057, 2063,1072 207 1, 2077, 2085, 2091, 2100, 2101, 2102, 2106, 2110, 2112,1073 21 17, 2118, 2122, 2123, 2128, 2134, 2135, 2138, 2140, 2141,1074 21 45, 2146, 2147, 2148, 2182, 2184, 2185, 2187, 2192, 2197,1075 220 2, 2204, 2206, 2211, 2213, 2215, 2217, 2222, 2224, 2233,1076 22 35, 2236, 2241, 2243, 2245, 2250, 2252, 2254, 2259, 2261,1077 226 3, 2272, 2273, 2274, 2278, 2280, 2282, 2287, 2289, 2291,1078 2 296, 2298, 2300, 2315, 2317, 2318, 2320, 2325, 2326, 2331,1079 233 3, 2335, 2340, 2342, 2344, 2346, 2351, 2353, 2355, 2365,1080 23 67, 2368, 2370, 2375, 2377, 2379, 2384, 2386, 2388, 2390,1081 2 395, 2397, 2399, 2430, 2432, 2433, 2435, 2440, 2445, 2453,1082 24 55, 2457, 2462, 2464, 2469, 2471, 2485, 2486, 2488, 2493,1083 2 495, 2497, 2499, 2501, 2506, 2507, 2509, 2511, 2516, 2518,1084 252 0, 2526, 2528, 2530, 2534, 2536, 2538, 2540, 2554, 2555,1085 25 57, 2562, 2564, 2566, 2568, 2570, 2575, 2576, 2578, 2580,1086 25 85, 2587, 2589, 2595, 2596, 2598, 2607, 2610, 2612, 2615,1087 26 17, 2619, 2632, 2633, 2635, 2640, 2642, 2644, 2646, 2648,1088 265 3, 2654, 2656, 2658, 2663, 2665, 2673, 2674, 2675, 2680,1089 268 1, 2685, 2687, 2689, 2691, 2693, 2695, 2702, 2704, 2706,1090 27 08, 2710, 2712, 2714, 2716, 2718, 2720, 2725, 2727, 2729,1091 27 34, 2760, 2761, 2763, 2767, 2768, 2772, 2774, 2776, 2778,1092 278 0, 2782, 2789, 2791, 2793, 2795, 2797, 2799, 2804, 2809,1093 281 1, 2813, 2831, 2833, 2838, 28391019 0, 292, 292, 298, 307, 308, 309, 313, 314, 315, 1020 319, 320, 324, 325, 329, 330, 334, 335, 341, 343, 1021 345, 347, 352, 353, 359, 363, 365, 366, 368, 369, 1022 371, 373, 375, 383, 384, 390, 391, 392, 397, 399, 1023 404, 405, 409, 413, 415, 417, 419, 424, 427, 429, 1024 431, 436, 439, 441, 443, 445, 447, 449, 451, 453, 1025 455, 457, 459, 466, 467, 469, 473, 474, 475, 476, 1026 480, 481, 483, 488, 489, 491, 493, 498, 499, 501, 1027 506, 507, 509, 514, 515, 517, 519, 521, 526, 527, 1028 529, 534, 535, 540, 541, 546, 547, 552, 553, 558, 1029 559, 564, 565, 568, 570, 575, 580, 581, 583, 585, 1030 591, 592, 598, 600, 602, 604, 609, 610, 615, 616, 1031 617, 618, 619, 620, 621, 622, 623, 624, 628, 629, 1032 636, 637, 643, 644, 645, 646, 647, 648, 649, 650, 1033 651, 661, 668, 670, 680, 681, 686, 688, 694, 696, 1034 700, 701, 706, 711, 714, 716, 718, 728, 730, 741, 1035 742, 744, 748, 750, 754, 755, 760, 761, 765, 770, 1036 771, 775, 777, 783, 784, 788, 790, 792, 794, 800, 1037 801, 805, 807, 812, 814, 816, 821, 823, 828, 830, 1038 834, 837, 841, 844, 848, 850, 854, 856, 863, 865, 1039 867, 876, 878, 880, 882, 884, 889, 891, 893, 895, 1040 900, 913, 914, 919, 921, 926, 930, 932, 934, 936, 1041 938, 944, 945, 951, 952, 956, 957, 962, 964, 970, 1042 971, 973, 978, 980, 987, 989, 993, 994, 999, 1001, 1043 1005, 1006, 1010, 1012, 1016, 1017, 1021, 1022, 1026, 1027, 1044 1042, 1043, 1044, 1045, 1046, 1050, 1055, 1062, 1072, 1077, 1045 1082, 1090, 1095, 1100, 1105, 1110, 1118, 1140, 1145, 1152, 1046 1154, 1161, 1166, 1171, 1182, 1187, 1192, 1197, 1202, 1211, 1047 1216, 1224, 1225, 1226, 1227, 1233, 1238, 1246, 1247, 1248, 1048 1249, 1253, 1254, 1255, 1256, 1261, 1262, 1271, 1272, 1277, 1049 1278, 1283, 1285, 1287, 1289, 1291, 1294, 1293, 1305, 1306, 1050 1308, 1318, 1319, 1324, 1328, 1330, 1332, 1334, 1336, 1338, 1051 1340, 1342, 1347, 1349, 1351, 1353, 1355, 1357, 1359, 1361, 1052 1363, 1365, 1367, 1369, 1371, 1377, 1378, 1380, 1382, 1384, 1053 1389, 1390, 1396, 1397, 1399, 1401, 1406, 1408, 1410, 1412, 1054 1417, 1418, 1420, 1422, 1427, 1428, 1430, 1435, 1436, 1438, 1055 1440, 1445, 1447, 1449, 1454, 1455, 1459, 1461, 1467, 1466, 1056 1470, 1472, 1477, 1479, 1485, 1486, 1491, 1492, 1494, 1495, 1057 1504, 1505, 1507, 1509, 1514, 1516, 1522, 1523, 1525, 1528, 1058 1531, 1536, 1537, 1542, 1547, 1551, 1553, 1559, 1558, 1565, 1059 1567, 1573, 1574, 1582, 1583, 1587, 1588, 1589, 1591, 1593, 1060 1600, 1601, 1603, 1605, 1610, 1611, 1617, 1618, 1622, 1623, 1061 1628, 1629, 1630, 1632, 1640, 1641, 1643, 1646, 1648, 1652, 1062 1653, 1654, 1656, 1658, 1662, 1667, 1675, 1676, 1685, 1687, 1063 1692, 1693, 1694, 1698, 1699, 1700, 1704, 1705, 1706, 1710, 1064 1711, 1712, 1717, 1718, 1719, 1720, 1726, 1727, 1729, 1734, 1065 1735, 1740, 1741, 1742, 1743, 1744, 1759, 1760, 1765, 1766, 1066 1774, 1776, 1778, 1781, 1783, 1785, 1808, 1809, 1811, 1813, 1067 1818, 1819, 1821, 1826, 1831, 1832, 1838, 1837, 1841, 1845, 1068 1847, 1849, 1855, 1856, 1861, 1866, 1868, 1873, 1875, 1876, 1069 1878, 1883, 1885, 1887, 1892, 1894, 1899, 1904, 1912, 1918, 1070 1917, 1931, 1932, 1937, 1938, 1942, 1947, 1952, 1960, 1965, 1071 1976, 1977, 1988, 1989, 1995, 1996, 2000, 2001, 2002, 2005, 1072 2004, 2015, 2024, 2030, 2036, 2045, 2051, 2057, 2063, 2069, 1073 2077, 2083, 2091, 2097, 2106, 2107, 2108, 2112, 2116, 2118, 1074 2123, 2124, 2128, 2129, 2134, 2140, 2141, 2144, 2146, 2147, 1075 2151, 2152, 2153, 2154, 2188, 2190, 2191, 2193, 2198, 2203, 1076 2208, 2210, 2212, 2217, 2219, 2221, 2223, 2228, 2230, 2239, 1077 2241, 2242, 2247, 2249, 2251, 2256, 2258, 2260, 2265, 2267, 1078 2269, 2278, 2279, 2280, 2284, 2286, 2288, 2293, 2295, 2297, 1079 2302, 2304, 2306, 2321, 2323, 2324, 2326, 2331, 2332, 2337, 1080 2339, 2341, 2346, 2348, 2350, 2352, 2357, 2359, 2361, 2371, 1081 2373, 2374, 2376, 2381, 2383, 2385, 2390, 2392, 2394, 2396, 1082 2401, 2403, 2405, 2436, 2438, 2439, 2441, 2446, 2451, 2459, 1083 2461, 2463, 2468, 2470, 2475, 2477, 2491, 2492, 2494, 2499, 1084 2501, 2503, 2505, 2507, 2512, 2513, 2515, 2517, 2522, 2524, 1085 2526, 2532, 2534, 2536, 2540, 2542, 2544, 2546, 2560, 2561, 1086 2563, 2568, 2570, 2572, 2574, 2576, 2581, 2582, 2584, 2586, 1087 2591, 2593, 2595, 2601, 2602, 2604, 2613, 2616, 2618, 2621, 1088 2623, 2625, 2638, 2639, 2641, 2646, 2648, 2650, 2652, 2654, 1089 2659, 2660, 2662, 2664, 2669, 2671, 2679, 2680, 2681, 2686, 1090 2687, 2691, 2693, 2695, 2697, 2699, 2701, 2708, 2710, 2712, 1091 2714, 2716, 2718, 2720, 2722, 2724, 2726, 2731, 2733, 2735, 1092 2740, 2766, 2767, 2769, 2773, 2774, 2778, 2780, 2782, 2784, 1093 2786, 2788, 2795, 2797, 2799, 2801, 2803, 2805, 2810, 2815, 1094 2817, 2819, 2837, 2839, 2844, 2845 1094 1095 }; 1095 1096 #endif … … 5216 5217 5217 5218 /* Line 1806 of yacc.c */ 5218 #line 29 0"parser.yy"5219 #line 292 "parser.yy" 5219 5220 { 5220 5221 typedefTable.enterScope(); … … 5225 5226 5226 5227 /* Line 1806 of yacc.c */ 5227 #line 29 6"parser.yy"5228 #line 298 "parser.yy" 5228 5229 { 5229 5230 typedefTable.leaveScope(); … … 5234 5235 5235 5236 /* Line 1806 of yacc.c */ 5236 #line 30 5"parser.yy"5237 #line 307 "parser.yy" 5237 5238 { (yyval.constant) = makeConstantInteger( *(yyvsp[(1) - (1)].tok) ); } 5238 5239 break; … … 5241 5242 5242 5243 /* Line 1806 of yacc.c */ 5243 #line 30 6"parser.yy"5244 #line 308 "parser.yy" 5244 5245 { (yyval.constant) = makeConstantFloat( *(yyvsp[(1) - (1)].tok) ); } 5245 5246 break; … … 5248 5249 5249 5250 /* Line 1806 of yacc.c */ 5250 #line 30 7"parser.yy"5251 #line 309 "parser.yy" 5251 5252 { (yyval.constant) = makeConstantChar( *(yyvsp[(1) - (1)].tok) ); } 5252 5253 break; … … 5255 5256 5256 5257 /* Line 1806 of yacc.c */ 5257 #line 33 2"parser.yy"5258 #line 334 "parser.yy" 5258 5259 { (yyval.constant) = makeConstantStr( *(yyvsp[(1) - (1)].tok) ); } 5259 5260 break; … … 5262 5263 5263 5264 /* Line 1806 of yacc.c */ 5264 #line 33 3"parser.yy"5265 #line 335 "parser.yy" 5265 5266 { (yyval.constant) = (yyvsp[(1) - (2)].constant)->appendstr( (yyvsp[(2) - (2)].tok) ); } 5266 5267 break; 5267 5268 5268 5269 case 18: 5269 5270 /* Line 1806 of yacc.c */5271 #line 340 "parser.yy"5272 { (yyval.en) = new VarRefNode( (yyvsp[(1) - (1)].tok) ); }5273 break;5274 5275 case 19:5276 5270 5277 5271 /* Line 1806 of yacc.c */ … … 5280 5274 break; 5281 5275 5276 case 19: 5277 5278 /* Line 1806 of yacc.c */ 5279 #line 344 "parser.yy" 5280 { (yyval.en) = new VarRefNode( (yyvsp[(1) - (1)].tok) ); } 5281 break; 5282 5282 5283 case 20: 5283 5284 5284 5285 /* Line 1806 of yacc.c */ 5285 #line 34 4"parser.yy"5286 #line 346 "parser.yy" 5286 5287 { (yyval.en) = (yyvsp[(2) - (3)].en); } 5287 5288 break; … … 5290 5291 5291 5292 /* Line 1806 of yacc.c */ 5292 #line 34 6"parser.yy"5293 #line 348 "parser.yy" 5293 5294 { (yyval.en) = new ValofExprNode( (yyvsp[(2) - (3)].sn) ); } 5294 5295 break; … … 5297 5298 5298 5299 /* Line 1806 of yacc.c */ 5299 #line 35 6"parser.yy"5300 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Index ), (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en) ); }5300 #line 358 "parser.yy" 5301 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Index, (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en) ) ); } 5301 5302 break; 5302 5303 … … 5304 5305 5305 5306 /* Line 1806 of yacc.c */ 5306 #line 3 58"parser.yy"5307 #line 360 "parser.yy" 5307 5308 { (yyval.en) = new CompositeExprNode( (yyvsp[(1) - (4)].en), (yyvsp[(3) - (4)].en) ); } 5308 5309 break; … … 5311 5312 5312 5313 /* Line 1806 of yacc.c */ 5313 #line 36 2"parser.yy"5314 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::FieldSel ), (yyvsp[(1) - (3)].en), new VarRefNode( (yyvsp[(3) - (3)].tok) )); }5314 #line 364 "parser.yy" 5315 { (yyval.en) = new CompositeExprNode2( build_fieldSel( (yyvsp[(1) - (3)].en), new VarRefNode( (yyvsp[(3) - (3)].tok) ) ) ); } 5315 5316 break; 5316 5317 … … 5318 5319 5319 5320 /* Line 1806 of yacc.c */ 5320 #line 36 5"parser.yy"5321 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::PFieldSel ), (yyvsp[(1) - (3)].en), new VarRefNode( (yyvsp[(3) - (3)].tok) )); }5321 #line 367 "parser.yy" 5322 { (yyval.en) = new CompositeExprNode2( build_pfieldSel( (yyvsp[(1) - (3)].en), new VarRefNode( (yyvsp[(3) - (3)].tok) ) ) ); } 5322 5323 break; 5323 5324 … … 5325 5326 5326 5327 /* Line 1806 of yacc.c */ 5327 #line 3 68"parser.yy"5328 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::IncrPost ), (yyvsp[(1) - (2)].en) ); }5328 #line 370 "parser.yy" 5329 { (yyval.en) = new CompositeExprNode2( build_opr1( OperatorNode::IncrPost, (yyvsp[(1) - (2)].en) ) ); } 5329 5330 break; 5330 5331 … … 5332 5333 5333 5334 /* Line 1806 of yacc.c */ 5334 #line 37 0"parser.yy"5335 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::DecrPost ), (yyvsp[(1) - (2)].en) ); }5335 #line 372 "parser.yy" 5336 { (yyval.en) = new CompositeExprNode2( build_opr1( OperatorNode::DecrPost, (yyvsp[(1) - (2)].en) ) ); } 5336 5337 break; 5337 5338 … … 5339 5340 5340 5341 /* Line 1806 of yacc.c */ 5341 #line 37 2"parser.yy"5342 #line 374 "parser.yy" 5342 5343 { (yyval.en) = new CompoundLiteralNode( (yyvsp[(2) - (7)].decl), new InitializerNode( (yyvsp[(5) - (7)].in), true ) ); } 5343 5344 break; … … 5346 5347 5347 5348 /* Line 1806 of yacc.c */ 5348 #line 37 4"parser.yy"5349 #line 376 "parser.yy" 5349 5350 { 5350 5351 Token fn; fn.str = new std::string( "?{}" ); // location undefined … … 5356 5357 5357 5358 /* Line 1806 of yacc.c */ 5358 #line 38 3"parser.yy"5359 #line 385 "parser.yy" 5359 5360 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_link( (yyvsp[(3) - (3)].en) )); } 5360 5361 break; … … 5363 5364 5364 5365 /* Line 1806 of yacc.c */ 5365 #line 3 88"parser.yy"5366 #line 390 "parser.yy" 5366 5367 { (yyval.en) = 0; } 5367 5368 break; … … 5370 5371 5371 5372 /* Line 1806 of yacc.c */ 5372 #line 39 1"parser.yy"5373 #line 393 "parser.yy" 5373 5374 { (yyval.en) = (yyvsp[(3) - (3)].en)->set_argName( (yyvsp[(1) - (3)].tok) ); } 5374 5375 break; … … 5377 5378 5378 5379 /* Line 1806 of yacc.c */ 5379 #line 39 6"parser.yy"5380 #line 398 "parser.yy" 5380 5381 { (yyval.en) = (yyvsp[(7) - (7)].en)->set_argName( (yyvsp[(3) - (7)].en) ); } 5381 5382 break; … … 5384 5385 5385 5386 /* Line 1806 of yacc.c */ 5386 #line 398"parser.yy"5387 #line 400 "parser.yy" 5387 5388 { (yyval.en) = (yyvsp[(9) - (9)].en)->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(yyvsp[(3) - (9)].en)->set_link( flattenCommas( (yyvsp[(5) - (9)].en) )))); } 5388 5389 break; … … 5391 5392 5392 5393 /* Line 1806 of yacc.c */ 5393 #line 40 3"parser.yy"5394 #line 405 "parser.yy" 5394 5395 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_link( (yyvsp[(3) - (3)].en) ); } 5395 5396 break; … … 5398 5399 5399 5400 /* Line 1806 of yacc.c */ 5400 #line 4 08"parser.yy"5401 #line 410 "parser.yy" 5401 5402 { (yyval.en) = new VarRefNode( (yyvsp[(1) - (1)].tok) ); } 5402 5403 break; … … 5405 5406 5406 5407 /* Line 1806 of yacc.c */ 5407 #line 41 2"parser.yy"5408 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( (yyvsp[(1) - (3)].tok) ), (yyvsp[(3) - (3)].en) ); }5408 #line 414 "parser.yy" 5409 { (yyval.en) = new CompositeExprNode2( build_fieldSel( (yyvsp[(3) - (3)].en), new VarRefNode( (yyvsp[(1) - (3)].tok) ) ) ); } 5409 5410 break; 5410 5411 … … 5412 5413 5413 5414 /* Line 1806 of yacc.c */ 5414 #line 41 4"parser.yy"5415 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( (yyvsp[(1) - (7)].tok) ), (yyvsp[(5) - (7)].en) ); }5415 #line 416 "parser.yy" 5416 { (yyval.en) = new CompositeExprNode2( build_fieldSel( (yyvsp[(5) - (7)].en), new VarRefNode( (yyvsp[(1) - (7)].tok) ) ) ); } 5416 5417 break; 5417 5418 … … 5419 5420 5420 5421 /* Line 1806 of yacc.c */ 5421 #line 41 6"parser.yy"5422 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( (yyvsp[(1) - (3)].tok) ), (yyvsp[(3) - (3)].en) ); }5422 #line 418 "parser.yy" 5423 { (yyval.en) = new CompositeExprNode2( build_pfieldSel( (yyvsp[(3) - (3)].en), new VarRefNode( (yyvsp[(1) - (3)].tok) ) ) ); } 5423 5424 break; 5424 5425 … … 5426 5427 5427 5428 /* Line 1806 of yacc.c */ 5428 #line 4 18"parser.yy"5429 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( (yyvsp[(1) - (7)].tok) ), (yyvsp[(5) - (7)].en) ); }5429 #line 420 "parser.yy" 5430 { (yyval.en) = new CompositeExprNode2( build_pfieldSel( (yyvsp[(5) - (7)].en), new VarRefNode( (yyvsp[(1) - (7)].tok) ) ) ); } 5430 5431 break; 5431 5432 5432 5433 case 48: 5433 5434 /* Line 1806 of yacc.c */5435 #line 426 "parser.yy"5436 { (yyval.en) = (yyvsp[(1) - (1)].constant); }5437 break;5438 5439 case 49:5440 5434 5441 5435 /* Line 1806 of yacc.c */ … … 5444 5438 break; 5445 5439 5440 case 49: 5441 5442 /* Line 1806 of yacc.c */ 5443 #line 430 "parser.yy" 5444 { (yyval.en) = (yyvsp[(1) - (1)].constant); } 5445 break; 5446 5446 5447 case 50: 5447 5448 5448 5449 /* Line 1806 of yacc.c */ 5449 #line 43 0"parser.yy"5450 #line 432 "parser.yy" 5450 5451 { (yyval.en) = (yyvsp[(2) - (2)].en)->set_extension( true ); } 5451 5452 break; … … 5454 5455 5455 5456 /* Line 1806 of yacc.c */ 5456 #line 432 "parser.yy" 5457 #line 437 "parser.yy" 5458 { (yyval.en) = (yyvsp[(1) - (2)].op) == OperatorNode::AddressOf ? (ExpressionNode*) new CompositeExprNode2( build_addressOf( (yyvsp[(2) - (2)].en) ) ) 5459 : (ExpressionNode*)new CompositeExprNode( new OperatorNode ( (yyvsp[(1) - (2)].op) ), (yyvsp[(2) - (2)].en) ); } 5460 break; 5461 5462 case 52: 5463 5464 /* Line 1806 of yacc.c */ 5465 #line 440 "parser.yy" 5457 5466 { (yyval.en) = new CompositeExprNode( (yyvsp[(1) - (2)].en), (yyvsp[(2) - (2)].en) ); } 5458 5467 break; 5459 5468 5460 case 52:5461 5462 /* Line 1806 of yacc.c */5463 #line 437 "parser.yy"5464 { (yyval.en) = new CompositeExprNode( (yyvsp[(1) - (2)].en), (yyvsp[(2) - (2)].en) ); }5465 break;5466 5467 5469 case 53: 5468 5470 5469 5471 /* Line 1806 of yacc.c */ 5470 #line 4 39"parser.yy"5471 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Incr ), (yyvsp[(2) - (2)].en) ); }5472 #line 442 "parser.yy" 5473 { (yyval.en) = new CompositeExprNode2( build_opr1( OperatorNode::Incr, (yyvsp[(2) - (2)].en) ) ); } 5472 5474 break; 5473 5475 … … 5475 5477 5476 5478 /* Line 1806 of yacc.c */ 5477 #line 44 1"parser.yy"5478 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Decr ), (yyvsp[(2) - (2)].en) ); }5479 #line 444 "parser.yy" 5480 { (yyval.en) = new CompositeExprNode2( build_opr1( OperatorNode::Decr, (yyvsp[(2) - (2)].en) ) ); } 5479 5481 break; 5480 5482 … … 5482 5484 5483 5485 /* Line 1806 of yacc.c */ 5484 #line 44 3"parser.yy"5485 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::SizeOf ), (yyvsp[(2) - (2)].en) ); }5486 #line 446 "parser.yy" 5487 { (yyval.en) = new CompositeExprNode2( build_sizeOf( (yyvsp[(2) - (2)].en) ) ); } 5486 5488 break; 5487 5489 … … 5489 5491 5490 5492 /* Line 1806 of yacc.c */ 5491 #line 44 5"parser.yy"5492 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( (yyvsp[(3) - (4)].decl) )); }5493 #line 448 "parser.yy" 5494 { (yyval.en) = new CompositeExprNode2( build_sizeOf( new TypeValueNode( (yyvsp[(3) - (4)].decl) ) ) ); } 5493 5495 break; 5494 5496 … … 5496 5498 5497 5499 /* Line 1806 of yacc.c */ 5498 #line 4 47"parser.yy"5499 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( (yyvsp[(3) - (6)].decl) ), new VarRefNode( (yyvsp[(5) - (6)].tok) )); }5500 #line 450 "parser.yy" 5501 { (yyval.en) = new CompositeExprNode2( build_offsetOf( new TypeValueNode( (yyvsp[(3) - (6)].decl) ), new VarRefNode( (yyvsp[(5) - (6)].tok) ) ) ); } 5500 5502 break; 5501 5503 … … 5503 5505 5504 5506 /* Line 1806 of yacc.c */ 5505 #line 4 49"parser.yy"5506 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( (yyvsp[(1) - (1)].tok) ) ); }5507 #line 452 "parser.yy" 5508 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( (yyvsp[(1) - (1)].tok) ) ); } 5507 5509 break; 5508 5510 … … 5510 5512 5511 5513 /* Line 1806 of yacc.c */ 5512 #line 45 1"parser.yy"5513 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( (yyvsp[(1) - (4)].tok) ), new TypeValueNode( (yyvsp[(3) - (4)].decl) ) ); }5514 #line 454 "parser.yy" 5515 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( (yyvsp[(1) - (4)].tok) ), new TypeValueNode( (yyvsp[(3) - (4)].decl) ) ); } 5514 5516 break; 5515 5517 … … 5517 5519 5518 5520 /* Line 1806 of yacc.c */ 5519 #line 45 3"parser.yy"5521 #line 456 "parser.yy" 5520 5522 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( (yyvsp[(1) - (4)].tok) ), (yyvsp[(3) - (4)].en) ); } 5521 5523 break; … … 5524 5526 5525 5527 /* Line 1806 of yacc.c */ 5526 #line 45 5"parser.yy"5527 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::AlignOf ), (yyvsp[(2) - (2)].en) ); }5528 #line 458 "parser.yy" 5529 { (yyval.en) = new CompositeExprNode2( build_alignOf( (yyvsp[(2) - (2)].en) ) ); } 5528 5530 break; 5529 5531 … … 5531 5533 5532 5534 /* Line 1806 of yacc.c */ 5533 #line 4 57"parser.yy"5534 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( (yyvsp[(3) - (4)].decl) ) ); }5535 #line 460 "parser.yy" 5536 { (yyval.en) = new CompositeExprNode2( build_alignOf( new TypeValueNode( (yyvsp[(3) - (4)].decl) ) ) ); } 5535 5537 break; 5536 5538 … … 5538 5540 5539 5541 /* Line 1806 of yacc.c */ 5540 #line 46 3"parser.yy"5541 { (yyval. en) = new OperatorNode( OperatorNode::PointTo ); }5542 #line 466 "parser.yy" 5543 { (yyval.op) = OperatorNode::PointTo; } 5542 5544 break; 5543 5545 … … 5545 5547 5546 5548 /* Line 1806 of yacc.c */ 5547 #line 46 4"parser.yy"5548 { (yyval. en) = new OperatorNode( OperatorNode::AddressOf ); }5549 #line 467 "parser.yy" 5550 { (yyval.op) = OperatorNode::AddressOf; } 5549 5551 break; 5550 5552 … … 5552 5554 5553 5555 /* Line 1806 of yacc.c */ 5554 #line 46 6"parser.yy"5555 { (yyval. en) = new OperatorNode( OperatorNode::And ); }5556 #line 469 "parser.yy" 5557 { (yyval.op) = OperatorNode::And; } 5556 5558 break; 5557 5559 … … 5559 5561 5560 5562 /* Line 1806 of yacc.c */ 5561 #line 47 0"parser.yy"5563 #line 473 "parser.yy" 5562 5564 { (yyval.en) = new OperatorNode( OperatorNode::UnPlus ); } 5563 5565 break; … … 5566 5568 5567 5569 /* Line 1806 of yacc.c */ 5568 #line 47 1"parser.yy"5570 #line 474 "parser.yy" 5569 5571 { (yyval.en) = new OperatorNode( OperatorNode::UnMinus ); } 5570 5572 break; … … 5573 5575 5574 5576 /* Line 1806 of yacc.c */ 5575 #line 47 2"parser.yy"5577 #line 475 "parser.yy" 5576 5578 { (yyval.en) = new OperatorNode( OperatorNode::Neg ); } 5577 5579 break; … … 5580 5582 5581 5583 /* Line 1806 of yacc.c */ 5582 #line 47 3"parser.yy"5584 #line 476 "parser.yy" 5583 5585 { (yyval.en) = new OperatorNode( OperatorNode::BitNeg ); } 5584 5586 break; … … 5587 5589 5588 5590 /* Line 1806 of yacc.c */ 5589 #line 4 79"parser.yy"5590 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( (yyvsp[(2) - (4)].decl) ), (yyvsp[(4) - (4)].en) ); }5591 #line 482 "parser.yy" 5592 { (yyval.en) = new CompositeExprNode2( build_cast( new TypeValueNode( (yyvsp[(2) - (4)].decl) ), (yyvsp[(4) - (4)].en) ) ); } 5591 5593 break; 5592 5594 … … 5594 5596 5595 5597 /* Line 1806 of yacc.c */ 5596 #line 48 1"parser.yy"5597 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( (yyvsp[(2) - (4)].decl) ), (yyvsp[(4) - (4)].en) ); }5598 #line 484 "parser.yy" 5599 { (yyval.en) = new CompositeExprNode2( build_cast( new TypeValueNode( (yyvsp[(2) - (4)].decl) ), (yyvsp[(4) - (4)].en) ) ); } 5598 5600 break; 5599 5601 … … 5601 5603 5602 5604 /* Line 1806 of yacc.c */ 5603 #line 4 87"parser.yy"5604 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Mul ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5605 #line 490 "parser.yy" 5606 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Mul, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5605 5607 break; 5606 5608 … … 5608 5610 5609 5611 /* Line 1806 of yacc.c */ 5610 #line 4 89"parser.yy"5611 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Div ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5612 #line 492 "parser.yy" 5613 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Div, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5612 5614 break; 5613 5615 … … 5615 5617 5616 5618 /* Line 1806 of yacc.c */ 5617 #line 49 1"parser.yy"5618 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Mod ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5619 #line 494 "parser.yy" 5620 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Mod, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5619 5621 break; 5620 5622 … … 5622 5624 5623 5625 /* Line 1806 of yacc.c */ 5624 #line 497"parser.yy"5625 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Plus ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5626 #line 500 "parser.yy" 5627 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Plus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5626 5628 break; 5627 5629 … … 5629 5631 5630 5632 /* Line 1806 of yacc.c */ 5631 #line 499"parser.yy"5632 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Minus ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5633 #line 502 "parser.yy" 5634 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Minus, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5633 5635 break; 5634 5636 … … 5636 5638 5637 5639 /* Line 1806 of yacc.c */ 5638 #line 50 5"parser.yy"5639 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::LShift ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5640 #line 508 "parser.yy" 5641 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::LShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5640 5642 break; 5641 5643 … … 5643 5645 5644 5646 /* Line 1806 of yacc.c */ 5645 #line 5 07"parser.yy"5646 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::RShift ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5647 #line 510 "parser.yy" 5648 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::RShift, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5647 5649 break; 5648 5650 … … 5650 5652 5651 5653 /* Line 1806 of yacc.c */ 5652 #line 51 3"parser.yy"5653 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::LThan ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5654 #line 516 "parser.yy" 5655 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::LThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5654 5656 break; 5655 5657 … … 5657 5659 5658 5660 /* Line 1806 of yacc.c */ 5659 #line 51 5"parser.yy"5660 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::GThan ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5661 #line 518 "parser.yy" 5662 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::GThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5661 5663 break; 5662 5664 … … 5664 5666 5665 5667 /* Line 1806 of yacc.c */ 5666 #line 5 17"parser.yy"5667 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::LEThan ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5668 #line 520 "parser.yy" 5669 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::LEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5668 5670 break; 5669 5671 … … 5671 5673 5672 5674 /* Line 1806 of yacc.c */ 5673 #line 5 19"parser.yy"5674 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::GEThan ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5675 #line 522 "parser.yy" 5676 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::GEThan, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5675 5677 break; 5676 5678 … … 5678 5680 5679 5681 /* Line 1806 of yacc.c */ 5680 #line 52 5"parser.yy"5681 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Eq ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5682 #line 528 "parser.yy" 5683 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Eq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5682 5684 break; 5683 5685 … … 5685 5687 5686 5688 /* Line 1806 of yacc.c */ 5687 #line 5 27"parser.yy"5688 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Neq ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5689 #line 530 "parser.yy" 5690 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Neq, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5689 5691 break; 5690 5692 … … 5692 5694 5693 5695 /* Line 1806 of yacc.c */ 5694 #line 53 3"parser.yy"5695 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::BitAnd ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5696 #line 536 "parser.yy" 5697 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::BitAnd, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5696 5698 break; 5697 5699 … … 5699 5701 5700 5702 /* Line 1806 of yacc.c */ 5701 #line 5 39"parser.yy"5702 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Xor ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5703 #line 542 "parser.yy" 5704 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Xor, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5703 5705 break; 5704 5706 … … 5706 5708 5707 5709 /* Line 1806 of yacc.c */ 5708 #line 54 5"parser.yy"5709 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::BitOr ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5710 #line 548 "parser.yy" 5711 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::BitOr, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5710 5712 break; 5711 5713 … … 5713 5715 5714 5716 /* Line 1806 of yacc.c */ 5715 #line 55 1"parser.yy"5716 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::And ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5717 #line 554 "parser.yy" 5718 { (yyval.en) = new CompositeExprNode2( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), true ) ); } 5717 5719 break; 5718 5720 … … 5720 5722 5721 5723 /* Line 1806 of yacc.c */ 5722 #line 5 57"parser.yy"5723 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Or ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5724 #line 560 "parser.yy" 5725 { (yyval.en) = new CompositeExprNode2( build_and_or( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en), false ) ); } 5724 5726 break; 5725 5727 … … 5727 5729 5728 5730 /* Line 1806 of yacc.c */ 5729 #line 56 3"parser.yy"5730 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*(yyvsp[(1) - (5)].en), *(yyvsp[(3) - (5)].en), *(yyvsp[(5) - (5)].en)) ) ); }5731 #line 567 "parser.yy" 5732 { (yyval.en) = new CompositeExprNode2( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); } 5731 5733 break; 5732 5734 … … 5734 5736 5735 5737 /* Line 1806 of yacc.c */ 5736 #line 56 5"parser.yy"5737 { (yyval.en) =new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ); }5738 #line 569 "parser.yy" 5739 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), (yyvsp[(1) - (4)].en), (yyvsp[(4) - (4)].en) ); } 5738 5740 break; 5739 5741 … … 5741 5743 5742 5744 /* Line 1806 of yacc.c */ 5743 #line 5 67"parser.yy"5744 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*(yyvsp[(1) - (5)].en), *(yyvsp[(3) - (5)].en), *(yyvsp[(5) - (5)].en)) ) ); }5745 #line 571 "parser.yy" 5746 { (yyval.en) = new CompositeExprNode2( build_cond( (yyvsp[(1) - (5)].en), (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].en) ) ); } 5745 5747 break; 5746 5748 … … 5748 5750 5749 5751 /* Line 1806 of yacc.c */ 5750 #line 5 78"parser.yy"5751 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5752 #line 582 "parser.yy" 5753 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); } 5752 5754 break; 5753 5755 … … 5755 5757 5756 5758 /* Line 1806 of yacc.c */ 5757 #line 58 0"parser.yy"5758 { (yyval.en) = new CompositeExprNode( (yyvsp[(2) - (3)].en), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5759 #line 584 "parser.yy" 5760 { (yyval.en) = new CompositeExprNode( (yyvsp[(2) - (3)].en), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); } 5759 5761 break; 5760 5762 … … 5762 5764 5763 5765 /* Line 1806 of yacc.c */ 5764 #line 58 2"parser.yy"5766 #line 586 "parser.yy" 5765 5767 { (yyval.en) = ( (yyvsp[(2) - (2)].en) == 0 ) ? (yyvsp[(1) - (2)].en) : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), (yyvsp[(1) - (2)].en), (yyvsp[(2) - (2)].en) ); } 5766 5768 break; … … 5769 5771 5770 5772 /* Line 1806 of yacc.c */ 5771 #line 5 87"parser.yy"5773 #line 591 "parser.yy" 5772 5774 { (yyval.en) = new NullExprNode; } 5773 5775 break; … … 5776 5778 5777 5779 /* Line 1806 of yacc.c */ 5778 #line 59 5"parser.yy"5780 #line 599 "parser.yy" 5779 5781 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ) ); } 5780 5782 break; … … 5783 5785 5784 5786 /* Line 1806 of yacc.c */ 5785 #line 597"parser.yy"5787 #line 601 "parser.yy" 5786 5788 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (yyvsp[(3) - (5)].en) ); } 5787 5789 break; … … 5790 5792 5791 5793 /* Line 1806 of yacc.c */ 5792 #line 599"parser.yy"5794 #line 603 "parser.yy" 5793 5795 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(new NullExprNode)->set_link( (yyvsp[(4) - (6)].en) ) ); } 5794 5796 break; … … 5797 5799 5798 5800 /* Line 1806 of yacc.c */ 5799 #line 60 1"parser.yy"5801 #line 605 "parser.yy" 5800 5802 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(yyvsp[(3) - (7)].en)->set_link( flattenCommas( (yyvsp[(5) - (7)].en) ) ) ); } 5801 5803 break; … … 5804 5806 5805 5807 /* Line 1806 of yacc.c */ 5806 #line 6 07"parser.yy"5808 #line 611 "parser.yy" 5807 5809 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_link( (yyvsp[(3) - (3)].en) ); } 5808 5810 break; … … 5811 5813 5812 5814 /* Line 1806 of yacc.c */ 5813 #line 61 1"parser.yy"5815 #line 615 "parser.yy" 5814 5816 { (yyval.en) = new OperatorNode( OperatorNode::MulAssn ); } 5815 5817 break; … … 5818 5820 5819 5821 /* Line 1806 of yacc.c */ 5820 #line 61 2"parser.yy"5822 #line 616 "parser.yy" 5821 5823 { (yyval.en) = new OperatorNode( OperatorNode::DivAssn ); } 5822 5824 break; … … 5825 5827 5826 5828 /* Line 1806 of yacc.c */ 5827 #line 61 3"parser.yy"5829 #line 617 "parser.yy" 5828 5830 { (yyval.en) = new OperatorNode( OperatorNode::ModAssn ); } 5829 5831 break; … … 5832 5834 5833 5835 /* Line 1806 of yacc.c */ 5834 #line 61 4"parser.yy"5836 #line 618 "parser.yy" 5835 5837 { (yyval.en) = new OperatorNode( OperatorNode::PlusAssn ); } 5836 5838 break; … … 5839 5841 5840 5842 /* Line 1806 of yacc.c */ 5841 #line 61 5"parser.yy"5843 #line 619 "parser.yy" 5842 5844 { (yyval.en) = new OperatorNode( OperatorNode::MinusAssn ); } 5843 5845 break; … … 5846 5848 5847 5849 /* Line 1806 of yacc.c */ 5848 #line 6 16"parser.yy"5850 #line 620 "parser.yy" 5849 5851 { (yyval.en) = new OperatorNode( OperatorNode::LSAssn ); } 5850 5852 break; … … 5853 5855 5854 5856 /* Line 1806 of yacc.c */ 5855 #line 6 17"parser.yy"5857 #line 621 "parser.yy" 5856 5858 { (yyval.en) = new OperatorNode( OperatorNode::RSAssn ); } 5857 5859 break; … … 5860 5862 5861 5863 /* Line 1806 of yacc.c */ 5862 #line 6 18"parser.yy"5864 #line 622 "parser.yy" 5863 5865 { (yyval.en) = new OperatorNode( OperatorNode::AndAssn ); } 5864 5866 break; … … 5867 5869 5868 5870 /* Line 1806 of yacc.c */ 5869 #line 6 19"parser.yy"5871 #line 623 "parser.yy" 5870 5872 { (yyval.en) = new OperatorNode( OperatorNode::ERAssn ); } 5871 5873 break; … … 5874 5876 5875 5877 /* Line 1806 of yacc.c */ 5876 #line 62 0"parser.yy"5878 #line 624 "parser.yy" 5877 5879 { (yyval.en) = new OperatorNode( OperatorNode::OrAssn ); } 5878 5880 break; … … 5881 5883 5882 5884 /* Line 1806 of yacc.c */ 5883 #line 6 26"parser.yy"5884 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Comma ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }5885 #line 631 "parser.yy" 5886 { (yyval.en) = new CompositeExprNode2( build_comma( (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 5885 5887 break; 5886 5888 … … 5888 5890 5889 5891 /* Line 1806 of yacc.c */ 5890 #line 63 1"parser.yy"5892 #line 636 "parser.yy" 5891 5893 { (yyval.en) = 0; } 5892 5894 break; … … 5895 5897 5896 5898 /* Line 1806 of yacc.c */ 5897 #line 64 0"parser.yy"5899 #line 645 "parser.yy" 5898 5900 { (yyval.sn) = (yyvsp[(1) - (1)].sn); } 5899 5901 break; … … 5902 5904 5903 5905 /* Line 1806 of yacc.c */ 5904 #line 6 47"parser.yy"5906 #line 652 "parser.yy" 5905 5907 { 5906 5908 Token fn; fn.str = new std::string( "^?{}" ); // location undefined … … 5913 5915 5914 5916 /* Line 1806 of yacc.c */ 5915 #line 6 57"parser.yy"5917 #line 662 "parser.yy" 5916 5918 { 5917 5919 (yyval.sn) = (yyvsp[(4) - (4)].sn)->add_label( (yyvsp[(1) - (4)].tok) ); … … 5922 5924 5923 5925 /* Line 1806 of yacc.c */ 5924 #line 66 4"parser.yy"5926 #line 669 "parser.yy" 5925 5927 { (yyval.sn) = new CompoundStmtNode( (StatementNode *)0 ); } 5926 5928 break; … … 5929 5931 5930 5932 /* Line 1806 of yacc.c */ 5931 #line 67 1"parser.yy"5933 #line 676 "parser.yy" 5932 5934 { (yyval.sn) = new CompoundStmtNode( (yyvsp[(5) - (7)].sn) ); } 5933 5935 break; … … 5936 5938 5937 5939 /* Line 1806 of yacc.c */ 5938 #line 6 77"parser.yy"5940 #line 682 "parser.yy" 5939 5941 { if ( (yyvsp[(1) - (3)].sn) != 0 ) { (yyvsp[(1) - (3)].sn)->set_link( (yyvsp[(3) - (3)].sn) ); (yyval.sn) = (yyvsp[(1) - (3)].sn); } } 5940 5942 break; … … 5943 5945 5944 5946 /* Line 1806 of yacc.c */ 5945 #line 68 2"parser.yy"5947 #line 687 "parser.yy" 5946 5948 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5947 5949 break; … … 5950 5952 5951 5953 /* Line 1806 of yacc.c */ 5952 #line 68 4"parser.yy"5954 #line 689 "parser.yy" 5953 5955 { // mark all fields in list 5954 5956 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != NULL; iter = (DeclarationNode *)iter->get_link() ) … … 5961 5963 5962 5964 /* Line 1806 of yacc.c */ 5963 #line 69 0"parser.yy"5965 #line 695 "parser.yy" 5964 5966 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5965 5967 break; … … 5968 5970 5969 5971 /* Line 1806 of yacc.c */ 5970 #line 697"parser.yy"5972 #line 702 "parser.yy" 5971 5973 { if ( (yyvsp[(1) - (2)].sn) != 0 ) { (yyvsp[(1) - (2)].sn)->set_link( (yyvsp[(2) - (2)].sn) ); (yyval.sn) = (yyvsp[(1) - (2)].sn); } } 5972 5974 break; … … 5975 5977 5976 5978 /* Line 1806 of yacc.c */ 5977 #line 70 2"parser.yy"5979 #line 707 "parser.yy" 5978 5980 { (yyval.sn) = new StatementNode( StatementNode::Exp, (yyvsp[(1) - (2)].en), 0 ); } 5979 5981 break; … … 5982 5984 5983 5985 /* Line 1806 of yacc.c */ 5984 #line 7 08"parser.yy"5986 #line 713 "parser.yy" 5985 5987 { (yyval.sn) = new StatementNode( StatementNode::If, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 5986 5988 break; … … 5989 5991 5990 5992 /* Line 1806 of yacc.c */ 5991 #line 71 0"parser.yy"5993 #line 715 "parser.yy" 5992 5994 { (yyval.sn) = new StatementNode( StatementNode::If, (yyvsp[(3) - (7)].en), (StatementNode *)mkList((*(yyvsp[(5) - (7)].sn), *(yyvsp[(7) - (7)].sn) )) ); } 5993 5995 break; … … 5996 5998 5997 5999 /* Line 1806 of yacc.c */ 5998 #line 71 2"parser.yy"6000 #line 717 "parser.yy" 5999 6001 { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 6000 6002 break; … … 6003 6005 6004 6006 /* Line 1806 of yacc.c */ 6005 #line 71 4"parser.yy"6007 #line 719 "parser.yy" 6006 6008 { 6007 6009 StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ); … … 6009 6011 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 6010 6012 // statement around the switch. Statements after the initial declaration list can never be executed, and 6011 // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement. 6013 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 6014 // statement. 6012 6015 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_link( sw )) ) : sw; 6013 6016 } … … 6017 6020 6018 6021 /* Line 1806 of yacc.c */ 6019 #line 72 3"parser.yy"6022 #line 729 "parser.yy" 6020 6023 { (yyval.sn) = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 6021 6024 break; … … 6024 6027 6025 6028 /* Line 1806 of yacc.c */ 6026 #line 7 25"parser.yy"6029 #line 731 "parser.yy" 6027 6030 { 6028 6031 StatementNode *sw = new StatementNode( StatementNode::Switch, (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ); … … 6034 6037 6035 6038 /* Line 1806 of yacc.c */ 6036 #line 7 35"parser.yy"6039 #line 741 "parser.yy" 6037 6040 { (yyval.en) = (yyvsp[(1) - (1)].en); } 6038 6041 break; … … 6041 6044 6042 6045 /* Line 1806 of yacc.c */ 6043 #line 737 "parser.yy" 6044 { (yyval.en) = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); } 6046 #line 743 "parser.yy" 6047 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Range, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 6048 break; 6049 6050 case 162: 6051 6052 /* Line 1806 of yacc.c */ 6053 #line 748 "parser.yy" 6054 { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(1) - (1)].en), 0 ); } 6045 6055 break; 6046 6056 … … 6048 6058 6049 6059 /* Line 1806 of yacc.c */ 6050 #line 7 44"parser.yy"6051 { (yyval. en) = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( (yyvsp[(1) - (3)].en) ))->set_link( (yyvsp[(3) - (3)].en) ) ); }6060 #line 750 "parser.yy" 6061 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_link( new StatementNode( StatementNode::Case, (yyvsp[(3) - (3)].en), 0 ) ) ); } 6052 6062 break; 6053 6063 … … 6055 6065 6056 6066 /* Line 1806 of yacc.c */ 6057 #line 7 48"parser.yy"6058 { (yyval.sn) = new StatementNode( StatementNode::Case, (yyvsp[(2) - (3)].en), 0); }6067 #line 754 "parser.yy" 6068 { (yyval.sn) = (yyvsp[(2) - (3)].sn); } 6059 6069 break; 6060 6070 … … 6062 6072 6063 6073 /* Line 1806 of yacc.c */ 6064 #line 7 49"parser.yy"6074 #line 755 "parser.yy" 6065 6075 { (yyval.sn) = new StatementNode( StatementNode::Default ); } 6066 6076 break; … … 6069 6079 6070 6080 /* Line 1806 of yacc.c */ 6071 #line 7 55"parser.yy"6081 #line 761 "parser.yy" 6072 6082 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (2)].sn)->set_link( (yyvsp[(2) - (2)].sn) )); } 6073 6083 break; … … 6076 6086 6077 6087 /* Line 1806 of yacc.c */ 6078 #line 7 59"parser.yy"6088 #line 765 "parser.yy" 6079 6089 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(2) - (2)].sn) ) ); } 6080 6090 break; … … 6083 6093 6084 6094 /* Line 1806 of yacc.c */ 6085 #line 7 64"parser.yy"6095 #line 770 "parser.yy" 6086 6096 { (yyval.sn) = 0; } 6087 6097 break; … … 6090 6100 6091 6101 /* Line 1806 of yacc.c */ 6092 #line 77 0"parser.yy"6102 #line 776 "parser.yy" 6093 6103 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(2) - (2)].sn) ) ); } 6094 6104 break; … … 6097 6107 6098 6108 /* Line 1806 of yacc.c */ 6099 #line 77 2"parser.yy"6109 #line 778 "parser.yy" 6100 6110 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_link( (yyvsp[(2) - (3)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(3) - (3)].sn) ) ) ) ); } 6101 6111 break; … … 6104 6114 6105 6115 /* Line 1806 of yacc.c */ 6106 #line 7 77"parser.yy"6116 #line 783 "parser.yy" 6107 6117 { (yyval.sn) = 0; } 6108 6118 break; … … 6111 6121 6112 6122 /* Line 1806 of yacc.c */ 6113 #line 78 3"parser.yy"6123 #line 789 "parser.yy" 6114 6124 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( (yyvsp[(2) - (2)].sn) ); } 6115 6125 break; … … 6118 6128 6119 6129 /* Line 1806 of yacc.c */ 6120 #line 7 85"parser.yy"6130 #line 791 "parser.yy" 6121 6131 { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*(yyvsp[(2) - (3)].sn), *(yyvsp[(3) - (3)].sn) ) ) ) ); } 6122 6132 break; … … 6125 6135 6126 6136 /* Line 1806 of yacc.c */ 6127 #line 7 87"parser.yy"6137 #line 793 "parser.yy" 6128 6138 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_link( (yyvsp[(2) - (3)].sn)->append_last_case( (yyvsp[(3) - (3)].sn) ))); } 6129 6139 break; … … 6132 6142 6133 6143 /* Line 1806 of yacc.c */ 6134 #line 7 89"parser.yy"6144 #line 795 "parser.yy" 6135 6145 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_link( (yyvsp[(2) - (4)].sn)->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*(yyvsp[(3) - (4)].sn), *(yyvsp[(4) - (4)].sn) ) ) ) ) ) ); } 6136 6146 break; … … 6139 6149 6140 6150 /* Line 1806 of yacc.c */ 6141 #line 794"parser.yy"6151 #line 800 "parser.yy" 6142 6152 { (yyval.sn) = new StatementNode( StatementNode::Break ); } 6143 6153 break; … … 6146 6156 6147 6157 /* Line 1806 of yacc.c */ 6148 #line 80 0"parser.yy"6158 #line 806 "parser.yy" 6149 6159 { (yyval.sn) = 0; } 6150 6160 break; … … 6153 6163 6154 6164 /* Line 1806 of yacc.c */ 6155 #line 80 2"parser.yy"6165 #line 808 "parser.yy" 6156 6166 { (yyval.sn) = 0; } 6157 6167 break; … … 6160 6170 6161 6171 /* Line 1806 of yacc.c */ 6162 #line 8 07"parser.yy"6172 #line 813 "parser.yy" 6163 6173 { (yyval.sn) = new StatementNode( StatementNode::While, (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ); } 6164 6174 break; … … 6167 6177 6168 6178 /* Line 1806 of yacc.c */ 6169 #line 8 09"parser.yy"6179 #line 815 "parser.yy" 6170 6180 { (yyval.sn) = new StatementNode( StatementNode::Do, (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn) ); } 6171 6181 break; … … 6174 6184 6175 6185 /* Line 1806 of yacc.c */ 6176 #line 81 1"parser.yy"6186 #line 817 "parser.yy" 6177 6187 { (yyval.sn) = new StatementNode( StatementNode::For, (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].sn) ); } 6178 6188 break; … … 6181 6191 6182 6192 /* Line 1806 of yacc.c */ 6183 #line 8 16"parser.yy"6193 #line 822 "parser.yy" 6184 6194 { (yyval.en) = new ForCtlExprNode( (yyvsp[(1) - (6)].en), (yyvsp[(4) - (6)].en), (yyvsp[(6) - (6)].en) ); } 6185 6195 break; … … 6188 6198 6189 6199 /* Line 1806 of yacc.c */ 6190 #line 8 18"parser.yy"6200 #line 824 "parser.yy" 6191 6201 { (yyval.en) = new ForCtlExprNode( (yyvsp[(1) - (4)].decl), (yyvsp[(2) - (4)].en), (yyvsp[(4) - (4)].en) ); } 6192 6202 break; … … 6195 6205 6196 6206 /* Line 1806 of yacc.c */ 6197 #line 82 3"parser.yy"6207 #line 829 "parser.yy" 6198 6208 { (yyval.sn) = new StatementNode( StatementNode::Goto, (yyvsp[(2) - (3)].tok) ); } 6199 6209 break; … … 6202 6212 6203 6213 /* Line 1806 of yacc.c */ 6204 #line 8 27"parser.yy"6214 #line 833 "parser.yy" 6205 6215 { (yyval.sn) = new StatementNode( StatementNode::Goto, (yyvsp[(3) - (4)].en) ); } 6206 6216 break; … … 6209 6219 6210 6220 /* Line 1806 of yacc.c */ 6211 #line 83 0"parser.yy"6221 #line 836 "parser.yy" 6212 6222 { (yyval.sn) = new StatementNode( StatementNode::Continue ); } 6213 6223 break; … … 6216 6226 6217 6227 /* Line 1806 of yacc.c */ 6218 #line 8 34"parser.yy"6228 #line 840 "parser.yy" 6219 6229 { (yyval.sn) = new StatementNode( StatementNode::Continue, (yyvsp[(2) - (3)].tok) ); } 6220 6230 break; … … 6223 6233 6224 6234 /* Line 1806 of yacc.c */ 6225 #line 8 37"parser.yy"6235 #line 843 "parser.yy" 6226 6236 { (yyval.sn) = new StatementNode( StatementNode::Break ); } 6227 6237 break; … … 6230 6240 6231 6241 /* Line 1806 of yacc.c */ 6232 #line 84 1"parser.yy"6242 #line 847 "parser.yy" 6233 6243 { (yyval.sn) = new StatementNode( StatementNode::Break, (yyvsp[(2) - (3)].tok) ); } 6234 6244 break; … … 6237 6247 6238 6248 /* Line 1806 of yacc.c */ 6239 #line 84 3"parser.yy"6249 #line 849 "parser.yy" 6240 6250 { (yyval.sn) = new StatementNode( StatementNode::Return, (yyvsp[(2) - (3)].en), 0 ); } 6241 6251 break; … … 6244 6254 6245 6255 /* Line 1806 of yacc.c */ 6246 #line 8 45"parser.yy"6256 #line 851 "parser.yy" 6247 6257 { (yyval.sn) = new StatementNode( StatementNode::Throw, (yyvsp[(2) - (3)].en), 0 ); } 6248 6258 break; … … 6251 6261 6252 6262 /* Line 1806 of yacc.c */ 6253 #line 8 49"parser.yy"6263 #line 855 "parser.yy" 6254 6264 { (yyval.sn) = new StatementNode( StatementNode::Throw, (yyvsp[(2) - (3)].en), 0 ); } 6255 6265 break; … … 6258 6268 6259 6269 /* Line 1806 of yacc.c */ 6260 #line 85 1"parser.yy"6270 #line 857 "parser.yy" 6261 6271 { (yyval.sn) = new StatementNode( StatementNode::Throw, (yyvsp[(2) - (5)].en), 0 ); } 6262 6272 break; … … 6265 6275 6266 6276 /* Line 1806 of yacc.c */ 6267 #line 8 58"parser.yy"6277 #line 864 "parser.yy" 6268 6278 { (yyval.sn) = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*(yyvsp[(2) - (3)].sn),*(yyvsp[(3) - (3)].pn) )))); } 6269 6279 break; … … 6272 6282 6273 6283 /* Line 1806 of yacc.c */ 6274 #line 86 0"parser.yy"6284 #line 866 "parser.yy" 6275 6285 { (yyval.sn) = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*(yyvsp[(2) - (3)].sn),*(yyvsp[(3) - (3)].pn) )))); } 6276 6286 break; … … 6279 6289 6280 6290 /* Line 1806 of yacc.c */ 6281 #line 86 2"parser.yy"6291 #line 868 "parser.yy" 6282 6292 { 6283 6293 (yyvsp[(3) - (4)].pn)->set_link( (yyvsp[(4) - (4)].pn) ); … … 6289 6299 6290 6300 /* Line 1806 of yacc.c */ 6291 #line 87 3"parser.yy"6301 #line 879 "parser.yy" 6292 6302 { (yyval.pn) = StatementNode::newCatchStmt( 0, (yyvsp[(5) - (5)].sn), true ); } 6293 6303 break; … … 6296 6306 6297 6307 /* Line 1806 of yacc.c */ 6298 #line 8 75"parser.yy"6308 #line 881 "parser.yy" 6299 6309 { (yyval.pn) = (yyvsp[(1) - (6)].pn)->set_link( StatementNode::newCatchStmt( 0, (yyvsp[(6) - (6)].sn), true ) ); } 6300 6310 break; … … 6303 6313 6304 6314 /* Line 1806 of yacc.c */ 6305 #line 8 77"parser.yy"6315 #line 883 "parser.yy" 6306 6316 { (yyval.pn) = StatementNode::newCatchStmt( 0, (yyvsp[(5) - (5)].sn), true ); } 6307 6317 break; … … 6310 6320 6311 6321 /* Line 1806 of yacc.c */ 6312 #line 8 79"parser.yy"6322 #line 885 "parser.yy" 6313 6323 { (yyval.pn) = (yyvsp[(1) - (6)].pn)->set_link( StatementNode::newCatchStmt( 0, (yyvsp[(6) - (6)].sn), true ) ); } 6314 6324 break; … … 6317 6327 6318 6328 /* Line 1806 of yacc.c */ 6319 #line 8 84"parser.yy"6329 #line 890 "parser.yy" 6320 6330 { (yyval.pn) = StatementNode::newCatchStmt( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ); } 6321 6331 break; … … 6324 6334 6325 6335 /* Line 1806 of yacc.c */ 6326 #line 8 86"parser.yy"6336 #line 892 "parser.yy" 6327 6337 { (yyval.pn) = (yyvsp[(1) - (10)].pn)->set_link( StatementNode::newCatchStmt( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ); } 6328 6338 break; … … 6331 6341 6332 6342 /* Line 1806 of yacc.c */ 6333 #line 8 88"parser.yy"6343 #line 894 "parser.yy" 6334 6344 { (yyval.pn) = StatementNode::newCatchStmt( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ); } 6335 6345 break; … … 6338 6348 6339 6349 /* Line 1806 of yacc.c */ 6340 #line 89 0"parser.yy"6350 #line 896 "parser.yy" 6341 6351 { (yyval.pn) = (yyvsp[(1) - (10)].pn)->set_link( StatementNode::newCatchStmt( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ); } 6342 6352 break; … … 6345 6355 6346 6356 /* Line 1806 of yacc.c */ 6347 #line 895"parser.yy"6357 #line 901 "parser.yy" 6348 6358 { 6349 6359 (yyval.pn) = new StatementNode( StatementNode::Finally, 0, (yyvsp[(2) - (2)].sn) ); … … 6355 6365 6356 6366 /* Line 1806 of yacc.c */ 6357 #line 9 09"parser.yy"6367 #line 915 "parser.yy" 6358 6368 { 6359 6369 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6365 6375 6366 6376 /* Line 1806 of yacc.c */ 6367 #line 9 14"parser.yy"6377 #line 920 "parser.yy" 6368 6378 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 6369 6379 break; … … 6372 6382 6373 6383 /* Line 1806 of yacc.c */ 6374 #line 9 16"parser.yy"6384 #line 922 "parser.yy" 6375 6385 { 6376 6386 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6382 6392 6383 6393 /* Line 1806 of yacc.c */ 6384 #line 9 25"parser.yy"6394 #line 931 "parser.yy" 6385 6395 { (yyval.sn) = new AsmStmtNode( StatementNode::Asm, (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ); } 6386 6396 break; … … 6389 6399 6390 6400 /* Line 1806 of yacc.c */ 6391 #line 9 27"parser.yy"6401 #line 933 "parser.yy" 6392 6402 { (yyval.sn) = new AsmStmtNode( StatementNode::Asm, (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ); } 6393 6403 break; … … 6396 6406 6397 6407 /* Line 1806 of yacc.c */ 6398 #line 9 29"parser.yy"6408 #line 935 "parser.yy" 6399 6409 { (yyval.sn) = new AsmStmtNode( StatementNode::Asm, (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ); } 6400 6410 break; … … 6403 6413 6404 6414 /* Line 1806 of yacc.c */ 6405 #line 93 1"parser.yy"6415 #line 937 "parser.yy" 6406 6416 { (yyval.sn) = new AsmStmtNode( StatementNode::Asm, (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].constant) ); } 6407 6417 break; … … 6410 6420 6411 6421 /* Line 1806 of yacc.c */ 6412 #line 93 3"parser.yy"6422 #line 939 "parser.yy" 6413 6423 { (yyval.sn) = new AsmStmtNode( StatementNode::Asm, (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].constant), (yyvsp[(12) - (14)].label) ); } 6414 6424 break; … … 6417 6427 6418 6428 /* Line 1806 of yacc.c */ 6419 #line 9 38"parser.yy"6429 #line 944 "parser.yy" 6420 6430 { (yyval.flag) = false; } 6421 6431 break; … … 6424 6434 6425 6435 /* Line 1806 of yacc.c */ 6426 #line 94 0"parser.yy"6436 #line 946 "parser.yy" 6427 6437 { (yyval.flag) = true; } 6428 6438 break; … … 6431 6441 6432 6442 /* Line 1806 of yacc.c */ 6433 #line 9 45"parser.yy"6443 #line 951 "parser.yy" 6434 6444 { (yyval.en) = 0; } 6435 6445 break; … … 6438 6448 6439 6449 /* Line 1806 of yacc.c */ 6440 #line 95 2"parser.yy"6450 #line 958 "parser.yy" 6441 6451 { (yyval.en) = (ExpressionNode *)(yyvsp[(1) - (3)].en)->set_link( (yyvsp[(3) - (3)].en) ); } 6442 6452 break; … … 6445 6455 6446 6456 /* Line 1806 of yacc.c */ 6447 #line 9 57"parser.yy"6457 #line 963 "parser.yy" 6448 6458 { (yyval.en) = new AsmExprNode( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ); } 6449 6459 break; … … 6452 6462 6453 6463 /* Line 1806 of yacc.c */ 6454 #line 9 59"parser.yy"6464 #line 965 "parser.yy" 6455 6465 { (yyval.en) = new AsmExprNode( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ); } 6456 6466 break; … … 6459 6469 6460 6470 /* Line 1806 of yacc.c */ 6461 #line 9 64"parser.yy"6471 #line 970 "parser.yy" 6462 6472 { (yyval.constant) = 0; } 6463 6473 break; … … 6466 6476 6467 6477 /* Line 1806 of yacc.c */ 6468 #line 9 66"parser.yy"6478 #line 972 "parser.yy" 6469 6479 { (yyval.constant) = (yyvsp[(1) - (1)].constant); } 6470 6480 break; … … 6473 6483 6474 6484 /* Line 1806 of yacc.c */ 6475 #line 9 68"parser.yy"6485 #line 974 "parser.yy" 6476 6486 { (yyval.constant) = (ConstantNode *)(yyvsp[(1) - (3)].constant)->set_link( (yyvsp[(3) - (3)].constant) ); } 6477 6487 break; … … 6480 6490 6481 6491 /* Line 1806 of yacc.c */ 6482 #line 97 3"parser.yy"6492 #line 979 "parser.yy" 6483 6493 { (yyval.label) = new LabelNode(); (yyval.label)->append_label( (yyvsp[(1) - (1)].tok) ); } 6484 6494 break; … … 6487 6497 6488 6498 /* Line 1806 of yacc.c */ 6489 #line 9 75"parser.yy"6499 #line 981 "parser.yy" 6490 6500 { (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->append_label( (yyvsp[(3) - (3)].tok) ); } 6491 6501 break; … … 6494 6504 6495 6505 /* Line 1806 of yacc.c */ 6496 #line 98 2"parser.yy"6506 #line 988 "parser.yy" 6497 6507 { (yyval.decl) = 0; } 6498 6508 break; … … 6501 6511 6502 6512 /* Line 1806 of yacc.c */ 6503 #line 9 89"parser.yy"6513 #line 995 "parser.yy" 6504 6514 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6505 6515 break; … … 6508 6518 6509 6519 /* Line 1806 of yacc.c */ 6510 #line 994"parser.yy"6520 #line 1000 "parser.yy" 6511 6521 { (yyval.decl) = 0; } 6512 6522 break; … … 6515 6525 6516 6526 /* Line 1806 of yacc.c */ 6517 #line 100 1"parser.yy"6527 #line 1007 "parser.yy" 6518 6528 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 6519 6529 break; … … 6522 6532 6523 6533 /* Line 1806 of yacc.c */ 6524 #line 10 15"parser.yy"6534 #line 1021 "parser.yy" 6525 6535 {} 6526 6536 break; … … 6529 6539 6530 6540 /* Line 1806 of yacc.c */ 6531 #line 10 16"parser.yy"6541 #line 1022 "parser.yy" 6532 6542 {} 6533 6543 break; … … 6536 6546 6537 6547 /* Line 1806 of yacc.c */ 6538 #line 10 45"parser.yy"6548 #line 1051 "parser.yy" 6539 6549 { 6540 6550 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6546 6556 6547 6557 /* Line 1806 of yacc.c */ 6548 #line 105 2"parser.yy"6558 #line 1058 "parser.yy" 6549 6559 { 6550 6560 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6556 6566 6557 6567 /* Line 1806 of yacc.c */ 6558 #line 10 57"parser.yy"6568 #line 1063 "parser.yy" 6559 6569 { 6560 6570 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (6)].tok), TypedefTable::ID ); … … 6566 6576 6567 6577 /* Line 1806 of yacc.c */ 6568 #line 10 67"parser.yy"6578 #line 1073 "parser.yy" 6569 6579 { 6570 6580 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6576 6586 6577 6587 /* Line 1806 of yacc.c */ 6578 #line 107 2"parser.yy"6588 #line 1078 "parser.yy" 6579 6589 { 6580 6590 typedefTable.setNextIdentifier( *(yyvsp[(2) - (3)].tok) ); … … 6586 6596 6587 6597 /* Line 1806 of yacc.c */ 6588 #line 10 77"parser.yy"6598 #line 1083 "parser.yy" 6589 6599 { 6590 6600 typedefTable.setNextIdentifier( *(yyvsp[(3) - (4)].tok) ); … … 6596 6606 6597 6607 /* Line 1806 of yacc.c */ 6598 #line 10 85"parser.yy"6608 #line 1091 "parser.yy" 6599 6609 { 6600 6610 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6606 6616 6607 6617 /* Line 1806 of yacc.c */ 6608 #line 109 0"parser.yy"6618 #line 1096 "parser.yy" 6609 6619 { 6610 6620 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6616 6626 6617 6627 /* Line 1806 of yacc.c */ 6618 #line 1 095"parser.yy"6628 #line 1101 "parser.yy" 6619 6629 { 6620 6630 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6626 6636 6627 6637 /* Line 1806 of yacc.c */ 6628 #line 110 0"parser.yy"6638 #line 1106 "parser.yy" 6629 6639 { 6630 6640 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6636 6646 6637 6647 /* Line 1806 of yacc.c */ 6638 #line 11 05"parser.yy"6648 #line 1111 "parser.yy" 6639 6649 { 6640 6650 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 6646 6656 6647 6657 /* Line 1806 of yacc.c */ 6648 #line 111 3"parser.yy"6658 #line 1119 "parser.yy" 6649 6659 { 6650 6660 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(3) - (8)].tok), DeclarationNode::newTuple( 0 ), (yyvsp[(6) - (8)].decl), 0, true ); … … 6655 6665 6656 6666 /* Line 1806 of yacc.c */ 6657 #line 11 36"parser.yy"6667 #line 1142 "parser.yy" 6658 6668 { 6659 6669 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6664 6674 6665 6675 /* Line 1806 of yacc.c */ 6666 #line 114 0"parser.yy"6676 #line 1146 "parser.yy" 6667 6677 { 6668 6678 (yyval.decl) = DeclarationNode::newFunction( (yyvsp[(2) - (7)].tok), (yyvsp[(1) - (7)].decl), (yyvsp[(5) - (7)].decl), 0, true ); … … 6673 6683 6674 6684 /* Line 1806 of yacc.c */ 6675 #line 11 47"parser.yy"6685 #line 1153 "parser.yy" 6676 6686 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 6677 6687 break; … … 6680 6690 6681 6691 /* Line 1806 of yacc.c */ 6682 #line 115 1"parser.yy"6692 #line 1157 "parser.yy" 6683 6693 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (9)].decl)->appendList( (yyvsp[(7) - (9)].decl) ) ); } 6684 6694 break; … … 6687 6697 6688 6698 /* Line 1806 of yacc.c */ 6689 #line 11 56"parser.yy"6699 #line 1162 "parser.yy" 6690 6700 { 6691 6701 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6697 6707 6698 6708 /* Line 1806 of yacc.c */ 6699 #line 116 1"parser.yy"6709 #line 1167 "parser.yy" 6700 6710 { 6701 6711 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6707 6717 6708 6718 /* Line 1806 of yacc.c */ 6709 #line 11 66"parser.yy"6719 #line 1172 "parser.yy" 6710 6720 { 6711 6721 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (5)].tok), TypedefTable::TD ); … … 6717 6727 6718 6728 /* Line 1806 of yacc.c */ 6719 #line 11 77"parser.yy"6729 #line 1183 "parser.yy" 6720 6730 { 6721 6731 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6727 6737 6728 6738 /* Line 1806 of yacc.c */ 6729 #line 118 2"parser.yy"6739 #line 1188 "parser.yy" 6730 6740 { 6731 6741 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6737 6747 6738 6748 /* Line 1806 of yacc.c */ 6739 #line 11 87"parser.yy"6749 #line 1193 "parser.yy" 6740 6750 { 6741 6751 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6747 6757 6748 6758 /* Line 1806 of yacc.c */ 6749 #line 119 2"parser.yy"6759 #line 1198 "parser.yy" 6750 6760 { 6751 6761 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6757 6767 6758 6768 /* Line 1806 of yacc.c */ 6759 #line 1 197"parser.yy"6769 #line 1203 "parser.yy" 6760 6770 { 6761 6771 typedefTable.addToEnclosingScope( TypedefTable::TD ); … … 6767 6777 6768 6778 /* Line 1806 of yacc.c */ 6769 #line 12 06"parser.yy"6779 #line 1212 "parser.yy" 6770 6780 { 6771 6781 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (4)].tok), TypedefTable::TD ); … … 6777 6787 6778 6788 /* Line 1806 of yacc.c */ 6779 #line 121 1"parser.yy"6789 #line 1217 "parser.yy" 6780 6790 { 6781 6791 typedefTable.addToEnclosingScope( *(yyvsp[(5) - (7)].tok), TypedefTable::TD ); … … 6787 6797 6788 6798 /* Line 1806 of yacc.c */ 6789 #line 12 28"parser.yy"6799 #line 1234 "parser.yy" 6790 6800 { 6791 6801 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6797 6807 6798 6808 /* Line 1806 of yacc.c */ 6799 #line 123 3"parser.yy"6809 #line 1239 "parser.yy" 6800 6810 { 6801 6811 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 6807 6817 6808 6818 /* Line 1806 of yacc.c */ 6809 #line 12 55"parser.yy"6819 #line 1261 "parser.yy" 6810 6820 { (yyval.decl) = 0; } 6811 6821 break; … … 6814 6824 6815 6825 /* Line 1806 of yacc.c */ 6816 #line 12 67"parser.yy"6826 #line 1273 "parser.yy" 6817 6827 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6818 6828 break; … … 6821 6831 6822 6832 /* Line 1806 of yacc.c */ 6823 #line 12 78"parser.yy"6833 #line 1284 "parser.yy" 6824 6834 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Const ); } 6825 6835 break; … … 6828 6838 6829 6839 /* Line 1806 of yacc.c */ 6830 #line 128 0"parser.yy"6840 #line 1286 "parser.yy" 6831 6841 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Restrict ); } 6832 6842 break; … … 6835 6845 6836 6846 /* Line 1806 of yacc.c */ 6837 #line 128 2"parser.yy"6847 #line 1288 "parser.yy" 6838 6848 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Volatile ); } 6839 6849 break; … … 6842 6852 6843 6853 /* Line 1806 of yacc.c */ 6844 #line 12 84"parser.yy"6854 #line 1290 "parser.yy" 6845 6855 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); } 6846 6856 break; … … 6849 6859 6850 6860 /* Line 1806 of yacc.c */ 6851 #line 12 86"parser.yy"6861 #line 1292 "parser.yy" 6852 6862 { (yyval.decl) = DeclarationNode::newQualifier( DeclarationNode::Atomic ); } 6853 6863 break; … … 6856 6866 6857 6867 /* Line 1806 of yacc.c */ 6858 #line 12 88"parser.yy"6868 #line 1294 "parser.yy" 6859 6869 { 6860 6870 typedefTable.enterScope(); … … 6865 6875 6866 6876 /* Line 1806 of yacc.c */ 6867 #line 129 2"parser.yy"6877 #line 1298 "parser.yy" 6868 6878 { 6869 6879 typedefTable.leaveScope(); … … 6875 6885 6876 6886 /* Line 1806 of yacc.c */ 6877 #line 130 1"parser.yy"6887 #line 1307 "parser.yy" 6878 6888 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6879 6889 break; … … 6882 6892 6883 6893 /* Line 1806 of yacc.c */ 6884 #line 130 3"parser.yy"6894 #line 1309 "parser.yy" 6885 6895 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 6886 6896 break; … … 6889 6899 6890 6900 /* Line 1806 of yacc.c */ 6891 #line 13 14"parser.yy"6901 #line 1320 "parser.yy" 6892 6902 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 6893 6903 break; … … 6896 6906 6897 6907 /* Line 1806 of yacc.c */ 6898 #line 132 3"parser.yy"6908 #line 1329 "parser.yy" 6899 6909 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } 6900 6910 break; … … 6903 6913 6904 6914 /* Line 1806 of yacc.c */ 6905 #line 13 25"parser.yy"6915 #line 1331 "parser.yy" 6906 6916 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Static ); } 6907 6917 break; … … 6910 6920 6911 6921 /* Line 1806 of yacc.c */ 6912 #line 13 27"parser.yy"6922 #line 1333 "parser.yy" 6913 6923 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Auto ); } 6914 6924 break; … … 6917 6927 6918 6928 /* Line 1806 of yacc.c */ 6919 #line 13 29"parser.yy"6929 #line 1335 "parser.yy" 6920 6930 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Register ); } 6921 6931 break; … … 6924 6934 6925 6935 /* Line 1806 of yacc.c */ 6926 #line 133 1"parser.yy"6936 #line 1337 "parser.yy" 6927 6937 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Inline ); } 6928 6938 break; … … 6931 6941 6932 6942 /* Line 1806 of yacc.c */ 6933 #line 133 3"parser.yy"6943 #line 1339 "parser.yy" 6934 6944 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); } 6935 6945 break; … … 6938 6948 6939 6949 /* Line 1806 of yacc.c */ 6940 #line 13 35"parser.yy"6950 #line 1341 "parser.yy" 6941 6951 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Noreturn ); } 6942 6952 break; … … 6945 6955 6946 6956 /* Line 1806 of yacc.c */ 6947 #line 13 37"parser.yy"6957 #line 1343 "parser.yy" 6948 6958 { (yyval.decl) = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); } 6949 6959 break; … … 6952 6962 6953 6963 /* Line 1806 of yacc.c */ 6954 #line 134 2"parser.yy"6964 #line 1348 "parser.yy" 6955 6965 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Char ); } 6956 6966 break; … … 6959 6969 6960 6970 /* Line 1806 of yacc.c */ 6961 #line 13 44"parser.yy"6971 #line 1350 "parser.yy" 6962 6972 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Double ); } 6963 6973 break; … … 6966 6976 6967 6977 /* Line 1806 of yacc.c */ 6968 #line 13 46"parser.yy"6978 #line 1352 "parser.yy" 6969 6979 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Float ); } 6970 6980 break; … … 6973 6983 6974 6984 /* Line 1806 of yacc.c */ 6975 #line 13 48"parser.yy"6985 #line 1354 "parser.yy" 6976 6986 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Int ); } 6977 6987 break; … … 6980 6990 6981 6991 /* Line 1806 of yacc.c */ 6982 #line 135 0"parser.yy"6992 #line 1356 "parser.yy" 6983 6993 { (yyval.decl) = DeclarationNode::newModifier( DeclarationNode::Long ); } 6984 6994 break; … … 6987 6997 6988 6998 /* Line 1806 of yacc.c */ 6989 #line 135 2"parser.yy"6999 #line 1358 "parser.yy" 6990 7000 { (yyval.decl) = DeclarationNode::newModifier( DeclarationNode::Short ); } 6991 7001 break; … … 6994 7004 6995 7005 /* Line 1806 of yacc.c */ 6996 #line 13 54"parser.yy"7006 #line 1360 "parser.yy" 6997 7007 { (yyval.decl) = DeclarationNode::newModifier( DeclarationNode::Signed ); } 6998 7008 break; … … 7001 7011 7002 7012 /* Line 1806 of yacc.c */ 7003 #line 13 56"parser.yy"7013 #line 1362 "parser.yy" 7004 7014 { (yyval.decl) = DeclarationNode::newModifier( DeclarationNode::Unsigned ); } 7005 7015 break; … … 7008 7018 7009 7019 /* Line 1806 of yacc.c */ 7010 #line 13 58"parser.yy"7020 #line 1364 "parser.yy" 7011 7021 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Void ); } 7012 7022 break; … … 7015 7025 7016 7026 /* Line 1806 of yacc.c */ 7017 #line 136 0"parser.yy"7027 #line 1366 "parser.yy" 7018 7028 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Bool ); } 7019 7029 break; … … 7022 7032 7023 7033 /* Line 1806 of yacc.c */ 7024 #line 136 2"parser.yy"7034 #line 1368 "parser.yy" 7025 7035 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Complex ); } 7026 7036 break; … … 7029 7039 7030 7040 /* Line 1806 of yacc.c */ 7031 #line 13 64"parser.yy"7041 #line 1370 "parser.yy" 7032 7042 { (yyval.decl) = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); } 7033 7043 break; … … 7036 7046 7037 7047 /* Line 1806 of yacc.c */ 7038 #line 13 66"parser.yy"7048 #line 1372 "parser.yy" 7039 7049 { (yyval.decl) = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 7040 7050 break; … … 7043 7053 7044 7054 /* Line 1806 of yacc.c */ 7045 #line 137 3"parser.yy"7055 #line 1379 "parser.yy" 7046 7056 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7047 7057 break; … … 7050 7060 7051 7061 /* Line 1806 of yacc.c */ 7052 #line 13 75"parser.yy"7062 #line 1381 "parser.yy" 7053 7063 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7054 7064 break; … … 7057 7067 7058 7068 /* Line 1806 of yacc.c */ 7059 #line 13 77"parser.yy"7069 #line 1383 "parser.yy" 7060 7070 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7061 7071 break; … … 7064 7074 7065 7075 /* Line 1806 of yacc.c */ 7066 #line 13 79"parser.yy"7076 #line 1385 "parser.yy" 7067 7077 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addType( (yyvsp[(1) - (3)].decl) ); } 7068 7078 break; … … 7071 7081 7072 7082 /* Line 1806 of yacc.c */ 7073 #line 13 85"parser.yy"7083 #line 1391 "parser.yy" 7074 7084 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7075 7085 break; … … 7078 7088 7079 7089 /* Line 1806 of yacc.c */ 7080 #line 139 2"parser.yy"7090 #line 1398 "parser.yy" 7081 7091 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7082 7092 break; … … 7085 7095 7086 7096 /* Line 1806 of yacc.c */ 7087 #line 1 394"parser.yy"7097 #line 1400 "parser.yy" 7088 7098 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7089 7099 break; … … 7092 7102 7093 7103 /* Line 1806 of yacc.c */ 7094 #line 1 396"parser.yy"7104 #line 1402 "parser.yy" 7095 7105 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addType( (yyvsp[(2) - (2)].decl) ); } 7096 7106 break; … … 7099 7109 7100 7110 /* Line 1806 of yacc.c */ 7101 #line 140 1"parser.yy"7111 #line 1407 "parser.yy" 7102 7112 { (yyval.decl) = (yyvsp[(3) - (4)].decl); } 7103 7113 break; … … 7106 7116 7107 7117 /* Line 1806 of yacc.c */ 7108 #line 140 3"parser.yy"7118 #line 1409 "parser.yy" 7109 7119 { (yyval.decl) = DeclarationNode::newTypeof( (yyvsp[(3) - (4)].en) ); } 7110 7120 break; … … 7113 7123 7114 7124 /* Line 1806 of yacc.c */ 7115 #line 14 05"parser.yy"7125 #line 1411 "parser.yy" 7116 7126 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].decl) ); } 7117 7127 break; … … 7120 7130 7121 7131 /* Line 1806 of yacc.c */ 7122 #line 14 07"parser.yy"7132 #line 1413 "parser.yy" 7123 7133 { (yyval.decl) = DeclarationNode::newAttr( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 7124 7134 break; … … 7127 7137 7128 7138 /* Line 1806 of yacc.c */ 7129 #line 141 3"parser.yy"7139 #line 1419 "parser.yy" 7130 7140 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7131 7141 break; … … 7134 7144 7135 7145 /* Line 1806 of yacc.c */ 7136 #line 14 15"parser.yy"7146 #line 1421 "parser.yy" 7137 7147 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7138 7148 break; … … 7141 7151 7142 7152 /* Line 1806 of yacc.c */ 7143 #line 14 17"parser.yy"7153 #line 1423 "parser.yy" 7144 7154 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7145 7155 break; … … 7148 7158 7149 7159 /* Line 1806 of yacc.c */ 7150 #line 142 3"parser.yy"7160 #line 1429 "parser.yy" 7151 7161 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7152 7162 break; … … 7155 7165 7156 7166 /* Line 1806 of yacc.c */ 7157 #line 14 25"parser.yy"7167 #line 1431 "parser.yy" 7158 7168 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7159 7169 break; … … 7162 7172 7163 7173 /* Line 1806 of yacc.c */ 7164 #line 143 1"parser.yy"7174 #line 1437 "parser.yy" 7165 7175 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7166 7176 break; … … 7169 7179 7170 7180 /* Line 1806 of yacc.c */ 7171 #line 143 3"parser.yy"7181 #line 1439 "parser.yy" 7172 7182 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7173 7183 break; … … 7176 7186 7177 7187 /* Line 1806 of yacc.c */ 7178 #line 14 35"parser.yy"7188 #line 1441 "parser.yy" 7179 7189 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7180 7190 break; … … 7183 7193 7184 7194 /* Line 1806 of yacc.c */ 7185 #line 144 0"parser.yy"7195 #line 1446 "parser.yy" 7186 7196 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(1) - (1)].tok) ); } 7187 7197 break; … … 7190 7200 7191 7201 /* Line 1806 of yacc.c */ 7192 #line 144 2"parser.yy"7202 #line 1448 "parser.yy" 7193 7203 { (yyval.decl) = DeclarationNode::newFromTypedef( (yyvsp[(2) - (2)].tok) )->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7194 7204 break; … … 7197 7207 7198 7208 /* Line 1806 of yacc.c */ 7199 #line 14 44"parser.yy"7209 #line 1450 "parser.yy" 7200 7210 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7201 7211 break; … … 7204 7214 7205 7215 /* Line 1806 of yacc.c */ 7206 #line 14 54"parser.yy"7216 #line 1460 "parser.yy" 7207 7217 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (4)].aggKey), 0, 0, (yyvsp[(3) - (4)].decl), true ); } 7208 7218 break; … … 7211 7221 7212 7222 /* Line 1806 of yacc.c */ 7213 #line 14 56"parser.yy"7223 #line 1462 "parser.yy" 7214 7224 { 7215 7225 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 7221 7231 7222 7232 /* Line 1806 of yacc.c */ 7223 #line 146 1"parser.yy"7233 #line 1467 "parser.yy" 7224 7234 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 7225 7235 break; … … 7228 7238 7229 7239 /* Line 1806 of yacc.c */ 7230 #line 146 3"parser.yy"7240 #line 1469 "parser.yy" 7231 7241 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (6)].aggKey), (yyvsp[(2) - (6)].tok), 0, (yyvsp[(5) - (6)].decl), true ); } 7232 7242 break; … … 7235 7245 7236 7246 /* Line 1806 of yacc.c */ 7237 #line 14 65"parser.yy"7247 #line 1471 "parser.yy" 7238 7248 { (yyval.decl) = DeclarationNode::newAggregate( (yyvsp[(1) - (7)].aggKey), 0, (yyvsp[(3) - (7)].en), (yyvsp[(6) - (7)].decl), false ); } 7239 7249 break; … … 7242 7252 7243 7253 /* Line 1806 of yacc.c */