com.oracle.truffle.tck.ComplexHasSizeNodeSub Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-tck Show documentation
Show all versions of truffle-tck Show documentation
A collection of tests that can certify language implementation to be compliant
with most recent requirements of the Truffle infrastructure and tooling.
package com.oracle.truffle.tck;
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.tck.ComplexNumberMessageResolution.ComplexHasSizeNode}
* It is used by the foreign access factory {@link com.oracle.truffle.tck.ComplexNumberMessageResolutionForeign}
*/
abstract class ComplexHasSizeNodeSub extends com.oracle.truffle.tck.ComplexNumberMessageResolution.ComplexHasSizeNode {
public abstract Object executeWithTarget(VirtualFrame frame, Object o0);
@Specialization
protected Object accessWithTarget(com.oracle.truffle.tck.ComplexNumber complex) {
return access(complex);
}
private static final class HAS_SIZERootNode extends RootNode {
protected HAS_SIZERootNode(Class extends TruffleLanguage>> language) {
super(language, null, null);
}
@Child private ComplexHasSizeNodeSub node = com.oracle.truffle.tck.ComplexHasSizeNodeSubNodeGen.create();
@Override
public Object execute(VirtualFrame frame) {
Object receiver = ForeignAccess.getReceiver(frame);
try {
return node.executeWithTarget(frame, receiver);
} catch (UnsupportedSpecializationException e) {
if (e.getNode() instanceof ComplexHasSizeNodeSub) {
throw UnsupportedTypeException.raise(e, e.getSuppliedValues());
} else {
throw e;
}
}
}
}
public static RootNode createRoot(Class extends TruffleLanguage>> language) {
return new HAS_SIZERootNode(language);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy