Exemplo n.º 1
0
        public override void Evaluate(IContext context)
        {
            if (_assigntype != TokenEnum.NOTHING)
            {
                Val v = _scope.GetVar(this, _varName);

                switch (_assigntype)
                {
                case TokenEnum.ASSIGN:
                    v = _value?.Evaluate(context) ?? Val.NULL;
                    break;

                case TokenEnum.PLUSASSIGN:
                    v = Ops.Do(BOp.ADD, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;

                case TokenEnum.MINUSASSIGN:
                    v = Ops.Do(BOp.SUBTRACT, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;

                case TokenEnum.ASTERISKASSIGN:
                    v = Ops.Do(BOp.MULTIPLY, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;

                case TokenEnum.SLASHASSIGN:
                    v = Ops.Do(BOp.DIVIDE, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;

                case TokenEnum.PERCENTASSIGN:
                    v = Ops.Do(BOp.MODULUS, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;

                case TokenEnum.AMPASSIGN:
                    v = Ops.Do(BOp.LOGICAL_AND, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;

                case TokenEnum.PIPEASSIGN:
                    v = Ops.Do(BOp.LOGICAL_OR, v, _value?.Evaluate(context) ?? Val.NULL);;
                    break;
                }

                if (_varExpr is IndexedExpression indexexpr)
                {
                    indexexpr.Evaluate(context);
                    _scope.SetVar(this, _varName, v, indexexpr._indices);
                }
                else
                {
                    _scope.SetVar(this, _varName, v);
                }
            }
            else
            {
                _value?.Evaluate(context);
            }
        }
Exemplo n.º 2
0
 public override Val Evaluate(IContext context)
 {
     return(_scope.GetVar(this, varName));
 }