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

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

Issue 10979058: - Implement first class types in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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_RAW_OBJECT_H_ 5 #ifndef VM_RAW_OBJECT_H_
6 #define VM_RAW_OBJECT_H_ 6 #define VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/token.h" 10 #include "vm/token.h"
11 #include "vm/snapshot.h" 11 #include "vm/snapshot.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 // Macrobatics to define the Object hierarchy of VM implementation classes. 15 // Macrobatics to define the Object hierarchy of VM implementation classes.
16 #define CLASS_LIST_NO_OBJECT(V) \ 16 #define CLASS_LIST_NO_OBJECT(V) \
17 V(Class) \ 17 V(Class) \
18 V(UnresolvedClass) \ 18 V(UnresolvedClass) \
19 V(AbstractType) \
20 V(Type) \
21 V(TypeParameter) \
22 V(AbstractTypeArguments) \ 19 V(AbstractTypeArguments) \
23 V(TypeArguments) \ 20 V(TypeArguments) \
24 V(InstantiatedTypeArguments) \ 21 V(InstantiatedTypeArguments) \
25 V(PatchClass) \ 22 V(PatchClass) \
26 V(Function) \ 23 V(Function) \
27 V(ClosureData) \ 24 V(ClosureData) \
28 V(RedirectionData) \ 25 V(RedirectionData) \
29 V(Field) \ 26 V(Field) \
30 V(LiteralToken) \ 27 V(LiteralToken) \
31 V(TokenStream) \ 28 V(TokenStream) \
(...skipping 11 matching lines...) Expand all
43 V(Context) \ 40 V(Context) \
44 V(ContextScope) \ 41 V(ContextScope) \
45 V(ICData) \ 42 V(ICData) \
46 V(SubtypeTestCache) \ 43 V(SubtypeTestCache) \
47 V(Error) \ 44 V(Error) \
48 V(ApiError) \ 45 V(ApiError) \
49 V(LanguageError) \ 46 V(LanguageError) \
50 V(UnhandledException) \ 47 V(UnhandledException) \
51 V(UnwindError) \ 48 V(UnwindError) \
52 V(Instance) \ 49 V(Instance) \
50 V(AbstractType) \
51 V(Type) \
52 V(TypeParameter) \
53 V(Number) \ 53 V(Number) \
54 V(Integer) \ 54 V(Integer) \
55 V(Smi) \ 55 V(Smi) \
56 V(Mint) \ 56 V(Mint) \
57 V(Bigint) \ 57 V(Bigint) \
58 V(Double) \ 58 V(Double) \
59 V(String) \ 59 V(String) \
60 V(OneByteString) \ 60 V(OneByteString) \
61 V(TwoByteString) \ 61 V(TwoByteString) \
62 V(FourByteString) \ 62 V(FourByteString) \
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. 450 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident.
451 RawString* ident_; // Name of the unresolved identifier. 451 RawString* ident_; // Name of the unresolved identifier.
452 RawClass* factory_signature_class_; // Expected type parameters for factory. 452 RawClass* factory_signature_class_; // Expected type parameters for factory.
453 RawObject** to() { 453 RawObject** to() {
454 return reinterpret_cast<RawObject**>(&ptr()->factory_signature_class_); 454 return reinterpret_cast<RawObject**>(&ptr()->factory_signature_class_);
455 } 455 }
456 intptr_t token_pos_; 456 intptr_t token_pos_;
457 }; 457 };
458 458
459 459
460 class RawAbstractType : public RawObject {
461 protected:
462 enum TypeState {
463 kAllocated, // Initial state.
464 kBeingFinalized, // In the process of being finalized.
465 kFinalizedInstantiated, // Instantiated type ready for use.
466 kFinalizedUninstantiated, // Uninstantiated type ready for use.
467 };
468
469 private:
470 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractType);
471
472 friend class ObjectStore;
473 };
474
475
476 class RawType : public RawAbstractType {
477 private:
478 RAW_HEAP_OBJECT_IMPLEMENTATION(Type);
479
480 RawObject** from() {
481 return reinterpret_cast<RawObject**>(&ptr()->type_class_);
482 }
483 RawObject* type_class_; // Either resolved class or unresolved class.
484 RawAbstractTypeArguments* arguments_;
485 RawError* malformed_error_; // Error object if type is malformed.
486 RawObject** to() {
487 return reinterpret_cast<RawObject**>(&ptr()->malformed_error_);
488 }
489 intptr_t token_pos_;
490 int8_t type_state_;
491 };
492
493
494 class RawTypeParameter : public RawAbstractType {
495 private:
496 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
497
498 RawObject** from() {
499 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_);
500 }
501 RawClass* parameterized_class_;
502 RawString* name_;
503 RawAbstractType* bound_; // DynamicType if no explicit bound specified.
504 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); }
505 intptr_t index_;
506 intptr_t token_pos_;
507 int8_t type_state_;
508 };
509
510
511 class RawAbstractTypeArguments : public RawObject { 460 class RawAbstractTypeArguments : public RawObject {
512 private: 461 private:
513 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments); 462 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments);
514 }; 463 };
515 464
516 465
517 class RawTypeArguments : public RawAbstractTypeArguments { 466 class RawTypeArguments : public RawAbstractTypeArguments {
518 private: 467 private:
519 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); 468 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments);
520 469
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 return reinterpret_cast<RawObject**>(&ptr()->message_); 980 return reinterpret_cast<RawObject**>(&ptr()->message_);
1032 } 981 }
1033 }; 982 };
1034 983
1035 984
1036 class RawInstance : public RawObject { 985 class RawInstance : public RawObject {
1037 RAW_HEAP_OBJECT_IMPLEMENTATION(Instance); 986 RAW_HEAP_OBJECT_IMPLEMENTATION(Instance);
1038 }; 987 };
1039 988
1040 989
990 class RawAbstractType : public RawInstance {
991 protected:
992 enum TypeState {
993 kAllocated, // Initial state.
994 kBeingFinalized, // In the process of being finalized.
995 kFinalizedInstantiated, // Instantiated type ready for use.
996 kFinalizedUninstantiated, // Uninstantiated type ready for use.
997 };
998
999 private:
1000 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractType);
1001
1002 friend class ObjectStore;
1003 };
1004
1005
1006 class RawType : public RawAbstractType {
1007 private:
1008 RAW_HEAP_OBJECT_IMPLEMENTATION(Type);
1009
1010 RawObject** from() {
1011 return reinterpret_cast<RawObject**>(&ptr()->type_class_);
1012 }
1013 RawObject* type_class_; // Either resolved class or unresolved class.
1014 RawAbstractTypeArguments* arguments_;
1015 RawError* malformed_error_; // Error object if type is malformed.
1016 RawObject** to() {
1017 return reinterpret_cast<RawObject**>(&ptr()->malformed_error_);
1018 }
1019 intptr_t token_pos_;
1020 int8_t type_state_;
1021 };
1022
1023
1024 class RawTypeParameter : public RawAbstractType {
1025 private:
1026 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
1027
1028 RawObject** from() {
1029 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_);
1030 }
1031 RawClass* parameterized_class_;
1032 RawString* name_;
1033 RawAbstractType* bound_; // DynamicType if no explicit bound specified.
1034 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); }
1035 intptr_t index_;
1036 intptr_t token_pos_;
1037 int8_t type_state_;
1038 };
1039
1040
1041 class RawNumber : public RawInstance { 1041 class RawNumber : public RawInstance {
1042 RAW_OBJECT_IMPLEMENTATION(Number); 1042 RAW_OBJECT_IMPLEMENTATION(Number);
1043 }; 1043 };
1044 1044
1045 1045
1046 class RawInteger : public RawNumber { 1046 class RawInteger : public RawNumber {
1047 RAW_OBJECT_IMPLEMENTATION(Integer); 1047 RAW_OBJECT_IMPLEMENTATION(Integer);
1048 }; 1048 };
1049 1049
1050 1050
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 kExternalUint64ArrayCid == kByteArrayCid + 18 && 1621 kExternalUint64ArrayCid == kByteArrayCid + 18 &&
1622 kExternalFloat32ArrayCid == kByteArrayCid + 19 && 1622 kExternalFloat32ArrayCid == kByteArrayCid + 19 &&
1623 kExternalFloat64ArrayCid == kByteArrayCid + 20 && 1623 kExternalFloat64ArrayCid == kByteArrayCid + 20 &&
1624 kStacktraceCid == kByteArrayCid + 21); 1624 kStacktraceCid == kByteArrayCid + 21);
1625 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid); 1625 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid);
1626 } 1626 }
1627 1627
1628 } // namespace dart 1628 } // namespace dart
1629 1629
1630 #endif // VM_RAW_OBJECT_H_ 1630 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698