From 697707d8560a5735be38fd9b1ff91a02c289d48f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 16 Apr 2019 20:53:41 -0400 Subject: Made some new-luxc modules "old". --- .../source/luxc/lang/translation/jvm/common.lux | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 new-luxc/source/luxc/lang/translation/jvm/common.lux (limited to 'new-luxc/source/luxc/lang/translation/jvm/common.lux') diff --git a/new-luxc/source/luxc/lang/translation/jvm/common.lux b/new-luxc/source/luxc/lang/translation/jvm/common.lux new file mode 100644 index 000000000..ea6665dc5 --- /dev/null +++ b/new-luxc/source/luxc/lang/translation/jvm/common.lux @@ -0,0 +1,72 @@ +(.module: + [lux #* + [abstract + [monad (#+ do)]] + [control + ["ex" exception (#+ exception:)] + ["." io]] + [data + ["." error (#+ Error)] + ["." text ("#/." hash) + format] + [collection + ["." dictionary (#+ Dictionary)]]] + ["." macro] + [host (#+ import:)] + [world + [binary (#+ Binary)]] + [tool + [compiler + [reference (#+ Register)] + ["." name] + ["." phase]]]] + ## [luxc + ## [lang + ## [host + ## ["." jvm + ## [type]]]]] + ) + +## (def: #export (with-artifacts action) +## (All [a] (-> (Meta a) (Meta [Artifacts a]))) +## (function (_ state) +## (case (action (update@ #.host +## (|>> (:coerce Host) +## (set@ #artifacts (dictionary.new text.hash)) +## (:coerce Nothing)) +## state)) +## (#error.Success [state' output]) +## (#error.Success [(update@ #.host +## (|>> (:coerce Host) +## (set@ #artifacts (|> (get@ #.host state) (:coerce Host) (get@ #artifacts))) +## (:coerce Nothing)) +## state') +## [(|> state' (get@ #.host) (:coerce Host) (get@ #artifacts)) +## output]]) + +## (#error.Error error) +## (#error.Error error)))) + +## (def: #export (load-definition state) +## (-> Lux (-> Name Binary (Error Any))) +## (function (_ (^@ def-name [def-module def-name]) def-bytecode) +## (let [normal-name (format (name.normalize def-name) (%n (text/hash def-name))) +## class-name (format (text.replace-all "/" "." def-module) "." normal-name)] +## (<| (macro.run state) +## (do macro.monad +## [_ (..store-class class-name def-bytecode) +## class (..load-class class-name)] +## (case (do error.monad +## [field (Class::getField [..value-field] class)] +## (Field::get [#.None] field)) +## (#error.Success (#.Some def-value)) +## (wrap def-value) + +## (#error.Success #.None) +## (phase.throw invalid-definition-value (%name def-name)) + +## (#error.Error error) +## (phase.throw cannot-load-definition +## (format "Definition: " (%name def-name) "\n" +## "Error:\n" +## error)))))))) -- cgit v1.2.3