src/Pure/ML/ml_env.ML
author wenzelm
Tue, 25 Mar 2014 13:18:10 +0100
changeset 56275 600f432ab556
parent 56203 76c72f4d0667
child 56618 874bdedb2313
permissions -rw-r--r--
added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/ML/ml_env.ML
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     3
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
     4
Toplevel environment for Standard ML and Isabelle/ML within the
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
     5
implicit context.
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     6
*)
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     7
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     8
signature ML_ENV =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
     9
sig
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    10
  val inherit: Context.generic -> Context.generic -> Context.generic
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    11
  val SML_name_space: ML_Name_Space.T
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    12
  val name_space: ML_Name_Space.T
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    13
  val local_context: use_context
36163
823c9400eb62 proper checking of ML functors (in Poly/ML 5.2 or later);
wenzelm
parents: 33519
diff changeset
    14
  val check_functor: string -> unit
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    15
end
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    16
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    17
structure ML_Env: ML_ENV =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    18
struct
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    19
31328
0d3aa0aeb96f maintain tokens within common ML environment;
wenzelm
parents: 31325
diff changeset
    20
(* context data *)
0d3aa0aeb96f maintain tokens within common ML environment;
wenzelm
parents: 31325
diff changeset
    21
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    22
type tables =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    23
  ML_Name_Space.valueVal Symtab.table *
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    24
  ML_Name_Space.typeVal Symtab.table *
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    25
  ML_Name_Space.fixityVal Symtab.table *
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    26
  ML_Name_Space.structureVal Symtab.table *
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    27
  ML_Name_Space.signatureVal Symtab.table *
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    28
  ML_Name_Space.functorVal Symtab.table;
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    29
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    30
fun merge_tables
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    31
  ((val1, type1, fixity1, structure1, signature1, functor1),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    32
   (val2, type2, fixity2, structure2, signature2, functor2)) : tables =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    33
  (Symtab.merge (K true) (val1, val2),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    34
   Symtab.merge (K true) (type1, type2),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    35
   Symtab.merge (K true) (fixity1, fixity2),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    36
   Symtab.merge (K true) (structure1, structure2),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    37
   Symtab.merge (K true) (signature1, signature2),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    38
   Symtab.merge (K true) (functor1, functor2));
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    39
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    40
type data = {bootstrap: bool, tables: tables, sml_tables: tables};
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    41
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    42
fun make_data (bootstrap, tables, sml_tables) : data =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    43
  {bootstrap = bootstrap, tables = tables, sml_tables = sml_tables};
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    44
33519
e31a85f92ce9 adapted Generic_Data, Proof_Data;
wenzelm
parents: 31470
diff changeset
    45
structure Env = Generic_Data
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    46
(
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    47
  type T = data
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    48
  val empty =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    49
    make_data (true,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    50
      (Symtab.empty, Symtab.empty, Symtab.empty, Symtab.empty, Symtab.empty, Symtab.empty),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    51
      (Symtab.make ML_Name_Space.initial_val,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    52
       Symtab.make ML_Name_Space.initial_type,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    53
       Symtab.make ML_Name_Space.initial_fixity,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    54
       Symtab.make ML_Name_Space.initial_structure,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    55
       Symtab.make ML_Name_Space.initial_signature,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    56
       Symtab.make ML_Name_Space.initial_functor));
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    57
  fun extend (data : T) = make_data (false, #tables data, #sml_tables data);
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    58
  fun merge (data : T * T) =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    59
    make_data (false,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    60
      merge_tables (pairself #tables data),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    61
      merge_tables (pairself #sml_tables data));
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    62
);
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    63
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    64
val inherit = Env.put o Env.get;
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
    65
31328
0d3aa0aeb96f maintain tokens within common ML environment;
wenzelm
parents: 31325
diff changeset
    66
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    67
(* SML name space *)
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    68
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    69
val SML_name_space: ML_Name_Space.T =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    70
  let
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    71
    fun lookup which name =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    72
      Context.the_thread_data ()
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    73
      |> (fn context => Symtab.lookup (which (#sml_tables (Env.get context))) name);
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    74
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    75
    fun all which () =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    76
      Context.the_thread_data ()
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    77
      |> (fn context => Symtab.dest (which (#sml_tables (Env.get context))))
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    78
      |> sort_distinct (string_ord o pairself #1);
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    79
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    80
    fun enter which entry =
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    81
      Context.>> (Env.map (fn {bootstrap, tables, sml_tables} =>
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    82
        let val sml_tables' = which (Symtab.update entry) sml_tables
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    83
        in make_data (bootstrap, tables, sml_tables') end));
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    84
  in
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    85
   {lookupVal    = lookup #1,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    86
    lookupType   = lookup #2,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    87
    lookupFix    = lookup #3,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    88
    lookupStruct = lookup #4,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    89
    lookupSig    = lookup #5,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    90
    lookupFunct  = lookup #6,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    91
    enterVal     = enter (fn h => fn (a, b, c, d, e, f) => (h a, b, c, d, e, f)),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    92
    enterType    = enter (fn h => fn (a, b, c, d, e, f) => (a, h b, c, d, e, f)),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    93
    enterFix     = enter (fn h => fn (a, b, c, d, e, f) => (a, b, h c, d, e, f)),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    94
    enterStruct  = enter (fn h => fn (a, b, c, d, e, f) => (a, b, c, h d, e, f)),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    95
    enterSig     = enter (fn h => fn (a, b, c, d, e, f) => (a, b, c, d, h e, f)),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    96
    enterFunct   = enter (fn h => fn (a, b, c, d, e, f) => (a, b, c, d, e, h f)),
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    97
    allVal       = all #1,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    98
    allType      = all #2,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
    99
    allFix       = all #3,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   100
    allStruct    = all #4,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   101
    allSig       = all #5,
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   102
    allFunct     = all #6}
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   103
  end;
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   104
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   105
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   106
(* Isabelle/ML name space *)
31328
0d3aa0aeb96f maintain tokens within common ML environment;
wenzelm
parents: 31325
diff changeset
   107
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   108
val name_space: ML_Name_Space.T =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   109
  let
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   110
    fun lookup sel1 sel2 name =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   111
      Context.thread_data ()
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   112
      |> (fn NONE => NONE | SOME context => Symtab.lookup (sel1 (#tables (Env.get context))) name)
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   113
      |> (fn NONE => sel2 ML_Name_Space.global name | some => some);
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   114
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   115
    fun all sel1 sel2 () =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   116
      Context.thread_data ()
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   117
      |> (fn NONE => [] | SOME context => Symtab.dest (sel1 (#tables (Env.get context))))
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   118
      |> append (sel2 ML_Name_Space.global ())
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   119
      |> sort_distinct (string_ord o pairself #1);
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   120
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   121
    fun enter ap1 sel2 entry =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   122
      if is_some (Context.thread_data ()) then
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   123
        Context.>> (Env.map (fn {bootstrap, tables, sml_tables} =>
56203
76c72f4d0667 clarified bootstrap process: switch to ML with context and antiquotations earlier;
wenzelm
parents: 48992
diff changeset
   124
          let
56275
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   125
            val _ = if bootstrap then sel2 ML_Name_Space.global entry else ();
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   126
            val tables' = ap1 (Symtab.update entry) tables;
600f432ab556 added command 'SML_file' for Standard ML without Isabelle/ML add-ons;
wenzelm
parents: 56203
diff changeset
   127
          in make_data (bootstrap, tables', sml_tables) end))
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   128
      else sel2 ML_Name_Space.global entry;
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   129
  in
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   130
   {lookupVal    = lookup #1 #lookupVal,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   131
    lookupType   = lookup #2 #lookupType,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   132
    lookupFix    = lookup #3 #lookupFix,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   133
    lookupStruct = lookup #4 #lookupStruct,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   134
    lookupSig    = lookup #5 #lookupSig,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   135
    lookupFunct  = lookup #6 #lookupFunct,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   136
    enterVal     = enter (fn h => fn (a, b, c, d, e, f) => (h a, b, c, d, e, f)) #enterVal,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   137
    enterType    = enter (fn h => fn (a, b, c, d, e, f) => (a, h b, c, d, e, f)) #enterType,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   138
    enterFix     = enter (fn h => fn (a, b, c, d, e, f) => (a, b, h c, d, e, f)) #enterFix,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   139
    enterStruct  = enter (fn h => fn (a, b, c, d, e, f) => (a, b, c, h d, e, f)) #enterStruct,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   140
    enterSig     = enter (fn h => fn (a, b, c, d, e, f) => (a, b, c, d, h e, f)) #enterSig,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   141
    enterFunct   = enter (fn h => fn (a, b, c, d, e, f) => (a, b, c, d, e, h f)) #enterFunct,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   142
    allVal       = all #1 #allVal,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   143
    allType      = all #2 #allType,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   144
    allFix       = all #3 #allFix,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   145
    allStruct    = all #4 #allStruct,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   146
    allSig       = all #5 #allSig,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   147
    allFunct     = all #6 #allFunct}
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   148
  end;
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   149
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   150
val local_context: use_context =
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   151
 {tune_source = ML_Parse.fix_ints,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   152
  name_space = name_space,
48992
0518bf89c777 renamed Position.str_of to Position.here;
wenzelm
parents: 36165
diff changeset
   153
  str_of_pos = Position.here oo Position.line_file,
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   154
  print = writeln,
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   155
  error = error};
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   156
36163
823c9400eb62 proper checking of ML functors (in Poly/ML 5.2 or later);
wenzelm
parents: 33519
diff changeset
   157
val is_functor = is_some o #lookupFunct name_space;
823c9400eb62 proper checking of ML functors (in Poly/ML 5.2 or later);
wenzelm
parents: 33519
diff changeset
   158
823c9400eb62 proper checking of ML functors (in Poly/ML 5.2 or later);
wenzelm
parents: 33519
diff changeset
   159
fun check_functor name =
36165
310a3f2f0e7e proper masking of dummy name_space;
wenzelm
parents: 36163
diff changeset
   160
  if not (is_functor "Table") (*mask dummy version of name_space*) orelse is_functor name then ()
36163
823c9400eb62 proper checking of ML functors (in Poly/ML 5.2 or later);
wenzelm
parents: 33519
diff changeset
   161
  else error ("Unknown ML functor: " ^ quote name);
823c9400eb62 proper checking of ML functors (in Poly/ML 5.2 or later);
wenzelm
parents: 33519
diff changeset
   162
31325
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   163
end;
700951b53d21 moved local ML environment to separate module ML_Env;
wenzelm
parents:
diff changeset
   164