aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNirmal Patel <npate012@gmail.com>2021-10-25 21:55:04 -0400
committerNirmal Patel <npate012@gmail.com>2021-10-25 21:55:04 -0400
commit10122cbf2160faf8fa42adf61c599143b6d87481 (patch)
tree341eec036f8244bacfd22acd2376152f6a891794 /gcc
parent78ed354283b17658d922029f07e4e7401039a4a3 (diff)
downloadgcc-10122cbf2160faf8fa42adf61c599143b6d87481.zip
gcc-10122cbf2160faf8fa42adf61c599143b6d87481.tar.gz
gcc-10122cbf2160faf8fa42adf61c599143b6d87481.tar.bz2
Converted FnType preprocessor defines into constants
Signed-off-by: Nirmal Patel <npate012@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.h17
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-stmt.h12
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-toplevel.h12
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.cc5
-rw-r--r--gcc/rust/typecheck/rust-tyty.h9
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 eafe079..501ce3f 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 c09c36b..17def2b 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 e33f5f8..a85fe66 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 1c30dfb..0febc6c 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 7155d24..aa24464 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,