|
@@ -36,17 +36,10 @@ open MacroApi
|
|
|
|
|
|
(* Create *)
|
|
|
|
|
|
-let sid = ref (-1)
|
|
|
-
|
|
|
-let stdlib = ref None
|
|
|
-let debug = ref None
|
|
|
-
|
|
|
-let debugger_initialized = ref false
|
|
|
-
|
|
|
let create com api is_macro =
|
|
|
let t = Timer.timer [(if is_macro then "macro" else "interp");"create"] in
|
|
|
- incr sid;
|
|
|
- let builtins = match !stdlib with
|
|
|
+ incr GlobalState.sid;
|
|
|
+ let builtins = match !GlobalState.stdlib with
|
|
|
| None ->
|
|
|
let builtins = {
|
|
|
static_builtins = IntMap.empty;
|
|
@@ -55,12 +48,12 @@ let create com api is_macro =
|
|
|
empty_constructor_builtins = Hashtbl.create 0;
|
|
|
} in
|
|
|
EvalStdLib.init_standard_library builtins;
|
|
|
- stdlib := Some builtins;
|
|
|
+ GlobalState.stdlib := Some builtins;
|
|
|
builtins
|
|
|
| Some (builtins) ->
|
|
|
builtins
|
|
|
in
|
|
|
- let debug = match !debug with
|
|
|
+ let debug = match !GlobalState.debug with
|
|
|
| None ->
|
|
|
let support_debugger = Common.defined com Define.EvalDebugger in
|
|
|
let socket =
|
|
@@ -93,7 +86,7 @@ let create com api is_macro =
|
|
|
exception_mode = CatchUncaught;
|
|
|
debug_context = new eval_debug_context;
|
|
|
} in
|
|
|
- debug := Some debug';
|
|
|
+ GlobalState.debug := Some debug';
|
|
|
debug'
|
|
|
| Some debug ->
|
|
|
debug
|
|
@@ -107,7 +100,7 @@ let create com api is_macro =
|
|
|
let eval = EvalThread.create_eval thread in
|
|
|
let evals = IntMap.singleton 0 eval in
|
|
|
let rec ctx = {
|
|
|
- ctx_id = !sid;
|
|
|
+ ctx_id = !GlobalState.sid;
|
|
|
is_macro = is_macro;
|
|
|
debug = debug;
|
|
|
detail_times = detail_times;
|
|
@@ -134,11 +127,11 @@ let create com api is_macro =
|
|
|
exception_stack = [];
|
|
|
max_stack_depth = int_of_string (Common.defined_value_safe ~default:"1000" com Define.EvalCallStackDepth);
|
|
|
} in
|
|
|
- if debug.support_debugger && not !debugger_initialized then begin
|
|
|
+ if debug.support_debugger && not !GlobalState.debugger_initialized then begin
|
|
|
(* Let's wait till the debugger says we're good to continue. This allows it to finish configuration.
|
|
|
Note that configuration is shared between macro and interpreter contexts, which is why the check
|
|
|
is governed by a global variable. *)
|
|
|
- debugger_initialized := true;
|
|
|
+ GlobalState.debugger_initialized := true;
|
|
|
(* There's select_ctx in the json-rpc handling, so let's select this one. It's fine because it's the
|
|
|
first context anyway. *)
|
|
|
select ctx;
|
|
@@ -367,7 +360,7 @@ let setup get_api =
|
|
|
exc_string "Invalid expression"
|
|
|
in
|
|
|
let v = VFunction (f,b) in
|
|
|
- Hashtbl.replace EvalStdLib.macro_lib n v
|
|
|
+ Hashtbl.replace GlobalState.macro_lib n v
|
|
|
| _ -> assert false
|
|
|
) api;
|
|
|
Globals.macro_platform := Globals.Eval
|