mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
Compare commits
3 Commits
16b8a3a164
...
8f47f3b30f
Author | SHA1 | Date | |
---|---|---|---|
8f47f3b30f | |||
0bad61fda6 | |||
ea18792373 |
@ -423,35 +423,35 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Constructor:
|
||||
cast(CodeConstructor, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeConstructor, {self}), result );
|
||||
break;
|
||||
|
||||
case Constructor_Fwd:
|
||||
cast(CodeConstructor, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeConstructor, {self}), result );
|
||||
break;
|
||||
|
||||
case Destructor:
|
||||
cast(CodeDestructor, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeDestructor, {self}), result );
|
||||
break;
|
||||
|
||||
case Destructor_Fwd:
|
||||
cast(CodeDestructor, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeDestructor, {self}), result );
|
||||
break;
|
||||
|
||||
case Enum:
|
||||
cast(CodeEnum, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeEnum, {self}), result );
|
||||
break;
|
||||
|
||||
case Enum_Fwd:
|
||||
cast(CodeEnum, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeEnum, {self}), result );
|
||||
break;
|
||||
|
||||
case Enum_Class:
|
||||
cast(CodeEnum, {self}).to_string_class_def( * result );
|
||||
to_string_class_def(cast(CodeEnum, {self}), result );
|
||||
break;
|
||||
|
||||
case Enum_Class_Fwd:
|
||||
cast(CodeEnum, {self}).to_string_class_fwd( * result );
|
||||
to_string_class_fwd(cast(CodeEnum, {self}), result );
|
||||
break;
|
||||
|
||||
case Export_Body:
|
||||
@ -459,19 +459,19 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Extern_Linkage:
|
||||
cast(CodeExtern, {self}).to_string( * result );
|
||||
to_string(cast(CodeExtern, {self}), result );
|
||||
break;
|
||||
|
||||
case Friend:
|
||||
cast(CodeFriend, {self}).to_string( * result );
|
||||
to_string(cast(CodeFriend, {self}), result );
|
||||
break;
|
||||
|
||||
case Function:
|
||||
cast(CodeFn, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeFn, {self}), result );
|
||||
break;
|
||||
|
||||
case Function_Fwd:
|
||||
cast(CodeFn, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeFn, {self}), result );
|
||||
break;
|
||||
|
||||
case Module:
|
||||
@ -501,11 +501,11 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Parameters:
|
||||
cast(CodeParam, {self}).to_string( * result );
|
||||
to_string(cast(CodeParam, {self}), result );
|
||||
break;
|
||||
|
||||
case Preprocess_Define:
|
||||
cast(CodeDefine, {self}).to_string( * result );
|
||||
to_string(cast(CodeDefine, {self}), result );
|
||||
break;
|
||||
|
||||
case Preprocess_If:
|
||||
@ -521,7 +521,7 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Preprocess_Include:
|
||||
cast(CodeInclude, {self}).to_string( * result );
|
||||
to_string(cast(CodeInclude, {self}), result );
|
||||
break;
|
||||
|
||||
case Preprocess_ElIf:
|
||||
@ -541,15 +541,15 @@ void to_string( AST* self, String* result )
|
||||
break;
|
||||
|
||||
case Specifiers:
|
||||
cast(CodeSpecifiers, {self}).to_string( * result );
|
||||
to_string(cast(CodeSpecifiers, {self}), result );
|
||||
break;
|
||||
|
||||
case Struct:
|
||||
cast(CodeStruct, {self}).to_string_def( * result );
|
||||
to_string_def(cast(CodeStruct, {self}), result );
|
||||
break;
|
||||
|
||||
case Struct_Fwd:
|
||||
cast(CodeStruct, {self}).to_string_fwd( * result );
|
||||
to_string_fwd(cast(CodeStruct, {self}), result );
|
||||
break;
|
||||
|
||||
case Template:
|
||||
|
@ -13,9 +13,8 @@ String to_string(Code self)
|
||||
return to_string( self.ast );
|
||||
}
|
||||
|
||||
String CodeAttributes::to_string()
|
||||
{
|
||||
return GEN_NS duplicate( ast->Content, GlobalAllocator );
|
||||
String to_string(CodeAttributes attributes) {
|
||||
return GEN_NS duplicate( attributes->Content, GlobalAllocator );
|
||||
}
|
||||
|
||||
String to_string(CodeBody body)
|
||||
@ -78,73 +77,73 @@ void to_string_export( CodeBody body, String* result )
|
||||
append_fmt( result, "};\n" );
|
||||
}
|
||||
|
||||
String CodeComment::to_string()
|
||||
String to_string(CodeComment comment)
|
||||
{
|
||||
return GEN_NS duplicate( ast->Content, GlobalAllocator );
|
||||
return GEN_NS duplicate( comment->Content, GlobalAllocator );
|
||||
}
|
||||
|
||||
String CodeConstructor::to_string()
|
||||
String to_string(CodeConstructor self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
switch (ast->Type)
|
||||
switch (self->Type)
|
||||
{
|
||||
using namespace ECode;
|
||||
case Constructor:
|
||||
to_string_def( result );
|
||||
to_string_def( self, & result );
|
||||
break;
|
||||
case Constructor_Fwd:
|
||||
to_string_fwd( result );
|
||||
to_string_fwd( self, & result );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeConstructor::to_string_def( String& result )
|
||||
void to_string_def(CodeConstructor self, String* result )
|
||||
{
|
||||
AST* ClassStructParent = ast->Parent->Parent;
|
||||
AST* ClassStructParent = self->Parent->Parent;
|
||||
if (ClassStructParent) {
|
||||
append( & result, ClassStructParent->Name );
|
||||
append( result, ClassStructParent->Name );
|
||||
}
|
||||
else {
|
||||
append( & result, ast->Name );
|
||||
append( result, self->Name );
|
||||
}
|
||||
|
||||
if ( ast->Params )
|
||||
append_fmt( & result, "( %S )", ast->Params.to_string() );
|
||||
if ( self->Params )
|
||||
append_fmt( result, "( %S )", GEN_NS to_string(self->Params) );
|
||||
else
|
||||
append( & result, "()" );
|
||||
append( result, "()" );
|
||||
|
||||
if ( ast->InitializerList )
|
||||
append_fmt( & result, " : %S", GEN_NS to_string(ast->InitializerList) );
|
||||
if ( self->InitializerList )
|
||||
append_fmt( result, " : %S", GEN_NS to_string(self->InitializerList) );
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, " // %S", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, " // %S", self->InlineCmt->Content );
|
||||
|
||||
append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
|
||||
}
|
||||
|
||||
void CodeConstructor::to_string_fwd( String& result )
|
||||
void to_string_fwd(CodeConstructor self, String* result )
|
||||
{
|
||||
AST* ClassStructParent = ast->Parent->Parent;
|
||||
AST* ClassStructParent = self->Parent->Parent;
|
||||
if (ClassStructParent) {
|
||||
append( & result, ClassStructParent->Name );
|
||||
append( result, ClassStructParent->Name );
|
||||
}
|
||||
else {
|
||||
append( & result, ast->Name );
|
||||
append( result, self->Name );
|
||||
}
|
||||
|
||||
if ( ast->Params )
|
||||
append_fmt( & result, "( %S )", ast->Params.to_string() );
|
||||
if ( self->Params )
|
||||
append_fmt( result, "( %S )", GEN_NS to_string(self->Params) );
|
||||
else
|
||||
append_fmt( & result, "()");
|
||||
append_fmt( result, "()");
|
||||
|
||||
if (ast->Body)
|
||||
append_fmt( & result, " = %S", GEN_NS to_string(ast->Body) );
|
||||
if (self->Body)
|
||||
append_fmt( result, " = %S", GEN_NS to_string(self->Body) );
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "; // %S\n", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, "; // %S\n", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, ";\n" );
|
||||
append( result, ";\n" );
|
||||
}
|
||||
|
||||
String to_string( CodeClass self )
|
||||
@ -175,7 +174,7 @@ void to_string_def( CodeClass self, String* result )
|
||||
|
||||
if ( ast->Attributes )
|
||||
{
|
||||
append_fmt( result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( result, "%S ", GEN_NS to_string(ast->Attributes) );
|
||||
}
|
||||
|
||||
if ( ast->ParentType )
|
||||
@ -219,7 +218,7 @@ void to_string_fwd( CodeClass self, String* result )
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( result, "class %S %S", ast->Attributes.to_string(), ast->Name );
|
||||
append_fmt( result, "class %S %S", to_string(ast->Attributes), ast->Name );
|
||||
|
||||
else append_fmt( result, "class %S", ast->Name );
|
||||
|
||||
@ -233,379 +232,379 @@ void to_string_fwd( CodeClass self, String* result )
|
||||
}
|
||||
}
|
||||
|
||||
String CodeDefine::to_string()
|
||||
String to_string(CodeDefine define)
|
||||
{
|
||||
return string_fmt_buf( GlobalAllocator, "#define %S %S\n", ast->Name, ast->Content );
|
||||
return string_fmt_buf( GlobalAllocator, "#define %S %S\n", define->Name, define->Content );
|
||||
}
|
||||
|
||||
void CodeDefine::to_string( String& result )
|
||||
void to_string(CodeDefine define, String* result )
|
||||
{
|
||||
append_fmt( & result, "#define %S %S\n", ast->Name, ast->Content );
|
||||
append_fmt( result, "#define %S %S\n", define->Name, define->Content );
|
||||
}
|
||||
|
||||
String CodeDestructor::to_string()
|
||||
String to_string(CodeDestructor self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
switch ( ast->Type )
|
||||
switch ( self->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
case Destructor:
|
||||
to_string_def( result );
|
||||
to_string_def( self, & result );
|
||||
break;
|
||||
case Destructor_Fwd:
|
||||
to_string_fwd( result );
|
||||
to_string_fwd( self, & result );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeDestructor::to_string_def( String& result )
|
||||
void to_string_def(CodeDestructor self, String* result )
|
||||
{
|
||||
if ( ast->Name )
|
||||
if ( self->Name )
|
||||
{
|
||||
append_fmt( & result, "%S()", ast->Name );
|
||||
append_fmt( result, "%S()", self->Name );
|
||||
}
|
||||
else if ( ast->Specs )
|
||||
else if ( self->Specs )
|
||||
{
|
||||
if ( ast->Specs.has( ESpecifier::Virtual ) )
|
||||
append_fmt( & result, "virtual ~%S()", ast->Parent->Name );
|
||||
if ( has(self->Specs, ESpecifier::Virtual ) )
|
||||
append_fmt( result, "virtual ~%S()", self->Parent->Name );
|
||||
else
|
||||
append_fmt( & result, "~%S()", ast->Parent->Name );
|
||||
append_fmt( result, "~%S()", self->Parent->Name );
|
||||
}
|
||||
else
|
||||
append_fmt( & result, "~%S()", ast->Parent->Name );
|
||||
append_fmt( result, "~%S()", self->Parent->Name );
|
||||
|
||||
append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
|
||||
}
|
||||
|
||||
void CodeDestructor::to_string_fwd( String& result )
|
||||
void to_string_fwd(CodeDestructor self, String* result )
|
||||
{
|
||||
if ( ast->Specs )
|
||||
if ( self->Specs )
|
||||
{
|
||||
if ( ast->Specs.has( ESpecifier::Virtual ) )
|
||||
append_fmt( & result, "virtual ~%S();\n", ast->Parent->Name );
|
||||
if ( has(self->Specs, ESpecifier::Virtual ) )
|
||||
append_fmt( result, "virtual ~%S();\n", self->Parent->Name );
|
||||
else
|
||||
append_fmt( & result, "~%S()", ast->Parent->Name );
|
||||
append_fmt( result, "~%S()", self->Parent->Name );
|
||||
|
||||
if ( ast->Specs.has( ESpecifier::Pure ) )
|
||||
append( & result, " = 0;" );
|
||||
else if (ast->Body)
|
||||
append_fmt( & result, " = %S;", GEN_NS to_string(ast->Body) );
|
||||
if ( has(self->Specs, ESpecifier::Pure ) )
|
||||
append( result, " = 0;" );
|
||||
else if (self->Body)
|
||||
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
|
||||
}
|
||||
else
|
||||
append_fmt( & result, "~%S();", ast->Parent->Name );
|
||||
append_fmt( result, "~%S();", self->Parent->Name );
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, " %S", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, " %S", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, "\n");
|
||||
append( result, "\n");
|
||||
}
|
||||
|
||||
String CodeEnum::to_string()
|
||||
String to_string(CodeEnum self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
switch ( ast->Type )
|
||||
switch ( self->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
case Enum:
|
||||
to_string_def( result );
|
||||
to_string_def(self, & result );
|
||||
break;
|
||||
case Enum_Fwd:
|
||||
to_string_fwd( result );
|
||||
to_string_fwd(self, & result );
|
||||
break;
|
||||
case Enum_Class:
|
||||
to_string_class_def( result );
|
||||
to_string_class_def(self, & result );
|
||||
break;
|
||||
case Enum_Class_Fwd:
|
||||
to_string_class_fwd( result );
|
||||
to_string_class_fwd(self, & result );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeEnum::to_string_def( String& result )
|
||||
void to_string_def(CodeEnum self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes || ast->UnderlyingType )
|
||||
if ( self->Attributes || self->UnderlyingType )
|
||||
{
|
||||
append( & result, "enum " );
|
||||
append( result, "enum " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ", GEN_NS to_string(self->Attributes) );
|
||||
|
||||
if ( ast->UnderlyingType )
|
||||
append_fmt( & result, "%S : %S\n{\n%S\n}"
|
||||
, ast->Name
|
||||
, ast->UnderlyingType.to_string()
|
||||
, GEN_NS to_string(ast->Body)
|
||||
if ( self->UnderlyingType )
|
||||
append_fmt( result, "%S : %S\n{\n%S\n}"
|
||||
, self->Name
|
||||
, self->UnderlyingType.to_string()
|
||||
, GEN_NS to_string(self->Body)
|
||||
);
|
||||
else if ( ast->UnderlyingTypeMacro )
|
||||
append_fmt( & result, "%S : %S\n{\n%S\n}"
|
||||
, ast->Name
|
||||
, GEN_NS to_string(ast->UnderlyingTypeMacro)
|
||||
, GEN_NS to_string(ast->Body)
|
||||
else if ( self->UnderlyingTypeMacro )
|
||||
append_fmt( result, "%S : %S\n{\n%S\n}"
|
||||
, self->Name
|
||||
, GEN_NS to_string(self->UnderlyingTypeMacro)
|
||||
, GEN_NS to_string(self->Body)
|
||||
);
|
||||
|
||||
else append_fmt( & result, "%S\n{\n%S\n}", ast->Name, GEN_NS to_string(ast->Body) );
|
||||
else append_fmt( result, "%S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) );
|
||||
}
|
||||
else append_fmt( & result, "enum %S\n{\n%S\n}", ast->Name, GEN_NS to_string(ast->Body) );
|
||||
else append_fmt( result, "enum %S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) );
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
append( & result, ";\n");
|
||||
if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) )
|
||||
append( result, ";\n");
|
||||
}
|
||||
|
||||
void CodeEnum::to_string_fwd( String& result )
|
||||
void to_string_fwd(CodeEnum self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
|
||||
|
||||
if ( ast->UnderlyingType )
|
||||
append_fmt( & result, "enum %S : %S", ast->Name, ast->UnderlyingType.to_string() );
|
||||
if ( self->UnderlyingType )
|
||||
append_fmt( result, "enum %S : %S", self->Name, self->UnderlyingType.to_string() );
|
||||
else
|
||||
append_fmt( & result, "enum %S", ast->Name );
|
||||
append_fmt( result, "enum %S", self->Name );
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) )
|
||||
{
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "; %S", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, "; %S", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, ";\n");
|
||||
append( result, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEnum::to_string_class_def( String& result )
|
||||
void to_string_class_def(CodeEnum self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes || ast->UnderlyingType )
|
||||
if ( self->Attributes || self->UnderlyingType )
|
||||
{
|
||||
append( & result, "enum class " );
|
||||
append( result, "enum class " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
if ( self->Attributes )
|
||||
{
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
|
||||
}
|
||||
|
||||
if ( ast->UnderlyingType )
|
||||
if ( self->UnderlyingType )
|
||||
{
|
||||
append_fmt( & result, "%S : %S\n{\n%S\n}", ast->Name, ast->UnderlyingType.to_string(), GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "%S : %S\n{\n%S\n}", self->Name, self->UnderlyingType.to_string(), GEN_NS to_string(self->Body) );
|
||||
}
|
||||
else
|
||||
{
|
||||
append_fmt( & result, "%S\n{\n%S\n}", ast->Name, GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "%S\n{\n%S\n}", self->Name, GEN_NS to_string(self->Body) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
append_fmt( & result, "enum class %S\n{\n%S\n}", GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "enum class %S\n{\n%S\n}", GEN_NS to_string(self->Body) );
|
||||
}
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
append( & result, ";\n");
|
||||
if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) )
|
||||
append( result, ";\n");
|
||||
}
|
||||
|
||||
void CodeEnum::to_string_class_fwd( String& result )
|
||||
void to_string_class_fwd(CodeEnum self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
append( & result, "enum class " );
|
||||
append( result, "enum class " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
|
||||
|
||||
append_fmt( & result, "%S : %S", ast->Name, ast->UnderlyingType.to_string() );
|
||||
append_fmt( result, "%S : %S", self->Name, self->UnderlyingType.to_string() );
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
if ( self->Parent.ast == nullptr || ( self->Parent->Type != ECode::Typedef && self->Parent->Type != ECode::Variable ) )
|
||||
{
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "; %S", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, "; %S", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, ";\n");
|
||||
append( result, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
String CodeExec::to_string()
|
||||
String to_string(CodeExec exec)
|
||||
{
|
||||
return GEN_NS duplicate( ast->Content, GlobalAllocator );
|
||||
return GEN_NS duplicate( exec->Content, GlobalAllocator );
|
||||
}
|
||||
|
||||
void CodeExtern::to_string( String& result )
|
||||
void to_string(CodeExtern self, String* result )
|
||||
{
|
||||
if ( ast->Body )
|
||||
append_fmt( & result, "extern \"%S\"\n{\n%S\n}\n", ast->Name, GEN_NS to_string(ast->Body) );
|
||||
if ( self->Body )
|
||||
append_fmt( result, "extern \"%S\"\n{\n%S\n}\n", self->Name, GEN_NS to_string(self->Body) );
|
||||
else
|
||||
append_fmt( & result, "extern \"%S\"\n{}\n", ast->Name );
|
||||
append_fmt( result, "extern \"%S\"\n{}\n", self->Name );
|
||||
}
|
||||
|
||||
String CodeInclude::to_string()
|
||||
String to_string(CodeInclude include)
|
||||
{
|
||||
return string_fmt_buf( GlobalAllocator, "#include %S\n", ast->Content );
|
||||
return string_fmt_buf( GlobalAllocator, "#include %S\n", include->Content );
|
||||
}
|
||||
|
||||
void CodeInclude::to_string( String& result )
|
||||
void to_string( CodeInclude include, String* result )
|
||||
{
|
||||
append_fmt( & result, "#include %S\n", ast->Content );
|
||||
append_fmt( result, "#include %S\n", include->Content );
|
||||
}
|
||||
|
||||
String CodeFriend::to_string()
|
||||
String to_string(CodeFriend self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeFriend::to_string( String& result )
|
||||
void to_string(CodeFriend self, String* result )
|
||||
{
|
||||
append_fmt( & result, "friend %S", GEN_NS to_string(ast->Declaration) );
|
||||
append_fmt( result, "friend %S", GEN_NS to_string(self->Declaration) );
|
||||
|
||||
if ( ast->Declaration->Type != ECode::Function && result[ length(result) - 1 ] != ';' )
|
||||
if ( self->Declaration->Type != ECode::Function && (* result)[ length(* result) - 1 ] != ';' )
|
||||
{
|
||||
append( & result, ";" );
|
||||
append( result, ";" );
|
||||
}
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, " %S", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, " %S", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, "\n");
|
||||
append( result, "\n");
|
||||
}
|
||||
|
||||
String CodeFn::to_string()
|
||||
String to_string(CodeFn self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
switch ( ast->Type )
|
||||
switch ( self->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
case Function:
|
||||
to_string_def( result );
|
||||
to_string_def(self, & result );
|
||||
break;
|
||||
case Function_Fwd:
|
||||
to_string_fwd( result );
|
||||
to_string_fwd(self, & result );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeFn::to_string_def( String& result )
|
||||
void to_string_def(CodeFn self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export" );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export" );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, " %S ", ast->Attributes.to_string() );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, " %S ",GEN_NS to_string(self->Attributes) );
|
||||
|
||||
bool prefix_specs = false;
|
||||
if ( ast->Specs )
|
||||
if ( self->Specs )
|
||||
{
|
||||
for ( SpecifierT spec : ast->Specs )
|
||||
for ( SpecifierT spec : self->Specs )
|
||||
{
|
||||
if ( ! ESpecifier::is_trailing( spec ) )
|
||||
{
|
||||
StrC spec_str = ESpecifier::to_str( spec );
|
||||
append_fmt( & result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
|
||||
prefix_specs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ast->Attributes || prefix_specs )
|
||||
append( & result, "\n" );
|
||||
if ( self->Attributes || prefix_specs )
|
||||
append( result, "\n" );
|
||||
|
||||
if ( ast->ReturnType )
|
||||
append_fmt( & result, "%S %S(", ast->ReturnType.to_string(), ast->Name );
|
||||
if ( self->ReturnType )
|
||||
append_fmt( result, "%S %S(", self->ReturnType.to_string(), self->Name );
|
||||
|
||||
else
|
||||
append_fmt( & result, "%S(", ast->Name );
|
||||
append_fmt( result, "%S(", self->Name );
|
||||
|
||||
if ( ast->Params )
|
||||
append_fmt( & result, "%S)", ast->Params.to_string() );
|
||||
if ( self->Params )
|
||||
append_fmt( result, "%S)", GEN_NS to_string(self->Params) );
|
||||
|
||||
else
|
||||
append( & result, ")" );
|
||||
append( result, ")" );
|
||||
|
||||
if ( ast->Specs )
|
||||
if ( self->Specs )
|
||||
{
|
||||
for ( SpecifierT spec : ast->Specs )
|
||||
for ( SpecifierT spec : self->Specs )
|
||||
{
|
||||
if ( ESpecifier::is_trailing( spec ) )
|
||||
{
|
||||
StrC spec_str = ESpecifier::to_str( spec );
|
||||
append_fmt( & result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
append_fmt( & result, "\n{\n%S\n}\n", GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "\n{\n%S\n}\n", GEN_NS to_string(self->Body) );
|
||||
}
|
||||
|
||||
void CodeFn::to_string_fwd( String& result )
|
||||
void to_string_fwd(CodeFn self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
if ( bitfield_is_equal( u32, self->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
if ( self->Attributes )
|
||||
append_fmt( result, "%S ",GEN_NS to_string(self->Attributes) );
|
||||
|
||||
b32 prefix_specs = false;
|
||||
if ( ast->Specs )
|
||||
if ( self->Specs )
|
||||
{
|
||||
for ( SpecifierT spec : ast->Specs )
|
||||
for ( SpecifierT spec : self->Specs )
|
||||
{
|
||||
if ( ! ESpecifier::is_trailing( spec ) || ! (spec != ESpecifier::Pure) )
|
||||
{
|
||||
StrC spec_str = ESpecifier::to_str( spec );
|
||||
append_fmt( & result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
|
||||
prefix_specs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ast->Attributes || prefix_specs )
|
||||
if ( self->Attributes || prefix_specs )
|
||||
{
|
||||
append( & result, "\n" );
|
||||
append( result, "\n" );
|
||||
}
|
||||
|
||||
if ( ast->ReturnType )
|
||||
append_fmt( & result, "%S %S(", ast->ReturnType.to_string(), ast->Name );
|
||||
if ( self->ReturnType )
|
||||
append_fmt( result, "%S %S(", self->ReturnType.to_string(), self->Name );
|
||||
|
||||
else
|
||||
append_fmt( & result, "%S(", ast->Name );
|
||||
append_fmt( result, "%S(", self->Name );
|
||||
|
||||
if ( ast->Params )
|
||||
append_fmt( & result, "%S)", ast->Params.to_string() );
|
||||
if ( self->Params )
|
||||
append_fmt( result, "%S)", GEN_NS to_string(self->Params) );
|
||||
|
||||
else
|
||||
append( & result, ")" );
|
||||
append( result, ")" );
|
||||
|
||||
if ( ast->Specs )
|
||||
if ( self->Specs )
|
||||
{
|
||||
for ( SpecifierT spec : ast->Specs )
|
||||
for ( SpecifierT spec : self->Specs )
|
||||
{
|
||||
if ( ESpecifier::is_trailing( spec ) )
|
||||
{
|
||||
StrC spec_str = ESpecifier::to_str( spec );
|
||||
append_fmt( & result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
append_fmt( result, " %.*s", spec_str.Len, spec_str.Ptr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ast->Specs && ast->Specs.has( ESpecifier::Pure ) >= 0 )
|
||||
append( & result, " = 0;" );
|
||||
else if (ast->Body)
|
||||
append_fmt( & result, " = %S;", GEN_NS to_string(ast->Body) );
|
||||
if ( self->Specs && has(self->Specs, ESpecifier::Pure ) >= 0 )
|
||||
append( result, " = 0;" );
|
||||
else if (self->Body)
|
||||
append_fmt( result, " = %S;", GEN_NS to_string(self->Body) );
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "; %S", ast->InlineCmt->Content );
|
||||
if ( self->InlineCmt )
|
||||
append_fmt( result, "; %S", self->InlineCmt->Content );
|
||||
else
|
||||
append( & result, ";\n" );
|
||||
append( result, ";\n" );
|
||||
}
|
||||
|
||||
String CodeModule::to_string()
|
||||
@ -665,10 +664,10 @@ void CodeOperator::to_string_def( String& result )
|
||||
append( & result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
|
||||
if ( ast->Specs )
|
||||
{
|
||||
@ -691,7 +690,7 @@ void CodeOperator::to_string_def( String& result )
|
||||
append_fmt( & result, "%S %S (", ast->ReturnType.to_string(), ast->Name );
|
||||
|
||||
if ( ast->Params )
|
||||
append_fmt( & result, "%S)", ast->Params.to_string() );
|
||||
append_fmt( & result, "%S)", GEN_NS to_string(ast->Params) );
|
||||
|
||||
else
|
||||
append( & result, ")" );
|
||||
@ -719,7 +718,7 @@ void CodeOperator::to_string_fwd( String& result )
|
||||
append( & result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S\n", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S\n",GEN_NS to_string(ast->Attributes) );
|
||||
|
||||
if ( ast->Specs )
|
||||
{
|
||||
@ -741,7 +740,7 @@ void CodeOperator::to_string_fwd( String& result )
|
||||
append_fmt( & result, "%S %S (", ast->ReturnType.to_string(), ast->Name );
|
||||
|
||||
if ( ast->Params )
|
||||
append_fmt( & result, "%S)", ast->Params.to_string() );
|
||||
append_fmt( & result, "%S)", GEN_NS to_string(ast->Params) );
|
||||
|
||||
else
|
||||
append_fmt( & result, ")" );
|
||||
@ -854,46 +853,47 @@ void CodeOpCast::to_string_fwd( String& result )
|
||||
append_fmt( & result, "operator %S();\n", ast->ValueType.to_string() );
|
||||
}
|
||||
|
||||
String CodeParam::to_string()
|
||||
String to_string(CodeParam self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeParam::to_string( String& result )
|
||||
void to_string( CodeParam self, String* result )
|
||||
{
|
||||
AST_Param* ast = self.ast;
|
||||
if ( ast->Macro )
|
||||
{
|
||||
// Related to parsing: ( <macro>, ... )
|
||||
GEN_NS append( & result, ast->Macro.ast->Content );
|
||||
GEN_NS append( result, ast->Macro.ast->Content );
|
||||
// Could also be: ( <macro> <type <name>, ... )
|
||||
}
|
||||
|
||||
if ( ast->Name )
|
||||
{
|
||||
if ( ast->ValueType.ast == nullptr )
|
||||
append_fmt( & result, " %S", ast->Name );
|
||||
append_fmt( result, " %S", ast->Name );
|
||||
else
|
||||
append_fmt( & result, " %S %S", ast->ValueType.to_string(), ast->Name );
|
||||
append_fmt( result, " %S %S", ast->ValueType.to_string(), ast->Name );
|
||||
|
||||
}
|
||||
else if ( ast->ValueType )
|
||||
append_fmt( & result, " %S", ast->ValueType.to_string() );
|
||||
append_fmt( result, " %S", ast->ValueType.to_string() );
|
||||
|
||||
if ( ast->PostNameMacro )
|
||||
{
|
||||
append_fmt( & result, " %S", GEN_NS to_string(ast->PostNameMacro) );
|
||||
append_fmt( result, " %S", GEN_NS to_string(ast->PostNameMacro) );
|
||||
}
|
||||
|
||||
if ( ast->Value )
|
||||
append_fmt( & result, " = %S", GEN_NS to_string(ast->Value) );
|
||||
append_fmt( result, " = %S", GEN_NS to_string(ast->Value) );
|
||||
|
||||
if ( ast->NumEntries - 1 > 0 )
|
||||
{
|
||||
for ( CodeParam param : ast->Next )
|
||||
{
|
||||
append_fmt( & result, ", %S", param.to_string() );
|
||||
append_fmt( result, ", %S", to_string(param) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -968,101 +968,110 @@ void CodePragma::to_string( String& result )
|
||||
append_fmt( & result, "#pragma %S\n", ast->Content );
|
||||
}
|
||||
|
||||
String CodeSpecifiers::to_string()
|
||||
String to_string(CodeSpecifiers self)
|
||||
{
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
to_string( result );
|
||||
to_string( self, & result );
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeSpecifiers::to_string( String& result )
|
||||
void to_string( CodeSpecifiers self, String* result )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(result != nullptr);
|
||||
s32 idx = 0;
|
||||
s32 left = ast->NumEntries;
|
||||
s32 left = self->NumEntries;
|
||||
while ( left-- )
|
||||
{
|
||||
StrC spec = ESpecifier::to_str( ast->ArrSpecs[idx] );
|
||||
append_fmt( & result, "%.*s ", spec.Len, spec.Ptr );
|
||||
StrC spec = ESpecifier::to_str( self->ArrSpecs[idx] );
|
||||
append_fmt( result, "%.*s ", spec.Len, spec.Ptr );
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
String CodeStruct::to_string()
|
||||
String to_string(CodeStruct self)
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
String result = string_make( GlobalAllocator, "" );
|
||||
switch ( ast->Type )
|
||||
switch ( self->Type )
|
||||
{
|
||||
using namespace ECode;
|
||||
case Struct:
|
||||
to_string_def( result );
|
||||
to_string_def( self, & result );
|
||||
break;
|
||||
case Struct_Fwd:
|
||||
to_string_fwd( result );
|
||||
to_string_fwd( self, & result );
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeStruct::to_string_def( String& result )
|
||||
void to_string_def( CodeStruct self, String* result )
|
||||
{
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
AST_Struct* ast = self.ast;
|
||||
|
||||
append( & result, "struct " );
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( result, "export " );
|
||||
|
||||
append( result, "struct " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
{
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
}
|
||||
|
||||
if ( ast->ParentType )
|
||||
{
|
||||
char const* access_level = to_str( ast->ParentAccess );
|
||||
|
||||
append_fmt( & result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() );
|
||||
append_fmt( result, "%S : %s %S", ast->Name, access_level, ast->ParentType.to_string() );
|
||||
|
||||
CodeType interface = cast(CodeType, ast->ParentType->Next);
|
||||
if ( interface )
|
||||
append( & result, "\n" );
|
||||
append( result, "\n" );
|
||||
|
||||
while ( interface )
|
||||
{
|
||||
append_fmt( & result, ", %S", interface.to_string() );
|
||||
append_fmt( result, ", %S", interface.to_string() );
|
||||
interface = interface->Next ? cast( CodeType, interface->Next) : CodeType { nullptr };
|
||||
}
|
||||
}
|
||||
else if ( ast->Name )
|
||||
{
|
||||
append( & result, ast->Name );
|
||||
append( result, ast->Name );
|
||||
}
|
||||
|
||||
if ( ast->InlineCmt )
|
||||
{
|
||||
append_fmt( & result, " // %S", ast->InlineCmt->Content );
|
||||
append_fmt( result, " // %S", ast->InlineCmt->Content );
|
||||
}
|
||||
|
||||
append_fmt( & result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
|
||||
append_fmt( result, "\n{\n%S\n}", GEN_NS to_string(ast->Body) );
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
append( & result, ";\n");
|
||||
append( result, ";\n");
|
||||
}
|
||||
|
||||
void CodeStruct::to_string_fwd( String& result )
|
||||
void to_string_fwd( CodeStruct self, String* result )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
AST_Struct* ast = self.ast;
|
||||
|
||||
if ( bitfield_is_equal( u32, ast->ModuleFlags, ModuleFlag_Export ))
|
||||
append( & result, "export " );
|
||||
append( result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "struct %S %S", ast->Attributes.to_string(), ast->Name );
|
||||
append_fmt( result, "struct %S %S",GEN_NS to_string(ast->Attributes), ast->Name );
|
||||
|
||||
else append_fmt( & result, "struct %S", ast->Name );
|
||||
else append_fmt( result, "struct %S", ast->Name );
|
||||
|
||||
if ( ast->Parent.ast == nullptr || ( ast->Parent->Type != ECode::Typedef && ast->Parent->Type != ECode::Variable ) )
|
||||
{
|
||||
if ( ast->InlineCmt )
|
||||
append_fmt( & result, "; %S", ast->InlineCmt->Content );
|
||||
append_fmt( result, "; %S", ast->InlineCmt->Content );
|
||||
else
|
||||
append( & result, ";\n");
|
||||
append( result, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1139,7 +1148,7 @@ void CodeType::to_string( String& result )
|
||||
if ( ast->ReturnType && ast->Params )
|
||||
{
|
||||
if ( ast->Attributes )
|
||||
append_fmt( result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
else
|
||||
{
|
||||
if ( ast->Specs )
|
||||
@ -1154,13 +1163,13 @@ void CodeType::to_string( String& result )
|
||||
if ( ast->ReturnType && ast->Params )
|
||||
{
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
else
|
||||
{
|
||||
if ( ast->Specs )
|
||||
append_fmt( & result, "%S %S ( %S ) %S", ast->ReturnType.to_string(), ast->Name, ast->Params.to_string(), ast->Specs.to_string() );
|
||||
append_fmt( & result, "%S %S ( %S ) %S", ast->ReturnType.to_string(), ast->Name, GEN_NS to_string(ast->Params), GEN_NS to_string(ast->Specs) );
|
||||
else
|
||||
append_fmt( & result, "%S %S ( %S )", ast->ReturnType.to_string(), ast->Name, ast->Params.to_string() );
|
||||
append_fmt( & result, "%S %S ( %S )", ast->ReturnType.to_string(), ast->Name, GEN_NS to_string(ast->Params) );
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1168,10 +1177,10 @@ void CodeType::to_string( String& result )
|
||||
#endif
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
|
||||
if ( ast->Specs )
|
||||
append_fmt( & result, "%S %S", ast->Name, ast->Specs.to_string() );
|
||||
append_fmt( & result, "%S %S", ast->Name, GEN_NS to_string(ast->Specs) );
|
||||
else
|
||||
append_fmt( & result, "%S", ast->Name );
|
||||
|
||||
@ -1194,7 +1203,7 @@ void CodeUnion::to_string( String& result )
|
||||
append( & result, "union " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
|
||||
if ( ast->Name )
|
||||
{
|
||||
@ -1237,7 +1246,7 @@ void CodeUsing::to_string( String& result )
|
||||
append( & result, "export " );
|
||||
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Attributes.to_string() );
|
||||
append_fmt( & result, "%S ",GEN_NS to_string(ast->Attributes) );
|
||||
|
||||
if ( ast->UnderlyingType )
|
||||
{
|
||||
@ -1288,7 +1297,7 @@ void CodeVar::to_string( String& result )
|
||||
// Its a comma-separated variable ( a NextVar )
|
||||
|
||||
if ( ast->Specs )
|
||||
append_fmt( & result, "%S ", ast->Specs.to_string() );
|
||||
append_fmt( & result, "%S ", GEN_NS to_string(ast->Specs) );
|
||||
|
||||
append( & result, ast->Name );
|
||||
|
||||
@ -1328,10 +1337,10 @@ void CodeVar::to_string( String& result )
|
||||
if ( ast->Attributes || ast->Specs )
|
||||
{
|
||||
if ( ast->Attributes )
|
||||
append_fmt( & result, "%S ", ast->Specs.to_string() );
|
||||
append_fmt( & result, "%S ", GEN_NS to_string(ast->Specs) );
|
||||
|
||||
if ( ast->Specs )
|
||||
append_fmt( & result, "%S\n", ast->Specs.to_string() );
|
||||
append_fmt( & result, "%S\n", GEN_NS to_string(ast->Specs) );
|
||||
|
||||
append_fmt( & result, "%S %S", ast->ValueType.to_string(), ast->Name );
|
||||
|
||||
|
@ -9,11 +9,71 @@ String to_string ( CodeBody body );
|
||||
void to_string ( CodeBody body, String* result );
|
||||
void to_string_export ( CodeBody body, String* result );
|
||||
|
||||
Code begin( CodeBody body);
|
||||
Code end ( CodeBody body );
|
||||
|
||||
void add_interface( CodeClass self, CodeType interface );
|
||||
String to_string ( CodeClass self );
|
||||
void to_string_def( CodeClass self, String* result );
|
||||
void to_string_fwd( CodeClass self, String* result );
|
||||
|
||||
void append (CodeParam params, CodeParam param );
|
||||
CodeParam get (CodeParam params, s32 idx);
|
||||
bool has_entries(CodeParam params );
|
||||
String to_string (CodeParam params );
|
||||
void to_string (CodeParam params, String* result );
|
||||
|
||||
CodeParam begin(CodeParam params);
|
||||
CodeParam end (CodeParam params);
|
||||
|
||||
bool append (CodeSpecifiers specifiers, SpecifierT spec);
|
||||
s32 has (CodeSpecifiers specifiers, SpecifierT spec);
|
||||
s32 remove (CodeSpecifiers specifiers, SpecifierT to_remove );
|
||||
String to_string(CodeSpecifiers specifiers);
|
||||
void to_string(CodeSpecifiers specifiers, String* result);
|
||||
|
||||
SpecifierT* begin(CodeSpecifiers specifiers );
|
||||
SpecifierT* end (CodeSpecifiers specifiers);
|
||||
|
||||
void add_interface(CodeStruct self, CodeType interface);
|
||||
String to_string (CodeStruct self);
|
||||
void to_string_fwd(CodeStruct self, String* result);
|
||||
void to_string_def(CodeStruct self, String* result);
|
||||
|
||||
String to_string(CodeAttributes attributes);
|
||||
String to_string(CodeComment comment );
|
||||
|
||||
String to_string (CodeConstructor constructor);
|
||||
void to_string_def(CodeConstructor constructor, String* result );
|
||||
void to_string_fwd(CodeConstructor constructor, String* result );
|
||||
|
||||
String to_string(CodeDefine define);
|
||||
void to_string(CodeDefine define, String* result);
|
||||
|
||||
String to_string (CodeDestructor destructor);
|
||||
void to_string_def(CodeDestructor destructor, String* result );
|
||||
void to_string_fwd(CodeDestructor destructor, String* result );
|
||||
|
||||
String to_string (CodeEnum self);
|
||||
void to_string_def (CodeEnum self, String* result );
|
||||
void to_string_fwd (CodeEnum self, String* result );
|
||||
void to_string_class_def(CodeEnum self, String* result );
|
||||
void to_string_class_fwd(CodeEnum self, String* result );
|
||||
|
||||
String to_string(CodeExec exec);
|
||||
|
||||
void to_string(CodeExtern self, String* result);
|
||||
|
||||
String to_string(CodeInclude include);
|
||||
void to_string(CodeInclude include, String* result);
|
||||
|
||||
String to_string(CodeFriend self);
|
||||
void to_string(CodeFriend self, String* result);
|
||||
|
||||
String to_string (CodeFn self);
|
||||
void to_string_def(CodeFn self, String* result);
|
||||
void to_string_fwd(CodeFn self, String* result);
|
||||
|
||||
#pragma region Code Types
|
||||
// These structs are not used at all by the C vairant.
|
||||
#if ! GEN_COMPILER_C
|
||||
@ -31,31 +91,21 @@ struct CodeBody
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result ); }
|
||||
void to_string_export( String& result ) { return GEN_NS to_string_export(* this, & result); }
|
||||
|
||||
Code begin() { return GEN_NS begin(* this); }
|
||||
Code end() { return GEN_NS end(* this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeBody );
|
||||
operator Code() { return * rcast( Code*, this ); }
|
||||
AST_Body* operator->() { return ast; }
|
||||
|
||||
#pragma region Iterator
|
||||
Code begin()
|
||||
{
|
||||
if ( ast )
|
||||
return { rcast( AST*, ast)->Front };
|
||||
return { nullptr };
|
||||
}
|
||||
Code end()
|
||||
{
|
||||
return { rcast(AST*, ast)->Back->Next };
|
||||
}
|
||||
#pragma endregion Iterator
|
||||
|
||||
AST_Body* ast;
|
||||
};
|
||||
|
||||
struct CodeClass
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 0
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeClass );
|
||||
|
||||
void add_interface( CodeType interface );
|
||||
@ -81,7 +131,7 @@ struct CodeClass
|
||||
|
||||
struct CodeParam
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeParam );
|
||||
|
||||
void append( CodeParam other );
|
||||
@ -92,10 +142,6 @@ struct CodeParam
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeParam );
|
||||
AST* raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
AST_Param* operator->()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
@ -105,115 +151,27 @@ struct CodeParam
|
||||
}
|
||||
return ast;
|
||||
}
|
||||
operator Code()
|
||||
{
|
||||
return { (AST*)ast };
|
||||
}
|
||||
#pragma region Iterator
|
||||
CodeParam begin()
|
||||
{
|
||||
if ( ast )
|
||||
return { ast };
|
||||
|
||||
return { nullptr };
|
||||
}
|
||||
CodeParam end()
|
||||
{
|
||||
// return { (AST_Param*) rcast( AST*, ast)->Last };
|
||||
return { nullptr };
|
||||
}
|
||||
operator Code() { return { (AST*)ast }; }
|
||||
CodeParam operator*() { return * this; }
|
||||
CodeParam& operator++();
|
||||
CodeParam operator*()
|
||||
{
|
||||
return * this;
|
||||
}
|
||||
#pragma endregion Iterator
|
||||
|
||||
AST_Param* ast;
|
||||
};
|
||||
|
||||
struct CodeSpecifiers
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeSpecifiers );
|
||||
|
||||
bool append( SpecifierT spec )
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( raw()->NumEntries == AST_ArrSpecs_Cap )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap );
|
||||
return false;
|
||||
}
|
||||
|
||||
raw()->ArrSpecs[ raw()->NumEntries ] = spec;
|
||||
raw()->NumEntries++;
|
||||
return true;
|
||||
}
|
||||
s32 has( SpecifierT spec )
|
||||
{
|
||||
for ( s32 idx = 0; idx < raw()->NumEntries; idx++ )
|
||||
{
|
||||
if ( raw()->ArrSpecs[ idx ] == spec )
|
||||
return idx;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
s32 remove( SpecifierT to_remove )
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( raw()->NumEntries == AST_ArrSpecs_Cap )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap );
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 result = -1;
|
||||
|
||||
s32 curr = 0;
|
||||
s32 next = 0;
|
||||
for(; next < raw()->NumEntries; ++ curr, ++ next)
|
||||
{
|
||||
SpecifierT spec = raw()->ArrSpecs[next];
|
||||
if (spec == to_remove)
|
||||
{
|
||||
result = next;
|
||||
|
||||
next ++;
|
||||
if (next >= raw()->NumEntries)
|
||||
break;
|
||||
|
||||
spec = raw()->ArrSpecs[next];
|
||||
}
|
||||
|
||||
raw()->ArrSpecs[ curr ] = spec;
|
||||
}
|
||||
|
||||
if (result > -1) {
|
||||
raw()->NumEntries --;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
bool append( SpecifierT spec ) { return GEN_NS append(* this, spec); }
|
||||
s32 has( SpecifierT spec ) { return GEN_NS has(* this, spec); }
|
||||
s32 remove( SpecifierT to_remove ) { return GEN_NS remove(* this, to_remove); }
|
||||
String to_string() { return GEN_NS to_string(* this ); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeSpecifiers);
|
||||
AST* raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
operator Code() { return { (AST*) ast }; }
|
||||
AST_Specifiers* operator->()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
@ -223,30 +181,13 @@ struct CodeSpecifiers
|
||||
}
|
||||
return ast;
|
||||
}
|
||||
operator Code()
|
||||
{
|
||||
return { (AST*) ast };
|
||||
}
|
||||
#pragma region Iterator
|
||||
SpecifierT* begin()
|
||||
{
|
||||
if ( ast )
|
||||
return & raw()->ArrSpecs[0];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
SpecifierT* end()
|
||||
{
|
||||
return raw()->ArrSpecs + raw()->NumEntries;
|
||||
}
|
||||
#pragma endregion Iterator
|
||||
|
||||
AST_Specifiers* ast;
|
||||
};
|
||||
|
||||
struct CodeStruct
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeStruct );
|
||||
|
||||
void add_interface( CodeType interface );
|
||||
@ -257,14 +198,7 @@ struct CodeStruct
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeStruct );
|
||||
AST* raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
operator Code()
|
||||
{
|
||||
return * rcast( Code*, this );
|
||||
}
|
||||
operator Code() { return * rcast( Code*, this ); }
|
||||
AST_Struct* operator->()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
@ -279,13 +213,12 @@ struct CodeStruct
|
||||
|
||||
struct CodeAttributes
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code(CodeAttributes);
|
||||
String to_string();
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeAttributes);
|
||||
AST *raw();
|
||||
operator Code();
|
||||
AST_Attributes *operator->();
|
||||
AST_Attributes *ast;
|
||||
@ -295,13 +228,12 @@ struct CodeAttributes
|
||||
|
||||
struct CodeComment
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code(CodeComment);
|
||||
String to_string();
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeComment);
|
||||
AST *raw();
|
||||
operator Code();
|
||||
AST_Comment *operator->();
|
||||
AST_Comment *ast;
|
||||
@ -309,16 +241,15 @@ struct CodeComment
|
||||
|
||||
struct CodeConstructor
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeConstructor );
|
||||
|
||||
String to_string();
|
||||
void to_string_def( String& result );
|
||||
void to_string_fwd( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeConstructor);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Constructor* operator->();
|
||||
AST_Constructor* ast;
|
||||
@ -326,15 +257,14 @@ struct CodeConstructor
|
||||
|
||||
struct CodeDefine
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeDefine );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeDefine);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Define* operator->();
|
||||
AST_Define* ast;
|
||||
@ -342,16 +272,15 @@ struct CodeDefine
|
||||
|
||||
struct CodeDestructor
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeDestructor );
|
||||
|
||||
String to_string();
|
||||
void to_string_def( String& result );
|
||||
void to_string_fwd( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this, & result); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeDestructor);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Destructor* operator->();
|
||||
AST_Destructor* ast;
|
||||
@ -359,18 +288,17 @@ struct CodeDestructor
|
||||
|
||||
struct CodeEnum
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeEnum );
|
||||
|
||||
String to_string();
|
||||
void to_string_def( String& result );
|
||||
void to_string_fwd( String& result );
|
||||
void to_string_class_def( String& result );
|
||||
void to_string_class_fwd( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this); }
|
||||
void to_string_class_def( String& result ) { return GEN_NS to_string_class_def(* this); }
|
||||
void to_string_class_fwd( String& result ) { return GEN_NS to_string_class_fwd(* this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeEnum);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Enum* operator->();
|
||||
AST_Enum* ast;
|
||||
@ -378,13 +306,12 @@ struct CodeEnum
|
||||
|
||||
struct CodeExec
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code(CodeExec);
|
||||
String to_string();
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeExec);
|
||||
AST *raw();
|
||||
operator Code();
|
||||
AST_Exec *operator->();
|
||||
AST_Exec *ast;
|
||||
@ -598,14 +525,13 @@ struct CodeExpr_UnaryPostfix
|
||||
|
||||
struct CodeExtern
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeExtern );
|
||||
|
||||
void to_string( String& result );
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeExtern);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Extern* operator->();
|
||||
AST_Extern* ast;
|
||||
@ -613,15 +539,14 @@ struct CodeExtern
|
||||
|
||||
struct CodeInclude
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeInclude );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeInclude);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Include* operator->();
|
||||
AST_Include* ast;
|
||||
@ -629,15 +554,14 @@ struct CodeInclude
|
||||
|
||||
struct CodeFriend
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeFriend );
|
||||
|
||||
String to_string();
|
||||
void to_string( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string( String& result ) { return GEN_NS to_string(* this, & result); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeFriend);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Friend* operator->();
|
||||
AST_Friend* ast;
|
||||
@ -645,16 +569,15 @@ struct CodeFriend
|
||||
|
||||
struct CodeFn
|
||||
{
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES || 1
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
Using_Code( CodeFn );
|
||||
|
||||
String to_string();
|
||||
void to_string_def( String& result );
|
||||
void to_string_fwd( String& result );
|
||||
String to_string() { return GEN_NS to_string(* this); }
|
||||
void to_string_def( String& result ) { return GEN_NS to_string_def(* this); }
|
||||
void to_string_fwd( String& result ) { return GEN_NS to_string_fwd(* this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeFn);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Fn* operator->();
|
||||
AST_Fn* ast;
|
||||
@ -670,7 +593,6 @@ struct CodeModule
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeModule);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Module* operator->();
|
||||
AST_Module* ast;
|
||||
@ -686,7 +608,6 @@ struct CodeNS
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeNS);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_NS* operator->();
|
||||
AST_NS* ast;
|
||||
@ -703,7 +624,6 @@ struct CodeOperator
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeOperator);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Operator* operator->();
|
||||
AST_Operator* ast;
|
||||
@ -720,7 +640,6 @@ struct CodeOpCast
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeOpCast);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_OpCast* operator->();
|
||||
AST_OpCast* ast;
|
||||
@ -736,7 +655,6 @@ struct CodePragma
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodePragma );
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Pragma* operator->();
|
||||
AST_Pragma* ast;
|
||||
@ -757,7 +675,6 @@ struct CodePreprocessCond
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodePreprocessCond );
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_PreprocessCond* operator->();
|
||||
AST_PreprocessCond* ast;
|
||||
@ -957,7 +874,6 @@ struct CodeTemplate
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeTemplate );
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Template* operator->();
|
||||
AST_Template* ast;
|
||||
@ -973,7 +889,6 @@ struct CodeType
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeType );
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Type* operator->();
|
||||
AST_Type* ast;
|
||||
@ -989,7 +904,6 @@ struct CodeTypedef
|
||||
#endif
|
||||
|
||||
Using_CodeOps( CodeTypedef );
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Typedef* operator->();
|
||||
AST_Typedef* ast;
|
||||
@ -1005,7 +919,6 @@ struct CodeUnion
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeUnion);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Union* operator->();
|
||||
AST_Union* ast;
|
||||
@ -1022,7 +935,6 @@ struct CodeUsing
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeUsing);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Using* operator->();
|
||||
AST_Using* ast;
|
||||
@ -1038,7 +950,6 @@ struct CodeVar
|
||||
#endif
|
||||
|
||||
Using_CodeOps(CodeVar);
|
||||
AST* raw();
|
||||
operator Code();
|
||||
AST_Var* operator->();
|
||||
AST_Var* ast;
|
||||
@ -1053,4 +964,5 @@ void to_string_export( CodeBody body, String& result ) { return to_string_export
|
||||
#endif
|
||||
|
||||
#endif //if ! GEN_COMPILER_C
|
||||
|
||||
#pragma endregion Code Types
|
||||
|
@ -55,11 +55,6 @@ inline CodeAttributes::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeAttributes::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeAttributes::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -91,11 +86,6 @@ inline CodeComment::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeComment::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeComment::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -127,11 +117,6 @@ inline CodeConstructor::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeConstructor::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeConstructor::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -179,11 +164,6 @@ inline CodeDefine::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeDefine::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeDefine::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -215,11 +195,6 @@ inline CodeDestructor::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeDestructor::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeDestructor::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -251,11 +226,6 @@ inline CodeEnum::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeEnum::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeEnum::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -287,11 +257,6 @@ inline CodeExec::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeExec::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeExec::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -323,11 +288,6 @@ inline CodeExtern::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeExtern::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeExtern::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -359,11 +319,6 @@ inline CodeFriend::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeFriend::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeFriend::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -395,11 +350,6 @@ inline CodeFn::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeFn::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeFn::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -431,11 +381,6 @@ inline CodeInclude::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeInclude::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeInclude::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -467,11 +412,6 @@ inline CodeModule::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeModule::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeModule::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -503,11 +443,6 @@ inline CodeNS::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeNS::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeNS::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -539,11 +474,6 @@ inline CodeOperator::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeOperator::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeOperator::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -575,11 +505,6 @@ inline CodeOpCast::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeOpCast::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeOpCast::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -627,11 +552,6 @@ inline CodePragma::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodePragma::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodePragma::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -663,11 +583,6 @@ inline CodePreprocessCond::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodePreprocessCond::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodePreprocessCond::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -731,11 +646,6 @@ inline CodeTemplate::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeTemplate::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeTemplate::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -767,11 +677,6 @@ inline CodeType::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeType::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeType::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -803,11 +708,6 @@ inline CodeTypedef::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeTypedef::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeTypedef::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -839,11 +739,6 @@ inline CodeUnion::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeUnion::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeUnion::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -875,11 +770,6 @@ inline CodeUsing::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeUsing::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeUsing::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
@ -911,11 +801,6 @@ inline CodeVar::operator bool()
|
||||
return ast != nullptr;
|
||||
}
|
||||
|
||||
inline AST* CodeVar::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
|
||||
inline CodeVar::operator Code()
|
||||
{
|
||||
return *rcast( Code*, this );
|
||||
|
@ -89,7 +89,6 @@ AST::operator Code()
|
||||
}
|
||||
|
||||
#pragma region Code
|
||||
|
||||
inline
|
||||
char const* debug_str( Code code )
|
||||
{
|
||||
@ -98,7 +97,6 @@ char const* debug_str( Code code )
|
||||
|
||||
return debug_str( code.ast );
|
||||
}
|
||||
|
||||
inline
|
||||
Code duplicate( Code code )
|
||||
{
|
||||
@ -110,7 +108,6 @@ Code duplicate( Code code )
|
||||
|
||||
return { duplicate(code.ast) };
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_body(Code code)
|
||||
{
|
||||
@ -120,7 +117,6 @@ bool is_body(Code code)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_equal( Code self, Code other )
|
||||
{
|
||||
@ -132,13 +128,11 @@ bool is_equal( Code self, Code other )
|
||||
}
|
||||
return is_equal( self.ast, other.ast );
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_valid(Code self)
|
||||
{
|
||||
return self.ast != nullptr && self.ast->Type != CodeT::Invalid;
|
||||
}
|
||||
|
||||
inline
|
||||
void set_global(Code self)
|
||||
{
|
||||
@ -150,7 +144,6 @@ void set_global(Code self)
|
||||
|
||||
self->Parent = Code_Global.ast;
|
||||
}
|
||||
|
||||
inline
|
||||
Code& Code::operator ++()
|
||||
{
|
||||
@ -159,9 +152,9 @@ Code& Code::operator ++()
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#pragma endregion Code
|
||||
|
||||
#pragma region CodeBody
|
||||
inline
|
||||
void append( CodeBody self, Code other )
|
||||
{
|
||||
@ -174,15 +167,28 @@ void append( CodeBody self, Code other )
|
||||
|
||||
append( rcast(AST*, self.ast), other.ast );
|
||||
}
|
||||
|
||||
inline
|
||||
void append( CodeBody self, CodeBody body )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
|
||||
for ( Code entry : body ) {
|
||||
append( self, entry );
|
||||
}
|
||||
}
|
||||
inline
|
||||
Code begin( CodeBody body) {
|
||||
if ( body.ast )
|
||||
return { rcast( AST*, body.ast)->Front };
|
||||
return { nullptr };
|
||||
}
|
||||
inline
|
||||
Code end(CodeBody body ){
|
||||
return { rcast(AST*, body.ast)->Back->Next };
|
||||
}
|
||||
#pragma endregion CodeBody
|
||||
|
||||
#pragma region CodeClass
|
||||
inline
|
||||
void add_interface( CodeClass self, CodeType type )
|
||||
{
|
||||
@ -203,11 +209,14 @@ void add_interface( CodeClass self, CodeType type )
|
||||
|
||||
possible_slot.ast = type.ast;
|
||||
}
|
||||
#pragma endregion CodeClass
|
||||
|
||||
#pragma region CodeParam
|
||||
inline
|
||||
void CodeParam::append( CodeParam other )
|
||||
void append( CodeParam appendee, CodeParam other )
|
||||
{
|
||||
AST* self = (AST*) ast;
|
||||
GEN_ASSERT(appendee.ast != nullptr);
|
||||
AST* self = cast(Code, appendee).ast;
|
||||
AST* entry = (AST*) other.ast;
|
||||
|
||||
if ( entry->Parent )
|
||||
@ -227,44 +236,144 @@ void CodeParam::append( CodeParam other )
|
||||
self->Last = entry;
|
||||
self->NumEntries++;
|
||||
}
|
||||
|
||||
inline
|
||||
CodeParam CodeParam::get( s32 idx )
|
||||
CodeParam get(CodeParam self, s32 idx )
|
||||
{
|
||||
CodeParam param = *this;
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
CodeParam param = * self;
|
||||
do
|
||||
{
|
||||
if ( ! ++ param )
|
||||
return { nullptr };
|
||||
|
||||
param = { (AST_Param*) param.raw()->Next };
|
||||
param = { (AST_Param*) cast(Code, param)->Next };
|
||||
}
|
||||
while ( --idx );
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
inline
|
||||
bool CodeParam::has_entries()
|
||||
bool has_entries(CodeParam self)
|
||||
{
|
||||
return ast->NumEntries > 0;
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
|
||||
inline
|
||||
CodeParam& CodeParam::operator ++()
|
||||
{
|
||||
ast = ast->Next.ast;
|
||||
return * this;
|
||||
}
|
||||
|
||||
inline
|
||||
void CodeStruct::add_interface( CodeType type )
|
||||
CodeParam begin(CodeParam params)
|
||||
{
|
||||
CodeType possible_slot = ast->ParentType;
|
||||
if ( params.ast )
|
||||
return { params.ast };
|
||||
|
||||
return { nullptr };
|
||||
}
|
||||
inline
|
||||
CodeParam end(CodeParam params)
|
||||
{
|
||||
// return { (AST_Param*) rcast( AST*, ast)->Last };
|
||||
return { nullptr };
|
||||
}
|
||||
#pragma endregion CodeParam
|
||||
|
||||
#pragma region CodeSpecifiers
|
||||
inline
|
||||
bool append(CodeSpecifiers self, SpecifierT spec )
|
||||
{
|
||||
if ( self.ast == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return false;
|
||||
}
|
||||
if ( self->NumEntries == AST_ArrSpecs_Cap )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap );
|
||||
return false;
|
||||
}
|
||||
|
||||
self->ArrSpecs[ self->NumEntries ] = spec;
|
||||
self->NumEntries++;
|
||||
return true;
|
||||
}
|
||||
inline
|
||||
s32 has(CodeSpecifiers self, SpecifierT spec)
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
|
||||
if ( self->ArrSpecs[ idx ] == spec )
|
||||
return idx;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline
|
||||
s32 remove( CodeSpecifiers self, SpecifierT to_remove )
|
||||
{
|
||||
AST_Specifiers* ast = self.ast;
|
||||
if ( ast == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return -1;
|
||||
}
|
||||
if ( self->NumEntries == AST_ArrSpecs_Cap )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap );
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 result = -1;
|
||||
|
||||
s32 curr = 0;
|
||||
s32 next = 0;
|
||||
for(; next < self->NumEntries; ++ curr, ++ next)
|
||||
{
|
||||
SpecifierT spec = self->ArrSpecs[next];
|
||||
if (spec == to_remove)
|
||||
{
|
||||
result = next;
|
||||
|
||||
next ++;
|
||||
if (next >= self->NumEntries)
|
||||
break;
|
||||
|
||||
spec = self->ArrSpecs[next];
|
||||
}
|
||||
|
||||
self->ArrSpecs[ curr ] = spec;
|
||||
}
|
||||
|
||||
if (result > -1) {
|
||||
self->NumEntries --;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
inline
|
||||
SpecifierT* begin(CodeSpecifiers self)
|
||||
{
|
||||
if ( self.ast )
|
||||
return & self->ArrSpecs[0];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
inline
|
||||
SpecifierT* end(CodeSpecifiers self)
|
||||
{
|
||||
return self->ArrSpecs + self->NumEntries;
|
||||
}
|
||||
#pragma endregion CodeSpecifiers
|
||||
|
||||
#pragma region CodeStruct
|
||||
inline
|
||||
void add_interface(CodeStruct self, CodeType type )
|
||||
{
|
||||
CodeType possible_slot = self->ParentType;
|
||||
if ( possible_slot.ast )
|
||||
{
|
||||
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
||||
ast->ParentAccess = AccessSpec_Public;
|
||||
self->ParentAccess = AccessSpec_Public;
|
||||
// If your planning on adding a proper parent,
|
||||
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
||||
}
|
||||
@ -276,7 +385,9 @@ void CodeStruct::add_interface( CodeType type )
|
||||
|
||||
possible_slot.ast = type.ast;
|
||||
}
|
||||
#pragma endregion Code
|
||||
|
||||
#pragma region Interface
|
||||
inline
|
||||
CodeBody def_body( CodeT type )
|
||||
{
|
||||
@ -319,3 +430,4 @@ StrC token_fmt_impl( ssize num, ... )
|
||||
|
||||
return { result, buf };
|
||||
}
|
||||
#pragma endregion Interface
|
||||
|
@ -180,7 +180,7 @@ void define_constants()
|
||||
|
||||
# define def_constant_spec( Type_, ... ) \
|
||||
spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \
|
||||
spec_##Type_.set_global();
|
||||
set_global(spec_##Type_);
|
||||
|
||||
# pragma push_macro("forceinline")
|
||||
# pragma push_macro("global")
|
||||
@ -218,7 +218,7 @@ void define_constants()
|
||||
def_constant_spec( volatile, ESpecifier::Volatile)
|
||||
|
||||
spec_local_persist = def_specifiers( 1, ESpecifier::Local_Persist );
|
||||
spec_local_persist.set_global();
|
||||
set_global(spec_local_persist);
|
||||
|
||||
# pragma pop_macro("forceinline")
|
||||
# pragma pop_macro("global")
|
||||
|
@ -31,7 +31,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
} \
|
||||
if ( params_code->Type != ECode::Parameters ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", params_code.debug_str()); \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code)); \
|
||||
return OpValidateResult::Fail; \
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
"param types: %s\n" \
|
||||
"return type: %s", \
|
||||
to_str(op).Ptr, \
|
||||
params_code.debug_str(), \
|
||||
debug_str(params_code), \
|
||||
ret_type.debug_str() \
|
||||
); \
|
||||
return OpValidateResult::Fail; \
|
||||
@ -73,7 +73,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s does not support non-member definition (more than one parameter provided) - %s",
|
||||
to_str(op),
|
||||
params_code.debug_str()
|
||||
debug_str(params_code)
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
@ -104,7 +104,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
log_failure("gen::def_operator: operator%s may not be defined with more than two parametes - param count; %d\n%s"
|
||||
, to_str(op)
|
||||
, params_code->NumEntries
|
||||
, params_code.debug_str()
|
||||
, debug_str(params_code)
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
@ -119,7 +119,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s params code provided is not of Parameters type - %s"
|
||||
, to_str(op)
|
||||
, params_code.debug_str()
|
||||
, debug_str(params_code)
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
@ -137,7 +137,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
case 2:
|
||||
check_param_eq_ret();
|
||||
|
||||
if ( ! params_code.get(1).is_equal( t_int ) )
|
||||
if ( ! is_equal(get(params_code, 1), t_int ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s requires second parameter of non-member definition to be int for post-decrement",
|
||||
@ -166,7 +166,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != ECode::Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", params_code.debug_str());
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code));
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, params_code.debug_str()
|
||||
, debug_str(params_code)
|
||||
, ret_type.debug_str()
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
@ -199,7 +199,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
#if 0
|
||||
if ( ! ret_type.is_equal( t_bool) )
|
||||
{
|
||||
log_failure( "gen::def_operator: return type is not a boolean - %s", params_code.debug_str() );
|
||||
log_failure( "gen::def_operator: return type is not a boolean - %s", debug_str(params_code) );
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
#endif
|
||||
@ -211,7 +211,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != ECode::Parameters )
|
||||
{
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", params_code.debug_str() );
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", debug_str(params_code) );
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, params_code.debug_str()
|
||||
, debug_str(params_code)
|
||||
, ret_type.debug_str()
|
||||
);
|
||||
return OpValidateResult::Fail;
|
||||
@ -277,7 +277,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
{
|
||||
if ( params_code->Type != ECode::Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", params_code.debug_str());
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", debug_str(params_code));
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ OpValidateResult operator__validate( OperatorT op, CodeParam params_code, CodeTy
|
||||
case PtrToMemOfPtr:
|
||||
if ( params_code )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s expects no paramters - %s", to_str(op), params_code.debug_str());
|
||||
log_failure("gen::def_operator: operator%s expects no paramters - %s", to_str(op), debug_str(params_code));
|
||||
return OpValidateResult::Fail;
|
||||
}
|
||||
break;
|
||||
@ -501,7 +501,7 @@ CodeConstructor def_constructor( CodeParam params, Code initializer_list, Code b
|
||||
|
||||
if ( params && params->Type != Parameters )
|
||||
{
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", params.debug_str());
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", debug_str(params));
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ CodeClass def_class( StrC name
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_class: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -647,7 +647,7 @@ CodeDestructor def_destructor( Code body, CodeSpecifiers specifiers )
|
||||
|
||||
if ( specifiers && specifiers->Type != Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", specifiers.debug_str() );
|
||||
log_failure( "gen::def_destructor: specifiers was not a 'Specifiers' type: %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -697,7 +697,7 @@ CodeEnum def_enum( StrC name
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -828,25 +828,25 @@ CodeFn def_function( StrC name
|
||||
|
||||
if ( params && params->Type != Parameters )
|
||||
{
|
||||
log_failure( "gen::def_function: params was not a `Parameters` type: %s", params.debug_str() );
|
||||
log_failure( "gen::def_function: params was not a `Parameters` type: %s", debug_str(params) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( ret_type && ret_type->Type != Typename )
|
||||
{
|
||||
log_failure( "gen::def_function: ret_type was not a Typename: %s", ret_type.debug_str() );
|
||||
log_failure( "gen::def_function: ret_type was not a Typename: %s", debug_str(ret_type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", specifiers.debug_str() );
|
||||
log_failure( "gen::def_function: specifiers was not a `Specifiers` type: %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_function: attributes was not a `PlatformAttributes` type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -967,13 +967,13 @@ CodeOperator def_operator( OperatorT op, StrC nspace
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_operator: PlatformAttributes was provided but its not of attributes type: %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_operator: Specifiers was provided but its not of specifiers type: %s", specifiers.debug_str() );
|
||||
log_failure( "gen::def_operator: Specifiers was provided but its not of specifiers type: %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1167,7 +1167,7 @@ CodeSpecifiers def_specifier( SpecifierT spec )
|
||||
CodeSpecifiers
|
||||
result = (CodeSpecifiers) make_code();
|
||||
result->Type = ECode::Specifiers;
|
||||
result.append( spec );
|
||||
append(result, spec );
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1183,7 +1183,7 @@ CodeStruct def_struct( StrC name
|
||||
|
||||
if ( attributes && attributes->Type != PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1229,7 +1229,7 @@ CodeStruct def_struct( StrC name
|
||||
{
|
||||
for (s32 idx = 0; idx < num_interfaces; idx++ )
|
||||
{
|
||||
result.add_interface( interfaces[idx] );
|
||||
add_interface(result, interfaces[idx] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1242,7 +1242,7 @@ CodeTemplate def_template( CodeParam params, Code declaration, ModuleFlag mflags
|
||||
|
||||
if ( params && params->Type != ECode::Parameters )
|
||||
{
|
||||
log_failure( "gen::def_template: params is not of parameters type - %s", params.debug_str() );
|
||||
log_failure( "gen::def_template: params is not of parameters type - %s", debug_str(params) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1387,7 +1387,7 @@ CodeUnion def_union( StrC name, Code body, CodeAttributes attributes, ModuleFlag
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_union: attributes was not a PlatformAttributes type - %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1424,7 +1424,7 @@ CodeUsing def_using( StrC name, CodeType type
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_using: attributes was not a PlatformAttributes type - %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1464,13 +1464,13 @@ CodeVar def_variable( CodeType type, StrC name, Code value
|
||||
|
||||
if ( attributes && attributes->Type != ECode::PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", attributes.debug_str() );
|
||||
log_failure( "gen::def_variable: attributes was not a `PlatformAttributes` type - %s", debug_str(attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != ECode::Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", specifiers.debug_str() );
|
||||
log_failure( "gen::def_variable: specifiers was not a `Specifiers` type - %s", debug_str(specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -2077,7 +2077,7 @@ CodeParam def_params( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
CodeParam result = (CodeParam) param.duplicate();
|
||||
CodeParam result = (CodeParam) duplicate(param);
|
||||
|
||||
while ( -- num )
|
||||
{
|
||||
@ -2090,7 +2090,7 @@ CodeParam def_params( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
result.append( param );
|
||||
append(result, param );
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
@ -2110,11 +2110,11 @@ CodeParam def_params( s32 num, CodeParam* codes )
|
||||
\
|
||||
if (current->Type != Parameters ) \
|
||||
{ \
|
||||
log_failure("gen::def_params: Code in coes array is not of paramter type - %s", current.debug_str() ); \
|
||||
log_failure("gen::def_params: Code in coes array is not of paramter type - %s", debug_str(current) ); \
|
||||
return InvalidCode; \
|
||||
}
|
||||
|
||||
CodeParam current = (CodeParam) codes->duplicate();
|
||||
CodeParam current = (CodeParam)duplicate(* codes);
|
||||
check_current();
|
||||
|
||||
CodeParam
|
||||
@ -2126,7 +2126,7 @@ CodeParam def_params( s32 num, CodeParam* codes )
|
||||
while( codes++, current = * codes, num--, num > 0 )
|
||||
{
|
||||
check_current();
|
||||
result.append( current );
|
||||
append(result, current );
|
||||
}
|
||||
# undef check_current
|
||||
|
||||
@ -2157,7 +2157,7 @@ CodeSpecifiers def_specifiers( s32 num, ... )
|
||||
{
|
||||
SpecifierT type = (SpecifierT)va_arg(va, int);
|
||||
|
||||
result.append( type );
|
||||
append(result, type );
|
||||
}
|
||||
while ( --num, num );
|
||||
va_end(va);
|
||||
@ -2186,7 +2186,7 @@ CodeSpecifiers def_specifiers( s32 num, SpecifierT* specs )
|
||||
s32 idx = 0;
|
||||
do
|
||||
{
|
||||
result.append( specs[idx] );
|
||||
append(result, specs[idx] );
|
||||
idx++;
|
||||
}
|
||||
while ( --num, num );
|
||||
|
@ -1440,7 +1440,7 @@ CodeFn parse_function_after_name(
|
||||
continue;
|
||||
}
|
||||
|
||||
specifiers.append( ESpecifier::to_type(currtok) );
|
||||
append(specifiers, ESpecifier::to_type(currtok) );
|
||||
eat( currtok.Type );
|
||||
}
|
||||
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>
|
||||
@ -1460,7 +1460,7 @@ CodeFn parse_function_after_name(
|
||||
else if ( check(TokType::Operator) && currtok.Text[0] == '=' )
|
||||
{
|
||||
eat(TokType::Operator);
|
||||
specifiers.append( ESpecifier::Pure );
|
||||
append(specifiers, ESpecifier::Pure );
|
||||
|
||||
eat( TokType::Number);
|
||||
Token stmt_end = currtok;
|
||||
@ -2443,7 +2443,7 @@ CodeOperator parse_operator_after_ret_type(
|
||||
continue;
|
||||
}
|
||||
|
||||
specifiers.append( ESpecifier::to_type(currtok) );
|
||||
append(specifiers, ESpecifier::to_type(currtok) );
|
||||
eat( currtok.Type );
|
||||
}
|
||||
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers>
|
||||
@ -2760,7 +2760,7 @@ CodeParam parse_params( bool use_template_capture )
|
||||
if ( check( TokType::Varadic_Argument ) )
|
||||
{
|
||||
eat( TokType::Varadic_Argument );
|
||||
result.append( param_varadic );
|
||||
append(result, param_varadic );
|
||||
continue;
|
||||
// ( <Macro> <ValueType> <Name> = <Expression>, ...
|
||||
}
|
||||
@ -2864,7 +2864,7 @@ CodeParam parse_params( bool use_template_capture )
|
||||
if ( value )
|
||||
param->Value = value;
|
||||
|
||||
result.append( param );
|
||||
append(result, param );
|
||||
}
|
||||
|
||||
if ( ! use_template_capture )
|
||||
@ -3288,7 +3288,7 @@ CodeVar parse_variable_declaration_list()
|
||||
"(Parser will add and continue to specifiers, but will most likely fail to compile)\n%s"
|
||||
, Context.to_string() );
|
||||
|
||||
specifiers.append( spec );
|
||||
append(specifiers, spec );
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3310,7 +3310,7 @@ CodeVar parse_variable_declaration_list()
|
||||
// eat(currtok.Type);
|
||||
|
||||
if ( specifiers )
|
||||
specifiers.append( spec );
|
||||
append(specifiers, spec );
|
||||
else
|
||||
specifiers = def_specifier( spec );
|
||||
}
|
||||
@ -3450,7 +3450,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
|
||||
if ( check( TokType::Spec_Virtual ) )
|
||||
{
|
||||
if ( specifiers )
|
||||
specifiers.append( ESpecifier::Virtual );
|
||||
append(specifiers, ESpecifier::Virtual );
|
||||
else
|
||||
specifiers = def_specifier( ESpecifier::Virtual );
|
||||
eat( TokType::Spec_Virtual );
|
||||
@ -3493,7 +3493,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
|
||||
eat( TokType::Number );
|
||||
// <Virtual Specifier> ~<Name>() = 0
|
||||
|
||||
specifiers.append( ESpecifier::Pure );
|
||||
append(specifiers, ESpecifier::Pure );
|
||||
}
|
||||
else if ( left && str_compare( next.Text, "default", sizeof("default") - 1 ) == 0)
|
||||
{
|
||||
@ -4148,7 +4148,7 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers )
|
||||
specifiers = def_specifier( ESpecifier::Const );
|
||||
|
||||
else
|
||||
specifiers.append( ESpecifier::Const );
|
||||
append(specifiers, ESpecifier::Const );
|
||||
|
||||
eat( TokType::Spec_Const );
|
||||
}
|
||||
|
@ -185,9 +185,9 @@ void clear(String& str);
|
||||
void free(String& str);
|
||||
#endif
|
||||
|
||||
inline char* begin(String& str) { return str; }
|
||||
inline char* end(String& str) { return scast(char*, str) + length(str); }
|
||||
inline char* next(String& str) { return scast(char*, str) + 1; }
|
||||
inline char* begin(String str) { return str; }
|
||||
inline char* end(String str) { return scast(char*, str) + length(str); }
|
||||
inline char* next(String str) { return scast(char*, str) + 1; }
|
||||
|
||||
inline
|
||||
usize string_grow_formula(usize value) {
|
||||
|
@ -373,11 +373,6 @@ CodeBody gen_ast_inlines()
|
||||
);
|
||||
|
||||
char const* codetype_impl_tmpl = stringize(
|
||||
inline
|
||||
AST* Code<typename>::raw()
|
||||
{
|
||||
return rcast( AST*, ast );
|
||||
}
|
||||
inline
|
||||
Code<typename>::operator Code()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user