made to work; contained too many dependencies on word/pointer size
authorceriel <none@none>
Mon, 18 Jul 1988 16:41:04 +0000 (16:41 +0000)
committerceriel <none@none>
Mon, 18 Jul 1988 16:41:04 +0000 (16:41 +0000)
lang/occam/comp/builtin.c
lang/occam/comp/em.c
lang/occam/comp/expr.c
lang/occam/comp/keytab.c
lang/occam/comp/lex.l
lang/occam/comp/occam.g
lang/occam/comp/report.c
lang/occam/comp/symtab.c

index d3f7b99..bc47bcb 100644 (file)
@@ -43,11 +43,11 @@ void init_builtins()
        insert("input", T_CHAN|T_BUILTIN, 1, &info);
 
        info.vc.st.builtin=file;
-       info.vc.offset=wz+pz;
+       info.vc.offset=wz+vz;
        insert("output", T_CHAN|T_BUILTIN, 1, &info);
 
        info.vc.st.builtin=file;
-       info.vc.offset=2*(wz+pz);
+       info.vc.offset=2*(wz+vz);
        insert("error", T_CHAN|T_BUILTIN, 1, &info);
 
        /* DEF EOF= -1, TEXT= -2, RAW= -3: */
index c6bdb03..8bb635b 100644 (file)
@@ -18,7 +18,7 @@
 int wz = 4, pz = 4, vz = 4;
 int Lflag;
 static Lab=0;
-char *malloc();
+char *Malloc();
 
 void init()
 {
@@ -40,7 +40,7 @@ void meswp()
 void maxdes()
 {
        C_df_dnam("maxcdes");
-       rom(wz, 0L); rom(wz, -1L); rom(wz, (long) (wz+pz));
+       rom(wz, 0L); rom(wz, -1L); rom(wz, (long) (wz+vz));
        C_df_dnam("maxwdes");
        rom(wz, 0L); rom(wz, -1L); rom(wz, (long) vz);
        C_df_dnam("maxbdes");
@@ -82,7 +82,7 @@ char *proc_label(L, name) register L; register char *name;
 
        if (lab!=nil) free(lab);
 
-       lab=malloc(strlen(name)+(1+sizeof(int)*3+1));
+       lab=Malloc(strlen(name)+(1+sizeof(int)*3+1));
                /* That is: P<L><name>\0 */
 
        sprint(lab, "P%d", L);
@@ -412,8 +412,8 @@ int set_file(f) char *f;
                apf= cmp<0 ? &pf->left : &pf->right;
 
        if (pf==nil) {
-               *apf= pf= (struct ftree *) malloc(sizeof *pf);
-               pf->file=strcpy(malloc(strlen(f)+1), f);
+               *apf= pf= (struct ftree *) Malloc(sizeof *pf);
+               pf->file=strcpy(Malloc(strlen(f)+1), f);
                pf->lab=0;
                pf->left=pf->right=nil;
        }
@@ -438,7 +438,7 @@ void par_fork(NONZERO) int *NONZERO;
 {
        C_zer((arith) pz);
        C_cal("pc_fork");
-       C_asp(pz);
+       C_asp((arith) pz);
        C_lfr((arith) wz);
        C_zne((label) new_label(NONZERO));
 }
index b022f45..057469d 100644 (file)
@@ -10,6 +10,7 @@
 
 static void rvalue(), assignable(), inputable(), outputable(), subscriptable();
 static void assigned();
+char *Malloc();
 
 /* The new_* functions make use of the used() and assinged() functions to
  * make known what is done to a variable.
@@ -89,7 +90,7 @@ struct expr *new_node(op, left, right, byte)
                        subscriptable(left, right, byte, &type, &arr_siz);
                        break;
                }
-               pe= (struct expr *) malloc(sizeof *pe);
+               pe= (struct expr *) Malloc(sizeof *pe);
 
                pe->kind=E_NODE;
                pe->type=type;
@@ -110,7 +111,7 @@ struct expr *new_var(var)
 {
        register struct expr *pe;
 
-       pe= (struct expr *) malloc(sizeof *pe);
+       pe= (struct expr *) Malloc(sizeof *pe);
 
        pe->kind=E_VAR;
 
@@ -133,7 +134,7 @@ struct expr *new_const(const)
 {
        register struct expr *pe;
 
-       pe= (struct expr *) malloc(sizeof *pe);
+       pe= (struct expr *) Malloc(sizeof *pe);
 
        pe->kind=E_CONST;
        pe->type=T_VALUE;
@@ -152,7 +153,7 @@ struct expr *new_table(kind, tab)
 {
        register struct expr *pe;
 
-       pe= (struct expr *) malloc(sizeof *pe);
+       pe= (struct expr *) Malloc(sizeof *pe);
 
        pe->kind=kind;
        pe->type=T_VALUE|T_ARR;
@@ -167,7 +168,7 @@ struct expr *new_table(kind, tab)
 
                tab=tab->next;
                pe->arr_siz++;
-               free(junk);
+               free((char *)junk);
        }
 
        return pe;
@@ -180,7 +181,7 @@ struct expr *copy_const(e) struct expr *e;
 {
        register struct expr *c;
 
-       c= (struct expr *) malloc(sizeof *c);
+       c= (struct expr *) Malloc(sizeof *c);
 
        *c= *e;
        return c;
@@ -191,7 +192,7 @@ struct expr *new_now()
 {
        register struct expr *pe;
 
-       pe= (struct expr *) malloc(sizeof *pe);
+       pe= (struct expr *) Malloc(sizeof *pe);
 
        pe->kind=E_NOW;
        pe->type=T_VALUE;
@@ -213,7 +214,7 @@ struct expr *new_io(out, chan, args)
                report("channel variable expected");
        used(chan);
 
-       pe= (struct expr *) malloc(sizeof *pe);
+       pe= (struct expr *) Malloc(sizeof *pe);
 
        pe->kind=E_IO;
        pe->type=T_VOID;
@@ -234,7 +235,7 @@ struct expr *new_call(proc, args)
 {
        register struct expr *pe;
 
-       pe= (struct expr *) malloc(sizeof *pe);
+       pe= (struct expr *) Malloc(sizeof *pe);
 
        used(proc);
 
@@ -253,7 +254,7 @@ void table_add(aapt, val) register struct table ***aapt; long val;
 {
        register struct table *pt;
 
-       pt= (struct table *) malloc(sizeof *pt);
+       pt= (struct table *) Malloc(sizeof *pt);
 
        pt->val=val;
        pt->next= **aapt;
@@ -269,7 +270,7 @@ void expr_list_add(aaelp, arg)
 {
        register struct expr_list *elp;
 
-       elp= (struct expr_list *) malloc(sizeof *elp);
+       elp= (struct expr_list *) Malloc(sizeof *elp);
 
        elp->arg=arg;
        elp->next= **aaelp;
@@ -466,11 +467,11 @@ void destroy(e) register struct expr *e;
                                        destroy(elp->arg);
                                        junk=elp;
                                        elp=elp->next;
-                                       free(junk);
+                                       free((char *)junk);
                                }
                        }
                        break;
                }
-               free(e);
+               free((char *)e);
        }
 }
index 0822ff8..01cd409 100644 (file)
@@ -63,9 +63,10 @@ char *lowerupper(str) register char *str;
        register char *key=keyword;
 
        if (islower(*str)) {
-               do
-                       *key++ = toupper(*str++);
-               while (key<keyword+MAXKEYLEN && islower(*str));
+               do {
+                       *key++ = toupper(*str);
+                       str++;
+               } while (key<keyword+MAXKEYLEN && islower(*str));
        } else {
                do
                        *key++ = *str++;
index 5aad446..fdc19e8 100644 (file)
@@ -15,7 +15,7 @@
 # define TABSTOP(ind)  (((ind)+TAB)&(~(TAB-1)))
 # endif
 
-char *malloc(), *strcpy();
+char *Malloc(), *strcpy();
 
 struct token token;
 int ind=0;             /* Indentation level of current line */
@@ -72,7 +72,7 @@ int included=0;               /* Is current file included? */
        register key;
 
        if ((key=keyword(yytext))==IDENTIFIER)
-               token.t_sval=strcpy(malloc(yyleng+1), yytext);
+               token.t_sval=strcpy(Malloc(yyleng+1), yytext);
        
        return key;
 }
@@ -289,7 +289,7 @@ char *tokenname(tk, inst) register tk, inst;
                case IDENTIFIER:
                        if (inst) {
                                sprint(fake_id, "_%d", ++fake_cnt);
-                               token.t_sval=strcpy(malloc(strlen(fake_id)+1),
+                               token.t_sval=strcpy(Malloc(strlen(fake_id)+1),
                                        fake_id);
                                return "IDENTIFIER";
                        } else
@@ -300,7 +300,7 @@ char *tokenname(tk, inst) register tk, inst;
                        return "NUMBER";
                case STRING:
                        if (inst) {
-                               token.t_sval=malloc(1);
+                               token.t_sval=Malloc(1);
                                token.t_sval[0]=0;
                        } else
                                free(token.t_sval);
index e314d33..e78cc46 100644 (file)
@@ -17,6 +17,7 @@
 
 static void nonconst(), nonpositive(), rep_cleanup(), check_assoc();
 void init_builtins();
+char *strcpy();
 
 extern int yylineno, LLsymb;
 union type_info info, none;
@@ -282,7 +283,7 @@ subscript(register *byte; register struct expr **e; )
                                        } else
                                        if (e1->u.const<=0)
                                                nonpositive(siz);
-                                       *e=new_node(FOR, *e, e1);
+                                       *e=new_node(FOR, *e, e1, *byte);
                                        slice=1;
                                }
          ]?
@@ -499,7 +500,7 @@ item(register struct expr **e;)
                                {       if (!subs_call && var_proc(var)) {
                                                if (pars!=nil)
                                                        report("no actual parameters");
-                                               *e=new_call(*e, nil);
+                                               *e=new_call(*e, (char *)nil);
                                        }
                                }
        | vector_constant(e)
@@ -515,7 +516,7 @@ statement(register struct expr **e;)
                                }:
          item(e)
          [       AS expression(&e1)
-                               {       *e=new_node(AS, *e, e1); }
+                               {       *e=new_node(AS, *e, e1, 0); }
                | [
                          '?'   {       out=0; }
                        | '!'   {       out=1; }
@@ -608,10 +609,10 @@ expression(register struct expr **e;)
                                        op=LLsymb;
                                }
                  operator element(&e1)
-                               {       *e=new_node(op, *e, e1); }
+                               {       *e=new_node(op, *e, e1, 0); }
          ]*
        | monadic_op(&op) element(&e1)
-                               {       *e=new_node(op, e1, nil); }
+                               {       *e=new_node(op, e1, (char *)nil, 0); }
        ;
 
 val_expr(register struct expr **e;) :
@@ -747,4 +748,9 @@ static void check_assoc(prev_op, op) register prev_op, op;
                );
        }
 }
+
+No_Mem()
+{
+       fatal("out of memory");
+}
 }
index 35dca93..7cc8f9f 100644 (file)
@@ -8,6 +8,7 @@
 extern int err, yylineno;
 extern char *curr_file;
 
+/*VARARGS1*/
 report(fmt, arg1, arg2, arg3) char *fmt;
 {
        fprint(STDERR, "%s (%d) F: ", curr_file, yylineno);
@@ -16,6 +17,7 @@ report(fmt, arg1, arg2, arg3) char *fmt;
        err=1;
 }
 
+/*VARARGS1*/
 warning(fmt, arg1, arg2, arg3) char *fmt, *arg1;
 {
        fprint(STDERR, "%s (%d) E: ", curr_file, yylineno);
@@ -23,6 +25,7 @@ warning(fmt, arg1, arg2, arg3) char *fmt, *arg1;
        fprint(STDERR,"\n");
 }
 
+/*VARARGS1*/
 fatal(fmt, arg1, arg2, arg3) char *fmt, *arg1;
 {
        fprint(STDERR, "%s (%d) X: ", curr_file, yylineno);
index 43f0591..6e5d493 100644 (file)
@@ -13,7 +13,7 @@ int min_offset=0;     /* Minimum of all offsets within current level */
 
 static struct symtab *sym_table=nil;
 
-char *malloc();
+char *Malloc();
 
 static struct symbol **search_sym(tree, name)
        struct symbol **tree;
@@ -46,7 +46,7 @@ struct symbol *insert(name, type, arr_siz, info)
                return nil;
        }
 
-       ps= (struct symbol *) malloc(sizeof *ps);
+       ps= (struct symbol *) Malloc(sizeof *ps);
 
        ps->s_name=name;
 
@@ -89,7 +89,7 @@ void sym_down()
 {
        register struct symtab *ps;
 
-       ps= (struct symtab *) malloc(sizeof *ps);
+       ps= (struct symtab *) Malloc(sizeof *ps);
 
        ps->local=nil;
        ps->global=sym_table;
@@ -117,13 +117,13 @@ static void sym_destroy(ps) register struct symbol *ps;
                        while (par!=nil) {
                                junk=par;
                                par=par->pr_next;
-                               free(junk);
+                               free((char *)junk);
                        }
                } else
                if ((ps->s_type&T_TYPE)==T_CONST)
                        destroy(ps->s_info.t_const);
-               free(ps->s_name);
-               free(ps);
+               free((char *)(ps->s_name));
+               free((char *)ps);
        }
 }
 
@@ -172,7 +172,7 @@ void pars_add(aapars, type, var)
 {
        register struct par_list *pl;
 
-       pl= (struct par_list *) malloc(sizeof *pl);
+       pl= (struct par_list *) Malloc(sizeof *pl);
 
        pl->pr_type=type;
        pl->pr_var=var;
@@ -204,4 +204,5 @@ int form_offsets(pars) register struct par_list *pars;
                        return offset+ ((var->s_type&T_ARR) ? pz : vz);
                }
        }
+       return pz;
 }