当前位置: 首页>>代码示例>>C++>>正文


C++ Exp::match方法代码示例

本文整理汇总了C++中Exp::match方法的典型用法代码示例。如果您正苦于以下问题:C++ Exp::match方法的具体用法?C++ Exp::match怎么用?C++ Exp::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exp的用法示例。


在下文中一共展示了Exp::match方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkCond

bool GenericExpTransformer::checkCond(Exp *cond, Exp *bindings)
{
	switch (cond->getOper()) {
	case opAnd:
		return checkCond(cond->getSubExp1(), bindings)
		    && checkCond(cond->getSubExp2(), bindings);
	case opEquals:
		{
			Exp *lhs = cond->getSubExp1(), *rhs = cond->getSubExp2();
			for (Exp *l = bindings; l->getOper() != opNil; l = l->getSubExp2()) {
				Exp *e = l->getSubExp1();
				bool change = false;
				lhs = lhs->searchReplaceAll(e->getSubExp1()->clone(), e->getSubExp2()->clone(), change);
#if 0
				if (change)
					LOG << "replaced " << e->getSubExp1() << " with " << e->getSubExp2() << "\n";
#endif
				change = false;
				rhs = rhs->searchReplaceAll(e->getSubExp1()->clone(), e->getSubExp2()->clone(), change);
#if 0
				if (change)
					LOG << "replaced " << e->getSubExp1() << " with " << e->getSubExp2() << "\n";
#endif
			}
			if (lhs->getOper() == opTypeOf) {
#if 0 // ADHOC TA
				Type *ty = lhs->getSubExp1()->getType();
#else
				Type *ty = NULL;
#endif
				if (ty == NULL) {
#if 0
					if (VERBOSE)
						LOG << "no type for typeof " << lhs << "\n";
#endif
					return false;
				}
				lhs = new TypeVal(ty);
#if 0
				LOG << "got typeval: " << lhs << "\n";
#endif
			}
			if (lhs->getOper() == opKindOf) {
				OPER op = lhs->getSubExp1()->getOper();
				lhs = new Const(operStrings[op]);
			}
			rhs = applyFuncs(rhs);

#if 0
			LOG << "check equals in cond: " << lhs << " == " << rhs << "\n";
#endif

			if (lhs->getOper() == opVar) {
				Exp *le;
				for (le = bindings; le->getOper() != opNil && le->getSubExp2()->getOper() != opNil; le = le->getSubExp2())
					;
				assert(le->getOper() != opNil);
				le->setSubExp2(new Binary(opList, new Binary(opEquals, lhs->clone(), rhs->clone()), new Terminal(opNil)));
#if 0
				LOG << "bindings now: " << bindings << "\n";
#endif
				return true;
			}

			if (*lhs == *rhs)
				return true;

#if 0 // ADHOC TA
			if (lhs->getOper() == opTypeVal
			 && rhs->getOper() == opTypeVal
			 && lhs->getType()->resolvesToCompound()
			 && rhs->getType()->isCompound())
				return true;
#endif

			Exp *new_bindings = lhs->match(rhs);
			if (new_bindings == NULL)
				return false;

#if 0
			LOG << "matched lhs with rhs, bindings: " << new_bindings << "\n";
#endif

			Exp *le;
			for (le = bindings; le->getOper() != opNil && le->getSubExp2()->getOper() != opNil; le = le->getSubExp2())
				;
			assert(le->getOper() != opNil);
			le->setSubExp2(new_bindings);

#if 0
			LOG << "bindings now: " << bindings << "\n";
#endif

			return true;
		}
	default:
		LOG << "don't know how to handle oper "
		    << operStrings[cond->getOper()] << " in cond.\n";
	}
	return false;
//.........这里部分代码省略.........
开发者ID:mibrahim,项目名称:boomerang,代码行数:101,代码来源:generic.cpp


注:本文中的Exp::match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。