diff options
| author | CircleShift <kgunger12@gmail.com> | 2025-12-05 01:58:03 -0500 |
|---|---|---|
| committer | CircleShift <kgunger12@gmail.com> | 2025-12-05 01:58:03 -0500 |
| commit | 062aefd6aa7cda6a30ae557f4813a2a967b49596 (patch) | |
| tree | d87bae11b5ccc8b5400744489da93dee9aac18c7 | |
| parent | 5b81a4819a249921085f6596927f9939dffc46e7 (diff) | |
[tnslc] Fix struct resolution
| -rw-r--r-- | tnslc/compile/module.tnsl | 2 | ||||
| -rw-r--r-- | tnslc/compile/struct.tnsl | 21 |
2 files changed, 13 insertions, 10 deletions
diff --git a/tnslc/compile/module.tnsl b/tnslc/compile/module.tnsl index d2f1525..99d42f1 100644 --- a/tnslc/compile/module.tnsl +++ b/tnslc/compile/module.tnsl @@ -188,7 +188,7 @@ struct Module { _printf(str`) _printf("' in module '\0") _printf(self.name) - _printf("'\n\0") + _print_num("' at level %d\n\0", lvl) /; loop (int i = 0; i < self.subs.count) [i++] diff --git a/tnslc/compile/struct.tnsl b/tnslc/compile/struct.tnsl index 45f85d3..780e8ad 100644 --- a/tnslc/compile/struct.tnsl +++ b/tnslc/compile/struct.tnsl @@ -149,13 +149,13 @@ struct Struct { return ;/ - /; if (ft`.size == 0) - # Recurse - ft`._compute_size(parent) - ;/ - /; if (ft`.size < 0) # Cyclical dependency + _printf("ERROR: Cyclic struct definition: '\0") + _printf(ft`.name) + _printf("' imported from '\0") + _printf(self.name) + _printf("'\n\0") return ;/ @@ -198,10 +198,13 @@ struct Struct { # Find struct and compute its size ~Struct out = parent`.find(SEARCH_STRUCT, ~sv) - sv.pop() - ~Module outp = parent - /; if (sv.count !== 0) - outp = parent`.find(SEARCH_SUB, ~sv) + /; if (out !== NULL && out`.size == 0) + sv.pop() + ~Module outp = parent + /; if (sv.count !== 0) + outp = parent`.find(SEARCH_SUB, ~sv) + ;/ + out`._compute_size(outp) ;/ sv.end() return out |