Merge pull request #327 from srenatus/sr/pass-argv-as-partial-strings
use partial strings for passing argv to toplevel.pl
This commit is contained in:
@@ -342,21 +342,14 @@ impl Machine {
|
|||||||
pub fn run_top_level(&mut self) {
|
pub fn run_top_level(&mut self) {
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
let mut filename_atoms = vec![];
|
let mut arg_pstrs = vec![];
|
||||||
|
for arg in env::args() {
|
||||||
// the first of these is the path to the scryer-prolog executable, so skip
|
arg_pstrs.push(self.machine_st.heap.put_complete_string(&arg));
|
||||||
// it.
|
|
||||||
for filename in env::args().skip(1) {
|
|
||||||
let atom = clause_name!(filename, self.indices.atom_tbl);
|
|
||||||
filename_atoms.push(HeapCellValue::Atom(atom, None));
|
|
||||||
}
|
}
|
||||||
|
let list_addr = Addr::HeapCell(self.machine_st.heap.to_list(arg_pstrs.into_iter()));
|
||||||
let list_addr =
|
|
||||||
Addr::HeapCell(self.machine_st.heap.to_list(filename_atoms.into_iter()));
|
|
||||||
|
|
||||||
self.machine_st[temp_v!(1)] = list_addr;
|
self.machine_st[temp_v!(1)] = list_addr;
|
||||||
self.machine_st.p = CodePtr::Local(LocalCodePtr::DirEntry(self.toplevel_idx));
|
self.machine_st.p = CodePtr::Local(LocalCodePtr::DirEntry(self.toplevel_idx));
|
||||||
|
|
||||||
self.run_query();
|
self.run_query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
:- module('$toplevel', ['$repl'/1, consult/1, use_module/1, use_module/2]).
|
:- module('$toplevel', ['$repl'/1, consult/1, use_module/1, use_module/2]).
|
||||||
|
|
||||||
'$repl'(ListOfModules) :-
|
'$repl'([_|Args]) :-
|
||||||
maplist('$use_list_of_modules', ListOfModules),
|
maplist('$use_list_of_modules', Args),
|
||||||
false.
|
false.
|
||||||
'$repl'(_) :- '$repl'.
|
'$repl'(_) :- '$repl'.
|
||||||
|
|
||||||
'$use_list_of_modules'(Module) :-
|
'$use_list_of_modules'(Mod0) :-
|
||||||
catch(use_module(Module), E, '$print_exception'(E)).
|
atom_chars(Mod, Mod0),
|
||||||
|
catch(use_module(Mod), E, '$print_exception'(E)).
|
||||||
|
|
||||||
'$repl' :-
|
'$repl' :-
|
||||||
catch('$read_and_match', E, '$print_exception'(E)),
|
catch('$read_and_match', E, '$print_exception'(E)),
|
||||||
|
|||||||
Reference in New Issue
Block a user