Mirror of http://offog.org/git/tock.git . Tock (translator from occam to C from Kent) is a Haskell-based compiler for occam and related languages.
Go to file
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
backends Change A.Dimension to take an Expression, not an Int. 2008-03-18 16:45:38 +00:00
checks Change A.Dimension to take an Expression, not an Int. 2008-03-18 16:45:38 +00:00
common Smarter tree traversals: "Scrap Your Uniplate". 2008-03-20 16:49:24 +00:00
data Change A.Dimension to take an Expression, not an Int. 2008-03-18 16:45:38 +00:00
docextra Clean up the documentation hack a bit. 2008-02-28 14:43:53 +00:00
flow Wrap QuickCheck tests into HUnit tests. 2008-03-12 19:38:02 +00:00
frontends Rename everywhereASTM to applyDepthM, and add a two-type version. 2008-03-20 11:40:19 +00:00
pass Smarter tree traversals: "Scrap Your Uniplate". 2008-03-20 16:49:24 +00:00
support Do away with the killval hack. 2008-03-12 16:43:15 +00:00
testcases Move constant checking from the occam parser into a pass. 2008-03-19 12:47:29 +00:00
transformations Fix the transformConstr0 test by defining x. 2008-03-20 11:23:45 +00:00
AUTHORS Changed tock to use autoconf/automake for its build process 2007-10-08 17:02:03 +00:00
cgtests.mk Changed the cgtests to no longer use a custom garbage collector 2008-03-10 17:23:37 +00:00
ChangeLog Changed tock to use autoconf/automake for its build process 2007-10-08 17:02:03 +00:00
compile-cgtests Added rules for getting and making the cgtests to the new Automake make system 2007-10-09 00:44:41 +00:00
configure.ac Added a check for C++CSP2 using pkg-config 2008-03-17 17:36:48 +00:00
COPYING Add licensing information. 2007-08-18 20:42:11 +00:00
COPYING.LIB Add licensing information. 2007-08-18 20:42:11 +00:00
GenOrdAST.hs Added a case for the top-level AST to OrdAST 2008-02-05 22:36:12 +00:00
GenTagAST.hs Changed two uses of gmapQ (const undefined) to the similar glength function in the SYB library 2008-02-24 12:32:25 +00:00
LANGUAGE Implement short-form PLACE, and fix PLACE IN WORKSPACE/VECSPACE. 2008-03-17 18:47:54 +00:00
Main.hs Fixed some unused module import warnings, now that PassM is not build of monad transformers 2008-03-10 17:19:45 +00:00
Makefile.am Smarter tree traversals: "Scrap Your Uniplate". 2008-03-20 16:49:24 +00:00
NEWS Changed tock to use autoconf/automake for its build process 2007-10-08 17:02:03 +00:00
README Changed tock to use autoconf/automake for its build process 2007-10-08 17:02:03 +00:00
SYNTAX Give tock its own repo -- i.e. remove everything else and move tock up 2007-07-16 21:48:55 +00:00
TestMain.hs Add a pass for folding constants in occam. 2008-03-17 15:48:43 +00:00
TODO Give tock its own repo -- i.e. remove everything else and move tock up 2007-07-16 21:48:55 +00:00