Fix behaviour on parameter overflow.
This commit is contained in:
@@ -186,7 +186,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
protected abstract PdtOperator GetOperator(PdtOperatorSignature sig);
|
protected abstract PdtOperator GetOperator(PdtOperatorSignature sig);
|
||||||
unsafe void Operate(PdtOperator op, int pc, bool noset = false) {
|
unsafe void Operate(PdtOperator op, int pc, bool noset = false) {
|
||||||
fixed (byte* pmem = _mem) {
|
fixed (byte* pmem = _mem) {
|
||||||
op.Begin(this);
|
op.Begin(this, pc);
|
||||||
for (int i = 0; i < pc; i++) {
|
for (int i = 0; i < pc; i++) {
|
||||||
var frame = _stack[--_framecount];
|
var frame = _stack[--_framecount];
|
||||||
op.LoadOperand(new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length));
|
op.LoadOperand(new PdtVariableMemory(frame.Type, pmem + frame.Offset, frame.Length));
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Cryville.Common.Pdt {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The count of the operands loaded.
|
/// The count of the operands loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int LoadedOperandCount { get { return _pc - _loadindex; } }
|
protected int LoadedOperandCount { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the operand at the specified index.
|
/// Gets the operand at the specified index.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -35,13 +35,13 @@ namespace Cryville.Common.Pdt {
|
|||||||
}
|
}
|
||||||
PdtEvaluatorBase _etor;
|
PdtEvaluatorBase _etor;
|
||||||
bool _rfreq = true;
|
bool _rfreq = true;
|
||||||
internal void Begin(PdtEvaluatorBase etor) {
|
internal void Begin(PdtEvaluatorBase etor, int pc) {
|
||||||
_etor = etor;
|
_etor = etor;
|
||||||
_loadindex = _pc;
|
_loadindex = LoadedOperandCount = pc;
|
||||||
}
|
}
|
||||||
internal void LoadOperand(PdtVariableMemory mem) {
|
internal void LoadOperand(PdtVariableMemory mem) {
|
||||||
if (_loadindex == 0) return;
|
if (--_loadindex >= _pc) return;
|
||||||
_operands[--_loadindex] = mem;
|
_operands[_loadindex] = mem;
|
||||||
}
|
}
|
||||||
internal void Call(byte* prmem, bool noset) {
|
internal void Call(byte* prmem, bool noset) {
|
||||||
_prmem = prmem;
|
_prmem = prmem;
|
||||||
|
|||||||
Reference in New Issue
Block a user