mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 04:11:30 +00:00
Move ListImplementation from coreimpl to core, as a private member.
BUG= Review URL: https://codereview.chromium.org//11189141 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14274 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
f35e4c5fcf
commit
dbbf15abd8
|
@ -148,3 +148,17 @@ patch class _StopwatchImpl {
|
|||
patch static int _frequency() => 1000;
|
||||
patch static int _now() => Primitives.dateNow();
|
||||
}
|
||||
|
||||
|
||||
// Patch for List implementation.
|
||||
patch class _ListImpl<E> {
|
||||
patch factory List([int length]) => Primitives.newList(length);
|
||||
|
||||
patch factory List.from(Iterable<E> other) {
|
||||
var result = new List();
|
||||
for (var element in other) {
|
||||
result.add(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,22 +53,6 @@ patch class StringImplementation {
|
|||
}
|
||||
|
||||
|
||||
// Patch for List implementation.
|
||||
// TODO(ager): Split out into date_patch.dart and allow #source
|
||||
// in patch files?
|
||||
patch class ListImplementation<E> {
|
||||
patch factory List([int length]) => Primitives.newList(length);
|
||||
|
||||
patch static List _from(Iterable other) {
|
||||
List result = new List();
|
||||
for (var element in other) {
|
||||
result.add(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Patch for RegExp implementation.
|
||||
// TODO(ager): Split out into regexp_patch.dart and allow #source in
|
||||
// patch files?
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* fixed size or extendable.
|
||||
*/
|
||||
interface List<E> extends Collection<E>, Sequence<E>
|
||||
default ListImplementation<E> {
|
||||
default _ListImpl<E> {
|
||||
/**
|
||||
* Creates a list of the given [length].
|
||||
*
|
||||
|
@ -174,3 +174,20 @@ interface List<E> extends Collection<E>, Sequence<E>
|
|||
*/
|
||||
void insertRange(int start, int length, [E initialValue]);
|
||||
}
|
||||
|
||||
class _ListImpl<E> {
|
||||
/**
|
||||
* Factory implementation of List().
|
||||
*
|
||||
* Creates a list of the given [length].
|
||||
*/
|
||||
external factory List([int length]);
|
||||
|
||||
/**
|
||||
* Factory implementation of List.from().
|
||||
*
|
||||
* Creates a list with the elements of [other]. The order in
|
||||
* the list will be the order provided by the iterator of [other].
|
||||
*/
|
||||
external factory List.from(Iterable<E> other);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,5 @@
|
|||
|
||||
#source("hash_map_set.dart");
|
||||
#source("linked_hash_map.dart");
|
||||
#source("list.dart");
|
||||
#source("regexp.dart");
|
||||
#source("string.dart");
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
'sources': [
|
||||
'hash_map_set.dart',
|
||||
'linked_hash_map.dart',
|
||||
'list.dart',
|
||||
'regexp.dart',
|
||||
'string.dart',
|
||||
],
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* A [List] is an indexable collection with a length. It can be of
|
||||
* fixed size or extendable.
|
||||
*/
|
||||
class ListImplementation<E> {
|
||||
/**
|
||||
* Factory implementation of List().
|
||||
*
|
||||
* Creates a list of the given [length].
|
||||
*/
|
||||
external factory List([int length]);
|
||||
|
||||
/**
|
||||
* Factory implementation of List.from().
|
||||
*
|
||||
* Creates a list with the elements of [other]. The order in
|
||||
* the list will be the order provided by the iterator of [other].
|
||||
*/
|
||||
factory List.from(Iterable<E> other) {
|
||||
// TODO(ajohnsen): Make external once the vm can handle it, so we don't
|
||||
// lose generic type information.
|
||||
// Issue: #4727
|
||||
return _from(other);
|
||||
}
|
||||
|
||||
external static List _from(Iterable other);
|
||||
}
|
|
@ -23,17 +23,17 @@ void FUNCTION_NAME(Common_IsBuiltinList)(Dart_NativeArguments args) {
|
|||
// If we have not cached the class pointers in the isolate data,
|
||||
// look them up and cache them now.
|
||||
if (object_array_class == NULL) {
|
||||
Dart_Handle coreimpl_lib =
|
||||
Dart_LookupLibrary(Dart_NewString("dart:coreimpl"));
|
||||
ASSERT(!Dart_IsError(coreimpl_lib));
|
||||
Dart_Handle core_lib =
|
||||
Dart_LookupLibrary(Dart_NewString("dart:core"));
|
||||
ASSERT(!Dart_IsError(core_lib));
|
||||
object_array_class =
|
||||
Dart_GetClass(coreimpl_lib, Dart_NewString("_ObjectArray"));
|
||||
Dart_GetClass(core_lib, Dart_NewString("_ObjectArray"));
|
||||
ASSERT(!Dart_IsError(object_array_class));
|
||||
immutable_array_class =
|
||||
Dart_GetClass(coreimpl_lib, Dart_NewString("_ImmutableArray"));
|
||||
Dart_GetClass(core_lib, Dart_NewString("_ImmutableArray"));
|
||||
ASSERT(!Dart_IsError(immutable_array_class));
|
||||
growable_object_array_class =
|
||||
Dart_GetClass(coreimpl_lib, Dart_NewString("_GrowableObjectArray"));
|
||||
Dart_GetClass(core_lib, Dart_NewString("_GrowableObjectArray"));
|
||||
ASSERT(!Dart_IsError(growable_object_array_class));
|
||||
// Update the cache.
|
||||
isolate_data->object_array_class =
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Note that the optimizing compiler depends on the algorithm which
|
||||
// returns a _GrowableObjectArray if length is null, otherwise returns
|
||||
// fixed size array.
|
||||
patch class ListImplementation<E> {
|
||||
patch class _ListImpl<E> {
|
||||
/* patch */ factory List([int length = null]) {
|
||||
if (length === null) {
|
||||
return new _GrowableObjectArray<E>();
|
||||
|
@ -14,8 +14,8 @@ patch class ListImplementation<E> {
|
|||
}
|
||||
}
|
||||
|
||||
/* patch */ static _from(Iterable other) {
|
||||
_GrowableObjectArray list = new _GrowableObjectArray();
|
||||
/* patch */ factory List.from(Iterable<E> other) {
|
||||
_GrowableObjectArray<E> list = new _GrowableObjectArray<E>();
|
||||
for (final e in other) {
|
||||
list.add(e);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,6 @@
|
|||
|
||||
{
|
||||
'sources': [
|
||||
'array.cc',
|
||||
'array.dart',
|
||||
'array_patch.dart',
|
||||
'growable_array.cc',
|
||||
'growable_array.dart',
|
||||
'immutable_map.dart',
|
||||
'literal_factory.dart',
|
||||
'math.dart',
|
||||
'math.cc',
|
||||
'object.cc',
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
'sources': [
|
||||
'date.cc',
|
||||
'date_patch.dart',
|
||||
'array.cc',
|
||||
'array.dart',
|
||||
'array_patch.dart',
|
||||
'double.cc',
|
||||
'double.dart',
|
||||
'double_patch.dart',
|
||||
|
@ -17,10 +20,14 @@
|
|||
'error.h',
|
||||
'expando_patch.dart',
|
||||
'function_patch.dart',
|
||||
'growable_array.cc',
|
||||
'growable_array.dart',
|
||||
'immutable_map.dart',
|
||||
'integers.cc',
|
||||
'integers.dart',
|
||||
'integers_patch.dart',
|
||||
'invocation_mirror_patch.dart',
|
||||
'literal_factory.dart',
|
||||
'object_patch.dart',
|
||||
'print_patch.dart',
|
||||
'stopwatch_patch.dart',
|
||||
|
|
|
@ -20,20 +20,16 @@ class _StringBase {
|
|||
* [codePoints].
|
||||
*/
|
||||
static String createFromCharCodes(List<int> charCodes) {
|
||||
_ObjectArray objectArray;
|
||||
if (charCodes is _ObjectArray) {
|
||||
objectArray = charCodes;
|
||||
} else {
|
||||
int len = charCodes.length;
|
||||
objectArray = new _ObjectArray(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
objectArray[i] = charCodes[i];
|
||||
}
|
||||
// TODO(ajohnsen): Add fast path once string_base is in core.
|
||||
int len = charCodes.length;
|
||||
var objectArray = new List(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
objectArray[i] = charCodes[i];
|
||||
}
|
||||
return _createFromCodePoints(objectArray);
|
||||
}
|
||||
|
||||
static String _createFromCodePoints(_ObjectArray<int> codePoints)
|
||||
static String _createFromCodePoints(List<int> codePoints)
|
||||
native "StringBase_createFromCodePoints";
|
||||
|
||||
String operator [](int index) native "String_charAt";
|
||||
|
@ -232,7 +228,7 @@ class _StringBase {
|
|||
*/
|
||||
static String _interpolate(List values) {
|
||||
int numValues = values.length;
|
||||
var stringList = new _ObjectArray(numValues);
|
||||
var stringList = new List(numValues);
|
||||
for (int i = 0; i < numValues; i++) {
|
||||
stringList[i] = values[i].toString();
|
||||
}
|
||||
|
@ -336,20 +332,16 @@ class _StringBase {
|
|||
}
|
||||
|
||||
static String concatAll(List<String> strings) {
|
||||
_ObjectArray stringsArray;
|
||||
if (strings is _ObjectArray) {
|
||||
stringsArray = strings;
|
||||
} else {
|
||||
int len = strings.length;
|
||||
stringsArray = new _ObjectArray(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
stringsArray[i] = strings[i];
|
||||
}
|
||||
// TODO(ajohnsen): Add fast path once string_base is in core.
|
||||
int len = strings.length;
|
||||
var stringsArray = new List(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
stringsArray[i] = strings[i];
|
||||
}
|
||||
return _concatAll(stringsArray);
|
||||
}
|
||||
|
||||
static String _concatAll(_ObjectArray<String> strings)
|
||||
static String _concatAll(List<String> strings)
|
||||
native "Strings_concatAll";
|
||||
}
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ void testLibrariesMap(Map libraries) {
|
|||
Expect.equals('dart:core.List', list_intf.qualifiedName);
|
||||
Expect.isFalse(list_intf.isPrivate);
|
||||
Expect.equals('Object', list_intf.superclass.simpleName);
|
||||
Expect.equals('ListImplementation', list_intf.defaultFactory.simpleName);
|
||||
Expect.equals('_ListImpl', list_intf.defaultFactory.simpleName);
|
||||
Expect.equals('dart:core', list_intf.owner.simpleName);
|
||||
Expect.isFalse(list_intf.isClass);
|
||||
Expect.equals('Collection', list_intf.superinterfaces[0].simpleName);
|
||||
|
|
|
@ -1689,9 +1689,9 @@ static bool IsRecognizedConstructor(const Function& function,
|
|||
static intptr_t GetResultCidOfConstructor(ConstructorCallNode* node) {
|
||||
const Function& function = node->constructor();
|
||||
const Class& function_class = Class::Handle(function.Owner());
|
||||
const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
|
||||
const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
||||
|
||||
if (function_class.library() != core_impl_lib.raw()) {
|
||||
if (function_class.library() != core_lib.raw()) {
|
||||
return kDynamicCid;
|
||||
}
|
||||
|
||||
|
@ -2067,7 +2067,7 @@ void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) {
|
|||
const String& cls_name = String::Handle(Symbols::NoSuchMethodError());
|
||||
const String& func_name = String::Handle(Symbols::ThrowNew());
|
||||
const Class& cls = Class::Handle(
|
||||
Library::Handle(Library::CoreImplLibrary()).LookupClass(cls_name));
|
||||
Library::Handle(Library::CoreLibrary()).LookupClass(cls_name));
|
||||
ASSERT(!cls.IsNull());
|
||||
getter_function = Resolver::ResolveStatic(cls,
|
||||
func_name,
|
||||
|
|
|
@ -175,9 +175,9 @@ bool Intrinsifier::ImmutableArray_getIndexed(Assembler* assembler) {
|
|||
|
||||
static intptr_t ComputeObjectArrayTypeArgumentsOffset() {
|
||||
const String& class_name = String::Handle(Symbols::New("_ObjectArray"));
|
||||
const Library& coreimpl_lib = Library::Handle(Library::CoreImplLibrary());
|
||||
const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
||||
const Class& cls =
|
||||
Class::Handle(coreimpl_lib.LookupClassAllowPrivate(class_name));
|
||||
Class::Handle(core_lib.LookupClassAllowPrivate(class_name));
|
||||
ASSERT(!cls.IsNull());
|
||||
ASSERT(cls.HasTypeArguments());
|
||||
ASSERT(cls.NumTypeArguments() == 1);
|
||||
|
@ -252,9 +252,9 @@ static intptr_t GetOffsetForField(const char* class_name_p,
|
|||
const char* field_name_p) {
|
||||
const String& class_name = String::Handle(Symbols::New(class_name_p));
|
||||
const String& field_name = String::Handle(Symbols::New(field_name_p));
|
||||
const Library& coreimpl_lib = Library::Handle(Library::CoreImplLibrary());
|
||||
const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
||||
const Class& cls =
|
||||
Class::Handle(coreimpl_lib.LookupClassAllowPrivate(class_name));
|
||||
Class::Handle(core_lib.LookupClassAllowPrivate(class_name));
|
||||
ASSERT(!cls.IsNull());
|
||||
const Field& field = Field::ZoneHandle(cls.LookupInstanceField(field_name));
|
||||
ASSERT(!field.IsNull());
|
||||
|
|
|
@ -1409,9 +1409,9 @@ static intptr_t GetOffsetForField(const char* class_name_p,
|
|||
const char* field_name_p) {
|
||||
const String& class_name = String::Handle(Symbols::New(class_name_p));
|
||||
const String& field_name = String::Handle(Symbols::New(field_name_p));
|
||||
const Library& coreimpl_lib = Library::Handle(Library::CoreImplLibrary());
|
||||
const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
||||
const Class& cls =
|
||||
Class::Handle(coreimpl_lib.LookupClassAllowPrivate(class_name));
|
||||
Class::Handle(core_lib.LookupClassAllowPrivate(class_name));
|
||||
ASSERT(!cls.IsNull());
|
||||
const Field& field = Field::ZoneHandle(cls.LookupInstanceField(field_name));
|
||||
ASSERT(!field.IsNull());
|
||||
|
|
|
@ -585,12 +585,12 @@ RawError* Object::Init(Isolate* isolate) {
|
|||
|
||||
cls = object_store->array_class(); // Was allocated above.
|
||||
name = Symbols::ObjectArray();
|
||||
RegisterPrivateClass(cls, name, core_impl_lib);
|
||||
RegisterPrivateClass(cls, name, core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
|
||||
cls = object_store->growable_object_array_class(); // Was allocated above.
|
||||
name = Symbols::GrowableObjectArray();
|
||||
RegisterPrivateClass(cls, name, core_impl_lib);
|
||||
RegisterPrivateClass(cls, name, core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
|
||||
cls = Class::New<ImmutableArray>();
|
||||
|
@ -598,7 +598,7 @@ RawError* Object::Init(Isolate* isolate) {
|
|||
cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset());
|
||||
ASSERT(object_store->immutable_array_class() != object_store->array_class());
|
||||
name = Symbols::ImmutableArray();
|
||||
RegisterPrivateClass(cls, name, core_impl_lib);
|
||||
RegisterPrivateClass(cls, name, core_lib);
|
||||
pending_classes.Add(cls, Heap::kOld);
|
||||
|
||||
cls = object_store->one_byte_string_class(); // Was allocated above.
|
||||
|
|
|
@ -1299,17 +1299,17 @@ static RawClass* LookupImplClass(const String& class_name) {
|
|||
}
|
||||
|
||||
|
||||
// Lookup class in the coreimpl lib which also contains various VM
|
||||
// Lookup class in the core lib which also contains various VM
|
||||
// helper methods and classes. Allow look up of private classes.
|
||||
static RawClass* LookupCoreImplClass(const String& class_name) {
|
||||
const Library& coreimpl_lib = Library::Handle(Library::CoreImplLibrary());
|
||||
static RawClass* LookupCoreClass(const String& class_name) {
|
||||
const Library& core_lib = Library::Handle(Library::CoreLibrary());
|
||||
String& name = String::Handle(class_name.raw());
|
||||
if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) {
|
||||
// Private identifiers are mangled on a per script basis.
|
||||
name = String::Concat(name, String::Handle(coreimpl_lib.private_key()));
|
||||
name = String::Concat(name, String::Handle(core_lib.private_key()));
|
||||
name = Symbols::New(name);
|
||||
}
|
||||
return coreimpl_lib.LookupClass(name);
|
||||
return core_lib.LookupClass(name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8641,7 +8641,7 @@ AstNode* Parser::ParseListLiteral(intptr_t type_pos,
|
|||
String& list_literal_factory_class_name = String::Handle(
|
||||
Symbols::ListLiteralFactoryClass());
|
||||
const Class& list_literal_factory_class =
|
||||
Class::Handle(LookupCoreImplClass(list_literal_factory_class_name));
|
||||
Class::Handle(LookupCoreClass(list_literal_factory_class_name));
|
||||
ASSERT(!list_literal_factory_class.IsNull());
|
||||
const String& list_literal_factory_name =
|
||||
String::Handle(Symbols::ListLiteralFactory());
|
||||
|
@ -8866,7 +8866,7 @@ AstNode* Parser::ParseMapLiteral(intptr_t type_pos,
|
|||
String& map_literal_factory_class_name = String::Handle(
|
||||
Symbols::MapLiteralFactoryClass());
|
||||
const Class& map_literal_factory_class =
|
||||
Class::Handle(LookupCoreImplClass(map_literal_factory_class_name));
|
||||
Class::Handle(LookupCoreClass(map_literal_factory_class_name));
|
||||
ASSERT(!map_literal_factory_class.IsNull());
|
||||
const String& map_literal_factory_name =
|
||||
String::Handle(Symbols::MapLiteralFactory());
|
||||
|
|
|
@ -42,7 +42,7 @@ class ObjectPointerVisitor;
|
|||
V(ThrowNew, "_throwNew") \
|
||||
V(ListLiteralFactoryClass, "_ListLiteralFactory") \
|
||||
V(ListLiteralFactory, "List.fromLiteral") \
|
||||
V(ListImplementation, "ListImplementation") \
|
||||
V(ListImplementation, "_ListImpl") \
|
||||
V(ListFactory, "List.") \
|
||||
V(MapLiteralFactoryClass, "_MapLiteralFactory") \
|
||||
V(MapLiteralFactory, "Map.fromLiteral") \
|
||||
|
|
Loading…
Reference in a new issue