diff options
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 # |