Browse Source

fixed modulo in flash9
allowed extern mc classes

Nicolas Cannasse 17 years ago
parent
commit
acec16e807
3 changed files with 19 additions and 2 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 16 1
      genswf.ml
  3. 2 1
      genswf9.ml

+ 1 - 0
doc/CHANGES.txt

@@ -23,6 +23,7 @@
 	more f9 Null<T> support for "if" and array declarations
 	more neko.Web.setCookie parameters
 	added "inline" for methods and static vars
+	fixed % type in flash9
 
 2007-10-31: 1.16
 	use _sans font for default flash traces (better Linux support)

+ 16 - 1
genswf.ml

@@ -20,6 +20,7 @@ open Swf
 open As3
 open As3hl
 open Genswf9
+open Type
 
 type context = {
 	mutable f8clips : string list;
@@ -105,6 +106,20 @@ let build_movieclip ctx (pack,name) =
 		hls_fields = [|{ hlf_name = c.hlc_name; hlf_slot = 1; hlf_kind = HFClass c; hlf_metas = None }|];
 	}
 
+let movieclip_exists types path =
+	let name = Ast.s_type_path path in
+	List.exists (function
+		| TClassDecl c when c.cl_path = path ->
+			(match c.cl_super with
+			| Some ({ cl_path = ["flash";"display"],"MovieClip" },[])
+			| Some ({ cl_path = ["flash";"display"],"Sprite" },[]) -> ()
+			| _ -> failwith ("The class " ^ name ^ " must either extends MovieClip or Sprite"));
+			not c.cl_extern
+		| TEnumDecl e when e.e_path = path -> failwith ("The clip " ^ name ^ " must be bound to a class")
+		| TTypeDecl t when t.t_path = path -> failwith ("The clip " ^ name ^ " must be bound to a class")
+		| _ -> false
+	) types
+
 let generate file ver header infile types hres =
 	let t = Plugin.timer "generate swf" in
 	let file , codeclip = (try let f , c = ExtString.String.split file "@" in f, Some c with _ -> file , None) in
@@ -171,7 +186,7 @@ let generate file ver header infile types hres =
 		List.iter (fun c ->
 			let path = ExtString.String.nsplit c.f9_classname "." in
 			let path = (match List.rev path with [] -> assert false | x :: l -> List.rev l, x) in
-			if c.f9_cid <> None && not (List.exists (fun t -> Type.t_path t = path) types) then
+			if c.f9_cid <> None && not (movieclip_exists types path) then
 				ctx.as3code <- build_movieclip ctx path :: ctx.as3code;
 		) ctx.f9clips;
 		let as3code = (match ctx.as3code with [] -> [] | l -> [tag (TActionScript3 (None,As3hlparse.flatten l))]) in

+ 2 - 1
genswf9.ml

@@ -1176,7 +1176,8 @@ and gen_binop ctx retval op e1 e2 t =
 	| OpUShr ->
 		gen_op A3OUShr
 	| OpMod ->
-		gen_op A3OMod
+		gen_op A3OMod;
+		if	classify ctx e1.etype = KInt && classify ctx e2.etype = KInt then coerce ctx (classify ctx t);
 	| OpInterval ->
 		assert false