treat functors with PI '.'/2 as lists (#1570)
This commit is contained in:
@@ -1466,17 +1466,20 @@ impl<I: Indexer> CodeOffsets<I> {
|
||||
atom_tbl: &mut AtomTable,
|
||||
) {
|
||||
match optimal_arg {
|
||||
&Term::Clause(_, atom!("."), ref terms) if terms.len() == 2 => {
|
||||
clause_index_info.opt_arg_index_key = OptArgIndexKey::List(self.optimal_index, 0);
|
||||
self.index_list(index);
|
||||
}
|
||||
&Term::Cons(..) | &Term::Literal(_, Literal::String(_)) | &Term::PartialString(..) => {
|
||||
clause_index_info.opt_arg_index_key = OptArgIndexKey::List(self.optimal_index, 0);
|
||||
self.index_list(index);
|
||||
}
|
||||
&Term::Clause(_, name, ref terms) => {
|
||||
clause_index_info.opt_arg_index_key =
|
||||
OptArgIndexKey::Structure(self.optimal_index, 0, name.clone(), terms.len());
|
||||
|
||||
self.index_structure(name, terms.len(), index);
|
||||
}
|
||||
&Term::Cons(..) | &Term::Literal(_, Literal::String(_)) | &Term::PartialString(..) => {
|
||||
clause_index_info.opt_arg_index_key = OptArgIndexKey::List(self.optimal_index, 0);
|
||||
|
||||
self.index_list(index);
|
||||
}
|
||||
&Term::Literal(_, constant) => {
|
||||
let overlapping_constants = self.index_constant(atom_tbl, constant, index);
|
||||
|
||||
|
||||
@@ -371,8 +371,14 @@ impl Machine {
|
||||
c
|
||||
}
|
||||
(HeapCellValueTag::Str, st) => {
|
||||
let arity = cell_as_atom_cell!(self.machine_st.heap[st]).get_arity();
|
||||
if arity == 0 { c } else { s }
|
||||
let (name, arity) = cell_as_atom_cell!(self.machine_st.heap[st])
|
||||
.get_name_and_arity();
|
||||
|
||||
match (name, arity) {
|
||||
(atom!("."), 2) => l,
|
||||
(_, 0) => c,
|
||||
_ => s,
|
||||
}
|
||||
}
|
||||
(HeapCellValueTag::Cons, ptr) => {
|
||||
match ptr.get_tag() {
|
||||
@@ -2812,6 +2818,19 @@ impl Machine {
|
||||
self.machine_st.s_offset = 0;
|
||||
self.machine_st.mode = MachineMode::Read;
|
||||
}
|
||||
(HeapCellValueTag::Str, s) => {
|
||||
let (name, arity) = cell_as_atom_cell!(self.machine_st.heap[s])
|
||||
.get_name_and_arity();
|
||||
|
||||
if name == atom!(".") && arity == 2 {
|
||||
self.machine_st.s = HeapPtr::HeapCell(s+1);
|
||||
self.machine_st.s_offset = 0;
|
||||
self.machine_st.mode = MachineMode::Read;
|
||||
} else {
|
||||
self.machine_st.backtrack();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
(HeapCellValueTag::Lis, l) => {
|
||||
self.machine_st.s = HeapPtr::HeapCell(l);
|
||||
self.machine_st.s_offset = 0;
|
||||
|
||||
Reference in New Issue
Block a user