Add string as struct, Fix void pointer indexing
compound for String is not working but maybe that's fine
This commit is contained in:
@@ -95,7 +95,7 @@ pctx->op_info_table[19] = {pctx->intern("!"_s), "NOT"_s, TK_Not, 0, 1};
|
||||
|
||||
// Init types
|
||||
pctx->type__void = {TYPE_VOID};
|
||||
pctx->type__string = {TYPE_STRING, sizeof(String), __alignof(String)};
|
||||
// pctx->type__string = {TYPE_STRING, sizeof(String), __alignof(String)};
|
||||
pctx->type__bool = {TYPE_BOOL, sizeof(bool), __alignof(bool)};
|
||||
pctx->type__type = {TYPE_TYPE, sizeof(S64), __alignof(S64)};
|
||||
|
||||
@@ -127,7 +127,7 @@ pctx->op_info_table[19] = {pctx->intern("!"_s), "NOT"_s, TK_Not, 0, 1};
|
||||
//pctx->type_any; // Needs to be inited at runtime
|
||||
|
||||
pctx->type_type = &pctx->type__type;
|
||||
pctx->type_string = &pctx->type__string;
|
||||
// pctx->type_string = &pctx->type__string;
|
||||
pctx->type_bool = &pctx->type__bool;
|
||||
|
||||
pctx->type_f32 = &pctx->type__f32;
|
||||
@@ -298,6 +298,10 @@ Any :: struct
|
||||
data: *void
|
||||
type: Type
|
||||
|
||||
String :: struct
|
||||
data: *U8
|
||||
len: S64
|
||||
|
||||
Type_Info_Kind :: enum
|
||||
S64 // FIRST_NUMERIC
|
||||
S32
|
||||
@@ -369,7 +373,7 @@ GetTypeInfo :: (type: Type): *Type_Info
|
||||
insert_builtin_type_into_scope(module, "F32"_s, pctx->type_f32);
|
||||
insert_builtin_type_into_scope(module, "void"_s, pctx->type_void);
|
||||
insert_builtin_type_into_scope(module, "Bool"_s, pctx->type_bool);
|
||||
insert_builtin_type_into_scope(module, "String"_s, pctx->type_string);
|
||||
// insert_builtin_type_into_scope(module, "String"_s, pctx->type_string);
|
||||
insert_builtin_type_into_scope(module, "Type"_s, pctx->type_type);
|
||||
}
|
||||
|
||||
@@ -411,6 +415,10 @@ GetTypeInfo :: (type: Type): *Type_Info
|
||||
Ast_Decl *any_decl = search_for_single_decl(module, pctx->intern("Any"_s));
|
||||
assert(any_decl->type == pctx->type_type);
|
||||
pctx->type_any = any_decl->type_val;
|
||||
|
||||
Ast_Decl *string_decl = search_for_single_decl(module, pctx->intern("String"_s));
|
||||
assert(string_decl->type == pctx->type_type);
|
||||
pctx->type_string = string_decl->type_val;
|
||||
}
|
||||
|
||||
Ast_Module *module = add_module(0, pctx->intern(filename), true);
|
||||
|
||||
Reference in New Issue
Block a user