Skip to content

Commit

Permalink
Committing follow-up compiler changes for Tom's CRef mods. All tests …
Browse files Browse the repository at this point in the history
…pass, looks good.

git-svn-id: http://svn.codehaus.org/jruby/branches/enebo@3983 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed Jul 9, 2007
1 parent 45b577e commit 6dece2b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/org/jruby/Ruby.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/org/jruby/javasupport/util/CompilerHelpers.java
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 6dece2b

Please sign in to comment.