afe3bf58ef68d16660893d6acef60c580402f5e3
[bpt/coccinelle.git] / python / .#yes_pycocci_aux.ml.1.3
1 (*
2 * Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
4 * This file is part of Coccinelle.
5 *
6 * Coccinelle is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, according to version 2 of the License.
9 *
10 * Coccinelle is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
20 *)
21
22
23 open Ast_c
24 open Common
25 open Pycaml
26
27 let rec exprrep expr = match expr with
28 Ast_c.Ident s -> s
29 | Ast_c.Constant c -> constantrep c
30 | Ast_c.FunCall (e,args) -> "TODO: FunCall"
31 | Ast_c.CondExpr (e1,e2,e3) -> "TODO: CondExpr"
32 | Ast_c.Sequence (e1,e2) -> "TODO: Sequence"
33 | Ast_c.Assignment (e1,op,e2) -> "TODO: Assignment"
34 | Ast_c.Postfix (e,op) -> "TODO: Postfix"
35 | Ast_c.Infix (e,op) -> "TODO: Infix"
36 | Ast_c.Unary (e,op) -> "TODO: Unary"
37 | Ast_c.Binary (e1,op,e2) -> "TODO: Binary"
38 | Ast_c.ArrayAccess (e1,e2) -> "TODO: ArrayAccess"
39 | Ast_c.RecordAccess (e1,s) -> "TODO: RecordAccess"
40 | Ast_c.RecordPtAccess (e,s) -> "TODO: RecordPtAccess"
41 | Ast_c.SizeOfExpr e -> "TODO: SizeOfExpr"
42 | Ast_c.SizeOfType t -> "TODO: SizeOfType"
43 | Ast_c.Cast (t,e) -> "TODO: Cast"
44 | Ast_c.StatementExpr c -> "TODO: StatementExpr"
45 | Ast_c.Constructor (t,i) -> "TODO: Constructor"
46 | Ast_c.ParenExpr e -> "TODO: ParenExpr"
47 and constantrep c = match c with
48 Ast_c.String (s,isWchar) -> s
49 | Ast_c.MultiString sl -> String.concat "" sl
50 | Ast_c.Char (s,isWchar) -> s
51 | Ast_c.Int s -> s
52 | Ast_c.Float (s,t) -> s
53
54 let call_pretty f a =
55 let str = ref ([] : string list) in
56 let pr_elem info = str := (Ast_c.str_of_info info) :: !str in
57 let pr_sp _ = () in
58 f pr_elem pr_sp a;
59 String.concat " " (List.rev !str)
60
61 let stringrep mvb = match mvb with
62 Ast_c.MetaIdVal s -> s
63 | Ast_c.MetaFuncVal s -> s
64 | Ast_c.MetaLocalFuncVal s -> s
65 | Ast_c.MetaExprVal ((expr,_),[il]) -> (exprrep expr)
66 | Ast_c.MetaExprVal e -> "TODO: <<MetaExprVal>>"
67 | Ast_c.MetaExprListVal expr_list -> "TODO: <<exprlist>>"
68 | Ast_c.MetaTypeVal typ -> call_pretty Pretty_print_c.pp_type_gen typ
69 | Ast_c.MetaInitVal ini -> "TODO: <<initiliser>>"
70 | Ast_c.MetaStmtVal statement -> "TODO: stmt"
71 | Ast_c.MetaParamVal params -> "TODO: <<param>>"
72 | Ast_c.MetaParamListVal params -> "TODO: <<paramlist>>"
73 | Ast_c.MetaListlenVal n -> string_of_int n
74 | Ast_c.MetaPosVal (pos1, pos2) ->
75 let print_pos = function
76 Ast_cocci.Real x -> string_of_int x
77 | Ast_cocci.Virt(x,off) -> Printf.sprintf "%d+%d" x off in
78 Common.sprintf ("pos(%s,%s)") (print_pos pos1) (print_pos pos2)
79 | Ast_c.MetaPosValList positions -> "TODO: <<postvallist>>"
80