/[svn]/typing/typed.ml
ViewVC logotype

Contents of /typing/typed.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (show annotations)
Tue Jul 10 17:00:52 2007 UTC (5 years, 10 months ago) by abate
File size: 1793 byte(s)
[r2002-10-26 17:23:03 by cvscast] Empty log message

Original author: cvscast
Date: 2002-10-26 17:23:03+00:00
1 (* Typed abstract syntax *)
2
3 (* Some sub-expression may have to be type-checked several times.
4 We first build the ``skeleton'' of the typed ast
5 (basically the parsed ast with types and patterns replaced with there
6 internal representation), then type check it.
7
8 The exp_typ and br_typ fields are updated to capture all the possible
9 values than can result from the expression or flow to the branch
10 *)
11
12 open Location
13
14 type tpat = Patterns.node
15 type ttyp = Types.node
16
17 type texpr = { exp_loc : loc;
18 mutable exp_typ : Types.descr;
19 exp_descr : texpr';
20 }
21 and texpr' =
22 | DebugTyper of ttyp
23
24 (* CDuce is a Lambda-calculus ... *)
25 | Var of string
26 | Apply of texpr * texpr
27 | Abstraction of abstr
28
29 (* Data constructors *)
30 | Cst of Types.const
31 | Pair of texpr * texpr
32 | RecordLitt of (Types.label, texpr) SortedMap.t
33
34 (* Data destructors *)
35 | Op of string * texpr list
36 | Match of texpr * branches
37 | Map of texpr * branches
38 | Dot of (texpr * Types.label)
39
40 and abstr = {
41 fun_name : string option;
42 fun_iface : (Types.descr * Types.descr) list;
43 fun_body : branches;
44 fun_typ : Types.descr;
45 fun_fv : string list;
46 }
47
48 and branches = {
49 mutable br_typ : Types.descr;
50 br_accept : Types.descr;
51 br_branches: branch list;
52
53 mutable br_compiled : compiled_branches option;
54 }
55 and branch = {
56 mutable br_used : bool;
57 br_pat : tpat;
58 br_body : texpr
59 }
60 and compiled_branches =
61 Patterns.Compile.dispatcher * ((string * int) list * texpr) array
62
63
64 let dispatcher brs =
65 match brs.br_compiled with
66 | Some d -> d
67 | None ->
68 let aux b = Patterns.descr b.br_pat, b.br_body in
69 let x = Patterns.Compile.make_branches
70 brs.br_typ
71 (List.map aux brs.br_branches) in
72 brs.br_compiled <- Some x;
73 x
74

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5