diff options
author | Eduardo Julian | 2021-09-08 17:25:20 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-09-08 17:25:20 -0400 |
commit | 18e4294819f5d4adafad091bdc5a30c25959ad2f (patch) | |
tree | b241acb7e32620731eed20a0d86e8b35ca3c5ada /lux-bootstrapper | |
parent | 392582885500d8201bbe502943ca4b02c5c77ac0 (diff) |
No more annotations.
Diffstat (limited to 'lux-bootstrapper')
-rw-r--r-- | lux-bootstrapper/src/lux/analyser.clj | 18 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/analyser/lux.clj | 31 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/analyser/module.clj | 26 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/analyser/proc/common.clj | 2 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/base.clj | 4 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/compiler/cache.clj | 13 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/compiler/core.clj | 6 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/compiler/jvm/lux.clj | 14 |
8 files changed, 50 insertions, 64 deletions
diff --git a/lux-bootstrapper/src/lux/analyser.clj b/lux-bootstrapper/src/lux/analyser.clj index 297ad5482..5ebda9c6e 100644 --- a/lux-bootstrapper/src/lux/analyser.clj +++ b/lux-bootstrapper/src/lux/analyser.clj @@ -123,12 +123,11 @@ "lux def" (|let [(&/$Item [_ (&/$Identifier "" ?name)] (&/$Item ?value - (&/$Item ?meta - (&/$Item exported? - (&/$End))) + (&/$Item exported? + (&/$End)) )) parameters] (&/with-location location - (&&lux/analyse-def analyse optimize eval! compile-def ?name ?value ?meta exported?))) + (&&lux/analyse-def analyse optimize eval! compile-def ?name ?value exported?))) "lux def alias" (|let [(&/$Item [_ (&/$Identifier "" ?alias)] @@ -141,18 +140,17 @@ "lux def type tagged" (|let [(&/$Item [_ (&/$Identifier "" ?name)] (&/$Item ?value - (&/$Item ?meta - (&/$Item ?labels - (&/$Item exported? - (&/$End)))) + (&/$Item ?labels + (&/$Item exported? + (&/$End))) )) parameters] (&/with-location location (|case ?labels [_ (&/$Form ?tags)] - (&&lux/analyse-def-type-tagged analyse optimize eval! compile-def ?name ?value ?meta false ?tags exported?) + (&&lux/analyse-def-type-tagged analyse optimize eval! compile-def ?name ?value false ?tags exported?) [_ (&/$Tuple ?slots)] - (&&lux/analyse-def-type-tagged analyse optimize eval! compile-def ?name ?value ?meta true ?slots exported?)))) + (&&lux/analyse-def-type-tagged analyse optimize eval! compile-def ?name ?value true ?slots exported?)))) "lux def program" (|let [(&/$Item ?program (&/$End)) parameters] diff --git a/lux-bootstrapper/src/lux/analyser/lux.clj b/lux-bootstrapper/src/lux/analyser/lux.clj index 77d54fab2..7bd83f931 100644 --- a/lux-bootstrapper/src/lux/analyser/lux.clj +++ b/lux-bootstrapper/src/lux/analyser/lux.clj @@ -266,7 +266,7 @@ (analyse-tuple analyse (&/$Right exo-type) ?elems)))) (defn ^:private analyse-global [analyse exo-type module name] - (|do [[[r-module r-name] [exported? endo-type ?annotations ?value]] (&&module/find-def module name) + (|do [[[r-module r-name] [exported? endo-type ?value]] (&&module/find-def module name) ;; This is a small shortcut to optimize analysis of typing code. _ (if (and (&type/type= &type/Type endo-type) (&type/type= &type/Type exo-type)) @@ -381,7 +381,7 @@ (defn analyse-apply [analyse location exo-type macro-caller =fn ?args] (|case =fn [_ (&&/$def ?module ?name)] - (|do [[real-name [exported? ?type ?annotations ?value]] (&&module/find-def! ?module ?name)] + (|do [[real-name [exported? ?type ?value]] (&&module/find-def! ?module ?name)] (if (&type/type= &type/Macro ?type) (|do [macro-expansion (fn [state] (|case (macro-caller ?value ?args state) @@ -406,7 +406,8 @@ ) (defn analyse-case [analyse exo-type ?value ?branches] - (|do [_ (&/assert! (> (&/|length ?branches) 0) "[Analyser Error] Cannot have empty branches in \"case\" expression.") + (|do [_ (&/assert! (> (&/|length ?branches) 0) + "[Analyser Error] Cannot have empty branches in \"case\" expression.") =value (&&/analyse-1+ analyse ?value) :let [var?? (|case =value [_ (&&/$var =var-kind)] @@ -548,10 +549,11 @@ (|do [[[real-module real-name] _] (&&module/find-def module-name local-name) :let [wanted-name (str module-name &/+name-separator+ local-name) source-name (str real-module &/+name-separator+ real-name)]] - (&/assert! false (str "[Analyser Error] Cannot re-define " wanted-name - (if (= wanted-name source-name) - "" - (str "\nThis is an alias for " source-name))))) + (&/assert! false + (str "[Analyser Error] Cannot re-define " wanted-name + (if (= wanted-name source-name) + "" + (str "\nThis is an alias for " source-name))))) (return &/$End)))) (defn eval [analyse optimize eval! type code] @@ -559,7 +561,7 @@ (&&/analyse-1 analyse type code))] (eval! (optimize analysis)))) -(defn analyse-def* [analyse optimize eval! compile-def ?name ?value ?annotations exported? type? & [?expected-type]] +(defn analyse-def* [analyse optimize eval! compile-def ?name ?value exported? type? & [?expected-type]] (|do [_ &/ensure-directive module-name &/get-module-name _ (ensure-undefined! module-name ?name) @@ -570,19 +572,18 @@ (&&/analyse-1 analyse ?expected-type ?value)) (&&/analyse-1+ analyse ?value)))) ==exported? (eval analyse optimize eval! &type/Bit exported?) - ==annotations (eval analyse optimize eval! &type/Code ?annotations) - def-value (compile-def ?name (optimize =value) ==annotations ==exported? type?) + def-value (compile-def ?name (optimize =value) ==exported? type?) _ &type/reset-mappings :let [def-type (&&/expr-type* =value) _ (println 'DEF (str module-name &/+name-separator+ ?name " : " (&type/show-type def-type)))]] (return (&/T [module-name def-type def-value ==exported?])))) -(defn analyse-def [analyse optimize eval! compile-def ?name ?value ?annotations exported?] - (|do [_ (analyse-def* analyse optimize eval! compile-def ?name ?value ?annotations exported? &/$None)] +(defn analyse-def [analyse optimize eval! compile-def ?name ?value exported?] + (|do [_ (analyse-def* analyse optimize eval! compile-def ?name ?value exported? &/$None)] (return &/$End))) -(defn analyse-def-type-tagged [analyse optimize eval! compile-def ?name ?value ?annotations record? labels* exported?] +(defn analyse-def-type-tagged [analyse optimize eval! compile-def ?name ?value record? labels* exported?] (|do [labels (&/map% (fn [tag*] (|case tag* [_ (&/$Text tag)] @@ -591,7 +592,7 @@ _ (&/fail-with-loc "[Analyser Error] Incorrect format for labels."))) labels*) - _ (analyse-def* analyse optimize eval! compile-def ?name ?value ?annotations exported? (&/$Some (&/T [record? labels])) &type/Type)] + _ (analyse-def* analyse optimize eval! compile-def ?name ?value exported? (&/$Some (&/T [record? labels])) &type/Type)] (return &/$End))) (defn analyse-def-alias [?alias ?original] @@ -676,7 +677,7 @@ (&/without-repl (&/save-module (|do [_ (&/assert! (not (= current-module path)) - (&/fail-with-loc (str "[Analyser Error] Module cannot import itself: " path))) + (str "[Analyser Error] Module cannot import itself: " path)) active? (&&module/active-module? path) ;; TODO: Enrich this error-message ;; to explicitly show the cyclic dependency. diff --git a/lux-bootstrapper/src/lux/analyser/module.clj b/lux-bootstrapper/src/lux/analyser/module.clj index 1904e55b7..0013a9173 100644 --- a/lux-bootstrapper/src/lux/analyser/module.clj +++ b/lux-bootstrapper/src/lux/analyser/module.clj @@ -115,7 +115,7 @@ ((&/fail-with-loc (str "[Analyser Error] Cannot create a new global definition outside of a global environment: " (str module &/+name-separator+ name))) state)))) -(defn define [module name exported? def-type def-meta def-value] +(defn define [module name exported? def-type def-value] (fn [state] (|case (&/get$ &/$scopes state) (&/$Item ?env (&/$End)) @@ -125,7 +125,7 @@ (&/|update module (fn [m] (&/update$ $defs - #(&/|put name (&/$DefinitionG (&/T [exported? def-type def-meta def-value])) %) + #(&/|put name (&/$DefinitionG (&/T [exported? def-type def-value])) %) m)) ms)))) nil) @@ -144,11 +144,10 @@ (&/$AliasG [o-module o-name]) ((type-def o-module o-name) state) - (&/$DefinitionG [exported? ?type ?meta ?value]) + (&/$DefinitionG [exported? ?type ?value]) (if (&type/type= &type/Type ?type) (return* state (&/T [exported? ?value])) - ((&/fail-with-loc (str "[Analyser Error] Not a type: " (&/ident->text (&/T [module name])) - "\nMETA: " (&/show-ast ?meta))) + ((&/fail-with-loc (str "[Analyser Error] Not a type: " (&/ident->text (&/T [module name])))) state)) (&/$TypeG [exported? ?value labels]) @@ -209,11 +208,6 @@ (&/get$ $imports) (&/|any? (partial = imported-module-name)))) -(def empty_annotations - (let [dummy_location (&/T ["" 0 0])] - (&/T [dummy_location - (&/$Record &/$End)]))) - (defn find-def! [module name] (|do [current-module &/get-module-name] (fn [state] @@ -229,7 +223,7 @@ (&/$TypeG [exported? ?value labels]) (return* state (&/T [(&/T [module name]) - (&/T [exported? &type/Type empty_annotations ?value])])) + (&/T [exported? &type/Type ?value])])) (&/$TagG _) ((&/fail-with-loc (str "[Analyser Error] Not a definition: " (&/ident->text (&/T [module name])))) @@ -259,13 +253,13 @@ " at module: " current-module)) state)) - (&/$DefinitionG [exported? ?type ?meta ?value]) + (&/$DefinitionG [exported? ?type ?value]) (if (or (.equals ^Object current-module module) (and exported? (or (.equals ^Object module &/prelude) (imports? state module current-module)))) (return* state (&/T [(&/T [module name]) - (&/T [exported? ?type ?meta ?value])])) + (&/T [exported? ?type ?value])])) ((&/fail-with-loc (str "[Analyser Error @ find-def] Cannot use private definition: " (str module &/+name-separator+ name) " at module: " current-module)) state)) @@ -276,7 +270,7 @@ (or (.equals ^Object module &/prelude) (imports? state module current-module)))) (return* state (&/T [(&/T [module name]) - (&/T [exported? &type/Type empty_annotations ?value])])) + (&/T [exported? &type/Type ?value])])) ((&/fail-with-loc (str "[Analyser Error @ find-def] Cannot use private definition: " (str module &/+name-separator+ name) " at module: " current-module)) state)) @@ -452,10 +446,10 @@ (define_tag module (str "#" label-name) was-exported? type label-names index))) (&/enumerate label-names)))))) -(defn define-type [module name exported? def-meta def-value record? labels] +(defn define-type [module name exported? def-value record? labels] (|case labels (&/$End) - (define module name exported? &type/Type def-meta def-value) + (define module name exported? &type/Type def-value) (&/$Item labelH labelT) (|do [_ (declare-labels module record? labels exported? def-value)] diff --git a/lux-bootstrapper/src/lux/analyser/proc/common.clj b/lux-bootstrapper/src/lux/analyser/proc/common.clj index 2d4c0d27e..6b96be2ce 100644 --- a/lux-bootstrapper/src/lux/analyser/proc/common.clj +++ b/lux-bootstrapper/src/lux/analyser/proc/common.clj @@ -32,7 +32,7 @@ (defn- analyse-lux-macro [analyse exo-type ?values] (|do [:let [(&/$Item macro (&/$End)) ?values] - [_real-name [_exported? _def-type _meta macro-type]] (&&module/find-def! &/prelude "Macro'") + [_real-name [_exported? _def-type macro-type]] (&&module/find-def! &/prelude "Macro'") [[=macro*-type =location] =macro] (&&/analyse-1 analyse macro-type macro) _ (&type/check exo-type &type/Macro)] (return (&/|list (&&/|meta exo-type =location diff --git a/lux-bootstrapper/src/lux/base.clj b/lux-bootstrapper/src/lux/base.clj index 911884769..513462d20 100644 --- a/lux-bootstrapper/src/lux/base.clj +++ b/lux-bootstrapper/src/lux/base.clj @@ -600,11 +600,11 @@ (|let [[file line col] meta] (str "@ " file "," line "," col "\n" msg)))) -(defn fail-with-loc [msg] +(defn fail-with-loc [^String msg] (fn [state] (fail* (add-loc (get$ $location state) msg)))) -(defn assert! [test message] +(defn assert! [test ^String message] (if test (return unit-tag) (fail-with-loc message))) diff --git a/lux-bootstrapper/src/lux/compiler/cache.clj b/lux-bootstrapper/src/lux/compiler/cache.clj index 6d1e5602d..b336ba6f0 100644 --- a/lux-bootstrapper/src/lux/compiler/cache.clj +++ b/lux-bootstrapper/src/lux/compiler/cache.clj @@ -11,8 +11,7 @@ [module :as &a-module]) (lux.compiler [core :as &&core] [io :as &&io]) - (lux.compiler.cache [type :as &&&type] - [ann :as &&&ann])) + (lux.compiler.cache [type :as &&&type])) (:import (java.io File) )) @@ -75,20 +74,16 @@ (defn make-identifier [ident] (&/T [(&/T ["" 0 0]) (&/$Identifier ident)])) -(defn make-record [kvs] - (&/T [(&/T ["" 0 0]) (&/$Record kvs)])) - (defn ^:private process-def-entry [load-def-value module ^String _def-entry] (let [parts (.split _def-entry &&core/datum-separator)] (case (first parts) "A" (let [[_ _name ^String _alias] parts [__module __name] (.split _alias &/+name-separator+)] (&a-module/define-alias module _name (&/T [__module __name]))) - "D" (let [[_ _name _exported? _type _anns] parts - [def-anns _] (&&&ann/deserialize _anns) + "D" (let [[_ _name _exported? _type] parts [def-type _] (&&&type/deserialize-type _type)] (|do [def-value (load-def-value module _name)] - (&a-module/define module _name (= "1" _exported?) def-type def-anns def-value))) + (&a-module/define module _name (= "1" _exported?) def-type def-value))) ":" (let [[_ _name _exported? _record? _head _tail] parts labels (&/$Item _head (if _tail (&/->list (seq (.split _tail "\\."))) @@ -96,7 +91,7 @@ (|do [def-value (load-def-value module _name)] (&a-module/define-type module _name - (= "1" _exported?) (make-record &/$End) + (= "1" _exported?) def-value (= "1" _record?) labels))) ;; "T" (let [[_ _name _exported? _type _index _group] parts ;; [_type _] (&&&type/deserialize-type _type) diff --git a/lux-bootstrapper/src/lux/compiler/core.clj b/lux-bootstrapper/src/lux/compiler/core.clj index 3dbd93140..5ba14e3ed 100644 --- a/lux-bootstrapper/src/lux/compiler/core.clj +++ b/lux-bootstrapper/src/lux/compiler/core.clj @@ -7,8 +7,7 @@ (lux [base :as & :refer [|case |let |do return* return fail*]]) (lux.analyser [base :as &a] [module :as &a-module]) - (lux.compiler.cache [type :as &&&type] - [ann :as &&&ann])) + (lux.compiler.cache [type :as &&&type])) (:import (java.io File BufferedOutputStream FileOutputStream))) @@ -56,12 +55,11 @@ ;; Next entry-separator def-entries) - (&/$DefinitionG [exported? ?def-type ?def-anns ?def-value]) + (&/$DefinitionG [exported? ?def-type ?def-value]) (str "D" datum-separator ?name datum-separator (if exported? "1" "0") datum-separator (&&&type/serialize-type ?def-type) - datum-separator (&&&ann/serialize ?def-anns) ;; Next entry-separator def-entries) diff --git a/lux-bootstrapper/src/lux/compiler/jvm/lux.clj b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj index 336f46998..279fd119a 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm/lux.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj @@ -119,7 +119,7 @@ (defn compile-apply [compile ?fn ?args] (|case ?fn [_ (&o/$def ?module ?name)] - (|do [[_ [_ _ _ func-obj]] (&a-module/find-def! ?module ?name) + (|do [[_ [_ _ func-obj]] (&a-module/find-def! ?module ?name) class-loader &/loader :let [func-class (class func-obj) func-arity (.get ^Field (.getDeclaredField func-class &&/arity-field) nil) @@ -252,7 +252,7 @@ (str base "\n\n" "Caused by: " (throwable->text cause)) base))) -(defn ^:private install-def! [class-loader current-class module-name ?name ?body ?meta exported? type?] +(defn ^:private install-def! [class-loader current-class module-name ?name ?body exported? type?] (|do [_ (return nil) :let [def-class (&&/load-class! class-loader (&host-generics/->class-name current-class)) def-type (&a/expr-type* ?body)] @@ -264,15 +264,15 @@ _ (&/without-repl-closure (|case type? (&/$Some [record? labels]) - (&a-module/define-type module-name ?name exported? ?meta def-value record? labels) + (&a-module/define-type module-name ?name exported? def-value record? labels) (&/$None) - (&a-module/define module-name ?name exported? def-type ?meta def-value)))] + (&a-module/define module-name ?name exported? def-type def-value)))] (return def-value))) (let [class-flags (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_SUPER) field-flags (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC)] - (defn compile-def [compile ?name ?body ?meta exported? type?] + (defn compile-def [compile ?name ?body exported? type?] (|do [module-name &/get-module-name class-loader &/loader] (|case (de-ann ?body) @@ -303,7 +303,7 @@ (return nil))) :let [_ (.visitEnd =class)] _ (&&/save-class! def-name (.toByteArray =class)) - def-value (install-def! class-loader current-class module-name ?name ?body ?meta exported? type?)] + def-value (install-def! class-loader current-class module-name ?name ?body exported? type?)] (return def-value))) _ @@ -329,7 +329,7 @@ (return nil))) :let [_ (.visitEnd =class)] _ (&&/save-class! def-name (.toByteArray =class)) - def-value (install-def! class-loader current-class module-name ?name ?body ?meta exported? type?)] + def-value (install-def! class-loader current-class module-name ?name ?body exported? type?)] (return def-value)))))) (defn compile-program [compile ?program] |