Skip to content

Commit

Permalink
Further cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Jan 20, 2025
1 parent c59d47f commit d2885fa
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 94 deletions.
22 changes: 2 additions & 20 deletions src/compiler/c_codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
case EXPR_SLICE_LEN:
case EXPR_DISCARD:
case EXPR_RVALUE:
case EXPR_UNRESOLVED_IDENTIFIER:
case EXPR_RECAST:
case EXPR_ADDR_CONVERSION:
case EXPR_EXT_TRUNC:
Expand All @@ -417,7 +416,8 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
case EXPR_VECTOR_FROM_ARRAY:
case EXPR_ANYFAULT_TO_FAULT:
break;
case EXPR_ACCESS_UNRESOLVED:
case UNRESOLVED_EXPRS:
UNREACHABLE
case EXPR_ACCESS_RESOLVED:
break;
case EXPR_ANYSWITCH:
Expand All @@ -438,15 +438,10 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
break;
case EXPR_CALL:
break;
case EXPR_CAST:
case EXPR_CATCH_UNRESOLVED:
UNREACHABLE
case EXPR_CATCH:
break;
case EXPR_COMPILER_CONST:
break;
case EXPR_COMPOUND_LITERAL:
break;
case EXPR_COND:
break;
case EXPR_CONST:
Expand Down Expand Up @@ -482,16 +477,12 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
break;
case EXPR_DESIGNATOR:
break;
case EXPR_EMBED:
break;
case EXPR_EXPRESSION_LIST:
break;
case EXPR_EXPR_BLOCK:
break;
case EXPR_FORCE_UNWRAP:
break;
case EXPR_GENERIC_IDENT:
break;
case EXPR_HASH_IDENT:
break;
case EXPR_IDENTIFIER:
Expand All @@ -504,8 +495,6 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
break;
case EXPR_MACRO_BLOCK:
break;
case EXPR_MACRO_BODY:
break;
case EXPR_MACRO_BODY_EXPANSION:
break;
case EXPR_MEMBER_GET:
Expand All @@ -518,8 +507,6 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
break;
case EXPR_OPTIONAL:
break;
case EXPR_OTHER_CONTEXT:
UNREACHABLE
case EXPR_POINTER_OFFSET:
break;
case EXPR_POISONED:
Expand Down Expand Up @@ -553,20 +540,15 @@ static void c_emit_expr(GenContext *c, CValue *value, Expr *expr)
case EXPR_TEST_HOOK:
break;
case EXPR_TRY:
case EXPR_TRY_UNRESOLVED:
break;
case EXPR_TRY_UNWRAP_CHAIN:
break;
case EXPR_TYPEID:
break;
case EXPR_TYPEID_INFO:
break;
case EXPR_TYPEINFO:
break;
case EXPR_UNARY:
break;
case EXPR_VASPLAT:
break;
}
PRINT("/* TODO EXPR */\n");
}
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -1661,5 +1661,7 @@ case TYPE_U8: case TYPE_U16: case TYPE_U32: case TYPE_U64: case TYPE_U128

#define UNRESOLVED_EXPRS EXPR_TRY_UNRESOLVED: case EXPR_ACCESS_UNRESOLVED: \
case EXPR_CATCH_UNRESOLVED: case EXPR_UNRESOLVED_IDENTIFIER: case EXPR_CAST: \
case EXPR_TYPEID
case EXPR_TYPEID: case EXPR_EMBED: case EXPR_VASPLAT: case EXPR_OTHER_CONTEXT: \
case EXPR_GENERIC_IDENT: case EXPR_COMPOUND_LITERAL: case EXPR_MACRO_BODY


23 changes: 0 additions & 23 deletions src/compiler/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ bool expr_may_addr(Expr *expr)
{
case UNRESOLVED_EXPRS:
UNREACHABLE
case EXPR_OTHER_CONTEXT:
return expr_may_addr(expr->expr_other_context.inner);
case EXPR_IDENTIFIER:
{
Decl *decl = expr->ident_expr;
Expand Down Expand Up @@ -260,23 +258,19 @@ bool expr_may_addr(Expr *expr)
case EXPR_CALL:
case EXPR_MAKE_ANY:
case EXPR_CATCH:
case EXPR_COMPOUND_LITERAL:
case EXPR_COND:
case EXPR_CONST:
case EXPR_DECL:
case EXPR_DEFAULT_ARG:
case EXPR_DESIGNATED_INITIALIZER_LIST:
case EXPR_DESIGNATOR:
case EXPR_EMBED:
case EXPR_EXPRESSION_LIST:
case EXPR_EXPR_BLOCK:
case EXPR_FORCE_UNWRAP:
case EXPR_GENERIC_IDENT:
case EXPR_INITIALIZER_LIST:
case EXPR_LAMBDA:
case EXPR_LAST_FAULT:
case EXPR_MACRO_BLOCK:
case EXPR_MACRO_BODY:
case EXPR_MACRO_BODY_EXPANSION:
case EXPR_NAMED_ARGUMENT:
case EXPR_NOP:
Expand All @@ -295,7 +289,6 @@ bool expr_may_addr(Expr *expr)
case EXPR_TRY:
case EXPR_TRY_UNWRAP_CHAIN:
case EXPR_TYPEID_INFO:
case EXPR_VASPLAT:
case EXPR_EXT_TRUNC:
case EXPR_INT_TO_BOOL:
case EXPR_MAKE_SLICE:
Expand All @@ -311,17 +304,13 @@ bool expr_is_runtime_const(Expr *expr)
RETRY:
switch (expr->expr_kind)
{
case EXPR_OTHER_CONTEXT:
expr = expr->expr_other_context.inner;
goto RETRY;
case EXPR_POINTER_OFFSET:
return exprid_is_runtime_const(expr->pointer_offset_expr.ptr) && exprid_is_runtime_const(
expr->pointer_offset_expr.offset);
case EXPR_SWIZZLE:
case EXPR_RETVAL:
case EXPR_BUILTIN:
case EXPR_CT_EVAL:
case EXPR_VASPLAT:
case EXPR_BENCHMARK_HOOK:
case EXPR_TEST_HOOK:
case EXPR_ANYSWITCH:
Expand All @@ -337,7 +326,6 @@ bool expr_is_runtime_const(Expr *expr)
case EXPR_CT_DEFINED:
case EXPR_CT_IS_CONST:
case EXPR_LAMBDA:
case EXPR_EMBED:
case EXPR_EXPR_BLOCK:
case EXPR_DECL:
case EXPR_CALL:
Expand Down Expand Up @@ -505,13 +493,10 @@ bool expr_is_runtime_const(Expr *expr)
case EXPR_TYPEINFO:
case EXPR_HASH_IDENT:
case EXPR_CT_IDENT:
case EXPR_COMPOUND_LITERAL:
case EXPR_POISONED:
case EXPR_CT_ARG:
case EXPR_ASM:
case EXPR_SUBSCRIPT_ASSIGN:
case EXPR_GENERIC_IDENT:
case EXPR_MACRO_BODY:
case EXPR_NAMED_ARGUMENT:
UNREACHABLE
case EXPR_NOP:
Expand Down Expand Up @@ -775,8 +760,6 @@ bool expr_is_pure(Expr *expr)
return expr_is_pure(expr->int_to_bool_expr.inner);
case EXPR_EXT_TRUNC:
return expr_is_pure(expr->ext_trunc_expr.inner);
case EXPR_OTHER_CONTEXT:
return expr_is_pure(expr->expr_other_context.inner);
case EXPR_SWIZZLE:
return exprid_is_pure(expr->swizzle_expr.parent);
case EXPR_BUILTIN_ACCESS:
Expand All @@ -796,10 +779,8 @@ bool expr_is_pure(Expr *expr)
case EXPR_CT_IS_CONST:
case EXPR_CT_EVAL:
case EXPR_CT_IDENT:
case EXPR_EMBED:
case EXPR_IDENTIFIER:
case EXPR_LAMBDA:
case EXPR_MACRO_BODY:
case EXPR_NOP:
case EXPR_OPERATOR_CHARS:
case EXPR_RETVAL:
Expand All @@ -809,7 +790,6 @@ bool expr_is_pure(Expr *expr)
case EXPR_MEMBER_GET:
return true;
case EXPR_BITASSIGN:
case EXPR_VASPLAT:
case EXPR_ANYSWITCH:
return false;
case EXPR_BINARY:
Expand All @@ -834,8 +814,6 @@ bool expr_is_pure(Expr *expr)
return expr_is_pure(expr->unary_expr.expr);
}
UNREACHABLE
case EXPR_GENERIC_IDENT:
return exprid_is_pure(expr->generic_ident_expr.parent);
case EXPR_BITACCESS:
case EXPR_ACCESS_RESOLVED:
// All access is pure if the parent is pure.
Expand All @@ -845,7 +823,6 @@ bool expr_is_pure(Expr *expr)
case EXPR_MACRO_BODY_EXPANSION:
case EXPR_CALL:
case EXPR_CATCH:
case EXPR_COMPOUND_LITERAL:
case EXPR_COND:
case EXPR_DESIGNATOR:
case EXPR_DECL:
Expand Down
6 changes: 0 additions & 6 deletions src/compiler/llvm_codegen_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7016,16 +7016,10 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr)
case EXPR_LAMBDA:
case EXPR_COND:
case EXPR_ASM:
case EXPR_VASPLAT:
case EXPR_GENERIC_IDENT:
case EXPR_EMBED:
case EXPR_MACRO_BODY:
case EXPR_OTHER_CONTEXT:
case EXPR_DESIGNATOR:
case EXPR_MEMBER_GET:
case EXPR_NAMED_ARGUMENT:
case EXPR_BUILTIN:
case EXPR_COMPOUND_LITERAL:
case EXPR_OPERATOR_CHARS:
UNREACHABLE
case EXPR_VECTOR_TO_ARRAY:
Expand Down
1 change: 1 addition & 0 deletions src/compiler/sema_decls.c
Original file line number Diff line number Diff line change
Expand Up @@ -3834,6 +3834,7 @@ static inline bool sema_analyse_macro(SemaContext *context, Decl *decl, bool *er
switch (body->expr_stmt->expr_kind)
{
case EXPR_IDENTIFIER:
case EXPR_UNRESOLVED_IDENTIFIER:
case EXPR_LAMBDA:
case EXPR_FORCE_UNWRAP:
case EXPR_ASM:
Expand Down
14 changes: 0 additions & 14 deletions src/compiler/sema_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
if (failed_ref) goto FAILED_REF;
RETURN_SEMA_ERROR(expr, "You cannot use swizzling to assign to multiple elements, use element-wise assign instead.");
case EXPR_LAMBDA:
case EXPR_EMBED:
if (failed_ref) goto FAILED_REF;
RETURN_SEMA_ERROR(expr, "This expression is a value and cannot be assigned to.");
case EXPR_CT_IDENT:
Expand All @@ -455,8 +454,6 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_DISCARD:
if (failed_ref) goto FAILED_REF;
goto ERR;
case EXPR_OTHER_CONTEXT:
return sema_binary_is_expr_lvalue(context, top_expr, expr->expr_other_context.inner, failed_ref);
case EXPR_IDENTIFIER:
{
Decl *decl = expr->ident_expr;
Expand Down Expand Up @@ -534,7 +531,6 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_CALL:
case EXPR_CATCH:
case EXPR_COMPILER_CONST:
case EXPR_COMPOUND_LITERAL:
case EXPR_COND:
case EXPR_CT_AND_OR:
case EXPR_CT_APPEND:
Expand All @@ -551,11 +547,9 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_DESIGNATOR:
case EXPR_EXPR_BLOCK:
case EXPR_FORCE_UNWRAP:
case EXPR_GENERIC_IDENT:
case EXPR_INITIALIZER_LIST:
case EXPR_LAST_FAULT:
case EXPR_MACRO_BLOCK:
case EXPR_MACRO_BODY:
case EXPR_MACRO_BODY_EXPANSION:
case EXPR_MAKE_ANY:
case EXPR_MAKE_SLICE:
Expand Down Expand Up @@ -588,7 +582,6 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_TYPECALL:
case EXPR_TYPEID_INFO:
case EXPR_TYPEINFO:
case EXPR_VASPLAT:
case EXPR_ANYFAULT_TO_FAULT:
case EXPR_VECTOR_FROM_ARRAY:
case EXPR_VECTOR_TO_ARRAY:
Expand Down Expand Up @@ -620,7 +613,6 @@ static bool expr_may_ref(Expr *expr)
case EXPR_SWIZZLE:
case EXPR_LAMBDA:
case EXPR_CT_IDENT:
case EXPR_EMBED:
case EXPR_DEFAULT_ARG:
case EXPR_TYPECALL:
case EXPR_MEMBER_GET:
Expand All @@ -644,8 +636,6 @@ static bool expr_may_ref(Expr *expr)
case EXPR_ADDR_CONVERSION:
case EXPR_MAKE_SLICE:
return false;
case EXPR_OTHER_CONTEXT:
return expr_may_ref(expr->expr_other_context.inner);
case EXPR_SUBSCRIPT_ASSIGN:
return true;
case UNRESOLVED_EXPRS:
Expand Down Expand Up @@ -703,7 +693,6 @@ static bool expr_may_ref(Expr *expr)
case EXPR_CALL:
case EXPR_CATCH:
case EXPR_COMPILER_CONST:
case EXPR_COMPOUND_LITERAL:
case EXPR_COND:
case EXPR_CONST:
case EXPR_CT_AND_OR:
Expand All @@ -720,11 +709,9 @@ static bool expr_may_ref(Expr *expr)
case EXPR_DESIGNATOR:
case EXPR_EXPR_BLOCK:
case EXPR_FORCE_UNWRAP:
case EXPR_GENERIC_IDENT:
case EXPR_INITIALIZER_LIST:
case EXPR_LAST_FAULT:
case EXPR_MACRO_BLOCK:
case EXPR_MACRO_BODY:
case EXPR_MACRO_BODY_EXPANSION:
case EXPR_NAMED_ARGUMENT:
case EXPR_NOP:
Expand All @@ -745,7 +732,6 @@ static bool expr_may_ref(Expr *expr)
case EXPR_TRY_UNWRAP_CHAIN:
case EXPR_TYPEID_INFO:
case EXPR_TYPEINFO:
case EXPR_VASPLAT:
case EXPR_MAKE_ANY:
return false;
}
Expand Down
20 changes: 2 additions & 18 deletions src/compiler/sema_liveness.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,11 @@ static void sema_trace_expr_liveness(Expr *expr)
case NON_RUNTIME_EXPR:
case EXPR_SUBSCRIPT_ASSIGN:
case EXPR_OPERATOR_CHARS:
case EXPR_VASPLAT:
case EXPR_GENERIC_IDENT:
case EXPR_EMBED:
case EXPR_MACRO_BODY:
case EXPR_MEMBER_GET:
case EXPR_NAMED_ARGUMENT:
case EXPR_UNRESOLVED_IDENTIFIER:
case EXPR_ACCESS_UNRESOLVED:
case UNRESOLVED_EXPRS:
UNREACHABLE
case EXPR_OTHER_CONTEXT:

UNREACHABLE
case EXPR_DESIGNATOR:
sema_trace_expr_liveness(expr->designator_expr.value);
Expand Down Expand Up @@ -329,9 +324,6 @@ static void sema_trace_expr_liveness(Expr *expr)
sema_trace_decl_liveness(declptr(expr->call_expr.func_ref));
return;
}
case EXPR_CAST:
ASSERT_SPAN(expr, "Casts should be gone when tracing liveness");
UNREACHABLE
case EXPR_FORCE_UNWRAP:
case EXPR_RETHROW:
case EXPR_OPTIONAL:
Expand Down Expand Up @@ -397,9 +389,6 @@ static void sema_trace_expr_liveness(Expr *expr)
sema_trace_const_initializer_liveness(expr->const_expr.initializer);
return;
}
case EXPR_COMPOUND_LITERAL:
sema_trace_expr_liveness(expr->expr_compound_literal.initializer);
return;
case EXPR_COND:
{
FOREACH(Expr *, e, expr->cond_expr) sema_trace_expr_liveness(e);
Expand All @@ -423,8 +412,6 @@ static void sema_trace_expr_liveness(Expr *expr)
return;
}
case EXPR_LAMBDA:
case EXPR_CATCH_UNRESOLVED:
case EXPR_TRY_UNRESOLVED:
UNREACHABLE
case EXPR_MACRO_BLOCK:
{
Expand Down Expand Up @@ -517,9 +504,6 @@ static void sema_trace_expr_liveness(Expr *expr)
case EXPR_EXT_TRUNC:
sema_trace_expr_liveness(expr->ext_trunc_expr.inner);
return;
case EXPR_TYPEID:
sema_trace_type_liveness(expr->typeid_expr->type);
return;
case EXPR_LAST_FAULT:
return;
}
Expand Down
Loading

0 comments on commit d2885fa

Please sign in to comment.