1
Fork 0

Generate better function argument names in global_allocator expansion

This commit is contained in:
David Tolnay 2023-08-06 07:20:31 -07:00
parent bc720ad36b
commit 704aa56ba0
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
5 changed files with 37 additions and 30 deletions

View file

@ -33,29 +33,41 @@ pub enum AllocatorTy {
pub struct AllocatorMethod {
pub name: Symbol,
pub inputs: &'static [AllocatorTy],
pub inputs: &'static [AllocatorMethodInput],
pub output: AllocatorTy,
}
pub struct AllocatorMethodInput {
pub name: &'static str,
pub ty: AllocatorTy,
}
pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
AllocatorMethod {
name: sym::alloc,
inputs: &[AllocatorTy::Layout],
inputs: &[AllocatorMethodInput { name: "layout", ty: AllocatorTy::Layout }],
output: AllocatorTy::ResultPtr,
},
AllocatorMethod {
name: sym::dealloc,
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
inputs: &[
AllocatorMethodInput { name: "ptr", ty: AllocatorTy::Ptr },
AllocatorMethodInput { name: "layout", ty: AllocatorTy::Layout },
],
output: AllocatorTy::Unit,
},
AllocatorMethod {
name: sym::realloc,
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Usize],
inputs: &[
AllocatorMethodInput { name: "ptr", ty: AllocatorTy::Ptr },
AllocatorMethodInput { name: "layout", ty: AllocatorTy::Layout },
AllocatorMethodInput { name: "new_size", ty: AllocatorTy::Usize },
],
output: AllocatorTy::ResultPtr,
},
AllocatorMethod {
name: sym::alloc_zeroed,
inputs: &[AllocatorTy::Layout],
inputs: &[AllocatorMethodInput { name: "layout", ty: AllocatorTy::Layout }],
output: AllocatorTy::ResultPtr,
},
];