Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -56,6 +56,7 @@
import java.util.Stack;
import java.util.WeakHashMap;
import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
import org.jruby.ast.executable.Script;
import org.jruby.ast.executable.YARVCompiledRunner;
import org.jruby.common.RubyWarnings;
@@ -88,6 +89,7 @@
import org.jruby.ext.Generator;
import org.jruby.ext.Readline;
import org.jruby.parser.Parser;
+import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.CacheMap;
import org.jruby.runtime.CallbackFactory;
@@ -319,7 +321,22 @@ public IRubyObject compileOrFallbackAndRun(Node node) {
}
// FIXME: Pass something better for args and block here?
- return script.run(getCurrentContext(), tc.getFrameSelf(), IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
+ try {
+ DynamicScope scope = new DynamicScope(((RootNode)node).getStaticScope());
+
+ StaticScope staticScope = scope.getStaticScope();
+
+ if (staticScope.getModule() == null) {
+ staticScope.setModule(getObject());
+ }
+
+ // Each root node has a top-level scope that we need to push
+ getCurrentContext().preRootNode(scope);
+
+ return script.run(getCurrentContext(), tc.getFrameSelf(), IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
+ } finally {
+ getCurrentContext().postRootNode();
+ }
} else {
return eval(node);
}
1  src/org/jruby/internal/runtime/methods/InvocationMethodFactory.java
View
@@ -81,7 +81,6 @@ private ClassWriter createCompiledCtor(String namePath, String sup) throws Excep
mv.visitVarInsn(ALOAD, 2);
mv.visitVarInsn(ALOAD, 3);
mv.visitVarInsn(ALOAD, 4);
- mv.visitVarInsn(ALOAD, 5);
mv.visitMethodInsn(INVOKESPECIAL, sup, "<init>", COMPILED_SUPER_SIG);
mv.visitInsn(RETURN);
mv.visitMaxs(0,0);
4 src/org/jruby/javasupport/util/CompilerHelpers.java
View
@@ -39,6 +39,7 @@ public static CompiledBlock createBlock(ThreadContext context, IRubyObject self,
String[] staticScopeNames, CompiledBlockCallback callback) {
StaticScope staticScope =
new BlockStaticScope(context.getCurrentScope().getStaticScope(), staticScopeNames);
+ staticScope.determineModule();
return new CompiledBlock(context, self, Arity.createArity(arity),
new DynamicScope(staticScope, context.getCurrentScope()), callback);
@@ -57,7 +58,8 @@ public static IRubyObject def(ThreadContext context, Visibility visibility, IRub
runtime.getWarnings().warn("redefining Object#initialize may cause infinite loop");
}
- StaticScope scope = new LocalStaticScope(null, scopeNames);
+ StaticScope scope = new LocalStaticScope(context.getCurrentScope().getStaticScope(), scopeNames);
+ scope.determineModule();
MethodFactory factory = MethodFactory.createFactory(compiledClass.getClassLoader());
DynamicMethod method;
Please sign in to comment.
Something went wrong with that request. Please try again.