Changeset c453ac4 for src/Parser


Ignore:
Timestamp:
Jan 31, 2018, 4:55:49 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
7aaec67
Parents:
c28a038d
Message:

Change parser to build FunctionDecl? withExpr rather than convert to a WithStmt?

Location:
src/Parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rc28a038d rc453ac4  
    723723}
    724724
    725 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body, StatementNode * with ) {
     725DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body, ExpressionNode * withExprs ) {
    726726        assert( type );
    727727        assert( type->kind == TypeData::Function );
    728728        assert( ! type->function.body );
    729         if ( with ) {
    730                 // convert
    731                 //  void f(S s) with (s) { x = 0; }
    732                 // to
    733                 //  void f(S s) { with(s) { x = 0; } }
    734                 WithStmt * withStmt = strict_dynamic_cast< WithStmt * >( with->build() );
    735                 withStmt->stmt = body->build();
    736                 delete body;
    737                 delete with;
    738                 body = new StatementNode( new CompoundStmt( { withStmt } ) );
    739         }
    740729        type->function.body = body;
     730        type->function.withExprs = withExprs;
    741731        return this;
    742732}
  • src/Parser/ParseNode.h

    rc28a038d rc453ac4  
    262262        DeclarationNode * addBitfield( ExpressionNode * size );
    263263        DeclarationNode * addVarArgs();
    264         DeclarationNode * addFunctionBody( StatementNode * body, StatementNode * with = nullptr );
     264        DeclarationNode * addFunctionBody( StatementNode * body, ExpressionNode * with = nullptr );
    265265        DeclarationNode * addOldDeclList( DeclarationNode * list );
    266266        DeclarationNode * setBase( TypeData * newType );
  • src/Parser/TypeData.cc

    rc28a038d rc453ac4  
    864864                CompoundStmt * body = dynamic_cast< CompoundStmt * >( stmt );
    865865                decl = new FunctionDecl( name, scs, linkage, buildFunction( td ), body, attributes, funcSpec );
     866                buildList( td->function.withExprs, decl->withExprs );
    866867                return decl->set_asmName( asmName );
    867868        } else if ( td->kind == TypeData::Aggregate ) {
  • src/Parser/parser.yy

    rc28a038d rc453ac4  
    259259%type<sn> iteration_statement                   jump_statement
    260260%type<sn> expression_statement                  asm_statement
    261 %type<sn> with_statement                                with_clause_opt
     261%type<sn> with_statement
     262%type<en> with_clause_opt
    262263%type<sn> exception_statement                   handler_clause                          finally_clause
    263264%type<catch_kind> handler_key
     
    24172418                { $$ = nullptr; }
    24182419        | WITH '(' tuple_expression_list ')'
    2419                 { $$ = new StatementNode( build_with( $3, nullptr ) ); }
     2420                { $$ = $3; }
    24202421        ;
    24212422
Note: See TracChangeset for help on using the changeset viewer.