Пример #1
0
        internal void LazyEmit_idiv()
        {
            // we need to special case dividing by -1, because the CLR div instruction
            // throws an OverflowException when dividing Int32.MinValue by -1, and
            // Java just silently overflows
            ConstIntExpr v = PeekStack() as ConstIntExpr;

            if (v != null)
            {
                if (v.i == -1)
                {
                    PopStack();
                    Emit(OpCodes.Neg);
                }
                else
                {
                    Emit(OpCodes.Div);
                }
            }
            else
            {
                Emit(OpCodes.Dup);
                Emit(OpCodes.Ldc_I4_M1);
                CodeEmitterLabel label = DefineLabel();
                Emit(OpCodes.Bne_Un_S, label);
                Emit(OpCodes.Pop);
                Emit(OpCodes.Neg);
                CodeEmitterLabel label2 = DefineLabel();
                Emit(OpCodes.Br_S, label2);
                MarkLabel(label);
                Emit(OpCodes.Div);
                MarkLabel(label2);
            }
        }
Пример #2
0
        internal void LazyEmitAnd_I4(int v2)
        {
            ConstIntExpr v1 = PeekStack() as ConstIntExpr;

            if (v1 != null)
            {
                PopStack();
                LazyEmitLdc_I4(v1.i & v2);
            }
            else
            {
                LazyEmitLdc_I4(v2);
                Emit(OpCodes.And);
            }
        }