Commit Graph

2292 Commits

Author SHA1 Message Date
Neil Brown
f69030df34 Changed the names of generated tock files to have ".tock" before the extension
This helps avoid collisions with pre-existing files, especially .inc files (but also .c and .h)
2009-04-02 15:40:39 +00:00
Neil Brown
ea14f568fa Removed genProcName
Everything that used it has now switched back to genName, as we don't need this occam_ prefix with the new name munging stuff from earlier patches.
2009-04-02 15:39:19 +00:00
Neil Brown
1cb17a85c4 Removed a lot of the junk from the lexer I'd recently added
The lexer is now roughly as it was a couple of weeks ago.
2009-04-02 15:36:42 +00:00
Neil Brown
51f67f59b4 Reworked the pragma generation again for occam PROCs
One change, based on Adam's suggestion, was to rename the pragma to TOCKEXTERNAL.

Another, also based on Adam's suggestion, was to generate both the munged name and the original name, which allows (along with a previous patch) different files to declare the same PROC, and will remove the need for the occam_ prefix in the backend.

I also stopped using specific states in the lexer, in favour of just using the normal lexing function (which has had its type generalised slightly).
2009-04-02 15:33:32 +00:00
Neil Brown
ca818d423c Made the munging of the names include the file name, to help with separate compilation
This will allow (along with a few patches in a minute) different occam files to declare the same PROC, and have it resolved correctly based on the order of their declaration, just like if it was all in one file.
2009-04-02 15:31:50 +00:00
Neil Brown
c79fd70959 Made sure that warnings are shown along with errors in the parser
The solution is a bit hacky, but this was an important problem.  If your PRAGMA failed to parse, that was worthy of a warning.  But if that then caused the parse to fail, all you would get is the parser error (could not find name), and you would never see the warnings about the pragmas not being recognised.  So now the pragmas are shoved into the error (using a basic encoding) and pulled out and issued if the parser dies.
2009-04-02 15:07:39 +00:00
Neil Brown
a307e39d47 Added a Read instance for Meta (taken from my benchmarks for the ICFP paper) 2009-04-02 15:07:17 +00:00
Neil Brown
3a0b251235 Fixed rangetest to work with the new support headers (it doesn't need the CIF header, only the plain header) 2009-04-02 13:20:35 +00:00
Neil Brown
ba2f62114a Fixed the C tests to compile again after the most recent changes 2009-04-01 19:58:47 +00:00
Neil Brown
37ff130ec9 Stopped static being generated in front of typedef 2009-04-01 19:58:30 +00:00
Neil Brown
ef36c39c38 Stopped the C code generating extern declarations for occam PROCs (it should only do this for C PROCs) 2009-04-01 19:51:43 +00:00
Neil Brown
e28bff5a50 Added code to put static before every identifier that is not being exported, to avoid collisions between occam files 2009-04-01 19:50:15 +00:00
Neil Brown
c85dc01842 Changed the cgtests Makefile to use the new separate compilation for cglib 2009-04-01 19:25:40 +00:00
Neil Brown
a1d9fcdff2 Fixed a bug in the C types for arrays of channel-ends 2009-04-01 19:25:19 +00:00
Neil Brown
7e7a437a3b Switched to using a different kind of pragma for occam externals, and munged the names to avoid collisions
The separately compiled occam PROCs now use #PRAGMA OCCAMEXTERNAL, which also discards the "= number" thing at the end.  These PROCs then need to be processed differently when adding on the sizes (C externals have one size per dimension, occam externals have the normal array of sizes).

We also now record which processes were originally at the top-level, and keep their original names (i.e. minus the _u43 suffixes) plus an "occam_" prefix to avoid collisions.
2009-04-01 19:21:40 +00:00
Neil Brown
5bf1ffa785 Made the preprocessor correct the path a #USEd file when it finds it on the search path while including it 2009-04-01 18:59:57 +00:00
Neil Brown
91092c17ff Added some missing static specifiers to some occam support functions 2009-04-01 18:59:10 +00:00
Neil Brown
8153cfc659 Added code for full compilation mode to include the relevant C files from occam #USE directives, and link to the relevant object files 2009-04-01 18:32:39 +00:00
Neil Brown
d457b793c0 Added code that allows any external PROCs not beginning with B or C to be handled as normal
This shows that my current scheme is a bit of a hack; if an occam programmer starts a normal PROC with B or C, it will be treated funny during separate compilation.  In future I probably need some new form of #PRAGMA to support separate compilation, different from that used to interface with C.
2009-04-01 17:29:32 +00:00
Neil Brown
7b55c96781 Fixed up the parsing of PRAGMAs to make it a bit simple, and match with other changes to the lexer and parser 2009-04-01 17:26:27 +00:00
Neil Brown
1e538fc592 Fixed ShowCode to print direction specifiers in the right place after variable names, as it's important now that what we spit out for PROC headers is legitimate occam 2009-04-01 17:08:04 +00:00
Neil Brown
4c4fccc1a2 Corrected the lexer (no vertical space after pragmas with the new way of doing them) 2009-04-01 17:07:37 +00:00
Neil Brown
512d05dd36 Removed the redundant warnings from the occam parser (after I put them back into CompState, a long time ago) 2009-04-01 16:56:37 +00:00
Neil Brown
db9b8e9d91 Changed where we generate the .inc file from being in the backend, to being a pass just after type-checking
We need to generate the externals after we've inferred channel directions, but before we do further work (like adding _sizes parameters and so on).
2009-04-01 16:54:07 +00:00
Neil Brown
abce001bab Added a command line option to indicate that there is no main PROC 2009-04-01 15:29:22 +00:00
Neil Brown
219bfd9ce1 Modified the C backend so that it will put the forward declarations into a header file and include that 2009-04-01 14:35:47 +00:00
Neil Brown
b830b27066 Added a couple more settings to CompState to set the locations of the (C and occam) header files (but not made them available via the command-line, just yet) 2009-04-01 14:34:13 +00:00
Neil Brown
e9730bfe1e Got the C++ backend working again, on the cgtests at least 2009-04-01 15:25:18 +00:00
Neil Brown
e91c075bcf Fixed up a lot of the failing tests
I changed a little bit of the code, but mainly the tests.  Several of the remaining failures are actually real failures, so I need to dig through the rest carefully.  A lot are failing because the C++ backend is broken.
2009-04-01 11:49:37 +00:00
Neil Brown
bea4dcfd80 Took out some C garbage, which gets around 200 more tests passing 2009-03-31 18:02:39 +00:00
Neil Brown
56e5b8da8e A mega-patch that gets tocktest compiling again
However, around a quarter of the tests currently fail...
2009-03-31 17:56:56 +00:00
Neil Brown
8ee32f0795 Made sure that record literals are pulled up (perhaps this accidentally lost in the past?) 2009-03-31 16:51:02 +00:00
Neil Brown
2941cbd049 Fixed a problem with record abbreviations being pulled all the way up to the top (which C doesn't like) 2009-03-31 16:50:42 +00:00
Neil Brown
33ca2fe253 Made sure that user types are resolved when fixing array constructor types 2009-03-31 16:19:18 +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
91ce2fe960 Fixed generation of actuals that are ActualExpression (ExprVariable {}) 2009-03-31 16:08:37 +00:00
Neil Brown
3566c6206f Fixed retyping non-packed records into arrays 2009-03-31 16:08:24 +00:00
Neil Brown
9f5b685c02 Corrected a nasty problem with pulling up free names into arguments
The problem was that the free name could involved in an array dimension (and hence a type) of something in the PROC.  When the name was then replaced in the type, CompState was not updated to have the new type, and instead kept the old type (potentially) all the way through to the backend, where it might be used for checking the bounds of an array index (against the old name taken from CompState, not the replaced name).
2009-03-31 11:51:02 +00:00
Neil Brown
334d22acd8 Corrected a try, so that we don't mistake a CHAN type for a CHAN TYPE type 2009-03-31 11:50:24 +00:00
Neil Brown
dbc3b97343 Changed the lexing and parsing of PRAGMAs again, to allow unknown pragmas
With my previous change to PRAGMAs, unknown pragmas would fatally fail in the lexer, so that an unknown pragma would always stop compilation, which is not good.  I've changed it more towards Adam's suggestion of re-lexing and re-parsing the pragma from the parser, so we now gracefully ignore unknown pragmas again.  The lexer is a bit messy, though.
2009-03-31 11:08:53 +00:00
Neil Brown
edc336de7a Fixed a bug when generating some no-arg PROCs 2009-03-31 10:50:52 +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
4d2cdc0a9d Altered the backend passes to use all the new VariableSizes mechanisms rather than the old stuff
This is quite a big patch, as it reworks a large pass.  The three backend passes dealing with sizes stuff have now been merged into one (because the traversal order is important).

Instead of generating sizes arrays by blindly appending "_sizes", we now create nonces and store them in the csArraySizes map in CompState, which is a bit less hacky.

Added to that, we also generate constant-size arrays (e.g. for [8]) -- which are needed in case we pass the array to a PROC that has a flexible dimension -- at the top of the whole program, and use that array for every variable with that size (so if foo and bar have the same size, we use the same sizes array from the top of the program).
2009-03-31 10:22:34 +00:00
Neil Brown
a10921d53a Fixed the last few uses of genSizeSuffix in GenerateC to use the new system instead 2009-03-31 09:35:59 +00:00
Neil Brown
f749967af4 Added some cases inside genVariable to handle the VariableSizes item
For mobile arrays, this uses the ->dimensions member.  For normal arrays, it uses the associated sizes array (by looking it up in CompState).
2009-03-31 09:34:36 +00:00
Neil Brown
298ba6465a Removed genSizeSuffix and turned most uses of it into calls to genDynamicDim 2009-03-31 09:29:55 +00:00
Neil Brown
b8daebfbc3 Made genDynamicDim a top-level function, and change its implementation to use VariableSizes rather than C-specific stuff 2009-03-31 09:28:45 +00:00
Neil Brown
e1cd694c27 Added code to pull up any VariableSizes expressions (since they result in an array) 2009-03-31 09:22:59 +00:00
Neil Brown
654dd453f1 Replaced another use of SizeVariable with VariableSizes (via specificDimSize), in SimplifyExprs 2009-03-31 09:22:38 +00:00
Neil Brown
af9ab28718 Replaced a use of SizeVariable with VariableSizes (indirectly) in SimplifyProcs 2009-03-31 09:21:32 +00:00