add op info to structures and atoms

This commit is contained in:
Mark Thom
2019-01-19 22:27:40 -07:00
parent ca7e62928b
commit 0dabb3f370
9 changed files with 76 additions and 83 deletions

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)], Fixity::In)
functor!("/", 2, [name, heap_integer!(arity)], (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)],
Fixity::In));
stub.append(&mut functor!(":", 2, [mod_name, name], Fixity::In));
(400, YFX)));
stub.append(&mut functor!(":", 2, [mod_name, name], (600, XFY)));
MachineError { stub, from: ErrorProvenance::Constructed }
}
@@ -258,7 +258,7 @@ impl MachineState {
loop {
match self.heap[new_l].clone() {
HeapCellValue::Addr(Addr::Str(l)) => new_l = l,
HeapCellValue::NamedStr(2, ref name, Some(Fixity::In))
HeapCellValue::NamedStr(2, ref name, Some(_))
if name.as_str() == "-" => break,
HeapCellValue::Addr(Addr::HeapCell(_)) => break,
HeapCellValue::Addr(Addr::StackCell(..)) => break,
@@ -278,7 +278,7 @@ impl MachineState {
// see 8.4.4 of Draft Technical Corrigendum 2.
pub(super) fn check_keysort_errors(&self) -> CallResult {
let stub = MachineError::functor_stub(clause_name!("keysort"), 2);
let stub = MachineError::functor_stub(clause_name!("keysort"), 2);
let pairs = self.store(self.deref(self[temp_v!(1)].clone()));
let sorted = self.store(self.deref(self[temp_v!(2)].clone()));

View File

@@ -567,7 +567,7 @@ impl MachineState {
for heap_val in self.post_order_iter(a) {
match heap_val {
HeapCellValue::NamedStr(2, name, Some(Fixity::In)) => {
HeapCellValue::NamedStr(2, name, Some(_)) => {
let a2 = interms.pop().unwrap();
let a1 = interms.pop().unwrap();
@@ -597,7 +597,7 @@ impl MachineState {
caller))
}
},
HeapCellValue::NamedStr(1, name, Some(Fixity::Pre)) => {
HeapCellValue::NamedStr(1, name, Some(_)) => {
let a1 = interms.pop().unwrap();
match name.as_str() {
@@ -1033,7 +1033,7 @@ impl MachineState {
let h = self.heap.h;
self.heap.push(HeapCellValue::Addr(Addr::Str(h + 1)));
self.heap.push(HeapCellValue::NamedStr(arity, ct.name(), ct.fixity()));
self.heap.push(HeapCellValue::NamedStr(arity, ct.name(), ct.spec()));
self.bind(addr.as_var().unwrap(), Addr::HeapCell(h));
@@ -1214,7 +1214,7 @@ impl MachineState {
&QueryInstruction::PutStructure(ref ct, arity, reg) => {
let h = self.heap.h;
self.heap.push(HeapCellValue::NamedStr(arity, ct.name(), ct.fixity()));
self.heap.push(HeapCellValue::NamedStr(arity, ct.name(), ct.spec()));
self[reg] = Addr::Str(h);
},
&QueryInstruction::PutUnsafeValue(n, arg) => {
@@ -1969,7 +1969,7 @@ impl MachineState {
Err(self.error_form(MachineError::instantiation_error(), stub)),
Addr::Str(s) =>
match self.heap[s].clone() {
HeapCellValue::NamedStr(2, ref name, Some(Fixity::In))
HeapCellValue::NamedStr(2, ref name, Some(_))
if *name == clause_name!("-") =>
Ok(Addr::HeapCell(s+1)),
_ => Err(self.error_form(MachineError::type_error(ValidType::Pair,
@@ -2164,7 +2164,7 @@ impl MachineState {
try_or_fail!(self, call_policy.compile_hook(self, hook)),
&ClauseType::Inlined(ref ct) =>
self.execute_inlined(ct),
&ClauseType::Named(ref name, ref idx) | &ClauseType::Op(ref name, _, ref idx) =>
&ClauseType::Named(ref name, ref idx) | &ClauseType::Op(OpDecl(.., ref name), ref idx) =>
try_or_fail!(self, call_policy.context_call(self, name.clone(), arity, idx.clone(),
indices)),
&ClauseType::System(ref ct) =>