diff options
author | Lars Knoll <[email protected]> | 2013-09-18 15:34:13 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-09-22 01:06:20 +0200 |
commit | 700ba1bcb39e082049c96fafdfaccfe5d83cd77e (patch) | |
tree | d21da27b94a927377ba2c6efd7c3af731d890b19 /src/qml/jsruntime/qv4context.cpp | |
parent | 1aa618970a9bed46123d0648500e957688d725ec (diff) |
Use a StringRef for Managed::get()
also store "toString" and "valueOf" as identifiers
in the engine and fix two places where we compared
strings the wrong way.
Change-Id: I70612221e72d43ed0e3c496e4209681bf254cded
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4context.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 449ec21b05..1da2499ec5 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -417,7 +417,8 @@ ReturnedValue ExecutionContext::getProperty(String *name) { Scope scope(this); ScopedValue v(scope); - name->makeIdentifier(); + ScopedString n(scope, name); + n->makeIdentifier(); if (name->isEqualTo(engine->id_this)) return thisObject.asReturnedValue(); @@ -429,7 +430,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) Object *w = static_cast<WithContext *>(ctx)->withObject; hasWith = true; bool hasProperty = false; - v = w->get(name, &hasProperty); + v = w->get(n, &hasProperty); if (hasProperty) { return v.asReturnedValue(); } @@ -456,7 +457,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) } if (c->activation) { bool hasProperty = false; - v = c->activation->get(name, &hasProperty); + v = c->activation->get(n, &hasProperty); if (hasProperty) return v.asReturnedValue(); } @@ -468,23 +469,23 @@ ReturnedValue ExecutionContext::getProperty(String *name) else if (ctx->type == Type_GlobalContext) { GlobalContext *g = static_cast<GlobalContext *>(ctx); bool hasProperty = false; - v = g->global->get(name, &hasProperty); + v = g->global->get(n, &hasProperty); if (hasProperty) return v.asReturnedValue(); } } - Scoped<String> n(scope, name); throwReferenceError(n); - return Value::undefinedValue().asReturnedValue(); + return 0; } ReturnedValue ExecutionContext::getPropertyNoThrow(String *name) { Scope scope(this); ScopedValue v(scope); - name->makeIdentifier(); + ScopedString n(scope, name); + n->makeIdentifier(); - if (name->isEqualTo(engine->id_this)) + if (n->isEqualTo(engine->id_this)) return thisObject.asReturnedValue(); bool hasWith = false; @@ -494,7 +495,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(String *name) Object *w = static_cast<WithContext *>(ctx)->withObject; hasWith = true; bool hasProperty = false; - v = w->get(name, &hasProperty); + v = w->get(n, &hasProperty); if (hasProperty) { return v.asReturnedValue(); } @@ -521,7 +522,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(String *name) } if (c->activation) { bool hasProperty = false; - v = c->activation->get(name, &hasProperty); + v = c->activation->get(n, &hasProperty); if (hasProperty) return v.asReturnedValue(); } @@ -533,7 +534,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(String *name) else if (ctx->type == Type_GlobalContext) { GlobalContext *g = static_cast<GlobalContext *>(ctx); bool hasProperty = false; - v = g->global->get(name, &hasProperty); + v = g->global->get(n, &hasProperty); if (hasProperty) return v.asReturnedValue(); } @@ -545,10 +546,11 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base) { Scope scope(this); ScopedValue v(scope); + ScopedString n(scope, name); *base = 0; - name->makeIdentifier(); + n->makeIdentifier(); - if (name->isEqualTo(engine->id_this)) + if (n->isEqualTo(engine->id_this)) return thisObject.asReturnedValue(); bool hasWith = false; @@ -558,7 +560,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base) Object *w = static_cast<WithContext *>(ctx)->withObject; hasWith = true; bool hasProperty = false; - v = w->get(name, &hasProperty); + v = w->get(n, &hasProperty); if (hasProperty) { *base = w; return v.asReturnedValue(); @@ -586,7 +588,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base) } if (c->activation) { bool hasProperty = false; - v = c->activation->get(name, &hasProperty); + v = c->activation->get(n, &hasProperty); if (hasProperty) { if (ctx->type == Type_QmlContext) *base = c->activation; @@ -601,14 +603,13 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base) else if (ctx->type == Type_GlobalContext) { GlobalContext *g = static_cast<GlobalContext *>(ctx); bool hasProperty = false; - v = g->global->get(name, &hasProperty); + v = g->global->get(n, &hasProperty); if (hasProperty) return v.asReturnedValue(); } } - Scoped<String> n(scope, name); throwReferenceError(n); - return Value::undefinedValue().asReturnedValue(); + return 0; } |