Commit Graph

30 Commits

Author SHA1 Message Date
Neil Brown
ab0301a342 Made the Rain parser actually record an unknown (to-be-inferred) type for numeric literals 2008-05-17 14:24:45 +00:00
Neil Brown
f10cb7d525 Moved the TypeExp type out to its own module, UnifyType 2008-05-17 14:21:57 +00:00
Neil Brown
f8b7e8f8cb Added unifying-related items to CompState, and changed all the uses of ST to IO in the TypeUnification module
As part of this patch I also had to provide a Data instance for TypeExp (to allow CompState to still be an instance of Data).  Using IORefs is easier than STRef RealWorld, and puts everything in terms of IO (which is already in PassM) rather than ST (which would require more lifting).
2008-05-17 12:50:52 +00:00
Neil Brown
e6162877af Changed the AST to fix the different unknown/inferred types
The Infer type (used by the occam frontend) is now separated from the "Unknown" types used in type unification that I'm experimenting with in Rain.
2008-05-17 12:47:31 +00:00
Neil Brown
962c1477b9 Added a special type for marking the type of numeric literals to be inferred later 2008-05-14 11:59:33 +00:00
Neil Brown
3daf82d318 Merged Alternative and AlternativeCond into a single Alternative item that always has a pre-condition 2008-04-03 14:52:37 +00:00
Adam Sampson
710be039cb Have the pregen programs figure out the types using generics.
Previously they had a list of the types they needed to generate
instances for.  This patch adds some helper code that can be used to
list all the AST.* types in the AST automatically. The result is that we
should be able to add new types to the AST without needing to change the
generator code.

This also means that GenOrdAST is now generating *all* the instances of
Ord for the AST; previously the trivial ones were derived by the
compiler.
2008-05-09 14:02:13 +00:00
Adam Sampson
c4f147f5db Rewrite findMeta in terms of listify.
It'll now recurse into the data item you give it, which means it works
on types like Actual where the Meta isn't an immediate child.
2008-04-07 22:31:18 +00:00
Adam Sampson
8cedbed5fc Move makeUniqueName and findUnscopedName into CompState. 2008-04-06 17:42:12 +00:00
Adam Sampson
249fd23e75 The type context is now used by passes, not the parser. 2008-04-06 02:59:34 +00:00
Adam Sampson
475a77404c Handle the RHS type of A.Counted consistently.
Previously the parser set it to the element type, but everything that used it
set it to the type of the whole array. Now it's documented in AST.hs, and the
parser makes it the type of the whole array, since that's almost always what
you really want later on.
2008-04-06 00:09:23 +00:00
Adam Sampson
e52b51b050 Add an Infer type to mark types that should be inferred.
We can then check it's been removed using a property later.
2008-04-04 12:09:33 +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
ceafd77c1e Removed Wait, GetTime and AlternativeWait (the old Rain time items) from the AST 2008-03-24 15:15:54 +00:00
Neil Brown
cbbafffbd2 Changed Rain to use the new timer type rather than things like the GetTime statement 2008-03-24 13:50:14 +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
7f28d3dbe3 Added a warnPC function (like diePC) for use with formatCode 2008-03-22 18:34:40 +00:00
Adam Sampson
7c4275116e Various cleanups to AST.hs.
No code changes; just reformatting.
2008-03-20 22:18:32 +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
9d0459cb75 Added a ListLiteral item to the AST 2008-03-19 15:58:34 +00:00
Neil Brown
ff9c0549ca Added types to the array constructor items in the AST 2008-03-19 13:21:12 +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
3005dfb506 Add a pass for folding constants in occam.
The existing constant-folding code in the parser is still there, since it needs
to know whether things are constant, and A.Dimension expects an Int.

However, this pass is useful because it does a better job of constant folding
than the parser would on its own: it can fold subexpressions of expressions
that are as a whole not constant.
2008-03-17 15:48:43 +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
ba75f5b06c Removed the initialiser expression on the Declaration item in the AST 2008-03-09 00:23:13 +00:00
Adam Sampson
337527a544 Remove obsolete comment -- Structured is parametric now. 2008-03-07 14:42:46 +00:00
Adam Sampson
d2c0fd674e Rework the code for getting errors through the parser.
This used to work by adding a magic prefix to the error message, but it appears
that doesn't work with the GHC 6.6 version of Parsec. It now searches for a
magic substring anywhere in the error message.

It uses // as a delimeter rather than \0 now, since including nulls in Strings
causes problems -- for example, putStr "a\0b" will only print "a".
2008-03-04 12:52:25 +00:00
Adam Sampson
8f2575819b Initial implementation of the occam-pi preprocessor.
This implements #DEFINE, #UNDEF, #IF, #ELSE and #ENDIF, macro expansion with
##, and TRUE, FALSE, AND, OR, NOT and DEFINED within #IF expressions, with the
same semantics as occ21.

The macro COMPILER.TOCK is always defined by default, so you can now say things
like "#IF NOT DEFINED (COMPILER.TOCK) ... #ENDIF".
2008-02-28 20:27:30 +00:00
Neil Brown
eef0ac53e0 Added a flag to the compiler to tell let it to not delete the temporary files it used 2008-02-27 18:23:22 +00:00
Neil Brown
decf249c51 Moved AST, CompState and Metadata out to a new data directory (along with the generated OrdAST and TagAST) 2008-02-26 15:02:13 +00:00