Fix behaviour on parameter overflow.

This commit is contained in:
2023-02-17 21:11:38 +08:00
parent f91aacd78e
commit 2d4087dc89
2 changed files with 6 additions and 6 deletions

View File

@@ -186,7 +186,7 @@ namespace Cryville.Common.Pdt {
protected abstract PdtOperator GetOperator(PdtOperatorSignature sig);
unsafe void Operate(PdtOperator op, int pc, bool noset = false) {
fixed (byte* pmem = _mem) {
op.Begin(this);
op.Begin(this, pc);
for (int i = 0; i < pc; i++) {
var frame = _stack[--_framecount];
op.LoadOperand(new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length));

View File

@@ -11,7 +11,7 @@ namespace Cryville.Common.Pdt {
/// <summary>
/// The count of the operands loaded.
/// </summary>
protected int LoadedOperandCount { get { return _pc - _loadindex; } }
protected int LoadedOperandCount { get; private set; }
/// <summary>
/// Gets the operand at the specified index.
/// </summary>
@@ -35,13 +35,13 @@ namespace Cryville.Common.Pdt {
}
PdtEvaluatorBase _etor;
bool _rfreq = true;
internal void Begin(PdtEvaluatorBase etor) {
internal void Begin(PdtEvaluatorBase etor, int pc) {
_etor = etor;
_loadindex = _pc;
_loadindex = LoadedOperandCount = pc;
}
internal void LoadOperand(PdtVariableMemory mem) {
if (_loadindex == 0) return;
_operands[--_loadindex] = mem;
if (--_loadindex >= _pc) return;
_operands[_loadindex] = mem;
}
internal void Call(byte* prmem, bool noset) {
_prmem = prmem;