diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2026-01-01 23:23:12 -0500 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2026-01-01 23:23:12 -0500 |
| commit | 4289c90cc90a9798091a741c3e18861b47836402 (patch) | |
| tree | a390a28f251c19648d7b7a44ae22d554181e8a98 /tnslc/compile/scope.tnsl | |
| parent | 8682fb7aad90f053375937fe391a65e7e269e2c1 (diff) | |
poor implementation of tmp vars + returns i guess
Diffstat (limited to 'tnslc/compile/scope.tnsl')
| -rw-r--r-- | tnslc/compile/scope.tnsl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tnslc/compile/scope.tnsl b/tnslc/compile/scope.tnsl index 62bbf68..b199abe 100644 --- a/tnslc/compile/scope.tnsl +++ b/tnslc/compile/scope.tnsl @@ -5,7 +5,7 @@ struct Scope { ~Scope parent, - utils.Vector vars, + utils.Vector vars, tmps, int unique } @@ -47,6 +47,7 @@ struct Scope { Var v self.vars.init(len v) + self.tmps.init(len v) ;/ /; end @@ -58,6 +59,12 @@ struct Scope { v`.end() ;/ self.vars.end() + + /; loop (int i = 0; i < self.tmps.count) [i++] + v = self.tmps.get(i) + v`.end() + ;/ + self.tmps.end() ;/ # @@ -236,6 +243,18 @@ struct Scope { return v ;/ + # Make a temp variable in register or stack for use in computations + /; mk_tmp (~Var base) [Var] + Var v = base`.copy() + return v + ;/ + + # Free n tmp variables (starts from most recently created) + # If you want to generate code to set the stack pointer then + # set code to true + /; free_tmp (int tmps, bool code) + ;/ + # # Sub scope # |