Class: WAG::Import

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Encodable

#to_wasm, #to_wat

Constructor Details

#initialize(module_name, name) ⇒ Import

Returns a new instance of Import.



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

def initialize(module_name, name)
  @module_name = module_name
  @name = name
end

Instance Attribute Details

#descObject (readonly)

Returns the value of attribute desc.



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

def desc
  @desc
end

#module_nameObject (readonly)

Returns the value of attribute module_name.



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

def module_name
  @module_name
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#func(label, &block) ⇒ Object



14
15
16
17
18
# File 'lib/wag/import.rb', line 14

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

#global(label, type, &block) ⇒ Object



20
21
22
23
24
# File 'lib/wag/import.rb', line 20

def global(label, type, &block)
  @desc = Global.new(label, type)
  @desc.instance_exec(&block) if block
  @desc
end

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



26
27
28
29
30
# File 'lib/wag/import.rb', line 26

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



32
33
34
35
36
# File 'lib/wag/import.rb', line 32

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

#to_sexprObject



38
39
40
# File 'lib/wag/import.rb', line 38

def to_sexpr
  [:import, module_name, name, desc.to_sexpr]
end