bitescript 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,7 +100,7 @@ module BiteScript
100
100
  ", b, __FILE__, line
101
101
  OpcodeInstructions[const_name] = const_down
102
102
 
103
- when "INVOKESTATIC", "INVOKEVIRTUAL", "INVOKEINTERFACE", "INVOKESPECIAL"
103
+ when "INVOKESTATIC", "INVOKEVIRTUAL", "INVOKEINTERFACE", "INVOKESPECIAL", "INVOKEDYNAMIC"
104
104
  # method instructions
105
105
  line = __LINE__; eval "
106
106
  def #{const_down}(type, name, call_sig)
@@ -191,16 +191,17 @@ module BiteScript
191
191
 
192
192
  when "NEWARRAY"
193
193
  # newaray has its own peculiarities
194
- {
195
- :boolean => 'Opcodes::T_BOOLEAN',
196
- :byte => 'Opcodes::T_BYTE',
197
- :short => 'Opcodes::T_SHORT',
198
- :char => 'Opcodes::T_CHAR',
199
- :int => 'Opcodes::T_INT',
200
- :long => 'Opcodes::T_LONG',
201
- :float => 'Opcodes::T_FLOAT',
202
- :double => 'Opcodes::T_DOUBLE'
203
- }.each do |type, op_type|
194
+ NEWARRAY_TYPES = {
195
+ :boolean => Opcodes::T_BOOLEAN,
196
+ :byte => Opcodes::T_BYTE,
197
+ :short => Opcodes::T_SHORT,
198
+ :char => Opcodes::T_CHAR,
199
+ :int => Opcodes::T_INT,
200
+ :long => Opcodes::T_LONG,
201
+ :float => Opcodes::T_FLOAT,
202
+ :double => Opcodes::T_DOUBLE
203
+ }
204
+ NEWARRAY_TYPES.each do |type, op_type|
204
205
  line = __LINE__; eval "
205
206
  def new#{type}array()
206
207
  method_visitor.visit_int_insn(Opcodes::#{const_name}, #{op_type})
@@ -208,6 +209,10 @@ module BiteScript
208
209
  end
209
210
  ", b, __FILE__, line
210
211
  end
212
+ def newarray(type)
213
+ t_type = NEWARRAY_TYPES[path(type).intern]
214
+ method_visitor.visit_int_insn(Opcodes::NEWARRAY, t_type)
215
+ end
211
216
  OpcodeInstructions[const_name] = const_down
212
217
 
213
218
  when "GETFIELD", "PUTFIELD", "GETSTATIC", "PUTSTATIC"
@@ -303,7 +308,7 @@ module BiteScript
303
308
  "T_DOUBLE", "DOUBLE", "ACC_STRICT", "NULL", "T_FLOAT", "ACC_FINAL",
304
309
  "F_SAME1", "ACC_NATIVE", "F_NEW", "T_CHAR", "T_INT", "ACC_VOLATILE",
305
310
  "V1_6", "V1_5", "V1_4", "V1_3", "V1_2", "V1_1", "UNINITIALIZED_THIS",
306
- "TOP", "T_SHORT"
311
+ "TOP", "T_SHORT", "INVOKEDYNAMIC_OWNER", "V1_7"
307
312
  # non-instructions
308
313
 
309
314
  else
data/lib/bitescript.rb CHANGED
@@ -5,12 +5,13 @@ require 'bitescript/bytecode'
5
5
  require 'bitescript/builder'
6
6
 
7
7
  module BiteScript
8
- VERSION = '0.0.2'
8
+ VERSION = '0.0.3'
9
9
 
10
10
  include BiteScript::ASM
11
11
  JAVA1_4 = Opcodes::V1_4
12
12
  JAVA1_5 = Opcodes::V1_5
13
13
  JAVA1_6 = Opcodes::V1_6
14
+ JAVA1_7 = Opcodes::V1_7
14
15
 
15
16
  class << self
16
17
  attr_accessor :bytecode_version
@@ -285,6 +285,15 @@ class TestBytecode < Test::Unit::TestCase
285
285
  assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_LONG], @dummy.single {newlongarray})
286
286
  assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_FLOAT], @dummy.single {newfloatarray})
287
287
  assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_DOUBLE], @dummy.single {newdoublearray})
288
+
289
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_BOOLEAN], @dummy.single {newarray Java::boolean})
290
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_BYTE], @dummy.single {newarray Java::byte})
291
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_SHORT], @dummy.single {newarray Java::short})
292
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_CHAR], @dummy.single {newarray Java::char})
293
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_INT], @dummy.single {newarray Java::int})
294
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_LONG], @dummy.single {newarray Java::long})
295
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_FLOAT], @dummy.single {newarray Java::float})
296
+ assert_equal([:visit_int_insn, Opcodes::NEWARRAY, Opcodes::T_DOUBLE], @dummy.single {newarray Java::double})
288
297
  end
289
298
 
290
299
  def test_field_insns
metadata CHANGED
@@ -66,7 +66,7 @@ requirements: []
66
66
 
67
67
  authors:
68
68
  - charles.nutter@sun.comCharles Oliver Nutter
69
- date: 2009-05-14 05:00:00 +00:00
69
+ date: 2009-06-14 05:00:00 +00:00
70
70
  platform: ruby
71
71
  test_files:
72
72
  - test/test_bitescript.rb
@@ -75,7 +75,7 @@ test_files:
75
75
  - test/test_java_class.rb
76
76
  - test/test_signature.rb
77
77
  version: !ruby/object:Gem::Version
78
- version: 0.0.2
78
+ version: 0.0.3
79
79
  require_paths:
80
80
  - lib
81
81
  dependencies: