mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
Merge remote-tracking branch 'origin/trunk' into list-unreachable
This commit is contained in:
commit
6095dcff66
107 changed files with 10287 additions and 9870 deletions
|
@ -62,7 +62,9 @@ use roc_mono::ir::{
|
|||
BranchInfo, CallType, EntryPoint, HigherOrderLowLevel, JoinPointId, ListLiteralElement,
|
||||
ModifyRc, OptLevel, ProcLayout,
|
||||
};
|
||||
use roc_mono::layout::{Builtin, LambdaSet, Layout, LayoutIds, TagIdIntType, UnionLayout};
|
||||
use roc_mono::layout::{
|
||||
Builtin, CapturesNiche, LambdaName, LambdaSet, Layout, LayoutIds, TagIdIntType, UnionLayout,
|
||||
};
|
||||
use roc_std::RocDec;
|
||||
use roc_target::{PtrWidth, TargetInfo};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
|
@ -715,7 +717,12 @@ fn promote_to_main_function<'a, 'ctx, 'env>(
|
|||
top_level: ProcLayout<'a>,
|
||||
) -> (&'static str, FunctionValue<'ctx>) {
|
||||
let it = top_level.arguments.iter().copied();
|
||||
let bytes = roc_alias_analysis::func_name_bytes_help(symbol, it, &top_level.result);
|
||||
let bytes = roc_alias_analysis::func_name_bytes_help(
|
||||
symbol,
|
||||
it,
|
||||
CapturesNiche::no_niche(),
|
||||
&top_level.result,
|
||||
);
|
||||
let func_name = FuncName(&bytes);
|
||||
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
||||
|
||||
|
@ -727,7 +734,14 @@ fn promote_to_main_function<'a, 'ctx, 'env>(
|
|||
);
|
||||
|
||||
// NOTE fake layout; it is only used for debug prints
|
||||
let roc_main_fn = function_value_by_func_spec(env, *func_spec, symbol, &[], &Layout::UNIT);
|
||||
let roc_main_fn = function_value_by_func_spec(
|
||||
env,
|
||||
*func_spec,
|
||||
symbol,
|
||||
&[],
|
||||
CapturesNiche::no_niche(),
|
||||
&Layout::UNIT,
|
||||
);
|
||||
|
||||
let main_fn_name = "$Test.main";
|
||||
|
||||
|
@ -3296,6 +3310,7 @@ fn expose_function_to_host<'a, 'ctx, 'env>(
|
|||
symbol: Symbol,
|
||||
roc_function: FunctionValue<'ctx>,
|
||||
arguments: &'a [Layout<'a>],
|
||||
captures_niche: CapturesNiche<'a>,
|
||||
return_layout: Layout<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
) {
|
||||
|
@ -3304,6 +3319,7 @@ fn expose_function_to_host<'a, 'ctx, 'env>(
|
|||
let proc_layout = ProcLayout {
|
||||
arguments,
|
||||
result: return_layout,
|
||||
captures_niche,
|
||||
};
|
||||
|
||||
let c_function_name: String = layout_ids
|
||||
|
@ -4185,7 +4201,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
|
|||
|
||||
// only have top-level thunks for this proc's module in scope
|
||||
// this retain is not needed for correctness, but will cause less confusion when debugging
|
||||
let home = proc.name.module_id();
|
||||
let home = proc.name.name().module_id();
|
||||
current_scope.retain_top_level_thunks_for_module(home);
|
||||
|
||||
build_proc(
|
||||
|
@ -4301,6 +4317,7 @@ fn build_proc_header<'a, 'ctx, 'env>(
|
|||
symbol,
|
||||
fn_val,
|
||||
arguments.into_bump_slice(),
|
||||
proc.name.captures_niche(),
|
||||
proc.ret_layout,
|
||||
layout_ids,
|
||||
);
|
||||
|
@ -4530,8 +4547,12 @@ pub fn build_proc<'a, 'ctx, 'env>(
|
|||
// * roc__mainForHost_1_Update_result_size() -> i64
|
||||
|
||||
let it = top_level.arguments.iter().copied();
|
||||
let bytes =
|
||||
roc_alias_analysis::func_name_bytes_help(symbol, it, &top_level.result);
|
||||
let bytes = roc_alias_analysis::func_name_bytes_help(
|
||||
symbol,
|
||||
it,
|
||||
CapturesNiche::no_niche(),
|
||||
&top_level.result,
|
||||
);
|
||||
let func_name = FuncName(&bytes);
|
||||
let func_solutions = mod_solutions.func_solutions(func_name).unwrap();
|
||||
|
||||
|
@ -4548,6 +4569,7 @@ pub fn build_proc<'a, 'ctx, 'env>(
|
|||
*func_spec,
|
||||
symbol,
|
||||
top_level.arguments,
|
||||
CapturesNiche::no_niche(),
|
||||
&top_level.result,
|
||||
)
|
||||
}
|
||||
|
@ -4559,7 +4581,7 @@ pub fn build_proc<'a, 'ctx, 'env>(
|
|||
}
|
||||
};
|
||||
|
||||
let ident_string = proc.name.as_str(&env.interns);
|
||||
let ident_string = proc.name.name().as_str(&env.interns);
|
||||
let fn_name: String = format!("{}_1", ident_string);
|
||||
|
||||
build_closure_caller(
|
||||
|
@ -4624,17 +4646,19 @@ fn function_value_by_func_spec<'a, 'ctx, 'env>(
|
|||
func_spec: FuncSpec,
|
||||
symbol: Symbol,
|
||||
arguments: &[Layout<'a>],
|
||||
captures_niche: CapturesNiche<'a>,
|
||||
result: &Layout<'a>,
|
||||
) -> FunctionValue<'ctx> {
|
||||
let fn_name = func_spec_name(env.arena, &env.interns, symbol, func_spec);
|
||||
let fn_name = fn_name.as_str();
|
||||
|
||||
function_value_by_name_help(env, arguments, result, symbol, fn_name)
|
||||
function_value_by_name_help(env, arguments, captures_niche, result, symbol, fn_name)
|
||||
}
|
||||
|
||||
fn function_value_by_name_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
arguments: &[Layout<'a>],
|
||||
_captures_niche: CapturesNiche<'a>,
|
||||
result: &Layout<'a>,
|
||||
symbol: Symbol,
|
||||
fn_name: &str,
|
||||
|
@ -4675,12 +4699,18 @@ fn roc_call_with_args<'a, 'ctx, 'env>(
|
|||
env: &Env<'a, 'ctx, 'env>,
|
||||
argument_layouts: &[Layout<'a>],
|
||||
result_layout: &Layout<'a>,
|
||||
symbol: Symbol,
|
||||
name: LambdaName<'a>,
|
||||
func_spec: FuncSpec,
|
||||
arguments: &[BasicValueEnum<'ctx>],
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let fn_val =
|
||||
function_value_by_func_spec(env, func_spec, symbol, argument_layouts, result_layout);
|
||||
let fn_val = function_value_by_func_spec(
|
||||
env,
|
||||
func_spec,
|
||||
name.name(),
|
||||
argument_layouts,
|
||||
name.captures_niche(),
|
||||
result_layout,
|
||||
);
|
||||
|
||||
call_roc_function(env, fn_val, result_layout, arguments)
|
||||
}
|
||||
|
@ -4869,8 +4899,9 @@ fn run_higher_order_low_level<'a, 'ctx, 'env>(
|
|||
let function = function_value_by_func_spec(
|
||||
env,
|
||||
func_spec,
|
||||
function_name,
|
||||
function_name.name(),
|
||||
argument_layouts,
|
||||
function_name.captures_niche(),
|
||||
return_layout,
|
||||
);
|
||||
|
||||
|
|
|
@ -168,10 +168,10 @@ pub fn str_from_utf8_range<'a, 'ctx, 'env>(
|
|||
call_void_bitcode_fn(
|
||||
env,
|
||||
&[
|
||||
result_ptr.into(),
|
||||
list_symbol_to_c_abi(env, scope, list).into(),
|
||||
count,
|
||||
start,
|
||||
result_ptr.into(),
|
||||
],
|
||||
bitcode::STR_FROM_UTF8_RANGE,
|
||||
);
|
||||
|
@ -194,9 +194,9 @@ pub fn str_from_utf8<'a, 'ctx, 'env>(
|
|||
call_void_bitcode_fn(
|
||||
env,
|
||||
&[
|
||||
result_ptr.into(),
|
||||
list_symbol_to_c_abi(env, scope, list).into(),
|
||||
pass_update_mode(env, update_mode),
|
||||
result_ptr.into(),
|
||||
],
|
||||
bitcode::STR_FROM_UTF8,
|
||||
);
|
||||
|
|
|
@ -1374,12 +1374,14 @@ fn build_box_eq_help<'a, 'ctx, 'env>(
|
|||
box1.set_name(Symbol::ARG_1.as_str(&env.interns));
|
||||
box2.set_name(Symbol::ARG_2.as_str(&env.interns));
|
||||
|
||||
let entry = ctx.append_basic_block(parent, "entry");
|
||||
env.builder.position_at_end(entry);
|
||||
|
||||
let return_true = ctx.append_basic_block(parent, "return_true");
|
||||
env.builder.position_at_end(return_true);
|
||||
env.builder
|
||||
.build_return(Some(&env.context.bool_type().const_all_ones()));
|
||||
|
||||
let entry = ctx.append_basic_block(parent, "entry");
|
||||
env.builder.position_at_end(entry);
|
||||
|
||||
let ptr_equal = env.builder.build_int_compare(
|
||||
|
@ -1402,8 +1404,8 @@ fn build_box_eq_help<'a, 'ctx, 'env>(
|
|||
let box1 = box1.into_pointer_value();
|
||||
let box2 = box2.into_pointer_value();
|
||||
|
||||
let value1 = env.builder.build_load(box1, "load_box1");
|
||||
let value2 = env.builder.build_load(box2, "load_box2");
|
||||
let value1 = load_roc_value(env, *inner_layout, box1, "load_box1");
|
||||
let value2 = load_roc_value(env, *inner_layout, box2, "load_box2");
|
||||
|
||||
let is_equal = build_eq(
|
||||
env,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue