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, 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);
 }
Beispiel #3
0
        /// <summary>
        /// Match expression with given code and two arguments.
        /// </summary>
        public static bool Match <T>(this AstNode node, AstCode code, out T operand, out AstExpression arg1, out AstExpression arg2)
        {
            List <AstExpression> args;

            if (node.Match(code, out operand, out args) && args.Count == 2)
            {
                arg1 = args[0];
                arg2 = args[1];
                return(true);
            }
            arg1 = null;
            arg2 = null;
            return(false);
        }
Beispiel #4
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 #5
0
 /// <summary>
 /// Copy ctor
 /// </summary>
 public AstExpression(AstExpression source)
     : base(source.SourceLocation)
 {
     CopyFrom(source);
 }