Enhanced version

This commit is contained in:
notoria
2020-05-01 16:46:31 +02:00
parent b911d2fda4
commit 6ae7ae0210
4 changed files with 14 additions and 6 deletions

View File

@@ -36,11 +36,6 @@ fn main() {
let handler = signal::SigHandler::Handler(handle_sigint); let handler = signal::SigHandler::Handler(handle_sigint);
unsafe { signal::signal(signal::Signal::SIGINT, handler) }.unwrap(); unsafe { signal::signal(signal::Signal::SIGINT, handler) }.unwrap();
if env::args().skip(1).any(|a| a == "-v" || a == "--version") {
println!("{:}", git_version!(cargo_prefix = "cargo:", fallback = "unknown"));
return;
}
let mut wam = Machine::new(readline::input_stream(), Stream::stdout()); let mut wam = Machine::new(readline::input_stream(), Stream::stdout());
wam.run_top_level(); wam.run_top_level();
} }

View File

@@ -264,6 +264,7 @@ pub enum SystemClauseType {
WAMInstructions, WAMInstructions,
WriteTerm, WriteTerm,
WriteTermToChars, WriteTermToChars,
ScryerPrologVersion,
} }
impl SystemClauseType { impl SystemClauseType {
@@ -418,6 +419,7 @@ impl SystemClauseType {
&SystemClauseType::WAMInstructions => clause_name!("$wam_instructions"), &SystemClauseType::WAMInstructions => clause_name!("$wam_instructions"),
&SystemClauseType::WriteTerm => clause_name!("$write_term"), &SystemClauseType::WriteTerm => clause_name!("$write_term"),
&SystemClauseType::WriteTermToChars => clause_name!("$write_term_to_chars"), &SystemClauseType::WriteTermToChars => clause_name!("$write_term_to_chars"),
&SystemClauseType::ScryerPrologVersion => clause_name!("$scryer_prolog_version"),
} }
} }
@@ -552,6 +554,7 @@ impl SystemClauseType {
("$wam_instructions", 3) => Some(SystemClauseType::WAMInstructions), ("$wam_instructions", 3) => Some(SystemClauseType::WAMInstructions),
("$write_term", 6) => Some(SystemClauseType::WriteTerm), ("$write_term", 6) => Some(SystemClauseType::WriteTerm),
("$write_term_to_chars", 7) => Some(SystemClauseType::WriteTermToChars), ("$write_term_to_chars", 7) => Some(SystemClauseType::WriteTermToChars),
("$scryer_prolog_version", 1) => Some(SystemClauseType::ScryerPrologVersion),
_ => None, _ => None,
} }
} }

View File

@@ -3515,6 +3515,15 @@ impl MachineState {
unreachable!() unreachable!()
} }
} }
&SystemClauseType::ScryerPrologVersion => {
use crate::git_version::git_version;
let version = self[temp_v!(1)];
let buffer =
git_version!(cargo_prefix = "cargo:", fallback = "unknown");
let chars = buffer.chars().map(|c| Addr::Char(c));
let result = Addr::HeapCell(self.heap.to_list(chars));
self.unify(version, result);
}
}; };
return_from_clause!(self.last_call, self) return_from_clause!(self.last_call, self)

View File

@@ -54,7 +54,8 @@ print_help(Args) :-
halt. halt.
print_version(Args) :- print_version(Args) :-
write('v0.8.120'), nl, % TODO: Something better is required here. '$scryer_prolog_version'(Version),
write(Version), nl,
halt. halt.
gather_goal(Type, Args0, Goals) :- gather_goal(Type, Args0, Goals) :-