Class: Furnace::AVM2::ABC::TraitInfo

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

Constant Summary collapse

XlatTable =
{
  :Slot     => 0,
  :Method   => 1,
  :Getter   => 2,
  :Setter   => 3,
  :Class    => 4,
  :Function => 5,
  :Const    => 6
}
TRAIT_FINAL =
0x01
TRAIT_OVERRIDE =
0x02
TRAIT_METADATA =
0x04

Instance Attribute Summary collapse

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



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

def method_missing(method, *args, &block)
  data.send(method, *args, &block)
end

Instance Attribute Details

#kind_rawObject

Returns the value of attribute kind_raw.



17
18
19
# File 'lib/furnace-avm2/abc/metadata/trait_info.rb', line 17

def kind_raw
  @kind_raw
end

Instance Method Details

#read_attributes(io, options) ⇒ Object



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

def read_attributes(io, options)
  byte = io.read(1).unpack("C").at(0)

  value     = byte >> 4
  @kind_raw = byte & 0xF

  value
end

#to_astletObject



60
61
62
# File 'lib/furnace-avm2/abc/metadata/trait_info.rb', line 60

def to_astlet
  data.to_astlet(self)
end

#write_attributes(io, value, options) ⇒ Object



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

def write_attributes(io, value, options)
  byte = (value << 4) | (@kind_raw & 0xf)

  io.write([ byte ].pack("C"))
end