CSE.Exps.BitwiseExp.Parse C# (CSharp) Method

Parse() public static method

Parses bitwise expressions
public static Parse ( CseObject leftOp, CseObject rightOp, BitwiseType type ) : CseObject
leftOp CseObject Left operand
rightOp CseObject Right operand
type BitwiseType Bitwise expression type
return CseObject
		public static CseObject Parse(CseObject leftOp, CseObject rightOp, BitwiseType type) {
			CseObject obj = null;

			if (type == BitwiseType.NOT) {
				obj = new CseObject(null) { IsLiteral = leftOp.IsLiteral };
			}
			else {
				obj = new CseObject(null) { IsLiteral = leftOp.IsLiteral && rightOp.IsLiteral };
			}

			try {
				switch (type) {
					case BitwiseType.AND:
						obj.Value = leftOp.Value & rightOp.Value;
						break;
					case BitwiseType.OR:
						obj.Value = leftOp.Value | rightOp.Value;
						break;
					case BitwiseType.NOT:
						obj.Value = ~leftOp.Value;
						break;
					case BitwiseType.SHL:
						obj.Value = leftOp.Value << rightOp.Value;
						break;
					case BitwiseType.SHR:
						obj.Value = leftOp.Value >> rightOp.Value;
						break;
					default:
						throw new System.NotImplementedException("Not implemented.");
				}
			}
			catch {
				// TODO: Fill this out!
			}

			return obj;
		}
	}
BitwiseExp