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

com.oracle.truffle.regex.ValidateMethodGen Maven / Gradle / Ivy

// CheckStyle: start generated
package com.oracle.truffle.regex;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.interop.ArityException;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.library.DynamicDispatchLibrary;
import com.oracle.truffle.api.library.LibraryExport;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.regex.RegexEngine.ValidateMethod;
import com.oracle.truffle.regex.runtime.nodes.ToStringNode;
import com.oracle.truffle.regex.runtime.nodes.ToStringNodeGen;
import java.util.concurrent.locks.Lock;

@GeneratedBy(ValidateMethod.class)
final class ValidateMethodGen {

    private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);

    static  {
        LibraryExport.register(ValidateMethod.class, new InteropLibraryExports());
    }

    private ValidateMethodGen() {
    }

    @GeneratedBy(ValidateMethod.class)
    private static final class InteropLibraryExports extends LibraryExport {

        private InteropLibraryExports() {
            super(InteropLibrary.class, ValidateMethod.class, false);
        }

        @Override
        protected InteropLibrary createUncached(Object receiver) {
            assert receiver instanceof ValidateMethod;
            InteropLibrary uncached = new Uncached();
            return uncached;
        }

        @Override
        protected InteropLibrary createCached(Object receiver) {
            assert receiver instanceof ValidateMethod;
            return new Cached();
        }

        @GeneratedBy(ValidateMethod.class)
        private static final class Cached extends InteropLibrary {

            @CompilationFinal private volatile int state_;
            @Child private ExecuteData execute_cache;

            Cached() {
            }

            @Override
            public boolean accepts(Object receiver) {
                assert !(receiver instanceof ValidateMethod) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
                return receiver instanceof ValidateMethod;
            }

            @Override
            public boolean hasLanguage(Object receiver) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((ValidateMethod) receiver)).hasLanguage();
            }

            @Override
            public Class> getLanguage(Object receiver) throws UnsupportedMessageException {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((ValidateMethod) receiver)).getLanguage();
            }

            @Override
            public Object toDisplayString(Object receiver, boolean allowSideEffects) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((ValidateMethod) receiver)).toDisplayString(allowSideEffects);
            }

            @Override
            public boolean isExecutable(Object receiver) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((ValidateMethod) receiver)).isExecutable();
            }

            @Override
            public Object execute(Object arg0Value_, Object... arg1Value) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                ValidateMethod arg0Value = ((ValidateMethod) arg0Value_);
                int state = state_;
                if (state != 0 /* is-active execute(ValidateMethod, Object[], ToStringNode, ToStringNode, ToStringNode) */) {
                    ExecuteData s1_ = this.execute_cache;
                    if (s1_ != null) {
                        return arg0Value.execute(arg1Value, s1_.patternToStringNode_, s1_.flagsToStringNode_, s1_.encodingToStringNode_);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value);
            }

            private Object executeAndSpecialize(ValidateMethod arg0Value, Object[] arg1Value) throws ArityException, UnsupportedTypeException {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                try {
                    ExecuteData s1_ = super.insert(new ExecuteData());
                    s1_.patternToStringNode_ = s1_.insertAccessor((ToStringNode.create()));
                    s1_.flagsToStringNode_ = s1_.insertAccessor((ToStringNode.create()));
                    s1_.encodingToStringNode_ = s1_.insertAccessor((ToStringNode.create()));
                    this.execute_cache = s1_;
                    this.state_ = state = state | 0b1 /* add-active execute(ValidateMethod, Object[], ToStringNode, ToStringNode, ToStringNode) */;
                    lock.unlock();
                    hasLock = false;
                    return arg0Value.execute(arg1Value, s1_.patternToStringNode_, s1_.flagsToStringNode_, s1_.encodingToStringNode_);
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else {
                    return NodeCost.MONOMORPHIC;
                }
            }

            @GeneratedBy(ValidateMethod.class)
            private static final class ExecuteData extends Node {

                @Child ToStringNode patternToStringNode_;
                @Child ToStringNode flagsToStringNode_;
                @Child ToStringNode encodingToStringNode_;

                ExecuteData() {
                }

                @Override
                public NodeCost getCost() {
                    return NodeCost.NONE;
                }

                 T insertAccessor(T node) {
                    return super.insert(node);
                }

            }
        }
        @GeneratedBy(ValidateMethod.class)
        private static final class Uncached extends InteropLibrary {

            Uncached() {
            }

            @TruffleBoundary
            @Override
            public boolean accepts(Object receiver) {
                assert !(receiver instanceof ValidateMethod) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
                return receiver instanceof ValidateMethod;
            }

            @Override
            public boolean isAdoptable() {
                return false;
            }

            @Override
            public NodeCost getCost() {
                return NodeCost.MEGAMORPHIC;
            }

            @TruffleBoundary
            @Override
            public boolean hasLanguage(Object receiver) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((AbstractRegexObject) receiver) .hasLanguage();
            }

            @TruffleBoundary
            @Override
            public Class> getLanguage(Object receiver) throws UnsupportedMessageException {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((AbstractRegexObject) receiver) .getLanguage();
            }

            @TruffleBoundary
            @Override
            public Object toDisplayString(Object receiver, boolean allowSideEffects) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((AbstractRegexObject) receiver) .toDisplayString(allowSideEffects);
            }

            @TruffleBoundary
            @Override
            public boolean isExecutable(Object receiver) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((ValidateMethod) receiver) .isExecutable();
            }

            @TruffleBoundary
            @Override
            public Object execute(Object arg0Value_, Object... arg1Value) throws ArityException, UnsupportedTypeException {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                ValidateMethod arg0Value = ((ValidateMethod) arg0Value_);
                return arg0Value.execute(arg1Value, (ToStringNodeGen.getUncached()), (ToStringNodeGen.getUncached()), (ToStringNodeGen.getUncached()));
            }

        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy