@powerlang/egg-js
Version:
A Smalltalk VM that runs on top of JavaScript
1,024 lines (888 loc) • 30.5 kB
JavaScript
import ClosureElementTypes from './ClosureElementTypes.js';
let EggEvaluator = class {
constructor() {
this._runtime = nil;
this._falseObj = nil;
this._trueObj = nil;
this._nilObj = nil;
this._context = nil;
this._undermessages = nil;
this._primitives = nil;
this._messageCount = nil;
this._stacks = nil;
}
static undermessages() {
return ["_basicAt:", "_basicAt:put:", "_bitShiftLeft:", "_byteAt:", "_byteAt:put:", "_smallSize", "_largeSize", "_isSmallInteger", "_basicHash", "_basicHash:", "_smallIntegerByteAt:", "_uShortAtOffset:", "_uShortAtOffset:put:"];
}
booleanFor_(aBoolean) {
let _retval;
if (aBoolean)
{
_retval = this._trueObj
} else {
_retval = this._falseObj
}
;
return _retval;
}
booleanFrom_(anObject) {
if (anObject._equalEqual(this._falseObj))
{
return false
}
;
if (anObject._equalEqual(this._trueObj))
{
return true
}
;
this.error_("not a boolean");
return this;
}
context() {
return this._context;
}
context_(anEvaluationContext) {
this._context = anEvaluationContext;
return this;
}
contextSwitchTo_(vmStack) {
return this.subclassResponsibility();
}
convertPrimitives() {
let original;
original = this._primitives;
this._primitives = Map.new();
original.keysAndValuesDo_((symbol, block) => {
return this._primitives.at_put_(this._runtime.symbolFromLocal_(symbol), block)
});
return this;
}
convertUndermessages() {
let original;
original = this._undermessages;
this._undermessages = Map.new();
original.keysAndValuesDo_((symbol, block) => {
return this._undermessages.at_put_(this._runtime.symbolFromLocal_(symbol), block)
});
return this;
}
evaluateClosure_(receiver) {
return this.evaluateClosure_withArgs_(receiver, []);
}
evaluateClosure_with_(aPClosure, anObject) {
return this.evaluateClosure_withArgs_(aPClosure, [anObject]);
}
evaluateClosure_with_with_(aPClosure, anObject, anotherObject) {
return this.evaluateClosure_withArgs_(aPClosure, [anObject, anotherObject]);
}
evaluateClosure_withArgs_(receiver, _arguments) {
return this.subclassResponsibility();
}
evaluatePerform_in_withArgs_(aSymbol, receiver, _arguments) {
let behavior, method;
behavior = this._runtime.behaviorOf_(receiver);
method = this._runtime.lookup_startingAt_(aSymbol, behavior);
_arguments.slots().do_((arg) => {
return this._context.pushOperand_(arg)
});
return this.invoke_with_(method, receiver);
}
evaluatePrimitiveHash_(receiver) {
let hash;
hash = receiver.headerHash();
if (hash._equal(0))
{
hash = this.nextHash();
receiver.headerHash_(hash)
}
;
return this._runtime.newInteger_(hash);
}
false() {
return this._falseObj;
}
initialize() {
this._messageCount = 0;
this._stacks = Map.new();
return this;
}
initializeExecutableCodeOf_(method) {
return this.subclassResponsibility();
}
initializeLinearExecutableCodeOf_(method) {
let sexpressions, executable;
sexpressions = this._runtime.sexpressionsOf_(method);
if (this._runtime.methodIsCallout_(method))
{
this.linearizer().visitFFIMethod_(sexpressions)
} else {
this.linearizer().visitMethod_(sexpressions)
}
;
executable = this._runtime.newExecutableCodeFor_(this.linearizer().operations().asArray());
return this._runtime.methodExecutableCode_put_(method, executable);
}
initializePrimitives() {
this._primitives = Map.new();
_cascade(this._primitives, (_recv) => {
_recv.at_put_("Behavior", this.primitiveBehavior());
_recv.at_put_("SetBehavior", this.primitiveSetBehavior());
_recv.at_put_("Class", this.primitiveClass());
_recv.at_put_("UnderHash", this.primitiveUnderHash());
_recv.at_put_("UnderIsBytes", this.primitiveUnderIsBytes());
_recv.at_put_("UnderPointersSize", this.primitiveUnderPointersSize());
_recv.at_put_("UnderSize", this.primitiveUnderSize());
_recv.at_put_("Size", this.primitiveSize());
_recv.at_put_("Hash", this.primitiveHash());
_recv.at_put_("At", this.primitiveAt());
_recv.at_put_("AtPut", this.primitiveAtPut());
_recv.at_put_("New", this.primitiveNew());
_recv.at_put_("NewSized", this.primitiveNewSized());
_recv.at_put_("NewBytes", this.primitiveNewBytes());
_recv.at_put_("Equal", this.primitiveEqual());
_recv.at_put_("SMIPlus", this.primitiveSMIPlus());
_recv.at_put_("SMIMinus", this.primitiveSMIMinus());
_recv.at_put_("SMITimes", this.primitiveSMITimes());
_recv.at_put_("SMIIntDiv", this.primitiveSMIIntDiv());
_recv.at_put_("SMIIntQuot", this.primitiveSMIIntQuot());
_recv.at_put_("SMIBitAnd", this.primitiveSMIBitAnd());
_recv.at_put_("SMIBitOr", this.primitiveSMIBitOr());
_recv.at_put_("SMIBitXor", this.primitiveSMIBitXor());
_recv.at_put_("SMIBitShift", this.primitiveSMIBitShift());
_recv.at_put_("SMIHighBit", this.primitiveSMIHighBit());
_recv.at_put_("SMIGreaterThan", this.primitiveSMIGreaterThan());
_recv.at_put_("SMIGreaterEqualThan", this.primitiveSMIGreaterEqualThan());
_recv.at_put_("SMIEqual", this.primitiveSMIEqual());
_recv.at_put_("SMINotEqual", this.primitiveSMINotEqual());
_recv.at_put_("SMISize", this.primitiveSMISize());
_recv.at_put_("ClosureValue", this.primitiveClosureValue());
_recv.at_put_("ClosureValueWithArgs", this.primitiveClosureValueWithArgs());
_recv.at_put_("ClosureArgumentCount", this.primitiveClosureArgumentCount());
_recv.at_put_("PerformWithArguments", this.primitivePerformWithArguments());
_recv.at_put_("StringReplaceFromToWithStartingAt", this.primitiveStringReplaceFromToWithStartingAt());
_recv.at_put_("FloatNew", this.primitiveFloatNew());
_recv.at_put_("DictionaryNew", this.primitiveBootstrapDictNew());
_recv.at_put_("FlushDispatchCaches", this.primitiveFlushDispatchCaches());
_recv.at_put_("BootstrapDictBeConstant", this.primitiveBootstrapDictBeConstant());
_recv.at_put_("BootstrapDictKeys", this.primitiveBootstrapDictKeys());
_recv.at_put_("BootstrapDictAt", this.primitiveBootstrapDictAt());
_recv.at_put_("BootstrapDictAtPut", this.primitiveBootstrapDictAtPut());
_recv.at_put_("HostSuspendedBecause", this.primitiveHostSuspendedBecause());
_recv.at_put_("HostCurrentMilliseconds", this.primitiveHostCurrentMilliseconds());
_recv.at_put_("HostLoadModule", this.primitiveHostLoadModule());
_recv.at_put_("HostReadFile", this.primitiveHostReadFile());
_recv.at_put_("HostPlatformName", this.primitiveHostPlatformName());
_recv.at_put_("HostFixOverrides", this.primitiveHostFixOverrides());
_recv.at_put_("PrimeFor", this.primitivePrimeFor());
_recv.at_put_("FlushFromCaches", this.primitiveFlushFromCaches());
_recv.at_put_("PrepareForExecution", this.primitivePrepareForExecution());
_recv.at_put_("ProcessVMStackInitialize", this.primitiveProcessVMStackInitialize());
_recv.at_put_("ProcessVMStackAt", this.primitiveProcessVMStackAt());
_recv.at_put_("ProcessVMStackAtPut", this.primitiveProcessVMStackAtPut());
_recv.at_put_("ProcessVMStackBpAtPut", this.primitiveProcessVMStackBpAtPut());
_recv.at_put_("ProcessVMStackPcAtPut", this.primitiveProcessVMStackPcAtPut());
_recv.at_put_("ProcessVMStackBP", this.primitiveProcessVMStackBP());
_recv.at_put_("ProcessVMStackBufferSize", this.primitiveProcessVMStackBufferSize());
return _recv.at_put_("ProcessVMStackContextSwitchTo", this.primitiveProcessVMStackContextSwitchTo());});
return this;
}
initializeRecursiveExecutableCodeOf_(method) {
let sexpressions, executable;
sexpressions = this._runtime.sexpressionsOf_(method);
executable = this._runtime.newExecutableCodeFor_(sexpressions);
return this._runtime.methodExecutableCode_put_(method, executable);
}
initializeUndermessages() {
this._undermessages = Map.new();
_cascade(this._undermessages, (_recv) => {
_recv.at_put_("_isSmallInteger", this.underprimitiveIsSmallInteger());
_recv.at_put_("_isLarge", this.underprimitiveIsLarge());
_recv.at_put_("_smallSize", this.underprimitiveSmallSize());
_recv.at_put_("_largeSize", this.underprimitiveLargeSize());
_recv.at_put_("_basicFlags", this.underprimitiveBasicFlags());
_recv.at_put_("_basicAt:", this.underprimitiveBasicAt());
_recv.at_put_("_basicAt:put:", this.underprimitiveBasicAtPut());
_recv.at_put_("_byteAt:", this.underprimitiveByteAt());
_recv.at_put_("_byteAt:put:", this.underprimitiveByteAtPut());
_recv.at_put_("_basicHash", this.underprimitiveBasicHash());
_recv.at_put_("_basicHash:", this.underprimitiveBasicHashPut());
_recv.at_put_("_smallIntegerByteAt:", this.underprimitiveSmallIntegerByteAt());
_recv.at_put_("_bitShiftLeft:", this.underprimitiveBitShiftLeft());
_recv.at_put_("_primitiveULongAtOffset:", this.underprimitiveULongAtOffset());
_recv.at_put_("_primitiveULongAtOffset:put:", this.underprimitiveULongAtOffsetPut());
_recv.at_put_("_uShortAtOffset:", this.underprimitiveUShortAtOffset());
_recv.at_put_("_uShortAtOffset:put:", this.underprimitiveUShortAtOffsetPut());
_recv.at_put_("_smiPlus:", this.underprimitiveSMIPlus());
_recv.at_put_("_smiMinus:", this.underprimitiveSMIMinus());
_recv.at_put_("_smiTimes:", this.underprimitiveSMITimes());
_recv.at_put_("_smiLowerThan:", this.underprimitiveSMILowerThan());
_recv.at_put_("_smiLowerEqualThan:", this.underprimitiveSMILowerEqualThan());
_recv.at_put_("_smiGreaterThan:", this.underprimitiveSMIGreaterThan());
_recv.at_put_("_smiGreaterEqualThan:", this.underprimitiveSMIGreaterEqualThan());
_recv.at_put_("_smiEquals:", this.underprimitiveSMIEquals());
_recv.at_put_("_identityEquals:", this.underprimitiveIdentityEquals());
_recv.at_put_("_leadingZeroBitCount", this.underprimitiveLeadingZeroBitCount());
_recv.at_put_("_quotientTowardZero:", this.underprimitiveSMIQuotientTowardZero());
_recv.at_put_("_remainderTowardZero:", this.underprimitiveSMIRemainderTowardZero());
_recv.at_put_("_bitShiftLeft:", this.underprimitiveSMIBitShiftLeft());
_recv.at_put_("_bitShiftRight:", this.underprimitiveSMIBitShiftRight());
_recv.at_put_("_smiBitAnd:", this.underprimitiveSMIBitAnd());
_recv.at_put_("_smiBitOr:", this.underprimitiveSMIBitOr());
return _recv.at_put_("_halt", this.underprimitiveHalt());});
return this;
}
invoke_with_(method, receiver) {
return this.subclassResponsibility();
}
isIdentical_to_(anObject, anotherObject) {
return anObject._equalEqual(anotherObject).or_(() => {
return anObject.isImmediate().and_(() => {
return anotherObject.isImmediate().and_(() => {
return anObject.value()._equal(anotherObject.value())
})
})
});
}
linearizer() {
return this.subclassResponsibility();
}
lookup_startingAt_sendSite_(aSymbol, aBehavior, anSMessage) {
let method, symbol;
const _home = {};
try {
method = anSMessage.methodFor_(aBehavior);
if (nil === method)
{
this._undermessages.at_ifPresent_(aSymbol, (block) => {
anSMessage.cacheUndermessage_(block);
throw [_home, block]
});
symbol = this._runtime.symbolFrom_(aSymbol);
method = this._runtime.lookup_startingAt_(symbol, aBehavior);
if (nil === method)
{
this.messageNotUnderstood_(anSMessage);
return nil
}
;
_cascade(anSMessage, (_recv) => {
_recv.registerCacheWith_(this._runtime);
return _recv.cache_when_(method, aBehavior);})
}
;
return method;
} catch(e) { if (e[0] == _home) return e[1]; else throw(e); }
}
nil() {
return this._nilObj;
}
prepareExecutableCode_(method) {
let code;
code = this._runtime.methodExecutableCode_(method);
if (this._runtime.isExecutableCode_(code))
{
return code
}
;
return this.initializeExecutableCodeOf_(method);
}
prepareForExecuting_(method) {
let code;
code = this.prepareExecutableCode_(method);
return this._runtime.executableCodeWork_(code);
}
primitiveAt() {
let receiver, index, value, _retval;
return () => {
receiver = this._context.self();
index = this._context.firstArgument().value();
value = receiver.at_(index);
if (receiver.isBytes())
{
_retval = this._runtime.newInteger_(value)
} else {
_retval = value
}
;
return _retval
};
}
primitiveAtPut() {
let index;
return () => {
index = this._context.firstArgument().value();
return this._context.self().at_put_(index, this._context.secondArgument())
};
}
primitiveBehavior() {
let receiver, _retval;
return () => {
receiver = this._context.self();
if (receiver.isImmediate())
{
_retval = this._runtime.smallIntegerBehavior()
} else {
_retval = receiver.behavior()
}
;
return _retval
};
}
primitiveBootstrapDictAt() {
let string;
return () => {
string = this._context.firstArgument().asString();
return this._context.self().at_(string)
};
}
primitiveBootstrapDictAtPut() {
let string;
return () => {
string = this._context.firstArgument().asString();
return this._context.self().at_put_(string, this._context.secondArgument())
};
}
primitiveBootstrapDictBeConstant() {
return () => {
return this._context.self().beConstant()
};
}
primitiveBootstrapDictKeys() {
return () => {
return this._context.self().keys()
};
}
primitiveBootstrapDictNew() {
return () => {
return this._runtime.newBootstrapDictionaryOf_(this._context.self())
};
}
primitiveClass() {
return () => {
return this._runtime.speciesFor_(this._context.self())
};
}
primitiveClosureArgumentCount() {
return () => {
return this._runtime.newInteger_(this._runtime.blockArgumentCount_(this._runtime.closureBlock_(this._context.self())))
};
}
primitiveClosureValue() {
return () => {
return this.evaluateClosure_(this._context.self())
};
}
primitiveClosureValueWithArgs() {
return () => {
return this.evaluateClosure_withArgs_(this._context.self(), this._context.methodArguments())
};
}
primitiveEqual() {
return () => {
return this._runtime.booleanFor_(this._context.self()._equal(this._context.firstArgument()))
};
}
primitiveFloatNew() {
return () => {
return this._runtime.newBytesOf_sized_(this._context.self(), 8)
};
}
primitiveFlushDispatchCaches() {
return () => {
return this._runtime.flushDispatchCache_in_(this._context.self(), this._context.firstArgument())
};
}
primitiveFlushFromCaches() {
return () => {
return this._runtime.flushDispatchCache_(this._runtime.methodSelector_(this._context.self()))
};
}
primitiveFor_(aSymbol) {
return this._primitives.at_(aSymbol);
}
primitiveHash() {
return () => {
return this._runtime.newInteger_(this._runtime.hashFor_(this._context.self()))
};
}
primitiveHostCurrentMilliseconds() {
return () => {
return this._runtime.newInteger_(this._runtime.bootstrapper().millisecondClockValue())
};
}
primitiveHostFixOverrides() {
return () => {
return this._runtime.fixOverrides()
};
}
primitiveHostLoadModule() {
return () => {
return this._runtime.loadModule_(this._context.firstArgument())
};
}
primitiveHostPlatformName() {
return () => {
return this._runtime.newString_(this._runtime.bootstrapper().architectureName())
};
}
primitiveHostReadFile() {
return () => {
return this._runtime.readFile_(this._context.firstArgument())
};
}
primitiveHostSuspendedBecause() {
return () => {
return this.signalSuspension()
};
}
primitiveNew() {
return () => {
return this._runtime.newSlotsOf_(this._context.self())
};
}
primitiveNewBytes() {
let size;
return () => {
size = this._context.firstArgument().value();
return this._runtime.newBytesOf_sized_(this._context.self(), size)
};
}
primitiveNewSized() {
let size;
return () => {
size = this._context.firstArgument().value();
return this._runtime.newOf_sized_(this._context.self(), size)
};
}
primitivePerformWithArguments() {
return () => {
return this.evaluatePerform_in_withArgs_(this._context.firstArgument(), this._context.self(), this._context.secondArgument())
};
}
primitivePrepareForExecution() {
return () => {
return this.prepareForExecuting_(this._context.self())
};
}
primitivePrimeFor() {
return () => {
return this.primitivePrimeFor_(this._context.firstArgument().value())
};
}
primitivePrimeFor_(anInteger) {
let result;
result = ([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 269, 359, 479, 641, 857, 1151, 1549, 2069, 2237, 2423, 2617, 2797, 2999, 3167, 3359, 3539, 3727, 3911, 4441, 4787, 5119, 5471, 5801, 6143, 6521, 6827, 7177, 7517, 7853, 8783, 9601, 10243, 10867, 11549, 12239, 12919, 13679, 14293, 15013, 15731, 17569, 19051, 20443, 21767, 23159, 24611, 25847, 27397, 28571, 30047, 31397, 35771, 38201, 40841, 43973, 46633, 48989, 51631, 54371, 57349, 60139, 62969]).detect_((i) => {
return i._greaterEqualThan(anInteger)
});
return this._runtime.newInteger_(result);
}
primitiveProcessVMStackAt() {
return () => {
return this._stacks.at_(this._context.receiver()).stack().at_(this._context.firstArgument().value())
};
}
primitiveProcessVMStackAtPut() {
return () => {
return this._stacks.at_(this._context.receiver()).stack().at_put_(this._context.firstArgument().value(), this._context.secondArgument())
};
}
primitiveProcessVMStackBP() {
return () => {
return this._runtime.newSmallInteger_(this._context.regBP())
};
}
primitiveProcessVMStackBpAtPut() {
return () => {
return this._stacks.at_(this._context.receiver()).stack().at_put_(this._context.firstArgument().value(), this._context.secondArgument().value())
};
}
primitiveProcessVMStackBufferSize() {
return () => {
return this._runtime.newInteger_(this._stacks.at_(this._context.receiver()).stackSize())
};
}
primitiveProcessVMStackContextSwitchTo() {
return () => {
return this.contextSwitchTo_(this._context.firstArgument())
};
}
primitiveProcessVMStackInitialize() {
return () => {
let _new;
if (this._stacks.isEmpty())
{
_new = this._context
} else {
_new = this.newEvaluationContext()
}
;
return this._stacks.at_put_(this._context.self(), _new)
};
}
primitiveProcessVMStackPcAtPut() {
return () => {
return this._stacks.at_(this._context.receiver()).stack().at_put_(this._context.firstArgument().value(), this._context.secondArgument().value())
};
}
primitiveSMIBitAnd() {
return () => {
return this._runtime.newInteger_(this._context.self().value().bitAnd_(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIBitOr() {
return () => {
return this._runtime.newInteger_(this._context.self().value().bitOr_(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIBitShift() {
return () => {
return this._runtime.newInteger_(this._context.self().value().bitShift_(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIBitXor() {
return () => {
return this._runtime.newInteger_(this._context.self().value().bitXor_(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIEqual() {
return () => {
return this._runtime.booleanFor_(this._context.self().value()._equal(this._context.firstArgument().value()))
};
}
primitiveSMIGreaterEqualThan() {
return () => {
return this._runtime.booleanFor_(this._context.self().value()._greaterEqualThan(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIGreaterThan() {
return () => {
return this._runtime.booleanFor_(this._context.self().value()._greaterThan(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIHighBit() {
return () => {
return this._runtime.newInteger_(this._context.self().value().highBit())
};
}
primitiveSMIIntDiv() {
return () => {
return this._runtime.newInteger_(this._context.self().value()._integerQuotient(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIIntQuot() {
return () => {
return this._runtime.newInteger_(this._context.self().value()._modulo(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIMinus() {
return () => {
return this._runtime.newInteger_((this._context.self().value()-this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMINotEqual() {
return () => {
return this._runtime.booleanFor_(this._context.self().value()._notEqual(this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMIPlus() {
return () => {
return this._runtime.newInteger_((this._context.self().value()+this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSMISize() {
return () => {
return this._runtime.newInteger_(this._context.self().value().bytesCount())
};
}
primitiveSMITimes() {
return () => {
return this._runtime.newInteger_((this._context.self().value()*this._runtime.integerFrom_(this._context.firstArgument())))
};
}
primitiveSetBehavior() {
let receiver;
return () => {
receiver = this._context.self();
receiver.behavior_(this._context.firstArgument());
return receiver
};
}
primitiveSize() {
return () => {
return this._runtime.newInteger_(this._runtime.arrayedSizeOf_(this._context.self()))
};
}
primitiveStringReplaceFromToWithStartingAt() {
let receiver;
return () => {
receiver = this._context.self();
receiver.bytes().replaceFrom_to_with_startingAt_(this._context.firstArgument().value(), this._context.secondArgument().value(), this._context.thirdArgument().bytes(), this._context.fourthArgument().value());
return receiver
};
}
primitiveUnderHash() {
return () => {
return this._runtime.newInteger_(this._context.self().headerHash())
};
}
primitiveUnderIsBytes() {
return () => {
return this._runtime.booleanFor_(this._context.self().isBytes())
};
}
primitiveUnderPointersSize() {
return () => {
return this._runtime.newInteger_(this._context.self().pointersSize())
};
}
primitiveUnderSize() {
return () => {
return this._runtime.newInteger_(this._context.self().size())
};
}
runtime() {
return this._runtime;
}
runtime_(anEggRuntime) {
this._runtime = anEggRuntime;
this._nilObj = this._runtime.nil();
this._trueObj = this._runtime.true();
this._falseObj = this._runtime.false();
_cascade(this, (_recv) => {
_recv.initializeUndermessages();
_recv.initializePrimitives();
_recv.convertUndermessages();
return _recv.convertPrimitives();});
return this;
}
sendLocal_to_(aSymbol, receiver) {
return this.sendLocal_to_with_(aSymbol, receiver, []);
}
signalSuspension() {
let originator, error;
originator = this.contextForProcess_(this._context.firstArgument());
error = _cascade(EggProcessSuspended.new(), (_recv) => {
_recv.process_(this._context.firstArgument());
_recv.exception_(this._context.secondArgument());
return _recv.context_(originator);});
error.signal();
return this;
}
stackSize() {
return this._context.framesCount();
}
true() {
return this._trueObj;
}
underprimitiveBasicAt() {
return (receiver, _arguments) => {
return receiver.slots().at_(_arguments.first().value())
};
}
underprimitiveBasicAtPut() {
return (receiver, _arguments) => {
receiver.slots().at_put_(_arguments.first().value(), _arguments.second());
return _arguments.second()
};
}
underprimitiveBasicFlags() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.headerFlags())
};
}
underprimitiveBasicHash() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.headerHash())
};
}
underprimitiveBasicHashPut() {
return (receiver, _arguments) => {
return receiver.headerHash_(_arguments.first().value())
};
}
underprimitiveBitShiftLeft() {
let result;
return (receiver, _arguments) => {
result = receiver.value().bitShift_(_arguments.first().value());
return this._runtime.newInteger_(result)
};
}
underprimitiveByteAt() {
let result;
return (receiver, _arguments) => {
result = receiver.bytes().at_(_arguments.first().value());
return this._runtime.newInteger_(result)
};
}
underprimitiveByteAtPut() {
return (receiver, _arguments) => {
receiver.bytes().at_put_(_arguments.first().value(), _arguments.second().value());
return _arguments.second()
};
}
underprimitiveHalt() {
return (receiver, _arguments) => {
return receiver.halt()
};
}
underprimitiveIdentityEquals() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(this.isIdentical_to_(receiver, _arguments.first()))
};
}
underprimitiveIsLarge() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.isSmall().not())
};
}
underprimitiveIsSmallInteger() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.isImmediate())
};
}
underprimitiveLargeSize() {
return (receiver, _arguments) => {
if (receiver.isSmall())
{
this.error()
}
;
return this._runtime.newInteger_(receiver.size())
};
}
underprimitiveLeadingZeroBitCount() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(this.underprimitiveLeadingZeroBitCount_(receiver.value()))
};
}
underprimitiveLeadingZeroBitCount_(anInteger) {
let _retval;
if (anInteger._lessThan(0))
{
_retval = 0
} else {
_retval = ((this._runtime.wordSize()*8)-anInteger.highBit())
}
;
return _retval;
}
underprimitiveSMIBitAnd() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.value().bitAnd_(_arguments.first().value()))
};
}
underprimitiveSMIBitOr() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.value().bitOr_(_arguments.first().value()))
};
}
underprimitiveSMIBitShiftLeft() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.value()._shiftLeft(_arguments.first().value()))
};
}
underprimitiveSMIBitShiftRight() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.value()._shiftRight(_arguments.first().value()))
};
}
underprimitiveSMIEquals() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.value()._equal(_arguments.first().value()))
};
}
underprimitiveSMIGreaterEqualThan() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.value()._greaterEqualThan(_arguments.first().value()))
};
}
underprimitiveSMIGreaterThan() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.value()._greaterThan(_arguments.first().value()))
};
}
underprimitiveSMILowerEqualThan() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.value()._lessEqualThan(_arguments.first().value()))
};
}
underprimitiveSMILowerThan() {
return (receiver, _arguments) => {
return this._runtime.booleanFor_(receiver.value()._lessThan(_arguments.first().value()))
};
}
underprimitiveSMIMinus() {
return (receiver, _arguments) => {
return this._runtime.newInteger_((receiver.value()-_arguments.first().value()))
};
}
underprimitiveSMIPlus() {
return (receiver, _arguments) => {
return this._runtime.newInteger_((receiver.value()+_arguments.first().value()))
};
}
underprimitiveSMIQuotientTowardZero() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.value().quo_(_arguments.first().value()))
};
}
underprimitiveSMIRemainderTowardZero() {
return (receiver, _arguments) => {
return this._runtime.newInteger_(receiver.value()._modulo(_arguments.first().value()))
};
}
underprimitiveSMITimes() {
return (receiver, _arguments) => {
return this._runtime.newInteger_((receiver.value()*_arguments.first().value()))
};
}
underprimitiveSmallIntegerByteAt() {
let result;
return (receiver, _arguments) => {
result = receiver.value().byteAt_(_arguments.first().value());
return this._runtime.newInteger_(result)
};
}
underprimitiveSmallSize() {
return (receiver, _arguments) => {
if (!receiver.isSmall())
{
this.error()
}
;
return this._runtime.newInteger_(receiver.size())
};
}
underprimitiveULongAtOffset() {
let result;
return (receiver, _arguments) => {
result = receiver.bytes().unsignedLongAt_((_arguments.second().value()+1));
return this._runtime.newInteger_(result)
};
}
underprimitiveULongAtOffsetPut() {
let value;
return (receiver, _arguments) => {
value = _arguments.second();
receiver.bytes().unsignedLongAt_put_((_arguments.first().value()+1), value.value());
return value
};
}
underprimitiveUShortAtOffset() {
let result;
return (receiver, _arguments) => {
result = receiver.bytes().unsignedShortAt_((_arguments.second().value()+1));
return this._runtime.newInteger_(result)
};
}
underprimitiveUShortAtOffsetPut() {
let value;
return (receiver, _arguments) => {
value = _arguments.second();
receiver.bytes().unsignedShortAt_put_((_arguments.first().value()+1), value.value());
return value
};
}
}
export default EggEvaluator