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
AS3Add, AS3AddI, AS3AlchemyExtend1, AS3AlchemyExtend16, AS3AlchemyExtend8, AS3AlchemyLoadFloat32, AS3AlchemyLoadFloat64, AS3AlchemyLoadInt16, AS3AlchemyLoadInt32, AS3AlchemyLoadInt8, AS3AlchemyStoreFloat32, AS3AlchemyStoreFloat64, AS3AlchemyStoreInt16, AS3AlchemyStoreInt32, AS3AlchemyStoreInt8, AS3ApplyType, AS3AsTypeLate, AS3BitAnd, AS3BitNot, AS3BitOr, AS3BitXor, AS3Call, AS3CallPropertyLex, AS3CheckFilter, AS3Coerce, AS3CoerceA, AS3CoerceB, AS3CoerceS, AS3Construct, AS3ConstructProperty, AS3ConstructSuper, AS3ConvertD, AS3ConvertI, AS3ConvertO, AS3ConvertS, AS3ConvertU, AS3DXNSLate, AS3Debug, AS3DebugFile, AS3DebugLine, AS3DecLocal, AS3DecLocalI, AS3Decrement, AS3DecrementI, AS3Divide, AS3Dup, AS3Equals, AS3EscXattr, AS3EscXelem, AS3GetGlobalScope, AS3GetLex, AS3GetScopeObject, AS3GetSlot, AS3GreaterEquals, AS3GreaterThan, AS3HasNext, AS3HasNext2, AS3In, AS3IncLocal, AS3IncLocalI, AS3Increment, AS3IncrementI, AS3InstanceOf, AS3IsTypeLate, AS3Kill, AS3Label, AS3LessEquals, AS3LessThan, AS3LookupSwitch, AS3Lshift, AS3Modulo, AS3Multiply, AS3MultiplyI, AS3Negate, AS3NegateI, AS3NewActivation, AS3NewArray, AS3NewCatch, AS3NewClass, AS3NewFunction, AS3NewObject, AS3NextName, AS3NextValue, AS3Nop, AS3Not, AS3Pop, AS3PopScope, AS3PushScope, AS3PushWith, AS3ReturnValue, AS3ReturnVoid, AS3Rshift, AS3SetSlot, AS3StrictEquals, AS3Subtract, AS3SubtractI, AS3Swap, AS3Throw, AS3TypeOf, AS3Urshift, ControlTransferOpcode, FunctionInvocationOpcode, LoadStoreOpcode, PropertyOpcode, PushLiteralOpcode
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.
61
62
63
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 61
def initialize(sequence)
@sequence = sequence
end
|
Instance Attribute Details
#sequence ⇒ Object
Returns the value of attribute sequence.
59
60
61
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 59
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
104
105
106
107
108
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 104
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
86
87
88
89
90
91
92
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 86
def byte_length
if respond_to? :body
@body.byte_length + 1
else
1
end
end
|
#consumes_context ⇒ Object
110
111
112
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 110
def consumes_context
false
end
|
#disassemble ⇒ Object
Also known as:
inspect
124
125
126
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 124
def disassemble
" #{offset.to_s.rjust(4, "0")} #{self.class.mnemonic.rjust(20, " ")} #{disassemble_parameters} # params: #{parameters.inspect}"
end
|
#disassemble_parameters ⇒ Object
120
121
122
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 120
def disassemble_parameters
@body.to_hash if @body
end
|
#next ⇒ Object
98
99
100
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 98
def next
@sequence.opcode_at(offset + byte_length)
end
|
#offset ⇒ Object
94
95
96
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 94
def offset
@sequence.offset_of(self)
end
|
#parameters ⇒ Object
114
115
116
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 114
def parameters
[]
end
|
#read(io) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 71
def read(io)
if respond_to? :body
@body = self.class.const_get(:Body).new(:parent => @sequence)
@body.read(io)
end
end
|
#root ⇒ Object
65
66
67
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 65
def root
@sequence.root
end
|
#write(io) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/furnace-avm2/abc/opcodes/opcode.rb', line 78
def write(io)
io.write([ instruction ].pack("C"))
if respond_to? :body
@body.write(io)
end
end
|