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.
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).
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.
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. :)
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++.
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.
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...
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
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.