Merge branch 'master' into windows-llvm-11.1.0

This commit is contained in:
gingerBill
2022-01-05 11:31:34 +00:00
12 changed files with 59 additions and 14 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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

View File

@@ -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) {

View File

@@ -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]

View File

@@ -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)
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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<OdinDocEntityIndex> entities;
OdinDocTypeIndex polmorphic_params;
OdinDocArray<OdinDocString> where_clauses;
OdinDocArray<OdinDocString> tags; // struct field tags
};
struct OdinDocAttribute {

View File

@@ -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<OdinDocString>(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:

View File

@@ -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;
}
}

View File

@@ -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