Filter: add floating point support
[lttng-tools.git] / src / lib / lttng-ctl / filter-visitor-generate-ir.c
index 9d44b234924da53f2d6a97b0333419ca0d4b0b78..dd0d7ffaf7137fc49f938462e4e7c4950a5a9cd8 100644 (file)
@@ -100,6 +100,22 @@ struct ir_op *make_op_load_numeric(int64_t v, enum ir_side side)
        return op;
 }
 
+static
+struct ir_op *make_op_load_float(double v, enum ir_side side)
+{
+       struct ir_op *op;
+
+       op = calloc(sizeof(struct ir_op), 1);
+       if (!op)
+               return NULL;
+       op->op = IR_OP_LOAD;
+       op->data_type = IR_DATA_FLOAT;
+       op->signedness = IR_SIGN_UNKNOWN;
+       op->side = side;
+       op->u.load.u.flt = v;
+       return op;
+}
+
 static
 struct ir_op *make_op_load_field_ref(char *string, enum ir_side side)
 {
@@ -314,8 +330,8 @@ struct ir_op *make_op_binary_compare(enum op_type bin_op_type,
 
        }
        if ((left->data_type == IR_DATA_STRING
-               && right->data_type == IR_DATA_NUMERIC)
-               || (left->data_type == IR_DATA_NUMERIC &&
+               && (right->data_type == IR_DATA_NUMERIC || right->data_type == IR_DATA_FLOAT))
+               || ((left->data_type == IR_DATA_NUMERIC || left->data_type == IR_DATA_FLOAT) &&
                        right->data_type == IR_DATA_STRING)) {
                fprintf(stderr, "[error] binary operation '%s' operand type mismatch\n", op_str);
                goto error;
@@ -492,6 +508,9 @@ struct ir_op *make_expression(struct filter_parser_ctx *ctx,
        case AST_EXP_CONSTANT:
                return make_op_load_numeric(node->u.expression.u.constant,
                                        side);
+       case AST_EXP_FLOAT_CONSTANT:
+               return make_op_load_float(node->u.expression.u.float_constant,
+                                       side);
        case AST_EXP_IDENTIFIER:
                if (node->u.expression.pre_op != AST_LINK_UNKNOWN) {
                        fprintf(stderr, "[error] %s: dotted and dereferenced identifiers not supported\n", __func__);
This page took 0.02353 seconds and 4 git commands to generate.