diff --git a/core_compiler.h b/core_compiler.h index b8ace23..1e38c5a 100644 --- a/core_compiler.h +++ b/core_compiler.h @@ -242,9 +242,9 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){ l->interns.first_keyword = keyword_struct.str; l->interns.last_keyword = keyword_enum.str; - intern_sizeof = l->intern("size_of"_s); - intern_lengthof = l->intern("length_of"_s); - intern_alignof = l->intern("align_of"_s); + intern_sizeof = l->intern("SizeOf"_s); + intern_lengthof = l->intern("Length"_s); + intern_alignof = l->intern("AlignOf"_s); intern_foreign = intern_string(&l->interns, "foreign"_s); intern_strict = intern_string(&l->interns, "strict"_s); intern_void = intern_string(&l->interns, "void"_s); diff --git a/core_main.cpp b/core_main.cpp index ac2e3b4..7ef42cd 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -61,7 +61,7 @@ For modules it's a bit different cause they should be distributed as valid. - [ ] Builtin data structures - - [ ] Fix length_of etc. they should be function calls not operators + - [ ] Fix Length etc. they should be function calls not operators - [ ] Strings probably should have len() instead of string.len - [ ] Slices - [ ] Some way to take slice of data diff --git a/core_typechecking.cpp b/core_typechecking.cpp index 67fff2f..e0d7f42 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -1228,7 +1228,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){ Operand name = resolve_expr(expr, inherit_flag(flags, AST_CANT_BE_NULL)); if(!name.is_const){ - compiler_error(node->pos, "size_of requires a constant value"); + compiler_error(node->pos, "SizeOf requires a constant value"); } Ast_Type *type = name.type == type_type ? name.type_val : name.type; @@ -1262,7 +1262,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){ else if(expr_atom_is_equal_intern(node->name, intern_alignof)){ Ast_Expr *expr = unpack_ast_call_expr_for_builtin(node); Operand name = resolve_expr(expr, inherit_flag(flags, AST_CANT_BE_NULL)); - if(!name.is_const) compiler_error(node->pos, "align_of requires a constant value"); + if(!name.is_const) compiler_error(node->pos, "AlignOf requires a constant value"); Ast_Type *type = name.type == type_type ? name.type_val : name.type; Value v = value_int(type->align); rewrite_into_const(node, Ast_Builtin, v); diff --git a/examples/arrays_and_slices.kl b/examples/arrays_and_slices.kl index c5bf450..201182b 100644 --- a/examples/arrays_and_slices.kl +++ b/examples/arrays_and_slices.kl @@ -14,8 +14,8 @@ be nice if handling of that was simplified. main :: (): int static_array: [8]int - // We can get size of array using length_of builtin - #Assert(length_of(static_array) == 8) + // We can get size of array using Length builtin + #Assert(Length(static_array) == 8) // Accessing values is like in C // Variables are zeroed by default @@ -39,7 +39,7 @@ main :: (): int slice: []int = static_array // We can't do a compile time Assert anymore - Assert(length_of(slice) == 8) + Assert(Length(slice) == 8) Assert(slice[4] == 1) // After we loop and reassign slice values diff --git a/examples/drawing_to_screen_using_windows_api.kl b/examples/drawing_to_screen_using_windows_api.kl index e6ecd41..42b9999 100644 --- a/examples/drawing_to_screen_using_windows_api.kl +++ b/examples/drawing_to_screen_using_windows_api.kl @@ -26,7 +26,7 @@ CreateBitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap bminfo := BITMAPINFO{ BITMAPINFOHEADER{ - biSize = 40, // @todo!!! size_of(BITMAPINFOHEADER), + biSize = 40, // @todo!!! SizeOf(BITMAPINFOHEADER), biWidth = size.x->LONG, biHeight = size.y->LONG, biPlanes = 1, diff --git a/examples/runtime_type_information.kl b/examples/runtime_type_information.kl index e6c4186..fc20f1a 100644 --- a/examples/runtime_type_information.kl +++ b/examples/runtime_type_information.kl @@ -14,10 +14,10 @@ main :: (): int return 1 if type_info.type == S64 - // We can use size_of and align_of operators + // We can use SizeOf and AlignOf operators // to figure out the type alignment and it's size - Assert(type_info.size == size_of(S64)) - Assert(type_info.align == align_of(S64)) + Assert(type_info.size == SizeOf(S64)) + Assert(type_info.align == AlignOf(S64)) else;; Assert(false, "We expected S64 here! What a boomer!") diff --git a/modules/base.kl b/modules/base.kl index c0b90d6..0bd9942 100644 --- a/modules/base.kl +++ b/modules/base.kl @@ -74,10 +74,10 @@ Utf32ToUtf16 :: (codepoint: U32): [2]U16, S64 StringToString16 :: (arena: *Arena, in: String): String16 in_str := &in[0] // @Note(Krzosa): Should be more then enough space - alloc_size := (length_of(in)*2)+1 + alloc_size := (Length(in)*2)+1 result := String16{str = PushSize(arena, alloc_size->U64)} - for i := 0, i < length_of(in) - s32, s32_len := Utf8ToUtf32(in_str + i, length_of(in) - i) + for i := 0, i < Length(in) + s32, s32_len := Utf8ToUtf32(in_str + i, Length(in) - i) if s32_len != 0 i += s32_len s16, s16_len := Utf32ToUtf16(s32) diff --git a/modules/os_windows.kl b/modules/os_windows.kl index 3d11282..55805d5 100644 --- a/modules/os_windows.kl +++ b/modules/os_windows.kl @@ -99,9 +99,9 @@ Print :: (string: String, args: ..) buffer_len: S64 arg_counter := 0 - for i := 0, i < length_of(string), i+=1 + for i := 0, i < Length(string), i+=1 if string[i] == '%' - Assert(arg_counter < length_of(args), "Passing too many [%] to a print lambda") + Assert(arg_counter < Length(args), "Passing too many [%] to a print lambda") arg := args[arg_counter++] if arg.type == S64