for (int i = 0; i < data->stringTableSize; ++i)
runtimeStrings[i] = engine->newIdentifier(data->stringAt(i));
- runtimeRegularExpressions = new QV4::Value[data->regexpTableSize];
+ runtimeRegularExpressions = new QV4::SafeValue[data->regexpTableSize];
// memset the regexps to 0 in case a GC run happens while we're within the loop below
- memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::Value));
+ memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::SafeValue));
for (int i = 0; i < data->regexpTableSize; ++i) {
const CompiledData::RegExp *re = data->regexpAt(i);
int flags = 0;
flags |= QQmlJS::V4IR::RegExp::RegExp_IgnoreCase;
if (re->flags & CompiledData::RegExp::RegExp_Multiline)
flags |= QQmlJS::V4IR::RegExp::RegExp_Multiline;
- QV4::RegExpObject *obj = engine->newRegExpObject(data->stringAt(re->stringIndex), flags)->getPointer();
- runtimeRegularExpressions[i] = QV4::Value::fromObject(obj);
+ runtimeRegularExpressions[i] = engine->newRegExpObject(data->stringAt(re->stringIndex), flags);
}
if (data->lookupTableSize) {
QV4::SafeString *runtimeStrings; // Array
QV4::Lookup *runtimeLookups;
- QV4::Value *runtimeRegularExpressions;
+ QV4::SafeValue *runtimeRegularExpressions;
QV4::InternalClass **runtimeClasses;
QVector<QV4::Function *> runtimeFunctions;
// QVector<QV4::Function *> runtimeFunctionsSortedByAddress;
TempType = 3,
ScopedLocalType = 4
};
- QV4::Value value;
+ QV4::Primitive value;
unsigned type : 3;
unsigned scope : 29;
unsigned index;
bool isTemp() const { return type == TempType; }
bool isScopedLocal() const { return type == ScopedLocalType; }
- static Param createValue(const QV4::Value &v)
+ static Param createValue(const QV4::Primitive &v)
{
Param p;
p.type = ValueType;
case V4IR::Temp::Formal:
case V4IR::Temp::ScopedFormal: {
loadPtr(Address(context, qOffsetOf(CallContext, callData)), reg);
- offset = sizeof(CallData) + (t->index - 1) * sizeof(Value);
+ offset = sizeof(CallData) + (t->index - 1) * sizeof(SafeValue);
} break;
case V4IR::Temp::Local:
case V4IR::Temp::ScopedLocal: {
loadPtr(Address(context, qOffsetOf(CallContext, locals)), reg);
- offset = t->index * sizeof(Value);
+ offset = t->index * sizeof(SafeValue);
} break;
case V4IR::Temp::StackSlot: {
return stackSlotPointer(t);
storeDouble(FPGpr0, result);
#endif
} else if (V4IR::Const *c = source->asConst()) {
- QV4::Value v = convertToValue(c);
+ QV4::Primitive v = convertToValue(c);
storeValue(v, result);
} else {
Q_UNREACHABLE();
}
}
-void Assembler::storeValue(QV4::Value value, V4IR::Temp* destination)
+void Assembler::storeValue(QV4::Primitive value, V4IR::Temp* destination)
{
Address addr = loadTempAddress(ScratchRegister, destination);
storeValue(value, addr);
const int locals = _as->stackLayout().calculateJSStackFrameSize();
_as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister);
_as->loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)), Assembler::LocalsRegister);
- _as->addPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister);
+ _as->addPtr(Assembler::TrustedImm32(sizeof(QV4::SafeValue)*locals), Assembler::LocalsRegister);
_as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)));
for (int i = 0, ei = _function->basicBlocks.size(); i != ei; ++i) {
_as->load32(addr, Assembler::ScratchRegister);
_as->store32((Assembler::RegisterID) registerTemp->index, addr);
addr.offset += 4;
- QV4::Value tag;
+ quint32 tag;
switch (registerTemp->type) {
case V4IR::BoolType:
- tag = QV4::Primitive::fromBoolean(false);
+ tag = QV4::Value::_Boolean_Type;
break;
case V4IR::SInt32Type:
- tag = QV4::Primitive::fromInt32(0);
+ tag = QV4::Value::_Integer_Type;
break;
default:
- tag = QV4::Primitive::undefinedValue();
+ tag = QV4::Value::Undefined_Type;
Q_UNREACHABLE();
}
- _as->store32(Assembler::TrustedImm32(tag.tag), addr);
+ _as->store32(Assembler::TrustedImm32(tag), addr);
_as->move(Assembler::ScratchRegister, (Assembler::RegisterID) registerTemp->index);
}
}
} else {
_as->zeroExtend32ToPtr((Assembler::RegisterID) t->index,
Assembler::ReturnValueRegister);
- QV4::Value upper;
+ quint64 tag;
switch (t->type) {
case V4IR::SInt32Type:
- upper = QV4::Primitive::fromInt32(0);
+ tag = QV4::Value::_Integer_Type;
break;
case V4IR::BoolType:
- upper = QV4::Primitive::fromBoolean(false);
+ tag = QV4::Value::_Boolean_Type;
break;
default:
- upper = QV4::Primitive::undefinedValue();
+ tag = QV4::Value::Undefined_Type;
Q_UNREACHABLE();
}
- _as->or64(Assembler::TrustedImm64(((int64_t) upper.tag) << 32),
+ _as->or64(Assembler::TrustedImm64(tag << 32),
Assembler::ReturnValueRegister);
}
} else {
}
#endif
} else if (V4IR::Const *c = s->expr->asConst()) {
- QV4::Value retVal = convertToValue(c);
+ QV4::Primitive retVal = convertToValue(c);
#if CPU(X86)
_as->move(Assembler::TrustedImm32(retVal.int_32), JSC::X86Registers::eax);
_as->move(Assembler::TrustedImm32(retVal.tag), JSC::X86Registers::edx);
}
const int locals = _as->stackLayout().calculateJSStackFrameSize();
- _as->subPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister);
+ _as->subPtr(Assembler::TrustedImm32(sizeof(QV4::SafeValue)*locals), Assembler::LocalsRegister);
_as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister);
_as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)));
}
Pointer p = _as->stackLayout().callDataAddress(qOffsetOf(CallData, tag));
- _as->store32(Assembler::TrustedImm32(QV4::Value::Integer_Type), p);
+ _as->store32(Assembler::TrustedImm32(QV4::Value::_Integer_Type), p);
p = _as->stackLayout().callDataAddress(qOffsetOf(CallData, argc));
_as->store32(Assembler::TrustedImm32(argc), p);
p = _as->stackLayout().callDataAddress(qOffsetOf(CallData, thisObject));
int calculateJSStackFrameSize() const
{
- const int locals = (localCount + sizeof(QV4::CallData)/sizeof(QV4::Value) - 1 + maxOutgoingArgumentCount) + 1;
- int frameSize = locals * sizeof(QV4::Value);
+ const int locals = (localCount + sizeof(QV4::CallData)/sizeof(QV4::SafeValue) - 1 + maxOutgoingArgumentCount) + 1;
+ int frameSize = locals * sizeof(QV4::SafeValue);
return frameSize;
}
Q_ASSERT(idx < localCount);
Pointer addr = callDataAddress(0);
- addr.offset -= sizeof(QV4::Value) * (idx + 1);
+ addr.offset -= sizeof(QV4::SafeValue) * (idx + 1);
return addr;
}
Q_ASSERT(argument < maxOutgoingArgumentCount);
const int index = maxOutgoingArgumentCount - argument;
- return Pointer(Assembler::LocalsRegister, sizeof(QV4::Value) * (-index));
+ return Pointer(Assembler::LocalsRegister, sizeof(QV4::SafeValue) * (-index));
}
Pointer callDataAddress(int offset = 0) const {
- return Pointer(Assembler::LocalsRegister, -(sizeof(QV4::CallData) + sizeof(QV4::Value) * (maxOutgoingArgumentCount - 1)) + offset);
+ return Pointer(Assembler::LocalsRegister, -(sizeof(QV4::CallData) + sizeof(QV4::SafeValue) * (maxOutgoingArgumentCount - 1)) + offset);
}
Address savedRegPointer(int offset) const
Q_ASSERT(offset >= 0);
Q_ASSERT(offset < savedRegCount);
- const int off = offset * sizeof(QV4::Value);
+ const int off = offset * sizeof(QV4::SafeValue);
return Address(Assembler::StackFrameRegister, - calleeSavedRegisterSpace() - off);
}
void storeUInt32ReturnValue(RegisterID dest)
{
- Pointer tmp(StackPointerRegister, -int(sizeof(QV4::Value)));
+ Pointer tmp(StackPointerRegister, -int(sizeof(QV4::SafeValue)));
storeReturnValue(tmp);
toUInt32Register(tmp, dest);
}
xor64(ScratchRegister, ReturnValueRegister);
move64ToDouble(ReturnValueRegister, dest);
#else
- Pointer tmp(StackPointerRegister, -int(sizeof(QV4::Value)));
+ Pointer tmp(StackPointerRegister, -int(sizeof(QV4::SafeValue)));
storeReturnValue(tmp);
loadDouble(tmp, dest);
#endif
JSC::MacroAssembler::storeDouble(FPGpr0, target);
}
- void storeValue(QV4::Value value, RegisterID destination)
+ void storeValue(QV4::Primitive value, RegisterID destination)
{
Q_UNUSED(value);
Q_UNUSED(destination);
Q_UNREACHABLE();
}
- void storeValue(QV4::Value value, Address destination)
+ void storeValue(QV4::Primitive value, Address destination)
{
#ifdef VALUE_FITS_IN_REGISTER
store64(TrustedImm64(value.val), destination);
#endif
}
- void storeValue(QV4::Value value, V4IR::Temp* temp);
+ void storeValue(QV4::Primitive value, V4IR::Temp* temp);
void enterStandardStackFrame();
void leaveStandardStackFrame();
Address tagAddr = addr;
tagAddr.offset += 4;
- QV4::Value v = convertToValue(c);
+ QV4::Primitive v = convertToValue(c);
store32(TrustedImm32(v.int_32), addr);
store32(TrustedImm32(v.tag), tagAddr);
return Pointer(addr);
int scratchTempIndex() const { return _function->tempCount; }
int callDataStart() const { return scratchTempIndex() + 1; }
- int outgoingArgumentTempStart() const { return callDataStart() + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value); }
+ int outgoingArgumentTempStart() const { return callDataStart() + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue); }
int frameSize() const { return outgoingArgumentTempStart() + _function->maxNumberOfArguments; }
template <int Instr>
return uval == value && !(value == 0 && isNegative(value));
}
-inline QV4::Value convertToValue(V4IR::Const *c)
+inline QV4::Primitive convertToValue(V4IR::Const *c)
{
switch (c->type) {
case V4IR::MissingType:
- return QV4::Value::emptyValue();
+ return QV4::Primitive::emptyValue();
case V4IR::NullType:
return QV4::Primitive::nullValue();
case V4IR::UndefinedType:
if (!rightConst || rightConst->type == StringType || rightConst->type == VarType)
return false;
- QV4::Value l = convertToValue(leftConst);
- QV4::Value r = convertToValue(rightConst);
+ QV4::Primitive l = convertToValue(leftConst);
+ QV4::Primitive r = convertToValue(rightConst);
switch (b->op) {
case OpGt:
if (!rightConst || rightConst->type == StringType || rightConst->type == VarType)
continue;
- QV4::Value lc = convertToValue(leftConst);
- QV4::Value rc = convertToValue(rightConst);
+ QV4::Primitive lc = convertToValue(leftConst);
+ QV4::Primitive rc = convertToValue(rightConst);
double l = __qmljs_to_number(&lc);
double r = __qmljs_to_number(&rc);
using namespace QV4;
-CallContext *ExecutionContext::newCallContext(void *stackSpace, Value *locals, FunctionObject *function, CallData *callData)
+CallContext *ExecutionContext::newCallContext(void *stackSpace, SafeValue *locals, FunctionObject *function, CallData *callData)
{
CallContext *c = (CallContext *)stackSpace;
#ifndef QT_NO_DEBUG
c->lookups = c->compilationUnit->runtimeLookups;
}
- c->locals = (Value *)(c + 1);
+ c->locals = (SafeValue *)(c + 1);
if (function->varCount)
std::fill(c->locals, c->locals + function->varCount, Primitive::undefinedValue());
c->callData = reinterpret_cast<CallData *>(c->locals + function->varCount);
- ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value));
+ ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(SafeValue));
if (callData->argc < function->formalParameterCount)
std::fill(c->callData->args + c->callData->argc, c->callData->args + function->formalParameterCount, Primitive::undefinedValue());
c->callData->argc = qMax((uint)callData->argc, function->formalParameterCount);
return w;
}
-CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const Value &exceptionValue)
+CatchContext *ExecutionContext::newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue)
{
CatchContext *c = static_cast<CatchContext *>(engine->memoryManager->allocContext(sizeof(CatchContext)));
engine->current = c;
{
initBaseContext(Type_GlobalContext, eng, /*parentContext*/0);
callData = reinterpret_cast<CallData *>(this + 1);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::_Integer_Type;
callData->argc = 0;
- callData->thisObject = Value::fromObject(eng->globalObject);
+ callData->thisObject = eng->globalObject;
global = 0;
}
withObject = with.getPointer();
}
-void CatchContext::initCatchContext(ExecutionContext *p, String *exceptionVarName, const Value &exceptionValue)
+void CatchContext::initCatchContext(ExecutionContext *p, const StringRef exceptionVarName, const ValueRef exceptionValue)
{
initBaseContext(Type_CatchContext, p->engine, p);
strictMode = p->strictMode;
lookups = compilationUnit->runtimeLookups;
}
- locals = (Value *)(this + 1);
+ locals = (SafeValue *)(this + 1);
if (function->varCount)
std::fill(locals, locals + function->varCount, Primitive::undefinedValue());
}
return w->withObject->deleteProperty(name);
} else if (ctx->type == Type_CatchContext) {
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return false;
} else if (ctx->type >= Type_CallContext) {
CallContext *c = static_cast<CallContext *>(ctx);
w->withObject->mark();
} else if (type == Type_CatchContext) {
CatchContext *c = static_cast<CatchContext *>(this);
- if (c->exceptionVarName)
- c->exceptionVarName->mark();
+ c->exceptionVarName->mark();
c->exceptionValue.mark();
} else if (type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(this);
w->put(name, value);
return;
}
- } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) {
+ } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->stringValue()->isEqualTo(name)) {
static_cast<CatchContext *>(ctx)->exceptionValue = *value;
return;
} else {
else if (ctx->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
else if (ctx->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
else if (ctx->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
}
if (f->function && f->function->isNamedExpression()
&& name->isEqualTo(f->function->name))
- return Value::fromObject(c->function).asReturnedValue();
+ return c->function->asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
interpreterInstructionPointer = 0;
}
- CallContext *newCallContext(void *stackSpace, Value *locals, FunctionObject *f, CallData *callData);
+ CallContext *newCallContext(void *stackSpace, SafeValue *locals, FunctionObject *f, CallData *callData);
CallContext *newCallContext(FunctionObject *f, CallData *callData);
WithContext *newWithContext(ObjectRef with);
- CatchContext *newCatchContext(String* exceptionVarName, const QV4::Value &exceptionValue);
+ CatchContext *newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue);
CallContext *newQmlContext(FunctionObject *f, ObjectRef qml);
String * const *formals() const;
void initQmlContext(ExecutionContext *parentContext, ObjectRef qml, QV4::FunctionObject *function);
bool needsOwnArguments() const;
- Value *locals;
+ SafeValue *locals;
Object *activation;
};
struct CatchContext : public ExecutionContext
{
- void initCatchContext(ExecutionContext *p, String *exceptionVarName, const QV4::Value &exceptionValue);
+ void initCatchContext(ExecutionContext *p, const StringRef exceptionVarName, const ValueRef exceptionValue);
- String *exceptionVarName;
- Value exceptionValue;
+ SafeString exceptionVarName;
+ SafeValue exceptionValue;
};
struct WithContext : public ExecutionContext
struct DateObject: Object {
Q_MANAGED
- Value value;
- DateObject(ExecutionEngine *engine, const Value &value): Object(engine->dateClass), value(value) {
+ SafeValue value;
+ DateObject(ExecutionEngine *engine, const ValueRef date): Object(engine->dateClass) {
vtbl = &static_vtbl;
type = Type_DateObject;
+ value = date;
}
DateObject(ExecutionEngine *engine, const QDateTime &value);
QDateTime toQDateTime() const;
protected:
- DateObject(InternalClass *ic): Object(ic), value(Primitive::fromDouble(qSNaN())) {
+ DateObject(InternalClass *ic): Object(ic) {
vtbl = &static_vtbl;
type = Type_DateObject;
+ value = Primitive::fromDouble(qSNaN());
}
};
applyPendingBreakPoints();
}
-void Debugger::aboutToThrow(const QV4::Value &value)
+void Debugger::aboutToThrow(const QV4::ValueRef value)
{
qDebug() << "*** We are about to throw...";
}
m_havePendingBreakPoints = false;
}
-static void realDumpValue(QV4::Value v, QV4::ExecutionContext *ctx, std::string prefix)
+static void realDumpValue(const QV4::ValueRef v, QV4::ExecutionContext *ctx, std::string prefix)
{
using namespace QV4;
using namespace std;
Scope scope(ctx);
- cout << prefix << "tag: " << hex << v.tag << dec << endl << prefix << "\t-> ";
- switch (v.type()) {
+ cout << prefix << "tag: " << hex << v->tag << dec << endl << prefix << "\t-> ";
+ switch (v->type()) {
case Value::Undefined_Type: cout << "Undefined"; return;
case Value::Null_Type: cout << "Null"; return;
case Value::Boolean_Type: cout << "Boolean"; break;
case Value::Integer_Type: cout << "Integer"; break;
- case Value::Managed_Type: cout << v.managed()->className().toUtf8().data(); break;
+ case Value::Managed_Type: cout << v->managed()->className().toUtf8().data(); break;
default: cout << "UNKNOWN" << endl; return;
}
cout << endl;
- if (v.isBoolean()) {
- cout << prefix << "\t-> " << (v.booleanValue() ? "TRUE" : "FALSE") << endl;
+ if (v->isBoolean()) {
+ cout << prefix << "\t-> " << (v->booleanValue() ? "TRUE" : "FALSE") << endl;
return;
}
- if (v.isInteger()) {
- cout << prefix << "\t-> " << v.integerValue() << endl;
+ if (v->isInteger()) {
+ cout << prefix << "\t-> " << v->integerValue() << endl;
return;
}
- if (v.isDouble()) {
- cout << prefix << "\t-> " << v.doubleValue() << endl;
+ if (v->isDouble()) {
+ cout << prefix << "\t-> " << v->doubleValue() << endl;
return;
}
- if (v.isString()) {
+ if (v->isString()) {
// maybe check something on the Managed object?
- cout << prefix << "\t-> @" << hex << v.stringValue() << endl;
- cout << prefix << "\t-> \"" << qPrintable(v.stringValue()->toQString()) << "\"" << endl;
+ cout << prefix << "\t-> @" << hex << v->stringValue() << endl;
+ cout << prefix << "\t-> \"" << qPrintable(v->stringValue()->toQString()) << "\"" << endl;
return;
}
cout << prefix << "properties:" << endl;
ForEachIteratorObject it(ctx, o);
ScopedValue name(scope);
+ ScopedValue pval(scope);
for (name = it.nextPropertyName(); !name->isNull(); name = it.nextPropertyName()) {
cout << prefix << "\t\"" << qPrintable(name->stringValue()->toQString()) << "\"" << endl;
PropertyAttributes attrs;
Property *d = o->__getOwnProperty__(ScopedString(scope, name), &attrs);
- Value pval = Value::fromReturnedValue(o->getValue(d, attrs));
+ pval = o->getValue(d, attrs);
cout << prefix << "\tvalue:" << endl;
realDumpValue(pval, ctx, prefix + "\t");
}
}
-void dumpValue(QV4::Value v, QV4::ExecutionContext *ctx)
+void dumpValue(const QV4::ValueRef v, QV4::ExecutionContext *ctx)
{
realDumpValue(v, ctx, std::string(""));
}
void maybeBreakAtInstruction(const uchar *code, bool breakPointHit);
public: // execution hooks
- void aboutToThrow(const Value &value);
+ void aboutToThrow(const ValueRef value);
private:
// requires lock to be held
return f->asReturned<FunctionObject>();
}
-Returned<BoundFunction> *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs)
+Returned<BoundFunction> *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs)
{
- assert(target);
+ Q_ASSERT(target);
BoundFunction *f = new (memoryManager) BoundFunction(scope, target, boundThis, boundArgs);
return f->asReturned<BoundFunction>();
}
-Returned<DateObject> *ExecutionEngine::newDateObject(const Value &value)
+Returned<DateObject> *ExecutionEngine::newDateObject(const ValueRef value)
{
DateObject *object = new (memoryManager) DateObject(this, value);
return object->asReturned<DateObject>();
ExecutionContext *popContext();
Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(SimpleCallContext *));
- Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs);
+ Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs);
Returned<Object> *newObject();
Returned<Object> *newObject(InternalClass *internalClass);
Returned<ArrayObject> *newArrayObject(const QStringList &list);
Returned<ArrayObject> *newArrayObject(InternalClass *ic);
- Returned<DateObject> *newDateObject(const Value &value);
+ Returned<DateObject> *newDateObject(const ValueRef value);
Returned<DateObject> *newDateObject(const QDateTime &dt);
Returned<RegExpObject> *newRegExpObject(const QString &pattern, int flags);
using namespace QV4;
-void Exception::throwException(ExecutionContext *context, const Value &value)
+void Exception::throwException(ExecutionContext *context, const ValueRef value)
{
if (context->engine->debugger)
context->engine->debugger->aboutToThrow(value);
throwInternal(context, value);
}
-Exception::Exception(ExecutionContext *throwingContext, const Value &exceptionValue)
+Exception::Exception(ExecutionContext *throwingContext, const ValueRef exceptionValue)
: e(throwingContext->engine)
{
e->exceptionValue = exceptionValue;
this->throwingContext = throwingContext->engine->current;
accepted = false;
- if (ErrorObject *error = exceptionValue.asErrorObject())
+ if (ErrorObject *error = exceptionValue->asErrorObject())
m_stackTrace = error->stackTrace;
else
m_stackTrace = throwingContext->engine->stackTrace();
}
#if !defined(V4_CXX_ABI_EXCEPTION)
-void Exception::throwInternal(ExecutionContext *throwingContext, const Value &exceptionValue)
+void Exception::throwInternal(ExecutionContext *throwingContext, const ValueRef exceptionValue)
{
throw Exception(throwingContext, exceptionValue);
}
#include "qv4exception_p.h"
+#include <private/qv4scopedvalue_p.h>
#include <unwind.h>
#include <cxxabi.h>
#include <bits/atomic_word.h>
using namespace QV4;
-void Exception::throwInternal(ExecutionContext *throwingContext, const Value &exceptionValue)
+void Exception::throwInternal(ExecutionContext *throwingContext, const ValueRef exceptionValue)
{
void *rawException = abi::__cxa_allocate_exception(sizeof(QV4::Exception));
gcc_refcounted_compatible_exception *refCountedException = reinterpret_cast<gcc_refcounted_compatible_exception *>(rawException) - 1;
namespace QV4 {
struct Q_QML_EXPORT Exception {
- static void Q_NORETURN throwException(ExecutionContext *throwingContext, const Value &exceptionValue);
+ static void Q_NORETURN throwException(ExecutionContext *throwingContext, const ValueRef exceptionValue);
~Exception();
private:
void *operator new(size_t, void *p) { return p; }
- explicit Exception(ExecutionContext *throwingContext, const Value &exceptionValue);
+ explicit Exception(ExecutionContext *throwingContext, const ValueRef exceptionValue);
ExecutionEngine *e;
ExecutionContext *throwingContext;
bool accepted;
ExecutionEngine::StackTrace m_stackTrace;
- static void Q_NORETURN throwInternal(ExecutionContext *throwingContext, const Value &exceptionValue);
+ static void Q_NORETURN throwInternal(ExecutionContext *throwingContext, const ValueRef exceptionValue);
};
} // namespace QV4
ctx->throwTypeError();
ScopedValue boundThis(scope, ctx->argument(0));
- QVector<Value> boundArgs;
+ QVector<SafeValue> boundArgs;
for (uint i = 1; i < ctx->callData->argc; ++i)
boundArgs += ctx->callData->args[i];
- return ctx->engine->newBoundFunction(ctx->engine->rootContext, target.getPointer(), boundThis, boundArgs)->asReturnedValue();
+ return ctx->engine->newBoundFunction(ctx->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue();
}
DEFINE_MANAGED_VTABLE(ScriptFunction);
DEFINE_MANAGED_VTABLE(BoundFunction);
-BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs)
+BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs)
: FunctionObject(scope, 0)
, target(target)
- , boundThis(boundThis)
, boundArgs(boundArgs)
{
vtbl = &static_vtbl;
+ this->boundThis = boundThis;
Scope s(scope);
ScopedValue protectThis(s, this);
struct BoundFunction: FunctionObject {
Q_MANAGED
FunctionObject *target;
- Value boundThis;
- QVector<Value> boundArgs;
+ SafeValue boundThis;
+ QVector<SafeValue> boundArgs;
- BoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs);
+ BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs);
~BoundFunction() {}
arrayData = newArrayData;
if (sparseArray) {
for (uint i = arrayFreeList; i < arrayAlloc; ++i) {
- arrayData[i].value = Value::emptyValue();
+ arrayData[i].value = Primitive::emptyValue();
arrayData[i].value = Primitive::fromInt32(i + 1);
}
} else {
} else {
arrayAttributes[it - arrayData].clear();
}
- it->value = Value::emptyValue();
+ it->value = Primitive::emptyValue();
}
}
arrayDataLen = newLen;
}
if (attrs->isGeneric())
- desc->value = Value::emptyValue();
+ desc->value = Primitive::emptyValue();
}
static Property genericDescriptor() {
Property pd;
- pd.value = Value::emptyValue();
+ pd.value = Primitive::emptyValue();
return pd;
}
void __qmljs_throw(ExecutionContext *context, const ValueRef value)
{
- Exception::throwException(context, *value);
+ Exception::throwException(context, value);
}
ReturnedValue __qmljs_builtin_typeof(ExecutionContext *ctx, const ValueRef value)
ExecutionContext *__qmljs_builtin_push_catch_scope(const StringRef exceptionVarName, const ValueRef exceptionValue, ExecutionContext *ctx)
{
- return ctx->newCatchContext(exceptionVarName.getPointer(), *exceptionValue);
+ return ctx->newCatchContext(exceptionVarName, exceptionValue);
}
ExecutionContext *__qmljs_builtin_pop_scope(ExecutionContext *ctx)
return val;
}
- static Value emptyValue();
static Value fromObject(Object *o);
static Value fromManaged(Managed *o);
struct Q_QML_EXPORT Primitive : public Value
{
+ static Primitive emptyValue();
static Primitive fromBoolean(bool b);
static Primitive fromInt32(int i);
static Primitive undefinedValue();
return v;
}
-inline Value Value::emptyValue()
+inline Primitive Primitive::emptyValue()
{
- Value v;
+ Primitive v;
v.tag = Value::Empty_Type;
v.uint_32 = 0;
return v;
if (param.isValue()) {
VMSTATS(paramIsValue);
- return const_cast<QV4::Value *>(¶m.value);
+ return const_cast<QV4::Value *>(&static_cast<const QV4::Value &>(param.value));
} else if (param.isArgument()) {
VMSTATS(paramIsArg);
QV4::ExecutionContext *c = context;