Commit d74132fd authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2005-03-04 12:11:52 by afrisch] cduce_mktop

Original author: afrisch
Date: 2005-03-04 12:11:54+00:00
parent 95b3761f
version="%VER%"
requires="%REQ% camlp4.gramlib"
description="Runtime support for CDuce"
archive(byte)="cduce_lib.cma"
archive(native)="cduce_lib.cmxa"
include Makefile.conf include Makefile.conf
VERSION = 0.2.3b1 VERSION = 0.2.3b1
all: cduce dtd2cduce validate cdo2ml cduce_lib.cma all: cduce dtd2cduce cduce_validate cdo2ml mlcduce_wrapper cduce_lib.cma
ifeq ($(NATIVE),true) ifeq ($(NATIVE),true)
all: cduce_lib.cmxa all: cduce_lib.cmxa
endif endif
...@@ -87,16 +87,14 @@ install_bin: ...@@ -87,16 +87,14 @@ install_bin:
@echo "Install binaries" @echo "Install binaries"
$(HIDE)mkdir -p $(BINDIR) $(HIDE)mkdir -p $(BINDIR)
$(HIDE)$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \ $(HIDE)$(INSTALL) -m755 cduce$(EXE) dtd2cduce$(EXE) \
validate$(EXE) cdo2ml$(EXE) $(BINDIR)/ cduce_validate$(EXE) cdo2ml$(EXE) \
mlcduce_wrapper$(EXE) \
cduce_mktop $(BINDIR)/
install_lib: install_lib:
@echo "Build META" @echo "Build META"
$(HIDE)echo 'version="$(VERSION)"' > META $(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
$(HIDE)echo 'requires="$(PACKAGES) camlp4.gramlib"' >> META
$(HIDE)echo 'description="Runtime support for CDuce"' >> META
$(HIDE)echo 'archive(byte)="cduce_lib.cma"' >> META
$(HIDE)echo 'archive(native)="cduce_lib.cmxa"' >> META
$(HIDE)-$(OCAMLFIND) remove cduce $(HIDE)-$(OCAMLFIND) remove cduce
$(HIDE)-$(OCAMLFIND) install cduce META \ $(HIDE)-$(OCAMLFIND) install cduce META \
cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \ cduce_lib.cmi $(wildcard *.cma) $(wildcard *.cmxa) $(wildcard *.a) \
...@@ -104,9 +102,10 @@ install_lib: ...@@ -104,9 +102,10 @@ install_lib:
uninstall: uninstall:
rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \ rm -f $(BINDIR)/cduce$(EXE) $(BINDIR)/dtd2cduce$(EXE) \
$(BINDIR)/validate$(EXE) $(BINDIR)/cdo2ml$(EXE) $(BINDIR)/cduce_validate$(EXE) $(BINDIR)/cdo2ml$(EXE) \
$(BINDIR)/mlcduce_wrapper$(EXE) $(BINDIR)/cduce_mktop
rm -f $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 \ rm -f $(MANDIR)/man1/cduce.1 $(MANDIR)/man1/dtd2cduce.1 \
$(MANDIR)/man1/validate.1 $(MANDIR)/man1/cdo2ml.1 $(MANDIR)/man1/cduce_validate.1 $(MANDIR)/man1/cdo2ml.1
rm -Rf $(DOCDIR) rm -Rf $(DOCDIR)
ocamlfind remove cduce ocamlfind remove cduce
...@@ -114,7 +113,7 @@ help: ...@@ -114,7 +113,7 @@ help:
@echo "GOALS" @echo "GOALS"
@echo " cduce : compiles the CDuce command line interpreter" @echo " cduce : compiles the CDuce command line interpreter"
@echo " dtd2cduce : compiles the dtd2cduce tools" @echo " dtd2cduce : compiles the dtd2cduce tools"
@echo " validate : compiles the schema validation tool" @echo " cduce_validate : compiles the schema validation tool"
@echo " doc : build the documentation" @echo " doc : build the documentation"
@echo " all : build binaries and libraries" @echo " all : build binaries and libraries"
@echo " install : install binaries, man pages, documentation" @echo " install : install binaries, man pages, documentation"
...@@ -212,7 +211,8 @@ OBJECTS += $(CQL_OBJECTS) ...@@ -212,7 +211,8 @@ OBJECTS += $(CQL_OBJECTS)
VALIDATE_OBJECTS := $(shell for o in $(OBJECTS); do echo $$o; if [ "$$o" = "schema/schema_parser.cmo" ]; then exit 0; fi; done) # all objects until schema_parser.cmo VALIDATE_OBJECTS := $(shell for o in $(OBJECTS); do echo $$o; if [ "$$o" = "schema/schema_parser.cmo" ]; then exit 0; fi; done) # all objects until schema_parser.cmo
CDUCE = $(OBJECTS) $(CQL_OBJECTS_RUN) driver/run.cmo OBJECTS += $(CQL_OBJECTS_RUN) driver/run.cmo
CDUCE = $(OBJECTS) driver/start.cmo
DTD2CDUCE = tools/dtd2cduce.cmo DTD2CDUCE = tools/dtd2cduce.cmo
ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \ ALL_OBJECTS = $(OBJECTS) $(NEW_SCHEMA_OBJS) \
...@@ -255,10 +255,14 @@ dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION)) ...@@ -255,10 +255,14 @@ dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
@echo "Build $@" @echo "Build $@"
$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(HIDE)$(LINK) $(INCLUDES) -o $@ $^
validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION) cduce_validate: $(VALIDATE_OBJECTS:.cmo=.$(EXTENSION)) tools/validate.$(EXTENSION)
@echo "Build $@" @echo "Build $@"
$(HIDE)$(LINK) $(INCLUDES) -o $@ $^ $(HIDE)$(LINK) $(INCLUDES) -o $@ $^
mlcduce_wrapper: $(OBJECTS:.cmo=.$(EXTENSION)) ocamliface/mlcduce_wrapper.ml
@echo "Build $@"
$(HIDE)$(LINK) $(INCLUDES) -o $@ odyl.cma camlp4.cma pr_o.cmo $^ $(EXTRA_LINK_OPTS)
cdo2ml: ocamliface/cdo2ml.ml cdo2ml: ocamliface/cdo2ml.ml
@echo "Build $@" @echo "Build $@"
$(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 odyl.cma camlp4.cma pr_o.cmo $^ $(HIDE)ocamlc -o $@ -pp camlp4o -I +camlp4 odyl.cma camlp4.cma pr_o.cmo $^
...@@ -277,7 +281,7 @@ clean: ...@@ -277,7 +281,7 @@ clean:
rm -f `find . -name "*~"` rm -f `find . -name "*~"`
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ META
rm -f cduce$(EXE) ocamlprof.dump rm -f cduce$(EXE) ocamlprof.dump
rm -f dtd2cduce$(EXE) webiface$(EXE) validate$(EXE) cdo2ml$(EXE) evaluator$(EXE) rm -f dtd2cduce$(EXE) webiface$(EXE) cduce_validate$(EXE) cdo2ml$(EXE) evaluator$(EXE)
rm -Rf prepro package rm -Rf prepro package
rm -f web/www/*.html web/*~ rm -f web/www/*.html web/*~
rm -f web/*.cdo rm -f web/*.cdo
......
#!/bin/sh
TARG=$1
PRIMS=$2
if [ "${TARG}" = "" ] || [ "${PRIMS}" = "" ]; then
echo "Usage: cduce_mktop <target> <primitive file>"
exit 2
fi
exec ocamlfind ocamlc -package cduce -o $TARG -linkpkg -pp mlcduce_wrapper -impl $PRIMS
...@@ -83,10 +83,12 @@ and compile_aux env tail = function ...@@ -83,10 +83,12 @@ and compile_aux env tail = function
| Typed.Dot (e,l) -> Dot (compile env tail e, l) | Typed.Dot (e,l) -> Dot (compile env tail e, l)
| Typed.Try (e,brs) -> Try (compile env false e, compile_branches env tail brs) | Typed.Try (e,brs) -> Try (compile env false e, compile_branches env tail brs)
| Typed.Ref (e,t) -> Ref (compile env tail e, t) | Typed.Ref (e,t) -> Ref (compile env tail e, t)
| Typed.External (t,i) -> | Typed.External (t,`Ext i) ->
(match env.cu with (match env.cu with
| Some cu -> Var (External (cu,i)) | Some cu -> Var (External (cu,i))
| None -> failwith "Cannot compile externals in the toplevel") | None -> failwith "Cannot compile externals in the toplevel")
| Typed.External (t,`Builtin s) ->
Var (Builtin s)
| Typed.Op (op,_,args) -> | Typed.Op (op,_,args) ->
let rec aux = function let rec aux = function
| [arg] -> [ compile env tail arg ] | [arg] -> [ compile env tail arg ]
...@@ -110,7 +112,7 @@ and compile_abstr env a = ...@@ -110,7 +112,7 @@ and compile_abstr env a =
p::slots, p::slots,
succ nb_slots, succ nb_slots,
Env.add x (Env nb_slots) fun_env; Env.add x (Env nb_slots) fun_env;
| Global _ | Ext _ | External _ as p -> | Global _ | Ext _ | External _ | Builtin _ as p ->
slots, slots,
nb_slots, nb_slots,
Env.add x p fun_env Env.add x p fun_env
......
...@@ -6,6 +6,7 @@ type var_loc = ...@@ -6,6 +6,7 @@ type var_loc =
| Ext of Types.CompUnit.t * int (* If pos < 0, the first arg is the value *) | Ext of Types.CompUnit.t * int (* If pos < 0, the first arg is the value *)
| External of Types.CompUnit.t * int | External of Types.CompUnit.t * int
(* If pos < 0, the first arg is the value *) (* If pos < 0, the first arg is the value *)
| Builtin of string
| Global of int (* Only for the toplevel *) | Global of int (* Only for the toplevel *)
| Dummy | Dummy
...@@ -14,6 +15,7 @@ let print_var_loc ppf = function ...@@ -14,6 +15,7 @@ let print_var_loc ppf = function
| Env i -> Format.fprintf ppf "Env %i" i | Env i -> Format.fprintf ppf "Env %i" i
| Ext (cu,i) -> Format.fprintf ppf "Ext (_,%i)" i | Ext (cu,i) -> Format.fprintf ppf "Ext (_,%i)" i
| External (cu,i) -> Format.fprintf ppf "External (_,%i)" i | External (cu,i) -> Format.fprintf ppf "External (_,%i)" i
| Builtin s -> Format.fprintf ppf "Builtin (%s,_)" s
| Global i -> Format.fprintf ppf "Global %i" i | Global i -> Format.fprintf ppf "Global %i" i
| Dummy -> Format.fprintf ppf "Dummy" | Dummy -> Format.fprintf ppf "Dummy"
...@@ -123,14 +125,18 @@ module Put = struct ...@@ -123,14 +125,18 @@ module Put = struct
Types.CompUnit.serialize s cu; Types.CompUnit.serialize s cu;
int s i int s i
| External (cu,i) -> | External (cu,i) ->
assert (i >= 0);
bits 3 s 2; bits 3 s 2;
Types.CompUnit.serialize s cu; Types.CompUnit.serialize s cu;
int s i int s i
| Env i -> | Builtin b ->
bits 3 s 3; bits 3 s 3;
Serialize.Put.string s b
| Env i ->
bits 3 s 4;
int s i int s i
| Dummy -> | Dummy ->
bits 3 s 4 bits 3 s 5
| Global _ -> assert false | Global _ -> assert false
let rec expr s = function let rec expr s = function
...@@ -258,8 +264,11 @@ module Get = struct ...@@ -258,8 +264,11 @@ module Get = struct
let cu = Types.CompUnit.deserialize s in let cu = Types.CompUnit.deserialize s in
let pos = int s in let pos = int s in
External (cu,pos) External (cu,pos)
| 3 -> Env (int s) | 3 ->
| 4 -> Dummy let s = Serialize.Get.string s in
Builtin s
| 4 -> Env (int s)
| 5 -> Dummy
| _ -> assert false | _ -> assert false
let rec expr s = let rec expr s =
......
...@@ -6,6 +6,7 @@ type var_loc = ...@@ -6,6 +6,7 @@ type var_loc =
| Ext of Types.CompUnit.t * int (* If pos < 0, the first arg is the value *) | Ext of Types.CompUnit.t * int (* If pos < 0, the first arg is the value *)
| External of Types.CompUnit.t * int | External of Types.CompUnit.t * int
(* If pos < 0, the first arg is the value *) (* If pos < 0, the first arg is the value *)
| Builtin of string
| Global of int (* Only for the toplevel *) | Global of int (* Only for the toplevel *)
| Dummy | Dummy
......
...@@ -46,7 +46,7 @@ let register_cst op t v = ...@@ -46,7 +46,7 @@ let register_cst op t v =
let register_fun op dom codom eval = let register_fun op dom codom eval =
register_cst op register_cst op
(Types.arrow (Types.cons dom) (Types.cons codom)) (Types.arrow (Types.cons dom) (Types.cons codom))
(Value.Abstraction ([(dom,codom)],eval)) (Value.Abstraction (Some [(dom,codom)],eval))
let register_op op ?(expect=Types.any) typ eval = let register_op op ?(expect=Types.any) typ eval =
register_unary op register_unary op
......
...@@ -48,14 +48,14 @@ types/normal.cmo: types/normal.cmi ...@@ -48,14 +48,14 @@ types/normal.cmo: types/normal.cmi
types/normal.cmx: types/normal.cmi types/normal.cmx: types/normal.cmi
types/types.cmo: types/atoms.cmi misc/bool.cmi types/chars.cmi \ types/types.cmo: types/atoms.cmi misc/bool.cmi types/chars.cmi \
misc/custom.cmo misc/encodings.cmi types/ident.cmo types/intervals.cmi \ misc/custom.cmo misc/encodings.cmi types/ident.cmo types/intervals.cmi \
misc/inttbl.cmi types/normal.cmi misc/pool.cmi misc/pretty.cmi \ misc/inttbl.cmi types/normal.cmi misc/ns.cmi misc/pool.cmi \
misc/serialize.cmi types/sortedList.cmi misc/state.cmi misc/stats.cmi \ misc/pretty.cmi misc/serialize.cmi types/sortedList.cmi misc/state.cmi \
types/types.cmi misc/stats.cmi types/types.cmi
types/types.cmx: types/atoms.cmx misc/bool.cmx types/chars.cmx \ types/types.cmx: types/atoms.cmx misc/bool.cmx types/chars.cmx \
misc/custom.cmx misc/encodings.cmx types/ident.cmx types/intervals.cmx \ misc/custom.cmx misc/encodings.cmx types/ident.cmx types/intervals.cmx \
misc/inttbl.cmx types/normal.cmx misc/pool.cmx misc/pretty.cmx \ misc/inttbl.cmx types/normal.cmx misc/ns.cmx misc/pool.cmx \
misc/serialize.cmx types/sortedList.cmx misc/state.cmx misc/stats.cmx \ misc/pretty.cmx misc/serialize.cmx types/sortedList.cmx misc/state.cmx \
types/types.cmi misc/stats.cmx types/types.cmi
types/sample.cmo: types/atoms.cmi types/chars.cmi types/ident.cmo \ types/sample.cmo: types/atoms.cmi types/chars.cmi types/ident.cmo \
types/intervals.cmi types/types.cmi types/sample.cmi types/intervals.cmi types/types.cmi types/sample.cmi
types/sample.cmx: types/atoms.cmx types/chars.cmx types/ident.cmx \ types/sample.cmx: types/atoms.cmx types/chars.cmx types/ident.cmx \
...@@ -100,11 +100,11 @@ schema/schema_xml.cmo: misc/encodings.cmi parser/location.cmi misc/ns.cmi \ ...@@ -100,11 +100,11 @@ schema/schema_xml.cmo: misc/encodings.cmi parser/location.cmi misc/ns.cmi \
schema/schema_pcre.cmi parser/url.cmi schema/schema_xml.cmi schema/schema_pcre.cmi parser/url.cmi schema/schema_xml.cmi
schema/schema_xml.cmx: misc/encodings.cmx parser/location.cmx misc/ns.cmx \ schema/schema_xml.cmx: misc/encodings.cmx parser/location.cmx misc/ns.cmx \
schema/schema_pcre.cmx parser/url.cmx schema/schema_xml.cmi schema/schema_pcre.cmx parser/url.cmx schema/schema_xml.cmi
schema/schema_common.cmo: types/atoms.cmi misc/encodings.cmi \ schema/schema_common.cmo: types/atoms.cmi misc/encodings.cmi types/ident.cmo \
types/intervals.cmi misc/ns.cmi schema/schema_pcre.cmi \ types/intervals.cmi misc/ns.cmi schema/schema_pcre.cmi \
schema/schema_types.cmi schema/schema_xml.cmi types/types.cmi \ schema/schema_types.cmi schema/schema_xml.cmi types/types.cmi \
runtime/value.cmi schema/schema_common.cmi runtime/value.cmi schema/schema_common.cmi
schema/schema_common.cmx: types/atoms.cmx misc/encodings.cmx \ schema/schema_common.cmx: types/atoms.cmx misc/encodings.cmx types/ident.cmx \
types/intervals.cmx misc/ns.cmx schema/schema_pcre.cmx \ types/intervals.cmx misc/ns.cmx schema/schema_pcre.cmx \
schema/schema_types.cmx schema/schema_xml.cmx types/types.cmx \ schema/schema_types.cmx schema/schema_xml.cmx types/types.cmx \
runtime/value.cmx schema/schema_common.cmi runtime/value.cmx schema/schema_common.cmi
...@@ -135,11 +135,11 @@ schema/schema_parser.cmx: types/atoms.cmx misc/encodings.cmx misc/ns.cmx \ ...@@ -135,11 +135,11 @@ schema/schema_parser.cmx: types/atoms.cmx misc/encodings.cmx misc/ns.cmx \
parser/ulexer.cmo: parser/ulexer.cmi parser/ulexer.cmo: parser/ulexer.cmi
parser/ulexer.cmx: parser/ulexer.cmi parser/ulexer.cmx: parser/ulexer.cmi
parser/ast.cmo: types/builtin_defs.cmi types/chars.cmi types/ident.cmo \ parser/ast.cmo: types/builtin_defs.cmi types/chars.cmi types/ident.cmo \
types/intervals.cmi parser/location.cmi misc/ns.cmi \ types/intervals.cmi parser/location.cmi misc/ns.cmi types/sequence.cmi \
schema/schema_types.cmi types/sequence.cmi types/types.cmi types/types.cmi
parser/ast.cmx: types/builtin_defs.cmx types/chars.cmx types/ident.cmx \ parser/ast.cmx: types/builtin_defs.cmx types/chars.cmx types/ident.cmx \
types/intervals.cmx parser/location.cmx misc/ns.cmx \ types/intervals.cmx parser/location.cmx misc/ns.cmx types/sequence.cmx \
schema/schema_types.cmx types/sequence.cmx types/types.cmx types/types.cmx
parser/parser.cmo: parser/ast.cmo types/atoms.cmi types/chars.cmi \ parser/parser.cmo: parser/ast.cmo types/atoms.cmi types/chars.cmi \
misc/encodings.cmi types/ident.cmo types/intervals.cmi \ misc/encodings.cmi types/ident.cmo types/intervals.cmi \
parser/location.cmi misc/ns.cmi types/sequence.cmi types/types.cmi \ parser/location.cmi misc/ns.cmi types/sequence.cmi types/types.cmi \
...@@ -151,23 +151,25 @@ parser/parser.cmx: parser/ast.cmx types/atoms.cmx types/chars.cmx \ ...@@ -151,23 +151,25 @@ parser/parser.cmx: parser/ast.cmx types/atoms.cmx types/chars.cmx \
types/externals.cmo: parser/location.cmi types/externals.cmi types/externals.cmo: parser/location.cmi types/externals.cmi
types/externals.cmx: parser/location.cmx types/externals.cmi types/externals.cmx: parser/location.cmx types/externals.cmi
typing/typed.cmo: types/ident.cmo parser/location.cmi misc/ns.cmi \ typing/typed.cmo: types/ident.cmo parser/location.cmi misc/ns.cmi \
types/patterns.cmi schema/schema_types.cmi types/types.cmi types/patterns.cmi types/types.cmi
typing/typed.cmx: types/ident.cmx parser/location.cmx misc/ns.cmx \ typing/typed.cmx: types/ident.cmx parser/location.cmx misc/ns.cmx \
types/patterns.cmx schema/schema_types.cmx types/types.cmx types/patterns.cmx types/types.cmx
typing/typer.cmo: parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \ typing/typer.cmo: parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \
types/chars.cmi misc/encodings.cmi types/externals.cmi misc/html.cmi \ types/chars.cmi misc/encodings.cmi types/externals.cmi misc/html.cmi \
types/ident.cmo parser/location.cmi misc/ns.cmi types/patterns.cmi \ types/ident.cmo driver/librarian.cmi parser/location.cmi misc/ns.cmi \
schema/schema_builtin.cmi schema/schema_common.cmi \ types/patterns.cmi schema/schema_builtin.cmi schema/schema_common.cmi \
schema/schema_parser.cmi schema/schema_types.cmi schema/schema_xml.cmi \ schema/schema_parser.cmi schema/schema_types.cmi \
types/sequence.cmi misc/serialize.cmi misc/state.cmi typing/typed.cmo \ schema/schema_validator.cmi schema/schema_xml.cmi types/sequence.cmi \
types/types.cmi runtime/value.cmi typing/typer.cmi misc/serialize.cmi typing/typed.cmo types/types.cmi runtime/value.cmi \
typing/typer.cmi
typing/typer.cmx: parser/ast.cmx types/atoms.cmx types/builtin_defs.cmx \ typing/typer.cmx: parser/ast.cmx types/atoms.cmx types/builtin_defs.cmx \
types/chars.cmx misc/encodings.cmx types/externals.cmx misc/html.cmx \ types/chars.cmx misc/encodings.cmx types/externals.cmx misc/html.cmx \
types/ident.cmx parser/location.cmx misc/ns.cmx types/patterns.cmx \ types/ident.cmx driver/librarian.cmx parser/location.cmx misc/ns.cmx \
schema/schema_builtin.cmx schema/schema_common.cmx \ types/patterns.cmx schema/schema_builtin.cmx schema/schema_common.cmx \
schema/schema_parser.cmx schema/schema_types.cmx schema/schema_xml.cmx \ schema/schema_parser.cmx schema/schema_types.cmx \
types/sequence.cmx misc/serialize.cmx misc/state.cmx typing/typed.cmx \ schema/schema_validator.cmx schema/schema_xml.cmx types/sequence.cmx \
types/types.cmx runtime/value.cmx typing/typer.cmi misc/serialize.cmx typing/typed.cmx types/types.cmx runtime/value.cmx \
typing/typer.cmi
runtime/load_xml.cmo: types/atoms.cmi misc/encodings.cmi types/ident.cmo \ runtime/load_xml.cmo: types/atoms.cmi misc/encodings.cmi types/ident.cmo \
parser/location.cmi misc/ns.cmi parser/url.cmi runtime/value.cmi \ parser/location.cmi misc/ns.cmi parser/url.cmi runtime/value.cmi \
runtime/load_xml.cmi runtime/load_xml.cmi
...@@ -196,13 +198,11 @@ runtime/print_xml.cmx: types/atoms.cmx misc/encodings.cmx types/ident.cmx \ ...@@ -196,13 +198,11 @@ runtime/print_xml.cmx: types/atoms.cmx misc/encodings.cmx types/ident.cmx \
runtime/print_xml.cmi runtime/print_xml.cmi
runtime/eval.cmo: runtime/explain.cmi types/ident.cmo compile/lambda.cmi \ runtime/eval.cmo: runtime/explain.cmi types/ident.cmo compile/lambda.cmi \
misc/ns.cmi types/patterns.cmi runtime/run_dispatch.cmi \ misc/ns.cmi types/patterns.cmi runtime/run_dispatch.cmi \
schema/schema_common.cmi schema/schema_types.cmi \ schema/schema_common.cmi typing/typer.cmi types/types.cmi \
schema/schema_validator.cmi typing/typer.cmi types/types.cmi \
runtime/value.cmi runtime/eval.cmi runtime/value.cmi runtime/eval.cmi
runtime/eval.cmx: runtime/explain.cmx types/ident.cmx compile/lambda.cmx \ runtime/eval.cmx: runtime/explain.cmx types/ident.cmx compile/lambda.cmx \
misc/ns.cmx types/patterns.cmx runtime/run_dispatch.cmx \ misc/ns.cmx types/patterns.cmx runtime/run_dispatch.cmx \
schema/schema_common.cmx schema/schema_types.cmx \ schema/schema_common.cmx typing/typer.cmx types/types.cmx \
schema/schema_validator.cmx typing/typer.cmx types/types.cmx \
runtime/value.cmx runtime/eval.cmi runtime/value.cmx runtime/eval.cmi
compile/compile.cmo: parser/ast.cmo runtime/eval.cmi types/ident.cmo \ compile/compile.cmo: parser/ast.cmo runtime/eval.cmi types/ident.cmo \
compile/lambda.cmi parser/location.cmi types/patterns.cmi \ compile/lambda.cmi parser/location.cmi types/patterns.cmi \
...@@ -240,16 +240,14 @@ driver/cduce.cmo: parser/ast.cmo types/builtin.cmi types/builtin_defs.cmi \ ...@@ -240,16 +240,14 @@ driver/cduce.cmo: parser/ast.cmo types/builtin.cmi types/builtin_defs.cmi \
compile/compile.cmi misc/encodings.cmi runtime/eval.cmi \ compile/compile.cmi misc/encodings.cmi runtime/eval.cmi \
runtime/explain.cmi types/ident.cmo driver/librarian.cmi \ runtime/explain.cmi types/ident.cmo driver/librarian.cmi \
parser/location.cmi misc/ns.cmi compile/operators.cmi parser/parser.cmi \ parser/location.cmi misc/ns.cmi compile/operators.cmi parser/parser.cmi \
types/patterns.cmi types/sample.cmi schema/schema_common.cmi \ types/patterns.cmi types/sample.cmi misc/state.cmi typing/typer.cmi \
misc/state.cmi typing/typer.cmi types/types.cmi parser/ulexer.cmi \ types/types.cmi parser/ulexer.cmi runtime/value.cmi driver/cduce.cmi
runtime/value.cmi driver/cduce.cmi
driver/cduce.cmx: parser/ast.cmx types/builtin.cmx types/builtin_defs.cmx \ driver/cduce.cmx: parser/ast.cmx types/builtin.cmx types/builtin_defs.cmx \
compile/compile.cmx misc/encodings.cmx runtime/eval.cmx \ compile/compile.cmx misc/encodings.cmx runtime/eval.cmx \
runtime/explain.cmx types/ident.cmx driver/librarian.cmx \ runtime/explain.cmx types/ident.cmx driver/librarian.cmx \
parser/location.cmx misc/ns.cmx compile/operators.cmx parser/parser.cmx \ parser/location.cmx misc/ns.cmx compile/operators.cmx parser/parser.cmx \
types/patterns.cmx types/sample.cmx schema/schema_common.cmx \ types/patterns.cmx types/sample.cmx misc/state.cmx typing/typer.cmx \
misc/state.cmx typing/typer.cmx types/types.cmx parser/ulexer.cmx \ types/types.cmx parser/ulexer.cmx runtime/value.cmx driver/cduce.cmi
runtime/value.cmx driver/cduce.cmi
runtime/system.cmo: types/atoms.cmi types/builtin.cmi types/builtin_defs.cmi \ runtime/system.cmo: types/atoms.cmi types/builtin.cmi types/builtin_defs.cmi \
types/ident.cmo parser/location.cmi compile/operators.cmi \ types/ident.cmo parser/location.cmi compile/operators.cmi \
types/sequence.cmi types/types.cmi runtime/value.cmi types/sequence.cmi types/types.cmi runtime/value.cmi
...@@ -286,10 +284,10 @@ query/query_aggregates.cmx: types/builtin_defs.cmx types/intervals.cmx \ ...@@ -286,10 +284,10 @@ query/query_aggregates.cmx: types/builtin_defs.cmx types/intervals.cmx \
compile/operators.cmx types/sequence.cmx runtime/value.cmx compile/operators.cmx types/sequence.cmx runtime/value.cmx
query/query.cmo: parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \ query/query.cmo: parser/ast.cmo types/atoms.cmi types/builtin_defs.cmi \
types/chars.cmi types/ident.cmo types/intervals.cmi parser/location.cmi \ types/chars.cmi types/ident.cmo types/intervals.cmi parser/location.cmi \
parser/parser.cmi types/types.cmi query/query.cmi misc/ns.cmi parser/parser.cmi types/types.cmi query/query.cmi
query/query.cmx: parser/ast.cmx types/atoms.cmx types/builtin_defs.cmx \ query/query.cmx: parser/ast.cmx types/atoms.cmx types/builtin_defs.cmx \
types/chars.cmx types/ident.cmx types/intervals.cmx parser/location.cmx \ types/chars.cmx types/ident.cmx types/intervals.cmx parser/location.cmx \
parser/parser.cmx types/types.cmx query/query.cmi misc/ns.cmx parser/parser.cmx types/types.cmx query/query.cmi
query/query_parse.cmo: parser/ast.cmo types/atoms.cmi types/ident.cmo \ query/query_parse.cmo: parser/ast.cmo types/atoms.cmi types/ident.cmo \
parser/location.cmi parser/parser.cmi query/query.cmi types/sequence.cmi \ parser/location.cmi parser/parser.cmi query/query.cmi types/sequence.cmi \
types/types.cmi types/types.cmi
...@@ -376,7 +374,7 @@ schema/schema_pcre.cmi: misc/encodings.cmi ...@@ -376,7 +374,7 @@ schema/schema_pcre.cmi: misc/encodings.cmi
schema/schema_types.cmi: types/atoms.cmi misc/encodings.cmi misc/ns.cmi \ schema/schema_types.cmi: types/atoms.cmi misc/encodings.cmi misc/ns.cmi \
runtime/value.cmi runtime/value.cmi
schema/schema_xml.cmi: misc/encodings.cmi misc/ns.cmi schema/schema_xml.cmi: misc/encodings.cmi misc/ns.cmi
schema/schema_common.cmi: types/atoms.cmi misc/encodings.cmi \ schema/schema_common.cmi: types/atoms.cmi misc/encodings.cmi types/ident.cmo \
types/intervals.cmi misc/ns.cmi schema/schema_types.cmi types/types.cmi \ types/intervals.cmi misc/ns.cmi schema/schema_types.cmi types/types.cmi \
runtime/value.cmi runtime/value.cmi
schema/schema_builtin.cmi: misc/encodings.cmi misc/ns.cmi \ schema/schema_builtin.cmi: misc/encodings.cmi misc/ns.cmi \
...@@ -387,8 +385,8 @@ schema/schema_parser.cmi: schema/schema_types.cmi ...@@ -387,8 +385,8 @@ schema/schema_parser.cmi: schema/schema_types.cmi
parser/parser.cmi: parser/ast.cmo parser/parser.cmi: parser/ast.cmo
types/externals.cmi: types/types.cmi types/externals.cmi: types/types.cmi
typing/typer.cmi: parser/ast.cmo misc/custom.cmo types/ident.cmo \ typing/typer.cmi: parser/ast.cmo misc/custom.cmo types/ident.cmo \
parser/location.cmi misc/ns.cmi types/patterns.cmi \ parser/location.cmi misc/ns.cmi types/patterns.cmi typing/typed.cmo \
schema/schema_types.cmi typing/typed.cmo types/types.cmi types/types.cmi runtime/value.cmi
runtime/load_xml.cmi: parser/url.cmi runtime/value.cmi runtime/load_xml.cmi: parser/url.cmi runtime/value.cmi
runtime/run_dispatch.cmi: types/patterns.cmi runtime/value.cmi runtime/run_dispatch.cmi: types/patterns.cmi runtime/value.cmi
runtime/explain.cmi: types/types.cmi runtime/value.cmi runtime/explain.cmi: types/types.cmi runtime/value.cmi
...@@ -402,7 +400,7 @@ compile/operators.cmi: parser/location.cmi types/types.cmi runtime/value.cmi ...@@ -402,7 +400,7 @@ compile/operators.cmi: parser/location.cmi types/types.cmi runtime/value.cmi
types/builtin.cmi: typing/typer.cmi runtime/value.cmi types/builtin.cmi: typing/typer.cmi runtime/value.cmi
driver/librarian.cmi: compile/compile.cmi types/ident.cmo typing/typer.cmi \ driver/librarian.cmi: compile/compile.cmi types/ident.cmo typing/typer.cmi \
types/types.cmi runtime/value.cmi types/types.cmi runtime/value.cmi
driver/cduce.cmi: misc/encodings.cmi runtime/value.cmi driver/cduce.cmi: misc/ns.cmi runtime/value.cmi
ocamliface/mltypes.cmi: ocamliface/asttypes.cmo types/types.cmi ocamliface/mltypes.cmi: ocamliface/asttypes.cmo types/types.cmi
query/query.cmi: parser/ast.cmo query/query.cmi: parser/ast.cmo
ocamliface/mltypes.cmi: ocamliface/asttypes.cmo types/types.cmi ocamliface/mltypes.cmi: ocamliface/asttypes.cmo types/types.cmi
......
...@@ -182,7 +182,7 @@ let rec compile verbose name id src = ...@@ -182,7 +182,7 @@ let rec compile verbose name id src =
p p
in in
let stub,types = !stub_ml name ty_env c_env in let stub,types = !stub_ml name ty_env c_env in
let ext = Externals.nb () > 0 in let ext = Externals.has () in
let cu = mk (cu,types,ext) in let cu = mk (cu,types,ext) in
cu.stub <- stub; cu.stub <- stub;
C.Tbl.add tbl id cu; C.Tbl.add tbl id cu;
...@@ -279,16 +279,30 @@ let import_check id chk = ignore (load_check id chk) ...@@ -279,16 +279,30 @@ let import_check id chk = ignore (load_check id chk)
let import_and_run id = import id; run id let import_and_run id = import id; run id
let import_from_string id str dig dep = ignore (load_from_string id str dig dep) let import_from_string id str dig dep = ignore (load_from_string id str dig dep)
let static_externals = Hashtbl.create 17
let register_static_external n v =
print_endline ("Builtin " ^ n);
Hashtbl.add static_externals n v
let () = let () =
Typer.from_comp_unit := (fun cu -> (load cu).typing); Typer.from_comp_unit := (fun cu -> (load cu).typing);
Typer.has_comp_unit := has_obj; Typer.has_comp_unit := has_obj;
Typer.has_static_external := Hashtbl.mem static_externals;
Compile.from_comp_unit := (fun cu -> (load cu).compile); Compile.from_comp_unit := (fun cu -> (load cu).compile);
Eval.get_global := (fun cu i -> import_and_run cu; (load cu).vals.(i)); Eval.get_global := (fun cu i -> import_and_run cu; (load cu).vals.(i));
Eval.set_global := (fun cu i v -> import cu; (load cu).vals.(i) <- v); Eval.set_global := (fun cu i v -> import cu; (load cu).vals.(i) <- v);
Eval.get_external := (fun cu i -> (load cu).exts.(i)) Eval.get_external := (fun cu i -> (load cu).exts.(i));
Eval.get_builtin := Hashtbl.find static_externals
let set_externals cu a = (load cu).exts <- a let set_externals cu a = (load cu).exts <- a
let registered_types cu = (load cu).types let registered_types cu = (load cu).types
let pack_types typs =
Serialize.Put.run (Serialize.Put.array Types.serialize) typs
let unpack_types typs =
Serialize.Get.run (Serialize.Get.array Types.deserialize) typs
...@@ -27,3 +27,9 @@ val set_externals: Types.CompUnit.t -> Value.t array -> unit ...@@ -27,3 +27,9 @@ val set_externals: Types.CompUnit.t -> Value.t array -> unit
type stub_ml type stub_ml
val stub_ml : (string -> Typer.t -> Compile.env -> val stub_ml : (string -> Typer.t -> Compile.env ->
stub_ml option * Types.t array) ref stub_ml option * Types.t array) ref
val pack_types: Types.t array -> string
val unpack_types: string -> Types.t array
val register_static_external: string -> Value.t -> unit
...@@ -181,10 +181,11 @@ let save () = ...@@ -181,10 +181,11 @@ let save () =
| None -> () | None -> ()
let main () = let main () =
at_exit (fun () -> Stats.dump Format.std_formatter);
Location.set_viewport (Html.create false); Location.set_viewport (Html.create false);
match mode () with match mode () with
| `Toplevel args -> | `Toplevel args ->
Config.inhibit "ocaml"; (* Config.inhibit "ocaml"; *)
Config.init_all (); Config.init_all ();
Builtin.argv := argv args; Builtin.argv := argv args;
restore (); restore ();
...@@ -202,6 +203,4 @@ let main () = ...@@ -202,6 +203,4 @@ let main () =
Builtin.argv := argv args; Builtin.argv := argv args;
Cduce.run f Cduce.run f
let () =
at_exit (fun () -> Stats.dump Format.std_formatter);
main ()
let loc = (Lexing.dummy_pos, Lexing.dummy_pos)
let usage =
"Usage: mlcduce_wrapper <primitive file>
"
let err s = prerr_endline s; prerr_endline usage; exit 1
let () =
if Array.length Sys.argv != 2 then err "";