From 84d7f9ccef221e9797929813af1094b335ba26e9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 9 Aug 2018 23:39:17 -0400 Subject: - Fixes for eval. - Macro-expansion during analysis. --- new-luxc/source/luxc/lang/macro.lux | 35 ---------------------- new-luxc/source/luxc/lang/translation/jvm.lux | 2 +- .../luxc/lang/translation/jvm/runtime.jvm.lux | 4 +-- 3 files changed, 3 insertions(+), 38 deletions(-) delete mode 100644 new-luxc/source/luxc/lang/macro.lux (limited to 'new-luxc/source/luxc') diff --git a/new-luxc/source/luxc/lang/macro.lux b/new-luxc/source/luxc/lang/macro.lux deleted file mode 100644 index 17ed2436b..000000000 --- a/new-luxc/source/luxc/lang/macro.lux +++ /dev/null @@ -1,35 +0,0 @@ -(.module: - lux - (lux (control [monad #+ do]) - (data ["e" error]) - [macro] - [host]) - (luxc (lang [".L" host] - (translation (jvm [".T" common]))))) - -(for {"JVM" (as-is (host.import: java/lang/reflect/Method - (invoke [Object (Array Object)] #try Object)) - (host.import: (java/lang/Class c) - (getMethod [String (Array (Class Object))] #try Method)) - (host.import: java/lang/Object) - (def: _object-class (Class Object) (host.class-for Object)) - (def: _apply-args - (Array (Class Object)) - (|> (host.array (Class Object) +2) - (host.array-write +0 _object-class) - (host.array-write +1 _object-class))) - (def: #export (expand macro inputs) - (-> Macro (List Code) (Meta (List Code))) - (do macro.Monad - [class (commonT.load-class hostL.function-class)] - (function (_ compiler) - (do e.Monad - [apply-method (Class::getMethod ["apply" _apply-args] class) - output (Method::invoke [(:coerce Object macro) - (|> (host.array Object +2) - (host.array-write +0 (:coerce Object inputs)) - (host.array-write +1 (:coerce Object compiler)))] - apply-method)] - (:coerce (e.Error [Lux (List Code)]) - output)))))) - }) diff --git a/new-luxc/source/luxc/lang/translation/jvm.lux b/new-luxc/source/luxc/lang/translation/jvm.lux index 14f8cf0a0..2aa46e050 100644 --- a/new-luxc/source/luxc/lang/translation/jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm.lux @@ -117,7 +117,7 @@ (def: (store! name bytecode store) (-> Text ByteCode Store (Error Any)) - (if (dictionary.contains? name (|> store atom.read io.run)) + (if (|> store atom.read io.run (dictionary.contains? name)) (ex.throw class-already-stored name) (exec (io.run (atom.update (dictionary.put name bytecode) store)) (#error.Success [])))) diff --git a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux index 4b3259efd..3c687f822 100644 --- a/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/jvm/runtime.jvm.lux @@ -381,7 +381,7 @@ pm-methods io-methods))] (do phase.Monad - [_ (translation.execute! [//.runtime-class bytecode])] + [_ (translation.execute! //.runtime-class [//.runtime-class bytecode])] (wrap bytecode)))) (def: translate-function @@ -411,7 +411,7 @@ _.RETURN)) applyI))] (do phase.Monad - [_ (translation.execute! [//.function-class bytecode])] + [_ (translation.execute! //.function-class [//.function-class bytecode])] (wrap bytecode)))) (def: #export translate -- cgit v1.2.3