本文整理汇总了C++中AssignmentExpressionPtr::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ AssignmentExpressionPtr::getValue方法的具体用法?C++ AssignmentExpressionPtr::getValue怎么用?C++ AssignmentExpressionPtr::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssignmentExpressionPtr
的用法示例。
在下文中一共展示了AssignmentExpressionPtr::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyzeProgram
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);
}
}
}
示例2: 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);
}
}
}
}
}
示例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: 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);
}
}
}
}
}
示例5: analyzeProgramImpl
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"));
}
}
}
示例6: onParse
void ExpStatement::onParse(AnalysisResultConstPtr ar, FileScopePtr scope) {
if (Option::OutputHHBC && !ar->isParseOnDemand()) return;
if (!m_exp->is(Expression::KindOfAssignmentExpression)) return;
AssignmentExpressionPtr assign =
dynamic_pointer_cast<AssignmentExpression>(m_exp);
if (!assign->getVariable()->is(Expression::KindOfArrayElementExpression)) {
return;
}
if (!assign->getValue()->is(Expression::KindOfScalarExpression) ||
!dynamic_pointer_cast<ScalarExpression>
(assign->getValue())->isLiteralString()) {
return;
}
string file = assign->getValue()->getLiteralString();
if (file.empty()) return;
string s = assign->getText();
string path = Option::GetAutoloadRoot(s);
if (path.empty()) return;
if (path[path.length() - 1] != '/' && file[0] != '/') {
file = path + '/' + file;
} else {
file = path + file;
}
if (Option::OutputHHBC) {
ar->parseOnDemand(file);
return;
}
ScalarExpressionPtr exp
(new ScalarExpression(getScope(), assign->getValue()->getLocation(),
T_STRING, file, true));
IncludeExpressionPtr include
(new IncludeExpression(getScope(), assign->getLocation(),
exp, T_INCLUDE_ONCE));
include->setDocumentRoot(); // autoload always starts from document root
include->onParse(ar, scope);
m_exp = include;
}
示例7: preOptimize
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();
}
示例8: 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);
}
}
}
示例9: getCtorAndInitInfo
void ClassVariable::getCtorAndInitInfo(
ExpressionPtr exp,
bool &needsCppCtor,
bool &needsInit,
SimpleVariablePtr &var,
TypePtr &type,
Symbol *&sym,
ExpressionPtr &value) {
ClassScopePtr scope = getClassScope();
bool derivFromRedec = scope->derivesFromRedeclaring() &&
!m_modifiers->isPrivate();
AssignmentExpressionPtr assignment;
bool isAssign = exp->is(Expression::KindOfAssignmentExpression);
if (isAssign) {
assignment = static_pointer_cast<AssignmentExpression>(exp);
var = dynamic_pointer_cast<SimpleVariable>(assignment->getVariable());
ASSERT(var);
value = assignment->getValue();
ASSERT(value);
} else {
var = dynamic_pointer_cast<SimpleVariable>(exp);
ASSERT(var);
}
sym = scope->getVariables()->getSymbol(var->getName());
ASSERT(sym);
type = scope->getVariables()->getFinalType(var->getName());
ASSERT(type);
bool isValueNull = isAssign ? value->isLiteralNull() : false;
bool typeIsInitable = type->is(Type::KindOfVariant) ||
type->getCPPInitializer();
if (!derivFromRedec &&
!sym->isOverride() &&
(isAssign ?
(isValueNull ||
(value->is(Expression::KindOfScalarExpression) &&
type->isPrimitive())) :
typeIsInitable)) {
needsCppCtor = true;
} else if (isAssign || typeIsInitable) {
// if we aren't an assignment and the type is not a variant
// w/ no CPP initializer, then we currently don't bother
// to initialize it in init().
needsInit = true;
}
}
示例10: GetValue
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();
}
示例11: 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);
}
示例12: 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();
}
}
}
}
示例13: preOptimize
StatementPtr ClassConstant::preOptimize(AnalysisResultConstPtr ar) {
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);
}
}
return StatementPtr();
}
示例14: collectAliasInfoRecur
void AliasManager::collectAliasInfoRecur(ConstructPtr cs) {
if (!cs) {
return;
}
if (StatementPtr s = dpc(Statement, cs)) {
switch (s->getKindOf()) {
case Statement::KindOfFunctionStatement:
case Statement::KindOfMethodStatement:
case Statement::KindOfClassStatement:
case Statement::KindOfInterfaceStatement:
return;
default:
break;
}
}
int nkid = cs->getKidCount();
for (int i = 0; i < nkid; i++) {
ConstructPtr kid = cs->getNthKid(i);
if (kid) {
collectAliasInfoRecur(kid);
}
}
if (ExpressionPtr e = dpc(Expression, cs)) {
int context = e->getContext();
switch (e->getKindOf()) {
case Expression::KindOfAssignmentExpression:
{
AssignmentExpressionPtr ae = spc(AssignmentExpression, e);
ExpressionPtr var = ae->getVariable();
ExpressionPtr val = ae->getValue();
if (var->is(Expression::KindOfSimpleVariable)) {
const std::string &name = spc(SimpleVariable, var)->getName();
AliasInfo &ai = m_aliasInfo[name];
if (val->getContext() & Expression::RefValue) {
ai.setIsRefTo();
m_variables->addUsed(name);
} else {
Expression::checkUsed(m_arp, var, val);
}
}
}
break;
case Expression::KindOfListAssignment:
{
ListAssignmentPtr la = spc(ListAssignment, e);
ExpressionListPtr vars = la->getVariables();
for (int i = vars->getCount(); i--; ) {
ExpressionPtr v = (*vars)[i];
if (v && v->is(Expression::KindOfSimpleVariable)) {
SimpleVariablePtr sv = spc(SimpleVariable, v);
m_variables->addUsed(sv->getName());
}
}
}
break;
case Expression::KindOfSimpleVariable:
{
const std::string &name = spc(SimpleVariable, e)->getName();
if (context & Expression::RefValue) {
AliasInfo &ai = m_aliasInfo[name];
ai.addRefLevel(0);
}
if (!(context & (Expression::AssignmentLHS |
Expression::UnsetContext))) {
m_variables->addUsed(name);
}
}
break;
case Expression::KindOfDynamicVariable:
if (context & Expression::RefValue) {
m_wildRefs = true;
}
break;
case Expression::KindOfArrayElementExpression:
{
int n = 1;
while (n < 10 &&
e->is(Expression::KindOfArrayElementExpression)) {
e = spc(ArrayElementExpression, e)->getVariable();
}
if (e->is(Expression::KindOfSimpleVariable)) {
const std::string &name = spc(SimpleVariable, e)->getName();
if (context & Expression::RefValue) {
AliasInfo &ai = m_aliasInfo[name];
ai.addRefLevel(n);
}
m_variables->addUsed(name); // need this for UnsetContext
}
}
break;
case Expression::KindOfObjectPropertyExpression:
{
e = spc(ObjectPropertyExpression, e)->getObject();
if (e->is(Expression::KindOfSimpleVariable)) {
const std::string &name = spc(SimpleVariable, e)->getName();
if (context & Expression::RefValue) {
//.........这里部分代码省略.........
示例15: outputCPPImpl
void ClassConstant::outputCPPImpl(CodeGenerator &cg, AnalysisResultPtr ar) {
bool lazyInit = cg.getContext() == CodeGenerator::CppLazyStaticInitializer;
if (cg.getContext() != CodeGenerator::CppClassConstantsDecl &&
cg.getContext() != CodeGenerator::CppClassConstantsImpl &&
!lazyInit) {
return;
}
ClassScopePtr scope = getClassScope();
for (int i = 0; i < m_exp->getCount(); i++) {
AssignmentExpressionPtr exp =
dynamic_pointer_cast<AssignmentExpression>((*m_exp)[i]);
ConstantExpressionPtr var =
dynamic_pointer_cast<ConstantExpression>(exp->getVariable());
TypePtr type = scope->getConstants()->getFinalType(var->getName());
ExpressionPtr value = exp->getValue();
if (!scope->getConstants()->isDynamic(var->getName()) == lazyInit) {
continue;
}
switch (cg.getContext()) {
case CodeGenerator::CppClassConstantsDecl:
cg_printf("extern const ");
if (type->is(Type::KindOfString)) {
cg_printf("StaticString");
} else {
type->outputCPPDecl(cg, ar, getScope());
}
cg_printf(" %s%s_%s;\n", Option::ClassConstantPrefix,
scope->getId(cg).c_str(),
var->getName().c_str());
break;
case CodeGenerator::CppClassConstantsImpl: {
cg_printf("const ");
bool isString = type->is(Type::KindOfString);
if (isString) {
cg_printf("StaticString");
} else {
type->outputCPPDecl(cg, ar, getScope());
}
value->outputCPPBegin(cg, ar);
cg_printf(" %s%s_%s", Option::ClassConstantPrefix,
scope->getId(cg).c_str(),
var->getName().c_str());
cg_printf(isString ? "(" : " = ");
ScalarExpressionPtr scalarExp =
dynamic_pointer_cast<ScalarExpression>(value);
if (isString && scalarExp) {
cg_printf("LITSTR_INIT(%s)",
scalarExp->getCPPLiteralString(cg).c_str());
} else {
value->outputCPP(cg, ar);
}
cg_printf(isString ? ");\n" : ";\n");
value->outputCPPEnd(cg, ar);
break;
}
case CodeGenerator::CppLazyStaticInitializer:
value->outputCPPBegin(cg, ar);
cg_printf("g->%s%s_%s = ", Option::ClassConstantPrefix,
scope->getId(cg).c_str(),
var->getName().c_str());
value->outputCPP(cg, ar);
cg_printf(";\n");
value->outputCPPEnd(cg, ar);
break;
default:
ASSERT(false);
}
}
}