summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/parser/javascriptengine_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/parser/javascriptengine_p.h')
-rw-r--r--src/declarative/qml/parser/javascriptengine_p.h125
1 files changed, 63 insertions, 62 deletions
diff --git a/src/declarative/qml/parser/javascriptengine_p.h b/src/declarative/qml/parser/javascriptengine_p.h
index 1e6e568..3bd924a 100644
--- a/src/declarative/qml/parser/javascriptengine_p.h
+++ b/src/declarative/qml/parser/javascriptengine_p.h
@@ -30,23 +30,50 @@
#ifndef JAVASCRIPTENGINE_P_H
#define JAVASCRIPTENGINE_P_H
-#include "javascriptvalue.h"
#include <QString>
#include <QSet>
+#include "javascriptastfwd_p.h"
+
QT_BEGIN_NAMESPACE
namespace JavaScript {
+class NameId
+{
+ QString _text;
-class Node;
-class Lexer;
-class NodePool;
+public:
+ NameId(const QChar *u, int s)
+ : _text(u, s)
+ { }
-namespace AST {
+ const QString asString() const
+ { return _text; }
-class Node;
+ bool operator == (const NameId &other) const
+ { return _text == other._text; }
-} // end of namespace AST
+ bool operator != (const NameId &other) const
+ { return _text != other._text; }
+
+ bool operator < (const NameId &other) const
+ { return _text < other._text; }
+};
+
+uint qHash(const JavaScript::NameId &id);
+
+} // end of namespace JavaScript
+
+#if defined(Q_CC_MSVC) && _MSC_VER <= 1300
+//this ensures that code outside JavaScript can use the hash function
+//it also a workaround for some compilers
+inline uint qHash(const JavaScript::NameId &nameId) { return JavaScript::qHash(nameId); }
+#endif
+
+namespace JavaScript {
+
+class Lexer;
+class NodePool;
namespace Ecma {
@@ -66,79 +93,53 @@ public:
} // end of namespace Ecma
-} // end of namespace JavaScript
-
-
-
-class JavaScriptNameIdImpl
+class DiagnosticMessage
{
- QString _text;
-
public:
- JavaScriptNameIdImpl(const QChar *u, int s)
- : _text(u, s)
- { }
+ enum Kind { Warning, Error };
- const QString asString() const
- { return _text; }
+ DiagnosticMessage()
+ : kind(Error) {}
- bool operator == (const JavaScriptNameIdImpl &other) const
- { return _text == other._text; }
+ DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message)
+ : kind(kind), loc(loc), message(message) {}
- bool operator != (const JavaScriptNameIdImpl &other) const
- { return _text != other._text; }
+ bool isWarning() const
+ { return kind == Warning; }
- bool operator < (const JavaScriptNameIdImpl &other) const
- { return _text < other._text; }
-};
+ bool isError() const
+ { return kind == Error; }
-inline uint qHash(const JavaScriptNameIdImpl &id)
-{ return qHash(id.asString()); }
+ Kind kind;
+ AST::SourceLocation loc;
+ QString message;
+};
-class JavaScriptEnginePrivate
+class Engine
{
- JavaScript::Lexer *_lexer;
- JavaScript::NodePool *_nodePool;
- JavaScript::AST::Node *_ast;
- QSet<JavaScriptNameIdImpl> _literals;
+ Lexer *_lexer;
+ NodePool *_nodePool;
+ QSet<NameId> _literals;
public:
- JavaScriptEnginePrivate()
- : _lexer(0), _nodePool(0), _ast(0)
- { }
-
- QSet<JavaScriptNameIdImpl> literals() const
- { return _literals; }
+ Engine();
+ ~Engine();
- JavaScriptNameIdImpl *intern(const QChar *u, int s)
- { return const_cast<JavaScriptNameIdImpl *>(&*_literals.insert(JavaScriptNameIdImpl(u, s))); }
+ QSet<NameId> literals() const;
- static QString toString(JavaScriptNameIdImpl *id)
- { return id->asString(); }
+ NameId *intern(const QChar *u, int s);
- JavaScript::Lexer *lexer() const
- { return _lexer; }
+ static QString toString(NameId *id);
- void setLexer(JavaScript::Lexer *lexer)
- { _lexer = lexer; }
+ Lexer *lexer() const;
+ void setLexer(Lexer *lexer);
- JavaScript::NodePool *nodePool() const
- { return _nodePool; }
-
- void setNodePool(JavaScript::NodePool *nodePool)
- { _nodePool = nodePool; }
-
- JavaScript::AST::Node *ast() const
- { return _ast; }
-
- JavaScript::AST::Node *changeAbstractSyntaxTree(JavaScript::AST::Node *node)
- {
- JavaScript::AST::Node *previousAST = _ast;
- _ast = node;
- return previousAST;
- }
+ NodePool *nodePool() const;
+ void setNodePool(NodePool *nodePool);
};
+} // end of namespace JavaScript
+
QT_END_NAMESPACE
#endif // JAVASCRIPTENGINE_P_H