4 Exception properties. |
4 Exception properties. |
5 *) |
5 *) |
6 |
6 |
7 signature EXN_PROPERTIES = |
7 signature EXN_PROPERTIES = |
8 sig |
8 sig |
9 val position_of_location: PolyML.location -> Position.T |
9 val position_of_polyml_location: ML_Compiler0.polyml_location -> Position.T |
10 val position: exn -> Position.T |
10 val position: exn -> Position.T |
11 val get: exn -> Properties.T |
11 val get: exn -> Properties.T |
12 val update: Properties.entry list -> exn -> exn |
12 val update: Properties.entry list -> exn -> exn |
13 end; |
13 end; |
14 |
14 |
15 structure Exn_Properties: EXN_PROPERTIES = |
15 structure Exn_Properties: EXN_PROPERTIES = |
16 struct |
16 struct |
17 |
17 |
18 (* source locations *) |
18 (* source locations *) |
19 |
19 |
20 fun props_of_location (loc: PolyML.location) = |
20 fun props_of_polyml_location (loc: ML_Compiler0.polyml_location) = |
21 (case YXML.parse_body (#file loc) of |
21 (case YXML.parse_body (#file loc) of |
22 [] => [] |
22 [] => [] |
23 | [XML.Text file] => |
23 | [XML.Text file] => |
24 if file = "Standard Basis" then [] |
24 if file = "Standard Basis" then [] |
25 else [(Markup.fileN, ML_System.standard_path file)] |
25 else [(Markup.fileN, ML_System.standard_path file)] |
26 | body => XML.Decode.properties body); |
26 | body => XML.Decode.properties body); |
27 |
27 |
28 fun position_of_location loc = |
28 fun position_of_polyml_location loc = |
29 Position.make |
29 Position.make |
30 {line = FixedInt.toInt (#startLine loc), |
30 {line = FixedInt.toInt (#startLine loc), |
31 offset = FixedInt.toInt (#startPosition loc), |
31 offset = FixedInt.toInt (#startPosition loc), |
32 end_offset = FixedInt.toInt (#endPosition loc), |
32 end_offset = FixedInt.toInt (#endPosition loc), |
33 props = props_of_location loc}; |
33 props = props_of_polyml_location loc}; |
34 |
34 |
35 fun position exn = |
35 fun position exn = |
36 (case PolyML.exceptionLocation exn of |
36 (case Exn.polyml_location exn of |
37 NONE => Position.none |
37 NONE => Position.none |
38 | SOME loc => position_of_location loc); |
38 | SOME loc => position_of_polyml_location loc); |
39 |
39 |
40 |
40 |
41 (* exception properties *) |
41 (* exception properties *) |
42 |
42 |
43 fun get exn = |
43 fun get exn = |
44 (case PolyML.exceptionLocation exn of |
44 (case Exn.polyml_location exn of |
45 NONE => [] |
45 NONE => [] |
46 | SOME loc => props_of_location loc); |
46 | SOME loc => props_of_polyml_location loc); |
47 |
47 |
48 fun update entries exn = |
48 fun update entries exn = |
49 if Exn.is_interrupt exn then exn |
49 if Exn.is_interrupt exn then exn |
50 else |
50 else |
51 let |
51 let |
52 val loc = |
52 val loc = |
53 the_default {file = "", startLine = 0, endLine = 0, startPosition = 0, endPosition = 0} |
53 the_default {file = "", startLine = 0, endLine = 0, startPosition = 0, endPosition = 0} |
54 (PolyML.exceptionLocation exn); |
54 (Exn.polyml_location exn); |
55 val props = props_of_location loc; |
55 val props = props_of_polyml_location loc; |
56 val props' = fold Properties.put entries props; |
56 val props' = fold Properties.put entries props; |
57 in |
57 in |
58 if props = props' then exn |
58 if props = props' then exn |
59 else |
59 else |
60 let |
60 let |