Ignore:
Timestamp:
Nov 17, 2023, 10:40:21 AM (8 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
0f6d2884
Parents:
e580aa5
Message:

Reformating and clean-up in SymTab? directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Mangler.h

    re580aa5 rb0845f9  
    3434}
    3535
    36 namespace SymTab {
    37         namespace Mangler {
    38                 namespace Encoding {
    39                         extern const std::string manglePrefix;
    40                         extern const std::string basicTypes[];
    41                         extern const std::map<int, std::string> qualifiers;
     36namespace Mangle {
    4237
    43                         extern const std::string void_t;
    44                         extern const std::string zero;
    45                         extern const std::string one;
     38/// Bitflags for mangle Mode:
     39enum {
     40        NoOverrideable  = 1 << 0,
     41        Type            = 1 << 1,
     42        NoGenericParams = 1 << 2
     43};
    4644
    47                         extern const std::string function;
    48                         extern const std::string tuple;
    49                         extern const std::string pointer;
    50                         extern const std::string array;
    51                         extern const std::string qualifiedTypeStart;
    52                         extern const std::string qualifiedTypeEnd;
    53 
    54                         extern const std::string forall;
    55                         extern const std::string typeVariables[];
    56 
    57                         extern const std::string struct_t;
    58                         extern const std::string union_t;
    59                         extern const std::string enum_t;
    60                         extern const std::string type;
    61 
    62                         extern const std::string autogen;
    63                         extern const std::string intrinsic;
     45/// Bitflag type for mangle Mode:
     46struct mangle_flags {
     47        union {
     48                unsigned int val;
     49                struct {
     50                        bool no_overrideable   : 1;
     51                        bool type              : 1;
     52                        bool no_generic_params : 1;
    6453                };
    65         } // Mangler
    66 } // SymTab
    67 
    68 namespace Mangle {
    69         /// Bitflags for mangle modes
    70         enum {
    71                 NoOverrideable  = 1 << 0,
    72                 Type            = 1 << 1,
    73                 NoGenericParams = 1 << 2
    7454        };
    7555
    76         /// Bitflag type for mangler modes
    77         struct mangle_flags {
    78                 union {
    79                         unsigned int val;
    80                         struct {
    81                                 bool no_overrideable   : 1;
    82                                 bool type              : 1;
    83                                 bool no_generic_params : 1;
    84                         };
    85                 };
     56        constexpr mangle_flags( unsigned int val ) : val(val) {}
     57};
    8658
    87                 constexpr mangle_flags( unsigned int val ) : val(val) {}
    88         };
     59using Mode = bitfield<mangle_flags>;
    8960
    90         using Mode = bitfield<mangle_flags>;
     61/// Mangle declaration name.
     62std::string mangle( const ast::Node * decl, Mode mode = {} );
    9163
    92         /// Mangle declaration name.
    93         std::string mangle( const ast::Node * decl, Mode mode = {} );
     64/// Most common mangle configuration for types.
     65static inline std::string mangleType( const ast::Node * type ) {
     66        return mangle( type, { NoOverrideable | Type } );
     67}
    9468
    95         /// Most common mangle configuration for types.
    96         static inline std::string mangleType( const ast::Node * type ) {
    97                 return mangle( type, { NoOverrideable | Type } );
    98         }
     69/// The substrings used in name mangling and demangling.
     70namespace Encoding {
     71        extern const std::string manglePrefix;
     72        extern const std::string basicTypes[];
     73        extern const std::map<int, std::string> qualifiers;
    9974
    100         namespace Encoding {
    101                 using namespace SymTab::Mangler::Encoding;
    102         };
     75        extern const std::string void_t;
     76        extern const std::string zero;
     77        extern const std::string one;
     78
     79        extern const std::string function;
     80        extern const std::string tuple;
     81        extern const std::string pointer;
     82        extern const std::string array;
     83        extern const std::string qualifiedTypeStart;
     84        extern const std::string qualifiedTypeEnd;
     85
     86        extern const std::string forall;
     87        extern const std::string typeVariables[];
     88
     89        extern const std::string struct_t;
     90        extern const std::string union_t;
     91        extern const std::string enum_t;
     92        extern const std::string type;
     93
     94        extern const std::string autogen;
     95        extern const std::string intrinsic;
     96}
     97
    10398}
    10499
Note: See TracChangeset for help on using the changeset viewer.