liblttng-ctl: use export list to define exported symbols
[lttng-tools.git] / src / common / filter / filter-visitor-ir-check-binary-op-nesting.c
CommitLineData
953192ba
MD
1/*
2 * filter-visitor-ir-check-binary-op-nesting.c
3 *
4 * LTTng filter IR check binary op nesting
5 *
ab5be9fa 6 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
953192ba 7 *
ab5be9fa 8 * SPDX-License-Identifier: LGPL-2.1-only
953192ba 9 *
953192ba
MD
10 */
11
12#include <stdio.h>
13#include <unistd.h>
14#include <string.h>
15#include <stdlib.h>
953192ba 16#include <inttypes.h>
953192ba 17#include "filter-ast.h"
95b9bd90 18#include "filter-parser.h"
953192ba
MD
19#include "filter-ir.h"
20
edf4b93e 21#include <common/compat/errno.h>
a187da1a
DG
22#include <common/macros.h>
23
953192ba
MD
24static
25int check_bin_op_nesting_recursive(struct ir_op *node, int nesting)
26{
27 switch (node->op) {
28 case IR_OP_UNKNOWN:
29 default:
30 fprintf(stderr, "[error] %s: unknown op type\n", __func__);
31 return -EINVAL;
32
33 case IR_OP_ROOT:
34 return check_bin_op_nesting_recursive(node->u.root.child,
35 nesting);
36 case IR_OP_LOAD:
37 return 0;
38 case IR_OP_UNARY:
39 return check_bin_op_nesting_recursive(node->u.unary.child,
40 nesting);
41 case IR_OP_BINARY:
42 {
43 int ret;
44
953192ba 45 ret = check_bin_op_nesting_recursive(node->u.binary.left,
29190311 46 nesting + 1);
953192ba
MD
47 if (ret)
48 return ret;
49 return check_bin_op_nesting_recursive(node->u.binary.right,
29190311 50 nesting + 1);
953192ba
MD
51 }
52 case IR_OP_LOGICAL:
53 {
54 int ret;
55
56 ret = check_bin_op_nesting_recursive(node->u.logical.left,
57 nesting);
58 if (ret)
59 return ret;
60 return check_bin_op_nesting_recursive(node->u.logical.right,
61 nesting);
62 }
63 }
64}
65
66int filter_visitor_ir_check_binary_op_nesting(struct filter_parser_ctx *ctx)
67{
68 return check_bin_op_nesting_recursive(ctx->ir_root, 0);
69}
This page took 0.052791 seconds and 4 git commands to generate.