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

Access to attributes itereator must be guarded.

parent e7dceb89
Branches
No related tags found
No related merge requests found
......@@ -110,11 +110,13 @@ public abstract class UnClass extends RBuiltinNode {
objectProfile.enter();
// TODO: should we make S4 objects shareable?
RS4Object resultS4 = RDataFactory.createS4Object();
RAttributes newAttributes = resultS4.initAttributes();
for (RAttribute attr : arg.getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
if (arg.getAttributes() != null) {
RAttributes newAttributes = resultS4.initAttributes();
for (RAttribute attr : arg.getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
}
newAttributes.remove(RRuntime.CLASS_ATTR_KEY);
}
newAttributes.remove(RRuntime.CLASS_ATTR_KEY);
return resultS4;
}
return arg;
......
......@@ -51,9 +51,11 @@ public abstract class DuplicateNode extends RBaseNode {
@Specialization
protected Object duplicate(RS4Object object) {
RS4Object newObject = RDataFactory.createS4Object();
RAttributes newAttributes = newObject.initAttributes();
for (RAttribute attr : object.getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
if (object.getAttributes() != null) {
RAttributes newAttributes = newObject.initAttributes();
for (RAttribute attr : object.getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
}
}
return newObject;
}
......
......@@ -131,11 +131,13 @@ public final class RFunction extends RSharingAttributeStorage implements RTypedV
@Override
public RShareable copy() {
RFunction newFunction = RDataFactory.createFunction(getName(), getTarget(), getRBuiltin(), getEnclosingFrame(), getFastPath(), containsDispatch());
RAttributes newAttributes = newFunction.initAttributes();
for (RAttribute attr : getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
if (getAttributes() != null) {
RAttributes newAttributes = newFunction.initAttributes();
for (RAttribute attr : getAttributes()) {
newAttributes.put(attr.getName(), attr.getValue());
}
newFunction.initAttributes(newAttributes);
}
newFunction.initAttributes(newAttributes);
return newFunction;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment