2023-08-28 21:03:08 -07:00
|
|
|
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
2023-08-21 17:30:13 -07:00
|
|
|
#pragma once
|
2023-08-21 20:02:20 -07:00
|
|
|
#include "static_data.cpp"
|
2023-08-28 20:46:50 -07:00
|
|
|
#endif
|
2023-08-21 17:30:13 -07:00
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
// This serializes all the data-members in a "debug" format, where each member is printed with its associated value.
|
2024-12-12 09:55:15 -08:00
|
|
|
Str code_debug_str(Code self)
|
2023-08-23 18:19:31 -07:00
|
|
|
{
|
2024-12-01 15:50:37 -08:00
|
|
|
GEN_ASSERT(self != nullptr);
|
2024-12-13 16:16:52 -08:00
|
|
|
StrBuilder result_stack = strbuilder_make_reserve( _ctx->Allocator_Temp, kilobytes(1) );
|
2024-12-12 09:55:15 -08:00
|
|
|
StrBuilder* result = & result_stack;
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Parent )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tParent : %S %S", code_type_str(self->Parent), self->Name.Len ? self->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
else
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tParent : %S", txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tName : %S", self->Name.Len ? self->Name : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tType : %S", code_type_str(self) );
|
|
|
|
strbuilder_append_fmt( result, "\n\tModule Flags : %S", module_flag_to_str( self->ModuleFlags ) );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-01 15:50:37 -08:00
|
|
|
switch ( self->Type )
|
2023-08-23 18:19:31 -07:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Invalid:
|
|
|
|
case CT_NewLine:
|
|
|
|
case CT_Access_Private:
|
|
|
|
case CT_Access_Protected:
|
|
|
|
case CT_Access_Public:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Untyped:
|
|
|
|
case CT_Execution:
|
|
|
|
case CT_Comment:
|
|
|
|
case CT_PlatformAttributes:
|
|
|
|
case CT_Preprocess_Include:
|
|
|
|
case CT_Preprocess_Pragma:
|
|
|
|
case CT_Preprocess_If:
|
|
|
|
case CT_Preprocess_ElIf:
|
|
|
|
case CT_Preprocess_Else:
|
|
|
|
case CT_Preprocess_IfDef:
|
|
|
|
case CT_Preprocess_IfNotDef:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tContent: %S", self->Content );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-14 15:49:41 -08:00
|
|
|
case CT_Preprocess_Define:
|
|
|
|
// TODO(ED): Needs implementaton
|
|
|
|
log_failure("code_debug_str: NOT IMPLEMENTED for CT_Preprocess_Define");
|
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class:
|
|
|
|
case CT_Struct:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParentAccess: %S", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParentType : %S", self->ParentType ? code_type_str(self->ParentType) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class_Fwd:
|
|
|
|
case CT_Struct_Fwd:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-25 09:12:11 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParentAccess: %S", self->ParentType ? access_spec_to_str( self->ParentAccess ) : txt("No Parent") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParentType : %S", self->ParentType ? code_type_str(self->ParentType) : txt("Null") );
|
2023-09-25 09:12:11 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Constructor:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tInitializerList: %S", self->InitializerList ? strbuilder_to_str( code_to_strbuilder(self->InitializerList) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Constructor_Fwd:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-25 09:12:11 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tInitializerList: %S", self->InitializerList ? strbuilder_to_str( code_to_strbuilder(self->InitializerList) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params) ) : txt("Null") );
|
2023-09-25 09:12:11 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Destructor:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Destructor_Fwd:
|
2023-09-25 09:12:11 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum:
|
|
|
|
case CT_Enum_Class:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Fwd:
|
|
|
|
case CT_Enum_Class_Fwd:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-25 13:42:29 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tUnderlying Type : %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") );
|
2023-09-25 09:12:11 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Extern_Linkage:
|
|
|
|
case CT_Namespace:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tBody: %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Friend:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? strbuilder_to_str( code_to_strbuilder(self->Declaration)) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-08-23 18:19:31 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function_Fwd:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-25 13:42:29 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") );
|
2023-09-25 13:42:29 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Module:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator:
|
|
|
|
case CT_Operator_Member:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tOp : %S", operator_to_str( self->Op ) );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Fwd:
|
|
|
|
case CT_Operator_Member_Fwd:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-25 13:42:29 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tReturnType: %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params) ) : txt("Null") );
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tOp : %S", operator_to_str( self->Op ) );
|
2023-09-25 13:42:29 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Cast:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Cast_Fwd:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-25 13:42:29 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") );
|
2023-09-25 13:42:29 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Parameters:
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
|
|
|
strbuilder_append_fmt( result, "\n\tLast : %S", self->Last->Name );
|
|
|
|
strbuilder_append_fmt( result, "\n\tNext : %S", self->Next->Name );
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-14 15:49:41 -08:00
|
|
|
case CT_Parameters_Define:
|
|
|
|
// TODO(ED): Needs implementaton
|
|
|
|
log_failure("code_debug_str: NOT IMPLEMENTED for CT_Parameters_Define");
|
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Specifiers:
|
2023-09-11 20:22:53 -07:00
|
|
|
{
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNumEntries: %d", self->NumEntries );
|
|
|
|
strbuilder_append_str( result, txt("\n\tArrSpecs: ") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
s32 idx = 0;
|
2024-12-01 15:50:37 -08:00
|
|
|
s32 left = self->NumEntries;
|
2023-09-11 20:22:53 -07:00
|
|
|
while ( left-- )
|
|
|
|
{
|
2024-12-12 09:55:15 -08:00
|
|
|
Str spec = spec_to_str( self->ArrSpecs[idx] );
|
|
|
|
strbuilder_append_fmt( result, "%.*s, ", spec.Len, spec.Ptr );
|
2023-09-11 20:22:53 -07:00
|
|
|
idx++;
|
|
|
|
}
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNextSpecs: %S", self->NextSpecs ? code_debug_str(self->NextSpecs) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Template:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tDeclaration: %S", self->Declaration ? strbuilder_to_str( code_to_strbuilder(self->Declaration)) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Typedef:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Typename:
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tReturnType : %S", self->ReturnType ? strbuilder_to_str( code_to_strbuilder(self->ReturnType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tParams : %S", self->Params ? strbuilder_to_str( code_to_strbuilder(self->Params)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tArrExpr : %S", self->ArrExpr ? strbuilder_to_str( code_to_strbuilder(self->ArrExpr)) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Union:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes: %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBody : %S", self->Body ? code_debug_str(self->Body) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Using:
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tUnderlyingType: %S", self->UnderlyingType ? strbuilder_to_str( code_to_strbuilder(self->UnderlyingType)) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Variable:
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
if ( self->Parent && self->Parent->Type == CT_Variable )
|
2023-09-11 20:22:53 -07:00
|
|
|
{
|
|
|
|
// Its a NextVar
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBitfieldSize: %S", self->BitfieldSize ? strbuilder_to_str( code_to_strbuilder(self->BitfieldSize)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tNextVar : %S", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Prev )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tPrev: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Next )
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tNext: %S %S", code_type_str(self->Prev), self->Prev->Name.Len ? self->Prev->Name : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
strbuilder_append_fmt( result, "\n\tInlineCmt : %S", self->InlineCmt ? self->InlineCmt->Content : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tAttributes : %S", self->Attributes ? strbuilder_to_str( code_to_strbuilder(self->Attributes) ) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tSpecs : %S", self->Specs ? strbuilder_to_str( code_to_strbuilder(self->Specs)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tValueType : %S", self->ValueType ? strbuilder_to_str( code_to_strbuilder(self->ValueType)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tBitfieldSize: %S", self->BitfieldSize ? strbuilder_to_str( code_to_strbuilder(self->BitfieldSize)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tValue : %S", self->Value ? strbuilder_to_str( code_to_strbuilder(self->Value)) : txt("Null") );
|
|
|
|
strbuilder_append_fmt( result, "\n\tNextVar : %S", self->NextVar ? code_debug_str(self->NextVar) : txt("Null") );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
}
|
2023-08-23 18:19:31 -07:00
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
return strbuilder_to_str( * result );
|
2023-08-23 18:19:31 -07:00
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
Code code_duplicate(Code self)
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-02 17:20:30 -08:00
|
|
|
Code result = make_code();
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
void* mem_result = rcast(void*, cast(AST*, result));
|
|
|
|
void* mem_self = rcast(void*, cast(AST*, self));
|
|
|
|
mem_copy( mem_result, mem_self, sizeof( AST ) );
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-12-08 20:10:10 -08:00
|
|
|
result->Parent = NullCode;
|
2023-07-24 14:45:27 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-12-13 11:38:27 -08:00
|
|
|
StrBuilder code_to_strbuilder(Code self)
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-13 16:16:52 -08:00
|
|
|
StrBuilder result = strbuilder_make_str( _ctx->Allocator_Temp, txt("") );
|
2024-12-12 09:55:15 -08:00
|
|
|
code_to_strbuilder_ptr( self, & result );
|
2023-11-19 17:34:46 -08:00
|
|
|
return result;
|
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
void code_to_strbuilder_ptr( Code self, StrBuilder* result )
|
2023-11-19 17:34:46 -08:00
|
|
|
{
|
2024-12-02 00:18:52 -08:00
|
|
|
GEN_ASSERT(self != nullptr);
|
2023-11-19 17:34:46 -08:00
|
|
|
local_persist thread_local
|
|
|
|
char SerializationLevel = 0;
|
2023-11-20 12:09:01 -08:00
|
|
|
|
2024-12-02 00:18:52 -08:00
|
|
|
switch ( self->Type )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Invalid:
|
2023-09-11 20:22:53 -07:00
|
|
|
#ifdef GEN_DONT_ALLOW_INVALID_CODE
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->code_debug_str() : Name );
|
2023-09-11 20:22:53 -07:00
|
|
|
#else
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_fmt( result, "Invalid Code!" );
|
2023-09-11 20:22:53 -07:00
|
|
|
#endif
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_NewLine:
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_str( result, txt("\n"));
|
2023-08-04 13:12:13 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Untyped:
|
|
|
|
case CT_Execution:
|
|
|
|
case CT_Comment:
|
|
|
|
case CT_PlatformAttributes:
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_str( result, self->Content );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Access_Private:
|
|
|
|
case CT_Access_Protected:
|
|
|
|
case CT_Access_Public:
|
2024-12-12 09:55:15 -08:00
|
|
|
strbuilder_append_str( result, self->Name );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2023-11-20 12:09:01 -08:00
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class:
|
2024-12-12 09:55:15 -08:00
|
|
|
class_to_strbuilder_def(cast(CodeClass, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
class_to_strbuilder_fwd(cast(CodeClass, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Constructor:
|
2024-12-12 09:55:15 -08:00
|
|
|
constructor_to_strbuilder_def(cast(CodeConstructor, self), result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Constructor_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
constructor_to_strbuilder_fwd(cast(CodeConstructor, self), result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Destructor:
|
2024-12-12 09:55:15 -08:00
|
|
|
destructor_to_strbuilder_def(cast(CodeDestructor, self), result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Destructor_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
destructor_to_strbuilder_fwd(cast(CodeDestructor, self), result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum:
|
2024-12-12 09:55:15 -08:00
|
|
|
enum_to_strbuilder_def(cast(CodeEnum, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
enum_to_strbuilder_fwd(cast(CodeEnum, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Class:
|
2024-12-12 09:55:15 -08:00
|
|
|
enum_to_strbuilder_class_def(cast(CodeEnum, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Class_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
enum_to_strbuilder_class_fwd(cast(CodeEnum, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Export_Body:
|
2024-12-12 09:55:15 -08:00
|
|
|
body_to_strbuilder_export(cast(CodeBody, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Extern_Linkage:
|
2024-12-13 11:38:27 -08:00
|
|
|
extern_to_strbuilder(cast(CodeExtern, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Friend:
|
2024-12-12 09:55:15 -08:00
|
|
|
friend_to_strbuilder_ref(cast(CodeFriend, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function:
|
2024-12-12 09:55:15 -08:00
|
|
|
fn_to_strbuilder_def(cast(CodeFn, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
fn_to_strbuilder_fwd(cast(CodeFn, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Module:
|
2024-12-12 09:55:15 -08:00
|
|
|
module_to_strbuilder_ref(cast(CodeModule, self), result );
|
2023-11-19 17:34:46 -08:00
|
|
|
break;
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Namespace:
|
2024-12-12 09:55:15 -08:00
|
|
|
namespace_to_strbuilder_ref(cast(CodeNS, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator:
|
|
|
|
case CT_Operator_Member:
|
2024-12-12 09:55:15 -08:00
|
|
|
code_op_to_strbuilder_def(cast(CodeOperator, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Fwd:
|
|
|
|
case CT_Operator_Member_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
code_op_to_strbuilder_fwd(cast(CodeOperator, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Cast:
|
2024-12-12 09:55:15 -08:00
|
|
|
opcast_to_strbuilder_def(cast(CodeOpCast, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Cast_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
opcast_to_strbuilder_fwd(cast(CodeOpCast, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Parameters:
|
2024-12-12 09:55:15 -08:00
|
|
|
params_to_strbuilder_ref(cast(CodeParams, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2023-11-20 12:09:01 -08:00
|
|
|
|
2024-12-14 15:49:41 -08:00
|
|
|
case CT_Parameters_Define:
|
|
|
|
define_params_to_strbuilder_ref(cast(CodeDefineParams, self), result);
|
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_Define:
|
2024-12-12 09:55:15 -08:00
|
|
|
define_to_strbuilder_ref(cast(CodeDefine, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_If:
|
2024-12-12 09:55:15 -08:00
|
|
|
preprocess_to_strbuilder_if(cast(CodePreprocessCond, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_IfDef:
|
2024-12-12 09:55:15 -08:00
|
|
|
preprocess_to_strbuilder_ifdef(cast(CodePreprocessCond, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_IfNotDef:
|
2024-12-12 09:55:15 -08:00
|
|
|
preprocess_to_strbuilder_ifndef(cast(CodePreprocessCond, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_Include:
|
2024-12-12 09:55:15 -08:00
|
|
|
include_to_strbuilder_ref(cast(CodeInclude, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_ElIf:
|
2024-12-12 09:55:15 -08:00
|
|
|
preprocess_to_strbuilder_elif(cast(CodePreprocessCond, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_Else:
|
2024-12-12 09:55:15 -08:00
|
|
|
preprocess_to_strbuilder_else(cast(CodePreprocessCond, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_EndIf:
|
2024-12-12 09:55:15 -08:00
|
|
|
preprocess_to_strbuilder_endif(cast(CodePreprocessCond, self), result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_Pragma:
|
2024-12-12 09:55:15 -08:00
|
|
|
pragma_to_strbuilder_ref(cast(CodePragma, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Specifiers:
|
2024-12-12 09:55:15 -08:00
|
|
|
specifiers_to_strbuilder_ref(cast(CodeSpecifiers, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Struct:
|
2024-12-12 09:55:15 -08:00
|
|
|
struct_to_strbuilder_def(cast(CodeStruct, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Struct_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
struct_to_strbuilder_fwd(cast(CodeStruct, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Template:
|
2024-12-12 09:55:15 -08:00
|
|
|
template_to_strbuilder_ref(cast(CodeTemplate, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Typedef:
|
2024-12-12 09:55:15 -08:00
|
|
|
typedef_to_strbuilder_ref(cast(CodeTypedef, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Typename:
|
2024-12-12 09:55:15 -08:00
|
|
|
typename_to_strbuilder_ref(cast(CodeTypename, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Union:
|
2024-12-12 09:55:15 -08:00
|
|
|
union_to_strbuilder_def( cast(CodeUnion, self), result );
|
2024-12-05 21:33:53 -08:00
|
|
|
break;
|
2024-12-06 02:29:17 -08:00
|
|
|
|
2024-12-05 21:33:53 -08:00
|
|
|
case CT_Union_Fwd:
|
2024-12-12 09:55:15 -08:00
|
|
|
union_to_strbuilder_fwd( cast(CodeUnion, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Using:
|
2024-12-12 09:55:15 -08:00
|
|
|
using_to_strbuilder_ref(cast(CodeUsing, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Using_Namespace:
|
2024-12-12 09:55:15 -08:00
|
|
|
using_to_strbuilder_ns(cast(CodeUsing, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Variable:
|
2024-12-12 09:55:15 -08:00
|
|
|
var_to_strbuilder_ref(cast(CodeVar, self), result );
|
2023-08-04 13:12:13 -07:00
|
|
|
break;
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Body:
|
|
|
|
case CT_Class_Body:
|
|
|
|
case CT_Extern_Linkage_Body:
|
|
|
|
case CT_Function_Body:
|
|
|
|
case CT_Global_Body:
|
|
|
|
case CT_Namespace_Body:
|
|
|
|
case CT_Struct_Body:
|
|
|
|
case CT_Union_Body:
|
2024-12-12 09:55:15 -08:00
|
|
|
body_to_strbuilder_ref( cast(CodeBody, self), result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
bool code_is_equal( Code self, Code other )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2023-08-22 13:01:50 -07:00
|
|
|
/*
|
|
|
|
AST values are either some u32 value, a cached string, or a pointer to another AST.
|
|
|
|
|
|
|
|
u32 values are compared by value.
|
|
|
|
Cached strings are compared by pointer.
|
|
|
|
AST nodes are compared with AST::is_equal.
|
|
|
|
*/
|
|
|
|
if ( other == nullptr )
|
2023-08-23 15:16:45 -07:00
|
|
|
{
|
2024-12-12 09:55:15 -08:00
|
|
|
log_fmt( "AST::is_equal: other is null\nAST: %S", code_debug_str(self) );
|
2023-08-22 13:01:50 -07:00
|
|
|
return false;
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
2023-08-22 13:01:50 -07:00
|
|
|
|
2024-12-01 21:34:40 -08:00
|
|
|
if ( self->Type != other->Type )
|
2023-08-23 15:16:45 -07:00
|
|
|
{
|
2024-12-12 09:55:15 -08:00
|
|
|
log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S"
|
2024-12-06 02:29:17 -08:00
|
|
|
, code_debug_str(self)
|
2024-12-13 16:16:52 -08:00
|
|
|
, code_debug_str(other)
|
2023-08-23 15:16:45 -07:00
|
|
|
);
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
return false;
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-12-01 21:34:40 -08:00
|
|
|
switch ( self->Type )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_val( val ) \
|
2024-12-01 21:34:40 -08:00
|
|
|
if ( self->val != other->val ) \
|
2023-09-03 17:29:45 -07:00
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Member - " #val " failed\n" \
|
2024-12-13 11:38:27 -08:00
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
2024-12-07 14:17:02 -08:00
|
|
|
, code_debug_str(self) \
|
|
|
|
,code_debug_str(other) \
|
2023-09-03 17:29:45 -07:00
|
|
|
); \
|
2024-12-03 15:47:12 -08:00
|
|
|
\
|
2023-09-03 17:29:45 -07:00
|
|
|
return false; \
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_str( str ) \
|
2024-12-13 11:38:27 -08:00
|
|
|
if ( ! str_are_equal( self->str, other->str ) ) \
|
2023-09-03 17:29:45 -07:00
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \
|
2024-12-13 11:38:27 -08:00
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
2024-12-07 14:17:02 -08:00
|
|
|
, code_debug_str(self) \
|
|
|
|
,code_debug_str(other) \
|
2023-09-03 17:29:45 -07:00
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
|
2024-12-13 16:16:52 -08:00
|
|
|
#define check_member_content( content ) \
|
|
|
|
if ( ! str_are_equal( self->content, other->content )) \
|
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \
|
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
, code_debug_str(self) \
|
|
|
|
, code_debug_str(other) \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
log_fmt("Content cannot be trusted to be unique with this check " \
|
|
|
|
"so it must be verified by eye for now\n" \
|
|
|
|
"AST Content:\n%S\n" \
|
|
|
|
"Other Content:\n%S\n" \
|
|
|
|
, str_visualize_whitespace(self->content, _ctx->Allocator_Temp) \
|
|
|
|
, str_visualize_whitespace(other->content, _ctx->Allocator_Temp) \
|
|
|
|
); \
|
2023-08-25 15:57:53 -07:00
|
|
|
}
|
|
|
|
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_ast( ast ) \
|
2024-12-01 21:34:40 -08:00
|
|
|
if ( self->ast ) \
|
2023-09-03 17:29:45 -07:00
|
|
|
{ \
|
|
|
|
if ( other->ast == nullptr ) \
|
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Failed for member " #ast " other equivalent param is null\n" \
|
2024-12-13 11:38:27 -08:00
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
"For ast member: %S\n" \
|
2024-12-07 14:17:02 -08:00
|
|
|
, code_debug_str(self) \
|
|
|
|
, code_debug_str(other) \
|
|
|
|
, code_debug_str(self->ast) \
|
2023-09-03 17:29:45 -07:00
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
\
|
2024-12-07 14:17:02 -08:00
|
|
|
if ( ! code_is_equal(self->ast, other->ast ) ) \
|
2023-09-03 17:29:45 -07:00
|
|
|
{ \
|
|
|
|
log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \
|
2024-12-13 11:38:27 -08:00
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
"For ast member: %S\n" \
|
|
|
|
"other's ast member: %S\n" \
|
2024-12-07 14:17:02 -08:00
|
|
|
, code_debug_str(self) \
|
|
|
|
, code_debug_str(other) \
|
|
|
|
, code_debug_str(self->ast) \
|
|
|
|
, code_debug_str(other->ast) \
|
2023-09-03 17:29:45 -07:00
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
|
|
|
} \
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_NewLine:
|
|
|
|
case CT_Access_Public:
|
|
|
|
case CT_Access_Protected:
|
|
|
|
case CT_Access_Private:
|
|
|
|
case CT_Preprocess_Else:
|
|
|
|
case CT_Preprocess_EndIf:
|
2023-08-22 13:01:50 -07:00
|
|
|
return true;
|
|
|
|
|
2023-08-26 08:55:05 -07:00
|
|
|
|
|
|
|
// Comments are not validated.
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Comment:
|
2023-09-05 21:30:34 -07:00
|
|
|
return true;
|
2023-08-26 08:55:05 -07:00
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Execution:
|
|
|
|
case CT_PlatformAttributes:
|
|
|
|
case CT_Untyped:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-25 15:57:53 -07:00
|
|
|
check_member_content( Content );
|
2023-09-05 21:30:34 -07:00
|
|
|
return true;
|
2023-08-22 13:01:50 -07:00
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class_Fwd:
|
|
|
|
case CT_Struct_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ParentType );
|
|
|
|
check_member_val( ParentAccess );
|
|
|
|
check_member_ast( Attributes );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class:
|
|
|
|
case CT_Struct:
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ParentType );
|
|
|
|
check_member_val( ParentAccess );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Body );
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Constructor:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( InitializerList );
|
|
|
|
check_member_ast( Params );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Constructor_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( InitializerList );
|
|
|
|
check_member_ast( Params );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Destructor:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Destructor_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( Specs );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum:
|
|
|
|
case CT_Enum_Class:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( UnderlyingType );
|
|
|
|
check_member_ast( Body );
|
2024-12-05 21:33:53 -08:00
|
|
|
check_member_ast( UnderlyingTypeMacro );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Fwd:
|
|
|
|
case CT_Enum_Class_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( UnderlyingType );
|
2024-12-05 21:33:53 -08:00
|
|
|
check_member_ast( UnderlyingTypeMacro );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Extern_Linkage:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Friend:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Declaration );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ReturnType );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( Params );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ReturnType );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( Params );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Module:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Namespace:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator:
|
|
|
|
case CT_Operator_Member:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ReturnType );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( Params );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Fwd:
|
|
|
|
case CT_Operator_Member_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ReturnType );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( Params );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Cast:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( ValueType );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Operator_Cast_Fwd:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( ValueType );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Parameters:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2024-12-01 21:34:40 -08:00
|
|
|
if ( self->NumEntries > 1 )
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2024-12-02 17:20:30 -08:00
|
|
|
Code curr = self;
|
|
|
|
Code curr_other = other;
|
2023-08-22 13:01:50 -07:00
|
|
|
while ( curr != nullptr )
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
if ( curr )
|
|
|
|
{
|
|
|
|
if ( curr_other == nullptr )
|
|
|
|
{
|
2023-09-03 17:29:45 -07:00
|
|
|
log_fmt("\nAST::is_equal: Failed for parameter, other equivalent param is null\n"
|
2024-12-12 09:55:15 -08:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
2024-12-07 14:17:02 -08:00
|
|
|
, code_debug_str(curr)
|
2023-08-23 15:16:45 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
if ( str_are_equal(curr->Name, curr_other->Name) )
|
2023-08-23 15:16:45 -07:00
|
|
|
{
|
2023-09-03 17:29:45 -07:00
|
|
|
log_fmt( "\nAST::is_equal: Failed for parameter name check\n"
|
2024-12-12 09:55:15 -08:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
2024-12-06 02:29:17 -08:00
|
|
|
, code_debug_str(self)
|
|
|
|
, code_debug_str(other)
|
|
|
|
, code_debug_str(curr)
|
|
|
|
, code_debug_str(curr_other)
|
2023-09-03 17:29:45 -07:00
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
if ( curr->ValueType && ! code_is_equal(curr->ValueType, curr_other->ValueType) )
|
2023-09-03 17:29:45 -07:00
|
|
|
{
|
|
|
|
log_fmt( "\nAST::is_equal: Failed for parameter value type check\n"
|
2024-12-12 09:55:15 -08:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
2024-12-06 02:29:17 -08:00
|
|
|
, code_debug_str(self)
|
|
|
|
, code_debug_str(other)
|
|
|
|
, code_debug_str(curr)
|
|
|
|
, code_debug_str(curr_other)
|
2023-09-03 17:29:45 -07:00
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
if ( curr->Value && ! code_is_equal(curr->Value, curr_other->Value) )
|
2023-09-03 17:29:45 -07:00
|
|
|
{
|
|
|
|
log_fmt( "\nAST::is_equal: Failed for parameter value check\n"
|
2024-12-12 09:55:15 -08:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
2024-12-06 02:29:17 -08:00
|
|
|
, code_debug_str(self)
|
|
|
|
, code_debug_str(other)
|
|
|
|
, code_debug_str(curr)
|
|
|
|
, code_debug_str(curr_other)
|
2023-08-23 15:16:45 -07:00
|
|
|
);
|
2023-08-25 15:40:13 -07:00
|
|
|
return false;
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
}
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
curr = curr->Next;
|
|
|
|
curr_other = curr_other->Next;
|
|
|
|
}
|
|
|
|
|
2023-08-25 15:40:13 -07:00
|
|
|
check_member_val( NumEntries );
|
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ValueType );
|
|
|
|
check_member_ast( Value );
|
|
|
|
check_member_ast( ArrExpr );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-14 15:49:41 -08:00
|
|
|
case CT_Parameters_Define:
|
|
|
|
{
|
|
|
|
// TODO(ED): Needs implementaton
|
|
|
|
log_failure("code_is_equal: NOT IMPLEMENTED for CT_Parameters_Define");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_Define:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
2024-12-14 15:49:41 -08:00
|
|
|
check_member_content( Body->Content );
|
2023-08-22 13:01:50 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_If:
|
|
|
|
case CT_Preprocess_IfDef:
|
|
|
|
case CT_Preprocess_IfNotDef:
|
|
|
|
case CT_Preprocess_ElIf:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-25 15:57:53 -07:00
|
|
|
check_member_content( Content );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Preprocess_Include:
|
|
|
|
case CT_Preprocess_Pragma:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-25 15:57:53 -07:00
|
|
|
check_member_content( Content );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Specifiers:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( NumEntries );
|
|
|
|
check_member_str( Name );
|
2024-12-01 21:34:40 -08:00
|
|
|
for ( s32 idx = 0; idx < self->NumEntries; ++idx )
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ArrSpecs[ idx ] );
|
2023-08-22 13:01:50 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Template:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Params );
|
|
|
|
check_member_ast( Declaration );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Typedef:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( IsFunction );
|
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( UnderlyingType );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Typename:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( IsParamPack );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Specs );
|
|
|
|
check_member_ast( ArrExpr );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Union:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Body );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2024-12-07 14:17:02 -08:00
|
|
|
|
2024-12-05 21:33:53 -08:00
|
|
|
case CT_Union_Fwd:
|
|
|
|
{
|
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
}
|
2023-08-22 13:01:50 -07:00
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Using:
|
|
|
|
case CT_Using_Namespace:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( UnderlyingType );
|
|
|
|
check_member_ast( Attributes );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Variable:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( ValueType );
|
|
|
|
check_member_ast( BitfieldSize );
|
|
|
|
check_member_ast( Value );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( Specs );
|
2023-09-06 00:06:30 -07:00
|
|
|
check_member_ast( NextVar );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class_Body:
|
|
|
|
case CT_Enum_Body:
|
|
|
|
case CT_Export_Body:
|
|
|
|
case CT_Global_Body:
|
|
|
|
case CT_Namespace_Body:
|
|
|
|
case CT_Struct_Body:
|
|
|
|
case CT_Union_Body:
|
2023-08-22 13:01:50 -07:00
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( Front );
|
|
|
|
check_member_ast( Back );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
2024-12-02 17:20:30 -08:00
|
|
|
Code curr = self->Front;
|
|
|
|
Code curr_other = other->Front;
|
2023-08-22 13:01:50 -07:00
|
|
|
while ( curr != nullptr )
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
if ( curr_other == nullptr )
|
|
|
|
{
|
2023-09-03 17:29:45 -07:00
|
|
|
log_fmt("\nAST::is_equal: Failed for body, other equivalent param is null\n"
|
2024-12-12 09:55:15 -08:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
2024-12-07 14:17:02 -08:00
|
|
|
, code_debug_str(curr)
|
2024-12-08 20:10:10 -08:00
|
|
|
, code_debug_str(other)
|
2023-08-23 15:16:45 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
if ( ! code_is_equal( curr, curr_other ) )
|
2023-08-23 15:16:45 -07:00
|
|
|
{
|
2023-09-03 17:29:45 -07:00
|
|
|
log_fmt( "\nAST::is_equal: Failed for body\n"
|
2024-12-12 09:55:15 -08:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
2024-12-06 02:29:17 -08:00
|
|
|
, code_debug_str(self)
|
|
|
|
, code_debug_str(other)
|
|
|
|
, code_debug_str(curr)
|
|
|
|
, code_debug_str(curr_other)
|
2023-08-23 15:16:45 -07:00
|
|
|
);
|
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
return false;
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
curr = curr->Next;
|
|
|
|
curr_other = curr_other->Next;
|
|
|
|
}
|
|
|
|
|
2023-08-25 15:40:13 -07:00
|
|
|
check_member_val( NumEntries );
|
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
return true;
|
|
|
|
}
|
2023-08-23 15:16:45 -07:00
|
|
|
|
|
|
|
#undef check_member_val
|
|
|
|
#undef check_member_str
|
|
|
|
#undef check_member_ast
|
2023-08-22 13:01:50 -07:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
bool code_validate_body(Code self)
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-02 00:18:52 -08:00
|
|
|
switch ( self->Type )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
2024-12-12 08:35:50 -08:00
|
|
|
CodeBody body = cast(CodeBody, self);
|
|
|
|
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_CLASS_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
|
|
|
CodeBody body = cast(CodeBody, self);
|
2024-12-06 21:21:09 -08:00
|
|
|
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
if ( entry->Type != CT_Untyped )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %S", code_debug_str(entry) );
|
2023-07-24 14:45:27 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Export_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
2024-12-12 08:35:50 -08:00
|
|
|
CodeBody body = cast(CodeBody, self);
|
|
|
|
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_EXPORT_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Extern_Linkage:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
2024-12-12 08:35:50 -08:00
|
|
|
CodeBody body = cast(CodeBody, self);
|
|
|
|
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Function_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
2024-12-12 08:35:50 -08:00
|
|
|
CodeBody body = cast(CodeBody, self);
|
|
|
|
for (Code code_entry = begin_CodeBody(body); code_entry != end_CodeBody(body); next_CodeBody(body, code_entry)) switch (code_entry->Type)
|
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(code_entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Global_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
|
|
|
CodeBody body = cast(CodeBody, self);
|
2024-12-12 08:35:50 -08:00
|
|
|
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )switch (entry->Type)
|
2023-08-06 11:58:43 -07:00
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
2023-08-06 11:58:43 -07:00
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Namespace_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
2024-12-12 08:35:50 -08:00
|
|
|
CodeBody body = cast(CodeBody, self);
|
|
|
|
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) switch (entry->Type)
|
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Struct_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
2024-12-12 08:35:50 -08:00
|
|
|
CodeBody body = cast(CodeBody, self);
|
|
|
|
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) ) switch (entry->Type)
|
|
|
|
{
|
2024-12-14 08:24:21 -08:00
|
|
|
GEN_AST_BODY_STRUCT_UNALLOWED_TYPES_CASES:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure("AST::validate_body: Invalid entry in body %S", code_debug_str(entry));
|
2024-12-12 08:35:50 -08:00
|
|
|
return false;
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Union_Body:
|
2024-12-06 02:29:17 -08:00
|
|
|
{
|
|
|
|
CodeBody body = cast(CodeBody, self);
|
2024-12-06 21:21:09 -08:00
|
|
|
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
if ( entry->Type != CT_Untyped )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %S", code_debug_str(entry) );
|
2023-07-24 14:45:27 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-12-12 09:55:15 -08:00
|
|
|
log_failure( "AST::validate_body: Invalid this AST does not have a body %S", code_debug_str(self) );
|
2023-07-24 14:45:27 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|