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

com.oracle.truffle.tck.MaxMinObjectFactory 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.

The newest version!
/*
 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
// CheckStyle: start generated
package com.oracle.truffle.tck;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.internal.SpecializationNode;
import com.oracle.truffle.api.dsl.internal.SpecializedNode;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.tck.MaxMinObject.MaxMinNode;
import com.oracle.truffle.tck.MaxMinObject.ReadArgNode;
import com.oracle.truffle.tck.MaxMinObject.UnboxNode;

@GeneratedBy(MaxMinObject.class)
final class MaxMinObjectFactory {

    @GeneratedBy(UnboxNode.class)
    static final class UnboxNodeGen extends UnboxNode implements SpecializedNode {

        @Child private ReadArgNode valueNode_;
        @Child private BaseNode_ specialization_;

        private UnboxNodeGen(ReadArgNode valueNode) {
            this.valueNode_ = valueNode;
            this.specialization_ = UninitializedNode_.create(this);
        }

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

        @Override
        public Object executeUnbox(VirtualFrame frameValue) {
            return specialization_.execute(frameValue);
        }

        @Override
        public SpecializationNode getSpecializationNode() {
            return specialization_;
        }

        @Override
        public Node deepCopy() {
            return SpecializationNode.updateRoot(super.deepCopy());
        }

        public static UnboxNode create(ReadArgNode valueNode) {
            return new UnboxNodeGen(valueNode);
        }

        @GeneratedBy(UnboxNode.class)
        private abstract static class BaseNode_ extends SpecializationNode {

            protected final UnboxNodeGen root;

            BaseNode_(UnboxNodeGen root, int index) {
                super(index);
                this.root = root;
            }

            @Override
            protected final Node[] getSuppliedChildren() {
                return new Node[] {root.valueNode_};
            }

            @Override
            public final Object acceptAndExecute(Frame frameValue, Object valueNodeValue) {
                return this.execute_((VirtualFrame) frameValue, valueNodeValue);
            }

            public abstract Object execute_(VirtualFrame frameValue, Object valueNodeValue);

            public Object execute(VirtualFrame frameValue) {
                Object valueNodeValue_ = root.valueNode_.execute(frameValue);
                return execute_(frameValue, valueNodeValue_);
            }

            @Override
            protected final SpecializationNode createNext(Frame frameValue, Object valueNodeValue) {
                if (valueNodeValue instanceof Integer) {
                    CompilerDirectives.transferToInterpreterAndInvalidate();
                    return ExecuteUnbox0Node_.create(root);
                }
                if (valueNodeValue instanceof Long) {
                    CompilerDirectives.transferToInterpreterAndInvalidate();
                    return ExecuteUnbox1Node_.create(root);
                }
                if (valueNodeValue instanceof String) {
                    CompilerDirectives.transferToInterpreterAndInvalidate();
                    return ExecuteUnbox2Node_.create(root);
                }
                if (valueNodeValue instanceof TruffleObject) {
                    TruffleObject valueNodeValue_ = (TruffleObject) valueNodeValue;
                    if ((root.isBoxedPrimitive((VirtualFrame) frameValue, valueNodeValue_))) {
                        CompilerDirectives.transferToInterpreterAndInvalidate();
                        return ExecuteUnbox3Node_.create(root);
                    }
                }
                return null;
            }

            @Override
            protected final SpecializationNode createPolymorphic() {
                return PolymorphicNode_.create(root);
            }

            protected final BaseNode_ getNext() {
                return (BaseNode_) this.next;
            }

        }
        @GeneratedBy(UnboxNode.class)
        private static final class UninitializedNode_ extends BaseNode_ {

            UninitializedNode_(UnboxNodeGen root) {
                super(root, 2147483647);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
                return uninitialized(frameValue, valueNodeValue);
            }

            static BaseNode_ create(UnboxNodeGen root) {
                return new UninitializedNode_(root);
            }

        }
        @GeneratedBy(UnboxNode.class)
        private static final class PolymorphicNode_ extends BaseNode_ {

            PolymorphicNode_(UnboxNodeGen root) {
                super(root, 0);
            }

            @Override
            public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object valueNodeValue) {
                return polymorphicMerge(newNode, super.merge(newNode, frameValue, valueNodeValue));
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
                return getNext().execute_(frameValue, valueNodeValue);
            }

            static BaseNode_ create(UnboxNodeGen root) {
                return new PolymorphicNode_(root);
            }

        }
        @GeneratedBy(methodName = "executeUnbox(int)", value = UnboxNode.class)
        private static final class ExecuteUnbox0Node_ extends BaseNode_ {

            ExecuteUnbox0Node_(UnboxNodeGen root) {
                super(root, 1);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
                if (valueNodeValue instanceof Integer) {
                    int valueNodeValue_ = (int) valueNodeValue;
                    return root.executeUnbox(valueNodeValue_);
                }
                return getNext().execute_(frameValue, valueNodeValue);
            }

            static BaseNode_ create(UnboxNodeGen root) {
                return new ExecuteUnbox0Node_(root);
            }

        }
        @GeneratedBy(methodName = "executeUnbox(long)", value = UnboxNode.class)
        private static final class ExecuteUnbox1Node_ extends BaseNode_ {

            ExecuteUnbox1Node_(UnboxNodeGen root) {
                super(root, 2);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
                if (valueNodeValue instanceof Long) {
                    long valueNodeValue_ = (long) valueNodeValue;
                    return root.executeUnbox(valueNodeValue_);
                }
                return getNext().execute_(frameValue, valueNodeValue);
            }

            static BaseNode_ create(UnboxNodeGen root) {
                return new ExecuteUnbox1Node_(root);
            }

        }
        @GeneratedBy(methodName = "executeUnbox(String)", value = UnboxNode.class)
        private static final class ExecuteUnbox2Node_ extends BaseNode_ {

            ExecuteUnbox2Node_(UnboxNodeGen root) {
                super(root, 3);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
                if (valueNodeValue instanceof String) {
                    String valueNodeValue_ = (String) valueNodeValue;
                    return root.executeUnbox(valueNodeValue_);
                }
                return getNext().execute_(frameValue, valueNodeValue);
            }

            static BaseNode_ create(UnboxNodeGen root) {
                return new ExecuteUnbox2Node_(root);
            }

        }
        @GeneratedBy(methodName = "executeUnbox(VirtualFrame, TruffleObject)", value = UnboxNode.class)
        private static final class ExecuteUnbox3Node_ extends BaseNode_ {

            ExecuteUnbox3Node_(UnboxNodeGen root) {
                super(root, 4);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
                if (valueNodeValue instanceof TruffleObject) {
                    TruffleObject valueNodeValue_ = (TruffleObject) valueNodeValue;
                    if ((root.isBoxedPrimitive(frameValue, valueNodeValue_))) {
                        return root.executeUnbox(frameValue, valueNodeValue_);
                    }
                }
                return getNext().execute_(frameValue, valueNodeValue);
            }

            static BaseNode_ create(UnboxNodeGen root) {
                return new ExecuteUnbox3Node_(root);
            }

        }
    }
    @GeneratedBy(MaxMinNode.class)
    static final class MaxMinNodeGen extends MaxMinNode implements SpecializedNode {

        @Child private UnboxNode firstNode_;
        @Child private UnboxNode secondNode_;
        @Child private BaseNode_ specialization_;

        private MaxMinNodeGen(boolean max, UnboxNode firstNode, UnboxNode secondNode) {
            super(max);
            this.firstNode_ = firstNode;
            this.secondNode_ = secondNode;
            this.specialization_ = UninitializedNode_.create(this);
        }

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

        @Override
        public Object execute(VirtualFrame frameValue) {
            return specialization_.execute(frameValue);
        }

        @Override
        public SpecializationNode getSpecializationNode() {
            return specialization_;
        }

        @Override
        public Node deepCopy() {
            return SpecializationNode.updateRoot(super.deepCopy());
        }

        public static MaxMinNode create(boolean max, UnboxNode firstNode, UnboxNode secondNode) {
            return new MaxMinNodeGen(max, firstNode, secondNode);
        }

        @GeneratedBy(MaxMinNode.class)
        private abstract static class BaseNode_ extends SpecializationNode {

            protected final MaxMinNodeGen root;

            BaseNode_(MaxMinNodeGen root, int index) {
                super(index);
                this.root = root;
            }

            @Override
            protected final Node[] getSuppliedChildren() {
                return new Node[] {root.firstNode_, root.secondNode_};
            }

            @Override
            public final Object acceptAndExecute(Frame frameValue, Object firstNodeValue, Object secondNodeValue) {
                return this.execute_((VirtualFrame) frameValue, firstNodeValue, secondNodeValue);
            }

            public abstract Object execute_(VirtualFrame frameValue, Object firstNodeValue, Object secondNodeValue);

            public Object execute(VirtualFrame frameValue) {
                Object firstNodeValue_ = root.firstNode_.executeUnbox(frameValue);
                Object secondNodeValue_ = root.secondNode_.executeUnbox(frameValue);
                return execute_(frameValue, firstNodeValue_, secondNodeValue_);
            }

            @Override
            protected final SpecializationNode createNext(Frame frameValue, Object firstNodeValue, Object secondNodeValue) {
                if (firstNodeValue instanceof Integer && secondNodeValue instanceof Integer) {
                    return Execute0Node_.create(root);
                }
                if (firstNodeValue instanceof Long && secondNodeValue instanceof Long) {
                    return Execute1Node_.create(root);
                }
                if (firstNodeValue instanceof Double && secondNodeValue instanceof Double) {
                    return Execute2Node_.create(root);
                }
                return null;
            }

            @Override
            protected final SpecializationNode createPolymorphic() {
                return PolymorphicNode_.create(root);
            }

            protected final BaseNode_ getNext() {
                return (BaseNode_) this.next;
            }

        }
        @GeneratedBy(MaxMinNode.class)
        private static final class UninitializedNode_ extends BaseNode_ {

            UninitializedNode_(MaxMinNodeGen root) {
                super(root, 2147483647);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object firstNodeValue, Object secondNodeValue) {
                return uninitialized(frameValue, firstNodeValue, secondNodeValue);
            }

            static BaseNode_ create(MaxMinNodeGen root) {
                return new UninitializedNode_(root);
            }

        }
        @GeneratedBy(MaxMinNode.class)
        private static final class PolymorphicNode_ extends BaseNode_ {

            PolymorphicNode_(MaxMinNodeGen root) {
                super(root, 0);
            }

            @Override
            public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object firstNodeValue, Object secondNodeValue) {
                return polymorphicMerge(newNode, super.merge(newNode, frameValue, firstNodeValue, secondNodeValue));
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object firstNodeValue, Object secondNodeValue) {
                return getNext().execute_(frameValue, firstNodeValue, secondNodeValue);
            }

            static BaseNode_ create(MaxMinNodeGen root) {
                return new PolymorphicNode_(root);
            }

        }
        @GeneratedBy(methodName = "execute(int, int)", value = MaxMinNode.class)
        private static final class Execute0Node_ extends BaseNode_ {

            Execute0Node_(MaxMinNodeGen root) {
                super(root, 1);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object firstNodeValue, Object secondNodeValue) {
                if (firstNodeValue instanceof Integer && secondNodeValue instanceof Integer) {
                    int firstNodeValue_ = (int) firstNodeValue;
                    int secondNodeValue_ = (int) secondNodeValue;
                    return root.execute(firstNodeValue_, secondNodeValue_);
                }
                return getNext().execute_(frameValue, firstNodeValue, secondNodeValue);
            }

            static BaseNode_ create(MaxMinNodeGen root) {
                return new Execute0Node_(root);
            }

        }
        @GeneratedBy(methodName = "execute(long, long)", value = MaxMinNode.class)
        private static final class Execute1Node_ extends BaseNode_ {

            Execute1Node_(MaxMinNodeGen root) {
                super(root, 2);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object firstNodeValue, Object secondNodeValue) {
                if (firstNodeValue instanceof Long && secondNodeValue instanceof Long) {
                    long firstNodeValue_ = (long) firstNodeValue;
                    long secondNodeValue_ = (long) secondNodeValue;
                    return root.execute(firstNodeValue_, secondNodeValue_);
                }
                return getNext().execute_(frameValue, firstNodeValue, secondNodeValue);
            }

            static BaseNode_ create(MaxMinNodeGen root) {
                return new Execute1Node_(root);
            }

        }
        @GeneratedBy(methodName = "execute(double, double)", value = MaxMinNode.class)
        private static final class Execute2Node_ extends BaseNode_ {

            Execute2Node_(MaxMinNodeGen root) {
                super(root, 3);
            }

            @Override
            public Object execute_(VirtualFrame frameValue, Object firstNodeValue, Object secondNodeValue) {
                if (firstNodeValue instanceof Double && secondNodeValue instanceof Double) {
                    double firstNodeValue_ = (double) firstNodeValue;
                    double secondNodeValue_ = (double) secondNodeValue;
                    return root.execute(firstNodeValue_, secondNodeValue_);
                }
                return getNext().execute_(frameValue, firstNodeValue, secondNodeValue);
            }

            static BaseNode_ create(MaxMinNodeGen root) {
                return new Execute2Node_(root);
            }

        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy