Ignore:
Timestamp:
Dec 4, 2017, 11:08:27 AM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
6d2f993
Parents:
497282e
Message:

Implement function declaration's with clause

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r497282e r5fcba14  
    717717}
    718718
    719 DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body ) {
     719DeclarationNode * DeclarationNode::addFunctionBody( StatementNode * body, StatementNode * with ) {
    720720        assert( type );
    721721        assert( type->kind == TypeData::Function );
    722722        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        }
    723734        type->function.body = body;
    724735        return this;
Note: See TracChangeset for help on using the changeset viewer.