add listing sources to modules
This commit is contained in:
@@ -12,6 +12,7 @@ use indexmap::IndexMap;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub type PredicateKey = (ClauseName, usize); // name, arity.
|
||||
@@ -132,6 +133,32 @@ impl Predicate {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum ListingSource {
|
||||
File(ClauseName, PathBuf), // filename, path
|
||||
User,
|
||||
}
|
||||
|
||||
impl ListingSource {
|
||||
pub fn from_file_and_path(filename: ClauseName, path_buf: PathBuf) -> Self {
|
||||
ListingSource::File(filename, path_buf)
|
||||
}
|
||||
|
||||
pub fn name(&self) -> ClauseName {
|
||||
match self {
|
||||
ListingSource::File(ref filename, _) => filename.clone(),
|
||||
ListingSource::User => clause_name!("[user]")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path(&self) -> PathBuf {
|
||||
match self {
|
||||
ListingSource::File(_, ref path) => path.clone(),
|
||||
ListingSource::User => std::env::current_dir().unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type CompiledResult = (Predicate, VecDeque<TopLevel>);
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -352,6 +379,7 @@ pub struct Module {
|
||||
pub local_goal_expansions: (Predicate, VecDeque<TopLevel>),
|
||||
pub inserted_expansions: bool, // has the module been successfully inserted into toplevel??
|
||||
pub is_impromptu_module: bool,
|
||||
pub listing_src: ListingSource,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
|
||||
Reference in New Issue
Block a user