From 3439602c2b356eaef3359b6496a0237f1af55e33 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 26 Oct 2017 21:41:41 -0400 Subject: - Added a new piece of compiler state, just for storing the current-module. --- stdlib/source/lux.lux | 76 +++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 36 deletions(-) (limited to 'stdlib/source/lux.lux') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 9509c7ad5..7aa9a96a6 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -710,6 +710,7 @@ ## {#info Info ## #source Source ## #cursor Cursor +## #current-module (Maybe Text) ## #modules (List [Text Module]) ## #scopes (List Scope) ## #type-context Type-Context @@ -725,32 +726,35 @@ Source (#Product ## "lux;cursor" Cursor - (#Product ## "lux;modules" - (#Apply (#Product Text Module) List) - (#Product ## "lux;scopes" - (#Apply Scope List) - (#Product ## "lux;type-context" - Type-Context - (#Product ## "lux;expected" - (#Apply Type Maybe) - (#Product ## "lux;seed" - Nat - (#Product ## scope-type-vars - (#Apply Nat List) - ## "lux;host" - Void)))))))))) + (#Product ## "lux;current-module" + (#Apply Text Maybe) + (#Product ## "lux;modules" + (#Apply (#Product Text Module) List) + (#Product ## "lux;scopes" + (#Apply Scope List) + (#Product ## "lux;type-context" + Type-Context + (#Product ## "lux;expected" + (#Apply Type Maybe) + (#Product ## "lux;seed" + Nat + (#Product ## scope-type-vars + (#Apply Nat List) + ## "lux;host" + Void))))))))))) (record$ (#Cons [(tag$ ["lux" "tags"]) (tuple$ (#Cons (text$ "info") (#Cons (text$ "source") (#Cons (text$ "cursor") - (#Cons (text$ "modules") - (#Cons (text$ "scopes") - (#Cons (text$ "type-context") - (#Cons (text$ "expected") - (#Cons (text$ "seed") - (#Cons (text$ "scope-type-vars") - (#Cons (text$ "host") - #Nil)))))))))))] + (#Cons (text$ "current-module") + (#Cons (text$ "modules") + (#Cons (text$ "scopes") + (#Cons (text$ "type-context") + (#Cons (text$ "expected") + (#Cons (text$ "seed") + (#Cons (text$ "scope-type-vars") + (#Cons (text$ "host") + #Nil))))))))))))] (#Cons [(tag$ ["lux" "doc"]) (text$ "Represents the state of the Lux compiler during a run. @@ -1807,7 +1811,7 @@ #Nil (-> Ident ($' Meta Ident)) (let' [[module name] ident - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} state] @@ -1970,12 +1974,12 @@ #Nil ($' Meta Text) ("lux case" state - {#info info #source source #modules modules + {#info info #source source #current-module current-module #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} - ("lux case" (reverse scopes) - (#Cons {#name (#;Cons module-name #Nil) #inner _ #locals _ #captured _} _) + ("lux case" current-module + (#;Some module-name) (#Right [state module-name]) _ @@ -2440,7 +2444,7 @@ (let' [[module name] ident] (function' [state] ("lux case" state - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor @@ -2698,12 +2702,12 @@ #Nil (-> Text ($' Meta Code)) ("lux case" state - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} - (#Right {#info info #source source #modules modules + (#Right {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed (n.+ +1 seed) #expected expected #cursor cursor @@ -3562,7 +3566,7 @@ (def: (find-module name) (-> Text (Meta Module)) (function [state] - (let [{#info info #source source #modules modules + (let [{#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} state] @@ -3625,7 +3629,7 @@ (def: get-expected-type (Meta Type) (function [state] - (let [{#info info #source source #modules modules + (let [{#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} state] @@ -4145,7 +4149,7 @@ (def: (exported-defs module state) (-> Text (Meta (List Text))) (let [modules (case state - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} @@ -4200,7 +4204,7 @@ (def: (find-in-env name state) (-> Text Compiler (Maybe Type)) (case state - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} @@ -4223,7 +4227,7 @@ (def: (find-def-type name state) (-> Ident Compiler (Maybe Type)) (let [[v-prefix v-name] name - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} state] @@ -4242,7 +4246,7 @@ (def: (find-def-value name state) (-> Ident (Meta [Type Top])) (let [[v-prefix v-name] name - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} state] @@ -5609,7 +5613,7 @@ (def: (get-scope-type-vars state) (Meta (List Nat)) (case state - {#info info #source source #modules modules + {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host #seed seed #expected expected #cursor cursor #scope-type-vars scope-type-vars} -- cgit v1.2.3