use a Dependencies struct to track what the dependencies between modules are and when they are met

This commit is contained in:
Folkert 2020-10-10 19:29:10 +02:00
parent e1eb4ed4e5
commit 085c5f54de
5 changed files with 406 additions and 552 deletions

View file

@ -33,13 +33,13 @@ pub fn build_file(
OptLevel::Normal => roc_builtins::std::standard_stdlib(), OptLevel::Normal => roc_builtins::std::standard_stdlib(),
OptLevel::Optimize => roc_builtins::unique::uniq_stdlib(), OptLevel::Optimize => roc_builtins::unique::uniq_stdlib(),
}; };
let monomorphize = roc_load::file::Phases::Monomorphize; let solve_types = roc_load::file::Phase::SolveTypes;
let loaded = roc_load::file::load( let loaded = roc_load::file::load(
filename.clone(), filename.clone(),
&stdlib, stdlib,
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
monomorphize, solve_types,
)?; )?;
let dest_filename = filename.with_file_name("roc_app.o"); let dest_filename = filename.with_file_name("roc_app.o");
let buf = &mut String::with_capacity(1024); let buf = &mut String::with_capacity(1024);

View file

@ -12,6 +12,7 @@ pub enum Mode {
Uniqueness, Uniqueness,
} }
#[derive(Debug, Clone)]
pub struct StdLib { pub struct StdLib {
pub mode: Mode, pub mode: Mode,
pub types: MutMap<Symbol, (SolvedType, Region)>, pub types: MutMap<Symbol, (SolvedType, Region)>,

File diff suppressed because it is too large Load diff

View file

@ -19,12 +19,14 @@ mod test_load {
use roc_can::def::Def; use roc_can::def::Def;
use roc_collections::all::MutMap; use roc_collections::all::MutMap;
use roc_constrain::module::SubsByModule; use roc_constrain::module::SubsByModule;
use roc_load::file::{load, LoadedModule, Phases}; use roc_load::file::{load, LoadedModule, Phase};
use roc_module::symbol::{Interns, ModuleId}; use roc_module::symbol::{Interns, ModuleId};
use roc_types::pretty_print::{content_to_string, name_all_type_vars}; use roc_types::pretty_print::{content_to_string, name_all_type_vars};
use roc_types::subs::Subs; use roc_types::subs::Subs;
use std::collections::HashMap; use std::collections::HashMap;
const GOAL_PHASE: Phase = Phase::SolveTypes;
// HELPERS // HELPERS
fn load_fixture( fn load_fixture(
@ -36,10 +38,10 @@ mod test_load {
let filename = src_dir.join(format!("{}.roc", module_name)); let filename = src_dir.join(format!("{}.roc", module_name));
let loaded = load( let loaded = load(
filename, filename,
&roc_builtins::std::standard_stdlib(), roc_builtins::std::standard_stdlib(),
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
Phases::TypeCheck, GOAL_PHASE,
); );
let loaded_module = loaded.expect("Test module failed to load"); let loaded_module = loaded.expect("Test module failed to load");
@ -132,10 +134,10 @@ mod test_load {
let filename = src_dir.join("Primary.roc"); let filename = src_dir.join("Primary.roc");
let loaded = load( let loaded = load(
filename, filename,
&roc_builtins::std::standard_stdlib(), roc_builtins::std::standard_stdlib(),
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
Phases::TypeCheck, GOAL_PHASE,
); );
let mut loaded_module = loaded.expect("Test module failed to load"); let mut loaded_module = loaded.expect("Test module failed to load");

View file

@ -20,12 +20,14 @@ mod test_uniq_load {
use roc_can::def::Def; use roc_can::def::Def;
use roc_collections::all::MutMap; use roc_collections::all::MutMap;
use roc_constrain::module::SubsByModule; use roc_constrain::module::SubsByModule;
use roc_load::file::{load, LoadedModule, Phases}; use roc_load::file::{load, LoadedModule, Phase};
use roc_module::symbol::{Interns, ModuleId}; use roc_module::symbol::{Interns, ModuleId};
use roc_types::pretty_print::{content_to_string, name_all_type_vars}; use roc_types::pretty_print::{content_to_string, name_all_type_vars};
use roc_types::subs::Subs; use roc_types::subs::Subs;
use std::collections::HashMap; use std::collections::HashMap;
const GOAL_PHASE: Phase = Phase::SolveTypes;
// HELPERS // HELPERS
fn load_fixture( fn load_fixture(
@ -37,10 +39,10 @@ mod test_uniq_load {
let filename = src_dir.join(format!("{}.roc", module_name)); let filename = src_dir.join(format!("{}.roc", module_name));
let loaded = load( let loaded = load(
filename, filename,
&unique::uniq_stdlib(), unique::uniq_stdlib(),
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
Phases::TypeCheck, GOAL_PHASE,
); );
let loaded_module = loaded.expect("Test module failed to load"); let loaded_module = loaded.expect("Test module failed to load");
@ -132,10 +134,10 @@ mod test_uniq_load {
let filename = src_dir.join("Primary.roc"); let filename = src_dir.join("Primary.roc");
let loaded = load( let loaded = load(
filename, filename,
&roc_builtins::std::standard_stdlib(), roc_builtins::std::standard_stdlib(),
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
Phases::TypeCheck, GOAL_PHASE,
); );
let mut loaded_module = loaded.expect("Test module failed to load"); let mut loaded_module = loaded.expect("Test module failed to load");