Commit Graph

325 Commits

Author SHA1 Message Date
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
81959bd76b Added quick preliminary support for the PERMITALIASES pragma 2009-02-10 01:01:23 +00:00
Neil Brown
f2c7bad3e2 Added a pass that turns directed subscripts into subscripted directed arrays, to make the usage checking easier 2009-02-09 12:14:01 +00:00
Neil Brown
9c4b8e8df1 Changed tocktest so you can pass it -v options for use with the automatic tests 2009-02-08 16:33:53 +00:00
Neil Brown
78606faaae Reintroduced the transformRangeRep pass, and fixed the transformEachRange pass (along with fixing the relevant tests) 2009-02-03 12:31:54 +00:00
Neil Brown
41cca68e4e Simplified the Rain parser by reintroducing a RangeLiteral item that will get replaced by an early pass 2009-02-03 12:24:10 +00:00
Neil Brown
6afbb80e9f Fixed some of the test modules to work with the new array literals and constructors 2009-02-03 11:19:21 +00:00
Neil Brown
0bffd42cad Fixed a missing case (an empty array) in one of the occam passes 2009-02-02 23:51:37 +00:00
Neil Brown
4b3090b66a Fixed the fixConstructorTypes pass to work properly and put it back into the pass list (having removed it earlier today) 2009-02-02 18:27:04 +00:00
Neil Brown
1591940996 Removed the fixConstructorTypes pass for now
This pass was responsible for screwing up the types of all arrays after type inference, and the compiler seems to work fine without it
2009-02-02 16:07:47 +00:00
Neil Brown
cbeeef486e Fixed the C backend putting too many braces in array literals, and removed some old comments 2009-02-01 22:27:43 +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
7d185fd72a Adjusted the Rain passes to cope with the new array literals 2009-02-01 21:54:32 +00:00
Neil Brown
46394b8c34 Fixed the occam and Rain parsers to work with the new system for array literals 2009-02-01 21:54:02 +00:00
Neil Brown
4f83187549 Fixed up all the tests in light of the new recursive procs 2009-01-29 00:56:32 +00:00
Neil Brown
8a28d765e7 Implemented recursive procs
This works fine in the C++ backend, not tested with the C backend yet
2009-01-29 00:43:24 +00:00
Neil Brown
10e6b4ce02 Updated all the tests to work with the new recursive functions 2009-01-29 00:34:12 +00:00
Neil Brown
7722e95dfd Added support for recursive functions (not procs, yet)
At the moment, the information is only needed in the parser, which must define recursive names before parsing the body of the function.  But in future, we should keep the information when the function becomes a proc, and then the C/C++ backends may need to use it (for example, when calculating stack space usage)
2009-01-29 00:27:11 +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
6d7f456791 Changed the occam parser to accept STEP in replicators 2009-01-28 23:47:00 +00:00
Neil Brown
e1056dd0c9 Changed the lexer to accept the STEP reserved word 2009-01-28 23:46:36 +00:00
Neil Brown
49ea4f053e Fixed the occam parser to allow comments after pragmas on the same line
One of the more recent cgtests has a comment after a pragma
2009-01-28 23:40:14 +00:00
Neil Brown
6ff8e3b163 Fixed a bug where records were being recorded with the wrong name type in the occam parser 2009-01-28 22:11:23 +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
1adca155dd Added a file full of tests for inferring direction specifiers in PROC formals 2009-01-20 23:43:42 +00:00
Neil Brown
1f4796e07f Fixed all the tests to reflect the new channel-end system, such that they all pass again
This is the last patch (for now) of the set implementing the new channel-end system
2009-01-20 17:41:44 +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
Neil Brown
4d692c8897 Fixed the occam and Rain parsers to work with the new channel-ends
For now, I have fixed the occam parser so that it allows 1 or more direction specifiers after channel names.  So c?? is valid, and should end up being equivalent to c?, but this may need altering later.
2009-01-20 17:28:57 +00:00
Neil Brown
8a36f6e96f Added support for parsing pragmas, for now just handling the SHARED pragma 2009-01-19 15:11:09 +00:00
Neil Brown
46a1cc311f Moved a couple of fields related to Rain type checking out of CompState and into a temporary StateT monad for the appropriate pass 2008-12-02 20:59:26 +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
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
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
Neil Brown
4c263dba7e Added support for poison to the lexer and parser (and associated tests) 2008-09-12 14:39:57 +00:00
Adam Sampson
f102d8e7ef Make "PORT" work for "PORT OF". 2008-06-11 13:18:54 +00:00
Adam Sampson
638a3f3c22 Allow a directed channel array to be sliced.
This lets you write things like "[cs! FOR 5]", which is horrible; I
would prefer "[cs FOR 5]!", since then that doesn't imply that you can
do things like "cs![0] ! 0".

However, Tock now compiles and passes cgtest87 -- the first occam-pi
cgtest we've handled. :)
2008-06-09 21:42:34 +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
64e86b22fe Fixed some StructureOccam tests that were broken recently by the change in the Token type 2008-06-06 13:14:34 +00:00
Adam Sampson
ab416326ad Make Token a real data type.
Previously it was a tuple, which meant it couldn't have sensible
custom instances. Token and TokenType now have Show instances, so we
get more useful output when parsing fails.
2008-06-05 09:46:52 +00:00
Neil Brown
4c726352a4 Removed an obsolete failing Rain test 2008-06-04 18:44:07 +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
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