Commit Graph

142 Commits

Author SHA1 Message Date
Adam Sampson
9e9459cb4a Clean up EvalLiterals.
In particular, evalSimpleLiteral is now much nicer, and the error
messages should be a bit more comprehensible.

The signed types previously used a different version of fromRead that
passed an extra argument that it then didn't use; I've switched back to
the old version now, since it appears not to need it any more.
2008-04-08 00:29:23 +00:00
Adam Sampson
28f329dd07 Don't assume an empty array literal can be a string literal. 2008-04-06 15:33:18 +00:00
Adam Sampson
17da4db956 Make genActual(s) use the correct abbreviation mode. 2008-04-01 13:16:23 +00:00
Adam Sampson
3283b7db41 Remove the Type/AbbrevMode information from Actual*.
It's redundant, since you can always compute them from the variable, and it
makes the code that deals with actuals rather cleaner.

On the other hand, it slightly complicates some of the tests, because any names
you use in an Actual need to be defined...
2008-03-26 18:16:09 +00:00
Neil Brown
2d0d6463d5 Removed the handling of the old Rain Wait/GetTime items from the backends 2008-03-24 15:08:05 +00:00
Neil Brown
c68aa42277 Added a sub-type to Timers, to support multiple types 2008-03-23 22:20:16 +00:00
Neil Brown
fc4cac736b Added the helper functions for adding and subtracting Times in C++CSP 2008-03-23 13:29:22 +00:00
Neil Brown
cc6dce5ead Tidied up the export/import lists for GenerateC and GenerateCPPCSP 2008-03-23 12:40:06 +00:00
Neil Brown
bc7e682119 Added a Concat operator for lists, and added support for it (and list assignment) to the backends 2008-03-21 19:20:15 +00:00
Neil Brown
b496912c51 Fixed conflicts with Adam's dimension changes 2008-03-19 17:49:32 +00:00
Neil Brown
839d92546b Altered the backends to support lists and foreach loops over lists (at least in the C++ part) 2008-03-19 17:20:52 +00:00
Adam Sampson
b1416bb0cf Change A.Dimension to take an Expression, not an Int.
This touches an awful lot of code, but cgtest07/17 (arrays and retyping) pass.

This is useful because there are going to be places in the future where we'll
want to represent dimensions that are known at runtime but not at compile time
-- for example, mobile allocations, or dynamically-sized arrays. It simplifies
the code in a number of places.

However, we do now need to be careful that expressions containing variables do
not leak into the State, since they won't be affected by later passes.

Two caveats (marked as FIXMEs in the source):

- Retypes checking in the occam parser is disabled, since the plan is to move
  it out to a pass anyway.
- There's some (now very obvious) duplication, particularly in the backend, of
  bits of code that construct expressions for the total size of an array
  (either in bytes or elements); this should be moved to a couple of helper
  functions that everything can use.
2008-03-18 16:45:38 +00:00
Adam Sampson
1124bb5a44 Use either Alt or TimerAlt as appropriate. 2008-03-15 15:15:21 +00:00
Adam Sampson
54668d3ba2 Implement the RESCHEDULE intrinsic. 2008-03-15 11:00:11 +00:00
Adam Sampson
4a68dda2b5 Clean up the generation of wrapper Procs for Pars.
Procs that are in csParProcs are now generated with the correct calling
convention directly, rather than having a second wrapper function generated
around them.
2008-03-14 22:01:59 +00:00
Adam Sampson
5156626ab0 Remove the identifyParProcs pass.
All it did was to make a list of the Procs generated by parsToProcs, so
parsToProcs may as well just do the same job itself.

The reason I'd made it a separate pass originally was that I wanted to
optimise out the wrapper when the child of a Par was already a ProcCall.
That optimisation isn't going to be possible any more with the new CCSP,
since wrappers have to fetch their arguments in a different way from
ordinary Procs.
2008-03-14 14:53:05 +00:00
Adam Sampson
88af6a29d2 Abstract CCSP setup into a function, and set up terminal properly.
If stdin is in use, it'll now be put into non-canonical mode. This is almost
the same as libkrocif's behaviour, except I've set VTIME to 0, since I don't
think there's a good reason to have a terminal read complete if no characters
are available.

This also sets CCSP's branding to "Tock", so error messages now start "Tock: ".
2008-03-12 14:38:58 +00:00
Adam Sampson
f2d3280cee Abstract killing TLP channel handlers out into a function. 2008-03-12 10:47:19 +00:00
Adam Sampson
8880413128 Use TimerAlt rather than Alt.
It really ought to pick the right one depending on whether there are any timer
guards.
2008-03-11 18:52:35 +00:00
Adam Sampson
7eaab68f04 Implement TLP output channels using a CIF helper process.
Input channels will be similar, but are stubbed out for now.
2008-03-11 18:47:48 +00:00
Adam Sampson
882d0c002a Remove debugging code. 2008-03-11 17:43:54 +00:00
Adam Sampson
8aae275895 Fix ALT enabling in the C backend. 2008-03-10 11:38:25 +00:00
Neil Brown
9533fa9926 Reversed the effect of an earlier patch (to put timers back in the C++ backend) now that I've seen Adam's patch that fixes it anyway 2008-03-09 19:04:34 +00:00
Neil Brown
76aeabe747 Fixed genRetypesSizes to work properly again with arrays with a non-fixed dimension (oops) 2008-03-09 18:54:37 +00:00
Neil Brown
3189c066b5 Fixed genRetypeSizes and its associated tests in light of the new array sizes passes 2008-03-09 16:58:05 +00:00
Neil Brown
0265063250 Re-added the index checking for array slices in the backend 2008-03-09 16:19:01 +00:00
Neil Brown
3d1945b517 Changed the code handling SizeVariable to output the size as an integer if it is known 2008-03-09 16:18:13 +00:00
Neil Brown
5c43172e46 Added an annotation to array subscripts to indicate whether they should have a run-time check added or not 2008-03-09 14:30:19 +00:00
Neil Brown
c733ac2cff Fixed the C++ backends so that it continues to declare timer variables, even though the C backend doesn't any more 2008-03-09 12:48:26 +00:00
Neil Brown
ba75f5b06c Removed the initialiser expression on the Declaration item in the AST 2008-03-09 00:23:13 +00:00
Adam Sampson
f8d4efa0e9 Go back to generating Time variables for timers.
This is for two reasons: first, the C++CSP backend still needs them, and
second, the way I'd done the removal wasn't correct; since you can have arrays
of them, abbreviate them, etc., they need to be stripped out by an earlier
pass so that other passes don't try to operate upon them.
2008-03-09 11:57:43 +00:00
Adam Sampson
35538cda36 Resolve conflicts.
This simplifies the formals/actuals stuff enough that most of it can probably
go away (once it's made to work again).
2008-03-08 17:18:22 +00:00
Neil Brown
ba9ac70d7c Changed the C and C++ backends to write directly to the output file, to save building up the strings in memory 2008-03-08 14:10:05 +00:00
Neil Brown
c87581e490 Tidied up the export list for the GenerateC module 2008-03-08 14:03:10 +00:00
Neil Brown
e1fd001322 Fixed a bug relating to not initialising C channel arrays properly (an over-enthusiastic trimming earlier) 2008-03-08 13:42:36 +00:00
Neil Brown
126dcdb4bb Removed all the unnecessary stuff from the C backend that used to be there for array sizes 2008-03-08 12:36:38 +00:00
Neil Brown
66a7ae9b58 Refactored the C backend, removed the abbrevVariable and genSlice functions 2008-03-08 11:55:56 +00:00
Neil Brown
3c070f035c Removed the code for initialising members - it is unneeded, and will no longer work until the ensuing _sizes declaration 2008-03-08 00:09:28 +00:00
Neil Brown
5ae8aca68e Fixed the sizes of retyping a multi-dimensional array 2008-03-07 22:46:39 +00:00
Neil Brown
fdef3b1924 Corrected genVariable to obey checkValid when working out the types for array slices 2008-03-07 15:51:27 +00:00
Neil Brown
4c1f2a1930 Adjusted the C++ (a lot) and C (a little) backends to reflect array _sizes changes, and added the new array passes to the overall pass list
Now that I have begun moving all the _sizes stuff forward into proper compiler passes, much of the code for handling arrays in the backends is going to become redundant:

- The tockArrayView class should eventually disappear; now that _sizes are pulled forward, there's no advantage of having this extra class (compared to just doing C and C++ arrays in the same, C-based, style)
- The declaration and use of the _sizes array everywhere should go, now that it is inserted in an earlier pass

I haven't removed as much as I should from the C backend; I am wary to touch it when Adam is about to move it over to the new CIF anyway
2008-03-06 19:08:38 +00:00
Neil Brown
a9692f884a Added a constructor to record types to help build record literals (especially those that contain array literals) 2008-02-29 16:44:00 +00:00
Adam Sampson
2f7539bcdb Convert the C backend to the new CIF API (mostly).
Most of this is mechanical: changing function names, and carrying the "wptr"
argument around. I've made the code for computing Expressions from Structureds
a bit more generic too.

The only complex bit is the handling of PAR processes, which I'm not very happy
with at the moment; they used to use the normal C calling convention, but now
you need to pack the arguments into the workspace. I'm handling this at the
moment by generating wrapper functions that do the unpacking, but it would be
better in the future to make the wrapper PROCs that we already generate have
the right interface.

This won't work for programs that use any of the top-level channels yet, since
there are no handlers for them.
2008-03-07 17:50:10 +00:00
Adam Sampson
8aabb0c98e Add a missing fold marker. 2008-03-07 17:02:03 +00:00
Neil Brown
20f7666044 Refactored cgenArraySubscript ready to add support for static dimensions 2008-03-01 20:39:45 +00:00
Neil Brown
60daa07b93 Renamed one of the array functions in the function table to be clearer 2008-03-01 20:22:34 +00:00
Neil Brown
01ac2ef21d Fixed an odd monomorphism restriction warning 2008-03-01 20:13:11 +00:00
Adam Sampson
50967cba95 Split the common C99/C++ support code out into a separate header.
Or, rather, add a new CIF-specific header, so tock_support.h is now the common
code and each of the backends has its own. This means some of the conditional
stuff can go away.
2008-03-05 16:54:29 +00:00
Adam Sampson
aff90d8d45 Some initial shuffling to get Tock working with the new CIF.
This changes the TLP code to use CCSP's stand-alone mode, and gets rid of the
old KRoC wrapper stuff. It also changes occam_stop everywhere in order to pass
the number of arguments (since ExternalCallN needs that now), and cleans up the
interaction with the C++ backend a bit.
2008-03-05 16:21:20 +00:00
Neil Brown
49585a1922 Added a constructor to record types to help build record literals (especially those that contain array literals) 2008-02-29 16:44:00 +00:00