support loading of modules from files specified at the command line
This commit is contained in:
@@ -81,6 +81,7 @@ fn load_module<R: Read>(wam: &mut Machine, name: &str, stream: ParsingStream<R>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super)
|
||||||
fn load_module_from_file(wam: &mut Machine, filename: &str) -> Result<ClauseName, SessionError>
|
fn load_module_from_file(wam: &mut Machine, filename: &str) -> Result<ClauseName, SessionError>
|
||||||
{
|
{
|
||||||
let path = fix_filename(wam.indices.atom_tbl.clone(), filename)?;
|
let path = fix_filename(wam.indices.atom_tbl.clone(), filename)?;
|
||||||
|
|||||||
@@ -217,6 +217,13 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_toplevel(&mut self) {
|
pub fn run_toplevel(&mut self) {
|
||||||
|
use std::env;
|
||||||
|
use prolog::machine::compile::load_module_from_file;
|
||||||
|
|
||||||
|
for filename in env::args() {
|
||||||
|
load_module_from_file(self, &filename);
|
||||||
|
}
|
||||||
|
|
||||||
self.machine_st.p = CodePtr::Local(LocalCodePtr::DirEntry(self.toplevel_idx));
|
self.machine_st.p = CodePtr::Local(LocalCodePtr::DirEntry(self.toplevel_idx));
|
||||||
self.run_query(&AllocVarDict::new());
|
self.run_query(&AllocVarDict::new());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user