Exemple #1
0
        protected ObjectDef EmitEqualityExpression(CParser.EqualityExpressionContext equalityExpression)
        {
            ObjectDef returnObjectDef = null;

            if (equalityExpression.relationalExpression() != null)
            {
                returnObjectDef = EmitRelationalExpression(equalityExpression.relationalExpression());
            }

            if (equalityExpression.relationalExpression() != null &&
                equalityExpression.equalityExpression() != null)
            {
                var equalityObj = EmitEqualityExpression(equalityExpression.equalityExpression());

                equalityObj.Load();
                returnObjectDef.Load();

                if (equalityExpression.Equal() != null)
                {
                    _generatorIL.Emit(OpCodes.Ceq);
                }
                else if (equalityExpression.NotEqual() != null)
                {
                    var zero = new ValueObjectDef(typeof(int), 0);

                    _generatorIL.Emit(OpCodes.Ceq);
                    zero.Load();
                    _generatorIL.Emit(OpCodes.Ceq);
                }

                returnObjectDef = LocalObjectDef.AllocateLocal(typeof(int));
            }

            return(returnObjectDef);
        }
        public override void ExitEqualityExpression(CParser.EqualityExpressionContext context)
        {
            if (context.equalityExpression() != null)
            {
                string operation = context.GetText().Substring(context.equalityExpression().GetText().Length, 2);

                if (operation == "==")
                {
                    //equalityExpression '==' relationalExpression
                    SafeCall(context, CExpression.EqualToOperator);
                }
                else
                {
                    //equalityExpression '!=' relationalExpression
                    SafeCall(context, CExpression.NotEqualToOperator);
                }
            }
        }