mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
Fixes for test.singleheader_ast.cpp, also added a bench for it.
On a Ryzen R9 5950 it takes 11 ms to generate AST and 21 ms to serialize to file.
This commit is contained in:
parent
a4f9596d3b
commit
c2319b9651
@ -4262,11 +4262,6 @@ CodeUnion parse_union( bool inplace_def )
|
|||||||
if ( currtok.Type == TokType::Preprocess_Hash )
|
if ( currtok.Type == TokType::Preprocess_Hash )
|
||||||
eat( TokType::Preprocess_Hash );
|
eat( TokType::Preprocess_Hash );
|
||||||
|
|
||||||
if ( currtok.Line >= 3826 )
|
|
||||||
{
|
|
||||||
log_fmt("here");
|
|
||||||
}
|
|
||||||
|
|
||||||
Code member = { nullptr };
|
Code member = { nullptr };
|
||||||
switch ( currtok_noskip.Type )
|
switch ( currtok_noskip.Type )
|
||||||
{
|
{
|
||||||
|
@ -1440,7 +1440,7 @@ CodeBody def_enum_body( s32 num, ... )
|
|||||||
|
|
||||||
if ( entry->Type != Untyped && entry->Type != Comment )
|
if ( entry->Type != Untyped && entry->Type != Comment )
|
||||||
{
|
{
|
||||||
log_failure("gen::def_enum_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() ); \
|
log_failure("gen::def_enum_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() );
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1472,7 +1472,7 @@ CodeBody def_enum_body( s32 num, Code* codes )
|
|||||||
|
|
||||||
if ( entry->Type != Untyped && entry->Type != Comment )
|
if ( entry->Type != Untyped && entry->Type != Comment )
|
||||||
{
|
{
|
||||||
log_failure("gen::def_enum_body: Entry type is not allowed: %s", entry.debug_str() ); \
|
log_failure("gen::def_enum_body: Entry type is not allowed: %s", entry.debug_str() );
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1853,7 +1853,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
|
|||||||
switch (entry->Type)
|
switch (entry->Type)
|
||||||
{
|
{
|
||||||
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
|
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES
|
||||||
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str() );
|
log_failure("gen::" "def_namespace_body" ": Entry type is not allowed: %s", entry.debug_str() );
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
@ -2062,7 +2062,7 @@ CodeBody def_struct_body( s32 num, Code* codes )
|
|||||||
switch (entry->Type)
|
switch (entry->Type)
|
||||||
{
|
{
|
||||||
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES
|
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES
|
||||||
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str() );
|
log_failure("gen::" "def_struct_body" ": Entry type is not allowed: %s", entry.debug_str() );
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2099,7 +2099,7 @@ CodeBody def_union_body( s32 num, ... )
|
|||||||
|
|
||||||
if ( entry->Type != Untyped && entry->Type != Comment )
|
if ( entry->Type != Untyped && entry->Type != Comment )
|
||||||
{
|
{
|
||||||
log_failure("gen::def_union_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() ); \
|
log_failure("gen::def_union_body: Entry type is not allowed - %s. Must be of untyped or comment type.", entry.debug_str() );
|
||||||
return CodeInvalid;
|
return CodeInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,30 +13,21 @@ void check_singleheader_ast()
|
|||||||
gen::init();
|
gen::init();
|
||||||
log_fmt("\ncheck_singleheader_ast:\n");
|
log_fmt("\ncheck_singleheader_ast:\n");
|
||||||
|
|
||||||
FileContents file = file_read_contents( GlobalAllocator, true, project_dir "singleheader/gen/gen.hpp" );
|
FileContents file = file_read_contents( GlobalAllocator, true, project_dir "singleheader/gen/gen.hpp" );
|
||||||
|
u64 time_start = time_rel_ms();
|
||||||
|
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
|
||||||
|
|
||||||
CodeBody ast = parse_global_body( { file.size, (char const*)file.data } );
|
log_fmt("\nAst generated. Time taken: %llu ms\n", time_rel_ms() - time_start);
|
||||||
|
|
||||||
log_fmt("generated AST!!!\n");
|
log_fmt("\nSerializng ast:\n");
|
||||||
|
time_start = time_rel_ms();
|
||||||
|
|
||||||
#if 0
|
Builder
|
||||||
s32 idx = 0;
|
builder = Builder::open( "singleheader_copy.gen.hpp" );
|
||||||
for ( Code entry : ast )
|
|
||||||
{
|
|
||||||
if (idx == 900)
|
|
||||||
{
|
|
||||||
log_fmt("break here\n");
|
|
||||||
}
|
|
||||||
log_fmt("Entry %d: %s\n", idx, entry.to_string() );
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Builder builder = Builder::open( "singleheader_copy.gen.hpp" );
|
|
||||||
log_fmt("\n\nserializng ast\n");
|
|
||||||
builder.print( ast );
|
builder.print( ast );
|
||||||
builder.write();
|
builder.write();
|
||||||
|
|
||||||
log_fmt("passed!!\n");
|
log_fmt("passed!! Time taken: %llu ms\n", time_rel_ms() - time_start);
|
||||||
|
|
||||||
gen::deinit();
|
gen::deinit();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user