Browse Source

fixed duplicate closure creation

Nicolas Cannasse 9 years ago
parent
commit
d3430b9e50
1 changed files with 3 additions and 1 deletions
  1. 3 1
      genhl.ml

+ 3 - 1
genhl.ml

@@ -5888,12 +5888,14 @@ let write_c version ch (code:code) =
 
 
 	line "";
 	line "";
 	line "// Static data";
 	line "// Static data";
+	let used = Hashtbl.create 0 in
 	Array.iter (fun f ->
 	Array.iter (fun f ->
 		Array.iteri (fun i op ->
 		Array.iteri (fun i op ->
 			match op with
 			match op with
-			| OGetFunction (_,fid) ->
+			| OGetFunction (_,fid) when not (Hashtbl.mem used fid) ->
 				let args, t = tfuns.(fid) in
 				let args, t = tfuns.(fid) in
 				sexpr "static vclosure cl$%d = { %s, %s, 0 }" fid (type_value (HFun (args,t))) funnames.(fid);
 				sexpr "static vclosure cl$%d = { %s, %s, 0 }" fid (type_value (HFun (args,t))) funnames.(fid);
+				Hashtbl.add used fid ();
 			| _ ->
 			| _ ->
 				()
 				()
 		) f.code
 		) f.code