aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4context.cpp60
-rw-r--r--src/qml/jsruntime/qv4context_p.h6
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp12
3 files changed, 40 insertions, 38 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 1e42a186a0..a8cdf30b16 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -403,12 +403,12 @@ void ExecutionContext::setProperty(String *name, const Value& value)
engine->globalObject->put(name, value);
}
-Value ExecutionContext::getProperty(String *name)
+ReturnedValue ExecutionContext::getProperty(String *name)
{
name->makeIdentifier();
if (name->isEqualTo(engine->id_this))
- return thisObject;
+ return thisObject.asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
@@ -419,7 +419,7 @@ Value ExecutionContext::getProperty(String *name)
bool hasProperty = false;
Value v = w->get(name, &hasProperty);
if (hasProperty) {
- return v;
+ return v.asReturnedValue();
}
continue;
}
@@ -428,7 +428,7 @@ Value ExecutionContext::getProperty(String *name)
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
if (c->exceptionVarName->isEqualTo(name))
- return c->exceptionValue;
+ return c->exceptionValue.asReturnedValue();
}
else if (ctx->type >= Type_CallContext) {
@@ -437,20 +437,20 @@ Value ExecutionContext::getProperty(String *name)
if (f->needsActivation || hasWith || hasCatchScope) {
for (unsigned int i = 0; i < f->varCount; ++i)
if (f->varList[i]->isEqualTo(name))
- return c->locals[i];
+ return c->locals[i].asReturnedValue();
for (int i = (int)f->formalParameterCount - 1; i >= 0; --i)
if (f->formalParameterList[i]->isEqualTo(name))
- return c->arguments[i];
+ return c->arguments[i].asReturnedValue();
}
if (c->activation) {
bool hasProperty = false;
Value v = c->activation->get(name, &hasProperty);
if (hasProperty)
- return v;
+ return v.asReturnedValue();
}
if (f->function && f->function->isNamedExpression()
&& name->isEqualTo(f->function->name))
- return Value::fromObject(c->function);
+ return Value::fromObject(c->function).asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
@@ -458,19 +458,19 @@ Value ExecutionContext::getProperty(String *name)
bool hasProperty = false;
Value v = g->global->get(name, &hasProperty);
if (hasProperty)
- return v;
+ return v.asReturnedValue();
}
}
throwReferenceError(Value::fromString(name));
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
-Value ExecutionContext::getPropertyNoThrow(String *name)
+ReturnedValue ExecutionContext::getPropertyNoThrow(String *name)
{
name->makeIdentifier();
if (name->isEqualTo(engine->id_this))
- return thisObject;
+ return thisObject.asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
@@ -481,7 +481,7 @@ Value ExecutionContext::getPropertyNoThrow(String *name)
bool hasProperty = false;
Value v = w->get(name, &hasProperty);
if (hasProperty) {
- return v;
+ return v.asReturnedValue();
}
continue;
}
@@ -490,7 +490,7 @@ Value ExecutionContext::getPropertyNoThrow(String *name)
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
if (c->exceptionVarName->isEqualTo(name))
- return c->exceptionValue;
+ return c->exceptionValue.asReturnedValue();
}
else if (ctx->type >= Type_CallContext) {
@@ -499,20 +499,20 @@ Value ExecutionContext::getPropertyNoThrow(String *name)
if (f->needsActivation || hasWith || hasCatchScope) {
for (unsigned int i = 0; i < f->varCount; ++i)
if (f->varList[i]->isEqualTo(name))
- return c->locals[i];
+ return c->locals[i].asReturnedValue();
for (int i = (int)f->formalParameterCount - 1; i >= 0; --i)
if (f->formalParameterList[i]->isEqualTo(name))
- return c->arguments[i];
+ return c->arguments[i].asReturnedValue();
}
if (c->activation) {
bool hasProperty = false;
Value v = c->activation->get(name, &hasProperty);
if (hasProperty)
- return v;
+ return v.asReturnedValue();
}
if (f->function && f->function->isNamedExpression()
&& name->isEqualTo(f->function->name))
- return Value::fromObject(c->function);
+ return Value::fromObject(c->function).asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
@@ -520,19 +520,19 @@ Value ExecutionContext::getPropertyNoThrow(String *name)
bool hasProperty = false;
Value v = g->global->get(name, &hasProperty);
if (hasProperty)
- return v;
+ return v.asReturnedValue();
}
}
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
-Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
+ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base)
{
*base = 0;
name->makeIdentifier();
if (name->isEqualTo(engine->id_this))
- return thisObject;
+ return thisObject.asReturnedValue();
bool hasWith = false;
bool hasCatchScope = false;
@@ -544,7 +544,7 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
Value v = w->get(name, &hasProperty);
if (hasProperty) {
*base = w;
- return v;
+ return v.asReturnedValue();
}
continue;
}
@@ -553,7 +553,7 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
if (c->exceptionVarName->isEqualTo(name))
- return c->exceptionValue;
+ return c->exceptionValue.asReturnedValue();
}
else if (ctx->type >= Type_CallContext) {
@@ -562,10 +562,10 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
if (f->needsActivation || hasWith || hasCatchScope) {
for (unsigned int i = 0; i < f->varCount; ++i)
if (f->varList[i]->isEqualTo(name))
- return c->locals[i];
+ return c->locals[i].asReturnedValue();
for (int i = (int)f->formalParameterCount - 1; i >= 0; --i)
if (f->formalParameterList[i]->isEqualTo(name))
- return c->arguments[i];
+ return c->arguments[i].asReturnedValue();
}
if (c->activation) {
bool hasProperty = false;
@@ -573,12 +573,12 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
if (hasProperty) {
if (ctx->type == Type_QmlContext)
*base = c->activation;
- return v;
+ return v.asReturnedValue();
}
}
if (f->function && f->function->isNamedExpression()
&& name->isEqualTo(f->function->name))
- return Value::fromObject(c->function);
+ return Value::fromObject(c->function).asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
@@ -586,11 +586,11 @@ Value ExecutionContext::getPropertyAndBase(String *name, Object **base)
bool hasProperty = false;
Value v = g->global->get(name, &hasProperty);
if (hasProperty)
- return v;
+ return v.asReturnedValue();
}
}
throwReferenceError(Value::fromString(name));
- return Value::undefinedValue();
+ return Value::undefinedValue().asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index fe10e33c5e..8ebffea981 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -142,9 +142,9 @@ struct Q_QML_EXPORT ExecutionContext
void Q_NORETURN throwUnimplemented(const QString &message);
void setProperty(String *name, const Value &value);
- Value getProperty(String *name);
- Value getPropertyNoThrow(String *name);
- Value getPropertyAndBase(String *name, Object **base);
+ ReturnedValue getProperty(String *name);
+ ReturnedValue getPropertyNoThrow(String *name);
+ ReturnedValue getPropertyAndBase(String *name, Object **base);
bool deleteProperty(String *name);
inline Value argument(unsigned int index = 0);
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 6c3276cd86..6771ee752f 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -782,7 +782,7 @@ ReturnedValue __qmljs_get_property(ExecutionContext *ctx, const ValueRef object,
ReturnedValue __qmljs_get_activation_property(ExecutionContext *ctx, String *name)
{
- return ctx->getProperty(name).asReturnedValue();
+ return ctx->getProperty(name);
}
uint __qmljs_equal_helper(const ValueRef x, const ValueRef y)
@@ -949,13 +949,14 @@ ReturnedValue __qmljs_call_global_lookup(ExecutionContext *context, uint index,
ReturnedValue __qmljs_call_activation_property(ExecutionContext *context, String *name, CallDataRef callData)
{
Q_ASSERT(callData->thisObject.isUndefined());
+ ValueScope scope(context);
Object *base;
- Value func = context->getPropertyAndBase(name, &base);
+ ScopedValue func(scope, context->getPropertyAndBase(name, &base));
if (base)
callData->thisObject = Value::fromObject(base);
- FunctionObject *o = func.asFunctionObject();
+ FunctionObject *o = func->asFunctionObject();
if (!o) {
QString objectAsString = QStringLiteral("[null]");
if (base)
@@ -1048,8 +1049,9 @@ ReturnedValue __qmljs_construct_global_lookup(ExecutionContext *context, uint in
ReturnedValue __qmljs_construct_activation_property(ExecutionContext *context, String *name, CallDataRef callData)
{
- Value func = context->getProperty(name);
- Object *f = func.asObject();
+ ValueScope scope(context);
+ ScopedValue func(scope, context->getProperty(name));
+ Object *f = func->asObject();
if (!f)
context->throwTypeError();