mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 15:44:04 +00:00
Merge branch 'master' into separate-int-word-sizes
This commit is contained in:
@@ -7887,8 +7887,11 @@ gb_internal ExprKind check_or_return_expr(CheckerContext *c, Operand *o, Ast *no
|
||||
rhs.type = right_type;
|
||||
rhs.mode = Addressing_Value;
|
||||
|
||||
// TODO(bill): better error message
|
||||
if (!check_is_assignable_to(c, &rhs, end_type)) {
|
||||
if (is_type_boolean(right_type) && is_type_boolean(end_type)) {
|
||||
// NOTE(bill): allow implicit conversion between boolean types
|
||||
// within 'or_return' to improve the experience using third-party code
|
||||
} else if (!check_is_assignable_to(c, &rhs, end_type)) {
|
||||
// TODO(bill): better error message
|
||||
gbString a = type_to_string(right_type);
|
||||
gbString b = type_to_string(end_type);
|
||||
gbString ret_type = type_to_string(result_type);
|
||||
|
||||
@@ -8,8 +8,9 @@ struct ErrorCollector {
|
||||
BlockingMutex string_mutex;
|
||||
RecursiveMutex block_mutex;
|
||||
|
||||
Array<u8> error_buffer;
|
||||
Array<String> errors;
|
||||
RecursiveMutex error_buffer_mutex;
|
||||
Array<u8> error_buffer;
|
||||
Array<String> errors;
|
||||
};
|
||||
|
||||
gb_global ErrorCollector global_error_collector;
|
||||
@@ -119,6 +120,7 @@ gb_internal void begin_error_block(void) {
|
||||
}
|
||||
|
||||
gb_internal void end_error_block(void) {
|
||||
mutex_lock(&global_error_collector.error_buffer_mutex);
|
||||
isize n = global_error_collector.error_buffer.count;
|
||||
if (n > 0) {
|
||||
u8 *text = global_error_collector.error_buffer.data;
|
||||
@@ -150,11 +152,16 @@ gb_internal void end_error_block(void) {
|
||||
text = gb_alloc_array(permanent_allocator(), u8, n+1);
|
||||
gb_memmove(text, global_error_collector.error_buffer.data, n);
|
||||
text[n] = 0;
|
||||
|
||||
|
||||
mutex_lock(&global_error_collector.error_out_mutex);
|
||||
String s = {text, n};
|
||||
array_add(&global_error_collector.errors, s);
|
||||
mutex_unlock(&global_error_collector.error_out_mutex);
|
||||
|
||||
global_error_collector.error_buffer.count = 0;
|
||||
}
|
||||
|
||||
mutex_unlock(&global_error_collector.error_buffer_mutex);
|
||||
global_error_collector.in_block.store(false);
|
||||
mutex_unlock(&global_error_collector.block_mutex);
|
||||
}
|
||||
@@ -172,11 +179,15 @@ gb_internal ERROR_OUT_PROC(default_error_out_va) {
|
||||
isize len = gb_snprintf_va(buf, gb_size_of(buf), fmt, va);
|
||||
isize n = len-1;
|
||||
if (global_error_collector.in_block) {
|
||||
mutex_lock(&global_error_collector.error_buffer_mutex);
|
||||
|
||||
isize cap = global_error_collector.error_buffer.count + n;
|
||||
array_reserve(&global_error_collector.error_buffer, cap);
|
||||
u8 *data = global_error_collector.error_buffer.data + global_error_collector.error_buffer.count;
|
||||
gb_memmove(data, buf, n);
|
||||
global_error_collector.error_buffer.count += n;
|
||||
|
||||
mutex_unlock(&global_error_collector.error_buffer_mutex);
|
||||
} else {
|
||||
mutex_lock(&global_error_collector.error_out_mutex);
|
||||
{
|
||||
|
||||
@@ -2083,10 +2083,12 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) {
|
||||
Type *elem = base_array_type(dst);
|
||||
lbValue e = lb_emit_conv(p, value, elem);
|
||||
lbAddr v = lb_add_local_generated(p, t, false);
|
||||
for (i64 i = 0; i < dst->Matrix.row_count; i++) {
|
||||
isize j = cast(isize)i;
|
||||
lbValue ptr = lb_emit_matrix_epi(p, v.addr, j, j);
|
||||
lb_emit_store(p, ptr, e);
|
||||
lbValue zero = lb_const_value(p->module, elem, exact_value_i64(0), true);
|
||||
for (i64 j = 0; j < dst->Matrix.column_count; j++) {
|
||||
for (i64 i = 0; i < dst->Matrix.row_count; i++) {
|
||||
lbValue ptr = lb_emit_matrix_epi(p, v.addr, i, j);
|
||||
lb_emit_store(p, ptr, i == j ? e : zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2462,7 +2462,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
|
||||
}
|
||||
is_raw_union = true;
|
||||
} else if (tag.string == "no_copy") {
|
||||
if (is_packed) {
|
||||
if (no_copy) {
|
||||
syntax_error(tag, "Duplicate struct tag '#%.*s'", LIT(tag.string));
|
||||
}
|
||||
no_copy = true;
|
||||
|
||||
@@ -47,7 +47,7 @@ gb_internal gb_inline u32 ptr_map_hash_key(uintptr key) {
|
||||
key = key ^ (key << 28);
|
||||
res = cast(u32)key;
|
||||
#elif defined(GB_ARCH_32_BIT)
|
||||
u32 state = ((u32)key) * 747796405u + 2891336453u;
|
||||
u32 state = (cast(u32)key) * 747796405u + 2891336453u;
|
||||
u32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
||||
res = (word >> 22u) ^ word;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user