2014-01-15 00:18:53 +01:00
|
|
|
diff --git a/src/libs/qmljs/parser/qmlerror.cpp b/src/libs/qmljs/parser/qmlerror.cpp
|
|
|
|
|
index d090a19..5ec311d 100644
|
|
|
|
|
--- a/src/libs/qmljs/parser/qmlerror.cpp
|
|
|
|
|
+++ b/src/libs/qmljs/parser/qmlerror.cpp
|
|
|
|
|
@@ -65,6 +65,12 @@ QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
|
\sa QQuickView::errors(), QmlComponent::errors()
|
|
|
|
|
*/
|
|
|
|
|
+
|
|
|
|
|
+static quint16 qmlSourceCoordinate(int n)
|
|
|
|
|
+{
|
|
|
|
|
+ return (n > 0 && n <= static_cast<int>(USHRT_MAX)) ? static_cast<quint16>(n) : 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
class QmlErrorPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
2013-01-22 11:15:23 +01:00
|
|
|
diff --git a/src/libs/qmljs/parser/qmljsengine_p.cpp b/src/libs/qmljs/parser/qmljsengine_p.cpp
|
2014-01-15 00:18:53 +01:00
|
|
|
index 1e22fa5..10fc3d1 100644
|
2013-01-22 11:15:23 +01:00
|
|
|
--- a/src/libs/qmljs/parser/qmljsengine_p.cpp
|
|
|
|
|
+++ b/src/libs/qmljs/parser/qmljsengine_p.cpp
|
|
|
|
|
@@ -110,7 +110,7 @@ double integerFromString(const QString &str, int radix)
|
2011-12-07 11:21:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Engine::Engine()
|
|
|
|
|
- : _lexer(0)
|
2013-01-23 15:06:08 +01:00
|
|
|
+ : _lexer(0), _directives(0)
|
2011-12-07 11:21:10 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
Engine::~Engine()
|
2013-01-22 11:15:23 +01:00
|
|
|
@@ -131,6 +131,12 @@ Lexer *Engine::lexer() const
|
2011-12-07 11:21:10 +01:00
|
|
|
void Engine::setLexer(Lexer *lexer)
|
|
|
|
|
{ _lexer = lexer; }
|
|
|
|
|
|
|
|
|
|
+void Engine::setDirectives(Directives *directives)
|
|
|
|
|
+{ _directives = directives; }
|
|
|
|
|
+
|
|
|
|
|
+Directives *Engine::directives() const
|
|
|
|
|
+{ return _directives; }
|
|
|
|
|
+
|
|
|
|
|
MemoryPool *Engine::pool()
|
|
|
|
|
{ return &_pool; }
|
|
|
|
|
|
2013-01-22 11:15:23 +01:00
|
|
|
diff --git a/src/libs/qmljs/parser/qmljsengine_p.h b/src/libs/qmljs/parser/qmljsengine_p.h
|
2014-01-15 00:18:53 +01:00
|
|
|
index b1f7e1a..29b69d1 100644
|
2013-01-22 11:15:23 +01:00
|
|
|
--- a/src/libs/qmljs/parser/qmljsengine_p.h
|
|
|
|
|
+++ b/src/libs/qmljs/parser/qmljsengine_p.h
|
2014-01-15 00:18:53 +01:00
|
|
|
@@ -44,36 +44,35 @@
|
|
|
|
|
#include "qmljsglobal_p.h"
|
|
|
|
|
#include "qmljsastfwd_p.h"
|
|
|
|
|
#include "qmljsmemorypool_p.h"
|
|
|
|
|
+#include <qmljs/qmljsconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QSet>
|
|
|
|
|
|
|
|
|
|
-#include <qmljs/qmljsconstants.h>
|
|
|
|
|
QT_QML_BEGIN_NAMESPACE
|
|
|
|
|
|
2011-12-07 11:21:10 +01:00
|
|
|
namespace QmlJS {
|
|
|
|
|
|
|
|
|
|
class Lexer;
|
|
|
|
|
+class Directives;
|
|
|
|
|
class MemoryPool;
|
|
|
|
|
|
|
|
|
|
class QML_PARSER_EXPORT DiagnosticMessage
|
2014-01-15 00:18:53 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
- enum Kind { Warning, Error };
|
|
|
|
|
-
|
|
|
|
|
DiagnosticMessage()
|
|
|
|
|
- : kind(Error) {}
|
|
|
|
|
+ : kind(Severity::Error) {}
|
|
|
|
|
|
|
|
|
|
- DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
|
|
|
|
|
+ DiagnosticMessage(Severity::Enum kind, const AST::SourceLocation &loc, const QString &message)
|
|
|
|
|
: kind(kind), loc(loc), message(message) {}
|
|
|
|
|
|
|
|
|
|
bool isWarning() const
|
|
|
|
|
- { return kind == Warning; }
|
|
|
|
|
+ { return kind == Severity::Warning; }
|
|
|
|
|
|
|
|
|
|
bool isError() const
|
|
|
|
|
- { return kind == Error; }
|
|
|
|
|
+ { return kind == Severity::Error; }
|
|
|
|
|
|
|
|
|
|
- Kind kind;
|
|
|
|
|
+ Severity::Enum kind;
|
|
|
|
|
AST::SourceLocation loc;
|
|
|
|
|
QString message;
|
|
|
|
|
};
|
|
|
|
|
@@ -81,6 +80,7 @@ public:
|
2011-12-07 11:21:10 +01:00
|
|
|
class QML_PARSER_EXPORT Engine
|
|
|
|
|
{
|
|
|
|
|
Lexer *_lexer;
|
|
|
|
|
+ Directives *_directives;
|
|
|
|
|
MemoryPool _pool;
|
|
|
|
|
QList<AST::SourceLocation> _comments;
|
|
|
|
|
QString _extraCode;
|
2014-01-15 00:18:53 +01:00
|
|
|
@@ -99,6 +99,9 @@ public:
|
2011-12-07 11:21:10 +01:00
|
|
|
Lexer *lexer() const;
|
|
|
|
|
void setLexer(Lexer *lexer);
|
|
|
|
|
|
|
|
|
|
+ void setDirectives(Directives *directives);
|
|
|
|
|
+ Directives *directives() const;
|
|
|
|
|
+
|
|
|
|
|
MemoryPool *pool();
|
|
|
|
|
|
|
|
|
|
inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
|
2014-01-15 00:18:53 +01:00
|
|
|
diff --git a/src/libs/qmljs/parser/qmljslexer.cpp b/src/libs/qmljs/parser/qmljslexer.cpp
|
|
|
|
|
index 9698e9d..036be75 100644
|
|
|
|
|
--- a/src/libs/qmljs/parser/qmljslexer.cpp
|
|
|
|
|
+++ b/src/libs/qmljs/parser/qmljslexer.cpp
|
|
|
|
|
@@ -345,7 +345,7 @@ static inline bool isIdentifierStart(QChar ch)
|
|
|
|
|
// fast path for ascii
|
|
|
|
|
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
|
|
|
|
|
(ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
|
|
|
|
|
- ch == '$' || ch == '_')
|
|
|
|
|
+ ch == QLatin1Char('$') || ch == QLatin1Char('_'))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
switch (ch.category()) {
|
|
|
|
|
@@ -368,7 +368,7 @@ static bool isIdentifierPart(QChar ch)
|
|
|
|
|
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
|
|
|
|
|
(ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
|
|
|
|
|
(ch.unicode() >= '0' && ch.unicode() <= '9') ||
|
|
|
|
|
- ch == '$' || ch == '_' ||
|
|
|
|
|
+ ch == QLatin1Char('$') || ch == QLatin1Char('_') ||
|
|
|
|
|
ch.unicode() == 0x200c /* ZWNJ */ || ch.unicode() == 0x200d /* ZWJ */)
|
|
|
|
|
return true;
|
|
|
|
|
|
2013-01-22 11:15:23 +01:00
|
|
|
diff --git a/src/libs/qmljs/parser/qmljsparser.cpp b/src/libs/qmljs/parser/qmljsparser.cpp
|
2014-01-15 00:18:53 +01:00
|
|
|
index 6e61637..e016b91 100644
|
2013-01-22 11:15:23 +01:00
|
|
|
--- a/src/libs/qmljs/parser/qmljsparser.cpp
|
|
|
|
|
+++ b/src/libs/qmljs/parser/qmljsparser.cpp
|
2014-01-15 00:18:53 +01:00
|
|
|
@@ -157,7 +157,20 @@ bool Parser::parse(int startToken)
|
2011-12-07 11:21:10 +01:00
|
|
|
|
|
|
|
|
token_buffer[0].token = startToken;
|
|
|
|
|
first_token = &token_buffer[0];
|
|
|
|
|
- last_token = &token_buffer[1];
|
|
|
|
|
+ if (startToken == T_FEED_JS_PROGRAM) {
|
|
|
|
|
+ Directives ignoreDirectives;
|
|
|
|
|
+ Directives *directives = driver->directives();
|
|
|
|
|
+ if (!directives)
|
|
|
|
|
+ directives = &ignoreDirectives;
|
|
|
|
|
+ lexer->scanDirectives(directives);
|
|
|
|
|
+ token_buffer[1].token = lexer->tokenKind();
|
|
|
|
|
+ token_buffer[1].dval = lexer->tokenValue();
|
|
|
|
|
+ token_buffer[1].loc = location(lexer);
|
|
|
|
|
+ token_buffer[1].spell = lexer->tokenSpell();
|
|
|
|
|
+ last_token = &token_buffer[2];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ last_token = &token_buffer[1];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
tos = -1;
|
|
|
|
|
program = 0;
|