Class: Furnace::AVM2::ABC::MethodBodyInfo

Inherits:
Record show all
Includes:
RecordWithTraits
Defined in:
lib/furnace-avm2/abc/metadata/method_body_info.rb

Instance Attribute Summary

Attributes inherited from Binary::Record

#root

Instance Method Summary collapse

Methods included from RecordWithTraits

#codes_to_ast

Methods inherited from Record

abc_array_of, flag, pool_array, pool_array_of, pool_ref, subset, xlat_direct, xlat_field, xlat_inverse

Methods inherited from Binary::Record

#byte_length, codegen, codegen_each, inherited, #inspect, method_missing, register, #to_hash, trace, trace_scope, trace_value

Instance Method Details

#after_read(io) ⇒ Object



18
19
20
21
22
# File 'lib/furnace-avm2/abc/metadata/method_body_info.rb', line 18

def after_read(io)
  exceptions.each do |exception|
    exception.resolve!
  end
end

#code_to_ast(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/furnace-avm2/abc/metadata/method_body_info.rb', line 24

def code_to_ast(options={})
  pipeline = Furnace::Transform::Pipeline.new([
    Furnace::AVM2::Transform::ASTBuild.new(options),
    Furnace::AVM2::Transform::ASTNormalize.new(options),
    Furnace::AVM2::Transform::PropagateConstants.new,
  ])

  pipeline.run(code, self)
end

#code_to_cfgObject



34
35
36
37
38
39
40
41
# File 'lib/furnace-avm2/abc/metadata/method_body_info.rb', line 34

def code_to_cfg
  pipeline = Furnace::Transform::Pipeline.new([
    Furnace::AVM2::Transform::PropagateLabels.new,
    Furnace::AVM2::Transform::CFGBuild.new
  ])

  pipeline.run(*code_to_ast({}))
end

#code_to_nfObject



43
44
45
46
47
48
49
50
# File 'lib/furnace-avm2/abc/metadata/method_body_info.rb', line 43

def code_to_nf
  pipeline = Furnace::Transform::Pipeline.new([
    Furnace::AVM2::Transform::CFGReduce.new,
    Furnace::AVM2::Transform::NFNormalize.new,
  ])

  pipeline.run(*code_to_cfg)
end

#collect_ns(options) ⇒ Object



56
57
58
59
60
# File 'lib/furnace-avm2/abc/metadata/method_body_info.rb', line 56

def collect_ns(options)
  code.each do |opcode|
    opcode.collect_ns(options) if opcode.respond_to? :collect_ns
  end
end

#decompile(options = {}) ⇒ Object



52
53
54
# File 'lib/furnace-avm2/abc/metadata/method_body_info.rb', line 52

def decompile(options={})
  Furnace::AVM2::Decompiler.new(self, options).decompile
end