Annotation of OpenXM_contrib2/asir2000/parse/comp.c, Revision 1.1.1.1
1.1 noro 1: /* $OpenXM: OpenXM/src/asir99/parse/comp.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */
2: #include "ca.h"
3: #include "parse.h"
4: #include "comp.h"
5: #if defined(THINK_C) || defined(VISUAL)
6: #include <stdarg.h>
7: #else
8: #include <varargs.h>
9: #endif
10:
11: extern f_return;
12:
13: #if defined(THINK_C) || defined(VISUAL)
14: void call_usrf(FUNC f,...)
15: {
16: va_list ap;
17: int ac,i;
18: pointer *c;
19: NODE tn;
20:
21: va_start(ap,f);
22: if ( !f )
23: notdef(0,0,0,0);
24: else {
25: pushpvs(f);
26: ac = va_arg(ap,int);
27: for ( i = 0, tn = f->f.usrf->args; i < ac;
28: i++, tn = NEXT(tn) )
29: ASSPV((int)FA0((FNODE)BDY(tn)),va_arg(ap,pointer));
30: c = va_arg(ap,pointer *); *c = evalstat(BDY(f->f.usrf));
31: va_end(ap);
32: f_return = 0; poppvs();
33: }
34: }
35: #else
36: void call_usrf(va_alist)
37: va_dcl
38: {
39: va_list ap;
40: int ac,i;
41: FUNC f;
42: pointer a,b,*c;
43: NODE tn;
44:
45: va_start(ap); f = va_arg(ap,FUNC);
46: if ( !f )
47: notdef(0,0,0,0);
48: else {
49: pushpvs(f);
50: ac = va_arg(ap,int);
51: for ( i = 0, tn = f->f.usrf->args; i < ac;
52: i++, tn = NEXT(tn) )
53: ASSPV((int)FA0((FNODE)BDY(tn)),va_arg(ap,pointer));
54: c = va_arg(ap,pointer *); *c = evalstat(BDY(f->f.usrf));
55: f_return = 0; poppvs();
56: }
57: }
58: #endif
59:
60: void addcomp(vl,a,b,c)
61: VL vl;
62: COMP a,b,*c;
63: {
64: if ( a->type != b->type )
65: error("addcomp : types different");
66: else
67: call_usrf(LSS->sa[a->type].arf.add,2,a,b,c);
68: }
69:
70: void subcomp(vl,a,b,c)
71: VL vl;
72: COMP a,b,*c;
73: {
74: if ( a->type != b->type )
75: error("subcomp : types different");
76: else
77: call_usrf(LSS->sa[a->type].arf.sub,2,a,b,c);
78: }
79:
80: void mulcomp(vl,a,b,c)
81: VL vl;
82: COMP a,b,*c;
83: {
84: if ( a->type != b->type )
85: error("mulcomp : types different");
86: else
87: call_usrf(LSS->sa[a->type].arf.mul,2,a,b,c);
88: }
89:
90: void divcomp(vl,a,b,c)
91: VL vl;
92: COMP a,b,*c;
93: {
94: if ( a->type != b->type )
95: error("divcomp : types different");
96: else
97: call_usrf(LSS->sa[a->type].arf.div,2,a,b,c);
98: }
99:
100: void chsgncomp(a,b)
101: COMP a,*b;
102: {
103: call_usrf(LSS->sa[a->type].arf.chsgn,1,a,b);
104: }
105:
106: void pwrcomp(vl,a,r,c)
107: VL vl;
108: COMP a;
109: Obj r;
110: COMP *c;
111: {
112: call_usrf(LSS->sa[a->type].arf.pwr,2,a,r,c);
113: }
114:
115: int compcomp(vl,a,b)
116: VL vl;
117: COMP a,b;
118: {
119: Q c;
120: int s;
121:
122: if ( a->type > b->type )
123: return 1;
124: else if ( a->type < b->type )
125: return -1;
126: else {
127: call_usrf(LSS->sa[a->type].arf.comp,2,a,b,&c);
128: s = QTOS(c);
129: if ( s > 0 )
130: return 1;
131: else if ( s < 0 )
132: return -1;
133: else
134: return 0;
135: }
136: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>