diff options
| author | Jonathan Marler <jonathan.j.marler@hp.com> | 2019-08-22 13:56:04 -0600 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-23 11:14:08 -0400 |
| commit | 9322eee80aadd6d9f80ebc11d29d09898237a14a (patch) | |
| tree | c8848c067244ee16f9cd5525a366d4bb451ae474 /src/analyze.cpp | |
| parent | 0e75fef1decdaba918b2abc84977ecadb010ad32 (diff) | |
| download | zig-9322eee80aadd6d9f80ebc11d29d09898237a14a.tar.gz zig-9322eee80aadd6d9f80ebc11d29d09898237a14a.zip | |
Encapsulate bigint representation, assert on cast data loss
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index a06bba3f2a..6397a16818 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1036,7 +1036,7 @@ static bool analyze_const_align(CodeGen *g, Scope *scope, AstNode *node, uint32_ if (type_is_invalid(align_result->type)) return false; - uint32_t align_bytes = bigint_as_unsigned(&align_result->data.x_bigint); + uint32_t align_bytes = bigint_as_u32(&align_result->data.x_bigint); if (align_bytes == 0) { add_node_error(g, node, buf_sprintf("alignment must be >= 1")); return false; @@ -1068,7 +1068,7 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf ** return true; } expand_undef_array(g, array_val); - size_t len = bigint_as_unsigned(&len_field->data.x_bigint); + size_t len = bigint_as_usize(&len_field->data.x_bigint); Buf *result = buf_alloc(); buf_resize(result, len); for (size_t i = 0; i < len; i += 1) { @@ -1078,7 +1078,7 @@ static bool analyze_const_string(CodeGen *g, Scope *scope, AstNode *node, Buf ** add_node_error(g, node, buf_sprintf("use of undefined value")); return false; } - uint64_t big_c = bigint_as_unsigned(&char_val->data.x_bigint); + uint64_t big_c = bigint_as_u64(&char_val->data.x_bigint); assert(big_c <= UINT8_MAX); uint8_t c = (uint8_t)big_c; buf_ptr(result)[i] = c; @@ -5976,7 +5976,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { { if (is_slice(type_entry)) { ConstExprValue *len_val = &const_val->data.x_struct.fields[slice_len_index]; - size_t len = bigint_as_unsigned(&len_val->data.x_bigint); + size_t len = bigint_as_usize(&len_val->data.x_bigint); ConstExprValue *ptr_val = &const_val->data.x_struct.fields[slice_ptr_index]; if (ptr_val->special == ConstValSpecialUndef) { |
