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

Parse() public static method

Parses conditional expressions
public static Parse ( CseObject leftOp, CseObject rightOp, CondType type ) : CseObject
leftOp CseObject Left operand
rightOp CseObject Right operand
type CondType Conditional operator type
return CseObject
		public static CseObject Parse(CseObject leftOp, CseObject rightOp, CondType type) {
			CseObject obj = new CseObject(null) { IsLiteral = leftOp.IsLiteral && rightOp.IsLiteral };

			try {
				switch (type) {
					case CondType.EQ:
						obj.Value = leftOp.Value == rightOp.Value;
						break;
					case CondType.NEQ:
						obj.Value = leftOp.Value != rightOp.Value;
						break;
					case CondType.GT:
						obj.Value = leftOp.Value > rightOp.Value;
						break;
					case CondType.GTE:
						obj.Value = leftOp.Value >= rightOp.Value;
						break;
					case CondType.LT:
						obj.Value = leftOp.Value < rightOp.Value;
						break;
					case CondType.LTE:
						obj.Value = leftOp.Value <= rightOp.Value;
						break;
					default:
						throw new System.NotImplementedException("Not implemented.");
				}
			}
			catch {
				// TODO: Fill this out!
			}

			return obj;
		}