class Opal::Fragment
These are generated by nodes, so will not have to create directly.
aka, source-maps!
mapping can be created of the original location => target location,
it was generated. Using this sexp, when writing fragments in order, a
to the destination. It also keeps hold of the original sexp from which
A fragment holds a string of generated javascript that will be written
def column
-
(Integer, nil)
-
def column @sexp.column if @sexp end
def initialize(code, scope, sexp = nil)
-
sexp
(Opal::Sexp
) -- sexp used for creating fragment -
code
(String
) -- javascript code
def initialize(code, scope, sexp = nil) @code = code.to_s @sexp = sexp @scope = scope end
def inspect
def inspect "f(#{@code.inspect})" end
def line
-
(Integer, nil)
-
def line @sexp.line if @sexp end
def source_map_name
def source_map_name case @sexp.type when :top, :begin, :newline, :js_return nil when :self 'self' when :module 'module' when :class 'class' when :int @sexp.children.first when :def @sexp.children.first when :defs @sexp.children[1] when :send @sexp.children[1] when :lvar, :lvasgn, :lvdeclare, :ivar, :ivasgn, :gvar, :cvar, :cvasgn, :gvars, :gvasgn @sexp.children.first else # nil end end