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

com.oracle.truffle.tck.ComplexNumberAEntryMessageResolutionForeign 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.CallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.ForeignAccess;
import com.oracle.truffle.api.interop.ForeignAccess.Factory;
import com.oracle.truffle.api.interop.ForeignAccess.Factory26;
import com.oracle.truffle.api.interop.Message;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.nodes.RootNode;

/**
 * This foreign access factory is generated by {@link com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution}.
 * You are supposed to use it for the receiver object {@link com.oracle.truffle.tck.ComplexNumberAEntry}.
 */
final class ComplexNumberAEntryMessageResolutionForeign implements Factory26, Factory {
    public static final ForeignAccess ACCESS = ForeignAccess.create(new ComplexNumberAEntryMessageResolutionForeign(), null);
    @Deprecated public static ForeignAccess createAccess() { return ForeignAccess.create(new ComplexNumberAEntryMessageResolutionForeign(), null); }

    private ComplexNumberAEntryMessageResolutionForeign() { }

    @Override
    public boolean canHandle(TruffleObject obj) {
        return com.oracle.truffle.tck.ComplexNumberAEntry.isInstance(obj);
    }

    @Override
    public CallTarget accessIsNull() {
      return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false));
    }
    @Override
    public CallTarget accessIsExecutable() {
      return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false));
    }
    @Override
    public CallTarget accessIsBoxed() {
      return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false));
    }
    @Override
    public CallTarget accessHasSize() {
      return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false));
    }
    @Override
    public CallTarget accessGetSize() {
      return null;
    }
    @Override
    public CallTarget accessUnbox() {
      return null;
    }
    @Override
    public CallTarget accessRead() {
      return com.oracle.truffle.api.Truffle.getRuntime().createCallTarget(ComplexNumbersAEntryReadSubNode.createRoot());
    }
    @Override
    public CallTarget accessWrite() {
      return com.oracle.truffle.api.Truffle.getRuntime().createCallTarget(ComplexNumbersAEntryWriteSubNode.createRoot());
    }
    @Override
    public CallTarget accessExecute(int argumentsLength) {
      return null;
    }
    @Override
    public CallTarget accessInvoke(int argumentsLength) {
      return null;
    }
    @Override
    public CallTarget accessNew(int argumentsLength) {
      return null;
    }
    @Override
    public CallTarget accessKeyInfo() {
      return null;
    }
    @Override
    public CallTarget accessKeys() {
      return com.oracle.truffle.api.Truffle.getRuntime().createCallTarget(ComplexNumbersAEntryKeysSubNode.createRoot());
    }
    @Override
    public CallTarget accessIsPointer() {
      return Truffle.getRuntime().createCallTarget(RootNode.createConstantNode(false));
    }
    @Override
    public CallTarget accessAsPointer() {
      return null;
    }
    @Override
    public CallTarget accessToNative() {
      return null;
    }
    @Override
    public CallTarget accessMessage(Message unknown) {
      return null;
    }

    /**
     * This message resolution is generated by {@link com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution.ComplexNumbersAEntryWriteNode}.
     */
    abstract static class ComplexNumbersAEntryWriteSubNode extends com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution.ComplexNumbersAEntryWriteNode {
        public abstract Object executeWithTarget(VirtualFrame frame, Object o0, Object o1, Object o2);
        @Specialization
        protected Object accessWithTarget(com.oracle.truffle.tck.ComplexNumberAEntry complexNumber, java.lang.String name, java.lang.Number value) {
            return access(complexNumber, name, value);
        }
        private static final class WriteRootNode extends RootNode {
            protected WriteRootNode() {
                super(null);
            }

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

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

    /**
     * This message resolution is generated by {@link com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution.ComplexNumbersAEntryReadNode}.
     */
    abstract static class ComplexNumbersAEntryReadSubNode extends com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution.ComplexNumbersAEntryReadNode {
        public abstract Object executeWithTarget(VirtualFrame frame, Object o0, Object o1);
        @Specialization
        protected Object accessWithTarget(com.oracle.truffle.tck.ComplexNumberAEntry complexNumber, java.lang.String name) {
            return access(complexNumber, name);
        }
        private static final class READRootNode extends RootNode {
            protected READRootNode() {
                super(null);
            }

            @Child private ComplexNumbersAEntryReadSubNode node = com.oracle.truffle.tck.ComplexNumberAEntryMessageResolutionForeignFactory.ComplexNumbersAEntryReadSubNodeGen.create();
            @Override
            public Object execute(VirtualFrame frame) {
                Object receiver = ForeignAccess.getReceiver(frame);
                Object identifier = ForeignAccess.getArguments(frame).get(0);
                try {
                    return node.executeWithTarget(frame, receiver, identifier);
                } catch (UnsupportedSpecializationException e) {
                    if (e.getNode() instanceof ComplexNumbersAEntryReadSubNode) {
                      throw UnsupportedTypeException.raise(e, e.getSuppliedValues());
                    } else {
                      throw e;
                    }
                }
            }

        }
        public static RootNode createRoot() {
            return new READRootNode();
        }
    }

    /**
     * This message resolution is generated by {@link com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution.ComplexNumbersAEntryKeysNode}.
     */
    abstract static class ComplexNumbersAEntryKeysSubNode extends com.oracle.truffle.tck.ComplexNumberAEntryMessageResolution.ComplexNumbersAEntryKeysNode {
        public abstract Object executeWithTarget(VirtualFrame frame, Object o0);
        @Specialization
        protected Object accessWithTarget(com.oracle.truffle.tck.ComplexNumberAEntry complexNumber) {
            return access(complexNumber);
        }
        private static final class KeysRootNode extends RootNode {
            protected KeysRootNode() {
                super(null);
            }

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

        }
        public static RootNode createRoot() {
            return new KeysRootNode();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy