forked from qt-creator/qt-creator
QmlJS: Also bind FunctionExpressions.
Reviewed-by: Erik Verbruggen
This commit is contained in:
@@ -106,7 +106,7 @@ bool Bind::usesQmlPrototype(ObjectValue *prototype,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Interpreter::ObjectValue *Bind::findFunctionScope(AST::FunctionDeclaration *node) const
|
Interpreter::ObjectValue *Bind::findFunctionScope(AST::FunctionExpression *node) const
|
||||||
{
|
{
|
||||||
return _functionScopes.value(node);
|
return _functionScopes.value(node);
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ bool Bind::visit(UiScriptBinding *ast)
|
|||||||
_idEnvironment->setProperty(i->name->asString(), _currentObjectValue);
|
_idEnvironment->setProperty(i->name->asString(), _currentObjectValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bind::visit(UiArrayBinding *)
|
bool Bind::visit(UiArrayBinding *)
|
||||||
@@ -298,7 +298,7 @@ bool Bind::visit(VariableDeclaration *ast)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bind::visit(FunctionDeclaration *ast)
|
bool Bind::visit(FunctionExpression *ast)
|
||||||
{
|
{
|
||||||
if (!ast->name)
|
if (!ast->name)
|
||||||
return false;
|
return false;
|
||||||
@@ -341,3 +341,8 @@ bool Bind::visit(FunctionDeclaration *ast)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Bind::visit(FunctionDeclaration *ast)
|
||||||
|
{
|
||||||
|
return visit(static_cast<FunctionExpression *>(ast));
|
||||||
|
}
|
||||||
|
@@ -62,7 +62,7 @@ public:
|
|||||||
bool usesQmlPrototype(Interpreter::ObjectValue *prototype,
|
bool usesQmlPrototype(Interpreter::ObjectValue *prototype,
|
||||||
const Interpreter::Context *context) const;
|
const Interpreter::Context *context) const;
|
||||||
|
|
||||||
Interpreter::ObjectValue *findFunctionScope(AST::FunctionDeclaration *node) const;
|
Interpreter::ObjectValue *findFunctionScope(AST::FunctionExpression *node) const;
|
||||||
bool isGroupedPropertyBinding(AST::Node *node) const;
|
bool isGroupedPropertyBinding(AST::Node *node) const;
|
||||||
|
|
||||||
static QString toString(AST::UiQualifiedId *qualifiedId, QChar delimiter = QChar('.'));
|
static QString toString(AST::UiQualifiedId *qualifiedId, QChar delimiter = QChar('.'));
|
||||||
@@ -85,6 +85,7 @@ protected:
|
|||||||
|
|
||||||
// QML/JS
|
// QML/JS
|
||||||
virtual bool visit(AST::FunctionDeclaration *ast);
|
virtual bool visit(AST::FunctionDeclaration *ast);
|
||||||
|
virtual bool visit(AST::FunctionExpression *ast);
|
||||||
virtual bool visit(AST::VariableDeclaration *ast);
|
virtual bool visit(AST::VariableDeclaration *ast);
|
||||||
|
|
||||||
Interpreter::ObjectValue *switchObjectValue(Interpreter::ObjectValue *newObjectValue);
|
Interpreter::ObjectValue *switchObjectValue(Interpreter::ObjectValue *newObjectValue);
|
||||||
@@ -102,7 +103,7 @@ private:
|
|||||||
|
|
||||||
QHash<AST::Node *, Interpreter::ObjectValue *> _qmlObjects;
|
QHash<AST::Node *, Interpreter::ObjectValue *> _qmlObjects;
|
||||||
QSet<AST::Node *> _groupedPropertyBindings;
|
QSet<AST::Node *> _groupedPropertyBindings;
|
||||||
QHash<AST::FunctionDeclaration *, Interpreter::ObjectValue *> _functionScopes;
|
QHash<AST::FunctionExpression *, Interpreter::ObjectValue *> _functionScopes;
|
||||||
QStringList _includedScripts;
|
QStringList _includedScripts;
|
||||||
|
|
||||||
QList<Interpreter::ImportInfo> _imports;
|
QList<Interpreter::ImportInfo> _imports;
|
||||||
|
@@ -3309,7 +3309,7 @@ const Value *ASTVariableReference::value(const Context *context) const
|
|||||||
return check(_ast->expression);
|
return check(_ast->expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTFunctionValue::ASTFunctionValue(FunctionDeclaration *ast, const QmlJS::Document *doc, Engine *engine)
|
ASTFunctionValue::ASTFunctionValue(FunctionExpression *ast, const QmlJS::Document *doc, Engine *engine)
|
||||||
: FunctionValue(engine), _ast(ast), _doc(doc)
|
: FunctionValue(engine), _ast(ast), _doc(doc)
|
||||||
{
|
{
|
||||||
setPrototype(engine->functionPrototype());
|
setPrototype(engine->functionPrototype());
|
||||||
@@ -3322,7 +3322,7 @@ ASTFunctionValue::~ASTFunctionValue()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionDeclaration *ASTFunctionValue::ast() const
|
FunctionExpression *ASTFunctionValue::ast() const
|
||||||
{
|
{
|
||||||
return _ast;
|
return _ast;
|
||||||
}
|
}
|
||||||
|
@@ -866,15 +866,15 @@ private:
|
|||||||
|
|
||||||
class QMLJS_EXPORT ASTFunctionValue: public FunctionValue
|
class QMLJS_EXPORT ASTFunctionValue: public FunctionValue
|
||||||
{
|
{
|
||||||
AST::FunctionDeclaration *_ast;
|
AST::FunctionExpression *_ast;
|
||||||
const Document *_doc;
|
const Document *_doc;
|
||||||
QList<NameId *> _argumentNames;
|
QList<NameId *> _argumentNames;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ASTFunctionValue(AST::FunctionDeclaration *ast, const Document *doc, Engine *engine);
|
ASTFunctionValue(AST::FunctionExpression *ast, const Document *doc, Engine *engine);
|
||||||
virtual ~ASTFunctionValue();
|
virtual ~ASTFunctionValue();
|
||||||
|
|
||||||
AST::FunctionDeclaration *ast() const;
|
AST::FunctionExpression *ast() const;
|
||||||
|
|
||||||
virtual const Value *returnValue() const;
|
virtual const Value *returnValue() const;
|
||||||
virtual int argumentCount() const;
|
virtual int argumentCount() const;
|
||||||
|
Reference in New Issue
Block a user