зеркало из https://github.com/mozilla/gecko-dev.git
Fixed New default constructor. stringToDouble semantics.
This commit is contained in:
Родитель
ed1163f000
Коммит
138b35a15b
|
@ -805,12 +805,11 @@ namespace MetaData {
|
|||
}
|
||||
|
||||
// XXX Default construction of an instance of the class
|
||||
// that is the value at the top of the execution stack
|
||||
js2val JS2Engine::defaultConstructor(JS2Metadata *meta, const js2val /* thisValue */, js2val /* argv */ [], uint32 /* argc */)
|
||||
// that is the value of the passed in 'this'
|
||||
js2val JS2Engine::defaultConstructor(JS2Metadata *meta, const js2val thisValue, js2val /* argv */ [], uint32 /* argc */)
|
||||
{
|
||||
js2val v = meta->engine->top();
|
||||
ASSERT(JS2VAL_IS_OBJECT(v) && !JS2VAL_IS_NULL(v));
|
||||
JS2Object *obj = JS2VAL_TO_OBJECT(v);
|
||||
ASSERT(JS2VAL_IS_OBJECT(thisValue) && !JS2VAL_IS_NULL(thisValue));
|
||||
JS2Object *obj = JS2VAL_TO_OBJECT(thisValue);
|
||||
ASSERT(obj->kind == ClassKind);
|
||||
JS2Class *c = checked_cast<JS2Class *>(obj);
|
||||
if (c->prototype)
|
||||
|
|
|
@ -459,8 +459,23 @@ namespace MetaData {
|
|||
return (JS2VAL_TO_BOOLEAN(x)) ? 1.0 : 0.0;
|
||||
if (JS2VAL_IS_STRING(x)) {
|
||||
String *str = JS2VAL_TO_STRING(x);
|
||||
uint32 length = str->length();
|
||||
if (length == 0)
|
||||
return 0.0;
|
||||
const char16 *numEnd;
|
||||
return stringToDouble(str->data(), str->data() + str->length(), numEnd);
|
||||
// if the string begins with '0X' or '0x' (after white space), then
|
||||
// read it as a hex integer.
|
||||
const char16 *strStart = str->data();
|
||||
const char16 *strEnd = strStart + length;
|
||||
const char16 *str1 = skipWhiteSpace(strStart, strEnd);
|
||||
if ((*str1 == '0') && ((str1[1] == 'x') || (str1[1] == 'X')))
|
||||
return stringToInteger(str1, strEnd, numEnd, 16);
|
||||
else {
|
||||
float64 d = stringToDouble(str1, strEnd, numEnd);
|
||||
if (numEnd == str1)
|
||||
return nan;
|
||||
return d;
|
||||
}
|
||||
}
|
||||
if (JS2VAL_IS_INACCESSIBLE(x))
|
||||
reportError(Exception::compileExpressionError, "Inappropriate compile time expression", engine->errorPos());
|
||||
|
|
|
@ -38,11 +38,13 @@
|
|||
uint16 argCount = BytecodeContainer::getShort(pc);
|
||||
pc += sizeof(uint16);
|
||||
a = top(argCount + 1);
|
||||
ASSERT(JS2VAL_IS_OBJECT(a) && !JS2VAL_IS_NULL(a));
|
||||
if (!JS2VAL_IS_OBJECT(a) || JS2VAL_IS_NULL(a)) {
|
||||
meta->reportError(Exception::badValueError, "object is not a constructor", errorPos());
|
||||
}
|
||||
JS2Object *obj = JS2VAL_TO_OBJECT(a);
|
||||
if (obj->kind == ClassKind) {
|
||||
JS2Class *c = checked_cast<JS2Class *>(obj);
|
||||
a = c->construct(meta, JS2VAL_NULL, base(argCount), argCount);
|
||||
a = c->construct(meta, a, base(argCount), argCount);
|
||||
pop(argCount + 1);
|
||||
push(a);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче