ZoneCodeGenerator: Add helper methods to Operation for the template engine to know whether parenthesis are required or not

This commit is contained in:
Jan 2019-11-14 14:59:21 +01:00
parent 8c303d394d
commit f80d661c1b

View File

@ -9,7 +9,13 @@ namespace ZoneCodeGenerator.Domain.Evaluation
class Operation : IEvaluation class Operation : IEvaluation
{ {
public IEvaluation Operand1 { get; } public IEvaluation Operand1 { get; }
public bool Operand1NeedsParenthesis => Operand1 is Operation operation1 &&
operation1.OperationType.Precedence > OperationType.Precedence;
public IEvaluation Operand2 { get; } public IEvaluation Operand2 { get; }
public bool Operand2NeedsParenthesis => Operand2 is Operation operation2 &&
operation2.OperationType.Precedence > OperationType.Precedence;
public OperationType OperationType { get; } public OperationType OperationType { get; }
public bool IsStatic => Operand1.IsStatic && Operand2.IsStatic; public bool IsStatic => Operand1.IsStatic && Operand2.IsStatic;