Moved ABI lowering from codegen to semantic analysis. Fixes for failables in the ABI and the codegen.

This commit is contained in:
Christoffer Lerno
2020-12-04 19:19:57 +01:00
parent 0b00fe6988
commit 6a5a0f2b94
22 changed files with 400 additions and 342 deletions

View File

@@ -254,6 +254,10 @@ static bool sema_analyse_struct_union(Context *context, Decl *decl)
had = decl->is_packed;
decl->is_packed = true;
break;
case ATTRIBUTE_OPAQUE:
had = decl->is_opaque;
decl->is_opaque = true;
break;
default:
UNREACHABLE
}
@@ -379,6 +383,7 @@ static inline Type *sema_analyse_function_signature(Context *context, FunctionSi
TokenType type = TOKEN_INVALID_TOKEN;
signature->mangled_signature = symtab_add(buffer, buffer_write_offset, fnv1a(buffer, buffer_write_offset), &type);
Type *func_type = stable_get(&context->local_symbols, signature->mangled_signature);
c_abi_func_create(signature);
if (!func_type)
{
func_type = type_new(TYPE_FUNC, signature->mangled_signature);
@@ -564,6 +569,7 @@ static AttributeType sema_analyse_attribute(Context *context, Attr *attr, Attrib
[ATTRIBUTE_NORETURN] = ATTR_FUNC,
[ATTRIBUTE_ALIGN] = ATTR_FUNC | ATTR_CONST | ATTR_VAR | ATTR_STRUCT | ATTR_UNION,
[ATTRIBUTE_INLINE] = ATTR_FUNC,
[ATTRIBUTE_NOINLINE] = ATTR_FUNC,
[ATTRIBUTE_OPAQUE] = ATTR_STRUCT | ATTR_UNION,
[ATTRIBUTE_STDCALL] = ATTR_FUNC
};