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

Added a hack for copying shared object in "slot<-" replacement form.

parent ccd9d4cb
Branches
No related tags found
No related merge requests found
......@@ -457,6 +457,11 @@ public final class RTruffleVisitor extends BasicVisitor<RSyntaxNode> {
String vSymbol = callArg.getVariable();
replacementArg = createReplacementForVariableUsing(callArg, vSymbol, replacement.isSuper());
RCallNode replacementCall = prepareReplacementCall(fAst, args, tmpSymbol, rhsSymbol, true);
// this is pretty gross, but at this point seems like the only way to get setClass to
// work properly
if (fAst.getLhs().toString().equals("slot<-")) {
replacementCall.replaceArgument(0, GetNonSharedNodeGen.create(replacementCall.getArgument(0).asRNode()));
}
assignFromTemp = WriteLocalFrameVariableNode.createAnonymous(vSymbol, replacementCall, WriteVariableNode.Mode.INVISIBLE, replacement.isSuper());
} else if (val instanceof AccessVector) {
AccessVector callArgAst = (AccessVector) val;
......
......@@ -282,6 +282,10 @@ public final class RCallNode extends RNode implements RSyntaxNode {
return arguments.v[index];
}
public void replaceArgument(int index, RSyntaxNode value) {
arguments.v[index] = value;
}
@Override
public Object execute(VirtualFrame frame) {
return execute(frame, executeFunctionNode(frame));
......
/*
* Copyright (c) 2016, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.r.runtime.RDeparse;
import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.RSerialize;
import com.oracle.truffle.r.runtime.data.RShareable;
import com.oracle.truffle.r.runtime.env.REnvironment;
import com.oracle.truffle.r.runtime.nodes.RNode;
import com.oracle.truffle.r.runtime.nodes.RSyntaxNode;
@NodeChild(value = "n", type = RNode.class)
public abstract class GetNonSharedNode extends RNode implements RSyntaxNode {
@Specialization
protected RShareable getNonShared(RShareable shareable) {
return shareable.getNonShared();
}
@Fallback
protected Object getNonShared(Object o) {
return o;
}
@Override
public void deparseImpl(RDeparse.State state) {
throw RInternalError.unimplemented("deparseImpl");
}
@Override
public RSyntaxNode substituteImpl(REnvironment env) {
throw RInternalError.unimplemented("substituteImpl");
}
@Override
public void serializeImpl(RSerialize.State state) {
throw RInternalError.unimplemented("serializeImpl");
}
public int getRlengthImpl() {
throw RInternalError.unimplemented();
}
@Override
public Object getRelementImpl(int index) {
throw RInternalError.unimplemented();
}
@Override
public boolean getRequalsImpl(RSyntaxNode other) {
throw RInternalError.unimplemented();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment