| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- #include "globrig.h"
- #include "define.h"
- #include "defpage.h"
- #include "nef2.h"
- #include "c1.h"
- Void addnum(a1, a2)
- long *a1, a2;
- {
- /*===========*/
- /* a1 +:= a2 */
- /*===========*/
- mpd x;
- numberdescriptor *WITH;
- if (*a1 == null_) {
- mknumb(a2, a1);
- return;
- }
- points(*a1, &x.sa);
- /* changed from pointr 25-jul-1989
- due to change in vax 10-feb-1989 */
- if (x.snd->dtype != number) {
- er(9L);
- *a1 = null_;
- } else {
- WITH = x.snd;
- WITH->val += a2; /* deleted sign */
- }
- } /* addnum*/
- Void setsel(xn, not_atomic, xa, tr_, rez)
- long xn;
- boolean not_atomic;
- long xa, tr_, rez;
- {
- /*==============================================*/
- /* whod: tr x */
- /* wyhod: t.x <- rez */
- /*==============================================*/
- /* wyhod */
- mpd x;
- a n; /* imq selektora */
- a t;
- long i, j;
- maintreedescriptor *WITH;
- long FORLIM, FORLIM1;
- fragmtreedescriptor *WITH1;
- if (not_atomic) {
- if (xa == null_) {
- er(21L);
- goto _L1;
- }
- pointr(xa, &x.sa);
- if (x.sad->dtype != idatom) {
- er(22L);
- goto _L1;
- }
- n = x.sad->name;
- } else
- n = xn;
- if (tr_ == null_)
- goto _L1;
- /* rezulxtat =null */
- /* opredelitx tip tr */
- pointr(tr_, &x.sa);
- if (x.smtd->dtype != treemain) { /* sna~ala w glawnom derewe */
- /* oibka */
- er(23L);
- goto _L1;
- }
- /*=====================================*/
- /* x ukazywaet na glawn.deskr. derewa */
- /* tr na deskr.glawn. derewa */
- /*=====================================*/
- /* poisk selektora n w derewe x */
- WITH = x.smtd; /* with */
- FORLIM = WITH->arcnum;
- for (i = 1; i <= FORLIM; i++) {
- if (WITH->arc[i - 1].arcname == n) { /* na{li */
- points(tr_, &x.sa);
- WITH->arc[i - 1].elt = rez;
- if (rez == null_) {
- FORLIM1 = WITH->arcnum;
- for (j = i; j < FORLIM1; j++)
- WITH->arc[j - 1] = WITH->arc[j];
- WITH->arcnum--;
- WITH->totalarcnum--;
- }
- goto _L1;
- }
- }
- t = WITH->next;
- /* prodolvaem poisk w fragmentah */
- while (t != null_) {
- pointr(t, &x.sa);
- WITH1 = x.sftd;
- FORLIM = WITH1->arcnum;
- for (i = 1; i <= FORLIM; i++) {
- if (WITH1->arc[i - 1].arcname == n) { /* na{li */
- points(t, &x.sa);
- WITH1->arc[i - 1].elt = rez;
- if (rez == null_) {
- FORLIM1 = WITH1->arcnum;
- for (j = i; j < FORLIM1; j++)
- WITH1->arc[j - 1] = WITH1->arc[j];
- WITH1->arcnum--;
- points(tr_, &x.sa);
- WITH = x.smtd;
- WITH->totalarcnum--;
- }
- goto _L1;
- }
- }
- t = WITH1->next; /* with */
- } /* while */
- /* ne nali ! */
- er(8L);
- _L1: ;
- } /* setsel */
- Void setind(xx, isobject, xa, l, rez)
- long xx;
- boolean isobject;
- long xa, l, rez;
- {
- /*==============================================*/
- /* whod: l xx */
- /* wyhod: l[ xx ] := rez */
- /* */
- /* l[ -1 ] - poslednij |l-t spiska */
- /* l[ -2 ] - predposlednij |l-t spiska ... */
- /*==============================================*/
- /* wyhod */
- mpd y;
- long k, n;
- a t;
- if (isobject) {
- n = numval(xa);
- if (n == 0) {
- er(3L);
- goto _L1;
- }
- } else
- n = xx;
- /* w n -zna~enie indeksa */
- if (l == null_) /* rezulxtat= null */
- goto _L1;
- /* opredelitx tip l */
- pointr(l, &y.sa);
- if (y.smld->dtype != listmain) {
- er(4L);
- goto _L1;
- }
- /*============================================*/
- /* y ukazywaet na deskriptor glawnogo spiska */
- /*============================================*/
- /* wy~islenie l[x] */
- k = y.smld->totalelnum;
- if (n < 0)
- n += k + 1;
- if (n < 1 || n > k) {
- er(5L);
- /* indeks wne spiska */
- goto _L1;
- }
- /*================================*/
- /* poisk |l-ta spiska */
- /*================================*/
- if (n <= y.smld->elnum) {
- points(l, &y.sa);
- y.smld->elt[n - 1] = rez;
- } else {
- n -= y.smld->elnum;
- t = y.smld->next;
- pointr(t, &y.sa);
- while (n > y.sfld->elnum) {
- n -= y.sfld->elnum;
- t = y.sfld->next;
- pointr(t, &y.sa);
- }
- points(t, &y.sa);
- y.sfld->elt[n - 1] = rez;
- }
- _L1: ;
- } /* setind */
- Void selop(xn, not_atomic, xa, tr_, rez)
- long xn;
- boolean not_atomic;
- long xa, tr_, *rez;
- {
- /*==============================================*/
- /* whod: tr x */
- /* wyhod: t.x -> rez */
- /*==============================================*/
- /* wyhod */
- mpd x;
- a n; /* imq selektora */
- a t;
- long i;
- maintreedescriptor *WITH;
- long FORLIM;
- fragmtreedescriptor *WITH1;
- *rez = null_;
- if (not_atomic) {
- if (xa == null_) {
- er(21L);
- goto _L1;
- }
- pointr(xa, &x.sa);
- if (x.sad->dtype != idatom) {
- er(22L);
- goto _L1;
- }
- n = x.sad->name;
- } else
- n = xn;
- if (tr_ == null_)
- goto _L1;
- /* rezulxtat =null */
- /* opredelitx tip tr */
- pointr(tr_, &x.sa);
- if (x.smtd->dtype != treemain) { /* sna~ala w glawnom derewe */
- /* o{ibka */
- er(23L);
- goto _L1;
- }
- /*=====================================*/
- /* x ukazywaet na glawn.deskr. derewa */
- /* tr na deskr.glawn. derewa */
- /*=====================================*/
- /* poisk selektora n w derewe x */
- WITH = x.smtd; /* with */
- FORLIM = WITH->arcnum;
- for (i = 0; i < FORLIM; i++) {
- if (WITH->arc[i].arcname == n) { /* na{li */
- *rez = WITH->arc[i].elt;
- goto _L1;
- }
- }
- t = WITH->next;
- /* prodolvaem poisk w fragmentah */
- while (t != null_) {
- pointr(t, &x.sa);
- WITH1 = x.sftd;
- FORLIM = WITH1->arcnum;
- for (i = 0; i < FORLIM; i++) {
- if (WITH1->arc[i].arcname == n) { /* na{li */
- *rez = WITH1->arc[i].elt;
- goto _L1;
- }
- }
- t = WITH1->next; /* with */
- } /* while */
- /* ne na{li ! */
- _L1: ;
- } /* selop */
- Void indxop(xx, isobject, xa, l, rez)
- long xx;
- boolean isobject;
- long xa, l, *rez;
- {
- /*==============================================*/
- /* whod: l xx */
- /* wyhod: l[ xx ] */
- /* */
- /* l[ -1 ] - poslednij |l-t spiska */
- /* l[ -2 ] - predposlednij |l-t spiska ... */
- /*==============================================*/
- /* wyhod */
- mpd y;
- long k, n;
- a t;
- *rez = null_;
- if (isobject) {
- n = numval(xa);
- if (n == 0) {
- er(3L);
- goto _L1;
- }
- } else
- n = xx;
- /* w n -zna~enie indeksa */
- if (l == null_) /* rezulxtat= null */
- goto _L1;
- /* opredelitx tip l */
- pointr(l, &y.sa);
- if (y.smld->dtype != listmain) {
- er(4L);
- goto _L1;
- }
- /*============================================*/
- /* y ukazywaet na deskriptor glawnogo spiska */
- /*============================================*/
- /* wy~islenie l[x] */
- k = y.smld->totalelnum;
- if (n < 0)
- n += k + 1;
- if (n < 1 || n > k) {
- er(5L);
- /* indeks wne spiska */
- goto _L1;
- }
- /*================================*/
- /* poisk |l-ta spiska */
- /*================================*/
- if (n <= y.smld->elnum)
- *rez = y.smld->elt[n - 1];
- else {
- n -= y.smld->elnum;
- t = y.smld->next;
- pointr(t, &y.sa);
- while (n > y.sfld->elnum) {
- n -= y.sfld->elnum;
- t = y.sfld->next;
- pointr(t, &y.sa);
- }
- *rez = y.sfld->elt[n - 1];
- }
- /* w rez rezulxtat = l [ x ] */
- _L1: ;
- } /* indxop */
- Void concop(a1, a2)
- long *a1, a2;
- {
- /*======================================*/
- /* operaciq a1 !! a2 */
- /* ( a1 !! a2 ) -> a1 */
- /*======================================*/
- /* wyhod */
- mpd x;
- ptr_ p1;
- a l;
- l = *a1;
- if (a2 == null_) {
- if (l == null_)
- goto _L99;
- else {
- pointr(l, &x.sa);
- if (x.smld->dtype == listmain)
- goto _L99;
- else {
- l = null_;
- goto _L99;
- }
- }
- }
- pointr(a2, &x.sa);
- if (x.smld->dtype != listmain) {
- l = null_;
- goto _L99;
- }
- if (l != null_) {
- pointr(l, &x.sa);
- if (x.smld->dtype != listmain) {
- l = null_;
- goto _L99;
- }
- }
- first(a2, &p1);
- while (p1.nel != 0) {
- lconc(&l, p1.cel);
- next(&p1);
- }
- _L99:
- *a1 = l;
- } /* concop */
- Void copyop(ob, rez)
- long ob, *rez;
- {
- /*==========================*/
- /*whod: ob */
- /*wyhod: copy( a )-> rez */
- /*==========================*/
- /* wyhod */
- long k;
- mpd x, y, z;
- a r1, r2, r3;
- if (ob == null_) {
- *rez = null_;
- goto _L99;
- }
- pointr(ob, &x.sa);
- switch (x.sad->dtype) {
- case atom:
- case idatom:
- case keyword:
- case number:
- case tatom:
- case fatom:
- case variable:
- case idvariable:
- case nvariable:
- case fvariable:
- case spec: /* coord removed */
- gets1(&r1, &y.sa);
- *y.sad = *x.sad;
- *rez = r1;
- break;
- case rulename:
- case object_d:
- gets2(&r1, &y.sa);
- *y.srd = *x.srd;
- *rez = r1;
- break;
- case listmain:
- case treemain:
- gets5(&r1, &y.sa);
- /* skopirowatx glawnyj deskriptor */
- *y.smld = *x.smld;
- *rez = r1;
- r2 = x.smld->next;
- while (r2 != null_) {
- pointr(r2, &x.sa);
- gets5(&r3, &z.sa);
- *z.smld = *x.smld;
- points(r1, &y.sa);
- y.smld->next = r3;
- r1 = r3;
- r2 = z.smld->next;
- } /* while */
- break;
- }/* case */
- _L99: ; /* wyhod */
- } /* copyop */
- /* End. */
|