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


C++ Exp类代码示例

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


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

示例1: Visit

  void Visit(Exp *lval)
  {
    // match any access which uses a GC thing type as an rvalue,
    // including those where the thing is not actually dereferenced.
    // we are watching not just for direct accesses to the thing,
    // but to places where it is copied to arguments, a return value,
    // a variable or heap location. any use of an GC thing pointer
    // not protected against GC is considered to be an error, and adding
    // these asserts aggressively lets us discharge reports easier and
    // generate reports close to the site of the actual problem.

    if (!lval->IsDrf())
      return;
    ExpDrf *nlval = lval->AsDrf();

    Type *type = nlval->GetType();
    if (type && type->IsCSU() && TypeIsGCThing(type->AsCSU())) {
      AssertInfo info;
      info.kind = ASK_GCSafe;
      info.cls = ASC_Check;
      info.point = point;

      Exp *target = nlval->GetTarget();
      if (target->IsFld() &&
          BlockSummary::FieldIsGCSafe(target->AsFld()->GetField())) {
        info.bit = Bit::MakeConstant(true);
      } else {
        Exp *gcsafe = Exp::MakeGCSafe(nlval->GetTarget(), false);
        info.bit = Bit::MakeVar(gcsafe);
      }

      asserts.PushBack(info);
    }
  }
开发者ID:brifordwylie,项目名称:turnersr.github.io,代码行数:34,代码来源:infer.cpp

示例2: guiyue11

void guiyue11() {
    for (int i = 0; i < 3; i++) {
        stateStack.pop();
    }
    Element E1, rop, E2;
    E2 = resultStack.top();
    resultStack.pop();
    rop = resultStack.top();
    resultStack.pop();
    E1 = resultStack.top();
    resultStack.pop();
    vector<Exp> & E1_exps = E1.getSegment();
    vector<Exp> & E2_exps = E2.getSegment();
    for(int i = 0; i < E2.getLength(); i++) {
        E1_exps.push_back(E2_exps[i]);
    }
    Exp exp;
    exp.setOpcode("j" + rop.getResult());
    exp.setArg1(E1.getResult());
    exp.setArg2(E2.getResult());
    exp.setResult("1");
    E1_exps.push_back(exp);
    E1.setLength(E1.getLength() + E2.getLength() + 1);
    printElement(E1);
    resultStack.push(E1);
}
开发者ID:huster-zhangpeng,项目名称:SLR-compiler,代码行数:26,代码来源:SLR.cpp

示例3: makeDiff

// Substitute s into all members of the set
void LocationSet::substitute(Assign& a)
{
    Exp* lhs = a.getLeft();
    if (lhs == NULL) return;
    Exp* rhs = a.getRight();
    if (rhs == NULL) return;		// ? Will this ever happen?
    std::set<Exp*, lessExpStar>::iterator it;
    // Note: it's important not to change the pointer in the set of pointers to expressions, without removing and
    // inserting again. Otherwise, the set becomes out of order, and operations such as set comparison fail!
    // To avoid any funny behaviour when iterating the loop, we use the following two sets
    LocationSet removeSet;			// These will be removed after the loop
    LocationSet removeAndDelete;	// These will be removed then deleted
    LocationSet insertSet;			// These will be inserted after the loop
    bool change;
    for (it = lset.begin(); it != lset.end(); it++)
        {
            Exp* loc = *it;
            Exp* replace;
            if (loc->search(lhs, replace))
                {
                    if (rhs->isTerminal())
                        {
                            // This is no longer a location of interest (e.g. %pc)
                            removeSet.insert(loc);
                            continue;
                        }
                    loc = loc->clone()->searchReplaceAll(lhs, rhs, change);
                    if (change)
                        {
                            loc = loc->simplifyArith();
                            loc = loc->simplify();
                            // If the result is no longer a register or memory (e.g.
                            // r[28]-4), then delete this expression and insert any
                            // components it uses (in the example, just r[28])
                            if (!loc->isRegOf() && !loc->isMemOf())
                                {
                                    // Note: can't delete the expression yet, because the
                                    // act of insertion into the remove set requires silent
                                    // calls to the compare function
                                    removeAndDelete.insert(*it);
                                    loc->addUsedLocs(insertSet);
                                    continue;
                                }
                            // Else we just want to replace it
                            // Regardless of whether the top level expression pointer has
                            // changed, remove and insert it from the set of pointers
                            removeSet.insert(*it);		// Note: remove the unmodified ptr
                            insertSet.insert(loc);
                        }
                }
        }
    makeDiff(removeSet);	   // Remove the items to be removed
    makeDiff(removeAndDelete); // These are to be removed as well
    makeUnion(insertSet);	   // Insert the items to be added
    // Now delete the expressions that are no longer needed
    std::set<Exp*, lessExpStar>::iterator dd;
    for (dd = removeAndDelete.lset.begin(); dd != removeAndDelete.lset.end();
            dd++)
        delete *dd;				// Plug that memory leak
}
开发者ID:JFreaker,项目名称:boomerang,代码行数:61,代码来源:managed.cpp

示例4: RemoveValExp

void RemoveValExp(FrameId frame, BlockMemory *mcfg,
                  const GuardExpVector &input, GuardExpVector *output)
{
  for (size_t iind = 0; iind < input.Size(); iind++) {
    const GuardExp &igt = input[iind];

    RemoveFrameMapper mapper(frame);
    Exp *nexp = igt.exp->DoMap(&mapper);

    GuardExpVector remove_res;
    mcfg->TranslateExp(TRK_RemoveVal, 0, nexp, &remove_res);
    nexp->DecRef();

    for (size_t rind = 0; rind < remove_res.Size(); rind++) {
      const GuardExp &rgt = remove_res[rind];
      rgt.IncRef();
      igt.guard->IncRef();

      Bit *new_guard = Bit::MakeAnd(igt.guard, rgt.guard);
      output->PushBack(GuardExp(rgt.exp, new_guard));
    }
  }

  output->SortCombine();
}
开发者ID:wh5a,项目名称:xgill,代码行数:25,代码来源:where.cpp

示例5: PrintUI

void WherePostcondition::PrintUI(OutStream &out) const
{
  PEdge *edge = m_frame->CFG()->GetSingleOutgoingEdge(m_point);
  Location *loc = m_frame->CFG()->GetPointLocation(m_point);

  if (edge->IsLoop()) {
    const char *loop_name = edge->AsLoop()->GetLoopId()->LoopName();
    out << "LoopInvariant [" << loop_name << "]";
  }
  else {
    out << "Postcondition [";

    PEdgeCall *nedge = edge->AsCall();
    Exp *function = nedge->GetFunction();
    function->PrintUI(out, true);

    out << ":" << loc->Line() << "]";
  }

  if (m_bit) {
    Bit *new_bit = BitConvertExitClobber(m_bit);

    out << " :: ";
    new_bit->PrintUI(out, true);
    new_bit->DecRef();
  }
}
开发者ID:wh5a,项目名称:xgill,代码行数:27,代码来源:where.cpp

示例6: output_value_on_line

inline void output_value_on_line(const std::string& filename,	//
		Domain_<Float, Float, 2>& domain,  //
		Axes aix, Float v, st idx) {
	//typedef Domain_<Float, Float, 2> Domain;
	typedef Domain_<Float, Float, 2>::pNode pNode;
	typedef Interpolate_<Float, Float, 2> Inter;
	typedef Point_<Float, 2> Point;
	typedef Expression_<Float, Float,2> Exp;

	// build an array
	st n = 300;
	ArrayListV<Float> arr = Linspace(  //
			domain.grid().min(VerticalAxes2D(aix)),  //
			domain.grid().max(VerticalAxes2D(aix)), n);

	// Interpolate
	ArrayListV<Float> arrval(n);
	std::fstream fss;
	fss.open(filename, std::fstream::out);
	for (st i = 0; i < n; ++i) {
		Point p;
		p[aix] = v;
		p[VerticalAxes2D(aix)] = arr[i];
		pNode pn = domain.grid().get_pnode(p.x(), p.y());

		Exp exp = Inter::OnPlane(pn, _X_, _Y_, p.x(), p.y(), 1);
		arrval[i] = exp.substitute(idx);
		fss << arr[i] << " " << arrval[i] << "\n";
	}
	fss.close();
}
开发者ID:hyperpower,项目名称:carpio,代码行数:31,代码来源:test_define.hpp

示例7: assert

/*==============================================================================
 * FUNCTION:	   NJMCDecoder::instantiateNamedParam
 * OVERVIEW:	   Similarly to the above, given a parameter name and a list of Exp*'s representing sub-parameters,
 *					return a fully substituted Exp for the whole expression
 * NOTE:		   Caller must delete result
 * PARAMETERS:	   name - parameter name
 *				   ... - Exp* representing actual operands
 * RETURNS:		   an instantiated list of Exps
 *============================================================================*/
Exp* NJMCDecoder::instantiateNamedParam(char* name, ...)
{
    if (RTLDict.ParamSet.find(name) == RTLDict.ParamSet.end())
        {
            std::cerr << "No entry for named parameter '" << name << "'\n";
            return 0;
        }
    assert(RTLDict.DetParamMap.find(name) != RTLDict.DetParamMap.end());
    ParamEntry &ent = RTLDict.DetParamMap[name];
    if (ent.kind != PARAM_ASGN && ent.kind != PARAM_LAMBDA )
        {
            std::cerr << "Attempt to instantiate expressionless parameter '" << name << "'\n";
            return 0;
        }
    // Start with the RHS
    assert(ent.asgn->getKind() == STMT_ASSIGN);
    Exp* result = ((Assign*)ent.asgn)->getRight()->clone();

    va_list args;
    va_start(args,name);
    for( std::list<std::string>::iterator it = ent.params.begin(); it != ent.params.end(); it++ )
        {
            Exp* formal = new Location(opParam, new Const((char*)it->c_str()), NULL);
            Exp* actual = va_arg(args, Exp*);
            bool change;
            result = result->searchReplaceAll(formal, actual, change);
            delete formal;
        }
    return result;
}
开发者ID:JFreaker,项目名称:boomerang,代码行数:39,代码来源:njmcDecoder.cpp

示例8: while

 Exp *autoParent() {
   Exp *current = this;
   while (current->auto_paren) {
     current = current->parent();
   }
   if (current==NULL) { return current; }
   return current->parent();
 }
开发者ID:joha2,项目名称:cosmicos,代码行数:8,代码来源:whitespace.cpp

示例9: CPPUNIT_ASSERT

/*==============================================================================
 * FUNCTION:		RtlTest::testIsCompare
 * OVERVIEW:		Test the isCompare function
 *============================================================================*/
void RtlTest::testIsCompare ()
{
  BinaryFileFactory bff;
  BinaryFile *pBF = bff.Load(SWITCH_SPARC);
  CPPUNIT_ASSERT(pBF != 0);
  CPPUNIT_ASSERT(pBF->GetMachine() == MACHINE_SPARC);
  Prog* prog = new Prog;
  FrontEnd *pFE = new SparcFrontEnd(pBF, prog, &bff);
  prog->setFrontEnd(pFE);

  // Decode second instruction: "sub		%i0, 2, %o1"
  int iReg;
  Exp* eOperand = NULL;
  DecodeResult inst = pFE->decodeInstruction(0x10910);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == false);

  // Decode fifth instruction: "cmp		%o1, 5"
  inst = pFE->decodeInstruction(0x1091c);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == true);
  CPPUNIT_ASSERT_EQUAL(9, iReg);
  std::string expected("5");
  std::ostringstream ost1;
  eOperand->print(ost1);
  std::string actual(ost1.str());
  CPPUNIT_ASSERT_EQUAL(expected, actual);

  pBF->UnLoad();
  delete pBF;
  delete pFE;
  pBF = bff.Load(SWITCH_PENT);
  CPPUNIT_ASSERT(pBF != 0);
  CPPUNIT_ASSERT(pBF->GetMachine() == MACHINE_PENTIUM);
  pFE = new PentiumFrontEnd(pBF, prog, &bff);
  prog->setFrontEnd(pFE);

  // Decode fifth instruction: "cmp	$0x5,%eax"
  inst = pFE->decodeInstruction(0x80488fb);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == true);
  CPPUNIT_ASSERT_EQUAL(24, iReg);
  std::ostringstream ost2;
  eOperand->print(ost2);
  actual = ost2.str();
  CPPUNIT_ASSERT_EQUAL(expected, actual);

  // Decode instruction: "add		$0x4,%esp"
  inst = pFE->decodeInstruction(0x804890c);
  CPPUNIT_ASSERT(inst.rtl != NULL);
  CPPUNIT_ASSERT(inst.rtl->isCompare(iReg, eOperand) == false);
  pBF->UnLoad();
  delete pFE;
}
开发者ID:zecke,项目名称:boomerang,代码行数:58,代码来源:RtlTest.cpp

示例10: GetSubtractedExp

// if exp is a subtraction (exp0 - exp1) and exp1 is an lvalue, return exp1.
static inline Exp* GetSubtractedExp(Exp *exp)
{
  ExpBinop *nexp = exp->IfBinop();
  if (!nexp)
    return NULL;
  BinopKind kind = nexp->GetBinopKind();
  if (kind != B_Minus && kind != B_MinusPP)
    return NULL;
  Exp *right = nexp->GetRightOperand();
  if (right->IsLvalue())
    return right;
  return NULL;
}
开发者ID:brifordwylie,项目名称:turnersr.github.io,代码行数:14,代码来源:sufficient.cpp

示例11: while

MM::VOID MM::PoolNodeInstance::initExp(MM::Exp * exp)
{
  if(exp != MM_NULL)
  {
    Vector<MM::Exp *> exps;
    exps.add(exp);
 
    MM::PoolNodeInstance * other = MM_NULL;
    MM::VarExp * varExp = MM_NULL;

    while(exps.isEmpty() == MM_FALSE)
    {
      Exp * curExp = exps.pop();

      switch(curExp->getTypeId())
      {
        case MM::T_BinExp:
          exps.add(((MM::BinExp*)curExp)->getLhsExp());
          exps.add(((MM::BinExp*)curExp)->getRhsExp());
          break;
       case MM::T_OverrideExp:
          exps.add(((MM::OverrideExp*)curExp)->getExp());
          break;
        case MM::T_UnExp:
          exps.add(((MM::UnExp*)curExp)->getExp());
          break;
        case MM::T_VarExp:
          varExp = (MM::VarExp *) curExp;
          other = instance->findPoolNodeInstance(varExp);
          if(other != MM_NULL)
          {
            printf("%lu poolNodeInstance %s observes poolNodeInstance %s %lu\n", this, poolNode->getName()->getBuffer(), other->getNode()->getName()->getBuffer(), other);
            fflush(stdout);
            other->addObserver(this);
            observing->add(other);
          }
          else
          {
            //TODO: runtime exception
            printf("Missing poolNodeInstance on expression %s\n", poolNode->getName()->getBuffer());
            fflush(stdout);
            //other = instance->findPoolNodeInstance(varExp);
          }
          break;
        default:
          break;
      }
    }
  }
}
开发者ID:Johnicholas,项目名称:MM-Lib,代码行数:50,代码来源:PoolNodeInstance.cpp

示例12: while

void Constraints::alphaSubst() {
	std::list<Exp*>::iterator it;
	for (it = disjunctions.begin(); it != disjunctions.end(); it++) {
		// This should be a conjuction of terms
		if (!(*it)->isConjunction())
			// A single term will do no good...
			continue;
		// Look for a term like alphaX* == fixedType*
		Exp* temp = (*it)->clone();
		Exp* term;
		bool found = false;
		Exp* trm1 = NULL;
		Exp* trm2 = NULL;
		Type* t1 = NULL, *t2;
		while ((term = nextConjunct(temp)) != NULL) {
			if (!term->isEquality())
				continue;
			trm1 = ((Binary*)term)->getSubExp1();
			if (!trm1->isTypeVal()) continue;
			trm2 = ((Binary*)term)->getSubExp2();
			if (!trm2->isTypeVal()) continue;
			// One of them has to be a pointer to an alpha
			t1 = ((TypeVal*)trm1)->getType();
			if (t1->isPointerToAlpha()) {
				found = true;
				break;
			}
			t2 = ((TypeVal*)trm2)->getType();
			if (t2->isPointerToAlpha()) {
				found = true;
				break;
			}
		}
		if (!found) continue;
		// We have a alpha value; get the value
		Exp* val, *alpha;
		if (t1->isPointerToAlpha()) {
			alpha = trm1;
			val = trm2;
		} else {
			val = trm1;
			alpha = trm2;
		}
		// Now substitute
		bool change;
		*it = (*it)->searchReplaceAll(alpha, val, change);
		*it = (*it)->simplifyConstraint();
	}
}
开发者ID:arnew,项目名称:boomerang,代码行数:49,代码来源:constraint.cpp

示例13: guiyue5

void guiyue5() {
    for (int i = 0; i < 6; i++) {
        stateStack.pop();
    }
    Element B, S1, S2;
    S2 = resultStack.top();
    resultStack.pop();
    resultStack.pop();
    S1 = resultStack.top();
    resultStack.pop();
    resultStack.pop();
    B = resultStack.top();
    resultStack.pop();
    resultStack.pop();
    printElement(B);
    cout<<endl;
    printElement(S1);
    cout<<endl;
    printElement(S2);
    cout<<endl;
    vector<Exp> & B_exps = B.getSegment();
    vector<Exp> & S1_exps = S1.getSegment();
    vector<Exp> & S2_exps = S2.getSegment();
    string destAddr = "";
    char buf[20] = "";
    sprintf(buf, "%d", S2.getLength()+2);
    destAddr.append(buf);
    B_exps[B_exps.size()-1].setResult(destAddr);
    for(unsigned i = 0; i < S2_exps.size(); i++) {
        B_exps.push_back(S2_exps[i]);
    }
    Exp exp;
    exp.setOpcode("j");
    exp.setArg1("None");
    exp.setArg2("None");
    buf[0] = '\0';
    sprintf(buf, "%d", S1.getLength()+1);
    destAddr.clear();
    destAddr.append(buf);
    exp.setResult(destAddr);
    B_exps.push_back(exp);
    for(int i = 0; i < S1.getLength(); i++) {
        B_exps.push_back(S1_exps[i]);
    }
    B.setLength(B.getLength()+S1.getLength()+S2.getLength()+1);
    printElement(B);
    resultStack.push(B);
}
开发者ID:huster-zhangpeng,项目名称:SLR-compiler,代码行数:48,代码来源:SLR.cpp

示例14: MatchEquality

Exp* MatchEquality(Exp *base, const BaseCompare &equality)
{
  Exp *source = equality.source;
  Exp *target = equality.target;

  // check for the source and base being the same value.
  if (source == base)
    return target;

  // check for the source and base begin different bounds on the same lvalue.
  if (source->IsBound() && base->IsBound()) {
    ExpBound *nsource = source->AsBound();
    ExpBound *nbase = base->AsBound();

    if (nsource->GetTarget() != nbase->GetTarget())
      return NULL;
    if (nsource->GetBoundKind() != nbase->GetBoundKind())
      return NULL;

    size_t base_width = nbase->GetStrideType()->Width();
    size_t source_width = nsource->GetStrideType()->Width();

    if (source_width == base_width)
      return target;

    // only handling upper bounds where the base's width is an even multiple
    // of the source's width. this is to handle cases where there is an
    // equality due to calling a primitive allocation function.
    if (nbase->GetBoundKind() != BND_Upper)
      return NULL;
    if (source_width == 0)
      return NULL;
    if (base_width < source_width)
      return NULL;

    size_t factor = base_width / source_width;
    if (source_width * factor != base_width)
      return NULL;

    // construct a new equality and recurse on it. the base's bound
    // can be compared with (target / factor).
    Exp *factor_exp = Exp::MakeInt(factor);
    return Exp::MakeBinop(B_Div, target, factor_exp);
  }

  return NULL;
}
开发者ID:brifordwylie,项目名称:turnersr.github.io,代码行数:47,代码来源:sufficient.cpp

示例15: getid

void
AST2DotTranslater::visit(SeqExp *exp)
{
	string sseq, sresult;
	string name = "SeqExp" + getid();
	Seq::iterator it = exp->seq->begin();
	while (it != exp->seq->end()) {
		Exp *e = *it;
		if (e) {
			e->accept(this);
			sseq = pop();
			sresult += name + " -> " + sseq;
		}
		++it;
	}
	
	push(sresult);
}
开发者ID:ktok07b6,项目名称:tiger,代码行数:18,代码来源:AST2DotTranslater.cpp


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