| 1 |
(* |
| 2 |
* This file is part of Coccinelle, lincensed under the terms of the GPL v2. |
| 3 |
* See copyright.txt in the Coccinelle source code for more information. |
| 4 |
* The Coccinelle source code can be obtained at http://coccinelle.lip6.fr |
| 5 |
*) |
| 6 |
|
| 7 |
(* Encapsulates state variables to keep track of internal state during |
| 8 |
* context rule generation. |
| 9 |
* |
| 10 |
* Contains the generated rule, current line number, mode, positions. |
| 11 |
*) |
| 12 |
|
| 13 |
(* ------------------------------------------------------------------------- *) |
| 14 |
(* TYPE *) |
| 15 |
type t |
| 16 |
|
| 17 |
(* Constructor *) |
| 18 |
val make: disj_map:Detect_patch.t -> t |
| 19 |
|
| 20 |
|
| 21 |
(* ------------------------------------------------------------------------- *) |
| 22 |
(* MODE AND LINE FUNCTIONS *) |
| 23 |
|
| 24 |
(* Change the mode of the current line *) |
| 25 |
val set_mode_star: arity:Ast0_cocci.arity -> t -> t |
| 26 |
val set_mode_context: arity:Ast0_cocci.arity -> t -> t |
| 27 |
|
| 28 |
(* Increase line number, set the mode of the new line to context. *) |
| 29 |
val inc_line: t -> t |
| 30 |
|
| 31 |
(* Increase line number, but only if current mode is star. *) |
| 32 |
val inc_star: t -> t |
| 33 |
|
| 34 |
(* Increase line number if rule line number exceeds current rule line. *) |
| 35 |
val skip: rule_line:int -> t -> t |
| 36 |
|
| 37 |
|
| 38 |
(* ------------------------------------------------------------------------- *) |
| 39 |
(* ADDING VALUE FUNCTIONS *) |
| 40 |
|
| 41 |
(* Add string value to the current line in the generated rule *) |
| 42 |
val add: string -> t -> t |
| 43 |
|
| 44 |
(* Add value, change the arity. *) |
| 45 |
val add_with_arity: string -> Ast0_cocci.arity -> t -> t |
| 46 |
|
| 47 |
|
| 48 |
(* ------------------------------------------------------------------------- *) |
| 49 |
(* DISJUNCTION FUNCTIONS *) |
| 50 |
|
| 51 |
(* start the disjunction rule *) |
| 52 |
val init_disj_result : t -> t |
| 53 |
|
| 54 |
(* get the disjunction map *) |
| 55 |
val get_disj : int -> t -> bool list |
| 56 |
|
| 57 |
(* set disjunction mode, in which everything added to the normal generated |
| 58 |
* rule is added to the disjunction rule as well. *) |
| 59 |
val set_disj_mode : bool -> t -> t |
| 60 |
|
| 61 |
|
| 62 |
(* ------------------------------------------------------------------------- *) |
| 63 |
(* POSITION FUNCTIONS *) |
| 64 |
|
| 65 |
(* freeze the position while executing the passed function *) |
| 66 |
val do_freeze_pos: (t -> t) -> t -> t |
| 67 |
|
| 68 |
(* Returns the numbered name of the new pos and the modified t *) |
| 69 |
val add_position: t -> (string * t) |
| 70 |
|
| 71 |
|
| 72 |
(* ------------------------------------------------------------------------- *) |
| 73 |
(* NO GEN FUNCTIONS *) |
| 74 |
|
| 75 |
(* flag for not generating positions *) |
| 76 |
val set_no_gen : bool -> t -> t |
| 77 |
val no_gen: t -> bool |
| 78 |
|
| 79 |
(* enter whencode nest while executing the passed function *) |
| 80 |
val do_whencode: (t -> t) -> t -> t |
| 81 |
|
| 82 |
|
| 83 |
(* ------------------------------------------------------------------------- *) |
| 84 |
(* GETTERS *) |
| 85 |
|
| 86 |
val get_positions: t -> string list |
| 87 |
val get_result: t -> |
| 88 |
string list (* main rule *) * |
| 89 |
string list option (* generated disj rule *) |