furnace-avm2 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +17 -0
- data/abcdump.abc +0 -0
- data/bin/furnace-avm2 +175 -0
- data/bin/furnace-avm2-benchmark +38 -0
- data/darkorbit.abc +0 -0
- data/furnace-avm2.gemspec +22 -0
- data/lib/avm2.rb +13 -0
- data/lib/avm2/abc.rb +65 -0
- data/lib/avm2/abc/metadata/const_pool_info.rb +18 -0
- data/lib/avm2/abc/metadata/exception_info.rb +29 -0
- data/lib/avm2/abc/metadata/file.rb +27 -0
- data/lib/avm2/abc/metadata/instance_info.rb +53 -0
- data/lib/avm2/abc/metadata/klass_info.rb +7 -0
- data/lib/avm2/abc/metadata/metadata_info.rb +9 -0
- data/lib/avm2/abc/metadata/method_body_info.rb +31 -0
- data/lib/avm2/abc/metadata/method_info.rb +57 -0
- data/lib/avm2/abc/metadata/multiname_info.rb +42 -0
- data/lib/avm2/abc/metadata/multiname_kind_genericname.rb +16 -0
- data/lib/avm2/abc/metadata/multiname_kind_multiname.rb +18 -0
- data/lib/avm2/abc/metadata/multiname_kind_multinamel.rb +17 -0
- data/lib/avm2/abc/metadata/multiname_kind_qname.rb +44 -0
- data/lib/avm2/abc/metadata/multiname_kind_rtqname.rb +17 -0
- data/lib/avm2/abc/metadata/multiname_kind_rtqnamel.rb +11 -0
- data/lib/avm2/abc/metadata/namespace_info.rb +22 -0
- data/lib/avm2/abc/metadata/ns_set_info.rb +13 -0
- data/lib/avm2/abc/metadata/option_detail.rb +26 -0
- data/lib/avm2/abc/metadata/option_info.rb +5 -0
- data/lib/avm2/abc/metadata/script_info.rb +7 -0
- data/lib/avm2/abc/metadata/trait_class.rb +9 -0
- data/lib/avm2/abc/metadata/trait_function.rb +9 -0
- data/lib/avm2/abc/metadata/trait_info.rb +55 -0
- data/lib/avm2/abc/metadata/trait_method.rb +12 -0
- data/lib/avm2/abc/metadata/trait_slot.rb +11 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_add.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_add_i.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_declocal.rb +14 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_declocal_i.rb +14 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_decrement.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_decrement_i.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_divide.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_equals.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_greaterequals.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_greaterthan.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_inclocal.rb +14 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_inclocal_i.rb +18 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_increment.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_increment_i.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_lessequals.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_lessthan.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_modulo.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_multiply.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_multiply_i.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_negate.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_negate_i.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_not.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_strictequals.rb +8 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_subtract.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_subtract_i.rb +10 -0
- data/lib/avm2/abc/opcodes/arithmetic_opcode.rb +4 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_bitand.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_bitnot.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_bitor.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_bitxor.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_lshift.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_rshift.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise/as3_urshift.rb +8 -0
- data/lib/avm2/abc/opcodes/bitwise_opcode.rb +4 -0
- data/lib/avm2/abc/opcodes/contextual_opcode.rb +32 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifeq.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_iffalse.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifge.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifgt.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifle.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_iflt.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifne.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifnge.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifngt.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifnle.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifnlt.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifstricteq.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_ifstrictne.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_iftrue.rb +14 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_jump.rb +22 -0
- data/lib/avm2/abc/opcodes/control_transfer/as3_lookupswitch.rb +34 -0
- data/lib/avm2/abc/opcodes/control_transfer_opcode.rb +37 -0
- data/lib/avm2/abc/opcodes/exception/as3_newcatch.rb +16 -0
- data/lib/avm2/abc/opcodes/exception_opcode.rb +4 -0
- data/lib/avm2/abc/opcodes/function_invocation/as3_call.rb +16 -0
- data/lib/avm2/abc/opcodes/function_invocation/as3_callproperty.rb +7 -0
- data/lib/avm2/abc/opcodes/function_invocation/as3_callpropvoid.rb +7 -0
- data/lib/avm2/abc/opcodes/function_invocation/as3_callsuper.rb +7 -0
- data/lib/avm2/abc/opcodes/function_invocation/as3_callsupervoid.rb +7 -0
- data/lib/avm2/abc/opcodes/function_invocation_opcode.rb +17 -0
- data/lib/avm2/abc/opcodes/function_return/as3_returnvalue.rb +8 -0
- data/lib/avm2/abc/opcodes/function_return/as3_returnvoid.rb +8 -0
- data/lib/avm2/abc/opcodes/function_return_opcode.rb +4 -0
- data/lib/avm2/abc/opcodes/generic/as3_astypelate.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_checkfilter.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_dup.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_dxnslate.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_escxattr.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_getglobalscope.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_getlex.rb +16 -0
- data/lib/avm2/abc/opcodes/generic/as3_getscopeobject.rb +16 -0
- data/lib/avm2/abc/opcodes/generic/as3_getslot.rb +16 -0
- data/lib/avm2/abc/opcodes/generic/as3_hasnext.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_hasnext2.rb +17 -0
- data/lib/avm2/abc/opcodes/generic/as3_in.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_instanceof.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_istypelate.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_kill.rb +16 -0
- data/lib/avm2/abc/opcodes/generic/as3_label.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_nextname.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_nextvalue.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_nop.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_pop.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_popscope.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_setslot.rb +16 -0
- data/lib/avm2/abc/opcodes/generic/as3_swap.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_throw.rb +8 -0
- data/lib/avm2/abc/opcodes/generic/as3_typeof.rb +8 -0
- data/lib/avm2/abc/opcodes/load_store/as3_getlocal.rb +15 -0
- data/lib/avm2/abc/opcodes/load_store/as3_getlocal_0.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_getlocal_1.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_getlocal_2.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_getlocal_3.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_setlocal.rb +15 -0
- data/lib/avm2/abc/opcodes/load_store/as3_setlocal_0.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_setlocal_1.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_setlocal_2.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store/as3_setlocal_3.rb +11 -0
- data/lib/avm2/abc/opcodes/load_store_opcode.rb +18 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_construct.rb +12 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_constructsuper.rb +16 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_newactivation.rb +8 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_newarray.rb +12 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_newclass.rb +12 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_newfunction.rb +12 -0
- data/lib/avm2/abc/opcodes/object_manipulation/as3_newobject.rb +12 -0
- data/lib/avm2/abc/opcodes/object_manipulation_opcode.rb +4 -0
- data/lib/avm2/abc/opcodes/opcode.rb +127 -0
- data/lib/avm2/abc/opcodes/property/as3_constructprop.rb +20 -0
- data/lib/avm2/abc/opcodes/property/as3_deleteproperty.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_findproperty.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_findpropstrict.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_getdescendants.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_getproperty.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_getsuper.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_initproperty.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_setproperty.rb +9 -0
- data/lib/avm2/abc/opcodes/property/as3_setsuper.rb +9 -0
- data/lib/avm2/abc/opcodes/property_opcode.rb +13 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushbyte.rb +11 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushdouble.rb +11 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushfalse.rb +7 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushint.rb +11 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushnan.rb +7 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushnull.rb +7 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushscope.rb +8 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushshort.rb +11 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushstring.rb +11 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushtrue.rb +7 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushundefined.rb +7 -0
- data/lib/avm2/abc/opcodes/push_literal/as3_pushwith.rb +8 -0
- data/lib/avm2/abc/opcodes/push_literal_opcode.rb +18 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_applytype.rb +12 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_coerce.rb +16 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_coerce_a.rb +8 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_coerce_b.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_coerce_s.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_convert_d.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_convert_i.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_convert_o.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_convert_s.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion/as3_convert_u.rb +10 -0
- data/lib/avm2/abc/opcodes/type_conversion_opcode.rb +4 -0
- data/lib/avm2/abc/primitives/opcode_sequence.rb +195 -0
- data/lib/avm2/abc/primitives/record.rb +132 -0
- data/lib/avm2/binary/choice_definition.rb +21 -0
- data/lib/avm2/binary/record.rb +469 -0
- data/lib/avm2/transform.rb +6 -0
- data/lib/avm2/transform/ast_build.rb +206 -0
- data/lib/avm2/transform/ast_normalize.rb +0 -0
- data/lib/avm2/version.rb +3 -0
- data/test/exception.abc +0 -0
- data/test/exception.as +29 -0
- data/test/literal.abc +0 -0
- data/test/literal.as +5 -0
- data/test/logic.abc +0 -0
- data/test/logic.as +23 -0
- data/test/loops.abc +0 -0
- data/test/loops.as +30 -0
- data/test/number.abc +0 -0
- data/test/number.as +14 -0
- data/test/switch.abc +0 -0
- data/test/switch.as +38 -0
- data/test/ternary.abc +0 -0
- data/test/ternary.as +22 -0
- metadata +579 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
module AVM2::ABC
|
2
|
+
class Opcode
|
3
|
+
MAP = {}
|
4
|
+
|
5
|
+
# Metamethods
|
6
|
+
|
7
|
+
def self.define_property(name, options={}, &block)
|
8
|
+
accessor_name = options[:accessor] || name
|
9
|
+
|
10
|
+
define_singleton_method(name) do |value=nil, &value_block|
|
11
|
+
if value_block
|
12
|
+
define_method(accessor_name) do
|
13
|
+
instance_exec &value_block
|
14
|
+
end
|
15
|
+
elsif !value.nil?
|
16
|
+
define_method(accessor_name) do
|
17
|
+
value
|
18
|
+
end
|
19
|
+
else
|
20
|
+
define_method(accessor_name) do
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
instance_exec(value, &block) if block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.body(&block)
|
30
|
+
@body_defined = true
|
31
|
+
|
32
|
+
klass = Class.new(Record)
|
33
|
+
klass.instance_exec &block
|
34
|
+
|
35
|
+
const_set :Body, klass
|
36
|
+
|
37
|
+
attr_accessor :body
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.mnemonic
|
41
|
+
@mnemonic ||= name.sub("AVM2::ABC::AS3", "")
|
42
|
+
end
|
43
|
+
|
44
|
+
# Common definitions
|
45
|
+
|
46
|
+
define_property :instruction do |encoding|
|
47
|
+
MAP[encoding] = self
|
48
|
+
end
|
49
|
+
|
50
|
+
define_property :consume_context, :accessor => :consumes_context
|
51
|
+
define_property :consume, :accessor => :consumes
|
52
|
+
define_property :produce, :accessor => :produces
|
53
|
+
|
54
|
+
define_property :type
|
55
|
+
define_property :special # swap, dup
|
56
|
+
|
57
|
+
attr_reader :sequence
|
58
|
+
|
59
|
+
def initialize(sequence)
|
60
|
+
@sequence = sequence
|
61
|
+
end
|
62
|
+
|
63
|
+
def root
|
64
|
+
@sequence.root
|
65
|
+
end
|
66
|
+
|
67
|
+
# Stream manipulation
|
68
|
+
|
69
|
+
def read(io)
|
70
|
+
if respond_to? :body
|
71
|
+
@body = self.class.const_get(:Body).new(:parent => @sequence)
|
72
|
+
@body.read(io)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def write(io)
|
77
|
+
io.write([ instruction ].pack("C"))
|
78
|
+
|
79
|
+
if respond_to? :body
|
80
|
+
@body.write(io)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def byte_length
|
85
|
+
if respond_to? :body
|
86
|
+
@body.byte_length + 1
|
87
|
+
else
|
88
|
+
1
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def offset
|
93
|
+
@sequence.offset_of(self)
|
94
|
+
end
|
95
|
+
|
96
|
+
def next
|
97
|
+
@sequence.opcode_at(offset + byte_length)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Attributes
|
101
|
+
|
102
|
+
def ast_type
|
103
|
+
self.class.mnemonic.
|
104
|
+
gsub(/^[A-Z]/) { |m| m[0].downcase }.
|
105
|
+
gsub(/([a-z])([A-Z])/) { |m| "#{m[0]}_#{m[1].downcase}" }
|
106
|
+
end
|
107
|
+
|
108
|
+
def consumes_context
|
109
|
+
false
|
110
|
+
end
|
111
|
+
|
112
|
+
def parameters
|
113
|
+
[]
|
114
|
+
end
|
115
|
+
|
116
|
+
# Disassembling
|
117
|
+
|
118
|
+
def disassemble_parameters
|
119
|
+
@body.to_hash if @body
|
120
|
+
end
|
121
|
+
|
122
|
+
def disassemble
|
123
|
+
" #{offset.to_s.rjust(4, "0")} #{self.class.mnemonic.rjust(20, " ")} #{disassemble_parameters} # params: #{parameters.inspect}"
|
124
|
+
end
|
125
|
+
alias :inspect :disassemble
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module AVM2::ABC
|
2
|
+
class AS3ConstructProperty < Opcode
|
3
|
+
include ContextualOpcode
|
4
|
+
|
5
|
+
instruction 0x4a
|
6
|
+
|
7
|
+
body do
|
8
|
+
const_ref :property, :multiname
|
9
|
+
vuint30 :arg_count
|
10
|
+
end
|
11
|
+
|
12
|
+
implicit_operand false
|
13
|
+
consume { body.arg_count }
|
14
|
+
produce 1
|
15
|
+
|
16
|
+
def disassemble_parameters
|
17
|
+
"#{body.property} #{body.arg_count}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|