aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-08-11 19:44:35 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-08-19 14:36:10 +0100
commit2148d2f9749d71a866f93335e1482f133d189b4e (patch)
treeaf49a9ba9cab830fb8f16129a36c74a4514ca50f /gcc
parent387f73626ae0e04c3f81d71d4de6780a4caad052 (diff)
downloadgcc-2148d2f9749d71a866f93335e1482f133d189b4e.zip
gcc-2148d2f9749d71a866f93335e1482f133d189b4e.tar.gz
gcc-2148d2f9749d71a866f93335e1482f133d189b4e.tar.bz2
refactor code into cc file
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/Make-lang.in1
-rw-r--r--gcc/rust/typecheck/rust-hir-trait-resolve.cc68
-rw-r--r--gcc/rust/typecheck/rust-hir-trait-resolve.h40
3 files changed, 72 insertions, 37 deletions
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index f4bc9ea..0d0ca1d 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -80,6 +80,7 @@ GRS_OBJS = \
rust/rust-tyty.o \
rust/rust-tyctx.o \
rust/rust-tyty-bounds.o \
+ rust/rust-hir-trait-resolve.o \
rust/rust-hir-const-fold.o \
rust/rust-lint-marklive.o \
$(END)
diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
new file mode 100644
index 0000000..5356636
--- /dev/null
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
@@ -0,0 +1,68 @@
+// Copyright (C) 2021 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include "rust-hir-trait-resolve.h"
+
+namespace Rust {
+namespace Resolver {
+
+void
+ResolveTraitItemToRef::visit (HIR::TraitItemType &type)
+{
+ TyTy::BaseType *ty
+ = new TyTy::PlaceholderType (type.get_mappings ().get_hirid ());
+ context->insert_type (type.get_mappings (), ty);
+
+ // create trait-item-ref
+ Location locus = type.get_locus ();
+ bool is_optional = false;
+ std::string identifier = type.get_name ();
+
+ resolved = TraitItemReference (identifier, is_optional,
+ TraitItemReference::TraitItemType::TYPE, &type,
+ self, substitutions, locus);
+}
+
+void
+ResolveTraitItemToRef::visit (HIR::TraitItemConst &cst)
+{
+ // create trait-item-ref
+ Location locus = cst.get_locus ();
+ bool is_optional = cst.has_expr ();
+ std::string identifier = cst.get_name ();
+
+ resolved = TraitItemReference (identifier, is_optional,
+ TraitItemReference::TraitItemType::CONST, &cst,
+ self, substitutions, locus);
+}
+
+void
+ResolveTraitItemToRef::visit (HIR::TraitItemFunc &fn)
+{
+ // create trait-item-ref
+ Location locus = fn.get_locus ();
+ bool is_optional = fn.has_block_defined ();
+ std::string identifier = fn.get_decl ().get_function_name ();
+
+ resolved = TraitItemReference (identifier, is_optional,
+ TraitItemReference::TraitItemType::FN, &fn,
+ self, substitutions, locus);
+}
+
+} // namespace Resolver
+} // namespace Rust
diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.h b/gcc/rust/typecheck/rust-hir-trait-resolve.h
index 1669a37..6507bca 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.h
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.h
@@ -42,45 +42,11 @@ public:
return resolver.resolved;
}
- void visit (HIR::TraitItemType &type) override
- {
- TyTy::BaseType *ty
- = new TyTy::PlaceholderType (type.get_mappings ().get_hirid ());
- context->insert_type (type.get_mappings (), ty);
-
- // create trait-item-ref
- Location locus = type.get_locus ();
- bool is_optional = false;
- std::string identifier = type.get_name ();
-
- resolved = TraitItemReference (identifier, is_optional,
- TraitItemReference::TraitItemType::TYPE,
- &type, self, substitutions, locus);
- }
+ void visit (HIR::TraitItemType &type) override;
- void visit (HIR::TraitItemConst &cst) override
- {
- // create trait-item-ref
- Location locus = cst.get_locus ();
- bool is_optional = cst.has_expr ();
- std::string identifier = cst.get_name ();
-
- resolved = TraitItemReference (identifier, is_optional,
- TraitItemReference::TraitItemType::CONST,
- &cst, self, substitutions, locus);
- }
+ void visit (HIR::TraitItemConst &cst) override;
- void visit (HIR::TraitItemFunc &fn) override
- {
- // create trait-item-ref
- Location locus = fn.get_locus ();
- bool is_optional = fn.has_block_defined ();
- std::string identifier = fn.get_decl ().get_function_name ();
-
- resolved = TraitItemReference (identifier, is_optional,
- TraitItemReference::TraitItemType::FN, &fn,
- self, substitutions, locus);
- }
+ void visit (HIR::TraitItemFunc &fn) override;
private:
ResolveTraitItemToRef (