diff --git a/core/fmt.odin b/core/fmt.odin index fa7d3893f..575925a16 100644 --- a/core/fmt.odin +++ b/core/fmt.odin @@ -170,11 +170,10 @@ write_type :: proc(buf: ^[]byte, ti: ^Type_Info) { write_string(buf, "]"); write_type(buf, info.elem); case Dynamic_Array: - write_string(buf, "[..]"); + write_string(buf, "[dynamic]"); write_type(buf, info.elem); case Slice: - write_string(buf, "["); - write_string(buf, "]"); + write_string(buf, "[]"); write_type(buf, info.elem); case Vector: write_string(buf, "[vector "); @@ -320,7 +319,7 @@ sprintf :: proc(buf: []byte, fmt: string, args: ..any) -> string { -parse_int :: proc(s: string, offset: int) -> (result: int, offset: int, ok: bool) { +_parse_int :: proc(s: string, offset: int) -> (result: int, offset: int, ok: bool) { is_digit :: proc(r: rune) -> bool #inline { return '0' <= r && r <= '9'; } @@ -356,7 +355,7 @@ _arg_number :: proc(fi: ^Fmt_Info, for i in 1..len(format) { if format[i] == ']' { - width, new_index, ok := parse_int(format, 1); + width, new_index, ok := _parse_int(format, 1); if !ok || new_index != i { return 0, i+1, false; } @@ -623,6 +622,19 @@ fmt_string :: proc(fi: ^Fmt_Info, s: string, verb: rune) { match verb { case 's', 'v': write_string(fi.buf, s); + + case 'x', 'X': + space := fi.space; + fi.space = false; + defer fi.space = space; + + for i in 0..len(s) { + if i > 0 && space { + write_byte(fi.buf, ' '); + } + _write_int(fi, cast(u64)s[i], 16, false, 8, verb == 'x' ? __DIGITS_LOWER : __DIGITS_UPPER); + } + default: fmt_bad_verb(fi, verb); } @@ -1044,7 +1056,7 @@ bprintf :: proc(b: ^[]byte, fmt: string, args: ..any) -> int { } was_prev_index = false; } else { - fi.width, i, fi.width_set = parse_int(fmt, i); + fi.width, i, fi.width_set = _parse_int(fmt, i); if was_prev_index && fi.width_set { // %[6]2d fi.good_arg_index = false; } @@ -1069,7 +1081,7 @@ bprintf :: proc(b: ^[]byte, fmt: string, args: ..any) -> int { } was_prev_index = false; } else { - fi.prec, i, fi.prec_set = parse_int(fmt, i); + fi.prec, i, fi.prec_set = _parse_int(fmt, i); if !fi.prec_set { fi.prec_set = true; fi.prec = 0; diff --git a/core/sys/windows.odin b/core/sys/windows.odin index 2493a29e1..3d29bfa83 100644 --- a/core/sys/windows.odin +++ b/core/sys/windows.odin @@ -349,6 +349,7 @@ SetWindowPos :: proc(wnd: Hwnd, wndInsertAfter: Hwnd, x, y, width, height: GetWindowPlacement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool #foreign user32; SetWindowPlacement :: proc(wnd: Hwnd, wndpl: ^Window_Placement) -> Bool #foreign user32; +GetWindowRect :: proc(wnd: Hwnd, rect: ^Rect) -> Bool #foreign user32; GetWindowLongPtrA :: proc(wnd: Hwnd, index: i32) -> i64 #foreign user32; SetWindowLongPtrA :: proc(wnd: Hwnd, index: i32, new: i64) -> i64 #foreign user32; diff --git a/src/checker.c b/src/checker.c index 22b48ca00..f8ecac489 100644 --- a/src/checker.c +++ b/src/checker.c @@ -28,7 +28,6 @@ typedef enum BuiltinProcId { BuiltinProc_new, BuiltinProc_free, - // BuiltinProc_new_slice, BuiltinProc_make, BuiltinProc_reserve, @@ -64,8 +63,6 @@ typedef enum BuiltinProcId { BuiltinProc_kmag, BuiltinProc_conj, - // BuiltinProc_ptr_offset, - // BuiltinProc_ptr_sub, BuiltinProc_slice_ptr, BuiltinProc_slice_to_bytes, @@ -84,7 +81,6 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = { {STR_LIT("new"), 1, false, Expr_Expr}, {STR_LIT("free"), 1, false, Expr_Stmt}, - // {STR_LIT("new_slice"), 2, true, Expr_Expr}, {STR_LIT("make"), 1, true, Expr_Expr}, {STR_LIT("reserve"), 2, false, Expr_Stmt}, @@ -108,7 +104,6 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = { {STR_LIT("panic"), 1, false, Expr_Stmt}, {STR_LIT("copy"), 2, false, Expr_Expr}, - // {STR_LIT("append"), 2, false, Expr_Expr}, {STR_LIT("swizzle"), 1, true, Expr_Expr}, @@ -120,8 +115,6 @@ gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = { {STR_LIT("kmag"), 1, false, Expr_Expr}, {STR_LIT("conj"), 1, false, Expr_Expr}, - // {STR_LIT("ptr_offset"), 2, false, Expr_Expr}, - // {STR_LIT("ptr_sub"), 2, false, Expr_Expr}, {STR_LIT("slice_ptr"), 2, true, Expr_Expr}, {STR_LIT("slice_to_bytes"), 1, false, Expr_Stmt}, @@ -310,7 +303,7 @@ typedef struct CheckerInfo { MapScope scopes; // Key: AstNode * | Node -> Scope MapExprInfo untyped; // Key: AstNode * | Expression -> ExprInfo MapDeclInfo entities; // Key: Entity * - MapEntity implicits; // Key: AstNode * + MapEntity implicits; // Key: AstNode * MapEntity foreigns; // Key: String MapAstFile files; // Key: String (full path) MapIsize type_info_map; // Key: Type * diff --git a/src/ir.c b/src/ir.c index df6c02bec..e09426229 100644 --- a/src/ir.c +++ b/src/ir.c @@ -5410,11 +5410,9 @@ void ir_build_range_string(irProcedure *proc, irValue *expr, Type *val_type, irBlock *done = NULL; irBlock *body = NULL; - irValue *index = ir_add_local_generated(proc, t_int); - ir_emit_store(proc, index, v_zero); irValue *offset_ = ir_add_local_generated(proc, t_int); - ir_emit_store(proc, index, v_zero); + ir_emit_store(proc, offset_, v_zero); loop = ir_new_block(proc, NULL, "for.string.loop"); ir_emit_jump(proc, loop); @@ -5441,11 +5439,10 @@ void ir_build_range_string(irProcedure *proc, irValue *expr, Type *val_type, ir_emit_store(proc, offset_, ir_emit_arith(proc, Token_Add, offset, len, t_int)); - idx = ir_emit_load(proc, index); + idx = offset; if (val_type != NULL) { val = ir_emit_struct_ev(proc, rune_and_len, 0); } - ir_emit_increment(proc, index); if (val_) *val_ = val; if (idx_) *idx_ = idx; diff --git a/src/parser.c b/src/parser.c index 8e56279ab..e9c1a9a44 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1724,11 +1724,7 @@ AstNode *parse_operand(AstFile *f, bool lhs) { AstNode *operand = NULL; // Operand switch (f->curr_token.kind) { case Token_Ident: - operand = parse_ident(f); - if (!lhs) { - // TODO(bill): Handle? - } - return operand; + return parse_ident(f); case Token_context: return ast_implicit(f, expect_token(f, Token_context)); @@ -1834,17 +1830,6 @@ AstNode *parse_operand(AstFile *f, bool lhs) { return type; } - // case Token_if: - // if (!lhs && f->expr_level >= 0) { - // return parse_if_expr(f); - // } - // break; - // case Token_OpenBrace: - // if (!lhs && f->expr_level >= 0) { - // return parse_block_expr(f); - // } - // break; - default: { AstNode *type = parse_type_or_ident(f); if (type != NULL) {