| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gwion_util.h" | ||
| 2 | #include "gwion_ast.h" | ||
| 3 | #include "gwion_env.h" | ||
| 4 | #include "vm.h" | ||
| 5 | #include "traverse.h" | ||
| 6 | #include "instr.h" | ||
| 7 | #include "emit.h" | ||
| 8 | #include "gwion.h" | ||
| 9 | #include "object.h" | ||
| 10 | #include "operator.h" | ||
| 11 | #include "import.h" | ||
| 12 | #include "gwi.h" | ||
| 13 | |||
| 14 | 4 | ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, | |
| 15 | const restrict m_str name) { | ||
| 16 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
|
4 | CHECK_BB(ck_ini(gwi, ck_tdef)); |
| 17 | 3 | gwi->ck->name = name; | |
| 18 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | CHECK_BB(check_typename_def(gwi, gwi->ck)); |
| 19 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | return (gwi->ck->td = gwi_str2td(gwi, type)) ? GW_OK : GW_ERROR; |
| 20 | } | ||
| 21 | |||
| 22 | 2 | ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) { | |
| 23 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | CHECK_BO(ck_ok(gwi, ck_tdef)); |
| 24 | 2 | Type_Decl *td = gwi->ck->td; | |
| 25 | 2 | td->flag |= flag; | |
| 26 | const Type_Def tdef = | ||
| 27 | 2 | new_type_def(gwi->gwion->mp, td, gwi->ck->sym, gwi->loc); | |
| 28 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (gwi->ck->tmpl) tdef->tmpl = gwi_tmpl(gwi); |
| 29 | 2 | gwi->ck->td = NULL; | |
| 30 | 2 | gwi->ck->tmpl = NULL; | |
| 31 | 2 | const m_bool ret = traverse_type_def(gwi->gwion->env, tdef); | |
| 32 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (gwi->gwion->data->cdoc) { |
| 33 | ✗ | gwfmt_indent(gwi->gwfmt); | |
| 34 | ✗ | gwfmt_type_def(gwi->gwfmt, tdef); | |
| 35 | } | ||
| 36 | 2 | const Type t = tdef->type; | |
| 37 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret > 0) |
| 38 | ✗ | set_tflag(t, tflag_scan0 | tflag_scan1 | tflag_scan2 | tflag_check | | |
| 39 | tflag_emit); | ||
| 40 | 2 | free_type_def(gwi->gwion->mp, tdef); | |
| 41 | 2 | ck_end(gwi); | |
| 42 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | return ret > 0 ? t : NULL; |
| 43 | } | ||
| 44 | |||
| 45 | 1 | ANN void ck_clean_tdef(MemPool mp, ImportCK *ck) { | |
| 46 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (ck->td) free_type_decl(mp, ck->td); |
| 47 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (ck->tmpl) free_id_list(mp, ck->tmpl); |
| 48 | 1 | } | |
| 49 |