mirror of
				https://github.com/Ed94/gencpp.git
				synced 2025-10-30 22:40:54 -07:00 
			
		
		
		
	Parsing constructors work, finally reached parity.
This commit is contained in:
		| @@ -2079,6 +2079,9 @@ namespace gen | ||||
|  | ||||
| 			case Friend: | ||||
| 				result.append_fmt( "friend %s", Declaration->to_string() ); | ||||
|  | ||||
| 				if ( result[ result.length() -1 ] != ';' ) | ||||
| 					result.append( ";" ); | ||||
| 			break; | ||||
|  | ||||
| 			case Function: | ||||
| @@ -2221,7 +2224,7 @@ namespace gen | ||||
| 				else | ||||
| 					result.append_fmt( "%s", ValueType->to_string() ); | ||||
|  | ||||
| 				if ( NumEntries - 1) | ||||
| 				if ( NumEntries - 1 > 0) | ||||
| 				{ | ||||
| 					for ( CodeParam param : Next->cast<CodeParam>() ) | ||||
| 					{ | ||||
| @@ -5382,7 +5385,7 @@ namespace gen | ||||
| 	internal CodeType      parse_type             ( Parser::TokArray& toks, char const* context ); | ||||
| 	internal CodeTypedef   parse_typedef          ( Parser::TokArray& toks, char const* context ); | ||||
| 	internal CodeUnion     parse_union            ( Parser::TokArray& toks, char const* context ); | ||||
| 	internal CodeUsing     parse_using            ( Parser::TokArray& toks, char const* context ); | ||||
| 	internal Code          parse_using            ( Parser::TokArray& toks, char const* context ); | ||||
|  | ||||
| 	internal inline | ||||
| 	Code parse_array_decl( Parser::TokArray& toks, char const* context ) | ||||
| @@ -5535,6 +5538,8 @@ namespace gen | ||||
| 		if ( value ) | ||||
| 			result->Value = value; | ||||
|  | ||||
| 		result->NumEntries++; | ||||
|  | ||||
| 		while ( left | ||||
| 			&& use_template_capture ? | ||||
| 					currtok.Type != TokType::Operator && currtok.Text[0] !=  '>' | ||||
| @@ -7490,7 +7495,7 @@ namespace gen | ||||
| 	} | ||||
|  | ||||
| 	internal | ||||
| 	CodeUsing parse_using( Parser::TokArray& toks, char const* context ) | ||||
| 	Code parse_using( Parser::TokArray& toks, char const* context ) | ||||
| 	{ | ||||
| 		using namespace Parser; | ||||
|  | ||||
| @@ -7531,21 +7536,30 @@ namespace gen | ||||
|  | ||||
| 		using namespace ECode; | ||||
|  | ||||
| 		CodeUsing | ||||
| 		result       = (CodeUsing) make_code(); | ||||
| 		result->Type = is_namespace ? Using_Namespace : Using; | ||||
| 		Code | ||||
| 		result       = make_code(); | ||||
| 		result->Name = get_cached_string( name ); | ||||
|  | ||||
| 		if ( type ) | ||||
| 			result->UnderlyingType = type; | ||||
| 		if ( is_namespace) | ||||
| 		{ | ||||
| 			result->Type = Using_Namespace; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			result->Type = Using; | ||||
|  | ||||
| 		if ( array_expr ) | ||||
| 			type->ArrExpr = array_expr; | ||||
| 			CodeUsing using_code = (CodeUsing) result; | ||||
|  | ||||
| 			if ( type ) | ||||
| 				using_code->UnderlyingType = type; | ||||
|  | ||||
| 			if ( array_expr ) | ||||
| 				type->ArrExpr = array_expr; | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
|  | ||||
| 	CodeUsing parse_using( StrC def ) | ||||
| 	Code parse_using( StrC def ) | ||||
| 	{ | ||||
| 		check_parse_args( parse_using, def ); | ||||
| 		using namespace Parser; | ||||
|   | ||||
| @@ -2683,7 +2683,6 @@ namespace gen | ||||
| 		{                                      \ | ||||
| 			return ast != nullptr;             \ | ||||
| 		} | ||||
| 		// operator AST*(); | ||||
|  | ||||
| 		template< class Type > | ||||
| 		Type cast() | ||||
| @@ -2696,6 +2695,10 @@ namespace gen | ||||
| 			return ast; | ||||
| 		} | ||||
| 		Code& operator ++(); | ||||
| 		Code& operator*() | ||||
| 		{ | ||||
| 			return *this; | ||||
| 		} | ||||
|  | ||||
| 		Using_Code( Code ); | ||||
|  | ||||
| @@ -2841,7 +2844,7 @@ namespace gen | ||||
| 		union { | ||||
| 			OperatorT     Op; | ||||
| 			AccessSpec    ParentAccess; | ||||
| 			u32           NumEntries; | ||||
| 			s32           NumEntries; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| @@ -2896,7 +2899,7 @@ namespace gen | ||||
| 		union { | ||||
| 			OperatorT     Op; | ||||
| 			AccessSpec    ParentAccess; | ||||
| 			u32           NumEntries; | ||||
| 			s32           NumEntries; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| @@ -2966,16 +2969,16 @@ namespace gen | ||||
| 			return * rcast( Code*, this ); | ||||
| 		} | ||||
| 	#pragma region Iterator | ||||
| 		Code* begin() | ||||
| 		Code begin() | ||||
| 		{ | ||||
| 			if ( ast ) | ||||
| 				return rcast( Code*, & rcast( AST*, ast)->Front ); | ||||
| 				return { rcast( AST*, ast)->Front }; | ||||
|  | ||||
| 			return nullptr; | ||||
| 			return { nullptr }; | ||||
| 		} | ||||
| 		Code* end() | ||||
| 		Code end() | ||||
| 		{ | ||||
| 			return nullptr; | ||||
| 			return { rcast(AST*, ast)->Back->Next }; | ||||
| 		} | ||||
| 	#pragma endregion Iterator | ||||
|  | ||||
| @@ -3130,7 +3133,8 @@ namespace gen | ||||
| 		Code              Parent; | ||||
| 		StringCached      Name; | ||||
| 		CodeT             Type; | ||||
| 		char              _PAD_UNUSED_[ sizeof(ModuleFlag) + sizeof(u32) ]; | ||||
| 		char              _PAD_UNUSED_[ sizeof(ModuleFlag) ]; | ||||
| 		s32 			  NumEntries; | ||||
| 	}; | ||||
| 	static_assert( sizeof(AST_Body) == sizeof(AST), "ERROR: AST_Filtered is not the same size as AST"); | ||||
|  | ||||
| @@ -3399,7 +3403,7 @@ namespace gen | ||||
| 		StringCached      Name; | ||||
| 		CodeT             Type; | ||||
| 		char 			  _PAD_UNUSED_[ sizeof(ModuleFlag) ]; | ||||
| 		u32               NumEntries; | ||||
| 		s32               NumEntries; | ||||
| 	}; | ||||
| 	static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the same size as AST"); | ||||
|  | ||||
| @@ -3412,7 +3416,7 @@ namespace gen | ||||
| 		StringCached      Name; | ||||
| 		CodeT             Type; | ||||
| 		char 			  _PAD_UNUSED_[ sizeof(ModuleFlag) ]; | ||||
| 		u32               NumEntries; | ||||
| 		s32               NumEntries; | ||||
| 	}; | ||||
| 		static_assert( sizeof(AST_Specifier) == sizeof(AST), "ERROR: AST_Specifier is not the same size as AST"); | ||||
|  | ||||
| @@ -3721,7 +3725,7 @@ namespace gen | ||||
| 	CodeType       parse_type         ( StrC type_def      ); | ||||
| 	CodeTypedef    parse_typedef      ( StrC typedef_def   ); | ||||
| 	CodeUnion      parse_union        ( StrC union_def     ); | ||||
| 	CodeUsing      parse_using        ( StrC using_def     ); | ||||
| 	Code           parse_using        ( StrC using_def     ); | ||||
| 	CodeVar        parse_variable     ( StrC var_def       ); | ||||
| #	endif | ||||
| #	pragma endregion Parsing | ||||
|   | ||||
| @@ -32,7 +32,7 @@ Code gen__array( StrC type ) | ||||
| 		name = { name_len, name_str }; | ||||
| 	}; | ||||
|  | ||||
| 	Code array = parse_struct( token_fmt( "ArrayType", name, "type", type, | ||||
| 	CodeStruct array = parse_struct( token_fmt( "ArrayType", name, "type", type, | ||||
| 		stringize( | ||||
| 			struct <ArrayType> | ||||
| 			{ | ||||
| @@ -108,7 +108,7 @@ Code gen__array( StrC type ) | ||||
| 				void free( void ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
| 					zpl::free( header.Allocator, &header ); | ||||
| 					gen::free( header.Allocator, &header ); | ||||
| 				} | ||||
|  | ||||
| 				Header& get_header( void ) | ||||
| @@ -136,14 +136,14 @@ Code gen__array( StrC type ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
|  | ||||
| 					ZPL_ASSERT( header.Num > 0 ); | ||||
| 					GEN_ASSERT( header.Num > 0 ); | ||||
| 					header.Num--; | ||||
| 				} | ||||
|  | ||||
| 				void remove_at( uw idx ) | ||||
| 				{ | ||||
| 					Header* header = &get_header(); | ||||
| 					ZPL_ASSERT( idx < header->Num ); | ||||
| 					GEN_ASSERT( idx < header->Num ); | ||||
|  | ||||
| 					mem_move( header + idx, header + idx + 1, sizeof( Type ) * ( header->Num - idx - 1 ) ); | ||||
| 					header->Num--; | ||||
| @@ -195,7 +195,7 @@ Code gen__array( StrC type ) | ||||
| 					new_header->Num       = header.Num; | ||||
| 					new_header->Capacity  = new_capacity; | ||||
|  | ||||
| 					zpl::free( header.Allocator, &header ); | ||||
| 					gen::free( header.Allocator, &header ); | ||||
|  | ||||
| 					Data = ( Type* )new_header + 1; | ||||
| 					return true; | ||||
| @@ -251,8 +251,8 @@ u32 gen_array_file() | ||||
| 	gen_array_file; | ||||
| 	gen_array_file.open( "array.Parsed.gen.hpp" ); | ||||
|  | ||||
| 	Code include_zpl = def_include( txt_StrC("gen.hpp") ); | ||||
| 	gen_array_file.print( include_zpl ); | ||||
| 	Code include_gen = def_include( txt_StrC("gen.hpp") ); | ||||
| 	gen_array_file.print( include_gen ); | ||||
|  | ||||
| 	gen_array_file.print( def_using_namespace( name(gen))); | ||||
|  | ||||
|   | ||||
| @@ -75,7 +75,7 @@ Code gen__buffer( StrC type ) | ||||
| 				void append( Type* values, sw num ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
| 					ZPL_ASSERT( header.Num + num <= header.Capacity); | ||||
| 					GEN_ASSERT( header.Num + num <= header.Capacity); | ||||
|  | ||||
| 					mem_copy( Data + header.Num, values, num * sizeof( Type ) ); | ||||
| 					header.Num += num; | ||||
| @@ -96,7 +96,7 @@ Code gen__buffer( StrC type ) | ||||
| 				void free( void ) | ||||
| 				{ | ||||
| 					Header& header = get_header(); | ||||
| 					zpl::free( header.Backing, &header ); | ||||
| 					gen::free( header.Backing, &header ); | ||||
| 				} | ||||
|  | ||||
| 				Header& get_header( void ) | ||||
|   | ||||
| @@ -99,7 +99,7 @@ Code gen__hashtable( StrC type ) | ||||
|  | ||||
| 				void map( MapProc map_proc ) | ||||
| 				{ | ||||
| 					ZPL_ASSERT_NOT_NULL( map_proc ); | ||||
| 					GEN_ASSERT_NOT_NULL( map_proc ); | ||||
|  | ||||
| 					for ( sw idx = 0; idx < Entries.num(); idx++ ) | ||||
| 					{ | ||||
| @@ -109,7 +109,7 @@ Code gen__hashtable( StrC type ) | ||||
|  | ||||
| 				void map_mut( MapMutProc map_proc ) | ||||
| 				{ | ||||
| 					ZPL_ASSERT_NOT_NULL( map_proc ); | ||||
| 					GEN_ASSERT_NOT_NULL( map_proc ); | ||||
|  | ||||
| 					for ( sw idx = 0; idx < Entries.num(); idx++ ) | ||||
| 					{ | ||||
|   | ||||
| @@ -16,7 +16,7 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Typedef | ||||
| 	{ | ||||
| 		Code u8_typedef = parse_typedef( code( | ||||
| 		CodeTypedef u8_typedef = parse_typedef( code( | ||||
| 			typedef unsigned char u8; | ||||
| 		)); | ||||
|  | ||||
| @@ -46,11 +46,11 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Enum | ||||
| 	{ | ||||
| 		Code fwd = parse_enum( code( | ||||
| 		CodeEnum fwd = parse_enum( code( | ||||
| 			enum ETestEnum : u8; | ||||
| 		)); | ||||
|  | ||||
| 		Code def = parse_enum( code( | ||||
| 		CodeEnum def = parse_enum( code( | ||||
| 			enum ETestEnum : u8 | ||||
| 			{ | ||||
| 				A, | ||||
| @@ -59,7 +59,7 @@ u32 gen_sanity() | ||||
| 			}; | ||||
| 		)); | ||||
|  | ||||
| 		Code fwd_enum_class = parse_enum( code( | ||||
| 		CodeEnum fwd_enum_class = parse_enum( code( | ||||
| 			enum class ETestEnumClass : u8; | ||||
| 		)); | ||||
|  | ||||
| @@ -89,11 +89,11 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Friend | ||||
| 	{ | ||||
| 		Code fwd = parse_class( code( | ||||
| 		CodeClass fwd = parse_class( code( | ||||
| 			class TestFriendClass; | ||||
| 		)); | ||||
|  | ||||
| 		Code def = parse_class( code( | ||||
| 		CodeClass def = parse_class( code( | ||||
| 			class TestFriend | ||||
| 			{ | ||||
| 				friend class TestFriendClass; | ||||
| @@ -143,7 +143,7 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Operator | ||||
| 	{ | ||||
| 		Code bitflagtest = parse_enum( code( | ||||
| 		CodeEnum bitflagtest = parse_enum( code( | ||||
| 			enum class EBitFlagTest : u8 | ||||
| 			{ | ||||
| 				A = 1 << 0, | ||||
| @@ -152,11 +152,11 @@ u32 gen_sanity() | ||||
| 			}; | ||||
| 		)); | ||||
|  | ||||
| 		Code op_fwd = parse_operator( code( | ||||
| 		CodeOperator op_fwd = parse_operator( code( | ||||
| 			EBitFlagTest operator | ( EBitFlagTest a, EBitFlagTest b ); | ||||
| 		)); | ||||
|  | ||||
| 		Code op_or = parse_operator( code( | ||||
| 		CodeOperator op_or = parse_operator( code( | ||||
| 			EBitFlagTest operator | ( EBitFlagTest a, EBitFlagTest b ) | ||||
| 			{ | ||||
| 				return EBitFlagTest( (u8)a | (u8)b ); | ||||
| @@ -211,12 +211,12 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Specifiers | ||||
| 	{ | ||||
| 		Code fwd_fn = parse_function( code( | ||||
| 		CodeFn fwd_fn = parse_function( code( | ||||
| 			inline | ||||
| 			void test_function_specifiers(); | ||||
| 		)); | ||||
|  | ||||
| 		Code typedef_u8_ptr = parse_typedef( code( | ||||
| 		CodeTypedef typedef_u8_ptr = parse_typedef( code( | ||||
| 			typedef u8* u8_ptr; | ||||
| 		)); | ||||
|  | ||||
| @@ -258,7 +258,7 @@ u32 gen_sanity() | ||||
| 		gen_sanity_file.print( parse_typedef( code( typedef unsigned short u16; )) ); | ||||
| 		gen_sanity_file.print( parse_typedef( code( typedef unsigned long  u32; )) ); | ||||
|  | ||||
| 		Code def = parse_union( code( | ||||
| 		CodeUnion def = parse_union( code( | ||||
| 			union TestUnion | ||||
| 			{ | ||||
| 				u8  a; | ||||
| @@ -275,18 +275,18 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Using | ||||
| 	{ | ||||
| 		Code reg = parse_using( code( | ||||
| 		CodeUsing reg = (CodeUsing) parse_using( code( | ||||
| 			using TestUsing = u8; | ||||
| 		)); | ||||
|  | ||||
| 		Code nspace = parse_namespace( code( | ||||
| 		CodeNamespace nspace = parse_namespace( code( | ||||
| 			namespace TestNamespace | ||||
| 			{ | ||||
| 			}; | ||||
|  | ||||
| 		)); | ||||
|  | ||||
| 		Code npspace_using = parse_using( code( | ||||
| 		CodeUsingNamespace npspace_using = (CodeUsingNamespace) parse_using( code( | ||||
| 			using namespace TestNamespace; | ||||
| 		)); | ||||
|  | ||||
| @@ -299,11 +299,11 @@ u32 gen_sanity() | ||||
|  | ||||
| 	// Variable | ||||
| 	{ | ||||
| 		Code bss = parse_variable( code( | ||||
| 		CodeVar bss = parse_variable( code( | ||||
| 			u8 test_variable; | ||||
| 		)); | ||||
|  | ||||
| 		Code data = parse_variable( code( | ||||
| 		CodeVar data = parse_variable( code( | ||||
| 			u8 test_variable = 0x12; | ||||
| 		)); | ||||
|  | ||||
| @@ -317,7 +317,7 @@ u32 gen_sanity() | ||||
| 	{ | ||||
| 	#pragma push_macro("template") | ||||
| 	#undef template | ||||
| 		Code tmpl = parse_template( code( | ||||
| 		CodeTemplate tmpl = parse_template( code( | ||||
| 			template< typename Type > | ||||
| 			void test_template( Type a ) | ||||
| 			{ | ||||
|   | ||||
| @@ -24,7 +24,7 @@ Code gen_SOA( CodeStruct struct_def, s32 num_entries = 0 ) | ||||
|  | ||||
| 	Array<CodeVar> vars = Array<CodeVar>::init( var_arena );; | ||||
|  | ||||
| 	CodeStruct soa = def_struct( name, def_body( ECode::Struct_Body )); | ||||
| 	CodeStruct soa = def_struct( name, def_struct_body( args( soa_entry ) )); | ||||
| 	{ | ||||
| 		for ( Code struct_mem : struct_def->Body ) | ||||
| 		{ | ||||
|   | ||||
| @@ -11,7 +11,7 @@ includes = include_directories( | ||||
| # get_sources = files('./get_sources.ps1') | ||||
| # sources     = files(run_command('powershell', get_sources, check: true).stdout().strip().split('\n')) | ||||
|  | ||||
| sources = [ '../test.Upfront.cpp' ] | ||||
| sources = [ '../test.cpp' ] | ||||
|  | ||||
| if get_option('buildtype').startswith('debug') | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| #ifdef gen_time | ||||
| #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS | ||||
| #define GEN_FEATURE_PARSING | ||||
| #include "Upfront\Sanity.Upfront.hpp" | ||||
| #include "Parsed\Array.Parsed.hpp" | ||||
| #include "Parsed\Buffer.Parsed.hpp" | ||||
| #include "Parsed\HashTable.Parsed.hpp" | ||||
| @@ -42,7 +41,7 @@ int gen_main() | ||||
| 		using u16 = unsigned short; | ||||
| 	))); | ||||
|  | ||||
| 	soa_test.print( def_include( txt_StrC("Bloat.hpp"))); | ||||
| 	soa_test.print( def_include( txt_StrC("gen.hpp"))); | ||||
|  | ||||
| 	soa_test.print( def_using_namespace( name(gen) ) ); | ||||
|  | ||||
| @@ -55,8 +54,7 @@ int gen_main() | ||||
| 				u32 C; | ||||
| 				u64 D; | ||||
| 			}; | ||||
| 		)), | ||||
| 		128 | ||||
| 		)) | ||||
| 	)); | ||||
|  | ||||
| 	soa_test.write(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user