2 * Copyright (c) 2017, 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.
9 (* Tracks the different types of mutability of a given local variable
10 Mutable: Objects marked as mutable must be affine, as in have 0-1 references.
11 These are mutably owned, so they can be frozen to become immutable. They can
12 have their properties set, but cannot be assigned to or passed to
15 Borrowed: Mutably borrowed. These can have their properties set, but cannot be
16 frozen, and have all the same restrictions as mutable variables.
17 A mutable parameter is always mutably borrowed.
19 Const: Const types have all the restrictions of immutable vars and mutable
20 vars. They cannot have their object properties be written toward, and cannot be
21 reassigned. They are essentially read only.
23 type mut_type
= Mutable
| Borrowed
| Const
24 type mutability
= Pos.t
* mut_type
26 (* Mapping from local variables to their mutability
27 Local mutability is stored in the local environment.
28 Once a variable is frozen, we remove it from the map,
29 and it is treated like any immutable variable in its
32 type mutability_env
= mutability
Local_id.Map.t
34 (* Given two mutability maps, intersect them. *)
35 val intersect_mutability
: mutability_env
-> mutability_env
-> mutability_env
-> mutability_env
36 val to_string
: mutability
-> string