diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2018-07-28 18:39:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-28 18:39:15 +0100 |
| commit | 8d2c4a78a19774d98f5603d78ab6520f39d18bcd (patch) | |
| tree | 95284815f9ec477819bbfd65e90c7cdae757a878 /src/ir_print.cpp | |
| parent | 1ab40d86009ff569b66650eb35b050a68e11df89 (diff) | |
| parent | 8504ff920b057007382bbeefcaa8a40e35689526 (diff) | |
Merge pull request #238 from odin-lang/big-int
Big int
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index 88b172d7f..ac1c20d90 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -65,6 +65,15 @@ void ir_write_i64(irFileBuffer *f, i64 i) { String str = i64_to_string(i, f->buf, IR_FILE_BUFFER_BUF_LEN-1); ir_write_string(f, str); } +void ir_write_big_int(irFileBuffer *f, BigInt const &x) { + i64 i = 0; + if (x.neg) { + i = big_int_to_i64(&x); + } else { + i = cast(i64)big_int_to_u64(&x); + } + ir_write_i64(f, i); +} void ir_file_write(irFileBuffer *f, void *data, isize len) { ir_file_buffer_write(f, data, len); @@ -587,19 +596,19 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type * } case ExactValue_Integer: { if (is_type_pointer(type)) { - if (value.value_integer == 0) { + if (big_int_is_zero(&value.value_integer)) { ir_write_str_lit(f, "null"); } else { ir_write_str_lit(f, "inttoptr ("); ir_print_type(f, m, t_int); ir_write_byte(f, ' '); - ir_write_i64(f, value.value_integer); + ir_write_big_int(f, value.value_integer); ir_write_str_lit(f, " to "); ir_print_type(f, m, t_rawptr); ir_write_str_lit(f, ")"); } } else { - ir_write_i64(f, value.value_integer); + ir_write_big_int(f, value.value_integer); } break; } |