Browse Source

add is_read flag to s_access and print "get"/"set" instead of "accessor" (closes #2203)

Simon Krajewski 12 years ago
parent
commit
978dfd0b86
3 changed files with 9 additions and 9 deletions
  1. 3 3
      genxml.ml
  2. 3 3
      type.ml
  3. 3 3
      typecore.ml

+ 3 - 3
genxml.ml

@@ -353,10 +353,10 @@ let generate_type com t =
 			| l -> p "@%s(%s) " (fst (MetaInfo.to_string m)) (String.concat "," (List.map Ast.s_expr pl))
 		) ml
 	in
-	let access a =
+	let access is_read a =
 		match a, pack with
 		| AccNever, "flash" :: _ -> "null"
-		| _ -> s_access a
+		| _ -> s_access is_read a
 	in
 	let print_field stat f =
 		p "\t";
@@ -365,7 +365,7 @@ let generate_type com t =
 		(match f.cf_kind with
 		| Var v ->
 			p "var %s" f.cf_name;
-			if v.v_read <> AccNormal || v.v_write <> AccNormal then p "(%s,%s)" (access v.v_read) (access v.v_write);
+			if v.v_read <> AccNormal || v.v_write <> AccNormal then p "(%s,%s)" (access true v.v_read) (access false v.v_write);
 			p " : %s" (stype f.cf_type);
 		| Method m ->
 			let params, ret = (match follow f.cf_type with

+ 3 - 3
type.ml

@@ -479,18 +479,18 @@ and s_type_params ctx = function
 	| [] -> ""
 	| l -> "<" ^ String.concat ", " (List.map (s_type ctx) l) ^ ">"
 
-let s_access = function
+let s_access is_read = function
 	| AccNormal -> "default"
 	| AccNo -> "null"
 	| AccNever -> "never"
 	| AccResolve -> "resolve"
-	| AccCall -> "accessor"
+	| AccCall -> if is_read then "get" else "set"
 	| AccInline	-> "inline"
 	| AccRequire (n,_) -> "require " ^ n
 
 let s_kind = function
 	| Var { v_read = AccNormal; v_write = AccNormal } -> "var"
-	| Var v -> "(" ^ s_access v.v_read ^ "," ^ s_access v.v_write ^ ")"
+	| Var v -> "(" ^ s_access true v.v_read ^ "," ^ s_access false v.v_write ^ ")"
 	| Method m ->
 		match m with
 		| MethNormal -> "method"

+ 3 - 3
typecore.ml

@@ -214,11 +214,11 @@ let unify_error_msg ctx = function
 		(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
+				"setter", s_access false va.v_write, s_access false vb.v_write
 			else if va.v_write = vb.v_write then
-				"getter", s_access va.v_read, s_access vb.v_read
+				"getter", s_access true va.v_read, s_access true 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 ^ ")"
+				"access", "(" ^ s_access true va.v_read ^ "," ^ s_access false va.v_write ^ ")", "(" ^ s_access true vb.v_read ^ "," ^ s_access false vb.v_write ^ ")"
 			in
 			"Inconsistent " ^ name ^ " for field " ^ f ^ " : " ^ stra ^ " should be " ^ strb
 		| _ ->