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 #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/atomic.h" | 9 #include "vm/atomic.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 V(SubtypeTestCache) \ | 45 V(SubtypeTestCache) \ |
46 V(Error) \ | 46 V(Error) \ |
47 V(ApiError) \ | 47 V(ApiError) \ |
48 V(LanguageError) \ | 48 V(LanguageError) \ |
49 V(UnhandledException) \ | 49 V(UnhandledException) \ |
50 V(UnwindError) \ | 50 V(UnwindError) \ |
51 V(Instance) \ | 51 V(Instance) \ |
52 V(LibraryPrefix) \ | 52 V(LibraryPrefix) \ |
53 V(AbstractType) \ | 53 V(AbstractType) \ |
54 V(Type) \ | 54 V(Type) \ |
55 V(FunctionType) \ | |
56 V(TypeRef) \ | 55 V(TypeRef) \ |
57 V(TypeParameter) \ | 56 V(TypeParameter) \ |
58 V(BoundedType) \ | 57 V(BoundedType) \ |
59 V(MixinAppType) \ | 58 V(MixinAppType) \ |
60 V(Closure) \ | 59 V(Closure) \ |
61 V(Number) \ | 60 V(Number) \ |
62 V(Integer) \ | 61 V(Integer) \ |
63 V(Smi) \ | 62 V(Smi) \ |
64 V(Mint) \ | 63 V(Mint) \ |
65 V(Bigint) \ | 64 V(Bigint) \ |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 | 844 |
846 class RawClosureData : public RawObject { | 845 class RawClosureData : public RawObject { |
847 private: | 846 private: |
848 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); | 847 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); |
849 | 848 |
850 RawObject** from() { | 849 RawObject** from() { |
851 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); | 850 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); |
852 } | 851 } |
853 RawContextScope* context_scope_; | 852 RawContextScope* context_scope_; |
854 RawFunction* parent_function_; // Enclosing function of this local function. | 853 RawFunction* parent_function_; // Enclosing function of this local function. |
855 RawFunctionType* signature_type_; | 854 RawType* signature_type_; |
856 RawInstance* closure_; // Closure object for static implicit closures. | 855 RawInstance* closure_; // Closure object for static implicit closures. |
857 RawObject** to() { | 856 RawObject** to() { |
858 return reinterpret_cast<RawObject**>(&ptr()->closure_); | 857 return reinterpret_cast<RawObject**>(&ptr()->closure_); |
859 } | 858 } |
860 | 859 |
861 friend class Function; | 860 friend class Function; |
862 }; | 861 }; |
863 | 862 |
864 | 863 |
865 class RawRedirectionData : public RawObject { | 864 class RawRedirectionData : public RawObject { |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 | 1593 |
1595 class RawType : public RawAbstractType { | 1594 class RawType : public RawAbstractType { |
1596 private: | 1595 private: |
1597 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); | 1596 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); |
1598 | 1597 |
1599 RawObject** from() { | 1598 RawObject** from() { |
1600 return reinterpret_cast<RawObject**>(&ptr()->type_class_); | 1599 return reinterpret_cast<RawObject**>(&ptr()->type_class_); |
1601 } | 1600 } |
1602 RawObject* type_class_; // Either resolved class or unresolved class. | 1601 RawObject* type_class_; // Either resolved class or unresolved class. |
1603 RawTypeArguments* arguments_; | 1602 RawTypeArguments* arguments_; |
1604 RawLanguageError* error_; // Error object if type is malformed or malbounded. | 1603 // This type object represents a function type if its signature field is a |
| 1604 // non-null function object. |
| 1605 // If this type is malformed or malbounded, the signature field gets |
| 1606 // overwritten by the error object in order to save space. If the type is a |
| 1607 // function type, its signature is lost, but the message in the error object |
| 1608 // can describe the issue without needing the signature. |
| 1609 union { |
| 1610 RawFunction* signature_; // If not null, this type is a function type. |
| 1611 RawLanguageError* error_; // If not null, type is malformed or malbounded. |
| 1612 } sig_or_err_; |
1605 RawObject** to() { | 1613 RawObject** to() { |
1606 return reinterpret_cast<RawObject**>(&ptr()->error_); | 1614 return reinterpret_cast<RawObject**>(&ptr()->sig_or_err_.error_); |
1607 } | 1615 } |
1608 TokenPosition token_pos_; | 1616 TokenPosition token_pos_; |
1609 int8_t type_state_; | 1617 int8_t type_state_; |
1610 }; | |
1611 | |
1612 | |
1613 class RawFunctionType : public RawAbstractType { | |
1614 private: | |
1615 RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType); | |
1616 | |
1617 RawObject** from() { | |
1618 return reinterpret_cast<RawObject**>(&ptr()->scope_class_); | |
1619 } | |
1620 RawClass* scope_class_; | |
1621 RawTypeArguments* arguments_; | |
1622 RawFunction* signature_; | |
1623 RawLanguageError* error_; // Error object if type is malformed or malbounded. | |
1624 RawObject** to() { | |
1625 return reinterpret_cast<RawObject**>(&ptr()->error_); | |
1626 } | |
1627 TokenPosition token_pos_; | |
1628 int8_t type_state_; | |
1629 }; | 1618 }; |
1630 | 1619 |
1631 | 1620 |
1632 class RawTypeRef : public RawAbstractType { | 1621 class RawTypeRef : public RawAbstractType { |
1633 private: | 1622 private: |
1634 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); | 1623 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); |
1635 | 1624 |
1636 RawObject** from() { | 1625 RawObject** from() { |
1637 return reinterpret_cast<RawObject**>(&ptr()->type_); | 1626 return reinterpret_cast<RawObject**>(&ptr()->type_); |
1638 } | 1627 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2355 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2344 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2356 kTypedDataInt8ArrayViewCid + 15); | 2345 kTypedDataInt8ArrayViewCid + 15); |
2357 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2346 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2358 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2347 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2359 return (kNullCid - kTypedDataInt8ArrayCid); | 2348 return (kNullCid - kTypedDataInt8ArrayCid); |
2360 } | 2349 } |
2361 | 2350 |
2362 } // namespace dart | 2351 } // namespace dart |
2363 | 2352 |
2364 #endif // VM_RAW_OBJECT_H_ | 2353 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |