Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Committing follow-up compiler changes for Tom's CRef mods. All tests …

…pass, looks good.

git-svn-id: http://svn.codehaus.org/jruby/branches/enebo@3983 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 6dece2b126b72d1289d0a55dbe91879476f01b7d 1 parent 45b577e
Charles Oliver Nutter headius authored
19 src/org/jruby/Ruby.java
@@ -56,6 +56,7 @@
56 56 import java.util.Stack;
57 57 import java.util.WeakHashMap;
58 58 import org.jruby.ast.Node;
  59 +import org.jruby.ast.RootNode;
59 60 import org.jruby.ast.executable.Script;
60 61 import org.jruby.ast.executable.YARVCompiledRunner;
61 62 import org.jruby.common.RubyWarnings;
@@ -88,6 +89,7 @@
88 89 import org.jruby.ext.Generator;
89 90 import org.jruby.ext.Readline;
90 91 import org.jruby.parser.Parser;
  92 +import org.jruby.parser.StaticScope;
91 93 import org.jruby.runtime.Block;
92 94 import org.jruby.runtime.CacheMap;
93 95 import org.jruby.runtime.CallbackFactory;
@@ -319,7 +321,22 @@ public IRubyObject compileOrFallbackAndRun(Node node) {
319 321 }
320 322
321 323 // FIXME: Pass something better for args and block here?
322   - return script.run(getCurrentContext(), tc.getFrameSelf(), IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
  324 + try {
  325 + DynamicScope scope = new DynamicScope(((RootNode)node).getStaticScope());
  326 +
  327 + StaticScope staticScope = scope.getStaticScope();
  328 +
  329 + if (staticScope.getModule() == null) {
  330 + staticScope.setModule(getObject());
  331 + }
  332 +
  333 + // Each root node has a top-level scope that we need to push
  334 + getCurrentContext().preRootNode(scope);
  335 +
  336 + return script.run(getCurrentContext(), tc.getFrameSelf(), IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
  337 + } finally {
  338 + getCurrentContext().postRootNode();
  339 + }
323 340 } else {
324 341 return eval(node);
325 342 }
1  src/org/jruby/internal/runtime/methods/InvocationMethodFactory.java
@@ -81,7 +81,6 @@ private ClassWriter createCompiledCtor(String namePath, String sup) throws Excep
81 81 mv.visitVarInsn(ALOAD, 2);
82 82 mv.visitVarInsn(ALOAD, 3);
83 83 mv.visitVarInsn(ALOAD, 4);
84   - mv.visitVarInsn(ALOAD, 5);
85 84 mv.visitMethodInsn(INVOKESPECIAL, sup, "<init>", COMPILED_SUPER_SIG);
86 85 mv.visitInsn(RETURN);
87 86 mv.visitMaxs(0,0);
4 src/org/jruby/javasupport/util/CompilerHelpers.java
@@ -39,6 +39,7 @@ public static CompiledBlock createBlock(ThreadContext context, IRubyObject self,
39 39 String[] staticScopeNames, CompiledBlockCallback callback) {
40 40 StaticScope staticScope =
41 41 new BlockStaticScope(context.getCurrentScope().getStaticScope(), staticScopeNames);
  42 + staticScope.determineModule();
42 43
43 44 return new CompiledBlock(context, self, Arity.createArity(arity),
44 45 new DynamicScope(staticScope, context.getCurrentScope()), callback);
@@ -57,7 +58,8 @@ public static IRubyObject def(ThreadContext context, Visibility visibility, IRub
57 58 runtime.getWarnings().warn("redefining Object#initialize may cause infinite loop");
58 59 }
59 60
60   - StaticScope scope = new LocalStaticScope(null, scopeNames);
  61 + StaticScope scope = new LocalStaticScope(context.getCurrentScope().getStaticScope(), scopeNames);
  62 + scope.determineModule();
61 63
62 64 MethodFactory factory = MethodFactory.createFactory(compiledClass.getClassLoader());
63 65 DynamicMethod method;

0 comments on commit 6dece2b

Please sign in to comment.
Something went wrong with that request. Please try again.