Commit Graph

29 Commits

Author SHA1 Message Date
Neil Brown
92c92a3f65 Fixed various small mobile typing issues 2009-04-09 17:05:16 +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
9fbbe87fd4 Fixed the reading of floating point literals to work for negative numbers 2009-04-03 17:53:10 +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
c1c73f9186 Added constant-folding support for VariableSizes 2009-03-30 15:32:38 +00:00
Neil Brown
676bbe34d4 Added a few missing lines in the constant folding 2009-03-27 21:40:14 +00:00
Neil Brown
d35825ec50 Added support for constant-folding reals, and for constant-folding RETYPES 2009-03-26 18:33:14 +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
8e5e73e3a2 Fixed the support in the backends for mobile channel stuff 2009-03-19 15:23:35 +00:00
Neil Brown
8de2dbca88 Adjusted the modules in common to match the new array constructor change 2009-02-01 21:52:13 +00:00
Neil Brown
2a8ee9a420 Fixed a bug in the constant folding, where anything divided by -1 was being evaluated to zero 2009-01-23 15:48:39 +00:00
Neil Brown
89c25e3f6c Added a type-class for retrieving the (AST) type of things
This patch hides all the old typeOfExpression, typeOfName, typeOfVariable, etc, and unifies them into a single type-class with an "astTypeOf" function.  The type-class is currently named Typed, but that can easily be changed (it's only explicitly referred to in the Types module).  The patch is essentially the type-class with a giant find-and-replace on the other modules.
2008-05-17 11:41:52 +00:00
Adam Sampson
3ab0c30589 When rendering array literals, recompute the dimensions.
This makes sure that literals produced by the constant evaluator will never
contain UnknownDimension. The change looks a lot more complex than it really
is; it already carried the type "downwards", and most of this is just making it
carry it back up to where the A.Literal is being constructured.
2008-04-06 15:40:50 +00:00
Adam Sampson
b65512b64c Make getConstantName descend into definitions.
This means you don't have to have folded constants throughout the tree/state in
order to evaluate them, which makes the early passes less awkward to manage.
2008-04-06 13:46:48 +00:00
Adam Sampson
1977e7880b Move evalIntExpression into EvalConstants, now that Types doesn't need it.
It now uses the full expression evaluator rather than the literal-only version.
2008-04-06 13:31:37 +00:00
Adam Sampson
9838cf7b8c Use forall to remove some repeated monad constraints. 2008-04-06 11:19:43 +00:00
Adam Sampson
e1fca531a0 Rework how OccValue is rendered to an Expression.
The rendering code now takes the type it's aiming for, so it can produce a
value of exactly the same type as the expression that was being folded
originally (rather than trying to work it out for itself).
2008-04-06 02:29:02 +00:00
Adam Sampson
e08aac59d3 Move Retypes checking from the occam parser into a pass.
This also fixes a bug in the original algorithm: it used to let you retype
[]INT to BYTE.
2008-03-19 19:38:56 +00:00
Adam Sampson
7f6cb6e0c3 Evaluate "(MOSTNEG INT) \ -1" correctly when evaluating constants.
This actually crashes older versions of GHC:
  Prelude Data.Int> (minBound :: Int32) `div` (-1)
  Floating point exception
2008-03-19 11:12:57 +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
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
93a3c81255 Fixed the right-shift in the constant folding to be an unsigned (logical, non sign-extending) shift 2008-02-27 12:45:29 +00:00
Neil Brown
c56cc6022a Switched everything in the EvalConstants module to use CSMR rather than CSM 2008-02-08 11:26:35 +00:00
Neil Brown
edc3a7e910 Removed the die function (that has no source position) and as far as possible replaced all its uses with dieP and a valid position 2008-01-28 17:21:13 +00:00
Neil Brown
38c409d378 Added the -fwarn-unused-imports compiler option to warn about unused imports, and then set about pruning and ordering (mostly in my code) the import lists for all the modules 2007-09-27 13:13:46 +00:00
Neil Brown
c97d1d00c8 Changed the error type from String to ErrorReport throughout the code
ErrorReport is of type (Maybe Meta, String), thereby adding an optional code position to error messages.

Die has been changed so that die and dieP are now implemented in terms of dieReport (:: ErrorReport -> m a).  This involved changing less code than changing die to be of type ErrorReport -> m a.  All that had to be changed directly was that Die instances now implement dieReport instead of die.

Any bits of code that "caught" errors has been changed so that it handles ErrorReport instead of String.  This ErrorReport is eventually, in Main, passed to dieIO, which will soon be changed to read the file in and provide the context.  Accordingly, MonadIO m has been added as a constraint to dieIO, and dieInternal has been changed to no longer use dieIO (because really we can't add the MonadIO constraint to dieInternal).

Various error messages have been changed.  Notably, all instances of fail in ParseOccam have been changed to use die or, wherever possible, dieP.  A similar thing has been done in EvalConstants and EvalLiterals.
2007-09-18 10:17:38 +00:00
Neil Brown
3e342a621c Added ShowOccam and ShowRain type-classes, and changed existing code to use these new show methods in error messages
The function showCode shows code as either occam or Rain depending on the frontend.  This is then used by a formatCode function that acts similar to 
printf, which makes it easy to format error messages that use showCode.
2007-09-16 17:20:57 +00:00
Neil Brown
2ff46a9041 Rearranged the Rain source files, renamed a couple of Rain files, and changed the Makefile accordingly. 2007-09-10 17:28:57 +00:00