From f4bc4570be7a51b00bf44d5bd4be99108dd94a30 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 6 Oct 2022 12:26:42 -0400 Subject: Libtnsl additions --- tnslc/compile/compile.tnsl | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'tnslc') diff --git a/tnslc/compile/compile.tnsl b/tnslc/compile/compile.tnsl index 0aade7b..a178d25 100644 --- a/tnslc/compile/compile.tnsl +++ b/tnslc/compile/compile.tnsl @@ -43,25 +43,23 @@ # Null type ;VType NT = {0, "null"} -/; find_var ({}charp name, ~VTrack tab) [{}charp] - /; loop (int i = 0; i < 8) [i++] +/; name_to_index ({}charp name, ~VTrack tab) [int] + /; loop (int i = 0; i < len tab`.sym_names) [i++] /; if (string_equate(tab`.sym_names{i}, name)) - ;{}charp out = "r" - ;{}charp n = string_from_int(i + 8) - ;add_strings(~out, ~n) - /; if (tab`.sym_sizes{i}._size == 4) - ;out.append('d') - ;; else if (tab`.sym_sizes{i}._size == 2) - ;out.append('w') - ;; else if (tab`.sym_sizes{i}._size == 1) - ;out.append('b') - ;/ - ;return out + ;return i ;/ ;/ ;tnsl.io.print("Failed to find vairable ") ;tnsl.io.println(name) + + ;return -1 +;/ + +/; index_to_loc (int index, ~VTrack tab) [{}charp] + ;{}charp out = "" + + ;/ /; token_is(~int cur, ~{}Token data, {}charp str) [bool] -- cgit v1.2.3