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 = { eliminate_nops: true }) ⇒ Object



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

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

  pipeline.run(code, self)
end

#code_to_cfgObject



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

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

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

#code_to_nfObject



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

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



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

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

#decompile(options = {}) ⇒ Object



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

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