From 4433c9bcd6c6cac44c018aad2e21a5b4d7cc4896 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 29 Nov 2017 22:49:56 -0400 Subject: - Adapted main codebase to the latest syntatic changes. --- new-luxc/source/luxc/lang/translation/eval.jvm.lux | 88 +++++++--------------- 1 file changed, 26 insertions(+), 62 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation/eval.jvm.lux') diff --git a/new-luxc/source/luxc/lang/translation/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/eval.jvm.lux index 6b9ee9743..9cce16a49 100644 --- a/new-luxc/source/luxc/lang/translation/eval.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/eval.jvm.lux @@ -1,4 +1,4 @@ -(;module: +(.module: lux (lux (control monad) (data [text] @@ -12,72 +12,36 @@ ["$i" inst])) ["la" analysis] ["ls" synthesis] - (translation [";T" common])) + (translation [".T" common])) )) -(host;import java.lang.Object) -(host;import java.lang.String) - -(host;import java.lang.reflect.Field +(host.import java/lang/reflect/Field (get [Object] Object)) -(host;import (java.lang.Class a) +(host.import (java/lang/Class a) (getField [String] Field)) -(host;import org.objectweb.asm.Opcodes - (#static ACC_PUBLIC int) - (#static ACC_SUPER int) - (#static ACC_FINAL int) - (#static ACC_STATIC int) - (#static PUTSTATIC int) - (#static RETURN int) - (#static V1_6 int) - ) - -(host;import org.objectweb.asm.MethodVisitor - (visitCode [] void) - (visitEnd [] void) - (visitLdcInsn [Object] void) - (visitFieldInsn [int String String String] void) - (visitInsn [int] void) - (visitMaxs [int int] void)) - -(host;import org.objectweb.asm.FieldVisitor - (visitEnd [] void)) - -(host;import org.objectweb.asm.ClassWriter - (#static COMPUTE_MAXS int) - (new [int]) - (visit [int int String String String (Array String)] void) - (visitEnd [] void) - (visitField [int String String String Object] FieldVisitor) - (visitMethod [int String String String (Array String)] MethodVisitor) - (toByteArray [] (Array byte))) - (def: #export (eval valueI) - (-> $;Inst (Meta Top)) - (do macro;Monad - [current-module macro;current-module-name - class-name (:: @ map %code (macro;gensym (format current-module "/eval"))) - #let [store-name (text;replace-all "/" "." class-name) - writer (|> (do-to (ClassWriter.new ClassWriter.COMPUTE_MAXS) - (ClassWriter.visit [commonT;bytecode-version - (i.+ Opcodes.ACC_PUBLIC Opcodes.ACC_SUPER) - class-name - (host;null) - "java/lang/Object" - (host;null)])) - ($d;field #$;Public ($_ $;++F $;finalF $;staticF) - commonT;value-field commonT;$Object) - ($d;method #$;Public ($_ $;++M $;staticM $;strictM) - "" - ($t;method (list) #;None (list)) - (|>. valueI - ($i;PUTSTATIC store-name commonT;value-field commonT;$Object) - $i;RETURN))) - bytecode (ClassWriter.toByteArray [] (do-to writer (ClassWriter.visitEnd [])))] - _ (commonT;store-class store-name bytecode) - class (commonT;load-class store-name)] + (-> $.Inst (Meta Top)) + (do macro.Monad + [current-module macro.current-module-name + class-name (:: @ map %code (macro.gensym (format current-module "/eval"))) + #let [store-name (text.replace-all "/" "." class-name) + bytecode ($d.class #$.V1_6 + #$.Public $.noneC + class-name + (list) ["java.lang.Object" (list)] + (list) + (|>> ($d.field #$.Public ($_ $.++F $.finalF $.staticF) + commonT.value-field commonT.$Object) + ($d.method #$.Public ($_ $.++M $.staticM $.strictM) + "" + ($t.method (list) #.None (list)) + (|>> valueI + ($i.PUTSTATIC store-name commonT.value-field commonT.$Object) + $i.RETURN))))] + _ (commonT.store-class store-name bytecode) + class (commonT.load-class store-name)] (wrap (|> class - (Class.getField [commonT;value-field]) - (Field.get (host;null)))))) + (Class::getField [commonT.value-field]) + (Field::get (host.null)))))) -- cgit v1.2.3