Browse Source

Spin moved to legacy, APEX dependent

Signed-off-by: Álvaro Jurado <elbingmiss@gmail.com>
Álvaro Jurado 1 year ago
parent
commit
f2bd037f54
42 changed files with 0 additions and 38167 deletions
  1. 0 380
      sys/man/1/spin
  2. 0 11
      sys/src/cmd/spin/README
  3. 0 420
      sys/src/cmd/spin/dstep.c
  4. 0 1080
      sys/src/cmd/spin/flow.c
  5. 0 351
      sys/src/cmd/spin/guided.c
  6. 0 868
      sys/src/cmd/spin/main.c
  7. 0 794
      sys/src/cmd/spin/mesg.c
  8. 0 57
      sys/src/cmd/spin/mkfile
  9. 0 1538
      sys/src/cmd/spin/pangen1.c
  10. 0 7309
      sys/src/cmd/spin/pangen1.h
  11. 0 3203
      sys/src/cmd/spin/pangen2.c
  12. 0 1162
      sys/src/cmd/spin/pangen2.h
  13. 0 439
      sys/src/cmd/spin/pangen3.c
  14. 0 1193
      sys/src/cmd/spin/pangen3.h
  15. 0 360
      sys/src/cmd/spin/pangen4.c
  16. 0 736
      sys/src/cmd/spin/pangen4.h
  17. 0 866
      sys/src/cmd/spin/pangen5.c
  18. 0 433
      sys/src/cmd/spin/pangen5.h
  19. 0 2351
      sys/src/cmd/spin/pangen6.c
  20. 0 2849
      sys/src/cmd/spin/pangen6.h
  21. 0 934
      sys/src/cmd/spin/pangen7.c
  22. 0 461
      sys/src/cmd/spin/pc_zpp.c
  23. 0 455
      sys/src/cmd/spin/ps_msc.c
  24. 0 145
      sys/src/cmd/spin/reprosrc.c
  25. 0 641
      sys/src/cmd/spin/run.c
  26. 0 1103
      sys/src/cmd/spin/sched.c
  27. 0 429
      sys/src/cmd/spin/spin.h
  28. 0 947
      sys/src/cmd/spin/spin.y
  29. 0 1530
      sys/src/cmd/spin/spinlex.c
  30. 0 678
      sys/src/cmd/spin/structs.c
  31. 0 605
      sys/src/cmd/spin/sym.c
  32. 0 141
      sys/src/cmd/spin/tl.h
  33. 0 683
      sys/src/cmd/spin/tl_buchi.c
  34. 0 345
      sys/src/cmd/spin/tl_cache.c
  35. 0 254
      sys/src/cmd/spin/tl_lex.c
  36. 0 276
      sys/src/cmd/spin/tl_main.c
  37. 0 129
      sys/src/cmd/spin/tl_mem.c
  38. 0 411
      sys/src/cmd/spin/tl_parse.c
  39. 0 319
      sys/src/cmd/spin/tl_rewrt.c
  40. 0 904
      sys/src/cmd/spin/tl_trans.c
  41. 0 367
      sys/src/cmd/spin/vars.c
  42. 0 10
      sys/src/cmd/spin/version.h

+ 0 - 380
sys/man/1/spin

@@ -1,380 +0,0 @@
-.TH SPIN 1
-.SH NAME
-spin - verification tool for models of concurrent systems
-.SH SYNOPSIS
-.B spin
-[
-.I options
-]
-.I file
-.br
-.B spin
-.B -V
-.SH DESCRIPTION
-.I Spin
-is a tool for analyzing the logical consistency of
-asynchronous systems, specifically distributed software,
-multi-threaded systems, and communication protocols.
-A model of the system is specified
-in a guarded command language called Promela (process meta language).
-This modeling language supports dynamic creation of
-processes, nondeterministic case selection, loops, gotos,
-local and global variables.
-It also allows for a concise specification of logical
-correctness requirements, including, but not restricted
-to requirements expressed in linear temporal logic.
-.PP
-Given a Promela model stored in
-.IR file ,
-.I spin
-can perform interactive, guided, or random simulations
-of the system's execution.
-It can also generate a C program that performs an exhaustive
-verification of the correctness requirements for the system.
-The main options supported are as follows. (You can always get
-a full list of current options with the command "spin --").
-.
-.TF -Exxx
-.PD
-.TP
-.B -a
-Generate a verifier (a model checker) for the specification.
-The output is written into a set of C files named
-.BR pan.[cbhmt] ,
-that can be compiled
-.RB ( "pcc pan.c" )
-to produce an executable verifier.
-The online
-.I spin
-manuals contain
-the details on compilation and use of the verifiers.
-.
-.TP
-.B -b
-Do not execute
-.I printf
-statements in a simulation run.
-.
-.TP
-.B -c
-Produce an ASCII approximation of a message sequence
-chart for a random or guided (when combined with
-.BR -t )
-simulation run. See also option
-.BR -M .
-.
-.TP
-.B -Dxxx
-Pass
-.I -Dxxx
-to the preprocessor (see also
-.I -E
-and
-.IR -I ).
-.
-.TP
-.B -d
-Produce symbol table information for the model specified in
-.IR file .
-For each Promela object this information includes the type, name and
-number of elements (if declared as an array), the initial
-value (if a data object) or size (if a message channel), the
-scope (global or local), and whether the object is declared as
-a variable or as a parameter.  For message channels, the data types
-of the message fields are listed.
-For structure variables, the third field defines the
-name of the structure declaration that contains the variable.
-.
-.TP
-.B -Exxx
-Pass
-.I xxx
-to the preprocessor (see also
-.I -D
-and
-.IR -I ).
-.
-.TP
-.B -e
-If the specification contains multiple never claims, or ltl properties,
-compute the synchronous product of all claims and write the result
-to the standard output.
-.
-.TP
-.BI -f " ltl"
-Translate the LTL formula
-.I ltl
-into a
-.I never
-claim.
-.br
-This option reads a formula in LTL syntax from the second argument
-and translates it into Promela syntax (a
-.I never
-claim, which is Promela's
-equivalent of a Büchi Automaton).
-The LTL operators are written:
-.B []
-(always),
-.B <>
-(eventually),
-and
-.B U
-(strong until).  There is no
-.B X
-(next) operator, to secure
-compatibility with the partial order reduction rules that are
-applied during the verification process.
-If the formula contains spaces, it should be quoted to form a
-single argument to the
-.I spin
-command.
-.br
-This option has largely been replaced with the support
-for inline specification of ltl formula, in Spin version 6.0.
-.
-.TP
-.BI -F " file"
-Translate the LTL formula stored in
-.I file
-into a
-.I never
-claim.
-.br
-This behaves identically to option
-.B -f
-but will read the formula from the
-.I file
-instead of from the command line.
-The file should contain the formula as the first line.  Any text
-that follows this first line is ignored, so it can be used to
-store comments or annotation on the formula.
-(On some systems the quoting conventions of the shell complicate
-the use of option
-.BR -f .
-Option
-.B -F
-is meant to solve those problems.)
-.
-.TP
-.B -g
-In combination with option
-.BR -p ,
-print all global variable updates in a simulation run.
-.
-.TP
-.B -h
-At the end of a simulation run, print the value of the seed
-that was used for the random number generator.
-By specifying the same seed with the
-.B -n
-option, the exact
-run can be repeated later.
-.
-.TP
-.B -I
-Show the result of inlining and preprocessing.
-.
-.TP
-.B -i
-Perform an interactive simulation, prompting the user at
-every execution step that requires a nondeterministic choice
-to be made.  The simulation proceeds without user intervention
-when execution is deterministic.
-.
-.TP
-.BI -j N
-Skip printing for the first
-.I N
-steps in a simulation run.
-.
-.TP
-.B -J
-Reverse the evaluation order for nested unless statements,
-e.g., to match the way in which Java handles exceptions.
-.
-.TP
-.BI -k " file"
-Use the file name
-.I file
-as the trail-file, see also
-.BR -t .
-.
-.TP
-.B -l
-In combination with option
-.BR -p ,
-include all local variable updates in the output of a simulation run.
-.
-.TP
-.B -M
-Produce a message sequence chart in Postscript form for a
-random simulation or a guided simulation
-(when combined with
-.BR -t ),
-for the model in
-.IR file ,
-and write the result into
-.IR file.ps .
-See also option
-.BR -c .
-.
-.TP
-.B -m
-Changes the semantics of send events.
-Ordinarily, a send action will be (blocked) if the
-target message buffer is full.
-With this option a message sent to a full buffer is lost.
-.
-.TP
-.BI -n N
-Set the seed for a random simulation to the integer value
-.IR N .
-There is no space between the
-.B -n
-and the integer
-.IR N .
-.
-.TP
-.BI -N " file"
-Use the never claim stored in
-.I file
-to generate the verified (see
-.BR -a ).
-.
-.TP
-.BI -O
-Use the original scope rules from pre-Spin version 6.
-.
-.TP
-.BI -o [123]
-Turn off data-flow optimization (
-.IR -o1 ).
-Do not hide write-only variables (
-.I -o2
-) during verification.
-Turn off statement merging (
-.I -o3
-) during verification.
-Turn on rendezvous optimization (
-.I -o4
-) during verification.
-Turn on case caching (
-.I -o5
-) to reduce the size of pan.m,
-but losing accuracy in reachability reports.
-.
-.TP
-.BI -O
-Use the scope rules pre-version 6.0. In this case there are only two
-possible levels of scope for all data declarations: global, or proctype local.
-In version 6.0 and later there is a third level of scope: inlines or blocks.
-.
-.TP
-.BI -P xxx
-Use the command
-.I xxx
-for preprocessing instead of the standard C preprocessor.
-.
-.TP
-.B -p
-Include all statement executions in the output of simulation runs.
-.
-.TP
-.BI -q N
-Suppress the output generated for channel
-.B N
-during simulation runs.
-.
-.TP
-.B -r
-Show all message-receive events, giving
-the name and number of the receiving process
-and the corresponding the source line number.
-For each message parameter, show
-the message type and the message channel number and name.
-.
-.TP
-.B -s
-Include all send operations in the output of simulation runs.
-.
-.TP
-.B -T
-Do not automatically indent the
-.I printf
-output of process
-.I i
-with
-.I i
-tabs.
-.
-.TP
-.B -t[\f2N\f1]
-Perform a guided simulation, following the [\f2N\f1th] error trail that
-was produces by an earlier verification run, see the online manuals
-for the details on verification. By default the error trail is looked for
-in a file with the same basename as the model, and with extension .trail.
-See also
-.BR -k .
-.
-.TP
-.B -v
-Verbose mode, add some more detail, and generate more
-hints and warnings about the model.
-.
-.TP
-.B -V
-Prints the
-.I spin
-version number and exit.
-.
-.PP
-With only a filename as an argument and no option flags,
-.I spin
-performs a random simulation of the model specified in
-the file.
-This normally does not generate output, except what is generated
-explicitly by the user within the model with
-.I printf
-statements, and some details about the final state that is
-reached after the simulation completes.
-The group of options
-.B -bgilmprstv
-is used to set the desired level of information that the user wants
-about a random, guided, or interactive simulation run.
-Every line of output normally contains a reference to the source
-line in the specification that generated it.
-If option
-.B -i
-is included, the simulation i
-.IR interactive ,
-or if option
-.B -t
-or
-.BI -k file
-is added, the simulation is
-.IR guided .
-.
-.SH SOURCE
-.B /sys/src/cmd/spin
-.SH SEE ALSO
-.in +4
-.ti -4
-.B http://spinroot.com/spin/Man/
-.br
-.in -4
-G.J. Holzmann,
-.IR "The Spin Model Checker (Primer and Reference Manual)" ,
-Addison-Wesley, Reading, Mass., 2004.
-.br
-—, `The model checker Spin,'
-.IR "IEEE Trans. on SE" ,
-Vol, 23, No. 5, May 1997.
-.br
-—, `Design and validation of protocols: a tutorial,'
-.IR "Computer Networks and ISDN Systems" ,
-Vol. 25, No. 9, 1993, pp. 981-1017.
-.br
-—,
-.IR "Design and Validation of Computer Protocols" ,
-Prentice Hall, Englewood Cliffs, NJ, 1991.

+ 0 - 11
sys/src/cmd/spin/README

@@ -1,11 +0,0 @@
-the latest version of spin is always
-available via:
-	http://spinroot.com/spin/whatispin.html
-
-to make the sources compile with the mkfile on Plan 9
-the following changes were made:
-
-	omitted memory.h from spin.h
-	changed /lib/cpp to /bin/cpp in main.c
-	simplified non_fatal() in main.c to remove
-	use of yychar

+ 0 - 420
sys/src/cmd/spin/dstep.c

@@ -1,420 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: dstep.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include "y.tab.h"
-
-#define MAXDSTEP	2048	/* was 512 */
-
-char	*NextLab[64];
-int	Level=0, GenCode=0, IsGuard=0, TestOnly=0;
-
-static int	Tj=0, Jt=0, LastGoto=0;
-static int	Tojump[MAXDSTEP], Jumpto[MAXDSTEP], Special[MAXDSTEP];
-static void	putCode(FILE *, Element *, Element *, Element *, int);
-
-extern int	Pid, separate, OkBreak;
-
-static void
-Sourced(int n, int special)
-{	int i;
-	for (i = 0; i < Tj; i++)
-		if (Tojump[i] == n)
-			return;
-	if (Tj >= MAXDSTEP)
-		fatal("d_step sequence too long", (char *)0);
-	Special[Tj] = special;
-	Tojump[Tj++] = n;
-}
-
-static void
-Dested(int n)
-{	int i;
-	for (i = 0; i < Tj; i++)
-		if (Tojump[i] == n)
-			return;
-	for (i = 0; i < Jt; i++)
-		if (Jumpto[i] == n)
-			return;
-	if (Jt >= MAXDSTEP)
-		fatal("d_step sequence too long", (char *)0);
-	Jumpto[Jt++] = n;
-	LastGoto = 1;
-}
-
-static void
-Mopup(FILE *fd)
-{	int i, j;
-
-	for (i = 0; i < Jt; i++)
-	{	for (j = 0; j < Tj; j++)
-			if (Tojump[j] == Jumpto[i])
-				break;
-		if (j == Tj)
-		{	char buf[16];
-			if (Jumpto[i] == OkBreak)
-			{	if (!LastGoto)
-				fprintf(fd, "S_%.3d_0:	/* break-dest */\n",
-					OkBreak);
-			} else {
-				sprintf(buf, "S_%.3d_0", Jumpto[i]);
-				non_fatal("goto %s breaks from d_step seq", buf);
-	}	}	}
-	for (j = 0; j < Tj; j++)
-	{	for (i = 0; i < Jt; i++)
-			if (Tojump[j] == Jumpto[i])
-				break;
-#ifdef DEBUG
-		if (i == Jt && !Special[i])
-			fprintf(fd, "\t\t/* no goto's to S_%.3d_0 */\n",
-			Tojump[j]);
-#endif
-	}
-	for (j = i = 0; j < Tj; j++)
-		if (Special[j])
-		{	Tojump[i] = Tojump[j];
-			Special[i] = 2;
-			if (i >= MAXDSTEP)
-			fatal("cannot happen (dstep.c)", (char *)0);
-			i++;
-		}
-	Tj = i;	/* keep only the global exit-labels */
-	Jt = 0;
-}
-
-static int
-FirstTime(int n)
-{	int i;
-	for (i = 0; i < Tj; i++)
-		if (Tojump[i] == n)
-			return (Special[i] <= 1);
-	return 1;
-}
-
-static void
-illegal(Element *e, char *str)
-{
-	printf("illegal operator in 'd_step:' '");
-	comment(stdout, e->n, 0);
-	printf("'\n");
-	fatal("'%s'", str);
-}
-
-static void
-filterbad(Element *e)
-{
-	switch (e->n->ntyp) {
-	case ASSERT:
-	case PRINT:
-	case 'c':
-		/* run cannot be completely undone
-		 * with sv_save-sv_restor
-		 */
-		if (any_oper(e->n->lft, RUN))
-			illegal(e, "run operator in d_step");
-
-		/* remote refs inside d_step sequences
-		 * would be okay, but they cannot always
-		 * be interpreted by the simulator the
-		 * same as by the verifier (e.g., for an
-		 * error trail)
-		 */
-		if (any_oper(e->n->lft, 'p'))
-			illegal(e, "remote reference in d_step");
-		break;
-	case '@':
-		illegal(e, "process termination");
-		break;
-	case D_STEP:
-		illegal(e, "nested d_step sequence");
-		break;
-	case ATOMIC:
-		illegal(e, "nested atomic sequence");
-		break;
-	default:
-		break;
-	}
-}
-
-static int
-CollectGuards(FILE *fd, Element *e, int inh)
-{	SeqList *h; Element *ee;
-
-	for (h = e->sub; h; h = h->nxt)
-	{	ee = huntstart(h->this->frst);
-		filterbad(ee);
-		switch (ee->n->ntyp) {
-		case NON_ATOMIC:
-			inh += CollectGuards(fd, ee->n->sl->this->frst, inh);
-			break;
-		case  IF:
-			inh += CollectGuards(fd, ee, inh);
-			break;
-		case '.':
-			if (ee->nxt->n->ntyp == DO)
-				inh += CollectGuards(fd, ee->nxt, inh);
-			break;
-		case ELSE:
-			if (inh++ > 0) fprintf(fd, " || ");
-/* 4.2.5 */		if (!pid_is_claim(Pid))
-				fprintf(fd, "(boq == -1 /* else */)");
-			else
-				fprintf(fd, "(1 /* else */)");
-			break;
-		case 'R':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-			putstmnt(fd, ee->n, ee->seqno);
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-		case 'r':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-			putstmnt(fd, ee->n, ee->seqno);
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-		case 's':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-/* 4.2.1 */		if (!pid_is_claim(Pid)) fprintf(fd, "(boq == -1) && ");
-			putstmnt(fd, ee->n, ee->seqno);
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-		case 'c':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-			if (!pid_is_claim(Pid))
-				fprintf(fd, "(boq == -1 && ");
-			putstmnt(fd, ee->n->lft, e->seqno);
-			if (!pid_is_claim(Pid))
-				fprintf(fd, ")");
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-	}	}
-	return inh;
-}
-
-int
-putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln, int seqno)
-{	int isg=0; char buf[64];
-
-	NextLab[0] = "continue";
-	filterbad(s->frst);
-
-	switch (s->frst->n->ntyp) {
-	case UNLESS:
-		non_fatal("'unless' inside d_step - ignored", (char *) 0);
-		return putcode(fd, s->frst->n->sl->this, nxt, 0, ln, seqno);
-	case NON_ATOMIC:
-		(void) putcode(fd, s->frst->n->sl->this, ZE, 1, ln, seqno);
-		break;
-	case IF:
-		fprintf(fd, "if (!(");
-		if (!CollectGuards(fd, s->frst, 0))	/* what about boq? */
-			fprintf(fd, "1");
-		fprintf(fd, "))\n\t\t\tcontinue;");
-		isg = 1;
-		break;
-	case '.':
-		if (s->frst->nxt->n->ntyp == DO)
-		{	fprintf(fd, "if (!(");
-			if (!CollectGuards(fd, s->frst->nxt, 0))
-				fprintf(fd, "1");
-			fprintf(fd, "))\n\t\t\tcontinue;");
-			isg = 1;
-		}
-		break;
-	case 'R': /* <- can't really happen (it's part of a 'c') */
-		fprintf(fd, "if (!("); TestOnly=1;
-		putstmnt(fd, s->frst->n, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case 'r':
-		fprintf(fd, "if (!("); TestOnly=1;
-		putstmnt(fd, s->frst->n, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case 's':
-		fprintf(fd, "if (");
-#if 1
-/* 4.2.1 */	if (!pid_is_claim(Pid)) fprintf(fd, "(boq != -1) || ");
-#endif
-		fprintf(fd, "!("); TestOnly=1;
-		putstmnt(fd, s->frst->n, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case 'c':
-		fprintf(fd, "if (!(");
-		if (!pid_is_claim(Pid)) fprintf(fd, "boq == -1 && ");
-		TestOnly=1;
-		putstmnt(fd, s->frst->n->lft, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case ELSE:
-		fprintf(fd, "if (boq != -1 || (");
-		if (separate != 2) fprintf(fd, "trpt->");
-		fprintf(fd, "o_pm&1))\n\t\t\tcontinue;");
-		break;
-	case ASGN:	/* new 3.0.8 */
-		fprintf(fd, "IfNotBlocked");
-		break;
-	}
-	if (justguards) return 0;
-
-	fprintf(fd, "\n\t\tsv_save();\n\t\t");
-#if 1
-	fprintf(fd, "reached[%d][%d] = 1;\n\t\t", Pid, seqno);
-	fprintf(fd, "reached[%d][t->st] = 1;\n\t\t", Pid);	/* true next state */
-	fprintf(fd, "reached[%d][tt] = 1;\n", Pid);		/* true current state */
-#endif
-	sprintf(buf, "Uerror(\"block in d_step seq, line %d\")", ln);
-	NextLab[0] = buf;
-	putCode(fd, s->frst, s->extent, nxt, isg);
-
-	if (nxt)
-	{	extern Symbol *Fname;
-		extern int lineno;
-
-		if (FirstTime(nxt->Seqno)
-		&& (!(nxt->status & DONE2) || !(nxt->status & D_ATOM)))
-		{	fprintf(fd, "S_%.3d_0: /* 1 */\n", nxt->Seqno);
-			nxt->status |= DONE2;
-			LastGoto = 0;
-		}
-		Sourced(nxt->Seqno, 1);
-		lineno = ln;
-		Fname = nxt->n->fn;
-		Mopup(fd);
-	}
-	unskip(s->frst->seqno);
-	return LastGoto;
-}
-
-static void
-putCode(FILE *fd, Element *f, Element *last, Element *next, int isguard)
-{	Element *e, *N;
-	SeqList *h; int i;
-	char NextOpt[64];
-	static int bno = 0;
-
-	for (e = f; e; e = e->nxt)
-	{	if (e->status & DONE2)
-			continue;
-		e->status |= DONE2;
-
-		if (!(e->status & D_ATOM))
-		{	if (!LastGoto)
-			{	fprintf(fd, "\t\tgoto S_%.3d_0;\n",
-					e->Seqno);
-				Dested(e->Seqno);
-			}
-			break;
-		}
-		fprintf(fd, "S_%.3d_0: /* 2 */\n", e->Seqno);
-		LastGoto = 0;
-		Sourced(e->Seqno, 0);
-
-		if (!e->sub)
-		{	filterbad(e);
-			switch (e->n->ntyp) {
-			case NON_ATOMIC:
-				h = e->n->sl;
-				putCode(fd, h->this->frst,
-					h->this->extent, e->nxt, 0);
-				break;
-			case BREAK:
-				if (LastGoto) break;
-				if (e->nxt)
-				{	i = target( huntele(e->nxt,
-						e->status, -1))->Seqno;
-					fprintf(fd, "\t\tgoto S_%.3d_0;	", i);
-					fprintf(fd, "/* 'break' */\n");
-					Dested(i);
-				} else
-				{	if (next)
-					{	fprintf(fd, "\t\tgoto S_%.3d_0;",
-							next->Seqno);
-						fprintf(fd, " /* NEXT */\n");
-						Dested(next->Seqno);
-					} else
-					fatal("cannot interpret d_step", 0);
-				}
-				break;
-			case GOTO:
-				if (LastGoto) break;
-				i = huntele( get_lab(e->n,1),
-					e->status, -1)->Seqno;
-				fprintf(fd, "\t\tgoto S_%.3d_0;	", i);
-				fprintf(fd, "/* 'goto' */\n");
-				Dested(i);
-				break;
-			case '.':
-				if (LastGoto) break;
-				if (e->nxt && (e->nxt->status & DONE2))
-				{	i = e->nxt?e->nxt->Seqno:0;
-					fprintf(fd, "\t\tgoto S_%.3d_0;", i);
-					fprintf(fd, " /* '.' */\n");
-					Dested(i);
-				}
-				break;
-			default:
-				putskip(e->seqno);
-				GenCode = 1; IsGuard = isguard;
-				fprintf(fd, "\t\t");
-				putstmnt(fd, e->n, e->seqno);
-				fprintf(fd, ";\n");
-				GenCode = IsGuard = isguard = LastGoto = 0;
-				break;
-			}
-			i = e->nxt?e->nxt->Seqno:0;
-			if (e->nxt && e->nxt->status & DONE2 && !LastGoto)
-			{	fprintf(fd, "\t\tgoto S_%.3d_0; ", i);
-				fprintf(fd, "/* ';' */\n");
-				Dested(i);
-				break;
-			}
-		} else
-		{	for (h = e->sub, i=1; h; h = h->nxt, i++)
-			{	sprintf(NextOpt, "goto S_%.3d_%d",
-					e->Seqno, i);
-				NextLab[++Level] = NextOpt;
-				N = (e->n && e->n->ntyp == DO) ? e : e->nxt;
-				putCode(fd, h->this->frst,
-					h->this->extent, N, 1);
-				Level--;
-				fprintf(fd, "%s: /* 3 */\n", &NextOpt[5]);
-				LastGoto = 0;
-			}
-			if (!LastGoto)
-			{	fprintf(fd, "\t\tUerror(\"blocking sel ");
-				fprintf(fd, "in d_step (nr.%d, near line %d)\");\n",
-				bno++, (e->n)?e->n->ln:0);
-				LastGoto = 0;
-			}
-		}
-		if (e == last)
-		{	if (!LastGoto && next)
-			{	fprintf(fd, "\t\tgoto S_%.3d_0;\n",
-					next->Seqno);
-				Dested(next->Seqno);
-			}
-			break;
-	}	}
-}

File diff suppressed because it is too large
+ 0 - 1080
sys/src/cmd/spin/flow.c


+ 0 - 351
sys/src/cmd/spin/guided.c

@@ -1,351 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: guided.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "y.tab.h"
-
-extern RunList	*run, *X;
-extern Element	*Al_El;
-extern Symbol	*Fname, *oFname;
-extern int	verbose, lineno, xspin, jumpsteps, depth, merger, cutoff;
-extern int	nproc, nstop, Tval, ntrail, columns;
-extern int16_t	Have_claim, Skip_claim;
-extern void ana_src(int, int);
-extern char	**trailfilename;
-
-int	TstOnly = 0, pno;
-
-static int	lastclaim = -1;
-static FILE	*fd;
-static void	lost_trail(void);
-
-static void
-whichproc(int p)
-{	RunList *oX;
-
-	for (oX = run; oX; oX = oX->nxt)
-		if (oX->pid == p)
-		{	printf("(%s) ", oX->n->name);
-			break;
-		}
-}
-
-static int
-newer(char *f1, char *f2)
-{
-#if defined(WIN32) || defined(WIN64)
-	struct _stat x, y;
-#else
-	struct stat x, y;
-#endif
-
-	if (stat(f1, (struct stat *)&x) < 0) return 0;
-	if (stat(f2, (struct stat *)&y) < 0) return 1;
-	if (x.st_mtime < y.st_mtime) return 0;
-
-	return 1;
-}
-
-void
-hookup(void)
-{	Element *e;
-
-	for (e = Al_El; e; e = e->Nxt)
-		if (e->n
-		&& (e->n->ntyp == ATOMIC
-		||  e->n->ntyp == NON_ATOMIC
-		||  e->n->ntyp == D_STEP))
-			(void) huntstart(e);
-}
-
-int
-not_claim(void)
-{
-	return (!Have_claim || !X || X->pid != 0);
-}
-
-void
-match_trail(void)
-{	int i, a, nst;
-	Element *dothis;
-	char snap[512], *q;
-
-	/*
-	 * if source model name is leader.pml
-	 * look for the trail file under these names:
-	 *	leader.pml.trail
-	 *	leader.pml.tra
-	 *	leader.trail
-	 *	leader.tra
-	 */
-
-	if (trailfilename)
-	{	if (strlen(*trailfilename) < sizeof(snap))
-		{	strcpy(snap, (const char *) *trailfilename);
-		} else
-		{	fatal("filename %s too long", *trailfilename);
-		}
-	} else
-	{	if (ntrail)
-			sprintf(snap, "%s%d.trail", oFname->name, ntrail);
-		else
-			sprintf(snap, "%s.trail", oFname->name);
-	}
-
-	if ((fd = fopen(snap, "r")) == NULL)
-	{	snap[strlen(snap)-2] = '\0';	/* .tra */
-		if ((fd = fopen(snap, "r")) == NULL)
-		{	if ((q = strchr(oFname->name, '.')) != NULL)
-			{	*q = '\0';
-				if (ntrail)
-					sprintf(snap, "%s%d.trail",
-						oFname->name, ntrail);
-				else
-					sprintf(snap, "%s.trail",
-						oFname->name);
-				*q = '.';
-
-				if ((fd = fopen(snap, "r")) != NULL)
-					goto okay;
-
-				snap[strlen(snap)-2] = '\0';	/* last try */
-				if ((fd = fopen(snap, "r")) != NULL)
-					goto okay;
-			}
-			printf("spin: cannot find trail file\n");
-			alldone(1);
-	}	}
-okay:
-	if (xspin == 0 && newer(oFname->name, snap))
-	printf("spin: warning, \"%s\" is newer than %s\n",
-		oFname->name, snap);
-
-	Tval = 1;
-
-	/*
-	 * sets Tval because timeouts may be part of trail
-	 * this used to also set m_loss to 1, but that is
-	 * better handled with the runtime -m flag
-	 */
-
-	hookup();
-
-	while (fscanf(fd, "%d:%d:%d\n", &depth, &pno, &nst) == 3)
-	{	if (depth == -2) { start_claim(pno); continue; }
-		if (depth == -4) { merger = 1; ana_src(0, 1); continue; }
-		if (depth == -1)
-		{	if (verbose)
-			{	if (columns == 2)
-				dotag(stdout, " CYCLE>\n");
-				else
-				dotag(stdout, "<<<<<START OF CYCLE>>>>>\n");
-			}
-			continue;
-		}
-
-		if (cutoff > 0 && depth >= cutoff)
-		{	printf("-------------\n");
-			printf("depth-limit (-u%d steps) reached\n", cutoff);
-			break;
-		}
-
-		if (Skip_claim && pno == 0) continue;
-
-		for (dothis = Al_El; dothis; dothis = dothis->Nxt)
-		{	if (dothis->Seqno == nst)
-				break;
-		}
-		if (!dothis)
-		{	printf("%3d: proc %d, no matching stmnt %d\n",
-				depth, pno - Have_claim, nst);
-			lost_trail();
-		}
-
-		i = nproc - nstop + Skip_claim;
-
-		if (dothis->n->ntyp == '@')
-		{	if (pno == i-1)
-			{	run = run->nxt;
-				nstop++;
-				if (verbose&4)
-				{	if (columns == 2)
-					{	dotag(stdout, "<end>\n");
-						continue;
-					}
-					if (Have_claim && pno == 0)
-					printf("%3d: claim terminates\n",
-						depth);
-					else
-					printf("%3d: proc %d terminates\n",
-						depth, pno - Have_claim);
-				}
-				continue;
-			}
-			if (pno <= 1) continue;	/* init dies before never */
-			printf("%3d: stop error, ", depth);
-			printf("proc %d (i=%d) trans %d, %c\n",
-				pno - Have_claim, i, nst, dothis->n->ntyp);
-			lost_trail();
-		}
-
-		if (!xspin && (verbose&32))
-		{	printf("i=%d pno %d\n", i, pno);
-		}
-
-		for (X = run; X; X = X->nxt)
-		{	if (--i == pno)
-				break;
-		}
-
-		if (!X)
-		{	if (verbose&32)
-			{	printf("%3d: no process %d (step %d)\n", depth, pno - Have_claim, nst);
-				printf(" max %d (%d - %d + %d) claim %d",
-					nproc - nstop + Skip_claim,
-					nproc, nstop, Skip_claim, Have_claim);
-				printf("active processes:\n");
-				for (X = run; X; X = X->nxt)
-				{	printf("\tpid %d\tproctype %s\n", X->pid, X->n->name);
-				}
-				printf("\n");
-				continue;
-			} else
-			{	printf("%3d:\tproc  %d (?) ", depth, pno);
-				lost_trail();
-			}
-		} else
-		{	X->pc  = dothis;
-		}
-
-		lineno = dothis->n->ln;
-		Fname  = dothis->n->fn;
-
-		if (dothis->n->ntyp == D_STEP)
-		{	Element *g, *og = dothis;
-			do {
-				g = eval_sub(og);
-				if (g && depth >= jumpsteps
-				&& ((verbose&32) || ((verbose&4) && not_claim())))
-				{	if (columns != 2)
-					{	p_talk(og, 1);
-
-						if (og->n->ntyp == D_STEP)
-						og = og->n->sl->this->frst;
-
-						printf("\t[");
-						comment(stdout, og->n, 0);
-						printf("]\n");
-					}
-					if (verbose&1) dumpglobals();
-					if (verbose&2) dumplocal(X);
-					if (xspin) printf("\n");
-				}
-				og = g;
-			} while (g && g != dothis->nxt);
-			if (X != NULL)
-			{	X->pc = g?huntele(g, 0, -1):g;
-			}
-		} else
-		{
-keepgoing:		if (dothis->merge_start)
-				a = dothis->merge_start;
-			else
-				a = dothis->merge;
-
-			if (X != NULL)
-			{	X->pc = eval_sub(dothis);
-				if (X->pc) X->pc = huntele(X->pc, 0, a);
-			}
-
-			if (depth >= jumpsteps
-			&& ((verbose&32) || ((verbose&4) && not_claim())))	/* -v or -p */
-			{	if (columns != 2)
-				{	p_talk(dothis, 1);
-
-					if (dothis->n->ntyp == D_STEP)
-					dothis = dothis->n->sl->this->frst;
-
-					printf("\t[");
-					comment(stdout, dothis->n, 0);
-					printf("]");
-					if (a && (verbose&32))
-					printf("\t<merge %d now @%d>",
-						dothis->merge,
-						(X && X->pc)?X->pc->seqno:-1);
-					printf("\n");
-				}
-				if (verbose&1) dumpglobals();
-				if (verbose&2) dumplocal(X);
-				if (xspin) printf("\n");
-
-				if (X && !X->pc)
-				{	X->pc = dothis;
-					printf("\ttransition failed\n");
-					a = 0;	/* avoid inf loop */
-				}
-			}
-			if (a && X && X->pc && X->pc->seqno != a)
-			{	dothis = X->pc;
-				goto keepgoing;
-		}	}
-
-		if (Have_claim && X && X->pid == 0
-		&&  dothis->n
-		&&  lastclaim != dothis->n->ln)
-		{	lastclaim = dothis->n->ln;
-			if (columns == 2)
-			{	char t[128];
-				sprintf(t, "#%d", lastclaim);
-				pstext(0, t);
-			} else
-			{
-				printf("Never claim moves to line %d\t[", lastclaim);
-				comment(stdout, dothis->n, 0);
-				printf("]\n");
-	}	}	}
-	printf("spin: trail ends after %d steps\n", depth);
-	wrapup(0);
-}
-
-static void
-lost_trail(void)
-{	int d, p, n, l;
-
-	while (fscanf(fd, "%d:%d:%d:%d\n", &d, &p, &n, &l) == 4)
-	{	printf("step %d: proc  %d ", d, p); whichproc(p);
-		printf("(state %d) - d %d\n", n, l);
-	}
-	wrapup(1);	/* no return */
-}
-
-int
-pc_value(Lextok *n)
-{	int i = nproc - nstop;
-	int pid = eval(n);
-	RunList *Y;
-
-	for (Y = run; Y; Y = Y->nxt)
-	{	if (--i == pid)
-			return Y->pc->seqno;
-	}
-	return 0;
-}

+ 0 - 868
sys/src/cmd/spin/main.c

@@ -1,868 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: main.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include <stdlib.h>
-#include "spin.h"
-#include "version.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-/* #include <malloc.h> */
-#include <time.h>
-#ifdef PC
-#include <io.h>
-extern int unlink(const char *);
-#else
-#include <unistd.h>
-#endif
-#include "y.tab.h"
-
-extern int	DstepStart, lineno, tl_terse;
-extern FILE	*yyin, *yyout, *tl_out;
-extern Symbol	*context;
-extern char	*claimproc;
-extern void	repro_src(void);
-extern void	qhide(int);
-extern char	CurScope[MAXSCOPESZ];
-
-Symbol	*Fname, *oFname;
-
-int	Etimeouts;	/* nr timeouts in program */
-int	Ntimeouts;	/* nr timeouts in never claim */
-int	analyze, columns, dumptab, has_remote, has_remvar;
-int	interactive, jumpsteps, m_loss, nr_errs, cutoff;
-int	s_trail, ntrail, verbose, xspin, notabs, rvopt;
-int	no_print, no_wrapup, Caccess, limited_vis, like_java;
-int	separate;	/* separate compilation */
-int	export_ast;	/* pangen5.c */
-int	old_scope_rules;	/* use pre 5.3.0 rules */
-int	split_decl = 1, product, Strict;
-
-int	merger = 1, deadvar = 1;
-int	ccache = 0; /* oyvind teig: 5.2.0 case caching off by default */
-
-static int preprocessonly, SeedUsed;
-static int seedy;	/* be verbose about chosen seed */
-static int inlineonly;	/* show inlined code */
-static int dataflow = 1;
-
-#if 0
-meaning of flags on verbose:
-	1	-g global variable values
-	2	-l local variable values
-	4	-p all process actions
-	8	-r receives
-	16	-s sends
-	32	-v verbose
-	64	-w very verbose
-#endif
-
-static char	Operator[] = "operator: ";
-static char	Keyword[]  = "keyword: ";
-static char	Function[] = "function-name: ";
-static char	**add_ltl  = (char **) 0;
-static char	**ltl_file = (char **) 0;
-static char	**nvr_file = (char **) 0;
-static char	*ltl_claims = (char *) 0;
-static FILE	*fd_ltl = (FILE *) 0;
-static char	*PreArg[64];
-static int	PreCnt = 0;
-static char	out1[64];
-
-char	**trailfilename;	/* new option 'k' */
-
-void	explain(int);
-
-	/* to use visual C++:
-		#define CPP	"CL -E/E"
-	   or call spin as:	"spin -PCL  -E/E"
-
-	   on OS2:
-		#define CPP	"icc -E/Pd+ -E/Q+"
-	   or call spin as:	"spin -Picc -E/Pd+ -E/Q+"
-	*/
-#ifndef CPP
-	#if defined(PC) || defined(MAC)
-		#define CPP	"gcc -E -x c"	/* most systems have gcc or cpp */
-		/* if gcc-4 is available, this setting is modified below */
-	#else
-		#ifdef SOLARIS
-			#define CPP	"/usr/ccs/lib/cpp"
-		#else
-			#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
-				#define CPP	"cpp"
-			#else
-				#define CPP	"/bin/cpp"	/* classic Unix systems */
-			#endif
-		#endif
-	#endif
-#endif
-
-static char	*PreProc = CPP;
-extern int	depth; /* at least some steps were made */
-
-void
-alldone(int estatus)
-{
-	if (preprocessonly == 0
-	&&  strlen(out1) > 0)
-		(void) unlink((const char *)out1);
-
-	if (seedy && !analyze && !export_ast
-	&& !s_trail && !preprocessonly && depth > 0)
-		printf("seed used: %d\n", SeedUsed);
-
-	if (xspin && (analyze || s_trail))
-	{	if (estatus)
-			printf("spin: %d error(s) - aborting\n",
-			estatus);
-		else
-			printf("Exit-Status 0\n");
-	}
-	exit(estatus);
-}
-
-void
-preprocess(char *a, char *b, int a_tmp)
-{	char precmd[1024], cmd[2048]; int i;
-#if defined(WIN32) || defined(WIN64)
-	struct _stat x;
-/*	struct stat x;	*/
-#endif
-#ifdef PC
-	extern int try_zpp(char *, char *);
-	if (PreCnt == 0 && try_zpp(a, b))
-	{	goto out;
-	}
-#endif
-#if defined(WIN32) || defined(WIN64)
-	if (strncmp(PreProc, "gcc -E -x c", strlen("gcc -E -x c")) == 0)
-	{	if (stat("/bin/gcc-4.exe", (struct stat *)&x) == 0	/* for PCs with cygwin */
-		||  stat("c:/cygwin/bin/gcc-4.exe", (struct stat *)&x) == 0)
-		{	PreProc = "gcc-4 -E -x c";
-		} else if (stat("/bin/gcc-3.exe", (struct stat *)&x) == 0
-		       ||  stat("c:/cygwin/bin/gcc-3.exe", (struct stat *)&x) == 0)
-		{	PreProc = "gcc-3 -E -x c";
-	}	}
-#endif
-	strcpy(precmd, PreProc);
-	for (i = 1; i <= PreCnt; i++)
-	{	strcat(precmd, " ");
-		strcat(precmd, PreArg[i]);
-	}
-	if (strlen(precmd) > sizeof(precmd))
-	{	fprintf(stdout, "spin: too many -D args, aborting\n");
-		alldone(1);
-	}
-	sprintf(cmd, "%s %s > %s", precmd, a, b);
-	if (system((const char *)cmd))
-	{	(void) unlink((const char *) b);
-		if (a_tmp) (void) unlink((const char *) a);
-		fprintf(stdout, "spin: preprocessing failed\n");	/* 4.1.2 was stderr */
-		alldone(1); /* no return, error exit */
-	}
-#ifdef PC
-out:
-#endif
-	if (a_tmp) (void) unlink((const char *) a);
-}
-
-void
-usage(void)
-{
-	printf("use: spin [-option] ... [-option] file\n");
-	printf("\tNote: file must always be the last argument\n");
-	printf("\t-A apply slicing algorithm\n");
-	printf("\t-a generate a verifier in pan.c\n");
-	printf("\t-B no final state details in simulations\n");
-	printf("\t-b don't execute printfs in simulation\n");
-	printf("\t-C print channel access info (combine with -g etc.)\n");
-	printf("\t-c columnated -s -r simulation output\n");
-	printf("\t-d produce symbol-table information\n");
-	printf("\t-Dyyy pass -Dyyy to the preprocessor\n");
-	printf("\t-Eyyy pass yyy to the preprocessor\n");
-	printf("\t-e compute synchronous product of multiple never claims (modified by -L)\n");
-	printf("\t-f \"..formula..\"  translate LTL ");
-	printf("into never claim\n");
-	printf("\t-F file  like -f, but with the LTL formula stored in a 1-line file\n");
-	printf("\t-g print all global variables\n");
-	printf("\t-h at end of run, print value of seed for random nr generator used\n");
-	printf("\t-i interactive (random simulation)\n");
-	printf("\t-I show result of inlining and preprocessing\n");
-	printf("\t-J reverse eval order of nested unlesses\n");
-	printf("\t-jN skip the first N steps ");
-	printf("in simulation trail\n");
-	printf("\t-k fname use the trailfile stored in file fname, see also -t\n");
-	printf("\t-L when using -e, use strict language intersection\n");
-	printf("\t-l print all local variables\n");
-	printf("\t-M print msc-flow in Postscript\n");
-	printf("\t-m lose msgs sent to full queues\n");
-	printf("\t-N fname use never claim stored in file fname\n");
-	printf("\t-nN seed for random nr generator\n");
-	printf("\t-O use old scope rules (pre 5.3.0)\n");
-	printf("\t-o1 turn off dataflow-optimizations in verifier\n");
-	printf("\t-o2 don't hide write-only variables in verifier\n");
-	printf("\t-o3 turn off statement merging in verifier\n");
-	printf("\t-o4 turn on rendezvous optiomizations in verifier\n");
-	printf("\t-o5 turn on case caching (reduces size of pan.m, but affects reachability reports)\n");
-	printf("\t-Pxxx use xxx for preprocessing\n");
-	printf("\t-p print all statements\n");
-	printf("\t-qN suppress io for queue N in printouts\n");
-	printf("\t-r print receive events\n");
-	printf("\t-S1 and -S2 separate pan source for claim and model\n");
-	printf("\t-s print send events\n");
-	printf("\t-T do not indent printf output\n");
-	printf("\t-t[N] follow [Nth] simulation trail, see also -k\n");
-	printf("\t-Uyyy pass -Uyyy to the preprocessor\n");
-	printf("\t-uN stop a simulation run after N steps\n");
-	printf("\t-v verbose, more warnings\n");
-	printf("\t-w very verbose (when combined with -l or -g)\n");
-	printf("\t-[XYZ] reserved for use by xspin interface\n");
-	printf("\t-V print version number and exit\n");
-	alldone(1);
-}
-
-void
-optimizations(int nr)
-{
-	switch (nr) {
-	case '1':
-		dataflow = 1 - dataflow; /* dataflow */
-		if (verbose&32)
-		printf("spin: dataflow optimizations turned %s\n",
-			dataflow?"on":"off");
-		break;
-	case '2':
-		/* dead variable elimination */
-		deadvar = 1 - deadvar;
-		if (verbose&32)
-		printf("spin: dead variable elimination turned %s\n",
-			deadvar?"on":"off");
-		break;
-	case '3':
-		/* statement merging */
-		merger = 1 - merger;
-		if (verbose&32)
-		printf("spin: statement merging turned %s\n",
-			merger?"on":"off");
-		break;
-
-	case '4':
-		/* rv optimization */
-		rvopt = 1 - rvopt;
-		if (verbose&32)
-		printf("spin: rendezvous optimization turned %s\n",
-			rvopt?"on":"off");
-		break;
-	case '5':
-		/* case caching */
-		ccache = 1 - ccache;
-		if (verbose&32)
-		printf("spin: case caching turned %s\n",
-			ccache?"on":"off");
-		break;
-	default:
-		printf("spin: bad or missing parameter on -o\n");
-		usage();
-		break;
-	}
-}
-
-int
-main(int argc, char *argv[])
-{	Symbol *s;
-	int T = (int) time((time_t *)0);
-	int usedopts = 0;
-	extern void ana_src(int, int);
-
-	yyin  = stdin;
-	yyout = stdout;
-	tl_out = stdout;
-	strcpy(CurScope, "_");
-
-	/* unused flags: y, z, G, L, Q, R, W */
-	while (argc > 1 && argv[1][0] == '-')
-	{	switch (argv[1][1]) {
-		/* generate code for separate compilation: S1 or S2 */
-		case 'S': separate = atoi(&argv[1][2]);
-			  /* fall through */
-		case 'a': analyze  = 1; break;
-		case 'A': export_ast = 1; break;
-		case 'B': no_wrapup = 1; break;
-		case 'b': no_print = 1; break;
-		case 'C': Caccess = 1; break;
-		case 'c': columns = 1; break;
-		case 'D': PreArg[++PreCnt] = (char *) &argv[1][0];
-			  break;	/* define */
-		case 'd': dumptab =  1; break;
-		case 'E': PreArg[++PreCnt] = (char *) &argv[1][2];
-			  break;
-		case 'e': product++; break; /* see also 'L' */
-		case 'F': ltl_file = (char **) (argv+2);
-			  argc--; argv++; break;
-		case 'f': add_ltl = (char **) argv;
-			  argc--; argv++; break;
-		case 'g': verbose +=  1; break;
-		case 'h': seedy = 1; break;
-		case 'i': interactive = 1; break;
-		case 'I': inlineonly = 1; break;
-		case 'J': like_java = 1; break;
-		case 'j': jumpsteps = atoi(&argv[1][2]); break;
-		case 'k': s_trail = 1;
-			  trailfilename = (char **) (argv+2);
-			  argc--; argv++; break;
-		case 'L': Strict++; break; /* modified -e */
-		case 'l': verbose +=  2; break;
-		case 'M': columns = 2; break;
-		case 'm': m_loss   =  1; break;
-		case 'N': nvr_file = (char **) (argv+2);
-			  argc--; argv++; break;
-		case 'n': T = atoi(&argv[1][2]); tl_terse = 1; break;
-		case 'O': old_scope_rules = 1; break;
-		case 'o': optimizations(argv[1][2]);
-			  usedopts = 1; break;
-		case 'P': PreProc = (char *) &argv[1][2]; break;
-		case 'p': verbose +=  4; break;
-		case 'q': if (isdigit((int) argv[1][2]))
-				qhide(atoi(&argv[1][2]));
-			  break;
-		case 'r': verbose +=  8; break;
-		case 's': verbose += 16; break;
-		case 'T': notabs = 1; break;
-		case 't': s_trail  =  1;
-			  if (isdigit((int)argv[1][2]))
-				ntrail = atoi(&argv[1][2]);
-			  break;
-		case 'U': PreArg[++PreCnt] = (char *) &argv[1][0];
-			  break;	/* undefine */
-		case 'u': cutoff = atoi(&argv[1][2]); break;	/* new 3.4.14 */
-		case 'v': verbose += 32; break;
-		case 'V': printf("%s\n", SpinVersion);
-			  alldone(0);
-			  break;
-		case 'w': verbose += 64; break;
-#if 0
-		case 'x': split_decl = 0; break;	/* experimental */
-#endif
-		case 'X': xspin = notabs = 1;
-#ifndef PC
-			  signal(SIGPIPE, alldone); /* not posix... */
-#endif
-			  break;
-		case 'Y': limited_vis = 1; break;	/* used by xspin */
-		case 'Z': preprocessonly = 1; break;	/* used by xspin */
-
-		default : usage(); break;
-		}
-		argc--; argv++;
-	}
-
-	if (usedopts && !analyze)
-		printf("spin: warning -o[123] option ignored in simulations\n");
-
-	if (ltl_file)
-	{	char formula[4096];
-		add_ltl = ltl_file-2; add_ltl[1][1] = 'f';
-		if (!(tl_out = fopen(*ltl_file, "r")))
-		{	printf("spin: cannot open %s\n", *ltl_file);
-			alldone(1);
-		}
-		if (!fgets(formula, 4096, tl_out))
-		{	printf("spin: cannot read %s\n", *ltl_file);
-		}
-		fclose(tl_out);
-		tl_out = stdout;
-		*ltl_file = (char *) formula;
-	}
-	if (argc > 1)
-	{	FILE *fd = stdout;
-		char cmd[512], out2[512];
-
-		/* must remain in current dir */
-		strcpy(out1, "pan.pre");
-
-		if (add_ltl || nvr_file)
-		{	sprintf(out2, "%s.nvr", argv[1]);
-			if ((fd = fopen(out2, MFLAGS)) == NULL)
-			{	printf("spin: cannot create tmp file %s\n",
-					out2);
-				alldone(1);
-			}
-			fprintf(fd, "#include \"%s\"\n", argv[1]);
-		}
-
-		if (add_ltl)
-		{	tl_out = fd;
-			nr_errs = tl_main(2, add_ltl);
-			fclose(fd);
-			preprocess(out2, out1, 1);
-		} else if (nvr_file)
-		{	fprintf(fd, "#include \"%s\"\n", *nvr_file);
-			fclose(fd);
-			preprocess(out2, out1, 1);
-		} else
-		{	preprocess(argv[1], out1, 0);
-		}
-
-		if (preprocessonly)
-			alldone(0);
-
-		if (!(yyin = fopen(out1, "r")))
-		{	printf("spin: cannot open %s\n", out1);
-			alldone(1);
-		}
-
-		if (strncmp(argv[1], "progress", (size_t) 8) == 0
-		||  strncmp(argv[1], "accept", (size_t) 6) == 0)
-			sprintf(cmd, "_%s", argv[1]);
-		else
-			strcpy(cmd, argv[1]);
-		oFname = Fname = lookup(cmd);
-		if (oFname->name[0] == '\"')
-		{	int i = (int) strlen(oFname->name);
-			oFname->name[i-1] = '\0';
-			oFname = lookup(&oFname->name[1]);
-		}
-	} else
-	{	oFname = Fname = lookup("<stdin>");
-		if (add_ltl)
-		{	if (argc > 0)
-				exit(tl_main(2, add_ltl));
-			printf("spin: missing argument to -f\n");
-			alldone(1);
-		}
-		printf("%s\n", SpinVersion);
-		fprintf(stderr, "spin: error, no filename specified");
-		fflush(stdout);
-		alldone(1);
-	}
-	if (columns == 2)
-	{	extern void putprelude(void);
-		if (xspin || verbose&(1|4|8|16|32))
-		{	printf("spin: -c precludes all flags except -t\n");
-			alldone(1);
-		}
-		putprelude();
-	}
-	if (columns && !(verbose&8) && !(verbose&16))
-		verbose += (8+16);
-	if (columns == 2 && limited_vis)
-		verbose += (1+4);
-	Srand((unsigned int) T);	/* defined in run.c */
-	SeedUsed = T;
-	s = lookup("_");	s->type = PREDEF; /* write-only global var */
-	s = lookup("_p");	s->type = PREDEF;
-	s = lookup("_pid");	s->type = PREDEF;
-	s = lookup("_last");	s->type = PREDEF;
-	s = lookup("_nr_pr");	s->type = PREDEF; /* new 3.3.10 */
-
-	yyparse();
-	fclose(yyin);
-
-	if (ltl_claims)
-	{	Symbol *r;
-		fclose(fd_ltl);
-		if (!(yyin = fopen(ltl_claims, "r")))
-		{	fatal("cannot open %s", ltl_claims);
-		}
-		r = oFname;
-		oFname = Fname = lookup(ltl_claims);
-		lineno = 0;
-		yyparse();
-		fclose(yyin);
-		oFname = Fname = r;
-		if (0)
-		{	(void) unlink(ltl_claims);
-	}	}
-
-	loose_ends();
-
-	if (inlineonly)
-	{	repro_src();
-		return 0;
-	}
-
-	chanaccess();
-	if (!Caccess)
-	{	if (!s_trail && (dataflow || merger))
-			ana_src(dataflow, merger);
-		sched();
-		alldone(nr_errs);
-	}
-	return 0;
-}
-
-void
-ltl_list(char *nm, char *fm)
-{
-	if (analyze || dumptab)	/* when generating pan.c only */
-	{	if (!ltl_claims)
-		{	ltl_claims = "_spin_nvr.tmp";
-			if ((fd_ltl = fopen(ltl_claims, MFLAGS)) == NULL)
-			{	fatal("cannot open tmp file %s", ltl_claims);
-			}
-			tl_out = fd_ltl;
-		}
-
-		add_ltl = (char **) emalloc(5 * sizeof(char *));
-		add_ltl[1] = "-c";
-		add_ltl[2] = nm;
-		add_ltl[3] = "-f";
-		add_ltl[4] = (char *) emalloc(strlen(fm)+4);
-		strcpy(add_ltl[4], "!(");
-		strcat(add_ltl[4], fm);
-		strcat(add_ltl[4], ")");
-		/* add_ltl[4] = fm; */
-
-		nr_errs += tl_main(4, add_ltl);
-
-		fflush(tl_out);
-		/* should read this file after the main file is read */
-	}
-}
-
-int
-yywrap(void)	/* dummy routine */
-{
-	return 1;
-}
-
-void
-non_fatal(char *s1, char *s2)
-{	extern char yytext[];
-
-	printf("spin: %s:%d, Error: ",
-		oFname?oFname->name:"nofilename", lineno);
-	if (s2)
-		printf(s1, s2);
-	else
-		printf(s1);
-	if (strlen(yytext)>1)
-		printf(" near '%s'", yytext);
-	printf("\n");
-	nr_errs++;
-}
-
-void
-fatal(char *s1, char *s2)
-{
-	non_fatal(s1, s2);
-	(void) unlink("pan.b");
-	(void) unlink("pan.c");
-	(void) unlink("pan.h");
-	(void) unlink("pan.m");
-	(void) unlink("pan.t");
-	(void) unlink("pan.pre");
-	alldone(1);
-}
-
-char *
-emalloc(size_t n)
-{	char *tmp;
-	static unsigned long cnt = 0;
-
-	if (n == 0)
-		return NULL;	/* robert shelton 10/20/06 */
-
-	if (!(tmp = (char *) malloc(n)))
-	{	printf("spin: allocated %ld Gb, wanted %d bytes more\n",
-			cnt/(1024*1024*1024), (int) n);
-		fatal("not enough memory", (char *)0);
-	}
-	cnt += (unsigned long) n;
-	memset(tmp, 0, n);
-	return tmp;
-}
-
-void
-trapwonly(Lextok *n /* , char *unused */)
-{	extern int realread;
-	int16_t i = (n->sym)?n->sym->type:0;
-
-	if (i != MTYPE
-	&&  i != BIT
-	&&  i != BYTE
-	&&  i != SHORT
-	&&  i != INT
-	&&  i != UNSIGNED)
-		return;
-
-	if (realread)
-	n->sym->hidden |= 128;	/* var is read at least once */
-}
-
-void
-setaccess(Symbol *sp, Symbol *what, int cnt, int t)
-{	Access *a;
-
-	for (a = sp->access; a; a = a->lnk)
-		if (a->who == context
-		&&  a->what == what
-		&&  a->cnt == cnt
-		&&  a->typ == t)
-			return;
-
-	a = (Access *) emalloc(sizeof(Access));
-	a->who = context;
-	a->what = what;
-	a->cnt = cnt;
-	a->typ = t;
-	a->lnk = sp->access;
-	sp->access = a;
-}
-
-Lextok *
-nn(Lextok *s, int t, Lextok *ll, Lextok *rl)
-{	Lextok *n = (Lextok *) emalloc(sizeof(Lextok));
-	static int warn_nn = 0;
-
-	n->uiid = is_inline();	/* record origin of the statement */
-	n->ntyp = (int16_t) t;
-	if (s && s->fn)
-	{	n->ln = s->ln;
-		n->fn = s->fn;
-	} else if (rl && rl->fn)
-	{	n->ln = rl->ln;
-		n->fn = rl->fn;
-	} else if (ll && ll->fn)
-	{	n->ln = ll->ln;
-		n->fn = ll->fn;
-	} else
-	{	n->ln = lineno;
-		n->fn = Fname;
-	}
-	if (s) n->sym  = s->sym;
-	n->lft  = ll;
-	n->rgt  = rl;
-	n->indstep = DstepStart;
-
-	if (t == TIMEOUT) Etimeouts++;
-
-	if (!context) return n;
-
-	if (t == 'r' || t == 's')
-		setaccess(n->sym, ZS, 0, t);
-	if (t == 'R')
-		setaccess(n->sym, ZS, 0, 'P');
-
-	if (context->name == claimproc)
-	{	int forbidden = separate;
-		switch (t) {
-		case ASGN:
-			printf("spin: Warning, never claim has side-effect\n");
-			break;
-		case 'r': case 's':
-			non_fatal("never claim contains i/o stmnts",(char *)0);
-			break;
-		case TIMEOUT:
-			/* never claim polls timeout */
-			if (Ntimeouts && Etimeouts)
-				forbidden = 0;
-			Ntimeouts++; Etimeouts--;
-			break;
-		case LEN: case EMPTY: case FULL:
-		case 'R': case NFULL: case NEMPTY:
-			/* status becomes non-exclusive */
-			if (n->sym && !(n->sym->xu&XX))
-			{	n->sym->xu |= XX;
-				if (separate == 2) {
-				printf("spin: warning, make sure that the S1 model\n");
-				printf("      also polls channel '%s' in its claim\n",
-				n->sym->name);
-			}	}
-			forbidden = 0;
-			break;
-		case 'c':
-			AST_track(n, 0);	/* register as a slice criterion */
-			/* fall thru */
-		default:
-			forbidden = 0;
-			break;
-		}
-		if (forbidden)
-		{	printf("spin: never, saw "); explain(t); printf("\n");
-			fatal("incompatible with separate compilation",(char *)0);
-		}
-	} else if ((t == ENABLED || t == PC_VAL) && !(warn_nn&t))
-	{	printf("spin: Warning, using %s outside never claim\n",
-			(t == ENABLED)?"enabled()":"pc_value()");
-		warn_nn |= t;
-	} else if (t == NONPROGRESS)
-	{	fatal("spin: Error, using np_ outside never claim\n",
-		       (char *)0);
-	}
-	return n;
-}
-
-Lextok *
-rem_lab(Symbol *a, Lextok *b, Symbol *c)	/* proctype name, pid, label name */
-{	Lextok *tmp1, *tmp2, *tmp3;
-
-	has_remote++;
-	c->type = LABEL;	/* refered to in global context here */
-	fix_dest(c, a);		/* in case target of rem_lab is jump */
-	tmp1 = nn(ZN, '?',   b, ZN); tmp1->sym = a;
-	tmp1 = nn(ZN, 'p', tmp1, ZN);
-	tmp1->sym = lookup("_p");
-	tmp2 = nn(ZN, NAME,  ZN, ZN); tmp2->sym = a;
-	tmp3 = nn(ZN, 'q', tmp2, ZN); tmp3->sym = c;
-	return nn(ZN, EQ, tmp1, tmp3);
-#if 0
-	      .---------------EQ-------.
-	     /                          \
-	   'p' -sym-> _p               'q' -sym-> c (label name)
-	   /                           /
-	 '?' -sym-> a (proctype)     NAME -sym-> a (proctype name)
-	 /
-	b (pid expr)
-#endif
-}
-
-Lextok *
-rem_var(Symbol *a, Lextok *b, Symbol *c, Lextok *ndx)
-{	Lextok *tmp1;
-
-	has_remote++;
-	has_remvar++;
-	dataflow = 0;	/* turn off dead variable resets 4.2.5 */
-	tmp1 = nn(ZN, '?', b, ZN); tmp1->sym = a;
-	tmp1 = nn(ZN, 'p', tmp1, ndx);
-	tmp1->sym = c;
-	return tmp1;
-#if 0
-	cannot refer to struct elements
-	only to scalars and arrays
-
-	    'p' -sym-> c (variable name)
-	    / \______  possible arrayindex on c
-	   /
-	 '?' -sym-> a (proctype)
-	 /
-	b (pid expr)
-#endif
-}
-
-void
-explain(int n)
-{	FILE *fd = stdout;
-	switch (n) {
-	default:	if (n > 0 && n < 256)
-				fprintf(fd, "'%c' = ", n);
-			fprintf(fd, "%d", n);
-			break;
-	case '\b':	fprintf(fd, "\\b"); break;
-	case '\t':	fprintf(fd, "\\t"); break;
-	case '\f':	fprintf(fd, "\\f"); break;
-	case '\n':	fprintf(fd, "\\n"); break;
-	case '\r':	fprintf(fd, "\\r"); break;
-	case 'c':	fprintf(fd, "condition"); break;
-	case 's':	fprintf(fd, "send"); break;
-	case 'r':	fprintf(fd, "recv"); break;
-	case 'R':	fprintf(fd, "recv poll %s", Operator); break;
-	case '@':	fprintf(fd, "@"); break;
-	case '?':	fprintf(fd, "(x->y:z)"); break;
-#if 1
-	case NEXT:	fprintf(fd, "X"); break;
-	case ALWAYS:	fprintf(fd, "[]"); break;
-	case EVENTUALLY: fprintf(fd, "<>"); break;
-	case IMPLIES:	fprintf(fd, "->"); break;
-	case EQUIV:	fprintf(fd, "<->"); break;
-	case UNTIL:	fprintf(fd, "U"); break;
-	case WEAK_UNTIL: fprintf(fd, "W"); break;
-	case IN: fprintf(fd, "%sin", Keyword); break;
-#endif
-	case ACTIVE:	fprintf(fd, "%sactive",	Keyword); break;
-	case AND:	fprintf(fd, "%s&&",	Operator); break;
-	case ASGN:	fprintf(fd, "%s=",	Operator); break;
-	case ASSERT:	fprintf(fd, "%sassert",	Function); break;
-	case ATOMIC:	fprintf(fd, "%satomic",	Keyword); break;
-	case BREAK:	fprintf(fd, "%sbreak",	Keyword); break;
-	case C_CODE:	fprintf(fd, "%sc_code",	Keyword); break;
-	case C_DECL:	fprintf(fd, "%sc_decl",	Keyword); break;
-	case C_EXPR:	fprintf(fd, "%sc_expr",	Keyword); break;
-	case C_STATE:	fprintf(fd, "%sc_state",Keyword); break;
-	case C_TRACK:	fprintf(fd, "%sc_track",Keyword); break;
-	case CLAIM:	fprintf(fd, "%snever",	Keyword); break;
-	case CONST:	fprintf(fd, "a constant"); break;
-	case DECR:	fprintf(fd, "%s--",	Operator); break;
-	case D_STEP:	fprintf(fd, "%sd_step",	Keyword); break;
-	case D_PROCTYPE: fprintf(fd, "%sd_proctype", Keyword); break;
-	case DO:	fprintf(fd, "%sdo",	Keyword); break;
-	case DOT:	fprintf(fd, "."); break;
-	case ELSE:	fprintf(fd, "%selse",	Keyword); break;
-	case EMPTY:	fprintf(fd, "%sempty",	Function); break;
-	case ENABLED:	fprintf(fd, "%senabled",Function); break;
-	case EQ:	fprintf(fd, "%s==",	Operator); break;
-	case EVAL:	fprintf(fd, "%seval",	Function); break;
-	case FI:	fprintf(fd, "%sfi",	Keyword); break;
-	case FULL:	fprintf(fd, "%sfull",	Function); break;
-	case GE:	fprintf(fd, "%s>=",	Operator); break;
-	case GOTO:	fprintf(fd, "%sgoto",	Keyword); break;
-	case GT:	fprintf(fd, "%s>",	Operator); break;
-	case HIDDEN:	fprintf(fd, "%shidden",	Keyword); break;
-	case IF:	fprintf(fd, "%sif",	Keyword); break;
-	case INCR:	fprintf(fd, "%s++",	Operator); break;
-	case INAME:	fprintf(fd, "inline name"); break;
-	case INLINE:	fprintf(fd, "%sinline",	Keyword); break;
-	case INIT:	fprintf(fd, "%sinit",	Keyword); break;
-	case ISLOCAL:	fprintf(fd, "%slocal",  Keyword); break;
-	case LABEL:	fprintf(fd, "a label-name"); break;
-	case LE:	fprintf(fd, "%s<=",	Operator); break;
-	case LEN:	fprintf(fd, "%slen",	Function); break;
-	case LSHIFT:	fprintf(fd, "%s<<",	Operator); break;
-	case LT:	fprintf(fd, "%s<",	Operator); break;
-	case MTYPE:	fprintf(fd, "%smtype",	Keyword); break;
-	case NAME:	fprintf(fd, "an identifier"); break;
-	case NE:	fprintf(fd, "%s!=",	Operator); break;
-	case NEG:	fprintf(fd, "%s! (not)",Operator); break;
-	case NEMPTY:	fprintf(fd, "%snempty",	Function); break;
-	case NFULL:	fprintf(fd, "%snfull",	Function); break;
-	case NON_ATOMIC: fprintf(fd, "sub-sequence"); break;
-	case NONPROGRESS: fprintf(fd, "%snp_",	Function); break;
-	case OD:	fprintf(fd, "%sod",	Keyword); break;
-	case OF:	fprintf(fd, "%sof",	Keyword); break;
-	case OR:	fprintf(fd, "%s||",	Operator); break;
-	case O_SND:	fprintf(fd, "%s!!",	Operator); break;
-	case PC_VAL:	fprintf(fd, "%spc_value",Function); break;
-	case PNAME:	fprintf(fd, "process name"); break;
-	case PRINT:	fprintf(fd, "%sprintf",	Function); break;
-	case PRINTM:	fprintf(fd, "%sprintm",	Function); break;
-	case PRIORITY:	fprintf(fd, "%spriority", Keyword); break;
-	case PROCTYPE:	fprintf(fd, "%sproctype",Keyword); break;
-	case PROVIDED:	fprintf(fd, "%sprovided",Keyword); break;
-	case RCV:	fprintf(fd, "%s?",	Operator); break;
-	case R_RCV:	fprintf(fd, "%s??",	Operator); break;
-	case RSHIFT:	fprintf(fd, "%s>>",	Operator); break;
-	case RUN:	fprintf(fd, "%srun",	Operator); break;
-	case SEP:	fprintf(fd, "token: ::"); break;
-	case SEMI:	fprintf(fd, ";"); break;
-	case SHOW:	fprintf(fd, "%sshow", Keyword); break;
-	case SND:	fprintf(fd, "%s!",	Operator); break;
-	case STRING:	fprintf(fd, "a string"); break;
-	case TRACE:	fprintf(fd, "%strace", Keyword); break;
-	case TIMEOUT:	fprintf(fd, "%stimeout",Keyword); break;
-	case TYPE:	fprintf(fd, "data typename"); break;
-	case TYPEDEF:	fprintf(fd, "%stypedef",Keyword); break;
-	case XU:	fprintf(fd, "%sx[rs]",	Keyword); break;
-	case UMIN:	fprintf(fd, "%s- (unary minus)", Operator); break;
-	case UNAME:	fprintf(fd, "a typename"); break;
-	case UNLESS:	fprintf(fd, "%sunless",	Keyword); break;
-	}
-}

+ 0 - 794
sys/src/cmd/spin/mesg.c

@@ -1,794 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: mesg.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include "y.tab.h"
-
-#ifndef MAXQ
-#define MAXQ	2500		/* default max # queues  */
-#endif
-
-extern RunList	*X;
-extern Symbol	*Fname;
-extern Lextok	*Mtype;
-extern int	verbose, TstOnly, s_trail, analyze, columns;
-extern int	lineno, depth, xspin, m_loss, jumpsteps;
-extern int	nproc, nstop;
-extern int16_t	Have_claim;
-
-Queue	*qtab = (Queue *) 0;	/* linked list of queues */
-Queue	*ltab[MAXQ];		/* linear list of queues */
-int	nqs = 0, firstrow = 1;
-char	Buf[4096];
-
-static Lextok	*n_rem = (Lextok *) 0;
-static Queue	*q_rem = (Queue  *) 0;
-
-static int	a_rcv(Queue *, Lextok *, int);
-static int	a_snd(Queue *, Lextok *);
-static int	sa_snd(Queue *, Lextok *);
-static int	s_snd(Queue *, Lextok *);
-extern void	sr_buf(int, int);
-extern void	sr_mesg(FILE *, int, int);
-extern void	putarrow(int, int);
-static void	sr_talk(Lextok *, int, char *, char *, int, Queue *);
-
-int
-cnt_mpars(Lextok *n)
-{	Lextok *m;
-	int i=0;
-
-	for (m = n; m; m = m->rgt)
-		i += Cnt_flds(m);
-	return i;
-}
-
-int
-qmake(Symbol *s)
-{	Lextok *m;
-	Queue *q;
-	int i;
-
-	if (!s->ini)
-		return 0;
-
-	if (nqs >= MAXQ)
-	{	lineno = s->ini->ln;
-		Fname  = s->ini->fn;
-		fatal("too many queues (%s)", s->name);
-	}
-	if (analyze && nqs >= 255)
-	{	fatal("too many channel types", (char *)0);
-	}
-
-	if (s->ini->ntyp != CHAN)
-		return eval(s->ini);
-
-	q = (Queue *) emalloc(sizeof(Queue));
-	q->qid    = ++nqs;
-	q->nslots = s->ini->val;
-	q->nflds  = cnt_mpars(s->ini->rgt);
-	q->setat  = depth;
-
-	i = max(1, q->nslots);	/* 0-slot qs get 1 slot minimum */
-
-	q->contents  = (int *) emalloc(q->nflds*i*sizeof(int));
-	q->fld_width = (int *) emalloc(q->nflds*sizeof(int));
-	q->stepnr = (int *)   emalloc(i*sizeof(int));
-
-	for (m = s->ini->rgt, i = 0; m; m = m->rgt)
-	{	if (m->sym && m->ntyp == STRUCT)
-			i = Width_set(q->fld_width, i, getuname(m->sym));
-		else
-			q->fld_width[i++] = m->ntyp;
-	}
-	q->nxt = qtab;
-	qtab = q;
-	ltab[q->qid-1] = q;
-
-	return q->qid;
-}
-
-int
-qfull(Lextok *n)
-{	int whichq = eval(n->lft)-1;
-
-	if (whichq < MAXQ && whichq >= 0 && ltab[whichq])
-		return (ltab[whichq]->qlen >= ltab[whichq]->nslots);
-	return 0;
-}
-
-int
-qlen(Lextok *n)
-{	int whichq = eval(n->lft)-1;
-
-	if (whichq < MAXQ && whichq >= 0 && ltab[whichq])
-		return ltab[whichq]->qlen;
-	return 0;
-}
-
-int
-q_is_sync(Lextok *n)
-{	int whichq = eval(n->lft)-1;
-
-	if (whichq < MAXQ && whichq >= 0 && ltab[whichq])
-		return (ltab[whichq]->nslots == 0);
-	return 0;
-}
-
-int
-qsend(Lextok *n)
-{	int whichq = eval(n->lft)-1;
-
-	if (whichq == -1)
-	{	printf("Error: sending to an uninitialized chan\n");
-		whichq = 0;
-		return 0;
-	}
-	if (whichq < MAXQ && whichq >= 0 && ltab[whichq])
-	{	ltab[whichq]->setat = depth;
-		if (ltab[whichq]->nslots > 0)
-			return a_snd(ltab[whichq], n);
-		else
-			return s_snd(ltab[whichq], n);
-	}
-	return 0;
-}
-
-int
-qrecv(Lextok *n, int full)
-{	int whichq = eval(n->lft)-1;
-
-	if (whichq == -1)
-	{	if (n->sym && !strcmp(n->sym->name, "STDIN"))
-		{	Lextok *m;
-
-			if (TstOnly) return 1;
-
-			for (m = n->rgt; m; m = m->rgt)
-			if (m->lft->ntyp != CONST && m->lft->ntyp != EVAL)
-			{	int c = getchar();
-				(void) setval(m->lft, c);
-			} else
-				fatal("invalid use of STDIN", (char *)0);
-
-			whichq = 0;
-			return 1;
-		}
-		printf("Error: receiving from an uninitialized chan %s\n",
-			n->sym?n->sym->name:"");
-		whichq = 0;
-		return 0;
-	}
-	if (whichq < MAXQ && whichq >= 0 && ltab[whichq])
-	{	ltab[whichq]->setat = depth;
-		return a_rcv(ltab[whichq], n, full);
-	}
-	return 0;
-}
-
-static int
-sa_snd(Queue *q, Lextok *n)	/* sorted asynchronous */
-{	Lextok *m;
-	int i, j, k;
-	int New, Old;
-
-	for (i = 0; i < q->qlen; i++)
-	for (j = 0, m = n->rgt; m && j < q->nflds; m = m->rgt, j++)
-	{	New = cast_val(q->fld_width[j], eval(m->lft), 0);
-		Old = q->contents[i*q->nflds+j];
-		if (New == Old)
-			continue;
-		if (New >  Old)
-			break;	/* inner loop */
-		goto found;	/* New < Old */
-	}
-found:
-	for (j = q->qlen-1; j >= i; j--)
-	for (k = 0; k < q->nflds; k++)
-	{	q->contents[(j+1)*q->nflds+k] =
-			q->contents[j*q->nflds+k];	/* shift up */
-		if (k == 0)
-			q->stepnr[j+1] = q->stepnr[j];
-	}
-	return i*q->nflds;				/* new q offset */
-}
-
-void
-typ_ck(int ft, int at, char *s)
-{
-	if ((verbose&32) && ft != at
-	&& (ft == CHAN || at == CHAN))
-	{	char buf[128], tag1[64], tag2[64];
-		(void) sputtype(tag1, ft);
-		(void) sputtype(tag2, at);
-		sprintf(buf, "type-clash in %s, (%s<-> %s)", s, tag1, tag2);
-		non_fatal("%s", buf);
-	}
-}
-
-static int
-a_snd(Queue *q, Lextok *n)
-{	Lextok *m;
-	int i = q->qlen*q->nflds;	/* q offset */
-	int j = 0;			/* q field# */
-
-	if (q->nslots > 0 && q->qlen >= q->nslots)
-		return m_loss;	/* q is full */
-
-	if (TstOnly) return 1;
-
-	if (n->val) i = sa_snd(q, n);	/* sorted insert */
-
-	q->stepnr[i/q->nflds] = depth;
-
-	for (m = n->rgt; m && j < q->nflds; m = m->rgt, j++)
-	{	int New = eval(m->lft);
-		q->contents[i+j] = cast_val(q->fld_width[j], New, 0);
-		if ((verbose&16) && depth >= jumpsteps)
-			sr_talk(n, New, "Send ", "->", j, q);
-		typ_ck(q->fld_width[j], Sym_typ(m->lft), "send");
-	}
-	if ((verbose&16) && depth >= jumpsteps)
-	{	for (i = j; i < q->nflds; i++)
-			sr_talk(n, 0, "Send ", "->", i, q);
-		if (j < q->nflds)
-			printf("%3d: warning: missing params in send\n",
-				depth);
-		if (m)
-			printf("%3d: warning: too many params in send\n",
-				depth);
-	}
-	q->qlen++;
-	return 1;
-}
-
-static int
-a_rcv(Queue *q, Lextok *n, int full)
-{	Lextok *m;
-	int i=0, oi, j, k;
-	extern int Rvous;
-
-	if (q->qlen == 0)
-		return 0;	/* q is empty */
-try_slot:
-	/* test executability */
-	for (m = n->rgt, j=0; m && j < q->nflds; m = m->rgt, j++)
-		if ((m->lft->ntyp == CONST
-		   && q->contents[i*q->nflds+j] != m->lft->val)
-		||  (m->lft->ntyp == EVAL
-		   && q->contents[i*q->nflds+j] != eval(m->lft->lft)))
-		{	if (n->val == 0		/* fifo recv */
-			||  n->val == 2		/* fifo poll */
-			|| ++i >= q->qlen)	/* last slot */
-				return 0;	/* no match  */
-			goto try_slot;
-		}
-	if (TstOnly) return 1;
-
-	if (verbose&8)
-	{	if (j < q->nflds)
-			printf("%3d: warning: missing params in next recv\n",
-				depth);
-		else if (m)
-			printf("%3d: warning: too many params in next recv\n",
-				depth);
-	}
-
-	/* set the fields */
-	if (Rvous)
-	{	n_rem = n;
-		q_rem = q;
-	}
-
-	oi = q->stepnr[i];
-	for (m = n->rgt, j = 0; m && j < q->nflds; m = m->rgt, j++)
-	{	if (columns && !full)	/* was columns == 1 */
-			continue;
-		if ((verbose&8) && !Rvous && depth >= jumpsteps)
-		{	sr_talk(n, q->contents[i*q->nflds+j],
-			(full && n->val < 2)?"Recv ":"[Recv] ", "<-", j, q);
-		}
-		if (!full)
-			continue;	/* test */
-		if (m && m->lft->ntyp != CONST && m->lft->ntyp != EVAL)
-		{	(void) setval(m->lft, q->contents[i*q->nflds+j]);
-			typ_ck(q->fld_width[j], Sym_typ(m->lft), "recv");
-		}
-		if (n->val < 2)		/* not a poll */
-		for (k = i; k < q->qlen-1; k++)
-		{	q->contents[k*q->nflds+j] =
-			  q->contents[(k+1)*q->nflds+j];
-			if (j == 0)
-			  q->stepnr[k] = q->stepnr[k+1];
-		}
-	}
-
-	if ((!columns || full)
-	&& (verbose&8) && !Rvous && depth >= jumpsteps)
-	for (i = j; i < q->nflds; i++)
-	{	sr_talk(n, 0,
-		(full && n->val < 2)?"Recv ":"[Recv] ", "<-", i, q);
-	}
-	if (columns == 2 && full && !Rvous && depth >= jumpsteps)
-		putarrow(oi, depth);
-
-	if (full && n->val < 2)
-		q->qlen--;
-	return 1;
-}
-
-static int
-s_snd(Queue *q, Lextok *n)
-{	Lextok *m;
-	RunList *rX, *sX = X;	/* rX=recvr, sX=sendr */
-	int i, j = 0;	/* q field# */
-
-	for (m = n->rgt; m && j < q->nflds; m = m->rgt, j++)
-	{	q->contents[j] = cast_val(q->fld_width[j], eval(m->lft), 0);
-		typ_ck(q->fld_width[j], Sym_typ(m->lft), "rv-send");
-	}
-	q->qlen = 1;
-	if (!complete_rendez())
-	{	q->qlen = 0;
-		return 0;
-	}
-	if (TstOnly)
-	{	q->qlen = 0;
-		return 1;
-	}
-	q->stepnr[0] = depth;
-	if ((verbose&16) && depth >= jumpsteps)
-	{	m = n->rgt;
-		rX = X; X = sX;
-		for (j = 0; m && j < q->nflds; m = m->rgt, j++)
-			sr_talk(n, eval(m->lft), "Sent ", "->", j, q);
-		for (i = j; i < q->nflds; i++)
-			sr_talk(n, 0, "Sent ", "->", i, q);
-		if (j < q->nflds)
-			  printf("%3d: warning: missing params in rv-send\n",
-				depth);
-		else if (m)
-			  printf("%3d: warning: too many params in rv-send\n",
-				depth);
-		X = rX;	/* restore receiver's context */
-		if (!s_trail)
-		{	if (!n_rem || !q_rem)
-				fatal("cannot happen, s_snd", (char *) 0);
-			m = n_rem->rgt;
-			for (j = 0; m && j < q->nflds; m = m->rgt, j++)
-			{	if (m->lft->ntyp != NAME
-				||  strcmp(m->lft->sym->name, "_") != 0)
-					i = eval(m->lft);
-				else	i = 0;
-
-				if (verbose&8)
-				sr_talk(n_rem,i,"Recv ","<-",j,q_rem);
-			}
-			if (verbose&8)
-			for (i = j; i < q->nflds; i++)
-				sr_talk(n_rem, 0, "Recv ", "<-", j, q_rem);
-			if (columns == 2)
-				putarrow(depth, depth);
-		}
-		n_rem = (Lextok *) 0;
-		q_rem = (Queue *) 0;
-	}
-	return 1;
-}
-
-static void
-channm(Lextok *n)
-{	char lbuf[512];
-
-	if (n->sym->type == CHAN)
-		strcat(Buf, n->sym->name);
-	else if (n->sym->type == NAME)
-		strcat(Buf, lookup(n->sym->name)->name);
-	else if (n->sym->type == STRUCT)
-	{	Symbol *r = n->sym;
-		if (r->context)
-		{	r = findloc(r);
-			if (!r)
-			{	strcat(Buf, "*?*");
-				return;
-		}	}
-		ini_struct(r);
-		printf("%s", r->name);
-		strcpy(lbuf, "");
-		struct_name(n->lft, r, 1, lbuf);
-		strcat(Buf, lbuf);
-	} else
-		strcat(Buf, "-");
-	if (n->lft->lft)
-	{	sprintf(lbuf, "[%d]", eval(n->lft->lft));
-		strcat(Buf, lbuf);
-	}
-}
-
-static void
-difcolumns(Lextok *n, char *tr, int v, int j, Queue *q)
-{	extern int pno;
-
-	if (j == 0)
-	{	Buf[0] = '\0';
-		channm(n);
-		strcat(Buf, (strncmp(tr, "Sen", 3))?"?":"!");
-	} else
-		strcat(Buf, ",");
-	if (tr[0] == '[') strcat(Buf, "[");
-	sr_buf(v, q->fld_width[j] == MTYPE);
-	if (j == q->nflds - 1)
-	{	int cnr;
-		if (s_trail) cnr = pno; else cnr = X?X->pid - Have_claim:0;
-		if (tr[0] == '[') strcat(Buf, "]");
-		pstext(cnr, Buf);
-	}
-}
-
-static void
-docolumns(Lextok *n, char *tr, int v, int j, Queue *q)
-{	int i;
-
-	if (firstrow)
-	{	printf("q\\p");
-		for (i = 0; i < nproc-nstop - Have_claim; i++)
-			printf(" %3d", i);
-		printf("\n");
-		firstrow = 0;
-	}
-	if (j == 0)
-	{	printf("%3d", q->qid);
-		if (X)
-		for (i = 0; i < X->pid - Have_claim; i++)
-			printf("   .");
-		printf("   ");
-		Buf[0] = '\0';
-		channm(n);
-		printf("%s%c", Buf, (strncmp(tr, "Sen", 3))?'?':'!');
-	} else
-		printf(",");
-	if (tr[0] == '[') printf("[");
-	sr_mesg(stdout, v, q->fld_width[j] == MTYPE);
-	if (j == q->nflds - 1)
-	{	if (tr[0] == '[') printf("]");
-		printf("\n");
-	}
-}
-
-typedef struct QH {
-	int	n;
-	struct	QH *nxt;
-} QH;
-static QH *qh;
-
-void
-qhide(int q)
-{	QH *p = (QH *) emalloc(sizeof(QH));
-	p->n = q;
-	p->nxt = qh;
-	qh = p;
-}
-
-int
-qishidden(int q)
-{	QH *p;
-	for (p = qh; p; p = p->nxt)
-		if (p->n == q)
-			return 1;
-	return 0;
-}
-
-static void
-sr_talk(Lextok *n, int v, char *tr, char *a, int j, Queue *q)
-{	char s[128];
-
-	if (qishidden(eval(n->lft)))
-		return;
-
-	if (columns)
-	{	if (columns == 2)
-			difcolumns(n, tr, v, j, q);
-		else
-			docolumns(n, tr, v, j, q);
-		return;
-	}
-	if (xspin)
-	{	if ((verbose&4) && tr[0] != '[')
-		sprintf(s, "(state -)\t[values: %d",
-			eval(n->lft));
-		else
-		sprintf(s, "(state -)\t[%d", eval(n->lft));
-		if (strncmp(tr, "Sen", 3) == 0)
-			strcat(s, "!");
-		else
-			strcat(s, "?");
-	} else
-	{	strcpy(s, tr);
-	}
-
-	if (j == 0)
-	{	char snm[128];
-		whoruns(1);
-		{	char *ptr = n->fn->name;
-			char *qtr = snm;
-			while (*ptr != '\0')
-			{	if (*ptr != '\"')
-				{	*qtr++ = *ptr;
-				}
-				ptr++;
-			}
-			*qtr = '\0';
-			printf("%s:%d %s",
-				snm, n->ln, s);
-		}
-	} else
-		printf(",");
-	sr_mesg(stdout, v, q->fld_width[j] == MTYPE);
-
-	if (j == q->nflds - 1)
-	{	if (xspin)
-		{	printf("]\n");
-			if (!(verbose&4)) printf("\n");
-			return;
-		}
-		printf("\t%s queue %d (", a, eval(n->lft));
-		Buf[0] = '\0';
-		channm(n);
-		printf("%s)\n", Buf);
-	}
-	fflush(stdout);
-}
-
-void
-sr_buf(int v, int j)
-{	int cnt = 1; Lextok *n;
-	char lbuf[512];
-
-	for (n = Mtype; n && j; n = n->rgt, cnt++)
-		if (cnt == v)
-		{	if(strlen(n->lft->sym->name) >= sizeof(lbuf))
-			{	non_fatal("mtype name %s too long", n->lft->sym->name);
-				break;
-			}
-			sprintf(lbuf, "%s", n->lft->sym->name);
-			strcat(Buf, lbuf);
-			return;
-		}
-	sprintf(lbuf, "%d", v);
-	strcat(Buf, lbuf);
-}
-
-void
-sr_mesg(FILE *fd, int v, int j)
-{	Buf[0] ='\0';
-	sr_buf(v, j);
-	fprintf(fd, Buf);
-}
-
-void
-doq(Symbol *s, int n, RunList *r)
-{	Queue *q;
-	int j, k;
-
-	if (!s->val)	/* uninitialized queue */
-		return;
-	for (q = qtab; q; q = q->nxt)
-	if (q->qid == s->val[n])
-	{	if (xspin > 0
-		&& (verbose&4)
-		&& q->setat < depth)
-			continue;
-		if (q->nslots == 0)
-			continue; /* rv q always empty */
-#if 0
-		if (q->qlen == 0)	/* new 7/10 -- dont show if queue is empty */
-		{	continue;
-		}
-#endif
-		printf("\t\tqueue %d (", q->qid);
-		if (r)
-		printf("%s(%d):", r->n->name, r->pid - Have_claim);
-		if (s->nel > 1 || s->isarray)
-		  printf("%s[%d]): ", s->name, n);
-		else
-		  printf("%s): ", s->name);
-		for (k = 0; k < q->qlen; k++)
-		{	printf("[");
-			for (j = 0; j < q->nflds; j++)
-			{	if (j > 0) printf(",");
-				sr_mesg(stdout, q->contents[k*q->nflds+j],
-					q->fld_width[j] == MTYPE);
-			}
-			printf("]");
-		}
-		printf("\n");
-		break;
-	}
-}
-
-void
-nochan_manip(Lextok *p, Lextok *n, int d)
-{	int e = 1;
-
-	if (d == 0 && p->sym && p->sym->type == CHAN)
-	{	setaccess(p->sym, ZS, 0, 'L');
-
-		if (n && n->ntyp == CONST)
-			fatal("invalid asgn to chan", (char *) 0);
-
-		if (n && n->sym && n->sym->type == CHAN)
-		{	setaccess(n->sym, ZS, 0, 'V');
-			return;
-		}
-	}
-
-	/* ok on the rhs of an assignment: */
-	if (!n || n->ntyp == LEN || n->ntyp == RUN
-	||  n->ntyp == FULL  || n->ntyp == NFULL
-	||  n->ntyp == EMPTY || n->ntyp == NEMPTY)
-		return;
-
-	if (n->sym && n->sym->type == CHAN)
-	{	if (d == 1)
-			fatal("invalid use of chan name", (char *) 0);
-		else
-			setaccess(n->sym, ZS, 0, 'V');
-	}
-
-	if (n->ntyp == NAME
-	||  n->ntyp == '.')
-		e = 0;	/* array index or struct element */
-
-	nochan_manip(p, n->lft, e);
-	nochan_manip(p, n->rgt, 1);
-}
-
-typedef struct BaseName {
-	char *str;
-	int cnt;
-	struct BaseName *nxt;
-} BaseName;
-BaseName *bsn;
-
-void
-newbasename(char *s)
-{	BaseName *b;
-
-/*	printf("+++++++++%s\n", s);	*/
-	for (b = bsn; b; b = b->nxt)
-		if (strcmp(b->str, s) == 0)
-		{	b->cnt++;
-			return;
-		}
-	b = (BaseName *) emalloc(sizeof(BaseName));
-	b->str = emalloc(strlen(s)+1);
-	b->cnt = 1;
-	strcpy(b->str, s);
-	b->nxt = bsn;
-	bsn = b;
-}
-
-void
-delbasename(char *s)
-{	BaseName *b, *prv = (BaseName *) 0;
-
-	for (b = bsn; b; prv = b, b = b->nxt)
-	{	if (strcmp(b->str, s) == 0)
-		{	b->cnt--;
-			if (b->cnt == 0)
-			{	if (prv)
-				{	prv->nxt = b->nxt;
-				} else
-				{	bsn = b->nxt;
-			}	}
-/*	printf("---------%s\n", s);	*/
-			break;
-	}	}
-}
-
-void
-checkindex(char *s, char *t)
-{	BaseName *b;
-
-/*	printf("xxx Check %s (%s)\n", s, t);	*/
-	for (b = bsn; b; b = b->nxt)
-	{
-/*		printf("	%s\n", b->str);	*/
-		if (strcmp(b->str, s) == 0)
-		{	non_fatal("do not index an array with itself (%s)", t);
-			break;
-	}	}
-}
-
-void
-scan_tree(Lextok *t, char *mn, char *mx)
-{	char sv[512];
-	char tmp[32];
-	int oln = lineno;
-
-	if (!t) return;
-
-	lineno = t->ln;
-
-	if (t->ntyp == NAME)
-	{	strcat(mn, t->sym->name);
-		strcat(mx, t->sym->name);
-		if (t->lft)		/* array index */
-		{	strcat(mn, "[]");
-			newbasename(mn);
-				strcpy(sv, mn);		/* save */
-				strcpy(mn, "");		/* clear */
-				strcat(mx, "[");
-				scan_tree(t->lft, mn, mx);	/* index */
-				strcat(mx, "]");
-				checkindex(mn, mx);	/* match against basenames */
-				strcpy(mn, sv);		/* restore */
-			delbasename(mn);
-		}
-		if (t->rgt)	/* structure element */
-		{	scan_tree(t->rgt, mn, mx);
-		}
-	} else if (t->ntyp == CONST)
-	{	strcat(mn, "1"); /* really: t->val */
-		sprintf(tmp, "%d", t->val);
-		strcat(mx, tmp);
-	} else if (t->ntyp == '.')
-	{	strcat(mn, ".");
-		strcat(mx, ".");
-		scan_tree(t->lft, mn, mx);
-	} else
-	{	strcat(mn, "??");
-		strcat(mx, "??");
-	}
-	lineno = oln;
-}
-
-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];
-
-/*	printf("==================================ZAP\n");	*/
-	bsn = (BaseName *) 0;	/* start new list */
-	strcpy(mn, "");
-	strcpy(mx, "");
-
-	scan_tree(n, mn, mx);
-/*	printf("==> %s\n", mn);	*/
-}
-
-void
-no_internals(Lextok *n)
-{	char *sp;
-
-	if (!n->sym
-	||  !n->sym->name)
-		return;
-
-	sp = n->sym->name;
-
-	if ((strlen(sp) == strlen("_nr_pr") && strcmp(sp, "_nr_pr") == 0)
-	||  (strlen(sp) == strlen("_p") && strcmp(sp, "_p") == 0))
-	{	fatal("attempt to assign value to system variable %s", sp);
-	}
-
-	no_nested_array_refs(n);
-}

+ 0 - 57
sys/src/cmd/spin/mkfile

@@ -1,57 +0,0 @@
-</$objtype/mkfile
-
-TARG=spin
-
-SPIN_OS=\
-	dstep.$O\
-	flow.$O\
-	guided.$O\
-	main.$O\
-	mesg.$O\
-	pangen1.$O\
-	pangen2.$O\
-	pangen3.$O\
-	pangen4.$O\
-	pangen5.$O\
-	pangen6.$O\
-	pangen7.$O\
-	pc_zpp.$O\
-	ps_msc.$O\
-	reprosrc.$O\
-	run.$O\
-	sched.$O\
-	spinlex.$O\
-	structs.$O\
-	sym.$O\
-	vars.$O\
-	y.tab.$O\
-
-TL_OS=\
-	tl_buchi.$O\
-	tl_cache.$O\
-	tl_lex.$O\
-	tl_main.$O\
-	tl_mem.$O\
-	tl_parse.$O\
-	tl_rewrt.$O\
-	tl_trans.$O\
-
-OFILES=$SPIN_OS $TL_OS
-
-YFILES=spin.y
-
-HFILES=y.tab.h
-
-BIN=/$objtype/bin
-</sys/src/cmd/mkone
-
-CC=pcc -c
-CFLAGS=-B -D_POSIX_SOURCE
-YFLAGS=-S -d
-
-$SPIN_OS:	spin.h
-$TL_OS:		tl.h
-
-main.$O pangen2.$O ps_msc.$O:	version.h
-pangen1.$O:			pangen1.h pangen3.h
-pangen2.$O:			pangen2.h pangen4.h pangen5.h pangen6.h

File diff suppressed because it is too large
+ 0 - 1538
sys/src/cmd/spin/pangen1.c


File diff suppressed because it is too large
+ 0 - 7309
sys/src/cmd/spin/pangen1.h


File diff suppressed because it is too large
+ 0 - 3203
sys/src/cmd/spin/pangen2.c


File diff suppressed because it is too large
+ 0 - 1162
sys/src/cmd/spin/pangen2.h


+ 0 - 439
sys/src/cmd/spin/pangen3.c

<
@@ -1,439 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: pangen3.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include "y.tab.h"
-
-extern FILE	*th;
-extern int	eventmapnr;
-
-typedef struct SRC {
-	int ln, st;	/* linenr, statenr */
-	Symbol *fn;	/* filename */
-	struct SRC *nxt;
-} SRC;
-
-static int	col;
-static Symbol	*lastfnm;
-static Symbol	lastdef;
-static int	lastfrom;
-static SRC	*frst = (SRC *) 0;
-static SRC	*skip = (SRC *) 0;
-
-extern int	ltl_mode;
-
-extern void	sr_mesg(FILE *, int, int);
-
-static void
-putnr(int n)
-{
-	if (col++ == 8)
-	{	fprintf(th, "\n\t");
-		col = 1;
-	}
-	fprintf(th, "%3d, ", n);
-}
-
-static void
-putfnm(int j, Symbol *s)
-{
-	if (lastfnm && lastfnm == s && j != -1)
-		return;
-
-	if (lastfnm)
-		fprintf(th, "{ \"%s\", %d, %d },\n\t",
-			lastfnm->name,
-			lastfrom,
-			j-1);
-	lastfnm = s;
-	lastfrom = j;
-}
-
-static void
-putfnm_flush(int j)
-{
-	if (lastfnm)
-		fprintf(th, "{ \"%s\", %d, %d }\n",
-			lastfnm->name,
-			lastfrom, j);
-}
-
-void
-putskip(int m)	/* states that need not be reached */
-{	SRC *tmp;
-
-	for (tmp = skip; tmp; tmp = tmp->nxt)
-		if (tmp->st == m)
-			return;
-	tmp = (SRC *) emalloc(sizeof(SRC));