瀏覽代碼

implement first of two try transforms

frabbit 11 年之前
父節點
當前提交
415fa6abaf
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      genpy.ml

+ 8 - 1
genpy.ml

@@ -626,7 +626,14 @@ module Transformer = struct
 			let r = { a_expr with eexpr = TArray(e1.a_expr, e2.a_expr)} in
 			let r = { a_expr with eexpr = TArray(e1.a_expr, e2.a_expr)} in
 			let blocks = List.append e1.a_blocks e2.a_blocks in
 			let blocks = List.append e1.a_blocks e2.a_blocks in
 			lift_expr ~blocks:blocks r
 			lift_expr ~blocks:blocks r
-		| (false, TTry(etry, catches)) -> assert false
+		| (false, TTry(etry, catches)) -> 
+			let etry = trans false [] etry in
+			let catches = List.map (fun(v,e) -> v, trans false [] e) catches in
+			let blocks = List.flatten (List.map (fun (_,e) -> e.a_blocks) catches) in
+			let catches = List.map (fun(v,e) -> v, e.a_expr) catches in
+			let r = { a_expr with eexpr = TTry(etry.a_expr, catches)} in
+			let blocks = List.append etry.a_blocks blocks in
+			lift false blocks r
 		| (true, TTry(etry, catches)) -> assert false
 		| (true, TTry(etry, catches)) -> assert false
 		| (_, TObjectDecl(fields)) -> 
 		| (_, TObjectDecl(fields)) -> 
 			let fields = List.map (fun (name,ex) -> name, trans true [] ex) fields in
 			let fields = List.map (fun (name,ex) -> name, trans true [] ex) fields in