github.com/ronhuafeng/gofrontend@v0.0.0-20220715151246-ff23266b8bc5/go/go-encode-id.h (about) 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 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. 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 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 28 // Encodes a struct tag that appears in a type literal encoding. 29 extern std::string 30 go_mangle_struct_tag(const std::string& tag); 31 32 #endif // !defined(GO_ENCODE_ID_H)