diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:29:48 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:29:48 -0400 |
| commit | 210179ee672a0c3799328a54e886f574b3823e3d (patch) | |
| tree | 25ddb95503c537c19b9fdb7614df2f16c4012d21 /structs.c | |
| parent | dee3742b48e27ef36637d004163286d3352b0763 (diff) | |
Optional enums (deprecated custom tag values)
Diffstat (limited to 'structs.c')
| -rw-r--r-- | structs.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -121,7 +121,7 @@ void compile_struct_def(env_t *env, ast_t *ast) assert(t && t->tag == StructType); auto struct_ = Match(t, StructType); if (def->fields) { - CORD typeinfo = CORD_asprintf("public const TypeInfo %r = {%zu, %zu, {.tag=CustomInfo, .CustomInfo={", + CORD typeinfo = CORD_asprintf("public const TypeInfo %r = {%zu, %zu, {.tag=StructInfo, .CustomInfo={", full_name, type_size(t), type_align(t)); typeinfo = CORD_all(typeinfo, ".as_text=(void*)", full_name, "$as_text, "); @@ -156,8 +156,8 @@ void compile_struct_def(env_t *env, ast_t *ast) typeinfo = CORD_cat(typeinfo, "}}};\n"); env->code->typeinfos = CORD_all(env->code->typeinfos, typeinfo); } else { - // If there are no fields, we can use an EmptyStruct typeinfo, which generates less code: - CORD typeinfo = CORD_asprintf("public const TypeInfo %r = {%zu, %zu, {.tag=EmptyStruct, .EmptyStruct.name=%r}};\n", + // If there are no fields, we can use an EmptyStructInfo typeinfo, which generates less code: + CORD typeinfo = CORD_asprintf("public const TypeInfo %r = {%zu, %zu, {.tag=EmptyStructInfo, .EmptyStructInfo.name=%r}};\n", full_name, type_size(t), type_align(t), CORD_quoted(def->name)); env->code->typeinfos = CORD_all(env->code->typeinfos, typeinfo); } |
