furnace-avm2 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/bin/furnace-avm2 +5 -1
- data/bin/furnace-avm2-decompiler +80 -13
- data/bin/furnace-avm2-shell +32 -0
- data/furnace-avm2.gemspec +1 -1
- data/lib/furnace-avm2/abc.rb +1 -7
- data/lib/furnace-avm2/abc/metadata/file.rb +65 -0
- data/lib/furnace-avm2/abc/metadata/instance_info.rb +17 -11
- data/lib/furnace-avm2/abc/metadata/metadata_info.rb +14 -4
- data/lib/furnace-avm2/abc/metadata/method_body_info.rb +11 -3
- data/lib/furnace-avm2/abc/metadata/method_info.rb +3 -4
- data/lib/furnace-avm2/abc/metadata/multiname_kind_genericname.rb +3 -2
- data/lib/furnace-avm2/abc/metadata/multiname_kind_multiname.rb +11 -2
- data/lib/furnace-avm2/abc/metadata/multiname_kind_multinamel.rb +4 -0
- data/lib/furnace-avm2/abc/metadata/multiname_kind_qname.rb +10 -2
- data/lib/furnace-avm2/abc/metadata/multiname_kind_rtqname.rb +4 -0
- data/lib/furnace-avm2/abc/metadata/multiname_kind_rtqnamel.rb +4 -0
- data/lib/furnace-avm2/abc/metadata/script_info.rb +11 -7
- data/lib/furnace-avm2/abc/metadata/trait_class.rb +2 -2
- data/lib/furnace-avm2/abc/metadata/trait_info.rb +1 -1
- data/lib/furnace-avm2/abc/metadata/trait_method.rb +4 -3
- data/lib/furnace-avm2/abc/metadata/trait_slot.rb +2 -2
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_extend_1.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_extend_16.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_extend_8.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_load_float32.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_load_float64.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_load_int16.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_load_int32.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_load_int8.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_store_float32.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_store_float64.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_store_int16.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_store_int32.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/alchemy/alchemy_store_int8.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_add.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_add_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_declocal.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_declocal_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_decrement.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_decrement_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_divide.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_equals.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_greaterequals.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_greaterthan.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_inclocal.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_inclocal_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_increment.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_increment_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_lessequals.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_lessthan.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_modulo.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_multiply.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_multiply_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_negate.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_negate_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_not.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_strictequals.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_subtract.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/arithmetic/as3_subtract_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_bitand.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_bitnot.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_bitor.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_bitxor.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_lshift.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_rshift.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/bitwise/as3_urshift.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/control_transfer/as3_lookupswitch.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/control_transfer_opcode.rb +0 -4
- data/lib/furnace-avm2/abc/opcodes/exception/as3_newcatch.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/function_invocation/as3_callproplex.rb +4 -0
- data/lib/furnace-avm2/abc/opcodes/function_invocation_opcode.rb +4 -0
- data/lib/furnace-avm2/abc/opcodes/function_return/as3_returnvalue.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/function_return/as3_returnvoid.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/generic/as3_escxattr.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/generic/as3_escxelem.rb +8 -0
- data/lib/furnace-avm2/abc/opcodes/generic/as3_getlex.rb +4 -0
- data/lib/furnace-avm2/abc/opcodes/object_manipulation/as3_newfunction.rb +5 -1
- data/lib/furnace-avm2/abc/opcodes/property/as3_constructprop.rb +4 -0
- data/lib/furnace-avm2/abc/opcodes/property_opcode.rb +4 -0
- data/lib/furnace-avm2/abc/opcodes/push_literal/as3_pushuint.rb +11 -0
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_applytype.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_coerce.rb +5 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_coerce_a.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_coerce_b.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_coerce_s.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_convert_d.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_convert_i.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_convert_o.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_convert_s.rb +1 -1
- data/lib/furnace-avm2/abc/opcodes/type_conversion/as3_convert_u.rb +1 -1
- data/lib/furnace-avm2/abc/primitives/opcode_sequence.rb +35 -23
- data/lib/furnace-avm2/abc/primitives/record.rb +11 -0
- data/lib/furnace-avm2/binary/record.rb +9 -7
- data/lib/furnace-avm2/source/declaration_tokens/callee_token.rb +8 -5
- data/lib/furnace-avm2/source/declaration_tokens/class_implementations_token.rb +5 -1
- data/lib/furnace-avm2/source/declaration_tokens/class_specifiers_token.rb +2 -1
- data/lib/furnace-avm2/source/declaration_tokens/class_token.rb +5 -1
- data/lib/furnace-avm2/source/declaration_tokens/metadata_token.rb +25 -0
- data/lib/furnace-avm2/source/declaration_tokens/method_specifiers_token.rb +4 -3
- data/lib/furnace-avm2/source/declaration_tokens/method_token.rb +1 -0
- data/lib/furnace-avm2/source/declaration_tokens/multiname_token.rb +28 -13
- data/lib/furnace-avm2/source/declaration_tokens/package_token.rb +9 -8
- data/lib/furnace-avm2/source/declaration_tokens/scope_token.rb +2 -0
- data/lib/furnace-avm2/source/declaration_tokens/script_token.rb +4 -1
- data/lib/furnace-avm2/source/declaration_tokens/slot_token.rb +1 -0
- data/lib/furnace-avm2/source/declaration_tokens/specifiers_token.rb +11 -9
- data/lib/furnace-avm2/source/decompiler.rb +372 -101
- data/lib/furnace-avm2/source/implementation_tokens/closure_name_token.rb +7 -0
- data/lib/furnace-avm2/source/implementation_tokens/closure_token.rb +9 -0
- data/lib/furnace-avm2/source/implementation_tokens/instance_of_token.rb +9 -0
- data/lib/furnace-avm2/source/implementation_tokens/supplementary_comment_token.rb +16 -0
- data/lib/furnace-avm2/source/implementation_tokens/xml_literal_token.rb +14 -0
- data/lib/furnace-avm2/transform/ast_build.rb +3 -2
- data/lib/furnace-avm2/transform/ast_normalize.rb +39 -7
- data/lib/furnace-avm2/transform/cfg_build.rb +16 -6
- data/lib/furnace-avm2/transform/cfg_reduce.rb +4 -3
- data/lib/furnace-avm2/transform/nf_normalize.rb +15 -7
- data/lib/furnace-avm2/version.rb +1 -1
- data/test/basic.as +15 -0
- data/test/global.as +11 -0
- metadata +46 -29
- data/bin/furnace-avm2-benchmark +0 -38
- data/lib/furnace-avm2/abc/opcodes/arithmetic_opcode.rb +0 -4
- data/lib/furnace-avm2/abc/opcodes/bitwise_opcode.rb +0 -4
- data/lib/furnace-avm2/abc/opcodes/exception_opcode.rb +0 -4
- data/lib/furnace-avm2/abc/opcodes/function_return_opcode.rb +0 -4
- data/lib/furnace-avm2/abc/opcodes/object_manipulation_opcode.rb +0 -4
- data/lib/furnace-avm2/abc/opcodes/type_conversion_opcode.rb +0 -4
@@ -1,5 +1,5 @@
|
|
1
1
|
module Furnace::AVM2::ABC
|
2
|
-
class AS3Coerce <
|
2
|
+
class AS3Coerce < Opcode
|
3
3
|
instruction 0x80
|
4
4
|
|
5
5
|
body do
|
@@ -12,5 +12,9 @@ module Furnace::AVM2::ABC
|
|
12
12
|
def parameters
|
13
13
|
[ body.type.to_astlet ]
|
14
14
|
end
|
15
|
+
|
16
|
+
def collect_ns(options)
|
17
|
+
body.type.collect_ns(options)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
1
3
|
module Furnace::AVM2::ABC
|
2
4
|
class OpcodeSequence < ::Array
|
3
5
|
attr_reader :root, :parent
|
@@ -91,44 +93,47 @@ module Furnace::AVM2::ABC
|
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
pending_label = nil
|
97
|
+
pending_queue = []
|
98
|
+
|
99
|
+
cutoff = lambda do |targets|
|
100
|
+
node = CFG::Node.new(graph, pending_label, pending_queue, nil, targets)
|
97
101
|
|
98
|
-
|
99
|
-
|
102
|
+
if graph.nodes.empty?
|
103
|
+
graph.entry = node
|
100
104
|
end
|
105
|
+
|
106
|
+
graph.nodes.add node
|
107
|
+
|
108
|
+
pending_label = nil
|
109
|
+
pending_queue = []
|
101
110
|
end
|
102
111
|
|
103
112
|
each do |opcode|
|
104
113
|
if targets.include? opcode
|
105
|
-
|
114
|
+
cutoff.([ opcode.offset ])
|
106
115
|
end
|
107
116
|
|
108
|
-
|
117
|
+
pending_label = opcode.offset if pending_label.nil?
|
118
|
+
pending_queue << opcode
|
109
119
|
|
110
120
|
if opcode.is_a? ControlTransferOpcode
|
111
121
|
if opcode.conditional
|
112
|
-
|
113
|
-
false => opcode.offset + opcode.byte_length })
|
122
|
+
cutoff.([ opcode.target.offset, opcode.offset + opcode.byte_length ])
|
114
123
|
else
|
115
|
-
|
124
|
+
cutoff.([ opcode.target.offset ])
|
116
125
|
end
|
117
126
|
elsif opcode.is_a? AS3LookupSwitch
|
118
|
-
|
119
|
-
|
120
|
-
opcode.case_targets.each_with_index do |target, index|
|
121
|
-
map[index] = target.offset
|
122
|
-
end
|
123
|
-
|
124
|
-
graph.transfer map
|
127
|
+
cutoff.(opcode.parameters.flatten)
|
125
128
|
end
|
126
129
|
end
|
127
130
|
|
128
|
-
|
131
|
+
cutoff.([])
|
129
132
|
|
130
|
-
exceptions.
|
131
|
-
|
133
|
+
if exceptions.any?
|
134
|
+
exception_node = CFG::Node.new(graph, :exception, [], nil,
|
135
|
+
exceptions.map(&:target_offset))
|
136
|
+
graph.nodes.add exception_node
|
132
137
|
end
|
133
138
|
|
134
139
|
graph
|
@@ -138,9 +143,16 @@ module Furnace::AVM2::ABC
|
|
138
143
|
cfg = build_cfg
|
139
144
|
dead_opcodes = []
|
140
145
|
|
141
|
-
cfg.nodes.
|
142
|
-
|
143
|
-
|
146
|
+
worklist = cfg.nodes.dup
|
147
|
+
while worklist.any?
|
148
|
+
node = worklist.first
|
149
|
+
worklist.delete node
|
150
|
+
|
151
|
+
next if node == cfg.entry
|
152
|
+
|
153
|
+
if node.sources.count == 0 ||
|
154
|
+
node.sources == [node]
|
155
|
+
dead_opcodes.concat node.insns
|
144
156
|
end
|
145
157
|
end
|
146
158
|
|
@@ -29,6 +29,17 @@ module Furnace::AVM2::ABC
|
|
29
29
|
root.constant_pool.send(array)[index - 1]
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
define_method(:"#{name}=") do |value|
|
34
|
+
pool = root.constant_pool.send(array)
|
35
|
+
if value.nil?
|
36
|
+
send(:"#{field}=", 0)
|
37
|
+
elsif index = pool.index(value)
|
38
|
+
send(:"#{field}=", index + 1)
|
39
|
+
else
|
40
|
+
raise "cpool setter: no such object in cpool"
|
41
|
+
end
|
42
|
+
end
|
32
43
|
end
|
33
44
|
end
|
34
45
|
|
@@ -161,7 +161,7 @@ module Furnace::AVM2::Binary
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def inspect
|
164
|
-
|
164
|
+
"AVM2Record(#{self.class.name.split("::").last})"
|
165
165
|
end
|
166
166
|
|
167
167
|
def byte_length
|
@@ -260,7 +260,7 @@ module Furnace::AVM2::Binary
|
|
260
260
|
end
|
261
261
|
|
262
262
|
def length_vint32(value, options)
|
263
|
-
length_vint(value)
|
263
|
+
length_vint(value, true)
|
264
264
|
end
|
265
265
|
|
266
266
|
# vuint32
|
@@ -270,11 +270,11 @@ module Furnace::AVM2::Binary
|
|
270
270
|
end
|
271
271
|
|
272
272
|
def write_vuint32(io, value, options)
|
273
|
-
write_vint(io, value,
|
273
|
+
write_vint(io, value, false)
|
274
274
|
end
|
275
275
|
|
276
276
|
def length_vuint32(value, options)
|
277
|
-
length_vint(value)
|
277
|
+
length_vint(value, false)
|
278
278
|
end
|
279
279
|
|
280
280
|
# vuint30
|
@@ -284,11 +284,11 @@ module Furnace::AVM2::Binary
|
|
284
284
|
end
|
285
285
|
|
286
286
|
def write_vuint30(io, value, options)
|
287
|
-
write_vint(io, value,
|
287
|
+
write_vint(io, value, false)
|
288
288
|
end
|
289
289
|
|
290
290
|
def length_vuint30(value, options)
|
291
|
-
length_vint(value)
|
291
|
+
length_vint(value, false)
|
292
292
|
end
|
293
293
|
|
294
294
|
# vstring
|
@@ -468,7 +468,9 @@ module Furnace::AVM2::Binary
|
|
468
468
|
io.write bytes.pack("C*")
|
469
469
|
end
|
470
470
|
|
471
|
-
def length_vint(value)
|
471
|
+
def length_vint(value, signed)
|
472
|
+
value = value & 0xffffffff
|
473
|
+
|
472
474
|
length = 0
|
473
475
|
|
474
476
|
begin
|