|
2 | 2 | open DisplayTypes.DisplayMode |
3 | 3 | open Type |
4 | 4 | open Common |
| 5 | +open Error |
5 | 6 | open PlatformConfig |
6 | 7 | open DefineList |
7 | 8 | open MetaList |
@@ -65,15 +66,14 @@ type 'value compiler_api = { |
65 | 66 | decode_type : 'value -> t; |
66 | 67 | info : ?depth:int -> string -> pos -> unit; |
67 | 68 | warning : ?depth:int -> Warning.warning -> string -> pos -> unit; |
68 | | - display_error : ?depth:int -> (string -> pos -> unit); |
| 69 | + display_error : ?sub:macro_error list -> string -> pos -> unit; |
69 | 70 | with_imports : 'a . import list -> placed_name list list -> (unit -> 'a) -> 'a; |
70 | 71 | with_options : 'a . compiler_options -> (unit -> 'a) -> 'a; |
71 | 72 | exc_string : 'a . string -> 'a; |
72 | 73 | get_hxb_writer_config : unit -> 'value; |
73 | 74 | set_hxb_writer_config : 'value -> unit; |
74 | 75 | } |
75 | 76 |
|
76 | | - |
77 | 77 | type enum_type = |
78 | 78 | | IExpr |
79 | 79 | | IEFieldKind |
@@ -747,6 +747,15 @@ let decode_placed_name vp v = |
747 | 747 | let decode_opt_array f v = |
748 | 748 | if v = vnull then [] else List.map f (decode_array v) |
749 | 749 |
|
| 750 | +let decode_sub_errors sub = |
| 751 | + let rec decode_sub o = |
| 752 | + let msg = decode_string (field o "msg") in |
| 753 | + let pos = decode_pos (field o "pos") in |
| 754 | + let sub = decode_opt_array decode_sub (field o "sub") in |
| 755 | + {msg; pos; sub} |
| 756 | + in |
| 757 | + decode_opt_array decode_sub sub |
| 758 | + |
750 | 759 | (* Ast.placed_type_path *) |
751 | 760 | let rec decode_ast_path t = |
752 | 761 | let pack = List.map decode_string (decode_array (field t "pack")) |
@@ -1800,24 +1809,24 @@ let macro_api ccom get_api = |
1800 | 1809 | "init_macros_done", vfun0 (fun () -> |
1801 | 1810 | vbool ((get_api()).init_macros_done ()) |
1802 | 1811 | ); |
1803 | | - "error", vfun3 (fun msg p depth -> |
| 1812 | + "error", vfun3 (fun msg p sub -> |
1804 | 1813 | let msg = decode_string msg in |
1805 | 1814 | let p = decode_pos p in |
1806 | | - let depth = decode_int depth in |
1807 | | - (get_api()).display_error ~depth msg p; |
| 1815 | + let sub = decode_sub_errors sub in |
| 1816 | + (get_api()).display_error ~sub msg p; |
1808 | 1817 | raise Abort |
1809 | 1818 | ); |
1810 | | - "fatal_error", vfun3 (fun msg p depth -> |
| 1819 | + "fatal_error", vfun3 (fun msg p sub -> |
1811 | 1820 | let msg = decode_string msg in |
1812 | | - let p = decode_pos p in |
1813 | | - let depth = decode_int depth in |
1814 | | - raise (Error.Fatal_error (Error.make_error ~depth (Custom msg) p)) |
| 1821 | + let pos = decode_pos p in |
| 1822 | + let sub = decode_sub_errors sub in |
| 1823 | + raise (Error.Fatal_error (Error.convert_error {msg; pos; sub})) |
1815 | 1824 | ); |
1816 | | - "report_error", vfun3 (fun msg p depth -> |
| 1825 | + "report_error", vfun3 (fun msg p sub -> |
1817 | 1826 | let msg = decode_string msg in |
1818 | 1827 | let p = decode_pos p in |
1819 | | - let depth = decode_int depth in |
1820 | | - (get_api()).display_error ~depth msg p; |
| 1828 | + let sub = decode_sub_errors sub in |
| 1829 | + (get_api()).display_error ~sub msg p; |
1821 | 1830 | vnull |
1822 | 1831 | ); |
1823 | 1832 | "warning", vfun3 (fun msg p depth -> |
|
0 commit comments