Changeset 5fcba14
- Timestamp:
- Dec 4, 2017, 11:08:27 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 6d2f993
- Parents:
- 497282e
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r497282e r5fcba14 717 717 } 718 718 719 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body ) {719 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body, StatementNode * with ) { 720 720 assert( type ); 721 721 assert( type->kind == TypeData::Function ); 722 722 assert( ! type->function.body ); 723 if ( with ) { 724 // convert 725 // void f(S s) with (s) { x = 0; } 726 // to 727 // void f(S s) { with(s) { x = 0; } } 728 WithStmt * withStmt = strict_dynamic_cast< WithStmt * >( with->build() ); 729 withStmt->stmt = body->build(); 730 delete body; 731 delete with; 732 body = new StatementNode( new CompoundStmt( { withStmt } ) ); 733 } 723 734 type->function.body = body; 724 735 return this; -
src/Parser/ParseNode.h
r497282e r5fcba14 262 262 DeclarationNode * addBitfield( ExpressionNode * size ); 263 263 DeclarationNode * addVarArgs(); 264 DeclarationNode * addFunctionBody( StatementNode * body );264 DeclarationNode * addFunctionBody( StatementNode * body, StatementNode * with = nullptr ); 265 265 DeclarationNode * addOldDeclList( DeclarationNode * list ); 266 266 DeclarationNode * setBase( TypeData * newType ); -
src/Parser/parser.yy
r497282e r5fcba14 2412 2412 { $$ = nullptr; } 2413 2413 | WITH '(' tuple_expression_list ')' 2414 { throw SemanticError("With clause is currently unimplemented."); $$ = nullptr; } // FIX ME2414 { $$ = new StatementNode( build_with( $3, nullptr ) ); } 2415 2415 ; 2416 2416 … … 2422 2422 // Add the function body to the last identifier in the function definition list, i.e., foo3: 2423 2423 // [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; } 2424 $1->get_last()->addFunctionBody( $3 );2424 $1->get_last()->addFunctionBody( $3, $2 ); 2425 2425 $$ = $1; 2426 2426 } … … 2430 2430 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2431 2431 typedefTable.leaveScope(); 2432 $$ = $2->addFunctionBody( $4 )->addType( $1 );2432 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2433 2433 } 2434 2434 // handles default int return type, OBSOLESCENT (see 1) … … 2437 2437 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2438 2438 typedefTable.leaveScope(); 2439 $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );2439 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2440 2440 } 2441 2441 // handles default int return type, OBSOLESCENT (see 1) … … 2444 2444 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2445 2445 typedefTable.leaveScope(); 2446 $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );2446 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2447 2447 } 2448 2448 // handles default int return type, OBSOLESCENT (see 1) … … 2451 2451 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2452 2452 typedefTable.leaveScope(); 2453 $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 );2453 $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); 2454 2454 } 2455 2455 … … 2460 2460 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2461 2461 typedefTable.leaveScope(); 2462 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addType( $1 );2462 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 ); 2463 2463 } 2464 2464 // handles default int return type, OBSOLESCENT (see 1) … … 2467 2467 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2468 2468 typedefTable.leaveScope(); 2469 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 );2469 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2470 2470 } 2471 2471 // handles default int return type, OBSOLESCENT (see 1) … … 2474 2474 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2475 2475 typedefTable.leaveScope(); 2476 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 );2476 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2477 2477 } 2478 2478 // handles default int return type, OBSOLESCENT (see 1) … … 2481 2481 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2482 2482 typedefTable.leaveScope(); 2483 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 );2483 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); 2484 2484 } 2485 2485 ;
Note: See TracChangeset
for help on using the changeset viewer.