From 8b9a17e97c67eac5163b25eab4ededdfdf6e9354 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 Dec 2012 20:48:11 +0100 Subject: [PATCH] Value properties of the Number constructor are readonly See 15.7.3.2 - 15.7.3.6 Change-Id: I39cace57456ecce9532ba6547b3dab5735fd874d Reviewed-by: Erik Verbruggen --- qv4ecmaobjects.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp index 3b042cc..4aa9c44 100644 --- a/qv4ecmaobjects.cpp +++ b/qv4ecmaobjects.cpp @@ -1317,15 +1317,28 @@ Value NumberCtor::call(ExecutionContext *ctx) void NumberPrototype::init(ExecutionContext *ctx, const Value &ctor) { ctor.objectValue()->__put__(ctx, ctx->engine->id_prototype, Value::fromObject(this)); - ctor.objectValue()->__put__(ctx, QStringLiteral("NaN"), Value::fromDouble(qSNaN())); - ctor.objectValue()->__put__(ctx, QStringLiteral("NEGATIVE_INFINITY"), Value::fromDouble(-qInf())); - ctor.objectValue()->__put__(ctx, QStringLiteral("POSITIVE_INFINITY"), Value::fromDouble(qInf())); - ctor.objectValue()->__put__(ctx, QStringLiteral("MAX_VALUE"), Value::fromDouble(1.7976931348623158e+308)); + + PropertyDescriptor desc; + desc.type = PropertyDescriptor::Data; + desc.writable = PropertyDescriptor::Unset; + desc.enumberable = PropertyDescriptor::Unset; + desc.configurable = PropertyDescriptor::Unset; + + desc.value = Value::fromDouble(qSNaN()); + ctor.objectValue()->__defineOwnProperty__(ctx, QStringLiteral("NaN"), &desc); + desc.value = Value::fromDouble(-qInf()); + ctor.objectValue()->__defineOwnProperty__(ctx, QStringLiteral("NEGATIVE_INFINITY"), &desc); + desc.value = Value::fromDouble(qInf()); + ctor.objectValue()->__defineOwnProperty__(ctx, QStringLiteral("POSITIVE_INFINITY"), &desc); + desc.value = Value::fromDouble(1.7976931348623158e+308); + ctor.objectValue()->__defineOwnProperty__(ctx, QStringLiteral("MAX_VALUE"), &desc); + #ifdef __INTEL_COMPILER # pragma warning( push ) # pragma warning(disable: 239) #endif - ctor.objectValue()->__put__(ctx, QStringLiteral("MIN_VALUE"), Value::fromDouble(5e-324)); + desc.value = Value::fromDouble(5e-324); + ctor.objectValue()->__defineOwnProperty__(ctx, QStringLiteral("MIN_VALUE"), &desc); #ifdef __INTEL_COMPILER # pragma warning( pop ) #endif -- 2.7.4