aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljs.g19
-rw-r--r--src/qml/parser/qqmljsast_p.h8
-rw-r--r--src/qml/parser/qqmljsglobal_p.h11
-rw-r--r--src/qml/parser/qqmljsmemorypool_p.h24
4 files changed, 34 insertions, 28 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 71b6978983..96b2b24298 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -506,7 +506,24 @@ bool Parser::parse(int startToken)
token_buffer[0].token = startToken;
first_token = &token_buffer[0];
- last_token = &token_buffer[1];
+ if (startToken == T_FEED_JS_PROGRAM && !lexer->qmlMode()) {
+ Directives ignoreDirectives;
+ Directives *directives = driver->directives();
+ if (!directives)
+ directives = &ignoreDirectives;
+ DiagnosticMessage error;
+ if (!lexer->scanDirectives(directives, &error)) {
+ diagnostic_messages.append(error);
+ return false;
+ }
+ 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;
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index fa6b5d2488..3987f6093a 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -103,11 +103,11 @@ namespace QQmlJS {
namespace AST {
-template <typename _T1, typename _T2>
-_T1 cast(_T2 *ast)
+template <typename T1, typename T2>
+T1 cast(T2 *ast)
{
- if (ast && ast->kind == static_cast<_T1>(0)->K)
- return static_cast<_T1>(ast);
+ if (ast && ast->kind == static_cast<T1>(0)->K)
+ return static_cast<T1>(ast);
return 0;
}
diff --git a/src/qml/parser/qqmljsglobal_p.h b/src/qml/parser/qqmljsglobal_p.h
index fe2cbe7d1d..48ba2b034b 100644
--- a/src/qml/parser/qqmljsglobal_p.h
+++ b/src/qml/parser/qqmljsglobal_p.h
@@ -33,6 +33,17 @@
#ifndef QQMLJSGLOBAL_P_H
#define QQMLJSGLOBAL_P_H
+//
+// 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 <QtCore/qglobal.h>
#ifdef QT_CREATOR
diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h
index 16927251c7..ae9f1d8257 100644
--- a/src/qml/parser/qqmljsmemorypool_p.h
+++ b/src/qml/parser/qqmljsmemorypool_p.h
@@ -102,29 +102,7 @@ public:
_ptr = _end = 0;
}
- template <typename _Tp> _Tp *New() { return new (this->allocate(sizeof(_Tp))) _Tp(); }
-
- template <typename PoolContentType, typename Visitor>
- void visitManagedPool(Visitor &visitor)
- {
- for (int i = 0; i <= _blockCount; ++i) {
- char *p = _blocks[i];
- char *end = p + BLOCK_SIZE;
- if (i == _blockCount) {
- Q_ASSERT(_ptr <= end);
- end = _ptr;
- }
-
- Q_ASSERT(p <= end);
-
- const qptrdiff increment = (sizeof(PoolContentType) + 7) & ~7;
-
- while (p + increment <= end) {
- visitor(reinterpret_cast<PoolContentType*>(p));
- p += increment;
- }
- }
- }
+ template <typename Tp> Tp *New() { return new (this->allocate(sizeof(Tp))) Tp(); }
private:
void *allocate_helper(size_t size)