forked from qt-creator/qt-creator
QmlJS: Merge parser updates from Qt5.
Change-Id: Ibed38abca8f7e7bae7d424751a18c83f4c9e9bc5 Reviewed-on: http://codereview.qt-project.org/4732 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "qmljsastvisitor_p.h"
|
||||
#include "qmljsglobal_p.h"
|
||||
#include "qmljsmemorypool_p.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
@@ -98,7 +99,7 @@ enum Op {
|
||||
} // namespace QSOperator
|
||||
|
||||
namespace QmlJS {
|
||||
class NameId;
|
||||
|
||||
namespace AST {
|
||||
|
||||
template <typename _T1, typename _T2>
|
||||
@@ -110,7 +111,7 @@ _T1 cast(_T2 *ast)
|
||||
return 0;
|
||||
}
|
||||
|
||||
class QML_PARSER_EXPORT Node
|
||||
class QML_PARSER_EXPORT Node: public Managed
|
||||
{
|
||||
public:
|
||||
enum Kind {
|
||||
@@ -264,7 +265,7 @@ class QML_PARSER_EXPORT UiFormal: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiFormal)
|
||||
|
||||
UiFormal(NameId *name, NameId *alias = 0)
|
||||
UiFormal(const QStringRef &name, const QStringRef &alias)
|
||||
: name(name), alias(alias)
|
||||
{ }
|
||||
|
||||
@@ -277,8 +278,8 @@ public:
|
||||
virtual void accept0(Visitor *visitor);
|
||||
|
||||
// attributes
|
||||
NameId *name;
|
||||
NameId *alias;
|
||||
QStringRef name;
|
||||
QStringRef alias;
|
||||
SourceLocation identifierToken;
|
||||
SourceLocation asToken;
|
||||
SourceLocation aliasToken;
|
||||
@@ -389,7 +390,7 @@ class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(IdentifierExpression)
|
||||
|
||||
IdentifierExpression(NameId *n):
|
||||
IdentifierExpression(const QStringRef &n):
|
||||
name (n) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
@@ -401,7 +402,7 @@ public:
|
||||
{ return identifierToken; }
|
||||
|
||||
// attributes
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
SourceLocation identifierToken;
|
||||
};
|
||||
|
||||
@@ -488,7 +489,7 @@ class QML_PARSER_EXPORT StringLiteral: public ExpressionNode
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(StringLiteral)
|
||||
|
||||
StringLiteral(NameId *v):
|
||||
StringLiteral(const QStringRef &v):
|
||||
value (v) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
@@ -500,7 +501,7 @@ public:
|
||||
{ return literalToken; }
|
||||
|
||||
// attributes:
|
||||
NameId *value;
|
||||
QStringRef value;
|
||||
SourceLocation literalToken;
|
||||
};
|
||||
|
||||
@@ -509,7 +510,7 @@ class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(RegExpLiteral)
|
||||
|
||||
RegExpLiteral(NameId *p, int f):
|
||||
RegExpLiteral(const QStringRef &p, int f):
|
||||
pattern (p), flags (f) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
@@ -521,7 +522,7 @@ public:
|
||||
{ return literalToken; }
|
||||
|
||||
// attributes:
|
||||
NameId *pattern;
|
||||
QStringRef pattern;
|
||||
int flags;
|
||||
SourceLocation literalToken;
|
||||
};
|
||||
@@ -696,13 +697,13 @@ class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
|
||||
|
||||
IdentifierPropertyName(NameId *n):
|
||||
IdentifierPropertyName(const QStringRef &n):
|
||||
id (n) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
|
||||
// attributes
|
||||
NameId *id;
|
||||
QStringRef id;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
||||
@@ -710,13 +711,13 @@ class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
|
||||
|
||||
StringLiteralPropertyName(NameId *n):
|
||||
StringLiteralPropertyName(const QStringRef &n):
|
||||
id (n) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
|
||||
// attributes
|
||||
NameId *id;
|
||||
QStringRef id;
|
||||
};
|
||||
|
||||
class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
|
||||
@@ -762,7 +763,7 @@ class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FieldMemberExpression)
|
||||
|
||||
FieldMemberExpression(ExpressionNode *b, NameId *n):
|
||||
FieldMemberExpression(ExpressionNode *b, const QStringRef &n):
|
||||
base (b), name (n)
|
||||
{ kind = K; }
|
||||
|
||||
@@ -776,7 +777,7 @@ public:
|
||||
|
||||
// attributes
|
||||
ExpressionNode *base;
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
SourceLocation dotToken;
|
||||
SourceLocation identifierToken;
|
||||
};
|
||||
@@ -1268,14 +1269,14 @@ class QML_PARSER_EXPORT VariableDeclaration: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(VariableDeclaration)
|
||||
|
||||
VariableDeclaration(NameId *n, ExpressionNode *e):
|
||||
VariableDeclaration(const QStringRef &n, ExpressionNode *e):
|
||||
name (n), expression (e), readOnly(false)
|
||||
{ kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
|
||||
// attributes
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
ExpressionNode *expression;
|
||||
bool readOnly;
|
||||
SourceLocation identifierToken;
|
||||
@@ -1561,7 +1562,7 @@ class QML_PARSER_EXPORT ContinueStatement: public Statement
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(ContinueStatement)
|
||||
|
||||
ContinueStatement(NameId *l = 0):
|
||||
ContinueStatement(const QStringRef &l = QStringRef()):
|
||||
label (l) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
@@ -1573,7 +1574,7 @@ public:
|
||||
{ return semicolonToken; }
|
||||
|
||||
// attributes
|
||||
NameId *label;
|
||||
QStringRef label;
|
||||
SourceLocation continueToken;
|
||||
SourceLocation identifierToken;
|
||||
SourceLocation semicolonToken;
|
||||
@@ -1584,7 +1585,7 @@ class QML_PARSER_EXPORT BreakStatement: public Statement
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(BreakStatement)
|
||||
|
||||
BreakStatement(NameId *l = 0):
|
||||
BreakStatement(const QStringRef &l):
|
||||
label (l) { kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
@@ -1596,7 +1597,7 @@ public:
|
||||
{ return semicolonToken; }
|
||||
|
||||
// attributes
|
||||
NameId *label;
|
||||
QStringRef label;
|
||||
SourceLocation breakToken;
|
||||
SourceLocation identifierToken;
|
||||
SourceLocation semicolonToken;
|
||||
@@ -1764,7 +1765,7 @@ class QML_PARSER_EXPORT LabelledStatement: public Statement
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(LabelledStatement)
|
||||
|
||||
LabelledStatement(NameId *l, Statement *stmt):
|
||||
LabelledStatement(const QStringRef &l, Statement *stmt):
|
||||
label (l), statement (stmt)
|
||||
{ kind = K; }
|
||||
|
||||
@@ -1777,7 +1778,7 @@ public:
|
||||
{ return statement->lastSourceLocation(); }
|
||||
|
||||
// attributes
|
||||
NameId *label;
|
||||
QStringRef label;
|
||||
Statement *statement;
|
||||
SourceLocation identifierToken;
|
||||
SourceLocation colonToken;
|
||||
@@ -1810,14 +1811,14 @@ class QML_PARSER_EXPORT Catch: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(Catch)
|
||||
|
||||
Catch(NameId *n, Block *stmt):
|
||||
Catch(const QStringRef &n, Block *stmt):
|
||||
name (n), statement (stmt)
|
||||
{ kind = K; }
|
||||
|
||||
virtual void accept0(Visitor *visitor);
|
||||
|
||||
// attributes
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
Block *statement;
|
||||
SourceLocation catchToken;
|
||||
SourceLocation lparenToken;
|
||||
@@ -1885,7 +1886,7 @@ class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FunctionExpression)
|
||||
|
||||
FunctionExpression(NameId *n, FormalParameterList *f, FunctionBody *b):
|
||||
FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
|
||||
name (n), formals (f), body (b)
|
||||
{ kind = K; }
|
||||
|
||||
@@ -1898,7 +1899,7 @@ public:
|
||||
{ return rbraceToken; }
|
||||
|
||||
// attributes
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
FormalParameterList *formals;
|
||||
FunctionBody *body;
|
||||
SourceLocation functionToken;
|
||||
@@ -1914,7 +1915,7 @@ class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FunctionDeclaration)
|
||||
|
||||
FunctionDeclaration(NameId *n, FormalParameterList *f, FunctionBody *b):
|
||||
FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b):
|
||||
FunctionExpression(n, f, b)
|
||||
{ kind = K; }
|
||||
|
||||
@@ -1926,11 +1927,11 @@ class QML_PARSER_EXPORT FormalParameterList: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(FormalParameterList)
|
||||
|
||||
FormalParameterList(NameId *n):
|
||||
FormalParameterList(const QStringRef &n):
|
||||
name (n), next (this)
|
||||
{ kind = K; }
|
||||
|
||||
FormalParameterList(FormalParameterList *previous, NameId *n):
|
||||
FormalParameterList(FormalParameterList *previous, const QStringRef &n):
|
||||
name (n)
|
||||
{
|
||||
kind = K;
|
||||
@@ -1948,7 +1949,7 @@ public:
|
||||
}
|
||||
|
||||
// attributes
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
FormalParameterList *next;
|
||||
SourceLocation commaToken;
|
||||
SourceLocation identifierToken;
|
||||
@@ -2096,11 +2097,11 @@ class QML_PARSER_EXPORT UiQualifiedId: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiQualifiedId)
|
||||
|
||||
UiQualifiedId(NameId *name)
|
||||
UiQualifiedId(const QStringRef &name)
|
||||
: next(this), name(name)
|
||||
{ kind = K; }
|
||||
|
||||
UiQualifiedId(UiQualifiedId *previous, NameId *name)
|
||||
UiQualifiedId(UiQualifiedId *previous, const QStringRef &name)
|
||||
: name(name)
|
||||
{
|
||||
kind = K;
|
||||
@@ -2119,7 +2120,7 @@ public:
|
||||
|
||||
// attributes
|
||||
UiQualifiedId *next;
|
||||
NameId *name;
|
||||
QStringRef name;
|
||||
SourceLocation identifierToken;
|
||||
};
|
||||
|
||||
@@ -2128,12 +2129,12 @@ class QML_PARSER_EXPORT UiImport: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiImport)
|
||||
|
||||
UiImport(NameId *fileName)
|
||||
: fileName(fileName), importUri(0), importId(0)
|
||||
UiImport(const QStringRef &fileName)
|
||||
: fileName(fileName), importUri(0)
|
||||
{ kind = K; }
|
||||
|
||||
UiImport(UiQualifiedId *uri)
|
||||
: fileName(0), importUri(uri), importId(0)
|
||||
: importUri(uri)
|
||||
{ kind = K; }
|
||||
|
||||
virtual SourceLocation firstSourceLocation() const
|
||||
@@ -2145,9 +2146,9 @@ public:
|
||||
virtual void accept0(Visitor *visitor);
|
||||
|
||||
// attributes
|
||||
NameId *fileName;
|
||||
QStringRef fileName;
|
||||
UiQualifiedId *importUri;
|
||||
NameId *importId;
|
||||
QStringRef importId;
|
||||
SourceLocation importToken;
|
||||
SourceLocation fileNameToken;
|
||||
SourceLocation versionToken;
|
||||
@@ -2297,11 +2298,11 @@ class QML_PARSER_EXPORT UiParameterList: public Node
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiParameterList)
|
||||
|
||||
UiParameterList(NameId *t, NameId *n):
|
||||
UiParameterList(const QStringRef &t, const QStringRef &n):
|
||||
type (t), name (n), next (this)
|
||||
{ kind = K; }
|
||||
|
||||
UiParameterList(UiParameterList *previous, NameId *t, NameId *n):
|
||||
UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n):
|
||||
type (t), name (n)
|
||||
{
|
||||
kind = K;
|
||||
@@ -2319,8 +2320,8 @@ public:
|
||||
}
|
||||
|
||||
// attributes
|
||||
NameId *type;
|
||||
NameId *name;
|
||||
QStringRef type;
|
||||
QStringRef name;
|
||||
UiParameterList *next;
|
||||
SourceLocation commaToken;
|
||||
SourceLocation identifierToken;
|
||||
@@ -2331,15 +2332,15 @@ class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
|
||||
public:
|
||||
QMLJS_DECLARE_AST_NODE(UiPublicMember)
|
||||
|
||||
UiPublicMember(NameId *memberType,
|
||||
NameId *name)
|
||||
: type(Property), typeModifier(0), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
|
||||
UiPublicMember(const QStringRef &memberType,
|
||||
const QStringRef &name)
|
||||
: type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
|
||||
{ kind = K; }
|
||||
|
||||
UiPublicMember(NameId *memberType,
|
||||
NameId *name,
|
||||
UiPublicMember(const QStringRef &memberType,
|
||||
const QStringRef &name,
|
||||
Statement *statement)
|
||||
: type(Property), typeModifier(0), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
|
||||
: type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0)
|
||||
{ kind = K; }
|
||||
|
||||
virtual SourceLocation firstSourceLocation() const
|
||||
@@ -2366,9 +2367,9 @@ public:
|
||||
|
||||
// attributes
|
||||
enum { Signal, Property } type;
|
||||
NameId *typeModifier;
|
||||
NameId *memberType;
|
||||
NameId *name;
|
||||
QStringRef typeModifier;
|
||||
QStringRef memberType;
|
||||
QStringRef name;
|
||||
Statement *statement; // initialized with a JS expression
|
||||
UiObjectMember *binding; // initialized with a QML object or array.
|
||||
bool isDefaultMember;
|
||||
|
||||
Reference in New Issue
Block a user