aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/statements.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-11-26 21:44:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-11-26 21:44:20 +0000
commit1e4cc1d4b097f346b4cda611782fe83eda0df18f (patch)
tree2d4e3368b005eaf1e957c8b3437f6e03d7026f42 /gcc/go/gofrontend/statements.cc
parent50e99db39196a0567e844f35ce1cd0f36d066b8f (diff)
downloadgcc-1e4cc1d4b097f346b4cda611782fe83eda0df18f.zip
gcc-1e4cc1d4b097f346b4cda611782fe83eda0df18f.tar.gz
gcc-1e4cc1d4b097f346b4cda611782fe83eda0df18f.tar.bz2
compiler: initial support for exporting function bodies
Create a framework for putting function bodies in export data. At present only empty functions will be put there, and they will be ignored on import. Later patches will get this to the point of supporting inlining of (some) functions defined in other packages. Reviewed-on: https://go-review.googlesource.com/c/150061 From-SVN: r266490
Diffstat (limited to 'gcc/go/gofrontend/statements.cc')
-rw-r--r--gcc/go/gofrontend/statements.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index c35002d..718139c 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -11,6 +11,7 @@
#include "types.h"
#include "expressions.h"
#include "gogo.h"
+#include "export.h"
#include "runtime.h"
#include "backend.h"
#include "statements.h"
@@ -1781,6 +1782,27 @@ Statement::make_statement(Expression* expr, bool is_ignored)
return new Expression_statement(expr, is_ignored);
}
+// Export data for a block.
+
+void
+Block_statement::do_export_statement(Export_function_body* efb)
+{
+ // We are already indented to the right position.
+ char buf[50];
+ snprintf(buf, sizeof buf, "{ //%d\n",
+ Linemap::location_to_line(this->block_->start_location()));
+ efb->write_c_string(buf);
+
+ this->block_->export_block(efb);
+ // The indentation is correct for the statements in the block, so
+ // subtract one for the closing curly brace.
+ efb->decrement_indent();
+ efb->indent();
+ efb->write_c_string("}");
+ // Increment back to the value the caller thinks it has.
+ efb->increment_indent();
+}
+
// Convert a block to the backend representation of a statement.
Bstatement*