Commit Graph

2343 Commits

Author SHA1 Message Date
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
Neil Brown
172e331a9c Made sure that constants pulled up into sizes arrays are resolved into integers, rather than still referring to named constants 2009-04-04 15:23:40 +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
df21bf23ae Added a command-line option to print the include path
I'm not totally clear yet if the include path is or should be different to the module path, but I think it will become clear as I get KRoC compiling.
2009-04-04 13:45:22 +00:00
Neil Brown
923b9700d8 Stopped fixed-sizes being added for TOCKEXTERNAL PROCs 2009-04-04 13:44:56 +00:00
Neil Brown
11cc8c92a7 Corrected a small warning in PrettyShow 2009-04-04 12:49:01 +00:00
Neil Brown
03bfe593cb Fixed a bug in determining the sizes for RETYPES 2009-04-04 12:31:25 +00:00
Neil Brown
c361a36e41 Added a message so that when we fail to find a file, we say exactly where we looked 2009-04-04 12:31:06 +00:00
Neil Brown
d595b73f28 Added a command-line option to print out the module directory 2009-04-04 12:30:09 +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
0466a50dfa Changed the build process to support a directory to put modules and includes in, and added a dummy lib (occamutl) 2009-04-04 12:28:47 +00:00
Neil Brown
18f37a0d96 Made it easier to print out a plain String after processing the command-line options 2009-04-04 12:27:56 +00:00
Neil Brown
c9f9eb8587 Added a couple of filter calls to the usage checking to speed it up
It now removes empty sets of (relevant) background knowledge to avoid needlessly creating lots of problems (thousands!) when it only needs one, and also stopped it checking array usage when there's at most one written-to/read-from index.

Fixes #90
2009-04-04 08:52:41 +00:00
Neil Brown
f755458545 Turned *EXTERNAL pragmas into specifications in the occam parser
There was a bug where things scoped in via pragmas were never scoped out again, which was screwing up the local names stack.  I then realised/decided that pragmas were really specifications, and decided to put them there in the parser.

The rest of this patch is just some rewiring to allow the special name munging involved in pragmas (they have already got a munged version of their name) and to stop the scoped in pragmas appearing in the AST.
2009-04-03 21:06:24 +00:00
Neil Brown
4a36d578c0 Added a check that the names being scoped out match the names that were scoped in, which helps find bugs in the parser 2009-04-03 21:03:19 +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
8170d9569d Added some code to Tock to be able to handle unlexable ASM blocks in source files 2009-04-03 17:54:13 +00:00
Neil Brown
9fbbe87fd4 Fixed the reading of floating point literals to work for negative numbers 2009-04-03 17:53:10 +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
38ffed2bda Stopped the .o file being removed after compilation when the -c flag was given 2009-04-03 16:52:16 +00:00
Neil Brown
081e4f79d4 Added more recognised suffixes to knock off in #USE directives 2009-04-03 16:52:00 +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
8220630426 Attempted to fix a problem with parsing pragmas, but I suspect it's still a bit haphazard 2009-04-03 16:50:41 +00:00
Neil Brown
0d63eeb400 Fixed a small parser bug involving variant 2009-04-03 15:34:33 +00:00
Neil Brown
b9cbcf0902 Added the intrinsic CAUSEERROR 2009-04-03 15:14:24 +00:00
Neil Brown
471c3a1ef5 Allowed #INCLUDE and #USE directives to have comments after the quoted part
I couldn't decide whether to fix this in the parser or the preprocessing code.  I went for the latter, as it was the simplest option.
2009-04-03 14:37:10 +00:00
Neil Brown
b803b1ec91 Reworked how stack sizes are calculated, and changed how we use them in the build process
Now that we support separate compilation, some of the stack sizes for PROCs depend on the stack sizes of other PROCs that were compiled in different files.  We can't just assume the default 512 bytes for these "foreign" PROCs, because that often won't be enough.  So instead, we must make the stack sizes for the current PROCs depend on (i.e. use in the calculation) the stack sizes of the foreign PROCs.

This dependence adds some issues though.  We cannot declare in one C file a const int that depends on the value of an extern const int from another C file (not valid C, it seems).  So instead, we move all the stack size declarations to header files, and use #includes and the preprocessor to make sure that the stack sizes are statically determined.

This in turn simplifies the build process in some ways.  These headers only need to be compiled by the .occ file that has the main process, by including them all into a C file and compiling that as before.  It means that each .occ file only has one .o file resulting (plus two C headers*, and a .inc file) so linking is a bit less confusing.

* I am keeping the two C headers for now, rather than appending the sizes one to the normal header, because I'm not entirely sure whether having one header that the C file depends on may trigger a recompilation that we don't want in some build systems.  I can always merge them later if that's not a valid worry.
2009-04-03 12:24:53 +00:00
Neil Brown
9bf32e339d Made sure that the names printed in TOCKEXTERNAL pragmas are fully munged (and thus equivalent to the exact C function name) 2009-04-03 12:22:19 +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
ca332a0925 Changed the asm-analysis to only generate stack-sizes for PROCs, and not non-PROCs or external PROCs
This just about works, but it allocates the usual 512 bytes for all external PROCs being called, rather than using the actual stack_size for those external PROCs (this causes popcorn to overflow the stack if left with the default 512 bytes)
2009-04-02 20:04:21 +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
b76676eca8 Fixed a few more missing-static problems 2009-04-02 19:33:09 +00:00
Neil Brown
098c4e5ef4 Added -c as an alternative for --no-main 2009-04-02 18:15:02 +00:00
Neil Brown
0e31e98bb2 Made Tock draw in the post-analysis object files when linking 2009-04-02 18:14:40 +00:00
Neil Brown
70789661f1 Got pragma-declared FUNCTIONS to be turned into PROCs and handled properly 2009-04-02 18:13:51 +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
f5e0288ad0 Added an error message for a backend pass that should never be needed -- but just was 2009-04-02 17:18:34 +00:00
Neil Brown
a843d07463 Changed the pragmas to support FUNCTIONs, and to order the names the other way (as Adam wanted) 2009-04-02 16:57:11 +00:00
Neil Brown
4ea3357129 Rolling back earlier patch, the header should come after the declarations, now that records are not in the headers 2009-04-02 16:51:11 +00:00
Neil Brown
5024e0d615 Fixed the generation of formals that are arrays of channel-ends 2009-04-02 15:58:35 +00:00
Neil Brown
aa2b31718a Moved the header inclusion to be before forward declarations, as often the latter use the former 2009-04-02 15:51:34 +00:00
Neil Brown
350057c314 Made sure that non-top-level specs still have forward declarations in the .c file (and not in the .h file) 2009-04-02 15:43:49 +00:00
Neil Brown
dbd315abd6 Allowed underscores in occam identifiers
I must admit, this was mainly done to allow munged names back in again as valid identifiers.

OEP 144 suggests replacing dot with underscore; this change just allows underscore alongside dot.  It won't break any existing code, and seems like something we want anyway, so I think it's a valid thing to do.
2009-04-02 15:42:26 +00:00