Commit Graph

31 Commits

Author SHA1 Message Date
Adam Sampson
7703eab52f Add applyExplicitM10.
Fortunately all of this will go away once I do the combinator change...
2008-04-07 21:34:34 +00:00
Adam Sampson
118a1f3527 Add a resolveAmbiguities pass.
Currently this only handles the FunctionCallList ambiguity.
2008-04-06 11:33:10 +00:00
Adam Sampson
9fa45cf406 Make the inferredTypesRecorded property check Infer has been removed. 2008-04-05 22:41:29 +00:00
Adam Sampson
8bbca0f760 Add applyExplicitM9 (as a stopgap). 2008-04-04 12:10:32 +00:00
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
d66fb79796 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
078b94ff8f Defined a custom monad for PassM rather than using the monad transformers in a stack 2008-03-10 15:18:31 +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
7d9110a9b0 Remove "Data t =>" qualifications from transformation types.
This is solely because GHC 6.6 doesn't like them (it complains about the type
variable already being in scope -- which it is, but there's nothing I can do
about that!). This doesn't lose any safety; if you try to write a
transformation for something that's not Data you'll find out when you try to
pass it to one of the application functions.
2008-04-01 12:31:20 +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
Neil Brown
bbdb429498 Changed transformWaitFor (and its tests) to transform the new InputTimerFor into InputTimerAfter 2008-03-24 15:09:05 +00:00
Neil Brown
dd7b0268b2 Added a new property (functionTypesChecked) to help fix the pass ordering 2008-03-23 00:09:01 +00:00
Adam Sampson
321e52dd65 Add checkDepthM.
This is like applyDepthM, but for functions that don't want to change the AST.
(There's probably a more efficient way of implementing this.)
2008-03-22 00:45:40 +00:00
Neil Brown
ebef4aaedf Fixed array constructors by adding an occam pass to figure out their type early on, and also corrected the ordering of the later passes 2008-03-21 18:23:42 +00:00
Neil Brown
142926172d Fixed the error message given when there is a problem with the pass dependency graph 2008-03-21 14:51:54 +00:00
Neil Brown
50ce3410b8 Added the pass for giving lists a type to the pass list 2008-03-20 16:54:40 +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
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
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
b8caf7c3b6 Move everywhereASTM into Pass. 2008-03-19 18:11:49 +00:00
Adam Sampson
79eefd5e98 Move constant checking from the occam parser into a pass.
The parser now doesn't do any constant folding or checking.
2008-03-19 12:47:29 +00:00
Adam Sampson
3340e95806 Make agg_typesDone include constantsFolded.
This is so that constant folding gets done early; it's important that it
doesn't happen after anything that tries to pull values into variables later
on.
2008-03-17 15:47:57 +00:00
Adam Sampson
89040a97b0 Move the dummy occam pass into an OccamPasses module.
(The plan is to gradually replace it with real passes.)
2008-03-15 14:40:17 +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
e3af6eecc1 Defined a custom monad for PassM rather than using the monad transformers in a stack 2008-03-10 15:18:31 +00:00
Neil Brown
35b1ffdc51 Added a new pass to turn all array slices into the full FromFor form 2008-03-09 16:15:24 +00:00
Neil Brown
4c1f2a1930 Adjusted the C++ (a lot) and C (a little) backends to reflect array _sizes changes, and added the new array passes to the overall pass list
Now that I have begun moving all the _sizes stuff forward into proper compiler passes, much of the code for handling arrays in the backends is going to become redundant:

- The tockArrayView class should eventually disappear; now that _sizes are pulled forward, there's no advantage of having this extra class (compared to just doing C and C++ arrays in the same, C-based, style)
- The declaration and use of the _sizes array everywhere should go, now that it is inserted in an earlier pass

I haven't removed as much as I should from the C backend; I am wary to touch it when Adam is about to move it over to the new CIF anyway
2008-03-06 19:08:38 +00:00
Neil Brown
60c7a2dde3 Added a preliminary pass-list for the work on flattening arrays 2008-03-06 09:59:18 +00:00
Neil Brown
9b570996ca Added a pass to flatten protocol inputs down into multiple sequential input statements 2008-02-27 16:45:27 +00:00
Neil Brown
caff04c548 Changed the use of everywhereM in underlyingType to use makeGeneric instead 2008-02-24 15:52:09 +00:00
Neil Brown
13c46d1fb2 Moved three pass-related modules out to their own directory 2008-02-24 12:32:21 +00:00