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