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

[r2004-06-27 22:12:44 by afrisch] Reference dans un sens

Original author: afrisch
Date: 2004-06-27 22:12:44+00:00
parent 4aff96c1
...@@ -44,6 +44,7 @@ and typ_descr = function ...@@ -44,6 +44,7 @@ and typ_descr = function
| Abstract "char" -> Builtin_defs.char_latin1 | Abstract "char" -> Builtin_defs.char_latin1
| Abstract "string" -> Builtin_defs.string_latin1 | Abstract "string" -> Builtin_defs.string_latin1
| Builtin ("list", [t]) -> Types.descr (Sequence.star_node (typ t)) | Builtin ("list", [t]) -> Types.descr (Sequence.star_node (typ t))
| Builtin ("Pervasives.ref", [t]) -> Builtin_defs.ref_type (typ t)
| _ -> assert false | _ -> assert false
and pvariant = function and pvariant = function
...@@ -170,6 +171,8 @@ and to_cd_descr e = function ...@@ -170,6 +171,8 @@ and to_cd_descr e = function
| Builtin ("list",[t]) -> | Builtin ("list",[t]) ->
(* Value.sequence_rev (List.rev_map fun_t <...>) *) (* Value.sequence_rev (List.rev_map fun_t <...>) *)
<:expr< Value.sequence_rev (List.rev_map $lid:to_cd_fun t$ $e$) >> <:expr< Value.sequence_rev (List.rev_map $lid:to_cd_fun t$ $e$) >>
| Builtin ("Pervasives.ref",[t]) ->
failwith "to_cd: Reference. TODO"
| _ -> assert false | _ -> assert false
and tuple_to_cd tl vars = List.map2 (fun t id -> to_cd <:expr< $lid:id$ >> t) tl vars and tuple_to_cd tl vars = List.map2 (fun t id -> to_cd <:expr< $lid:id$ >> t) tl vars
...@@ -269,6 +272,11 @@ and to_ml_descr e = function ...@@ -269,6 +272,11 @@ and to_ml_descr e = function
| Builtin ("list",[t]) -> | Builtin ("list",[t]) ->
(* List.rev_map fun_t (Value.get_sequence_rev <...> *) (* List.rev_map fun_t (Value.get_sequence_rev <...> *)
<:expr< List.rev_map $lid:to_ml_fun t$ (Value.get_sequence_rev $e$) >> <:expr< List.rev_map $lid:to_ml_fun t$ (Value.get_sequence_rev $e$) >>
| Builtin ("Pervasives.ref",[t]) ->
(* ref t(Eval.eval_apply (Value.get_field <...> "get") Value.nil) *)
let e = <:expr< Value.get_field $e$ $label_ascii "get"$ >> in
let e = <:expr< Eval.eval_apply $e$ Value.nil >> in
<:expr< Pervasives.ref $to_ml e t$ >>
| _ -> assert false | _ -> assert false
and tuple_to_ml tl vars = List.map2 (fun t id -> to_ml <:expr< $lid:id$ >> t) tl vars and tuple_to_ml tl vars = List.map2 (fun t id -> to_ml <:expr< $lid:id$ >> t) tl vars
......
...@@ -78,7 +78,7 @@ let new_slot () = ...@@ -78,7 +78,7 @@ let new_slot () =
let builtins = let builtins =
List.fold_left (fun m x -> StringMap.add x () m) StringMap.empty List.fold_left (fun m x -> StringMap.add x () m) StringMap.empty
["list"] ["list"; "Pervasives.ref" ]
let rec unfold seen constrs ty = let rec unfold seen constrs ty =
try try
...@@ -155,7 +155,7 @@ let unsupported s = ...@@ -155,7 +155,7 @@ let unsupported s =
raise (Error (Printf.sprintf "Unsupport feature (%s) found in .cmi" s)) raise (Error (Printf.sprintf "Unsupport feature (%s) found in .cmi" s))
let read_cmi name = let read_cmi name =
Config.load_path := !Librarian.obj_path; Config.load_path := Config.standard_library :: !Librarian.obj_path;
let filename = Misc.find_in_path_uncap !Config.load_path (name ^ ".cmi") in let filename = Misc.find_in_path_uncap !Config.load_path (name ^ ".cmi") in
let sg = Env.read_signature name filename in let sg = Env.read_signature name filename in
ocaml_env := Env.add_signature sg Env.initial; ocaml_env := Env.add_signature sg Env.initial;
......
...@@ -574,3 +574,4 @@ let get_field v l = ...@@ -574,3 +574,4 @@ let get_field v l =
match v with match v with
| Record fields -> LabelMap.assoc l fields | Record fields -> LabelMap.assoc l fields
| _ -> raise Not_found | _ -> raise Not_found
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