Browse Source

added optional arguments
tabs

Nicolas Cannasse 19 years ago
parent
commit
0903dd7bb5

+ 10 - 8
ast.ml

@@ -55,7 +55,7 @@ type keyword =
 	| Interface
 	| Untyped
 	| Cast
-	
+
 type binop =
 	| OpAdd
 	| OpMult
@@ -118,6 +118,7 @@ type token =
 	| Arrow
 	| IntInterval of string
 	| Macro of string
+	| Question
 
 type unop_flag =
 	| Prefix
@@ -127,18 +128,18 @@ type while_flag =
 	| NormalWhile
 	| DoWhile
 
-type type_path_normal = { 
+type type_path_normal = {
 	tpackage : string list;
 	tname : string;
 	tparams : type_path list;
 }
 
-and anonymous_field = 
+and anonymous_field =
 	| AFVar of type_path
 	| AFProp of type_path * string * string
-	| AFFun of (string * type_path) list * type_path
+	| AFFun of (string * bool * type_path) list * type_path
 
-and type_path = 
+and type_path =
 	| TPNormal of type_path_normal
 	| TPFunction of type_path list * type_path
 	| TPAnonymous of (string * anonymous_field * pos) list
@@ -146,7 +147,7 @@ and type_path =
 	| TPExtend of type_path_normal * (string * anonymous_field * pos) list
 
 type func = {
-	f_args : (string * type_path option) list;
+	f_args : (string * bool * type_path option) list;
 	f_type : type_path option;
 	f_expr : expr;
 }
@@ -257,7 +258,7 @@ let s_constant = function
 	| Ident s -> s
 	| Type s -> s
 	| Regexp (r,o) -> "~/" ^ r ^ "/"
-	
+
 let s_keyword = function
 	| Function -> "function"
 	| Class -> "class"
@@ -345,8 +346,9 @@ let s_token = function
 	| Arrow -> "->"
 	| IntInterval s -> s ^ "..."
 	| Macro s -> "#" ^ s
+	| Question -> "?"
 
-let unescape s = 
+let unescape s =
 	let b = Buffer.create 0 in
 	let rec loop esc i =
 		if i = String.length s then

+ 2 - 0
doc/CHANGES.txt

@@ -1,6 +1,8 @@
 2006-07-??: 1.03
 	haxedoc executable now part of the distribution
 	removed selectDB from the neko.db.Connection API
+	added optional parameters with selection
+	removed --no-flash-opt-args
 
 2006-06-08: 1.02
 	fixed stack overflow when recursive class <: recursive signature

+ 34 - 34
genjs.ml

@@ -34,13 +34,13 @@ let s_path = function
 	| ([],"@Main") -> "$Main"
 	| p -> Ast.s_type_path p
 
-let kwds = 
+let kwds =
 	let h = Hashtbl.create 0 in
 	List.iter (fun s -> Hashtbl.add h s ()) [
 		"abstract"; "as"; "boolean"; "break"; "byte"; "case"; "catch"; "char"; "class"; "continue"; "const";
 		"debugger"; "default"; "delete"; "do"; "double"; "else"; "enum"; "export"; "extends"; "false"; "final";
 		"finally"; "float"; "for"; "function"; "goto"; "if"; "implements"; "import"; "in"; "instanceof"; "int";
-        "interface"; "is"; "long"; "namespace"; "native"; "new"; "null"; "package"; "private"; "protected"; 
+        "interface"; "is"; "long"; "namespace"; "native"; "new"; "null"; "package"; "private"; "protected";
 		"public"; "return"; "short"; "static"; "super"; "switch"; "synchronized"; "this"; "throw"; "throws";
 		"transient"; "true"; "try"; "typeof"; "use"; "var"; "void"; "volatile"; "while"; "with"
 	];
@@ -50,11 +50,11 @@ let field s = if Hashtbl.mem kwds s then "[\"" ^ s ^ "\"]" else "." ^ s
 let ident s = if Hashtbl.mem kwds s then "$" ^ s else s
 
 let spr ctx s = Buffer.add_string ctx.buf s
-let print ctx = Printf.kprintf (fun s -> Buffer.add_string ctx.buf s)			
+let print ctx = Printf.kprintf (fun s -> Buffer.add_string ctx.buf s)
 
 let unsupported = Typer.error "This expression cannot be compiled to Javascript"
 
-let newline ctx = 
+let newline ctx =
 	match Buffer.nth ctx.buf (Buffer.length ctx.buf - 1) with
 	| '}' | '{' | ':' -> print ctx "\n%s" ctx.tabs
 	| _ -> print ctx ";\n%s" ctx.tabs
@@ -67,12 +67,12 @@ let rec concat ctx s f = function
 		spr ctx s;
 		concat ctx s f l
 
-let parent e = 
+let parent e =
 	match e.eexpr with
 	| TParenthesis _ -> e
 	| _ -> mk (TParenthesis e) e.etype e.epos
 
-let block e = 
+let block e =
 	match e.eexpr with
 	| TBlock (_ :: _) -> e
 	| _ -> mk (TBlock [e]) e.etype e.epos
@@ -82,7 +82,7 @@ let open_block ctx =
 	ctx.tabs <- "\t" ^ ctx.tabs;
 	(fun() -> ctx.tabs <- oldt)
 
-let rec iter_switch_break in_switch e =	
+let rec iter_switch_break in_switch e =
 	match e.eexpr with
 	| TFunction _ | TWhile _ | TFor _ -> ()
 	| TSwitch _ | TMatch _ when not in_switch -> iter_switch_break true e
@@ -113,7 +113,7 @@ let this ctx = if ctx.in_value then "$this" else "this"
 let gen_constant ctx p = function
 	| TInt i -> print ctx "%ld" i
 	| TFloat s -> spr ctx s
-	| TString s -> 
+	| TString s ->
 		if String.contains s '\000' then Typer.error "A String cannot contain \\0 characters" p;
 		print ctx "\"%s\"" (Ast.s_escape s)
 	| TBool b -> spr ctx (if b then "true" else "false")
@@ -144,7 +144,7 @@ let rec gen_call ctx e el =
 		spr ctx (field s);
 		spr ctx "(";
 		concat ctx "," (gen_value ctx) el;
-		spr ctx ")"		
+		spr ctx ")"
 	| TLocal "__new__" , { eexpr = TConst (TString cl) } :: params ->
 		print ctx "new %s(" cl;
 		concat ctx "," (gen_value ctx) params;
@@ -169,7 +169,7 @@ and gen_expr ctx e =
 	| TLocal s -> spr ctx (ident s)
 	| TEnumField (e,s) ->
 		print ctx "%s%s" (s_path e.e_path) (field s)
-	| TArray (e1,e2) -> 
+	| TArray (e1,e2) ->
 		gen_value ctx e1;
 		spr ctx "[";
 		gen_value ctx e2;
@@ -185,13 +185,13 @@ and gen_expr ctx e =
 		gen_value ctx e2;
 	| TField (x,s) ->
 		(match follow e.etype with
-		| TFun _ -> 
+		| TFun _ ->
 			spr ctx "$closure(";
 			gen_value ctx x;
 			spr ctx ",";
 			gen_constant ctx e.epos (TString s);
 			spr ctx ")";
-		| _ -> 
+		| _ ->
 			gen_value ctx x;
 			spr ctx (field s))
 	| TType t ->
@@ -224,9 +224,9 @@ and gen_expr ctx e =
 		newline ctx;
 		print ctx "}";
 	| TFunction f ->
-		let old = ctx.in_value in 
+		let old = ctx.in_value in
 		ctx.in_value <- false;
-		print ctx "function(%s) " (String.concat "," (List.map ident (List.map fst f.tf_args)));
+		print ctx "function(%s) " (String.concat "," (List.map ident (List.map arg_name f.tf_args)));
 		gen_expr ctx (block f.tf_expr);
 		ctx.in_value <- old;
 	| TCall (e,el) ->
@@ -242,7 +242,7 @@ and gen_expr ctx e =
 		()
 	| TVars vl ->
 		spr ctx "var ";
-		concat ctx ", " (fun (n,_,e) -> 
+		concat ctx ", " (fun (n,_,e) ->
 			spr ctx (ident n);
 			match e with
 			| None -> ()
@@ -283,7 +283,7 @@ and gen_expr ctx e =
 		spr ctx "do ";
 		gen_expr ctx e;
 		spr ctx " while";
-		gen_value ctx (parent cond);		
+		gen_value ctx (parent cond);
 		handle_break();
 	| TObjectDecl fields ->
 		spr ctx "{ ";
@@ -329,8 +329,8 @@ and gen_expr ctx e =
 				None
 			) in
 			match t with
-			| None -> 
-				last := true; 
+			| None ->
+				last := true;
 				spr ctx "{";
 				let bend = open_block ctx in
 				newline ctx;
@@ -353,7 +353,7 @@ and gen_expr ctx e =
 				newline ctx;
 				spr ctx "} else "
 		) catchs;
-		if not !last then print ctx "throw($e%d)" id;		
+		if not !last then print ctx "throw($e%d)" id;
 		bend();
 		newline ctx;
 		spr ctx "}";
@@ -366,16 +366,16 @@ and gen_expr ctx e =
 		List.iter (fun (constr,params,e) ->
 			print ctx "case \"%s\":" constr;
 			newline ctx;
-			(match params with 
+			(match params with
 			| None | Some [] -> ()
-			| Some l -> 
+			| Some l ->
 				let n = ref 0 in
 				let l = List.fold_left (fun acc (v,_) -> incr n; match v with None -> acc | Some v -> (v,!n) :: acc) [] l in
 				match l with
 				| [] -> ()
 				| l ->
 					spr ctx "var ";
-					concat ctx ", " (fun (v,n) -> 
+					concat ctx ", " (fun (v,n) ->
 						print ctx "%s = $e[%d]" v n;
 					) l;
 					newline ctx);
@@ -391,7 +391,7 @@ and gen_expr ctx e =
 			print ctx "break";
 			newline ctx;
 		);
-		spr ctx "}"		
+		spr ctx "}"
 	| TSwitch (e,cases,def) ->
 		spr ctx "switch";
 		gen_value ctx (parent e);
@@ -434,12 +434,12 @@ and gen_value ctx e =
 			newline ctx;
 			b
 		end else
-			(fun() -> ()) 
+			(fun() -> ())
 		in
 		(fun() ->
 			if block then begin
 				newline ctx;
-				spr ctx "return $r";				
+				spr ctx "return $r";
 				b();
 				newline ctx;
 				spr ctx "}";
@@ -466,7 +466,7 @@ and gen_value ctx e =
 		gen_expr ctx e
 	| TReturn _
 	| TBreak
-	| TContinue ->		
+	| TContinue ->
 		unsupported e.epos
 	| TVars _
 	| TFor _
@@ -481,7 +481,7 @@ and gen_value ctx e =
 	| TBlock el ->
 		let v = value true in
 		let rec loop = function
-			| [] -> 
+			| [] ->
 				spr ctx "return null";
 			| [e] ->
 				gen_expr ctx (assign e);
@@ -491,7 +491,7 @@ and gen_value ctx e =
 				loop l
 		in
 		loop el;
-		v();	
+		v();
 	| TIf (cond,e,eo) ->
 		spr ctx "(";
 		gen_value ctx cond;
@@ -530,7 +530,7 @@ let generate_package_create ctx (p,_) =
 		| p :: l ->
 			Hashtbl.add ctx.packages (p :: acc) ();
 			(match acc with
-			| [] -> 
+			| [] ->
 				print ctx "%s = {}" p;
 			| _ ->
 				print ctx "%s%s = {}" (String.concat "." (List.rev acc)) (field p));
@@ -541,7 +541,7 @@ let generate_package_create ctx (p,_) =
 
 let gen_class_static_field ctx c f =
 	match f.cf_expr with
-	| None -> 
+	| None ->
 		print ctx "%s%s = null" (s_path c.cl_path) (field f.cf_name);
 		newline ctx
 	| Some e ->
@@ -563,7 +563,7 @@ let gen_class_field ctx c f =
 		gen_value ctx e;
 		newline ctx
 
-let generate_class ctx c = 
+let generate_class ctx c =
 	ctx.current <- c;
 	let p = s_path c.cl_path in
 	generate_package_create ctx c.cl_path;
@@ -579,7 +579,7 @@ let generate_class ctx c =
 		print ctx "%s.__construct__ = null" p;
 	);
 	newline ctx;
-	print ctx "%s.__name__ = [%s]" p (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" (Ast.s_escape s)) (fst c.cl_path @ [snd c.cl_path])));	
+	print ctx "%s.__name__ = [%s]" p (String.concat "," (List.map (fun s -> Printf.sprintf "\"%s\"" (Ast.s_escape s)) (fst c.cl_path @ [snd c.cl_path])));
 	newline ctx;
 	print ctx "%s.toString = $class_str" p;
 	newline ctx;
@@ -610,7 +610,7 @@ let generate_enum ctx e =
 		print ctx "%s%s = " p (field f.ef_name);
 		(match f.ef_type with
 		| TFun (args,_) ->
-			let sargs = String.concat "," (List.map fst args) in
+			let sargs = String.concat "," (List.map arg_name args) in
 			print ctx "function(%s) { var $x = [\"%s\",%s]; $x.__enum__ = %s; return $x; }" sargs f.ef_name sargs p;
 		| _ ->
 			print ctx "[\"%s\"]" f.ef_name;
@@ -658,7 +658,7 @@ let generate file types hres =
 	) hres;
 	print ctx "js.Boot.__init()";
 	newline ctx;
-	List.iter (fun e -> 
+	List.iter (fun e ->
 		gen_expr ctx e;
 		newline ctx;
 	) (List.rev ctx.inits);

+ 40 - 40
genneko.ml

@@ -34,10 +34,10 @@ let files = Hashtbl.create 0
 
 let pos p =
 	let file = (try
-		Hashtbl.find files p.pfile 
+		Hashtbl.find files p.pfile
 	with Not_found -> try
 		let len = String.length p.pfile in
-		let base = List.find (fun path -> 
+		let base = List.find (fun path ->
 			let l = String.length path in
 			len > l  && String.sub p.pfile 0 l = path
 		) (!Plugin.class_path) in
@@ -60,8 +60,8 @@ let add_local ctx v p =
 		| TLocal a ->
 			if flag && a = v then raise Exit
 		| TFunction f ->
-			if not (List.exists (fun (a,_) -> a = v) f.tf_args) then loop true f.tf_expr
-		| TVars l -> 
+			if not (List.exists (fun (a,_,_) -> a = v) f.tf_args) then loop true f.tf_expr
+		| TVars l ->
 			if List.exists (fun (a,_,_) -> a = v) l then raise Not_found;
 			Type.iter (loop flag) e
 		| TFor (a,e1,e2) ->
@@ -83,7 +83,7 @@ let add_local ctx v p =
 		| TTry (e,catchs) ->
 			loop flag e;
 			List.iter (fun (a,_,e) -> if a <> v then loop flag e) catchs
-		| _ -> 
+		| _ ->
 			Type.iter (loop flag) e
 	in
 	let isref = (try
@@ -134,7 +134,7 @@ let call p e el =
 	(ECall (e,el),p)
 
 let array p el =
-	call p (builtin p "array") el 
+	call p (builtin p "array") el
 
 let pmap_list f p =
 	PMap.fold (fun v acc -> f v :: acc) p []
@@ -147,7 +147,7 @@ let no_dollar t =
 
 let gen_type_path p (path,t) =
 	match path with
-	| [] -> 
+	| [] ->
 		ident p (no_dollar t)
 	| path :: l ->
 		let epath = List.fold_left (fun e path -> field p e path) (ident p path) l in
@@ -161,7 +161,7 @@ let gen_constant pe c =
 	| TString s -> call p (field p (ident p "String") "new") [str p s]
 	| TBool b -> (EConst (if b then True else False),p)
 	| TNull -> null p
-	| TThis -> this p 
+	| TThis -> this p
 	| TSuper -> assert false
 
 let rec gen_binop ctx p op e1 e2 =
@@ -173,7 +173,7 @@ let rec gen_binop ctx p op e1 e2 =
 	| OpPhysNotEq ->  (EBinop ("!=", call p (builtin p "pcompare") [gen_expr ctx e1; gen_expr ctx e2], int p 0),p)
 	| _ -> gen_op (Ast.s_binop op)
 
-and gen_unop ctx p op flag e =	
+and gen_unop ctx p op flag e =
 	match op with
 	| Increment -> (EBinop ((if flag = Prefix then "+=" else "++="), gen_expr ctx e , int p 1),p)
 	| Decrement -> (EBinop ((if flag = Prefix then "-=" else "--="), gen_expr ctx e , int p 1),p)
@@ -219,10 +219,10 @@ and gen_closure p t e f =
 				],p)),p)
 			),p)
 		] , p
-	| _ -> 
+	| _ ->
 		field p e f
 
-and gen_expr ctx e = 
+and gen_expr ctx e =
 	let p = pos e.epos in
 	match e.eexpr with
 	| TConst c ->
@@ -258,38 +258,38 @@ and gen_expr ctx e =
 	| TUnop (op,flag,e) ->
 		gen_unop ctx p op flag e
 	| TVars vl ->
-		(EVars (List.map (fun (v,_,e) -> 
+		(EVars (List.map (fun (v,_,e) ->
 			let isref = add_local ctx v p in
-			let e = (match e with 
-				| None -> 
-					if isref then 
+			let e = (match e with
+				| None ->
+					if isref then
 						Some (call p (builtin p "array") [null p])
 					else
-						None 
-				| Some e -> 
+						None
+				| Some e ->
 					let e = gen_expr ctx e in
 					if isref then
 						Some (call p (builtin p "array") [e])
 					else
 						Some e
-			) in	
+			) in
 			v , e
 		) vl),p)
 	| TFunction f ->
-		let b = block ctx [f.tf_expr] in		
-		let inits = List.fold_left (fun acc (a,_) -> 
-			if add_local ctx a p then 
+		let b = block ctx [f.tf_expr] in
+		let inits = List.fold_left (fun acc (a,_,_) ->
+			if add_local ctx a p then
 				(a, Some (call p (builtin p "array") [ident p a])) :: acc
 			else
 				acc
 		) [] f.tf_args in
 		let e = gen_expr ctx f.tf_expr in
 		let e = (match inits with [] -> e | _ -> (EBlock [(EVars (List.rev inits),p);e],p)) in
-		let e = (EFunction (List.map fst f.tf_args, e),p) in
+		let e = (EFunction (List.map arg_name f.tf_args, e),p) in
 		b();
 		e
 	| TBlock el ->
-		let b = block ctx el in		
+		let b = block ctx el in
 		let rec loop = function
 			| [] -> []
 			| e :: l ->
@@ -308,7 +308,7 @@ and gen_expr ctx e =
 		b();
 		let next = call p (field p (ident p "@tmp") "next") [] in
 		let next = (if isref then call p (builtin p "array") [next] else next) in
-		(EBlock 
+		(EBlock
 			[(EVars ["@tmp", Some it],p);
 			(EWhile (call p (field p (ident p "@tmp") "hasNext") [],
 				(EBlock [
@@ -316,7 +316,7 @@ and gen_expr ctx e =
 					e
 				],p)
 			,NormalWhile),p)]
-		,p)	
+		,p)
 	| TIf (cond,e1,e2) ->
 		(EIf (gen_expr ctx cond,gen_expr ctx e1,(match e2 with None -> None | Some e -> Some (gen_expr ctx e))),p)
 	| TWhile (econd,e,flag) ->
@@ -326,7 +326,7 @@ and gen_expr ctx e =
 			| [] -> call p (builtin p "rethrow") [ident p "@tmp"]
 			| (v,t,e) :: l ->
 				let e2 = loop l in
-				let path = (match follow t with 
+				let path = (match follow t with
 					| TInst (c,_) -> Some c.cl_path
 					| TEnum (e,_) -> Some e.e_path
 					| TDynamic _ -> None
@@ -376,8 +376,8 @@ and gen_expr ctx e =
 						| None -> gen_expr ctx e2
 						| Some el ->
 							let b = block ctx [e2] in
-							let vars = List.fold_left (fun acc (v,_) -> 								
-								incr count; 
+							let vars = List.fold_left (fun acc (v,_) ->
+								incr count;
 								match v with
 								| None ->
 									acc
@@ -409,7 +409,7 @@ and gen_expr ctx e =
 
 let gen_method ctx p c acc =
 	match c.cf_expr with
-	| None -> 
+	| None ->
 		(c.cf_name, null p) :: acc
 	| Some e ->
 		match e.eexpr with
@@ -418,7 +418,7 @@ let gen_method ctx p c acc =
 		| TFunction _ -> ((if c.cf_name = "new" then "__construct__" else c.cf_name), gen_expr ctx e) :: acc
 		| _ -> (c.cf_name, null p) :: acc
 
-let gen_class ctx c =	
+let gen_class ctx c =
 	let p = pos c.cl_pos in
 	let clpath = gen_type_path p (fst c.cl_path,"@" ^ snd c.cl_path) in
 	let stpath = gen_type_path p c.cl_path in
@@ -427,7 +427,7 @@ let gen_class ctx c =
 	| Some f ->
 		(match follow f.cf_type with
 		| TFun (args,_) ->
-			let params = List.map fst args in
+			let params = List.map arg_name args in
 			gen_method ctx p f ["new",(EFunction (params,(EBlock [
 				(EVars ["@o",Some (call p (builtin p "new") [null p])],p);
 				(call p (builtin p "objsetproto") [ident p "@o"; clpath]);
@@ -448,7 +448,7 @@ let gen_class ctx c =
 				EReturn (Some (field p (ident p "@s") "__s")),p;
 			],p)),p)]
 		| _ -> []
-	with Not_found -> 
+	with Not_found ->
 		[]
 	) in
 	let fserialize = "__serialize" , ident p "@serialize" in
@@ -472,13 +472,13 @@ let gen_class ctx c =
 		| [] , name -> [(EBinop ("=",field p (ident p "@classes") name,ident p (no_dollar name)),p)]
 		| _ -> []
 	in
-	(EBlock ([eclass; estat; call p (builtin p "objsetproto") [clpath; esuper]] @ emeta),p)	
+	(EBlock ([eclass; estat; call p (builtin p "objsetproto") [clpath; esuper]] @ emeta),p)
 
 let gen_enum_constr path c =
 	let p = pos c.ef_pos in
 	(EBinop ("=",field p path c.ef_name, match follow c.ef_type with
 		| TFun (params,_) ->
-			let params = List.map fst params in
+			let params = List.map arg_name params in
 			(EFunction (params,
 				(EBlock [
 					(EVars ["@tmp",Some (EObject [
@@ -515,7 +515,7 @@ let gen_enum e =
 
 let gen_type ctx t =
 	match t with
-	| TClassDecl c -> 
+	| TClassDecl c ->
 		(match c.cl_init with
 		| None -> ()
 		| Some e -> ctx.inits <- e :: ctx.inits);
@@ -523,7 +523,7 @@ let gen_type ctx t =
 			null (pos c.cl_pos)
 		else
 			gen_class ctx c
-	| TEnumDecl e -> 
+	| TEnumDecl e ->
 		if e.e_path = ([],"Bool") then
 			null (pos e.e_pos)
 		else
@@ -544,7 +544,7 @@ let gen_static_vars ctx t =
 				| Some e ->
 					match e.eexpr with
 					| TFunction _ -> acc
-					| _ -> 
+					| _ ->
 						let p = pos e.epos in
 						(EBinop ("=",
 							(field p (gen_type_path p c.cl_path) f.cf_name),
@@ -560,7 +560,7 @@ let gen_package h t =
 			let path = acc @ [x] in
 			if not (Hashtbl.mem h path) then begin
 				let p = pos (match t with TClassDecl c -> c.cl_pos | TEnumDecl e -> e.e_pos | TSignatureDecl s -> s.s_pos) in
-				let e = (EBinop ("=",gen_type_path p (acc,x),call p (builtin p "new") [null p]),p) in				
+				let e = (EBinop ("=",gen_type_path p (acc,x),call p (builtin p "new") [null p]),p) in
 				Hashtbl.add h path ();
 				(match acc with
 				| [] ->
@@ -589,7 +589,7 @@ let gen_name acc t =
 		let name = fst e.e_path @ [snd e.e_path] in
 		let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant e.e_pos (TString n)) name); int p (List.length name)] in
 		(EBinop ("=",field p (gen_type_path p e.e_path) "__ename__",arr),p) :: acc
-	| TClassDecl c -> 
+	| TClassDecl c ->
 		if c.cl_extern then
 			acc
 		else
@@ -597,7 +597,7 @@ let gen_name acc t =
 			let name = fst c.cl_path @ [snd c.cl_path] in
 			let interf = field p (gen_type_path p c.cl_path) "__interfaces__" in
 			let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant c.cl_pos (TString n)) name); int p (List.length name)] in
-			(EBinop ("=",field p (gen_type_path p c.cl_path) "__name__",arr),p) :: 
+			(EBinop ("=",field p (gen_type_path p c.cl_path) "__name__",arr),p) ::
 			(EBinop ("=",interf, call p (field p (ident p "Array") "new1") [interf; int p (List.length c.cl_implements)]),p) ::
 			acc
 	| TSignatureDecl _ ->

+ 4 - 3
genswf8.ml

@@ -392,7 +392,7 @@ let cfind flag cst e =
 	let rec loop2 e =
 		match e.eexpr with
 		| TFunction f ->
-			if not flag && not (List.exists (fun (a,_) -> a = vname) f.tf_args) then loop2 f.tf_expr
+			if not flag && not (List.exists (fun (a,_,_) -> a = vname) f.tf_args) then loop2 f.tf_expr
 		| TBlock _ ->
 			(try
 				iter loop2 e;
@@ -415,7 +415,7 @@ let cfind flag cst e =
 	let rec loop e =
 		match e.eexpr with
 		| TFunction f ->
-			if not (List.exists (fun (a,_) -> a = vname) f.tf_args) then loop2 f.tf_expr
+			if not (List.exists (fun (a,_,_) -> a = vname) f.tf_args) then loop2 f.tf_expr
 		| TBlock _ ->
 			(try
 				iter loop e;
@@ -975,7 +975,7 @@ and gen_expr_2 ctx retval e =
 		) ctx.regs PMap.empty;
 		ctx.reg_count <- (if reg_super then 2 else 1);
 		let pargs = ref [] in
-		let rargs = List.map (fun (a,t) ->
+		let rargs = List.map (fun (a,_,t) ->
 			let no_reg = ctx.version = 6 || cfind false (TLocal a) f.tf_expr in
 			if no_reg then begin
 				ctx.regs <- PMap.add a None ctx.regs;
@@ -1483,6 +1483,7 @@ let generate file ver header infile types hres =
 	f();
 	write ctx ASet;
 	List.iter (fun t -> gen_type_def ctx t) types;
+	ignore(gen_type ctx (["flash"],"Boot") (!extern_boot));
 	gen_type_map ctx;
 	gen_boot ctx hres;
 	List.iter (fun m -> gen_movieclip ctx m) ctx.movieclips;

+ 17 - 14
genxml.ml

@@ -19,7 +19,7 @@
 open Ast
 open Type
 
-type xml = 
+type xml =
 	| Node of string * (string * string) list * xml list
 	| PCData of string
 	| CData of string
@@ -30,42 +30,45 @@ let node name att childs = Node (name,att,childs)
 let pcdata s = PCData s
 let cdata s = CData s
 
-let pmap f m = 
+let pmap f m =
 	PMap.fold (fun x acc -> f x :: acc) m []
 
 let gen_path (p,n) priv =
 	("path",String.concat "." ((if n.[0] != '#' && priv then List.rev (List.tl (List.rev p)) else p) @ [n]))
 
-let gen_doc s = 
+let gen_doc s =
 	let f = if String.contains s '<' || String.contains s '>' || String.contains s '&' then	cdata else pcdata in
 	node "haxe:doc" [] [f s]
 
 let gen_doc_opt d =
-	match d with 
+	match d with
 	| None -> []
 	| Some s -> [gen_doc s]
 
+let gen_arg_name (name,opt,_) =
+	(if opt then "?" else "") ^ name
+
 let rec gen_type t =
 	match t with
 	| TMono m -> (match !m with None -> tag "unknown" | Some t -> gen_type t)
 	| TEnum (e,params) -> node "e" [gen_path e.e_path e.e_private] (List.map gen_type params)
 	| TInst (c,params) -> node "c" [gen_path c.cl_path c.cl_private] (List.map gen_type params)
 	| TSign (s,params) -> node "s" [gen_path s.s_path s.s_private] (List.map gen_type params)
-	| TFun (args,r) -> node "f" ["a",String.concat ":" (List.map fst args)] (List.map gen_type (List.map snd args @ [r]))
+	| TFun (args,r) -> node "f" ["a",String.concat ":" (List.map gen_arg_name args)] (List.map gen_type (List.map (fun (_,_,t) -> t) args @ [r]))
 	| TAnon fields -> node "a" [] (pmap (fun f -> node f.cf_name [] [gen_type f.cf_type]) fields)
 	| TDynamic t2 -> node "d" [] (if t == t2 then [] else [gen_type t2])
 	| TLazy f -> gen_type (!f())
 
 let gen_constr e =
 	let doc = gen_doc_opt e.ef_doc in
-	let args, t = (match follow e.ef_type with 
+	let args, t = (match follow e.ef_type with
 		| TFun (args,_) ->
-			["a",String.concat ":" (List.map fst args)] ,
-			List.map (fun (_,t) -> gen_type t) args @ doc
-		| _ -> 
+			["a",String.concat ":" (List.map gen_arg_name args)] ,
+			List.map (fun (_,_,t) -> gen_type t) args @ doc
+		| _ ->
 			[] , doc
 	) in
-	node e.ef_name args t 
+	node e.ef_name args t
 
 let gen_field att f =
 	let att = (match f.cf_expr with None -> att | Some e -> ("line",string_of_int (Lexer.get_error_line e.epos)) :: att) in
@@ -79,7 +82,7 @@ let gen_type_params priv path params pos m =
 let gen_type ctx t =
 	let m = Typer.module_of_type ctx t in
 	match t with
-	| TClassDecl c -> 
+	| TClassDecl c ->
 		let stats = pmap (gen_field ["static","1"]) c.cl_statics in
 		let fields = pmap (gen_field []) c.cl_fields in
 		let constr = (match c.cl_constructor with None -> [] | Some f -> [gen_field [] f]) in
@@ -93,14 +96,14 @@ let gen_type ctx t =
 		let t = gen_type s.s_type in
 		node "signature" (gen_type_params s.s_private s.s_path s.s_types s.s_pos m) (t :: doc)
 
-let att_str att = 
+let att_str att =
 	String.concat "" (List.map (fun (a,v) -> Printf.sprintf " %s=\"%s\"" a v) att)
 
 let rec write_xml ch tabs x =
 	match x with
-	| Node (name,att,[]) -> 
+	| Node (name,att,[]) ->
 		IO.printf ch "%s<%s%s/>" tabs name (att_str att)
-	| Node (name,att,[x]) -> 
+	| Node (name,att,[x]) ->
 		IO.printf ch "%s<%s%s>" tabs name (att_str att);
 		write_xml ch "" x;
 		IO.printf ch "</%s>" name;

+ 11 - 10
lexer.mll

@@ -45,12 +45,12 @@ let all_lines = Hashtbl.create 0
 let lines = ref []
 let buf = Buffer.create 100
 
-let error e pos = 
+let error e pos =
 	raise (Error (e,{ pmin = pos; pmax = pos; pfile = !cur_file }))
 
 let keywords =
 	let h = Hashtbl.create 3 in
-	List.iter (fun k -> Hashtbl.add h (s_keyword k) k) 
+	List.iter (fun k -> Hashtbl.add h (s_keyword k) k)
 		[Function;Class;Static;Var;If;Else;While;Do;For;
 		Break;Return;Continue;Extends;Implements;Import;
 		Switch;Case;Default;Public;Private;Try;Untyped;
@@ -72,7 +72,7 @@ let save() =
 let restore file =
 	save_lines();
 	cur_file := file;
-	lines := Hashtbl.find all_lines file 
+	lines := Hashtbl.find all_lines file
 
 let newline lexbuf =
 	lines :=  (lexeme_end lexbuf) :: !lines
@@ -111,7 +111,7 @@ let add c = Buffer.add_string buf c
 let mk_tok t pmin pmax =
 	t , { pfile = !cur_file; pmin = pmin; pmax = pmax }
 
-let mk lexbuf t = 
+let mk lexbuf t =
 	mk_tok t (lexeme_start lexbuf) (lexeme_end lexbuf)
 
 let mk_ident lexbuf =
@@ -130,7 +130,7 @@ let idtype = '_'* ['A'-'Z'] ['_' 'a'-'z' 'A'-'Z' '0'-'9']*
 rule token = parse
 	| eof { mk lexbuf Eof }
 	| "\239\187\191" { token lexbuf }
-	| [' ' '\t']+ { token lexbuf } 
+	| [' ' '\t']+ { token lexbuf }
 	| "\r\n" { newline lexbuf; token lexbuf }
 	| '\n' | '\r' { newline lexbuf; token lexbuf }
 	| "0x" ['0'-'9' 'a'-'f' 'A'-'F']+ { mk lexbuf (Const (Int (lexeme lexbuf))) }
@@ -139,7 +139,7 @@ rule token = parse
 	| '.' ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) }
 	| ['0'-'9']+ ['e' 'E'] ['+' '-']? ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) }
 	| ['0'-'9']+ '.' ['0'-'9']* ['e' 'E'] ['+' '-']? ['0'-'9']+ { mk lexbuf (Const (Float (lexeme lexbuf))) }
-	| ['0'-'9']+ "..." { 
+	| ['0'-'9']+ "..." {
 			let s = lexeme lexbuf in
 			mk lexbuf (IntInterval (String.sub s 0 (String.length s - 3)))
 		}
@@ -194,6 +194,7 @@ rule token = parse
 	| "}" { mk lexbuf BrClose }
 	| "(" { mk lexbuf POpen }
 	| ")" { mk lexbuf PClose }
+	| "?" { mk lexbuf Question }
 	| "/*" {
 			reset();
 			let pmin = lexeme_start lexbuf in
@@ -221,11 +222,11 @@ rule token = parse
 			let str = contents() in
 			mk_tok (Const (Regexp (str,options))) pmin pmax;
 		}
-	| '#' ident { 
+	| '#' ident {
 			let v = lexeme lexbuf in
 			let v = String.sub v 1 (String.length v - 1) in
-			mk lexbuf (Macro v) 
-		}	
+			mk lexbuf (Macro v)
+		}
 	| ident { mk_ident lexbuf }
 	| idtype { mk lexbuf (Const (Type (lexeme lexbuf))) }
 	| _ { invalid_char lexbuf }
@@ -264,7 +265,7 @@ and regexp = parse
 	| [^ '\\' '/' '\r' '\n']+ { store lexbuf; regexp lexbuf }
 
 and regexp_options = parse
-	| 'g' | 'i' | 'm' | 's' { 
+	| 'g' | 'i' | 'm' | 's' {
 			let l = lexeme lexbuf in
 			l ^ regexp_options lexbuf
 		}

+ 29 - 27
parser.ml

@@ -82,7 +82,7 @@ let rec make_binop op e ((v,p2) as e2) =
 	| _ ->
 		EBinop (op,e,e2) , punion (pos e) (pos e2)
 
-let rec make_unop op ((v,p2) as e) p1 = 
+let rec make_unop op ((v,p2) as e) p1 =
 	match v with
 	| EBinop (bop,e,e2) -> EBinop (bop, make_unop op e p1 , e2) , (punion p1 p2)
 	| _ ->
@@ -119,7 +119,7 @@ let property_ident = parser
 let log m s =
 	prerr_endline m
 
-let get_doc s = 
+let get_doc s =
 	let d = !doc in
 	doc := None;
 	d
@@ -132,22 +132,22 @@ let semicolon s =
 		match s with parser
 		| [< '(Semicolon,p) >] -> p
 		| [< >] -> snd (last_token s)
-	else 
+	else
 		match s with parser
 		| [< '(Semicolon,p) >] -> p
 		| [< s >] -> error Missing_semicolon (snd (last_token s))
 
-let rec	parse_file s = 
+let rec	parse_file s =
 	doc := None;
 	match s with parser
 	| [< '(Const (Ident "package"),_); p = parse_package; _ = semicolon; l = plist parse_type_decl; '(Eof,_); >] -> p , l
 	| [< l = plist parse_type_decl; '(Eof,_) >] -> [] , l
 
-and parse_type_decl s =	
+and parse_type_decl s =
 	match s with parser
 	| [< '(Kwd Import,p1); t = parse_type_path_normal; _ = semicolon >] -> (EImport (t.tpackage,t.tname), p1)
 	| [< c = parse_common_params; s >] ->
-		match s with parser 
+		match s with parser
 		| [< n , p1 = parse_enum_params; doc = get_doc; '(Const (Type name),_); tl = parse_type_params; '(BrOpen,_); l = plist parse_enum; '(BrClose,p2) >] -> (EEnum (name,doc,tl,List.map snd c @ n,l), punion p1 p2)
 		| [< n , p1 = parse_class_params; doc = get_doc; '(Const (Type name),_); tl = parse_type_params; hl = psep Comma parse_class_herit; '(BrOpen,_); fl = plist parse_class_field; '(BrClose,p2) >] -> (EClass (name,doc,tl,List.map fst c @ n @ hl,fl), punion p1 p2)
 		| [< '(Const (Ident "signature"),p1); doc = get_doc; '(Const (Type name),p2); tl = parse_type_params; s >] ->
@@ -215,7 +215,7 @@ and parse_type_path_next t = parser
 			TPFunction (t :: args,r)
 		| _ ->
 			TPFunction ([t] , t2))
-	| [< >] -> t 
+	| [< >] -> t
 
 and parse_type_anonymous_resume name = parser
 	| [< '(DblDot,p); t = parse_type_path; s >] ->
@@ -228,7 +228,7 @@ and parse_type_anonymous_resume name = parser
 and parse_type_anonymous = parser
 	| [< name = any_ident; '(DblDot,p); t = parse_type_path >] -> (name, AFVar t, p)
 
-and parse_enum s = 
+and parse_enum s =
 	doc := None;
 	match s with parser
 	| [< name = any_ident; doc = get_doc; s >] ->
@@ -256,7 +256,7 @@ and parse_class_field s =
 				| [< >] -> serror()
 				) in
 				(FVar (name,doc,l,t,e),punion p1 p2))
-		| [< '(Kwd Function,p1); name = parse_fun_name; pl = parse_type_params; '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] ->			
+		| [< '(Kwd Function,p1); name = parse_fun_name; pl = parse_type_params; '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; s >] ->
 			let e = (match s with parser
 				| [< e = expr >] -> e
 				| [< '(Semicolon,p) >] -> (EBlock [],p)
@@ -290,10 +290,12 @@ and parse_fun_name = parser
 	| [< '(Kwd New,_) >] -> "new"
 
 and parse_fun_param = parser
-	| [< name = any_ident; t = parse_type_opt >] -> (name,t)
+	| [< '(Question,_); name = any_ident; t = parse_type_opt >] -> (name,true,t)
+	| [< name = any_ident; t = parse_type_opt >] -> (name,false,t)
 
 and parse_fun_param_type = parser
-	| [< name = any_ident; '(DblDot,_); t = parse_type_path >] -> (name,t)
+	| [< '(Question,_); name = any_ident; '(DblDot,_); t = parse_type_path >] -> (name,true,t)
+	| [< name = any_ident; '(DblDot,_); t = parse_type_path >] -> (name,false,t)
 
 and parse_type_params = parser
 	| [< '(Binop OpLt,_); l = psep Comma parse_type_param; '(Binop OpGt,_) >] -> l
@@ -321,7 +323,7 @@ and block1 = parser
 and block2 name ident p = parser
 	| [< '(DblDot,_); e = expr; l = plist parse_obj_decl; _ = popt comma >] -> EObjectDecl ((name,e) :: l)
 	| [< e = expr_next (EConst (if ident then Ident name else Type name),p); s >] ->
-		try 
+		try
 			let _ = semicolon s in
 			let b = block s in
 			EBlock (e :: b)
@@ -331,7 +333,7 @@ and block2 name ident p = parser
 				EBlock (block s)
 
 and block s =
-	try 
+	try
 		let e = parse_block_elt s in
 		e :: block s
 	with
@@ -373,7 +375,7 @@ and expr = parser
 	| [< '(Kwd New,p1); t = parse_type_path_normal; '(POpen,_); al = psep Comma expr; '(PClose,p2); s >] -> expr_next (ENew (t,al),punion p1 p2) s
 	| [< '(POpen,p1); e = expr; '(PClose,p2); s >] -> expr_next (EParenthesis e, punion p1 p2) s
 	| [< '(BkOpen,p1); l = psep Comma expr; _ = popt comma; '(BkClose,p2); s >] -> expr_next (EArrayDecl l, punion p1 p2) s
-	| [< '(Kwd Function,p1); '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; e = expr; s >] -> 
+	| [< '(Kwd Function,p1); '(POpen,_); al = psep Comma parse_fun_param; '(PClose,_); t = parse_type_opt; e = expr; s >] ->
 		let f = {
 			f_type = t;
 			f_args = al;
@@ -387,7 +389,7 @@ and expr = parser
 	| [< '(Kwd If,p); '(POpen,_); cond = expr; '(PClose,_); e1 = expr; s >] ->
 		let e2 , s = (match s with parser
 			| [< '(Kwd Else,_); e2 = expr; s >] -> Some e2 , s
-			| [< >] -> 
+			| [< >] ->
 				match Stream.npeek 2 s with
 				| [(Semicolon,_);(Kwd Else,_)] ->
 					Stream.junk s;
@@ -410,7 +412,7 @@ and expr = parser
 	| [< '(Kwd Untyped,p1); e = expr >] -> (EUntyped e,punion p1 (pos e))
 
 and expr_next e1 = parser
-	| [< '(Dot,_); s >] -> 
+	| [< '(Dot,_); s >] ->
 		(match s with parser
 		| [< '(Const (Ident f),p); s >] -> expr_next (EField (e1,f) , punion (pos e1) p) s
 		| [< '(Const (Type t),p); s >] -> expr_next (EType (e1,t) , punion (pos e1) p) s
@@ -423,7 +425,7 @@ and expr_next e1 = parser
 		(match s with parser
 		| [< '(Binop OpGt,_); s >] ->
 			(match s with parser
-			| [< '(Binop OpGt,_) >] -> 
+			| [< '(Binop OpGt,_) >] ->
 				(match s with parser
 				| [< '(Binop OpAssign,_); e2 = expr >] -> make_binop (OpAssignOp OpUShr) e1 e2
 				| [< e2 = expr >] -> make_binop OpUShr e1 e2
@@ -445,7 +447,7 @@ and expr_next e1 = parser
 	| [< >] -> e1
 
 and parse_switch_cases = parser
-	| [< '(Kwd Default,p1); '(DblDot,_); e = block1; l , def = parse_switch_cases >] -> 
+	| [< '(Kwd Default,p1); '(DblDot,_); e = block1; l , def = parse_switch_cases >] ->
 		(match def with None -> () | Some (e,p) -> error Duplicate_default p);
 		l , Some (e , p1)
 	| [< '(Kwd Case,p1); e = expr; '(DblDot,_); b = block1; l , def = parse_switch_cases >] ->
@@ -465,7 +467,7 @@ let parse code file =
 	let mstack = ref [] in
 	cache := DynArray.create();
 	doc := None;
-	Lexer.init file;	
+	Lexer.init file;
 	let rec next_token() =
 		let tk = Lexer.token code in
 		match fst tk with
@@ -473,21 +475,21 @@ let parse code file =
 			let l = String.length s in
 			if l > 2 && s.[0] = '*' && s.[l-1] = '*' then doc := Some (String.sub s 1 (l-2));
 			next_token()
-		| CommentLine s -> 
+		| CommentLine s ->
 			next_token()
 		| Macro "end" ->
 			(match !mstack with
 			| [] -> serror()
-			| _ :: l -> 
+			| _ :: l ->
 				mstack := l;
 				next_token())
 		| Macro "else" ->
 			(match !mstack with
 			| [] -> serror()
-			| _ :: l -> 
+			| _ :: l ->
 				mstack := l;
 				skip_tokens false;
-				next_token())			
+				next_token())
 		| Macro "if" ->
 			enter_macro();
 			next_token()
@@ -501,10 +503,10 @@ let parse code file =
 			if Plugin.defined s then
 				mstack := p :: !mstack
 			else
-				skip_tokens true		
+				skip_tokens true
 		| _ ->
 			serror()
-	
+
 	and skip_tokens test =
 		let rec loop() =
 			let tk = Lexer.token code in
@@ -525,7 +527,7 @@ let parse code file =
 		in
 		loop()
 	in
-	let s = Stream.from (fun _ -> 
+	let s = Stream.from (fun _ ->
 		let t = next_token() in
 		DynArray.add (!cache) t;
 		Some t
@@ -538,7 +540,7 @@ let parse code file =
 		l
 	with
 		| Stream.Error _
-		| Stream.Failure -> 
+		| Stream.Failure ->
 			let last = (match Stream.peek s with None -> last_token s | Some t -> t) in
 			Lexer.restore old;
 			cache := old_cache;

+ 1 - 1
std/String.hx

@@ -52,7 +52,7 @@ extern class String {
 	function charAt( index : Int) : String;
 	function charCodeAt( index : Int) : Int;
 
-	function indexOf( value : String, startIndex : Int ) : Int;
+	function indexOf( value : String, ?startIndex : Int ) : Int;
 	function lastIndexOf( value : String, startIndex : Int ) : Int;
 	function split( delimiter : String ) : Array<String>;
 	function substr( pos : Int, len : Int ) : String;

+ 6 - 6
std/flash/Camera.hx

@@ -3,7 +3,7 @@ package flash;
 extern class Camera {
 
 	static var names(default,null) : Array<String>;
-	static function get( index : Int ) : Camera;
+	static function get( ?index : Int ) : Camera;
 
 	var bandwidth(default,null) : Int;
 
@@ -23,12 +23,12 @@ extern class Camera {
 
 	var quality(default,null) : Int;
 
-	function setMode(width:Int,height:Int,fps:Float,favorArea:Bool):Void;
-	function setMotionLevel(motionLevel:Float,timeOut:Float):Void;
-	function setQuality(bandwidth:Int,quality:Int):Void;
+	function setMode( width:Int, height:Int, ?fps:Float, ?favorArea:Bool ):Void;
+	function setMotionLevel( motionLevel:Float , ?timeOut:Float ):Void;
+	function setQuality( bandwidth:Int, quality:Int ):Void;
 
-	function onActivity(active:Bool):Void;
-	function onStatus(infoObject:Dynamic):Void;
+	function onActivity( active:Bool ):Void;
+	function onStatus( infoObject:Dynamic ):Void;
 
 	// ? not documented ?
 

+ 3 - 3
std/flash/Lib.hx

@@ -38,7 +38,7 @@ class Lib {
 		return untyped __eval__(str);
 	}
 
-	public static function getURL( url : String, target : String, post : Bool ) {
+	public static function getURL( url : String, ?target : String, ?post : Bool ) {
 		untyped if( post == null ) {
 			if( target == null )
 				__geturl__(url,"_self");
@@ -50,11 +50,11 @@ class Lib {
 			__geturl__(url,target,"GET");
 	}
 
-	public static function fscommand( cmd : String, param : Dynamic ) {
+	public static function fscommand( cmd : String, ?param : Dynamic ) {
 		untyped __geturl__("FSCommand:"+cmd,if( param == null ) "" else param);
 	}
 
-	public static function print( cmd : String, kind : String ) {
+	public static function print( cmd : String, ?kind : String ) {
 		kind = if (kind == "bframe" || kind == "bmax") "print:#"+kind else "print:";
 		untyped __geturl__(kind,cmd);
 	}

+ 2 - 2
std/flash/LoadVars.hx

@@ -15,8 +15,8 @@ implements Dynamic<String>
 	// don't allow : function addRequestHeader( headers : Array<String> ) : Void;
 
 	function load(url:String):Bool;
-	function send(url:String,target:String,method:String):Bool;
-	function sendAndLoad(url:String,targetObject:Dynamic,method:String):Bool;
+	function send(url:String,target:String,?method:String):Bool;
+	function sendAndLoad(url:String,targetObject:Dynamic,?method:String):Bool;
 	function getBytesLoaded():Int;
 	function getBytesTotal():Int;
 	function decode(queryString:String):Void;

+ 1 - 1
std/flash/LocalConnection.hx

@@ -9,7 +9,7 @@ implements Dynamic
 	function new() : Void;
 
 	function connect(connectionName:String):Bool;
-	function send(connectionName:String, methodName:String, p1 : Dynamic, p2 : Dynamic, p3 : Dynamic, p4 : Dynamic, p5 : Dynamic, p6 : Dynamic ):Bool;
+	function send(connectionName:String, methodName:String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic, ?p6 : Dynamic ):Bool;
 
 	function close():Void;
 	function domain():String;

+ 2 - 2
std/flash/Microphone.hx

@@ -4,7 +4,7 @@ extern class Microphone
 {
 
 	static var names(default,null) : Array<String>;
-	static function get(index:Int) : Microphone;
+	static function get(?index:Int) : Microphone;
 
 	var activityLevel(default,null) : Float;
 	var gain(default,null) : Float;
@@ -16,7 +16,7 @@ extern class Microphone
 	var rate(default,null) : Float;
 	var useEchoSuppression(default,null) : Bool;
 
-	function setSilenceLevel(silenceLevel:Int,timeOut:Float):Void;
+	function setSilenceLevel(silenceLevel:Int,?timeOut:Float):Void;
 	function setRate(rate:Float):Void;
 	function setGain(gain:Float):Void;
 	function setUseEchoSuppression(useEchoSuppression:Bool):Void;

+ 15 - 0
std/flash/Mouse.hx

@@ -1,11 +1,26 @@
 package flash;
 
+#if flash_strict
+signature MouseListener {
+	function onMouseDown() : Void;
+	function onMouseMove() : Void;
+	function onMouseUp() : Void;
+	function onMouseWheel( delta : Float, scrollTarget : String ) : Void;
+}
+#end
+
 extern class Mouse
 {
 	static function show():Int;
 	static function hide():Int;
+#if flash_strict
+	static function addListener(listener:MouseListener):Void;
+	static function removeListener(listener:MouseListener):Bool;
+#else true
 	static function addListener(listener:Dynamic):Void;
 	static function removeListener(listener:Dynamic):Bool;
+#end
+
 }
 
 

+ 26 - 12
std/flash/MovieClip.hx

@@ -39,18 +39,27 @@ implements Dynamic
 	var _url : String;
 	var _parent : MovieClip;
 
-	function getURL(url : String, window : String, method : String) : Void;
+	function getURL( url : String, ?window : String, ?method : String ) : Void;
 	function unloadMovie() : Void;
-	function loadVariables(url : String, method : String) : Void;
-	function loadMovie(url : String, method : String) : Void;
-	function attachMovie(id : String, name : String, depth : Int, initObject : Dynamic) : MovieClip;
+	function loadVariables( url : String, ?method : String ) : Void;
+	function loadMovie( url : String, ?method : String ) : Void;
+	function attachMovie(id : String, name : String, depth : Int, ?initObject : Dynamic) : MovieClip;
+
+	#if flash_strict
+	function swapDepths( depth : Int ) : Void;
+	#else true
 	function swapDepths(mc : Dynamic) : Void;
+	#end
 	// function swapDepths( mc : String ) : Void;
 	// function swapDepths( mc : MovieClip ) : Void;
 	// function swapDepths( depth : Int ) : Void;
+
 	function localToGlobal(pt : { x : Float, y : Float } ) : Void;
 	function globalToLocal(pt : { x : Float, y : Float } ) : Void;
-	function hitTest(x : Dynamic, y : Dynamic, shape : Bool) : Bool;
+
+	// optional param problem if called with a second Bool parameter
+	function hitTest( x_or_mc : Dynamic, ?y : Float, ?shape : Bool ) : Bool;
+
 	// function hitTest( x : Float, y : Float, shape : Bool ) : Bool;
 	// function hitTest( mc : MovieClip ) : Bool;
 	function getBounds(bounds  :  MovieClip) : { xMin : Float, xMax : Float, yMin : Float, yMax : Float };
@@ -72,15 +81,15 @@ implements Dynamic
 	// frame : String | Int
 	function gotoAndStop(frame : Dynamic) : Void;
 	// frame : String | Int
-	function duplicateMovieClip(name : String, depth : Int, initObject : Dynamic) : MovieClip;
+	function duplicateMovieClip(name : String, depth : Int, ?initObject : Dynamic) : MovieClip;
 	function removeMovieClip() : Void;
-	function startDrag(lockCenter : Bool, left : Float, top : Float, right : Float, bottom : Float) : Void;
+	function startDrag( lockCenter : Bool, ?left : Float, ?top : Float, ?right : Float, ?bottom : Float ) : Void;
 	function stopDrag() : Void;
 	function createEmptyMovieClip(name : String, depth : Int) : MovieClip;
-	function beginFill(rgb : Int, alpha : Float) : Void;
+	function beginFill(rgb : Int, ?alpha : Float) : Void;
 
 #if flash8
-	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<Float>, ratios : Array<Float>, matrix : Dynamic, spreadMethod : String, interpolationMethod : String, focalPointRatio : Float ) : Void;
+	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<Float>, ratios : Array<Float>, matrix : Dynamic, ?spreadMethod : String, ?interpolationMethod : String, ?focalPointRatio : Float ) : Void;
 #else true
 	function beginGradientFill(fillType : String, colors : Array<Int>, alphas : Array<Float>, ratios : Array<Float>, matrix : Dynamic) : Void;
 #end
@@ -90,9 +99,9 @@ implements Dynamic
 	function lineTo(x : Float, y : Float) : Void;
 	function curveTo(controlX : Float, controlY : Float, anchorX : Float, anchorY : Float) : Void;
 #if flash8
-	function lineStyle(thickness : Float, rgb : Int, alpha : Float, pixelHinting : Bool, noScale : String, capsStyle : String, jointStyle : String, miterLimit : Float) : Void;
+	function lineStyle(thickness : Float, rgb : Int, ?alpha : Float, ?pixelHinting : Bool, ?noScale : String, ?capsStyle : String, ?jointStyle : String, ?miterLimit : Float) : Void;
 #else true
-	function lineStyle(thickness : Float, rgb : Int, alpha : Float) : Void;
+	function lineStyle(thickness : Float, rgb : Int, ?alpha : Float) : Void;
 #end
 	function endFill() : Void;
 	function clear() : Void;
@@ -132,9 +141,14 @@ implements Dynamic
 	var scrollRect : Dynamic;
 	var transform : flash.geom.Transform;
 	var scale9Grid : flash.geom.Rectangle<Float>;
+
 	function getRect( bounds : MovieClip ) : { xMin : Float, yMin : Float, xMax : Float, yMax : Float };
 	// don't allow bounds : String
-	function attachBitmap( bmp : flash.display.BitmapData, depth : Int, pixelSnapping : String, smoothing : Bool ) : Void;
+
+
+	function attachBitmap( bmp : flash.display.BitmapData, depth : Int, ?pixelSnapping : String, ?smoothing : Bool ) : Void;
+	function beginBitmapFill( bmp : flash.display.BitmapData , ?matrix:flash.geom.Matrix, ?repeat:Bool, ?smoothing:Bool ) : Void;
+  	function lineGradientStyle( fillType:String, colors:Array<Int>, alphas:Array<Float>, ratios:Array<Float>, matrix:Dynamic, ?spreadMethod : String, ?interpolationMethod:String, ?focalPointRatio:Float ) : Void;
 #end
 
 }

+ 3 - 3
std/flash/NetConnection.hx

@@ -6,12 +6,12 @@ extern class NetConnection
 implements Dynamic
 #end
 {
-	var isConnected : Bool;
-	var uri : String;
+	var isConnected(default,null) : Bool;
+	var uri(default,null) : String;
 
 	function new() : Void;
 	function connect( targetURI : String ) : Bool;
-	function call( remoteMethod : String, resultObject : Dynamic, p1 : Dynamic, p2 : Dynamic, p3 : Dynamic, p4 : Dynamic, p5 : Dynamic, p6 : Dynamic) : Void;
+	function call( remoteMethod : String, resultObject : Dynamic, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic, ?p6 : Dynamic ) : Void;
 	function addHeader( header : String, mustUnderstand : Bool, object : Dynamic ) : Void;
 	function close() : Void;
 

+ 1 - 1
std/flash/NetStream.hx

@@ -19,7 +19,7 @@ extern class NetStream
 	function play( name : String, start : Float, len : Float, reset : Dynamic ) : Void;
 	function receiveAudio( flag : Bool ) : Void;
 	function receiveVideo( flag : Dynamic ) : Void;
-	function pause( flag : Bool ) : Void;
+	function pause( ?flag : Bool ) : Void;
 	function seek( offset : Float ) : Void;
 	function close() : Void;
 	function attachAudio( theMicrophone : Microphone ) : Void;

+ 1 - 1
std/flash/PrintJob.hx

@@ -4,7 +4,7 @@ extern class PrintJob
 {
 	function new() : Void;
 	function start():Bool;
-	function addPage(target:Dynamic, printArea:Dynamic, options:Dynamic, frameNum:Float):Bool;
+	function addPage(target:Dynamic, ?printArea:Dynamic, ?options:Dynamic, ?frameNum:Float):Bool;
 	function send():Void;
 
 	var paperWidth(default,null) : Float;

+ 7 - 2
std/flash/SharedObject.hx

@@ -2,13 +2,18 @@ package flash;
 
 extern class SharedObject
 {
-	static function getLocal(name:String,localPath:String):SharedObject;
+	#if flash8
+	static function getLocal(name:String,?localPath:String,?secure:Bool):SharedObject;
+	#else true
+	static function getLocal(name:String,?localPath:String):SharedObject;
+	#end
+
 	static function getRemote(name:String,remotePath:String,persistence:Dynamic):SharedObject;
 	static function deleteAll(url:String) : Void;
 	static function getDiskUsage(url:String) : Int;
 
 	function send(handlerName:String):Void;
-	function flush(minDiskSpace:Float):Dynamic;
+	function flush(?minDiskSpace:Float):Dynamic;
 	function close():Void;
 	function getSize():Float;
 	function setFps(updatesPerSecond:Float):Bool;

+ 2 - 2
std/flash/Sound.hx

@@ -18,9 +18,9 @@ extern class Sound
 	function setPan(value:Float):Void;
 	function setTransform(transformObject:Dynamic):Void;
 	function setVolume(value:Float):Void;
-	function stop(linkageID:String):Void;
+	function stop(?linkageID:String):Void;
 	function attachSound(id:String):Void;
-	function start(secondOffset:Float, loops:Float):Void;
+	function start(?secondOffset:Float, ?loops:Float):Void;
 	function loadSound(url:String, isStreaming:Bool):Void;
 	function getBytesLoaded():Float;
 	function getBytesTotal():Float;

+ 1 - 1
std/flash/System.hx

@@ -4,7 +4,7 @@ extern class System
 {
 	static var useCodepage:Bool;
 	static var exactSettings:Bool;
-	static function showSettings(tabID:Float):Void;
+	static function showSettings(?tabID:Float):Void;
 	static function setClipboard(text:String):Void;
 	static function onStatus(infoObject:Dynamic):Void;
 }

+ 5 - 2
std/flash/TextField.hx

@@ -66,8 +66,11 @@ extern class TextField
 
 	function replaceText(beginIndex:Int,endIndex:Int,newText:String):Void;
 	function replaceSel(newText:String):Void;
-	function getTextFormat(beginIndex:Int,endIndex:Int):TextFormat;
-	function setTextFormat( begin : Dynamic, end : Dynamic, tf : TextFormat ):Void;
+	function getTextFormat(?beginIndex:Int,?endIndex:Int):TextFormat;
+
+	// wtf ?? optional first argument !
+	// if beginIndex and endIndex are null, does it works ?
+	function setTextFormat( begin : Dynamic, ?end : Dynamic, ?tf : TextFormat ):Void;
 	function removeTextField():Void;
 	function getNewTextFormat():TextFormat;
 	function setNewTextFormat(tf:TextFormat):Void;

+ 6 - 5
std/flash/TextFormat.hx

@@ -18,11 +18,12 @@ extern class TextFormat
 	var blockIndent:Float;
 	var tabStops:Array<Dynamic>;
 	var bullet:Bool;
-	function new(font:String,size:Float,textColor:Int,
-                    	bold:Bool,italic:Bool,underline:Bool,
-                    	url:String,window:String,align:String,
-                    	leftMargin:Float,rightMargin:Float,indent:Float,leading:Float) : Void;
-	function getTextExtent(text:String, width : Float):Dynamic;
+	function new( ?font:String, ?size:Float, ?textColor:Int,
+                  ?bold:Bool, ?italic:Bool, ?underline:Bool,
+                  ?url:String, ?window:String, ?align:String,
+                  ?leftMargin:Float, ?rightMargin:Float, ?indent:Float,
+                  ?leading:Float ) : Void;
+	function getTextExtent(text:String, ?width : Float) : Dynamic;
 }
 
 

+ 4 - 4
std/flash/TextSnapshot.hx

@@ -4,10 +4,10 @@ extern class TextSnapshot
 {
 	function findText(startIndex:Int, textToFind:String, caseSensitive:Bool):Float;
 	function getCount():Int;
-	function getSelected(start:Int, end:Int):Bool;
-	function getSelectedText(includeLineEndings:Bool):String;
-	function getText(start:Int, end:Int, includeLineEndings:Bool):String;
-	function hitTestTextNearPos(x:Float, y:Float, closeDist:Float):Float;
+	function getSelected(start:Int, ?end:Int):Bool;
+	function getSelectedText(?includeLineEndings:Bool):String;
+	function getText(start:Int, end:Int, ?includeLineEndings:Bool):String;
+	function hitTestTextNearPos(x:Float, y:Float, ?closeDist:Float):Float;
 	function setSelectColor(color:Int):Void;
 	function setSelected(start:Int, end:Int, select:Bool):Void;
 }

+ 10 - 10
std/flash/display/BitmapData.hx

@@ -12,7 +12,7 @@ extern class BitmapData {
 	var rectangle : Rectangle<Int>;
 	var transparent : Bool;
 
-	function new( width : Int, height : Int, transparent : Bool, fillcolor : Int ) : Void;
+	function new( width : Int, height : Int, ?transparent : Bool, ?fillcolor : Int ) : Void;
 
 	function getPixel( x : Int, y : Int ) : Int;
 	function setPixel( x : Int, y : Int, color : Int ) : Void;
@@ -20,20 +20,20 @@ extern class BitmapData {
 	function setPixel32( x : Int, y : Int, color : Int ) : Void;
 
 	function fillRect( r : Rectangle<Int>, color : Int ) : Void;
-	function copyPixels( src : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, alpha : BitmapData, alphaPos : Point<Int>, mergeAlpha : Bool ) : Void;
+	function copyPixels( src : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, ?alpha : BitmapData, ?alphaPos : Point<Int>, ?mergeAlpha : Bool ) : Void;
 	function applyFilter( source : BitmapData, sourceRect : Rectangle<Int>, dest : Point<Int>, filter : flash.filters.BitmapFilter ) : Int;
 	function scroll( dx : Int, dy : Int ) : Void;
-	function threshold( src : BitmapData , srcRect : Rectangle<Int>, dstPoint : Point<Int>, op : String, threshold : Int, color : Int, mask : Int, copy : Bool ) : Int;
-	function draw( source : Dynamic, matrix : flash.geom.Matrix, colortrans : flash.geom.ColorTransform, blendMode : Dynamic, clipRect : Rectangle<Int>, smooth : Bool) : Void;
-	function pixelDissolve( src : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, seed : Int, npixels : Int, fillColor : Int ) : Int;
+	function threshold( src : BitmapData , srcRect : Rectangle<Int>, dstPoint : Point<Int>, op : String, threshold : Int, ?color : Int, ?mask : Int, ?copy : Bool ) : Int;
+	function draw( source : Dynamic, ?matrix : flash.geom.Matrix, ?colortrans : flash.geom.ColorTransform, ?blendMode : Dynamic, ?clipRect : Rectangle<Int>, ?smooth : Bool) : Void;
+	function pixelDissolve( src : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, ?seed : Int, ?npixels : Int, ?fillColor : Int ) : Int;
 	function floodFill( x : Int, y : Int, color : Int ) : Void;
-	function getColorBoundsRect( mask : Int, color : Int, fillColor : Bool ) : Rectangle<Int>;
-	function perlinNoise( x : Int, y : Int, num : Int, seed : Int, stitch : Bool, noise : Bool, channels : Int, gray : Bool, offsets : Dynamic ) : Void;
+	function getColorBoundsRect( mask : Int, color : Int, ?fillColor : Bool ) : Rectangle<Int>;
+	function perlinNoise( x : Int, y : Int, num : Int, seed : Int, stitch : Bool, noise : Bool, ?channels : Int, ?gray : Bool, ?offsets : Dynamic ) : Void;
 	function colorTransform( r : Rectangle<Int>, trans : flash.geom.ColorTransform ) : Void;
-	function hitTest( firstPoint : Point<Int>, firstAlpha : Int, object : Dynamic, secondPoint : Point<Int>, secondAlpha : Int ) : Bool;
-	function paletteMap( source : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, reds : Array<Dynamic>, greens : Array<Dynamic>, blues : Array<Dynamic>, alphas : Array<Dynamic> ) : Void;
+	function hitTest( firstPoint : Point<Int>, firstAlpha : Int, object : Dynamic, ?secondPoint : Point<Int>, ?secondAlpha : Int ) : Bool;
+	function paletteMap( source : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, ?reds : Array<Dynamic>, ?greens : Array<Dynamic>, ?blues : Array<Dynamic>, ?alphas : Array<Dynamic> ) : Void;
 	function merge( src : BitmapData, srcRect : Rectangle<Int>, dst : Point<Int>, redMult : Int, greenMult : Int, blueMult : Int, alphaMult : Int ) : Void;
-	function noise( seed : Int, low : Int, high : Int, channels : Int, gray : Bool ) : Void;
+	function noise( seed : Int, ?low : Int, ?high : Int, ?channels : Int, ?gray : Bool ) : Void;
 	function copyChannel( source : BitmapData, sourceRect : Rectangle<Int>, dest : Point<Int>, sourceChannel : Int, destChannel : Int ) : Void;
 	function clone() : BitmapData;
 	function dispose() : Void;

+ 1 - 1
std/flash/external/ExternalInterface.hx

@@ -4,6 +4,6 @@ extern class ExternalInterface {
 
 	static var available : Bool;
 	static function addCallback( methodName : String, instance : Dynamic, method : Dynamic ) : Bool;
-	static var call : Dynamic;
+	static function call( methodName : String, ?p1 : Dynamic, ?p2 : Dynamic, ?p3 : Dynamic, ?p4 : Dynamic, ?p5 : Dynamic, ?p6 : Dynamic, ?p7 : Dynamic, ?p8 : Dynamic, ?p9 : Dynamic ) : Dynamic;
 
 }

+ 1 - 1
std/flash/filters/BevelFilter.hx

@@ -15,7 +15,7 @@ extern class BevelFilter extends BitmapFilter {
 	var angle : Float;
 	var distance : Float;
 
-	function new(distance : Float, angle : Float, highlightColor : Float, highlightAlpha : Float, shadowColor : Float, shadowAlpha : Float, blurX : Float, blurY : Float, strength : Float, quality : Float, type : String, knockout : Bool) : Void;
+	function new( ?distance : Float, ?angle : Float, ?highlightColor : Float, ?highlightAlpha : Float, ?shadowColor : Float, ?shadowAlpha : Float, ?blurX : Float, ?blurY : Float, ?strength : Float, ?quality : Float, ?type : String, ?knockout : Bool) : Void;
 	function clone() : BevelFilter;
 
 }

+ 1 - 1
std/flash/filters/BlurFilter.hx

@@ -6,7 +6,7 @@ extern class BlurFilter extends BitmapFilter {
 	var blurX : Float;
 	var blurY : Float;
 
-	function new( bx : Float, by : Float, qual : Float ) : Void;
+	function new( ?blurX : Float, ?blurY : Float, ?quality : Float ) : Void;
 	function clone() : BlurFilter;
 
 }

+ 1 - 1
std/flash/filters/ColorMatrixFilter.hx

@@ -4,7 +4,7 @@ extern class ColorMatrixFilter extends BitmapFilter {
 
 	var matrix : Array<Float>; // 20 Numbers
 
-	function new( matrix : Array<Float> ) : Void;
+	function new( ?matrix : Array<Float> ) : Void;
 	function clone() : ColorMatrixFilter;
 
 }

+ 1 - 1
std/flash/filters/ConvolutionFilter.hx

@@ -12,7 +12,7 @@ extern class ConvolutionFilter extends BitmapFilter {
 	var matrixX : Float;
 	var matrixY : Float;
 
-	function new(matrixX : Float, matrixY : Float, matrix : Array<Dynamic>, divisor : Float, bias : Float, preserveAlpha : Bool, clamp : Bool, color : Float, alpha : Float) : Void;
+	function new( ?matrixX : Float, ?matrixY : Float, ?matrix : Array<Dynamic>, ?divisor : Float, ?bias : Float, ?preserveAlpha : Bool, ?clamp : Bool, ?color : Float, ?alpha : Float) : Void;
 	function clone() : ConvolutionFilter;
 
 }

+ 1 - 1
std/flash/filters/DisplacementMapFilter.hx

@@ -12,7 +12,7 @@ extern class DisplacementMapFilter extends BitmapFilter {
 	var mapPoint : flash.geom.Point<Float>;
 	var mapBitmap : flash.display.BitmapData;
 
-	function new(mapBitmap : flash.display.BitmapData, mapPoint : flash.geom.Point<Float>, componentX : Float, componentY : Float, scaleX : Float, scaleY : Float, mode : String, color : Float, alpha : Float) : Void;
+	function new( ?mapBitmap : flash.display.BitmapData, ?mapPoint : flash.geom.Point<Float>, ?componentX : Float, ?componentY : Float, ?scaleX : Float, ?scaleY : Float, ?mode : String, ?color : Float, ?alpha : Float ) : Void;
 	function clone() : DisplacementMapFilter;
 
 }

+ 1 - 1
std/flash/filters/DropShadowFilter.hx

@@ -14,7 +14,7 @@ extern class DropShadowFilter extends BitmapFilter {
 	var angle : Float;
 	var distance : Float;
 
-	function new(distance : Float, angle : Float, color : Float, alpha : Float, blurX : Float, blurY : Float, strength : Float, quality : Float, inner : Bool, knockout : Bool, hideObject : Bool) : Void;
+	function new( ?distance : Float, ?angle : Float, ?color : Float, ?alpha : Float, ?blurX : Float, ?blurY : Float, ?strength : Float, ?quality : Float, ?inner : Bool, ?knockout : Bool, ?hideObject : Bool ) : Void;
 	function clone() : DropShadowFilter;
 
 }

+ 1 - 1
std/flash/filters/GlowFilter.hx

@@ -11,7 +11,7 @@ extern class GlowFilter extends BitmapFilter {
 	var alpha : Float;
 	var color : Float;
 
-	function new(color : Float, alpha : Float, blurX : Float, blurY : Float, strength : Float, quality : Float, inner : Bool, knockout : Bool) : Void;
+	function new( ?color : Float, ?alpha : Float, ?blurX : Float, ?blurY : Float, ?strength : Float, ?quality : Float, ?inner : Bool, ?knockout : Bool ) : Void;
 	function clone() : GlowFilter;
 
 }

+ 1 - 1
std/flash/filters/GradientBevelFilter.hx

@@ -14,7 +14,7 @@ extern class GradientBevelFilter extends BitmapFilter {
 	var angle : Float;
 	var distance : Float;
 
-	function new(distance : Float, angle : Float, colors : Array<Dynamic>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, blurX : Float, blurY : Float, strength : Float, quality : Float, type : String, knockout : Bool) : Void;
+	function new( ?distance : Float, ?angle : Float, ?colors : Array<Dynamic>, ?alphas : Array<Dynamic>, ?ratios : Array<Dynamic>, ?blurX : Float, ?blurY : Float, ?strength : Float, ?quality : Float, ?type : String, ?knockout : Bool ) : Void;
 	function clone() : GradientBevelFilter;
 
 }

+ 1 - 1
std/flash/filters/GradientGlowFilter.hx

@@ -14,7 +14,7 @@ extern class GradientGlowFilter extends BitmapFilter {
 	var angle : Float;
 	var distance : Float;
 
-	function new(distance : Float, angle : Float, colors : Array<Dynamic>, alphas : Array<Dynamic>, ratios : Array<Dynamic>, blurX : Float, blurY : Float, strength : Float, quality : Float, type : String, knockout : Bool) : Void;
+	function new( ?distance : Float, ?angle : Float, ?colors : Array<Dynamic>, ?alphas : Array<Dynamic>, ?ratios : Array<Dynamic>, ?blurX : Float, ?blurY : Float, ?strength : Float, ?quality : Float, ?type : String, ?knockout : Bool ) : Void;
 	function clone() : GradientGlowFilter;
 
 }

+ 1 - 1
std/flash/geom/ColorTransform.hx

@@ -12,7 +12,7 @@ extern class ColorTransform {
 	var redMultiplier : Float;
 	var alphaMultiplier : Float;
 
-	function new( rm : Float, gm : Float, bm : Float, am : Float, ro : Float, go : Float, bo : Float, ao : Float ) : Void;
+	function new( ?rm : Float, ?gm : Float, ?bm : Float, ?am : Float, ?ro : Float, ?go : Float, ?bo : Float, ?ao : Float ) : Void;
 	function toString() : String;
 	function concat( c : ColorTransform ) : Void;
 

+ 3 - 3
std/flash/geom/Matrix.hx

@@ -10,7 +10,7 @@ extern class Matrix {
 	var tx : Float;
 	var ty : Float;
 
-	function new(a : Float, b : Float, c : Float, d : Float, tx : Float, ty : Float) : Void;
+	function new( ?a : Float, ?b : Float, ?c : Float, ?d : Float, ?tx : Float, ?ty : Float) : Void;
 
 	function transformPoint( p : Point<Float> ) : Point<Float>;
 	function deltaTransformPoint( p : Point<Float> ) : Void; // does not apply translation
@@ -23,8 +23,8 @@ extern class Matrix {
 	function concat( m : Matrix ) : Void;
 	function clone() : Matrix;
 
-	function createGradientBox( width : Float, height : Float, rot : Float, tx : Float, ty : Float ) : Void;
-	function createBox( scalex : Float, scaley : Float, rot : Float, tx : Float, ty : Float ) : Void;
+	function createGradientBox( width : Float, height : Float, ?rot : Float, ?tx : Float, ?ty : Float ) : Void;
+	function createBox( scalex : Float, scaley : Float, ?rot : Float, ?tx : Float, ?ty : Float ) : Void;
 
 
 }

+ 2 - 2
std/flash/net/FileReference.hx

@@ -11,9 +11,9 @@ extern class FileReference {
 
 	function new() : Void;
 
-	function browse( typeList : Array<Dynamic> ) : Bool;
+	function browse( ?typeList : Array<Dynamic> ) : Bool;
 	function upload( url : String ) : Bool;
-	function download( url : String, defaultName : String ) : Bool;
+	function download( url : String, ?defaultName : String ) : Bool;
 	function cancel() : Void;
 
 	function addListener( listener : Dynamic ) : Void;

+ 1 - 1
std/flash/net/FileReferenceList.hx

@@ -6,7 +6,7 @@ extern class FileReferenceList {
 
 	function new() : Void;
 
-	function browse( typeList : Array<Dynamic> ) : Bool;
+	function browse( ?typeList : Array<Dynamic> ) : Bool;
 	function addListener( listener : Dynamic ) : Void;
 	function removeListener( listener : Dynamic ) : Bool;
 

+ 6 - 4
std/neko/NekoString__.hx

@@ -57,9 +57,9 @@ class NekoString__ implements String {
 		}
 	}
 
-	public function indexOf( str, pos ) {
+	public function indexOf( str, ?pos ) {
 		untyped {
-			var p = __dollar__sfind(this.__s,pos,str.__s);
+			var p = try __dollar__sfind(this.__s,if( pos == null ) 0 else pos,str.__s) catch( e : Dynamic ) null;
 			if( p == null )
 				return -1;
 			return p;
@@ -69,9 +69,11 @@ class NekoString__ implements String {
 	public function lastIndexOf( str, pos ) {
 		untyped {
 			var last = -1;
+			if( pos == null )
+				pos = 0;
 			while( true ) {
-				var p = __dollar__sfind(this.__s,last + 1,str.__s);
-				if( p == null )
+				var p = try __dollar__sfind(this.__s,last+1,str.__s) catch( e : Dynamic ) null;
+				if( p == null || p > pos )
 					return last;
 				last = p;
 			}

+ 37 - 31
type.ml

@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *)
- 
+
 type module_path = string list * string
 
 type field_access =
@@ -24,12 +24,12 @@ type field_access =
 	| NoAccess
 	| MethodAccess of string
 
-type t = 
+type t =
 	| TMono of t option ref
 	| TEnum of tenum * t list
 	| TInst of tclass * t list
 	| TSign of tsignature * t list
-	| TFun of (string * t) list * t
+	| TFun of (string * bool * t) list * t
 	| TAnon of (string, tclass_field) PMap.t
 	| TDynamic of t
 	| TLazy of (unit -> t) ref
@@ -44,7 +44,7 @@ and tconstant =
 	| TSuper
 
 and tfunc = {
-	tf_args : (string * t) list;
+	tf_args : (string * bool * t) list;
 	tf_type : t;
 	tf_expr : texpr;
 }
@@ -138,13 +138,13 @@ and tsignature = {
 	mutable s_type : t;
 }
 
-and module_type = 
+and module_type =
 	| TClassDecl of tclass
 	| TEnumDecl of tenum
 	| TSignatureDecl of tsignature
 
 type module_def = {
-	mpath : module_path;		
+	mpath : module_path;
 	mtypes : module_type list;
 	mutable mimports : module_def list;
 }
@@ -176,6 +176,8 @@ let mk_class path pos doc priv =
 
 let null_class = mk_class ([],"") Ast.null_pos None true
 
+let arg_name (name,_,_) = name
+
 let t_private = function
 	| TClassDecl c -> c.cl_private
 	| TEnumDecl e -> e.e_private
@@ -188,7 +190,7 @@ let t_path = function
 
 let print_context() = ref []
 
-let rec s_type ctx t = 
+let rec s_type ctx t =
 	match t with
 	| TMono r ->
 		(match !r with
@@ -203,15 +205,15 @@ let rec s_type ctx t =
 	| TFun ([],t) ->
 		"Void -> " ^ s_fun ctx t false
 	| TFun (l,t) ->
-		String.concat " -> " (List.map (fun (s,t) -> 
-			(if s = "" then "" else s ^ " : ") ^ s_fun ctx t true
+		String.concat " -> " (List.map (fun (s,b,t) ->
+			(if b then "?" else "") ^ (if s = "" then "" else s ^ " : ") ^ s_fun ctx t true
 		) l) ^ " -> " ^ s_fun ctx t false
 	| TAnon fl ->
 		let fl = PMap.fold (fun f acc -> (" " ^ f.cf_name ^ " : " ^ s_type ctx f.cf_type) :: acc) fl [] in
 		"{" ^ String.concat "," fl ^ " }"
 	| TDynamic t2 ->
 		"Dynamic" ^ s_type_params ctx (if t == t2 then [] else [t2])
-	| TLazy f ->		
+	| TLazy f ->
 		s_type ctx (!f())
 
 and s_fun ctx t void =
@@ -238,7 +240,7 @@ let rec link e a b =
 		else match t with
 		| TMono t -> (match !t with None -> false | Some t -> loop t)
 		| TEnum (_,tl) | TInst (_,tl) | TSign (_,tl) -> List.exists loop tl
-		| TFun (tl,t) -> List.exists (fun (_,t) -> loop t) tl || loop t
+		| TFun (tl,t) -> List.exists (fun (_,_,t) -> loop t) tl || loop t
 		| TDynamic t2 ->
 			if t == t2 then
 				false
@@ -295,7 +297,7 @@ let apply_params cparams params t =
 				t
 			| [TMono r] ->
 				(match !r with
-				| Some tt when t == tt -> 
+				| Some tt when t == tt ->
 					(* for dynamic *)
 					let pt = mk_mono() in
 					let t = TInst (c,[pt]) in
@@ -305,7 +307,7 @@ let apply_params cparams params t =
 			| _ ->
 				TInst (c,List.map loop tl))
 		| TFun (tl,r) ->
-			TFun (List.map (fun (s,t) -> s, loop t) tl,loop r)
+			TFun (List.map (fun (s,o,t) -> s, o, loop t) tl,loop r)
 		| TAnon fl ->
 			TAnon (PMap.map (fun f -> { f with cf_type = loop f.cf_type }) fl)
 		| TLazy f ->
@@ -344,10 +346,10 @@ let rec type_eq param a b =
 	| TSign (s,tl) , _ -> type_eq param (apply_params s.s_types tl s.s_type) b
 	| _ , TSign (s,tl) -> type_eq param a (apply_params s.s_types tl s.s_type)
 	| TEnum (a,tl1) , TEnum (b,tl2) -> a == b && List.for_all2 (type_eq param) tl1 tl2
-	| TInst (c1,tl1) , TInst (c2,tl2) -> 
+	| TInst (c1,tl1) , TInst (c2,tl2) ->
 		c1 == c2 && List.for_all2 (type_eq param) tl1 tl2
 	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
-		type_eq param r1 r2 && List.for_all2 (fun (_,t1) (_,t2) -> type_eq param t1 t2) l1 l2
+		type_eq param r1 r2 && List.for_all2 (fun (_,o1,t1) (_,o2,t2) -> o1 = o2 && type_eq param t1 t2) l1 l2
 	| TDynamic a , TDynamic b ->
 		type_eq param a b
 	| TAnon fl1, TAnon fl2 ->
@@ -375,6 +377,7 @@ type unify_error =
 	| Has_no_field of t * string
 	| Invalid_access of string * bool
 	| Invalid_visibility of string
+	| Not_matching_optional
 
 exception Unify_error of unify_error list
 
@@ -401,31 +404,31 @@ let rec unify a b =
 	else match a, b with
 	| TLazy f , _ -> unify (!f()) b
 	| _ , TLazy f -> unify a (!f())
-	| TMono t , _ -> 
-		(match !t with 
-		| None -> if not (link t a b) then error [cannot_unify a b] 
+	| TMono t , _ ->
+		(match !t with
+		| None -> if not (link t a b) then error [cannot_unify a b]
 		| Some t -> unify t b)
-	| _ , TMono t -> 
+	| _ , TMono t ->
 		(match !t with
 		| None -> if not (link t b a) then error [cannot_unify a b]
 		| Some t -> unify a t)
 	| TSign (s,tl) , _ ->
-		(try 
+		(try
 			unify (apply_params s.s_types tl s.s_type) b
-		with 
+		with
 			Unify_error l -> error (cannot_unify a b :: l))
 	| _ , TSign (s,tl) ->
 		if not (List.exists (fun (a2,s2) -> a == a2 && s == s2) (!unify_stack)) then begin
-			try 
+			try
 				unify_stack := (a,s) :: !unify_stack;
 				unify a (apply_params s.s_types tl s.s_type);
 				unify_stack := List.tl !unify_stack;
-			with 
+			with
 				Unify_error l ->
 					unify_stack := List.tl !unify_stack;
 					error (cannot_unify a b :: l)
 		end
-	| TEnum (ea,tl1) , TEnum (eb,tl2) -> 
+	| TEnum (ea,tl1) , TEnum (eb,tl2) ->
 		if ea != eb then error [cannot_unify a b];
 		unify_types a b tl1 tl2
 	| TInst (c1,tl1) , TInst (c2,tl2) ->
@@ -445,7 +448,10 @@ let rec unify a b =
 	| TFun (l1,r1) , TFun (l2,r2) when List.length l1 = List.length l2 ->
 		(try
 			unify r1 r2;
-			List.iter2 (fun (_,t1) (_,t2) -> unify t1 t2) l2 l1 (* contravariance *)
+			List.iter2 (fun (_,o1,t1) (_,o2,t2) ->
+				if o1 && not o2 then error [Not_matching_optional];
+				unify t1 t2
+			) l2 l1 (* contravariance *)
 		with
 			Unify_error l -> error (cannot_unify a b :: l))
 	| TInst (c,tl) , TAnon fl ->
@@ -455,7 +461,7 @@ let rec unify a b =
 				if not (unify_access f1.cf_get f2.cf_get) then error [invalid_access n true];
 				if not (unify_access f1.cf_set f2.cf_set) then error [invalid_access n false];
 				if f2.cf_public && not f1.cf_public then error [invalid_visibility n];
-				try 
+				try
 					unify (apply_params c.cl_types tl f1.cf_type) f2.cf_type
 				with
 					Unify_error l -> error (invalid_field n :: l)
@@ -473,13 +479,13 @@ let rec unify a b =
 					unify f1.cf_type f2.cf_type;
 				with
 					Unify_error l -> error (invalid_field n :: l)
-			) fl2;			
+			) fl2;
 		with
 			Unify_error l -> error (cannot_unify a b :: l))
 	| TDynamic t , _ ->
 		if t == a then
 			()
-		else (match b with 
+		else (match b with
 		| TDynamic t2 ->
 			if t2 != b && not (type_eq true t t2) then error [cannot_unify a b; cannot_unify t t2];
 		| _ ->
@@ -487,10 +493,10 @@ let rec unify a b =
 	| _ , TDynamic t ->
 		if t == b then
 			()
-		else (match a with 
-		| TDynamic t2 -> 
+		else (match a with
+		| TDynamic t2 ->
 			if t2 != a && not (type_eq true t t2) then error [cannot_unify a b; cannot_unify t t2]
-		| _ -> 
+		| _ ->
 			error [cannot_unify a b])
 	| _ , _ ->
 		error [cannot_unify a b]

+ 53 - 43
typer.ml

@@ -81,6 +81,8 @@ let unify_error_msg ctx = function
 		"Inconsistent " ^ (if get then "getter" else "setter") ^ " for field " ^ f
 	| Invalid_visibility n ->
 		"The field " ^ n ^ " is not public"
+	| Not_matching_optional ->
+		"Optional parameters can't be forced"
 
 let rec error_msg = function
 	| Module_not_found m -> "Class not found : " ^ s_type_path m
@@ -102,6 +104,8 @@ let load_ref : (context -> module_path -> pos -> module_def) ref = ref (fun _ _
 let type_expr_ref = ref (fun _ ?need_val _ -> assert false)
 let type_module_ref = ref (fun _ _ _ _ -> assert false)
 
+let null p = mk (TConst TNull) (mk_mono()) p
+
 let load ctx m p = (!load_ref) ctx m p
 
 let context err warn =
@@ -354,7 +358,7 @@ and load_type ctx p t =
 					load_type ctx p t, NormalAccess, NormalAccess
 				| AFFun (tl,t) ->
 					let t = load_type ctx p t in
-					let args = List.map (fun (name,t) -> name , load_type ctx p t) tl in
+					let args = List.map (fun (name,o,t) -> name , o, load_type ctx p t) tl in
 					TFun (args,t), NormalAccess, NormalAccess
 				| AFProp (t,i1,i2) ->
 					let access m get =
@@ -383,7 +387,7 @@ and load_type ctx p t =
 		| [TPNormal { tpackage = []; tparams = []; tname = "Void" }] ->
 			TFun ([],load_type ctx p r)
 		| _ ->
-			TFun (List.map (fun t -> "",load_type ctx p t) args,load_type ctx p r)
+			TFun (List.map (fun t -> "",false,load_type ctx p t) args,load_type ctx p r)
 
 let load_type_opt ctx p t =
 	match t with
@@ -399,7 +403,7 @@ let rec reverse_type t =
 	| TSign (s,params) ->
 		TPNormal { tpackage = fst s.s_path; tname = snd s.s_path; tparams = List.map reverse_type params }
 	| TFun (params,ret) ->
-		TPFunction (List.map (fun (_,t) -> reverse_type t) params,reverse_type ret)
+		TPFunction (List.map (fun (_,_,t) -> reverse_type t) params,reverse_type ret)
 	| TAnon fields ->
 		TPAnonymous (PMap.fold (fun f acc ->
 			(f.cf_name , AFVar (reverse_type f.cf_type), null_pos) :: acc
@@ -421,13 +425,13 @@ let extend_remoting ctx c t p async prot =
 	let tvoid = TPNormal { tpackage = []; tname = "Void"; tparams = [] } in
 	let make_field name args ret =
 		try
-			let targs = List.map (fun (a,t) -> a, Some (reverse_type t)) args in
+			let targs = List.map (fun (a,o,t) -> a, o, Some (reverse_type t)) args in
 			let tret = reverse_type ret in
-			let eargs = [EArrayDecl (List.map (fun (a,_) -> (EConst (Ident a),p)) args),p] in
+			let eargs = [EArrayDecl (List.map (fun (a,_,_) -> (EConst (Ident a),p)) args),p] in
 			let targs , tret , eargs = if async then
 				match tret with
 				| TPNormal { tpackage = []; tname = "Void" } -> targs , tvoid , eargs @ [EConst (Ident "null"),p]
-				| _ -> targs @ ["__callb",Some (TPFunction ([tret],tvoid))] , tvoid , eargs @ [EUntyped (EConst (Ident "__callb"),p),p]
+				| _ -> targs @ ["__callb",true,Some (TPFunction ([tret],tvoid))] , tvoid , eargs @ [EUntyped (EConst (Ident "__callb"),p),p]
 			else
 				targs, tret , eargs
 			in
@@ -452,7 +456,7 @@ let extend_remoting ctx c t p async prot =
 	let class_fields = (match ct with
 		| TInst (c,params) ->
 			(FVar ("__cnx",None,[],Some (TPNormal { tpackage = ["haxe";"remoting"]; tname = if async then "AsyncConnection" else "Connection"; tparams = [] }),None),p) ::
-			(FFun ("new",None,[APublic],[],{ f_args = ["c",None]; f_type = None; f_expr = (EBinop (OpAssign,(EConst (Ident "__cnx"),p),(EConst (Ident "c"),p)),p) }),p) ::
+			(FFun ("new",None,[APublic],[],{ f_args = ["c",false,None]; f_type = None; f_expr = (EBinop (OpAssign,(EConst (Ident "__cnx"),p),(EConst (Ident "c"),p)),p) }),p) ::
 			PMap.fold (fun f acc ->
 				if not f.cf_public then
 					acc
@@ -573,7 +577,7 @@ let is_flash_extern t =
 	match follow t with
 	| TInst (c,_) ->
 		(match fst c.cl_path with
-		| "flash" :: _ -> c.cl_extern && not (Plugin.defined "no_flash_opt_args")
+		| "flash" :: _ -> c.cl_extern
 		| _ -> false)
 	| _ -> false
 
@@ -634,48 +638,54 @@ let rec return_flow ctx e =
 
 let unify_call_params ctx t el args p =
 	let error flag =
-		if flag && is_flash_extern t then
-			el (* allow fewer args for flash API only *)
-		else
-			let argstr = "Function require " ^ (if args = [] then "no argument" else "arguments : " ^ String.concat ", " (List.map fst args)) in
-			display_error ctx ((if flag then "Not enough" else "Too many") ^ " arguments\n" ^ argstr) p;
-			el
+		let format_arg = (fun (name,opt,_) -> (if opt then "?" else "") ^ name) in
+		let argstr = "Function require " ^ (if args = [] then "no argument" else "arguments : " ^ String.concat ", " (List.map format_arg args)) in
+		display_error ctx ((if flag then "Not enough" else "Too many") ^ " arguments\n" ^ argstr) p
 	in
-	let rec loop l l2 =
+	let rec loop acc l l2 =
 		match l , l2 with
 		| [] , [] ->
-			el
-		| [] , [(_,t)] ->
-			let rec loop t =
+			List.rev acc
+		| [] , [(_,false,t)] ->
+			let rec follow2 t =
 				match t with
 				| TMono r ->
 					(match !r with
-					| Some t -> loop t
+					| Some t -> follow2 t
 					| _ -> t)
 				| TLazy f ->
-					loop (!f())
+					follow2 (!f())
 				| _ -> t
 			in
-			(match loop t with
+			(match follow2 t with
 			| TSign ({ s_path = ["haxe"] , "PosInfos" },[]) ->
 				let infos = mk_infos ctx p [] in
 				let e = (!type_expr_ref) ctx ~need_val:true infos in
-				el @ [e]
-			| _ -> error true)
-		| [] , _ ->
-			error true
+				loop (e :: acc) [] []
+			| _ ->
+				error true;
+				loop (null p :: acc) [] [])
+		| [] , (_,opt,_) :: l ->
+			if not opt then error true;
+			if is_flash_extern t then 
+				loop acc [] l
+			else
+				loop (null p :: acc) [] l
 		| _ , [] ->
-			error false
-		| e :: l, (name,t) :: l2 ->
-			(try
-				unify ctx e.etype t e.epos;
+			error false;
+			List.rev acc
+		| e :: l, (name,opt,t) :: l2 ->
+			try
+				unify_raise ctx e.etype t e.epos;
+				loop (e :: acc) l l2
 			with
-				| Error (Protect _,_) as e -> raise e
-				| Error (m,p) -> raise (Error (Stack (m,Custom ("For function argument '" ^ name ^ "'")), p))
-			);
-			loop l l2
+				Error (Unify ul,_) ->
+					if opt then
+						loop (null p :: acc) (e :: l) l2
+					else
+						raise (Error (Stack (Unify ul,Custom ("For function argument '" ^ name ^ "'")), p))
 	in
-	loop el args
+	loop [] el args
 
 let type_local ctx i p =
 	(* local lookup *)
@@ -865,7 +875,7 @@ let type_matching ctx (enum,params) (e,p) ecases =
 		let args = (match c.ef_type with
 			| TFun (l,_) ->
 				if List.length l <> List.length el then needs (List.length l);
-				List.map (fun (_,t) -> apply_params enum.e_types params t) l
+				List.map (fun (_,_,t) -> apply_params enum.e_types params t) l
 			| TEnum _ -> error "This constructor does not take any paramter" p
 			| _ -> assert false
 		) in
@@ -1574,7 +1584,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 			el , r
 		| TMono _ ->
 			let t = mk_mono() in
-			unify ctx (TFun (List.map (fun e -> "",e.etype) el,t)) e.etype e.epos;
+			unify ctx (TFun (List.map (fun e -> "",false,e.etype) el,t)) e.etype e.epos;
 			el, t
 		| t ->
 			el, if t == t_dynamic then
@@ -1609,7 +1619,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 		type_unop ctx op flag e p
 	| EFunction f ->
 		let rt = load_type_opt ctx p f.f_type in
-		let args = List.map (fun (s,t) -> s , load_type_opt ctx p t) f.f_args in
+		let args = List.map (fun (s,opt,t) -> s , opt, load_type_opt ctx p t) f.f_args in
 		let ft = TFun (args,rt) in
 		let e , fargs = type_function ctx ft true false f p in
 		let f = {
@@ -1642,7 +1652,7 @@ and type_expr ctx ?(need_val=true) (e,p) =
 and type_function ctx t static constr f p =
 	let locals = save_locals ctx in
 	let fargs , r = (match t with
-		| TFun (args,r) -> List.map (fun (n,t) -> add_local ctx n t, t) args, r
+		| TFun (args,r) -> List.map (fun (n,opt,t) -> add_local ctx n t, opt, t) args, r
 		| _ -> assert false
 	) in
 	let old_ret = ctx.ret in
@@ -1802,7 +1812,7 @@ let init_class ctx c p herits fields =
 				type_params = params @ ctx.type_params;
 			} in
 			let ret = type_opt ctx p f.f_type in
-			let args = List.map (fun (name,t) -> name , type_opt ctx p t) f.f_args in
+			let args = List.map (fun (name,opt,t) -> name , opt, type_opt ctx p t) f.f_args in
 			let t = TFun (args,ret) in
 			let stat = List.mem AStatic access in
 			let constr = (name = "new") in
@@ -1864,7 +1874,7 @@ let init_class ctx c p herits fields =
 				| "dynamic" -> MethodAccess ("set_" ^ name)
 				| "default" -> NormalAccess
 				| _ ->
-					check_set := check_method set (TFun (["",ret],ret));
+					check_set := check_method set (TFun (["",false,ret],ret));
 					MethodAccess set
 			) in
 			if set = NormalAccess && (match get with MethodAccess _ -> true | _ -> false) then error "Unsupported property combination" p;
@@ -1903,8 +1913,8 @@ let init_class ctx c p herits fields =
 		| TFun (args,r) ->
 			let t = field_type f in
 			let n = ref 0 in
-			let args = List.map (fun (_,t) -> incr n; "p" ^ string_of_int (!n) , t) args in
-			let eargs = List.map (fun (n,t) -> mk (TLocal n) t p) args in
+			let args = List.map (fun (_,b,t) -> incr n; "p" ^ string_of_int (!n) , b, t) args in
+			let eargs = List.map (fun (n,_,t) -> mk (TLocal n) t p) args in
 			let func = {
 				tf_args = args;
 				tf_type = t;
@@ -2050,7 +2060,7 @@ let type_module ctx m tdecls loadp =
 			List.iter (fun (c,doc,t,p) ->
 				let t = (match t with
 					| [] -> et
-					| l -> TFun (List.map (fun (s,t) -> s, load_type ctx p t) l, et)
+					| l -> TFun (List.map (fun (s,t) -> s, false, load_type ctx p t) l, et)
 				) in
 				e.e_constrs <- PMap.add c { ef_name = c; ef_type = t; ef_pos = p; ef_doc = doc } e.e_constrs
 			) constrs