compilatoin of disjuction goes through

parent 476d5929
......@@ -93,21 +93,18 @@ get_post(S,C,Cplx,Tail,X,XX) :-
).
caller(cc,Args,label(G,N),V,[L,LL]) :- !,
narg(Args,MM),
narg(Args,0,MM),
M is MM + 3,
(M==N -> true ; throw(cc_does_not_match_caller)),
(Tail=#f -> throw(cc_not_in_tail_context) ; true),
tr('clear-sp' , Clear),
L=[[Clear]|L2],
get_CS(V,C,S),
set_S(V,0),
push_args(F,V,L2,L3),
push_v(2,V),
tr(seek,Seek),
L3=[[Seek,2]|L4],
L2=[[Seek,3]|L4],
push_args_args(Args,V,L4,LL2),
set_FS(V,F,S),
tr('goto', Goto),
tr('goto-inst', Goto),
LL2 = [[Goto,G]|LL].
caller(cc,Args,Tail,V,[L,LL]) :- !,
......@@ -144,7 +141,7 @@ caller(F,Args,Tail,V,[L,LL]) :-
);
Tail = label(G,N) ->
(
tr(goto,Goto),
tr(goto-inst,Goto),
tr('call-n',Call),
LL2 = [[Call,N],[Goto,G]|LL]
);
......
......@@ -49,13 +49,13 @@ head_at_true(#f,#t,A,C,Lab,Lab2,L1,LLX) :-
compile_disjunction
([X],First,Aq,Ae,Out,Lab,A,Tail,S0,[U],V,[L,LL]) :- !,
First=#t -> compile_goal(X,First,V,[L,LL]) ;
(First=#t -> compile_goal(X,First,V,[L,LL]) ;
catch((
get_CES(V,C,E,S),
set_AES(V,Aq,0,S0),
(
compile_goal(X,Tail,V,[LX,LL]),
get_ACES(Aq1,C1,E1,S1),
get_ACES(V,Aq1,C1,E1,S1),
(C == C1 -> true ; throw(bug_c_state_error)),
(
eql_a(Ae,Aq1) -> true ;
......@@ -63,7 +63,7 @@ compile_disjunction
),
SS is max(S,S1),
EE is E \\/ E1,
set_AES(Aq,EE,SS),
set_AES(V,Aq,EE,SS),
U = [E1,_],
head_at_true(First,#t,A,C,Lab,Lab2,L,LX)
)),Er,
......@@ -79,9 +79,9 @@ compile_disjunction
Er == #f -> throw(#f);
Er == c -> throw(#f)
)
)).
))).
goal(X,Y,Lab,Tail,Out,A,Ae,Aq,C,S,S0,E,U,UU,V,L,LL,LG,LLX) :-
goal(X,Y,First,Lab,Tail,Out,A,Ae,Aq,C,S,S0,E,U,UU,V,L,LL,LG,LLX) :-
compile_goal(X,Tail,V,[LX,LG]),
get_ACES(V,A1q,C1,E1,S1),
(C == C1 -> true ; throw(bug_c_state_error)),
......@@ -113,7 +113,7 @@ compile_disjunction([X|Y],First,Aq,Ae,Out, Lab,A,Tail,S0,[U|UU],V,[L,LL]) :- !,
get_CES(V,C,E,S),
(Tail==#t -> LG=LLX ; LG = [[Goto,Out]|LLX]),
set_AES(V,Aq,0,S0),
catch(goal(X,Y,Lab,Tail,Out,A,Ae,Aq,C,S,S0,E,U,UU,V,L,LL,LG,LLX), Er,
catch(goal(X,Y,First,Lab,Tail,Out,A,Ae,Aq,C,S,S0,E,U,UU,V,L,LL,LG,LLX), Er,
(
tfc(Er),
(Tail==#t -> LLG = [[cc]|LG] ; LLG=LG),
......
......@@ -149,15 +149,18 @@ compile_goal(';'(|X),Tail,V,[L,LL]) :- !,
XX=[] -> L=[[false]|LL] ;
XX=[Z] -> compile_goal(Z,Tail,V,[L,LL]) ;
(
get_E(V,E),
set_E(V,0),
get_ESM(V,E,S,M),
S2 is S + 2,
M2 is max(M,S2),
set_ESM(V,0,S2,M2),
label(Lab),label(Out),tr(newframe,Newframe),
compile_disjunction(XX,#t,Out,Lab,Lab,Tail,S2,U,V,LM,Er),
compile_disjunction(XX,#t,Aq,Ae,Out,Lab,Lab,Tail,S2,U,V,LM),!,
L = [[Newframe,Lab,0] | LX],
LM = [LX, [[label,Out] | LL]],
get_E(B,Ed),
add_missing_variables(H,U,Ed,Ed,EEd),
EE is E \\/ EEd
get_EBH(V,B,Ed,H),
add_missing_variables(H,U,Ed,Ed,EEd),!,
EE is E \\/ EEd,
set_E(V,EE)
)
).
......
......@@ -36,17 +36,35 @@
(<=> e ,(<lookup> (vector-ref v ne)))
(<=> b ,(<lookup> (vector-ref v nb)))))
(<define> (get_EBH v e b h)
(<let> ((v (<lookup> v)))
(<=> e ,(<lookup> (vector-ref v ne)))
(<=> b ,(<lookup> (vector-ref v nb)))
(<=> h ,(<lookup> (vector-ref v nh)))))
(<define> (get_SM v s m)
(<let> ((v (<lookup> v)))
(<=> s ,(<lookup> (vector-ref v ns)))
(<=> m ,(<lookup> (vector-ref v nm)))))
(<define> (get_ESM v e s m)
(<let> ((v (<lookup> v)))
(<=> e ,(<lookup> (vector-ref v ne)))
(<=> s ,(<lookup> (vector-ref v ns)))
(<=> m ,(<lookup> (vector-ref v nm)))))
(<define> (get_AES v a e s)
(<let> ((v (<lookup> v)))
(<=> s ,(<lookup> (vector-ref v ns)))
(<=> e ,(<lookup> (vector-ref v ne)))
(<=> a ,(<lookup> (vector-ref v na)))))
(<define> (get_CES v c e s)
(<let> ((v (<lookup> v)))
(<=> c ,(<lookup> (vector-ref v nc)))
(<=> e ,(<lookup> (vector-ref v ne)))
(<=> s ,(<lookup> (vector-ref v ns)))))
(<define> (get_ACES v a c e s)
(<let> ((v (<lookup> v)))
(<=> s ,(<lookup> (vector-ref v ns)))
......@@ -115,6 +133,12 @@
(<set> (vector-ref v ne) (<lookup> e))
(<set> (vector-ref v ns) (<lookup> s))))
(<define> (set_ESM v e s m)
(let ((v (<lookup> v)))
(<set> (vector-ref v nm) (<lookup> m))
(<set> (vector-ref v ne) (<lookup> e))
(<set> (vector-ref v ns) (<lookup> s))))
(<define> (set_ACES v a c e s)
(let ((v (<lookup> v)))
(<set> (vector-ref v na) (<lookup> a))
......@@ -262,7 +286,7 @@ add_miss(_,[],[],E,E).
add_miss(H,[V|Xs],Ys,E,EE) :-
new_tag(H,V,_,Tag,Etag),
first(Tag),
reference(Tag),
reference(H,Tag),
E1 is E \\/ Etag,
Ys=[Tag|YYs],
add_miss(H,Xs,YYs,E1,EE).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment