Commit Graph

2387 Commits

Author SHA1 Message Date
Neil Brown
4a629c27ab Fixed rangetest to work again, given the changes to the names of the operators in the support headers 2009-04-08 19:10:08 +00:00
Neil Brown
69c05d7258 Fixed the types in the ..TOSTRING procs in the support headers 2009-04-08 19:09:51 +00:00
Neil Brown
41d52320de Corrected the C++ backend to obey csHasMain, and stop generating duplicate definitions for externally-originating classes 2009-04-08 16:45:51 +00:00
Neil Brown
ae61b22355 Corrected the C++ compilation commands, and gave the header a different extension 2009-04-08 16:45:08 +00:00
Neil Brown
cc4720832b Corrected a mistake in the last patch 2009-04-08 16:34:04 +00:00
Neil Brown
6814ac2679 Added a joinWith helper (short for concat . intersperse) and changed most of the uses in the code to use the helper function 2009-04-08 16:28:23 +00:00
Neil Brown
5a7f68a44f Removed some of the old C generation functions, and added a new one (genFunctionCall) to get the C++ backend compiling again 2009-04-08 16:07:01 +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
d2fb80c516 Added a foldM1 function to the Utils module 2009-04-08 15:33:36 +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
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
adf046a30e Fixed the implicit mobility module (it was only broken for Rain anyway) 2009-04-08 12:15:11 +00:00
Neil Brown
1ea35c6715 Fixed the name munging for declared user-defined operators 2009-04-08 12:14:05 +00:00
Neil Brown
1e21895276 Stopped abbreviations of arrays of records being pulled up 2009-04-08 12:13:23 +00:00
Neil Brown
dc64b5e664 Fixed the filename munging in the generated copy_ procs for records 2009-04-08 12:13:07 +00:00
Neil Brown
d782c91ed0 Added some missing occam operators to the various lists 2009-04-08 12:03:48 +00:00
Neil Brown
29a41fce72 Fixed the Check module to generates its BK based on the new operators-as-functions system -- it now compiles, but I haven't tested it thoroughly 2009-04-08 12:03:39 +00:00
Neil Brown
da4f4e1cd8 Changed an old use of the Not operator into the corresponding function call 2009-04-08 10:34:51 +00:00
Neil Brown
22cb9d35b6 Fixed the constant folding to understand the new operators-as-functions system, and only fold when the original built-in definition is being used 2009-04-08 10:28:26 +00:00
Neil Brown
6cb47fd1c3 Fixed one of properties that involved AFTER 2009-04-08 10:19:38 +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
3fd373e4ac Stopped calls to the user-defined operators being pulled up 2009-04-07 16:12:03 +00:00
Neil Brown
a3ec0aab7f Stopped the built-in operators from being transformed into PROCs 2009-04-07 16:11:18 +00:00
Neil Brown
ca3c982a7e Fixed transformConstr to work with the new helper functions 2009-04-07 16:10:42 +00:00
Neil Brown
8a35da4be4 Fixed the removeAfter pass to work on function calls to the AFTER operator 2009-04-07 16:09:12 +00:00
Neil Brown
58167432bb Added and fixed more of the occam operators in the support headers 2009-04-07 16:08:28 +00:00
Neil Brown
85790012b0 Allowed removeNesting to pull up functions (the only ones affected will be the built-in operators) 2009-04-07 16:07:46 +00:00
Neil Brown
8635039542 Stopped removeFreeNames from considering external things to be free names 2009-04-07 16:07:21 +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
0a67b804bb Added more intrinsically-defined operators to the list 2009-04-07 16:01:44 +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
7031ab7fb8 Changed the lexer to make it lex the new (user-defineable) operators 2009-04-07 15:51:34 +00:00
Neil Brown
e648a87fd1 Turned REM into \ in the parser, as that was the easiest place to do it 2009-04-07 15:43:56 +00:00
Neil Brown
095e3e1680 Fixed the parsing of associative operators 2009-04-07 15:43:41 +00:00
Neil Brown
7bd4e3d309 Added functions to the list of things that need stack sizes, even if they are external
I think this is not quite right, but for now it fixes stack sizes not being generated for any non-inlined standard operators.
2009-04-07 15:42:37 +00:00
Neil Brown
6e4e9c1808 Implemented much more of the support functions, and renamed some of the uglier types 2009-04-06 13:24:26 +00:00
Neil Brown
c4f625b1ba Overhauled the support headers to add most of the missing occam operators as inline functions 2009-04-06 00:56:06 +00:00
Neil Brown
9260048da2 Quickly fixed the Rain frontend to compile with the operator changes 2009-04-05 23:08:12 +00:00
Neil Brown
6d6d26d5d6 Fixed the backends to work with the new system (mainly removing unnecessary code) 2009-04-05 23:06:47 +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
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
cd0dd96939 Added some code to the Intrinsics module to list all (currently only some) of the occam standard operators with the types they can operate on 2009-04-05 22:48:23 +00:00
Neil Brown
238abc5070 Removed all the stuff from the ShowCode module that used to deal with operators 2009-04-05 22:38:00 +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
364bc6f31e Made double-star be resolved into a single star when parsing a string literal
I should probably do all the other escapes too, but for now I haven't.
2009-04-05 22:29:32 +00:00
Neil Brown
f8103c1d2d Added a library path to the set of Tock directories 2009-04-04 15:57:50 +00:00
Neil Brown
8400de520b Fixed the regular expression on #INCLUDE and #USE to allow any white-space at the end 2009-04-04 15:34:43 +00:00
Neil Brown
c2174743e7 Made the unknown preprocessor directive warning show what the unknown directive was 2009-04-04 15:34:17 +00:00