9 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * SPDX-License-Identifier: LGPL-2.1-only
15 #include "filter-ast.hpp"
19 enum ir_op_signedness {
23 IR_SIGN_DYN, /* signedness determined dynamically */
29 IR_DATA_NUMERIC, /* numeric and boolean */
32 IR_DATA_GET_CONTEXT_REF,
36 static inline const char *ir_data_type_str(enum ir_data_type type)
40 return "IR_DATA_UNKNOWN";
42 return "IR_DATA_STRING";
44 return "IR_DATA_NUMERIC";
46 return "IR_DATA_FLOAT";
47 case IR_DATA_FIELD_REF:
48 return "IR_DATA_FIELD_REF";
49 case IR_DATA_GET_CONTEXT_REF:
50 return "IR_DATA_GET_CONTEXT_REF";
51 case IR_DATA_EXPRESSION:
52 return "IR_DATA_EXPRESSION";
67 static inline const char *ir_op_type_str(enum ir_op_type type)
71 return "IR_OP_UNKNOWN";
79 return "IR_OP_BINARY";
81 return "IR_OP_LOGICAL";
87 /* left or right child */
94 enum ir_load_string_type {
95 /* Plain, no globbing at all: `hello world`. */
96 IR_LOAD_STRING_TYPE_PLAIN = 0,
98 /* Star at the end only: `hello *`. */
99 IR_LOAD_STRING_TYPE_GLOB_STAR_END,
101 /* At least one star, anywhere, but not at the end only: `he*wor*`. */
102 IR_LOAD_STRING_TYPE_GLOB_STAR,
109 enum ir_load_expression_type {
110 IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
111 IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
112 IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
113 IR_LOAD_EXPRESSION_GET_SYMBOL,
114 IR_LOAD_EXPRESSION_GET_INDEX,
115 IR_LOAD_EXPRESSION_LOAD_FIELD,
118 static inline const char *ir_load_expression_type_str(enum ir_load_expression_type type)
121 case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
122 return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
123 case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
124 return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
125 case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
126 return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
127 case IR_LOAD_EXPRESSION_GET_SYMBOL:
128 return "IR_LOAD_EXPRESSION_GET_SYMBOL";
129 case IR_LOAD_EXPRESSION_GET_INDEX:
130 return "IR_LOAD_EXPRESSION_GET_INDEX";
131 case IR_LOAD_EXPRESSION_LOAD_FIELD:
132 return "IR_LOAD_EXPRESSION_LOAD_FIELD";
138 struct ir_load_expression_op {
139 struct ir_load_expression_op *next;
140 enum ir_load_expression_type type;
147 struct ir_load_expression {
148 struct ir_load_expression_op *child;
154 enum ir_load_string_type type;
160 struct ir_load_expression *expression;
165 enum unary_op_type type;
169 struct ir_op_binary {
175 struct ir_op_logical {
182 /* common to all ops */
184 enum ir_data_type data_type;
185 enum ir_op_signedness signedness;
189 struct ir_op_root root;
190 struct ir_op_load load;
191 struct ir_op_unary unary;
192 struct ir_op_binary binary;
193 struct ir_op_logical logical;
197 #endif /* _FILTER_IR_H */