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


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

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


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

示例1:

Exp *GenericExpTransformer::applyTo(Exp *e, bool &bMod)
{
	bool change;
	Exp *bindings = e->match(match);
	if (bindings == NULL) {
#if 0
		if (e->getOper() == match->getOper())
			LOG << "match failed: " << e << " with " << match << "\n";
#endif
		return e;
	}

	if (where) {
		Exp *cond = where->clone();
		if (checkCond(cond, bindings) == false)
			return e;
	}

	LOG << "applying generic exp transformer match: " << match;
	if (where)
		LOG << " where: " << where;
	LOG << " become: " << become;
	LOG << " to: " << e;
	LOG << " bindings: " << bindings << "\n";

	e = become->clone();
	for (Exp *l = bindings; l->getOper() != opNil; l = l->getSubExp2())
		e = e->searchReplaceAll(l->getSubExp1()->getSubExp1(),
		                        l->getSubExp1()->getSubExp2(),
		                        change);

	LOG << "calculated result: " << e << "\n";
	bMod = true;

	Exp *r;
	if (e->search(new Unary(opVar, new Terminal(opWild)), r)) {
		LOG << "error: variable " << r << " in result!\n";
		assert(false);
	}

	return e;
}
开发者ID:mibrahim,项目名称:boomerang,代码行数:42,代码来源:generic.cpp

示例2: renameBlockVars


//.........这里部分代码省略.........
					S->subscriptVar(x, def /*, this */);
				}
			}
		}

		// MVE: Check for Call and Return Statements; these have DefCollector objects that need to be updated
		// Do before the below, so CallStatements have not yet processed their defines
		if (S->isCall() || S->isReturn()) {
			DefCollector* col;
			if (S->isCall())
				col = ((CallStatement*)S)->getDefCollector();
			else
				col = ((ReturnStatement*)S)->getCollector();
			col->updateDefs(Stacks, proc);
		}

		// For each definition of some variable a in S
		LocationSet defs;
		S->getDefinitions(defs);
		LocationSet::iterator dd;
		for (dd = defs.begin(); dd != defs.end(); dd++) {
			Exp* a = *dd;
			// Don't consider a if it cannot be renamed
			bool suitable = canRename(a, proc);
			if (suitable) {
				// Push i onto Stacks[a]
				// Note: we clone a because otherwise it could be an expression that gets deleted through various
				// modifications. This is necessary because we do several passes of this algorithm to sort out the
				// memory expressions
				Stacks[a->clone()].push(S);
				// Replace definition of a with definition of a_i in S (we don't do this)
			}
			// FIXME: MVE: do we need this awful hack?
			if (a->getOper() == opLocal) {
				Exp *a1 = S->getProc()->expFromSymbol(((Const*)a->getSubExp1())->getStr());
				assert(a1);
				a = a1;
				// Stacks already has a definition for a (as just the bare local)
				if (suitable) {
					Stacks[a->clone()].push(S);
				}
			}
		}
		// Special processing for define-alls (presently, only childless calls).
// But note that only everythings at the current memory level are defined!
		if (S->isCall() && ((CallStatement*)S)->isChildless() && !Boomerang::get()->assumeABI) {
			// S is a childless call (and we're not assuming ABI compliance)
			Stacks[defineAll];										// Ensure that there is an entry for defineAll
			std::map<Exp*, std::stack<Statement*>, lessExpStar>::iterator dd;
			for (dd = Stacks.begin(); dd != Stacks.end(); ++dd) {
// if (dd->first->isMemDepth(memDepth))
					dd->second.push(S);								// Add a definition for all vars
			}
		}
	}

	// For each successor Y of block n
	std::vector<PBB>& outEdges = bb->getOutEdges();
	unsigned numSucc = outEdges.size();
	for (unsigned succ = 0; succ < numSucc; succ++) {
		PBB Ybb = outEdges[succ];
		// Suppose n is the jth predecessor of Y
		int j = Ybb->whichPred(bb);
		// For each phi-function in Y
		Statement* S;
		for (S = Ybb->getFirstStmt(rit, sit); S; S = Ybb->getNextStmt(rit, sit)) {
开发者ID:WilliamMaber,项目名称:boomerang,代码行数:67,代码来源:dataflow.cpp

示例3: 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

示例4: processProc


//.........这里部分代码省略.........
						// procedure

						if (uDest < pBF->getLimitTextHigh()) {
							targetQueue.visit(pCfg, uDest, pBB);
							pCfg->addOutEdge(pBB, uDest, true);
						}
						else {
							std::cout<<"Entering Processing Proc5\n"; 
							if (!ASS_FILE)
								LOG << "Error: Instruction at " << uAddr << " branches beyond end of section, to "
									<< uDest << "\n";
							else{
								targetQueue.visit(pCfg, uDest, pBB);
								pCfg->addOutEdge(pBB, uDest, true);
							} 

						}
					}
					break;
				}

				case STMT_CASE: {
					Exp* pDest = stmt_jump->getDest();
					if (pDest == NULL) {				// Happens if already analysed (now redecoding)
						// SWITCH_INFO* psi = ((CaseStatement*)stmt_jump)->getSwitchInfo();
						BB_rtls->push_back(pRtl);
						pBB = pCfg->newBB(BB_rtls, NWAY, 0);	// processSwitch will update num outedges
						pBB->processSwitch(pProc);		// decode arms, set out edges, etc
						sequentialDecode = false;		// Don't decode after the jump
						BB_rtls = NULL;					// New RTLList for next BB
						break;							// Just leave it alone
					}
					// Check for indirect calls to library functions, especially in Win32 programs
					if (pDest && pDest->getOper() == opMemOf &&
							pDest->getSubExp1()->getOper() == opIntConst && 
							pBF->IsDynamicLinkedProcPointer(((Const*)pDest->getSubExp1())->getAddr())) {
						if (VERBOSE)
							LOG << "jump to a library function: " << stmt_jump << ", replacing with a call/ret.\n";
						// jump to a library function
						// replace with a call ret
						// TODO: 
						std::string func = pBF->GetDynamicProcName(
							((Const*)stmt_jump->getDest()->getSubExp1())->getAddr());
						//------------------------------------
						CallStatement *call = new CallStatement;
						call->setDest(stmt_jump->getDest()->clone());
						LibProc *lp = pProc->getProg()->getLibraryProc(func.c_str());
						if (lp == NULL)
							LOG << "getLibraryProc returned NULL, aborting\n";
						assert(lp);
						call->setDestProc(lp);
						std::list<Statement*>* stmt_list = new std::list<Statement*>;
						stmt_list->push_back(call);
						BB_rtls->push_back(new RTL(pRtl->getAddress(), stmt_list));
						pBB = pCfg->newBB(BB_rtls, CALL, 1);
						appendSyntheticReturn(pBB, pProc, pRtl);
						sequentialDecode = false;
						BB_rtls = NULL;
						if (pRtl->getAddress() == pProc->getNativeAddress()) {
							// it's a thunk
							// Proc *lp = prog->findProc(func.c_str());
							func = std::string("__imp_") + func;
							pProc->setName(func.c_str());
							//lp->setName(func.c_str());
							Boomerang::get()->alert_update_signature(pProc);
						}
开发者ID:PhuongLam94,项目名称:Boomerang-Production,代码行数:67,代码来源:frontend.cpp


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