Skip to content
Snippets Groups Projects
Commit 4abd46c4 authored by stepan's avatar stepan
Browse files

RPairList: make sure tag is always RSymbol or RNull

parent f3644b00
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,7 @@ import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.RPairList;
import com.oracle.truffle.r.runtime.data.RShareable;
import com.oracle.truffle.r.runtime.data.RStringVector;
import com.oracle.truffle.r.runtime.data.RSymbol;
import com.oracle.truffle.r.runtime.data.RTypedValue;
import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
......@@ -75,7 +76,7 @@ public final class CoerceNodes {
for (int i = 0; i < v.getLength(); i++) {
Object element = v.getDataAtAsObject(i);
adjustSharing(v, element);
RPairList cur = RDataFactory.createPairList(element, RNull.instance, names != null ? names.getDataAt(i) : RNull.instance, gnurType);
RPairList cur = RDataFactory.createPairList(element, RNull.instance, names != null ? RDataFactory.createSymbol(names.getDataAt(i)) : RNull.instance, gnurType);
if (prev == null) {
assert head == null;
......
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -108,7 +108,7 @@ public final class RArgsValuesAndNames extends RObject implements RTypedValue {
assert signature.getLength() == getLength();
for (int i = 0; i < getLength(); i++) {
String name = signature.getName(i);
RPairList cur = RDataFactory.createPairList(getArgument(i), RNull.instance, name != null ? name : RNull.instance, SEXPTYPE.DOTSXP);
RPairList cur = RDataFactory.createPairList(getArgument(i), RNull.instance, name != null ? RDataFactory.createSymbol(name) : RNull.instance, SEXPTYPE.DOTSXP);
if (head == null) {
head = cur;
......
......@@ -45,7 +45,13 @@ import com.oracle.truffle.r.runtime.gnur.SEXPTYPE;
* {@code null} is never allowed as a value for the tag, car or cdr, only the type.
*/
public final class RPairList extends RSharingAttributeStorage implements RAbstractContainer, Iterable<RPairList> {
/**
* Data of the current pair list cell.
*/
private Object car = RNull.instance;
/**
* Link to the next {@link RPairList} cell or {@link RNull} if last.
*/
private Object cdr = RNull.instance;
/**
* Externally, i.e., when serialized, this is either a SYMSXP ({@link RSymbol}) or an
......@@ -336,9 +342,7 @@ public final class RPairList extends RSharingAttributeStorage implements RAbstra
int i = 0;
while (true) {
data[i] = Utils.toString(pl.tag);
if (pl.tag == RRuntime.STRING_NA) {
complete = false;
}
complete &= data[i] != RRuntime.STRING_NA;
if (isNull(pl.cdr)) {
break;
}
......@@ -353,7 +357,7 @@ public final class RPairList extends RSharingAttributeStorage implements RAbstra
Object p = this;
for (int i = 0; i < newNames.getLength() && !isNull(p); i++) {
RPairList pList = (RPairList) p;
pList.tag = newNames.getDataAt(i);
pList.tag = RDataFactory.createSymbol(newNames.getDataAt(i));
p = pList.cdr;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment