mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
allow configure of whether roc_alloc is generated
This commit is contained in:
parent
f921bfc1a7
commit
66be08d073
8 changed files with 47 additions and 15 deletions
|
@ -28,12 +28,29 @@ mod object_builder;
|
|||
pub use object_builder::build_module;
|
||||
mod run_roc;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum AssemblyBackendMode {
|
||||
/// Assumes primitives (roc_alloc, roc_panic, etc) are provided by the host
|
||||
Binary,
|
||||
/// Provides a testing implementation of primitives (roc_alloc, roc_panic, etc)
|
||||
Test,
|
||||
}
|
||||
|
||||
impl AssemblyBackendMode {
|
||||
fn generate_allocators(self) -> bool {
|
||||
match self {
|
||||
AssemblyBackendMode::Binary => false,
|
||||
AssemblyBackendMode::Test => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Env<'a> {
|
||||
pub arena: &'a Bump,
|
||||
pub module_id: ModuleId,
|
||||
pub exposed_to_host: MutSet<Symbol>,
|
||||
pub lazy_literals: bool,
|
||||
pub generate_allocators: bool,
|
||||
pub mode: AssemblyBackendMode,
|
||||
}
|
||||
|
||||
// These relocations likely will need a length.
|
||||
|
@ -1280,9 +1297,7 @@ trait Backend<'a> {
|
|||
self.load_literal_symbols(args);
|
||||
self.build_fn_call(sym, fn_name, args, arg_layouts, ret_layout)
|
||||
}
|
||||
other => {
|
||||
eprintln!("maybe {other:?} should have a custom implementation?");
|
||||
|
||||
_other => {
|
||||
// just call the function
|
||||
let fn_name = self.function_symbol_to_string(
|
||||
func_sym,
|
||||
|
|
|
@ -190,7 +190,7 @@ fn build_object<'a, B: Backend<'a>>(
|
|||
);
|
||||
*/
|
||||
|
||||
if backend.env().generate_allocators {
|
||||
if backend.env().mode.generate_allocators() {
|
||||
generate_wrapper(
|
||||
&mut backend,
|
||||
&mut output,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue