// Very simple code to understand how tlcc works #include #include using namespace std; #define _TLMP_foo struct _F_foo{ string title; void print(const char *s){ printf ("%s::print s=%s\n",title.c_str(),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, const char *title) { c.title = title; 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_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 26 "helper.tlcc" int main() { class __sc_tests_helper_tlcc1: public _F_foo{ public: __sc_tests_helper_tlcc1 () { } _F_foo_func1( ) { #line 30 "helper.tlcc" printf ("This is func1\n"); print("func1"); } // #line 33 "helper.tlcc" _F_foo_func2( ) { #line 34 "helper.tlcc" printf ("This is func2\n"); struct __gl_tests_helper_tlcc_GLOCAL1_1{ _F_foo &foo; __gl_tests_helper_tlcc_GLOCAL1_1(_F_foo *_c) : foo(*_c) {} }; { // Inserted to support nested glocals __gl_tests_helper_tlcc_GLOCAL1_1 B_glocal(this); class __sc_tests_helper_tlcc2: public _F_foo{ public: __gl_tests_helper_tlcc_GLOCAL1_1 &glocal; __sc_tests_helper_tlcc2 (__gl_tests_helper_tlcc_GLOCAL1_1 &g) : glocal(g) { } _F_foo_func1( ) { #line 37 "helper.tlcc" print ("func2 -> func1"); glocal.foo.print("func2 -> func1"); } // #line 40 "helper.tlcc" _F_foo_func2( ) { #line 41 "helper.tlcc" print ("func2 -> func2"); } // #line 43 "helper.tlcc" }; __sc_tests_helper_tlcc2 _scopeobj2(B_glocal); #line 36 "helper.tlcc" ::foo(_scopeobj2,"sub-foo"); #line 36 "helper.tlcc" #line 44 "helper.tlcc" } // #line 45 "helper.tlcc" } // For nested glocals 1 -> 0 }; static __sc_tests_helper_tlcc1 _scopeobj1; #line 29 "helper.tlcc" ::foo(_scopeobj1,"main-foo"); #line 46 "helper.tlcc" return 0; } #line 49 "helper.tlcc"