111
|
1 // go-encode-id.h -- Go identifier encoding utilities -*- C++ -*-
|
|
2
|
|
3 // Copyright 2016 The Go Authors. All rights reserved.
|
|
4 // Use of this source code is governed by a BSD-style
|
|
5 // license that can be found in the LICENSE file.
|
|
6
|
|
7 #ifndef GO_ENCODE_ID_H
|
|
8 #define GO_ENCODE_ID_H
|
|
9
|
|
10 #include "backend.h"
|
|
11
|
131
|
12 // Given an identifier that will appear in assembly code, this helper
|
|
13 // returns TRUE if the identifier needs special encoding to be used as
|
|
14 // an ASM name, FALSE if the name is OK as is.
|
111
|
15 extern bool
|
|
16 go_id_needs_encoding(const std::string& str);
|
|
17
|
|
18 // Encodes the specified identifier for ASM name safety, returning a
|
|
19 // string with the encoded value.
|
|
20 extern std::string
|
|
21 go_encode_id(const std::string &id);
|
|
22
|
145
|
23 // Decodes an encoded ID, returning the original string handed off to
|
|
24 // go_encode_id().
|
|
25 extern std::string
|
|
26 go_decode_id(const std::string &id);
|
|
27
|
111
|
28 // Returns the empty string if the specified name needs encoding,
|
131
|
29 // otherwise invokes go_encode_id on the name and returns the result.
|
111
|
30 extern std::string
|
|
31 go_selectively_encode_id(const std::string &id);
|
|
32
|
131
|
33 // Encodes a struct tag that appears in a type literal encoding.
|
|
34 extern std::string
|
|
35 go_mangle_struct_tag(const std::string& tag);
|
|
36
|
145
|
37 // Encode a package path. A package path can contain any arbitrary
|
|
38 // character, including '.'. go_encode_id expects that any '.' will
|
|
39 // be inserted by name mangling in a controlled manner. So first
|
|
40 // translate any '.' using the same .x encoding as used by
|
|
41 // go_mangle_struct_tag.
|
|
42 extern std::string
|
|
43 go_mangle_pkgpath(const std::string& pkgpath);
|
|
44
|
111
|
45 #endif // !defined(GO_ENCODE_ID_H)
|