Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (39 sloc) 1.029 kb
8e1223c @tenderlove johnson needs date from core.js
tenderlove authored
1 require 'date'
2c8606c @jbarnette Add a bunch of improvements to bin/johnson. All of these can be speci…
authored
2 require "generator"
a2a230e Beginnings of method support on SpiderMonkey::Proxy, moving a few thi…
jbarnette authored
3
be42be5 @matthewd Make J::SM::Runtime a subclass of J::Runtime.
matthewd authored
4 # the 'public' interface
5 require "johnson/error"
6 require "johnson/runtime"
7 require "johnson/ruby_land_proxy"
8 require "johnson/parser"
d50ae78 Skeletal delegating Johnson::Context.
jbarnette authored
9
58b43de Fixin' order.
jbarnette authored
10 # visitable module and visitors
11 require "johnson/visitable"
12 require "johnson/visitors"
13
14 # parse tree nodes
15 require "johnson/nodes"
16
be42be5 @matthewd Make J::SM::Runtime a subclass of J::Runtime.
matthewd authored
17 # SpiderMonkey, the default JS engine
18 require "johnson/spidermonkey"
45990a2 Pulled in the Johnson Prelude, including Ruby.Symbol.
jbarnette authored
19
20 module Johnson
eea1e28 @jbarnette Prep for v1.2.0.
authored
21 VERSION = "1.2.0"
3f5616e @jbarnette Separate version file is pointless.
authored
22
afb6861 @matthewd Vague attempt to make the API look more documented.
matthewd authored
23 ###
24 # Evaluate the given JavaScript +expression+ in a new runtime, after
25 # setting the given +vars+ into the global object.
26 #
27 # Returns the result of evaluating the given expression.
9e2e650 Added Johnson.evaluate() as a simple front-end.
jbarnette authored
28 def self.evaluate(expression, vars={})
ae3584f @jbarnette Runtime is the new Context. One context per Ruby thread.
authored
29 runtime = Johnson::Runtime.new
30 vars.each { |key, value| runtime[key] = value }
3f5616e @jbarnette Separate version file is pointless.
authored
31
ae3584f @jbarnette Runtime is the new Context. One context per Ruby thread.
authored
32 runtime.evaluate(expression)
9e2e650 Added Johnson.evaluate() as a simple front-end.
jbarnette authored
33 end
3f5616e @jbarnette Separate version file is pointless.
authored
34
27a28d8 @tenderlove fixing warnings, accepting *args
tenderlove authored
35 def self.parse(js, *args)
36 Johnson::Parser.parse(js, *args)
6603ac4 @jbarnette Make Johnson.parse() an alias for Johnson::Parser.parse().
authored
37 end
a6aad5a @tenderlove adding some utility methods and rdoc
tenderlove authored
38
c1b88cc @jbarnette Revert "Ruby.Class.prototype, not totally robust."
authored
39 ###
afb6861 @matthewd Vague attempt to make the API look more documented.
matthewd authored
40 # Create a new runtime and load all +files+.
41 #
42 # Returns the new Johnson::Runtime.
a6aad5a @tenderlove adding some utility methods and rdoc
tenderlove authored
43 def self.load(*files)
44 rt = Johnson::Runtime.new
45 rt.load(*files)
46 rt
47 end
45990a2 Pulled in the Johnson Prelude, including Ruby.Symbol.
jbarnette authored
48 end
Something went wrong with that request. Please try again.