Class: Relaton::Un::Wasm::Instance
- Inherits:
-
Object
- Object
- Relaton::Un::Wasm::Instance
- Defined in:
- lib/relaton/un/wasm/instance.rb
Instance Attribute Summary collapse
-
#funcs ⇒ Object
readonly
Returns the value of attribute funcs.
-
#globals ⇒ Object
readonly
Returns the value of attribute globals.
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #export_index(name, kind) ⇒ Object
-
#initialize(mod, imports = {}) ⇒ Instance
constructor
imports: { “modname” => { “fieldname” => Proc } }.
- #invoke(name, *args) ⇒ Object
- #invoke_by_index(func_idx, args) ⇒ Object
Constructor Details
#initialize(mod, imports = {}) ⇒ Instance
imports: { “modname” => { “fieldname” => Proc } }
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/relaton/un/wasm/instance.rb', line 10 def initialize(mod, imports = {}) @mod = mod @types = mod.types @imports = imports @funcs = [] @globals = [] @table = [] link_funcs init_memory init_globals init_table init_data @interpreter = Interpreter.new(self) end |
Instance Attribute Details
#funcs ⇒ Object (readonly)
Returns the value of attribute funcs.
7 8 9 |
# File 'lib/relaton/un/wasm/instance.rb', line 7 def funcs @funcs end |
#globals ⇒ Object (readonly)
Returns the value of attribute globals.
7 8 9 |
# File 'lib/relaton/un/wasm/instance.rb', line 7 def globals @globals end |
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
7 8 9 |
# File 'lib/relaton/un/wasm/instance.rb', line 7 def memory @memory end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
7 8 9 |
# File 'lib/relaton/un/wasm/instance.rb', line 7 def table @table end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
7 8 9 |
# File 'lib/relaton/un/wasm/instance.rb', line 7 def types @types end |
Instance Method Details
#export_index(name, kind) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/relaton/un/wasm/instance.rb', line 34 def export_index(name, kind) exp = @mod.exports.find { |e| e.name == name && e.kind == kind } raise LinkError, "no export named #{name} of kind #{kind}" unless exp exp.index end |
#invoke(name, *args) ⇒ Object
25 26 27 28 |
# File 'lib/relaton/un/wasm/instance.rb', line 25 def invoke(name, *args) idx = export_index(name, :func) invoke_by_index(idx, args) end |
#invoke_by_index(func_idx, args) ⇒ Object
30 31 32 |
# File 'lib/relaton/un/wasm/instance.rb', line 30 def invoke_by_index(func_idx, args) @interpreter.invoke(func_idx, args) end |