How define nested types ?

42 views
Skip to first unread message

NN

unread,
Mar 10, 2013, 4:00:14 PM3/10/13
to nemer...@googlegroups.com
This one doesn't work:

def a = typer.Env.Define(<[ decl: module A {} ]>);
a.Define(<[ decl: module B {} ]>);
a.Compile();

error : the type A.B was not finalized, forgot the TypeBuilder.Compile () on it?

This one compiles but creates only top module 'X' without nested A and B !!!

def x = [<[ decl: module A {} ]>, <[ decl: module B : A {} ]>];
def tb = typer.Env.Define(<[ decl: module X { ..$x } ]>);
tb.Compile();

NN

unread,
Mar 11, 2013, 9:29:13 AM3/11/13
to nemer...@googlegroups.com
Everything is simple you define types with DefineNestedTypes and members with Define.

Example:
def t = typer.Env.Define(<[ decl: module A {} ]>);
t.DefineNestedType(<[ decl: class B {} ]>).Compile();
t.Define(<[ decl: public F() : void {} ]>);
t.Compile();
Reply all
Reply to author
Forward
0 new messages