DescriptorArray::WhitenessWitness witness(*descriptors);
- int index = 0;
-
{ // Add length.
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength));
- CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
{ // Add name.
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName));
- CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
{ // Add arguments.
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionArguments));
- CallbacksDescriptor d(
- *factory()->arguments_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->arguments_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
{ // Add caller.
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionCaller));
- CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->caller_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
if (prototypeMode != DONT_ADD_PROTOTYPE) {
// Add prototype.
attribs = static_cast<PropertyAttributes>(attribs & ~READ_ONLY);
}
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype));
- CallbacksDescriptor d(
- *factory()->prototype_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
+ CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
descriptors->Sort(witness);
DescriptorArray::WhitenessWitness witness(*descriptors);
- int index = 0;
{ // Add length.
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionLength));
- CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->length_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
{ // Add name.
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionName));
- CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->name_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
{ // Add arguments.
Handle<AccessorPair> arguments(factory()->NewAccessorPair());
- CallbacksDescriptor d(
- *factory()->arguments_symbol(), *arguments, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->arguments_symbol(), *arguments, attribs);
+ descriptors->Append(&d, witness);
}
{ // Add caller.
Handle<AccessorPair> caller(factory()->NewAccessorPair());
- CallbacksDescriptor d(
- *factory()->caller_symbol(), *caller, attribs, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attribs);
+ descriptors->Append(&d, witness);
}
if (prototypeMode != DONT_ADD_PROTOTYPE) {
attribs = static_cast<PropertyAttributes>(attribs | READ_ONLY);
}
Handle<Foreign> f(factory()->NewForeign(&Accessors::FunctionPrototype));
- CallbacksDescriptor d(
- *factory()->prototype_symbol(), *f, attribs, index + 1);
- descriptors->Set(index, &d, witness);
+ CallbacksDescriptor d(*factory()->prototype_symbol(), *f, attribs);
+ descriptors->Append(&d, witness);
}
descriptors->Sort(witness);
DescriptorArray::WhitenessWitness witness(*descriptors);
PropertyAttributes final =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
- int index = 0;
{
// ECMA-262, section 15.10.7.1.
FieldDescriptor field(heap->source_symbol(),
JSRegExp::kSourceFieldIndex,
- final,
- index + 1);
- descriptors->Set(index, &field, witness);
- ++index;
+ final);
+ descriptors->Append(&field, witness);
}
{
// ECMA-262, section 15.10.7.2.
FieldDescriptor field(heap->global_symbol(),
JSRegExp::kGlobalFieldIndex,
- final,
- index + 1);
- descriptors->Set(index, &field, witness);
- ++index;
+ final);
+ descriptors->Append(&field, witness);
}
{
// ECMA-262, section 15.10.7.3.
FieldDescriptor field(heap->ignore_case_symbol(),
JSRegExp::kIgnoreCaseFieldIndex,
- final,
- index + 1);
- descriptors->Set(index, &field, witness);
- ++index;
+ final);
+ descriptors->Append(&field, witness);
}
{
// ECMA-262, section 15.10.7.4.
FieldDescriptor field(heap->multiline_symbol(),
JSRegExp::kMultilineFieldIndex,
- final,
- index + 1);
- descriptors->Set(index, &field, witness);
- ++index;
+ final);
+ descriptors->Append(&field, witness);
}
{
// ECMA-262, section 15.10.7.5.
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
FieldDescriptor field(heap->last_index_symbol(),
JSRegExp::kLastIndexFieldIndex,
- writable,
- index + 1);
- descriptors->Set(index, &field, witness);
+ writable);
+ descriptors->Append(&field, witness);
}
descriptors->Sort(witness);
// Create the descriptor array for the arguments object.
Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
DescriptorArray::WhitenessWitness witness(*descriptors);
- int index = 0;
{ // length
- FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM, index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
+ descriptors->Append(&d, witness);
}
{ // callee
CallbacksDescriptor d(*factory->callee_symbol(),
*callee,
- attributes,
- index + 1);
- descriptors->Set(index, &d, witness);
- ++index;
+ attributes);
+ descriptors->Append(&d, witness);
}
{ // caller
CallbacksDescriptor d(*factory->caller_symbol(),
*caller,
- attributes,
- index + 1);
- descriptors->Set(index, &d, witness);
+ attributes);
+ descriptors->Append(&d, witness);
}
descriptors->Sort(witness);
reresult_descriptors->CopyFrom(0, *array_descriptors, old, witness);
if (copy_result->IsFailure()) return false;
- int index = 1;
+ reresult_descriptors->SetLastAdded(0);
+
{
FieldDescriptor index_field(heap()->index_symbol(),
JSRegExpResult::kIndexIndex,
- NONE,
- index + 1);
- reresult_descriptors->Set(index, &index_field, witness);
- ++index;
+ NONE);
+ reresult_descriptors->Append(&index_field, witness);
}
{
FieldDescriptor input_field(heap()->input_symbol(),
JSRegExpResult::kInputIndex,
- NONE,
- index + 1);
- reresult_descriptors->Set(index, &input_field, witness);
+ NONE);
+ reresult_descriptors->Append(&input_field, witness);
}
reresult_descriptors->Sort(witness);
String* key,
Object* value,
PropertyAttributes attributes) {
- CallbacksDescriptor desc(key, value, attributes, 0);
+ CallbacksDescriptor desc(key, value, attributes);
MaybeObject* obj = array->CopyAdd(&desc);
return obj;
}
DescriptorArray::WhitenessWitness witness(*result);
// Copy the descriptors from the array.
- for (int i = 0; i < descriptor_count; i++) {
- DescriptorArray::CopyFrom(result, i, array, i, witness);
+ if (0 < descriptor_count) {
+ result->SetLastAdded(array->LastAdded());
+ for (int i = 0; i < descriptor_count; i++) {
+ DescriptorArray::CopyFrom(result, i, array, i, witness);
+ }
}
// Fill in new callback descriptors. Process the callbacks from
// back to front so that the last callback with a given name takes
// precedence over previously added callbacks with that name.
- int added_descriptor_count = descriptor_count;
- int next_enum = array->NextEnumerationIndex();
for (int i = nof_callbacks - 1; i >= 0; i--) {
Handle<AccessorInfo> entry =
Handle<AccessorInfo>(AccessorInfo::cast(callbacks.get(i)));
Handle<String> key =
SymbolFromString(Handle<String>(String::cast(entry->name())));
// Check if a descriptor with this name already exists before writing.
- if (LinearSearch(*result, EXPECT_UNSORTED, *key, added_descriptor_count) ==
+ if (LinearSearch(*result,
+ EXPECT_UNSORTED,
+ *key,
+ result->NumberOfSetDescriptors()) ==
DescriptorArray::kNotFound) {
- CallbacksDescriptor desc(*key,
- *entry,
- entry->property_attributes(),
- next_enum++);
- result->Set(added_descriptor_count, &desc, witness);
- added_descriptor_count++;
+ CallbacksDescriptor desc(*key, *entry, entry->property_attributes());
+ result->Append(&desc, witness);
}
}
+ int new_number_of_descriptors = result->NumberOfSetDescriptors();
// Return the old descriptor array if there were no new elements.
- if (added_descriptor_count == descriptor_count) return array;
+ if (new_number_of_descriptors == descriptor_count) return array;
// If duplicates were detected, allocate a result of the right size
// and transfer the elements.
- if (added_descriptor_count < result->length()) {
+ if (new_number_of_descriptors < result->length()) {
Handle<DescriptorArray> new_result =
- NewDescriptorArray(added_descriptor_count);
- for (int i = 0; i < added_descriptor_count; i++) {
+ NewDescriptorArray(new_number_of_descriptors);
+ for (int i = 0; i < new_number_of_descriptors; i++) {
DescriptorArray::CopyFrom(new_result, i, result, i, witness);
}
result = new_result;
// Sort the result before returning.
result->Sort(witness);
- ASSERT(result->NextEnumerationIndex() == next_enum);
return result;
}