Browse Source

Make @:pure a proper meta

Dan Korostelev 9 years ago
parent
commit
5ede96e231
4 changed files with 5 additions and 3 deletions
  1. 2 2
      analyzer.ml
  2. 1 0
      ast.ml
  3. 1 0
      common.ml
  4. 1 1
      genxml.ml

+ 2 - 2
analyzer.ml

@@ -124,7 +124,7 @@ let rec can_be_used_as_value com e =
 	with Exit ->
 		false
 
-let has_pure_meta meta = Meta.has (Meta.Custom ":pure") meta
+let has_pure_meta meta = Meta.has Meta.Pure meta
 
 let is_pure c cf = has_pure_meta c.cl_meta || has_pure_meta cf.cf_meta
 
@@ -2735,7 +2735,7 @@ module Purity = struct
 				if (Meta.has (Meta.Custom ":impure")) cf.cf_meta then taint_raise node;
 				loop e;
 				node.pn_purity <- Pure;
-				cf.cf_meta <- (Meta.Custom ":pure",[],e.epos) :: cf.cf_meta
+				cf.cf_meta <- (Meta.Pure,[],e.epos) :: cf.cf_meta
 			with Exit ->
 				()
 

+ 1 - 0
ast.ml

@@ -138,6 +138,7 @@ module Meta = struct
 		| Protected
 		| Public
 		| PublicFields
+		| Pure
 		| QuotedField
 		| ReadOnly
 		| RealPath

+ 1 - 0
common.ml

@@ -470,6 +470,7 @@ module MetaInfo = struct
 		| PrivateAccess -> ":privateAccess",("Allow private access to anything for the annotated expression",[UsedOn TExpr])
 		| Protected -> ":protected",("Marks a class field as being protected",[UsedOn TClassField])
 		| Property -> ":property",("Marks a property field to be compiled as a native C# property",[UsedOn TClassField;Platform Cs])
+		| Pure -> ":pure",("Marks a class field, class or expression as pure (side-effect free)",[UsedOnEither [TClass;TClassField;TExpr]])
 		| ReadOnly -> ":readOnly",("Generates a field with the 'readonly' native keyword",[Platform Cs; UsedOn TClassField])
 		| RealPath -> ":realPath",("Internally used on @:native types to retain original path information",[Internal])
 		| Remove -> ":remove",("Causes an interface to be removed from all implementing classes before generation",[UsedOn TClass])

+ 1 - 1
genxml.ml

@@ -80,7 +80,7 @@ let rec follow_param t =
 		t
 
 let gen_meta meta =
-	let meta = List.filter (fun (m,_,_) -> match m with Meta.Used | Meta.MaybeUsed | Meta.RealPath | (Meta.Custom ":pure") -> false | _ -> true) meta in
+	let meta = List.filter (fun (m,_,_) -> match m with Meta.Used | Meta.MaybeUsed | Meta.RealPath | Meta.Pure -> false | _ -> true) meta in
 	match meta with
 	| [] -> []
 	| _ ->