浏览代码

allow to store Classes in registers without cast

Nicolas Cannasse 17 年之前
父节点
当前提交
86924eadf5
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      genswf9.ml

+ 9 - 2
genswf9.ml

@@ -31,6 +31,7 @@ type tkind =
 	| KBool
 	| KBool
 	| KType of hl_name
 	| KType of hl_name
 	| KDynamic
 	| KDynamic
+	| KNone
 
 
 type register = {
 type register = {
 	rid : int;
 	rid : int;
@@ -221,8 +222,11 @@ let classify ctx t =
 		KUInt
 		KUInt
 	| TFun _ ->
 	| TFun _ ->
 		KType (HMPath ([],"Function"))
 		KType (HMPath ([],"Function"))
-	| TMono _
-	| TAnon _
+	| TAnon a ->
+		(match !(a.a_status) with
+		| Statics _ -> KNone
+		| _ -> KDynamic)
+	| TMono _	
 	| TType _
 	| TType _
 	| TDynamic _ ->
 	| TDynamic _ ->
 		KDynamic
 		KDynamic
@@ -285,6 +289,7 @@ let coerce ctx t =
 	   this type on the stack (as detected by the bytecode verifier)...
 	   this type on the stack (as detected by the bytecode verifier)...
 	   maybe this get removed at JIT, so it's only useful to reduce codesize
 	   maybe this get removed at JIT, so it's only useful to reduce codesize
 	*)
 	*)
+	if t <> KNone then
 	write ctx (match t with
 	write ctx (match t with
 		| KInt -> HToInt
 		| KInt -> HToInt
 		| KUInt -> HToUInt
 		| KUInt -> HToUInt
@@ -292,6 +297,7 @@ let coerce ctx t =
 		| KBool -> HToBool
 		| KBool -> HToBool
 		| KType t -> HCast t
 		| KType t -> HCast t
 		| KDynamic -> HAsAny
 		| KDynamic -> HAsAny
+		| KNone -> assert false
 	)
 	)
 
 
 let set_reg ctx r =
 let set_reg ctx r =
@@ -514,6 +520,7 @@ let begin_fun ctx args tret el stat p =
 			| KBool -> HFalse :: s
 			| KBool -> HFalse :: s
 			| KType t -> HNull :: HAsType t :: s
 			| KType t -> HNull :: HAsType t :: s
 			| KDynamic -> HNull :: HAsAny :: s
 			| KDynamic -> HNull :: HAsAny :: s
+			| KNone -> HNull :: s
 		) (DynArray.to_list ctx.infos.iregs)) in
 		) (DynArray.to_list ctx.infos.iregs)) in
 		let delta = List.length extra in
 		let delta = List.length extra in
 		let f = {
 		let f = {