fix conformity errors

This commit is contained in:
Mark Thom
2019-04-04 22:51:00 -06:00
parent 546aeea479
commit 3912a4772d
17 changed files with 150 additions and 150 deletions

View File

@@ -395,8 +395,8 @@ impl ListingCompiler {
if ct_name == &name && arity == ct_arity => {
*idx = self_idx.clone();
},
&mut ClauseType::Op(ref op_decl, ref mut idx)
if op_decl.name() == name && op_decl.arity() == arity => {
&mut ClauseType::Op(ref op_name, ref shared_op_desc, ref mut idx)
if op_name == &name && shared_op_desc.arity() == arity => {
*idx = self_idx.clone();
},
_ => {}
@@ -553,14 +553,11 @@ impl ListingCompiler {
Declaration::NonCountedBacktracking(name, arity) =>
Ok(self.add_non_counted_bt_flag(name, arity)),
Declaration::Op(op_decl) => {
let existing_desc = {
let comp_ops = composite_op!(self.module.is_some(), &wam_indices.op_dir,
&mut indices.op_dir);
let spec = get_desc(op_decl.name(), composite_op!(self.module.is_some(),
&wam_indices.op_dir,
&mut indices.op_dir));
get_desc(op_decl.name(), comp_ops)
};
op_decl.submit(self.get_module_name(), existing_desc, &mut indices.op_dir)
op_decl.submit(self.get_module_name(), spec, &mut indices.op_dir)
},
Declaration::UseModule(name) =>
self.use_module(name, code_repo, flags, wam_indices, indices),
@@ -579,10 +576,10 @@ impl ListingCompiler {
}
}
fn process_and_commit_decl<'a, R: Read>(&mut self, decl: Declaration,
worker: &mut TopLevelBatchWorker<'a, R>,
indices: &mut IndexStore, flags: MachineFlags)
-> Result<(), SessionError>
fn process_and_commit_decl<R: Read>(&mut self, decl: Declaration,
worker: &mut TopLevelBatchWorker<R>,
indices: &mut IndexStore, flags: MachineFlags)
-> Result<(), SessionError>
{
match &decl {
&Declaration::Dynamic(ref name, arity) => {

View File

@@ -149,7 +149,7 @@ impl<T: CopierTarget> CopyTermState<T> {
self.target[addr] = HeapCellValue::Addr(Addr::Str(threshold));
self.trail.push((Ref::HeapCell(addr),
HeapCellValue::NamedStr(arity, name.clone(), fixity)));
HeapCellValue::NamedStr(arity, name.clone(), fixity.clone())));
self.target.push(HeapCellValue::NamedStr(arity, name, fixity));

View File

@@ -22,7 +22,7 @@ pub(super) struct MachineError {
impl MachineError {
pub(super) fn functor_stub(name: ClauseName, arity: usize) -> MachineStub {
let name = HeapCellValue::Addr(Addr::Con(Constant::Atom(name, None)));
functor!("/", 2, [name, heap_integer!(arity)], (400, YFX))
functor!("/", 2, [name, heap_integer!(arity)], SharedOpDesc::new(400, YFX))
}
pub(super) fn evaluation_error(eval_error: EvalError) -> Self {
@@ -47,8 +47,8 @@ impl MachineError {
stub.append(&mut functor!("/", 2, [HeapCellValue::Addr(Addr::HeapCell(h + 2 + 3)),
heap_integer!(arity)],
(400, YFX)));
stub.append(&mut functor!(":", 2, [mod_name, name], (600, XFY)));
SharedOpDesc::new(400, YFX)));
stub.append(&mut functor!(":", 2, [mod_name, name], SharedOpDesc::new(600, XFY)));
MachineError { stub, from: ErrorProvenance::Constructed }
}

View File

@@ -14,8 +14,8 @@ use std::rc::Rc;
#[derive(Clone, PartialEq, Eq, Hash)]
pub enum DBRef {
BuiltInPred(ClauseName, usize, Option<(usize, Specifier)>),
NamedPred(ClauseName, usize, Option<(usize, Specifier)>)
BuiltInPred(ClauseName, usize, Option<SharedOpDesc>),
NamedPred(ClauseName, usize, Option<SharedOpDesc>)
}
#[derive(Clone, PartialEq, Eq, Hash)]
@@ -163,7 +163,7 @@ impl From<Ref> for TrailRef {
#[derive(Clone, PartialEq)]
pub enum HeapCellValue {
Addr(Addr),
NamedStr(usize, ClauseName, Option<(usize, Specifier)>), // arity, name, precedence/Specifier if it has one.
NamedStr(usize, ClauseName, Option<SharedOpDesc>), // arity, name, precedence/Specifier if it has one.
}
impl HeapCellValue {
@@ -411,7 +411,7 @@ pub struct IndexStore {
impl IndexStore {
pub fn predicate_exists(&self, name: ClauseName, module: ClauseName, arity: usize,
op_spec: Option<(usize, Specifier)>)
op_spec: Option<SharedOpDesc>)
-> bool
{
match self.modules.get(&module) {
@@ -419,8 +419,8 @@ impl IndexStore {
match ClauseType::from(name, arity, op_spec) {
ClauseType::Named(name, arity, _) =>
module.code_dir.contains_key(&(name, arity)),
ClauseType::Op(op_decl, ..) =>
module.code_dir.contains_key(&(op_decl.name(), op_decl.arity())),
ClauseType::Op(name, spec, ..) =>
module.code_dir.contains_key(&(name, spec.arity())),
_ =>
true
},
@@ -428,8 +428,8 @@ impl IndexStore {
match ClauseType::from(name, arity, op_spec) {
ClauseType::Named(name, arity, _) =>
self.code_dir.contains_key(&(name, arity)),
ClauseType::Op(op_decl, ..) =>
self.code_dir.contains_key(&(op_decl.name(), op_decl.arity())),
ClauseType::Op(name, spec, ..) =>
self.code_dir.contains_key(&(name, spec.arity())),
_ =>
true
}

View File

@@ -538,11 +538,11 @@ pub(crate) trait CallPolicy: Any {
let c = match machine_st.compare_term_test(&a2, &a3) {
Ordering::Greater => Addr::Con(Constant::Atom(clause_name!(">"),
Some((700, XFX)))),
Some(SharedOpDesc::new(700, XFX)))),
Ordering::Equal => Addr::Con(Constant::Atom(clause_name!("="),
Some((700, XFX)))),
Some(SharedOpDesc::new(700, XFX)))),
Ordering::Less => Addr::Con(Constant::Atom(clause_name!("<"),
Some((700, XFX))))
Some(SharedOpDesc::new(700, XFX))))
};
machine_st.unify(a1, c);

View File

@@ -1023,7 +1023,7 @@ impl MachineState {
self.interms[t - 1] = try_or_fail!(self, self.pow(n1, n2));
self.p += 1;
},
},
&ArithmeticInstruction::RDiv(ref a1, ref a2, t) => {
let stub = MachineError::functor_stub(clause_name!("(rdiv)"), 2);
@@ -2002,7 +2002,7 @@ impl MachineState {
}
fn try_functor_compound_case(&mut self, name: ClauseName, arity: usize,
spec: Option<(usize, Specifier)>)
spec: Option<SharedOpDesc>)
{
let name = Addr::Con(Constant::Atom(name, spec));
let arity = Addr::Con(integer!(arity));
@@ -2164,9 +2164,10 @@ impl MachineState {
HeapCellValue::NamedStr(2, ref name, Some(_))
if *name == clause_name!("-") =>
Ok(Addr::HeapCell(s+1)),
_ => Err(self.error_form(MachineError::type_error(ValidType::Pair,
self.heap[s].as_addr(s)),
stub))
_ =>
Err(self.error_form(MachineError::type_error(ValidType::Pair,
self.heap[s].as_addr(s)),
stub))
},
a => Err(self.error_form(MachineError::type_error(ValidType::Pair, a), stub))
}
@@ -2389,7 +2390,7 @@ impl MachineState {
self.p = CodePtr::Local(self.cp);
}
},
&ClauseType::Named(ref name, _, ref idx) | &ClauseType::Op(OpDecl(.., ref name), ref idx) =>
&ClauseType::Named(ref name, _, ref idx) | &ClauseType::Op(ref name, _, ref idx) =>
try_or_fail!(self, call_policy.context_call(self, name.clone(), arity, idx.clone(),
indices)),
&ClauseType::System(ref ct) =>

View File

@@ -274,13 +274,7 @@ impl Machine {
#[inline]
pub fn add_batched_ops(&mut self, op_dir: OpDir) {
for ((name, fixity), info) in op_dir {
if info.1 == 0 {
self.indices.op_dir.remove(&(name, fixity));
} else {
self.indices.op_dir.insert((name, fixity), info);
}
}
self.indices.op_dir.extend(op_dir.into_iter());
}
#[inline]

View File

@@ -71,6 +71,11 @@ pub trait SubModuleUser
fn insert_dir_entry(&mut self, ClauseName, usize, CodeIndex);
fn get_op_module_name(&mut self, name: ClauseName, fixity: Fixity) -> Option<ClauseName>
{
self.op_dir().get(&(name, fixity)).map(|op_val| op_val.owning_module())
}
fn remove_module(&mut self, mod_name: ClauseName, module: &Module)
{
for (name, arity) in module.module_decl.exports.iter().cloned() {
@@ -86,21 +91,21 @@ pub trait SubModuleUser
// remove or respecify ops.
if arity == 2 {
if let Some((_, _, mod_name)) = self.op_dir().get(&(name.clone(), Fixity::In)).cloned()
if let Some(mod_name) = self.get_op_module_name(name.clone(), Fixity::In)
{
if mod_name == module.module_decl.name {
self.op_dir().remove(&(name.clone(), Fixity::In));
}
}
} else if arity == 1 {
if let Some((_, _, mod_name)) = self.op_dir().get(&(name.clone(), Fixity::Pre)).cloned()
if let Some(mod_name) = self.get_op_module_name(name.clone(), Fixity::Pre)
{
if mod_name == module.module_decl.name {
self.op_dir().remove(&(name.clone(), Fixity::Pre));
}
}
if let Some((_, _, mod_name)) = self.op_dir().get(&(name.clone(), Fixity::Post)).cloned()
if let Some(mod_name) = self.get_op_module_name(name.clone(), Fixity::Post)
{
if mod_name == module.module_decl.name {
self.op_dir().remove(&(name.clone(), Fixity::Post));

View File

@@ -570,8 +570,8 @@ impl MachineState {
}
},
&SystemClauseType::OpDeclaration => {
let priority = self[temp_v!(1)].clone();
let specifier = self[temp_v!(2)].clone();
let priority = self[temp_v!(1)].clone();
let specifier = self[temp_v!(2)].clone();
let op = self[temp_v!(3)].clone();
let priority = match self.store(self.deref(priority)) {
@@ -599,8 +599,8 @@ impl MachineState {
if op_decl.0 == 0 {
Ok(op_decl.remove(&mut indices.op_dir))
} else {
let desc = get_desc(op_decl.name(), composite_op!(&indices.op_dir));
op_decl.submit(module, desc, &mut indices.op_dir)
let spec = get_desc(op_decl.name(), composite_op!(&indices.op_dir));
op_decl.submit(module, spec, &mut indices.op_dir)
}
});

View File

@@ -58,16 +58,16 @@ impl<'a, 'b> CompositeIndices<'a, 'b>
}
}
fn get_clause_type(&mut self, name: ClauseName, arity: usize, spec: Option<(usize, Specifier)>) -> ClauseType
fn get_clause_type(&mut self, name: ClauseName, arity: usize, spec: Option<SharedOpDesc>) -> ClauseType
{
match ClauseType::from(name, arity, spec) {
ClauseType::Named(name, arity, _) => {
let idx = self.get_code_index(name.clone(), arity);
ClauseType::Named(name, arity, idx.clone())
},
ClauseType::Op(op_decl, _) => {
let idx = self.get_code_index(op_decl.2.clone(), arity);
ClauseType::Op(op_decl, idx.clone())
ClauseType::Op(name, spec, _) => {
let idx = self.get_code_index(name.clone(), arity);
ClauseType::Op(name, spec, idx.clone())
},
ct => ct
}
@@ -741,8 +741,8 @@ impl RelationWorker {
self.dynamic_clauses.extend(other.dynamic_clauses.into_iter());
}
fn expand_queue_contents<'a, R>(&mut self, term_stream: &mut TermStream<'a, R>, op_dir: &OpDir)
-> Result<(), SessionError>
fn expand_queue_contents<R>(&mut self, term_stream: &mut TermStream<R>, op_dir: &OpDir)
-> Result<(), SessionError>
where R: Read
{
let mut machine_st = MachineState::new();
@@ -762,8 +762,8 @@ impl RelationWorker {
}
}
fn term_to_toplevel<'a, R>(term_stream: &mut TermStream<'a, R>, code_dir: &mut CodeDir, term: Term)
-> Result<(TopLevel, RelationWorker), ParserError>
fn term_to_toplevel<R>(term_stream: &mut TermStream<R>, code_dir: &mut CodeDir, term: Term)
-> Result<(TopLevel, RelationWorker), ParserError>
where R: Read
{
let mut rel_worker = RelationWorker::new();