Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Dec 12, 2016
1 parent 2da5b8a commit 4df266b
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions smop/resolve.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
:- discontiguous rank/2.
:- discontiguous shape/2.
:- discontiguous let/2.
:- dynamic let/2.
:- dynamic symtab/2.

prog([
let(solver, matlab_function(ai,af,w)),
let(nBlocks, matlab_max(matlab_ravel(ai))),
let([m,n], matlab_size(ai)),
let(ii, [0, 1, 0,-1]),
let(jj, [1, 0,-1, 0]),
let(a, ai),
let(mv, [])]).

resolve(A) :-
atom(A),
!,
writeln(A).
%assertz(is_ref(A)).

resolve(A) :-
number(A),
!,
writeln(A).

resolve(let(A,B)) :-
!,
resolve(B),
lhs_resolve(A),
writeln(let).

resolve([]) :-
!,
writeln("[]").

resolve([A|B]) :-
!,
resolve(A),
resolve(B).

resolve(A) :-
compound(A),
!,
compound_name_arguments(A,B,C),
resolve(B),
resolve(C),
write(B), length(C,N), writeln(N).
%--------------------------------
lhs_resolve(A) :- % A=...
atom(A),
!,
writeln(A).
% assertz(is_def(A)).

%lhs_resolve(A) :-
% number(A).

lhs_resolve(let(A,B)) :- % A=B...
!,
resolve(B),
lhs_resolve(A),
writeln(letl).

lhs_resolve([]) :-
!,
writeln("[]").

lhs_resolve([A|B]) :-
!,
lhs_resolve(A),
lhs_resolve(B).

lhs_resolve(A) :- % A(B)= ...
compound(A),
!,
compound_name_arguments(A,B,C),
lhs_resolve(B),
resolve(C),
writeln(B).

% vim : syntax=prolog

0 comments on commit 4df266b

Please sign in to comment.