Skip to content
Permalink
Browse files
Merge branch 'master' into update_stdlib
  • Loading branch information
headius committed Nov 4, 2014
2 parents 5c6293c + 4d070a8 commit 562620e8b7ecfe4879dd83837d538454558cd926
Showing 3 changed files with 12 additions and 51 deletions.
@@ -35,7 +35,7 @@
jar 'com.github.jnr:jnr-enxio:0.4'
jar 'com.github.jnr:jnr-x86asm:1.0.2'
jar 'com.github.jnr:jnr-unixsocket:0.3'
jar 'com.github.jnr:jnr-posix:3.0.2'
jar 'com.github.jnr:jnr-posix:3.0.7-SNAPSHOT'
jar 'com.github.jnr:jnr-constants:0.8.6-SNAPSHOT'
jar 'com.github.jnr:jnr-ffi:2.0.0-SNAPSHOT'
jar 'com.github.jnr:jffi:${jffi.version}'
@@ -71,7 +71,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.2</version>
<version>3.0.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
@@ -87,7 +87,6 @@ public static IRubyObject interpretCommonEval(Ruby runtime, String file, int lin
BeginEndInterpreterContext ic = (BeginEndInterpreterContext) evalScript.prepareForInterpretation();
ThreadContext context = runtime.getCurrentContext();

IRubyObject rv = null;
DynamicScope s = rootNode.getScope();
s.setEvalType(evalType);
context.pushScope(s);
@@ -103,21 +102,12 @@ public static IRubyObject interpretCommonEval(Ruby runtime, String file, int lin
s.growIfNeeded();

runBeginEndBlocks(evalScript.getBeginBlocks(), context, self, ss, null);
rv = evalScript.call(context, self, evalScript.getStaticScope().getModule(), block, backtraceName);
return evalScript.call(context, self, evalScript.getStaticScope().getModule(), block, backtraceName);
} finally {
runEndBlocks(ic.getEndBlocks(), context, self, ss, null);
s.clearEvalType();
context.popScope();
}
return rv;
}

public static IRubyObject interpretSimpleEval(Ruby runtime, String file, int lineNumber, String backtraceName, Node node, IRubyObject self, EvalType evalType) {
return interpretCommonEval(runtime, file, lineNumber, backtraceName, (RootNode)node, self, Block.NULL_BLOCK, evalType);
}

public static IRubyObject interpretBindingEval(Ruby runtime, String file, int lineNumber, String backtraceName, Node node, IRubyObject self, Block block) {
return interpretCommonEval(runtime, file, lineNumber, backtraceName, (RootNode)node, self, block, EvalType.BINDING_EVAL);
}

public static void runBeginEndBlocks(List<IRClosure> beBlocks, ThreadContext context, IRubyObject self, StaticScope currScope, Object[] temp) {
@@ -158,8 +148,6 @@ protected IRubyObject execute(Ruby runtime, IRScriptBody irScope, IRubyObject se
currModule = context.getRuntime().getObject();
}

IRubyObject retVal;

scope.setModule(currModule);
DynamicScope tlbScope = irScope.getTopLevelBindingScope();
if (tlbScope == null) {
@@ -171,18 +159,15 @@ protected IRubyObject execute(Ruby runtime, IRScriptBody irScope, IRubyObject se
context.setCurrentVisibility(Visibility.PRIVATE);

try {
Interpreter.runBeginEndBlocks(ic.getBeginBlocks(), context, self, scope, null);
retVal = Interpreter.INTERPRET_ROOT(context, self, ic, currModule, name);

Interpreter.dumpStats();
runBeginEndBlocks(ic.getBeginBlocks(), context, self, scope, null);
return INTERPRET_ROOT(context, self, ic, currModule, name);
} catch (IRBreakJump bj) {
throw IRException.BREAK_LocalJumpError.getException(context.runtime);
} finally {
Interpreter.runEndBlocks(ic.getEndBlocks(), context, self, scope, null);
runEndBlocks(ic.getEndBlocks(), context, self, scope, null);
dumpStats();
context.popScope();
}

return retVal;
}

private static void setResult(Object[] temp, DynamicScope currDynScope, Variable resultVar, Object result) {
@@ -726,34 +711,17 @@ public static IRubyObject INTERPRET_METHOD(ThreadContext context, InterpretedIRM
*/
public static IRubyObject evalSimple(ThreadContext context, IRubyObject self, RubyString src, String file, int lineNumber, EvalType evalType) {
Ruby runtime = context.runtime;

if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

// this is ensured by the caller
assert file != null;

// no binding, just eval in "current" frame (caller's frame)
RubyString source = src.convertToString();

DynamicScope evalScope = context.getCurrentScope().getEvalScope(runtime);
evalScope.getStaticScope().determineModule();

try {
Node node = runtime.parseEval(source.getByteList(), file, evalScope, lineNumber);
RootNode node = (RootNode) runtime.parseEval(src.convertToString().getByteList(), file, evalScope, lineNumber);

return Interpreter.interpretSimpleEval(runtime, file, lineNumber, "(eval)", node, self, evalType);
/*
* SSS FIXME: Why was this here?
* Do we need an IR equivalent here?
*
} catch (JumpException.BreakJump bj) {
throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, (IRubyObject)bj.getValue(), "unexpected break");
*/
} catch (StackOverflowError soe) {
throw runtime.newSystemStackError("stack level too deep", soe);
}
return interpretCommonEval(runtime, file, lineNumber, "(eval)", node, self, Block.NULL_BLOCK, evalType);
}

/**
@@ -771,25 +739,18 @@ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject sel
throw new UnsupportedOperationException();
}

DynamicScope evalScope;

// in 1.9, eval scopes are local to the binding
evalScope = binding.getEvalScope(runtime);
DynamicScope evalScope = binding.getEvalScope(runtime);
evalScope.setEvalType(EvalType.BINDING_EVAL);

// FIXME: This determine module is in a strange location and should somehow be in block
evalScope.getStaticScope().determineModule();

Frame lastFrame = context.preEvalWithBinding(binding);
try {
// Binding provided for scope, use it
RubyString source = src.convertToString();
Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine());
RootNode node = (RootNode) runtime.parseEval(src.convertToString().getByteList(), binding.getFile(), evalScope, binding.getLine());
Block block = binding.getFrame().getBlock();

return Interpreter.interpretBindingEval(runtime, binding.getFile(), binding.getLine(), binding.getMethod(), node, self, block);
} catch (StackOverflowError soe) {
throw runtime.newSystemStackError("stack level too deep", soe);
return interpretCommonEval(runtime, binding.getFile(), binding.getLine(), binding.getMethod(), node, self, block, EvalType.BINDING_EVAL);
} finally {
context.postEvalWithBinding(binding, lastFrame);
}

0 comments on commit 562620e

Please sign in to comment.