| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // has been created. | 349 // has been created. |
| 350 cls.InitEmptyFields(); | 350 cls.InitEmptyFields(); |
| 351 | 351 |
| 352 cls = Class::New<ImmutableArray>(); | 352 cls = Class::New<ImmutableArray>(); |
| 353 object_store->set_immutable_array_class(cls); | 353 object_store->set_immutable_array_class(cls); |
| 354 cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset()); | 354 cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset()); |
| 355 | 355 |
| 356 // Allocate and initialize the object class and type. | 356 // Allocate and initialize the object class and type. |
| 357 cls = Class::New<Instance>(); | 357 cls = Class::New<Instance>(); |
| 358 object_store->set_object_class(cls); | 358 object_store->set_object_class(cls); |
| 359 // The bootstrap script is not compiled yet, so the superclass of Object does | |
| 360 // not yet point to itself, therefore, Type::NewNonParameterizedType(cls) | |
| 361 // can safely assert that cls.NumTypeArguments() == 0 without entering an | |
| 362 // endless loop. | |
| 363 ASSERT(cls.SuperClass() == Class::null()); | |
| 364 type = Type::NewNonParameterizedType(cls); | 359 type = Type::NewNonParameterizedType(cls); |
| 365 object_store->set_object_type(type); | 360 object_store->set_object_type(type); |
| 366 | 361 |
| 367 cls = Class::New<Smi>(); | 362 cls = Class::New<Smi>(); |
| 368 object_store->set_smi_class(cls); | 363 object_store->set_smi_class(cls); |
| 369 | 364 |
| 370 cls = Class::New<Mint>(); | 365 cls = Class::New<Mint>(); |
| 371 object_store->set_mint_class(cls); | 366 object_store->set_mint_class(cls); |
| 372 | 367 |
| 373 cls = Class::New<Bigint>(); | 368 cls = Class::New<Bigint>(); |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 } | 1326 } |
| 1332 // TODO(regis): Merge IsMoreSpecificThan here after type checks for | 1327 // TODO(regis): Merge IsMoreSpecificThan here after type checks for |
| 1333 // function types are finalized and implemented. | 1328 // function types are finalized and implemented. |
| 1334 // For now, keep the assert below. | 1329 // For now, keep the assert below. |
| 1335 | 1330 |
| 1336 // The optionality and dubious bliss rules described in the guide have | 1331 // The optionality and dubious bliss rules described in the guide have |
| 1337 // already been checked in IsMoreSpecificThan call above. | 1332 // already been checked in IsMoreSpecificThan call above. |
| 1338 if (raw() != other.raw()) { | 1333 if (raw() != other.raw()) { |
| 1339 return false; | 1334 return false; |
| 1340 } | 1335 } |
| 1341 ASSERT(NumTypeArguments() > 0); // Or IsMoreSpecificThan would be true. | 1336 ASSERT(HasTypeArguments()); // Otherwise, IsMoreSpecificThan would be true. |
| 1342 return false; | 1337 return false; |
| 1343 } | 1338 } |
| 1344 | 1339 |
| 1345 | 1340 |
| 1346 RawFunction* Class::LookupDynamicFunction(const String& name) const { | 1341 RawFunction* Class::LookupDynamicFunction(const String& name) const { |
| 1347 Function& function = Function::Handle(LookupFunction(name)); | 1342 Function& function = Function::Handle(LookupFunction(name)); |
| 1348 if (function.IsNull() || function.is_static()) { | 1343 if (function.IsNull() || function.is_static()) { |
| 1349 return Function::null(); | 1344 return Function::null(); |
| 1350 } | 1345 } |
| 1351 switch (function.kind()) { | 1346 switch (function.kind()) { |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 | 1854 |
| 1860 | 1855 |
| 1861 RawType* Type::NewRawType(const Class& type_class) { | 1856 RawType* Type::NewRawType(const Class& type_class) { |
| 1862 const TypeArguments& type_arguments = | 1857 const TypeArguments& type_arguments = |
| 1863 TypeArguments::Handle(type_class.type_parameter_extends()); | 1858 TypeArguments::Handle(type_class.type_parameter_extends()); |
| 1864 return NewParameterizedType(Object::Handle(type_class.raw()), type_arguments); | 1859 return NewParameterizedType(Object::Handle(type_class.raw()), type_arguments); |
| 1865 } | 1860 } |
| 1866 | 1861 |
| 1867 | 1862 |
| 1868 RawType* Type::NewNonParameterizedType(const Class& type_class) { | 1863 RawType* Type::NewNonParameterizedType(const Class& type_class) { |
| 1869 ASSERT(type_class.NumTypeArguments() == 0); | 1864 ASSERT(!type_class.HasTypeArguments()); |
| 1870 const TypeArguments& no_type_arguments = TypeArguments::Handle(); | 1865 const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
| 1871 ParameterizedType& type = ParameterizedType::Handle(); | 1866 ParameterizedType& type = ParameterizedType::Handle(); |
| 1872 type ^= ParameterizedType::New( | 1867 type ^= ParameterizedType::New( |
| 1873 Object::Handle(type_class.raw()), no_type_arguments); | 1868 Object::Handle(type_class.raw()), no_type_arguments); |
| 1874 type.set_is_finalized(); | 1869 type.set_is_finalized(); |
| 1875 return type.raw(); | 1870 return type.raw(); |
| 1876 } | 1871 } |
| 1877 | 1872 |
| 1878 | 1873 |
| 1879 RawType* Type::NewParameterizedType(const Object& clazz, | 1874 RawType* Type::NewParameterizedType(const Object& clazz, |
| (...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4479 return this->raw(); | 4474 return this->raw(); |
| 4480 } | 4475 } |
| 4481 | 4476 |
| 4482 | 4477 |
| 4483 RawType* Instance::GetType() const { | 4478 RawType* Instance::GetType() const { |
| 4484 if (IsNull()) { | 4479 if (IsNull()) { |
| 4485 return Type::NullType(); | 4480 return Type::NullType(); |
| 4486 } | 4481 } |
| 4487 const Class& cls = Class::Handle(clazz()); | 4482 const Class& cls = Class::Handle(clazz()); |
| 4488 TypeArguments& type_arguments = TypeArguments::Handle(); | 4483 TypeArguments& type_arguments = TypeArguments::Handle(); |
| 4489 if (cls.NumTypeArguments() > 0) { | 4484 if (cls.HasTypeArguments()) { |
| 4490 type_arguments = GetTypeArguments(); | 4485 type_arguments = GetTypeArguments(); |
| 4491 } | 4486 } |
| 4492 return Type::NewParameterizedType(cls, type_arguments); | 4487 return Type::NewParameterizedType(cls, type_arguments); |
| 4493 } | 4488 } |
| 4494 | 4489 |
| 4495 | 4490 |
| 4496 RawTypeArguments* Instance::GetTypeArguments() const { | 4491 RawTypeArguments* Instance::GetTypeArguments() const { |
| 4497 const Class& cls = Class::Handle(clazz()); | 4492 const Class& cls = Class::Handle(clazz()); |
| 4498 intptr_t field_offset = cls.type_arguments_instance_field_offset(); | 4493 intptr_t field_offset = cls.type_arguments_instance_field_offset(); |
| 4499 ASSERT(field_offset != Class::kNoTypeArguments); | 4494 ASSERT(field_offset != Class::kNoTypeArguments); |
| (...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6464 const String& str = String::Handle(pattern()); | 6459 const String& str = String::Handle(pattern()); |
| 6465 const char* format = "JSRegExp: pattern=%s flags=%s"; | 6460 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 6466 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 6461 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 6467 char* chars = reinterpret_cast<char*>( | 6462 char* chars = reinterpret_cast<char*>( |
| 6468 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6463 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 6469 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 6464 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 6470 return chars; | 6465 return chars; |
| 6471 } | 6466 } |
| 6472 | 6467 |
| 6473 } // namespace dart | 6468 } // namespace dart |
| OLD | NEW |