Commit Graph

91 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
e61a23855a Fixed all the conflicts while merging into the Polyplate branch 2009-04-09 11:01:39 +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
5534d1c3d6 Fixed some problems with DATA TYPEs that were actually MOBILE stuff not being resolved at the right points 2009-04-12 13:50:59 +00:00
Neil Brown
ddbec737f2 Got all the tests compiling again after recent changes
For some reason, the usage check tests are now very slow to run (perhaps because of all the operator definitions added to each one?), which needs further investigation.
2009-04-10 19:29:40 +00:00
Neil Brown
92c92a3f65 Fixed various small mobile typing issues 2009-04-09 17:05:16 +00:00
Neil Brown
229f2197af Turned findMeta into a member of a FindMeta type-class 2009-04-09 11:13:37 +00:00
Neil Brown
998cf1c005 Fixed various bits of type-inference in OccamTypes 2009-04-09 10:00:03 +00:00
Neil Brown
de097bb138 Fixed type-checking on ambigious record fields, so that now the cgtests are happy again 2009-04-08 19:11:33 +00:00
Neil Brown
5c353f10b7 A big patch to get ArrayUsageCheck compiling again, with the new operators 2009-04-08 15:44:35 +00:00
Neil Brown
009cf8cc8b Added a helper function like functionOperator, but that only gives back a Just result if the operator is a non-overridden version 2009-04-08 15:15:47 +00:00
Neil Brown
1ea35c6715 Fixed the name munging for declared user-defined operators 2009-04-08 12:14:05 +00:00
Neil Brown
d782c91ed0 Added some missing occam operators to the various lists 2009-04-08 12:03:48 +00:00
Neil Brown
26be673ce1 Made sure that user-defined types are resolved before looking for matching operator definitions 2009-04-08 10:18:14 +00:00
Neil Brown
62dfdec9ab Added a translation routine to the Types module to turn occam operators into C-friendly names 2009-04-07 16:12:37 +00:00
Neil Brown
f7e114f2fd Overhauled the Types module and ParseOccam to support the new system of operators-as-functions
The idea behind this is to parse unary/binary operators into function calls with 1/2 operands.  So the AST actually has a FunctionCall with the name "+".  Function names may now be quoted operators, and thus you can also have function declarations with names such as "+".  Resolving is *not* done in the parser for these function names, but rather every "+" is left as "+" (no matter what types it operates on, or what is in scope) by the parser (see later patches to InferTypes instead).

When parsing an occam source file, we automatically insert a bunch of PRAGMA TOCKEXTERNAL that define the default occam operators (e.g. + on INT) as external C functions (which they are!).  The naming scheme for these C functions is standardised, and must be used by functions such as mulExprs (which bases the function on the type of its operands) and the new versions mulExprsInt (which are pegged to INT).

The Types module also has some new functions for dealing with operator-functions.
2009-04-05 22:54:05 +00:00
Neil Brown
2edf5cc43d Fixed constant folding to resolve any user types involved
Due to awkward module dependencies, some functions had to be moved around to accommodate this change.  Two from Types have gone to EvalLiterals, and two to CompState.  Everything still compiles just as before though.
2009-03-31 16:11:00 +00:00
Neil Brown
dbf886996a Removed various bits of old code relating to the old sizes mechanism 2009-03-31 10:50:04 +00:00
Neil Brown
1144975abc Added support for VariableSizes to the Types module, including a helper function: specificDimSize 2009-03-30 15:30:46 +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
34ae9861d0 Marked up channel bundles as being mobile 2009-03-23 21:12:36 +00:00
Neil Brown
78f9fb6196 Added support in recordFields for channel bundles (which are similar enough to records) 2009-03-23 18:59:41 +00:00
Neil Brown
04108613d9 Added support to a couple of functions for the IsClaimed SpecType 2009-03-23 18:56:48 +00:00
Neil Brown
41805aaacf Changed the ChanEnd constructor to only keep information about its shared-ness, not about the whole channel 2009-03-23 18:40:28 +00:00
Neil Brown
8492dc03d4 Introduced a ShareMode in the AST, and used it in the channel attributes (rather than Bool) 2009-03-22 22:29:39 +00:00
Neil Brown
0a97946fbf Fixed various type-checking things related to mobile types 2009-03-22 21:05:36 +00:00
Neil Brown
4f6050069c Moved isMobileType into the Types module where it belongs 2009-03-22 18:26:14 +00:00
Neil Brown
03f1b2d115 Added a few more mobile things (DEFINED keyword, an intrinsic) 2009-03-20 20:53:51 +00:00
Neil Brown
3a7b2aaaf4 Added a function for getting the attributes of a record type 2009-03-20 19:10:11 +00:00
Neil Brown
1044a94730 Changed most of the rest of Tock (except some tests) to understand the new record attributes 2009-03-20 15:18:29 +00:00
Neil Brown
65875f523f Added mobile cloning rather than using dereferencing to copy mobiles 2009-03-19 16:47:31 +00:00
Neil Brown
ca61da25cf Added a function to the Types module to allow you to easily change the type of a SpecType 2009-03-19 15:13:00 +00:00
Neil Brown
0d5c8f28fd Fixed a couple of helper functions to navigate through mobile arrays properly 2009-02-27 17:09:14 +00:00
Neil Brown
4055746e19 Fixed typeOfVariable to handle directed inferred variables 2009-02-10 22:20:02 +00:00
Neil Brown
8de2dbca88 Adjusted the modules in common to match the new array constructor change 2009-02-01 21:52:13 +00:00
Neil Brown
594d7ef242 Tweaked various code in the common and checks directory to work with the new step count in the For replicator 2009-01-28 23:43:16 +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
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
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
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
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
7bbfab34a0 Added simple instances of the Typed class for actuals and formals 2008-05-18 09:42:51 +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
bfd7b079a7 Make unsubscriptType handle Infer. 2008-04-06 18:42:40 +00:00
Adam Sampson
1640b9ce63 Move applyDimension into Types. 2008-04-06 15:32:35 +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
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