-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
SubAssign.cs
41 lines (34 loc) · 1.35 KB
/
SubAssign.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) Dmytro Kyshchenko. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Diagnostics.CodeAnalysis;
namespace xFunc.Maths.Expressions.Programming;
/// <summary>
/// Represents the "-=" operator.
/// </summary>
public class SubAssign : VariableBinaryExpression
{
/// <summary>
/// Initializes a new instance of the <see cref="SubAssign"/> class.
/// </summary>
/// <param name="variable">The variable.</param>
/// <param name="exp">The expression.</param>
public SubAssign(Variable variable, IExpression exp)
: base(variable, exp)
{
}
/// <inheritdoc />
protected override object Execute(NumberValue variableValue, NumberValue value)
=> variableValue - value;
/// <inheritdoc />
protected override TResult AnalyzeInternal<TResult>(IAnalyzer<TResult> analyzer)
=> analyzer.Analyze(this);
/// <inheritdoc />
[ExcludeFromCodeCoverage]
protected override TResult AnalyzeInternal<TResult, TContext>(
IAnalyzer<TResult, TContext> analyzer,
TContext context)
=> analyzer.Analyze(this, context);
/// <inheritdoc />
public override IExpression Clone(Variable? variable = null, IExpression? value = null)
=> new SubAssign(variable ?? Variable, value ?? Value);
}