summaryrefslogtreecommitdiff
path: root/tnslc
diff options
context:
space:
mode:
authorCircleShift <kgunger12@gmail.com>2025-12-28 02:15:10 -0500
committerCircleShift <kgunger12@gmail.com>2025-12-28 02:15:10 -0500
commit053876f61cc07c0d4a57b7b64a85e6b5fc23509a (patch)
tree291cdf2ec1bce296aa2cff06c6ea9b002d74bec3 /tnslc
parent75c5c7ccdf258d1f4731b02b6291ce55a04ea709 (diff)
mk_aware from node
Diffstat (limited to 'tnslc')
-rw-r--r--tnslc/compile/scope.tnsl37
1 files changed, 37 insertions, 0 deletions
diff --git a/tnslc/compile/scope.tnsl b/tnslc/compile/scope.tnsl
index b4fd4f3..4b36932 100644
--- a/tnslc/compile/scope.tnsl
+++ b/tnslc/compile/scope.tnsl
@@ -109,6 +109,7 @@ struct Scope {
Var mk = v`.copy()
mk.offset = 0
+ # TODO: Make sure this works properly
/; if (mk.loc > 0)
mk.loc = 1
;/
@@ -117,6 +118,42 @@ struct Scope {
;/
/; mk_aware_node (~parse.Node n)
+
+ ~parse.Node sub
+ ~parse.Node tp = NULL
+ /; loop (int i = 0; i < n`.sub.count) [i++]
+ sub = n`.sub.get(i)
+ /; if (n`._type == parse.NTYPE_TYPE)
+ tp = n
+ ;; else if (n`._type == parse.NTYPE_ID)
+ /; if (tp == NULL)
+ _printf("COMPILER ERROR: Should have type node before first id in decl node\n\0")
+ return
+ ;/
+
+ # Part 1: Add var
+ Var v
+ v.init(tp, n`.data)
+
+ # TODO: Make sure this works properly
+ /; if (v.regable() == true)
+ v.loc = 0 - 1
+ ;; else
+ v.loc = 1
+ ;/
+ v.offset = 0
+
+ self.vars.push(~v)
+
+ # Part 2: Compute via value (if exists)
+ /; if (n`.sub.count > 0)
+ n = n`.sub.get(0)
+ /; if (n`._type == parse.NTYPE_VALUE)
+ self.precheck_stmt(n)
+ ;/
+ ;/
+ ;/
+ ;/
;/
/; precheck_stmt (~parse.Node n)