From d5c22564841a072ef7c4c173628b5b5029648807 Mon Sep 17 00:00:00 2001 From: Adam Welc <adam.welc@oracle.com> Date: Mon, 27 Jan 2014 21:05:43 -0800 Subject: [PATCH] Fixes to vector casts and attributes printing. Enabled tests fixed by the previously introduced changes. --- .../r/nodes/builtin/base/AsCharacter.java | 4 +- .../r/nodes/builtin/base/AsDouble.java | 6 +- .../r/nodes/builtin/base/AsInteger.java | 17 +-- .../r/nodes/builtin/base/AsLogical.java | 2 +- .../truffle/r/nodes/builtin/base/Combine.java | 2 +- .../truffle/r/nodes/builtin/base/NChar.java | 2 +- .../truffle/r/nodes/builtin/base/Paste.java | 4 +- .../nodes/builtin/base/PrettyPrinterNode.java | 13 +- .../truffle/r/nodes/builtin/base/Print.java | 2 +- .../truffle/r/nodes/builtin/base/SApply.java | 2 +- .../truffle/r/nodes/builtin/base/Substr.java | 2 +- .../r/nodes/builtin/base/UpdateDimNames.java | 2 +- .../r/nodes/builtin/base/UpdateNames.java | 2 +- .../truffle/r/nodes/unary/CastDoubleNode.java | 8 +- .../r/nodes/unary/CastIntegerNode.java | 17 ++- .../r/nodes/unary/CastLogicalNode.java | 6 +- .../truffle/r/nodes/unary/CastStringNode.java | 135 ++++++++++++++++-- .../r/runtime/data/RLogicalVector.java | 4 + .../truffle/r/test/ExpectedTestOutput.test | 115 +++++++++++++++ .../oracle/truffle/r/test/all/AllTests.java | 22 ++- .../truffle/r/test/failing/FailingTests.java | 85 ----------- .../r/test/simple/TestSimpleArithmetic.java | 5 - .../r/test/simple/TestSimpleAttributes.java | 10 +- 23 files changed, 302 insertions(+), 165 deletions(-) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java index 8766deccc0..c2fea86ab7 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsCharacter.java @@ -51,7 +51,7 @@ public abstract class AsCharacter extends RBuiltinNode { public String doInt(VirtualFrame frame, int value) { if (castCharacterNode == null) { CompilerDirectives.transferToInterpreter(); - castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false)); + castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false, false, false)); } return (String) castCharacterNode.executeString(frame, value); } @@ -87,7 +87,7 @@ public abstract class AsCharacter extends RBuiltinNode { public RStringVector doVector(VirtualFrame frame, RAbstractVector vector) { if (castCharacterNode == null) { CompilerDirectives.transferToInterpreter(); - castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false)); + castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false, false, false)); } Object ret = castCharacterNode.executeStringVector(frame, vector); return (RStringVector) ret; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java index 2d7d242035..467d30ef11 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/AsDouble.java @@ -91,7 +91,7 @@ public abstract class AsDouble extends RBuiltinNode { @Specialization public RDoubleVector asDouble(RDoubleVector vector) { - return vector; + return RDataFactory.createDoubleVector(vector.getDataCopy(), vector.isComplete()); } @Specialization @@ -115,8 +115,8 @@ public abstract class AsDouble extends RBuiltinNode { } @Specialization - public RDoubleSequence asDouble(RDoubleSequence sequence) { - return sequence; + public RDoubleVector asDouble(RDoubleSequence sequence) { + return (RDoubleVector) sequence.createVector(); } @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 d6e1ff826e..fc893ad8b8 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 @@ -99,14 +99,9 @@ public abstract class AsInteger extends RBuiltinNode { return RRuntime.INT_NA; } - @Specialization(order = 70, guards = "oneDimensional") + @Specialization(order = 71) public RIntVector asInteger(RIntVector vector) { - return vector; - } - - @Specialization(order = 71, guards = "!oneDimensional") - public RIntVector asIntegerND(RIntVector vector) { - return vector.copyWithNewDimensions(null); + return RDataFactory.createIntVector(vector.getDataCopy(), vector.isComplete()); } @Specialization @@ -135,8 +130,8 @@ public abstract class AsInteger extends RBuiltinNode { } @Specialization - public RIntSequence asInteger(RIntSequence sequence) { - return sequence; + public RIntVector asInteger(RIntSequence sequence) { + return (RIntVector) sequence.createVector(); } @Specialization @@ -148,8 +143,4 @@ public abstract class AsInteger extends RBuiltinNode { public RIntVector asInteger(VirtualFrame frame, RList list) { return castIntVector(frame, list); } - - protected static boolean oneDimensional(RAbstractVector v) { - return !v.hasDimensions() || v.getDimensions().length == 1; - } } 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 564090667f..e1030947d6 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 @@ -94,7 +94,7 @@ public abstract class AsLogical extends RBuiltinNode { @Specialization public RLogicalVector asLogical(RLogicalVector vector) { - return vector; + return RDataFactory.createLogicalVector(vector.getDataCopy(), vector.isComplete()); } @Specialization 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 9bcecbed04..07bf9ad1dc 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 @@ -282,7 +282,7 @@ public abstract class Combine extends RBuiltinNode { private Object castString(VirtualFrame frame, Object operand) { if (castString == null) { CompilerDirectives.transferToInterpreter(); - castString = adoptChild(CastStringNodeFactory.create(null, false)); + castString = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } return castString.executeCast(frame, operand); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java index 5876953ae6..a7d3eb8c3c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/NChar.java @@ -40,7 +40,7 @@ public abstract class NChar extends RBuiltinNode { private String coerceContent(VirtualFrame frame, Object content) { if (convertString == null) { CompilerDirectives.transferToInterpreter(); - convertString = adoptChild(CastStringNodeFactory.create(null, false)); + convertString = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } try { return (String) convertString.executeCast(frame, content); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java index af2e248da2..7918b9518b 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Paste.java @@ -42,7 +42,7 @@ public abstract class Paste extends RBuiltinNode { private String castCharacter(VirtualFrame frame, Object o) { if (castCharacterNode == null) { CompilerDirectives.transferToInterpreter(); - castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false)); + castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } return (String) castCharacterNode.executeString(frame, o); } @@ -50,7 +50,7 @@ public abstract class Paste extends RBuiltinNode { private RStringVector castCharacterVector(VirtualFrame frame, Object o) { if (castCharacterNode == null) { CompilerDirectives.transferToInterpreter(); - castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false)); + castCharacterNode = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } Object ret = castCharacterNode.executeStringVector(frame, o); if (ret instanceof String) { 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 6048fb9e12..bbfcd07e5b 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 @@ -36,6 +36,7 @@ import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.data.*; @NodeChild(value = "operand", type = RNode.class) +@NodeField(name = "printingAttributes", type = boolean.class) public abstract class PrettyPrinterNode extends RNode { @Child protected ToString toString; @@ -51,10 +52,12 @@ public abstract class PrettyPrinterNode extends RNode { @Child PrettyPrinterNode recursivePrettyPrinter; - private Object prettyPrintRecursive(VirtualFrame frame, Object o) { + protected abstract boolean isPrintingAttributes(); + + private Object prettyPrintAttributes(VirtualFrame frame, Object o) { if (recursivePrettyPrinter == null) { CompilerDirectives.transferToInterpreter(); - recursivePrettyPrinter = adoptChild(PrettyPrinterNodeFactory.create(null)); + recursivePrettyPrinter = adoptChild(PrettyPrinterNodeFactory.create(null, true)); } return recursivePrettyPrinter.executeString(frame, o); } @@ -125,7 +128,7 @@ public abstract class PrettyPrinterNode extends RNode { } builder.append("\n"); builder.append("attr(,\"" + attr.getKey() + "\")\n"); - builder.append(prettyPrintRecursive(frame, attr.getValue())); + builder.append(prettyPrintAttributes(frame, attr.getValue())); } return builder.toString(); } @@ -354,7 +357,7 @@ public abstract class PrettyPrinterNode extends RNode { } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { - if (operand.elementNamePrefix != null) { + if (isPrintingAttributes() && operand.elementNamePrefix != null) { sb.append(operand.elementNamePrefix); } Object name = operand.getNameAt(i); @@ -381,7 +384,7 @@ public abstract class PrettyPrinterNode extends RNode { } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { - if (operand.elementNamePrefix != null) { + if (isPrintingAttributes() && operand.elementNamePrefix != null) { sb.append(operand.elementNamePrefix); } else { sb.append(listName); 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 5d26edd6df..26126474d8 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 @@ -41,7 +41,7 @@ import com.oracle.truffle.r.runtime.data.model.*; @SuppressWarnings("unused") public abstract class Print extends RBuiltinNode { - @Child protected PrettyPrinterNode prettyPrinter = adoptChild(PrettyPrinterNodeFactory.create(null)); + @Child protected PrettyPrinterNode prettyPrinter = adoptChild(PrettyPrinterNodeFactory.create(null, false)); private void printHelper(String string) { getContext().getConsoleHandler().println(string); 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 4f84e002d4..17e4dfb632 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 @@ -233,7 +233,7 @@ public abstract class SApply extends RBuiltinNode { private RStringVector castString(VirtualFrame frame, RAbstractVector value) { if (castString == null) { CompilerDirectives.transferToInterpreter(); - castString = adoptChild(CastStringNodeFactory.create(null, false)); + castString = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } return (RStringVector) castString.executeString(frame, value); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java index 1e1f971d30..877fe865cb 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/Substr.java @@ -210,7 +210,7 @@ public abstract class Substr extends RBuiltinNode { private void ensureCast() { if (castString == null) { CompilerDirectives.transferToInterpreter(); - castString = adoptChild(CastStringNodeFactory.create(null, false)); + castString = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java index 34a61f1d00..518762f22c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateDimNames.java @@ -42,7 +42,7 @@ public abstract class UpdateDimNames extends RBuiltinNode { private Object castString(VirtualFrame frame, Object o) { if (castStringNode == null) { CompilerDirectives.transferToInterpreter(); - castStringNode = adoptChild(CastStringNodeFactory.create(null, true)); + castStringNode = adoptChild(CastStringNodeFactory.create(null, true, true, false)); } return castStringNode.executeStringVector(frame, o); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java index 4833fcc6b0..e6271ecab2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/base/UpdateNames.java @@ -41,7 +41,7 @@ public abstract class UpdateNames extends RBuiltinNode { private Object castString(VirtualFrame frame, Object o) { if (castStringNode == null) { CompilerDirectives.transferToInterpreter(); - castStringNode = adoptChild(CastStringNodeFactory.create(null, false)); + castStringNode = adoptChild(CastStringNodeFactory.create(null, false, true, false)); } return castStringNode.executeStringVector(frame, o); } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java index 237355b9f0..3b10e9c64e 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java @@ -90,7 +90,7 @@ public abstract class CastDoubleNode extends CastNode { } @Specialization(order = 101, guards = "preserveDimensions") - public RDoubleVector doLogicalVectorDimsAndNames(RLogicalVector operand) { + public RDoubleVector doLogicalVectorDims(RLogicalVector operand) { naCheck.enable(operand); double[] ddata = new double[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { @@ -123,7 +123,7 @@ public abstract class CastDoubleNode extends CastNode { } @Specialization(order = 104, guards = "preserveDimensions") - public RDoubleVector doStringVectorDimsAndNames(RStringVector operand) { + public RDoubleVector doStringVectorDims(RStringVector operand) { naCheck.enable(operand); double[] ddata = new double[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { @@ -152,11 +152,11 @@ public abstract class CastDoubleNode extends CastNode { String value = operand.getDataAt(i); ddata[i] = naCheck.convertStringToDouble(value); } - return RDataFactory.createDoubleVector(ddata, operand.isComplete(), operand.getNames()); + return RDataFactory.createDoubleVector(ddata, operand.isComplete()); } @Specialization(order = 107, guards = "preserveDimensions") - public RDoubleVector doComplexVectorDimsAndNames(RComplexVector operand) { + public RDoubleVector doComplexVectorDims(RComplexVector operand) { naCheck.enable(operand); double[] ddata = new double[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { 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 429f939d43..18b18c399f 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,8 +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), @NodeField(name = "context", type = RContext.class)}) public abstract class CastIntegerNode extends CastNode { private final NACheck check = NACheck.create(); @@ -114,7 +113,7 @@ public abstract class CastIntegerNode extends CastNode { } @Specialization(order = 101, guards = "preserveDimensions") - public RIntVector doComplexVectorDimsAndNames(RComplexVector vector) { + public RIntVector doComplexVectorDims(RComplexVector vector) { check.enable(vector); int length = vector.getLength(); int[] result = new int[length]; @@ -150,7 +149,7 @@ public abstract class CastIntegerNode extends CastNode { } @Specialization(order = 104, guards = "preserveDimensions") - public RIntVector doStringVectorDimsAndNames(RStringVector vector) { + public RIntVector doStringVectorDims(RStringVector vector) { check.enable(vector); int length = vector.getLength(); int[] result = new int[length]; @@ -183,7 +182,7 @@ public abstract class CastIntegerNode extends CastNode { } @Specialization(order = 107, guards = "preserveDimensions") - public RIntVector doLogicalVectorDimsAndNames(RLogicalVector vector) { + public RIntVector doLogicalVectorDims(RLogicalVector vector) { check.enable(vector); int length = vector.getLength(); int[] result = new int[length]; @@ -216,7 +215,7 @@ public abstract class CastIntegerNode extends CastNode { } @Specialization(order = 110, guards = "preserveDimensions") - public RIntVector doDoubleVectorDimsAndNames(RDoubleVector vector) { + public RIntVector doDoubleVectorDims(RDoubleVector vector) { check.enable(vector); int[] result = check.convertDoubleVectorToIntData(getContext(), vector); return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions()); @@ -237,13 +236,13 @@ public abstract class CastIntegerNode extends CastNode { } @Specialization(order = 113, guards = "preserveDimensions") - public RIntVector doRawVectorDimsAndNames(RRawVector vector) { + public RIntVector doRawVectorDims(RRawVector vector) { int length = vector.getLength(); int[] result = new int[length]; for (int i = 0; i < length; i++) { result[i] = vector.getDataAt(i).getValue(); } - return RDataFactory.createIntVector(result, check.neverSeenNA()); + return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getDimensions()); } @Specialization(order = 114, guards = "preserveNames") @@ -263,7 +262,7 @@ public abstract class CastIntegerNode extends CastNode { for (int i = 0; i < length; i++) { result[i] = vector.getDataAt(i).getValue(); } - return RDataFactory.createIntVector(result, check.neverSeenNA(), vector.getNames()); + return RDataFactory.createIntVector(result, check.neverSeenNA()); } @Specialization 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 940c535241..e55a77dd9a 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 @@ -113,7 +113,7 @@ public abstract class CastLogicalNode extends CastNode { } @Specialization(order = 101, guards = "preserveDimensions") - public RLogicalVector doStringVectorDimsAndNames(RStringVector operand) { + public RLogicalVector doStringVectorDims(RStringVector operand) { naCheck.enable(operand); byte[] ddata = new byte[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { @@ -146,7 +146,7 @@ public abstract class CastLogicalNode extends CastNode { } @Specialization(order = 104, guards = "preserveDimensions") - public RLogicalVector doComplexVectorDimsAndNames(RComplexVector operand) { + public RLogicalVector doComplexVectorDims(RComplexVector operand) { naCheck.enable(operand); byte[] ddata = new byte[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { @@ -179,7 +179,7 @@ public abstract class CastLogicalNode extends CastNode { } @Specialization(order = 107, guards = "preserveDimensions") - public RLogicalVector doRawVectorDimsAndNames(RRawVector operand) { + public RLogicalVector doRawVectorDims(RRawVector operand) { byte[] ddata = new byte[operand.getLength()]; for (int i = 0; i < operand.getLength(); i++) { RRaw value = operand.getDataAt(i); 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 67bd919c6d..6cb3640728 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 @@ -29,7 +29,8 @@ import com.oracle.truffle.r.nodes.builtin.base.*; import com.oracle.truffle.r.runtime.data.*; import com.oracle.truffle.r.runtime.data.model.*; -@NodeField(name = "emptyVectorConvertedToNull", type = boolean.class) +@NodeFields({@NodeField(name = "emptyVectorConvertedToNull", type = boolean.class), @NodeField(name = "namesPreservation", type = boolean.class), + @NodeField(name = "dimensionsPreservation", type = boolean.class)}) public abstract class CastStringNode extends CastNode { @Child private ToString toString = adoptChild(ToStringFactory.create(new RNode[1], null, null)); @@ -40,6 +41,18 @@ public abstract class CastStringNode extends CastNode { public abstract boolean isEmptyVectorConvertedToNull(); + protected abstract boolean isNamesPreservation(); + + protected abstract boolean isDimensionsPreservation(); + + protected boolean preserveNames() { + return isNamesPreservation(); + } + + protected boolean preserveDimensions() { + return isDimensionsPreservation(); + } + public CastStringNode() { toString.setQuotes(false); } @@ -74,38 +87,78 @@ public abstract class CastStringNode extends CastNode { return toString.executeString(frame, value); } - @Specialization(guards = "isZeroLength") + @Specialization(order = 100, guards = "isZeroLength") public Object doEmptyVector(@SuppressWarnings("unused") RAbstractVector vector) { return isEmptyVectorConvertedToNull() ? RNull.instance : RDataFactory.createStringVector(0); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 102, guards = "!isZeroLength") public RStringVector doStringVector(RStringVector vector) { return vector; } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 103, guards = "!isZeroLength") public RStringVector doIntVector(VirtualFrame frame, RIntVector vector) { return performAbstractIntVector(frame, vector); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 104, guards = "!isZeroLength") public RStringVector doDoubleVector(VirtualFrame frame, RDoubleVector vector) { return performAbstractDoubleVector(frame, vector); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 105, guards = "!isZeroLength") public RStringVector doIntSequence(VirtualFrame frame, RIntSequence vector) { return performAbstractIntVector(frame, vector); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 106, guards = "!isZeroLength") public RStringVector doDoubleSequence(VirtualFrame frame, RDoubleSequence vector) { return performAbstractDoubleVector(frame, vector); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 107, guards = {"!isZeroLength", "preserveDimensions"}) + public RStringVector doLogicalVectorDims(VirtualFrame frame, RLogicalVector vector) { + int length = vector.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, vector.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions()); + } + + @Specialization(order = 108, guards = {"!isZeroLength", "preserveNames"}) + public RStringVector doLogicalVectorNames(VirtualFrame frame, RLogicalVector vector) { + int length = vector.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, vector.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); + } + + @Specialization(order = 109, guards = "!isZeroLength") public RStringVector doLogicalVector(VirtualFrame frame, RLogicalVector vector) { + int length = vector.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, vector.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); + } + + @Specialization(order = 110, guards = {"!isZeroLength", "preserveDimensions"}) + public RStringVector doComplexVectorDims(VirtualFrame frame, RComplexVector vector) { + int length = vector.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, vector.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions()); + } + + @Specialization(order = 111, guards = {"!isZeroLength", "preserveNames"}) + public RStringVector doComplexVectorNames(VirtualFrame frame, RComplexVector vector) { int length = vector.getLength(); String[] result = new String[length]; for (int i = 0; i < length; i++) { @@ -114,8 +167,28 @@ public abstract class CastStringNode extends CastNode { return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 112, guards = "!isZeroLength") public RStringVector doComplexVector(VirtualFrame frame, RComplexVector vector) { + int length = vector.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, vector.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); + } + + @Specialization(order = 113, guards = {"!isZeroLength", "preserveDimensions"}) + public RStringVector doRawVectorDims(VirtualFrame frame, RRawVector vector) { + int length = vector.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, vector.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions()); + } + + @Specialization(order = 114, guards = {"!isZeroLength", "preserveNames"}) + public RStringVector doRawVectorNames(VirtualFrame frame, RRawVector vector) { int length = vector.getLength(); String[] result = new String[length]; for (int i = 0; i < length; i++) { @@ -124,18 +197,28 @@ public abstract class CastStringNode extends CastNode { return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); } - @Specialization(guards = "!isZeroLength") + @Specialization(order = 115, guards = "!isZeroLength") public RStringVector doRawVector(VirtualFrame frame, RRawVector vector) { int length = vector.getLength(); String[] result = new String[length]; for (int i = 0; i < length; i++) { result[i] = toString.executeString(frame, vector.getDataAt(i)); } - return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); } - @Specialization - public RStringVector doList(VirtualFrame frame, RList list) { + @Specialization(order = 116, guards = {"!isZeroLength", "preserveDimensions"}) + public RStringVector doListDims(VirtualFrame frame, RList list) { + int length = list.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, list.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, list.getDimensions()); + } + + @Specialization(order = 117, guards = {"!isZeroLength", "preserveNames"}) + public RStringVector doListNames(VirtualFrame frame, RList list) { int length = list.getLength(); String[] result = new String[length]; for (int i = 0; i < length; i++) { @@ -144,13 +227,29 @@ public abstract class CastStringNode extends CastNode { return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, list.getNames()); } + @Specialization(order = 118, guards = "!isZeroLength") + public RStringVector doList(VirtualFrame frame, RList list) { + int length = list.getLength(); + String[] result = new String[length]; + for (int i = 0; i < length; i++) { + result[i] = toString.executeString(frame, list.getDataAt(i)); + } + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); + } + private RStringVector performAbstractIntVector(VirtualFrame frame, RAbstractIntVector vector) { int length = vector.getLength(); String[] result = new String[length]; for (int i = 0; i < length; i++) { result[i] = toString.executeString(frame, vector.getDataAt(i)); } - return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); + if (preserveDimensions()) { + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions()); + } else if (preserveNames()) { + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); + } else { + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); + } } private RStringVector performAbstractDoubleVector(VirtualFrame frame, RAbstractDoubleVector vector) { @@ -159,7 +258,13 @@ public abstract class CastStringNode extends CastNode { for (int i = 0; i < length; i++) { result[i] = toString.executeString(frame, vector.getDataAt(i)); } - return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); + if (preserveDimensions()) { + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getDimensions()); + } else if (preserveNames()) { + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR, vector.getNames()); + } else { + return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); + } } protected boolean isZeroLength(@SuppressWarnings("unused") VirtualFrame frame, RAbstractVector vector) { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLogicalVector.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLogicalVector.java index 0a16ca316b..7534c19ac2 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLogicalVector.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RLogicalVector.java @@ -129,6 +129,10 @@ public final class RLogicalVector extends RVector implements RAbstractLogicalVec return RLogical.class; } + public byte[] getDataCopy() { + return Arrays.copyOf(data, data.length); + } + @Override public RLogicalVector copyWithNewDimensions(int[] newDimensions) { return RDataFactory.createLogicalVector(data, isComplete(), newDimensions); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 0b4ebbdd37..042844220d 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -342,6 +342,14 @@ Warning message: In c(TRUE, TRUE) & c(TRUE, FALSE, FALSE) : longer object length is not a multiple of shorter object length +##com.oracle.truffle.r.test.simple.TestSimpleArithmetic.testNonvectorizedLogicalLengthChecks +#{ c(a=TRUE, TRUE) | c(TRUE, b=FALSE, FALSE) } + b +TRUE TRUE TRUE +Warning message: +In c(a = TRUE, TRUE) | c(TRUE, b = FALSE, FALSE) : + longer object length is not a multiple of shorter object length + ##com.oracle.truffle.r.test.simple.TestSimpleArithmetic.testNonvectorizedLogicalOr #{ 0 || 0 } [1] FALSE @@ -1856,6 +1864,11 @@ Error: object 'nonexistent' not found #{ x <- as.raw(1:2); attr(x, "hi") <- 2 ; x & x } [1] 01 02 +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testArithmeticPropagation +#{ x <- c(a=FALSE,b=TRUE) ; attr(x, "hi") <- 2 ; !x } + a b + TRUE FALSE + ##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testBuiltinPropagation #{ x <- 1 ; attr(x, "myatt") <- 1; c(x, x, x) } [1] 1 1 1 @@ -1912,6 +1925,108 @@ $dimnames[[3]] +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testCastsIgnore +#{ x <- c(a=1, b=2) ; attr(x, "myatt") <- 1 ; as.character(x) } +[1] "1" "2" + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testCastsIgnore +#{ x <- c(a=1, b=2) ; attr(x, "myatt") <- 1 ; as.double(x) } +[1] 1 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testCastsIgnore +#{ x <- c(a=1, b=2) ; attr(x, "myatt") <- 1 ; as.integer(x) } +[1] 1 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- "s" ; attr(x, "hi") <- 2 ; x } +[1] "s" +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- 1 ; attr(x, "hi") <- 2 ; x } +[1] 1 +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- 1+1i ; attr(x, "hi") <- 2 ; x } +[1] 1+1i +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- 1L ; attr(x, "hi") <- 2 ; x } +[1] 1 +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- TRUE ; attr(x, "hi") <- 2 ; x } +[1] TRUE +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- as.raw(10) ; attr(x, "hi") <- 2 ; x } +[1] 0a +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- c(1, 2) ; attr(x, "hi") <- 2; x } +[1] 1 2 +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- c(1L, 2L) ; attr(x, "hi") <- 2; attr(x, "hello") <- 1:2 ; x } +[1] 1 2 +attr(,"hi") +[1] 2 +attr(,"hello") +[1] 1 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- c(1L, 2L) ; attr(x, "hi") <- 2; x } +[1] 1 2 +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- c(hello=1) ; attr(x, "hi") <- 2 ; attr(x,"names") <- "HELLO" ; x } +HELLO + 1 +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x <- c(hello=9) ; attr(x, "hi") <- 2 ; y <- x ; y } +hello + 9 +attr(,"hi") +[1] 2 + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x<-1; dim(x)<-1; y<-(attr(x, "dimnames")<-list(1)); y } +[[1]] +[1] "1" + + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x<-1; dim(x)<-1; y<-list(a="1"); attr(y, "foo")<-"foo"; z<-(attr(x, "dimnames")<-y); z } +$a +[1] "1" + +attr(,"foo") +[1] "foo" + +##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testDefinition +#{ x<-1; dim(x)<-1; y<-list(a="1"); z<-(attr(x, "dimnames")<-y); z } +$a +[1] "1" + + ##com.oracle.truffle.r.test.simple.TestSimpleAttributes.testOtherPropagation #{ x <- 1:2; attr(x, "hi") <- 2 ; x == x } [1] TRUE TRUE diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java index 9c4b3d09bc..e91cfd611d 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/all/AllTests.java @@ -674,7 +674,7 @@ public class AllTests extends TestBase { } @Test - public void TestSimpleArithmetic_testNonvectorizedLogicalLengthChecksIgnore_a1594db2ddfa1d07731f6c5f92cd9833() { + public void TestSimpleArithmetic_testNonvectorizedLogicalLengthChecks_a1594db2ddfa1d07731f6c5f92cd9833() { assertEvalWarning("{ c(a=TRUE, TRUE) | c(TRUE, b=FALSE, FALSE) }"); } @@ -3203,6 +3203,11 @@ public class AllTests extends TestBase { assertEval("{ x <- as.raw(1:2); attr(x, \"hi\") <- 2 ; x & x }"); } + @Test + public void TestSimpleAttributes_testArithmeticPropagation_bd8aedf4ca4bd613b8c5ce35463c17a5() { + assertEval("{ x <- c(a=FALSE,b=TRUE) ; attr(x, \"hi\") <- 2 ; !x }"); + } + @Test public void TestSimpleAttributes_testArithmeticPropagationIgnore_1bda07d542646902be34ad03340e3589() { assertEval("{ x <- c(1+1i,2+2i); attr(x, \"hi\") <- 3 ; y <- 2:3 ; attr(y,\"zz\") <- 2; x+y }"); @@ -3258,11 +3263,6 @@ public class AllTests extends TestBase { assertEval("{ x <- c(a=1,b=2) ; attr(x, \"hi\") <- 2 ; -x }"); } - @Test - public void TestSimpleAttributes_testArithmeticPropagationIgnore_bd8aedf4ca4bd613b8c5ce35463c17a5() { - assertEval("{ x <- c(a=FALSE,b=TRUE) ; attr(x, \"hi\") <- 2 ; !x }"); - } - @Test public void TestSimpleAttributes_testArrayPropagation_ff71faa7f9c4a02839d5cb9c6735788f() { assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1; x[c(1,1)] }"); @@ -3528,6 +3528,16 @@ public class AllTests extends TestBase { assertEval("{ x<-1; dim(x)<-1; y<-(attr(x, \"dimnames\")<-list(1)); y }"); } + @Test + public void TestSimpleAttributes_testDefinition_4889b45f46fc504e4461e022620fc5d7() { + assertEval("{ x<-1; dim(x)<-1; y<-list(a=\"1\"); z<-(attr(x, \"dimnames\")<-y); z }"); + } + + @Test + public void TestSimpleAttributes_testDefinition_3856e444c64ddd1b3dbeb3529dd0c22f() { + assertEval("{ x<-1; dim(x)<-1; y<-list(a=\"1\"); attr(y, \"foo\")<-\"foo\"; z<-(attr(x, \"dimnames\")<-y); z }"); + } + @Test public void TestSimpleAttributes_testOtherPropagation_4957f6dceaabc15ff469b4e6e576d6dc() { assertEval("{ x <- 1:2; attr(x, \"hi\") <- 2 ; x == x }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java index bd18dc7843..94e5130a1f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/failing/FailingTests.java @@ -263,11 +263,6 @@ public class FailingTests extends TestBase { assertEval("{ f <- function(a,b) { a && b } ; f(c(TRUE, FALSE), logical()) ; f(TRUE, c(TRUE,TRUE,FALSE)) ; f(1,2) }"); } - @Ignore - public void TestSimpleArithmetic_testNonvectorizedLogicalLengthChecksIgnore_a1594db2ddfa1d07731f6c5f92cd9833() { - assertEvalWarning("{ c(a=TRUE, TRUE) | c(TRUE, b=FALSE, FALSE) }"); - } - @Ignore public void TestSimpleArithmetic_testScalarsComplexIgnore_ec41b305258209dcd1f01b4c73dfa38c() { assertEval("{ x <- 1+2i; y <- 3+4i; round(x*x*y/(x+y), digits=5) }"); @@ -1053,11 +1048,6 @@ public class FailingTests extends TestBase { assertEval("{ x <- c(a=1,b=2) ; attr(x, \"hi\") <- 2 ; -x }"); } - @Ignore - public void TestSimpleAttributes_testArithmeticPropagationIgnore_bd8aedf4ca4bd613b8c5ce35463c17a5() { - assertEval("{ x <- c(a=FALSE,b=TRUE) ; attr(x, \"hi\") <- 2 ; !x }"); - } - @Ignore public void TestSimpleAttributes_testArrayPropagation_ff71faa7f9c4a02839d5cb9c6735788f() { assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1; x[c(1,1)] }"); @@ -1198,81 +1188,6 @@ public class FailingTests extends TestBase { assertEval("{ x<-1:8; dim(x)<-c(2, 2, 2); names(x)<-101:108; attr(x, \"dimnames\")<-list(201:202, 203:204, 205:206); attr(x, \"foo\")<-\"foo\"; y<-x; attributes(x>y) }"); } - @Ignore - public void TestSimpleAttributes_testCastsIgnore_7421f56a7aeb2d6ab6fb29c2bdb776f6() { - assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1 ; as.character(x) }"); - } - - @Ignore - public void TestSimpleAttributes_testCastsIgnore_c7ac6373611836a463ed1329c7aa7eee() { - assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1 ; as.double(x) }"); - } - - @Ignore - public void TestSimpleAttributes_testCastsIgnore_a553b41add3e553324f2a994498662c4() { - assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1 ; as.integer(x) }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_9bfc4209f222e2d701466ef7d338132a() { - assertEval("{ x <- as.raw(10) ; attr(x, \"hi\") <- 2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_80a0a73a4efa096e215a3bf7e5e5ee3e() { - assertEval("{ x <- TRUE ; attr(x, \"hi\") <- 2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_59f68b4d9d36df8c78eb72446822f6dd() { - assertEval("{ x <- 1L ; attr(x, \"hi\") <- 2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_ea8b6eacdfe0a30063d3a701d8b81f6e() { - assertEval("{ x <- 1 ; attr(x, \"hi\") <- 2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_a0ab09aad0b3f396ec58751a4051d177() { - assertEval("{ x <- 1+1i ; attr(x, \"hi\") <- 2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_32d40d8d60a044f9fafe367b8ae885fb() { - assertEval("{ x <- \"s\" ; attr(x, \"hi\") <- 2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_ce72d4164b0322ade6f4182d9311ebb0() { - assertEval("{ x <- c(1L, 2L) ; attr(x, \"hi\") <- 2; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_6c9cda38c30d74cc14b3e95de0034c60() { - assertEval("{ x <- c(1, 2) ; attr(x, \"hi\") <- 2; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_424967deb3f2e2c414ea5fb27c821f3b() { - assertEval("{ x <- c(1L, 2L) ; attr(x, \"hi\") <- 2; attr(x, \"hello\") <- 1:2 ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_af51cfc72a0c2a460dea902e49bac27c() { - assertEval("{ x <- c(hello=9) ; attr(x, \"hi\") <- 2 ; y <- x ; y }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_efd8aa922890186c8ec61d84b7fefd05() { - assertEval("{ x <- c(hello=1) ; attr(x, \"hi\") <- 2 ; attr(x,\"names\") <- \"HELLO\" ; x }"); - } - - @Ignore - public void TestSimpleAttributes_testDefinition_09cc8ecbb951d42df7ce9a2b83157a71() { - assertEval("{ x<-1; dim(x)<-1; y<-(attr(x, \"dimnames\")<-list(1)); y }"); - } - @Ignore public void TestSimpleBuiltins_testAbsIgnore_261d7e173c1caffcac87b3030f93a81c() { assertEval("{ abs(c(0/0,1i)) }"); diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleArithmetic.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleArithmetic.java index 7861b1c623..034867e29c 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleArithmetic.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleArithmetic.java @@ -648,11 +648,6 @@ public class TestSimpleArithmetic extends TestBase { assertEvalWarning("{ as.raw(c(1,5,4)) | as.raw(c(1,4)) }"); assertEvalWarning("{ c(TRUE, FALSE, FALSE) & c(TRUE,TRUE) }"); assertEvalWarning("{ c(TRUE, TRUE) & c(TRUE, FALSE, FALSE) }"); - } - - @Test - @Ignore - public void testNonvectorizedLogicalLengthChecksIgnore() { assertEvalWarning("{ c(a=TRUE, TRUE) | c(TRUE, b=FALSE, FALSE) }"); } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleAttributes.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleAttributes.java index 9603eb75c0..705fc761cf 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleAttributes.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/TestSimpleAttributes.java @@ -18,7 +18,6 @@ import com.oracle.truffle.r.test.*; public class TestSimpleAttributes extends TestBase { @Test - @Ignore public void testDefinition() { assertEval("{ x <- as.raw(10) ; attr(x, \"hi\") <- 2 ; x }"); assertEval("{ x <- TRUE ; attr(x, \"hi\") <- 2 ; x }"); @@ -35,6 +34,9 @@ public class TestSimpleAttributes extends TestBase { assertEval("{ x <- c(hello=1) ; attr(x, \"hi\") <- 2 ; attr(x,\"names\") <- \"HELLO\" ; x }"); assertEval("{ x<-1; dim(x)<-1; y<-(attr(x, \"dimnames\")<-list(1)); y }"); + + assertEval("{ x<-1; dim(x)<-1; y<-list(a=\"1\"); z<-(attr(x, \"dimnames\")<-y); z }"); + assertEval("{ x<-1; dim(x)<-1; y<-list(a=\"1\"); attr(y, \"foo\")<-\"foo\"; z<-(attr(x, \"dimnames\")<-y); z }"); } @Test @@ -44,6 +46,8 @@ public class TestSimpleAttributes extends TestBase { assertEval("{ x <- 1:2 ; attr(x, \"hi\") <- 2 ; !x }"); assertEval("{ x <- 1:2; attr(x, \"hi\") <- 2 ; x & x }"); assertEval("{ x <- as.raw(1:2); attr(x, \"hi\") <- 2 ; x & x }"); + + assertEval("{ x <- c(a=FALSE,b=TRUE) ; attr(x, \"hi\") <- 2 ; !x }"); } @Test @@ -63,8 +67,6 @@ public class TestSimpleAttributes extends TestBase { assertEval("{ x <- 1:2 ; attr(x, \"hi\") <- 3 ; attr(x, \"hihi\") <- 10 ; y <- 2:3 ; attr(y,\"zz\") <- 2; attr(y,\"hi\") <-3; attr(y,\"bye\") <- 4 ; x+y }"); assertEval("{ x <- c(a=1,b=2) ; attr(x, \"hi\") <- 2 ; -x }"); - - assertEval("{ x <- c(a=FALSE,b=TRUE) ; attr(x, \"hi\") <- 2 ; !x }"); } @Test @@ -72,9 +74,7 @@ public class TestSimpleAttributes extends TestBase { } @Test - @Ignore public void testCastsIgnore() { - // FIXME print regressions assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1 ; as.character(x) }"); assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1 ; as.double(x) }"); assertEval("{ x <- c(a=1, b=2) ; attr(x, \"myatt\") <- 1 ; as.integer(x) }"); -- GitLab