Lines Matching refs:cx

50 match_string_comp(Cx_t* cx, Cxtype_t* st, Cxtype_t* pt, Cxvalue_t* pv, Cxdisc_t* disc)
66 re->re_disc = &cx->redisc;
76 match_string_exec(Cx_t* cx, void* data, Cxtype_t* st, Cxvalue_t* sv, Cxdisc_t* disc)
86 match_string_free(Cx_t* cx, void* data, Cxdisc_t* disc)
111 void_external(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
129 void_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
140 number_external(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
199 number_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
217 if (format && format->map && !cxstr2num(cx, format, buf, size, &m))
222 if (disc->errorf && !(cx->flags & CX_QUIET))
223 (*disc->errorf)(cx, disc, 1, "%s: invalid number [(buf+size)=%p e=%p%s base=%d size=%d]", fmtquote(buf, NiL, NiL, size, 0), (char*)buf+size, e, (format && (format->flags & CX_UNSIGNED)) ? " unsigned" : "", format ? format->base : 0, size);
233 string_external(Cx_t* cx, Cxtype_t* type, const char* details, register Cxformat_t* format, register Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
262 string_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
277 buffer_external(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
310 if (cx->disc->errorf)
311 (*cx->disc->errorf)(cx, cx->disc, ERROR_SYSTEM|2, "%s: unknown buffer representation details", details);
320 buffer_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
332 (*disc->errorf)(cx, disc, ERROR_SYSTEM|2, "out of space");
350 type_external(Cx_t* cx, Cxtype_t* type, const char* details, register Cxformat_t* format, register Cxvalue_t* value, char* buf, size_t size, Cxdisc_t* disc)
365 type_internal(Cx_t* cx, Cxtype_t* type, const char* details, Cxformat_t* format, Cxoperand_t* ret, const char* buf, size_t size, Vmalloc_t* vm, Cxdisc_t* disc)
396 op_call_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
398 return (*pc->data.variable->function)(cx, pc->data.variable, r, b + (pc->pp + 1), -pc->pp, data, disc);
402 op_nop_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
408 op_end_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
420 op_ref_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
422 return (r->value.variable = cxvariable(cx, b->value.string.data, a->type, disc)) ? 0 : -1;
426 op_sc_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
430 cx->jump = (int)pc->data.number;
437 op_const_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
444 op_tst_V(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
446 if (cx->disc->errorf)
447 (*cx->disc->errorf)(cx, cx->disc, 2, "CX_TST not implemented yet");
452 op_add_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
459 op_sub_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
466 op_mpy_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
473 op_div_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
477 if (cx->disc->errorf)
478 (*cx->disc->errorf)(cx, cx->disc, 2, "divide by 0");
486 op_mod_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
490 if (cx->disc->errorf)
491 (*cx->disc->errorf)(cx, cx->disc, 2, "modulus by number < 1.0");
500 op_and_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
507 op_or_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
514 op_xor_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
521 op_andand_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
528 op_oror_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
535 op_lsh_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
542 op_rsh_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
549 op_inv_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
556 op_log_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
563 op_not_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
570 op_uplus_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
577 op_uminus_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
584 op_lt_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
591 op_le_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
598 op_eq_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
605 op_ne_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
612 op_ge_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
619 op_gt_N(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
626 op_log_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
633 op_lt_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
642 op_le_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
651 op_eq_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
658 op_ne_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
665 op_ge_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
674 op_gt_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
683 op_not_S(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
690 op_lt_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
699 op_le_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
708 op_eq_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
715 op_ne_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
722 op_ge_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
731 op_gt_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
740 op_not_B(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
747 op_eq_T(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
754 op_ne_T(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
761 op_cast_SN(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
766 if (*e && cx->disc->errorf)
767 (*cx->disc->errorf)(cx, cx->disc, 2, "%s: invalid number", b->value.string.data);
772 op_match(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
776 if ((i = (*a->type->match->execf)(cx, pc->data.pointer, a->type, &a->value, disc)) < 0)
783 op_nomatch(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
787 if ((i = (*a->type->match->execf)(cx, pc->data.pointer, a->type, &a->value, disc)) < 0)
794 re_match(Cx_t* cx, Cxexpr_t* expr, Cxinstruction_t* x, Cxinstruction_t* a, Cxinstruction_t* b, void* data, Cxdisc_t* disc)
796 if (!(x->data.pointer = (*a->type->match->compf)(cx, a->type, b->type, &b->data, disc)))
798 if (a->type->match->freef && cxatfree(cx, expr, a->type->match->freef, x->data.pointer))
800 (*a->type->match->freef)(cx, x->data.pointer, disc);
881 cxsizeof(Cx_t* cx, Cxvariable_t* var, Cxtype_t* type, Cxvalue_t* value)
919 cx_edit_B(Cx_t* cx, Cxvariable_t* var, Cxoperand_t* ret, Cxoperand_t* arg, int n, void* data, Cxdisc_t* disc)
923 if (!(edit = cxedit(cx, arg[0].value.string.data, disc)))
926 return cxsub(cx, edit, ret);
930 cx_sizeof_B(Cx_t* cx, Cxvariable_t* var, Cxoperand_t* ret, Cxoperand_t* arg, int n, void* data, Cxdisc_t* disc)
932 ret->value.number = cxsizeof(cx, var, arg->type, &arg->value);
937 cx_typeof_B(Cx_t* cx, Cxvariable_t* var, Cxoperand_t* ret, Cxoperand_t* arg, int n, void* data, Cxdisc_t* disc)
958 * open a cx session
964 register Cx_t* cx;
981 if (!(cx = vmnewof(vm, 0, Cx_t, 1, 0)) || !(cx->cvtbuf = vmnewof(vm, 0, char, cx->cvtsiz = 64, 0)))
987 cx->state = cxstate(disc);
988 cx->table = &table;
989 cx->id = CX_ID;
990 cx->vm = vm;
991 cx->em = em;
992 cx->rm = rm;
993 cx->disc = disc;
994 cx->flags = flags;
995 cx->test = test;
996 cx->redisc.re_version = REG_VERSION;
997 cx->redisc.re_flags = REG_NOFREE;
998 cx->redisc.re_errorf = (regerror_t)disc->errorf;
999 if (!(cx->buf = sfstropen()) || !(cx->tp = sfstropen()))
1001 cxclose(cx);
1004 cx->scoped = 1;
1007 cx->op = sfstdout;
1008 if (!(cx->fields = dtnew(cx->vm, &state.listdisc, Dtqueue)) || !(cx->buf = sfstropen()) || !(cx->tp = sfstropen()))
1010 cxclose(cx);
1013 cx->callouts = state.callouts;
1014 cx->constraints = state.constraints;
1015 cx->edits = state.edits;
1016 cx->maps = state.maps;
1017 cx->queries = state.queries;
1018 cx->recodes = state.recodes;
1019 cx->types = state.types;
1020 cx->variables = state.variables;
1022 cx->ctype = state.ctype;
1023 return cx;
1135 * close a cx session
1139 cxclose(register Cx_t* cx)
1141 if (!cx)
1143 if (cx->scope)
1144 cxscope(cx, NiL, 0, 0, cx->disc);
1145 if (--cx->scoped <= 0)
1147 if (cx->view & CX_VIEW_callouts)
1148 dtclose(cx->callouts);
1149 if (cx->view & CX_VIEW_constraints)
1150 dtclose(cx->constraints);
1151 if (cx->view & CX_VIEW_edits)
1152 dtclose(cx->edits);
1153 if (cx->view & CX_VIEW_maps)
1154 dtclose(cx->maps);
1155 if (cx->view & CX_VIEW_queries)
1156 dtclose(cx->queries);
1157 if (cx->view & CX_VIEW_recodes)
1158 dtclose(cx->recodes);
1159 if (cx->view & CX_VIEW_types)
1160 dtclose(cx->types);
1161 if (cx->view & CX_VIEW_fields)
1162 dtclose(cx->fields);
1163 if (cx->view & CX_VIEW_variables)
1164 dtclose(cx->variables);
1165 if (cx->scope)
1166 cx->scope->scoped--;
1167 if (cx->buf)
1168 sfclose(cx->buf);
1169 if (cx->tp)
1170 sfclose(cx->tp);
1171 if (cx->em)
1172 vmclose(cx->em);
1173 if (cx->rm)
1174 vmclose(cx->rm);
1175 if (cx->vm)
1176 vmclose(cx->vm);
1186 cxaddtype(Cx_t* cx, register Cxtype_t* type, Cxdisc_t* disc)
1196 if (cx)
1198 disc = cx->disc;
1199 if (cx->view & CX_VIEW_types)
1200 dict = cx->types;
1201 else if (!(dict = dtnew(cx->vm, &state.namedisc, Dtoset)))
1209 dtview(dict, cx->types);
1210 cx->types = dict;
1211 cx->view |= CX_VIEW_types;
1213 if (!(copy = vmnewof(cx->vm, 0, Cxtype_t, 1, 0)))
1234 if ((base = (char*)type->base) && !(type->base = cxtype(cx, base, disc)))
1240 if ((base = (char*)type->fundamental) && !(type->fundamental = cxtype(cx, base, disc)))
1261 type->member->members = cx ? cx->variables : state.variables;
1262 else if (!(type->member->members = cx ? dtnew(cx->vm, &state.namedisc, Dtoset) : dtopen(&state.namedisc, Dtoset)))
1275 if ((base = (char*)v->type) && !(v->type = cxtype(cx, base, disc)))
1289 if (!(type->generic[i] = cxtype(cx, base, disc)))
1324 if (cxaddrecode(cx, re, disc))
1338 cxtype(Cx_t* cx, const char* name, Cxdisc_t* disc)
1355 if (!(t = (Cxtype_t*)dtmatch(cx ? cx->types : state.types, name)) && disc->loadf && (*disc->loadf)(lib, disc))
1356 t = (Cxtype_t*)dtmatch(cx ? cx->types : state.types, name);
1365 cxaddcallout(Cx_t* cx, register Cxcallout_t* callout, Cxdisc_t* disc)
1371 if (cx)
1373 disc = cx->disc;
1374 if (cx->view & CX_VIEW_callouts)
1375 dict = cx->callouts;
1376 else if (!(dict = dtnew(cx->vm, &state.codedisc, Dtoset)))
1384 dtview(dict, cx->callouts);
1385 cx->callouts = dict;
1386 cx->view |= CX_VIEW_callouts;
1388 if (!(copy = vmnewof(cx->vm, 0, Cxcallout_t, 1, 0)))
1410 else if (!(callout->op.type1 = cxtype(cx, name, disc)))
1418 else if (!(callout->op.type2 = cxtype(cx, name, disc)))
1439 cxcallout(Cx_t* cx, int code, Cxtype_t* type1, Cxtype_t* type2, Cxdisc_t* disc)
1450 while (!(callout = (Cxcallout_t*)dtmatch(cx ? cx->callouts : state.callouts, &op)))
1467 cxaddquery(Cx_t* cx, Cxquery_t* query, Cxdisc_t* disc)
1472 if (cx)
1474 disc = cx->disc;
1475 if (cx->view & CX_VIEW_queries)
1476 dict = cx->queries;
1477 else if (!(dict = dtnew(cx->vm, &state.namedisc, Dtoset)))
1485 dtview(dict, cx->queries);
1486 cx->queries = dict;
1487 cx->view |= CX_VIEW_queries;
1489 if (!(copy = vmnewof(cx->vm, 0, Cxquery_t, 1, 0)))
1515 cxquery(Cx_t* cx, const char* name, Cxdisc_t* disc)
1532 if (!(q = (Cxquery_t*)dtmatch(cx ? cx->queries : state.queries, name)) && disc->loadf && (*disc->loadf)(lib, disc))
1533 q = (Cxquery_t*)dtmatch(cx ? cx->queries : state.queries, name);
1542 cxfunction(Cx_t* cx, const char* name, Cxdisc_t* disc)
1550 if (!cx)
1556 if (f = (Cxvariable_t*)dtmatch(cx->variables, name))
1578 if (cxaddvariable(cx, &lib->functions[i], disc))
1580 if (f = (Cxvariable_t*)dtmatch(cx->variables, name))
1601 cxaddmap(Cx_t* cx, Cxmap_t* map, Cxdisc_t* disc)
1606 if (cx)
1608 disc = cx->disc;
1609 if (cx->view & CX_VIEW_maps)
1610 dict = cx->maps;
1611 if (!(dict = dtnew(cx->vm, &state.namedisc, Dtoset)))
1619 dtview(dict, cx->maps);
1620 cx->maps = dict;
1621 cx->view |= CX_VIEW_maps;
1623 if (!(copy = vmnewof(cx->vm, 0, Cxmap_t, 1, 0)))
1651 cxmap(Cx_t* cx, const char* name, Cxdisc_t* disc)
1653 return (Cxmap_t*)dtmatch(cx ? cx->maps : state.maps, name);
1661 cxaddrecode(Cx_t* cx, register Cxrecode_t* recode, Cxdisc_t* disc)
1668 if (cx)
1670 disc = cx->disc;
1671 if (cx->view & CX_VIEW_recodes)
1672 dict = cx->recodes;
1673 else if (!(dict = dtnew(cx->vm, &state.codedisc, Dtoset)))
1681 dtview(dict, cx->recodes);
1682 cx->recodes = dict;
1683 cx->view |= CX_VIEW_recodes;
1685 if (!(copy = vmnewof(cx->vm, 0, Cxrecode_t, 1, 0)))
1705 if ((name = (char*)recode->op.type1) && !(recode->op.type1 = cxtype(cx, name, disc)))
1711 if ((name = (char*)recode->op.type2) && !(recode->op.type2 = cxtype(cx, name, disc)))
1728 cxrecode(Cx_t* cx, int code, Cxtype_t* type1, Cxtype_t* type2, Cxdisc_t* disc)
1748 return (recode = (Cxrecode_t*)dtmatch(cx ? cx->recodes : state.recodes, &op)) ? recode->recode : (Cxrecode_f)0;
1756 cxaddedit(Cx_t* cx, register Cxedit_t* edit, Cxdisc_t* disc)
1761 if (cx)
1763 disc = cx->disc;
1764 if (cx->view & CX_VIEW_edits)
1765 dict = cx->edits;
1766 else if (!(dict = dtnew(cx->vm, &state.namedisc, Dtoset)))
1774 dtview(dict, cx->edits);
1775 cx->edits = dict;
1776 cx->view |= CX_VIEW_edits;
1778 if (!(copy = vmnewof(cx->vm, 0, Cxedit_t, 1, 0)))
1811 cxedit(Cx_t* cx, const char* data, Cxdisc_t* disc)
1817 e = (Cxedit_t*)dtmatch(cx ? cx->edits : state.edits, data);
1827 if (!(e = cx ? vmnewof(cx->vm, 0, Cxedit_t, 1, 0) : newof(0, Cxedit_t, 1, 0)))
1843 if (!(e = cx ? vmnewof(cx->vm, 0, Cxedit_t, 1, strlen(data) + 1) : newof(0, Cxedit_t, 1, strlen(data) + 1)))
1851 if (cx)
1855 e->redisc.re_resizehandle = cx->vm;
1869 if (cx && cxaddedit(cx, e, disc))
1880 cxaddconstraint(Cx_t* cx, register Cxconstraint_t* constraint, Cxdisc_t* disc)
1885 if (cx)
1887 disc = cx->disc;
1888 if (cx->view & CX_VIEW_constraints)
1889 dict = cx->constraints;
1890 else if (!(dict = dtnew(cx->vm, &state.namedisc, Dtoset)))
1898 dtview(dict, cx->constraints);
1899 cx->constraints = dict;
1900 cx->view |= CX_VIEW_constraints;
1902 if (!(copy = vmnewof(cx->vm, 0, Cxconstraint_t, 1, 0)))
1934 cxconstraint(Cx_t* cx, const char* name, Cxdisc_t* disc)
1936 return (Cxconstraint_t*)dtmatch(cx ? cx->constraints : state.constraints, name);
1964 cxaddvariable(register Cx_t* cx, register Cxvariable_t* variable, Cxdisc_t* disc)
1970 if (cx)
1972 disc = cx->disc;
1973 if (cx->view & CX_VIEW_variables)
1974 dict = cx->variables;
1975 else if (!(dict = dtnew(cx->vm, &state.namedisc, Dtoset)))
1983 dtview(dict, cx->variables);
1984 cx->variables = dict;
1985 cx->view |= CX_VIEW_variables;
2001 if ((name = (char*)variable->type) && !(variable->type = cxtype(cx, name, disc)))
2009 if (cx)
2011 if (sx = cx->scope)
2014 cx->index = sx->index;
2017 variable->header.index = cx->index++;
2023 if (cx)
2024 dtinsert(cx->fields, variable);
2034 cxvariable(Cx_t* cx, const char* name, register Cxtype_t* m, Cxdisc_t* disc)
2044 if (!cx)
2050 disc = cx->disc;
2053 if (!(v = (Cxvariable_t*)dtmatch(cx->variables, name)))
2069 dict = cx->variables;
2122 dtinsert(cx->variables, v);
2128 (*disc->errorf)(cx, disc, 2, "%s: not a member of %s", name, m->name);
2140 cxcast(Cx_t* cx, Cxoperand_t* ret, Cxvariable_t* var, Cxtype_t* type, void* data, const char* format)
2162 if (!cx->getf && !(cx->getf = cxcallout(cx, CX_GET, 0, 0, cx->disc)))
2164 if (cx->disc->errorf)
2165 (*cx->disc->errorf)(NiL, cx->disc, 3, "%s: cx CX_GET callout must be defined", var->name);
2180 if (var->name != var->type->name && (*cx->getf)(cx, &x, ret, &a, &b, data, cx->disc))
2187 if ((*ref->member->getf)(cx, &x, ret, &a, &b, data, cx->disc))
2191 else if ((*cx->getf)(cx, &x, ret, &a, NiL, data, cx->disc))
2201 cxsuball(cx, var->format.map->part, ret);
2207 if (ret->value.string.size > cx->ccsiz)
2210 if (!(cx->ccbuf = vmoldof(cx->vm, cx->ccbuf, char, n, 0)))
2212 if (cx->disc->errorf)
2213 (*cx->disc->errorf)(NiL, cx->disc, ERROR_SYSTEM|2, "out of space");
2216 cx->ccsiz = n;
2218 ret->value.string.data = (char*)ccmapcpy(map, cx->ccbuf, ret->value.string.data, ret->value.string.size);
2225 if (!var || !cxisnumber(from) || !var->format.map || format || cxnum2str(cx, &var->format, (Cxinteger_t)ret->value.number, &s))
2229 while ((n = (*ret->type->externalf)(cx, ret->type, format, var ? &var->format : (Cxformat_t*)0, &ret->value, cx->cvtbuf, cx->cvtsiz, cx->disc)) > cx->cvtsiz)
2232 if (!(cx->cvtbuf = vmoldof(cx->vm, cx->cvtbuf, char, n, 0)))
2234 if (cx->disc->errorf)
2235 (*cx->disc->errorf)(NiL, cx->disc, ERROR_SYSTEM|2, "out of space");
2238 cx->cvtsiz = n;
2242 ret->value.string.data = cx->cvtbuf;
2253 else if (cxisnumber(type) && var && cxisstring(from) && var->format.map && !cxstr2num(cx, &var->format, val.value.string.data, val.value.string.size, &m))
2259 else if (!type->internalf || (*type->internalf)(cx, type, format, var ? &var->format : (Cxformat_t*)0, ret, val.value.string.data, val.value.string.size, cx->em, cx->disc) < 0)
2265 if ((x.callout = cxcallout(cx, CX_CAST, ret->type, type, cx->disc)) && !(*x.callout)(cx, &x, ret, NiL, &val, NiL, cx->disc))
2267 if (cx->disc->errorf)
2268 (*cx->disc->errorf)(cx, cx->disc, 2, "cannot cast %s to %s", ret->type->name, type->name);
2417 cxlocation(Cx_t* cx, void* data)
2421 return cx->disc->locationf && (s = (*cx->disc->locationf)(cx, data, cx->disc)) ? s : "";
2432 cxcvt(register Cx_t* cx, const char* s, size_t n)
2434 if (cx->cvtsiz <= n || !cx->cvtbuf)
2436 cx->cvtsiz = roundof(n + 1, 32);
2437 if (!(cx->cvtbuf = vmoldof(cx->vm, cx->cvtbuf, char, cx->cvtsiz, 0)))
2439 if (cx->disc->errorf)
2440 (*cx->disc->errorf)(NiL, cx->disc, ERROR_SYSTEM|2, "out of space");
2444 memcpy(cx->cvtbuf, s, n);
2445 cx->cvtbuf[n] = 0;
2446 return cx->cvtbuf;