diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-05-17 12:26:35 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-05-17 12:26:35 -0400 |
| commit | b483db486842c6d7d348b28ca09e56673e1bd800 (patch) | |
| tree | 72c392366154f45f0c657bd7650d65d9f7d9e86d /src/codegen.cpp | |
| parent | 9851a943ed0360433c9612449ed065a6800adc51 (diff) | |
| download | zig-b483db486842c6d7d348b28ca09e56673e1bd800.tar.gz zig-b483db486842c6d7d348b28ca09e56673e1bd800.zip | |
typeId builtin instead of isInteger, isFloat, etc
closes #373
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
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); |
