
com.oracle.truffle.sl.runtime.CheckNullSub Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-sl Show documentation
Show all versions of truffle-sl Show documentation
Truffle SL is an example language implemented using the Truffle API.
package com.oracle.truffle.sl.runtime;
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;
abstract class CheckNullSub extends com.oracle.truffle.sl.runtime.SLNullMessageResolution.CheckNull {
public abstract Object executeWithTarget(VirtualFrame frame, Object o);
@Specialization
protected Object testWithTarget(com.oracle.truffle.api.interop.TruffleObject receiver) {
return test(receiver);
}
private final static class LanguageCheckRootNode extends RootNode {
protected LanguageCheckRootNode(Class extends TruffleLanguage>> language) {
super(language, null, null);
}
@Child private CheckNullSub node = com.oracle.truffle.sl.runtime.CheckNullSubNodeGen.create();
@Override
public Object execute(VirtualFrame frame) {
try {
Object receiver = ForeignAccess.getReceiver(frame);
return node.executeWithTarget(frame, receiver);
} catch (UnsupportedSpecializationException e) {
throw UnsupportedTypeException.raise(e.getSuppliedValues());
}
}
}
public static RootNode createRoot(Class extends TruffleLanguage>> language) {
return new LanguageCheckRootNode(language);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy