Răsfoiți Sursa

bugfixes : switch on bool , case with no expressions

Nicolas Cannasse 17 ani în urmă
părinte
comite
9a9a29b0e7
2 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 5 0
      doc/CHANGES.txt
  2. 4 0
      typer.ml

+ 5 - 0
doc/CHANGES.txt

@@ -5,6 +5,9 @@ TODO optimizer : optimizations and ast manipulation in a separate module
 TODO optimizer : when an object is only used localy, move its fields on the stack (allow inlined iterators)
 TODO optimizer : precompute constant expressions
 TODO optimizer : reduce expressions such as function()...() , [arr][0] or if(true) (for better inlining)
+TODO optimizer : move multiple statics access into local variables
+TODO optimizer : optimize switch on constants unless there is platform dispatch for it
+TODO inlining : allow inlined getter/setter
 TODO inlining : substitute class+function type parameters in order to have fully typed expressions
 
 2008-??-??: 1.19
@@ -18,6 +21,8 @@ TODO inlining : substitute class+function type parameters in order to have fully
 	{} is now an empty object and not an empty block
 	fixed some verify errors left in flash9
 	fixed private/protected differences in gen-hx-classes
+	genswf9 : allowed to store a Class in a typed register
+	fixed switch-on-bool (don't use matching)
 
 2008-02-23: 1.18
 	some optimization and bugfix for as3 codegen

+ 4 - 0
typer.ml

@@ -1541,6 +1541,9 @@ and type_switch ctx e cases def need_val p =
 			None
 	in
 	let enum = ref (match follow e.etype with
+		| TEnum ({ e_path = [],"Bool" },_)		
+		| TEnum ({ e_path = ["flash"],_ ; e_extern = true },_) ->
+			None
 		| TEnum (e,params) -> Some (e,params)
 		| TMono r ->
 			(match lookup_enum (List.concat (List.map fst cases)) with
@@ -1593,6 +1596,7 @@ and type_switch ctx e cases def need_val p =
 			first := false;
 			v
 		) el in
+		if el = [] then error "Case must match at least one expression" (pos e2);
 		let e2 = type_expr ctx ~need_val e2 in
 		locals();
 		unify_val e2;