// Very simple code to understand how tlcc works // and test the new reference system #include #include #include using namespace std; #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 22 "refer1.tlcc" static void f (int &refval, int val, const char *title,vector &tb) { using glocaltype0 = decltype(refval); using glocaltype1 = decltype(val); using glocaltype2 = decltype(title); using glocaltype3 = decltype(tb); #line 30 "refer1.tlcc" struct __gl_tests_refer1_tlcc_GLOCAL1_1{ __gl_tests_refer1_tlcc_GLOCAL1_1(glocaltype0 &refval,glocaltype1 &val,glocaltype2 &title,glocaltype3 &tb) : refval(refval) ,val(val) ,title(title) ,tb(tb) {} glocaltype0 &refval; glocaltype1 &val; glocaltype2 &title; #line 28 "refer1.tlcc" int a; glocaltype3 &tb; }; { // Inserted to support nested glocals __gl_tests_refer1_tlcc_GLOCAL1_1 B_glocal(refval,val,title,tb); #line 28 "refer1.tlcc" B_glocal.a=1; #line 30 "refer1.tlcc" class __sc_tests_refer1_tlcc1: public _F_foo{ public: __gl_tests_refer1_tlcc_GLOCAL1_1 &glocal; __sc_tests_refer1_tlcc1 (__gl_tests_refer1_tlcc_GLOCAL1_1 &g) : glocal(g) { } _F_foo_func1( ) { #line 31 "refer1.tlcc" printf ("This is func1 glocal.a=%d\n",glocal.a); glocal.tb.push_back("func1"); } // #line 34 "refer1.tlcc" _F_foo_func2( ) { #line 35 "refer1.tlcc" printf ("This is func2, val=%d title=%s\n",glocal.val,glocal.title); glocal.tb.push_back("func2"); glocal.refval++; } // #line 39 "refer1.tlcc" }; __sc_tests_refer1_tlcc1 _scopeobj1(B_glocal); #line 30 "refer1.tlcc" ::foo(_scopeobj1); #line 40 "refer1.tlcc" } } // For nested glocals 1 -> 0 #line 42 "refer1.tlcc" int main () { vector tb; int val=10; f (val,1,"this is the title",tb); printf ("val=%d\n",val); for (auto const &s:tb) printf ("tb[]=%s\n",s.c_str()); return 0; }