Skip to content

Commit

Permalink
Minor improvement in error reporting.
Browse files Browse the repository at this point in the history
Use simple name "int", "string" etc instead of
internal representation.
  • Loading branch information
skaller committed Jan 2, 2023
1 parent 3a47e71 commit 821e807
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/compiler/flx_core/flx_btype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ and str_of_btype typ =
| BTYP_sum ts -> "BTYP_sum(" ^ ss ts ^")"
| BTYP_compactsum ts -> "BTYP_compactsum(" ^ ss ts ^")"
| BTYP_unitsum n -> string_of_int n
| BTYP_inst (it, i,ts,mt) -> "BTYP_inst("^str_of_instkind it ^","^string_of_int i^"["^ss ts^"]:"^Flx_kind.sk mt^")"
| BTYP_inst (it, i,ts,mt) ->
begin match Flx_concordance.get_type_name i with
| Some name -> name
| None ->
"BTYP_inst("^str_of_instkind it ^","^string_of_int i^"["^ss ts^"]:"^Flx_kind.sk mt^")"
end
| BTYP_finst (i,ks,dom,cod) -> "BTYP_finst("^string_of_int i^"["^sks ks^"]:"^sk dom^"->"^sk cod^")"
| BTYP_vinst (i,ts,mt) -> "BTYP_vinst("^string_of_int i^"["^ss ts^"]:"^Flx_kind.sk mt^")"
| BTYP_tuple ts -> "BTYP_tuple(" ^ ss ts ^ ")"
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/flx_core/flx_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,11 @@ and sb bsym_table depth fixlist counter prec tc =
">"

| BTYP_inst (it,i,ts,mt) ->
0, (match bsym_table with
0, (
match Flx_concordance.get_type_name i with
| Some name -> name
| None ->
match bsym_table with
| Some tab -> let name = qualified_name_of_bindex tab i in
(* print_endline ("DEBUG: flx_print: BTYP_inst " ^ si i ^ ": " ^ name); *)
str_of_instkind it ^ " " ^ name
Expand Down
7 changes: 7 additions & 0 deletions src/packages/concordance.fdoc
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,12 @@ let flx_decr_int = 203
let flx_land = 210
let flx_lor = 211
let flx_lnot = 212

let get_type_name (x:int) : string option =
match x with
| 102 -> Some "int"
| 112 -> Some "size"
| 402 -> Some "string"
| _ -> None
@

2 changes: 1 addition & 1 deletion src/packages/strings.fdoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This type is deprecated, to be repalced by C++11 unicode string type.
@tangle string.flx
typedef cstring = +char;
type string = "::std::basic_string<char>"
requires Cxx_headers::string,
requires index TYPE_string, Cxx_headers::string,
header '#include "flx_serialisers.hpp"',
encoder "::flx::gc::generic::string_encoder",
decoder "::flx::gc::generic::string_decoder"
Expand Down

0 comments on commit 821e807

Please sign in to comment.