com.oracle.truffle.api.metadata.VarsMapWriteNodeSub Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-api Show documentation
Show all versions of truffle-api Show documentation
Truffle is a multi-language framework for executing dynamic languages
that achieves high performance when combined with Graal.
package com.oracle.truffle.api.metadata;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.interop.ForeignAccess;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
/**
* This message resolution is generated by {@link com.oracle.truffle.api.metadata.DefaultScopeVariables.VariablesMapObject.VariablesMapMessageResolution.VarsMapWriteNode}
* It is used by the foreign access factory {@link com.oracle.truffle.api.metadata.VariablesMapMessageResolutionForeign}
*/
abstract class VarsMapWriteNodeSub extends com.oracle.truffle.api.metadata.DefaultScopeVariables.VariablesMapObject.VariablesMapMessageResolution.VarsMapWriteNode {
public abstract Object executeWithTarget(VirtualFrame frame, Object o0, Object o1, Object o2);
@Specialization
protected Object accessWithTarget(com.oracle.truffle.api.metadata.DefaultScopeVariables.VariablesMapObject varMap, java.lang.String name, java.lang.Object value) {
return access(varMap, name, value);
}
private static final class WriteRootNode extends RootNode {
protected WriteRootNode() {
super(null);
}
@Child private VarsMapWriteNodeSub node = com.oracle.truffle.api.metadata.VarsMapWriteNodeSubNodeGen.create();
@Override
public Object execute(VirtualFrame frame) {
Object receiver = ForeignAccess.getReceiver(frame);
Object identifier = ForeignAccess.getArguments(frame).get(0);
Object value = ForeignAccess.getArguments(frame).get(1);
try {
return node.executeWithTarget(frame, receiver, identifier, value);
} catch (UnsupportedSpecializationException e) {
if (e.getNode() instanceof VarsMapWriteNodeSub) {
throw UnsupportedTypeException.raise(e, e.getSuppliedValues());
} else {
throw e;
}
}
}
}
@Deprecated
@SuppressWarnings("unused")
public static RootNode createRoot(Class extends TruffleLanguage>> language) {
return createRoot();
}
public static RootNode createRoot() {
return new WriteRootNode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy