Class: Wardite::Exports
- Inherits:
-
Object
- Object
- Wardite::Exports
- Defined in:
- lib/wardite.rb
Overview
@rbs!
type exportHandle = WasmFunction | ExternalFunction | Table | Global | Memory
Instance Attribute Summary collapse
-
#mappings ⇒ Object
: Hash[String, [Integer, exportHandle]].
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(export_section, store) ⇒ Exports
constructor
A new instance of Exports.
- #method_missing(name, *_args) ⇒ Object
- #respond_to?(name) ⇒ Boolean
Constructor Details
#initialize(export_section, store) ⇒ Exports
Returns a new instance of Exports.
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 |
# File 'lib/wardite.rb', line 1168 def initialize(export_section, store) @mappings = {} export_section.exports.each_pair do |name, desc| case desc.kind when 0x0 @mappings[name] = [desc.kind, store.funcs[desc.index]] when 0x1 @mappings[name] = [desc.kind, store.tables[desc.index]] when 0x2 @mappings[name] = [desc.kind, store.memories[desc.index]] when 0x3 @mappings[name] = [desc.kind, store.globals[desc.index]] else end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args) ⇒ Object
1195 1196 1197 1198 1199 1200 1201 |
# File 'lib/wardite.rb', line 1195 def method_missing(name, *_args) if self[name.to_s] self[name.to_s] else super end end |
Instance Attribute Details
#mappings ⇒ Object
: Hash[String, [Integer, exportHandle]]
1163 1164 1165 |
# File 'lib/wardite.rb', line 1163 def mappings @mappings end |
Instance Method Details
#[](name) ⇒ Object
1187 1188 1189 |
# File 'lib/wardite.rb', line 1187 def [](name) @mappings[name]&.[](1) end |
#respond_to?(name) ⇒ Boolean
1191 1192 1193 |
# File 'lib/wardite.rb', line 1191 def respond_to?(name) !!self[name.to_s] || super end |