Sha256: 6d89b1830958e0874ac68efd9633464eca0c4ec7308e8d34b026a488b6fd2707
Contents?: true
Size: 1.33 KB
Versions: 13
Compression:
Stored size: 1.33 KB
Contents
module Opal # A fragment holds a string of generated javascript that will be written # to the destination. It also keeps hold of the original sexp from which # it was generated. Using this sexp, when writing fragments in order, a # mapping can be created of the original location => target location, # aka, source-maps! # # These are generated by nodes, so will not have to create directly. class Fragment # String of javascript this fragment holds # @return [String] attr_reader :code # Create fragment with javascript code and optional original [Opal::Sexp]. # # @param code [String] javascript code # @param sexp [Opal::Sexp] sexp used for creating fragment def initialize(code, scope, sexp = nil) @code = code.to_s @sexp = sexp @scope = scope end # Inspect the contents of this fragment, f("fooo") def inspect "f(#{@code.inspect})" end def source_map_name return nil unless @scope def_node = @scope.def? ? @scope : @scope.find_parent_def def_node && def_node.mid end # Original line this fragment was created from # @return [Integer, nil] def line @sexp.line if @sexp end # Original column this fragment was created from # @return [Integer, nil] def column @sexp.column if @sexp end end end
Version data entries
13 entries across 13 versions & 1 rubygems