Commit Graph

83 Commits

Author SHA1 Message Date
Neil Brown
c8b724d2be Merged the latest set of changes from the trunk into the Polyplate branch
I also added the import list to all the Data.Generics imports in the tests (as I did for the other modules recently)
2009-04-10 20:38:29 +00:00
Neil Brown
8f767ff0d4 Made all the imports of Data.Generics have an import list
This makes sure that we catch all leftover instances of using SYB to do generic operations that we should be using Polyplate for instead.  Most modules should only import Data, and possibly Typeable.
2009-04-09 15:36:37 +00:00
Neil Brown
1141ecb472 Fixed the Rain modules to use the new Pass system/types 2008-12-14 18:35:39 +00:00
Neil Brown
229f2197af Turned findMeta into a member of a FindMeta type-class 2009-04-09 11:13:37 +00:00
Neil Brown
9260048da2 Quickly fixed the Rain frontend to compile with the operator changes 2009-04-05 23:08:12 +00:00
Neil Brown
41805aaacf Changed the ChanEnd constructor to only keep information about its shared-ness, not about the whole channel 2009-03-23 18:40:28 +00:00
Neil Brown
8492dc03d4 Introduced a ShareMode in the AST, and used it in the channel attributes (rather than Bool) 2009-03-22 22:29:39 +00:00
Neil Brown
7d185fd72a Adjusted the Rain passes to cope with the new array literals 2009-02-01 21:54:32 +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
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
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
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
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
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
Neil Brown
d4938a166c Fixed some more Rain tests related to the old method of inferring types 2008-06-01 17:21:14 +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
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
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
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
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
46aa0383be Removed some unused functions from RainTypes 2008-05-18 09:52:50 +00:00
Neil Brown
4586cdd43a Added an export list to RainTypes, and removed some tests for old passes 2008-05-18 09:49:11 +00:00
Neil Brown
f79cba0616 Changed the parameter type checking to use type unification 2008-05-18 09:43:12 +00:00
Neil Brown
e53fda754e Fixed the Rain passes so the the alphabet test case now works (at least) 2008-05-17 20:51:42 +00:00
Neil Brown
1e5268dea5 Fixed the types that are definitely known (declarations, etc) so that they are available during type unification 2008-05-17 19:48:48 +00:00
Neil Brown
bf07c441ae Changed the communication type checking to be part of the type unification framework 2008-05-17 19:47:47 +00:00
Neil Brown
1115364d47 Changed TypeExp to stop using Data.Generics (which was getting awkward)
Instead of storing the Constr, which was messy, we now store a String (to allow comparison of constructor types during unification) and a function to reform the type at the end of the type checking.
2008-05-17 19:44:45 +00:00
Neil Brown
cd0c8d2901 Added assignments to the new type unification system for Rain 2008-05-17 14:23:31 +00:00
Neil Brown
1e6ae6bff9 Improved the error messages when the type unification fails 2008-05-17 14:23:00 +00:00
Neil Brown
f10cb7d525 Moved the TypeExp type out to its own module, UnifyType 2008-05-17 14:21:57 +00:00
Neil Brown
63a28d0044 Changed the conditionals type-checking to use type unification rather than the old system 2008-05-17 12:53:05 +00:00
Neil Brown
89c25e3f6c Added a type-class for retrieving the (AST) type of things
This patch hides all the old typeOfExpression, typeOfName, typeOfVariable, etc, and unifies them into a single type-class with an "astTypeOf" function.  The type-class is currently named Typed, but that can easily be changed (it's only explicitly referred to in the Types module).  The patch is essentially the type-class with a giant find-and-replace on the other modules.
2008-05-17 11:41:52 +00:00
Neil Brown
3daf82d318 Merged Alternative and AlternativeCond into a single Alternative item that always has a pre-condition 2008-04-03 14:52:37 +00:00
Adam Sampson
7525138c96 Defined types for tree traversals, and moved them to their own file.
We now have three kinds of canned tree traversals, all of which are smart about
which types they're applied to: explicit-descent transformations,
implicit-descent transformations, and implicit-descent checks. I've only
provided depth-first application of the latter two, but we could do
breadth-first in the future if necessary.
2008-04-01 12:01:09 +00:00
Adam Sampson
3283b7db41 Remove the Type/AbbrevMode information from Actual*.
It's redundant, since you can always compute them from the variable, and it
makes the code that deals with actuals rather cleaner.

On the other hand, it slightly complicates some of the tests, because any names
you use in an Actual need to be defined...
2008-03-26 18:16:09 +00:00
Adam Sampson
b296706bea Update Rain typechecker to match isIntegerType change.
isIntegerType now recognises Time as an integral type, so the rules for Time
operations in the Rain typechecker needed updating.
2008-03-26 14:55:15 +00:00
Neil Brown
8fe152bf98 Merged the type-checking on time-related statements in Rain into the pass that checks types in communications 2008-03-24 15:15:28 +00:00
Neil Brown
74a5cf52a7 Stopped constants being assigned to in the type-checker for Rain 2008-03-23 12:15:00 +00:00
Neil Brown
7a7b60449c Enhanced an error message in RainTypes 2008-03-22 19:04:34 +00:00
Neil Brown
813d6affd1 Fixed an error message in RainTypes 2008-03-22 18:02:43 +00:00
Neil Brown
7bd5bdf1fa Changed a Rain pass to transform the Plus operator on lists into the proper Concat operator 2008-03-21 19:23:16 +00:00
Neil Brown
8db5975671 Refactored checkExpressionTypes a little 2008-03-21 16:35:57 +00:00
Neil Brown
edf1060c9b Fixed conflicts in the Rain passes 2008-03-21 12:45:24 +00:00