Beispiel #1
0
 /// <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);
 }
Beispiel #2
0
 /// <summary>
 /// Match basic block with one label followed by an expression with code code and one argument.
 /// </summary>
 public static bool MatchSingle <T>(this AstBasicBlock bb, AstCode code, out T operand, out AstExpression arg)
 {
     if (bb.Body.Count == 2 &&
         bb.Body[0] is AstLabel &&
         bb.Body[1].Match(code, out operand, out arg))
     {
         return(true);
     }
     operand = default(T);
     arg     = null;
     return(false);
 }
Beispiel #3
0
 /// <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);
 }