Mercurial > hg > CbC > CbC_gcc
diff gcc/go/gofrontend/export.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/gcc/go/gofrontend/export.h Fri Oct 27 22:46:09 2017 +0900 +++ b/gcc/go/gofrontend/export.h Thu Oct 25 07:37:49 2018 +0900 @@ -11,7 +11,9 @@ class Go_sha1_helper; class Gogo; +class Named_object; class Import_init; +class Named_object; class Bindings; class Type; class Package; @@ -57,7 +59,8 @@ EXPORT_FORMAT_UNKNOWN = 0, EXPORT_FORMAT_V1 = 1, EXPORT_FORMAT_V2 = 2, - EXPORT_FORMAT_CURRENT = EXPORT_FORMAT_V2 + EXPORT_FORMAT_V3 = 3, + EXPORT_FORMAT_CURRENT = EXPORT_FORMAT_V3 }; // This class manages exporting Go declarations. It handles the main @@ -119,9 +122,10 @@ // Size of export data magic string (which includes version number). static const int magic_len = 4; - // Magic strings (current version and older v1 version). + // Magic strings (current version and older versions). static const char cur_magic[magic_len]; static const char v1_magic[magic_len]; + static const char v2_magic[magic_len]; // The length of the checksum string. static const int checksum_len = 20; @@ -151,6 +155,10 @@ const Import_init_set& imported_init_fns, const Bindings* bindings); + // Set the index of a type. + bool + set_type_index(Type*); + // Write a string to the export stream. void write_string(const std::string& s) @@ -192,6 +200,11 @@ Export(const Export&); Export& operator=(const Export&); + // Prepare types for exporting. + int + prepare_types(const std::vector<Named_object*>* exports, + Unordered_set(const Package*)* imports); + // Write out all known packages. void write_packages(const std::map<std::string, Package*>& packages); @@ -208,31 +221,35 @@ // Write out the imported packages. void - write_imports(const std::map<std::string, Package*>& imports); + write_imports(const std::map<std::string, Package*>& imports, + const Unordered_set(const Package*)& type_imports); // Write out the imported initialization functions and init graph. void write_imported_init_fns(const std::string& package_name, const std::string&, const Import_init_set&); + // Write out all types. + void + write_types(int unexported_type_index); + + // Write out one type definition. + void + write_type_definition(const Type* type, int index); + // Register one builtin type. void register_builtin_type(Gogo*, const char* name, Builtin_code); - // Mapping from Type objects to a constant index. - typedef Unordered_map(const Type*, int) Type_refs; - // The stream to which we are writing data. Stream* stream_; - // Type mappings. - Type_refs type_refs_; // Index number of next type. int type_index_; // Packages we have written out. Unordered_set(const Package*) packages_; }; -// An export streamer which puts the export stream in a named section. +// An export streamer that puts the export stream in a named section. class Stream_to_section : public Export::Stream { @@ -247,4 +264,26 @@ Backend* backend_; }; +// An export streamer that puts the export stream in a string. + +class Stream_to_string : public Export::Stream +{ + public: + Stream_to_string() + : string_() + {} + + const std::string& + string() const + { return this->string_; } + + protected: + void + do_write(const char* s, size_t len) + { this->string_.append(s, len); } + + private: + std::string string_; +}; + #endif // !defined(GO_EXPORT_H)