Chromium Code Reviews| Index: src/bootstrapper.cc |
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
| index 82a63f0ae60e1474d5c2a66ecc2c018cea6ea8ff..9796bb18258ac005f70e4bd017e8a4e88b96c3c1 100644 |
| --- a/src/bootstrapper.cc |
| +++ b/src/bootstrapper.cc |
| @@ -1237,6 +1237,62 @@ bool Genesis::InstallNatives() { |
| apply->shared()->set_length(2); |
| } |
| + // Create a constructor for RegExp results (a variant of Array that |
| + // predefines the two properties index and match). |
| + { |
| + // RegExpResult initial map. |
| + |
| + // Find global.Array.prototype to inherit from. |
| + Handle<JSFunction> array_constructor(global_context()->array_function()); |
| + Handle<JSObject> array_prototype( |
| + JSObject::cast(array_constructor->instance_prototype())); |
| + |
| + // Add initial map. |
| + Handle<Map> initial_map = |
| + Factory::NewMap(JS_ARRAY_TYPE, JSArray::kRegExpResultSize); |
| + initial_map->set_constructor(*array_constructor); |
| + |
| + // Set prototype on map. |
| + initial_map->set_non_instance_prototype(false); |
| + initial_map->set_prototype(*array_prototype); |
| + |
| + // Update map with length accessor from Array and add "index" and "input". |
| + Handle<Map> array_map(global_context()->js_array_map()); |
| + Handle<DescriptorArray> array_descriptors( |
| + array_map->instance_descriptors()); |
| + ASSERT_EQ(1, array_descriptors->number_of_descriptors()); |
| + |
| + Handle<DescriptorArray> reresult_descriptors = |
| + Factory::NewDescriptorArray(3); |
| + |
| + reresult_descriptors->CopyFrom(0, *array_descriptors, 0); |
| + |
| + int enum_index = 0; |
| + { |
| + FieldDescriptor index_field(Heap::index_symbol(), |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Move the constant to JSRegExpResult (see comment i
Lasse Reichstein
2010/04/13 09:50:56
Done.
|
| + JSArray::kIndexIndex, |
| + NONE, |
| + enum_index++); |
| + reresult_descriptors->Set(1, &index_field); |
| + } |
| + |
| + { |
| + FieldDescriptor input_field(Heap::input_symbol(), |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Ditto.
Lasse Reichstein
2010/04/13 09:50:56
Done too.
|
| + JSArray::kInputIndex, |
| + NONE, |
| + enum_index++); |
| + reresult_descriptors->Set(2, &input_field); |
| + } |
| + reresult_descriptors->Sort(); |
| + |
| + initial_map->set_inobject_properties(2); |
| + initial_map->set_pre_allocated_property_fields(2); |
| + initial_map->set_unused_property_fields(0); |
| + initial_map->set_instance_descriptors(*reresult_descriptors); |
| + |
| + global_context()->set_regexp_result_map(*initial_map); |
| + } |
| + |
| #ifdef DEBUG |
| builtins->Verify(); |
| #endif |