2 * Copyright 2005-2010, Ecole des Mines de Nantes, University of Copenhagen
3 * Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
4 * This file is part of Coccinelle.
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.
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.
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/>.
18 * The authors reserve the right to distribute this or future versions of
19 * Coccinelle under other licenses.
23 (* Constraints on Meta-* Identifiers, Functions *)
26 | IdNegIdSet
of string list
27 | IdRegExp
of string * Str.regexp
28 | IdNotRegExp
of string * Str.regexp
30 (* --------------------------------------------------------------------- *)
33 type added_string
= Noindent
of string | Indent
of string
35 type info
= { line
: int; column
: int;
36 strbef
: (added_string
* int (* line *) * int (* col *)) list
;
37 straft
: (added_string
* int (* line *) * int (* col *)) list
}
39 type meta_name
= string * string
40 (* need to be careful about rewrapping, to avoid duplicating pos info
41 currently, the pos info is always None until asttoctl2. *)
45 free_vars
: meta_name list
; (*free vars*)
46 minus_free_vars
: meta_name list
; (*minus free vars*)
47 fresh_vars
: (meta_name
* seed
) list
; (*fresh vars*)
48 inherited
: meta_name list
; (*inherited vars*)
49 saved_witness
: meta_name list
; (*witness vars*)
50 bef_aft
: dots_bef_aft
;
51 (* the following is for or expressions *)
52 pos_info
: meta_name mcode
option; (* pos info, try not to duplicate *)
53 true_if_test_exp
: bool;(* true if "test_exp from iso", only for exprs *)
54 (* isos relevant to the term; ultimately only used for rule_elems *)
55 iso_info
: (string*anything
) list
}
58 BEFORE
of 'a list list
* count
59 | AFTER
of 'a list list
* count
60 | BEFOREAFTER
of 'a list list
* 'a list list
* count
63 and 'a mcode
= 'a
* info
* mcodekind
* meta_pos
(* pos variable *)
64 (* pos is an offset indicating where in the C code the mcodekind
66 (* int list is the match instances, which are only meaningful in annotated
68 (* int is the adjacency index, which is incremented on context dots *)
69 (* iteration is only allowed on contect code, the intuition vaguely being
70 that there is no way to replace something more than once. Actually,
71 allowing iterated additions on minus code would cause problems with some
72 heuristics for adding braces, because one couldn't identify simple
73 replacements with certainty. Anyway, iteration doesn't seem to be needed
74 on - code for the moment. Although it may be confusing that there can be
75 iterated addition of code before context code where the context code is
76 immediately followed by removed code. *)
78 MINUS
of pos
* int list
* int * anything list list
79 | CONTEXT
of pos
* anything befaft
81 and count
= ONE
(* + *) | MANY
(* ++ *)
83 Real
of int (* charpos *) | Virt
of int * int (* charpos + offset *)
84 and pos
= NoPos
| DontCarePos
| FixPos
of (fixpos
* fixpos
)
88 | AddingBetweenDots
of statement
* int (*index of let var*)
89 | DroppingBetweenDots
of statement
* int (*index of let var*)
91 and inherited
= Type_cocci.inherited
92 and keep_binding
= Type_cocci.keep_binding
93 and multi
= bool (*true if a nest is one or more, false if it is zero or more*)
96 meta_name list
(*free vars*) * (meta_name
* seed
) list
(*fresh*) *
97 meta_name list
(*inherited vars*) * mcodekind
99 (* --------------------------------------------------------------------- *)
102 and arity
= UNIQUE
| OPT
| MULTI
| NONE
105 MetaIdDecl
of arity
* meta_name
(* name *)
106 | MetaFreshIdDecl
of meta_name
(* name *) * seed
(* seed *)
107 | MetaTypeDecl
of arity
* meta_name
(* name *)
108 | MetaInitDecl
of arity
* meta_name
(* name *)
109 | MetaListlenDecl
of meta_name
(* name *)
110 | MetaParamDecl
of arity
* meta_name
(* name *)
111 | MetaParamListDecl
of arity
* meta_name
(*name*) * meta_name
option (*len*)
113 arity
* meta_name
(* name *) * Type_cocci.typeC list
option
114 | MetaErrDecl
of arity
* meta_name
(* name *)
116 arity
* meta_name
(* name *) * Type_cocci.typeC list
option
118 arity
* meta_name
(* name *) * Type_cocci.typeC list
option
119 | MetaLocalIdExpDecl
of
120 arity
* meta_name
(* name *) * Type_cocci.typeC list
option
121 | MetaExpListDecl
of arity
* meta_name
(*name*) * meta_name
option (*len*)
122 | MetaStmDecl
of arity
* meta_name
(* name *)
123 | MetaStmListDecl
of arity
* meta_name
(* name *)
124 | MetaFuncDecl
of arity
* meta_name
(* name *)
125 | MetaLocalFuncDecl
of arity
* meta_name
(* name *)
126 | MetaPosDecl
of arity
* meta_name
(* name *)
127 | MetaDeclarerDecl
of arity
* meta_name
(* name *)
128 | MetaIteratorDecl
of arity
* meta_name
(* name *)
130 and seed
= NoVal
| StringSeed
of string | ListSeed
of seed_elem list
131 and seed_elem
= SeedString
of string | SeedId
of meta_name
133 (* --------------------------------------------------------------------- *)
134 (* --------------------------------------------------------------------- *)
142 and 'a dots
= 'a base_dots wrap
144 (* --------------------------------------------------------------------- *)
149 | MetaId
of meta_name mcode
* idconstraint
* keep_binding
* inherited
150 | MetaFunc
of meta_name mcode
* idconstraint
* keep_binding
* inherited
151 | MetaLocalFunc
of meta_name mcode
* idconstraint
* keep_binding
* inherited
154 | UniqueIdent
of ident
156 and ident
= base_ident wrap
158 (* --------------------------------------------------------------------- *)
161 and base_expression
=
163 | Constant
of constant mcode
164 | FunCall
of expression
* string mcode
(* ( *) *
165 expression dots
* string mcode
(* ) *)
166 | Assignment
of expression
* assignOp mcode
* expression
*
167 bool (* true if it can match an initialization *)
168 | CondExpr
of expression
* string mcode
(* ? *) * expression
option *
169 string mcode
(* : *) * expression
170 | Postfix
of expression
* fixOp mcode
171 | Infix
of expression
* fixOp mcode
172 | Unary
of expression
* unaryOp mcode
173 | Binary
of expression
* binaryOp mcode
* expression
174 | Nested
of expression
* binaryOp mcode
* expression
175 | ArrayAccess
of expression
* string mcode
(* [ *) * expression
*
177 | RecordAccess
of expression
* string mcode
(* . *) * ident
178 | RecordPtAccess
of expression
* string mcode
(* -> *) * ident
179 | Cast
of string mcode
(* ( *) * fullType
* string mcode
(* ) *) *
181 | SizeOfExpr
of string mcode
(* sizeof *) * expression
182 | SizeOfType
of string mcode
(* sizeof *) * string mcode
(* ( *) *
183 fullType
* string mcode
(* ) *)
184 | TypeExp
of fullType
(*type name used as an expression, only in
187 | Paren
of string mcode
(* ( *) * expression
*
190 | MetaErr
of meta_name mcode
* constraints
* keep_binding
*
192 | MetaExpr
of meta_name mcode
* constraints
* keep_binding
*
193 Type_cocci.typeC list
option * form
* inherited
194 | MetaExprList
of meta_name mcode
* listlen
option * keep_binding
*
195 inherited
(* only in arg lists *)
197 | EComma
of string mcode
(* only in arg lists *)
199 | DisjExpr
of expression list
200 | NestExpr
of expression dots
* expression
option * multi
202 (* can appear in arg lists, and also inside Nest, as in:
203 if(< ... X ... Y ...>)
204 In the following, the expression option is the WHEN *)
205 | Edots
of string mcode
(* ... *) * expression
option
206 | Ecircles
of string mcode
(* ooo *) * expression
option
207 | Estars
of string mcode
(* *** *) * expression
option
209 | OptExp
of expression
210 | UniqueExp
of expression
214 | NotIdCstrt
of idconstraint
215 | NotExpCstrt
of expression list
217 (* ANY = int E; ID = idexpression int X; CONST = constant int X; *)
218 and form
= ANY
| ID
| LocalID
| CONST
(* form for MetaExp *)
220 and expression
= base_expression wrap
222 and listlen
= meta_name mcode
* keep_binding
* inherited
224 and unaryOp
= GetRef
| DeRef
| UnPlus
| UnMinus
| Tilde
| Not
225 and assignOp
= SimpleAssign
| OpAssign
of arithOp
226 and fixOp
= Dec
| Inc
228 and binaryOp
= Arith
of arithOp
| Logical
of logicalOp
230 Plus
| Minus
| Mul
| Div
| Mod
| DecLeft
| DecRight
| And
| Or
| Xor
231 and logicalOp
= Inf
| Sup
| InfEq
| SupEq
| Eq
| NotEq
| AndLog
| OrLog
239 (* --------------------------------------------------------------------- *)
243 Type
of const_vol mcode
option * typeC
244 | DisjType
of fullType list
(* only after iso *)
245 | OptType
of fullType
246 | UniqueType
of fullType
249 BaseType
of baseType
* string mcode list
(* Yoann style *)
250 | SignedT
of sign mcode
* typeC
option
251 | Pointer
of fullType
* string mcode
(* * *)
252 | FunctionPointer
of fullType
*
253 string mcode
(* ( *)*string mcode
(* * *)*string mcode
(* ) *)*
254 string mcode
(* ( *)*parameter_list
*string mcode
(* ) *)
256 (* used for the automatic managment of prototypes *)
257 | FunctionType
of bool (* true if all minus for dropping return type *) *
259 string mcode
(* ( *) * parameter_list
*
262 | Array
of fullType
* string mcode
(* [ *) *
263 expression
option * string mcode
(* ] *)
264 | EnumName
of string mcode
(*enum*) * ident
(* name *)
265 | StructUnionName
of structUnion mcode
* ident
option (* name *)
266 | StructUnionDef
of fullType
(* either StructUnionName or metavar *) *
267 string mcode
(* { *) * declaration dots
* string mcode
(* } *)
268 | TypeName
of string mcode
(* pad: should be 'of ident' ? *)
270 | MetaType
of meta_name mcode
* keep_binding
* inherited
272 and fullType
= base_fullType wrap
273 and typeC
= base_typeC wrap
275 and baseType
= VoidType
| CharType
| ShortType
| IntType
| DoubleType
276 | FloatType
| LongType
| LongLongType
278 and structUnion
= Struct
| Union
280 and sign
= Signed
| Unsigned
282 and const_vol
= Const
| Volatile
284 (* --------------------------------------------------------------------- *)
285 (* Variable declaration *)
286 (* Even if the Cocci program specifies a list of declarations, they are
287 split out into multiple declarations of a single variable each. *)
289 and base_declaration
=
290 Init
of storage mcode
option * fullType
* ident
* string mcode
(*=*) *
291 initialiser
* string mcode
(*;*)
292 | UnInit
of storage mcode
option * fullType
* ident
* string mcode
(* ; *)
293 | TyDecl
of fullType
* string mcode
(* ; *)
294 | MacroDecl
of ident
(* name *) * string mcode
(* ( *) *
295 expression dots
* string mcode
(* ) *) * string mcode
(* ; *)
296 | Typedef
of string mcode
(*typedef*) * fullType
*
297 typeC
(* either TypeName or metavar *) * string mcode
(*;*)
298 | DisjDecl
of declaration list
299 (* Ddots is for a structure declaration *)
300 | Ddots
of string mcode
(* ... *) * declaration
option (* whencode *)
302 | MetaDecl
of meta_name mcode
* keep_binding
* inherited
304 | OptDecl
of declaration
305 | UniqueDecl
of declaration
307 and declaration
= base_declaration wrap
309 (* --------------------------------------------------------------------- *)
312 and base_initialiser
=
313 MetaInit
of meta_name mcode
* keep_binding
* inherited
314 | InitExpr
of expression
315 | InitList
of string mcode
(*{*) * initialiser list
* string mcode
(*}*) *
316 initialiser list
(* whencode: elements that shouldn't appear in init *)
318 designator list
(* name *) * string mcode
(*=*) *
319 initialiser
(* gccext: *)
320 | InitGccName
of ident
(* name *) * string mcode
(*:*) *
322 | IComma
of string mcode
(* , *)
324 | OptIni
of initialiser
325 | UniqueIni
of initialiser
328 DesignatorField
of string mcode
(* . *) * ident
329 | DesignatorIndex
of string mcode
(* [ *) * expression
* string mcode
(* ] *)
331 string mcode
(* [ *) * expression
* string mcode
(* ... *) *
332 expression
* string mcode
(* ] *)
334 and initialiser
= base_initialiser wrap
336 (* --------------------------------------------------------------------- *)
339 and base_parameterTypeDef
=
340 VoidParam
of fullType
341 | Param
of fullType
* ident
option
343 | MetaParam
of meta_name mcode
* keep_binding
* inherited
344 | MetaParamList
of meta_name mcode
* listlen
option * keep_binding
*
347 | PComma
of string mcode
349 | Pdots
of string mcode
(* ... *)
350 | Pcircles
of string mcode
(* ooo *)
352 | OptParam
of parameterTypeDef
353 | UniqueParam
of parameterTypeDef
355 and parameterTypeDef
= base_parameterTypeDef wrap
357 and parameter_list
= parameterTypeDef dots
359 (* --------------------------------------------------------------------- *)
360 (* #define Parameters *)
362 and base_define_param
=
364 | DPComma
of string mcode
365 | DPdots
of string mcode
(* ... *)
366 | DPcircles
of string mcode
(* ooo *)
367 | OptDParam
of define_param
368 | UniqueDParam
of define_param
370 and define_param
= base_define_param wrap
372 and base_define_parameters
=
373 NoParams
(* not parameter list, not an empty one *)
374 | DParams
of string mcode
(*( *) * define_param dots
* string mcode
(* )*)
376 and define_parameters
= base_define_parameters wrap
378 (* --------------------------------------------------------------------- *)
381 (* PER = keep bindings separate, ALL = collect them *)
382 and meta_collect
= PER
| ALL
385 MetaPos
of meta_name mcode
* meta_name list
*
386 meta_collect
* keep_binding
* inherited
389 (* --------------------------------------------------------------------- *)
390 (* Function declaration *)
392 and storage
= Static
| Auto
| Register
| Extern
394 (* --------------------------------------------------------------------- *)
398 FunHeader
of mcodekind
(* before the function header *) *
399 bool (* true if all minus, for dropping static, etc *) *
400 fninfo list
* ident
(* name *) *
401 string mcode
(* ( *) * parameter_list
*
403 | Decl
of mcodekind
(* before the decl *) *
404 bool (* true if all minus *) * declaration
406 | SeqStart
of string mcode
(* { *)
407 | SeqEnd
of string mcode
(* } *)
409 | ExprStatement
of expression
* string mcode
(*;*)
410 | IfHeader
of string mcode
(* if *) * string mcode
(* ( *) *
411 expression
* string mcode
(* ) *)
412 | Else
of string mcode
(* else *)
413 | WhileHeader
of string mcode
(* while *) * string mcode
(* ( *) *
414 expression
* string mcode
(* ) *)
415 | DoHeader
of string mcode
(* do *)
416 | WhileTail
of string mcode
(* while *) * string mcode
(* ( *) *
417 expression
* string mcode
(* ) *) *
419 | ForHeader
of string mcode
(* for *) * string mcode
(* ( *) *
420 expression
option * string mcode
(*;*) *
421 expression
option * string mcode
(*;*) *
422 expression
option * string mcode
(* ) *)
423 | IteratorHeader
of ident
(* name *) * string mcode
(* ( *) *
424 expression dots
* string mcode
(* ) *)
425 | SwitchHeader
of string mcode
(* switch *) * string mcode
(* ( *) *
426 expression
* string mcode
(* ) *)
427 | Break
of string mcode
(* break *) * string mcode
(* ; *)
428 | Continue
of string mcode
(* continue *) * string mcode
(* ; *)
429 | Label
of ident
* string mcode
(* : *)
430 | Goto
of string mcode
(* goto *) * ident
* string mcode
(* ; *)
431 | Return
of string mcode
(* return *) * string mcode
(* ; *)
432 | ReturnExpr
of string mcode
(* return *) * expression
*
435 | MetaRuleElem
of meta_name mcode
* keep_binding
* inherited
436 | MetaStmt
of meta_name mcode
* keep_binding
* metaStmtInfo
*
438 | MetaStmtList
of meta_name mcode
* keep_binding
* inherited
440 | Exp
of expression
(* matches a subterm *)
441 | TopExp
of expression
(* for macros body, exp at top level,
443 | Ty
of fullType
(* only at SP top level, matches a subterm *)
444 | TopInit
of initialiser
(* only at top level *)
445 | Include
of string mcode
(*#include*) * inc_file mcode
(*file *)
446 | DefineHeader
of string mcode
(* #define *) * ident
(* name *) *
447 define_parameters
(*params*)
448 | Case
of string mcode
(* case *) * expression
* string mcode
(*:*)
449 | Default
of string mcode
(* default *) * string mcode
(*:*)
450 | DisjRuleElem
of rule_elem list
453 FStorage
of storage mcode
455 | FInline
of string mcode
456 | FAttr
of string mcode
459 NotSequencible
| SequencibleAfterDots
of dots_whencode list
| Sequencible
461 and rule_elem
= base_rule_elem wrap
464 Seq
of rule_elem
(* { *) *
465 statement dots
* rule_elem
(* } *)
466 | IfThen
of rule_elem
(* header *) * statement
* end_info
(* endif *)
467 | IfThenElse
of rule_elem
(* header *) * statement
*
468 rule_elem
(* else *) * statement
* end_info
(* endif *)
469 | While
of rule_elem
(* header *) * statement
* end_info
(*endwhile*)
470 | Do
of rule_elem
(* do *) * statement
* rule_elem
(* tail *)
471 | For
of rule_elem
(* header *) * statement
* end_info
(*endfor*)
472 | Iterator
of rule_elem
(* header *) * statement
* end_info
(*enditer*)
473 | Switch
of rule_elem
(* header *) * rule_elem
(* { *) *
474 statement
(*decl*) dots
* case_line list
* rule_elem
(*}*)
475 | Atomic
of rule_elem
476 | Disj
of statement dots list
477 | Nest
of statement dots
*
478 (statement dots
,statement
) whencode list
* multi
*
479 dots_whencode list
* dots_whencode list
480 | FunDecl
of rule_elem
(* header *) * rule_elem
(* { *) *
481 statement dots
* rule_elem
(* } *)
482 | Define
of rule_elem
(* header *) * statement dots
483 | Dots
of string mcode
(* ... *) *
484 (statement dots
,statement
) whencode list
*
485 dots_whencode list
* dots_whencode list
486 | Circles
of string mcode
(* ooo *) *
487 (statement dots
,statement
) whencode list
*
488 dots_whencode list
* dots_whencode list
489 | Stars
of string mcode
(* *** *) *
490 (statement dots
,statement
) whencode list
*
491 dots_whencode list
* dots_whencode list
492 | OptStm
of statement
493 | UniqueStm
of statement
495 and ('a
,'b
) whencode
=
498 | WhenModifier
of when_modifier
499 | WhenNotTrue
of rule_elem
(* useful for fvs *)
500 | WhenNotFalse
of rule_elem
503 (* The following removes the shortest path constraint. It can be used
504 with other when modifiers *)
506 (* The following removes the special consideration of error paths. It
507 can be used with other when modifiers *)
512 (* only used with asttoctl *)
514 WParen
of rule_elem
* meta_name
(*pren_var*)
516 | Other_dots
of statement dots
518 and statement
= base_statement wrap
521 CaseLine
of rule_elem
(* case/default header *) * statement dots
522 | OptCase
of case_line
524 and case_line
= base_case_line wrap
527 Local
of inc_elem list
528 | NonLocal
of inc_elem list
536 | CODE
of statement dots
537 | FILEINFO
of string mcode
(* old file *) * string mcode
(* new file *)
538 | ERRORWORDS
of expression list
540 and top_level
= base_top_level wrap
543 CocciRulename
of string option * dependency
*
544 string list
* string list
* exists
* bool
545 | GeneratedRulename
of string option * dependency
*
546 string list
* string list
* exists
* bool
547 | ScriptRulename
of string * dependency
548 | InitialScriptRulename
of string * dependency
549 | FinalScriptRulename
of string * dependency
551 and ruletype
= Normal
| Generated
554 CocciRule
of string (* name *) *
555 (dependency
* string list
(* dropped isos *) * exists
) * top_level list
556 * bool list
* ruletype
557 | ScriptRule
of string * dependency
* (string * meta_name
) list
* string
558 | InitialScriptRule
of string (*language*) * dependency
* string (*code*)
559 | FinalScriptRule
of string (*language*) * dependency
* string (*code*)
562 Dep
of string (* rule applies for the current binding *)
563 | AntiDep
of string (* rule doesn't apply for the current binding *)
564 | EverDep
of string (* rule applies for some binding *)
565 | NeverDep
of string (* rule never applies for any binding *)
566 | AndDep
of dependency
* dependency
567 | OrDep
of dependency
* dependency
570 and rule_with_metavars
= metavar list
* rule
573 FullTypeTag
of fullType
574 | BaseTypeTag
of baseType
575 | StructUnionTag
of structUnion
578 | ExpressionTag
of expression
579 | ConstantTag
of constant
580 | UnaryOpTag
of unaryOp
581 | AssignOpTag
of assignOp
583 | BinaryOpTag
of binaryOp
584 | ArithOpTag
of arithOp
585 | LogicalOpTag
of logicalOp
586 | DeclarationTag
of declaration
587 | InitTag
of initialiser
588 | StorageTag
of storage
589 | IncFileTag
of inc_file
590 | Rule_elemTag
of rule_elem
591 | StatementTag
of statement
592 | CaseLineTag
of case_line
593 | ConstVolTag
of const_vol
594 | Token
of string * info
option
595 | Pragma
of added_string list
597 | ExprDotsTag
of expression dots
598 | ParamDotsTag
of parameterTypeDef dots
599 | StmtDotsTag
of statement dots
600 | DeclDotsTag
of declaration dots
602 | ParamTag
of parameterTypeDef
603 | SgrepStartTag
of string
604 | SgrepEndTag
of string
606 (* --------------------------------------------------------------------- *)
608 and exists
= Exists
| Forall
| Undetermined
609 (* | ReverseForall - idea: look back on all flow paths; not implemented *)
611 (* --------------------------------------------------------------------- *)
613 let mkToken x
= Token
(x
,None
)
615 (* --------------------------------------------------------------------- *)
617 let lub_count i1 i2
=
622 (* --------------------------------------------------------------------- *)
624 let rewrap model x
= {model
with node
= x
}
625 let rewrap_mcode (_
,a
,b
,c
) x
= (x
,a
,b
,c
)
626 let unwrap x
= x
.node
627 let unwrap_mcode (x
,_
,_
,_
) = x
628 let get_mcodekind (_
,_
,x
,_
) = x
629 let get_line x
= x
.node_line
630 let get_mcode_line (_
,l
,_
,_
) = l
.line
631 let get_mcode_col (_
,l
,_
,_
) = l
.column
632 let get_fvs x
= x
.free_vars
633 let set_fvs fvs x
= {x
with free_vars
= fvs
}
634 let get_mfvs x
= x
.minus_free_vars
635 let set_mfvs mfvs x
= {x
with minus_free_vars
= mfvs
}
636 let get_fresh x
= x
.fresh_vars
637 let get_inherited x
= x
.inherited
638 let get_saved x
= x
.saved_witness
639 let get_dots_bef_aft x
= x
.bef_aft
640 let set_dots_bef_aft d x
= {x
with bef_aft
= d
}
641 let get_pos x
= x
.pos_info
642 let set_pos x pos
= {x
with pos_info
= pos
}
643 let get_test_exp x
= x
.true_if_test_exp
644 let set_test_exp x
= {x
with true_if_test_exp
= true}
645 let get_isos x
= x
.iso_info
646 let set_isos x isos
= {x
with iso_info
= isos
}
647 let get_pos_var (_
,_
,_
,p
) = p
648 let set_pos_var vr
(a
,b
,c
,_
) = (a
,b
,c
,vr
)
649 let drop_pos (a
,b
,c
,_
) = (a
,b
,c
,NoMetaPos
)
651 let get_wcfvs (whencode
: ('a wrap
, 'b wrap
) whencode list
) =
655 WhenNot
(a
) -> get_fvs a
656 | WhenAlways
(a
) -> get_fvs a
657 | WhenModifier
(_
) -> []
658 | WhenNotTrue
(e
) -> get_fvs e
659 | WhenNotFalse
(e
) -> get_fvs e
)
662 (* --------------------------------------------------------------------- *)
664 let get_meta_name = function
665 MetaIdDecl
(ar
,nm
) -> nm
666 | MetaFreshIdDecl
(nm
,seed
) -> nm
667 | MetaTypeDecl
(ar
,nm
) -> nm
668 | MetaInitDecl
(ar
,nm
) -> nm
669 | MetaListlenDecl
(nm
) -> nm
670 | MetaParamDecl
(ar
,nm
) -> nm
671 | MetaParamListDecl
(ar
,nm
,nm1
) -> nm
672 | MetaConstDecl
(ar
,nm
,ty
) -> nm
673 | MetaErrDecl
(ar
,nm
) -> nm
674 | MetaExpDecl
(ar
,nm
,ty
) -> nm
675 | MetaIdExpDecl
(ar
,nm
,ty
) -> nm
676 | MetaLocalIdExpDecl
(ar
,nm
,ty
) -> nm
677 | MetaExpListDecl
(ar
,nm
,nm1
) -> nm
678 | MetaStmDecl
(ar
,nm
) -> nm
679 | MetaStmListDecl
(ar
,nm
) -> nm
680 | MetaFuncDecl
(ar
,nm
) -> nm
681 | MetaLocalFuncDecl
(ar
,nm
) -> nm
682 | MetaPosDecl
(ar
,nm
) -> nm
683 | MetaDeclarerDecl
(ar
,nm
) -> nm
684 | MetaIteratorDecl
(ar
,nm
) -> nm
686 (* --------------------------------------------------------------------- *)
689 FullTypeTag _
-> "FullTypeTag"
690 | BaseTypeTag _
-> "BaseTypeTag"
691 | StructUnionTag _
-> "StructUnionTag"
692 | SignTag _
-> "SignTag"
693 | IdentTag _
-> "IdentTag"
694 | ExpressionTag _
-> "ExpressionTag"
695 | ConstantTag _
-> "ConstantTag"
696 | UnaryOpTag _
-> "UnaryOpTag"
697 | AssignOpTag _
-> "AssignOpTag"
698 | FixOpTag _
-> "FixOpTag"
699 | BinaryOpTag _
-> "BinaryOpTag"
700 | ArithOpTag _
-> "ArithOpTag"
701 | LogicalOpTag _
-> "LogicalOpTag"
702 | DeclarationTag _
-> "DeclarationTag"
703 | InitTag _
-> "InitTag"
704 | StorageTag _
-> "StorageTag"
705 | IncFileTag _
-> "IncFileTag"
706 | Rule_elemTag _
-> "Rule_elemTag"
707 | StatementTag _
-> "StatementTag"
708 | CaseLineTag _
-> "CaseLineTag"
709 | ConstVolTag _
-> "ConstVolTag"
711 | Pragma _
-> "Pragma"
713 | ExprDotsTag _
-> "ExprDotsTag"
714 | ParamDotsTag _
-> "ParamDotsTag"
715 | StmtDotsTag _
-> "StmtDotsTag"
716 | DeclDotsTag _
-> "DeclDotsTag"
717 | TypeCTag _
-> "TypeCTag"
718 | ParamTag _
-> "ParamTag"
719 | SgrepStartTag _
-> "SgrepStartTag"
720 | SgrepEndTag _
-> "SgrepEndTag"
722 (* --------------------------------------------------------------------- *)
724 let no_info = { line
= 0; column
= -1; strbef
= []; straft
= [] }
730 minus_free_vars
= [];
736 true_if_test_exp
= false;
739 let make_meta_rule_elem s d
(fvs
,fresh
,inh
) =
742 (MetaRuleElem
(((rule,s
),no_info,d
,NoMetaPos
),Type_cocci.Unitary
,false)))
743 with free_vars
= fvs
; fresh_vars
= fresh
; inherited
= inh
}
745 let make_meta_decl s d
(fvs
,fresh
,inh
) =
748 (MetaDecl
(((rule,s
),no_info,d
,NoMetaPos
),Type_cocci.Unitary
,false))) with
749 free_vars
= fvs
; fresh_vars
= fresh
; inherited
= inh
}
751 let make_mcode x
= (x
,no_info,CONTEXT
(NoPos
,NOTHING
),NoMetaPos
)
753 (* --------------------------------------------------------------------- *)
755 let equal_pos x y
= x
= y
757 (* --------------------------------------------------------------------- *)