Commit Graph

1925 Commits

Author SHA1 Message Date
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
ed9c92878a Added a helper function to RainTypesTest to make the unification tests shorter 2008-05-14 10:09:42 +00:00
Neil Brown
9f1d65f4a0 Added more tests for type unification, fixed some bugs and added cleaner error handling 2008-05-14 09:52:16 +00:00
Neil Brown
e3fa3df623 Added a module for doing type unification, and some very basic tests for it 2008-05-13 23:25:42 +00:00
Neil Brown
3ca4ee1a5e Added a new helper function to Utils for transforming Map values monadically 2008-05-13 23:24:43 +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
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
04da66531f Fix nesting.occ so it has a valid TLP signature. 2008-05-15 12:23:44 +00:00
Adam Sampson
0106e6bbb7 Fix the page size in the Tock logo.
This makes it render properly in things other than Inkscape; previously the
logo was drawn outside the page area.
2008-05-14 23:22:50 +00:00
Adam Sampson
7a7e3e2b24 Make GenNavAST generate instances of a "Polyplate" class.
This provides transformM, which we can build applyX (etc.) on top of:
it takes a set of functions, and applies them wherever they could
match in a data structure, without automatically recursing. This is
done using a four(!)-argument typeclass, drawing inspiration from
Biplate.

The resulting 25,000-line set of instances takes a little while to
compile...
2008-05-10 16:27:46 +00:00
Adam Sampson
058a3488d9 Generate instances of a Navigable class.
This isn't immediately useful, but I plan to build on it.
2008-05-09 15:46:18 +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
9f172865ff Move DataBox into Utils.
AnyDataItem is effectively the same, so we could reuse DataBox for that
too in the future.
2008-05-09 09:50:42 +00:00
Adam Sampson
9c77aed7b3 Move Gen* into their own directory. 2008-05-09 09:36:45 +00:00
Adam Sampson
8babfb2911 Remove profiling options added by mistake. 2008-05-09 09:36:29 +00:00
Adam Sampson
06296276a4 Use unlines in GenOrdAST too. 2008-05-08 20:45:48 +00:00
Adam Sampson
8b991806e7 Clean up GenTagAST so that it just has one list of types.
This meant having it figure out which types are parameterised and
what their prefixes should be automatically. (More work for Typeable.)
2008-05-08 16:07:46 +00:00
Adam Sampson
0e2a944788 Make GenOrdAST and GenTagAST use Typeable.
This simplifies the code quite a bit, since Typeable knows about
parameters to types; you don't have to do magic to handle
Structured Thingy any more.
2008-05-08 15:37:56 +00:00
Adam Sampson
2d00b1e5c5 Optimise applyX a bit.
This avoids computing the transformation function each time we recurse.
2008-05-07 15:51:09 +00:00
Adam Sampson
0886ab9f9b Abstract the set of types that gmapMFor takes out to a type.
(No change in behaviour, yet.)
2008-04-08 23:13:58 +00:00
Adam Sampson
441b2ee344 Do away with the pkgconfig file in favour of another generated module.
Paths.hs is now generated by the Makefile.am, so it can include paths.

As a bonus, this actually works, since we weren't previously installing the .pc
file anywhere...
2008-05-07 13:06:27 +00:00
Adam Sampson
7567e5e499 Move the autoconf-generated Haskell files into a "config" directory. 2008-05-07 12:57:35 +00:00
Adam Sampson
39c7522096 Remove an obsolete FIXME. 2008-05-07 12:49:20 +00:00
Adam Sampson
d289900cb5 Use pkgconfig to find CCSP.
This means we now only depend on CCSP, rather than all of KRoC.
2008-05-07 10:48:48 +00:00
Adam Sampson
f3ca84c2b9 Add AC_PREREQ.
We need a fairly recent autoconf; this'll make it obvious if a user's got an
older one.
2008-04-26 19:58:52 +00:00
Adam Sampson
298c71ad8f Add a logo for Tock. 2008-04-18 10:17:32 +00:00
Adam Sampson
474e805c75 Add a "run" target to build and run the cgtests.
This uses the run-tests script.
2008-04-08 15:17:40 +00:00
Adam Sampson
8625859773 Flush output when the C backend exits.
This makes "someprog | cat" work -- previously the output never got written.
The C++ support code already does this.
2008-04-08 15:12:24 +00:00
Adam Sampson
f445ccbdc9 Fix C style.
The Tock support headers (at least the C side) follow the KRoC C standards,
which are essentially K&R with spaces before function arg lists.
2008-04-08 15:08:25 +00:00
Adam Sampson
ce622da2cb Use rm -f. 2008-04-08 14:54:00 +00:00
Adam Sampson
3da2ad1385 Provide combinators for generic traversals.
The types get hairier, but the code is much simpler!

I've left {check,apply}DepthM{,2} there for now, but reimplemented them in
terms of the new combinators.

Fixes #58.
2008-04-08 14:41:25 +00:00
Adam Sampson
e460032c30 Remove debugging putStr from the QC-HUnit adaptor.
This was what was causing random numbers to appear during testing.

I've also cleaned up the code a bit.
2008-04-08 14:39:43 +00:00
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
f1e9ffe230 In the evaluator, handle byte literals of any type. 2008-04-08 00:10:45 +00:00
Adam Sampson
eb8a855f32 Change most uses of underlyingType to resolveUserType in OccamTypes.
underlyingType recurses, and in at least one case it was going too far.
2008-04-07 23:52:44 +00:00
Adam Sampson
a5bd28bab4 Use a sensible NameType for names converted to unscoped.
This is because the code that finds free names looks at the NameType -- which
it certainly shouldn't.
2008-04-07 23:36:53 +00:00
Adam Sampson
feb0496d71 Handle DATA TYPE FOO IS (some record). 2008-04-07 23:36:30 +00:00
Adam Sampson
201788b478 Fix explicitly-typed array literals -- don't throw away the type. 2008-04-07 22:43:51 +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
c627214727 Resolve the v[s] ambiguity outside the parser.
This removes the last use of typeOf* from the parser.
2008-04-07 21:36:21 +00:00
Adam Sampson
7703eab52f Add applyExplicitM10.
Fortunately all of this will go away once I do the combinator change...
2008-04-07 21:34:34 +00:00
Adam Sampson
cc907a1339 Pick the best type available for operators and array literals.
This is rather more expensive than the approach it was using, but it
does the right thing for things like "3 + 4(MYINT)" and "[3, 4(MYINT)]",
and the code's actually simpler.
2008-04-07 20:14:00 +00:00
Adam Sampson
3326c56a54 Always infer left-to-right for dyadic operators (except shifts).
This isn't the right behaviour, although it's closer: what it really needs to
do is to try to infer both sides in the current (or no) context, pick the more
specific type of the two inferred, then use that to redo the other one. Yuck!
2008-04-07 12:04:34 +00:00
Adam Sampson
caa59c6788 Reinstate support for intrinsic Procs and Functions.
This works the same way that it used to. I did experiment with actually
defining them as Procs and Functions in the normal way, but that'd require an
awful lot of special-casing later on, and would preclude support for multiple
types in the future, so I'll keep it this way for now.
2008-04-07 11:55:20 +00:00
Adam Sampson
ea69ebd0ec Assume that string literals have type []BYTE unless otherwise specified.
This means that "" has the correct type, which cgtest07 checks for.
2008-04-07 00:20:42 +00:00
Adam Sampson
d0072fc2ee Infer types in record literals.
This also changes the behaviour for array literals so that the inferred type of
the first item is used as the default for the rest. This satisfies all the
cgtests except for a test in cgtest59 which does "a IS [3, 4 (type)]:", which
I've never seen in a real program, and would require a bit more complication to
handle.
2008-04-07 00:05:15 +00:00
Adam Sampson
6d31c79234 Only apply inferTypes to the AST.
It updates the state itself anyway, and applying it to the AST results in it
doing an awful lot of traversal this early on.
2008-04-06 22:28:58 +00:00
Adam Sampson
3d1d2c4d9c Fix type inference for BytesInExpr. 2008-04-06 19:04:16 +00:00
Adam Sampson
988c5c6fef Add special handling for CHAN ANY.
Fixes #57.
2008-04-06 18:54:32 +00:00
Adam Sampson
71d8c7024b Unsubscript the context (when walking a subscripted expression. 2008-04-06 18:43:34 +00:00