aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/lang/scope.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/lang/scope.lux')
-rw-r--r--stdlib/source/lux/lang/scope.lux19
1 files changed, 17 insertions, 2 deletions
diff --git a/stdlib/source/lux/lang/scope.lux b/stdlib/source/lux/lang/scope.lux
index 45008ae24..1995338f4 100644
--- a/stdlib/source/lux/lang/scope.lux
+++ b/stdlib/source/lux/lang/scope.lux
@@ -9,7 +9,7 @@
(coll [list "list/" Functor<List> Fold<List> Monoid<List>]
(dictionary [plist])))
[macro])
- (// [analysis #+ Variable]))
+ (// [analysis #+ Variable Register]))
(type: Locals (Bindings Text [Type Nat]))
(type: Foreign (Bindings Text [Type Variable]))
@@ -163,7 +163,7 @@
))
(def: #export next-local
- (Meta Nat)
+ (Meta Register)
(function (_ compiler)
(case (get@ #.scopes compiler)
#.Nil
@@ -171,3 +171,18 @@
(#.Cons top _)
(#e.Success [compiler (get@ [#.locals #.counter] top)]))))
+
+(def: (ref-to-variable ref)
+ (-> Ref Variable)
+ (case ref
+ (#.Local register)
+ (#analysis.Local register)
+
+ (#.Captured register)
+ (#analysis.Foreign register)))
+
+(def: #export (environment scope)
+ (-> Scope (List Variable))
+ (|> scope
+ (get@ [#.captured #.mappings])
+ (list/map (function (_ [_ [_ ref]]) (ref-to-variable ref)))))