Class: Furnace::AVM2::ABC::ScriptInfo

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

Instance Attribute Summary

Attributes inherited from Binary::Record

#root

Instance Method Summary collapse

Methods included from RecordWithTraits

#codes_to_ast

Methods included from InitializerBody

#initializer_body

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

#collect_nsObject



10
11
12
13
14
15
16
17
18
# File 'lib/furnace-avm2/abc/metadata/script_info.rb', line 10

def collect_ns
  options = { ns: Set.new, no_ns: Set.new, names: {} }
  options[:ns].add package_name.ns if has_name?

  initializer.collect_ns(options) if initializer
  traits.each { |trait| trait.collect_ns(options) }

  options
end

#decompile(options = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/furnace-avm2/abc/metadata/script_info.rb', line 20

def decompile(options={})
  Furnace::AVM2::Tokens::PackageToken.new(self,
        options.merge(collect_ns).merge(
          package_type: :script,
          package_name: package_name)
        )
end

#has_name?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/furnace-avm2/abc/metadata/script_info.rb', line 28

def has_name?
  non_init_traits.any?
end

#non_init_traitsObject



36
37
38
# File 'lib/furnace-avm2/abc/metadata/script_info.rb', line 36

def non_init_traits
  traits.reject { |trait| trait.kind == :Class }
end

#package_nameObject



32
33
34
# File 'lib/furnace-avm2/abc/metadata/script_info.rb', line 32

def package_name
  non_init_traits[0].name if non_init_traits.any?
end