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

com.oracle.truffle.api.interop.java.WriteFieldNodeSub Maven / Gradle / Ivy

Go to download

Truffle is a multi-language framework for executing dynamic languages that achieves high performance when combined with Graal.

There is a newer version: 1.0.0-rc7
Show newest version
package com.oracle.truffle.api.interop.java;
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 WriteFieldNodeSub extends com.oracle.truffle.api.interop.java.JavaObjectMessageResolution.WriteFieldNode {
    public abstract Object executeWithTarget(VirtualFrame frame, Object o0, Object o1, Object o2);
    @Specialization
    protected Object accessWithTarget(com.oracle.truffle.api.frame.VirtualFrame frame, com.oracle.truffle.api.interop.java.JavaObject receiver, java.lang.String name, java.lang.Object value) {
        return access(frame, receiver, name, value);
    }
    @Specialization
    protected Object accessWithTarget(com.oracle.truffle.api.interop.java.JavaObject receiver, int index, java.lang.Object value) {
        return access(receiver, index, value);
    }
    private final static class WriteRootNode extends RootNode {
        protected WriteRootNode(Class> language) {
            super(language, null, null);
        }

        @Child private WriteFieldNodeSub node = com.oracle.truffle.api.interop.java.WriteFieldNodeSubNodeGen.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) {
                throw UnsupportedTypeException.raise(e.getSuppliedValues());
            }
        }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy