public static void StackCheckBinary(ValueStack check) { check.Pop(); check.Pop(); check.Push(new UnionValue(true)); }
public static void Eval(ValueStack stack, EOperatorType op) { if (op == EOperatorType.Unary_Negation) { Negate(stack, op); return; } if (stack.Size < 2 || op == EOperatorType.INVALID) { stack.Push(UnionValue.Error); return; } var rhs = stack.Pop(); var lhs = stack.Pop(); stack.Push(EvaluateImpl(lhs, rhs, op)); }
public static void Negate(ValueStack stack, EOperatorType op) { if (stack.Size < 1) { stack.Push(UnionValue.Error); return; } var rhs = stack.Pop(); if (!rhs.IsError && (rhs.Type == EValType.BOOL)) { stack.Push(new UnionValue(!rhs.AsBool)); } else { stack.Push(UnionValue.Error); return; } }
public void DBGStackCheck(Context ctx, ValueStack stack) { switch (VType) { case EValueTypes.CONST: stack.Push(_Val); break; case EValueTypes.OP_UNARY: var vl = stack.Pop(); if (vl.Type == EValType.BOOL) { stack.Push(!vl.AsBool); } else { stack.Push(UnionValue.Error); } break; case EValueTypes.OP_BINARY: Operator.StackCheckBinary(stack); break; // TODO improve validation case EValueTypes.GET_VAR_OR_CALL: if (null != ctx) { var val2 = ctx.Vars.Contains(_Val.AsString); stack.Push(val2); } else { stack.Push(true); } break; } }