com.oracle.truffle.sl.nodes.expression.SLLessThanNodeGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truffle-sl Show documentation
Show all versions of truffle-sl Show documentation
Truffle SL is an example language implemented using the Truffle API.
The newest version!
/*
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// CheckStyle: start generated
package com.oracle.truffle.sl.nodes.expression;
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.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.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import com.oracle.truffle.sl.nodes.SLTypes;
import com.oracle.truffle.sl.nodes.SLTypesGen;
import java.math.BigInteger;
@GeneratedBy(SLLessThanNode.class)
public final class SLLessThanNodeGen extends SLLessThanNode implements SpecializedNode {
@Child private SLExpressionNode leftNode_;
@Child private SLExpressionNode rightNode_;
@CompilationFinal private Class> leftNodeType_;
@CompilationFinal private Class> rightNodeType_;
@Child private BaseNode_ specialization_;
private SLLessThanNodeGen(SourceSection src, SLExpressionNode leftNode, SLExpressionNode rightNode) {
super(src);
this.leftNode_ = leftNode;
this.rightNode_ = rightNode;
this.specialization_ = UninitializedNode_.create(this);
}
@Override
public NodeCost getCost() {
return specialization_.getNodeCost();
}
@Override
public Object executeGeneric(VirtualFrame frameValue) {
return specialization_.execute(frameValue);
}
@Override
public boolean executeBoolean(VirtualFrame frameValue) {
return specialization_.executeBoolean(frameValue);
}
@Override
public void executeVoid(VirtualFrame frameValue) {
specialization_.executeVoid(frameValue);
return;
}
@Override
public SpecializationNode getSpecializationNode() {
return specialization_;
}
@Override
public Node deepCopy() {
return SpecializationNode.updateRoot(super.deepCopy());
}
public static SLLessThanNode create(SourceSection src, SLExpressionNode leftNode, SLExpressionNode rightNode) {
return new SLLessThanNodeGen(src, leftNode, rightNode);
}
@GeneratedBy(SLLessThanNode.class)
private abstract static class BaseNode_ extends SpecializationNode {
protected final SLLessThanNodeGen root;
BaseNode_(SLLessThanNodeGen root, int index) {
super(index);
this.root = root;
}
@Override
protected final Node[] getSuppliedChildren() {
return new Node[] {root.leftNode_, root.rightNode_};
}
@Override
public final Object acceptAndExecute(Frame frameValue, Object leftNodeValue, Object rightNodeValue) {
return this.executeBoolean_((VirtualFrame) frameValue, leftNodeValue, rightNodeValue);
}
public abstract boolean executeBoolean_(VirtualFrame frameValue, Object leftNodeValue, Object rightNodeValue);
public Object execute(VirtualFrame frameValue) {
Object leftNodeValue_ = executeLeftNode_(frameValue);
Object rightNodeValue_ = executeRightNode_(frameValue);
return executeBoolean_(frameValue, leftNodeValue_, rightNodeValue_);
}
public boolean executeBoolean(VirtualFrame frameValue) {
return (boolean) execute(frameValue);
}
public void executeVoid(VirtualFrame frameValue) {
executeBoolean(frameValue);
return;
}
@Override
protected final SpecializationNode createNext(Frame frameValue, Object leftNodeValue, Object rightNodeValue) {
if (leftNodeValue instanceof Long && rightNodeValue instanceof Long) {
return LessThan0Node_.create(root);
}
if (SLTypesGen.isImplicitBigInteger(leftNodeValue) && SLTypesGen.isImplicitBigInteger(rightNodeValue)) {
return LessThan1Node_.create(root, leftNodeValue, rightNodeValue);
}
return null;
}
@Override
protected final SpecializationNode createPolymorphic() {
return PolymorphicNode_.create(root);
}
protected final BaseNode_ getNext() {
return (BaseNode_) this.next;
}
protected final Object executeLeftNode_(Frame frameValue) {
Class> leftNodeType_ = root.leftNodeType_;
try {
if (leftNodeType_ == long.class) {
return root.leftNode_.executeLong((VirtualFrame) frameValue);
} else if (leftNodeType_ == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
Class> _type = Object.class;
try {
Object _value = root.leftNode_.executeGeneric((VirtualFrame) frameValue);
if (_value instanceof Long) {
_type = long.class;
} else {
_type = Object.class;
}
return _value;
} finally {
root.leftNodeType_ = _type;
}
} else {
return root.leftNode_.executeGeneric((VirtualFrame) frameValue);
}
} catch (UnexpectedResultException ex) {
root.leftNodeType_ = Object.class;
return ex.getResult();
}
}
protected final Object executeRightNode_(Frame frameValue) {
Class> rightNodeType_ = root.rightNodeType_;
try {
if (rightNodeType_ == long.class) {
return root.rightNode_.executeLong((VirtualFrame) frameValue);
} else if (rightNodeType_ == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
Class> _type = Object.class;
try {
Object _value = root.rightNode_.executeGeneric((VirtualFrame) frameValue);
if (_value instanceof Long) {
_type = long.class;
} else {
_type = Object.class;
}
return _value;
} finally {
root.rightNodeType_ = _type;
}
} else {
return root.rightNode_.executeGeneric((VirtualFrame) frameValue);
}
} catch (UnexpectedResultException ex) {
root.rightNodeType_ = Object.class;
return ex.getResult();
}
}
}
@GeneratedBy(SLLessThanNode.class)
private static final class UninitializedNode_ extends BaseNode_ {
UninitializedNode_(SLLessThanNodeGen root) {
super(root, 2147483647);
}
@Override
public boolean executeBoolean_(VirtualFrame frameValue, Object leftNodeValue, Object rightNodeValue) {
return (boolean) uninitialized(frameValue, leftNodeValue, rightNodeValue);
}
static BaseNode_ create(SLLessThanNodeGen root) {
return new UninitializedNode_(root);
}
}
@GeneratedBy(SLLessThanNode.class)
private static final class PolymorphicNode_ extends BaseNode_ {
PolymorphicNode_(SLLessThanNodeGen root) {
super(root, 0);
}
@Override
public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object leftNodeValue, Object rightNodeValue) {
return polymorphicMerge(newNode, super.merge(newNode, frameValue, leftNodeValue, rightNodeValue));
}
@Override
public boolean executeBoolean(VirtualFrame frameValue) {
Object leftNodeValue_ = executeLeftNode_(frameValue);
Object rightNodeValue_ = executeRightNode_(frameValue);
return getNext().executeBoolean_(frameValue, leftNodeValue_, rightNodeValue_);
}
@Override
public boolean executeBoolean_(VirtualFrame frameValue, Object leftNodeValue, Object rightNodeValue) {
return getNext().executeBoolean_(frameValue, leftNodeValue, rightNodeValue);
}
static BaseNode_ create(SLLessThanNodeGen root) {
return new PolymorphicNode_(root);
}
}
@GeneratedBy(methodName = "lessThan(long, long)", value = SLLessThanNode.class)
private static final class LessThan0Node_ extends BaseNode_ {
LessThan0Node_(SLLessThanNodeGen root) {
super(root, 1);
}
@Override
public Object execute(VirtualFrame frameValue) {
return executeBoolean(frameValue);
}
@Override
public boolean executeBoolean(VirtualFrame frameValue) {
long leftNodeValue_;
try {
leftNodeValue_ = root.leftNode_.executeLong(frameValue);
} catch (UnexpectedResultException ex) {
Object rightNodeValue = executeRightNode_(frameValue);
return getNext().executeBoolean_(frameValue, ex.getResult(), rightNodeValue);
}
long rightNodeValue_;
try {
rightNodeValue_ = root.rightNode_.executeLong(frameValue);
} catch (UnexpectedResultException ex) {
return getNext().executeBoolean_(frameValue, leftNodeValue_, ex.getResult());
}
return root.lessThan(leftNodeValue_, rightNodeValue_);
}
@Override
public boolean executeBoolean_(VirtualFrame frameValue, Object leftNodeValue, Object rightNodeValue) {
if (leftNodeValue instanceof Long && rightNodeValue instanceof Long) {
long leftNodeValue_ = (long) leftNodeValue;
long rightNodeValue_ = (long) rightNodeValue;
return root.lessThan(leftNodeValue_, rightNodeValue_);
}
return getNext().executeBoolean_(frameValue, leftNodeValue, rightNodeValue);
}
static BaseNode_ create(SLLessThanNodeGen root) {
return new LessThan0Node_(root);
}
}
@GeneratedBy(methodName = "lessThan(BigInteger, BigInteger)", value = SLLessThanNode.class)
private static final class LessThan1Node_ extends BaseNode_ {
private final Class> leftNodeImplicitType;
private final Class> rightNodeImplicitType;
LessThan1Node_(SLLessThanNodeGen root, Object leftNodeValue, Object rightNodeValue) {
super(root, 2);
this.leftNodeImplicitType = SLTypesGen.getImplicitBigIntegerClass(leftNodeValue);
this.rightNodeImplicitType = SLTypesGen.getImplicitBigIntegerClass(rightNodeValue);
}
@Override
public boolean isSame(SpecializationNode other) {
return super.isSame(other) && this.leftNodeImplicitType == ((LessThan1Node_) other).leftNodeImplicitType && this.rightNodeImplicitType == ((LessThan1Node_) other).rightNodeImplicitType;
}
@Override
public boolean executeBoolean(VirtualFrame frameValue) {
BigInteger leftNodeValue_;
try {
if (leftNodeImplicitType == long.class) {
leftNodeValue_ = SLTypes.castBigInteger(root.leftNode_.executeLong(frameValue));
} else {
Object leftNodeValue__ = executeLeftNode_(frameValue);
leftNodeValue_ = SLTypesGen.expectImplicitBigInteger(leftNodeValue__, leftNodeImplicitType);
}
} catch (UnexpectedResultException ex) {
Object rightNodeValue = executeRightNode_(frameValue);
return getNext().executeBoolean_(frameValue, ex.getResult(), rightNodeValue);
}
BigInteger rightNodeValue_;
try {
if (rightNodeImplicitType == long.class) {
rightNodeValue_ = SLTypes.castBigInteger(root.rightNode_.executeLong(frameValue));
} else {
Object rightNodeValue__ = executeRightNode_(frameValue);
rightNodeValue_ = SLTypesGen.expectImplicitBigInteger(rightNodeValue__, rightNodeImplicitType);
}
} catch (UnexpectedResultException ex) {
return getNext().executeBoolean_(frameValue, leftNodeValue_, ex.getResult());
}
return root.lessThan(leftNodeValue_, rightNodeValue_);
}
@Override
public boolean executeBoolean_(VirtualFrame frameValue, Object leftNodeValue, Object rightNodeValue) {
if (SLTypesGen.isImplicitBigInteger(leftNodeValue, leftNodeImplicitType) && SLTypesGen.isImplicitBigInteger(rightNodeValue, rightNodeImplicitType)) {
BigInteger leftNodeValue_ = SLTypesGen.asImplicitBigInteger(leftNodeValue, leftNodeImplicitType);
BigInteger rightNodeValue_ = SLTypesGen.asImplicitBigInteger(rightNodeValue, rightNodeImplicitType);
return root.lessThan(leftNodeValue_, rightNodeValue_);
}
return getNext().executeBoolean_(frameValue, leftNodeValue, rightNodeValue);
}
static BaseNode_ create(SLLessThanNodeGen root, Object leftNodeValue, Object rightNodeValue) {
return new LessThan1Node_(root, leftNodeValue, rightNodeValue);
}
}
}