fix conformity errors
This commit is contained in:
@@ -14,7 +14,7 @@ cfg-if = "0.1.7"
|
|||||||
downcast = "0.10.0"
|
downcast = "0.10.0"
|
||||||
num = "0.2"
|
num = "0.2"
|
||||||
ordered-float = "0.5.0"
|
ordered-float = "0.5.0"
|
||||||
prolog_parser = "0.8.14"
|
prolog_parser = "0.8.15"
|
||||||
readline_rs_compat = { version = "0.1.7", optional = true }
|
readline_rs_compat = { version = "0.1.7", optional = true }
|
||||||
ref_thread_local = "0.0.0"
|
ref_thread_local = "0.0.0"
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ impl<'a> ArithInstructionIterator<'a> {
|
|||||||
let state = match term {
|
let state = match term {
|
||||||
&Term::AnonVar =>
|
&Term::AnonVar =>
|
||||||
return Err(ArithmeticError::InvalidTerm),
|
return Err(ArithmeticError::InvalidTerm),
|
||||||
&Term::Clause(ref cell, ref name, ref terms, fixity) =>
|
&Term::Clause(ref cell, ref name, ref terms, ref fixity) =>
|
||||||
match ClauseType::from(name.clone(), terms.len(), fixity) {
|
match ClauseType::from(name.clone(), terms.len(), fixity.clone()) {
|
||||||
ct @ ClauseType::Named(..) | ct @ ClauseType::Op(..) =>
|
ct @ ClauseType::Named(..) | ct @ ClauseType::Op(..) =>
|
||||||
Ok(TermIterState::Clause(Level::Shallow, 0, cell, ct, terms)),
|
Ok(TermIterState::Clause(Level::Shallow, 0, cell, ct, terms)),
|
||||||
_ => Err(ArithmeticError::InvalidOp)
|
_ => Err(ArithmeticError::InvalidOp)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use prolog_parser::ast::*;
|
use prolog_parser::ast::*;
|
||||||
|
|
||||||
use prolog::forms::OpDecl;
|
|
||||||
use prolog::machine::machine_indices::*;
|
use prolog::machine::machine_indices::*;
|
||||||
|
|
||||||
use ref_thread_local::RefThreadLocal;
|
use ref_thread_local::RefThreadLocal;
|
||||||
@@ -403,7 +402,7 @@ pub enum ClauseType {
|
|||||||
Hook(CompileTimeHook),
|
Hook(CompileTimeHook),
|
||||||
Inlined(InlinedClauseType),
|
Inlined(InlinedClauseType),
|
||||||
Named(ClauseName, usize, CodeIndex), // name, arity, index.
|
Named(ClauseName, usize, CodeIndex), // name, arity, index.
|
||||||
Op(OpDecl, CodeIndex),
|
Op(ClauseName, SharedOpDesc, CodeIndex),
|
||||||
System(SystemClauseType)
|
System(SystemClauseType)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,16 +453,16 @@ impl BuiltInClauseType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ClauseType {
|
impl ClauseType {
|
||||||
pub fn spec(&self) -> Option<(usize, Specifier)> {
|
pub fn spec(&self) -> Option<SharedOpDesc> {
|
||||||
match self {
|
match self {
|
||||||
&ClauseType::Op(ref op_decl, _) =>
|
&ClauseType::Op(_, ref spec, _) =>
|
||||||
Some((op_decl.0, op_decl.1)),
|
Some(spec.clone()),
|
||||||
&ClauseType::Inlined(InlinedClauseType::CompareNumber(..))
|
&ClauseType::Inlined(InlinedClauseType::CompareNumber(..))
|
||||||
| &ClauseType::BuiltIn(BuiltInClauseType::Is(..))
|
| &ClauseType::BuiltIn(BuiltInClauseType::Is(..))
|
||||||
| &ClauseType::BuiltIn(BuiltInClauseType::CompareTerm(_))
|
| &ClauseType::BuiltIn(BuiltInClauseType::CompareTerm(_))
|
||||||
| &ClauseType::BuiltIn(BuiltInClauseType::NotEq)
|
| &ClauseType::BuiltIn(BuiltInClauseType::NotEq)
|
||||||
| &ClauseType::BuiltIn(BuiltInClauseType::Eq) =>
|
| &ClauseType::BuiltIn(BuiltInClauseType::Eq) =>
|
||||||
Some((700, XFX)),
|
Some(SharedOpDesc::new(700, XFX)),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,21 +473,20 @@ impl ClauseType {
|
|||||||
&ClauseType::BuiltIn(ref built_in) => built_in.name(),
|
&ClauseType::BuiltIn(ref built_in) => built_in.name(),
|
||||||
&ClauseType::Hook(ref hook) => hook.name(),
|
&ClauseType::Hook(ref hook) => hook.name(),
|
||||||
&ClauseType::Inlined(ref inlined) => clause_name!(inlined.name()),
|
&ClauseType::Inlined(ref inlined) => clause_name!(inlined.name()),
|
||||||
&ClauseType::Op(ref op_decl, ..) => op_decl.name(),
|
&ClauseType::Op(ref name, ..) => name.clone(),
|
||||||
&ClauseType::Named(ref name, ..) => name.clone(),
|
&ClauseType::Named(ref name, ..) => name.clone(),
|
||||||
&ClauseType::System(ref system) => system.name(),
|
&ClauseType::System(ref system) => system.name(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from(name: ClauseName, arity: usize, spec: Option<(usize, Specifier)>) -> Self {
|
pub fn from(name: ClauseName, arity: usize, spec: Option<SharedOpDesc>) -> Self {
|
||||||
CLAUSE_TYPE_FORMS.borrow().get(&(name.as_str(), arity)).cloned()
|
CLAUSE_TYPE_FORMS.borrow().get(&(name.as_str(), arity)).cloned()
|
||||||
.unwrap_or_else(||
|
.unwrap_or_else(||
|
||||||
SystemClauseType::from(name.as_str(), arity)
|
SystemClauseType::from(name.as_str(), arity)
|
||||||
.map(ClauseType::System)
|
.map(ClauseType::System)
|
||||||
.unwrap_or_else(||
|
.unwrap_or_else(||
|
||||||
if let Some(spec) = spec {
|
if let Some(spec) = spec {
|
||||||
let op_decl = OpDecl(spec.0, spec.1, name);
|
ClauseType::Op(name, spec, CodeIndex::default())
|
||||||
ClauseType::Op(op_decl, CodeIndex::default())
|
|
||||||
} else if name.as_str() == "call" {
|
} else if name.as_str() == "call" {
|
||||||
ClauseType::CallN
|
ClauseType::CallN
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -177,30 +177,31 @@ impl OpDecl {
|
|||||||
self.2.clone()
|
self.2.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arity(&self) -> usize {
|
#[inline]
|
||||||
let spec = self.1;
|
|
||||||
|
|
||||||
if (spec | XFX != 0) || (spec | XFY != 0) || (spec | YFX != 0) {
|
|
||||||
2
|
|
||||||
} else {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remove(&self, op_dir: &mut OpDir) {
|
pub fn remove(&self, op_dir: &mut OpDir) {
|
||||||
|
self.insert_into_op_dir(clause_name!(""), op_dir, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn insert_into_op_dir(&self, module: ClauseName, op_dir: &mut OpDir, prec: usize)
|
||||||
|
{
|
||||||
let (spec, name) = (self.1, self.2.clone());
|
let (spec, name) = (self.1, self.2.clone());
|
||||||
|
|
||||||
if is_prefix!(spec) {
|
let fixity = match spec {
|
||||||
op_dir.remove(&(name.clone(), Fixity::Pre));
|
XFY | XFX | YFX => Fixity::In,
|
||||||
|
XF | YF => Fixity::Post,
|
||||||
|
FX | FY => Fixity::Pre,
|
||||||
|
_ => return
|
||||||
|
};
|
||||||
|
|
||||||
|
match op_dir.get(&(name.clone(), fixity)) {
|
||||||
|
Some(cell) => {
|
||||||
|
cell.shared_op_desc().set(prec, spec);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_infix!(spec) {
|
op_dir.insert((name, fixity), OpDirValue::new(spec, prec, module));
|
||||||
op_dir.remove(&(name.clone(), Fixity::In));
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_postfix!(spec) {
|
|
||||||
op_dir.remove(&(name, Fixity::Post));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn submit(&self, module: ClauseName, existing_desc: Option<OpDesc>, op_dir: &mut OpDir)
|
pub fn submit(&self, module: ClauseName, existing_desc: Option<OpDesc>, op_dir: &mut OpDir)
|
||||||
@@ -213,7 +214,7 @@ impl OpDecl {
|
|||||||
if desc.post > 0 {
|
if desc.post > 0 {
|
||||||
return Err(SessionError::OpIsInfixAndPostFix(name));
|
return Err(SessionError::OpIsInfixAndPostFix(name));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_postfix!(spec) {
|
if is_postfix!(spec) {
|
||||||
@@ -221,23 +222,10 @@ impl OpDecl {
|
|||||||
if desc.inf > 0 {
|
if desc.inf > 0 {
|
||||||
return Err(SessionError::OpIsInfixAndPostFix(name));
|
return Err(SessionError::OpIsInfixAndPostFix(name));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match spec {
|
Ok(self.insert_into_op_dir(module, op_dir, prec))
|
||||||
XFY | XFX | YFX => {
|
|
||||||
op_dir.insert((name.clone(), Fixity::In), (spec, prec, module.clone()));
|
|
||||||
},
|
|
||||||
XF | YF => {
|
|
||||||
op_dir.insert((name.clone(), Fixity::Post), (spec, prec, module.clone()));
|
|
||||||
},
|
|
||||||
FX | FY => {
|
|
||||||
op_dir.insert((name.clone(), Fixity::Pre), (spec, prec, module.clone()));
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ use std::rc::Rc;
|
|||||||
/* contains the location, name, precision and Specifier of the parent op. */
|
/* contains the location, name, precision and Specifier of the parent op. */
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum DirectedOp {
|
pub enum DirectedOp {
|
||||||
Left(ClauseName, (usize, Specifier)),
|
Left(ClauseName, SharedOpDesc),
|
||||||
Right(ClauseName, (usize, Specifier)),
|
Right(ClauseName, SharedOpDesc)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DirectedOp {
|
impl DirectedOp {
|
||||||
@@ -33,22 +33,33 @@ impl DirectedOp {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn is_negative_sign(&self) -> bool {
|
fn is_negative_sign(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
&DirectedOp::Left(ref name, (_, spec)) | &DirectedOp::Right(ref name, (_, spec)) =>
|
&DirectedOp::Left(ref name, ref cell) | &DirectedOp::Right(ref name, ref cell) =>
|
||||||
name.as_str() == "-" && is_prefix!(spec)
|
name.as_str() == "-" && is_prefix!(cell.assoc())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn needs_bracketing(child_spec: (usize, Specifier), op: &DirectedOp) -> bool
|
fn needs_bracketing(child_spec: &SharedOpDesc, op: &DirectedOp) -> bool
|
||||||
{
|
{
|
||||||
match op {
|
match op {
|
||||||
&DirectedOp::Left(_, (priority, spec)) => {
|
&DirectedOp::Left(ref name, ref cell) => {
|
||||||
|
let (priority, spec) = cell.get();
|
||||||
|
|
||||||
|
if name.as_str() == "-" {
|
||||||
|
let child_assoc = child_spec.assoc();
|
||||||
|
if is_prefix!(spec) && (is_postfix!(child_assoc) || is_infix!(child_assoc)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let is_strict_right = is_yfx!(spec) || is_xfx!(spec) || is_fx!(spec);
|
let is_strict_right = is_yfx!(spec) || is_xfx!(spec) || is_fx!(spec);
|
||||||
child_spec.0 > priority || (child_spec.0 == priority && is_strict_right)
|
child_spec.prec() > priority || (child_spec.prec() == priority && is_strict_right)
|
||||||
},
|
},
|
||||||
&DirectedOp::Right(_, (priority, spec)) => {
|
&DirectedOp::Right(_, ref cell) => {
|
||||||
|
let (priority, spec) = cell.get();
|
||||||
let is_strict_left = is_xfx!(spec) || is_xfy!(spec) || is_xf!(spec);
|
let is_strict_left = is_xfx!(spec) || is_xfy!(spec) || is_xf!(spec);
|
||||||
child_spec.0 > priority || (child_spec.0 == priority && is_strict_left)
|
|
||||||
|
child_spec.prec() > priority || (child_spec.prec() == priority && is_strict_left)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,19 +77,19 @@ impl<'a> HCPreOrderIterator<'a> {
|
|||||||
None => return false
|
None => return false
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut parent_spec = DirectedOp::Left(clause_name!("-"), (200, FY));
|
let mut parent_spec = DirectedOp::Left(clause_name!("-"), SharedOpDesc::new(200, FY));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match self.machine_st.store(self.machine_st.deref(addr)) {
|
match self.machine_st.store(self.machine_st.deref(addr)) {
|
||||||
Addr::Str(s) =>
|
Addr::Str(s) =>
|
||||||
match &self.machine_st.heap[s] {
|
match &self.machine_st.heap[s] {
|
||||||
&HeapCellValue::NamedStr(_, ref name, Some(spec))
|
&HeapCellValue::NamedStr(_, ref name, Some(ref spec))
|
||||||
if is_postfix!(spec.1) || is_infix!(spec.1) =>
|
if is_postfix!(spec.assoc()) || is_infix!(spec.assoc()) =>
|
||||||
if needs_bracketing(spec, &parent_spec) {
|
if needs_bracketing(spec, &parent_spec) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
addr = Addr::HeapCell(s+1);
|
addr = Addr::HeapCell(s+1);
|
||||||
parent_spec = DirectedOp::Right(name.clone(), spec);
|
parent_spec = DirectedOp::Right(name.clone(), spec.clone());
|
||||||
},
|
},
|
||||||
_ =>
|
_ =>
|
||||||
return false
|
return false
|
||||||
@@ -95,7 +106,7 @@ impl<'a> HCPreOrderIterator<'a> {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum TokenOrRedirect {
|
pub enum TokenOrRedirect {
|
||||||
Atom(ClauseName),
|
Atom(ClauseName),
|
||||||
Op(ClauseName, (usize, Specifier)),
|
Op(ClauseName, SharedOpDesc),
|
||||||
NumberedVar(String),
|
NumberedVar(String),
|
||||||
CompositeRedirect(DirectedOp),
|
CompositeRedirect(DirectedOp),
|
||||||
FunctorRedirect,
|
FunctorRedirect,
|
||||||
@@ -259,7 +270,7 @@ fn continues_with_append(atom: &str, op: &str) -> bool {
|
|||||||
if alpha_char!(ac) {
|
if alpha_char!(ac) {
|
||||||
alpha_numeric_char!(oc)
|
alpha_numeric_char!(oc)
|
||||||
} else if graphic_token_char!(ac) {
|
} else if graphic_token_char!(ac) {
|
||||||
graphic_char!(oc)
|
graphic_token_char!(oc)
|
||||||
} else if variable_indicator_char!(ac) {
|
} else if variable_indicator_char!(ac) {
|
||||||
alpha_numeric_char!(oc)
|
alpha_numeric_char!(oc)
|
||||||
} else if capital_letter_char!(ac) {
|
} else if capital_letter_char!(ac) {
|
||||||
@@ -354,7 +365,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
{
|
{
|
||||||
let mut printer = Self::new(machine_st, output);
|
let mut printer = Self::new(machine_st, output);
|
||||||
|
|
||||||
printer.toplevel_spec = Some(DirectedOp::Right(clause_name!("="), (700, XFX)));
|
printer.toplevel_spec = Some(DirectedOp::Right(clause_name!("="), SharedOpDesc::new(700, XFX)));
|
||||||
printer.heap_locs = reverse_heap_locs(machine_st, heap_locs);
|
printer.heap_locs = reverse_heap_locs(machine_st, heap_locs);
|
||||||
|
|
||||||
printer
|
printer
|
||||||
@@ -375,25 +386,25 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: create a DirectedOp factory method. Use it here, and above.
|
// TODO: create a DirectedOp factory method. Use it here, and above.
|
||||||
fn enqueue_op(&mut self, ct: ClauseType, spec: (usize, Specifier)) {
|
fn enqueue_op(&mut self, ct: ClauseType, spec: SharedOpDesc) {
|
||||||
if is_postfix!(spec.1) {
|
if is_postfix!(spec.assoc()) {
|
||||||
let right_directed_op = DirectedOp::Right(ct.name(), spec);
|
let right_directed_op = DirectedOp::Right(ct.name(), spec.clone());
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::Op(ct.name(), spec));
|
self.state_stack.push(TokenOrRedirect::Op(ct.name(), spec));
|
||||||
self.state_stack.push(TokenOrRedirect::CompositeRedirect(right_directed_op));
|
self.state_stack.push(TokenOrRedirect::CompositeRedirect(right_directed_op));
|
||||||
} else if is_prefix!(spec.1) {
|
} else if is_prefix!(spec.assoc()) {
|
||||||
if ct.name().as_str() == "-" {
|
if ct.name().as_str() == "-" {
|
||||||
self.format_negated_operand();
|
self.format_negated_operand(spec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let left_directed_op = DirectedOp::Left(ct.name(), spec);
|
let left_directed_op = DirectedOp::Left(ct.name(), spec.clone());
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::CompositeRedirect(left_directed_op));
|
self.state_stack.push(TokenOrRedirect::CompositeRedirect(left_directed_op));
|
||||||
self.state_stack.push(TokenOrRedirect::Op(ct.name(), spec));
|
self.state_stack.push(TokenOrRedirect::Op(ct.name(), spec));
|
||||||
} else { // if is_infix!(spec.1)
|
} else { // if is_infix!(spec.assoc())
|
||||||
let left_directed_op = DirectedOp::Left(ct.name(), spec);
|
let left_directed_op = DirectedOp::Left(ct.name(), spec.clone());
|
||||||
let right_directed_op = DirectedOp::Right(ct.name(), spec);
|
let right_directed_op = DirectedOp::Right(ct.name(), spec.clone());
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::CompositeRedirect(left_directed_op));
|
self.state_stack.push(TokenOrRedirect::CompositeRedirect(left_directed_op));
|
||||||
self.state_stack.push(TokenOrRedirect::Op(ct.name(), spec));
|
self.state_stack.push(TokenOrRedirect::Op(ct.name(), spec));
|
||||||
@@ -416,10 +427,10 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
self.state_stack.push(TokenOrRedirect::Atom(name));
|
self.state_stack.push(TokenOrRedirect::Atom(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_negated_operand(&mut self)
|
fn format_negated_operand(&mut self, spec: SharedOpDesc)
|
||||||
{
|
{
|
||||||
let op = DirectedOp::Left(clause_name!("-"), (200, FY));
|
let op = DirectedOp::Left(clause_name!("-"), spec);
|
||||||
|
|
||||||
self.state_stack.push(TokenOrRedirect::CompositeRedirect(op));
|
self.state_stack.push(TokenOrRedirect::CompositeRedirect(op));
|
||||||
self.state_stack.push(TokenOrRedirect::Space);
|
self.state_stack.push(TokenOrRedirect::Space);
|
||||||
self.state_stack.push(TokenOrRedirect::Atom(clause_name!("-")));
|
self.state_stack.push(TokenOrRedirect::Atom(clause_name!("-")));
|
||||||
@@ -452,10 +463,17 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
if self.format_numbered_vars(iter) {
|
if self.format_numbered_vars(iter) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(spec) = ct.spec() {
|
if let Some(spec) = ct.spec() {
|
||||||
if !self.ignore_ops {
|
if "." == ct.name().as_str() && is_infix!(spec.assoc()) {
|
||||||
|
if !self.ignore_ops {
|
||||||
|
self.push_list();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !self.ignore_ops && spec.prec() > 0 {
|
||||||
return self.enqueue_op(ct, spec);
|
return self.enqueue_op(ct, spec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,10 +646,10 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
if self.outputter.ends_with(&format!(" {}", op.as_str())) {
|
if self.outputter.ends_with(&format!(" {}", op.as_str())) {
|
||||||
self.push_char(' ');
|
self.push_char(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.push_char('(');
|
self.push_char('(');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.print_atom(atom);
|
self.print_atom(atom);
|
||||||
|
|
||||||
if op.is_some() {
|
if op.is_some() {
|
||||||
@@ -715,12 +733,12 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter>
|
|||||||
};
|
};
|
||||||
|
|
||||||
match heap_val {
|
match heap_val {
|
||||||
HeapCellValue::NamedStr(arity, ref name, Some(spec)) => {
|
HeapCellValue::NamedStr(arity, name, Some(spec)) => {
|
||||||
let add_brackets = if !self.ignore_ops {
|
let add_brackets = if !self.ignore_ops {
|
||||||
add_brackets || if let Some(ref op) = &op {
|
add_brackets || if let Some(ref op) = &op {
|
||||||
needs_bracketing(spec, op)
|
needs_bracketing(&spec, op)
|
||||||
} else {
|
} else {
|
||||||
is_functor_redirect && spec.0 >= 1000
|
is_functor_redirect && spec.prec() >= 1000
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -45,10 +45,9 @@ impl<'a> TermIterState<'a> {
|
|||||||
match term {
|
match term {
|
||||||
&Term::AnonVar =>
|
&Term::AnonVar =>
|
||||||
TermIterState::AnonVar(lvl),
|
TermIterState::AnonVar(lvl),
|
||||||
&Term::Clause(ref cell, ref name, ref subterms, spec) => {
|
&Term::Clause(ref cell, ref name, ref subterms, ref spec) => {
|
||||||
let ct = if let Some(spec) = spec {
|
let ct = if let Some(spec) = spec {
|
||||||
let op_decl = OpDecl(spec.0, spec.1, name.clone());
|
ClauseType::Op(name.clone(), spec.clone(), CodeIndex::default())
|
||||||
ClauseType::Op(op_decl, CodeIndex::default())
|
|
||||||
} else {
|
} else {
|
||||||
ClauseType::Named(name.clone(), subterms.len(), CodeIndex::default())
|
ClauseType::Named(name.clone(), subterms.len(), CodeIndex::default())
|
||||||
};
|
};
|
||||||
@@ -86,9 +85,9 @@ impl<'a> QueryIterator<'a> {
|
|||||||
let state = match term {
|
let state = match term {
|
||||||
&Term::AnonVar =>
|
&Term::AnonVar =>
|
||||||
return QueryIterator { state_stack: vec![] },
|
return QueryIterator { state_stack: vec![] },
|
||||||
&Term::Clause(ref r, ref name, ref terms, fixity) =>
|
&Term::Clause(ref r, ref name, ref terms, ref fixity) =>
|
||||||
TermIterState::Clause(Level::Root, 0, r,
|
TermIterState::Clause(Level::Root, 0, r,
|
||||||
ClauseType::from(name.clone(), terms.len(), fixity),
|
ClauseType::from(name.clone(), terms.len(), fixity.clone()),
|
||||||
terms),
|
terms),
|
||||||
&Term::Cons(..) =>
|
&Term::Cons(..) =>
|
||||||
return QueryIterator { state_stack: vec![] },
|
return QueryIterator { state_stack: vec![] },
|
||||||
@@ -200,8 +199,8 @@ impl<'a> FactIterator<'a> {
|
|||||||
let states = match term {
|
let states = match term {
|
||||||
&Term::AnonVar =>
|
&Term::AnonVar =>
|
||||||
vec![TermIterState::AnonVar(Level::Root)],
|
vec![TermIterState::AnonVar(Level::Root)],
|
||||||
&Term::Clause(ref cell, ref name, ref terms, fixity) => {
|
&Term::Clause(ref cell, ref name, ref terms, ref fixity) => {
|
||||||
let ct = ClauseType::from(name.clone(), terms.len(), fixity);
|
let ct = ClauseType::from(name.clone(), terms.len(), fixity.clone());
|
||||||
vec![TermIterState::Clause(Level::Root, 0, cell, ct, terms)]
|
vec![TermIterState::Clause(Level::Root, 0, cell, ct, terms)]
|
||||||
},
|
},
|
||||||
&Term::Cons(ref cell, ref head, ref tail) =>
|
&Term::Cons(ref cell, ref head, ref tail) =>
|
||||||
|
|||||||
@@ -395,8 +395,8 @@ impl ListingCompiler {
|
|||||||
if ct_name == &name && arity == ct_arity => {
|
if ct_name == &name && arity == ct_arity => {
|
||||||
*idx = self_idx.clone();
|
*idx = self_idx.clone();
|
||||||
},
|
},
|
||||||
&mut ClauseType::Op(ref op_decl, ref mut idx)
|
&mut ClauseType::Op(ref op_name, ref shared_op_desc, ref mut idx)
|
||||||
if op_decl.name() == name && op_decl.arity() == arity => {
|
if op_name == &name && shared_op_desc.arity() == arity => {
|
||||||
*idx = self_idx.clone();
|
*idx = self_idx.clone();
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -553,14 +553,11 @@ impl ListingCompiler {
|
|||||||
Declaration::NonCountedBacktracking(name, arity) =>
|
Declaration::NonCountedBacktracking(name, arity) =>
|
||||||
Ok(self.add_non_counted_bt_flag(name, arity)),
|
Ok(self.add_non_counted_bt_flag(name, arity)),
|
||||||
Declaration::Op(op_decl) => {
|
Declaration::Op(op_decl) => {
|
||||||
let existing_desc = {
|
let spec = get_desc(op_decl.name(), composite_op!(self.module.is_some(),
|
||||||
let comp_ops = composite_op!(self.module.is_some(), &wam_indices.op_dir,
|
&wam_indices.op_dir,
|
||||||
&mut indices.op_dir);
|
&mut indices.op_dir));
|
||||||
|
|
||||||
get_desc(op_decl.name(), comp_ops)
|
op_decl.submit(self.get_module_name(), spec, &mut indices.op_dir)
|
||||||
};
|
|
||||||
|
|
||||||
op_decl.submit(self.get_module_name(), existing_desc, &mut indices.op_dir)
|
|
||||||
},
|
},
|
||||||
Declaration::UseModule(name) =>
|
Declaration::UseModule(name) =>
|
||||||
self.use_module(name, code_repo, flags, wam_indices, indices),
|
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,
|
fn process_and_commit_decl<R: Read>(&mut self, decl: Declaration,
|
||||||
worker: &mut TopLevelBatchWorker<'a, R>,
|
worker: &mut TopLevelBatchWorker<R>,
|
||||||
indices: &mut IndexStore, flags: MachineFlags)
|
indices: &mut IndexStore, flags: MachineFlags)
|
||||||
-> Result<(), SessionError>
|
-> Result<(), SessionError>
|
||||||
{
|
{
|
||||||
match &decl {
|
match &decl {
|
||||||
&Declaration::Dynamic(ref name, arity) => {
|
&Declaration::Dynamic(ref name, arity) => {
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ impl<T: CopierTarget> CopyTermState<T> {
|
|||||||
self.target[addr] = HeapCellValue::Addr(Addr::Str(threshold));
|
self.target[addr] = HeapCellValue::Addr(Addr::Str(threshold));
|
||||||
|
|
||||||
self.trail.push((Ref::HeapCell(addr),
|
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));
|
self.target.push(HeapCellValue::NamedStr(arity, name, fixity));
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ pub(super) struct MachineError {
|
|||||||
impl MachineError {
|
impl MachineError {
|
||||||
pub(super) fn functor_stub(name: ClauseName, arity: usize) -> MachineStub {
|
pub(super) fn functor_stub(name: ClauseName, arity: usize) -> MachineStub {
|
||||||
let name = HeapCellValue::Addr(Addr::Con(Constant::Atom(name, None)));
|
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 {
|
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)),
|
stub.append(&mut functor!("/", 2, [HeapCellValue::Addr(Addr::HeapCell(h + 2 + 3)),
|
||||||
heap_integer!(arity)],
|
heap_integer!(arity)],
|
||||||
(400, YFX)));
|
SharedOpDesc::new(400, YFX)));
|
||||||
stub.append(&mut functor!(":", 2, [mod_name, name], (600, XFY)));
|
stub.append(&mut functor!(":", 2, [mod_name, name], SharedOpDesc::new(600, XFY)));
|
||||||
|
|
||||||
MachineError { stub, from: ErrorProvenance::Constructed }
|
MachineError { stub, from: ErrorProvenance::Constructed }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum DBRef {
|
pub enum DBRef {
|
||||||
BuiltInPred(ClauseName, usize, Option<(usize, Specifier)>),
|
BuiltInPred(ClauseName, usize, Option<SharedOpDesc>),
|
||||||
NamedPred(ClauseName, usize, Option<(usize, Specifier)>)
|
NamedPred(ClauseName, usize, Option<SharedOpDesc>)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||||
@@ -163,7 +163,7 @@ impl From<Ref> for TrailRef {
|
|||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub enum HeapCellValue {
|
pub enum HeapCellValue {
|
||||||
Addr(Addr),
|
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 {
|
impl HeapCellValue {
|
||||||
@@ -411,7 +411,7 @@ pub struct IndexStore {
|
|||||||
|
|
||||||
impl IndexStore {
|
impl IndexStore {
|
||||||
pub fn predicate_exists(&self, name: ClauseName, module: ClauseName, arity: usize,
|
pub fn predicate_exists(&self, name: ClauseName, module: ClauseName, arity: usize,
|
||||||
op_spec: Option<(usize, Specifier)>)
|
op_spec: Option<SharedOpDesc>)
|
||||||
-> bool
|
-> bool
|
||||||
{
|
{
|
||||||
match self.modules.get(&module) {
|
match self.modules.get(&module) {
|
||||||
@@ -419,8 +419,8 @@ impl IndexStore {
|
|||||||
match ClauseType::from(name, arity, op_spec) {
|
match ClauseType::from(name, arity, op_spec) {
|
||||||
ClauseType::Named(name, arity, _) =>
|
ClauseType::Named(name, arity, _) =>
|
||||||
module.code_dir.contains_key(&(name, arity)),
|
module.code_dir.contains_key(&(name, arity)),
|
||||||
ClauseType::Op(op_decl, ..) =>
|
ClauseType::Op(name, spec, ..) =>
|
||||||
module.code_dir.contains_key(&(op_decl.name(), op_decl.arity())),
|
module.code_dir.contains_key(&(name, spec.arity())),
|
||||||
_ =>
|
_ =>
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
@@ -428,8 +428,8 @@ impl IndexStore {
|
|||||||
match ClauseType::from(name, arity, op_spec) {
|
match ClauseType::from(name, arity, op_spec) {
|
||||||
ClauseType::Named(name, arity, _) =>
|
ClauseType::Named(name, arity, _) =>
|
||||||
self.code_dir.contains_key(&(name, arity)),
|
self.code_dir.contains_key(&(name, arity)),
|
||||||
ClauseType::Op(op_decl, ..) =>
|
ClauseType::Op(name, spec, ..) =>
|
||||||
self.code_dir.contains_key(&(op_decl.name(), op_decl.arity())),
|
self.code_dir.contains_key(&(name, spec.arity())),
|
||||||
_ =>
|
_ =>
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -538,11 +538,11 @@ pub(crate) trait CallPolicy: Any {
|
|||||||
|
|
||||||
let c = match machine_st.compare_term_test(&a2, &a3) {
|
let c = match machine_st.compare_term_test(&a2, &a3) {
|
||||||
Ordering::Greater => Addr::Con(Constant::Atom(clause_name!(">"),
|
Ordering::Greater => Addr::Con(Constant::Atom(clause_name!(">"),
|
||||||
Some((700, XFX)))),
|
Some(SharedOpDesc::new(700, XFX)))),
|
||||||
Ordering::Equal => Addr::Con(Constant::Atom(clause_name!("="),
|
Ordering::Equal => Addr::Con(Constant::Atom(clause_name!("="),
|
||||||
Some((700, XFX)))),
|
Some(SharedOpDesc::new(700, XFX)))),
|
||||||
Ordering::Less => Addr::Con(Constant::Atom(clause_name!("<"),
|
Ordering::Less => Addr::Con(Constant::Atom(clause_name!("<"),
|
||||||
Some((700, XFX))))
|
Some(SharedOpDesc::new(700, XFX))))
|
||||||
};
|
};
|
||||||
|
|
||||||
machine_st.unify(a1, c);
|
machine_st.unify(a1, c);
|
||||||
|
|||||||
@@ -1023,7 +1023,7 @@ impl MachineState {
|
|||||||
|
|
||||||
self.interms[t - 1] = try_or_fail!(self, self.pow(n1, n2));
|
self.interms[t - 1] = try_or_fail!(self, self.pow(n1, n2));
|
||||||
self.p += 1;
|
self.p += 1;
|
||||||
},
|
},
|
||||||
&ArithmeticInstruction::RDiv(ref a1, ref a2, t) => {
|
&ArithmeticInstruction::RDiv(ref a1, ref a2, t) => {
|
||||||
let stub = MachineError::functor_stub(clause_name!("(rdiv)"), 2);
|
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,
|
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 name = Addr::Con(Constant::Atom(name, spec));
|
||||||
let arity = Addr::Con(integer!(arity));
|
let arity = Addr::Con(integer!(arity));
|
||||||
@@ -2164,9 +2164,10 @@ impl MachineState {
|
|||||||
HeapCellValue::NamedStr(2, ref name, Some(_))
|
HeapCellValue::NamedStr(2, ref name, Some(_))
|
||||||
if *name == clause_name!("-") =>
|
if *name == clause_name!("-") =>
|
||||||
Ok(Addr::HeapCell(s+1)),
|
Ok(Addr::HeapCell(s+1)),
|
||||||
_ => Err(self.error_form(MachineError::type_error(ValidType::Pair,
|
_ =>
|
||||||
self.heap[s].as_addr(s)),
|
Err(self.error_form(MachineError::type_error(ValidType::Pair,
|
||||||
stub))
|
self.heap[s].as_addr(s)),
|
||||||
|
stub))
|
||||||
},
|
},
|
||||||
a => Err(self.error_form(MachineError::type_error(ValidType::Pair, a), 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);
|
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(),
|
try_or_fail!(self, call_policy.context_call(self, name.clone(), arity, idx.clone(),
|
||||||
indices)),
|
indices)),
|
||||||
&ClauseType::System(ref ct) =>
|
&ClauseType::System(ref ct) =>
|
||||||
|
|||||||
@@ -274,13 +274,7 @@ impl Machine {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_batched_ops(&mut self, op_dir: OpDir) {
|
pub fn add_batched_ops(&mut self, op_dir: OpDir) {
|
||||||
for ((name, fixity), info) in op_dir {
|
self.indices.op_dir.extend(op_dir.into_iter());
|
||||||
if info.1 == 0 {
|
|
||||||
self.indices.op_dir.remove(&(name, fixity));
|
|
||||||
} else {
|
|
||||||
self.indices.op_dir.insert((name, fixity), info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ pub trait SubModuleUser
|
|||||||
|
|
||||||
fn insert_dir_entry(&mut self, ClauseName, usize, CodeIndex);
|
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)
|
fn remove_module(&mut self, mod_name: ClauseName, module: &Module)
|
||||||
{
|
{
|
||||||
for (name, arity) in module.module_decl.exports.iter().cloned() {
|
for (name, arity) in module.module_decl.exports.iter().cloned() {
|
||||||
@@ -86,21 +91,21 @@ pub trait SubModuleUser
|
|||||||
|
|
||||||
// remove or respecify ops.
|
// remove or respecify ops.
|
||||||
if arity == 2 {
|
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 {
|
if mod_name == module.module_decl.name {
|
||||||
self.op_dir().remove(&(name.clone(), Fixity::In));
|
self.op_dir().remove(&(name.clone(), Fixity::In));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if arity == 1 {
|
} 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 {
|
if mod_name == module.module_decl.name {
|
||||||
self.op_dir().remove(&(name.clone(), Fixity::Pre));
|
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 {
|
if mod_name == module.module_decl.name {
|
||||||
self.op_dir().remove(&(name.clone(), Fixity::Post));
|
self.op_dir().remove(&(name.clone(), Fixity::Post));
|
||||||
|
|||||||
@@ -570,8 +570,8 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
&SystemClauseType::OpDeclaration => {
|
&SystemClauseType::OpDeclaration => {
|
||||||
let priority = self[temp_v!(1)].clone();
|
let priority = self[temp_v!(1)].clone();
|
||||||
let specifier = self[temp_v!(2)].clone();
|
let specifier = self[temp_v!(2)].clone();
|
||||||
let op = self[temp_v!(3)].clone();
|
let op = self[temp_v!(3)].clone();
|
||||||
|
|
||||||
let priority = match self.store(self.deref(priority)) {
|
let priority = match self.store(self.deref(priority)) {
|
||||||
@@ -599,8 +599,8 @@ impl MachineState {
|
|||||||
if op_decl.0 == 0 {
|
if op_decl.0 == 0 {
|
||||||
Ok(op_decl.remove(&mut indices.op_dir))
|
Ok(op_decl.remove(&mut indices.op_dir))
|
||||||
} else {
|
} else {
|
||||||
let desc = get_desc(op_decl.name(), composite_op!(&indices.op_dir));
|
let spec = get_desc(op_decl.name(), composite_op!(&indices.op_dir));
|
||||||
op_decl.submit(module, desc, &mut indices.op_dir)
|
op_decl.submit(module, spec, &mut indices.op_dir)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
match ClauseType::from(name, arity, spec) {
|
||||||
ClauseType::Named(name, arity, _) => {
|
ClauseType::Named(name, arity, _) => {
|
||||||
let idx = self.get_code_index(name.clone(), arity);
|
let idx = self.get_code_index(name.clone(), arity);
|
||||||
ClauseType::Named(name, arity, idx.clone())
|
ClauseType::Named(name, arity, idx.clone())
|
||||||
},
|
},
|
||||||
ClauseType::Op(op_decl, _) => {
|
ClauseType::Op(name, spec, _) => {
|
||||||
let idx = self.get_code_index(op_decl.2.clone(), arity);
|
let idx = self.get_code_index(name.clone(), arity);
|
||||||
ClauseType::Op(op_decl, idx.clone())
|
ClauseType::Op(name, spec, idx.clone())
|
||||||
},
|
},
|
||||||
ct => ct
|
ct => ct
|
||||||
}
|
}
|
||||||
@@ -741,8 +741,8 @@ impl RelationWorker {
|
|||||||
self.dynamic_clauses.extend(other.dynamic_clauses.into_iter());
|
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)
|
fn expand_queue_contents<R>(&mut self, term_stream: &mut TermStream<R>, op_dir: &OpDir)
|
||||||
-> Result<(), SessionError>
|
-> Result<(), SessionError>
|
||||||
where R: Read
|
where R: Read
|
||||||
{
|
{
|
||||||
let mut machine_st = MachineState::new();
|
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)
|
fn term_to_toplevel<R>(term_stream: &mut TermStream<R>, code_dir: &mut CodeDir, term: Term)
|
||||||
-> Result<(TopLevel, RelationWorker), ParserError>
|
-> Result<(TopLevel, RelationWorker), ParserError>
|
||||||
where R: Read
|
where R: Read
|
||||||
{
|
{
|
||||||
let mut rel_worker = RelationWorker::new();
|
let mut rel_worker = RelationWorker::new();
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ impl fmt::Display for ClauseType {
|
|||||||
&ClauseType::System(SystemClauseType::SetCutPoint(r)) =>
|
&ClauseType::System(SystemClauseType::SetCutPoint(r)) =>
|
||||||
write!(f, "$set_cp({})", r),
|
write!(f, "$set_cp({})", r),
|
||||||
&ClauseType::Named(ref name, _, ref idx)
|
&ClauseType::Named(ref name, _, ref idx)
|
||||||
| &ClauseType::Op(OpDecl(.., ref name), ref idx) =>
|
| &ClauseType::Op(ref name, _, ref idx) =>
|
||||||
{
|
{
|
||||||
let idx = idx.0.borrow();
|
let idx = idx.0.borrow();
|
||||||
write!(f, "{}:{}/{}", idx.1, name, idx.0)
|
write!(f, "{}:{}/{}", idx.1, name, idx.0)
|
||||||
@@ -150,9 +150,9 @@ impl fmt::Display for HeapCellValue {
|
|||||||
match self {
|
match self {
|
||||||
&HeapCellValue::Addr(ref addr) =>
|
&HeapCellValue::Addr(ref addr) =>
|
||||||
write!(f, "{}", addr),
|
write!(f, "{}", addr),
|
||||||
&HeapCellValue::NamedStr(arity, ref name, Some((priority, spec))) =>
|
&HeapCellValue::NamedStr(arity, ref name, Some(ref cell)) =>
|
||||||
write!(f, "{}/{} (op, priority: {}, spec: {})", name.as_str(), arity,
|
write!(f, "{}/{} (op, priority: {}, spec: {})", name.as_str(), arity,
|
||||||
priority, spec),
|
cell.prec(), cell.assoc()),
|
||||||
&HeapCellValue::NamedStr(arity, ref name, None) =>
|
&HeapCellValue::NamedStr(arity, ref name, None) =>
|
||||||
write!(f, "{}/{}", name.as_str(), arity)
|
write!(f, "{}/{}", name.as_str(), arity)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user