diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-10 15:48:50 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-13 09:55:25 +0200 |
commit | 540134d66dd0a235ace91ddc28940d2d88c24ac3 (patch) | |
tree | fa5499e63a0a84f3c5dda91e463eb8db47d88ea0 /src/qml/compiler | |
parent | e9852df2d7c1064c95ff4c4463587ad713e68334 (diff) |
Move valueAsNumber into ExecutableCompilationUnit
This reduces our dependence on QV4::Value in the devtools.
Change-Id: I4b3f937bc08c16f7e2543fdc5cc34c0cfb121f8f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qqmlpropertyvalidator.cpp | 6 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 8 | ||||
-rw-r--r-- | src/qml/compiler/qv4executablecompilationunit.cpp | 2 | ||||
-rw-r--r-- | src/qml/compiler/qv4executablecompilationunit_p.h | 6 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 1 |
5 files changed, 10 insertions, 13 deletions
diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp index 5b0bd8858a..71d5318652 100644 --- a/src/qml/compiler/qqmlpropertyvalidator.cpp +++ b/src/qml/compiler/qqmlpropertyvalidator.cpp @@ -397,7 +397,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache break; case QVariant::UInt: { if (binding->type == QV4::CompiledData::Binding::Type_Number) { - double d = binding->valueAsNumber(compilationUnit->constants); + double d = compilationUnit->bindingValueAsNumber(binding); if (double(uint(d)) == d) return noError; } @@ -406,7 +406,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache break; case QVariant::Int: { if (binding->type == QV4::CompiledData::Binding::Type_Number) { - double d = binding->valueAsNumber(compilationUnit->constants); + double d = compilationUnit->bindingValueAsNumber(binding); if (double(int(d)) == d) return noError; } @@ -571,7 +571,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache } else if (property->propType() == qMetaTypeId<QList<int> >()) { bool ok = (binding->type == QV4::CompiledData::Binding::Type_Number); if (ok) { - double n = binding->valueAsNumber(compilationUnit->constants); + double n = compilationUnit->bindingValueAsNumber(binding); if (double(int(n)) != n) ok = false; } diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 629adf8231..94b64694ae 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -57,7 +57,6 @@ #include <QHash> #include <QUrl> -#include <private/qv4value_p.h> #include <private/qv4executableallocator_p.h> #include <private/qqmlrefcount_p.h> #include <private/qqmlnullablevalue_p.h> @@ -522,13 +521,6 @@ struct Q_QML_PRIVATE_EXPORT Binding bool isTranslationBinding() const { return type == Type_Translation || type == Type_TranslationById; } bool evaluatesToString() const { return type == Type_String || isTranslationBinding(); } - double valueAsNumber(const Value *constantTable) const - { - if (type != Type_Number) - return 0.0; - return constantTable[value.constantValueIndex].doubleValue(); - } - bool valueAsBoolean() const { if (type == Type_Boolean) diff --git a/src/qml/compiler/qv4executablecompilationunit.cpp b/src/qml/compiler/qv4executablecompilationunit.cpp index 88e5c1dc0e..97c828d4d8 100644 --- a/src/qml/compiler/qv4executablecompilationunit.cpp +++ b/src/qml/compiler/qv4executablecompilationunit.cpp @@ -760,7 +760,7 @@ QString ExecutableCompilationUnit::bindingValueAsString(const CompiledData::Bind case Binding::Type_Boolean: return binding->value.b ? QStringLiteral("true") : QStringLiteral("false"); case Binding::Type_Number: - return QString::number(binding->valueAsNumber(constants)); + return QString::number(bindingValueAsNumber(binding)); case Binding::Type_Invalid: return QString(); #if !QT_CONFIG(translation) diff --git a/src/qml/compiler/qv4executablecompilationunit_p.h b/src/qml/compiler/qv4executablecompilationunit_p.h index dd3918cc84..4e3aadf28a 100644 --- a/src/qml/compiler/qv4executablecompilationunit_p.h +++ b/src/qml/compiler/qv4executablecompilationunit_p.h @@ -244,6 +244,12 @@ public: QString bindingValueAsString(const CompiledData::Binding *binding) const; QString bindingValueAsScriptString(const CompiledData::Binding *binding) const; + double bindingValueAsNumber(const CompiledData::Binding *binding) const + { + if (binding->type != CompiledData::Binding::Type_Number) + return 0.0; + return constants[binding->value.constantValueIndex].doubleValue(); + } protected: quint32 totalStringCount() const diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index e517c6d8b9..5338583164 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -51,7 +51,6 @@ // We mean it. // #include <private/qv4global_p.h> -#include <private/qv4value_p.h> #include <private/qv4runtime_p.h> #include <private/qv4compileddata_p.h> // for CompiledData::CodeOffsetToLine used by the dumper #include <qendian.h> |