org.truffleruby.debug.ForeignArrayGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ruby-language Show documentation
Show all versions of ruby-language Show documentation
Core module of Ruby on Truffle
The newest version!
// CheckStyle: start generated
package org.truffleruby.debug;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.library.DynamicDispatchLibrary;
import com.oracle.truffle.api.library.LibraryExport;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.UnadoptableNode;
import org.truffleruby.debug.TruffleDebugNodes.ForeignArrayNode.ForeignArray;
@GeneratedBy(ForeignArray.class)
public final class ForeignArrayGen {
private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
static {
LibraryExport.register(ForeignArray.class, new InteropLibraryExports());
}
private ForeignArrayGen() {
}
@GeneratedBy(ForeignArray.class)
public static class InteropLibraryExports extends LibraryExport {
private InteropLibraryExports() {
super(InteropLibrary.class, ForeignArray.class, false, false, 0);
}
@Override
protected InteropLibrary createUncached(Object receiver) {
assert receiver instanceof ForeignArray;
InteropLibrary uncached = new Uncached(receiver);
return uncached;
}
@Override
protected InteropLibrary createCached(Object receiver) {
assert receiver instanceof ForeignArray;
return new Cached(receiver);
}
@GeneratedBy(ForeignArray.class)
public static class Cached extends InteropLibrary {
private final Class extends ForeignArray> receiverClass_;
protected Cached(Object receiver) {
ForeignArray castReceiver = ((ForeignArray) receiver) ;
this.receiverClass_ = castReceiver.getClass();
}
@Override
public boolean accepts(Object receiver) {
assert receiver.getClass() != this.receiverClass_ || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return CompilerDirectives.isExact(receiver, this.receiverClass_);
}
@Override
public boolean hasArrayElements(Object receiver) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).hasArrayElements();
}
@Override
public boolean isArrayElementReadable(Object receiver, long index) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).isArrayElement(index);
}
@Override
public boolean isArrayElementModifiable(Object receiver, long index) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).isArrayElement(index);
}
@TruffleBoundary
@Override
public Object readArrayElement(Object receiver, long index) throws UnsupportedMessageException, InvalidArrayIndexException {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).readArrayElement(index);
}
@TruffleBoundary
@Override
public void writeArrayElement(Object receiver, long index, Object value) throws UnsupportedMessageException, UnsupportedTypeException, InvalidArrayIndexException {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
(CompilerDirectives.castExact(receiver, receiverClass_)).writeArrayElement(index, value);
return;
}
@Override
public boolean isArrayElementInsertable(Object receiver, long index) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).isArrayElementInsertable(index);
}
@Override
public long getArraySize(Object receiver) throws UnsupportedMessageException {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).getArraySize();
}
@Override
public Object toDisplayString(Object receiver, boolean allowSideEffects) {
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return (CompilerDirectives.castExact(receiver, receiverClass_)).toDisplayString(allowSideEffects);
}
}
@GeneratedBy(ForeignArray.class)
public static class Uncached extends InteropLibrary implements UnadoptableNode {
private final Class extends ForeignArray> receiverClass_;
protected Uncached(Object receiver) {
this.receiverClass_ = ((ForeignArray) receiver).getClass();
}
@Override
@TruffleBoundary
public boolean accepts(Object receiver) {
assert receiver.getClass() != this.receiverClass_ || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
return CompilerDirectives.isExact(receiver, this.receiverClass_);
}
@TruffleBoundary
@Override
public boolean hasArrayElements(Object receiver) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .hasArrayElements();
}
@TruffleBoundary
@Override
public boolean isArrayElementReadable(Object receiver, long index) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .isArrayElement(index);
}
@TruffleBoundary
@Override
public boolean isArrayElementModifiable(Object receiver, long index) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .isArrayElement(index);
}
@TruffleBoundary
@Override
public Object readArrayElement(Object receiver, long index) throws UnsupportedMessageException, InvalidArrayIndexException {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .readArrayElement(index);
}
@TruffleBoundary
@Override
public void writeArrayElement(Object receiver, long index, Object value) throws UnsupportedMessageException, UnsupportedTypeException, InvalidArrayIndexException {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
((ForeignArray) receiver) .writeArrayElement(index, value);
return;
}
@TruffleBoundary
@Override
public boolean isArrayElementInsertable(Object receiver, long index) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .isArrayElementInsertable(index);
}
@TruffleBoundary
@Override
public long getArraySize(Object receiver) throws UnsupportedMessageException {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .getArraySize();
}
@TruffleBoundary
@Override
public Object toDisplayString(Object receiver, boolean allowSideEffects) {
// declared: true
assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
return ((ForeignArray) receiver) .toDisplayString(allowSideEffects);
}
}
}
}