// Very simple code to understand how tlcc works #include #define _TLMP_foo static void print (const char *s) { printf ("::print s=%s\n",s); } struct _F_foo{ void print(const char *s){ printf ("foo::print s=%s\n",s); } #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(); } #define _TLMP_bar struct _F_bar{ #define _F_bar_func1(x) void x func1() virtual _F_bar_func1( )=0; #define _F_bar_func2(x) void x func2() virtual _F_bar_func2( )=0; }; void bar (_F_bar &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 #ifndef _TLMP_bar #error TLMP module bar unknown #endif #ifndef _F_bar_func1 #error Unknown logical function func1 for module/class bar #endif #ifndef _F_bar_func2 #error Unknown logical function func2 for module/class bar #endif #line 40 "helper2.tlcc" int main() { class __sc_tests_helper2_tlcc1: public _F_foo{ public: __sc_tests_helper2_tlcc1 () { } _F_foo_func1( ) { #line 44 "helper2.tlcc" printf ("This is func1\n"); print("func1"); } // #line 47 "helper2.tlcc" _F_foo_func2( ) { #line 48 "helper2.tlcc" printf ("This is func2\n"); struct __gl_tests_helper2_tlcc_GLOCAL1_1{ _F_foo &foo; __gl_tests_helper2_tlcc_GLOCAL1_1(_F_foo *_c) : foo(*_c) {} }; { // Inserted to support nested glocals __gl_tests_helper2_tlcc_GLOCAL1_1 B_glocal(this); class __sc_tests_helper2_tlcc2: public _F_bar{ public: __gl_tests_helper2_tlcc_GLOCAL1_1 &glocal; __sc_tests_helper2_tlcc2 (__gl_tests_helper2_tlcc_GLOCAL1_1 &g) : glocal(g) { } _F_bar_func1( ) { #line 51 "helper2.tlcc" printf ("func2 -> func1\n"); glocal.foo.print("func2 -> func1"); } // #line 54 "helper2.tlcc" _F_bar_func2( ) { #line 55 "helper2.tlcc" ::print ("func2 -> func2"); } // #line 57 "helper2.tlcc" }; __sc_tests_helper2_tlcc2 _scopeobj2(B_glocal); #line 50 "helper2.tlcc" ::bar(_scopeobj2); #line 50 "helper2.tlcc" #line 58 "helper2.tlcc" } // #line 59 "helper2.tlcc" } // For nested glocals 1 -> 0 }; static __sc_tests_helper2_tlcc1 _scopeobj1; #line 43 "helper2.tlcc" ::foo(_scopeobj1); #line 60 "helper2.tlcc" return 0; } #line 63 "helper2.tlcc"