public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] gccrs: refactor unify commit as a static function from unify code Date: Tue, 28 Feb 2023 22:37:04 +0000 (GMT) [thread overview] Message-ID: <20230228223704.9817F3858416@sourceware.org> (raw) https://gcc.gnu.org/g:83863c69193c27ad6dcfb67d86691ef6fb3e1486 commit 83863c69193c27ad6dcfb67d86691ef6fb3e1486 Author: Philip Herron <herron.philip@googlemail.com> Date: Sun Feb 26 18:30:49 2023 +0000 gccrs: refactor unify commit as a static function from unify code Signed-off-by: Philip Herron <herron.philip@googlemail.com> gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::Resolve): refactor (UnifyRules::commit): refactor * typecheck/rust-unify.h: likewise Diff: --- gcc/rust/typecheck/rust-unify.cc | 27 +++++++++++++++++---------- gcc/rust/typecheck/rust-unify.h | 5 ++++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc index cbbff8c4420..e96d6b70379 100644 --- a/gcc/rust/typecheck/rust-unify.cc +++ b/gcc/rust/typecheck/rust-unify.cc @@ -36,7 +36,7 @@ UnifyRules::Resolve (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs, TyTy::BaseType *result = r.go (); if (r.commit_flag) - r.commit (result); + UnifyRules::commit (lhs.get_ty (), rhs.get_ty (), result); bool failed = result->get_kind () == TyTy::TypeKind::ERROR; if (failed && r.emit_error) @@ -58,19 +58,26 @@ UnifyRules::get_other () } void -UnifyRules::commit (TyTy::BaseType *resolved) +UnifyRules::commit (TyTy::BaseType *base, TyTy::BaseType *other, + TyTy::BaseType *resolved) { - resolved->append_reference (get_base ()->get_ref ()); - resolved->append_reference (get_other ()->get_ref ()); - for (auto ref : get_base ()->get_combined_refs ()) + TypeCheckContext &context = *TypeCheckContext::get (); + Analysis::Mappings &mappings = *Analysis::Mappings::get (); + + TyTy::BaseType *b = base->destructure (); + TyTy::BaseType *o = other->destructure (); + + resolved->append_reference (b->get_ref ()); + resolved->append_reference (o->get_ref ()); + for (auto ref : b->get_combined_refs ()) resolved->append_reference (ref); - for (auto ref : get_other ()->get_combined_refs ()) + for (auto ref : o->get_combined_refs ()) resolved->append_reference (ref); - get_other ()->append_reference (resolved->get_ref ()); - get_other ()->append_reference (get_base ()->get_ref ()); - get_base ()->append_reference (resolved->get_ref ()); - get_base ()->append_reference (get_other ()->get_ref ()); + o->append_reference (resolved->get_ref ()); + o->append_reference (b->get_ref ()); + b->append_reference (resolved->get_ref ()); + b->append_reference (o->get_ref ()); bool result_resolved = resolved->get_kind () != TyTy::TypeKind::INFER; bool result_is_infer_var = resolved->get_kind () == TyTy::TypeKind::INFER; diff --git a/gcc/rust/typecheck/rust-unify.h b/gcc/rust/typecheck/rust-unify.h index 75fb884385e..15672f1dcb9 100644 --- a/gcc/rust/typecheck/rust-unify.h +++ b/gcc/rust/typecheck/rust-unify.h @@ -32,6 +32,9 @@ public: TyTy::TyWithLocation rhs, Location locus, bool commit_flag, bool emit_error); + static void commit (TyTy::BaseType *base, TyTy::BaseType *other, + TyTy::BaseType *resolved); + protected: TyTy::BaseType *expect_inference_variable (TyTy::InferType *ltype, TyTy::BaseType *rtype); @@ -69,7 +72,7 @@ private: Location locus, bool commit_flag, bool emit_error); void emit_type_mismatch () const; - void commit (TyTy::BaseType *resolved); + TyTy::BaseType *go (); TyTy::BaseType *get_base ();
reply other threads:[~2023-02-28 22:37 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230228223704.9817F3858416@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).