summaryrefslogtreecommitdiff
path: root/src/qml/compiler/qv4codegen.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-11 11:07:32 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-17 07:47:09 +0000
commit1dac47c1418b44cf4a56b42bfca2b277795fd213 (patch)
tree26727943c30628340662a66d7cbe9f52d75c5b58 /src/qml/compiler/qv4codegen.cpp
parentd89d5cffe79bd060a1b04a2c47a3d728bffbe195 (diff)
downloadqtdeclarative-1dac47c1418b44cf4a56b42bfca2b277795fd213.tar.gz
Cleanups in Value/Primitive
Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r--src/qml/compiler/qv4codegen.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 5c91b51b91..8709e3fff8 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -968,7 +968,7 @@ bool Codegen::visit(ClassExpression *ast)
return false;
r.storeOnStack(heritage.stackSlot());
} else {
- Reference::fromConst(this, Primitive::emptyValue().asReturnedValue()).loadInAccumulator();
+ Reference::fromConst(this, Value::emptyValue().asReturnedValue()).loadInAccumulator();
heritage.storeConsumeAccumulator();
}
@@ -1040,7 +1040,7 @@ bool Codegen::visit(ArrayPattern *ast)
if (args == -1)
args = temp;
if (!arg) {
- auto c = Reference::fromConst(this, Primitive::emptyValue().asReturnedValue());
+ auto c = Reference::fromConst(this, Value::emptyValue().asReturnedValue());
(void) c.storeOnStack(temp);
} else {
RegisterScope scope(this);
@@ -1101,7 +1101,7 @@ bool Codegen::visit(ArrayPattern *ast)
while (it) {
for (Elision *elision = it->elision; elision; elision = elision->next) {
- Reference::fromConst(this, Primitive::emptyValue().asReturnedValue()).loadInAccumulator();
+ Reference::fromConst(this, Value::emptyValue().asReturnedValue()).loadInAccumulator();
pushAccumulator();
}
@@ -1485,9 +1485,9 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
}
case QSOperator::BitAnd:
if (right.isConstant()) {
- int rightAsInt = Primitive::fromReturnedValue(right.constant).toInt32();
+ int rightAsInt = Value::fromReturnedValue(right.constant).toInt32();
if (left.isConstant()) {
- int result = Primitive::fromReturnedValue(left.constant).toInt32() & rightAsInt;
+ int result = Value::fromReturnedValue(left.constant).toInt32() & rightAsInt;
return Reference::fromConst(this, Encode(result));
}
left.loadInAccumulator();
@@ -1503,9 +1503,9 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
break;
case QSOperator::BitOr:
if (right.isConstant()) {
- int rightAsInt = Primitive::fromReturnedValue(right.constant).toInt32();
+ int rightAsInt = Value::fromReturnedValue(right.constant).toInt32();
if (left.isConstant()) {
- int result = Primitive::fromReturnedValue(left.constant).toInt32() | rightAsInt;
+ int result = Value::fromReturnedValue(left.constant).toInt32() | rightAsInt;
return Reference::fromConst(this, Encode(result));
}
left.loadInAccumulator();
@@ -1521,9 +1521,9 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
break;
case QSOperator::BitXor:
if (right.isConstant()) {
- int rightAsInt = Primitive::fromReturnedValue(right.constant).toInt32();
+ int rightAsInt = Value::fromReturnedValue(right.constant).toInt32();
if (left.isConstant()) {
- int result = Primitive::fromReturnedValue(left.constant).toInt32() ^ rightAsInt;
+ int result = Value::fromReturnedValue(left.constant).toInt32() ^ rightAsInt;
return Reference::fromConst(this, Encode(result));
}
left.loadInAccumulator();
@@ -1541,7 +1541,7 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
if (right.isConstant()) {
left.loadInAccumulator();
Instruction::UShrConst ushr;
- ushr.rhs = Primitive::fromReturnedValue(right.constant).toInt32() & 0x1f;
+ ushr.rhs = Value::fromReturnedValue(right.constant).toInt32() & 0x1f;
bytecodeGenerator->addInstruction(ushr);
} else {
right.loadInAccumulator();
@@ -1554,7 +1554,7 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
if (right.isConstant()) {
left.loadInAccumulator();
Instruction::ShrConst shr;
- shr.rhs = Primitive::fromReturnedValue(right.constant).toInt32() & 0x1f;
+ shr.rhs = Value::fromReturnedValue(right.constant).toInt32() & 0x1f;
bytecodeGenerator->addInstruction(shr);
} else {
right.loadInAccumulator();
@@ -1567,7 +1567,7 @@ Codegen::Reference Codegen::binopHelper(QSOperator::Op oper, Reference &left, Re
if (right.isConstant()) {
left.loadInAccumulator();
Instruction::ShlConst shl;
- shl.rhs = Primitive::fromReturnedValue(right.constant).toInt32() & 0x1f;
+ shl.rhs = Value::fromReturnedValue(right.constant).toInt32() & 0x1f;
bytecodeGenerator->addInstruction(shl);
} else {
right.loadInAccumulator();
@@ -1709,7 +1709,7 @@ Codegen::Reference Codegen::jumpBinop(QSOperator::Op oper, Reference &left, Refe
}
if (right.isConstant() && (oper == QSOperator::Equal || oper == QSOperator::NotEqual)) {
- Value c = Primitive::fromReturnedValue(right.constant);
+ Value c = Value::fromReturnedValue(right.constant);
if (c.isNull() || c.isUndefined()) {
left.loadInAccumulator();
if (oper == QSOperator::Equal) {
@@ -1979,7 +1979,7 @@ Codegen::Arguments Codegen::pushArgs(ArgumentList *args)
argc = 0;
for (ArgumentList *it = args; it; it = it->next) {
if (it->isSpreadElement) {
- Reference::fromConst(this, Primitive::emptyValue().asReturnedValue()).storeOnStack(calldata + argc);
+ Reference::fromConst(this, Value::emptyValue().asReturnedValue()).storeOnStack(calldata + argc);
++argc;
}
RegisterScope scope(this);
@@ -4279,7 +4279,7 @@ QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty str
Instruction::LoadUndefined load;
codegen->bytecodeGenerator->addInstruction(load);
} else {
- Value p = Primitive::fromReturnedValue(constant);
+ Value p = Value::fromReturnedValue(constant);
if (p.isNumber()) {
double d = p.asDouble();
int i = static_cast<int>(d);
@@ -4290,7 +4290,7 @@ QT_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // the loads below are empty str
return;
}
Instruction::LoadInt load;
- load.value = Primitive::fromReturnedValue(constant).toInt32();
+ load.value = Value::fromReturnedValue(constant).toInt32();
codegen->bytecodeGenerator->addInstruction(load);
return;
}