comparison clang/lib/Parse/ParseCbC.cpp @ 155:70c77e05b61e

write goto with environment with out logjmp basic idea
author anatofuz
date Wed, 11 Mar 2020 19:59:35 +0900
parents e8a9b4f4d755
children 5fe240291530
comparison
equal deleted inserted replaced
154:f7e988d3e4cc 155:70c77e05b61e
73 private: 73 private:
74 Token NextToken; 74 Token NextToken;
75 }; 75 };
76 } 76 }
77 77
78 /// goto with environment with out logjmp
79 /// basic idea is prepare struct containes pointer to return value variable and stack pointer
80 ///
81 /// int main() {
82 /// struct __CbC_return {
83 /// int* i;
84 /// void* sp;
85 // void* fp;
86 /// } ret;
87 // int i;
88 /// if (0) {
89 // _CBC_RETURN:
90 // %fp = ret.fp;
91 // %rsp = ret.sp;
92 // i = *(ret.i); //?
93 // return i;
94 // }
95 /// ret.i = &i;
96 /// ret.sp = %rsp;
97 // ret.fp = %rfp;
98 /// __code c(int i,void* env) = _CBC_RETURN;
99 /// goto f(c, &ret);
100 /// }
101 ///
102 /// __code ret(int, void* env) {
103 // sp = env;
104 // %rax = 1;
105 // jmp _CBC_RETURN;
106 /// }
107 ///
108 ///
78 109
79 /// Prepare__retForGotoWithTheEnvExpr - Prepare __CbC_return, code segment for returning and some necessary statements. 110 /// Prepare__retForGotoWithTheEnvExpr - Prepare __CbC_return, code segment for returning and some necessary statements.
80 /// It is called when the parser find __return and statements are put into complex statement. 111 /// It is called when the parser find __return and statements are put into complex statement.
81 /// 112 ///
82 /// examples which are created: 113 /// examples which are created: