Implement collapse operators.
This commit is contained in:
@@ -95,6 +95,14 @@ namespace Cryville.Crtr {
|
|||||||
else throw new KeyNotFoundException(string.Format("Undefined operator {0}({1})", name, pc));
|
else throw new KeyNotFoundException(string.Format("Undefined operator {0}({1})", name, pc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool Collapse(string name, PdtVariableMemory param) {
|
||||||
|
switch (name) {
|
||||||
|
case "&": return param.AsNumber() == 0;
|
||||||
|
case "|": return param.AsNumber() != 0;
|
||||||
|
default: throw new KeyNotFoundException(string.Format("Undefined collapse operator {0}", name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ChartEvent ContextEvent { private get; set; }
|
public ChartEvent ContextEvent { private get; set; }
|
||||||
public Transform ContextTransform { private get; set; }
|
public Transform ContextTransform { private get; set; }
|
||||||
public Judge ContextJudge { private get; set; }
|
public Judge ContextJudge { private get; set; }
|
||||||
@@ -120,13 +128,11 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
static PdtEvaluator() {
|
static PdtEvaluator() {
|
||||||
_shortops.Add(new OperatorSignature("*", 2), new op_mul_2());
|
_shortops.Add(new OperatorSignature("*", 2), new op_mul_2());
|
||||||
_shortops.Add(new OperatorSignature("&", 2), new op_mul_2());
|
|
||||||
_shortops.Add(new OperatorSignature("/", 2), new op_div_2());
|
_shortops.Add(new OperatorSignature("/", 2), new op_div_2());
|
||||||
_shortops.Add(new OperatorSignature("%", 2), new op_mod_2());
|
_shortops.Add(new OperatorSignature("%", 2), new op_mod_2());
|
||||||
|
|
||||||
_shortops.Add(new OperatorSignature("+", 1), new op_add_1());
|
_shortops.Add(new OperatorSignature("+", 1), new op_add_1());
|
||||||
_shortops.Add(new OperatorSignature("+", 2), new op_add_2());
|
_shortops.Add(new OperatorSignature("+", 2), new op_add_2());
|
||||||
_shortops.Add(new OperatorSignature("|", 2), new op_add_2());
|
|
||||||
_shortops.Add(new OperatorSignature("-", 1), new op_sub_1());
|
_shortops.Add(new OperatorSignature("-", 1), new op_sub_1());
|
||||||
_shortops.Add(new OperatorSignature("-", 2), new op_sub_2());
|
_shortops.Add(new OperatorSignature("-", 2), new op_sub_2());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user