Skip to content
Snippets Groups Projects
Commit ab441221 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

frameToEnvironment doesn't need TruffleBoundary

parent 5b66027e
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,7 @@ public abstract class Xtfrm extends RBuiltinNode.Arg1 { ...@@ -64,7 +64,7 @@ public abstract class Xtfrm extends RBuiltinNode.Arg1 {
REnvironment env = RArguments.getEnvironment(frame); REnvironment env = RArguments.getEnvironment(frame);
if (createProfile.profile(env == null)) { if (createProfile.profile(env == null)) {
env = REnvironment.createEnclosingEnvironments(frame.materialize()); env = REnvironment.frameToEnvironment(frame.materialize());
} }
RFunction func = (RFunction) getNode.execute(frame, "xtfrm.default", env, RType.Function.getName(), true); RFunction func = (RFunction) getNode.execute(frame, "xtfrm.default", env, RType.Function.getName(), true);
return RContext.getEngine().evalFunction(func, null, null, true, null, x); return RContext.getEngine().evalFunction(func, null, null, true, null, x);
......
...@@ -146,7 +146,7 @@ public final class EnvironmentNodes { ...@@ -146,7 +146,7 @@ public final class EnvironmentNodes {
} }
REnvironment env = RArguments.getEnvironment(enclosing); REnvironment env = RArguments.getEnvironment(enclosing);
if (createProfile.profile(env == null)) { if (createProfile.profile(env == null)) {
return REnvironment.createEnclosingEnvironments(enclosing.materialize()); return REnvironment.frameToEnvironment(enclosing.materialize());
} }
return env; return env;
} }
......
...@@ -660,27 +660,8 @@ public abstract class REnvironment extends RAttributeStorage { ...@@ -660,27 +660,8 @@ public abstract class REnvironment extends RAttributeStorage {
MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame; MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame;
REnvironment env = RArguments.getEnvironment(f); REnvironment env = RArguments.getEnvironment(f);
if (env == null) { if (env == null) {
if (RArguments.getFunction(f) == null) { assert RArguments.getFunction(f) != null;
throw RInternalError.shouldNotReachHere(); RArguments.setEnvironment(f, env = new REnvironment.Function(f));
}
env = createEnclosingEnvironments(f);
}
return env;
}
/**
* This chain can be followed back to whichever "base" (i.e. non-function) environment the
* outermost function was defined in, e.g. "global" or "base". The purpose of this method is to
* create an analogous lexical parent chain of {@link Function} instances with the correct
* {@link MaterializedFrame}.
*/
@TruffleBoundary
public static REnvironment createEnclosingEnvironments(MaterializedFrame frame) {
MaterializedFrame f = frame instanceof VirtualEvalFrame ? ((VirtualEvalFrame) frame).getOriginalFrame() : frame;
REnvironment env = RArguments.getEnvironment(f);
if (env == null) {
// parent is the env of the enclosing frame
env = REnvironment.Function.create(f);
} }
return env; return env;
} }
...@@ -1068,14 +1049,6 @@ public abstract class REnvironment extends RAttributeStorage { ...@@ -1068,14 +1049,6 @@ public abstract class REnvironment extends RAttributeStorage {
// function environments are not named // function environments are not named
super(UNNAMED, frame); super(UNNAMED, frame);
} }
private static Function create(MaterializedFrame frame) {
Function result = (Function) RArguments.getEnvironment(frame);
if (result == null) {
result = new Function(frame);
}
return result;
}
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment