aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r--stdlib/source/lux.lux43
1 files changed, 29 insertions, 14 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 1632e6eab..fe9958d56 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -351,11 +351,25 @@
(#Cons [["lux" "type-args"] (#ListA (#Cons (#TextA "m") (#Cons (#TextA "v") #;Nil)))]
default-def-meta-exported))))
+## (type: #export Ref
+## (#Local Nat)
+## (#Captured Nat))
+(_lux_def Ref
+ (#NamedT ["lux" "Ref"]
+ (#SumT ## Local
+ Nat
+ ## Captured
+ Nat))
+ (#Cons [["lux" "tags"] (#ListA (#Cons (#TextA "Local")
+ (#Cons (#TextA "Captured")
+ #Nil)))]
+ default-def-meta-exported))
+
## (type: Scope
## {#name (List Text)
## #inner Nat
-## #locals (Bindings Text Void)
-## #captured (Bindings Text Void)})
+## #locals (Bindings Text [Type Nat])
+## #captured (Bindings Text [Type Ref])})
(_lux_def Scope
(#NamedT ["lux" "Scope"]
(#ProdT ## name
@@ -363,9 +377,9 @@
(#ProdT ## inner
Nat
(#ProdT ## locals
- (#AppT (#AppT Bindings Text) Void)
+ (#AppT (#AppT Bindings Text) (#ProdT Type Nat))
## captured
- (#AppT (#AppT Bindings Text) Void)))))
+ (#AppT (#AppT Bindings Text) (#ProdT Type Ref))))))
(#Cons [["lux" "tags"] (#ListA (#Cons (#TextA "name")
(#Cons (#TextA "inner")
(#Cons (#TextA "locals")
@@ -4130,16 +4144,17 @@
(find (: (-> Scope (Maybe Type))
(function [env]
(case env
- {#name _ #inner _ #locals {#counter _ #mappings locals} #captured {#counter _ #mappings closure}}
- (try-both (find (: (-> [Text Void] (Maybe Type))
- (function [[bname analysis]]
- (let [[[type _] _] (:! (Meta [Type Cursor] Void)
- analysis)]
- (if (Text/= name bname)
- (#Some type)
- #None)))))
- locals
- closure))))
+ {#name _
+ #inner _
+ #locals {#counter _ #mappings locals}
+ #captured {#counter _ #mappings closure}}
+ (try-both (find (: (-> [Text [Type Top]] (Maybe Type))
+ (function [[bname [type _]]]
+ (if (Text/= name bname)
+ (#Some type)
+ #None))))
+ (: (List [Text [Type Top]]) locals)
+ (: (List [Text [Type Top]]) closure)))))
scopes)))
(def: (find-def-type name state)