return std::signbit(number) ? -v : v;
}
-Object *Value::asObject() const
-{
- return isObject() ? objectValue() : 0;
-}
-
-FunctionObject *Value::asFunctionObject() const
-{
- return isObject() ? objectValue()->asFunctionObject() : 0;
-}
-
-BooleanObject *Value::asBooleanObject() const
-{
- return isObject() ? objectValue()->asBooleanObject() : 0;
-}
-
-NumberObject *Value::asNumberObject() const
-{
- return isObject() ? objectValue()->asNumberObject() : 0;
-}
-
-StringObject *Value::asStringObject() const
-{
- return isObject() ? objectValue()->asStringObject() : 0;
-}
-
-DateObject *Value::asDateObject() const
-{
- return isObject() ? objectValue()->asDateObject() : 0;
-}
-
-RegExpObject *Value::asRegExpObject() const
-{
- return isObject() ? objectValue()->asRegExpObject() : 0;
-}
-
-ArrayObject *Value::asArrayObject() const
-{
- return isObject() ? objectValue()->asArrayObject() : 0;
-}
-
-ErrorObject *Value::asErrorObject() const
-{
- return isObject() ? objectValue()->asErrorObject() : 0;
-}
-
Value Value::property(ExecutionContext *ctx, String *name) const
{
return isObject() ? objectValue()->__get__(ctx, name) : undefinedValue();
#include <QtCore/qnumeric.h>
#include <qv4string.h>
#include <QtCore/QDebug>
+#include <qv4managed.h>
namespace QQmlJS {
namespace VM {
struct String;
-struct Object;
-struct BooleanObject;
-struct NumberObject;
-struct StringObject;
-struct ArrayObject;
-struct DateObject;
-struct FunctionObject;
-struct RegExpObject;
-struct ErrorObject;
-struct ArgumentsObject;
struct ExecutionContext;
struct ExecutionEngine;
struct Value;
int int_32;
#if CPU(X86_64)
#else
+ Managed *m;
Object *o;
String *s;
#endif
Object *objectValue() const {
return (Object *)(val & ~(quint64(Type_Mask) << Tag_Shift));
}
+ Managed *managed() const {
+ return (Managed *)(val & ~(quint64(Type_Mask) << Tag_Shift));
+ }
#else
String *stringValue() const {
return s;
Object *objectValue() const {
return o;
}
+ Managed *managed() const {
+ return m;
+ }
#endif
quint64 rawValue() const {
}
+inline Object *Value::asObject() const
+{
+ return isObject() ? objectValue() : 0;
+}
+
+inline FunctionObject *Value::asFunctionObject() const
+{
+ return isObject() ? managed()->asFunctionObject() : 0;
+}
+
+inline BooleanObject *Value::asBooleanObject() const
+{
+ return isObject() ? managed()->asBooleanObject() : 0;
+}
+
+inline NumberObject *Value::asNumberObject() const
+{
+ return isObject() ? managed()->asNumberObject() : 0;
+}
+
+inline StringObject *Value::asStringObject() const
+{
+ return isObject() ? managed()->asStringObject() : 0;
+}
+
+inline DateObject *Value::asDateObject() const
+{
+ return isObject() ? managed()->asDateObject() : 0;
+}
+
+inline RegExpObject *Value::asRegExpObject() const
+{
+ return isObject() ? managed()->asRegExpObject() : 0;
+}
+
+inline ArrayObject *Value::asArrayObject() const
+{
+ return isObject() ? managed()->asArrayObject() : 0;
+}
+
+inline ErrorObject *Value::asErrorObject() const
+{
+ return isObject() ? managed()->asErrorObject() : 0;
+}
+
+
} // namespace VM
} // namespace QQmlJS
Type_ForeachIteratorObject
};
+ Object *asObject() { return reinterpret_cast<Object *>(this); }
ArrayObject *asArrayObject() { return type == Type_ArrayObject ? reinterpret_cast<ArrayObject *>(this) : 0; }
FunctionObject *asFunctionObject() { return type == Type_FunctionObject ? reinterpret_cast<FunctionObject *>(this) : 0; }
BooleanObject *asBooleanObject() { return type == Type_BooleanObject ? reinterpret_cast<BooleanObject *>(this) : 0; }