All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.truffle.tck.ComplexWriteNodeSub Maven / Gradle / Ivy

Go to download

A collection of tests that can certify language implementation to be compliant with most recent requirements of the Truffle infrastructure and tooling.

There is a newer version: 1.0.0-rc7
Show newest version
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.ComplexWriteNode}
 * It is used by the foreign access factory {@link com.oracle.truffle.tck.ComplexNumberMessageResolutionForeign}
 */
abstract class ComplexWriteNodeSub extends com.oracle.truffle.tck.ComplexNumberMessageResolution.ComplexWriteNode {
    public abstract Object executeWithTarget(VirtualFrame frame, Object o0, Object o1, Object o2);
    @Specialization
    protected Object accessWithTarget(com.oracle.truffle.tck.ComplexNumber complex, java.lang.String identifier, java.lang.Number value) {
        return access(complex, identifier, value);
    }
    @Specialization
    protected Object accessWithTarget(com.oracle.truffle.tck.ComplexNumber complex, int index, java.lang.Number value) {
        return access(complex, index, value);
    }
    private static final class WriteRootNode extends RootNode {
        protected WriteRootNode(Class> language) {
            super(language, null, null);
        }

        @Child private ComplexWriteNodeSub node = com.oracle.truffle.tck.ComplexWriteNodeSubNodeGen.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 ComplexWriteNodeSub) {
                  throw UnsupportedTypeException.raise(e, e.getSuppliedValues());
                } else {
                  throw e;
                }
            }
        }

    }
    public static RootNode createRoot(Class> language) {
        return new WriteRootNode(language);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy