small elements are now stored in their exact size rather than
authorMark Linton <linton@ucbvax.Berkeley.EDU>
Sun, 14 Feb 1982 09:19:52 +0000 (01:19 -0800)
committerMark Linton <linton@ucbvax.Berkeley.EDU>
Sun, 14 Feb 1982 09:19:52 +0000 (01:19 -0800)
always as longs on the evaluation stack

SCCS-vsn: usr.bin/pascal/pdx/sym/printval.c 1.3
SCCS-vsn: usr.bin/pascal/pdx/sym/tree.c 1.2

usr/src/usr.bin/pascal/pdx/sym/printval.c
usr/src/usr.bin/pascal/pdx/sym/tree.c

index 3cd5fc5..34ef207 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)printval.c 1.2 %G%";
+static char sccsid[] = "@(#)printval.c 1.3 %G%";
 
 /*
  * Print out the value at the top of the stack using the given type.
 
 /*
  * Print out the value at the top of the stack using the given type.
@@ -18,104 +18,104 @@ static char sccsid[] = "@(#)printval.c 1.2 %G%";
 printval(s)
 SYM *s;
 {
 printval(s)
 SYM *s;
 {
-       SYM *t;
-       ADDRESS a;
-       int len;
-
-       if (s->class == REF) {
-               s = s->type;
+    SYM *t;
+    ADDRESS a;
+    int len;
+
+    if (s->class == REF) {
+       s = s->type;
+    }
+    switch(s->class) {
+       case ARRAY:
+           t = rtype(s->type);
+           if (t==t_char || (t->class==RANGE && t->type==t_char)) {
+               len = size(s);
+               sp -= len;
+               printf("'%.*s'", len, sp);
+               break;
+           } else {
+               printarray(s);
+           }
+           break;
+
+       case RECORD:
+           printrecord(s);
+           break;
+
+       case VARNT:
+           error("can't print out variant records");
+           break;
+
+       case RANGE:
+           if (s == t_real) {
+               printf("%g", pop(double));
+           } else if (s == t_char) {
+               printf("'%c'", pop(char));
+           } else if (s == t_boolean) {
+               printf(pop(BOOLEAN)==TRUE ? "true" : "false");
+           } else {
+               printf("%ld", popsmall(s));
+           }
+           break;
+
+       case FILET:
+       case PTR: {
+           ADDRESS addr;
+
+           addr = pop(ADDRESS);
+           if (addr == 0) {
+               printf("nil");
+           } else {
+               printf("0%o", addr);
+           }
+           break;
        }
        }
-       switch(s->class) {
-               case ARRAY:
-                       t = rtype(s->type);
-                       if (t==t_char || (t->class==RANGE && t->type==t_char)) {
-                               len = size(s);
-                               sp -= len;
-                               printf("'%.*s'", len, sp);
-                               break;
-                       } else {
-                               printarray(s);
-                       }
-                       break;
-
-               case RECORD:
-                       printrecord(s);
-                       break;
-
-               case VARNT:
-                       error("can't print out variant records");
-                       break;
-
-               case RANGE:
-                       if (s == t_real) {
-                               printf("%g", pop(double));
-                       } else if (s == t_char) {
-                               printf("'%c'", pop(long));
-                       } else if (s == t_boolean) {
-                               printf(pop(BOOLEAN)==TRUE ? "true" : "false");
-                       } else {
-                               printf("%ld", pop(long));
-                       }
-                       break;
-
-               case FILET:
-               case PTR: {
-                       ADDRESS addr;
-
-                       addr = pop(ADDRESS);
-                       if (addr == 0) {
-                               printf("nil");
-                       } else {
-                               printf("0%o", addr);
-                       }
-                       break;
-               }
-
-               case FIELD:
-                       error("missing record specification");
-                       break;
-
-               case SCAL: {
-                       int scalar;
-                       BOOLEAN found;
-
-                       scalar = pop(long);
-                       found = FALSE;
-                       for (t = s->chain; t != NIL; t = t->chain) {
-                               if (t->symvalue.iconval == scalar) {
-                                       printf("%s", t->symbol);
-                                       found = TRUE;
-                                       break;
-                               }
-                       }
-                       if (!found) {
-                               printf("(scalar = %d)", scalar);
-                       }
-                       break;
-               }
 
 
-               case FPROC:
-               case FFUNC:
-               {
-                       ADDRESS a;
-
-                       a = fparamaddr(pop(long));
-                       t = whatblock(a);
-                       if (t == NIL) {
-                               printf("(proc %d)", a);
-                       } else {
-                               printf("%s", t->symbol);
-                       }
-                       break;
+       case FIELD:
+           error("missing record specification");
+           break;
+
+       case SCAL: {
+           int scalar;
+           BOOLEAN found;
+
+           scalar = popsmall(s);
+           found = FALSE;
+           for (t = s->chain; t != NIL; t = t->chain) {
+               if (t->symvalue.iconval == scalar) {
+                   printf("%s", t->symbol);
+                   found = TRUE;
+                   break;
                }
                }
+           }
+           if (!found) {
+               printf("(scalar = %d)", scalar);
+           }
+           break;
+       }
 
 
-               default:
-                       if (s->class < BADUSE || s->class > VARNT) {
-                               panic("printval: bad class %d", s->class);
-                       }
-                       error("don't know how to print a %s", classname(s));
-                       /* NOTREACHED */
+       case FPROC:
+       case FFUNC:
+       {
+           ADDRESS a;
+
+           a = fparamaddr(pop(long));
+           t = whatblock(a);
+           if (t == NIL) {
+               printf("(proc %d)", a);
+           } else {
+               printf("%s", t->symbol);
+           }
+           break;
        }
        }
+
+       default:
+           if (s->class < BADUSE || s->class > VARNT) {
+               panic("printval: bad class %d", s->class);
+           }
+           error("don't know how to print a %s", classname(s));
+           /* NOTREACHED */
+    }
 }
 
 /*
 }
 
 /*
@@ -125,15 +125,15 @@ SYM *s;
 LOCAL printrecord(s)
 SYM *s;
 {
 LOCAL printrecord(s)
 SYM *s;
 {
-       SYM *t;
-
-       if ((t = s->chain) == NIL) {
-               error("record has no fields");
-       }
-       printf("(");
-       sp -= size(s);
-       printfield(t);
-       printf(")");
+    SYM *t;
+
+    if ((t = s->chain) == NIL) {
+       error("record has no fields");
+    }
+    printf("(");
+    sp -= size(s);
+    printfield(t);
+    printf(")");
 }
 
 /*
 }
 
 /*
@@ -144,18 +144,17 @@ SYM *s;
 LOCAL printfield(s)
 SYM *s;
 {
 LOCAL printfield(s)
 SYM *s;
 {
-       STACK *savesp;
-
-       if (s->chain != NIL) {
-               printfield(s->chain);
-               printf(", ");
-       }
-       printf("%s = ", s->symbol);
-       savesp = sp;
-       sp += (s->symvalue.offset + size(s->type));
-       alignstack();
-       printval(s->type);
-       sp = savesp;
+    STACK *savesp;
+
+    if (s->chain != NIL) {
+       printfield(s->chain);
+       printf(", ");
+    }
+    printf("%s = ", s->symbol);
+    savesp = sp;
+    sp += (s->symvalue.offset + size(s->type));
+    printval(s->type);
+    sp = savesp;
 }
 
 /*
 }
 
 /*
@@ -170,22 +169,22 @@ SYM *s;
 LOCAL printarray(a)
 SYM *a;
 {
 LOCAL printarray(a)
 SYM *a;
 {
-       STACK *savesp, *newsp;
-       SYM *eltype;
-       long elsize;
-
-       savesp = sp;
-       sp -= size(a);
-       newsp = sp;
-       eltype = a->type;
-       elsize = size(eltype);
-       printf("(");
-       for (sp += elsize; sp <= savesp; sp += 2*elsize) {
-               if (sp - elsize != newsp) {
-                       printf(", ");
-               }
-               printval(eltype);
+    STACK *savesp, *newsp;
+    SYM *eltype;
+    long elsize;
+
+    savesp = sp;
+    sp -= size(a);
+    newsp = sp;
+    eltype = a->type;
+    elsize = size(eltype);
+    printf("(");
+    for (sp += elsize; sp <= savesp; sp += 2*elsize) {
+       if (sp - elsize != newsp) {
+           printf(", ");
        }
        }
-       sp = newsp;
-       printf(")");
+       printval(eltype);
+    }
+    sp = newsp;
+    printf(")");
 }
 }
index 5d4104c..82e6c6a 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)tree.c 1.1 %G%";
+static char sccsid[] = "@(#)tree.c 1.2 %G%";
 
 /*
  * This module contains the interface between the SYM routines and
 
 /*
  * This module contains the interface between the SYM routines and
@@ -20,7 +20,7 @@ static char sccsid[] = "@(#)tree.c 1.1 %G%";
 
 typedef char *ARGLIST;
 
 
 typedef char *ARGLIST;
 
-#define nextarg(arglist, type) ((type *) (arglist += sizeof(type)))[-1]
+#define nextarg(arglist, type)  ((type *) (arglist += sizeof(type)))[-1]
 
 LOCAL SYM *mkstring();
 LOCAL SYM *namenode();
 
 LOCAL SYM *mkstring();
 LOCAL SYM *namenode();
@@ -34,178 +34,178 @@ SYM *treetype(p, ap)
 register NODE *p;
 register ARGLIST ap;
 {
 register NODE *p;
 register ARGLIST ap;
 {
-       switch(p->op) {
-               case O_NAME: {
-                       SYM *s;
-
-                       s = nextarg(ap, SYM *);
-                       s = which(s);
-                       return namenode(p, s);
-                       /* NOTREACHED */
-               }
+    switch(p->op) {
+       case O_NAME: {
+           SYM *s;
+
+           s = nextarg(ap, SYM *);
+           s = which(s);
+           return namenode(p, s);
+           /* NOTREACHED */
+       }
 
 
-               case O_WHICH:
-                       p->nameval = nextarg(ap, SYM *);
-                       p->nameval = which(p->nameval);
-                       return NIL;
-
-               case O_LCON:
-                       return t_int;
-
-               case O_FCON:
-                       return t_real;
-
-               case O_SCON: {
-                       char *cpy;
-                       SYM *s;
-
-                       cpy = strdup(p->sconval);
-                       p->sconval = cpy;
-                       s = mkstring(p->sconval);
-                       if (s == t_char) {
-                               p->op = O_LCON;
-                               p->lconval = p->sconval[0];
-                       }
-                       return s;
-               }
+       case O_WHICH:
+           p->nameval = nextarg(ap, SYM *);
+           p->nameval = which(p->nameval);
+           return NIL;
+
+       case O_LCON:
+           return t_int;
+
+       case O_FCON:
+           return t_real;
+
+       case O_SCON: {
+           char *cpy;
+           SYM *s;
+
+           cpy = strdup(p->sconval);
+           p->sconval = cpy;
+           s = mkstring(p->sconval);
+           if (s == t_char) {
+               p->op = O_LCON;
+               p->lconval = p->sconval[0];
+           }
+           return s;
+       }
 
 
-               case O_INDIR:
-                       p->left = nextarg(ap, NODE *);
-                       chkclass(p->left, PTR);
-                       return rtype(p->left->nodetype)->type;
-
-               case O_RVAL: {
-                       NODE *p1, *q;
-
-                       p1 = p->left;
-                       p->nodetype = p1->nodetype;
-                       if (p1->op == O_NAME) {
-                               if (p1->nodetype->class == FUNC) {
-                                       p->op = O_CALL;
-                                       p->right = NIL;
-                               } else if (p1->nameval->class == CONST) {
-                                       if (p1->nameval->type == t_real->type) {
-                                               p->op = O_FCON;
-                                               p->fconval = p1->nameval->symvalue.fconval;
-                                               p->nodetype = t_real;
-                                               dispose(p1);
-                                       } else {
-                                               p->op = O_LCON;
-                                               p->lconval = p1->nameval->symvalue.iconval;
-                                               p->nodetype = p1->nameval->type;
-                                               dispose(p1);
-                                       }
-                               }
-                       }
-                       return p->nodetype;
-                       /* NOTREACHED */
+       case O_INDIR:
+           p->left = nextarg(ap, NODE *);
+           chkclass(p->left, PTR);
+           return rtype(p->left->nodetype)->type;
+
+       case O_RVAL: {
+           NODE *p1, *q;
+
+           p1 = p->left;
+           p->nodetype = p1->nodetype;
+           if (p1->op == O_NAME) {
+               if (p1->nodetype->class == FUNC) {
+                   p->op = O_CALL;
+                   p->right = NIL;
+               } else if (p1->nameval->class == CONST) {
+                   if (p1->nameval->type == t_real->type) {
+                       p->op = O_FCON;
+                       p->fconval = p1->nameval->symvalue.fconval;
+                       p->nodetype = t_real;
+                       dispose(p1);
+                   } else {
+                       p->op = O_LCON;
+                       p->lconval = p1->nameval->symvalue.iconval;
+                       p->nodetype = p1->nameval->type;
+                       dispose(p1);
+                   }
                }
                }
+           }
+           return p->nodetype;
+           /* NOTREACHED */
+       }
 
 
-               case O_CALL: {
-                       SYM *s;
-
-                       p->left = nextarg(ap, NODE *);
-                       p->right = nextarg(ap, NODE *);
-                       s = p->left->nodetype;
-                       if (isblock(s) && isbuiltin(s)) {
-                               p->op = (OP) s->symvalue.token.tokval;
-                               tfree(p->left);
-                               p->left = p->right;
-                               p->right = NIL;
-                       }
-                       return s->type;
-               }
+       case O_CALL: {
+           SYM *s;
+
+           p->left = nextarg(ap, NODE *);
+           p->right = nextarg(ap, NODE *);
+           s = p->left->nodetype;
+           if (isblock(s) && isbuiltin(s)) {
+               p->op = (OP) s->symvalue.token.tokval;
+               tfree(p->left);
+               p->left = p->right;
+               p->right = NIL;
+           }
+           return s->type;
+       }
 
 
-               case O_ITOF:
-                       return t_real;
-
-               case O_NEG: {
-                       SYM *s;
-
-                       p->left = nextarg(ap, NODE *);
-                       s = p->left->nodetype;
-                       if (!compatible(s, t_int)) {
-                               if (!compatible(s, t_real)) {
-                                       trerror("%t is improper type", p->left);
-                               } else {
-                                       p->op = O_NEGF;
-                               }
-                       }
-                       return s;
-               }
+       case O_ITOF:
+           return t_real;
 
 
-               case O_ADD:
-               case O_SUB:
-               case O_MUL:
-               case O_LT:
-               case O_LE:
-               case O_GT:
-               case O_GE:
-               case O_EQ:
-               case O_NE:
-               {
-                       BOOLEAN t1real, t2real;
-                       SYM *t1, *t2;
-
-                       p->left = nextarg(ap, NODE *);
-                       p->right = nextarg(ap, NODE *);
-                       t1 = rtype(p->left->nodetype);
-                       t2 = rtype(p->right->nodetype);
-                       t1real = (t1 == t_real);
-                       t2real = (t2 == t_real);
-                       if (t1real || t2real) {
-                               p->op++;
-                               if (!t1real) {
-                                       p->left = build(O_ITOF, p->left);
-                               } else if (!t2real) {
-                                       p->right = build(O_ITOF, p->right);
-                               }
-                       } else {
-                               if (t1real) {
-                                       convert(&p->left, t_int, O_NOP);
-                               }
-                               if (t2real) {
-                                       convert(&p->right, t_int, O_NOP);
-                               }
-                       }
-                       if (p->op >= O_LT) {
-                               return t_boolean;
-                       } else {
-                               if (t1real || t2real) {
-                                       return t_real;
-                               } else {
-                                       return t_int;
-                               }
-                       }
-                       /* NOTREACHED */
+       case O_NEG: {
+           SYM *s;
+
+           p->left = nextarg(ap, NODE *);
+           s = p->left->nodetype;
+           if (!compatible(s, t_int)) {
+               if (!compatible(s, t_real)) {
+                   trerror("%t is improper type", p->left);
+               } else {
+                   p->op = O_NEGF;
                }
                }
+           }
+           return s;
+       }
 
 
-               case O_DIVF:
-                       p->left = nextarg(ap, NODE *);
-                       p->right = nextarg(ap, NODE *);
-                       convert(&p->left, t_real, O_ITOF);
-                       convert(&p->right, t_real, O_ITOF);
-                       return t_real;
-
-               case O_DIV:
-               case O_MOD:
-                       p->left = nextarg(ap, NODE *);
-                       p->right = nextarg(ap, NODE *);
-                       convert(&p->left, t_int, O_NOP);
-                       convert(&p->right, t_int, O_NOP);
-                       return t_int;
-
-               case O_AND:
-               case O_OR:
-                       p->left = nextarg(ap, NODE *);
-                       p->right = nextarg(ap, NODE *);
-                       chkboolean(p->left);
-                       chkboolean(p->right);
-                       return t_boolean;
-
-               default:
-                       return NIL;
+       case O_ADD:
+       case O_SUB:
+       case O_MUL:
+       case O_LT:
+       case O_LE:
+       case O_GT:
+       case O_GE:
+       case O_EQ:
+       case O_NE:
+       {
+           BOOLEAN t1real, t2real;
+           SYM *t1, *t2;
+
+           p->left = nextarg(ap, NODE *);
+           p->right = nextarg(ap, NODE *);
+           t1 = rtype(p->left->nodetype);
+           t2 = rtype(p->right->nodetype);
+           t1real = (t1 == t_real);
+           t2real = (t2 == t_real);
+           if (t1real || t2real) {
+               p->op++;
+               if (!t1real) {
+                   p->left = build(O_ITOF, p->left);
+               } else if (!t2real) {
+                   p->right = build(O_ITOF, p->right);
+               }
+           } else {
+               if (t1real) {
+                   convert(&p->left, t_int, O_NOP);
+               }
+               if (t2real) {
+                   convert(&p->right, t_int, O_NOP);
+               }
+           }
+           if (p->op >= O_LT) {
+               return t_boolean;
+           } else {
+               if (t1real || t2real) {
+                   return t_real;
+               } else {
+                   return t_int;
+               }
+           }
+           /* NOTREACHED */
        }
        }
+
+       case O_DIVF:
+           p->left = nextarg(ap, NODE *);
+           p->right = nextarg(ap, NODE *);
+           convert(&p->left, t_real, O_ITOF);
+           convert(&p->right, t_real, O_ITOF);
+           return t_real;
+
+       case O_DIV:
+       case O_MOD:
+           p->left = nextarg(ap, NODE *);
+           p->right = nextarg(ap, NODE *);
+           convert(&p->left, t_int, O_NOP);
+           convert(&p->right, t_int, O_NOP);
+           return t_int;
+
+       case O_AND:
+       case O_OR:
+           p->left = nextarg(ap, NODE *);
+           p->right = nextarg(ap, NODE *);
+           chkboolean(p->left);
+           chkboolean(p->right);
+           return t_boolean;
+
+       default:
+           return NIL;
+    }
 }
 
 /*
 }
 
 /*
@@ -218,21 +218,21 @@ LOCAL SYM *namenode(p, s)
 NODE *p;
 SYM *s;
 {
 NODE *p;
 SYM *s;
 {
-       NODE *np;
-
-       p->nameval = s;
-       if (s->class == REF) {
-               np = alloc(1, NODE);
-               *np = *p;
-               p->op = O_INDIR;
-               p->left = np;
-               np->nodetype = s;
-       }
-       if (s->class == CONST || s->class == VAR || s->class == FVAR) {
-               return s->type;
-       } else {
-               return s;
-       }
+    NODE *np;
+
+    p->nameval = s;
+    if (s->class == REF) {
+       np = alloc(1, NODE);
+       *np = *p;
+       p->op = O_INDIR;
+       p->left = np;
+       np->nodetype = s;
+    }
+    if (s->class == CONST || s->class == VAR || s->class == FVAR) {
+       return s->type;
+    } else {
+       return s;
+    }
 }
 
 /*
 }
 
 /*
@@ -247,19 +247,19 @@ NODE **tp;
 SYM *typeto;
 OP op;
 {
 SYM *typeto;
 OP op;
 {
-#define tree   (*tp)
-
-       SYM *s;
-
-       s = rtype(tree->nodetype);
-       typeto = rtype(typeto);
-       if (typeto == t_real && compatible(s, t_int)) {
-               tree = build(op, tree);
-       } else if (!compatible(s, typeto)) {
-               trerror("%t is improper type");
-       } else if (op != O_NOP && s != typeto) {
-               tree = build(op, tree);
-       }
+#define tree    (*tp)
+
+    SYM *s;
+
+    s = rtype(tree->nodetype);
+    typeto = rtype(typeto);
+    if (typeto == t_real && compatible(s, t_int)) {
+       tree = build(op, tree);
+    } else if (!compatible(s, typeto)) {
+       trerror("%t is improper type");
+    } else if (op != O_NOP && s != typeto) {
+       tree = build(op, tree);
+    }
 
 #undef tree
 }
 
 #undef tree
 }
@@ -277,32 +277,32 @@ NODE *dot(record, field)
 NODE *record;
 SYM *field;
 {
 NODE *record;
 SYM *field;
 {
-       register NODE *p;
-       register SYM *s;
-
-       if (isblock(record->nodetype)) {
-               s = findsym(field, record->nodetype);
-               if (s == NIL) {
-                       error("\"%s\" is not defined in \"%s\"",
-                               field->symbol, record->nodetype->symbol);
-               }
-               p = alloc(1, NODE);
-               p->op = O_NAME;
-               p->nodetype = namenode(p, s);
-       } else {
-               s = findclass(field, FIELD);
-               if (s == NIL) {
-                       error("\"%s\" is not a field", field->symbol);
-               }
-               field = s;
-               chkfield(record, field);
-               p = alloc(1, NODE);
-               p->op = O_ADD;
-               p->nodetype = field->type;
-               p->left = record;
-               p->right = build(O_LCON, (long) field->symvalue.offset);
+    register NODE *p;
+    register SYM *s;
+
+    if (isblock(record->nodetype)) {
+       s = findsym(field, record->nodetype);
+       if (s == NIL) {
+           error("\"%s\" is not defined in \"%s\"",
+               field->symbol, record->nodetype->symbol);
+       }
+       p = alloc(1, NODE);
+       p->op = O_NAME;
+       p->nodetype = namenode(p, s);
+    } else {
+       s = findclass(field, FIELD);
+       if (s == NIL) {
+           error("\"%s\" is not a field", field->symbol);
        }
        }
-       return p;
+       field = s;
+       chkfield(record, field);
+       p = alloc(1, NODE);
+       p->op = O_ADD;
+       p->nodetype = field->type;
+       p->left = record;
+       p->right = build(O_LCON, (long) field->symvalue.offset);
+    }
+    return p;
 }
 
 /*
 }
 
 /*
@@ -313,55 +313,55 @@ SYM *field;
 NODE *subscript(a, slist)
 NODE *a, *slist;
 {
 NODE *subscript(a, slist)
 NODE *a, *slist;
 {
-       register SYM *t;
-       register NODE *p;
-       SYM *etype, *atype, *eltype;
-       NODE *esub, *olda;
-
-       olda = a;
-       t = rtype(a->nodetype);
-       if (t->class != ARRAY) {
-               trerror("%t is not an array");
+    register SYM *t;
+    register NODE *p;
+    SYM *etype, *atype, *eltype;
+    NODE *esub, *olda;
+
+    olda = a;
+    t = rtype(a->nodetype);
+    if (t->class != ARRAY) {
+       trerror("%t is not an array");
+    }
+    eltype = t->type;
+    p = slist;
+    t = t->chain;
+    for (; p != NIL && t != NIL; p = p->right, t = t->chain) {
+       esub = p->left;
+       etype = rtype(esub->nodetype);
+       atype = rtype(t);
+       if (!compatible(atype, etype)) {
+           trerror("subscript %t is the wrong type", esub);
        }
        }
-       eltype = t->type;
-       p = slist;
-       t = t->chain;
-       for (; p != NIL && t != NIL; p = p->right, t = t->chain) {
-               esub = p->left;
-               etype = rtype(esub->nodetype);
-               atype = rtype(t);
-               if (!compatible(atype, etype)) {
-                       trerror("subscript %t is the wrong type", esub);
-               }
-               a = build(O_INDEX, a, esub);
-               a->nodetype = eltype;
-       }
-       if (p != NIL) {
-               trerror("too many subscripts for %t", olda);
-       } else if (t != NIL) {
-               trerror("not enough subscripts for %t", olda);
-       }
-       return(a);
+       a = build(O_INDEX, a, esub);
+       a->nodetype = eltype;
+    }
+    if (p != NIL) {
+       trerror("too many subscripts for %t", olda);
+    } else if (t != NIL) {
+       trerror("not enough subscripts for %t", olda);
+    }
+    return(a);
 }
 
 /*
  * Evaluate a subscript index.
  */
 
 }
 
 /*
  * Evaluate a subscript index.
  */
 
-evalindex(s)
-SYM *s;
+evalindex(arraytype, index)
+SYM *arraytype;
+long index;
 {
 {
-       long i;
-       long lb, ub;
-
-       s = rtype(s)->chain;
-       i = pop(long);
-       lb = s->symvalue.rangev.lower;
-       ub = s->symvalue.rangev.upper;
-       if (i < lb || i > ub) {
-               error("subscript out of range");
-       }
-       return(i - lb);
+    long lb, ub;
+    SYM *indextype;
+
+    indextype = arraytype->chain;
+    lb = indextype->symvalue.rangev.lower;
+    ub = indextype->symvalue.rangev.upper;
+    if (index < lb || index > ub) {
+       error("subscript out of range");
+    }
+    return(index - lb);
 }
 
 /*
 }
 
 /*
@@ -372,23 +372,23 @@ LOCAL chkfield(r, f)
 NODE *r;
 SYM *f;
 {
 NODE *r;
 SYM *f;
 {
-       register SYM *s;
-
-       chkclass(r, RECORD);
-
-       /*
-        * Don't do this for compiled code.
-        */
-#      if (!isvax)
-               for (s = r->nodetype->chain; s != NIL; s = s->chain) {
-                       if (s == f) {
-                               break;
-                       }
-               }
-               if (s == NIL) {
-                       error("\"%s\" is not a field in specified record", f->symbol);
-               }
-#      endif
+    register SYM *s;
+
+    chkclass(r, RECORD);
+
+    /*
+     * Don't do this for compiled code.
+     */
+#   if (!isvax)
+       for (s = r->nodetype->chain; s != NIL; s = s->chain) {
+           if (s == f) {
+               break;
+           }
+       }
+       if (s == NIL) {
+           error("\"%s\" is not a field in specified record", f->symbol);
+       }
+#   endif
 }
 
 /*
 }
 
 /*
@@ -398,9 +398,9 @@ SYM *f;
 chkboolean(p)
 register NODE *p;
 {
 chkboolean(p)
 register NODE *p;
 {
-       if (p->nodetype != t_boolean) {
-               trerror("found %t, expected boolean expression");
-       }
+    if (p->nodetype != t_boolean) {
+       trerror("found %t, expected boolean expression");
+    }
 }
 
 /*
 }
 
 /*
@@ -411,12 +411,12 @@ LOCAL chkclass(p, class)
 NODE *p;
 int class;
 {
 NODE *p;
 int class;
 {
-       SYM tmpsym;
+    SYM tmpsym;
 
 
-       tmpsym.class = class;
-       if (p->nodetype->class != class) {
-               trerror("%t is not a %s", p, classname(&tmpsym));
-       }
+    tmpsym.class = class;
+    if (p->nodetype->class != class) {
+       trerror("%t is not a %s", p, classname(&tmpsym));
+    }
 }
 
 /*
 }
 
 /*
@@ -427,35 +427,35 @@ int class;
 LOCAL SYM *mkstring(str)
 char *str;
 {
 LOCAL SYM *mkstring(str)
 char *str;
 {
-       register char *p, *q;
-       SYM *s, *t;
-       static SYM zerosym;
-
-       p = str;
-       q = str + 1;
-       while (*q != '\0') {
-               if (q[0] != '\'' || q[1] != '\'') {
-                       *p = *q;
-                       p++;
-               }
-               q++;
+    register char *p, *q;
+    SYM *s, *t;
+    static SYM zerosym;
+
+    p = str;
+    q = str + 1;
+    while (*q != '\0') {
+       if (q[0] != '\'' || q[1] != '\'') {
+           *p = *q;
+           p++;
        }
        }
-       *--p = '\0';
-       if (p == str + 1) {
-               return t_char;
-       }
-       s = alloc(1, SYM);
-       *s = zerosym;
-       s->class = ARRAY;
-       s->type = t_char;
-       s->chain = alloc(1, SYM);
-       t = s->chain;
-       *t = zerosym;
-       t->class = RANGE;
-       t->type = t_int;
-       t->symvalue.rangev.lower = 1;
-       t->symvalue.rangev.upper = p - str + 1;
-       return s;
+       q++;
+    }
+    *--p = '\0';
+    if (p == str + 1) {
+       return t_char;
+    }
+    s = alloc(1, SYM);
+    *s = zerosym;
+    s->class = ARRAY;
+    s->type = t_char;
+    s->chain = alloc(1, SYM);
+    t = s->chain;
+    *t = zerosym;
+    t->class = RANGE;
+    t->type = t_int;
+    t->symvalue.rangev.lower = 1;
+    t->symvalue.rangev.upper = p - str + 1;
+    return s;
 }
 
 /*
 }
 
 /*
@@ -465,5 +465,5 @@ char *str;
 unmkstring(s)
 SYM *s;
 {
 unmkstring(s)
 SYM *s;
 {
-       dispose(s->chain);
+    dispose(s->chain);
 }
 }