Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Mangler.h

    r6f096d2 rd7d9a60  
    2121#include <utility>            // for pair
    2222
    23 #include "AST/Bitfield.hpp"
    24 #include "AST/Fwd.hpp"
    2523#include "SynTree/SynTree.h"  // for Types
    2624#include "SynTree/Visitor.h"  // for Visitor, maybeAccept
    27 
    28 // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling
    29 // The CFA name mangling scheme is based closely on the itanium C++ name mangling scheme, with the following key differences:
    30 // * Variable names are also mangled to include type information, not just functions
    31 // * CFA does not have template expansion, so the rules for function specialization do not apply.
    32 // * CFA instead has to handle type parameters and assertion parameters.
    33 // * Currently name compression is not implemented.
    34 
    35 namespace ResolvExpr {
    36         class TypeEnvironment;
    37 }
    3825
    3926namespace SymTab {
    4027        namespace Mangler {
    4128                /// Mangle syntax tree object; primary interface to clients
    42                 std::string mangle( const BaseSyntaxNode * decl, bool mangleOverridable = true, bool typeMode = false, bool mangleGenericParams = true );
     29                std::string mangle( BaseSyntaxNode * decl, bool mangleOverridable = true, bool typeMode = false, bool mangleGenericParams = true );
    4330
    4431                /// Mangle a type name; secondary interface
    45                 std::string mangleType( const Type * ty );
     32                std::string mangleType( Type* ty );
    4633                /// Mangle ignoring generic type parameters
    47                 std::string mangleConcrete( const Type * ty );
    48 
    49                 namespace Encoding {
    50                         extern const std::string manglePrefix;
    51                         extern const std::string basicTypes[];
    52                         extern const std::map<int, std::string> qualifiers;
    53 
    54                         extern const std::string void_t;
    55                         extern const std::string zero;
    56                         extern const std::string one;
    57 
    58                         extern const std::string function;
    59                         extern const std::string tuple;
    60                         extern const std::string pointer;
    61                         extern const std::string array;
    62                         extern const std::string qualifiedTypeStart;
    63                         extern const std::string qualifiedTypeEnd;
    64 
    65                         extern const std::string forall;
    66                         extern const std::string typeVariables[];
    67 
    68                         extern const std::string struct_t;
    69                         extern const std::string union_t;
    70                         extern const std::string enum_t;
    71                         extern const std::string type;
    72 
    73                         extern const std::string autogen;
    74                         extern const std::string intrinsic;
    75                 };
     34                std::string mangleConcrete( Type* ty );
    7635        } // Mangler
    7736} // SymTab
    78 
    79 namespace Mangle {
    80         /// Bitflags for mangle modes
    81         enum {
    82                 NoOverrideable  = 1 << 0,
    83                 Type            = 1 << 1,
    84                 NoGenericParams = 1 << 2
    85         };
    86 
    87         /// Bitflag type for mangler modes
    88         struct mangle_flags {
    89                 union {
    90                         unsigned int val;
    91                         struct {
    92                                 bool no_overrideable   : 1;
    93                                 bool type              : 1;
    94                                 bool no_generic_params : 1;
    95                         };
    96                 };
    97 
    98                 constexpr mangle_flags( unsigned int val ) : val(val) {}
    99         };
    100 
    101         using Mode = bitfield<mangle_flags>;
    102 
    103         static inline Mode typeMode() { return NoOverrideable | Type; }
    104 
    105         /// Mangle declaration name
    106         std::string mangle( const ast::Node * decl, Mode mode = {} );
    107 
    108         namespace Encoding {
    109                 using namespace SymTab::Mangler::Encoding;
    110         };
    111 }
    112 
    113 extern "C" {
    114         char * cforall_demangle(const char *, int);
    115 }
    11637
    11738// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.