diff --git a/core/c/c.odin b/core/c/c.odin index d135fa93c..139d9920a 100644 --- a/core/c/c.odin +++ b/core/c/c.odin @@ -3,6 +3,8 @@ package c import builtin "core:builtin" char :: builtin.u8 // assuming -funsigned-char + +schar :: builtin.i8 short :: builtin.i16 int :: builtin.i32 long :: builtin.i32 when (ODIN_OS == "windows" || size_of(builtin.rawptr) == 4) else builtin.i64 diff --git a/core/c/frontend/preprocessor/preprocess.odin b/core/c/frontend/preprocessor/preprocess.odin index 62b4183bc..9651cc81c 100644 --- a/core/c/frontend/preprocessor/preprocess.odin +++ b/core/c/frontend/preprocessor/preprocess.odin @@ -956,7 +956,7 @@ substitute_token :: proc(cpp: ^Preprocessor, tok: ^Token, args: ^Macro_Arg) -> ^ continue } - if tok.lit == "__VA__OPT__" && tok.next.lit == "(" { + if tok.lit == "__VA_OPT__" && tok.next.lit == "(" { opt_arg := read_macro_arg_one(cpp, &tok, tok.next.next, true) if has_varargs(args) { for t := opt_arg.tok; t.kind != .EOF; t = t.next { diff --git a/core/c/libc/types.odin b/core/c/libc/types.odin index 7199cf57b..a49e52fb6 100644 --- a/core/c/libc/types.odin +++ b/core/c/libc/types.odin @@ -3,6 +3,8 @@ package libc import "core:c" char :: c.char // assuming -funsigned-char + +schar :: c.schar short :: c.short int :: c.int long :: c.long diff --git a/core/math/linalg/glsl/linalg_glsl.odin b/core/math/linalg/glsl/linalg_glsl.odin index 3b4976452..053182794 100644 --- a/core/math/linalg/glsl/linalg_glsl.odin +++ b/core/math/linalg/glsl/linalg_glsl.odin @@ -1597,7 +1597,7 @@ quatNlerp :: proc "c" (a, b: quat, t: f32) -> (c: quat) { c.y = a.y + (b.y-a.y)*t c.z = a.z + (b.z-a.z)*t c.w = a.w + (b.w-a.w)*t - return c/builtin.abs(c) + return c/quat(builtin.abs(c)) } quatSlerp :: proc "c" (x, y: quat, t: f32) -> (q: quat) { @@ -1699,7 +1699,7 @@ dquatNlerp :: proc "c" (a, b: dquat, t: f64) -> (c: dquat) { c.y = a.y + (b.y-a.y)*t c.z = a.z + (b.z-a.z)*t c.w = a.w + (b.w-a.w)*t - return c/builtin.abs(c) + return c/dquat(builtin.abs(c)) } dquatSlerp :: proc "c" (x, y: dquat, t: f64) -> (q: dquat) { diff --git a/core/odin/doc-format/doc_format.odin b/core/odin/doc-format/doc_format.odin index c80be2489..83cd89ca2 100644 --- a/core/odin/doc-format/doc_format.odin +++ b/core/odin/doc-format/doc_format.odin @@ -11,7 +11,7 @@ String :: distinct Array(byte) Version_Type_Major :: 0 Version_Type_Minor :: 2 -Version_Type_Patch :: 1 +Version_Type_Patch :: 2 Version_Type :: struct { major, minor, patch: u8, @@ -242,6 +242,8 @@ Type :: struct { polymorphic_params: Type_Index, // Used By: .Struct, .Union where_clauses: Array(String), + // Used By: .Struct + tags: Array(String), } Type_Flags_Basic :: distinct bit_set[Type_Flag_Basic; u32le] diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index d40c80aeb..b32453a5d 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -296,6 +296,8 @@ foreign libc { @(link_name="readdir_r$INODE64") _unix_readdir_r :: proc(dirp: Dir, entry: ^Dirent, result: ^^Dirent) -> c.int --- @(link_name="fcntl") _unix_fcntl :: proc(fd: Handle, cmd: c.int, buf: ^byte) -> c.int --- + @(link_name="fchmod") _unix_fchmod :: proc(fildes: Handle, mode: u16) -> c.int ---; + @(link_name="malloc") _unix_malloc :: proc(size: int) -> rawptr --- @(link_name="calloc") _unix_calloc :: proc(num, size: int) -> rawptr --- @(link_name="free") _unix_free :: proc(ptr: rawptr) --- @@ -305,6 +307,8 @@ foreign libc { @(link_name="chdir") _unix_chdir :: proc(buf: cstring) -> c.int --- @(link_name="realpath") _unix_realpath :: proc(path: cstring, resolved_path: rawptr) -> rawptr --- + @(link_name="strerror") _darwin_string_error :: proc(num : c.int) -> cstring ---; + @(link_name="exit") _unix_exit :: proc(status: c.int) -> ! --- } @@ -319,16 +323,35 @@ get_last_error :: proc() -> int { return __error()^ } -open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Errno) { +get_last_error_string :: proc() -> string { + return cast(string)_darwin_string_error(cast(c.int)get_last_error()); +} + +open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (Handle, Errno) { cstr := strings.clone_to_cstring(path) handle := _unix_open(cstr, i32(flags), u16(mode)) delete(cstr) if handle == -1 { return INVALID_HANDLE, 1 } + +when ODIN_OS == "darwin" && ODIN_ARCH == "arm64" { + if mode != 0 { + err := fchmod(handle, cast(u16)mode) + if err != 0 { + _unix_close(handle) + return INVALID_HANDLE, 1 + } + } +} + return handle, 0 } +fchmod :: proc(fildes: Handle, mode: u16) -> Errno { + return cast(Errno)_unix_fchmod(fildes, mode) +} + close :: proc(fd: Handle) { _unix_close(fd) } diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 67e2f3bd7..cfffffd9f 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7688,6 +7688,14 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type } } + if (t->kind == Type_Matrix) { + if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) { + if (0 < max && max < max_type_count) { + error(node, "Expected %lld values for this matrix literal, got %lld", cast(long long)max_type_count, cast(long long)max); + } + } + } + break; } diff --git a/src/check_type.cpp b/src/check_type.cpp index b4f30d2f0..282da4d0a 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -922,20 +922,19 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no i64 lower = big_int_to_i64(&i); i64 upper = big_int_to_i64(&j); - bool lower_changed = false; + i64 actual_lower = lower; i64 bits = MAX_BITS; if (type->BitSet.underlying != nullptr) { bits = 8*type_size_of(type->BitSet.underlying); if (lower > 0) { - lower = 0; - lower_changed = true; + actual_lower = 0; } else if (lower < 0) { error(bs->elem, "bit_set does not allow a negative lower bound (%lld) when an underlying type is set", lower); } } - i64 bits_required = upper-lower; + i64 bits_required = upper-actual_lower; switch (be->op.kind) { case Token_Ellipsis: case Token_RangeFull: @@ -959,7 +958,7 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no break; } if (!is_valid) { - if (lower_changed) { + if (actual_lower != lower) { error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required (internal the lower changed was changed 0 as an underlying type was set)", bits, bits_required); } else { error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required", bits, bits_required); diff --git a/src/docs_format.cpp b/src/docs_format.cpp index 1c3af6257..5cfac4817 100644 --- a/src/docs_format.cpp +++ b/src/docs_format.cpp @@ -15,7 +15,7 @@ struct OdinDocVersionType { #define OdinDocVersionType_Major 0 #define OdinDocVersionType_Minor 2 -#define OdinDocVersionType_Patch 1 +#define OdinDocVersionType_Patch 2 struct OdinDocHeaderBase { u8 magic[8]; @@ -137,6 +137,7 @@ struct OdinDocType { OdinDocArray entities; OdinDocTypeIndex polmorphic_params; OdinDocArray where_clauses; + OdinDocArray tags; // struct field tags }; struct OdinDocAttribute { diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index e8e8892ec..56ad0561e 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -598,6 +598,15 @@ OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) { } doc_type.where_clauses = odin_doc_where_clauses(w, st->where_clauses); } + + auto tags = array_make(heap_allocator(), type->Struct.fields.count); + defer (array_free(&tags)); + + for_array(i, type->Struct.fields) { + tags[i] = odin_doc_write_string(w, type->Struct.tags[i]); + } + + doc_type.tags = odin_write_slice(w, tags.data, tags.count); } break; case Type_Union: diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index 016e464b8..20b444058 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -2188,6 +2188,7 @@ void lb_build_stmt(lbProcedure *p, Ast *node) { lb_emit_defer_stmts(p, lbDeferExit_Branch, block); } lb_emit_jump(p, block); + lb_start_block(p, lb_create_block(p, "unreachable")); case_end; } } diff --git a/vendor/microui/microui.odin b/vendor/microui/microui.odin index 9d3e01fa0..947f59f40 100644 --- a/vendor/microui/microui.odin +++ b/vendor/microui/microui.odin @@ -1030,9 +1030,7 @@ number_textbox :: proc(ctx: ^Context, value: ^Real, r: Rect, id: Id, fmt_string: if ctx.number_edit_id == id { res := textbox_raw(ctx, ctx.number_edit_buf[:], &ctx.number_edit_len, id, r, {}) if .SUBMIT in res || ctx.focus_id != id { - ok: bool - value^, ok = parse_real(string(ctx.number_edit_buf[:ctx.number_edit_len])) - assert(ok == true) + value^, _ = parse_real(string(ctx.number_edit_buf[:ctx.number_edit_len])) ctx.number_edit_id = 0 } else { return true