-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor out type reading logic (#67)
- Loading branch information
Showing
10 changed files
with
743 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module I = Types_in | ||
|
||
let get_def_name (td : I.ty_def) = | ||
match td with | ||
| TDOpaque (name, _) | ||
| TDAdt (name, _, _) | ||
| TDRecord (name, _, _) | ||
| TDAlias (name, _) -> | ||
name | ||
|
||
let find_ty_def name (st : I.structure) = | ||
try | ||
List.find | ||
(fun td -> | ||
match td with | ||
| I.TDOpaque (name', _) | ||
| I.TDAdt (name', _, _) | ||
| I.TDRecord (name', _, _) | ||
| I.TDAlias (name', _) | ||
when name' = name -> | ||
true | ||
| _ -> false) | ||
st.ty_defs | ||
with | ||
| Not_found -> Report.(error_comp_not_found Type name st) | ||
|
||
let find_component kind name map st = | ||
try List.assoc name map with | ||
| Not_found -> Report.error_comp_not_found kind name st | ||
|
||
let find_val_comp name (st : I.structure) = | ||
find_component Value name st.val_defs st | ||
|
||
let find_constr_comp name (st : I.structure) = | ||
find_component Constructor name st.constr_defs st | ||
|
||
let find_mod_comp name (st : I.structure) = | ||
find_component Mod name st.mod_defs st | ||
|
||
let find_mod_sig_comp name (st : I.structure) = | ||
find_component ModSig name st.mod_sigs st |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
val unify : Types_in.ty -> Types_in.ty -> unit | ||
|
||
val occur : Types_in.tv ref -> Types_in.ty -> bool | ||
|
||
exception OccurError of (Types_in.tv ref * Types_in.ty) |
Oops, something went wrong.