restore .scryerrc loading
This commit is contained in:
@@ -307,6 +307,7 @@ pub enum SystemClauseType {
|
|||||||
IsSTOEnabled,
|
IsSTOEnabled,
|
||||||
SetSTOAsUnify,
|
SetSTOAsUnify,
|
||||||
SetNSTOAsUnify,
|
SetNSTOAsUnify,
|
||||||
|
HomeDirectory,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SystemClauseType {
|
impl SystemClauseType {
|
||||||
@@ -591,6 +592,7 @@ impl SystemClauseType {
|
|||||||
&SystemClauseType::IsSTOEnabled => clause_name!("$is_sto_enabled"),
|
&SystemClauseType::IsSTOEnabled => clause_name!("$is_sto_enabled"),
|
||||||
&SystemClauseType::SetSTOAsUnify => clause_name!("$set_sto_as_unify"),
|
&SystemClauseType::SetSTOAsUnify => clause_name!("$set_sto_as_unify"),
|
||||||
&SystemClauseType::SetNSTOAsUnify => clause_name!("$set_nsto_as_unify"),
|
&SystemClauseType::SetNSTOAsUnify => clause_name!("$set_nsto_as_unify"),
|
||||||
|
&SystemClauseType::HomeDirectory => clause_name!("$home_directory"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,6 +841,7 @@ impl SystemClauseType {
|
|||||||
("$is_sto_enabled", 1) => Some(SystemClauseType::IsSTOEnabled),
|
("$is_sto_enabled", 1) => Some(SystemClauseType::IsSTOEnabled),
|
||||||
("$set_sto_as_unify", 0) => Some(SystemClauseType::SetSTOAsUnify),
|
("$set_sto_as_unify", 0) => Some(SystemClauseType::SetSTOAsUnify),
|
||||||
("$set_nsto_as_unify", 0) => Some(SystemClauseType::SetNSTOAsUnify),
|
("$set_nsto_as_unify", 0) => Some(SystemClauseType::SetNSTOAsUnify),
|
||||||
|
("$home_directory", 1) => Some(SystemClauseType::HomeDirectory),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,34 +126,6 @@ fn current_dir() -> PathBuf {
|
|||||||
include!(concat!(env!("OUT_DIR"), "/libraries.rs"));
|
include!(concat!(env!("OUT_DIR"), "/libraries.rs"));
|
||||||
|
|
||||||
impl Machine {
|
impl Machine {
|
||||||
/*
|
|
||||||
fn compile_scryerrc(&mut self) {
|
|
||||||
let mut path = match dirs_next::home_dir() {
|
|
||||||
Some(path) => path,
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
path.push(".scryerrc");
|
|
||||||
|
|
||||||
if path.is_file() {
|
|
||||||
let file_src = match File::open(&path) {
|
|
||||||
Ok(file_handle) => Stream::from_file_as_input(
|
|
||||||
clause_name!(".scryerrc"),
|
|
||||||
file_handle,
|
|
||||||
),
|
|
||||||
Err(_) => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
let rc_src = ListingSource::from_file_and_path(
|
|
||||||
clause_name!(".scryerrc"),
|
|
||||||
path.to_path_buf(),
|
|
||||||
);
|
|
||||||
|
|
||||||
compile_user_module(self, file_src, rc_src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fn run_module_predicate(&mut self, module_name: ClauseName, key: PredicateKey) {
|
fn run_module_predicate(&mut self, module_name: ClauseName, key: PredicateKey) {
|
||||||
if let Some(module) = self.indices.modules.get(&module_name) {
|
if let Some(module) = self.indices.modules.get(&module_name) {
|
||||||
if let Some(ref code_index) = module.code_dir.get(&key) {
|
if let Some(ref code_index) = module.code_dir.get(&key) {
|
||||||
|
|||||||
@@ -5454,6 +5454,28 @@ impl MachineState {
|
|||||||
&SystemClauseType::SetNSTOAsUnify => {
|
&SystemClauseType::SetNSTOAsUnify => {
|
||||||
self.unify_fn = MachineState::unify;
|
self.unify_fn = MachineState::unify;
|
||||||
}
|
}
|
||||||
|
&SystemClauseType::HomeDirectory => {
|
||||||
|
let path = match dirs_next::home_dir() {
|
||||||
|
Some(path) => path,
|
||||||
|
None => {
|
||||||
|
self.fail = true;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if path.is_dir() {
|
||||||
|
if let Some(path) = path.to_str() {
|
||||||
|
let path_atom = self.heap.to_unifiable(
|
||||||
|
HeapCellValue::Atom(clause_name!(path.to_string(), self.atom_tbl), None),
|
||||||
|
);
|
||||||
|
|
||||||
|
(self.unify_fn)(self, self[temp_v!(1)], path_atom);
|
||||||
|
return return_from_clause!(self.last_call, self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.fail = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return_from_clause!(self.last_call, self)
|
return_from_clause!(self.last_call, self)
|
||||||
|
|||||||
@@ -9,6 +9,13 @@
|
|||||||
:- use_module(library('$project_atts')).
|
:- use_module(library('$project_atts')).
|
||||||
:- use_module(library('$atts')).
|
:- use_module(library('$atts')).
|
||||||
|
|
||||||
|
load_scryerrc :-
|
||||||
|
( '$home_directory'(HomeDir) ->
|
||||||
|
atom_concat(HomeDir, '/.scryerrc', ScryerrcFile),
|
||||||
|
catch(use_module(ScryerrcFile), E, print_exception(E))
|
||||||
|
; true
|
||||||
|
).
|
||||||
|
|
||||||
:- dynamic(argv/1).
|
:- dynamic(argv/1).
|
||||||
|
|
||||||
'$repl'([_|Args0]) :-
|
'$repl'([_|Args0]) :-
|
||||||
@@ -19,12 +26,14 @@
|
|||||||
; asserta('$toplevel':argv([])),
|
; asserta('$toplevel':argv([])),
|
||||||
Args = Args0
|
Args = Args0
|
||||||
),
|
),
|
||||||
|
load_scryerrc,
|
||||||
delegate_task(Args, []),
|
delegate_task(Args, []),
|
||||||
repl.
|
repl.
|
||||||
'$repl'(_) :-
|
'$repl'(_) :-
|
||||||
( \+ argv(_) -> asserta('$toplevel':argv([]))
|
( \+ argv(_) -> asserta('$toplevel':argv([]))
|
||||||
; true
|
; true
|
||||||
),
|
),
|
||||||
|
load_scryerrc,
|
||||||
repl.
|
repl.
|
||||||
|
|
||||||
delegate_task([], []).
|
delegate_task([], []).
|
||||||
|
|||||||
Reference in New Issue
Block a user