Exemple #1
0
        /// <summary>
        /// Emit the end cases for a short-circuit
        /// </summary>
        /// <param name="info"></param>
        /// <param name="ilg"></param>
        /// <param name="endLabel"></param>
        private static void EmitTerminals(ShortCircuitInfo info, FleeILGenerator ilg, Label endLabel)
        {
            // Emit the false case if it was used
            if (info.HasLabel(OurFalseTerminalKey) == true)
            {
                Label falseLabel = info.FindLabel(OurFalseTerminalKey);

                // Mark the label and note its position
                ilg.MarkLabel(falseLabel);

                ilg.Emit(OpCodes.Ldc_I4_0);

                // If we also have a true terminal, then skip over it
                if (info.HasLabel(OurTrueTerminalKey) == true)
                {
                    // only 1-3 opcodes, always a short branch
                    ilg.Emit(OpCodes.Br_S, endLabel);
                }
            }

            // Emit the true case if it was used
            if (info.HasLabel(OurTrueTerminalKey) == true)
            {
                Label trueLabel = info.FindLabel(OurTrueTerminalKey);

                // Mark the label and note its position
                ilg.MarkLabel(trueLabel);

                ilg.Emit(OpCodes.Ldc_I4_1);
            }
        }
Exemple #2
0
 private static Label GetLabel(object key, FleeILGenerator ilg, ShortCircuitInfo info)
 {
     if (info.HasLabel(key))
     {
         return(info.FindLabel(key));
     }
     return(info.AddLabel(key, ilg.DefineLabel()));
 }
Exemple #3
0
        private static void EmitOperand(ExpressionElement operand, ShortCircuitInfo info, FleeILGenerator ilg, IServiceProvider services)
        {
            // Is this operand the target of a label?
            if (info.HasLabel(operand) == true)
            {
                // Yes, so mark it
                Label leftLabel = info.FindLabel(operand);
                ilg.MarkLabel(leftLabel);
            }

            // Emit the operand
            operand.Emit(ilg, services);
        }