summaryrefslogtreecommitdiff
path: root/src/trans/allocator.hpp
blob: 8a4e51861cea5dfd3ae16d256600f3cdb3d0b87d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * MRustC - Mutabah's Rust Compiler
 * - By John Hodge (Mutabah/thePowersGang)
 *
 * trans/allocator.hpp
 * - Handling for switchable allocator backends
 */
#include <cstddef>

enum class AllocatorDataTy {
    // - Return
    Never,  // !
    Unit,   // ()
    ResultPtr,  // (..., *mut i8) + *mut u8
    ResultExcess,   // (..., *mut i8, *mut i8) + *mut u8
    UsizePair,  // (..., *mut usize, *mut usize) + ()
    ResultUnit, // i8
    // - Args
    Layout, // usize, usize
    LayoutRef,  // *const Layout  [actually *const i8]
    AllocError, // *const i8
    Ptr,    // *mut u8
};
struct AllocatorMethod {
    const char* name;
    AllocatorDataTy ret;
    size_t  n_args;
    const AllocatorDataTy* args;    // Terminated by Never
};
enum class AllocatorKind {
    Global,
    DefaultLib,
    DefaultExe,
};

extern const AllocatorMethod   ALLOCATOR_METHODS[10];