Annotation of 43BSD/ingres/source/ovqp/interp1.c, revision 1.1

1.1     ! root        1: # include      <ingres.h>
        !             2: # include      <aux.h>
        !             3: # include      <symbol.h>
        !             4: # include      <tree.h>
        !             5: # include      "../decomp/globs.h"
        !             6: # include      <sccs.h>
        !             7: # include      <errors.h>
        !             8: 
        !             9: SCCSID(@(#)interp1.c   8.3     2/8/85)
        !            10: 
        !            11: 
        !            12: /*
        !            13: **     INTERP1.C
        !            14: **
        !            15: **     symbol I/O utility routines for OVQP interpreter.
        !            16: **
        !            17: */
        !            18: 
        !            19: /*
        !            20: ** GETSYMBOL
        !            21: **
        !            22: **     Gets (type, len, value) symbols from list
        !            23: **     A ptr to the list is advanced after
        !            24: **     call.  Symbols are moved to a target location
        !            25: **     (typically a slot on the interpreter's De.ov_stack).
        !            26: **     Legality of symbol type and length is checked.
        !            27: **     Returns         1  if no more symbols in list
        !            28: **                     0 otherwise
        !            29: **
        !            30: */
        !            31: 
        !            32: getsymbol(ts, p)
        !            33: SYMBOL *ts;            /* target location (on stack) */
        !            34: SYMBOL ***p;           /* pointer to list */
        !            35: {
        !            36:        int                     len;    /*length of target symbol*/
        !            37:        register union symvalue *d;     /* ptr to data for target symbol */
        !            38:        register SYMBOL         *cp;    /* the item in the list */
        !            39:        register SYMBOL         *tops;  /* target location on stack */
        !            40:        register union symvalue *val;
        !            41:        register STRKEEPER      *seen;  /* Have we seen an s? */
        !            42:        register char           *c;     /* For debugging */
        !            43:        int                     start;  /* save the start pos of a string */
        !            44: 
        !            45:        seen = 0;
        !            46:        tops = ts;      /* copy stack pointer */
        !            47:        cp = **p;       /* get list pointer */
        !            48:        tops->start = -1;       /* initialize start to impossible value */
        !            49: 
        !            50: #      ifdef xOTR1
        !            51:        if (tTf(84, 0))
        !            52:        {
        !            53:                printf("GETSYM: ");
        !            54:                prsym(cp);
        !            55:        }
        !            56: #      endif
        !            57: 
        !            58:        if (tops >= (SYMBOL *) &De.ov_stack[STACKSIZ])
        !            59:                ov_err(STACKOVER);
        !            60: 
        !            61:        val = &cp->value;
        !            62:        /* decomp will put the s_var's value in the right place 
        !            63:         * if this is the case
        !            64:         */
        !            65:        if (cp->type == VAR || cp->type == S_VAR)
        !            66:        {
        !            67:                tops->type = val->sym_var.varfrmt;
        !            68:                len = tops->len = val->sym_var.varfrml;
        !            69:                d = (union symvalue *) val->sym_var.valptr;
        !            70:                seen = (STRKEEPER *) val->sym_var.varstr;
        !            71:                val->sym_var.varstr = 0;
        !            72:        }
        !            73:        else
        !            74:        {
        !            75:                tops->type = cp->type;
        !            76:                len = tops->len = cp->len;
        !            77:                len &= I1MASK;
        !            78:                d = &cp->value;
        !            79:        }
        !            80:        /* advance De.ov_qvect sequencing pointer p */
        !            81:        *p += 1;
        !            82: 
        !            83:        switch(tops->type)
        !            84:        {
        !            85:          case INT:
        !            86:                switch (len)
        !            87:                {
        !            88:                  case 1:
        !            89:                        tops->value.sym_data.i2type = d->sym_data.i1type;
        !            90:                        break;
        !            91:                  case 2:
        !            92:                  case 4:
        !            93:                        bmove((char *) d, (char *) &tops->value.sym_data, len);
        !            94:                        break;
        !            95: 
        !            96:                  default:
        !            97:                        syserr("getsym:bad int len %d",len);
        !            98:                }
        !            99:                break;
        !           100: 
        !           101:          case FLOAT:
        !           102:                switch (len)
        !           103:                {
        !           104:                  case 4:
        !           105:                        tops->value.sym_data.f8type = d->sym_data.f4type;
        !           106:                        break;
        !           107: 
        !           108:                  case 8:
        !           109:                        tops->value.sym_data.f8type = d->sym_data.f8type;
        !           110:                        break;
        !           111: 
        !           112:                  default:
        !           113:                        syserr("getsym:bad FLOAT len %d",len);
        !           114:                }
        !           115:                break;
        !           116: 
        !           117:          case CHAR:
        !           118:          {
        !           119:                if ( seen )
        !           120:                {
        !           121:                    if ((c = (char *)grabstring(seen,d,1+(char *)tops, &start)) != NULL)
        !           122:                    {
        !           123:                        tops->value.sym_data.cptype = c;
        !           124:                        /*tops->leavebl = 1; */
        !           125:                        tops->start = start;
        !           126:                    }
        !           127:                    else
        !           128:                    {
        !           129:                        tops->value.sym_data.cptype = "\0";
        !           130:                        tops->len = 0;
        !           131:                    }
        !           132:                }
        !           133:                else
        !           134:                {
        !           135:                    tops->value.sym_data.cptype = (char *)d;
        !           136:                    seen = 0;
        !           137:                }
        !           138:                break;
        !           139:        }
        !           140: 
        !           141:          case AOP:
        !           142:          case BOP:
        !           143:          case UOP:
        !           144:          case COP:
        !           145:                tops->value.sym_op.opno = d->sym_op.opno;
        !           146:                break;
        !           147: 
        !           148:          case RESDOM:
        !           149:                tops->value.sym_resdom.resno = d->sym_resdom.resno;
        !           150:                break;
        !           151: 
        !           152:          case AND:
        !           153:          case OR:
        !           154:                break;
        !           155: 
        !           156:          case AGHEAD:
        !           157:          case BYHEAD:
        !           158:          case ROOT:
        !           159:          case QLEND:
        !           160:                return (1);     /* all these are delimitors between lists */
        !           161: 
        !           162:          default:
        !           163:                syserr("getsym:bad type %d", tops->type);
        !           164:        }
        !           165:        return(0);
        !           166: }
        !           167: /*
        !           168: **  TOUT
        !           169: **
        !           170: **     Copies a symbol value into the Output tuple buffer.
        !           171: **     Used to write target
        !           172: **     list elements or aggregate values into the output tuple.&
        !           173: */
        !           174: 
        !           175: tout(s, offp, rlen)
        !           176: register SYMBOL        *s;
        !           177: char           *offp;
        !           178: int            rlen;
        !           179: {
        !           180:        register int    i;
        !           181:        register char   *p;
        !           182:        int             slen;
        !           183: 
        !           184: #      ifdef xOTR1
        !           185:        if (tTf(84, 3))
        !           186:        {
        !           187:                printf("TOUT: s=");
        !           188:                prstack(s);
        !           189:                printf("  offset=%d, rlen=%d\n", offp-De.ov_outtup, rlen);
        !           190:        }
        !           191: #      endif
        !           192:        if (s->type == CHAR)
        !           193:        {
        !           194:                slen = s->len & I1MASK;
        !           195:                rlen &= I1MASK;
        !           196:                i = rlen - slen;        /* compute difference between sizes */
        !           197:                if (i <= 0)
        !           198:                {
        !           199:                        bmove(s->value.sym_data.cptype, offp, rlen);
        !           200:                }
        !           201:                else
        !           202:                {
        !           203:                        p = s->value.sym_data.cptype;
        !           204:                        bmove(p, offp, slen);
        !           205:                        p = &offp[slen];
        !           206:                        while (i--)
        !           207:                                *p++ = ' ';     /* blank out remainder */
        !           208:                }
        !           209:        }
        !           210:        else
        !           211:        {
        !           212:                bmove((char *)&s->value, offp, rlen);
        !           213:        }
        !           214: }
        !           215: 
        !           216: /*
        !           217: **     RCVT -  convert a symbol to a given type 
        !           218: **
        !           219: **     Parameters:
        !           220: **             tos -  the symbol
        !           221: **             restype - the type to convert it to
        !           222: **             reslen - the length of the type
        !           223: **
        !           224: **     Trace Flags:
        !           225: **             84.6
        !           226: **
        !           227: **     Called by:
        !           228: **             interpret()
        !           229: **             setallkey()
        !           230: **             typecoerce()
        !           231: */
        !           232: rcvt(tos, restype, reslen)
        !           233: register SYMBOL        *tos;
        !           234: int            restype, reslen;
        !           235: {
        !           236:        register int    rtype, rlen;
        !           237:        int             stype, slen;
        !           238: 
        !           239:        rtype = restype;
        !           240:        rlen = reslen;
        !           241:        stype = tos->type;
        !           242:        slen= tos->len;
        !           243: #      ifdef xOTR1
        !           244:        if (tTf(84, 6))
        !           245:        {
        !           246:                printf("RCVT:type=");
        !           247:                xputchar(rtype);
        !           248:                printf("%3d, tos=", rlen);
        !           249:                prstack(tos);
        !           250:        }
        !           251: #      endif
        !           252: 
        !           253:        if (rtype != stype)
        !           254:        {
        !           255:                if (rtype == CHAR || stype == CHAR)
        !           256:                        ov_err(BADCONV);        /* bad char to numeric conversion requested */
        !           257:                if (rtype == FLOAT)
        !           258:                        itof(tos);
        !           259:                else
        !           260:                {
        !           261:                        if (rlen == 4)
        !           262:                                ftoi4(tos);
        !           263:                        else
        !           264:                                ftoi2(tos);
        !           265:                }
        !           266:                tos->len = rlen;        /* handles conversion to i1 or f4 */
        !           267:        }
        !           268: 
        !           269:        else
        !           270:        {
        !           271:                if (rtype != CHAR && rlen != slen)
        !           272:                {
        !           273:                        if (rtype == INT)
        !           274:                        {
        !           275:                                if (rlen == 4)
        !           276:                                        i2toi4(tos);
        !           277:                                else if (slen == 4)
        !           278:                                                i4toi2(tos);
        !           279:                        }
        !           280:                        tos->len = rlen;        /* handles conversion to i1 or f4 */
        !           281:                }
        !           282:        }
        !           283: #      ifdef xOTR3
        !           284:        if (tTf(84, 6))
        !           285:        {
        !           286:                printf("RCVT rets: symbol: ");
        !           287:                prsym(tos);
        !           288:        }
        !           289: #      endif
        !           290: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.