aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-01-16 14:24:56 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-01-17 15:58:07 +0000
commit659ade1611568da5d91a0d6a2d76871cce658ff7 (patch)
treef860691c1fc461ede8ea6e2334d1f1b9a7f2395f /gcc/rust/backend/rust-compile-item.h
parent7066c0eca18f99aca3e88a08b2aaf71d970d0ab6 (diff)
downloadgcc-659ade1611568da5d91a0d6a2d76871cce658ff7.zip
gcc-659ade1611568da5d91a0d6a2d76871cce658ff7.tar.gz
gcc-659ade1611568da5d91a0d6a2d76871cce658ff7.tar.bz2
Handle forward references in backend compilation
We must ensure the backend can support compilation of things declared lexically after they are referenced. This scans the toplevel except functions which are handled as we reference them. To make that generic enough for all toplevel items will be a move to query based compilation which still needs planning.
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r--gcc/rust/backend/rust-compile-item.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index 8c7eda5..a367ac7 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -31,9 +31,9 @@ namespace Compile {
class CompileItem : public HIRCompileBase
{
public:
- static void compile (HIR::Item *item, Context *ctx)
+ static void compile (HIR::Item *item, Context *ctx, bool compile_fns = true)
{
- CompileItem compiler (ctx);
+ CompileItem compiler (ctx, compile_fns);
item->accept_vis (compiler);
}
@@ -116,6 +116,9 @@ public:
void visit (HIR::Function &function)
{
+ if (!compile_fns)
+ return;
+
// items can be forward compiled which means we may not need to invoke this
// code
Bfunction *lookup = nullptr;
@@ -277,7 +280,11 @@ public:
}
private:
- CompileItem (Context *ctx) : HIRCompileBase (ctx) {}
+ CompileItem (Context *ctx, bool compile_fns)
+ : HIRCompileBase (ctx), compile_fns (compile_fns)
+ {}
+
+ bool compile_fns;
};
} // namespace Compile