lib/opal/nodes/runtime_helpers.rb in opal-0.10.6 vs lib/opal/nodes/runtime_helpers.rb in opal-0.11.0.rc1
- old
+ new
@@ -1,17 +1,22 @@
+# frozen_string_literal: true
require 'set'
require 'opal/nodes/base'
module Opal
module Nodes
class RuntimeHelpers < Base
HELPERS = Set.new
children :recvr, :meth, :arglist
+ def self.s(type, *children)
+ ::Opal::AST::Node.new(type, children)
+ end
+
def self.compatible?(recvr, meth, arglist)
- recvr == [:const, :Opal] and HELPERS.include?(meth.to_sym)
+ recvr == s(:const, nil, :Opal) and HELPERS.include?(meth.to_sym)
end
def self.helper(name, &block)
HELPERS << name
define_method("compile_#{name}", &block)
@@ -24,18 +29,18 @@
raise "Helper not supported: #{meth}"
end
end
helper :truthy? do
- unless sexp = arglist[1]
+ unless sexp = arglist.children[0]
raise "truthy? requires an object"
end
js_truthy(sexp)
end
helper :falsy? do
- unless sexp = arglist[1]
+ unless sexp = arglist.children[0]
raise "falsy? requires an object"
end
js_falsy(sexp)
end