Commit Graph

55 Commits

Author SHA1 Message Date
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
15a4a59bcf Stopped the pass that removes unused variables removing unused replicators 2009-01-23 14:24:44 +00:00
Neil Brown
766cb09dcf Changed pullUp to pull up channel arrays that have direction specifiers applied to the whole array
For example, a call like foo(6, cs!) will have cs! pulled up, iff cs was of type CHAN X.  If cs was of type CHAN! X, nothing is done (and the needless direction will be removed later on).
2009-01-20 17:33:24 +00:00
Neil Brown
6f22d8a573 Stopped the pulling up of fully-resolved array expressions where one of the subscripts is a slice
This was causing a problem in the C/C++ backends, where the slice function call was having _sizes appended to it.  So now we pull up anything that results in an array, or is a slice.
2009-01-15 22:44:11 +00:00
Neil Brown
9d1dfb7f5f Stopped arrays being pulled up when all the indices have been supplied 2009-01-15 21:36:05 +00:00
Neil Brown
b48129d4e5 Fixed some uses of Map.lookup that used the old system of it working with any monad (in GHC 6.10, it's always Maybe) 2008-11-28 11:38:06 +00:00
Neil Brown
0e7a6c5b98 Added a NameSource field for NameDef that indicates where a name comes from 2008-11-25 17:36:42 +00:00
Neil Brown
fe3dd78db3 Realised that pullRepCounts should pull the counts for PAR and ALT after all, and adjusted one test to reflect this 2008-11-16 18:43:34 +00:00
Neil Brown
bfacb526fb Converted one of the tests for pullRepCounts to use the new mechanism, which in turn exposed that the pass was not altering the definition in the state (which it may as well) 2008-11-16 18:25:53 +00:00
Neil Brown
5bc88ec1fc Fixed another test that was broken during the change to Rep 2008-06-04 18:43:50 +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
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
d044b51335 Renamed ndType to ndSpecType, as per Trac ticket #59 2008-05-21 13:38:51 +00:00
Neil Brown
4537cd205c Fixed the occam pass list so that it now has the correct order in respect to all the pre-requisite properties 2008-05-21 12:30:04 +00:00
Neil Brown
11588b34a3 Fixed a bug where transformConstr would skip over the second of two nested definitions of array constructors 2008-05-20 23:44:32 +00:00
Neil Brown
48fbf5f3e1 Added pulling up of list literals and list-constructed expressions 2008-05-20 23:44:07 +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
1977e7880b Move evalIntExpression into EvalConstants, now that Types doesn't need it.
It now uses the full expression evaluator rather than the literal-only version.
2008-04-06 13:31: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
Neil Brown
0ed18c933f Fixed pullUp to not pull up list expressions
This patch looks like I removed the wrong line above, but it was identical to the line I actually removed, so the patch is fine, it just looks odd.
2008-03-23 11:49:42 +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
9cea36257e Make functionsToProcs depend on expressionTypesChecked.
I think in general typechecking needs to happen before any other pass runs,
else the user's likely to get rather confusing error messages.
2008-03-22 00:04:53 +00:00
Neil Brown
14e375247c Added an error message to transformConstr for when the type is not supported 2008-03-21 19:32:07 +00:00
Neil Brown
cfccd38c51 Changed transformConstr to transform list-typed array constructors to build up a list rather than subscripting it 2008-03-21 19:22:29 +00:00
Neil Brown
a1daf15576 Pulled up list expressions in a similar way to array expressions 2008-03-21 19:21:46 +00:00
Neil Brown
da5801ad03 Refactored transformConstr to pull out some of its working into helper functions 2008-03-21 19:13:54 +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
e2f5d18169 Added a case in pullRepCountSeq for ForEach replicators 2008-03-19 17:15:14 +00:00
Neil Brown
cb819d142a Altered transformConstr to handle array constructors with types in them 2008-03-19 13:23:20 +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
b21f020862 Make SimplifyExprs compute the type of the variable it declares.
This lets you say things like:
  VAL []INT xs IS [i = 0 FOR 20 | i]:
and have it figure out that the type of xs is really [20]INT.

This also cleans up the code a very small amount.
2008-03-17 18:33:04 +00:00
Adam Sampson
ca230be268 Use Prop.agg_typesDone rather than listing its members. 2008-03-17 15:47:29 +00:00
Neil Brown
c1f0ff92c9 Corrected the transformation of AFTER for the BYTE type 2008-03-09 16:26:50 +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
ba75f5b06c Removed the initialiser expression on the Declaration item in the AST 2008-03-09 00:23:13 +00:00
Neil Brown
f0fceb5aee Stopped array literals being pulled up out of record literals in C++, now that the array handling has been changed 2008-03-07 15:48:24 +00:00
Neil Brown
9ab6cbc0b4 Changed the pullUp function to behave differently for C than C++ (pulling up of array literals inside record literals) 2008-02-29 03:05:52 +00:00
Neil Brown
46de1956b3 Corrected the pulling up of SEQ replicator counts to descend properly into nested functions 2008-02-27 19:58:09 +00:00
Neil Brown
86c17fed99 Added a pass for pulling up the replicator counts in SEQs so that the count is constant for the whole loop 2008-02-27 19:33:44 +00:00
Neil Brown
b0fac1f82a Made sure that definitions are only pulled up after protocol inputs have been flattened 2008-02-27 17:20:52 +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
1edaacae89 Altered the AST to allow a function to be either an ExpressionList (classical occam) or a Process (Rain/proposed new occam) 2008-02-24 19:29:31 +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