129 map ML_Lex.read |
129 map ML_Lex.read |
130 ["Context.put_generic_context (SOME (Context.Theory ML_context))", |
130 ["Context.put_generic_context (SOME (Context.Theory ML_context))", |
131 "Context.put_generic_context (SOME (Context.Proof ML_context))", |
131 "Context.put_generic_context (SOME (Context.Proof ML_context))", |
132 "Context.put_generic_context (SOME ML_context)"]; |
132 "Context.put_generic_context (SOME ML_context)"]; |
133 |
133 |
134 fun make_environment sml = if sml then ML_Env.SML else ML_Env.Isabelle; |
134 fun environment SML = if SML then ML_Env.SML else ML_Env.Isabelle; |
|
135 fun operations SML = if SML then ML_Env.SML_operations else ML_Env.Isabelle_operations; |
135 |
136 |
136 fun evaluate {SML, verbose} = |
137 fun evaluate {SML, verbose} = |
137 ML_Context.eval |
138 ML_Context.eval |
138 {environment = make_environment SML, redirect = false, verbose = verbose, |
139 {environment = environment SML, redirect = false, verbose = verbose, |
139 debug = SOME false, writeln = writeln_message, warning = warning_message} |
140 debug = SOME false, writeln = writeln_message, warning = warning_message} |
140 Position.none; |
141 Position.none; |
141 |
142 |
142 fun eval_setup thread_name index SML context = |
143 fun eval_setup thread_name index SML context = |
143 context |
144 context |
144 |> Context_Position.set_visible_generic false |
145 |> Context_Position.set_visible_generic false |
145 |> ML_Env.add_name_space (make_environment SML) |
146 |> ML_Env.add_name_space (environment SML) |
146 (PolyML.DebuggerInterface.debugNameSpace (the_debug_state thread_name index)); |
147 (PolyML.DebuggerInterface.debugNameSpace (the_debug_state thread_name index)); |
147 |
148 |
148 fun eval_context thread_name index SML toks = |
149 fun eval_context thread_name index SML toks = |
149 let |
150 let |
150 val context = Context.the_generic_context (); |
151 val context = Context.the_generic_context (); |
168 |
169 |
169 in |
170 in |
170 |
171 |
171 fun eval thread_name index SML txt1 txt2 = |
172 fun eval thread_name index SML txt1 txt2 = |
172 let |
173 let |
173 val (toks1, toks2) = apply2 (ML_Lex.read_source SML o Input.string) (txt1, txt2); |
174 val (toks1, toks2) = apply2 (#read_source (operations SML) o Input.string) (txt1, txt2); |
174 val context = eval_context thread_name index SML toks1; |
175 val context = eval_context thread_name index SML toks1; |
175 in Context.setmp_generic_context (SOME context) (evaluate {SML = SML, verbose = true}) toks2 end; |
176 in Context.setmp_generic_context (SOME context) (evaluate {SML = SML, verbose = true}) toks2 end; |
176 |
177 |
177 fun print_vals thread_name index SML txt = |
178 fun print_vals thread_name index SML txt = |
178 let |
179 let |
179 val toks = ML_Lex.read_source SML (Input.string txt) |
180 val toks = #read_source (operations SML) (Input.string txt) |
180 val context = eval_context thread_name index SML toks; |
181 val context = eval_context thread_name index SML toks; |
181 val space = PolyML.DebuggerInterface.debugNameSpace (the_debug_state thread_name index); |
182 val space = PolyML.DebuggerInterface.debugNameSpace (the_debug_state thread_name index); |
182 |
183 |
183 fun print x = |
184 fun print x = |
184 Pretty.from_polyml |
185 Pretty.from_polyml |