test
This commit is contained in:
@@ -6,11 +6,6 @@
|
|||||||
:- use_module(library(error)).
|
:- use_module(library(error)).
|
||||||
:- use_module(library(lists), [append/3]).
|
:- use_module(library(lists), [append/3]).
|
||||||
|
|
||||||
user:term_expansion(Term0, Term) :-
|
|
||||||
nonvar(Term0),
|
|
||||||
dcg_rule(Term0, (Head :- Body)),
|
|
||||||
Term = (Head :- Body).
|
|
||||||
|
|
||||||
phrase(GRBody, S0) :-
|
phrase(GRBody, S0) :-
|
||||||
phrase(GRBody, S0, []).
|
phrase(GRBody, S0, []).
|
||||||
|
|
||||||
@@ -133,3 +128,8 @@ dcg_cbody(\+ GRBody, S0, S, ( \+ phrase(GRBody,S0,_), S0 = S )).
|
|||||||
dcg_cbody(( GRIf -> GRThen ), S0, S, ( If -> Then )) :-
|
dcg_cbody(( GRIf -> GRThen ), S0, S, ( If -> Then )) :-
|
||||||
dcg_body(GRIf, S0, S1, If),
|
dcg_body(GRIf, S0, S1, If),
|
||||||
dcg_body(GRThen, S1, S, Then).
|
dcg_body(GRThen, S1, S, Then).
|
||||||
|
|
||||||
|
user:term_expansion(Term0, Term) :-
|
||||||
|
nonvar(Term0),
|
||||||
|
dcg_rule(Term0, (Head :- Body)),
|
||||||
|
Term = (Head :- Body).
|
||||||
|
|||||||
@@ -350,10 +350,6 @@ fn compile_into_module(
|
|||||||
match compile_into_module_impl(wam, &mut compiler, module, src, indices) {
|
match compile_into_module_impl(wam, &mut compiler, module, src, indices) {
|
||||||
Ok(()) => EvalSession::EntrySuccess,
|
Ok(()) => EvalSession::EntrySuccess,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if let Some(module) = compiler.module.take() {
|
|
||||||
wam.indices.insert_module(module);
|
|
||||||
}
|
|
||||||
|
|
||||||
compiler.drop_expansions(&mut wam.code_repo);
|
compiler.drop_expansions(&mut wam.code_repo);
|
||||||
EvalSession::from(e)
|
EvalSession::from(e)
|
||||||
}
|
}
|
||||||
@@ -370,16 +366,16 @@ fn compile_into_module_impl(
|
|||||||
setup_module_expansions(wam, &module);
|
setup_module_expansions(wam, &module);
|
||||||
|
|
||||||
let module_name = module.module_decl.name.clone();
|
let module_name = module.module_decl.name.clone();
|
||||||
compiler.module = Some(module);
|
// compiler.module = Some(module); This trips the goal expansion up. Should be possible to 'merge' modules.
|
||||||
|
// A much better strategy!
|
||||||
|
wam.indices.insert_module(module);
|
||||||
|
|
||||||
wam.code_repo.compile_hook(CompileTimeHook::TermExpansion)?;
|
wam.code_repo.compile_hook(CompileTimeHook::TermExpansion)?;
|
||||||
wam.code_repo.compile_hook(CompileTimeHook::GoalExpansion)?;
|
wam.code_repo.compile_hook(CompileTimeHook::GoalExpansion)?;
|
||||||
|
|
||||||
let mut stream = parsing_stream(src)?;
|
|
||||||
|
|
||||||
let mut results = compiler.gather_items(
|
let mut results = compiler.gather_items(
|
||||||
wam,
|
wam,
|
||||||
&mut stream,
|
&mut parsing_stream(src)?,
|
||||||
&mut indices,
|
&mut indices,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -401,10 +397,11 @@ fn compile_into_module_impl(
|
|||||||
clause_code_generator.generate_clause_code(&results.dynamic_clause_map, wam)?;
|
clause_code_generator.generate_clause_code(&results.dynamic_clause_map, wam)?;
|
||||||
|
|
||||||
let top_level_term_dir = results.top_level_term_dirs.consolidate();
|
let top_level_term_dir = results.top_level_term_dirs.consolidate();
|
||||||
|
let module = wam.indices.take_module(module_name).unwrap();
|
||||||
|
|
||||||
add_module(
|
add_module(
|
||||||
wam,
|
wam,
|
||||||
compiler.module.take().unwrap(),
|
module,
|
||||||
indices,
|
indices,
|
||||||
top_level_term_dir,
|
top_level_term_dir,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user