Commit Graph

59 Commits

Author SHA1 Message Date
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
Neil Brown
c97d1d00c8 Changed the error type from String to ErrorReport throughout the code
ErrorReport is of type (Maybe Meta, String), thereby adding an optional code position to error messages.

Die has been changed so that die and dieP are now implemented in terms of dieReport (:: ErrorReport -> m a).  This involved changing less code than changing die to be of type ErrorReport -> m a.  All that had to be changed directly was that Die instances now implement dieReport instead of die.

Any bits of code that "caught" errors has been changed so that it handles ErrorReport instead of String.  This ErrorReport is eventually, in Main, passed to dieIO, which will soon be changed to read the file in and provide the context.  Accordingly, MonadIO m has been added as a constraint to dieIO, and dieInternal has been changed to no longer use dieIO (because really we can't add the MonadIO constraint to dieInternal).

Various error messages have been changed.  Notably, all instances of fail in ParseOccam have been changed to use die or, wherever possible, dieP.  A similar thing has been done in EvalConstants and EvalLiterals.
2007-09-18 10:17:38 +00:00
Neil Brown
3e342a621c Added ShowOccam and ShowRain type-classes, and changed existing code to use these new show methods in error messages
The function showCode shows code as either occam or Rain depending on the frontend.  This is then used by a formatCode function that acts similar to 
printf, which makes it easy to format error messages that use showCode.
2007-09-16 17:20:57 +00:00
Neil Brown
c61f2ea617 Rain: added checks that types match in input and output statements 2007-09-16 11:46:01 +00:00
Neil Brown
337ad7fd32 Rain: added type-checking tests for if and while conditionals 2007-09-16 09:59:30 +00:00
Neil Brown
5354c99a4e Rain: added a function and tests for checking the types involved in assignments 2007-09-16 09:18:12 +00:00
Neil Brown
9ef8343c3a Rain: moved matchParamPass into RainTypes 2007-09-15 21:29:30 +00:00
Neil Brown
3301207a97 Rain: added more type-checkers tests, all of which pass 2007-09-15 21:19:16 +00:00