Exemplo n.º 1
0
        public override bool Match(CFGNode target)
        {
            IsMatched = false;
            MatchedNodes = new Tenpow.Collections.Generic.Set<CFGNode>();
            MatchedExpression = null;
            // TODO: Match a condition binaryExpression

            if (target.BasicBlock.Statements.Count < 1)
            {
                return false;
            }
            IAssignStatement assignStatement = target.BasicBlock.Statements[0] as IAssignStatement;
            if (assignStatement != null)
            {
                MatchedExpression = new AssignExpression(assignStatement.Target, assignStatement.Expression);
            }
            else
            {
                IExpressionStatement expressionStatement = target.BasicBlock.Statements[0] as IExpressionStatement;
                if (expressionStatement == null)
                {
                    return false;
                }
                MatchedExpression = expressionStatement.Expression;
            }
            MatchedNodes.Add(target);

            OnMatched(new CFGPatternMatch(MatchedNodes));
            IsMatched = true;
            return true;
        }
Exemplo n.º 2
0
 void ExpressionPattern_Matched(object sender, PatternMatchEventArgs<CFGPatternMatch> args)
 {
     MatchedNodes = args.Match.MatchedNodes;
 }