summaryrefslogtreecommitdiff
path: root/tnslc
diff options
context:
space:
mode:
authorKai Gunger <kgunger12@gmail.com>2025-12-07 23:20:45 -0500
committerKai Gunger <kgunger12@gmail.com>2025-12-07 23:20:45 -0500
commit8bb2e3bdb00341dcd8b6fd4d272b2c96a708acb3 (patch)
treef58c966d4d5e5eaafdd5b149add4c68bbae9733f /tnslc
parentdb29085af649f8a42958898aaf2c3bfcef67f385 (diff)
fix module step 1 name resolution
Diffstat (limited to 'tnslc')
-rw-r--r--tnslc/compile/codegen.tnsl58
-rw-r--r--tnslc/compile/module.tnsl6
-rw-r--r--tnslc/compile/struct.tnsl2
3 files changed, 27 insertions, 39 deletions
diff --git a/tnslc/compile/codegen.tnsl b/tnslc/compile/codegen.tnsl
index 867d00d..ef668c7 100644
--- a/tnslc/compile/codegen.tnsl
+++ b/tnslc/compile/codegen.tnsl
@@ -37,57 +37,45 @@
ast.end()
;/
-/; _gen_prim(int size, ~uint8 id) [Struct]
+/; _gen_prim(~Module m, int size, ~uint8 id)
+ ~Module mds = m`._create_methods(id)
+ mds`.parent = m
+
Var t
+
Struct s
s.size = size
- s.methods = NULL
+ s.methods = mds
s.members.init(len t)
s.name = utils.strcpy(id)
s._up = NULL
- return s
+
+ m`.structs.push(~s)
;/
/; _gen_prims (~Module m)
- Struct s
-
# One byte prims
- s = _gen_prim(1, "bool\0")
- m`.structs.push(~s)
- s = _gen_prim(1, "uint8\0")
- m`.structs.push(~s)
- s = _gen_prim(1, "int8\0")
- m`.structs.push(~s)
+ _gen_prim(m, 1, "bool\0")
+ _gen_prim(m, 1, "uint8\0")
+ _gen_prim(m, 1, "int8\0")
# Two byte prims
- s = _gen_prim(2, "uint16\0")
- m`.structs.push(~s)
- s = _gen_prim(2, "int16\0")
- m`.structs.push(~s)
+ _gen_prim(m, 2, "uint16\0")
+ _gen_prim(m, 2, "int16\0")
# Four byte prims
- s = _gen_prim(4, "uint32\0")
- m`.structs.push(~s)
- s = _gen_prim(4, "int32\0")
- m`.structs.push(~s)
- s = _gen_prim(4, "float32\0")
- m`.structs.push(~s)
+ _gen_prim(m, 4, "uint32\0")
+ _gen_prim(m, 4, "int32\0")
+ _gen_prim(m, 4, "float32\0")
# Eight byte prims
- s = _gen_prim(8, "uint64\0")
- m`.structs.push(~s)
- s = _gen_prim(8, "int64\0")
- m`.structs.push(~s)
- s = _gen_prim(8, "float64\0")
- m`.structs.push(~s)
- s = _gen_prim(8, "uint\0")
- m`.structs.push(~s)
- s = _gen_prim(8, "int\0")
- m`.structs.push(~s)
- s = _gen_prim(8, "float\0")
- m`.structs.push(~s)
- s = _gen_prim(8, "void\0")
- m`.structs.push(~s)
+ _gen_prim(m, 8, "uint64\0")
+ _gen_prim(m, 8, "int64\0")
+ _gen_prim(m, 8, "float64\0")
+ _gen_prim(m, 8, "uint\0")
+ _gen_prim(m, 8, "int\0")
+ _gen_prim(m, 8, "float\0")
+ _gen_prim(m, 8, "void\0")
;/
diff --git a/tnslc/compile/module.tnsl b/tnslc/compile/module.tnsl
index 8e1fedc..eb7ce47 100644
--- a/tnslc/compile/module.tnsl
+++ b/tnslc/compile/module.tnsl
@@ -92,7 +92,7 @@ struct Module {
m.init(sub, buf)
self.subs.push(~m)
;; else if (sub`._type == parse.NTYPE_STRUCT)
- ~Module m = self._create_methods(sub)
+ ~Module m = self._create_methods(sub`.data)
Struct s
s.init(sub)
s.methods = m
@@ -146,7 +146,7 @@ struct Module {
/; loop (int i = 0; i < self.structs.count) [i++]
s = self.structs.get(i)
/; if (s`.size == 0)
- s`._compute_size(~self)
+ s`._compute_size()
;/
;/
@@ -179,7 +179,7 @@ struct Module {
~Function f
/; loop (int i = 0; i < self.funcs.count) [i++]
f = self.funcs.get(i)
- f`._compile(~self, cb)
+ # f`._compile(~self, cb)
;/
~Module m
diff --git a/tnslc/compile/struct.tnsl b/tnslc/compile/struct.tnsl
index 24f14cf..fd1f6e0 100644
--- a/tnslc/compile/struct.tnsl
+++ b/tnslc/compile/struct.tnsl
@@ -137,7 +137,7 @@ struct Struct {
tn = n
# Find type, compute size, set add_size to type size
- ~Struct ft = self._find_type(self.methods, n)
+ ~Struct ft = self._find_type(n)
/; if (ft == NULL)
# Type not found