2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
10 (*****************************************************************************)
11 (* Functions dealing with continuation based flow typing of local variables *)
12 (*****************************************************************************)
14 module C
= Typing_continuations
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:
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 (* Add the key, value pair to the continuation named 'name'
58 * If the continuation doesn't exist, create it *)
59 val add_to_cont
: C.t
-> Local_id.t
-> Typing_local_types.local
-> t
-> t
61 val update_cont_entry
: C.t
-> t
-> (per_cont_entry
-> per_cont_entry
) -> t
63 (* remove a local from a continuation if it exists. Otherwise do nothing. *)
64 val remove_from_cont
: C.t
-> Local_id.t
-> t
-> t
66 (* Drop a continuation. If the continuation is absent, the map remains
68 val drop_cont
: C.t
-> t
-> t
70 val drop_conts
: C.t list
-> t
-> t
72 val replace_cont
: C.t
-> per_cont_entry
option -> t
-> t