// Very simple code to understand how tlcc works #include #define _TLMP_foo struct _F_foo{ #define _F_foo_func1(x) void x func1() virtual _F_foo_func1( )=0; #define _F_foo_func2(x) void x func2() virtual _F_foo_func2( )=0; }; void foo (_F_foo &c) { c.func1(); c.func2(); } #ifndef _TLMP_foo #error TLMP module foo unknown #endif #ifndef _F_foo_func1 #error Unknown logical function func1 for module/class foo #endif #ifndef _F_foo_func2 #error Unknown logical function func2 for module/class foo #endif #line 19 "glocals2.tlcc" int main () { struct FOO{ int b=11; }; #line 26 "glocals2.tlcc" struct __gl_tests_glocals2_tlcc_GLOCAL1_1{ #line 25 "glocals2.tlcc" FOO foo; }; { // Inserted to support nested glocals __gl_tests_glocals2_tlcc_GLOCAL1_1 B_glocal; #line 26 "glocals2.tlcc" B_glocal.foo.b++; printf ("Between glocals B_glocal.foo.b=%d\n",B_glocal.foo.b); #line 29 "glocals2.tlcc" struct __gl_tests_glocals2_tlcc_GLOCAL1_2{ __gl_tests_glocals2_tlcc_GLOCAL1_1 &glocal; __gl_tests_glocals2_tlcc_GLOCAL1_2(__gl_tests_glocals2_tlcc_GLOCAL1_1 &gl) : glocal(gl) {} #line 28 "glocals2.tlcc" int a ; }; { // Inserted to support nested glocals __gl_tests_glocals2_tlcc_GLOCAL1_2 C_glocal(B_glocal); #line 28 "glocals2.tlcc" C_glocal.a= 1; #line 29 "glocals2.tlcc" class __sc_tests_glocals2_tlcc1: public _F_foo{ public: __gl_tests_glocals2_tlcc_GLOCAL1_2 &glocal; __sc_tests_glocals2_tlcc1 (__gl_tests_glocals2_tlcc_GLOCAL1_2 &g) : glocal(g) { } _F_foo_func1( ) { #line 30 "glocals2.tlcc" printf ("This is func1 foo.b=%d a=%d\n",glocal.glocal.foo.b,glocal.a); } // #line 32 "glocals2.tlcc" _F_foo_func2( ) { #line 33 "glocals2.tlcc" printf ("This is func2\n"); } // #line 35 "glocals2.tlcc" }; __sc_tests_glocals2_tlcc1 _scopeobj1(C_glocal); #line 29 "glocals2.tlcc" ::foo(_scopeobj1); #line 36 "glocals2.tlcc" return 0; } } // For nested glocals 2 -> 1 } // For nested glocals 1 -> 0 #line 39 "glocals2.tlcc"