expand goals in initialization directives.
This commit is contained in:
@@ -307,7 +307,6 @@ impl<'a, R: Read> TermStream<'a, R> {
|
|||||||
while let Some(term) = terms.pop_front() {
|
while let Some(term) = terms.pop_front() {
|
||||||
match machine_st.try_expand_term(self.wam, &term, CompileTimeHook::GoalExpansion) {
|
match machine_st.try_expand_term(self.wam, &term, CompileTimeHook::GoalExpansion) {
|
||||||
Some(term_string) => {
|
Some(term_string) => {
|
||||||
println!("trying to goal expand {}", term_string);
|
|
||||||
let term = self.parse_expansion_output(term_string.as_str(), op_dir)?;
|
let term = self.parse_expansion_output(term_string.as_str(), op_dir)?;
|
||||||
|
|
||||||
match term {
|
match term {
|
||||||
|
|||||||
@@ -72,3 +72,19 @@ use_module(Module, QualifiedExports) :-
|
|||||||
)
|
)
|
||||||
; throw(error(instantiation_error, use_module/2))
|
; throw(error(instantiation_error, use_module/2))
|
||||||
).
|
).
|
||||||
|
|
||||||
|
% expand goals in initialization directives.
|
||||||
|
user:term_expansion(Term0, (:- initialization(ExpandedGoals))) :-
|
||||||
|
nonvar(Term0),
|
||||||
|
Term0 = (:- initialization(Goals)),
|
||||||
|
expand_goals(Goals, ExpandedGoals).
|
||||||
|
|
||||||
|
expand_goals(Goals, ExpandedGoals) :-
|
||||||
|
nonvar(Goals),
|
||||||
|
var(ExpandedGoals),
|
||||||
|
( Goals = (Goal0, Goals0) ->
|
||||||
|
( expand_goal(Goal0, Goal1) -> expand_goals(Goals0, Goals1), ExpandedGoals = (Goal1, Goals1)
|
||||||
|
; expand_goals(Goals0, Goals1), ExpandedGoals = (Goal0, Goals1)
|
||||||
|
)
|
||||||
|
; expand_goal(Goals, ExpandedGoals), !
|
||||||
|
).
|
||||||
|
|||||||
Reference in New Issue
Block a user