X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.c;h=3ab1d218797685340360eda838aad56a9f610c52;hp=d2293fe7bf4f360de6bd5bf19e4551e489e2559c;hb=ac133e1eb5215f4da26898eb191a24fad848db0f;hpb=81b71a515e2024cee739deb6e207eb3b0e7c5d64 diff --git a/src/context.c b/src/context.c index d2293fe..3ab1d21 100644 --- a/src/context.c +++ b/src/context.c @@ -40,6 +40,9 @@ static struct psi_std_type { } psi_std_types[] = { {PSI_T_FLOAT, "float"}, {PSI_T_DOUBLE, "double"}, +#ifdef HAVE_LONG_DOUBLE + {PSI_T_LONG_DOUBLE, "long double"}, +#endif {PSI_T_INT8, "int8_t"}, {PSI_T_INT16, "int16_t"}, {PSI_T_INT32, "int32_t"}, @@ -124,6 +127,10 @@ static inline int locate_decl_type_struct(decl_structs *structs, decl_type *type static inline int validate_decl_type(PSI_Data *data, decl_type *type) { switch (type->type) { + case PSI_T_CHAR: + case PSI_T_SHORT: + case PSI_T_INT: + case PSI_T_LONG: case PSI_T_NAME: if (!data->defs || !locate_decl_type_alias(data->defs, type)) { return 0; @@ -166,6 +173,35 @@ static inline int validate_decl_arg(PSI_Data *data, decl_arg *arg) { return 1; } +static int psi_sort_struct_arg_cmp(const void *_a, const void *_b) { + decl_arg *a = *(decl_arg **)_a, *b = *(decl_arg **)_b; + + if (a->layout->pos == b->layout->pos) { + if (a->layout->len == b->layout->len) { + return 0; + } else if (a->layout->len > b->layout->len) { + return -1; + } else { + return 1; + } + } else if (a->layout->pos > b->layout->pos) { + return 1; + } else { + return -1; + } +} +static void psi_sort_struct_arg_swp(void *a, void *b) { + decl_arg **_a = a, **_b = b, *_c; + + _c = *_b; + *_b = *_a; + *_a = _c; +} +static inline void psi_sort_struct_args(decl_struct *s) { + zend_insert_sort(s->args->args, s->args->count, sizeof(*s->args->args), + psi_sort_struct_arg_cmp, psi_sort_struct_arg_swp); +} + static inline int validate_decl_struct(PSI_Data *data, decl_struct *s) { size_t i; @@ -207,6 +243,9 @@ static inline int validate_decl_struct(PSI_Data *data, decl_struct *s) { s->size = darg->layout->pos + darg->layout->len; } } + + psi_sort_struct_args(s); + return 1; } @@ -1236,7 +1275,7 @@ static inline void dump_impl_set_value(int fd, set_value *set, unsigned level) { dprintf(fd, ", "); dump_num_exp(fd, set->num); } - if (set->inner) { + if (set->inner && set->func->type != PSI_T_ELLIPSIS) { dprintf(fd, ",\n"); for (i = 0; i < set->count; ++i) { dump_impl_set_value(fd, set->inner[i], level+1); @@ -1272,7 +1311,8 @@ void PSI_ContextDump(PSI_Context *C, int fd) dprintf(fd, "typedef "); dump_decl_type(fd, tdef->type); - dprintf(fd, " %s;\n", tdef->alias); + dprintf(fd, " %s%s;\n", tdef->type->type == PSI_T_POINTER ? "*":"", + tdef->alias); } dprintf(fd, "\n"); } @@ -1383,6 +1423,9 @@ void PSI_ContextDump(PSI_Context *C, int fd) dprintf(fd, "%s($%s)", let->val->data.func->name, let->val->data.func->var->name); break; + case PSI_LET_NUMEXP: + dump_num_exp(fd, let->val->data.num); + break; EMPTY_SWITCH_DEFAULT_CASE(); }