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


C++ ExpressionPtr::getType方法代码示例

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


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

示例1: checkParamTypeCodeErrors

void FunctionCall::checkParamTypeCodeErrors(AnalysisResultPtr ar) {
  if (!m_funcScope || m_arrayParams) return;
  for (int i = 0, n = m_funcScope->getMaxParamCount(); i < n; ++i) {
    TypePtr specType = m_funcScope->getParamTypeSpec(i);
    if (!specType) continue;

    const char *fmt = 0;
    string ptype;
    if (!m_params || m_params->getCount() <= i) {
      if (i >= m_funcScope->getMinParamCount()) break;
      fmt = "parameter %d of %s() requires %s, none given";
    } else {
      ExpressionPtr param = (*m_params)[i];
      if (!Type::Inferred(ar, param->getType(), specType)) {
        fmt = "parameter %d of %s() requires %s, called with %s";
      }
      ptype = param->getType()->toString();
    }
    if (fmt) {
      string msg;
      string_printf
        (msg, fmt,
         i + 1,
         escapeStringForCPP(m_funcScope->getOriginalName()).c_str(),
         specType->toString().c_str(), ptype.c_str());
      Compiler::Error(Compiler::BadArgumentType,
                      shared_from_this(), msg);
    }
  }
}
开发者ID:AmineCherrai,项目名称:hhvm,代码行数:30,代码来源:function_call.cpp

示例2: buildPtrOfFunction

	ExpressionPtr buildPtrOfFunction(const ExpressionPtr& funExpr) {
		assert_true(funExpr->getType().isa<FunctionTypePtr>()) << "Trying to build a ptr of a non-function type:\n" << dumpColor(funExpr)
			                                                   << "\nType: " << dumpColor(funExpr->getType());
		IRBuilder builder(funExpr->getNodeManager());
		auto& pExt = funExpr->getNodeManager().getLangExtension<PointerExtension>();
		return builder.callExpr(pExt.getPtrOfFunction(), funExpr);
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:7,代码来源:pointer.cpp

示例3: analyzeProgram

void FunctionCall::analyzeProgram(AnalysisResultPtr ar) {
  if (m_class) m_class->analyzeProgram(ar);
  if (m_nameExp) m_nameExp->analyzeProgram(ar);
  if (m_params) m_params->analyzeProgram(ar);
  if (ar->getPhase() == AnalysisResult::AnalyzeFinal) {
    if (m_funcScope && !m_arrayParams) {
      for (int i = 0, n = m_funcScope->getMaxParamCount(); i < n; ++i) {
        if (TypePtr specType = m_funcScope->getParamTypeSpec(i)) {
          const char *fmt = 0;
          string ptype;
          if (!m_params || m_params->getCount() <= i) {
            if (i >= m_funcScope->getMinParamCount()) break;
            fmt = "parameter %d of %s() requires %s, none given";
          } else {
            ExpressionPtr param = (*m_params)[i];
            if (!Type::Inferred(ar, param->getType(), specType)) {
              fmt = "parameter %d of %s() requires %s, called with %s";
            }
            ptype = param->getType()->toString();
          }
          if (fmt) {
            string msg;
            Util::string_printf
              (msg, fmt,
               i + 1,
               Util::escapeStringForCPP(m_funcScope->getOriginalName()).c_str(),
               specType->toString().c_str(), ptype.c_str());
            Compiler::Error(Compiler::BadArgumentType,
                            shared_from_this(), msg);
          }
        }
      }
    }
  }
}
开发者ID:7755373049,项目名称:hiphop-php,代码行数:35,代码来源:function_call.cpp

示例4: updateStruct

/*
 * Changes the type of the field of a struct
 */
void updateStruct(const ExpressionPtr& structure, TypePtr& type, const ExpressionPtr& identifier) {
	NodeManager& mgr = structure->getNodeManager();
	IRBuilder builder(mgr);

	TypePtr baseType = structure->getType();
	RefTypePtr refTy = baseType.isa<RefTypePtr>();
	StructTypePtr kst = refTy ? refTy->getElementType().as<StructTypePtr>() : structure->getType().as<StructTypePtr>();
	std::string name = identifier->toString();
	NamedTypePtr oldType = kst->getNamedTypeEntryOf(name);
	NamedTypePtr newType = builder.namedType(name, refTy ? builder.refType(type) : type);

	TypePtr newStructType = transform::replaceAll(mgr, baseType, oldType, newType).as<TypePtr>();

	type = newStructType;
}
开发者ID:alcides,项目名称:insieme,代码行数:18,代码来源:ocl_host_utils1.cpp

示例5: buildPtrFromIntegral

	ExpressionPtr buildPtrFromIntegral(const ExpressionPtr& intExpr, const TypePtr& ptrType) {
		assert_pred1(intExpr->getNodeManager().getLangBasic().isInt, intExpr->getType()) << "Trying to build ptr from non-integral.";
		assert_pred1(isPointer, ptrType) << "Trying to build non-ptr-type from integral.";
		IRBuilder builder(intExpr->getNodeManager());
		auto& pExt = intExpr->getNodeManager().getLangExtension<PointerExtension>();
		return builder.callExpr(pExt.getPtrFromIntegral(), intExpr, builder.getTypeLiteral(ptrType));
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:7,代码来源:pointer.cpp

示例6: buildPtrSubscript

	ExpressionPtr buildPtrSubscript(const ExpressionPtr& ptrExpr, const ExpressionPtr& subscriptExpr) {
		assert_pred1(isPointer, ptrExpr) << "Trying to build a ptr subscript from non-ptr.";
		assert_pred1(ptrExpr->getNodeManager().getLangBasic().isInt, subscriptExpr->getType()) << "Trying to build a ptr subscript with non-integral subscript.";
		IRBuilder builder(ptrExpr->getNodeManager());
		auto& pExt = ptrExpr->getNodeManager().getLangExtension<PointerExtension>();
		return builder.callExpr(pExt.getPtrSubscript(), ptrExpr, subscriptExpr);
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:7,代码来源:pointer.cpp

示例7: inferTypes

TypePtr ClosureExpression::inferTypes(AnalysisResultPtr ar, TypePtr type,
                                      bool coerce) {
  if (m_vars) {
    assert(m_values && m_values->getCount() == m_vars->getCount());

    // containing function's variable table (not closure function's)
    VariableTablePtr variables = getScope()->getVariables();

    // closure function's variable table
    VariableTablePtr cvariables = m_func->getFunctionScope()->getVariables();

    // force all reference use vars into variant for this function scope
    for (int i = 0; i < m_vars->getCount(); i++) {
      ParameterExpressionPtr param =
        dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
      const string &name = param->getName();
      if (param->isRef()) {
        variables->forceVariant(ar, name, VariableTable::AnyVars);
      }
    }

    // infer the types of the values
    m_values->inferAndCheck(ar, Type::Some, false);

    // coerce the types inferred from m_values into m_vars
    for (int i = 0; i < m_vars->getCount(); i++) {
      ExpressionPtr value = (*m_values)[i];
      ParameterExpressionPtr var =
        dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
      assert(!var->getExpectedType());
      assert(!var->getImplementedType());
      if (var->isRef()) {
        var->setActualType(Type::Variant);
      } else {
        TypePtr origVarType(var->getActualType() ?
                            var->getActualType() : Type::Some);
        var->setActualType(Type::Coerce(ar, origVarType, value->getType()));
      }
    }

    {
      // this lock isn't technically needed for thread-safety, since
      // the dependencies are all set up. however, the lock assertions
      // will fail if we don't acquire it.
      GET_LOCK(m_func->getFunctionScope());

      // bootstrap the closure function's variable table with
      // the types from m_vars
      for (int i = 0; i < m_vars->getCount(); i++) {
        ParameterExpressionPtr param =
          dynamic_pointer_cast<ParameterExpression>((*m_vars)[i]);
        const string &name = param->getName();
        cvariables->addParamLike(name, param->getType(), ar,
                                 shared_from_this(),
                                 getScope()->isFirstPass());
      }
    }
  }
  return s_ClosureType;
}
开发者ID:JustProgrammer,项目名称:hiphop-php,代码行数:60,代码来源:closure_expression.cpp

示例8: replaceValue

ExpressionPtr Expression::replaceValue(ExpressionPtr rep) {
  if (hasContext(Expression::RefValue) &&
      isRefable(true) && !rep->isRefable(true)) {
    /*
      An assignment isRefable, but the rhs may not be. Need this to
      prevent "bad pass by reference" errors.
    */
    ExpressionListPtr el(new ExpressionList(getScope(), getRange(),
                                            ExpressionList::ListKindWrapped));
    el->addElement(rep);
    rep->clearContext(AssignmentRHS);
    rep = el;
  }
  if (rep->is(KindOfSimpleVariable) && !is(KindOfSimpleVariable)) {
    static_pointer_cast<SimpleVariable>(rep)->setAlwaysStash();
  }
  rep->copyContext(m_context & ~(DeadStore|AccessContext));
  if (TypePtr t1 = getType()) {
    if (TypePtr t2 = rep->getType()) {
      if (!Type::SameType(t1, t2)) {
        rep->setExpectedType(t1);
      }
    }
  }

  if (rep->getScope() != getScope()) {
    rep->resetScope(getScope());
  }

  return rep;
}
开发者ID:andyanx,项目名称:hhvm,代码行数:31,代码来源:expression.cpp

示例9: buildPtrFromArray

	ExpressionPtr buildPtrFromArray(const ExpressionPtr& arrExpr) {
		assert_pred1(isReference, arrExpr) << "Trying to buildPtrFromArray from non-ref.";
		assert_pred1(isArray, core::analysis::getReferencedType(arrExpr->getType())) << "Trying to buildPtrFromArray from non-array.";
		IRBuilder builder(arrExpr->getNodeManager());
		auto& pExt = arrExpr->getNodeManager().getLangExtension<PointerExtension>();
		return builder.callExpr(pExt.getPtrFromArray(), arrExpr);
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:7,代码来源:pointer.cpp

示例10: buildPtrReinterpret

	ExpressionPtr buildPtrReinterpret(const ExpressionPtr& ptrExpr, const TypePtr& newElementType) {
		assert_pred1(core::lang::isPointer, ptrExpr) << "Trying to build a ptr reinterpret from non-ptr.";
		PointerType srcTy(ptrExpr->getType());
		// early exit if there is nothing to do
		if(srcTy.getElementType() == newElementType) return ptrExpr;
		// otherwise, build reinterpret
		IRBuilder builder(ptrExpr->getNodeManager());
		auto& pExt = ptrExpr->getNodeManager().getLangExtension<PointerExtension>();
		return builder.callExpr(pExt.getPtrReinterpret(), ptrExpr, builder.getTypeLiteral(newElementType));
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:10,代码来源:pointer.cpp

示例11: buildPtrCast

	ExpressionPtr buildPtrCast(const ExpressionPtr& ptrExpr, bool newConst, bool newVolatile) {
		assert_pred1(core::lang::isPointer, ptrExpr) << "Trying to build a ptr cast from non-ptr.";
		PointerType srcTy(ptrExpr->getType());
		// early exit if there is nothing to do
		if(srcTy.isConst() == newConst && srcTy.isVolatile() == newVolatile) return ptrExpr;
		// otherwise, build cast
		IRBuilder builder(ptrExpr->getNodeManager());
		auto& pExt = ptrExpr->getNodeManager().getLangExtension<PointerExtension>();
		auto& bmExt = ptrExpr->getNodeManager().getLangExtension<BooleanMarkerExtension>();
		return builder.callExpr(pExt.getPtrCast(), ptrExpr, bmExt.getMarkerTypeLiteral(newConst), bmExt.getMarkerTypeLiteral(newVolatile));
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:11,代码来源:pointer.cpp

示例12: wrapBoolean

void QOpExpression::wrapBoolean(CodeGenerator &cg,
                                AnalysisResultPtr ar,
                                ExpressionPtr exp) {
  TypePtr t(exp->getType());
  ASSERT(t);
  bool wrap = false;
  if (!t->is(Type::KindOfBoolean)) {
    wrap = true;
    cg_printf("toBoolean(");
  }
  exp->outputCPP(cg, ar);
  if (wrap) cg_printf(")");
}
开发者ID:AviMoto,项目名称:hiphop-php,代码行数:13,代码来源:qop_expression.cpp

示例13: buildPtrOperation

	ExpressionPtr buildPtrOperation(BasicGenerator::Operator op, const ExpressionPtr& ptrExpr) {
		assert_true(isReference(ptrExpr) && isPointer(core::analysis::getReferencedType(ptrExpr->getType())))
			<< "Trying to build a unary pointer operation with non-ref<ptr>.";
		IRBuilder builder(ptrExpr->getNodeManager());
		auto& pExt = ptrExpr->getNodeManager().getLangExtension<PointerExtension>();
		switch(op) {
		case BasicGenerator::Operator::PostInc: return builder.callExpr(pExt.getPtrPostInc(), ptrExpr);
		case BasicGenerator::Operator::PostDec: return builder.callExpr(pExt.getPtrPostDec(), ptrExpr);
		case BasicGenerator::Operator::PreInc: return builder.callExpr(pExt.getPtrPreInc(), ptrExpr);
		case BasicGenerator::Operator::PreDec: return builder.callExpr(pExt.getPtrPreDec(), ptrExpr);
		default: break;
		}

		assert_fail() << "Unsupported unary pointer operation " << op;
		return ExpressionPtr();
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:16,代码来源:pointer.cpp

示例14: CheckNeededRHS

bool Expression::CheckNeededRHS(ExpressionPtr value) {
  bool needed = true;
  always_assert(value);
  while (value->is(KindOfAssignmentExpression)) {
    value = dynamic_pointer_cast<AssignmentExpression>(value)->getValue();
  }
  if (value->isScalar()) {
    needed = false;
  } else {
    TypePtr type = value->getType();
    if (type && (type->is(Type::KindOfSome) || type->is(Type::KindOfAny))) {
      type = value->getActualType();
    }
    if (type && type->isNoObjectInvolved()) needed = false;
  }
  return needed;
}
开发者ID:andyanx,项目名称:hhvm,代码行数:17,代码来源:expression.cpp

示例15: updateParams

void RefDict::updateParams() {
  ControlFlowGraph *g = m_am.graph();
  ControlBlock *b     = g->getDfBlock(1);

  BitOps::Bits *refbv = b->getRow(DataFlow::PRefIn);
  BitOps::Bits *objbv = b->getRow(DataFlow::PObjIn);

  for (int i = size(); i--; ) {
    if (ExpressionPtr e = get(i)) {
      always_assert(e->is(Expression::KindOfSimpleVariable));
      always_assert(((unsigned int)i) == e->getCanonID());
      Symbol *sym = static_pointer_cast<SimpleVariable>(e)->getSymbol();
      if (sym && (sym->isParameter() || sym->isClosureVar())) {
        TypePtr paramType;
        bool isRef;
        if (sym->isParameter()) {
          ExpressionListPtr methodParams = m_method_stmt->getParams();
          ExpressionPtr paramExprPtr =
              (*methodParams)[sym->getParameterIndex()];
          paramType = paramExprPtr->getType();
          isRef = m_method_stmt->isRef(sym->getParameterIndex());
        } else {
          assert(sym->isClosureVar());
          // can only assume it is a Variant for now
          paramType = Type::Variant;
          isRef = sym->isRefClosureVar();
        }
        if (first_pass) {
          if (isRef || sym->isCallTimeRef()) {
            BitOps::set_bit(i, refbv, true);
          }
        } else {
          if (paramType) {
            if (!paramType->isNoObjectInvolved()) {
              BitOps::set_bit(i, objbv, true);
            }
          } else {
            // no type information, so we must assume it holds an object
            BitOps::set_bit(i, objbv, true);
          }
        }
      }
    }
  }
}
开发者ID:Bluarggag,项目名称:hhvm,代码行数:45,代码来源:ref_dict.cpp


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