From b343dcdcb4e6b9297257dc066885aa530b8a04c1 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 12 Dec 2022 13:04:40 -0500 Subject: Fix path completion --- tnslc/compile/compile.tnsl | 33 ++++++++++++++++++++++++++------- tnslc/paths.tnsl | 5 +++-- 2 files changed, 29 insertions(+), 9 deletions(-) (limited to 'tnslc') diff --git a/tnslc/compile/compile.tnsl b/tnslc/compile/compile.tnsl index aefcbfe..677cf55 100644 --- a/tnslc/compile/compile.tnsl +++ b/tnslc/compile/compile.tnsl @@ -32,13 +32,26 @@ } /; method VType - /; get_sub_type({}charp name) [{}charp] + /; get_sub_type({}charp name) [VType] /; loop (int i = 0; i < len (self.sub_types)) [i = i + 2] /; if (string_equate(~name, ~(self.sub_types{i + 1}))) - ;return (self.sub_types{i}) + ;return vtype_by_name(self.sub_types{i}) ;/ ;/ - ;return "" + ;return NT + ;/ + + /; get_offset({}charp name) [int] + ;int out = 0 + /; loop (int i = 0; i < len (self.sub_types)) [i = i + 2] + /; if (string_equate(~name, ~(self.sub_types{i + 1}))) + ;return out + ;; else + ;VType tmp = vtype_by_name(self.sub_types{i}) + ;out = out + tmp.size + ;/ + ;/ + ;return -1 ;/ ;/ @@ -56,7 +69,7 @@ /; method VTrack # returns true if the value is allocated to the stack - /; add_track({}charp name, VType _type) [bool] + /; add_track({}charp name, VType _type) [int] ;bool to_stack = is_struct(_type) ;int count = 0 @@ -72,7 +85,13 @@ ;self.sym_names.append(name) ;self.sym_types.append(_type) - ;self.on_stack.append() + ;self.on_stack.append(to_stack) + + /; if (count > 7) + ;return -1 + ;/ + + ;return count ;/ # Returns true if the variable is being tracked @@ -514,8 +533,8 @@ ;cur`++ /; loop (data`{cur`}.token_type == TOKEN_TYPE.DEFWORD) - ;tab`.sym_types.append(def_t) - ;tab`.sym_names.append(data`{cur`}.data`) + ;int stack = tab`.add_track() + /; if (token_is(cur, data, ",")) ;cur`++ ;; else if (token_is(cur, data, "=")) diff --git a/tnslc/paths.tnsl b/tnslc/paths.tnsl index c85da11..1e8c705 100644 --- a/tnslc/paths.tnsl +++ b/tnslc/paths.tnsl @@ -58,16 +58,17 @@ ;return out ;/ -/; join ({}{}charp s, charp j) [{}charp] +/; join ({}{}charp s, charp jc) [{}charp] ;{}charp out = "" /; loop (int i = 0; i < len s) [i++] /; loop (int j = 0; j < len s{i}) [j++] ;out.append(s{i}{j}) ;/ /; if (i < len s - 1) - ;out.append(j) + ;out.append(jc) ;/ ;/ + ;return out ;/ -- cgit v1.2.3