Commits

Corentin Derbois committed 599e35b

Clean and add tools for visitor

Comments (0)

Files changed (1)

 class visitor =
   object(this)
 
+(************************* Accept method for overriding **************************)
+
     (* Complet this accept *)
   method acceptFunctionDefinition decspe dec dec_list cs =
     ();
     if (tu <> None) then this#visitTranslationUnit (getValue tu);
     this#visitExternalDeclaration (getValue ed)
 
+(************************ Visite method *******************************)
+
   method visitFunctionDefinition ast = match ast with
   	  Ast.FUN_spec_dec_list(decspe, dec, dec_list, cs)
       -> this#acceptFunctionDefinition (Some decspe) (Some dec) (Some dec_list) (Some cs)
 	  | Ast.TU_tans(tu, ed) -> this#acceptTranslationUnit (Some tu) (Some ed)
 	  | Ast.None            -> ()
 	
+(*************** Some buttyfull method to help ***********************)
+(********************** Beurk By Kokarez *****************************)
+
+  method getFuncName ast =
+    let dd = match ast with
+      Ast.DECL_direct(dd) -> dd | _ -> raise (NotImplemented "GetFuncName") in
+      let rec rec_name ast = match ast with
+          Ast.DIDE_id(s) -> s
+        | Ast.DIDE_param_list(d, _) -> rec_name d
+        | _ -> raise (NotImplemented "GetFuncName")
+          in
+            rec_name dd
+
   end
 
 class prettyPrintVisitor =
     inherit visitor as old
 
     method acceptFunctionDefinition a b c d =
-      print_endline "Function";
+      print_endline ("Function: " ^ (this#getFuncName (getValue b)));
       old#acceptFunctionDefinition a b c d
 
   end