Permalink
Browse files

Fixes for asm 4.0.

* mh_etc are now h_etc
* MethodHandle is now Handle
* ASM4 constant is ignored
  • Loading branch information...
1 parent dff922a commit 9daf504a59ddb1393f796ab7578835ffc8dce371 @headius committed Nov 10, 2011
Showing with 14 additions and 19 deletions.
  1. +1 −1 examples/invokedynamic.bs
  2. +1 −0 lib/bitescript.rb
  3. +3 −2 lib/bitescript/asm.rb
  4. +5 −5 lib/bitescript/bytecode.rb
  5. +4 −11 lib/bitescript/mirror.rb
@@ -8,7 +8,7 @@ JClass = java.lang.Class
# Our main method, which does one invokedynamic
main do
# handle for our bootstrap, which binds invokedynamic to a CallSite
- bootstrap = mh_invokestatic this, 'bootstrap', CallSite, Lookup, string, MethodType
+ bootstrap = h_invokestatic this, 'bootstrap', CallSite, Lookup, string, MethodType
ldc 'Hello, invokedynamic!'
invokedynamic 'print', [void, string], bootstrap
View
@@ -11,6 +11,7 @@ module BiteScript
JAVA1_5 = Opcodes::V1_5
JAVA1_6 = Opcodes::V1_6
JAVA1_7 = Opcodes::V1_7
+ JAVA1_8 = Opcodes::V1_7
class << self
attr_accessor :bytecode_version
View
@@ -36,11 +36,12 @@ module ASM
java_import asm_package.signature.SignatureVisitor
java_import asm_package.signature.SignatureWriter
- # MethodHandle was introduced in ASM 4.0, and is only available to
+ # Handle was introduced in ASM 4.0, and is only available to
# JRuby > 1.6.1
begin
- java_import asm_package.MethodHandle
+ java_import asm_package.Handle
rescue
+ fail "this version of bitescript requires ASM 4.0"
end
end
end
View
@@ -282,12 +282,12 @@ def tableswitch(min, max, default, cases = [])
end
OpcodeInstructions['TABLESWITCH'] = 'tableswitch'
- when "MH_INVOKESPECIAL", "MH_INVOKESTATIC", "MH_PUTSTATIC", "MH_GETSTATIC", "MH_PUTFIELD",
- "MH_GETFIELD", "MH_INVOKEVIRTUAL", "MH_INVOKEINTERFACE",
- "MH_NEWINVOKESPECIAL"
+ when "H_INVOKESPECIAL", "H_INVOKESTATIC", "H_PUTSTATIC", "H_GETSTATIC", "H_PUTFIELD",
+ "H_GETFIELD", "H_INVOKEVIRTUAL", "H_INVOKEINTERFACE",
+ "H_NEWINVOKESPECIAL"
line = __LINE__; eval "
def #{const_down}(cls, name, *call_sig)
- MethodHandle.new(Opcodes::#{const_name}, path(cls), name, sig(*call_sig))
+ Handle.new(Opcodes::#{const_name}, path(cls), name, sig(*call_sig))
end
", b, __FILE__, line
OpcodeInstructions[const_name] = const_down
@@ -299,7 +299,7 @@ def #{const_down}(cls, name, *call_sig)
"T_DOUBLE", "DOUBLE", "ACC_STRICT", "NULL", "T_FLOAT", "ACC_FINAL",
"F_SAME1", "ACC_NATIVE", "F_NEW", "T_CHAR", "T_INT", "ACC_VOLATILE",
"V1_6", "V1_5", "V1_4", "V1_3", "V1_2", "V1_1", "UNINITIALIZED_THIS",
- "TOP", "T_SHORT", "INVOKEDYNAMIC_OWNER", "V1_7"
+ "TOP", "T_SHORT", "INVOKEDYNAMIC_OWNER", "V1_7", "ASM4"
# non-instructions
View
@@ -58,7 +58,7 @@ def inspect_value(v)
end
end
- class Builder
+ class Builder < BiteScript::ASM::AnnotationVisitor
class ValueArray
attr_reader :parent
def initialize(annotation, array)
@@ -71,8 +71,6 @@ def []=(name, value)
end
end
- include BiteScript::ASM::AnnotationVisitor
-
attr_reader :annotation
def initialize(desc, visible)
@current = @annotation = AnnotationMirror.new(Type.getType(desc))
@@ -289,10 +287,7 @@ def inspect
result << "}"
end
- class Builder
- include BiteScript::ASM::ClassVisitor
- include BiteScript::ASM::FieldVisitor
- include BiteScript::ASM::MethodVisitor
+ class Builder < BiteScript::ASM::ClassVisitor
def visit(version, access, name, signature, super_name, interfaces)
@current = @class = ClassMirror.new(Type.getObjectType(name), access)
@@ -414,8 +409,7 @@ def inspect
end
end
- class SignatureMirror
- include BiteScript::ASM::SignatureVisitor
+ class SignatureMirror < BiteScript::ASM::SignatureVisitor
attr_reader :type_parameters
attr_reader :parameter_types, :return_type, :exception_types
@@ -570,8 +564,7 @@ def to_s
end
end
- class GenericTypeBuilder
- include BiteScript::ASM::SignatureVisitor
+ class GenericTypeBuilder < BiteScript::ASM::SignatureVisitor
attr_reader :result
def self.read(signature)

0 comments on commit 9daf504

Please sign in to comment.