furnace-avm2 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -3
- data/lib/avm2/abc/metadata/instance_info.rb +4 -0
- data/lib/avm2/abc/metadata/klass_info.rb +12 -0
- data/lib/avm2/abc/metadata/method_info.rb +1 -2
- data/lib/avm2/abc/metadata/option_detail.rb +2 -22
- data/lib/avm2/abc/metadata/record_with_traits.rb +19 -1
- data/lib/avm2/abc/metadata/trait_slot.rb +63 -5
- data/lib/avm2/abc/opcodes/arithmetic/as3_equals.rb +1 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_greaterequals.rb +1 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_greaterthan.rb +1 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_lessequals.rb +1 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_lessthan.rb +1 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_not.rb +1 -0
- data/lib/avm2/abc/opcodes/arithmetic/as3_strictequals.rb +1 -0
- data/lib/avm2/abc/opcodes/opcode.rb +2 -0
- data/lib/avm2/transform/ast_normalize.rb +14 -2
- data/lib/avm2/version.rb +1 -1
- metadata +6 -6
data/Gemfile.lock
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
module AVM2::ABC
|
2
2
|
class KlassInfo < Record
|
3
|
+
include RecordWithTraits
|
4
|
+
|
3
5
|
root_ref :initializer, :method
|
4
6
|
|
5
7
|
abc_array_of :trait, :nested, :class => TraitInfo
|
8
|
+
|
9
|
+
def to_astlet
|
10
|
+
root = AST::Node.new(:klass)
|
11
|
+
|
12
|
+
if traits.any?
|
13
|
+
root.children << AST::Node.new(:traits, traits.map(&:to_astlet))
|
14
|
+
end
|
15
|
+
|
16
|
+
root.normalize_hierarchy!
|
17
|
+
end
|
6
18
|
end
|
7
19
|
end
|
@@ -27,9 +27,8 @@ module AVM2::ABC
|
|
27
27
|
|
28
28
|
def to_astlet(index, name=nil)
|
29
29
|
root = AST::Node.new(:method)
|
30
|
-
root.metadata = {
|
30
|
+
root.metadata = { method: self, label: index }
|
31
31
|
|
32
|
-
root.children << index
|
33
32
|
root.children << name || self.name
|
34
33
|
|
35
34
|
if return_type
|
@@ -1,26 +1,6 @@
|
|
1
1
|
module AVM2::ABC
|
2
2
|
class OptionDetail < Record
|
3
|
-
|
4
|
-
:
|
5
|
-
:UInt => 0x04,
|
6
|
-
:Double => 0x06,
|
7
|
-
:Utf8 => 0x01,
|
8
|
-
:True => 0x0B,
|
9
|
-
:False => 0x0A,
|
10
|
-
:Null => 0x0C,
|
11
|
-
:Undefined => 0x00,
|
12
|
-
:Namespace => 0x08,
|
13
|
-
:PackageNamespace => 0x16,
|
14
|
-
:PackageInternalNs => 0x17,
|
15
|
-
:ProtectedNamespace => 0x18,
|
16
|
-
:ExplicitNamespace => 0x19,
|
17
|
-
:StaticProtectedNs => 0x1A,
|
18
|
-
:PrivateNs => 0x05,
|
19
|
-
}
|
20
|
-
|
21
|
-
vuint30 :val
|
22
|
-
|
23
|
-
uint8 :kind_raw
|
24
|
-
xlat_field :kind
|
3
|
+
vuint30 :value_idx
|
4
|
+
uint8 :value_kind_raw
|
25
5
|
end
|
26
6
|
end
|
@@ -1,9 +1,27 @@
|
|
1
1
|
module AVM2::ABC
|
2
2
|
module RecordWithTraits
|
3
3
|
TraitInfo::XlatTable.keys.each do |trait_type|
|
4
|
-
|
4
|
+
basename = trait_type.to_s.downcase
|
5
|
+
|
6
|
+
define_method :"#{basename}_traits" do
|
5
7
|
traits.select { |trait| trait.kind == trait_type }
|
6
8
|
end
|
9
|
+
|
10
|
+
define_method :"#{basename}_trait" do |name|
|
11
|
+
case name
|
12
|
+
when String
|
13
|
+
traits.find { |trait| trait.name.to_s == name }
|
14
|
+
when AST::Node
|
15
|
+
traits.find { |trait| trait.name.to_astlet == name }
|
16
|
+
else
|
17
|
+
traits.find { |trait| trait.name == name }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
define_method :"#{basename}_trait!" do |name|
|
22
|
+
send(:"#{basename}_trait", name) or
|
23
|
+
raise "trait #{name} not found"
|
24
|
+
end
|
7
25
|
end
|
8
26
|
|
9
27
|
def codes_to_ast
|
@@ -1,13 +1,71 @@
|
|
1
1
|
module AVM2::ABC
|
2
2
|
class TraitSlot < Record
|
3
|
-
|
4
|
-
|
3
|
+
XlatTable = {
|
4
|
+
:Int => 0x03,
|
5
|
+
:UInt => 0x04,
|
6
|
+
:Double => 0x06,
|
7
|
+
:Utf8 => 0x01,
|
8
|
+
:True => 0x0B,
|
9
|
+
:False => 0x0A,
|
10
|
+
:Null => 0x0C,
|
11
|
+
:Undefined => 0x00,
|
12
|
+
:Namespace => 0x08,
|
13
|
+
:PackageNamespace => 0x16,
|
14
|
+
:PackageInternalNs => 0x17,
|
15
|
+
:ProtectedNamespace => 0x18,
|
16
|
+
:ExplicitNamespace => 0x19,
|
17
|
+
:StaticProtectedNs => 0x1A,
|
18
|
+
:PrivateNs => 0x05,
|
19
|
+
}
|
5
20
|
|
6
|
-
vuint30
|
7
|
-
|
21
|
+
vuint30 :idx
|
22
|
+
const_ref :type, :multiname
|
23
|
+
|
24
|
+
vuint30 :value_idx
|
25
|
+
|
26
|
+
uint8 :value_kind_raw, :if => lambda { value_idx != 0 }
|
27
|
+
xlat_field :value_kind
|
8
28
|
|
9
29
|
def to_astlet(trait)
|
10
|
-
AST::Node.new(:slot, [ trait.name.to_astlet, type.to_astlet, idx ])
|
30
|
+
AST::Node.new(:slot, [ (trait.name ? trait.name.to_astlet : nil), (type ? type.to_astlet : nil), value, idx ])
|
31
|
+
end
|
32
|
+
|
33
|
+
def value
|
34
|
+
if value_idx > 0
|
35
|
+
case value_kind
|
36
|
+
when :Int
|
37
|
+
AST::Node.new(:integer, [ root.constant_pool.ints[value_idx - 1] ])
|
38
|
+
when :UInt
|
39
|
+
AST::Node.new(:integer, [ root.constant_pool.uints[value_idx - 1] ])
|
40
|
+
when :Double
|
41
|
+
AST::Node.new(:integer, [ root.constant_pool.doubles[value_idx - 1] ])
|
42
|
+
when :Utf8
|
43
|
+
AST::Node.new(:integer, [ root.constant_pool.strings[value_idx - 1] ])
|
44
|
+
when :True
|
45
|
+
AST::Node.new(:true)
|
46
|
+
when :False
|
47
|
+
AST::Node.new(:false)
|
48
|
+
when :Null
|
49
|
+
AST::Node.new(:null)
|
50
|
+
when :Undefined
|
51
|
+
AST::Node.new(:undefined)
|
52
|
+
else
|
53
|
+
raise "unknown value kind #{value_kind}"
|
54
|
+
end
|
55
|
+
else
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def ruby_value
|
61
|
+
astlet_value = self.value
|
62
|
+
if astlet_value
|
63
|
+
if astlet_value.children.count > 0
|
64
|
+
astlet_value.children.first
|
65
|
+
else
|
66
|
+
astlet_value.name
|
67
|
+
end
|
68
|
+
end
|
11
69
|
end
|
12
70
|
end
|
13
71
|
end
|
@@ -31,8 +31,20 @@ module AVM2
|
|
31
31
|
|
32
32
|
# (if-* a b) -> (*' a b)
|
33
33
|
IF_MAPPING = {
|
34
|
-
:eq
|
35
|
-
:
|
34
|
+
:eq => [false, :==],
|
35
|
+
:ne => [true, :==],
|
36
|
+
:ge => [false, :>=],
|
37
|
+
:nge => [true, :>=],
|
38
|
+
:gt => [false, :>],
|
39
|
+
:ngt => [true, :>],
|
40
|
+
:le => [false, :<=],
|
41
|
+
:nle => [true, :<=],
|
42
|
+
:lt => [false, :<],
|
43
|
+
:nlt => [true, :<],
|
44
|
+
:stricteq => [false, :===],
|
45
|
+
:strictne => [true, :===],
|
46
|
+
:true => [false, :expand],
|
47
|
+
:false => [true, :expand],
|
36
48
|
}
|
37
49
|
IF_MAPPING.each do |cond, (reverse, comp)|
|
38
50
|
define_method :"on_if_#{cond}" do |node|
|
data/lib/avm2/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: furnace-avm2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: furnace
|
16
|
-
requirement: &
|
16
|
+
requirement: &79918900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.0.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *79918900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: trollop
|
27
|
-
requirement: &
|
27
|
+
requirement: &79918360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *79918360
|
36
36
|
description: furnace-avm2 allows one to load, modify and write backFlash ActionScript3
|
37
37
|
bytecode. It can also decompile it.
|
38
38
|
email:
|