jv* pathbuf;
int pathsize; // number of allocated elements
-// FIXME mem
int path_push(stackval sv, jv val) {
int pos = sv.pathidx;
assert(pos <= pathsize);
pathsize = oldpathsize ? oldpathsize * 2 : 100;
pathbuf = realloc(pathbuf, sizeof(pathbuf[0]) * pathsize);
for (int i=oldpathsize; i<pathsize; i++) {
- pathbuf[i] = jv_null();
+ pathbuf[i] = jv_invalid();
}
}
jv_free(pathbuf[pos]);
case LOADK: {
jv v = jv_array_get(jv_copy(frame_current_bytecode(&frame_stk)->constants), *pc++);
- //FIXME assert(v);
+ assert(jv_is_valid(v));
stack_push(stackval_replace(stack_pop(), v));
break;
}
cc->retaddr = retaddr;
cc->is_backtrack_frame = 0;
for (int i=0; i<cl.bc->nlocals; i++) {
- *frame_local_var(fp, i) = jv_null();
+ *frame_local_var(fp, i) = jv_invalid();
}
return fp;
}
jvp_string_free_p(key);
} else {
slot = jvp_object_add_slot(object, key, bucket);
- slot->value = jv_null();
+ slot->value = jv_invalid();
}
if (slot == 0) {
jvp_object_rehash(object);
assert(!jvp_object_find_slot(object, key, bucket));
slot = jvp_object_add_slot(object, key, bucket);
assert(slot);
- slot->value = jv_null();
+ slot->value = jv_invalid();
}
return &slot->value;
}
p->stack = 0;
p->stacklen = p->stackpos = 0;
p->hasnext = 0;
- p->next = jv_null(); //FIXME: jv_invalid
+ p->next = jv_invalid(); //FIXME: jv_invalid
p->tokenbuf = 0;
p->tokenlen = p->tokenpos = 0;
p->st = JV_PARSER_NORMAL;
presult msg = scan(&parser, ch);
if (msg){
printf("ERROR: %s (parsing '%s')\n", msg, string);
- return jv_null();
+ return jv_invalid();
}
}
presult msg = finish(&parser);
if (msg) {
printf("ERROR: %s (parsing '%s')\n", msg, string);
- return jv_null();
+ return jv_invalid();
}
jv value = jv_copy(parser.next);
jv_parser_free(&parser);
printf("\n");
fgets(buf, sizeof(buf), testdata);
jv input = jv_parse(buf);
+ assert(jv_is_valid(input));
jq_init(bc, input);
while (fgets(buf, sizeof(buf), testdata)) {
if (skipline(buf)) break;
jv expected = jv_parse(buf);
+ assert(jv_is_valid(expected));
jv actual = jq_next();
if (!jv_is_valid(actual)) {
printf("Insufficient results\n");