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.
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
# File 'lib/wardite.rb', line 1175 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
1202 1203 1204 1205 1206 1207 1208 |
# File 'lib/wardite.rb', line 1202 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]]
1170 1171 1172 |
# File 'lib/wardite.rb', line 1170 def mappings @mappings end |
Instance Method Details
#[](name) ⇒ Object
1194 1195 1196 |
# File 'lib/wardite.rb', line 1194 def [](name) @mappings[name]&.[](1) end |
#respond_to?(name) ⇒ Boolean
1198 1199 1200 |
# File 'lib/wardite.rb', line 1198 def respond_to?(name) !!self[name.to_s] || super end |