Fix collapse operators and boolean property operator.

This commit is contained in:
2022-11-14 11:28:10 +08:00
parent 7fca09ff49
commit 318a6705be
2 changed files with 3 additions and 3 deletions

View File

@@ -92,8 +92,8 @@ namespace Cryville.Crtr {
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
protected override bool Collapse(int name, PdtVariableMemory param) {
if (name == _colop_and) return param.AsNumber() <= 0;
else if (name == _colop_or) return param.AsNumber() > 0;
if (name == _colop_and) return param.Type == PdtInternalType.Number && param.AsNumber() <= 0;
else if (name == _colop_or) return param.Type != PdtInternalType.Number || param.AsNumber() > 0;
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
}

View File

@@ -21,7 +21,7 @@ namespace Cryville.Crtr {
readonly Action<bool> _cb;
public Boolean(Action<bool> cb) { _cb = cb; }
protected override void Execute() {
_cb(GetOperand(0).AsNumber() != 0);
_cb(GetOperand(0).AsNumber() > 0);
}
}
public class Integer : PropOp {