expressions

parent f215b2de
......@@ -329,7 +329,7 @@ handle(['push-variable-scm',[[S,V,Q],N,F|_]],I,II,L,LL) :- !,
(
new_var(V,Q,S),
(V=[VC|_] -> QQ=svar(VC) ; QQ=var(V)),
'push-variable'(QQ,I,II,L,LL)
'push-variable-scm'(QQ,I,II,L,LL)
)
).
......
......@@ -28,15 +28,13 @@ compile_scm((Op, ';'(max,min,+,-,*,/,<<,>>,\\/,/\\,mod))
throw(E)
),
(
binop1L(Op,O),
LY=[[O,EX]|LL]
LY=[['push-instruction',EX],[Op]|LL]
))
),
ifc(compile_scm(Y,V,LX,LY),EY,
(
(number(EY) -> true ; throw(EY)),
binop1R(Op,O),
LX=[[O,EY]|LL]
LX=[['push-instruction',EY],[Op]|LL]
),
(
push_v(-1,V),
......
......@@ -8,6 +8,7 @@
#:use-module (system vm assembler)
#:use-module (logic guile-log guile-prolog vm vm-pre)
#:use-module (logic guile-log guile-prolog vm vm-var)
#:use-module (logic guile-log vm vm)
#:export (compile_scm))
(include-from-path "logic/guile-log/guile-prolog/vm/vm-scm-model.scm")
......@@ -42,8 +42,9 @@
eq(P,I,II,L,LL) :- cmp(eq,P,I,II,L,LL).
neq(P,I,II,L,LL) :- cmp(neq,P,I,II,L,LL).
trbpo(plus , plus).
trbpo(minus , minus).
-trace.
trbop(plus , plus).
trbop(minus , minus).
trbop(band , band).
trbop(bor , bor).
trbop(xor , xor).
......@@ -52,14 +53,12 @@
trbop('shift-l', lshift).
trbop('shift-r', rshift).
trbop(divide , divide).
binop(Bop,I,II,L,LL) :-
lookup2(I,L,L1),
trbop(Bop,Nm),
I1 is I - 2,
I2 is I - 1,
generate(Bop(base + I1, base + I2, base + I1),L1,L2),
generate(Bop(base + I1, base + I1, base + I2),L,L2),
II is I - 1,
reset(II,L2,LL).
......
......@@ -7,7 +7,9 @@
#:use-module (logic guile-log vm utils)
#:replace (cutter goto-inst sp-move equal-instruction
push-instruction pushv push-variable set_p
pop-variable pop seek dup clear-sp push_at))
pop-variable pop seek dup clear-sp push_at
push-variable-scm
))
(compile-prolog-string
"
......@@ -52,10 +54,16 @@
gset(sp[I],svar(I2-1),I2,L1,LL),
II is I + 1.
-trace.
'push-variable'(V,I,II,L,LL) :-
gset(sp(I),V,I,L,LL),
II is I + 1.
-trace.
'push-variable-scm'(V,I,II,L,LL) :-
gset(sp(I),V,I,L,L1),
generate(lookup(base+I),L1,LL),
II is I + 1.
'pop-variable'(V,I,II,L,LL) :-
gset(V,sp(I-1),L,LL),
......
......@@ -24,11 +24,13 @@
(set! i 0)
(set! constants (make-hash-table))))
(<define> (getconst n c l ll)
(let ((c (<lookup> c)))
(cond
((or (string? c) (number? c) (boolean? c) (symbol? c) (keyword? c))
(<=> l (("get-constant" n c) . ll)))
(<=> l (,(vector (list "get-constant" (vector (list op2+ base n)) c))
. ll)))
(else
(let ((it (hashq-ref constants c)))
(if it
......
......@@ -31,7 +31,7 @@
cutter goto-inst sp-move equal-instruction
push-instruction pushv push-variable
pop-variable pop seek dup clear-sp push_at
set_p
set_p push-variable-scm
;; unify
ggset unify unify-2 unify-constant-2
......
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