src/Pure/ML/ml_context.ML
changeset 58978 e42da880c61e
parent 58928 23d0ffd48006
child 58979 162a4c2e97bc
equal deleted inserted replaced
58977:9576b510f6a2 58978:e42da880c61e
    23   val eval_file: ML_Compiler.flags -> Path.T -> unit
    23   val eval_file: ML_Compiler.flags -> Path.T -> unit
    24   val eval_source: ML_Compiler.flags -> Symbol_Pos.source -> unit
    24   val eval_source: ML_Compiler.flags -> Symbol_Pos.source -> unit
    25   val eval_in: Proof.context option -> ML_Compiler.flags -> Position.T ->
    25   val eval_in: Proof.context option -> ML_Compiler.flags -> Position.T ->
    26     ML_Lex.token Antiquote.antiquote list -> unit
    26     ML_Lex.token Antiquote.antiquote list -> unit
    27   val eval_source_in: Proof.context option -> ML_Compiler.flags -> Symbol_Pos.source -> unit
    27   val eval_source_in: Proof.context option -> ML_Compiler.flags -> Symbol_Pos.source -> unit
    28   val expression: Position.T -> string -> string -> ML_Lex.token Antiquote.antiquote list ->
    28   val expression: Position.range -> string -> string ->
    29     Context.generic -> Context.generic
    29     ML_Lex.token Antiquote.antiquote list -> Context.generic -> Context.generic
    30 end
    30 end
    31 
    31 
    32 structure ML_Context: ML_CONTEXT =
    32 structure ML_Context: ML_CONTEXT =
    33 struct
    33 struct
    34 
    34 
   171 fun eval_file flags path =
   171 fun eval_file flags path =
   172   let val pos = Path.position path
   172   let val pos = Path.position path
   173   in eval flags pos (ML_Lex.read pos (File.read path)) end;
   173   in eval flags pos (ML_Lex.read pos (File.read path)) end;
   174 
   174 
   175 fun eval_source flags source =
   175 fun eval_source flags source =
   176   eval flags (#pos source) (ML_Lex.read_source (#SML flags) source);
   176   eval flags (#1 (#range source)) (ML_Lex.read_source (#SML flags) source);
   177 
   177 
   178 fun eval_in ctxt flags pos ants =
   178 fun eval_in ctxt flags pos ants =
   179   Context.setmp_thread_data (Option.map Context.Proof ctxt)
   179   Context.setmp_thread_data (Option.map Context.Proof ctxt)
   180     (fn () => eval flags pos ants) ();
   180     (fn () => eval flags pos ants) ();
   181 
   181 
   182 fun eval_source_in ctxt flags source =
   182 fun eval_source_in ctxt flags source =
   183   Context.setmp_thread_data (Option.map Context.Proof ctxt)
   183   Context.setmp_thread_data (Option.map Context.Proof ctxt)
   184     (fn () => eval_source flags source) ();
   184     (fn () => eval_source flags source) ();
   185 
   185 
   186 fun expression pos bind body ants =
   186 fun expression range bind body ants =
   187   exec (fn () =>
   187   exec (fn () =>
   188     eval ML_Compiler.flags pos
   188     eval ML_Compiler.flags (#1 range)
   189      (ML_Lex.read Position.none ("Context.set_thread_data (SOME (let " ^ bind ^ " = ") @ ants @
   189      (ML_Lex.read_set_range range ("Context.set_thread_data (SOME (let " ^ bind ^ " = ") @
   190       ML_Lex.read Position.none (" in " ^ body ^ " end (ML_Context.the_generic_context ())));")));
   190       ants @
       
   191       ML_Lex.read_set_range range (" in " ^ body ^ " end (ML_Context.the_generic_context ())));")));
   191 
   192 
   192 end;
   193 end;
   193 
   194