Explorar o código

print arguments of TFunction

Simon Krajewski %!s(int64=10) %!d(string=hai) anos
pai
achega
8174084819
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      type.ml

+ 5 - 1
type.ml

@@ -1127,7 +1127,11 @@ let rec s_expr_ast print_var_ids tabs s_type e =
 	| TArrayDecl el -> tag "ArrayDecl" (List.map loop el)
 	| TCall (e1,el) -> tag "Call" (loop e1 :: (List.map loop el))
 	| TNew (c,tl,el) -> tag "New" ((s_type (TInst(c,tl))) :: (List.map loop el))
-	| TFunction f -> tag "Function" [loop f.tf_expr]
+	| TFunction f ->
+		let arg (v,cto) =
+			tag "Arg" ~t:(Some v.v_type) ~extra_tabs:"\t" (match cto with None -> [local v] | Some ct -> [local v;const ct])
+		in
+		tag "Function" ((List.map arg f.tf_args) @ [loop f.tf_expr])
 	| TVar (v,eo) -> var v (match eo with None -> [] | Some e -> [loop e])
 	| TBlock el -> tag "Block" (List.map loop el)
 	| TIf (e,e1,e2) -> tag "If" (loop e :: (Printf.sprintf "[Then:%s] %s" (s_type e1.etype) (loop e1)) :: (match e2 with None -> [] | Some e -> [Printf.sprintf "[Else:%s] %s" (s_type e.etype) (loop e)]))