Changeset c331406
- Timestamp:
- Aug 5, 2016, 11:03:04 AM (9 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 */ 7244 #line 14 67"parser.yy"7254 #line 1473 "parser.yy" 7245 7255 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 7246 7256 break; … … 7249 7259 7250 7260 /* Line 1806 of yacc.c */ 7251 #line 147 2"parser.yy"7261 #line 1478 "parser.yy" 7252 7262 { (yyval.aggKey) = DeclarationNode::Struct; } 7253 7263 break; … … 7256 7266 7257 7267 /* Line 1806 of yacc.c */ 7258 #line 14 74"parser.yy"7268 #line 1480 "parser.yy" 7259 7269 { (yyval.aggKey) = DeclarationNode::Union; } 7260 7270 break; … … 7263 7273 7264 7274 /* Line 1806 of yacc.c */ 7265 #line 14 79"parser.yy"7275 #line 1485 "parser.yy" 7266 7276 { (yyval.decl) = 0; } 7267 7277 break; … … 7270 7280 7271 7281 /* Line 1806 of yacc.c */ 7272 #line 148 1"parser.yy"7282 #line 1487 "parser.yy" 7273 7283 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 7274 7284 break; … … 7277 7287 7278 7288 /* Line 1806 of yacc.c */ 7279 #line 14 87"parser.yy"7289 #line 1493 "parser.yy" 7280 7290 { (yyval.decl) = (yyvsp[(2) - (3)].decl)->set_extension( true ); } 7281 7291 break; … … 7284 7294 7285 7295 /* Line 1806 of yacc.c */ 7286 #line 149 0"parser.yy"7296 #line 1496 "parser.yy" 7287 7297 { // mark all fields in list 7288 7298 for ( DeclarationNode *iter = (yyvsp[(2) - (3)].decl); iter != NULL; iter = (DeclarationNode *)iter->get_link() ) … … 7295 7305 7296 7306 /* Line 1806 of yacc.c */ 7297 #line 150 0"parser.yy"7307 #line 1506 "parser.yy" 7298 7308 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addName( (yyvsp[(2) - (2)].tok) ); } 7299 7309 break; … … 7302 7312 7303 7313 /* Line 1806 of yacc.c */ 7304 #line 150 2"parser.yy"7314 #line 1508 "parser.yy" 7305 7315 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(1) - (3)].decl)->cloneType( (yyvsp[(3) - (3)].tok) ) ); } 7306 7316 break; … … 7309 7319 7310 7320 /* Line 1806 of yacc.c */ 7311 #line 15 04"parser.yy"7321 #line 1510 "parser.yy" 7312 7322 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(1) - (2)].decl)->cloneType( 0 ) ); } 7313 7323 break; … … 7316 7326 7317 7327 /* Line 1806 of yacc.c */ 7318 #line 15 09"parser.yy"7328 #line 1515 "parser.yy" 7319 7329 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7320 7330 break; … … 7323 7333 7324 7334 /* Line 1806 of yacc.c */ 7325 #line 151 1"parser.yy"7335 #line 1517 "parser.yy" 7326 7336 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(1) - (4)].decl)->cloneBaseType( (yyvsp[(4) - (4)].decl) ) ); } 7327 7337 break; … … 7330 7340 7331 7341 /* Line 1806 of yacc.c */ 7332 #line 15 16"parser.yy"7342 #line 1522 "parser.yy" 7333 7343 { (yyval.decl) = DeclarationNode::newName( 0 ); /* XXX */ } 7334 7344 break; … … 7337 7347 7338 7348 /* Line 1806 of yacc.c */ 7339 #line 15 18"parser.yy"7349 #line 1524 "parser.yy" 7340 7350 { (yyval.decl) = DeclarationNode::newBitfield( (yyvsp[(1) - (1)].en) ); } 7341 7351 break; … … 7344 7354 7345 7355 /* Line 1806 of yacc.c */ 7346 #line 152 1"parser.yy"7356 #line 1527 "parser.yy" 7347 7357 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 7348 7358 break; … … 7351 7361 7352 7362 /* Line 1806 of yacc.c */ 7353 #line 15 24"parser.yy"7363 #line 1530 "parser.yy" 7354 7364 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addBitfield( (yyvsp[(2) - (2)].en) ); } 7355 7365 break; … … 7358 7368 7359 7369 /* Line 1806 of yacc.c */ 7360 #line 153 0"parser.yy"7370 #line 1536 "parser.yy" 7361 7371 { (yyval.en) = 0; } 7362 7372 break; … … 7365 7375 7366 7376 /* Line 1806 of yacc.c */ 7367 #line 153 2"parser.yy"7377 #line 1538 "parser.yy" 7368 7378 { (yyval.en) = (yyvsp[(1) - (1)].en); } 7369 7379 break; … … 7372 7382 7373 7383 /* Line 1806 of yacc.c */ 7374 #line 15 37"parser.yy"7384 #line 1543 "parser.yy" 7375 7385 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7376 7386 break; … … 7379 7389 7380 7390 /* Line 1806 of yacc.c */ 7381 #line 15 46"parser.yy"7391 #line 1552 "parser.yy" 7382 7392 { (yyval.decl) = DeclarationNode::newEnum( 0, (yyvsp[(3) - (5)].decl) ); } 7383 7393 break; … … 7386 7396 7387 7397 /* Line 1806 of yacc.c */ 7388 #line 15 48"parser.yy"7398 #line 1554 "parser.yy" 7389 7399 { 7390 7400 typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); … … 7396 7406 7397 7407 /* Line 1806 of yacc.c */ 7398 #line 155 3"parser.yy"7408 #line 1559 "parser.yy" 7399 7409 { typedefTable.makeTypedef( *(yyvsp[(2) - (2)].tok) ); } 7400 7410 break; … … 7403 7413 7404 7414 /* Line 1806 of yacc.c */ 7405 #line 15 55"parser.yy"7415 #line 1561 "parser.yy" 7406 7416 { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(2) - (7)].tok), (yyvsp[(5) - (7)].decl) ); } 7407 7417 break; … … 7410 7420 7411 7421 /* Line 1806 of yacc.c */ 7412 #line 156 0"parser.yy"7422 #line 1566 "parser.yy" 7413 7423 { (yyval.decl) = DeclarationNode::newEnumConstant( (yyvsp[(1) - (2)].tok), (yyvsp[(2) - (2)].en) ); } 7414 7424 break; … … 7417 7427 7418 7428 /* Line 1806 of yacc.c */ 7419 #line 156 2"parser.yy"7429 #line 1568 "parser.yy" 7420 7430 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( DeclarationNode::newEnumConstant( (yyvsp[(3) - (4)].tok), (yyvsp[(4) - (4)].en) ) ); } 7421 7431 break; … … 7424 7434 7425 7435 /* Line 1806 of yacc.c */ 7426 #line 15 67"parser.yy"7436 #line 1573 "parser.yy" 7427 7437 { (yyval.en) = 0; } 7428 7438 break; … … 7431 7441 7432 7442 /* Line 1806 of yacc.c */ 7433 #line 15 69"parser.yy"7443 #line 1575 "parser.yy" 7434 7444 { (yyval.en) = (yyvsp[(2) - (2)].en); } 7435 7445 break; … … 7438 7448 7439 7449 /* Line 1806 of yacc.c */ 7440 #line 15 76"parser.yy"7450 #line 1582 "parser.yy" 7441 7451 { (yyval.decl) = 0; } 7442 7452 break; … … 7445 7455 7446 7456 /* Line 1806 of yacc.c */ 7447 #line 15 84"parser.yy"7457 #line 1590 "parser.yy" 7448 7458 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7449 7459 break; … … 7452 7462 7453 7463 /* Line 1806 of yacc.c */ 7454 #line 15 86"parser.yy"7464 #line 1592 "parser.yy" 7455 7465 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7456 7466 break; … … 7459 7469 7460 7470 /* Line 1806 of yacc.c */ 7461 #line 15 88"parser.yy"7471 #line 1594 "parser.yy" 7462 7472 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7463 7473 break; … … 7466 7476 7467 7477 /* Line 1806 of yacc.c */ 7468 #line 1 596"parser.yy"7478 #line 1602 "parser.yy" 7469 7479 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7470 7480 break; … … 7473 7483 7474 7484 /* Line 1806 of yacc.c */ 7475 #line 1 598"parser.yy"7485 #line 1604 "parser.yy" 7476 7486 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7477 7487 break; … … 7480 7490 7481 7491 /* Line 1806 of yacc.c */ 7482 #line 160 0"parser.yy"7492 #line 1606 "parser.yy" 7483 7493 { (yyval.decl) = (yyvsp[(1) - (9)].decl)->appendList( (yyvsp[(5) - (9)].decl) )->appendList( (yyvsp[(9) - (9)].decl) ); } 7484 7494 break; … … 7487 7497 7488 7498 /* Line 1806 of yacc.c */ 7489 #line 16 06"parser.yy"7499 #line 1612 "parser.yy" 7490 7500 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7491 7501 break; … … 7494 7504 7495 7505 /* Line 1806 of yacc.c */ 7496 #line 161 1"parser.yy"7506 #line 1617 "parser.yy" 7497 7507 { (yyval.decl) = 0; } 7498 7508 break; … … 7501 7511 7502 7512 /* Line 1806 of yacc.c */ 7503 #line 16 18"parser.yy"7513 #line 1624 "parser.yy" 7504 7514 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->addVarArgs(); } 7505 7515 break; … … 7508 7518 7509 7519 /* Line 1806 of yacc.c */ 7510 #line 16 25"parser.yy"7520 #line 1631 "parser.yy" 7511 7521 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7512 7522 break; … … 7515 7525 7516 7526 /* Line 1806 of yacc.c */ 7517 #line 16 27"parser.yy"7527 #line 1633 "parser.yy" 7518 7528 { (yyval.decl) = (yyvsp[(1) - (5)].decl)->appendList( (yyvsp[(5) - (5)].decl) ); } 7519 7529 break; … … 7522 7532 7523 7533 /* Line 1806 of yacc.c */ 7524 #line 16 36"parser.yy"7534 #line 1642 "parser.yy" 7525 7535 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7526 7536 break; … … 7529 7539 7530 7540 /* Line 1806 of yacc.c */ 7531 #line 16 39"parser.yy"7541 #line 1645 "parser.yy" 7532 7542 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addName( (yyvsp[(2) - (3)].tok) ); } 7533 7543 break; … … 7536 7546 7537 7547 /* Line 1806 of yacc.c */ 7538 #line 164 1"parser.yy"7548 #line 1647 "parser.yy" 7539 7549 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addName( (yyvsp[(3) - (4)].tok) )->addQualifiers( (yyvsp[(1) - (4)].decl) ); } 7540 7550 break; … … 7543 7553 7544 7554 /* Line 1806 of yacc.c */ 7545 #line 165 1"parser.yy"7555 #line 1657 "parser.yy" 7546 7556 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7547 7557 break; … … 7550 7560 7551 7561 /* Line 1806 of yacc.c */ 7552 #line 16 57"parser.yy"7562 #line 1663 "parser.yy" 7553 7563 { 7554 7564 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7560 7570 7561 7571 /* Line 1806 of yacc.c */ 7562 #line 166 2"parser.yy"7572 #line 1668 "parser.yy" 7563 7573 { 7564 7574 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 7570 7580 7571 7581 /* Line 1806 of yacc.c */ 7572 #line 167 1"parser.yy"7582 #line 1677 "parser.yy" 7573 7583 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7574 7584 break; … … 7577 7587 7578 7588 /* Line 1806 of yacc.c */ 7579 #line 168 0"parser.yy"7589 #line 1686 "parser.yy" 7580 7590 { (yyval.decl) = DeclarationNode::newName( (yyvsp[(1) - (1)].tok) ); } 7581 7591 break; … … 7584 7594 7585 7595 /* Line 1806 of yacc.c */ 7586 #line 168 2"parser.yy"7596 #line 1688 "parser.yy" 7587 7597 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( DeclarationNode::newName( (yyvsp[(3) - (3)].tok) ) ); } 7588 7598 break; … … 7591 7601 7592 7602 /* Line 1806 of yacc.c */ 7593 #line 17 07"parser.yy"7603 #line 1713 "parser.yy" 7594 7604 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7595 7605 break; … … 7598 7608 7599 7609 /* Line 1806 of yacc.c */ 7600 #line 17 15"parser.yy"7610 #line 1721 "parser.yy" 7601 7611 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addType( (yyvsp[(1) - (2)].decl) ); } 7602 7612 break; … … 7605 7615 7606 7616 /* Line 1806 of yacc.c */ 7607 #line 172 0"parser.yy"7617 #line 1726 "parser.yy" 7608 7618 { (yyval.in) = 0; } 7609 7619 break; … … 7612 7622 7613 7623 /* Line 1806 of yacc.c */ 7614 #line 172 2"parser.yy"7624 #line 1728 "parser.yy" 7615 7625 { (yyval.in) = (yyvsp[(2) - (2)].in); } 7616 7626 break; … … 7619 7629 7620 7630 /* Line 1806 of yacc.c */ 7621 #line 17 24"parser.yy"7631 #line 1730 "parser.yy" 7622 7632 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_maybeConstructed( false ); } 7623 7633 break; … … 7626 7636 7627 7637 /* Line 1806 of yacc.c */ 7628 #line 17 28"parser.yy"7638 #line 1734 "parser.yy" 7629 7639 { (yyval.in) = new InitializerNode( (yyvsp[(1) - (1)].en) ); } 7630 7640 break; … … 7633 7643 7634 7644 /* Line 1806 of yacc.c */ 7635 #line 17 29"parser.yy"7645 #line 1735 "parser.yy" 7636 7646 { (yyval.in) = new InitializerNode( (yyvsp[(2) - (4)].in), true ); } 7637 7647 break; … … 7640 7650 7641 7651 /* Line 1806 of yacc.c */ 7642 #line 17 34"parser.yy"7652 #line 1740 "parser.yy" 7643 7653 { (yyval.in) = 0; } 7644 7654 break; … … 7647 7657 7648 7658 /* Line 1806 of yacc.c */ 7649 #line 17 36"parser.yy"7659 #line 1742 "parser.yy" 7650 7660 { (yyval.in) = (yyvsp[(2) - (2)].in)->set_designators( (yyvsp[(1) - (2)].en) ); } 7651 7661 break; … … 7654 7664 7655 7665 /* Line 1806 of yacc.c */ 7656 #line 17 37"parser.yy"7666 #line 1743 "parser.yy" 7657 7667 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (3)].in)->set_link( (yyvsp[(3) - (3)].in) ) ); } 7658 7668 break; … … 7661 7671 7662 7672 /* Line 1806 of yacc.c */ 7663 #line 17 39"parser.yy"7673 #line 1745 "parser.yy" 7664 7674 { (yyval.in) = (InitializerNode *)( (yyvsp[(1) - (4)].in)->set_link( (yyvsp[(4) - (4)].in)->set_designators( (yyvsp[(3) - (4)].en) ) ) ); } 7665 7675 break; … … 7668 7678 7669 7679 /* Line 1806 of yacc.c */ 7670 #line 17 55"parser.yy"7680 #line 1761 "parser.yy" 7671 7681 { (yyval.en) = new VarRefNode( (yyvsp[(1) - (2)].tok) ); } 7672 7682 break; … … 7675 7685 7676 7686 /* Line 1806 of yacc.c */ 7677 #line 176 1"parser.yy"7687 #line 1767 "parser.yy" 7678 7688 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (2)].en)->set_link( (yyvsp[(2) - (2)].en) )); } 7679 7689 break; … … 7682 7692 7683 7693 /* Line 1806 of yacc.c */ 7684 #line 17 69"parser.yy"7694 #line 1775 "parser.yy" 7685 7695 { (yyval.en) = new DesignatorNode( new VarRefNode( (yyvsp[(1) - (1)].tok) ) ); } 7686 7696 break; … … 7689 7699 7690 7700 /* Line 1806 of yacc.c */ 7691 #line 177 1"parser.yy"7701 #line 1777 "parser.yy" 7692 7702 { (yyval.en) = new DesignatorNode( new VarRefNode( (yyvsp[(2) - (2)].tok) ) ); } 7693 7703 break; … … 7696 7706 7697 7707 /* Line 1806 of yacc.c */ 7698 #line 17 74"parser.yy"7708 #line 1780 "parser.yy" 7699 7709 { (yyval.en) = new DesignatorNode( (yyvsp[(3) - (5)].en), true ); } 7700 7710 break; … … 7703 7713 7704 7714 /* Line 1806 of yacc.c */ 7705 #line 17 76"parser.yy"7715 #line 1782 "parser.yy" 7706 7716 { (yyval.en) = new DesignatorNode( (yyvsp[(3) - (5)].en), true ); } 7707 7717 break; … … 7710 7720 7711 7721 /* Line 1806 of yacc.c */ 7712 #line 17 78"parser.yy"7713 { (yyval.en) = new DesignatorNode( new CompositeExprNode ( new OperatorNode( OperatorNode::Range ), (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ), true ); }7722 #line 1784 "parser.yy" 7723 { (yyval.en) = new DesignatorNode( new CompositeExprNode2( build_opr2( OperatorNode::Range, (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].en) ) ), true ); } 7714 7724 break; 7715 7725 … … 7717 7727 7718 7728 /* Line 1806 of yacc.c */ 7719 #line 178 0"parser.yy"7729 #line 1786 "parser.yy" 7720 7730 { (yyval.en) = new DesignatorNode( (yyvsp[(4) - (6)].en) ); } 7721 7731 break; … … 7724 7734 7725 7735 /* Line 1806 of yacc.c */ 7726 #line 18 04"parser.yy"7736 #line 1810 "parser.yy" 7727 7737 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7728 7738 break; … … 7731 7741 7732 7742 /* Line 1806 of yacc.c */ 7733 #line 18 06"parser.yy"7743 #line 1812 "parser.yy" 7734 7744 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7735 7745 break; … … 7738 7748 7739 7749 /* Line 1806 of yacc.c */ 7740 #line 18 08"parser.yy"7750 #line 1814 "parser.yy" 7741 7751 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->addQualifiers( (yyvsp[(2) - (3)].decl) )->addQualifiers( (yyvsp[(3) - (3)].decl) ); } 7742 7752 break; … … 7745 7755 7746 7756 /* Line 1806 of yacc.c */ 7747 #line 18 14"parser.yy"7757 #line 1820 "parser.yy" 7748 7758 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 7749 7759 break; … … 7752 7762 7753 7763 /* Line 1806 of yacc.c */ 7754 #line 18 16"parser.yy"7764 #line 1822 "parser.yy" 7755 7765 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 7756 7766 break; … … 7759 7769 7760 7770 /* Line 1806 of yacc.c */ 7761 #line 182 1"parser.yy"7771 #line 1827 "parser.yy" 7762 7772 { (yyval.decl) = DeclarationNode::newFromTypeGen( (yyvsp[(1) - (4)].tok), (yyvsp[(3) - (4)].en) ); } 7763 7773 break; … … 7766 7776 7767 7777 /* Line 1806 of yacc.c */ 7768 #line 18 27"parser.yy"7778 #line 1833 "parser.yy" 7769 7779 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->appendList( (yyvsp[(3) - (4)].decl) ); } 7770 7780 break; … … 7773 7783 7774 7784 /* Line 1806 of yacc.c */ 7775 #line 183 2"parser.yy"7785 #line 1838 "parser.yy" 7776 7786 { typedefTable.addToEnclosingScope( *(yyvsp[(2) - (2)].tok), TypedefTable::TD ); } 7777 7787 break; … … 7780 7790 7781 7791 /* Line 1806 of yacc.c */ 7782 #line 18 34"parser.yy"7792 #line 1840 "parser.yy" 7783 7793 { (yyval.decl) = DeclarationNode::newTypeParam( (yyvsp[(1) - (4)].tclass), (yyvsp[(2) - (4)].tok) )->addAssertions( (yyvsp[(4) - (4)].decl) ); } 7784 7794 break; … … 7787 7797 7788 7798 /* Line 1806 of yacc.c */ 7789 #line 184 0"parser.yy"7799 #line 1846 "parser.yy" 7790 7800 { (yyval.tclass) = DeclarationNode::Type; } 7791 7801 break; … … 7794 7804 7795 7805 /* Line 1806 of yacc.c */ 7796 #line 184 2"parser.yy"7806 #line 1848 "parser.yy" 7797 7807 { (yyval.tclass) = DeclarationNode::Ftype; } 7798 7808 break; … … 7801 7811 7802 7812 /* Line 1806 of yacc.c */ 7803 #line 18 44"parser.yy"7813 #line 1850 "parser.yy" 7804 7814 { (yyval.tclass) = DeclarationNode::Dtype; } 7805 7815 break; … … 7808 7818 7809 7819 /* Line 1806 of yacc.c */ 7810 #line 18 49"parser.yy"7820 #line 1855 "parser.yy" 7811 7821 { (yyval.decl) = 0; } 7812 7822 break; … … 7815 7825 7816 7826 /* Line 1806 of yacc.c */ 7817 #line 185 1"parser.yy"7827 #line 1857 "parser.yy" 7818 7828 { (yyval.decl) = (yyvsp[(1) - (2)].decl) != 0 ? (yyvsp[(1) - (2)].decl)->appendList( (yyvsp[(2) - (2)].decl) ) : (yyvsp[(2) - (2)].decl); } 7819 7829 break; … … 7822 7832 7823 7833 /* Line 1806 of yacc.c */ 7824 #line 18 56"parser.yy"7834 #line 1862 "parser.yy" 7825 7835 { 7826 7836 typedefTable.openTrait( *(yyvsp[(2) - (5)].tok) ); … … 7832 7842 7833 7843 /* Line 1806 of yacc.c */ 7834 #line 186 1"parser.yy"7844 #line 1867 "parser.yy" 7835 7845 { (yyval.decl) = (yyvsp[(4) - (5)].decl); } 7836 7846 break; … … 7839 7849 7840 7850 /* Line 1806 of yacc.c */ 7841 #line 186 3"parser.yy"7851 #line 1869 "parser.yy" 7842 7852 { (yyval.decl) = 0; } 7843 7853 break; … … 7846 7856 7847 7857 /* Line 1806 of yacc.c */ 7848 #line 18 68"parser.yy"7858 #line 1874 "parser.yy" 7849 7859 { (yyval.en) = new TypeValueNode( (yyvsp[(1) - (1)].decl) ); } 7850 7860 break; … … 7853 7863 7854 7864 /* Line 1806 of yacc.c */ 7855 #line 187 1"parser.yy"7865 #line 1877 "parser.yy" 7856 7866 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_link( new TypeValueNode( (yyvsp[(3) - (3)].decl) ))); } 7857 7867 break; … … 7860 7870 7861 7871 /* Line 1806 of yacc.c */ 7862 #line 187 3"parser.yy"7872 #line 1879 "parser.yy" 7863 7873 { (yyval.en) = (ExpressionNode *)( (yyvsp[(1) - (3)].en)->set_link( (yyvsp[(3) - (3)].en) )); } 7864 7874 break; … … 7867 7877 7868 7878 /* Line 1806 of yacc.c */ 7869 #line 18 78"parser.yy"7879 #line 1884 "parser.yy" 7870 7880 { (yyval.decl) = (yyvsp[(2) - (2)].decl); } 7871 7881 break; … … 7874 7884 7875 7885 /* Line 1806 of yacc.c */ 7876 #line 188 0"parser.yy"7886 #line 1886 "parser.yy" 7877 7887 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addQualifiers( (yyvsp[(1) - (3)].decl) ); } 7878 7888 break; … … 7881 7891 7882 7892 /* Line 1806 of yacc.c */ 7883 #line 188 2"parser.yy"7893 #line 1888 "parser.yy" 7884 7894 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl)->copyStorageClasses( (yyvsp[(1) - (3)].decl) ) ); } 7885 7895 break; … … 7888 7898 7889 7899 /* Line 1806 of yacc.c */ 7890 #line 18 87"parser.yy"7900 #line 1893 "parser.yy" 7891 7901 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addAssertions( (yyvsp[(2) - (2)].decl) ); } 7892 7902 break; … … 7895 7905 7896 7906 /* Line 1806 of yacc.c */ 7897 #line 18 89"parser.yy"7907 #line 1895 "parser.yy" 7898 7908 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addAssertions( (yyvsp[(2) - (4)].decl) )->addType( (yyvsp[(4) - (4)].decl) ); } 7899 7909 break; … … 7902 7912 7903 7913 /* Line 1806 of yacc.c */ 7904 #line 1 894"parser.yy"7914 #line 1900 "parser.yy" 7905 7915 { 7906 7916 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (1)].tok), TypedefTable::TD ); … … 7912 7922 7913 7923 /* Line 1806 of yacc.c */ 7914 #line 1 899"parser.yy"7924 #line 1905 "parser.yy" 7915 7925 { 7916 7926 typedefTable.addToEnclosingScope( *(yyvsp[(1) - (6)].tok), TypedefTable::TG ); … … 7922 7932 7923 7933 /* Line 1806 of yacc.c */ 7924 #line 19 07"parser.yy"7934 #line 1913 "parser.yy" 7925 7935 { 7926 7936 typedefTable.addToEnclosingScope( *(yyvsp[(2) - (9)].tok), TypedefTable::ID ); … … 7932 7942 7933 7943 /* Line 1806 of yacc.c */ 7934 #line 191 2"parser.yy"7944 #line 1918 "parser.yy" 7935 7945 { 7936 7946 typedefTable.enterTrait( *(yyvsp[(2) - (8)].tok) ); … … 7942 7952 7943 7953 /* Line 1806 of yacc.c */ 7944 #line 19 17"parser.yy"7954 #line 1923 "parser.yy" 7945 7955 { 7946 7956 typedefTable.leaveTrait(); … … 7953 7963 7954 7964 /* Line 1806 of yacc.c */ 7955 #line 19 27"parser.yy"7965 #line 1933 "parser.yy" 7956 7966 { (yyval.decl) = (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ); } 7957 7967 break; … … 7960 7970 7961 7971 /* Line 1806 of yacc.c */ 7962 #line 19 37"parser.yy"7972 #line 1943 "parser.yy" 7963 7973 { 7964 7974 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7970 7980 7971 7981 /* Line 1806 of yacc.c */ 7972 #line 194 2"parser.yy"7982 #line 1948 "parser.yy" 7973 7983 { 7974 7984 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 7980 7990 7981 7991 /* Line 1806 of yacc.c */ 7982 #line 19 47"parser.yy"7992 #line 1953 "parser.yy" 7983 7993 { 7984 7994 typedefTable.addToEnclosingScope2( *(yyvsp[(5) - (5)].tok), TypedefTable::ID ); … … 7990 8000 7991 8001 /* Line 1806 of yacc.c */ 7992 #line 19 55"parser.yy"8002 #line 1961 "parser.yy" 7993 8003 { 7994 8004 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 8000 8010 8001 8011 /* Line 1806 of yacc.c */ 8002 #line 196 0"parser.yy"8012 #line 1966 "parser.yy" 8003 8013 { 8004 8014 typedefTable.addToEnclosingScope2( TypedefTable::ID ); … … 8010 8020 8011 8021 /* Line 1806 of yacc.c */ 8012 #line 197 0"parser.yy"8022 #line 1976 "parser.yy" 8013 8023 {} 8014 8024 break; … … 8017 8027 8018 8028 /* Line 1806 of yacc.c */ 8019 #line 197 2"parser.yy"8029 #line 1978 "parser.yy" 8020 8030 { 8021 8031 if ( theTree ) { … … 8030 8040 8031 8041 /* Line 1806 of yacc.c */ 8032 #line 19 84"parser.yy"8042 #line 1990 "parser.yy" 8033 8043 { (yyval.decl) = ( (yyvsp[(1) - (3)].decl) != NULL ) ? (yyvsp[(1) - (3)].decl)->appendList( (yyvsp[(3) - (3)].decl) ) : (yyvsp[(3) - (3)].decl); } 8034 8044 break; … … 8037 8047 8038 8048 /* Line 1806 of yacc.c */ 8039 #line 19 89"parser.yy"8049 #line 1995 "parser.yy" 8040 8050 { (yyval.decl) = 0; } 8041 8051 break; … … 8044 8054 8045 8055 /* Line 1806 of yacc.c */ 8046 #line 1997"parser.yy"8056 #line 2003 "parser.yy" 8047 8057 {} 8048 8058 break; … … 8051 8061 8052 8062 /* Line 1806 of yacc.c */ 8053 #line 1999"parser.yy"8063 #line 2005 "parser.yy" 8054 8064 { 8055 8065 linkageStack.push( linkage ); … … 8061 8071 8062 8072 /* Line 1806 of yacc.c */ 8063 #line 20 04"parser.yy"8073 #line 2010 "parser.yy" 8064 8074 { 8065 8075 linkage = linkageStack.top(); … … 8072 8082 8073 8083 /* Line 1806 of yacc.c */ 8074 #line 201 0"parser.yy"8084 #line 2016 "parser.yy" 8075 8085 { // mark all fields in list 8076 8086 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != NULL; iter = (DeclarationNode *)iter->get_link() ) … … 8083 8093 8084 8094 /* Line 1806 of yacc.c */ 8085 #line 20 25"parser.yy"8095 #line 2031 "parser.yy" 8086 8096 { 8087 8097 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8094 8104 8095 8105 /* Line 1806 of yacc.c */ 8096 #line 203 1"parser.yy"8106 #line 2037 "parser.yy" 8097 8107 { 8098 8108 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8105 8115 8106 8116 /* Line 1806 of yacc.c */ 8107 #line 204 0"parser.yy"8117 #line 2046 "parser.yy" 8108 8118 { 8109 8119 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8116 8126 8117 8127 /* Line 1806 of yacc.c */ 8118 #line 20 46"parser.yy"8128 #line 2052 "parser.yy" 8119 8129 { 8120 8130 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8125 8135 8126 8136 case 537: 8127 8128 /* Line 1806 of yacc.c */8129 #line 2052 "parser.yy"8130 {8131 typedefTable.addToEnclosingScope( TypedefTable::ID );8132 typedefTable.leaveScope();8133 (yyval.decl) = (yyvsp[(2) - (3)].decl)->addFunctionBody( (yyvsp[(3) - (3)].sn) )->addQualifiers( (yyvsp[(1) - (3)].decl) );8134 }8135 break;8136 8137 case 538:8138 8137 8139 8138 /* Line 1806 of yacc.c */ … … 8146 8145 break; 8147 8146 8147 case 538: 8148 8149 /* Line 1806 of yacc.c */ 8150 #line 2064 "parser.yy" 8151 { 8152 typedefTable.addToEnclosingScope( TypedefTable::ID ); 8153 typedefTable.leaveScope(); 8154 (yyval.decl) = (yyvsp[(2) - (3)].decl)->addFunctionBody( (yyvsp[(3) - (3)].sn) )->addQualifiers( (yyvsp[(1) - (3)].decl) ); 8155 } 8156 break; 8157 8148 8158 case 539: 8149 8159 8150 8160 /* Line 1806 of yacc.c */ 8151 #line 20 64"parser.yy"8161 #line 2070 "parser.yy" 8152 8162 { 8153 8163 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8160 8170 8161 8171 /* Line 1806 of yacc.c */ 8162 #line 207 2"parser.yy"8172 #line 2078 "parser.yy" 8163 8173 { 8164 8174 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8171 8181 8172 8182 /* Line 1806 of yacc.c */ 8173 #line 20 78"parser.yy"8183 #line 2084 "parser.yy" 8174 8184 { 8175 8185 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8182 8192 8183 8193 /* Line 1806 of yacc.c */ 8184 #line 20 86"parser.yy"8194 #line 2092 "parser.yy" 8185 8195 { 8186 8196 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8193 8203 8194 8204 /* Line 1806 of yacc.c */ 8195 #line 209 2"parser.yy"8205 #line 2098 "parser.yy" 8196 8206 { 8197 8207 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 8204 8214 8205 8215 /* Line 1806 of yacc.c */ 8206 #line 21 07"parser.yy"8207 { (yyval.en) = new CompositeExprNode ( new OperatorNode( OperatorNode::Range ), (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ); }8216 #line 2113 "parser.yy" 8217 { (yyval.en) = new CompositeExprNode2( build_opr2( OperatorNode::Range, (yyvsp[(1) - (3)].en), (yyvsp[(3) - (3)].en) ) ); } 8208 8218 break; 8209 8219 … … 8211 8221 8212 8222 /* Line 1806 of yacc.c */ 8213 #line 21 17"parser.yy"8223 #line 2123 "parser.yy" 8214 8224 { (yyval.decl) = 0; } 8215 8225 break; … … 8218 8228 8219 8229 /* Line 1806 of yacc.c */ 8220 #line 21 24"parser.yy"8230 #line 2130 "parser.yy" 8221 8231 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 8222 8232 break; … … 8225 8235 8226 8236 /* Line 1806 of yacc.c */ 8227 #line 213 0"parser.yy"8237 #line 2136 "parser.yy" 8228 8238 { (yyval.decl) = 0; } 8229 8239 break; … … 8232 8242 8233 8243 /* Line 1806 of yacc.c */ 8234 #line 21 45"parser.yy"8244 #line 2151 "parser.yy" 8235 8245 {} 8236 8246 break; … … 8239 8249 8240 8250 /* Line 1806 of yacc.c */ 8241 #line 21 46"parser.yy"8251 #line 2152 "parser.yy" 8242 8252 {} 8243 8253 break; … … 8246 8256 8247 8257 /* Line 1806 of yacc.c */ 8248 #line 21 47"parser.yy"8258 #line 2153 "parser.yy" 8249 8259 {} 8250 8260 break; … … 8253 8263 8254 8264 /* Line 1806 of yacc.c */ 8255 #line 21 48"parser.yy"8265 #line 2154 "parser.yy" 8256 8266 {} 8257 8267 break; … … 8260 8270 8261 8271 /* Line 1806 of yacc.c */ 8262 #line 218 3"parser.yy"8272 #line 2189 "parser.yy" 8263 8273 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8264 8274 break; … … 8267 8277 8268 8278 /* Line 1806 of yacc.c */ 8269 #line 21 86"parser.yy"8279 #line 2192 "parser.yy" 8270 8280 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8271 8281 break; … … 8274 8284 8275 8285 /* Line 1806 of yacc.c */ 8276 #line 21 88"parser.yy"8286 #line 2194 "parser.yy" 8277 8287 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8278 8288 break; … … 8281 8291 8282 8292 /* Line 1806 of yacc.c */ 8283 #line 219 3"parser.yy"8293 #line 2199 "parser.yy" 8284 8294 { 8285 8295 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8291 8301 8292 8302 /* Line 1806 of yacc.c */ 8293 #line 2 198"parser.yy"8303 #line 2204 "parser.yy" 8294 8304 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8295 8305 break; … … 8298 8308 8299 8309 /* Line 1806 of yacc.c */ 8300 #line 220 3"parser.yy"8310 #line 2209 "parser.yy" 8301 8311 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8302 8312 break; … … 8305 8315 8306 8316 /* Line 1806 of yacc.c */ 8307 #line 22 05"parser.yy"8317 #line 2211 "parser.yy" 8308 8318 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8309 8319 break; … … 8312 8322 8313 8323 /* Line 1806 of yacc.c */ 8314 #line 22 07"parser.yy"8324 #line 2213 "parser.yy" 8315 8325 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8316 8326 break; … … 8319 8329 8320 8330 /* Line 1806 of yacc.c */ 8321 #line 221 2"parser.yy"8331 #line 2218 "parser.yy" 8322 8332 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8323 8333 break; … … 8326 8336 8327 8337 /* Line 1806 of yacc.c */ 8328 #line 22 14"parser.yy"8338 #line 2220 "parser.yy" 8329 8339 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8330 8340 break; … … 8333 8343 8334 8344 /* Line 1806 of yacc.c */ 8335 #line 22 16"parser.yy"8345 #line 2222 "parser.yy" 8336 8346 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8337 8347 break; … … 8340 8350 8341 8351 /* Line 1806 of yacc.c */ 8342 #line 22 18"parser.yy"8352 #line 2224 "parser.yy" 8343 8353 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8344 8354 break; … … 8347 8357 8348 8358 /* Line 1806 of yacc.c */ 8349 #line 222 3"parser.yy"8359 #line 2229 "parser.yy" 8350 8360 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8351 8361 break; … … 8354 8364 8355 8365 /* Line 1806 of yacc.c */ 8356 #line 22 25"parser.yy"8366 #line 2231 "parser.yy" 8357 8367 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8358 8368 break; … … 8361 8371 8362 8372 /* Line 1806 of yacc.c */ 8363 #line 22 34"parser.yy"8373 #line 2240 "parser.yy" 8364 8374 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8365 8375 break; … … 8368 8378 8369 8379 /* Line 1806 of yacc.c */ 8370 #line 22 37"parser.yy"8380 #line 2243 "parser.yy" 8371 8381 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8372 8382 break; … … 8375 8385 8376 8386 /* Line 1806 of yacc.c */ 8377 #line 224 2"parser.yy"8387 #line 2248 "parser.yy" 8378 8388 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8379 8389 break; … … 8382 8392 8383 8393 /* Line 1806 of yacc.c */ 8384 #line 22 44"parser.yy"8394 #line 2250 "parser.yy" 8385 8395 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8386 8396 break; … … 8389 8399 8390 8400 /* Line 1806 of yacc.c */ 8391 #line 22 46"parser.yy"8401 #line 2252 "parser.yy" 8392 8402 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8393 8403 break; … … 8396 8406 8397 8407 /* Line 1806 of yacc.c */ 8398 #line 225 1"parser.yy"8408 #line 2257 "parser.yy" 8399 8409 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8400 8410 break; … … 8403 8413 8404 8414 /* Line 1806 of yacc.c */ 8405 #line 225 3"parser.yy"8415 #line 2259 "parser.yy" 8406 8416 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8407 8417 break; … … 8410 8420 8411 8421 /* Line 1806 of yacc.c */ 8412 #line 22 55"parser.yy"8422 #line 2261 "parser.yy" 8413 8423 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8414 8424 break; … … 8417 8427 8418 8428 /* Line 1806 of yacc.c */ 8419 #line 226 0"parser.yy"8429 #line 2266 "parser.yy" 8420 8430 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8421 8431 break; … … 8424 8434 8425 8435 /* Line 1806 of yacc.c */ 8426 #line 226 2"parser.yy"8436 #line 2268 "parser.yy" 8427 8437 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8428 8438 break; … … 8431 8441 8432 8442 /* Line 1806 of yacc.c */ 8433 #line 22 64"parser.yy"8443 #line 2270 "parser.yy" 8434 8444 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8435 8445 break; … … 8438 8448 8439 8449 /* Line 1806 of yacc.c */ 8440 #line 22 79"parser.yy"8450 #line 2285 "parser.yy" 8441 8451 { (yyval.decl) = (yyvsp[(1) - (4)].decl)->addIdList( (yyvsp[(3) - (4)].decl) ); } 8442 8452 break; … … 8445 8455 8446 8456 /* Line 1806 of yacc.c */ 8447 #line 228 1"parser.yy"8457 #line 2287 "parser.yy" 8448 8458 { (yyval.decl) = (yyvsp[(2) - (6)].decl)->addIdList( (yyvsp[(5) - (6)].decl) ); } 8449 8459 break; … … 8452 8462 8453 8463 /* Line 1806 of yacc.c */ 8454 #line 228 3"parser.yy"8464 #line 2289 "parser.yy" 8455 8465 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8456 8466 break; … … 8459 8469 8460 8470 /* Line 1806 of yacc.c */ 8461 #line 22 88"parser.yy"8471 #line 2294 "parser.yy" 8462 8472 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8463 8473 break; … … 8466 8476 8467 8477 /* Line 1806 of yacc.c */ 8468 #line 229 0"parser.yy"8478 #line 2296 "parser.yy" 8469 8479 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8470 8480 break; … … 8473 8483 8474 8484 /* Line 1806 of yacc.c */ 8475 #line 229 2"parser.yy"8485 #line 2298 "parser.yy" 8476 8486 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8477 8487 break; … … 8480 8490 8481 8491 /* Line 1806 of yacc.c */ 8482 #line 2 297"parser.yy"8492 #line 2303 "parser.yy" 8483 8493 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8484 8494 break; … … 8487 8497 8488 8498 /* Line 1806 of yacc.c */ 8489 #line 2 299"parser.yy"8499 #line 2305 "parser.yy" 8490 8500 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8491 8501 break; … … 8494 8504 8495 8505 /* Line 1806 of yacc.c */ 8496 #line 230 1"parser.yy"8506 #line 2307 "parser.yy" 8497 8507 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8498 8508 break; … … 8501 8511 8502 8512 /* Line 1806 of yacc.c */ 8503 #line 23 16"parser.yy"8513 #line 2322 "parser.yy" 8504 8514 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8505 8515 break; … … 8508 8518 8509 8519 /* Line 1806 of yacc.c */ 8510 #line 23 19"parser.yy"8520 #line 2325 "parser.yy" 8511 8521 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8512 8522 break; … … 8515 8525 8516 8526 /* Line 1806 of yacc.c */ 8517 #line 232 1"parser.yy"8527 #line 2327 "parser.yy" 8518 8528 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8519 8529 break; … … 8522 8532 8523 8533 /* Line 1806 of yacc.c */ 8524 #line 23 27"parser.yy"8534 #line 2333 "parser.yy" 8525 8535 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8526 8536 break; … … 8529 8539 8530 8540 /* Line 1806 of yacc.c */ 8531 #line 233 2"parser.yy"8541 #line 2338 "parser.yy" 8532 8542 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8533 8543 break; … … 8536 8546 8537 8547 /* Line 1806 of yacc.c */ 8538 #line 23 34"parser.yy"8548 #line 2340 "parser.yy" 8539 8549 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8540 8550 break; … … 8543 8553 8544 8554 /* Line 1806 of yacc.c */ 8545 #line 23 36"parser.yy"8555 #line 2342 "parser.yy" 8546 8556 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8547 8557 break; … … 8550 8560 8551 8561 /* Line 1806 of yacc.c */ 8552 #line 234 1"parser.yy"8562 #line 2347 "parser.yy" 8553 8563 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8554 8564 break; … … 8557 8567 8558 8568 /* Line 1806 of yacc.c */ 8559 #line 234 3"parser.yy"8569 #line 2349 "parser.yy" 8560 8570 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8561 8571 break; … … 8564 8574 8565 8575 /* Line 1806 of yacc.c */ 8566 #line 23 45"parser.yy"8576 #line 2351 "parser.yy" 8567 8577 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8568 8578 break; … … 8571 8581 8572 8582 /* Line 1806 of yacc.c */ 8573 #line 23 47"parser.yy"8583 #line 2353 "parser.yy" 8574 8584 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8575 8585 break; … … 8578 8588 8579 8589 /* Line 1806 of yacc.c */ 8580 #line 235 2"parser.yy"8590 #line 2358 "parser.yy" 8581 8591 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8582 8592 break; … … 8585 8595 8586 8596 /* Line 1806 of yacc.c */ 8587 #line 23 54"parser.yy"8597 #line 2360 "parser.yy" 8588 8598 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8589 8599 break; … … 8592 8602 8593 8603 /* Line 1806 of yacc.c */ 8594 #line 23 56"parser.yy"8604 #line 2362 "parser.yy" 8595 8605 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8596 8606 break; … … 8599 8609 8600 8610 /* Line 1806 of yacc.c */ 8601 #line 23 66"parser.yy"8611 #line 2372 "parser.yy" 8602 8612 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8603 8613 break; … … 8606 8616 8607 8617 /* Line 1806 of yacc.c */ 8608 #line 23 69"parser.yy"8618 #line 2375 "parser.yy" 8609 8619 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8610 8620 break; … … 8613 8623 8614 8624 /* Line 1806 of yacc.c */ 8615 #line 237 1"parser.yy"8625 #line 2377 "parser.yy" 8616 8626 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8617 8627 break; … … 8620 8630 8621 8631 /* Line 1806 of yacc.c */ 8622 #line 23 76"parser.yy"8632 #line 2382 "parser.yy" 8623 8633 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8624 8634 break; … … 8627 8637 8628 8638 /* Line 1806 of yacc.c */ 8629 #line 23 78"parser.yy"8639 #line 2384 "parser.yy" 8630 8640 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8631 8641 break; … … 8634 8644 8635 8645 /* Line 1806 of yacc.c */ 8636 #line 238 0"parser.yy"8646 #line 2386 "parser.yy" 8637 8647 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8638 8648 break; … … 8641 8651 8642 8652 /* Line 1806 of yacc.c */ 8643 #line 23 85"parser.yy"8653 #line 2391 "parser.yy" 8644 8654 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8645 8655 break; … … 8648 8658 8649 8659 /* Line 1806 of yacc.c */ 8650 #line 23 87"parser.yy"8660 #line 2393 "parser.yy" 8651 8661 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8652 8662 break; … … 8655 8665 8656 8666 /* Line 1806 of yacc.c */ 8657 #line 23 89"parser.yy"8667 #line 2395 "parser.yy" 8658 8668 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8659 8669 break; … … 8662 8672 8663 8673 /* Line 1806 of yacc.c */ 8664 #line 239 1"parser.yy"8674 #line 2397 "parser.yy" 8665 8675 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8666 8676 break; … … 8669 8679 8670 8680 /* Line 1806 of yacc.c */ 8671 #line 2 396"parser.yy"8681 #line 2402 "parser.yy" 8672 8682 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8673 8683 break; … … 8676 8686 8677 8687 /* Line 1806 of yacc.c */ 8678 #line 2 398"parser.yy"8688 #line 2404 "parser.yy" 8679 8689 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8680 8690 break; … … 8683 8693 8684 8694 /* Line 1806 of yacc.c */ 8685 #line 240 0"parser.yy"8695 #line 2406 "parser.yy" 8686 8696 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8687 8697 break; … … 8690 8700 8691 8701 /* Line 1806 of yacc.c */ 8692 #line 243 1"parser.yy"8702 #line 2437 "parser.yy" 8693 8703 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8694 8704 break; … … 8697 8707 8698 8708 /* Line 1806 of yacc.c */ 8699 #line 24 34"parser.yy"8709 #line 2440 "parser.yy" 8700 8710 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8701 8711 break; … … 8704 8714 8705 8715 /* Line 1806 of yacc.c */ 8706 #line 24 36"parser.yy"8716 #line 2442 "parser.yy" 8707 8717 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8708 8718 break; … … 8711 8721 8712 8722 /* Line 1806 of yacc.c */ 8713 #line 244 1"parser.yy"8723 #line 2447 "parser.yy" 8714 8724 { 8715 8725 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8721 8731 8722 8732 /* Line 1806 of yacc.c */ 8723 #line 24 46"parser.yy"8733 #line 2452 "parser.yy" 8724 8734 { 8725 8735 typedefTable.setNextIdentifier( *(yyvsp[(1) - (1)].tok) ); … … 8731 8741 8732 8742 /* Line 1806 of yacc.c */ 8733 #line 24 54"parser.yy"8743 #line 2460 "parser.yy" 8734 8744 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8735 8745 break; … … 8738 8748 8739 8749 /* Line 1806 of yacc.c */ 8740 #line 24 56"parser.yy"8750 #line 2462 "parser.yy" 8741 8751 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8742 8752 break; … … 8745 8755 8746 8756 /* Line 1806 of yacc.c */ 8747 #line 24 58"parser.yy"8757 #line 2464 "parser.yy" 8748 8758 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8749 8759 break; … … 8752 8762 8753 8763 /* Line 1806 of yacc.c */ 8754 #line 246 3"parser.yy"8764 #line 2469 "parser.yy" 8755 8765 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 8756 8766 break; … … 8759 8769 8760 8770 /* Line 1806 of yacc.c */ 8761 #line 24 65"parser.yy"8771 #line 2471 "parser.yy" 8762 8772 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8763 8773 break; … … 8766 8776 8767 8777 /* Line 1806 of yacc.c */ 8768 #line 247 0"parser.yy"8778 #line 2476 "parser.yy" 8769 8779 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addParamList( (yyvsp[(4) - (6)].decl) ); } 8770 8780 break; … … 8773 8783 8774 8784 /* Line 1806 of yacc.c */ 8775 #line 247 2"parser.yy"8785 #line 2478 "parser.yy" 8776 8786 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8777 8787 break; … … 8780 8790 8781 8791 /* Line 1806 of yacc.c */ 8782 #line 24 87"parser.yy"8792 #line 2493 "parser.yy" 8783 8793 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8784 8794 break; … … 8787 8797 8788 8798 /* Line 1806 of yacc.c */ 8789 #line 24 89"parser.yy"8799 #line 2495 "parser.yy" 8790 8800 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8791 8801 break; … … 8794 8804 8795 8805 /* Line 1806 of yacc.c */ 8796 #line 2 494"parser.yy"8806 #line 2500 "parser.yy" 8797 8807 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8798 8808 break; … … 8801 8811 8802 8812 /* Line 1806 of yacc.c */ 8803 #line 2 496"parser.yy"8813 #line 2502 "parser.yy" 8804 8814 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8805 8815 break; … … 8808 8818 8809 8819 /* Line 1806 of yacc.c */ 8810 #line 2 498"parser.yy"8820 #line 2504 "parser.yy" 8811 8821 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8812 8822 break; … … 8815 8825 8816 8826 /* Line 1806 of yacc.c */ 8817 #line 250 0"parser.yy"8827 #line 2506 "parser.yy" 8818 8828 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8819 8829 break; … … 8822 8832 8823 8833 /* Line 1806 of yacc.c */ 8824 #line 250 2"parser.yy"8834 #line 2508 "parser.yy" 8825 8835 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8826 8836 break; … … 8829 8839 8830 8840 /* Line 1806 of yacc.c */ 8831 #line 25 08"parser.yy"8841 #line 2514 "parser.yy" 8832 8842 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8833 8843 break; … … 8836 8846 8837 8847 /* Line 1806 of yacc.c */ 8838 #line 251 0"parser.yy"8848 #line 2516 "parser.yy" 8839 8849 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8840 8850 break; … … 8843 8853 8844 8854 /* Line 1806 of yacc.c */ 8845 #line 251 2"parser.yy"8855 #line 2518 "parser.yy" 8846 8856 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8847 8857 break; … … 8850 8860 8851 8861 /* Line 1806 of yacc.c */ 8852 #line 25 17"parser.yy"8862 #line 2523 "parser.yy" 8853 8863 { (yyval.decl) = DeclarationNode::newFunction( 0, 0, (yyvsp[(3) - (5)].decl), 0 ); } 8854 8864 break; … … 8857 8867 8858 8868 /* Line 1806 of yacc.c */ 8859 #line 25 19"parser.yy"8869 #line 2525 "parser.yy" 8860 8870 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8861 8871 break; … … 8864 8874 8865 8875 /* Line 1806 of yacc.c */ 8866 #line 252 1"parser.yy"8876 #line 2527 "parser.yy" 8867 8877 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8868 8878 break; … … 8871 8881 8872 8882 /* Line 1806 of yacc.c */ 8873 #line 25 27"parser.yy"8883 #line 2533 "parser.yy" 8874 8884 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 8875 8885 break; … … 8878 8888 8879 8889 /* Line 1806 of yacc.c */ 8880 #line 25 29"parser.yy"8890 #line 2535 "parser.yy" 8881 8891 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false )->addArray( (yyvsp[(3) - (3)].decl) ); } 8882 8892 break; … … 8885 8895 8886 8896 /* Line 1806 of yacc.c */ 8887 #line 25 35"parser.yy"8897 #line 2541 "parser.yy" 8888 8898 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(3) - (5)].en), 0, false ); } 8889 8899 break; … … 8892 8902 8893 8903 /* Line 1806 of yacc.c */ 8894 #line 25 37"parser.yy"8904 #line 2543 "parser.yy" 8895 8905 { (yyval.decl) = DeclarationNode::newVarArray( 0 ); } 8896 8906 break; … … 8899 8909 8900 8910 /* Line 1806 of yacc.c */ 8901 #line 25 39"parser.yy"8911 #line 2545 "parser.yy" 8902 8912 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newArray( (yyvsp[(4) - (6)].en), 0, false ) ); } 8903 8913 break; … … 8906 8916 8907 8917 /* Line 1806 of yacc.c */ 8908 #line 254 1"parser.yy"8918 #line 2547 "parser.yy" 8909 8919 { (yyval.decl) = (yyvsp[(1) - (6)].decl)->addArray( DeclarationNode::newVarArray( 0 ) ); } 8910 8920 break; … … 8913 8923 8914 8924 /* Line 1806 of yacc.c */ 8915 #line 25 56"parser.yy"8925 #line 2562 "parser.yy" 8916 8926 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8917 8927 break; … … 8920 8930 8921 8931 /* Line 1806 of yacc.c */ 8922 #line 25 58"parser.yy"8932 #line 2564 "parser.yy" 8923 8933 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 8924 8934 break; … … 8927 8937 8928 8938 /* Line 1806 of yacc.c */ 8929 #line 256 3"parser.yy"8939 #line 2569 "parser.yy" 8930 8940 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 8931 8941 break; … … 8934 8944 8935 8945 /* Line 1806 of yacc.c */ 8936 #line 25 65"parser.yy"8946 #line 2571 "parser.yy" 8937 8947 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 8938 8948 break; … … 8941 8951 8942 8952 /* Line 1806 of yacc.c */ 8943 #line 25 67"parser.yy"8953 #line 2573 "parser.yy" 8944 8954 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 8945 8955 break; … … 8948 8958 8949 8959 /* Line 1806 of yacc.c */ 8950 #line 25 69"parser.yy"8960 #line 2575 "parser.yy" 8951 8961 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 8952 8962 break; … … 8955 8965 8956 8966 /* Line 1806 of yacc.c */ 8957 #line 257 1"parser.yy"8967 #line 2577 "parser.yy" 8958 8968 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8959 8969 break; … … 8962 8972 8963 8973 /* Line 1806 of yacc.c */ 8964 #line 25 77"parser.yy"8974 #line 2583 "parser.yy" 8965 8975 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8966 8976 break; … … 8969 8979 8970 8980 /* Line 1806 of yacc.c */ 8971 #line 25 79"parser.yy"8981 #line 2585 "parser.yy" 8972 8982 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 8973 8983 break; … … 8976 8986 8977 8987 /* Line 1806 of yacc.c */ 8978 #line 258 1"parser.yy"8988 #line 2587 "parser.yy" 8979 8989 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 8980 8990 break; … … 8983 8993 8984 8994 /* Line 1806 of yacc.c */ 8985 #line 25 86"parser.yy"8995 #line 2592 "parser.yy" 8986 8996 { (yyval.decl) = DeclarationNode::newFunction( 0, 0, (yyvsp[(3) - (5)].decl), 0 ); } 8987 8997 break; … … 8990 9000 8991 9001 /* Line 1806 of yacc.c */ 8992 #line 25 88"parser.yy"9002 #line 2594 "parser.yy" 8993 9003 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 8994 9004 break; … … 8997 9007 8998 9008 /* Line 1806 of yacc.c */ 8999 #line 259 0"parser.yy"9009 #line 2596 "parser.yy" 9000 9010 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 9001 9011 break; … … 9004 9014 9005 9015 /* Line 1806 of yacc.c */ 9006 #line 2 597"parser.yy"9016 #line 2603 "parser.yy" 9007 9017 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addArray( (yyvsp[(2) - (2)].decl) ); } 9008 9018 break; … … 9011 9021 9012 9022 /* Line 1806 of yacc.c */ 9013 #line 26 08"parser.yy"9023 #line 2614 "parser.yy" 9014 9024 { (yyval.decl) = DeclarationNode::newArray( 0, 0, false ); } 9015 9025 break; … … 9018 9028 9019 9029 /* Line 1806 of yacc.c */ 9020 #line 261 1"parser.yy"9030 #line 2617 "parser.yy" 9021 9031 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 9022 9032 break; … … 9025 9035 9026 9036 /* Line 1806 of yacc.c */ 9027 #line 261 3"parser.yy"9037 #line 2619 "parser.yy" 9028 9038 { (yyval.decl) = DeclarationNode::newArray( 0, (yyvsp[(3) - (5)].decl), false ); } 9029 9039 break; … … 9032 9042 9033 9043 /* Line 1806 of yacc.c */ 9034 #line 26 16"parser.yy"9044 #line 2622 "parser.yy" 9035 9045 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 9036 9046 break; … … 9039 9049 9040 9050 /* Line 1806 of yacc.c */ 9041 #line 26 18"parser.yy"9051 #line 2624 "parser.yy" 9042 9052 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl), true ); } 9043 9053 break; … … 9046 9056 9047 9057 /* Line 1806 of yacc.c */ 9048 #line 262 0"parser.yy"9058 #line 2626 "parser.yy" 9049 9059 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(3) - (7)].decl), true ); } 9050 9060 break; … … 9053 9063 9054 9064 /* Line 1806 of yacc.c */ 9055 #line 26 34"parser.yy"9065 #line 2640 "parser.yy" 9056 9066 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 9057 9067 break; … … 9060 9070 9061 9071 /* Line 1806 of yacc.c */ 9062 #line 26 36"parser.yy"9072 #line 2642 "parser.yy" 9063 9073 { (yyval.decl) = (yyvsp[(1) - (2)].decl)->addQualifiers( (yyvsp[(2) - (2)].decl) ); } 9064 9074 break; … … 9067 9077 9068 9078 /* Line 1806 of yacc.c */ 9069 #line 264 1"parser.yy"9079 #line 2647 "parser.yy" 9070 9080 { (yyval.decl) = DeclarationNode::newPointer( 0 ); } 9071 9081 break; … … 9074 9084 9075 9085 /* Line 1806 of yacc.c */ 9076 #line 264 3"parser.yy"9086 #line 2649 "parser.yy" 9077 9087 { (yyval.decl) = DeclarationNode::newPointer( (yyvsp[(2) - (2)].decl) ); } 9078 9088 break; … … 9081 9091 9082 9092 /* Line 1806 of yacc.c */ 9083 #line 26 45"parser.yy"9093 #line 2651 "parser.yy" 9084 9094 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addPointer( DeclarationNode::newPointer( 0 ) ); } 9085 9095 break; … … 9088 9098 9089 9099 /* Line 1806 of yacc.c */ 9090 #line 26 47"parser.yy"9100 #line 2653 "parser.yy" 9091 9101 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addPointer( DeclarationNode::newPointer( (yyvsp[(2) - (3)].decl) ) ); } 9092 9102 break; … … 9095 9105 9096 9106 /* Line 1806 of yacc.c */ 9097 #line 26 49"parser.yy"9107 #line 2655 "parser.yy" 9098 9108 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 9099 9109 break; … … 9102 9112 9103 9113 /* Line 1806 of yacc.c */ 9104 #line 26 55"parser.yy"9114 #line 2661 "parser.yy" 9105 9115 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 9106 9116 break; … … 9109 9119 9110 9120 /* Line 1806 of yacc.c */ 9111 #line 26 57"parser.yy"9121 #line 2663 "parser.yy" 9112 9122 { (yyval.decl) = (yyvsp[(2) - (4)].decl)->addArray( (yyvsp[(4) - (4)].decl) ); } 9113 9123 break; … … 9116 9126 9117 9127 /* Line 1806 of yacc.c */ 9118 #line 26 59"parser.yy"9128 #line 2665 "parser.yy" 9119 9129 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 9120 9130 break; … … 9123 9133 9124 9134 /* Line 1806 of yacc.c */ 9125 #line 26 64"parser.yy"9135 #line 2670 "parser.yy" 9126 9136 { (yyval.decl) = (yyvsp[(2) - (8)].decl)->addParamList( (yyvsp[(6) - (8)].decl) ); } 9127 9137 break; … … 9130 9140 9131 9141 /* Line 1806 of yacc.c */ 9132 #line 26 66"parser.yy"9142 #line 2672 "parser.yy" 9133 9143 { (yyval.decl) = (yyvsp[(2) - (3)].decl); } 9134 9144 break; … … 9137 9147 9138 9148 /* Line 1806 of yacc.c */ 9139 #line 26 76"parser.yy"9149 #line 2682 "parser.yy" 9140 9150 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 9141 9151 break; … … 9144 9154 9145 9155 /* Line 1806 of yacc.c */ 9146 #line 26 86"parser.yy"9156 #line 2692 "parser.yy" 9147 9157 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9148 9158 break; … … 9151 9161 9152 9162 /* Line 1806 of yacc.c */ 9153 #line 26 88"parser.yy"9163 #line 2694 "parser.yy" 9154 9164 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9155 9165 break; … … 9158 9168 9159 9169 /* Line 1806 of yacc.c */ 9160 #line 269 0"parser.yy"9170 #line 2696 "parser.yy" 9161 9171 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9162 9172 break; … … 9165 9175 9166 9176 /* Line 1806 of yacc.c */ 9167 #line 269 2"parser.yy"9177 #line 2698 "parser.yy" 9168 9178 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9169 9179 break; … … 9172 9182 9173 9183 /* Line 1806 of yacc.c */ 9174 #line 2 694"parser.yy"9184 #line 2700 "parser.yy" 9175 9185 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9176 9186 break; … … 9179 9189 9180 9190 /* Line 1806 of yacc.c */ 9181 #line 2 696"parser.yy"9191 #line 2702 "parser.yy" 9182 9192 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9183 9193 break; … … 9186 9196 9187 9197 /* Line 1806 of yacc.c */ 9188 #line 270 3"parser.yy"9198 #line 2709 "parser.yy" 9189 9199 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9190 9200 break; 9191 9201 9192 9202 case 718: 9193 9194 /* Line 1806 of yacc.c */9195 #line 2705 "parser.yy"9196 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }9197 break;9198 9199 case 719:9200 9201 /* Line 1806 of yacc.c */9202 #line 2707 "parser.yy"9203 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }9204 break;9205 9206 case 720:9207 9208 /* Line 1806 of yacc.c */9209 #line 2709 "parser.yy"9210 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }9211 break;9212 9213 case 721:9214 9203 9215 9204 /* Line 1806 of yacc.c */ … … 9218 9207 break; 9219 9208 9209 case 719: 9210 9211 /* Line 1806 of yacc.c */ 9212 #line 2713 "parser.yy" 9213 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9214 break; 9215 9216 case 720: 9217 9218 /* Line 1806 of yacc.c */ 9219 #line 2715 "parser.yy" 9220 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 9221 break; 9222 9223 case 721: 9224 9225 /* Line 1806 of yacc.c */ 9226 #line 2717 "parser.yy" 9227 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9228 break; 9229 9220 9230 case 722: 9221 9231 9222 9232 /* Line 1806 of yacc.c */ 9223 #line 271 3"parser.yy"9233 #line 2719 "parser.yy" 9224 9234 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9225 9235 break; 9226 9236 9227 9237 case 723: 9228 9229 /* Line 1806 of yacc.c */9230 #line 2715 "parser.yy"9231 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }9232 break;9233 9234 case 724:9235 9236 /* Line 1806 of yacc.c */9237 #line 2717 "parser.yy"9238 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }9239 break;9240 9241 case 725:9242 9243 /* Line 1806 of yacc.c */9244 #line 2719 "parser.yy"9245 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); }9246 break;9247 9248 case 726:9249 9238 9250 9239 /* Line 1806 of yacc.c */ … … 9253 9242 break; 9254 9243 9244 case 724: 9245 9246 /* Line 1806 of yacc.c */ 9247 #line 2723 "parser.yy" 9248 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9249 break; 9250 9251 case 725: 9252 9253 /* Line 1806 of yacc.c */ 9254 #line 2725 "parser.yy" 9255 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( (yyvsp[(2) - (3)].decl) )->addNewArray( (yyvsp[(1) - (3)].decl) ); } 9256 break; 9257 9258 case 726: 9259 9260 /* Line 1806 of yacc.c */ 9261 #line 2727 "parser.yy" 9262 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9263 break; 9264 9255 9265 case 727: 9256 9266 9257 9267 /* Line 1806 of yacc.c */ 9258 #line 27 26"parser.yy"9268 #line 2732 "parser.yy" 9259 9269 { (yyval.decl) = DeclarationNode::newVarArray( (yyvsp[(3) - (6)].decl) ); } 9260 9270 break; … … 9263 9273 9264 9274 /* Line 1806 of yacc.c */ 9265 #line 27 28"parser.yy"9275 #line 2734 "parser.yy" 9266 9276 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), false ); } 9267 9277 break; … … 9270 9280 9271 9281 /* Line 1806 of yacc.c */ 9272 #line 273 3"parser.yy"9282 #line 2739 "parser.yy" 9273 9283 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(4) - (6)].en), (yyvsp[(3) - (6)].decl), true ); } 9274 9284 break; … … 9277 9287 9278 9288 /* Line 1806 of yacc.c */ 9279 #line 27 35"parser.yy"9289 #line 2741 "parser.yy" 9280 9290 { (yyval.decl) = DeclarationNode::newArray( (yyvsp[(5) - (7)].en), (yyvsp[(4) - (7)].decl)->addQualifiers( (yyvsp[(3) - (7)].decl) ), true ); } 9281 9291 break; … … 9284 9294 9285 9295 /* Line 1806 of yacc.c */ 9286 #line 276 2"parser.yy"9296 #line 2768 "parser.yy" 9287 9297 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addQualifiers( (yyvsp[(1) - (2)].decl) ); } 9288 9298 break; … … 9291 9301 9292 9302 /* Line 1806 of yacc.c */ 9293 #line 277 3"parser.yy"9303 #line 2779 "parser.yy" 9294 9304 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9295 9305 break; … … 9298 9308 9299 9309 /* Line 1806 of yacc.c */ 9300 #line 27 75"parser.yy"9310 #line 2781 "parser.yy" 9301 9311 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9302 9312 break; … … 9305 9315 9306 9316 /* Line 1806 of yacc.c */ 9307 #line 27 77"parser.yy"9317 #line 2783 "parser.yy" 9308 9318 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9309 9319 break; … … 9312 9322 9313 9323 /* Line 1806 of yacc.c */ 9314 #line 27 79"parser.yy"9324 #line 2785 "parser.yy" 9315 9325 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9316 9326 break; … … 9319 9329 9320 9330 /* Line 1806 of yacc.c */ 9321 #line 278 1"parser.yy"9331 #line 2787 "parser.yy" 9322 9332 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewPointer( DeclarationNode::newPointer( 0 ) ); } 9323 9333 break; … … 9326 9336 9327 9337 /* Line 1806 of yacc.c */ 9328 #line 278 3"parser.yy"9338 #line 2789 "parser.yy" 9329 9339 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewPointer( DeclarationNode::newPointer( (yyvsp[(1) - (3)].decl) ) ); } 9330 9340 break; 9331 9341 9332 9342 case 742: 9333 9334 /* Line 1806 of yacc.c */9335 #line 2790 "parser.yy"9336 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }9337 break;9338 9339 case 743:9340 9341 /* Line 1806 of yacc.c */9342 #line 2792 "parser.yy"9343 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }9344 break;9345 9346 case 744:9347 9348 /* Line 1806 of yacc.c */9349 #line 2794 "parser.yy"9350 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); }9351 break;9352 9353 case 745:9354 9343 9355 9344 /* Line 1806 of yacc.c */ … … 9358 9347 break; 9359 9348 9360 case 74 6:9349 case 743: 9361 9350 9362 9351 /* Line 1806 of yacc.c */ … … 9365 9354 break; 9366 9355 9367 case 74 7:9356 case 744: 9368 9357 9369 9358 /* Line 1806 of yacc.c */ … … 9372 9361 break; 9373 9362 9363 case 745: 9364 9365 /* Line 1806 of yacc.c */ 9366 #line 2802 "parser.yy" 9367 { (yyval.decl) = (yyvsp[(3) - (3)].decl)->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9368 break; 9369 9370 case 746: 9371 9372 /* Line 1806 of yacc.c */ 9373 #line 2804 "parser.yy" 9374 { (yyval.decl) = (yyvsp[(4) - (4)].decl)->addNewArray( (yyvsp[(3) - (4)].decl) )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 9375 break; 9376 9377 case 747: 9378 9379 /* Line 1806 of yacc.c */ 9380 #line 2806 "parser.yy" 9381 { (yyval.decl) = (yyvsp[(2) - (2)].decl)->addNewArray( (yyvsp[(1) - (2)].decl) ); } 9382 break; 9383 9374 9384 case 748: 9375 9385 9376 9386 /* Line 1806 of yacc.c */ 9377 #line 28 05"parser.yy"9387 #line 2811 "parser.yy" 9378 9388 { (yyval.decl) = DeclarationNode::newTuple( (yyvsp[(3) - (5)].decl) ); } 9379 9389 break; … … 9382 9392 9383 9393 /* Line 1806 of yacc.c */ 9384 #line 281 0"parser.yy"9394 #line 2816 "parser.yy" 9385 9395 { (yyval.decl) = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), (yyvsp[(4) - (5)].decl), 0 ); } 9386 9396 break; … … 9389 9399 9390 9400 /* Line 1806 of yacc.c */ 9391 #line 281 2"parser.yy"9401 #line 2818 "parser.yy" 9392 9402 { (yyval.decl) = DeclarationNode::newFunction( 0, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), 0 ); } 9393 9403 break; … … 9396 9406 9397 9407 /* Line 1806 of yacc.c */ 9398 #line 28 14"parser.yy"9408 #line 2820 "parser.yy" 9399 9409 { (yyval.decl) = DeclarationNode::newFunction( 0, (yyvsp[(1) - (6)].decl), (yyvsp[(4) - (6)].decl), 0 ); } 9400 9410 break; … … 9403 9413 9404 9414 /* Line 1806 of yacc.c */ 9405 #line 28 38"parser.yy"9415 #line 2844 "parser.yy" 9406 9416 { (yyval.en) = 0; } 9407 9417 break; … … 9410 9420 9411 9421 /* Line 1806 of yacc.c */ 9412 #line 284 0"parser.yy"9422 #line 2846 "parser.yy" 9413 9423 { (yyval.en) = (yyvsp[(2) - (2)].en); } 9414 9424 break; … … 9417 9427 9418 9428 /* Line 1806 of yacc.c */ 9419 #line 94 20 "Parser/parser.cc"9429 #line 9430 "Parser/parser.cc" 9420 9430 default: break; 9421 9431 } … … 9648 9658 9649 9659 /* Line 2067 of yacc.c */ 9650 #line 284 3"parser.yy"9660 #line 2849 "parser.yy" 9651 9661 9652 9662 // ----end of grammar---- -
src/Parser/parser.h
r5070fe4 rc331406 274 274 LabelNode *label; 275 275 InitializerNode *in; 276 OperatorNode::Type op; 276 277 bool flag; 277 278 … … 279 280 280 281 /* Line 2068 of yacc.c */ 281 #line 28 2"Parser/parser.h"282 #line 283 "Parser/parser.h" 282 283 } YYSTYPE; 283 284 # define YYSTYPE_IS_TRIVIAL 1 -
src/Parser/parser.yy
r5070fe4 rc331406 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 23 17:01:30201613 // Update Count : 1 66812 // Last Modified On : Fri Aug 5 08:15:57 2016 13 // Update Count : 1721 14 14 // 15 15 … … 119 119 LabelNode *label; 120 120 InitializerNode *in; 121 OperatorNode::Type op; 121 122 bool flag; 122 123 } … … 129 130 %type<constant> constant 130 131 %type<en> tuple tuple_expression_list 131 %type<en> ptrref_operator unary_operator assignment_operator 132 %type<op> ptrref_operator 133 %type<en> unary_operator assignment_operator 132 134 %type<en> primary_expression postfix_expression unary_expression 133 135 %type<en> cast_expression multiplicative_expression additive_expression shift_expression … … 150 152 %type<sn> block_item_list block_item 151 153 %type<sn> case_clause 152 %type<en> case_value case_value_list153 %type<sn> case_ label case_label_list154 %type<en> case_value 155 %type<sn> case_value_list case_label case_label_list 154 156 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 155 157 %type<pn> handler_list handler_clause finally_clause … … 354 356 // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is 355 357 // equivalent to the old x[i,j]. 356 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Index ), $1, $4); }358 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Index, $1, $4 ) ); } 357 359 | postfix_expression '(' argument_expression_list ')' 358 360 { $$ = new CompositeExprNode( $1, $3 ); } … … 360 362 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1; 361 363 | postfix_expression '.' no_attr_identifier 362 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::FieldSel ), $1, new VarRefNode( $3 )); }364 { $$ = new CompositeExprNode2( build_fieldSel( $1, new VarRefNode( $3 ) ) ); } 363 365 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 364 366 | postfix_expression ARROW no_attr_identifier 365 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::PFieldSel ), $1, new VarRefNode( $3 )); }367 { $$ = new CompositeExprNode2( build_pfieldSel( $1, new VarRefNode( $3 ) ) ); } 366 368 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector 367 369 | postfix_expression ICR 368 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::IncrPost ), $1); }370 { $$ = new CompositeExprNode2( build_opr1( OperatorNode::IncrPost, $1 ) ); } 369 371 | postfix_expression DECR 370 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1); }372 { $$ = new CompositeExprNode2( build_opr1( OperatorNode::DecrPost, $1 ) ); } 371 373 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99 372 374 { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); } … … 410 412 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1; 411 413 | no_attr_identifier '.' field 412 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $3); }414 { $$ = new CompositeExprNode2( build_fieldSel( $3, new VarRefNode( $1 ) ) ); } 413 415 | no_attr_identifier '.' '[' push field_list pop ']' 414 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::FieldSel ), new VarRefNode( $1 ), $5); }416 { $$ = new CompositeExprNode2( build_fieldSel( $5, new VarRefNode( $1 ) ) ); } 415 417 | no_attr_identifier ARROW field 416 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $3); }418 { $$ = new CompositeExprNode2( build_pfieldSel( $3, new VarRefNode( $1 ) ) ); } 417 419 | no_attr_identifier ARROW '[' push field_list pop ']' 418 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::PFieldSel ), new VarRefNode( $1 ), $5); }420 { $$ = new CompositeExprNode2( build_pfieldSel( $5, new VarRefNode( $1 ) ) ); } 419 421 ; 420 422 … … 429 431 | EXTENSION cast_expression // GCC 430 432 { $$ = $2->set_extension( true ); } 431 | ptrref_operator cast_expression // CFA432 { $$ = new CompositeExprNode( $1, $2 ); }433 433 // '*' ('&') is separated from unary_operator because of shift/reduce conflict in: 434 434 // { * X; } // dereference X 435 435 // { * int X; } // CFA declaration of pointer to int 436 | ptrref_operator cast_expression // CFA 437 { $$ = $1 == OperatorNode::AddressOf ? (ExpressionNode*) new CompositeExprNode2( build_addressOf( $2 ) ) 438 : (ExpressionNode*)new CompositeExprNode( new OperatorNode ( $1 ), $2 ); } 436 439 | unary_operator cast_expression 437 440 { $$ = new CompositeExprNode( $1, $2 ); } 438 441 | ICR unary_expression 439 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2); }442 { $$ = new CompositeExprNode2( build_opr1( OperatorNode::Incr, $2 ) ); } 440 443 | DECR unary_expression 441 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Decr ), $2); }444 { $$ = new CompositeExprNode2( build_opr1( OperatorNode::Decr, $2 ) ); } 442 445 | SIZEOF unary_expression 443 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::SizeOf ), $2); }446 { $$ = new CompositeExprNode2( build_sizeOf( $2 ) ); } 444 447 | SIZEOF '(' type_name_no_function ')' 445 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); }448 { $$ = new CompositeExprNode2( build_sizeOf( new TypeValueNode( $3 ) ) ); } 446 449 | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')' 447 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }450 { $$ = new CompositeExprNode2( build_offsetOf( new TypeValueNode( $3 ), new VarRefNode( $5 ) ) ); } 448 451 | ATTR_IDENTIFIER 449 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ) ); }452 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ) ); } 450 453 | ATTR_IDENTIFIER '(' type_name ')' 451 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), new TypeValueNode( $3 ) ); }454 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), new TypeValueNode( $3 ) ); } 452 455 | ATTR_IDENTIFIER '(' argument_expression ')' 453 456 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 ), $3 ); } 454 457 | ALIGNOF unary_expression // GCC, variable alignment 455 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::AlignOf ), $2); }458 { $$ = new CompositeExprNode2( build_alignOf( $2 ) ); } 456 459 | ALIGNOF '(' type_name_no_function ')' // GCC, type alignment 457 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( $3) ); }460 { $$ = new CompositeExprNode2( build_alignOf( new TypeValueNode( $3 ) ) ); } 458 461 // | ANDAND IDENTIFIER // GCC, address of label 459 462 // { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LabelAddress ), new VarRefNode( $2, true ) ); } … … 461 464 462 465 ptrref_operator: 463 '*' { $$ = new OperatorNode( OperatorNode::PointTo ); }464 | '&' { $$ = new OperatorNode( OperatorNode::AddressOf ); }466 '*' { $$ = OperatorNode::PointTo; } 467 | '&' { $$ = OperatorNode::AddressOf; } 465 468 // GCC, address of label must be handled by semantic check for ref,ref,label 466 | ANDAND { $$ = new OperatorNode( OperatorNode::And ); }469 | ANDAND { $$ = OperatorNode::And; } 467 470 ; 468 471 … … 477 480 unary_expression 478 481 | '(' type_name_no_function ')' cast_expression 479 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4); }482 { $$ = new CompositeExprNode2( build_cast( new TypeValueNode( $2 ), $4 ) ); } 480 483 | '(' type_name_no_function ')' tuple 481 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Cast ), new TypeValueNode( $2 ), $4); }484 { $$ = new CompositeExprNode2( build_cast( new TypeValueNode( $2 ), $4 ) ); } 482 485 ; 483 486 … … 485 488 cast_expression 486 489 | multiplicative_expression '*' cast_expression 487 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Mul ), $1, $3); }490 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Mul, $1, $3 ) ); } 488 491 | multiplicative_expression '/' cast_expression 489 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Div ), $1, $3); }492 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Div, $1, $3 ) ); } 490 493 | multiplicative_expression '%' cast_expression 491 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Mod ), $1, $3); }494 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Mod, $1, $3 ) ); } 492 495 ; 493 496 … … 495 498 multiplicative_expression 496 499 | additive_expression '+' multiplicative_expression 497 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Plus ), $1, $3); }500 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Plus, $1, $3 ) ); } 498 501 | additive_expression '-' multiplicative_expression 499 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Minus ), $1, $3); }502 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Minus, $1, $3 ) ); } 500 503 ; 501 504 … … 503 506 additive_expression 504 507 | shift_expression LS additive_expression 505 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::LShift ), $1, $3); }508 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::LShift, $1, $3 ) ); } 506 509 | shift_expression RS additive_expression 507 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::RShift ), $1, $3); }510 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::RShift, $1, $3 ) ); } 508 511 ; 509 512 … … 511 514 shift_expression 512 515 | relational_expression '<' shift_expression 513 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::LThan ), $1, $3); }516 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::LThan, $1, $3 ) ); } 514 517 | relational_expression '>' shift_expression 515 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::GThan ), $1, $3); }518 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::GThan, $1, $3 ) ); } 516 519 | relational_expression LE shift_expression 517 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::LEThan ), $1, $3); }520 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::LEThan, $1, $3 ) ); } 518 521 | relational_expression GE shift_expression 519 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::GEThan ), $1, $3); }522 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::GEThan, $1, $3 ) ); } 520 523 ; 521 524 … … 523 526 relational_expression 524 527 | equality_expression EQ relational_expression 525 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Eq ), $1, $3); }528 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Eq, $1, $3 ) ); } 526 529 | equality_expression NE relational_expression 527 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Neq ), $1, $3); }530 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Neq, $1, $3 ) ); } 528 531 ; 529 532 … … 531 534 equality_expression 532 535 | AND_expression '&' equality_expression 533 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::BitAnd ), $1, $3); }536 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::BitAnd, $1, $3 ) ); } 534 537 ; 535 538 … … 537 540 AND_expression 538 541 | exclusive_OR_expression '^' AND_expression 539 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Xor ), $1, $3); }542 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Xor, $1, $3 ) ); } 540 543 ; 541 544 … … 543 546 exclusive_OR_expression 544 547 | inclusive_OR_expression '|' exclusive_OR_expression 545 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::BitOr ), $1, $3); }548 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::BitOr, $1, $3 ) ); } 546 549 ; 547 550 … … 549 552 inclusive_OR_expression 550 553 | logical_AND_expression ANDAND inclusive_OR_expression 551 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::And ), $1, $3); }554 { $$ = new CompositeExprNode2( build_and_or( $1, $3, true ) ); } 552 555 ; 553 556 … … 555 558 logical_AND_expression 556 559 | logical_OR_expression OROR logical_AND_expression 557 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Or ), $1, $3); }560 { $$ = new CompositeExprNode2( build_and_or( $1, $3, false ) ); } 558 561 ; 559 562 … … 561 564 logical_OR_expression 562 565 | logical_OR_expression '?' comma_expression ':' conditional_expression 563 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 )) ); }566 { $$ = new CompositeExprNode2( build_cond( $1, $3, $5 ) ); } 564 567 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 565 { $$ =new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), $1, $4 ); }568 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::NCond ), $1, $4 ); } 566 569 | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression 567 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Cond ), (ExpressionNode *)mkList( (*$1, *$3, *$5 )) ); }570 { $$ = new CompositeExprNode2( build_cond( $1, $3, $5 ) ); } 568 571 ; 569 572 … … 576 579 conditional_expression 577 580 | unary_expression '=' assignment_expression 578 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $3 ); }581 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $3 ); } 579 582 | unary_expression assignment_operator assignment_expression 580 { $$ = new CompositeExprNode( $2, $1, $3 ); }583 { $$ = new CompositeExprNode( $2, $1, $3 ); } 581 584 | tuple assignment_opt // CFA, tuple expression 582 585 { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( new OperatorNode( OperatorNode::Assign ), $1, $2 ); } … … 624 627 assignment_expression 625 628 | comma_expression ',' assignment_expression // { $$ = (ExpressionNode *)$1->add_to_list( $3 ); } 626 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Comma ), $1, $3 ); } 629 //{ $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Comma ), $1, $3 ); } 630 { $$ = new CompositeExprNode2( build_comma( $1, $3 ) ); } 627 631 ; 628 632 … … 717 721 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 718 722 // statement around the switch. Statements after the initial declaration list can never be executed, and 719 // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement. 723 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 724 // statement. 720 725 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 721 726 } … … 735 740 constant_expression { $$ = $1; } 736 741 | constant_expression ELLIPSIS constant_expression // GCC, subrange 737 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Range ), $1, $3); }742 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Range, $1, $3 ) ); } 738 743 | subrange // CFA, subrange 739 744 ; 740 745 741 746 case_value_list: // CFA 742 case_value 743 | case_value_list ',' case_value744 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)(tupleContents( $1 ))->set_link( $3) ); }747 case_value { $$ = new StatementNode( StatementNode::Case, $1, 0 ); } 748 // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5" 749 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_link( new StatementNode( StatementNode::Case, $3, 0 ) ) ); } 745 750 ; 746 751 747 752 case_label: // CFA 748 CASE case_value_list ':' { $$ = new StatementNode( StatementNode::Case, $2, 0 ); }753 CASE case_value_list ':' { $$ = $2; } 749 754 | DEFAULT ':' { $$ = new StatementNode( StatementNode::Default ); } 750 755 // A semantic check is required to ensure only one default clause per switch/choose statement. … … 1776 1781 { $$ = new DesignatorNode( $3, true ); } 1777 1782 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 1778 { $$ = new DesignatorNode( new CompositeExprNode ( new OperatorNode( OperatorNode::Range ), $3, $5), true ); }1783 { $$ = new DesignatorNode( new CompositeExprNode2( build_opr2( OperatorNode::Range, $3, $5 ) ), true ); } 1779 1784 | '.' '[' push field_list pop ']' // CFA, tuple field selector 1780 1785 { $$ = new DesignatorNode( $4 ); } … … 2105 2110 subrange: 2106 2111 constant_expression '~' constant_expression // CFA, integer subrange 2107 { $$ = new CompositeExprNode ( new OperatorNode( OperatorNode::Range ), $1, $3); }2112 { $$ = new CompositeExprNode2( build_opr2( OperatorNode::Range, $1, $3 ) ); } 2108 2113 ; 2109 2114 -
src/ResolvExpr/Resolver.cc
r5070fe4 rc331406 24 24 #include "SynTree/Initializer.h" 25 25 #include "SymTab/Indexer.h" 26 #include "SymTab/Autogen.h" 26 27 #include "Common/utility.h" 27 28 #include "InitTweak/InitTweak.h" … … 41 42 42 43 virtual void visit( ArrayType * at ); 44 virtual void visit( PointerType * at ); 43 45 44 46 virtual void visit( ExprStmt *exprStmt ); … … 52 54 virtual void visit( BranchStmt *branchStmt ); 53 55 virtual void visit( ReturnStmt *returnStmt ); 54 virtual void visit( ImplicitCtorDtorStmt * impCtorDtorStmt );55 56 56 57 virtual void visit( SingleInit *singleInit ); … … 59 60 private: 60 61 typedef std::list< Initializer * >::iterator InitIterator; 62 63 template< typename PtrType > 64 void handlePtrType( PtrType * type ); 61 65 62 66 void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & ); … … 192 196 } 193 197 198 template< typename PtrType > 199 void Resolver::handlePtrType( PtrType * type ) { 200 if ( type->get_dimension() ) { 201 CastExpr *castExpr = new CastExpr( type->get_dimension(), SymTab::SizeType->clone() ); 202 Expression *newExpr = findSingleExpression( castExpr, *this ); 203 delete type->get_dimension(); 204 type->set_dimension( newExpr ); 205 } 206 } 207 194 208 void Resolver::visit( ArrayType * at ) { 195 if ( at->get_dimension() ) { 196 BasicType arrayLenType = BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 197 CastExpr *castExpr = new CastExpr( at->get_dimension(), arrayLenType.clone() ); 198 Expression *newExpr = findSingleExpression( castExpr, *this ); 199 delete at->get_dimension(); 200 at->set_dimension( newExpr ); 201 } 209 handlePtrType( at ); 202 210 Visitor::visit( at ); 211 } 212 213 void Resolver::visit( PointerType * pt ) { 214 handlePtrType( pt ); 215 Visitor::visit( pt ); 203 216 } 204 217 … … 422 435 423 436 void Resolver::visit( ListInit * listInit ) { 424 InitIterator iter = listInit->begin _initializers();425 InitIterator end = listInit->end _initializers();437 InitIterator iter = listInit->begin(); 438 InitIterator end = listInit->end(); 426 439 427 440 if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) { … … 521 534 // implicitly generated, there's no way for it to have side effects, so get rid of it 522 535 // to clean up generated code. 523 if ( InitTweak::isIn strinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) {536 if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) { 524 537 delete ctorInit->get_ctor(); 525 538 ctorInit->set_ctor( NULL ); 526 539 } 527 if ( InitTweak::isInstrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) { 540 541 // xxx - todo 542 // if ( InitTweak::isIntrinsicCallStmt( ctorInit->get_ctor() ) ) { 543 // // can reduce the constructor down to a SingleInit using the 544 // // second argument from the ctor call 545 // } 546 547 if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->get_dtor() ) ) { 528 548 delete ctorInit->get_dtor(); 529 549 ctorInit->set_dtor( NULL ); 530 550 } 531 }532 533 void Resolver::visit( ImplicitCtorDtorStmt * impCtorDtorStmt ) {534 // before resolving ctor/dtor, need to remove type qualifiers from the first argument (the object being constructed).535 // Do this through a cast expression to greatly simplify the code.536 Expression * callExpr = InitTweak::getCtorDtorCall( impCtorDtorStmt );537 assert( callExpr );538 Expression *& constructee = InitTweak::getCallArg( callExpr, 0 );539 Type * type = 0;540 541 // need to find the type of the first argument, which is unfortunately not uniform since array construction542 // includes an untyped '+' expression.543 if ( UntypedExpr * plusExpr = dynamic_cast< UntypedExpr * >( constructee ) ) {544 // constructee is <array>+<index>545 // get Variable <array>, then get the base type of the VariableExpr - this is the type that needs to be fixed546 Expression * arr = InitTweak::getCallArg( plusExpr, 0 );547 assert( dynamic_cast< VariableExpr * >( arr ) || dynamic_cast< MemberExpr *>( arr ) );548 assert( arr && arr->get_results().size() == 1 );549 type = arr->get_results().front()->clone();550 } else {551 // otherwise, constructing a plain object, which means the object's address is being taken.552 // Need to get the type of the VariableExpr object, because the AddressExpr is rebuilt and uses the553 // type of the VariableExpr to do so.554 assert( constructee->get_results().size() == 1 );555 AddressExpr * addrExpr = dynamic_cast< AddressExpr * > ( constructee );556 assert( addrExpr && addrExpr->get_results().size() == 1 );557 type = addrExpr->get_results().front()->clone();558 }559 // cast to T* with qualifiers removed.560 // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument561 // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever562 // remove lvalue as a qualifier, this can change to563 // type->get_qualifiers() = Type::Qualifiers();564 Type * base = InitTweak::getPointerBase( type );565 assert( base );566 base->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true);567 // if pointer has lvalue qualifier, cast won't appear in output568 type->set_isLvalue( false );569 constructee = new CastExpr( constructee, type );570 571 // finally, resolve the ctor/dtor572 impCtorDtorStmt->get_callStmt()->accept( *this );573 551 } 574 552 } // namespace ResolvExpr -
src/SymTab/AddVisit.h
r5070fe4 rc331406 10 10 // Created On : Sun May 17 16:14:32 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:46:33201613 // Update Count : 612 // Last Modified On : Thu Aug 4 11:22:01 2016 13 // Update Count : 9 14 14 // 15 15 … … 33 33 template< typename Visitor > 34 34 inline void addVisit(SwitchStmt *switchStmt, Visitor &visitor) { 35 addVisitStatementList( switchStmt->get_ branches(), visitor );35 addVisitStatementList( switchStmt->get_statements(), visitor ); 36 36 maybeAccept( switchStmt->get_condition(), visitor ); 37 37 } -
src/SymTab/Autogen.cc
r5070fe4 rc331406 26 26 27 27 namespace SymTab { 28 Type * SizeType = 0; 29 28 30 class AutogenerateRoutines : public Visitor { 29 31 public: … … 59 61 bool isUnnamedBitfield( ObjectDecl * obj ) { 60 62 return obj != NULL && obj->get_name() == "" && obj->get_bitfieldWidth() != NULL; 61 }62 63 template< typename OutputIterator >64 void makeScalarFunction( Expression *src, ObjectDecl *dstParam, DeclarationWithType *member, std::string fname, OutputIterator out ) {65 ObjectDecl *obj = dynamic_cast<ObjectDecl *>( member );66 // unnamed bit fields are not copied as they cannot be accessed67 if ( isUnnamedBitfield( obj ) ) return;68 69 // want to be able to generate assignment, ctor, and dtor generically,70 // so fname is either ?=?, ?{}, or ^?{}71 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );72 73 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );74 derefExpr->get_args().push_back( new VariableExpr( dstParam ) );75 76 // do something special for unnamed members77 Expression *dstselect = new AddressExpr( new MemberExpr( member, derefExpr ) );78 fExpr->get_args().push_back( dstselect );79 80 if ( src ) {81 fExpr->get_args().push_back( src );82 }83 84 Statement * callStmt = new ExprStmt( noLabels, fExpr );85 if ( (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) ) ) {86 // implicitly generated ctor/dtor calls should be wrapped87 // so that later passes are aware they were generated.88 // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield,89 // because this causes the address to be taken at codegen, which is illegal in C.90 callStmt = new ImplicitCtorDtorStmt( callStmt );91 }92 *out++ = callStmt;93 63 } 94 64 … … 219 189 } 220 190 191 InitTweak::InitExpander srcParam( src ); 192 221 193 // assign to destination (and return value if generic) 222 if ( ArrayType *array = dynamic_cast< ArrayType * >( field->get_type() ) ) { 223 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 224 derefExpr->get_args().push_back( new VariableExpr( dstParam ) ); 225 Expression *dstselect = new MemberExpr( field, derefExpr ); 226 227 makeArrayFunction( src, dstselect, array, func->get_name(), back_inserter( func->get_statements()->get_kids() ), forward ); 228 if ( isDynamicLayout && returnVal ) { 229 UntypedExpr *derefRet = new UntypedExpr( new NameExpr( "*?" ) ); 230 derefRet->get_args().push_back( new VariableExpr( returnVal ) ); 231 Expression *retselect = new MemberExpr( field, derefRet ); 232 233 makeArrayFunction( src, retselect, array, func->get_name(), back_inserter( func->get_statements()->get_kids() ), forward ); 234 } 235 } else { 236 makeScalarFunction( src, dstParam, field, func->get_name(), back_inserter( func->get_statements()->get_kids() ) ); 237 if ( isDynamicLayout && returnVal ) makeScalarFunction( src, returnVal, field, func->get_name(), back_inserter( func->get_statements()->get_kids() ) ); 194 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 195 derefExpr->get_args().push_back( new VariableExpr( dstParam ) ); 196 Expression *dstselect = new MemberExpr( field, derefExpr ); 197 genImplicitCall( srcParam, dstselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward ); 198 199 if ( isDynamicLayout && returnVal ) { 200 UntypedExpr *derefRet = new UntypedExpr( new NameExpr( "*?" ) ); 201 derefRet->get_args().push_back( new VariableExpr( returnVal ) ); 202 Expression *retselect = new MemberExpr( field, derefRet ); 203 genImplicitCall( srcParam, retselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward ); 238 204 } // if 239 205 } -
src/SymTab/Autogen.h
r5070fe4 rc331406 22 22 #include "SynTree/Declaration.h" 23 23 #include "SynTree/Initializer.h" 24 #include "InitTweak/InitTweak.h" 24 25 25 26 namespace SymTab { 26 27 27 /// Generates assignment operators, constructors, and destructor for aggregate types as required 28 void autogenerateRoutines( std::list< Declaration * > &translationUnit ); 28 29 29 // originally makeArrayAssignment - changed to Function because it is now used for ctors and dtors as well 30 // admittedly not a great name change. This used to live in Validate.cc, but has been moved so it can be reused elsewhere 30 /// returns true if obj's name is the empty string and it has a bitfield width 31 bool isUnnamedBitfield( ObjectDecl * obj ); 31 32 32 /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments. 33 /// If forward is true, loop goes from 0 to N-1, else N-1 to 0 34 template< typename OutputIterator > 35 void makeArrayFunction( Expression *srcParam, Expression *dstParam, ArrayType *array, std::string fname, OutputIterator out, bool forward = true ) { 36 static UniqueName indexName( "_index" ); 33 /// size_t type - set when size_t typedef is seen. Useful in a few places, 34 /// such as in determining array dimension type 35 extern Type * SizeType; 37 36 38 // for a flexible array member nothing is done -- user must define own assignment 39 if ( ! array->get_dimension() ) return; 37 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. 38 template< typename OutputIterator > 39 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true ); 40 40 41 Expression * begin, * end, * update, * cmp; 42 if ( forward ) { 43 // generate: for ( int i = 0; i < 0; ++i ) 44 begin = new NameExpr( "0" ); 45 end = array->get_dimension()->clone(); 46 cmp = new NameExpr( "?<?" ); 47 update = new NameExpr( "++?" ); 48 } else { 49 // generate: for ( int i = N-1; i >= 0; --i ) 50 begin = new UntypedExpr( new NameExpr( "?-?" ) ); 51 ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() ); 52 ((UntypedExpr*)begin)->get_args().push_back( new NameExpr( "1" ) ); 53 end = new NameExpr( "0" ); 54 cmp = new NameExpr( "?>=?" ); 55 update = new NameExpr( "--?" ); 56 } 41 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types. 42 /// optionally returns a statement which must be inserted prior to the containing loop, if there is one 43 template< typename OutputIterator > 44 Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) { 45 // want to be able to generate assignment, ctor, and dtor generically, 46 // so fname is either ?=?, ?{}, or ^?{} 47 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) ); 57 48 58 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), NULL ); 49 // do something special for unnamed members 50 dstParam = new AddressExpr( dstParam ); 51 if ( addCast ) { 52 // cast to T* with qualifiers removed, so that qualified objects can be constructed 53 // and destructed with the same functions as non-qualified objects. 54 // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument 55 // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever 56 // remove lvalue as a qualifier, this can change to 57 // type->get_qualifiers() = Type::Qualifiers(); 58 assert( type ); 59 Type * castType = type->clone(); 60 castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, true); 61 castType->set_isLvalue( true ); // xxx - might not need this 62 dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) ); 63 } 64 fExpr->get_args().push_back( dstParam ); 59 65 60 UntypedExpr *init = new UntypedExpr( new NameExpr( "?=?" ) ); 61 init->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) ); 62 init->get_args().push_back( begin ); 63 index->set_init( new SingleInit( init, std::list<Expression*>() ) ); 66 Statement * listInit = srcParam.buildListInit( fExpr ); 64 67 65 UntypedExpr *cond = new UntypedExpr( cmp ); 66 cond->get_args().push_back( new VariableExpr( index ) ); 67 cond->get_args().push_back( end ); 68 std::list< Expression * > args = *++srcParam; 69 fExpr->get_args().splice( fExpr->get_args().end(), args ); 68 70 69 UntypedExpr *inc = new UntypedExpr( update ); 70 inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) ); 71 *out++ = new ExprStmt( noLabels, fExpr ); 71 72 72 // want to be able to generate assignment, ctor, and dtor generically, 73 // so fname is either ?=?, ?{}, or ^?{} 74 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) ); 73 srcParam.clearArrayIndices(); 75 74 76 UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?+?" ) ); 77 dstIndex->get_args().push_back( dstParam ); 78 dstIndex->get_args().push_back( new VariableExpr( index ) ); 79 fExpr->get_args().push_back( dstIndex ); 75 return listInit; 76 } 80 77 81 // srcParam is NULL for default ctor/dtor 82 if ( srcParam ) { 83 UntypedExpr *srcIndex = new UntypedExpr( new NameExpr( "?[?]" ) ); 84 srcIndex->get_args().push_back( srcParam ); 85 srcIndex->get_args().push_back( new VariableExpr( index ) ); 86 fExpr->get_args().push_back( srcIndex ); 87 } 78 /// Store in out a loop which calls fname on each element of the array with srcParam and dstParam as arguments. 79 /// If forward is true, loop goes from 0 to N-1, else N-1 to 0 80 template< typename OutputIterator > 81 void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) { 82 static UniqueName indexName( "_index" ); 88 83 89 std::list<Statement *> initList; 90 CompoundStmt * block = new CompoundStmt( noLabels ); 91 block->get_kids().push_back( new DeclStmt( noLabels, index ) ); 92 block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, new ExprStmt( noLabels, fExpr ) ) ); 84 // for a flexible array member nothing is done -- user must define own assignment 85 if ( ! array->get_dimension() ) return ; 93 86 94 Statement * stmt = block; 95 if ( fname == "?{}" || fname == "^?{}" ) { 96 // implicitly generated ctor/dtor calls should be wrapped 97 // so that later passes are aware they were generated 98 stmt = new ImplicitCtorDtorStmt( stmt ); 99 } 100 *out++ = stmt; 101 } 87 Expression * begin, * end, * update, * cmp; 88 if ( forward ) { 89 // generate: for ( int i = 0; i < 0; ++i ) 90 begin = new NameExpr( "0" ); 91 end = array->get_dimension()->clone(); 92 cmp = new NameExpr( "?<?" ); 93 update = new NameExpr( "++?" ); 94 } else { 95 // generate: for ( int i = N-1; i >= 0; --i ) 96 begin = new UntypedExpr( new NameExpr( "?-?" ) ); 97 ((UntypedExpr*)begin)->get_args().push_back( array->get_dimension()->clone() ); 98 ((UntypedExpr*)begin)->get_args().push_back( new NameExpr( "1" ) ); 99 end = new NameExpr( "0" ); 100 cmp = new NameExpr( "?>=?" ); 101 update = new NameExpr( "--?" ); 102 } 103 104 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), NULL ); 105 106 UntypedExpr *init = new UntypedExpr( new NameExpr( "?=?" ) ); 107 init->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) ); 108 init->get_args().push_back( begin ); 109 index->set_init( new SingleInit( init, std::list<Expression*>() ) ); 110 111 UntypedExpr *cond = new UntypedExpr( cmp ); 112 cond->get_args().push_back( new VariableExpr( index ) ); 113 cond->get_args().push_back( end ); 114 115 UntypedExpr *inc = new UntypedExpr( update ); 116 inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) ); 117 118 UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) ); 119 dstIndex->get_args().push_back( dstParam ); 120 dstIndex->get_args().push_back( new VariableExpr( index ) ); 121 dstParam = dstIndex; 122 123 // srcParam must keep track of the array indices to build the 124 // source parameter and/or array list initializer 125 srcParam.addArrayIndex( new VariableExpr( index ), array->get_dimension()->clone() ); 126 127 // for stmt's body, eventually containing call 128 CompoundStmt * body = new CompoundStmt( noLabels ); 129 Statement * listInit = genCall( srcParam, dstParam, fname, back_inserter( body->get_kids() ), array->get_base(), addCast, forward ); 130 131 // block containing for stmt and index variable 132 std::list<Statement *> initList; 133 CompoundStmt * block = new CompoundStmt( noLabels ); 134 block->get_kids().push_back( new DeclStmt( noLabels, index ) ); 135 if ( listInit ) block->get_kids().push_back( listInit ); 136 block->get_kids().push_back( new ForStmt( noLabels, initList, cond, inc, body ) ); 137 138 *out++ = block; 139 } 140 141 template< typename OutputIterator > 142 Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) { 143 if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) { 144 genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward ); 145 return 0; 146 } else { 147 return genScalarCall( srcParam, dstParam, fname, out, type, addCast ); 148 } 149 } 150 151 /// inserts into out a generated call expression to function fname with arguments dstParam 152 /// and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls. decl is the 153 /// object being constructed. The function wraps constructor and destructor calls in an 154 /// ImplicitCtorDtorStmt node. 155 template< typename OutputIterator > 156 void genImplicitCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, DeclarationWithType * decl, bool forward = true ) { 157 ObjectDecl *obj = dynamic_cast<ObjectDecl *>( decl ); 158 assert( obj ); 159 // unnamed bit fields are not copied as they cannot be accessed 160 if ( isUnnamedBitfield( obj ) ) return; 161 162 bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && obj->get_bitfieldWidth() == NULL ) ); 163 std::list< Statement * > stmts; 164 genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->get_type(), addCast, forward ); 165 166 // currently genCall should produce at most one element, but if that changes then the next line needs to be updated to grab the statement which contains the call 167 assert( stmts.size() <= 1 ); 168 if ( stmts.size() == 1 ) { 169 Statement * callStmt = stmts.front(); 170 if ( addCast ) { 171 // implicitly generated ctor/dtor calls should be wrapped 172 // so that later passes are aware they were generated. 173 // xxx - don't mark as an implicit ctor/dtor if obj is a bitfield, 174 // because this causes the address to be taken at codegen, which is illegal in C. 175 callStmt = new ImplicitCtorDtorStmt( callStmt ); 176 } 177 *out++ = callStmt; 178 } 179 } 102 180 } // namespace SymTab 103 181 #endif // AUTOGEN_H -
src/SymTab/FixFunction.cc
r5070fe4 rc331406 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FixFunction.cc -- 7 // FixFunction.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 44 44 45 45 Type * FixFunction::mutate(ArrayType *arrayType) { 46 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), maybeClone( arrayType->get_base()->clone() ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() ); 46 // need to recursively mutate the base type in order for multi-dimensional arrays to work. 47 PointerType *pointerType = new PointerType( arrayType->get_qualifiers(), arrayType->get_base()->clone()->acceptMutator( *this ), maybeClone( arrayType->get_dimension() ), arrayType->get_isVarLen(), arrayType->get_isStatic() ); 47 48 delete arrayType; 48 49 return pointerType; -
src/SymTab/Validate.cc
r5070fe4 rc331406 174 174 175 175 virtual void visit( FunctionDecl *funcDecl ); 176 };176 }; 177 177 178 178 class CompoundLiteral : public GenPoly::DeclMutator { … … 191 191 EliminateTypedef::eliminateTypedef( translationUnit ); 192 192 HoistStruct::hoistStruct( translationUnit ); 193 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs Pass1 193 194 acceptAll( translationUnit, pass1 ); 194 195 acceptAll( translationUnit, pass2 ); 195 196 ReturnChecker::checkFunctionReturns( translationUnit ); 196 mutateAll( translationUnit, compoundliteral ); 197 autogenerateRoutines( translationUnit ); 197 compoundliteral.mutateDeclarationList( translationUnit ); 198 198 acceptAll( translationUnit, pass3 ); 199 199 VerifyCtorDtor::verify( translationUnit ); … … 490 490 EliminateTypedef eliminator; 491 491 mutateAll( translationUnit, eliminator ); 492 if ( eliminator.typedefNames.count( "size_t" ) ) { 493 // grab and remember declaration of size_t 494 SizeType = eliminator.typedefNames["size_t"].first->get_base()->clone(); 495 } else { 496 // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong 497 // eventually should have a warning for this case. 498 SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 499 } 492 500 filter( translationUnit, isTypedef, true ); 501 493 502 } 494 503 … … 518 527 Declaration *EliminateTypedef::mutate( TypedefDecl * tyDecl ) { 519 528 Declaration *ret = Mutator::mutate( tyDecl ); 529 520 530 if ( typedefNames.count( tyDecl->get_name() ) == 1 && typedefNames[ tyDecl->get_name() ].second == scopeLevel ) { 521 531 // typedef to the same name from the same scope -
src/SynTree/AddStmtVisitor.cc
r5070fe4 rc331406 10 10 // Created On : Wed Jun 22 12:11:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:49:59201613 // Update Count : 1 212 // Last Modified On : Thu Aug 4 11:23:47 2016 13 // Update Count : 16 14 14 // 15 15 … … 71 71 72 72 void AddStmtVisitor::visit(SwitchStmt *switchStmt) { 73 visitStatementList( switchStmt->get_ branches() );73 visitStatementList( switchStmt->get_statements() ); 74 74 maybeAccept( switchStmt->get_condition(), *this ); 75 75 } -
src/SynTree/Declaration.cc
r5070fe4 rc331406 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Declaration.cc -- 7 // Declaration.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 20 20 #include "Initializer.h" 21 21 #include "Type.h" 22 #include "Attribute.h" 22 23 #include "Common/utility.h" 23 24 -
src/SynTree/Declaration.h
r5070fe4 rc331406 64 64 class DeclarationWithType : public Declaration { 65 65 public: 66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage );66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes ); 67 67 DeclarationWithType( const DeclarationWithType &other ); 68 68 virtual ~DeclarationWithType(); … … 75 75 int get_scopeLevel() const { return scopeLevel; } 76 76 void set_scopeLevel( int newValue ) { scopeLevel = newValue; } 77 78 std::list< Attribute * >& get_attributes() { return attributes; } 79 const std::list< Attribute * >& get_attributes() const { return attributes; } 77 80 78 81 virtual DeclarationWithType *clone() const = 0; … … 87 90 // shadowed identifiers can be accessed 88 91 int scopeLevel = 0; 92 93 std::list< Attribute * > attributes; 89 94 }; 90 95 … … 92 97 typedef DeclarationWithType Parent; 93 98 public: 94 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline = false, bool isNoreturn = false );99 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes = std::list< Attribute * >(), bool isInline = false, bool isNoreturn = false ); 95 100 ObjectDecl( const ObjectDecl &other ); 96 101 virtual ~ObjectDecl(); … … 131 136 std::list< std::string >& get_oldIdents() { return oldIdents; } 132 137 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 133 std::list< Attribute * >& get_attributes() { return attributes; }134 138 135 139 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 143 147 std::list< std::string > oldIdents; 144 148 std::list< Declaration* > oldDecls; 145 std::list< Attribute * > attributes;146 149 }; 147 150 -
src/SynTree/DeclarationWithType.cc
r5070fe4 rc331406 16 16 #include "Declaration.h" 17 17 #include "Type.h" 18 #include "Attribute.h" 18 19 #include "Common/utility.h" 19 20 20 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage )21 : Declaration( name, sc, linkage ) {21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes ) 22 : Declaration( name, sc, linkage ), attributes( attributes ) { 22 23 } 23 24 24 25 DeclarationWithType::DeclarationWithType( const DeclarationWithType &other ) 25 26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) { 27 cloneAll( other.attributes, attributes ); 26 28 } 27 29 28 30 DeclarationWithType::~DeclarationWithType() { 31 deleteAll( attributes ); 29 32 } 30 33 -
src/SynTree/Expression.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 : Mon Jun 13 16:03:39201613 // Update Count : 4 212 // Last Modified On : Wed Aug 3 17:06:51 2016 13 // Update Count : 45 14 14 // 15 15 … … 344 344 } 345 345 346 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned... 346 347 MemberExpr::MemberExpr( const MemberExpr &other ) : 347 Expression( other ), member( maybeClone( other.member )), aggregate( maybeClone( other.aggregate ) ) {348 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { 348 349 } 349 350 350 351 MemberExpr::~MemberExpr() { 351 delete member;352 // delete member; 352 353 delete aggregate; 353 354 } … … 528 529 } 529 530 531 RangeExpr::RangeExpr( ConstantExpr *low, ConstantExpr *high ) : low( low ), high( high ) {} 532 RangeExpr::RangeExpr( const RangeExpr &other ) : low( other.low->clone() ), high( other.high->clone() ) {} 533 void RangeExpr::print( std::ostream &os, int indent ) const { 534 os << std::string( indent, ' ' ) << "Range Expression: "; 535 low->print( os, indent ); 536 os << " ... "; 537 high->print( os, indent ); 538 } 530 539 531 540 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.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 : Mon Jul 4 14:45:32201613 // Update Count : 2 312 // Last Modified On : Wed Aug 3 17:08:44 2016 13 // Update Count : 27 14 14 // 15 15 … … 18 18 19 19 #include <map> 20 #include <memory> 20 21 #include "SynTree.h" 21 22 #include "Visitor.h" … … 634 635 }; 635 636 637 class RangeExpr : public Expression { 638 public: 639 RangeExpr( ConstantExpr *low, ConstantExpr *high ); 640 RangeExpr( const RangeExpr &other ); 641 642 ConstantExpr * get_low() const { return low.get(); } 643 ConstantExpr * get_high() const { return high.get(); } 644 RangeExpr * set_low( ConstantExpr *low ) { RangeExpr::low.reset( low ); return this; } 645 RangeExpr * set_high( ConstantExpr *high ) { RangeExpr::high.reset( high ); return this; } 646 647 virtual RangeExpr *clone() const { return new RangeExpr( *this ); } 648 virtual void accept( Visitor &v ) { v.visit( this ); } 649 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 650 virtual void print( std::ostream &os, int indent = 0 ) const; 651 private: 652 std::unique_ptr<ConstantExpr> low, high; 653 }; 654 636 655 std::ostream & operator<<( std::ostream & out, Expression * expr ); 637 656 -
src/SynTree/FunctionDecl.cc
r5070fe4 rc331406 23 23 24 24 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes ) 25 : Parent( name, sc, linkage ), type( type ), statements( statements ), attributes( attributes ) {25 : Parent( name, sc, linkage, attributes ), type( type ), statements( statements ) { 26 26 set_isInline( isInline ); 27 27 set_isNoreturn( isNoreturn ); … … 34 34 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 35 35 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 36 cloneAll( other.attributes, attributes );37 36 } 38 37 … … 40 39 delete type; 41 40 delete statements; 42 deleteAll( attributes );43 41 } 44 42 … … 69 67 } // if 70 68 71 printAll( attributes, os, indent );69 printAll( get_attributes(), os, indent ); 72 70 73 71 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { -
src/SynTree/Initializer.h
r5070fe4 rc331406 93 93 std::list<Initializer*> &get_initializers() { return initializers; } 94 94 95 std::list<Initializer*>::iterator begin_initializers() { return initializers.begin(); } 96 std::list<Initializer*>::iterator end_initializers() { return initializers.end(); } 95 typedef std::list<Initializer*>::iterator iterator; 96 iterator begin() { return initializers.begin(); } 97 iterator end() { return initializers.end(); } 97 98 98 99 virtual ListInit *clone() const { return new ListInit( *this ); } -
src/SynTree/Label.h
r5070fe4 rc331406 24 24 class Label { 25 25 public: 26 Label( const std::string & name = "", Statement * labelled = 0 ) : name( name ), labelled( labelled) {}26 Label( const std::string & name = "", Statement * labelled = 0, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : name( name ), labelled( labelled ), attributes( attributes ) {} 27 27 Label( const char * name, Statement * labelled = 0 ) : name( name ), labelled( labelled ) {} 28 28 -
src/SynTree/Mutator.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:51:19201613 // Update Count : 1 712 // Last Modified On : Thu Aug 4 11:23:21 2016 13 // Update Count : 19 14 14 // 15 15 … … 126 126 Statement *Mutator::mutate( SwitchStmt *switchStmt ) { 127 127 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) ); 128 mutateAll( switchStmt->get_ branches(), *this );128 mutateAll( switchStmt->get_statements(), *this ); 129 129 return switchStmt; 130 130 } … … 349 349 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 350 350 return compLitExpr; 351 } 352 353 Expression *Mutator::mutate( RangeExpr *rangeExpr ) { 354 rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) ); 355 rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) ); 356 return rangeExpr; 351 357 } 352 358 -
src/SynTree/Mutator.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 : Tue Jul 12 17:51:43201613 // Update Count : 1 112 // Last Modified On : Wed Aug 3 16:59:45 2016 13 // Update Count : 12 14 14 // 15 15 #include <cassert> … … 78 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 80 virtual Expression* mutate( RangeExpr *rangeExpr ); 80 81 81 82 virtual Type* mutate( VoidType *basicType ); -
src/SynTree/ObjectDecl.cc
r5070fe4 rc331406 18 18 #include "Initializer.h" 19 19 #include "Expression.h" 20 #include "Attribute.h" 20 21 #include "Common/utility.h" 21 22 #include "Statement.h" 22 23 23 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )24 : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn ) 25 : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 25 26 set_isInline( isInline ); 26 27 set_isNoreturn( isNoreturn ); … … 45 46 os << LinkageSpec::toString( get_linkage() ) << " "; 46 47 } // if 48 49 printAll( get_attributes(), os, indent ); 47 50 48 51 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { … … 80 83 } // if 81 84 85 // xxx - should printShort print attributes? 86 82 87 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 83 88 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; -
src/SynTree/Statement.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:52:32201613 // Update Count : 5512 // Last Modified On : Thu Aug 4 11:25:20 2016 13 // Update Count : 61 14 14 // 15 15 … … 143 143 } 144 144 145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_ branches ):146 Statement( _labels ), condition( _condition ), branches( _branches ) {145 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_statements ): 146 Statement( _labels ), condition( _condition ), statements( _statements ) { 147 147 } 148 148 149 149 SwitchStmt::SwitchStmt( const SwitchStmt & other ): 150 150 Statement( other ), condition( maybeClone( other.condition ) ) { 151 cloneAll( other. branches, branches );151 cloneAll( other.statements, statements ); 152 152 } 153 153 154 154 SwitchStmt::~SwitchStmt() { 155 155 delete condition; 156 // destroy branches 157 } 158 159 void SwitchStmt::add_case( CaseStmt *c ) {} 156 // destroy statements 157 } 160 158 161 159 void SwitchStmt::print( std::ostream &os, int indent ) const { … … 164 162 os << endl; 165 163 166 // branches164 // statements 167 165 std::list<Statement *>::const_iterator i; 168 for ( i = branches.begin(); i != branches.end(); i++)166 for ( i = statements.begin(); i != statements.end(); i++) 169 167 (*i)->print( os, indent + 4 ); 170 168 171 //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));169 //for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os )); 172 170 } 173 171 … … 187 185 } 188 186 189 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> branches ) {190 return new CaseStmt( labels, 0, branches, true );187 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) { 188 return new CaseStmt( labels, 0, stmts, true ); 191 189 } 192 190 -
src/SynTree/Statement.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 : T ue Jul 12 17:53:29201613 // Update Count : 4712 // Last Modified On : Thu Aug 4 11:26:02 2016 13 // Update Count : 64 14 14 // 15 15 … … 129 129 class SwitchStmt : public Statement { 130 130 public: 131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> & branches );131 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements ); 132 132 SwitchStmt( const SwitchStmt &other ); 133 133 virtual ~SwitchStmt(); … … 136 136 void set_condition( Expression *newValue ) { condition = newValue; } 137 137 138 std::list<Statement *> & get_branches() { return branches; } 139 void add_case( CaseStmt * ); 138 std::list<Statement *> & get_statements() { return statements; } 140 139 141 140 virtual void accept( Visitor &v ) { v.visit( this ); } … … 146 145 private: 147 146 Expression * condition; 148 std::list<Statement *> branches; // should be list of CaseStmt147 std::list<Statement *> statements; 149 148 }; 150 149 151 150 class CaseStmt : public Statement { 152 151 public: 153 CaseStmt( std::list<Label> labels, Expression *conditions, 154 std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 152 CaseStmt( std::list<Label> labels, Expression *conditions, std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 155 153 CaseStmt( const CaseStmt &other ); 156 154 virtual ~CaseStmt(); 157 155 158 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), 159 std::list<Statement *> stmts = std::list<Statement *>() ); 156 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() ); 160 157 161 158 bool isDefault() const { return _isDefault; } -
src/SynTree/SynTree.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 : Tue Jul 12 17:54:02201613 // Update Count : 612 // Last Modified On : Wed Aug 3 17:02:34 2016 13 // Update Count : 7 14 14 // 15 15 … … 83 83 class UntypedValofExpr; 84 84 class CompoundLiteralExpr; 85 class RangeExpr; 85 86 86 87 class Type; -
src/SynTree/Visitor.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:54:39201613 // Update Count : 1912 // Last Modified On : Thu Aug 4 11:24:25 2016 13 // Update Count : 21 14 14 // 15 15 … … 109 109 void Visitor::visit( SwitchStmt *switchStmt ) { 110 110 maybeAccept( switchStmt->get_condition(), *this ); 111 acceptAll( switchStmt->get_ branches(), *this );111 acceptAll( switchStmt->get_statements(), *this ); 112 112 } 113 113 … … 296 296 maybeAccept( compLitExpr->get_type(), *this ); 297 297 maybeAccept( compLitExpr->get_initializer(), *this ); 298 } 299 300 void Visitor::visit( RangeExpr *rangeExpr ) { 301 maybeAccept( rangeExpr->get_low(), *this ); 302 maybeAccept( rangeExpr->get_high(), *this ); 298 303 } 299 304 -
src/SynTree/Visitor.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 : Tue Jul 12 17:55:09201613 // Update Count : 812 // Last Modified On : Wed Aug 3 17:01:50 2016 13 // Update Count : 9 14 14 // 15 15 … … 78 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 80 virtual void visit( RangeExpr *rangeExpr ); 80 81 81 82 virtual void visit( VoidType *basicType ); -
src/examples/gc_no_raii/bug-repro/return_template.c
r5070fe4 rc331406 5 5 }; 6 6 7 forall(otype T) void ?{}(wrap(T)* this); 8 forall(otype T) void ?{}(wrap(T)* this, wrap(T)* rhs); 9 forall(otype T) void ^?{}(wrap(T)* this); 10 forall(otype T) void ?=?(wrap(T)* this, wrap(T)* rhs); 11 7 12 forall(otype T) 8 static inlinewrap(T) test()13 wrap(T) test() 9 14 { 10 15 wrap(T) tester; -
src/examples/gc_no_raii/src/gc.h
r5070fe4 rc331406 7 7 static inline gcpointer(T) gcmalloc() 8 8 { 9 gcpointer(T) test; 10 // ctor(&test, gc_allocate(sizeof(T))); 11 // gc_conditional_collect(); 12 return test; 9 gcpointer(T) ptr; 10 void* address = gc_allocate(sizeof(T)); 11 (&ptr){ address }; 12 ctor(&ptr, address); 13 gc_conditional_collect(); 14 return ptr; 13 15 } -
src/examples/gc_no_raii/src/gcpointers.c
r5070fe4 rc331406 1 1 #include "gcpointers.h" 2 2 3 #include "gc.h"3 // #include "gc.h" 4 4 #include "internal/collector.h" 5 5 #include "internal/object_header.h" -
src/examples/gc_no_raii/src/gcpointers.h
r5070fe4 rc331406 10 10 }; 11 11 12 void gcpointer_ctor(gcpointer_t* this);13 void gcpointer_ctor(gcpointer_t* this, void* address);14 void gcpointer_ctor(gcpointer_t* this, gcpointer_t*other);15 void gcpointer_dtor(gcpointer_t* this);16 gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t*rhs);12 void ?{}(gcpointer_t* this); 13 void ?{}(gcpointer_t* this, void* address); 14 void ?{}(gcpointer_t* this, gcpointer_t other); 15 void ^?{}(gcpointer_t* this); 16 gcpointer_t* ?=?(gcpointer_t this, gcpointer_t rhs); 17 17 18 18 //Logical operators … … 27 27 }; 28 28 29 forall(otype T) 30 static inline void ctor(gcpointer(T)* this) 31 { 32 gcpointer_ctor(&this->internal); 33 } 29 // 30 forall(otype T) void ?{}(gcpointer(T)* this); 31 forall(otype T) void ?{}(gcpointer(T)* this, void* address); 32 forall(otype T) void ctor(gcpointer(T)* this, void* address); 33 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other); 34 forall(otype T) void ^?{}(gcpointer(T)* this); 35 forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs); 34 36 35 // forall(otype T)36 // static inline void ctor(gcpointer(T)* this, int null)37 // {38 // gcpointer_ctor(&this->internal, NULL);39 // }40 37 41 forall(otype T) 42 static inline void ctor(gcpointer(T)* this, void* address) 43 { 44 gcpointer_ctor(&this->internal, address); 45 } 46 47 forall(otype T) 48 static inline void ctor(gcpointer(T)* this, gcpointer(T)* other) 49 { 50 gcpointer_ctor(&this->internal, other); 51 } 52 53 forall(otype T) 54 static inline void dtor(gcpointer(T)* this) 55 { 56 gcpointer_dtor(&this->internal); 57 } 58 59 forall(otype T) 60 static inline gcpointer(T)* ?=?(gcpointer(T)* this, gcpointer(T)* rhs) 61 { 62 gcpointer_assign(&this->internal, &rhs->internal); 63 return this; 64 } 65 66 forall(otype T) 67 static inline T *?(gcpointer(T) this) 68 { 69 return *(T*)this.internal.ptr; 70 } 38 forall(otype T) T *?(gcpointer(T) this); 71 39 72 40 //Logical operators 73 forall(otype T) 74 static inline int ?!=?(gcpointer(T) this, gcpointer(T) rhs) 75 { 76 return this.internal.ptr != rhs.internal.ptr; 77 } 78 79 forall(otype T) 80 static inline int ?==?(gcpointer(T) this, gcpointer(T) rhs) 81 { 82 return !(this == rhs); 83 } 84 85 forall(otype T) 86 extern struct gcpointer(T) 0; 41 forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs); 42 forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs); -
src/examples/gc_no_raii/src/internal/memory_pool.h
r5070fe4 rc331406 3 3 extern "C" { 4 4 #include <stdbool.h> 5 #include <stddef.h> 5 6 #include <stdint.h> 6 7 } -
src/examples/gc_no_raii/src/internal/state.h
r5070fe4 rc331406 1 1 #pragma once 2 2 3 #ifdef __cforall 4 extern "C" { 5 #endif 3 6 #include <stddef.h> 4 7 #include <stdint.h> 8 #ifdef __cforall 9 } 10 #endif 11 #include <vector> 5 12 6 13 #include "tools.h" 7 #include "vector.h"8 14 9 15 typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; -
src/examples/gc_no_raii/src/tools/worklist.h
r5070fe4 rc331406 10 10 #endif 11 11 12 #include "vector.h"12 #include <vector> 13 13 14 14 typedef vector(intptr_t*, heap_allocator(intptr_t*)) worklist_t; -
src/examples/gc_no_raii/test/badlll.c
r5070fe4 rc331406 7 7 }; 8 8 9 void ?{}(List_t* this); 10 List_t* ?=?(List_t* this, List_t* rhs); 11 9 12 typedef gcpointer(List_t) LLL; 10 13 11 14 #define MAX (1024 * 1024) 12 15 13 LLL buildLLL(int sz) 16 // LLL buildLLL(int sz) 17 void bla() 14 18 { 15 19 int i; 16 LLL ll0, lll, llc;17 18 ll0 = gcmalloc();19 ll0->val = 0;20 lll = ll0;21 22 for (i = 1; i < sz; i++)23 {24 llc = gcmalloc();25 llc->val = i;26 lll->next = llc;27 lll = llc;28 }29 30 return ll0;20 // LLL ll0;//, lll, llc; 21 // 22 // ll0 = gcmalloc(); 23 // ll0->val = 0; 24 // lll = ll0; 25 // 26 // for (i = 1; i < sz; i++) 27 // { 28 // llc = gcmalloc(); 29 // llc->val = i; 30 // lll->next = llc; 31 // lll = llc; 32 // } 33 // 34 // return ll0; 31 35 } 32 33 void testLLL(LLL lll)34 {35 unsigned char *counted;36 37 counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));38 while (lll)39 {40 counted[lll->val]++;41 if (counted[lll->val] > 1)42 {43 fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);44 exit(1);45 }46 lll = lll->next;47 }48 49 return;50 }36 // 37 // void testLLL(LLL lll) 38 // { 39 // unsigned char *counted; 40 // 41 // counted = (unsigned char *) calloc(MAX, sizeof(unsigned char)); 42 // while (lll) 43 // { 44 // counted[lll->val]++; 45 // if (counted[lll->val] > 1) 46 // { 47 // fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val); 48 // exit(1); 49 // } 50 // lll = lll->next; 51 // } 52 // 53 // return; 54 // } 51 55 52 56 int main(void) … … 54 58 LLL mylll; 55 59 56 mylll = buildLLL(MAX);57 58 testLLL(mylll);60 // mylll = buildLLL(MAX); 61 // 62 // testLLL(mylll); 59 63 60 64 return 0; -
src/examples/gc_no_raii/test/gctest.c
r5070fe4 rc331406 7 7 int main() { 8 8 sout | "Bonjour au monde!\n"; 9 10 gcpointer(int) anInt = gcmalloc(); 9 11 } -
src/main.cc
r5070fe4 rc331406 43 43 #include "InitTweak/GenInit.h" 44 44 #include "InitTweak/FixInit.h" 45 #include "InitTweak/FixGlobalInit.h"46 45 //#include "Explain/GenProlog.h" 47 46 //#include "Try/Visit.h" … … 283 282 OPTPRINT( "fixNames" ) 284 283 CodeGen::fixNames( translationUnit ); 285 OPTPRINT( "fixGlobalInit" );286 InitTweak::fixGlobalInit( translationUnit, filename, libcfap || treep );287 284 OPTPRINT( "tweakInit" ) 288 285 InitTweak::genInit( translationUnit ); … … 305 302 } 306 303 304 // fix ObjectDecl - replaces ConstructorInit nodes 307 305 OPTPRINT( "fixInit" ) 308 // fix ObjectDecl - replaces ConstructorInit nodes 309 InitTweak::fix( translationUnit ); 306 InitTweak::fix( translationUnit, filename, libcfap || treep ); 310 307 if ( ctorinitp ) { 311 308 dump ( translationUnit ); -
src/tests/.expect/64/extension.txt
r5070fe4 rc331406 100 100 ((void)((__extension__ __a__i_2 , __extension__ __b__i_2) , __extension__ __c__i_2)); 101 101 } 102 __attribute__ ((constructor(),)) static void _init_extension(void){103 int _global_init0;104 ((void)((*((int *)(&__a__i_1)))=_global_init0) /* ?{} */);105 int _global_init1;106 ((void)((*((int *)(&__b__i_1)))=_global_init1) /* ?{} */);107 int _global_init2;108 ((void)((*((int *)(&__c__i_1)))=_global_init2) /* ?{} */);109 }110 __attribute__ ((destructor(),)) static void _destroy_extension(void){111 ((void)((*((int *)(&__c__i_1)))) /* ^?{} */);112 ((void)((*((int *)(&__b__i_1)))) /* ^?{} */);113 ((void)((*((int *)(&__a__i_1)))) /* ^?{} */);114 } -
src/tests/init_once.c
r5070fe4 rc331406 92 92 init_once y = x; 93 93 94 void static_variable() { 95 static init_once x; 96 } 97 94 98 int main() { 95 99 // local variables … … 179 183 } 180 184 } 185 186 // function-scoped static variable 187 for (int i = 0; i < 10; i++) { 188 static_variable(); 189 } 181 190 } 182 191 -
src/tests/switch.c
r5070fe4 rc331406 10 10 // Created On : Tue Jul 12 06:50:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 30 14:41:32201613 // Update Count : 3 012 // Last Modified On : Thu Aug 4 11:44:29 2016 13 // Update Count : 31 14 14 // 15 15 … … 39 39 case 4: 40 40 j = 0; 41 } 42 43 switch ( i ) { 44 case 1, 2, 3: 45 switch ( i ) { 46 case 2, 3, 4: 47 7; 48 } 41 49 } 42 50
Note:
See TracChangeset
for help on using the changeset viewer.