Sfoglia il codice sorgente

changed cf_get & cf_set to cf_kind

Nicolas Cannasse 15 anni fa
parent
commit
91028fb7e8
14 ha cambiato i file con 299 aggiunte e 238 eliminazioni
  1. 4 5
      codegen.ml
  2. 31 23
      genas3.ml
  3. 15 16
      gencpp.ml
  4. 1 1
      genjs.ml
  5. 3 1
      genneko.ml
  6. 35 35
      genphp.ml
  7. 1 1
      genswf8.ml
  8. 12 10
      genswf9.ml
  9. 12 6
      genxml.ml
  10. 1 1
      optimizer.ml
  11. 79 44
      type.ml
  12. 14 4
      typecore.ml
  13. 34 40
      typeload.ml
  14. 57 51
      typer.ml

+ 4 - 5
codegen.ml

@@ -244,8 +244,7 @@ let extend_xml_proxy ctx c t file p =
 						cf_public = true;
 						cf_doc = None;
 						cf_meta = no_meta;
-						cf_get = ResolveAccess;
-						cf_set = NoAccess;
+						cf_kind = Var { v_read = AccResolve; v_write = AccNo };
 						cf_params = [];
 						cf_expr = None;
 					} in
@@ -927,8 +926,8 @@ let fix_overrides com t =
 	match com.platform, t with
 	| Flash9, TClassDecl c ->
 		c.cl_ordered_fields <- List.map (fun f ->
-			match f.cf_expr with
-			| Some { eexpr = TFunction fd } when f.cf_set <> NormalAccess && f.cf_set <> MethodAccess true ->
+			match f.cf_expr, f.cf_kind with
+			| Some { eexpr = TFunction fd }, Method (MethNormal | MethInline) ->
 				fix_override c f fd
 			| _ ->
 				f
@@ -1060,7 +1059,7 @@ let dump_types com =
 		| Type.TClassDecl c ->
 			let print_field stat f =
 				print "\t%s%s%s%s" (if stat then "static " else "") (if f.cf_public then "public " else "") f.cf_name (params f.cf_params);
-				print "(%s,%s) : %s" (s_access f.cf_get) (s_access f.cf_set) (s_type f.cf_type);
+				print "(%s) : %s" (s_kind f.cf_kind) (s_type f.cf_type);
 				(match f.cf_expr with
 				| None -> ()
 				| Some e -> print "\n\n\t = %s" (Type.s_expr s_type e));

+ 31 - 23
genas3.ml

@@ -835,8 +835,8 @@ let generate_field ctx static f =
 	let public = f.cf_public || Hashtbl.mem ctx.get_sets (f.cf_name,static) || (f.cf_name = "main" && static) || f.cf_name = "resolve" in
 	let rights = (if static then "static " else "") ^ (if public then "public" else "protected") in
 	let p = ctx.curclass.cl_pos in
-	match f.cf_expr with
-	| Some { eexpr = TFunction fd } when f.cf_set = MethodAccess false || f.cf_set = NeverAccess ->
+	match f.cf_expr, f.cf_kind with
+	| Some { eexpr = TFunction fd }, Method (MethNormal | MethInline) ->
 		print ctx "%s " rights;
 		let rec loop c =
 			match c.cl_super with
@@ -853,6 +853,7 @@ let generate_field ctx static f =
 		h();
 		newline ctx
 	| _ ->
+		let is_getset = (match f.cf_kind with Var { v_read = AccCall _ } | Var { v_write = AccCall _ } -> true | _ -> false) in
 		if ctx.curclass.cl_path = (["flash"],"Boot") && f.cf_name = "init" then
 			generate_boot_init ctx
 		else if ctx.curclass.cl_interface then
@@ -865,41 +866,45 @@ let generate_field ctx static f =
 					if o then print ctx " = %s" (default_value tstr);
 				) args;
 				print ctx ") : %s " (type_str ctx r p);
-			| _ when (match f.cf_get with CallAccess m -> true | _ -> match f.cf_set with CallAccess m -> true | _ -> false) -> 
+			| _ when is_getset -> 
 				let t = type_str ctx f.cf_type p in
 				let id = s_ident f.cf_name in
-				(match f.cf_get with
-				| NormalAccess | CallAccess _ -> print ctx "function get %s() : %s;" id t;
-				| _ -> ());
-				(match f.cf_set with
-				| NormalAccess | CallAccess _ -> print ctx "function set %s( __v : %s ) : void;" id t;
-				| _ -> ());
+				(match f.cf_kind with
+				| Var v ->
+					(match v.v_read with
+					| AccNormal | AccCall _ -> print ctx "function get %s() : %s;" id t;
+					| _ -> ());
+					(match v.v_write with
+					| AccNormal | AccCall _ -> print ctx "function set %s( __v : %s ) : void;" id t;
+					| _ -> ());
+				| _ -> assert false)
 			| _ -> ()
 		else
-		if (match f.cf_get with CallAccess m -> true | _ -> match f.cf_set with CallAccess m -> true | _ -> false) then begin
+		if is_getset then begin
 			let t = type_str ctx f.cf_type p in
 			let id = s_ident f.cf_name in
-			(match f.cf_get with
-			| NormalAccess ->
+			let v = (match f.cf_kind with Var v -> v | _ -> assert false) in
+			(match v.v_read with
+			| AccNormal ->
 				print ctx "%s function get %s() : %s { return $%s; }" rights id t id;
 				newline ctx
-			| CallAccess m ->
+			| AccCall m ->
 				print ctx "%s function get %s() : %s { return %s(); }" rights id t m;
 				newline ctx
-			| NoAccess | NeverAccess ->
-				print ctx "%s function get %s() : %s { return $%s; }" (if f.cf_set = NoAccess then "protected" else "private") id t id;
+			| AccNo | AccNever ->
+				print ctx "%s function get %s() : %s { return $%s; }" (if v.v_read = AccNo then "protected" else "private") id t id;
 				newline ctx
 			| _ ->
 				());
-			(match f.cf_set with
-			| NormalAccess ->
+			(match v.v_write with
+			| AccNormal ->
 				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" rights id t id;
 				newline ctx
-			| CallAccess m ->
+			| AccCall m ->
 				print ctx "%s function set %s( __v : %s ) : void { %s(__v); }" rights id t m;
 				newline ctx
-			| NoAccess | NeverAccess ->
-				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" (if f.cf_set = NoAccess then "protected" else "private") id t id;
+			| AccNo | AccNever ->
+				print ctx "%s function set %s( __v : %s ) : void { $%s = __v; }" (if v.v_write = AccNo then "protected" else "private") id t id;
 				newline ctx
 			| _ -> ());
 			print ctx "protected var $%s : %s" (s_ident f.cf_name) (type_str ctx f.cf_type p);
@@ -917,8 +922,11 @@ let rec define_getset ctx stat c =
 		Hashtbl.add ctx.get_sets (name,stat) f.cf_name
 	in
 	let field f =
-		(match f.cf_get with CallAccess m -> def f m | _ -> ());
-		(match f.cf_set with CallAccess m -> def f m | _ -> ())
+		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 | _ -> ())
 	in
 	List.iter field (if stat then c.cl_ordered_statics else c.cl_ordered_fields);
 	match c.cl_super with
@@ -949,7 +957,7 @@ let generate_class ctx c =
 		let f = { f with
 			cf_name = snd c.cl_path;
 			cf_public = true;
-			cf_set = MethodAccess false;
+			cf_kind = Method MethNormal;
 		} in
 		ctx.constructor_block <- true;
 		generate_field ctx false f;

+ 15 - 16
gencpp.ml

@@ -17,9 +17,9 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *)
+open Ast
 open Type
 open Common
-open Ast
 
 
 (*
@@ -1607,9 +1607,8 @@ let is_dynamic_method f =
 *)
 
 let is_dynamic_method f =
-		(match f.cf_expr with
-		| Some { eexpr = TFunction fd } when f.cf_set = MethodAccess true -> true
-		| Some { eexpr = TFunction fd } when f.cf_set = NormalAccess -> true
+		(match f.cf_expr, f.cf_kind with
+		| Some { eexpr = TFunction _ }, (Var _ | Method MethDynamic) -> true
 		| _ -> false);;
 
 
@@ -1851,13 +1850,13 @@ let gen_member_def ctx class_def is_static is_extern is_interface field =
 			output "	";
 			gen_type ctx field.cf_type;
 			output (" &" ^ remap_name ^ "_dyn() { return " ^ remap_name ^ ";}\n" )
-		| _ ->  (match field.cf_get with
-			| CallAccess name when (is_dynamic_accessor name "get" field class_def) ->
+		| _ ->  (match field.cf_kind with
+			| Var { v_read = AccCall name } when (is_dynamic_accessor name "get" field class_def) ->
 				output ("\t\tDynamic get_" ^ field.cf_name ^ ";\n" )
 			| _ -> ()
 			);
-			(match field.cf_set with
-			| CallAccess name when  (is_dynamic_accessor name "set" field class_def) ->
+			(match field.cf_kind with
+			| Var { v_write = AccCall name } when  (is_dynamic_accessor name "set" field class_def) ->
 				output ("\t\tDynamic set_" ^ field.cf_name ^ ";\n" )
 			| _ -> ()
 			)
@@ -2416,9 +2415,9 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 					let remap_name = keyword_remap field.cf_name in
 					output_cpp ("	HX_MARK_MEMBER_NAME(" ^ remap_name ^ ",\"" ^ field.cf_name^ "\");\n");
 
-					(match field.cf_get with | CallAccess name when (is_dynamic_accessor name "get" field class_def) ->
+					(match field.cf_kind with Var { v_read = AccCall name } when (is_dynamic_accessor name "get" field class_def) ->
 						output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ name ^ "," ^ "\"" ^ name ^ "\");\n" ) | _ -> ());
-					(match field.cf_set with | CallAccess name when  (is_dynamic_accessor name "set" field class_def) ->
+					(match field.cf_kind with Var { v_write = AccCall name } when  (is_dynamic_accessor name "set" field class_def) ->
 						output_cpp ("\tHX_MARK_MEMBER_NAME(" ^ name ^ "," ^ "\"" ^ name ^ "\");\n" ) | _ -> ());
 				end
 
@@ -2461,8 +2460,8 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 		output_cpp ("Dynamic " ^ class_name ^ "::__Field(const ::String &inName)\n{\n");
 		let get_field_dat = List.map (fun f ->
 			(f.cf_name, String.length f.cf_name, "return " ^
-				(match f.cf_get with
-				| CallAccess prop -> (keyword_remap prop) ^ "()"
+				(match f.cf_kind with
+				| Var { v_read = AccCall prop } -> (keyword_remap prop) ^ "()"
 				| _ -> ((keyword_remap f.cf_name) ^ if (variable_field f) then "" else "_dyn()")
 				) ^ ";"
 			) )
@@ -2490,8 +2489,8 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 				let remap_name = keyword_remap f.cf_name in
 				output_cpp ("	if (inFieldID==__id_" ^ remap_name ^ ") return "  ^
 					( if (return_type="double") then "hx::ToDouble( " else "" ) ^
-					(match f.cf_get with
-					| CallAccess prop -> (keyword_remap prop) ^ "()"
+					(match f.cf_kind with
+					| Var { v_read = AccCall prop } -> (keyword_remap prop) ^ "()"
 					| _ -> ((keyword_remap f.cf_name) ^ if ( variable_field f) then "" else "_dyn()")
 					) ^ ( if (return_type="double") then " ) " else "" ) ^ ";\n");
 				) in
@@ -2512,8 +2511,8 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
 
 		let set_field_dat = List.map (fun f ->
 			(f.cf_name, String.length f.cf_name,
-				(match f.cf_set with
-				| CallAccess prop -> "return " ^ (keyword_remap prop) ^ "(inValue);"
+				(match f.cf_kind with
+				| Var { v_write = AccCall prop } -> "return " ^ (keyword_remap prop) ^ "(inValue);"
 				| _ -> (keyword_remap f.cf_name) ^ "=inValue.Cast< " ^ (type_string f.cf_type) ^
 				         " >(); return inValue;"
 				)  )

+ 1 - 1
genjs.ml

@@ -659,7 +659,7 @@ let generate_class ctx c =
 		newline ctx;
 	);
 	List.iter (gen_class_static_field ctx c) c.cl_ordered_statics;
-	PMap.iter (fun _ f -> if f.cf_get <> ResolveAccess then gen_class_field ctx c f) c.cl_fields;
+	PMap.iter (fun _ f -> match f.cf_kind with Var { v_read = AccResolve } -> () | _ -> gen_class_field ctx c f) c.cl_fields;
 	print ctx "%s.prototype.__class__ = %s" p p;
 	newline ctx;
 	match c.cl_implements with

+ 3 - 1
genneko.ml

@@ -495,7 +495,9 @@ let gen_method ctx p c acc =
 	ctx.curmethod <- c.cf_name;
 	match c.cf_expr with
 	| None ->
-		if c.cf_get = ResolveAccess then acc else (c.cf_name, null p) :: acc
+		(match c.cf_kind with
+		| Var { v_read = AccResolve } -> acc
+		| _ -> (c.cf_name, null p) :: acc)
 	| Some e ->
 		match e.eexpr with
 		| TCall ({ eexpr = TField ({ eexpr = TTypeExpr (TClassDecl { cl_path = (["neko"],"Lib") }) }, load)},[{ eexpr = TConst (TString m) };{ eexpr = TConst (TString f) };{ eexpr = TConst (TInt n) }]) when load = "load" || load = "loadLazy" ->

+ 35 - 35
genphp.ml

@@ -444,9 +444,9 @@ let is_in_dynamic_methods ctx e s =
 	) ctx.all_dynamic_methods
 
 let is_dynamic_method f =
-	(match f.cf_set with
-		| NormalAccess -> true
-		| MethodAccess true -> true
+	(match f.cf_kind with
+		| Var _ -> true
+		| Method MethDynamic -> true
 		| _ -> false)
 		
 let fun_block ctx f p =
@@ -1628,13 +1628,10 @@ let generate_field ctx static f =
 		else
 			ctx.curmethod <- f.cf_name;
 		spr ctx (rights ^ " ");
-		(match f.cf_set with
-		| NormalAccess
-		| MethodAccess true ->
+		if is_dynamic_method f then
 			gen_dynamic_function ctx static (s_ident f.cf_name) fd f.cf_params p
-		| _ ->
-			gen_function ctx (s_ident f.cf_name) fd f.cf_params p
-		);
+		else
+			gen_function ctx (s_ident f.cf_name) fd f.cf_params p		
 	| _ ->
 		if ctx.curclass.cl_interface then
 			match follow f.cf_type with
@@ -1646,34 +1643,37 @@ let generate_field ctx static f =
 				print ctx ")";
 			| _ -> spr ctx "//"; ()
 		else if
-			(match f.cf_get, f.cf_set with
-			| CallAccess m1, CallAccess m2 ->
-				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);
-					if not (is_method_defined ctx m2 static) then
+			(match f.cf_kind with
+			| Var v ->
+				(match v.v_read, v.v_write with
+				| AccCall m1, AccCall m2 ->
+					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);
+						if not (is_method_defined ctx m2 static) then
+							newline ctx);
+					if not (is_method_defined ctx m2 static) then (
+						generate_self_method ctx rights m2 static true;
+						print ctx "%s $%s" rights (s_ident m2);
 						newline ctx);
-				if not (is_method_defined ctx m2 static) then (
-					generate_self_method ctx rights m2 static true;
-					print ctx "%s $%s" rights (s_ident m2);
-					newline ctx);
-				false
-			| CallAccess m, _ ->
-				if not (is_method_defined ctx m static) then generate_self_method ctx rights m static false;
-				print ctx "%s $%s" rights (s_ident f.cf_name);
-				true
-			| _, CallAccess m ->
-				if not (is_method_defined ctx m static) then generate_self_method ctx rights m static true;
-				print ctx "%s $%s" rights (s_ident f.cf_name);
-				true
-			| _ ->
-				false) then
+					false
+				| AccCall m, _ ->
+					if not (is_method_defined ctx m static) then generate_self_method ctx rights m static false;
+					print ctx "%s $%s" rights (s_ident f.cf_name);
+					true
+				| _, AccCall m ->
+					if not (is_method_defined ctx m static) then generate_self_method ctx rights m static true;
+					print ctx "%s $%s" rights (s_ident f.cf_name);
+					true
+				| _ ->
+					false)
+			| _ -> false) then
 				()
 		else begin
 			let name = s_ident f.cf_name in
 			if static then
-				(match f.cf_set with
-				| NormalAccess -> 
+				(match f.cf_kind with
+				| Var _ -> 
 					(match follow f.cf_type with
 					| TFun _
 					| TDynamic _ ->
@@ -1705,8 +1705,8 @@ let generate_static_field_assign ctx path f =
 			match e.eexpr with
 			| TConst _ -> ()
 			| TFunction fd ->
-				(match f.cf_set with
-				| NormalAccess when 
+				(match f.cf_kind with
+				| Var _ when 
 						(match follow f.cf_type with
 						| TFun _
 						| TDynamic _ ->
@@ -1716,7 +1716,7 @@ let generate_static_field_assign ctx path f =
 					newline ctx;
 					print ctx "%s::$%s = " (s_path ctx path false p) (s_ident f.cf_name);
 					gen_value ctx e
-				| MethodAccess true ->
+				| Method MethDynamic ->
 					newline ctx;
 					print ctx "%s::$%s = " (s_path ctx path false p) (s_ident f.cf_name);
 					gen_value ctx e

+ 1 - 1
genswf8.ml

@@ -1402,7 +1402,7 @@ let gen_type_def ctx t =
 		let flag = is_protected ctx ~stat:true (TInst (c,[])) "" in
 		List.iter (gen_class_static_field ctx c flag) c.cl_ordered_statics;
 		let flag = is_protected ctx (TInst (c,[])) "" in
-		PMap.iter (fun _ f -> if f.cf_get <> ResolveAccess then gen_class_field ctx flag f) c.cl_fields;
+		PMap.iter (fun _ f -> match f.cf_kind with Var { v_read = AccResolve } -> () | _ -> gen_class_field ctx flag f) c.cl_fields;
 	| TEnumDecl e when e.e_extern ->
 		()
 	| TEnumDecl e ->

+ 12 - 10
genswf9.ml

@@ -1637,8 +1637,8 @@ let generate_construct ctx fdata c =
 		j());
 	(* --- *)
 	PMap.iter (fun _ f ->
-		match f.cf_expr with
-		| Some { eexpr = TFunction fdata } when f.cf_set = MethodAccess true ->
+		match f.cf_expr, f.cf_kind with
+		| Some { eexpr = TFunction fdata }, Method MethDynamic ->
 			let id = ident f.cf_name in
 			write ctx (HFindProp id);
 			write ctx (HGetProp id);
@@ -1658,7 +1658,7 @@ let generate_class_statics ctx c =
 	List.iter (fun f ->
 		match f.cf_expr with
 		| None -> ()
-		| Some { eexpr = TFunction _ } when f.cf_set = MethodAccess false || f.cf_get = InlineAccess -> ()
+		| Some { eexpr = TFunction _ } when (match f.cf_kind with Method (MethNormal | MethInline) -> true | _ -> false) -> ()
 		| Some e ->
 			write ctx (HGetLex (type_path ctx c.cl_path));
 			gen_expr ctx true e;
@@ -1678,8 +1678,8 @@ let generate_class_init ctx c hc =
 	end;
 	write ctx (HClassDef hc);
 	List.iter (fun f ->
-		match f.cf_expr with
-		| Some { eexpr = TFunction fdata } when f.cf_set = MethodAccess true ->
+		match f.cf_expr, f.cf_kind with
+		| Some { eexpr = TFunction fdata }, Method MethDynamic ->
 			write ctx HDup;
 			write ctx (HFunction (generate_method ctx fdata true));
 			write ctx (HInitProp (ident f.cf_name));
@@ -1738,22 +1738,24 @@ let generate_field_kind ctx f c stat =
 			| Some (c,_) ->
 				PMap.exists f.cf_name c.cl_fields || loop c
 		in
-		if f.cf_set = NormalAccess || f.cf_set = MethodAccess true then
+		(match f.cf_kind with
+		| Var _ | Method MethDynamic ->
 			Some (HFVar {
 				hlv_type = Some (type_path ctx ([],"Function"));
 				hlv_value = HVNone;
 				hlv_const = false;
 			})
-		else
+		| _ ->
 			Some (HFMethod {
 				hlm_type = generate_method ctx fdata stat;
 				hlm_final = stat;
 				hlm_override = not stat && loop c;
 				hlm_kind = MK3Normal;
 			})
+		);
 	| _ when c.cl_interface && not stat ->
-		(match follow f.cf_type with
-		| TFun (args,tret) when f.cf_set = MethodAccess false ->
+		(match follow f.cf_type, f.cf_kind with
+		| TFun (args,tret), Method (MethNormal | MethInline) ->
 			Some (HFMethod {
 				hlm_type = end_fun ctx (List.map (fun (a,opt,t) -> a, (if opt then Some TNull else None), t) args) tret;
 				hlm_final = false;
@@ -1762,7 +1764,7 @@ let generate_field_kind ctx f c stat =
 			})
 		| _ ->
 			None)
-	| _ when f.cf_get = ResolveAccess ->
+	| _ when (match f.cf_kind with Var { v_read = AccResolve } -> true | _ -> false) ->
 		None
 	| _ ->
 		Some (HFVar {

+ 12 - 6
genxml.ml

@@ -74,14 +74,20 @@ let rec gen_type t =
 and gen_field att f =
 	let add_get_set acc name att =
 		match acc with
-		| NormalAccess | ResolveAccess -> att
-		| MethodAccess dyn -> (name, if dyn then "dynamic" else "method") :: att 
-		| NoAccess | NeverAccess -> (name, "null") :: att
-		| CallAccess m -> (name,m) :: att
-		| InlineAccess -> (name,"inline") :: att
+		| AccNormal | AccResolve -> att
+		| AccNo | AccNever -> (name, "null") :: att
+		| AccCall m -> (name,m) :: 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
-	let att = add_get_set f.cf_get "get" (add_get_set f.cf_set "set" att) in	
+	let att = (match f.cf_kind with
+		| Var v -> add_get_set v.v_read "get" (add_get_set v.v_write "set" att)
+		| Method m ->
+			(match m with
+			| MethNormal -> ("set", "method") :: att
+			| MethDynamic -> ("set", "dynamic") :: att
+			| MethInline -> ("get", "inline") :: ("set","null") :: att)
+	) in
 	let att = (match f.cf_params with [] -> att | l -> ("params", String.concat ":" (List.map (fun (n,_) -> n) l)) :: att) in
 	node f.cf_name (if f.cf_public then ("public","1") :: att else att) (gen_type f.cf_type :: gen_doc_opt f.cf_doc)
 

+ 1 - 1
optimizer.ml

@@ -436,7 +436,7 @@ let rec reduce_loop ctx is_sub e =
 	| TCall ({ eexpr = TFunction func } as ef,el) ->
 		(match follow ef.etype with
 		| TFun (_,rt) ->
-			let cf = { cf_name = ""; cf_params = []; cf_type = ef.etype; cf_public = true; cf_doc = None; cf_meta = no_meta; cf_get = NormalAccess; cf_set = NoAccess; cf_expr = None } in
+			let cf = { cf_name = ""; cf_params = []; cf_type = ef.etype; cf_public = true; cf_doc = None; cf_meta = no_meta; cf_kind = Var { v_read = AccNormal; v_write = AccNo }; cf_expr = None } in
 			let inl = (try type_inline ctx cf func (mk (TConst TNull) (mk_mono()) e.epos) el rt e.epos with Error (Custom _,_) -> None) in
 			(match inl with
 			| None -> e

+ 79 - 44
type.ml

@@ -20,14 +20,27 @@ open Ast
 
 type path = string list * string
 
-type field_access =
-	| NormalAccess
-	| NoAccess
-	| ResolveAccess (* call resolve("field") when accessed *)
-	| CallAccess of string (* perform a method call when accessed *)
-	| MethodAccess of bool (* true = the method is dynamic *)
-	| InlineAccess (* similar to Normal but inline when acccessed *)
-	| NeverAccess (* can't be accessed, even in subclasses *)
+type field_kind =
+	| Var of var_kind
+	| Method of method_kind
+
+and var_kind = {
+	v_read : var_access;
+	v_write : var_access;
+}
+
+and var_access =
+	| AccNormal
+	| 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 *)
+	| AccInline			(* similar to Normal but inline when accessed *)
+
+and method_kind =
+	| MethNormal
+	| MethInline
+	| MethDynamic
 
 type t =
 	| TMono of t option ref
@@ -110,8 +123,7 @@ and tclass_field = {
 	cf_public : bool;
 	mutable cf_doc : Ast.documentation;
 	cf_meta : metadata;
-	cf_get : field_access;
-	cf_set : field_access;
+	cf_kind : field_kind;
 	cf_params : (string * t) list;
 	mutable cf_expr : texpr option;
 }
@@ -303,13 +315,21 @@ and s_type_params ctx = function
 	| l -> "<" ^ String.concat ", " (List.map (s_type ctx) l) ^ ">"
 
 let s_access = function
-	| NormalAccess -> "default"
-	| NoAccess -> "null"
-	| NeverAccess -> "never"
-	| CallAccess m -> m
-	| MethodAccess b -> if b then "dynamic method" else "default method"
-	| ResolveAccess -> "resolve"
-	| InlineAccess -> "inline"
+	| AccNormal -> "default"
+	| AccNo -> "null"
+	| AccNever -> "never"
+	| AccResolve -> "resolve"
+	| AccCall m -> m
+	| AccInline	-> "inline"
+
+let s_kind = function
+	| Var { v_read = AccNormal; v_write = AccNormal } -> "var"
+	| Var v -> "(" ^ s_access v.v_read ^ "," ^ s_access v.v_write ^ ")"
+	| Method m ->
+		match m with
+		| MethNormal -> "method"
+		| MethDynamic -> "dynamic method"
+		| MethInline -> "inline method"
 
 let rec is_parent csup c =
 	if c == csup then
@@ -492,7 +512,7 @@ type unify_error =
 	| Invalid_field_type of string
 	| Has_no_field of t * string
 	| Has_extra_field of t * string
-	| Invalid_access of string * bool * field_access * field_access
+	| Invalid_kind of string * field_kind * field_kind
 	| Invalid_visibility of string
 	| Not_matching_optional of string
 	| Cant_force_optional
@@ -501,7 +521,7 @@ exception Unify_error of unify_error list
 
 let cannot_unify a b = Cannot_unify (a,b)
 let invalid_field n = Invalid_field_type n
-let invalid_access n get a b = Invalid_access (n,get,a,b)
+let invalid_kind n a b = Invalid_kind (n,a,b)
 let invalid_visibility n = Invalid_visibility n
 let has_no_field t n = Has_no_field (t,n)
 let has_extra_field t n = Has_extra_field (t,n)
@@ -509,24 +529,39 @@ let error l = raise (Unify_error l)
 let has_meta m ml = List.mem (m,[]) (ml())
 let no_meta() = []
 
-type simple_access =
-	| SAYes
-	| SANo
-	| SARuntime
-
-let simple_access = function
-	| NormalAccess | InlineAccess | MethodAccess true -> SAYes
-	| NoAccess | NeverAccess | MethodAccess false -> SANo
-	| ResolveAccess | CallAccess _ -> SARuntime
-
 (*
 	we can restrict access as soon as both are runtime-compatible
 *)
 let unify_access a1 a2 =
-	a1 = a2 || match simple_access a1 , simple_access a2 with
-		| SAYes, SAYes
-		| _, SANo -> true
-		| _ -> false
+	a1 = a2 || match a1, a2 with
+	| _, AccNo | _, AccNever -> true
+	| AccInline, AccNormal -> true
+	| _ -> false
+
+let direct_access = function
+	| AccNo | AccNever | AccNormal | AccInline -> true
+	| AccResolve | AccCall _ -> false
+
+let unify_kind k1 k2 =
+	k1 = k2 || match k1, k2 with
+		| Var v1, Var v2 -> unify_access v1.v_read v2.v_read && unify_access v1.v_write v2.v_write
+		| Var v, Method m ->
+			(match v.v_read, v.v_write, m with
+			| AccNormal, _, MethNormal -> true
+			| AccNormal, AccNormal, MethDynamic -> true
+			| _ -> false)
+		| Method m, Var v -> 
+			(match m with
+			| MethDynamic -> direct_access v.v_read && direct_access v.v_write
+			| MethNormal | MethInline ->
+				match v.v_write with
+				| AccNo | AccNever -> true
+				| _ -> false)
+		| Method m1, Method m2 ->
+			match m1,m2 with
+			| MethInline, MethNormal
+			| MethDynamic, MethNormal -> true
+			| _ -> false
 
 let eq_stack = ref []
 
@@ -589,8 +624,7 @@ let rec type_eq param a b =
 			PMap.iter (fun n f1 ->
 				try
 					let f2 = PMap.find n a2.a_fields in
-					if f1.cf_get <> f2.cf_get && (param = EqStrict || param = EqCoreType || not (unify_access f1.cf_get f2.cf_get)) then error [invalid_access n true f1.cf_get f2.cf_get];
-					if f1.cf_set <> f2.cf_set && (param = EqStrict || param = EqCoreType || not (unify_access f1.cf_set f2.cf_set)) then error [invalid_access n false f1.cf_set f2.cf_set];
+					if f1.cf_kind <> f2.cf_kind && (param = EqStrict || param = EqCoreType || not (unify_kind f1.cf_kind f2.cf_kind)) then error [invalid_kind n f1.cf_kind f2.cf_kind];
 					try
 						type_eq param f1.cf_type f2.cf_type
 					with
@@ -718,8 +752,7 @@ let rec unify a b =
 		(try
 			PMap.iter (fun n f2 ->
 				let ft, f1 = (try class_field c n with Not_found -> error [has_no_field a n]) in
-				if not (unify_access f1.cf_get f2.cf_get) then error [invalid_access n true f1.cf_get f2.cf_get];
-				if not (unify_access f1.cf_set f2.cf_set) then error [invalid_access n false f1.cf_set f2.cf_set];
+				if not (unify_kind f1.cf_kind f2.cf_kind) then error [invalid_kind n f1.cf_kind f2.cf_kind];
 				if f2.cf_public && not f1.cf_public then error [invalid_visibility n];
 				try
 					unify_with_access (apply_params c.cl_types tl ft) f2
@@ -734,8 +767,7 @@ let rec unify a b =
 			PMap.iter (fun n f2 ->
 			try
 				let f1 = PMap.find n a1.a_fields in
-				if not (unify_access f1.cf_get f2.cf_get) then error [invalid_access n true f1.cf_get f2.cf_get];
-				if not (unify_access f1.cf_set f2.cf_set) then error [invalid_access n false f1.cf_set f2.cf_set];
+				if not (unify_kind f1.cf_kind f2.cf_kind) then error [invalid_kind n f1.cf_kind f2.cf_kind];
 				if f2.cf_public && not f1.cf_public then error [invalid_visibility n];
 				try
 					unify_with_access f1.cf_type f2;
@@ -814,11 +846,14 @@ and unify_types a b tl1 tl2 =
 	with
 		Unify_error l -> error ((cannot_unify a b) :: l)
 
-and unify_with_access t f =
-	match f.cf_get, f.cf_set with
-	| NoAccess , _ | NeverAccess, _ -> unify f.cf_type t
-	| _ , NoAccess | _, NeverAccess -> unify t f.cf_type
-	| _ , _ -> type_eq EqBothDynamic t f.cf_type
+and unify_with_access t1 f2 =
+	match f2.cf_kind with
+	(* write only *)
+	| Var { v_read = AccNo } | Var { v_read = AccNever } -> unify f2.cf_type t1
+	(* read only *)
+	| Method MethNormal | Method MethInline | Var { v_write = AccNo } | Var { v_write = AccNever } -> unify t1 f2.cf_type
+	(* read/write *)
+	| _ -> type_eq EqBothDynamic t1 f2.cf_type
 
 let iter f e =
 	match e.eexpr with

+ 14 - 4
typecore.ml

@@ -78,8 +78,19 @@ let unify_error_msg ctx = function
 		s_type ctx t ^ " has no field " ^ n
 	| Has_extra_field (t,n) ->
 		s_type ctx t ^ " has extra field " ^ n
-	| Invalid_access (f,get,a,b) ->
-		"Inconsistent " ^ (if get then "getter" else "setter") ^ " for field " ^ f ^ " : " ^ s_access a ^ " should be " ^ s_access b
+	| Invalid_kind (f,a,b) ->
+		(match a, b with
+		| Var va, Var vb ->
+			let name, stra, strb = if va.v_read = vb.v_read then
+				"setter", s_access va.v_write, s_access vb.v_write
+			else if va.v_write = vb.v_write then
+				"getter", s_access va.v_read, s_access vb.v_read
+			else
+				"access", "(" ^ s_access va.v_read ^ "," ^ s_access va.v_write ^ ")", "(" ^ s_access vb.v_read ^ "," ^ s_access vb.v_write ^ ")"
+			in
+			"Inconsistent " ^ name ^ " for field " ^ f ^ " : " ^ stra ^ " should be " ^ strb
+		| _ ->
+			"Field " ^ f ^ " is " ^ s_kind a ^ " but should be " ^ s_kind b)
 	| Invalid_visibility n ->
 		"The field " ^ n ^ " is not public"
 	| Not_matching_optional n ->
@@ -205,8 +216,7 @@ let mk_field name t = {
 	cf_doc = None;
 	cf_meta = no_meta;
 	cf_public = true;
-	cf_get = NormalAccess;
-	cf_set = NormalAccess;
+	cf_kind = Var { v_read = AccNormal; v_write = AccNormal };
 	cf_expr = None;
 	cf_params = [];
 }

+ 34 - 40
typeload.ml

@@ -193,30 +193,29 @@ and load_complex_type ctx p t =
 	| TPAnonymous l ->
 		let rec loop acc (n,pub,f,p) =
 			if PMap.mem n acc then error ("Duplicate field declaration : " ^ n) p;
-			let t , get, set = (match f with
+			let t , access = (match f with
 				| AFVar t ->
-					load_complex_type ctx p t, NormalAccess, NormalAccess
+					load_complex_type ctx p t, Var { v_read = AccNormal; v_write = AccNormal }
 				| AFFun (tl,t) ->
 					let t = load_complex_type ctx p t in
 					let args = List.map (fun (name,o,t) -> name , o, load_complex_type ctx p t) tl in
-					TFun (args,t), NormalAccess, MethodAccess false
+					TFun (args,t), Method MethNormal
 				| AFProp (t,i1,i2) ->
 					let access m get =
 						match m with
-						| "null" -> NoAccess
-						| "never" -> NeverAccess
-						| "default" -> NormalAccess
-						| "dynamic" -> CallAccess ((if get then "get_"  else "set_") ^ n)
-						| _ -> CallAccess m
+						| "null" -> AccNo
+						| "never" -> AccNever
+						| "default" -> AccNormal
+						| "dynamic" -> AccCall ((if get then "get_"  else "set_") ^ n)
+						| _ -> AccCall m
 					in
-					load_complex_type ctx p t, access i1 true, access i2 false
+					load_complex_type ctx p t, Var { v_read = access i1 true; v_write = access i2 false }
 			) in
 			PMap.add n {
 				cf_name = n;
 				cf_type = t;
 				cf_public = (match pub with None -> true | Some p -> p);
-				cf_get = get;
-				cf_set = set;
+				cf_kind = access;
 				cf_params = [];
 				cf_expr = None;
 				cf_doc = None;
@@ -311,9 +310,9 @@ let check_overriding ctx c p () =
 					display_error ctx ("Field " ^ i ^ " should be declared with 'override' since it is inherited from superclass") p
 				else if f.cf_public <> f2.cf_public then
 					display_error ctx ("Field " ^ i ^ " has different visibility (public/private) than superclass one") p
-				else if f2.cf_get = InlineAccess then
+				else if f2.cf_kind = Method MethInline then
 					display_error ctx ("Field " ^ i ^ " is inlined and cannot be overridden") p
-				else if f2.cf_get <> f.cf_get || f2.cf_set <> f.cf_set then
+				else if f2.cf_kind <> f.cf_kind then
 					display_error ctx ("Field " ^ i ^ " has different property access than in superclass") p
 				else try
 					let t = apply_params csup.cl_types params t in
@@ -348,10 +347,8 @@ let rec check_interface ctx c p intf params =
 			let p = (match f2.cf_expr with None -> p | Some e -> e.epos) in
 			if f.cf_public && not f2.cf_public then
 				display_error ctx ("Field " ^ i ^ " should be public as requested by " ^ s_type_path intf.cl_path) p
-			else if not (unify_access f2.cf_get f.cf_get) then
-				display_error ctx ("Field " ^ i ^ " has different property access than in " ^ s_type_path intf.cl_path ^ " (" ^ s_access f2.cf_get ^ " should be " ^ s_access f.cf_get ^ ")") p
-			else if not (unify_access f2.cf_set f.cf_set) then
-				display_error ctx ("Field " ^ i ^ " has different property access than in " ^ s_type_path intf.cl_path ^ " (" ^ s_access f2.cf_set ^ " should be " ^ s_access f.cf_set ^ ")") p
+			else if not (unify_kind f2.cf_kind f.cf_kind) then
+				display_error ctx ("Field " ^ i ^ " has different property access than in " ^ s_type_path intf.cl_path ^ " (" ^ s_kind f2.cf_kind ^ " should be " ^ s_kind f.cf_kind ^ ")") p
 			else try
 				valid_redefinition ctx f2 t2 f (apply_params intf.cl_types params f.cf_type)
 			with
@@ -598,10 +595,9 @@ let init_core_api ctx c =
 				(match f2.cf_doc with
 				| None -> f2.cf_doc <- f.cf_doc
 				| Some _ -> ());
-				if f2.cf_get <> f.cf_get || f2.cf_set <> f.cf_set then begin
-					match f2.cf_get, f.cf_get, f2.cf_set, f.cf_set with
-					| InlineAccess, NormalAccess, NeverAccess, MethodAccess false -> () (* allow to add 'inline' *)
-					| NormalAccess, InlineAccess, MethodAccess false, NeverAccess -> () (* allow to remove 'inline' - only during transition ? *)
+				if f2.cf_kind <> f.cf_kind then begin
+					match f2.cf_kind, f.cf_kind with
+					| Method MethInline, Method MethNormal -> () (* allow to add 'inline' *)
 					| _ ->
 						error ("Field " ^ i ^ " has different property access than core type") p;
 				end;
@@ -695,8 +691,7 @@ let init_class ctx c p herits fields =
 				cf_doc = doc;
 				cf_meta = type_meta ctx meta;
 				cf_type = t;
-				cf_get = if inline then InlineAccess else NormalAccess;
-				cf_set = if inline then NeverAccess else NormalAccess;
+				cf_kind = Var (if inline then { v_read = AccInline ; v_write = AccNever } else { v_read = AccNormal; v_write = AccNormal });
 				cf_expr = None;
 				cf_public = is_public access None;
 				cf_params = [];
@@ -726,7 +721,8 @@ let init_class ctx c p herits fields =
 			let inline = List.mem AInline access in
 			if inline && c.cl_interface then error "You can't declare inline methods in interfaces" p;
 			let parent = (if not stat then get_parent c name else None) in
-			let dynamic = List.mem ADynamic access || (match parent with Some { cf_set = MethodAccess true } -> true | _ -> false) in
+			let dynamic = List.mem ADynamic access || (match parent with Some { cf_kind = Method MethDynamic } -> true | _ -> false) in
+			if inline && dynamic then error "You can't have both 'inline' and 'dynamic'" p;
 			let ctx = { ctx with
 				curclass = c;
 				curmethod = name;
@@ -751,8 +747,7 @@ let init_class ctx c p herits fields =
 				cf_doc = doc;
 				cf_meta = type_meta ctx meta;
 				cf_type = t;
-				cf_get = if inline then InlineAccess else NormalAccess;
-				cf_set = (if inline then NeverAccess else MethodAccess dynamic);
+				cf_kind = Method (if inline then MethInline else if dynamic then MethDynamic else MethNormal);
 				cf_expr = None;
 				cf_public = is_public access parent;
 				cf_params = params;
@@ -795,35 +790,34 @@ let init_class ctx c p herits fields =
 					| Not_found -> if not c.cl_interface then error ("Method " ^ m ^ " required by property " ^ name ^ " is missing") p
 			in
 			let get = (match get with
-				| "null" -> NoAccess
-				| "dynamic" -> CallAccess ("get_" ^ name)
-				| "never" -> NeverAccess
-				| "default" -> NormalAccess
+				| "null" -> AccNo
+				| "dynamic" -> AccCall ("get_" ^ name)
+				| "never" -> AccNever
+				| "default" -> AccNormal
 				| _ ->
 					check_get := check_method get (TFun ([],ret));
-					CallAccess get
+					AccCall get
 			) in
 			let set = (match set with
 				| "null" ->
 					(* standard flash library read-only variables can't be accessed for writing, even in subclasses *)
 					if c.cl_extern && (match c.cl_path with "flash" :: _  , _ -> true | _ -> false) && Common.defined ctx.com "flash9" then
-						NeverAccess
+						AccNever
 					else
-						NoAccess
-				| "never" -> NeverAccess
-				| "dynamic" -> CallAccess ("set_" ^ name)
-				| "default" -> NormalAccess
+						AccNo
+				| "never" -> AccNever
+				| "dynamic" -> AccCall ("set_" ^ name)
+				| "default" -> AccNormal
 				| _ ->
 					check_set := check_method set (TFun (["",false,ret],ret));
-					CallAccess set
+					AccCall set
 			) in
-			if set = NormalAccess && (match get with CallAccess _ -> 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 = doc;
 				cf_meta = type_meta ctx meta;
-				cf_get = get;
-				cf_set = set;
+				cf_kind = Var { v_read = get; v_write = set };
 				cf_expr = None;
 				cf_type = ret;
 				cf_public = is_public access None;

+ 57 - 51
typer.ml

@@ -216,8 +216,10 @@ let rec type_module_type ctx t tparams p =
 				cf_name = f.ef_name;
 				cf_public = true;
 				cf_type = f.ef_type;
-				cf_get = NormalAccess;
-				cf_set = (match follow f.ef_type with TFun _ -> MethodAccess false | _ -> NoAccess);
+				cf_kind = (match follow f.ef_type with 
+					| TFun _ -> Method MethNormal 
+					| _ -> Var { v_read = AccNormal; v_write = Type.AccNo }
+				);
 				cf_doc = None;
 				cf_meta = no_meta;
 				cf_expr = None;
@@ -277,7 +279,7 @@ let make_call ctx e params t p =
 			| TAnon a -> (try PMap.find fname a.a_fields with Not_found -> raise Exit)
 			| _ -> raise Exit
 		) in
-		if f.cf_get <> InlineAccess then raise Exit;
+		if f.cf_kind <> Method MethInline then raise Exit;
 		ignore(follow f.cf_type); (* force evaluation *)
 		(match f.cf_expr with
 		| Some { eexpr = TFunction fd } ->
@@ -323,47 +325,54 @@ let rec acc_get ctx g p =
 			loop e
 
 let field_access ctx mode f t e p =
-	let normal() = AccExpr (mk (TField (e,f.cf_name)) t p) in
-	match (match mode with MGet | MCall -> f.cf_get | MSet -> f.cf_set) with
-	| NoAccess ->
-		(match follow e.etype with
-		| TInst (c,_) when is_parent c ctx.curclass -> normal()
-		| TAnon a ->
-			(match !(a.a_status) with
-			| Statics c2 when ctx.curclass == c2 -> normal()
-			| _ -> if ctx.untyped then normal() else AccNo f.cf_name)
-		| _ ->
-			if ctx.untyped then normal() else AccNo f.cf_name)
-	| MethodAccess false when not ctx.untyped ->
-		error "Cannot rebind this method : please use 'dynamic' before method declaration" p
-	| NormalAccess | MethodAccess _ ->
-		(* 
-			creates a closure if we're reading a normal method
-			or a read-only variable (which could be a method)
-		*)
-		(match mode, f.cf_set with
-		| MGet, MethodAccess _ -> AccExpr (mk (TClosure (e,f.cf_name)) t p)
-		| MGet, NoAccess | MGet, NeverAccess when (match follow t with TFun _ -> true | _ -> false) -> AccExpr (mk (TClosure (e,f.cf_name)) t p)
-		| _ ->
-			match follow e.etype with
-			| TAnon a -> (match !(a.a_status) with EnumStatics e -> AccExpr (mk (TEnumField (e,f.cf_name)) t p) | _ -> normal())
-			| _ -> normal())
-	| CallAccess m ->
-		if m = ctx.curmethod && (match e.eexpr with TConst TThis -> true | TTypeExpr (TClassDecl c) when c == ctx.curclass -> true | _ -> false) then
-			let prefix = if Common.defined ctx.com "as3" then "$" else "" in
-			AccExpr (mk (TField (e,prefix ^ f.cf_name)) t p)
-		else if mode = MSet then
-			AccSet (e,m,t,f.cf_name)
-		else
-			AccExpr (make_call ctx (mk (TField (e,m)) (tfun [] t) p) [] t p)
-	| ResolveAccess ->
-		let fstring = mk (TConst (TString f.cf_name)) ctx.api.tstring p in
-		let tresolve = tfun [ctx.api.tstring] t in
-		AccExpr (make_call ctx (mk (TField (e,"resolve")) tresolve p) [fstring] t p)
-	| NeverAccess ->
-		AccNo f.cf_name
-	| InlineAccess ->
-		AccInline (e,f,t)
+	let fnormal() = AccExpr (mk (TField (e,f.cf_name)) t p) in
+	let normal() =
+		match follow e.etype with
+		| TAnon a -> (match !(a.a_status) with EnumStatics e -> AccExpr (mk (TEnumField (e,f.cf_name)) t p) | _ -> fnormal())
+		| _ -> fnormal()
+	in
+	match f.cf_kind with
+	| Method m ->		
+		if mode = MSet && m <> MethDynamic && not ctx.untyped then error "Cannot rebind this method : please use 'dynamic' before method declaration" p;
+		(match m, mode with
+		| MethInline, _ -> AccInline (e,f,t)
+		| _ , MGet -> AccExpr (mk (TClosure (e,f.cf_name)) t p)
+		| _ -> normal())
+	| Var v ->
+		match (match mode with MGet | MCall -> v.v_read | MSet -> v.v_write) with
+		| Type.AccNo ->
+			(match follow e.etype with
+			| TInst (c,_) when is_parent c ctx.curclass -> normal()
+			| TAnon a ->
+				(match !(a.a_status) with
+				| Statics c2 when ctx.curclass == c2 -> normal()
+				| _ -> if ctx.untyped then normal() else AccNo f.cf_name)
+			| _ ->
+				if ctx.untyped then normal() else AccNo f.cf_name)
+		| AccNormal ->
+			(*
+				if we are reading from a read-only variable, it might actually be a method, so make sure to create a closure
+			*)
+			if mode = MGet && (match v.v_write, follow t with (Type.AccNo | AccNever), TFun _ -> true | _ -> false) then
+				AccExpr (mk (TClosure (e,f.cf_name)) t p)
+			else
+				normal()
+		| AccCall m ->
+			if m = ctx.curmethod && (match e.eexpr with TConst TThis -> true | TTypeExpr (TClassDecl c) when c == ctx.curclass -> true | _ -> false) then
+				let prefix = if Common.defined ctx.com "as3" then "$" else "" in
+				AccExpr (mk (TField (e,prefix ^ f.cf_name)) t p)
+			else if mode = MSet then
+				AccSet (e,m,t,f.cf_name)
+			else
+				AccExpr (make_call ctx (mk (TField (e,m)) (tfun [] t) p) [] t p)
+		| AccResolve ->
+			let fstring = mk (TConst (TString f.cf_name)) ctx.api.tstring p in
+			let tresolve = tfun [ctx.api.tstring] t in
+			AccExpr (make_call ctx (mk (TField (e,"resolve")) tresolve p) [fstring] t p)
+		| AccNever ->
+			AccNo f.cf_name
+		| Type.AccInline ->
+			AccInline (e,f,t)
 
 let using_field ctx mode e i p =
 	if mode = MSet then raise Not_found;
@@ -546,7 +555,7 @@ let rec type_field ctx e i p mode =
 		in
 		(try
 			let t , f = class_field c i in
-			if e.eexpr = TConst TSuper && f.cf_set = NormalAccess && Common.platform ctx.com Flash9 then error "Cannot access superclass variable for calling : needs to be a proper method" p;
+			if e.eexpr = TConst TSuper && (match f.cf_kind with Var _ -> true | _ -> false) && Common.platform ctx.com Flash9 then error "Cannot access superclass variable for calling : needs to be a proper method" p;
 			if not f.cf_public && not (is_parent c ctx.curclass) && not ctx.untyped then display_error ctx ("Cannot access to private field " ^ i) p;
 			field_access ctx mode f (apply_params c.cl_types params t) e p
 		with Not_found -> try
@@ -580,8 +589,7 @@ let rec type_field ctx e i p mode =
 				cf_doc = None;
 				cf_meta = no_meta;
 				cf_public = true;
-				cf_get = NormalAccess;
-				cf_set = (match mode with MSet -> NormalAccess | MGet | MCall -> NoAccess);
+				cf_kind = Var { v_read = AccNormal; v_write = (match mode with MSet -> AccNormal | MGet | MCall -> Type.AccNo) };
 				cf_expr = None;
 				cf_params = [];
 			} in
@@ -596,8 +604,7 @@ let rec type_field ctx e i p mode =
 			cf_doc = None;
 			cf_meta = no_meta;
 			cf_public = true;
-			cf_get = NormalAccess;
-			cf_set = (match mode with MSet -> NormalAccess | MGet | MCall -> NoAccess);
+			cf_kind = Var { v_read = AccNormal; v_write = (match mode with MSet -> AccNormal | MGet | MCall -> Type.AccNo) };
 			cf_expr = None;
 			cf_params = [];
 		} in
@@ -1795,8 +1802,7 @@ let types ctx main excludes =
 			cf_name = "init";
 			cf_type = r;
 			cf_public = false;
-			cf_get = NormalAccess;
-			cf_set = NormalAccess;
+			cf_kind = Var { v_read = AccNormal; v_write = AccNormal };
 			cf_doc = None;
 			cf_meta = no_meta;
 			cf_params = [];