let rec type_collect res = function
TC.ConstVol(_,ty) | TC.Pointer(ty) | TC.FunctionPointer(ty)
| TC.Array(ty) -> type_collect res ty
+ | TC.EnumName(TC.MV(tyname,_,_)) ->
+ bind [tyname] res
+ | TC.StructUnionName(_,TC.MV(tyname,_,_)) ->
+ bind [tyname] res
| TC.MetaType(tyname,_,_) ->
bind [tyname] res
| TC.SignedT(_,Some ty) -> type_collect res ty
let astfvdecls recursor k d =
bind (k d)
(match Ast.unwrap d with
- Ast.DisjDecl(decls) -> bind_disj (List.map k decls)
+ Ast.MetaDecl(name,_,_) | Ast.MetaField(name,_,_) -> [metaid name]
+ | Ast.DisjDecl(decls) -> bind_disj (List.map k decls)
| _ -> option_default) in
let astfvfullType recursor k ty =
V.combiner bind option_default
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing donothing donothing
+ donothing donothing donothing donothing donothing
astfvident astfvexpr astfvfullType astfvtypeC astfvinit astfvparam
astfvdecls astfvrule_elem astfvstatement donothing donothing donothing_a
let rec type_collect res = function
TC.ConstVol(_,ty) | TC.Pointer(ty) | TC.FunctionPointer(ty)
| TC.Array(ty) -> type_collect res ty
+ | TC.EnumName(TC.MV(tyname,TC.Saved,_)) ->
+ bind [tyname] res
+ | TC.StructUnionName(_,TC.MV(tyname,TC.Saved,_)) ->
+ bind [tyname] res
| TC.MetaType(tyname,TC.Saved,_) ->
bind [tyname] res
| TC.SignedT(_,Some ty) -> type_collect res ty
| Ast.MetaParamList(name,_,_,_) -> [metaid name]
| _ -> option_default) in
+ let astfvdecls recursor k d =
+ bind (k d)
+ (match Ast.unwrap d with
+ Ast.MetaDecl(name,TC.Saved,_) | Ast.MetaField(name,TC.Saved,_) ->
+ [metaid name]
+ | _ -> option_default) in
+
let astfvrule_elem recursor k re =
(*within a rule_elem, pattern3 manages the coherence of the bindings*)
bind (k re)
V.combiner bind option_default
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing donothing donothing
+ donothing donothing donothing donothing donothing
astfvident astfvexpr donothing astfvtypeC astfvinit astfvparam
- donothing astfvrule_elem donothing donothing donothing donothing
+ astfvdecls astfvrule_elem donothing donothing donothing donothing
(* ---------------------------------------------------------------- *)
V.combiner bind option_default
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing donothing donothing
+ donothing donothing donothing donothing donothing
donothing donothing donothing donothing donothing donothing
donothing astfvrule_elem astfvstatement donothing donothing donothing
| TC.Pointer(ty) -> TC.Pointer(type_infos ty)
| TC.FunctionPointer(ty) -> TC.FunctionPointer(type_infos ty)
| TC.Array(ty) -> TC.Array(type_infos ty)
+ | TC.EnumName(TC.MV(name,_,_)) ->
+ let (unitary,inherited) = classify (name,(),(),Ast.NoMetaPos) in
+ TC.EnumName(TC.MV(name,unitary,inherited))
+ | TC.StructUnionName(su,TC.MV(name,_,_)) ->
+ let (unitary,inherited) = classify (name,(),(),Ast.NoMetaPos) in
+ TC.StructUnionName(su,TC.MV(name,unitary,inherited))
| TC.MetaType(name,_,_) ->
let (unitary,inherited) = classify (name,(),(),Ast.NoMetaPos) in
Type_cocci.MetaType(name,unitary,inherited)
Ast.rewrap e (Ast.MetaParamList(name,lenname,unitary,inherited))
| _ -> e in
+ let decl r k e =
+ let e = k e in
+ match Ast.unwrap e with
+ Ast.MetaDecl(name,_,_) ->
+ let (unitary,inherited) = classify name in
+ Ast.rewrap e (Ast.MetaDecl(name,unitary,inherited))
+ | Ast.MetaField(name,_,_) ->
+ let (unitary,inherited) = classify name in
+ Ast.rewrap e (Ast.MetaField(name,unitary,inherited))
+ | _ -> e in
+
let rule_elem r k e =
let e = k e in
match Ast.unwrap e with
let fn = V.rebuilder
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing donothing donothing
- ident expression donothing typeC init param donothing rule_elem
+ donothing donothing donothing donothing donothing
+ ident expression donothing typeC init param decl rule_elem
donothing donothing donothing donothing in
List.map fn.V.rebuilder_top_level minirules
V.rebuilder
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing astfvstatement_dots donothing
+ donothing donothing astfvstatement_dots donothing donothing
donothing donothing donothing donothing donothing donothing donothing
astfvrule_elem astfvstatement astfvcase_line astfvtoplevel donothing
[] -> []
| (metavars, rule)::rules ->
match rule with
- Ast.ScriptRule (_,_,_,_,_)
+ Ast.ScriptRule (_,_,_,_,script_vars,_) ->
+ (* why are metavars in rule, but outside for cocci rule??? *)
+ let bound = script_vars @ bound in
+ rule::(loop bound rules)
| Ast.InitialScriptRule (_,_,_,_) | Ast.FinalScriptRule (_,_,_,_) ->
(* bound stays as is because script rules have no names, so no
inheritance is possible *)
let v =
V.combiner bind option_default
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
- donothing donothing donothing donothing
+ donothing donothing donothing donothing donothing
donothing donothing donothing donothing donothing donothing
donothing donothing donothing donothing donothing donothing in
match rule with
List.fold_right
(function (metavar_list,r) ->
function (used_after,used_after_lists) ->
- let locally_defined = List.map Ast.get_meta_name metavar_list in
+ let locally_defined =
+ match r with
+ Ast.ScriptRule (_,_,_,_,free_vars,_) -> free_vars
+ | _ -> List.map Ast.get_meta_name metavar_list in
let continue_propagation =
List.filter (function x -> not(List.mem x locally_defined))
used_after in
let free_vars =
match r with
- Ast.ScriptRule (_,_,_,mv,_) ->
+ Ast.ScriptRule (_,_,_,mv,_,_) ->
drop_virt(List.map (function (_,(r,v),_) -> (r,v)) mv)
| Ast.InitialScriptRule (_,_,_,_)
| Ast.FinalScriptRule (_,_,_,_) -> []
(function (metavars,r) ->
function used_after ->
match r with
- Ast.ScriptRule (_,_,_,_,_)
+ Ast.ScriptRule (_,_,_,_,_,_) (* no minirules, so nothing to do? *)
| Ast.InitialScriptRule (_,_,_,_) | Ast.FinalScriptRule (_,_,_,_) ->
- ([], [used_after], [], [])
+ ([], [used_after], [[]], [])
| Ast.CocciRule (name, rule_info, minirules, _,_) ->
collect_local_used_after metavars minirules used_after
)
List.map
(function (mv, r) ->
match r with
- Ast.ScriptRule _
+ Ast.ScriptRule _ (* doesn't declare position variables *)
| Ast.InitialScriptRule _ | Ast.FinalScriptRule _ -> []
| Ast.CocciRule (_,_,rule,_,_) ->
let positions =