| 1 |
(* Typed abstract syntax *) |
(* 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 |
open Location |
| 13 |
|
|
| 14 |
type tpat = Patterns.node |
type tpat = Patterns.node |
| 15 |
type ttyp = Types.node |
type ttyp = Types.node |
| 16 |
|
|
| 17 |
type texpr = { loc : Location.loc; mutable typ : Types.descr; descr : texpr' } |
type texpr = { loc : Location.loc; |
| 18 |
|
mutable exp_typ : Types.descr; |
| 19 |
|
exp_descr : texpr'; |
| 20 |
|
fv : string list |
| 21 |
|
} |
| 22 |
and texpr' = |
and texpr' = |
|
|
|
| 23 |
(* CDuce is a Lambda-calculus ... *) |
(* CDuce is a Lambda-calculus ... *) |
| 24 |
| Var of string |
| Var of string |
| 25 |
| Apply of texpr * texpr |
| Apply of texpr * texpr |
| 37 |
|
|
| 38 |
and abstr = { |
and abstr = { |
| 39 |
fun_name : string option; |
fun_name : string option; |
| 40 |
fun_iface : (tpat * tpat) list; |
fun_iface : (ttyp * ttyp) list; |
| 41 |
fun_body : branches |
fun_body : branches |
| 42 |
} |
} |
| 43 |
|
|
| 44 |
and branches = branch list |
and branches = branch list |
| 45 |
and branch = { used : bool; mutable typ : Types.descr; body : texpr } |
and branch = |
| 46 |
|
{ mutable used : bool; |
| 47 |
|
mutable br_typ : Types.descr; |
| 48 |
|
br_pat : tpat; |
| 49 |
|
br_body : texpr } |
| 50 |
|
|
| 51 |
and op = string |
and op = string |
| 52 |
|
|