Commit b022b026 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

tweaked the preliminary implementation of the javascript runtime.

parent 66da3217
configure.log
cduce
cduce_js_runtime.*
tests/js/*.js
*.o
*.cmo
*.cdo
......
......@@ -170,7 +170,7 @@ DIRS := $(DIRS_DEPEND) $(OCAMLIFACE)
# Objects to build
BASE_OBJECTS = \
OBJECTS = \
driver/cduce_config.cmo misc/stats.cmo misc/custom.cmo misc/encodings.cmo \
misc/upool.cmo misc/pretty.cmo misc/ns.cmo misc/imap.cmo misc/html.cmo misc/utils.cmo \
\
......@@ -201,8 +201,7 @@ parser/cduce_loc.cmo parser/cduce_url.cmo \
schema/schema_parser.cmo schema/schema_converter.cmo \
runtime/load_xml.cmo runtime/print_xml.cmo compile/operators.cmo types/builtin.cmo \
driver/librarian.cmo \
OBJECTS = $(BASE_OBJECTS) types/sample.cmo driver/cduce.cmo
types/sample.cmo driver/cduce.cmo
schema/schema_types.ml: schema/schema_types.mli
cp $^ $@
......@@ -285,7 +284,7 @@ ALL_OBJECTS = $(OBJECTS_NO_MLIFACE) \
tools/validate.cmo \
parser/cduce_curl.cmo \
parser/cduce_netclient.cmo \
runtime/cduce_expat.cmo runtime/cduce_pxp.cmo
runtime/cduce_expat.cmo runtime/cduce_pxp.cmo runtime/cduce_js.cmo
ALL_INTERFACES = schema/schema_types.mli
......@@ -319,7 +318,7 @@ dtd2cduce: tools/dtd2cduce.ml
@echo "Build $@"
$(HIDE)$(OCAMLFIND) $(CAML) -o $@ -package "$(PXP_PACK) netcgi2" -linkpkg $^
CDUCE_JS_RUNTIME = $(BASE_OBJECTS) driver/cduce_js_runtime.cmo
CDUCE_JS_RUNTIME = $(OBJECTS) runtime/cduce_js.cmo driver/cduce_js_runtime.cmo
cduce_js_runtime: $(CDUCE_JS_RUNTIME)
@echo "Build $@"
$(HIDE)$(CAMLC) -custom -linkpkg camlp4lib.cma $(INCLUDES) -o $@ $^ $(EXTRA_LINK_OPTS)
......@@ -334,7 +333,7 @@ cduce_js_runtime.bytecode:
#js_of_ocaml +nat.js +weak.js +toplevel.js cduce_js_runtime
.PHONY: compute_depend
.PHONY: compute_depend cduce_js_runtime.bytecode
compute_depend: $(DEPEND_OCAMLDEP)
@echo "Computing dependencies ..."
......
......@@ -288,16 +288,6 @@ driver/cduce.cmx : runtime/value.cmx parser/ulexer.cmx types/types.cmx \
compile/lambda.cmx types/ident.cmx runtime/eval.cmx compile/compile.cmx \
parser/cduce_loc.cmx types/builtin_defs.cmx types/builtin.cmx \
compile/auto_pat.cmx types/atoms.cmx parser/ast.cmx driver/cduce.cmi
runtime/system.cmo : runtime/value.cmi types/types.cmi types/sequence.cmi \
compile/operators.cmi types/ident.cmo parser/cduce_loc.cmi \
types/builtin_defs.cmi types/builtin.cmi types/atoms.cmi
runtime/system.cmx : runtime/value.cmx types/types.cmx types/sequence.cmx \
compile/operators.cmx types/ident.cmx parser/cduce_loc.cmx \
types/builtin_defs.cmx types/builtin.cmx types/atoms.cmx
query/query_aggregates.cmo : runtime/value.cmi types/sequence.cmi \
compile/operators.cmi types/intervals.cmi types/builtin_defs.cmi
query/query_aggregates.cmx : runtime/value.cmx types/sequence.cmx \
compile/operators.cmx types/intervals.cmx types/builtin_defs.cmx
parser/cduce_curl.cmo : runtime/value.cmi parser/cduce_url.cmi \
driver/cduce_config.cmi
parser/cduce_curl.cmx : runtime/value.cmx parser/cduce_url.cmx \
......@@ -327,9 +317,9 @@ driver/run.cmx : runtime/value.cmx parser/ulexer.cmx misc/stats.cmx \
driver/librarian.cmx types/ident.cmx misc/html.cmx parser/cduce_loc.cmx \
driver/cduce_config.cmx driver/cduce.cmx types/builtin.cmx
driver/cduce_js_runtime.cmo : driver/librarian.cmi types/ident.cmo \
parser/cduce_loc.cmi driver/cduce_config.cmi
parser/cduce_loc.cmi runtime/cduce_js.cmi driver/cduce_config.cmi
driver/cduce_js_runtime.cmx : driver/librarian.cmx types/ident.cmx \
parser/cduce_loc.cmx driver/cduce_config.cmx
parser/cduce_loc.cmx runtime/cduce_js.cmx driver/cduce_config.cmx
driver/start.cmo : driver/run.cmo
driver/start.cmx : driver/run.cmx
driver/examples.cmo :
......@@ -366,6 +356,8 @@ runtime/cduce_pxp.cmo : runtime/value.cmi schema/schema_xml.cmi \
runtime/cduce_pxp.cmx : runtime/value.cmx schema/schema_xml.cmx \
runtime/load_xml.cmx parser/cduce_url.cmx driver/cduce_config.cmx \
runtime/cduce_pxp.cmi
runtime/cduce_js.cmo : runtime/load_xml.cmi runtime/cduce_js.cmi
runtime/cduce_js.cmx : runtime/load_xml.cmx runtime/cduce_js.cmi
driver/cduce_config.cmi :
misc/stats.cmi :
misc/encodings.cmi : misc/custom.cmo
......@@ -444,6 +436,7 @@ runtime/cduce_pxp.cmi :
runtime/cduce_expat.cmi :
runtime/cduce_expat.cmi :
runtime/cduce_pxp.cmi :
runtime/cduce_js.cmi :
schema/schema_types.cmi : runtime/value.cmi misc/ns.cmi misc/encodings.cmi \
types/atoms.cmi
ocamliface/3.x/caml_cduce.cmo :
......
open Ident
let flush_to_console s =
Firebug.console ## log (Js.string s)
......@@ -8,25 +5,12 @@ let init () =
Sys_js.set_channel_flusher stdout flush_to_console;
Sys_js.set_channel_flusher stderr flush_to_console
let compile_run src =
let name =
Filename.chop_suffix (Filename.basename src) ".cd"
in
let name = U.mk_latin1 name in
Librarian.compile_run false name src
let load_run obj =
Cduce_loc.obj_path := (Filename.dirname obj)::!Cduce_loc.obj_path ;
let name =
Filename.chop_suffix (Filename.basename obj) ".cdo"
in
let name = U.mk_latin1 name in
Librarian.load_run name
let () =
print_int Marshal.header_size;
print_newline ();
flush stdout;
Cduce_config.init_all ();
load_run "/static/main.cdo"
try
init ();
Cduce_config.init_all ();
Cduce_js.use ();
Cduce.compile_run "/static/main.cd"
with
Invalid_argument "Function 'exit' not implemented" -> ()
let load_from_dom start_e end_e text_e id =
(* find the node in the current page with id *)
let elem = Dom_html.document ## getElementById (Js.string id) in
match Js.Opt.to_option elem with
None -> Value.failwith' ("No element with id " ^ id)
| Some elem ->
ignore (elem);
Value.failwith' "DOM Parsing Not implemented"
(* recursively:
if the current node is an element node,
call start_e tag (attribute,value) list
if the current node is a text node or a CDATA section
call text_e txt
in all cases
traverse the node recursively using firstChild/nextSibling
after the recursive calls, if the current node is an element node
call end_e tag
*)
(* return unit and in case of error, Value.failwith' "error message" *)
let use () =
Load_xml.xml_parser :=
load_from_dom Load_xml.start_element_handler
Load_xml.end_element_handler
Load_xml.text_handler
;
val use : unit -> unit
......@@ -5,4 +5,4 @@ let fact (n : Int) : Int =
let x = fact 24
let [] = print (string_of x)
let _ = load_xml "id:foo" (* raises an exception for now *)
This diff is collapsed.
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