From d6c48ae6a8b58f5974133170863a31c70f0123d1 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 14 Jul 2021 13:59:02 -0400 Subject: Normalized the hierarchy of the standard library modules. --- lux-bootstrapper/src/lux/analyser/base.clj | 2 +- lux-bootstrapper/src/lux/base.clj | 5 +-- lux-bootstrapper/src/lux/compiler/jvm.clj | 4 +-- lux-bootstrapper/src/lux/compiler/jvm/base.clj | 8 +++-- lux-bootstrapper/src/lux/compiler/jvm/case.clj | 16 ++++----- lux-bootstrapper/src/lux/compiler/jvm/lux.clj | 13 +++---- .../src/lux/compiler/jvm/proc/common.clj | 13 +++---- lux-bootstrapper/src/lux/compiler/jvm/rt.clj | 28 +++++++++------ lux-bootstrapper/src/lux/host.clj | 13 ++++++- lux-bootstrapper/src/lux/repl.clj | 2 +- lux-bootstrapper/src/lux/type.clj | 42 +++++++++++----------- lux-bootstrapper/src/lux/type/host.clj | 2 +- 12 files changed, 87 insertions(+), 61 deletions(-) (limited to 'lux-bootstrapper') diff --git a/lux-bootstrapper/src/lux/analyser/base.clj b/lux-bootstrapper/src/lux/analyser/base.clj index d6787280f..e5f47f977 100644 --- a/lux-bootstrapper/src/lux/analyser/base.clj +++ b/lux-bootstrapper/src/lux/analyser/base.clj @@ -77,7 +77,7 @@ (let [tag-names #{"Primitive" "Sum" "Product" "Function" "Parameter" "Var" "Ex" "UnivQ" "ExQ" "Apply" "Named"}] (defn type-tag? [module name] - (and (= "lux" module) + (and (= &/prelude module) (contains? tag-names name)))) (defn |meta [type location analysis] diff --git a/lux-bootstrapper/src/lux/base.clj b/lux-bootstrapper/src/lux/base.clj index 5ef710a03..648b3341c 100644 --- a/lux-bootstrapper/src/lux/base.clj +++ b/lux-bootstrapper/src/lux/base.clj @@ -5,7 +5,7 @@ clojure.core.match.array)) (def prelude - "lux") + "library/lux") (def !log! (atom false)) (defn flag-prn! [& args] @@ -13,7 +13,8 @@ (apply prn args))) ;; [Tags] -(def unit-tag (.intern "")) +(def unit-tag + (.intern "")) (defn T [elems] (case (count elems) diff --git a/lux-bootstrapper/src/lux/compiler/jvm.clj b/lux-bootstrapper/src/lux/compiler/jvm.clj index bacf2cb9c..e2521fec7 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm.clj @@ -188,7 +188,7 @@ (.visit &host/bytecode-version (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER) module-class-name nil "java/lang/Object" nil) (.visitSource file-name nil))] - _ (if (= "lux" name) + _ (if (= &/prelude name) (|do [_ &&rt/compile-Function-class _ &&rt/compile-LuxRT-class] (return nil)) @@ -242,7 +242,7 @@ &&jvm-cache/load-def-value &&jvm-cache/install-all-defs-in-module &&jvm-cache/uninstall-all-defs-in-module) - _ (compile-module source-dirs "lux")] + _ (compile-module source-dirs &/prelude)] (compile-module source-dirs program-module))] (|case (m-action (&/init-state "{old}" mode (jvm-host))) (&/$Right ?state _) diff --git a/lux-bootstrapper/src/lux/compiler/jvm/base.clj b/lux-bootstrapper/src/lux/compiler/jvm/base.clj index b5e520de5..47566a626 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/base.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/base.clj @@ -21,8 +21,12 @@ (java.lang.reflect Field))) ;; [Constants] -(def ^:const ^String function-class "lux/Function") -(def ^:const ^String lux-utils-class "lux/LuxRT") +(def ^:const ^String function-class + (&host/internal &host/function-class)) + +(def ^:const ^String lux-utils-class + (&host/internal &host/lux-utils-class)) + (def ^:const ^String unit-tag-field "unit_tag") ;; Formats diff --git a/lux-bootstrapper/src/lux/compiler/jvm/case.clj b/lux-bootstrapper/src/lux/compiler/jvm/case.clj index b7cdb7571..8a41db0b3 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/case.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/case.clj @@ -114,21 +114,21 @@ #(doto ^MethodVisitor % (.visitInsn Opcodes/AALOAD)) #(doto ^MethodVisitor % - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "tuple_left" "([Ljava/lang/Object;I)Ljava/lang/Object;")))] + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "tuple_left" "([Ljava/lang/Object;I)Ljava/lang/Object;")))] (doto writer stack-peek (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") (.visitLdcInsn (int lefts)) accessI - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;"))) + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;"))) (&o/$TuplePM (&/$Right _idx)) (doto writer stack-peek (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") (.visitLdcInsn (int (dec _idx))) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "tuple_right" "([Ljava/lang/Object;I)Ljava/lang/Object;") - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")) + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "tuple_right" "([Ljava/lang/Object;I)Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")) (&o/$VariantPM _idx+) (|let [$success (new Label) @@ -147,7 +147,7 @@ (.visitLdcInsn writer "") (.visitInsn writer Opcodes/ACONST_NULL))] (doto writer - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_get" "([Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "sum_get" "([Ljava/lang/Object;ILjava/lang/Object;)Ljava/lang/Object;") (.visitInsn Opcodes/DUP) (.visitJumpInsn Opcodes/IFNULL $fail) (.visitJumpInsn Opcodes/GOTO $success) @@ -155,7 +155,7 @@ (.visitInsn Opcodes/POP) (.visitJumpInsn Opcodes/GOTO $else) (.visitLabel $success) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;"))) + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;"))) (&o/$SeqPM _left-pm _right-pm) (doto writer @@ -178,7 +178,7 @@ (compile-pattern* bodies 1 $else pm) (.visitLabel $else) (.visitInsn Opcodes/POP) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_fail" "()V") + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "pm_fail" "()V") (.visitInsn Opcodes/ACONST_NULL) (.visitJumpInsn Opcodes/GOTO $end)))) @@ -200,7 +200,7 @@ (.visitInsn Opcodes/ACONST_NULL))] _ (compile ?value) :let [_ (doto *writer* - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")) + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "pm_stack_push" "([Ljava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")) _ (compile-pattern *writer* bodies-labels ?pm $end)] _ (compile-bodies *writer* compile bodies-labels ?bodies $end) :let [_ (.visitLabel *writer* $end)]] diff --git a/lux-bootstrapper/src/lux/compiler/jvm/lux.clj b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj index 515bd8db5..f5fa88e02 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/lux.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj @@ -15,7 +15,8 @@ (lux.analyser [base :as &a] [module :as &a-module]) (lux.compiler.jvm [base :as &&] - [function :as &&function])) + [function :as &&function] + [rt :as &rt])) (:import (org.objectweb.asm Opcodes Label ClassWriter @@ -79,7 +80,7 @@ (.visitLdcInsn *writer* "") (.visitInsn *writer* Opcodes/ACONST_NULL))] _ (compile value) - :let [_ (.visitMethodInsn *writer* Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")]] + :let [_ (.visitMethodInsn *writer* Opcodes/INVOKESTATIC &rt/rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")]] (return nil))) (defn compile-local [compile ?idx] @@ -120,7 +121,7 @@ class-loader &/loader :let [func-class (class func-obj) func-arity (.get ^Field (.getDeclaredField func-class &&/arity-field) nil) - func-partials (.get ^Field (.getDeclaredField (Class/forName "lux.Function" true class-loader) &&/partials-field) func-obj) + func-partials (.get ^Field (.getDeclaredField (Class/forName &host/function-class true class-loader) &&/partials-field) func-obj) num-args (&/|length ?args) func-class-name (->> func-class .getName &host-generics/->bytecode-class-name)]] (if (and (= 0 func-partials) @@ -208,7 +209,7 @@ (.visitLdcInsn (int (if tail? (dec idx) idx))) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class (if tail? "tuple_right" "tuple_left") "([Ljava/lang/Object;I)Ljava/lang/Object;")))) _path)]] @@ -339,7 +340,7 @@ (.visitLdcInsn (->> #'&/$Nil meta ::&/idx int)) ;; I (.visitInsn Opcodes/ACONST_NULL) ;; I? (.visitLdcInsn &/unit-tag) ;; I?U - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") ;; V + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") ;; V ;; Tail: End ;; Size: Begin (.visitVarInsn Opcodes/ALOAD 0) ;; VA @@ -379,7 +380,7 @@ (.visitLdcInsn "") ;; I2I? (.visitInsn Opcodes/DUP2_X1) ;; II?2I? (.visitInsn Opcodes/POP2) ;; II?2 - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") ;; IV + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") ;; IV ;; Cons: End (.visitInsn Opcodes/SWAP) ;; VI (.visitJumpInsn Opcodes/GOTO $loop) diff --git a/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj b/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj index f21557e88..cd1b77dee 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj @@ -14,7 +14,8 @@ [lux.type.host :as &host-type] [lux.host.generics :as &host-generics] [lux.analyser.base :as &a] - [lux.compiler.jvm.base :as &&]) + (lux.compiler.jvm [base :as &&] + [rt :as &rt])) (:import (org.objectweb.asm Opcodes Label ClassWriter @@ -81,8 +82,8 @@ ^MethodVisitor *writer* &/get-writer _ (compile ?op) :let [_ (doto *writer* - (.visitTypeInsn Opcodes/CHECKCAST "lux/Function") - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "runTry" "(Llux/Function;)[Ljava/lang/Object;"))]] + (.visitTypeInsn Opcodes/CHECKCAST &rt/function-class) + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "runTry" (str "(L" &rt/function-class ";)[Ljava/lang/Object;")))]] (return nil))) (do-template [ ] @@ -160,7 +161,7 @@ _ (compile ?input) :let [_ (doto *writer* (.visitTypeInsn Opcodes/CHECKCAST "java/lang/String") - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "decode_frac" "(Ljava/lang/String;)[Ljava/lang/Object;"))]] + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "decode_frac" "(Ljava/lang/String;)[Ljava/lang/Object;"))]] (return nil))) (defn ^:private compile-int-char [compile ?values special-args] @@ -276,11 +277,11 @@ (.visitJumpInsn Opcodes/IF_ICMPEQ $not-found) (.visitInsn Opcodes/I2L) &&/wrap-long - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;") (.visitJumpInsn Opcodes/GOTO $end) (.visitLabel $not-found) (.visitInsn Opcodes/POP) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_none" "()[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC &rt/rt-class "make_none" "()[Ljava/lang/Object;") (.visitLabel $end))]] (return nil))) diff --git a/lux-bootstrapper/src/lux/compiler/jvm/rt.clj b/lux-bootstrapper/src/lux/compiler/jvm/rt.clj index 7fabd27ed..73812ef8f 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/rt.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/rt.clj @@ -21,6 +21,12 @@ MethodVisitor AnnotationVisitor))) +(def ^:const ^String rt-class + &&/lux-utils-class) + +(def ^:const ^String function-class + &&/function-class) + ;; [Utils] (def init-method "") @@ -63,7 +69,7 @@ (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd)))))]] - (&&/save-class! (second (string/split &&/function-class #"/")) + (&&/save-class! (-> &&/function-class (string/split #"/") (nth 2)) (.toByteArray (doto =class .visitEnd))))) (defmacro [& instructions] @@ -170,7 +176,7 @@ super-nested ( super-nested-tag ;; super-tag !variant <>last? ;; super-tag, super-last !variant <>value ;; super-tag, super-last, super-value - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")) + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;")) update-!variant ( !variant <>value (.visitTypeInsn Opcodes/CHECKCAST "[Ljava/lang/Object;") @@ -249,11 +255,11 @@ (.visitVarInsn Opcodes/ALOAD 0) (.visitMethodInsn Opcodes/INVOKESTATIC ) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;") (.visitInsn Opcodes/ARETURN) (.visitLabel $to) (.visitLabel $handler) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_none" "()[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "make_none" "()[Ljava/lang/Object;") (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd))) @@ -335,7 +341,7 @@ (.visitLdcInsn (->> #'&/$None meta ::&/idx int)) ;; I (.visitInsn Opcodes/ACONST_NULL) ;; I? (.visitLdcInsn &/unit-tag) ;; I?U - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd)) @@ -344,7 +350,7 @@ (.visitLdcInsn (->> #'&/$Some meta ::&/idx int)) ;; I (.visitLdcInsn "") ;; I? (.visitVarInsn Opcodes/ALOAD 0) ;; I?O - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd)) @@ -377,14 +383,14 @@ (.visitMethodInsn Opcodes/INVOKESPECIAL "java/io/PrintWriter" "" "(Ljava/io/Writer;Z)V") ;; P ))] - (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "runTry" "(Llux/Function;)[Ljava/lang/Object;" nil nil) + (doto (.visitMethod =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_STATIC) "runTry" (str "(L" function-class ";)[Ljava/lang/Object;") nil nil) (.visitCode) (.visitTryCatchBlock $from $to $handler "java/lang/Throwable") (.visitLabel $from) (.visitVarInsn Opcodes/ALOAD 0) (.visitInsn Opcodes/ACONST_NULL) - (.visitMethodInsn Opcodes/INVOKEVIRTUAL "lux/Function" &&/apply-method (&&/apply-signature 1)) - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKEVIRTUAL function-class &&/apply-method (&&/apply-signature 1)) + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "make_some" "(Ljava/lang/Object;)[Ljava/lang/Object;") (.visitInsn Opcodes/ARETURN) (.visitLabel $to) (.visitLabel $handler) ;; T @@ -397,7 +403,7 @@ (.visitLdcInsn (->> #'&/$Left meta ::&/idx int)) ;; SI (.visitInsn Opcodes/ACONST_NULL) ;; SI? swap2x1 ;; I?S - (.visitMethodInsn Opcodes/INVOKESTATIC "lux/LuxRT" "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") + (.visitMethodInsn Opcodes/INVOKESTATIC rt-class "sum_make" "(ILjava/lang/Object;Ljava/lang/Object;)[Ljava/lang/Object;") (.visitInsn Opcodes/ARETURN) (.visitMaxs 0 0) (.visitEnd))) @@ -406,5 +412,5 @@ (compile-LuxRT-adt-methods) (compile-LuxRT-int-methods) (compile-LuxRT-frac-methods))]] - (&&/save-class! (second (string/split &&/lux-utils-class #"/")) + (&&/save-class! (-> &&/lux-utils-class (string/split #"/") (nth 2)) (.toByteArray (doto =class .visitEnd))))) diff --git a/lux-bootstrapper/src/lux/host.clj b/lux-bootstrapper/src/lux/host.clj index 4da818db2..eb1bcb41c 100644 --- a/lux-bootstrapper/src/lux/host.clj +++ b/lux-bootstrapper/src/lux/host.clj @@ -15,12 +15,23 @@ MethodVisitor))) ;; [Constants] -(def function-class "lux.Function") (def module-separator "/") (def class-name-separator ".") (def class-separator "/") (def bytecode-version Opcodes/V1_6) +(defn ^String external [^String internal] + (.replace internal class-separator class-name-separator)) + +(defn ^String internal [^String external] + (.replace external class-name-separator class-separator)) + +(def ^:const ^String function-class + (str (external &/prelude) class-name-separator "Function")) + +(def ^:const ^String lux-utils-class + (str (external &/prelude) class-name-separator "LuxRT")) + ;; [Resources] (defn ^String ->module-class [old] old) diff --git a/lux-bootstrapper/src/lux/repl.clj b/lux-bootstrapper/src/lux/repl.clj index d980ac9ec..ff5c108c5 100644 --- a/lux-bootstrapper/src/lux/repl.clj +++ b/lux-bootstrapper/src/lux/repl.clj @@ -21,7 +21,7 @@ (defn ^:private init [source-dirs] (do (&compiler/init!) - (|case ((|do [_ (&compiler/compile-module source-dirs "lux") + (|case ((|do [_ (&compiler/compile-module source-dirs &/prelude) _ (&cache/delete repl-module) _ (&module/create-module repl-module 0) _ (fn [?state] diff --git a/lux-bootstrapper/src/lux/type.clj b/lux-bootstrapper/src/lux/type.clj index 8853224b5..267b6d67b 100644 --- a/lux-bootstrapper/src/lux/type.clj +++ b/lux-bootstrapper/src/lux/type.clj @@ -25,41 +25,43 @@ (def empty-env &/$Nil) -(def I64 (&/$Named (&/T ["lux" "I64"]) +(def I64 (&/$Named (&/T [&/prelude "I64"]) (&/$UnivQ empty-env (&/$Primitive "#I64" (&/|list (&/$Parameter 1)))))) (def Nat* (&/$Primitive &&host/nat-data-tag &/$Nil)) (def Rev* (&/$Primitive &&host/rev-data-tag &/$Nil)) (def Int* (&/$Primitive &&host/int-data-tag &/$Nil)) -(def Bit (&/$Named (&/T ["lux" "Bit"]) (&/$Primitive "#Bit" &/$Nil))) -(def Nat (&/$Named (&/T ["lux" "Nat"]) (&/$Apply Nat* I64))) -(def Rev (&/$Named (&/T ["lux" "Rev"]) (&/$Apply Rev* I64))) -(def Int (&/$Named (&/T ["lux" "Int"]) (&/$Apply Int* I64))) -(def Frac (&/$Named (&/T ["lux" "Frac"]) (&/$Primitive "#Frac" &/$Nil))) -(def Text (&/$Named (&/T ["lux" "Text"]) (&/$Primitive "#Text" &/$Nil))) -(def Ident (&/$Named (&/T ["lux" "Ident"]) (&/$Product Text Text))) +(def Bit (&/$Named (&/T [&/prelude "Bit"]) (&/$Primitive "#Bit" &/$Nil))) +(def Nat (&/$Named (&/T [&/prelude "Nat"]) (&/$Apply Nat* I64))) +(def Rev (&/$Named (&/T [&/prelude "Rev"]) (&/$Apply Rev* I64))) +(def Int (&/$Named (&/T [&/prelude "Int"]) (&/$Apply Int* I64))) +(def Frac (&/$Named (&/T [&/prelude "Frac"]) (&/$Primitive "#Frac" &/$Nil))) +(def Text (&/$Named (&/T [&/prelude "Text"]) (&/$Primitive "#Text" &/$Nil))) +(def Ident (&/$Named (&/T [&/prelude "Ident"]) (&/$Product Text Text))) (defn Array [elemT] (&/$Primitive "#Array" (&/|list elemT))) (def Nothing - (&/$Named (&/T ["lux" "Nothing"]) + (&/$Named (&/T [&/prelude "Nothing"]) (&/$UnivQ empty-env (&/$Parameter 1)))) (def Any - (&/$Named (&/T ["lux" "Any"]) + (&/$Named (&/T [&/prelude "Any"]) (&/$ExQ empty-env (&/$Parameter 1)))) (def IO - (&/$Named (&/T ["lux/control/io" "IO"]) + (&/$Named (&/T [(str &/prelude "/control/io") "IO"]) (&/$UnivQ empty-env - (&/$Primitive "lux/type/abstract.Abstraction lux/control/io.IO" (&/|list (&/$Parameter 1)))))) + (&/$Primitive (str &/prelude "/type/abstract.Abstraction " + &/prelude "/control/io.IO") + (&/|list (&/$Parameter 1)))))) (def List - (&/$Named (&/T ["lux" "List"]) + (&/$Named (&/T [&/prelude "List"]) (&/$UnivQ empty-env (&/$Sum ;; lux;Nil @@ -70,7 +72,7 @@ (&/$Parameter 0))))))) (def Maybe - (&/$Named (&/T ["lux" "Maybe"]) + (&/$Named (&/T [&/prelude "Maybe"]) (&/$UnivQ empty-env (&/$Sum ;; lux;None @@ -80,7 +82,7 @@ ))) (def Type - (&/$Named (&/T ["lux" "Type"]) + (&/$Named (&/T [&/prelude "Type"]) (let [Type (&/$Apply (&/$Parameter 1) (&/$Parameter 0)) TypeList (&/$Apply Type List) TypePair (&/$Product Type Type)] @@ -121,18 +123,18 @@ ))))) (def Location - (&/$Named (&/T ["lux" "Location"]) + (&/$Named (&/T [&/prelude "Location"]) (&/$Product Text (&/$Product Nat Nat)))) (def Meta - (&/$Named (&/T ["lux" "Meta"]) + (&/$Named (&/T [&/prelude "Meta"]) (&/$UnivQ empty-env (&/$UnivQ empty-env (&/$Product (&/$Parameter 3) (&/$Parameter 1)))))) (def Code* - (&/$Named (&/T ["lux" "Code'"]) + (&/$Named (&/T [&/prelude "Code'"]) (let [Code (&/$Apply (&/$Apply (&/$Parameter 1) (&/$Parameter 0)) (&/$Parameter 1)) @@ -164,12 +166,12 @@ )))) (def Code - (&/$Named (&/T ["lux" "Code"]) + (&/$Named (&/T [&/prelude "Code"]) (let [w (&/$Apply Location Meta)] (&/$Apply (&/$Apply w Code*) w)))) (def Macro - (&/$Named (&/T ["lux" "Macro"]) + (&/$Named (&/T [&/prelude "Macro"]) (&/$Primitive "#Macro" &/$Nil))) (defn bound? [id] diff --git a/lux-bootstrapper/src/lux/type/host.clj b/lux-bootstrapper/src/lux/type/host.clj index 36e969046..dbf780a84 100644 --- a/lux-bootstrapper/src/lux/type/host.clj +++ b/lux-bootstrapper/src/lux/type/host.clj @@ -59,7 +59,7 @@ output))) (def ^:private Any - (&/$Named (&/T ["lux" "Any"]) + (&/$Named (&/T [&/prelude "Any"]) (&/$ExQ (&/|list) (&/$Parameter 1)))) -- cgit v1.2.3