1:- module(aop_context,[
2 aop_push_active_aspect/1,
3 aop_pop_active_aspect/0,
4 aop_push_active_object/1,
5 aop_pop_active_object/0,
6 aop_push_active_variables/1,
7 aop_pop_active_variables/0,
8 aop_load_context/2
9 ]). 10
11aop_push_context(Type, Value) :-
12 13 ( nb_current(Type, History)
14 -> nb_setval(Type, [Value| History])
15 ; nb_setval(Type, [Value])
16 ).
17
18aop_pop_context(Type, Value) :-
19 20 ( nb_current(Type, History)
21 -> (
22 History = [Value | MoreHistory],
23 nb_setval(Type, MoreHistory)
24 )
25 ; true 26 ).
27
28aop_pop_context(Type) :-
29 aop_pop_context(Type, _).
30
31aop_current_context(Type, Value) :-
32 nb_current(Type, History) -> History = [ Value | _].
33
34aop_push_active_aspect(Aspect) :-
35 aop_push_context(aop_aspect_context, Aspect).
37aop_pop_active_aspect :-
38 aop_pop_context(aop_aspect_context).
39
40aop_push_active_object(Object) :-
41 42 aop_push_context(aop_object_context, Object).
43
44aop_pop_active_object :-
45 aop_pop_context(aop_object_context).
46
47aop_push_active_variables(Variables) :-
48 aop_push_context(aop_variables_context, Variables).
50aop_pop_active_variables :-
51 aop_pop_context(aop_variables_context).
52
53aop_load_context(aspect, Context) :-
54 aop_current_context(aop_aspect_context, Context).
55
56aop_load_context(object, Context) :-
57 aop_current_context(aop_object_context, Context).
58
59aop_load_context(variables, Context) :-
60 aop_current_context(aop_variables_context, Context)