Skip to content

Commit

Permalink
resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Dec 15, 2016
1 parent acf2d2e commit ac40bcf
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions smop/resolve.pl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
:- discontiguous rank/2.
:- discontiguous shape/2.
:- discontiguous let/2.
:- dynamic let/2.
:- dynamic symtab/2.
%:- discontiguous is_def/1.
%:- discontiguous is_def/1.
%:- discontiguous shape/2.
%:- discontiguous let/2.
:- dynamic is_def/1.
:- dynamic is_ref/1.
:- dynamic resolve/1.
:- dynamic do_resolve/1.
:- dynamic lhs_resolve/1.

prog([
let(solver, matlab_function(ai,af,w)),
Expand All @@ -13,6 +17,23 @@
let(a, ai),
let(mv, [])]).

% b-code down stack grows right
% + + f | |
% 2 + 2 f | x |
% 3 + 2 3 f | x | y
% [] + [2,3] f | [x,y] |
% () 5 f(x,y) | |

% ?- do_resolve(a=b).
% =
% a
% b
% []
% ()

% () apply/2
% [] list/_
% =/2
% TODO
% 0. Copy state of is_def/is_ref --> resolve statements
% 4, const rank shape
Expand All @@ -21,9 +42,11 @@
% 10. parser
% 12. backend
do_resolve(A) :-
retractall(is_def),
retractall(is_ref),
%retractall(is_def(_)),
%retractall(is_ref(_)),
resolve(A).
%listing(is_def/1),
%listing(is_ref/1).

is_unused(A) :-
is_def(A),
Expand Down Expand Up @@ -68,7 +91,7 @@
compound_name_arguments(A,B,C),
resolve(B),
resolve(C),
write(B), length(C,N), writeln(N).
writeln("()").
%--------------------------------
lhs_resolve(A) :- % A=...
atom(A),
Expand All @@ -83,7 +106,7 @@
!,
resolve(B),
lhs_resolve(A),
writeln(letl).
writeln(let).

lhs_resolve([]) :-
!,
Expand All @@ -100,6 +123,6 @@
compound_name_arguments(A,B,C),
lhs_resolve(B),
resolve(C),
writeln(B).
writeln("()").

% vim : syntax=prolog

0 comments on commit ac40bcf

Please sign in to comment.