public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Converted FnType preprocessor defines into constants
@ 2022-06-08 11:43 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:10122cbf2160faf8fa42adf61c599143b6d87481

commit 10122cbf2160faf8fa42adf61c599143b6d87481
Author: Nirmal Patel <npate012@gmail.com>
Date:   Mon Oct 25 21:55:04 2021 -0400

    Converted FnType preprocessor defines into constants
    
    Signed-off-by: Nirmal Patel <npate012@gmail.com>

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-implitem.h | 17 ++++++++++-------
 gcc/rust/typecheck/rust-hir-type-check-stmt.h     | 12 ++++++------
 gcc/rust/typecheck/rust-hir-type-check-toplevel.h | 12 ++++++------
 gcc/rust/typecheck/rust-hir-type-check.cc         |  5 +++--
 gcc/rust/typecheck/rust-tyty.h                    |  9 ++++-----
 5 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
index eafe0790a7e..501ce3fba5b 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h
@@ -111,9 +111,9 @@ public:
 	context->insert_type (param.get_mappings (), param_tyty);
       }
 
-    uint8_t flags = FNTYPE_IS_EXTERN_FLAG;
+    uint8_t flags = TyTy::FnType::FNTYPE_IS_EXTERN_FLAG;
     if (function.is_variadic ())
-      flags |= FNTYPE_IS_VARADIC_FLAG;
+      flags |= TyTy::FnType::FNTYPE_IS_VARADIC_FLAG;
 
     auto fnType = new TyTy::FnType (
       function.get_mappings ().get_hirid (),
@@ -272,11 +272,14 @@ public:
 	context->insert_type (param.get_mappings (), param_tyty);
       }
 
-    auto fnType = new TyTy::FnType (
-      function.get_mappings ().get_hirid (),
-      function.get_mappings ().get_defid (), function.get_function_name (),
-      function.is_method () ? FNTYPE_IS_METHOD_FLAG : FNTYPE_DEFAULT_FLAGS,
-      ABI::RUST, std::move (params), ret_type, std::move (substitutions));
+    auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
+				    function.get_mappings ().get_defid (),
+				    function.get_function_name (),
+				    function.is_method ()
+				      ? TyTy::FnType::FNTYPE_IS_METHOD_FLAG
+				      : TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
+				    ABI::RUST, std::move (params), ret_type,
+				    std::move (substitutions));
 
     context->insert_type (function.get_mappings (), fnType);
   }
diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.h b/gcc/rust/typecheck/rust-hir-type-check-stmt.h
index c09c36ba85e..17def2b6aee 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-stmt.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.h
@@ -331,12 +331,12 @@ public:
 	context->insert_type (param.get_mappings (), param_tyty);
       }
 
-    auto fnType
-      = new TyTy::FnType (function.get_mappings ().get_hirid (),
-			  function.get_mappings ().get_defid (),
-			  function.get_function_name (), FNTYPE_DEFAULT_FLAGS,
-			  ABI::RUST, std::move (params), ret_type,
-			  std::move (substitutions));
+    auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
+				    function.get_mappings ().get_defid (),
+				    function.get_function_name (),
+				    TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
+				    ABI::RUST, std::move (params), ret_type,
+				    std::move (substitutions));
     context->insert_type (function.get_mappings (), fnType);
 
     TyTy::FnType *resolved_fn_type = fnType;
diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
index e33f5f8b984..a85fe6693b9 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h
@@ -290,12 +290,12 @@ public:
 	context->insert_type (param.get_mappings (), param_tyty);
       }
 
-    auto fnType
-      = new TyTy::FnType (function.get_mappings ().get_hirid (),
-			  function.get_mappings ().get_defid (),
-			  function.get_function_name (), FNTYPE_DEFAULT_FLAGS,
-			  ABI::RUST, std::move (params), ret_type,
-			  std::move (substitutions));
+    auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
+				    function.get_mappings ().get_defid (),
+				    function.get_function_name (),
+				    TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
+				    ABI::RUST, std::move (params), ret_type,
+				    std::move (substitutions));
     context->insert_type (function.get_mappings (), fnType);
   }
 
diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc
index 1c30dfbaf2c..0febc6c45cf 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check.cc
@@ -583,8 +583,9 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
     = new TyTy::FnType (fn.get_mappings ().get_hirid (),
 			fn.get_mappings ().get_defid (),
 			function.get_function_name (),
-			function.is_method () ? FNTYPE_IS_METHOD_FLAG
-					      : FNTYPE_DEFAULT_FLAGS,
+			function.is_method ()
+			  ? TyTy::FnType::FNTYPE_IS_METHOD_FLAG
+			  : TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
 			ABI::RUST, std::move (params), ret_type, substitutions);
 
   context->insert_type (fn.get_mappings (), resolved);
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h
index 7155d247d81..aa24464f41b 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -1138,11 +1138,10 @@ private:
 class FnType : public BaseType, public SubstitutionRef
 {
 public:
-  // FIXME these could be constants
-#define FNTYPE_DEFAULT_FLAGS 0x00
-#define FNTYPE_IS_METHOD_FLAG 0x01
-#define FNTYPE_IS_EXTERN_FLAG 0x02
-#define FNTYPE_IS_VARADIC_FLAG 0X04
+  static const uint8_t FNTYPE_DEFAULT_FLAGS = 0x00;
+  static const uint8_t FNTYPE_IS_METHOD_FLAG = 0x01;
+  static const uint8_t FNTYPE_IS_EXTERN_FLAG = 0x02;
+  static const uint8_t FNTYPE_IS_VARADIC_FLAG = 0X04;
 
   FnType (HirId ref, DefId id, std::string identifier, uint8_t flags, ABI abi,
 	  std::vector<std::pair<HIR::Pattern *, BaseType *>> params,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 11:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:43 [gcc/devel/rust/master] Converted FnType preprocessor defines into constants Thomas Schwinge

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).