本文整理汇总了C++中ConstantTablePtr::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantTablePtr::setValue方法的具体用法?C++ ConstantTablePtr::setValue怎么用?C++ ConstantTablePtr::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantTablePtr
的用法示例。
在下文中一共展示了ConstantTablePtr::setValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inferAndCheck
TypePtr SimpleFunctionCall::inferAndCheck(AnalysisResultPtr ar, TypePtr type,
bool coerce) {
reset();
ConstructPtr self = shared_from_this();
// handling define("CONSTANT", ...);
if (m_className.empty()) {
if (m_type == DefineFunction && m_params && m_params->getCount() >= 2) {
ScalarExpressionPtr name =
dynamic_pointer_cast<ScalarExpression>((*m_params)[0]);
string varName;
if (name) {
varName = name->getIdentifier();
if (!varName.empty()) {
ExpressionPtr value = (*m_params)[1];
TypePtr varType = value->inferAndCheck(ar, NEW_TYPE(Some), false);
ar->getDependencyGraph()->
addParent(DependencyGraph::KindOfConstant,
ar->getName(), varName, self);
ConstantTablePtr constants =
ar->findConstantDeclarer(varName)->getConstants();
if (constants != ar->getConstants()) {
if (value && !value->isScalar()) {
constants->setDynamic(ar, varName);
varType = Type::Variant;
}
if (constants->isDynamic(varName)) {
m_dynamicConstant = true;
ar->getScope()->getVariables()->
setAttribute(VariableTable::NeedGlobalPointer);
} else {
constants->setType(ar, varName, varType, true);
}
// in case the old 'value' has been optimized
constants->setValue(ar, varName, value);
}
return checkTypesImpl(ar, type, Type::Boolean, coerce);
}
}
if (varName.empty() && ar->isFirstPass()) {
ar->getCodeError()->record(self, CodeError::BadDefine, self);
}
} else if (m_type == ExtractFunction) {
ar->getScope()->getVariables()->forceVariants(ar);
}
}
FunctionScopePtr func;
// avoid raising both MissingObjectContext and UnknownFunction
bool errorFlagged = false;
if (m_className.empty()) {
func = ar->findFunction(m_name);
} else {
ClassScopePtr cls = ar->resolveClass(m_className);
if (cls && cls->isVolatile()) {
ar->getScope()->getVariables()
->setAttribute(VariableTable::NeedGlobalPointer);
}
if (!cls || cls->isRedeclaring()) {
if (cls) {
m_redeclaredClass = true;
}
if (!cls && ar->isFirstPass()) {
ar->getCodeError()->record(self, CodeError::UnknownClass, self);
}
if (m_params) {
m_params->inferAndCheck(ar, NEW_TYPE(Some), false);
}
return checkTypesImpl(ar, type, Type::Variant, coerce);
}
m_derivedFromRedeclaring = cls->derivesFromRedeclaring();
m_validClass = true;
if (m_name == "__construct") {
// if the class is known, php will try to identify class-name ctor
func = cls->findConstructor(ar, true);
}
else {
func = cls->findFunction(ar, m_name, true, true);
}
if (func && !func->isStatic()) {
ClassScopePtr clsThis = ar->getClassScope();
FunctionScopePtr funcThis = ar->getFunctionScope();
if (!clsThis ||
(clsThis->getName() != m_className &&
!clsThis->derivesFrom(ar, m_className)) ||
funcThis->isStatic()) {
// set the method static to avoid "unknown method" runtime exception
if (Option::StaticMethodAutoFix && !func->containsThis()) {
func->setStatic();
}
if (ar->isFirstPass()) {
ar->getCodeError()->record(self, CodeError::MissingObjectContext,
self);
errorFlagged = true;
}
//.........这里部分代码省略.........