Cosmetic changes
This commit is contained in:
@@ -242,9 +242,9 @@ lex_init(Allocator *token_string_arena, Allocator *map_allocator, Lexer *l){
|
|||||||
l->interns.first_keyword = keyword_struct.str;
|
l->interns.first_keyword = keyword_struct.str;
|
||||||
l->interns.last_keyword = keyword_enum.str;
|
l->interns.last_keyword = keyword_enum.str;
|
||||||
|
|
||||||
intern_sizeof = l->intern("size_of"_s);
|
intern_sizeof = l->intern("SizeOf"_s);
|
||||||
intern_lengthof = l->intern("length_of"_s);
|
intern_lengthof = l->intern("Length"_s);
|
||||||
intern_alignof = l->intern("align_of"_s);
|
intern_alignof = l->intern("AlignOf"_s);
|
||||||
intern_foreign = intern_string(&l->interns, "foreign"_s);
|
intern_foreign = intern_string(&l->interns, "foreign"_s);
|
||||||
intern_strict = intern_string(&l->interns, "strict"_s);
|
intern_strict = intern_string(&l->interns, "strict"_s);
|
||||||
intern_void = intern_string(&l->interns, "void"_s);
|
intern_void = intern_string(&l->interns, "void"_s);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ For modules it's a bit different cause they should be distributed as valid.
|
|||||||
|
|
||||||
|
|
||||||
- [ ] Builtin data structures
|
- [ ] 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
|
- [ ] Strings probably should have len() instead of string.len
|
||||||
- [ ] Slices
|
- [ ] Slices
|
||||||
- [ ] Some way to take slice of data
|
- [ ] Some way to take slice of data
|
||||||
|
|||||||
@@ -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));
|
Operand name = resolve_expr(expr, inherit_flag(flags, AST_CANT_BE_NULL));
|
||||||
if(!name.is_const){
|
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;
|
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)){
|
else if(expr_atom_is_equal_intern(node->name, intern_alignof)){
|
||||||
Ast_Expr *expr = unpack_ast_call_expr_for_builtin(node);
|
Ast_Expr *expr = unpack_ast_call_expr_for_builtin(node);
|
||||||
Operand name = resolve_expr(expr, inherit_flag(flags, AST_CANT_BE_NULL));
|
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;
|
Ast_Type *type = name.type == type_type ? name.type_val : name.type;
|
||||||
Value v = value_int(type->align);
|
Value v = value_int(type->align);
|
||||||
rewrite_into_const(node, Ast_Builtin, v);
|
rewrite_into_const(node, Ast_Builtin, v);
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ be nice if handling of that was simplified.
|
|||||||
main :: (): int
|
main :: (): int
|
||||||
static_array: [8]int
|
static_array: [8]int
|
||||||
|
|
||||||
// We can get size of array using length_of builtin
|
// We can get size of array using Length builtin
|
||||||
#Assert(length_of(static_array) == 8)
|
#Assert(Length(static_array) == 8)
|
||||||
|
|
||||||
// Accessing values is like in C
|
// Accessing values is like in C
|
||||||
// Variables are zeroed by default
|
// Variables are zeroed by default
|
||||||
@@ -39,7 +39,7 @@ main :: (): int
|
|||||||
slice: []int = static_array
|
slice: []int = static_array
|
||||||
|
|
||||||
// We can't do a compile time Assert anymore
|
// We can't do a compile time Assert anymore
|
||||||
Assert(length_of(slice) == 8)
|
Assert(Length(slice) == 8)
|
||||||
Assert(slice[4] == 1)
|
Assert(slice[4] == 1)
|
||||||
|
|
||||||
// After we loop and reassign slice values
|
// After we loop and reassign slice values
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ CreateBitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
|
|||||||
|
|
||||||
bminfo := BITMAPINFO{
|
bminfo := BITMAPINFO{
|
||||||
BITMAPINFOHEADER{
|
BITMAPINFOHEADER{
|
||||||
biSize = 40, // @todo!!! size_of(BITMAPINFOHEADER),
|
biSize = 40, // @todo!!! SizeOf(BITMAPINFOHEADER),
|
||||||
biWidth = size.x->LONG,
|
biWidth = size.x->LONG,
|
||||||
biHeight = size.y->LONG,
|
biHeight = size.y->LONG,
|
||||||
biPlanes = 1,
|
biPlanes = 1,
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ main :: (): int
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
if type_info.type == S64
|
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
|
// to figure out the type alignment and it's size
|
||||||
Assert(type_info.size == size_of(S64))
|
Assert(type_info.size == SizeOf(S64))
|
||||||
Assert(type_info.align == align_of(S64))
|
Assert(type_info.align == AlignOf(S64))
|
||||||
|
|
||||||
else;; Assert(false, "We expected S64 here! What a boomer!")
|
else;; Assert(false, "We expected S64 here! What a boomer!")
|
||||||
|
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ Utf32ToUtf16 :: (codepoint: U32): [2]U16, S64
|
|||||||
StringToString16 :: (arena: *Arena, in: String): String16
|
StringToString16 :: (arena: *Arena, in: String): String16
|
||||||
in_str := &in[0]
|
in_str := &in[0]
|
||||||
// @Note(Krzosa): Should be more then enough space
|
// @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)}
|
result := String16{str = PushSize(arena, alloc_size->U64)}
|
||||||
for i := 0, i < length_of(in)
|
for i := 0, i < Length(in)
|
||||||
s32, s32_len := Utf8ToUtf32(in_str + i, length_of(in) - i)
|
s32, s32_len := Utf8ToUtf32(in_str + i, Length(in) - i)
|
||||||
if s32_len != 0
|
if s32_len != 0
|
||||||
i += s32_len
|
i += s32_len
|
||||||
s16, s16_len := Utf32ToUtf16(s32)
|
s16, s16_len := Utf32ToUtf16(s32)
|
||||||
|
|||||||
@@ -99,9 +99,9 @@ Print :: (string: String, args: ..)
|
|||||||
buffer_len: S64
|
buffer_len: S64
|
||||||
|
|
||||||
arg_counter := 0
|
arg_counter := 0
|
||||||
for i := 0, i < length_of(string), i+=1
|
for i := 0, i < Length(string), i+=1
|
||||||
if string[i] == '%'
|
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++]
|
arg := args[arg_counter++]
|
||||||
|
|
||||||
if arg.type == S64
|
if arg.type == S64
|
||||||
|
|||||||
Reference in New Issue
Block a user