public override Val Evaluate(IContext context) { if (_set.Count == 0) { return(_first.Evaluate(context)); } Val result = _first.Evaluate(context); if (result.Type != typeof(bool)) { throw new EvalException(this, Resource.Strings.Error_EvalException_NonBooleanConditional.F(result.Value)); } if ((bool)result) { foreach (CExpression _expr in _set) { Val adden = _expr.Evaluate(context); try { result = Ops.Do(BOp.LOGICAL_AND, result, adden); } catch (Exception ex) { throw new EvalException(this, "&&", result, adden, ex); } if (!(bool)result) { break; } } } return(result); }
public override Val Evaluate(IContext context) { Val result = _first.Evaluate(context); foreach (CExpression _expr in _set.Keys) { Val adden = _expr.Evaluate(context); switch (_set[_expr]) { case TokenEnum.ASTERISK: try { result = Ops.Do(BOp.MULTIPLY, result, adden); } catch (Exception ex) { throw new EvalException(this, "*", result, adden, ex); } break; case TokenEnum.SLASH: try { result = Ops.Do(BOp.DIVIDE, result, adden); } catch (Exception ex) { throw new EvalException(this, "/", result, adden, ex); } break; case TokenEnum.PERCENT: try { result = Ops.Do(BOp.MODULUS, result, adden); } catch (Exception ex) { throw new EvalException(this, "%", result, adden, ex); } break; } } return(result); }
public override Val Evaluate(IContext context) { Val result = _first.Evaluate(context); Val adden = _second.Evaluate(context); if (isUnequal) { try { result = Ops.IsNotEqual(result, adden); } catch (Exception ex) { throw new EvalException(this, "!=", result, adden, ex); } } else { try { result = Ops.IsEqual(result, adden); } catch (Exception ex) { throw new EvalException(this, "==", result, adden, ex); } } return(result); }
public override Val Evaluate(IContext context) { Val result = _question.Evaluate(context); if (result.Type != typeof(bool)) { throw new EvalException(this, Resource.Strings.Error_EvalException_NonBooleanConditional.F(result.Value)); } if ((bool)result) { return(_true?.Evaluate(context) ?? new Val()); } else { return(_false?.Evaluate(context) ?? new Val()); } }
public override Val Evaluate(IContext context) { Val result = _primary.Evaluate(context); switch (_type) { default: case TokenEnum.PLUS: case TokenEnum.NOTHING: return(result); case TokenEnum.MINUS: try { return(Ops.Do(UOp.NEGATION, result)); } catch (Exception ex) { throw new EvalException(this, "-", result, ex); } case TokenEnum.NOT: try { return(Ops.Do(UOp.LOGICAL_NOT, result)); } catch (Exception ex) { throw new EvalException(this, "!", result, ex); } } }
public override Val Evaluate(IContext context) { Val result = _first.Evaluate(context); foreach (CExpression _expr in _set.Keys) { Val adden = _expr.Evaluate(context); switch (_set[_expr]) { case TokenEnum.PLUS: try { result = Ops.Do(BOp.ADD, result, adden); } catch (Exception ex) { throw new EvalException(this, "+", result, adden, ex); } break; case TokenEnum.MINUS: try { result = Ops.Do(BOp.SUBTRACT, result, adden);; } catch (Exception ex) { throw new EvalException(this, "-", result, adden, ex); } break; } } return(result); }
public override Val Evaluate(IContext context) { Val v1 = _first.Evaluate(context); Val v2 = _second.Evaluate(context); switch (_type) { case TokenEnum.LESSTHAN: try { return(Ops.Do(BOp.LESS_THAN, v1, v2)); } catch (Exception ex) { throw new EvalException(this, "<", v1, v2, ex); } case TokenEnum.GREATERTHAN: try { return(Ops.Do(BOp.MORE_THAN, v1, v2)); } catch (Exception ex) { throw new EvalException(this, ">", v1, v2, ex); } case TokenEnum.LESSEQUAL: try { return(Ops.Do(BOp.LESS_THAN_OR_EQUAL_TO, v1, v2)); } catch (Exception ex) { throw new EvalException(this, "<=", v1, v2, ex); } case TokenEnum.GREATEREQUAL: try { return(Ops.Do(BOp.MORE_THAN_OR_EQUAL_TO, v1, v2)); } catch (Exception ex) { throw new EvalException(this, ">=", v1, v2, ex); } default: return(v1); } }
public override Val Evaluate(IContext context) { Val c = _expression.Evaluate(context); if (_indices_expr == null) { return(c); } for (int i = 0; i < _indices_expr.Length; i++) { for (int i2 = 0; i2 < _indices_expr[i].Length; i2++) { Val v = _indices_expr[i][i2].Evaluate(context); try { _indices[i][i2] = v.Cast <int>(); } catch { throw new EvalException(this, Resource.Strings.Error_EvalException_InvalidArrayIndex); } } } Val cv = c; foreach (int[] i2 in _indices) { cv = Ops.GetIndex(cv, i2); } return(cv); /* * Array a; * try * { * a = c.Cast<Array>(); * } * catch * { * throw new EvalException(this, Resource.Strings.Error_EvalException_IndexOnNonArray.F(c)); * } * * try * { * object o = a; * foreach (int[] i2 in _indices) * { * a = (Array)o; * o = a.GetValue(i2); * } * * return new Val(o); * } * catch (IndexOutOfRangeException) * { * int len = a?.Length ?? 0; * throw new EvalException(this, Resource.Strings.Error_EvalException_IndexOutOfRange.F(_indices.Length, len)); * } * catch * { * throw new EvalException(this, Resource.Strings.Error_EvalException_IndexOnNonArray.F(c)); * } */ }
public override Val Evaluate(IContext context) { return(_child.Evaluate(context)); }
public override Val Evaluate(IContext context) { return(_expr.Evaluate(context)); }