Move to use libcurl-minimal
[hiphop-php.git] / hphp / hack / src / typing / typing_per_cont_env.mli
blob07954b9b728f2d29fb1e96a4b3da264312593945
1 (*
2 * Copyright (c) 2015, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
8 *)
10 (*****************************************************************************)
11 (* Functions dealing with continuation based flow typing of local variables *)
12 (*****************************************************************************)
14 module C = Typing_continuations
15 module CMap = C.Map
17 type per_cont_entry = {
18 (* Local types per continuation. For example, the local types of the
19 * break continuation correspond to the local types that there were at the
20 * last encountered break in the current scope. These are kept to be merged
21 * at the appropriate merge points. *)
22 local_types: Typing_local_types.t;
23 (* Fake members are used when we want member variables to be treated like
24 * locals. We want to handle the following:
25 * if($this->x) {
26 * ... $this->x ...
27 * }
28 * The trick consists in replacing $this->x with a "fake" local. So that
29 * all the logic that normally applies to locals is applied in cases like
30 * this. Hence the name: FakeMembers.
31 * All the fake members are thrown away at the first call.
32 * We keep the invalidated fake members for better error messages.
34 fake_members: Typing_fake_members.t;
35 (* Type parameter environment
36 * Lower and upper bounds on generic type parameters and abstract types
37 * For constraints of the form Tu <: Tv where both Tu and Tv are type
38 * parameters, we store an upper bound for Tu and a lower bound for Tv.
39 * Contrasting with tenv and subst, bounds are *assumptions* for type
40 * inference, not conclusions.
42 tpenv: Type_parameter_env.t;
45 type t = per_cont_entry Typing_continuations.Map.t
47 val initial_locals : per_cont_entry -> t
49 val empty_entry : per_cont_entry
51 (* Get a continuation wrapped in Some, or None if not found *)
52 val get_cont_option : C.t -> t -> per_cont_entry option
54 (** Get all continuations present in an environment *)
55 val all_continuations : t -> C.t list
57 (** Continuations used to typecheck the `finally` block. *)
58 val continuations_for_finally : C.t list
60 (* Add the key, value pair to the continuation named 'name'
61 * If the continuation doesn't exist, create it *)
62 val add_to_cont : C.t -> Local_id.t -> Typing_local_types.local -> t -> t
64 val update_cont_entry : C.t -> t -> (per_cont_entry -> per_cont_entry) -> t
66 (* remove a local from a continuation if it exists. Otherwise do nothing. *)
67 val remove_from_cont : C.t -> Local_id.t -> t -> t
69 (* Drop a continuation. If the continuation is absent, the map remains
70 * unchanged. *)
71 val drop_cont : C.t -> t -> t
73 val drop_conts : C.t list -> t -> t
75 val replace_cont : C.t -> per_cont_entry option -> t -> t