public override VariableValue Evaluate(IVariableStore variables) { var left = Left.Evaluate(variables); var right = Right.Evaluate(variables); if (left.HasList) { var result = left.List.AddVariable(right); if (result != SetVariableResult.Success) { switch (result) { case SetVariableResult.NotFound: throw new ExpressionEvaluationException(_missingAddException, Left); case SetVariableResult.ReadOnly: throw new ExpressionEvaluationException(_readOnlyAddException, Left); case SetVariableResult.TypeMismatch: throw new ExpressionEvaluationException(_mismatchedAddException, Left, right.Type); } } return(right); } else { var value = VariableHandler.Add(left, right); if (value.IsEmpty) { throw TypeMismatch(left.Type, right.Type); } return(Assign(variables, value)); } }
public override VariableValue Evaluate(IVariableStore variables) { var left = Left.Evaluate(variables); var right = Right.Evaluate(variables); var value = VariableHandler.Add(left, right); if (value.IsEmpty) { throw TypeMismatch(left.Type, right.Type); } return(value); }
public override VariableValue Evaluate(IVariableStore variables) { var result = Right.Evaluate(variables); var value = VariableHandler.Add(result, VariableValue.Create(-1)); if (value.IsEmpty) { throw TypeMismatch(result.Type); } if (Right is IAssignableOperation assignable) { assignable.SetValue(variables, value); return(value); } else { throw new ExpressionEvaluationException(_invalidAssignmentException, Right); } }