From 49883bfce369f8a55006352efa2b3dd30259f7cc Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 27 Oct 2019 01:45:34 +0200 Subject: [PATCH] ZoneCodeGenerator: Add bitwise and, or, xor operations --- .../Domain/Evaluation/OperationType.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/ZoneCodeGenerator/Domain/Evaluation/OperationType.cs b/src/ZoneCodeGenerator/Domain/Evaluation/OperationType.cs index a91d217a..854b04b2 100644 --- a/src/ZoneCodeGenerator/Domain/Evaluation/OperationType.cs +++ b/src/ZoneCodeGenerator/Domain/Evaluation/OperationType.cs @@ -17,8 +17,11 @@ namespace ZoneCodeGenerator.Domain.Evaluation BitwiseShift = 3, RelationalGreaterLessThan = 4, RelationalEquals = 5, - LogicalAnd = 6, - LogicalOr = 7 + BitwiseAnd = 6, + BitwiseXor = 7, + BitwiseOr = 8, + LogicalAnd = 9, + LogicalOr = 10 } public delegate int EvaluationFunction(int operand1, int operand2); @@ -69,6 +72,24 @@ namespace ZoneCodeGenerator.Domain.Evaluation (operand1, operand2) => operand1 % operand2 ); + public static OperationType OperationBitwiseAnd = new OperationType( + "&", + OperationPrecedence.BitwiseAnd, + (operand1, operand2) => operand1 & operand2 + ); + + public static OperationType OperationBitwiseXor = new OperationType( + "^", + OperationPrecedence.BitwiseXor, + (operand1, operand2) => operand1 ^ operand2 + ); + + public static OperationType OperationBitwiseOr = new OperationType( + "|", + OperationPrecedence.BitwiseOr, + (operand1, operand2) => operand1 | operand2 + ); + public static OperationType OperationShiftLeft = new OperationType( "<<", OperationPrecedence.BitwiseShift,