| 1 | //
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // Mangler.h --
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Richard C. Bilson
 | 
|---|
| 10 | // Created On       : Sun May 17 21:44:03 2015
 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Sat Jul 22 09:45:30 2017
 | 
|---|
| 13 | // Update Count     : 15
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #pragma once
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include <map>                // for map, map<>::value_compare
 | 
|---|
| 19 | #include <sstream>            // for ostringstream
 | 
|---|
| 20 | #include <string>             // for string
 | 
|---|
| 21 | #include <utility>            // for pair
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #include "SynTree/SynTree.h"  // for Types
 | 
|---|
| 24 | #include "SynTree/Visitor.h"  // for Visitor, maybeAccept
 | 
|---|
| 25 | 
 | 
|---|
| 26 | // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling
 | 
|---|
| 27 | // The CFA name mangling scheme is based closely on the itanium C++ name mangling scheme, with the following key differences:
 | 
|---|
| 28 | // * Variable names are also mangled to include type information, not just functions
 | 
|---|
| 29 | // * CFA does not have template expansion, so the rules for function specialization do not apply.
 | 
|---|
| 30 | // * CFA instead has to handle type parameters and assertion parameters.
 | 
|---|
| 31 | // * Currently name compression is not implemented.
 | 
|---|
| 32 | 
 | 
|---|
| 33 | namespace ResolvExpr {
 | 
|---|
| 34 |         class TypeEnvironment;
 | 
|---|
| 35 | }
 | 
|---|
| 36 | 
 | 
|---|
| 37 | namespace SymTab {
 | 
|---|
| 38 |         namespace Mangler {
 | 
|---|
| 39 |                 /// Mangle syntax tree object; primary interface to clients
 | 
|---|
| 40 |                 std::string mangle( BaseSyntaxNode * decl, bool mangleOverridable = true, bool typeMode = false, bool mangleGenericParams = true );
 | 
|---|
| 41 | 
 | 
|---|
| 42 |                 /// Mangle a type name; secondary interface
 | 
|---|
| 43 |                 std::string mangleType( Type* ty );
 | 
|---|
| 44 |                 /// Mangle ignoring generic type parameters
 | 
|---|
| 45 |                 std::string mangleConcrete( Type* ty );
 | 
|---|
| 46 | 
 | 
|---|
| 47 |                 namespace Encoding {
 | 
|---|
| 48 |                         extern const std::string manglePrefix;
 | 
|---|
| 49 |                         extern const std::string basicTypes[];
 | 
|---|
| 50 |                         extern const std::map<int, std::string> qualifiers;
 | 
|---|
| 51 | 
 | 
|---|
| 52 |                         extern const std::string void_t;
 | 
|---|
| 53 |                         extern const std::string zero;
 | 
|---|
| 54 |                         extern const std::string one;
 | 
|---|
| 55 | 
 | 
|---|
| 56 |                         extern const std::string function;
 | 
|---|
| 57 |                         extern const std::string tuple;
 | 
|---|
| 58 |                         extern const std::string pointer;
 | 
|---|
| 59 |                         extern const std::string array;
 | 
|---|
| 60 |                         extern const std::string qualifiedTypeStart;
 | 
|---|
| 61 |                         extern const std::string qualifiedTypeEnd;
 | 
|---|
| 62 | 
 | 
|---|
| 63 |                         extern const std::string forall;
 | 
|---|
| 64 |                         extern const std::string typeVariables[];
 | 
|---|
| 65 | 
 | 
|---|
| 66 |                         extern const std::string struct_t;
 | 
|---|
| 67 |                         extern const std::string union_t;
 | 
|---|
| 68 |                         extern const std::string enum_t;
 | 
|---|
| 69 |                         extern const std::string type;
 | 
|---|
| 70 | 
 | 
|---|
| 71 |                         extern const std::string autogen;
 | 
|---|
| 72 |                         extern const std::string intrinsic;
 | 
|---|
| 73 |                 };
 | 
|---|
| 74 |         } // Mangler
 | 
|---|
| 75 | } // SymTab
 | 
|---|
| 76 | 
 | 
|---|
| 77 | extern "C" {
 | 
|---|
| 78 |         char * cforall_demangle(const char *, int);
 | 
|---|
| 79 | }
 | 
|---|
| 80 | 
 | 
|---|
| 81 | // Local Variables: //
 | 
|---|
| 82 | // tab-width: 4 //
 | 
|---|
| 83 | // mode: c++ //
 | 
|---|
| 84 | // compile-command: "make install" //
 | 
|---|
| 85 | // End: //
 | 
|---|