mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
HashMap is now Printable. Fix access inlining for enums. #1958
This commit is contained in:
@@ -1089,7 +1089,7 @@ const char *llvm_codegen(void *context)
|
||||
|
||||
void llvm_add_global_decl(GenContext *c, Decl *decl)
|
||||
{
|
||||
ASSERT(decl->var.kind == VARDECL_GLOBAL || decl->var.kind == VARDECL_CONST);
|
||||
ASSERT_SPAN(decl, decl->var.kind == VARDECL_GLOBAL || decl->var.kind == VARDECL_CONST);
|
||||
|
||||
bool same_module = decl->unit->module == c->code_module;
|
||||
LLVMTypeRef type = llvm_get_type(c, decl->type);
|
||||
@@ -1282,7 +1282,7 @@ LLVMValueRef llvm_get_ref(GenContext *c, Decl *decl)
|
||||
{
|
||||
return decl->backend_ref = llvm_get_ref(c, decl->var.alias);
|
||||
}
|
||||
ASSERT(decl->var.kind == VARDECL_GLOBAL || decl->var.kind == VARDECL_CONST);
|
||||
ASSERT_SPAN(decl, decl->var.kind == VARDECL_GLOBAL || decl->var.kind == VARDECL_CONST);
|
||||
llvm_add_global_decl(c, decl);
|
||||
return decl->backend_ref;
|
||||
case DECL_FUNC:
|
||||
|
||||
@@ -1767,7 +1767,6 @@ static void cast_enum_to_value(Expr* expr, Type *to_type)
|
||||
cast_int_to_int(expr, to_type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (expr_is_const_enum(expr))
|
||||
{
|
||||
expr_replace(expr, copy_expr_single(expr->const_expr.enum_err_val->enum_constant.args[decl->enums.inline_index]));
|
||||
|
||||
@@ -277,14 +277,27 @@ Expr *sema_enter_inline_member(Expr *parent, CanonicalType *type)
|
||||
{
|
||||
Decl *decl = type->decl;
|
||||
if (!decl->is_substruct) return NULL;
|
||||
|
||||
if (parent->expr_kind == EXPR_CONST)
|
||||
{
|
||||
return copy_expr_single(parent->const_expr.enum_err_val->enum_constant.args[0]);
|
||||
if (decl->enums.inline_value)
|
||||
{
|
||||
Expr *expr = expr_new_expr(EXPR_CONST, parent);
|
||||
expr_rewrite_const_int(expr, decl->enums.type_info->type, parent->const_expr.enum_err_val->enum_constant.ordinal);
|
||||
return expr;
|
||||
}
|
||||
return copy_expr_single(parent->const_expr.enum_err_val->enum_constant.args[decl->enums.inline_index]);
|
||||
}
|
||||
if (decl->enums.inline_value)
|
||||
{
|
||||
Expr *expr = copy_expr_single(parent);
|
||||
expr->type = decl->enums.type_info->type;
|
||||
return expr;
|
||||
}
|
||||
Expr *property = expr_new(EXPR_ACCESS_RESOLVED, parent->span);
|
||||
property->resolve_status = RESOLVE_DONE;
|
||||
property->access_resolved_expr.parent = parent;
|
||||
property->access_resolved_expr.ref = decl->enums.parameters[0];
|
||||
property->access_resolved_expr.ref = decl->enums.parameters[decl->enums.inline_value];
|
||||
property->type = property->access_resolved_expr.ref->type;
|
||||
return property;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user