Skip to content
Snippets Groups Projects
Commit fd9e9e3f authored by Adam Welc's avatar Adam Welc
Browse files

Attribute objects cannot be shared.

parent a09458a6
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.runtime.*;
import com.oracle.truffle.r.runtime.data.*;
import com.oracle.truffle.r.runtime.data.RAttributes.RAttribute;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
import static com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
......@@ -109,8 +110,11 @@ public abstract class UnClass extends RBuiltinNode {
objectProfile.enter();
// TODO: should we make S4 objects shareable?
RS4Object resultS4 = RDataFactory.createS4Object();
resultS4.initAttributes(arg.getAttributes());
resultS4.removeAttr(attrProfiles, RRuntime.CLASS_ATTR_KEY);
RAttributes newAttributes = resultS4.initAttributes();
for (RAttribute attr : arg.getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
}
newAttributes.remove(RRuntime.CLASS_ATTR_KEY);
return resultS4;
}
return arg;
......
......@@ -24,9 +24,11 @@ package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.r.runtime.*;
import com.oracle.truffle.r.runtime.data.RAttributes;
import com.oracle.truffle.r.runtime.data.RDataFactory;
import com.oracle.truffle.r.runtime.data.RFunction;
import com.oracle.truffle.r.runtime.data.RS4Object;
import com.oracle.truffle.r.runtime.data.RAttributes.RAttribute;
import com.oracle.truffle.r.runtime.data.model.*;
import com.oracle.truffle.r.runtime.nodes.RBaseNode;
......@@ -49,7 +51,10 @@ public abstract class DuplicateNode extends RBaseNode {
@Specialization
protected Object duplicate(RS4Object object) {
RS4Object newObject = RDataFactory.createS4Object();
newObject.initAttributes(object.getAttributes());
RAttributes newAttributes = newObject.initAttributes();
for (RAttribute attr : object.getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
}
return newObject;
}
......
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