aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-18 15:36:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-20 21:11:54 +0200
commitb93ddb95a74fff4bc61073b6b04e9dd7a7dc7f36 (patch)
tree5a3a1d29d2232fd10f5d9ffa3584e0ee22eab456 /src/qml/compiler
parent6b2b62e903e1207255b0652b728ecaee6d51aea9 (diff)
Qml JavaScript code generation cleanups
* Run the binding expressions, functions and signal handlers through the V4 codegen _per_ component, and run the isel at the end for the entire file. We need to do per-component codegen because we want to set up the correct id and object scopes, which are different for the root component and anonymous components. * Changed V4IR::Module to allow for the concept of "qml modules" where there is no root function defined. This is a logical consequence of running v4 codegen multiple times with different input but the same V4IR::Module. Change-Id: Ib3a719f83507cbab7c2e4e145ccad5b663c795cf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp5
-rw-r--r--src/qml/compiler/qv4compileddata_p.h2
-rw-r--r--src/qml/compiler/qv4compiler.cpp1
-rw-r--r--src/qml/compiler/qv4isel_p.cpp3
-rw-r--r--src/qml/compiler/qv4jsir.cpp6
-rw-r--r--src/qml/compiler/qv4jsir_p.h6
6 files changed, 15 insertions, 8 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 887edc0b10..b485dcc240 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -140,7 +140,10 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
std::sort(runtimeFunctionsSortedByAddress.begin(), runtimeFunctionsSortedByAddress.end(), functionSortHelper);
#endif
- return runtimeFunctions[data->indexOfRootFunction];
+ if (data->indexOfRootFunction != -1)
+ return runtimeFunctions[data->indexOfRootFunction];
+ else
+ return 0;
}
void CompilationUnit::unlink()
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 6784707607..bf6794e182 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -161,7 +161,7 @@ struct Unit
uint offsetToRegexpTable;
uint jsClassTableSize;
uint offsetToJSClassTable;
- uint indexOfRootFunction;
+ qint32 indexOfRootFunction;
quint32 sourceFileIndex;
QString stringAt(int idx) const {
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 8cd4c8e2d8..7d8c188927 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -198,6 +198,7 @@ QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(int *total
unit->offsetToRegexpTable = unit->offsetToLookupTable + unit->lookupTableSize * CompiledData::Lookup::calculateSize();
unit->jsClassTableSize = jsClasses.count();
unit->offsetToJSClassTable = unit->offsetToRegexpTable + unit->regexpTableSize * CompiledData::RegExp::calculateSize();
+ unit->indexOfRootFunction = -1;
unit->sourceFileIndex = getStringId(irModule->fileName);
// write strings and string table
diff --git a/src/qml/compiler/qv4isel_p.cpp b/src/qml/compiler/qv4isel_p.cpp
index 500c2bd26f..483cb8e6f9 100644
--- a/src/qml/compiler/qv4isel_p.cpp
+++ b/src/qml/compiler/qv4isel_p.cpp
@@ -80,9 +80,6 @@ EvalISelFactory::~EvalISelFactory()
QV4::CompiledData::CompilationUnit *EvalInstructionSelection::compile(bool generateUnitData)
{
- Function *rootFunction = irModule->rootFunction;
- if (!rootFunction)
- return 0;
for (int i = 0; i < irModule->functions.size(); ++i)
run(i);
diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp
index 869bf4acaf..50afcf29c2 100644
--- a/src/qml/compiler/qv4jsir.cpp
+++ b/src/qml/compiler/qv4jsir.cpp
@@ -610,8 +610,10 @@ Function *Module::newFunction(const QString &name, Function *outer)
Function *f = new Function(this, outer, name);
functions.append(f);
if (!outer) {
- assert(!rootFunction);
- rootFunction = f;
+ if (!isQmlModule) {
+ assert(!rootFunction);
+ rootFunction = f;
+ }
} else {
outer->nestedFunctions.append(f);
}
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index d0782a3a43..7b0ee52737 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -682,10 +682,14 @@ struct Q_QML_EXPORT Module {
QVector<Function *> functions;
Function *rootFunction;
QString fileName;
+ bool isQmlModule; // implies rootFunction is always 0
Function *newFunction(const QString &name, Function *outer);
- Module() : rootFunction(0) {}
+ Module()
+ : rootFunction(0)
+ , isQmlModule(false)
+ {}
~Module();
void setFileName(const QString &name);