Commit Graph

35 Commits

Author SHA1 Message Date
Neil Brown
8f767ff0d4 Made all the imports of Data.Generics have an import list
This makes sure that we catch all leftover instances of using SYB to do generic operations that we should be using Polyplate for instead.  Most modules should only import Data, and possibly Typeable.
2009-04-09 15:36:37 +00:00
Neil Brown
a72b01ff02 Merged the latest changes from my usage checking into the polyplate branch 2009-02-10 17:11:24 +00:00
Neil Brown
890e7ea9a6 Fixed many of the modules to use the new Polyplate-based Traversal system 2008-12-02 18:06:10 +00:00
Neil Brown
dc64b5e664 Fixed the filename munging in the generated copy_ procs for records 2009-04-08 12:13:07 +00:00
Neil Brown
e457d82f0c Changed FUNCTIONs and PROCs to have optional bodies, and put all the externals into the AST (without bodies)
This may seem like an odd change, but it simplifies the logic a lot.  I kept having problems with passes not operating on externals (e.g. functions-to-procs, adding array sizes, constant folding in array dimensions) and adding a special case every time to also process the externals was getting silly.

Putting the externals in the AST therefore made sense, but I didn't want to just add dummy bodies as this would cause them to throw up errors (e.g. in the type-checking for functions).  So I turned the bodies into a Maybe type, and that has worked out well.

I also stopped storing the formals in csExternals (since they are now in csNames, and the tree), which streamlined that nicely, and stopped me having to keep them up to date.
2009-04-04 14:56:35 +00:00
Neil Brown
d6ad0ba202 Made the name of record-copying PROCs different for each file that generates them, to avoid clashes at link time 2009-04-03 10:25:55 +00:00
Neil Brown
af9ab28718 Replaced a use of SizeVariable with VariableSizes (indirectly) in SimplifyProcs 2009-03-31 09:21:32 +00:00
Neil Brown
45b22472c3 Changed the rest of tock to reflect the changes to the Is constructor 2009-03-24 23:57:24 +00:00
Neil Brown
f73171140c Fixed a subtle bug with conflicting abbreviation modes in the PROCS generated to copy records 2009-03-23 21:08:40 +00:00
Neil Brown
979eec927a Added a pass that removes replicators with a count of 0, and turns replicators with a count of 1 into non-replicated things (with the appropriate abbreviation) 2009-02-04 11:30:57 +00:00
Neil Brown
40b9a8b76b Fixed the generated PROCs for copying records not having their definition recorded 2009-02-02 17:23:28 +00:00
Neil Brown
8a28d765e7 Implemented recursive procs
This works fine in the C++ backend, not tested with the C backend yet
2009-01-29 00:43:24 +00:00
Neil Brown
6693a8b8b9 Changed things in the transformations directory in light of the new step count 2009-01-28 23:46:04 +00:00
Neil Brown
41ff60cb78 Removed the Rep constructor from Structured and instead added a Rep constructor to SpecType
This way, all replicators are declared like other names, and their scope is considered replicated.  This simplifies the code a little.

Fixes #55
2008-06-04 17:00:43 +00:00
Neil Brown
21329287e2 Fixed a problem with GHC 6.6 and the new pass mechanism by removing all the dollars that were confusing the type-checker 2008-06-03 16:16:26 +00:00
Neil Brown
ba66cce89f Moved all the remaining pass information to be with the passes themselves, and adjusted the tests accordingly
All the passes now have their information (name, pre-requisites and post- properties) stored at the point where the pass is declared, which means the pass lists are just a simple list of pass functions.

The main consequence of this change was that the tests had to be changed.  Now, instead of taking a "pass applied to data" item (type: PassM b), they take both the pass (type: Pass) and source data (type: b), and apply them later.  This was the decision that involved the simplest changes to the existing tests (simply unbracketing the application of the pass to the source).  I also had to include a few old-style versions though (testPass', testPassShouldFail') for where the functions were being used to test things that weren't actually passes (mainly StructureOccam).

Fixes #48
2008-06-02 14:31:19 +00:00
Adam Sampson
36e7353ee7 Take NameType out of NameDef.
NameType is only really needed in the parser, so this takes it out of
NameDef, meaning that later passes defining names no longer need to
set an arbitrary NameType for them. The parser gets slightly more
complicated (because some productions now have to return a SpecType
and a NameType too), but lots of other code gets simpler.

The code that removed free names was the only thing outside the parser
using NameType, and it now makes a more sensible decision based on the
SpecType. Since unscoped names previously didn't have a SpecType at
all, I've added an Unscoped constructor to it and arranged matters
such that unscoped names now get a proper entry in csNames.

Fixes #61.
2008-06-02 10:13:14 +00:00
Adam Sampson
a7877ecd68 Make applyToOnly more general, and use it in more places.
This simplifies several bits of code that are doing things with Structureds.
2008-05-25 22:36:54 +00:00
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
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
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
5156626ab0 Remove the identifyParProcs pass.
All it did was to make a list of the Procs generated by parsToProcs, so
parsToProcs may as well just do the same job itself.

The reason I'd made it a separate pass originally was that I wanted to
optimise out the wrapper when the child of a Par was already a ProcCall.
That optimisation isn't going to be possible any more with the new CCSP,
since wrappers have to fetch their arguments in a different way from
ordinary Procs.
2008-03-14 14:53:05 +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
Neil Brown
08d02bfb17 Changed the behaviour of assignment for records
Previously, assignments of records were directly flattened into assignment of each of the fields.  Now, we instead generate a copy_<recordname> inline procedure for each record definition, and compile code that uses that (for C++, we could even make this an operator= implementation later on).  This allows us to re-use the proc later in the C/C++ backends if needed.
2008-02-29 16:36:47 +00:00
Neil Brown
a4424ee82d Fixed a few dependencies in the pass lists relating to functions 2008-02-27 20:05:47 +00:00
Neil Brown
cfc3577c21 Fixed the pre-condition of flattenAssign to include the types being resolved 2008-02-27 18:24:33 +00:00
Neil Brown
5dbf7fea7a Changed functionsToProcs to work on the new style of function, and made sure parallel assignment isn't removed first 2008-02-25 22:05:53 +00:00
Neil Brown
2e6718ac50 Changed all the lists of passes to add pre- and post- properties 2008-02-19 09:43:40 +00:00
Neil Brown
3ce0eaf452 Made the first adjustment to the Pass system, ready to introduce properties and a dependency graph. For now passes are still executed in list order 2008-02-16 10:19:14 +00:00
Neil Brown
acd57d74de Changed the A.Structured type to be parameterised
This patch is actually an amalgam of multiple (already large) patches.  Those patches conflicted (parameterised Structured vs. changes to usage checking and FlowGraph) and encountered a nasty bug in darcs 1 involving exponential time (see http://wiki.darcs.net/DarcsWiki/ConflictsFAQ for more details).  Reasoning that half an hour (of 100% CPU use) was too long to apply patches, I opted to re-record the parameterised Structured changes as this new large patch.  Here are the commit messages originally used for the patches (which, as mentioned, were already large patches):

A gigantic patch switching all the non-test modules over to using parameterised A.Structured
Changed the FlowGraph module again to handle any sort of Structured you want to pass to it (mainly for testing)
A further gigantic patch changing all the tests to work with the new parameterised Structured
Fixed a nasty bug involving functions being named incorrectly inside transformInputCase
Added a hand-written instance of Data for Structured that allows us to use ext1M properly
Fixed a few warnings in the code
2008-02-05 19:40:27 +00:00
Neil Brown
edc3a7e910 Removed the die function (that has no source position) and as far as possible replaced all its uses with dieP and a valid position 2008-01-28 17:21:13 +00:00
Neil Brown
bdda623d7e Added types to all the cases where the monomorhpism restriction applied 2008-01-26 20:51:11 +00:00
Neil Brown
a25824b601 Changed the passes to be of type Pass, rather than A.Process -> PassM A.Process 2007-10-17 13:09: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
2ff46a9041 Rearranged the Rain source files, renamed a couple of Rain files, and changed the Makefile accordingly. 2007-09-10 17:28:57 +00:00