Commit | Line | Data |
---|---|---|
953192ba MD |
1 | #ifndef _FILTER_IR_H |
2 | #define _FILTER_IR_H | |
3 | ||
4 | /* | |
5 | * filter-ir.h | |
6 | * | |
7 | * LTTng filter ir | |
8 | * | |
9 | * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * | |
11 | * This library is free software; you can redistribute it and/or modify it | |
12 | * under the terms of the GNU Lesser General Public License, version 2.1 only, | |
13 | * as published by the Free Software Foundation. | |
14 | * | |
15 | * This library is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | * Lesser General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU Lesser General Public License | |
21 | * along with this library; if not, write to the Free Software Foundation, | |
22 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23 | */ | |
24 | ||
25 | #include "filter-ast.h" | |
26 | ||
27 | enum ir_op_signedness { | |
28 | IR_SIGN_UNKNOWN = 0, | |
29 | IR_SIGNED, | |
30 | IR_UNSIGNED, | |
31 | IR_SIGN_DYN, /* signedness determined dynamically */ | |
32 | }; | |
33 | ||
34 | enum ir_data_type { | |
35 | IR_DATA_UNKNOWN = 0, | |
36 | IR_DATA_STRING, | |
37 | IR_DATA_NUMERIC, /* numeric and boolean */ | |
e90d8561 | 38 | IR_DATA_FLOAT, |
953192ba | 39 | IR_DATA_FIELD_REF, |
586dc72f | 40 | IR_DATA_GET_CONTEXT_REF, |
bff988fa | 41 | IR_DATA_EXPRESSION, |
953192ba MD |
42 | }; |
43 | ||
44 | enum ir_op_type { | |
45 | IR_OP_UNKNOWN = 0, | |
46 | IR_OP_ROOT, | |
47 | IR_OP_LOAD, | |
48 | IR_OP_UNARY, | |
49 | IR_OP_BINARY, | |
50 | IR_OP_LOGICAL, | |
51 | }; | |
52 | ||
53 | /* left or right child */ | |
54 | enum ir_side { | |
55 | IR_SIDE_UNKNOWN = 0, | |
56 | IR_LEFT, | |
57 | IR_RIGHT, | |
58 | }; | |
59 | ||
9f449915 PP |
60 | enum ir_load_string_type { |
61 | /* Plain, no globbing at all: `hello world`. */ | |
62 | IR_LOAD_STRING_TYPE_PLAIN = 0, | |
63 | ||
64 | /* Star at the end only: `hello *`. */ | |
65 | IR_LOAD_STRING_TYPE_GLOB_STAR_END, | |
66 | ||
67 | /* At least one star, anywhere, but not at the end only: `he*wor*`. */ | |
68 | IR_LOAD_STRING_TYPE_GLOB_STAR, | |
69 | }; | |
70 | ||
953192ba MD |
71 | struct ir_op_root { |
72 | struct ir_op *child; | |
73 | }; | |
74 | ||
bff988fa MD |
75 | enum ir_load_expression_type { |
76 | IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT, | |
77 | IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT, | |
78 | IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT, | |
79 | IR_LOAD_EXPRESSION_GET_SYMBOL, | |
80 | IR_LOAD_EXPRESSION_GET_INDEX, | |
81 | IR_LOAD_EXPRESSION_LOAD_FIELD, | |
82 | }; | |
83 | ||
84 | struct ir_load_expression_op { | |
85 | struct ir_load_expression_op *next; | |
86 | enum ir_load_expression_type type; | |
87 | union { | |
88 | char *symbol; | |
89 | uint64_t index; | |
90 | } u; | |
91 | }; | |
92 | ||
93 | struct ir_load_expression { | |
94 | struct ir_load_expression_op *child; | |
95 | }; | |
96 | ||
953192ba MD |
97 | struct ir_op_load { |
98 | union { | |
9f449915 PP |
99 | struct { |
100 | enum ir_load_string_type type; | |
101 | char *value; | |
102 | } string; | |
953192ba | 103 | int64_t num; |
e90d8561 | 104 | double flt; |
953192ba | 105 | char *ref; |
bff988fa | 106 | struct ir_load_expression *expression; |
953192ba MD |
107 | } u; |
108 | }; | |
109 | ||
110 | struct ir_op_unary { | |
111 | enum unary_op_type type; | |
112 | struct ir_op *child; | |
113 | }; | |
114 | ||
115 | struct ir_op_binary { | |
116 | enum op_type type; | |
117 | struct ir_op *left; | |
118 | struct ir_op *right; | |
119 | }; | |
120 | ||
121 | struct ir_op_logical { | |
122 | enum op_type type; | |
123 | struct ir_op *left; | |
124 | struct ir_op *right; | |
125 | }; | |
126 | ||
127 | struct ir_op { | |
128 | /* common to all ops */ | |
129 | enum ir_op_type op; | |
130 | enum ir_data_type data_type; | |
131 | enum ir_op_signedness signedness; | |
132 | enum ir_side side; | |
133 | ||
134 | union { | |
135 | struct ir_op_root root; | |
136 | struct ir_op_load load; | |
137 | struct ir_op_unary unary; | |
138 | struct ir_op_binary binary; | |
139 | struct ir_op_logical logical; | |
140 | } u; | |
141 | }; | |
142 | ||
143 | #endif /* _FILTER_IR_H */ |