本文整理汇总了C++中ExpressionPtr::containsDynamicConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionPtr::containsDynamicConstant方法的具体用法?C++ ExpressionPtr::containsDynamicConstant怎么用?C++ ExpressionPtr::containsDynamicConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionPtr
的用法示例。
在下文中一共展示了ExpressionPtr::containsDynamicConstant方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inferTypes
void ClassVariable::inferTypes(AnalysisResultPtr ar) {
ASSERT(getScope().get() == getClassScope().get());
IMPLEMENT_INFER_AND_CHECK_ASSERT(getScope());
m_declaration->inferAndCheck(ar, Type::Variant, false);
if (m_modifiers->isStatic()) {
ClassScopePtr scope = getClassScope();
for (int i = 0; i < m_declaration->getCount(); i++) {
ExpressionPtr exp = (*m_declaration)[i];
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
// If the class variable's type is Object, we have to
// force it to be a Variant, because we don't include
// the class header files in global_variables.h
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
if (var) {
TypePtr type = scope->getVariables()->getFinalType(var->getName());
if (type->is(Type::KindOfObject)) {
scope->getVariables()->forceVariant(ar, var->getName(),
VariableTable::AnyVars);
}
}
ExpressionPtr value = assignment->getValue();
if (value->containsDynamicConstant(ar)) {
scope->getVariables()->
setAttribute(VariableTable::ContainsDynamicStatic);
}
}
}
}
}
示例2: inferTypes
void ClassVariable::inferTypes(AnalysisResultPtr ar) {
assert(getScope().get() == getClassScope().get());
IMPLEMENT_INFER_AND_CHECK_ASSERT(getScope());
// assignments will ignore the passed in type,
// but we need to ensure that Null is applied to
// the simple variables.
m_declaration->inferAndCheck(ar, Type::Null, false);
if (m_modifiers->isStatic()) {
ClassScopePtr scope = getClassScope();
for (int i = 0; i < m_declaration->getCount(); i++) {
ExpressionPtr exp = (*m_declaration)[i];
SimpleVariablePtr var;
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
ExpressionPtr value = assignment->getValue();
if (value->containsDynamicConstant(ar)) {
scope->getVariables()->
setAttribute(VariableTable::ContainsDynamicStatic);
}
}
}
}
}
示例3: inferTypes
void ClassVariable::inferTypes(AnalysisResultPtr ar) {
m_declaration->inferAndCheck(ar, NEW_TYPE(Some), false);
if (m_modifiers->isStatic()) {
ClassScopePtr scope = ar->getClassScope();
for (int i = 0; i < m_declaration->getCount(); i++) {
ExpressionPtr exp = (*m_declaration)[i];
if (exp->is(Expression::KindOfAssignmentExpression)) {
scope->setNeedStaticInitializer();
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
// If the class variable's type is Object, we have to
// force it to be a Variant, because we don't include
// the class header files in global_variables.h
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
if (var) {
TypePtr type = scope->getVariables()->getFinalType(var->getName());
if (type->is(Type::KindOfObject)) {
scope->getVariables()->forceVariant(ar, var->getName());
}
}
ExpressionPtr value = assignment->getValue();
if (value->containsDynamicConstant(ar)) {
scope->getVariables()->
setAttribute(VariableTable::ContainsDynamicStatic);
}
} else {
SimpleVariablePtr var = dynamic_pointer_cast<SimpleVariable>(exp);
TypePtr type = scope->getVariables()->getFinalType(var->getName());
// If the class variable's type is Object, we have to
// force it to be a Variant, because we don't include
// the class header files in global_variables.h
if (type->is(Type::KindOfObject)) {
scope->getVariables()->forceVariant(ar, var->getName());
}
const char *initializer = type->getCPPInitializer();
if (initializer) scope->setNeedStaticInitializer();
}
}
}
}
示例4: outputCPPImpl
void ClassVariable::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
ClassScopePtr scope = ar->getClassScope();
bool derivFromRedec = scope->derivesFromRedeclaring() &&
!m_modifiers->isPrivate();
for (int i = 0; i < m_declaration->getCount(); i++) {
ExpressionPtr exp = (*m_declaration)[i];
SimpleVariablePtr var;
TypePtr type;
switch (cg.getContext()) {
case CodeGenerator::CppConstructor:
if (m_modifiers->isStatic()) continue;
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
var = dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
value->outputCPPBegin(cg, ar);
if (derivFromRedec) {
cg_printf("%sset(\"%s\",-1, ", Option::ObjectPrefix,
var->getName().c_str());
value->outputCPP(cg, ar);
cg_printf(")");
} else {
cg_printf("%s%s = ", Option::PropertyPrefix, var->getName().c_str());
value->outputCPP(cg, ar);
}
cg_printf(";\n");
value->outputCPPEnd(cg, ar);
} else {
var = dynamic_pointer_cast<SimpleVariable>(exp);
if (derivFromRedec) {
cg_printf("%sset(\"%s\",-1, null);\n", Option::ObjectPrefix,
var->getName().c_str());
} else {
type = scope->getVariables()->getFinalType(var->getName());
const char *initializer = type->getCPPInitializer();
if (initializer) {
cg_printf("%s%s = %s;\n", Option::PropertyPrefix,
var->getName().c_str(), initializer);
}
}
}
break;
case CodeGenerator::CppStaticInitializer:
{
if (!m_modifiers->isStatic()) continue;
VariableTablePtr variables = scope->getVariables();
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
var = dynamic_pointer_cast<SimpleVariable>
(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
if (value->containsDynamicConstant(ar)) continue;
cg_printf("g->%s%s%s%s = ",
Option::StaticPropertyPrefix, scope->getId(cg).c_str(),
Option::IdPrefix.c_str(), var->getName().c_str());
value->outputCPP(cg, ar);
} else {
var = dynamic_pointer_cast<SimpleVariable>(exp);
type = scope->getVariables()->getFinalType(var->getName());
const char *initializer = type->getCPPInitializer();
if (initializer) {
cg_printf("g->%s%s%s%s = %s",
Option::StaticPropertyPrefix, scope->getId(cg).c_str(),
Option::IdPrefix.c_str(), var->getName().c_str(),
initializer);
}
}
cg_printf(";\n");
}
break;
case CodeGenerator::CppLazyStaticInitializer:
{
if (!m_modifiers->isStatic()) continue;
if (!exp->is(Expression::KindOfAssignmentExpression)) continue;
VariableTablePtr variables = scope->getVariables();
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
var = dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
if (!value->containsDynamicConstant(ar)) continue;
value->outputCPPBegin(cg, ar);
cg_printf("g->%s%s%s%s = ",
Option::StaticPropertyPrefix, scope->getId(cg).c_str(),
Option::IdPrefix.c_str(), var->getName().c_str());
value->outputCPP(cg, ar);
cg_printf(";\n");
value->outputCPPEnd(cg, ar);
}
break;
default:
//.........这里部分代码省略.........
示例5: outputCPPImpl
//.........这里部分代码省略.........
var->getName().c_str());
value->outputCPP(cg, ar);
cg_printf(")");
}
} else {
if (type->is(Type::KindOfVariant)) {
cg_printf("%s%s(Variant::nullInit)",
Option::PropertyPrefix,
var->getName().c_str());
} else {
const char *initializer = type->getCPPInitializer();
ASSERT(initializer);
cg_printf("%s%s(%s)",
Option::PropertyPrefix,
var->getName().c_str(),
initializer);
}
}
}
break;
case CodeGenerator::CppInitializer:
if (initInInit) {
if (isAssign) {
value->outputCPPBegin(cg, ar);
if (derivFromRedec) {
cg_printf("%sset(", Option::ObjectPrefix);
cg_printString(var->getName(), ar, shared_from_this());
cg_printf(", ");
value->outputCPP(cg, ar);
cg_printf(")");
} else if (isValueNull) {
cg_printf("setNull(%s%s)", Option::PropertyPrefix,
var->getName().c_str());
} else {
cg_printf("%s%s = ", Option::PropertyPrefix, var->getName().c_str());
value->outputCPP(cg, ar);
}
cg_printf(";\n");
value->outputCPPEnd(cg, ar);
} else {
if (derivFromRedec) {
cg_printf("%sset(", Option::ObjectPrefix);
cg_printString(var->getName(), ar, shared_from_this());
cg_printf(", null_variant);\n");
} else {
if (type->is(Type::KindOfVariant)) {
cg_printf("setNull(%s%s);\n", Option::PropertyPrefix,
var->getName().c_str());
} else {
const char *initializer = type->getCPPInitializer();
ASSERT(initializer);
cg_printf("%s%s = %s;\n", Option::PropertyPrefix,
var->getName().c_str(), initializer);
}
}
}
}
break;
case CodeGenerator::CppStaticInitializer:
if (isAssign) {
if (value->containsDynamicConstant(ar)) continue;
if (sym->isOverride()) continue;
if (isValueNull) {
cg_printf("setNull(g->%s%s%s%s)",
Option::StaticPropertyPrefix, scope->getId().c_str(),
Option::IdPrefix.c_str(), var->getName().c_str());
} else {
cg_printf("g->%s%s%s%s = ",
Option::StaticPropertyPrefix, scope->getId().c_str(),
Option::IdPrefix.c_str(), var->getName().c_str());
value->outputCPP(cg, ar);
}
} else {
const char *initializer = type->getCPPInitializer();
if (initializer) {
cg_printf("g->%s%s%s%s = %s",
Option::StaticPropertyPrefix, scope->getId().c_str(),
Option::IdPrefix.c_str(), var->getName().c_str(),
initializer);
}
}
cg_printf(";\n");
break;
case CodeGenerator::CppLazyStaticInitializer:
if (!isAssign) continue;
if (!value->containsDynamicConstant(ar)) continue;
if (sym->isOverride()) continue;
value->outputCPPBegin(cg, ar);
cg_printf("g->%s%s%s%s = ",
Option::StaticPropertyPrefix, scope->getId().c_str(),
Option::IdPrefix.c_str(), var->getName().c_str());
value->outputCPP(cg, ar);
cg_printf(";\n");
value->outputCPPEnd(cg, ar);
break;
default:
break;
}
}
}