crude prototype

This commit is contained in:
Folkert 2021-02-20 22:56:01 +01:00
parent df206edd88
commit daf6de950e
2 changed files with 10 additions and 5 deletions

View file

@ -135,6 +135,9 @@ pub fn build(target: &Triple, matches: &ArgMatches, run_after_build: bool) -> io
Err(LoadingProblem::ParsingFailedReport(report)) => { Err(LoadingProblem::ParsingFailedReport(report)) => {
print!("{}", report); print!("{}", report);
} }
Err(LoadingProblem::NoPlatform) => {
print!("The file you ran did not provide a platform\nMaybe you are trying to run an Interface module?");
}
Err(other) => { Err(other) => {
panic!("build_file failed with error:\n{:?}", other); panic!("build_file failed with error:\n{:?}", other);
} }

View file

@ -980,6 +980,8 @@ pub enum LoadingProblem<'a> {
}, },
ParsingFailed(ParseProblem<'a, SyntaxError<'a>>), ParsingFailed(ParseProblem<'a, SyntaxError<'a>>),
UnexpectedHeader(String), UnexpectedHeader(String),
/// there is no platform (likely running an Interface module)
NoPlatform,
MsgChannelDied, MsgChannelDied,
ErrJoiningWorkerThreads, ErrJoiningWorkerThreads,
@ -1479,7 +1481,7 @@ where
state, state,
subs, subs,
exposed_to_host, exposed_to_host,
))); )?));
} }
Msg::FailedToParse(problem) => { Msg::FailedToParse(problem) => {
// Shut down all the worker threads. // Shut down all the worker threads.
@ -2044,7 +2046,7 @@ fn finish_specialization(
state: State, state: State,
subs: Subs, subs: Subs,
exposed_to_host: MutMap<Symbol, Variable>, exposed_to_host: MutMap<Symbol, Variable>,
) -> MonomorphizedModule { ) -> Result<MonomorphizedModule, LoadingProblem> {
let module_ids = Arc::try_unwrap(state.arc_modules) let module_ids = Arc::try_unwrap(state.arc_modules)
.unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids")) .unwrap_or_else(|_| panic!("There were still outstanding Arc references to module_ids"))
.into_inner() .into_inner()
@ -2085,7 +2087,7 @@ fn finish_specialization(
} }
} }
Some(To::NewPackage(p_or_p)) => p_or_p, Some(To::NewPackage(p_or_p)) => p_or_p,
None => panic!("no platform!"), None => return Err(LoadingProblem::NoPlatform),
}; };
match package_or_path { match package_or_path {
@ -2097,7 +2099,7 @@ fn finish_specialization(
let platform_path = path_to_platform.into(); let platform_path = path_to_platform.into();
MonomorphizedModule { Ok(MonomorphizedModule {
can_problems, can_problems,
mono_problems, mono_problems,
type_problems, type_problems,
@ -2110,7 +2112,7 @@ fn finish_specialization(
procedures, procedures,
sources, sources,
timings: state.timings, timings: state.timings,
} })
} }
fn finish( fn finish(