diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-16 21:06:17 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-07-24 12:27:58 +0300 |
| commit | a93fdfedf36dcb909d90cbf963b087c5873bec1d (patch) | |
| tree | a6cd8127f5490298317446aa618a640316992016 /src/libsyntax | |
| parent | a7f28678bbf4e16893bb6a718e427504167a9494 (diff) | |
| download | rust-a93fdfedf36dcb909d90cbf963b087c5873bec1d.tar.gz rust-a93fdfedf36dcb909d90cbf963b087c5873bec1d.zip | |
Merge `rustc_allocator` into `libsyntax_ext`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/allocator.rs | 53 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 1 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/libsyntax/ext/allocator.rs b/src/libsyntax/ext/allocator.rs new file mode 100644 index 00000000000..f2c6bf27cee --- /dev/null +++ b/src/libsyntax/ext/allocator.rs @@ -0,0 +1,53 @@ +#[derive(Clone, Copy)] +pub enum AllocatorKind { + Global, + DefaultLib, + DefaultExe, +} + +impl AllocatorKind { + pub fn fn_name(&self, base: &str) -> String { + match *self { + AllocatorKind::Global => format!("__rg_{}", base), + AllocatorKind::DefaultLib => format!("__rdl_{}", base), + AllocatorKind::DefaultExe => format!("__rde_{}", base), + } + } +} + +pub enum AllocatorTy { + Layout, + Ptr, + ResultPtr, + Unit, + Usize, +} + +pub struct AllocatorMethod { + pub name: &'static str, + pub inputs: &'static [AllocatorTy], + pub output: AllocatorTy, +} + +pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[ + AllocatorMethod { + name: "alloc", + inputs: &[AllocatorTy::Layout], + output: AllocatorTy::ResultPtr, + }, + AllocatorMethod { + name: "dealloc", + inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout], + output: AllocatorTy::Unit, + }, + AllocatorMethod { + name: "realloc", + inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Usize], + output: AllocatorTy::ResultPtr, + }, + AllocatorMethod { + name: "alloc_zeroed", + inputs: &[AllocatorTy::Layout], + output: AllocatorTy::ResultPtr, + }, +]; diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 3dea1977c4d..e3bc72335ab 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -165,6 +165,7 @@ pub mod print { pub mod ext { pub use syntax_pos::hygiene; + pub mod allocator; pub mod base; pub mod build; pub mod derive; |
