org.jruby.truffle.cext.CharPointerWriteNodeSub Maven / Gradle / Ivy
The newest version!
package org.jruby.truffle.cext;
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 org.jruby.truffle.cext.StringCharPointerMessageResolution.CharPointerWriteNode}
* It is used by the foreign access factory {@link org.jruby.truffle.cext.StringCharPointerMessageResolutionForeign}
*/
public abstract class CharPointerWriteNodeSub extends org.jruby.truffle.cext.StringCharPointerMessageResolution.CharPointerWriteNode {
public abstract Object executeWithTarget(VirtualFrame frame, Object o0, Object o1, Object o2);
@Specialization
protected Object accessWithTarget(org.jruby.truffle.cext.StringCharPointerAdapter stringCharPointerAdapter, int index, java.lang.Object value) {
return access(stringCharPointerAdapter, index, value);
}
private static final class WriteRootNode extends RootNode {
protected WriteRootNode(Class extends TruffleLanguage>> language) {
super(language, null, null);
}
@Child private CharPointerWriteNodeSub node = org.jruby.truffle.cext.CharPointerWriteNodeSubNodeGen.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 CharPointerWriteNodeSub) {
throw UnsupportedTypeException.raise(e, e.getSuppliedValues());
} else {
throw e;
}
}
}
}
public static RootNode createRoot(Class extends TruffleLanguage>> language) {
return new WriteRootNode(language);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy