Commit Graph

258 Commits

Author SHA1 Message Date
Neil Brown
7e0bc775bf Changed the writtenVars entry of Vars to be a map from variables to (assigned-from) expressions
The expressions are optional (wrapped in a Maybe type)
2008-06-05 20:30:44 +00:00
Neil Brown
936382a3ca Renamed labelFunctions to labelUsageFunctions, to make it clearer what the functions are for 2008-06-05 20:16:02 +00:00
Neil Brown
069cfd9a9f Fixed the pulling up of replicators when they are free names (something that was broken in the original Rep change) 2008-06-04 19:06:05 +00:00
Neil Brown
e2dac3aa76 Simplified freeNamesIn by removing what is an unnecessary case for replicators 2008-06-04 19:05:31 +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
Adam Sampson
f2352019ab Implement INITIAL and RESULT abbreviations.
This adds the passes to transform INITIAL into the correct form.

Fixes #42.
2008-06-03 14:57:24 +00:00
Adam Sampson
6ee21f76c9 Initial work on supporting INITIAL and RESULT abbreviations.
This fixes the AST, parser and typechecker, and adds a pass to
transform Result back into Abbrev, but doesn't transform Initial yet.
(It actually works for trivial stuff anyway, but it won't do the right
thing for complex types or PROC parameters.)

It appears (to me) to make sense to support INITIAL/RESULT reshaping
and retyping too, so this does.

Refs #42.
2008-06-02 20:41:37 +00:00
Adam Sampson
f811d2cdc9 Clean up some remaining messy code after the passes rework. 2008-06-02 17:04:30 +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
Neil Brown
0adbdda126 Moved all the pass information about the Rain passes into their definition (rather than the pass list at the top)
As part of this patch, I have also introduced a helper function that fiddles the type system for those passes that must run at the top-level (i.e. on A.AST) rather than on any Data t.  They will give an error if not applied at the top-level.
2008-06-02 12:51:14 +00:00
Adam Sampson
cf79f9c284 Get rid of the nasty ghost names hack.
Rather than prefixing the names, there's now a set of ghost names in
CompState.

Fixes #66.
2008-06-02 10:58:26 +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
Neil Brown
5301b83148 Added code to actually make the implicit mobility decisions take effect in the tree 2008-06-01 19:28:22 +00:00
Neil Brown
600ce667cb Refactored the code for making and printing out the move/copy decisions in the ImplicitMobility module 2008-05-30 18:28:40 +00:00
Neil Brown
947f252e66 Corrected the implicit mobility so that it now works properly on the Rain move testcase 2008-05-30 17:29:21 +00:00
Neil Brown
a5fca4816b Added the beginnings of support for implicit mobility for Rain (just printing out the decisions for now) 2008-05-30 17:16:10 +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
d044b51335 Renamed ndType to ndSpecType, as per Trac ticket #59 2008-05-21 13:38:51 +00:00
Neil Brown
8943b767eb Fixed the SimplifyTypes module
This fixes Trac ticket #46.  The pass for masking out state bodies has been moved to PassList (since it's so small and should be run first) for now, and SimplifyTypes has had its previous two passes merged into one.
2008-05-21 13:12:49 +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
Neil Brown
3daf82d318 Merged Alternative and AlternativeCond into a single Alternative item that always has a pre-condition 2008-04-03 14:52:37 +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
cbbafffbd2 Changed Rain to use the new timer type rather than things like the GetTime statement 2008-03-24 13:50:14 +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
Neil Brown
4e9a00a5b7 Added support for for-each replicators to the freeNamesIn function 2008-03-23 00:08:48 +00:00
Adam Sampson
e23a12c71d Don't resolve user types until after type checking.
This is important -- a user type defined as INT in occam must not be treated
the same as INT when typechecking.
2008-03-22 00:12:54 +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
f7141bda6f Corrected transformConstr0 2008-03-21 20:02:33 +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
b496912c51 Fixed conflicts with Adam's dimension changes 2008-03-19 17:49:32 +00:00
Neil Brown
e2f5d18169 Added a case in pullRepCountSeq for ForEach replicators 2008-03-19 17:15:14 +00:00
Neil Brown
722499b05d Adjusted the test for transformConstr to work properly with the new array constructor type 2008-03-19 13:29:02 +00:00
Neil Brown
db0467f1ca Adjusted the rain passes to use the new array constructor type, and weaned a few of them off everywhereM 2008-03-19 13:24:15 +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
52d72647ae Fix the transformConstr0 test by defining x. 2008-03-20 11:23:45 +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