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


C++ ExprVector类代码示例

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


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

示例1: handleOneArraySubscriptExpr

void ReduceArrayDim::handleOneArraySubscriptExpr(
       const ArraySubscriptExpr *ASE)
{
  const Type *ASETy = ASE->getType().getTypePtr();
  if (!ASETy->isScalarType() && !ASETy->isStructureType() && 
      !ASETy->isUnionType())
    return;

  ExprVector IdxExprs;
  const Expr *BaseE = getBaseExprAndIdxExprs(ASE, IdxExprs);
  TransAssert(BaseE && "Empty Base expression!");

  if (IdxExprs.size() <= 1)
    return;

  const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseE);
  if (!DRE)
    return;

  const ValueDecl *OrigDecl = DRE->getDecl();
  const VarDecl *VD = dyn_cast<VarDecl>(OrigDecl);
  if (!VD)
    return;

  const VarDecl *CanonicalVD = VD->getCanonicalDecl();
  if (CanonicalVD != TheVarDecl)
    return;

  rewriteSubscriptExpr(IdxExprs); 
}
开发者ID:sylvestre,项目名称:creduce,代码行数:30,代码来源:ReduceArrayDim.cpp

示例2: if

ExprVector EntityBase::FaceGetNormalExprs(void) {
    ExprVector r;
    if(type == FACE_NORMAL_PT) {
        Vector v = Vector::From(numNormal.vx, numNormal.vy, numNormal.vz);
        r = ExprVector::From(v.WithMagnitude(1));
    } else if(type == FACE_XPROD) {
        ExprVector vc = ExprVector::From(param[0], param[1], param[2]);
        ExprVector vn =
            ExprVector::From(numNormal.vx, numNormal.vy, numNormal.vz);
        r = vc.Cross(vn);
        r = r.WithMagnitude(Expr::From(1.0));
    } else if(type == FACE_N_ROT_TRANS) {
        // The numerical normal vector gets the rotation; the numerical
        // normal has magnitude one, and the rotation doesn't change that,
        // so there's no need to fix it up.
        r = ExprVector::From(numNormal.vx, numNormal.vy, numNormal.vz);
        ExprQuaternion q =
            ExprQuaternion::From(param[3], param[4], param[5], param[6]);
        r = q.Rotate(r);
    } else if(type == FACE_N_TRANS) {
        r = ExprVector::From(numNormal.vx, numNormal.vy, numNormal.vz);
    } else if(type == FACE_N_ROT_AA) {
        r = ExprVector::From(numNormal.vx, numNormal.vy, numNormal.vz);
        ExprQuaternion q = GetAxisAngleQuaternionExprs(3);
        r = q.Rotate(r);
    } else oops();
    return r;
}
开发者ID:BBBSnowball,项目名称:python-solvespace,代码行数:28,代码来源:entity.cpp

示例3: ArgumentException

void OpReplaceRepeated::Apply(Expression *expression, Calculator *calculator, int32 recursions)
{
	if(expression->LeafCount() != 2)
		throw ArgumentException("ReplaceRepeated expects 2 arguments.");
	if(expression->LeafCount() != 2)
		throw ArgumentException("ReplaceRepeated expects 2 arguments.");
	string leafFunction = expression->Leaf(1)->FunctionName();
	if(leafFunction != "Rule" && leafFunction != "RuleDelayed" && leafFunction != "List")
		throw ArgumentException("ReplaceRepeated expects its second argument to be a rule or a list of rules.");
	ExprVector rules;
	if(leafFunction == "List")
	{
		for(ExprVector::const_iterator item = expression->Leaf(1)->Leaves().begin(); item != expression->Leaf(1)->Leaves().end(); ++ item)
			if((*item)->FunctionName() != "Rule" && (*item)->FunctionName() != "RuleDelayed")
				throw ArgumentException("ReplaceRepeated expects its second argument to be a rule or a list of rules.");
		rules = expression->Leaf(1)->Leaves();
	}
	else
		rules.push_back(expression->Leaf(1));
	int32 iterations(0);
	Expression *result = expression->Leaf(0);
	while(true)
	{
		bool changed(false);
		if(!result->ReplaceAll(rules, calculator, &changed))
			break;
		if(!changed)
			break;
		++iterations;
		if(iterations >= Max_ReplaceRepeated_Iterations)
			throw LimitationException("Maximum number of iterations reached.");
	}
	expression->AssignLeaf(0);
	expression->Evaluate(calculator, recursions);
}
开发者ID:dubrousky,项目名称:Mathador,代码行数:35,代码来源:Rule.cpp

示例4: TransformExpr

Stmt *TransformVector::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
  unsigned NumElems = Node->getNumElements();
  if (NumElems == 0) {
    // array subscripting syntax
    Expr *ExprBase = TransformExpr(Node->getBase());
    ASTCtx.Deallocate(Node);
    return ExprBase;
  } else {
    DeclVector DeclVec;
    ExprVector ExprVec;
    MakeElementExprs(DeclVec, ExprVec, Node);
    assert((ExprVec.size() == NumElems) && "Wrong accessor?");
    if (DeclVec.size() > 0) {
      PushBackDeclStmts(*CurStmtVec, DeclVec);
    }

    if (NumElems == 1) {
      return ExprVec[0];
    } else {
      QualType NodeTy = Node->getType();
      CallExpr *NewExpr = new (ASTCtx) CallExpr(ASTCtx,
          CLExprs.getVectorLiteralExpr(NodeTy), ExprVec.data(), NumElems,
          NodeTy, VK_RValue, SourceLocation());
      return NewExpr;
    }
  }
}
开发者ID:SiddharthC,项目名称:snucl-1.3.2,代码行数:27,代码来源:TransformVector.cpp

示例5: create

/**
* @brief Converts the given LLVM call instruction @a inst into an expression in BIR.
*/
ShPtr<CallExpr> LLVMInstructionConverter::convertCallInstToCallExpr(llvm::CallInst &inst) {
	ExprVector args;
	for (auto &arg: inst.arg_operands()) {
		args.push_back(getConverter()->convertValueToExpression(arg));
	}

	auto calledExpr = getConverter()->convertValueToExpression(inst.getCalledValue());
	return CallExpr::create(calledExpr, args);
}
开发者ID:SchuckBeta,项目名称:retdec,代码行数:12,代码来源:llvm_instruction_converter.cpp

示例6: ReplaceAll

bool Expression::ReplaceAll(const ExprVector &rules, Calculator *calculator, bool *changed)
{
	for(ExprVector::const_iterator rule = rules.begin(); rule != rules.end(); ++rule)
		if(Replace(*rule, calculator, changed))
			return true;
	for(ExprVector::const_iterator leaf = leaves.begin(); leaf != leaves.end(); ++leaf)
		if((*leaf)->ReplaceAll(rules, calculator, changed))
			return true;
	return false;
}
开发者ID:dubrousky,项目名称:Mathador,代码行数:10,代码来源:Expression.cpp

示例7: vector_bwd

void Gradient::vector_bwd(const ExprVector& v, ExprLabel** compL, const ExprLabel& y) {
	if (v.dim.is_vector()) {
		for (int i=0; i<v.length(); i++) compL[i]->g->i()+=y.g->v()[i];
	}
	else {
		if (v.row_vector())
			for (int i=0; i<v.length(); i++) compL[i]->g->v()+=y.g->m()[i];
		else
			for (int i=0; i<v.length(); i++) compL[i]->g->v()+=y.g->m().col(i);
	}
}
开发者ID:Jordan08,项目名称:ibex-lib,代码行数:11,代码来源:ibex_Gradient.cpp

示例8: PointInThreeSpace

ExprVector ConstraintBase::PointInThreeSpace(hEntity workplane,
                                             Expr *u, Expr *v)
{
    EntityBase *w = SK.GetEntity(workplane);

    ExprVector ub = w->Normal()->NormalExprsU();
    ExprVector vb = w->Normal()->NormalExprsV();
    ExprVector ob = w->WorkplaneGetOffsetExprs();

    return (ub.ScaledBy(u)).Plus(vb.ScaledBy(v)).Plus(ob);
}
开发者ID:blondegeek,项目名称:solvespace-1,代码行数:11,代码来源:constrainteq.cpp

示例9: getBaseExprAndIdxExprs

void ReduceArraySize::handleOneASE(const ArraySubscriptExpr *ASE)
{
  const Type *ASETy = ASE->getType().getTypePtr();
  if (!ASETy->isScalarType() && !ASETy->isStructureType() && 
      !ASETy->isUnionType())
    return;
  
  ExprVector IdxExprs;
  const Expr *BaseE = getBaseExprAndIdxExprs(ASE, IdxExprs);
  TransAssert(BaseE && "Empty Base expression!");

  const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(BaseE);
  if (!DRE)
    return;

  const ValueDecl *OrigDecl = DRE->getDecl();
  const VarDecl *VD = dyn_cast<VarDecl>(OrigDecl);
  if (!VD)
    return;

  const VarDecl *CanonicalVD = VD->getCanonicalDecl();
  DimValueVector *DimVec = VarDeclToDim[CanonicalVD];
  // It's possible DimVec is NULL, e.g.,
  // int main(..., char *argv[]) {
  //  ... argv[1] ...
  // }
  if (!DimVec)
    return;

  TransAssert((DimVec->size() >= IdxExprs.size()) &&
              "More indices than it should be!");

  unsigned int DimIdx = 0;
  for (ExprVector::reverse_iterator I = IdxExprs.rbegin(), 
       E = IdxExprs.rend(); I != E; ++I) {

    int OldIdx = (*DimVec)[DimIdx];
    if (OldIdx == -1) {
      DimIdx++;
      continue;
    }

    const Expr *IdxE = (*I);
    if (isIntegerExpr(IdxE)) {
      int Idx = getIndexAsInteger(IdxE);
      if (Idx > OldIdx)
        (*DimVec)[DimIdx] = Idx;
    }
    else {
      (*DimVec)[DimIdx] = -1;
    }
    DimIdx++;
  }
}
开发者ID:BlastarIndia,项目名称:creduce,代码行数:54,代码来源:ReduceArraySize.cpp

示例10: getSubExprs

/***************************************************************
* Function: RangeExpr::getSubExprs()
* Purpose : Access sub-expressions
* Initial : Maxime Chevalier-Boisvert on January 8, 2009
****************************************************************
Revisions and bug fixes:
*/
Expression::ExprVector RangeExpr::getSubExprs() const
{
	// Create a list to store the sub-expression pointers
	ExprVector list; 
	
	// Add the sub-expressions to the list
	list.push_back(m_pStartExpr); 
	list.push_back(m_pStepExpr);
	list.push_back(m_pEndExpr);
	
	// Return the list
	return list;	
}
开发者ID:Sable,项目名称:mcvm,代码行数:20,代码来源:rangeexpr.cpp

示例11: copy

/***************************************************************
* Function: ParamExpr::copy()
* Purpose : Copy this IIR node recursively
* Initial : Maxime Chevalier-Boisvert on November 8, 2008
****************************************************************
Revisions and bug fixes:
*/
ParamExpr* ParamExpr::copy() const
{
	// Create an argument vector to store the argument copies
	ExprVector arguments;

	// Copy each argument
	for (ExprVector::const_iterator itr = m_arguments.begin(); itr != m_arguments.end(); ++itr)
		arguments.push_back((Expression*)(*itr)->copy());

	// Create and return a copy of this node
	return new ParamExpr(
		m_pSymbolExpr->copy(),
		arguments
	);
}
开发者ID:dcdelia,项目名称:mcvm,代码行数:22,代码来源:paramexpr.cpp

示例12: copy

/***************************************************************
* Function: AssignStmt::copy()
* Purpose : Copy this IIR node recursively
* Initial : Maxime Chevalier-Boisvert on November 6, 2008
****************************************************************
Revisions and bug fixes:
*/
AssignStmt* AssignStmt::copy() const
{
	// Create a vector for the left expression copies
	ExprVector leftExprs;
	
	// Copy each left expression
	for (ExprVector::const_iterator itr = m_leftExprs.begin(); itr != m_leftExprs.end(); ++itr)
		leftExprs.push_back((*itr)->copy());
	
	// Create and return a copy of this node
	return new AssignStmt(
		leftExprs,
		m_pRightExpr->copy(),
		m_suppressOut
	);
}	
开发者ID:Sable,项目名称:mcvm,代码行数:23,代码来源:assignstmt.cpp

示例13:

void HC4Revise::vector_bwd(const ExprVector& v, ExprLabel** compL, const ExprLabel& y) {
	if (v.dim.is_vector()) {
		for (int i=0; i<v.length(); i++)
			if ((compL[i]->d->i() &= y.d->v()[i]).is_empty()) throw EmptyBoxException();
	}
	else {
		if (v.row_vector())
			for (int i=0; i<v.length(); i++) {
				if ((compL[i]->d->v()&=y.d->m().col(i)).is_empty()) throw EmptyBoxException();
			}
		else
			for (int i=0; i<v.length(); i++) {
				if ((compL[i]->d->v()&=y.d->m().row(i)).is_empty()) throw EmptyBoxException();
			}
	}
}
开发者ID:nicolaje,项目名称:reliable-slam,代码行数:16,代码来源:ibex_HC4Revise.cpp

示例14: ParseMicrosoftIfExistsBraceInitializer

// Return true if a comma (or closing brace) is necessary after the
// __if_exists/if_not_exists statement.
bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
                                                    bool &InitExprsOk) {
  bool trailingComma = false;
  IfExistsCondition Result;
  if (ParseMicrosoftIfExistsCondition(Result))
    return false;
  
  BalancedDelimiterTracker Braces(*this, tok::l_brace);
  if (Braces.consumeOpen()) {
    Diag(Tok, diag::err_expected) << tok::l_brace;
    return false;
  }

  switch (Result.Behavior) {
  case IEB_Parse:
    // Parse the declarations below.
    break;
        
  case IEB_Dependent:
    Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
      << Result.IsIfExists;
    // Fall through to skip.
      
  case IEB_Skip:
    Braces.skipToEnd();
    return false;
  }

  while (!isEofOrEom()) {
    trailingComma = false;
    // If we know that this cannot be a designation, just parse the nested
    // initializer directly.
    ExprResult SubElt;
    if (MayBeDesignationStart())
      SubElt = ParseInitializerWithPotentialDesignator();
    else
      SubElt = ParseInitializer();

    if (Tok.is(tok::ellipsis))
      SubElt = Actions.ActOnPackExpansion(SubElt.get(), ConsumeToken());
    
    // If we couldn't parse the subelement, bail out.
    if (!SubElt.isInvalid())
      InitExprs.push_back(SubElt.release());
    else
      InitExprsOk = false;

    if (Tok.is(tok::comma)) {
      ConsumeToken();
      trailingComma = true;
    }

    if (Tok.is(tok::r_brace))
      break;
  }

  Braces.consumeClose();

  return !trailingComma;
}
开发者ID:Xmister,项目名称:clang-onex,代码行数:62,代码来源:ParseInit.cpp

示例15: Flatten

// Flatten out all expressions with a given head.
void Expression::Flatten(const string head)
{
	ExprVector newLeaves;
	newLeaves.reserve(leaves.size());
	for(ExprVector::const_iterator leaf = leaves.begin(); leaf != leaves.end(); ++leaf)
		if((*leaf)->FunctionName() == head)
		{
			for(ExprVector::const_iterator subLeaf = (*leaf)->Leaves().begin(); subLeaf != (*leaf)->Leaves().end(); ++subLeaf)
				newLeaves.push_back(*subLeaf);
			(*leaf)->Leaves().clear();
			delete *leaf;
		}
		else
			newLeaves.push_back(*leaf);
	leaves = newLeaves;
}
开发者ID:dubrousky,项目名称:Mathador,代码行数:17,代码来源:Expression.cpp


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