1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #ifndef SYZYGY_REFINERY_TYPES_TYPE_NAMER_H_
16 : #define SYZYGY_REFINERY_TYPES_TYPE_NAMER_H_
17 :
18 : #include <dia2.h>
19 :
20 : #include "base/macros.h"
21 : #include "base/strings/string16.h"
22 : #include "syzygy/refinery/types/type.h"
23 :
24 m : namespace refinery {
25 :
26 m : bool GetSymBaseTypeName(IDiaSymbol* symbol, base::string16* type_name);
27 :
28 : // Handles naming for types whose name depends on other types' names.
29 : // @note array names do not depend on the index type.
30 m : class TypeNamer {
31 m : public:
32 : // @param set_decorated_name whether the namer should handle decorated names.
33 : // @note Decorated name handling should be disabled when accessing type
34 : // information through DIA as it does not expose decorated names.
35 m : explicit TypeNamer(bool set_decorated_name);
36 m : ~TypeNamer();
37 :
38 : // Assign names for types whose name depends on the name of other types.
39 : // @returns true on success, false on failure.
40 m : bool EnsureTypeName(TypePtr type) const;
41 :
42 m : static bool GetTypeName(IDiaSymbol* type, base::string16* type_name);
43 :
44 m : private:
45 m : bool AssignPointerName(PointerTypePtr ptr) const;
46 m : bool AssignArrayName(ArrayTypePtr array) const;
47 m : bool AssignFunctionName(FunctionTypePtr function) const;
48 :
49 m : static bool GetPointerName(IDiaSymbol* type, base::string16* type_name);
50 m : static bool GetArrayName(IDiaSymbol* type, base::string16* type_name);
51 m : static bool GetFunctionName(IDiaSymbol* type, base::string16* type_name);
52 :
53 m : static void GetPointerNameSuffix(bool is_const,
54 m : bool is_volatile,
55 m : bool is_ref,
56 m : base::string16* suffix);
57 :
58 m : static void GetArrayNameSuffix(bool is_const,
59 m : bool is_volatile,
60 m : size_t count,
61 m : base::string16* suffix);
62 :
63 m : bool set_decorated_name_;
64 :
65 m : DISALLOW_COPY_AND_ASSIGN(TypeNamer);
66 m : };
67 :
68 m : } // namespace refinery
69 :
70 : #endif // SYZYGY_REFINERY_TYPES_TYPE_NAMER_H_
|