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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 2455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 case RawFunction::kRegularFunction: | 2466 case RawFunction::kRegularFunction: |
2467 case RawFunction::kGetterFunction: | 2467 case RawFunction::kGetterFunction: |
2468 case RawFunction::kSetterFunction: | 2468 case RawFunction::kSetterFunction: |
2469 case RawFunction::kImplicitGetter: | 2469 case RawFunction::kImplicitGetter: |
2470 case RawFunction::kImplicitSetter: | 2470 case RawFunction::kImplicitSetter: |
2471 case RawFunction::kMethodExtractor: | 2471 case RawFunction::kMethodExtractor: |
2472 case RawFunction::kNoSuchMethodDispatcher: | 2472 case RawFunction::kNoSuchMethodDispatcher: |
2473 case RawFunction::kInvokeFieldDispatcher: | 2473 case RawFunction::kInvokeFieldDispatcher: |
2474 return true; | 2474 return true; |
2475 case RawFunction::kClosureFunction: | 2475 case RawFunction::kClosureFunction: |
2476 case RawFunction::kImplicitClosureFunction: | |
2477 case RawFunction::kSignatureFunction: | 2476 case RawFunction::kSignatureFunction: |
2478 case RawFunction::kConstructor: | 2477 case RawFunction::kConstructor: |
2479 case RawFunction::kImplicitStaticFinalGetter: | 2478 case RawFunction::kImplicitStaticFinalGetter: |
2480 case RawFunction::kIrregexpFunction: | 2479 case RawFunction::kIrregexpFunction: |
2481 return false; | 2480 return false; |
2482 default: | 2481 default: |
2483 UNREACHABLE(); | 2482 UNREACHABLE(); |
2484 return false; | 2483 return false; |
2485 } | 2484 } |
2486 } | 2485 } |
2487 bool IsStaticFunction() const { | 2486 bool IsStaticFunction() const { |
2488 if (!is_static()) { | 2487 if (!is_static()) { |
2489 return false; | 2488 return false; |
2490 } | 2489 } |
2491 switch (kind()) { | 2490 switch (kind()) { |
2492 case RawFunction::kRegularFunction: | 2491 case RawFunction::kRegularFunction: |
2493 case RawFunction::kGetterFunction: | 2492 case RawFunction::kGetterFunction: |
2494 case RawFunction::kSetterFunction: | 2493 case RawFunction::kSetterFunction: |
2495 case RawFunction::kImplicitGetter: | 2494 case RawFunction::kImplicitGetter: |
2496 case RawFunction::kImplicitSetter: | 2495 case RawFunction::kImplicitSetter: |
2497 case RawFunction::kImplicitStaticFinalGetter: | 2496 case RawFunction::kImplicitStaticFinalGetter: |
2498 case RawFunction::kIrregexpFunction: | 2497 case RawFunction::kIrregexpFunction: |
2499 return true; | 2498 return true; |
2500 case RawFunction::kClosureFunction: | 2499 case RawFunction::kClosureFunction: |
2501 case RawFunction::kImplicitClosureFunction: | |
2502 case RawFunction::kSignatureFunction: | 2500 case RawFunction::kSignatureFunction: |
2503 case RawFunction::kConstructor: | 2501 case RawFunction::kConstructor: |
2504 case RawFunction::kMethodExtractor: | 2502 case RawFunction::kMethodExtractor: |
2505 case RawFunction::kNoSuchMethodDispatcher: | 2503 case RawFunction::kNoSuchMethodDispatcher: |
2506 case RawFunction::kInvokeFieldDispatcher: | 2504 case RawFunction::kInvokeFieldDispatcher: |
2507 return false; | 2505 return false; |
2508 default: | 2506 default: |
2509 UNREACHABLE(); | 2507 UNREACHABLE(); |
2510 return false; | 2508 return false; |
2511 } | 2509 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2768 } | 2766 } |
2769 | 2767 |
2770 // Returns true if this function represents an implicit setter function. | 2768 // Returns true if this function represents an implicit setter function. |
2771 bool IsImplicitSetterFunction() const { | 2769 bool IsImplicitSetterFunction() const { |
2772 return kind() == RawFunction::kImplicitSetter; | 2770 return kind() == RawFunction::kImplicitSetter; |
2773 } | 2771 } |
2774 | 2772 |
2775 // Returns true if this function represents a (possibly implicit) closure | 2773 // Returns true if this function represents a (possibly implicit) closure |
2776 // function. | 2774 // function. |
2777 bool IsClosureFunction() const { | 2775 bool IsClosureFunction() const { |
2778 RawFunction::Kind k = kind(); | 2776 return kind() == RawFunction::kClosureFunction; |
2779 return (k == RawFunction::kClosureFunction) || | |
2780 (k == RawFunction::kImplicitClosureFunction); | |
2781 } | 2777 } |
2782 | 2778 |
2783 // Returns true if this function represents a generated irregexp function. | 2779 // Returns true if this function represents a generated irregexp function. |
2784 bool IsIrregexpFunction() const { | 2780 bool IsIrregexpFunction() const { |
2785 return kind() == RawFunction::kIrregexpFunction; | 2781 return kind() == RawFunction::kIrregexpFunction; |
2786 } | 2782 } |
2787 | 2783 |
2788 // Returns true if this function represents an implicit closure function. | 2784 // Returns true if this function represents an implicit closure function. |
2789 bool IsImplicitClosureFunction() const { | 2785 bool IsImplicitClosureFunction() const; |
2790 return kind() == RawFunction::kImplicitClosureFunction; | |
2791 } | |
2792 | 2786 |
2793 // Returns true if this function represents a converted closure function. | 2787 // Returns true if this function represents a converted closure function. |
2794 bool IsConvertedClosureFunction() const { | 2788 bool IsConvertedClosureFunction() const { |
2795 return kind() == RawFunction::kConvertedClosureFunction; | 2789 return kind() == RawFunction::kConvertedClosureFunction; |
2796 } | 2790 } |
2797 | 2791 |
2798 // Returns true if this function represents a non implicit closure function. | 2792 // Returns true if this function represents a non implicit closure function. |
2799 bool IsNonImplicitClosureFunction() const { | 2793 bool IsNonImplicitClosureFunction() const { |
2800 return IsClosureFunction() && !IsImplicitClosureFunction(); | 2794 return IsClosureFunction() && !IsImplicitClosureFunction(); |
2801 } | 2795 } |
2802 | 2796 |
2803 // Returns true if this function represents an implicit static closure | 2797 // Returns true if this function represents an implicit static closure |
2804 // function. | 2798 // function. |
2805 bool IsImplicitStaticClosureFunction() const { | 2799 bool IsImplicitStaticClosureFunction() const { |
2806 return IsImplicitClosureFunction() && is_static(); | 2800 return is_static() && IsImplicitClosureFunction(); |
2807 } | 2801 } |
2808 static bool IsImplicitStaticClosureFunction(RawFunction* func); | 2802 static bool IsImplicitStaticClosureFunction(RawFunction* func); |
2809 | 2803 |
2810 // Returns true if this function represents an implicit instance closure | 2804 // Returns true if this function represents an implicit instance closure |
2811 // function. | 2805 // function. |
2812 bool IsImplicitInstanceClosureFunction() const { | 2806 bool IsImplicitInstanceClosureFunction() const { |
2813 return IsImplicitClosureFunction() && !is_static(); | 2807 return !is_static() && IsImplicitClosureFunction(); |
2814 } | 2808 } |
2815 | 2809 |
2816 bool IsConstructorClosureFunction() const; | 2810 bool IsConstructorClosureFunction() const; |
2817 | 2811 |
2818 // Returns true if this function represents a local function. | 2812 // Returns true if this function represents a local function. |
2819 bool IsLocalFunction() const { return parent_function() != Function::null(); } | 2813 bool IsLocalFunction() const { return parent_function() != Function::null(); } |
2820 | 2814 |
2821 // Returns true if this function represents a signature function without code. | 2815 // Returns true if this function represents a signature function without code. |
2822 bool IsSignatureFunction() const { | 2816 bool IsSignatureFunction() const { |
2823 return kind() == RawFunction::kSignatureFunction; | 2817 return kind() == RawFunction::kSignatureFunction; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2875 RawFunction::Kind kind, | 2869 RawFunction::Kind kind, |
2876 bool is_static, | 2870 bool is_static, |
2877 bool is_const, | 2871 bool is_const, |
2878 bool is_abstract, | 2872 bool is_abstract, |
2879 bool is_external, | 2873 bool is_external, |
2880 bool is_native, | 2874 bool is_native, |
2881 const Object& owner, | 2875 const Object& owner, |
2882 TokenPosition token_pos, | 2876 TokenPosition token_pos, |
2883 Heap::Space space = Heap::kOld); | 2877 Heap::Space space = Heap::kOld); |
2884 | 2878 |
2885 // Allocates a new Function object representing a closure function | |
2886 // with given kind - kClosureFunction, kImplicitClosureFunction or | |
2887 // kConvertedClosureFunction. | |
2888 static RawFunction* NewClosureFunctionWithKind(RawFunction::Kind kind, | |
2889 const String& name, | |
2890 const Function& parent, | |
2891 TokenPosition token_pos); | |
2892 | |
2893 // Allocates a new Function object representing a closure function. | 2879 // Allocates a new Function object representing a closure function. |
2894 static RawFunction* NewClosureFunction(const String& name, | 2880 static RawFunction* NewClosureFunction(const String& name, |
2895 const Function& parent, | 2881 const Function& parent, |
2896 TokenPosition token_pos); | 2882 TokenPosition token_pos); |
2897 | 2883 |
2898 // Allocates a new Function object representing an implicit closure function. | |
2899 static RawFunction* NewImplicitClosureFunction(const String& name, | |
2900 const Function& parent, | |
2901 TokenPosition token_pos); | |
2902 | |
2903 // Allocates a new Function object representing a converted closure function. | 2884 // Allocates a new Function object representing a converted closure function. |
2904 static RawFunction* NewConvertedClosureFunction(const String& name, | 2885 static RawFunction* NewConvertedClosureFunction(const String& name, |
2905 const Function& parent, | 2886 const Function& parent, |
2906 TokenPosition token_pos); | 2887 TokenPosition token_pos); |
2907 | 2888 |
2908 // Allocates a new Function object representing a signature function. | 2889 // Allocates a new Function object representing a signature function. |
2909 // The owner is the scope class of the function type. | 2890 // The owner is the scope class of the function type. |
2910 // The parent is the enclosing function or null if none. | 2891 // The parent is the enclosing function or null if none. |
2911 static RawFunction* NewSignatureFunction(const Object& owner, | 2892 static RawFunction* NewSignatureFunction(const Object& owner, |
2912 const Function& parent, | 2893 const Function& parent, |
(...skipping 6072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8985 | 8966 |
8986 inline void TypeArguments::SetHash(intptr_t value) const { | 8967 inline void TypeArguments::SetHash(intptr_t value) const { |
8987 // This is only safe because we create a new Smi, which does not cause | 8968 // This is only safe because we create a new Smi, which does not cause |
8988 // heap allocation. | 8969 // heap allocation. |
8989 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8970 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
8990 } | 8971 } |
8991 | 8972 |
8992 } // namespace dart | 8973 } // namespace dart |
8993 | 8974 |
8994 #endif // RUNTIME_VM_OBJECT_H_ | 8975 #endif // RUNTIME_VM_OBJECT_H_ |
OLD | NEW |