Commit Graph

106 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
78716a2727 Added a CHP backend option to Tock 2008-11-26 12:24:21 +00:00
Neil Brown
2690ec1d1b Fixed the munging of names to always use the Meta tag again 2009-04-10 19:28:03 +00:00
Neil Brown
e462da4a76 Added a system for specifying implicitly-used modules on the command-line
An implicitly used module is equivalent to a #USE directive before the first line of the main file.  This, combined with changes in occbuild, are my current way of implementing the automatic use of the forall module in occam.
2009-04-10 19:26:22 +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
49d6e2aaaf Reworked how the stack sizes are recorded and merged together
The previous method, using the C preprocessor was both nasty, and crazily resource-intensive.  The new method stores stack size information in files that are read in and processed by the compiler when it comes time to link.
2009-04-07 16:03:52 +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
7b4a6c812c Removed monadic and dyadic operators from the AST
This is the first part of a change, suggested in #64, to remove operators in favour of functions (which will also allow user-defined operators).

The ticket suggested removed operators after the parser, but the way it's working out, it is fine to just never represent as anything other than function calls.

All the knock-on changes will be recorded in later patches.
2009-04-05 22:31: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
2a321d7910 Added a NameExternal item to NameSource, to stop using NamePredefined for externals 2009-04-04 14:56:00 +00:00
Neil Brown
cfcf50297f Added the new tock include directory to the standard search path 2009-04-04 12:29:53 +00:00
Neil Brown
45db9cdd27 Realised that my bits and bytes per word were somewhat mixed up 2009-04-03 20:19:48 +00:00
Neil Brown
c0ead7b5a8 Added some of the standard occam defines, such as TARGET.BITS.PER.WORD
For the moment, TARGET.HAS.FPU is left out, because a lot of occam libraries seem to do ASM if it's defined, and we can't handle ASM
2009-04-03 17:55:12 +00:00
Neil Brown
5f124636fb Fixed the name munged to be stable for #USE directives, but use the old name counter for #INCLUDE directives
This is necessary because occam files often #INCLUDE something multiple times (e.g. cgtests) and want different names, but this is not the case for #USE.
2009-04-03 16:52:40 +00:00
Neil Brown
427938039c Implemented a search path for Tock (for #INCLUDE and #USE directives) 2009-04-03 16:51:00 +00:00
Neil Brown
d6ad0ba202 Made the name of record-copying PROCs different for each file that generates them, to avoid clashes at link time 2009-04-03 10:25:55 +00:00
Neil Brown
dbc1b461a4 Made makeNonce use the munged meta-tag, to stop wrapper PROCs from different files having name clashes at link-time 2009-04-02 20:02:11 +00:00
Neil Brown
460c3e287f Changed names to be uniquified based on their source position, and fixed the source position for things in pragmas
The second part of the patch is essential, given the first.  Otherwise names in different pragmas in the same file can overlap -- this already happened in oak!
2009-04-02 17:45:31 +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
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
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
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
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
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
904d19a6a5 Added a new VariableSizes constructor to Variable that will supplant SizeVariable and AllSizesVariable 2009-03-30 15:28:38 +00:00
Neil Brown
b86ffbbf3b Added two new items to CompState, which will help to replace the _sizes suffix 2009-03-30 15:13:56 +00:00
Neil Brown
6e66cf7521 Added a command-line option to change how much stack the unknown functions are given 2009-03-26 22:49:38 +00:00
Neil Brown
eb99480484 Finished off the support for external C functions 2009-03-26 22:37:28 +00:00
Neil Brown
95d7144c7b Added the ability to specify linker flags separately from C compilation flags 2009-03-26 22:36:13 +00:00
Neil Brown
09093cff12 Added the ability to print out HTML-highlighted lexed occam
This falls a bit outside the compiler's remit, but it will be the same code to print out the lexed occam without highlighting, which I plan to use for doing libraries with Tock in a bit.
2009-03-26 22:34:34 +00:00
Neil Brown
633a3dbbc5 Quickly added a command line option to allow you to specify flags to pass to the C/C++ compiler 2009-03-25 22:35:49 +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
53f7378988 Merged IsClaimed, IsChannelArray and IsExpr into Is, which now takes an Actual 2009-03-24 23:56:53 +00:00
Neil Brown
5ffea3f78e Added a lex mode to Tock that shows how a program was lexed 2009-03-24 18:18:55 +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
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
1edabee2e7 Changed the AST claim element to be an abbreviation rather than a process 2009-03-23 15:52:19 +00:00
Neil Brown
5f9d0c6429 Added various keywords, AST elements and parser bits related to channel bundles, claim blocks and shared channels 2009-03-22 22:49:49 +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
03f1b2d115 Added a few more mobile things (DEFINED keyword, an intrinsic) 2009-03-20 20:53:51 +00:00
Neil Brown
1c0f4d17ca Changed the RecordType item to support multiple attributes (including mobility) 2009-03-20 15:17:15 +00:00
Neil Brown
1343954c2f Added an option to automatically run indent on C/C++ source before running GCC
This option is very handy when debugging the C/C++ output of Tock when GCC gives a compiler error.
2009-03-21 18:25:09 +00:00
Neil Brown
65550b705e Added an AllSizesVariable item to the AST so that the backend inserts the right code for mobiles and non-mobiles 2009-03-20 11:31:14 +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
b970b9df33 Added command line options for occam 2 mobility, and turned it off by default 2009-03-19 11:38:48 +00:00
Neil Brown
823592bd1d Added some passes to mobilise non-mobile arrays 2009-02-27 17:12:08 +00:00
Neil Brown
81959bd76b Added quick preliminary support for the PERMITALIASES pragma 2009-02-10 01:01:23 +00:00