Annotation of OpenXM_contrib2/asir2000/io/cpexpr.c, Revision 1.17
1.3 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.4 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
1.17 ! noro 47: * $OpenXM: OpenXM_contrib2/asir2000/io/cpexpr.c,v 1.16 2003/12/25 02:40:24 noro Exp $
1.3 noro 48: */
1.1 noro 49: #include "ca.h"
50: #include "parse.h"
1.2 noro 51: #include "al.h"
1.1 noro 52: #include "base.h"
1.16 noro 53: #if PARI
54: #include "genpari.h"
55: #endif
1.1 noro 56:
1.8 noro 57: extern int hex_output,fortran_output,double_output,real_digit;
1.2 noro 58:
59: #define PRINTHAT (fortran_output?PUTS("**"):PUTS("^"))
60:
1.1 noro 61: #define TAIL
62: #define PUTS(s) (total_length+=strlen(s))
63: #define PRINTN length_n
1.2 noro 64: #define PRINTBF length_bf
1.1 noro 65: #define PRINTCPLX length_cplx
1.2 noro 66: #define PRINTLM length_lm
67: #define PRINTUP2 length_up2
1.1 noro 68: #define PRINTV length_v
69: #define PRINTEXPR length_expr
70: #define PRINTNUM length_num
71: #define PRINTP length_p
72: #define PRINTR length_r
73: #define PRINTLIST length_list
74: #define PRINTVECT length_vect
75: #define PRINTMAT length_mat
76: #define PRINTSTR length_str
77: #define PRINTCOMP length_comp
78: #define PRINTDP length_dp
1.2 noro 79: #define PRINTUI length_ui
80: #define PRINTGF2MAT length_gf2mat
81: #define PRINTGFMMAT length_gfmmat
1.5 noro 82: #define PRINTBYTEARRAY length_bytearray
1.11 noro 83: #define PRINTQUOTE length_QUOTE
1.17 ! noro 84: #define PRINTSYMBOL length_SYMBOL
! 85: #define PRINTRANGE length_RANGE
1.2 noro 86: #define PRINTERR length_err
87: #define PRINTLF length_lf
88: #define PRINTLOP length_lop
89: #define PRINTFOP length_fop
90: #define PRINTEOP length_eop
91: #define PRINTQOP length_qop
92: #define PRINTUP length_up
1.12 noro 93: #define PRINTUM length_um
94: #define PRINTSF length_sf
1.1 noro 95:
96: void PRINTEXPR();
97: void PRINTNUM();
1.2 noro 98: void PRINTN();
1.1 noro 99: void PRINTV();
100: void PRINTP();
101: void PRINTR();
102: void PRINTLIST();
103: void PRINTVECT();
104: void PRINTMAT();
105: void PRINTSTR();
106: void PRINTCOMP();
107: void PRINTDP();
1.2 noro 108: void PRINTUI();
109: void PRINTGF2MAT();
110: void PRINTGFMMAT();
1.5 noro 111: void PRINTBYTEARRAY();
1.11 noro 112: void PRINTQUOTE();
1.17 ! noro 113: void PRINTSYMBOL();
! 114: void PRINTRANGE();
1.2 noro 115: void PRINTERR();
1.1 noro 116: void PRINTCPLX();
1.2 noro 117: void PRINTLM();
118: void PRINTLF();
1.13 noro 119: void PRINTUP();
120: void PRINTUM();
1.2 noro 121: void PRINTUP2();
1.13 noro 122: void PRINTFOP();
123: void PRINTEOP();
124: void PRINTLOP();
125: void PRINTQOP();
126: void PRINTSF();
1.1 noro 127:
128: static int total_length;
129:
1.13 noro 130: int estimate_length(VL vl,pointer p)
1.1 noro 131: {
132: total_length = 0;
133: PRINTEXPR(vl,p);
134: return total_length;
135: }
136:
1.15 ohara 137: #if defined(PARI)
1.13 noro 138: void PRINTBF(BF a)
1.2 noro 139: {
140: char *str;
1.7 noro 141: char *GENtostr0();
142: void myoutbrute();
1.2 noro 143:
1.7 noro 144: if ( double_output ) {
145: str = GENtostr0(a->body,myoutbrute);
146: } else {
147: str = GENtostr(a->body);
148: }
1.2 noro 149: total_length += strlen(str);
150: free(str);
151: }
152: #endif
153:
1.13 noro 154: void PRINTEXPR(VL vl,pointer p)
1.1 noro 155: {
156: if ( !p ) {
157: total_length++;
158: return;
159: }
160:
161: switch ( OID(p) ) {
162: case O_N:
163: PRINTNUM((Num)p); break;
164: case O_P:
165: PRINTP(vl,(P)p); break;
166: case O_R:
167: PRINTR(vl,(R)p); break;
168: case O_LIST:
169: PRINTLIST(vl,(LIST)p); break;
170: case O_VECT:
171: PRINTVECT(vl,(VECT)p); break;
172: case O_MAT:
173: PRINTMAT(vl,(MAT)p); break;
174: case O_STR:
175: PRINTSTR((STRING)p); break;
176: case O_COMP:
177: PRINTCOMP(vl,(COMP)p); break;
178: case O_DP:
179: PRINTDP(vl,(DP)p); break;
1.2 noro 180: case O_USINT:
181: PRINTUI(vl,(USINT)p); break;
182: case O_GF2MAT:
183: PRINTGF2MAT(vl,(GF2MAT)p); break;
184: case O_ERR:
185: PRINTERR(vl,(ERR)p); break;
186: case O_MATHCAP:
187: PRINTLIST(vl,((MATHCAP)p)->body); break;
188: case O_F:
189: PRINTLF(vl,(F)p); break;
190: case O_GFMMAT:
191: PRINTGFMMAT(vl,(GFMMAT)p); break;
1.5 noro 192: case O_BYTEARRAY:
193: PRINTBYTEARRAY(vl,(BYTEARRAY)p); break;
1.11 noro 194: case O_QUOTE:
195: PRINTQUOTE(vl,(QUOTE)p); break;
1.17 ! noro 196: case O_SYMBOL:
! 197: PRINTSYMBOL((SYMBOL)p); break;
! 198: case O_RANGE:
! 199: PRINTRANGE(vl,(RANGE)p); break;
1.1 noro 200: default:
201: break;
202: }
203: }
204:
1.13 noro 205: void PRINTN(N n)
1.1 noro 206: {
207: double ceil();
208:
209: if ( !n )
210: PUTS("0");
1.2 noro 211: else if ( hex_output )
212: total_length += 2+(int)(PL(n)*8);
1.1 noro 213: else
214: total_length += (int)(ceil(0.31*((double)(BSH*PL(n))))+1);
215: }
216:
1.13 noro 217: void PRINTNUM(Num q)
1.1 noro 218: {
219: if ( !q ) {
220: PUTS("0");
221: return;
222: }
223: switch ( NID(q) ) {
224: case N_Q:
225: if ( SGN((Q)q) == -1 )
226: PUTS("-");
227: PRINTN(NM((Q)q));
228: if ( !INT((Q)q) ) {
229: PUTS("/"); PRINTN(DN((Q)q));
230: }
231: break;
232: case N_R:
1.7 noro 233: if ( double_output )
1.8 noro 234: total_length += 400+real_digit; /* XXX */
1.7 noro 235: else
1.8 noro 236: total_length += 20+real_digit; /* XXX */
1.1 noro 237: break;
238: case N_A:
239: PUTS("("); PRINTR(ALG,(R)BDY((Alg)q)); PUTS(")");
240: break;
1.15 ohara 241: #if defined(PARI)
1.1 noro 242: case N_B:
243: PRINTBF((BF)q); break;
244: #endif
245: case N_C:
246: PRINTCPLX((C)q); break;
247: case N_M:
1.2 noro 248: total_length += 11; /* XXX */
249: break;
250: case N_LM:
251: PRINTN(((LM)q)->body); break;
252: case N_GF2N:
253: if ( hex_output )
254: PRINTN((N)(((GF2N)q)->body));
255: else
256: PRINTUP2(((GF2N)q)->body);
257: break;
258: case N_GFPN:
259: PRINTUP((UP)(((GFPN)q)->body));
1.9 noro 260: break;
261: case N_GFS:
1.10 noro 262: total_length += 13; /* XXX */
1.2 noro 263: break;
1.12 noro 264: case N_GFSN:
265: PRINTUM(BDY((GFSN)q));
266: break;
1.2 noro 267: default:
1.1 noro 268: break;
269: }
270: }
271:
1.13 noro 272: void PRINTCPLX(C a)
1.1 noro 273: {
274: PUTS("(");
275: if ( a->r )
276: PRINTNUM(a->r);
277: if ( a->i ) {
278: if ( a->r && (compnum(0,a->i,0) > 0) )
279: PUTS("+");
280: PRINTNUM(a->i); PUTS("*@i");
281: }
282: PUTS(")");
283: }
284:
1.13 noro 285: void PRINTP(VL vl,P p)
1.1 noro 286: {
287: V v;
288: DCP dc;
289:
290: if ( !p )
291: PUTS("0");
292: else if ( NUM(p) )
293: PRINTNUM((Num)p);
294: else
295: for ( dc = DC(p), v = VR(p); dc; dc = NEXT(dc) ) {
296: if ( !DEG(dc) )
297: PRINTP(vl,COEF(dc));
298: else {
299: if ( NUM(COEF(dc)) && UNIQ((Q)COEF(dc)) ) {
300: ;
301: } else if ( NUM(COEF(dc)) && MUNIQ((Q)COEF(dc)) )
302: PUTS("-");
303: else if ( NUM(COEF(dc)) || !NEXT(DC(COEF(dc)))) {
304: PRINTP(vl,COEF(dc)); PUTS("*");
305: } else {
306: PUTS("("); PRINTP(vl,COEF(dc)); PUTS(")*");
307: }
308: PRINTV(vl,v);
309: if ( cmpq(DEG(dc),ONE) ) {
1.2 noro 310: PRINTHAT;
1.1 noro 311: if ( INT(DEG(dc)) && SGN(DEG(dc))>0 )
312: PRINTNUM((Num)DEG(dc));
313: else {
314: PUTS("("); PRINTNUM((Num)DEG(dc)); PUTS(")");
315: }
316: }
317: }
318: if ( NEXT(dc) ) {
319: P t;
320:
321: t = COEF(NEXT(dc));
322: if (!DEG(NEXT(dc))) {
323: if ( NUM(t) ) {
324: if ( !mmono(t) )
325: PUTS("+");
326: } else {
327: if (!mmono(COEF(DC(t))))
328: PUTS("+");
329: }
330: } else {
331: if ( !mmono(t) )
332: PUTS("+");
333: }
334: }
335: }
336: }
337:
1.2 noro 338: extern int hideargs;
339:
1.13 noro 340: void PRINTV(VL vl,V v)
1.1 noro 341: {
342: PF pf;
343: PFAD ad;
344: int i;
345:
346: if ( NAME(v) )
347: PUTS(NAME(v));
348: else if ( (vid)v->attr == V_PF ) {
349: pf = ((PFINS)v->priv)->pf; ad = ((PFINS)v->priv)->ad;
350: if ( !strcmp(NAME(pf),"pow") ) {
1.14 noro 351: PUTS("(("); PRINTR(vl,(R)ad[0].arg); PUTS(")"); PRINTHAT; PUTS("(");
352: PRINTR(vl,(R)ad[1].arg); PUTS("))");
1.1 noro 353: } else if ( !pf->argc )
354: PUTS(NAME(pf));
355: else {
1.2 noro 356: if ( hideargs ) {
357: for ( i = 0; i < pf->argc; i++ )
358: if ( ad[i].d )
359: break;
360: if ( i < pf->argc ) {
361: PUTS(NAME(pf));
1.1 noro 362: total_length += 11; /* XXX */
1.2 noro 363: for ( i = 1; i < pf->argc; i++ ) {
364: total_length += 11; /* XXX */
365: }
366: PUTS("}");
367: } else {
368: PUTS(NAME(pf));
369: total_length += 1; /* XXX */
1.1 noro 370: }
371: } else {
1.2 noro 372: for ( i = 0; i < pf->argc; i++ )
373: if ( ad[i].d )
374: break;
375: if ( i < pf->argc ) {
376: PUTS(NAME(pf));
377: total_length += 11; /* XXX */
378: for ( i = 1; i < pf->argc; i++ ) {
379: total_length += 11; /* XXX */
380: }
381: PUTS(")(");
382: } else {
383: PUTS(NAME(pf));
384: total_length += 1; /* XXX */
385: }
386: PRINTR(vl,(R)ad[0].arg);
387: for ( i = 1; i < pf->argc; i++ ) {
388: PUTS(","); PRINTR(vl,(R)ad[i].arg);
389: }
390: PUTS(")");
1.1 noro 391: }
392: }
393: }
394: }
395:
1.13 noro 396: void PRINTR(VL vl,R a)
1.1 noro 397: {
398: if ( !a )
399: PUTS("0");
400: else
401: switch (OID(a)) {
402: case O_N: case O_P:
403: PRINTP(vl,(P)a); break;
404: default:
405: PUTS("("); PRINTP(vl,NM((R)a)); PUTS(")/("); PRINTP(vl,DN((R)a)); PUTS(")");
406: break;
407: }
408: }
409:
1.13 noro 410: void PRINTVECT(VL vl,VECT vect)
1.1 noro 411: {
412: int i;
413: pointer *ptr;
414:
415: PUTS("[ ");
416: for ( i = 0, ptr = BDY(vect); i < vect->len; i++ ) {
417: PRINTEXPR(vl,ptr[i]); PUTS(" ");
418: }
419: PUTS("]");
420: }
421:
1.13 noro 422: void PRINTMAT(VL vl,MAT mat)
1.1 noro 423: {
424: int i,j,r,c;
425: pointer *ptr;
426:
427: for ( i = 0, r = mat->row, c = mat->col; i < r; i++ ) {
428: PUTS("[ ");
429: for ( j = 0, ptr = BDY(mat)[i]; j < c; j++ ) {
430: PRINTEXPR(vl,ptr[j]); PUTS(" ");
431: }
432: PUTS("]");
433: if ( i < r - 1 )
434: PUTS("\n");
435: }
436: }
437:
1.13 noro 438: void PRINTLIST(VL vl,LIST list)
1.1 noro 439: {
440: NODE tnode;
441:
442: PUTS("[");
443: for ( tnode = (NODE)list->body; tnode; tnode = NEXT(tnode) ) {
444: PRINTEXPR(vl,tnode->body);
445: if ( NEXT(tnode) )
446: PUTS(",");
447: }
448: PUTS("]");
449: }
450:
1.13 noro 451: void PRINTSTR(STRING str)
1.1 noro 452: {
453: char *p;
454:
455: for ( p = BDY(str); *p; p++ )
456: if ( *p == '"' )
457: PUTS("\"");
458: else {
459: total_length += 1;
460: }
461: }
462:
1.13 noro 463: void PRINTCOMP(VL vl,COMP c)
1.1 noro 464: {
465: int n,i;
466:
467: n = getcompsize((int)c->type);
468: PUTS("{");
469: for ( i = 0; i < n; i++ ) {
470: PRINTEXPR(vl,(pointer)c->member[i]);
471: if ( i < n-1 )
472: PUTS(",");
473: }
474: PUTS("}");
475: }
476:
1.13 noro 477: void PRINTDP(VL vl,DP d)
1.1 noro 478: {
479: int n,i;
480: MP m;
481: DL dl;
482:
483: for ( n = d->nv, m = BDY(d); m; m = NEXT(m) ) {
484: PUTS("("); PRINTEXPR(vl,(pointer)m->c); PUTS(")*<<");
485: for ( i = 0, dl = m->dl; i < n-1; i++ ) {
486: total_length += 11;
487: }
488: total_length += 10;
489: PUTS(">>");
490: if ( NEXT(m) )
491: PUTS("+");
1.2 noro 492: }
493: }
494:
1.13 noro 495: void PRINTUI(VL vl,USINT u)
1.2 noro 496: {
497: total_length += 10;
498: }
499:
1.13 noro 500: void PRINTGF2MAT(VL vl,GF2MAT mat)
1.2 noro 501: {
502: int row,col,w,i,j,k,m;
503: unsigned int t;
504: unsigned int **b;
505:
506: row = mat->row;
507: col = mat->col;
508: w = (col+BSH-1)/BSH;
509: b = mat->body;
510: for ( i = 0; i < row; i++ ) {
511: for ( j = 0, m = 0; j < w; j++ ) {
512: t = b[i][j];
513: for ( k = 0; m < col && k < BSH; k++, m++ )
514: if ( t & (1<<k) )
515: PUTS("1");
516: else
517: PUTS("0");
518: }
519: PUTS("\n");
520: }
521: }
522:
1.13 noro 523: void PRINTGFMMAT(VL vl,GFMMAT mat)
1.2 noro 524: {
525: int row,col,i,j;
526: unsigned int **b;
527:
528: row = mat->row;
529: col = mat->col;
530: b = mat->body;
531: for ( i = 0; i < row; i++ ) {
532: PUTS("[");
533: for ( j = 0; j < col; j++ ) {
534: total_length += 10; /* XXX */
535: }
536: PUTS("]\n");
537: }
1.5 noro 538: }
539:
1.13 noro 540: void PRINTBYTEARRAY(VL vl,BYTEARRAY array)
1.5 noro 541: {
542: /* |xx xx ... xx| */
1.6 noro 543: total_length += 1+3*array->len;
1.11 noro 544: }
545:
1.13 noro 546: void PRINTQUOTE(VL vl,QUOTE quote)
1.11 noro 547: {
548: /* <...quoted...> */
549: total_length += 20;
1.17 ! noro 550: }
! 551:
! 552: void PRINTSYMBOL(SYMBOL sym)
! 553: {
! 554: total_length += strlen(sym->name);
! 555: }
! 556:
! 557: void PRINTRANGE(VL vl,RANGE r)
! 558: {
! 559: PUTS("range("); PRINTEXPR(vl,r->start);
! 560: PUTS(","); PRINTEXPR(vl,r->end); PUTS(")");
1.2 noro 561: }
562:
1.13 noro 563: void PRINTERR(VL vl,ERR e)
1.2 noro 564: {
565: PUTS("error("); PRINTEXPR(vl,e->body); PUTS(")");
566: }
567:
1.13 noro 568: void PRINTUP2(UP2 p)
1.2 noro 569: {
570: int d,i;
571:
572: if ( !p ) {
573: PUTS("0");
574: } else {
575: d = degup2(p);
576: PUTS("(");
577: if ( !d ) {
578: PUTS("1");
579: } else if ( d == 1 ) {
580: PUTS("@");
581: } else {
582: PRINTHAT;
583: total_length += 11;
584: }
585: for ( i = d-1; i >= 0; i-- ) {
586: if ( p->b[i/BSH] & (1<<(i%BSH)) )
587: if ( !i ) {
588: PUTS("+1");
589: } else if ( i == 1 ) {
590: PUTS("+@");
591: } else {
592: PRINTHAT;
593: total_length += 12;
594: }
595: }
596: PUTS(")");
597: }
598: }
599:
1.13 noro 600: void PRINTLF(VL vl,F f)
1.2 noro 601: {
602: switch ( FOP(f) ) {
603: case AL_TRUE:
604: PUTS("@true");
605: break;
606: case AL_FALSE:
607: PUTS("@false");
608: break;
609:
610: case AL_OR: case AL_AND:
611: PRINTFOP(vl,f); break;
612: case AL_NOT: case AL_IMPL: case AL_REPL: case AL_EQUIV:
613: PRINTEOP(vl,f); break;
614:
615: case AL_EQUAL: case AL_NEQ: case AL_LESSP:
616: case AL_GREATERP: case AL_LEQ: case AL_GEQ:
617: PRINTLOP(vl,f); break;
618:
619: case AL_EX: case AL_ALL:
620: PRINTQOP(vl,f); break;
621: default:
622: break;
623: }
624: }
625:
1.13 noro 626: void PRINTFOP(VL vl,F f)
1.2 noro 627: {
628: char *op;
629: NODE n;
630:
631: op = FOP(f)==AL_OR?" @|| ":" @&& ";
632: n = FJARG(f);
633: PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
634: for ( n = NEXT(n); n; n = NEXT(n) ) {
635: PUTS(op); PUTS("("); PRINTEXPR(vl,BDY(n)); PUTS(")");
636: }
637: }
638:
1.13 noro 639: void PRINTEOP(VL vl,F f)
1.2 noro 640: {
641: oFOP op;
642: char *sop;
643:
644: if ( (op = FOP(f)) == AL_NOT ) {
645: PUTS("(@! "); PRINTEXPR(vl,(Obj)FARG(f)); PUTS(")"); return;
646: }
647: switch ( op ) {
648: case AL_IMPL:
649: sop = " @impl "; break;
650: case AL_REPL:
651: sop = " @repl "; break;
652: case AL_EQUIV:
653: sop = " @equiv "; break;
654: default:
655: break;
656: }
657: PUTS("(");
658: PRINTEXPR(vl,(Obj)FLHS(f));
659: PUTS(sop);
660: PRINTEXPR(vl,(Obj)FRHS(f));
661: PUTS(")");
662: }
663:
1.13 noro 664: void PRINTLOP(VL vl,F f)
1.2 noro 665: {
666: char *op;
667:
668: switch ( FOP(f) ) {
669: case AL_EQUAL:
670: op = " @== "; break;
671: case AL_NEQ:
672: op = " @!= "; break;
673: case AL_LESSP:
674: op = " @< "; break;
675: case AL_GREATERP:
676: op = " @> "; break;
677: case AL_LEQ:
678: op = " @<= "; break;
679: case AL_GEQ:
680: op = " @>= "; break;
681: default:
682: error("PRINTLOP : invalid operator");
683: break;
684: }
685: PRINTEXPR(vl,(Obj)FPL(f)); PUTS(op); PUTS("0");
686: }
687:
1.13 noro 688: void PRINTQOP(VL vl,F f)
1.2 noro 689: {
690: char *op;
691:
692: op = FOP(f)==AL_EX?"ex":"all";
693: PUTS(op); PUTS(NAME(FQVR(f)));
694: total_length += 2;
695: PRINTEXPR(vl,(Obj)FQMAT(f)); PUTS(")");
696: }
697:
1.13 noro 698: void PRINTUP(UP n)
1.2 noro 699: {
700: int i,d;
701:
702: if ( !n )
703: PUTS("0");
704: else if ( !n->d )
705: PRINTNUM(n->c[0]);
706: else {
707: d = n->d;
708: PUTS("(");
709: if ( !d ) {
710: PRINTNUM(n->c[d]);
711: } else if ( d == 1 ) {
712: PRINTNUM(n->c[d]);
713: PUTS("*@p");
714: } else {
715: PRINTNUM(n->c[d]);
716: PRINTHAT;
717: total_length += 13;
718: }
719: for ( i = d-1; i >= 0; i-- ) {
720: if ( n->c[i] ) {
721: PUTS("+("); PRINTNUM(n->c[i]); PUTS(")");
722: if ( i >= 2 ) {
723: PRINTHAT;
724: total_length += 13;
725: } else if ( i == 1 )
726: PUTS("*@p");
727: }
728: }
729: PUTS(")");
1.1 noro 730: }
1.12 noro 731: }
732:
1.13 noro 733: void PRINTUM(UM n)
1.12 noro 734: {
735: int i,d;
736:
737: if ( !n )
738: PUTS("0");
739: else if ( !n->d )
740: PRINTSF(n->c[0]);
741: else {
742: d = n->d;
743: PUTS("(");
744: if ( !d ) {
745: PRINTSF(n->c[d]);
746: } else if ( d == 1 ) {
747: PRINTSF(n->c[d]);
748: PUTS("*@s");
749: } else {
750: PRINTSF(n->c[d]);
751: PUTS("*@s"); PRINTHAT; total_length += 13;
752: }
753: for ( i = d-1; i >= 0; i-- ) {
754: if ( n->c[i] ) {
755: PUTS("+("); PRINTSF(n->c[i]); PUTS(")");
756: if ( i >= 2 ) {
757: PUTS("*@s"); PRINTHAT; total_length += 13;
758: } else if ( i == 1 )
759: PUTS("*@s");
760: }
761: }
762: PUTS(")");
763: }
764: }
765:
1.13 noro 766: void PRINTSF(unsigned int i)
1.12 noro 767: {
768: if ( !i ) {
769: PUTS("0");
770: } else
771: total_length += 15;
1.1 noro 772: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>