| author | blanchet | 
| Thu, 26 Jun 2014 13:35:17 +0200 | |
| changeset 57364 | c1060d10089f | 
| parent 56333 | 38f1422ef473 | 
| child 57858 | 39d9c7f175e0 | 
| permissions | -rw-r--r-- | 
| 28405 | 1 | (* Title: Pure/context_position.ML | 
| 2 | Author: Makarius | |
| 3 | ||
| 28409 | 4 | Context position visibility flag. | 
| 28405 | 5 | *) | 
| 6 | ||
| 7 | signature CONTEXT_POSITION = | |
| 8 | sig | |
| 55672 
5e25cc741ab9
support for completion within the formal context;
 wenzelm parents: 
52700diff
changeset | 9 | val is_visible_generic: Context.generic -> bool | 
| 28405 | 10 | val is_visible: Proof.context -> bool | 
| 52700 | 11 | val is_visible_global: theory -> bool | 
| 28405 | 12 | val set_visible: bool -> Proof.context -> Proof.context | 
| 52700 | 13 | val set_visible_global: bool -> theory -> theory | 
| 28405 | 14 | val restore_visible: Proof.context -> Proof.context -> Proof.context | 
| 52700 | 15 | val restore_visible_global: theory -> theory -> theory | 
| 55923 | 16 | val is_reported_generic: Context.generic -> Position.T -> bool | 
| 17 | val is_reported: Proof.context -> Position.T -> bool | |
| 47005 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 18 | val report_generic: Context.generic -> Position.T -> Markup.T -> unit | 
| 39507 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 19 | val reported_text: Proof.context -> Position.T -> Markup.T -> string -> string | 
| 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 20 | val report_text: Proof.context -> Position.T -> Markup.T -> string -> unit | 
| 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 21 | val report: Proof.context -> Position.T -> Markup.T -> unit | 
| 48767 | 22 | val reports_text: Proof.context -> Position.report_text list -> unit | 
| 44736 | 23 | val reports: Proof.context -> Position.report list -> unit | 
| 28405 | 24 | end; | 
| 25 | ||
| 33383 | 26 | structure Context_Position: CONTEXT_POSITION = | 
| 28405 | 27 | struct | 
| 28 | ||
| 47813 | 29 | structure Data = Generic_Data | 
| 30 | ( | |
| 31 | type T = bool option; | |
| 32 | val empty: T = NONE; | |
| 33 | val extend = I; | |
| 34 | fun merge (x, y): T = if is_some x then x else y; | |
| 35 | ); | |
| 36 | ||
| 37 | val is_visible_generic = the_default true o Data.get; | |
| 38 | val is_visible = is_visible_generic o Context.Proof; | |
| 52700 | 39 | val is_visible_global = is_visible_generic o Context.Theory; | 
| 28405 | 40 | |
| 52700 | 41 | val set_visible = Context.proof_map o Data.put o SOME; | 
| 42 | val set_visible_global = Context.theory_map o Data.put o SOME; | |
| 43 | ||
| 44 | val restore_visible = set_visible o is_visible; | |
| 45 | val restore_visible_global = set_visible_global o is_visible_global; | |
| 38831 
4933a3dfd745
more careful treatment of context visibility flag wrt. spurious warnings;
 wenzelm parents: 
38481diff
changeset | 46 | |
| 55923 | 47 | fun is_reported_generic context pos = is_visible_generic context andalso Position.is_reported pos; | 
| 48 | fun is_reported ctxt pos = is_visible ctxt andalso Position.is_reported pos; | |
| 49 | ||
| 47005 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 50 | fun report_generic context pos markup = | 
| 55923 | 51 | if is_reported_generic context pos then | 
| 56333 
38f1422ef473
support bulk messages consisting of small string segments, which are more healthy to the Poly/ML RTS and might prevent spurious GC crashes such as MTGCProcessMarkPointers::ScanAddressesInObject;
 wenzelm parents: 
56294diff
changeset | 52 | Output.report [Position.reported_text pos markup ""] | 
| 47005 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 53 | else (); | 
| 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 54 | |
| 39507 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 55 | fun reported_text ctxt pos markup txt = | 
| 55923 | 56 | if is_reported ctxt pos then Position.reported_text pos markup txt else ""; | 
| 38481 
81ec258c4cd3
Output_Position.report_text -- markup with potential "arguments";
 wenzelm parents: 
38237diff
changeset | 57 | |
| 56333 
38f1422ef473
support bulk messages consisting of small string segments, which are more healthy to the Poly/ML RTS and might prevent spurious GC crashes such as MTGCProcessMarkPointers::ScanAddressesInObject;
 wenzelm parents: 
56294diff
changeset | 58 | fun report_text ctxt pos markup txt = Output.report [reported_text ctxt pos markup txt]; | 
| 39507 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 59 | fun report ctxt pos markup = report_text ctxt pos markup ""; | 
| 28405 | 60 | |
| 48767 | 61 | fun reports_text ctxt reps = if is_visible ctxt then Position.reports_text reps else (); | 
| 44736 | 62 | fun reports ctxt reps = if is_visible ctxt then Position.reports reps else (); | 
| 63 | ||
| 28405 | 64 | end; |