summaryrefslogtreecommitdiff
path: root/tnslc/compile/scope.tnsl
diff options
context:
space:
mode:
authorKai Gunger <kgunger12@gmail.com>2026-04-29 02:21:38 -0400
committerKai Gunger <kgunger12@gmail.com>2026-04-29 02:21:38 -0400
commit84eb185812b70ec900ec8607bced68da440ae7a2 (patch)
treef337f2f2bd42fdbd4b5dcb382a5c449e7d4e3327 /tnslc/compile/scope.tnsl
parent3af75072c6226932f7dae48c6fc34c4177e42c18 (diff)
[tnslc] Basic statement comp
Diffstat (limited to 'tnslc/compile/scope.tnsl')
-rw-r--r--tnslc/compile/scope.tnsl34
1 files changed, 34 insertions, 0 deletions
diff --git a/tnslc/compile/scope.tnsl b/tnslc/compile/scope.tnsl
index a9cbef7..81f4f4b 100644
--- a/tnslc/compile/scope.tnsl
+++ b/tnslc/compile/scope.tnsl
@@ -288,6 +288,11 @@ struct Scope {
return out
;/
+ _printf("ERROR: Found variable \"\0")
+ _printf(name)
+ _printf("\" but it doesn't look like it's been initialized yet!\n\0")
+ _print_num(" Loc: %d\n\0", out`.loc)
+ _print_num(" Offset: %d\n\0", out`.offset)
return NULL
;/
@@ -330,6 +335,9 @@ struct Scope {
;/
/; mk_set_var (~Var src) [~Var]
+ _printf("Make setting \"\0")
+ _printf(src`.name)
+ _printf("\"\n\0")
~Var v = self.mk_var(src)
/; if (v == NULL)
@@ -417,6 +425,32 @@ struct Scope {
return false
;/
+ /; free_to (~Var tmp, bool code)
+ # TODO:DETERMINE HOW MANY TMPS
+ int tmps = 0
+ ~Var v
+ /; loop (int i - 1; i !> self.tmps.count) [i++]
+ v = self.tmps.get(self.tmps.count - i)
+ /; if (v`.offset == tmp`.offset)
+ tmps = self.tmps.count
+ tmps = tmps - i
+ tmps = tmps + 1
+ ;/
+ ;/
+
+ /; if (tmps !== 0)
+ self.free_tmp(tmps, code)
+ ;; else
+ ~uint8 scope_name = self.base_label()
+ int off = tmp`.offset
+ _printf("COMPILER ERROR: Unable to find temp to free to in scope \"\0")
+ _printf(scope_name)
+ _printf("\"\n\0")
+ _print_num(" Was looking for tmp with offset %d but could not find one.\n\0", off)
+ ;/
+
+ ;/
+
#
# Sub scope
#