| 1091 | } |
| 1092 | |
| 1093 | static bool parse_member(cs_file_t *f, char **fld, int n) { |
| 1094 | /* M start kind explicit type name tparams sig */ |
| 1095 | if (n != 8) { |
| 1096 | return false; |
| 1097 | } |
| 1098 | cs_member_t *m = &f->members[f->nmembers]; |
| 1099 | memset(m, 0, sizeof(*m)); |
| 1100 | m->start = (uint32_t)strtoul(fld[1], NULL, 10); |
| 1101 | m->kind = fld[2][0]; |
| 1102 | m->is_static = m->kind && fld[2][1] == 's'; |
| 1103 | m->explicit_impl = fld[3][0] == '1'; |
| 1104 | m->type = field_index(fld[4], f->ntypes); |
| 1105 | m->name = fld[5]; |
| 1106 | m->arity = count_list(fld[6], ','); |
| 1107 | bool callable_like = m->kind == 'c' || m->kind == 'o' || m->kind == 'x'; |
| 1108 | m->sig = callable_like ? fld[7] : NULL; |
| 1109 | m->nparams = (m->sig && m->sig[0]) ? count_list(m->sig, '|') : 0; |
| 1110 | size_t nl = strlen(m->name); |
| 1111 | if (m->type < 0 || !m->kind || !strchr("cvpeox", m->kind) || |
| 1112 | fld[2][m->is_static ? PAIR_LEN : SKIP_ONE] || nl == 0 || nl >= CS_NAME_BUF) { |
| 1113 | return false; |
| 1114 | } |
| 1115 | /* owners of type parameters: the types come first, the members after |
| 1116 | * the LAST type the blob has, whose count is known only at the end */ |
| 1117 | add_tparams(f, -(f->nmembers + PAIR_LEN), fld[6]); |
| 1118 | f->nmembers++; |
| 1119 | return true; |
| 1120 | } |
| 1121 | |
| 1122 | /* Everything the records of one blob say, into `f`. false for a blob this |
| 1123 | * code did not write (or one the store damaged), and when memory ran out. */ |
no test coverage detected