本文整理汇总了C++中ExpressionPtr::getImplementedType方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::getImplementedType方法的具体用法?C++ ExpressionPtr::getImplementedType怎么用?C++ ExpressionPtr::getImplementedType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::getImplementedType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputStringExpr
static void outputStringExpr(CodeGenerator &cg, AnalysisResultPtr ar,
ExpressionPtr exp, bool asLitStr) {
if (asLitStr && exp->isLiteralString()) {
const std::string &s = exp->getLiteralString();
char *enc = string_cplus_escape(s.c_str(), s.size());
cg_printf("\"%s\", %d", enc, s.size());
free(enc);
return;
}
bool close = false;
if ((exp->hasContext(Expression::LValue) &&
(!exp->getActualType()->is(Type::KindOfString) ||
(exp->getImplementedType() &&
!exp->getImplementedType()->is(Type::KindOfString))))
||
!exp->getType()->is(Type::KindOfString)) {
cg_printf("toString(");
close = true;
}
exp->outputCPP(cg, ar);
if (close) cg_printf(")");
}
示例2: SetExpTypeForExistsContext
void UnaryOpExpression::SetExpTypeForExistsContext(AnalysisResultPtr ar,
ExpressionPtr e,
bool allowPrimitives) {
if (!e) return;
TypePtr at(e->getActualType());
if (!allowPrimitives && at &&
at->isExactType() && at->isPrimitive()) {
at = e->inferAndCheck(ar, Type::Variant, true);
}
TypePtr it(e->getImplementedType());
TypePtr et(e->getExpectedType());
if (et && et->is(Type::KindOfVoid)) e->setExpectedType(TypePtr());
if (at && (!it || Type::IsMappedToVariant(it)) &&
((allowPrimitives && Type::HasFastCastMethod(at)) ||
(!allowPrimitives &&
(at->is(Type::KindOfObject) ||
at->is(Type::KindOfArray) ||
at->is(Type::KindOfString))))) {
e->setExpectedType(it ? at : TypePtr());
}
}
示例3: checkCopyElision
static bool checkCopyElision(FunctionScopePtr func, ExpressionPtr exp) {
if (!exp->getType()->is(Type::KindOfVariant) || func->isRefReturn()) {
return false;
}
TypePtr imp = exp->getImplementedType();
if (!imp) imp = exp->getActualType();
if (!imp || !imp->is(Type::KindOfVariant)) return false;
if (func->getNRVOFix() && exp->is(Expression::KindOfSimpleVariable)) {
return true;
}
if (FunctionCallPtr fc = dynamic_pointer_cast<FunctionCall>(exp)) {
FunctionScopePtr fs = fc->getFuncScope();
if (!fs || fs->isRefReturn()) {
return true;
}
}
return false;
}
示例4: inferParamTypes
//.........这里部分代码省略.........
Compiler::Error(Compiler::TooManyArgument, exp, m_stmt);
}
valid = false;
if (!Option::AllDynamic) setDynamic();
}
}
bool canSetParamType = isUserFunction() && !m_overriding && !m_perfectVirtual;
for (int i = 0; i < params->getCount(); i++) {
ExpressionPtr param = (*params)[i];
if (i < m_maxParam && param->hasContext(Expression::RefParameter)) {
/**
* This should be very un-likely, since call time pass by ref is a
* deprecated, not very widely used (at least in FB codebase) feature.
*/
TRY_LOCK_THIS();
Symbol *sym = getVariables()->addSymbol(m_paramNames[i]);
sym->setLvalParam();
sym->setCallTimeRef();
}
if (valid && param->hasContext(Expression::InvokeArgument)) {
param->clearContext(Expression::InvokeArgument);
param->clearContext(Expression::RefValue);
param->clearContext(Expression::NoRefWrapper);
}
bool isRefVararg = (i >= m_maxParam && isReferenceVariableArgument());
if ((i < m_maxParam && isRefParam(i)) || isRefVararg) {
param->setContext(Expression::LValue);
param->setContext(Expression::RefValue);
param->inferAndCheck(ar, Type::Variant, true);
} else if (!(param->getContext() & Expression::RefParameter)) {
param->clearContext(Expression::LValue);
param->clearContext(Expression::RefValue);
param->clearContext(Expression::InvokeArgument);
param->clearContext(Expression::NoRefWrapper);
}
TypePtr expType;
/**
* Duplicate the logic of getParamType(i), w/o the mutation
*/
TypePtr paramType(i < m_maxParam && !isZendParamMode() ?
m_paramTypes[i] : TypePtr());
if (!paramType) paramType = Type::Some;
if (valid && !canSetParamType && i < m_maxParam &&
(!Option::HardTypeHints || !m_paramTypeSpecs[i])) {
/**
* What is this magic, you might ask?
*
* Here, we take advantage of implicit conversion from every type to
* Variant. Essentially, we don't really care what type comes out of this
* expression since it'll just get converted anyways. Doing it this way
* allows us to generate less temporaries along the way.
*/
TypePtr optParamType(paramType->is(Type::KindOfVariant) ?
Type::Some : paramType);
expType = param->inferAndCheck(ar, optParamType, false);
} else {
expType = param->inferAndCheck(ar, Type::Some, false);
}
if (i < m_maxParam) {
if (!Option::HardTypeHints || !m_paramTypeSpecs[i]) {
if (canSetParamType) {
if (!Type::SameType(paramType, expType) &&
!paramType->is(Type::KindOfVariant)) {
TRY_LOCK_THIS();
paramType = setParamType(ar, i, expType);
} else {
// do nothing - how is this safe? well, if we ever observe
// paramType == expType, then this means at some point in the past,
// somebody called setParamType() with expType. thus, by calling
// setParamType() again with expType, we contribute no "new"
// information. this argument also still applies in the face of
// concurrency
}
}
// See note above. If we have an implemented type, however, we
// should set the paramType to the implemented type to avoid an
// un-necessary cast
if (paramType->is(Type::KindOfVariant)) {
TypePtr it(param->getImplementedType());
paramType = it ? it : expType;
}
if (valid) {
if (!Type::IsLegalCast(ar, expType, paramType) &&
paramType->isNonConvertibleType()) {
param->inferAndCheck(ar, paramType, true);
}
param->setExpectedType(paramType);
}
}
}
// we do a best-effort check for bad pass-by-reference and do not report
// error for some vararg case (e.g., array_multisort can have either ref
// or value for the same vararg).
if (!isRefVararg || !isMixedVariableArgument()) {
Expression::CheckPassByReference(ar, param);
}
}
return ret;
}