diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java index 114953b6d876bb669da1b887c726417ebca74dd1..92f93fec9898d1afc03cd00038904638dbd97284 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/REngine.java @@ -52,7 +52,7 @@ public final class REngine { private REngine(String[] commandArgs, ConsoleHandler consoleHandler) { RDefaultPackages defaultPackages = RDefaultPackages.getInstance(); this.context = RContext.instantiate(defaultPackages, commandArgs, consoleHandler); - defaultPackages.load(context); + defaultPackages.load(); } /** @@ -97,7 +97,7 @@ public final class REngine { private Object parseAndEvalImpl(ANTLRStringStream stream, Source source, VirtualFrame globalFrame, boolean printResult) { try { - RTruffleVisitor transform = new RTruffleVisitor(context); + RTruffleVisitor transform = new RTruffleVisitor(); RNode node = transform.transform(parseAST(stream, source)); FunctionDefinitionNode rootNode = new FunctionDefinitionNode(null, transform.getEnvironment(), node, RArguments.EMPTY_OBJECT_ARRAY, "<main>"); CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode); @@ -156,7 +156,7 @@ public final class REngine { private void printResult(Object result) { if (!(result instanceof RInvisible)) { - RFunction function = context.getLookup().lookup(context, "print"); + RFunction function = context.getLookup().lookup("print"); function.call(null, RArguments.create(function, new Object[]{result})).toString(); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java index 186e8160881ca9c51f51aeb7e52ab7aa7d34d04a..90116c236869e378c4ab8c59370a7492e228d16a 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RTruffleVisitor.java @@ -26,22 +26,21 @@ import com.oracle.truffle.api.*; import com.oracle.truffle.r.nodes.access.*; import com.oracle.truffle.r.nodes.access.ReadVariableNode.ReadSuperVariableNode; import com.oracle.truffle.r.nodes.binary.*; +import com.oracle.truffle.r.nodes.builtin.base.*; import com.oracle.truffle.r.nodes.control.*; import com.oracle.truffle.r.nodes.function.*; -import com.oracle.truffle.r.nodes.builtin.base.Invisible; import com.oracle.truffle.r.parser.ast.*; import com.oracle.truffle.r.parser.ast.Constant.ConstantType; +import com.oracle.truffle.r.parser.ast.Repeat; import com.oracle.truffle.r.parser.tools.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; public final class RTruffleVisitor extends BasicVisitor<RNode> { - private final RContext context; private REnvironment environment; - public RTruffleVisitor(RContext context) { - this.context = context; + public RTruffleVisitor() { this.environment = new REnvironment(); } @@ -64,9 +63,9 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { } switch (c.getType()) { case INT: - return ConstantNode.create(src, RRuntime.string2int(context, c.getValues()[0])); + return ConstantNode.create(src, RRuntime.string2int(c.getValues()[0])); case DOUBLE: - return ConstantNode.create(src, RRuntime.string2double(context, c.getValues()[0])); + return ConstantNode.create(src, RRuntime.string2double(c.getValues()[0])); case BOOL: String value = c.getValues()[0]; if (value.equals("NA")) { @@ -81,7 +80,7 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { case STRING: return ConstantNode.create(src, c.getValues()[0]); case COMPLEX: - return ConstantNode.create(src, RDataFactory.createComplex(0, RRuntime.string2double(context, c.getValues()[0]))); + return ConstantNode.create(src, RDataFactory.createComplex(0, RRuntime.string2double(c.getValues()[0]))); default: throw new UnsupportedOperationException(); } @@ -98,7 +97,7 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { nodes[index] = e.getValue() != null ? e.getValue().accept(this) : ConstantNode.create(RMissing.instance); index++; } - return CallNode.createCall(call.getSource(), ReadVariableNode.create(call.getName(), context, true, false), CallArgumentsNode.create(nodes, argumentNames)); + return CallNode.createCall(call.getSource(), ReadVariableNode.create(call.getName(), true, false), CallArgumentsNode.create(nodes, argumentNames)); } @Override @@ -149,14 +148,14 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { @Override public RNode visit(UnaryOperation op) { RNode operand = op.getLHS().accept(this); - return CallNode.createStaticCall(op.getSource(), context, op.getPrettyOperator(), CallArgumentsNode.createUnnamed(operand)); + return CallNode.createStaticCall(op.getSource(), op.getPrettyOperator(), CallArgumentsNode.createUnnamed(operand)); } @Override public RNode visit(BinaryOperation op) { RNode left = op.getLHS().accept(this); RNode right = op.getRHS().accept(this); - return CallNode.createStaticCall(op.getSource(), context, op.getPrettyOperator(), CallArgumentsNode.createUnnamed(left, right)); + return CallNode.createStaticCall(op.getSource(), op.getPrettyOperator(), CallArgumentsNode.createUnnamed(left, right)); } @Override @@ -272,7 +271,7 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { WriteVariableNode aAssign = WriteVariableNode.create(a, rhs, false, false, true); // read v, assign tmp - ReadVariableNode v = n.isSuper() ? ReadSuperVariableNode.create(vAST.getSource(), vSymbol, context, false, false) : ReadVariableNode.create(vAST.getSource(), vSymbol, context, false, false); + ReadVariableNode v = n.isSuper() ? ReadSuperVariableNode.create(vAST.getSource(), vSymbol, false, false) : ReadVariableNode.create(vAST.getSource(), vSymbol, false, false); final String tmp = "*tmp*"; WriteVariableNode tmpAssign = WriteVariableNode.create(tmp, v, false, false); @@ -292,7 +291,7 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { // assign v, read a WriteVariableNode vAssign = WriteVariableNode.create(vSymbol, replacementFunctionCall, false, n.isSuper()); - ReadVariableNode aRead = ReadVariableNode.create(a, context, false, false); + ReadVariableNode aRead = ReadVariableNode.create(a, false, false); // assemble SequenceNode replacement = new SequenceNode(new RNode[]{aAssign, tmpAssign, vAssign, Invisible.create(aRead)}); @@ -302,12 +301,12 @@ public final class RTruffleVisitor extends BasicVisitor<RNode> { @Override public RNode visit(SimpleAccessVariable n) { - return ReadVariableNode.create(n.getSource(), n.getSymbol(), context, false, n.shouldCopyValue()); + return ReadVariableNode.create(n.getSource(), n.getSymbol(), false, n.shouldCopyValue()); } @Override public RNode visit(SimpleAccessTempVariable n) { - return ReadVariableNode.create(n.getSource(), n.getSymbol(), context, false, false); + return ReadVariableNode.create(n.getSource(), n.getSymbol(), false, false); } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/ReadVariableNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/ReadVariableNode.java index f249f4f1e7ca7580480af70745b2ce6754a9d0ba..4cd465545e53101b9270143f6b719be5904d69d5 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/ReadVariableNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/ReadVariableNode.java @@ -35,7 +35,6 @@ import com.oracle.truffle.r.nodes.access.ReadVariableNodeFactory.ReadAndCopySupe import com.oracle.truffle.r.nodes.access.ReadVariableNodeFactory.ReadLocalVariableNodeFactory; import com.oracle.truffle.r.nodes.access.ReadVariableNodeFactory.ReadSuperVariableNodeFactory; import com.oracle.truffle.r.nodes.access.ReadVariableNodeFactory.UnknownVariableNodeFactory; - import com.oracle.truffle.r.nodes.access.FrameSlotNode.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @@ -45,12 +44,12 @@ public abstract class ReadVariableNode extends RNode { public abstract Object execute(VirtualFrame frame, MaterializedFrame enclosingFrame); - public static ReadVariableNode create(Object symbol, RContext context, boolean functionLookup, boolean shouldCopyValue) { - return new UnresolvedReadVariableNode(symbol, context, functionLookup, shouldCopyValue); + public static ReadVariableNode create(Object symbol, boolean functionLookup, boolean shouldCopyValue) { + return new UnresolvedReadVariableNode(symbol, functionLookup, shouldCopyValue); } - public static ReadVariableNode create(SourceSection src, Object symbol, RContext context, boolean functionLookup, boolean shouldCopyValue) { - ReadVariableNode rvn = create(symbol, context, functionLookup, shouldCopyValue); + public static ReadVariableNode create(SourceSection src, Object symbol, boolean functionLookup, boolean shouldCopyValue) { + ReadVariableNode rvn = create(symbol, functionLookup, shouldCopyValue); rvn.assignSourceSection(src); return rvn; } @@ -58,7 +57,6 @@ public abstract class ReadVariableNode extends RNode { public static final class UnresolvedReadVariableNode extends ReadVariableNode { private final Object symbol; - private final RContext context; private final boolean functionLookup; /** @@ -72,9 +70,8 @@ public abstract class ReadVariableNode extends RNode { copyValue = c; } - public UnresolvedReadVariableNode(Object symbol, RContext context, boolean functionLookup, boolean copyValue) { + public UnresolvedReadVariableNode(Object symbol, boolean functionLookup, boolean copyValue) { this.symbol = symbol; - this.context = context; this.functionLookup = functionLookup; this.copyValue = copyValue; } @@ -85,7 +82,7 @@ public abstract class ReadVariableNode extends RNode { if (enclosingFrame != null) { ReadSuperVariableNode readSuper = copyValue ? ReadAndCopySuperVariableNodeFactory.create(null, new FrameSlotNode.UnresolvedFrameSlotNode(symbol)) : ReadSuperVariableNodeFactory.create(null, new FrameSlotNode.UnresolvedFrameSlotNode(symbol)); - ReadVariableMaterializedNode readNode = new ReadVariableMaterializedNode(readSuper, new UnresolvedReadVariableNode(symbol, context, functionLookup, copyValue), functionLookup); + ReadVariableMaterializedNode readNode = new ReadVariableMaterializedNode(readSuper, new UnresolvedReadVariableNode(symbol, functionLookup, copyValue), functionLookup); return replace(readNode).execute(frame, enclosingFrame); } else { return replace(resolveNonFrame()).execute(frame); @@ -93,7 +90,7 @@ public abstract class ReadVariableNode extends RNode { } private ReadVariableNode resolveNonFrame() { - RFunction lookupResult = context.getLookup().lookup(context, symbol.toString()); + RFunction lookupResult = RContext.getInstance().getLookup().lookup(symbol.toString()); if (lookupResult != null) { return BuiltinFunctionVariableNodeFactory.create(lookupResult); } else { @@ -109,10 +106,10 @@ public abstract class ReadVariableNode extends RNode { if (assumptions == null) { // Found variable in one of the frames; build inline cache. ReadLocalVariableNode actualReadNode = ReadLocalVariableNodeFactory.create(new FrameSlotNode.UnresolvedFrameSlotNode(symbol)); - readNode = new ReadVariableVirtualNode(actualReadNode, new UnresolvedReadVariableNode(symbol, context, functionLookup, copyValue), functionLookup); + readNode = new ReadVariableVirtualNode(actualReadNode, new UnresolvedReadVariableNode(symbol, functionLookup, copyValue), functionLookup); } else { // Symbol is missing in all frames; bundle assumption checks and access builtin. - readNode = new ReadVariableNonFrameNode(assumptions, resolveNonFrame(), new UnresolvedReadVariableNode(symbol, context, functionLookup, copyValue), symbol); + readNode = new ReadVariableNonFrameNode(assumptions, resolveNonFrame(), new UnresolvedReadVariableNode(symbol, functionLookup, copyValue), symbol); } return replace(readNode).execute(frame); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java index e16455b56a23b1dfc42038c7eff1c9ce4964a7ff..972f29b03bc387c9e8048cff287abaedaf08acbc 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryArithmeticNode.java @@ -59,7 +59,7 @@ public abstract class BinaryArithmeticNode extends BinaryNode { } public static BinaryArithmeticNode create(BinaryArithmeticFactory arithmetic) { - return BinaryArithmeticNodeFactory.create(arithmetic, null, new RNode[2], null, null); + return BinaryArithmeticNodeFactory.create(arithmetic, null, new RNode[2], null); } @CreateCast({"arguments"}) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java index 94130d715cbd06458d107b55f57b1fe6510e5d52..32d7b1ed48a63c03b6beae18859d8d502053af71 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNode.java @@ -1472,7 +1472,7 @@ public abstract class BinaryBooleanNode extends BinaryNode { } boolean notMultiple = l != 0 || r != 0; if (notMultiple) { - getContext().setEvalWarning(RError.LENGTH_NOT_MULTI); + RContext.getInstance().setEvalWarning(RError.LENGTH_NOT_MULTI); } RLogicalVector ret = RDataFactory.createLogicalVector(result, leftNACheck.neverSeenNA() && rightNACheck.neverSeenNA()); ret.setDimensions(left.hasDimensions() ? left.getDimensions() : right.getDimensions(), this.getSourceSection()); @@ -1517,7 +1517,7 @@ public abstract class BinaryBooleanNode extends BinaryNode { } boolean notMultiple = l != 0 || r != 0; if (notMultiple) { - getContext().setEvalWarning(RError.LENGTH_NOT_MULTI); + RContext.getInstance().setEvalWarning(RError.LENGTH_NOT_MULTI); } RLogicalVector ret = RDataFactory.createLogicalVector(result, leftNACheck.neverSeenNA() && rightNACheck.neverSeenNA()); ret.setDimensions(left.hasDimensions() ? left.getDimensions() : right.getDimensions(), this.getSourceSection()); @@ -1562,7 +1562,7 @@ public abstract class BinaryBooleanNode extends BinaryNode { } boolean notMultiple = l != 0 || r != 0; if (notMultiple) { - getContext().setEvalWarning(RError.LENGTH_NOT_MULTI); + RContext.getInstance().setEvalWarning(RError.LENGTH_NOT_MULTI); } RLogicalVector ret = RDataFactory.createLogicalVector(result, leftNACheck.neverSeenNA() && rightNACheck.neverSeenNA()); ret.setDimensions(left.hasDimensions() ? left.getDimensions() : right.getDimensions(), this.getSourceSection()); @@ -1607,7 +1607,7 @@ public abstract class BinaryBooleanNode extends BinaryNode { } boolean notMultiple = l != 0 || r != 0; if (notMultiple) { - getContext().setEvalWarning(RError.LENGTH_NOT_MULTI); + RContext.getInstance().setEvalWarning(RError.LENGTH_NOT_MULTI); } RLogicalVector ret = RDataFactory.createLogicalVector(result, leftNACheck.neverSeenNA() && rightNACheck.neverSeenNA()); ret.setDimensions(left.hasDimensions() ? left.getDimensions() : right.getDimensions(), this.getSourceSection()); @@ -1648,7 +1648,7 @@ public abstract class BinaryBooleanNode extends BinaryNode { } boolean notMultiple = l != 0 || r != 0; if (notMultiple) { - getContext().setEvalWarning(RError.LENGTH_NOT_MULTI); + RContext.getInstance().setEvalWarning(RError.LENGTH_NOT_MULTI); } RRawVector ret = RDataFactory.createRawVector(result); ret.setDimensions(left.hasDimensions() ? left.getDimensions() : right.getDimensions(), this.getSourceSection()); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java index d7c9629ffc77520aeefd331045e25b308f4e929b..367c415e52bc18f66302c13adcd109494b1b50a3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/BinaryBooleanNonVectorizedNode.java @@ -62,7 +62,7 @@ public abstract class BinaryBooleanNonVectorizedNode extends BinaryNode { } private LeftOpToLogicalScalarCast createCast(RNode child) { - return LeftOpToLogicalScalarCastFactory.create(child, getContext(), logic.opName()); + return LeftOpToLogicalScalarCastFactory.create(child, logic.opName()); } @ShortCircuit("arguments[1]") @@ -242,14 +242,12 @@ public abstract class BinaryBooleanNonVectorizedNode extends BinaryNode { return needsRightOperand; } - @NodeFields({@NodeField(name = "context", type = RContext.class), @NodeField(name = "opName", type = String.class)}) + @NodeField(name = "opName", type = String.class) @NodeChild("operand") public abstract static class LeftOpToLogicalScalarCast extends RNode { public abstract byte executeCast(VirtualFrame frame, Object o); - public abstract RContext getContext(); - public abstract String getOpName(); @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CbindFoldOperationNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CbindFoldOperationNode.java index dbfc9b23305ba4e4dd68a699568e68edb1679328..8540b9d6030be7785ce64188971f3b2d8b715b33 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CbindFoldOperationNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CbindFoldOperationNode.java @@ -30,7 +30,7 @@ public final class CbindFoldOperationNode extends FoldOperationNode { @Child private CbindBinaryNode cbind; public CbindFoldOperationNode() { - this.cbind = adoptChild(CbindBinaryNodeFactory.create(new RNode[2], null, null)); + this.cbind = adoptChild(CbindBinaryNodeFactory.create(new RNode[2], null)); } private Object executeCbind(VirtualFrame frame, Object left, Object right) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CombineFoldOperationNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CombineFoldOperationNode.java index 33319680ea2e27ee38d5bbc5cb7b11097a1fc287..6f94d37778598bcce891fe4752e111212419b827 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CombineFoldOperationNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/CombineFoldOperationNode.java @@ -40,7 +40,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeComplex(VirtualFrame frame, Object left, Object right) { if (combineComplex == null) { CompilerDirectives.transferToInterpreter(); - combineComplex = adoptChild(CombineBinaryComplexNodeFactory.create(new RNode[2], null, null)); + combineComplex = adoptChild(CombineBinaryComplexNodeFactory.create(new RNode[2], null)); } return combineComplex.executeCombine(frame, left, right); } @@ -49,7 +49,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeDouble(VirtualFrame frame, Object left, Object right) { if (combineDouble == null) { CompilerDirectives.transferToInterpreter(); - combineDouble = adoptChild(CombineBinaryDoubleNodeFactory.create(new RNode[2], null, null)); + combineDouble = adoptChild(CombineBinaryDoubleNodeFactory.create(new RNode[2], null)); } return combineDouble.executeCombine(frame, left, right); } @@ -58,7 +58,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeInteger(VirtualFrame frame, Object left, Object right) { if (combineInteger == null) { CompilerDirectives.transferToInterpreter(); - combineInteger = adoptChild(CombineBinaryIntegerNodeFactory.create(new RNode[2], null, null)); + combineInteger = adoptChild(CombineBinaryIntegerNodeFactory.create(new RNode[2], null)); } return combineInteger.executeCombine(frame, left, right); } @@ -67,7 +67,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeString(VirtualFrame frame, Object left, Object right) { if (combineString == null) { CompilerDirectives.transferToInterpreter(); - combineString = adoptChild(CombineBinaryStringNodeFactory.create(new RNode[2], null, null)); + combineString = adoptChild(CombineBinaryStringNodeFactory.create(new RNode[2], null)); } return combineString.executeCombine(frame, left, right); } @@ -76,7 +76,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeLogical(VirtualFrame frame, Object left, Object right) { if (combineLogical == null) { CompilerDirectives.transferToInterpreter(); - combineLogical = adoptChild(CombineBinaryLogicalNodeFactory.create(new RNode[2], null, null)); + combineLogical = adoptChild(CombineBinaryLogicalNodeFactory.create(new RNode[2], null)); } return combineLogical.executeCombine(frame, left, right); } @@ -85,7 +85,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeRaw(VirtualFrame frame, Object left, Object right) { if (combineRaw == null) { CompilerDirectives.transferToInterpreter(); - combineRaw = adoptChild(CombineBinaryRawNodeFactory.create(new RNode[2], null, null)); + combineRaw = adoptChild(CombineBinaryRawNodeFactory.create(new RNode[2], null)); } return combineRaw.executeCombine(frame, left, right); } @@ -94,7 +94,7 @@ public final class CombineFoldOperationNode extends FoldOperationNode { public Object executeList(VirtualFrame frame, Object left, Object right) { if (combineList == null) { CompilerDirectives.transferToInterpreter(); - combineList = adoptChild(CombineBinaryListNodeFactory.create(new RNode[2], null, null)); + combineList = adoptChild(CombineBinaryListNodeFactory.create(new RNode[2], null)); } return combineList.executeCombine(frame, left, right); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/RbindFoldOperationNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/RbindFoldOperationNode.java index 7dfbe1617d9787486e91d9dc7c0cc1db45b6d81e..467259bb6513c796230c1d81e6c625dbc3e1500b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/RbindFoldOperationNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/binary/RbindFoldOperationNode.java @@ -30,7 +30,7 @@ public final class RbindFoldOperationNode extends FoldOperationNode { @Child private RbindBinaryNode rbind; public RbindFoldOperationNode() { - this.rbind = adoptChild(RbindBinaryNodeFactory.create(new RNode[2], null, null)); + this.rbind = adoptChild(RbindBinaryNodeFactory.create(new RNode[2], null)); } private Object executeRbind(VirtualFrame frame, Object left, Object right) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java index bcef6907424addb44da152510719b25d68d8dd51..7088ea6b614c42ba6c506e00e96545cc7eb6474f 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RBuiltinNode.java @@ -33,14 +33,12 @@ import com.oracle.truffle.r.nodes.builtin.base.*; import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; -@NodeFields({@NodeField(name = "context", type = RContext.class), @NodeField(name = "builtin", type = RBuiltinFactory.class)}) +@NodeField(name = "builtin", type = RBuiltinFactory.class) @NodeChild(value = "arguments", type = RNode[].class) public abstract class RBuiltinNode extends CallNode { public abstract RNode[] getArguments(); - public abstract RContext getContext(); - public abstract RBuiltinFactory getBuiltin(); public Object[] getParameterNames() { @@ -77,9 +75,9 @@ public abstract class RBuiltinNode extends CallNode { return args; } - static CallTarget createArgumentsCallTarget(RContext ctx, RBuiltinFactory builtin) { + static CallTarget createArgumentsCallTarget(RBuiltinFactory builtin) { RNode[] args = createCallArguments(builtin); - RBuiltinNode node = createNode(ctx, builtin, args, null); + RBuiltinNode node = createNode(builtin, args, null); injectParameterDefaultValues(node); RBuiltinRootNode root = new RBuiltinRootNode(node, node.getParameterNames(), new FrameDescriptor()); node.onCreate(); @@ -100,21 +98,20 @@ public abstract class RBuiltinNode extends CallNode { RNode[] builtinArguments; // static number of arguments builtinArguments = inlineStaticArguments(args); - RBuiltinNode builtin = createNode(getContext(), getBuiltin(), builtinArguments, args.getNameCount() == 0 ? null : args.getNames()); + RBuiltinNode builtin = createNode(getBuiltin(), builtinArguments, args.getNameCount() == 0 ? null : args.getNames()); builtin.onCreate(); return builtin; } - private static RBuiltinNode createNode(RContext context, RBuiltinFactory factory, RNode[] builtinArguments, String[] argNames) { + private static RBuiltinNode createNode(RBuiltinFactory factory, RNode[] builtinArguments, String[] argNames) { boolean isCombine = (factory.getFactory().getClass() == CombineFactory.class || factory.getFactory().getClass() == ListBuiltinFactory.class); - Object[] args = new Object[(isCombine ? 4 : 3) + factory.getConstantArguments().length]; + Object[] args = new Object[(isCombine ? 3 : 2) + factory.getConstantArguments().length]; int index = 0; for (; index < factory.getConstantArguments().length; index++) { args[index] = factory.getConstantArguments()[index]; } args[index++] = builtinArguments; - args[index++] = context; args[index++] = factory; if (isCombine) { args[index++] = argNames; @@ -216,16 +213,14 @@ public abstract class RBuiltinNode extends CallNode { @Children protected final RNode[] arguments; - private final RContext context; private final RBuiltinFactory builtin; public RCustomBuiltinNode(RBuiltinNode prev) { - this(prev.getArguments(), prev.getContext(), prev.getBuiltin()); + this(prev.getArguments(), prev.getBuiltin()); } - public RCustomBuiltinNode(RNode[] arguments, RContext context, RBuiltinFactory builtin) { + public RCustomBuiltinNode(RNode[] arguments, RBuiltinFactory builtin) { this.arguments = adoptChildren(arguments); - this.context = context; this.builtin = builtin; } @@ -234,11 +229,6 @@ public abstract class RBuiltinNode extends CallNode { return arguments; } - @Override - public RContext getContext() { - return context; - } - @Override public RBuiltinFactory getBuiltin() { return builtin; @@ -250,8 +240,8 @@ public abstract class RBuiltinNode extends CallNode { @Child protected CallNode snippetCall; - public RSnippetNode(RNode[] arguments, RContext context, RBuiltinFactory builtin, FunctionExpressionNode function) { - super(arguments, context, builtin); + public RSnippetNode(RNode[] arguments, RBuiltinFactory builtin, FunctionExpressionNode function) { + super(arguments, builtin); snippetCall = adoptChild(CallNode.createCall(function, CallArgumentsNode.create(getArguments(), new String[]{}))); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RDefaultPackages.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RDefaultPackages.java index 3e0103e1814ed5a0c41a0fa98eac4d054bdf2548..db09ab18b07cc3c1e046a7b268be7a374966ced0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RDefaultPackages.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RDefaultPackages.java @@ -24,7 +24,6 @@ package com.oracle.truffle.r.nodes.builtin; import com.oracle.truffle.r.nodes.builtin.base.*; import com.oracle.truffle.r.nodes.builtin.debug.*; -import com.oracle.truffle.r.runtime.*; public final class RDefaultPackages extends RPackages { @@ -32,9 +31,9 @@ public final class RDefaultPackages extends RPackages { // empty } - public void load(RContext context) { - load(new BasePackage(context)); - load(new DebugPackage(context)); + public void load() { + load(new BasePackage()); + load(new DebugPackage()); } private static RDefaultPackages instance; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RLibraryLoader.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RLibraryLoader.java index f61b44bde9bf838133acff7af9e3477b2be484b9..4cddc47142b657b136981c87168c9b9003e11eb3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RLibraryLoader.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RLibraryLoader.java @@ -41,11 +41,9 @@ import com.oracle.truffle.r.runtime.data.*; public class RLibraryLoader { private final File libFile; - private final RContext context; - public RLibraryLoader(File libFile, RContext context) { + public RLibraryLoader(File libFile) { this.libFile = libFile; - this.context = context; } public Map<String, FunctionExpressionNode.StaticFunctionExpressionNode> loadLibrary() { @@ -72,8 +70,8 @@ public class RLibraryLoader { ANTLRFileStream stream; try { stream = new ANTLRFileStream(libFile.getAbsolutePath()); - RTruffleVisitor transform = new RTruffleVisitor(context); - RNode node = transform.transform(parseAST(stream, context.getSourceManager().get(libFile.getAbsolutePath()))); + RTruffleVisitor transform = new RTruffleVisitor(); + RNode node = transform.transform(parseAST(stream, RContext.getInstance().getSourceManager().get(libFile.getAbsolutePath()))); return node; } catch (RecognitionException | IOException e) { throw new RuntimeException(e.getMessage(), e); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackage.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackage.java index 56fa97dd1fddf2652382fa92f8b83606914dd4c4..d05a98d612075d5c364fc95aae4b203ff4e36f17 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackage.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackage.java @@ -38,7 +38,6 @@ import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.builtin.RBuiltin.LastParameterKind; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode.RCustomBuiltinNode; import com.oracle.truffle.r.nodes.function.*; -import com.oracle.truffle.r.runtime.*; /** * Intended to be subclassed by definitions of builtin functions. @@ -46,8 +45,8 @@ import com.oracle.truffle.r.runtime.*; public abstract class RPackage { private final TreeMap<String, RBuiltinFactory> builtins = new TreeMap<>(); - protected RPackage(RContext context) { - loadSnippets(context); + protected RPackage() { + loadSnippets(); } public final RBuiltinFactory lookupByName(String methodName) { @@ -62,11 +61,11 @@ public abstract class RPackage { return builtins; } - public final void loadSnippets(RContext context) { + public final void loadSnippets() { String rSourceName = getName() + ".r"; URL rSource = getClass().getResource(rSourceName); if (rSource != null) { - RLibraryLoader loader = new RLibraryLoader(new File(rSource.getPath()), context); + RLibraryLoader loader = new RLibraryLoader(new File(rSource.getPath())); Map<String, FunctionExpressionNode.StaticFunctionExpressionNode> builtinDefs = loader.loadLibrary(); for (Map.Entry<String, FunctionExpressionNode.StaticFunctionExpressionNode> def : builtinDefs.entrySet()) { NodeFactory<RBuiltinNode> nodeFactory = new RSnippetNodeFactory(def.getValue()); @@ -154,7 +153,7 @@ public abstract class RPackage { public RBuiltinNode createNode(Object... arguments) { try { - RBuiltinNode builtin = new RCustomBuiltinNode((RNode[]) arguments[0], (RContext) arguments[1], (RBuiltinFactory) arguments[2]); + RBuiltinNode builtin = new RCustomBuiltinNode((RNode[]) arguments[0], (RBuiltinFactory) arguments[1]); return constructor.newInstance(builtin); } catch (Exception e) { throw new RuntimeException(e); @@ -194,7 +193,7 @@ public abstract class RPackage { @Override public RBuiltinNode createNode(Object... arguments) { - RBuiltinNode builtin = new RBuiltinNode.RSnippetNode((RNode[]) arguments[0], (RContext) arguments[1], (RBuiltinFactory) arguments[2], function); + RBuiltinNode builtin = new RBuiltinNode.RSnippetNode((RNode[]) arguments[0], (RBuiltinFactory) arguments[1], function); return builtin; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackages.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackages.java index 927ee335922f3b1c8efada715f86f8cb886b0f45..3f688c908c67e3da106956cff88b0d3c852b06d5 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackages.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/RPackages.java @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - /* +/* * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ @@ -45,8 +45,8 @@ public abstract class RPackages implements RBuiltinLookup { } @Override - public RFunction lookup(RContext context, String methodName) { - RFunction function = context.getCachedFunction(methodName); + public RFunction lookup(String methodName) { + RFunction function = RContext.getInstance().getCachedFunction(methodName); if (function != null) { return function; } @@ -55,12 +55,12 @@ public abstract class RPackages implements RBuiltinLookup { if (builtin == null) { return null; } - return createFunction(context, builtin, methodName); + return createFunction(builtin, methodName); } - private static RFunction createFunction(RContext context, RBuiltinFactory builtin, String methodName) { - CallTarget callTarget = RBuiltinNode.createArgumentsCallTarget(context, builtin); - return context.putCachedFunction(methodName, new RFunction(builtin.getBuiltinNames()[0], callTarget, true)); + private static RFunction createFunction(RBuiltinFactory builtin, String methodName) { + CallTarget callTarget = RBuiltinNode.createArgumentsCallTarget(builtin); + return RContext.getInstance().putCachedFunction(methodName, new RFunction(builtin.getBuiltinNames()[0], callTarget, true)); } private RBuiltinFactory lookupBuiltin(String name) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/All.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/All.java index 1bad02af53acbc9729a8404c75bbb2f41f491201..dd949fcd8e3dd21a4645eb31c9c5d85ced52310e 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/All.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/All.java @@ -43,7 +43,7 @@ public abstract class All extends RBuiltinNode { private byte castLogical(VirtualFrame frame, Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreter(); - castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false, getContext())); + castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false)); } return (byte) castLogicalNode.executeByte(frame, o); } @@ -51,7 +51,7 @@ public abstract class All extends RBuiltinNode { private RLogicalVector castLogicalVector(VirtualFrame frame, Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreter(); - castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false, getContext())); + castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false)); } return (RLogicalVector) castLogicalNode.executeLogicalVector(frame, o); } @@ -89,7 +89,7 @@ public abstract class All extends RBuiltinNode { @Specialization public byte all(VirtualFrame frame, String value) { check.enable(value); - return check.convertStringToLogical(getContext(), value); + return check.convertStringToLogical(value); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Any.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Any.java index 83f8909f73efdd4d7b83314b19e273b1ac54ddff..867ea31e952d46b77cf691e6f3705f6a7538913b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Any.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Any.java @@ -43,7 +43,7 @@ public abstract class Any extends RBuiltinNode { private byte castLogical(VirtualFrame frame, Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreter(); - castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false, getContext())); + castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false)); } return (byte) castLogicalNode.executeByte(frame, o); } @@ -51,7 +51,7 @@ public abstract class Any extends RBuiltinNode { private RLogicalVector castLogicalVector(VirtualFrame frame, Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreter(); - castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false, getContext())); + castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, true, false)); } return (RLogicalVector) castLogicalNode.executeLogicalVector(frame, o); } @@ -89,7 +89,7 @@ public abstract class Any extends RBuiltinNode { @Specialization public byte any(VirtualFrame frame, String value) { check.enable(value); - return check.convertStringToLogical(getContext(), value); + return check.convertStringToLogical(value); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java index fc893ad8b8436971d135a0bda2b31372ee9e3027..0e23f4b37a34e430702f62799eed272205523ec3 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsInteger.java @@ -44,7 +44,7 @@ public abstract class AsInteger extends RBuiltinNode { private int castInt(VirtualFrame frame, Object o) { if (castIntNode == null) { CompilerDirectives.transferToInterpreter(); - castIntNode = adoptChild(CastIntegerNodeFactory.create(null, false, false, getContext())); + castIntNode = adoptChild(CastIntegerNodeFactory.create(null, false, false)); } return (int) castIntNode.executeInt(frame, o); } @@ -52,7 +52,7 @@ public abstract class AsInteger extends RBuiltinNode { private RIntVector castIntVector(VirtualFrame frame, Object o) { if (castIntNode == null) { CompilerDirectives.transferToInterpreter(); - castIntNode = adoptChild(CastIntegerNodeFactory.create(null, false, false, getContext())); + castIntNode = adoptChild(CastIntegerNodeFactory.create(null, false, false)); } return (RIntVector) castIntNode.executeIntVector(frame, o); } @@ -65,7 +65,7 @@ public abstract class AsInteger extends RBuiltinNode { @Specialization public int asInteger(double value) { check.enable(value); - return check.convertDoubleToInt(getContext(), value); + return check.convertDoubleToInt(value); } @Specialization @@ -76,7 +76,7 @@ public abstract class AsInteger extends RBuiltinNode { @Specialization public int asInteger(RComplex value) { check.enable(value); - return check.convertComplexToInt(getContext(), value); + return check.convertComplexToInt(value); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java index e1030947d68d6d506bdb5a5df4ce9d518c4ae632..f10c9d2afaf48343014977870f1db053c079c457 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsLogical.java @@ -45,7 +45,7 @@ public abstract class AsLogical extends RBuiltinNode { private byte castLogical(VirtualFrame frame, Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreter(); - castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, false, false, getContext())); + castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, false, false)); } return (byte) castLogicalNode.executeByte(frame, o); } @@ -53,7 +53,7 @@ public abstract class AsLogical extends RBuiltinNode { private RLogicalVector castLogicalVector(VirtualFrame frame, Object o) { if (castLogicalNode == null) { CompilerDirectives.transferToInterpreter(); - castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, false, false, getContext())); + castLogicalNode = adoptChild(CastLogicalNodeFactory.create(null, false, false)); } return (RLogicalVector) castLogicalNode.executeLogicalVector(frame, o); } @@ -84,7 +84,7 @@ public abstract class AsLogical extends RBuiltinNode { @Specialization public byte asLogical(VirtualFrame frame, String value) { check.enable(value); - return check.convertStringToLogical(getContext(), value); + return check.convertStringToLogical(value); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java index ebb0caca19641bbd40932173c917464629683ecf..d3343e131d8d0902e4590503d3b2893aaede7276 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsRaw.java @@ -81,7 +81,7 @@ public abstract class AsRaw extends RBuiltinNode { // TODO: Output NA and out-of-range warning. if (castInteger == null) { CompilerDirectives.transferToInterpreter(); - castInteger = adoptChild(CastIntegerNodeFactory.create(null, false, false, getContext())); + castInteger = adoptChild(CastIntegerNodeFactory.create(null, false, false)); } return asRaw((int) castInteger.executeInt(frame, value)); } @@ -150,7 +150,7 @@ public abstract class AsRaw extends RBuiltinNode { public RRawVector asRaw(VirtualFrame frame, RList value) { if (asRawRecursive == null) { CompilerDirectives.transferToInterpreter(); - asRawRecursive = adoptChild(AsRawFactory.create(new RNode[1], getContext(), getBuiltin())); + asRawRecursive = adoptChild(AsRawFactory.create(new RNode[1], getBuiltin())); } int length = value.getLength(); RRawVector result = RDataFactory.createRawVector(length); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java index 5f695cded947ce4a5346201257ddf9536927a3d5..49854aea7c6629d310315ec457c945ce1563e850 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java @@ -25,14 +25,11 @@ package com.oracle.truffle.r.nodes.builtin.base; import com.oracle.truffle.r.nodes.binary.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.unary.*; -import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.ops.*; public class BasePackage extends RPackage { - public BasePackage(RContext context) { - super(context); - + public BasePackage() { // primitive operations load(UnaryNotNode.class).names("!"); load(BinaryArithmeticNode.class).names("+").arguments(BinaryArithmetic.ADD, null); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java index 7de6d2d632d881ac351d9dc717843a8c594e83cf..49024409518e4bb8f363101adf8e5fd417981cd6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cat.java @@ -57,7 +57,7 @@ public abstract class Cat extends RBuiltinNode { private void ensureToString(String sep) { if (toString == null || !sep.equals(currentSep)) { CompilerDirectives.transferToInterpreter(); - toString = adoptChild(ToStringFactory.create(new RNode[1], getContext(), getBuiltin())); + toString = adoptChild(ToStringFactory.create(new RNode[1], getBuiltin())); toString.setSeparator(sep); toString.setQuotes(false); toString.setIntL(false); @@ -93,12 +93,9 @@ public abstract class Cat extends RBuiltinNode { return RInvisible.INVISIBLE_NULL; } - // This builtin must be allowed to produce output. - // CheckStyle: stop system..print check - @SlowPath - private void catIntl(String s) { - getContext().getConsoleHandler().print(s); + private static void catIntl(String s) { + RContext.getInstance().getConsoleHandler().print(s); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cbind.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cbind.java index a86cb2c92411d43eed86ab96eb5a5cb12f0707d1..14484e2e02a31e290e9ae5942f7241a6e127d724 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cbind.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Cbind.java @@ -43,7 +43,7 @@ public final class Cbind extends RWrapperBuiltinNode { @Override protected RNode createDelegate() { - Combine combine = CombineFactory.create(getArguments(), getContext(), getBuiltin(), null); + Combine combine = CombineFactory.create(getArguments(), getBuiltin(), null); combine.setFoldOperation(new CbindFoldOperationNode()); return combine; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java index 07bf9ad1dc2b7cb4c8cd563f10356e1caad28436..a2a997308976ce5f9da085992909f20ac42ccdfc 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Combine.java @@ -266,7 +266,7 @@ public abstract class Combine extends RBuiltinNode { private Object castInteger(VirtualFrame frame, Object operand) { if (castInteger == null) { CompilerDirectives.transferToInterpreter(); - castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false, getContext())); + castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false)); } return castInteger.executeCast(frame, operand); } @@ -274,7 +274,7 @@ public abstract class Combine extends RBuiltinNode { private Object castLogical(VirtualFrame frame, Object operand) { if (castLogical == null) { CompilerDirectives.transferToInterpreter(); - castLogical = adoptChild(CastLogicalNodeFactory.create(null, true, false, getContext())); + castLogical = adoptChild(CastLogicalNodeFactory.create(null, true, false)); } return castLogical.executeCast(frame, operand); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/CommandArgs.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/CommandArgs.java index fc227ffeb74e976933d795901ed5b3c7fa940a38..1b479c9c17f6272ae432448fc9129b96611d0ffd 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/CommandArgs.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/CommandArgs.java @@ -24,6 +24,7 @@ package com.oracle.truffle.r.nodes.builtin.base; import java.util.*; +import com.oracle.truffle.api.CompilerDirectives.SlowPath; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; @@ -37,9 +38,9 @@ public abstract class CommandArgs extends RBuiltinNode { return getCommandArgs(trailingOnly == RRuntime.LOGICAL_TRUE); } - @com.oracle.truffle.api.CompilerDirectives.SlowPath - private RStringVector getCommandArgs(boolean trailingOnly) { - String[] s = getContext().getCommandArgs(); + @SlowPath + private static RStringVector getCommandArgs(boolean trailingOnly) { + String[] s = RContext.getInstance().getCommandArgs(); if (trailingOnly) { int index = s.length; for (int i = 0; i < s.length; ++i) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Exists.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Exists.java index e93d3876014a741de4cdbad8a34e9d6d082c05b2..66dc116a5350a3600685903e374cee62a611de29 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Exists.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Exists.java @@ -89,7 +89,7 @@ public abstract class Exists extends RBuiltinNode { if (!name.equals(lastName)) { CompilerDirectives.transferToInterpreterAndInvalidate(); lastName = name; - lastLookup = getContext().getLookup().lookup(getContext(), name) != null; + lastLookup = RContext.getInstance().getLookup().lookup(name) != null; } // FIXME deal with changes in packages due to deleting symbols return lastLookup; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Invisible.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Invisible.java index 67adec13914edc8f4bcc9faf464b17cbb51a894e..212f9e5510342ef925e84b8f211ecaeff2c114ad 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Invisible.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Invisible.java @@ -34,7 +34,7 @@ public abstract class Invisible extends RBuiltinNode { private static final Object[] PARAMETER_NAMES = new Object[]{"x"}; public static RNode create(RNode value) { - return InvisibleFactory.create(new RNode[]{value}, null, null); + return InvisibleFactory.create(new RNode[]{value}, null); } @Override diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java index 2e6bf5a687e789c68a36370cd2404ced2fc22b1f..a85aa9ac2e896a27ae112823e2df33d7450232ee 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsNA.java @@ -40,7 +40,7 @@ public abstract class IsNA extends RBuiltinNode { private Object isNARecursive(VirtualFrame frame, Object o) { if (recursiveIsNA == null) { CompilerDirectives.transferToInterpreter(); - recursiveIsNA = adoptChild(IsNAFactory.create(new RNode[1], getContext(), getBuiltin())); + recursiveIsNA = adoptChild(IsNAFactory.create(new RNode[1], getBuiltin())); } return recursiveIsNA.execute(frame, o); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsUnsorted.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsUnsorted.java index 59c2944bea2d9180cc8b6a051e00e45c081a4cde..a88b0a0dd42980931fbc02ccc944fcbe7d5d369c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsUnsorted.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/IsUnsorted.java @@ -46,7 +46,7 @@ public abstract class IsUnsorted extends RBuiltinNode { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RRuntime.LOGICAL_FALSE), ConstantNode.create(RRuntime.LOGICAL_FALSE)}; } - @Child protected BinaryBooleanNode ge = adoptChild(BinaryBooleanNodeFactory.create(BinaryCompare.GREATER_EQUAL, new RNode[1], getContext(), getBuiltin())); + @Child protected BinaryBooleanNode ge = adoptChild(BinaryBooleanNodeFactory.create(BinaryCompare.GREATER_EQUAL, new RNode[1], getBuiltin())); @Specialization @SuppressWarnings("unused") diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/MatchFun.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/MatchFun.java index 74954e30a7d144ad8c054918164a0c9db0c28c3e..0d4d934d5f02e42ba1d217d9ed8c9c1ae1a90e6d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/MatchFun.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/MatchFun.java @@ -64,7 +64,7 @@ public abstract class MatchFun extends RBuiltinNode { if (lookup == null || !fun.equals(lastFun)) { CompilerDirectives.transferToInterpreterAndInvalidate(); lastFun = fun; - ReadVariableNode rvn = ReadVariableNode.create(fun, getContext(), true, false); + ReadVariableNode rvn = ReadVariableNode.create(fun, true, false); lookup = lookup == null ? adoptChild(rvn) : lookup.replace(rvn); } Object r = lookup.execute(frame); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java index d28c18e33a709626b634ce4aa3237bfd5a8cb2c4..5779e219ce1848792a2c0d984624ece7a7554aa2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Matrix.java @@ -37,7 +37,7 @@ public abstract class Matrix extends RBuiltinNode { private static final String[] PARAMETER_NAMES = new String[]{"data", "nrow", "ncol", "byrow", "dimnames"}; - @Child private Transpose transpose = this.adoptChild(TransposeFactory.create(new RNode[1], getContext(), getBuiltin())); + @Child private Transpose transpose = this.adoptChild(TransposeFactory.create(new RNode[1], getBuiltin())); @Override public Object[] getParameterNames() { @@ -53,8 +53,8 @@ public abstract class Matrix extends RBuiltinNode { @CreateCast("arguments") public RNode[] castArguments(RNode[] arguments) { // nrow and ncol (positions 1, 2) are actually int - arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false, getContext()); - arguments[2] = CastIntegerNodeFactory.create(arguments[2], true, false, getContext()); + arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false); + arguments[2] = CastIntegerNodeFactory.create(arguments[2], true, false); return arguments; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Max.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Max.java index bdeebaefc04e1ad7e1095de55dc8d4f6e55798a9..4557f060651b79123edc7a56373cdc3cc6d00b69 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Max.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Max.java @@ -47,7 +47,7 @@ public final class Max extends RWrapperBuiltinNode { @Override protected RNode createDelegate() { ReduceSemantics semantics = new ReduceSemantics(RRuntime.INT_MIN_VALUE, Double.NEGATIVE_INFINITY, false, RError.NO_NONMISSING_MAX); - Combine combine = CombineFactory.create(getArguments(), getContext(), getBuiltin(), null); + Combine combine = CombineFactory.create(getArguments(), getBuiltin(), null); return UnaryArithmeticReduceNodeFactory.create(semantics, BinaryArithmetic.MAX, combine); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Min.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Min.java index b690ab723039b9c6deefd51d9dca44a2ec88a024..8202063c0666a7467a83fdcb150381611db1db15 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Min.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Min.java @@ -47,7 +47,7 @@ public final class Min extends RWrapperBuiltinNode { @Override protected RNode createDelegate() { ReduceSemantics semantics = new ReduceSemantics(RRuntime.INT_MAX_VALUE, Double.POSITIVE_INFINITY, false, RError.NO_NONMISSING_MIN); - Combine combine = CombineFactory.create(getArguments(), getContext(), getBuiltin(), null); + Combine combine = CombineFactory.create(getArguments(), getBuiltin(), null); return UnaryArithmeticReduceNodeFactory.create(semantics, BinaryArithmetic.MIN, combine); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Mod.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Mod.java index cc7f3e3a0b304bb92dfbe0cea0904e74071a08ca..bc4d1f886d06a321f556cf3507f3d6442fad4368 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Mod.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Mod.java @@ -34,7 +34,7 @@ public abstract class Mod extends RBuiltinNode { @Child protected BinaryArithmeticNode pow = adoptChild(BinaryArithmeticNode.create(BinaryArithmetic.POW)); @Child protected BinaryArithmeticNode add = adoptChild(BinaryArithmeticNode.create(BinaryArithmetic.ADD)); - @Child protected Sqrt sqrt = adoptChild(SqrtFactory.create(new RNode[1], getContext(), getBuiltin())); + @Child protected Sqrt sqrt = adoptChild(SqrtFactory.create(new RNode[1], getBuiltin())); @Specialization public double mod(RComplex x) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NewEnv.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NewEnv.java index 44b01984f91c548f63fa020d3734afbab459054d..f9d50b4ab6a8af1e3b8d3b8b090c48df33ead3c6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NewEnv.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NewEnv.java @@ -48,7 +48,7 @@ public abstract class NewEnv extends RBuiltinNode { @CreateCast("arguments") protected RNode[] castStatusArgument(RNode[] arguments) { // size argument is at index 2, and an int - arguments[2] = CastIntegerNodeFactory.create(arguments[2], true, false, getContext()); + arguments[2] = CastIntegerNodeFactory.create(arguments[2], true, false); return arguments; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java index bbfcd07e5b4cdd92c489a59bf192018dd8c23a8a..e1eff2930b45016bb7aff76a99b14f916c602f19 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/PrettyPrinterNode.java @@ -238,7 +238,7 @@ public abstract class PrettyPrinterNode extends RNode { private String printMatrix(VirtualFrame frame, RVector vector) { if (toString == null) { CompilerDirectives.transferToInterpreter(); - toString = adoptChild(ToStringFactory.create(new RNode[1], null, null)); + toString = adoptChild(ToStringFactory.create(new RNode[1], null)); } return toString.executeString(frame, vector); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Print.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Print.java index 26126474d826fecc81c2e51364738241a1b197f2..c366a800dcc3af2bbf59fdb7b153b1f686caf7ed 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Print.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Print.java @@ -43,8 +43,8 @@ public abstract class Print extends RBuiltinNode { @Child protected PrettyPrinterNode prettyPrinter = adoptChild(PrettyPrinterNodeFactory.create(null, false)); - private void printHelper(String string) { - getContext().getConsoleHandler().println(string); + private static void printHelper(String string) { + RContext.getInstance().getConsoleHandler().println(string); } @Specialization diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java index 9d05d3ba15b1f5500645f3a37e381b60bd98fbfd..fcde40a3447104423724ce2deebe91fe73f1fef7 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Quit.java @@ -48,14 +48,14 @@ public abstract class Quit extends RBuiltinNode { @CreateCast("arguments") protected RNode[] castStatusArgument(RNode[] arguments) { // status argument is at index 1 - arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false, getContext()); + arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false); return arguments; } @Specialization public Object doQuit(final String saveArg, int status, byte runLast) { String save = saveArg; - RContext.ConsoleHandler consoleHandler = getContext().getConsoleHandler(); + RContext.ConsoleHandler consoleHandler = RContext.getInstance().getConsoleHandler(); if (save.equals("default")) { if (consoleHandler.isInteractive()) { save = "ask"; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rbind.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rbind.java index 6d9d7f5ac095b0414955556554534072c5f578ed..c8262195d03eb0fc29d9ef2a45f772a0c6939441 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rbind.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rbind.java @@ -44,7 +44,7 @@ public final class Rbind extends RWrapperBuiltinNode { @Override protected RNode createDelegate() { - Combine combine = CombineFactory.create(getArguments(), getContext(), getBuiltin(), null); + Combine combine = CombineFactory.create(getArguments(), getBuiltin(), null); combine.setFoldOperation(new RbindFoldOperationNode()); return combine; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/RepeatInternal.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/RepeatInternal.java index 1f8a830b656dc341edc479a6f3a4cd3c71cc3538..ea24412b6da41877b8f6f3d7bc08f482af9f2e73 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/RepeatInternal.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/RepeatInternal.java @@ -37,7 +37,7 @@ public abstract class RepeatInternal extends RBuiltinNode { @CreateCast("arguments") protected RNode[] castStatusArgument(RNode[] arguments) { // times argument is at index 1 - arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false, getContext()); + arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false); return arguments; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rnorm.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rnorm.java index cdb128399e45f9050175a06904049c7915367b92..c5967c95eccbf954ac23df168226d023be9310a1 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rnorm.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Rnorm.java @@ -38,7 +38,7 @@ public abstract class Rnorm extends RBuiltinNode { @Specialization public RDoubleVector rnorm(int n, double mean, double standardd) { - RRandomNumberGenerator rng = getContext().getRandomNumberGenerator(); + RRandomNumberGenerator rng = RContext.getInstance().getRandomNumberGenerator(); double[] result = new double[n]; for (int i = 0; i < n; i++) { result[i] = generateNorm(mean, standardd, rng); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Runif.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Runif.java index 9ee6a1aba0b12a9db6c5846e4a559dabe16f177f..30b6017f60792630c5290137eee03b963c2f414d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Runif.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Runif.java @@ -32,7 +32,7 @@ public abstract class Runif extends RBuiltinNode { @Specialization public RDoubleVector runif(int n) { - RRandomNumberGenerator rng = getContext().getRandomNumberGenerator(); + RRandomNumberGenerator rng = RContext.getInstance().getRandomNumberGenerator(); double[] result = new double[n]; for (int i = 0; i < n; i++) { result[i] = rng.genrandDouble(); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SApply.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SApply.java index 17e4dfb632bc1d7cb21253736560ae049caabe51..58d99dccd12e7166937c7a51a9a68a550d18ec8c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SApply.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SApply.java @@ -201,7 +201,7 @@ public abstract class SApply extends RBuiltinNode { private Object call(VirtualFrame frame, RFunction function) { if (callNode == null) { CompilerDirectives.transferToInterpreter(); - callNode = adoptChild(CallNode.createCall(null, CallArgumentsNode.createUnnamed(ReadVariableNode.create(temporaryVariableSymbol, getContext(), false, false)))); + callNode = adoptChild(CallNode.createCall(null, CallArgumentsNode.createUnnamed(ReadVariableNode.create(temporaryVariableSymbol, false, false)))); } return callNode.execute(frame, function); } @@ -209,7 +209,7 @@ public abstract class SApply extends RBuiltinNode { private int callInt(VirtualFrame frame, RFunction function) throws UnexpectedResultException { if (callNode == null) { CompilerDirectives.transferToInterpreter(); - callNode = adoptChild(CallNode.createCall(null, CallArgumentsNode.createUnnamed(ReadVariableNode.create(temporaryVariableSymbol, getContext(), false, false)))); + callNode = adoptChild(CallNode.createCall(null, CallArgumentsNode.createUnnamed(ReadVariableNode.create(temporaryVariableSymbol, false, false)))); } return RTypesGen.RTYPES.expectInteger(callNode.execute(frame, function)); } @@ -217,7 +217,7 @@ public abstract class SApply extends RBuiltinNode { private double callDouble(VirtualFrame frame, RFunction function) throws UnexpectedResultException { if (callNode == null) { CompilerDirectives.transferToInterpreter(); - callNode = adoptChild(CallNode.createCall(null, CallArgumentsNode.createUnnamed(ReadVariableNode.create(temporaryVariableSymbol, getContext(), false, false)))); + callNode = adoptChild(CallNode.createCall(null, CallArgumentsNode.createUnnamed(ReadVariableNode.create(temporaryVariableSymbol, false, false)))); } return RTypesGen.RTYPES.expectDouble(callNode.execute(frame, function)); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sd.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sd.java index c2d7c2b9ea2f3f6a287d09d7589adc504258716d..a694531a694f507981d41659bc4fa8fdda37d664 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sd.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sd.java @@ -46,8 +46,8 @@ public abstract class Sd extends RBuiltinNode { return new RNode[]{ConstantNode.create(RMissing.instance), ConstantNode.create(RRuntime.LOGICAL_FALSE)}; } - @Child protected Mean mean = adoptChild(MeanFactory.create(new RNode[2], getContext(), getBuiltin())); - @Child protected Sqrt sqrt = adoptChild(SqrtFactory.create(new RNode[1], getContext(), getBuiltin())); + @Child protected Mean mean = adoptChild(MeanFactory.create(new RNode[2], getBuiltin())); + @Child protected Sqrt sqrt = adoptChild(SqrtFactory.create(new RNode[1], getBuiltin())); @Child protected BinaryArithmetic add = adoptChild(BinaryArithmetic.ADD.create()); @Child protected BinaryArithmetic sub = adoptChild(BinaryArithmetic.SUBTRACT.create()); @Child protected BinaryArithmetic pow = adoptChild(BinaryArithmetic.POW.create()); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SetSeed.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SetSeed.java index ed7d0e97c8abf165da252c5fc3d28afd566d2073..d62d4097b0b43da123c5564feeac7791f76f8817 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SetSeed.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/SetSeed.java @@ -24,6 +24,7 @@ package com.oracle.truffle.r.nodes.builtin.base; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.nodes.builtin.*; +import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @RBuiltin("set.seed") @@ -31,7 +32,7 @@ public abstract class SetSeed extends RBuiltinNode { @Specialization public RNull setseed(int n) { - getContext().getRandomNumberGenerator().setSeed(n); + RContext.getInstance().getRandomNumberGenerator().setSeed(n); return RNull.instance; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sum.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sum.java index b5b09a174e39759de9b99dbf50fc7828eb510c6a..129f276315c6e2942505ca9faddeeceb51dc437c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sum.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Sum.java @@ -57,7 +57,7 @@ public final class Sum extends RWrapperBuiltinNode { @Override protected RNode createDelegate() { ReduceSemantics semantics = new ReduceSemantics(0, 0.0, true, null); - Combine combine = CombineFactory.create(getArguments(), getContext(), getBuiltin(), null); + Combine combine = CombineFactory.create(getArguments(), getBuiltin(), null); return UnaryArithmeticReduceNodeFactory.create(semantics, BinaryArithmetic.ADD, combine); } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/ToString.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/ToString.java index 5f62d94f88955af7d8611eebc8225ade3b3ca2e2..17893f5825395f4d4ecedd1f30f2225eddbb04db 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/ToString.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/ToString.java @@ -48,7 +48,7 @@ public abstract class ToString extends RBuiltinNode { private String toStringRecursive(VirtualFrame frame, Object o) { if (recursiveToString == null) { CompilerDirectives.transferToInterpreter(); - recursiveToString = adoptChild(ToStringFactory.create(new RNode[1], getContext(), getBuiltin())); + recursiveToString = adoptChild(ToStringFactory.create(new RNode[1], getBuiltin())); recursiveToString.setSeparator(separator); recursiveToString.setQuotes(quotes); recursiveToString.setIntL(intL); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java index d9b04a360a1520c4e086af39e9b61d00ce31433e..db66eedf88f6b691c73209ffec104b46cfa3d7f6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttr.java @@ -48,7 +48,7 @@ public abstract class UpdateAttr extends RBuiltinNode { private RAbstractVector updateNames(VirtualFrame frame, RAbstractVector vector, Object o) { if (updateNames == null) { CompilerDirectives.transferToInterpreter(); - updateNames = adoptChild(UpdateNamesFactory.create(new RNode[1], getContext(), getBuiltin())); + updateNames = adoptChild(UpdateNamesFactory.create(new RNode[1], getBuiltin())); } return (RAbstractVector) updateNames.executeStringVector(frame, vector, o); } @@ -56,7 +56,7 @@ public abstract class UpdateAttr extends RBuiltinNode { private RAbstractVector updateDimNames(VirtualFrame frame, RAbstractVector vector, Object o) { if (updateDimNames == null) { CompilerDirectives.transferToInterpreter(); - updateDimNames = adoptChild(UpdateDimNamesFactory.create(new RNode[1], getContext(), getBuiltin())); + updateDimNames = adoptChild(UpdateDimNamesFactory.create(new RNode[1], getBuiltin())); } return (RAbstractVector) updateDimNames.executeList(frame, vector, o); } @@ -64,7 +64,7 @@ public abstract class UpdateAttr extends RBuiltinNode { private RAbstractIntVector castInteger(VirtualFrame frame, RAbstractVector vector) { if (castInteger == null) { CompilerDirectives.transferToInterpreter(); - castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false, getContext())); + castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false)); } return (RAbstractIntVector) castInteger.executeCast(frame, vector); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java index 2ec056bd9dcd533919a14d8ef02f86ae326352ac..b556928b0ad1ec09ebeeaf29d0a0d665164ecdf2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateAttributes.java @@ -48,7 +48,7 @@ public abstract class UpdateAttributes extends RBuiltinNode { private void updateNamesStringVector(VirtualFrame frame, RAbstractVector vector, Object o) { if (updateNames == null) { CompilerDirectives.transferToInterpreter(); - updateNames = adoptChild(UpdateNamesFactory.create(new RNode[1], getContext(), getBuiltin())); + updateNames = adoptChild(UpdateNamesFactory.create(new RNode[1], getBuiltin())); } updateNames.executeStringVector(frame, vector, o); } @@ -56,7 +56,7 @@ public abstract class UpdateAttributes extends RBuiltinNode { private RAbstractIntVector castInteger(VirtualFrame frame, RAbstractVector vector) { if (castInteger == null) { CompilerDirectives.transferToInterpreter(); - castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false, getContext())); + castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false)); } return (RAbstractIntVector) castInteger.executeCast(frame, vector); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java index 08c8b27cc1147c5723cd591839aadef2b4661bba..6e2fc6e936a84b749d6bb2962f40dd1ff5644855 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDim.java @@ -42,7 +42,7 @@ public abstract class UpdateDim extends RBuiltinNode { private RAbstractIntVector castInteger(VirtualFrame frame, RAbstractVector vector) { if (castInteger == null) { CompilerDirectives.transferToInterpreter(); - castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false, getContext())); + castInteger = adoptChild(CastIntegerNodeFactory.create(null, true, false)); } return (RAbstractIntVector) castInteger.executeCast(frame, vector); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java index ecbf94a712c7e1038775862ce97ab81300c000ad..ac0790a5d2c63cafcd00125d457ad856da89e26a 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateLength.java @@ -36,7 +36,7 @@ public abstract class UpdateLength extends RBuiltinNode { @CreateCast("arguments") protected RNode[] castStatusArgument(RNode[] arguments) { // length argument is at index 1, and cast to int - arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false, getContext()); + arguments[1] = CastIntegerNodeFactory.create(arguments[1], true, false); return arguments; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugInfoBuiltin.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugInfoBuiltin.java index ec61b2554f2efd748483c877f77f7ef671de934e..4a44e80372bb38595249306d117d83a925606862 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugInfoBuiltin.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugInfoBuiltin.java @@ -27,6 +27,7 @@ import java.util.*; import com.oracle.truffle.api.CompilerDirectives.*; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.r.nodes.builtin.*; +import com.oracle.truffle.r.runtime.*; @RBuiltin({"debug.info"}) @RBuiltinComment("Prints this message.") @@ -35,7 +36,7 @@ public abstract class DebugInfoBuiltin extends RBuiltinNode { @SlowPath @Specialization public Object printTree() { - RPackages packages = (RPackages) getContext().getLookup(); + RPackages packages = (RPackages) RContext.getInstance().getLookup(); StringBuilder b = new StringBuilder(); for (RPackage pack : packages.getPackages()) { b.append(createPackageString(pack)); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugPackage.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugPackage.java index 6af88f97c81e8f42954dc642ece70aa944c3abc8..2b59cd21be65ff8c13214329c7df7e7cd2632ad0 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugPackage.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/debug/DebugPackage.java @@ -23,12 +23,10 @@ package com.oracle.truffle.r.nodes.builtin.debug; import com.oracle.truffle.r.nodes.builtin.*; -import com.oracle.truffle.r.runtime.*; public class DebugPackage extends RPackage { - public DebugPackage(RContext context) { - super(context); + public DebugPackage() { load(DebugInfoBuiltin.class); load(DebugSource.class); load(DebugTreeBuiltin.class); @@ -43,9 +41,9 @@ public class DebugPackage extends RPackage { private static DebugPackage instance; - public static DebugPackage getInstance(RContext context) { + public static DebugPackage getInstance() { if (instance == null) { - instance = new DebugPackage(context); + instance = new DebugPackage(); } return instance; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallNode.java index 43de15c362d22ac7c12bf5082c9da0bc3d79638e..15801bbb5eb421e9b574aefa10ac3028ba6ff2f8 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/CallNode.java @@ -61,12 +61,12 @@ public abstract class CallNode extends RNode { return RTypesGen.RTYPES.expectDouble(execute(frame, function)); } - public static CallNode createStaticCall(RContext context, String function, CallArgumentsNode arguments) { - return CallNode.createCall(ReadVariableNode.create(function, context, true, false), arguments); + public static CallNode createStaticCall(String function, CallArgumentsNode arguments) { + return CallNode.createCall(ReadVariableNode.create(function, true, false), arguments); } - public static CallNode createStaticCall(SourceSection src, RContext context, String function, CallArgumentsNode arguments) { - CallNode cn = createStaticCall(context, function, arguments); + public static CallNode createStaticCall(SourceSection src, String function, CallArgumentsNode arguments) { + CallNode cn = createStaticCall(function, arguments); cn.assignSourceSection(src); return cn; } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java index 18b18c399f7882fef812bf26a58681f0a7146efd..578a5707be328ac866392b34fd5965414fdf36c5 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java @@ -30,7 +30,7 @@ import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.ops.na.*; -@NodeFields({@NodeField(name = "namesPreservation", type = boolean.class), @NodeField(name = "dimensionsPreservation", type = boolean.class), @NodeField(name = "context", type = RContext.class)}) +@NodeFields({@NodeField(name = "namesPreservation", type = boolean.class), @NodeField(name = "dimensionsPreservation", type = boolean.class)}) public abstract class CastIntegerNode extends CastNode { private final NACheck check = NACheck.create(); @@ -39,8 +39,6 @@ public abstract class CastIntegerNode extends CastNode { public abstract Object executeIntVector(VirtualFrame frame, Object o); - public abstract RContext getContext(); - protected abstract boolean isNamesPreservation(); protected abstract boolean isDimensionsPreservation(); @@ -58,7 +56,7 @@ public abstract class CastIntegerNode extends CastNode { private Object castIntegerRecursive(VirtualFrame frame, Object o) { if (recursiveCastInteger == null) { CompilerDirectives.transferToInterpreter(); - recursiveCastInteger = adoptChild(CastIntegerNodeFactory.create(null, isNamesPreservation(), isDimensionsPreservation(), getContext())); + recursiveCastInteger = adoptChild(CastIntegerNodeFactory.create(null, isNamesPreservation(), isDimensionsPreservation())); } return recursiveCastInteger.executeInt(frame, o); } @@ -81,7 +79,7 @@ public abstract class CastIntegerNode extends CastNode { @Specialization public int doDouble(double operand) { check.enable(operand); - return check.convertDoubleToInt(getContext(), operand); + return check.convertDoubleToInt(operand); } @Specialization @@ -97,7 +95,7 @@ public abstract class CastIntegerNode extends CastNode { @Specialization public int doComplex(RComplex operand) { check.enable(operand); - return check.convertComplexToInt(getContext(), operand); + return check.convertComplexToInt(operand); } @Specialization @@ -118,9 +116,9 @@ public abstract class CastIntegerNode extends CastNode { int length = vector.getLength(); int[] result = new int[length]; for (int i = 0; i < length; i++) { - result[i] = check.convertComplexToInt(getContext(), vector.getDataAt(i), false); + result[i] = check.convertComplexToInt(vector.getDataAt(i), false); } - getContext().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); + RContext.getInstance().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions()); } @@ -130,9 +128,9 @@ public abstract class CastIntegerNode extends CastNode { int length = vector.getLength(); int[] result = new int[length]; for (int i = 0; i < length; i++) { - result[i] = check.convertComplexToInt(getContext(), vector.getDataAt(i), false); + result[i] = check.convertComplexToInt(vector.getDataAt(i), false); } - getContext().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); + RContext.getInstance().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames()); } @@ -142,9 +140,9 @@ public abstract class CastIntegerNode extends CastNode { int length = vector.getLength(); int[] result = new int[length]; for (int i = 0; i < length; i++) { - result[i] = check.convertComplexToInt(getContext(), vector.getDataAt(i), false); + result[i] = check.convertComplexToInt(vector.getDataAt(i), false); } - getContext().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); + RContext.getInstance().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); return RDataFactory.createIntVector(result, check.neverSeenNA()); } @@ -217,21 +215,21 @@ public abstract class CastIntegerNode extends CastNode { @Specialization(order = 110, guards = "preserveDimensions") public RIntVector doDoubleVectorDims(RDoubleVector vector) { check.enable(vector); - int[] result = check.convertDoubleVectorToIntData(getContext(), vector); + int[] result = check.convertDoubleVectorToIntData(vector); return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions()); } @Specialization(order = 111, guards = "preserveNames") public RIntVector doDoubleVectorNames(RDoubleVector vector) { check.enable(vector); - int[] result = check.convertDoubleVectorToIntData(getContext(), vector); + int[] result = check.convertDoubleVectorToIntData(vector); return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames()); } @Specialization(order = 112) public RIntVector doDoubleVector(RDoubleVector vector) { check.enable(vector); - int[] result = check.convertDoubleVectorToIntData(getContext(), vector); + int[] result = check.convertDoubleVectorToIntData(vector); return RDataFactory.createIntVector(result, check.neverSeenNA()); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java index e55a77dd9a9a6ff12571a9639806411630826ea1..eee13c37d3f49f6ebe3a129072d3a62fbf5bcba5 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastLogicalNode.java @@ -31,7 +31,7 @@ import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; import com.oracle.truffle.r.runtime.ops.na.*; -@NodeFields({@NodeField(name = "namesPreservation", type = boolean.class), @NodeField(name = "dimensionsPreservation", type = boolean.class), @NodeField(name = "context", type = RContext.class)}) +@NodeFields({@NodeField(name = "namesPreservation", type = boolean.class), @NodeField(name = "dimensionsPreservation", type = boolean.class)}) public abstract class CastLogicalNode extends CastNode { private final NACheck naCheck = NACheck.create(); @@ -40,8 +40,6 @@ public abstract class CastLogicalNode extends CastNode { public abstract Object executeLogicalVector(VirtualFrame frame, Object o); - public abstract RContext getContext(); - protected abstract boolean isNamesPreservation(); protected abstract boolean isDimensionsPreservation(); @@ -79,7 +77,7 @@ public abstract class CastLogicalNode extends CastNode { @Specialization public byte doString(String operand) { naCheck.enable(operand); - return naCheck.convertStringToLogical(getContext(), operand); + return naCheck.convertStringToLogical(operand); } @Specialization @@ -118,7 +116,7 @@ public abstract class CastLogicalNode extends CastNode { byte[] ddata = new byte[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { String value = operand.getDataAt(i); - ddata[i] = naCheck.convertStringToLogical(getContext(), value); + ddata[i] = naCheck.convertStringToLogical(value); } return RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getDimensions()); } @@ -129,7 +127,7 @@ public abstract class CastLogicalNode extends CastNode { byte[] ddata = new byte[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { String value = operand.getDataAt(i); - ddata[i] = naCheck.convertStringToLogical(getContext(), value); + ddata[i] = naCheck.convertStringToLogical(value); } return RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA(), operand.getNames()); } @@ -140,7 +138,7 @@ public abstract class CastLogicalNode extends CastNode { byte[] ddata = new byte[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { String value = operand.getDataAt(i); - ddata[i] = naCheck.convertStringToLogical(getContext(), value); + ddata[i] = naCheck.convertStringToLogical(value); } return RDataFactory.createLogicalVector(ddata, naCheck.neverSeenNA()); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java index 6cb3640728e01648967348173e6d4449d1e76e06..696366bc8502991454a5286f21d344248d206838 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastStringNode.java @@ -33,7 +33,7 @@ import com.oracle.truffle.r.runtime.data.model.*; @NodeField(name = "dimensionsPreservation", type = boolean.class)}) public abstract class CastStringNode extends CastNode { - @Child private ToString toString = adoptChild(ToStringFactory.create(new RNode[1], null, null)); + @Child private ToString toString = adoptChild(ToStringFactory.create(new RNode[1], null)); public abstract Object executeString(VirtualFrame frame, Object o); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RBuiltinLookup.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RBuiltinLookup.java index bca0e6037d5055a353ca2f92fcf341c32c11379b..3a1efb2f7c38da58284d1a743b68a2f7ac481751 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RBuiltinLookup.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RBuiltinLookup.java @@ -26,6 +26,6 @@ import com.oracle.truffle.r.runtime.data.*; public interface RBuiltinLookup { - RFunction lookup(RContext context, String methodName); + RFunction lookup(String methodName); } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java index 91ac6519acc6c3886cf48aecd14f6740a110a086..11e856cab2fa0589f464b89474526aa4dcd6a43b 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RRuntime.java @@ -153,13 +153,13 @@ public class RRuntime { return !isNAorNaN(d) && !Double.isInfinite(d); } - public static int string2int(RContext context, String s) { + public static int string2int(String s) { if (s != STRING_NA) { // FIXME use R rules try { return Integer.decode(s); // decode supports hex constants } catch (NumberFormatException e) { - context.getAssumptions().naIntroduced.invalidate(); + RContext.getInstance().getAssumptions().naIntroduced.invalidate(); } } return INT_NA; @@ -170,7 +170,7 @@ public class RRuntime { return longValue == d && ((int) longValue & 0xffffffff) == longValue; } - public static double string2double(RContext context, String v) { + public static double string2double(String v) { if (v != STRING_NA) { // FIXME use R rules if ("Inf".equals(v)) { @@ -187,7 +187,7 @@ public class RRuntime { } catch (NumberFormatException ein) { } } - context.getAssumptions().naIntroduced.invalidate(); + RContext.getInstance().getAssumptions().naIntroduced.invalidate(); } } return DOUBLE_NA; @@ -213,7 +213,7 @@ public class RRuntime { return isNA(c) ? LOGICAL_NA : c.getRealPart() == 0.0 && c.getImaginaryPart() == 0.0 ? LOGICAL_FALSE : LOGICAL_TRUE; } - public static byte string2logical(RContext context, String s) { + public static byte string2logical(String s) { if (s != STRING_NA) { if (s.equals("TRUE") || s.equals("T")) { return TRUE; @@ -227,7 +227,7 @@ public class RRuntime { if (s.equals("False") || s.equals("false")) { return FALSE; } - context.getAssumptions().naIntroduced.invalidate(); + RContext.getInstance().getAssumptions().naIntroduced.invalidate(); } return LOGICAL_NA; } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/na/NACheck.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/na/NACheck.java index 7f1d355d538215d9df6df6f3b5f03272686eb0e5..9539985f2dffdc6dd81c55d0e6a255f173b16387 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/na/NACheck.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ops/na/NACheck.java @@ -291,14 +291,14 @@ public final class NACheck implements RDataCheckClosure { return ((int) value.getRealPart()) == 0 ? RRuntime.LOGICAL_FALSE : RRuntime.LOGICAL_TRUE; } - public int convertComplexToInt(RContext context, RComplex right) { - return convertComplexToInt(context, right, true); + public int convertComplexToInt(RComplex right) { + return convertComplexToInt(right, true); } @SuppressWarnings("static-method") - public int convertComplexToInt(RContext context, RComplex right, boolean warning) { + public int convertComplexToInt(RComplex right, boolean warning) { if (warning) { - context.setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); + RContext.getInstance().setEvalWarning(RError.IMAGINARY_PARTS_DISCARDED_IN_COERCION); } return (int) right.getRealPart(); } @@ -314,7 +314,7 @@ public final class NACheck implements RDataCheckClosure { return false; } - public int convertDoubleToInt(RContext context, double value) { + public int convertDoubleToInt(double value) { if (checkNAorNaN(value)) { return RRuntime.INT_NA; } @@ -324,13 +324,13 @@ public final class NACheck implements RDataCheckClosure { CompilerDirectives.transferToInterpreterAndInvalidate(); this.conversionOverflowReached = true; } - context.setEvalWarning(RError.NA_INTRODUCED_COERCION); + RContext.getInstance().setEvalWarning(RError.NA_INTRODUCED_COERCION); return RRuntime.INT_NA; } return result; } - public int[] convertDoubleVectorToIntData(RContext context, RDoubleVector vector) { + public int[] convertDoubleVectorToIntData(RDoubleVector vector) { int length = vector.getLength(); int[] result = new int[length]; boolean warning = false; @@ -351,7 +351,7 @@ public final class NACheck implements RDataCheckClosure { result[i] = intValue; } if (warning) { - context.setEvalWarning(RError.NA_INTRODUCED_COERCION); + RContext.getInstance().setEvalWarning(RError.NA_INTRODUCED_COERCION); } } return result; @@ -368,8 +368,8 @@ public final class NACheck implements RDataCheckClosure { } @SuppressWarnings("static-method") - public byte convertStringToLogical(RContext context, String value) { - return RRuntime.string2logical(context, value); + public byte convertStringToLogical(String value) { + return RRuntime.string2logical(value); } }