Fix collapse operators and boolean property operator.
This commit is contained in:
@@ -92,8 +92,8 @@ namespace Cryville.Crtr {
|
|||||||
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
|
static readonly int _colop_and = IdentifierManager.SharedInstance.Request("&");
|
||||||
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
|
static readonly int _colop_or = IdentifierManager.SharedInstance.Request("|");
|
||||||
protected override bool Collapse(int name, PdtVariableMemory param) {
|
protected override bool Collapse(int name, PdtVariableMemory param) {
|
||||||
if (name == _colop_and) return param.AsNumber() <= 0;
|
if (name == _colop_and) return param.Type == PdtInternalType.Number && param.AsNumber() <= 0;
|
||||||
else if (name == _colop_or) return 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));
|
else throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ namespace Cryville.Crtr {
|
|||||||
readonly Action<bool> _cb;
|
readonly Action<bool> _cb;
|
||||||
public Boolean(Action<bool> cb) { _cb = cb; }
|
public Boolean(Action<bool> cb) { _cb = cb; }
|
||||||
protected override void Execute() {
|
protected override void Execute() {
|
||||||
_cb(GetOperand(0).AsNumber() != 0);
|
_cb(GetOperand(0).AsNumber() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Integer : PropOp {
|
public class Integer : PropOp {
|
||||||
|
Reference in New Issue
Block a user