aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4errorobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-08-29 14:31:32 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-02 17:27:36 +0200
commitedee5c3dc0d922ec3b6a44d66193e9a57b8a979e (patch)
tree5e40caa777c01a7999d736ead63ae239d1eb5b98 /src/qml/jsruntime/qv4errorobject.cpp
parent3ad8b0f0e8193bb7b62ffee6b33588ef6b51459c (diff)
Move prototype pointer into QV4::InternalClass
The prototype is actually the same for most objects. By moving it into the internal class, we can save 8 bytes per object, as well as allowing for some future optimizations. Also fix a bug in the implementation of the Error prototype objects. Change-Id: I4d4b641055f644a9b088f27be34bfdb0446279b7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4errorobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index 6c7c290452..f0d7d7205e 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -72,6 +72,15 @@
using namespace QV4;
+ErrorObject::ErrorObject(InternalClass *ic)
+ : Object(ic)
+ , stack(0)
+{
+ type = Type_ErrorObject;
+ vtbl = &static_vtbl;
+ defineDefaultProperty(ic->engine, QStringLiteral("name"), Value::fromString(ic->engine, "Error"));
+}
+
ErrorObject::ErrorObject(ExecutionEngine *engine, const Value &message, ErrorType t)
: Object(engine)
, stack(0)
@@ -158,68 +167,68 @@ SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const Value &msg)
: ErrorObject(engine, msg, SyntaxError)
{
vtbl = &static_vtbl;
- prototype = engine->syntaxErrorPrototype;
+ setPrototype(engine->syntaxErrorPrototype);
}
SyntaxErrorObject::SyntaxErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber)
: ErrorObject(engine, msg, fileName, lineNumber, columnNumber, SyntaxError)
{
vtbl = &static_vtbl;
- prototype = engine->syntaxErrorPrototype;
+ setPrototype(engine->syntaxErrorPrototype);
}
EvalErrorObject::EvalErrorObject(ExecutionEngine *engine, const Value &message)
: ErrorObject(engine, message, EvalError)
{
- prototype = engine->evalErrorPrototype;
+ setPrototype(engine->evalErrorPrototype);
}
RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const Value &message)
: ErrorObject(engine, message, RangeError)
{
- prototype = engine->rangeErrorPrototype;
+ setPrototype(engine->rangeErrorPrototype);
}
RangeErrorObject::RangeErrorObject(ExecutionEngine *engine, const QString &message)
: ErrorObject(engine, Value::fromString(engine, message), RangeError)
{
- prototype = engine->rangeErrorPrototype;
+ setPrototype(engine->rangeErrorPrototype);
}
ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const Value &message)
: ErrorObject(engine, message, ReferenceError)
{
- prototype = engine->referenceErrorPrototype;
+ setPrototype(engine->referenceErrorPrototype);
}
ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const QString &message)
: ErrorObject(engine, Value::fromString(engine, message), ReferenceError)
{
- prototype = engine->referenceErrorPrototype;
+ setPrototype(engine->referenceErrorPrototype);
}
ReferenceErrorObject::ReferenceErrorObject(ExecutionEngine *engine, const QString &msg, const QString &fileName, int lineNumber, int columnNumber)
: ErrorObject(engine, msg, fileName, lineNumber, columnNumber, ReferenceError)
{
- prototype = engine->referenceErrorPrototype;
+ setPrototype(engine->referenceErrorPrototype);
}
TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const Value &message)
: ErrorObject(engine, message, TypeError)
{
- prototype = engine->typeErrorPrototype;
+ setPrototype(engine->typeErrorPrototype);
}
TypeErrorObject::TypeErrorObject(ExecutionEngine *engine, const QString &message)
: ErrorObject(engine, Value::fromString(engine, message), TypeError)
{
- prototype = engine->typeErrorPrototype;
+ setPrototype(engine->typeErrorPrototype);
}
URIErrorObject::URIErrorObject(ExecutionEngine *engine, const Value &message)
: ErrorObject(engine, message, URIError)
{
- prototype = engine->uRIErrorPrototype;
+ setPrototype(engine->uRIErrorPrototype);
}
DEFINE_MANAGED_VTABLE(ErrorCtor);