diff --git a/src/compiler/ast.c b/src/compiler/ast.c index d82c3b246..de14260e2 100644 --- a/src/compiler/ast.c +++ b/src/compiler/ast.c @@ -80,7 +80,6 @@ Decl *decl_new_with_type(const char *name, SourceSpan loc, DeclKind decl_type) case DECL_FAULTVALUE: case DECL_IMPORT: case DECL_MACRO: - case DECL_GENERIC: case DECL_CT_IF: case DECL_CT_ELSE: case DECL_CT_ELIF: @@ -160,8 +159,6 @@ const char *decl_to_a_name(Decl *decl) return "a fault"; case DECL_FUNC: return "a function"; - case DECL_GENERIC: - return "a generic"; case DECL_MACRO: return "a macro"; case DECL_STRUCT: diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 4c609ef90..b70c4f9b2 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -1589,13 +1589,7 @@ struct CompilationUnit_ Visibility default_visibility; bool export_by_default; bool test_by_default; - struct - { - // Not properly implemented - Decl **generic_methods; - Decl **generics; - Decl **generic_defines; - }; + Decl **generic_defines; Decl **ct_ifs; Decl **ct_asserts; Decl **ct_echos; diff --git a/src/compiler/context.c b/src/compiler/context.c index d1739c7ef..a5fc2e9ac 100644 --- a/src/compiler/context.c +++ b/src/compiler/context.c @@ -148,7 +148,6 @@ void decl_register(Decl *decl) case DECL_UNION: case DECL_DEFINE: case DECL_FUNC: - case DECL_GENERIC: case DECL_MACRO: case DECL_VAR: global_context_add_decl(decl); @@ -165,20 +164,6 @@ void unit_register_global_decl(CompilationUnit *unit, Decl *decl) { case DECL_POISONED: break; - case DECL_GENERIC: - assert(decl->name); - if (decl->func_decl.type_parent) - { - vec_add(unit->generic_methods, decl); - return; - } - else - { - vec_add(unit->generics, decl); - } - decl_set_external_name(decl); - decl_register(decl); - break; case DECL_MACRO: assert(decl->name); if (decl->func_decl.type_parent) diff --git a/src/compiler/copying.c b/src/compiler/copying.c index 4e749af70..f5724661d 100644 --- a/src/compiler/copying.c +++ b/src/compiler/copying.c @@ -957,7 +957,6 @@ Decl *copy_decl(CopyStruct *c, Decl *decl) break; case DECL_IMPORT: break; - case DECL_GENERIC: case DECL_MACRO: MACRO_COPY_ASTID(copy->func_decl.docs); MACRO_COPY_TYPEID(decl->func_decl.type_parent); diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 479d9552f..3aafbb57b 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -147,7 +147,6 @@ typedef enum DECL_GLOBALS, DECL_INITIALIZE, DECL_FINALIZE, - DECL_GENERIC, DECL_IMPORT, DECL_CT_INCLUDE, DECL_LABEL, @@ -163,7 +162,7 @@ typedef enum #define NON_TYPE_DECLS DECL_IMPORT: case DECL_MACRO: \ case DECL_DECLARRAY: case DECL_CT_IF: case DECL_CT_ELSE: case DECL_CT_ELIF: \ case DECL_CT_SWITCH: case DECL_CT_CASE: case DECL_ATTRIBUTE: case DECL_LABEL: \ - case DECL_DEFINE: case DECL_CT_ASSERT: case DECL_GENERIC: case DECL_INITIALIZE: \ + case DECL_DEFINE: case DECL_CT_ASSERT: case DECL_INITIALIZE: \ case DECL_FINALIZE: case DECL_CT_ECHO: case DECL_CT_INCLUDE: case DECL_GLOBALS #define NON_RUNTIME_EXPR EXPR_DESIGNATOR: case EXPR_POISONED: \ @@ -539,7 +538,6 @@ typedef enum TOKEN_FOREACH, TOKEN_FOREACH_R, TOKEN_FN, - TOKEN_GENERIC, TOKEN_TLOCAL, TOKEN_IF, TOKEN_IMPORT, diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index 0883f2054..8de08933b 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -1079,7 +1079,6 @@ LLVMValueRef llvm_get_ref(GenContext *c, Decl *decl) case DECL_ENUM: case DECL_ENUM_CONSTANT: case DECL_FAULT: - case DECL_GENERIC: case DECL_IMPORT: case DECL_LABEL: case DECL_MACRO: diff --git a/src/compiler/llvm_codegen_debug_info.c b/src/compiler/llvm_codegen_debug_info.c index 27db55a03..7b769c777 100644 --- a/src/compiler/llvm_codegen_debug_info.c +++ b/src/compiler/llvm_codegen_debug_info.c @@ -582,7 +582,7 @@ static inline LLVMMetadataRef llvm_get_debug_type_internal(GenContext *c, Type * case TYPE_ANY: return type->backend_debug_type = llvm_debug_any_type(c, type); case TYPE_SCALED_VECTOR: - TODO + UNSUPPORTED; } UNREACHABLE } diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 598bcea64..92caa8892 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -418,7 +418,7 @@ LLVMValueRef llvm_emit_coerce(GenContext *c, LLVMTypeRef coerced, BEValue *value if (coerced_type_kind == LLVMScalableVectorTypeKind) { - TODO + UNSUPPORTED; } // Otherwise, do it through memory. diff --git a/src/compiler/llvm_codegen_type.c b/src/compiler/llvm_codegen_type.c index 9939c6879..524ac266a 100644 --- a/src/compiler/llvm_codegen_type.c +++ b/src/compiler/llvm_codegen_type.c @@ -692,7 +692,7 @@ LLVMValueRef llvm_get_typeid(GenContext *c, Type *type) case TYPE_POISONED: UNREACHABLE case TYPE_SCALED_VECTOR: - TODO + UNSUPPORTED; } UNREACHABLE } \ No newline at end of file diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 208723cfc..9461f92fb 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -42,7 +42,6 @@ void recover_top_level(ParseContext *c) case TOKEN_IMPORT: case TOKEN_EXTERN: case TOKEN_ENUM: - case TOKEN_GENERIC: case TOKEN_DEFINE: case TOKEN_TYPEDEF: case TOKEN_FAULT: @@ -2185,11 +2184,10 @@ static inline bool parse_func_macro_header(ParseContext *c, Decl *decl) */ static inline Decl *parse_macro_declaration(ParseContext *c, AstId docs) { - DeclKind kind = try_consume(c, TOKEN_MACRO) ? DECL_MACRO : DECL_GENERIC; - if (kind == DECL_GENERIC) advance_and_verify(c, TOKEN_GENERIC); + advance_and_verify(c, TOKEN_MACRO); Decl *decl = decl_calloc(); - decl->decl_kind = kind; + decl->decl_kind = DECL_MACRO; decl->func_decl.docs = docs; if (!parse_func_macro_header(c, decl)) return poisoned_decl; const char *block_parameter = NULL; @@ -3054,7 +3052,6 @@ AFTER_VISIBILITY: if (is_private) decl->visibility = VISIBLE_PRIVATE; break; } - case TOKEN_GENERIC: case TOKEN_MACRO: { ASSIGN_DECL_OR_RET(decl, parse_macro_declaration(c, docs), poisoned_decl); diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index 5e35077a0..f1a53740f 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -1374,7 +1374,6 @@ Ast *parse_stmt(ParseContext *c) case TOKEN_QUESTQUEST: case TOKEN_ENUM: case TOKEN_FN: - case TOKEN_GENERIC: case TOKEN_IMPORT: case TOKEN_MACRO: case TOKEN_MODULE: diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 7c3bd7cac..650a4723c 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -1162,8 +1162,6 @@ static inline const char *method_name_by_decl(Decl *method_like) return "macro method"; case DECL_FUNC: return "method"; - case DECL_GENERIC: - return "generic method"; default: UNREACHABLE } @@ -2444,7 +2442,6 @@ static bool sema_analyse_macro_method(SemaContext *context, Decl *decl) static inline bool sema_analyse_macro(SemaContext *context, Decl *decl) { - bool is_generic = decl->decl_kind == DECL_GENERIC; decl->func_decl.unit = context->unit; if (!sema_analyse_func_macro(context, decl, false)) return false; @@ -3110,7 +3107,6 @@ bool sema_analyse_decl(SemaContext *context, Decl *decl) if (!sema_analyse_func(context, decl)) goto FAILED; break; case DECL_MACRO: - case DECL_GENERIC: if (!sema_analyse_macro(context, decl)) goto FAILED; break; case DECL_VAR: diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index e25a4cf90..415434101 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -552,9 +552,6 @@ static inline bool sema_cast_ident_rvalue(SemaContext *context, Expr *expr) case DECL_MACRO: SEMA_ERROR(expr, "Expected a macro followed by (...)."); return expr_poison(expr); - case DECL_GENERIC: - SEMA_ERROR(expr, "Expected generic function followed by (...)."); - return expr_poison(expr); case DECL_FAULTVALUE: SEMA_ERROR(expr, "Did you forget a '!' after '%s'?", decl->name); return expr_poison(expr); @@ -806,7 +803,7 @@ static inline bool sema_expr_analyse_identifier(SemaContext *context, Type *to, return false; } - if (decl->decl_kind == DECL_VAR || decl->decl_kind == DECL_FUNC || decl->decl_kind == DECL_MACRO || decl->decl_kind == DECL_GENERIC) + if (decl->decl_kind == DECL_VAR || decl->decl_kind == DECL_FUNC || decl->decl_kind == DECL_MACRO) { if (decl->unit->module != context->unit->module && !decl->is_autoimport && !expr->identifier_expr.path) { @@ -822,9 +819,6 @@ static inline bool sema_expr_analyse_identifier(SemaContext *context, Type *to, case DECL_MACRO: message = "Macros from other modules must be prefixed with the module name."; break; - case DECL_GENERIC: - message = "Generic functions from other modules must be prefixed with the module name."; - break; default: UNREACHABLE } @@ -2050,10 +2044,6 @@ bool sema_expr_analyse_general_call(SemaContext *context, Expr *expr, Decl *decl expr->call_expr.func_ref = declid(decl); expr->call_expr.is_func_ref = true; return sema_expr_analyse_func_call(context, expr, decl, struct_var, optional); - case DECL_GENERIC: - expr->call_expr.func_ref = declid(decl); - expr->call_expr.is_func_ref = true; - TODO // Maybe generics won't happen case DECL_POISONED: return false; default: @@ -5283,8 +5273,6 @@ static inline const char *sema_addr_may_take_of_ident(Expr *inner) return sema_addr_may_take_of_var(inner, decl); case DECL_MACRO: return "It is not possible to take the address of a macro."; - case DECL_GENERIC: - return "It is not possible to take the address of a generic function."; default: UNREACHABLE } diff --git a/src/compiler/sema_liveness.c b/src/compiler/sema_liveness.c index 731350c66..54ee2ed02 100644 --- a/src/compiler/sema_liveness.c +++ b/src/compiler/sema_liveness.c @@ -494,7 +494,6 @@ static void sema_trace_decl_liveness(Decl *decl) case DECL_CT_SWITCH: case DECL_CT_ASSERT: case DECL_CT_ECHO: - case DECL_GENERIC: case DECL_IMPORT: case DECL_CT_INCLUDE: case DECL_LABEL: diff --git a/src/compiler/sema_passes.c b/src/compiler/sema_passes.c index 002bf44d6..6664d0fac 100644 --- a/src/compiler/sema_passes.c +++ b/src/compiler/sema_passes.c @@ -403,10 +403,6 @@ void sema_analysis_pass_decls(Module *module) { sema_analyse_decl(&context, unit->macros[i]); } - VECEACH(unit->generics, i) - { - sema_analyse_decl(&context, unit->generics[i]); - } VECEACH(unit->methods, i) { sema_analyse_decl(&context, unit->methods[i]); diff --git a/src/compiler/sema_types.c b/src/compiler/sema_types.c index 3a7558ed0..52a16924a 100644 --- a/src/compiler/sema_types.c +++ b/src/compiler/sema_types.c @@ -217,7 +217,6 @@ static bool sema_resolve_type_identifier(SemaContext *context, TypeInfo *type_in case DECL_ENUM_CONSTANT: case DECL_IMPORT: case DECL_MACRO: - case DECL_GENERIC: case DECL_LABEL: case DECL_ATTRIBUTE: SEMA_ERROR(type_info, "This is not a type."); diff --git a/src/compiler/semantic_analyser.c b/src/compiler/semantic_analyser.c index 3e044b738..128c9eac0 100644 --- a/src/compiler/semantic_analyser.c +++ b/src/compiler/semantic_analyser.c @@ -195,7 +195,6 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls) case DECL_DEFINE: case DECL_DISTINCT: case DECL_ENUM: - case DECL_GENERIC: case DECL_FAULT: case DECL_FUNC: case DECL_STRUCT: diff --git a/src/compiler/tokens.c b/src/compiler/tokens.c index f61fbbe6a..a62297cbd 100644 --- a/src/compiler/tokens.c +++ b/src/compiler/tokens.c @@ -231,8 +231,6 @@ const char *token_type_to_string(TokenType type) return "foreach_r"; case TOKEN_FN: return "fn"; - case TOKEN_GENERIC: - return "generic"; case TOKEN_IF: return "if"; case TOKEN_IMPORT: diff --git a/src/compiler/types.c b/src/compiler/types.c index eaab3c113..9cf330323 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -699,7 +699,7 @@ AlignSize type_abi_alignment(Type *type) case TYPE_SUBARRAY: return alignment_subarray; case TYPE_SCALED_VECTOR: - TODO + UNSUPPORTED; } UNREACHABLE } diff --git a/src/utils/errors.h b/src/utils/errors.h index 216622cd3..566464293 100644 --- a/src/utils/errors.h +++ b/src/utils/errors.h @@ -51,6 +51,7 @@ #define TODO FATAL_ERROR("TODO reached"); +#define UNSUPPORTED do { error_exit("Unsupported functionality"); } while (0) #define TEST_ASSERT(condition_, string_) while (!(condition_)) { FATAL_ERROR(string_); } #define TEST_ASSERTF(condition_, string_, ...) while (!(condition_)) { char* str_ = str_printf(string_, __VA_ARGS__); FATAL_ERROR(str_); }