Commit 762d1ce2 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2005-03-04 15:26:27 by afrisch] #builtins directive

Original author: afrisch
Date: 2005-03-04 15:26:28+00:00
parent 4ff87bac
...@@ -70,14 +70,15 @@ package: clean ...@@ -70,14 +70,15 @@ package: clean
#cvs_snapshot: #cvs_snapshot:
# $(MAKE) package VERSION=cvs`date +%Y%m%d` # $(MAKE) package VERSION=cvs`date +%Y%m%d`
MSTONE=2
cvs_snapshot: cvs_snapshot:
(cd /tmp; \ (cd /tmp; \
rm -Rf cduce; \ rm -Rf cduce; \
cvs -z3 -d ":pserver:anonymous@cvs.cduce.org:/cvsroot" co cduce; \ cvs -z3 -d ":pserver:anonymous@cvs.cduce.org:/cvsroot" co cduce; \
tar czf cduce-cvs.tar.gz cduce; \ tar czf cduce-cvs$(MSTONE).tar.gz cduce; \
rm -Rf cduce; \ rm -Rf cduce; \
scp cduce-cvs.tar.gz cduce@iris.ens.fr:public_html/download; \ scp cduce-cvs$(MSTONE).tar.gz cduce@iris.ens.fr:public_html/download; \
rm -f cduce-cvs.tar.gz) rm -f cduce-cvs$(MSTONE).tar.gz)
OCAML_STDLIBDIR := $(shell ocamlc -where) OCAML_STDLIBDIR := $(shell ocamlc -where)
.PHONY: .ocamlinit .PHONY: .ocamlinit
......
...@@ -265,6 +265,11 @@ let directive ppf tenv cenv = function ...@@ -265,6 +265,11 @@ let directive ppf tenv cenv = function
silent := true silent := true
| `Verbose -> | `Verbose ->
silent := false silent := false
| `Builtins ->
let b = Librarian.get_builtins () in
Format.fprintf ppf "Embedded OCaml value: ";
List.iter (fun s -> Format.fprintf ppf "%s " s) b;
Format.fprintf ppf "@."
let print_id_opt ppf = function let print_id_opt ppf = function
| None -> Format.fprintf ppf "-" | None -> Format.fprintf ppf "-"
......
...@@ -283,6 +283,10 @@ let static_externals = Hashtbl.create 17 ...@@ -283,6 +283,10 @@ let static_externals = Hashtbl.create 17
let register_static_external n v = let register_static_external n v =
Hashtbl.add static_externals n v Hashtbl.add static_externals n v
let get_builtins () =
List.sort Pervasives.compare
(Hashtbl.fold (fun n _ accu -> n::accu) static_externals [])
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;
......
...@@ -29,4 +29,4 @@ val stub_ml : (string -> Typer.t -> Compile.env -> ...@@ -29,4 +29,4 @@ val stub_ml : (string -> Typer.t -> Compile.env ->
stub_ml option * Types.t array) ref stub_ml option * Types.t array) ref
val register_static_external: string -> Value.t -> unit val register_static_external: string -> Value.t -> unit
val get_builtins: unit -> string list
...@@ -35,6 +35,7 @@ and toplevel_directive = ...@@ -35,6 +35,7 @@ and toplevel_directive =
| `Debug of debug_directive | `Debug of debug_directive
| `Verbose | `Verbose
| `Silent | `Silent
| `Builtins
] ]
......
...@@ -159,6 +159,7 @@ EXTEND ...@@ -159,6 +159,7 @@ EXTEND
| "#"; IDENT "dump_value"; e = expr -> [ mk loc (Directive (`Dump e)) ] | "#"; IDENT "dump_value"; e = expr -> [ mk loc (Directive (`Dump e)) ]
| "#"; IDENT "reinit_ns" -> [ mk loc (Directive `Reinit_ns) ] | "#"; IDENT "reinit_ns" -> [ mk loc (Directive `Reinit_ns) ]
| "#"; IDENT "help" -> [ mk loc (Directive `Help) ] | "#"; IDENT "help" -> [ mk loc (Directive `Help) ]
| "#"; IDENT "builtins" -> [ mk loc (Directive `Builtins) ]
| "include"; s = STRING2 -> | "include"; s = STRING2 ->
let s = let s =
if Filename.is_relative s if Filename.is_relative s
......
...@@ -374,6 +374,11 @@ the name of an OCaml unit (like <code>List</code>). Empty lines ...@@ -374,6 +374,11 @@ the name of an OCaml unit (like <code>List</code>). Empty lines
and lines starting with a sharp character are ignored. and lines starting with a sharp character are ignored.
</p> </p>
<p>
In a custom toplevel, the directive <code>#builtins</code> prints the name
of embedded OCaml values.
</p>
</box> </box>
<box title="Examples" link="examples"> <box title="Examples" link="examples">
......
...@@ -250,6 +250,11 @@ values and types with namespaces (see <local href="namespaces"/>). ...@@ -250,6 +250,11 @@ values and types with namespaces (see <local href="namespaces"/>).
Schema</local> documents). Schema</local> documents).
</p> </p>
<p>
The toplevel directive <code>#builtins</code> prints the name
of embedded OCaml values (see <local href="manual_interfacewithocaml"/>).
</p>
<p> <p>
The toplevel has no line editing facilities. The toplevel has no line editing facilities.
You can use an external wrapper such as You can use an external wrapper such as
......
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