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

org.jruby.truffle.language.methods.AddMethodNodeGen Maven / Gradle / Ivy

The newest version!
// CheckStyle: start generated
package org.jruby.truffle.language.methods;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.Visibility;

@GeneratedBy(AddMethodNode.class)
public final class AddMethodNodeGen extends AddMethodNode {

    @Child private RubyNode moduleNode_;
    @Child private RubyNode methodNode_;
    @Child private RubyNode visibilityNode_;
    @CompilationFinal private boolean seenUnsupported0;

    private AddMethodNodeGen(boolean ignoreNameVisibility, boolean isLiteralDef, RubyNode moduleNode, RubyNode methodNode, RubyNode visibilityNode) {
        super(ignoreNameVisibility, isLiteralDef);
        this.moduleNode_ = moduleNode;
        this.methodNode_ = methodNode;
        this.visibilityNode_ = visibilityNode;
    }

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

    @Override
    public DynamicObject executeAddMethod(DynamicObject moduleNodeValue, InternalMethod methodNodeValue, Visibility visibilityNodeValue) {
        if ((RubyGuards.isRubyModule(moduleNodeValue))) {
            return this.addMethod(moduleNodeValue, methodNodeValue, visibilityNodeValue);
        }
        throw unsupported(moduleNodeValue, methodNodeValue, visibilityNodeValue);
    }

    @Override
    public Object execute(VirtualFrame frameValue) {
        DynamicObject moduleNodeValue_;
        try {
            moduleNodeValue_ = moduleNode_.executeDynamicObject(frameValue);
        } catch (UnexpectedResultException ex) {
            Object methodNodeValue = methodNode_.execute(frameValue);
            Object visibilityNodeValue = visibilityNode_.execute(frameValue);
            throw unsupported(ex.getResult(), methodNodeValue, visibilityNodeValue);
        }
        InternalMethod methodNodeValue_;
        try {
            methodNodeValue_ = expectInternalMethod(methodNode_.execute(frameValue));
        } catch (UnexpectedResultException ex) {
            Object visibilityNodeValue = visibilityNode_.execute(frameValue);
            throw unsupported(moduleNodeValue_, ex.getResult(), visibilityNodeValue);
        }
        Visibility visibilityNodeValue_;
        try {
            visibilityNodeValue_ = expectVisibility(visibilityNode_.execute(frameValue));
        } catch (UnexpectedResultException ex) {
            throw unsupported(moduleNodeValue_, methodNodeValue_, ex.getResult());
        }
        if ((RubyGuards.isRubyModule(moduleNodeValue_))) {
            return this.addMethod(moduleNodeValue_, methodNodeValue_, visibilityNodeValue_);
        }
        throw unsupported(moduleNodeValue_, methodNodeValue_, visibilityNodeValue_);
    }

    @Override
    public void executeVoid(VirtualFrame frameValue) {
        execute(frameValue);
        return;
    }

    private UnsupportedSpecializationException unsupported(Object moduleNodeValue, Object methodNodeValue, Object visibilityNodeValue) {
        if (!seenUnsupported0) {
            CompilerDirectives.transferToInterpreterAndInvalidate();
            seenUnsupported0 = true;
        }
        return new UnsupportedSpecializationException(this, new Node[] {moduleNode_, methodNode_, visibilityNode_}, moduleNodeValue, methodNodeValue, visibilityNodeValue);
    }

    private static InternalMethod expectInternalMethod(Object value) throws UnexpectedResultException {
        if (value instanceof InternalMethod) {
            return (InternalMethod) value;
        }
        throw new UnexpectedResultException(value);
    }

    private static Visibility expectVisibility(Object value) throws UnexpectedResultException {
        if (value instanceof Visibility) {
            return (Visibility) value;
        }
        throw new UnexpectedResultException(value);
    }

    public static AddMethodNode create(boolean ignoreNameVisibility, boolean isLiteralDef, RubyNode moduleNode, RubyNode methodNode, RubyNode visibilityNode) {
        return new AddMethodNodeGen(ignoreNameVisibility, isLiteralDef, moduleNode, methodNode, visibilityNode);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy