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.
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 |
# File 'lib/wardite.rb', line 1236 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
1263 1264 1265 1266 1267 1268 1269 |
# File 'lib/wardite.rb', line 1263 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]]
1231 1232 1233 |
# File 'lib/wardite.rb', line 1231 def mappings @mappings end |
Instance Method Details
#[](name) ⇒ Object
1255 1256 1257 |
# File 'lib/wardite.rb', line 1255 def [](name) @mappings[name]&.[](1) end |
#respond_to?(name) ⇒ Boolean
1259 1260 1261 |
# File 'lib/wardite.rb', line 1259 def respond_to?(name) !!self[name.to_s] || super end |