Files
corelang/core_globals.cpp
2022-09-30 09:16:53 +02:00

137 lines
5.0 KiB
C++

thread_local Parse_Ctx *pctx;
thread_local B32 emit_line_directives;
Allocator *bigint_allocator;
global S64 bigint_allocation_count;
global Token token_null = {SAME_SCOPE};
global Token null_token; // @todo: memes, why the above is called null?
/*#import meta
for i in meta.keywords: print(f'Intern_String keyword_{i.lower()};')
for i in meta.interns: print(f'Intern_String intern_{i.lower()};')
for i in meta.token_simple_expr:
if i[1] != "SPECIAL":
print("Intern_String op_" + meta.pascal_to_snake(i[0]) + ";")
*/
Intern_String keyword_struct;
Intern_String keyword_union;
Intern_String keyword_true;
Intern_String keyword_default;
Intern_String keyword_break;
Intern_String keyword_false;
Intern_String keyword_return;
Intern_String keyword_switch;
Intern_String keyword_assert;
Intern_String keyword_if;
Intern_String keyword_elif;
Intern_String keyword_pass;
Intern_String keyword_else;
Intern_String keyword_for;
Intern_String keyword_enum;
Intern_String intern_sizeof;
Intern_String intern_length;
Intern_String intern_alignof;
Intern_String intern_foreign;
Intern_String intern_strict;
Intern_String intern_void;
Intern_String intern_flag;
Intern_String intern_it;
Intern_String op_mul;
Intern_String op_div;
Intern_String op_mod;
Intern_String op_left_shift;
Intern_String op_right_shift;
Intern_String op_add;
Intern_String op_sub;
Intern_String op_equals;
Intern_String op_lesser_then_or_equal;
Intern_String op_greater_then_or_equal;
Intern_String op_lesser_then;
Intern_String op_greater_then;
Intern_String op_not_equals;
Intern_String op_bit_and;
Intern_String op_bit_or;
Intern_String op_bit_xor;
Intern_String op_and;
Intern_String op_or;
Intern_String op_neg;
Intern_String op_not;
Intern_String op_decrement;
Intern_String op_increment;
Intern_String op_post_decrement;
Intern_String op_post_increment;
/*END*/
//-----------------------------------------------------------------------------
// Type globals
//-----------------------------------------------------------------------------
const SizeU pointer_size = sizeof(SizeU);
const SizeU pointer_align = __alignof(SizeU);
global Ast_Type type__void = {TYPE_VOID};
global Ast_Type type__string = {TYPE_STRING, sizeof(String), __alignof(String)};
global Ast_Type type__bool = {TYPE_BOOL, sizeof(bool), __alignof(bool)};
global Ast_Type type__type = {TYPE_TYPE, sizeof(S64), __alignof(S64)};
global Ast_Type type__f32 = {TYPE_F32, sizeof(F32), __alignof(F32)};
global Ast_Type type__f64 = {TYPE_F64, sizeof(F64), __alignof(F64)};
global Ast_Type type__s8 = {TYPE_S8, sizeof(S8), __alignof(S8)};
global Ast_Type type__s16 = {TYPE_S16, sizeof(S16), __alignof(S16)};
global Ast_Type type__s32 = {TYPE_S32, sizeof(S32), __alignof(S32)};
global Ast_Type type__s64 = {TYPE_S64, sizeof(S64), __alignof(S64)};
global Ast_Type type__u8 = {TYPE_U8, sizeof(U8), __alignof(U8), true};
global Ast_Type type__u16 = {TYPE_U16, sizeof(U16), __alignof(U16), true};
global Ast_Type type__u32 = {TYPE_U32, sizeof(U32), __alignof(U32), true};
global Ast_Type type__u64 = {TYPE_U64, sizeof(U64), __alignof(U64), true};
global Ast_Type type__untyped_bool = {TYPE_UNTYPED_BOOL, sizeof(bool), __alignof(bool)};
global Ast_Type type__untyped_int = {TYPE_UNTYPED_INT, sizeof(S64), __alignof(S64)};
global Ast_Type type__untyped_string = {TYPE_UNTYPED_STRING, sizeof(String), __alignof(String)};
global Ast_Type type__untyped_float = {TYPE_UNTYPED_FLOAT, sizeof(double), __alignof(double)};
global Ast_Type type__char = {TYPE_CHAR, sizeof(char), __alignof(char)};
global Ast_Type type__int = {TYPE_INT, sizeof(int), __alignof(int)};
global Ast_Type *type_char = &type__char;
global Ast_Type *type_int = &type__int;
global Ast_Type *type_void = &type__void;
global Ast_Type *type_pointer_to_char; // Needs to be inited at runtime
global Ast_Type *type_pointer_to_void; // Needs to be inited at runtime
global Ast_Type *type_any; // Needs to be inited at runtime
global Ast_Type *type_type = &type__type;
global Ast_Type *type_string = &type__string;
global Ast_Type *type_bool = &type__bool;
global Ast_Type *type_f32 = &type__f32;
global Ast_Type *type_f64 = &type__f64;
global Ast_Type *type_s8 = &type__s8 ;
global Ast_Type *type_s16 = &type__s16;
global Ast_Type *type_s32 = &type__s32;
global Ast_Type *type_s64 = &type__s64;
global Ast_Type *type_u8 = &type__u8 ;
global Ast_Type *type_u16 = &type__u16;
global Ast_Type *type_u32 = &type__u32;
global Ast_Type *type_u64 = &type__u64;
global Ast_Type *untyped_string = &type__untyped_string;
global Ast_Type *untyped_bool = &type__untyped_bool;
global Ast_Type *untyped_int = &type__untyped_int;
global Ast_Type *untyped_float = &type__untyped_float;
//-----------------------------------------------------------------------------
// Time records
//-----------------------------------------------------------------------------
global F64 generating_time_begin;
global F64 generating_time_end;
global F64 resolving_time_begin;
global F64 resolving_time_end;
global F64 total_time;
global F64 init_ctx_time_begin;
global F64 init_ctx_time_end;