mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
make SubsByModule opaque
This commit is contained in:
parent
52c056ad13
commit
c79ecec56e
@ -1,12 +1,11 @@
|
||||
use std::path::Path;
|
||||
|
||||
use bumpalo::Bump;
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_load::file::LoadedModule;
|
||||
use roc_target::TargetInfo;
|
||||
|
||||
pub fn load_module(src_file: &Path) -> LoadedModule {
|
||||
let subs_by_module = MutMap::default();
|
||||
let subs_by_module = Default::default();
|
||||
|
||||
let arena = Bump::new();
|
||||
let loaded = roc_load::file::load_and_typecheck(
|
||||
|
@ -4,7 +4,6 @@ use roc_build::{
|
||||
program,
|
||||
};
|
||||
use roc_builtins::bitcode;
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_load::file::LoadingProblem;
|
||||
use roc_mono::ir::OptLevel;
|
||||
use roc_target::TargetInfo;
|
||||
@ -61,7 +60,7 @@ pub fn build_file<'a>(
|
||||
let target_info = TargetInfo::from(target);
|
||||
|
||||
// Step 1: compile the app and generate the .o file
|
||||
let subs_by_module = MutMap::default();
|
||||
let subs_by_module = Default::default();
|
||||
|
||||
// Release builds use uniqueness optimizations
|
||||
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
|
||||
@ -366,7 +365,7 @@ pub fn check_file(
|
||||
let target_info = TargetInfo::default_x86_64();
|
||||
|
||||
// Step 1: compile the app and generate the .o file
|
||||
let subs_by_module = MutMap::default();
|
||||
let subs_by_module = Default::default();
|
||||
|
||||
// Release builds use uniqueness optimizations
|
||||
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
|
||||
|
@ -8,7 +8,20 @@ use roc_types::solved_types::{FreeVars, SolvedType};
|
||||
use roc_types::subs::{StorageSubs, VarStore, Variable};
|
||||
use roc_types::types::{Alias, Problem};
|
||||
|
||||
pub type SubsByModule = MutMap<ModuleId, ExposedModuleTypes>;
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct ExposedByModule {
|
||||
exposed: MutMap<ModuleId, ExposedModuleTypes>,
|
||||
}
|
||||
|
||||
impl ExposedByModule {
|
||||
pub fn insert(&mut self, module_id: ModuleId, exposed: ExposedModuleTypes) {
|
||||
self.exposed.insert(module_id, exposed);
|
||||
}
|
||||
|
||||
pub fn get(&self, module_id: &ModuleId) -> Option<&ExposedModuleTypes> {
|
||||
self.exposed.get(module_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ExposedModuleTypes {
|
||||
@ -119,7 +132,7 @@ pub fn pre_constrain_imports(
|
||||
home: ModuleId,
|
||||
references: &MutSet<Symbol>,
|
||||
imported_modules: MutMap<ModuleId, Region>,
|
||||
exposed_types: &mut SubsByModule,
|
||||
exposed_types: &mut ExposedByModule,
|
||||
stdlib: &StdLib,
|
||||
) -> ConstrainableImports {
|
||||
let mut imported_symbols = Vec::with_capacity(references.len());
|
||||
|
@ -11,7 +11,7 @@ use roc_can::module::{canonicalize_module_defs, Module};
|
||||
use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet};
|
||||
use roc_constrain::module::{
|
||||
constrain_imports, constrain_module, pre_constrain_imports, ConstrainableImports,
|
||||
ExposedModuleTypes, HackyImport, Import, SubsByModule,
|
||||
ExposedByModule, ExposedModuleTypes, HackyImport, Import,
|
||||
};
|
||||
use roc_module::ident::{Ident, ModuleName, QualifiedModuleName};
|
||||
use roc_module::symbol::{
|
||||
@ -567,7 +567,7 @@ struct State<'a> {
|
||||
pub platform_data: Option<PlatformData>,
|
||||
pub goal_phase: Phase,
|
||||
pub stdlib: &'a StdLib,
|
||||
pub exposed_types: SubsByModule,
|
||||
pub exposed_types: ExposedByModule,
|
||||
pub output_path: Option<&'a str>,
|
||||
pub platform_path: PlatformPath<'a>,
|
||||
pub target_info: TargetInfo,
|
||||
@ -607,7 +607,7 @@ impl<'a> State<'a> {
|
||||
target_info: TargetInfo,
|
||||
goal_phase: Phase,
|
||||
stdlib: &'a StdLib,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
arc_modules: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||
ident_ids_by_module: Arc<Mutex<MutMap<ModuleId, IdentIds>>>,
|
||||
) -> Self {
|
||||
@ -813,7 +813,7 @@ pub fn load_and_typecheck<'a>(
|
||||
filename: PathBuf,
|
||||
stdlib: &'a StdLib,
|
||||
src_dir: &Path,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||
use LoadResult::*;
|
||||
@ -840,7 +840,7 @@ pub fn load_and_monomorphize<'a>(
|
||||
filename: PathBuf,
|
||||
stdlib: &'a StdLib,
|
||||
src_dir: &Path,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
||||
use LoadResult::*;
|
||||
@ -868,7 +868,7 @@ pub fn load_and_monomorphize_from_str<'a>(
|
||||
src: &'a str,
|
||||
stdlib: &'a StdLib,
|
||||
src_dir: &Path,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
||||
use LoadResult::*;
|
||||
@ -1034,7 +1034,7 @@ fn load<'a>(
|
||||
load_start: LoadStart<'a>,
|
||||
stdlib: &'a StdLib,
|
||||
src_dir: &Path,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||
@ -1070,7 +1070,7 @@ fn load_single_threaded<'a>(
|
||||
load_start: LoadStart<'a>,
|
||||
stdlib: &'a StdLib,
|
||||
src_dir: &Path,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||
@ -1246,7 +1246,7 @@ fn load_multi_threaded<'a>(
|
||||
load_start: LoadStart<'a>,
|
||||
stdlib: &'a StdLib,
|
||||
src_dir: &Path,
|
||||
exposed_types: SubsByModule,
|
||||
exposed_types: ExposedByModule,
|
||||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||
@ -3041,7 +3041,7 @@ impl<'a> BuildTask<'a> {
|
||||
constraint: ConstraintSoa,
|
||||
var_store: VarStore,
|
||||
imported_modules: MutMap<ModuleId, Region>,
|
||||
exposed_types: &mut SubsByModule,
|
||||
exposed_types: &mut ExposedByModule,
|
||||
stdlib: &StdLib,
|
||||
dep_idents: MutMap<ModuleId, IdentIds>,
|
||||
declarations: Vec<Declaration>,
|
||||
|
@ -19,7 +19,7 @@ mod test_load {
|
||||
use roc_can::def::Declaration::*;
|
||||
use roc_can::def::Def;
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_constrain::module::SubsByModule;
|
||||
use roc_constrain::module::ExposedByModule;
|
||||
use roc_load::file::LoadedModule;
|
||||
use roc_module::ident::ModuleName;
|
||||
use roc_module::symbol::{Interns, ModuleId};
|
||||
@ -159,7 +159,7 @@ mod test_load {
|
||||
fn load_fixture(
|
||||
dir_name: &str,
|
||||
module_name: &str,
|
||||
subs_by_module: SubsByModule,
|
||||
subs_by_module: ExposedByModule,
|
||||
) -> LoadedModule {
|
||||
let src_dir = fixtures_dir().join(dir_name);
|
||||
let filename = src_dir.join(format!("{}.roc", module_name));
|
||||
|
@ -426,7 +426,7 @@ pub fn load_modules_for_files(filenames: Vec<PathBuf>, std_lib: StdLib) -> Vec<L
|
||||
filename,
|
||||
&std_lib,
|
||||
src_dir.as_path(),
|
||||
MutMap::default(),
|
||||
Default::default(),
|
||||
roc_target::TargetInfo::default_x86_64(), // This is just type-checking for docs, so "target" doesn't matter
|
||||
) {
|
||||
Ok(loaded) => modules.push(loaded),
|
||||
|
@ -1,7 +1,6 @@
|
||||
use bumpalo::Bump;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_fmt::annotation::Formattable;
|
||||
use roc_fmt::annotation::{Newlines, Parens};
|
||||
use roc_load::file::{LoadingProblem, MonomorphizedModule};
|
||||
@ -55,7 +54,7 @@ pub fn compile_to_mono<'a>(
|
||||
|
||||
let module_src = arena.alloc(promote_expr_to_module(src));
|
||||
|
||||
let exposed_types = MutMap::default();
|
||||
let exposed_types = Default::default();
|
||||
let loaded = roc_load::file::load_and_monomorphize_from_str(
|
||||
arena,
|
||||
filename,
|
||||
|
Loading…
Reference in New Issue
Block a user