org.jruby.truffle.interop.ForeignReadStringCachingHelperNodeGen Maven / Gradle / Ivy
The newest version!
// CheckStyle: start generated
package org.jruby.truffle.interop;
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.object.DynamicObject;
import org.jruby.truffle.core.cast.NameToJavaStringNode;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.RubyTypesGen;
@GeneratedBy(ForeignReadStringCachingHelperNode.class)
final class ForeignReadStringCachingHelperNodeGen extends ForeignReadStringCachingHelperNode implements SpecializedNode {
@Child private RubyNode receiver_;
@Child private RubyNode name_;
@CompilationFinal private Class> nameType_;
@Child private BaseNode_ specialization_;
private ForeignReadStringCachingHelperNodeGen(RubyNode receiver, RubyNode name) {
this.receiver_ = receiver;
this.name_ = name;
this.specialization_ = UninitializedNode_.create(this);
}
@Override
public NodeCost getCost() {
return specialization_.getNodeCost();
}
@Override
public Object executeStringCachingHelper(VirtualFrame frameValue, DynamicObject receiverValue, Object nameValue) {
return specialization_.execute1(frameValue, receiverValue, nameValue);
}
@Override
public Object execute(VirtualFrame frameValue) {
return specialization_.execute0(frameValue);
}
@Override
public void executeVoid(VirtualFrame frameValue) {
specialization_.executeVoid(frameValue);
return;
}
@Override
public int executeInteger(VirtualFrame frameValue) throws UnexpectedResultException {
return specialization_.executeInt(frameValue);
}
@Override
public SpecializationNode getSpecializationNode() {
return specialization_;
}
@Override
public Node deepCopy() {
return SpecializationNode.updateRoot(super.deepCopy());
}
private static int expectInteger(Object value) throws UnexpectedResultException {
if (value instanceof Integer) {
return (int) value;
}
throw new UnexpectedResultException(value);
}
public static ForeignReadStringCachingHelperNode create(RubyNode receiver, RubyNode name) {
return new ForeignReadStringCachingHelperNodeGen(receiver, name);
}
@GeneratedBy(ForeignReadStringCachingHelperNode.class)
private abstract static class BaseNode_ extends SpecializationNode {
@CompilationFinal protected ForeignReadStringCachingHelperNodeGen root;
BaseNode_(ForeignReadStringCachingHelperNodeGen root, int index) {
super(index);
this.root = root;
}
@Override
protected final void setRoot(Node root) {
this.root = (ForeignReadStringCachingHelperNodeGen) root;
}
@Override
protected final Node[] getSuppliedChildren() {
return new Node[] {root.receiver_, root.name_};
}
@Override
public final Object acceptAndExecute(Frame frameValue, Object receiverValue, Object nameValue) {
return this.execute_((VirtualFrame) frameValue, receiverValue, nameValue);
}
public abstract Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue);
public Object execute1(VirtualFrame frameValue, DynamicObject receiverValue, Object nameValue) {
return execute_(frameValue, receiverValue, nameValue);
}
public Object execute0(VirtualFrame frameValue) {
Object receiverValue_ = root.receiver_.execute(frameValue);
Object nameValue_ = executeName_(frameValue);
return execute_(frameValue, receiverValue_, nameValue_);
}
public void executeVoid(VirtualFrame frameValue) {
execute0(frameValue);
return;
}
public int executeInt(VirtualFrame frameValue) throws UnexpectedResultException {
return expectInteger(execute0(frameValue));
}
@Override
protected final SpecializationNode createNext(Frame frameValue, Object receiverValue, Object nameValue) {
if (receiverValue instanceof DynamicObject) {
DynamicObject receiverValue_ = (DynamicObject) receiverValue;
if ((root.isStringLike(nameValue))) {
NameToJavaStringNode toJavaStringNode1 = (NameToJavaStringNode.create());
ForeignReadStringCachedHelperNode nextHelper1 = (root.createNextHelper());
return CacheStringLikeAndForwardNode_.create(root, toJavaStringNode1, nextHelper1);
}
if (RubyTypesGen.isImplicitInteger(nameValue)) {
int nameValue_ = RubyTypesGen.asImplicitInteger(nameValue);
if ((RubyGuards.isRubyString(receiverValue_)) && (root.inRange(receiverValue_, nameValue_))) {
return IndexStringNode_.create(root, nameValue);
}
if ((RubyGuards.isRubyString(receiverValue_)) && (!(root.inRange(receiverValue_, nameValue_)))) {
return IndexStringOutOfRangeNode_.create(root, nameValue);
}
}
if ((!(RubyGuards.isRubyString(receiverValue_))) && (!(root.isStringLike(nameValue)))) {
ForeignReadStringCachedHelperNode nextHelper4 = (root.createNextHelper());
return IndexObjectNode_.create(root, nextHelper4);
}
}
return null;
}
@Override
protected final SpecializationNode createPolymorphic() {
return PolymorphicNode_.create(root);
}
protected final BaseNode_ getNext() {
return (BaseNode_) this.next;
}
protected final Object executeName_(Frame frameValue) {
Class> nameType_ = root.nameType_;
try {
if (nameType_ == int.class) {
return root.name_.executeInteger((VirtualFrame) frameValue);
} else if (nameType_ == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
Class> _type = Object.class;
try {
Object _value = root.name_.execute((VirtualFrame) frameValue);
if (_value instanceof Integer) {
_type = int.class;
} else {
_type = Object.class;
}
return _value;
} finally {
root.nameType_ = _type;
}
} else {
return root.name_.execute((VirtualFrame) frameValue);
}
} catch (UnexpectedResultException ex) {
root.nameType_ = Object.class;
return ex.getResult();
}
}
}
@GeneratedBy(ForeignReadStringCachingHelperNode.class)
private static final class UninitializedNode_ extends BaseNode_ {
UninitializedNode_(ForeignReadStringCachingHelperNodeGen root) {
super(root, 2147483647);
}
@Override
public Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue) {
return uninitialized(frameValue, receiverValue, nameValue);
}
static BaseNode_ create(ForeignReadStringCachingHelperNodeGen root) {
return new UninitializedNode_(root);
}
}
@GeneratedBy(ForeignReadStringCachingHelperNode.class)
private static final class PolymorphicNode_ extends BaseNode_ {
PolymorphicNode_(ForeignReadStringCachingHelperNodeGen root) {
super(root, 0);
}
@Override
public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object receiverValue, Object nameValue) {
return polymorphicMerge(newNode, super.merge(newNode, frameValue, receiverValue, nameValue));
}
@Override
public Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue) {
return getNext().execute_(frameValue, receiverValue, nameValue);
}
static BaseNode_ create(ForeignReadStringCachingHelperNodeGen root) {
return new PolymorphicNode_(root);
}
}
@GeneratedBy(methodName = "cacheStringLikeAndForward(VirtualFrame, DynamicObject, Object, NameToJavaStringNode, ForeignReadStringCachedHelperNode)", value = ForeignReadStringCachingHelperNode.class)
private static final class CacheStringLikeAndForwardNode_ extends BaseNode_ {
@Child private NameToJavaStringNode toJavaStringNode;
@Child private ForeignReadStringCachedHelperNode nextHelper;
CacheStringLikeAndForwardNode_(ForeignReadStringCachingHelperNodeGen root, NameToJavaStringNode toJavaStringNode, ForeignReadStringCachedHelperNode nextHelper) {
super(root, 1);
this.toJavaStringNode = toJavaStringNode;
this.nextHelper = nextHelper;
}
@Override
public Object execute1(VirtualFrame frameValue, DynamicObject receiverValue, Object nameValue) {
if ((root.isStringLike(nameValue))) {
return root.cacheStringLikeAndForward(frameValue, receiverValue, nameValue, this.toJavaStringNode, this.nextHelper);
}
return getNext().execute1(frameValue, receiverValue, nameValue);
}
@Override
public Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue) {
if (receiverValue instanceof DynamicObject) {
DynamicObject receiverValue_ = (DynamicObject) receiverValue;
if ((root.isStringLike(nameValue))) {
return root.cacheStringLikeAndForward(frameValue, receiverValue_, nameValue, this.toJavaStringNode, this.nextHelper);
}
}
return getNext().execute_(frameValue, receiverValue, nameValue);
}
static BaseNode_ create(ForeignReadStringCachingHelperNodeGen root, NameToJavaStringNode toJavaStringNode, ForeignReadStringCachedHelperNode nextHelper) {
return new CacheStringLikeAndForwardNode_(root, toJavaStringNode, nextHelper);
}
}
@GeneratedBy(methodName = "indexString(DynamicObject, int)", value = ForeignReadStringCachingHelperNode.class)
private static final class IndexStringNode_ extends BaseNode_ {
private final Class> nameImplicitType;
IndexStringNode_(ForeignReadStringCachingHelperNodeGen root, Object nameValue) {
super(root, 2);
this.nameImplicitType = RubyTypesGen.getImplicitIntegerClass(nameValue);
}
@Override
public boolean isSame(SpecializationNode other) {
return super.isSame(other) && this.nameImplicitType == ((IndexStringNode_) other).nameImplicitType;
}
@Override
public Object execute0(VirtualFrame frameValue) {
try {
return executeInt(frameValue);
} catch (UnexpectedResultException ex) {
return ex.getResult();
}
}
@Override
public int executeInt(VirtualFrame frameValue) throws UnexpectedResultException {
DynamicObject receiverValue_;
try {
receiverValue_ = root.receiver_.executeDynamicObject(frameValue);
} catch (UnexpectedResultException ex) {
Object nameValue = executeName_(frameValue);
return expectInteger(getNext().execute_(frameValue, ex.getResult(), nameValue));
}
int nameValue_;
try {
if (nameImplicitType == int.class) {
nameValue_ = root.name_.executeInteger(frameValue);
} else {
Object nameValue__ = executeName_(frameValue);
nameValue_ = RubyTypesGen.expectImplicitInteger(nameValue__, nameImplicitType);
}
} catch (UnexpectedResultException ex) {
return expectInteger(getNext().execute_(frameValue, receiverValue_, ex.getResult()));
}
if ((RubyGuards.isRubyString(receiverValue_)) && (root.inRange(receiverValue_, nameValue_))) {
return root.indexString(receiverValue_, nameValue_);
}
return expectInteger(getNext().execute_(frameValue, receiverValue_, nameValue_));
}
@Override
public Object execute1(VirtualFrame frameValue, DynamicObject receiverValue, Object nameValue) {
if (RubyTypesGen.isImplicitInteger(nameValue, nameImplicitType)) {
int nameValue_ = RubyTypesGen.asImplicitInteger(nameValue, nameImplicitType);
if ((RubyGuards.isRubyString(receiverValue)) && (root.inRange(receiverValue, nameValue_))) {
return root.indexString(receiverValue, nameValue_);
}
}
return getNext().execute1(frameValue, receiverValue, nameValue);
}
@Override
public Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue) {
if (receiverValue instanceof DynamicObject && RubyTypesGen.isImplicitInteger(nameValue, nameImplicitType)) {
DynamicObject receiverValue_ = (DynamicObject) receiverValue;
int nameValue_ = RubyTypesGen.asImplicitInteger(nameValue, nameImplicitType);
if ((RubyGuards.isRubyString(receiverValue_)) && (root.inRange(receiverValue_, nameValue_))) {
return root.indexString(receiverValue_, nameValue_);
}
}
return getNext().execute_(frameValue, receiverValue, nameValue);
}
static BaseNode_ create(ForeignReadStringCachingHelperNodeGen root, Object nameValue) {
return new IndexStringNode_(root, nameValue);
}
}
@GeneratedBy(methodName = "indexStringOutOfRange(DynamicObject, int)", value = ForeignReadStringCachingHelperNode.class)
private static final class IndexStringOutOfRangeNode_ extends BaseNode_ {
private final Class> nameImplicitType;
IndexStringOutOfRangeNode_(ForeignReadStringCachingHelperNodeGen root, Object nameValue) {
super(root, 3);
this.nameImplicitType = RubyTypesGen.getImplicitIntegerClass(nameValue);
}
@Override
public boolean isSame(SpecializationNode other) {
return super.isSame(other) && this.nameImplicitType == ((IndexStringOutOfRangeNode_) other).nameImplicitType;
}
@Override
public Object execute0(VirtualFrame frameValue) {
try {
return executeInt(frameValue);
} catch (UnexpectedResultException ex) {
return ex.getResult();
}
}
@Override
public int executeInt(VirtualFrame frameValue) throws UnexpectedResultException {
DynamicObject receiverValue_;
try {
receiverValue_ = root.receiver_.executeDynamicObject(frameValue);
} catch (UnexpectedResultException ex) {
Object nameValue = executeName_(frameValue);
return expectInteger(getNext().execute_(frameValue, ex.getResult(), nameValue));
}
int nameValue_;
try {
if (nameImplicitType == int.class) {
nameValue_ = root.name_.executeInteger(frameValue);
} else {
Object nameValue__ = executeName_(frameValue);
nameValue_ = RubyTypesGen.expectImplicitInteger(nameValue__, nameImplicitType);
}
} catch (UnexpectedResultException ex) {
return expectInteger(getNext().execute_(frameValue, receiverValue_, ex.getResult()));
}
if ((RubyGuards.isRubyString(receiverValue_)) && (!(root.inRange(receiverValue_, nameValue_)))) {
return root.indexStringOutOfRange(receiverValue_, nameValue_);
}
return expectInteger(getNext().execute_(frameValue, receiverValue_, nameValue_));
}
@Override
public Object execute1(VirtualFrame frameValue, DynamicObject receiverValue, Object nameValue) {
if (RubyTypesGen.isImplicitInteger(nameValue, nameImplicitType)) {
int nameValue_ = RubyTypesGen.asImplicitInteger(nameValue, nameImplicitType);
if ((RubyGuards.isRubyString(receiverValue)) && (!(root.inRange(receiverValue, nameValue_)))) {
return root.indexStringOutOfRange(receiverValue, nameValue_);
}
}
return getNext().execute1(frameValue, receiverValue, nameValue);
}
@Override
public Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue) {
if (receiverValue instanceof DynamicObject && RubyTypesGen.isImplicitInteger(nameValue, nameImplicitType)) {
DynamicObject receiverValue_ = (DynamicObject) receiverValue;
int nameValue_ = RubyTypesGen.asImplicitInteger(nameValue, nameImplicitType);
if ((RubyGuards.isRubyString(receiverValue_)) && (!(root.inRange(receiverValue_, nameValue_)))) {
return root.indexStringOutOfRange(receiverValue_, nameValue_);
}
}
return getNext().execute_(frameValue, receiverValue, nameValue);
}
static BaseNode_ create(ForeignReadStringCachingHelperNodeGen root, Object nameValue) {
return new IndexStringOutOfRangeNode_(root, nameValue);
}
}
@GeneratedBy(methodName = "indexObject(VirtualFrame, DynamicObject, Object, ForeignReadStringCachedHelperNode)", value = ForeignReadStringCachingHelperNode.class)
private static final class IndexObjectNode_ extends BaseNode_ {
@Child private ForeignReadStringCachedHelperNode nextHelper;
IndexObjectNode_(ForeignReadStringCachingHelperNodeGen root, ForeignReadStringCachedHelperNode nextHelper) {
super(root, 4);
this.nextHelper = nextHelper;
}
@Override
public Object execute1(VirtualFrame frameValue, DynamicObject receiverValue, Object nameValue) {
if ((!(RubyGuards.isRubyString(receiverValue))) && (!(root.isStringLike(nameValue)))) {
return root.indexObject(frameValue, receiverValue, nameValue, this.nextHelper);
}
return getNext().execute1(frameValue, receiverValue, nameValue);
}
@Override
public Object execute_(VirtualFrame frameValue, Object receiverValue, Object nameValue) {
if (receiverValue instanceof DynamicObject) {
DynamicObject receiverValue_ = (DynamicObject) receiverValue;
if ((!(RubyGuards.isRubyString(receiverValue_))) && (!(root.isStringLike(nameValue)))) {
return root.indexObject(frameValue, receiverValue_, nameValue, this.nextHelper);
}
}
return getNext().execute_(frameValue, receiverValue, nameValue);
}
static BaseNode_ create(ForeignReadStringCachingHelperNodeGen root, ForeignReadStringCachedHelperNode nextHelper) {
return new IndexObjectNode_(root, nextHelper);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy