mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Merge branch 'master' into sysinfo
This commit is contained in:
@@ -73,10 +73,10 @@ wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator)
|
|||||||
|
|
||||||
// If N == -1 the call to WideCharToMultiByte assume the wide string is null terminated
|
// If N == -1 the call to WideCharToMultiByte assume the wide string is null terminated
|
||||||
// and will scan it to find the first null terminated character. The resulting string will
|
// and will scan it to find the first null terminated character. The resulting string will
|
||||||
// also null terminated.
|
// also be null terminated.
|
||||||
// If N != -1 it assumes the wide string is not null terminated and the resulting string
|
// If N != -1 it assumes the wide string is not null terminated and the resulting string
|
||||||
// will not be null terminated, we therefore have to force it to be null terminated manually.
|
// will not be null terminated.
|
||||||
text := make([]byte, n+1 if N != -1 else n) or_return
|
text := make([]byte, n) or_return
|
||||||
|
|
||||||
n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil)
|
n1 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(text), n, nil, nil)
|
||||||
if n1 == 0 {
|
if n1 == 0 {
|
||||||
|
|||||||
+644
-318
File diff suppressed because it is too large
Load Diff
+14
-1
@@ -3039,8 +3039,8 @@ void check_binary_matrix(CheckerContext *c, Token const &op, Operand *x, Operand
|
|||||||
x->type = xt;
|
x->type = xt;
|
||||||
goto matrix_success;
|
goto matrix_success;
|
||||||
} else {
|
} else {
|
||||||
GB_ASSERT(is_type_matrix(yt));
|
|
||||||
GB_ASSERT(!is_type_matrix(xt));
|
GB_ASSERT(!is_type_matrix(xt));
|
||||||
|
GB_ASSERT(is_type_matrix(yt));
|
||||||
|
|
||||||
if (op.kind == Token_Mul) {
|
if (op.kind == Token_Mul) {
|
||||||
// NOTE(bill): no need to handle the matrix case here since it should be handled above
|
// NOTE(bill): no need to handle the matrix case here since it should be handled above
|
||||||
@@ -3061,6 +3061,9 @@ void check_binary_matrix(CheckerContext *c, Token const &op, Operand *x, Operand
|
|||||||
x->type = alloc_type_matrix(yt->Matrix.elem, 1, yt->Matrix.column_count);
|
x->type = alloc_type_matrix(yt->Matrix.elem, 1, yt->Matrix.column_count);
|
||||||
}
|
}
|
||||||
goto matrix_success;
|
goto matrix_success;
|
||||||
|
} else if (are_types_identical(yt->Matrix.elem, xt)) {
|
||||||
|
x->type = check_matrix_type_hint(y->type, type_hint);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!are_types_identical(xt, yt)) {
|
if (!are_types_identical(xt, yt)) {
|
||||||
@@ -7359,6 +7362,14 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
|
|||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x.mode == Addressing_Type || y.mode == Addressing_Type) {
|
||||||
|
Ast *type_expr = (x.mode == Addressing_Type) ? x.expr : y.expr;
|
||||||
|
gbString type_string = expr_to_string(type_expr);
|
||||||
|
error(node, "Type %s is invalid operand for ternary if expression", type_string);
|
||||||
|
gb_string_free(type_string);
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
|
||||||
if (x.type == nullptr || x.type == t_invalid ||
|
if (x.type == nullptr || x.type == t_invalid ||
|
||||||
y.type == nullptr || y.type == t_invalid) {
|
y.type == nullptr || y.type == t_invalid) {
|
||||||
return kind;
|
return kind;
|
||||||
@@ -7395,6 +7406,7 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
|
|||||||
check_cast_internal(c, &y, type_hint)) {
|
check_cast_internal(c, &y, type_hint)) {
|
||||||
convert_to_typed(c, o, type_hint);
|
convert_to_typed(c, o, type_hint);
|
||||||
update_untyped_expr_type(c, node, type_hint, !is_type_untyped(type_hint));
|
update_untyped_expr_type(c, node, type_hint, !is_type_untyped(type_hint));
|
||||||
|
o->type = type_hint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return kind;
|
return kind;
|
||||||
@@ -9574,6 +9586,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
|
|||||||
case Ast_MapType:
|
case Ast_MapType:
|
||||||
case Ast_BitSetType:
|
case Ast_BitSetType:
|
||||||
case Ast_MatrixType:
|
case Ast_MatrixType:
|
||||||
|
case Ast_RelativeType:
|
||||||
o->mode = Addressing_Type;
|
o->mode = Addressing_Type;
|
||||||
o->type = check_type(c, node);
|
o->type = check_type(c, node);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise=false);
|
lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise);
|
||||||
|
|
||||||
lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast *right, Type *type) {
|
lbValue lb_emit_logical_binary_expr(lbProcedure *p, TokenKind op, Ast *left, Ast *right, Type *type) {
|
||||||
lbModule *m = p->module;
|
lbModule *m = p->module;
|
||||||
@@ -987,7 +987,6 @@ lbValue lb_emit_vector_mul_matrix(lbProcedure *p, lbValue lhs, lbValue rhs, Type
|
|||||||
lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise) {
|
lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Type *type, bool component_wise) {
|
||||||
GB_ASSERT(is_type_matrix(lhs.type) || is_type_matrix(rhs.type));
|
GB_ASSERT(is_type_matrix(lhs.type) || is_type_matrix(rhs.type));
|
||||||
|
|
||||||
|
|
||||||
if (op == Token_Mul && !component_wise) {
|
if (op == Token_Mul && !component_wise) {
|
||||||
Type *xt = base_type(lhs.type);
|
Type *xt = base_type(lhs.type);
|
||||||
Type *yt = base_type(rhs.type);
|
Type *yt = base_type(rhs.type);
|
||||||
@@ -1001,8 +1000,22 @@ lbValue lb_emit_arith_matrix(lbProcedure *p, TokenKind op, lbValue lhs, lbValue
|
|||||||
} else if (is_type_array_like(xt)) {
|
} else if (is_type_array_like(xt)) {
|
||||||
GB_ASSERT(yt->kind == Type_Matrix);
|
GB_ASSERT(yt->kind == Type_Matrix);
|
||||||
return lb_emit_vector_mul_matrix(p, lhs, rhs, type);
|
return lb_emit_vector_mul_matrix(p, lhs, rhs, type);
|
||||||
}
|
} else {
|
||||||
|
GB_ASSERT(xt->kind == Type_Basic);
|
||||||
|
GB_ASSERT(yt->kind == Type_Matrix);
|
||||||
|
GB_ASSERT(is_type_matrix(type));
|
||||||
|
|
||||||
|
Type *array_type = alloc_type_array(yt->Matrix.elem, matrix_type_total_internal_elems(yt));
|
||||||
|
GB_ASSERT(type_size_of(array_type) == type_size_of(yt));
|
||||||
|
|
||||||
|
lbValue array_lhs = lb_emit_conv(p, lhs, array_type);
|
||||||
|
lbValue array_rhs = rhs;
|
||||||
|
array_rhs.type = array_type;
|
||||||
|
|
||||||
|
lbValue array = lb_emit_arith(p, op, array_lhs, array_rhs, array_type);
|
||||||
|
array.type = type;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (is_type_matrix(lhs.type)) {
|
if (is_type_matrix(lhs.type)) {
|
||||||
rhs = lb_emit_conv(p, rhs, lhs.type);
|
rhs = lb_emit_conv(p, rhs, lhs.type);
|
||||||
@@ -1047,7 +1060,7 @@ lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbValue rhs, Ty
|
|||||||
if (is_type_array_like(lhs.type) || is_type_array_like(rhs.type)) {
|
if (is_type_array_like(lhs.type) || is_type_array_like(rhs.type)) {
|
||||||
return lb_emit_arith_array(p, op, lhs, rhs, type);
|
return lb_emit_arith_array(p, op, lhs, rhs, type);
|
||||||
} else if (is_type_matrix(lhs.type) || is_type_matrix(rhs.type)) {
|
} else if (is_type_matrix(lhs.type) || is_type_matrix(rhs.type)) {
|
||||||
return lb_emit_arith_matrix(p, op, lhs, rhs, type);
|
return lb_emit_arith_matrix(p, op, lhs, rhs, type, false);
|
||||||
} else if (is_type_complex(type)) {
|
} else if (is_type_complex(type)) {
|
||||||
lhs = lb_emit_conv(p, lhs, type);
|
lhs = lb_emit_conv(p, lhs, type);
|
||||||
rhs = lb_emit_conv(p, rhs, type);
|
rhs = lb_emit_conv(p, rhs, type);
|
||||||
@@ -1320,7 +1333,7 @@ lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) {
|
|||||||
if (is_type_matrix(be->left->tav.type) || is_type_matrix(be->right->tav.type)) {
|
if (is_type_matrix(be->left->tav.type) || is_type_matrix(be->right->tav.type)) {
|
||||||
lbValue left = lb_build_expr(p, be->left);
|
lbValue left = lb_build_expr(p, be->left);
|
||||||
lbValue right = lb_build_expr(p, be->right);
|
lbValue right = lb_build_expr(p, be->right);
|
||||||
return lb_emit_arith_matrix(p, be->op.kind, left, right, default_type(tv.type));
|
return lb_emit_arith_matrix(p, be->op.kind, left, right, default_type(tv.type), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -225,6 +225,20 @@ lbValue lb_emit_transmute(lbProcedure *p, lbValue value, Type *t) {
|
|||||||
if (is_type_simd_vector(src) && is_type_simd_vector(dst)) {
|
if (is_type_simd_vector(src) && is_type_simd_vector(dst)) {
|
||||||
res.value = LLVMBuildBitCast(p->builder, value.value, lb_type(p->module, t), "");
|
res.value = LLVMBuildBitCast(p->builder, value.value, lb_type(p->module, t), "");
|
||||||
return res;
|
return res;
|
||||||
|
} else if (is_type_array_like(src) && is_type_simd_vector(dst)) {
|
||||||
|
unsigned align = cast(unsigned)gb_max(type_align_of(src), type_align_of(dst));
|
||||||
|
lbValue ptr = lb_address_from_load_or_generate_local(p, value);
|
||||||
|
if (lb_try_update_alignment(ptr, align)) {
|
||||||
|
LLVMTypeRef result_type = lb_type(p->module, t);
|
||||||
|
res.value = LLVMBuildPointerCast(p->builder, ptr.value, LLVMPointerType(result_type, 0), "");
|
||||||
|
res.value = LLVMBuildLoad2(p->builder, result_type, res.value, "");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
lbAddr addr = lb_add_local_generated(p, t, false);
|
||||||
|
lbValue ap = lb_addr_get_ptr(p, addr);
|
||||||
|
ap = lb_emit_conv(p, ap, alloc_type_pointer(value.type));
|
||||||
|
lb_emit_store(p, ap, value);
|
||||||
|
return lb_addr_load(p, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lb_is_type_aggregate(src) || lb_is_type_aggregate(dst)) {
|
if (lb_is_type_aggregate(src) || lb_is_type_aggregate(dst)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user