program API (in progress)

parent 6d7f26b2
...@@ -447,7 +447,7 @@ install_local: bin/why3ml ...@@ -447,7 +447,7 @@ install_local: bin/why3ml
# Whyml (new API) # Whyml (new API)
######## ########
MLW_FILES = mlw_ty MLW_FILES = mlw_ty mlw_expr
MLWMODULES = $(addprefix src/whyml/, $(MLW_FILES)) MLWMODULES = $(addprefix src/whyml/, $(MLW_FILES))
......
(**************************************************************************)
(* *)
(* Copyright (C) 2010-2011 *)
(* François Bobot *)
(* Jean-Christophe Filliâtre *)
(* Claude Marché *)
(* Andrei Paskevich *)
(* *)
(* This software is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Library General Public *)
(* License version 2.1, with the special exception on linking *)
(* described in file LICENSE. *)
(* *)
(* This software is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)
(* *)
(**************************************************************************)
open Why3
open Ident
open Ty
open Mlw_ty
(* program symbols *)
type psymbol = {
p_ident: ident;
p_tvs: Stv.t;
p_reg: Sreg.t;
p_vty: vty;
(* pv_ghost: bool; *)
}
let create_psymbol id tvars regs vty =
(* TODO? check that tvars/regs are in vty *)
{ p_ident = id_register id;
p_tvs = tvars;
p_reg = regs;
p_vty = vty; }
(**************************************************************************)
(* *)
(* Copyright (C) 2010-2011 *)
(* François Bobot *)
(* Jean-Christophe Filliâtre *)
(* Claude Marché *)
(* Andrei Paskevich *)
(* *)
(* This software is free software; you can redistribute it and/or *)
(* modify it under the terms of the GNU Library General Public *)
(* License version 2.1, with the special exception on linking *)
(* described in file LICENSE. *)
(* *)
(* This software is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)
(* *)
(**************************************************************************)
open Why3
open Ident
open Ty
open Mlw_ty
(* program symbols *)
type psymbol = private {
p_ident: ident;
p_tvs: Stv.t;
p_reg: Sreg.t;
p_vty: vty;
(* pv_ghost: bool; *)
}
val create_psymbol: preid -> Stv.t -> Sreg.t -> vty -> psymbol
(* program expressions *)
(*
| Letrec of (psymbol * lambda) list * expr
| Let of pvsymbol * expr * expr
*)
This diff is collapsed.
...@@ -21,137 +21,136 @@ open Why3 ...@@ -21,137 +21,136 @@ open Why3
open Stdlib open Stdlib
open Ident open Ident
open Ty open Ty
open Term
(** value types (w/o effects) *) (** individual types (first-order types w/o effects) *)
type vtysymbol = private { type itysymbol = private {
vts_pure : tysymbol; its_pure : tysymbol;
vts_args : tvsymbol list; its_args : tvsymbol list;
vts_regs : region list; its_regs : region list;
vts_def : vty option; its_def : ity option;
} }
and vty = private { and ity = private {
vty_node : vty_node; ity_node : ity_node;
vty_tag : Hashweak.tag; ity_tag : Hashweak.tag;
} }
and vty_node = private and ity_node = private
| Vtyvar of tvsymbol | Ityvar of tvsymbol
| Vtypur of tysymbol * vty list | Itypur of tysymbol * ity list
| Vtyapp of vtysymbol * vty list * region list | Ityapp of itysymbol * ity list * region list
(* | Vtymod of tysymbol * vty *) (* | Itymod of tysymbol * ity *)
and region = private { and region = private {
reg_ty : vty; reg_ity : ity;
reg_tag : Hashweak.tag; reg_tag : Hashweak.tag;
} }
module Mvts : Map.S with type key = vtysymbol module Mits : Map.S with type key = itysymbol
module Svts : Mvts.Set module Sits : Mits.Set
module Hvts : Hashtbl.S with type key = vtysymbol module Hits : Hashtbl.S with type key = itysymbol
module Wvts : Hashweak.S with type key = vtysymbol module Wits : Hashweak.S with type key = itysymbol
module Mvty : Map.S with type key = vty module Mity : Map.S with type key = ity
module Svty : Mvty.Set module Sity : Mity.Set
module Hvty : Hashtbl.S with type key = vty module Hity : Hashtbl.S with type key = ity
module Wvty : Hashweak.S with type key = vty module Wity : Hashweak.S with type key = ity
module Mreg : Map.S with type key = region module Mreg : Map.S with type key = region
module Sreg : Mreg.Set module Sreg : Mreg.Set
module Hreg : Hashtbl.S with type key = region module Hreg : Hashtbl.S with type key = region
module Wreg : Hashweak.S with type key = region module Wreg : Hashweak.S with type key = region
val vts_equal : vtysymbol -> vtysymbol -> bool val its_equal : itysymbol -> itysymbol -> bool
val vty_equal : vty -> vty -> bool val ity_equal : ity -> ity -> bool
val vts_hash : vtysymbol -> int val its_hash : itysymbol -> int
val vty_hash : vty -> int val ity_hash : ity -> int
val reg_equal : region -> region -> bool val reg_equal : region -> region -> bool
val reg_hash : region -> int val reg_hash : region -> int
exception BadVtyArity of vtysymbol * int * int exception BadItyArity of itysymbol * int * int
exception BadRegArity of vtysymbol * int * int exception BadRegArity of itysymbol * int * int
exception DuplicateRegion of region exception DuplicateRegion of region
exception UnboundRegion of region exception UnboundRegion of region
exception InvalidRegion of region exception InvalidRegion of region
val create_region : vty -> region val create_region : ity -> region
val create_vtysymbol : val create_itysymbol :
preid -> tvsymbol list -> region list -> vty option -> vtysymbol preid -> tvsymbol list -> region list -> ity option -> itysymbol
val vty_var : tvsymbol -> vty val ity_var : tvsymbol -> ity
val vty_pur : tysymbol -> vty list -> vty val ity_pur : tysymbol -> ity list -> ity
val vty_app : vtysymbol -> vty list -> region list -> vty val ity_app : itysymbol -> ity list -> region list -> ity
(* erases all [Vtymod] *) (* erases all [Itymod] *)
(* val vty_unmod : vty -> vty *) (* val ity_unmod : ity -> ity *)
(* all aliases expanded, all regions removed *) (* all aliases expanded, all regions removed *)
val ty_of_vty : vty -> ty val ty_of_ity : ity -> ty
(* replaces every [Tyapp] with [Vtypur] *) (* replaces every [Tyapp] with [Itypur] *)
val vty_of_ty : ty -> vty val ity_of_ty : ty -> ity
(* generic traversal functions *) (* generic traversal functions *)
val vty_map : (vty -> vty) -> vty -> vty val ity_map : (ity -> ity) -> ity -> ity
val vty_fold : ('a -> vty -> 'a) -> 'a -> vty -> 'a val ity_fold : ('a -> ity -> 'a) -> 'a -> ity -> 'a
val vty_all : (vty -> bool) -> vty -> bool val ity_all : (ity -> bool) -> ity -> bool
val vty_any : (vty -> bool) -> vty -> bool val ity_any : (ity -> bool) -> ity -> bool
(* traversal functions on type variables and regions *) (* traversal functions on type variables and regions *)
val vty_v_map : val ity_v_map :
(tvsymbol -> vty) -> (region -> region) -> vty -> vty (tvsymbol -> ity) -> (region -> region) -> ity -> ity
val vty_v_fold : val ity_v_fold :
('a -> tvsymbol -> 'a) -> ('a -> region -> 'a) -> 'a -> vty -> 'a ('a -> tvsymbol -> 'a) -> ('a -> region -> 'a) -> 'a -> ity -> 'a
val vty_v_all : (tvsymbol -> bool) -> (region -> bool) -> vty -> bool val ity_v_all : (tvsymbol -> bool) -> (region -> bool) -> ity -> bool
val vty_v_any : (tvsymbol -> bool) -> (region -> bool) -> vty -> bool val ity_v_any : (tvsymbol -> bool) -> (region -> bool) -> ity -> bool
(** {3 symbol-wise map/fold} *) (** {3 symbol-wise map/fold} *)
(** visits every symbol of the type *) (** visits every symbol of the type *)
(* (*
val vty_s_map : (vtysymbol -> vtysymbol) -> vty -> vty val ity_s_map : (itysymbol -> itysymbol) -> ity -> ity
val vty_s_fold : ('a -> vtysymbol -> 'a) -> 'a -> vty -> 'a val ity_s_fold : ('a -> itysymbol -> 'a) -> 'a -> ity -> 'a
val vty_s_all : (vtysymbol -> bool) -> vty -> bool val ity_s_all : (itysymbol -> bool) -> ity -> bool
val vty_s_any : (vtysymbol -> bool) -> vty -> bool val ity_s_any : (itysymbol -> bool) -> ity -> bool
*) *)
val vty_freevars : Stv.t -> vty -> Stv.t val ity_freevars : Stv.t -> ity -> Stv.t
val vty_closed : vty -> bool val ity_closed : ity -> bool
val vty_pure: vty -> bool val ity_pure: ity -> bool
exception RegionMismatch of region * region exception RegionMismatch of region * region
exception TypeMismatch of vty * vty exception TypeMismatch of ity * ity
type vty_subst = private { type ity_subst = private {
vty_subst_tv: vty Mtv.t; ity_subst_tv: ity Mtv.t;
vty_subst_reg: region Mreg.t; ity_subst_reg: region Mreg.t;
} }
val vty_subst_empty: vty_subst val ity_subst_empty: ity_subst
val vty_match : vty_subst -> vty -> vty -> vty_subst val ity_match : ity_subst -> ity -> ity -> ity_subst
val vty_equal_check : vty -> vty -> unit val ity_equal_check : ity -> ity -> unit
(*****
(** computation types (with effects) *) (** computation types (with effects) *)
(* exception symbols *) (* exception symbols *)
type xsymbol = private { type xsymbol = private {
xs_id : ident; xs_name : ident;
xs_vty: vty; (* closed and pure *) xs_ity: ity; (* closed and pure *)
} }
val create_xsymbol: preid -> vty -> xsymbol val create_xsymbol: preid -> ity -> xsymbol
module Mexn: Map.S with type key = xsymbol module Mexn: Map.S with type key = xsymbol
module Sexn: Mexn.Set module Sexn: Mexn.Set
...@@ -170,39 +169,36 @@ val eff_union: effect -> effect -> effect ...@@ -170,39 +169,36 @@ val eff_union: effect -> effect -> effect
val eff_read: region -> effect val eff_read: region -> effect
val eff_write: region -> effect val eff_write: region -> effect
val eff_raise: xsymbol -> effect val eff_raise: xsymbol -> effect
val eff_remove_raise: xsymbol -> effect -> effect val eff_remove_raise: xsymbol -> effect -> effect
(* program symbols *) (* program variables *)
type psymbol = private { type pvsymbol = private {
p_vs: vsymbol; pv_vs: vsymbol;
p_vty: vty; pv_ity: ity;
p_ghost: bool; pv_ghost: bool;
p_mutable: region option; pv_mutable: region option;
} }
val create_psymbol: ?mut:region -> ?ghost:bool -> vty -> psymbol val create_pvsymbol: preid -> ?mut:region -> ?ghost:bool -> ity -> pvsymbol
(* expression types *) (* value types *)
type ety = private type vty = private
| Evalue of psymbol | VTvalue of pvsymbol
| Earrow of psymbol * cty | VTarrow of pvsymbol * cty
(* computation types *) (* computation types *)
and cty = private { and cty = private {
c_pre: fmla; c_pre: term;
c_ety: ety; c_vty: vty;
c_eff: effect; c_eff: effect;
c_post: fmla; c_post: term;
c_xpost: xpost; c_xpost: xpost;
} }
and xpost = (psymbol * fmla) Xmap.t and xpost = (pvsymbol * term) Mexn.t
(* smart constructors *) (* smart constructors *)
val ety_value: psymbol -> ety val vty_value: pvsymbol -> vty
val ety_arrow: psymbol -> cty -> ety val vty_arrow:
pvsymbol -> ?pre:term -> ?post:term -> ?xpost:xpost -> vty -> effect -> vty
val create_cty: ?pre:fmla -> ?post:post -> ?xpost:xpost -> ety -> effect -> cty
****)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment