91
92
let mcode_contain_plus = function
92
93
| A.CONTEXT (_,A.NOTHING) -> false
93
94
| A.CONTEXT _ -> true
94
| A.MINUS (_,[]) -> false
95
| A.MINUS (_,x::xs) -> true
95
| A.MINUS (_,_,_,[]) -> false
96
| A.MINUS (_,_,_,x::xs) -> true
96
97
| A.PLUS -> raise Impossible
98
99
let mcode_simple_minus = function
99
| A.MINUS (_,[]) -> true
100
| A.MINUS (_,_,_,[]) -> true
113
{A.line = 0; column =0; A.strbef=[]; A.straft=[];},
114
(A.MINUS(A.DontCarePos, [])),
114
{A.line = 0; A.column =0; A.strbef=[]; A.straft=[];},
115
(A.MINUS(A.DontCarePos,[],-1,[])),
117
118
let generalize_mcode ia =
121
122
| A.PLUS -> raise Impossible
122
123
| A.CONTEXT (A.NoPos,x) ->
123
124
A.CONTEXT (A.DontCarePos,x)
124
| A.MINUS (A.NoPos,x) ->
125
A.MINUS (A.DontCarePos,x)
125
| A.MINUS (A.NoPos,inst,adj,x) ->
126
A.MINUS (A.DontCarePos,inst,adj,x)
127
128
| A.CONTEXT ((A.FixPos _|A.DontCarePos), _)
128
| A.MINUS ((A.FixPos _|A.DontCarePos), _)
129
| A.MINUS ((A.FixPos _|A.DontCarePos), _, _, _)
448
449
ref (Some ((Lib_parsing_c.al_type returnType),local),
449
450
Ast_c.NotTest) in
450
451
let ident = name in
451
let idexpr = (B.Ident (ident), typ),Ast_c.noii in
453
((B.Assignment (idexpr, B.SimpleAssign, e),
454
Ast_c.noType()), [iini])
453
Ast_c.mk_e_bis (B.Ident (ident)) typ Ast_c.noii
457
(B.Assignment (idexpr,B.SimpleAssign, e)) [iini] in
455
460
| _ -> F.Decl decl
457
462
| _ -> F.Decl decl
1095
1099
(B.RegularName (s, [iis]))
1097
1101
| B.CppConcatenatedName _ | B.CppVariadicName _ |B.CppIdentBuilder _
1103
(* This should be moved to the Id case of ident. Metavariables
1104
should be allowed to be bound to such variables. But doing so
1105
would require implementing an appropriate distr function *)
1100
1108
and (ident: info_ident -> (A.ident, string * Ast_c.info) matcher) =
1101
1109
fun infoidb ida ((idb, iib) as ib) ->
2287
2294
pr2_once "PB: More that one variable in decl. Have to split";
2291
let _iiptvirgb = tuple_of_list1 iifield in
2297
| B.EmptyField _iifield ->
2294
| B.MacroStructDeclTodo -> fail
2300
| B.MacroDeclField _ ->
2295
2303
| B.CppDirectiveStruct directive -> fail
2296
2304
| B.IfdefStruct directive -> fail
3749
3757
| _, F.ExprStatement (_, (None, ii)) -> fail (* happen ? *)
3751
| A.Label(id,dd), F.Label (st,(s,ii)) ->
3752
let (ib1,ib2) = tuple_of_list2 ii in
3753
let (string_of_id,rebuild) =
3754
match A.unwrap id with
3755
A.Id(s) -> (s,function s -> A.rewrap id (A.Id(s)))
3756
| _ -> failwith "labels with metavariables not supported" in
3757
if (term string_of_id) =$= s
3759
tokenf string_of_id ib1 >>= (fun string_of_id ib1 ->
3759
| A.Label(id,dd), F.Label (st, nameb, ((),ii)) ->
3760
let (ib2) = tuple_of_list1 ii in
3761
(match A.unwrap id with
3763
ident_cpp DontKnow id nameb >>= (fun ida nameb ->
3760
3764
tokenf dd ib2 >>= (fun dd ib2 ->
3762
A.Label(rebuild string_of_id,dd),
3763
F.Label (st,(s,[ib1;ib2]))
3767
F.Label (st,nameb, ((),[ib2]))
3769
| _ -> failwith "labels with metavariables not supported"
3767
| A.Goto(goto,id,sem), F.Goto (st,(s,ii)) ->
3768
let (ib1,ib2,ib3) = tuple_of_list3 ii in
3772
| A.Goto(goto,id,sem), F.Goto (st,nameb, ((),ii)) ->
3773
let (ib1,ib3) = tuple_of_list2 ii in
3769
3774
tokenf goto ib1 >>= (fun goto ib1 ->
3770
ident DontKnow id (s, ib2) >>= (fun id (s, ib2) ->
3775
ident_cpp DontKnow id nameb >>= (fun id nameb ->
3771
3776
tokenf sem ib3 >>= (fun sem ib3 ->
3773
3778
A.Goto(goto,id,sem),
3774
F.Goto (st,(s,[ib1;ib2;ib3]))
3779
F.Goto (st,nameb, ((),[ib1;ib3]))
3777
3782
(* have not a counter part in coccinelle, for the moment *)
3788
3793
(F.MacroStmt (_, _)| F.DefineDoWhileZeroHeader _| F.EndNode|F.TopNode)
3791
(F.Label (_, _)|F.Break (_, _)|F.Continue (_, _)|F.Default (_, _)|
3796
(F.Label (_, _, _)|F.Break (_, _)|F.Continue (_, _)|F.Default (_, _)|
3792
3797
F.Case (_, _)|F.Include _|F.Goto _|F.ExprStatement _|
3793
3798
F.DefineType _|F.DefineExpr _|F.DefineTodo|
3794
3799
F.DefineHeader (_, _)|F.ReturnExpr (_, _)|F.Return (_, _)|F.MacroIterHeader (_, _)|