Commit Graph

295 Commits

Author SHA1 Message Date
Neil Brown
1f4796e07f Fixed all the tests to reflect the new channel-end system, such that they all pass again
This is the last patch (for now) of the set implementing the new channel-end system
2009-01-20 17:41:44 +00:00
Neil Brown
a416f7dac9 Fixed the occam type-checker to work with the new channel-ends, adding direction specifiers where necessary
In actual parameters (checking against the formal type), abbreviations (checking against the inferred/specified destination type), and inputs (including inside ALTs) and outputs, direction specifiers are automatically added where needed.  With all the other changes, this seems to compile all the occam 2 cgtests, and cgtest87 (which tests directions) as well as Adam's tests so I'm fairly confident that it was the right thing to do.
2009-01-20 17:30:17 +00:00
Neil Brown
4d692c8897 Fixed the occam and Rain parsers to work with the new channel-ends
For now, I have fixed the occam parser so that it allows 1 or more direction specifiers after channel names.  So c?? is valid, and should end up being equivalent to c?, but this may need altering later.
2009-01-20 17:28:57 +00:00
Neil Brown
8a36f6e96f Added support for parsing pragmas, for now just handling the SHARED pragma 2009-01-19 15:11:09 +00:00
Neil Brown
46a1cc311f Moved a couple of fields related to Rain type checking out of CompState and into a temporary StateT monad for the appropriate pass 2008-12-02 20:59:26 +00:00
Neil Brown
0e7a6c5b98 Added a NameSource field for NameDef that indicates where a name comes from 2008-11-25 17:36:42 +00:00
Neil Brown
0d486f108f Added a value to indicate what type a warning is (to support future configurability) and streamlined the warning functions 2008-11-13 15:36:22 +00:00
Neil Brown
192ccd4e2c Extended the type unification for Rain to support type-checking things that are being poisoned (which could be either end of a channel) 2008-09-12 14:40:04 +00:00
Neil Brown
4c263dba7e Added support for poison to the lexer and parser (and associated tests) 2008-09-12 14:39:57 +00:00
Adam Sampson
f102d8e7ef Make "PORT" work for "PORT OF". 2008-06-11 13:18:54 +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
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
4c726352a4 Removed an obsolete failing Rain test 2008-06-04 18:44:07 +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
21329287e2 Fixed a problem with GHC 6.6 and the new pass mechanism by removing all the dollars that were confusing the type-checker 2008-06-03 16:16:26 +00:00
Adam Sampson
6ee21f76c9 Initial work on supporting INITIAL and RESULT abbreviations.
This fixes the AST, parser and typechecker, and adds a pass to
transform Result back into Abbrev, but doesn't transform Initial yet.
(It actually works for trivial stuff anyway, but it won't do the right
thing for complex types or PROC parameters.)

It appears (to me) to make sense to support INITIAL/RESULT reshaping
and retyping too, so this does.

Refs #42.
2008-06-02 20:41:37 +00:00
Neil Brown
ba66cce89f Moved all the remaining pass information to be with the passes themselves, and adjusted the tests accordingly
All the passes now have their information (name, pre-requisites and post- properties) stored at the point where the pass is declared, which means the pass lists are just a simple list of pass functions.

The main consequence of this change was that the tests had to be changed.  Now, instead of taking a "pass applied to data" item (type: PassM b), they take both the pass (type: Pass) and source data (type: b), and apply them later.  This was the decision that involved the simplest changes to the existing tests (simply unbracketing the application of the pass to the source).  I also had to include a few old-style versions though (testPass', testPassShouldFail') for where the functions were being used to test things that weren't actually passes (mainly StructureOccam).

Fixes #48
2008-06-02 14:31:19 +00:00
Neil Brown
0adbdda126 Moved all the pass information about the Rain passes into their definition (rather than the pass list at the top)
As part of this patch, I have also introduced a helper function that fiddles the type system for those passes that must run at the top-level (i.e. on A.AST) rather than on any Data t.  They will give an error if not applied at the top-level.
2008-06-02 12:51:14 +00:00
Adam Sampson
cf79f9c284 Get rid of the nasty ghost names hack.
Rather than prefixing the names, there's now a set of ghost names in
CompState.

Fixes #66.
2008-06-02 10:58:26 +00:00
Adam Sampson
13ea7f2c4b Resolve conflicts after merge. 2008-06-02 10:28:26 +00:00
Adam Sampson
36e7353ee7 Take NameType out of NameDef.
NameType is only really needed in the parser, so this takes it out of
NameDef, meaning that later passes defining names no longer need to
set an arbitrary NameType for them. The parser gets slightly more
complicated (because some productions now have to return a SpecType
and a NameType too), but lots of other code gets simpler.

The code that removed free names was the only thing outside the parser
using NameType, and it now makes a more sensible decision based on the
SpecType. Since unscoped names previously didn't have a SpecType at
all, I've added an Unscoped constructor to it and arranged matters
such that unscoped names now get a proper entry in csNames.

Fixes #61.
2008-06-02 10:13:14 +00:00
Adam Sampson
77a718f078 Remove another obsolete comment. 2008-05-30 14:13:24 +00:00
Adam Sampson
9749d58f09 Remove an obsolete comment. 2008-05-30 12:24:46 +00:00
Neil Brown
231d037cb3 Added a pass to turn all List types into Mobile List 2008-06-01 19:26:40 +00:00
Neil Brown
d4938a166c Fixed some more Rain tests related to the old method of inferring types 2008-06-01 17:21:14 +00:00
Neil Brown
155f58c174 Fixed the Rain parser tests with respect to the new type inference 2008-06-01 16:48:15 +00:00
Neil Brown
a5fca4816b Added the beginnings of support for implicit mobility for Rain (just printing out the decisions for now) 2008-05-30 17:16:10 +00:00
Neil Brown
d623c82b3b Removed some of the bad uses of findMeta (where no meta tag would be found) from the Rain parser 2008-05-30 16:39:58 +00:00
Adam Sampson
8b3eba594d Add SubscriptCheck field to SubscriptFromFor etc.
This makes it possible to mark a slice as not needing runtime
checking, which is immediately useful for _sizes arrays.

This fixes cgtest03, which was previously failing to compile because
the _sizes array for one of the constants in it contained a runtime
check and thus wasn't itself constant. I've added a testcase file for
the relevant bit of code.
2008-05-26 17:36:26 +00:00
Adam Sampson
a7877ecd68 Make applyToOnly more general, and use it in more places.
This simplifies several bits of code that are doing things with Structureds.
2008-05-25 22:36:54 +00:00
Adam Sampson
6debf9292f Rework Traversal, and convert all passes to use it.
This changes the Traversal API to the one that I've been working on in
the Polyplate branch, but implemented in terms of Data. The
performance isn't as good as the Polyplate version, but the code is a
lot simpler because it doesn't need all the type constraints (and it
doesn't make GHC struggle).

This also reworks all the passes in Tock to use the new API, including
those that previously used makeGeneric (which I've now removed) or
everywhereM. Most of the passes are simpler because of this, and I
suspect it's fixed a few subtle bugs resulting from missing recursion
in makeGeneric code.

I haven't yet profiled this, but subjectively it seems about the same
as the old Traversal (and thus faster for all the passes that didn't
yet use it).
2008-05-25 20:13:57 +00:00
Neil Brown
d044b51335 Renamed ndType to ndSpecType, as per Trac ticket #59 2008-05-21 13:38:51 +00:00
Neil Brown
35498a4d13 Renamed the "Typed" type-class to "ASTTypeable" as per the Trac ticket 2008-05-21 13:16:45 +00:00
Neil Brown
9f411bfd45 Fixed the Rain passes so that the order correctly satisfies the pre-requisites 2008-05-21 12:46:51 +00:00
Neil Brown
4537cd205c Fixed the occam pass list so that it now has the correct order in respect to all the pre-requisite properties 2008-05-21 12:30:04 +00:00
Neil Brown
e5d8b51827 Added a missing line to substitute back inferred types for anonymous non-numeric types 2008-05-20 22:08:15 +00:00
Neil Brown
af63afa5e9 Added type inference for list literals and list constructors 2008-05-20 21:56:07 +00:00
Neil Brown
2b3783d845 Fixed the handling of types for function returns
Function returns are done in Rain by assigning to the function name, so we need a bit of extra code when checking assignments to see if the LHS is a function name.
2008-05-20 18:11:05 +00:00
Neil Brown
bd7584e280 Turned off the checkFunction pass for now, since it is over-eager at spotting problems with Rain functions 2008-03-25 18:46:51 +00:00
Neil Brown
f0a90a3024 Removed "run" from the Rain syntax, and adopted the occam approach instead 2008-03-25 17:32:54 +00:00
Neil Brown
4429dfc051 Added Meta tags all over the place in the type unification to give better error messages 2008-05-20 18:42:20 +00:00
Neil Brown
6afea19ee6 Cleared up the mess of old stuff in the list of rain passes 2008-05-18 11:36:08 +00:00
Neil Brown
8cc602100d Added code to replace the unknown types with their deduced values after type unification 2008-05-18 11:34:26 +00:00
Neil Brown
ec5baf4e97 Stopped the Rain parser using any as a placeholder, and switched to using the unknown types 2008-05-18 11:34:05 +00:00
Neil Brown
760c8a9a1e Added marking up of types in foreach replicators for type unification 2008-05-18 11:13:48 +00:00
Neil Brown
0c443255e6 Changed the expression types to use type unification, and removed the old test
The new behaviour is to check that both sides of a dyadic operator have the same type.  This means that multiplying time by a scalar is no longer possible, but it also means (due to the lack of checks after unification) that multiplying two lists is possible, or concatenating two integers.  This needs to be fixed by adding another pass.
2008-05-18 10:30:25 +00:00
Neil Brown
6758cd7da3 Changed the list concatenation operator to be ++ in Rain 2008-05-18 10:30:17 +00:00
Neil Brown
46aa0383be Removed some unused functions from RainTypes 2008-05-18 09:52:50 +00:00