Class: Opal::BuilderProcessors::WASMProcessor
- Inherits:
-
Processor
- Object
- Processor
- Opal::BuilderProcessors::WASMProcessor
- Defined in:
- lib/opal/webassembly/processor.rb
Instance Method Summary collapse
-
#initialize(source, filename, options = {}) ⇒ WASMProcessor
constructor
Override the initialization, because we really don’t want a new line mangling.
- #requires ⇒ Object
- #source ⇒ Object
-
#source_map ⇒ Object
No source map support.
Constructor Details
#initialize(source, filename, options = {}) ⇒ WASMProcessor
Override the initialization, because we really don’t want a new line mangling
10 11 12 13 14 15 |
# File 'lib/opal/webassembly/processor.rb', line 10 def initialize(source, filename, = {}) #source += "\n" unless source.end_with?("\n") @source, @filename, @options = source, filename, @requires = [] @required_trees = [] end |
Instance Method Details
#requires ⇒ Object
38 39 40 |
# File 'lib/opal/webassembly/processor.rb', line 38 def requires ['webassembly'] + super end |
#source ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/opal/webassembly/processor.rb', line 17 def source module_name = ::Opal::Compiler.module_name(@filename) source = Base64.strict_encode64(@source.to_s) <<~END Opal.modules[#{module_name.inspect}] = function() { // WebAssembly module var self = Opal.top; self.$require("webassembly"); Opal.WebAssembly.$load_from_base64('#{source}', #{module_name.inspect}); }; END end |
#source_map ⇒ Object
No source map support. Required to be mocked for tests.
31 32 33 34 35 36 |
# File 'lib/opal/webassembly/processor.rb', line 31 def source_map o = Object.new def o.generated_code; ""; end def o.to_h; {version: 3, sections: nil, sources: [], mappings: []}; end o end |