prepare for updating the code_dir with each new predicate

This commit is contained in:
Mark Thom
2018-06-16 23:36:22 -06:00
parent 7b99dc53b6
commit a824a53fa8
2 changed files with 70 additions and 38 deletions

View File

@@ -88,10 +88,16 @@ impl TLInfo for QueryInfo {
}
}
pub fn parse_code(wam: &Machine, buffer: &str) -> Result<TopLevelPacket, ParserError>
pub fn parse_code(wam: &mut Machine, buffer: &str) -> Result<TopLevelPacket, ParserError>
{
let mut worker = TopLevelWorker::new(buffer.as_bytes(), wam.atom_tbl());
worker.parse_code(&wam.op_dir)
let atom_tbl = wam.atom_tbl();
let index = MachineCodeIndex {
code_dir: &mut wam.code_dir,
op_dir: &mut wam.op_dir
};
let mut worker = TopLevelWorker::new(buffer.as_bytes(), atom_tbl, index);
worker.parse_code()
}
// throw errors if declaration or query found.
@@ -220,13 +226,11 @@ pub fn compile_listing(wam: &mut Machine, src_str: &str) -> EvalSession
let mut code = Vec::new();
let mut worker = TopLevelWorker::new(src_str.as_bytes(), wam.atom_tbl());
let tls = {
let indices = MachineCodeIndex { code_dir: &mut code_dir,
op_dir: &mut op_dir };
try_eval_session!(worker.parse_batch(&wam, indices))
let indices = MachineCodeIndex { code_dir: &mut code_dir, op_dir: &mut op_dir };
let mut worker = TopLevelWorker::new(src_str.as_bytes(), wam.atom_tbl(), indices);
try_eval_session!(worker.parse_batch(&wam))
};
for tl in tls {
@@ -255,7 +259,8 @@ pub fn compile_listing(wam: &mut Machine, src_str: &str) -> EvalSession
wam.use_module_in_toplevel(name);
},
TopLevelPacket::Decl(TopLevel::Declaration(Declaration::UseQualifiedModule(name, exports)), _)
TopLevelPacket::Decl(TopLevel::Declaration(Declaration::UseQualifiedModule(name, exports)),
_)
=>
{
if let Some(ref submodule) = wam.get_module(name.clone()) {