mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-31 06:50:53 -07:00 
			
		
		
		
	impl up to interface.cpp compiles (upfront next)
This commit is contained in:
		| @@ -839,7 +839,7 @@ R"(#define AST_ArrSpecs_Cap \ | |||||||
| 	Code src_static_data 	    = scan_file( project_dir "components/static_data.cpp" ); | 	Code src_static_data 	    = scan_file( project_dir "components/static_data.cpp" ); | ||||||
| 	Code src_ast_case_macros    = scan_file( project_dir "components/ast_case_macros.cpp" ); | 	Code src_ast_case_macros    = scan_file( project_dir "components/ast_case_macros.cpp" ); | ||||||
| 	Code src_ast                = scan_file( project_dir "components/ast.cpp" ); | 	Code src_ast                = scan_file( project_dir "components/ast.cpp" ); | ||||||
| 	Code src_code              = scan_file( project_dir "components/code_serialization.cpp" ); | 	Code src_code_serialization = scan_file( project_dir "components/code_serialization.cpp" ); | ||||||
| 	Code src_interface          = scan_file( project_dir "components/interface.cpp" ); | 	Code src_interface          = scan_file( project_dir "components/interface.cpp" ); | ||||||
| 	Code src_upfront            = scan_file( project_dir "components/interface.upfront.cpp" ); | 	Code src_upfront            = scan_file( project_dir "components/interface.upfront.cpp" ); | ||||||
| 	Code src_lexer              = scan_file( project_dir "components/lexer.cpp" ); | 	Code src_lexer              = scan_file( project_dir "components/lexer.cpp" ); | ||||||
| @@ -986,11 +986,11 @@ R"(#define AST_ArrSpecs_Cap \ | |||||||
| 		header.print_fmt( "#pragma region AST\n\n" ); | 		header.print_fmt( "#pragma region AST\n\n" ); | ||||||
| 		header.print( src_ast_case_macros ); | 		header.print( src_ast_case_macros ); | ||||||
| 		header.print( src_ast ); | 		header.print( src_ast ); | ||||||
| 		// header.print( src_code ); | 		header.print( src_code_serialization ); | ||||||
| 		header.print_fmt( "#pragma endregion AST\n\n" ); | 		header.print_fmt( "#pragma endregion AST\n\n" ); | ||||||
|  |  | ||||||
| 		// header.print_fmt( "#pragma region Interface\n" ); | 		 header.print_fmt( "#pragma region Interface\n" ); | ||||||
| 		// header.print( src_interface ); | 		 header.print( src_interface ); | ||||||
| 		// header.print( src_upfront ); | 		// header.print( src_upfront ); | ||||||
| 		// header.print_fmt( "\n#pragma region Parsing\n\n" ); | 		// header.print_fmt( "\n#pragma region Parsing\n\n" ); | ||||||
| 		// header.print( format_code_to_untyped(parser_nspace) ); | 		// header.print( format_code_to_untyped(parser_nspace) ); | ||||||
| @@ -999,7 +999,7 @@ R"(#define AST_ArrSpecs_Cap \ | |||||||
| 		// header.print( parsing_interface ); | 		// header.print( parsing_interface ); | ||||||
| 		// header.print_fmt( "\n#pragma endregion Parsing\n" ); | 		// header.print_fmt( "\n#pragma endregion Parsing\n" ); | ||||||
| 		// header.print( untyped ); | 		// header.print( untyped ); | ||||||
| 		// header.print_fmt( "\n#pragma endregion Interface\n\n"); | 		 header.print_fmt( "\n#pragma endregion Interface\n\n"); | ||||||
|  |  | ||||||
| 		// header.print_fmt( "#pragma region Builder\n" ); | 		// header.print_fmt( "#pragma region Builder\n" ); | ||||||
| 		// header.print( scan_file( project_dir "auxillary/builder.cpp"  ) ); | 		// header.print( scan_file( project_dir "auxillary/builder.cpp"  ) ); | ||||||
|   | |||||||
| @@ -107,7 +107,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name ) | |||||||
| 		HT_FindResult <fn>__find     ( <tbl_type>  self, u64 key ); | 		HT_FindResult <fn>__find     ( <tbl_type>  self, u64 key ); | ||||||
| 		b32           <fn>__full     ( <tbl_type>  self ); | 		b32           <fn>__full     ( <tbl_type>  self ); | ||||||
|  |  | ||||||
| 		<tbl_type> <fn>init( AllocatorInfo allocator ) | 		<tbl_type> <fn>_init( AllocatorInfo allocator ) | ||||||
| 		{ | 		{ | ||||||
| 			<tbl_type> result = hashtable_init_reserve(<type>, allocator, 8); | 			<tbl_type> result = hashtable_init_reserve(<type>, allocator, 8); | ||||||
| 			return result; | 			return result; | ||||||
| @@ -379,7 +379,7 @@ CodeBody gen_hashtable( StrC type, StrC hashtable_name ) | |||||||
| R"(#define GENERIC_SLOT_<slot>__hashtable_init          <type>,      <tbl_type>_init | R"(#define GENERIC_SLOT_<slot>__hashtable_init          <type>,      <tbl_type>_init | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_init_reserve     <type>,      <tbl_type>_init_reserve | #define GENERIC_SLOT_<slot>__hashtable_init_reserve     <type>,      <tbl_type>_init_reserve | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_clear            <tbl_type>,  <tbl_type>_clear | #define GENERIC_SLOT_<slot>__hashtable_clear            <tbl_type>,  <tbl_type>_clear | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_destroy          <tbl_type>*, <tbl_type>_destroy | #define GENERIC_SLOT_<slot>__hashtable_destroy          <tbl_type>,  <tbl_type>_destroy | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_get              <tbl_type>,  <tbl_type>_get | #define GENERIC_SLOT_<slot>__hashtable_get              <tbl_type>,  <tbl_type>_get | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_map              <tbl_type>,  <tbl_type>_map | #define GENERIC_SLOT_<slot>__hashtable_map              <tbl_type>,  <tbl_type>_map | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_map_mut          <tbl_type>,  <tbl_type>_map_mut | #define GENERIC_SLOT_<slot>__hashtable_map_mut          <tbl_type>,  <tbl_type>_map_mut | ||||||
| @@ -387,7 +387,7 @@ R"(#define GENERIC_SLOT_<slot>__hashtable_init          <type>,      <tbl_type>_ | |||||||
| #define GENERIC_SLOT_<slot>__hashtable_rehash           <tbl_type>*, <tbl_type>_rehash | #define GENERIC_SLOT_<slot>__hashtable_rehash           <tbl_type>*, <tbl_type>_rehash | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_rehash_fast      <tbl_type>,  <tbl_type>_rehash_fast | #define GENERIC_SLOT_<slot>__hashtable_rehash_fast      <tbl_type>,  <tbl_type>_rehash_fast | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_remove_entry     <tbl_type>,  <tbl_type>_remove_entry | #define GENERIC_SLOT_<slot>__hashtable_remove_entry     <tbl_type>,  <tbl_type>_remove_entry | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_set              <tbl_type>*, <tbl_type>_set | #define GENERIC_SLOT_<slot>__hashtable_set              <tbl_type>,  <tbl_type>_set | ||||||
| #define GENERIC_SLOT_<slot>__hashtable_slot             <tbl_type>,  <tbl_type>_slot | #define GENERIC_SLOT_<slot>__hashtable_slot             <tbl_type>,  <tbl_type>_slot | ||||||
|  |  | ||||||
| #define GENERIC_SLOT_<slot>__hashtable__add_entry       <tbl_type>*, <tbl_type>__add_entry | #define GENERIC_SLOT_<slot>__hashtable__add_entry       <tbl_type>*, <tbl_type>__add_entry | ||||||
|   | |||||||
| @@ -3,13 +3,15 @@ | |||||||
| #include "ast.cpp" | #include "ast.cpp" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| forceinline | inline | ||||||
| String attributes_to_string(CodeAttributes attributes) { | String attributes_to_string(CodeAttributes attributes) { | ||||||
| 	GEN_ASSERT(attributes); | 	GEN_ASSERT(attributes); | ||||||
| 	return {(char*) strc_duplicate( attributes->Content, GlobalAllocator ).Ptr}; | 	char* raw = ccast(char*, strc_duplicate( attributes->Content, GlobalAllocator ).Ptr); | ||||||
|  | 	String result = { raw }; | ||||||
|  | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| forceinline | inline | ||||||
| void attributes_to_string_ref(CodeAttributes attributes, String* result) { | void attributes_to_string_ref(CodeAttributes attributes, String* result) { | ||||||
| 	GEN_ASSERT(attributes); | 	GEN_ASSERT(attributes); | ||||||
| 	GEN_ASSERT(result); | 	GEN_ASSERT(result); | ||||||
| @@ -77,13 +79,15 @@ void body_to_string_export( CodeBody body, String* result ) | |||||||
| 	string_append_fmt( result, "};\n" ); | 	string_append_fmt( result, "};\n" ); | ||||||
| } | } | ||||||
|  |  | ||||||
| forceinline | inline | ||||||
| String comment_to_string(CodeComment comment) { | String comment_to_string(CodeComment comment) { | ||||||
| 	GEN_ASSERT(comment); | 	GEN_ASSERT(comment); | ||||||
| 	return {(char*) strc_duplicate( comment->Content, GlobalAllocator ).Ptr}; | 	char* raw = ccast(char*, strc_duplicate( comment->Content, GlobalAllocator ).Ptr); | ||||||
|  | 	String result = { raw }; | ||||||
|  | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| forceinline | inline | ||||||
| void comment_to_string_ref(CodeComment comment, String* result) { | void comment_to_string_ref(CodeComment comment, String* result) { | ||||||
| 	GEN_ASSERT(comment); | 	GEN_ASSERT(comment); | ||||||
| 	GEN_ASSERT(result); | 	GEN_ASSERT(result); | ||||||
| @@ -184,9 +188,8 @@ void class_to_string_def( CodeClass self, String* result ) | |||||||
|  |  | ||||||
| 	if ( self->ParentType ) | 	if ( self->ParentType ) | ||||||
| 	{ | 	{ | ||||||
| 		char const* access_level = access_spec_to_str( self->ParentAccess ); | 		StrC access_level = access_spec_to_str( self->ParentAccess ); | ||||||
|  | 		string_append_fmt( result, "%SC : %SC %S", self->Name, access_level, typename_to_string(self->ParentType) ); | ||||||
| 		string_append_fmt( result, "%SC : %s %S", self->Name, access_level, typename_to_string(self->ParentType) ); |  | ||||||
|  |  | ||||||
| 		CodeTypename interface = cast(CodeTypename, self->ParentType->Next); | 		CodeTypename interface = cast(CodeTypename, self->ParentType->Next); | ||||||
| 		if ( interface ) | 		if ( interface ) | ||||||
| @@ -195,10 +198,10 @@ void class_to_string_def( CodeClass self, String* result ) | |||||||
| 		while ( interface ) | 		while ( interface ) | ||||||
| 		{ | 		{ | ||||||
| 			string_append_fmt( result, ", %S", typename_to_string(interface) ); | 			string_append_fmt( result, ", %S", typename_to_string(interface) ); | ||||||
| 			interface = interface->Next ? cast(CodeTypename, interface->Next) : CodeTypename { nullptr }; | 			interface = interface->Next ? cast(CodeTypename, interface->Next) : NullCode; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else if ( self->Name ) | 	else if ( self->Name.Len ) | ||||||
| 	{ | 	{ | ||||||
| 		string_append_strc( result, self->Name ); | 		string_append_strc( result, self->Name ); | ||||||
| 	} | 	} | ||||||
| @@ -263,7 +266,7 @@ String destructor_to_string(CodeDestructor self) | |||||||
|  |  | ||||||
| void destructor_to_string_def(CodeDestructor self, String* result ) | void destructor_to_string_def(CodeDestructor self, String* result ) | ||||||
| { | { | ||||||
| 	if ( self->Name ) | 	if ( self->Name.Len ) | ||||||
| 	{ | 	{ | ||||||
| 		string_append_fmt( result, "%SC()", self->Name ); | 		string_append_fmt( result, "%SC()", self->Name ); | ||||||
| 	} | 	} | ||||||
| @@ -439,7 +442,10 @@ void enum_to_string_class_fwd(CodeEnum self, String* result ) | |||||||
|  |  | ||||||
| String exec_to_string(CodeExec exec) | String exec_to_string(CodeExec exec) | ||||||
| { | { | ||||||
| 	return {(char*) strc_duplicate( exec->Content, GlobalAllocator ).Ptr}; | 	GEN_ASSERT(exec); | ||||||
|  | 	char* raw = ccast(char*, strc_duplicate( exec->Content, GlobalAllocator ).Ptr); | ||||||
|  | 	String result = { raw }; | ||||||
|  | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| void extern_to_string(CodeExtern self, String* result ) | void extern_to_string(CodeExtern self, String* result ) | ||||||
| @@ -622,10 +628,10 @@ String module_to_string(CodeModule self) | |||||||
|  |  | ||||||
| void module_to_string_ref(CodeModule self, String* result ) | void module_to_string_ref(CodeModule self, String* result ) | ||||||
| { | { | ||||||
| 	if (((u32(ModuleFlag_Export) & u32(self->ModuleFlags)) == u32(ModuleFlag_Export))) | 	if (((scast(u32, ModuleFlag_Export) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Export))) | ||||||
| 		string_append_strc( result, txt("export ")); | 		string_append_strc( result, txt("export ")); | ||||||
|  |  | ||||||
| 	if (((u32(ModuleFlag_Import) & u32(self->ModuleFlags)) == u32(ModuleFlag_Import))) | 	if (((scast(u32, ModuleFlag_Import) & scast(u32, self->ModuleFlags)) == scast(u32, ModuleFlag_Import))) | ||||||
| 		string_append_strc( result, txt("import ")); | 		string_append_strc( result, txt("import ")); | ||||||
|  |  | ||||||
| 	string_append_fmt( result, "%SC;\n", self->Name ); | 	string_append_fmt( result, "%SC;\n", self->Name ); | ||||||
| @@ -796,7 +802,7 @@ void opcast_to_string_def(CodeOpCast self, String* result ) | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ( self->Name && self->Name.Len ) | 		if ( self->Name.Ptr && self->Name.Len ) | ||||||
| 			string_append_fmt( result, "%SC operator %S()", self->Name, typename_to_string(self->ValueType) ); | 			string_append_fmt( result, "%SC operator %S()", self->Name, typename_to_string(self->ValueType) ); | ||||||
| 		else | 		else | ||||||
| 			string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) ); | 			string_append_fmt( result, "operator %S()", typename_to_string(self->ValueType) ); | ||||||
| @@ -814,7 +820,7 @@ void opcast_to_string_def(CodeOpCast self, String* result ) | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->Name && self->Name.Len ) | 	if ( self->Name.Ptr && self->Name.Len ) | ||||||
| 		string_append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, typename_to_string(self->ValueType), body_to_string(self->Body) ); | 		string_append_fmt( result, "%SC operator %S()\n{\n%S\n}\n", self->Name, typename_to_string(self->ValueType), body_to_string(self->Body) ); | ||||||
| 	else | 	else | ||||||
| 		string_append_fmt( result, "operator %S()\n{\n%S\n}\n", typename_to_string(self->ValueType), body_to_string(self->Body) ); | 		string_append_fmt( result, "operator %S()\n{\n%S\n}\n", typename_to_string(self->ValueType), body_to_string(self->Body) ); | ||||||
| @@ -877,7 +883,7 @@ void params_to_string_ref( CodeParam self, String* result ) | |||||||
| 		// Could also be: ( <macro> <type <name>, ... ) | 		// Could also be: ( <macro> <type <name>, ... ) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if ( self->Name ) | 	if ( self->Name.Ptr && self->Name.Len ) | ||||||
| 	{ | 	{ | ||||||
| 		if ( self->ValueType == nullptr ) | 		if ( self->ValueType == nullptr ) | ||||||
| 			string_append_fmt( result, " %SC", self->Name ); | 			string_append_fmt( result, " %SC", self->Name ); | ||||||
| @@ -1036,9 +1042,9 @@ void struct_to_string_def( CodeStruct self, String* result ) | |||||||
|  |  | ||||||
| 	if ( self->ParentType ) | 	if ( self->ParentType ) | ||||||
| 	{ | 	{ | ||||||
| 		char const* access_level = access_spec_to_str( self->ParentAccess ); | 		StrC access_level = access_spec_to_str( self->ParentAccess ); | ||||||
|  |  | ||||||
| 		string_append_fmt( result, "%SC : %s %S", self->Name, access_level, typename_to_string(self->ParentType) ); | 		string_append_fmt( result, "%SC : %SC %S", self->Name, access_level, typename_to_string(self->ParentType) ); | ||||||
|  |  | ||||||
| 		CodeTypename interface = cast(CodeTypename, self->ParentType->Next); | 		CodeTypename interface = cast(CodeTypename, self->ParentType->Next); | ||||||
| 		if ( interface ) | 		if ( interface ) | ||||||
| @@ -1047,10 +1053,10 @@ void struct_to_string_def( CodeStruct self, String* result ) | |||||||
| 		while ( interface ) | 		while ( interface ) | ||||||
| 		{ | 		{ | ||||||
| 			string_append_fmt( result, ", %S", typename_to_string(interface) ); | 			string_append_fmt( result, ", %S", typename_to_string(interface) ); | ||||||
| 			interface = interface->Next ? cast( CodeTypename, interface->Next) : CodeTypename { nullptr }; | 			interface = interface->Next ? cast( CodeTypename, interface->Next) : NullCode; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else if ( self->Name ) | 	else if ( self->Name.Len ) | ||||||
| 	{ | 	{ | ||||||
| 		string_append_strc( result, self->Name ); | 		string_append_strc( result, self->Name ); | ||||||
| 	} | 	} | ||||||
| @@ -1238,7 +1244,7 @@ void union_to_string_def(CodeUnion self, String* result ) | |||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); | 		string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Name ) | 	if ( self->Name.Len ) | ||||||
| 	{ | 	{ | ||||||
| 		string_append_fmt( result, "%SC\n{\n%S\n}" | 		string_append_fmt( result, "%SC\n{\n%S\n}" | ||||||
| 			, self->Name | 			, self->Name | ||||||
| @@ -1269,7 +1275,7 @@ void union_to_string_fwd(CodeUnion self, String* result ) | |||||||
| 	if ( self->Attributes ) | 	if ( self->Attributes ) | ||||||
| 		string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); | 		string_append_fmt( result, "%S ", attributes_to_string(self->Attributes) ); | ||||||
|  |  | ||||||
| 	if ( self->Name ) | 	if ( self->Name.Len ) | ||||||
| 	{ | 	{ | ||||||
| 		string_append_fmt( result, "%SC", self->Name); | 		string_append_fmt( result, "%SC", self->Name); | ||||||
| 	} | 	} | ||||||
| @@ -1331,7 +1337,7 @@ void using_to_string_ref(CodeUsing self, String* result ) | |||||||
| 		string_append_strc( result, txt("\n")); | 		string_append_strc( result, txt("\n")); | ||||||
| } | } | ||||||
|  |  | ||||||
| forceinline | inline | ||||||
| void using_to_string_ns(CodeUsing self, String* result ) | void using_to_string_ns(CodeUsing self, String* result ) | ||||||
| { | { | ||||||
| 	GEN_ASSERT(self); | 	GEN_ASSERT(self); | ||||||
| @@ -1342,7 +1348,7 @@ void using_to_string_ns(CodeUsing self, String* result ) | |||||||
| 		string_append_fmt( result, "using namespace %SC;\n", self->Name ); | 		string_append_fmt( result, "using namespace %SC;\n", self->Name ); | ||||||
| } | } | ||||||
|  |  | ||||||
| forceinline | inline | ||||||
| String var_to_string(CodeVar self) | String var_to_string(CodeVar self) | ||||||
| { | { | ||||||
| 	GEN_ASSERT(self); | 	GEN_ASSERT(self); | ||||||
|   | |||||||
| @@ -101,10 +101,12 @@ void define_constants() | |||||||
| 	access_public->Name = get_cached_string( txt("public:\n") ); | 	access_public->Name = get_cached_string( txt("public:\n") ); | ||||||
| 	code_set_global(access_public); | 	code_set_global(access_public); | ||||||
|  |  | ||||||
| 	attrib_api_export = def_attributes( code(GEN_API_Export_Code)); | 	StrC api_export_str = code(GEN_API_Export_Code); | ||||||
|  | 	attrib_api_export = def_attributes( api_export_str ); | ||||||
| 	code_set_global(cast(Code, attrib_api_export)); | 	code_set_global(cast(Code, attrib_api_export)); | ||||||
|  |  | ||||||
| 	attrib_api_import = def_attributes( code(GEN_API_Import_Code)); | 	StrC api_import_str = code(GEN_API_Import_Code); | ||||||
|  | 	attrib_api_import = def_attributes( api_import_str ); | ||||||
| 	code_set_global(cast(Code, attrib_api_import)); | 	code_set_global(cast(Code, attrib_api_import)); | ||||||
|  |  | ||||||
| 	module_global_fragment          = make_code(); | 	module_global_fragment          = make_code(); | ||||||
| @@ -144,8 +146,13 @@ void define_constants() | |||||||
| 	code_set_global((Code)preprocess_endif); | 	code_set_global((Code)preprocess_endif); | ||||||
|  |  | ||||||
| #	define def_constant_code_type( Type_ )           \ | #	define def_constant_code_type( Type_ )           \ | ||||||
| 		t_##Type_ = def_type( name(Type_) ); \ | 		do                                           \ | ||||||
| 		code_set_global( cast(Code, t_##Type_)); | 		{                                            \ | ||||||
|  | 		    Opts_def_type ops = {};                  \ | ||||||
|  | 			StrC name_str = name(Type_);             \ | ||||||
|  | 			t_##Type_ = def_type( name_str, ops );   \ | ||||||
|  | 			code_set_global( cast(Code, t_##Type_)); \ | ||||||
|  | 		} while(0) | ||||||
|  |  | ||||||
| 	def_constant_code_type( auto ); | 	def_constant_code_type( auto ); | ||||||
| 	def_constant_code_type( void ); | 	def_constant_code_type( void ); | ||||||
| @@ -237,9 +244,10 @@ void init() | |||||||
| { | { | ||||||
| 	// Setup global allocator | 	// Setup global allocator | ||||||
| 	{ | 	{ | ||||||
| 		GlobalAllocator = AllocatorInfo { & Global_Allocator_Proc, nullptr }; | 		AllocatorInfo becasue_C = { & Global_Allocator_Proc, nullptr }; | ||||||
|  | 		GlobalAllocator = becasue_C; | ||||||
|  |  | ||||||
| 		Global_AllocatorBuckets = array_init_reserve<Arena>( heap(), 128 ); | 		Global_AllocatorBuckets = array_init_reserve(Arena, heap(), 128 ); | ||||||
|  |  | ||||||
| 		if ( Global_AllocatorBuckets == nullptr ) | 		if ( Global_AllocatorBuckets == nullptr ) | ||||||
| 			GEN_FATAL( "Failed to reserve memory for Global_AllocatorBuckets"); | 			GEN_FATAL( "Failed to reserve memory for Global_AllocatorBuckets"); | ||||||
| @@ -273,12 +281,12 @@ void init() | |||||||
|  |  | ||||||
| 	// Setup the arrays | 	// Setup the arrays | ||||||
| 	{ | 	{ | ||||||
| 		CodePools = array_init_reserve<Pool>( Allocator_DataArrays, InitSize_DataArrays ); | 		CodePools = array_init_reserve(Pool, Allocator_DataArrays, InitSize_DataArrays ); | ||||||
|  |  | ||||||
| 		if ( CodePools == nullptr ) | 		if ( CodePools == nullptr ) | ||||||
| 			GEN_FATAL( "gen::init: Failed to initialize the CodePools array" ); | 			GEN_FATAL( "gen::init: Failed to initialize the CodePools array" ); | ||||||
|  |  | ||||||
| 		StringArenas = array_init_reserve<Arena>( Allocator_DataArrays, InitSize_DataArrays ); | 		StringArenas = array_init_reserve(Arena, Allocator_DataArrays, InitSize_DataArrays ); | ||||||
|  |  | ||||||
| 		if ( StringArenas == nullptr ) | 		if ( StringArenas == nullptr ) | ||||||
| 			GEN_FATAL( "gen::init: Failed to initialize the StringArenas array" ); | 			GEN_FATAL( "gen::init: Failed to initialize the StringArenas array" ); | ||||||
| @@ -305,14 +313,14 @@ void init() | |||||||
|  |  | ||||||
| 	// Setup the hash tables | 	// Setup the hash tables | ||||||
| 	{ | 	{ | ||||||
| 		StringCache = hashtable_init<StringCached>(Allocator_StringTable); | 		StringCache = hashtable_init(StringCached, Allocator_StringTable); | ||||||
|  |  | ||||||
| 		if ( StringCache.Entries == nullptr ) | 		if ( StringCache.Entries == nullptr ) | ||||||
| 			GEN_FATAL( "gen::init: Failed to initialize the StringCache"); | 			GEN_FATAL( "gen::init: Failed to initialize the StringCache"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Preprocessor Defines | 	// Preprocessor Defines | ||||||
| 	PreprocessorDefines = array_init_reserve<StringCached>( GlobalAllocator, kilobytes(1) ); | 	PreprocessorDefines = array_init_reserve(StringCached, GlobalAllocator, kilobytes(1) ); | ||||||
|  |  | ||||||
| 	define_constants(); | 	define_constants(); | ||||||
| 	GEN_NS_PARSER init(); | 	GEN_NS_PARSER init(); | ||||||
| @@ -396,7 +404,7 @@ AllocatorInfo get_string_allocator( s32 str_length ) | |||||||
|  |  | ||||||
| 	usize size_req = str_length + sizeof(StringHeader) + sizeof(char*); | 	usize size_req = str_length + sizeof(StringHeader) + sizeof(char*); | ||||||
|  |  | ||||||
| 	if ( last->TotalUsed + ssize(size_req) > last->TotalSize ) | 	if ( last->TotalUsed + scast(ssize, size_req) > last->TotalSize ) | ||||||
| 	{ | 	{ | ||||||
| 		Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena ); | 		Arena new_arena = arena_init_from_allocator( Allocator_StringArena, SizePer_StringArena ); | ||||||
|  |  | ||||||
| @@ -424,7 +432,7 @@ StringCached get_cached_string( StrC str ) | |||||||
| 	StrC result = string_to_strc( string_make_strc( get_string_allocator( str.Len ), str )); | 	StrC result = string_to_strc( string_make_strc( get_string_allocator( str.Len ), str )); | ||||||
| 	hashtable_set(StringCache, key, result ); | 	hashtable_set(StringCache, key, result ); | ||||||
|  |  | ||||||
| 	return { str.Len, result }; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| // Used internally to retireve a Code object form the CodePool. | // Used internally to retireve a Code object form the CodePool. | ||||||
| @@ -444,20 +452,8 @@ Code make_code() | |||||||
| 		allocator = array_back( CodePools); | 		allocator = array_back( CodePools); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	Code result { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) }; | 	Code result = { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) }; | ||||||
| 	mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) ); | 	mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) ); | ||||||
| 	// result->Type = ECode::Invalid; |  | ||||||
|  |  | ||||||
| 	// result->Content     = { nullptr }; |  | ||||||
| 	// result->Prev        = { nullptr }; |  | ||||||
| 	// result->Next        = { nullptr }; |  | ||||||
| 	// result->Token		= nullptr; |  | ||||||
| 	// result->Parent      = { nullptr }; |  | ||||||
| 	// result->Name        = { nullptr }; |  | ||||||
| 	// result->Type        = ECode::Invalid; |  | ||||||
| 	// result->ModuleFlags = ModuleFlag::Invalid; |  | ||||||
| 	// result->NumEntries  = 0; |  | ||||||
|  |  | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ | |||||||
|  |  | ||||||
| #ifndef bit | #ifndef bit | ||||||
| #define bit( Value )                             ( 1 << Value ) | #define bit( Value )                             ( 1 << Value ) | ||||||
| #define bitfield_is_equal( Type, Field, Mask ) ( (Type(Mask) & Type(Field)) == Type(Mask) ) | #define bitfield_is_equal( Type, Field, Mask ) ( (scast(Type, Mask) & scast(Type, Field)) == scast(Type, Mask) ) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| // Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion | // Mainly intended for forcing the base library to utilize only C-valid constructs or type coercion | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user