summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CfimOfJson.ml4
-rw-r--r--src/Interpreter.ml2
-rw-r--r--src/Print.ml12
-rw-r--r--src/Substitute.ml2
-rw-r--r--src/Types.ml18
5 files changed, 16 insertions, 22 deletions
diff --git a/src/CfimOfJson.ml b/src/CfimOfJson.ml
index f16ae601..f3527e17 100644
--- a/src/CfimOfJson.ml
+++ b/src/CfimOfJson.ml
@@ -27,7 +27,7 @@ let type_var_of_json (js : json) : (T.type_var, string) result =
| `Assoc [ ("index", index); ("name", name) ] ->
let* index = T.TypeVarId.id_of_json index in
let* name = string_of_json name in
- Ok { T.tv_index = index; tv_name = name }
+ Ok { T.index; name }
| _ -> Error "")
let region_var_of_json (js : json) : (T.region_var, string) result =
@@ -36,7 +36,7 @@ let region_var_of_json (js : json) : (T.region_var, string) result =
| `Assoc [ ("index", index); ("name", name) ] ->
let* index = T.RegionVarId.id_of_json index in
let* name = string_option_of_json name in
- Ok { T.rv_index = index; rv_name = name }
+ Ok { T.index; name }
| _ -> Error "")
let region_of_json (js : json) : (T.RegionVarId.id T.region, string) result =
diff --git a/src/Interpreter.ml b/src/Interpreter.ml
index fefbb00b..53cef961 100644
--- a/src/Interpreter.ml
+++ b/src/Interpreter.ml
@@ -2410,7 +2410,7 @@ and eval_local_function_call (config : C.config) (ctx : C.eval_ctx)
| ConcreteMode -> (
let tsubst =
Subst.make_type_subst
- (List.map (fun v -> v.T.tv_index) def.A.signature.type_params)
+ (List.map (fun v -> v.T.index) def.A.signature.type_params)
type_params
in
let locals, body = Subst.fun_def_substitute_in_body tsubst def in
diff --git a/src/Print.ml b/src/Print.ml
index b4c9a73a..6d7a6c68 100644
--- a/src/Print.ml
+++ b/src/Print.ml
@@ -11,12 +11,12 @@ module M = Modules
(** Pretty-printing for types *)
module Types = struct
- let type_var_to_string (tv : T.type_var) : string = tv.tv_name
+ let type_var_to_string (tv : T.type_var) : string = tv.name
let region_var_to_string (rv : T.region_var) : string =
- match rv.rv_name with
+ match rv.name with
| Some name -> name
- | None -> T.RegionVarId.to_string rv.rv_index
+ | None -> T.RegionVarId.to_string rv.index
let region_to_string (rid_to_string : 'rid -> string) (r : 'rid T.region) :
string =
@@ -109,13 +109,13 @@ module Types = struct
let regions = def.region_params in
let types = def.type_params in
let rid_to_string rid =
- match List.find_opt (fun rv -> rv.T.rv_index = rid) regions with
+ match List.find_opt (fun rv -> rv.T.index = rid) regions with
| Some rv -> region_var_to_string rv
| None -> failwith "Unreachable"
in
let r_to_string = region_to_string rid_to_string in
let type_var_id_to_string id =
- match List.find_opt (fun tv -> tv.T.tv_index = id) types with
+ match List.find_opt (fun tv -> tv.T.index = id) types with
| Some tv -> type_var_to_string tv
| None -> failwith "Unreachable"
in
@@ -449,7 +449,7 @@ module Contexts = struct
let r_to_string _ = failwith "Unexpected use of r_to_string" in
let type_var_id_to_string vid =
let v = C.lookup_type_var ctx vid in
- v.tv_name
+ v.name
in
let type_def_id_to_string def_id =
let def = T.TypeDefId.nth ctx.type_context def_id in
diff --git a/src/Substitute.ml b/src/Substitute.ml
index 13e0b583..635795ac 100644
--- a/src/Substitute.ml
+++ b/src/Substitute.ml
@@ -61,7 +61,7 @@ let make_type_subst (var_ids : T.TypeVarId.id list) (tys : 'r T.ty list) :
let type_def_get_instantiated_field_type (def : T.type_def)
(opt_variant_id : T.VariantId.id option) (types : T.ety list) : T.ety list =
let ty_subst =
- make_type_subst (List.map (fun x -> x.T.tv_index) def.T.type_params) types
+ make_type_subst (List.map (fun x -> x.T.index) def.T.type_params) types
in
let fields = TU.type_def_get_fields def opt_variant_id in
List.map
diff --git a/src/Types.ml b/src/Types.ml
index ba179ef8..8af62388 100644
--- a/src/Types.ml
+++ b/src/Types.ml
@@ -10,21 +10,15 @@ module FieldId = IdGen ()
module RegionVarId = IdGen ()
-type type_var = {
- tv_index : TypeVarId.id;
- (** Unique index identifying the variable - TODO: may be redundant with
- using indexed vectors *)
- tv_name : string; (** Variable name *)
+type ('id, 'name) indexed_var = {
+ index : 'id; (** Unique index identifying the variable *)
+ name : 'name; (** Variable name *)
}
[@@deriving show]
-type region_var = {
- rv_index : RegionVarId.id;
- (** Unique index identifying the region - TODO: may be redundant *)
- rv_name : string option; (** Region name *)
-}
-(* TODO: merge with type_var? (for the name collision issues) *)
-[@@deriving show]
+type type_var = (TypeVarId.id, string) indexed_var [@@deriving show]
+
+type region_var = (RegionVarId.id, string option) indexed_var [@@deriving show]
(** A region.