Class: Relaton::Un::Wasm::Module

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/un/wasm/module.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModule

Returns a new instance of Module.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/relaton/un/wasm/module.rb', line 21

def initialize
  @types = []
  @imports = []
  @function_type_indices = []
  @tables = []
  @memories = []
  @globals = []
  @exports = []
  @elements = []
  @code = []
  @data = []
  @start = nil
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def data
  @data
end

#elementsObject (readonly)

Returns the value of attribute elements.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def elements
  @elements
end

#exportsObject (readonly)

Returns the value of attribute exports.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def exports
  @exports
end

#function_type_indicesObject (readonly)

Returns the value of attribute function_type_indices.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def function_type_indices
  @function_type_indices
end

#globalsObject (readonly)

Returns the value of attribute globals.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def globals
  @globals
end

#importsObject (readonly)

Returns the value of attribute imports.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def imports
  @imports
end

#memoriesObject (readonly)

Returns the value of attribute memories.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def memories
  @memories
end

#startObject (readonly)

Returns the value of attribute start.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def start
  @start
end

#tablesObject (readonly)

Returns the value of attribute tables.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def tables
  @tables
end

#typesObject (readonly)

Returns the value of attribute types.



18
19
20
# File 'lib/relaton/un/wasm/module.rb', line 18

def types
  @types
end

Class Method Details

.parse(bytes) ⇒ Object



35
36
37
# File 'lib/relaton/un/wasm/module.rb', line 35

def self.parse(bytes)
  Decoder.new(bytes).decode
end

Instance Method Details

#imported_function_countObject

Number of imported functions (they precede module-defined functions in the funcidx space).



41
42
43
# File 'lib/relaton/un/wasm/module.rb', line 41

def imported_function_count
  @imports.count { |i| i.kind == :func }
end