emit stream aliases as permission error culprits whenever possible
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::arena::*;
|
||||||
use crate::atom_table::*;
|
use crate::atom_table::*;
|
||||||
use crate::parser::ast::*;
|
use crate::parser::ast::*;
|
||||||
|
|
||||||
@@ -6,6 +7,7 @@ use crate::forms::*;
|
|||||||
use crate::machine::heap::*;
|
use crate::machine::heap::*;
|
||||||
use crate::machine::loader::CompilationTarget;
|
use crate::machine::loader::CompilationTarget;
|
||||||
use crate::machine::machine_state::*;
|
use crate::machine::machine_state::*;
|
||||||
|
use crate::machine::streams::*;
|
||||||
use crate::machine::system_calls::BrentAlgState;
|
use crate::machine::system_calls::BrentAlgState;
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
|
||||||
@@ -158,9 +160,29 @@ impl PermissionError for HeapCellValue {
|
|||||||
index_atom: Atom,
|
index_atom: Atom,
|
||||||
perm: Permission,
|
perm: Permission,
|
||||||
) -> MachineError {
|
) -> MachineError {
|
||||||
|
let cell = read_heap_cell!(self,
|
||||||
|
(HeapCellValueTag::Cons, ptr) => {
|
||||||
|
match_untyped_arena_ptr!(ptr,
|
||||||
|
(ArenaHeaderTag::Stream, stream) => {
|
||||||
|
if let Some(alias) = stream.options().get_alias() {
|
||||||
|
atom_as_cell!(alias)
|
||||||
|
} else {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
let stub = functor!(
|
let stub = functor!(
|
||||||
atom!("permission_error"),
|
atom!("permission_error"),
|
||||||
[atom(perm.as_atom()), atom(index_atom), cell(self)]
|
[atom(perm.as_atom()), atom(index_atom), cell(cell)]
|
||||||
);
|
);
|
||||||
|
|
||||||
MachineError {
|
MachineError {
|
||||||
|
|||||||
@@ -1547,7 +1547,15 @@ impl MachineState {
|
|||||||
arity: usize,
|
arity: usize,
|
||||||
) -> MachineStub {
|
) -> MachineStub {
|
||||||
let stub = functor_stub(caller, arity);
|
let stub = functor_stub(caller, arity);
|
||||||
let err = self.permission_error(perm, err_atom, stream_as_cell!(stream));
|
let err = self.permission_error(
|
||||||
|
perm,
|
||||||
|
err_atom,
|
||||||
|
if let Some(alias) = stream.options().get_alias() {
|
||||||
|
atom_as_cell!(alias)
|
||||||
|
} else {
|
||||||
|
stream_as_cell!(stream)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
self.error_form(err, stub)
|
self.error_form(err, stub)
|
||||||
}
|
}
|
||||||
@@ -1715,7 +1723,7 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
ErrorKind::PermissionDenied => {
|
ErrorKind::PermissionDenied => {
|
||||||
// 8.11.5.3k)
|
// 8.11.5.3k)
|
||||||
return Err(self.open_permission_error(self[temp_v!(1)], atom!("open"), 4));
|
return Err(self.open_permission_error(self.registers[1], atom!("open"), 4));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let stub = functor_stub(atom!("open"), 4);
|
let stub = functor_stub(atom!("open"), 4);
|
||||||
|
|||||||
Reference in New Issue
Block a user