| version 1.8, 2001/03/09 01:44:10 |
version 1.30, 2018/03/29 07:50:06 |
|
|
| * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
| * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
| * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
| * $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.7 2000/12/16 06:16:10 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.29 2018/03/29 01:32:53 noro Exp $ |
| */ |
*/ |
| #include "ca.h" |
#include "ca.h" |
| #include "parse.h" |
#include "parse.h" |
| #include "al.h" |
#include "al.h" |
| #include "base.h" |
#include "base.h" |
| |
|
| |
#ifndef CPRINT |
| |
#define CPRINT |
| |
#endif |
| |
|
| extern int hex_output,fortran_output,double_output,real_digit; |
extern int hex_output,fortran_output,double_output,real_digit; |
| |
extern int hideargs,outputstyle; |
| |
static int total_length; |
| |
|
| #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^")) |
|
| |
|
| #define TAIL |
#define TAIL |
| #define PUTS(s) (total_length+=strlen(s)) |
#define PUTS(s) (total_length+=strlen(s)) |
| #define PRINTN length_n |
#define PRINTN length_n |
| Line 73 extern int hex_output,fortran_output,double_output,rea |
|
| Line 77 extern int hex_output,fortran_output,double_output,rea |
|
| #define PRINTSTR length_str |
#define PRINTSTR length_str |
| #define PRINTCOMP length_comp |
#define PRINTCOMP length_comp |
| #define PRINTDP length_dp |
#define PRINTDP length_dp |
| |
#define PRINTDPM length_dpm |
| #define PRINTUI length_ui |
#define PRINTUI length_ui |
| #define PRINTGF2MAT length_gf2mat |
#define PRINTGF2MAT length_gf2mat |
| #define PRINTGFMMAT length_gfmmat |
#define PRINTGFMMAT length_gfmmat |
| #define PRINTBYTEARRAY length_bytearray |
#define PRINTBYTEARRAY length_bytearray |
| |
#define PRINTQUOTE length_QUOTE |
| |
#define PRINTQUOTEARG length_QUOTEARG |
| |
#define PRINTSYMBOL length_SYMBOL |
| |
#define PRINTRANGE length_RANGE |
| |
#define PRINTTB length_TB |
| |
#define PRINTDPV length_DPV |
| |
#define PRINTNBP length_nbp |
| #define PRINTERR length_err |
#define PRINTERR length_err |
| #define PRINTLF length_lf |
#define PRINTLF length_lf |
| #define PRINTLOP length_lop |
#define PRINTLOP length_lop |
| Line 84 extern int hex_output,fortran_output,double_output,rea |
|
| Line 96 extern int hex_output,fortran_output,double_output,rea |
|
| #define PRINTEOP length_eop |
#define PRINTEOP length_eop |
| #define PRINTQOP length_qop |
#define PRINTQOP length_qop |
| #define PRINTUP length_up |
#define PRINTUP length_up |
| |
#define PRINTUM length_um |
| |
#define PRINTSF length_sf |
| |
#define PRINTFARGS length_fargs |
| |
#define PRINTFNODENODE length_fnodenode |
| |
#define PRINTFNODE length_fnode |
| |
|
| void PRINTEXPR(); |
#include "pexpr_body.c" |
| void PRINTNUM(); |
|
| void PRINTN(); |
|
| void PRINTV(); |
|
| void PRINTP(); |
|
| void PRINTR(); |
|
| void PRINTLIST(); |
|
| void PRINTVECT(); |
|
| void PRINTMAT(); |
|
| void PRINTSTR(); |
|
| void PRINTCOMP(); |
|
| void PRINTDP(); |
|
| void PRINTUI(); |
|
| void PRINTGF2MAT(); |
|
| void PRINTGFMMAT(); |
|
| void PRINTBYTEARRAY(); |
|
| void PRINTERR(); |
|
| void PRINTCPLX(); |
|
| void PRINTLM(); |
|
| void PRINTLF(); |
|
| void PRINTUP2(); |
|
| |
|
| |
/* special functions for estimating length */ |
| |
|
| static int total_length; |
static int total_length; |
| |
|
| int estimate_length(vl,p) |
int estimate_length(VL vl,pointer p) |
| VL vl; |
|
| pointer p; |
|
| { |
{ |
| total_length = 0; |
total_length = 0; |
| PRINTEXPR(vl,p); |
PRINTEXPR(vl,p); |
| return total_length; |
return total_length; |
| } |
} |
| |
|
| #if PARI |
void PRINTBF(BF a) |
| void PRINTBF(a) |
|
| BF a; |
|
| { |
{ |
| char *str; |
char *str; |
| char *GENtostr(); |
int dprec; |
| char *GENtostr0(); |
char fbuf[BUFSIZ]; |
| void myoutbrute(); |
|
| |
|
| if ( double_output ) { |
dprec = a->body->_mpfr_prec*0.30103; |
| str = GENtostr0(a->body,myoutbrute); |
sprintf(fbuf,"%%.%dR%c",dprec,(double_output==1)?'f':(double_output==2)?'e':'g'); |
| } else { |
mpfr_asprintf(&str,fbuf,a->body); |
| str = GENtostr(a->body); |
total_length += strlen(str); |
| } |
mpfr_free_str(str); |
| total_length += strlen(str); |
|
| free(str); |
|
| } |
} |
| #endif |
|
| |
|
| void PRINTEXPR(vl,p) |
void PRINTNUM(Num q) |
| VL vl; |
|
| pointer p; |
|
| { |
{ |
| if ( !p ) { |
DAlg d; |
| total_length++; |
DP nm; |
| return; |
Q dn; |
| } |
|
| |
|
| switch ( OID(p) ) { |
if ( !q ) { |
| case O_N: |
PUTS("0"); |
| PRINTNUM((Num)p); break; |
return; |
| case O_P: |
} |
| PRINTP(vl,(P)p); break; |
switch ( NID(q) ) { |
| case O_R: |
case N_Q: |
| PRINTR(vl,(R)p); break; |
if ( SGN((Q)q) == -1 ) |
| case O_LIST: |
PUTS("-"); |
| PRINTLIST(vl,(LIST)p); break; |
PRINTN(NM((Q)q)); |
| case O_VECT: |
if ( !INT((Q)q) ) { |
| PRINTVECT(vl,(VECT)p); break; |
PUTS("/"); PRINTN(DN((Q)q)); |
| case O_MAT: |
} |
| PRINTMAT(vl,(MAT)p); break; |
break; |
| case O_STR: |
case N_R: |
| PRINTSTR((STRING)p); break; |
if ( double_output ) |
| case O_COMP: |
total_length += 400+real_digit; /* XXX */ |
| PRINTCOMP(vl,(COMP)p); break; |
else |
| case O_DP: |
total_length += 20+real_digit; /* XXX */ |
| PRINTDP(vl,(DP)p); break; |
break; |
| case O_USINT: |
case N_A: |
| PRINTUI(vl,(USINT)p); break; |
PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); |
| case O_GF2MAT: |
break; |
| PRINTGF2MAT(vl,(GF2MAT)p); break; |
case N_B: |
| case O_ERR: |
PRINTBF((BF)q); break; |
| PRINTERR(vl,(ERR)p); break; |
case N_C: |
| case O_MATHCAP: |
PRINTCPLX((C)q); break; |
| PRINTLIST(vl,((MATHCAP)p)->body); break; |
case N_M: |
| case O_F: |
total_length += 11; /* XXX */ |
| PRINTLF(vl,(F)p); break; |
break; |
| case O_GFMMAT: |
case N_LM: |
| PRINTGFMMAT(vl,(GFMMAT)p); break; |
PRINTN(((LM)q)->body); break; |
| case O_BYTEARRAY: |
case N_GF2N: |
| PRINTBYTEARRAY(vl,(BYTEARRAY)p); break; |
if ( hex_output ) |
| default: |
PRINTN((N)(((GF2N)q)->body)); |
| break; |
else |
| } |
PRINTUP2(((GF2N)q)->body); |
| |
break; |
| |
case N_GFPN: |
| |
PRINTUP((UP)(((GFPN)q)->body)); |
| |
break; |
| |
case N_GFS: |
| |
total_length += 13; /* XXX */ |
| |
break; |
| |
case N_GFSN: |
| |
PRINTUM(BDY((GFSN)q)); |
| |
break; |
| |
case N_DA: |
| |
d = (DAlg)q; |
| |
nm = d->nm; |
| |
dn = d->dn; |
| |
if ( SGN((Q)dn) == -1 ) PUTS("-"); |
| |
PUTS("("); |
| |
PRINTDP(CO,((DAlg)q)->nm); |
| |
PUTS(")"); |
| |
if ( !UNIN(NM(dn)) ) { |
| |
PUTS("/"); |
| |
PRINTN(NM(dn)); |
| |
} |
| |
break; |
| |
default: |
| |
break; |
| |
} |
| } |
} |
| |
|
| void PRINTN(n) |
void PRINTV(VL vl,V v) |
| N n; |
|
| { |
{ |
| double ceil(); |
PF pf; |
| |
PFAD ad; |
| |
int i; |
| |
|
| if ( !n ) |
if ( NAME(v) ) |
| PUTS("0"); |
PUTS(NAME(v)); |
| else if ( hex_output ) |
else if ( (vid)v->attr == V_PF ) { |
| total_length += 2+(int)(PL(n)*8); |
pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad; |
| else |
if ( !strcmp(NAME(pf),"pow") ) { |
| total_length += (int)(ceil(0.31*((double)(BSH*PL(n))))+1); |
PUTS("(("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("("); |
| |
PRINTR(vl,(R)ad[1].arg); PUTS("))"); |
| |
} else if ( !pf->argc ) |
| |
PUTS(NAME(pf)); |
| |
else { |
| |
if ( hideargs ) { |
| |
for ( i = 0; i < pf->argc; i++ ) |
| |
if ( ad[i].d ) |
| |
break; |
| |
if ( i < pf->argc ) { |
| |
PUTS(NAME(pf)); |
| |
total_length += 11; /* XXX */ |
| |
for ( i = 1; i < pf->argc; i++ ) { |
| |
total_length += 11; /* XXX */ |
| |
} |
| |
PUTS("}"); |
| |
} else { |
| |
PUTS(NAME(pf)); |
| |
total_length += 1; /* XXX */ |
| |
} |
| |
} else { |
| |
for ( i = 0; i < pf->argc; i++ ) |
| |
if ( ad[i].d ) |
| |
break; |
| |
if ( i < pf->argc ) { |
| |
PUTS(NAME(pf)); |
| |
total_length += 11; /* XXX */ |
| |
for ( i = 1; i < pf->argc; i++ ) { |
| |
total_length += 11; /* XXX */ |
| |
} |
| |
PUTS(")("); |
| |
} else { |
| |
PUTS(NAME(pf)); |
| |
total_length += 1; /* XXX */ |
| |
} |
| |
PRINTR(vl,(R)ad[0].arg); |
| |
for ( i = 1; i < pf->argc; i++ ) { |
| |
PUTS(","); PRINTR(vl,(R)ad[i].arg); |
| |
} |
| |
PUTS(")"); |
| |
} |
| |
} |
| |
} |
| } |
} |
| |
|
| void PRINTNUM(q) |
void PRINTN(N n) |
| Num q; |
|
| { |
{ |
| if ( !q ) { |
double ceil(); |
| PUTS("0"); |
|
| return; |
|
| } |
|
| switch ( NID(q) ) { |
|
| case N_Q: |
|
| if ( SGN((Q)q) == -1 ) |
|
| PUTS("-"); |
|
| PRINTN(NM((Q)q)); |
|
| if ( !INT((Q)q) ) { |
|
| PUTS("/"); PRINTN(DN((Q)q)); |
|
| } |
|
| break; |
|
| case N_R: |
|
| if ( double_output ) |
|
| total_length += 400+real_digit; /* XXX */ |
|
| else |
|
| total_length += 20+real_digit; /* XXX */ |
|
| break; |
|
| case N_A: |
|
| PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")"); |
|
| break; |
|
| #if PARI |
|
| case N_B: |
|
| PRINTBF((BF)q); break; |
|
| #endif |
|
| case N_C: |
|
| PRINTCPLX((C)q); break; |
|
| case N_M: |
|
| total_length += 11; /* XXX */ |
|
| break; |
|
| case N_LM: |
|
| PRINTN(((LM)q)->body); break; |
|
| case N_GF2N: |
|
| if ( hex_output ) |
|
| PRINTN((N)(((GF2N)q)->body)); |
|
| else |
|
| PRINTUP2(((GF2N)q)->body); |
|
| break; |
|
| case N_GFPN: |
|
| PRINTUP((UP)(((GFPN)q)->body)); |
|
| break; |
|
| default: |
|
| break; |
|
| } |
|
| } |
|
| |
|
| void PRINTCPLX(a) |
if ( !n ) |
| C a; |
PUTS("0"); |
| { |
else if ( hex_output ) |
| PUTS("("); |
total_length += 2+(int)(PL(n)*8); |
| if ( a->r ) |
else |
| PRINTNUM(a->r); |
total_length += (int)(ceil(0.31*((double)(BSH*PL(n))))+1); |
| if ( a->i ) { |
|
| if ( a->r && (compnum(0,a->i,0) > 0) ) |
|
| PUTS("+"); |
|
| PRINTNUM(a->i); PUTS("*@i"); |
|
| } |
|
| PUTS(")"); |
|
| } |
} |
| |
|
| void PRINTP(vl,p) |
void PRINTSTR(STRING str) |
| VL vl; |
|
| P p; |
|
| { |
{ |
| V v; |
char *p; |
| DCP dc; |
|
| int t; |
|
| |
|
| if ( !p ) |
for ( p = BDY(str); *p; p++ ) |
| PUTS("0"); |
if ( *p == '"' ) |
| else if ( NUM(p) ) |
PUTS("\""); |
| PRINTNUM((Num)p); |
else { |
| else |
total_length += 1; |
| for ( dc = DC(p), v = VR(p); dc; dc = NEXT(dc) ) { |
} |
| if ( !DEG(dc) ) |
|
| PRINTP(vl,COEF(dc)); |
|
| else { |
|
| if ( NUM(COEF(dc)) && UNIQ((Q)COEF(dc)) ) { |
|
| ; |
|
| } else if ( NUM(COEF(dc)) && MUNIQ((Q)COEF(dc)) ) |
|
| PUTS("-"); |
|
| else if ( NUM(COEF(dc)) || !NEXT(DC(COEF(dc)))) { |
|
| PRINTP(vl,COEF(dc)); PUTS("*"); |
|
| } else { |
|
| PUTS("("); PRINTP(vl,COEF(dc)); PUTS(")*"); |
|
| } |
|
| PRINTV(vl,v); |
|
| if ( cmpq(DEG(dc),ONE) ) { |
|
| PRINTHAT; |
|
| if ( INT(DEG(dc)) && SGN(DEG(dc))>0 ) |
|
| PRINTNUM((Num)DEG(dc)); |
|
| else { |
|
| PUTS("("); PRINTNUM((Num)DEG(dc)); PUTS(")"); |
|
| } |
|
| } |
|
| } |
|
| if ( NEXT(dc) ) { |
|
| P t; |
|
| |
|
| t = COEF(NEXT(dc)); |
|
| if (!DEG(NEXT(dc))) { |
|
| if ( NUM(t) ) { |
|
| if ( !mmono(t) ) |
|
| PUTS("+"); |
|
| } else { |
|
| if (!mmono(COEF(DC(t)))) |
|
| PUTS("+"); |
|
| } |
|
| } else { |
|
| if ( !mmono(t) ) |
|
| PUTS("+"); |
|
| } |
|
| } |
|
| } |
|
| } |
} |
| |
|
| extern int hideargs; |
void PRINTDP(VL vl,DP d) |
| |
|
| void PRINTV(vl,v) |
|
| VL vl; |
|
| V v; |
|
| { |
{ |
| PF pf; |
int n,i; |
| PFAD ad; |
MP m; |
| int i; |
DL dl; |
| |
|
| if ( NAME(v) ) |
for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) { |
| PUTS(NAME(v)); |
PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<"); |
| else if ( (vid)v->attr == V_PF ) { |
for ( i = 0, dl = m->dl; i < n-1; i++ ) { |
| pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad; |
total_length += 11; |
| if ( !strcmp(NAME(pf),"pow") ) { |
} |
| PUTS("("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("("); |
total_length += 10; |
| PRINTR(vl,(R)ad[1].arg); PUTS(")"); |
PUTS(">>"); |
| } else if ( !pf->argc ) |
if ( NEXT(m) ) |
| PUTS(NAME(pf)); |
PUTS("+"); |
| else { |
} |
| if ( hideargs ) { |
|
| for ( i = 0; i < pf->argc; i++ ) |
|
| if ( ad[i].d ) |
|
| break; |
|
| if ( i < pf->argc ) { |
|
| PUTS(NAME(pf)); |
|
| total_length += 11; /* XXX */ |
|
| for ( i = 1; i < pf->argc; i++ ) { |
|
| total_length += 11; /* XXX */ |
|
| } |
|
| PUTS("}"); |
|
| } else { |
|
| PUTS(NAME(pf)); |
|
| total_length += 1; /* XXX */ |
|
| } |
|
| } else { |
|
| for ( i = 0; i < pf->argc; i++ ) |
|
| if ( ad[i].d ) |
|
| break; |
|
| if ( i < pf->argc ) { |
|
| PUTS(NAME(pf)); |
|
| total_length += 11; /* XXX */ |
|
| for ( i = 1; i < pf->argc; i++ ) { |
|
| total_length += 11; /* XXX */ |
|
| } |
|
| PUTS(")("); |
|
| } else { |
|
| PUTS(NAME(pf)); |
|
| total_length += 1; /* XXX */ |
|
| } |
|
| PRINTR(vl,(R)ad[0].arg); |
|
| for ( i = 1; i < pf->argc; i++ ) { |
|
| PUTS(","); PRINTR(vl,(R)ad[i].arg); |
|
| } |
|
| PUTS(")"); |
|
| } |
|
| } |
|
| } |
|
| } |
} |
| |
|
| void PRINTR(vl,a) |
void PRINTDPM(VL vl,DPM d) |
| VL vl; |
|
| R a; |
|
| { |
{ |
| if ( !a ) |
int n,i; |
| PUTS("0"); |
DMM m; |
| else |
DL dl; |
| switch (OID(a)) { |
|
| case O_N: case O_P: |
|
| PRINTP(vl,(P)a); break; |
|
| default: |
|
| PUTS("("); PRINTP(vl,NM((R)a)); PUTS(")/("); PRINTP(vl,DN((R)a)); PUTS(")"); |
|
| break; |
|
| } |
|
| } |
|
| |
|
| void PRINTVECT(vl,vect) |
for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) { |
| VL vl; |
PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<"); |
| VECT vect; |
for ( i = 0, dl = m->dl; i < n-1; i++ ) { |
| { |
total_length += 11; |
| int i; |
} |
| pointer *ptr; |
total_length += 10; |
| |
total_length += 11; /* for ':pos' */ |
| PUTS("[ "); |
PUTS(">>"); |
| for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) { |
if ( NEXT(m) ) |
| PRINTEXPR(vl,ptr[i]); PUTS(" "); |
PUTS("+"); |
| } |
} |
| PUTS("]"); |
|
| } |
} |
| |
|
| void PRINTMAT(vl,mat) |
|
| VL vl; |
|
| MAT mat; |
|
| { |
|
| int i,j,r,c; |
|
| pointer *ptr; |
|
| |
|
| for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) { |
void PRINTUI(VL vl,USINT u) |
| PUTS("[ "); |
|
| for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) { |
|
| PRINTEXPR(vl,ptr[j]); PUTS(" "); |
|
| } |
|
| PUTS("]"); |
|
| if ( i < r - 1 ) |
|
| PUTS("\n"); |
|
| } |
|
| } |
|
| |
|
| void PRINTLIST(vl,list) |
|
| VL vl; |
|
| LIST list; |
|
| { |
{ |
| NODE tnode; |
total_length += 10; |
| |
|
| PUTS("["); |
|
| for ( tnode = (NODE)list->body; tnode; tnode = NEXT(tnode) ) { |
|
| PRINTEXPR(vl,tnode->body); |
|
| if ( NEXT(tnode) ) |
|
| PUTS(","); |
|
| } |
|
| PUTS("]"); |
|
| } |
} |
| |
|
| void PRINTSTR(str) |
void PRINTGFMMAT(VL vl,GFMMAT mat) |
| STRING str; |
|
| { |
{ |
| char *p; |
int row,col,i,j; |
| |
unsigned int **b; |
| |
|
| for ( p = BDY(str); *p; p++ ) |
row = mat->row; |
| if ( *p == '"' ) |
col = mat->col; |
| PUTS("\""); |
b = mat->body; |
| else { |
for ( i = 0; i < row; i++ ) { |
| total_length += 1; |
PUTS("["); |
| } |
for ( j = 0; j < col; j++ ) { |
| |
total_length += 10; /* XXX */ |
| |
} |
| |
PUTS("]\n"); |
| |
} |
| } |
} |
| |
|
| void PRINTCOMP(vl,c) |
void PRINTBYTEARRAY(VL vl,BYTEARRAY array) |
| VL vl; |
|
| COMP c; |
|
| { |
{ |
| int n,i; |
/* |xx xx ... xx| */ |
| |
total_length += 1+3*array->len; |
| n = getcompsize((int)c->type); |
|
| PUTS("{"); |
|
| for ( i = 0; i < n; i++ ) { |
|
| PRINTEXPR(vl,(pointer)c->member[i]); |
|
| if ( i < n-1 ) |
|
| PUTS(","); |
|
| } |
|
| PUTS("}"); |
|
| } |
} |
| |
|
| void PRINTDP(vl,d) |
extern int print_quote; |
| VL vl; |
|
| DP d; |
|
| { |
|
| int n,i; |
|
| MP m; |
|
| DL dl; |
|
| |
|
| for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) { |
void PRINTQUOTE(VL vl,QUOTE quote) |
| PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<"); |
|
| for ( i = 0, dl = m->dl; i < n-1; i++ ) { |
|
| total_length += 11; |
|
| } |
|
| total_length += 10; |
|
| PUTS(">>"); |
|
| if ( NEXT(m) ) |
|
| PUTS("+"); |
|
| } |
|
| } |
|
| |
|
| void PRINTUI(vl,u) |
|
| VL vl; |
|
| USINT u; |
|
| { |
{ |
| total_length += 10; |
LIST list; |
| } |
|
| |
|
| void PRINTGF2MAT(vl,mat) |
if ( print_quote == 2 ) { |
| VL vl; |
PRINTFNODE(BDY(quote),0); |
| GF2MAT mat; |
} else if ( print_quote == 1 ) { |
| { |
/* XXX */ |
| int row,col,w,i,j,k,m; |
fnodetotree(BDY(quote),&list); |
| unsigned int t; |
PRINTEXPR(vl,(Obj)list); |
| unsigned int **b; |
} else { |
| |
/* <...quoted...> */ |
| row = mat->row; |
total_length += 20; |
| col = mat->col; |
} |
| w = (col+BSH-1)/BSH; |
|
| b = mat->body; |
|
| for ( i = 0; i < row; i++ ) { |
|
| for ( j = 0, m = 0; j < w; j++ ) { |
|
| t = b[i][j]; |
|
| for ( k = 0; m < col && k < BSH; k++, m++ ) |
|
| if ( t & (1<<k) ) |
|
| PUTS("1"); |
|
| else |
|
| PUTS("0"); |
|
| } |
|
| PUTS("\n"); |
|
| } |
|
| } |
} |
| |
|
| void PRINTGFMMAT(vl,mat) |
void PRINTQUOTEARG(VL vl,QUOTEARG quote) |
| VL vl; |
|
| GFMMAT mat; |
|
| { |
{ |
| int row,col,i,j; |
/* XXX */ |
| unsigned int t; |
/* <...quoted...> */ |
| unsigned int **b; |
total_length += 20; |
| |
|
| row = mat->row; |
|
| col = mat->col; |
|
| b = mat->body; |
|
| for ( i = 0; i < row; i++ ) { |
|
| PUTS("["); |
|
| for ( j = 0; j < col; j++ ) { |
|
| total_length += 10; /* XXX */ |
|
| } |
|
| PUTS("]\n"); |
|
| } |
|
| } |
} |
| |
|
| void PRINTBYTEARRAY(vl,array) |
void PRINTSYMBOL(SYMBOL sym) |
| VL vl; |
|
| BYTEARRAY array; |
|
| { |
{ |
| /* |xx xx ... xx| */ |
total_length += strlen(sym->name); |
| total_length += 1+3*array->len; |
|
| } |
} |
| |
|
| void PRINTERR(vl,e) |
void PRINTTB(VL vl,TB p) |
| VL vl; |
|
| ERR e; |
|
| { |
{ |
| PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")"); |
int i; |
| } |
|
| |
|
| void PRINTUP2(p) |
for ( i = 0; i < p->next; i++ ) { |
| UP2 p; |
total_length += strlen(p->body[i]); |
| { |
} |
| int d,i; |
|
| |
|
| if ( !p ) { |
|
| PUTS("0"); |
|
| } else { |
|
| d = degup2(p); |
|
| PUTS("("); |
|
| if ( !d ) { |
|
| PUTS("1"); |
|
| } else if ( d == 1 ) { |
|
| PUTS("@"); |
|
| } else { |
|
| PRINTHAT; |
|
| total_length += 11; |
|
| } |
|
| for ( i = d-1; i >= 0; i-- ) { |
|
| if ( p->b[i/BSH] & (1<<(i%BSH)) ) |
|
| if ( !i ) { |
|
| PUTS("+1"); |
|
| } else if ( i == 1 ) { |
|
| PUTS("+@"); |
|
| } else { |
|
| PRINTHAT; |
|
| total_length += 12; |
|
| } |
|
| } |
|
| PUTS(")"); |
|
| } |
|
| } |
} |
| |
|
| void PRINTLF(vl,f) |
void PRINTUP2(UP2 p) |
| VL vl; |
|
| F f; |
|
| { |
{ |
| switch ( FOP(f) ) { |
int d,i; |
| case AL_TRUE: |
|
| PUTS("@true"); |
|
| break; |
|
| case AL_FALSE: |
|
| PUTS("@false"); |
|
| break; |
|
| |
|
| case AL_OR: case AL_AND: |
if ( !p ) { |
| PRINTFOP(vl,f); break; |
PUTS("0"); |
| case AL_NOT: case AL_IMPL: case AL_REPL: case AL_EQUIV: |
} else { |
| PRINTEOP(vl,f); break; |
d = degup2(p); |
| |
PUTS("("); |
| case AL_EQUAL: case AL_NEQ: case AL_LESSP: |
if ( !d ) { |
| case AL_GREATERP: case AL_LEQ: case AL_GEQ: |
PUTS("1"); |
| PRINTLOP(vl,f); break; |
} else if ( d == 1 ) { |
| |
PUTS("@"); |
| case AL_EX: case AL_ALL: |
} else { |
| PRINTQOP(vl,f); break; |
PRINTHAT; |
| default: |
total_length += 11; |
| break; |
} |
| } |
for ( i = d-1; i >= 0; i-- ) { |
| |
if ( p->b[i/BSH] & (1<<(i%BSH)) ) |
| |
if ( !i ) { |
| |
PUTS("+1"); |
| |
} else if ( i == 1 ) { |
| |
PUTS("+@"); |
| |
} else { |
| |
PRINTHAT; |
| |
total_length += 12; |
| |
} |
| |
} |
| |
PUTS(")"); |
| |
} |
| } |
} |
| |
|
| PRINTFOP(vl,f) |
void PRINTQOP(VL vl,F f) |
| VL vl; |
|
| F f; |
|
| { |
{ |
| char *op; |
char *op; |
| NODE n; |
|
| |
|
| op = FOP(f)==AL_OR?" @|| ":" @&& "; |
op = FOP(f)==AL_EX?"ex":"all"; |
| n = FJARG(f); |
PUTS(op); PUTS(NAME(FQVR(f))); |
| PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")"); |
total_length += 2; |
| for ( n = NEXT(n); n; n = NEXT(n) ) { |
PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")"); |
| PUTS(op); PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")"); |
|
| } |
|
| } |
} |
| |
|
| PRINTEOP(vl,f) |
void PRINTUP(UP n) |
| VL vl; |
|
| F f; |
|
| { |
{ |
| oFOP op; |
int i,d; |
| char *sop; |
|
| |
|
| if ( (op = FOP(f)) == AL_NOT ) { |
if ( !n ) |
| PUTS("(@! "); PRINTEXPR(vl,(Obj)FARG(f)); PUTS(")"); return; |
PUTS("0"); |
| } |
else if ( !n->d ) |
| switch ( op ) { |
PRINTNUM(n->c[0]); |
| case AL_IMPL: |
else { |
| sop = " @impl "; break; |
d = n->d; |
| case AL_REPL: |
PUTS("("); |
| sop = " @repl "; break; |
if ( !d ) { |
| case AL_EQUIV: |
PRINTNUM(n->c[d]); |
| sop = " @equiv "; break; |
} else if ( d == 1 ) { |
| default: |
PRINTNUM(n->c[d]); |
| break; |
PUTS("*@p"); |
| } |
} else { |
| PUTS("("); |
PRINTNUM(n->c[d]); |
| PRINTEXPR(vl,(Obj)FLHS(f)); |
PRINTHAT; |
| PUTS(sop); |
total_length += 13; |
| PRINTEXPR(vl,(Obj)FRHS(f)); |
} |
| PUTS(")"); |
for ( i = d-1; i >= 0; i-- ) { |
| |
if ( n->c[i] ) { |
| |
PUTS("+("); PRINTNUM(n->c[i]); PUTS(")"); |
| |
if ( i >= 2 ) { |
| |
PRINTHAT; |
| |
total_length += 13; |
| |
} else if ( i == 1 ) |
| |
PUTS("*@p"); |
| |
} |
| |
} |
| |
PUTS(")"); |
| |
} |
| } |
} |
| |
|
| PRINTLOP(vl,f) |
void PRINTUM(UM n) |
| VL vl; |
|
| F f; |
|
| { |
{ |
| char *op; |
int i,d; |
| |
|
| switch ( FOP(f) ) { |
if ( !n ) |
| case AL_EQUAL: |
PUTS("0"); |
| op = " @== "; break; |
else if ( !n->d ) |
| case AL_NEQ: |
PRINTSF(n->c[0]); |
| op = " @!= "; break; |
else { |
| case AL_LESSP: |
d = n->d; |
| op = " @< "; break; |
PUTS("("); |
| case AL_GREATERP: |
if ( !d ) { |
| op = " @> "; break; |
PRINTSF(n->c[d]); |
| case AL_LEQ: |
} else if ( d == 1 ) { |
| op = " @<= "; break; |
PRINTSF(n->c[d]); |
| case AL_GEQ: |
PUTS("*@s"); |
| op = " @>= "; break; |
} else { |
| default: |
PRINTSF(n->c[d]); |
| error("PRINTLOP : invalid operator"); |
PUTS("*@s"); PRINTHAT; total_length += 13; |
| break; |
} |
| } |
for ( i = d-1; i >= 0; i-- ) { |
| PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0"); |
if ( n->c[i] ) { |
| |
PUTS("+("); PRINTSF(n->c[i]); PUTS(")"); |
| |
if ( i >= 2 ) { |
| |
PUTS("*@s"); PRINTHAT; total_length += 13; |
| |
} else if ( i == 1 ) |
| |
PUTS("*@s"); |
| |
} |
| |
} |
| |
PUTS(")"); |
| |
} |
| } |
} |
| |
|
| PRINTQOP(vl,f) |
void PRINTNBP(VL vl,NBP p) |
| VL vl; |
|
| F f; |
|
| { |
{ |
| char *op; |
NODE t; |
| |
NBM m; |
| op = FOP(f)==AL_EX?"ex":"all"; |
int d,i; |
| PUTS(op); PUTS(NAME(FQVR(f))); |
unsigned int *b; |
| total_length += 2; |
if ( !p ) PUTS("0"); |
| PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")"); |
else { |
| |
for ( t = BDY(p); t; t = NEXT(t) ) { |
| |
m = (NBM)BDY(t); |
| |
PRINTEXPR(vl,(Obj)m->c); |
| |
d = m->d; |
| |
b = m->b; |
| |
if ( d ) |
| |
for ( i = 0; i < d; i++ ) { |
| |
if ( NBM_GET(b,i) ) PUTS("x"); |
| |
else PUTS("y"); |
| |
} |
| |
else PUTS("1"); |
| |
if ( NEXT(t) ) PUTS("+"); |
| |
} |
| |
} |
| } |
} |
| |
|
| PRINTUP(n) |
void PRINTSF(unsigned int i) |
| UP n; |
|
| { |
{ |
| int i,d; |
if ( !i ) { |
| |
PUTS("0"); |
| |
} else |
| |
total_length += 15; |
| |
|
| if ( !n ) |
#ifndef CPRINT |
| PUTS("0"); |
#define CPRINT |
| else if ( !n->d ) |
#endif |
| PRINTNUM(n->c[0]); |
|
| else { |
|
| d = n->d; |
|
| PUTS("("); |
|
| if ( !d ) { |
|
| PRINTNUM(n->c[d]); |
|
| } else if ( d == 1 ) { |
|
| PRINTNUM(n->c[d]); |
|
| PUTS("*@p"); |
|
| } else { |
|
| PRINTNUM(n->c[d]); |
|
| PRINTHAT; |
|
| total_length += 13; |
|
| } |
|
| for ( i = d-1; i >= 0; i-- ) { |
|
| if ( n->c[i] ) { |
|
| PUTS("+("); PRINTNUM(n->c[i]); PUTS(")"); |
|
| if ( i >= 2 ) { |
|
| PRINTHAT; |
|
| total_length += 13; |
|
| } else if ( i == 1 ) |
|
| PUTS("*@p"); |
|
| } |
|
| } |
|
| PUTS(")"); |
|
| } |
|
| } |
} |