Commit Graph

90 Commits

Author SHA1 Message Date
Neil Brown
c8b724d2be Merged the latest set of changes from the trunk into the Polyplate branch
I also added the import list to all the Data.Generics imports in the tests (as I did for the other modules recently)
2009-04-10 20:38:29 +00:00
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
ae74752336 Fixed a bug introduced in the Polyplate merging where findDir wasn't working properly 2009-02-11 16:02:56 +00:00
Neil Brown
9294febd6f Converted addDirections to the Polyplate traversals, and fixed inferTypes to work in Polyplate (more merging from trunk) 2009-02-11 12:17:28 +00:00
Neil Brown
c69ea8815d Merged in the latest changes from the trunk into the Polyplate branch 2009-02-03 13:14:07 +00:00
Neil Brown
5a10e94c6a Fixed various conflicts between the Polyplate branch and the latest changes in the trunk 2009-01-28 15:48:08 +00:00
Neil Brown
2349474ba6 Fixed the occam modules to work with the new Polyplate type-classes 2008-12-14 18:52:52 +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
ce0214cbf4 Fixed operators defined inside functions not being recorded in csOperators 2009-04-10 16:07:18 +00:00
Neil Brown
e53da5822f Fixed a problem where operators with % in the name were screwing up an error message 2009-04-10 16:06:49 +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
397d8b7936 Resolved the types of the operators before searching through them for matches 2009-04-08 12:30:48 +00:00
Neil Brown
dc4cfe331b Made the operator search ignore the values of array dimensions, as it should do 2009-04-08 12:23:45 +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
a8c9802f5d Changed the occam type checker to handle checking user defined operators better
They are now recursed into with no type context, then afterwards the type is deduced.  This seems to be how they were meant to work, and is also much faster than what I was doing.
2009-04-07 15:52:06 +00:00
Neil Brown
e1c18cc082 Changed inferTypes to resolve operators to the right definition
This patch follows on from the previous change to the parser.  When it spots a function-call, it looks for operators and treats them differently.

It keeps a stack of operators in scope (csOperators in CompState), and when an operator is used, it searches the stack (with all old definitions masked out) for operator definitions to resolve to.

The way it chooses which operator to use in the presence of overloadings (e.g. + on INT vs + on INT32) is simply to try them all.  If one matches, it uses that.  If none, or more than one match, it gives an error.  This makes the code simple and seems logical, but I'm not totally confident if this is the required behaviour for resolving overloaded operators.
2009-04-05 23:01:26 +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
dbf886996a Removed various bits of old code relating to the old sizes mechanism 2009-03-31 10:50:04 +00:00
Neil Brown
63cb30802e Fixed the type inference for CLAIMs 2009-03-27 16:24:01 +00:00
Neil Brown
363ef6a9bc Made sure that user types are resolved when type-checking for occam 2009-03-27 09:44:05 +00:00
Neil Brown
9b753edde2 Got arrays abbrevs with unknown dimensions in the type to take the type from the RHS 2009-03-25 16:38:40 +00:00
Neil Brown
5418916245 Added the parsing of channel-array literals in PROC parameters 2009-03-25 16:38:21 +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
19e0fb0573 Added an AllocChannelBundle constructor in ExpressionList for assignments that allocate the two ends of a mobile channel bundle 2009-03-23 18:58:50 +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
2d232dd322 Fixed subscripting of channel bundles to be corrected like record field subscripts are 2009-03-23 15:53:56 +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
64f58f3770 Fiddled the occam type checker and inference to understand the basics of mobile types (and infer the dereferences) 2009-03-20 15:19:06 +00:00
Neil Brown
c787aa9fa5 Fixed a bug in the occam type inference where channels of arrays were not being processed properly 2009-02-27 17:01:07 +00:00
Neil Brown
a1585c74a9 Fixed inferTypes so that it again handles Specifications in Structured ExpressionList in function definitions 2009-02-11 11:53:04 +00:00
Neil Brown
6d5c01ac69 Changed inferTypes so that directions are inferred when channels (and arrays of channels) are abbreviated 2009-02-10 22:20:51 +00:00
Neil Brown
6db9b221af Moved the adding of direction specifiers out of the type inferrence pass into a new pass that runs before type inference 2009-02-10 21:34:42 +00:00
Neil Brown
68f808583b Added code to handle whole channels being passed to PROCs in the usage checking, and made sure they still obey the SHARED pragma 2009-02-10 12:34:28 +00:00
Neil Brown
80a3eba49a Had the first attempt at correcting the occam passes to work with the new array literals 2009-02-01 21:54:51 +00:00
Neil Brown
2c6f624ea3 Changed the occam type-checker and the Rain stuff to be okay with the new step count 2009-01-28 23:47:36 +00:00
Neil Brown
1410e80fb1 Added support for intrinsic functions with multiple return values
Previously, such a function was an IntrinsicFunctionCall inside one expression of an ExpressionList, which the type-checker rejected.  I've had to add a new constructor to ExpressionList, and I've quickly hacked together the line in the C backend to make it work -- but it does seem to work.
2009-01-23 18:58:52 +00:00
Neil Brown
fab6850041 Added code to infer the directions of undirected channel formals, where possible
Fixes #24

I still need to do a little more, however, to pass my more elaborate examples in the test file.
2009-01-23 15:59:02 +00:00
Neil Brown
a416f7dac9 Fixed the occam type-checker to work with the new channel-ends, adding direction specifiers where necessary
In actual parameters (checking against the formal type), abbreviations (checking against the inferred/specified destination type), and inputs (including inside ALTs) and outputs, direction specifiers are automatically added where needed.  With all the other changes, this seems to compile all the occam 2 cgtests, and cgtest87 (which tests directions) as well as Adam's tests so I'm fairly confident that it was the right thing to do.
2009-01-20 17:30:17 +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
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
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
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