mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 11:11:46 -07:00
Compare commits
5 Commits
broken_cha
...
v0.14-Alph
Author | SHA1 | Date | |
---|---|---|---|
6498b13658 | |||
7f562cd77f | |||
3a0e971ebf | |||
4997cb5878 | |||
729c891cbd |
@ -690,13 +690,25 @@ String AST::to_string()
|
|||||||
case Function:
|
case Function:
|
||||||
{
|
{
|
||||||
if ( bitfield_is_equal( u32, ModuleFlags, ModuleFlag::Export ))
|
if ( bitfield_is_equal( u32, ModuleFlags, ModuleFlag::Export ))
|
||||||
result.append( "export " );
|
result.append( "export" );
|
||||||
|
|
||||||
if ( Attributes )
|
if ( Attributes )
|
||||||
result.append_fmt( "%S ", Attributes->to_string() );
|
result.append_fmt( " %S ", Attributes->to_string() );
|
||||||
|
|
||||||
if ( Specs )
|
if ( Specs )
|
||||||
result.append_fmt( "%S", Specs->to_string() );
|
{
|
||||||
|
for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() )
|
||||||
|
{
|
||||||
|
if ( ! ESpecifier::is_trailing( spec ) )
|
||||||
|
{
|
||||||
|
StrC spec_str = ESpecifier::to_str( spec );
|
||||||
|
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Attributes || Specs )
|
||||||
|
result.append( "\n" );
|
||||||
|
|
||||||
if ( ReturnType )
|
if ( ReturnType )
|
||||||
result.append_fmt( "%S %S(", ReturnType->to_string(), Name );
|
result.append_fmt( "%S %S(", ReturnType->to_string(), Name );
|
||||||
@ -735,7 +747,21 @@ String AST::to_string()
|
|||||||
result.append_fmt( "%S ", Attributes->to_string() );
|
result.append_fmt( "%S ", Attributes->to_string() );
|
||||||
|
|
||||||
if ( Specs )
|
if ( Specs )
|
||||||
result.append_fmt( "%S", Specs->to_string() );
|
{
|
||||||
|
for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() )
|
||||||
|
{
|
||||||
|
if ( ! ESpecifier::is_trailing( spec ) )
|
||||||
|
{
|
||||||
|
StrC spec_str = ESpecifier::to_str( spec );
|
||||||
|
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Attributes || Specs )
|
||||||
|
{
|
||||||
|
result.append("\n" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ReturnType )
|
if ( ReturnType )
|
||||||
result.append_fmt( "%S %S(", ReturnType->to_string(), Name );
|
result.append_fmt( "%S %S(", ReturnType->to_string(), Name );
|
||||||
@ -795,7 +821,24 @@ String AST::to_string()
|
|||||||
result.append_fmt( "%S ", Attributes->to_string() );
|
result.append_fmt( "%S ", Attributes->to_string() );
|
||||||
|
|
||||||
if ( Attributes )
|
if ( Attributes )
|
||||||
result.append_fmt( "%S\n", Attributes->to_string() );
|
result.append_fmt( "%S ", Attributes->to_string() );
|
||||||
|
|
||||||
|
if ( Specs )
|
||||||
|
{
|
||||||
|
for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() )
|
||||||
|
{
|
||||||
|
if ( ! ESpecifier::is_trailing( spec ) )
|
||||||
|
{
|
||||||
|
StrC spec_str = ESpecifier::to_str( spec );
|
||||||
|
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Attributes || Specs )
|
||||||
|
{
|
||||||
|
result.append("\n" );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ReturnType )
|
if ( ReturnType )
|
||||||
result.append_fmt( "%S %S (", ReturnType->to_string(), Name );
|
result.append_fmt( "%S %S (", ReturnType->to_string(), Name );
|
||||||
@ -834,7 +877,21 @@ String AST::to_string()
|
|||||||
result.append_fmt( "%S\n", Attributes->to_string() );
|
result.append_fmt( "%S\n", Attributes->to_string() );
|
||||||
|
|
||||||
if ( Specs )
|
if ( Specs )
|
||||||
result.append_fmt( "%S\n", Specs->to_string() );
|
{
|
||||||
|
for ( SpecifierT spec : Specs->cast<CodeSpecifiers>() )
|
||||||
|
{
|
||||||
|
if ( ! ESpecifier::is_trailing( spec ) )
|
||||||
|
{
|
||||||
|
StrC spec_str = ESpecifier::to_str( spec );
|
||||||
|
result.append_fmt( " %.*s", spec_str.Len, spec_str.Ptr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( Attributes || Specs )
|
||||||
|
{
|
||||||
|
result.append("\n" );
|
||||||
|
}
|
||||||
|
|
||||||
result.append_fmt( "%S %S (", ReturnType->to_string(), Name );
|
result.append_fmt( "%S %S (", ReturnType->to_string(), Name );
|
||||||
|
|
||||||
@ -991,12 +1048,6 @@ String AST::to_string()
|
|||||||
s32 left = NumEntries;
|
s32 left = NumEntries;
|
||||||
while ( left-- )
|
while ( left-- )
|
||||||
{
|
{
|
||||||
if ( ESpecifier::is_trailing( ArrSpecs[idx]) && ArrSpecs[idx] != ESpecifier::Const )
|
|
||||||
{
|
|
||||||
idx++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
StrC spec = ESpecifier::to_str( ArrSpecs[idx] );
|
StrC spec = ESpecifier::to_str( ArrSpecs[idx] );
|
||||||
result.append_fmt( "%.*s ", spec.Len, spec.Ptr );
|
result.append_fmt( "%.*s ", spec.Len, spec.Ptr );
|
||||||
idx++;
|
idx++;
|
||||||
|
@ -257,7 +257,7 @@ struct AST
|
|||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||||
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
StringCached Content; // Attributes, Comment, Execution, Include
|
StringCached Content; // Attributes, Comment, Execution, Include
|
||||||
@ -316,7 +316,7 @@ struct AST_POD
|
|||||||
};
|
};
|
||||||
union {
|
union {
|
||||||
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
AST* NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
|
||||||
AST* SpecsFuncSuffix; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
AST* SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
StringCached Content; // Attributes, Comment, Execution, Include
|
StringCached Content; // Attributes, Comment, Execution, Include
|
||||||
|
@ -509,6 +509,8 @@ namespace Parser
|
|||||||
);
|
);
|
||||||
return { { nullptr }, 0 };
|
return { { nullptr }, 0 };
|
||||||
}
|
}
|
||||||
|
move_forward();
|
||||||
|
content.Length++;
|
||||||
|
|
||||||
while ( left && current != '"' && current != '>' )
|
while ( left && current != '"' && current != '>' )
|
||||||
{
|
{
|
||||||
@ -2296,6 +2298,7 @@ CodeFn parse_function_after_name(
|
|||||||
|
|
||||||
CodeParam params = parse_params();
|
CodeParam params = parse_params();
|
||||||
|
|
||||||
|
// These have to be kept separate from the return type's specifiers.
|
||||||
while ( left && currtok.is_specifier() )
|
while ( left && currtok.is_specifier() )
|
||||||
{
|
{
|
||||||
if ( specifiers.ast == nullptr )
|
if ( specifiers.ast == nullptr )
|
||||||
@ -4784,7 +4787,7 @@ CodeType parse_type( bool* typedef_is_function )
|
|||||||
#if 0
|
#if 0
|
||||||
else if ( currtok.Type == TokType::DeclType )
|
else if ( currtok.Type == TokType::DeclType )
|
||||||
{
|
{
|
||||||
// Will have a capture and its own parsing rules, were going to just shove everything in a string.
|
// Will have a capture and its own parsing rules, were going to just shove everything in a string (for now).
|
||||||
name = currtok;
|
name = currtok;
|
||||||
eat( TokType::DeclType );
|
eat( TokType::DeclType );
|
||||||
|
|
||||||
@ -5619,7 +5622,7 @@ CodeVar parse_variable()
|
|||||||
|
|
||||||
// Ignore const specifiers, they're handled by the type
|
// Ignore const specifiers, they're handled by the type
|
||||||
if ( spec == ESpecifier::Const )
|
if ( spec == ESpecifier::Const )
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
specs_found[NumSpecifiers] = spec;
|
specs_found[NumSpecifiers] = spec;
|
||||||
NumSpecifiers++;
|
NumSpecifiers++;
|
||||||
|
Reference in New Issue
Block a user