Browse Source

remove TMatch reminiscents

Dan Korostelev 9 years ago
parent
commit
4bcf0a3c2f
3 changed files with 11 additions and 49 deletions
  1. 5 34
      src/generators/gencommon.ml
  2. 6 13
      src/generators/gencpp.ml
  3. 0 2
      src/generators/genjava.ml

+ 5 - 34
src/generators/gencommon.ml

@@ -5174,8 +5174,6 @@ 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) } *)
 			| TReturn(eopt) ->
 				{ expr with eexpr = TReturn(Option.map fn eopt) }
 			| TThrow (texpr) ->
@@ -5367,8 +5365,6 @@ 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) } *)
 			| 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) ->
@@ -5674,8 +5670,6 @@ 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) } *)
 				| 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) ->
@@ -6812,8 +6806,6 @@ struct
 					{ e with eexpr = TWhile (handle (run econd) gen.gcon.basic.tbool econd.etype, (in_value := false; 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, (in_value := false; run (mk_block e)))) el_e_l, Option.map (fun e -> in_value := false; 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, (in_value := false; run (mk_block e1))) }
 				| TTry (e, ve_l) ->
@@ -8771,16 +8763,11 @@ end;;
 	enums into normal classes. This is done at the first module pass by creating new classes with the same
 	path inside the modules, and removing the actual enum module by setting it as en extern.
 
-	Later, on the last expression pass, it will transform the TMatch codes into TSwitch. it will introduce a new
-	dependency, though:
-		* The target must create its own strategy to deal with reflection. As it is right now, we will have a base class
-		which the class will extend, create @:$IsEnum metadata for the class, and create @:alias() metadatas for the fields,
-		with their tag order (as a string) as their alias. If you are using ReflectionCFs, then you don't have to worry
-		about that, as it's already generating all information needed by the haxe runtime.
-		so they can be
-
-	dependencies:
-		The MatchToSwitch part must run after ExprStatementUnwrap as modified expressions might confuse it (not so true anymore)
+	* The target must create its own strategy to deal with reflection. As it is right now, we will have a base class
+	which the class will extend, create @:$IsEnum metadata for the class, and create @:alias() metadatas for the fields,
+	with their tag order (as a string) as their alias. If you are using ReflectionCFs, then you don't have to worry
+	about that, as it's already generating all information needed by the haxe runtime.
+	so they can be
 
 *)
 
@@ -9014,8 +9001,6 @@ struct
 
 		Enum to class Expression Filter
 
-		will convert TMatch into TSwitch
-
 		dependencies:
 			Should run before TArrayTransform, since it generates array access expressions
 
@@ -10097,18 +10082,6 @@ 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) ->
-					let def, k = process_expr def in
-					let def = handle_case (def, k) in
-					let k = ref k in
-					let ret = { expr with eexpr = TMatch(cond, ep, List.map (fun (il, vopt, e) ->
-						let e, ek = process_expr e in
-						k := aggregate_kind !k ek;
-						(il, vopt, handle_case (e, ek))
-					) il_vopt_e_l, Some def) } in
-					ret, !k *)
 				| TTry (e, catches) ->
 					let e, k = process_expr e in
 					let k = ref k in
@@ -10527,8 +10500,6 @@ 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) } *)
 				| 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) ->

+ 6 - 13
src/generators/gencpp.ml

@@ -210,7 +210,7 @@ type context =
 
    ctx_interface_slot : (string,int) Hashtbl.t ref;
    ctx_interface_slot_count : int ref;
-   (* This is for returning from the child nodes of TMatch, TSwitch && TTry *)
+   (* This is for returning from the child nodes of TSwitch && TTry *)
    mutable ctx_real_this_ptr : bool;
    mutable ctx_class_member_types : (string,string) Hashtbl.t;
 }
@@ -1912,7 +1912,7 @@ let cpp_cast_variant_type_of t = match t with
    | TCppScalarArray _
    | TCppDynamicArray
    | TCppClass
-   | TCppEnum _ 
+   | TCppEnum _
    | TCppInst _ -> t
    | _ -> cpp_variant_type_of t;
 ;;
@@ -3304,7 +3304,7 @@ let gen_cpp_ast_expression_tree ctx class_name func_name function_args injection
          | TCppClass
          | TCppEnum _
          | TCppInst _ -> out (".StaticCast< " ^ (tcpp_to_string valueType ) ^ " >()")
-         | _ ->() 
+         | _ ->()
          )
 
       | CppIntSwitch(condition, cases, defVal) ->
@@ -3681,7 +3681,7 @@ let all_virtual_functions clazz =
 let rec unreflective_type t =
     match follow t with
        | TInst (klass,_) ->  Meta.has Meta.Unreflective klass.cl_meta
-       | TFun (args,ret) -> 
+       | TFun (args,ret) ->
            List.fold_left (fun result (_,_,t) -> result || (unreflective_type t)) (unreflective_type ret) args;
        | _ -> false
 ;;
@@ -3710,7 +3710,7 @@ let native_field_name_remap is_static field =
    if not is_static then
       remap_name
    else begin
-      let nativeImpl = get_meta_string field.cf_meta Meta.Native in 
+      let nativeImpl = get_meta_string field.cf_meta Meta.Native in
       if nativeImpl<>"" then begin
          let r = Str.regexp "^[a-zA-Z_0-9]+$" in
             if Str.string_match r remap_name 0 then
@@ -3743,7 +3743,7 @@ let gen_field ctx class_def class_name ptr_name dot_name is_static is_interface
 
       if (not (is_dynamic_haxe_method field)) then begin
          (* The actual function definition *)
-         let nativeImpl = get_meta_string field.cf_meta Meta.Native in 
+         let nativeImpl = get_meta_string field.cf_meta Meta.Native in
          let remap_name = native_field_name_remap is_static field in
          output (if is_void then "void" else return_type );
          output (" " ^ class_name ^ "::" ^ remap_name ^ "(" );
@@ -4044,13 +4044,6 @@ let find_referenced_types_flags ctx obj super_deps constructor_deps header_only
             (* Must visit the types, Type.iter will visit the expressions ... *)
             | 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,_) ->
-               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; *)
             (* Must visit type too, Type.iter will visit the expressions ... *)
             | TNew  (klass,params,_) -> begin
                visit_type (TInst (klass,params));

+ 0 - 2
src/generators/genjava.ml

@@ -337,8 +337,6 @@ 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 *)
 			| TIf (_,eif, Some eelse) ->
 				is_final_return_expr eif && is_final_return_expr eelse
 			| TFor (_,_,e) ->