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

com.oracle.truffle.sl.builtins.SLPrintlnBuiltinFactory Maven / Gradle / Ivy

There is a newer version: 24.1.1
Show newest version
// CheckStyle: start generated
package com.oracle.truffle.sl.builtins;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.InteropLibrary;
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.sl.SLLanguage;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import com.oracle.truffle.sl.runtime.SLContext;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.Lock;

@GeneratedBy(SLPrintlnBuiltin.class)
public final class SLPrintlnBuiltinFactory implements NodeFactory {

    private static final SLPrintlnBuiltinFactory INSTANCE = new SLPrintlnBuiltinFactory();
    private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class);

    private SLPrintlnBuiltinFactory() {
    }

    @Override
    public Class getNodeClass() {
        return SLPrintlnBuiltin.class;
    }

    @Override
    public List> getExecutionSignature() {
        return Arrays.asList(SLExpressionNode.class);
    }

    @Override
    public List>> getNodeSignatures() {
        return Arrays.asList(Arrays.asList(SLExpressionNode[].class));
    }

    @Override
    public SLPrintlnBuiltin createNode(Object... arguments) {
        if (arguments.length == 1 && (arguments[0] == null || arguments[0] instanceof SLExpressionNode[])) {
            return create((SLExpressionNode[]) arguments[0]);
        } else {
            throw new IllegalArgumentException("Invalid create signature.");
        }
    }

    public static NodeFactory getInstance() {
        return INSTANCE;
    }

    public static SLPrintlnBuiltin create(SLExpressionNode[] arguments) {
        return new SLPrintlnBuiltinNodeGen(arguments);
    }

    @GeneratedBy(SLPrintlnBuiltin.class)
    public static final class SLPrintlnBuiltinNodeGen extends SLPrintlnBuiltin {

        @Child private SLExpressionNode arguments0_;
        @CompilationFinal private volatile int state_;
        @CompilationFinal private ContextReference sLLanguageContextReference_;
        @Child private InteropLibrary interop_;

        private SLPrintlnBuiltinNodeGen(SLExpressionNode[] arguments) {
            this.arguments0_ = arguments != null && 0 < arguments.length ? arguments[0] : null;
        }

        @Override
        protected Object execute(VirtualFrame frameValue) {
            int state = state_;
            Object arguments0Value_ = this.arguments0_.executeGeneric(frameValue);
            if (state != 0 /* is-active println(Object, InteropLibrary, SLContext) */) {
                {
                    ContextReference sLLanguageContextReference__ = this.sLLanguageContextReference_;
                    SLContext context__ = sLLanguageContextReference__.get();
                    return println(arguments0Value_, this.interop_, context__);
                }
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            return executeAndSpecialize(arguments0Value_);
        }

        private Object executeAndSpecialize(Object arguments0Value) {
            Lock lock = getLock();
            boolean hasLock = true;
            lock.lock();
            int state = state_;
            try {
                {
                    SLContext context__ = null;
                    this.interop_ = super.insert((INTEROP_LIBRARY_.createDispatched(3)));
                    ContextReference sLLanguageContextReference__1 = this.sLLanguageContextReference_;
                    if (sLLanguageContextReference__1 == null) {
                        this.sLLanguageContextReference_ = sLLanguageContextReference__1 = super.lookupContextReference(SLLanguage.class);
                    }
                    context__ = sLLanguageContextReference__1.get();
                    this.state_ = state = state | 0b1 /* add-active println(Object, InteropLibrary, SLContext) */;
                    lock.unlock();
                    hasLock = false;
                    return println(arguments0Value, this.interop_, context__);
                }
            } finally {
                if (hasLock) {
                    lock.unlock();
                }
            }
        }

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

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy