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-07-24 14:45:27 -07:00
|
|
|
Code Code::Global;
|
|
|
|
Code Code::Invalid;
|
|
|
|
|
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.
|
2023-08-23 18:19:31 -07:00
|
|
|
char const* AST::debug_str()
|
|
|
|
{
|
2023-09-11 20:22:53 -07:00
|
|
|
String result = String::make_reserve( GlobalAllocator, kilobytes(1) );
|
|
|
|
|
2023-08-23 18:19:31 -07:00
|
|
|
if ( Parent )
|
2023-09-11 20:22:53 -07:00
|
|
|
result.append_fmt( "\n\tParent : %S %S", Parent->type_str(), Name ? Name : "" );
|
|
|
|
else
|
|
|
|
result.append_fmt( "\n\tParent : %S", "Null" );
|
|
|
|
|
|
|
|
result.append_fmt( "\n\tName : %S", Name ? Name : "Null" );
|
|
|
|
result.append_fmt( "\n\tType : %S", type_str() );
|
|
|
|
result.append_fmt( "\n\tModule Flags : %S", to_str( ModuleFlags ) );
|
|
|
|
|
|
|
|
switch ( Type )
|
2023-08-23 18:19:31 -07:00
|
|
|
{
|
2023-09-11 20:22:53 -07:00
|
|
|
using namespace ECode;
|
|
|
|
|
|
|
|
case Invalid:
|
|
|
|
case NewLine:
|
|
|
|
case Access_Private:
|
|
|
|
case Access_Protected:
|
|
|
|
case Access_Public:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Untyped:
|
|
|
|
case Execution:
|
|
|
|
case Comment:
|
|
|
|
case PlatformAttributes:
|
|
|
|
case Preprocess_Define:
|
|
|
|
case Preprocess_Include:
|
|
|
|
case Preprocess_Pragma:
|
|
|
|
case Preprocess_If:
|
|
|
|
case Preprocess_ElIf:
|
|
|
|
case Preprocess_Else:
|
|
|
|
case Preprocess_IfDef:
|
|
|
|
case Preprocess_IfNotDef:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tContent: %S", Content );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Class:
|
|
|
|
case Struct:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmd : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParentAccess: %s", ParentType ? to_str( ParentAccess ) : "No Parent" );
|
|
|
|
result.append_fmt( "\n\tParentType : %s", ParentType ? ParentType->type_str() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 09:12:11 -07:00
|
|
|
case Class_Fwd:
|
|
|
|
case Struct_Fwd:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-25 09:12:11 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-25 09:12:11 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmd : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParentAccess: %s", ParentType ? to_str( ParentAccess ) : "No Parent" );
|
|
|
|
result.append_fmt( "\n\tParentType : %s", ParentType ? ParentType->type_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Constructor:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tInitializerList: %S", InitializerList ? InitializerList->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 09:12:11 -07:00
|
|
|
case Constructor_Fwd:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-25 09:12:11 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-25 09:12:11 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tInitializerList: %S", InitializerList ? InitializerList->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Destructor:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 09:12:11 -07:00
|
|
|
case Destructor_Fwd:
|
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Enum:
|
2023-09-25 09:12:11 -07:00
|
|
|
case Enum_Class:
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tUnderlying Type : %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 13:42:29 -07:00
|
|
|
case Enum_Fwd:
|
2023-09-25 09:12:11 -07:00
|
|
|
case Enum_Class_Fwd:
|
2023-09-25 13:42:29 -07:00
|
|
|
if ( Prev )
|
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
if ( Next )
|
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tUnderlying Type : %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
2023-09-25 09:12:11 -07:00
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Extern_Linkage:
|
|
|
|
case Namespace:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tBody: %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Friend:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tDeclaration: %S", Declaration ? Declaration->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Function:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-08-23 18:19:31 -07:00
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 13:42:29 -07:00
|
|
|
case Function_Fwd:
|
|
|
|
if ( Prev )
|
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
if ( Next )
|
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Module:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Operator:
|
2023-09-25 13:42:29 -07:00
|
|
|
case Operator_Member:
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
result.append_fmt( "\n\tOp : %S", to_str( Op ) );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 13:42:29 -07:00
|
|
|
case Operator_Fwd:
|
|
|
|
case Operator_Member_Fwd:
|
|
|
|
if ( Prev )
|
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
if ( Next )
|
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tReturnType: %S", ReturnType ? ReturnType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tOp : %S", to_str( Op ) );
|
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Operator_Cast:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-25 13:42:29 -07:00
|
|
|
case Operator_Cast_Fwd:
|
|
|
|
if ( Prev )
|
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
if ( Next )
|
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
2023-09-11 20:22:53 -07:00
|
|
|
case Parameters:
|
|
|
|
result.append_fmt( "\n\tNumEntries: %d", NumEntries );
|
|
|
|
result.append_fmt( "\n\tLast : %S", Last->Name );
|
|
|
|
result.append_fmt( "\n\tNext : %S", Next->Name );
|
|
|
|
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tValue : %S", Value ? Value->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Specifiers:
|
|
|
|
{
|
|
|
|
result.append_fmt( "\n\tNumEntries: %d", NumEntries );
|
|
|
|
result.append( "\n\tArrSpecs: " );
|
|
|
|
|
|
|
|
s32 idx = 0;
|
|
|
|
s32 left = NumEntries;
|
|
|
|
while ( left-- )
|
|
|
|
{
|
|
|
|
StrC spec = ESpecifier::to_str( ArrSpecs[idx] );
|
|
|
|
result.append_fmt( "%.*s, ", spec.Len, spec.Ptr );
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
result.append_fmt( "\n\tNextSpecs: %S", NextSpecs ? NextSpecs->debug_str() : "Null" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Template:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tDeclaration: %S", Declaration ? Declaration->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Typedef:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tUnderlyingType: %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Typename:
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tReturnType : %S", ReturnType ? ReturnType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tParams : %S", Params ? Params->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tArrExpr : %S", ArrExpr ? ArrExpr->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Union:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tAttributes: %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBody : %S", Body ? Body->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Using:
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tUnderlyingType: %S", UnderlyingType ? UnderlyingType->to_string() : "Null" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Variable:
|
|
|
|
|
|
|
|
if ( Parent && Parent->Type == Variable )
|
|
|
|
{
|
|
|
|
// Its a NextVar
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tValue : %S", Value ? Value->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBitfieldSize: %S", BitfieldSize ? BitfieldSize->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Prev )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tPrev: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
if ( Next )
|
2023-09-25 13:42:29 -07:00
|
|
|
result.append_fmt( "\n\tNext: %S %S", Prev->type_str(), Prev->Name ? Prev->Name : "Null" );
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
result.append_fmt( "\n\tInlineCmt : %S", InlineCmt ? InlineCmt->Content : "Null" );
|
|
|
|
result.append_fmt( "\n\tAttributes : %S", Attributes ? Attributes->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tSpecs : %S", Specs ? Specs->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tValueType : %S", ValueType ? ValueType->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tBitfieldSize: %S", BitfieldSize ? BitfieldSize->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tValue : %S", Value ? Value->to_string() : "Null" );
|
|
|
|
result.append_fmt( "\n\tNextVar : %S", NextVar ? NextVar->debug_str() : "Null" );
|
|
|
|
break;
|
|
|
|
}
|
2023-08-23 18:19:31 -07:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
AST* AST::duplicate()
|
|
|
|
{
|
|
|
|
using namespace ECode;
|
|
|
|
|
2023-07-26 11:21:20 -07:00
|
|
|
AST* result = make_code().ast;
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2023-07-26 11:21:20 -07:00
|
|
|
mem_copy( result, this, sizeof( AST ) );
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2023-07-26 11:21:20 -07:00
|
|
|
result->Parent = nullptr;
|
2023-07-24 14:45:27 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
String AST::to_string()
|
|
|
|
{
|
|
|
|
String result = String::make( GlobalAllocator, "" );
|
2023-11-19 17:34:46 -08:00
|
|
|
to_string( result );
|
|
|
|
return result;
|
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2023-11-19 17:34:46 -08:00
|
|
|
void AST::to_string( String& result )
|
|
|
|
{
|
|
|
|
local_persist thread_local
|
|
|
|
char SerializationLevel = 0;
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
switch ( Type )
|
|
|
|
{
|
|
|
|
using namespace ECode;
|
|
|
|
|
|
|
|
case Invalid:
|
2023-09-11 20:22:53 -07:00
|
|
|
#ifdef GEN_DONT_ALLOW_INVALID_CODE
|
2023-08-08 19:14:58 -07:00
|
|
|
log_failure("Attempted to serialize invalid code! - %S", Parent ? Parent->debug_str() : Name );
|
2023-09-11 20:22:53 -07:00
|
|
|
#else
|
|
|
|
result.append_fmt( "Invalid Code!" );
|
|
|
|
#endif
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2023-08-04 13:12:13 -07:00
|
|
|
case NewLine:
|
|
|
|
result.append("\n");
|
|
|
|
break;
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
case Untyped:
|
|
|
|
case Execution:
|
|
|
|
case Comment:
|
2023-09-11 20:22:53 -07:00
|
|
|
case PlatformAttributes:
|
2023-08-22 21:05:58 -07:00
|
|
|
result.append( Content );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Access_Private:
|
|
|
|
case Access_Protected:
|
|
|
|
case Access_Public:
|
|
|
|
result.append( Name );
|
|
|
|
break;
|
2023-11-19 17:34:46 -08:00
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
case Class:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeClass>().to_string_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Class_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeClass>().to_string_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
2023-08-07 00:10:45 -07:00
|
|
|
case Constructor:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeConstructor>().to_string_def( result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Constructor_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeConstructor>().to_string_fwd( result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Destructor:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeDestructor>().to_string_def( result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Destructor_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeDestructor>().to_string_fwd( result );
|
2023-08-07 00:10:45 -07:00
|
|
|
break;
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
case Enum:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeEnum>().to_string_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Enum_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeEnum>().to_string_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Enum_Class:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeEnum>().to_string_class_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Enum_Class_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeEnum>().to_string_class_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Export_Body:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeBody>().to_string_export( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Extern_Linkage:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeExtern>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Friend:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeFriend>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Function:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeFn>().to_string_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Function_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeFn>().to_string_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Module:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeModule>().to_string( result );
|
|
|
|
break;
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
case Namespace:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeNS>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Operator:
|
|
|
|
case Operator_Member:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeOperator>().to_string_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Operator_Fwd:
|
|
|
|
case Operator_Member_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeOperator>().to_string_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Operator_Cast:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeOpCast>().to_string_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Operator_Cast_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeOpCast>().to_string_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Parameters:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeParam>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
2023-11-19 17:34:46 -08:00
|
|
|
|
2023-07-29 22:21:04 -07:00
|
|
|
case Preprocess_Define:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeDefine>().to_string( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_If:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePreprocessCond>().to_string_if( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_IfDef:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePreprocessCond>().to_string_ifdef( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_IfNotDef:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePreprocessCond>().to_string_ifndef( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_Include:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeInclude>().to_string( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_ElIf:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePreprocessCond>().to_string_elif( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_Else:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePreprocessCond>().to_string_else( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_EndIf:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePreprocessCond>().to_string_endif( result );
|
2023-07-29 22:21:04 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Preprocess_Pragma:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodePragma>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Specifiers:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeSpecifiers>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Struct:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeStruct>().to_string_def( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Struct_Fwd:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeStruct>().to_string_fwd( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Template:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeTemplate>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Typedef:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeTypedef>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Typename:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeType>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Union:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeUnion>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Using:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeUsing>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Using_Namespace:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeUsing>().to_string_ns( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Variable:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeVar>().to_string( result );
|
2023-08-04 13:12:13 -07:00
|
|
|
break;
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
case Enum_Body:
|
2023-08-04 13:12:13 -07:00
|
|
|
case Class_Body:
|
2023-07-24 14:45:27 -07:00
|
|
|
case Extern_Linkage_Body:
|
|
|
|
case Function_Body:
|
|
|
|
case Global_Body:
|
|
|
|
case Namespace_Body:
|
|
|
|
case Struct_Body:
|
|
|
|
case Union_Body:
|
2023-11-19 17:34:46 -08:00
|
|
|
cast<CodeBody>().to_string( result );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AST::is_equal( AST* other )
|
|
|
|
{
|
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
|
|
|
{
|
|
|
|
log_fmt( "AST::is_equal: other is null\nAST: %S", debug_str() );
|
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
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
if ( Type != other->Type )
|
2023-08-23 15:16:45 -07:00
|
|
|
{
|
|
|
|
log_fmt("AST::is_equal: Type check failure with other\nAST: %S\nOther: %S"
|
|
|
|
, debug_str()
|
|
|
|
, other->debug_str()
|
|
|
|
);
|
|
|
|
|
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
|
|
|
|
|
|
|
switch ( Type )
|
|
|
|
{
|
2023-08-22 13:01:50 -07:00
|
|
|
using namespace ECode;
|
|
|
|
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_val( val ) \
|
|
|
|
if ( val != other->val ) \
|
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Member - " #val " failed\n" \
|
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
, debug_str() \
|
|
|
|
, other->debug_str() \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_str( str ) \
|
|
|
|
if ( str != other->str ) \
|
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Member string - "#str " failed\n" \
|
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
, debug_str() \
|
|
|
|
, other->debug_str() \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_content( content ) \
|
|
|
|
if ( content != other->content ) \
|
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Member content - "#content " failed\n" \
|
2023-08-25 15:57:53 -07:00
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
, debug_str() \
|
|
|
|
, other->debug_str() \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
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" \
|
2023-09-03 17:29:45 -07:00
|
|
|
, content.visualize_whitespace() \
|
|
|
|
, other->content.visualize_whitespace() \
|
2023-08-25 15:57:53 -07:00
|
|
|
); \
|
|
|
|
}
|
|
|
|
|
2023-09-03 17:29:45 -07:00
|
|
|
#define check_member_ast( ast ) \
|
|
|
|
if ( ast ) \
|
|
|
|
{ \
|
|
|
|
if ( other->ast == nullptr ) \
|
|
|
|
{ \
|
|
|
|
log_fmt("\nAST::is_equal: Failed for member " #ast " other equivalent param is null\n" \
|
|
|
|
"AST : %s\n" \
|
|
|
|
"Other: %s\n" \
|
|
|
|
"For ast member: %s\n" \
|
|
|
|
, debug_str() \
|
|
|
|
, other->debug_str() \
|
|
|
|
, ast->debug_str() \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
if ( ! ast->is_equal( other->ast ) ) \
|
|
|
|
{ \
|
|
|
|
log_fmt( "\nAST::is_equal: Failed for " #ast"\n" \
|
|
|
|
"AST : %S\n" \
|
|
|
|
"Other: %S\n" \
|
|
|
|
"For ast member: %S\n" \
|
|
|
|
"other's ast member: %S\n" \
|
|
|
|
, debug_str() \
|
|
|
|
, other->debug_str() \
|
|
|
|
, ast->debug_str() \
|
|
|
|
, other->ast->debug_str() \
|
|
|
|
); \
|
|
|
|
\
|
|
|
|
return false; \
|
|
|
|
} \
|
2023-08-23 15:16:45 -07:00
|
|
|
}
|
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
case NewLine:
|
|
|
|
case Access_Public:
|
|
|
|
case Access_Protected:
|
|
|
|
case Access_Private:
|
|
|
|
case Preprocess_Else:
|
|
|
|
case Preprocess_EndIf:
|
|
|
|
return true;
|
|
|
|
|
2023-08-26 08:55:05 -07:00
|
|
|
|
|
|
|
// Comments are not validated.
|
2023-08-22 13:01:50 -07:00
|
|
|
case Comment:
|
2023-09-05 21:30:34 -07:00
|
|
|
return true;
|
2023-08-26 08:55:05 -07:00
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
case Execution:
|
|
|
|
case PlatformAttributes:
|
|
|
|
case Untyped:
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
case Class_Fwd:
|
|
|
|
case Struct_Fwd:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Class:
|
|
|
|
case 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;
|
|
|
|
}
|
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
case Constructor:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Constructor_Fwd:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Destructor:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Destructor_Fwd:
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( Specs );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Enum:
|
|
|
|
case Enum_Class:
|
|
|
|
{
|
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 );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Enum_Fwd:
|
|
|
|
case Enum_Class_Fwd:
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ModuleFlags );
|
|
|
|
check_member_str( Name );
|
|
|
|
check_member_ast( Attributes );
|
|
|
|
check_member_ast( UnderlyingType );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Extern_Linkage:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Friend:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Function:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Function_Fwd:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Module:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Namespace:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Operator:
|
|
|
|
case Operator_Member:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Operator_Fwd:
|
|
|
|
case Operator_Member_Fwd:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Operator_Cast:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Operator_Cast_Fwd:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Parameters:
|
|
|
|
{
|
|
|
|
if ( NumEntries > 1 )
|
|
|
|
{
|
|
|
|
AST* curr = this;
|
|
|
|
AST* curr_other = other;
|
|
|
|
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"
|
2023-08-23 15:16:45 -07:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
, curr->debug_str()
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-09-03 17:34:27 -07:00
|
|
|
if ( 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"
|
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
|
|
|
, debug_str()
|
|
|
|
, other->debug_str()
|
|
|
|
, curr->debug_str()
|
|
|
|
, curr_other->debug_str()
|
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( curr->ValueType && ! curr->ValueType->is_equal(curr_other->ValueType) )
|
|
|
|
{
|
|
|
|
log_fmt( "\nAST::is_equal: Failed for parameter value type check\n"
|
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
|
|
|
, debug_str()
|
|
|
|
, other->debug_str()
|
|
|
|
, curr->debug_str()
|
|
|
|
, curr_other->debug_str()
|
|
|
|
);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( curr->Value && ! curr->Value->is_equal(curr_other->Value) )
|
|
|
|
{
|
|
|
|
log_fmt( "\nAST::is_equal: Failed for parameter value check\n"
|
2023-08-23 15:16:45 -07:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
|
|
|
, debug_str()
|
|
|
|
, other->debug_str()
|
|
|
|
, curr->debug_str()
|
|
|
|
, curr_other->debug_str()
|
|
|
|
);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Preprocess_Define:
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_str( Name );
|
2023-08-25 15:57:53 -07:00
|
|
|
check_member_content( Content );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Preprocess_If:
|
|
|
|
case Preprocess_IfDef:
|
|
|
|
case Preprocess_IfNotDef:
|
|
|
|
case Preprocess_ElIf:
|
|
|
|
{
|
2023-08-25 15:57:53 -07:00
|
|
|
check_member_content( Content );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Preprocess_Include:
|
|
|
|
case Preprocess_Pragma:
|
|
|
|
{
|
2023-08-25 15:57:53 -07:00
|
|
|
check_member_content( Content );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Specifiers:
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( NumEntries );
|
|
|
|
check_member_str( Name );
|
2023-08-22 13:01:50 -07:00
|
|
|
for ( s32 idx = 0; idx < NumEntries; ++idx )
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_val( ArrSpecs[ idx ] );
|
2023-08-22 13:01:50 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Template:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Typedef:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
case Typename:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Union:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Using:
|
|
|
|
case Using_Namespace:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Variable:
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Class_Body:
|
|
|
|
case Enum_Body:
|
|
|
|
case Export_Body:
|
|
|
|
case Global_Body:
|
|
|
|
case Namespace_Body:
|
|
|
|
case Struct_Body:
|
|
|
|
case Union_Body:
|
|
|
|
{
|
2023-08-23 15:16:45 -07:00
|
|
|
check_member_ast( Front );
|
|
|
|
check_member_ast( Back );
|
2023-08-22 13:01:50 -07:00
|
|
|
|
|
|
|
AST* curr = Front;
|
|
|
|
AST* curr_other = other->Front;
|
|
|
|
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"
|
2023-08-23 15:16:45 -07:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
, curr->debug_str()
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-22 13:01:50 -07:00
|
|
|
if ( ! curr->is_equal( 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"
|
2023-08-23 15:16:45 -07:00
|
|
|
"AST : %S\n"
|
|
|
|
"Other: %S\n"
|
|
|
|
"For ast member: %S\n"
|
|
|
|
"other's ast member: %S\n"
|
|
|
|
, debug_str()
|
|
|
|
, other->debug_str()
|
|
|
|
, curr->debug_str()
|
|
|
|
, curr_other->debug_str()
|
|
|
|
);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AST::validate_body()
|
|
|
|
{
|
|
|
|
using namespace ECode;
|
|
|
|
|
2023-07-29 02:52:06 -07:00
|
|
|
#define CheckEntries( Unallowed_Types ) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
for ( Code entry : cast<CodeBody>() ) \
|
|
|
|
{ \
|
|
|
|
switch ( entry->Type ) \
|
|
|
|
{ \
|
|
|
|
Unallowed_Types \
|
|
|
|
log_failure( "AST::validate_body: Invalid entry in body %s", entry.debug_str() ); \
|
|
|
|
return false; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
2023-07-24 14:45:27 -07:00
|
|
|
while (0);
|
|
|
|
|
|
|
|
switch ( Type )
|
|
|
|
{
|
|
|
|
case Class_Body:
|
2023-07-28 18:44:31 -07:00
|
|
|
CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Enum_Body:
|
|
|
|
for ( Code entry : cast<CodeBody>() )
|
|
|
|
{
|
|
|
|
if ( entry->Type != Untyped )
|
|
|
|
{
|
|
|
|
log_failure( "AST::validate_body: Invalid entry in enum body (needs to be untyped or comment) %s", entry.debug_str() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Export_Body:
|
2023-07-28 18:44:31 -07:00
|
|
|
CheckEntries( GEN_AST_BODY_CLASS_UNALLOWED_TYPES );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Extern_Linkage:
|
2023-07-28 18:44:31 -07:00
|
|
|
CheckEntries( GEN_AST_BODY_EXTERN_LINKAGE_UNALLOWED_TYPES );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Function_Body:
|
2023-07-28 18:44:31 -07:00
|
|
|
CheckEntries( GEN_AST_BODY_FUNCTION_UNALLOWED_TYPES );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Global_Body:
|
2023-08-06 11:58:43 -07:00
|
|
|
for (Code entry : cast<CodeBody>())
|
|
|
|
{
|
|
|
|
switch (entry->Type)
|
|
|
|
{
|
|
|
|
case Access_Public:
|
|
|
|
case Access_Protected:
|
|
|
|
case Access_Private:
|
|
|
|
case PlatformAttributes:
|
|
|
|
case Class_Body:
|
|
|
|
case Enum_Body:
|
|
|
|
case Execution:
|
|
|
|
case Friend:
|
|
|
|
case Function_Body:
|
|
|
|
case Global_Body:
|
|
|
|
case Namespace_Body:
|
|
|
|
case Operator_Member:
|
|
|
|
case Operator_Member_Fwd:
|
|
|
|
case Parameters:
|
|
|
|
case Specifiers:
|
|
|
|
case Struct_Body:
|
|
|
|
case Typename:
|
|
|
|
log_failure("AST::validate_body: Invalid entry in body %s", entry.debug_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Namespace_Body:
|
2023-07-28 18:44:31 -07:00
|
|
|
CheckEntries( GEN_AST_BODY_NAMESPACE_UNALLOWED_TYPES );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Struct_Body:
|
2023-07-28 18:44:31 -07:00
|
|
|
CheckEntries( GEN_AST_BODY_STRUCT_UNALLOWED_TYPES );
|
2023-07-24 14:45:27 -07:00
|
|
|
break;
|
|
|
|
case Union_Body:
|
|
|
|
for ( Code entry : Body->cast<CodeBody>() )
|
|
|
|
{
|
|
|
|
if ( entry->Type != Untyped )
|
|
|
|
{
|
|
|
|
log_failure( "AST::validate_body: Invalid entry in union body (needs to be untyped or comment) %s", entry.debug_str() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
log_failure( "AST::validate_body: Invalid this AST does not have a body %s", debug_str() );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2023-07-29 02:52:06 -07:00
|
|
|
|
|
|
|
#undef CheckEntries
|
2023-07-24 14:45:27 -07:00
|
|
|
}
|