struct expr *low, struct expr *high);
struct expr *range_expr_to_prefix(struct expr *range);
-extern struct expr *compound_expr_alloc(const struct location *loc,
- enum expr_types etypes);
extern void list_expr_sort(struct list_head *head);
extern void list_splice_sorted(struct list_head *list, struct list_head *head);
loc = dev_expr->location;
expr_free(dev_expr);
- dev_expr = compound_expr_alloc(&loc, EXPR_LIST);
+ dev_expr = list_expr_alloc(&loc);
list_splice_init(&tmp, &expr_list(dev_expr)->expressions);
return dev_expr;
return expr;
}
-struct expr *compound_expr_alloc(const struct location *loc,
- enum expr_types etype)
-{
- struct expr *expr;
-
- expr = expr_alloc(loc, etype, &invalid_type, BYTEORDER_INVALID, 0);
- /* same layout for EXPR_CONCAT, EXPR_SET and EXPR_LIST. */
- init_list_head(&expr->expr_set.expressions);
- return expr;
-}
-
static void concat_expr_destroy(struct expr *expr)
{
struct expr *i, *next;
struct expr *concat_expr_alloc(const struct location *loc)
{
- return compound_expr_alloc(loc, EXPR_CONCAT);
+ struct expr *expr;
+
+ expr = expr_alloc(loc, EXPR_CONCAT, &invalid_type, BYTEORDER_INVALID, 0);
+ init_list_head(&expr_concat(expr)->expressions);
+
+ return expr;
}
void concat_expr_add(struct expr *concat, struct expr *item)
struct expr *list_expr_alloc(const struct location *loc)
{
- return compound_expr_alloc(loc, EXPR_LIST);
+ struct expr *expr;
+
+ expr = expr_alloc(loc, EXPR_LIST, &invalid_type, BYTEORDER_INVALID, 0);
+ init_list_head(&expr_list(expr)->expressions);
+
+ return expr;
}
void list_expr_add(struct expr *expr, struct expr *item)
struct expr *set_expr_alloc(const struct location *loc, const struct set *set)
{
- struct expr *set_expr = compound_expr_alloc(loc, EXPR_SET);
+ struct expr *set_expr;
+
+ set_expr = expr_alloc(loc, EXPR_SET, &invalid_type, BYTEORDER_INVALID, 0);
+ init_list_head(&expr_set(set_expr)->expressions);
if (!set)
return set_expr;
flowtable_list_expr : flowtable_expr_member
{
- $$ = compound_expr_alloc(&@$, EXPR_LIST);
+ $$ = list_expr_alloc(&@$);
list_expr_add($$, $1);
}
| flowtable_list_expr COMMA flowtable_expr_member
if (!expr)
YYERROR;
- $$ = compound_expr_alloc(&@$, EXPR_LIST);
+ $$ = list_expr_alloc(&@$);
list_expr_add($$, expr);
}
| DEVICE variable_expr
{
datatype_set($2->sym->expr, &ifname_type);
- $$ = compound_expr_alloc(&@$, EXPR_LIST);
+ $$ = list_expr_alloc(&@$);
list_expr_add($$, $2);
}
| DEVICES '=' flowtable_expr
initializer_expr : rhs_expr
| list_rhs_expr
- | '{' '}' { $$ = compound_expr_alloc(&@$, EXPR_SET); }
+ | '{' '}' { $$ = set_expr_alloc(&@$, NULL); }
| DASH NUM
{
int32_t num = -$2;
static struct expr *json_parse_devs(struct json_ctx *ctx, json_t *root)
{
- struct expr *tmp, *expr = compound_expr_alloc(int_loc, EXPR_LIST);
+ struct expr *tmp, *expr = list_expr_alloc(int_loc);
const char *dev;
json_t *value;
size_t index;