// Very simple code to understand how tlcc works #include #include using namespace std; #define _TLMP_foo struct _F_foo{ #define _F_foo_func1(x) void x func1(const char *msg) virtual _F_foo_func1( )=0; #define _F_foo_func2(x) void x func2(const char *msg) virtual _F_foo_func2( )=0; }; void foo (_F_foo &c, const char *msg) { c.func1(msg); c.func2(msg); } #ifndef _TLMP_foo #error TLMP module foo unknown #endif #ifndef _F_foo_func1 #error Unknown logical function func1 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 #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 20 "simple2.tlcc" int main() { class __sc_tests_simple2_tlcc1: public _F_foo{ public: __sc_tests_simple2_tlcc1 () { } _F_foo_func1( ) { #line 24 "simple2.tlcc" printf ("This is func1 msg=%s\n",msg); string tmp = string(msg) + " -> func1"; struct __gl_tests_simple2_tlcc_GLOCAL1_1{ _F_foo &foo; __gl_tests_simple2_tlcc_GLOCAL1_1(_F_foo *_c) : foo(*_c) {} }; { // Inserted to support nested glocals __gl_tests_simple2_tlcc_GLOCAL1_1 B_glocal(this); class __sc_tests_simple2_tlcc2: public _F_foo{ public: __gl_tests_simple2_tlcc_GLOCAL1_1 &glocal; __sc_tests_simple2_tlcc2 (__gl_tests_simple2_tlcc_GLOCAL1_1 &g) : glocal(g) { } _F_foo_func1( ) { #line 28 "simple2.tlcc" printf ("This is func1 -> func1 msg=%s\n",msg); } // #line 30 "simple2.tlcc" _F_foo_func2( ) { #line 31 "simple2.tlcc" printf ("This is func1 -> func2 msg=%s\n",msg); } // #line 33 "simple2.tlcc" }; __sc_tests_simple2_tlcc2 _scopeobj2(B_glocal); #line 27 "simple2.tlcc" ::foo(_scopeobj2,tmp.c_str()); #line 27 "simple2.tlcc" #line 34 "simple2.tlcc" } // #line 35 "simple2.tlcc" } // For nested glocals 1 -> 0 _F_foo_func2( ) { #line 36 "simple2.tlcc" printf ("This is func2 msg=%s\n",msg); string tmp = string(msg) + " -> func2"; struct __gl_tests_simple2_tlcc_GLOCAL1_2{ _F_foo &foo; __gl_tests_simple2_tlcc_GLOCAL1_2(_F_foo *_c) : foo(*_c) {} }; { // Inserted to support nested glocals __gl_tests_simple2_tlcc_GLOCAL1_2 B_glocal(this); class __sc_tests_simple2_tlcc3: public _F_foo{ public: __gl_tests_simple2_tlcc_GLOCAL1_2 &glocal; __sc_tests_simple2_tlcc3 (__gl_tests_simple2_tlcc_GLOCAL1_2 &g) : glocal(g) { } _F_foo_func1( ) { #line 40 "simple2.tlcc" printf ("This is func2 -> func1 msg=%s\n",msg); } // #line 42 "simple2.tlcc" _F_foo_func2( ) { #line 43 "simple2.tlcc" printf ("This is func2 -> func2 msg=%s\n",msg); } // #line 45 "simple2.tlcc" }; __sc_tests_simple2_tlcc3 _scopeobj3(B_glocal); #line 39 "simple2.tlcc" ::foo(_scopeobj3,tmp.c_str()); #line 39 "simple2.tlcc" #line 46 "simple2.tlcc" } // #line 47 "simple2.tlcc" } // For nested glocals 2 -> 0 }; static __sc_tests_simple2_tlcc1 _scopeobj1; #line 23 "simple2.tlcc" ::foo(_scopeobj1,"foo1"); #line 48 "simple2.tlcc" return 0; } #line 51 "simple2.tlcc"