/// <summary> /// Match basic block ending with an expression with code code and one argument, followed by a branch. /// </summary> public static bool MatchLastAndBr <T>(this AstBasicBlock bb, AstCode code, out T operand, out AstExpression arg, out AstLabel brLabel) { if (bb.Body.ElementAtOrDefault(bb.Body.Count - 2).Match(code, out operand, out arg) && bb.Body.LastOrDefault().Match(AstCode.Br, out brLabel)) { return(true); } operand = default(T); arg = null; brLabel = null; return(false); }
/// <summary> /// Match basic block with one label followed by an expression with code code and one argument, followed by a branch. /// </summary> public static bool MatchSingleAndBr <T>(this AstBasicBlock bb, AstCode code, out T operand, out AstExpression arg, out AstLabel brLabel) { if (bb.Body.Count == 3 && bb.Body[0] is AstLabel && bb.Body[1].Match(code, out operand, out arg) && bb.Body[2].Match(AstCode.Br, out brLabel)) { return(true); } operand = default(T); arg = null; brLabel = null; return(false); }