Extending Qt Creator Manual | Evaluate

Extending Qt Creator Manual 4.5.2

# Evaluate Class

(QmlJS::Evaluate)

The Evaluate class evaluates AST::Nodes to Values. More...

Header: | #include <Evaluate>

- List of all members, including inherited members

## Public Functions

| Evaluate(const ScopeChain *scopeChain, ReferenceContext *referenceContext = 0)
| ~Evaluate()
const Value * | reference(AST::Node *ast)
const Value * | value(AST::Node *ast)
const Value * | operator()(AST::Node *ast)

## Protected Functions

void | accept(AST::Node *node)
const Value * | switchResult(const Value *result)
bool | visit(AST::UiProgram *ast) override
bool | visit(AST::UiHeaderItemList *ast) override
bool | visit(AST::NewMemberExpression *ast) override
bool | visit(AST::NewExpression *ast) override
bool | visit(AST::CallExpression *ast) override
bool | visit(AST::ArgumentList *ast) override
bool | visit(AST::PostIncrementExpression *ast) override
bool | visit(AST::PostDecrementExpression *ast) override
bool | visit(AST::DeleteExpression *ast) override
bool | visit(AST::VoidExpression *ast) override
bool | visit(AST::TypeOfExpression *ast) override
bool | visit(AST::PreIncrementExpression *ast) override
bool | visit(AST::PreDecrementExpression *ast) override
bool | visit(AST::UnaryPlusExpression *ast) override
bool | visit(AST::UnaryMinusExpression *ast) override
bool | visit(AST::TildeExpression *ast) override
bool | visit(AST::NotExpression *ast) override
bool | visit(AST::BinaryExpression *ast) override
bool | visit(AST::ConditionalExpression *ast) override
bool | visit(AST::Expression *ast) override
bool | visit(AST::Block *ast) override
bool | visit(AST::StatementList *ast) override
bool | visit(AST::VariableStatement *ast) override
bool | visit(AST::VariableDeclarationList *ast) override
bool | visit(AST::VariableDeclaration *ast) override
bool | visit(AST::EmptyStatement *ast) override
bool | visit(AST::ExpressionStatement *ast) override
bool | visit(AST::IfStatement *ast) override
bool | visit(AST::DoWhileStatement *ast) override
bool | visit(AST::WhileStatement *ast) override
bool | visit(AST::ForStatement *ast) override
bool | visit(AST::LocalForStatement *ast) override
bool | visit(AST::ForEachStatement *ast) override
bool | visit(AST::LocalForEachStatement *ast) override
bool | visit(AST::ContinueStatement *ast) override
bool | visit(AST::BreakStatement *ast) override
bool | visit(AST::ReturnStatement *ast) override
bool | visit(AST::WithStatement *ast) override
bool | visit(AST::UiQualifiedPragmaId *ast) override
bool | visit(AST::SwitchStatement *ast) override
bool | visit(AST::CaseBlock *ast) override
bool | visit(AST::CaseClauses *ast) override
bool | visit(AST::CaseClause *ast) override
bool | visit(AST::DefaultClause *ast) override
bool | visit(AST::LabelledStatement *ast) override
bool | visit(AST::ThrowStatement *ast) override
bool | visit(AST::TryStatement *ast) override
bool | visit(AST::Catch *ast) override
bool | visit(AST::Finally *ast) override
bool | visit(AST::FunctionDeclaration *ast) override
bool | visit(AST::FunctionExpression *ast) override
bool | visit(AST::FormalParameterList *ast) override
bool | visit(AST::FunctionBody *ast) override
bool | visit(AST::Program *ast) override
bool | visit(AST::SourceElements *ast) override
bool | visit(AST::FunctionSourceElement *ast) override
bool | visit(AST::StatementSourceElement *ast) override
bool | visit(AST::DebuggerStatement *ast) override
bool | visit(AST::UiPragma *ast) override
bool | visit(AST::UiImport *ast) override
bool | visit(AST::UiPublicMember *ast) override
bool | visit(AST::UiSourceElement *ast) override
bool | visit(AST::UiObjectDefinition *ast) override
bool | visit(AST::UiObjectInitializer *ast) override
bool | visit(AST::UiObjectBinding *ast) override
bool | visit(AST::UiScriptBinding *ast) override
bool | visit(AST::UiArrayBinding *ast) override
bool | visit(AST::UiObjectMemberList *ast) override
bool | visit(AST::UiArrayMemberList *ast) override
bool | visit(AST::UiQualifiedId *ast) override
bool | visit(AST::ThisExpression *ast) override
bool | visit(AST::IdentifierExpression *ast) override
bool | visit(AST::NullExpression *ast) override
bool | visit(AST::TrueLiteral *ast) override
bool | visit(AST::FalseLiteral *ast) override
bool | visit(AST::StringLiteral *ast) override
bool | visit(AST::NumericLiteral *ast) override
bool | visit(AST::RegExpLiteral *ast) override
bool | visit(AST::ArrayLiteral *ast) override
bool | visit(AST::ObjectLiteral *ast) override
bool | visit(AST::ElementList *ast) override
bool | visit(AST::Elision *ast) override
bool | visit(AST::PropertyAssignmentList *ast) override
bool | visit(AST::PropertyGetterSetter *ast) override
bool | visit(AST::PropertyNameAndValue *ast) override
bool | visit(AST::NestedExpression *ast) override
bool | visit(AST::IdentifierPropertyName *ast) override
bool | visit(AST::StringLiteralPropertyName *ast) override
bool | visit(AST::NumericLiteralPropertyName *ast) override
bool | visit(AST::ArrayMemberExpression *ast) override
bool | visit(AST::FieldMemberExpression *ast) override

## Detailed Description

The Evaluate class evaluates AST::Nodes to Values.

The Evaluate visitor is constructed with a ScopeChain and accepts JavaScript expressions as well as some other AST::Nodes. It evaluates the expression in the given ScopeChain and returns a Value representing the result.

Example: Pass in the AST for "1 + 2" and NumberValue will be returned.

In normal cases only the call operator (or the equivalent value() function) will be used.

The reference() function has the special behavior of not resolving References which can be useful when interested in the identity of a variable instead of its value.

Example: In a scope where "var a = 1"

- value(Identifier-a) will return NumberValue
- reference(Identifier-a) will return the ASTVariableReference for the declaration of "a"

See also Value and ScopeChain.

## Member Function Documentation

### Evaluate::Evaluate(const ScopeChain *scopeChain, ReferenceContext *referenceContext = 0)

Default constructs an instance of Evaluate.

### Evaluate::~Evaluate()

Destroys the instance of Evaluate.

### `[protected]` void Evaluate::accept(AST::Node *node)

### const Value *Evaluate::reference(AST::Node *ast)

### `[protected]` const Value *Evaluate::switchResult(const Value *result)

### const Value *Evaluate::value(AST::Node *ast)

### `[protected]` bool Evaluate::visit(AST::UiProgram *ast)

### `[protected]` bool Evaluate::visit(AST::UiHeaderItemList *ast)

### `[protected]` bool Evaluate::visit(AST::NewMemberExpression *ast)

### `[protected]` bool Evaluate::visit(AST::NewExpression *ast)

### `[protected]` bool Evaluate::visit(AST::CallExpression *ast)

### `[protected]` bool Evaluate::visit(AST::ArgumentList *ast)

### `[protected]` bool Evaluate::visit(AST::PostIncrementExpression *ast)

### `[protected]` bool Evaluate::visit(AST::PostDecrementExpression *ast)

### `[protected]` bool Evaluate::visit(AST::DeleteExpression *ast)

### `[protected]` bool Evaluate::visit(AST::VoidExpression *ast)

### `[protected]` bool Evaluate::visit(AST::TypeOfExpression *ast)

### `[protected]` bool Evaluate::visit(AST::PreIncrementExpression *ast)

### `[protected]` bool Evaluate::visit(AST::PreDecrementExpression *ast)

### `[protected]` bool Evaluate::visit(AST::UnaryPlusExpression *ast)

### `[protected]` bool Evaluate::visit(AST::UnaryMinusExpression *ast)

### `[protected]` bool Evaluate::visit(AST::TildeExpression *ast)

### `[protected]` bool Evaluate::visit(AST::NotExpression *ast)

### `[protected]` bool Evaluate::visit(AST::BinaryExpression *ast)

### `[protected]` bool Evaluate::visit(AST::ConditionalExpression *ast)

### `[protected]` bool Evaluate::visit(AST::Expression *ast)

### `[protected]` bool Evaluate::visit(AST::Block *ast)

### `[protected]` bool Evaluate::visit(AST::StatementList *ast)

### `[protected]` bool Evaluate::visit(AST::VariableStatement *ast)

### `[protected]` bool Evaluate::visit(AST::VariableDeclarationList *ast)

### `[protected]` bool Evaluate::visit(AST::VariableDeclaration *ast)

### `[protected]` bool Evaluate::visit(AST::EmptyStatement *ast)

### `[protected]` bool Evaluate::visit(AST::ExpressionStatement *ast)

### `[protected]` bool Evaluate::visit(AST::IfStatement *ast)

### `[protected]` bool Evaluate::visit(AST::DoWhileStatement *ast)

### `[protected]` bool Evaluate::visit(AST::WhileStatement *ast)

### `[protected]` bool Evaluate::visit(AST::ForStatement *ast)

### `[protected]` bool Evaluate::visit(AST::LocalForStatement *ast)

### `[protected]` bool Evaluate::visit(AST::ForEachStatement *ast)

### `[protected]` bool Evaluate::visit(AST::LocalForEachStatement *ast)

### `[protected]` bool Evaluate::visit(AST::ContinueStatement *ast)

### `[protected]` bool Evaluate::visit(AST::BreakStatement *ast)

### `[protected]` bool Evaluate::visit(AST::ReturnStatement *ast)

### `[protected]` bool Evaluate::visit(AST::WithStatement *ast)

### `[protected]` bool Evaluate::visit(AST::UiQualifiedPragmaId *ast)

### `[protected]` bool Evaluate::visit(AST::SwitchStatement *ast)

### `[protected]` bool Evaluate::visit(AST::CaseBlock *ast)

### `[protected]` bool Evaluate::visit(AST::CaseClauses *ast)

### `[protected]` bool Evaluate::visit(AST::CaseClause *ast)

### `[protected]` bool Evaluate::visit(AST::DefaultClause *ast)

### `[protected]` bool Evaluate::visit(AST::LabelledStatement *ast)

### `[protected]` bool Evaluate::visit(AST::ThrowStatement *ast)

### `[protected]` bool Evaluate::visit(AST::TryStatement *ast)

### `[protected]` bool Evaluate::visit(AST::Catch *ast)

### `[protected]` bool Evaluate::visit(AST::Finally *ast)

### `[protected]` bool Evaluate::visit(AST::FunctionDeclaration *ast)

### `[protected]` bool Evaluate::visit(AST::FunctionExpression *ast)

### `[protected]` bool Evaluate::visit(AST::FormalParameterList *ast)

### `[protected]` bool Evaluate::visit(AST::FunctionBody *ast)

### `[protected]` bool Evaluate::visit(AST::Program *ast)

### `[protected]` bool Evaluate::visit(AST::SourceElements *ast)

### `[protected]` bool Evaluate::visit(AST::FunctionSourceElement *ast)

### `[protected]` bool Evaluate::visit(AST::StatementSourceElement *ast)

### `[protected]` bool Evaluate::visit(AST::DebuggerStatement *ast)

### `[protected]` bool Evaluate::visit(AST::UiPragma *ast)

### `[protected]` bool Evaluate::visit(AST::UiImport *ast)

### `[protected]` bool Evaluate::visit(AST::UiPublicMember *ast)

### `[protected]` bool Evaluate::visit(AST::UiSourceElement *ast)

### `[protected]` bool Evaluate::visit(AST::UiObjectDefinition *ast)

### `[protected]` bool Evaluate::visit(AST::UiObjectInitializer *ast)

### `[protected]` bool Evaluate::visit(AST::UiObjectBinding *ast)

### `[protected]` bool Evaluate::visit(AST::UiScriptBinding *ast)

### `[protected]` bool Evaluate::visit(AST::UiArrayBinding *ast)

### `[protected]` bool Evaluate::visit(AST::UiObjectMemberList *ast)

### `[protected]` bool Evaluate::visit(AST::UiArrayMemberList *ast)

### `[protected]` bool Evaluate::visit(AST::UiQualifiedId *ast)

### `[protected]` bool Evaluate::visit(AST::ThisExpression *ast)

### `[protected]` bool Evaluate::visit(AST::IdentifierExpression *ast)

### `[protected]` bool Evaluate::visit(AST::NullExpression *ast)

### `[protected]` bool Evaluate::visit(AST::TrueLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::FalseLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::StringLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::NumericLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::RegExpLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::ArrayLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::ObjectLiteral *ast)

### `[protected]` bool Evaluate::visit(AST::ElementList *ast)

### `[protected]` bool Evaluate::visit(AST::Elision *ast)

### `[protected]` bool Evaluate::visit(AST::PropertyAssignmentList *ast)

### `[protected]` bool Evaluate::visit(AST::PropertyGetterSetter *ast)

### `[protected]` bool Evaluate::visit(AST::PropertyNameAndValue *ast)

### `[protected]` bool Evaluate::visit(AST::NestedExpression *ast)

### `[protected]` bool Evaluate::visit(AST::IdentifierPropertyName *ast)

### `[protected]` bool Evaluate::visit(AST::StringLiteralPropertyName *ast)

### `[protected]` bool Evaluate::visit(AST::NumericLiteralPropertyName *ast)

### `[protected]` bool Evaluate::visit(AST::ArrayMemberExpression *ast)

### `[protected]` bool Evaluate::visit(AST::FieldMemberExpression *ast)

### const Value *Evaluate::operator()(AST::Node *ast)