diff --git a/Bin/spin652_windows64.exe.gz b/Bin/spin652_windows64.exe.gz new file mode 100644 index 0000000..2bebba8 Binary files /dev/null and b/Bin/spin652_windows64.exe.gz differ diff --git a/Doc/V6.Updates b/Doc/V6.Updates index ce2d11e..645bd89 100644 --- a/Doc/V6.Updates +++ b/Doc/V6.Updates @@ -950,3 +950,5 @@ Smaller changes: assert(B[1]); } the explicit removal of the initialization value is now removed. +- february 2024: minor update, full(q) now returns false for a + rendez-vous channel (it used to return true) diff --git a/Src/flow.c b/Src/flow.c index 0f95d22..4842b7c 100644 --- a/Src/flow.c +++ b/Src/flow.c @@ -442,6 +442,7 @@ if_seq(Lextok *n) e->sub = s; for (z = s; z; z = z->nxt) add_el(t, z->this); /* append target */ + if (tok == DO) { add_el(t, cur_s->this); /* target upfront */ t = new_el(nn(n, BREAK, ZN, ZN)); /* break target */ @@ -861,6 +862,7 @@ make_atomic(Sequence *s, int added) #if 0 static int depth = 0; void dump_sym(Symbol *, char *); +void explain(int); void dump_lex(Lextok *t, char *s) @@ -871,7 +873,7 @@ dump_lex(Lextok *t, char *s) for (i = 0; i < depth; i++) printf("\t"); explain(t->ntyp); - if (t->ntyp == NAME) printf(" %s ", t->sym->name); + if (t->ntyp == NAME || t->ntyp == TYPE) printf(" '%s' ", t->sym->name); if (t->ntyp == CONST) printf(" %d ", t->val); if (is_typedef(t->ntyp)) { dump_sym(t->sym, "\n:Z:"); @@ -887,7 +889,7 @@ dump_lex(Lextok *t, char *s) void dump_sym(Symbol *z, char *s) { int i; - char txt[64]; +// char txt[64]; depth++; printf(s); for (i = 0; i < depth; i++) @@ -899,11 +901,11 @@ dump_sym(Symbol *z, char *s) if (z->ini->rgt->rgt || !z->ini->rgt->sym) fatal("chan %s in for should have only one field (a typedef)", z->name); - printf(" -- %s %p -- ", z->ini->rgt->sym->name, z->ini->rgt->sym); + printf(" -- %s %p -- ", z->ini->rgt->sym->name, (void *) z->ini->rgt->sym); } } else if (is_typedef(z->type)) { if (z->Snm) - printf(" == %s %p == ", z->Snm->name, z->Snm); + printf(" == %s %p == ", z->Snm->name, (void *) z->Snm); else { if (z->Slst) dump_lex(z->Slst, "\n:X:"); @@ -1037,7 +1039,9 @@ for_index(Lextok *a3, Lextok *a5) leaf = leaf->lft; // printf("%s %d\n", leaf->sym->name, leaf->sym->isarray); } - + if (!leaf) + { fatal("unexpected type of for-loop", (char *) 0); + } if (leaf->sym->isarray == 0 || leaf->sym->nel <= 0) { fatal("bad arrayname %s", leaf->sym->name); diff --git a/Src/main.c b/Src/main.c index 4fe68cb..ae8fa1c 100644 --- a/Src/main.c +++ b/Src/main.c @@ -103,7 +103,7 @@ void explain(int); can later be truncated at that point */ #if 1 - #define CPP "gcc -std=gnu99 -Wformat-overflow=0 -E -x c" + #define CPP "gcc -std=gnu99 -Wno-unknown-warning-option -Wformat-overflow=0 -E -x c" /* if gcc-4 is available, this setting is modified below */ #else #if defined(PC) || defined(MAC) @@ -587,9 +587,9 @@ preprocess(char *a, char *b, int a_tmp) */ if (strncmp(PreProc, "gcc ", strlen("gcc ")) == 0) { if (e_system(0, "gcc-4 --version > pan.pre 2>&1") == 0) - { strcpy(PreProc, "gcc-4 -std=gnu99 -Wformat-overflow=0 -E -x c"); + { strcpy(PreProc, "gcc-4 -std=gnu99 -Wno-unknown-warning-option -Wformat-overflow=0 -E -x c"); } else if (e_system(0, "gcc-3 --version > pan.pre 2>&1") == 0) - { strcpy(PreProc, "gcc-3 -std=gnu99 -Wformat-overflow=0 -E -x c"); + { strcpy(PreProc, "gcc-3 -std=gnu99 -Wno-unknown-warning-option -Wformat-overflow=0 -E -x c"); } } #endif @@ -1076,7 +1076,7 @@ samecase: if (buzzed != 0) strcpy(out1, "pan.pre"); if (add_ltl || nvr_file) - { assert(strlen(argv[1]) < sizeof(out2)); + { assert(strlen(argv[1])+6 < sizeof(out2)); sprintf(out2, "%s.nvr", argv[1]); if ((fd = fopen(out2, MFLAGS)) == NULL) { printf("spin: cannot create tmp file %s\n", diff --git a/Src/mesg.c b/Src/mesg.c index 97a53ef..10b69fa 100644 --- a/Src/mesg.c +++ b/Src/mesg.c @@ -109,8 +109,12 @@ int qfull(Lextok *n) { int whichq = eval(n->lft)-1; - if (whichq < MAXQ && whichq >= 0 && ltab[whichq]) - return (ltab[whichq]->qlen >= ltab[whichq]->nslots); + if (whichq < MAXQ + && whichq >= 0 // valid qid + && ltab[whichq] // q exists + && ltab[whichq]->nslots > 0) // !q_is_sync added 02/24 + { return (ltab[whichq]->qlen >= ltab[whichq]->nslots); + } return 0; } @@ -325,13 +329,15 @@ a_snd(Queue *q, Lextok *n) { Value New = evalValue(m->lft); q->contents[i+j] = cast_val(q->fld_width[j], New, 0); - if (q->fld_width[i+j] == MTYPE) - { mtype_ck(q->mtp[i+j], m->lft); /* 6.4.8 */ + if (q->fld_width[j] == MTYPE) /* may 30, 2023: i+j -> j */ + { mtype_ck(q->mtp[j], m->lft); /* 6.4.8 - may 30: same change */ } if ((verbose&16) && depth >= jumpsteps) { sr_talk(n, New, "Send ", "->", j, q); /* XXX j was i+j in 6.4.8 */ } - typ_ck(q->fld_width[i+j], Sym_typ(m->lft), "send"); + + /* may 30, 2023: the field types are 0..nflds, not i+0..nflds */ + typ_ck(q->fld_width[j], Sym_typ(m->lft), "send"); } if ((verbose&16) && depth >= jumpsteps) @@ -363,8 +369,8 @@ a_rcv(Queue *q, Lextok *n, int full) /* test executability */ for (m = n->rgt, j=0; m && j < q->nflds; m = m->rgt, j++) { - if (q->fld_width[i*q->nflds+j] == MTYPE) - { mtype_ck(q->mtp[i*q->nflds+j], m->lft); /* 6.4.8 */ + if (q->fld_width[j] == MTYPE) /* may 30, 2023: i*q->nflds+j -> j */ + { mtype_ck(q->mtp[j], m->lft); /* 6.4.8 -- may 30, same change */ } if (m->lft->ntyp == CONST @@ -920,7 +926,7 @@ typedef struct BaseName { static BaseName *bsn; -void +static void newbasename(char *s) { BaseName *b; @@ -938,7 +944,7 @@ newbasename(char *s) bsn = b; } -void +static void delbasename(char *s) { BaseName *b, *prv = (BaseName *) 0; @@ -956,7 +962,7 @@ delbasename(char *s) } } } -void +static void checkindex(char *s, char *t) { BaseName *b; @@ -970,7 +976,7 @@ checkindex(char *s, char *t) } } } -void +static void scan_tree(Lextok *t, char *mn, char *mx) { char sv[512]; char tmp[32]; @@ -981,14 +987,17 @@ scan_tree(Lextok *t, char *mn, char *mx) lineno = t->ln; if (t->ntyp == NAME) - { if (strlen(t->sym->name) + strlen(mn) > 256) // conservative + { if (strlen(t->sym->name) + strlen(mn) > 512) { fatal("name too long", t->sym->name); } strcat(mn, t->sym->name); - strcat(mx, t->sym->name); + if (t->lft) /* array index */ - { strcat(mn, "[]"); + { if(strlen(t->sym->name) + strlen("[]") > 512) + { fatal("name too long", t->sym->name); + } + strcat(mn, "[]"); newbasename(mn); strcpy(sv, mn); /* save */ strcpy(mn, ""); /* clear */ @@ -1017,7 +1026,7 @@ scan_tree(Lextok *t, char *mn, char *mx) lineno = oln; } -void +static void no_nested_array_refs(Lextok *n) /* a [ a[1] ] with a[1] = 1, causes trouble in pan.b */ { char mn[512]; char mx[512]; diff --git a/Src/pangen1.c b/Src/pangen1.c index d6efa11..ce78855 100644 --- a/Src/pangen1.c +++ b/Src/pangen1.c @@ -741,7 +741,7 @@ c_var(FILE *fd, char *pref, Symbol *sp) buf, ptr, pref, sp->name); } } else - { fprintf(fd, "\t{\tint l_in;\n"); + { fprintf(fd, "\t{\tint l_in; /* 1 */\n"); fprintf(fd, "\t\tfor (l_in = 0; l_in < %d; l_in++)\n", sp->nel); fprintf(fd, "\t\t{\n"); fprintf(fd, "\t\t\tprintf(\"\t%s %s[%%d]:\t%%d\\n\", l_in, %s%s[l_in]);\n", @@ -927,7 +927,6 @@ do_var(FILE *ofd, int dowhat, char *s, Symbol *sp, switch(dowhat) { case PUTV: if (sp->hidden&1) break; - typ2c(sp); break; @@ -985,7 +984,7 @@ do_var(FILE *ofd, int dowhat, char *s, Symbol *sp, fprintf(ofd, "%s", ter); } } else - { fprintf(ofd, "\t{\tint l_in;\n"); + { fprintf(ofd, "\t{\tint l_in; /* 2 */\n"); fprintf(ofd, "\t\tfor (l_in = 0; l_in < %d; l_in++)\n", sp->nel); fprintf(ofd, "\t\t{\n"); diff --git a/Src/run.c b/Src/run.c index afb2aac..474c26b 100644 --- a/Src/run.c +++ b/Src/run.c @@ -28,6 +28,8 @@ static int pc_enabled(Lextok *n); static int get_priority(Lextok *n); static void set_priority(Lextok *n, Lextok *m); extern void sr_buf(int, int, const char *); +extern char *which_mtype(const char *); +extern char *which_mtype_val(const int); void Srand(unsigned int s) @@ -638,62 +640,62 @@ interprint(FILE *fd, Lextok *n) GBuf[0] = '\0'; if (!no_print) - if (!s_trail || depth >= jumpsteps) { - for (i = 0; i < (int) strlen(s); i++) - switch (s[i]) { - case '\"': break; /* ignore */ - case '\\': - switch(s[++i]) { - case 't': strcat(GBuf, "\t"); break; - case 'n': strcat(GBuf, "\n"); break; - default: goto onechar; - } - break; - case '%': - if ((c = s[++i]) == '%') - { strcat(GBuf, "%"); /* literal */ - break; - } - if (!tmp) - { non_fatal("too few print args %s", s); - break; - } - j = evalValue(tmp->lft); - - if (c == 'e' - && tmp->lft - && tmp->lft->sym - && tmp->lft->sym->mtype_name) - { t = tmp->lft->sym->mtype_name->name; - } - - tmp = tmp->rgt; - switch(c) { - case 'c': sprintf(lbuf, "%c", getInt(j)); break; - case 'd': sprintf(lbuf, "%d", getInt(j)); break; - - case 'e': strcpy(tBuf, GBuf); /* event name */ - GBuf[0] = '\0'; - - sr_buf(getInt(j), 1, t); // TODO PG - hanlde float in j value - - strcpy(lbuf, GBuf); - strcpy(GBuf, tBuf); - break; - - case 'o': sprintf(lbuf, "%o", getInt(j)); break; - case 'u': sprintf(lbuf, "%u", (unsigned) getInt(j)); break; - case 'x': sprintf(lbuf, "%x", getInt(j)); break; - case 'f': sprintf(lbuf, "%f", getFloat(j)); break; - default: non_fatal("bad print cmd: '%s'", &s[i-1]); - lbuf[0] = '\0'; break; - } - goto append; - default: -onechar: lbuf[0] = s[i]; lbuf[1] = '\0'; -append: strcat(GBuf, lbuf); - break; - } + if (!s_trail || depth >= jumpsteps) + { for (i = 0; i < (int) strlen(s); i++) + { switch (s[i]) { + case '\"': break; /* ignore */ + case '\\': + switch(s[++i]) { + case 't': strcat(GBuf, "\t"); break; + case 'n': strcat(GBuf, "\n"); break; + default: goto onechar; + } + break; + case '%': + if ((c = s[++i]) == '%') + { strcat(GBuf, "%"); /* literal */ + break; + } + if (!tmp) + { non_fatal("too few print args %s", s); + break; + } + j = evalValue(tmp->lft); + if (c == 'e' + && tmp->lft) + { if (tmp->lft->sym) + { if (tmp->lft->sym->mtype_name) + { t = tmp->lft->sym->mtype_name->name; + } + } else if (tmp->lft->ntyp == CONST) + { t = which_mtype_val(tmp->lft->val); + } } + + tmp = tmp->rgt; + switch(c) { + case 'c': sprintf(lbuf, "%c", getInt(j)); break; + case 'd': sprintf(lbuf, "%d", getInt(j)); break; + + case 'e': strcpy(tBuf, GBuf); /* event name */ + GBuf[0] = '\0'; + sr_buf(getInt(j), 1, t); // TODO PG - hanlde float in j value + strcpy(lbuf, GBuf); + strcpy(GBuf, tBuf); + break; + + case 'o': sprintf(lbuf, "%o", getInt(j)); break; + case 'u': sprintf(lbuf, "%u", (unsigned) getInt(j)); break; + case 'x': sprintf(lbuf, "%x", getInt(j)); break; + case 'f': sprintf(lbuf, "%f", getFloat(j)); break; + default: non_fatal("bad print cmd: '%s'", &s[i-1]); + lbuf[0] = '\0'; break; + } + goto append; + default: +onechar: lbuf[0] = s[i]; lbuf[1] = '\0'; +append: strcat(GBuf, lbuf); + break; + } } dotag(fd, GBuf); } if (strlen(GBuf) >= 4096) fatal("printf string too long", 0); diff --git a/Src/sched.c b/Src/sched.c index 3f28b59..3855b4d 100644 --- a/Src/sched.c +++ b/Src/sched.c @@ -856,7 +856,6 @@ addsymbol(RunList *r, Symbol *s) && (old_scope_rules || strcmp((const char *)t->bscp, (const char *)s->bscp) == 0)) return; /* it's already there */ - t = (Symbol *) emalloc(sizeof(Symbol)); t->name = s->name; t->type = s->type; diff --git a/Src/spin.y b/Src/spin.y index 5cab910..f95d362 100644 --- a/Src/spin.y +++ b/Src/spin.y @@ -14,6 +14,7 @@ #include #endif #include +#include #define YYMAXDEPTH 20000 /* default is 10000 */ #define YYDEBUG 0 diff --git a/Src/spinlex.c b/Src/spinlex.c index 5179bb1..06a9096 100644 --- a/Src/spinlex.c +++ b/Src/spinlex.c @@ -13,7 +13,7 @@ #include "spin.h" #include "y.tab.h" -#define MAXINL 16 /* max recursion depth inline fcts */ +#define MAXINL 32 /* max recursion depth inline fcts */ #define MAXPAR 32 /* max params to an inline call */ #define MAXLEN 512 /* max len of an actual parameter text */ #define MAX_TOKEN_TEXT_LENGTH 2048 /* max len of an actual token text */ @@ -746,7 +746,8 @@ c_add_loc(FILE *fd, char *s) /* state vector entries for proctype s */ for (r = c_added; r; r = r->nxt) /* pickup local decls */ { if (strncmp(r->t->name, " Local", strlen(" Local")) == 0) { p = r->t->name + strlen(" Local"); -fprintf(fd, "/* XXX p=<%s>, s=<%s>, buf=<%s> r->s->name=<%s>XXX */\n", p, s, buf, r->s->name); + fprintf(fd, "/* XXX p=<%s>, s=<%s>, buf=<%s> r->s->name=<%s>XXX */\n", + p, s, buf, r->s->name); while (*p == ' ' || *p == '\t') { p++; } diff --git a/Src/structs.c b/Src/structs.c index e4b3c71..c1f0194 100644 --- a/Src/structs.c +++ b/Src/structs.c @@ -450,7 +450,7 @@ struct_name(Lextok *n, Symbol *v, int xinit, char *buf) void walk2_struct(char *s, Symbol *z) { Lextok *fp, *tl; - char eprefix[128]; + char eprefix[512]; int ix; memset(eprefix, 0, sizeof(eprefix)); @@ -472,7 +472,7 @@ walk2_struct(char *s, Symbol *z) void walk_struct(FILE *ofd, int dowhat, char *s, Symbol *z, char *a, char *b, char *c) { Lextok *fp, *tl; - char eprefix[128]; + char eprefix[512]; int ix; memset(eprefix, 0, sizeof(eprefix)); @@ -494,7 +494,7 @@ walk_struct(FILE *ofd, int dowhat, char *s, Symbol *z, char *a, char *b, char *c void c_struct(FILE *fd, char *ipref, Symbol *z) { Lextok *fp, *tl; - char pref[256], eprefix[300]; + char pref[512], eprefix[300]; int ix; ini_struct(z); @@ -521,7 +521,7 @@ c_struct(FILE *fd, char *ipref, Symbol *z) void dump_struct(Symbol *z, char *prefix, RunList *r) { Lextok *fp, *tl; - char eprefix[256]; + char eprefix[512]; int ix, jx; ini_struct(z); diff --git a/Src/sym.c b/Src/sym.c index 3a85ccd..d256902 100644 --- a/Src/sym.c +++ b/Src/sym.c @@ -120,7 +120,6 @@ lookup(char *s) && samename(sp->owner, owner)) { return sp; /* global */ } } - sp = (Symbol *) emalloc(sizeof(Symbol)); sp->name = (char *) emalloc(strlen(s) + 1); strcpy(sp->name, s); @@ -405,7 +404,6 @@ find_mtype_list(const char *s) { if (strcmp(lst->nm, s) == 0) { return &(lst->mt); } } - /* not found, create it */ lst = (Mtypes_t *) emalloc(sizeof(Mtypes_t)); lst->nm = (char *) emalloc(strlen(s)+1); @@ -445,7 +443,6 @@ setmtype(Lextok *mtype_name, Lextok *m) || n->lft->ntyp != NAME || n->lft->lft) /* indexed variable */ fatal("bad mtype definition", (char *)0); - /* label the name */ if (n->lft->sym->type != MTYPE) { n->lft->sym->hidden |= 128; /* is used */ @@ -478,6 +475,19 @@ which_mtype(const char *str) /* which mtype is str, 0 if not an mtype at all */ return (char *) 0; } +char * +which_mtype_val(const int v) /* which mtype is v, 0 if not an mtype at all */ +{ Mtypes_t *lst; + Lextok *n; + + for (lst = Mtypes; lst; lst = lst->nxt) + for (n = lst->mt; n; n = n->rgt) + { if (v == n->lft->sym->ini->val) + { return lst->nm; + } } + return (char *) 0; +} + int ismtype(char *str) /* name to number */ { Mtypes_t *lst; diff --git a/Src/vars.c b/Src/vars.c index 4925689..27524dd 100644 --- a/Src/vars.c +++ b/Src/vars.c @@ -93,7 +93,8 @@ setval(Lextok *v, Value n) if (v->sym->context && v->sym->type) return setlocal(v, n); if (!v->sym->type) - v->sym = lookup(v->sym->name); + { v->sym = lookup(v->sym->name); + } return setglobal(v, n); } diff --git a/Src/version.h b/Src/version.h index 6d431c0..199f160 100644 --- a/Src/version.h +++ b/Src/version.h @@ -6,4 +6,4 @@ * Tool documentation is available at http://spinroot.com */ -#define SpinVersion "Spin Version 6.5.2 -- 9 June 2022 + N7S Custom - Work-in-Progress" \ No newline at end of file +#define SpinVersion "Spin Version 6.5.2 -- 21 June 2024 + N7S Custom"