Browse Source

removed TMatch (mostly)

Simon Krajewski 12 years ago
parent
commit
609abf3a8e
17 changed files with 134 additions and 438 deletions
  1. 70 36
      codegen.ml
  2. 1 1
      common.ml
  3. 1 51
      genas3.ml
  4. 16 54
      gencommon.ml
  5. 10 62
      gencpp.ml
  6. 3 4
      gencs.ml
  7. 4 5
      genjava.ml
  8. 1 60
      genjs.ml
  9. 0 58
      genneko.ml
  10. 2 52
      genphp.ml
  11. 0 2
      genswf8.ml
  12. 3 3
      genswf9.ml
  13. 2 2
      interp.ml
  14. 7 7
      optimizer.ml
  15. 8 35
      type.ml
  16. 0 3
      typeload.ml
  17. 6 3
      typer.ml

+ 70 - 36
codegen.ml

@@ -851,18 +851,32 @@ let rec local_usage f e =
 				local_usage f e;
 			))
 		) catchs;
-	| TMatch (e,_,cases,def) ->
-		local_usage f e;
-		List.iter (fun (_,vars,e) ->
-			let cc f =
-				(match vars with
-				| None -> ()
-				| Some l ->	List.iter (function None -> () | Some v -> f (Declare v)) l);
+	| TPatMatch dt ->
+		List.iter (fun (v,eo) ->
+			f (Declare v);
+			match eo with None -> () | Some e -> local_usage f e
+		) dt.dt_var_init;
+		let rec fdt dt = match dt with
+			| DTBind(bl,dt) ->
+				List.iter (fun ((v,_),e) ->
+					f (Declare v);
+					local_usage f e
+				) bl;
+				fdt dt
+			| DTExpr e -> local_usage f e
+			| DTGuard(e,dt1,dt2) ->
 				local_usage f e;
-			in
-			f (Block cc)
-		) cases;
-		(match def with None -> () | Some e -> local_usage f e);
+				fdt dt1;
+				(match dt2 with None -> () | Some dt -> fdt dt)
+			| DTSwitch(e,cl) ->
+				local_usage f e;
+				List.iter (fun (e,dt) ->
+					local_usage f e;
+					fdt dt
+				) cl
+			| DTGoto _ -> ()
+		in
+		Array.iter fdt dt.dt_dt_lookup
 	| _ ->
 		iter (local_usage f) e
 
@@ -924,7 +938,8 @@ let captured_vars com e =
 					v, e
 			) catchs in
 			mk (TTry (wrap used expr,catchs)) e.etype e.epos
-		| TMatch (expr,enum,cases,def) ->
+		(* TODO: find out this does *)
+(* 		| TMatch (expr,enum,cases,def) ->
 			let cases = List.map (fun (il,vars,e) ->
 				let pos = e.epos in
 				let e = ref (wrap used e) in
@@ -943,7 +958,7 @@ let captured_vars com e =
 				il, vars, !e
 			) cases in
 			let def = match def with None -> None | Some e -> Some (wrap used e) in
-			mk (TMatch (wrap used expr,enum,cases,def)) e.etype e.epos
+			mk (TMatch (wrap used expr,enum,cases,def)) e.etype e.epos *)
 		| TFunction f ->
 			(*
 				list variables that are marked as used, but also used in that
@@ -1176,17 +1191,29 @@ let rename_local_vars com e =
 				loop e;
 				old()
 			) catchs;
-		| TMatch (e,_,cases,def) ->
-			loop e;
-			List.iter (fun (_,vars,e) ->
-				let old = save() in
-				(match vars with
-				| None -> ()
-				| Some l ->	List.iter (function None -> () | Some v -> declare v e.epos) l);
-				loop e;
-				old();
-			) cases;
-			(match def with None -> () | Some e -> loop e);
+		| TPatMatch dt ->
+			let rec fdt dt = match dt with
+				| DTSwitch(e,cl) ->
+					loop e;
+					List.iter (fun (_,dt) ->
+						let old = save() in
+						fdt dt;
+						old();
+					) cl;
+				| DTBind(bl,dt) ->
+					List.iter (fun ((v,p),e) ->
+						declare v e.epos
+					) bl;
+					fdt dt
+				| DTExpr e -> loop e;
+				| DTGuard(e,dt1,dt2) ->
+					loop e;
+					fdt dt1;
+					(match dt2 with None -> () | Some dt -> fdt dt)
+				| DTGoto _ ->
+					()
+			in
+			Array.iter fdt dt.dt_dt_lookup
 		| TTypeExpr t ->
 			check t
 		| TNew (c,_,_) ->
@@ -1299,17 +1326,24 @@ let check_local_vars_init e =
 			| Some e ->
 				loop vars e;
 				join vars cvars)
-		| TMatch (e,_,cases,def) ->
-			loop vars e;
-			let old = !vars in
-			let cvars = List.map (fun (_,vl,e) ->
-				vars := old;
-				loop vars e;
-				restore vars old [];
-				!vars
-			) cases in
-			(match def with None -> () | Some e -> vars := old; loop vars e);
-			join vars cvars
+		| TPatMatch dt ->
+			let cvars = ref [] in
+			let rec fdt dt = match dt with
+				| DTExpr e ->
+					let old = !vars in
+					loop vars e;
+					restore vars old [];
+					cvars := !vars :: !cvars
+				| DTSwitch(e,cl) ->
+					loop vars e;
+					List.iter (fun (_,dt) -> fdt dt) cl
+				| DTGuard(e,dt1,dt2) ->
+					fdt dt1;
+					(match dt2 with None -> () | Some dt -> fdt dt)
+				| DTBind(_,dt) -> fdt dt
+				| DTGoto _ -> ()
+			in
+			join vars !cvars
 		(* mark all reachable vars as initialized, since we don't exit the block  *)
 		| TBreak | TContinue | TReturn None ->
 			vars := PMap.map (fun _ -> true) !vars
@@ -1985,7 +2019,7 @@ let rec constructor_side_effects e =
 		true
 	| TField (_,FEnum _) ->
 		false
-	| TUnop _ | TArray _ | TField _ | TCall _ | TNew _ | TFor _ | TWhile _ | TSwitch _ | TMatch _ | TPatMatch _ | TReturn _ | TThrow _ ->
+	| TUnop _ | TArray _ | TField _ | TCall _ | TNew _ | TFor _ | TWhile _ | TSwitch _ | TPatMatch _ | TReturn _ | TThrow _ ->
 		true
 	| TBinop _ | TTry _ | TIf _ | TBlock _ | TVars _
 	| TFunction _ | TArrayDecl _ | TObjectDecl _

+ 1 - 1
common.ml

@@ -484,7 +484,7 @@ let get_config com =
 			pf_pad_nulls = true;
 			pf_add_final_return = false;
 			pf_overload = false;
-			pf_pattern_matching = false;
+			pf_pattern_matching = true;
 		}
 	| Flash when defined Define.As3 ->
 		{

+ 1 - 51
genas3.ml

@@ -276,7 +276,7 @@ let rec type_str ctx t p =
 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
+	| TSwitch _ | TPatMatch _ when not in_switch -> iter_switch_break true e
 	| TBreak when in_switch -> raise Exit
 	| _ -> iter (iter_switch_break in_switch) e
 
@@ -726,49 +726,6 @@ and gen_expr ctx e =
 			print ctx "catch( %s : %s )" (s_ident v.v_name) (type_str ctx v.v_type e.epos);
 			gen_expr ctx e;
 		) catchs;
-	| TMatch (e,_,cases,def) ->
-		print ctx "{";
-		let bend = open_block ctx in
-		newline ctx;
-		let tmp = gen_local ctx "$e" in
-		print ctx "var %s : enum = " tmp;
-		gen_value ctx e;
-		newline ctx;
-		print ctx "switch( %s.index ) {" tmp;
-		List.iter (fun (cl,params,e) ->
-			List.iter (fun c ->
-				newline ctx;
-				print ctx "case %d:" c;
-			) cl;
-			(match params with
-			| None | Some [] -> ()
-			| Some l ->
-				let n = ref (-1) 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 ->
-					newline ctx;
-					spr ctx "var ";
-					concat ctx ", " (fun (v,n) ->
-						print ctx "%s : %s = %s.params[%d]" (s_ident v.v_name) (type_str ctx v.v_type e.epos) tmp n;
-					) l);
-			gen_block ctx e;
-			print ctx "break";
-		) cases;
-		(match def with
-		| None -> ()
-		| Some e ->
-			newline ctx;
-			spr ctx "default:";
-			gen_block ctx e;
-			print ctx "break";
-		);
-		newline ctx;
-		spr ctx "}";
-		bend();
-		newline ctx;
-		spr ctx "}";
 	| TPatMatch dt -> assert false
 	| TSwitch (e,cases,def) ->
 		spr ctx "switch";
@@ -931,13 +888,6 @@ and gen_value ctx e =
 			match def with None -> None | Some e -> Some (assign e)
 		)) e.etype e.epos);
 		v()
-	| TMatch (cond,enum,cases,def) ->
-		let v = value true in
-		gen_expr ctx (mk (TMatch (cond,enum,
-			List.map (fun (constr,params,e) -> (constr,params,assign e)) cases,
-			match def with None -> None | Some e -> Some (assign e)
-		)) e.etype e.epos);
-		v()
 	| TPatMatch dt -> assert false
 	| TTry (b,catchs) ->
 		let v = value true in

+ 16 - 54
gencommon.ml

@@ -110,7 +110,7 @@ struct
   let mk_heexpr = function
     | TConst _ -> 0 | TLocal _ -> 1 | TArray _ -> 3 | TBinop _ -> 4 | TField _ -> 5 | TTypeExpr _ -> 7 | TParenthesis _ -> 8 | TObjectDecl _ -> 9
     | TArrayDecl _ -> 10 | TCall _ -> 11 | TNew _ -> 12 | TUnop _ -> 13 | TFunction _ -> 14 | TVars _ -> 15 | TBlock _ -> 16 | TFor _ -> 17 | TIf _ -> 18 | TWhile _ -> 19
-    | TSwitch _ -> 20 | TMatch _ -> 21 | TTry _ -> 22 | TReturn _ -> 23 | TBreak -> 24 | TContinue -> 25 | TThrow _ -> 26 | TCast _ -> 27 | TMeta _ -> 28 | TPatMatch _ -> 29
+    | TSwitch _ -> 20 | TPatMatch _ -> 21 | TTry _ -> 22 | TReturn _ -> 23 | TBreak -> 24 | TContinue -> 25 | TThrow _ -> 26 | TCast _ -> 27 | TMeta _ -> 28
 
   let mk_heetype = function
     | TMono _ -> 0 | TEnum _ -> 1 | TInst _ -> 2 | TType _ -> 3 | TFun _ -> 4
@@ -4602,8 +4602,8 @@ struct
         { expr with eexpr = TWhile(fn cond, block, flag) }
       | TSwitch(cond, el_block_l, default) ->
         { expr with eexpr = TSwitch( fn cond, List.map (fun (el,block) -> (List.map fn el, block)) el_block_l, default ) }
-      | TMatch(cond, enum, cases, default) ->
-        { expr with eexpr = TMatch(fn cond, enum, cases, default) }
+(*       | TMatch(cond, enum, cases, default) ->
+        { expr with eexpr = TMatch(fn cond, enum, cases, default) } *)
       | TReturn(eopt) ->
         { expr with eexpr = TReturn(Option.map fn eopt) }
       | TThrow (texpr) ->
@@ -4669,7 +4669,6 @@ struct
       | TFor _
       | TWhile _
       | TSwitch _
-      | TMatch _
       | TPatMatch _
       | TTry _
       | TReturn _
@@ -4795,8 +4794,8 @@ struct
         { right with eexpr = TBlock(apply_assign_block assign_fun el) }
       | TSwitch (cond, elblock_l, default) ->
         { right with eexpr = TSwitch(cond, List.map (fun (el,block) -> (el, mk_get_block assign_fun block)) elblock_l, Option.map (mk_get_block assign_fun) default) }
-      | TMatch (cond, ep, il_vlo_e_l, default) ->
-        { right with eexpr = TMatch(cond, ep, List.map (fun (il,vlo,e) -> (il,vlo,mk_get_block assign_fun e)) il_vlo_e_l, Option.map (mk_get_block assign_fun) default) }
+(*       | TMatch (cond, ep, il_vlo_e_l, default) ->
+        { right with eexpr = TMatch(cond, ep, List.map (fun (il,vlo,e) -> (il,vlo,mk_get_block assign_fun e)) il_vlo_e_l, Option.map (mk_get_block assign_fun) default) } *)
       | TTry (block, catches) ->
         { right with eexpr = TTry(mk_get_block assign_fun block, List.map (fun (v,block) -> (v,mk_get_block assign_fun block) ) catches) }
       | TIf (cond,eif,eelse) ->
@@ -5103,8 +5102,8 @@ struct
           { e with eexpr = TBlock(block) }
         | TTry (block, catches) ->
           { e with eexpr = TTry(traverse (mk_block block), List.map (fun (v,block) -> (v, traverse (mk_block block))) catches) }
-        | TMatch (cond,ep,il_vol_e_l,default) ->
-          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
+(*         | TMatch (cond,ep,il_vol_e_l,default) ->
+          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) } *)
         | TSwitch (cond,el_e_l, default) ->
           { e with eexpr = TSwitch(cond, List.map (fun (el,e) -> (el, traverse (mk_block e))) el_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
         | TWhile (cond,block,flag) ->
@@ -6010,8 +6009,8 @@ struct
           { e with eexpr = TWhile (handle (run econd) gen.gcon.basic.tbool econd.etype, run (mk_block e1), flag) }
         | TSwitch (cond, el_e_l, edef) ->
           { e with eexpr = TSwitch(run cond, List.map (fun (el,e) -> (List.map run el, run (mk_block e))) el_e_l, Option.map (fun e -> run (mk_block e)) edef) }
-        | TMatch (cond, en, il_vl_e_l, edef) ->
-          { e with eexpr = TMatch(run cond, en, List.map (fun (il, vl, e) -> (il, vl, run (mk_block e))) il_vl_e_l, Option.map (fun e -> run (mk_block e)) edef) }
+(*         | TMatch (cond, en, il_vl_e_l, edef) ->
+          { e with eexpr = TMatch(run cond, en, List.map (fun (il, vl, e) -> (il, vl, run (mk_block e))) il_vl_e_l, Option.map (fun e -> run (mk_block e)) edef) } *)
         | TFor (v,cond,e1) ->
           { e with eexpr = TFor(v, run cond, run (mk_block e1)) }
         | TTry (e, ve_l) ->
@@ -8600,43 +8599,6 @@ struct
             in
             let cond_array = { (mk_field_access gen f "params" f.epos) with etype = gen.gcon.basic.tarray t_empty } in
             { e with eexpr = TArray(cond_array, mk_int gen i cond_array.epos); }
-          | TMatch(cond,(en,eparams),cases,default) ->
-            let cond = run cond in (* being safe *)
-            (* check if en was converted to class *)
-            (* if it was, switch on tag field and change cond type *)
-            let exprs_before, cond_local, cond = try
-              let cl = Hashtbl.find t.ec_tbl en.e_path in
-              let cond = { cond with etype = TInst(cl, eparams) } in
-              let exprs_before, new_cond = ensure_local gen cond in
-              exprs_before, new_cond, get_index gen new_cond cl eparams
-            with | Not_found ->
-              (*
-                if it's not a class, we'll either use get_native_enum_tag or in a last resource,
-                call Type.getEnumIndex
-              *)
-              match opt_get_native_enum_tag with
-                | Some get_native_etag ->
-                  [], cond, get_native_etag cond
-                | None ->
-                  [], cond, { eexpr = TCall(mk_static_field_access_infer gen.gclasses.cl_type "enumIndex" e.epos [], [cond]); etype = gen.gcon.basic.tint; epos = cond.epos }
-            in
-
-            (* for each case, change cases to expr int, and see if there is any var create *)
-            let change_case (il, params, expr) =
-              let expr = run expr in
-              (* if there are, set var with tarray *)
-              let exprs = tmatch_params_to_exprs gen params cond_local in
-              let expr = match expr.eexpr with
-                | TBlock(bl) -> { expr with eexpr = TBlock(exprs @ bl) }
-                | _ -> { expr with eexpr = TBlock ( exprs @ [expr] ) }
-              in
-              (List.map (fun i -> mk_int gen i e.epos) il, expr)
-            in
-
-            let tswitch = { e with eexpr = TSwitch(cond, List.map change_case cases, Option.map run default) } in
-            (match exprs_before with
-              | [] -> tswitch
-              | _ -> { e with eexpr = TBlock(exprs_before @ [tswitch]) })
           | _ -> Type.map_expr run e
       in
 
@@ -9350,7 +9312,7 @@ struct
 
           new_e
         | TSwitch _
-        | TMatch _ ->
+        | TPatMatch _ ->
           let last_switch = !in_switch in
           in_switch := true;
 
@@ -9574,9 +9536,9 @@ struct
             (el, handle_case (e, ek))
           ) el_e_l, Some def) } in
           ret, !k
-        | TMatch(cond, ep, il_vopt_e_l, None) ->
-          { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) -> (il, vopt, handle_case (process_expr e))) il_vopt_e_l, None) }, Normal
-        | TMatch(cond, ep, il_vopt_e_l, Some def) ->
+(*         | TMatch(cond, ep, il_vopt_e_l, None) ->
+          { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) -> (il, vopt, handle_case (process_expr e))) il_vopt_e_l, None) }, Normal *)
+(*         | TMatch(cond, ep, il_vopt_e_l, Some def) ->
           let def, k = process_expr def in
           let def = handle_case (def, k) in
           let k = ref k in
@@ -9585,7 +9547,7 @@ struct
             k := aggregate_kind !k ek;
             (il, vopt, handle_case (e, ek))
           ) il_vopt_e_l, Some def) } in
-          ret, !k
+          ret, !k *)
         | TTry (e, catches) ->
           let e, k = process_expr e in
           let k = ref k in
@@ -9866,8 +9828,8 @@ struct
           { e with eexpr = TBlock bl }
         | TTry (block, catches) ->
           { e with eexpr = TTry(traverse (mk_block block), List.map (fun (v,block) -> (v, traverse (mk_block block))) catches) }
-        | TMatch (cond,ep,il_vol_e_l,default) ->
-          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
+(*         | TMatch (cond,ep,il_vol_e_l,default) ->
+          { e with eexpr = TMatch(cond,ep,List.map (fun (il,vol,e) -> (il,vol,traverse (mk_block e))) il_vol_e_l, Option.map (fun e -> traverse (mk_block e)) default) } *)
         | TSwitch (cond,el_e_l, default) ->
           { e with eexpr = TSwitch(cond, List.map (fun (el,e) -> (el, traverse (mk_block e))) el_e_l, Option.map (fun e -> traverse (mk_block e)) default) }
         | TWhile (cond,block,flag) ->

+ 10 - 62
gencpp.ml

@@ -790,10 +790,10 @@ let rec iter_retval f retval e =
 		f true e;
 		List.iter (fun (el,e2) -> List.iter (f true) el; f retval e2) cases;
 		(match def with None -> () | Some e -> f retval e)
-	| TMatch (e,_,cases,def) ->
+(* 	| TMatch (e,_,cases,def) ->
 		f true e;
 		List.iter (fun (_,_,e) -> f false e) cases;
-		(match def with None -> () | Some e -> f false e)
+		(match def with None -> () | Some e -> f false e) *)
 	| TPatMatch dt -> assert false
 	| TTry (e,catches) ->
 		f retval e;
@@ -894,7 +894,7 @@ let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_
          let name = keyword_remap tvar.v_name in
 			if  not (Hashtbl.mem declarations name) then
 				Hashtbl.replace undeclared name (type_string expression.etype)
-		| TMatch (condition, enum, cases, default) ->
+(* 		| TMatch (condition, enum, cases, default) ->
 			find_undeclared_variables undeclared declarations this_suffix allow_this condition;
 			List.iter (fun (case_ids,params,expression) ->
 				let old_decs = Hashtbl.copy declarations in
@@ -910,7 +910,7 @@ let find_undeclared_variables_ctx ctx undeclared declarations this_suffix allow_
 			(match default with | None -> ()
 			| Some expr ->
 				find_undeclared_variables undeclared declarations this_suffix allow_this expr;
-			);
+			); *)
 		| TFor (tvar, init, loop) ->
 			let old_decs = Hashtbl.copy declarations in
 			Hashtbl.add declarations (keyword_remap tvar.v_name) ();
@@ -1247,7 +1247,7 @@ and find_local_functions_and_return_blocks_ctx ctx retval expression =
 			if (retval) then begin
 				define_local_return_block_ctx ctx expression (next_anon_function_name ctx) true;
 			end  (* else we are done *)
-		| TMatch (_, _, _, _)
+		| TPatMatch (_)
 		| TTry (_, _)
 		| TSwitch (_, _, _) when retval ->
 				define_local_return_block_ctx ctx expression (next_anon_function_name ctx) true;
@@ -1271,9 +1271,9 @@ and find_local_functions_and_return_blocks_ctx ctx retval expression =
 		| TArray (obj,_) when (is_null obj) -> ( )
 		| TIf ( _ , _ , _ ) when retval -> (* ? operator style *)
 		   iter_retval find_local_functions_and_return_blocks retval expression
-		| TMatch (_, _, _, _)
+		| TPatMatch (_)
 		| TSwitch (_, _, _) when retval -> ( )
-		| TMatch ( cond , _, _, _)
+		(* | TMatch ( cond , _, _, _) *)
 		| TWhile ( cond , _, _ )
 		| TIf ( cond , _, _ )
 		| TSwitch ( cond , _, _) -> iter_retval find_local_functions_and_return_blocks true cond
@@ -1884,7 +1884,7 @@ and gen_expression ctx retval expression =
 	(* These have already been defined in find_local_return_blocks ... *)
 	| TTry (_,_)
 	| TSwitch (_,_,_)
-	| TMatch (_, _, _, _) when (retval && (not return_from_internal_node) )->
+	| TPatMatch (_) when (retval && (not return_from_internal_node) )->
       gen_local_block_call()
     | TPatMatch dt -> assert false
 	| TSwitch (condition,cases,optional_default)  ->
@@ -1939,58 +1939,6 @@ and gen_expression ctx retval expression =
 				output ";\n";
 			);
 		end
-	| TMatch (condition, enum, cases, default) ->
-		let tmp_var = get_switch_var ctx in
-		writer#begin_block;
-		output_i (  "::" ^ (join_class_path_remap (fst enum).e_path "::") ^ " " ^ tmp_var ^ " = " );
-		gen_expression ctx true condition;
-		output ";\n";
-
-		let use_if_statements = contains_break expression in
-		let dump_condition = if (use_if_statements) then begin
-			let tmp_name = get_switch_var ctx in
-			output_i ( "int " ^ tmp_name ^ " = (" ^ tmp_var ^ ")->GetIndex();" );
-			let elif = ref "if" in
-			( fun case_ids -> output (!elif ^ " (" ); elif := "else if";
-					output (String.concat "||"
-					(List.map (fun id -> (string_of_int id) ^ "==" ^ tmp_name ) case_ids ) );
-				output ") " )
-		end else begin
-			output_i ("switch((" ^ tmp_var ^ ")->GetIndex())");
-			( fun case_ids ->
-			List.iter (fun id -> output ("case " ^ (string_of_int id) ^ ": ") ) case_ids;
-			)
-		end in
-		writer#begin_block;
-		List.iter (fun (case_ids,params,expression) ->
-			output_i "";
-			dump_condition case_ids;
-			let has_params = match params with | Some _ -> true | _ -> false in
-			if (has_params) then begin
-				writer#begin_block;
-				List.iter (fun (name,vtype,id) -> output_i
-				((type_string vtype) ^ " " ^ (keyword_remap name) ^
-					" = " ^ tmp_var ^ "->__Param(" ^ (string_of_int id) ^ ");\n"))
-						(tmatch_params_to_args params);
-			end;
-			ctx.ctx_return_from_block <- return_from_internal_node;
-			gen_expression ctx false (to_block expression);
-			if (has_params) then writer#end_block;
-			if (not use_if_statements) then output_i ";break;\n";
-		) cases;
-		(match default with
-		| None -> ()
-		|  Some e ->
-			if (use_if_statements) then
-				output_i "else "
-			else
-				output_i "default: ";
-			ctx.ctx_return_from_block <- return_from_internal_node;
-			gen_expression ctx false (to_block e);
-		);
-		writer#end_block;
-		writer#end_block;
-
 	| TTry (expression, catch_list) ->
 		output "try";
 		(* Move this "inside" the try call ... *)
@@ -2363,12 +2311,12 @@ let find_referenced_types ctx obj super_deps constructor_deps header_only for_de
 				| TTry (e,catches) ->
 					List.iter (fun (v,_) -> visit_type v.v_type) catches
 				(* Must visit the enum param types, Type.iter will visit the rest ... *)
-				| TMatch (_,enum,cases,_) ->
+(* 				| TMatch (_,enum,cases,_) ->
 					add_type (fst enum).e_path;
 					List.iter (fun (case_ids,params,expression) ->
 						(match params with
 						| None -> ()
-						| Some l -> List.iter (function None -> () | Some v -> visit_type v.v_type) l  ) ) cases;
+						| Some l -> List.iter (function None -> () | Some v -> visit_type v.v_type) l  ) ) cases; *)
 				(* Must visit type too, Type.iter will visit the expressions ... *)
             | TNew  (klass,params,_) -> begin
                visit_type (TInst (klass,params));

+ 3 - 4
gencs.ml

@@ -850,7 +850,7 @@ let configure gen =
 
   let has_semicolon e =
     match e.eexpr with
-      | TBlock _ | TFor _ | TSwitch _ | TMatch _ | TTry _ | TIf _ -> false
+      | TBlock _ | TFor _ | TSwitch _ | TPatMatch _ | TTry _ | TIf _ -> false
       | TWhile (_,_,flag) when flag = Ast.NormalWhile -> false
       | _ -> true
   in
@@ -993,7 +993,7 @@ let configure gen =
         | TParenthesis e ->
           write w "("; expr_s w e; write w ")"
         | TMeta (_,e) ->
-            expr_s w e 
+            expr_s w e
         | TArrayDecl el ->
           print w "new %s" (t_s e.etype);
           write w "{";
@@ -1263,8 +1263,7 @@ let configure gen =
           if !strict_mode then assert false
         | TObjectDecl _ -> write w "[ obj decl not supported ]"; if !strict_mode then assert false
         | TFunction _ -> write w "[ func decl not supported ]"; if !strict_mode then assert false
-        | TMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
-        | TPatMatch dt -> assert false
+        | TPatMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
     )
     and do_call w e el =
       let params, el = extract_tparams [] el in

+ 4 - 5
genjava.ml

@@ -288,8 +288,8 @@ struct
       | TBlock bl -> is_final_return_block is_switch bl
       | TSwitch (_, el_e_l, edef) ->
         List.for_all (fun (_,e) -> is_final_return_expr e) el_e_l && Option.map_default is_final_return_expr false edef
-      | TMatch (_, _, il_vl_e_l, edef) ->
-        List.for_all (fun (_,_,e) -> is_final_return_expr e)il_vl_e_l && Option.map_default is_final_return_expr false edef
+(*       | TMatch (_, _, il_vl_e_l, edef) ->
+        List.for_all (fun (_,_,e) -> is_final_return_expr e)il_vl_e_l && Option.map_default is_final_return_expr false edef *)
       | TIf (_,eif, Some eelse) ->
         is_final_return_expr eif && is_final_return_expr eelse
       | TFor (_,_,e) ->
@@ -1012,7 +1012,7 @@ let configure gen =
     match e.eexpr with
       | TLocal { v_name = "__fallback__" }
       | TCall ({ eexpr = TLocal( { v_name = "__label__" } ) }, [ { eexpr = TConst(TInt _) } ] ) -> false
-      | TBlock _ | TFor _ | TSwitch _ | TMatch _ | TTry _ | TIf _ -> false
+      | TBlock _ | TFor _ | TSwitch _ | TPatMatch _ | TTry _ | TIf _ -> false
       | TWhile (_,_,flag) when flag = Ast.NormalWhile -> false
       | _ -> true
   in
@@ -1390,8 +1390,7 @@ let configure gen =
           if !strict_mode then assert false
         | TObjectDecl _ -> write w "[ obj decl not supported ]"; if !strict_mode then assert false
         | TFunction _ -> write w "[ func decl not supported ]"; if !strict_mode then assert false
-        | TMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
-        | TPatMatch dt -> assert false
+        | TPatMatch _ -> write w "[ match not supported ]"; if !strict_mode then assert false
     in
     expr_s w e
   in

+ 1 - 60
genjs.ml

@@ -260,7 +260,7 @@ let rec has_return 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
+	| TSwitch _ | TPatMatch _ when not in_switch -> iter_switch_break true e
 	| TBreak when in_switch -> raise Exit
 	| _ -> iter (iter_switch_break in_switch) e
 
@@ -638,58 +638,6 @@ and gen_expr ctx e =
 		bend();
 		newline ctx;
 		spr ctx "}";
-	| TMatch (e,(estruct,_),cases,def) ->
-		let evar = (if List.for_all (fun (_,pl,_) -> pl = None) cases then begin
-			spr ctx "switch( ";
-			gen_value ctx (if Optimizer.need_parent e then Codegen.mk_parent e else e);
-			spr ctx "[1] ) {";
-			"???"
-		end else begin
-			let v = (match e.eexpr with
-				| TLocal v -> v.v_name
-				| _ ->
-					spr ctx "var $e = ";
-					gen_value ctx e;
-					newline ctx;
-					"$e"
-			) in
-			print ctx "switch( %s[1] ) {" v;
-			v
-		end) in
-		List.iter (fun (cl,params,e) ->
-			List.iter (fun c ->
-				newline ctx;
-				print ctx "case %d:" c;
-			) cl;
-			let bend = open_block ctx in
-			(match params with
-			| None -> ()
-			| Some l ->
-				let n = ref 1 in
-				let l = List.fold_left (fun acc v -> incr n; match v with None -> acc | Some v -> (v.v_name,!n) :: acc) [] l in
-				newline ctx;
-				spr ctx "var ";
-				concat ctx ", " (fun (v,n) ->
-					print ctx "%s = %s[%d]" (ident v) evar n;
-				) l);
-			gen_block ctx e;
-			if not (has_return e) then begin
-				newline ctx;
-				print ctx "break";
-			end;
-			bend();
-		) cases;
-		(match def with
-		| None -> ()
-		| Some e ->
-			newline ctx;
-			spr ctx "default:";
-			let bend = open_block ctx in
-			gen_block ctx e;
-			bend();
-		);
-		newline ctx;
-		spr ctx "}"
 	| TPatMatch dt -> assert false
 	| TSwitch (e,cases,def) ->
 		spr ctx "switch";
@@ -855,13 +803,6 @@ and gen_value ctx e =
 			match def with None -> None | Some e -> Some (assign e)
 		)) e.etype e.epos);
 		v()
-	| TMatch (cond,enum,cases,def) ->
-		let v = value() in
-		gen_expr ctx (mk (TMatch (cond,enum,
-			List.map (fun (constr,params,e) -> (constr,params,assign e)) cases,
-			match def with None -> None | Some e -> Some (assign e)
-		)) e.etype e.epos);
-		v()
 	| TPatMatch dt -> assert false
 	| TTry (b,catchs) ->
 		let v = value() in

+ 0 - 58
genneko.ml

@@ -364,64 +364,6 @@ and gen_expr ctx e =
 		gen_expr ctx e
 	| TCast (e1,Some t) ->
 		gen_expr ctx (Codegen.default_cast ~vtmp:"@tmp" ctx.com e1 t e.etype e.epos)
-	| TMatch (e,_,cases,eo) ->
-		let p = pos ctx e.epos in
-		let etmp = (EVars ["@tmp",Some (gen_expr ctx e)],p) in
-		let eindex = field p (ident p "@tmp") "index" in
-		let gen_params params e =
-			match params with
-			| None ->
-				gen_expr ctx e
-			| Some el ->
-				let count = ref (-1) in
-				let vars = List.fold_left (fun acc v ->
-					incr count;
-					match v with
-					| None ->
-						acc
-					| Some v ->
-						let e = (EArray (ident p "@tmp",int p (!count)),p) in
-						let e = (if v.v_capture then call p (builtin p "array") [e] else e) in
-						(v.v_name , Some e) :: acc
-				) [] el in
-				let e = gen_expr ctx e in
-				(EBlock [
-					(EVars ["@tmp",Some (field p (ident p "@tmp") "args")],p);
-					(match vars with [] -> null p | _ -> EVars vars,p);
-					e
-				],p)
-		in
-		(try
-		  (EBlock [
-			etmp;
-			(ESwitch (
-				eindex,
-				List.map (fun (cl,params,e2) ->
-					let cond = match cl with
-						| [s] -> int p s
-						| _ -> raise Exit
-					in
-					cond , gen_params params e2
-				) cases,
-				(match eo with None -> None | Some e -> Some (gen_expr ctx e))
-			),p)
-		  ],p)
-		with
-			Exit ->
-				(EBlock [
-					etmp;
-					(EVars ["@index",Some eindex],p);
-					List.fold_left (fun acc (cl,params,e2) ->
-						let cond = (match cl with
-							| [] -> assert false
-							| c :: l ->
-								let eq c = (EBinop ("==",ident p "@index",int p c),p) in
-								List.fold_left (fun acc c -> (EBinop ("||",acc,eq c),p)) (eq c) l
-						) in
-						EIf (cond,gen_params params e2,Some acc),p
-					) (match eo with None -> null p | Some e -> (gen_expr ctx e)) (List.rev cases)
-				],p)
-		)
  	| TPatMatch dt ->
 		let num_labels = Array.length dt.dt_dt_lookup in
 		let lc = ctx.label_count in

+ 2 - 52
genphp.ml

@@ -1303,7 +1303,7 @@ and gen_expr ctx e =
 				| TThrow _
 				| TWhile _
 				| TFor _
-				| TMatch _
+				| TPatMatch _
 				| TTry _
 				| TBreak
 				| TBlock _ ->
@@ -1317,7 +1317,7 @@ and gen_expr ctx e =
 					| TThrow _
 					| TWhile _
 					| TFor _
-					| TMatch _
+					| TPatMatch _
 					| TTry _
 					| TBlock _ -> ()
 					| _ ->
@@ -1585,55 +1585,6 @@ and gen_expr ctx e =
 		bend();
 		newline ctx;
 		spr ctx "}"
-	| TMatch (e,_,cases,def) ->
-		let b = save_locals ctx in
-		let tmp = define_local ctx "__hx__t" in
-		print ctx "$%s = " tmp;
-		gen_value ctx e;
-		newline ctx;
-		print ctx "switch($%s->index) {" tmp;
-		let old_loop = ctx.in_loop in
-		ctx.in_loop <- false;
-		ctx.nested_loops <- ctx.nested_loops + 1;
-		newline ctx;
-		List.iter (fun (cl,params,e) ->
-			List.iter (fun c ->
-				print ctx "case %d:" c;
-				newline ctx;
-			) cl;
-			let b = save_locals ctx in
-			(match params with
-			| None | Some [] -> ()
-			| Some l ->
-				let n = ref (-1) in
-				let l = List.fold_left (fun acc v -> incr n; match v with None -> acc | Some v -> (v.v_name,v.v_type,!n) :: acc) [] l in
-				match l with
-				| [] -> ()
-				| l ->
-					concat ctx "; " (fun (v,t,n) ->
-						let v = define_local ctx v in
-						print ctx "$%s = $%s->params[%d]" v tmp n;
-					) l;
-					newline ctx);
-			restore_in_block ctx in_block;
-			gen_expr ctx (mk_block e);
-			print ctx "break";
-			newline ctx;
-			b()
-		) cases;
-		(match def with
-		| None -> ()
-		| Some e ->
-			spr ctx "default:";
-			restore_in_block ctx in_block;
-			gen_expr ctx (mk_block e);
-			print ctx "break";
-			newline ctx;
-		);
-		ctx.nested_loops <- ctx.nested_loops - 1;
-		ctx.in_loop <- old_loop;
-		spr ctx "}";
-		b()
 	| TPatMatch dt -> assert false
 	| TSwitch (e,cases,def) ->
 		let old_loop = ctx.in_loop in
@@ -1823,7 +1774,6 @@ and gen_value ctx e =
 	| TThrow _
 	| TSwitch _
 	| TFor _
-	| TMatch _
 	| TPatMatch _
 	| TIf _
 	| TTry _ ->

+ 0 - 2
genswf8.ml

@@ -1168,8 +1168,6 @@ and gen_expr_2 ctx retval e =
 		gen_expr ctx retval e
 	| TCast (e1,Some t) ->
 		gen_expr ctx retval (Codegen.default_cast ctx.com e1 t e.etype e.epos)
-	| TMatch (e,_,cases,def) ->
-		gen_match ctx retval e cases def
 	| TPatMatch dt -> assert false
 	| TFor (v,it,e) ->
 		gen_expr ctx true it;

+ 3 - 3
genswf9.ml

@@ -1278,7 +1278,7 @@ let rec gen_expr_content ctx retval e =
 		);
 		List.iter (fun j -> j()) jend;
 		branch());
-	| TMatch (e0,_,cases,def) ->
+(* 	| TMatch (e0,_,cases,def) ->
 		let t = classify ctx e.etype in
 		let rparams = alloc_reg ctx (KType (type_path ctx ([],"Array"))) in
 		let has_params = List.exists (fun (_,p,_) -> p <> None) cases in
@@ -1329,7 +1329,7 @@ let rec gen_expr_content ctx retval e =
 		) cases in
 		switch();
 		List.iter (fun j -> j()) jends;
-		free_reg ctx rparams
+		free_reg ctx rparams *)
 	| TPatMatch dt -> assert false
 	| TCast (e1,t) ->
 		gen_expr ctx retval e1;
@@ -1705,7 +1705,7 @@ and generate_function ctx fdata stat =
 			| TReturn (Some e) ->
 				let rec inner_loop e =
 					match e.eexpr with
-					| TSwitch _ | TMatch _ | TFor _ | TWhile _ | TTry _ -> false
+					| TSwitch _ | TPatMatch _ | TFor _ | TWhile _ | TTry _ -> false
 					| TIf _ -> loop e
 					| TParenthesis e | TMeta(_,e) -> inner_loop e
 					| _ -> true

+ 2 - 2
interp.ml

@@ -4495,7 +4495,7 @@ let rec make_ast e =
 		) cases in
 		let def = match eopt def with None -> None | Some (EBlock [],_) -> Some None | e -> Some e in
 		ESwitch (make_ast e,cases,def)
-	| TMatch (e,(en,_),cases,def) ->
+(* 	| TMatch (e,(en,_),cases,def) ->
 		let scases (idx,args,e) =
 			let p = e.epos in
 			let unused = (EConst (Ident "_"),p) in
@@ -4517,7 +4517,7 @@ let rec make_ast e =
 			) idx, None, (match e.eexpr with TBlock [] -> None | _ -> Some (make_ast e))
 		in
 		let def = match eopt def with None -> None | Some (EBlock [],_) -> Some None | e -> Some e in
-		ESwitch (make_ast e,List.map scases cases,def)
+		ESwitch (make_ast e,List.map scases cases,def) *)
 	| TPatMatch dt -> assert false
 	| TTry (e,catches) -> ETry (make_ast e,List.map (fun (v,e) -> v.v_name, (try make_type v.v_type with Exit -> assert false), make_ast e) catches)
 	| TReturn e -> EReturn (eopt e)

+ 7 - 7
optimizer.ml

@@ -32,7 +32,7 @@ let has_side_effect e =
 	let rec loop e =
 		match e.eexpr with
 		| TConst _ | TLocal _ | TField (_,FEnum _) | TTypeExpr _ | TFunction _ -> ()
-		| TMatch _ | TPatMatch _ | TNew _ | TCall _ | TField _ | TArray _ | TBinop ((OpAssignOp _ | OpAssign),_,_) | TUnop ((Increment|Decrement),_,_) -> raise Exit
+		| TPatMatch _ | TNew _ | TCall _ | TField _ | TArray _ | TBinop ((OpAssignOp _ | OpAssign),_,_) | TUnop ((Increment|Decrement),_,_) -> raise Exit
 		| TReturn _ | TBreak | TContinue | TThrow _ | TCast (_,Some _) -> raise Exit
 		| TCast (_,None) | TBinop _ | TUnop _ | TParenthesis _ | TMeta _ | TWhile _ | TFor _ | TIf _ | TTry _ | TSwitch _ | TArrayDecl _ | TVars _ | TBlock _ | TObjectDecl _ -> Type.iter loop e
 	in
@@ -241,14 +241,14 @@ let rec type_inline ctx cf f ethis params tret config p force =
 			let eloop = map false eloop in
 			in_loop := old;
 			{ e with eexpr = TWhile (cond,eloop,flag) }
-		| TMatch (v,en,cases,def) ->
+(* 		| TMatch (v,en,cases,def) ->
 			let term = term && def <> None in
 			let cases = List.map (fun (i,vl,e) ->
 				let vl = opt (List.map (fun v -> opt (fun v -> (local v).i_subst) v)) vl in
 				i, vl, map term e
 			) cases in
 			let def = opt (map term) def in
-			{ e with eexpr = TMatch (map false v,en,cases,def); etype = if term && ret_val then unify_min ctx ((List.map (fun (_,_,e) -> e) cases) @ (match def with None -> [] | Some e -> [e])) else e.etype }
+			{ e with eexpr = TMatch (map false v,en,cases,def); etype = if term && ret_val then unify_min ctx ((List.map (fun (_,_,e) -> e) cases) @ (match def with None -> [] | Some e -> [e])) else e.etype } *)
 		| TPatMatch _ ->
 			cancel_inlining := true; (* TODO *)
 			e
@@ -605,7 +605,7 @@ let rec need_parent e =
 	match e.eexpr with
 	| TConst _ | TLocal _ | TArray _ | TField _ | TParenthesis _ | TMeta _ | TCall _ | TNew _ | TTypeExpr _ | TObjectDecl _ | TArrayDecl _ -> false
 	| TCast (e,None) -> need_parent e
-	| TCast _ | TThrow _ | TReturn _ | TTry _ | TMatch _ | TPatMatch _ | TSwitch _ | TFor _ | TIf _ | TWhile _ | TBinop _ | TContinue | TBreak
+	| TCast _ | TThrow _ | TReturn _ | TTry _ | TPatMatch _ | TSwitch _ | TFor _ | TIf _ | TWhile _ | TBinop _ | TContinue | TBreak
 	| TBlock _ | TVars _ | TFunction _ | TUnop _ -> true
 
 let rec add_final_return e t =
@@ -647,7 +647,7 @@ let sanitize_expr com e =
 		match e.eexpr with
 		| TVars _	(* needs to be put into blocks *)
 		| TFor _	(* a temp var is needed for holding iterator *)
-		| TMatch _	(* a temp var is needed for holding enum *)
+		| TPatMatch _	(* a temp var is needed for holding enum *)
 		| TCall ({ eexpr = TLocal { v_name = "__js__" } },_) (* we never know *)
 			-> block e
 		| _ -> e
@@ -730,11 +730,11 @@ let sanitize_expr com e =
 		let cases = List.map (fun (el,e) -> el, complex e) cases in
 		let def = (match def with None -> None | Some e -> Some (complex e)) in
 		{ e with eexpr = TSwitch (e1,cases,def) }
-	| TMatch (e1, en, cases, def) ->
+(* 	| TMatch (e1, en, cases, def) ->
 		let e1 = parent e1 in
 		let cases = List.map (fun (el,vars,e) -> el, vars, complex e) cases in
 		let def = (match def with None -> None | Some e -> Some (complex e)) in
-		{ e with eexpr = TMatch (e1,en,cases,def) }
+		{ e with eexpr = TMatch (e1,en,cases,def) } *)
 	| _ ->
 		e
 

+ 8 - 35
type.ml

@@ -119,7 +119,6 @@ and texpr_expr =
 	| TIf of texpr * texpr * texpr option
 	| TWhile of texpr * texpr * Ast.while_flag
 	| TSwitch of texpr * (texpr list * texpr) list * texpr option
-	| TMatch of texpr * (tenum * tparams) * (int list * tvar option list option * texpr) list * texpr option
 	| TPatMatch of decision_tree
 	| TTry of texpr * (tvar * texpr) list
 	| TReturn of texpr option
@@ -1285,6 +1284,14 @@ and unify_with_access t1 f2 =
 	(* read/write *)
 	| _ -> type_eq EqBothDynamic t1 f2.cf_type
 
+let iter_dt f dt = match dt with
+	| DTBind(_,dt) -> f dt
+	| DTSwitch(_,cl) -> List.iter (fun (_,dt) -> f dt) cl
+	| DTGuard(_,dt1,dt2) ->
+		f dt1;
+		(match dt2 with None -> () | Some dt -> f dt)
+	| DTGoto _ | DTExpr _ -> ()
+
 let iter f e =
 	match e.eexpr with
 	| TConst _
@@ -1327,10 +1334,6 @@ let iter f e =
 		f e;
 		List.iter (fun (el,e2) -> List.iter f el; f e2) cases;
 		(match def with None -> () | Some e -> f e)
-	| TMatch (e,_,cases,def) ->
-		f e;
-		List.iter (fun (_,_,e) -> f e) cases;
-		(match def with None -> () | Some e -> f e)
 	| TPatMatch dt ->
 		let rec loop dt = match dt with
 			| DTBind(_,dt) -> loop dt
@@ -1397,8 +1400,6 @@ let map_expr f e =
 		{ e with eexpr = TIf (f ec,f e1,match e2 with None -> None | Some e -> Some (f e)) }
 	| TSwitch (e1,cases,def) ->
 		{ e with eexpr = TSwitch (f e1, List.map (fun (el,e2) -> List.map f el, f e2) cases, match def with None -> None | Some e -> Some (f e)) }
-	| TMatch (e1,t,cases,def) ->
-		{ e with eexpr = TMatch (f e1, t, List.map (fun (cl,params,e) -> cl, params, f e) cases, match def with None -> None | Some e -> Some (f e)) }
 	| TPatMatch dt ->
 		let rec loop dt = match dt with
 			| DTBind(vl,dt) -> DTBind(vl, loop dt)
@@ -1469,15 +1470,6 @@ let map_expr_type f ft fv e =
 		{ e with eexpr = TIf (f ec,f e1,match e2 with None -> None | Some e -> Some (f e)); etype = ft e.etype }
 	| TSwitch (e1,cases,def) ->
 		{ e with eexpr = TSwitch (f e1, List.map (fun (el,e2) -> List.map f el, f e2) cases, match def with None -> None | Some e -> Some (f e)); etype = ft e.etype }
-	| TMatch (e1,(en,pl),cases,def) ->
-		let map_case (cl,params,e) =
-			let params = match params with
-				| None -> None
-				| Some l -> Some (List.map (function None -> None | Some v -> Some (fv v)) l)
-			in
-			cl, params, f e
-		in
-		{ e with eexpr = TMatch (f e1, (en,List.map ft pl), List.map map_case cases, match def with None -> None | Some e -> Some (f e)); etype = ft e.etype }
 	| TPatMatch dt ->
 		let rec loop dt = match dt with
 			| DTBind(vl,dt) -> DTBind(vl, loop dt)
@@ -1518,7 +1510,6 @@ let s_expr_kind e =
 	| TIf (_,_,_) -> "If"
 	| TWhile (_,_,_) -> "While"
 	| TSwitch (_,_,_) -> "Switch"
-	| TMatch (_,_,_,_) -> "Match"
 	| TPatMatch _ -> "PatMatch"
 	| TTry (_,_) -> "Try"
 	| TReturn _ -> "Return"
@@ -1595,10 +1586,6 @@ let rec s_expr s_type e =
 		| DoWhile -> sprintf "DoWhile (%s,%s)" (loop e) (loop econd))
 	| TSwitch (e,cases,def) ->
 		sprintf "Switch (%s,(%s)%s)" (loop e) (slist (fun (cl,e) -> sprintf "case %s: %s" (slist loop cl) (loop e)) cases) (match def with None -> "" | Some e -> "," ^ loop e)
-	| TMatch (e,(en,tparams),cases,def) ->
-		let args vl = slist (function None -> "_" | Some v -> sprintf "%s : %s" (s_var v) (s_type v.v_type)) vl in
-		let cases = slist (fun (il,vl,e) -> sprintf "case %s%s : %s" (slist string_of_int il) (match vl with None -> "" | Some vl -> sprintf "(%s)" (args vl)) (loop e)) cases in
-		sprintf "Match %s (%s,(%s)%s)" (s_type (TEnum (en,tparams))) (loop e) cases (match def with None -> "" | Some e -> "," ^ loop e)
 	| TPatMatch dt -> s_dt "" (dt.dt_dt_lookup.(dt.dt_first))
 	| TTry (e,cl) ->
 		sprintf "Try %s(%s) " (loop e) (slist (fun (v,e) -> sprintf "catch( %s : %s ) %s" (s_var v) (s_type v.v_type) (loop e)) cl)
@@ -1676,20 +1663,6 @@ let rec s_expr_pretty tabs s_type e =
 		let ntabs = tabs ^ "\t" in
 		let s = sprintf "switch (%s) {\n%s%s" (loop e) (slist (fun (cl,e) -> sprintf "%scase %s: %s\n" ntabs (slist loop cl) (s_expr_pretty ntabs s_type e)) cases) (match def with None -> "" | Some e -> ntabs ^ "default: " ^ (s_expr_pretty ntabs s_type e) ^ "\n") in
 		s ^ tabs ^ "}"
-	| TMatch (e,(en,tparams),cases,def) ->
-		let ntabs = tabs ^ "\t" in
-		let cases = slist (fun (il,vl,e) ->
-			let ctor i = (PMap.find (List.nth en.e_names i) en.e_constrs).ef_name in
-			let ctors = String.concat "," (List.map ctor il) in
-			begin match vl with
-				| None ->
-					sprintf "%scase %s: %s\n" ntabs ctors (s_expr_pretty ntabs s_type e)
-				| Some vl ->
-					sprintf "%scase %s(%s): %s\n" ntabs ctors (String.concat "," (List.map (fun v -> match v with None -> "_" | Some v -> v.v_name) vl)) (s_expr_pretty ntabs s_type e)
-			end
-		) cases in
-		let s = sprintf "switch (%s) {\n%s%s" (loop e) cases (match def with None -> "" | Some e -> ntabs ^ "default: " ^ (s_expr_pretty ntabs s_type e) ^ "\n") in
-		s ^ tabs ^ "}"
 	| TPatMatch dt -> s_dt tabs (dt.dt_dt_lookup.(dt.dt_first))
 	| TTry (e,cl) ->
 		sprintf "try %s%s" (loop e) (slist (fun (v,e) -> sprintf "catch( %s : %s ) %s" v.v_name (s_type v.v_type) (loop e)) cl)

+ 0 - 3
typeload.ml

@@ -883,9 +883,6 @@ let rec return_flow ctx e =
 		return_flow e
 	| TSwitch (e,cases,None) when (match follow e.etype with TEnum _ -> true | _ -> false) ->
 		List.iter (fun (_,e) -> return_flow e) cases;
-	| TMatch (_,_,cases,def) ->
-		List.iter (fun (_,_,e) -> return_flow e) cases;
-		(match def with None -> () | Some e -> return_flow e)
 	| TPatMatch dt ->
 		let rec loop d = match d with
 			| DTExpr e -> return_flow e

+ 6 - 3
typer.ml

@@ -1917,7 +1917,10 @@ and type_switch_old ctx e cases def with_type p =
 and type_switch ctx e cases def with_type p =
 	try
 		let dt = match_expr ctx e cases def with_type p in
-		if not ctx.in_macro && not (Common.defined ctx.com Define.Interp) && ctx.com.config.pf_pattern_matching then mk (TPatMatch dt) dt.dt_type p else Codegen.PatternMatchConversion.to_typed_ast ctx dt p
+		if not ctx.in_macro && not (Common.defined ctx.com Define.Interp) && ctx.com.config.pf_pattern_matching then
+			mk (TPatMatch dt) dt.dt_type p
+		else
+			Codegen.PatternMatchConversion.to_typed_ast ctx dt p
 	with Exit ->
 		type_switch_old ctx e cases def with_type p
 
@@ -3269,9 +3272,9 @@ let generate ctx =
 				end
 			in
 			loop c
-		| TMatch (_,(enum,_),_,_) ->
+(* 		| TMatch (_,(enum,_),_,_) ->
 			loop_enum p enum;
-			iter (walk_expr p) e
+			iter (walk_expr p) e *)
 		| TCall (f,_) ->
 			iter (walk_expr p) e;
 			(* static call for initializing a variable *)