Class: Furnace::AVM2::ABC::Opcode
- Inherits:
-
Object
- Object
- Furnace::AVM2::ABC::Opcode
show all
- Defined in:
- lib/furnace-avm2/abc/opcodes/opcode.rb
Direct Known Subclasses
AS3AlchemyExtend1, AS3AlchemyExtend16, AS3AlchemyExtend8, AS3AlchemyLoadFloat32, AS3AlchemyLoadFloat64, AS3AlchemyLoadInt16, AS3AlchemyLoadInt32, AS3AlchemyLoadInt8, AS3AlchemyStoreFloat32, AS3AlchemyStoreFloat64, AS3AlchemyStoreInt16, AS3AlchemyStoreInt32, AS3AlchemyStoreInt8, AS3ApplyType, AS3AsTypeLate, AS3BitAnd, AS3BitNot, AS3BitOr, AS3BitXor, AS3Call, AS3CallPropertyLex, AS3CheckFilter, AS3Construct, AS3ConstructProperty, AS3ConstructSuper, AS3DXNSLate, AS3Debug, AS3DebugFile, AS3DebugLine, AS3Dup, AS3EscXattr, AS3EscXelem, AS3GetGlobalScope, AS3GetLex, AS3GetScopeObject, AS3GetSlot, AS3HasNext, AS3HasNext2, AS3In, AS3InstanceOf, AS3IsTypeLate, AS3Kill, AS3Label, AS3LookupSwitch, AS3Lshift, AS3NewActivation, AS3NewArray, AS3NewCatch, AS3NewClass, AS3NewFunction, AS3NewObject, AS3NextName, AS3NextValue, AS3Nop, AS3Pop, AS3PopScope, AS3PushScope, AS3PushWith, AS3Rshift, AS3SetSlot, AS3Swap, AS3Throw, AS3TypeOf, AS3Urshift, ArithmeticOpcode, ControlTransferOpcode, FunctionInvocationOpcode, FunctionReturnOpcode, LoadStoreOpcode, PropertyOpcode, PushLiteralOpcode, TypeConversionOpcode
Constant Summary
collapse
- MAP =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(sequence) ⇒ Opcode
Returns a new instance of Opcode.
63
64
65
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 63
def initialize(sequence)
@sequence = sequence
end
|
Instance Attribute Details
#sequence ⇒ Object
Returns the value of attribute sequence.
61
62
63
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 61
def sequence
@sequence
end
|
Class Method Details
.body(&block) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 29
def self.body(&block)
@body_defined = true
klass = Class.new(Record)
klass.instance_exec &block
const_set :Body, klass
attr_accessor :body
end
|
.define_property(name, options = {}, &block) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 7
def self.define_property(name, options={}, &block)
accessor_name = options[:accessor] || name
define_singleton_method(name) do |value=nil, &value_block|
if value_block
define_method(accessor_name) do
instance_exec &value_block
end
elsif !value.nil?
define_method(accessor_name) do
value
end
else
define_method(accessor_name) do
true
end
end
instance_exec(value, &block) if block
end
end
|
.mnemonic ⇒ Object
40
41
42
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 40
def self.mnemonic
@mnemonic ||= name.sub("Furnace::AVM2::ABC::AS3", "")
end
|
Instance Method Details
#ast_type ⇒ Object
106
107
108
109
110
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 106
def ast_type
self.class.mnemonic.
gsub(/^[A-Z]/) { |m| m[0].downcase }.
gsub(/([a-z])([A-Z])/) { |m| "#{m[0]}_#{m[1].downcase}" }
end
|
#byte_length ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 88
def byte_length
if respond_to? :body
@body.byte_length + 1
else
1
end
end
|
#consumes_context ⇒ Object
112
113
114
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 112
def consumes_context
false
end
|
#disassemble ⇒ Object
Also known as:
inspect
126
127
128
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 126
def disassemble
" #{offset.to_s.rjust(4, "0")} #{self.class.mnemonic.rjust(20, " ")} #{disassemble_parameters}"
end
|
#disassemble_parameters ⇒ Object
122
123
124
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 122
def disassemble_parameters
@body.to_hash if @body
end
|
#next ⇒ Object
100
101
102
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 100
def next
@sequence.opcode_at(offset + byte_length)
end
|
#offset ⇒ Object
96
97
98
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 96
def offset
@sequence.offset_of(self)
end
|
#parameters ⇒ Object
116
117
118
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 116
def parameters
[]
end
|
#read(io) ⇒ Object
73
74
75
76
77
78
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 73
def read(io)
if respond_to? :body
@body = self.class.const_get(:Body).new(:parent => @sequence)
@body.read(io)
end
end
|
#root ⇒ Object
67
68
69
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 67
def root
@sequence.root
end
|
#write(io) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 80
def write(io)
io.write([ instruction ].pack("C"))
if respond_to? :body
@body.write(io)
end
end
|