aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2020-12-18 16:17:47 +0000
committerPhilip Herron <herron.philip@googlemail.com>2020-12-19 19:32:41 +0000
commit3a10d1f15969f94c3d3bc836db1d75dd0f914aa9 (patch)
treeeecfac3b2f5b7b995a249862e16692a3d5e76845 /gcc/rust/backend
parentbc14d9a0cd3c67093a9c11ad368c0d28325b21c6 (diff)
downloadgcc-3a10d1f15969f94c3d3bc836db1d75dd0f914aa9.zip
gcc-3a10d1f15969f94c3d3bc836db1d75dd0f914aa9.tar.gz
gcc-3a10d1f15969f94c3d3bc836db1d75dd0f914aa9.tar.bz2
Add type unification as part of typecheck.
Rust must examine each usage of a name and unify their types. For example: let mut x; x = 1 This means the declaration is determined to be an inference variable then the assignment can be resolved to an Integer TyTy which can be combined as part of the rules to now make the let x decl be an i32.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-context.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index f890678..1924b52 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -205,9 +205,13 @@ public:
virtual ~TyTyResolveCompile () {}
- void visit (TyTy::FnType &type) { gcc_unreachable (); }
+ void visit (TyTy::UnitType &type) override { gcc_unreachable (); }
- void visit (TyTy::BoolType &type)
+ void visit (TyTy::InferType &type) override { gcc_unreachable (); }
+
+ void visit (TyTy::FnType &type) override { gcc_unreachable (); }
+
+ void visit (TyTy::BoolType &type) override
{
::Btype *compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ref (), &compiled_type);
@@ -215,7 +219,7 @@ public:
translated = compiled_type;
}
- void visit (TyTy::IntType &type)
+ void visit (TyTy::IntType &type) override
{
printf ("type [%s] has ref: %u\n", type.as_string ().c_str (),
type.get_ref ());
@@ -226,7 +230,7 @@ public:
translated = compiled_type;
}
- void visit (TyTy::UintType &type)
+ void visit (TyTy::UintType &type) override
{
::Btype *compiled_type = nullptr;
bool ok = ctx->lookup_compiled_types (type.get_ref (), &compiled_type);