heptagon/compiler/global/types.ml

48 lines
1.6 KiB
OCaml
Raw Normal View History

(**************************************************************************)
(* *)
(* Heptagon *)
(* *)
(* Author : Marc Pouzet *)
(* Organization : Demons, LRI, University of Paris-Sud, Orsay *)
(* *)
(**************************************************************************)
open Names
2010-07-08 17:41:00 +02:00
open Misc
2010-07-05 16:55:14 +02:00
open Location
2010-07-05 16:55:14 +02:00
type static_exp = { se_desc: static_exp_desc; se_ty: ty; se_loc: location }
and static_exp_desc =
| Svar of constant_name
| Sint of int
| Sfloat of float
| Sbool of bool
| Sconstructor of constructor_name
| Sfield of field_name
| Stuple of static_exp list
| Sarray_power of static_exp * static_exp (** power : 0^n : [0,0,0,0,0,..] *)
| Sarray of static_exp list (** [ e1, e2, e3 ] *)
| Srecord of (field_name * static_exp) list (** { f1 = e1; f2 = e2; ... } *)
| Sop of fun_name * static_exp list (** defined ops for now in pervasives *)
2010-11-23 17:10:11 +01:00
and ty =
| Tprod of ty list
| Tid of type_name
| Tarray of ty * static_exp
| Tunit
2010-07-07 12:15:02 +02:00
2010-06-16 17:03:45 +02:00
let invalid_type = Tprod []
let prod = function
| [] -> assert false
| [ty] -> ty
| ty_list -> Tprod ty_list
2010-08-24 17:24:22 +02:00
(** DO NOT use this after the typing, since it could give invalid_type *)
let mk_static_exp ?(loc = no_location) ?(ty = invalid_type) desc =
2010-07-05 16:55:14 +02:00
{ se_desc = desc; se_ty = ty; se_loc = loc }
2010-07-08 17:41:00 +02:00