Commit 322f1452 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2002-10-26 17:23:03 by cvscast] Empty log message

Original author: cvscast
Date: 2002-10-26 17:23:03+00:00
parent d7274dd9
......@@ -29,7 +29,7 @@ and texpr' =
(* Data constructors *)
| Cst of Types.const
| Pair of texpr * texpr
| RecordLitt of (Types.label * texpr) list
| RecordLitt of (Types.label, texpr) SortedMap.t
(* Data destructors *)
| Op of string * texpr list
......
......@@ -335,21 +335,18 @@ let rec expr { loc = loc; descr = d } =
let (fv,e) = expr e in
(fv, Typed.Dot (e,l))
| RecordLitt r ->
(* Note: quadratic check for non duplication of labels.
Should improve that to O(n log n) for dealing
with huge number of attributes ?
*)
let fv = ref Fv.empty in
let labs = ref [] in
let r = List.sort (fun (l1,_) (l2,_) -> compare l1 l2) r in
let r = List.map
(fun (l,e) ->
let (fv2,e) = expr e in
if (List.mem l !labs) then
raise_loc loc (MultipleLabel l);
labs := l :: !labs;
fv := Fv.union !fv fv2;
(l,e)
) r in
let (fv2,e) = expr e in fv := Fv.union !fv fv2; (l,e))
r in
let rec check = function
| (l1,_) :: (l2,_) :: _ when l1 = l2 ->
raise_loc loc (MultipleLabel l1)
| _ :: rem -> check rem
| _ -> () in
check r;
(!fv, Typed.RecordLitt r)
| Op (op,le) ->
let (fvs,ltes) = List.split (List.map expr le) in
......
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