From 2d8bd32e5d0072213db9f2a3cf3e33589b7a9c05 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 Dec 2012 19:41:10 +0100 Subject: [PATCH] Fix some smaller bugs in toPropertyDescriptor This should now be fully compliant with 8.10.5 Change-Id: I4afacb95a9ec0eb9366181da9dbeb74a5c34c55b Reviewed-by: Simon Hausmann --- qv4ecmaobjects.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp index 82d20f7..3b042cc 100644 --- a/qv4ecmaobjects.cpp +++ b/qv4ecmaobjects.cpp @@ -892,23 +892,13 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope desc->configurable = PropertyDescriptor::Undefined; if (o->__hasProperty__(ctx, ctx->engine->id_configurable)) - desc->enumberable = __qmljs_to_boolean(o->__get__(ctx, ctx->engine->id_configurable), ctx) ? PropertyDescriptor::Set : PropertyDescriptor::Unset; - - desc->writable = PropertyDescriptor::Undefined; - if (o->__hasProperty__(ctx, ctx->engine->id_writable)) - desc->enumberable = __qmljs_to_boolean(o->__get__(ctx, ctx->engine->id_writable), ctx) ? PropertyDescriptor::Set : PropertyDescriptor::Unset; - - if (o->__hasProperty__(ctx, ctx->engine->id_value)) { - desc->value = o->__get__(ctx, ctx->engine->id_value); - desc->type = PropertyDescriptor::Data; - } + desc->configurable = __qmljs_to_boolean(o->__get__(ctx, ctx->engine->id_configurable), ctx) ? PropertyDescriptor::Set : PropertyDescriptor::Unset; + desc->get = 0; if (o->__hasProperty__(ctx, ctx->engine->id_get)) { Value get = o->__get__(ctx, ctx->engine->id_get); FunctionObject *f = get.asFunctionObject(); if (f) { - if (desc->isWritable() || desc->isData()) - __qmljs_throw_type_error(ctx); desc->get = f; } else if (!get.isUndefined()) { __qmljs_throw_type_error(ctx); @@ -918,12 +908,11 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope desc->type = PropertyDescriptor::Accessor; } + desc->set = 0; if (o->__hasProperty__(ctx, ctx->engine->id_set)) { Value get = o->__get__(ctx, ctx->engine->id_set); FunctionObject *f = get.asFunctionObject(); if (f) { - if (desc->isWritable() || desc->isData()) - __qmljs_throw_type_error(ctx); desc->set = f; } else if (!get.isUndefined()) { __qmljs_throw_type_error(ctx); @@ -932,6 +921,24 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, Value v, Prope } desc->type = PropertyDescriptor::Accessor; } + + desc->writable = PropertyDescriptor::Undefined; + if (o->__hasProperty__(ctx, ctx->engine->id_writable)) { + if (desc->isAccessor()) + __qmljs_throw_type_error(ctx); + desc->writable = __qmljs_to_boolean(o->__get__(ctx, ctx->engine->id_writable), ctx) ? PropertyDescriptor::Set : PropertyDescriptor::Unset; + // writable forces it to be a data descriptor + desc->type = PropertyDescriptor::Data; + desc->value = Value::undefinedValue(); + } + + if (o->__hasProperty__(ctx, ctx->engine->id_value)) { + if (desc->isAccessor()) + __qmljs_throw_type_error(ctx); + desc->value = o->__get__(ctx, ctx->engine->id_value); + desc->type = PropertyDescriptor::Data; + } + } -- 2.7.4