Example #1
0
        private static Label GetShortCircuitLabel(AndOrElement current, ShortCircuitInfo info, FleeIlGenerator ilg)
        {
            var cloneOperands  = (Stack)info.Operands.Clone();
            var cloneOperators = (Stack)info.Operators.Clone();

            current.PopRightChild(cloneOperands, cloneOperators);
            Label getShortCircuitLabel;

            while (cloneOperators.Count > 0)
            {
                var top  = (AndOrElement)cloneOperators.Pop();
                var flag = top.myOperation != current.myOperation;
                if (flag)
                {
                    var nextOperand = RuntimeHelpers.GetObjectValue(cloneOperands.Pop());
                    getShortCircuitLabel = GetLabel(RuntimeHelpers.GetObjectValue(nextOperand), ilg, info);
                    return(getShortCircuitLabel);
                }
                top.PopRightChild(cloneOperands, cloneOperators);
            }
            var flag2 = current.myOperation == AndOrOperation.And;

            if (flag2)
            {
                getShortCircuitLabel = GetLabel(RuntimeHelpers.GetObjectValue(ourFalseTerminalKey), ilg, info);
                return(getShortCircuitLabel);
            }
            getShortCircuitLabel = GetLabel(RuntimeHelpers.GetObjectValue(ourTrueTerminalKey), ilg, info);
            return(getShortCircuitLabel);
        }
Example #2
0
        private static void EmitBranch(AndOrElement op, FleeIlGenerator ilg, Label target, ShortCircuitInfo info)
        {
            var isTemp = ilg.IsTemp;

            if (isTemp)
            {
                info.Branches.AddBranch(ilg, target);
                var shortBranch = GetBranchOpcode(op, false);
                ilg.Emit(shortBranch, target);
            }
            else
            {
                var longBranch = info.Branches.IsLongBranch(ilg, target);
                var brOpcode   = GetBranchOpcode(op, longBranch);
                ilg.Emit(brOpcode, target);
            }
        }
Example #3
0
        private static OpCode GetBranchOpcode(AndOrElement op, bool longBranch)
        {
            var    flag = op.myOperation == AndOrOperation.And;
            OpCode getBranchOpcode;

            if (flag)
            {
                getBranchOpcode = longBranch ? OpCodes.Brfalse : OpCodes.Brfalse_S;
            }
            else if (longBranch)
            {
                getBranchOpcode = OpCodes.Brtrue;
            }
            else
            {
                getBranchOpcode = OpCodes.Brtrue_S;
            }
            return(getBranchOpcode);
        }