Class: WAG::Element

Inherits:
Object
  • Object
show all
Includes:
Encodable
Defined in:
lib/wag/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Encodable

#to_wasm, #to_wat

Constructor Details

#initialize(table_id, *labels) ⇒ Element

Returns a new instance of Element.



9
10
11
12
# File 'lib/wag/element.rb', line 9

def initialize(table_id, *labels)
  @table_id = table_id.to_i
  @labels = labels.map { |l| WAG::Label.from(l) }
end

Instance Attribute Details

#labelsObject (readonly)

Returns the value of attribute labels.



7
8
9
# File 'lib/wag/element.rb', line 7

def labels
  @labels
end

#table_idObject (readonly)

Returns the value of attribute table_id.



7
8
9
# File 'lib/wag/element.rb', line 7

def table_id
  @table_id
end

Instance Method Details

#to_sexprObject



14
15
16
# File 'lib/wag/element.rb', line 14

def to_sexpr
  [:elem, [:'i32.const', table_id]].concat(labels.map(&:to_sexpr))
end