예제 #1
0
// Find the first Assignment with loc on the LHS
Assignment *
StatementList::findOnLeft(Exp *loc) const
{
	for (const auto &s : slist) {
		auto as = (Assignment *)s;
		Exp *left = as->getLeft();
		if (*left == *loc)
			return as;
		if (left->isLocal()) {
			auto l = (Location *)left;
			Exp *e = l->getProc()->expFromSymbol(((Const *)l->getSubExp1())->getStr());
			if (e && ((*e == *loc) || (e->isSubscript() && *e->getSubExp1() == *loc))) {
				return as;
			}
		}
	}
	return nullptr;
}
예제 #2
0
// Find the first Assignment with loc on the LHS
Assignment* StatementList::findOnLeft(Exp* loc)
{
    if (slist.size() == 0)
        return NULL;
    for (iterator it = slist.begin(); it != slist.end(); it++)
        {
            Exp *left = ((Assignment*)*it)->getLeft();
            if (*left == *loc)
                return (Assignment*)*it;
            if (left->isLocal())
                {
                    Location *l = (Location*)left;
                    Exp *e = l->getProc()->expFromSymbol(((Const*)l->getSubExp1())->getStr());
                    if (e && ((*e == *loc) || (e->isSubscript() && *e->getSubExp1() == *loc)))
                        {
                            return (Assignment*)*it;
                        }
                }
        }
    return NULL;
}