finalize the module resolution operator.
This commit is contained in:
@@ -38,10 +38,9 @@ fn print_code(code: &Code) {
|
||||
pub fn parse_code(wam: &mut Machine, buffer: &str) -> Result<TopLevelPacket, ParserError>
|
||||
{
|
||||
let atom_tbl = wam.atom_tbl();
|
||||
let index = MachineCodeIndex {
|
||||
let index = MachineCodeIndices {
|
||||
code_dir: &mut wam.code_dir,
|
||||
op_dir: &mut wam.op_dir,
|
||||
//modules: &wam.modules
|
||||
};
|
||||
|
||||
let mut worker = TopLevelWorker::new(buffer.as_bytes(), atom_tbl, index);
|
||||
@@ -189,11 +188,11 @@ impl<'a> ListingCompiler<'a> {
|
||||
Ok(code)
|
||||
}
|
||||
|
||||
fn add_code(self, code: Code, indices: MachineCodeIndex) {
|
||||
fn add_code(self, code: Code, indices: MachineCodeIndices) {
|
||||
let code_dir = mem::replace(indices.code_dir, HashMap::new());
|
||||
let op_dir = mem::replace(indices.op_dir, HashMap::new());
|
||||
|
||||
if let Some(mut module) = self.module {
|
||||
if let Some(mut module) = self.module {
|
||||
module.code_dir.extend(as_module_code_dir(code_dir));
|
||||
module.op_dir.extend(op_dir.into_iter());
|
||||
|
||||
@@ -206,7 +205,7 @@ impl<'a> ListingCompiler<'a> {
|
||||
|
||||
}
|
||||
|
||||
fn use_module(module: &mut Option<Module>, submodule: &Module, indices: &mut MachineCodeIndex)
|
||||
fn use_module(module: &mut Option<Module>, submodule: &Module, indices: &mut MachineCodeIndices)
|
||||
{
|
||||
indices.use_module(submodule);
|
||||
|
||||
@@ -216,7 +215,7 @@ fn use_module(module: &mut Option<Module>, submodule: &Module, indices: &mut Mac
|
||||
}
|
||||
|
||||
fn use_qualified_module(module: &mut Option<Module>, submodule: &Module, exports: &Vec<PredicateKey>,
|
||||
indices: &mut MachineCodeIndex)
|
||||
indices: &mut MachineCodeIndices)
|
||||
{
|
||||
indices.use_qualified_module(submodule, exports);
|
||||
|
||||
@@ -226,7 +225,7 @@ fn use_qualified_module(module: &mut Option<Module>, submodule: &Module, exports
|
||||
}
|
||||
|
||||
pub
|
||||
fn compile_listing(wam: &mut Machine, src_str: &str, mut indices: MachineCodeIndex) -> EvalSession
|
||||
fn compile_listing(wam: &mut Machine, src_str: &str, mut indices: MachineCodeIndices) -> EvalSession
|
||||
{
|
||||
let mut worker = TopLevelBatchWorker::new(src_str.as_bytes(), wam.atom_tbl());
|
||||
let mut compiler = ListingCompiler::new(wam);
|
||||
@@ -264,12 +263,12 @@ fn compile_listing(wam: &mut Machine, src_str: &str, mut indices: MachineCodeInd
|
||||
}
|
||||
|
||||
pub fn compile_user_module(wam: &mut Machine, src_str: &str) -> EvalSession {
|
||||
let mut indices = machine_code_index!(&mut CodeDir::new(), &mut default_op_dir());
|
||||
let mut indices = machine_code_indices!(&mut CodeDir::new(), &mut default_op_dir());
|
||||
|
||||
if let Some(ref builtins) = wam.modules.get(&clause_name!("builtins")) {
|
||||
indices.use_module(builtins);
|
||||
indices.use_module(builtins);
|
||||
} else {
|
||||
return EvalSession::from(SessionError::ModuleNotFound);
|
||||
return EvalSession::from(SessionError::ModuleNotFound);
|
||||
}
|
||||
|
||||
compile_listing(wam, src_str, indices)
|
||||
|
||||
Reference in New Issue
Block a user