diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2025-12-01 01:13:09 -0500 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2025-12-01 01:13:09 -0500 |
| commit | 82d11944094349e7c4795659dac45fea954223e2 (patch) | |
| tree | 4ab2091ee633d5d40bbc7383a4638dff81fccebc /tnslc/compile/struct.tnsl | |
| parent | 46e23fa81f651961b2388c95e9569d2d39c3cffb (diff) | |
initial struct sizing
Diffstat (limited to 'tnslc/compile/struct.tnsl')
| -rw-r--r-- | tnslc/compile/struct.tnsl | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/tnslc/compile/struct.tnsl b/tnslc/compile/struct.tnsl index 5403553..4b1ccfb 100644 --- a/tnslc/compile/struct.tnsl +++ b/tnslc/compile/struct.tnsl @@ -62,6 +62,30 @@ struct Struct { self.members.init(len v) ;/ + /; _print (int idt) + _indent(idt) + _printf("{ Struct : \0") + _printf(self.name) + _printf("\n\0") + + _indent(idt) + _printf(" size:\0") + _print_num("%d\0", self.size) + _printf("\n\0") + + _indent(idt) + _printf(" members:\n\0") + + ~Var v + /; loop (int i = 0; i < self.members.count) [i++] + v = self.members.get(i) + v._print(idt + 1) + ;/ + + _indent(idt) + _printf("}\n\0") + ;/ + /; add_member(~Var v) self.members.push(v) ;/ @@ -145,7 +169,7 @@ struct Struct { utils.Vector sv sv.init(8) - ~void str + ~uint8 str ~parse.Node n bool seen_id = false @@ -153,7 +177,7 @@ struct Struct { n = tn`.sub.get(i) /; if (n`._type == parse.NTYPE_ID) str = n`.data - sv.push(~str) + sv.push(str) seen_id = true ;; else if (seen_id == true) i = tn`.sub.count @@ -161,11 +185,11 @@ struct Struct { ;/ # Find struct and compute its size - ~Struct out = parent.find(SEARCH_STRUCT, ~sv) + ~Struct out = parent`.find(SEARCH_STRUCT, ~sv) sv.pop() ~Module outp = parent /; if (sv.count !== 0) - outp = parent.find(SEARCH_SUB, ~sv) + outp = parent`.find(SEARCH_SUB, ~sv) ;/ sv.end() return out |