本文整理汇总了C++中AssignmentExpressionPtr类的典型用法代码示例。如果您正苦于以下问题:C++ AssignmentExpressionPtr类的具体用法?C++ AssignmentExpressionPtr怎么用?C++ AssignmentExpressionPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssignmentExpressionPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getClassScope
void ClassVariable::analyzeProgramImpl(AnalysisResultPtr ar) {
m_declaration->analyzeProgram(ar);
AnalysisResult::Phase phase = ar->getPhase();
if (phase != AnalysisResult::AnalyzeAll) {
return;
}
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);
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
scope->getVariables()->setClassInitVal(var->getName(), value);
scope->getVariables()->markOverride(ar, var->getName());
} else {
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(exp);
scope->getVariables()->markOverride(ar, var->getName());
scope->getVariables()->setClassInitVal(var->getName(),
makeConstant(ar, "null"));
}
}
}
示例2: onParse
void ClassVariable::onParse(AnalysisResultPtr ar) {
ModifierExpressionPtr modifiers =
ar->getScope()->setModifiers(m_modifiers);
for (int i = 0; i < m_declaration->getCount(); i++) {
VariableTablePtr variables = ar->getScope()->getVariables();
ExpressionPtr exp = (*m_declaration)[i];
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(var)->getName();
if (variables->isPresent(name)) {
ar->getCodeError()->record(CodeError::DeclaredVariableTwice, exp);
}
IParseHandlerPtr ph = dynamic_pointer_cast<IParseHandler>(exp);
ph->onParse(ar);
} else {
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(exp)->getName();
if (variables->isPresent(name)) {
ar->getCodeError()->record(CodeError::DeclaredVariableTwice, exp);
}
variables->add(name, TypePtr(), false, ar, exp, m_modifiers);
}
}
ar->getScope()->setModifiers(modifiers);
}
示例3: preOptimize
StatementPtr ClassConstant::preOptimize(AnalysisResultConstPtr ar) {
if (!isAbstract() && !isTypeconst()) {
for (int i = 0; i < m_exp->getCount(); i++) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>((*m_exp)[i]);
ExpressionPtr var = assignment->getVariable();
ExpressionPtr val = assignment->getValue();
const std::string &name =
dynamic_pointer_cast<ConstantExpression>(var)->getName();
Symbol *sym = getScope()->getConstants()->getSymbol(name);
Lock lock(BlockScope::s_constMutex);
if (sym->getValue() != val) {
getScope()->addUpdates(BlockScope::UseKindConstRef);
sym->setValue(val);
}
}
}
// abstract constants are not added to the constant table and don't have
// any values to propagate.
return StatementPtr();
}
示例4: ASSERT
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);
}
}
}
}
}
示例5: assert
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);
}
}
}
}
}
示例6: onParseRecur
void ClassVariable::onParseRecur(AnalysisResultConstPtr ar,
ClassScopePtr scope) {
ModifierExpressionPtr modifiers =
scope->setModifiers(m_modifiers);
for (int i = 0; i < m_declaration->getCount(); i++) {
VariableTablePtr variables = scope->getVariables();
ExpressionPtr exp = (*m_declaration)[i];
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(var)->getName();
if (variables->isPresent(name)) {
Compiler::Error(Compiler::DeclaredVariableTwice, exp);
m_declaration->removeElement(i--);
} else {
assignment->onParseRecur(ar, scope);
}
} else {
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(exp)->getName();
if (variables->isPresent(name)) {
Compiler::Error(Compiler::DeclaredVariableTwice, exp);
m_declaration->removeElement(i--);
} else {
variables->add(name, Type::Variant, false, ar, exp, m_modifiers);
}
}
}
scope->setModifiers(modifiers);
}
示例7: shared_from_this
void ClassVariable::analyzeProgram(AnalysisResultPtr ar) {
m_declaration->analyzeProgram(ar);
AnalysisResult::Phase phase = ar->getPhase();
if (phase != AnalysisResult::AnalyzeAll) {
return;
}
if (m_modifiers->isAbstract()) {
Compiler::Error(Compiler::AbstractProperty, shared_from_this());
}
ClassScopePtr scope = getClassScope();
for (int i = 0; i < m_declaration->getCount(); i++) {
ExpressionPtr exp = (*m_declaration)[i];
bool error;
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
scope->getVariables()->setClassInitVal(var->getName(), value);
error = scope->getVariables()->markOverride(ar, var->getName());
} else {
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(exp);
error = scope->getVariables()->markOverride(ar, var->getName());
scope->getVariables()->setClassInitVal(var->getName(),
makeConstant(ar, "null"));
}
if (error) {
Compiler::Error(Compiler::InvalidOverride, exp);
}
}
}
示例8: parseTimeFatal
void ClassConstant::onParseRecur(AnalysisResultConstPtr ar,
ClassScopePtr scope) {
ConstantTablePtr constants = scope->getConstants();
if (scope->isTrait()) {
parseTimeFatal(Compiler::InvalidTraitStatement,
"Traits cannot have constants");
}
for (int i = 0; i < m_exp->getCount(); i++) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>((*m_exp)[i]);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<ConstantExpression>(var)->getName();
if (constants->isPresent(name)) {
assignment->parseTimeFatal(Compiler::DeclaredConstantTwice,
"Cannot redeclare %s::%s",
scope->getOriginalName().c_str(),
name.c_str());
} else {
assignment->onParseRecur(ar, scope);
}
}
}
示例9: parseTimeFatal
void ClassConstant::onParseRecur(AnalysisResultConstPtr ar,
ClassScopePtr scope) {
ConstantTablePtr constants = scope->getConstants();
if (scope->isTrait()) {
parseTimeFatal(Compiler::InvalidTraitStatement,
"Traits cannot have constants");
}
if (isAbstract()) {
for (int i = 0; i < m_exp->getCount(); i++) {
ConstantExpressionPtr exp =
dynamic_pointer_cast<ConstantExpression>((*m_exp)[i]);
const std::string &name = exp->getName();
if (constants->isPresent(name)) {
exp->parseTimeFatal(Compiler::DeclaredConstantTwice,
"Cannot redeclare %s::%s",
scope->getOriginalName().c_str(),
name.c_str());
}
// HACK: break attempts to write global constants here;
// see ConstantExpression::preOptimize
exp->setContext(Expression::LValue);
// Unlike with assignment expression below, nothing needs to be added
// to the scope's constant table
}
} else {
for (int i = 0; i < m_exp->getCount(); i++) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>((*m_exp)[i]);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<ConstantExpression>(var)->getName();
if (constants->isPresent(name)) {
assignment->parseTimeFatal(Compiler::DeclaredConstantTwice,
"Cannot redeclare %s::%s",
scope->getOriginalName().c_str(),
name.c_str());
} else {
if (isTypeconst()) {
// We do not want type constants to be available at run time.
// To ensure this we do not want them to be added to the constants
// table. The constants table is used to inline values for expressions
// See ClassConstantExpression::preOptimize.
// AssignmentExpression::onParseRecur essentially adds constants to
// the constant table so we skip it.
continue;
}
assignment->onParseRecur(ar, scope);
}
}
}
}
示例10: getClassScope
StatementPtr ClassVariable::preOptimize(AnalysisResultConstPtr ar) {
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);
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
scope->getVariables()->setClassInitVal(var->getName(), value);
}
}
return StatementPtr();
}
示例11: analyzeProgramImpl
void ClassVariable::analyzeProgramImpl(AnalysisResultPtr ar) {
m_declaration->analyzeProgram(ar);
if (ar->getPhase() != AnalysisResult::AnalyzeInclude) return;
ClassScopePtr scope = ar->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);
SimpleVariablePtr var =
dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ExpressionPtr value = assignment->getValue();
scope->getVariables()->setClassInitVal(var->getName(), value);
}
}
}
示例12: ExpressionPtr
ExpressionPtr Option::GetValue(VariableTablePtr variables,
const char *varName) {
ConstructPtr decl = variables->getDeclaration(varName);
if (!decl) {
return ExpressionPtr();
}
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(decl);
if (!assignment) {
Logger::Error("Line %d: Ignored option %s", decl->getLocation()->line1,
varName);
return ExpressionPtr();
}
return assignment->getValue();
}
示例13: parseTimeFatal
void ClassVariable::onParseRecur(AnalysisResultConstPtr ar,
ClassScopePtr scope) {
ModifierExpressionPtr modifiers =
scope->setModifiers(m_modifiers);
if (m_modifiers->isAbstract()) {
parseTimeFatal(Compiler::InvalidAttribute,
"Properties cannot be declared abstract");
}
if (m_modifiers->isFinal()) {
parseTimeFatal(Compiler::InvalidAttribute,
"Properties cannot be declared final");
}
for (int i = 0; i < m_declaration->getCount(); i++) {
VariableTablePtr variables = scope->getVariables();
ExpressionPtr exp = (*m_declaration)[i];
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(var)->getName();
if (variables->isPresent(name)) {
exp->parseTimeFatal(Compiler::DeclaredVariableTwice,
"Cannot redeclare %s::$%s",
scope->getOriginalName().c_str(), name.c_str());
} else {
assignment->onParseRecur(ar, scope);
}
} else {
const std::string &name =
dynamic_pointer_cast<SimpleVariable>(exp)->getName();
if (variables->isPresent(name)) {
exp->parseTimeFatal(Compiler::DeclaredVariableTwice,
"Cannot redeclare %s::$%s",
scope->getOriginalName().c_str(), name.c_str());
} else {
variables->add(name, Type::Null, false, ar, exp, m_modifiers);
}
}
}
scope->setModifiers(modifiers);
}
示例14: addTraitPropsToScope
void ClassVariable::addTraitPropsToScope(AnalysisResultPtr ar,
ClassScopePtr scope) {
ModifierExpressionPtr modifiers = scope->setModifiers(m_modifiers);
VariableTablePtr variables = scope->getVariables();
for (int i = 0; i < m_declaration->getCount(); i++) {
ExpressionPtr exp = (*m_declaration)[i];
SimpleVariablePtr var;
ExpressionPtr value;
if (exp->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>(exp);
var = dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
value = assignment->getValue();
} else {
var = dynamic_pointer_cast<SimpleVariable>(exp);
value = makeConstant(ar, "null");
}
const string &name = var->getName();
Symbol *sym;
ClassScopePtr prevScope = variables->isPresent(name) ? scope :
scope->getVariables()->findParent(ar, name, sym);
if (prevScope &&
!isEquivRedecl(name, exp, m_modifiers,
prevScope->getVariables()->getSymbol(name))) {
Compiler::Error(Compiler::DeclaredVariableTwice, exp);
m_declaration->removeElement(i--);
} else {
if (prevScope != scope) { // Property is new or override, so add it
variables->add(name, Type::Variant, false, ar, exp, m_modifiers);
variables->getSymbol(name)->setValue(exp);
variables->setClassInitVal(name, value);
variables->markOverride(ar, name);
} else {
m_declaration->removeElement(i--);
}
}
}
scope->setModifiers(modifiers);
}
示例15: onParseRecur
void ClassConstant::onParseRecur(AnalysisResultConstPtr ar,
ClassScopePtr scope) {
ConstantTablePtr constants = scope->getConstants();
for (int i = 0; i < m_exp->getCount(); i++) {
AssignmentExpressionPtr assignment =
dynamic_pointer_cast<AssignmentExpression>((*m_exp)[i]);
ExpressionPtr var = assignment->getVariable();
const std::string &name =
dynamic_pointer_cast<ConstantExpression>(var)->getName();
if (constants->isPresent(name)) {
Compiler::Error(Compiler::DeclaredConstantTwice, assignment);
m_exp->removeElement(i--);
} else {
assignment->onParseRecur(ar, scope);
}
}
}