Commit Graph

66 Commits

Author SHA1 Message Date
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
Neil Brown
af4a66e2e4 Corrected the spelling of the name of one of the Rain passes 2008-03-20 16:46:45 +00:00
Neil Brown
d4991461a5 Fixed the type of a list for the empty list 2008-03-20 16:44:36 +00:00
Neil Brown
cd58986721 Added a first implementation of the annotateListLiteralTypes pass 2008-03-20 16:35:09 +00:00
Neil Brown
bd26f758b4 Added tests for annotating the types of list literals and ranges in Rain 2008-03-20 14:44:19 +00:00
Neil Brown
43b77ff1a0 Made names for loop variables unique in Rain, and made their abbreviation mode Abbrev 2008-03-19 17:19:58 +00:00
Adam Sampson
746e360a4a Rename everywhereASTM to applyDepthM, and add a two-type version.
The renaming is because I can never remember which of everywhere and
everywhere' goes depth-first...
2008-03-20 11:40:19 +00:00
Adam Sampson
b8caf7c3b6 Move everywhereASTM into Pass. 2008-03-19 18:11:49 +00:00
Neil Brown
ba75f5b06c Removed the initialiser expression on the Declaration item in the AST 2008-03-09 00:23:13 +00:00
Neil Brown
25f2efb94c Changed the existing Rain code (and tests) to use the new List type rather than the Array type 2007-10-25 10:13:17 +00:00
Neil Brown
6b95827cab Added an optional initialiser-expression to Declaration in the AST, and changed the rest of the code accordingly 2007-10-24 23:50:00 +00:00
Neil Brown
15ecb2b178 Added the -fwarn-type-defaults compiler option (for when integer literals are given a default type) and fixed the few warnings that arose from doing so 2007-09-27 13:29:16 +00:00
Neil Brown
38c409d378 Added the -fwarn-unused-imports compiler option to warn about unused imports, and then set about pruning and ordering (mostly in my code) the import lists for all the modules 2007-09-27 13:13:46 +00:00
Neil Brown
028c27eb73 Rain: implemented type-checking for wait guards 2007-09-26 23:42:40 +00:00
Neil Brown
a65953ad89 Rain: added type-checking for wait statements 2007-09-26 23:08:55 +00:00
Neil Brown
a12d46401a Rain: implementing type checking for inputs inside alts 2007-09-26 22:37:32 +00:00
Neil Brown
4e635d84ba Rain: added a pass for checking the types in GetTime processes 2007-09-19 11:36:55 +00:00
Neil Brown
c925774280 Changed the types code so that all the tests for the new Time type pass 2007-09-19 11:24:14 +00:00