public override dynamic Calc(Dictionary <string, dynamic> variables) { if (!_wasСalculated || !ConstOnly) { _cachedValue = _unOp switch { UnOp.Plus => _childOperator == null ? +Value : +_childOperator.Calc(variables), UnOp.Minus => _childOperator == null ? -Value : -_childOperator.Calc(variables), UnOp.Not => _childOperator == null ? !Value : !_childOperator.Calc(variables), UnOp.Tilde => _childOperator == null ? ~Value : ~_childOperator.Calc(variables), _ => throw new NotImplementedException() }; } _wasСalculated = true; return(_cachedValue); }
public override dynamic Calc(Dictionary <string, dynamic> variables) { if (!_wasСalculated || !ConstOnly) { if (_variableName != null) { if (!variables.TryGetValue(_variableName, out var value)) { throw new NullReferenceException(); } Value = value; } _cachedValue = _childOperator == null ? Value : _childOperator.Calc(variables); } _wasСalculated = true; return(_cachedValue); }