Commit Graph

1781 Commits

Author SHA1 Message Date
Neil Brown
426064ba2d Fixed some failing tests due to a change in the sequential edge labels in the flow graph (just the while tests) 2008-09-11 16:10:30 +00:00
Adam Sampson
3eeda5d821 Add a unit tests file for SimplifyTypes.
The tests in there at the moment are pretty trivial, but I'm going to
want to add more stuff to SimplifyTypes later.
2008-06-11 15:56:24 +00:00
Adam Sampson
8545b08aee Tidy up resolveNamedTypes. 2008-06-11 15:46:11 +00:00
Adam Sampson
f102d8e7ef Make "PORT" work for "PORT OF". 2008-06-11 13:18:54 +00:00
Adam Sampson
87848ad7db Make the TypeSet representation a bit smarter.
It used to just be the list of target type keys. It's now a map from
all possible type keys to a precomputed hit/through/miss decision for
them. gmapMFor can therefore dig into "through" types without needing
to (fail to) apply the generic function first.

This makes less difference than I was expecting: it shaves the time
for cgtest24 from 2m30 down to 2m15.
2008-06-11 12:05:39 +00:00
Adam Sampson
7a11d0b2c3 Include TypeSet in OpsM.
This means the TypeSet is only rebuilt when the ops are extended, not
each time the operation is applied (curse the unpredictability of
Haskell CAF optimisation).
2008-06-11 12:04:06 +00:00
Adam Sampson
02c444be95 Update abbrevation types in the state too.
This makes cgtest82 work, although I'm not very happy with it as a fix. I'd
rather have a way of ensuring the state's definitions are kept up to date when
we change something in the AST.
2008-06-10 13:57:01 +00:00
Adam Sampson
638a3f3c22 Allow a directed channel array to be sliced.
This lets you write things like "[cs! FOR 5]", which is horrible; I
would prefer "[cs FOR 5]!", since then that doesn't imply that you can
do things like "cs![0] ! 0".

However, Tock now compiles and passes cgtest87 -- the first occam-pi
cgtest we've handled. :)
2008-06-09 21:42:34 +00:00
Adam Sampson
62a0873d3d Implement channel direction decorators.
This is mostly straightforward: modify the parser to allow direction
decorators in the right places, and extend the type checker to match.
There's some slight awkwardness in that some of the Types functions
have to perform the same checks as the type checker (e.g. directing a
non-channel), so I've tidied up their error messages a bit.

At the backend, I've just added a little pass to strip out all the
DirectedVariables, since the other backend passes don't handle them
gracefully. From the occam/C point of view this is fine, but I'm not
sure if it's going to cause problems for C++.
2008-06-09 21:35:20 +00:00
Adam Sampson
04f72a62db Handle IsChannelArray when adding _sizes.
This also refactors the sizes-array-declaring code, pulling the
declaration of static sizes out to a helper function, and does a
couple of other minor cleanups to match.
2008-06-09 21:32:04 +00:00
Adam Sampson
ad875bd477 Fix abbreviation of channel ends in the C backend.
I'm pretty sure this test used to fail and got fixed, but I think the
test was fixed to match the incorrect code rather than the other way
around. What it's testing is the abbreviation of a channel end as an
identically-typed channel end, which (since they're both pointers)
should look something like:

Channel *c;
Channel *d = c;

Instead it was generating "d = &c", which broke cgtest87.

The change made to GenerateC to fix this feels a bit awkward to me --
it's very simple, but it's yet another special case in genVariableAM.
All of the genVariable code could really use reworking (again),
perhaps to use some internal representation of the C expression...
2008-06-09 21:19:01 +00:00
Adam Sampson
19484ec72e Show channel attributes in occam code. 2008-06-09 12:36:26 +00:00
Adam Sampson
23e1ba2eec Remove an "in the future" comment that's been done. 2008-06-06 10:15:43 +00:00
Neil Brown
c711dcd7fe Filled in getVarSpec, to record the variables read from and written to in specifications 2008-06-07 20:30:24 +00:00
Neil Brown
e39ebf5962 Added support for using the constraints in the background knowledge for the usage checking 2008-06-07 20:29:48 +00:00
Neil Brown
2a56189d30 Added an additional testcase for conditions in the usage checking 2008-06-07 20:29:21 +00:00
Neil Brown
70139ad072 Added support for recording conditional expressions in the flow graph (based on IF and WHILE, at least) 2008-06-07 20:28:04 +00:00
Neil Brown
6f23920e69 Added a function to find all the logical constraints that must hold at a certain point in the program, based on the flow graph 2008-06-07 20:26:29 +00:00
Neil Brown
a594d5f4e8 Stopped the expression flattener from stopping on an unrecognised dyadic operator, and instead made it record the expression unflattened 2008-06-07 20:13:36 +00:00
Neil Brown
3a5881c14f Added an optional flag to the ESeq edge label, ready to be used to indicate whether a condition was true on this branch or not 2008-06-06 18:34:50 +00:00
Neil Brown
cbe460f306 Added a new part to UsageLabel for conditions in nodes, and added a new corresponding labelling function for nodes 2008-06-06 18:32:47 +00:00
Neil Brown
fe1238d379 Added a helper operator to make the FlowGraph module a bit more readable 2008-06-06 18:23:03 +00:00
Neil Brown
d3c9d90f8d Corrected a bug when wiring up specifications (specifically inside ALTs) in the flow graph 2008-06-06 16:06:03 +00:00
Neil Brown
4c5067e8b1 Fixed some Rain tests broken by recent changes 2008-06-06 10:49:29 +00:00
Neil Brown
5ef075e5d2 Added background knowledge based on replicator bounds 2008-06-06 10:45:46 +00:00
Neil Brown
7538fcc225 Reindented some code in ArrayUsageCheck (just tidying up) 2008-06-06 10:44:05 +00:00
Neil Brown
b603b43b57 Added a subOne function (the dual of addOne) to the Types module 2008-06-06 10:43:30 +00:00
Neil Brown
cb6fb40440 Added some more testcases involving deduction from (sequential) replicator bounds 2008-06-06 10:39:12 +00:00
Neil Brown
b9b025a429 Added some tests for the new usage checking and reachability mechanisms 2008-06-05 23:11:00 +00:00
Neil Brown
78a513a852 Implemented addBK, at least for assignments 2008-06-05 23:10:30 +00:00
Neil Brown
d75bca3c0d Added a couple of new helper functions to the Utils module 2008-06-05 23:09:46 +00:00
Neil Brown
ca8c6f14ce Cleaned up some code in ArrayUsageCheck that is uncommented when bugs appear 2008-06-05 23:09:01 +00:00
Neil Brown
c9da4a7eaf Overhauled the way that the array usage checking deals with background knowledge, ready to implement usage checking that makes proper use of background knowledge (information from elsewhere in the program) 2008-06-05 20:37:59 +00:00
Neil Brown
cf35eb97d3 Corrected a couple of uses of flowAlgorithm to use the connected nodes, not all the remaining nodes in the graph 2008-06-05 20:35:43 +00:00
Neil Brown
7e0bc775bf Changed the writtenVars entry of Vars to be a map from variables to (assigned-from) expressions
The expressions are optional (wrapped in a Maybe type)
2008-06-05 20:30:44 +00:00
Neil Brown
d9e8c7fc87 Changed findReachDef to return a map from nodes to expressions rather than previous nodes
The expressions are optional (wrapped in a Maybe type).  Nothing indicates that the variable was written to, but that the value isn't available.  This is usually the case (for example, process parameters, channel inputs).

I have also temporarily disabled the tests for this function
2008-06-05 20:30:06 +00:00
Neil Brown
17255bb2b1 Changed the uses of flowAlgorithm to make better use of userErrLabel to give better error messages 2008-06-05 20:22:47 +00:00
Neil Brown
24b10deb33 Realised that ParItems is a functor, and therefore made it an instance of such 2008-06-05 20:17:25 +00:00
Neil Brown
936382a3ca Renamed labelFunctions to labelUsageFunctions, to make it clearer what the functions are for 2008-06-05 20:16:02 +00:00
Neil Brown
ac3d1ed42a Reordered the type parameters for the FNode' type in the flow graph, and made it a functor over the label 2008-06-05 20:11:13 +00:00
Neil Brown
64e86b22fe Fixed some StructureOccam tests that were broken recently by the change in the Token type 2008-06-06 13:14:34 +00:00
Adam Sampson
ab416326ad Make Token a real data type.
Previously it was a tuple, which meant it couldn't have sensible
custom instances. Token and TokenType now have Show instances, so we
get more useful output when parsing fails.
2008-06-05 09:46:52 +00:00
Neil Brown
069cfd9a9f Fixed the pulling up of replicators when they are free names (something that was broken in the original Rep change) 2008-06-04 19:06:05 +00:00
Neil Brown
e2dac3aa76 Simplified freeNamesIn by removing what is an unnecessary case for replicators 2008-06-04 19:05:31 +00:00
Neil Brown
cfbdfc555e Fixed a discrepancy between the C and C++ backends over generating the code for replicators 2008-06-04 18:53:42 +00:00
Neil Brown
4c726352a4 Removed an obsolete failing Rain test 2008-06-04 18:44:07 +00:00
Neil Brown
5bc88ec1fc Fixed another test that was broken during the change to Rep 2008-06-04 18:43:50 +00:00
Neil Brown
a417708cda Fixed some of the flow graph tests that were broken by the change to Rep 2008-06-04 18:32:16 +00:00
Neil Brown
41ff60cb78 Removed the Rep constructor from Structured and instead added a Rep constructor to SpecType
This way, all replicators are declared like other names, and their scope is considered replicated.  This simplifies the code a little.

Fixes #55
2008-06-04 17:00:43 +00:00
Neil Brown
9066d4112b Removed all the PassR and PassMR stuff, now we just have Pass and PassM 2008-06-03 16:30:10 +00:00