From b483db486842c6d7d348b28ca09e56673e1bd800 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 17 May 2017 12:26:35 -0400 Subject: typeId builtin instead of isInteger, isFloat, etc closes #373 --- src/codegen.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index e4799d63f1..5e752d9a69 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3009,7 +3009,6 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, case IrInstructionIdTestComptime: case IrInstructionIdCheckSwitchProngs: case IrInstructionIdCheckStatementIsVoid: - case IrInstructionIdTestType: case IrInstructionIdTypeName: case IrInstructionIdCanImplicitCast: case IrInstructionIdSetGlobalAlign: @@ -3018,6 +3017,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, case IrInstructionIdDeclRef: case IrInstructionIdSwitchVar: case IrInstructionIdOffsetOf: + case IrInstructionIdTypeId: zig_unreachable(); case IrInstructionIdReturn: return ir_render_return(g, executable, (IrInstructionReturn *)instruction); @@ -4423,8 +4423,6 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdCImport, "cImport", 1); create_builtin_fn(g, BuiltinFnIdErrName, "errorName", 1); create_builtin_fn(g, BuiltinFnIdTypeName, "typeName", 1); - create_builtin_fn(g, BuiltinFnIdIsInteger, "isInteger", 1); - create_builtin_fn(g, BuiltinFnIdIsFloat, "isFloat", 1); create_builtin_fn(g, BuiltinFnIdCanImplicitCast, "canImplicitCast", 2); create_builtin_fn(g, BuiltinFnIdEmbedFile, "embedFile", 1); create_builtin_fn(g, BuiltinFnIdCmpExchange, "cmpxchg", 5); @@ -4449,6 +4447,7 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdRem, "rem", 2); create_builtin_fn(g, BuiltinFnIdMod, "mod", 2); create_builtin_fn(g, BuiltinFnIdInlineCall, "inlineCall", SIZE_MAX); + create_builtin_fn(g, BuiltinFnIdTypeId, "typeId", 1); } static const char *bool_to_str(bool b) { @@ -4580,6 +4579,15 @@ static void define_builtin_compile_vars(CodeGen *g) { " ReleaseFast,\n" "};\n\n"); } + { + buf_appendf(contents, "pub const TypeId = enum {\n"); + size_t field_count = type_id_len(); + for (size_t i = 0; i < field_count; i += 1) { + const TypeTableEntryId id = type_id_at_index(i); + buf_appendf(contents, " %s,\n", type_id_name(id)); + } + buf_appendf(contents, "};\n\n"); + } buf_appendf(contents, "pub const is_big_endian = %s;\n", bool_to_str(g->is_big_endian)); buf_appendf(contents, "pub const is_test = %s;\n", bool_to_str(g->is_test_build)); buf_appendf(contents, "pub const os = Os.%s;\n", cur_os); -- cgit v1.2.3