Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 969 cls.set_is_prefinalized(); | 969 cls.set_is_prefinalized(); |
| 970 pending_classes.Add(cls, Heap::kOld); | 970 pending_classes.Add(cls, Heap::kOld); |
| 971 type = Type::NewNonParameterizedType(cls); | 971 type = Type::NewNonParameterizedType(cls); |
| 972 object_store->set_uint32x4_type(type); | 972 object_store->set_uint32x4_type(type); |
| 973 | 973 |
| 974 object_store->set_typed_data_classes(typed_data_classes); | 974 object_store->set_typed_data_classes(typed_data_classes); |
| 975 | 975 |
| 976 // Set the super type of class Stacktrace to Object type so that the | 976 // Set the super type of class Stacktrace to Object type so that the |
| 977 // 'toString' method is implemented. | 977 // 'toString' method is implemented. |
| 978 cls = object_store->stacktrace_class(); | 978 cls = object_store->stacktrace_class(); |
| 979 type = object_store->object_type(); | |
| 979 cls.set_super_type(type); | 980 cls.set_super_type(type); |
| 980 | 981 |
| 981 // Note: The abstract class Function is represented by VM class | 982 // Note: The abstract class Function is represented by VM class |
| 982 // DartFunction, not VM class Function. | 983 // DartFunction, not VM class Function. |
| 983 cls = Class::New<DartFunction>(); | 984 cls = Class::New<DartFunction>(); |
| 984 RegisterClass(cls, Symbols::Function(), core_lib); | 985 RegisterClass(cls, Symbols::Function(), core_lib); |
| 985 pending_classes.Add(cls, Heap::kOld); | 986 pending_classes.Add(cls, Heap::kOld); |
| 986 type = Type::NewNonParameterizedType(cls); | 987 type = Type::NewNonParameterizedType(cls); |
| 987 object_store->set_function_type(type); | 988 object_store->set_function_type(type); |
| 988 | 989 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1579 return 0; | 1580 return 0; |
| 1580 } | 1581 } |
| 1581 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); | 1582 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 1582 return type_params.Length(); | 1583 return type_params.Length(); |
| 1583 } | 1584 } |
| 1584 | 1585 |
| 1585 | 1586 |
| 1586 intptr_t Class::NumTypeArguments() const { | 1587 intptr_t Class::NumTypeArguments() const { |
| 1587 // To work properly, this call requires the super class of this class to be | 1588 // To work properly, this call requires the super class of this class to be |
| 1588 // resolved, which is checked by the SuperClass() call. | 1589 // resolved, which is checked by the SuperClass() call. |
| 1589 Class& cls = Class::Handle(raw()); | 1590 Isolate* isolate = Isolate::Current(); |
| 1591 Class& cls = Class::Handle(isolate, raw()); | |
| 1590 intptr_t num_type_args = 0; | 1592 intptr_t num_type_args = 0; |
| 1591 | 1593 |
| 1592 do { | 1594 do { |
| 1593 if (cls.IsSignatureClass()) { | 1595 if (cls.IsSignatureClass()) { |
| 1594 const Function& signature_fun = | 1596 const Function& signature_fun = |
| 1595 Function::Handle(cls.signature_function()); | 1597 Function::Handle(isolate, cls.signature_function()); |
| 1596 if (!signature_fun.is_static() && | 1598 if (!signature_fun.is_static() && |
| 1597 !signature_fun.HasInstantiatedSignature()) { | 1599 !signature_fun.HasInstantiatedSignature()) { |
| 1598 cls = signature_fun.Owner(); | 1600 cls = signature_fun.Owner(); |
| 1599 } | 1601 } |
| 1600 } | 1602 } |
| 1601 num_type_args += cls.NumTypeParameters(); | 1603 num_type_args += cls.NumTypeParameters(); |
| 1602 // Object is its own super class during bootstrap. | 1604 // Object is its own super class during bootstrap. |
|
Ivan Posva
2013/06/01 01:10:34
Why does Object have to be its own super class dur
siva
2013/06/03 17:43:38
Not sure, I will have to wait for Regis to answer
regis
2013/06/10 15:19:35
I do not think we have to set the super_type of cl
siva
2013/06/11 00:34:02
If I remove the setting in parser.cc during parsin
regis
2013/06/11 11:51:14
Sorry, I was not clear.
Classes that do not speci
| |
| 1603 if (cls.SuperClass() == Class::null() || cls.SuperClass() == cls.raw()) { | 1605 if (cls.super_type() == Type::null() || |
| 1606 cls.super_type() == isolate->object_store()->object_type()) { | |
| 1604 break; | 1607 break; |
| 1605 } | 1608 } |
| 1606 cls = cls.SuperClass(); | 1609 cls = cls.SuperClass(); |
| 1607 } while (true); | 1610 } while (true); |
| 1608 return num_type_args; | 1611 return num_type_args; |
| 1609 } | 1612 } |
| 1610 | 1613 |
| 1611 | 1614 |
| 1612 bool Class::HasTypeArguments() const { | 1615 bool Class::HasTypeArguments() const { |
| 1613 if (!IsSignatureClass() && (is_type_finalized() || is_prefinalized())) { | 1616 if (!IsSignatureClass() && (is_type_finalized() || is_prefinalized())) { |
| 1614 // More efficient than calling NumTypeArguments(). | 1617 // More efficient than calling NumTypeArguments(). |
| 1615 return type_arguments_field_offset() != kNoTypeArguments; | 1618 return type_arguments_field_offset() != kNoTypeArguments; |
| 1616 } else { | 1619 } else { |
| 1617 // No need to check NumTypeArguments() if class has type parameters. | 1620 // No need to check NumTypeArguments() if class has type parameters. |
| 1618 return (NumTypeParameters() > 0) || (NumTypeArguments() > 0); | 1621 return (NumTypeParameters() > 0) || (NumTypeArguments() > 0); |
| 1619 } | 1622 } |
| 1620 } | 1623 } |
| 1621 | 1624 |
| 1622 | 1625 |
| 1623 RawClass* Class::SuperClass() const { | 1626 RawClass* Class::SuperClass() const { |
| 1624 const AbstractType& sup_type = AbstractType::Handle(super_type()); | 1627 if (super_type() == Type::null()) { |
| 1625 if (sup_type.IsNull()) { | |
| 1626 return Class::null(); | 1628 return Class::null(); |
| 1627 } | 1629 } |
| 1630 const AbstractType& sup_type = AbstractType::Handle(super_type()); | |
| 1628 return sup_type.type_class(); | 1631 return sup_type.type_class(); |
| 1629 } | 1632 } |
| 1630 | 1633 |
| 1631 | 1634 |
| 1632 void Class::set_super_type(const AbstractType& value) const { | 1635 void Class::set_super_type(const AbstractType& value) const { |
| 1633 ASSERT(value.IsNull() || | 1636 ASSERT(value.IsNull() || |
| 1634 value.IsType() || | 1637 value.IsType() || |
| 1635 value.IsBoundedType() || | 1638 value.IsBoundedType() || |
| 1636 value.IsMixinAppType()); | 1639 value.IsMixinAppType()); |
| 1637 StorePointer(&raw_ptr()->super_type_, value.raw()); | 1640 StorePointer(&raw_ptr()->super_type_, value.raw()); |
| (...skipping 5245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6883 // There is a list of visible names. The name we're looking for is not | 6886 // There is a list of visible names. The name we're looking for is not |
| 6884 // contained in the list, so it is hidden. | 6887 // contained in the list, so it is hidden. |
| 6885 return true; | 6888 return true; |
| 6886 } | 6889 } |
| 6887 // The name is not filtered out. | 6890 // The name is not filtered out. |
| 6888 return false; | 6891 return false; |
| 6889 } | 6892 } |
| 6890 | 6893 |
| 6891 | 6894 |
| 6892 RawObject* Namespace::Lookup(const String& name) const { | 6895 RawObject* Namespace::Lookup(const String& name) const { |
| 6893 const Library& lib = Library::Handle(library()); | 6896 Isolate* isolate = Isolate::Current(); |
| 6897 const Library& lib = Library::Handle(isolate, library()); | |
| 6894 intptr_t ignore = 0; | 6898 intptr_t ignore = 0; |
| 6895 // Lookup the name in the library's symbols. | 6899 // Lookup the name in the library's symbols. |
| 6896 Object& obj = Object::Handle(lib.LookupEntry(name, &ignore)); | 6900 Object& obj = Object::Handle(isolate, lib.LookupEntry(name, &ignore)); |
| 6897 if (obj.IsNull()) { | 6901 if (obj.IsNull()) { |
| 6898 // Lookup in the re-exported symbols. | 6902 // Lookup in the re-exported symbols. |
| 6899 obj = lib.LookupExport(name); | 6903 obj = lib.LookupExport(name); |
| 6900 } | 6904 } |
| 6901 if (obj.IsNull() || HidesName(name)) { | 6905 if (obj.IsNull() || HidesName(name)) { |
| 6902 return Object::null(); | 6906 return Object::null(); |
| 6903 } | 6907 } |
| 6904 return obj.raw(); | 6908 return obj.raw(); |
| 6905 } | 6909 } |
| 6906 | 6910 |
| (...skipping 6394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13301 space); | 13305 space); |
| 13302 return reinterpret_cast<RawWeakProperty*>(raw); | 13306 return reinterpret_cast<RawWeakProperty*>(raw); |
| 13303 } | 13307 } |
| 13304 | 13308 |
| 13305 | 13309 |
| 13306 const char* WeakProperty::ToCString() const { | 13310 const char* WeakProperty::ToCString() const { |
| 13307 return "_WeakProperty"; | 13311 return "_WeakProperty"; |
| 13308 } | 13312 } |
| 13309 | 13313 |
| 13310 } // namespace dart | 13314 } // namespace dart |
| OLD | NEW |