From ac40bcf28d41b8a4fa89736fb5ef15857d0923c3 Mon Sep 17 00:00:00 2001 From: Victor Lei Date: Thu, 15 Dec 2016 09:45:17 +0300 Subject: [PATCH] resolve --- smop/resolve.pl | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/smop/resolve.pl b/smop/resolve.pl index 2ad89270..fcec5b7e 100644 --- a/smop/resolve.pl +++ b/smop/resolve.pl @@ -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)), @@ -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 @@ -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), @@ -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), @@ -83,7 +106,7 @@ !, resolve(B), lhs_resolve(A), - writeln(letl). + writeln(let). lhs_resolve([]) :- !, @@ -100,6 +123,6 @@ compound_name_arguments(A,B,C), lhs_resolve(B), resolve(C), - writeln(B). + writeln("()"). % vim : syntax=prolog