From c7e53036704b1a89b740c023c7b4bcc74b7e956a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 14 Jun 2017 17:56:24 -0400 Subject: - Heavy refactoring. --- new-luxc/source/luxc/generator/common.jvm.lux | 87 ++------------------------- 1 file changed, 5 insertions(+), 82 deletions(-) (limited to 'new-luxc/source/luxc/generator/common.jvm.lux') diff --git a/new-luxc/source/luxc/generator/common.jvm.lux b/new-luxc/source/luxc/generator/common.jvm.lux index e5d3552c4..2c943c5e5 100644 --- a/new-luxc/source/luxc/generator/common.jvm.lux +++ b/new-luxc/source/luxc/generator/common.jvm.lux @@ -5,23 +5,13 @@ (data ["R" result] (coll ["d" dict]) text/format) - [macro #+ Monad] - [host #+ jvm-import do-to])) + [host #+ jvm-import])) ## [Host] (jvm-import org.objectweb.asm.Opcodes - (#static V1_6 int) - (#static CHECKCAST int) - (#static INVOKESTATIC int) - (#static INVOKEVIRTUAL int)) + (#static V1_6 int)) -(jvm-import org.objectweb.asm.MethodVisitor - (visitLdcInsn [Object] void) - (visitTypeInsn [int String] void) - (visitMethodInsn [int String String String boolean] void)) - -(jvm-import java.lang.Object - (toString [] String)) +(jvm-import java.lang.Object) (jvm-import (java.lang.Class a)) @@ -34,49 +24,11 @@ (type: #export Class-Store (A;Atom (d;Dict Text Bytecode))) (type: #export Host - {#visitor (Maybe MethodVisitor) - #loader ClassLoader + {#loader ClassLoader #store Class-Store}) (def: #export unit Text "\u0000") -(def: (visitor::get compiler) - (-> Compiler (Maybe MethodVisitor)) - (|> (get@ #;host compiler) - (:! Host) - (get@ #visitor))) - -(def: (visitor::put ?visitor compiler) - (-> (Maybe MethodVisitor) Compiler Compiler) - (update@ #;host - (function [host] - (|> host - (:! Host) - (set@ #visitor ?visitor) - (:! Void))) - compiler)) - -(def: #export get-visitor - (Lux MethodVisitor) - (function [compiler] - (case (visitor::get compiler) - #;None - (#R;Error "No visitor has been set.") - - (#;Some visitor) - (#R;Success [compiler visitor])))) - -(def: #export (with-visitor visitor body) - (All [a] (-> MethodVisitor (Lux a) (Lux a))) - (function [compiler] - (case (macro;run' (visitor::put (#;Some visitor) compiler) body) - (#R;Error error) - (#R;Error error) - - (#R;Success [compiler' output]) - (#R;Success [(visitor::put (visitor::get compiler) compiler') - output])))) - (def: #export (store-class name byte-code) (-> Text Bytecode (Lux Unit)) (function [compiler] @@ -97,34 +49,5 @@ (#R;Success [compiler (ClassLoader.loadClass [name] (get@ #loader host))]) (#R;Error (format "Unknown class: " name)))))) - -(do-template [ ] - [(def: #export ( writer) - (-> MethodVisitor MethodVisitor) - (do-to writer - (MethodVisitor.visitMethodInsn [Opcodes.INVOKESTATIC - "valueOf" (format "(" ")" "L" ";") - false]))) - (def: #export ( writer) - (-> MethodVisitor MethodVisitor) - (do-to writer - (MethodVisitor.visitTypeInsn [Opcodes.CHECKCAST ]) - (MethodVisitor.visitMethodInsn [Opcodes.INVOKEVIRTUAL - (format "()" ) - false])))] - - [wrap-boolean unwrap-boolean "java/lang/Boolean" "booleanValue" "Z" Opcodes.DUP_X1] - [wrap-byte unwrap-byte "java/lang/Byte" "byteValue" "B" Opcodes.DUP_X1] - [wrap-short unwrap-short "java/lang/Short" "shortValue" "S" Opcodes.DUP_X1] - [wrap-int unwrap-int "java/lang/Integer" "intValue" "I" Opcodes.DUP_X1] - [wrap-long unwrap-long "java/lang/Long" "longValue" "J" Opcodes.DUP_X2] - [wrap-float unwrap-float "java/lang/Float" "floatValue" "F" Opcodes.DUP_X1] - [wrap-double unwrap-double "java/lang/Double" "doubleValue" "D" Opcodes.DUP_X2] - [wrap-char unwrap-char "java/lang/Character" "charValue" "C" Opcodes.DUP_X1] - ) - -(type: #export Flags Int) -(type: #export Descriptor Text) - -(def: #export bytecode-version Flags Opcodes.V1_6) +(def: #export bytecode-version Int Opcodes.V1_6) (def: #export runtime-class-name Text "LuxRT") -- cgit v1.2.3