com.oracle.truffle.sl.nodes.local.SLWriteLocalVariableNodeGen 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.local;
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.FrameSlot;
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.SLTypesGen;
@GeneratedBy(SLWriteLocalVariableNode.class)
public final class SLWriteLocalVariableNodeGen extends SLWriteLocalVariableNode implements SpecializedNode {
private final FrameSlot slot;
@Child private SLExpressionNode valueNode_;
@CompilationFinal private Class> valueNodeType_;
@CompilationFinal private boolean excludeWriteLong_;
@CompilationFinal private boolean excludeWriteBoolean_;
@Child private BaseNode_ specialization_;
private SLWriteLocalVariableNodeGen(SourceSection src, SLExpressionNode valueNode, FrameSlot slot) {
super(src);
this.slot = slot;
this.valueNode_ = valueNode;
this.specialization_ = UninitializedNode_.create(this);
}
@Override
protected FrameSlot getSlot() {
return this.slot;
}
@Override
public NodeCost getCost() {
return specialization_.getNodeCost();
}
@Override
public Object executeGeneric(VirtualFrame frameValue) {
return specialization_.execute(frameValue);
}
@Override
public void executeVoid(VirtualFrame frameValue) {
specialization_.executeVoid(frameValue);
return;
}
@Override
public boolean executeBoolean(VirtualFrame frameValue) throws UnexpectedResultException {
return specialization_.executeBoolean(frameValue);
}
@Override
public long executeLong(VirtualFrame frameValue) throws UnexpectedResultException {
return specialization_.executeLong(frameValue);
}
@Override
public SpecializationNode getSpecializationNode() {
return specialization_;
}
@Override
public Node deepCopy() {
return SpecializationNode.updateRoot(super.deepCopy());
}
public static SLWriteLocalVariableNode create(SourceSection src, SLExpressionNode valueNode, FrameSlot slot) {
return new SLWriteLocalVariableNodeGen(src, valueNode, slot);
}
@GeneratedBy(SLWriteLocalVariableNode.class)
private abstract static class BaseNode_ extends SpecializationNode {
protected final SLWriteLocalVariableNodeGen root;
BaseNode_(SLWriteLocalVariableNodeGen 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_ = executeValueNode_(frameValue);
return execute_(frameValue, valueNodeValue_);
}
public void executeVoid(VirtualFrame frameValue) {
execute(frameValue);
return;
}
public boolean executeBoolean(VirtualFrame frameValue) throws UnexpectedResultException {
return SLTypesGen.expectBoolean(execute(frameValue));
}
public long executeLong(VirtualFrame frameValue) throws UnexpectedResultException {
return SLTypesGen.expectLong(execute(frameValue));
}
@Override
protected final SpecializationNode createNext(Frame frameValue, Object valueNodeValue) {
if (valueNodeValue instanceof Long) {
if ((root.isLongKind((VirtualFrame) frameValue))) {
if (!root.excludeWriteLong_) {
CompilerDirectives.transferToInterpreterAndInvalidate();
return WriteLongNode_.create(root);
}
}
}
if (valueNodeValue instanceof Boolean) {
if ((root.isBooleanKind((VirtualFrame) frameValue))) {
if (!root.excludeWriteBoolean_) {
CompilerDirectives.transferToInterpreterAndInvalidate();
return WriteBooleanNode_.create(root);
}
}
}
CompilerDirectives.transferToInterpreterAndInvalidate();
root.excludeWriteLong_ = true;
root.excludeWriteBoolean_ = true;
return WriteNode_.create(root);
}
@Override
protected final SpecializationNode createPolymorphic() {
return PolymorphicNode_.create(root);
}
protected final BaseNode_ getNext() {
return (BaseNode_) this.next;
}
protected final Object executeValueNode_(Frame frameValue) {
Class> valueNodeType_ = root.valueNodeType_;
try {
if (valueNodeType_ == boolean.class) {
return root.valueNode_.executeBoolean((VirtualFrame) frameValue);
} else if (valueNodeType_ == long.class) {
return root.valueNode_.executeLong((VirtualFrame) frameValue);
} else if (valueNodeType_ == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
Class> _type = Object.class;
try {
Object _value = root.valueNode_.executeGeneric((VirtualFrame) frameValue);
if (_value instanceof Boolean) {
_type = boolean.class;
} else if (_value instanceof Long) {
_type = long.class;
} else {
_type = Object.class;
}
return _value;
} finally {
root.valueNodeType_ = _type;
}
} else {
return root.valueNode_.executeGeneric((VirtualFrame) frameValue);
}
} catch (UnexpectedResultException ex) {
root.valueNodeType_ = Object.class;
return ex.getResult();
}
}
}
@GeneratedBy(SLWriteLocalVariableNode.class)
private static final class UninitializedNode_ extends BaseNode_ {
UninitializedNode_(SLWriteLocalVariableNodeGen root) {
super(root, 2147483647);
}
@Override
public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
return uninitialized(frameValue, valueNodeValue);
}
static BaseNode_ create(SLWriteLocalVariableNodeGen root) {
return new UninitializedNode_(root);
}
}
@GeneratedBy(SLWriteLocalVariableNode.class)
private static final class PolymorphicNode_ extends BaseNode_ {
PolymorphicNode_(SLWriteLocalVariableNodeGen 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(SLWriteLocalVariableNodeGen root) {
return new PolymorphicNode_(root);
}
}
@GeneratedBy(methodName = "writeLong(VirtualFrame, long)", value = SLWriteLocalVariableNode.class)
private static final class WriteLongNode_ extends BaseNode_ {
WriteLongNode_(SLWriteLocalVariableNodeGen root) {
super(root, 1);
}
@Override
public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object valueNodeValue) {
if (newNode.getClass() == WriteNode_.class) {
removeSame("Contained by write(VirtualFrame, Object)");
}
return super.merge(newNode, frameValue, valueNodeValue);
}
@Override
public Object execute(VirtualFrame frameValue) {
try {
return executeLong(frameValue);
} catch (UnexpectedResultException ex) {
return ex.getResult();
}
}
@Override
public long executeLong(VirtualFrame frameValue) throws UnexpectedResultException {
long valueNodeValue_;
try {
valueNodeValue_ = root.valueNode_.executeLong(frameValue);
} catch (UnexpectedResultException ex) {
return SLTypesGen.expectLong(getNext().execute_(frameValue, ex.getResult()));
}
if ((root.isLongKind(frameValue))) {
return root.writeLong(frameValue, valueNodeValue_);
}
return SLTypesGen.expectLong(getNext().execute_(frameValue, valueNodeValue_));
}
@Override
public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
if (valueNodeValue instanceof Long) {
long valueNodeValue_ = (long) valueNodeValue;
if ((root.isLongKind(frameValue))) {
return root.writeLong(frameValue, valueNodeValue_);
}
}
return getNext().execute_(frameValue, valueNodeValue);
}
static BaseNode_ create(SLWriteLocalVariableNodeGen root) {
return new WriteLongNode_(root);
}
}
@GeneratedBy(methodName = "writeBoolean(VirtualFrame, boolean)", value = SLWriteLocalVariableNode.class)
private static final class WriteBooleanNode_ extends BaseNode_ {
WriteBooleanNode_(SLWriteLocalVariableNodeGen root) {
super(root, 2);
}
@Override
public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object valueNodeValue) {
if (newNode.getClass() == WriteNode_.class) {
removeSame("Contained by write(VirtualFrame, Object)");
}
return super.merge(newNode, frameValue, valueNodeValue);
}
@Override
public Object execute(VirtualFrame frameValue) {
try {
return executeBoolean(frameValue);
} catch (UnexpectedResultException ex) {
return ex.getResult();
}
}
@Override
public boolean executeBoolean(VirtualFrame frameValue) throws UnexpectedResultException {
boolean valueNodeValue_;
try {
valueNodeValue_ = root.valueNode_.executeBoolean(frameValue);
} catch (UnexpectedResultException ex) {
return SLTypesGen.expectBoolean(getNext().execute_(frameValue, ex.getResult()));
}
if ((root.isBooleanKind(frameValue))) {
return root.writeBoolean(frameValue, valueNodeValue_);
}
return SLTypesGen.expectBoolean(getNext().execute_(frameValue, valueNodeValue_));
}
@Override
public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
if (valueNodeValue instanceof Boolean) {
boolean valueNodeValue_ = (boolean) valueNodeValue;
if ((root.isBooleanKind(frameValue))) {
return root.writeBoolean(frameValue, valueNodeValue_);
}
}
return getNext().execute_(frameValue, valueNodeValue);
}
static BaseNode_ create(SLWriteLocalVariableNodeGen root) {
return new WriteBooleanNode_(root);
}
}
@GeneratedBy(methodName = "write(VirtualFrame, Object)", value = SLWriteLocalVariableNode.class)
private static final class WriteNode_ extends BaseNode_ {
WriteNode_(SLWriteLocalVariableNodeGen root) {
super(root, 3);
}
@Override
public Object execute_(VirtualFrame frameValue, Object valueNodeValue) {
return root.write(frameValue, valueNodeValue);
}
static BaseNode_ create(SLWriteLocalVariableNodeGen root) {
return new WriteNode_(root);
}
}
}