unageanu-javaclass 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/javaclass/accessflag.rb +278 -278
- data/lib/javaclass/attribute.rb +1058 -1058
- data/lib/javaclass/base.rb +368 -368
- data/lib/javaclass/class.rb +281 -281
- data/lib/javaclass/constant.rb +520 -520
- data/lib/javaclass/member.rb +192 -192
- data/lib/javaclass/reader.rb +445 -445
- data/lib/javaclass.rb +7 -7
- data/sample/class_list.rb +38 -8
- data/sample/create_assert.rb +68 -68
- data/sample/sample.rb +26 -26
- data/sample/type_hierarchy.rb +93 -0
- data/test/test_access_flag.rb +205 -205
- data/test/test_attribute.rb +955 -955
- data/test/test_class.rb +90 -90
- data/test/test_constant.rb +830 -830
- data/test/test_member.rb +282 -282
- metadata +2 -1
data/lib/javaclass/base.rb
CHANGED
@@ -1,369 +1,369 @@
|
|
1
|
-
|
2
|
-
module JavaClass
|
3
|
-
|
4
|
-
module Base
|
5
|
-
|
6
|
-
# 0..255の数字の配列に変換する
|
7
|
-
def to_byte( value, length )
|
8
|
-
return [0x00]*length if value == nil
|
9
|
-
tmp = []
|
10
|
-
length.times {|i|
|
11
|
-
tmp.unshift( value & 0xFF )
|
12
|
-
value >>= 8
|
13
|
-
}
|
14
|
-
return tmp
|
15
|
-
end
|
16
|
-
|
17
|
-
# 16進数表現の文字列形式に変換する
|
18
|
-
def dump()
|
19
|
-
buff = ""
|
20
|
-
i = 1
|
21
|
-
self.to_bytes().each {|b|
|
22
|
-
buff << sprintf("%0.2X", b)
|
23
|
-
buff << (i%16==0 ? "\n" : i%4==0 ? " " : "")
|
24
|
-
i+=1
|
25
|
-
}
|
26
|
-
return buff.strip
|
27
|
-
end
|
28
|
-
|
29
|
-
# オブジェクト比較メソッド
|
30
|
-
def ==(other)
|
31
|
-
_eql?(other) { |a,b| a == b }
|
32
|
-
end
|
33
|
-
def ===(other)
|
34
|
-
_eql?(other) { |a,b| a === b }
|
35
|
-
end
|
36
|
-
def eql?(other)
|
37
|
-
_eql?(other) { |a,b| a.eql? b }
|
38
|
-
end
|
39
|
-
def hash
|
40
|
-
hash = 0
|
41
|
-
values.each {|v|
|
42
|
-
hash = v.hash + 31 * hash
|
43
|
-
}
|
44
|
-
return hash
|
45
|
-
end
|
46
|
-
protected
|
47
|
-
def values
|
48
|
-
values = []
|
49
|
-
values << self.class
|
50
|
-
instance_variables.each { |name|
|
51
|
-
# java_classを比較すると循環するので外す。
|
52
|
-
values << instance_variable_get(name) unless name.to_s =~ /java\_class$/
|
53
|
-
}
|
54
|
-
return values
|
55
|
-
end
|
56
|
-
private
|
57
|
-
def _eql?(other, &block)
|
58
|
-
return false if other == nil
|
59
|
-
return true if self.equal? other
|
60
|
-
return false unless other.kind_of?(JavaClass::Base)
|
61
|
-
a = values
|
62
|
-
b = other.values
|
63
|
-
return false if a.length != b.length
|
64
|
-
a.length.times{|i|
|
65
|
-
return false unless block.call( a[i], b[i] )
|
66
|
-
}
|
67
|
-
return true
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
module Item
|
73
|
-
#
|
74
|
-
#===シグネチャを取得する。
|
75
|
-
#
|
76
|
-
#<b>戻り値</b>::シグネチャ。定義されていない場合nil
|
77
|
-
#
|
78
|
-
def signature
|
79
|
-
(attributes.key? "Signature") ? attributes["Signature"].signature : nil
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
#===Deprecatedかどうか評価する。
|
84
|
-
#
|
85
|
-
#<b>戻り値</b>::Deprecatedであればtrue
|
86
|
-
#
|
87
|
-
def deprecated?
|
88
|
-
attributes.key? 'Deprecated'
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
#===設定されているアノテーションを配列で取得する。
|
93
|
-
#
|
94
|
-
#<b>戻り値</b>::アノテーションの配列
|
95
|
-
#
|
96
|
-
def annotations
|
97
|
-
['RuntimeVisibleAnnotations', 'RuntimeInvisibleAnnotations'].inject([]) { |l, k|
|
98
|
-
l.concat( attributes[k].annotations ) if attributes.key? k
|
99
|
-
l
|
100
|
-
}
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
module Converters
|
107
|
-
|
108
|
-
module_function
|
109
|
-
def convert_field_descriptor( descriptor )
|
110
|
-
value = ""
|
111
|
-
case descriptor[0].chr
|
112
|
-
when "["
|
113
|
-
value = convert_field_descriptor( descriptor[1..descriptor.size-1] ) + "[]"
|
114
|
-
when "L"
|
115
|
-
value = descriptor[1..descriptor.size-2].gsub(/\//, ".")
|
116
|
-
when "B"
|
117
|
-
value = "byte"
|
118
|
-
when "C"
|
119
|
-
value = "char"
|
120
|
-
when "D"
|
121
|
-
value = "double"
|
122
|
-
when "F"
|
123
|
-
value = "float"
|
124
|
-
when "I"
|
125
|
-
value = "int"
|
126
|
-
when "J"
|
127
|
-
value = "long"
|
128
|
-
when "S"
|
129
|
-
value = "short"
|
130
|
-
when "Z"
|
131
|
-
value = "boolean"
|
132
|
-
end
|
133
|
-
return value
|
134
|
-
end
|
135
|
-
def convert_method_descriptor( descriptor )
|
136
|
-
res = {}
|
137
|
-
if ( descriptor =~ /\((.*)\)(.+)/ )
|
138
|
-
res[:return] = $2 == "V" ? "void" : convert_field_descriptor( $2 )
|
139
|
-
res[:args] = []
|
140
|
-
strs = $1.scan( /(\[*[BCDFIJSZ]|\[*L.*?;)/ ).flatten
|
141
|
-
strs.each { |str|
|
142
|
-
res[:args] << convert_field_descriptor( str )
|
143
|
-
}
|
144
|
-
else
|
145
|
-
raise "illegal method descriptor. descriptor=" << descriptor
|
146
|
-
end
|
147
|
-
return res
|
148
|
-
end
|
149
|
-
#
|
150
|
-
#=== コードの文字列表現を得る。
|
151
|
-
#*code::コード
|
152
|
-
#<b>戻り値</b>::コードの文字列表現
|
153
|
-
#
|
154
|
-
def convert_code( code )
|
155
|
-
str = nil
|
156
|
-
case code
|
157
|
-
when 0x00; str = "nop"
|
158
|
-
when 0x01; str = "aconst_null"
|
159
|
-
when 0x02; str = "iconst_m1"
|
160
|
-
when 0x03; str = "iconst_0"
|
161
|
-
when 0x04; str = "iconst_1"
|
162
|
-
when 0x05; str = "iconst_2"
|
163
|
-
when 0x06; str = "iconst_3"
|
164
|
-
when 0x07; str = "iconst_4"
|
165
|
-
when 0x08; str = "iconst_5"
|
166
|
-
when 0x09; str = "lconst_0"
|
167
|
-
when 0x0a; str = "lconst_1"
|
168
|
-
when 0x0b; str = "fconst_0"
|
169
|
-
when 0x0c; str = "fconst_1"
|
170
|
-
when 0x0d; str = "fconst_2"
|
171
|
-
when 0x0e; str = "dconst_0"
|
172
|
-
when 0x0f; str = "dconst_1"
|
173
|
-
when 0x10; str = "bipush"
|
174
|
-
when 0x11; str = "sipush"
|
175
|
-
when 0x12; str = "ldc"
|
176
|
-
when 0x13; str = "ldc_w"
|
177
|
-
when 0x14; str = "ldc2_w"
|
178
|
-
when 0x15; str = "iload"
|
179
|
-
when 0x16; str = "lload"
|
180
|
-
when 0x17; str = "fload"
|
181
|
-
when 0x18; str = "dload"
|
182
|
-
when 0x19; str = "aload"
|
183
|
-
when 0x1a; str = "iload_0"
|
184
|
-
when 0x1b; str = "iload_1"
|
185
|
-
when 0x1c; str = "iload_2"
|
186
|
-
when 0x1d; str = "iload_3"
|
187
|
-
when 0x1e; str = "lload_0"
|
188
|
-
when 0x1f; str = "lload_1"
|
189
|
-
when 0x20; str = "lload_2"
|
190
|
-
when 0x21; str = "lload_3"
|
191
|
-
when 0x22; str = "fload_0"
|
192
|
-
when 0x23; str = "fload_1"
|
193
|
-
when 0x24; str = "fload_2"
|
194
|
-
when 0x25; str = "fload_3"
|
195
|
-
when 0x26; str = "dload_0"
|
196
|
-
when 0x27; str = "dload_1"
|
197
|
-
when 0x28; str = "dload_2"
|
198
|
-
when 0x29; str = "dload_3"
|
199
|
-
when 0x2a; str = "aload_0"
|
200
|
-
when 0x2b; str = "aload_1"
|
201
|
-
when 0x2c; str = "aload_2"
|
202
|
-
when 0x2d; str = "aload_3"
|
203
|
-
when 0x2e; str = "iaload"
|
204
|
-
when 0x2f; str = "laload"
|
205
|
-
when 0x30; str = "faload"
|
206
|
-
when 0x31; str = "daload"
|
207
|
-
when 0x32; str = "aaload"
|
208
|
-
when 0x33; str = "baload"
|
209
|
-
when 0x34; str = "caload"
|
210
|
-
when 0x35; str = "saload"
|
211
|
-
when 0x36; str = "istore"
|
212
|
-
when 0x37; str = "lstore"
|
213
|
-
when 0x38; str = "fstore"
|
214
|
-
when 0x39; str = "dstore"
|
215
|
-
when 0x3a; str = "astore"
|
216
|
-
when 0x3b; str = "istore_0"
|
217
|
-
when 0x3c; str = "istore_1"
|
218
|
-
when 0x3d; str = "istore_2"
|
219
|
-
when 0x3e; str = "istore_3"
|
220
|
-
when 0x3f; str = "lstore_0"
|
221
|
-
when 0x40; str = "lstore_1"
|
222
|
-
when 0x41; str = "lstore_2"
|
223
|
-
when 0x42; str = "lstore_3"
|
224
|
-
when 0x43; str = "fstore_0"
|
225
|
-
when 0x44; str = "fstore_1"
|
226
|
-
when 0x45; str = "fstore_2"
|
227
|
-
when 0x46; str = "fstore_3"
|
228
|
-
when 0x47; str = "dstore_0"
|
229
|
-
when 0x48; str = "dstore_1"
|
230
|
-
when 0x49; str = "dstore_2"
|
231
|
-
when 0x4a; str = "dstore_3"
|
232
|
-
when 0x4b; str = "astore_0"
|
233
|
-
when 0x4c; str = "astore_1"
|
234
|
-
when 0x4d; str = "astore_2"
|
235
|
-
when 0x4e; str = "astore_3"
|
236
|
-
when 0x4f; str = "iastore"
|
237
|
-
when 0x50; str = "lastore"
|
238
|
-
when 0x51; str = "fastore"
|
239
|
-
when 0x52; str = "dastore"
|
240
|
-
when 0x53; str = "aastore"
|
241
|
-
when 0x54; str = "bastore"
|
242
|
-
when 0x55; str = "castore"
|
243
|
-
when 0x56; str = "sastore"
|
244
|
-
when 0x57; str = "pop"
|
245
|
-
when 0x58; str = "pop2"
|
246
|
-
when 0x59; str = "dup"
|
247
|
-
when 0x5a; str = "dup_x1"
|
248
|
-
when 0x5b; str = "dup_x2"
|
249
|
-
when 0x5c; str = "dup2"
|
250
|
-
when 0x5d; str = "dup2_x1"
|
251
|
-
when 0x5e; str = "dup2_x2"
|
252
|
-
when 0x5f; str = "swap"
|
253
|
-
when 0x60; str = "iadd"
|
254
|
-
when 0x61; str = "ladd"
|
255
|
-
when 0x62; str = "fadd"
|
256
|
-
when 0x63; str = "dadd"
|
257
|
-
when 0x64; str = "isub"
|
258
|
-
when 0x65; str = "lsub"
|
259
|
-
when 0x66; str = "fsub"
|
260
|
-
when 0x67; str = "dsub"
|
261
|
-
when 0x68; str = "imul"
|
262
|
-
when 0x69; str = "lmul"
|
263
|
-
when 0x6a; str = "fmul"
|
264
|
-
when 0x6b; str = "dmul"
|
265
|
-
when 0x6c; str = "idiv"
|
266
|
-
when 0x6d; str = "ldiv"
|
267
|
-
when 0x6e; str = "fdiv"
|
268
|
-
when 0x6f; str = "ddiv"
|
269
|
-
when 0x70; str = "irem"
|
270
|
-
when 0x71; str = "lrem"
|
271
|
-
when 0x72; str = "frem"
|
272
|
-
when 0x73; str = "drem"
|
273
|
-
when 0x75; str = "lneg"
|
274
|
-
when 0x76; str = "fneg"
|
275
|
-
when 0x77; str = "dneg"
|
276
|
-
when 0x78; str = "ishl"
|
277
|
-
when 0x79; str = "lshl"
|
278
|
-
when 0x7a; str = "ishr"
|
279
|
-
when 0x7b; str = "lshr"
|
280
|
-
when 0x7c; str = "iushr"
|
281
|
-
when 0x7d; str = "lushr"
|
282
|
-
when 0x7e; str = "iand"
|
283
|
-
when 0x7f; str = "land"
|
284
|
-
when 0x80; str = "ior"
|
285
|
-
when 0x81; str = "lor"
|
286
|
-
when 0x82; str = "ixor"
|
287
|
-
when 0x83; str = "lxor"
|
288
|
-
when 0x84; str = "iinc"
|
289
|
-
when 0x85; str = "i2l"
|
290
|
-
when 0x86; str = "i2f"
|
291
|
-
when 0x87; str = "i2d"
|
292
|
-
when 0x88; str = "l2i"
|
293
|
-
when 0x89; str = "l2f"
|
294
|
-
when 0x8a; str = "l2d"
|
295
|
-
when 0x8b; str = "f2i"
|
296
|
-
when 0x8c; str = "f2l"
|
297
|
-
when 0x8d; str = "f2d"
|
298
|
-
when 0x8e; str = "d2i"
|
299
|
-
when 0x8f; str = "d2l"
|
300
|
-
when 0x90; str = "d2f"
|
301
|
-
when 0x91; str = "i2b"
|
302
|
-
when 0x92; str = "i2c"
|
303
|
-
when 0x93; str = "i2s"
|
304
|
-
when 0x94; str = "lcmp"
|
305
|
-
when 0x95; str = "fcmpl"
|
306
|
-
when 0x96; str = "fcmpg"
|
307
|
-
when 0x97; str = "dcmpl"
|
308
|
-
when 0x98; str = "dcmpg"
|
309
|
-
when 0x99; str = "ifeq"
|
310
|
-
when 0x9a; str = "ifne"
|
311
|
-
when 0x9b; str = "iflt"
|
312
|
-
when 0x9c; str = "ifge"
|
313
|
-
when 0x9d; str = "ifgt"
|
314
|
-
when 0x9e; str = "ifle"
|
315
|
-
when 0x9f; str = "if_icmpeq"
|
316
|
-
when 0xa0; str = "if_icmpne"
|
317
|
-
when 0xa1; str = "if_icmplt"
|
318
|
-
when 0xa2; str = "if_icmpge"
|
319
|
-
when 0xa3; str = "if_icmpgt"
|
320
|
-
when 0xa4; str = "if_icmple"
|
321
|
-
when 0xa5; str = "if_acmpeq"
|
322
|
-
when 0xa6; str = "if_acmpne"
|
323
|
-
when 0xa7; str = "goto"
|
324
|
-
when 0xa8; str = "jsr"
|
325
|
-
when 0xa9; str = "ret"
|
326
|
-
when 0xaa; str = "tableswitch"
|
327
|
-
when 0xab; str = "lookupswitch"
|
328
|
-
when 0xac; str = "ireturn"
|
329
|
-
when 0xad; str = "lreturn"
|
330
|
-
when 0xae; str = "freturn"
|
331
|
-
when 0xaf; str = "dreturn"
|
332
|
-
when 0xb0; str = "areturn"
|
333
|
-
when 0xb1; str = "return"
|
334
|
-
when 0xb2; str = "getstatic"
|
335
|
-
when 0xb3; str = "putstatic"
|
336
|
-
when 0xb4; str = "getfield"
|
337
|
-
when 0xb5; str = "putfield"
|
338
|
-
when 0xb6; str = "invokevirtual"
|
339
|
-
when 0xb7; str = "invokespecial"
|
340
|
-
when 0xb8; str = "invokestatic"
|
341
|
-
when 0xb9; str = "invokeinterface"
|
342
|
-
when 0xba; str = "xxxunusedxxx1"
|
343
|
-
when 0xbb; str = "new"
|
344
|
-
when 0xbc; str = "newarray"
|
345
|
-
when 0xbd; str = "anewarray"
|
346
|
-
when 0xbe; str = "arraylength"
|
347
|
-
when 0xbf; str = "athrow"
|
348
|
-
when 0xc0; str = "checkcast"
|
349
|
-
when 0xc1; str = "instanceof"
|
350
|
-
when 0xc2; str = "monitorenter"
|
351
|
-
when 0xc3; str = "monitorexit"
|
352
|
-
when 0xc4; str = "wide"
|
353
|
-
when 0xc5; str = "multianewarray"
|
354
|
-
when 0xc6; str = "ifnull"
|
355
|
-
when 0xc7; str = "ifnonnull"
|
356
|
-
when 0xc8; str = "goto_w"
|
357
|
-
when 0xc9; str = "jsr_w"
|
358
|
-
when 0xca; str = "breakpoint"
|
359
|
-
when 0xfe; str = "impdep1"
|
360
|
-
when 0xff; str = "impdep2"
|
361
|
-
else
|
362
|
-
aise "unknown code. code=" << code.to_s
|
363
|
-
end
|
364
|
-
return str;
|
365
|
-
end
|
366
|
-
|
367
|
-
end
|
368
|
-
|
1
|
+
|
2
|
+
module JavaClass
|
3
|
+
|
4
|
+
module Base
|
5
|
+
|
6
|
+
# 0..255の数字の配列に変換する
|
7
|
+
def to_byte( value, length )
|
8
|
+
return [0x00]*length if value == nil
|
9
|
+
tmp = []
|
10
|
+
length.times {|i|
|
11
|
+
tmp.unshift( value & 0xFF )
|
12
|
+
value >>= 8
|
13
|
+
}
|
14
|
+
return tmp
|
15
|
+
end
|
16
|
+
|
17
|
+
# 16進数表現の文字列形式に変換する
|
18
|
+
def dump()
|
19
|
+
buff = ""
|
20
|
+
i = 1
|
21
|
+
self.to_bytes().each {|b|
|
22
|
+
buff << sprintf("%0.2X", b)
|
23
|
+
buff << (i%16==0 ? "\n" : i%4==0 ? " " : "")
|
24
|
+
i+=1
|
25
|
+
}
|
26
|
+
return buff.strip
|
27
|
+
end
|
28
|
+
|
29
|
+
# オブジェクト比較メソッド
|
30
|
+
def ==(other)
|
31
|
+
_eql?(other) { |a,b| a == b }
|
32
|
+
end
|
33
|
+
def ===(other)
|
34
|
+
_eql?(other) { |a,b| a === b }
|
35
|
+
end
|
36
|
+
def eql?(other)
|
37
|
+
_eql?(other) { |a,b| a.eql? b }
|
38
|
+
end
|
39
|
+
def hash
|
40
|
+
hash = 0
|
41
|
+
values.each {|v|
|
42
|
+
hash = v.hash + 31 * hash
|
43
|
+
}
|
44
|
+
return hash
|
45
|
+
end
|
46
|
+
protected
|
47
|
+
def values
|
48
|
+
values = []
|
49
|
+
values << self.class
|
50
|
+
instance_variables.each { |name|
|
51
|
+
# java_classを比較すると循環するので外す。
|
52
|
+
values << instance_variable_get(name) unless name.to_s =~ /java\_class$/
|
53
|
+
}
|
54
|
+
return values
|
55
|
+
end
|
56
|
+
private
|
57
|
+
def _eql?(other, &block)
|
58
|
+
return false if other == nil
|
59
|
+
return true if self.equal? other
|
60
|
+
return false unless other.kind_of?(JavaClass::Base)
|
61
|
+
a = values
|
62
|
+
b = other.values
|
63
|
+
return false if a.length != b.length
|
64
|
+
a.length.times{|i|
|
65
|
+
return false unless block.call( a[i], b[i] )
|
66
|
+
}
|
67
|
+
return true
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
module Item
|
73
|
+
#
|
74
|
+
#===シグネチャを取得する。
|
75
|
+
#
|
76
|
+
#<b>戻り値</b>::シグネチャ。定義されていない場合nil
|
77
|
+
#
|
78
|
+
def signature
|
79
|
+
(attributes.key? "Signature") ? attributes["Signature"].signature : nil
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
#===Deprecatedかどうか評価する。
|
84
|
+
#
|
85
|
+
#<b>戻り値</b>::Deprecatedであればtrue
|
86
|
+
#
|
87
|
+
def deprecated?
|
88
|
+
attributes.key? 'Deprecated'
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
#===設定されているアノテーションを配列で取得する。
|
93
|
+
#
|
94
|
+
#<b>戻り値</b>::アノテーションの配列
|
95
|
+
#
|
96
|
+
def annotations
|
97
|
+
['RuntimeVisibleAnnotations', 'RuntimeInvisibleAnnotations'].inject([]) { |l, k|
|
98
|
+
l.concat( attributes[k].annotations ) if attributes.key? k
|
99
|
+
l
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
module Converters
|
107
|
+
|
108
|
+
module_function
|
109
|
+
def convert_field_descriptor( descriptor )
|
110
|
+
value = ""
|
111
|
+
case descriptor[0].chr
|
112
|
+
when "["
|
113
|
+
value = convert_field_descriptor( descriptor[1..descriptor.size-1] ) + "[]"
|
114
|
+
when "L"
|
115
|
+
value = descriptor[1..descriptor.size-2].gsub(/\//, ".")
|
116
|
+
when "B"
|
117
|
+
value = "byte"
|
118
|
+
when "C"
|
119
|
+
value = "char"
|
120
|
+
when "D"
|
121
|
+
value = "double"
|
122
|
+
when "F"
|
123
|
+
value = "float"
|
124
|
+
when "I"
|
125
|
+
value = "int"
|
126
|
+
when "J"
|
127
|
+
value = "long"
|
128
|
+
when "S"
|
129
|
+
value = "short"
|
130
|
+
when "Z"
|
131
|
+
value = "boolean"
|
132
|
+
end
|
133
|
+
return value
|
134
|
+
end
|
135
|
+
def convert_method_descriptor( descriptor )
|
136
|
+
res = {}
|
137
|
+
if ( descriptor =~ /\((.*)\)(.+)/ )
|
138
|
+
res[:return] = $2 == "V" ? "void" : convert_field_descriptor( $2 )
|
139
|
+
res[:args] = []
|
140
|
+
strs = $1.scan( /(\[*[BCDFIJSZ]|\[*L.*?;)/ ).flatten
|
141
|
+
strs.each { |str|
|
142
|
+
res[:args] << convert_field_descriptor( str )
|
143
|
+
}
|
144
|
+
else
|
145
|
+
raise "illegal method descriptor. descriptor=" << descriptor
|
146
|
+
end
|
147
|
+
return res
|
148
|
+
end
|
149
|
+
#
|
150
|
+
#=== コードの文字列表現を得る。
|
151
|
+
#*code::コード
|
152
|
+
#<b>戻り値</b>::コードの文字列表現
|
153
|
+
#
|
154
|
+
def convert_code( code )
|
155
|
+
str = nil
|
156
|
+
case code
|
157
|
+
when 0x00; str = "nop"
|
158
|
+
when 0x01; str = "aconst_null"
|
159
|
+
when 0x02; str = "iconst_m1"
|
160
|
+
when 0x03; str = "iconst_0"
|
161
|
+
when 0x04; str = "iconst_1"
|
162
|
+
when 0x05; str = "iconst_2"
|
163
|
+
when 0x06; str = "iconst_3"
|
164
|
+
when 0x07; str = "iconst_4"
|
165
|
+
when 0x08; str = "iconst_5"
|
166
|
+
when 0x09; str = "lconst_0"
|
167
|
+
when 0x0a; str = "lconst_1"
|
168
|
+
when 0x0b; str = "fconst_0"
|
169
|
+
when 0x0c; str = "fconst_1"
|
170
|
+
when 0x0d; str = "fconst_2"
|
171
|
+
when 0x0e; str = "dconst_0"
|
172
|
+
when 0x0f; str = "dconst_1"
|
173
|
+
when 0x10; str = "bipush"
|
174
|
+
when 0x11; str = "sipush"
|
175
|
+
when 0x12; str = "ldc"
|
176
|
+
when 0x13; str = "ldc_w"
|
177
|
+
when 0x14; str = "ldc2_w"
|
178
|
+
when 0x15; str = "iload"
|
179
|
+
when 0x16; str = "lload"
|
180
|
+
when 0x17; str = "fload"
|
181
|
+
when 0x18; str = "dload"
|
182
|
+
when 0x19; str = "aload"
|
183
|
+
when 0x1a; str = "iload_0"
|
184
|
+
when 0x1b; str = "iload_1"
|
185
|
+
when 0x1c; str = "iload_2"
|
186
|
+
when 0x1d; str = "iload_3"
|
187
|
+
when 0x1e; str = "lload_0"
|
188
|
+
when 0x1f; str = "lload_1"
|
189
|
+
when 0x20; str = "lload_2"
|
190
|
+
when 0x21; str = "lload_3"
|
191
|
+
when 0x22; str = "fload_0"
|
192
|
+
when 0x23; str = "fload_1"
|
193
|
+
when 0x24; str = "fload_2"
|
194
|
+
when 0x25; str = "fload_3"
|
195
|
+
when 0x26; str = "dload_0"
|
196
|
+
when 0x27; str = "dload_1"
|
197
|
+
when 0x28; str = "dload_2"
|
198
|
+
when 0x29; str = "dload_3"
|
199
|
+
when 0x2a; str = "aload_0"
|
200
|
+
when 0x2b; str = "aload_1"
|
201
|
+
when 0x2c; str = "aload_2"
|
202
|
+
when 0x2d; str = "aload_3"
|
203
|
+
when 0x2e; str = "iaload"
|
204
|
+
when 0x2f; str = "laload"
|
205
|
+
when 0x30; str = "faload"
|
206
|
+
when 0x31; str = "daload"
|
207
|
+
when 0x32; str = "aaload"
|
208
|
+
when 0x33; str = "baload"
|
209
|
+
when 0x34; str = "caload"
|
210
|
+
when 0x35; str = "saload"
|
211
|
+
when 0x36; str = "istore"
|
212
|
+
when 0x37; str = "lstore"
|
213
|
+
when 0x38; str = "fstore"
|
214
|
+
when 0x39; str = "dstore"
|
215
|
+
when 0x3a; str = "astore"
|
216
|
+
when 0x3b; str = "istore_0"
|
217
|
+
when 0x3c; str = "istore_1"
|
218
|
+
when 0x3d; str = "istore_2"
|
219
|
+
when 0x3e; str = "istore_3"
|
220
|
+
when 0x3f; str = "lstore_0"
|
221
|
+
when 0x40; str = "lstore_1"
|
222
|
+
when 0x41; str = "lstore_2"
|
223
|
+
when 0x42; str = "lstore_3"
|
224
|
+
when 0x43; str = "fstore_0"
|
225
|
+
when 0x44; str = "fstore_1"
|
226
|
+
when 0x45; str = "fstore_2"
|
227
|
+
when 0x46; str = "fstore_3"
|
228
|
+
when 0x47; str = "dstore_0"
|
229
|
+
when 0x48; str = "dstore_1"
|
230
|
+
when 0x49; str = "dstore_2"
|
231
|
+
when 0x4a; str = "dstore_3"
|
232
|
+
when 0x4b; str = "astore_0"
|
233
|
+
when 0x4c; str = "astore_1"
|
234
|
+
when 0x4d; str = "astore_2"
|
235
|
+
when 0x4e; str = "astore_3"
|
236
|
+
when 0x4f; str = "iastore"
|
237
|
+
when 0x50; str = "lastore"
|
238
|
+
when 0x51; str = "fastore"
|
239
|
+
when 0x52; str = "dastore"
|
240
|
+
when 0x53; str = "aastore"
|
241
|
+
when 0x54; str = "bastore"
|
242
|
+
when 0x55; str = "castore"
|
243
|
+
when 0x56; str = "sastore"
|
244
|
+
when 0x57; str = "pop"
|
245
|
+
when 0x58; str = "pop2"
|
246
|
+
when 0x59; str = "dup"
|
247
|
+
when 0x5a; str = "dup_x1"
|
248
|
+
when 0x5b; str = "dup_x2"
|
249
|
+
when 0x5c; str = "dup2"
|
250
|
+
when 0x5d; str = "dup2_x1"
|
251
|
+
when 0x5e; str = "dup2_x2"
|
252
|
+
when 0x5f; str = "swap"
|
253
|
+
when 0x60; str = "iadd"
|
254
|
+
when 0x61; str = "ladd"
|
255
|
+
when 0x62; str = "fadd"
|
256
|
+
when 0x63; str = "dadd"
|
257
|
+
when 0x64; str = "isub"
|
258
|
+
when 0x65; str = "lsub"
|
259
|
+
when 0x66; str = "fsub"
|
260
|
+
when 0x67; str = "dsub"
|
261
|
+
when 0x68; str = "imul"
|
262
|
+
when 0x69; str = "lmul"
|
263
|
+
when 0x6a; str = "fmul"
|
264
|
+
when 0x6b; str = "dmul"
|
265
|
+
when 0x6c; str = "idiv"
|
266
|
+
when 0x6d; str = "ldiv"
|
267
|
+
when 0x6e; str = "fdiv"
|
268
|
+
when 0x6f; str = "ddiv"
|
269
|
+
when 0x70; str = "irem"
|
270
|
+
when 0x71; str = "lrem"
|
271
|
+
when 0x72; str = "frem"
|
272
|
+
when 0x73; str = "drem"
|
273
|
+
when 0x75; str = "lneg"
|
274
|
+
when 0x76; str = "fneg"
|
275
|
+
when 0x77; str = "dneg"
|
276
|
+
when 0x78; str = "ishl"
|
277
|
+
when 0x79; str = "lshl"
|
278
|
+
when 0x7a; str = "ishr"
|
279
|
+
when 0x7b; str = "lshr"
|
280
|
+
when 0x7c; str = "iushr"
|
281
|
+
when 0x7d; str = "lushr"
|
282
|
+
when 0x7e; str = "iand"
|
283
|
+
when 0x7f; str = "land"
|
284
|
+
when 0x80; str = "ior"
|
285
|
+
when 0x81; str = "lor"
|
286
|
+
when 0x82; str = "ixor"
|
287
|
+
when 0x83; str = "lxor"
|
288
|
+
when 0x84; str = "iinc"
|
289
|
+
when 0x85; str = "i2l"
|
290
|
+
when 0x86; str = "i2f"
|
291
|
+
when 0x87; str = "i2d"
|
292
|
+
when 0x88; str = "l2i"
|
293
|
+
when 0x89; str = "l2f"
|
294
|
+
when 0x8a; str = "l2d"
|
295
|
+
when 0x8b; str = "f2i"
|
296
|
+
when 0x8c; str = "f2l"
|
297
|
+
when 0x8d; str = "f2d"
|
298
|
+
when 0x8e; str = "d2i"
|
299
|
+
when 0x8f; str = "d2l"
|
300
|
+
when 0x90; str = "d2f"
|
301
|
+
when 0x91; str = "i2b"
|
302
|
+
when 0x92; str = "i2c"
|
303
|
+
when 0x93; str = "i2s"
|
304
|
+
when 0x94; str = "lcmp"
|
305
|
+
when 0x95; str = "fcmpl"
|
306
|
+
when 0x96; str = "fcmpg"
|
307
|
+
when 0x97; str = "dcmpl"
|
308
|
+
when 0x98; str = "dcmpg"
|
309
|
+
when 0x99; str = "ifeq"
|
310
|
+
when 0x9a; str = "ifne"
|
311
|
+
when 0x9b; str = "iflt"
|
312
|
+
when 0x9c; str = "ifge"
|
313
|
+
when 0x9d; str = "ifgt"
|
314
|
+
when 0x9e; str = "ifle"
|
315
|
+
when 0x9f; str = "if_icmpeq"
|
316
|
+
when 0xa0; str = "if_icmpne"
|
317
|
+
when 0xa1; str = "if_icmplt"
|
318
|
+
when 0xa2; str = "if_icmpge"
|
319
|
+
when 0xa3; str = "if_icmpgt"
|
320
|
+
when 0xa4; str = "if_icmple"
|
321
|
+
when 0xa5; str = "if_acmpeq"
|
322
|
+
when 0xa6; str = "if_acmpne"
|
323
|
+
when 0xa7; str = "goto"
|
324
|
+
when 0xa8; str = "jsr"
|
325
|
+
when 0xa9; str = "ret"
|
326
|
+
when 0xaa; str = "tableswitch"
|
327
|
+
when 0xab; str = "lookupswitch"
|
328
|
+
when 0xac; str = "ireturn"
|
329
|
+
when 0xad; str = "lreturn"
|
330
|
+
when 0xae; str = "freturn"
|
331
|
+
when 0xaf; str = "dreturn"
|
332
|
+
when 0xb0; str = "areturn"
|
333
|
+
when 0xb1; str = "return"
|
334
|
+
when 0xb2; str = "getstatic"
|
335
|
+
when 0xb3; str = "putstatic"
|
336
|
+
when 0xb4; str = "getfield"
|
337
|
+
when 0xb5; str = "putfield"
|
338
|
+
when 0xb6; str = "invokevirtual"
|
339
|
+
when 0xb7; str = "invokespecial"
|
340
|
+
when 0xb8; str = "invokestatic"
|
341
|
+
when 0xb9; str = "invokeinterface"
|
342
|
+
when 0xba; str = "xxxunusedxxx1"
|
343
|
+
when 0xbb; str = "new"
|
344
|
+
when 0xbc; str = "newarray"
|
345
|
+
when 0xbd; str = "anewarray"
|
346
|
+
when 0xbe; str = "arraylength"
|
347
|
+
when 0xbf; str = "athrow"
|
348
|
+
when 0xc0; str = "checkcast"
|
349
|
+
when 0xc1; str = "instanceof"
|
350
|
+
when 0xc2; str = "monitorenter"
|
351
|
+
when 0xc3; str = "monitorexit"
|
352
|
+
when 0xc4; str = "wide"
|
353
|
+
when 0xc5; str = "multianewarray"
|
354
|
+
when 0xc6; str = "ifnull"
|
355
|
+
when 0xc7; str = "ifnonnull"
|
356
|
+
when 0xc8; str = "goto_w"
|
357
|
+
when 0xc9; str = "jsr_w"
|
358
|
+
when 0xca; str = "breakpoint"
|
359
|
+
when 0xfe; str = "impdep1"
|
360
|
+
when 0xff; str = "impdep2"
|
361
|
+
else
|
362
|
+
aise "unknown code. code=" << code.to_s
|
363
|
+
end
|
364
|
+
return str;
|
365
|
+
end
|
366
|
+
|
367
|
+
end
|
368
|
+
|
369
369
|
end
|