Simon Krajewski 12 年 前
コミット
4d7454bc84
4 ファイル変更6 行追加2 行削除
  1. 1 0
      ast.ml
  2. 1 1
      codegen.ml
  3. 1 0
      common.ml
  4. 3 1
      matcher.ml

+ 1 - 0
ast.ml

@@ -85,6 +85,7 @@ module Meta = struct
 		| Meta
 		| Macro
 		| MaybeUsed
+		| MatchAny
 		| MultiType
 		| Native
 		| NativeGen

+ 1 - 1
codegen.ml

@@ -1623,7 +1623,7 @@ module PatternMatchConversion = struct
 			let null = ref None in
 			let cases = List.filter (fun (e,dt) ->
  				match e.eexpr with
- 				| TConst (TString "_") ->
+ 				| TMeta((Meta.MatchAny,_,_),_) ->
 					def := Some (convert_dt cctx dt);
 					false
 				| TConst (TNull) ->

+ 1 - 0
common.ml

@@ -344,6 +344,7 @@ module MetaInfo = struct
 		| Meta -> ":meta",("Internally used to mark a class field as being the metadata field",[])
 		| Macro -> ":macro",("(deprecated)",[])
 		| MaybeUsed -> ":maybeUsed",("Internally used by DCE to mark fields that might be kept",[Internal])
+		| MatchAny -> ":matchAny",("Internally used to mark the default case when pattern matching",[Internal])
 		| MultiType -> ":multiType",("Specifies that an abstract chooses its this-type from its @:to functions",[UsedOn TAbstract])
 		| Native -> ":native",("Rewrites the path of a class or enum during generation",[HasParam "Output type path";UsedOnEither [TClass;TEnum]])
 		| NativeGen -> ":nativeGen",("Annotates that a type should be treated as if it were an extern definition - platform native",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum]])

+ 3 - 1
matcher.ml

@@ -899,7 +899,9 @@ let convert_con ctx con = match con.c_def with
 	| CExpr e -> e
 	| CEnum(e,ef) -> mk_const ctx con.c_pos (TInt (Int32.of_int ef.ef_index))
 	| CArray i -> mk_const ctx con.c_pos (TInt (Int32.of_int i))
-	| CAny -> mk (TConst (TString "_")) (mk_mono()) con.c_pos
+	| CAny ->
+		let t = mk_mono() in
+		mk (TMeta((Meta.MatchAny,[],con.c_pos),mk (TConst (TNull)) t con.c_pos)) t con.c_pos
 	| CFields _ -> assert false
 
 (* Decision tree compilation *)