summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c6d225)
raw | patch | inline | side by side (parent: 1c6d225)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 4 Mar 2015 20:13:49 +0000 (21:13 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 4 Mar 2015 20:13:49 +0000 (21:13 +0100) |
However, when evaluating the expression, the operand has to be set. We'll use
this as a placeholder for inserting values dynamically.
this as a placeholder for inserting values dynamically.
src/core/store_lookup.c | patch | blob | history | |
src/frontend/analyzer.c | patch | blob | history |
index 2d1b3ca11e5fc895ddf7fca662412e345ba84e32..5aa69152f237576cb4d2995e15c9a3c771b5b976 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
int status;
+ assert(CMP_M(m)->left && CMP_M(m)->right);
+
if ((ITER_M(m)->m->type < MATCHER_LT)
|| (MATCHER_NREGEX < ITER_M(m)->m->type))
return 0;
|| (m->type == MATCHER_NE)
|| (m->type == MATCHER_GE)
|| (m->type == MATCHER_GT));
+ assert(e1 && e2);
if (expr_eval2(e1, &v1, e2, &v2, obj, filter))
return 0;
int status = 1;
assert((m->type == MATCHER_IN) || (m->type == MATCHER_NIN));
+ assert(CMP_M(m)->left && CMP_M(m)->right);
if (expr_eval2(CMP_M(m)->left, &value,
CMP_M(m)->right, &array, obj, filter))
assert((m->type == MATCHER_REGEX)
|| (m->type == MATCHER_NREGEX));
+ assert(CMP_M(m)->left && CMP_M(m)->right);
if (expr_eval2(CMP_M(m)->left, &v, CMP_M(m)->right, ®ex, obj, filter))
return 0;
CMP_M(obj)->right = va_arg(ap, sdb_store_expr_t *);
sdb_object_ref(SDB_OBJ(CMP_M(obj)->right));
- if ((! CMP_M(obj)->left) || (! CMP_M(obj)->right))
+ if (! CMP_M(obj)->right)
return -1;
return 0;
} /* cmp_matcher_init */
index c7a6ee0c6ff547c906a101f6b2509725b1c9dd60..62bae1c134904af8a84ede0d7906912fe3704f3e 100644 (file)
--- a/src/frontend/analyzer.c
+++ b/src/frontend/analyzer.c
} /* analyze_expr */
static int
-analyze_matcher(int context, sdb_store_matcher_t *m, sdb_strbuf_t *errbuf)
+analyze_matcher(int context, int parent_type,
+ sdb_store_matcher_t *m, sdb_strbuf_t *errbuf)
{
if (! m)
return 0;
case MATCHER_OR:
case MATCHER_AND:
assert(OP_M(m)->left && OP_M(m)->right);
- if (analyze_matcher(context, OP_M(m)->left, errbuf))
+ if (analyze_matcher(context, m->type, OP_M(m)->left, errbuf))
return -1;
- if (analyze_matcher(context, OP_M(m)->right, errbuf))
+ if (analyze_matcher(context, m->type, OP_M(m)->right, errbuf))
return -1;
break;
case MATCHER_NOT:
assert(UOP_M(m)->op);
- if (analyze_matcher(context, UOP_M(m)->op, errbuf))
+ if (analyze_matcher(context, m->type, UOP_M(m)->op, errbuf))
return -1;
break;
return -1;
}
}
- else if (analyze_matcher(ITER_M(m)->type, ITER_M(m)->m, errbuf))
+ else if (analyze_matcher(ITER_M(m)->type, m->type,
+ ITER_M(m)->m, errbuf))
return -1;
break;
case MATCHER_NE:
case MATCHER_GE:
case MATCHER_GT:
- assert(CMP_M(m)->left && CMP_M(m)->right);
+ assert(CMP_M(m)->right);
+ if ((parent_type == MATCHER_ALL)
+ || (parent_type == MATCHER_ANY)) {
+ // TODO: assert(! CMP_M(m)->left);
+ }
+ else {
+ assert(CMP_M(m)->left);
+ }
+
if (analyze_expr(context, CMP_M(m)->left, errbuf))
return -1;
if (analyze_expr(context, CMP_M(m)->right, errbuf))
return -1;
}
- if (analyze_matcher(context, m, errbuf))
+ if (analyze_matcher(context, -1, m, errbuf))
status = -1;
- if (analyze_matcher(-1, filter, errbuf))
+ if (analyze_matcher(-1, -1, filter, errbuf))
status = -1;
return status;
} /* sdb_fe_analyze */