Object.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Behaviors;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import Hoot.Collections.*;
import Hoot.Collections.String;
import java.io.Serializable;
import Hoot.Exceptions.*;
import Hoot.Magnitudes.Number;
import Hoot.Magnitudes.Integer;
import static Hoot.Magnitudes.SmallInteger.*;
import Hoot.Runtime.Names.Primitive;
import Hoot.Runtime.Behaviors.HootRegistry;
import Smalltalk.Collections.ReadableString;
import Smalltalk.Streams.StreamedSink;
import Smalltalk.Magnitudes.Scalar;
public abstract class Object extends java.lang.Object implements Cloneable, Serializable, Ordered, Subject
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends MetaclassBase implements Ordered.Metatype, Subject.Metatype
{
static final Object.Metaclass $class = new Object.Metaclass();
public Metaclass() {
this(Object.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return Object.class; }
/**
* @return
*/
@Override public Subject $new()
{
java.lang.String exitID = "ObjectMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Subject)f0.exit(exitID, Primitive.newInstance(this.outerClass()));
});
}
/**
* @return
*/
public Boolean accepts(final java.lang.Object item)
{
java.lang.String exitID = "ObjectMetatype>>accepts";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (Boolean)f0.exit(exitID, Boolean.from(this.outerClass().isInstance(item)));
});
}
}
/**
*
*/
protected Object()
{
java.lang.String exitID = "Object>>Object";
Frame f0 = new Frame(exitID);
}
/**
* @return
*/
public synchronized Object acquireMonitorDuring(final NiladicValuable aBlock)
{
java.lang.String exitID = "Object>>acquireMonitorDuring";
Frame f0 = new Frame(exitID);
aBlock.value();
return (Object)this;
}
/**
* @return
*/
public synchronized Object awakenAllWaitingThreads()
{
java.lang.String exitID = "Object>>awakenAllWaitingThreads";
Frame f0 = new Frame(exitID);
this.notifyAll();
return (Object)this;
}
/**
* @return
*/
public synchronized Object awakenOneWaitingThread()
{
java.lang.String exitID = "Object>>awakenOneWaitingThread";
Frame f0 = new Frame(exitID);
this.notify();
return (Object)this;
}
/**
* @return
*/
public synchronized Object waitForChange_ifInterrupted(final Number duration, final NiladicValuable aBlock)
{
java.lang.String exitID = "Object>>waitForChange_ifInterrupted";
Frame f0 = new Frame(exitID);
try {
this.wait(duration.primitiveLong());
} catch (InterruptedException ex) {
aBlock.value();
};
return (Object)this;
}
/**
* @return
*/
public synchronized Object waitForChangeIfInterrupted(final NiladicValuable aBlock)
{
java.lang.String exitID = "Object>>waitForChangeIfInterrupted";
Frame f0 = new Frame(exitID);
try {
this.wait();
} catch (InterruptedException ex) {
aBlock.value();
};
return (Object)this;
}
/**
* @return
*/
public Subject value()
{
java.lang.String exitID = "Object>>value";
Frame f0 = new Frame(exitID);
return (Subject)this;
}
/**
* @return
*/
public <ResultType extends Subject> ResultType yourself()
{
java.lang.String exitID = "Object>>yourself";
Frame f0 = new Frame(exitID);
return (ResultType)this;
}
/**
* @return
*/
public Behavior species()
{
java.lang.String exitID = "Object>>species";
Frame f0 = new Frame(exitID);
return (Behavior)this.$class();
}
/**
* @return
*/
public Association associateWith(final Object associate)
{
java.lang.String exitID = "Object>>associateWith";
Frame f0 = new Frame(exitID);
return (Association)Association.withKey_withValue(this, associate);
}
/**
* @return
*/
@Override public int compareTo(final java.lang.Object candidate)
{
java.lang.String exitID = "Object>>compareTo";
Frame f0 = new Frame(exitID);
if ((candidate == null)) {
Hoot.Exceptions.UnhandledJavaException.raiseNullPointer();
};
if (this.equals(candidate)) {
return 0;
};
return (int)(Boolean.primitiveValue(this.lessThan(((Scalar)candidate))) ? Negativity.intValue() : Unity.intValue());
}
/**
* @return
*/
@Override public boolean equals(final java.lang.Object candidate)
{
java.lang.String exitID = "Object>>equals";
Frame f0 = new Frame(exitID);
if ((candidate == null)) {
return false;
};
return (boolean)this.equals(((Subject)candidate)).asPrimitive();
}
/**
* @return
*/
@Override public int hashCode()
{
java.lang.String exitID = "Object>>hashCode";
Frame f0 = new Frame(exitID);
return (int)super.hashCode();
}
/**
* @return
*/
@Override public Boolean equals(final Subject candidate)
{
java.lang.String exitID = "Object>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)(this.isSame(((Object)candidate)));
}
/**
* @return
*/
public Boolean isSame(final Object candidate)
{
java.lang.String exitID = "Object>>isSame";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((this == candidate));
}
/**
* @return
*/
public Boolean isSame(final Subject candidate)
{
java.lang.String exitID = "Object>>isSame";
Frame f0 = new Frame(exitID);
return (Boolean)((Object)candidate).isSame(this);
}
/**
* @return
*/
public Boolean notEqual(final Subject candidate)
{
java.lang.String exitID = "Object>>notEqual";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(this.equals(candidate)).not());
}
/**
* @return
*/
public Boolean notSame(final Subject candidate)
{
java.lang.String exitID = "Object>>notSame";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(this.isSame(candidate)).not());
}
/**
* @return
*/
public final Integer hash()
{
java.lang.String exitID = "Object>>hash";
Frame f0 = new Frame(exitID);
return (Integer)SmallInteger.from(this.hashCode());
}
/**
* @return
*/
public final Integer identityHash()
{
java.lang.String exitID = "Object>>identityHash";
Frame f0 = new Frame(exitID);
return (Integer)SmallInteger.from(super.hashCode());
}
/**
* @return
*/
@Override public Boolean lessThan(final Scalar upperBound)
{
java.lang.String exitID = "Object>>lessThan";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(upperBound.moreThan(this)));
}
/**
* @return
*/
@Override public Boolean notMore(final Scalar upperBound)
{
java.lang.String exitID = "Object>>notMore";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((this.moreThan(upperBound)).not());
}
/**
* @return
*/
@Override public Boolean moreThan(final Scalar lowerBound)
{
java.lang.String exitID = "Object>>moreThan";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(lowerBound.lessThan(this)));
}
/**
* @return
*/
@Override public Boolean notLess(final Scalar lowerBound)
{
java.lang.String exitID = "Object>>notLess";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(lowerBound.notMore(this)));
}
/**
* @return
*/
@Override public Boolean between_and(final Scalar lowerBound, final Scalar upperBound)
{
java.lang.String exitID = "Object>>between_and";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(lowerBound.notMore(this)).and(Predicate.with(f2 -> {
return (this.notMore(upperBound));
}, "")));
}
/**
* @return
*/
@Override public Boolean in(final Interval aRange)
{
java.lang.String exitID = "Object>>in";
Frame f0 = new Frame(exitID);
return (Boolean)aRange.includes(this);
}
/**
* @return
*/
@Override public Boolean inside_and(final Scalar lowerBound, final Scalar upperBound)
{
java.lang.String exitID = "Object>>inside_and";
Frame f0 = new Frame(exitID);
return (Boolean)((Boolean)(lowerBound.lessThan(this)).and(Predicate.with(f2 -> {
return (this.lessThan(upperBound));
}, "")));
}
/**
* @return
*/
@Override public Ordered max(final Scalar value)
{
java.lang.String exitID = "Object>>max";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
(this.moreThan(value)).ifTrue(Closure.with(f2 -> {
return (Ordered)f0.exit(exitID, this);
}, ""));
return (Ordered)f0.exit(exitID, ((Ordered)value));
});
}
/**
* @return
*/
@Override public Ordered min(final Scalar value)
{
java.lang.String exitID = "Object>>min";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
(this.lessThan(value)).ifTrue(Closure.with(f2 -> {
return (Ordered)f0.exit(exitID, this);
}, ""));
return (Ordered)f0.exit(exitID, ((Ordered)value));
});
}
/**
* @return
*/
public Object copy()
{
java.lang.String exitID = "Object>>copy";
Frame f0 = new Frame(exitID);
return (Object)this.shallowCopy();
}
/**
* @return
*/
public <ResultType extends Object> ResultType deepCopy()
{
java.lang.String exitID = "Object>>deepCopy";
Frame f0 = new Frame(exitID);
return (ResultType)((ResultType)Primitive.deepCopyOf(this));
}
/**
* @return
*/
public <ResultType extends Object> ResultType shallowCopy()
{
java.lang.String exitID = "Object>>shallowCopy";
Frame f0 = new Frame(exitID);
return (ResultType)((ResultType)Primitive.shallowCopyOf(this));
}
/**
* @return
*/
public Object $do(final MonadicValuable aBlock)
{
java.lang.String exitID = "Object>>$do";
Frame f0 = new Frame(exitID);
return (Object)aBlock.value(this);
}
/**
* @return
*/
public MessageSend send(final Selector selector, final Subject ... args)
{
java.lang.String exitID = "Object>>send";
Frame f0 = new Frame(exitID);
return (MessageSend)new MessageSend(this, selector, args);
}
/**
* @return
*/
public Object perform(final Selector selector, final Subject ... arguments)
{
java.lang.String exitID = "Object>>perform";
Frame f0 = new Frame(exitID);
return (Object)this.send(selector, arguments).perform();
}
/**
* @return
*/
public Object perform_withArguments(final Selector selector, final Subject ... arguments)
{
java.lang.String exitID = "Object>>perform_withArguments";
Frame f0 = new Frame(exitID);
return (Object)this.send(selector, arguments).perform();
}
/**
* @return
*/
public Object perform_with_with_with_with(final Selector selector, final Subject a0, final Subject a1, final Subject a2, final Subject a3)
{
java.lang.String exitID = "Object>>perform_with_with_with_with";
Frame f0 = new Frame(exitID);
return (Object)this.perform(selector, a0, a1, a2, a3);
}
/**
* @return
*/
public Object perform_with_with_with(final Selector selector, final Subject a0, final Subject a1, final Subject a2)
{
java.lang.String exitID = "Object>>perform_with_with_with";
Frame f0 = new Frame(exitID);
return (Object)this.perform(selector, a0, a1, a2);
}
/**
* @return
*/
public Object perform_with_with(final Selector selector, final Subject a0, final Subject a1)
{
java.lang.String exitID = "Object>>perform_with_with";
Frame f0 = new Frame(exitID);
return (Object)this.perform(selector, a0, a1);
}
/**
* @return
*/
public Object perform_with(final Selector selector, final Subject a0)
{
java.lang.String exitID = "Object>>perform_with";
Frame f0 = new Frame(exitID);
return (Object)this.perform(selector, a0);
}
/**
* @return
*/
public Object perform(final Selector selector)
{
java.lang.String exitID = "Object>>perform";
Frame f0 = new Frame(exitID);
return (Object)this.perform(selector, new Subject[0]);
}
/**
* @return
*/
public Object printOn(final StreamedSink aStream)
{
java.lang.String exitID = "Object>>printOn";
Frame f0 = new Frame(exitID);
aStream.nextPutAll(this.printString());
return (Object)this;
}
/**
* @return
*/
public String printLine()
{
java.lang.String exitID = "Object>>printLine";
Frame f0 = new Frame(exitID);
return (String)this.printString().printLine();
}
/**
* @return
*/
public String printString()
{
java.lang.String exitID = "Object>>printString";
Frame f0 = new Frame(exitID);
return (String)(this.species().namePrefix().append(this.$class().name()));
}
/**
* @return
*/
public String printTerm()
{
java.lang.String exitID = "Object>>printTerm";
Frame f0 = new Frame(exitID);
return (String)String.from("( ").append(this.printString()).append(String.from(" )"));
}
/**
* @return
*/
public Object doesNotUnderstand(final SentMessage message)
{
java.lang.String exitID = "Object>>doesNotUnderstand";
Frame f0 = new Frame(exitID);
return (Object)new MessageNotUnderstood(new MessageSend(this, message.selector(), message.arguments()));
}
/**
* @return
*/
public void error(final ReadableString messageText)
{
java.lang.String exitID = "Object>>error";
Frame f0 = new Frame(exitID);
Primitive.printError(messageText.asSelector().name());
throw new IllegalStateException(messageText.asSelector().name());
}
/**
* @return
*/
public void invalidMessage()
{
java.lang.String exitID = "Object>>invalidMessage";
Frame f0 = new Frame(exitID);
this.error(String.from("An unsupported message was sent to this object"));
}
/**
* @return
*/
public Object ifNil(final NiladicValuable nilBlock)
{
java.lang.String exitID = "Object>>ifNil";
Frame f0 = new Frame(exitID);
return (Object)Nil.literal();
}
/**
* @return
*/
public Object ifNil_ifExtant(final NiladicValuable nilBlock, final NiladicValuable extantBlock)
{
java.lang.String exitID = "Object>>ifNil_ifExtant";
Frame f0 = new Frame(exitID);
return (Object)((Object)extantBlock.value());
}
/**
* @return
*/
public Object ifExtant(final NiladicValuable extantBlock)
{
java.lang.String exitID = "Object>>ifExtant";
Frame f0 = new Frame(exitID);
return (Object)((Object)extantBlock.value());
}
/**
* @return
*/
public Object ifExtant_ifNil(final NiladicValuable extantBlock, final NiladicValuable nilBlock)
{
java.lang.String exitID = "Object>>ifExtant_ifNil";
Frame f0 = new Frame(exitID);
return (Object)((Object)extantBlock.value());
}
/**
* @return
*/
public Boolean isClass()
{
java.lang.String exitID = "Object>>isClass";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isBehavior()
{
java.lang.String exitID = "Object>>isBehavior";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isMetaclass()
{
java.lang.String exitID = "Object>>isMetaclass";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isKindOf(final Classified candidateClass)
{
java.lang.String exitID = "Object>>isKindOf";
Frame f0 = new Frame(exitID);
return (Boolean)this.species().inheritsFrom(((Behavior)candidateClass));
}
/**
* @return
*/
public Boolean instanceOf(final java.lang.Class aClass)
{
java.lang.String exitID = "Object>>instanceOf";
Frame f0 = new Frame(exitID);
Behavior aType = ((Behavior)HootRegistry.getType(aClass));
return (Boolean)this.isMemberOf(aType);
}
/**
* @return
*/
public Boolean isMemberOf(final Classified candidateClass)
{
java.lang.String exitID = "Object>>isMemberOf";
Frame f0 = new Frame(exitID);
return (Boolean)(((Behavior)candidateClass).isSame(((Subject)this.$class())));
}
/**
* @return
*/
public Boolean respondsTo(final Selector selector)
{
java.lang.String exitID = "Object>>respondsTo";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(Primitive.class_hasMethod(this.$class().primitiveClass(), selector.name()));
}
/**
* @return
*/
public Boolean isNil()
{
java.lang.String exitID = "Object>>isNil";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean notNil()
{
java.lang.String exitID = "Object>>notNil";
Frame f0 = new Frame(exitID);
return (Boolean)True.literal();
}
/**
* @return
*/
public Boolean isFloat()
{
java.lang.String exitID = "Object>>isFloat";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isLiteral()
{
java.lang.String exitID = "Object>>isLiteral";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isString()
{
java.lang.String exitID = "Object>>isString";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isSmallInteger()
{
java.lang.String exitID = "Object>>isSmallInteger";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isInteger()
{
java.lang.String exitID = "Object>>isInteger";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isArray()
{
java.lang.String exitID = "Object>>isArray";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isBoolean()
{
java.lang.String exitID = "Object>>isBoolean";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isCharacter()
{
java.lang.String exitID = "Object>>isCharacter";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isCollection()
{
java.lang.String exitID = "Object>>isCollection";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public static Boolean isNull(final Object candidate)
{
java.lang.String exitID = "Object>>$isNull";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from((candidate == null));
}
/**
* @return
*/
public static Nil literalNil()
{
java.lang.String exitID = "Object>>$literalNil";
Frame f0 = new Frame(exitID);
return (Nil)Nil.literal();
}
}