diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-11-27 18:55:56 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-11-27 18:55:56 +0000 |
commit | 336785efd4228d3ed044bf8ede10c43de9c6ba61 (patch) | |
tree | 2faff4665b784c50a7779309159027fe2d3718f3 /gcc/go/gofrontend/export.h | |
parent | ba28599caf0c45ea4552a3228c15b1d99e572007 (diff) | |
download | gcc-336785efd4228d3ed044bf8ede10c43de9c6ba61.zip gcc-336785efd4228d3ed044bf8ede10c43de9c6ba61.tar.gz gcc-336785efd4228d3ed044bf8ede10c43de9c6ba61.tar.bz2 |
compiler: change Expression export to use Export_function_body
In preparation for writing expressions to inline function bodies,
change the existing expression export code to use Export_function_body
rather than Export. Adjust existing expression exporters accordingly.
This is a refactoring that doesn't affect compiler output.
Reviewed-on: https://go-review.googlesource.com/c/150063
From-SVN: r266523
Diffstat (limited to 'gcc/go/gofrontend/export.h')
-rw-r--r-- | gcc/go/gofrontend/export.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/export.h b/gcc/go/gofrontend/export.h index 5751488..3cbf8e1 100644 --- a/gcc/go/gofrontend/export.h +++ b/gcc/go/gofrontend/export.h @@ -12,6 +12,7 @@ class Go_sha1_helper; class Gogo; class Named_object; +class Export_function_body; class Import_init; class Named_object; class Bindings; @@ -183,6 +184,10 @@ class Export : public String_dump void write_type(const Type*); + // Write a type to an exported function body. + void + write_type_to(const Type*, Export_function_body*); + // Write the escape note to the export stream. If NOTE is NULL, write // nothing. void @@ -241,6 +246,10 @@ class Export : public String_dump void register_builtin_type(Gogo*, const char* name, Builtin_code); + // Return the index of a type in the export data. + int + type_index(const Type*); + // The stream to which we are writing data. Stream* stream_; // Index number of next type. @@ -290,11 +299,11 @@ class Stream_to_string : public Export::Stream // to Statements and Expressions. It builds up the export data for // the function. -class Export_function_body +class Export_function_body : public String_dump { public: - Export_function_body(int indent) - : indent_(indent) + Export_function_body(Export* exp, int indent) + : exp_(exp), indent_(indent) { } // Write a character to the body. @@ -312,6 +321,11 @@ class Export_function_body write_string(const std::string& str) { this->body_.append(str); } + // Write a type reference to the body. + void + write_type(const Type* type) + { this->exp_->write_type_to(type, this); } + // Append as many spaces as the current indentation level. void indent() @@ -336,6 +350,8 @@ class Export_function_body { return this->body_; } private: + // The overall export data. + Export* exp_; // The body we are building. std::string body_; // Current indentation level: the number of spaces before each statement. |