mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
maybe it's good now?
This commit is contained in:
commit
7601bcb2fa
91 changed files with 406 additions and 423 deletions
|
@ -32,7 +32,7 @@ These are the policies for upholding our community's standards of conduct. If yo
|
||||||
|
|
||||||
In the Roc community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely.
|
In the Roc community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely.
|
||||||
|
|
||||||
And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Roc progammers comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust.
|
And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Roc programmers comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust.
|
||||||
|
|
||||||
The enforcement policies listed above apply to all official Roc venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Roc Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.
|
The enforcement policies listed above apply to all official Roc venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Roc Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM rust:1.53-slim-buster
|
FROM rust:1.54-slim-buster
|
||||||
WORKDIR /earthbuild
|
WORKDIR /earthbuild
|
||||||
|
|
||||||
prep-debian:
|
prep-debian:
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn build_file<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let loaded = roc_load::file::load_and_monomorphize(
|
let loaded = roc_load::file::load_and_monomorphize(
|
||||||
&arena,
|
arena,
|
||||||
roc_file_path.clone(),
|
roc_file_path.clone(),
|
||||||
stdlib,
|
stdlib,
|
||||||
src_dir.as_path(),
|
src_dir.as_path(),
|
||||||
|
@ -128,11 +128,11 @@ pub fn build_file<'a>(
|
||||||
let cwd = roc_file_path.parent().unwrap();
|
let cwd = roc_file_path.parent().unwrap();
|
||||||
let binary_path = cwd.join(&*loaded.output_path); // TODO should join ".exe" on Windows
|
let binary_path = cwd.join(&*loaded.output_path); // TODO should join ".exe" on Windows
|
||||||
let code_gen_timing = program::gen_from_mono_module(
|
let code_gen_timing = program::gen_from_mono_module(
|
||||||
&arena,
|
arena,
|
||||||
loaded,
|
loaded,
|
||||||
&roc_file_path,
|
&roc_file_path,
|
||||||
Triple::host(),
|
Triple::host(),
|
||||||
&app_o_file,
|
app_o_file,
|
||||||
opt_level,
|
opt_level,
|
||||||
emit_debug_info,
|
emit_debug_info,
|
||||||
);
|
);
|
||||||
|
|
|
@ -479,7 +479,7 @@ fn list_to_ast<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let arena = env.arena;
|
let arena = env.arena;
|
||||||
let mut output = Vec::with_capacity_in(len, &arena);
|
let mut output = Vec::with_capacity_in(len, arena);
|
||||||
let elem_size = elem_layout.stack_size(env.ptr_bytes) as usize;
|
let elem_size = elem_layout.stack_size(env.ptr_bytes) as usize;
|
||||||
|
|
||||||
for index in 0..len {
|
for index in 0..len {
|
||||||
|
@ -533,7 +533,7 @@ where
|
||||||
{
|
{
|
||||||
let arena = env.arena;
|
let arena = env.arena;
|
||||||
let subs = env.subs;
|
let subs = env.subs;
|
||||||
let mut output = Vec::with_capacity_in(sequence.len(), &arena);
|
let mut output = Vec::with_capacity_in(sequence.len(), arena);
|
||||||
|
|
||||||
// We'll advance this as we iterate through the fields
|
// We'll advance this as we iterate through the fields
|
||||||
let mut field_ptr = ptr as *const u8;
|
let mut field_ptr = ptr as *const u8;
|
||||||
|
@ -560,7 +560,7 @@ fn struct_to_ast<'a>(
|
||||||
) -> Expr<'a> {
|
) -> Expr<'a> {
|
||||||
let arena = env.arena;
|
let arena = env.arena;
|
||||||
let subs = env.subs;
|
let subs = env.subs;
|
||||||
let mut output = Vec::with_capacity_in(field_layouts.len(), &arena);
|
let mut output = Vec::with_capacity_in(field_layouts.len(), arena);
|
||||||
|
|
||||||
// The fields, sorted alphabetically
|
// The fields, sorted alphabetically
|
||||||
let mut sorted_fields = {
|
let mut sorted_fields = {
|
||||||
|
|
|
@ -219,7 +219,7 @@ pub fn gen_and_eval<'a>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let lib = module_to_dylib(&env.module, &target, opt_level)
|
let lib = module_to_dylib(env.module, &target, opt_level)
|
||||||
.expect("Error loading compiled dylib for test");
|
.expect("Error loading compiled dylib for test");
|
||||||
let res_answer = unsafe {
|
let res_answer = unsafe {
|
||||||
eval::jit_to_ast(
|
eval::jit_to_ast(
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn find_zig_str_path() -> PathBuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
fn build_zig_host(
|
pub fn build_zig_host(
|
||||||
env_path: &str,
|
env_path: &str,
|
||||||
env_home: &str,
|
env_home: &str,
|
||||||
emit_bin: &str,
|
emit_bin: &str,
|
||||||
|
@ -86,7 +86,7 @@ fn build_zig_host(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn build_zig_host(
|
pub fn build_zig_host(
|
||||||
env_path: &str,
|
env_path: &str,
|
||||||
env_home: &str,
|
env_home: &str,
|
||||||
emit_bin: &str,
|
emit_bin: &str,
|
||||||
|
@ -333,7 +333,7 @@ fn link_linux(
|
||||||
output_path,
|
output_path,
|
||||||
),
|
),
|
||||||
LinkType::Dylib => {
|
LinkType::Dylib => {
|
||||||
// TODO: do we acually need the version number on this?
|
// TODO: do we actually need the version number on this?
|
||||||
// Do we even need the "-soname" argument?
|
// Do we even need the "-soname" argument?
|
||||||
//
|
//
|
||||||
// See https://software.intel.com/content/www/us/en/develop/articles/create-a-unix-including-linux-shared-library.html
|
// See https://software.intel.com/content/www/us/en/develop/articles/create-a-unix-including-linux-shared-library.html
|
||||||
|
@ -496,7 +496,7 @@ pub fn module_to_dylib(
|
||||||
|
|
||||||
app_o_file.set_file_name("app.o");
|
app_o_file.set_file_name("app.o");
|
||||||
|
|
||||||
// Emit the .o file using position-indepedent code (PIC) - needed for dylibs
|
// Emit the .o file using position-independent code (PIC) - needed for dylibs
|
||||||
let reloc = RelocMode::PIC;
|
let reloc = RelocMode::PIC;
|
||||||
let model = CodeModel::Default;
|
let model = CodeModel::Default;
|
||||||
let target_machine =
|
let target_machine =
|
||||||
|
|
|
@ -132,7 +132,7 @@ pub fn gen_from_mono_module(
|
||||||
// Compile and add all the Procs before adding main
|
// Compile and add all the Procs before adding main
|
||||||
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
|
||||||
let env = roc_gen_llvm::llvm::build::Env {
|
let env = roc_gen_llvm::llvm::build::Env {
|
||||||
arena: &arena,
|
arena,
|
||||||
builder: &builder,
|
builder: &builder,
|
||||||
dibuilder: &dibuilder,
|
dibuilder: &dibuilder,
|
||||||
compile_unit: &compile_unit,
|
compile_unit: &compile_unit,
|
||||||
|
@ -243,7 +243,7 @@ pub fn gen_from_mono_module(
|
||||||
target::target_machine(&target, convert_opt_level(opt_level), reloc, model).unwrap();
|
target::target_machine(&target, convert_opt_level(opt_level), reloc, model).unwrap();
|
||||||
|
|
||||||
target_machine
|
target_machine
|
||||||
.write_to_file(&env.module, FileType::Object, &app_o_file)
|
.write_to_file(env.module, FileType::Object, app_o_file)
|
||||||
.expect("Writing .o file failed");
|
.expect("Writing .o file failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl Constraint {
|
||||||
|
|
||||||
fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDetail) {
|
fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDetail) {
|
||||||
for var in &detail.type_variables {
|
for var in &detail.type_variables {
|
||||||
if !(declared.rigid_vars.contains(&var) || declared.flex_vars.contains(&var)) {
|
if !(declared.rigid_vars.contains(var) || declared.flex_vars.contains(var)) {
|
||||||
accum.type_variables.insert(*var);
|
accum.type_variables.insert(*var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,11 @@ fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDe
|
||||||
|
|
||||||
// recursion vars should be always rigid
|
// recursion vars should be always rigid
|
||||||
for var in &detail.recursion_variables {
|
for var in &detail.recursion_variables {
|
||||||
if declared.flex_vars.contains(&var) {
|
if declared.flex_vars.contains(var) {
|
||||||
panic!("recursion variable {:?} is declared as flex", var);
|
panic!("recursion variable {:?} is declared as flex", var);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !declared.rigid_vars.contains(&var) {
|
if !declared.rigid_vars.contains(var) {
|
||||||
accum.recursion_variables.insert(*var);
|
accum.recursion_variables.insert(*var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,7 +380,7 @@ pub fn sort_can_defs(
|
||||||
//
|
//
|
||||||
// In the above example, `f` cannot reference `a`, and in the closure
|
// In the above example, `f` cannot reference `a`, and in the closure
|
||||||
// a call to `f` cannot cycle back to `a`.
|
// a call to `f` cannot cycle back to `a`.
|
||||||
let mut loc_succ = local_successors(&references, &env.closures);
|
let mut loc_succ = local_successors(references, &env.closures);
|
||||||
|
|
||||||
// if the current symbol is a closure, peek into its body
|
// if the current symbol is a closure, peek into its body
|
||||||
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
|
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
|
||||||
|
@ -430,7 +430,7 @@ pub fn sort_can_defs(
|
||||||
//
|
//
|
||||||
// In the above example, `f` cannot reference `a`, and in the closure
|
// In the above example, `f` cannot reference `a`, and in the closure
|
||||||
// a call to `f` cannot cycle back to `a`.
|
// a call to `f` cannot cycle back to `a`.
|
||||||
let mut loc_succ = local_successors(&references, &env.closures);
|
let mut loc_succ = local_successors(references, &env.closures);
|
||||||
|
|
||||||
// if the current symbol is a closure, peek into its body
|
// if the current symbol is a closure, peek into its body
|
||||||
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
|
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
|
||||||
|
@ -454,7 +454,7 @@ pub fn sort_can_defs(
|
||||||
let direct_successors = |symbol: &Symbol| -> ImSet<Symbol> {
|
let direct_successors = |symbol: &Symbol| -> ImSet<Symbol> {
|
||||||
match refs_by_symbol.get(symbol) {
|
match refs_by_symbol.get(symbol) {
|
||||||
Some((_, references)) => {
|
Some((_, references)) => {
|
||||||
let mut loc_succ = local_successors(&references, &env.closures);
|
let mut loc_succ = local_successors(references, &env.closures);
|
||||||
|
|
||||||
// NOTE: if the symbol is a closure we DONT look into its body
|
// NOTE: if the symbol is a closure we DONT look into its body
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ pub fn sort_can_defs(
|
||||||
),
|
),
|
||||||
Some((region, _)) => {
|
Some((region, _)) => {
|
||||||
let expr_region =
|
let expr_region =
|
||||||
can_defs_by_symbol.get(&symbol).unwrap().loc_expr.region;
|
can_defs_by_symbol.get(symbol).unwrap().loc_expr.region;
|
||||||
|
|
||||||
let entry = CycleEntry {
|
let entry = CycleEntry {
|
||||||
symbol: *symbol,
|
symbol: *symbol,
|
||||||
|
@ -662,11 +662,11 @@ fn group_to_declaration(
|
||||||
// for a definition, so every definition is only inserted (thus typechecked and emitted) once
|
// for a definition, so every definition is only inserted (thus typechecked and emitted) once
|
||||||
let mut seen_pattern_regions: ImSet<Region> = ImSet::default();
|
let mut seen_pattern_regions: ImSet<Region> = ImSet::default();
|
||||||
|
|
||||||
for cycle in strongly_connected_components(&group, filtered_successors) {
|
for cycle in strongly_connected_components(group, filtered_successors) {
|
||||||
if cycle.len() == 1 {
|
if cycle.len() == 1 {
|
||||||
let symbol = &cycle[0];
|
let symbol = &cycle[0];
|
||||||
|
|
||||||
if let Some(can_def) = can_defs_by_symbol.get(&symbol) {
|
if let Some(can_def) = can_defs_by_symbol.get(symbol) {
|
||||||
let mut new_def = can_def.clone();
|
let mut new_def = can_def.clone();
|
||||||
|
|
||||||
// Determine recursivity of closures that are not tail-recursive
|
// Determine recursivity of closures that are not tail-recursive
|
||||||
|
@ -678,7 +678,7 @@ fn group_to_declaration(
|
||||||
*recursive = closure_recursivity(*symbol, closures);
|
*recursive = closure_recursivity(*symbol, closures);
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_recursive = successors(&symbol).contains(&symbol);
|
let is_recursive = successors(symbol).contains(symbol);
|
||||||
|
|
||||||
if !seen_pattern_regions.contains(&new_def.loc_pattern.region) {
|
if !seen_pattern_regions.contains(&new_def.loc_pattern.region) {
|
||||||
if is_recursive {
|
if is_recursive {
|
||||||
|
@ -854,7 +854,7 @@ fn canonicalize_pending_def<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
for (_, (symbol, _)) in scope.idents() {
|
for (_, (symbol, _)) in scope.idents() {
|
||||||
if !vars_by_symbol.contains_key(&symbol) {
|
if !vars_by_symbol.contains_key(symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,7 +999,7 @@ fn canonicalize_pending_def<'a>(
|
||||||
//
|
//
|
||||||
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
|
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
|
||||||
if let (
|
if let (
|
||||||
&ast::Pattern::Identifier(ref _name),
|
&ast::Pattern::Identifier(_name),
|
||||||
&Pattern::Identifier(ref defined_symbol),
|
&Pattern::Identifier(ref defined_symbol),
|
||||||
&Closure {
|
&Closure {
|
||||||
function_type,
|
function_type,
|
||||||
|
@ -1021,7 +1021,7 @@ fn canonicalize_pending_def<'a>(
|
||||||
|
|
||||||
// Since everywhere in the code it'll be referred to by its defined name,
|
// Since everywhere in the code it'll be referred to by its defined name,
|
||||||
// remove its generated name from the closure map. (We'll re-insert it later.)
|
// remove its generated name from the closure map. (We'll re-insert it later.)
|
||||||
let references = env.closures.remove(&symbol).unwrap_or_else(|| {
|
let references = env.closures.remove(symbol).unwrap_or_else(|| {
|
||||||
panic!(
|
panic!(
|
||||||
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
|
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
|
||||||
symbol, env.closures
|
symbol, env.closures
|
||||||
|
@ -1065,7 +1065,7 @@ fn canonicalize_pending_def<'a>(
|
||||||
// Store the referenced locals in the refs_by_symbol map, so we can later figure out
|
// Store the referenced locals in the refs_by_symbol map, so we can later figure out
|
||||||
// which defined names reference each other.
|
// which defined names reference each other.
|
||||||
for (_, (symbol, region)) in scope.idents() {
|
for (_, (symbol, region)) in scope.idents() {
|
||||||
if !vars_by_symbol.contains_key(&symbol) {
|
if !vars_by_symbol.contains_key(symbol) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1110,10 +1110,8 @@ fn canonicalize_pending_def<'a>(
|
||||||
// identifier (e.g. `f = \x -> ...`), then this symbol can be tail-called.
|
// identifier (e.g. `f = \x -> ...`), then this symbol can be tail-called.
|
||||||
let outer_identifier = env.tailcallable_symbol;
|
let outer_identifier = env.tailcallable_symbol;
|
||||||
|
|
||||||
if let (
|
if let (&ast::Pattern::Identifier(_name), &Pattern::Identifier(ref defined_symbol)) =
|
||||||
&ast::Pattern::Identifier(ref _name),
|
(&loc_pattern.value, &loc_can_pattern.value)
|
||||||
&Pattern::Identifier(ref defined_symbol),
|
|
||||||
) = (&loc_pattern.value, &loc_can_pattern.value)
|
|
||||||
{
|
{
|
||||||
env.tailcallable_symbol = Some(*defined_symbol);
|
env.tailcallable_symbol = Some(*defined_symbol);
|
||||||
|
|
||||||
|
@ -1144,7 +1142,7 @@ fn canonicalize_pending_def<'a>(
|
||||||
//
|
//
|
||||||
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
|
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
|
||||||
if let (
|
if let (
|
||||||
&ast::Pattern::Identifier(ref _name),
|
&ast::Pattern::Identifier(_name),
|
||||||
&Pattern::Identifier(ref defined_symbol),
|
&Pattern::Identifier(ref defined_symbol),
|
||||||
&Closure {
|
&Closure {
|
||||||
function_type,
|
function_type,
|
||||||
|
@ -1166,7 +1164,7 @@ fn canonicalize_pending_def<'a>(
|
||||||
|
|
||||||
// Since everywhere in the code it'll be referred to by its defined name,
|
// Since everywhere in the code it'll be referred to by its defined name,
|
||||||
// remove its generated name from the closure map. (We'll re-insert it later.)
|
// remove its generated name from the closure map. (We'll re-insert it later.)
|
||||||
let references = env.closures.remove(&symbol).unwrap_or_else(|| {
|
let references = env.closures.remove(symbol).unwrap_or_else(|| {
|
||||||
panic!(
|
panic!(
|
||||||
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
|
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
|
||||||
symbol, env.closures
|
symbol, env.closures
|
||||||
|
@ -1555,7 +1553,7 @@ fn correct_mutual_recursive_type_alias<'a>(
|
||||||
let mut loc_succ = alias.typ.symbols();
|
let mut loc_succ = alias.typ.symbols();
|
||||||
// remove anything that is not defined in the current block
|
// remove anything that is not defined in the current block
|
||||||
loc_succ.retain(|key| symbols_introduced.contains(key));
|
loc_succ.retain(|key| symbols_introduced.contains(key));
|
||||||
loc_succ.remove(&symbol);
|
loc_succ.remove(symbol);
|
||||||
|
|
||||||
loc_succ
|
loc_succ
|
||||||
}
|
}
|
||||||
|
|
|
@ -980,7 +980,7 @@ where
|
||||||
visited.insert(defined_symbol);
|
visited.insert(defined_symbol);
|
||||||
|
|
||||||
for local in refs.lookups.iter() {
|
for local in refs.lookups.iter() {
|
||||||
if !visited.contains(&local) {
|
if !visited.contains(local) {
|
||||||
let other_refs: References =
|
let other_refs: References =
|
||||||
references_from_local(*local, visited, refs_by_def, closures);
|
references_from_local(*local, visited, refs_by_def, closures);
|
||||||
|
|
||||||
|
@ -991,7 +991,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
for call in refs.calls.iter() {
|
for call in refs.calls.iter() {
|
||||||
if !visited.contains(&call) {
|
if !visited.contains(call) {
|
||||||
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
|
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
|
||||||
|
|
||||||
answer = answer.union(other_refs);
|
answer = answer.union(other_refs);
|
||||||
|
@ -1022,7 +1022,7 @@ where
|
||||||
visited.insert(call_symbol);
|
visited.insert(call_symbol);
|
||||||
|
|
||||||
for closed_over_local in references.lookups.iter() {
|
for closed_over_local in references.lookups.iter() {
|
||||||
if !visited.contains(&closed_over_local) {
|
if !visited.contains(closed_over_local) {
|
||||||
let other_refs =
|
let other_refs =
|
||||||
references_from_local(*closed_over_local, visited, refs_by_def, closures);
|
references_from_local(*closed_over_local, visited, refs_by_def, closures);
|
||||||
|
|
||||||
|
@ -1033,7 +1033,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
for call in references.calls.iter() {
|
for call in references.calls.iter() {
|
||||||
if !visited.contains(&call) {
|
if !visited.contains(call) {
|
||||||
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
|
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
|
||||||
|
|
||||||
answer = answer.union(other_refs);
|
answer = answer.union(other_refs);
|
||||||
|
|
|
@ -276,7 +276,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
When(loc_cond_expr, branches) => {
|
When(loc_cond_expr, branches) => {
|
||||||
let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, &loc_cond_expr));
|
let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, loc_cond_expr));
|
||||||
let mut desugared_branches = Vec::with_capacity_in(branches.len(), arena);
|
let mut desugared_branches = Vec::with_capacity_in(branches.len(), arena);
|
||||||
|
|
||||||
for branch in branches.iter() {
|
for branch in branches.iter() {
|
||||||
|
@ -346,7 +346,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
|
||||||
}
|
}
|
||||||
If(if_thens, final_else_branch) => {
|
If(if_thens, final_else_branch) => {
|
||||||
// If does not get desugared into `when` so we can give more targeted error messages during type checking.
|
// If does not get desugared into `when` so we can give more targeted error messages during type checking.
|
||||||
let desugared_final_else = &*arena.alloc(desugar_expr(arena, &final_else_branch));
|
let desugared_final_else = &*arena.alloc(desugar_expr(arena, final_else_branch));
|
||||||
|
|
||||||
let mut desugared_if_thens = Vec::with_capacity_in(if_thens.len(), arena);
|
let mut desugared_if_thens = Vec::with_capacity_in(if_thens.len(), arena);
|
||||||
|
|
||||||
|
@ -363,8 +363,8 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Expect(condition, continuation) => {
|
Expect(condition, continuation) => {
|
||||||
let desugared_condition = &*arena.alloc(desugar_expr(arena, &condition));
|
let desugared_condition = &*arena.alloc(desugar_expr(arena, condition));
|
||||||
let desugared_continuation = &*arena.alloc(desugar_expr(arena, &continuation));
|
let desugared_continuation = &*arena.alloc(desugar_expr(arena, continuation));
|
||||||
arena.alloc(Located {
|
arena.alloc(Located {
|
||||||
value: Expect(desugared_condition, desugared_continuation),
|
value: Expect(desugared_condition, desugared_continuation),
|
||||||
region: loc_expr.region,
|
region: loc_expr.region,
|
||||||
|
|
|
@ -185,7 +185,7 @@ pub fn canonicalize_pattern<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatLiteral(ref string) => match pattern_type {
|
FloatLiteral(string) => match pattern_type {
|
||||||
WhenBranch => match finish_parsing_float(string) {
|
WhenBranch => match finish_parsing_float(string) {
|
||||||
Err(_error) => {
|
Err(_error) => {
|
||||||
let problem = MalformedPatternProblem::MalformedFloat;
|
let problem = MalformedPatternProblem::MalformedFloat;
|
||||||
|
|
|
@ -124,7 +124,7 @@ impl Scope {
|
||||||
// If this IdentId was already added previously
|
// If this IdentId was already added previously
|
||||||
// when the value was exposed in the module header,
|
// when the value was exposed in the module header,
|
||||||
// use that existing IdentId. Otherwise, create a fresh one.
|
// use that existing IdentId. Otherwise, create a fresh one.
|
||||||
let ident_id = match exposed_ident_ids.get_id(&ident.as_inline_str()) {
|
let ident_id = match exposed_ident_ids.get_id(ident.as_inline_str()) {
|
||||||
Some(ident_id) => *ident_id,
|
Some(ident_id) => *ident_id,
|
||||||
None => all_ident_ids.add(ident.clone().into()),
|
None => all_ident_ids.add(ident.clone().into()),
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub struct CanExprOut {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut {
|
pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut {
|
||||||
let loc_expr = roc_parse::test_helpers::parse_loc_with(&arena, expr_str).unwrap_or_else(|e| {
|
let loc_expr = roc_parse::test_helpers::parse_loc_with(arena, expr_str).unwrap_or_else(|e| {
|
||||||
panic!(
|
panic!(
|
||||||
"can_expr_with() got a parse error when attempting to canonicalize:\n\n{:?} {:?}",
|
"can_expr_with() got a parse error when attempting to canonicalize:\n\n{:?} {:?}",
|
||||||
expr_str, e
|
expr_str, e
|
||||||
|
|
|
@ -145,7 +145,7 @@ mod test_can {
|
||||||
let region = Region::zero();
|
let region = Region::zero();
|
||||||
|
|
||||||
assert_can(
|
assert_can(
|
||||||
&string.clone(),
|
string.clone(),
|
||||||
RuntimeError(RuntimeError::InvalidFloat(
|
RuntimeError(RuntimeError::InvalidFloat(
|
||||||
FloatErrorKind::Error,
|
FloatErrorKind::Error,
|
||||||
region,
|
region,
|
||||||
|
@ -658,7 +658,7 @@ mod test_can {
|
||||||
recursive: recursion,
|
recursive: recursion,
|
||||||
..
|
..
|
||||||
}) => recursion.clone(),
|
}) => recursion.clone(),
|
||||||
Some(other @ _) => {
|
Some(other) => {
|
||||||
panic!("assignment at {} is not a closure, but a {:?}", i, other)
|
panic!("assignment at {} is not a closure, but a {:?}", i, other)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -680,7 +680,7 @@ mod test_can {
|
||||||
recursive: recursion,
|
recursive: recursion,
|
||||||
..
|
..
|
||||||
} => recursion.clone(),
|
} => recursion.clone(),
|
||||||
other @ _ => {
|
other => {
|
||||||
panic!("assignment at {} is not a closure, but a {:?}", i, other)
|
panic!("assignment at {} is not a closure, but a {:?}", i, other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ where
|
||||||
let mut buf = String::new_in(arena);
|
let mut buf = String::new_in(arena);
|
||||||
|
|
||||||
if let Some(first) = strings.next() {
|
if let Some(first) = strings.next() {
|
||||||
buf.push_str(&first);
|
buf.push_str(first);
|
||||||
|
|
||||||
for string in strings {
|
for string in strings {
|
||||||
buf.reserve(join_str.len() + string.len());
|
buf.reserve(join_str.len() + string.len());
|
||||||
|
@ -133,7 +133,7 @@ where
|
||||||
let mut answer = MutMap::default();
|
let mut answer = MutMap::default();
|
||||||
|
|
||||||
for (key, right_value) in map2 {
|
for (key, right_value) in map2 {
|
||||||
match std::collections::HashMap::get(map1, &key) {
|
match std::collections::HashMap::get(map1, key) {
|
||||||
None => (),
|
None => (),
|
||||||
Some(left_value) => {
|
Some(left_value) => {
|
||||||
answer.insert(key.clone(), (left_value.clone(), right_value.clone()));
|
answer.insert(key.clone(), (left_value.clone(), right_value.clone()));
|
||||||
|
|
|
@ -1446,7 +1446,7 @@ fn instantiate_rigids(
|
||||||
let mut rigid_substitution: ImMap<Variable, Type> = ImMap::default();
|
let mut rigid_substitution: ImMap<Variable, Type> = ImMap::default();
|
||||||
|
|
||||||
for (name, var) in introduced_vars.var_by_name.iter() {
|
for (name, var) in introduced_vars.var_by_name.iter() {
|
||||||
if let Some(existing_rigid) = ftv.get(&name) {
|
if let Some(existing_rigid) = ftv.get(name) {
|
||||||
rigid_substitution.insert(*var, Type::Variable(*existing_rigid));
|
rigid_substitution.insert(*var, Type::Variable(*existing_rigid));
|
||||||
} else {
|
} else {
|
||||||
// It's possible to use this rigid in nested defs
|
// It's possible to use this rigid in nested defs
|
||||||
|
|
|
@ -119,7 +119,7 @@ fn headers_from_annotation_help(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This accepts PatternState (rather than returning it) so that the caller can
|
/// This accepts PatternState (rather than returning it) so that the caller can
|
||||||
/// intiialize the Vecs in PatternState using with_capacity
|
/// initialize the Vecs in PatternState using with_capacity
|
||||||
/// based on its knowledge of their lengths.
|
/// based on its knowledge of their lengths.
|
||||||
pub fn constrain_pattern(
|
pub fn constrain_pattern(
|
||||||
env: &Env,
|
env: &Env,
|
||||||
|
@ -206,7 +206,7 @@ pub fn constrain_pattern(
|
||||||
let pat_type = Type::Variable(*var);
|
let pat_type = Type::Variable(*var);
|
||||||
let expected = PExpected::NoExpectation(pat_type.clone());
|
let expected = PExpected::NoExpectation(pat_type.clone());
|
||||||
|
|
||||||
if !state.headers.contains_key(&symbol) {
|
if !state.headers.contains_key(symbol) {
|
||||||
state
|
state
|
||||||
.headers
|
.headers
|
||||||
.insert(*symbol, Located::at(region, pat_type.clone()));
|
.insert(*symbol, Located::at(region, pat_type.clone()));
|
||||||
|
|
|
@ -295,7 +295,7 @@ impl<'a> Formattable<'a> for Expr<'a> {
|
||||||
items,
|
items,
|
||||||
final_comments,
|
final_comments,
|
||||||
} => {
|
} => {
|
||||||
fmt_list(buf, &items, final_comments, indent);
|
fmt_list(buf, items, final_comments, indent);
|
||||||
}
|
}
|
||||||
BinOps(lefts, right) => fmt_bin_ops(buf, lefts, right, false, parens, indent),
|
BinOps(lefts, right) => fmt_bin_ops(buf, lefts, right, false, parens, indent),
|
||||||
UnaryOp(sub_expr, unary_op) => {
|
UnaryOp(sub_expr, unary_op) => {
|
||||||
|
@ -1027,7 +1027,7 @@ fn format_field_multiline<'a, T>(
|
||||||
format_field_multiline(buf, sub_field, indent, separator_prefix);
|
format_field_multiline(buf, sub_field, indent, separator_prefix);
|
||||||
}
|
}
|
||||||
AssignedField::SpaceAfter(sub_field, spaces) => {
|
AssignedField::SpaceAfter(sub_field, spaces) => {
|
||||||
// We have somethig like that:
|
// We have something like that:
|
||||||
// ```
|
// ```
|
||||||
// field # comment
|
// field # comment
|
||||||
// , otherfield
|
// , otherfield
|
||||||
|
|
|
@ -74,7 +74,7 @@ where
|
||||||
/// build_proc creates a procedure and outputs it to the wrapped object writer.
|
/// build_proc creates a procedure and outputs it to the wrapped object writer.
|
||||||
fn build_proc(&mut self, proc: Proc<'a>) -> Result<(&'a [u8], &[Relocation]), String> {
|
fn build_proc(&mut self, proc: Proc<'a>) -> Result<(&'a [u8], &[Relocation]), String> {
|
||||||
self.reset();
|
self.reset();
|
||||||
self.load_args(&proc.args)?;
|
self.load_args(proc.args)?;
|
||||||
// let start = std::time::Instant::now();
|
// let start = std::time::Instant::now();
|
||||||
self.scan_ast(&proc.body);
|
self.scan_ast(&proc.body);
|
||||||
self.create_free_map();
|
self.create_free_map();
|
||||||
|
|
|
@ -31,7 +31,7 @@ mod dev_num {
|
||||||
assert_evals_to!("-0.0", 0.0, f64);
|
assert_evals_to!("-0.0", 0.0, f64);
|
||||||
assert_evals_to!("1.0", 1.0, f64);
|
assert_evals_to!("1.0", 1.0, f64);
|
||||||
assert_evals_to!("-1.0", -1.0, f64);
|
assert_evals_to!("-1.0", -1.0, f64);
|
||||||
assert_evals_to!("3.1415926535897932", 3.1415926535897932, f64);
|
assert_evals_to!("3.1415926535897932", 3.141_592_653_589_793, f64);
|
||||||
assert_evals_to!(&format!("{:0.1}", f64::MIN), f64::MIN, f64);
|
assert_evals_to!(&format!("{:0.1}", f64::MIN), f64::MIN, f64);
|
||||||
assert_evals_to!(&format!("{:0.1}", f64::MAX), f64::MAX, f64);
|
assert_evals_to!(&format!("{:0.1}", f64::MAX), f64::MAX, f64);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub fn helper<'a>(
|
||||||
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
||||||
arena,
|
arena,
|
||||||
filename,
|
filename,
|
||||||
&module_src,
|
module_src,
|
||||||
&stdlib,
|
&stdlib,
|
||||||
src_dir,
|
src_dir,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub fn build_has_tag_id<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
match env.module.get_function(fn_name) {
|
match env.module.get_function(fn_name) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => build_has_tag_id_help(env, union_layout, &fn_name),
|
None => build_has_tag_id_help(env, union_layout, fn_name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +97,9 @@ fn build_has_tag_id_help<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
&fn_name,
|
fn_name,
|
||||||
output_type.into(),
|
output_type.into(),
|
||||||
&argument_types,
|
argument_types,
|
||||||
);
|
);
|
||||||
|
|
||||||
// called from zig, must use C calling convention
|
// called from zig, must use C calling convention
|
||||||
|
@ -204,7 +204,7 @@ pub fn build_transform_caller<'a, 'ctx, 'env>(
|
||||||
function,
|
function,
|
||||||
closure_data_layout,
|
closure_data_layout,
|
||||||
argument_layouts,
|
argument_layouts,
|
||||||
&fn_name,
|
fn_name,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ fn build_transform_caller_help<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
&fn_name,
|
fn_name,
|
||||||
env.context.void_type().into(),
|
env.context.void_type().into(),
|
||||||
&(bumpalo::vec![ in env.arena; BasicTypeEnum::PointerType(arg_type); argument_layouts.len() + 2 ]),
|
&(bumpalo::vec![ in env.arena; BasicTypeEnum::PointerType(arg_type); argument_layouts.len() + 2 ]),
|
||||||
);
|
);
|
||||||
|
@ -394,7 +394,7 @@ fn build_rc_wrapper<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::GENERIC_RC_REF;
|
let symbol = Symbol::GENERIC_RC_REF;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &layout)
|
.get(symbol, layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let fn_name = match rc_operation {
|
let fn_name = match rc_operation {
|
||||||
|
@ -489,7 +489,7 @@ pub fn build_eq_wrapper<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::GENERIC_EQ_REF;
|
let symbol = Symbol::GENERIC_EQ_REF;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &layout)
|
.get(symbol, layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let function_value = match env.module.get_function(fn_name.as_str()) {
|
let function_value = match env.module.get_function(fn_name.as_str()) {
|
||||||
|
@ -576,7 +576,7 @@ pub fn build_compare_wrapper<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
&fn_name,
|
fn_name,
|
||||||
env.context.i8_type().into(),
|
env.context.i8_type().into(),
|
||||||
&[arg_type.into(), arg_type.into(), arg_type.into()],
|
&[arg_type.into(), arg_type.into(), arg_type.into()],
|
||||||
);
|
);
|
||||||
|
|
|
@ -347,7 +347,7 @@ pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Modu
|
||||||
// we compile the builtins into LLVM bitcode
|
// we compile the builtins into LLVM bitcode
|
||||||
let bitcode_bytes: &[u8] = include_bytes!("../../../builtins/bitcode/builtins.bc");
|
let bitcode_bytes: &[u8] = include_bytes!("../../../builtins/bitcode/builtins.bc");
|
||||||
|
|
||||||
let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name);
|
let memory_buffer = MemoryBuffer::create_from_memory_range(bitcode_bytes, module_name);
|
||||||
|
|
||||||
let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx)
|
let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx)
|
||||||
.unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err));
|
.unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err));
|
||||||
|
@ -632,7 +632,7 @@ pub fn float_with_precision<'a, 'ctx, 'env>(
|
||||||
Builtin::Decimal => call_bitcode_fn(
|
Builtin::Decimal => call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[env.context.f64_type().const_float(value).into()],
|
&[env.context.f64_type().const_float(value).into()],
|
||||||
&bitcode::DEC_FROM_F64,
|
bitcode::DEC_FROM_F64,
|
||||||
),
|
),
|
||||||
Builtin::Float64 => env.context.f64_type().const_float(value).into(),
|
Builtin::Float64 => env.context.f64_type().const_float(value).into(),
|
||||||
Builtin::Float32 => env.context.f32_type().const_float(value).into(),
|
Builtin::Float32 => env.context.f32_type().const_float(value).into(),
|
||||||
|
@ -976,7 +976,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
||||||
// The layout of the struct expects them to be dropped!
|
// The layout of the struct expects them to be dropped!
|
||||||
let (field_expr, field_layout) = load_symbol_and_layout(scope, symbol);
|
let (field_expr, field_layout) = load_symbol_and_layout(scope, symbol);
|
||||||
if !field_layout.is_dropped_because_empty() {
|
if !field_layout.is_dropped_because_empty() {
|
||||||
field_types.push(basic_type_from_layout(env, &field_layout));
|
field_types.push(basic_type_from_layout(env, field_layout));
|
||||||
|
|
||||||
field_vals.push(field_expr);
|
field_vals.push(field_expr);
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1187,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
UnionLayout::NonNullableUnwrapped(field_layouts) => {
|
UnionLayout::NonNullableUnwrapped(field_layouts) => {
|
||||||
let struct_layout = Layout::Struct(&field_layouts);
|
let struct_layout = Layout::Struct(field_layouts);
|
||||||
|
|
||||||
let struct_type = basic_type_from_layout(env, &struct_layout);
|
let struct_type = basic_type_from_layout(env, &struct_layout);
|
||||||
|
|
||||||
|
@ -1260,7 +1260,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
|
||||||
// cast the argument bytes into the desired shape for this tag
|
// cast the argument bytes into the desired shape for this tag
|
||||||
let (argument, _structure_layout) = load_symbol_and_layout(scope, structure);
|
let (argument, _structure_layout) = load_symbol_and_layout(scope, structure);
|
||||||
|
|
||||||
get_tag_id(env, parent, &union_layout, argument).into()
|
get_tag_id(env, parent, union_layout, argument).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1459,7 +1459,7 @@ pub fn build_tag<'a, 'ctx, 'env>(
|
||||||
union_layout,
|
union_layout,
|
||||||
tag_id,
|
tag_id,
|
||||||
arguments,
|
arguments,
|
||||||
&tag_field_layouts,
|
tag_field_layouts,
|
||||||
tags,
|
tags,
|
||||||
reuse_allocation,
|
reuse_allocation,
|
||||||
parent,
|
parent,
|
||||||
|
@ -1491,7 +1491,7 @@ pub fn build_tag<'a, 'ctx, 'env>(
|
||||||
union_layout,
|
union_layout,
|
||||||
tag_id,
|
tag_id,
|
||||||
arguments,
|
arguments,
|
||||||
&tag_field_layouts,
|
tag_field_layouts,
|
||||||
tags,
|
tags,
|
||||||
reuse_allocation,
|
reuse_allocation,
|
||||||
parent,
|
parent,
|
||||||
|
@ -2269,7 +2269,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
||||||
scope,
|
scope,
|
||||||
parent,
|
parent,
|
||||||
layout,
|
layout,
|
||||||
&expr,
|
expr,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Make a new scope which includes the binding we just encountered.
|
// Make a new scope which includes the binding we just encountered.
|
||||||
|
@ -2399,7 +2399,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
||||||
cond_layout,
|
cond_layout,
|
||||||
cond_symbol,
|
cond_symbol,
|
||||||
} => {
|
} => {
|
||||||
let ret_type = basic_type_from_layout(env, &ret_layout);
|
let ret_type = basic_type_from_layout(env, ret_layout);
|
||||||
|
|
||||||
let switch_args = SwitchArgsIr {
|
let switch_args = SwitchArgsIr {
|
||||||
cond_layout: *cond_layout,
|
cond_layout: *cond_layout,
|
||||||
|
@ -2477,7 +2477,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
|
||||||
);
|
);
|
||||||
|
|
||||||
// remove this join point again
|
// remove this join point again
|
||||||
scope.join_points.remove(&id);
|
scope.join_points.remove(id);
|
||||||
|
|
||||||
cont_block.move_after(phi_block).unwrap();
|
cont_block.move_after(phi_block).unwrap();
|
||||||
|
|
||||||
|
@ -3121,7 +3121,7 @@ where
|
||||||
let call_result = {
|
let call_result = {
|
||||||
let call = builder.build_invoke(
|
let call = builder.build_invoke(
|
||||||
function,
|
function,
|
||||||
&arguments,
|
arguments,
|
||||||
then_block,
|
then_block,
|
||||||
catch_block,
|
catch_block,
|
||||||
"call_roc_function",
|
"call_roc_function",
|
||||||
|
@ -3291,7 +3291,7 @@ fn make_exception_catching_wrapper<'a, 'ctx, 'env>(
|
||||||
// Add main to the module.
|
// Add main to the module.
|
||||||
let wrapper_function = add_func(
|
let wrapper_function = add_func(
|
||||||
env.module,
|
env.module,
|
||||||
&wrapper_function_name,
|
wrapper_function_name,
|
||||||
wrapper_function_type,
|
wrapper_function_type,
|
||||||
Linkage::External,
|
Linkage::External,
|
||||||
C_CALL_CONV,
|
C_CALL_CONV,
|
||||||
|
@ -3414,7 +3414,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
|
||||||
// Add all the Proc headers to the module.
|
// Add all the Proc headers to the module.
|
||||||
// We have to do this in a separate pass first,
|
// We have to do this in a separate pass first,
|
||||||
// because their bodies may reference each other.
|
// because their bodies may reference each other.
|
||||||
let headers = build_proc_headers(env, &mod_solutions, procedures, &mut scope);
|
let headers = build_proc_headers(env, mod_solutions, procedures, &mut scope);
|
||||||
|
|
||||||
let (_, function_pass) = construct_optimization_passes(env.module, opt_level);
|
let (_, function_pass) = construct_optimization_passes(env.module, opt_level);
|
||||||
|
|
||||||
|
@ -3428,7 +3428,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
|
||||||
current_scope.retain_top_level_thunks_for_module(home);
|
current_scope.retain_top_level_thunks_for_module(home);
|
||||||
|
|
||||||
build_proc(
|
build_proc(
|
||||||
&env,
|
env,
|
||||||
mod_solutions,
|
mod_solutions,
|
||||||
&mut layout_ids,
|
&mut layout_ids,
|
||||||
func_spec_solutions,
|
func_spec_solutions,
|
||||||
|
@ -3441,7 +3441,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
|
||||||
env.dibuilder.finalize();
|
env.dibuilder.finalize();
|
||||||
|
|
||||||
if fn_val.verify(true) {
|
if fn_val.verify(true) {
|
||||||
function_pass.run_on(&fn_val);
|
function_pass.run_on(fn_val);
|
||||||
} else {
|
} else {
|
||||||
let mode = "NON-OPTIMIZED";
|
let mode = "NON-OPTIMIZED";
|
||||||
|
|
||||||
|
@ -3511,7 +3511,7 @@ fn build_proc_header<'a, 'ctx, 'env>(
|
||||||
let mut arg_basic_types = Vec::with_capacity_in(args.len(), arena);
|
let mut arg_basic_types = Vec::with_capacity_in(args.len(), arena);
|
||||||
|
|
||||||
for (layout, _) in args.iter() {
|
for (layout, _) in args.iter() {
|
||||||
let arg_type = basic_type_from_layout(env, &layout);
|
let arg_type = basic_type_from_layout(env, layout);
|
||||||
|
|
||||||
arg_basic_types.push(arg_type);
|
arg_basic_types.push(arg_type);
|
||||||
}
|
}
|
||||||
|
@ -5426,7 +5426,7 @@ fn build_int_binop<'a, 'ctx, 'env>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NumDivUnchecked => bd.build_int_signed_div(lhs, rhs, "div_int").into(),
|
NumDivUnchecked => bd.build_int_signed_div(lhs, rhs, "div_int").into(),
|
||||||
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], &bitcode::NUM_POW_INT),
|
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], bitcode::NUM_POW_INT),
|
||||||
NumBitwiseAnd => bd.build_and(lhs, rhs, "int_bitwise_and").into(),
|
NumBitwiseAnd => bd.build_and(lhs, rhs, "int_bitwise_and").into(),
|
||||||
NumBitwiseXor => bd.build_xor(lhs, rhs, "int_bitwise_xor").into(),
|
NumBitwiseXor => bd.build_xor(lhs, rhs, "int_bitwise_xor").into(),
|
||||||
NumBitwiseOr => bd.build_or(lhs, rhs, "int_bitwise_or").into(),
|
NumBitwiseOr => bd.build_or(lhs, rhs, "int_bitwise_or").into(),
|
||||||
|
@ -5523,7 +5523,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
|
||||||
let result = bd.build_float_add(lhs, rhs, "add_float");
|
let result = bd.build_float_add(lhs, rhs, "add_float");
|
||||||
|
|
||||||
let is_finite =
|
let is_finite =
|
||||||
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
|
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
|
||||||
|
|
||||||
let then_block = context.append_basic_block(parent, "then_block");
|
let then_block = context.append_basic_block(parent, "then_block");
|
||||||
let throw_block = context.append_basic_block(parent, "throw_block");
|
let throw_block = context.append_basic_block(parent, "throw_block");
|
||||||
|
@ -5544,7 +5544,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
|
||||||
let result = bd.build_float_add(lhs, rhs, "add_float");
|
let result = bd.build_float_add(lhs, rhs, "add_float");
|
||||||
|
|
||||||
let is_finite =
|
let is_finite =
|
||||||
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
|
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
|
||||||
let is_infinite = bd.build_not(is_finite, "negate");
|
let is_infinite = bd.build_not(is_finite, "negate");
|
||||||
|
|
||||||
let struct_type = context.struct_type(
|
let struct_type = context.struct_type(
|
||||||
|
@ -5572,7 +5572,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
|
||||||
let result = bd.build_float_sub(lhs, rhs, "sub_float");
|
let result = bd.build_float_sub(lhs, rhs, "sub_float");
|
||||||
|
|
||||||
let is_finite =
|
let is_finite =
|
||||||
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
|
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
|
||||||
|
|
||||||
let then_block = context.append_basic_block(parent, "then_block");
|
let then_block = context.append_basic_block(parent, "then_block");
|
||||||
let throw_block = context.append_basic_block(parent, "throw_block");
|
let throw_block = context.append_basic_block(parent, "throw_block");
|
||||||
|
@ -5593,7 +5593,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
|
||||||
let result = bd.build_float_sub(lhs, rhs, "sub_float");
|
let result = bd.build_float_sub(lhs, rhs, "sub_float");
|
||||||
|
|
||||||
let is_finite =
|
let is_finite =
|
||||||
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
|
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
|
||||||
let is_infinite = bd.build_not(is_finite, "negate");
|
let is_infinite = bd.build_not(is_finite, "negate");
|
||||||
|
|
||||||
let struct_type = context.struct_type(
|
let struct_type = context.struct_type(
|
||||||
|
@ -5621,7 +5621,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
|
||||||
let result = bd.build_float_mul(lhs, rhs, "mul_float");
|
let result = bd.build_float_mul(lhs, rhs, "mul_float");
|
||||||
|
|
||||||
let is_finite =
|
let is_finite =
|
||||||
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
|
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
|
||||||
|
|
||||||
let then_block = context.append_basic_block(parent, "then_block");
|
let then_block = context.append_basic_block(parent, "then_block");
|
||||||
let throw_block = context.append_basic_block(parent, "throw_block");
|
let throw_block = context.append_basic_block(parent, "throw_block");
|
||||||
|
@ -5642,7 +5642,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
|
||||||
let result = bd.build_float_mul(lhs, rhs, "mul_float");
|
let result = bd.build_float_mul(lhs, rhs, "mul_float");
|
||||||
|
|
||||||
let is_finite =
|
let is_finite =
|
||||||
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
|
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
|
||||||
let is_infinite = bd.build_not(is_finite, "negate");
|
let is_infinite = bd.build_not(is_finite, "negate");
|
||||||
|
|
||||||
let struct_type = context.struct_type(
|
let struct_type = context.struct_type(
|
||||||
|
@ -5688,9 +5688,9 @@ fn build_dec_binop<'a, 'ctx, 'env>(
|
||||||
use roc_module::low_level::LowLevel::*;
|
use roc_module::low_level::LowLevel::*;
|
||||||
|
|
||||||
match op {
|
match op {
|
||||||
NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_ADD_WITH_OVERFLOW),
|
NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_ADD_WITH_OVERFLOW),
|
||||||
NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_SUB_WITH_OVERFLOW),
|
NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_SUB_WITH_OVERFLOW),
|
||||||
NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_MUL_WITH_OVERFLOW),
|
NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_MUL_WITH_OVERFLOW),
|
||||||
NumAdd => build_dec_binop_throw_on_overflow(
|
NumAdd => build_dec_binop_throw_on_overflow(
|
||||||
env,
|
env,
|
||||||
parent,
|
parent,
|
||||||
|
@ -5715,7 +5715,7 @@ fn build_dec_binop<'a, 'ctx, 'env>(
|
||||||
rhs,
|
rhs,
|
||||||
"decimal multiplication overflowed",
|
"decimal multiplication overflowed",
|
||||||
),
|
),
|
||||||
NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_DIV),
|
NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_DIV),
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("Unrecognized int binary operation: {:?}", op);
|
unreachable!("Unrecognized int binary operation: {:?}", op);
|
||||||
}
|
}
|
||||||
|
@ -5938,10 +5938,10 @@ fn build_float_unary_op<'a, 'ctx, 'env>(
|
||||||
env.context.i64_type(),
|
env.context.i64_type(),
|
||||||
"num_floor",
|
"num_floor",
|
||||||
),
|
),
|
||||||
NumIsFinite => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_IS_FINITE),
|
NumIsFinite => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_IS_FINITE),
|
||||||
NumAtan => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ATAN),
|
NumAtan => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ATAN),
|
||||||
NumAcos => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ACOS),
|
NumAcos => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ACOS),
|
||||||
NumAsin => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ASIN),
|
NumAsin => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ASIN),
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("Unrecognized int unary operation: {:?}", op);
|
unreachable!("Unrecognized int unary operation: {:?}", op);
|
||||||
}
|
}
|
||||||
|
@ -6107,7 +6107,7 @@ fn cxa_allocate_exception<'a, 'ctx, 'env>(
|
||||||
let context = env.context;
|
let context = env.context;
|
||||||
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
|
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
|
||||||
|
|
||||||
let function = match module.get_function(&name) {
|
let function = match module.get_function(name) {
|
||||||
Some(gvalue) => gvalue,
|
Some(gvalue) => gvalue,
|
||||||
None => {
|
None => {
|
||||||
// void *__cxa_allocate_exception(size_t thrown_size);
|
// void *__cxa_allocate_exception(size_t thrown_size);
|
||||||
|
@ -6141,7 +6141,7 @@ fn cxa_throw_exception<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>, info: BasicVal
|
||||||
|
|
||||||
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
|
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
|
||||||
|
|
||||||
let function = match module.get_function(&name) {
|
let function = match module.get_function(name) {
|
||||||
Some(value) => value,
|
Some(value) => value,
|
||||||
None => {
|
None => {
|
||||||
// void __cxa_throw (void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) );
|
// void __cxa_throw (void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) );
|
||||||
|
@ -6207,7 +6207,7 @@ fn get_gxx_personality_v0<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> Function
|
||||||
let module = env.module;
|
let module = env.module;
|
||||||
let context = env.context;
|
let context = env.context;
|
||||||
|
|
||||||
match module.get_function(&name) {
|
match module.get_function(name) {
|
||||||
Some(gvalue) => gvalue,
|
Some(gvalue) => gvalue,
|
||||||
None => {
|
None => {
|
||||||
let personality_func = add_func(
|
let personality_func = add_func(
|
||||||
|
@ -6229,7 +6229,7 @@ fn cxa_end_catch(env: &Env<'_, '_, '_>) {
|
||||||
let module = env.module;
|
let module = env.module;
|
||||||
let context = env.context;
|
let context = env.context;
|
||||||
|
|
||||||
let function = match module.get_function(&name) {
|
let function = match module.get_function(name) {
|
||||||
Some(gvalue) => gvalue,
|
Some(gvalue) => gvalue,
|
||||||
None => {
|
None => {
|
||||||
let cxa_end_catch = add_func(
|
let cxa_end_catch = add_func(
|
||||||
|
@ -6257,7 +6257,7 @@ fn cxa_begin_catch<'a, 'ctx, 'env>(
|
||||||
let module = env.module;
|
let module = env.module;
|
||||||
let context = env.context;
|
let context = env.context;
|
||||||
|
|
||||||
let function = match module.get_function(&name) {
|
let function = match module.get_function(name) {
|
||||||
Some(gvalue) => gvalue,
|
Some(gvalue) => gvalue,
|
||||||
None => {
|
None => {
|
||||||
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
|
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub fn dict_len<'a, 'ctx, 'env>(
|
||||||
.build_alloca(dict_as_zig_dict.get_type(), "dict_ptr");
|
.build_alloca(dict_as_zig_dict.get_type(), "dict_ptr");
|
||||||
env.builder.build_store(dict_ptr, dict_as_zig_dict);
|
env.builder.build_store(dict_ptr, dict_as_zig_dict);
|
||||||
|
|
||||||
call_bitcode_fn(env, &[dict_ptr.into()], &bitcode::DICT_LEN)
|
call_bitcode_fn(env, &[dict_ptr.into()], bitcode::DICT_LEN)
|
||||||
}
|
}
|
||||||
Layout::Builtin(Builtin::EmptyDict) => ctx.i64_type().const_zero().into(),
|
Layout::Builtin(Builtin::EmptyDict) => ctx.i64_type().const_zero().into(),
|
||||||
_ => unreachable!("Invalid layout given to Dict.len : {:?}", dict_layout),
|
_ => unreachable!("Invalid layout given to Dict.len : {:?}", dict_layout),
|
||||||
|
@ -78,7 +78,7 @@ pub fn dict_empty<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> BasicValueEnum<'
|
||||||
// we must give a pointer for the bitcode function to write the result into
|
// we must give a pointer for the bitcode function to write the result into
|
||||||
let result_alloc = env.builder.build_alloca(roc_dict_type, "dict_empty");
|
let result_alloc = env.builder.build_alloca(roc_dict_type, "dict_empty");
|
||||||
|
|
||||||
call_void_bitcode_fn(env, &[result_alloc.into()], &bitcode::DICT_EMPTY);
|
call_void_bitcode_fn(env, &[result_alloc.into()], bitcode::DICT_EMPTY);
|
||||||
|
|
||||||
env.builder.build_load(result_alloc, "load_result")
|
env.builder.build_load(result_alloc, "load_result")
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ pub fn dict_insert<'a, 'ctx, 'env>(
|
||||||
dec_value_fn.as_global_value().as_pointer_value().into(),
|
dec_value_fn.as_global_value().as_pointer_value().into(),
|
||||||
result_ptr.into(),
|
result_ptr.into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_INSERT,
|
bitcode::DICT_INSERT,
|
||||||
);
|
);
|
||||||
|
|
||||||
env.builder.build_load(result_ptr, "load_result")
|
env.builder.build_load(result_ptr, "load_result")
|
||||||
|
@ -199,7 +199,7 @@ pub fn dict_remove<'a, 'ctx, 'env>(
|
||||||
dec_value_fn.as_global_value().as_pointer_value().into(),
|
dec_value_fn.as_global_value().as_pointer_value().into(),
|
||||||
result_ptr.into(),
|
result_ptr.into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_REMOVE,
|
bitcode::DICT_REMOVE,
|
||||||
);
|
);
|
||||||
|
|
||||||
env.builder.build_load(result_ptr, "load_result")
|
env.builder.build_load(result_ptr, "load_result")
|
||||||
|
@ -250,7 +250,7 @@ pub fn dict_contains<'a, 'ctx, 'env>(
|
||||||
hash_fn.as_global_value().as_pointer_value().into(),
|
hash_fn.as_global_value().as_pointer_value().into(),
|
||||||
eq_fn.as_global_value().as_pointer_value().into(),
|
eq_fn.as_global_value().as_pointer_value().into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_CONTAINS,
|
bitcode::DICT_CONTAINS,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ pub fn dict_get<'a, 'ctx, 'env>(
|
||||||
eq_fn.as_global_value().as_pointer_value().into(),
|
eq_fn.as_global_value().as_pointer_value().into(),
|
||||||
inc_value_fn.as_global_value().as_pointer_value().into(),
|
inc_value_fn.as_global_value().as_pointer_value().into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_GET,
|
bitcode::DICT_GET,
|
||||||
)
|
)
|
||||||
.into_struct_value();
|
.into_struct_value();
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ pub fn dict_elements_rc<'a, 'ctx, 'env>(
|
||||||
key_fn.as_global_value().as_pointer_value().into(),
|
key_fn.as_global_value().as_pointer_value().into(),
|
||||||
value_fn.as_global_value().as_pointer_value().into(),
|
value_fn.as_global_value().as_pointer_value().into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_ELEMENTS_RC,
|
bitcode::DICT_ELEMENTS_RC,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ pub fn dict_keys<'a, 'ctx, 'env>(
|
||||||
inc_key_fn.as_global_value().as_pointer_value().into(),
|
inc_key_fn.as_global_value().as_pointer_value().into(),
|
||||||
list_ptr.into(),
|
list_ptr.into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_KEYS,
|
bitcode::DICT_KEYS,
|
||||||
);
|
);
|
||||||
|
|
||||||
let list_ptr = env
|
let list_ptr = env
|
||||||
|
@ -527,7 +527,7 @@ pub fn dict_union<'a, 'ctx, 'env>(
|
||||||
inc_value_fn.as_global_value().as_pointer_value().into(),
|
inc_value_fn.as_global_value().as_pointer_value().into(),
|
||||||
output_ptr.into(),
|
output_ptr.into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_UNION,
|
bitcode::DICT_UNION,
|
||||||
);
|
);
|
||||||
|
|
||||||
env.builder.build_load(output_ptr, "load_output_ptr")
|
env.builder.build_load(output_ptr, "load_output_ptr")
|
||||||
|
@ -549,7 +549,7 @@ pub fn dict_difference<'a, 'ctx, 'env>(
|
||||||
dict2,
|
dict2,
|
||||||
key_layout,
|
key_layout,
|
||||||
value_layout,
|
value_layout,
|
||||||
&bitcode::DICT_DIFFERENCE,
|
bitcode::DICT_DIFFERENCE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ pub fn dict_intersection<'a, 'ctx, 'env>(
|
||||||
dict2,
|
dict2,
|
||||||
key_layout,
|
key_layout,
|
||||||
value_layout,
|
value_layout,
|
||||||
&bitcode::DICT_INTERSECTION,
|
bitcode::DICT_INTERSECTION,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ pub fn dict_walk<'a, 'ctx, 'env>(
|
||||||
layout_width(env, accum_layout),
|
layout_width(env, accum_layout),
|
||||||
env.builder.build_bitcast(output_ptr, u8_ptr, "to_opaque"),
|
env.builder.build_bitcast(output_ptr, u8_ptr, "to_opaque"),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_WALK,
|
bitcode::DICT_WALK,
|
||||||
);
|
);
|
||||||
|
|
||||||
env.builder.build_load(output_ptr, "load_output_ptr")
|
env.builder.build_load(output_ptr, "load_output_ptr")
|
||||||
|
@ -721,7 +721,7 @@ pub fn dict_values<'a, 'ctx, 'env>(
|
||||||
inc_value_fn.as_global_value().as_pointer_value().into(),
|
inc_value_fn.as_global_value().as_pointer_value().into(),
|
||||||
list_ptr.into(),
|
list_ptr.into(),
|
||||||
],
|
],
|
||||||
&bitcode::DICT_VALUES,
|
bitcode::DICT_VALUES,
|
||||||
);
|
);
|
||||||
|
|
||||||
let list_ptr = env
|
let list_ptr = env
|
||||||
|
@ -784,7 +784,7 @@ pub fn set_from_list<'a, 'ctx, 'env>(
|
||||||
dec_key_fn.as_global_value().as_pointer_value().into(),
|
dec_key_fn.as_global_value().as_pointer_value().into(),
|
||||||
result_alloca.into(),
|
result_alloca.into(),
|
||||||
],
|
],
|
||||||
&bitcode::SET_FROM_LIST,
|
bitcode::SET_FROM_LIST,
|
||||||
);
|
);
|
||||||
|
|
||||||
env.builder.build_load(result_alloca, "load_result")
|
env.builder.build_load(result_alloca, "load_result")
|
||||||
|
@ -800,7 +800,7 @@ fn build_hash_wrapper<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::GENERIC_HASH_REF;
|
let symbol = Symbol::GENERIC_HASH_REF;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &layout)
|
.get(symbol, layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let function_value = match env.module.get_function(fn_name.as_str()) {
|
let function_value = match env.module.get_function(fn_name.as_str()) {
|
||||||
|
@ -867,8 +867,7 @@ fn dict_symbol_to_zig_dict<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let zig_dict_type = env.module.get_struct_type("dict.RocDict").unwrap();
|
let zig_dict_type = env.module.get_struct_type("dict.RocDict").unwrap();
|
||||||
|
|
||||||
complex_bitcast(&env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict")
|
complex_bitcast(env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict").into_struct_value()
|
||||||
.into_struct_value()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn zig_dict_type<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> inkwell::types::StructType<'ctx> {
|
fn zig_dict_type<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> inkwell::types::StructType<'ctx> {
|
||||||
|
|
|
@ -130,7 +130,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
|
||||||
| Builtin::Float16
|
| Builtin::Float16
|
||||||
| Builtin::Decimal
|
| Builtin::Decimal
|
||||||
| Builtin::Usize => {
|
| Builtin::Usize => {
|
||||||
let hash_bytes = store_and_use_as_u8_ptr(env, val, &layout);
|
let hash_bytes = store_and_use_as_u8_ptr(env, val, layout);
|
||||||
hash_bitcode_fn(env, seed, hash_bytes, layout.stack_size(ptr_bytes))
|
hash_bitcode_fn(env, seed, hash_bytes, layout.stack_size(ptr_bytes))
|
||||||
}
|
}
|
||||||
Builtin::Str => {
|
Builtin::Str => {
|
||||||
|
@ -138,7 +138,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[seed.into(), build_str::str_to_i128(env, val).into()],
|
&[seed.into(), build_str::str_to_i128(env, val).into()],
|
||||||
&bitcode::DICT_HASH_STR,
|
bitcode::DICT_HASH_STR,
|
||||||
)
|
)
|
||||||
.into_int_value()
|
.into_int_value()
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ fn build_hash_tag<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::GENERIC_HASH;
|
let symbol = Symbol::GENERIC_HASH;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &layout)
|
.get(symbol, layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
|
@ -335,7 +335,7 @@ fn build_hash_tag<'a, 'ctx, 'env>(
|
||||||
None => {
|
None => {
|
||||||
let seed_type = env.context.i64_type();
|
let seed_type = env.context.i64_type();
|
||||||
|
|
||||||
let arg_type = basic_type_from_layout(env, &layout);
|
let arg_type = basic_type_from_layout(env, layout);
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -659,7 +659,7 @@ fn build_hash_list<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::GENERIC_HASH;
|
let symbol = Symbol::GENERIC_HASH;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &layout)
|
.get(symbol, layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
|
@ -667,7 +667,7 @@ fn build_hash_list<'a, 'ctx, 'env>(
|
||||||
None => {
|
None => {
|
||||||
let seed_type = env.context.i64_type();
|
let seed_type = env.context.i64_type();
|
||||||
|
|
||||||
let arg_type = basic_type_from_layout(env, &layout);
|
let arg_type = basic_type_from_layout(env, layout);
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -870,7 +870,7 @@ fn store_and_use_as_u8_ptr<'a, 'ctx, 'env>(
|
||||||
value: BasicValueEnum<'ctx>,
|
value: BasicValueEnum<'ctx>,
|
||||||
layout: &Layout<'a>,
|
layout: &Layout<'a>,
|
||||||
) -> PointerValue<'ctx> {
|
) -> PointerValue<'ctx> {
|
||||||
let basic_type = basic_type_from_layout(env, &layout);
|
let basic_type = basic_type_from_layout(env, layout);
|
||||||
let alloc = env.builder.build_alloca(basic_type, "store");
|
let alloc = env.builder.build_alloca(basic_type, "store");
|
||||||
env.builder.build_store(alloc, value);
|
env.builder.build_store(alloc, value);
|
||||||
|
|
||||||
|
@ -895,7 +895,7 @@ fn hash_bitcode_fn<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[seed.into(), buffer.into(), num_bytes.into()],
|
&[seed.into(), buffer.into(), num_bytes.into()],
|
||||||
&bitcode::DICT_HASH,
|
bitcode::DICT_HASH,
|
||||||
)
|
)
|
||||||
.into_int_value()
|
.into_int_value()
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ pub fn list_single<'a, 'ctx, 'env>(
|
||||||
pass_element_as_opaque(env, element),
|
pass_element_as_opaque(env, element),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_SINGLE,
|
bitcode::LIST_SINGLE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ pub fn list_join<'a, 'ctx, 'env>(
|
||||||
env.alignment_intvalue(element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_JOIN,
|
bitcode::LIST_JOIN,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -239,7 +239,7 @@ pub fn list_reverse<'a, 'ctx, 'env>(
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(&element_layout),
|
||||||
layout_width(env, &element_layout),
|
layout_width(env, &element_layout),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_REVERSE,
|
bitcode::LIST_REVERSE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,11 +291,11 @@ pub fn list_append<'a, 'ctx, 'env>(
|
||||||
env,
|
env,
|
||||||
&[
|
&[
|
||||||
pass_list_as_i128(env, original_wrapper.into()),
|
pass_list_as_i128(env, original_wrapper.into()),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
pass_element_as_opaque(env, element),
|
pass_element_as_opaque(env, element),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_APPEND,
|
bitcode::LIST_APPEND,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,12 +311,12 @@ pub fn list_swap<'a, 'ctx, 'env>(
|
||||||
env,
|
env,
|
||||||
&[
|
&[
|
||||||
pass_list_as_i128(env, original_wrapper.into()),
|
pass_list_as_i128(env, original_wrapper.into()),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, &element_layout),
|
layout_width(env, element_layout),
|
||||||
index_1.into(),
|
index_1.into(),
|
||||||
index_2.into(),
|
index_2.into(),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_SWAP,
|
bitcode::LIST_SWAP,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,17 +328,17 @@ pub fn list_drop<'a, 'ctx, 'env>(
|
||||||
count: IntValue<'ctx>,
|
count: IntValue<'ctx>,
|
||||||
element_layout: &Layout<'a>,
|
element_layout: &Layout<'a>,
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
let dec_element_fn = build_dec_wrapper(env, layout_ids, &element_layout);
|
let dec_element_fn = build_dec_wrapper(env, layout_ids, element_layout);
|
||||||
call_bitcode_fn_returns_list(
|
call_bitcode_fn_returns_list(
|
||||||
env,
|
env,
|
||||||
&[
|
&[
|
||||||
pass_list_as_i128(env, original_wrapper.into()),
|
pass_list_as_i128(env, original_wrapper.into()),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, &element_layout),
|
layout_width(env, element_layout),
|
||||||
count.into(),
|
count.into(),
|
||||||
dec_element_fn.as_global_value().as_pointer_value().into(),
|
dec_element_fn.as_global_value().as_pointer_value().into(),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_DROP,
|
bitcode::LIST_DROP,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ pub fn list_set<'a, 'ctx, 'env>(
|
||||||
&[
|
&[
|
||||||
bytes.into(),
|
bytes.into(),
|
||||||
length.into(),
|
length.into(),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
index.into(),
|
index.into(),
|
||||||
pass_element_as_opaque(env, element),
|
pass_element_as_opaque(env, element),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
|
@ -456,7 +456,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>(
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
pass_as_opaque(env, default_ptr),
|
pass_as_opaque(env, default_ptr),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
layout_width(env, default_layout),
|
layout_width(env, default_layout),
|
||||||
pass_as_opaque(env, result_ptr),
|
pass_as_opaque(env, result_ptr),
|
||||||
|
@ -487,7 +487,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>(
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
pass_as_opaque(env, default_ptr),
|
pass_as_opaque(env, default_ptr),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
layout_width(env, function_call_return_layout),
|
layout_width(env, function_call_return_layout),
|
||||||
layout_width(env, default_layout),
|
layout_width(env, default_layout),
|
||||||
|
@ -563,7 +563,7 @@ pub fn list_range<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, low_ptr),
|
pass_as_opaque(env, low_ptr),
|
||||||
pass_as_opaque(env, high_ptr),
|
pass_as_opaque(env, high_ptr),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_RANGE,
|
bitcode::LIST_RANGE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,12 +611,12 @@ pub fn list_keep_if<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, roc_function_call.data),
|
pass_as_opaque(env, roc_function_call.data),
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
inc_element_fn.as_global_value().as_pointer_value().into(),
|
inc_element_fn.as_global_value().as_pointer_value().into(),
|
||||||
dec_element_fn.as_global_value().as_pointer_value().into(),
|
dec_element_fn.as_global_value().as_pointer_value().into(),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_KEEP_IF,
|
bitcode::LIST_KEEP_IF,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +653,7 @@ pub fn list_keep_oks<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, roc_function_call.data),
|
pass_as_opaque(env, roc_function_call.data),
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
env.alignment_intvalue(&before_layout),
|
env.alignment_intvalue(before_layout),
|
||||||
layout_width(env, before_layout),
|
layout_width(env, before_layout),
|
||||||
layout_width(env, result_layout),
|
layout_width(env, result_layout),
|
||||||
layout_width(env, after_layout),
|
layout_width(env, after_layout),
|
||||||
|
@ -697,7 +697,7 @@ pub fn list_keep_errs<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, roc_function_call.data),
|
pass_as_opaque(env, roc_function_call.data),
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
env.alignment_intvalue(&before_layout),
|
env.alignment_intvalue(before_layout),
|
||||||
layout_width(env, before_layout),
|
layout_width(env, before_layout),
|
||||||
layout_width(env, result_layout),
|
layout_width(env, result_layout),
|
||||||
layout_width(env, after_layout),
|
layout_width(env, after_layout),
|
||||||
|
@ -724,7 +724,7 @@ pub fn list_sort_with<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, roc_function_call.data),
|
pass_as_opaque(env, roc_function_call.data),
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
],
|
],
|
||||||
bitcode::LIST_SORT_WITH,
|
bitcode::LIST_SORT_WITH,
|
||||||
|
@ -747,7 +747,7 @@ pub fn list_map_with_index<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, roc_function_call.data),
|
pass_as_opaque(env, roc_function_call.data),
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
layout_width(env, return_layout),
|
layout_width(env, return_layout),
|
||||||
],
|
],
|
||||||
|
@ -771,7 +771,7 @@ pub fn list_map<'a, 'ctx, 'env>(
|
||||||
pass_as_opaque(env, roc_function_call.data),
|
pass_as_opaque(env, roc_function_call.data),
|
||||||
roc_function_call.inc_n_data.into(),
|
roc_function_call.inc_n_data.into(),
|
||||||
roc_function_call.data_is_owned.into(),
|
roc_function_call.data_is_owned.into(),
|
||||||
env.alignment_intvalue(&element_layout),
|
env.alignment_intvalue(element_layout),
|
||||||
layout_width(env, element_layout),
|
layout_width(env, element_layout),
|
||||||
layout_width(env, return_layout),
|
layout_width(env, return_layout),
|
||||||
],
|
],
|
||||||
|
@ -873,7 +873,7 @@ pub fn list_concat<'a, 'ctx, 'env>(
|
||||||
env.alignment_intvalue(elem_layout),
|
env.alignment_intvalue(elem_layout),
|
||||||
layout_width(env, elem_layout),
|
layout_width(env, elem_layout),
|
||||||
],
|
],
|
||||||
&bitcode::LIST_CONCAT,
|
bitcode::LIST_CONCAT,
|
||||||
),
|
),
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!("Invalid List layout for List.concat {:?}", list_layout);
|
unreachable!("Invalid List layout for List.concat {:?}", list_layout);
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn str_split<'a, 'ctx, 'env>(
|
||||||
let segment_count = call_bitcode_fn(
|
let segment_count = call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str_i128.into(), delim_i128.into()],
|
&[str_i128.into(), delim_i128.into()],
|
||||||
&bitcode::STR_COUNT_SEGMENTS,
|
bitcode::STR_COUNT_SEGMENTS,
|
||||||
)
|
)
|
||||||
.into_int_value();
|
.into_int_value();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ pub fn str_split<'a, 'ctx, 'env>(
|
||||||
call_void_bitcode_fn(
|
call_void_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[ret_list_ptr_zig_rocstr, str_i128.into(), delim_i128.into()],
|
&[ret_list_ptr_zig_rocstr, str_i128.into(), delim_i128.into()],
|
||||||
&bitcode::STR_STR_SPLIT_IN_PLACE,
|
bitcode::STR_STR_SPLIT_IN_PLACE,
|
||||||
);
|
);
|
||||||
|
|
||||||
store_list(env, ret_list_ptr, segment_count)
|
store_list(env, ret_list_ptr, segment_count)
|
||||||
|
@ -62,7 +62,7 @@ fn str_symbol_to_i128<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let i128_type = env.context.i128_type().into();
|
let i128_type = env.context.i128_type().into();
|
||||||
|
|
||||||
complex_bitcast(&env.builder, string, i128_type, "str_to_i128").into_int_value()
|
complex_bitcast(env.builder, string, i128_type, "str_to_i128").into_int_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn str_to_i128<'a, 'ctx, 'env>(
|
pub fn str_to_i128<'a, 'ctx, 'env>(
|
||||||
|
@ -119,7 +119,7 @@ pub fn str_concat<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str1_i128.into(), str2_i128.into()],
|
&[str1_i128.into(), str2_i128.into()],
|
||||||
&bitcode::STR_CONCAT,
|
bitcode::STR_CONCAT,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ pub fn str_join_with<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[list_i128.into(), str_i128.into()],
|
&[list_i128.into(), str_i128.into()],
|
||||||
&bitcode::STR_JOIN_WITH,
|
bitcode::STR_JOIN_WITH,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ pub fn str_number_of_bytes<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
// the builtin will always return an u64
|
// the builtin will always return an u64
|
||||||
let length =
|
let length =
|
||||||
call_bitcode_fn(env, &[str_i128.into()], &bitcode::STR_NUMBER_OF_BYTES).into_int_value();
|
call_bitcode_fn(env, &[str_i128.into()], bitcode::STR_NUMBER_OF_BYTES).into_int_value();
|
||||||
|
|
||||||
// cast to the appropriate usize of the current build
|
// cast to the appropriate usize of the current build
|
||||||
env.builder
|
env.builder
|
||||||
|
@ -171,7 +171,7 @@ pub fn str_starts_with<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str_i128.into(), prefix_i128.into()],
|
&[str_i128.into(), prefix_i128.into()],
|
||||||
&bitcode::STR_STARTS_WITH,
|
bitcode::STR_STARTS_WITH,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ pub fn str_starts_with_code_point<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str_i128.into(), prefix],
|
&[str_i128.into(), prefix],
|
||||||
&bitcode::STR_STARTS_WITH_CODE_POINT,
|
bitcode::STR_STARTS_WITH_CODE_POINT,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ pub fn str_ends_with<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str_i128.into(), prefix_i128.into()],
|
&[str_i128.into(), prefix_i128.into()],
|
||||||
&bitcode::STR_ENDS_WITH,
|
bitcode::STR_ENDS_WITH,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ pub fn str_count_graphemes<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str_i128.into()],
|
&[str_i128.into()],
|
||||||
&bitcode::STR_COUNT_GRAPEHEME_CLUSTERS,
|
bitcode::STR_COUNT_GRAPEHEME_CLUSTERS,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ pub fn str_from_int<'a, 'ctx, 'env>(
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
let int = load_symbol(scope, &int_symbol);
|
let int = load_symbol(scope, &int_symbol);
|
||||||
|
|
||||||
call_bitcode_fn(env, &[int], &bitcode::STR_FROM_INT)
|
call_bitcode_fn(env, &[int], bitcode::STR_FROM_INT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Str.toBytes : Str -> List U8
|
/// Str.toBytes : Str -> List U8
|
||||||
|
@ -247,7 +247,7 @@ pub fn str_to_bytes<'a, 'ctx, 'env>(
|
||||||
"to_bytes",
|
"to_bytes",
|
||||||
);
|
);
|
||||||
|
|
||||||
call_bitcode_fn_returns_list(env, &[string], &bitcode::STR_TO_BYTES)
|
call_bitcode_fn_returns_list(env, &[string], bitcode::STR_TO_BYTES)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Str.fromUtf8 : List U8 -> { a : Bool, b : Str, c : Nat, d : I8 }
|
/// Str.fromUtf8 : List U8 -> { a : Bool, b : Str, c : Nat, d : I8 }
|
||||||
|
@ -273,7 +273,7 @@ pub fn str_from_utf8<'a, 'ctx, 'env>(
|
||||||
),
|
),
|
||||||
result_ptr.into(),
|
result_ptr.into(),
|
||||||
],
|
],
|
||||||
&bitcode::STR_FROM_UTF8,
|
bitcode::STR_FROM_UTF8,
|
||||||
);
|
);
|
||||||
|
|
||||||
let record_type = env.context.struct_type(
|
let record_type = env.context.struct_type(
|
||||||
|
@ -306,7 +306,7 @@ pub fn str_from_float<'a, 'ctx, 'env>(
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
let float = load_symbol(scope, &int_symbol);
|
let float = load_symbol(scope, &int_symbol);
|
||||||
|
|
||||||
call_bitcode_fn(env, &[float], &bitcode::STR_FROM_FLOAT)
|
call_bitcode_fn(env, &[float], bitcode::STR_FROM_FLOAT)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Str.equal : Str, Str -> Bool
|
/// Str.equal : Str, Str -> Bool
|
||||||
|
@ -321,7 +321,7 @@ pub fn str_equal<'a, 'ctx, 'env>(
|
||||||
call_bitcode_fn(
|
call_bitcode_fn(
|
||||||
env,
|
env,
|
||||||
&[str1_i128.into(), str2_i128.into()],
|
&[str1_i128.into(), str2_i128.into()],
|
||||||
&bitcode::STR_EQUAL,
|
bitcode::STR_EQUAL,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
Builtin::Usize => int_cmp(IntPredicate::EQ, "eq_usize"),
|
Builtin::Usize => int_cmp(IntPredicate::EQ, "eq_usize"),
|
||||||
|
|
||||||
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_EQ),
|
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_EQ),
|
||||||
Builtin::Float128 => float_cmp(FloatPredicate::OEQ, "eq_f128"),
|
Builtin::Float128 => float_cmp(FloatPredicate::OEQ, "eq_f128"),
|
||||||
Builtin::Float64 => float_cmp(FloatPredicate::OEQ, "eq_f64"),
|
Builtin::Float64 => float_cmp(FloatPredicate::OEQ, "eq_f64"),
|
||||||
Builtin::Float32 => float_cmp(FloatPredicate::OEQ, "eq_f32"),
|
Builtin::Float32 => float_cmp(FloatPredicate::OEQ, "eq_f32"),
|
||||||
|
@ -245,7 +245,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
Builtin::Usize => int_cmp(IntPredicate::NE, "neq_usize"),
|
Builtin::Usize => int_cmp(IntPredicate::NE, "neq_usize"),
|
||||||
|
|
||||||
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_NEQ),
|
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_NEQ),
|
||||||
Builtin::Float128 => float_cmp(FloatPredicate::ONE, "neq_f128"),
|
Builtin::Float128 => float_cmp(FloatPredicate::ONE, "neq_f128"),
|
||||||
Builtin::Float64 => float_cmp(FloatPredicate::ONE, "neq_f64"),
|
Builtin::Float64 => float_cmp(FloatPredicate::ONE, "neq_f64"),
|
||||||
Builtin::Float32 => float_cmp(FloatPredicate::ONE, "neq_f32"),
|
Builtin::Float32 => float_cmp(FloatPredicate::ONE, "neq_f32"),
|
||||||
|
@ -361,13 +361,13 @@ fn build_list_eq<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::LIST_EQ;
|
let symbol = Symbol::LIST_EQ;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &element_layout)
|
.get(symbol, element_layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let arg_type = basic_type_from_layout(env, &list_layout);
|
let arg_type = basic_type_from_layout(env, list_layout);
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -428,7 +428,7 @@ fn build_list_eq_help<'a, 'ctx, 'env>(
|
||||||
/* current_scope */ lexical_block.as_debug_info_scope(),
|
/* current_scope */ lexical_block.as_debug_info_scope(),
|
||||||
/* inlined_at */ None,
|
/* inlined_at */ None,
|
||||||
);
|
);
|
||||||
builder.set_current_debug_location(&ctx, loc);
|
builder.set_current_debug_location(ctx, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add args to scope
|
// Add args to scope
|
||||||
|
@ -636,7 +636,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
|
||||||
/* current_scope */ lexical_block.as_debug_info_scope(),
|
/* current_scope */ lexical_block.as_debug_info_scope(),
|
||||||
/* inlined_at */ None,
|
/* inlined_at */ None,
|
||||||
);
|
);
|
||||||
builder.set_current_debug_location(&ctx, loc);
|
builder.set_current_debug_location(ctx, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add args to scope
|
// Add args to scope
|
||||||
|
@ -752,13 +752,13 @@ fn build_tag_eq<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
let symbol = Symbol::GENERIC_EQ;
|
let symbol = Symbol::GENERIC_EQ;
|
||||||
let fn_name = layout_ids
|
let fn_name = layout_ids
|
||||||
.get(symbol, &tag_layout)
|
.get(symbol, tag_layout)
|
||||||
.to_symbol_string(symbol, &env.interns);
|
.to_symbol_string(symbol, &env.interns);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let arg_type = basic_type_from_layout(env, &tag_layout);
|
let arg_type = basic_type_from_layout(env, tag_layout);
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -817,7 +817,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
||||||
/* current_scope */ lexical_block.as_debug_info_scope(),
|
/* current_scope */ lexical_block.as_debug_info_scope(),
|
||||||
/* inlined_at */ None,
|
/* inlined_at */ None,
|
||||||
);
|
);
|
||||||
builder.set_current_debug_location(&ctx, loc);
|
builder.set_current_debug_location(ctx, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add args to scope
|
// Add args to scope
|
||||||
|
|
|
@ -58,8 +58,7 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NullableUnwrapped { other_fields, .. } => {
|
NullableUnwrapped { other_fields, .. } => {
|
||||||
let block =
|
let block = block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes);
|
||||||
block_of_memory_slices(env.context, &[&other_fields], env.ptr_bytes);
|
|
||||||
block.ptr_type(AddressSpace::Generic).into()
|
block.ptr_type(AddressSpace::Generic).into()
|
||||||
}
|
}
|
||||||
NonNullableUnwrapped(fields) => {
|
NonNullableUnwrapped(fields) => {
|
||||||
|
|
|
@ -720,14 +720,14 @@ fn modify_refcount_list<'a, 'ctx, 'env>(
|
||||||
&env.interns,
|
&env.interns,
|
||||||
"increment_list",
|
"increment_list",
|
||||||
"decrement_list",
|
"decrement_list",
|
||||||
&layout,
|
layout,
|
||||||
mode,
|
mode,
|
||||||
);
|
);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let basic_type = basic_type_from_layout(env, &layout);
|
let basic_type = basic_type_from_layout(env, layout);
|
||||||
let function_value = build_header(env, basic_type, mode, &fn_name);
|
let function_value = build_header(env, basic_type, mode, &fn_name);
|
||||||
|
|
||||||
modify_refcount_list_help(
|
modify_refcount_list_help(
|
||||||
|
@ -857,14 +857,14 @@ fn modify_refcount_str<'a, 'ctx, 'env>(
|
||||||
&env.interns,
|
&env.interns,
|
||||||
"increment_str",
|
"increment_str",
|
||||||
"decrement_str",
|
"decrement_str",
|
||||||
&layout,
|
layout,
|
||||||
mode,
|
mode,
|
||||||
);
|
);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let basic_type = basic_type_from_layout(env, &layout);
|
let basic_type = basic_type_from_layout(env, layout);
|
||||||
let function_value = build_header(env, basic_type, mode, &fn_name);
|
let function_value = build_header(env, basic_type, mode, &fn_name);
|
||||||
|
|
||||||
modify_refcount_str_help(env, mode, layout, function_value);
|
modify_refcount_str_help(env, mode, layout, function_value);
|
||||||
|
@ -956,14 +956,14 @@ fn modify_refcount_dict<'a, 'ctx, 'env>(
|
||||||
&env.interns,
|
&env.interns,
|
||||||
"increment_dict",
|
"increment_dict",
|
||||||
"decrement_dict",
|
"decrement_dict",
|
||||||
&layout,
|
layout,
|
||||||
mode,
|
mode,
|
||||||
);
|
);
|
||||||
|
|
||||||
let function = match env.module.get_function(fn_name.as_str()) {
|
let function = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let basic_type = basic_type_from_layout(env, &layout);
|
let basic_type = basic_type_from_layout(env, layout);
|
||||||
let function_value = build_header(env, basic_type, mode, &fn_name);
|
let function_value = build_header(env, basic_type, mode, &fn_name);
|
||||||
|
|
||||||
modify_refcount_dict_help(
|
modify_refcount_dict_help(
|
||||||
|
@ -1118,7 +1118,7 @@ pub fn build_header_help<'a, 'ctx, 'env>(
|
||||||
FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention.
|
FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention.
|
||||||
);
|
);
|
||||||
|
|
||||||
let subprogram = env.new_subprogram(&fn_name);
|
let subprogram = env.new_subprogram(fn_name);
|
||||||
fn_val.set_subprogram(subprogram);
|
fn_val.set_subprogram(subprogram);
|
||||||
|
|
||||||
env.dibuilder.finalize();
|
env.dibuilder.finalize();
|
||||||
|
|
|
@ -148,7 +148,7 @@ fn generate_entry_doc<'a>(
|
||||||
|
|
||||||
match def {
|
match def {
|
||||||
Def::SpaceBefore(sub_def, comments_or_new_lines) => {
|
Def::SpaceBefore(sub_def, comments_or_new_lines) => {
|
||||||
// Comments before a definition are attached to the current defition
|
// Comments before a definition are attached to the current definition
|
||||||
|
|
||||||
for detached_doc in detached_docs_from_comments_and_new_lines(comments_or_new_lines) {
|
for detached_doc in detached_docs_from_comments_and_new_lines(comments_or_new_lines) {
|
||||||
acc.push(DetachedDoc(detached_doc));
|
acc.push(DetachedDoc(detached_doc));
|
||||||
|
|
|
@ -225,7 +225,7 @@ impl<'a> Dependencies<'a> {
|
||||||
if let Some(to_notify) = self.notifies.get(&key) {
|
if let Some(to_notify) = self.notifies.get(&key) {
|
||||||
for notify_key in to_notify {
|
for notify_key in to_notify {
|
||||||
let mut is_empty = false;
|
let mut is_empty = false;
|
||||||
if let Some(waiting_for_pairs) = self.waiting_for.get_mut(¬ify_key) {
|
if let Some(waiting_for_pairs) = self.waiting_for.get_mut(notify_key) {
|
||||||
waiting_for_pairs.remove(&key);
|
waiting_for_pairs.remove(&key);
|
||||||
is_empty = waiting_for_pairs.is_empty();
|
is_empty = waiting_for_pairs.is_empty();
|
||||||
}
|
}
|
||||||
|
@ -469,7 +469,7 @@ fn start_phase<'a>(
|
||||||
for dep_id in deps_by_name.values() {
|
for dep_id in deps_by_name.values() {
|
||||||
// We already verified that these are all present,
|
// We already verified that these are all present,
|
||||||
// so unwrapping should always succeed here.
|
// so unwrapping should always succeed here.
|
||||||
let idents = ident_ids_by_module.get(&dep_id).unwrap();
|
let idents = ident_ids_by_module.get(dep_id).unwrap();
|
||||||
|
|
||||||
dep_idents.insert(*dep_id, idents.clone());
|
dep_idents.insert(*dep_id, idents.clone());
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ fn start_phase<'a>(
|
||||||
var_store,
|
var_store,
|
||||||
imported_modules,
|
imported_modules,
|
||||||
&mut state.exposed_types,
|
&mut state.exposed_types,
|
||||||
&state.stdlib,
|
state.stdlib,
|
||||||
declarations,
|
declarations,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1635,7 @@ fn start_tasks<'a>(
|
||||||
) -> Result<(), LoadingProblem<'a>> {
|
) -> Result<(), LoadingProblem<'a>> {
|
||||||
for (module_id, phase) in work {
|
for (module_id, phase) in work {
|
||||||
for task in start_phase(module_id, phase, arena, state) {
|
for task in start_phase(module_id, phase, arena, state) {
|
||||||
enqueue_task(&injector, worker_listeners, task)?
|
enqueue_task(injector, worker_listeners, task)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1759,11 +1759,11 @@ fn update<'a>(
|
||||||
|
|
||||||
state.module_cache.headers.insert(header.module_id, header);
|
state.module_cache.headers.insert(header.module_id, header);
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
|
|
||||||
let work = state.dependencies.notify(home, Phase::LoadHeader);
|
let work = state.dependencies.notify(home, Phase::LoadHeader);
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -1796,7 +1796,7 @@ fn update<'a>(
|
||||||
|
|
||||||
let work = state.dependencies.notify(module_id, Phase::Parse);
|
let work = state.dependencies.notify(module_id, Phase::Parse);
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -1831,7 +1831,7 @@ fn update<'a>(
|
||||||
.dependencies
|
.dependencies
|
||||||
.notify(module_id, Phase::CanonicalizeAndConstrain);
|
.notify(module_id, Phase::CanonicalizeAndConstrain);
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -1882,7 +1882,7 @@ fn update<'a>(
|
||||||
.notify(module_id, Phase::CanonicalizeAndConstrain),
|
.notify(module_id, Phase::CanonicalizeAndConstrain),
|
||||||
);
|
);
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -1986,7 +1986,7 @@ fn update<'a>(
|
||||||
state.constrained_ident_ids.insert(module_id, ident_ids);
|
state.constrained_ident_ids.insert(module_id, ident_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
|
@ -2041,7 +2041,7 @@ fn update<'a>(
|
||||||
.dependencies
|
.dependencies
|
||||||
.notify(module_id, Phase::FindSpecializations);
|
.notify(module_id, Phase::FindSpecializations);
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
@ -2143,7 +2143,7 @@ fn update<'a>(
|
||||||
existing.extend(requested);
|
existing.extend(requested);
|
||||||
}
|
}
|
||||||
|
|
||||||
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
|
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
|
@ -2348,7 +2348,7 @@ fn load_pkg_config<'a>(
|
||||||
let parse_start = SystemTime::now();
|
let parse_start = SystemTime::now();
|
||||||
let bytes = arena.alloc(bytes_vec);
|
let bytes = arena.alloc(bytes_vec);
|
||||||
let parse_state = parser::State::new(bytes);
|
let parse_state = parser::State::new(bytes);
|
||||||
let parsed = roc_parse::module::parse_header(&arena, parse_state);
|
let parsed = roc_parse::module::parse_header(arena, parse_state);
|
||||||
let parse_header_duration = parse_start.elapsed().unwrap();
|
let parse_header_duration = parse_start.elapsed().unwrap();
|
||||||
|
|
||||||
// Insert the first entries for this module's timings
|
// Insert the first entries for this module's timings
|
||||||
|
@ -2518,7 +2518,7 @@ fn parse_header<'a>(
|
||||||
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
|
||||||
let parse_start = SystemTime::now();
|
let parse_start = SystemTime::now();
|
||||||
let parse_state = parser::State::new(src_bytes);
|
let parse_state = parser::State::new(src_bytes);
|
||||||
let parsed = roc_parse::module::parse_header(&arena, parse_state);
|
let parsed = roc_parse::module::parse_header(arena, parse_state);
|
||||||
let parse_header_duration = parse_start.elapsed().unwrap();
|
let parse_header_duration = parse_start.elapsed().unwrap();
|
||||||
|
|
||||||
// Insert the first entries for this module's timings
|
// Insert the first entries for this module's timings
|
||||||
|
@ -2667,7 +2667,7 @@ fn parse_header<'a>(
|
||||||
}
|
}
|
||||||
Ok((ast::Module::Platform { header }, _parse_state)) => Ok(fabricate_effects_module(
|
Ok((ast::Module::Platform { header }, _parse_state)) => Ok(fabricate_effects_module(
|
||||||
arena,
|
arena,
|
||||||
&"",
|
"",
|
||||||
module_ids,
|
module_ids,
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
header,
|
header,
|
||||||
|
@ -2825,7 +2825,7 @@ fn send_header<'a>(
|
||||||
|
|
||||||
let name = match opt_shorthand {
|
let name = match opt_shorthand {
|
||||||
Some(shorthand) => {
|
Some(shorthand) => {
|
||||||
PQModuleName::Qualified(&shorthand, declared_name.as_inline_str().clone())
|
PQModuleName::Qualified(shorthand, declared_name.as_inline_str().clone())
|
||||||
}
|
}
|
||||||
None => PQModuleName::Unqualified(declared_name.as_inline_str().clone()),
|
None => PQModuleName::Unqualified(declared_name.as_inline_str().clone()),
|
||||||
};
|
};
|
||||||
|
@ -2901,13 +2901,13 @@ fn send_header<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
home.register_debug_idents(&ident_ids);
|
home.register_debug_idents(ident_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
ident_ids.clone()
|
ident_ids.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut parse_entries: Vec<_> = (&packages).iter().map(|x| &x.value).collect();
|
let mut parse_entries: Vec<_> = packages.iter().map(|x| &x.value).collect();
|
||||||
let mut package_entries = MutMap::default();
|
let mut package_entries = MutMap::default();
|
||||||
|
|
||||||
while let Some(parse_entry) = parse_entries.pop() {
|
while let Some(parse_entry) = parse_entries.pop() {
|
||||||
|
@ -3053,7 +3053,7 @@ fn send_header_two<'a>(
|
||||||
let mut module_ids = (*module_ids).lock();
|
let mut module_ids = (*module_ids).lock();
|
||||||
let mut ident_ids_by_module = (*ident_ids_by_module).lock();
|
let mut ident_ids_by_module = (*ident_ids_by_module).lock();
|
||||||
|
|
||||||
let name = PQModuleName::Qualified(&shorthand, declared_name);
|
let name = PQModuleName::Qualified(shorthand, declared_name);
|
||||||
home = module_ids.get_or_insert(&name);
|
home = module_ids.get_or_insert(&name);
|
||||||
|
|
||||||
// Ensure this module has an entry in the exposed_ident_ids map.
|
// Ensure this module has an entry in the exposed_ident_ids map.
|
||||||
|
@ -3138,13 +3138,13 @@ fn send_header_two<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
home.register_debug_idents(&ident_ids);
|
home.register_debug_idents(ident_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
ident_ids.clone()
|
ident_ids.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut parse_entries: Vec<_> = (&packages).iter().map(|x| &x.value).collect();
|
let mut parse_entries: Vec<_> = packages.iter().map(|x| &x.value).collect();
|
||||||
let mut package_entries = MutMap::default();
|
let mut package_entries = MutMap::default();
|
||||||
|
|
||||||
while let Some(parse_entry) = parse_entries.pop() {
|
while let Some(parse_entry) = parse_entries.pop() {
|
||||||
|
@ -3390,7 +3390,7 @@ fn fabricate_effects_module<'a>(
|
||||||
|
|
||||||
let module_id: ModuleId;
|
let module_id: ModuleId;
|
||||||
|
|
||||||
let effect_entries = unpack_exposes_entries(arena, &effects.entries);
|
let effect_entries = unpack_exposes_entries(arena, effects.entries);
|
||||||
let name = effects.effect_type_name;
|
let name = effects.effect_type_name;
|
||||||
let declared_name: ModuleName = name.into();
|
let declared_name: ModuleName = name.into();
|
||||||
|
|
||||||
|
@ -3464,7 +3464,7 @@ fn fabricate_effects_module<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
module_id.register_debug_idents(&ident_ids);
|
module_id.register_debug_idents(ident_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
ident_ids.clone()
|
ident_ids.clone()
|
||||||
|
@ -3685,7 +3685,7 @@ where
|
||||||
|
|
||||||
let mut var_store = VarStore::default();
|
let mut var_store = VarStore::default();
|
||||||
let canonicalized = canonicalize_module_defs(
|
let canonicalized = canonicalize_module_defs(
|
||||||
&arena,
|
arena,
|
||||||
parsed_defs,
|
parsed_defs,
|
||||||
module_id,
|
module_id,
|
||||||
module_ids,
|
module_ids,
|
||||||
|
@ -3712,7 +3712,7 @@ where
|
||||||
module_output.scope,
|
module_output.scope,
|
||||||
name.as_str().into(),
|
name.as_str().into(),
|
||||||
&module_output.ident_ids,
|
&module_output.ident_ids,
|
||||||
&parsed_defs,
|
parsed_defs,
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3761,7 +3761,7 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result<Msg<'a>, Loadi
|
||||||
let parse_start = SystemTime::now();
|
let parse_start = SystemTime::now();
|
||||||
let source = header.parse_state.bytes;
|
let source = header.parse_state.bytes;
|
||||||
let parse_state = header.parse_state;
|
let parse_state = header.parse_state;
|
||||||
let parsed_defs = match module_defs().parse(&arena, parse_state) {
|
let parsed_defs = match module_defs().parse(arena, parse_state) {
|
||||||
Ok((_, success, _state)) => success,
|
Ok((_, success, _state)) => success,
|
||||||
Err((_, fail, _)) => {
|
Err((_, fail, _)) => {
|
||||||
return Err(LoadingProblem::ParsingFailed(fail.into_parse_problem(
|
return Err(LoadingProblem::ParsingFailed(fail.into_parse_problem(
|
||||||
|
|
|
@ -188,8 +188,8 @@ mod test_load {
|
||||||
|
|
||||||
name_all_type_vars(*expr_var, subs);
|
name_all_type_vars(*expr_var, subs);
|
||||||
|
|
||||||
let actual_str = content_to_string(content, subs, home, &interns);
|
let actual_str = content_to_string(content, subs, home, interns);
|
||||||
let fully_qualified = symbol.fully_qualified(&interns, home).to_string();
|
let fully_qualified = symbol.fully_qualified(interns, home).to_string();
|
||||||
let expected_type = expected_types
|
let expected_type = expected_types
|
||||||
.remove(fully_qualified.as_str())
|
.remove(fully_qualified.as_str())
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
|
|
|
@ -317,7 +317,7 @@ impl fmt::Debug for ModuleId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// In relese builds, all we have access to is the number, so only display that.
|
/// In release builds, all we have access to is the number, so only display that.
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.0.fmt(f)
|
self.0.fmt(f)
|
||||||
|
@ -368,7 +368,7 @@ impl<'a> PackageModuleIds<'a> {
|
||||||
self.by_name.insert(module_name.clone(), module_id);
|
self.by_name.insert(module_name.clone(), module_id);
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
Self::insert_debug_name(module_id, &module_name);
|
Self::insert_debug_name(module_id, module_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_id
|
module_id
|
||||||
|
@ -449,7 +449,7 @@ impl ModuleIds {
|
||||||
self.by_name.insert(module_name.clone(), module_id);
|
self.by_name.insert(module_name.clone(), module_id);
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
Self::insert_debug_name(module_id, &module_name);
|
Self::insert_debug_name(module_id, module_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_id
|
module_id
|
||||||
|
|
|
@ -1108,7 +1108,7 @@ fn expr_spec<'a>(
|
||||||
let index = (*index) as u32;
|
let index = (*index) as u32;
|
||||||
let tag_value_id = env.symbols[structure];
|
let tag_value_id = env.symbols[structure];
|
||||||
|
|
||||||
let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes();
|
let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
|
||||||
let type_name = TypeName(&type_name_bytes);
|
let type_name = TypeName(&type_name_bytes);
|
||||||
|
|
||||||
let union_id = builder.add_unwrap_named(block, MOD_APP, type_name, tag_value_id)?;
|
let union_id = builder.add_unwrap_named(block, MOD_APP, type_name, tag_value_id)?;
|
||||||
|
@ -1128,7 +1128,7 @@ fn expr_spec<'a>(
|
||||||
|
|
||||||
let tag_value_id = env.symbols[structure];
|
let tag_value_id = env.symbols[structure];
|
||||||
|
|
||||||
let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes();
|
let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
|
||||||
let type_name = TypeName(&type_name_bytes);
|
let type_name = TypeName(&type_name_bytes);
|
||||||
|
|
||||||
let variant_id =
|
let variant_id =
|
||||||
|
@ -1234,7 +1234,7 @@ fn layout_spec_help(
|
||||||
| UnionLayout::NullableUnwrapped { .. }
|
| UnionLayout::NullableUnwrapped { .. }
|
||||||
| UnionLayout::NullableWrapped { .. }
|
| UnionLayout::NullableWrapped { .. }
|
||||||
| UnionLayout::NonNullableUnwrapped(_) => {
|
| UnionLayout::NonNullableUnwrapped(_) => {
|
||||||
let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes();
|
let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
|
||||||
let type_name = TypeName(&type_name_bytes);
|
let type_name = TypeName(&type_name_bytes);
|
||||||
|
|
||||||
Ok(builder.add_named_type(MOD_APP, type_name))
|
Ok(builder.add_named_type(MOD_APP, type_name))
|
||||||
|
|
|
@ -475,7 +475,7 @@ impl<'a> BorrowInfState<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This looks at the assignement
|
/// This looks at the assignment
|
||||||
///
|
///
|
||||||
/// let z = e in ...
|
/// let z = e in ...
|
||||||
///
|
///
|
||||||
|
|
|
@ -924,7 +924,7 @@ fn pick_path<'a>(branches: &'a [Branch]) -> &'a Vec<PathInstruction> {
|
||||||
for (path, pattern) in &branch.patterns {
|
for (path, pattern) in &branch.patterns {
|
||||||
// NOTE we no longer check for the guard here
|
// NOTE we no longer check for the guard here
|
||||||
// if !branch.guard.is_none() || needs_tests(&pattern) {
|
// if !branch.guard.is_none() || needs_tests(&pattern) {
|
||||||
if needs_tests(&pattern) {
|
if needs_tests(pattern) {
|
||||||
all_paths.push(path);
|
all_paths.push(path);
|
||||||
} else {
|
} else {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -996,7 +996,7 @@ where
|
||||||
let mut min_paths = vec![first_path];
|
let mut min_paths = vec![first_path];
|
||||||
|
|
||||||
for path in all_paths {
|
for path in all_paths {
|
||||||
let weight = small_defaults(branches, &path);
|
let weight = small_defaults(branches, path);
|
||||||
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
match weight.cmp(&min_weight) {
|
match weight.cmp(&min_weight) {
|
||||||
|
@ -1219,7 +1219,7 @@ fn test_to_equality<'a>(
|
||||||
test: Test<'a>,
|
test: Test<'a>,
|
||||||
) -> (StoresVec<'a>, Symbol, Symbol, Option<ConstructorKnown<'a>>) {
|
) -> (StoresVec<'a>, Symbol, Symbol, Option<ConstructorKnown<'a>>) {
|
||||||
let (rhs_symbol, mut stores, test_layout) =
|
let (rhs_symbol, mut stores, test_layout) =
|
||||||
path_to_expr_help(env, cond_symbol, &path, *cond_layout);
|
path_to_expr_help(env, cond_symbol, path, *cond_layout);
|
||||||
|
|
||||||
match test {
|
match test {
|
||||||
Test::IsCtor { tag_id, union, .. } => {
|
Test::IsCtor { tag_id, union, .. } => {
|
||||||
|
@ -1325,13 +1325,7 @@ fn stores_and_condition<'a>(
|
||||||
|
|
||||||
// Assumption: there is at most 1 guard, and it is the outer layer.
|
// Assumption: there is at most 1 guard, and it is the outer layer.
|
||||||
for (path, test) in test_chain {
|
for (path, test) in test_chain {
|
||||||
tests.push(test_to_equality(
|
tests.push(test_to_equality(env, cond_symbol, cond_layout, &path, test))
|
||||||
env,
|
|
||||||
cond_symbol,
|
|
||||||
&cond_layout,
|
|
||||||
&path,
|
|
||||||
test,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tests
|
tests
|
||||||
|
@ -1540,7 +1534,7 @@ fn decide_to_branching<'a>(
|
||||||
match decider {
|
match decider {
|
||||||
Leaf(Jump(label)) => {
|
Leaf(Jump(label)) => {
|
||||||
let index = jumps
|
let index = jumps
|
||||||
.binary_search_by_key(&label, |ref r| r.0)
|
.binary_search_by_key(&label, |r| r.0)
|
||||||
.expect("jump not in list of jumps");
|
.expect("jump not in list of jumps");
|
||||||
|
|
||||||
Stmt::Jump(jumps[index].1, &[])
|
Stmt::Jump(jumps[index].1, &[])
|
||||||
|
|
|
@ -50,7 +50,7 @@ use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
||||||
// Let's work through the `Cons x xx` example
|
// Let's work through the `Cons x xx` example
|
||||||
//
|
//
|
||||||
// First we need to know the constructor of `xs` in the particular block. This information would
|
// First we need to know the constructor of `xs` in the particular block. This information would
|
||||||
// normally be lost when we compile pattern matches, but we keep it in the `BrachInfo` field of
|
// normally be lost when we compile pattern matches, but we keep it in the `BranchInfo` field of
|
||||||
// switch branches. here we also store the symbol that was switched on, and the layout of that
|
// switch branches. here we also store the symbol that was switched on, and the layout of that
|
||||||
// symbol.
|
// symbol.
|
||||||
//
|
//
|
||||||
|
@ -187,7 +187,7 @@ impl<'a, 'i> Env<'a, 'i> {
|
||||||
pub fn unique_symbol(&mut self) -> Symbol {
|
pub fn unique_symbol(&mut self) -> Symbol {
|
||||||
let ident_id = self.ident_ids.gen_unique();
|
let ident_id = self.ident_ids.gen_unique();
|
||||||
|
|
||||||
self.home.register_debug_idents(&self.ident_ids);
|
self.home.register_debug_idents(self.ident_ids);
|
||||||
|
|
||||||
Symbol::new(self.home, ident_id)
|
Symbol::new(self.home, ident_id)
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ impl<'a, 'i> Env<'a, 'i> {
|
||||||
fn manual_unique_symbol(home: ModuleId, ident_ids: &mut IdentIds) -> Symbol {
|
fn manual_unique_symbol(home: ModuleId, ident_ids: &mut IdentIds) -> Symbol {
|
||||||
let ident_id = ident_ids.gen_unique();
|
let ident_id = ident_ids.gen_unique();
|
||||||
|
|
||||||
home.register_debug_idents(&ident_ids);
|
home.register_debug_idents(ident_ids);
|
||||||
|
|
||||||
Symbol::new(home, ident_id)
|
Symbol::new(home, ident_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,7 +740,7 @@ impl<'a> Context<'a> {
|
||||||
) -> (&'a Stmt<'a>, LiveVarSet) {
|
) -> (&'a Stmt<'a>, LiveVarSet) {
|
||||||
use Expr::*;
|
use Expr::*;
|
||||||
|
|
||||||
let mut live_vars = update_live_vars(&v, &b_live_vars);
|
let mut live_vars = update_live_vars(&v, b_live_vars);
|
||||||
live_vars.remove(&z);
|
live_vars.remove(&z);
|
||||||
|
|
||||||
let new_b = match v {
|
let new_b = match v {
|
||||||
|
@ -750,7 +750,7 @@ impl<'a> Context<'a> {
|
||||||
| Array { elems: ys, .. } => self.add_inc_before_consume_all(
|
| Array { elems: ys, .. } => self.add_inc_before_consume_all(
|
||||||
ys,
|
ys,
|
||||||
self.arena.alloc(Stmt::Let(z, v, l, b)),
|
self.arena.alloc(Stmt::Let(z, v, l, b)),
|
||||||
&b_live_vars,
|
b_live_vars,
|
||||||
),
|
),
|
||||||
|
|
||||||
Call(crate::ir::Call {
|
Call(crate::ir::Call {
|
||||||
|
|
|
@ -809,7 +809,7 @@ impl<'a, 'i> Env<'a, 'i> {
|
||||||
pub fn unique_symbol(&mut self) -> Symbol {
|
pub fn unique_symbol(&mut self) -> Symbol {
|
||||||
let ident_id = self.ident_ids.gen_unique();
|
let ident_id = self.ident_ids.gen_unique();
|
||||||
|
|
||||||
self.home.register_debug_idents(&self.ident_ids);
|
self.home.register_debug_idents(self.ident_ids);
|
||||||
|
|
||||||
Symbol::new(self.home, ident_id)
|
Symbol::new(self.home, ident_id)
|
||||||
}
|
}
|
||||||
|
@ -1700,7 +1700,7 @@ fn pattern_to_when<'a>(
|
||||||
|
|
||||||
UnsupportedPattern(region) => {
|
UnsupportedPattern(region) => {
|
||||||
// create the runtime error here, instead of delegating to When.
|
// create the runtime error here, instead of delegating to When.
|
||||||
// UnsupportedPattern should then never occcur in When
|
// UnsupportedPattern should then never occur in When
|
||||||
let error = roc_problem::can::RuntimeError::UnsupportedPattern(*region);
|
let error = roc_problem::can::RuntimeError::UnsupportedPattern(*region);
|
||||||
(env.unique_symbol(), Located::at_zero(RuntimeError(error)))
|
(env.unique_symbol(), Located::at_zero(RuntimeError(error)))
|
||||||
}
|
}
|
||||||
|
@ -2468,7 +2468,7 @@ fn specialize_solved_type<'a>(
|
||||||
|
|
||||||
// for debugging only
|
// for debugging only
|
||||||
let attempted_layout = layout_cache
|
let attempted_layout = layout_cache
|
||||||
.from_var(&env.arena, fn_var, env.subs)
|
.from_var(env.arena, fn_var, env.subs)
|
||||||
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
|
||||||
|
|
||||||
let raw = match attempted_layout {
|
let raw = match attempted_layout {
|
||||||
|
@ -2509,7 +2509,7 @@ fn specialize_solved_type<'a>(
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
attempted_layout,
|
attempted_layout,
|
||||||
layout_cache
|
layout_cache
|
||||||
.from_var(&env.arena, fn_var, env.subs)
|
.from_var(env.arena, fn_var, env.subs)
|
||||||
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err))
|
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3855,7 +3855,7 @@ pub fn with_hole<'a>(
|
||||||
let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena);
|
let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena);
|
||||||
|
|
||||||
for (_, arg_expr) in args.iter() {
|
for (_, arg_expr) in args.iter() {
|
||||||
arg_symbols.push(possible_reuse_symbol(env, procs, &arg_expr));
|
arg_symbols.push(possible_reuse_symbol(env, procs, arg_expr));
|
||||||
}
|
}
|
||||||
let arg_symbols = arg_symbols.into_bump_slice();
|
let arg_symbols = arg_symbols.into_bump_slice();
|
||||||
|
|
||||||
|
@ -3885,7 +3885,7 @@ pub fn with_hole<'a>(
|
||||||
let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena);
|
let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena);
|
||||||
|
|
||||||
for (_, arg_expr) in args.iter() {
|
for (_, arg_expr) in args.iter() {
|
||||||
arg_symbols.push(possible_reuse_symbol(env, procs, &arg_expr));
|
arg_symbols.push(possible_reuse_symbol(env, procs, arg_expr));
|
||||||
}
|
}
|
||||||
let arg_symbols = arg_symbols.into_bump_slice();
|
let arg_symbols = arg_symbols.into_bump_slice();
|
||||||
|
|
||||||
|
@ -5540,7 +5540,7 @@ fn store_pattern_help<'a>(
|
||||||
layout_cache,
|
layout_cache,
|
||||||
outer_symbol,
|
outer_symbol,
|
||||||
&layout,
|
&layout,
|
||||||
&arguments,
|
arguments,
|
||||||
stmt,
|
stmt,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5557,7 +5557,7 @@ fn store_pattern_help<'a>(
|
||||||
layout_cache,
|
layout_cache,
|
||||||
outer_symbol,
|
outer_symbol,
|
||||||
*layout,
|
*layout,
|
||||||
&arguments,
|
arguments,
|
||||||
*tag_id,
|
*tag_id,
|
||||||
stmt,
|
stmt,
|
||||||
);
|
);
|
||||||
|
@ -6374,7 +6374,7 @@ fn call_by_name_help<'a>(
|
||||||
// the variables of the given arguments
|
// the variables of the given arguments
|
||||||
let mut pattern_vars = Vec::with_capacity_in(loc_args.len(), arena);
|
let mut pattern_vars = Vec::with_capacity_in(loc_args.len(), arena);
|
||||||
for (var, _) in &loc_args {
|
for (var, _) in &loc_args {
|
||||||
match layout_cache.from_var(&env.arena, *var, &env.subs) {
|
match layout_cache.from_var(env.arena, *var, env.subs) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
pattern_vars.push(*var);
|
pattern_vars.push(*var);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1317,7 +1317,7 @@ fn layout_from_flat_type<'a>(
|
||||||
}
|
}
|
||||||
} else if tag_layouts.len() == 1 {
|
} else if tag_layouts.len() == 1 {
|
||||||
// drop the tag id
|
// drop the tag id
|
||||||
UnionLayout::NonNullableUnwrapped(&tag_layouts.pop().unwrap())
|
UnionLayout::NonNullableUnwrapped(tag_layouts.pop().unwrap())
|
||||||
} else {
|
} else {
|
||||||
UnionLayout::Recursive(tag_layouts.into_bump_slice())
|
UnionLayout::Recursive(tag_layouts.into_bump_slice())
|
||||||
};
|
};
|
||||||
|
@ -2114,7 +2114,7 @@ impl<'a> LayoutIds<'a> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the id associated with this layout, or default to next_id.
|
// Get the id associated with this layout, or default to next_id.
|
||||||
let answer = ids.by_id.get(&layout).copied().unwrap_or(ids.next_id);
|
let answer = ids.by_id.get(layout).copied().unwrap_or(ids.next_id);
|
||||||
|
|
||||||
// If we had to default to next_id, it must not have been found;
|
// If we had to default to next_id, it must not have been found;
|
||||||
// store the ID we're going to return and increment next_id.
|
// store the ID we're going to return and increment next_id.
|
||||||
|
@ -2145,7 +2145,7 @@ impl<'a> LayoutIds<'a> {
|
||||||
// Get the id associated with this layout, or default to next_id.
|
// Get the id associated with this layout, or default to next_id.
|
||||||
let answer = ids
|
let answer = ids
|
||||||
.toplevels_by_id
|
.toplevels_by_id
|
||||||
.get(&layout)
|
.get(layout)
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or(ids.next_id);
|
.unwrap_or(ids.next_id);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl<'a, 'i> Env<'a, 'i> {
|
||||||
fn unique_symbol(&mut self) -> Symbol {
|
fn unique_symbol(&mut self) -> Symbol {
|
||||||
let ident_id = self.ident_ids.gen_unique();
|
let ident_id = self.ident_ids.gen_unique();
|
||||||
|
|
||||||
self.home.register_debug_idents(&self.ident_ids);
|
self.home.register_debug_idents(self.ident_ids);
|
||||||
|
|
||||||
Symbol::new(self.home, ident_id)
|
Symbol::new(self.home, ident_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ pub fn make_tail_recursive<'a>(
|
||||||
stmt: Stmt<'a>,
|
stmt: Stmt<'a>,
|
||||||
args: &'a [(Layout<'a>, Symbol)],
|
args: &'a [(Layout<'a>, Symbol)],
|
||||||
) -> Stmt<'a> {
|
) -> Stmt<'a> {
|
||||||
let alloced = arena.alloc(stmt);
|
let allocated = arena.alloc(stmt);
|
||||||
match insert_jumps(arena, alloced, id, needle) {
|
match insert_jumps(arena, allocated, id, needle) {
|
||||||
None => alloced.clone(),
|
None => allocated.clone(),
|
||||||
Some(new) => {
|
Some(new) => {
|
||||||
// jumps were inserted, we must now add a join point
|
// jumps were inserted, we must now add a join point
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,7 @@ fn underscore_expression<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
|
||||||
|
|
||||||
match output {
|
match output {
|
||||||
Some(name) => Ok((MadeProgress, Expr::Underscore(name), final_state)),
|
Some(name) => Ok((MadeProgress, Expr::Underscore(name), final_state)),
|
||||||
None => Ok((MadeProgress, Expr::Underscore(&""), final_state)),
|
None => Ok((MadeProgress, Expr::Underscore(""), final_state)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub fn positive_number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, Number>
|
||||||
move |_arena, state: State<'a>| {
|
move |_arena, state: State<'a>| {
|
||||||
match state.bytes.get(0) {
|
match state.bytes.get(0) {
|
||||||
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
|
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
|
||||||
parse_number_base(false, &state.bytes, state)
|
parse_number_base(false, state.bytes, state)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// this is not a number at all
|
// this is not a number at all
|
||||||
|
@ -33,7 +33,7 @@ pub fn number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, Number> {
|
||||||
parse_number_base(true, &state.bytes[1..], state)
|
parse_number_base(true, &state.bytes[1..], state)
|
||||||
}
|
}
|
||||||
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
|
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
|
||||||
parse_number_base(false, &state.bytes, state)
|
parse_number_base(false, state.bytes, state)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// this is not a number at all
|
// this is not a number at all
|
||||||
|
|
|
@ -259,7 +259,7 @@ fn loc_ident_pattern_help<'a>(
|
||||||
Located {
|
Located {
|
||||||
region: loc_ident.region,
|
region: loc_ident.region,
|
||||||
value: Pattern::Malformed(
|
value: Pattern::Malformed(
|
||||||
String::from_str_in(&malformed_str, &arena).into_bump_str(),
|
String::from_str_in(&malformed_str, arena).into_bump_str(),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
state,
|
state,
|
||||||
|
@ -299,7 +299,7 @@ fn underscore_pattern_help<'a>() -> impl Parser<'a, Pattern<'a>, EPattern<'a>> {
|
||||||
|
|
||||||
match output {
|
match output {
|
||||||
Some(name) => Ok((MadeProgress, Pattern::Underscore(name), final_state)),
|
Some(name) => Ok((MadeProgress, Pattern::Underscore(name), final_state)),
|
||||||
None => Ok((MadeProgress, Pattern::Underscore(&""), final_state)),
|
None => Ok((MadeProgress, Pattern::Underscore(""), final_state)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,12 +303,12 @@ fn applied_type<'a>(min_indent: u16) -> impl Parser<'a, TypeAnnotation<'a>, Type
|
||||||
),
|
),
|
||||||
|(ctor, args): (TypeAnnotation<'a>, Vec<'a, Located<TypeAnnotation<'a>>>)| {
|
|(ctor, args): (TypeAnnotation<'a>, Vec<'a, Located<TypeAnnotation<'a>>>)| {
|
||||||
match &ctor {
|
match &ctor {
|
||||||
TypeAnnotation::Apply(ref module_name, ref name, _) => {
|
TypeAnnotation::Apply(module_name, name, _) => {
|
||||||
if args.is_empty() {
|
if args.is_empty() {
|
||||||
// ctor is already an Apply with no args, so return it directly.
|
// ctor is already an Apply with no args, so return it directly.
|
||||||
ctor
|
ctor
|
||||||
} else {
|
} else {
|
||||||
TypeAnnotation::Apply(*module_name, *name, args.into_bump_slice())
|
TypeAnnotation::Apply(module_name, name, args.into_bump_slice())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TypeAnnotation::Malformed(_) => ctor,
|
TypeAnnotation::Malformed(_) => ctor,
|
||||||
|
@ -371,7 +371,7 @@ fn expression<'a>(min_indent: u16) -> impl Parser<'a, Located<TypeAnnotation<'a>
|
||||||
.parse(arena, state)?;
|
.parse(arena, state)?;
|
||||||
|
|
||||||
// prepare arguments
|
// prepare arguments
|
||||||
let mut arguments = Vec::with_capacity_in(rest.len() + 1, &arena);
|
let mut arguments = Vec::with_capacity_in(rest.len() + 1, arena);
|
||||||
arguments.push(first);
|
arguments.push(first);
|
||||||
arguments.extend(rest);
|
arguments.extend(rest);
|
||||||
let output = arena.alloc(arguments);
|
let output = arena.alloc(arguments);
|
||||||
|
|
|
@ -1609,7 +1609,7 @@ mod test_parse {
|
||||||
#[test]
|
#[test]
|
||||||
fn single_underscore_closure() {
|
fn single_underscore_closure() {
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let pattern = Located::new(0, 0, 1, 2, Pattern::Underscore(&""));
|
let pattern = Located::new(0, 0, 1, 2, Pattern::Underscore(""));
|
||||||
let patterns = &[pattern];
|
let patterns = &[pattern];
|
||||||
let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 6, 8, Num("42"))));
|
let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 6, 8, Num("42"))));
|
||||||
let actual = parse_expr_with(&arena, "\\_ -> 42");
|
let actual = parse_expr_with(&arena, "\\_ -> 42");
|
||||||
|
@ -1629,7 +1629,7 @@ mod test_parse {
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
11,
|
11,
|
||||||
Pattern::MalformedIdent(&"the_answer", roc_parse::ident::BadIdent::Underscore(0, 5)),
|
Pattern::MalformedIdent("the_answer", roc_parse::ident::BadIdent::Underscore(0, 5)),
|
||||||
);
|
);
|
||||||
let patterns = &[pattern];
|
let patterns = &[pattern];
|
||||||
let expr = Located::new(0, 0, 15, 17, Expr::Num("42"));
|
let expr = Located::new(0, 0, 15, 17, Expr::Num("42"));
|
||||||
|
@ -1671,8 +1671,8 @@ mod test_parse {
|
||||||
#[test]
|
#[test]
|
||||||
fn closure_with_underscores() {
|
fn closure_with_underscores() {
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let underscore1 = Located::new(0, 0, 1, 2, Pattern::Underscore(&""));
|
let underscore1 = Located::new(0, 0, 1, 2, Pattern::Underscore(""));
|
||||||
let underscore2 = Located::new(0, 0, 4, 9, Pattern::Underscore(&"name"));
|
let underscore2 = Located::new(0, 0, 4, 9, Pattern::Underscore("name"));
|
||||||
let patterns = bumpalo::vec![in &arena; underscore1, underscore2];
|
let patterns = bumpalo::vec![in &arena; underscore1, underscore2];
|
||||||
let expected = Closure(
|
let expected = Closure(
|
||||||
arena.alloc(patterns),
|
arena.alloc(patterns),
|
||||||
|
@ -1906,7 +1906,7 @@ mod test_parse {
|
||||||
fn underscore_backpassing() {
|
fn underscore_backpassing() {
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let newlines = bumpalo::vec![in &arena; Newline, Newline];
|
let newlines = bumpalo::vec![in &arena; Newline, Newline];
|
||||||
let underscore = Located::new(1, 1, 0, 1, Pattern::Underscore(&""));
|
let underscore = Located::new(1, 1, 0, 1, Pattern::Underscore(""));
|
||||||
let identifier_y = Located::new(1, 1, 7, 8, Identifier("y"));
|
let identifier_y = Located::new(1, 1, 7, 8, Identifier("y"));
|
||||||
|
|
||||||
let num_4 = Num("4");
|
let num_4 = Num("4");
|
||||||
|
@ -3531,7 +3531,6 @@ mod test_parse {
|
||||||
match parsed {
|
match parsed {
|
||||||
Ok((_, _, _state)) => {
|
Ok((_, _, _state)) => {
|
||||||
// dbg!(_state);
|
// dbg!(_state);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Err((_, _fail, _state)) => {
|
Err((_, _fail, _state)) => {
|
||||||
// dbg!(_fail, _state);
|
// dbg!(_fail, _state);
|
||||||
|
@ -3707,7 +3706,7 @@ mod test_parse {
|
||||||
guard: None,
|
guard: None,
|
||||||
});
|
});
|
||||||
let newlines = &[Newline];
|
let newlines = &[Newline];
|
||||||
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore(&"")), newlines);
|
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore("")), newlines);
|
||||||
let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2);
|
let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2);
|
||||||
let expr2 = Num("4");
|
let expr2 = Num("4");
|
||||||
let loc_expr2 = Located::new(2, 2, 9, 10, expr2);
|
let loc_expr2 = Located::new(2, 2, 9, 10, expr2);
|
||||||
|
@ -3752,7 +3751,7 @@ mod test_parse {
|
||||||
guard: None,
|
guard: None,
|
||||||
});
|
});
|
||||||
let newlines = &[Newline];
|
let newlines = &[Newline];
|
||||||
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore(&"")), newlines);
|
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore("")), newlines);
|
||||||
let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2);
|
let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2);
|
||||||
let expr2 = Num("4");
|
let expr2 = Num("4");
|
||||||
let loc_expr2 = Located::new(2, 2, 9, 10, expr2);
|
let loc_expr2 = Located::new(2, 2, 9, 10, expr2);
|
||||||
|
|
|
@ -159,17 +159,17 @@ fn to_syntax_report<'a>(
|
||||||
title: "PARSE PROBLEM".to_string(),
|
title: "PARSE PROBLEM".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Type(typ) => to_type_report(alloc, filename, &typ, 0, 0),
|
Type(typ) => to_type_report(alloc, filename, typ, 0, 0),
|
||||||
Pattern(pat) => to_pattern_report(alloc, filename, &pat, 0, 0),
|
Pattern(pat) => to_pattern_report(alloc, filename, pat, 0, 0),
|
||||||
Expr(expr) => to_expr_report(
|
Expr(expr) => to_expr_report(
|
||||||
alloc,
|
alloc,
|
||||||
filename,
|
filename,
|
||||||
Context::InDef(start_row, start_col),
|
Context::InDef(start_row, start_col),
|
||||||
&expr,
|
expr,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
Header(header) => to_header_report(alloc, filename, &header, 0, 0),
|
Header(header) => to_header_report(alloc, filename, header, 0, 0),
|
||||||
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,19 +205,17 @@ fn to_expr_report<'a>(
|
||||||
use roc_parse::parser::EExpr;
|
use roc_parse::parser::EExpr;
|
||||||
|
|
||||||
match parse_problem {
|
match parse_problem {
|
||||||
EExpr::If(if_, row, col) => to_if_report(alloc, filename, context, &if_, *row, *col),
|
EExpr::If(if_, row, col) => to_if_report(alloc, filename, context, if_, *row, *col),
|
||||||
EExpr::When(when, row, col) => to_when_report(alloc, filename, context, &when, *row, *col),
|
EExpr::When(when, row, col) => to_when_report(alloc, filename, context, when, *row, *col),
|
||||||
EExpr::Lambda(lambda, row, col) => {
|
EExpr::Lambda(lambda, row, col) => {
|
||||||
to_lambda_report(alloc, filename, context, &lambda, *row, *col)
|
to_lambda_report(alloc, filename, context, lambda, *row, *col)
|
||||||
}
|
|
||||||
EExpr::List(list, row, col) => to_list_report(alloc, filename, context, &list, *row, *col),
|
|
||||||
EExpr::Str(string, row, col) => {
|
|
||||||
to_str_report(alloc, filename, context, &string, *row, *col)
|
|
||||||
}
|
}
|
||||||
|
EExpr::List(list, row, col) => to_list_report(alloc, filename, context, list, *row, *col),
|
||||||
|
EExpr::Str(string, row, col) => to_str_report(alloc, filename, context, string, *row, *col),
|
||||||
EExpr::InParens(expr, row, col) => {
|
EExpr::InParens(expr, row, col) => {
|
||||||
to_expr_in_parens_report(alloc, filename, context, &expr, *row, *col)
|
to_expr_in_parens_report(alloc, filename, context, expr, *row, *col)
|
||||||
}
|
}
|
||||||
EExpr::Type(tipe, row, col) => to_type_report(alloc, filename, &tipe, *row, *col),
|
EExpr::Type(tipe, row, col) => to_type_report(alloc, filename, tipe, *row, *col),
|
||||||
EExpr::ElmStyleFunction(region, row, col) => {
|
EExpr::ElmStyleFunction(region, row, col) => {
|
||||||
let surroundings = Region::from_rows_cols(start_row, start_col, *row, *col);
|
let surroundings = Region::from_rows_cols(start_row, start_col, *row, *col);
|
||||||
let region = *region;
|
let region = *region;
|
||||||
|
@ -529,7 +527,7 @@ fn to_expr_report<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EExpr::Space(error, row, col) => to_space_report(alloc, filename, &error, *row, *col),
|
EExpr::Space(error, row, col) => to_space_report(alloc, filename, error, *row, *col),
|
||||||
|
|
||||||
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
||||||
}
|
}
|
||||||
|
@ -1557,10 +1555,10 @@ fn to_pattern_report<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EPattern::Record(record, row, col) => {
|
EPattern::Record(record, row, col) => {
|
||||||
to_precord_report(alloc, filename, &record, *row, *col)
|
to_precord_report(alloc, filename, record, *row, *col)
|
||||||
}
|
}
|
||||||
EPattern::PInParens(inparens, row, col) => {
|
EPattern::PInParens(inparens, row, col) => {
|
||||||
to_pattern_in_parens_report(alloc, filename, &inparens, *row, *col)
|
to_pattern_in_parens_report(alloc, filename, inparens, *row, *col)
|
||||||
}
|
}
|
||||||
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
_ => todo!("unhandled parse error: {:?}", parse_problem),
|
||||||
}
|
}
|
||||||
|
@ -1958,14 +1956,14 @@ fn to_type_report<'a>(
|
||||||
use roc_parse::parser::Type;
|
use roc_parse::parser::Type;
|
||||||
|
|
||||||
match parse_problem {
|
match parse_problem {
|
||||||
Type::TRecord(record, row, col) => to_trecord_report(alloc, filename, &record, *row, *col),
|
Type::TRecord(record, row, col) => to_trecord_report(alloc, filename, record, *row, *col),
|
||||||
Type::TTagUnion(tag_union, row, col) => {
|
Type::TTagUnion(tag_union, row, col) => {
|
||||||
to_ttag_union_report(alloc, filename, &tag_union, *row, *col)
|
to_ttag_union_report(alloc, filename, tag_union, *row, *col)
|
||||||
}
|
}
|
||||||
Type::TInParens(tinparens, row, col) => {
|
Type::TInParens(tinparens, row, col) => {
|
||||||
to_tinparens_report(alloc, filename, &tinparens, *row, *col)
|
to_tinparens_report(alloc, filename, tinparens, *row, *col)
|
||||||
}
|
}
|
||||||
Type::TApply(tapply, row, col) => to_tapply_report(alloc, filename, &tapply, *row, *col),
|
Type::TApply(tapply, row, col) => to_tapply_report(alloc, filename, tapply, *row, *col),
|
||||||
|
|
||||||
Type::TFunctionArgument(row, col) => match what_is_next(alloc.src_lines, *row, *col) {
|
Type::TFunctionArgument(row, col) => match what_is_next(alloc.src_lines, *row, *col) {
|
||||||
Next::Other(Some(',')) => {
|
Next::Other(Some(',')) => {
|
||||||
|
@ -2856,27 +2854,27 @@ fn to_header_report<'a>(
|
||||||
|
|
||||||
match parse_problem {
|
match parse_problem {
|
||||||
EHeader::Provides(provides, row, col) => {
|
EHeader::Provides(provides, row, col) => {
|
||||||
to_provides_report(alloc, filename, &provides, *row, *col)
|
to_provides_report(alloc, filename, provides, *row, *col)
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::Exposes(exposes, row, col) => {
|
EHeader::Exposes(exposes, row, col) => {
|
||||||
to_exposes_report(alloc, filename, &exposes, *row, *col)
|
to_exposes_report(alloc, filename, exposes, *row, *col)
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::Imports(imports, row, col) => {
|
EHeader::Imports(imports, row, col) => {
|
||||||
to_imports_report(alloc, filename, &imports, *row, *col)
|
to_imports_report(alloc, filename, imports, *row, *col)
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::Requires(requires, row, col) => {
|
EHeader::Requires(requires, row, col) => {
|
||||||
to_requires_report(alloc, filename, &requires, *row, *col)
|
to_requires_report(alloc, filename, requires, *row, *col)
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::Packages(packages, row, col) => {
|
EHeader::Packages(packages, row, col) => {
|
||||||
to_packages_report(alloc, filename, &packages, *row, *col)
|
to_packages_report(alloc, filename, packages, *row, *col)
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::Effects(effects, row, col) => {
|
EHeader::Effects(effects, row, col) => {
|
||||||
to_effects_report(alloc, filename, &effects, *row, *col)
|
to_effects_report(alloc, filename, effects, *row, *col)
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::IndentStart(row, col) => {
|
EHeader::IndentStart(row, col) => {
|
||||||
|
@ -2988,7 +2986,7 @@ fn to_header_report<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EHeader::Space(error, row, col) => to_space_report(alloc, filename, &error, *row, *col),
|
EHeader::Space(error, row, col) => to_space_report(alloc, filename, error, *row, *col),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ fn report_bad_type<'b>(
|
||||||
alloc,
|
alloc,
|
||||||
found,
|
found,
|
||||||
expected_type,
|
expected_type,
|
||||||
add_category(alloc, this_is, &category),
|
add_category(alloc, this_is, category),
|
||||||
further_details,
|
further_details,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
@ -1443,7 +1443,7 @@ pub fn to_doc<'b>(
|
||||||
|
|
||||||
Record(fields_map, ext) => {
|
Record(fields_map, ext) => {
|
||||||
let mut fields = fields_map.into_iter().collect::<Vec<_>>();
|
let mut fields = fields_map.into_iter().collect::<Vec<_>>();
|
||||||
fields.sort_by(|(a, _), (b, _)| a.cmp(&b));
|
fields.sort_by(|(a, _), (b, _)| a.cmp(b));
|
||||||
|
|
||||||
report_text::record(
|
report_text::record(
|
||||||
alloc,
|
alloc,
|
||||||
|
@ -1482,7 +1482,7 @@ pub fn to_doc<'b>(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
tags.sort_by(|(a, _), (b, _)| a.cmp(&b));
|
tags.sort_by(|(a, _), (b, _)| a.cmp(b));
|
||||||
|
|
||||||
report_text::tag_union(
|
report_text::tag_union(
|
||||||
alloc,
|
alloc,
|
||||||
|
@ -1505,7 +1505,7 @@ pub fn to_doc<'b>(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
tags.sort_by(|(a, _), (b, _)| a.cmp(&b));
|
tags.sort_by(|(a, _), (b, _)| a.cmp(b));
|
||||||
|
|
||||||
report_text::recursive_tag_union(
|
report_text::recursive_tag_union(
|
||||||
alloc,
|
alloc,
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl<'b> Report<'b> {
|
||||||
pub fn render_ci(self, buf: &'b mut String, alloc: &'b RocDocAllocator<'b>) {
|
pub fn render_ci(self, buf: &'b mut String, alloc: &'b RocDocAllocator<'b>) {
|
||||||
let err_msg = "<buffer is not a utf-8 encoded string>";
|
let err_msg = "<buffer is not a utf-8 encoded string>";
|
||||||
|
|
||||||
self.pretty(&alloc)
|
self.pretty(alloc)
|
||||||
.1
|
.1
|
||||||
.render_raw(70, &mut CiWrite::new(buf))
|
.render_raw(70, &mut CiWrite::new(buf))
|
||||||
.expect(err_msg);
|
.expect(err_msg);
|
||||||
|
@ -85,7 +85,7 @@ impl<'b> Report<'b> {
|
||||||
) {
|
) {
|
||||||
let err_msg = "<buffer is not a utf-8 encoded string>";
|
let err_msg = "<buffer is not a utf-8 encoded string>";
|
||||||
|
|
||||||
self.pretty(&alloc)
|
self.pretty(alloc)
|
||||||
.1
|
.1
|
||||||
.render_raw(70, &mut ColorWrite::new(palette, buf))
|
.render_raw(70, &mut ColorWrite::new(palette, buf))
|
||||||
.expect(err_msg);
|
.expect(err_msg);
|
||||||
|
|
|
@ -110,7 +110,7 @@ pub fn can_expr_with<'a>(
|
||||||
home: ModuleId,
|
home: ModuleId,
|
||||||
expr_str: &'a str,
|
expr_str: &'a str,
|
||||||
) -> Result<CanExprOut, ParseErrOut<'a>> {
|
) -> Result<CanExprOut, ParseErrOut<'a>> {
|
||||||
let loc_expr = match roc_parse::test_helpers::parse_loc_with(&arena, expr_str) {
|
let loc_expr = match roc_parse::test_helpers::parse_loc_with(arena, expr_str) {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
Err(fail) => {
|
Err(fail) => {
|
||||||
let interns = Interns::default();
|
let interns = Interns::default();
|
||||||
|
|
|
@ -65,7 +65,7 @@ mod test_reporting {
|
||||||
problems: can_problems,
|
problems: can_problems,
|
||||||
..
|
..
|
||||||
} = can_expr(arena, expr_src)?;
|
} = can_expr(arena, expr_src)?;
|
||||||
let mut subs = Subs::new(var_store.into());
|
let mut subs = Subs::new(var_store);
|
||||||
|
|
||||||
for (var, name) in output.introduced_variables.name_by_var {
|
for (var, name) in output.introduced_variables.name_by_var {
|
||||||
subs.rigid_var(var, name);
|
subs.rigid_var(var, name);
|
||||||
|
@ -223,11 +223,9 @@ mod test_reporting {
|
||||||
list_reports(&arena, src, &mut buf, callback);
|
list_reports(&arena, src, &mut buf, callback);
|
||||||
|
|
||||||
// convenient to copy-paste the generated message
|
// convenient to copy-paste the generated message
|
||||||
if true {
|
if true && buf != expected_rendering {
|
||||||
if buf != expected_rendering {
|
for line in buf.split('\n') {
|
||||||
for line in buf.split("\n") {
|
println!(" {}", line);
|
||||||
println!(" {}", line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,11 +245,9 @@ mod test_reporting {
|
||||||
list_header_reports(&arena, src, &mut buf, callback);
|
list_header_reports(&arena, src, &mut buf, callback);
|
||||||
|
|
||||||
// convenient to copy-paste the generated message
|
// convenient to copy-paste the generated message
|
||||||
if true {
|
if true && buf != expected_rendering {
|
||||||
if buf != expected_rendering {
|
for line in buf.split('\n') {
|
||||||
for line in buf.split("\n") {
|
println!(" {}", line);
|
||||||
println!(" {}", line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,10 @@ pub fn make_solved_types(
|
||||||
for loc_named_var in alias.type_variables.iter() {
|
for loc_named_var in alias.type_variables.iter() {
|
||||||
let (name, var) = &loc_named_var.value;
|
let (name, var) = &loc_named_var.value;
|
||||||
|
|
||||||
args.push((name.clone(), SolvedType::new(&solved_subs, *var)));
|
args.push((name.clone(), SolvedType::new(solved_subs, *var)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let solved_type = SolvedType::from_type(&solved_subs, &alias.typ);
|
let solved_type = SolvedType::from_type(solved_subs, &alias.typ);
|
||||||
let solved_alias = SolvedType::Alias(*symbol, args, Box::new(solved_type));
|
let solved_alias = SolvedType::Alias(*symbol, args, Box::new(solved_type));
|
||||||
|
|
||||||
solved_types.insert(*symbol, solved_alias);
|
solved_types.insert(*symbol, solved_alias);
|
||||||
|
@ -71,7 +71,7 @@ pub fn make_solved_types(
|
||||||
// other modules will generate constraints for imported values
|
// other modules will generate constraints for imported values
|
||||||
// within the context of their own Subs.
|
// within the context of their own Subs.
|
||||||
for (symbol, var) in exposed_vars_by_symbol.iter() {
|
for (symbol, var) in exposed_vars_by_symbol.iter() {
|
||||||
let solved_type = SolvedType::new(&solved_subs, *var);
|
let solved_type = SolvedType::new(solved_subs, *var);
|
||||||
|
|
||||||
solved_types.insert(*symbol, solved_type);
|
solved_types.insert(*symbol, solved_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl Pools {
|
||||||
pub fn split_last(&self) -> (&Vec<Variable>, &[Vec<Variable>]) {
|
pub fn split_last(&self) -> (&Vec<Variable>, &[Vec<Variable>]) {
|
||||||
self.0
|
self.0
|
||||||
.split_last()
|
.split_last()
|
||||||
.unwrap_or_else(|| panic!("Attempted to split_last() on non-empy Pools"))
|
.unwrap_or_else(|| panic!("Attempted to split_last() on non-empty Pools"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extend_to(&mut self, n: usize) {
|
pub fn extend_to(&mut self, n: usize) {
|
||||||
|
@ -257,7 +257,7 @@ fn solve(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Lookup(symbol, expectation, region) => {
|
Lookup(symbol, expectation, region) => {
|
||||||
match env.vars_by_symbol.get(&symbol) {
|
match env.vars_by_symbol.get(symbol) {
|
||||||
Some(var) => {
|
Some(var) => {
|
||||||
// Deep copy the vars associated with this symbol before unifying them.
|
// Deep copy the vars associated with this symbol before unifying them.
|
||||||
// Otherwise, suppose we have this:
|
// Otherwise, suppose we have this:
|
||||||
|
@ -390,7 +390,7 @@ fn solve(
|
||||||
// If the return expression is guaranteed to solve,
|
// If the return expression is guaranteed to solve,
|
||||||
// solve the assignments themselves and move on.
|
// solve the assignments themselves and move on.
|
||||||
solve(
|
solve(
|
||||||
&env,
|
env,
|
||||||
state,
|
state,
|
||||||
rank,
|
rank,
|
||||||
pools,
|
pools,
|
||||||
|
@ -508,7 +508,7 @@ fn solve(
|
||||||
env: saved_env,
|
env: saved_env,
|
||||||
mark,
|
mark,
|
||||||
} = solve(
|
} = solve(
|
||||||
&env,
|
env,
|
||||||
state,
|
state,
|
||||||
next_rank,
|
next_rank,
|
||||||
next_pools,
|
next_pools,
|
||||||
|
@ -577,7 +577,7 @@ fn solve(
|
||||||
let mut new_env = env.clone();
|
let mut new_env = env.clone();
|
||||||
for (symbol, loc_var) in local_def_vars.iter() {
|
for (symbol, loc_var) in local_def_vars.iter() {
|
||||||
// when there are duplicates, keep the one from `env`
|
// when there are duplicates, keep the one from `env`
|
||||||
if !new_env.vars_by_symbol.contains_key(&symbol) {
|
if !new_env.vars_by_symbol.contains_key(symbol) {
|
||||||
new_env.vars_by_symbol.insert(*symbol, loc_var.value);
|
new_env.vars_by_symbol.insert(*symbol, loc_var.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,7 +599,7 @@ fn solve(
|
||||||
problems,
|
problems,
|
||||||
cached_aliases,
|
cached_aliases,
|
||||||
subs,
|
subs,
|
||||||
&ret_con,
|
ret_con,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (symbol, loc_var) in local_def_vars {
|
for (symbol, loc_var) in local_def_vars {
|
||||||
|
@ -1004,7 +1004,7 @@ fn adjust_rank(
|
||||||
unsafe { &*ptr }
|
unsafe { &*ptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, &content);
|
let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, content);
|
||||||
|
|
||||||
subs.set_rank_mark(var, max_rank, visit_mark);
|
subs.set_rank_mark(var, max_rank, visit_mark);
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ mod solve_expr {
|
||||||
subs.get(variable).content
|
subs.get(variable).content
|
||||||
};
|
};
|
||||||
|
|
||||||
let actual_str = content_to_string(content, &subs, home, &interns);
|
let actual_str = content_to_string(content, subs, home, &interns);
|
||||||
|
|
||||||
// Disregard UnusedDef problems, because those are unavoidable when
|
// Disregard UnusedDef problems, because those are unavoidable when
|
||||||
// returning a function from the test expression.
|
// returning a function from the test expression.
|
||||||
|
@ -3820,7 +3820,7 @@ mod solve_expr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn recursive_functon_with_rigid() {
|
fn recursive_function_with_rigid() {
|
||||||
infer_eq_without_problem(
|
infer_eq_without_problem(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
|
|
|
@ -13,7 +13,7 @@ struct List {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
On a 64-bit system, this `struct` would take up 16B in memory. On a 32-bit sysem, it would take up 8B.
|
On a 64-bit system, this `struct` would take up 16B in memory. On a 32-bit system, it would take up 8B.
|
||||||
|
|
||||||
Here's what the fields mean:
|
Here's what the fields mean:
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ mod gen_num {
|
||||||
x
|
x
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
RocDec::from_str_to_i128_unsafe(&"2.1"),
|
RocDec::from_str_to_i128_unsafe("2.1"),
|
||||||
i128
|
i128
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@ mod gen_num {
|
||||||
z
|
z
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
RocDec::from_str_to_i128_unsafe(&"5.2"),
|
RocDec::from_str_to_i128_unsafe("5.2"),
|
||||||
i128
|
i128
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -639,7 +639,7 @@ mod gen_num {
|
||||||
Err _ -> -1
|
Err _ -> -1
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
RocDec::from_str_to_i128_unsafe(&"3.333333333333333333"),
|
RocDec::from_str_to_i128_unsafe("3.333333333333333333"),
|
||||||
i128
|
i128
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ mod gen_num {
|
||||||
(x - y) - z
|
(x - y) - z
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
RocDec::from_str_to_i128_unsafe(&"-3.9"),
|
RocDec::from_str_to_i128_unsafe("-3.9"),
|
||||||
i128
|
i128
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -803,7 +803,7 @@ mod gen_num {
|
||||||
x * y * z
|
x * y * z
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
RocDec::from_str_to_i128_unsafe(&"48.0"),
|
RocDec::from_str_to_i128_unsafe("48.0"),
|
||||||
i128
|
i128
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1280,7 +1280,7 @@ fn linked_list_singleton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn recursive_functon_with_rigid() {
|
fn recursive_function_with_rigid() {
|
||||||
assert_non_opt_evals_to!(
|
assert_non_opt_evals_to!(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub fn helper<'a>(
|
||||||
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
||||||
arena,
|
arena,
|
||||||
filename,
|
filename,
|
||||||
&module_src,
|
module_src,
|
||||||
stdlib,
|
stdlib,
|
||||||
src_dir,
|
src_dir,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
|
@ -211,7 +211,7 @@ pub fn helper<'a>(
|
||||||
|
|
||||||
// Compile and add all the Procs before adding main
|
// Compile and add all the Procs before adding main
|
||||||
let env = roc_gen_llvm::llvm::build::Env {
|
let env = roc_gen_llvm::llvm::build::Env {
|
||||||
arena: &arena,
|
arena,
|
||||||
builder: &builder,
|
builder: &builder,
|
||||||
dibuilder: &dibuilder,
|
dibuilder: &dibuilder,
|
||||||
compile_unit: &compile_unit,
|
compile_unit: &compile_unit,
|
||||||
|
@ -252,7 +252,7 @@ pub fn helper<'a>(
|
||||||
// Uncomment this to see the module's optimized LLVM instruction output:
|
// Uncomment this to see the module's optimized LLVM instruction output:
|
||||||
// env.module.print_to_stderr();
|
// env.module.print_to_stderr();
|
||||||
|
|
||||||
let lib = module_to_dylib(&env.module, &target, opt_level)
|
let lib = module_to_dylib(env.module, &target, opt_level)
|
||||||
.expect("Error loading compiled dylib for test");
|
.expect("Error loading compiled dylib for test");
|
||||||
|
|
||||||
(main_fn_name, delayed_errors.join("\n"), lib)
|
(main_fn_name, delayed_errors.join("\n"), lib)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
|
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
|
||||||
#![allow(clippy::large_enum_variant)]
|
#![allow(clippy::large_enum_variant)]
|
||||||
// we actually want to compare against the literal float bits
|
// we actually want to compare against the literal float bits
|
||||||
#![allow(clippy::clippy::float_cmp)]
|
#![allow(clippy::float_cmp)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate pretty_assertions;
|
extern crate pretty_assertions;
|
||||||
|
@ -100,7 +100,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
|
||||||
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
||||||
arena,
|
arena,
|
||||||
filename,
|
filename,
|
||||||
&module_src,
|
module_src,
|
||||||
&stdlib,
|
&stdlib,
|
||||||
src_dir,
|
src_dir,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
|
|
|
@ -452,7 +452,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
|
||||||
sorted_fields.sort_by(|(a, _), (b, _)| {
|
sorted_fields.sort_by(|(a, _), (b, _)| {
|
||||||
a.clone()
|
a.clone()
|
||||||
.as_string(interns, home)
|
.as_string(interns, home)
|
||||||
.cmp(&b.as_string(&interns, home))
|
.cmp(&b.as_string(interns, home))
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut any_written_yet = false;
|
let mut any_written_yet = false;
|
||||||
|
@ -464,7 +464,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
|
||||||
any_written_yet = true;
|
any_written_yet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.push_str(&label.as_string(&interns, home));
|
buf.push_str(&label.as_string(interns, home));
|
||||||
|
|
||||||
for var in vars {
|
for var in vars {
|
||||||
buf.push(' ');
|
buf.push(' ');
|
||||||
|
@ -496,7 +496,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
|
||||||
|
|
||||||
buf.push_str("[ ");
|
buf.push_str("[ ");
|
||||||
|
|
||||||
buf.push_str(&tag_name.as_string(&interns, home));
|
buf.push_str(&tag_name.as_string(interns, home));
|
||||||
|
|
||||||
buf.push_str(" ]");
|
buf.push_str(" ]");
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
|
||||||
} else {
|
} else {
|
||||||
any_written_yet = true;
|
any_written_yet = true;
|
||||||
}
|
}
|
||||||
buf.push_str(&label.as_string(&interns, home));
|
buf.push_str(&label.as_string(interns, home));
|
||||||
|
|
||||||
for var in vars {
|
for var in vars {
|
||||||
buf.push(' ');
|
buf.push(' ');
|
||||||
|
@ -757,7 +757,7 @@ fn write_symbol(env: &Env, symbol: Symbol, buf: &mut String) {
|
||||||
// Don't qualify the symbol if it's in our home module,
|
// Don't qualify the symbol if it's in our home module,
|
||||||
// or if it's a builtin (since all their types are always in scope)
|
// or if it's a builtin (since all their types are always in scope)
|
||||||
if module_id != env.home && !module_id.is_builtin() {
|
if module_id != env.home && !module_id.is_builtin() {
|
||||||
buf.push_str(module_id.to_string(&interns));
|
buf.push_str(module_id.to_string(interns));
|
||||||
buf.push('.');
|
buf.push('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -513,11 +513,11 @@ pub fn to_type(
|
||||||
let mut new_args = Vec::with_capacity(args.len());
|
let mut new_args = Vec::with_capacity(args.len());
|
||||||
|
|
||||||
for arg in args {
|
for arg in args {
|
||||||
new_args.push(to_type(&arg, free_vars, var_store));
|
new_args.push(to_type(arg, free_vars, var_store));
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_ret = to_type(&ret, free_vars, var_store);
|
let new_ret = to_type(ret, free_vars, var_store);
|
||||||
let new_closure = to_type(&closure, free_vars, var_store);
|
let new_closure = to_type(closure, free_vars, var_store);
|
||||||
|
|
||||||
Type::Function(new_args, Box::new(new_closure), Box::new(new_ret))
|
Type::Function(new_args, Box::new(new_closure), Box::new(new_ret))
|
||||||
}
|
}
|
||||||
|
@ -525,13 +525,13 @@ pub fn to_type(
|
||||||
let mut new_args = Vec::with_capacity(args.len());
|
let mut new_args = Vec::with_capacity(args.len());
|
||||||
|
|
||||||
for arg in args {
|
for arg in args {
|
||||||
new_args.push(to_type(&arg, free_vars, var_store));
|
new_args.push(to_type(arg, free_vars, var_store));
|
||||||
}
|
}
|
||||||
|
|
||||||
Type::Apply(*symbol, new_args)
|
Type::Apply(*symbol, new_args)
|
||||||
}
|
}
|
||||||
Rigid(lowercase) => {
|
Rigid(lowercase) => {
|
||||||
if let Some(var) = free_vars.named_vars.get(&lowercase) {
|
if let Some(var) = free_vars.named_vars.get(lowercase) {
|
||||||
Type::Variable(*var)
|
Type::Variable(*var)
|
||||||
} else {
|
} else {
|
||||||
let var = var_store.fresh();
|
let var = var_store.fresh();
|
||||||
|
@ -552,9 +552,9 @@ pub fn to_type(
|
||||||
|
|
||||||
for (label, field) in fields {
|
for (label, field) in fields {
|
||||||
let field_val = match field {
|
let field_val = match field {
|
||||||
Required(typ) => Required(to_type(&typ, free_vars, var_store)),
|
Required(typ) => Required(to_type(typ, free_vars, var_store)),
|
||||||
Optional(typ) => Optional(to_type(&typ, free_vars, var_store)),
|
Optional(typ) => Optional(to_type(typ, free_vars, var_store)),
|
||||||
Demanded(typ) => Demanded(to_type(&typ, free_vars, var_store)),
|
Demanded(typ) => Demanded(to_type(typ, free_vars, var_store)),
|
||||||
};
|
};
|
||||||
|
|
||||||
new_fields.insert(label.clone(), field_val);
|
new_fields.insert(label.clone(), field_val);
|
||||||
|
|
|
@ -406,7 +406,7 @@ impl Type {
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Variable(v) => {
|
Variable(v) => {
|
||||||
if let Some(replacement) = substitutions.get(&v) {
|
if let Some(replacement) = substitutions.get(v) {
|
||||||
*self = replacement.clone();
|
*self = replacement.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,15 +762,15 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet<Symbol>) {
|
||||||
|
|
||||||
match tipe {
|
match tipe {
|
||||||
Function(args, closure, ret) => {
|
Function(args, closure, ret) => {
|
||||||
symbols_help(&ret, accum);
|
symbols_help(ret, accum);
|
||||||
symbols_help(&closure, accum);
|
symbols_help(closure, accum);
|
||||||
args.iter().for_each(|arg| symbols_help(arg, accum));
|
args.iter().for_each(|arg| symbols_help(arg, accum));
|
||||||
}
|
}
|
||||||
FunctionOrTagUnion(_, _, ext) => {
|
FunctionOrTagUnion(_, _, ext) => {
|
||||||
symbols_help(&ext, accum);
|
symbols_help(ext, accum);
|
||||||
}
|
}
|
||||||
RecursiveTagUnion(_, tags, ext) | TagUnion(tags, ext) => {
|
RecursiveTagUnion(_, tags, ext) | TagUnion(tags, ext) => {
|
||||||
symbols_help(&ext, accum);
|
symbols_help(ext, accum);
|
||||||
tags.iter()
|
tags.iter()
|
||||||
.map(|v| v.1.iter())
|
.map(|v| v.1.iter())
|
||||||
.flatten()
|
.flatten()
|
||||||
|
@ -778,7 +778,7 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet<Symbol>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Record(fields, ext) => {
|
Record(fields, ext) => {
|
||||||
symbols_help(&ext, accum);
|
symbols_help(ext, accum);
|
||||||
fields.values().for_each(|field| {
|
fields.values().for_each(|field| {
|
||||||
use RecordField::*;
|
use RecordField::*;
|
||||||
|
|
||||||
|
@ -791,11 +791,11 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet<Symbol>) {
|
||||||
}
|
}
|
||||||
Alias(alias_symbol, _, actual_type) => {
|
Alias(alias_symbol, _, actual_type) => {
|
||||||
accum.insert(*alias_symbol);
|
accum.insert(*alias_symbol);
|
||||||
symbols_help(&actual_type, accum);
|
symbols_help(actual_type, accum);
|
||||||
}
|
}
|
||||||
HostExposedAlias { name, actual, .. } => {
|
HostExposedAlias { name, actual, .. } => {
|
||||||
accum.insert(*name);
|
accum.insert(*name);
|
||||||
symbols_help(&actual, accum);
|
symbols_help(actual, accum);
|
||||||
}
|
}
|
||||||
Apply(symbol, args) => {
|
Apply(symbol, args) => {
|
||||||
accum.insert(*symbol);
|
accum.insert(*symbol);
|
||||||
|
|
|
@ -177,7 +177,7 @@ fn unify_alias(
|
||||||
match other_content {
|
match other_content {
|
||||||
FlexVar(_) => {
|
FlexVar(_) => {
|
||||||
// Alias wins
|
// Alias wins
|
||||||
merge(subs, &ctx, Alias(symbol, args.to_owned(), real_var))
|
merge(subs, ctx, Alias(symbol, args.to_owned(), real_var))
|
||||||
}
|
}
|
||||||
RecursionVar { structure, .. } => unify_pool(subs, pool, real_var, *structure),
|
RecursionVar { structure, .. } => unify_pool(subs, pool, real_var, *structure),
|
||||||
RigidVar(_) => unify_pool(subs, pool, real_var, ctx.second),
|
RigidVar(_) => unify_pool(subs, pool, real_var, ctx.second),
|
||||||
|
@ -190,7 +190,7 @@ fn unify_alias(
|
||||||
}
|
}
|
||||||
|
|
||||||
if problems.is_empty() {
|
if problems.is_empty() {
|
||||||
problems.extend(merge(subs, &ctx, other_content.clone()));
|
problems.extend(merge(subs, ctx, other_content.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if problems.is_empty() {
|
if problems.is_empty() {
|
||||||
|
|
|
@ -145,7 +145,7 @@ fn render_main_content(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_annotation_to_html(0, &mut content, &type_ann);
|
type_annotation_to_html(0, &mut content, type_ann);
|
||||||
|
|
||||||
buf.push_str(
|
buf.push_str(
|
||||||
html_node(
|
html_node(
|
||||||
|
@ -218,17 +218,17 @@ fn render_name_and_version(name: &str, version: &str) -> String {
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut verions_href = String::new();
|
let mut versions_href = String::new();
|
||||||
|
|
||||||
verions_href.push('/');
|
versions_href.push('/');
|
||||||
verions_href.push_str(name);
|
versions_href.push_str(name);
|
||||||
verions_href.push('/');
|
versions_href.push('/');
|
||||||
verions_href.push_str(version);
|
versions_href.push_str(version);
|
||||||
|
|
||||||
buf.push_str(
|
buf.push_str(
|
||||||
html_node(
|
html_node(
|
||||||
"a",
|
"a",
|
||||||
vec![("class", "version"), ("href", verions_href.as_str())],
|
vec![("class", "version"), ("href", versions_href.as_str())],
|
||||||
version,
|
version,
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
|
@ -541,7 +541,7 @@ fn should_be_multiline(type_ann: &TypeAnnotation) -> bool {
|
||||||
if is_multiline {
|
if is_multiline {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
is_multiline = should_be_multiline(&value);
|
is_multiline = should_be_multiline(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl Lines for CodeLines {
|
||||||
fn get_line(&self, line_nr: usize) -> UIResult<&str> {
|
fn get_line(&self, line_nr: usize) -> UIResult<&str> {
|
||||||
let line_string = slice_get(line_nr, &self.lines)?;
|
let line_string = slice_get(line_nr, &self.lines)?;
|
||||||
|
|
||||||
Ok(&line_string)
|
Ok(line_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn line_len(&self, line_nr: usize) -> UIResult<usize> {
|
fn line_len(&self, line_nr: usize) -> UIResult<usize> {
|
||||||
|
@ -85,7 +85,7 @@ impl Lines for CodeLines {
|
||||||
let mut lines = BumpString::with_capacity_in(self.nr_of_chars(), arena);
|
let mut lines = BumpString::with_capacity_in(self.nr_of_chars(), arena);
|
||||||
|
|
||||||
for line in &self.lines {
|
for line in &self.lines {
|
||||||
lines.push_str(&line);
|
lines.push_str(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
lines
|
lines
|
||||||
|
|
|
@ -194,7 +194,7 @@ fn color_backtrace(backtrace: &snafu::Backtrace) -> String {
|
||||||
|
|
||||||
for line in backtrace_split {
|
for line in backtrace_split {
|
||||||
let new_line = if line.contains("src") {
|
let new_line = if line.contains("src") {
|
||||||
if !contains_one_of(&line, &irrelevant_src) {
|
if !contains_one_of(line, &irrelevant_src) {
|
||||||
if let Some(prev_line) = prev_line_opt {
|
if let Some(prev_line) = prev_line_opt {
|
||||||
prev_line_opt = Some(format!("{}", prev_line.truecolor(255, 30, 30)));
|
prev_line_opt = Some(format!("{}", prev_line.truecolor(255, 30, 30)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl MarkupNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let closest_ast_child = slice_get(best_index, &children_ids)?;
|
let closest_ast_child = slice_get(best_index, children_ids)?;
|
||||||
|
|
||||||
let closest_ast_child_index =
|
let closest_ast_child_index =
|
||||||
index_of(*closest_ast_child, &child_ids_with_ast)?;
|
index_of(*closest_ast_child, &child_ids_with_ast)?;
|
||||||
|
@ -259,7 +259,7 @@ pub fn expr2_to_markup<'a, 'b>(
|
||||||
| Expr2::I128 { text, .. }
|
| Expr2::I128 { text, .. }
|
||||||
| Expr2::U128 { text, .. }
|
| Expr2::U128 { text, .. }
|
||||||
| Expr2::Float { text, .. } => {
|
| Expr2::Float { text, .. } => {
|
||||||
let num_str = get_string(env, &text);
|
let num_str = get_string(env, text);
|
||||||
|
|
||||||
new_markup_node(
|
new_markup_node(
|
||||||
num_str,
|
num_str,
|
||||||
|
@ -275,7 +275,7 @@ pub fn expr2_to_markup<'a, 'b>(
|
||||||
markup_node_pool,
|
markup_node_pool,
|
||||||
),
|
),
|
||||||
Expr2::GlobalTag { name, .. } => new_markup_node(
|
Expr2::GlobalTag { name, .. } => new_markup_node(
|
||||||
get_string(env, &name),
|
get_string(env, name),
|
||||||
expr2_node_id,
|
expr2_node_id,
|
||||||
HighlightStyle::Type,
|
HighlightStyle::Type,
|
||||||
markup_node_pool,
|
markup_node_pool,
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub fn init_model<'a>(
|
||||||
interns: &'a Interns,
|
interns: &'a Interns,
|
||||||
code_arena: &'a Bump,
|
code_arena: &'a Bump,
|
||||||
) -> EdResult<EdModel<'a>> {
|
) -> EdResult<EdModel<'a>> {
|
||||||
let mut module = EdModule::new(&code_str, env, code_arena)?;
|
let mut module = EdModule::new(code_str, env, code_arena)?;
|
||||||
|
|
||||||
let ast_root_id = module.ast_root_id;
|
let ast_root_id = module.ast_root_id;
|
||||||
let mut markup_node_pool = SlowPool::new();
|
let mut markup_node_pool = SlowPool::new();
|
||||||
|
@ -175,7 +175,7 @@ impl<'a> EdModule<'a> {
|
||||||
|
|
||||||
let region = Region::new(0, 0, 0, 0);
|
let region = Region::new(0, 0, 0, 0);
|
||||||
|
|
||||||
let expr2_result = str_to_expr2(&ast_arena, &code_str, &mut env, &mut scope, region);
|
let expr2_result = str_to_expr2(ast_arena, code_str, &mut env, &mut scope, region);
|
||||||
|
|
||||||
match expr2_result {
|
match expr2_result {
|
||||||
Ok((expr2, _output)) => {
|
Ok((expr2, _output)) => {
|
||||||
|
@ -239,7 +239,7 @@ pub mod test_ed_model {
|
||||||
);
|
);
|
||||||
|
|
||||||
ed_model::init_model(
|
ed_model::init_model(
|
||||||
&code_str,
|
code_str,
|
||||||
file_path,
|
file_path,
|
||||||
env,
|
env,
|
||||||
&ed_model_refs.interns,
|
&ed_model_refs.interns,
|
||||||
|
|
|
@ -221,7 +221,7 @@ impl<'a> EdModel<'a> {
|
||||||
if self.grid_node_map.node_exists_at_pos(caret_pos) {
|
if self.grid_node_map.node_exists_at_pos(caret_pos) {
|
||||||
let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self
|
let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self
|
||||||
.grid_node_map
|
.grid_node_map
|
||||||
.get_expr_start_end_pos(self.get_caret(), &self)?;
|
.get_expr_start_end_pos(self.get_caret(), self)?;
|
||||||
|
|
||||||
self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?;
|
self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?;
|
||||||
} else if self
|
} else if self
|
||||||
|
@ -230,7 +230,7 @@ impl<'a> EdModel<'a> {
|
||||||
{
|
{
|
||||||
let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self
|
let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self
|
||||||
.grid_node_map
|
.grid_node_map
|
||||||
.get_expr_start_end_pos(self.get_caret().decrement_col(), &self)?;
|
.get_expr_start_end_pos(self.get_caret().decrement_col(), self)?;
|
||||||
|
|
||||||
self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?;
|
self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ impl<'a> EdModel<'a> {
|
||||||
let constrained = constrain_expr(
|
let constrained = constrain_expr(
|
||||||
&arena,
|
&arena,
|
||||||
&mut self.module.env,
|
&mut self.module.env,
|
||||||
&expr,
|
expr,
|
||||||
Expected::NoExpectation(Type2::Variable(var)),
|
Expected::NoExpectation(Type2::Variable(var)),
|
||||||
Region::zero(),
|
Region::zero(),
|
||||||
);
|
);
|
||||||
|
@ -275,7 +275,7 @@ impl<'a> EdModel<'a> {
|
||||||
let content = subs.get(var).content;
|
let content = subs.get(var).content;
|
||||||
|
|
||||||
PoolStr::new(
|
PoolStr::new(
|
||||||
&content_to_string(content, &subs, self.module.env.home, self.interns),
|
&content_to_string(content, subs, self.module.env.home, self.interns),
|
||||||
self.module.env.pool,
|
self.module.env.pool,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -605,7 +605,7 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||||
}
|
}
|
||||||
Expr2::SmallStr(old_arr_str) => {
|
Expr2::SmallStr(old_arr_str) => {
|
||||||
update_small_string(
|
update_small_string(
|
||||||
&ch, old_arr_str, ed_model
|
ch, old_arr_str, ed_model
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
Expr2::Str(old_pool_str) => {
|
Expr2::Str(old_pool_str) => {
|
||||||
|
@ -2043,11 +2043,11 @@ pub mod test_ed_update {
|
||||||
expected_tooltip: &str,
|
expected_tooltip: &str,
|
||||||
new_char: char,
|
new_char: char,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
assert_type_tooltips_seq(pre_lines, &vec![expected_tooltip], &new_char.to_string())
|
assert_type_tooltips_seq(pre_lines, &[expected_tooltip], &new_char.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assert_type_tooltip_clean(lines: &[&str], expected_tooltip: &str) -> Result<(), String> {
|
pub fn assert_type_tooltip_clean(lines: &[&str], expected_tooltip: &str) -> Result<(), String> {
|
||||||
assert_type_tooltips_seq(lines, &vec![expected_tooltip], "")
|
assert_type_tooltips_seq(lines, &[expected_tooltip], "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// When doing ctrl+shift+up multiple times we select the surrounding expression every time,
|
// When doing ctrl+shift+up multiple times we select the surrounding expression every time,
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn start_new_int(ed_model: &mut EdModel, digit_char: &char) -> EdResult<Inpu
|
||||||
curr_mark_node,
|
curr_mark_node,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
let is_blank_node = curr_mark_node.is_blank();
|
let is_blank_node = curr_mark_node.is_blank();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn start_new_list(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
curr_mark_node,
|
curr_mark_node,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
let is_blank_node = curr_mark_node.is_blank();
|
let is_blank_node = curr_mark_node.is_blank();
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ pub fn add_blank_child(
|
||||||
curr_mark_node: _,
|
curr_mark_node: _,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
let trip_result: EdResult<(ExprId, ExprId, MarkNodeId)> = if let Some(parent_id) = parent_id_opt
|
let trip_result: EdResult<(ExprId, ExprId, MarkNodeId)> = if let Some(parent_id) = parent_id_opt
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub fn start_new_record(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
curr_mark_node,
|
curr_mark_node,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
let is_blank_node = curr_mark_node.is_blank();
|
let is_blank_node = curr_mark_node.is_blank();
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ pub fn update_empty_record(
|
||||||
curr_mark_node,
|
curr_mark_node,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
if prev_mark_node.get_content()? == nodes::LEFT_ACCOLADE
|
if prev_mark_node.get_content()? == nodes::LEFT_ACCOLADE
|
||||||
&& curr_mark_node.get_content()? == nodes::RIGHT_ACCOLADE
|
&& curr_mark_node.get_content()? == nodes::RIGHT_ACCOLADE
|
||||||
|
@ -182,7 +182,7 @@ pub fn update_record_colon(
|
||||||
curr_mark_node,
|
curr_mark_node,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
if let Some(parent_id) = parent_id_opt {
|
if let Some(parent_id) = parent_id_opt {
|
||||||
let curr_ast_node = ed_model.module.env.pool.get(ast_node_id);
|
let curr_ast_node = ed_model.module.env.pool.get(ast_node_id);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn update_small_string(
|
||||||
curr_mark_node: _,
|
curr_mark_node: _,
|
||||||
parent_id_opt: _,
|
parent_id_opt: _,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
let new_input = &new_char.to_string();
|
let new_input = &new_char.to_string();
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ pub fn update_string(
|
||||||
curr_mark_node: _,
|
curr_mark_node: _,
|
||||||
parent_id_opt: _,
|
parent_id_opt: _,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
// update markup
|
// update markup
|
||||||
let curr_mark_node_mut = ed_model.markup_node_pool.get_mut(curr_mark_node_id);
|
let curr_mark_node_mut = ed_model.markup_node_pool.get_mut(curr_mark_node_id);
|
||||||
|
@ -129,7 +129,7 @@ pub fn start_new_string(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
curr_mark_node,
|
curr_mark_node,
|
||||||
parent_id_opt,
|
parent_id_opt,
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
} = get_node_context(&ed_model)?;
|
} = get_node_context(ed_model)?;
|
||||||
|
|
||||||
if curr_mark_node.is_blank() {
|
if curr_mark_node.is_blank() {
|
||||||
let new_expr2_node = Expr2::SmallStr(arraystring::ArrayString::new());
|
let new_expr2_node = Expr2::SmallStr(arraystring::ArrayString::new());
|
||||||
|
|
|
@ -108,7 +108,7 @@ fn markup_to_wgpu_helper<'a>(
|
||||||
attributes: _,
|
attributes: _,
|
||||||
parent_id_opt: _,
|
parent_id_opt: _,
|
||||||
} => {
|
} => {
|
||||||
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, &syn_high_style)?;
|
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, syn_high_style)?;
|
||||||
|
|
||||||
let glyph_text = glyph_brush::OwnedText::new(content)
|
let glyph_text = glyph_brush::OwnedText::new(content)
|
||||||
.with_color(colors::to_slice(*highlight_color))
|
.with_color(colors::to_slice(*highlight_color))
|
||||||
|
@ -127,7 +127,7 @@ fn markup_to_wgpu_helper<'a>(
|
||||||
.with_color(colors::to_slice(colors::WHITE))
|
.with_color(colors::to_slice(colors::WHITE))
|
||||||
.with_scale(code_style.font_size);
|
.with_scale(code_style.font_size);
|
||||||
|
|
||||||
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, &syn_high_style)?;
|
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, syn_high_style)?;
|
||||||
|
|
||||||
let char_width = code_style.glyph_dim_rect.width;
|
let char_width = code_style.glyph_dim_rect.width;
|
||||||
let char_height = code_style.glyph_dim_rect.height;
|
let char_height = code_style.glyph_dim_rect.height;
|
||||||
|
|
|
@ -121,10 +121,10 @@ pub fn create_rect_buffers(
|
||||||
let num_rects = {
|
let num_rects = {
|
||||||
let mut quad_buffer_builder = QuadBufferBuilder::new();
|
let mut quad_buffer_builder = QuadBufferBuilder::new();
|
||||||
for rect in rects {
|
for rect in rects {
|
||||||
quad_buffer_builder = quad_buffer_builder.push_rect(&rect);
|
quad_buffer_builder = quad_buffer_builder.push_rect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (stg_vertex, stg_index, num_indices) = quad_buffer_builder.build(&gpu_device);
|
let (stg_vertex, stg_index, num_indices) = quad_buffer_builder.build(gpu_device);
|
||||||
|
|
||||||
stg_vertex.copy_to_buffer(encoder, &vertex_buffer);
|
stg_vertex.copy_to_buffer(encoder, &vertex_buffer);
|
||||||
stg_index.copy_to_buffer(encoder, &index_buffer);
|
stg_index.copy_to_buffer(encoder, &index_buffer);
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn make_rect_pipeline(
|
||||||
label: Some("Rectangle pipeline layout"),
|
label: Some("Rectangle pipeline layout"),
|
||||||
});
|
});
|
||||||
let pipeline = create_render_pipeline(
|
let pipeline = create_render_pipeline(
|
||||||
&gpu_device,
|
gpu_device,
|
||||||
&pipeline_layout,
|
&pipeline_layout,
|
||||||
swap_chain_descr.format,
|
swap_chain_descr.format,
|
||||||
&wgpu::ShaderModuleDescriptor {
|
&wgpu::ShaderModuleDescriptor {
|
||||||
|
@ -42,7 +42,7 @@ pub fn create_render_pipeline(
|
||||||
|
|
||||||
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Render pipeline"),
|
label: Some("Render pipeline"),
|
||||||
layout: Some(&layout),
|
layout: Some(layout),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
|
|
@ -81,7 +81,7 @@ fn section_from_text<'a>(
|
||||||
..Section::default()
|
..Section::default()
|
||||||
}
|
}
|
||||||
.add_text(
|
.add_text(
|
||||||
wgpu_glyph::Text::new(&text.text)
|
wgpu_glyph::Text::new(text.text)
|
||||||
.with_color(Vector4::from(text.color))
|
.with_color(Vector4::from(text.color))
|
||||||
.with_scale(text.size),
|
.with_scale(text.size),
|
||||||
)
|
)
|
||||||
|
@ -156,5 +156,5 @@ pub fn build_glyph_brush(
|
||||||
) -> Result<GlyphBrush<()>, InvalidFont> {
|
) -> Result<GlyphBrush<()>, InvalidFont> {
|
||||||
let inconsolata = FontArc::try_from_slice(include_bytes!("../../../Inconsolata-Regular.ttf"))?;
|
let inconsolata = FontArc::try_from_slice(include_bytes!("../../../Inconsolata-Regular.ttf"))?;
|
||||||
|
|
||||||
Ok(GlyphBrushBuilder::using_font(inconsolata).build(&gpu_device, render_format))
|
Ok(GlyphBrushBuilder::using_font(inconsolata).build(gpu_device, render_format))
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,7 +472,7 @@ fn expr2_to_string_helper(
|
||||||
Expr2::EmptyRecord => out_string.push_str("EmptyRecord"),
|
Expr2::EmptyRecord => out_string.push_str("EmptyRecord"),
|
||||||
Expr2::Record { record_var, fields } => {
|
Expr2::Record { record_var, fields } => {
|
||||||
out_string.push_str("Record:\n");
|
out_string.push_str("Record:\n");
|
||||||
out_string.push_str(&var_to_string(&record_var, indent_level + 1));
|
out_string.push_str(&var_to_string(record_var, indent_level + 1));
|
||||||
|
|
||||||
out_string.push_str(&format!("{}fields: [\n", get_spacing(indent_level + 1)));
|
out_string.push_str(&format!("{}fields: [\n", get_spacing(indent_level + 1)));
|
||||||
|
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ fn constrain_when_branch<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This accepts PatternState (rather than returning it) so that the caller can
|
/// This accepts PatternState (rather than returning it) so that the caller can
|
||||||
/// intiialize the Vecs in PatternState using with_capacity
|
/// initialize the Vecs in PatternState using with_capacity
|
||||||
/// based on its knowledge of their lengths.
|
/// based on its knowledge of their lengths.
|
||||||
pub fn constrain_pattern<'a>(
|
pub fn constrain_pattern<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
|
@ -1129,7 +1129,7 @@ pub fn constrain_pattern<'a>(
|
||||||
let pat_type = Type2::Variable(*var);
|
let pat_type = Type2::Variable(*var);
|
||||||
let expected = PExpected::NoExpectation(pat_type.shallow_clone());
|
let expected = PExpected::NoExpectation(pat_type.shallow_clone());
|
||||||
|
|
||||||
if !state.headers.contains_key(&symbol) {
|
if !state.headers.contains_key(symbol) {
|
||||||
state.headers.insert(*symbol, pat_type.shallow_clone());
|
state.headers.insert(*symbol, pat_type.shallow_clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,11 @@ impl<'a> File<'a> {
|
||||||
let allocation = arena.alloc(bytes);
|
let allocation = arena.alloc(bytes);
|
||||||
|
|
||||||
let module_parse_state = parser::State::new(allocation);
|
let module_parse_state = parser::State::new(allocation);
|
||||||
let parsed_module = roc_parse::module::parse_header(&arena, module_parse_state);
|
let parsed_module = roc_parse::module::parse_header(arena, module_parse_state);
|
||||||
|
|
||||||
match parsed_module {
|
match parsed_module {
|
||||||
Ok((module, state)) => {
|
Ok((module, state)) => {
|
||||||
let parsed_defs = module_defs().parse(&arena, state);
|
let parsed_defs = module_defs().parse(arena, state);
|
||||||
|
|
||||||
match parsed_defs {
|
match parsed_defs {
|
||||||
Ok((_, defs, _)) => Ok(File {
|
Ok((_, defs, _)) => Ok(File {
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl Pools {
|
||||||
pub fn split_last(&self) -> (&Vec<Variable>, &[Vec<Variable>]) {
|
pub fn split_last(&self) -> (&Vec<Variable>, &[Vec<Variable>]) {
|
||||||
self.0
|
self.0
|
||||||
.split_last()
|
.split_last()
|
||||||
.unwrap_or_else(|| panic!("Attempted to split_last() on non-empy Pools"))
|
.unwrap_or_else(|| panic!("Attempted to split_last() on non-empty Pools"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extend_to(&mut self, n: usize) {
|
pub fn extend_to(&mut self, n: usize) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl<'a> ToolTip<'a> {
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
color: ui_theme.tooltip_text,
|
color: ui_theme.tooltip_text,
|
||||||
text: &self.text,
|
text: self.text,
|
||||||
size: ui_theme.default_font_size,
|
size: ui_theme.default_font_size,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ fn infer_eq(actual: &str, expected_str: &str) {
|
||||||
all_ident_ids: dep_idents,
|
all_ident_ids: dep_idents,
|
||||||
};
|
};
|
||||||
|
|
||||||
let actual_str = content_to_string(content, &subs, mod_id, &interns);
|
let actual_str = content_to_string(content, subs, mod_id, &interns);
|
||||||
|
|
||||||
assert_eq!(actual_str, expected_str);
|
assert_eq!(actual_str, expected_str);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ can write (it would be plain Roc code, but with some extra keywords that aren't
|
||||||
available in normal modules - kinda like `port module` in Elm), and which
|
available in normal modules - kinda like `port module` in Elm), and which
|
||||||
describe both the Roc-host/C boundary as well as the Roc-host/Roc-app boundary.
|
describe both the Roc-host/C boundary as well as the Roc-host/Roc-app boundary.
|
||||||
Roc application authors only care about the Roc-host/Roc-app portion, and the
|
Roc application authors only care about the Roc-host/Roc-app portion, and the
|
||||||
host author only cares about the Roc-host/C bounary when implementing the host.
|
host author only cares about the Roc-host/C boundary when implementing the host.
|
||||||
|
|
||||||
Using this glue code, the Roc compiler can generate C header files describing the
|
Using this glue code, the Roc compiler can generate C header files describing the
|
||||||
boundary. This not only gets us host compatibility with C compilers, but also
|
boundary. This not only gets us host compatibility with C compilers, but also
|
||||||
|
|
|
@ -40,7 +40,7 @@ can write (it would be plain Roc code, but with some extra keywords that aren't
|
||||||
available in normal modules - kinda like `port module` in Elm), and which
|
available in normal modules - kinda like `port module` in Elm), and which
|
||||||
describe both the Roc-host/C boundary as well as the Roc-host/Roc-app boundary.
|
describe both the Roc-host/C boundary as well as the Roc-host/Roc-app boundary.
|
||||||
Roc application authors only care about the Roc-host/Roc-app portion, and the
|
Roc application authors only care about the Roc-host/Roc-app portion, and the
|
||||||
host author only cares about the Roc-host/C bounary when implementing the host.
|
host author only cares about the Roc-host/C boundary when implementing the host.
|
||||||
|
|
||||||
Using this glue code, the Roc compiler can generate C header files describing the
|
Using this glue code, the Roc compiler can generate C header files describing the
|
||||||
boundary. This not only gets us host compatibility with C compilers, but also
|
boundary. This not only gets us host compatibility with C compilers, but also
|
||||||
|
|
|
@ -437,7 +437,7 @@ when error is
|
||||||
|
|
||||||
# File.WriteErr possibilities
|
# File.WriteErr possibilities
|
||||||
DirectoryNotFound -> ...
|
DirectoryNotFound -> ...
|
||||||
WriteAcessDenied -> ...
|
WriteAccessDenied -> ...
|
||||||
DiskFull -> ...
|
DiskFull -> ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ Dict.fromList [ KV "Sam" True, KV "Ali" False KV firstName False
|
||||||
|
|
||||||
This works, but is not nearly as nice to read.
|
This works, but is not nearly as nice to read.
|
||||||
|
|
||||||
Additionally, map literals can compile direcly to efficient initialization code
|
Additionally, map literals can compile directly to efficient initialization code
|
||||||
without needing to (hopefully be able to) optimize away the intermediate
|
without needing to (hopefully be able to) optimize away the intermediate
|
||||||
`List` involved in `fromList`.
|
`List` involved in `fromList`.
|
||||||
|
|
||||||
|
@ -969,7 +969,7 @@ test "it works"
|
||||||
This is convenient with higher-order functions which take a function as their
|
This is convenient with higher-order functions which take a function as their
|
||||||
final argument. Since many Roc functions have the same type as Elm functions
|
final argument. Since many Roc functions have the same type as Elm functions
|
||||||
except with their arguments flipped, this means it's possible to end a lot
|
except with their arguments flipped, this means it's possible to end a lot
|
||||||
of expessions with anonymous functions - e.g.
|
of expressions with anonymous functions - e.g.
|
||||||
|
|
||||||
```elm
|
```elm
|
||||||
modifiedNums =
|
modifiedNums =
|
||||||
|
@ -1357,7 +1357,7 @@ are all unions containing a single tag. That means they hold no information at r
|
||||||
that is, discarded prior to code generation.
|
that is, discarded prior to code generation.
|
||||||
|
|
||||||
During code generation, Roc treats `Quantity [ Km ] Int` as equivalent to `Quantity Int`.
|
During code generation, Roc treats `Quantity [ Km ] Int` as equivalent to `Quantity Int`.
|
||||||
Then, becaue `Quantity Int` is an alias for `[ Quantity Int ]`, it will unbox again
|
Then, because `Quantity Int` is an alias for `[ Quantity Int ]`, it will unbox again
|
||||||
and reduce that all the way down to to `Int`.
|
and reduce that all the way down to to `Int`.
|
||||||
|
|
||||||
This means that, just like phantom *types*, phantom *values* affect type checking
|
This means that, just like phantom *types*, phantom *values* affect type checking
|
||||||
|
|
4
vendor/morphic_lib/src/api.rs
vendored
4
vendor/morphic_lib/src/api.rs
vendored
|
@ -1612,7 +1612,7 @@ fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) {
|
||||||
|
|
||||||
fn hash_func_name(mod_: ModName, func: FuncName) -> FuncSpec {
|
fn hash_func_name(mod_: ModName, func: FuncName) -> FuncSpec {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
hash_bstr(&mut hasher, &mod_.0);
|
hash_bstr(&mut hasher, mod_.0);
|
||||||
hash_bstr(&mut hasher, &func.0);
|
hash_bstr(&mut hasher, func.0);
|
||||||
FuncSpec(hasher.finalize().into())
|
FuncSpec(hasher.finalize().into())
|
||||||
}
|
}
|
||||||
|
|
8
vendor/morphic_lib/src/preprocess.rs
vendored
8
vendor/morphic_lib/src/preprocess.rs
vendored
|
@ -679,8 +679,8 @@ fn preprocess_block_expr(
|
||||||
values_in_scope,
|
values_in_scope,
|
||||||
continuations_in_scope,
|
continuations_in_scope,
|
||||||
block,
|
block,
|
||||||
&api_node.op,
|
api_node.op,
|
||||||
&api_node.inputs,
|
api_node.inputs,
|
||||||
)
|
)
|
||||||
.map_err(Error::annotate_binding(BindingLocation::Value(
|
.map_err(Error::annotate_binding(BindingLocation::Value(
|
||||||
api_value_id,
|
api_value_id,
|
||||||
|
@ -1149,7 +1149,7 @@ fn preprocess_func_def(
|
||||||
let (final_block, ret_val) = preprocess_block_expr(
|
let (final_block, ret_val) = preprocess_block_expr(
|
||||||
tc,
|
tc,
|
||||||
ctx,
|
ctx,
|
||||||
&api_builder,
|
api_builder,
|
||||||
body_types,
|
body_types,
|
||||||
&mut graph_builder,
|
&mut graph_builder,
|
||||||
&mut values_in_scope,
|
&mut values_in_scope,
|
||||||
|
@ -1183,7 +1183,7 @@ fn preprocess_const_def(
|
||||||
let (final_block, ret_val) = preprocess_block_expr(
|
let (final_block, ret_val) = preprocess_block_expr(
|
||||||
tc,
|
tc,
|
||||||
ctx,
|
ctx,
|
||||||
&api_builder,
|
api_builder,
|
||||||
body_types,
|
body_types,
|
||||||
&mut graph_builder,
|
&mut graph_builder,
|
||||||
&mut values_in_scope,
|
&mut values_in_scope,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue