Переглянути джерело

[Refactor]: - removed redundant string argument from AccCall
- changed AKSet
- minimized occurences of FDynamic

Simon Krajewski 12 роки тому
батько
коміт
9f812cae85
14 змінених файлів з 92 додано та 127 видалено
  1. 2 2
      codegen.ml
  2. 9 7
      dce.ml
  3. 8 8
      genas3.ml
  4. 10 10
      gencommon.ml
  5. 11 9
      gencpp.ml
  6. 9 5
      genphp.ml
  7. 2 50
      genswf9.ml
  8. 1 1
      genxml.ml
  9. 1 1
      interp.ml
  10. 1 1
      std/haxe/macro/Type.hx
  11. 2 2
      std/sys/db/RecordMacros.hx
  12. 2 2
      type.ml
  13. 10 10
      typeload.ml
  14. 24 19
      typer.ml

+ 2 - 2
codegen.ml

@@ -95,10 +95,10 @@ let rec has_properties c =
 let get_properties fields =
 	List.fold_left (fun acc f ->
 		let acc = (match f.cf_kind with
-		| Var { v_read = AccCall getter } -> ("get_" ^ f.cf_name , getter) :: acc
+		| Var { v_read = AccCall } -> ("get_" ^ f.cf_name , "get_" ^ f.cf_name) :: acc
 		| _ -> acc) in
 		match f.cf_kind with
-		| Var { v_write = AccCall setter } -> ("set_" ^ f.cf_name , setter) :: acc
+		| Var { v_write = AccCall } -> ("set_" ^ f.cf_name , "set_" ^ f.cf_name) :: acc
 		| _ -> acc
 	) [] fields
 

+ 9 - 7
dce.ml

@@ -224,7 +224,7 @@ and field dce c n stat =
 		mark_field dce c cf stat;
 	with Not_found -> try
 		(* me might have a property access on an interface *)
-		let l = String.length n - 4 in
+ 		let l = String.length n - 4 in
 		if l < 0 then raise Not_found;
 		let prefix = String.sub n 0 4 in
 		let pn = String.sub n 4 l in
@@ -235,8 +235,8 @@ and field dce c n stat =
 				field dce c pn stat
 			in
 			(match prefix,cf.cf_kind with
-				| "get_",Var {v_read = AccCall s} when s = n -> keep()
-				| "set_",Var {v_write = AccCall s} when s = n -> keep()
+				| "get_",Var {v_read = AccCall} when "get_" ^ cf.cf_name = n -> keep()
+				| "set_",Var {v_write = AccCall} when "set_" ^ cf.cf_name = n -> keep()
 				| _ -> raise Not_found
 			);
 		end;
@@ -455,12 +455,14 @@ let run com main full =
 			in
 			let check_prop stat cf =
 				(match cf.cf_kind with
-				| Var {v_read = AccCall s; v_write = a} ->
-					cf.cf_kind <- Var {v_read = if has_accessor c s stat then AccCall s else AccNever; v_write = a}
+				| Var {v_read = AccCall; v_write = a} ->
+					let s = "get_" ^ cf.cf_name in
+					cf.cf_kind <- Var {v_read = if has_accessor c s stat then AccCall else AccNever; v_write = a}
 				| _ -> ());
 				(match cf.cf_kind with
-				| Var {v_write = AccCall s; v_read = a} ->
-					cf.cf_kind <- Var {v_write = if has_accessor c s stat then AccCall s else AccNever; v_read = a}
+				| Var {v_write = AccCall; v_read = a} ->
+					let s = "set_" ^ cf.cf_name in
+					cf.cf_kind <- Var {v_write = if has_accessor c s stat then AccCall else AccNever; v_read = a}
 				| _ -> ())
 			in
 			List.iter (check_prop true) c.cl_ordered_statics;

+ 8 - 8
genas3.ml

@@ -1013,11 +1013,11 @@ let generate_field ctx static f =
 				| Var v ->
 					(match v.v_read with
 					| AccNormal -> print ctx "function get %s() : %s;" id t;
-					| AccCall s -> print ctx "function %s() : %s;" s t;
+					| AccCall -> print ctx "function %s() : %s;" ("get_" ^ f.cf_name) t;
 					| _ -> ());
 					(match v.v_write with
 					| AccNormal -> print ctx "function set %s( __v : %s ) : void;" id t;
-					| AccCall s -> print ctx "function %s( __v : %s ) : %s;" s t t;
+					| AccCall -> print ctx "function %s( __v : %s ) : %s;" ("set_" ^ f.cf_name) t t;
 					| _ -> ());
 				| _ -> assert false)
 			| _ -> ()
@@ -1036,16 +1036,16 @@ let generate_field ctx static f =
 			| AccNormal | AccNo | AccNever ->
 				print ctx "%s function get %s() : %s { return $%s; }" rights id t id;
 				newline ctx
-			| AccCall m ->
-				print ctx "%s function get %s() : %s { return %s(); }" rights id t m;
+			| AccCall ->
+				print ctx "%s function get %s() : %s { return %s(); }" rights id t ("get_" ^ f.cf_name);
 				newline ctx
 			| _ -> ());
 			(match v.v_write with
 			| AccNormal | AccNo | AccNever ->
 				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" rights id t id;
 				newline ctx
-			| AccCall m ->
-				print ctx "%s function set %s( __v : %s ) : void { %s(__v); }" rights id t m;
+			| AccCall ->
+				print ctx "%s function set %s( __v : %s ) : void { %s(__v); }" rights id t ("set_" ^ f.cf_name);
 				newline ctx
 			| _ -> ());
 			print ctx "%sprotected var $%s : %s" (if static then "static " else "") (s_ident f.cf_name) (type_str ctx f.cf_type p);
@@ -1063,8 +1063,8 @@ let rec define_getset ctx stat c =
 		match f.cf_kind with
 		| Method _ -> ()
 		| Var v ->
-			(match v.v_read with AccCall m -> def f m | _ -> ());
-			(match v.v_write with AccCall m -> def f m | _ -> ())
+			(match v.v_read with AccCall -> def f ("get_" ^ f.cf_name) | _ -> ());
+			(match v.v_write with AccCall -> def f ("set_" ^ f.cf_name) | _ -> ())
 	in
 	List.iter field (if stat then c.cl_ordered_statics else c.cl_ordered_fields);
 	match c.cl_super with

+ 10 - 10
gencommon.ml

@@ -6995,10 +6995,10 @@ struct
             epos = pos;
           } in
           match cf.cf_kind with
-            | Var { v_write = AccCall fn } ->
+            | Var { v_write = AccCall } ->
               let bl =
               [
-                mk_this_call_raw fn (TFun(["value",false,cf.cf_type], cf.cf_type)) [ value_local ];
+                mk_this_call_raw ("set_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [ value_local ];
                 mk_return value_local
               ] in
               if Type.is_extern_field cf then
@@ -7049,13 +7049,13 @@ struct
 
          let get_field cf cf_type ethis cl name =
           match cf.cf_kind with
-            | Var { v_read = AccCall fn } when Type.is_extern_field cf ->
-              mk_return (mk_this_call_raw fn (TFun(["value",false,cf.cf_type], cf.cf_type)) [  ])
-            | Var { v_read = AccCall fn } ->
+            | Var { v_read = AccCall } when Type.is_extern_field cf ->
+              mk_return (mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [  ])
+            | Var { v_read = AccCall } ->
               {
                 eexpr = TIf(
                   handle_prop_local,
-                  mk_return (mk_this_call_raw fn (TFun(["value",false,cf.cf_type], cf.cf_type)) [  ]),
+                  mk_return (mk_this_call_raw ("get_" ^ cf.cf_name) (TFun(["value",false,cf.cf_type], cf.cf_type)) [  ]),
                   Some { eexpr = TField (ethis, FInstance(cl, cf)); etype = cf_type; epos = pos }
                 );
                 etype = cf_type;
@@ -9573,14 +9573,14 @@ struct
           match cf.cf_kind with
             | Var vkind ->
               (match vkind.v_read with
-                | AccCall str ->
-                  let newcf = mk_class_field str (TFun([],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in
+                | AccCall ->
+                  let newcf = mk_class_field ("get_" ^ cf.cf_name) (TFun([],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in
                   to_add := newcf :: !to_add;
                 | _ -> ()
               );
               (match vkind.v_write with
-                | AccCall str ->
-                  let newcf = mk_class_field str (TFun(["val",false,cf.cf_type],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in
+                | AccCall ->
+                  let newcf = mk_class_field ("set_" ^ cf.cf_name) (TFun(["val",false,cf.cf_type],cf.cf_type)) true cf.cf_pos (Method MethNormal) [] in
                   to_add := newcf :: !to_add;
                 | _ -> ()
               );

+ 11 - 9
gencpp.ml

@@ -2241,12 +2241,12 @@ let gen_member_def ctx class_def is_static is_interface field =
 			gen_type ctx field.cf_type;
 			output (" &" ^ remap_name ^ "_dyn() { return " ^ remap_name ^ ";}\n" )
 		| _ ->  (match field.cf_kind with
-			| Var { v_read = AccCall name } when (not is_static) && (is_dynamic_accessor name "get" field class_def) ->
+			| Var { v_read = AccCall } when (not is_static) && (is_dynamic_accessor ("get_" ^ field.cf_name) "get" field class_def) ->
 				output ("\t\tDynamic get_" ^ field.cf_name ^ ";\n" )
 			| _ -> ()
 			);
 			(match field.cf_kind with
-			| Var { v_write = AccCall name } when (not is_static) &&  (is_dynamic_accessor name "set" field class_def) ->
+			| Var { v_write = AccCall } when (not is_static) &&  (is_dynamic_accessor ("set_" ^ field.cf_name) "set" field class_def) ->
 				output ("\t\tDynamic set_" ^ field.cf_name ^ ";\n" )
 			| _ -> ()
 			)
@@ -2913,9 +2913,11 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 				let remap_name = keyword_remap field.cf_name in
 				output_cpp ("	" ^ macro ^ "(" ^ remap_name ^ ",\"" ^ field.cf_name^ "\");\n");
 
-					(match field.cf_kind with Var { v_read = AccCall name } when (is_dynamic_accessor name "get" field class_def) ->
+					(match field.cf_kind with Var { v_read = AccCall } when (is_dynamic_accessor ("get_" ^ field.cf_name) "get" field class_def) ->
+						let name = "get_" ^ field.cf_name in
 						output_cpp ("\t" ^ macro ^ "(" ^ name ^ "," ^ "\"" ^ name ^ "\");\n" ) | _ -> ());
-					(match field.cf_kind with Var { v_write = AccCall name } when  (is_dynamic_accessor name "set" field class_def) ->
+					(match field.cf_kind with Var { v_write = AccCall } when  (is_dynamic_accessor ("set_" ^ field.cf_name) "set" field class_def) ->
+						let name = "set_" ^ field.cf_name in
 						output_cpp ("\t" ^ macro ^ "(" ^ name ^ "," ^ "\"" ^ name ^ "\");\n" ) | _ -> ());
 				end
 		in
@@ -2984,8 +2986,8 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 		let get_field_dat = List.map (fun f ->
 			(f.cf_name, String.length f.cf_name, "return " ^
 				(match f.cf_kind with
-				| Var { v_read = AccCall prop } when is_extern_field f -> (keyword_remap prop) ^ "()"
-				| Var { v_read = AccCall prop } -> "inCallProp ? " ^ (keyword_remap prop) ^ "() : " ^
+				| Var { v_read = AccCall } when is_extern_field f -> (keyword_remap ("get_" ^ f.cf_name)) ^ "()"
+				| Var { v_read = AccCall } -> "inCallProp ? " ^ (keyword_remap ("get_" ^ f.cf_name)) ^ "() : " ^
 				        ((keyword_remap f.cf_name) ^ if (variable_field f) then "" else "_dyn()")
 				| _ -> ((keyword_remap f.cf_name) ^ if (variable_field f) then "" else "_dyn()")
 				) ^ ";"
@@ -3014,7 +3016,7 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 				output_cpp ("	if (inFieldID==__id_" ^ remap_name ^ ") return "  ^
 					( if (return_type="Float") then "hx::ToDouble( " else "" ) ^
 					(match f.cf_kind with
-					| Var { v_read = AccCall prop } -> (keyword_remap prop) ^ "()"
+					| Var { v_read = AccCall } -> (keyword_remap ("get_" ^ f.cf_name)) ^ "()"
 					| _ -> ((keyword_remap f.cf_name) ^ if ( variable_field f) then "" else "_dyn()")
 					) ^ ( if (return_type="Float") then " ) " else "" ) ^ ";\n");
 				) in
@@ -3038,8 +3040,8 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
                " return inValue;" in
 			(f.cf_name, String.length f.cf_name,
 				(match f.cf_kind with
-				| Var { v_write = AccCall prop } when is_extern_field f -> "return " ^ (keyword_remap prop) ^ "(inValue);"
-				| Var { v_write = AccCall prop } -> "if (inCallProp) return " ^ (keyword_remap prop) ^ "(inValue);"
+				| Var { v_write = AccCall } when is_extern_field f -> "return " ^ (keyword_remap ("set_" ^ f.cf_name)) ^ "(inValue);"
+				| Var { v_write = AccCall } -> "if (inCallProp) return " ^ (keyword_remap ("set_" ^ f.cf_name)) ^ "(inValue);"
 					 ^ default_action
             | _ -> default_action
 				)

+ 9 - 5
genphp.ml

@@ -229,8 +229,8 @@ let to_string_null ctx e =
 	let v = alloc_var "__call__" t_dynamic in
 	let f = mk (TLocal v) t_dynamic e.epos in
 	mk (TCall (f, [ Codegen.string ctx.com "_hx_string_or_null" e.epos; e])) ctx.com.basic.tstring e.epos
-	
-	
+
+
 let as_string_expr ctx e =	match e.eexpr with
 	| TConst (TNull) ->  to_string ctx e
 	| TConst (TString s) -> e
@@ -1887,7 +1887,9 @@ let generate_field ctx static f =
 			(match f.cf_kind with
 			| Var v ->
 				(match v.v_read, v.v_write with
-				| AccCall m1, AccCall m2 ->
+				| AccCall, AccCall ->
+					let m1 = "get_" ^ f.cf_name in
+					let m2 = "set_" ^ f.cf_name in
 					if not (is_method_defined ctx m1 static) then (
 						generate_self_method ctx rights m1 static false;
 						print ctx "%s $%s" rights (s_ident m1);
@@ -1898,12 +1900,14 @@ let generate_field ctx static f =
 						print ctx "%s $%s" rights (s_ident m2);
 						newline ctx);
 					false
-				| AccCall m, _ ->
+				| AccCall, _ ->
+					let m = "get_" ^ f.cf_name in
 					if not (is_method_defined ctx m static) then generate_self_method ctx rights m static false;
 					print ctx "%s $%s" rights (s_ident_field f.cf_name);
 					gen_assigned_value ctx f.cf_expr;
 					true
-				| _, AccCall m ->
+				| _, AccCall ->
+					let m = "set_" ^ f.cf_name in
 					if not (is_method_defined ctx m static) then generate_self_method ctx rights m static true;
 					print ctx "%s $%s" rights (s_ident_field f.cf_name);
 					gen_assigned_value ctx f.cf_expr;

+ 2 - 50
genswf9.ml

@@ -2074,56 +2074,8 @@ let generate_class ctx c =
 		match f.cf_kind with
 		| Method _ -> acc
 		| Var v ->
-			let p = f.cf_pos in
-			let ethis = mk (TConst TThis) (TInst (c,[])) p in
-			let acc = (match v.v_read with
-				| AccCall n when n <> "get_" ^ f.cf_name ->
-					(* generate get_xxx method *)
-					let m = if c.cl_interface then
-						end_fun ctx [] None f.cf_type
-					else
-						let fk = begin_fun ctx [] f.cf_type [ethis] false p in
-						gen_expr ctx false (mk (TReturn (Some (mk (TCall (mk (TField (ethis,FDynamic n)) t_dynamic p,[])) f.cf_type p))) t_dynamic p);
-						fk()
-					in
-					{
-						hlf_name = ident ("get_" ^ f.cf_name);
-						hlf_slot = alloc_slot();
-						hlf_kind = HFMethod {
-							hlm_type = m;
-							hlm_final = false;
-							hlm_override = false;
-							hlm_kind = MK3Normal;
-						};
-						hlf_metas = None;
-					} :: acc
-				| _ ->
-					acc
-			) in
-			let acc = (match v.v_write with
-				| AccCall n when n <> "set_" ^ f.cf_name ->
-					(* generatee set_xxx method *)
-					let v = alloc_var "tmp" f.cf_type in
-					let m = if c.cl_interface then
-						end_fun ctx [v,None] None f.cf_type
-					else
-						let fk = begin_fun ctx [v,None] f.cf_type [ethis] false p in
-						gen_expr ctx false (mk (TReturn (Some (mk (TCall (mk (TField (ethis,FDynamic n)) t_dynamic p,[mk (TLocal v) v.v_type p])) f.cf_type p))) t_dynamic p);
-						fk()
-					in
-					{
-						hlf_name = ident ("set_" ^ f.cf_name);
-						hlf_slot = alloc_slot();
-						hlf_kind = HFMethod {
-							hlm_type = m;
-							hlm_final = false;
-							hlm_override = false;
-							hlm_kind = MK3Normal;
-						};
-						hlf_metas = None;
-					} :: acc
-				| _ -> acc
-			) in
+			(* let p = f.cf_pos in *)
+			(* let ethis = mk (TConst TThis) (TInst (c,[])) p in *)
 			acc
 	in
 	let fields = PMap.fold (fun f acc ->

+ 1 - 1
genxml.ml

@@ -120,7 +120,7 @@ and gen_field att f =
 		match acc with
 		| AccNormal | AccResolve | AccRequire _ -> att
 		| AccNo | AccNever -> (name, "null") :: att
-		| AccCall m -> (name,m) :: att
+		| AccCall -> (name,"accessor") :: att
 		| AccInline -> (name,"inline") :: att
 	in
 	let att = (match f.cf_expr with None -> att | Some e -> ("line",string_of_int (Lexer.get_error_line e.epos)) :: att) in

+ 1 - 1
interp.ml

@@ -4129,7 +4129,7 @@ and encode_var_access a =
 		| AccNo -> 1, []
 		| AccNever -> 2, []
 		| AccResolve -> 3, []
-		| AccCall s -> 4, [enc_string s]
+		| AccCall -> 4, []
 		| AccInline	-> 5, []
 		| AccRequire (s,msg) -> 6, [enc_string s; null enc_string msg]
 	) in

+ 1 - 1
std/haxe/macro/Type.hx

@@ -131,7 +131,7 @@ enum VarAccess {
 	AccNo;
 	AccNever;
 	AccResolve;
-	AccCall( m : String );
+	AccCall;
 	AccInline;
 	AccRequire( r : String, ?msg : String );
 }

+ 2 - 2
std/sys/db/RecordMacros.hx

@@ -296,7 +296,7 @@ class RecordMacros {
 					continue;
 				// handle relations
 				if( f.meta.has(":relation") ) {
-					if( !Type.enumEq(g,AccCall("get_" + f.name)) || !Type.enumEq(s,AccCall("set_" + f.name)) )
+					if( !Type.enumEq(g,AccCall) || !Type.enumEq(s,AccCall) )
 						error("Relation should be (dynamic,dynamic)", f.pos);
 					for( m in f.meta.get() ) {
 						if( m.name != ":relation" ) continue;
@@ -327,7 +327,7 @@ class RecordMacros {
 					continue;
 				}
 				switch( g ) {
-				case AccCall(_):
+				case AccCall:
 					if( !f.meta.has(":data") )
 						error("Relation should be defined with @:relation(key)", f.pos);
 				default:

+ 2 - 2
type.ml

@@ -38,7 +38,7 @@ and var_access =
 	| AccNo				(* can't be accessed outside of the class itself and its subclasses *)
 	| AccNever			(* can't be accessed, even in subclasses *)
 	| AccResolve		(* call resolve("field") when accessed *)
-	| AccCall of string (* perform a method call when accessed *)
+	| AccCall			(* perform a method call when accessed *)
 	| AccInline			(* similar to Normal but inline when accessed *)
 	| AccRequire of string * string option (* set when @:require(cond) fails *)
 
@@ -466,7 +466,7 @@ let s_access = function
 	| AccNo -> "null"
 	| AccNever -> "never"
 	| AccResolve -> "resolve"
-	| AccCall m -> m
+	| AccCall -> "accessor"
 	| AccInline	-> "inline"
 	| AccRequire (n,_) -> "require " ^ n
 

+ 10 - 10
typeload.ml

@@ -464,11 +464,11 @@ and load_complex_type ctx p t =
 						| "null" -> AccNo
 						| "never" -> AccNever
 						| "default" -> AccNormal
-						| "dynamic" -> AccCall ((if get then "get_"  else "set_") ^ n)
-						| "get" when get -> AccCall ("get_" ^ n)
-						| "set" when not get -> AccCall ("set_" ^ n)
-						| x when get && x = "get_" ^ n -> AccCall x
-						| x when not get && x = "set_" ^ n -> AccCall x
+						| "dynamic" -> AccCall
+						| "get" when get -> AccCall
+						| "set" when not get -> AccCall
+						| x when get && x = "get_" ^ n -> AccCall
+						| x when not get && x = "set_" ^ n -> AccCall
 						| _ ->
 							error "Custom property access is no longer supported in Haxe 3" f.cff_pos;
 					in
@@ -1587,13 +1587,13 @@ let init_class ctx c p context_init herits fields =
 			in
 			let get = (match get with
 				| "null" -> AccNo
-				| "dynamic" -> AccCall ("get_" ^ name)
+				| "dynamic" -> AccCall
 				| "never" -> AccNever
 				| "default" -> AccNormal
 				| _ ->
 					let get = if get = "get" then "get_" ^ name else get in
 					delay ctx PForce (fun() -> check_method get t_get (if get <> "get" && get <> "get_" ^ name then Some ("get_" ^ name) else None));
-					AccCall get
+					AccCall
 			) in
 			let set = (match set with
 				| "null" ->
@@ -1603,14 +1603,14 @@ let init_class ctx c p context_init herits fields =
 					else
 						AccNo
 				| "never" -> AccNever
-				| "dynamic" -> AccCall ("set_" ^ name)
+				| "dynamic" -> AccCall
 				| "default" -> AccNormal
 				| _ ->
 					let set = if set = "set" then "set_" ^ name else set in
 					delay ctx PForce (fun() -> check_method set t_set (if set <> "set" && set <> "set_" ^ name then Some ("set_" ^ name) else None));
-					AccCall set
+					AccCall
 			) in
-			if set = AccNormal && (match get with AccCall _ -> true | _ -> false) then error "Unsupported property combination" p;
+			if set = AccNormal && (match get with AccCall -> true | _ -> false) then error "Unsupported property combination" p;
 			let cf = {
 				cf_name = name;
 				cf_doc = f.cff_doc;

+ 24 - 19
typer.ml

@@ -45,7 +45,7 @@ type access_kind =
 	| AKNo of string
 	| AKExpr of texpr
 	| AKField of texpr * tclass_field * tfield_access
-	| AKSet of texpr * string * t * string
+	| AKSet of texpr * t * tclass_field
 	| AKInline of texpr * tclass_field * tfield_access * t
 	| AKMacro of texpr * tclass_field
 	| AKUsing of texpr * tclass * tclass_field * texpr
@@ -96,6 +96,10 @@ let rec classify t =
 	| TDynamic _ -> KDyn
 	| _ -> KOther
 
+let quick_field_dynamic t s =
+	try quick_field t s
+	with Not_found -> FDynamic s
+
 let object_field f =
 	let pf = Parser.quoted_ident_prefix in
 	let pflen = String.length pf in
@@ -833,7 +837,8 @@ let field_access ctx mode f fmode t e p =
 				AKExpr (mk (TField (e,FClosure (None,f))) t p)
 			else
 				normal()
-		| AccCall m ->
+		| AccCall ->
+			let m = (match mode with MSet -> "set_" | _ -> "get_") ^ f.cf_name in
 			if m = ctx.curfield.cf_name && (match e.eexpr with TConst TThis -> true | TTypeExpr (TClassDecl c) when c == ctx.curclass -> true | _ -> false) then
 				let prefix = (match ctx.com.platform with Flash when Common.defined ctx.com Define.As3 -> "$" | _ -> "") in
 				if is_extern_field f then begin
@@ -852,11 +857,11 @@ let field_access ctx mode f fmode t e p =
 					let ef = mk (TField (e,FStatic (c,f))) t p in
 					AKUsing (ef,c,f,this)
 				end else
-					AKExpr (make_call ctx (mk (TField (e,FDynamic m)) (tfun [this.etype] t) p) [this] t p)
+					AKExpr (make_call ctx (mk (TField (e,quick_field_dynamic e.etype m)) (tfun [this.etype] t) p) [this] t p)
 			end else if mode = MSet then
-				AKSet (e,m,t,f.cf_name)
+				AKSet (e,t,f)
 			else
-				AKExpr (make_call ctx (mk (TField (e,FDynamic m)) (tfun [] t) p) [] t p)
+				AKExpr (make_call ctx (mk (TField (e,quick_field_dynamic e.etype m)) (tfun [] t) p) [] t p)
 		| AccResolve ->
 			let fstring = mk (TConst (TString f.cf_name)) ctx.t.tstring p in
 			let tresolve = tfun [ctx.t.tstring] t in
@@ -1170,15 +1175,15 @@ and type_field ctx e i p mode =
 			let et = type_module_type ctx (TClassDecl c) None p in
 			let field_expr f t = mk (TField (et,FStatic (c,f))) t p in
 			(match mode, f.cf_kind with
-			| MGet, Var {v_read = AccCall s} ->
+			| MGet, Var {v_read = AccCall } ->
 				(* getter call *)
-				let f = PMap.find s c.cl_statics in
+				let f = PMap.find ("get_" ^ f.cf_name) c.cl_statics in
 				let t = field_type f in
 				let r = match follow t with TFun(_,r) -> r | _ -> raise Not_found in
 				let ef = field_expr f r in
 				AKExpr(make_call ctx ef [e] r p)
-			| MSet, Var {v_write = AccCall s} ->
-				let f = PMap.find s c.cl_statics in
+			| MSet, Var {v_write = AccCall } ->
+				let f = PMap.find ("set_" ^ f.cf_name) c.cl_statics in
 				let t = field_type f in
 				let ef = field_expr f t in
 				AKUsing (ef,c,f,e)
@@ -1384,7 +1389,7 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
 	match op with
 	| OpAssign ->
 		let e1 = type_access ctx (fst e1) (snd e1) MSet in
-		let tt = (match e1 with AKNo _ | AKInline _ | AKUsing _ | AKMacro _ | AKAccess _ -> Value | AKSet(_,_,t,_) -> WithType t | AKExpr e | AKField (e,_,_) -> WithType e.etype) in
+		let tt = (match e1 with AKNo _ | AKInline _ | AKUsing _ | AKMacro _ | AKAccess _ -> Value | AKSet(_,t,_) -> WithType t | AKExpr e | AKField (e,_,_) -> WithType e.etype) in
 		let e2 = type_expr ctx e2 tt in
 		(match e1 with
 		| AKNo s -> error ("Cannot access field or identifier " ^ s ^ " for writing") p
@@ -1397,9 +1402,9 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
 				error "Assigning a value to itself" p
 			| _ , _ -> ());
 			mk (TBinop (op,e1,e2)) e1.etype p
-		| AKSet (e,m,t,_) ->
+		| AKSet (e,t,cf) ->
 			unify ctx e2.etype t p;
-			make_call ctx (mk (TField (e,FDynamic m)) (tfun [t] t) p) [e2] t p
+			make_call ctx (mk (TField (e,quick_field_dynamic e.etype ("set_" ^ cf.cf_name))) (tfun [t] t) p) [e2] t p
 		| AKAccess(ebase,ekey) ->
 			let a,pl,c = match follow ebase.etype with TAbstract({a_impl = Some c} as a,pl) -> a,pl,c | _ -> error "Invalid operation" p in
 			let cf,tf,r =
@@ -1438,16 +1443,16 @@ let rec type_binop ctx op e1 e2 is_assign_op p =
 				(* this must be an abstract cast *)
 				check_assign ctx e;
 				eop)
-		| AKSet (e,m,t,f) ->
+		| AKSet (e,t,cf) ->
 			let l = save_locals ctx in
 			let v = gen_local ctx e.etype in
 			let ev = mk (TLocal v) e.etype p in
-			let get = type_binop ctx op (EField ((EConst (Ident v.v_name),p),f),p) e2 true p in
+			let get = type_binop ctx op (EField ((EConst (Ident v.v_name),p),cf.cf_name),p) e2 true p in
 			unify ctx get.etype t p;
 			l();
 			mk (TBlock [
 				mk (TVars [v,Some e]) ctx.t.tvoid p;
-				make_call ctx (mk (TField (ev,FDynamic m)) (tfun [t] t) p) [get] t p
+				make_call ctx (mk (TField (ev,quick_field_dynamic ev.etype ("set_" ^ cf.cf_name))) (tfun [t] t) p) [get] t p
 			]) t p
  		| AKUsing(ef,c,cf,et) ->
  			(* abstract setter + getter *)
@@ -1803,13 +1808,13 @@ and type_unop ctx op flag e p =
 		error ("The field or identifier " ^ s ^ " is not accessible for " ^ (if set then "writing" else "reading")) p
 	| AKInline _ | AKUsing _ | AKMacro _ | AKAccess _ ->
 		error "This kind of operation is not supported" p
-	| AKSet (e,m,t,f) ->
+	| AKSet (e,t,cf) ->
 		let l = save_locals ctx in
 		let v = gen_local ctx e.etype in
 		let ev = mk (TLocal v) e.etype p in
 		let op = (match op with Increment -> OpAdd | Decrement -> OpSub | _ -> assert false) in
 		let one = (EConst (Int "1"),p) in
-		let eget = (EField ((EConst (Ident v.v_name),p),f),p) in
+		let eget = (EField ((EConst (Ident v.v_name),p),cf.cf_name),p) in
 		match flag with
 		| Prefix ->
 			let get = type_binop ctx op eget one false p in
@@ -1817,7 +1822,7 @@ and type_unop ctx op flag e p =
 			l();
 			mk (TBlock [
 				mk (TVars [v,Some e]) ctx.t.tvoid p;
-				make_call ctx (mk (TField (ev,FDynamic m)) (tfun [t] t) p) [get] t p
+				make_call ctx (mk (TField (ev,quick_field_dynamic ev.etype ("set_" ^ cf.cf_name))) (tfun [t] t) p) [get] t p
 			]) t p
 		| Postfix ->
 			let v2 = gen_local ctx t in
@@ -1828,7 +1833,7 @@ and type_unop ctx op flag e p =
 			l();
 			mk (TBlock [
 				mk (TVars [v,Some e; v2,Some get]) ctx.t.tvoid p;
-				make_call ctx (mk (TField (ev,FDynamic m)) (tfun [plusone.etype] t) p) [plusone] t p;
+				make_call ctx (mk (TField (ev,quick_field_dynamic ev.etype ("set_" ^ cf.cf_name))) (tfun [plusone.etype] t) p) [plusone] t p;
 				ev2
 			]) t p