coverage.pl 1023 Bytes
% == No, Emacs this is -*-Prolog-*- code, not what you thought... =============

% == Code coverage for PaCCS ==================================================

% ++ cv_basic(AST, CODE, ST)  - - - - - - - - - - - - - - - - - - - - - - - - -

cv_basic(int_lin_ne(COEF, VARS, CONST), _ST) -->
    int_vector(COEF, CC, NN),
    var_vector(VARS, YY),
    constant(CONST, KK),
    { name(CC, CCN), name(YY, YYN), name(KK, KKN), name(NN, NNN) },
    "fd_poly_ne_k(", CCN, ", ", YYN, ", ", NNN, ", ", KKN, ");\n".

int_vector(val(CC,array(int,1,NN),_,_), CC, NN) --> [].

var_vector(lit(VS, array(int(_LB,_UB))), VA) --> % array of FD variables
    { length(VS, L), name(L, LN),
      uniq_name(va, VA), name(VA, VAN) },
    "  fd_int ", VAN, "[", LN, "] = { ",
    var_name_list(VS),
    " }; ".

constant(lit(KK,int), KK) --> [].

var_name_list([]) --> [].
var_name_list([var(CVN,_,_,_)]) -->
    { !, name(CVN, CVNN) }, CVNN.
var_name_list([var(CVN,_,_,_)|Vs]) -->
    { name(CVN, CVNN) }, CVNN, ", ", 
    var_name_list(Vs).