|
@@ -47,8 +47,6 @@ module.exports = class Computer {
|
|
LESS_THAN: 1,
|
|
LESS_THAN: 1,
|
|
};
|
|
};
|
|
|
|
|
|
- this.parameterMode = ComputerParameterMode.POSITION_MODE;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Whether the Execute loop should skip moving the pointer after running the opcode
|
|
* Whether the Execute loop should skip moving the pointer after running the opcode
|
|
*
|
|
*
|
|
@@ -230,21 +228,6 @@ module.exports = class Computer {
|
|
return status;
|
|
return status;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Parse operands based on the current parameter mode
|
|
|
|
- *
|
|
|
|
- * When the int computer is in Immediate Mode, the values are returned
|
|
|
|
- * as-is. When in Position Mode, the operands are used as memory
|
|
|
|
- * addresses, and the values at those addresses are returned instead.
|
|
|
|
- *
|
|
|
|
- * @private
|
|
|
|
- * @returns {number[]} The parsed list of operands
|
|
|
|
- */
|
|
|
|
- _ParseOperands(...operands) {
|
|
|
|
- if (this.parameterMode == ComputerParameterMode.IMMEDIATE_MODE) { return operands; }
|
|
|
|
- return operands.map((operand) => this.stack.Get(operand));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Execute the Add opcode
|
|
* Execute the Add opcode
|
|
*
|
|
*
|
|
@@ -548,19 +531,6 @@ module.exports = class Computer {
|
|
this.awaitingInput = false;
|
|
this.awaitingInput = false;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Sets the computer's memory to a new stack
|
|
|
|
- *
|
|
|
|
- * Note: This resets the computer's initial memory, so `Reset` will use this value
|
|
|
|
- *
|
|
|
|
- * @param {number[]} stack The new memory stack for the computer
|
|
|
|
- * @returns {void}
|
|
|
|
- */
|
|
|
|
- SetMemory(stack) {
|
|
|
|
- this._initialMemory = DeepClone(stack);
|
|
|
|
- this.stack = new Stack(stack);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Throws an error with the given message and a memory dump
|
|
* Throws an error with the given message and a memory dump
|
|
*
|
|
*
|