aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compiler.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-12 10:27:54 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-06-19 12:50:37 +0000
commit56f29d005c2c6eb028e3ed2d1ef8edd6d03d1403 (patch)
treee8a2503ba9f50c7797e16eeb96e444617b54ec18 /src/qml/compiler/qv4compiler.cpp
parent6f2bdb816dc816461cf3888eb732f71904b6a7ab (diff)
Pass the JSUnitGenerator into the codegen
Allow registering all the required data to generate the proper compilationunit already in the codegenerator. Change-Id: I36345cc01927b3f8dc3ba6d91da175bd6abe124a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r--src/qml/compiler/qv4compiler.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index f7e63437e1..6ef3d10780 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -43,6 +43,8 @@
#include <private/qv4string_p.h>
#include <private/qv4value_p.h>
#include <private/qv4alloca_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsast_p.h>
#include <wtf/MathExtras.h>
#include <QCryptographicHash>
@@ -168,6 +170,23 @@ int QV4::Compiler::JSUnitGenerator::registerRegExp(QV4::IR::RegExp *regexp)
return regexps.size() - 1;
}
+int QV4::Compiler::JSUnitGenerator::registerRegExp(QQmlJS::AST::RegExpLiteral *regexp)
+{
+ CompiledData::RegExp re;
+ re.stringIndex = registerString(regexp->pattern.toString());
+
+ re.flags = 0;
+ if (regexp->flags & QQmlJS::Lexer::RegExp_Global)
+ re.flags |= CompiledData::RegExp::RegExp_Global;
+ if (regexp->flags & QQmlJS::Lexer::RegExp_IgnoreCase)
+ re.flags |= CompiledData::RegExp::RegExp_IgnoreCase;
+ if (regexp->flags & QQmlJS::Lexer::RegExp_Multiline)
+ re.flags |= CompiledData::RegExp::RegExp_Multiline;
+
+ regexps.append(re);
+ return regexps.size() - 1;
+}
+
int QV4::Compiler::JSUnitGenerator::registerConstant(QV4::ReturnedValue v)
{
int idx = constants.indexOf(v);
@@ -209,6 +228,22 @@ int QV4::Compiler::JSUnitGenerator::registerJSClass(int count, IR::ExprList *arg
return jsClassOffsets.size() - 1;
}
+int QV4::Compiler::JSUnitGenerator::registerJSClass(int count, CompiledData::JSClassMember *members)
+{
+ const int size = CompiledData::JSClass::calculateSize(count);
+ jsClassOffsets.append(jsClassData.size());
+ const int oldSize = jsClassData.size();
+ jsClassData.resize(jsClassData.size() + size);
+ memset(jsClassData.data() + oldSize, 0, size);
+
+ CompiledData::JSClass *jsClass = reinterpret_cast<CompiledData::JSClass*>(jsClassData.data() + oldSize);
+ jsClass->nMembers = count;
+ CompiledData::JSClassMember *jsClassMembers = reinterpret_cast<CompiledData::JSClassMember*>(jsClass + 1);
+ memcpy(jsClassMembers, members, sizeof(CompiledData::JSClassMember)*count);
+
+ return jsClassOffsets.size() - 1;
+}
+
QV4::CompiledData::Unit *QV4::Compiler::JSUnitGenerator::generateUnit(GeneratorOption option)
{
registerString(irModule->fileName);