Merge branch 'master' of http://github.com/mthom/rusty-wam into develop
This commit is contained in:
@@ -216,9 +216,9 @@ pub trait SubModuleUser {
|
||||
}
|
||||
}
|
||||
|
||||
fn use_qualified_module(&mut self, submodule: &Module, exports: Vec<PredicateKey>) -> EvalSession
|
||||
fn use_qualified_module(&mut self, submodule: &Module, exports: &Vec<PredicateKey>) -> EvalSession
|
||||
{
|
||||
for (name, arity) in exports {
|
||||
for (name, arity) in exports.iter().cloned() {
|
||||
if !submodule.module_decl.exports.contains(&(name.clone(), arity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ impl fmt::Display for EvalError {
|
||||
&EvalError::ModuleDoesNotContainExport => write!(f, "module does not contain claimed export."),
|
||||
&EvalError::QueryFailure => write!(f, "false."),
|
||||
&EvalError::QueryFailureWithException(ref e) => write!(f, "{}", error_string(e)),
|
||||
&EvalError::ImpermissibleEntry(ref msg) => write!(f, "cannot overwrite builtin {}.", msg),
|
||||
&EvalError::ImpermissibleEntry(ref msg) => write!(f, "cannot overwrite {}.", msg),
|
||||
&EvalError::OpIsInfixAndPostFix =>
|
||||
write!(f, "cannot define an op to be both postfix and infix."),
|
||||
&EvalError::NamelessEntry => write!(f, "the predicate head is not an atom or clause."),
|
||||
@@ -642,7 +642,11 @@ pub fn compile_listing(wam: &mut Machine, src_str: &str) -> EvalSession
|
||||
TopLevelPacket::Decl(TopLevel::Declaration(Declaration::UseModule(name)), _) => {
|
||||
if let Some(ref submodule) = wam.get_module(name.clone()) {
|
||||
if let Some(ref mut module) = module {
|
||||
let mut code_index = machine_code_index!(&mut code_dir, &mut op_dir);
|
||||
|
||||
module.use_module(submodule);
|
||||
code_index.use_module(submodule);
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -654,7 +658,11 @@ pub fn compile_listing(wam: &mut Machine, src_str: &str) -> EvalSession
|
||||
TopLevelPacket::Decl(TopLevel::Declaration(Declaration::UseQualifiedModule(name, exports)), _) => {
|
||||
if let Some(ref submodule) = wam.get_module(name.clone()) {
|
||||
if let Some(ref mut module) = module {
|
||||
module.use_qualified_module(submodule, exports);
|
||||
let mut code_index = machine_code_index!(&mut code_dir, &mut op_dir);
|
||||
|
||||
module.use_qualified_module(submodule, &exports);
|
||||
code_index.use_qualified_module(submodule, &exports);
|
||||
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -190,12 +190,10 @@ impl Machine {
|
||||
-> EvalSession
|
||||
{
|
||||
match self.code_dir.get(&(name.clone(), arity)) {
|
||||
Some(&CodeIndex (ref idx)) =>
|
||||
if idx.borrow().1 == clause_name!("builtin") {
|
||||
Some(&CodeIndex (ref idx)) if idx.borrow().1 != clause_name!("user") =>
|
||||
return EvalSession::from(EvalError::ImpermissibleEntry(format!("{}/{}",
|
||||
name,
|
||||
arity)))
|
||||
},
|
||||
arity))),
|
||||
_ => {}
|
||||
};
|
||||
|
||||
|
||||
@@ -783,3 +783,9 @@ macro_rules! set_code_index {
|
||||
idx.1 = $mod_name.clone();
|
||||
}}
|
||||
}
|
||||
|
||||
macro_rules! machine_code_index {
|
||||
($code_dir:expr, $op_dir:expr) => (
|
||||
MachineCodeIndex { code_dir: $code_dir, op_dir: $op_dir }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ impl<R: Read> TopLevelWorker<R> {
|
||||
|
||||
pub fn parse_batch(&mut self, op_dir: &mut OpDir) -> Result<Vec<TopLevelPacket>, EvalError>
|
||||
{
|
||||
let mut preds = vec![];
|
||||
let mut preds = vec![];
|
||||
let mut mod_name = clause_name!("user");
|
||||
let mut results = vec![];
|
||||
let mut rel_worker = RelationWorker::new();
|
||||
@@ -602,6 +602,9 @@ impl<R: Read> TopLevelWorker<R> {
|
||||
let tl = TopLevel::Declaration(Declaration::Module(actual_mod));
|
||||
results.push(TopLevelPacket::Decl(tl, vec![]));
|
||||
},
|
||||
TopLevel::Declaration(decl) => {
|
||||
results.push(TopLevelPacket::Decl(TopLevel::Declaration(decl), vec![]));
|
||||
},
|
||||
tl => preds.extend(tl.as_predicate().ok().unwrap().clauses().into_iter())
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user