| 508 | } |
| 509 | |
| 510 | static void dk_from(dk_t *d, TSNode ins) { |
| 511 | TSNode spec = {0}; |
| 512 | TSNode alias = ts_node_child_by_field_name(ins, "as", (uint32_t)strlen("as")); |
| 513 | for (uint32_t i = 0; i < ts_node_named_child_count(ins); i++) { |
| 514 | if (dk_type(ts_node_named_child(ins, i), "image_spec")) { |
| 515 | spec = ts_node_named_child(ins, i); |
| 516 | } |
| 517 | } |
| 518 | const char *ref = ts_node_is_null(spec) ? NULL : dk_expand(d, d->global, dk_text(d, spec)); |
| 519 | d->stage++; |
| 520 | d->local = NULL; |
| 521 | d->workdir = "/"; |
| 522 | d->entry.set = false; |
| 523 | d->cmd.set = false; |
| 524 | bool stage = ref && dk_is_stage(d, ref); |
| 525 | if (ref && !stage) { |
| 526 | dk_link(d, ref, "from", dk_line(ins)); |
| 527 | } |
| 528 | if (d->stage < DK_MAX_STAGES) { |
| 529 | d->st[d->stage].parent = stage ? dk_stage_of(d, ref) : -1; |
| 530 | d->stages[d->stage] = ts_node_is_null(alias) ? NULL : dk_text(d, alias); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /* JSON string `s` (quoted) unquoted; \\ and \" unescaped. */ |
| 535 | static const char *dk_json_string(dk_t *d, const char *s) { |
no test coverage detected