Skip to content

Commit d4bfbb0

Browse files
Merge #772
772: Converted FnType preprocessor defines into constants r=philberty a=npate012 Fixes #737 I have converted FnType preprocessor defines to static const of uint8_t. I did not change the variable case. Co-authored-by: Nirmal Patel <[email protected]>
2 parents 78ed354 + 10122cb commit d4bfbb0

5 files changed

+29
-26
lines changed

gcc/rust/typecheck/rust-hir-type-check-implitem.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ class TypeCheckTopLevelExternItem : public TypeCheckBase
111111
context->insert_type (param.get_mappings (), param_tyty);
112112
}
113113

114-
uint8_t flags = FNTYPE_IS_EXTERN_FLAG;
114+
uint8_t flags = TyTy::FnType::FNTYPE_IS_EXTERN_FLAG;
115115
if (function.is_variadic ())
116-
flags |= FNTYPE_IS_VARADIC_FLAG;
116+
flags |= TyTy::FnType::FNTYPE_IS_VARADIC_FLAG;
117117

118118
auto fnType = new TyTy::FnType (
119119
function.get_mappings ().get_hirid (),
@@ -272,11 +272,14 @@ class TypeCheckTopLevelImplItem : public TypeCheckBase
272272
context->insert_type (param.get_mappings (), param_tyty);
273273
}
274274

275-
auto fnType = new TyTy::FnType (
276-
function.get_mappings ().get_hirid (),
277-
function.get_mappings ().get_defid (), function.get_function_name (),
278-
function.is_method () ? FNTYPE_IS_METHOD_FLAG : FNTYPE_DEFAULT_FLAGS,
279-
ABI::RUST, std::move (params), ret_type, std::move (substitutions));
275+
auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
276+
function.get_mappings ().get_defid (),
277+
function.get_function_name (),
278+
function.is_method ()
279+
? TyTy::FnType::FNTYPE_IS_METHOD_FLAG
280+
: TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
281+
ABI::RUST, std::move (params), ret_type,
282+
std::move (substitutions));
280283

281284
context->insert_type (function.get_mappings (), fnType);
282285
}

gcc/rust/typecheck/rust-hir-type-check-stmt.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ class TypeCheckStmt : public TypeCheckBase
331331
context->insert_type (param.get_mappings (), param_tyty);
332332
}
333333

334-
auto fnType
335-
= new TyTy::FnType (function.get_mappings ().get_hirid (),
336-
function.get_mappings ().get_defid (),
337-
function.get_function_name (), FNTYPE_DEFAULT_FLAGS,
338-
ABI::RUST, std::move (params), ret_type,
339-
std::move (substitutions));
334+
auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
335+
function.get_mappings ().get_defid (),
336+
function.get_function_name (),
337+
TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
338+
ABI::RUST, std::move (params), ret_type,
339+
std::move (substitutions));
340340
context->insert_type (function.get_mappings (), fnType);
341341

342342
TyTy::FnType *resolved_fn_type = fnType;

gcc/rust/typecheck/rust-hir-type-check-toplevel.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ class TypeCheckTopLevel : public TypeCheckBase
290290
context->insert_type (param.get_mappings (), param_tyty);
291291
}
292292

293-
auto fnType
294-
= new TyTy::FnType (function.get_mappings ().get_hirid (),
295-
function.get_mappings ().get_defid (),
296-
function.get_function_name (), FNTYPE_DEFAULT_FLAGS,
297-
ABI::RUST, std::move (params), ret_type,
298-
std::move (substitutions));
293+
auto fnType = new TyTy::FnType (function.get_mappings ().get_hirid (),
294+
function.get_mappings ().get_defid (),
295+
function.get_function_name (),
296+
TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
297+
ABI::RUST, std::move (params), ret_type,
298+
std::move (substitutions));
299299
context->insert_type (function.get_mappings (), fnType);
300300
}
301301

gcc/rust/typecheck/rust-hir-type-check.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,9 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
583583
= new TyTy::FnType (fn.get_mappings ().get_hirid (),
584584
fn.get_mappings ().get_defid (),
585585
function.get_function_name (),
586-
function.is_method () ? FNTYPE_IS_METHOD_FLAG
587-
: FNTYPE_DEFAULT_FLAGS,
586+
function.is_method ()
587+
? TyTy::FnType::FNTYPE_IS_METHOD_FLAG
588+
: TyTy::FnType::FNTYPE_DEFAULT_FLAGS,
588589
ABI::RUST, std::move (params), ret_type, substitutions);
589590

590591
context->insert_type (fn.get_mappings (), resolved);

gcc/rust/typecheck/rust-tyty.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,11 +1138,10 @@ class ADTType : public BaseType, public SubstitutionRef
11381138
class FnType : public BaseType, public SubstitutionRef
11391139
{
11401140
public:
1141-
// FIXME these could be constants
1142-
#define FNTYPE_DEFAULT_FLAGS 0x00
1143-
#define FNTYPE_IS_METHOD_FLAG 0x01
1144-
#define FNTYPE_IS_EXTERN_FLAG 0x02
1145-
#define FNTYPE_IS_VARADIC_FLAG 0X04
1141+
static const uint8_t FNTYPE_DEFAULT_FLAGS = 0x00;
1142+
static const uint8_t FNTYPE_IS_METHOD_FLAG = 0x01;
1143+
static const uint8_t FNTYPE_IS_EXTERN_FLAG = 0x02;
1144+
static const uint8_t FNTYPE_IS_VARADIC_FLAG = 0X04;
11461145

11471146
FnType (HirId ref, DefId id, std::string identifier, uint8_t flags, ABI abi,
11481147
std::vector<std::pair<HIR::Pattern *, BaseType *>> params,

0 commit comments

Comments
 (0)