aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-30 15:34:12 +0200
committerLars Knoll <lars.knoll@qt.io>2017-07-03 06:09:13 +0000
commitbac9b54dfb38767a34410fa55f8f46e64b458efb (patch)
tree800905c8112b465b1ded26f100b1abc7f7f17c68 /src/qml/jsruntime
parentf4804726c30279c54b0e9354305506458b9a0c76 (diff)
Split up qv4codegen into several files
And changed the namespace of those classes to QV4::Compiler. ScanFunctions should over time also move into its own file. Change-Id: If084acea4a9a20b9c79ad47dac19e02dc720e098 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp7
-rw-r--r--src/qml/jsruntime/qv4global_p.h16
-rw-r--r--src/qml/jsruntime/qv4script.cpp28
-rw-r--r--src/qml/jsruntime/qv4script_p.h6
4 files changed, 23 insertions, 34 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 992701d0fb..fbce1e0cda 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -210,17 +210,16 @@ void FunctionCtor::construct(const Managed *that, Scope &scope, CallData *callDa
return;
}
- using namespace QQmlJS::AST;
- FunctionExpression *fe = QQmlJS::AST::cast<FunctionExpression *>(parser.rootNode());
+ QQmlJS::AST::FunctionExpression *fe = QQmlJS::AST::cast<QQmlJS::AST::FunctionExpression *>(parser.rootNode());
if (!fe) {
scope.result = scope.engine->throwSyntaxError(QLatin1String("Parse error"));
return;
}
- QQmlJS::Module module(scope.engine->debugger() != 0);
+ Compiler::Module module(scope.engine->debugger() != 0);
Compiler::JSUnitGenerator jsGenerator(&module);
- QQmlJS::RuntimeCodegen cg(scope.engine, &jsGenerator, f->strictMode());
+ Compiler::RuntimeCodegen cg(scope.engine, &jsGenerator, f->strictMode());
cg.generateFromFunctionExpression(QString(), function, fe, &module);
QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit = cg.generateCompilationUnit();
diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h
index ab7ee17e68..549cf66e24 100644
--- a/src/qml/jsruntime/qv4global_p.h
+++ b/src/qml/jsruntime/qv4global_p.h
@@ -147,13 +147,15 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); }
#endif
QT_BEGIN_NAMESPACE
-namespace QQmlJS {
+
+namespace QV4 {
+
+namespace Compiler {
struct Module;
struct Context;
+ struct JSUnitGenerator;
}
-namespace QV4 {
-
namespace Heap {
struct Base;
struct MemberData;
@@ -188,14 +190,6 @@ namespace Heap {
template <typename T, size_t> struct Pointer;
}
-namespace IR {
-struct Function;
-struct Module;
-}
-namespace Compiler {
-struct JSUnitGenerator;
-}
-
class MemoryManager;
class ExecutableAllocator;
struct String;
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 68ed07b214..0370531579 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -80,16 +80,16 @@ void Script::parse()
if (parsed)
return;
- using namespace QQmlJS;
+ using namespace QV4::Compiler;
parsed = true;
ExecutionEngine *v4 = scope->engine();
Scope valueScope(v4);
- QQmlJS::Module module(v4->debugger() != 0);
+ Module module(v4->debugger() != 0);
- QQmlJS::Engine ee, *engine = &ee;
+ Engine ee, *engine = &ee;
Lexer lexer(engine);
lexer.setCode(sourceCode, line, parseAsBinding);
Parser parser(engine);
@@ -97,7 +97,7 @@ void Script::parse()
const bool parsed = parser.parseProgram();
const auto diagnosticMessages = parser.diagnosticMessages();
- for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
+ for (const DiagnosticMessage &m : diagnosticMessages) {
if (m.isError()) {
valueScope.engine->throwSyntaxError(m.message, sourceFile, m.loc.startLine, m.loc.startColumn);
return;
@@ -120,7 +120,7 @@ void Script::parse()
RuntimeCodegen cg(v4, &jsGenerator, strictMode);
if (inheritContext)
cg.setUseFastLookups(false);
- cg.generateFromProgram(sourceFile, sourceCode, program, &module, QQmlJS::EvalCode);
+ cg.generateFromProgram(sourceFile, sourceCode, program, &module, EvalCode);
if (v4->hasException)
return;
@@ -175,26 +175,26 @@ Function *Script::function()
return vmFunction;
}
-QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QQmlJS::Module *module, Compiler::JSUnitGenerator *unitGenerator,
+QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QV4::Compiler::Module *module, Compiler::JSUnitGenerator *unitGenerator,
const QUrl &url, const QString &source, QList<QQmlError> *reportedErrors,
- QQmlJS::Directives *directivesCollector)
+ Directives *directivesCollector)
{
- using namespace QQmlJS;
+ using namespace QV4::Compiler;
using namespace QQmlJS::AST;
- QQmlJS::Engine ee;
+ Engine ee;
if (directivesCollector)
ee.setDirectives(directivesCollector);
- QQmlJS::Lexer lexer(&ee);
+ Lexer lexer(&ee);
lexer.setCode(source, /*line*/1, /*qml mode*/false);
- QQmlJS::Parser parser(&ee);
+ Parser parser(&ee);
parser.parseProgram();
QList<QQmlError> errors;
const auto diagnosticMessages = parser.diagnosticMessages();
- for (const QQmlJS::DiagnosticMessage &m : diagnosticMessages) {
+ for (const DiagnosticMessage &m : diagnosticMessages) {
if (m.isWarning()) {
qWarning("%s:%d : %s", qPrintable(url.toString()), m.loc.startLine, qPrintable(m.message));
continue;
@@ -221,9 +221,9 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(QQmlJS::Mo
return 0;
}
- QQmlJS::Codegen cg(unitGenerator, /*strict mode*/false);
+ Codegen cg(unitGenerator, /*strict mode*/false);
cg.setUseFastLookups(false);
- cg.generateFromProgram(url.toString(), source, program, module, QQmlJS::EvalCode);
+ cg.generateFromProgram(url.toString(), source, program, module, EvalCode);
errors = cg.qmlErrors();
if (!errors.isEmpty()) {
if (reportedErrors)
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index 760dad0060..75045dda9c 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -61,10 +61,6 @@ QT_BEGIN_NAMESPACE
class QQmlContextData;
-namespace QQmlJS {
-class Directives;
-}
-
namespace QV4 {
struct ContextStateSaver {
@@ -139,7 +135,7 @@ struct Q_QML_EXPORT Script {
Function *function();
- static QQmlRefPointer<CompiledData::CompilationUnit> precompile(QQmlJS::Module *module, Compiler::JSUnitGenerator *unitGenerator, const QUrl &url, const QString &source,
+ static QQmlRefPointer<CompiledData::CompilationUnit> precompile(QV4::Compiler::Module *module, Compiler::JSUnitGenerator *unitGenerator, const QUrl &url, const QString &source,
QList<QQmlError> *reportedErrors = 0, QQmlJS::Directives *directivesCollector = 0);
static ReturnedValue evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext);