Mercurial > hg > CbC > CbC_gcc
comparison gcc/go/gofrontend/types.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
561 // traversing it. | 561 // traversing it. |
562 bool | 562 bool |
563 verify() | 563 verify() |
564 { return this->do_verify(); } | 564 { return this->do_verify(); } |
565 | 565 |
566 // Return true if two types are identical. If ERRORS_ARE_IDENTICAL, | 566 // Bit flags to pass to are_identical and friends. |
567 // returns that an erroneous type is identical to any other type; | 567 |
568 // this is used to avoid cascading errors. If this returns false, | 568 // Treat error types as their own distinct type. Sometimes we |
569 // ignore error types--treat them as identical to every other | |
570 // type--to avoid cascading errors. | |
571 static const int COMPARE_ERRORS = 1; | |
572 | |
573 // Compare struct field tags when comparing structs. We ignore | |
574 // struct field tags for purposes of type conversion. | |
575 static const int COMPARE_TAGS = 2; | |
576 | |
577 // Compare aliases: treat an alias to T as distinct from T. | |
578 static const int COMPARE_ALIASES = 4; | |
579 | |
580 // Return true if two types are identical. If this returns false, | |
569 // and REASON is not NULL, it may set *REASON. | 581 // and REASON is not NULL, it may set *REASON. |
570 static bool | 582 static bool |
571 are_identical(const Type* lhs, const Type* rhs, bool errors_are_identical, | 583 are_identical(const Type* lhs, const Type* rhs, int flags, |
572 std::string* reason); | 584 std::string* reason); |
573 | |
574 // An argument to are_identical_cmp_tags, indicating whether or not | |
575 // to compare struct field tags. | |
576 enum Cmp_tags { | |
577 COMPARE_TAGS, | |
578 IGNORE_TAGS | |
579 }; | |
580 | |
581 // Return true if two types are identical. This is like the | |
582 // are_identical function, but also takes a CMP_TAGS argument | |
583 // indicating whether to compare struct tags. Otherwise the | |
584 // parameters are as for are_identical. | |
585 static bool | |
586 are_identical_cmp_tags(const Type* lhs, const Type* rhs, | |
587 Cmp_tags, bool errors_are_identical, | |
588 std::string* reason); | |
589 | 585 |
590 // Return true if two types are compatible for use in a binary | 586 // Return true if two types are compatible for use in a binary |
591 // operation, other than a shift, comparison, or channel send. This | 587 // operation, other than a shift, comparison, or channel send. This |
592 // is an equivalence relation. | 588 // is an equivalence relation. |
593 static bool | 589 static bool |
646 | 642 |
647 // Return a hash code for this type for the method hash table. | 643 // Return a hash code for this type for the method hash table. |
648 // Types which are equivalent according to are_identical will have | 644 // Types which are equivalent according to are_identical will have |
649 // the same hash code. | 645 // the same hash code. |
650 unsigned int | 646 unsigned int |
651 hash_for_method(Gogo*) const; | 647 hash_for_method(Gogo*, int) const; |
652 | 648 |
653 // Return the type classification. | 649 // Return the type classification. |
654 Type_classification | 650 Type_classification |
655 classification() const | 651 classification() const |
656 { return this->classification_; } | 652 { return this->classification_; } |
674 forwarded(); | 670 forwarded(); |
675 | 671 |
676 const Type* | 672 const Type* |
677 forwarded() const; | 673 forwarded() const; |
678 | 674 |
675 // Return the type skipping any alias definitions and any defined | |
676 // forward declarations. This is like forwarded, but also | |
677 // recursively expands alias definitions to the aliased type. | |
678 Type* | |
679 unalias(); | |
680 | |
681 const Type* | |
682 unalias() const; | |
683 | |
679 // Return true if this is a basic type: a type which is not composed | 684 // Return true if this is a basic type: a type which is not composed |
680 // of other types, and is not void. | 685 // of other types, and is not void. |
681 bool | 686 bool |
682 is_basic_type() const; | 687 is_basic_type() const; |
683 | 688 |
905 // represent that as pointer-to-void. | 910 // represent that as pointer-to-void. |
906 bool | 911 bool |
907 is_unsafe_pointer_type() const | 912 is_unsafe_pointer_type() const |
908 { return this->points_to() != NULL && this->points_to()->is_void_type(); } | 913 { return this->points_to() != NULL && this->points_to()->is_void_type(); } |
909 | 914 |
915 // Return a version of this type with any expressions copied, but | |
916 // only if copying the expressions will affect the size of the type. | |
917 // If there are no such expressions in the type (expressions can | |
918 // only occur in array types), just return the same type. If any | |
919 // expressions can not affect the size of the type, just return the | |
920 // same type. | |
921 Type* | |
922 copy_expressions(); | |
923 | |
910 // Look for field or method NAME for TYPE. Return an expression for | 924 // Look for field or method NAME for TYPE. Return an expression for |
911 // it, bound to EXPR. | 925 // it, bound to EXPR. |
912 static Expression* | 926 static Expression* |
913 bind_field_or_method(Gogo*, const Type* type, Expression* expr, | 927 bind_field_or_method(Gogo*, const Type* type, Expression* expr, |
914 const std::string& name, Location); | 928 const std::string& name, Location); |
1062 virtual bool | 1076 virtual bool |
1063 do_in_heap() | 1077 do_in_heap() |
1064 { return true; } | 1078 { return true; } |
1065 | 1079 |
1066 virtual unsigned int | 1080 virtual unsigned int |
1067 do_hash_for_method(Gogo*) const; | 1081 do_hash_for_method(Gogo*, int) const; |
1068 | 1082 |
1069 virtual Btype* | 1083 virtual Btype* |
1070 do_get_backend(Gogo*) = 0; | 1084 do_get_backend(Gogo*) = 0; |
1071 | 1085 |
1072 virtual Expression* | 1086 virtual Expression* |
1361 Bvariable* gc_symbol_var_; | 1375 Bvariable* gc_symbol_var_; |
1362 // Whether this type can appear in the heap. | 1376 // Whether this type can appear in the heap. |
1363 bool in_heap_; | 1377 bool in_heap_; |
1364 }; | 1378 }; |
1365 | 1379 |
1366 // Type hash table operations. | 1380 // Type hash table operations, treating aliases as identical to the |
1381 // types that they alias. | |
1367 | 1382 |
1368 class Type_hash_identical | 1383 class Type_hash_identical |
1369 { | 1384 { |
1370 public: | 1385 public: |
1371 unsigned int | 1386 unsigned int |
1372 operator()(const Type* type) const | 1387 operator()(const Type* type) const |
1373 { return type->hash_for_method(NULL); } | 1388 { |
1389 return type->hash_for_method(NULL, | |
1390 Type::COMPARE_ERRORS | Type::COMPARE_TAGS); | |
1391 } | |
1374 }; | 1392 }; |
1375 | 1393 |
1376 class Type_identical | 1394 class Type_identical |
1377 { | 1395 { |
1378 public: | 1396 public: |
1379 bool | 1397 bool |
1380 operator()(const Type* t1, const Type* t2) const | 1398 operator()(const Type* t1, const Type* t2) const |
1381 { return Type::are_identical(t1, t2, false, NULL); } | 1399 { |
1400 return Type::are_identical(t1, t2, | |
1401 Type::COMPARE_ERRORS | Type::COMPARE_TAGS, | |
1402 NULL); | |
1403 } | |
1382 }; | 1404 }; |
1383 | 1405 |
1384 // An identifier with a type. | 1406 // An identifier with a type. |
1385 | 1407 |
1386 class Typed_identifier | 1408 class Typed_identifier |
1478 void | 1500 void |
1479 sort_by_name(); | 1501 sort_by_name(); |
1480 | 1502 |
1481 // Traverse types. | 1503 // Traverse types. |
1482 int | 1504 int |
1483 traverse(Traverse*); | 1505 traverse(Traverse*) const; |
1484 | 1506 |
1485 // Return the first and last elements. | 1507 // Return the first and last elements. |
1486 Typed_identifier& | 1508 Typed_identifier& |
1487 front() | 1509 front() |
1488 { return this->entries_.front(); } | 1510 { return this->entries_.front(); } |
1704 bool | 1726 bool |
1705 do_compare_is_identity(Gogo*) | 1727 do_compare_is_identity(Gogo*) |
1706 { return true; } | 1728 { return true; } |
1707 | 1729 |
1708 unsigned int | 1730 unsigned int |
1709 do_hash_for_method(Gogo*) const; | 1731 do_hash_for_method(Gogo*, int) const; |
1710 | 1732 |
1711 Btype* | 1733 Btype* |
1712 do_get_backend(Gogo*); | 1734 do_get_backend(Gogo*); |
1713 | 1735 |
1714 Expression* | 1736 Expression* |
1790 bool | 1812 bool |
1791 do_needs_key_update() | 1813 do_needs_key_update() |
1792 { return true; } | 1814 { return true; } |
1793 | 1815 |
1794 unsigned int | 1816 unsigned int |
1795 do_hash_for_method(Gogo*) const; | 1817 do_hash_for_method(Gogo*, int) const; |
1796 | 1818 |
1797 Btype* | 1819 Btype* |
1798 do_get_backend(Gogo*); | 1820 do_get_backend(Gogo*); |
1799 | 1821 |
1800 Expression* | 1822 Expression* |
1868 bool | 1890 bool |
1869 do_needs_key_update() | 1891 do_needs_key_update() |
1870 { return true; } | 1892 { return true; } |
1871 | 1893 |
1872 unsigned int | 1894 unsigned int |
1873 do_hash_for_method(Gogo*) const; | 1895 do_hash_for_method(Gogo*, int) const; |
1874 | 1896 |
1875 Btype* | 1897 Btype* |
1876 do_get_backend(Gogo*); | 1898 do_get_backend(Gogo*); |
1877 | 1899 |
1878 Expression* | 1900 Expression* |
2016 bool | 2038 bool |
2017 is_valid_redeclaration(const Function_type* t, std::string*) const; | 2039 is_valid_redeclaration(const Function_type* t, std::string*) const; |
2018 | 2040 |
2019 // Whether this type is the same as T. | 2041 // Whether this type is the same as T. |
2020 bool | 2042 bool |
2021 is_identical(const Function_type* t, bool ignore_receiver, | 2043 is_identical(const Function_type* t, bool ignore_receiver, int flags, |
2022 Cmp_tags, bool errors_are_identical, std::string*) const; | 2044 std::string*) const; |
2023 | 2045 |
2024 // Record that this is a varargs function. | 2046 // Record that this is a varargs function. |
2025 void | 2047 void |
2026 set_is_varargs() | 2048 set_is_varargs() |
2027 { this->is_varargs_ = true; } | 2049 { this->is_varargs_ = true; } |
2063 // Return the backend representation of this function type. This is used | 2085 // Return the backend representation of this function type. This is used |
2064 // as the real type of a backend function declaration or defintion. | 2086 // as the real type of a backend function declaration or defintion. |
2065 Btype* | 2087 Btype* |
2066 get_backend_fntype(Gogo*); | 2088 get_backend_fntype(Gogo*); |
2067 | 2089 |
2090 // Return whether this is a Backend_function_type. | |
2091 virtual bool | |
2092 is_backend_function_type() const | |
2093 { return false; } | |
2094 | |
2068 protected: | 2095 protected: |
2069 int | 2096 int |
2070 do_traverse(Traverse*); | 2097 do_traverse(Traverse*); |
2071 | 2098 |
2072 // A function descriptor may be allocated on the heap. | 2099 // A function descriptor may be allocated on the heap. |
2077 bool | 2104 bool |
2078 do_compare_is_identity(Gogo*) | 2105 do_compare_is_identity(Gogo*) |
2079 { return false; } | 2106 { return false; } |
2080 | 2107 |
2081 unsigned int | 2108 unsigned int |
2082 do_hash_for_method(Gogo*) const; | 2109 do_hash_for_method(Gogo*, int) const; |
2083 | 2110 |
2084 Btype* | 2111 Btype* |
2085 do_get_backend(Gogo*); | 2112 do_get_backend(Gogo*); |
2086 | 2113 |
2087 Expression* | 2114 Expression* |
2156 Typed_identifier_list* parameters, | 2183 Typed_identifier_list* parameters, |
2157 Typed_identifier_list* results, Location location) | 2184 Typed_identifier_list* results, Location location) |
2158 : Function_type(receiver, parameters, results, location) | 2185 : Function_type(receiver, parameters, results, location) |
2159 { } | 2186 { } |
2160 | 2187 |
2188 // Return whether this is a Backend_function_type. This overrides | |
2189 // Function_type::is_backend_function_type. | |
2190 bool | |
2191 is_backend_function_type() const | |
2192 { return true; } | |
2193 | |
2161 protected: | 2194 protected: |
2162 Btype* | 2195 Btype* |
2163 do_get_backend(Gogo* gogo) | 2196 do_get_backend(Gogo* gogo) |
2164 { return this->get_backend_fntype(gogo); } | 2197 { return this->get_backend_fntype(gogo); } |
2165 }; | 2198 }; |
2200 bool | 2233 bool |
2201 do_compare_is_identity(Gogo*) | 2234 do_compare_is_identity(Gogo*) |
2202 { return true; } | 2235 { return true; } |
2203 | 2236 |
2204 unsigned int | 2237 unsigned int |
2205 do_hash_for_method(Gogo*) const; | 2238 do_hash_for_method(Gogo*, int) const; |
2206 | 2239 |
2207 Btype* | 2240 Btype* |
2208 do_get_backend(Gogo*); | 2241 do_get_backend(Gogo*); |
2209 | 2242 |
2210 Expression* | 2243 Expression* |
2422 // Return the number of fields. | 2455 // Return the number of fields. |
2423 size_t | 2456 size_t |
2424 field_count() const | 2457 field_count() const |
2425 { return this->fields_->size(); } | 2458 { return this->fields_->size(); } |
2426 | 2459 |
2460 // Location of struct definition. | |
2461 Location | |
2462 location() const | |
2463 { return this->location_; } | |
2464 | |
2427 // Push a new field onto the end of the struct. This is used when | 2465 // Push a new field onto the end of the struct. This is used when |
2428 // building a closure variable. | 2466 // building a closure variable. |
2429 void | 2467 void |
2430 push_field(const Struct_field& sf) | 2468 push_field(const Struct_field& sf) |
2431 { this->fields_->push_back(sf); } | 2469 { this->fields_->push_back(sf); } |
2442 unsigned int | 2480 unsigned int |
2443 total_field_count() const; | 2481 total_field_count() const; |
2444 | 2482 |
2445 // Whether this type is identical with T. | 2483 // Whether this type is identical with T. |
2446 bool | 2484 bool |
2447 is_identical(const Struct_type* t, Cmp_tags, | 2485 is_identical(const Struct_type* t, int) const; |
2448 bool errors_are_identical) const; | |
2449 | 2486 |
2450 // Return whether NAME is a local field which is not exported. This | 2487 // Return whether NAME is a local field which is not exported. This |
2451 // is only used for better error reporting. | 2488 // is only used for better error reporting. |
2452 bool | 2489 bool |
2453 is_unexported_local_field(Gogo*, const std::string& name) const; | 2490 is_unexported_local_field(Gogo*, const std::string& name) const; |
2462 // called after the finalize_methods pass. | 2499 // called after the finalize_methods pass. |
2463 bool | 2500 bool |
2464 has_any_methods() const | 2501 has_any_methods() const |
2465 { return this->all_methods_ != NULL; } | 2502 { return this->all_methods_ != NULL; } |
2466 | 2503 |
2467 // Return the methods for tihs type. This should only be called | 2504 // Return the methods for this type. This should only be called |
2468 // after the finalize_methods pass. | 2505 // after the finalize_methods pass. |
2469 const Methods* | 2506 const Methods* |
2470 methods() const | 2507 methods() const |
2471 { return this->all_methods_; } | 2508 { return this->all_methods_; } |
2472 | 2509 |
2554 | 2591 |
2555 bool | 2592 bool |
2556 do_in_heap(); | 2593 do_in_heap(); |
2557 | 2594 |
2558 unsigned int | 2595 unsigned int |
2559 do_hash_for_method(Gogo*) const; | 2596 do_hash_for_method(Gogo*, int) const; |
2560 | 2597 |
2561 Btype* | 2598 Btype* |
2562 do_get_backend(Gogo*); | 2599 do_get_backend(Gogo*); |
2563 | 2600 |
2564 Expression* | 2601 Expression* |
2648 bool | 2685 bool |
2649 int_length(int64_t* plen); | 2686 int_length(int64_t* plen); |
2650 | 2687 |
2651 // Whether this type is identical with T. | 2688 // Whether this type is identical with T. |
2652 bool | 2689 bool |
2653 is_identical(const Array_type* t, Cmp_tags, | 2690 is_identical(const Array_type* t, int) const; |
2654 bool errors_are_identical) const; | |
2655 | 2691 |
2656 // Return an expression for the pointer to the values in an array. | 2692 // Return an expression for the pointer to the values in an array. |
2657 Expression* | 2693 Expression* |
2658 get_value_pointer(Gogo*, Expression* array, bool is_lvalue) const; | 2694 get_value_pointer(Gogo*, Expression* array, bool is_lvalue) const; |
2659 | 2695 |
2731 bool | 2767 bool |
2732 do_in_heap() | 2768 do_in_heap() |
2733 { return this->length_ == NULL || this->element_type_->in_heap(); } | 2769 { return this->length_ == NULL || this->element_type_->in_heap(); } |
2734 | 2770 |
2735 unsigned int | 2771 unsigned int |
2736 do_hash_for_method(Gogo*) const; | 2772 do_hash_for_method(Gogo*, int) const; |
2737 | 2773 |
2738 Btype* | 2774 Btype* |
2739 do_get_backend(Gogo*); | 2775 do_get_backend(Gogo*); |
2740 | 2776 |
2741 Expression* | 2777 Expression* |
2814 static Bvariable* | 2850 static Bvariable* |
2815 backend_zero_value(Gogo*); | 2851 backend_zero_value(Gogo*); |
2816 | 2852 |
2817 // Whether this type is identical with T. | 2853 // Whether this type is identical with T. |
2818 bool | 2854 bool |
2819 is_identical(const Map_type* t, Cmp_tags, | 2855 is_identical(const Map_type* t, int) const; |
2820 bool errors_are_identical) const; | |
2821 | 2856 |
2822 // Import a map type. | 2857 // Import a map type. |
2823 static Map_type* | 2858 static Map_type* |
2824 do_import(Import*); | 2859 do_import(Import*); |
2825 | 2860 |
2826 static Type* | 2861 static Type* |
2827 make_map_type_descriptor_type(); | 2862 make_map_type_descriptor_type(); |
2863 | |
2864 // This must be in sync with libgo/go/runtime/hashmap.go. | |
2865 static const int bucket_size = 8; | |
2828 | 2866 |
2829 protected: | 2867 protected: |
2830 int | 2868 int |
2831 do_traverse(Traverse*); | 2869 do_traverse(Traverse*); |
2832 | 2870 |
2846 { | 2884 { |
2847 return this->key_type_->is_reflexive() && this->val_type_->is_reflexive(); | 2885 return this->key_type_->is_reflexive() && this->val_type_->is_reflexive(); |
2848 } | 2886 } |
2849 | 2887 |
2850 unsigned int | 2888 unsigned int |
2851 do_hash_for_method(Gogo*) const; | 2889 do_hash_for_method(Gogo*, int) const; |
2852 | 2890 |
2853 Btype* | 2891 Btype* |
2854 do_get_backend(Gogo*); | 2892 do_get_backend(Gogo*); |
2855 | 2893 |
2856 Expression* | 2894 Expression* |
2865 void | 2903 void |
2866 do_export(Export*) const; | 2904 do_export(Export*) const; |
2867 | 2905 |
2868 private: | 2906 private: |
2869 // These must be in sync with libgo/go/runtime/hashmap.go. | 2907 // These must be in sync with libgo/go/runtime/hashmap.go. |
2870 static const int bucket_size = 8; | |
2871 static const int max_key_size = 128; | 2908 static const int max_key_size = 128; |
2872 static const int max_val_size = 128; | 2909 static const int max_val_size = 128; |
2873 static const int max_zero_size = 1024; | 2910 static const int max_zero_size = 1024; |
2874 | 2911 |
2875 // Maps with value types larger than max_zero_size require passing a | 2912 // Maps with value types larger than max_zero_size require passing a |
2932 element_type() const | 2969 element_type() const |
2933 { return this->element_type_; } | 2970 { return this->element_type_; } |
2934 | 2971 |
2935 // Whether this type is identical with T. | 2972 // Whether this type is identical with T. |
2936 bool | 2973 bool |
2937 is_identical(const Channel_type* t, Cmp_tags, | 2974 is_identical(const Channel_type* t, int) const; |
2938 bool errors_are_identical) const; | |
2939 | 2975 |
2940 // Import a channel type. | 2976 // Import a channel type. |
2941 static Channel_type* | 2977 static Channel_type* |
2942 do_import(Import*); | 2978 do_import(Import*); |
2943 | 2979 |
2944 static Type* | 2980 static Type* |
2945 make_chan_type_descriptor_type(); | 2981 make_chan_type_descriptor_type(); |
2946 | 2982 |
2947 static Type* | 2983 static Type* |
2948 select_type(int ncases); | 2984 select_case_type(); |
2949 | 2985 |
2950 protected: | 2986 protected: |
2951 int | 2987 int |
2952 do_traverse(Traverse* traverse) | 2988 do_traverse(Traverse* traverse) |
2953 { return Type::traverse(this->element_type_, traverse); } | 2989 { return Type::traverse(this->element_type_, traverse); } |
2962 bool | 2998 bool |
2963 do_compare_is_identity(Gogo*) | 2999 do_compare_is_identity(Gogo*) |
2964 { return true; } | 3000 { return true; } |
2965 | 3001 |
2966 unsigned int | 3002 unsigned int |
2967 do_hash_for_method(Gogo*) const; | 3003 do_hash_for_method(Gogo*, int) const; |
2968 | 3004 |
2969 Btype* | 3005 Btype* |
2970 do_get_backend(Gogo*); | 3006 do_get_backend(Gogo*); |
2971 | 3007 |
2972 Expression* | 3008 Expression* |
3021 { | 3057 { |
3022 go_assert(this->methods_are_finalized_); | 3058 go_assert(this->methods_are_finalized_); |
3023 return this->all_methods_ == NULL; | 3059 return this->all_methods_ == NULL; |
3024 } | 3060 } |
3025 | 3061 |
3026 // Return the list of methods. This will return NULL for an empty | 3062 // Return the list of locally defined methos. This will return NULL |
3027 // interface. | 3063 // for an empty interface. Embedded interfaces will appear in this |
3064 // list as an entry with no name. | |
3065 const Typed_identifier_list* | |
3066 local_methods() const | |
3067 { return this->parse_methods_; } | |
3068 | |
3069 // Return the list of all methods. This will return NULL for an | |
3070 // empty interface. | |
3028 const Typed_identifier_list* | 3071 const Typed_identifier_list* |
3029 methods() const; | 3072 methods() const; |
3030 | 3073 |
3031 // Return the number of methods. | 3074 // Return the number of methods. |
3032 size_t | 3075 size_t |
3052 implements_interface(const Type* t, std::string* reason) const; | 3095 implements_interface(const Type* t, std::string* reason) const; |
3053 | 3096 |
3054 // Whether this type is identical with T. REASON is as in | 3097 // Whether this type is identical with T. REASON is as in |
3055 // implements_interface. | 3098 // implements_interface. |
3056 bool | 3099 bool |
3057 is_identical(const Interface_type* t, Cmp_tags, | 3100 is_identical(const Interface_type* t, int) const; |
3058 bool errors_are_identical) const; | |
3059 | 3101 |
3060 // Whether we can assign T to this type. is_identical is known to | 3102 // Whether we can assign T to this type. is_identical is known to |
3061 // be false. | 3103 // be false. |
3062 bool | 3104 bool |
3063 is_compatible_for_assign(const Interface_type*, std::string* reason) const; | 3105 is_compatible_for_assign(const Interface_type*, std::string* reason) const; |
3113 bool | 3155 bool |
3114 do_needs_key_update() | 3156 do_needs_key_update() |
3115 { return true; } | 3157 { return true; } |
3116 | 3158 |
3117 unsigned int | 3159 unsigned int |
3118 do_hash_for_method(Gogo*) const; | 3160 do_hash_for_method(Gogo*, int) const; |
3119 | 3161 |
3120 Btype* | 3162 Btype* |
3121 do_get_backend(Gogo*); | 3163 do_get_backend(Gogo*); |
3122 | 3164 |
3123 Expression* | 3165 Expression* |
3146 const Interface_type* t2; | 3188 const Interface_type* t2; |
3147 }; | 3189 }; |
3148 | 3190 |
3149 bool | 3191 bool |
3150 assume_identical(const Interface_type*, const Interface_type*) const; | 3192 assume_identical(const Interface_type*, const Interface_type*) const; |
3193 | |
3194 struct Bmethods_map_entry | |
3195 { | |
3196 Btype *btype; | |
3197 bool is_placeholder; | |
3198 }; | |
3199 | |
3200 // A mapping from Interface_type to the backend type of its bmethods_, | |
3201 // used to ensure that the backend representation of identical types | |
3202 // is identical. | |
3203 typedef Unordered_map_hash(const Interface_type*, Bmethods_map_entry, | |
3204 Type_hash_identical, Type_identical) Bmethods_map; | |
3205 | |
3206 static Bmethods_map bmethods_map; | |
3151 | 3207 |
3152 // The list of methods associated with the interface from the | 3208 // The list of methods associated with the interface from the |
3153 // parser. This will be NULL for the empty interface. This may | 3209 // parser. This will be NULL for the empty interface. This may |
3154 // include unnamed interface types. | 3210 // include unnamed interface types. |
3155 Typed_identifier_list* parse_methods_; | 3211 Typed_identifier_list* parse_methods_; |
3191 named_object_(named_object), in_function_(NULL), in_function_index_(0), | 3247 named_object_(named_object), in_function_(NULL), in_function_index_(0), |
3192 type_(type), local_methods_(NULL), all_methods_(NULL), | 3248 type_(type), local_methods_(NULL), all_methods_(NULL), |
3193 interface_method_tables_(NULL), pointer_interface_method_tables_(NULL), | 3249 interface_method_tables_(NULL), pointer_interface_method_tables_(NULL), |
3194 location_(location), named_btype_(NULL), dependencies_(), | 3250 location_(location), named_btype_(NULL), dependencies_(), |
3195 is_alias_(false), is_visible_(true), is_error_(false), in_heap_(true), | 3251 is_alias_(false), is_visible_(true), is_error_(false), in_heap_(true), |
3196 is_placeholder_(false), is_converted_(false), is_circular_(false), | 3252 is_placeholder_(false), is_converted_(false), is_verified_(false), |
3197 is_verified_(false), seen_(false), seen_in_compare_is_identity_(false), | 3253 seen_(false), seen_in_compare_is_identity_(false), |
3198 seen_in_get_backend_(false), seen_alias_(false) | 3254 seen_in_get_backend_(false), seen_alias_(false) |
3199 { } | 3255 { } |
3200 | 3256 |
3201 // Return the associated Named_object. This holds the actual name. | 3257 // Return the associated Named_object. This holds the actual name. |
3202 Named_object* | 3258 Named_object* |
3293 // Whether this named type is valid. A recursive named type is invalid. | 3349 // Whether this named type is valid. A recursive named type is invalid. |
3294 bool | 3350 bool |
3295 is_valid() const | 3351 is_valid() const |
3296 { return !this->is_error_; } | 3352 { return !this->is_error_; } |
3297 | 3353 |
3298 // Whether this is a circular type: a pointer or function type that | |
3299 // refers to itself, which is not possible in C. | |
3300 bool | |
3301 is_circular() const | |
3302 { return this->is_circular_; } | |
3303 | |
3304 // Return the base type for this type. | 3354 // Return the base type for this type. |
3305 Type* | 3355 Type* |
3306 named_base(); | 3356 named_base(); |
3307 | 3357 |
3308 const Type* | 3358 const Type* |
3393 // Append the mangled type name as for Type::append_mangled_name, | 3443 // Append the mangled type name as for Type::append_mangled_name, |
3394 // but if USE_ALIAS use the alias name rather than the alias target. | 3444 // but if USE_ALIAS use the alias name rather than the alias target. |
3395 void | 3445 void |
3396 append_mangled_type_name(Gogo*, bool use_alias, std::string*) const; | 3446 append_mangled_type_name(Gogo*, bool use_alias, std::string*) const; |
3397 | 3447 |
3398 // Export the type. | |
3399 void | |
3400 export_named_type(Export*, const std::string& name) const; | |
3401 | |
3402 // Import a named type. | 3448 // Import a named type. |
3403 static void | 3449 static void |
3404 import_named_type(Import*, Named_type**); | 3450 import_named_type(Import*, Named_type**); |
3405 | 3451 |
3406 // Initial conversion to backend representation. | 3452 // Initial conversion to backend representation. |
3430 bool | 3476 bool |
3431 do_in_heap() | 3477 do_in_heap() |
3432 { return this->in_heap_ && this->type_->in_heap(); } | 3478 { return this->in_heap_ && this->type_->in_heap(); } |
3433 | 3479 |
3434 unsigned int | 3480 unsigned int |
3435 do_hash_for_method(Gogo*) const; | 3481 do_hash_for_method(Gogo*, int) const; |
3436 | 3482 |
3437 Btype* | 3483 Btype* |
3438 do_get_backend(Gogo*); | 3484 do_get_backend(Gogo*); |
3439 | 3485 |
3440 Expression* | 3486 Expression* |
3505 // which the final size of the type is not known. | 3551 // which the final size of the type is not known. |
3506 bool is_placeholder_; | 3552 bool is_placeholder_; |
3507 // Whether this type has been converted to the backend | 3553 // Whether this type has been converted to the backend |
3508 // representation. Implies that is_placeholder_ is false. | 3554 // representation. Implies that is_placeholder_ is false. |
3509 bool is_converted_; | 3555 bool is_converted_; |
3510 // Whether this is a pointer or function type which refers to the | |
3511 // type itself. | |
3512 bool is_circular_; | |
3513 // Whether this type has been verified. | 3556 // Whether this type has been verified. |
3514 bool is_verified_; | 3557 bool is_verified_; |
3515 // In a recursive operation such as has_pointer, this flag is used | 3558 // In a recursive operation such as has_pointer, this flag is used |
3516 // to prevent infinite recursion when a type refers to itself. This | 3559 // to prevent infinite recursion when a type refers to itself. This |
3517 // is mutable because it is always reset to false when the function | 3560 // is mutable because it is always reset to false when the function |
3596 bool | 3639 bool |
3597 do_in_heap() | 3640 do_in_heap() |
3598 { return this->real_type()->in_heap(); } | 3641 { return this->real_type()->in_heap(); } |
3599 | 3642 |
3600 unsigned int | 3643 unsigned int |
3601 do_hash_for_method(Gogo* gogo) const | 3644 do_hash_for_method(Gogo* gogo, int flags) const |
3602 { return this->real_type()->hash_for_method(gogo); } | 3645 { return this->real_type()->hash_for_method(gogo, flags); } |
3603 | 3646 |
3604 Btype* | 3647 Btype* |
3605 do_get_backend(Gogo* gogo); | 3648 do_get_backend(Gogo* gogo); |
3606 | 3649 |
3607 Expression* | 3650 Expression* |