diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2026-05-01 02:09:47 -0400 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2026-05-01 02:09:47 -0400 |
| commit | 1de32dbcac6a7a9756df034b914a4a836ca5bbac (patch) | |
| tree | 764736f8ac02ca41a0650fc45cdad02820742be9 /tnslc/compile/function.tnsl | |
| parent | edba04ae6266536cf7285570eb31245298a5123f (diff) | |
[tnslc] self in method
Diffstat (limited to 'tnslc/compile/function.tnsl')
| -rw-r--r-- | tnslc/compile/function.tnsl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tnslc/compile/function.tnsl b/tnslc/compile/function.tnsl index bde7d2c..f945479 100644 --- a/tnslc/compile/function.tnsl +++ b/tnslc/compile/function.tnsl @@ -25,6 +25,29 @@ struct Function { ~parse.Node n int reg = 1 int stack_up = 8 + + /; if (self.m == true) + ~Struct s = parent`.related_type() + Var p + p._init(s) + _delete(p.name) + p.name = utils.strcpy("self\0") + p.ptr_push(0) + p.loc = reg + reg++ + self.inputs.push(~p) + _printf("Generated self:\n\0") + p._print(0) + ;; else + _printf("Did not generate self for \"\0") + _printf(self.name) + _printf("\"\n\0") + ;/ + + /; if (dl == NULL) + return + ;/ + /; loop (int i = 0; i < dl`.sub.count) [i++] n = dl`.sub.get(i) /; if (n`._type == parse.NTYPE_TYPE) @@ -86,6 +109,9 @@ struct Function { /; _resolve_type (~Module parent) ~parse.Node _up = self._up /; if (_up`.sub.count < 1) + /; if (self.m == true) + self._resolve_dlist(parent, NULL) + ;/ return ;/ @@ -95,6 +121,8 @@ struct Function { /; if (_up`.sub.count > 1) lst = _up`.sub.get(1) ;/ + ;; else if (self.m == true) + self._resolve_dlist(parent, NULL) ;/ /; if (lst`._type == parse.NTYPE_TLIST) @@ -192,6 +220,12 @@ struct Function { ~Var in /; loop (int i = 0; i < self.inputs.count) [i++] in = self.inputs.get(i) + /; if (in.is_ref()) + ~int32 ptc = in.top_ptrc() + int32 set = 0 + set = set - 1 + ptc` = set + ;/ out.mk_set_var(in) ;/ |