2
0
Эх сурвалжийг харах

bugfix metadata with parameters for enums

Nicolas Cannasse 15 жил өмнө
parent
commit
c318edd455
1 өөрчлөгдсөн 7 нэмэгдсэн , 6 устгасан
  1. 7 6
      genneko.ml

+ 7 - 6
genneko.ml

@@ -605,10 +605,7 @@ let gen_enum ctx e =
 		pmap_list (gen_enum_constr ctx path) e.e_constrs @
 		pmap_list (gen_enum_constr ctx path) e.e_constrs @
 		(match e.e_path with
 		(match e.e_path with
 		| [] , name -> [EBinop ("=",field p (ident p "@classes") name,ident p name),p]
 		| [] , name -> [EBinop ("=",field p (ident p "@classes") name,ident p name),p]
-		| _ -> []) @
-		(match Codegen.build_metadata ctx.com (TEnumDecl e) with
-		| None -> []
-		| Some e -> [EBinop ("=",field p path "__meta__", gen_expr ctx e),p])
+		| _ -> [])
 	),p)
 	),p)
 
 
 let gen_type ctx t acc =
 let gen_type ctx t acc =
@@ -690,8 +687,12 @@ let gen_name ctx acc t =
 		let path = gen_type_path p e.e_path in
 		let path = gen_type_path p e.e_path in
 		let setname = (EBinop ("=",field p path "__ename__",arr),p) in
 		let setname = (EBinop ("=",field p path "__ename__",arr),p) in
 		let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant ctx e.e_pos (TString n)) e.e_names); int p (List.length e.e_names)] in
 		let arr = call p (field p (ident p "Array") "new1") [array p (List.map (fun n -> gen_constant ctx e.e_pos (TString n)) e.e_names); int p (List.length e.e_names)] in
-		let setconstrs = (EBinop ("=", field p path "__constructs__", arr),p) in
-		setname :: setconstrs :: acc
+		let setconstrs = (EBinop ("=", field p path "__constructs__", arr),p) in		
+		let meta = (match Codegen.build_metadata ctx.com (TEnumDecl e) with
+			| None -> []
+			| Some e -> [EBinop ("=",field p path "__meta__", gen_expr ctx e),p]
+		) in
+		setname :: setconstrs :: meta @ acc
 	| TClassDecl c ->
 	| TClassDecl c ->
 		if c.cl_extern || c.cl_path = ([],"@Main") then
 		if c.cl_extern || c.cl_path = ([],"@Main") then
 			acc
 			acc