summaryrefslogtreecommitdiff
path: root/tnslc
diff options
context:
space:
mode:
authorCircleShift <kgunger12@gmail.com>2025-12-05 01:03:25 -0500
committerCircleShift <kgunger12@gmail.com>2025-12-05 01:03:25 -0500
commit5b81a4819a249921085f6596927f9939dffc46e7 (patch)
tree45699e5c2505512a951f29f099970d13dc8363d0 /tnslc
parentc4ece1f196c361f10515d1de41c1b23875769f54 (diff)
[tnslc] Fix pointer issue with find func
Diffstat (limited to 'tnslc')
-rw-r--r--tnslc/compile/module.tnsl21
-rw-r--r--tnslc/compile/struct.tnsl2
-rw-r--r--tnslc/compile/var.tnsl4
-rw-r--r--tnslc/test.tnsl22
4 files changed, 38 insertions, 11 deletions
diff --git a/tnslc/compile/module.tnsl b/tnslc/compile/module.tnsl
index 38653da..d2f1525 100644
--- a/tnslc/compile/module.tnsl
+++ b/tnslc/compile/module.tnsl
@@ -183,29 +183,34 @@ struct Module {
/; if ((lvl + 1) < key`.count)
~Module m
- ~uint8 str = key`.get(lvl)
+ ~~uint8 str = key`.get(lvl)
+ _printf("Trying to find sub '\0")
+ _printf(str`)
+ _printf("' in module '\0")
+ _printf(self.name)
+ _printf("'\n\0")
+
/; loop (int i = 0; i < self.subs.count) [i++]
m = self.subs.get(i)
- /; if (utils.strcmp(str, m`.name) == true)
+ /; if (utils.strcmp(str`, m`.name) == true)
~void v = m._find(stype, key, lvl + 1)
/; if (v != NULL)
return v
;/
- return NULL
;/
;/
;; else
- ~uint8 str = key`.get(key`.count - 1)
+ ~~uint8 str = key`.get(key`.count - 1)
~void out = NULL
/; if (stype == SEARCH_VAR)
- out = self._find_var(str)
+ out = self._find_var(str`)
;; else if (stype == SEARCH_STRUCT)
- out = self._find_struct(str)
+ out = self._find_struct(str`)
;; else if (stype == SEARCH_FUNC)
- out = self._find_func(str)
+ out = self._find_func(str`)
;; else if (stype == SEARCH_SUB)
- out = self._find_sub(str)
+ out = self._find_sub(str`)
;/
/; if (out !== NULL)
diff --git a/tnslc/compile/struct.tnsl b/tnslc/compile/struct.tnsl
index 7c18585..45f85d3 100644
--- a/tnslc/compile/struct.tnsl
+++ b/tnslc/compile/struct.tnsl
@@ -189,7 +189,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
diff --git a/tnslc/compile/var.tnsl b/tnslc/compile/var.tnsl
index c26d227..df62d66 100644
--- a/tnslc/compile/var.tnsl
+++ b/tnslc/compile/var.tnsl
@@ -190,8 +190,8 @@ struct Var {
;; else
t = _tn`.sub.get(idx)
/; if (t`._type == parse.NTYPE_ID)
- ~void str = t`.data
- strv.push(str)
+ ~uint8 str = t`.data
+ strv.push(~str)
;; else
running = false
;/
diff --git a/tnslc/test.tnsl b/tnslc/test.tnsl
index 6163318..fd29a23 100644
--- a/tnslc/test.tnsl
+++ b/tnslc/test.tnsl
@@ -1,5 +1,27 @@
+/; module Container
+ /; module m1
+ struct Box {
+ ~uint8 data
+ }
+ ;/
+
+ /; module m2
+ struct Crate {
+ {}m1.Box boxes
+ }
+ ;/
+
+;/
+
+struct Option {
+ bool has_crate,
+ Container.m2.Crate crate
+}
+
+
/; main (int argc, ~~uint8 argv) [int]
+
return 0
;/