Module: Johnson

Defined in:
lib/johnson/cli.rb,
lib/johnson.rb,
lib/johnson/error.rb,
lib/johnson/parser.rb,
lib/johnson/runtime.rb,
lib/johnson/nodes/for.rb,
lib/johnson/visitable.rb,
lib/johnson/nodes/list.rb,
lib/johnson/nodes/node.rb,
lib/johnson/cli/options.rb,
lib/johnson/nodes/for_in.rb,
lib/johnson/nodes/function.rb,
lib/johnson/ruby_land_proxy.rb,
lib/johnson/visitors/visitor.rb,
lib/johnson/nodes/binary_node.rb,
lib/johnson/nodes/ternary_node.rb,
lib/johnson/parser/syntax_error.rb,
lib/johnson/tracemonkey/context.rb,
lib/johnson/tracemonkey/runtime.rb,
lib/johnson/spidermonkey/context.rb,
lib/johnson/spidermonkey/runtime.rb,
lib/johnson/tracemonkey/debugger.rb,
lib/johnson/visitors/dot_visitor.rb,
lib/johnson/spidermonkey/debugger.rb,
lib/johnson/visitors/ecma_visitor.rb,
lib/johnson/visitors/sexp_visitor.rb,
lib/johnson/tracemonkey/js_land_proxy.rb,
lib/johnson/spidermonkey/js_land_proxy.rb,
lib/johnson/tracemonkey/immutable_node.rb,
lib/johnson/spidermonkey/immutable_node.rb,
lib/johnson/tracemonkey/ruby_land_proxy.rb,
lib/johnson/spidermonkey/ruby_land_proxy.rb,
lib/johnson/visitors/enumerating_visitor.rb,
lib/johnson/tracemonkey/mutable_tree_visitor.rb,
lib/johnson/spidermonkey/mutable_tree_visitor.rb

Overview

:nodoc:

Defined Under Namespace

Modules: CLI, Nodes, Parser, SpiderMonkey, TraceMonkey, Visitable, Visitors Classes: Error, RubyLandProxy, Runtime

Constant Summary collapse

VERSION =
"1.1.2.6"

Class Method Summary collapse

Class Method Details

.evaluate(expression, vars = {}) ⇒ Object

Evaluate the given JavaScript expression in a new runtime, after setting the given vars into the global object.

Returns the result of evaluating the given expression.



28
29
30
31
32
33
# File 'lib/johnson.rb', line 28

def self.evaluate(expression, vars={})
  runtime = Johnson::Runtime.new
  vars.each { |key, value| runtime[key] = value }

  runtime.evaluate(expression)
end

.load(*files) ⇒ Object

Create a new runtime and load all files.

Returns the new Johnson::Runtime.



43
44
45
46
47
# File 'lib/johnson.rb', line 43

def self.load(*files)
  rt = Johnson::Runtime.new
  rt.load(*files)
  rt
end

.parse(js, *args) ⇒ Object



35
36
37
# File 'lib/johnson.rb', line 35

def self.parse(js, *args)
  Johnson::Parser.parse(js, *args)
end

.runtimesObject



49
50
51
# File 'lib/johnson.rb', line 49

def self.runtimes
  Runtime.runtimes
end

.versionObject



19
20
21
# File 'lib/johnson.rb', line 19

def self.version
  VERSION
end