Skip to content
Snippets Groups Projects
Commit 2b263893 authored by stepan's avatar stepan
Browse files

Deparse supports KEEPINTEGER

Note: the callers that set the 'opts' parameter explicitly to 0 were modified
so that deparse behaves compatibly.
parent ed9e26be
Branches
No related tags found
No related merge requests found
......@@ -445,7 +445,7 @@ class RRuntimeASTAccessImpl implements RRuntimeASTAccess {
// This checks for the specific structure of replacements
RLanguage replacement = ReplacementDispatchNode.getRLanguage(rl);
RLanguage elem = replacement == null ? rl : replacement;
String string = RDeparse.deparse(elem, RDeparse.DEFAULT_Cutoff, true, 0, -1);
String string = RDeparse.deparse(elem, RDeparse.DEFAULT_Cutoff, true, RDeparse.KEEPINTEGER, -1);
return string.split("\n")[0];
}
......
......@@ -22,7 +22,8 @@
*/
package com.oracle.truffle.r.nodes.builtin.base;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.*;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.asStringVector;
import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.instanceOf;
import static com.oracle.truffle.r.runtime.RDispatch.INTERNAL_GENERIC;
import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE;
import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
......@@ -76,7 +77,7 @@ public abstract class AsCharacter extends RBuiltinNode {
} else if (elem instanceof RStringVector && ((RStringVector) elem).getLength() == 1) {
data[i] = ((RStringVector) elem).getDataAt(0);
} else {
data[i] = RDeparse.deparse(elem);
data[i] = RDeparse.deparse(elem, RDeparse.MAX_Cutoff, true, RDeparse.SIMPLEDEPARSE, -1);
}
if (RRuntime.isNA(data[i])) {
complete = RDataFactory.INCOMPLETE_VECTOR;
......
......@@ -12,12 +12,18 @@
package com.oracle.truffle.r.nodes.builtin.base.foreign;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.r.nodes.builtin.CastBuilder;
import com.oracle.truffle.r.nodes.builtin.RExternalBuiltinNode;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
public abstract class CairoProps extends RExternalBuiltinNode.Arg1 {
@Override
protected void createCasts(CastBuilder casts) {
casts.arg(0).asIntegerVector();
}
@Specialization
protected byte cairoProps(@SuppressWarnings("unused") RAbstractIntVector param) {
return RRuntime.LOGICAL_FALSE;
......
......@@ -39,6 +39,6 @@ final class LanguagePrinter extends AbstractValuePrinter<RLanguage> {
@Override
@TruffleBoundary
protected void printValue(RLanguage language, PrintContext printCtx) throws IOException {
printCtx.output().print(RDeparse.deparse(language, RDeparse.DEFAULT_Cutoff, true, 0, -1));
printCtx.output().print(RDeparse.deparse(language, RDeparse.DEFAULT_Cutoff, true, RDeparse.KEEPINTEGER, -1));
}
}
......@@ -97,7 +97,7 @@ public class RDeparse {
CURLY,
PAREN,
SUBSET,
DOLLAR;
DOLLAR
}
// TODO for consistency make an enum
......@@ -847,7 +847,10 @@ public class RDeparse {
if (RRuntime.isNA(i)) {
append((singleElement ? "NA_integer_" : "NA"));
} else {
append(RRuntime.intToStringNoCheck(i)).append('L');
append(RRuntime.intToStringNoCheck(i));
if ((opts & KEEPINTEGER) != 0) {
append('L');
}
}
break;
case CPLXSXP:
......@@ -959,12 +962,12 @@ public class RDeparse {
@TruffleBoundary
public static String deparseSyntaxElement(RSyntaxElement element) {
return new DeparseVisitor(false, RDeparse.MAX_Cutoff, true, 0, -1).append(element).getContents();
return new DeparseVisitor(false, RDeparse.MAX_Cutoff, true, KEEPINTEGER, -1).append(element).getContents();
}
@TruffleBoundary
public static String deparse(Object value) {
return new DeparseVisitor(false, RDeparse.MAX_Cutoff, true, 0, -1).appendValue(value).getContents();
return new DeparseVisitor(false, RDeparse.MAX_Cutoff, true, KEEPINTEGER, -1).appendValue(value).getContents();
}
@TruffleBoundary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment