Extending Qt Creator Manual | Evaluate

Extending Qt Creator Manual 4.7.2

# Evaluate Class

(QmlJS::Evaluate)

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

Header: | #include <Evaluate>
Inherits: | QmlJS::AST::Visitor (protected)

- List of all members, including inherited members

## Public Functions

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

- 190 public functions inherited from QmlJS::AST::Visitor

## Protected Functions

void | accept(AST::Node *node)
const QmlJS::Value * | switchResult(const QmlJS::Value *result)

## Reimplemented Protected Functions

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

Default constructs an instance of Evaluate.

### `[virtual]` Evaluate::~Evaluate()

Destroys the instance of Evaluate. The destructor is virtual.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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