Lines Matching refs:cc
505 identifier(Cx_t* cx, Cxcompile_t* cc, register int c, Cxoperand_t* r)
549 variable(Cx_t* cx, Cxcompile_t* cc, int c, Cxtype_t* m, Cxtype_t** type)
555 if (identifier(cx, cc, c, &a))
602 codecast(Cx_t* cx, Cxcompile_t* cc, Cxtype_t* t, Cxcallout_f cast, void* pointer)
611 if ((cx->flags & CX_DEBUG) && sfstrtell(cc->xp))
612 cxcodetrace(cx, "comp", &c, (unsigned int)sfstrtell(cc->xp) / sizeof(c), 0, 0);
613 sfwrite(cc->xp, &c, sizeof(c));
622 code(Cx_t* cx, Cxcompile_t* cc, Cxexpr_t* expr, int op, int pp, Cxtype_t* type1, Cxtype_t* type2, void* pointer, Cxnumber_t number, Cxvariable_t* ref)
641 if ((cc->pp += pp) > cc->depth)
642 cc->depth = cc->pp;
659 i1 = i2 = (Cxinstruction_t*)(sfstrseek(cc->xp, 0, SEEK_CUR) - 1 * sizeof(Cxinstruction_t));
666 i1 = (Cxinstruction_t*)(sfstrseek(cc->xp, 0, SEEK_CUR) - 2 * sizeof(Cxinstruction_t));
670 expr->vm = cc->vm;
671 expr->done = cc->done;
674 cc->done = expr->done;
675 i1 = (Cxinstruction_t*)(sfstrseek(cc->xp, 0, SEEK_CUR) - 2 * sizeof(Cxinstruction_t));
697 t = *(Cxinstruction_t*)(sfstrseek(cc->xp, -sizeof(Cxinstruction_t), SEEK_CUR));
702 if ((cx->flags & CX_DEBUG) && sfstrtell(cc->xp))
703 cxcodetrace(cx, "comp", &c, (unsigned int)sfstrtell(cc->xp) / sizeof(c), 0, 0);
704 sfwrite(cc->xp, &c, sizeof(c));
705 if ((cx->flags & CX_DEBUG) && sfstrtell(cc->xp))
706 cxcodetrace(cx, "comp", &t, (unsigned int)sfstrtell(cc->xp) / sizeof(c), 0, 0);
707 sfwrite(cc->xp, &t, sizeof(t));
737 if ((*type1->internalf)(cx, type1, NiL, &format, &r, i2->data.string.data, i2->data.string.size, cc->vm, cx->disc) < 0)
762 if (!(i2->data.string.data = vmstrdup(cc->vm, s)))
775 if (!(i1->data.string.data = vmstrdup(cc->vm, s)))
796 if ((*type1->internalf)(cx, type1, NiL, &format, &r, i2->data.string.data, i2->data.string.size, cc->vm, cx->disc) < 0)
816 if ((*type2->internalf)(cx, type2, NiL, &format, &r, i1->data.string.data, i1->data.string.size, cc->vm, cx->disc) < 0)
831 if ((cx->flags & CX_DEBUG) && sfstrtell(cc->xp))
832 cxcodetrace(cx, "comp", &x, (unsigned int)sfstrtell(cc->xp) / sizeof(x), 0, 0);
833 if (sfwrite(cc->xp, &x, sizeof(x)) != sizeof(x))
840 codecast(cx, cc, v1->type, edit, v1->format.map->part);
841 return cc->type = x.type;
853 prototype(Cx_t* cx, Cxcompile_t* cc, Cxvariable_t* v, Cxtype_t** tp, char** sp, char** ep, int* op)
944 parse(Cx_t* cx, Cxcompile_t* cc, Cxexpr_t* expr, int precedence, Cxvariable_t** ref)
967 cc->level++;
1019 if (!(v = variable(cx, cc, 0, m, 0)))
1026 if (!code(cx, cc, expr, CX_GET, 1, v->type, cx->state->type_void, v, 0, NiL))
1028 if (!code(cx, cc, expr, CX_NUM, 1, cx->state->type_number, cx->state->type_void, NiL, 1.0, NiL))
1030 if (!code(cx, cc, expr, o & ~CX_X2, -1, v->type, cx->state->type_number, NiL, 0, NiL))
1032 if (!code(cx, cc, expr, CX_SET, 0, cx->state->type_void, v->type, v, 0, NiL))
1036 if (!code(cx, cc, expr, CX_NUM, 1, cx->state->type_number, cx->state->type_void, NiL, -1.0, NiL))
1038 if (!code(cx, cc, expr, o & ~CX_X2, -1, v->type, cx->state->type_number, NiL, 0, NiL))
1067 if (!code(cx, cc, expr, CX_GET, 1, v->type, cx->state->type_void, v, 0, NiL))
1073 if (!(v = variable(cx, cc, 0, m, 0)))
1076 if (!code(cx, cc, expr, CX_REF, 1, cx->state->type_reference, cx->state->type_void, v, 0, NiL))
1086 if (!code(cx, cc, expr, CX_NUM, 1, cx->state->type_type_t, cx->state->type_void, t, 0, NiL))
1093 if (!code(cx, cc, expr, CX_GET, 1, v->type, cx->state->type_void, v, 0, NiL))
1131 if (cc->type != cx->state->type_number && !code(cx, cc, expr, CX_LOG, 0, cc->type, cx->state->type_void, NiL, 0, NiL))
1135 z = sfstrtell(cc->xp);
1136 if (!code(cx, cc, expr, (o == CX_ANDAND) ? CX_SC0 : CX_SC1, 0, cx->state->type_number, cx->state->type_void, NiL, 0, NiL))
1140 t = cc->type;
1141 if (parse(cx, cc, expr, p, NiL) != cx->state->type_void || cx->error)
1143 if (cx->table->logical[o] && cc->type != cx->state->type_number && !code(cx, cc, expr, CX_LOG, 0, cc->type, cx->state->type_void, NiL, 0, NiL))
1145 if (o != CX_SET && ((o & CX_UNARY) ? !code(cx, cc, expr, o, 0, cc->type, cx->state->type_void, NiL, 0, NiL) : !code(cx, cc, expr, o, -1, t, cc->type, NiL, 0, h)))
1151 if (v->type != cc->type)
1156 (*cx->disc->errorf)(cx, cx->disc, 2, "%s cannot assign %s to %s", cxcontext(cx), cc->type->name, v->type->name);
1159 v->type = cc->type;
1161 if (!code(cx, cc, expr, CX_SET, 0, cx->state->type_void, cc->type, v, 0, NiL))
1166 ((Cxinstruction_t*)(sfstrbase(cc->xp) + z))->data.number = (sfstrtell(cc->xp) - z) / sizeof(Cxinstruction_t);
1211 if (!code(cx, cc, expr, CX_NUM, 1, cx->state->type_number, cx->state->type_void, NiL, n, NiL))
1220 if (!(v = variable(cx, cc, c, m, &t)))
1246 if (v->type != cx->state->type_void && !code(cx, cc, expr, CX_NUM, 1, cx->state->type_number, cx->state->type_void, NiL, 0, NiL))
1251 if ((r = prototype(cx, cc, v, &t, &s, &e, &o)) < 0)
1255 cc->collecting++;
1256 k = cc->paren;
1257 cc->paren = p == ')';
1260 z = sfstrtell(cc->xp);
1261 if (parse(cx, cc, expr, cx->table->precedence[CX_CALL], NiL) != cx->state->type_void || cx->error)
1263 cc->collecting--;
1264 cc->paren = k;
1267 if (sfstrtell(cc->xp) != z)
1270 while (cc->type != t && t != cx->state->type_void)
1272 if (o && r > 0 && (r = prototype(cx, cc, v, &t, &s, &e, &o)) > 0)
1276 cc->collecting--;
1277 cc->paren = k;
1287 cc->collecting--;
1288 cc->paren = k;
1291 if ((r = prototype(cx, cc, v, &t, &s, &e, &o)) < 0)
1293 cc->collecting--;
1294 cc->paren = k;
1302 cc->collecting--;
1303 cc->paren = k;
1311 cc->collecting--;
1312 cc->paren = k;
1328 if (!code(cx, cc, expr, CX_CALL, -i, v->type, cx->state->type_void, v, 0, NiL))
1332 if (codecast(cx, cc, g, cast, NiL))
1354 if (!x && !v && (v = variable(cx, cc, c, m, 0)))
1364 if (!code(cx, cc, expr, CX_GET, 1, v->type, cx->state->type_void, v, 0, NiL))
1370 if (cc->collecting)
1375 if (!code(cx, cc, expr, CX_POP, -1, cx->state->type_void, cx->state->type_void, NiL, 0, NiL))
1379 if (cc->collecting)
1388 if (cc->collecting)
1390 if (!cc->paren)
1406 if (!identifier(cx, cc, c, &w) && (c = next(cx)) == ')' && ((c = next(cx)) == '(' || (cx->ctype[c] & CX_CTYPE_ALPHA)))
1423 k = cc->balanced;
1424 cc->balanced = 0;
1425 o = cc->collecting;
1426 cc->collecting = 0;
1427 u = parse(cx, cc, expr, cx->table->precedence[CX_PAREN], &f);
1429 cc->collecting = o;
1430 cc->balanced = k;
1449 if (cc->level > 0)
1494 if (parse(cx, cc, expr, cx->table->precedence[CX_TST], NiL) != cx->state->type_void || cx->error)
1504 else if (!code(cx, cc, expr, CX_NOP, 0, cx->state->type_void, cx->state->type_void, NiL, 0, NiL))
1506 if (parse(cx, cc, expr, cx->table->precedence[CX_TST], NiL) != cx->state->type_void || cx->error)
1508 if (!code(cx, cc, expr, CX_TST, 0, cx->state->type_void, cx->state->type_void, NiL, 0, NiL))
1532 if (!(s = vmstrdup(cc->vm, s)))
1538 if (!code(cx, cc, expr, CX_STR, 1, cx->state->type_string, cx->state->type_void, s, 0, NiL))
1552 cc->level--;
1564 if (!code(cx, cc, expr, CX_NUM, 1, cx->state->type_type_t, cx->state->type_void, t, 0, NiL))
1571 if (!code(cx, cc, expr, CX_GET, 1, v->type, cx->state->type_void, v, 0, NiL))
1573 if (g && codecast(cx, cc, g, cast, NiL))
1578 cc->level--;
1585 if (cc->collecting)
1599 cc->level--;
1608 node(Cx_t* cx, Cxcompile_t* cc, size_t n)
1612 if (!(expr = vmnewof(cc->vm, 0, Cxexpr_t, 1, n)))
1626 compile(Cx_t* cx, Cxcompile_t* cc, int balanced)
1632 cc->pp = 4;
1633 cc->balanced = balanced;
1634 cc->type = cx->state->type_void;
1635 if (!(expr = node(cx, cc, sizeof(Cxquery_t))))
1638 sfstrseek(cc->xp, 0, SEEK_SET);
1639 if (!code(cx, cc, expr, CX_END, 0, cx->state->type_void, cx->state->type_void, NiL, 0, NiL))
1641 pos = sfstrtell(cc->xp);
1642 if (parse(cx, cc, expr, 0, NiL) != cx->state->type_void || cx->error)
1652 pc = (Cxinstruction_t*)(sfstrseek(cc->xp, 0, SEEK_CUR) - 1 * sizeof(Cxinstruction_t));
1653 if (pc->op == CX_GET && !code(cx, cc, expr, CX_LOG, 0, pc->type, cx->state->type_void, NiL, 0, NiL))
1657 if (!code(cx, cc, expr, CX_END, 0, cx->state->type_void, cx->state->type_void, NiL, 0, NiL))
1659 n = sfstrtell(cc->xp) - pos;
1660 if (!(expr->query->prog = vmnewof(cc->vm, 0, Cxinstruction_t, n / sizeof(Cxinstruction_t), 0)))
1666 memcpy(expr->query->prog, sfstrbase(cc->xp) + pos, n);
1667 if (cc->depth > cc->stacksize)
1669 cc->stacksize = roundof(cc->depth, 64);
1670 if (!(cc->stack = vmnewof(cc->vm, cc->stack, Cxoperand_t, cc->stacksize, 0)))
1685 compose(Cx_t* cx, Cxcompile_t* cc, int prec)
1707 o = sfstrtell(cc->tp);
1719 sfputc(cc->tp, c);
1724 sfputc(cc->tp, c);
1728 sfputc(cc->tp, c);
1729 else if (sfstrtell(cc->tp) != o)
1733 if (!(fp = compose(cx, cc, '}')))
1752 if (!(fp = node(cx, cc, 0)))
1760 sfputc(cc->tp, c);
1761 else if (sfstrtell(cc->tp) != o)
1766 if (!(fp = compile(cx, cc, 0)))
1775 sfputc(cc->tp, c);
1782 sfputc(cc->tp, c);
1783 sfputc(cc->tp, c);
1790 o = sfstrtell(cc->tp);
1805 sfputc(cc->tp, c);
1815 if (sfstrtell(cc->tp) != p)
1817 sfputc(cc->tp, 0);
1820 s = sfstrbase(cc->tp) + p;
1823 if (!(f = (char*)vmstrdup(cc->vm, s)))
1829 sfstrseek(cc->tp, p, SEEK_SET);
1834 p = sfstrtell(cc->tp);
1851 if (!(n = sfstrtell(cc->tp)) && prec == '}')
1854 return node(cx, cc, 0);
1861 if (!(fp = node(cx, cc, (m + 1) * sizeof(char*) + n)))
1865 memcpy(s, sfstrseek(cc->tp, 0, SEEK_SET), n);
1919 if (!(fp = fp->next = compose(cx, cc, c)))
1924 if (peek(cx, 1) != ':' && !(fp->pass = compose(cx, cc, c)))
1929 if (!(fp->fail = compose(cx, cc, c)))
1933 else if (!(fp->pass = compose(cx, cc, c)))
1940 sfputc(cc->tp, c);
1962 defaults(register Cxcompile_t* cc, register Cxexpr_t* expr, Cxexpr_t* parent, Sfio_t* op)
1968 expr->vm = cc->vm;
1969 expr->done = cc->done;
1970 expr->stack = cc->stack;
1971 expr->stacksize = cc->stacksize;
1972 expr->reclaim = cc->reclaim;
1979 defaults(cc, expr->group, parent, expr->op);
1981 defaults(cc, expr->pass, expr, expr->op);
1983 defaults(cc, expr->fail, expr, expr->op);
2065 Cxcompile_t* cc;
2073 if (!(cc = vmnewof(cx->vm, 0, Cxcompile_t, 1, 0)) || !(cc->tp = sfstropen()) || !(cc->xp = sfstropen()))
2076 cc->reclaim = !!(cx->deletef = cxcallout(cx, CX_DEL, cx->state->type_void, cx->state->type_void, cx->disc));
2085 if (!(cc->vm = vmopen(Vmdcheap, Vmlast, 0)))
2096 if (!(expr = compose(cx, cc, 0)))
2100 else if (!(expr = compile(cx, cc, cx->flags & CX_BALANCED)))
2102 defaults(cc, expr, expr, sfstdout);
2103 cc->vm = 0;
2111 if (cc)
2113 if (cc->tp)
2114 sfstrclose(cc->tp);
2115 if (cc->xp)
2116 sfstrclose(cc->xp);
2117 if (cc->vm)
2118 vmclose(cc->vm);
2119 vmfree(cx->vm, cc);