Browse Source

fixed issue #388

Nicolas Cannasse 14 years ago
parent
commit
c8ef58be53
3 changed files with 16 additions and 7 deletions
  1. 6 0
      common.ml
  2. 4 7
      main.ml
  3. 6 0
      typer.ml

+ 6 - 0
common.ml

@@ -145,6 +145,12 @@ let platform_name = function
 	| Php -> "php"
 	| Cpp -> "cpp"
 
+let flash_versions = List.map (fun v ->
+	let maj = int_of_float v in
+	let min = int_of_float (mod_float (v *. 10.) 10.) in
+	v, string_of_int maj ^ (if min = 0 then "" else "_" ^ string_of_int min)
+) [9.;10.;10.1;10.2;10.3;11.]
+
 let defined ctx v = PMap.mem v ctx.defines
 
 let define ctx v =

+ 4 - 7
main.ml

@@ -538,15 +538,12 @@ try
 			if com.flash_version >= 9. then begin
 				let rec loop = function
 					| [] -> ()
-					| v :: _ when v > com.flash_version -> ()
-					| v :: l ->
-						let maj = int_of_float v in
-						let min = int_of_float (mod_float (v *. 10.) 10.) in
-						let def = "flash" ^ string_of_int maj ^ (if min = 0 then "" else "_" ^ string_of_int min) in
-						Common.define com def;
+					| (v,_) :: _ when v > com.flash_version -> ()
+					| (v,def) :: l ->
+						Common.define com ("flash" ^ def);
 						loop l
 				in
-				loop [9.;10.;10.1;10.2;10.3;11.];
+				loop Common.flash_versions;
 				com.package_rules <- PMap.add "flash" (Directory "flash9") com.package_rules;
 				com.package_rules <- PMap.add "flash9" Forbidden com.package_rules;
 				com.platform <- Flash9;

+ 6 - 0
typer.ml

@@ -2028,6 +2028,12 @@ let load_macro ctx cpath f p =
 			List.iter (fun p -> com2.defines <- PMap.remove (platform_name p) com2.defines) platforms;
 			com2.class_path <- List.filter (fun s -> not (ExtString.String.exists s "/_std/")) com2.class_path;
 			com2.class_path <- List.map (fun p -> p ^ "neko" ^ "/_std/") com2.std_path @ com2.class_path;
+			com2.defines <- PMap.foldi (fun k _ acc -> 
+				if List.exists (fun (_,d) -> "flash" ^ d = k) Common.flash_versions then
+					acc
+				else
+					PMap.add k () acc
+			) com2.defines PMap.empty;
 			Common.define com2 "macro";
 			Common.init_platform com2 Neko;
 			let ctx2 = ctx.g.do_create com2 in