diff options
Diffstat (limited to 'copy.c')
-rw-r--r-- | copy.c | 23 |
1 files changed, 7 insertions, 16 deletions
@@ -126,27 +126,18 @@ static void copy_type(Copier *c, Type *out, Type *in) { it's okay to copy the struct definition here, because before resolving, only one thing can point to a given StructDef */ - StructType *sout = &out->struc, *sin = &in->struc; - - sout->def = allocr_malloc(c->allocr, sizeof *sout->def); - *sout->def = *sin->def; - size_t nfields = arr_len(sin->def->fields); - sout->def->fields = NULL; + out->struc = allocr_malloc(c->allocr, sizeof *out->struc); + *out->struc = *in->struc; + size_t nfields = arr_len(in->struc->fields); + out->struc->fields = NULL; - arr_set_lena(&sout->def->fields, nfields, c->allocr); + arr_set_lena(&out->struc->fields, nfields, c->allocr); for (size_t i = 0; i < nfields; ++i) { - Field *fout = &sout->def->fields[i]; - Field *fin = &sin->def->fields[i]; + Field *fout = &out->struc->fields[i]; + Field *fin = &in->struc->fields[i]; *fout = *fin; copy_type(c, &fout->type, &fin->type); } - - size_t nargs = arr_len(sin->args); - sout->args = NULL; - arr_set_lena(&sout->args, nargs, c->allocr); - for (size_t i = 0; i < nargs; ++i) { - copy_expr(c, &sout->args[i], &sin->args[i]); - } } } break; } |