Commit 3909931e authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-03-15 14:05:23 by afrisch] Replace Global ref with external ref when creating .cdo...

Original author: afrisch
Date: 2004-03-15 14:05:23+00:00
parent b2f2fc81
......@@ -48,6 +48,21 @@ and branches = {
(Patterns.Compile.dispatcher * expr Patterns.Compile.rhs array) option
}
let rec dump_expr ppf = function
| Var v -> print_var_loc ppf v
| ExtVar (cu,i) -> Format.fprintf ppf "Extvar (_,%i)" i
| Apply (tr,f,x) -> Format.fprintf ppf "Apply (%b,%a,%a)" tr dump_expr f dump_expr x
| Abstraction (env,iface,brs) ->
Format.fprintf ppf "Abstraction ([";
for i = 0 to Array.length env - 1 do
Format.fprintf ppf "{%a}," print_var_loc env.(i);
done;
Format.fprintf ppf "],%a)" dump_branches brs
| _ -> Format.fprintf ppf "other expr";
and dump_branches ppf brs =
List.iter (fun (p,e) -> Format.fprintf ppf "_ -> %a |" dump_expr e) brs.brs
type code_item =
| Eval of expr
| Let_decl of Patterns.node * expr
......@@ -70,14 +85,16 @@ module Put = struct
let binary_op = ref (fun _ _ -> assert false; ())
open Serialize.Put
let current_cu = ref Types.CompUnit.pervasives
(* Used to create self reference when saving *)
let var_loc s = function
| Stack i ->
bits 2 s 0;
int s i
| Global i ->
bits 2 s 1;
int s i
assert false;
| Env i ->
bits 2 s 2;
int s i
......@@ -85,6 +102,14 @@ module Put = struct
bits 2 s 3
let rec expr s = function
| ExtVar (cu,pos) ->
bits nbits s 19;
Types.CompUnit.serialize s cu;
int s pos
| Var (Global pos) ->
bits nbits s 19;
Types.CompUnit.serialize s !current_cu;
int s pos
| Var v ->
bits nbits s 0;
var_loc s v
......@@ -160,10 +185,6 @@ module Put = struct
bits nbits s 18;
expr s e;
Types.Node.serialize s t
| ExtVar (cu,pos) ->
bits nbits s 19;
Types.CompUnit.serialize s cu;
int s pos
and branches s brs =
list (pair Patterns.Node.serialize expr) s brs.brs;
......@@ -193,7 +214,6 @@ module Get = struct
let var_loc s =
match bits 2 s with
| 0 -> Stack (int s)
| 1 -> Global (int s)
| 2 -> Env (int s)
| 3 -> Dummy
| _ -> assert false
......
......@@ -110,8 +110,8 @@ schema/schema_parser.cmx: misc/q_symbol.cmo misc/encodings.cmx types/intervals.c
runtime/value.cmx schema/schema_parser.cmi
parser/location.cmo: misc/q_symbol.cmo parser/location.cmi
parser/location.cmx: misc/q_symbol.cmo parser/location.cmi
parser/url.cmo: misc/q_symbol.cmo parser/url.cmi
parser/url.cmx: misc/q_symbol.cmo parser/url.cmi
parser/url.cmo: misc/q_symbol.cmo parser/location.cmi parser/url.cmi
parser/url.cmx: misc/q_symbol.cmo parser/location.cmx parser/url.cmi
parser/ulexer.cmo: misc/q_symbol.cmo parser/ulexer.cmi
parser/ulexer.cmx: misc/q_symbol.cmo parser/ulexer.cmi
parser/ast.cmo: misc/q_symbol.cmo types/builtin_defs.cmi types/chars.cmi types/ident.cmo \
......@@ -218,18 +218,42 @@ driver/librarian.cmx: misc/q_symbol.cmo types/builtin.cmx compile/compile.cmx \
parser/location.cmx parser/parser.cmx types/sequence.cmx \
misc/serialize.cmx typing/typer.cmx types/types.cmx runtime/value.cmx \
driver/librarian.cmi
cdo2cmo/ml_types.cmo: misc/q_symbol.cmo types/types.cmi
cdo2cmo/ml_types.cmx: misc/q_symbol.cmo types/types.cmx
cdo2cmo/ml_cduce.cmo: misc/q_symbol.cmo types/atoms.cmi types/builtin_defs.cmi types/chars.cmi \
compile/compile.cmi misc/encodings.cmi types/ident.cmo \
types/intervals.cmi compile/lambda.cmo driver/librarian.cmi \
cdo2cmo/ml_types.cmo misc/ns.cmi types/sequence.cmi typing/typer.cmi \
types/types.cmi
cdo2cmo/ml_cduce.cmx: misc/q_symbol.cmo types/atoms.cmx types/builtin_defs.cmx types/chars.cmx \
compile/compile.cmx misc/encodings.cmx types/ident.cmx \
types/intervals.cmx compile/lambda.cmx driver/librarian.cmx \
cdo2cmo/ml_types.cmx misc/ns.cmx types/sequence.cmx typing/typer.cmx \
types/types.cmx
cdo2cmo/ml_ocaml.cmo: misc/q_symbol.cmo driver/librarian.cmi cdo2cmo/ml_types.cmo
cdo2cmo/ml_ocaml.cmx: misc/q_symbol.cmo driver/librarian.cmx cdo2cmo/ml_types.cmx
cdo2cmo/ml_checker.cmo: misc/q_symbol.cmo cdo2cmo/ml_cduce.cmo cdo2cmo/ml_ocaml.cmo \
cdo2cmo/ml_types.cmo
cdo2cmo/ml_checker.cmx: misc/q_symbol.cmo cdo2cmo/ml_cduce.cmx cdo2cmo/ml_ocaml.cmx \
cdo2cmo/ml_types.cmx
cdo2cmo/ml_generator.cmo: misc/q_symbol.cmo cdo2cmo/ml_cduce.cmo cdo2cmo/ml_ocaml.cmo \
cdo2cmo/ml_types.cmo
cdo2cmo/ml_generator.cmx: misc/q_symbol.cmo cdo2cmo/ml_cduce.cmx cdo2cmo/ml_ocaml.cmx \
cdo2cmo/ml_types.cmx
driver/cduce.cmo: misc/q_symbol.cmo parser/ast.cmo types/builtin.cmi compile/compile.cmi \
misc/encodings.cmi runtime/eval.cmi runtime/explain.cmi types/ident.cmo \
driver/librarian.cmi parser/location.cmi misc/ns.cmi parser/parser.cmi \
types/patterns.cmi types/sample.cmi schema/schema_common.cmi \
misc/state.cmi typing/typer.cmi types/types.cmi parser/ulexer.cmi \
runtime/value.cmi driver/cduce.cmi
driver/librarian.cmi parser/location.cmi cdo2cmo/ml_cduce.cmo \
cdo2cmo/ml_checker.cmo cdo2cmo/ml_generator.cmo cdo2cmo/ml_ocaml.cmo \
misc/ns.cmi parser/parser.cmi types/patterns.cmi types/sample.cmi \
schema/schema_common.cmi misc/state.cmi typing/typer.cmi types/types.cmi \
parser/ulexer.cmi runtime/value.cmi driver/cduce.cmi
driver/cduce.cmx: misc/q_symbol.cmo parser/ast.cmx types/builtin.cmx compile/compile.cmx \
misc/encodings.cmx runtime/eval.cmx runtime/explain.cmx types/ident.cmx \
driver/librarian.cmx parser/location.cmx misc/ns.cmx parser/parser.cmx \
types/patterns.cmx types/sample.cmx schema/schema_common.cmx \
misc/state.cmx typing/typer.cmx types/types.cmx parser/ulexer.cmx \
runtime/value.cmx driver/cduce.cmi
driver/librarian.cmx parser/location.cmx cdo2cmo/ml_cduce.cmx \
cdo2cmo/ml_checker.cmx cdo2cmo/ml_generator.cmx cdo2cmo/ml_ocaml.cmx \
misc/ns.cmx parser/parser.cmx types/patterns.cmx types/sample.cmx \
schema/schema_common.cmx misc/state.cmx typing/typer.cmx types/types.cmx \
parser/ulexer.cmx runtime/value.cmx driver/cduce.cmi
query/query.cmo: misc/q_symbol.cmo parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \
types/chars.cmi types/ident.cmo types/intervals.cmi parser/location.cmi \
parser/parser.cmi types/types.cmi query/query.cmi
......@@ -244,10 +268,12 @@ query/query_parse.cmx: misc/q_symbol.cmo parser/ast.cmx types/atoms.cmx types/id
types/types.cmx
driver/run.cmo: misc/q_symbol.cmo driver/cduce.cmi types/ident.cmo driver/librarian.cmi \
runtime/load_xml.cmi parser/location.cmi types/sequence.cmi \
misc/state.cmi misc/stats.cmi parser/ulexer.cmi runtime/value.cmi
misc/state.cmi misc/stats.cmi parser/ulexer.cmi parser/url.cmi \
runtime/value.cmi
driver/run.cmx: misc/q_symbol.cmo driver/cduce.cmx types/ident.cmx driver/librarian.cmx \
runtime/load_xml.cmx parser/location.cmx types/sequence.cmx \
misc/state.cmx misc/stats.cmx parser/ulexer.cmx runtime/value.cmx
misc/state.cmx misc/stats.cmx parser/ulexer.cmx parser/url.cmx \
runtime/value.cmx
driver/webiface.cmo: misc/q_symbol.cmo driver/cduce.cmi driver/examples.cmo parser/location.cmi \
misc/state.cmi
driver/webiface.cmx: misc/q_symbol.cmo driver/cduce.cmx driver/examples.cmx parser/location.cmx \
......
......@@ -67,6 +67,7 @@ let find_obj id =
let save id out =
protect_op "Save compilation unit";
Lambda.Put.current_cu := id;
let cu = find id in
C.enter id;
let raw = Serialize.Put.run serialize cu in
......
......@@ -36,7 +36,8 @@ let sp = ref 0
let dump ppf =
Format.fprintf ppf "sp = %i frame = %i@." !sp !frame;
for i = 0 to !sp - 1 do
if i = !frame then Format.fprintf ppf "FRAME@.";
Format.fprintf ppf "[%i]: " i;
if i = !frame then Format.fprintf ppf "(FRAME)";
Format.fprintf ppf "%a@." Value.print !stack.(i)
done
......@@ -319,7 +320,6 @@ let eval =
| Let_funs funs -> eval_rec_funs funs
)
let comp_unit init code =
(* Save the stack so as to be able to run a loaded comp_unit
from the toplevel *)
......
......@@ -21,13 +21,14 @@ module CompUnit = struct
module Tbl = Inttbl
let pervasives = mk (U.mk "Pervasives")
let current = ref dummy_min
let close_serialize_ref = ref (fun () -> assert false)
let depend = Inttbl.create ()
let serialize t cu =
if cu != pervasives then Inttbl.add depend cu ();
if (cu != pervasives) && (cu != !current) then Inttbl.add depend cu ();
serialize t cu
let close_serialize () =
......@@ -38,7 +39,6 @@ module CompUnit = struct
let stack = ref []
let current = ref dummy_min
let enter i = stack := !current :: !stack; current := i
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment