2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-01-18 13:13:34 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-01-18 13:13:34 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-01-18 13:13:34 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-05-12 13:25:35 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-01-18 13:13:34 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// W A R N I N G
|
|
|
|
|
// -------------
|
|
|
|
|
//
|
|
|
|
|
// This file is not part of the Qt API. It exists purely as an
|
|
|
|
|
// implementation detail. This header file may change from version to
|
|
|
|
|
// version without notice, or even be removed.
|
|
|
|
|
//
|
|
|
|
|
// We mean it.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "qmljsastvisitor_p.h"
|
|
|
|
|
#include "qmljsglobal_p.h"
|
2011-09-13 08:42:52 +02:00
|
|
|
#include "qmljsmemorypool_p.h"
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
#include <QtCore/qstring.h>
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
QT_QML_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
#define QMLJS_DECLARE_AST_NODE(name) \
|
|
|
|
|
enum { K = Kind_##name };
|
|
|
|
|
|
|
|
|
|
namespace QSOperator // ### rename
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
enum Op {
|
|
|
|
|
Add,
|
|
|
|
|
And,
|
|
|
|
|
InplaceAnd,
|
|
|
|
|
Assign,
|
|
|
|
|
BitAnd,
|
|
|
|
|
BitOr,
|
|
|
|
|
BitXor,
|
|
|
|
|
InplaceSub,
|
|
|
|
|
Div,
|
|
|
|
|
InplaceDiv,
|
|
|
|
|
Equal,
|
2018-10-16 15:32:58 +02:00
|
|
|
Exp,
|
|
|
|
|
InplaceExp,
|
2010-01-18 13:13:34 +01:00
|
|
|
Ge,
|
|
|
|
|
Gt,
|
|
|
|
|
In,
|
|
|
|
|
InplaceAdd,
|
|
|
|
|
InstanceOf,
|
|
|
|
|
Le,
|
|
|
|
|
LShift,
|
|
|
|
|
InplaceLeftShift,
|
|
|
|
|
Lt,
|
|
|
|
|
Mod,
|
|
|
|
|
InplaceMod,
|
|
|
|
|
Mul,
|
|
|
|
|
InplaceMul,
|
|
|
|
|
NotEqual,
|
|
|
|
|
Or,
|
|
|
|
|
InplaceOr,
|
|
|
|
|
RShift,
|
|
|
|
|
InplaceRightShift,
|
|
|
|
|
StrictEqual,
|
|
|
|
|
StrictNotEqual,
|
|
|
|
|
Sub,
|
|
|
|
|
URShift,
|
|
|
|
|
InplaceURightShift,
|
2018-10-16 15:32:58 +02:00
|
|
|
InplaceXor,
|
|
|
|
|
Invalid
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QSOperator
|
|
|
|
|
|
|
|
|
|
namespace QmlJS {
|
2011-09-13 08:42:52 +02:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
namespace AST {
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
enum class VariableScope {
|
|
|
|
|
NoScope,
|
|
|
|
|
Var,
|
|
|
|
|
Let,
|
|
|
|
|
Const
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-29 11:00:30 +02:00
|
|
|
template <typename T1, typename T2>
|
|
|
|
|
T1 cast(T2 *ast)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
2016-04-29 11:00:30 +02:00
|
|
|
if (ast && ast->kind == static_cast<T1>(0)->K)
|
|
|
|
|
return static_cast<T1>(ast);
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
FunctionExpression *asAnonymousFunctionDefinition(AST::Node *n);
|
|
|
|
|
ClassExpression *asAnonymousClassDefinition(AST::Node *n);
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
class QML_PARSER_EXPORT Node: public Managed
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum Kind {
|
|
|
|
|
Kind_Undefined,
|
|
|
|
|
|
|
|
|
|
Kind_ArgumentList,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_ArrayPattern,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_ArrayMemberExpression,
|
|
|
|
|
Kind_BinaryExpression,
|
|
|
|
|
Kind_Block,
|
|
|
|
|
Kind_BreakStatement,
|
|
|
|
|
Kind_CallExpression,
|
|
|
|
|
Kind_CaseBlock,
|
|
|
|
|
Kind_CaseClause,
|
|
|
|
|
Kind_CaseClauses,
|
|
|
|
|
Kind_Catch,
|
|
|
|
|
Kind_ConditionalExpression,
|
|
|
|
|
Kind_ContinueStatement,
|
|
|
|
|
Kind_DebuggerStatement,
|
|
|
|
|
Kind_DefaultClause,
|
|
|
|
|
Kind_DeleteExpression,
|
|
|
|
|
Kind_DoWhileStatement,
|
|
|
|
|
Kind_ElementList,
|
|
|
|
|
Kind_Elision,
|
|
|
|
|
Kind_EmptyStatement,
|
|
|
|
|
Kind_Expression,
|
|
|
|
|
Kind_ExpressionStatement,
|
|
|
|
|
Kind_FalseLiteral,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_SuperLiteral,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_FieldMemberExpression,
|
|
|
|
|
Kind_Finally,
|
|
|
|
|
Kind_ForEachStatement,
|
|
|
|
|
Kind_ForStatement,
|
|
|
|
|
Kind_FormalParameterList,
|
|
|
|
|
Kind_FunctionBody,
|
|
|
|
|
Kind_FunctionDeclaration,
|
|
|
|
|
Kind_FunctionExpression,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_ClassExpression,
|
|
|
|
|
Kind_ClassDeclaration,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_IdentifierExpression,
|
|
|
|
|
Kind_IdentifierPropertyName,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_ComputedPropertyName,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_IfStatement,
|
|
|
|
|
Kind_LabelledStatement,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_NameSpaceImport,
|
|
|
|
|
Kind_ImportSpecifier,
|
|
|
|
|
Kind_ImportsList,
|
|
|
|
|
Kind_NamedImports,
|
|
|
|
|
Kind_ImportClause,
|
|
|
|
|
Kind_FromClause,
|
|
|
|
|
Kind_ImportDeclaration,
|
|
|
|
|
Kind_Module,
|
|
|
|
|
Kind_ExportSpecifier,
|
|
|
|
|
Kind_ExportsList,
|
|
|
|
|
Kind_ExportClause,
|
|
|
|
|
Kind_ExportDeclaration,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_NewExpression,
|
|
|
|
|
Kind_NewMemberExpression,
|
|
|
|
|
Kind_NotExpression,
|
|
|
|
|
Kind_NullExpression,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_YieldExpression,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_NumericLiteral,
|
|
|
|
|
Kind_NumericLiteralPropertyName,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_ObjectPattern,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_PostDecrementExpression,
|
|
|
|
|
Kind_PostIncrementExpression,
|
|
|
|
|
Kind_PreDecrementExpression,
|
|
|
|
|
Kind_PreIncrementExpression,
|
|
|
|
|
Kind_Program,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_PropertyDefinitionList,
|
2013-11-06 14:17:23 +01:00
|
|
|
Kind_PropertyGetterSetter,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_PropertyName,
|
2013-11-06 14:17:23 +01:00
|
|
|
Kind_PropertyNameAndValue,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_RegExpLiteral,
|
|
|
|
|
Kind_ReturnStatement,
|
|
|
|
|
Kind_StatementList,
|
|
|
|
|
Kind_StringLiteral,
|
|
|
|
|
Kind_StringLiteralPropertyName,
|
|
|
|
|
Kind_SwitchStatement,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_TemplateLiteral,
|
|
|
|
|
Kind_TaggedTemplate,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_ThisExpression,
|
|
|
|
|
Kind_ThrowStatement,
|
|
|
|
|
Kind_TildeExpression,
|
|
|
|
|
Kind_TrueLiteral,
|
|
|
|
|
Kind_TryStatement,
|
|
|
|
|
Kind_TypeOfExpression,
|
|
|
|
|
Kind_UnaryMinusExpression,
|
|
|
|
|
Kind_UnaryPlusExpression,
|
|
|
|
|
Kind_VariableDeclaration,
|
|
|
|
|
Kind_VariableDeclarationList,
|
|
|
|
|
Kind_VariableStatement,
|
|
|
|
|
Kind_VoidExpression,
|
|
|
|
|
Kind_WhileStatement,
|
|
|
|
|
Kind_WithStatement,
|
|
|
|
|
Kind_NestedExpression,
|
2018-10-16 15:32:58 +02:00
|
|
|
Kind_ClassElementList,
|
|
|
|
|
Kind_PatternElement,
|
|
|
|
|
Kind_PatternElementList,
|
|
|
|
|
Kind_PatternProperty,
|
|
|
|
|
Kind_PatternPropertyList,
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
Kind_UiArrayBinding,
|
|
|
|
|
Kind_UiImport,
|
|
|
|
|
Kind_UiObjectBinding,
|
|
|
|
|
Kind_UiObjectDefinition,
|
|
|
|
|
Kind_UiObjectInitializer,
|
|
|
|
|
Kind_UiObjectMemberList,
|
|
|
|
|
Kind_UiArrayMemberList,
|
2013-11-06 14:17:23 +01:00
|
|
|
Kind_UiPragma,
|
2010-01-18 13:13:34 +01:00
|
|
|
Kind_UiProgram,
|
|
|
|
|
Kind_UiParameterList,
|
|
|
|
|
Kind_UiPublicMember,
|
|
|
|
|
Kind_UiQualifiedId,
|
|
|
|
|
Kind_UiScriptBinding,
|
2013-11-06 14:17:23 +01:00
|
|
|
Kind_UiSourceElement,
|
2017-12-20 10:47:33 +01:00
|
|
|
Kind_UiHeaderItemList,
|
|
|
|
|
Kind_UiEnumDeclaration,
|
|
|
|
|
Kind_UiEnumMemberList
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
inline Node() {}
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2010-10-19 16:08:44 +02:00
|
|
|
// NOTE: node destructors are never called,
|
|
|
|
|
// instead we block free the memory
|
|
|
|
|
// (see the NodePool class)
|
2010-01-18 13:13:34 +01:00
|
|
|
virtual ~Node() {}
|
|
|
|
|
|
|
|
|
|
virtual ExpressionNode *expressionCast();
|
|
|
|
|
virtual BinaryExpression *binaryExpressionCast();
|
|
|
|
|
virtual Statement *statementCast();
|
|
|
|
|
virtual UiObjectMember *uiObjectMemberCast();
|
2018-10-16 15:32:58 +02:00
|
|
|
virtual LeftHandSideExpression *leftHandSideExpressionCast();
|
|
|
|
|
virtual Pattern *patternCast();
|
|
|
|
|
// implements the IsFunctionDefinition rules in the spec
|
|
|
|
|
virtual FunctionExpression *asFunctionDefinition();
|
|
|
|
|
virtual ClassExpression *asClassDefinition();
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
void accept(Visitor *visitor);
|
|
|
|
|
static void accept(Node *node, Visitor *visitor);
|
|
|
|
|
|
|
|
|
|
inline static void acceptChild(Node *node, Visitor *visitor)
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return accept(node, visitor); } // ### remove
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
virtual void accept0(Visitor *visitor) = 0;
|
2011-12-07 11:16:26 +01:00
|
|
|
virtual SourceLocation firstSourceLocation() const = 0;
|
|
|
|
|
virtual SourceLocation lastSourceLocation() const = 0;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
int kind = Kind_Undefined;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ExpressionNode: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ExpressionNode() {}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
ExpressionNode *expressionCast() override;
|
2018-10-16 15:32:58 +02:00
|
|
|
|
|
|
|
|
AST::FormalParameterList *reparseAsFormalParameterList(MemoryPool *pool);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT LeftHandSideExpression : public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
LeftHandSideExpression *leftHandSideExpressionCast() override;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT Statement: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Statement() {}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
Statement *statementCast() override;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT NestedExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NestedExpression)
|
|
|
|
|
|
|
|
|
|
NestedExpression(ExpressionNode *expression)
|
|
|
|
|
: expression(expression)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return lparenToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rparenToken; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
FunctionExpression *asFunctionDefinition() override;
|
|
|
|
|
ClassExpression *asClassDefinition() override;
|
|
|
|
|
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ThisExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ThisExpression)
|
|
|
|
|
|
|
|
|
|
ThisExpression() { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return thisToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return thisToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation thisToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(IdentifierExpression)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
IdentifierExpression(const QStringRef &n):
|
2010-01-18 13:13:34 +01:00
|
|
|
name (n) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return identifierToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return identifierToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef name;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT NullExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NullExpression)
|
|
|
|
|
|
|
|
|
|
NullExpression() { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return nullToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return nullToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation nullToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT TrueLiteral: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(TrueLiteral)
|
|
|
|
|
|
|
|
|
|
TrueLiteral() { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return trueToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return trueToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation trueToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT FalseLiteral: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(FalseLiteral)
|
|
|
|
|
|
|
|
|
|
FalseLiteral() { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return falseToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return falseToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation falseToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT SuperLiteral : public LeftHandSideExpression
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(SuperLiteral)
|
|
|
|
|
|
|
|
|
|
SuperLiteral() { kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return superToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return superToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation superToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT NumericLiteral: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NumericLiteral)
|
|
|
|
|
|
|
|
|
|
NumericLiteral(double v):
|
|
|
|
|
value(v) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return literalToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return literalToken; }
|
|
|
|
|
|
|
|
|
|
// attributes:
|
|
|
|
|
double value;
|
|
|
|
|
SourceLocation literalToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT StringLiteral: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(StringLiteral)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
StringLiteral(const QStringRef &v):
|
2010-01-18 13:13:34 +01:00
|
|
|
value (v) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return literalToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return literalToken; }
|
|
|
|
|
|
|
|
|
|
// attributes:
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef value;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation literalToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT TemplateLiteral : public LeftHandSideExpression
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(TemplateLiteral)
|
|
|
|
|
|
|
|
|
|
TemplateLiteral(const QStringRef &str, ExpressionNode *e)
|
|
|
|
|
: value(str), expression(e), next(nullptr)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return literalToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return next ? next->lastSourceLocation() : (expression ? expression->lastSourceLocation() : literalToken); }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
QStringRef value;
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
TemplateLiteral *next;
|
|
|
|
|
SourceLocation literalToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(RegExpLiteral)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
RegExpLiteral(const QStringRef &p, int f):
|
2010-01-18 13:13:34 +01:00
|
|
|
pattern (p), flags (f) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return literalToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return literalToken; }
|
|
|
|
|
|
|
|
|
|
// attributes:
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef pattern;
|
2010-01-18 13:13:34 +01:00
|
|
|
int flags;
|
|
|
|
|
SourceLocation literalToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT Pattern : public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
enum ParseMode {
|
|
|
|
|
Literal,
|
|
|
|
|
Binding
|
|
|
|
|
};
|
|
|
|
|
Pattern *patternCast() override;
|
|
|
|
|
virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) = 0;
|
|
|
|
|
ParseMode parseMode = Literal;
|
|
|
|
|
};
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ArrayPattern : public Pattern
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ArrayPattern)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ArrayPattern(PatternElementList *elts)
|
|
|
|
|
: elements(elts)
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return lbracketToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rbracketToken; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
bool isValidArrayLiteral(SourceLocation *errorLocation = nullptr) const;
|
|
|
|
|
|
|
|
|
|
bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElementList *elements = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation lbracketToken;
|
|
|
|
|
SourceLocation commaToken;
|
|
|
|
|
SourceLocation rbracketToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ObjectPattern : public Pattern
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(ObjectPattern)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ObjectPattern()
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ObjectPattern(PatternPropertyList *plist)
|
|
|
|
|
: properties(plist)
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return lbraceToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternPropertyList *properties = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation lbraceToken;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
};
|
|
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
class QML_PARSER_EXPORT Elision: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Elision)
|
|
|
|
|
|
|
|
|
|
Elision():
|
|
|
|
|
next (this) { kind = K; }
|
|
|
|
|
|
|
|
|
|
Elision(Elision *previous)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return commaToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : commaToken; }
|
|
|
|
|
|
|
|
|
|
inline Elision *finish ()
|
|
|
|
|
{
|
|
|
|
|
Elision *front = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2011-12-07 11:16:26 +01:00
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
Elision *next;
|
|
|
|
|
SourceLocation commaToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT PropertyName: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2011-12-07 11:16:26 +01:00
|
|
|
QMLJS_DECLARE_AST_NODE(PropertyName)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
PropertyName() { kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return propertyNameToken; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return propertyNameToken; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2016-04-29 11:00:30 +02:00
|
|
|
virtual QString asString() const = 0;
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2011-12-07 11:16:26 +01:00
|
|
|
SourceLocation propertyNameToken;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT PatternElement : public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(PatternElement)
|
|
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
|
// object literal types
|
|
|
|
|
Literal,
|
|
|
|
|
Getter,
|
|
|
|
|
Setter,
|
|
|
|
|
|
|
|
|
|
// used by both bindings and literals
|
|
|
|
|
SpreadElement,
|
|
|
|
|
RestElement = SpreadElement,
|
|
|
|
|
|
|
|
|
|
// binding types
|
|
|
|
|
Binding,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PatternElement(ExpressionNode *i = nullptr, Type t = Literal)
|
|
|
|
|
: initializer(i), type(t)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
PatternElement(const QStringRef &n, ExpressionNode *i = nullptr, Type t = Binding)
|
|
|
|
|
: bindingIdentifier(n), initializer(i), type(t)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(t >= RestElement);
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PatternElement(Pattern *pattern, ExpressionNode *i = nullptr, Type t = Binding)
|
|
|
|
|
: bindingTarget(pattern), initializer(i), type(t)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(t >= RestElement);
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
virtual bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage);
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return identifierToken.isValid() ? identifierToken : (bindingTarget ? bindingTarget->firstSourceLocation() : initializer->firstSourceLocation()); }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return initializer ? initializer->lastSourceLocation() : (bindingTarget ? bindingTarget->lastSourceLocation() : identifierToken); }
|
|
|
|
|
|
|
|
|
|
ExpressionNode *destructuringTarget() const { return bindingTarget; }
|
|
|
|
|
Pattern *destructuringPattern() const { return bindingTarget ? bindingTarget->patternCast() : nullptr; }
|
|
|
|
|
PatternElementList *elementList() const { ArrayPattern *a = cast<ArrayPattern *>(bindingTarget); return a ? a->elements : nullptr; }
|
|
|
|
|
PatternPropertyList *propertyList() const { ObjectPattern *o = cast<ObjectPattern *>(bindingTarget); return o ? o->properties : nullptr; }
|
|
|
|
|
|
|
|
|
|
bool isVariableDeclaration() const { return scope != VariableScope::NoScope; }
|
|
|
|
|
bool isLexicallyScoped() const { return scope == VariableScope::Let || scope == VariableScope::Const; }
|
|
|
|
|
|
|
|
|
|
virtual void boundNames(QStringList *names);
|
|
|
|
|
|
2016-04-29 11:00:30 +02:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
QStringRef bindingIdentifier;
|
|
|
|
|
ExpressionNode *bindingTarget = nullptr;
|
|
|
|
|
ExpressionNode *initializer = nullptr;
|
|
|
|
|
Type type = Literal;
|
|
|
|
|
// when used in a VariableDeclarationList
|
|
|
|
|
VariableScope scope = VariableScope::NoScope;
|
|
|
|
|
bool isForDeclaration = false;
|
2013-11-06 14:17:23 +01:00
|
|
|
};
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT PatternElementList : public Node
|
2013-11-06 14:17:23 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(PatternElementList)
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElementList(Elision *elision, PatternElement *element)
|
|
|
|
|
: elision(elision), element(element), next(this)
|
2013-11-06 14:17:23 +01:00
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElementList *append(PatternElementList *n) {
|
|
|
|
|
n->next = next;
|
|
|
|
|
next = n;
|
|
|
|
|
return n;
|
2010-01-18 13:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
inline PatternElementList *finish ()
|
2013-11-06 14:17:23 +01:00
|
|
|
{
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElementList *front = next;
|
2013-11-06 14:17:23 +01:00
|
|
|
next = 0;
|
|
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
void boundNames(QStringList *names);
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return elision ? elision->firstSourceLocation() : element->firstSourceLocation(); }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return next ? next->lastSourceLocation() : (element ? element->lastSourceLocation() : elision->lastSourceLocation()); }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
Elision *elision = nullptr;
|
|
|
|
|
PatternElement *element = nullptr;
|
|
|
|
|
PatternElementList *next;
|
2013-11-06 14:17:23 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT PatternProperty : public PatternElement
|
2013-11-06 14:17:23 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(PatternProperty)
|
|
|
|
|
|
|
|
|
|
PatternProperty(PropertyName *name, ExpressionNode *i = nullptr, Type t = Literal)
|
|
|
|
|
: PatternElement(i, t), name(name)
|
|
|
|
|
{ kind = K; }
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternProperty(PropertyName *name, const QStringRef &n, ExpressionNode *i = nullptr)
|
|
|
|
|
: PatternElement(n, i), name(name)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
PatternProperty(PropertyName *name, Pattern *pattern, ExpressionNode *i = nullptr)
|
|
|
|
|
: PatternElement(pattern, i), name(name)
|
2013-11-06 14:17:23 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return name->firstSourceLocation(); }
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{
|
|
|
|
|
SourceLocation loc = PatternElement::lastSourceLocation();
|
|
|
|
|
return loc.isValid() ? loc : name->lastSourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void boundNames(QStringList *names) override;
|
|
|
|
|
bool convertLiteralToAssignmentPattern(MemoryPool *pool, SourceLocation *errorLocation, QString *errorMessage) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
PropertyName *name;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation colonToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT PatternPropertyList : public Node
|
2013-11-06 14:17:23 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(PatternPropertyList)
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternPropertyList(PatternProperty *property)
|
|
|
|
|
: property(property), next(this)
|
2013-11-06 14:17:23 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternPropertyList(PatternPropertyList *previous, PatternProperty *property)
|
|
|
|
|
: property(property), next(this)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
void boundNames(QStringList *names);
|
|
|
|
|
|
|
|
|
|
inline PatternPropertyList *finish ()
|
|
|
|
|
{
|
|
|
|
|
PatternPropertyList *front = next;
|
|
|
|
|
next = 0;
|
|
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return property->firstSourceLocation(); }
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return next ? next->lastSourceLocation() : property->lastSourceLocation(); }
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternProperty *property;
|
|
|
|
|
PatternPropertyList *next;
|
2013-11-06 14:17:23 +01:00
|
|
|
};
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
IdentifierPropertyName(const QStringRef &n):
|
2010-01-18 13:13:34 +01:00
|
|
|
id (n) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
QString asString() const override { return id.toString(); }
|
2016-04-29 11:00:30 +02:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef id;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
StringLiteralPropertyName(const QStringRef &n):
|
2010-01-18 13:13:34 +01:00
|
|
|
id (n) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
QString asString() const override { return id.toString(); }
|
2016-04-29 11:00:30 +02:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef id;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName)
|
|
|
|
|
|
|
|
|
|
NumericLiteralPropertyName(double n):
|
|
|
|
|
id (n) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
QString asString() const override;
|
2016-04-29 11:00:30 +02:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
double id;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ComputedPropertyName : public PropertyName
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ComputedPropertyName)
|
|
|
|
|
|
|
|
|
|
ComputedPropertyName(ExpressionNode *expression)
|
|
|
|
|
: expression(expression)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
QString asString() const override { return QString(); }
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return expression->firstSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ArrayMemberExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ArrayMemberExpression)
|
|
|
|
|
|
|
|
|
|
ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e):
|
|
|
|
|
base (b), expression (e)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return base->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rbracketToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation lbracketToken;
|
|
|
|
|
SourceLocation rbracketToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(FieldMemberExpression)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
FieldMemberExpression(ExpressionNode *b, const QStringRef &n):
|
2010-01-18 13:13:34 +01:00
|
|
|
base (b), name (n)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return base->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return identifierToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef name;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation dotToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT TaggedTemplate : public LeftHandSideExpression
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(TaggedTemplate)
|
|
|
|
|
|
|
|
|
|
TaggedTemplate(ExpressionNode *b, TemplateLiteral *t)
|
|
|
|
|
: base (b), templateLiteral(t)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return base->firstSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return templateLiteral->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
|
|
|
|
TemplateLiteral *templateLiteral;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT NewMemberExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NewMemberExpression)
|
|
|
|
|
|
|
|
|
|
NewMemberExpression(ExpressionNode *b, ArgumentList *a):
|
|
|
|
|
base (b), arguments (a)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return newToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rparenToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
|
|
|
|
ArgumentList *arguments;
|
|
|
|
|
SourceLocation newToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT NewExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NewExpression)
|
|
|
|
|
|
|
|
|
|
NewExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return newToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation newToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT CallExpression: public LeftHandSideExpression
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(CallExpression)
|
|
|
|
|
|
|
|
|
|
CallExpression(ExpressionNode *b, ArgumentList *a):
|
|
|
|
|
base (b), arguments (a)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return base->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rparenToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
|
|
|
|
ArgumentList *arguments;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ArgumentList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ArgumentList)
|
|
|
|
|
|
|
|
|
|
ArgumentList(ExpressionNode *e):
|
|
|
|
|
expression (e), next (this)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
ArgumentList(ArgumentList *previous, ExpressionNode *e):
|
|
|
|
|
expression (e)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return expression->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{
|
|
|
|
|
if (next)
|
|
|
|
|
return next->lastSourceLocation();
|
|
|
|
|
return expression->lastSourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
inline ArgumentList *finish ()
|
|
|
|
|
{
|
|
|
|
|
ArgumentList *front = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
ArgumentList *next;
|
|
|
|
|
SourceLocation commaToken;
|
2018-10-16 15:32:58 +02:00
|
|
|
bool isSpreadElement = false;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(PostIncrementExpression)
|
|
|
|
|
|
|
|
|
|
PostIncrementExpression(ExpressionNode *b):
|
|
|
|
|
base (b) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return base->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return incrementToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
|
|
|
|
SourceLocation incrementToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(PostDecrementExpression)
|
|
|
|
|
|
|
|
|
|
PostDecrementExpression(ExpressionNode *b):
|
|
|
|
|
base (b) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return base->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return decrementToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *base;
|
|
|
|
|
SourceLocation decrementToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(DeleteExpression)
|
|
|
|
|
|
|
|
|
|
DeleteExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return deleteToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation deleteToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT VoidExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(VoidExpression)
|
|
|
|
|
|
|
|
|
|
VoidExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return voidToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation voidToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(TypeOfExpression)
|
|
|
|
|
|
|
|
|
|
TypeOfExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return typeofToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation typeofToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(PreIncrementExpression)
|
|
|
|
|
|
|
|
|
|
PreIncrementExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return incrementToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation incrementToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(PreDecrementExpression)
|
|
|
|
|
|
|
|
|
|
PreDecrementExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return decrementToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation decrementToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UnaryPlusExpression)
|
|
|
|
|
|
|
|
|
|
UnaryPlusExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return plusToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation plusToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UnaryMinusExpression)
|
|
|
|
|
|
|
|
|
|
UnaryMinusExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return minusToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation minusToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT TildeExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(TildeExpression)
|
|
|
|
|
|
|
|
|
|
TildeExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return tildeToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation tildeToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT NotExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NotExpression)
|
|
|
|
|
|
|
|
|
|
NotExpression(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return notToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation notToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(BinaryExpression)
|
|
|
|
|
|
|
|
|
|
BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r):
|
|
|
|
|
left (l), op (o), right (r)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
BinaryExpression *binaryExpressionCast() override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return left->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return right->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *left;
|
|
|
|
|
int op;
|
|
|
|
|
ExpressionNode *right;
|
|
|
|
|
SourceLocation operatorToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ConditionalExpression)
|
|
|
|
|
|
|
|
|
|
ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f):
|
|
|
|
|
expression (e), ok (t), ko (f)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return ko->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
ExpressionNode *ok;
|
|
|
|
|
ExpressionNode *ko;
|
|
|
|
|
SourceLocation questionToken;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Expression)
|
|
|
|
|
|
|
|
|
|
Expression(ExpressionNode *l, ExpressionNode *r):
|
|
|
|
|
left (l), right (r) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return left->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return right->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *left;
|
|
|
|
|
ExpressionNode *right;
|
|
|
|
|
SourceLocation commaToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT Block: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Block)
|
|
|
|
|
|
|
|
|
|
Block(StatementList *slist):
|
|
|
|
|
statements (slist) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return lbraceToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
StatementList *statements;
|
|
|
|
|
SourceLocation lbraceToken;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT StatementList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(StatementList)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
// ### This should be a Statement, but FunctionDeclaration currently doesn't inherit it.
|
|
|
|
|
StatementList(Node *stmt)
|
|
|
|
|
: statement(stmt), next (this)
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
StatementList *append(StatementList *n) {
|
|
|
|
|
n->next = next;
|
|
|
|
|
next = n;
|
|
|
|
|
return n;
|
2010-01-18 13:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return statement->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : statement->lastSourceLocation(); }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
inline StatementList *finish ()
|
|
|
|
|
{
|
|
|
|
|
StatementList *front = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
Node *statement = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
StatementList *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT VariableDeclarationList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(VariableDeclarationList)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
VariableDeclarationList(PatternElement *decl)
|
|
|
|
|
: declaration(decl), next(this)
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
VariableDeclarationList(VariableDeclarationList *previous, PatternElement *decl)
|
|
|
|
|
: declaration(decl)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return declaration->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{
|
|
|
|
|
if (next)
|
|
|
|
|
return next->lastSourceLocation();
|
|
|
|
|
return declaration->lastSourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
inline VariableDeclarationList *finish(VariableScope s)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
VariableDeclarationList *front = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2017-12-20 10:47:33 +01:00
|
|
|
VariableDeclarationList *vdl;
|
2018-10-16 15:32:58 +02:00
|
|
|
for (vdl = front; vdl != nullptr; vdl = vdl->next) {
|
2017-12-20 10:47:33 +01:00
|
|
|
vdl->declaration->scope = s;
|
2010-01-18 13:13:34 +01:00
|
|
|
}
|
|
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElement *declaration;
|
2010-01-18 13:13:34 +01:00
|
|
|
VariableDeclarationList *next;
|
|
|
|
|
SourceLocation commaToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT VariableStatement: public Statement
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(VariableStatement)
|
|
|
|
|
|
|
|
|
|
VariableStatement(VariableDeclarationList *vlist):
|
|
|
|
|
declarations (vlist)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return declarationKindToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return declarations->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
VariableDeclarationList *declarations;
|
|
|
|
|
SourceLocation declarationKindToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT EmptyStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(EmptyStatement)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
EmptyStatement() { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ExpressionStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ExpressionStatement)
|
|
|
|
|
|
|
|
|
|
ExpressionStatement(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return expression->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return semicolonToken.isValid() ? semicolonToken : expression->lastSourceLocation(); }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT IfStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(IfStatement)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
IfStatement(ExpressionNode *e, Statement *t, Statement *f = nullptr):
|
2010-01-18 13:13:34 +01:00
|
|
|
expression (e), ok (t), ko (f)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return ifToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
if (ko)
|
|
|
|
|
return ko->lastSourceLocation();
|
|
|
|
|
|
|
|
|
|
return ok->lastSourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
Statement *ok;
|
|
|
|
|
Statement *ko;
|
|
|
|
|
SourceLocation ifToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
SourceLocation elseToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT DoWhileStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(DoWhileStatement)
|
|
|
|
|
|
|
|
|
|
DoWhileStatement(Statement *stmt, ExpressionNode *e):
|
|
|
|
|
statement (stmt), expression (e)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return doToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
Statement *statement;
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation doToken;
|
|
|
|
|
SourceLocation whileToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT WhileStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(WhileStatement)
|
|
|
|
|
|
|
|
|
|
WhileStatement(ExpressionNode *e, Statement *stmt):
|
|
|
|
|
expression (e), statement (stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return whileToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
Statement *statement;
|
|
|
|
|
SourceLocation whileToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ForStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ForStatement)
|
|
|
|
|
|
|
|
|
|
ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
|
|
|
|
|
initialiser (i), condition (c), expression (e), statement (stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
|
2010-01-18 13:13:34 +01:00
|
|
|
declarations (vlist), condition (c), expression (e), statement (stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return forToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
ExpressionNode *initialiser = nullptr;
|
|
|
|
|
VariableDeclarationList *declarations = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
ExpressionNode *condition;
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
Statement *statement;
|
|
|
|
|
SourceLocation forToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation firstSemicolonToken;
|
|
|
|
|
SourceLocation secondSemicolonToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
enum class ForEachType {
|
|
|
|
|
In,
|
|
|
|
|
Of
|
|
|
|
|
};
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
class QML_PARSER_EXPORT ForEachStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ForEachStatement)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt)
|
|
|
|
|
: lhs(i), expression(e), statement(stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
ForEachStatement(PatternElement *v, ExpressionNode *e, Statement *stmt)
|
|
|
|
|
: lhs(v), expression(e), statement(stmt)
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return forToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElement *declaration() const {
|
|
|
|
|
return AST::cast<PatternElement *>(lhs);
|
|
|
|
|
}
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
Node *lhs;
|
2010-01-18 13:13:34 +01:00
|
|
|
ExpressionNode *expression;
|
|
|
|
|
Statement *statement;
|
|
|
|
|
SourceLocation forToken;
|
|
|
|
|
SourceLocation lparenToken;
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation inOfToken;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation rparenToken;
|
2018-10-16 15:32:58 +02:00
|
|
|
ForEachType type;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ContinueStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ContinueStatement)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
ContinueStatement(const QStringRef &l = QStringRef()):
|
2010-01-18 13:13:34 +01:00
|
|
|
label (l) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return continueToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef label;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation continueToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT BreakStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(BreakStatement)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
BreakStatement(const QStringRef &l):
|
2010-01-18 13:13:34 +01:00
|
|
|
label (l) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return breakToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef label;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation breakToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ReturnStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ReturnStatement)
|
|
|
|
|
|
|
|
|
|
ReturnStatement(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return returnToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation returnToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT YieldExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(YieldExpression)
|
|
|
|
|
|
|
|
|
|
YieldExpression(ExpressionNode *e = nullptr):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return yieldToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return expression ? expression->lastSourceLocation() : yieldToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
bool isYieldStar = false;
|
|
|
|
|
SourceLocation yieldToken;
|
|
|
|
|
};
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
class QML_PARSER_EXPORT WithStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(WithStatement)
|
|
|
|
|
|
|
|
|
|
WithStatement(ExpressionNode *e, Statement *stmt):
|
|
|
|
|
expression (e), statement (stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return withToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
Statement *statement;
|
|
|
|
|
SourceLocation withToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT CaseBlock: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(CaseBlock)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
CaseBlock(CaseClauses *c, DefaultClause *d = nullptr, CaseClauses *r = nullptr):
|
2010-01-18 13:13:34 +01:00
|
|
|
clauses (c), defaultClause (d), moreClauses (r)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return lbraceToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
CaseClauses *clauses;
|
|
|
|
|
DefaultClause *defaultClause;
|
|
|
|
|
CaseClauses *moreClauses;
|
|
|
|
|
SourceLocation lbraceToken;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT SwitchStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(SwitchStatement)
|
|
|
|
|
|
|
|
|
|
SwitchStatement(ExpressionNode *e, CaseBlock *b):
|
|
|
|
|
expression (e), block (b)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return switchToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return block->rbraceToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
CaseBlock *block;
|
|
|
|
|
SourceLocation switchToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
class QML_PARSER_EXPORT CaseClause: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(CaseClause)
|
|
|
|
|
|
|
|
|
|
CaseClause(ExpressionNode *e, StatementList *slist):
|
|
|
|
|
expression (e), statements (slist)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return caseToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return statements ? statements->lastSourceLocation() : colonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
StatementList *statements;
|
|
|
|
|
SourceLocation caseToken;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
};
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
class QML_PARSER_EXPORT CaseClauses: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(CaseClauses)
|
|
|
|
|
|
|
|
|
|
CaseClauses(CaseClause *c):
|
|
|
|
|
clause (c), next (this)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
CaseClauses(CaseClauses *previous, CaseClause *c):
|
|
|
|
|
clause (c)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return clause->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : clause->lastSourceLocation(); }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
inline CaseClauses *finish ()
|
|
|
|
|
{
|
|
|
|
|
CaseClauses *front = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//attributes
|
|
|
|
|
CaseClause *clause;
|
|
|
|
|
CaseClauses *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT DefaultClause: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(DefaultClause)
|
|
|
|
|
|
|
|
|
|
DefaultClause(StatementList *slist):
|
|
|
|
|
statements (slist)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return defaultToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return statements ? statements->lastSourceLocation() : colonToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
StatementList *statements;
|
|
|
|
|
SourceLocation defaultToken;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT LabelledStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(LabelledStatement)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
LabelledStatement(const QStringRef &l, Statement *stmt):
|
2010-01-18 13:13:34 +01:00
|
|
|
label (l), statement (stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return identifierToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef label;
|
2010-01-18 13:13:34 +01:00
|
|
|
Statement *statement;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ThrowStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ThrowStatement)
|
|
|
|
|
|
|
|
|
|
ThrowStatement(ExpressionNode *e):
|
|
|
|
|
expression (e) { kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return throwToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
ExpressionNode *expression;
|
|
|
|
|
SourceLocation throwToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT Catch: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Catch)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
Catch(PatternElement *p, Block *stmt)
|
|
|
|
|
: patternElement(p), statement(stmt)
|
|
|
|
|
{ kind = K; }
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return catchToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
PatternElement *patternElement;
|
2010-01-18 13:13:34 +01:00
|
|
|
Block *statement;
|
|
|
|
|
SourceLocation catchToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT Finally: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Finally)
|
|
|
|
|
|
|
|
|
|
Finally(Block *stmt):
|
|
|
|
|
statement (stmt)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return finallyToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return statement ? statement->lastSourceLocation() : finallyToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
Block *statement;
|
|
|
|
|
SourceLocation finallyToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT TryStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(TryStatement)
|
|
|
|
|
|
|
|
|
|
TryStatement(Statement *stmt, Catch *c, Finally *f):
|
|
|
|
|
statement (stmt), catchExpression (c), finallyExpression (f)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
TryStatement(Statement *stmt, Finally *f):
|
2018-10-16 15:32:58 +02:00
|
|
|
statement (stmt), catchExpression (nullptr), finallyExpression (f)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
TryStatement(Statement *stmt, Catch *c):
|
2018-10-16 15:32:58 +02:00
|
|
|
statement (stmt), catchExpression (c), finallyExpression (nullptr)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return tryToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
if (finallyExpression)
|
|
|
|
|
return finallyExpression->statement->rbraceToken;
|
|
|
|
|
else if (catchExpression)
|
|
|
|
|
return catchExpression->statement->rbraceToken;
|
|
|
|
|
|
|
|
|
|
return statement->lastSourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
Statement *statement;
|
|
|
|
|
Catch *catchExpression;
|
|
|
|
|
Finally *finallyExpression;
|
|
|
|
|
SourceLocation tryToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(FunctionExpression)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
FunctionExpression(const QStringRef &n, FormalParameterList *f, StatementList *b):
|
2010-01-18 13:13:34 +01:00
|
|
|
name (n), formals (f), body (b)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return functionToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
FunctionExpression *asFunctionDefinition() override;
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef name;
|
2018-10-16 15:32:58 +02:00
|
|
|
bool isArrowFunction = false;
|
|
|
|
|
bool isGenerator = false;
|
2010-01-18 13:13:34 +01:00
|
|
|
FormalParameterList *formals;
|
2018-10-16 15:32:58 +02:00
|
|
|
StatementList *body;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation functionToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation lparenToken;
|
|
|
|
|
SourceLocation rparenToken;
|
|
|
|
|
SourceLocation lbraceToken;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(FunctionDeclaration)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
FunctionDeclaration(const QStringRef &n, FormalParameterList *f, StatementList *b):
|
2010-01-18 13:13:34 +01:00
|
|
|
FunctionExpression(n, f, b)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT FormalParameterList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(FormalParameterList)
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
FormalParameterList(FormalParameterList *previous, PatternElement *e)
|
|
|
|
|
: element(e)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
if (previous) {
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
} else {
|
|
|
|
|
next = this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormalParameterList *append(FormalParameterList *n) {
|
|
|
|
|
n->next = next;
|
|
|
|
|
next = n;
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isSimpleParameterList()
|
|
|
|
|
{
|
|
|
|
|
AST::FormalParameterList *formals = this;
|
|
|
|
|
while (formals) {
|
|
|
|
|
PatternElement *e = formals->element;
|
|
|
|
|
if (e && e->type == PatternElement::RestElement)
|
|
|
|
|
return false;
|
|
|
|
|
if (e && (e->initializer || e->bindingTarget))
|
|
|
|
|
return false;
|
|
|
|
|
formals = formals->next;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int length()
|
|
|
|
|
{
|
|
|
|
|
// the length property of Function objects
|
|
|
|
|
int l = 0;
|
|
|
|
|
AST::FormalParameterList *formals = this;
|
|
|
|
|
while (formals) {
|
|
|
|
|
PatternElement *e = formals->element;
|
|
|
|
|
if (!e || e->initializer)
|
|
|
|
|
break;
|
|
|
|
|
if (e->type == PatternElement::RestElement)
|
|
|
|
|
break;
|
|
|
|
|
++l;
|
|
|
|
|
formals = formals->next;
|
|
|
|
|
}
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool containsName(const QString &name) const {
|
|
|
|
|
for (const FormalParameterList *it = this; it; it = it->next) {
|
|
|
|
|
PatternElement *b = it->element;
|
|
|
|
|
// ### handle binding patterns
|
|
|
|
|
if (b && b->bindingIdentifier == name)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList formals() const;
|
|
|
|
|
|
|
|
|
|
QStringList boundNames() const;
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return element->firstSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
FormalParameterList *finish(MemoryPool *pool);
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
PatternElement *element = nullptr;
|
|
|
|
|
FormalParameterList *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ClassExpression : public ExpressionNode
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ClassExpression)
|
|
|
|
|
|
|
|
|
|
ClassExpression(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
|
|
|
|
|
: name(n), heritage(heritage), elements(elements)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return classToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
|
|
|
|
ClassExpression *asClassDefinition() override;
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
QStringRef name;
|
|
|
|
|
ExpressionNode *heritage;
|
|
|
|
|
ClassElementList *elements;
|
|
|
|
|
SourceLocation classToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation lbraceToken;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ClassDeclaration: public ClassExpression
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ClassDeclaration)
|
|
|
|
|
|
|
|
|
|
ClassDeclaration(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
|
|
|
|
|
: ClassExpression(n, heritage, elements)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ClassElementList : public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ClassElementList)
|
|
|
|
|
|
|
|
|
|
ClassElementList(PatternProperty *property, bool isStatic)
|
|
|
|
|
: isStatic(isStatic), property(property)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
kind = K;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClassElementList *append(ClassElementList *n) {
|
|
|
|
|
n->next = next;
|
|
|
|
|
next = n;
|
|
|
|
|
return n;
|
2010-01-18 13:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return property->firstSourceLocation(); }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{
|
|
|
|
|
if (next)
|
|
|
|
|
return next->lastSourceLocation();
|
|
|
|
|
return property->lastSourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClassElementList *finish();
|
|
|
|
|
|
|
|
|
|
bool isStatic;
|
|
|
|
|
ClassElementList *next;
|
|
|
|
|
PatternProperty *property;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT Program: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Program)
|
|
|
|
|
|
|
|
|
|
Program(StatementList *statements)
|
|
|
|
|
: statements(statements)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return statements ? statements->firstSourceLocation() : SourceLocation(); }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return statements ? statements->lastSourceLocation() : SourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
StatementList *statements;
|
|
|
|
|
};
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ImportSpecifier: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ImportSpecifier)
|
|
|
|
|
|
|
|
|
|
ImportSpecifier(const QStringRef &importedBinding)
|
|
|
|
|
: importedBinding(importedBinding)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
2018-10-16 15:32:58 +02:00
|
|
|
kind = K;
|
2010-01-18 13:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ImportSpecifier(const QStringRef &identifier, const QStringRef &importedBinding)
|
|
|
|
|
: identifier(identifier), importedBinding(importedBinding)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return identifier.isNull() ? importedBindingToken : identifierToken; }
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return importedBindingToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
SourceLocation identifierToken;
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation importedBindingToken;
|
|
|
|
|
QStringRef identifier;
|
|
|
|
|
QStringRef importedBinding;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ImportsList: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(ImportsList)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ImportsList(ImportSpecifier *importSpecifier)
|
|
|
|
|
: importSpecifier(importSpecifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportsList(ImportsList *previous, ImportSpecifier *importSpecifier)
|
|
|
|
|
: importSpecifier(importSpecifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
if (previous) {
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
} else {
|
|
|
|
|
next = this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportsList *finish()
|
|
|
|
|
{
|
|
|
|
|
ImportsList *head = next;
|
|
|
|
|
next = nullptr;
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return importSpecifierToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return next ? next->lastSourceLocation() : importSpecifierToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation importSpecifierToken;
|
|
|
|
|
ImportSpecifier *importSpecifier;
|
|
|
|
|
ImportsList *next = this;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT NamedImports: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(NamedImports)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
NamedImports()
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
NamedImports(ImportsList *importsList)
|
|
|
|
|
: importsList(importsList)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return leftBraceToken; }
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return rightBraceToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation leftBraceToken;
|
|
|
|
|
SourceLocation rightBraceToken;
|
|
|
|
|
ImportsList *importsList = nullptr;
|
|
|
|
|
};
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT NameSpaceImport: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(NameSpaceImport)
|
|
|
|
|
|
|
|
|
|
NameSpaceImport(const QStringRef &importedBinding)
|
|
|
|
|
: importedBinding(importedBinding)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
2018-10-16 15:32:58 +02:00
|
|
|
kind = K;
|
2010-01-18 13:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
virtual SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return starToken; }
|
|
|
|
|
virtual SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return importedBindingToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation starToken;
|
|
|
|
|
SourceLocation importedBindingToken;
|
|
|
|
|
QStringRef importedBinding;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ImportClause: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(ImportClause)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ImportClause(const QStringRef &importedDefaultBinding)
|
|
|
|
|
: importedDefaultBinding(importedDefaultBinding)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportClause(NameSpaceImport *nameSpaceImport)
|
|
|
|
|
: nameSpaceImport(nameSpaceImport)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportClause(NamedImports *namedImports)
|
|
|
|
|
: namedImports(namedImports)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportClause(const QStringRef &importedDefaultBinding, NameSpaceImport *nameSpaceImport)
|
|
|
|
|
: importedDefaultBinding(importedDefaultBinding)
|
|
|
|
|
, nameSpaceImport(nameSpaceImport)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportClause(const QStringRef &importedDefaultBinding, NamedImports *namedImports)
|
|
|
|
|
: importedDefaultBinding(importedDefaultBinding)
|
|
|
|
|
, namedImports(namedImports)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
virtual SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->firstSourceLocation() : namedImports->firstSourceLocation()) : importedDefaultBindingToken; }
|
|
|
|
|
virtual SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return importedDefaultBinding.isNull() ? (nameSpaceImport ? nameSpaceImport->lastSourceLocation() : namedImports->lastSourceLocation()) : importedDefaultBindingToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation importedDefaultBindingToken;
|
|
|
|
|
QStringRef importedDefaultBinding;
|
|
|
|
|
NameSpaceImport *nameSpaceImport = nullptr;
|
|
|
|
|
NamedImports *namedImports = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT FromClause: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(FromClause)
|
|
|
|
|
|
|
|
|
|
FromClause(const QStringRef &moduleSpecifier)
|
|
|
|
|
: moduleSpecifier(moduleSpecifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return fromToken; }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return moduleSpecifierToken; }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation fromToken;
|
|
|
|
|
SourceLocation moduleSpecifierToken;
|
|
|
|
|
QStringRef moduleSpecifier;
|
2011-12-07 11:16:26 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ImportDeclaration: public Statement
|
2011-12-07 11:16:26 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(ImportDeclaration)
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ImportDeclaration(ImportClause *importClause, FromClause *fromClause)
|
|
|
|
|
: importClause(importClause), fromClause(fromClause)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImportDeclaration(const QStringRef &moduleSpecifier)
|
|
|
|
|
: moduleSpecifier(moduleSpecifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return importToken; }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return moduleSpecifier.isNull() ? fromClause->lastSourceLocation() : moduleSpecifierToken; }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation importToken;
|
|
|
|
|
SourceLocation moduleSpecifierToken;
|
|
|
|
|
QStringRef moduleSpecifier;
|
|
|
|
|
ImportClause *importClause = nullptr;
|
|
|
|
|
FromClause *fromClause = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ExportSpecifier: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(ExportSpecifier)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ExportSpecifier(const QStringRef &identifier)
|
|
|
|
|
: identifier(identifier), exportedIdentifier(identifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportSpecifier(const QStringRef &identifier, const QStringRef &exportedIdentifier)
|
|
|
|
|
: identifier(identifier), exportedIdentifier(exportedIdentifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return identifierToken; }
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return exportedIdentifierToken.isValid() ? exportedIdentifierToken : identifierToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation exportedIdentifierToken;
|
|
|
|
|
QStringRef identifier;
|
|
|
|
|
QStringRef exportedIdentifier;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ExportsList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ExportsList)
|
|
|
|
|
|
|
|
|
|
ExportsList(ExportSpecifier *exportSpecifier)
|
|
|
|
|
: exportSpecifier(exportSpecifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportsList(ExportsList *previous, ExportSpecifier *exportSpecifier)
|
|
|
|
|
: exportSpecifier(exportSpecifier)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
if (previous) {
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
} else {
|
|
|
|
|
next = this;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ExportsList *finish()
|
|
|
|
|
{
|
|
|
|
|
ExportsList *head = next;
|
|
|
|
|
next = nullptr;
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return exportSpecifier->firstSourceLocation(); }
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return next ? next->lastSourceLocation() : exportSpecifier->lastSourceLocation(); }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
ExportSpecifier *exportSpecifier;
|
|
|
|
|
ExportsList *next;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ExportClause: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-10-16 15:32:58 +02:00
|
|
|
QMLJS_DECLARE_AST_NODE(ExportClause)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
ExportClause()
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportClause(ExportsList *exportsList)
|
|
|
|
|
: exportsList(exportsList)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return leftBraceToken; }
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return rightBraceToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation leftBraceToken;
|
|
|
|
|
SourceLocation rightBraceToken;
|
|
|
|
|
ExportsList *exportsList = nullptr;
|
|
|
|
|
};
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
class QML_PARSER_EXPORT ExportDeclaration: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(ExportDeclaration)
|
|
|
|
|
|
|
|
|
|
ExportDeclaration(FromClause *fromClause)
|
|
|
|
|
: fromClause(fromClause)
|
|
|
|
|
{
|
|
|
|
|
exportAll = true;
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportDeclaration(ExportClause *exportClause, FromClause *fromClause)
|
|
|
|
|
: exportClause(exportClause), fromClause(fromClause)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportDeclaration(ExportClause *exportClause)
|
|
|
|
|
: exportClause(exportClause)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExportDeclaration(bool exportDefault, Node *variableStatementOrDeclaration)
|
|
|
|
|
: variableStatementOrDeclaration(variableStatementOrDeclaration)
|
|
|
|
|
, exportDefault(exportDefault)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return exportToken; }
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2018-10-16 15:32:58 +02:00
|
|
|
{ return fromClause ? fromClause->lastSourceLocation() : (exportClause ? exportClause->lastSourceLocation() : variableStatementOrDeclaration->lastSourceLocation()); }
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
SourceLocation exportToken;
|
|
|
|
|
bool exportAll = false;
|
|
|
|
|
ExportClause *exportClause = nullptr;
|
|
|
|
|
FromClause *fromClause = nullptr;
|
|
|
|
|
Node *variableStatementOrDeclaration = nullptr;
|
|
|
|
|
bool exportDefault = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT ESModule: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(Module)
|
|
|
|
|
|
|
|
|
|
ESModule(StatementList *body)
|
|
|
|
|
: body(body)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return body ? body->firstSourceLocation() : SourceLocation(); }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return body ? body->lastSourceLocation() : SourceLocation(); }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
StatementList *body;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT DebuggerStatement: public Statement
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(DebuggerStatement)
|
|
|
|
|
|
|
|
|
|
DebuggerStatement()
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return debuggerToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation debuggerToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiQualifiedId: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiQualifiedId)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
UiQualifiedId(const QStringRef &name)
|
2010-01-18 13:13:34 +01:00
|
|
|
: next(this), name(name)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
UiQualifiedId(UiQualifiedId *previous, const QStringRef &name)
|
2010-01-18 13:13:34 +01:00
|
|
|
: name(name)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UiQualifiedId *finish()
|
|
|
|
|
{
|
|
|
|
|
UiQualifiedId *head = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return identifierToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : identifierToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
UiQualifiedId *next;
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef name;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiImport: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiImport)
|
|
|
|
|
|
2011-09-13 08:42:52 +02:00
|
|
|
UiImport(const QStringRef &fileName)
|
2018-10-16 15:32:58 +02:00
|
|
|
: fileName(fileName), importUri(nullptr)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
UiImport(UiQualifiedId *uri)
|
2011-09-13 08:42:52 +02:00
|
|
|
: importUri(uri)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return importToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef fileName;
|
2010-01-18 13:13:34 +01:00
|
|
|
UiQualifiedId *importUri;
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef importId;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation importToken;
|
|
|
|
|
SourceLocation fileNameToken;
|
|
|
|
|
SourceLocation versionToken;
|
|
|
|
|
SourceLocation asToken;
|
|
|
|
|
SourceLocation importIdToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
class QML_PARSER_EXPORT UiObjectMember: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override = 0;
|
|
|
|
|
SourceLocation lastSourceLocation() const override = 0;
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
UiObjectMember *uiObjectMemberCast() override;
|
2013-11-06 14:17:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiObjectMemberList: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2013-11-06 14:17:23 +01:00
|
|
|
QMLJS_DECLARE_AST_NODE(UiObjectMemberList)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiObjectMemberList(UiObjectMember *member)
|
|
|
|
|
: next(this), member(member)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member)
|
|
|
|
|
: member(member)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return member->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
|
|
|
|
|
|
|
|
|
|
UiObjectMemberList *finish()
|
|
|
|
|
{
|
|
|
|
|
UiObjectMemberList *head = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2013-11-06 14:17:23 +01:00
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
UiObjectMemberList *next;
|
|
|
|
|
UiObjectMember *member;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiPragma: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2013-11-06 14:17:23 +01:00
|
|
|
QMLJS_DECLARE_AST_NODE(UiPragma)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2018-10-16 15:32:58 +02:00
|
|
|
UiPragma(QStringRef name)
|
|
|
|
|
: name(name)
|
2013-11-06 14:17:23 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return pragmaToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return semicolonToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
2018-10-16 15:32:58 +02:00
|
|
|
QStringRef name;
|
2013-11-06 14:17:23 +01:00
|
|
|
SourceLocation pragmaToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
class QML_PARSER_EXPORT UiHeaderItemList: public Node
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2013-11-06 14:17:23 +01:00
|
|
|
QMLJS_DECLARE_AST_NODE(UiHeaderItemList)
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiHeaderItemList(UiImport *import)
|
|
|
|
|
: headerItem(import), next(this)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiHeaderItemList(UiPragma *pragma)
|
|
|
|
|
: headerItem(pragma), next(this)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
UiHeaderItemList(UiHeaderItemList *previous, UiImport *import)
|
|
|
|
|
: headerItem(import)
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiHeaderItemList(UiHeaderItemList *previous, UiPragma *pragma)
|
|
|
|
|
: headerItem(pragma)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiHeaderItemList *finish()
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
2013-11-06 14:17:23 +01:00
|
|
|
UiHeaderItemList *head = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2013-11-06 14:17:23 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return headerItem->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2013-11-06 14:17:23 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : headerItem->lastSourceLocation(); }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
2013-11-06 14:17:23 +01:00
|
|
|
Node *headerItem;
|
|
|
|
|
UiHeaderItemList *next;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
class QML_PARSER_EXPORT UiProgram: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiProgram)
|
|
|
|
|
|
2013-11-06 14:17:23 +01:00
|
|
|
UiProgram(UiHeaderItemList *headers, UiObjectMemberList *members)
|
|
|
|
|
: headers(headers), members(members)
|
2011-12-07 11:16:26 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{
|
2013-11-06 14:17:23 +01:00
|
|
|
if (headers)
|
|
|
|
|
return headers->firstSourceLocation();
|
2011-12-07 11:16:26 +01:00
|
|
|
else if (members)
|
|
|
|
|
return members->firstSourceLocation();
|
|
|
|
|
return SourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{
|
|
|
|
|
if (members)
|
|
|
|
|
return members->lastSourceLocation();
|
2013-11-06 14:17:23 +01:00
|
|
|
else if (headers)
|
|
|
|
|
return headers->lastSourceLocation();
|
2011-12-07 11:16:26 +01:00
|
|
|
return SourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
2013-11-06 14:17:23 +01:00
|
|
|
UiHeaderItemList *headers;
|
2011-12-07 11:16:26 +01:00
|
|
|
UiObjectMemberList *members;
|
|
|
|
|
};
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
class QML_PARSER_EXPORT UiArrayMemberList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiArrayMemberList)
|
|
|
|
|
|
|
|
|
|
UiArrayMemberList(UiObjectMember *member)
|
|
|
|
|
: next(this), member(member)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member)
|
|
|
|
|
: member(member)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return member->firstSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
UiArrayMemberList *finish()
|
|
|
|
|
{
|
|
|
|
|
UiArrayMemberList *head = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
UiArrayMemberList *next;
|
|
|
|
|
UiObjectMember *member;
|
|
|
|
|
SourceLocation commaToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiObjectInitializer: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiObjectInitializer)
|
|
|
|
|
|
|
|
|
|
UiObjectInitializer(UiObjectMemberList *members)
|
|
|
|
|
: members(members)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return lbraceToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
SourceLocation lbraceToken;
|
|
|
|
|
UiObjectMemberList *members;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiParameterList: public Node
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiParameterList)
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
UiParameterList(UiQualifiedId *t, const QStringRef &n):
|
2010-01-18 13:13:34 +01:00
|
|
|
type (t), name (n), next (this)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
UiParameterList(UiParameterList *previous, UiQualifiedId *t, const QStringRef &n):
|
2010-01-18 13:13:34 +01:00
|
|
|
type (t), name (n)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return propertyTypeToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2011-12-07 11:16:26 +01:00
|
|
|
{ return next ? next->lastSourceLocation() : identifierToken; }
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
inline UiParameterList *finish ()
|
|
|
|
|
{
|
|
|
|
|
UiParameterList *front = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2010-01-18 13:13:34 +01:00
|
|
|
return front;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
2017-03-16 17:13:46 +01:00
|
|
|
UiQualifiedId *type;
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef name;
|
2010-01-18 13:13:34 +01:00
|
|
|
UiParameterList *next;
|
|
|
|
|
SourceLocation commaToken;
|
2011-12-07 11:16:26 +01:00
|
|
|
SourceLocation propertyTypeToken;
|
2010-01-18 13:13:34 +01:00
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiPublicMember)
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
UiPublicMember(UiQualifiedId *memberType,
|
2011-09-13 08:42:52 +02:00
|
|
|
const QStringRef &name)
|
2018-10-16 15:32:58 +02:00
|
|
|
: type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
UiPublicMember(UiQualifiedId *memberType,
|
2011-09-13 08:42:52 +02:00
|
|
|
const QStringRef &name,
|
2011-05-12 13:25:35 +02:00
|
|
|
Statement *statement)
|
2018-10-16 15:32:58 +02:00
|
|
|
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
if (defaultToken.isValid())
|
|
|
|
|
return defaultToken;
|
|
|
|
|
else if (readonlyToken.isValid())
|
|
|
|
|
return readonlyToken;
|
|
|
|
|
|
|
|
|
|
return propertyToken;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
2010-03-31 15:40:28 +02:00
|
|
|
if (binding)
|
|
|
|
|
return binding->lastSourceLocation();
|
2011-06-27 10:43:29 +02:00
|
|
|
if (statement)
|
|
|
|
|
return statement->lastSourceLocation();
|
2010-03-31 15:40:28 +02:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
return semicolonToken;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
enum { Signal, Property } type;
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef typeModifier;
|
2017-03-16 17:13:46 +01:00
|
|
|
UiQualifiedId *memberType;
|
2011-09-13 08:42:52 +02:00
|
|
|
QStringRef name;
|
2011-05-12 13:25:35 +02:00
|
|
|
Statement *statement; // initialized with a JS expression
|
2010-03-31 15:40:28 +02:00
|
|
|
UiObjectMember *binding; // initialized with a QML object or array.
|
2010-01-18 13:13:34 +01:00
|
|
|
bool isDefaultMember;
|
|
|
|
|
bool isReadonlyMember;
|
|
|
|
|
UiParameterList *parameters;
|
|
|
|
|
SourceLocation defaultToken;
|
|
|
|
|
SourceLocation readonlyToken;
|
|
|
|
|
SourceLocation propertyToken;
|
|
|
|
|
SourceLocation typeModifierToken;
|
|
|
|
|
SourceLocation typeToken;
|
|
|
|
|
SourceLocation identifierToken;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
SourceLocation semicolonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiObjectDefinition)
|
|
|
|
|
|
|
|
|
|
UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId,
|
|
|
|
|
UiObjectInitializer *initializer)
|
|
|
|
|
: qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return qualifiedTypeNameId->identifierToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return initializer->rbraceToken; }
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
UiQualifiedId *qualifiedTypeNameId;
|
|
|
|
|
UiObjectInitializer *initializer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiSourceElement)
|
|
|
|
|
|
|
|
|
|
UiSourceElement(Node *sourceElement)
|
|
|
|
|
: sourceElement(sourceElement)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
|
|
|
|
|
return funDecl->firstSourceLocation();
|
|
|
|
|
else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
|
|
|
|
|
return varStmt->firstSourceLocation();
|
|
|
|
|
|
|
|
|
|
return SourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{
|
|
|
|
|
if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
|
|
|
|
|
return funDecl->lastSourceLocation();
|
|
|
|
|
else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
|
|
|
|
|
return varStmt->lastSourceLocation();
|
|
|
|
|
|
|
|
|
|
return SourceLocation();
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
Node *sourceElement;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiObjectBinding)
|
|
|
|
|
|
|
|
|
|
UiObjectBinding(UiQualifiedId *qualifiedId,
|
|
|
|
|
UiQualifiedId *qualifiedTypeNameId,
|
|
|
|
|
UiObjectInitializer *initializer)
|
|
|
|
|
: qualifiedId(qualifiedId),
|
|
|
|
|
qualifiedTypeNameId(qualifiedTypeNameId),
|
2010-03-03 11:38:33 +01:00
|
|
|
initializer(initializer),
|
|
|
|
|
hasOnToken(false)
|
2010-01-18 13:13:34 +01:00
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-03-03 11:38:33 +01:00
|
|
|
{
|
|
|
|
|
if (hasOnToken && qualifiedTypeNameId)
|
|
|
|
|
return qualifiedTypeNameId->identifierToken;
|
|
|
|
|
|
|
|
|
|
return qualifiedId->identifierToken;
|
|
|
|
|
}
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return initializer->rbraceToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
2011-12-07 11:16:26 +01:00
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
// attributes
|
|
|
|
|
UiQualifiedId *qualifiedId;
|
|
|
|
|
UiQualifiedId *qualifiedTypeNameId;
|
|
|
|
|
UiObjectInitializer *initializer;
|
|
|
|
|
SourceLocation colonToken;
|
2010-03-03 11:38:33 +01:00
|
|
|
bool hasOnToken;
|
2010-01-18 13:13:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiScriptBinding)
|
|
|
|
|
|
|
|
|
|
UiScriptBinding(UiQualifiedId *qualifiedId,
|
|
|
|
|
Statement *statement)
|
|
|
|
|
: qualifiedId(qualifiedId),
|
|
|
|
|
statement(statement)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return qualifiedId->identifierToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return statement->lastSourceLocation(); }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
UiQualifiedId *qualifiedId;
|
|
|
|
|
Statement *statement;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiArrayBinding)
|
|
|
|
|
|
|
|
|
|
UiArrayBinding(UiQualifiedId *qualifiedId,
|
|
|
|
|
UiArrayMemberList *members)
|
|
|
|
|
: qualifiedId(qualifiedId),
|
|
|
|
|
members(members)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation firstSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return qualifiedId->identifierToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
SourceLocation lastSourceLocation() const override
|
2010-01-18 13:13:34 +01:00
|
|
|
{ return rbracketToken; }
|
|
|
|
|
|
2017-03-16 17:13:46 +01:00
|
|
|
void accept0(Visitor *visitor) override;
|
2010-01-18 13:13:34 +01:00
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
UiQualifiedId *qualifiedId;
|
|
|
|
|
UiArrayMemberList *members;
|
|
|
|
|
SourceLocation colonToken;
|
|
|
|
|
SourceLocation lbracketToken;
|
|
|
|
|
SourceLocation rbracketToken;
|
|
|
|
|
};
|
|
|
|
|
|
2017-12-20 10:47:33 +01:00
|
|
|
class QML_PARSER_EXPORT UiEnumMemberList: public Node
|
|
|
|
|
{
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiEnumMemberList)
|
|
|
|
|
public:
|
|
|
|
|
UiEnumMemberList(const QStringRef &member, double v = 0.0)
|
|
|
|
|
: next(this), member(member), value(v)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
UiEnumMemberList(UiEnumMemberList *previous, const QStringRef &member)
|
|
|
|
|
: member(member)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
value = previous->value + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UiEnumMemberList(UiEnumMemberList *previous, const QStringRef &member, double v)
|
|
|
|
|
: member(member), value(v)
|
|
|
|
|
{
|
|
|
|
|
kind = K;
|
|
|
|
|
next = previous->next;
|
|
|
|
|
previous->next = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return memberToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return next ? next->lastSourceLocation() :
|
|
|
|
|
valueToken.isValid() ? valueToken : memberToken; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
UiEnumMemberList *finish()
|
|
|
|
|
{
|
|
|
|
|
UiEnumMemberList *head = next;
|
2018-10-16 15:32:58 +02:00
|
|
|
next = nullptr;
|
2017-12-20 10:47:33 +01:00
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
UiEnumMemberList *next;
|
|
|
|
|
QStringRef member;
|
|
|
|
|
double value;
|
|
|
|
|
SourceLocation memberToken;
|
|
|
|
|
SourceLocation valueToken;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT UiEnumDeclaration: public UiObjectMember
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QMLJS_DECLARE_AST_NODE(UiEnumDeclaration)
|
|
|
|
|
|
|
|
|
|
UiEnumDeclaration(const QStringRef &name,
|
|
|
|
|
UiEnumMemberList *members)
|
|
|
|
|
: name(name)
|
|
|
|
|
, members(members)
|
|
|
|
|
{ kind = K; }
|
|
|
|
|
|
|
|
|
|
SourceLocation firstSourceLocation() const override
|
|
|
|
|
{ return enumToken; }
|
|
|
|
|
|
|
|
|
|
SourceLocation lastSourceLocation() const override
|
|
|
|
|
{ return rbraceToken; }
|
|
|
|
|
|
|
|
|
|
void accept0(Visitor *visitor) override;
|
|
|
|
|
|
|
|
|
|
// attributes
|
|
|
|
|
SourceLocation enumToken;
|
|
|
|
|
SourceLocation rbraceToken;
|
|
|
|
|
QStringRef name;
|
|
|
|
|
UiEnumMemberList *members;
|
|
|
|
|
};
|
|
|
|
|
|
2010-01-18 13:13:34 +01:00
|
|
|
} } // namespace AST
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QT_QML_END_NAMESPACE
|
2017-03-16 17:13:46 +01:00
|
|
|
|