[[package]]
name = "prolog_parser"
-version = "0.7.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+version = "0.7.12"
dependencies = [
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "rusty-wam"
-version = "0.7.9"
+version = "0.7.10"
dependencies = [
"downcast 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "prolog_parser 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "prolog_parser 0.7.12",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe"
"checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f"
-"checksum prolog_parser 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "608b6d0e85a6ea8d4fda3679fc314a8b08efdb07f896438342a9d727b04b72d7"
"checksum redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ab105df655884ede59d45b7070c8a65002d921461ee813a024558ca16030eea0"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
[package]
name = "rusty-wam"
-version = "0.7.9"
+version = "0.7.10"
repository = "https://github.com/mthom/rusty-wam"
description = "The Warren Abstract Machine in Rust."
downcast = "0.9.1"
num = "0.2"
ordered-float = "0.5.0"
-prolog_parser = "0.7.11"
+prolog_parser = { path = "../prolog_parser", version = "0.7.12" }
[dependencies.termion]
version = "1.4.0"
\ No newline at end of file
pub fn new() -> Self {
ListingCompiler { module: None, non_counted_bt_preds: HashSet::new() }
}
-
- fn use_module(&mut self, submodule: Module, wam: &mut Machine,
- indices: &mut MachineCodeIndices) -> Result<(), SessionError>
+
+ fn use_module(&mut self, submodule: Module, wam: &mut Machine, indices: &mut MachineCodeIndices)
+ -> Result<(), SessionError>
{
let mod_name = self.get_module_name();
-
+
indices.use_module(&submodule)?;
if let &mut Some(ref mut module) = &mut self.module {
-> Result<(), SessionError>
{
let mod_name = self.get_module_name();
-
+
indices.use_qualified_module(&submodule, exports)?;
if let &mut Some(ref mut module) = &mut self.module {
wam.insert_module(submodule);
Ok(())
}
-
+
fn get_module_name(&self) -> ClauseName {
self.module.as_ref()
.map(|module| module.module_decl.name.clone())
let mut compiler = ListingCompiler::new();
let mut toplevel_results = vec![];
- while let Some(decl) = try_eval_session!(worker.consume(&mut indices)) {
+ while let Some(decl) = try_eval_session!(worker.consume(&wam.op_dir, &mut indices)) {
if decl.is_module_decl() {
toplevel_indices.copy_and_swap(&mut indices);
mem::swap(&mut worker.results, &mut toplevel_results);
pub fn atom_tbl(&self) -> TabledData<Atom> {
self.ms.atom_tbl.clone()
}
-
- pub fn get_module(&self, name: ClauseName) -> Option<&Module> {
- self.modules.get(&name)
- }
-
+
pub fn add_batched_code(&mut self, code: Code, code_dir: CodeDir) -> Result<(), SessionError>
{
for (ref key, ref idx) in code_dir.iter() {
let mut parser = Parser::new(stdin.lock(), wam.atom_tbl(), wam.machine_flags());
parser.add_to_top(buffer.as_str());
- Ok(Input::Term(parser.read_term(&wam.op_dir)?))
+ Ok(Input::Term(parser.read_term(composite_op!(&wam.op_dir))?))
}
}
}
pub fn read<R: Read>(&mut self, inner: R, op_dir: &OpDir) -> Result<usize, ParserError>
{
let mut parser = Parser::new(inner, self.atom_tbl.clone(), self.flags);
- let term = parser.read_term(op_dir)?;
+ let term = parser.read_term(composite_op!(op_dir))?;
Ok(write_term_to_heap(term, self))
}
pub struct TopLevelBatchWorker<R: Read> {
parser: Parser<R>,
rel_worker: RelationWorker,
- pub results: Vec<(Predicate, VecDeque<TopLevel>)>
+ pub results: Vec<(Predicate, VecDeque<TopLevel>)>,
+ pub in_module: bool
}
impl<R: Read> TopLevelBatchWorker<R> {
{
TopLevelBatchWorker { parser: Parser::new(inner, atom_tbl, flags),
rel_worker: RelationWorker::new(),
- results: vec![] }
+ results: vec![],
+ in_module: false }
}
+ #[inline]
+ fn read_term(&mut self, static_op_dir: &OpDir, op_dir: &OpDir) -> Result<Term, ParserError> {
+ let composite_op = composite_op!(self.in_module, op_dir, static_op_dir);
+ self.parser.read_term(composite_op)
+ }
+
pub
- fn consume(&mut self, indices: &mut MachineCodeIndices) -> Result<Option<Declaration>, SessionError>
+ fn consume(&mut self, op_dir: &OpDir, indices: &mut MachineCodeIndices)
+ -> Result<Option<Declaration>, SessionError>
{
let mut preds = vec![];
self.parser.reset(); // empty the parser stack of token descriptions.
let mut new_rel_worker = RelationWorker::new();
- let term = self.parser.read_term(&indices.op_dir)?;
+ let term = self.read_term(op_dir, &indices.op_dir)?;
let tl = new_rel_worker.try_term_to_tl(indices, term, true)?;
if !is_consistent(&tl, &preds) { // if is_consistent returns false, preds is non-empty.