Class: WAG::Export

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Encodable

#to_wasm, #to_wat

Constructor Details

#initialize(name) ⇒ Export

Returns a new instance of Export.



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

def initialize(name)
  @name = name
end

Instance Attribute Details

#descObject (readonly)

Returns the value of attribute desc.



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

def desc
  @desc
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#func(label, &block) ⇒ Object



13
14
15
16
17
# File 'lib/wag/export.rb', line 13

def func(label, &block)
  @desc = Function.new(label)
  @desc.instance_exec(&block) if block
  @desc
end

#global(label, type) ⇒ Object



19
20
21
# File 'lib/wag/export.rb', line 19

def global(label, type)
  @desc = Global.new(label, type)
end

#memory(number, min = nil, max = nil, &block) ⇒ Object



23
24
25
26
27
# File 'lib/wag/export.rb', line 23

def memory(number, min = nil, max = nil, &block)
  @desc = Memory.new(number, min, max)
  @desc.instance_exec(&block) if block
  @desc
end

#table(number, type = :funcref, &block) ⇒ Object



29
30
31
32
33
# File 'lib/wag/export.rb', line 29

def table(number, type = :funcref, &block)
  @desc = Table.new(number, type)
  @desc.instance_exec(&block) if block
  @desc
end

#to_sexprObject



35
36
37
# File 'lib/wag/export.rb', line 35

def to_sexpr
  [:export, name, desc.to_sexpr]
end