consume whitespace before reading a term in loader.pl, modify prolog_load_context at file key to better reflect loading context, use it when reporting singleton variables (#812)
This commit is contained in:
@@ -1612,20 +1612,26 @@ impl Machine {
|
||||
|
||||
pub(crate) fn load_context_file(&mut self) {
|
||||
if let Some(load_context) = self.load_contexts.last() {
|
||||
if let Some(file_name) = load_context.path.file_name() {
|
||||
let file_name_str = file_name.to_str().unwrap();
|
||||
let file_name_atom =
|
||||
clause_name!(file_name_str.to_string(), self.machine_st.atom_tbl);
|
||||
match load_context.path.file_name() {
|
||||
Some(file_name) if load_context.path.is_file() => {
|
||||
let file_name_str = file_name.to_str().unwrap();
|
||||
let file_name_atom =
|
||||
clause_name!(file_name_str.to_string(), self.machine_st.atom_tbl);
|
||||
|
||||
let file_name_addr = Addr::Con(
|
||||
self.machine_st
|
||||
.heap
|
||||
.push(HeapCellValue::Atom(file_name_atom, None)),
|
||||
);
|
||||
|
||||
let file_name_addr = Addr::Con(
|
||||
self.machine_st
|
||||
.heap
|
||||
.push(HeapCellValue::Atom(file_name_atom, None)),
|
||||
);
|
||||
.unify(file_name_addr, self.machine_st[temp_v!(1)]);
|
||||
|
||||
self.machine_st
|
||||
.unify(file_name_addr, self.machine_st[temp_v!(1)]);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
return self.load_context_module();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -395,6 +395,7 @@ impl Stream {
|
||||
StreamInstance::TlsStream(..) |
|
||||
StreamInstance::ReadlineStream(..) |
|
||||
StreamInstance::StaticStr(..) |
|
||||
StreamInstance::PausedPrologStream(..) |
|
||||
StreamInstance::Bytes(..) => Some(0),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
@@ -3888,54 +3888,6 @@ impl MachineState {
|
||||
|
||||
self.unify(a1, a2);
|
||||
}
|
||||
/*
|
||||
&SystemClauseType::GetClause => {
|
||||
let head = self[temp_v!(1)];
|
||||
|
||||
let subsection = match self.store(self.deref(head)) {
|
||||
Addr::Str(s) => match &self.heap[s] {
|
||||
&HeapCellValue::NamedStr(arity, ref name, ..) => {
|
||||
indices.get_clause_subsection(
|
||||
name.owning_module(),
|
||||
name.clone(),
|
||||
arity,
|
||||
)
|
||||
}
|
||||
_ => {
|
||||
unreachable!()
|
||||
}
|
||||
},
|
||||
Addr::Con(h) if self.heap.atom_at(h) => {
|
||||
if let &HeapCellValue::Atom(ref name, _) = &self.heap[h] {
|
||||
indices.get_clause_subsection(
|
||||
name.owning_module(),
|
||||
name.clone(),
|
||||
0,
|
||||
)
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
unreachable!()
|
||||
}
|
||||
};
|
||||
|
||||
match subsection {
|
||||
Some(dynamic_predicate_info) => {
|
||||
self.execute_at_index(
|
||||
2,
|
||||
dir_entry!(dynamic_predicate_info.clauses_subsection_p),
|
||||
);
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
_ => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
&SystemClauseType::GetCutPoint => {
|
||||
let a1 = self[temp_v!(1)];
|
||||
let a2 = Addr::CutPoint(self.b0);
|
||||
@@ -5496,6 +5448,18 @@ impl MachineState {
|
||||
}
|
||||
}
|
||||
}
|
||||
&SystemClauseType::DevourWhitespace => {
|
||||
let stream =
|
||||
self.get_stream_or_alias(self[temp_v!(1)], indices, "$devour_whitespace", 1)?;
|
||||
|
||||
match self.devour_whitespace(stream, self.atom_tbl.clone()) {
|
||||
Ok(false) => {} // not at EOF.
|
||||
_ => {
|
||||
self.fail = true;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return_from_clause!(self.last_call, self)
|
||||
|
||||
Reference in New Issue
Block a user