Class: Furnace::AVM2::ABC::MethodInfo

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

Constant Summary collapse

NEED_ARGUMENTS =
0x01
NEED_ACTIVATION =
0x02
NEED_REST =
0x04
HAS_OPTIONAL =
0x08
SET_DXNS =
0x40
HAS_PARAM_NAMES =
0x80

Instance Attribute Summary

Attributes inherited from Binary::Record

#root

Instance Method Summary collapse

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_ns(options) ⇒ Object



58
59
60
61
# File 'lib/furnace-avm2/abc/metadata/method_info.rb', line 58

def collect_ns(options)
  param_types.compact.each { |type| type.collect_ns(options) }
  return_type.collect_ns(options) if return_type
end

#to_astlet(index, name = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/furnace-avm2/abc/metadata/method_info.rb', line 29

def to_astlet(index, name=nil)
  root = AST::Node.new(:method)
  root. = { method: self, label: index }

  root.children << name || self.name

  if return_type
    root.children << return_type.to_astlet
  else
    root.children << nil
  end

  if has_param_names?
    names = param_names
  else
    names = param_count.times.map { |n| "a#{n}" }
  end

  root.children << names.each_with_index.map do |name, index|
    if param_types[index]
      [ name, param_types[index].to_astlet ]
    else
      [ name, nil ]
    end
  end

  root.normalize_hierarchy!
end