Extending Qt Creator Manual | Evaluate

Extending Qt Creator Manual 4.3.0

# 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)

## 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)

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