I have added two helper functions, but since they are used in contexts that are already specific to C++CSP (i.e. the channel-ends have the ">>" and "<<" operators applied to them) I have not added them to the dictionary of functions.
This patch allows C++CSP to actually use the direction of channels to pass around channel-ends rather than channel pointers, just as C++CSP was designed for.
As Neil pointed out, I'd already added some rules to PrettyShow to handle the
Maps in CompState; this does the same for the Sets, which means it's pshow-able
again.
Neil spotted that I'd broken the C++CSP backend with these changes, and I
wasn't very happy with what I'd done anyway, so this is take 2. Now there's a
separate pass that runs before GenerateC which builds a set of functions used
in PARs.
Since the set of passes that runs now depends on several variables, there's now
an expression which builds a list of passes to run; this should be easier to
extend in the future.
This is similar (but not identical) to the change Adam was doing at the same type for occam.
I think the main difference is that rather than returning () from parsing a reserved word,
I return Meta so that you can easily write rules like:
do { m <- sSemiColon ; return $ A.Skip m}
The tests have also been updated to use the new parser, and fail on either a lexing or a
parsing error.
This is the code that expands array and record assignments out into multiple
assignments. Having it done as a pass means it can do a better job -- this
fixes some problems with cgtest56 where the old version of the code couldn't
handle record assignments from literals.
This is the first pass that's had to add a replicator to the tree, so this also
introduces a helper function for generating new replicator counters.
CompState now contains Sets and Maps, which aren't instances of Data and thus
break pshow. This could be fixed in the future by providing instance
definitions, assuming the GHC library maintainers don't beat us to it.
This means that field names end up as "foo_u123" rather than "foo" in the
generated source -- which is a good thing, because some of the cgtests use
field names like "bool" and "int".
This fixes a bug that cgtest56 exposed, where an array of a user-defined type
that was itself an array wound up being an array of arrays rather than a single
array.
As part of this, makeArrayType is now called addDimensions, and takes a list of
dimensions to add rather than just one.
isValidLiteralType was a bit too simplistic before; it needs to look at array
types one dimension at a time rather than trying to do the whole lot at once.
The types have been added to the AST. Beyond the obvious trivial changes (extra cases in functions, etc), the only
significant change was that isSafeConversion needed to be changed. I took the opportunity to totally rewrite the
function into a graph-like mechanism rather than just using a list. To demonstrate its correctness I also wrote an
exhaustive test for it.
This also makes sure that every function gets a stack size constant.
There are some functions which don't do any stack adjustment -- where GCC's
smart enough to just compile them to a "ret" (because it knows it needs a
function pointer, but also that the function does nothing). CCSP doesn't like
it when you ask for a stack size of 0; I haven't yet investigated why, but this is likely to change anyway once Carl's changes go into CCSP trunk.