From 50dbeaeb018ab2cb44df3f557f1958eb15351f31 Mon Sep 17 00:00:00 2001 From: Aymeric Fromherz Date: Fri, 24 May 2024 12:47:43 +0200 Subject: Rename span into raw_span --- compiler/Errors.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler/Errors.ml') diff --git a/compiler/Errors.ml b/compiler/Errors.ml index 30887593..d084df51 100644 --- a/compiler/Errors.ml +++ b/compiler/Errors.ml @@ -1,13 +1,13 @@ let log = Logging.errors_log let meta_to_string (meta : Meta.meta) = - let span = meta.span in - let file = match span.file with Virtual s | Local s -> s in + let raw_span = meta.span in + let file = match raw_span.file with Virtual s | Local s -> s in let loc_to_string (l : Meta.loc) : string = string_of_int l.line ^ ":" ^ string_of_int l.col in - "Source: '" ^ file ^ "', lines " ^ loc_to_string span.beg_loc ^ "-" - ^ loc_to_string span.end_loc + "Source: '" ^ file ^ "', lines " ^ loc_to_string raw_span.beg_loc ^ "-" + ^ loc_to_string raw_span.end_loc let format_error_message (meta : Meta.meta option) (msg : string) = let meta = -- cgit v1.2.3 From b294639a5cbd2a51fc5bb5e55e0c386ee568ca8c Mon Sep 17 00:00:00 2001 From: Aymeric Fromherz Date: Fri, 24 May 2024 13:28:12 +0200 Subject: Rename meta into span --- compiler/Errors.ml | 70 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'compiler/Errors.ml') diff --git a/compiler/Errors.ml b/compiler/Errors.ml index d084df51..6e2de7e1 100644 --- a/compiler/Errors.ml +++ b/compiler/Errors.ml @@ -1,70 +1,72 @@ let log = Logging.errors_log -let meta_to_string (meta : Meta.meta) = - let raw_span = meta.span in +let span_to_string (span : Meta.span) = + let raw_span = span.span in let file = match raw_span.file with Virtual s | Local s -> s in let loc_to_string (l : Meta.loc) : string = string_of_int l.line ^ ":" ^ string_of_int l.col in - "Source: '" ^ file ^ "', lines " ^ loc_to_string raw_span.beg_loc ^ "-" + "Source: '" ^ file ^ "', lines " + ^ loc_to_string raw_span.beg_loc + ^ "-" ^ loc_to_string raw_span.end_loc -let format_error_message (meta : Meta.meta option) (msg : string) = - let meta = - match meta with None -> "" | Some meta -> "\n" ^ meta_to_string meta +let format_error_message (span : Meta.span option) (msg : string) = + let span = + match span with None -> "" | Some span -> "\n" ^ span_to_string span in - msg ^ meta + msg ^ span let format_error_message_with_file_line (file : string) (line : int) - (meta : Meta.meta option) (msg : string) = + (span : Meta.span option) (msg : string) = "In file " ^ file ^ ", line " ^ string_of_int line ^ ":\n" - ^ format_error_message meta msg + ^ format_error_message span msg -exception CFailure of (Meta.meta option * string) +exception CFailure of (Meta.span option * string) -let error_list : (Meta.meta option * string) list ref = ref [] +let error_list : (Meta.span option * string) list ref = ref [] -let push_error (meta : Meta.meta option) (msg : string) = - error_list := (meta, msg) :: !error_list +let push_error (span : Meta.span option) (msg : string) = + error_list := (span, msg) :: !error_list (** Register an error, and throw an exception if [throw] is true *) let save_error (file : string) (line : int) ?(throw : bool = false) - (meta : Meta.meta option) (msg : string) = - push_error meta msg; + (span : Meta.span option) (msg : string) = + push_error span msg; if !Config.fail_hard && throw then ( - let msg = format_error_message_with_file_line file line meta msg in + let msg = format_error_message_with_file_line file line span msg in log#serror (msg ^ "\n"); raise (Failure msg)) -let craise_opt_meta (file : string) (line : int) (meta : Meta.meta option) +let craise_opt_span (file : string) (line : int) (span : Meta.span option) (msg : string) = if !Config.fail_hard then ( - let msg = format_error_message_with_file_line file line meta msg in + let msg = format_error_message_with_file_line file line span msg in log#serror (msg ^ "\n"); - raise (Failure (format_error_message_with_file_line file line meta msg))) + raise (Failure (format_error_message_with_file_line file line span msg))) else - let () = push_error meta msg in - raise (CFailure (meta, msg)) + let () = push_error span msg in + raise (CFailure (span, msg)) -let craise (file : string) (line : int) (meta : Meta.meta) (msg : string) = - craise_opt_meta file line (Some meta) msg +let craise (file : string) (line : int) (span : Meta.span) (msg : string) = + craise_opt_span file line (Some span) msg -let cassert_opt_meta (file : string) (line : int) (b : bool) - (meta : Meta.meta option) (msg : string) = - if not b then craise_opt_meta file line meta msg +let cassert_opt_span (file : string) (line : int) (b : bool) + (span : Meta.span option) (msg : string) = + if not b then craise_opt_span file line span msg -let cassert (file : string) (line : int) (b : bool) (meta : Meta.meta) +let cassert (file : string) (line : int) (b : bool) (span : Meta.span) (msg : string) = - cassert_opt_meta file line b (Some meta) msg + cassert_opt_span file line b (Some span) msg -let sanity_check (file : string) (line : int) b meta = - cassert file line b meta "Internal error, please file an issue" +let sanity_check (file : string) (line : int) b span = + cassert file line b span "Internal error, please file an issue" -let sanity_check_opt_meta (file : string) (line : int) b meta = - cassert_opt_meta file line b meta "Internal error, please file an issue" +let sanity_check_opt_span (file : string) (line : int) b span = + cassert_opt_span file line b span "Internal error, please file an issue" -let internal_error (file : string) (line : int) meta = - craise file line meta "Internal error, please file an issue" +let internal_error (file : string) (line : int) span = + craise file line span "Internal error, please file an issue" let exec_raise = craise let exec_assert = cassert -- cgit v1.2.3