Commit Graph

298 Commits

Author SHA1 Message Date
Neil Brown
4ef1ff7196 Changed to a state monad for warnings, and added a runPassM function to remove duplicate code for running passes 2008-04-03 12:21:59 +00:00
Neil Brown
20843f70a4 Corrected all the tests to use the new PassM monad 2008-03-10 17:07:48 +00:00
Neil Brown
d66fb79796 Fixed some unused module import warnings, now that PassM is not build of monad transformers 2008-03-10 17:19:45 +00:00
Adam Sampson
bd9c4dae98 Go back to passing the value to the type-contains function.
This'll make the modification to look at constructors cleaner.
2008-04-02 16:11:13 +00:00
Adam Sampson
f515b5ce55 Change "find" to "targets", for clarity. 2008-04-02 15:16:47 +00:00
Adam Sampson
d9df114909 Rework gmapMFor so it takes a list of type keys.
This means we only need one gmapMFor function, and we do fewer calls to
typeKey, but we have to make typeKey available for use where it's called.
2008-04-02 15:09:07 +00:00
Adam Sampson
aeb2ebd9f4 Fix Haddock. 2008-04-01 13:22:30 +00:00
Adam Sampson
d2bcd0cde5 Use IntMap.keysSet.
(Thanks to Neil for spotting this!)
2008-03-26 23:19:37 +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
ef329e3ed0 Check SpecTypes. 2008-03-26 14:20:35 +00:00
Adam Sampson
c9cb7d2bf9 Check Proc calls. 2008-03-26 12:26:04 +00:00
Adam Sampson
6861b22da6 Check timer operations. 2008-03-25 16:45:25 +00:00
Adam Sampson
b3e3308b3e Implement channel IO checks, and refactor OccamTypes (again). 2008-03-25 15:56:03 +00:00
Neil Brown
c68aa42277 Added a sub-type to Timers, to support multiple types 2008-03-23 22:20:16 +00:00
Neil Brown
7830d82c51 Fixed the display of names in ShowCode for Rain 2008-03-23 12:13:55 +00:00
Neil Brown
1bf3f6f0f1 Fixed the type of a function name in buildExpr to fix the tests 2008-03-23 12:08:08 +00:00
Neil Brown
6f76f6385e Added to an error message in Types to help determine the problem 2008-03-23 00:07:48 +00:00
Neil Brown
e767e33190 Added support for some intrinsic (time-related) functions in Rain 2008-03-22 18:58:10 +00:00
Neil Brown
7f28d3dbe3 Added a warnPC function (like diePC) for use with formatCode 2008-03-22 18:34:40 +00:00
Neil Brown
710abd7019 Added support for function calls to the Rain parser 2008-03-22 17:49:21 +00:00
Adam Sampson
60ca26128c More occam typechecks: input/output items, replicators, choices.
Various infrastructure too to support these.

Doing A.ForEach raised an interesting question: what does it work over?  In
plain occam it'd just be arrays, but it should obviously work for lists too.
This suggests that Size and Subscript should work on lists as well, since
ForEach will be implemented in terms of them. I've therefore introduced the
idea of a "sequence" class of types.
2008-03-22 23:47:29 +00:00
Adam Sampson
388f2f38a6 plainSubscriptType doesn't really need to know what the subscript is. 2008-03-22 00:53:46 +00:00
Adam Sampson
56de093739 Add isScalarType. 2008-03-22 00:53:13 +00:00
Adam Sampson
8b2568264d Add more utility functions along the lines of defineConst.
These let you define various sorts of name in the initial state of a pass test.
2008-03-22 00:44:57 +00:00
Adam Sampson
8b5233ba47 Add ShowCode instances for A.Name. 2008-03-22 00:42:00 +00:00
Adam Sampson
cfc5b18e3e Don't show the state when a pass unexpectedly succeeds.
This used not to be a problem, but there's now quite a lot of stuff predefined
in the state when testing the typechecker, so it tends to obscure the real
error...
2008-03-20 23:56:13 +00:00
Neil Brown
025eebf61d Added support for giving ranges an explicit type in Rain 2008-03-21 21:10:47 +00:00
Neil Brown
2189a6c28a Added support for list literals to the Rain parser 2008-03-21 20:03:47 +00:00
Neil Brown
33b04e7646 Tidied up a few unused functions and module imports 2008-03-21 15:16:36 +00:00
Neil Brown
0e3465afc0 Corrected some Rain tests to avoid using the Int type 2008-03-20 16:42:25 +00:00
Neil Brown
a6452f93df Added a ShowOccam and ShowRain instance for lists of things 2008-03-20 16:34:11 +00:00
Neil Brown
ecb82d13a8 Revamped the ShowCode module, transforming it to use the writer monad 2008-03-20 16:20:14 +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
123936e71c Changed addOne to use Add not Plus (we can always define a plusOne...) 2008-03-20 12:30:07 +00:00
Neil Brown
713b5c3e5c Added a subExprs helper function to match the rest 2008-03-19 17:52:01 +00:00
Neil Brown
b496912c51 Fixed conflicts with Adam's dimension changes 2008-03-19 17:49:32 +00:00
Neil Brown
35ebd43f79 Fixed some error messages in the Types module 2008-03-19 17:02:45 +00:00
Neil Brown
45c2619307 Changed the rain parser to use ListLiteral for strings 2008-03-19 15:59:23 +00:00
Neil Brown
7baeb318f2 Adjusted the Types module to use the new types in array constructors 2008-03-19 13:21:42 +00:00
Adam Sampson
eb29e65bad Smarter tree traversals: "Scrap Your Uniplate".
This provides gmapMFor and gmapMFor2, which are like gmapM, but know what
they're looking for, and can therefore avoid going down branches of the tree
that won't contain any interesting types.

The basic approach is quite similar to Uniplate's PlateData: there's a function
(containsType) that'll tell you whether one type is contained somewhere within
another. However, unlike Uniplate, we build a static IntMap IntSet of the types
we need to know about, which allows rather quicker lookups. (I did try using
PlateData first.)

The result is that applyDepthM is now much quicker than it was before.
applyDepthM2 is a bit less impressive, which I assume is because it can't
really prune the tree much if it's looking for two types.

Future enhancements:
- convert more passes to use applyDepthM*;
- make gmapMFor* aware of constructors rather than just types, which should
  allow a bit more pruning.
2008-03-20 16:49:24 +00:00
Adam Sampson
e08aac59d3 Move Retypes checking from the occam parser into a pass.
This also fixes a bug in the original algorithm: it used to let you retype
[]INT to BYTE.
2008-03-19 19:38:56 +00:00
Adam Sampson
7f6cb6e0c3 Evaluate "(MOSTNEG INT) \ -1" correctly when evaluating constants.
This actually crashes older versions of GHC:
  Prelude Data.Int> (minBound :: Int32) `div` (-1)
  Floating point exception
2008-03-19 11:12:57 +00:00
Adam Sampson
b1416bb0cf Change A.Dimension to take an Expression, not an Int.
This touches an awful lot of code, but cgtest07/17 (arrays and retyping) pass.

This is useful because there are going to be places in the future where we'll
want to represent dimensions that are known at runtime but not at compile time
-- for example, mobile allocations, or dynamically-sized arrays. It simplifies
the code in a number of places.

However, we do now need to be careful that expressions containing variables do
not leak into the State, since they won't be affected by later passes.

Two caveats (marked as FIXMEs in the source):

- Retypes checking in the occam parser is disabled, since the plan is to move
  it out to a pass anyway.
- There's some (now very obvious) duplication, particularly in the backend, of
  bits of code that construct expressions for the total size of an array
  (either in bytes or elements); this should be moved to a couple of helper
  functions that everything can use.
2008-03-18 16:45:38 +00:00
Adam Sampson
54668d3ba2 Implement the RESCHEDULE intrinsic. 2008-03-15 11:00:11 +00:00
Adam Sampson
6df110dce4 Wrap QuickCheck tests into HUnit tests.
This means all the tests now get run as part of one list, and HUnit keeps track
of the number of failures for us. (The reason I was doing this was so that
tocktest will exit non-zero on QuickCheck test failure too.)

As part of this, I've reworked TestMain's main function quite a bit. It'll now
filter QuickCheck tests into response to options too.
2008-03-12 19:38:02 +00:00
Adam Sampson
8120a75186 Clean up TestUtils.
Reorder functions in categories, and add some folds so it's easier to navigate.
2008-03-12 18:27:30 +00:00
Adam Sampson
808277ca84 Remove now-unused code for running timed tests. 2008-03-12 18:21:22 +00:00
Neil Brown
c778ff0031 Fixed some unused module import warnings, now that PassM is not build of monad transformers 2008-03-10 17:19:45 +00:00
Neil Brown
9f18b348e8 Corrected all the tests to use the new PassM monad 2008-03-10 17:07:48 +00:00
Neil Brown
5c43172e46 Added an annotation to array subscripts to indicate whether they should have a run-time check added or not 2008-03-09 14:30:19 +00:00