本文整理汇总了C++中AnalysisResultPtr::isConstantRedeclared方法的典型用法代码示例。如果您正苦于以下问题:C++ AnalysisResultPtr::isConstantRedeclared方法的具体用法?C++ AnalysisResultPtr::isConstantRedeclared怎么用?C++ AnalysisResultPtr::isConstantRedeclared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnalysisResultPtr
的用法示例。
在下文中一共展示了AnalysisResultPtr::isConstantRedeclared方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isDefineWithoutImpl
bool SimpleFunctionCall::isDefineWithoutImpl(AnalysisResultPtr ar) {
if (!m_className.empty()) return false;
if (m_type == DefineFunction && m_params && m_params->getCount() >= 2) {
if (m_dynamicConstant) return false;
ScalarExpressionPtr name =
dynamic_pointer_cast<ScalarExpression>((*m_params)[0]);
if (!name) return false;
string varName = name->getIdentifier();
if (varName.empty()) return false;
if (ar->getConstants()->isSystem(varName)) return true;
ExpressionPtr value = (*m_params)[1];
return (!ar->isConstantRedeclared(varName)) && value->isScalar();
} else {
return false;
}
}
示例2: outputCPPImpl
void SimpleFunctionCall::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
bool linemap = outputLineMap(cg, ar, true);
if (!m_lambda.empty()) {
cg.printf("\"%s\"", m_lambda.c_str());
if (linemap) cg.printf(")");
return;
}
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();
ExpressionPtr value = (*m_params)[1];
if (varName.empty()) {
cg.printf("throw_fatal(\"bad define\")");
} else if (m_dynamicConstant) {
cg.printf("g->declareConstant(\"%s\", g->%s%s, ",
varName.c_str(), Option::ConstantPrefix,
varName.c_str());
value->outputCPP(cg, ar);
cg.printf(")");
} else {
bool needAssignment = true;
bool isSystem = ar->getConstants()->isSystem(varName);
if (isSystem ||
((!ar->isConstantRedeclared(varName)) && value->isScalar())) {
needAssignment = false;
}
if (needAssignment) {
cg.printf("%s%s = ", Option::ConstantPrefix, varName.c_str());
value->outputCPP(cg, ar);
}
}
} else {
cg.printf("throw_fatal(\"bad define\")");
}
if (linemap) cg.printf(")");
return;
}
if (m_name == "func_num_args") {
cg.printf("num_args");
if (linemap) cg.printf(")");
return;
}
switch (m_type) {
case VariableArgumentFunction:
{
FunctionScopePtr func =
dynamic_pointer_cast<FunctionScope>(ar->getScope());
if (func) {
cg.printf("%s(", m_name.c_str());
func->outputCPPParamsCall(cg, ar, true);
if (m_params) {
cg.printf(",");
m_params->outputCPP(cg, ar);
}
cg.printf(")");
if (linemap) cg.printf(")");
return;
}
}
break;
case FunctionExistsFunction:
case ClassExistsFunction:
case InterfaceExistsFunction:
{
bool literalString = false;
string symbol;
if (m_params && m_params->getCount() == 1) {
ExpressionPtr value = (*m_params)[0];
if (value->isScalar()) {
ScalarExpressionPtr name =
dynamic_pointer_cast<ScalarExpression>(value);
if (name && name->isLiteralString()) {
literalString = true;
symbol = name->getLiteralString();
}
}
}
if (literalString) {
switch (m_type) {
case FunctionExistsFunction:
{
const std::string &lname = Util::toLower(symbol);
bool dynInvoke = Option::DynamicInvokeFunctions.find(lname) !=
Option::DynamicInvokeFunctions.end();
if (!dynInvoke) {
FunctionScopePtr func = ar->findFunction(lname);
if (func) {
if (!func->isDynamic()) {
if (func->isRedeclaring()) {
const char *name = func->getName().c_str();
cg.printf("(%s->%s%s != invoke_failed_%s)",
cg.getGlobals(ar), Option::InvokePrefix,
//.........这里部分代码省略.........