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