Strip array suffix (`int[]` → `int`, `String[][]` → `String`, dim=2). */
| 234 | |
| 235 | /* Strip array suffix (`int[]` → `int`, `String[][]` → `String`, dim=2). */ |
| 236 | static const char *unwrap_array_text(CBMArena *a, const char *type_text, int *out_dim) { |
| 237 | if (out_dim) |
| 238 | *out_dim = 0; |
| 239 | if (!type_text) |
| 240 | return NULL; |
| 241 | size_t n = strlen(type_text); |
| 242 | int dim = 0; |
| 243 | while (n >= 2 && type_text[n - 1] == ']' && type_text[n - 2] == '[') { |
| 244 | n -= 2; |
| 245 | dim++; |
| 246 | } |
| 247 | if (out_dim) |
| 248 | *out_dim = dim; |
| 249 | if (dim == 0) |
| 250 | return type_text; |
| 251 | return cbm_arena_strndup(a, type_text, n); |
| 252 | } |
| 253 | |
| 254 | /* Map primitive name → boxed wrapper QN. */ |
| 255 | static const CBMType *box_primitive(CBMArena *a, const char *prim) { |
no test coverage detected