2010-01-18 16:15:23 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2010-01-18 16:15:23 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef QMLBIND_H
|
|
|
|
|
#define QMLBIND_H
|
|
|
|
|
|
2010-01-26 14:50:52 +01:00
|
|
|
#include <qmljs/parser/qmljsastvisitor_p.h>
|
|
|
|
|
#include <qmljs/qmljsinterpreter.h>
|
2011-07-01 12:11:02 +02:00
|
|
|
#include <qmljs/qmljsvalueowner.h>
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
#include <QtCore/QHash>
|
2010-02-01 17:20:46 +01:00
|
|
|
#include <QtCore/QStringList>
|
2010-02-02 15:55:17 +01:00
|
|
|
#include <QtCore/QSharedPointer>
|
2010-09-16 15:29:37 +02:00
|
|
|
#include <QtCore/QCoreApplication>
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
namespace QmlJS {
|
|
|
|
|
|
2010-02-03 15:59:15 +01:00
|
|
|
class Document;
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
class QMLJS_EXPORT Bind: protected AST::Visitor
|
|
|
|
|
{
|
2010-02-03 15:59:15 +01:00
|
|
|
Q_DISABLE_COPY(Bind)
|
2010-09-16 15:29:37 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(QmlJS::Bind)
|
2010-02-03 15:59:15 +01:00
|
|
|
|
2010-02-01 16:39:32 +01:00
|
|
|
public:
|
2010-09-16 15:29:37 +02:00
|
|
|
Bind(Document *doc, QList<DiagnosticMessage> *messages);
|
2010-01-18 16:15:23 +01:00
|
|
|
virtual ~Bind();
|
|
|
|
|
|
2010-09-16 15:29:37 +02:00
|
|
|
QList<Interpreter::ImportInfo> imports() const;
|
2010-02-01 17:20:46 +01:00
|
|
|
|
2010-02-10 17:05:45 +01:00
|
|
|
Interpreter::ObjectValue *idEnvironment() const;
|
|
|
|
|
Interpreter::ObjectValue *rootObjectValue() const;
|
|
|
|
|
|
|
|
|
|
Interpreter::ObjectValue *findQmlObject(AST::Node *node) const;
|
2010-02-11 18:58:17 +01:00
|
|
|
bool usesQmlPrototype(Interpreter::ObjectValue *prototype,
|
2011-07-13 15:04:27 +02:00
|
|
|
const Interpreter::ContextPtr &context) const;
|
2010-02-01 12:17:39 +01:00
|
|
|
|
2011-06-06 14:13:50 +02:00
|
|
|
Interpreter::ObjectValue *findAttachedJSScope(AST::Node *node) const;
|
2010-05-12 13:58:23 +02:00
|
|
|
bool isGroupedPropertyBinding(AST::Node *node) const;
|
2010-04-20 15:19:37 +02:00
|
|
|
|
2010-02-01 17:04:31 +01:00
|
|
|
static QString toString(AST::UiQualifiedId *qualifiedId, QChar delimiter = QChar('.'));
|
2010-02-10 17:05:45 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
using AST::Visitor::visit;
|
2010-02-01 12:17:39 +01:00
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
void accept(AST::Node *node);
|
|
|
|
|
|
2010-02-03 14:31:03 +01:00
|
|
|
virtual bool visit(AST::UiProgram *ast);
|
|
|
|
|
virtual bool visit(AST::Program *ast);
|
|
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
// Ui
|
|
|
|
|
virtual bool visit(AST::UiImport *ast);
|
|
|
|
|
virtual bool visit(AST::UiPublicMember *ast);
|
|
|
|
|
virtual bool visit(AST::UiObjectDefinition *ast);
|
|
|
|
|
virtual bool visit(AST::UiObjectBinding *ast);
|
|
|
|
|
virtual bool visit(AST::UiScriptBinding *ast);
|
|
|
|
|
virtual bool visit(AST::UiArrayBinding *ast);
|
2010-02-03 14:31:03 +01:00
|
|
|
|
|
|
|
|
// QML/JS
|
2010-01-18 16:15:23 +01:00
|
|
|
virtual bool visit(AST::FunctionDeclaration *ast);
|
2010-11-16 13:53:39 +01:00
|
|
|
virtual bool visit(AST::FunctionExpression *ast);
|
2010-02-03 14:31:03 +01:00
|
|
|
virtual bool visit(AST::VariableDeclaration *ast);
|
2010-01-18 16:15:23 +01:00
|
|
|
|
2010-01-26 14:50:52 +01:00
|
|
|
Interpreter::ObjectValue *switchObjectValue(Interpreter::ObjectValue *newObjectValue);
|
|
|
|
|
Interpreter::ObjectValue *bindObject(AST::UiQualifiedId *qualifiedTypeNameId, AST::UiObjectInitializer *initializer);
|
|
|
|
|
|
2010-01-18 16:15:23 +01:00
|
|
|
private:
|
2010-02-02 15:55:17 +01:00
|
|
|
Document *_doc;
|
2011-07-01 12:11:02 +02:00
|
|
|
Interpreter::ValueOwner _valueOwner;
|
2010-01-26 14:50:52 +01:00
|
|
|
|
|
|
|
|
Interpreter::ObjectValue *_currentObjectValue;
|
|
|
|
|
Interpreter::ObjectValue *_idEnvironment;
|
|
|
|
|
Interpreter::ObjectValue *_rootObjectValue;
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-02-02 17:06:48 +01:00
|
|
|
QHash<AST::Node *, Interpreter::ObjectValue *> _qmlObjects;
|
2010-05-12 13:58:23 +02:00
|
|
|
QSet<AST::Node *> _groupedPropertyBindings;
|
2011-06-06 14:13:50 +02:00
|
|
|
QHash<AST::Node *, Interpreter::ObjectValue *> _attachedJSScopes;
|
2010-02-01 17:20:46 +01:00
|
|
|
QStringList _includedScripts;
|
2010-04-06 09:52:29 +02:00
|
|
|
|
2010-09-16 15:29:37 +02:00
|
|
|
QList<Interpreter::ImportInfo> _imports;
|
|
|
|
|
|
|
|
|
|
QList<DiagnosticMessage> *_diagnosticMessages;
|
2010-01-18 16:15:23 +01:00
|
|
|
};
|
|
|
|
|
|
2011-02-04 09:52:39 +01:00
|
|
|
} // namespace Qml
|
2010-01-18 16:15:23 +01:00
|
|
|
|
|
|
|
|
#endif // QMLBIND_H
|