{
#ifndef QT_NO_SETTINGS
QV8Engine *engine = args->engine();
- QV4::ExecutionContext *ctx = args->v4engine()->currentContext();
- QV4::Scope scope(ctx);
+ QV4::Scope scope(args->v4engine());
+ QV4::ScopedContext ctx(scope, args->v4engine()->currentContext());
if (engine->engine()->offlineStoragePath().isEmpty())
V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled."));
pd->value = mappedArguments()->data[index];
}
- bool strict = engine->currentContext()->d()->strictMode;
- engine->currentContext()->d()->strictMode = false;
+ bool strict = engine->currentContext()->strictMode;
+ engine->currentContext()->strictMode = false;
bool result = Object::defineOwnProperty2(scope.engine, index, desc, attrs);
- engine->currentContext()->d()->strictMode = strict;
+ engine->currentContext()->strictMode = strict;
if (isMapped && attrs.isData()) {
Q_ASSERT(arrayData());
}
}
- if (engine->currentContext()->d()->strictMode && !result)
+ if (engine->currentContext()->strictMode && !result)
return engine->throwTypeError();
return result;
}
if (!m_returnedValue.isUndefined())
m_returnedValue = Encode::undefined();
- m_currentContext = m_engine->currentContext()->d();
+ m_currentContext = m_engine->currentContext();
m_stepping = speed;
m_runningCondition.wakeAll();
}
{
ExecutionState state;
state.fileName = getFunction()->sourceFile();
- state.lineNumber = engine()->currentContext()->d()->lineNumber;
+ state.lineNumber = engine()->currentContext()->lineNumber;
return state;
}
return m_engine->stackTrace(frameLimit);
}
-static inline CallContext *findContext(ExecutionContext *ctxt, int frame)
+static inline Heap::CallContext *findContext(Heap::ExecutionContext *ctxt, int frame)
{
if (!ctxt)
return 0;
- Scope scope(ctxt);
+ Scope scope(ctxt->engine);
Scoped<ExecutionContext> ctx(scope, ctxt);
while (ctx) {
CallContext *cCtxt = ctx->asCallContext();
if (cCtxt && cCtxt->d()->function) {
if (frame < 1)
- return cCtxt;
+ return cCtxt->d();
--frame;
}
ctx = ctx->d()->parent;
return 0;
}
-static inline CallContext *findScope(ExecutionContext *ctxt, int scope)
+static inline Heap::CallContext *findScope(Heap::ExecutionContext *ctxt, int scope)
{
if (!ctxt)
return 0;
- Scope s(ctxt);
+ Scope s(ctxt->engine);
Scoped<ExecutionContext> ctx(s, ctxt);
for (; scope > 0 && ctx; --scope)
ctx = ctx->d()->outer;
- return ctx ? ctx->asCallContext() : 0;
+ return (ctx && ctx->d()) ? ctx->asCallContext()->d() : 0;
}
void Debugger::collectArgumentsInContext(Collector *collector, int frameNr, int scopeNr)
if (frameNr < 0)
return;
- CallContext *ctxt = findScope(findContext(engine->currentContext(), frameNr), scopeNr);
+ Scope scope(engine);
+ Scoped<CallContext> ctxt(scope, findScope(findContext(engine->currentContext(), frameNr), scopeNr));
if (!ctxt)
return;
- Scope scope(engine);
ScopedValue v(scope);
int nFormals = ctxt->formalCount();
for (unsigned i = 0, ei = nFormals; i != ei; ++i) {
if (frameNr < 0)
return;
- CallContext *ctxt = findScope(findContext(engine->currentContext(), frameNr), scopeNr);
+ Scope scope(engine);
+ Scoped<CallContext> ctxt(scope, findScope(findContext(engine->currentContext(), frameNr), scopeNr));
if (!ctxt)
return;
- Scope scope(engine);
ScopedValue v(scope);
for (unsigned i = 0, ei = ctxt->variableCount(); i != ei; ++i) {
QString qName;
if (state() != Paused)
return types;
- CallContext *sctxt = findContext(m_engine->currentContext(), frame);
+ Scope scope(m_engine);
+ Scoped<CallContext> sctxt(scope, findContext(m_engine->currentContext(), frame));
if (!sctxt || sctxt->d()->type < Heap::ExecutionContext::Type_SimpleCallContext)
return types;
- CallContext *ctxt = static_cast<CallContext *>(sctxt);
- Scope scope(m_engine);
- Scoped<ExecutionContext> it(scope, ctxt);
+ Scoped<ExecutionContext> it(scope, sctxt->d());
for (; it; it = it->d()->outer)
types.append(it->d()->type);
return;
QMutexLocker locker(&m_lock);
- int lineNumber = engine()->currentContext()->d()->lineNumber;
+ int lineNumber = engine()->currentContext()->lineNumber;
if (m_gatherSources) {
m_gatherSources->run();
switch (m_stepping) {
case StepOver:
- if (m_currentContext.asManaged()->d() != m_engine->currentContext()->d())
+ if (m_currentContext.asManaged()->d() != m_engine->currentContext())
break;
// fall through
case StepIn:
QMutexLocker locker(&m_lock);
if (m_stepping == StepIn) {
- m_currentContext = m_engine->currentContext()->d();
+ m_currentContext = m_engine->currentContext();
}
}
QMutexLocker locker(&m_lock);
Scope scope(m_engine);
- if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->currentContext()->d()) {
- m_currentContext = m_engine->currentContext()->d()->parent;
+ if (m_stepping != NotStepping && m_currentContext.asManaged()->d() == m_engine->currentContext()) {
+ m_currentContext = m_engine->currentContext()->parent;
m_stepping = StepOver;
m_returnedValue = retVal;
}
Function *Debugger::getFunction() const
{
- ExecutionContext *context = m_engine->currentContext();
+ Scope scope(m_engine);
+ ScopedContext context(scope, m_engine->currentContext());
if (CallContext *callCtx = context->asCallContext())
return callCtx->d()->function->function;
else {
Scoped<GlobalContext> g(scope, memoryManager->alloc<GlobalContext>(this));
g->d()->callData = rootContext()->d()->callData;
- Q_ASSERT(currentContext() == g.getPointer());
+ Q_ASSERT(currentContext() == g->d());
return g.getPointer();
}
Heap::Object *ExecutionEngine::qmlContextObject() const
{
- Heap::ExecutionContext *ctx = currentContext()->d();
+ Heap::ExecutionContext *ctx = currentContext();
if (ctx->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->outer)
ctx = ctx->parent;
QVector<StackFrame> ExecutionEngine::stackTrace(int frameLimit) const
{
- Scope scope(this->currentContext());
+ Scope scope(const_cast<ExecutionEngine *>(this));
ScopedString name(scope);
QVector<StackFrame> stack;
setter->mark(this);
}
- Heap::ExecutionContext *c = currentContext()->d();
+ Heap::ExecutionContext *c = currentContext();
while (c) {
Q_ASSERT(c->inUse);
if (!c->markBit) {
friend struct ExecutionContext;
friend struct Heap::ExecutionContext;
public:
- ExecutionContext *current;
- ExecutionContext *currentContext() const { return current; }
+ Heap::ExecutionContext *current;
+ Heap::ExecutionContext *currentContext() const { return current; }
Value *jsStackTop;
quint32 hasException;
ExecutionContext *pushGlobalContext();
void pushContext(CallContext *context);
- ExecutionContext *popContext();
+ Heap::ExecutionContext *popContext();
Heap::Object *newObject();
Heap::Object *newObject(InternalClass *internalClass, Object *prototype);
inline void ExecutionEngine::pushContext(CallContext *context)
{
- Q_ASSERT(current && current->d() && context && context->d());
- context->d()->parent = current->d();
- current = context;
+ Q_ASSERT(current && context && context->d());
+ context->d()->parent = current;
+ current = context->d();
}
-inline ExecutionContext *ExecutionEngine::popContext()
+inline Heap::ExecutionContext *ExecutionEngine::popContext()
{
- Q_ASSERT(current->d()->parent);
- // ### GC
- current = reinterpret_cast<ExecutionContext *>(current->d()->parent);
- Q_ASSERT(current && current->d());
+ Q_ASSERT(current->parent);
+ current = current->parent;
+ Q_ASSERT(current);
return current;
}
, type(t)
, strictMode(false)
, engine(engine)
- , parent(engine->currentContext()->d())
+ , parent(engine->currentContext())
, outer(0)
, lookups(0)
, compilationUnit(0)
, lineNumber(-1)
{
- // ### GC
- engine->current = reinterpret_cast<QV4::ExecutionContext *>(this);
+ engine->current = this;
}
{
FunctionCtor *f = static_cast<FunctionCtor *>(that);
ExecutionEngine *v4 = f->internalClass()->engine;
- ExecutionContext *ctx = v4->currentContext();
+ Scope scope(v4);
+ ScopedContext ctx(scope, v4->currentContext());
QString arguments;
QString body;
if (callData->argc > 0) {
ScopedObject proto(scope, f->protoForConstructor());
ScopedObject obj(scope, v4->newObject(ic, proto));
- ExecutionContext *context = v4->currentContext();
+ ScopedContext context(scope, v4->currentContext());
callData->thisObject = obj.asReturnedValue();
Scoped<CallContext> ctx(scope, context->newCallContext(f.getPointer(), callData));
return Encode::undefined();
CHECK_STACK_LIMITS(v4);
- ExecutionContext *context = v4->currentContext();
- Scope scope(context);
+ Scope scope(v4);
+ ScopedContext context(scope, v4->currentContext());
Scoped<CallContext> ctx(scope, context->newCallContext(f, callData));
ScopedObject proto(scope, f->protoForConstructor());
callData->thisObject = v4->newObject(ic, proto);
- ExecutionContext *context = v4->currentContext();
- ExecutionContextSaver ctxSaver(scope, context);
+ ExecutionContextSaver ctxSaver(scope, v4->currentContext());
CallContext::Data ctx(v4);
ctx.strictMode = f->strictMode();
callData->args[callData->argc] = Encode::undefined();
++callData->argc;
}
- Q_ASSERT(v4->currentContext()->d() == &ctx);
+ Q_ASSERT(v4->currentContext() == &ctx);
Scoped<Object> result(scope, Q_V4_PROFILE(v4, f->function()));
SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that);
Scope scope(v4);
- ExecutionContext *context = v4->currentContext();
- ExecutionContextSaver ctxSaver(scope, context);
+ ExecutionContextSaver ctxSaver(scope, v4->currentContext());
CallContext::Data ctx(v4);
ctx.strictMode = f->strictMode();
callData->args[callData->argc] = Encode::undefined();
++callData->argc;
}
- Q_ASSERT(v4->currentContext()->d() == &ctx);
+ Q_ASSERT(v4->currentContext() == &ctx);
ScopedValue result(scope, Q_V4_PROFILE(v4, f->function()));
CHECK_STACK_LIMITS(v4);
Scope scope(v4);
- ExecutionContext *context = v4->currentContext();
- ExecutionContextSaver ctxSaver(scope, context);
+ ExecutionContextSaver ctxSaver(scope, v4->currentContext());
CallContext::Data ctx(v4);
ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context?
ctx.callData = callData;
- Q_ASSERT(v4->currentContext()->d() == &ctx);
+ Q_ASSERT(v4->currentContext() == &ctx);
return f->d()->code(reinterpret_cast<CallContext *>(&ctx));
}
CHECK_STACK_LIMITS(v4);
Scope scope(v4);
- ExecutionContext *context = v4->currentContext();
- ExecutionContextSaver ctxSaver(scope, context);
+ ExecutionContextSaver ctxSaver(scope, v4->currentContext());
CallContext::Data ctx(v4);
ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context?
ctx.callData = callData;
- Q_ASSERT(v4->currentContext()->d() == &ctx);
+ Q_ASSERT(v4->currentContext() == &ctx);
return f->d()->code(reinterpret_cast<CallContext *>(&ctx), f->d()->index);
}
ExecutionEngine *v4 = engine();
Scope scope(v4);
- ExecutionContext *parentContext = v4->currentContext();
+ ScopedContext parentContext(scope, v4->currentContext());
ExecutionContextSaver ctxSaver(scope, parentContext);
ExecutionContext *ctx = parentContext;
ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValue &value)
{
if (value.isString())
- return engine->currentContext()->d()->engine->newString(value.toString())->asReturnedValue();
+ return engine->currentContext()->engine->newString(value.toString())->asReturnedValue();
else if (value.isDouble())
return Encode(value.toDouble());
else if (value.isBool())
ReturnedValue Lookup::lookup(ValueRef thisObject, Object *o, PropertyAttributes *attrs)
{
ExecutionEngine *engine = o->engine();
- Identifier *name = engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]->identifier;
+ Identifier *name = engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]->identifier;
int i = 0;
Heap::Object *obj = o->d();
while (i < Size && obj) {
{
Heap::Object *obj = thisObject->d();
ExecutionEngine *engine = thisObject->engine();
- Identifier *name = engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]->identifier;
+ Identifier *name = engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]->identifier;
int i = 0;
while (i < Size && obj) {
classList[i] = obj->internalClass;
Q_ASSERT(object->isString());
proto = engine->stringPrototype.asObject();
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
if (name->equals(engine->id_length.getPointer())) {
// special case, as the property is on the object itself
l->getter = stringLengthGetter;
QV4::ScopedObject o(scope, object->toObject(scope.engine));
if (!o)
return Encode::undefined();
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
return o->get(name);
}
}
}
Scope scope(engine);
- Scoped<String> n(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ Scoped<String> n(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
return engine->throwReferenceError(n);
}
o = RuntimeHelpers::convertToObject(scope.engine, object);
if (!o) // type error
return;
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
o->put(name, value);
return;
}
QV4::Scope scope(engine);
QV4::ScopedObject o(scope, object->toObject(scope.engine));
if (o) {
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
o->put(name, value);
}
}
return;
reject:
- if (engine()->currentContext()->d()->strictMode)
+ if (engine()->currentContext()->strictMode)
engine()->throwTypeError();
}
{
Scope scope(m->engine());
ScopedObject o(scope, static_cast<Object *>(m));
- ScopedString name(scope, scope.engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
InternalClass *c = o->internalClass();
uint idx = c->find(name);
return;
reject:
- if (engine()->currentContext()->d()->strictMode) {
+ if (engine()->currentContext()->strictMode) {
QString message = QStringLiteral("Cannot assign to read-only property \"");
message += name->toQString();
message += QLatin1Char('\"');
return;
reject:
- if (engine()->currentContext()->d()->strictMode)
+ if (engine()->currentContext()->strictMode)
engine()->throwTypeError();
}
InternalClass::removeMember(this, name->identifier());
return true;
}
- if (engine()->currentContext()->d()->strictMode)
+ if (engine()->currentContext()->strictMode)
engine()->throwTypeError();
return false;
}
if (!ad || ad->vtable()->del(this, index))
return true;
- if (engine()->currentContext()->d()->strictMode)
+ if (engine()->currentContext()->strictMode)
engine()->throwTypeError();
return false;
}
return __defineOwnProperty__(engine, memberIndex, name, p, attrs);
reject:
- if (engine->currentContext()->d()->strictMode)
+ if (engine->currentContext()->strictMode)
engine->throwTypeError();
return false;
}
return defineOwnProperty2(engine, index, p, attrs);
reject:
- if (engine->currentContext()->d()->strictMode)
+ if (engine->currentContext()->strictMode)
engine->throwTypeError();
return false;
}
return __defineOwnProperty__(engine, index, 0, p, attrs);
reject:
- if (engine->currentContext()->d()->strictMode)
+ if (engine->currentContext()->strictMode)
engine->throwTypeError();
return false;
}
setHasAccessorProperty();
return true;
reject:
- if (engine->currentContext()->d()->strictMode)
+ if (engine->currentContext()->strictMode)
engine->throwTypeError();
return false;
}
ReturnedValue ArrayObject::getLookup(Managed *m, Lookup *l)
{
Scope scope(m->engine());
- ScopedString name(scope, m->engine()->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, m->engine()->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
if (name->equals(m->engine()->id_length)) {
// special case, as the property is on the object itself
l->getter = Lookup::arrayLengthGetter;
if (hasProperty)
*hasProperty = true;
- return getProperty(d()->object, scope.engine->currentContext(), result);
+ ScopedContext ctx(scope, scope.engine->currentContext());
+ return getProperty(d()->object, ctx, result);
}
ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx, QQmlPropertyData *property, bool captureRequired)
return false;
}
- setProperty(object, engine->currentContext(), result, value);
+ Scope scope(engine);
+ ScopedContext ctx(scope, engine->currentContext());
+ setProperty(object, ctx, result, value);
return true;
}
ReturnedValue QObjectMethod::callInternal(CallData *callData)
{
- ExecutionContext *context = engine()->currentContext();
+ Scope scope(engine());
+ ScopedContext context(scope, scope.engine->currentContext());
if (d()->index == DestroyMethod)
return method_destroy(context, callData->args, callData->argc);
else if (d()->index == ToStringMethod)
return Encode::undefined();
QV8Engine *v8Engine = context->d()->engine->v8Engine;
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine);
- QV4::Scope scope(v4);
QQmlPropertyData method;
ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
{
- ExecutionContext *ctx = m->engine()->currentContext();
- Scope scope(ctx);
+ Scope scope(m->engine());
+ ScopedContext ctx(scope, scope.engine->currentContext());
ScopedValue r(scope, callData->argument(0));
ScopedValue f(scope, callData->argument(1));
ReturnedValue Runtime::closure(ExecutionEngine *engine, int functionId)
{
- QV4::Function *clos = engine->currentContext()->d()->compilationUnit->runtimeFunctions[functionId];
+ QV4::Function *clos = engine->currentContext()->compilationUnit->runtimeFunctions[functionId];
Q_ASSERT(clos);
- return FunctionObject::createScriptFunction(engine->currentContext(), clos)->asReturnedValue();
+ Scope scope(engine);
+ return FunctionObject::createScriptFunction(ScopedContext(scope, engine->currentContext()), clos)->asReturnedValue();
}
ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const ValueRef base, const ValueRef index)
ReturnedValue Runtime::deleteMember(ExecutionEngine *engine, const ValueRef base, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
return deleteMemberString(engine, base, name);
}
ReturnedValue Runtime::deleteName(ExecutionEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
- return Encode(engine->currentContext()->deleteProperty(name));
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedContext ctx(scope, engine->currentContext());
+ return Encode(ctx->deleteProperty(name));
}
QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const ValueRef left, const ValueRef right)
void Runtime::setProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex, const ValueRef value)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject o(scope, object->toObject(engine));
if (!o)
return;
void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, const ValueRef value)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
- engine->currentContext()->setProperty(name, value);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedContext ctx(scope, engine->currentContext());
+ ctx->setProperty(name, value);
}
ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const ValueRef object, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
Scoped<Object> o(scope, object);
if (o)
ReturnedValue Runtime::getActivationProperty(ExecutionEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
- return engine->currentContext()->getProperty(name);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedContext ctx(scope, engine->currentContext());
+ return ctx->getProperty(name);
}
#endif // V4_BOOTSTRAP
Scope scope(engine);
Q_ASSERT(callData->thisObject.isUndefined());
- Lookup *l = engine->currentContext()->d()->lookups + index;
+ Lookup *l = engine->currentContext()->lookups + index;
Scoped<FunctionObject> o(scope, l->globalGetter(l, engine));
if (!o)
return engine->throwTypeError();
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
if (o.getPointer() == scope.engine->evalFunction && name->equals(scope.engine->id_eval))
return static_cast<EvalFunction *>(o.getPointer())->evalCall(callData, true);
{
Q_ASSERT(callData->thisObject.isUndefined());
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject base(scope);
Object *baseObj = 0;
- ScopedValue func(scope, engine->currentContext()->getPropertyAndBase(name, baseObj));
+ ScopedContext ctx(scope, engine->currentContext());
+ ScopedValue func(scope, ctx->getPropertyAndBase(name, baseObj));
base.ptr->m = baseObj ? &baseObj->data : 0;
if (scope.engine->hasException)
return Encode::undefined();
ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
Scoped<Object> baseObject(scope, callData->thisObject);
if (!baseObject) {
Q_ASSERT(!callData->thisObject.isEmpty());
ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData)
{
- Lookup *l = engine->currentContext()->d()->lookups + index;
+ Lookup *l = engine->currentContext()->lookups + index;
Value v;
v = l->getter(l, engine, callData->thisObject);
if (!v.isObject())
Scope scope(engine);
Q_ASSERT(callData->thisObject.isUndefined());
- Lookup *l = engine->currentContext()->d()->lookups + index;
+ Lookup *l = engine->currentContext()->lookups + index;
Scoped<Object> f(scope, l->globalGetter(l, engine));
if (!f)
return engine->throwTypeError();
ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
- ScopedValue func(scope, engine->currentContext()->getProperty(name));
+ ScopedContext ctx(scope, engine->currentContext());
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedValue func(scope, ctx->getProperty(name));
if (scope.engine->hasException)
return Encode::undefined();
{
Scope scope(engine);
ScopedObject thisObject(scope, callData->thisObject.toObject(engine));
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
if (scope.engine->hasException)
return Encode::undefined();
ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData)
{
- Lookup *l = engine->currentContext()->d()->lookups + index;
+ Lookup *l = engine->currentContext()->lookups + index;
Value v;
v = l->getter(l, engine, callData->thisObject);
if (!v.isObject())
QV4::ReturnedValue Runtime::typeofName(ExecutionEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
- ScopedValue prop(scope, engine->currentContext()->getProperty(name));
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedContext ctx(scope, engine->currentContext());
+ ScopedValue prop(scope, ctx->getProperty(name));
// typeof doesn't throw. clear any possible exception
scope.engine->hasException = false;
return Runtime::typeofValue(engine, prop);
QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const ValueRef base, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject obj(scope, base->toObject(engine));
if (scope.engine->hasException)
return Encode::undefined();
{
Scope scope(engine);
ScopedObject obj(scope, o->toObject(engine));
- engine->currentContext()->newWithContext(obj);
+ ScopedContext ctx(scope, engine->currentContext());
+ ctx->newWithContext(obj);
}
ReturnedValue Runtime::unwindException(ExecutionEngine *engine)
{
Scope scope(engine);
ScopedValue v(scope, engine->catchException(0));
- ScopedString exceptionVarName(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[exceptionVarNameIndex]);
- engine->currentContext()->newCatchContext(exceptionVarName, v);
+ ScopedString exceptionVarName(scope, engine->currentContext()->compilationUnit->runtimeStrings[exceptionVarNameIndex]);
+ ScopedContext ctx(scope, engine->currentContext());
+ ctx->newCatchContext(exceptionVarName, v);
}
void Runtime::popScope(ExecutionEngine *engine)
void Runtime::declareVar(ExecutionEngine *engine, bool deletable, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
- engine->currentContext()->createMutableBinding(name, deletable);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedContext ctx(scope, engine->currentContext());
+ ctx->createMutableBinding(name, deletable);
}
ReturnedValue Runtime::arrayLiteral(ExecutionEngine *engine, Value *values, uint length)
ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)
{
Scope scope(engine);
- QV4::InternalClass *klass = engine->currentContext()->d()->compilationUnit->runtimeClasses[classId];
+ QV4::InternalClass *klass = engine->currentContext()->compilationUnit->runtimeClasses[classId];
Scoped<Object> o(scope, engine->newObject(klass, engine->objectPrototype.asObject()));
{
QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine)
{
- Q_ASSERT(engine->currentContext()->d()->type >= Heap::ExecutionContext::Type_CallContext);
- CallContext *c = static_cast<CallContext *>(engine->currentContext());
+ Q_ASSERT(engine->currentContext()->type >= Heap::ExecutionContext::Type_CallContext);
+ Scope scope(engine);
+ Scoped<CallContext> c(scope, static_cast<Heap::CallContext *>(engine->currentContext()));
return (engine->memoryManager->alloc<ArgumentsObject>(c))->asReturnedValue();
}
ReturnedValue Runtime::regexpLiteral(ExecutionEngine *engine, int id)
{
- return engine->currentContext()->d()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue();
+ return engine->currentContext()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue();
}
ReturnedValue Runtime::getQmlIdArray(NoThrowEngine *engine)
engine->throwTypeError(QStringLiteral("Cannot read property of null"));
return Encode::undefined();
}
- return QV4::QObjectWrapper::getProperty(wrapper->object(), engine->currentContext(), propertyIndex, captureRequired);
+ ScopedContext ctx(scope, engine->currentContext());
+ return QV4::QObjectWrapper::getProperty(wrapper->object(), ctx, propertyIndex, captureRequired);
}
QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex)
QQmlEngine *qmlEngine = engine->v8Engine->engine();
QQmlData::ensurePropertyCache(qmlEngine, attachedObject);
- return QV4::QObjectWrapper::getProperty(attachedObject, engine->currentContext(), propertyIndex, /*captureRequired*/true);
+ ScopedContext ctx(scope, engine->currentContext());
+ return QV4::QObjectWrapper::getProperty(attachedObject, ctx, propertyIndex, /*captureRequired*/true);
}
ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, bool captureRequired)
scope.engine->throwTypeError(QStringLiteral("Cannot read property of null"));
return Encode::undefined();
}
- return QV4::QObjectWrapper::getProperty(wrapper->singletonObject(), engine->currentContext(), propertyIndex, captureRequired);
+ ScopedContext ctx(scope, engine->currentContext());
+ return QV4::QObjectWrapper::getProperty(wrapper->singletonObject(), ctx, propertyIndex, captureRequired);
}
void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const ValueRef object, int propertyIndex, const ValueRef value)
engine->throwTypeError(QStringLiteral("Cannot write property of null"));
return;
}
- wrapper->setProperty(engine->currentContext(), propertyIndex, value);
+ ScopedContext ctx(scope, engine->currentContext());
+ wrapper->setProperty(ctx, propertyIndex, value);
}
ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine)
QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->currentContext()->d()->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[nameIndex]);
Scoped<QmlContextWrapper> wrapper(scope, engine->qmlContextObject());
return wrapper->qmlSingletonWrapper(engine->v8Engine, name);
}
void Runtime::convertThisToObject(ExecutionEngine *engine)
{
- Value *t = &engine->currentContext()->d()->callData->thisObject;
+ Value *t = &engine->currentContext()->callData->thisObject;
if (t->isObject())
return;
if (t->isNullOrUndefined()) {
savedContext->tag = QV4::Value::Managed_Type;
#endif
}
+ ExecutionContextSaver(Scope &scope, Heap::ExecutionContext *context)
+ : engine(context->engine)
+ , savedContext(scope.alloc(1))
+ {
+ savedContext->m = context;
+#if QT_POINTER_SIZE == 4
+ savedContext->tag = QV4::Value::Managed_Type;
+#endif
+ }
~ExecutionContextSaver()
{
- engine->current = static_cast<ExecutionContext *>(savedContext->asManaged());
+ engine->current = static_cast<Heap::ExecutionContext *>(savedContext->heapObject());
}
};
o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
- o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml);
+ ScopedContext ctx(s, s.engine->currentContext());
+ o->d()->qmlContext = ctx->newQmlContext(o, qml);
s.engine->popContext();
}
o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
- o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml);
+ ScopedContext ctx(s, s.engine->currentContext());
+ o->d()->qmlContext = ctx->newQmlContext(o, qml);
s.engine->popContext();
}
}
if (index < static_cast<uint>(o->d()->value.stringValue()->toQString().length())) {
- if (v4->currentContext()->d()->strictMode)
+ if (v4->currentContext()->strictMode)
v4->throwTypeError();
return false;
}
return;
reject:
- if (scope.engine->currentContext()->d()->strictMode)
+ if (scope.engine->currentContext()->strictMode)
scope.engine->throwTypeError();
}
if (wrapper && wrapper->d()->readOnly) {
QString error = QLatin1String("Invalid write to global property \"") + name->toQString() +
QLatin1Char('"');
- Scoped<String> e(scope, v4->currentContext()->d()->engine->newString(error));
+ Scoped<String> e(scope, v4->currentContext()->engine->newString(error));
v4->throwError(e);
return;
}
case QMetaType::Double:
return QV4::Encode(*reinterpret_cast<const double*>(ptr));
case QMetaType::QString:
- return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue();
+ return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(ptr))->asReturnedValue();
case QMetaType::Float:
return QV4::Encode(*reinterpret_cast<const float*>(ptr));
case QMetaType::Short:
case QMetaType::Double:
return QV4::Encode(*reinterpret_cast<const double*>(data));
case QMetaType::QString:
- return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue();
+ return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast<const QString*>(data))->asReturnedValue();
case QMetaType::Float:
return QV4::Encode(*reinterpret_cast<const float*>(data));
case QMetaType::Short: