class Opal::BuilderProcessors::Processor

Public Class Methods

new(source, filename, options = {}) click to toggle source

Override the initialization, because we really don't want a new line mangling

# File lib/opal/webassembly/processor.rb, line 10
def initialize(source, filename, options = {})
  #source += "\n" unless source.end_with?("\n")
  @source, @filename, @options = source, filename, options
  @requires = []
  @required_trees = []
end

Public Instance Methods

requires() click to toggle source
Calls superclass method
# File lib/opal/webassembly/processor.rb, line 38
def requires
  ['webassembly'] + super
end
source() click to toggle source
# 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() click to toggle source

No source map support. Required to be mocked for tests.

# 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