mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
Fixed dynamic lookup of static slots. Added code to compare strings.
This commit is contained in:
parent
b1350d87b6
commit
d9bf640477
@ -234,7 +234,7 @@ static JSValue less_Default(const JSValue& r1, const JSValue& r2)
|
||||
JSValue rv = r2.toPrimitive(JSValue::Number);
|
||||
if (lv.isString() && rv.isString()) {
|
||||
// XXX FIXME urgh, call w_strcmp ??? on a JSString ???
|
||||
return JSValue();
|
||||
return JSValue(rv.string->compare(*lv.string));
|
||||
}
|
||||
else {
|
||||
lv = lv.toNumber();
|
||||
@ -690,7 +690,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
// REVISIT: should signal error if slot doesn't exist.
|
||||
JSClass* thisClass = dynamic_cast<JSClass*>(value.type);
|
||||
if (thisClass && thisClass->hasStatic(*src2(gp))) {
|
||||
const JSSlot& slot = thisClass->getSlot(*src2(gp));
|
||||
const JSSlot& slot = thisClass->getStatic(*src2(gp));
|
||||
(*registers)[dst(gp).first] = (*thisClass)[slot.mIndex];
|
||||
}
|
||||
} else {
|
||||
@ -709,7 +709,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
// REVISIT: should signal error if slot doesn't exist.
|
||||
JSClass* thisClass = dynamic_cast<JSClass*>(value.object);
|
||||
if (thisClass && thisClass->hasStatic(*src1(sp))) {
|
||||
const JSSlot& slot = thisClass->getSlot(*src1(sp));
|
||||
const JSSlot& slot = thisClass->getStatic(*src1(sp));
|
||||
(*thisClass)[slot.mIndex] = (*registers)[src2(sp).first];
|
||||
}
|
||||
} else {
|
||||
|
@ -195,14 +195,20 @@ namespace JSClasses {
|
||||
public:
|
||||
void* operator new(size_t n, JSClass* thisClass)
|
||||
{
|
||||
return gc_base::operator new((n - sizeof(JSValue)) + thisClass->getSlotCount() * sizeof(JSValue));
|
||||
uint32 slotCount = thisClass->getSlotCount();
|
||||
if (slotCount > 0) n += sizeof(JSValue) * (slotCount - 1);
|
||||
return gc_base::operator new(n);
|
||||
}
|
||||
|
||||
JSInstance(JSClass* thisClass)
|
||||
{
|
||||
mType = thisClass;
|
||||
// initialize all slots with undefined.
|
||||
std::uninitialized_fill(&mSlots[1], &mSlots[0] + thisClass->getSlotCount(), JSTypes::kUndefinedValue);
|
||||
// initialize extra slots with undefined.
|
||||
uint32 slotCount = thisClass->getSlotCount();
|
||||
if (slotCount > 0) {
|
||||
std::uninitialized_fill(&mSlots[1], &mSlots[1] + (slotCount - 1),
|
||||
JSTypes::kUndefinedValue);
|
||||
}
|
||||
// for grins, use the prototype link to access methods.
|
||||
setPrototype(thisClass->getScope());
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ static JSValue less_Default(const JSValue& r1, const JSValue& r2)
|
||||
JSValue rv = r2.toPrimitive(JSValue::Number);
|
||||
if (lv.isString() && rv.isString()) {
|
||||
// XXX FIXME urgh, call w_strcmp ??? on a JSString ???
|
||||
return JSValue();
|
||||
return JSValue(rv.string->compare(*lv.string));
|
||||
}
|
||||
else {
|
||||
lv = lv.toNumber();
|
||||
@ -690,7 +690,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
// REVISIT: should signal error if slot doesn't exist.
|
||||
JSClass* thisClass = dynamic_cast<JSClass*>(value.type);
|
||||
if (thisClass && thisClass->hasStatic(*src2(gp))) {
|
||||
const JSSlot& slot = thisClass->getSlot(*src2(gp));
|
||||
const JSSlot& slot = thisClass->getStatic(*src2(gp));
|
||||
(*registers)[dst(gp).first] = (*thisClass)[slot.mIndex];
|
||||
}
|
||||
} else {
|
||||
@ -709,7 +709,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
// REVISIT: should signal error if slot doesn't exist.
|
||||
JSClass* thisClass = dynamic_cast<JSClass*>(value.object);
|
||||
if (thisClass && thisClass->hasStatic(*src1(sp))) {
|
||||
const JSSlot& slot = thisClass->getSlot(*src1(sp));
|
||||
const JSSlot& slot = thisClass->getStatic(*src1(sp));
|
||||
(*thisClass)[slot.mIndex] = (*registers)[src2(sp).first];
|
||||
}
|
||||
} else {
|
||||
|
@ -195,14 +195,20 @@ namespace JSClasses {
|
||||
public:
|
||||
void* operator new(size_t n, JSClass* thisClass)
|
||||
{
|
||||
return gc_base::operator new((n - sizeof(JSValue)) + thisClass->getSlotCount() * sizeof(JSValue));
|
||||
uint32 slotCount = thisClass->getSlotCount();
|
||||
if (slotCount > 0) n += sizeof(JSValue) * (slotCount - 1);
|
||||
return gc_base::operator new(n);
|
||||
}
|
||||
|
||||
JSInstance(JSClass* thisClass)
|
||||
{
|
||||
mType = thisClass;
|
||||
// initialize all slots with undefined.
|
||||
std::uninitialized_fill(&mSlots[1], &mSlots[0] + thisClass->getSlotCount(), JSTypes::kUndefinedValue);
|
||||
// initialize extra slots with undefined.
|
||||
uint32 slotCount = thisClass->getSlotCount();
|
||||
if (slotCount > 0) {
|
||||
std::uninitialized_fill(&mSlots[1], &mSlots[1] + (slotCount - 1),
|
||||
JSTypes::kUndefinedValue);
|
||||
}
|
||||
// for grins, use the prototype link to access methods.
|
||||
setPrototype(thisClass->getScope());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user