mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Fixup compile errors
This commit is contained in:
parent
51978e08ed
commit
5f8b509cb3
3 changed files with 45 additions and 14 deletions
|
@ -23,7 +23,7 @@ pub fn load_types(
|
|||
mut type_problems,
|
||||
mut declarations_by_id,
|
||||
mut solved,
|
||||
interns,
|
||||
mut interns,
|
||||
..
|
||||
} = roc_load::load_and_typecheck(
|
||||
arena,
|
||||
|
@ -74,7 +74,7 @@ pub fn load_types(
|
|||
let types_and_targets = Architecture::iter()
|
||||
.map(|arch| {
|
||||
let target_info = arch.into();
|
||||
let mut env = Env::new(arena, subs, &interns, target_info);
|
||||
let mut env = Env::new(home, arena, subs, &mut interns, target_info);
|
||||
|
||||
(env.vars_to_types(variables.clone()), target_info)
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ use roc_builtins::bitcode::{
|
|||
IntWidth::{self, *},
|
||||
};
|
||||
use roc_collections::VecMap;
|
||||
use roc_module::symbol::{Interns, Symbol};
|
||||
use roc_module::symbol::{Interns, ModuleId, Symbol};
|
||||
use roc_mono::layout::{
|
||||
cmp_fields, ext_var_is_empty_tag_union, round_up_to_alignment, Builtin, Layout, LayoutCache,
|
||||
UnionLayout,
|
||||
|
@ -410,7 +410,8 @@ pub struct Env<'a> {
|
|||
arena: &'a Bump,
|
||||
subs: &'a Subs,
|
||||
layout_cache: LayoutCache<'a>,
|
||||
interns: &'a Interns,
|
||||
home: ModuleId,
|
||||
interns: &'a mut Interns,
|
||||
struct_names: Structs,
|
||||
enum_names: Enums,
|
||||
pending_recursive_types: VecMap<TypeId, Layout<'a>>,
|
||||
|
@ -418,11 +419,32 @@ pub struct Env<'a> {
|
|||
target: TargetInfo,
|
||||
}
|
||||
|
||||
macro_rules! fresh_multimorphic_symbol {
|
||||
($env:expr) => {
|
||||
&mut || {
|
||||
let ident_id = $env
|
||||
.interns
|
||||
.all_ident_ids
|
||||
.get_mut(&$env.home)
|
||||
.unwrap()
|
||||
.gen_unique();
|
||||
Symbol::new($env.home, ident_id)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl<'a> Env<'a> {
|
||||
pub fn new(arena: &'a Bump, subs: &'a Subs, interns: &'a Interns, target: TargetInfo) -> Self {
|
||||
pub fn new(
|
||||
home: ModuleId,
|
||||
arena: &'a Bump,
|
||||
subs: &'a Subs,
|
||||
interns: &'a mut Interns,
|
||||
target: TargetInfo,
|
||||
) -> Self {
|
||||
Env {
|
||||
arena,
|
||||
subs,
|
||||
home,
|
||||
interns,
|
||||
struct_names: Default::default(),
|
||||
enum_names: Default::default(),
|
||||
|
@ -451,7 +473,7 @@ impl<'a> Env<'a> {
|
|||
fn add_type(&mut self, var: Variable, types: &mut Types) -> TypeId {
|
||||
let layout = self
|
||||
.layout_cache
|
||||
.from_var(self.arena, var, self.subs)
|
||||
.from_var(self.arena, var, self.subs, fresh_multimorphic_symbol!(self))
|
||||
.expect("Something weird ended up in the content");
|
||||
|
||||
add_type_help(self, layout, var, None, types)
|
||||
|
@ -587,7 +609,7 @@ fn add_type_help<'a>(
|
|||
let type_id = types.add(RocType::RecursivePointer(TypeId::PENDING), layout);
|
||||
let structure_layout = env
|
||||
.layout_cache
|
||||
.from_var(env.arena, *structure, subs)
|
||||
.from_var(env.arena, *structure, subs, fresh_multimorphic_symbol!(env))
|
||||
.unwrap();
|
||||
|
||||
env.pending_recursive_types
|
||||
|
@ -695,7 +717,7 @@ where
|
|||
label,
|
||||
field_var,
|
||||
env.layout_cache
|
||||
.from_var(env.arena, field_var, subs)
|
||||
.from_var(env.arena, field_var, subs, fresh_multimorphic_symbol!(env))
|
||||
.unwrap(),
|
||||
));
|
||||
}
|
||||
|
@ -765,7 +787,12 @@ fn add_tag_union<'a>(
|
|||
let payload_var = payload_vars.get(0).unwrap();
|
||||
let payload_layout = env
|
||||
.layout_cache
|
||||
.from_var(env.arena, *payload_var, env.subs)
|
||||
.from_var(
|
||||
env.arena,
|
||||
*payload_var,
|
||||
env.subs,
|
||||
fresh_multimorphic_symbol!(env),
|
||||
)
|
||||
.expect("Something weird ended up in the content");
|
||||
let payload_id = add_type_help(env, payload_layout, *payload_var, None, types);
|
||||
|
||||
|
@ -914,7 +941,10 @@ fn struct_fields_needed<I: IntoIterator<Item = Variable>>(env: &mut Env<'_>, var
|
|||
let arena = env.arena;
|
||||
|
||||
vars.into_iter().fold(0, |count, var| {
|
||||
let layout = env.layout_cache.from_var(arena, var, subs).unwrap();
|
||||
let layout = env
|
||||
.layout_cache
|
||||
.from_var(arena, var, subs, fresh_multimorphic_symbol!(env))
|
||||
.unwrap();
|
||||
|
||||
if layout.is_dropped_because_empty() {
|
||||
count
|
||||
|
|
|
@ -108,9 +108,9 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
|
|||
/// Size of the return value is statically determined from its Rust type
|
||||
/// The `transform` callback takes the app's memory and the returned value
|
||||
/// _main_fn_name is always the same and we don't use it here
|
||||
fn call_function<Return, F>(&self, _main_fn_name: &str, transform: F) -> Expr<'a>
|
||||
fn call_function<Return, F>(&self, _main_fn_name: &str, mut transform: F) -> Expr<'a>
|
||||
where
|
||||
F: Fn(&'a Self::Memory, Return) -> Expr<'a>,
|
||||
F: FnMut(&'a Self::Memory, Return) -> Expr<'a>,
|
||||
Self::Memory: 'a,
|
||||
{
|
||||
let app_final_memory_size: usize = js_run_app();
|
||||
|
@ -138,10 +138,10 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
|
|||
&self,
|
||||
_main_fn_name: &str,
|
||||
_ret_bytes: usize,
|
||||
transform: F,
|
||||
mut transform: F,
|
||||
) -> T
|
||||
where
|
||||
F: Fn(&'a Self::Memory, usize) -> T,
|
||||
F: FnMut(&'a Self::Memory, usize) -> T,
|
||||
Self::Memory: 'a,
|
||||
{
|
||||
let app_final_memory_size: usize = js_run_app();
|
||||
|
@ -251,6 +251,7 @@ pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
|
|||
main_fn_layout,
|
||||
content,
|
||||
&subs,
|
||||
module_id, interns.all_ident_ids.get_mut(&module_id).unwrap(),
|
||||
target_info,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue