mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 23:37:56 +03:00
Merge pull request #3519 from rtfeldman/i3483
Fully qualify values exported to host linking
This commit is contained in:
commit
c48c4f3183
@ -121,7 +121,13 @@ pub fn build_file<'a>(
|
||||
.exposed_to_host
|
||||
.closure_types
|
||||
.iter()
|
||||
.map(|x| x.as_str(&loaded.interns).to_string())
|
||||
.map(|x| {
|
||||
format!(
|
||||
"{}_{}",
|
||||
x.module_string(&loaded.interns),
|
||||
x.as_str(&loaded.interns)
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let preprocessed_host_path = if emit_wasm {
|
||||
|
@ -4793,8 +4793,9 @@ fn build_closure_caller<'a, 'ctx, 'env>(
|
||||
|
||||
// e.g. `roc__main_1_Fx_caller`
|
||||
let function_name = format!(
|
||||
"roc__{}_{}_caller",
|
||||
"roc__{}_{}_{}_caller",
|
||||
def_name,
|
||||
alias_symbol.module_string(&env.interns),
|
||||
alias_symbol.as_str(&env.interns)
|
||||
);
|
||||
|
||||
@ -4908,15 +4909,17 @@ fn build_host_exposed_alias_size_help<'a, 'ctx, 'env>(
|
||||
let size_function_spec = FunctionSpec::cconv(env, CCReturn::Return, Some(i64), &[]);
|
||||
let size_function_name: String = if let Some(label) = opt_label {
|
||||
format!(
|
||||
"roc__{}_{}_{}_size",
|
||||
"roc__{}_{}_{}_{}_size",
|
||||
def_name,
|
||||
alias_symbol.module_string(&env.interns),
|
||||
alias_symbol.as_str(&env.interns),
|
||||
label
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"roc__{}_{}_size",
|
||||
"roc__{}_{}_{}_size",
|
||||
def_name,
|
||||
alias_symbol.module_string(&env.interns),
|
||||
alias_symbol.as_str(&env.interns)
|
||||
)
|
||||
};
|
||||
|
@ -26,9 +26,9 @@ const Allocator = mem.Allocator;
|
||||
|
||||
extern fn roc__mainForHost_1_exposed_generic([*]u8) void;
|
||||
extern fn roc__mainForHost_size() i64;
|
||||
extern fn roc__mainForHost_1_Fx_caller(*const u8, [*]u8, [*]u8) void;
|
||||
extern fn roc__mainForHost_1_Fx_size() i64;
|
||||
extern fn roc__mainForHost_1_Fx_result_size() i64;
|
||||
extern fn roc__mainForHost_1__Fx_caller(*const u8, [*]u8, [*]u8) void;
|
||||
extern fn roc__mainForHost_1__Fx_size() i64;
|
||||
extern fn roc__mainForHost_1__Fx_result_size() i64;
|
||||
|
||||
const Align = 2 * @alignOf(usize);
|
||||
extern fn malloc(size: usize) callconv(.C) ?*align(Align) anyopaque;
|
||||
@ -123,7 +123,7 @@ fn to_seconds(tms: std.os.timespec) f64 {
|
||||
fn call_the_closure(closure_data_pointer: [*]u8) void {
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
||||
const size = roc__mainForHost_1_Fx_result_size();
|
||||
const size = roc__mainForHost_1__Fx_result_size();
|
||||
const raw_output = allocator.allocAdvanced(u8, @alignOf(u64), @intCast(usize, size), .at_least) catch unreachable;
|
||||
var output = @ptrCast([*]u8, raw_output);
|
||||
|
||||
@ -133,7 +133,7 @@ fn call_the_closure(closure_data_pointer: [*]u8) void {
|
||||
|
||||
const flags: u8 = 0;
|
||||
|
||||
roc__mainForHost_1_Fx_caller(&flags, closure_data_pointer, output);
|
||||
roc__mainForHost_1__Fx_caller(&flags, closure_data_pointer, output);
|
||||
|
||||
// The closure returns result, nothing interesting to do with it
|
||||
return;
|
||||
|
@ -21,18 +21,18 @@ extern "C" {
|
||||
|
||||
// init
|
||||
|
||||
#[link_name = "roc__programForHost_1_Init_caller"]
|
||||
#[link_name = "roc__programForHost_1__Init_caller"]
|
||||
fn call_init(size: *const Bounds, closure_data: *const u8, output: *mut Model);
|
||||
|
||||
#[link_name = "roc__programForHost_1_Init_size"]
|
||||
#[link_name = "roc__programForHost_1__Init_size"]
|
||||
fn init_size() -> i64;
|
||||
|
||||
#[link_name = "roc__programForHost_1_Init_result_size"]
|
||||
#[link_name = "roc__programForHost_1__Init_result_size"]
|
||||
fn init_result_size() -> i64;
|
||||
|
||||
// update
|
||||
|
||||
#[link_name = "roc__programForHost_1_Update_caller"]
|
||||
#[link_name = "roc__programForHost_1__Update_caller"]
|
||||
fn call_update(
|
||||
model: *const Model,
|
||||
event: *const RocEvent,
|
||||
@ -40,18 +40,18 @@ extern "C" {
|
||||
output: *mut Model,
|
||||
);
|
||||
|
||||
#[link_name = "roc__programForHost_1_Update_size"]
|
||||
#[link_name = "roc__programForHost_1__Update_size"]
|
||||
fn update_size() -> i64;
|
||||
|
||||
#[link_name = "roc__programForHost_1_Update_result_size"]
|
||||
#[link_name = "roc__programForHost_1__Update_result_size"]
|
||||
fn update_result_size() -> i64;
|
||||
|
||||
// render
|
||||
|
||||
#[link_name = "roc__programForHost_1_Render_caller"]
|
||||
#[link_name = "roc__programForHost_1__Render_caller"]
|
||||
fn call_render(model: *const Model, closure_data: *const u8, output: *mut RocList<RocElem>);
|
||||
|
||||
#[link_name = "roc__programForHost_1_Render_size"]
|
||||
#[link_name = "roc__programForHost_1__Render_size"]
|
||||
fn roc_render_size() -> i64;
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,14 @@ extern "C" {
|
||||
#[link_name = "roc__mainForHost_size"]
|
||||
fn roc_main_size() -> i64;
|
||||
|
||||
#[link_name = "roc__mainForHost_1_Fx_caller"]
|
||||
#[link_name = "roc__mainForHost_1__Fx_caller"]
|
||||
fn call_Fx(flags: *const u8, closure_data: *const u8, output: *mut u8);
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[link_name = "roc__mainForHost_1_Fx_size"]
|
||||
#[link_name = "roc__mainForHost_1__Fx_size"]
|
||||
fn size_Fx() -> i64;
|
||||
|
||||
#[link_name = "roc__mainForHost_1_Fx_result_size"]
|
||||
#[link_name = "roc__mainForHost_1__Fx_result_size"]
|
||||
fn size_Fx_result() -> i64;
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ extern "C" {
|
||||
#[link_name = "roc__mainForHost_size"]
|
||||
fn roc_main_size() -> i64;
|
||||
|
||||
#[link_name = "roc__mainForHost_1_Fx_caller"]
|
||||
#[link_name = "roc__mainForHost_1__Fx_caller"]
|
||||
fn call_Fx(flags: *const u8, closure_data: *const u8, output: *mut u8);
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[link_name = "roc__mainForHost_1_Fx_size"]
|
||||
#[link_name = "roc__mainForHost_1__Fx_size"]
|
||||
fn size_Fx() -> i64;
|
||||
|
||||
#[link_name = "roc__mainForHost_1_Fx_result_size"]
|
||||
#[link_name = "roc__mainForHost_1__Fx_result_size"]
|
||||
fn size_Fx_result() -> i64;
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,9 @@ const Allocator = mem.Allocator;
|
||||
|
||||
extern fn roc__mainForHost_1_exposed_generic([*]u8) void;
|
||||
extern fn roc__mainForHost_size() i64;
|
||||
extern fn roc__mainForHost_1_Fx_caller(*const u8, [*]u8, [*]u8) void;
|
||||
extern fn roc__mainForHost_1_Fx_size() i64;
|
||||
extern fn roc__mainForHost_1_Fx_result_size() i64;
|
||||
extern fn roc__mainForHost_1__Fx_caller(*const u8, [*]u8, [*]u8) void;
|
||||
extern fn roc__mainForHost_1__Fx_size() i64;
|
||||
extern fn roc__mainForHost_1__Fx_result_size() i64;
|
||||
|
||||
const Align = 2 * @alignOf(usize);
|
||||
extern fn malloc(size: usize) callconv(.C) ?*align(Align) anyopaque;
|
||||
@ -125,7 +125,7 @@ fn to_seconds(tms: std.os.timespec) f64 {
|
||||
fn call_the_closure(closure_data_pointer: [*]u8) void {
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
||||
const size = roc__mainForHost_1_Fx_result_size();
|
||||
const size = roc__mainForHost_1__Fx_result_size();
|
||||
|
||||
if (size == 0) {
|
||||
// the function call returns an empty record
|
||||
@ -133,7 +133,7 @@ fn call_the_closure(closure_data_pointer: [*]u8) void {
|
||||
// So it's special-cased
|
||||
const flags: u8 = 0;
|
||||
var result: [1]u8 = .{0};
|
||||
roc__mainForHost_1_Fx_caller(&flags, closure_data_pointer, &result);
|
||||
roc__mainForHost_1__Fx_caller(&flags, closure_data_pointer, &result);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -146,7 +146,7 @@ fn call_the_closure(closure_data_pointer: [*]u8) void {
|
||||
}
|
||||
|
||||
const flags: u8 = 0;
|
||||
roc__mainForHost_1_Fx_caller(&flags, closure_data_pointer, output);
|
||||
roc__mainForHost_1__Fx_caller(&flags, closure_data_pointer, output);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ extern fn roc__mainForHost_size() i64;
|
||||
const ConstModel = [*]const u8;
|
||||
const MutModel = [*]u8;
|
||||
|
||||
extern fn roc__mainForHost_1_Init_caller([*]u8, [*]u8, MutModel) void;
|
||||
extern fn roc__mainForHost_1_Init_size() i64;
|
||||
extern fn roc__mainForHost_1_Init_result_size() i64;
|
||||
extern fn roc__mainForHost_1__Init_caller([*]u8, [*]u8, MutModel) void;
|
||||
extern fn roc__mainForHost_1__Init_size() i64;
|
||||
extern fn roc__mainForHost_1__Init_result_size() i64;
|
||||
|
||||
fn allocate_model(allocator: *Allocator) MutModel {
|
||||
const size = roc__mainForHost_1_Init_result_size();
|
||||
const size = roc__mainForHost_1__Init_result_size();
|
||||
const raw_output = allocator.allocAdvanced(u8, @alignOf(u64), @intCast(usize, size), .at_least) catch unreachable;
|
||||
var output = @ptrCast([*]u8, raw_output);
|
||||
|
||||
@ -48,33 +48,33 @@ fn init(allocator: *Allocator) ConstModel {
|
||||
const closure: [*]u8 = undefined;
|
||||
const output = allocate_model(allocator);
|
||||
|
||||
roc__mainForHost_1_Init_caller(closure, closure, output);
|
||||
roc__mainForHost_1__Init_caller(closure, closure, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
extern fn roc__mainForHost_1_Update_caller(ConstModel, *const RocStr, [*]u8, MutModel) void;
|
||||
extern fn roc__mainForHost_1_Update_size() i64;
|
||||
extern fn roc__mainForHost_1_Update_result_size() i64;
|
||||
extern fn roc__mainForHost_1__Update_caller(ConstModel, *const RocStr, [*]u8, MutModel) void;
|
||||
extern fn roc__mainForHost_1__Update_size() i64;
|
||||
extern fn roc__mainForHost_1__Update_result_size() i64;
|
||||
|
||||
fn update(allocator: *Allocator, model: ConstModel, msg: RocStr) ConstModel {
|
||||
const closure: [*]u8 = undefined;
|
||||
const output = allocate_model(allocator);
|
||||
|
||||
roc__mainForHost_1_Update_caller(model, &msg, closure, output);
|
||||
roc__mainForHost_1__Update_caller(model, &msg, closure, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
extern fn roc__mainForHost_1_View_caller(ConstModel, [*]u8, *RocStr) void;
|
||||
extern fn roc__mainForHost_1_View_size() i64;
|
||||
extern fn roc__mainForHost_1_View_result_size() i64;
|
||||
extern fn roc__mainForHost_1__View_caller(ConstModel, [*]u8, *RocStr) void;
|
||||
extern fn roc__mainForHost_1__View_size() i64;
|
||||
extern fn roc__mainForHost_1__View_result_size() i64;
|
||||
|
||||
fn view(input: ConstModel) RocStr {
|
||||
const closure: [*]u8 = undefined;
|
||||
var output: RocStr = undefined;
|
||||
|
||||
roc__mainForHost_1_View_caller(input, closure, &output);
|
||||
roc__mainForHost_1__View_caller(input, closure, &output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user