/// <summary> /// Get the label for a short-circuit /// </summary> /// <param name="current"></param> /// <param name="info"></param> /// <param name="ilg"></param> /// <returns></returns> private static Label GetShortCircuitLabel(AndOrElement current, ShortCircuitInfo info, FleeILGenerator ilg) { // We modify the given stacks so we need to clone them Stack cloneOperands = (Stack)info.Operands.Clone(); Stack cloneOperators = (Stack)info.Operators.Clone(); // Pop all siblings current.PopRightChild(cloneOperands, cloneOperators); // Go until we run out of operators while (cloneOperators.Count > 0) { // Get the top operator AndOrElement top = (AndOrElement)cloneOperators.Pop(); // Is is a different operation? if (top._myOperation != current._myOperation) { // Yes, so return a label to its right operand object nextOperand = cloneOperands.Pop(); return(GetLabel(nextOperand, ilg, info)); } else { // No, so keep going up the stack top.PopRightChild(cloneOperands, cloneOperators); } } // We've reached the end of the stack so return the label for the appropriate true/false terminal if (current._myOperation == AndOrOperation.And) { return(GetLabel(OurFalseTerminalKey, ilg, info)); } else { return(GetLabel(OurTrueTerminalKey, ilg, info)); } }