void ICondition.Compile(MethodEmitter emitter) { // The object was safely cast to be the conditionals type // If it's null, then the type cast didn't work... emitter.LoadNull(); emitter.Compare(OpCodes.Ceq); emitter.LogicalNot(); }
public override void Compile(MethodEmitter emitter) { emitter.Chain(m_Property); bool inverse = false; bool couldCompare = emitter.CompareTo(1, () => { m_Value.Load(emitter); }); if (couldCompare) { emitter.Load(0); switch (m_Operator) { case ComparisonOperator.Equal: emitter.Compare(OpCodes.Ceq); break; case ComparisonOperator.NotEqual: emitter.Compare(OpCodes.Ceq); inverse = true; break; case ComparisonOperator.Greater: emitter.Compare(OpCodes.Cgt); break; case ComparisonOperator.GreaterEqual: emitter.Compare(OpCodes.Clt); inverse = true; break; case ComparisonOperator.Lesser: emitter.Compare(OpCodes.Clt); break; case ComparisonOperator.LesserEqual: emitter.Compare(OpCodes.Cgt); inverse = true; break; default: throw new InvalidOperationException("Invalid comparison operator."); } } else { // This type is -not- comparable // We can only support == and != operations m_Value.Load(emitter); switch (m_Operator) { case ComparisonOperator.Equal: emitter.Compare(OpCodes.Ceq); break; case ComparisonOperator.NotEqual: emitter.Compare(OpCodes.Ceq); inverse = true; break; case ComparisonOperator.Greater: case ComparisonOperator.GreaterEqual: case ComparisonOperator.Lesser: case ComparisonOperator.LesserEqual: throw new InvalidOperationException("Property does not support relational comparisons."); default: throw new InvalidOperationException("Invalid operator."); } } if (m_Not != inverse) { emitter.LogicalNot(); } }
public override void Compile( MethodEmitter emitter ) { emitter.Chain( m_Property ); bool inverse = false; bool couldCompare = emitter.CompareTo( 1, delegate() { m_Value.Load( emitter ); } ); if ( couldCompare ) { emitter.Load( 0 ); switch ( m_Operator ) { case ComparisonOperator.Equal: emitter.Compare( OpCodes.Ceq ); break; case ComparisonOperator.NotEqual: emitter.Compare( OpCodes.Ceq ); inverse = true; break; case ComparisonOperator.Greater: emitter.Compare( OpCodes.Cgt ); break; case ComparisonOperator.GreaterEqual: emitter.Compare( OpCodes.Clt ); inverse = true; break; case ComparisonOperator.Lesser: emitter.Compare( OpCodes.Clt ); break; case ComparisonOperator.LesserEqual: emitter.Compare( OpCodes.Cgt ); inverse = true; break; default: throw new InvalidOperationException( "Invalid comparison operator." ); } } else { // This type is -not- comparable // We can only support == and != operations m_Value.Load( emitter ); switch ( m_Operator ) { case ComparisonOperator.Equal: emitter.Compare( OpCodes.Ceq ); break; case ComparisonOperator.NotEqual: emitter.Compare( OpCodes.Ceq ); inverse = true; break; case ComparisonOperator.Greater: case ComparisonOperator.GreaterEqual: case ComparisonOperator.Lesser: case ComparisonOperator.LesserEqual: throw new InvalidOperationException( "Property does not support relational comparisons." ); default: throw new InvalidOperationException( "Invalid operator." ); } } if ( m_Not != inverse ) emitter.LogicalNot(); }