Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: runtime/vm/object.h

Issue 10800002: Hide names of internal classes from the user by mapping them to the documented (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 static int GetSingletonClassIndex(const RawClass* raw_class); 322 static int GetSingletonClassIndex(const RawClass* raw_class);
323 static RawClass* GetSingletonClass(int index); 323 static RawClass* GetSingletonClass(int index);
324 static const char* GetSingletonClassName(int index); 324 static const char* GetSingletonClassName(int index);
325 325
326 static RawClass* CreateAndRegisterInterface(const char* cname, 326 static RawClass* CreateAndRegisterInterface(const char* cname,
327 const Script& script, 327 const Script& script,
328 const Library& lib); 328 const Library& lib);
329 static void RegisterClass(const Class& cls, 329 static void RegisterClass(const Class& cls,
330 const char* cname, 330 const char* cname,
331 const char* user_visible_cname,
331 const Script& script, 332 const Script& script,
332 const Library& lib); 333 const Library& lib);
333 334
334 static void RegisterPrivateClass(const Class& cls, 335 static void RegisterPrivateClass(const Class& cls,
335 const char* cname, 336 const char* cname,
337 const char* user_visible_cname,
336 const Script& script, 338 const Script& script,
337 const Library& lib); 339 const Library& lib);
338 340
339 static RawError* Init(Isolate* isolate); 341 static RawError* Init(Isolate* isolate);
340 static void InitFromSnapshot(Isolate* isolate); 342 static void InitFromSnapshot(Isolate* isolate);
341 static void InitOnce(); 343 static void InitOnce();
342 344
343 static intptr_t InstanceSize() { 345 static intptr_t InstanceSize() {
344 return RoundedAllocationSize(sizeof(RawObject)); 346 return RoundedAllocationSize(sizeof(RawObject));
345 } 347 }
346 348
347 static const ObjectKind kInstanceKind = kObject; 349 static const ObjectKind kInstanceKind = kObject;
348 350
349 // Different kinds of type tests. 351 // Different kinds of type tests.
350 enum TypeTestKind { 352 enum TypeTestKind {
351 kIsSubtypeOf = 0, 353 kIsSubtypeOf = 0,
352 kIsMoreSpecificThan 354 kIsMoreSpecificThan
353 }; 355 };
354 356
357 // Different kinds of name visibility.
358 enum NameVisibility {
359 kInternalName = 0,
360 kUserVisibleName
361 };
362
355 protected: 363 protected:
356 // Used for extracting the C++ vtable during bringup. 364 // Used for extracting the C++ vtable during bringup.
357 Object() : raw_(null_) {} 365 Object() : raw_(null_) {}
358 366
359 uword raw_value() const { 367 uword raw_value() const {
360 return reinterpret_cast<uword>(raw()); 368 return reinterpret_cast<uword>(raw());
361 } 369 }
362 370
363 inline void SetRaw(RawObject* value); 371 inline void SetRaw(RawObject* value);
364 372
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 raw_ptr()->instance_kind_ = value; 489 raw_ptr()->instance_kind_ = value;
482 } 490 }
483 491
484 intptr_t id() const { return raw_ptr()->id_; } 492 intptr_t id() const { return raw_ptr()->id_; }
485 void set_id(intptr_t value) const { 493 void set_id(intptr_t value) const {
486 raw_ptr()->id_ = value; 494 raw_ptr()->id_ = value;
487 } 495 }
488 496
489 RawString* Name() const; 497 RawString* Name() const;
490 498
499 RawString* UserVisibleName() const;
500
491 RawScript* script() const { return raw_ptr()->script_; } 501 RawScript* script() const { return raw_ptr()->script_; }
492 502
493 intptr_t token_pos() const { return raw_ptr()->token_pos_; } 503 intptr_t token_pos() const { return raw_ptr()->token_pos_; }
494 504
495 // This class represents the signature class of a closure function if 505 // This class represents the signature class of a closure function if
496 // signature_function() is not null. 506 // signature_function() is not null.
497 // The associated function may be a closure function (with code) or a 507 // The associated function may be a closure function (with code) or a
498 // signature function (without code) solely describing the result type and 508 // signature function (without code) solely describing the result type and
499 // parameter types of the signature. 509 // parameter types of the signature.
500 RawFunction* signature_function() const { 510 RawFunction* signature_function() const {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 const Function& signature_function, 744 const Function& signature_function,
735 const Script& script); 745 const Script& script);
736 746
737 // Return a class object corresponding to the specified kind. If 747 // Return a class object corresponding to the specified kind. If
738 // a canonicalized version of it exists then that object is returned 748 // a canonicalized version of it exists then that object is returned
739 // otherwise a new object is allocated and returned. 749 // otherwise a new object is allocated and returned.
740 static RawClass* GetClass(ObjectKind kind); 750 static RawClass* GetClass(ObjectKind kind);
741 751
742 private: 752 private:
743 void set_name(const String& value) const; 753 void set_name(const String& value) const;
754 void set_user_visible_name(const String& value) const;
744 void set_script(const Script& value) const; 755 void set_script(const Script& value) const;
745 void set_token_pos(intptr_t value) const; 756 void set_token_pos(intptr_t value) const;
746 void set_signature_function(const Function& value) const; 757 void set_signature_function(const Function& value) const;
747 void set_signature_type(const AbstractType& value) const; 758 void set_signature_type(const AbstractType& value) const;
748 void set_class_state(int8_t state) const; 759 void set_class_state(int8_t state) const;
749 760
750 void set_constants(const Array& value) const; 761 void set_constants(const Array& value) const;
751 762
752 void set_canonical_types(const Array& value) const; 763 void set_canonical_types(const Array& value) const;
753 RawArray* canonical_types() const; 764 RawArray* canonical_types() const;
(...skipping 14 matching lines...) Expand all
768 intptr_t token_pos); 779 intptr_t token_pos);
769 780
770 // Check the subtype or 'more specific' relationship. 781 // Check the subtype or 'more specific' relationship.
771 bool TypeTest(TypeTestKind test_kind, 782 bool TypeTest(TypeTestKind test_kind,
772 const AbstractTypeArguments& type_arguments, 783 const AbstractTypeArguments& type_arguments,
773 const Class& other, 784 const Class& other,
774 const AbstractTypeArguments& other_type_arguments, 785 const AbstractTypeArguments& other_type_arguments,
775 Error* malformed_error) const; 786 Error* malformed_error) const;
776 787
777 HEAP_OBJECT_IMPLEMENTATION(Class, Object); 788 HEAP_OBJECT_IMPLEMENTATION(Class, Object);
789 friend class AbstractType;
790 friend class Instance;
778 friend class Object; 791 friend class Object;
779 friend class Instance;
780 friend class AbstractType;
781 friend class Type; 792 friend class Type;
782 }; 793 };
783 794
784 795
785 // Unresolved class is used for storing unresolved names which will be resolved 796 // Unresolved class is used for storing unresolved names which will be resolved
786 // to a class after all classes have been loaded and finalized. 797 // to a class after all classes have been loaded and finalized.
787 class UnresolvedClass : public Object { 798 class UnresolvedClass : public Object {
788 public: 799 public:
789 RawLibraryPrefix* library_prefix() const { 800 RawLibraryPrefix* library_prefix() const {
790 return raw_ptr()->library_prefix_; 801 return raw_ptr()->library_prefix_;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 851
841 // Instantiate this type using the given type argument vector. 852 // Instantiate this type using the given type argument vector.
842 // Return a new type, or return 'this' if it is already instantiated. 853 // Return a new type, or return 'this' if it is already instantiated.
843 virtual RawAbstractType* InstantiateFrom( 854 virtual RawAbstractType* InstantiateFrom(
844 const AbstractTypeArguments& instantiator_type_arguments) const; 855 const AbstractTypeArguments& instantiator_type_arguments) const;
845 856
846 // Return the canonical version of this type. 857 // Return the canonical version of this type.
847 virtual RawAbstractType* Canonicalize() const; 858 virtual RawAbstractType* Canonicalize() const;
848 859
849 // The name of this type, including the names of its type arguments, if any. 860 // The name of this type, including the names of its type arguments, if any.
850 virtual RawString* Name() const; 861 virtual RawString* Name() const {
862 return BuildName(kInternalName);
863 }
864
865 // The name of this type, including the names of its type arguments, if any.
866 // Names of internal classes are mapped to their public interfaces.
867 virtual RawString* UserVisibleName() const {
868 return BuildName(kUserVisibleName);
869 }
851 870
852 // The name of this type's class, i.e. without the type argument names of this 871 // The name of this type's class, i.e. without the type argument names of this
853 // type. 872 // type.
854 RawString* ClassName() const; 873 RawString* ClassName() const;
855 874
856 // Check if this type represents the 'Dynamic' type. 875 // Check if this type represents the 'Dynamic' type.
857 bool IsDynamicType() const { 876 bool IsDynamicType() const {
858 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); 877 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class());
859 } 878 }
860 879
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 Error* malformed_error) const { 932 Error* malformed_error) const {
914 return TypeTest(kIsMoreSpecificThan, other, malformed_error); 933 return TypeTest(kIsMoreSpecificThan, other, malformed_error);
915 } 934 }
916 935
917 private: 936 private:
918 // Check the subtype or 'more specific' relationship. 937 // Check the subtype or 'more specific' relationship.
919 bool TypeTest(TypeTestKind test_kind, 938 bool TypeTest(TypeTestKind test_kind,
920 const AbstractType& other, 939 const AbstractType& other,
921 Error* malformed_error) const; 940 Error* malformed_error) const;
922 941
942 // Return the internal or public name of this type, including the names of its
943 // type arguments, if any.
944 RawString* BuildName(NameVisibility visibility) const;
945
923 protected: 946 protected:
924 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); 947 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object);
948 friend class AbstractTypeArguments;
925 friend class Class; 949 friend class Class;
926 friend class AbstractTypeArguments; 950 friend class Function;
927 }; 951 };
928 952
929 953
930 // A Type consists of a class, possibly parameterized with type 954 // A Type consists of a class, possibly parameterized with type
931 // arguments. Example: C<T1, T2>. 955 // arguments. Example: C<T1, T2>.
932 // An unresolved class is a String specifying the class name. 956 // An unresolved class is a String specifying the class name.
933 // 957 //
934 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as 958 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as
935 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not 959 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not
936 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. 960 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated; 1067 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated;
1044 } 1068 }
1045 void set_is_finalized() const; 1069 void set_is_finalized() const;
1046 virtual bool IsBeingFinalized() const { return false; } 1070 virtual bool IsBeingFinalized() const { return false; }
1047 virtual bool IsMalformed() const { return false; } 1071 virtual bool IsMalformed() const { return false; }
1048 virtual bool IsResolved() const { return true; } 1072 virtual bool IsResolved() const { return true; }
1049 virtual bool HasResolvedTypeClass() const { return false; } 1073 virtual bool HasResolvedTypeClass() const { return false; }
1050 RawClass* parameterized_class() const { 1074 RawClass* parameterized_class() const {
1051 return raw_ptr()->parameterized_class_; 1075 return raw_ptr()->parameterized_class_;
1052 } 1076 }
1053 virtual RawString* Name() const { return raw_ptr()->name_; } 1077 RawString* name() const { return raw_ptr()->name_; }
1054 intptr_t index() const { return raw_ptr()->index_; } 1078 intptr_t index() const { return raw_ptr()->index_; }
1055 void set_index(intptr_t value) const; 1079 void set_index(intptr_t value) const;
1056 RawAbstractType* bound() const { return raw_ptr()->bound_; } 1080 RawAbstractType* bound() const { return raw_ptr()->bound_; }
1057 void set_bound(const AbstractType& value) const; 1081 void set_bound(const AbstractType& value) const;
1058 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } 1082 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; }
1059 virtual bool IsInstantiated() const { return false; } 1083 virtual bool IsInstantiated() const { return false; }
1060 virtual bool Equals(const AbstractType& other) const; 1084 virtual bool Equals(const AbstractType& other) const;
1061 virtual bool IsIdentical(const AbstractType& other, 1085 virtual bool IsIdentical(const AbstractType& other,
1062 bool check_type_parameter_bound) const; 1086 bool check_type_parameter_bound) const;
1063 virtual RawAbstractType* InstantiateFrom( 1087 virtual RawAbstractType* InstantiateFrom(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 // Return 'this' if this type argument vector is instantiated, i.e. if it does 1128 // Return 'this' if this type argument vector is instantiated, i.e. if it does
1105 // not refer to type parameters. Otherwise, return a new type argument vector 1129 // not refer to type parameters. Otherwise, return a new type argument vector
1106 // where each reference to a type parameter is replaced with the corresponding 1130 // where each reference to a type parameter is replaced with the corresponding
1107 // type of the instantiator type argument vector. 1131 // type of the instantiator type argument vector.
1108 virtual RawAbstractTypeArguments* InstantiateFrom( 1132 virtual RawAbstractTypeArguments* InstantiateFrom(
1109 const AbstractTypeArguments& instantiator_type_arguments) const; 1133 const AbstractTypeArguments& instantiator_type_arguments) const;
1110 1134
1111 // Do not canonicalize InstantiatedTypeArguments or NULL objects 1135 // Do not canonicalize InstantiatedTypeArguments or NULL objects
1112 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } 1136 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); }
1113 1137
1114 // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, int>". 1138 // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, Smi>".
1115 virtual RawString* Name() const { 1139 virtual RawString* Name() const {
1116 return SubvectorName(0, Length()); 1140 return SubvectorName(0, Length(), kInternalName);
1117 } 1141 }
1118 1142
1119 // The name of a subvector of this type argument vector, e.g. "<T, Dynamic>". 1143 // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, int>".
1120 virtual RawString* SubvectorName(intptr_t from_index, intptr_t len) const; 1144 // Names of internal classes are mapped to their public interfaces.
1145 virtual RawString* UserVisibleName() const {
1146 return SubvectorName(0, Length(), kUserVisibleName);
1147 }
1121 1148
1122 // Check if this type argument vector consists solely of DynamicType, 1149 // Check if this type argument vector consists solely of DynamicType,
1123 // considering only a prefix of length 'len'. 1150 // considering only a prefix of length 'len'.
1124 bool IsRaw(intptr_t len) const { 1151 bool IsRaw(intptr_t len) const {
1125 return IsDynamicTypes(false, len); 1152 return IsDynamicTypes(false, len);
1126 } 1153 }
1127 1154
1128 // Check if this type argument vector would consist solely of DynamicType if 1155 // Check if this type argument vector would consist solely of DynamicType if
1129 // it was instantiated from a raw (null) instantiator, i.e. consider each type 1156 // it was instantiated from a raw (null) instantiator, i.e. consider each type
1130 // parameter as it would be first instantiated from a vector of dynamic types. 1157 // parameter as it would be first instantiated from a vector of dynamic types.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 // instantiated from a vector of dynamic types. 1198 // instantiated from a vector of dynamic types.
1172 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const; 1199 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const;
1173 1200
1174 // Check the subtype or 'more specific' relationship, considering only a 1201 // Check the subtype or 'more specific' relationship, considering only a
1175 // prefix of length 'len'. 1202 // prefix of length 'len'.
1176 bool TypeTest(TypeTestKind test_kind, 1203 bool TypeTest(TypeTestKind test_kind,
1177 const AbstractTypeArguments& other, 1204 const AbstractTypeArguments& other,
1178 intptr_t len, 1205 intptr_t len,
1179 Error* malformed_error) const; 1206 Error* malformed_error) const;
1180 1207
1208 // Return the internal or public name of a subvector of this type argument
1209 // vector, e.g. "<T, Dynamic, List<T>, int>".
1210 RawString* SubvectorName(intptr_t from_index,
1211 intptr_t len,
1212 NameVisibility name_visibility) const;
1213
1181 protected: 1214 protected:
1182 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); 1215 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object);
1216 friend class AbstractType;
1183 friend class Class; 1217 friend class Class;
1184 }; 1218 };
1185 1219
1186 1220
1187 // A TypeArguments is an array of AbstractType. 1221 // A TypeArguments is an array of AbstractType.
1188 class TypeArguments : public AbstractTypeArguments { 1222 class TypeArguments : public AbstractTypeArguments {
1189 public: 1223 public:
1190 virtual intptr_t Length() const; 1224 virtual intptr_t Length() const;
1191 virtual RawAbstractType* TypeAt(intptr_t index) const; 1225 virtual RawAbstractType* TypeAt(intptr_t index) const;
1192 static intptr_t type_at_offset(intptr_t index) { 1226 static intptr_t type_at_offset(intptr_t index) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments); 1317 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments);
1284 friend class Class; 1318 friend class Class;
1285 }; 1319 };
1286 1320
1287 1321
1288 class Function : public Object { 1322 class Function : public Object {
1289 public: 1323 public:
1290 RawString* name() const { return raw_ptr()->name_; } 1324 RawString* name() const { return raw_ptr()->name_; }
1291 1325
1292 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the 1326 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the
1293 // signature of the given function. 1327 // internal signature of the given function.
1294 RawString* Signature() const { 1328 RawString* Signature() const {
1295 return BuildSignature(false, TypeArguments::Handle()); 1329 const bool instantiate = false;
1330 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle());
1296 } 1331 }
1297 1332
1298 // Build a string of the form '(A, [b: B, c: C]) => D' representing the 1333 // Build a string of the form '(A, [b: B, c: C]) => D' representing the
1299 // signature of the given function, where all generic types (e.g. '<T, R>' in 1334 // signature of the given function, where all generic types (e.g. '<T, R>' in
1300 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given 1335 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given
1301 // instantiator type argument vector (e.g. '<A, D>'). 1336 // instantiator type argument vector (e.g. '<A, D>').
1302 RawString* InstantiatedSignatureFrom( 1337 RawString* InstantiatedSignatureFrom(
1303 const AbstractTypeArguments& instantiator) const { 1338 const AbstractTypeArguments& instantiator,
1304 return BuildSignature(true, instantiator); 1339 NameVisibility name_visibility) const {
1340 const bool instantiate = true;
1341 return BuildSignature(instantiate, name_visibility, instantiator);
1305 } 1342 }
1306 1343
1307 // Returns true if the signature of this function is instantiated, i.e. if it 1344 // Returns true if the signature of this function is instantiated, i.e. if it
1308 // does not involve generic parameter types or generic result type. 1345 // does not involve generic parameter types or generic result type.
1309 bool HasInstantiatedSignature() const; 1346 bool HasInstantiatedSignature() const;
1310 1347
1311 RawClass* owner() const { return raw_ptr()->owner_; } 1348 RawClass* owner() const { return raw_ptr()->owner_; }
1312 void set_owner(const Class& value) const; 1349 void set_owner(const Class& value) const;
1313 1350
1314 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } 1351 RawAbstractType* result_type() const { return raw_ptr()->result_type_; }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 void set_name(const String& value) const; 1612 void set_name(const String& value) const;
1576 void set_kind(RawFunction::Kind value) const; 1613 void set_kind(RawFunction::Kind value) const;
1577 void set_is_static(bool is_static) const; 1614 void set_is_static(bool is_static) const;
1578 void set_is_const(bool is_const) const; 1615 void set_is_const(bool is_const) const;
1579 void set_parent_function(const Function& value) const; 1616 void set_parent_function(const Function& value) const;
1580 void set_token_pos(intptr_t value) const; 1617 void set_token_pos(intptr_t value) const;
1581 void set_implicit_closure_function(const Function& value) const; 1618 void set_implicit_closure_function(const Function& value) const;
1582 static RawFunction* New(); 1619 static RawFunction* New();
1583 1620
1584 RawString* BuildSignature(bool instantiate, 1621 RawString* BuildSignature(bool instantiate,
1622 NameVisibility name_visibility,
1585 const AbstractTypeArguments& instantiator) const; 1623 const AbstractTypeArguments& instantiator) const;
1586 1624
1587 // Check the subtype or 'more specific' relationship. 1625 // Check the subtype or 'more specific' relationship.
1588 bool TypeTest(TypeTestKind test_kind, 1626 bool TypeTest(TypeTestKind test_kind,
1589 const AbstractTypeArguments& type_arguments, 1627 const AbstractTypeArguments& type_arguments,
1590 const Function& other, 1628 const Function& other,
1591 const AbstractTypeArguments& other_type_arguments, 1629 const AbstractTypeArguments& other_type_arguments,
1592 Error* malformed_error) const; 1630 Error* malformed_error) const;
1593 1631
1594 // Checks the type of the formal parameter at the given position for 1632 // Checks the type of the formal parameter at the given position for
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 static RawLibrary* NewLibraryHelper(const String& url, 2032 static RawLibrary* NewLibraryHelper(const String& url,
1995 bool import_core_lib); 2033 bool import_core_lib);
1996 void AddImportedInto(const Library& library) const; 2034 void AddImportedInto(const Library& library) const;
1997 RawObject* LookupObjectFiltered(const String& name, 2035 RawObject* LookupObjectFiltered(const String& name,
1998 const Library& filter_lib) const; 2036 const Library& filter_lib) const;
1999 RawLibrary* LookupObjectInImporter(const String& name) const; 2037 RawLibrary* LookupObjectInImporter(const String& name) const;
2000 RawString* FindDuplicateDefinition() const; 2038 RawString* FindDuplicateDefinition() const;
2001 2039
2002 HEAP_OBJECT_IMPLEMENTATION(Library, Object); 2040 HEAP_OBJECT_IMPLEMENTATION(Library, Object);
2003 friend class Class; 2041 friend class Class;
2042 friend class Debugger;
2004 friend class DictionaryIterator; 2043 friend class DictionaryIterator;
2005 friend class Debugger;
2006 friend class Isolate; 2044 friend class Isolate;
2007 }; 2045 };
2008 2046
2009 2047
2010 class LibraryPrefix : public Object { 2048 class LibraryPrefix : public Object {
2011 public: 2049 public:
2012 RawString* name() const { return raw_ptr()->name_; } 2050 RawString* name() const { return raw_ptr()->name_; }
2013 RawArray* libraries() const { return raw_ptr()->libraries_; } 2051 RawArray* libraries() const { return raw_ptr()->libraries_; }
2014 intptr_t num_libs() const { return raw_ptr()->num_libs_; } 2052 intptr_t num_libs() const { return raw_ptr()->num_libs_; }
2015 2053
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 raw_ptr()->code_ = code; 2118 raw_ptr()->code_ = code;
2081 } 2119 }
2082 2120
2083 // New is a private method as RawInstruction and RawCode objects should 2121 // New is a private method as RawInstruction and RawCode objects should
2084 // only be created using the Code::FinalizeCode method. This method creates 2122 // only be created using the Code::FinalizeCode method. This method creates
2085 // the RawInstruction and RawCode objects, sets up the pointer offsets 2123 // the RawInstruction and RawCode objects, sets up the pointer offsets
2086 // and links the two in a GC safe manner. 2124 // and links the two in a GC safe manner.
2087 static RawInstructions* New(intptr_t size); 2125 static RawInstructions* New(intptr_t size);
2088 2126
2089 HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); 2127 HEAP_OBJECT_IMPLEMENTATION(Instructions, Object);
2128 friend class Class;
2090 friend class Code; 2129 friend class Code;
2091 friend class Class;
2092 }; 2130 };
2093 2131
2094 2132
2095 class LocalVarDescriptors : public Object { 2133 class LocalVarDescriptors : public Object {
2096 public: 2134 public:
2097 intptr_t Length() const; 2135 intptr_t Length() const;
2098 2136
2099 RawString* GetName(intptr_t var_index) const; 2137 RawString* GetName(intptr_t var_index) const;
2100 2138
2101 void SetVar(intptr_t var_index, 2139 void SetVar(intptr_t var_index,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 } 2286 }
2249 2287
2250 bool InRange(intptr_t offset) const { return offset < SizeInBits(); } 2288 bool InRange(intptr_t offset) const { return offset < SizeInBits(); }
2251 2289
2252 bool GetBit(intptr_t bit_offset) const; 2290 bool GetBit(intptr_t bit_offset) const;
2253 void SetBit(intptr_t bit_offset, bool value) const; 2291 void SetBit(intptr_t bit_offset, bool value) const;
2254 2292
2255 void set_bitmap_size_in_bytes(intptr_t value) const; 2293 void set_bitmap_size_in_bytes(intptr_t value) const;
2256 2294
2257 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); 2295 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object);
2296 friend class BitmapBuilder;
2258 friend class Class; 2297 friend class Class;
2259 friend class BitmapBuilder;
2260 }; 2298 };
2261 2299
2262 2300
2263 class ExceptionHandlers : public Object { 2301 class ExceptionHandlers : public Object {
2264 public: 2302 public:
2265 intptr_t Length() const; 2303 intptr_t Length() const;
2266 2304
2267 intptr_t TryIndex(intptr_t index) const; 2305 intptr_t TryIndex(intptr_t index) const;
2268 intptr_t HandlerPC(intptr_t index) const; 2306 intptr_t HandlerPC(intptr_t index) const;
2269 2307
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); 2976 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew);
2939 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); 2977 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew);
2940 2978
2941 virtual double AsDoubleValue() const; 2979 virtual double AsDoubleValue() const;
2942 virtual int64_t AsInt64Value() const; 2980 virtual int64_t AsInt64Value() const;
2943 2981
2944 // Returns 0, -1 or 1. 2982 // Returns 0, -1 or 1.
2945 virtual int CompareWith(const Integer& other) const; 2983 virtual int CompareWith(const Integer& other) const;
2946 2984
2947 OBJECT_IMPLEMENTATION(Integer, Number); 2985 OBJECT_IMPLEMENTATION(Integer, Number);
2986 friend class Class;
2948 }; 2987 };
2949 2988
2950 2989
2951 class Smi : public Integer { 2990 class Smi : public Integer {
2952 public: 2991 public:
2953 // Smi value range is from -(2^N) to (2^N)-1. 2992 // Smi value range is from -(2^N) to (2^N)-1.
2954 // N=30 (32-bit build) or N=62 (64-bit build). 2993 // N=30 (32-bit build) or N=62 (64-bit build).
2955 static const intptr_t kBits = kBitsPerWord - 2; 2994 static const intptr_t kBits = kBitsPerWord - 2;
2956 static const intptr_t kMaxValue = (static_cast<intptr_t>(1) << kBits) - 1; 2995 static const intptr_t kMaxValue = (static_cast<intptr_t>(1) << kBits) - 1;
2957 static const intptr_t kMinValue = -(static_cast<intptr_t>(1) << kBits); 2996 static const intptr_t kMinValue = -(static_cast<intptr_t>(1) << kBits);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2993 3032
2994 static bool IsValid(intptr_t value) { 3033 static bool IsValid(intptr_t value) {
2995 return (value >= kMinValue) && (value <= kMaxValue); 3034 return (value >= kMinValue) && (value <= kMaxValue);
2996 } 3035 }
2997 3036
2998 static bool IsValid64(int64_t value) { 3037 static bool IsValid64(int64_t value) {
2999 return (value >= kMinValue) && (value <= kMaxValue); 3038 return (value >= kMinValue) && (value <= kMaxValue);
3000 } 3039 }
3001 3040
3002 private: 3041 private:
3003 friend class Api; // For ValueFromRaw
3004
3005 static intptr_t ValueFromRaw(uword raw_value) { 3042 static intptr_t ValueFromRaw(uword raw_value) {
3006 intptr_t value = raw_value; 3043 intptr_t value = raw_value;
3007 ASSERT((value & kSmiTagMask) == kSmiTag); 3044 ASSERT((value & kSmiTagMask) == kSmiTag);
3008 return (value >> kSmiTagShift); 3045 return (value >> kSmiTagShift);
3009 } 3046 }
3010 static cpp_vtable handle_vtable_; 3047 static cpp_vtable handle_vtable_;
3011 3048
3012 OBJECT_IMPLEMENTATION(Smi, Integer); 3049 OBJECT_IMPLEMENTATION(Smi, Integer);
3050 friend class Api; // For ValueFromRaw
3051 friend class Class;
3013 friend class Object; 3052 friend class Object;
3014 friend class Class;
3015 }; 3053 };
3016 3054
3017 3055
3018 class Mint : public Integer { 3056 class Mint : public Integer {
3019 public: 3057 public:
3020 static const intptr_t kBits = 63; // 64-th bit is sign. 3058 static const intptr_t kBits = 63; // 64-th bit is sign.
3021 static const int64_t kMaxValue = 3059 static const int64_t kMaxValue =
3022 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF)); 3060 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF));
3023 static const int64_t kMinValue = 3061 static const int64_t kMinValue =
3024 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000)); 3062 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3118 Chunk* ChunkAddr(intptr_t index) const { 3156 Chunk* ChunkAddr(intptr_t index) const {
3119 ASSERT(0 <= index); 3157 ASSERT(0 <= index);
3120 ASSERT(index < Length()); 3158 ASSERT(index < Length());
3121 uword digits_start = reinterpret_cast<uword>(raw_ptr()) + sizeof(RawBigint); 3159 uword digits_start = reinterpret_cast<uword>(raw_ptr()) + sizeof(RawBigint);
3122 return &(reinterpret_cast<Chunk*>(digits_start)[index]); 3160 return &(reinterpret_cast<Chunk*>(digits_start)[index]);
3123 } 3161 }
3124 3162
3125 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); 3163 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew);
3126 3164
3127 HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); 3165 HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer);
3166 friend class BigintOperations;
3128 friend class Class; 3167 friend class Class;
3129 friend class BigintOperations;
3130 }; 3168 };
3131 3169
3132 3170
3133 class Double : public Number { 3171 class Double : public Number {
3134 public: 3172 public:
3135 double value() const { 3173 double value() const {
3136 return raw_ptr()->value_; 3174 return raw_ptr()->value_;
3137 } 3175 }
3138 3176
3139 bool EqualsToDouble(double value) const; 3177 bool EqualsToDouble(double value) const;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
3649 return value ? Bool::True() : Bool::False(); 3687 return value ? Bool::True() : Bool::False();
3650 } 3688 }
3651 3689
3652 private: 3690 private:
3653 void set_value(bool value) const { raw_ptr()->value_ = value; } 3691 void set_value(bool value) const { raw_ptr()->value_ = value; }
3654 3692
3655 // New should only be called to initialize the two legal bool values. 3693 // New should only be called to initialize the two legal bool values.
3656 static RawBool* New(bool value); 3694 static RawBool* New(bool value);
3657 3695
3658 HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); 3696 HEAP_OBJECT_IMPLEMENTATION(Bool, Instance);
3697 friend class Class;
3659 friend class Object; // To initialize the true and false values. 3698 friend class Object; // To initialize the true and false values.
3660 friend class Class;
3661 }; 3699 };
3662 3700
3663 3701
3664 class Array : public Instance { 3702 class Array : public Instance {
3665 public: 3703 public:
3666 intptr_t Length() const { 3704 intptr_t Length() const {
3667 ASSERT(!IsNull()); 3705 ASSERT(!IsNull());
3668 return Smi::Value(raw_ptr()->length_); 3706 return Smi::Value(raw_ptr()->length_);
3669 } 3707 }
3670 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } 3708 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 private: 3881 private:
3844 RawArray* DataArray() const { return data()->ptr(); } 3882 RawArray* DataArray() const { return data()->ptr(); }
3845 RawObject** ObjectAddr(intptr_t index) const { 3883 RawObject** ObjectAddr(intptr_t index) const {
3846 ASSERT((index >= 0) && (index < Length())); 3884 ASSERT((index >= 0) && (index < Length()));
3847 return &(DataArray()->data()[index]); 3885 return &(DataArray()->data()[index]);
3848 } 3886 }
3849 3887
3850 static const int kDefaultInitialCapacity = 4; 3888 static const int kDefaultInitialCapacity = 4;
3851 3889
3852 HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 3890 HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
3891 friend class Array;
3853 friend class Class; 3892 friend class Class;
3854 friend class Array;
3855 }; 3893 };
3856 3894
3857 3895
3858 class ByteArray : public Instance { 3896 class ByteArray : public Instance {
3859 public: 3897 public:
3860 intptr_t Length() const { 3898 intptr_t Length() const {
3861 ASSERT(!IsNull()); 3899 ASSERT(!IsNull());
3862 return Smi::Value(raw_ptr()->length_); 3900 return Smi::Value(raw_ptr()->length_);
3863 } 3901 }
3864 3902
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5206 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5169 return false; 5207 return false;
5170 } 5208 }
5171 } 5209 }
5172 return true; 5210 return true;
5173 } 5211 }
5174 5212
5175 } // namespace dart 5213 } // namespace dart
5176 5214
5177 #endif // VM_OBJECT_H_ 5215 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698