source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/closure.rb | Ruby | mit | 4,915 | master | 8,869 | # frozen_string_literal: true
module Opal
module Nodes
# This module takes care of providing information about the
# closure stack that we have for the nodes during compile time.
# This is not a typical node.
#
# Also, while loops are not closures per se, this module also
# takes a note about... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/module.rb | Ruby | mit | 4,915 | master | 2,193 | # frozen_string_literal: true
require 'opal/nodes/scope'
module Opal
module Nodes
class ModuleNode < ScopeNode
handle :module
children :cid, :body
def compile
if compiler.runtime_mode?
# Skip class/module generation
line stmt(body)
return
end
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args.rb | Ruby | mit | 4,915 | master | 1,008 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/args/arg'
require 'opal/nodes/args/arity_check'
require 'opal/nodes/args/ensure_kwargs_are_kwargs'
require 'opal/nodes/args/extract_block_arg'
require 'opal/nodes/args/extract_kwarg'
require 'opal/nodes/args/extract_kwargs'
require 'opal/node... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/definitions.rb | Ruby | mit | 4,915 | master | 3,473 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class UndefNode < Base
handle :undef
children :value
def compile
helper :udef
children.each do |child|
push dce_def_begin(child.children.first) if child.type == :sym
line "$u... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/defined.rb | Ruby | mit | 4,915 | master | 6,478 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class DefinedNode < Base
handle :defined?
children :value
def compile
case value.type
when :self, :nil, :false, :true
push value.type.to_s.inspect
when :lvasgn, :ivasgn, :gvasgn... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/class.rb | Ruby | mit | 4,915 | master | 1,408 | # frozen_string_literal: true
require 'opal/nodes/module'
module Opal
module Nodes
class ClassNode < ModuleNode
handle :class
children :cid, :sup, :body
def compile
name, base = name_and_base
helper :klass_def
if body.nil?
# Empty body: rely on runtime $kla... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/if.rb | Ruby | mit | 4,915 | master | 13,384 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/ast/matcher'
require 'thread' if RUBY_ENGINE == 'opal'
module Opal
module Nodes
class IfNode < Base
handle :if
children :test, :true_body, :false_body
def compile
if should_compile_as_simple_expression?
i... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/top.rb | Ruby | mit | 4,915 | master | 5,167 | # frozen_string_literal: true
require 'pathname'
require 'json'
require 'opal/version'
require 'opal/nodes/scope'
module Opal
module Nodes
# Generates code for an entire file, i.e. the base sexp
class TopNode < ScopeNode
handle :top
children :body
def compile
compiler.top_scope =... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/rescue.rb | Ruby | mit | 4,915 | master | 5,987 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class EnsureNode < Base
handle :ensure
children :begn, :ensr
def compile
push_closure if wrap_in_closure?
push 'try {'
in_ensure do
line stmt(body_sexp)
end
l... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/helpers.rb | Ruby | mit | 4,915 | master | 3,791 | # frozen_string_literal: true
require 'opal/regexp_anchors'
module Opal
module Nodes
module Helpers
def property(name)
valid_name?(name) ? ".#{name}" : "[#{name.inspect}]"
end
def valid_name?(name)
Opal::Rewriters::JsReservedWords.valid_name?(name)
end
# Converts ... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/yield.rb | Ruby | mit | 4,915 | master | 1,575 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class BaseYieldNode < Base
def compile_call
yielding_scope = find_yielding_scope
yielding_scope.uses_block!
yielding_scope.block_name ||= '$yield'
block_name = yielding_scope.block_name
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/super.rb | Ruby | mit | 4,915 | master | 5,292 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
# This base class is used just to child the find_super_dispatcher method
# body. This is then used by actual super calls, or a defined?(super) style
# call.
class BaseSuperNode < CallNode
def initialize(*)
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/arglist.rb | Ruby | mit | 4,915 | master | 1,229 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
# FIXME: needs rewrite
class ArglistNode < Base
handle :arglist
def compile
code, work = [], []
children.each do |current|
splat = current.type == :splat
arg = expr(current)
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/hash.rb | Ruby | mit | 4,915 | master | 2,534 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class HashNode < Base
handle :hash
attr_accessor :has_kwsplat, :keys, :values
def initialize(*)
super
@has_kwsplat = false
@keys = []
@values = []
children.each do |child... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/singleton_class.rb | Ruby | mit | 4,915 | master | 684 | # frozen_string_literal: true
require 'opal/nodes/scope'
module Opal
module Nodes
class SingletonClassNode < ScopeNode
handle :sclass
children :object, :body
def compile
push '(function(self, $parent_nesting) {'
in_scope do
body_stmt = stmt(compiler.returns(body))
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/while.rb | Ruby | mit | 4,915 | master | 2,895 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class WhileNode < Base
handle :while
children :test, :body
def compile
test_code = js_truthy(test)
@redo_var = scope.new_temp if uses_redo?
compiler.in_while do
while_loop[:cl... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/logic.rb | Ruby | mit | 4,915 | master | 2,195 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class NextNode < Base
handle :next
def compile
thrower(:next, value)
end
def value
case children.size
when 0
s(:nil)
when 1
children.first
else
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/base.rb | Ruby | mit | 4,915 | master | 5,162 | # frozen_string_literal: true
require 'opal/nodes/helpers'
require 'opal/nodes/closure'
require 'opal/builder/post_processor'
module Opal
module Nodes
class Base
include Helpers
include Closure::NodeSupport
include Builder::PostProcessor::NodeSupport
include Builder::PostProcessor::DCE::... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/literal.rb | Ruby | mit | 4,915 | master | 9,510 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/regexp_transpiler'
module Opal
module Nodes
class ValueNode < Base
handle :true, :false, :nil
def compile
push type.to_s
end
def self.truthy_optimize?
true
end
end
class SelfNode < Base... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/lambda.rb | Ruby | mit | 4,915 | master | 313 | # frozen_string_literal: true
require 'opal/nodes/call'
module Opal
module Nodes
class LambdaNode < Base
handle :lambda
children :iter
def compile
helper :lambda
scope.defines_lambda do
push '$lambda(', expr(iter), ')'
end
end
end
end
end |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call.rb | Ruby | mit | 4,915 | master | 10,088 | # frozen_string_literal: true
require 'set'
require 'pathname'
require 'opal/nodes/base'
module Opal
module Nodes
class CallNode < Base
handle :send, :csend
attr_reader :recvr, :meth, :arglist, :iter
SPECIALS = {}
# Operators that get optimized by compiler
OPERATORS = { :+ => :p... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/scope.rb | Ruby | mit | 4,915 | master | 10,038 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class ScopeNode < Base
# Every scope can have a parent scope
attr_accessor :parent
# The class or module name if this scope is a class scope
attr_accessor :name
# The given block name for a def scope... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/iter.rb | Ruby | mit | 4,915 | master | 3,933 | # frozen_string_literal: true
require 'opal/nodes/node_with_args'
module Opal
module Nodes
class IterNode < NodeWithArgs
handle :iter
children :inline_args, :stmts
def compile
is_lambda! if scope.lambda_definition?
compile_body_or_shortcut
blockopts = {}
blo... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/def.rb | Ruby | mit | 4,915 | master | 2,366 | # frozen_string_literal: true
require 'opal/nodes/node_with_args'
module Opal
module Nodes
class DefNode < NodeWithArgs
handle :def
children :mid, :inline_args, :stmts
def compile
compile_body_or_shortcut
blockopts = {}
blockopts["$$arity"] = arity if arity < 0
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/array.rb | Ruby | mit | 4,915 | master | 1,315 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class ArrayNode < Base
handle :array
def compile
return push('[]') if children.empty?
code, work = [], []
children.each do |child|
splat = child.type == :splat
part = expr... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/node_with_args.rb | Ruby | mit | 4,915 | master | 886 | # frozen_string_literal: true
require 'opal/nodes/scope'
require 'opal/nodes/args/parameters'
require 'opal/nodes/node_with_args/shortcuts'
module Opal
module Nodes
class NodeWithArgs < ScopeNode
attr_reader :used_kwargs
attr_accessor :arity
attr_reader :original_args
def initialize(*)
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/variables.rb | Ruby | mit | 4,915 | master | 4,340 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class LocalVariableNode < Base
handle :lvar
children :var_name
def using_irb?
compiler.irb? && scope.top?
end
def compile
return push(var_name.to_s) unless using_irb?
with_t... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/masgn.rb | Ruby | mit | 4,915 | master | 3,404 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
class MassAssignNode < Base
SIMPLE_ASSIGNMENT = %i[lvasgn ivasgn lvar gvasgn cdecl casgn].freeze
handle :masgn
children :lhs, :rhs
def compile
with_temp do |array|
if rhs.type == :array
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/node_with_args/shortcuts.rb | Ruby | mit | 4,915 | master | 3,037 | # frozen_string_literal: true
module Opal
module Nodes
class NodeWithArgs < ScopeNode
# Shortcuts for the simplest kinds of methods
Shortcut = Struct.new(:name, :for, :when, :transform) do
def match?(node)
node.instance_exec(&self.when)
end
def compile(node)
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call/eval.rb | Ruby | mit | 4,915 | master | 1,375 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/call'
module Opal
module Nodes
class CallNode
# This can be refactored in terms of binding, but it would need 'corelib/binding'
# to be required in existing code.
add_special :eval do |compile_default|
# Catch ... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call/js_property.rb | Ruby | mit | 4,915 | master | 1,226 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/call'
module Opal
module Nodes
# recvr.JS[:prop]
# => recvr.prop
class JsAttrNode < Base
handle :jsattr
children :recvr, :property
def compile
push recv(recvr), '[', expr(property), ']'
end
e... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call/require.rb | Ruby | mit | 4,915 | master | 3,897 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/call'
module Opal
module Nodes
class CallNode
add_special :require do |compile_default|
str = DependencyResolver.new(compiler, arglist.children[0]).resolve
compiler.track_require str unless str.nil?
compile... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call/match3.rb | Ruby | mit | 4,915 | master | 2,666 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/call'
module Opal
module Nodes
# Handles match_with_lvasgn nodes which represent matching a regular expression
# with a right-hand side value and assigning the match result to a left-hand side variable.
class Match3Node < Base
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call/reflection.rb | Ruby | mit | 4,915 | master | 1,441 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/call'
module Opal
module Nodes
class CallNode
add_special :__callee__ do
if scope.def?
push fragment scope.mid.to_s.inspect
else
push fragment 'nil'
end
end
add_special :__m... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/call/dce.rb | Ruby | mit | 4,915 | master | 2,921 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/nodes/call'
module Opal
module Nodes
class CallNode
def dce_matcher(methods)
case methods.length
when 0
when 1
methods.first
else
methods
end
end
def dce_symbol_ar... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_optarg.rb | Ruby | mit | 4,915 | master | 896 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# Compiles extraction of a single inline optional argument
# def m(a = 1); end
# ^^^^^
#
# This node doesn't exist in the original AST,
# InlineArgs rewriter creates it to simpl... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb | Ruby | mit | 4,915 | master | 492 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# A utility node responsible for compiling
# a runtime validation for kwargs.
#
# This node is used for both inline and post-kwargs
#
class EnsureKwargsAreKwargs < Base
handle... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_kwrestarg.rb | Ruby | mit | 4,915 | master | 912 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for extracting a single
# splat keyword argument from $kwargs
#
# $kwargs always exist (as argument when inlining is possible
# and as a local variable when it's ... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/arity_check.rb | Ruby | mit | 4,915 | master | 3,954 | # frozen_string_literal: true
require 'opal/nodes/base'
require 'opal/rewriters/arguments'
module Opal
module Nodes
class ArityCheckNode < Base
handle :arity_check
children :args_node
def initialize(*)
super
arguments = Rewriters::Arguments.new(args_node.children)
@a... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_kwarg.rb | Ruby | mit | 4,915 | master | 708 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for extracting a single
# required keyword argument from $kwargs
#
# $kwargs always exist (as argument when inlining is possible
# and as a local variable when it... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/initialize_iterarg.rb | Ruby | mit | 4,915 | master | 541 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for initializing a single
# required block arg
#
# proc { |a| }
#
# Procs don't have arity checking and code like
# proc { |a| }.call
# must... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/prepare_post_args.rb | Ruby | mit | 4,915 | master | 576 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# A utility node responsible for preparing
# post-argument for :extract_post_* nodes
class PreparePostArgs < Base
handle :prepare_post_args
children :offset
def compile
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_kwargs.rb | Ruby | mit | 4,915 | master | 637 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# A utility node responsible for extracting
# post-kwargs from post-arguments.
#
# This node is used when kwargs cannot be inlined:
# def m(a = 1, kw:); end
#
# This node is N... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_post_arg.rb | Ruby | mit | 4,915 | master | 489 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for extracting a single
# required post-argument from $post_args
#
class ExtractPostArg < Base
handle :extract_post_arg
children :name
def comp... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_post_optarg.rb | Ruby | mit | 4,915 | master | 895 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for extracting a single
# optional post-argument
#
# args_to_keep is the number of required post-arguments
#
# def m(a = 1, b, c, d); end
# becomes ... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/fake_arg.rb | Ruby | mit | 4,915 | master | 560 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# Compiles a fake argument produced by the InlineArgs rewriter.
#
# This argument represents an argument from the
# Ruby code that gets initialized later in the function body.
#
# def... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/parameters.rb | Ruby | mit | 4,915 | master | 1,669 | # frozen_string_literal: true
module Opal
module Nodes
module Args
class Parameters
def initialize(args)
@args = args.children
end
def to_code
stringified_parameters = @args.map do |arg|
public_send(:"on_#{arg.type}", arg)
end
"[... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/initialize_shadowarg.rb | Ruby | mit | 4,915 | master | 454 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for initializing a shadow arg
#
# proc { |;a| }
#
class InitializeShadowarg < Base
handle :initialize_shadowarg
children :name
def compil... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_kwoptarg.rb | Ruby | mit | 4,915 | master | 870 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for extracting a single
# optional keyword argument from $kwargs
#
# $kwargs always exist (as argument when inlining is possible
# and as a local variable when it... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/arg.rb | Ruby | mit | 4,915 | master | 375 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# Compiles a single inline required argument
# def m(a); end
# ^
class ArgNode < Base
handle :arg
children :name
def compile
scope.add_arg name
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_block_arg.rb | Ruby | mit | 4,915 | master | 569 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# Compiles extraction of the block argument
# def m(&block); end
# ^^^^^^
#
# This node doesn't exist in the original AST,
# InlineArgs rewriter creates it to simplify compilati... |
github | opal/opal | https://github.com/opal/opal | lib/opal/nodes/args/extract_restarg.rb | Ruby | mit | 4,915 | master | 974 | # frozen_string_literal: true
require 'opal/nodes/base'
module Opal
module Nodes
module Args
# This node is responsible for extracting a splat argument from post-arguments
#
# args_to_keep is the number of required post-arguments
#
# def m(*a, b, c, d); end
# becomes someth... |
github | opal/opal | https://github.com/opal/opal | lib/opal/ast/node.rb | Ruby | mit | 4,915 | master | 501 | # frozen_string_literal: true
require 'ast'
require 'parser/ast/node'
module Opal
module AST
class Node < ::Parser::AST::Node
attr_reader :meta
def assign_properties(properties)
if meta = properties[:meta]
meta = meta.dup if meta.frozen?
@meta.merge!(meta)
else
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/ast/matcher.rb | Ruby | mit | 4,915 | master | 1,772 | # frozen_string_literal: true
require 'ast'
require 'parser/ast/node'
module Opal
module AST
class Matcher
def initialize(&block)
@root = instance_exec(&block)
end
def s(type, *children)
Node.new(type, children)
end
def cap(capture)
Node.new(:capture, [cap... |
github | opal/opal | https://github.com/opal/opal | lib/opal/ast/builder.rb | Ruby | mit | 4,915 | master | 316 | # frozen_string_literal: true
require 'opal/ast/node'
require 'parser/ruby32'
module Opal
module AST
class Builder < ::Parser::Builders::Default
self.emit_lambda = true
def n(type, children, location)
::Opal::AST::Node.new(type, children, location: location)
end
end
end
end |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/directory.rb | Ruby | mit | 4,915 | master | 3,760 | # frozen_string_literal: true
module Opal
class Builder
# This module is included into Builder, provides abstracted data about a new
# paradigm of compiling Opal applications into a directory.
module Directory
def version_prefix
"opal/#{Opal::VERSION_MAJOR_MINOR}"
end
def sourc... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/scheduler.rb | Ruby | mit | 4,915 | master | 3,426 | # frozen_string_literal: true
require 'opal/os' unless RUBY_ENGINE == 'opal'
module Opal
class Builder
class Scheduler
def initialize(builder)
@builder = builder
end
attr_accessor :builder
# Prefork is not deterministic. This module corrects an order of processed
# files ... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/post_processor.rb | Ruby | mit | 4,915 | master | 1,633 | # frozen_string_literal: true
module Opal
class Builder
class PostProcessor
@postprocessors = []
def self.register(klass)
@postprocessors << klass
end
def self.call(processed, builder)
@postprocessors.each do |postprocessor|
processed = postprocessor.new(process... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/processor.rb | Ruby | mit | 4,915 | master | 4,763 | # frozen_string_literal: true
require 'opal/compiler'
require 'opal/erb'
require 'erb'
module Opal
class Builder
class Processor
def initialize(source, filename, abs_path = nil, options = {})
options = abs_path if abs_path.is_a? Hash
source += "\n" unless source.end_with?("\n")
@s... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/post_processor/dce.rb | Ruby | mit | 4,915 | master | 7,472 | # frozen_string_literal: true
require 'opal/builder/post_processor/dce/call_tree'
module Opal
class Builder
class PostProcessor
class DCE < PostProcessor
def self.enabled?(builder)
builder.dce?
end
def initialize(_, _)
super
reset
end
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/post_processor/dce/call_tree.rb | Ruby | mit | 4,915 | master | 6,309 | # frozen_string_literal: true
# rubocop:disable Style/CaseEquality
module Opal
class Builder
class PostProcessor
class DCE < PostProcessor
# CallTree records a tree of definitions and calls, like
# so:
#
# (root):
# - definitions:
# - CallTree:
# ... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/scheduler/prefork.rb | Ruby | mit | 4,915 | master | 7,368 | # frozen_string_literal: true
require 'etc'
require 'set'
module Opal
class Builder
class Scheduler
class Prefork < Scheduler
# We hook into the process_requires method
def process_requires(rel_path, requires, autoloads, options)
return if requires.empty?
if @in_fork
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/scheduler/threaded.rb | Ruby | mit | 4,915 | master | 3,933 | # frozen_string_literal: true
module Opal
class Builder
class Scheduler
class Threaded < Scheduler
def initialize(builder)
super(builder)
@threads = []
@threads_mutex = Thread::Mutex.new
init_thread_args
end
# We hook into the process_require... |
github | opal/opal | https://github.com/opal/opal | lib/opal/builder/scheduler/sequential.rb | Ruby | mit | 4,915 | master | 462 | # frozen_string_literal: true
module Opal
class Builder
class Scheduler
class Sequential < Scheduler
def process_requires(rel_path, requires, autoloads, options)
requires.map { |r| builder.process_require(r, autoloads, options) }
rescue Builder::MissingRequire => error
r... |
github | opal/opal | https://github.com/opal/opal | lib/opal/source_map/vlq.rb | Ruby | mit | 4,915 | master | 2,567 | # Ported from http://github.com/maccman/sourcemap
#
# Adopted from ConradIrwin/ruby-source_map
# https://github.com/ConradIrwin/ruby-source_map/blob/master/lib/source_map/vlq.rb
#
# Resources
#
# http://en.wikipedia.org/wiki/Variable-length_quantity
# https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFz... |
github | opal/opal | https://github.com/opal/opal | lib/opal/source_map/map.rb | Ruby | mit | 4,915 | master | 771 | # frozen_string_literal: true
require 'base64'
require 'json'
module Opal::SourceMap::Map
def to_h
@to_h || map
end
def to_json
map = to_h
map.to_json
rescue Encoding::UndefinedConversionError
map[:sections].each do |i|
i.to_json
rescue Encoding::UndefinedConversionError
map[:... |
github | opal/opal | https://github.com/opal/opal | lib/opal/source_map/index.rb | Ruby | mit | 4,915 | master | 2,687 | # frozen_string_literal: true
class Opal::SourceMap::Index
include Opal::SourceMap::Map
attr_reader :source_maps
# @param source_maps [Opal::SourceMap::File]
# @param join: the string used to join the sources, empty by default, Opal::Builder uses "\n"
def initialize(source_maps, join: nil)
@source_maps... |
github | opal/opal | https://github.com/opal/opal | lib/opal/source_map/file.rb | Ruby | mit | 4,915 | master | 7,807 | # frozen_string_literal: true
class Opal::SourceMap::File
include Opal::SourceMap::Map
attr_reader :fragments
attr_reader :file
attr_reader :source
def initialize(fragments, file, source, generated_code = nil)
@fragments = fragments
@file = file
@source = source
@names_map = Hash.new { |has... |
github | opal/opal | https://github.com/opal/opal | lib/opal/parser/source_buffer.rb | Ruby | mit | 4,915 | master | 212 | # frozen_string_literal: true
module Opal
module Parser
class SourceBuffer < ::Parser::Source::Buffer
def self.recognize_encoding(string)
super || Encoding::UTF_8
end
end
end
end |
github | opal/opal | https://github.com/opal/opal | lib/opal/parser/default_config.rb | Ruby | mit | 4,915 | master | 1,192 | # frozen_string_literal: true
module Opal
module Parser
module DefaultConfig
module ClassMethods
attr_accessor :diagnostics_consumer
def default_parser
parser = super
parser.diagnostics.all_errors_are_fatal = true
parser.diagnostics.ignore_warnings = fals... |
github | opal/opal | https://github.com/opal/opal | lib/opal/parser/patch.rb | Ruby | mit | 4,915 | master | 4,690 | # backtick_javascript: true
# frozen_string_literal: true
if RUBY_ENGINE == 'opal'
class Parser::Lexer
def source_buffer=(source_buffer)
@source_buffer = source_buffer
if @source_buffer
source = @source_buffer.source
# Force UTF8 unpacking even if JS works with UTF-16/UCS-2
#... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cache/file_cache.rb | Ruby | mit | 4,915 | master | 4,671 | # frozen_string_literal: true
require 'fileutils'
require 'zlib'
module Opal
module Cache
class FileCache
def initialize(dir: nil, max_size: nil)
@dir = dir || self.class.find_dir
# Store at most 32MB of cache - de facto this 32MB is larger,
# as we don't account for inode size for... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/chrome.rb | Ruby | mit | 4,915 | master | 7,554 | # frozen_string_literal: true
require 'shellwords'
require 'socket'
require 'timeout'
require 'tmpdir'
require 'rbconfig'
require 'opal/os'
module Opal
module CliRunners
class Chrome
SCRIPT_PATH = File.expand_path('cdp_interface.rb', __dir__).freeze
DEFAULT_CDP_HOST = 'localhost'
DEFAULT_CDP_... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/system_runner.rb | Ruby | mit | 4,915 | master | 2,197 | # frozen_string_literal: true
require 'tempfile'
require 'tmpdir'
require 'fileutils'
module Opal
VirtualFileObject = Struct.new(:path, keyword_init: true)
# Generic runner that will resort to calling an external program.
#
# @option :options [Hash,nil] :env a hash of options to be used as env in the
# c... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/server.rb | Ruby | mit | 4,915 | master | 1,673 | # frozen_string_literal: true
require 'opal/simple_server'
module Opal
module CliRunners
class Server
def self.call(data)
runner = new(data)
runner.run
runner.exit_status
end
def initialize(data)
options = data[:options] || {}
@builder = data[:builder]
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/applescript.rb | Ruby | mit | 4,915 | master | 781 | # frozen_string_literal: true
require 'opal/cli_runners/system_runner'
module Opal
module CliRunners
class Applescript
def self.call(data)
unless system('which osalang > /dev/null')
raise MissingJavaScriptSupport, 'JavaScript Automation is only supported by OS X Yosemite and above.'
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/nodejs.rb | Ruby | mit | 4,915 | master | 1,484 | # frozen_string_literal: true
require 'shellwords'
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'opal/os'
module Opal
module CliRunners
class Nodejs
if RUBY_ENGINE == 'opal'
# We can't rely on Opal.gem_dir for now...
NODE_PATH = 'stdlib/nodejs/node_modules'
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/cdp_interface.rb | Ruby | mit | 4,915 | master | 9,123 | # backtick_javascript: true
# frozen_string_literal: true
# This script I converted into Opal, so that I don't have to write
# buffer handling again. We have gets, Node has nothing close to it,
# even async.
# For CDP see docs/cdp_common.(md|json)
require 'opal/platform'
require 'nodejs/env'
%x{
var CDP = require("c... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/bun.rb | Ruby | mit | 4,915 | master | 670 | # frozen_string_literal: true
require 'shellwords'
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'opal/os'
module Opal
module CliRunners
class Bun
def self.call(data)
argv = data[:argv].dup.to_a
SystemRunner.call(data) do |tempfile|
opts = Shellwords.shel... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/firefox.rb | Ruby | mit | 4,915 | master | 16,575 | # frozen_string_literal: true
require 'shellwords'
require 'socket'
require 'timeout'
require 'tmpdir'
require 'rbconfig'
require 'opal/os'
require 'json'
require 'fileutils'
require 'net/http'
module Opal
module CliRunners
class Firefox
SCRIPT_PATH = File.expand_path('cdp_interface.rb', __dir__).freeze
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/deno.rb | Ruby | mit | 4,915 | master | 733 | # frozen_string_literal: true
require 'shellwords'
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'opal/os'
module Opal
module CliRunners
class Deno
def self.call(data)
argv = data[:argv].dup.to_a
SystemRunner.call(data) do |tempfile|
opts = Shellwords.she... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/compiler.rb | Ruby | mit | 4,915 | master | 3,591 | # frozen_string_literal: true
require 'opal/paths'
# The compiler runner will just output the compiled JavaScript
class Opal::CliRunners::Compiler
def self.call(data)
new(data).start
end
def initialize(data)
@options = data[:options] || {}
@builder_factory = data.fetch(:builder)
@map_fi... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/gjs.rb | Ruby | mit | 4,915 | master | 762 | # frozen_string_literal: true
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'shellwords'
module Opal
module CliRunners
# Gjs is GNOME's JavaScript runtime based on Mozilla SpiderMonkey
class Gjs
def self.call(data)
exe = ENV['GJS_PATH'] || 'gjs'
builder = data[:... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/mini_racer.rb | Ruby | mit | 4,915 | master | 1,149 | # frozen_string_literal: true
require 'mini_racer'
require 'opal/paths'
module Opal
module CliRunners
class MiniRacer
def self.call(data)
::MiniRacer::Platform.set_flags! :harmony
builder = data.fetch(:builder).call
output = data.fetch(:output)
# TODO: pass it
argv... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/safari.rb | Ruby | mit | 4,915 | master | 6,803 | # frozen_string_literal: true
require 'shellwords'
require 'socket'
require 'timeout'
require 'tmpdir'
require 'rbconfig'
require 'opal/os'
require 'net/http'
require 'webrick'
module Opal
module CliRunners
class Safari
EXECUTION_TIMEOUT = 600 # seconds
DEFAULT_SAFARI_DRIVER_HOST = 'localhost'
... |
github | opal/opal | https://github.com/opal/opal | lib/opal/cli_runners/quickjs.rb | Ruby | mit | 4,915 | master | 712 | # frozen_string_literal: true
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'shellwords'
module Opal
module CliRunners
# QuickJS is Fabrice Bellard's minimalistic JavaScript engine
# https://github.com/bellard/quickjs
class Quickjs
def self.call(data)
exe = ENV['QJS... |
github | opal/opal | https://github.com/opal/opal | lib/tilt/opal.rb | Ruby | mit | 4,915 | master | 1,161 | # frozen_string_literal: true
require 'tilt'
require 'opal/builder'
require 'opal/config'
require 'opal/version'
module Opal
class TiltTemplate < Tilt::Template
self.default_mime_type = 'application/javascript'
def self.inherited(subclass)
subclass.default_mime_type = 'application/javascript'
end... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | simplecov.gemspec | Ruby | mit | 4,885 | main | 1,660 | # frozen_string_literal: true
$LOAD_PATH.push File.expand_path("lib", __dir__)
# Why oh why oh what is this?
# See the cuke that is setting this.
# Basically to really reproduce #877 we needed a gemspec that doesn't
# (indirectly) define a SimpleCov module... so this is the workaround.
version =
if ENV["SIMPLECOV_N... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | Gemfile | Ruby | mit | 4,885 | main | 447 | # frozen_string_literal: true
source "https://rubygems.org"
group :development do
gem "nokogiri"
gem "cuprite"
gem "aruba", ">= 2.0"
gem "capybara"
gem "rackup"
gem "cucumber"
gem "minitest"
gem "rake"
gem "rspec"
gem "rubocop" if RUBY_VERSION > "3.2"
gem "test-unit"
# Explicitly add webrick b... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | Rakefile | Ruby | mit | 4,885 | main | 1,959 | # frozen_string_literal: true
require "rubygems"
require "bundler/setup"
Bundler::GemHelper.install_tasks
# See https://github.com/simplecov-ruby/simplecov/issues/171
desc "Set permissions on all files so they are compatible with both user-local and system-wide installs"
task :fix_permissions do
system 'bash -c "fi... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/support/env.rb | Ruby | mit | 4,885 | main | 2,119 | # frozen_string_literal: true
# While you're here, handy tip for debugging: try to attach @announce-output
# @announce-command to the scenarios/features to see what's going on
require "bundler"
Bundler.setup
require "capybara/cucumber"
require "capybara/cuprite"
require "aruba/cucumber"
require "aruba/config/jruby" i... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/old_coverage_json_steps.rb | Ruby | mit | 4,885 | main | 777 | # frozen_string_literal: true
RESULTSET_JSON_PATH = "coverage/.resultset.json"
PATH_PLACE_HOLDER = "$$path"
COMMAND_NAME = "RSpec Different Name to avoid overriding"
Given "the paths in the old .resultset.json are adjusted to the current environment" do
in_current_directory do
resultset_json_content = File.read... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/html_steps.rb | Ruby | mit | 4,885 | main | 4,974 | # frozen_string_literal: true
Then /^I should see the groups:$/ do |table|
expected_groups = table.hashes
expect(page).to have_css("#content .file_list_container", count: expected_groups.count)
expected_groups.each do |group|
with_scope "#content ##{group['name'].gsub(/[^a-z]/i, '')}.file_list_container" do... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/parameter_types.rb | Ruby | mit | 4,885 | main | 633 | # frozen_string_literal: true
#
# Enforce the alphabetical execution of specs because rspec 2+ executes them
# randomly with `rspec spec` while we need them in an accurate order for coverage
# reports that include the spec files.
#
# This is due to the fact that coverage will not include the first loaded spec/test fil... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/parallel_tests_steps.rb | Ruby | mit | 4,885 | main | 1,562 | # frozen_string_literal: true
Then "I should see the line coverage results for the parallel tests project" do
steps %(
Then I should see the groups:
| name | coverage | files |
| All Files | 89.36% | 9 |
And I should see the source files:
| name | coverage |
| li... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/json_steps.rb | Ruby | mit | 4,885 | main | 820 | # frozen_string_literal: true
Then /^the JSON coverage report should match the output for the basic case$/ do
cd(".") do
json_report = JSON.parse(File.read("coverage/coverage.json"))
coverage_hash = json_report.fetch "coverage"
directory = Dir.pwd
faked_project = coverage_hash.fetch("#{directory}/li... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/web_steps.rb | Ruby | mit | 4,885 | main | 2,016 | # frozen_string_literal: true
module WithinHelpers
def with_scope(locator)
locator ? within(locator) { yield } : yield
end
end
World(WithinHelpers)
When /^I open the coverage report$/ do
visit "/"
# New simplecov-html shows #wrapper via jQuery .show() after JS init;
# wait for that or for old format whe... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | features/step_definitions/simplecov_steps.rb | Ruby | mit | 4,885 | main | 3,317 | # frozen_string_literal: true
# Just a shortcut to make framework setup more readable
# The test project is using separate config files to avoid specifying all of
# test/spec_helper in the features every time.
Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
framework_dir =
case frame... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/simplecov.rb | Ruby | mit | 4,885 | main | 16,443 | # frozen_string_literal: true
require "English"
# Coverage may be inaccurate under JRUBY.
if defined?(JRUBY_VERSION) && defined?(JRuby) && !org.jruby.RubyInstanceConfig.FULL_TRACE_ENABLED
# @see https://github.com/jruby/jruby/issues/1196
# @see https://github.com/metricfu/metric_fu/pull/226
# @see https://gith... |
github | simplecov-ruby/simplecov | https://github.com/simplecov-ruby/simplecov | lib/minitest/simplecov_plugin.rb | Ruby | mit | 4,885 | main | 411 | # frozen_string_literal: true
# How minitest plugins. See https://github.com/simplecov-ruby/simplecov/pull/756 for why we need this.
# https://github.com/seattlerb/minitest#writing-extensions
module Minitest
def self.plugin_simplecov_init(_options)
if defined?(SimpleCov)
SimpleCov.external_at_exit = true
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.