Commit Graph

435 Commits

Author SHA1 Message Date
Neil Brown
9b1368ffe7 Implemented all but one (RAN) of the intrinsic functions in appendix N by mapping them directly to the C versions 2009-01-27 13:38:00 +00:00
Neil Brown
c19039e90e Added the definitions of most of the intrinsics from the occam 2.1 manual (but not yet the implementations) 2009-01-25 18:54:57 +00:00
Neil Brown
7337978dcf Added many more intrinsics to the list of occam intrinsics 2009-01-23 19:19:36 +00:00
Neil Brown
c2aaf2fcf7 Provided more helpful errors in the test harness when something is wrong 2009-01-23 14:42:46 +00:00
Neil Brown
d806931fbf Revamped the TestHarness framework to allow multiple substitutions in a test prologue 2009-01-20 23:43:07 +00:00
Neil Brown
9145c993ea Fixed the constant folding to use a type for Int based on the compilation target rather than just assuming Int32
However, it is possible that there will still be a problem if the C and C++ compiler have different int sizes, because the constant folding has to know the type at compile time, and thus we have to arbitrarily choose to use the C version.  In future, we could perhaps swap all Ints for the appropriate substiution (e.g. Int64) at run-time, based on the flags and prior knowledge about C/C++ int sizes
2009-01-23 15:50:06 +00:00
Neil Brown
2a8ee9a420 Fixed a bug in the constant folding, where anything divided by -1 was being evaluated to zero 2009-01-23 15:48:39 +00:00
Neil Brown
de80ab467e Fixed the common Types module to work with the new channel-ends 2009-01-20 17:27:37 +00:00
Neil Brown
336c5abe3c Fixed the ShowCode module to work with the new channel-ends 2009-01-20 17:27:10 +00:00
Neil Brown
ee62c604fc Renamed our permutations function to permutation to avoid a conflict with a new GHC 6.10 function 2008-11-28 11:28:39 +00:00
Neil Brown
09e0e46ec2 Added some comments to my changes to GenericUtils 2008-11-25 18:06:14 +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
e117422c31 Added a couple more tests for checkUnusedVar which has revealed two bugs
One of these bugs is that array variables are counted as unused when they are used subscripted.  I think that should be solved when we flip back to the listify approach.

The second bug is more interesting, as it is triggered only in a certain arrangement with an IF.  It's either a bug in the flow-graph building or in the varsTouchedAfter code.
2008-11-20 15:06:36 +00:00
Neil Brown
5f01f12d43 Adjusted testOccamPassWarn to enable all warnings when testing a pass 2008-11-20 14:20:36 +00:00
Neil Brown
6cbdc0e13b Finally merged the list of warnings into CompState rather than having its own StateT monad 2008-11-20 13:35:44 +00:00
Neil Brown
f88c671cf7 Added a set of enabled warnings to CompState 2008-11-20 13:17:05 +00:00
Neil Brown
38374320a3 Moved the remainder of the checkInitVar tests over to the new system 2008-11-19 17:25:02 +00:00
Neil Brown
3b57d43eb6 Moved more of the checkInitVar tests to the new system 2008-11-19 17:08:17 +00:00
Neil Brown
810c798dac Added some copies of the checkInitVar tests that use the new occam EDSL testing instead of the old method 2008-11-19 16:53:13 +00:00
Neil Brown
f4ff507543 Moved wrapProcSeq into the TestUtils module 2008-11-19 16:09:31 +00:00
Neil Brown
e5ed7e07b7 Fixed the apply function, which (mainly due to having the wrong type signature, but also its use of extTransformRoute) was not as polymorphic as it should have been, which was breaking the traversal (I think it would only work on one Structured type) 2008-11-14 15:30:02 +00:00
Neil Brown
0d486f108f Added a value to indicate what type a warning is (to support future configurability) and streamlined the warning functions 2008-11-13 15:36:22 +00:00
Neil Brown
2a15f4ef5f Filled in all the gaps such that the CheckTest tests now run (including some debug output, for now)
One of the tests fails at the moment because the specification node has two entries associated with it in the flowgraph.  One is the scope-in and one is the scope-out.  I think the analysis is currently picking the scope-out node and looking beyond that, where -- surprise, surprise -- the variable is not used again.  So I need some easy way of telling the flow analyses which of the two nodes I want to start from, in this case and other ones where I also add two nodes related to the same point in the AST.
2008-11-12 16:54:00 +00:00
Neil Brown
98122211ad Got all the new analysis stuff compiling, but with several parts unimplemented 2008-11-12 12:34:32 +00:00
Neil Brown
dc030acabe Changed the FlowGraph stuff to use the new Route type (that includes identifiers) rather than the bare functions as it used to 2008-11-10 14:01:30 +00:00
Neil Brown
d0e2cd7b03 Finally wrestled the Haskell typechecker into submission to add my CheckFramework and its monads, which will hopefully do all that I need 2008-11-08 00:00:09 +00:00
Neil Brown
d6b102838a Added a Route data type that packages up the routing function and an identifier (to provide equality) 2008-11-07 10:08:16 +00:00
Neil Brown
d12b2178de Added an augmented version of Adam's gmapMFor that uses the same generics techniques, but also gives a route to the node to the transformation function 2008-11-06 18:32:35 +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
771297632d Finished converting all the cases in testInputCase to use the new occam EDSL 2008-11-16 16:57:52 +00:00
Neil Brown
9ac861ac93 Fixed the map ordering problem by matching against any permutation 2008-11-16 13:06:08 +00:00
Neil Brown
f2bac46655 Added a testPatternMatchOneOf function to check that something matches at least one of a list of given patterns 2008-11-16 13:03:28 +00:00
Neil Brown
6f54b89b38 Added a permutations function to the Utils module 2008-11-16 13:03:04 +00:00
Neil Brown
559ba83c28 Developed the occam EDSL further, adding support for input CASE statements, more type-classes to allow easier use and various other improvements 2008-11-16 12:21:22 +00:00
Neil Brown
02a28b7585 Made testOccamPass more general, so that it does not have to be applied at the top-level 2008-11-15 20:13:33 +00:00
Neil Brown
a570f2eff3 Renamed the variables in the occam EDSL to be less likely to clash in other modules 2008-11-15 20:11:52 +00:00
Neil Brown
f4d9c791ef Simplified the occam EDSL by removing the unnecessary monad in favour of plain lists, and added a way to separate expected output from input 2008-11-15 20:06:47 +00:00
Neil Brown
7764ed9326 Added a module for easily knocking up fragments of occam code to test, but need to remove some of the extravagance in the design (including an unnecessary monad) 2008-11-15 19:29:56 +00:00
Neil Brown
192ccd4e2c Extended the type unification for Rain to support type-checking things that are being poisoned (which could be either end of a channel) 2008-09-12 14:40:04 +00:00
Adam Sampson
87848ad7db Make the TypeSet representation a bit smarter.
It used to just be the list of target type keys. It's now a map from
all possible type keys to a precomputed hit/through/miss decision for
them. gmapMFor can therefore dig into "through" types without needing
to (fail to) apply the generic function first.

This makes less difference than I was expecting: it shaves the time
for cgtest24 from 2m30 down to 2m15.
2008-06-11 12:05:39 +00:00
Adam Sampson
62a0873d3d Implement channel direction decorators.
This is mostly straightforward: modify the parser to allow direction
decorators in the right places, and extend the type checker to match.
There's some slight awkwardness in that some of the Types functions
have to perform the same checks as the type checker (e.g. directing a
non-channel), so I've tidied up their error messages a bit.

At the backend, I've just added a little pass to strip out all the
DirectedVariables, since the other backend passes don't handle them
gracefully. From the occam/C point of view this is fine, but I'm not
sure if it's going to cause problems for C++.
2008-06-09 21:35:20 +00:00
Adam Sampson
19484ec72e Show channel attributes in occam code. 2008-06-09 12:36:26 +00:00
Neil Brown
b603b43b57 Added a subOne function (the dual of addOne) to the Types module 2008-06-06 10:43:30 +00:00
Neil Brown
d75bca3c0d Added a couple of new helper functions to the Utils module 2008-06-05 23:09:46 +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
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
59e0922263 Added a new operator to Utils (>.>, the flipped version of <.<) 2008-06-02 14:09:33 +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
4e6b166696 Fixed implicit mobility to work in the (C++, at least) backend 2008-06-01 19:46:32 +00:00
Neil Brown
e66ce1f810 Added a line to ShowCode for dereferenced variables 2008-06-01 19:25:33 +00:00
Neil Brown
969c04d42b Improved the Rain support in ShowCode a little 2008-06-01 17:58:40 +00:00
Neil Brown
155f58c174 Fixed the Rain parser tests with respect to the new type inference 2008-06-01 16:48:15 +00:00
Neil Brown
c4702a7f6e Added a new helper function, eitherToMaybe in Utils 2008-05-30 17:14:28 +00:00
Neil Brown
01e702acb2 Changed to print out the error context (based on the meta tag) on stderr instead of stdout 2008-05-30 16:40:21 +00:00
Adam Sampson
8b3eba594d Add SubscriptCheck field to SubscriptFromFor etc.
This makes it possible to mark a slice as not needing runtime
checking, which is immediately useful for _sizes arrays.

This fixes cgtest03, which was previously failing to compile because
the _sizes array for one of the constants in it contained a runtime
check and thus wasn't itself constant. I've added a testcase file for
the relevant bit of code.
2008-05-26 17:36:26 +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
35498a4d13 Renamed the "Typed" type-class to "ASTTypeable" as per the Trac ticket 2008-05-21 13:16:45 +00:00
Neil Brown
2300a5c3a7 Added a few extra cases in ShowCode, for some Rain things 2008-05-20 23:42:52 +00:00
Neil Brown
8c78d056b6 Improved display of unknown types (for debugging, really) 2008-05-20 22:07:35 +00:00
Neil Brown
7bbfab34a0 Added simple instances of the Typed class for actuals and formals 2008-05-18 09:42:51 +00:00
Neil Brown
fb090a3618 Hacked the ShowCode module quickly to display a lot more Rain code (stealing from the occam stuff, and twiddling it slightly) 2008-05-17 22:21:18 +00:00
Neil Brown
7d65db43c0 Changed TestHarness to support Rain test files as well as occam 2008-05-17 13:13:52 +00:00
Neil Brown
e6162877af Changed the AST to fix the different unknown/inferred types
The Infer type (used by the occam frontend) is now separated from the "Unknown" types used in type unification that I'm experimenting with in Rain.
2008-05-17 12:47:31 +00:00
Neil Brown
e843ce5022 Added a mapMapWithKeyM function to Utils, and cleaned up some of the whitespace 2008-05-14 12:18:27 +00:00
Neil Brown
962c1477b9 Added a special type for marking the type of numeric literals to be inferred later 2008-05-14 11:59:33 +00:00
Neil Brown
3ca4ee1a5e Added a new helper function to Utils for transforming Map values monadically 2008-05-13 23:24:43 +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
9f172865ff Move DataBox into Utils.
AnyDataItem is effectively the same, so we could reuse DataBox for that
too in the future.
2008-05-09 09:50:42 +00:00
Adam Sampson
0886ab9f9b Abstract the set of types that gmapMFor takes out to a type.
(No change in behaviour, yet.)
2008-04-08 23:13:58 +00:00
Adam Sampson
e460032c30 Remove debugging putStr from the QC-HUnit adaptor.
This was what was causing random numbers to appear during testing.

I've also cleaned up the code a bit.
2008-04-08 14:39:43 +00:00
Adam Sampson
9e9459cb4a Clean up EvalLiterals.
In particular, evalSimpleLiteral is now much nicer, and the error
messages should be a bit more comprehensible.

The signed types previously used a different version of fromRead that
passed an extra argument that it then didn't use; I've switched back to
the old version now, since it appears not to need it any more.
2008-04-08 00:29:23 +00:00
Adam Sampson
f1e9ffe230 In the evaluator, handle byte literals of any type. 2008-04-08 00:10:45 +00:00
Adam Sampson
bfd7b079a7 Make unsubscriptType handle Infer. 2008-04-06 18:42:40 +00:00
Adam Sampson
3ab0c30589 When rendering array literals, recompute the dimensions.
This makes sure that literals produced by the constant evaluator will never
contain UnknownDimension. The change looks a lot more complex than it really
is; it already carried the type "downwards", and most of this is just making it
carry it back up to where the A.Literal is being constructured.
2008-04-06 15:40:50 +00:00
Adam Sampson
1640b9ce63 Move applyDimension into Types. 2008-04-06 15:32:35 +00:00
Adam Sampson
b65512b64c Make getConstantName descend into definitions.
This means you don't have to have folded constants throughout the tree/state in
order to evaluate them, which makes the early passes less awkward to manage.
2008-04-06 13:46:48 +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
9838cf7b8c Use forall to remove some repeated monad constraints. 2008-04-06 11:19:43 +00:00
Adam Sampson
aa3b17b555 Make protocolItems give a more useful error message on failure. 2008-04-06 02:50:46 +00:00
Adam Sampson
e1fca531a0 Rework how OccValue is rendered to an Expression.
The rendering code now takes the type it's aiming for, so it can produce a
value of exactly the same type as the expression that was being folded
originally (rather than trying to work it out for itself).
2008-04-06 02:29:02 +00:00
Adam Sampson
2fdf749be0 Handle Infer in evalSimpleLiteral. 2008-04-06 02:28:43 +00:00
Adam Sampson
71df38813f Make subscriptType and trivialSubscriptType aware of Infer.
Subscripting Infer gives you Infer.

This also makes trivialSubscriptType handle user types in the same way as
subscriptType. (There probably isn't much reason to have both any more, since
subscriptType doesn't do the checks it used to do.)
2008-04-06 02:27:07 +00:00
Adam Sampson
e9d95aa0fd Tidy up OccValue a bit. 2008-04-06 00:48:02 +00:00
Adam Sampson
37b5735de1 When showing occam code, use CHAN/PORT rather than CHAN OF/PORT OF. 2008-04-05 23:19:12 +00:00
Adam Sampson
e52b51b050 Add an Infer type to mark types that should be inferred.
We can then check it's been removed using a property later.
2008-04-04 12:09:33 +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
20843f70a4 Corrected all the tests to use the new PassM monad 2008-03-10 17:07:48 +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
Adam Sampson
bd9c4dae98 Go back to passing the value to the type-contains function.
This'll make the modification to look at constructors cleaner.
2008-04-02 16:11:13 +00:00
Adam Sampson
f515b5ce55 Change "find" to "targets", for clarity. 2008-04-02 15:16:47 +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
aeb2ebd9f4 Fix Haddock. 2008-04-01 13:22:30 +00:00
Adam Sampson
d2bcd0cde5 Use IntMap.keysSet.
(Thanks to Neil for spotting this!)
2008-03-26 23:19: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
Adam Sampson
ef329e3ed0 Check SpecTypes. 2008-03-26 14:20:35 +00:00
Adam Sampson
c9cb7d2bf9 Check Proc calls. 2008-03-26 12:26:04 +00:00
Adam Sampson
6861b22da6 Check timer operations. 2008-03-25 16:45:25 +00:00
Adam Sampson
b3e3308b3e Implement channel IO checks, and refactor OccamTypes (again). 2008-03-25 15:56:03 +00:00