diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lux/analyser/module.clj | 2 | ||||
-rw-r--r-- | src/lux/base.clj | 7 | ||||
-rw-r--r-- | src/lux/type.clj | 207 |
3 files changed, 14 insertions, 202 deletions
diff --git a/src/lux/analyser/module.clj b/src/lux/analyser/module.clj index deb6be69e..63ba9b741 100644 --- a/src/lux/analyser/module.clj +++ b/src/lux/analyser/module.clj @@ -62,6 +62,8 @@ (defn define [module name def-data type] ;; (prn 'define module name (aget def-data 0) (&type/show-type type)) (fn [state] + (when (and (= "Macro" name) (= "lux" module)) + (&type/set-macro-type! (aget def-data 1))) (|case (&/get$ &/$envs state) (&/$Cons ?env (&/$Nil)) (return* (->> state diff --git a/src/lux/base.clj b/src/lux/base.clj index 0e164f5d2..e57cb0957 100644 --- a/src/lux/base.clj +++ b/src/lux/base.clj @@ -600,6 +600,13 @@ (do (prn 'memory-class-loader/store class-name (keys @store)) (throw (IllegalStateException. (str "[Class Loader] Unknown class: " class-name))))))))) + +;; (deftype Host +;; (& #writer (^ org.objectweb.asm.ClassWriter) +;; #loader (^ java.net.URLClassLoader) +;; #classes (^ clojure.lang.Atom) +;; #catching (List Text) +;; #module-states (List (, Text ModuleState)))) (defn host [_] (let [store (atom {})] (T ;; "lux;writer" diff --git a/src/lux/type.clj b/src/lux/type.clj index d6275651e..bc28dbde0 100644 --- a/src/lux/type.clj +++ b/src/lux/type.clj @@ -114,208 +114,11 @@ ))) $Void)))) -(def Bindings - (Named$ (&/T "lux" "Bindings") - (Univ$ empty-env - (Univ$ empty-env - (Tuple$ (&/|list - ;; "lux;counter" - Int - ;; "lux;mappings" - (App$ List - (Tuple$ (&/|list (Bound$ 2) - (Bound$ 0)))))))))) - -(def Env - (Named$ (&/T "lux" "Env") - (let [bindings (App$ (App$ Bindings (Bound$ 2)) - (Bound$ 0))] - (Univ$ empty-env - (Univ$ empty-env - (Tuple$ - (&/|list - ;; "lux;name" - Text - ;; "lux;inner-closures" - Int - ;; "lux;locals" - bindings - ;; "lux;closure" - bindings - ))))))) - -(def Cursor - (Named$ (&/T "lux" "Cursor") - (Tuple$ (&/|list Text Int Int)))) - -(def Meta - (Named$ (&/T "lux" "Meta") - (Univ$ empty-env - (Univ$ empty-env - (Tuple$ (&/|list (Bound$ 2) - (Bound$ 0))))))) - -(def AST* - (Named$ (&/T "lux" "AST'") - (let [AST* (App$ (Bound$ 0) - (App$ (Bound$ 1) - (Bound$ 0))) - AST*List (App$ List AST*)] - (Univ$ empty-env - (Variant$ (&/|list - ;; &/$BoolS - Bool - ;; &/$IntS - Int - ;; &/$RealS - Real - ;; &/$CharS - Char - ;; &/$TextS - Text - ;; &/$SymbolS - Ident - ;; &/$TagS - Ident - ;; &/$FormS - AST*List - ;; &/$TupleS - AST*List - ;; &/$RecordS - (App$ List (Tuple$ (&/|list AST* AST*)))) - ))))) - -(def AST - (Named$ (&/T "lux" "AST") - (let [w (App$ Meta Cursor)] - (App$ w (App$ AST* w))))) - -(def ^:private ASTList (App$ List AST)) - -(def Either - (Named$ (&/T "lux" "Either") - (Univ$ empty-env - (Univ$ empty-env - (Variant$ (&/|list - ;; &/$Left - (Bound$ 2) - ;; &/$Right - (Bound$ 0))))))) - -(def StateE - (Univ$ empty-env - (Univ$ empty-env - (Lambda$ (Bound$ 2) - (App$ (App$ Either Text) - (Tuple$ (&/|list (Bound$ 2) - (Bound$ 0)))))))) - -(def Source - (Named$ (&/T "lux" "Source") - (App$ List - (App$ (App$ Meta Cursor) - Text)))) - -(def Host - (Named$ (&/T "lux" "Host") - (Tuple$ - (&/|list - ;; "lux;writer" - (Data$ "org.objectweb.asm.ClassWriter" &/Nil$) - ;; "lux;loader" - (Data$ "java.lang.ClassLoader" &/Nil$) - ;; "lux;classes" - (Data$ "clojure.lang.Atom" &/Nil$) - ;; "lux;catching" - (App$ List Text) - )))) - -(def DefData* - (Univ$ empty-env - (Variant$ (&/|list - ;; "lux;ValueD" - (Tuple$ (&/|list Type Unit)) - ;; "lux;TypeD" - Type - ;; "lux;MacroD" - (Bound$ 0) - ;; "lux;AliasD" - Ident - )))) - -(def LuxVar - (Named$ (&/T "lux" "LuxVar") - (Variant$ (&/|list - ;; "lux;Local" - Int - ;; "lux;Global" - Ident)))) - -(def $Module - (Univ$ empty-env - (Tuple$ - (&/|list - ;; "lux;module-aliases" - (App$ List (Tuple$ (&/|list Text Text))) - ;; "lux;defs" - (App$ List - (Tuple$ (&/|list Text - (Tuple$ (&/|list Bool - (App$ DefData* - (Lambda$ ASTList - (App$ (App$ StateE (Bound$ 0)) - ASTList)))))))) - ;; "lux;imports" - (App$ List Text) - ;; "lux;tags" - ;; (List (, Text (, Int (List Ident) Type))) - (App$ List - (Tuple$ (&/|list Text - (Tuple$ (&/|list Int - (App$ List Ident) - Type))))) - ;; "lux;types" - ;; (List (, Text (, (List Ident) Type))) - (App$ List - (Tuple$ (&/|list Text - (Tuple$ (&/|list (App$ List Ident) - Type))))) - )))) - -(def $Compiler - (Named$ (&/T "lux" "Compiler") - (App$ (Univ$ empty-env - (Tuple$ - (&/|list - ;; "lux;source" - Source - ;; "lux;cursor" - Cursor - ;; "lux;modules" - (App$ List (Tuple$ (&/|list Text - (App$ $Module (App$ (Bound$ 1) (Bound$ 0)))))) - ;; "lux;envs" - (App$ List - (App$ (App$ Env Text) - (Tuple$ (&/|list LuxVar Type)))) - ;; "lux;types" - (App$ (App$ Bindings Int) Type) - ;; "lux;expected" - Type - ;; "lux;seed" - Int - ;; "lux;eval?" - Bool - ;; "lux;host" - Host - ))) - $Void))) - -(def Macro - (Named$ (&/T "lux" "Macro") - (Lambda$ ASTList - (App$ (App$ StateE $Compiler) - ASTList)))) +(def Macro) + +(defn set-macro-type! [type] + (def Macro type) + nil) (defn bound? [id] (fn [state] |