Hacking the compiler: Get Scope after some line of function

unDEFER via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 27 04:59:51 PDT 2017


Hello! I'm trying to do some strange thing: compile some 
Statement (do semantic3 phase) in the scope of other function.
Other function is for example:

auto megafunction()
{
     B b;
     uint a = 25;
     return b;
}

AST of this code looks like:

FuncDeclaration
{
     fbody = CompoundStatement
     {
          ExpStatement
          {
              exp = DeclarationExp
          }
          ExpStatement
          {
              exp = DeclarationExp
          }
          ReturnStatement;
     }
}

So if I'm trying to take fbody._scope, all works correctly (other 
functions and templates from this module are declared), but 
neither a nor b are declared in this scope.
But exp.declaration._scope is null.

So how to get scope e.g. after line "B b;"?


More information about the Digitalmars-d-learn mailing list