<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/johnson/ruby_land_proxy.rb</filename>
    </added>
    <added>
      <filename>lib/johnson/spidermonkey.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -9,8 +9,8 @@
 /ext/spidermonkey/*.o
 /ext/spidermonkey/*.so
 
-/lib/johnson/*.bundle
-/lib/johnson/*.so
+/lib/johnson/spidermonkey/*.bundle
+/lib/johnson/spidermonkey/*.so
 
 /vendor/spidermonkey/*.OBJ
 </diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,7 @@ Hoe.spec &quot;johnson&quot; do
   clean_globs    &lt;&lt; &quot;vendor/spidermonkey/**/*.OBJ&quot;
 
   Rake::ExtensionTask.new &quot;spidermonkey&quot;, spec do |ext|
-    ext.lib_dir = &quot;lib/johnson&quot;
+    ext.lib_dir = &quot;lib/johnson/spidermonkey&quot;
   end
 end
 </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -567,8 +567,11 @@ void init_Johnson_SpiderMonkey_Proxy(VALUE spidermonkey)
   VALUE spidermonkey = rb_define_module_under(johnson, &quot;SpiderMonkey&quot;);
   */
 
+  VALUE johnson = rb_const_get(rb_mKernel, rb_intern(&quot;Johnson&quot;));
+  VALUE johnson_proxy = rb_const_get(johnson, rb_intern(&quot;RubyLandProxy&quot;));
+
   /* RubyLandProxy class. */
-  proxy_class = rb_define_class_under(spidermonkey, &quot;RubyLandProxy&quot;, rb_cObject);
+  proxy_class = rb_define_class_under(spidermonkey, &quot;RubyLandProxy&quot;, johnson_proxy);
 
   rb_define_method(proxy_class, &quot;[]&quot;, get, 1);
   rb_define_method(proxy_class, &quot;[]=&quot;, set, 2);</diff>
      <filename>ext/spidermonkey/ruby_land_proxy.c</filename>
    </modified>
    <modified>
      <diff>@@ -375,7 +375,10 @@ void init_Johnson_SpiderMonkey_Runtime(VALUE spidermonkey)
   VALUE spidermonkey = rb_define_module_under(johnson, &quot;SpiderMonkey&quot;);
   */
 
-  VALUE klass = rb_define_class_under(spidermonkey, &quot;Runtime&quot;, rb_cObject);
+  VALUE johnson = rb_const_get(rb_mKernel, rb_intern(&quot;Johnson&quot;));
+  VALUE johnson_runtime = rb_const_get(johnson, rb_intern(&quot;Runtime&quot;));
+
+  VALUE klass = rb_define_class_under(spidermonkey, &quot;Runtime&quot;, johnson_runtime);
 
   rb_define_alloc_func(klass, allocate);
   rb_define_private_method(klass, &quot;initialize_native&quot;, initialize_native, 1);</diff>
      <filename>ext/spidermonkey/runtime.c</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ void Init_spidermonkey()
 {
   JS_SetCStringsAreUTF8();
 
-  VALUE johnson = rb_define_module(&quot;Johnson&quot;); // FIXME: this belongs outside the extension
+  VALUE johnson = rb_const_get(rb_mKernel, rb_intern(&quot;Johnson&quot;));
   VALUE spidermonkey = rb_define_module_under(johnson, &quot;SpiderMonkey&quot;);
   
   init_Johnson_SpiderMonkey_Context(spidermonkey);</diff>
      <filename>ext/spidermonkey/spidermonkey.c</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,10 @@
 require &quot;generator&quot;
 
-# the native SpiderMonkey extension
-require &quot;johnson/spidermonkey&quot;
+# the 'public' interface
+require &quot;johnson/error&quot;
+require &quot;johnson/runtime&quot;
+require &quot;johnson/ruby_land_proxy&quot;
+require &quot;johnson/parser&quot;
 
 # visitable module and visitors
 require &quot;johnson/visitable&quot;
@@ -10,19 +13,8 @@ require &quot;johnson/visitors&quot;
 # parse tree nodes
 require &quot;johnson/nodes&quot;
 
-# the SpiderMonkey bits written in Ruby
-require &quot;johnson/spidermonkey/runtime&quot;
-require &quot;johnson/spidermonkey/context&quot;
-require &quot;johnson/spidermonkey/js_land_proxy&quot;
-require &quot;johnson/spidermonkey/ruby_land_proxy&quot;
-require &quot;johnson/spidermonkey/mutable_tree_visitor&quot;
-require &quot;johnson/spidermonkey/debugger&quot;
-require &quot;johnson/spidermonkey/immutable_node&quot;
-
-# the 'public' interface
-require &quot;johnson/error&quot;
-require &quot;johnson/runtime&quot;
-require &quot;johnson/parser&quot;
+# SpiderMonkey, the default JS engine
+require &quot;johnson/spidermonkey&quot;
 
 module Johnson
   VERSION = &quot;1.1.2&quot;</diff>
      <filename>lib/johnson.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,51 +4,80 @@ module Johnson
   class Runtime
 
     PRELUDE_PATH = File.expand_path File.dirname(__FILE__) +
-      &quot;/js/prelude.js&quot;
+      &quot;/js/prelude.js&quot; # :nodoc:
 
-    PRELUDE = IO.read PRELUDE_PATH
+    PRELUDE = IO.read PRELUDE_PATH # :nodoc:
 
     ###
-    # The underlying JavaScript engine instance.
-    attr_reader :delegate
+    # Deprecated: Previously, returned the underlying JavaScript engine
+    # instance. Now returns self.
+    def delegate
+      self
+    end
+
+    ###
+    # Create a new Runtime instance, using the default JavaScript
+    # engine.
+    #
+    # Optionally takes a parameter specifying which engine to use, but
+    # this is deprecated; instead, just create an instance of that
+    # engine's runtime directly.
+    #
+    # :call-seq:
+    #   new(runtime_class=nil)
+    #
+    def self.new(*args)
+      return super if self &lt; Johnson::Runtime
+
+      delegate = args.first
+      if delegate.is_a? Class
+        delegate.new
+      elsif delegate
+        delegate
+      else
+        Johnson::SpiderMonkey::Runtime.new
+      end
+    end
 
     ###
-    # Create a new Runtime instance, using the given +delegate+ class,
-    # or a Johnson::SpiderMonkey::Runtime by default.
-    def initialize(delegate=Johnson::SpiderMonkey::Runtime)
-      @delegate = delegate.is_a?(Class) ? delegate.new : delegate
+    # Install the Johnson prelude into this runtime environment.
+    def initialize # :notnew:
       evaluate PRELUDE, PRELUDE_PATH, 1
       global.Johnson.runtime = self
+      global['Ruby'] = Object
     end
 
     ###
     # Access the +key+ property of the JavaScript +global+ object.
     def [](key)
-      delegate[key]
+      global[key]
     end
 
     ###
     # Set the +key+ property of the JavaScript +global+ object to
     # +value+.
     def []=(key, value)
-      delegate[key] = value
+      global[key] = value
     end
 
+
     ###
     # Execute the JavaScript source in +script+. If supplied, the script
     # is marked as starting on line +linenum+ of +filename+.
     #
     # Equivalent to calling RubyLandScript#execute on the result of
     # Runtime#compile.
-    def evaluate(script, filename=nil, linenum=nil)
+    def evaluate(script, filename = nil, linenum = nil)
       return nil if script.nil?
-      delegate.evaluate(script, filename, linenum)
+      compiled_script = compile(script, filename, linenum)
+      evaluate_compiled_script(compiled_script)
     end
 
+
     ###
     # The JavaScript unique Global Object.
     def global
-      delegate.global
+      raise NotImplementedError
     end
 
     ###
@@ -57,7 +86,7 @@ module Johnson
     # Checks for (and skips) a shebang line at the top of any of them.
     def load(*files)
       files.map { |f|
-        delegate.evaluate(File.read(f).gsub(/\A#!.*$/, ''), f, 1)
+        evaluate(File.read(f).gsub(/\A#!.*$/, ''), f, 1)
       }.last
     end
 
@@ -76,11 +105,14 @@ module Johnson
     # Compile the JavaScript source in +script+. If supplied, the script
     # is marked as starting on line +linenum+ of +filename+.
     def compile(script, filename=nil, linenum=nil)
-      delegate.compile(script, filename, linenum)
+      raise NotImplementedError
     end
 
+    ###
+    # Evaluates the given JS script, that should have been returned by a
+    # previous call to #compile().
     def evaluate_compiled_script(script)
-      delegate.evaluate_compiled(script)
+      raise NotImplementedError
     end
   end
 end</diff>
      <filename>lib/johnson/runtime.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,54 +1,9 @@
 module Johnson #:nodoc:
   module SpiderMonkey #:nodoc:
-    class RubyLandProxy # native
-      include Enumerable
-      
-      def initialize
-        raise Johnson::Error, &quot;#{self.class.name} is an internal support class.&quot;
-      end
-      
-      private :initialize
-      
-      # FIXME: need to revisit array vs non-array proxy, to_a/to_ary semantics, etc.
-      alias_method :size, :length
-      alias_method :to_ary, :to_a
-      
-      def to_proc
-        @proc ||= Proc.new { |*args| call(*args) }
-      end
-
-      def call(*args)
-        call_using(runtime.global, *args)
-      end
-
+    class RubyLandProxy &lt; Johnson::RubyLandProxy # native
       def call_using(this, *args)
         native_call(this, *args)
       end
-      
-      def inspect
-        toString
-      end
-      
-      def method_missing(sym, *args, &amp;block)
-        args &lt;&lt; block if block_given?
-        
-        name = sym.to_s
-        assignment = &quot;=&quot; == name[-1, 1]
-        
-        # default behavior if the slot's not there
-        return super unless assignment || respond_to?(sym)
-        
-        unless function_property?(name)
-          # for arity 0, treat it as a get
-          return self[name] if args.empty?
-
-          # arity 1 and quacking like an assignment, treat it as a set
-          return self[name[0..-2]] = args[0] if assignment &amp;&amp; 1 == args.size
-        end        
-        
-        # okay, must really be a function
-        call_function_property(name, *args)
-      end
     end
     class RubyLandScript &lt; RubyLandProxy # native
       def break(linenum, &amp;block)</diff>
      <filename>lib/johnson/spidermonkey/ruby_land_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 module Johnson #:nodoc:
   module SpiderMonkey #:nodoc:
-    class Runtime # native
+    class Runtime &lt; Johnson::Runtime # native
       CONTEXT_MAP_KEY = :johnson_context_map
 
       attr_reader :traps
@@ -9,7 +9,7 @@ module Johnson #:nodoc:
         @gcthings = {}
         @traps = []
         initialize_native(options)
-        self[&quot;Ruby&quot;] = Object
+        super()
       end
       
       # called from js_land_proxy.c:make_js_land_proxy
@@ -31,23 +31,10 @@ module Johnson #:nodoc:
         contexts[self.object_id] ||= Context.new(self)
       end
 
-      def [](key)
-        global[key]
-      end
-      
-      def []=(key, value)
-        global[key] = value
-      end
-
-      ###
-      # Evaluate +script+ with +filename+ and +linenum+
-      def evaluate(script, filename = nil, linenum = nil)
-        compiled_script = compile(script, filename, linenum)
-        evaluate_compiled_script(compiled_script)
-      end
-
-      def evaluate_compiled script
-        evaluate_compiled_script(script)
+      alias :evaluate_compiled_script_without_clearing_traps :evaluate_compiled_script
+      def evaluate_compiled_script script
+        evaluate_compiled_script_without_clearing_traps(script)
+      ensure
         @traps.each do |trap_tuple|
           clear_trap(*trap_tuple)
         end</diff>
      <filename>lib/johnson/spidermonkey/runtime.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>08405b447d2db8c4abc3864860f9e798400ce653</id>
    </parent>
  </parents>
  <author>
    <name>Matthew Draper</name>
    <email>matthew@trebex.net</email>
  </author>
  <url>http://github.com/jbarnette/johnson/commit/be42be52244cd14ce6dced2c77dd23586c895f14</url>
  <id>be42be52244cd14ce6dced2c77dd23586c895f14</id>
  <committed-date>2009-10-03T07:39:16-07:00</committed-date>
  <authored-date>2009-10-03T07:21:02-07:00</authored-date>
  <message>Make J::SM::Runtime a subclass of J::Runtime.

Similarly, invent a J::RubyLandProxy, which is the superclass of
J::SM::RubyLandProxy.

Neither of these classes are useful in themselves, without an
engine-specific subclass providing the real implementation... but their
separate existence should simplify documenting the user-relevant API.</message>
  <tree>4c957b6cd20aad91622ce4f8c10daf18e857dd96</tree>
  <committer>
    <name>Matthew Draper</name>
    <email>matthew@trebex.net</email>
  </committer>
</commit>
