mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-15 03:01:47 -07:00
borken : lots of stuff changed, explaining in later commit...v
This commit is contained in:
@ -362,7 +362,9 @@ Code code_duplicate(Code self)
|
||||
{
|
||||
Code result = make_code();
|
||||
|
||||
mem_copy( result.ast, self.ast, sizeof( AST ) );
|
||||
void* mem_result = rcast(void*, cast(AST*, result));
|
||||
void* mem_self = rcast(void*, cast(AST*, self));
|
||||
mem_copy( mem_result, mem_self, sizeof( AST ) );
|
||||
|
||||
result->Parent = { nullptr };
|
||||
return result;
|
||||
@ -409,173 +411,173 @@ void code_to_string_ptr( Code self, String* result )
|
||||
break;
|
||||
|
||||
case CT_Class:
|
||||
to_string_def(cast(CodeClass, self), result );
|
||||
class_to_string_def(cast(CodeClass, self), result );
|
||||
break;
|
||||
|
||||
case CT_Class_Fwd:
|
||||
to_string_fwd(cast(CodeClass, self), result );
|
||||
class_to_string_fwd(cast(CodeClass, self), result );
|
||||
break;
|
||||
|
||||
case CT_Constructor:
|
||||
to_string_def(cast(CodeConstructor, self), result );
|
||||
constructor_to_string_def(cast(CodeConstructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Constructor_Fwd:
|
||||
to_string_fwd(cast(CodeConstructor, self), result );
|
||||
constructor_to_string_fwd(cast(CodeConstructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Destructor:
|
||||
to_string_def(cast(CodeDestructor, self), result );
|
||||
destructor_to_string_def(cast(CodeDestructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Destructor_Fwd:
|
||||
to_string_fwd(cast(CodeDestructor, self), result );
|
||||
destructor_to_string_fwd(cast(CodeDestructor, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum:
|
||||
to_string_def(cast(CodeEnum, self), result );
|
||||
enum_to_string_def(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Fwd:
|
||||
to_string_fwd(cast(CodeEnum, self), result );
|
||||
enum_to_string_fwd(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Class:
|
||||
to_string_class_def(cast(CodeEnum, self), result );
|
||||
enum_to_string_class_def(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Class_Fwd:
|
||||
to_string_class_fwd(cast(CodeEnum, self), result );
|
||||
enum_to_string_class_fwd(cast(CodeEnum, self), result );
|
||||
break;
|
||||
|
||||
case CT_Export_Body:
|
||||
to_string_export(cast(CodeBody, self), result );
|
||||
body_to_string_export(cast(CodeBody, self), result );
|
||||
break;
|
||||
|
||||
case CT_Extern_Linkage:
|
||||
to_string(cast(CodeExtern, self), result );
|
||||
extern_to_string(cast(CodeExtern, self), result );
|
||||
break;
|
||||
|
||||
case CT_Friend:
|
||||
to_string(cast(CodeFriend, self), result );
|
||||
friend_to_string_ref(cast(CodeFriend, self), result );
|
||||
break;
|
||||
|
||||
case CT_Function:
|
||||
to_string_def(cast(CodeFn, self), result );
|
||||
fn_to_string_def(cast(CodeFn, self), result );
|
||||
break;
|
||||
|
||||
case CT_Function_Fwd:
|
||||
to_string_fwd(cast(CodeFn, self), result );
|
||||
fn_to_string_fwd(cast(CodeFn, self), result );
|
||||
break;
|
||||
|
||||
case CT_Module:
|
||||
to_string(cast(CodeModule, self), result );
|
||||
module_to_string_ref(cast(CodeModule, self), result );
|
||||
break;
|
||||
|
||||
case CT_Namespace:
|
||||
to_string(cast(CodeNS, self), result );
|
||||
namespace_to_string_ref(cast(CodeNS, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator:
|
||||
case CT_Operator_Member:
|
||||
to_string_def(cast(CodeOperator, self), result );
|
||||
code_op_to_string_def(cast(CodeOperator, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator_Fwd:
|
||||
case CT_Operator_Member_Fwd:
|
||||
to_string_fwd(cast(CodeOperator, self), result );
|
||||
code_op_to_string_fwd(cast(CodeOperator, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator_Cast:
|
||||
to_string_def(cast(CodeOpCast, self), result );
|
||||
opcast_to_string_def(cast(CodeOpCast, self), result );
|
||||
break;
|
||||
|
||||
case CT_Operator_Cast_Fwd:
|
||||
to_string_fwd(cast(CodeOpCast, self), result );
|
||||
opcast_to_string_fwd(cast(CodeOpCast, self), result );
|
||||
break;
|
||||
|
||||
case CT_Parameters:
|
||||
to_string(cast(CodeParam, self), result );
|
||||
params_to_string_ref(cast(CodeParam, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Define:
|
||||
to_string(cast(CodeDefine, self), result );
|
||||
define_to_string_ref(cast(CodeDefine, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_If:
|
||||
to_string_if(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_if(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_IfDef:
|
||||
to_string_ifdef(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_ifdef(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_IfNotDef:
|
||||
to_string_ifndef(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_ifndef(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Include:
|
||||
to_string(cast(CodeInclude, self), result );
|
||||
include_to_string_ref(cast(CodeInclude, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_ElIf:
|
||||
to_string_elif(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_elif(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Else:
|
||||
to_string_else(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_else(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_EndIf:
|
||||
to_string_endif(cast(CodePreprocessCond, self), result );
|
||||
preprocess_to_string_endif(cast(CodePreprocessCond, self), result );
|
||||
break;
|
||||
|
||||
case CT_Preprocess_Pragma:
|
||||
to_string(cast(CodePragma, self), result );
|
||||
pragma_to_string_ref(cast(CodePragma, self), result );
|
||||
break;
|
||||
|
||||
case CT_Specifiers:
|
||||
to_string(cast(CodeSpecifiers, self), result );
|
||||
specifiers_to_string_ref(cast(CodeSpecifiers, self), result );
|
||||
break;
|
||||
|
||||
case CT_Struct:
|
||||
to_string_def(cast(CodeStruct, self), result );
|
||||
struct_to_string_def(cast(CodeStruct, self), result );
|
||||
break;
|
||||
|
||||
case CT_Struct_Fwd:
|
||||
to_string_fwd(cast(CodeStruct, self), result );
|
||||
struct_to_string_fwd(cast(CodeStruct, self), result );
|
||||
break;
|
||||
|
||||
case CT_Template:
|
||||
to_string(cast(CodeTemplate, self), result );
|
||||
template_to_string_ref(cast(CodeTemplate, self), result );
|
||||
break;
|
||||
|
||||
case CT_Typedef:
|
||||
to_string(cast(CodeTypedef, self), result );
|
||||
typedef_to_string_ref(cast(CodeTypedef, self), result );
|
||||
break;
|
||||
|
||||
case CT_Typename:
|
||||
to_string(cast(CodeTypename, self), result );
|
||||
typename_to_string_ref(cast(CodeTypename, self), result );
|
||||
break;
|
||||
|
||||
case CT_Union:
|
||||
to_string_def( cast(CodeUnion, self), result );
|
||||
union_to_string_def( cast(CodeUnion, self), result );
|
||||
break;
|
||||
|
||||
case CT_Union_Fwd:
|
||||
to_string_fwd( cast(CodeUnion, self), result );
|
||||
union_to_string_fwd( cast(CodeUnion, self), result );
|
||||
break;
|
||||
|
||||
case CT_Using:
|
||||
to_string(cast(CodeUsing, self), result );
|
||||
using_to_string_ref(cast(CodeUsing, self), result );
|
||||
break;
|
||||
|
||||
case CT_Using_Namespace:
|
||||
to_string_ns(cast(CodeUsing, self), result );
|
||||
using_to_string_ns(cast(CodeUsing, self), result );
|
||||
break;
|
||||
|
||||
case CT_Variable:
|
||||
to_string(cast(CodeVar, self), result );
|
||||
var_to_string_ref(cast(CodeVar, self), result );
|
||||
break;
|
||||
|
||||
case CT_Enum_Body:
|
||||
@ -586,7 +588,7 @@ void code_to_string_ptr( Code self, String* result )
|
||||
case CT_Namespace_Body:
|
||||
case CT_Struct_Body:
|
||||
case CT_Union_Body:
|
||||
to_string( cast(CodeBody, self), result );
|
||||
body_to_string_ref( cast(CodeBody, self), result );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1159,20 +1161,20 @@ bool code_is_equal( Code self, Code other )
|
||||
|
||||
bool code_validate_body(Code self)
|
||||
{
|
||||
#define CheckEntries( Unallowed_Types ) \
|
||||
do \
|
||||
{ \
|
||||
CodeBody body = cast(CodeBody, self); \
|
||||
for ( Code code_entry = begin(body); code_entry != end(body); next(body, code_entry) ) \
|
||||
{ \
|
||||
switch ( code_entry->Type ) \
|
||||
{ \
|
||||
Unallowed_Types \
|
||||
log_failure( "AST::validate_body: Invalid entry in body %s", code_debug_str(code_entry) ); \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
#define CheckEntries( Unallowed_Types ) \
|
||||
do \
|
||||
{ \
|
||||
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 ) \
|
||||
{ \
|
||||
Unallowed_Types \
|
||||
log_failure( "AST::validate_body: Invalid entry in body %s", code_debug_str(code_entry) ); \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
while (0);
|
||||
|
||||
switch ( self->Type )
|
||||
@ -1185,7 +1187,7 @@ bool code_validate_body(Code self)
|
||||
case CT_Enum_Body:
|
||||
{
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin(body); entry != end(body); next(body, entry) )
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
||||
{
|
||||
if ( entry->Type != CT_Untyped )
|
||||
{
|
||||
@ -1213,7 +1215,7 @@ bool code_validate_body(Code self)
|
||||
case CT_Global_Body:
|
||||
{
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin(body); entry != end(body); next(body, entry) )
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
||||
{
|
||||
switch (entry->Type)
|
||||
{
|
||||
@ -1253,7 +1255,7 @@ bool code_validate_body(Code self)
|
||||
case CT_Union_Body:
|
||||
{
|
||||
CodeBody body = cast(CodeBody, self);
|
||||
for ( Code entry = begin(body); entry != end(body); next(body, entry) )
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); next_CodeBody(body, entry) )
|
||||
{
|
||||
if ( entry->Type != CT_Untyped )
|
||||
{
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "gen/especifier.hpp"
|
||||
#endif
|
||||
|
||||
GEN_API_C_BEGIN
|
||||
|
||||
struct AST;
|
||||
struct AST_Body;
|
||||
struct AST_Attributes;
|
||||
@ -158,17 +156,20 @@ GEN_NS_PARSER_BEGIN
|
||||
struct Token;
|
||||
GEN_NS_PARSER_END
|
||||
|
||||
#define Token_Typedef struct Token Token
|
||||
typedef Token_Typedef;
|
||||
#undef Token_Typedef
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
GEN_API_C_END
|
||||
template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); }
|
||||
GEN_API_C_BEGIN
|
||||
// Note(Ed): This is to alleviate an edge case with parsing usings or typedefs where I don't really have it setup
|
||||
// to parse a 'namespace' macro or a type with a macro.
|
||||
// I have ideas for ways to pack that into the typedef/using ast, but for now just keeping it like this
|
||||
#define ParserTokenType GEN_NS_PARSER Token
|
||||
typedef ParserTokenType Token;
|
||||
#undef ParserTokenType
|
||||
#endif
|
||||
|
||||
#pragma region Code Interface
|
||||
#if GEN_COMPILER_CPP
|
||||
template< class Type> forceinline Type tmpl_cast( Code self ) { return * rcast( Type*, & self ); }
|
||||
#endif
|
||||
|
||||
#pragma region Code C-Interface
|
||||
void code_append (Code code, Code other );
|
||||
char const* code_debug_str (Code code);
|
||||
Code code_duplicate (Code code);
|
||||
@ -182,10 +183,9 @@ String code_to_string (Code self );
|
||||
void code_to_string_ptr(Code self, String* result );
|
||||
char const* code_type_str (Code self );
|
||||
bool code_validate_body(Code self );
|
||||
#pragma endregion Code Interface
|
||||
#pragma endregion Code C-Interface
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
GEN_API_C_END
|
||||
/*
|
||||
AST* wrapper
|
||||
- Not constantly have to append the '*' as this is written often..
|
||||
@ -195,34 +195,36 @@ struct Code
|
||||
{
|
||||
AST* ast;
|
||||
|
||||
# define Using_Code( Typename ) \
|
||||
char const* debug_str() { return code_debug_str(* this); } \
|
||||
Code duplicate() { return code_duplicate(* this); } \
|
||||
bool is_equal( Code other ) { return code_is_equal(* this, other); } \
|
||||
bool is_body() { return code_is_body(* this); } \
|
||||
bool is_valid() { return code_is_valid(* this); } \
|
||||
void set_global() { return code_set_global(* this); }
|
||||
# define Using_Code( Typename ) \
|
||||
forceinline char const* debug_str() { return code_debug_str(* this); } \
|
||||
forceinline Code duplicate() { return code_duplicate(* this); } \
|
||||
forceinline bool is_equal( Code other ) { return code_is_equal(* this, other); } \
|
||||
forceinline bool is_body() { return code_is_body(* this); } \
|
||||
forceinline bool is_valid() { return code_is_valid(* this); } \
|
||||
forceinline void set_global() { return code_set_global(* this); }
|
||||
|
||||
# define Using_CodeOps( Typename ) \
|
||||
Typename& operator = ( Code other ); \
|
||||
bool operator ==( Code other ) { return (AST*)ast == other.ast; } \
|
||||
bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
|
||||
# define Using_CodeOps( Typename ) \
|
||||
forceinline Typename& operator = ( Code other ); \
|
||||
forceinline bool operator ==( Code other ) { return (AST*)ast == other.ast; } \
|
||||
forceinline bool operator !=( Code other ) { return (AST*)ast != other.ast; } \
|
||||
forceinline bool operator ==(std::nullptr_t) const { return ast == nullptr; } \
|
||||
forceinline bool operator !=(std::nullptr_t) const { return ast != nullptr; } \
|
||||
operator bool();
|
||||
|
||||
#if GEN_SUPPORT_CPP_MEMBER_FEATURES
|
||||
#if ! GEN_C_LIKE_CPP
|
||||
Using_Code( Code );
|
||||
void append(Code other) { return code_append(* this, other); }
|
||||
Code* entry(u32 idx) { return code_entry(* this, idx); }
|
||||
bool has_entries() { return code_has_entries(* this); }
|
||||
String to_string() { return code_to_string(* this); }
|
||||
void to_string(String& result) { return code_to_string_ptr(* this, & result); }
|
||||
char const* type_str() { return code_type_str(* this); }
|
||||
bool validate_body() { return code_validate_body(*this); }
|
||||
forceinline void append(Code other) { return code_append(* this, other); }
|
||||
forceinline Code* entry(u32 idx) { return code_entry(* this, idx); }
|
||||
forceinline bool has_entries() { return code_has_entries(* this); }
|
||||
forceinline String to_string() { return code_to_string(* this); }
|
||||
forceinline void to_string(String& result) { return code_to_string_ptr(* this, & result); }
|
||||
forceinline char const* type_str() { return code_type_str(* this); }
|
||||
forceinline bool validate_body() { return code_validate_body(*this); }
|
||||
#endif
|
||||
|
||||
Using_CodeOps( Code );
|
||||
forceinline AST* operator ->() { return ast; }
|
||||
|
||||
AST* operator ->() { return ast; }
|
||||
Code& operator ++();
|
||||
|
||||
// TODO(Ed) : Remove this overload.
|
||||
@ -237,11 +239,6 @@ struct Code
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(std::nullptr_t) const { return ast == nullptr; }
|
||||
bool operator!=(std::nullptr_t) const { return ast != nullptr; }
|
||||
friend bool operator==(std::nullptr_t, const Code code) { return code.ast == nullptr; }
|
||||
friend bool operator!=(std::nullptr_t, const Code code) { return code.ast != nullptr; }
|
||||
|
||||
#ifdef GEN_ENFORCE_STRONG_CODE_TYPES
|
||||
# define operator explicit operator
|
||||
#endif
|
||||
@ -276,7 +273,6 @@ struct Code
|
||||
operator CodeVar() const;
|
||||
#undef operator
|
||||
};
|
||||
GEN_API_C_BEGIN
|
||||
#endif
|
||||
|
||||
#pragma region Statics
|
||||
@ -287,7 +283,6 @@ extern Code Code_Global;
|
||||
extern Code Code_Invalid;
|
||||
#pragma endregion Statics
|
||||
|
||||
typedef struct Code_POD Code_POD;
|
||||
struct Code_POD
|
||||
{
|
||||
AST* ast;
|
||||
@ -362,7 +357,7 @@ struct AST
|
||||
Code Next;
|
||||
Code Back;
|
||||
};
|
||||
Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
||||
Token* Token; // Reference to starting token, only avaialble if it was derived from parsing.
|
||||
Code Parent;
|
||||
StringCached Name;
|
||||
CodeType Type;
|
||||
@ -385,10 +380,12 @@ static_assert( sizeof(AST) == AST_POD_Size, "ERROR: AST POD is not size of AST_P
|
||||
struct InvalidCode_ImplictCaster;
|
||||
#define InvalidCode (InvalidCode_ImplictCaster{})
|
||||
#else
|
||||
#define InvalidCode Code_Invalid
|
||||
#define InvalidCode { (AST*)Code_Invalid }
|
||||
#endif
|
||||
|
||||
#if GEN_COMPILER_CPP
|
||||
// Used when the its desired when omission is allowed in a definition.
|
||||
#define NullCode { nullptr }
|
||||
|
||||
GEN_API_C_END
|
||||
#else
|
||||
#define NullCode nullptr
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,139 +1,79 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
enum CodeType_Def enum_underlying( u32 )
|
||||
|
||||
{ CT_Invalid,
|
||||
CT_Untyped,
|
||||
CT_NewLine,
|
||||
CT_Comment,
|
||||
CT_Access_Private,
|
||||
CT_Access_Protected,
|
||||
CT_Access_Public,
|
||||
CT_PlatformAttributes,
|
||||
CT_Class,
|
||||
CT_Class_Fwd,
|
||||
CT_Class_Body,
|
||||
CT_Constructor,
|
||||
CT_Constructor_Fwd,
|
||||
CT_Destructor,
|
||||
CT_Destructor_Fwd,
|
||||
CT_Enum,
|
||||
CT_Enum_Fwd,
|
||||
CT_Enum_Body,
|
||||
CT_Enum_Class,
|
||||
CT_Enum_Class_Fwd,
|
||||
CT_Execution,
|
||||
CT_Export_Body,
|
||||
CT_Extern_Linkage,
|
||||
CT_Extern_Linkage_Body,
|
||||
CT_Friend,
|
||||
CT_Function,
|
||||
CT_Function_Fwd,
|
||||
CT_Function_Body,
|
||||
CT_Global_Body,
|
||||
CT_Module,
|
||||
CT_Namespace,
|
||||
CT_Namespace_Body,
|
||||
CT_Operator,
|
||||
CT_Operator_Fwd,
|
||||
CT_Operator_Member,
|
||||
CT_Operator_Member_Fwd,
|
||||
CT_Operator_Cast,
|
||||
CT_Operator_Cast_Fwd,
|
||||
CT_Parameters,
|
||||
CT_Preprocess_Define,
|
||||
CT_Preprocess_Include,
|
||||
CT_Preprocess_If,
|
||||
CT_Preprocess_IfDef,
|
||||
CT_Preprocess_IfNotDef,
|
||||
CT_Preprocess_ElIf,
|
||||
CT_Preprocess_Else,
|
||||
CT_Preprocess_EndIf,
|
||||
CT_Preprocess_Pragma,
|
||||
CT_Specifiers,
|
||||
CT_Struct,
|
||||
CT_Struct_Fwd,
|
||||
CT_Struct_Body,
|
||||
CT_Template,
|
||||
CT_Typedef,
|
||||
CT_Typename,
|
||||
CT_Union,
|
||||
CT_Union_Fwd,
|
||||
CT_Union_Body,
|
||||
CT_Using,
|
||||
CT_Using_Namespace,
|
||||
CT_Variable,
|
||||
CT_NumTypes };
|
||||
typedef enum CodeType_Def CodeType;
|
||||
|
||||
inline StrC codetype_to_str( CodeType type )
|
||||
enum CodeType : u32
|
||||
{
|
||||
local_persist StrC lookup[61] = {
|
||||
{ sizeof( "Invalid" ), "Invalid" },
|
||||
{ sizeof( "Untyped" ), "Untyped" },
|
||||
{ sizeof( "NewLine" ), "NewLine" },
|
||||
{ sizeof( "Comment" ), "Comment" },
|
||||
{ sizeof( "Access_Private" ), "Access_Private" },
|
||||
{ sizeof( "Access_Protected" ), "Access_Protected" },
|
||||
{ sizeof( "Access_Public" ), "Access_Public" },
|
||||
{ sizeof( "PlatformAttributes" ), "PlatformAttributes" },
|
||||
{ sizeof( "Class" ), "Class" },
|
||||
{ sizeof( "Class_Fwd" ), "Class_Fwd" },
|
||||
{ sizeof( "Class_Body" ), "Class_Body" },
|
||||
{ sizeof( "Constructor" ), "Constructor" },
|
||||
{ sizeof( "Constructor_Fwd" ), "Constructor_Fwd" },
|
||||
{ sizeof( "Destructor" ), "Destructor" },
|
||||
{ sizeof( "Destructor_Fwd" ), "Destructor_Fwd" },
|
||||
{ sizeof( "Enum" ), "Enum" },
|
||||
{ sizeof( "Enum_Fwd" ), "Enum_Fwd" },
|
||||
{ sizeof( "Enum_Body" ), "Enum_Body" },
|
||||
{ sizeof( "Enum_Class" ), "Enum_Class" },
|
||||
{ sizeof( "Enum_Class_Fwd" ), "Enum_Class_Fwd" },
|
||||
{ sizeof( "Execution" ), "Execution" },
|
||||
{ sizeof( "Export_Body" ), "Export_Body" },
|
||||
{ sizeof( "Extern_Linkage" ), "Extern_Linkage" },
|
||||
{ sizeof( "Extern_Linkage_Body" ), "Extern_Linkage_Body" },
|
||||
{ sizeof( "Friend" ), "Friend" },
|
||||
{ sizeof( "Function" ), "Function" },
|
||||
{ sizeof( "Function_Fwd" ), "Function_Fwd" },
|
||||
{ sizeof( "Function_Body" ), "Function_Body" },
|
||||
{ sizeof( "Global_Body" ), "Global_Body" },
|
||||
{ sizeof( "Module" ), "Module" },
|
||||
{ sizeof( "Namespace" ), "Namespace" },
|
||||
{ sizeof( "Namespace_Body" ), "Namespace_Body" },
|
||||
{ sizeof( "Operator" ), "Operator" },
|
||||
{ sizeof( "Operator_Fwd" ), "Operator_Fwd" },
|
||||
{ sizeof( "Operator_Member" ), "Operator_Member" },
|
||||
{ sizeof( "Operator_Member_Fwd" ), "Operator_Member_Fwd" },
|
||||
{ sizeof( "Operator_Cast" ), "Operator_Cast" },
|
||||
{ sizeof( "Operator_Cast_Fwd" ), "Operator_Cast_Fwd" },
|
||||
{ sizeof( "Parameters" ), "Parameters" },
|
||||
{ sizeof( "Preprocess_Define" ), "Preprocess_Define" },
|
||||
{ sizeof( "Preprocess_Include" ), "Preprocess_Include" },
|
||||
{ sizeof( "Preprocess_If" ), "Preprocess_If" },
|
||||
{ sizeof( "Preprocess_IfDef" ), "Preprocess_IfDef" },
|
||||
{ sizeof( "Preprocess_IfNotDef" ), "Preprocess_IfNotDef" },
|
||||
{ sizeof( "Preprocess_ElIf" ), "Preprocess_ElIf" },
|
||||
{ sizeof( "Preprocess_Else" ), "Preprocess_Else" },
|
||||
{ sizeof( "Preprocess_EndIf" ), "Preprocess_EndIf" },
|
||||
{ sizeof( "Preprocess_Pragma" ), "Preprocess_Pragma" },
|
||||
{ sizeof( "Specifiers" ), "Specifiers" },
|
||||
{ sizeof( "Struct" ), "Struct" },
|
||||
{ sizeof( "Struct_Fwd" ), "Struct_Fwd" },
|
||||
{ sizeof( "Struct_Body" ), "Struct_Body" },
|
||||
{ sizeof( "Template" ), "Template" },
|
||||
{ sizeof( "Typedef" ), "Typedef" },
|
||||
{ sizeof( "Typename" ), "Typename" },
|
||||
{ sizeof( "Union" ), "Union" },
|
||||
{ sizeof( "Union_Fwd" ), "Union_Fwd" },
|
||||
{ sizeof( "Union_Body" ), "Union_Body" },
|
||||
{ sizeof( "Using" ), "Using" },
|
||||
{ sizeof( "Using_Namespace" ), "Using_Namespace" },
|
||||
{ sizeof( "Variable" ), "Variable" },
|
||||
};
|
||||
return lookup[type];
|
||||
CT_Invalid,CT_Untyped,CT_NewLine,CT_Comment,CT_Access_Private,CT_Access_Protected,CT_Access_Public,CT_PlatformAttributes,CT_Class,CT_Class_Fwd,CT_Class_Body,CT_Constructor,CT_Constructor_Fwd,CT_Destructor,CT_Destructor_Fwd,CT_Enum,CT_Enum_Fwd,CT_Enum_Body,CT_Enum_Class,CT_Enum_Class_Fwd,CT_Execution,CT_Export_Body,CT_Extern_Linkage,CT_Extern_Linkage_Body,CT_Friend,CT_Function,CT_Function_Fwd,CT_Function_Body,CT_Global_Body,CT_Module,CT_Namespace,CT_Namespace_Body,CT_Operator,CT_Operator_Fwd,CT_Operator_Member,CT_Operator_Member_Fwd,CT_Operator_Cast,CT_Operator_Cast_Fwd,CT_Parameters,CT_Preprocess_Define,CT_Preprocess_Include,CT_Preprocess_If,CT_Preprocess_IfDef,CT_Preprocess_IfNotDef,CT_Preprocess_ElIf,CT_Preprocess_Else,CT_Preprocess_EndIf,CT_Preprocess_Pragma,CT_Specifiers,CT_Struct,CT_Struct_Fwd,CT_Struct_Body,CT_Template,CT_Typedef,CT_Typename,CT_Union,CT_Union_Fwd,CT_Union_Body,CT_Using,CT_Using_Namespace,CT_Variable,CT_NumTypes
|
||||
};
|
||||
typedef enum CodeType CodeType;
|
||||
inline
|
||||
StrC codetype_to_str( CodeType type)
|
||||
{
|
||||
local_persist StrC lookup[61] = { { sizeof("Invalid"), "Invalid" },
|
||||
{ sizeof("Untyped"), "Untyped" },
|
||||
{ sizeof("NewLine"), "NewLine" },
|
||||
{ sizeof("Comment"), "Comment" },
|
||||
{ sizeof("Access_Private"), "Access_Private" },
|
||||
{ sizeof("Access_Protected"), "Access_Protected" },
|
||||
{ sizeof("Access_Public"), "Access_Public" },
|
||||
{ sizeof("PlatformAttributes"), "PlatformAttributes" },
|
||||
{ sizeof("Class"), "Class" },
|
||||
{ sizeof("Class_Fwd"), "Class_Fwd" },
|
||||
{ sizeof("Class_Body"), "Class_Body" },
|
||||
{ sizeof("Constructor"), "Constructor" },
|
||||
{ sizeof("Constructor_Fwd"), "Constructor_Fwd" },
|
||||
{ sizeof("Destructor"), "Destructor" },
|
||||
{ sizeof("Destructor_Fwd"), "Destructor_Fwd" },
|
||||
{ sizeof("Enum"), "Enum" },
|
||||
{ sizeof("Enum_Fwd"), "Enum_Fwd" },
|
||||
{ sizeof("Enum_Body"), "Enum_Body" },
|
||||
{ sizeof("Enum_Class"), "Enum_Class" },
|
||||
{ sizeof("Enum_Class_Fwd"), "Enum_Class_Fwd" },
|
||||
{ sizeof("Execution"), "Execution" },
|
||||
{ sizeof("Export_Body"), "Export_Body" },
|
||||
{ sizeof("Extern_Linkage"), "Extern_Linkage" },
|
||||
{ sizeof("Extern_Linkage_Body"), "Extern_Linkage_Body" },
|
||||
{ sizeof("Friend"), "Friend" },
|
||||
{ sizeof("Function"), "Function" },
|
||||
{ sizeof("Function_Fwd"), "Function_Fwd" },
|
||||
{ sizeof("Function_Body"), "Function_Body" },
|
||||
{ sizeof("Global_Body"), "Global_Body" },
|
||||
{ sizeof("Module"), "Module" },
|
||||
{ sizeof("Namespace"), "Namespace" },
|
||||
{ sizeof("Namespace_Body"), "Namespace_Body" },
|
||||
{ sizeof("Operator"), "Operator" },
|
||||
{ sizeof("Operator_Fwd"), "Operator_Fwd" },
|
||||
{ sizeof("Operator_Member"), "Operator_Member" },
|
||||
{ sizeof("Operator_Member_Fwd"), "Operator_Member_Fwd" },
|
||||
{ sizeof("Operator_Cast"), "Operator_Cast" },
|
||||
{ sizeof("Operator_Cast_Fwd"), "Operator_Cast_Fwd" },
|
||||
{ sizeof("Parameters"), "Parameters" },
|
||||
{ sizeof("Preprocess_Define"), "Preprocess_Define" },
|
||||
{ sizeof("Preprocess_Include"), "Preprocess_Include" },
|
||||
{ sizeof("Preprocess_If"), "Preprocess_If" },
|
||||
{ sizeof("Preprocess_IfDef"), "Preprocess_IfDef" },
|
||||
{ sizeof("Preprocess_IfNotDef"), "Preprocess_IfNotDef" },
|
||||
{ sizeof("Preprocess_ElIf"), "Preprocess_ElIf" },
|
||||
{ sizeof("Preprocess_Else"), "Preprocess_Else" },
|
||||
{ sizeof("Preprocess_EndIf"), "Preprocess_EndIf" },
|
||||
{ sizeof("Preprocess_Pragma"), "Preprocess_Pragma" },
|
||||
{ sizeof("Specifiers"), "Specifiers" },
|
||||
{ sizeof("Struct"), "Struct" },
|
||||
{ sizeof("Struct_Fwd"), "Struct_Fwd" },
|
||||
{ sizeof("Struct_Body"), "Struct_Body" },
|
||||
{ sizeof("Template"), "Template" },
|
||||
{ sizeof("Typedef"), "Typedef" },
|
||||
{ sizeof("Typename"), "Typename" },
|
||||
{ sizeof("Union"), "Union" },
|
||||
{ sizeof("Union_Fwd"), "Union_Fwd" },
|
||||
{ sizeof("Union_Body"), "Union_Body" },
|
||||
{ sizeof("Using"), "Using" },
|
||||
{ sizeof("Using_Namespace"), "Using_Namespace" },
|
||||
{ sizeof("Variable"), "Variable" },
|
||||
}; return lookup[ type ];
|
||||
}
|
||||
|
||||
|
@ -1,111 +1,65 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
enum Operator_Def enum_underlying( u32 )
|
||||
|
||||
{ Op_Invalid,
|
||||
Op_Assign,
|
||||
Op_Assign_Add,
|
||||
Op_Assign_Subtract,
|
||||
Op_Assign_Multiply,
|
||||
Op_Assign_Divide,
|
||||
Op_Assign_Modulo,
|
||||
Op_Assign_BAnd,
|
||||
Op_Assign_BOr,
|
||||
Op_Assign_BXOr,
|
||||
Op_Assign_LShift,
|
||||
Op_Assign_RShift,
|
||||
Op_Increment,
|
||||
Op_Decrement,
|
||||
Op_Unary_Plus,
|
||||
Op_Unary_Minus,
|
||||
Op_UnaryNot,
|
||||
Op_Add,
|
||||
Op_Subtract,
|
||||
Op_Multiply,
|
||||
Op_Divide,
|
||||
Op_Modulo,
|
||||
Op_BNot,
|
||||
Op_BAnd,
|
||||
Op_BOr,
|
||||
Op_BXOr,
|
||||
Op_LShift,
|
||||
Op_RShift,
|
||||
Op_LAnd,
|
||||
Op_LOr,
|
||||
Op_LEqual,
|
||||
Op_LNot,
|
||||
Op_Lesser,
|
||||
Op_Greater,
|
||||
Op_LesserEqual,
|
||||
Op_GreaterEqual,
|
||||
Op_Subscript,
|
||||
Op_Indirection,
|
||||
Op_AddressOf,
|
||||
Op_MemberOfPointer,
|
||||
Op_PtrToMemOfPtr,
|
||||
Op_FunctionCall,
|
||||
Op_Comma,
|
||||
Op_New,
|
||||
Op_NewArray,
|
||||
Op_Delete,
|
||||
Op_DeleteArray,
|
||||
NumOps };
|
||||
typedef enum Operator_Def Operator;
|
||||
|
||||
inline StrC operator_to_str( Operator op )
|
||||
enum Operator : u32
|
||||
{
|
||||
local_persist StrC lookup[47] = {
|
||||
{ sizeof( "INVALID" ), "INVALID" },
|
||||
{ sizeof( "=" ), "=" },
|
||||
{ sizeof( "+=" ), "+=" },
|
||||
{ sizeof( "-=" ), "-=" },
|
||||
{ sizeof( "*=" ), "*=" },
|
||||
{ sizeof( "/=" ), "/=" },
|
||||
{ sizeof( "%=" ), "%=" },
|
||||
{ sizeof( "&=" ), "&=" },
|
||||
{ sizeof( "|=" ), "|=" },
|
||||
{ sizeof( "^=" ), "^=" },
|
||||
{ sizeof( "<<=" ), "<<=" },
|
||||
{ sizeof( ">>=" ), ">>=" },
|
||||
{ sizeof( "++" ), "++" },
|
||||
{ sizeof( "--" ), "--" },
|
||||
{ sizeof( "+" ), "+" },
|
||||
{ sizeof( "-" ), "-" },
|
||||
{ sizeof( "!" ), "!" },
|
||||
{ sizeof( "+" ), "+" },
|
||||
{ sizeof( "-" ), "-" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( "/" ), "/" },
|
||||
{ sizeof( "%" ), "%" },
|
||||
{ sizeof( "~" ), "~" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "|" ), "|" },
|
||||
{ sizeof( "^" ), "^" },
|
||||
{ sizeof( "<<" ), "<<" },
|
||||
{ sizeof( ">>" ), ">>" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( "||" ), "||" },
|
||||
{ sizeof( "==" ), "==" },
|
||||
{ sizeof( "!=" ), "!=" },
|
||||
{ sizeof( "<" ), "<" },
|
||||
{ sizeof( ">" ), ">" },
|
||||
{ sizeof( "<=" ), "<=" },
|
||||
{ sizeof( ">=" ), ">=" },
|
||||
{ sizeof( "[]" ), "[]" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "->" ), "->" },
|
||||
{ sizeof( "->*" ), "->*" },
|
||||
{ sizeof( "()" ), "()" },
|
||||
{ sizeof( "," ), "," },
|
||||
{ sizeof( "new" ), "new" },
|
||||
{ sizeof( "new[]" ), "new[]" },
|
||||
{ sizeof( "delete" ), "delete" },
|
||||
{ sizeof( "delete[]" ), "delete[]" },
|
||||
};
|
||||
return lookup[op];
|
||||
Op_Invalid,Op_Assign,Op_Assign_Add,Op_Assign_Subtract,Op_Assign_Multiply,Op_Assign_Divide,Op_Assign_Modulo,Op_Assign_BAnd,Op_Assign_BOr,Op_Assign_BXOr,Op_Assign_LShift,Op_Assign_RShift,Op_Increment,Op_Decrement,Op_Unary_Plus,Op_Unary_Minus,Op_UnaryNot,Op_Add,Op_Subtract,Op_Multiply,Op_Divide,Op_Modulo,Op_BNot,Op_BAnd,Op_BOr,Op_BXOr,Op_LShift,Op_RShift,Op_LAnd,Op_LOr,Op_LEqual,Op_LNot,Op_Lesser,Op_Greater,Op_LesserEqual,Op_GreaterEqual,Op_Subscript,Op_Indirection,Op_AddressOf,Op_MemberOfPointer,Op_PtrToMemOfPtr,Op_FunctionCall,Op_Comma,Op_New,Op_NewArray,Op_Delete,Op_DeleteArray,NumOps
|
||||
};
|
||||
typedef enum Operator Operator;
|
||||
inline
|
||||
StrC operator_to_str( Operator op)
|
||||
{
|
||||
local_persist StrC lookup[47] = { { sizeof("INVALID"), "INVALID" },
|
||||
{ sizeof("="), "=" },
|
||||
{ sizeof("+="), "+=" },
|
||||
{ sizeof("-="), "-=" },
|
||||
{ sizeof("*="), "*=" },
|
||||
{ sizeof("/="), "/=" },
|
||||
{ sizeof("%="), "%=" },
|
||||
{ sizeof("&="), "&=" },
|
||||
{ sizeof("|="), "|=" },
|
||||
{ sizeof("^="), "^=" },
|
||||
{ sizeof("<<="), "<<=" },
|
||||
{ sizeof(">>="), ">>=" },
|
||||
{ sizeof("++"), "++" },
|
||||
{ sizeof("--"), "--" },
|
||||
{ sizeof("+"), "+" },
|
||||
{ sizeof("-"), "-" },
|
||||
{ sizeof("!"), "!" },
|
||||
{ sizeof("+"), "+" },
|
||||
{ sizeof("-"), "-" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof("/"), "/" },
|
||||
{ sizeof("%"), "%" },
|
||||
{ sizeof("~"), "~" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("|"), "|" },
|
||||
{ sizeof("^"), "^" },
|
||||
{ sizeof("<<"), "<<" },
|
||||
{ sizeof(">>"), ">>" },
|
||||
{ sizeof("&&"), "&&" },
|
||||
{ sizeof("||"), "||" },
|
||||
{ sizeof("=="), "==" },
|
||||
{ sizeof("!="), "!=" },
|
||||
{ sizeof("<"), "<" },
|
||||
{ sizeof(">"), ">" },
|
||||
{ sizeof("<="), "<=" },
|
||||
{ sizeof(">="), ">=" },
|
||||
{ sizeof("[]"), "[]" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("->"), "->" },
|
||||
{ sizeof("->*"), "->*" },
|
||||
{ sizeof("()"), "()" },
|
||||
{ sizeof(","), "," },
|
||||
{ sizeof("new"), "new" },
|
||||
{ sizeof("new[]"), "new[]" },
|
||||
{ sizeof("delete"), "delete" },
|
||||
{ sizeof("delete[]"), "delete[]" },
|
||||
}; return lookup[ op ];
|
||||
}
|
||||
|
||||
|
@ -1,68 +1,54 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
enum Specifier_Def enum_underlying( u32 )
|
||||
|
||||
{ Spec_Invalid, Spec_Consteval, Spec_Constexpr, Spec_Constinit, Spec_Explicit, Spec_External_Linkage, Spec_ForceInline,
|
||||
Spec_Global, Spec_Inline, Spec_Internal_Linkage, Spec_Local_Persist, Spec_Mutable, Spec_NeverInline, Spec_Ptr,
|
||||
Spec_Ref, Spec_Register, Spec_RValue, Spec_Static, Spec_Thread_Local, Spec_Virtual, Spec_Const,
|
||||
Spec_Final, Spec_NoExceptions, Spec_Override, Spec_Pure, Spec_Volatile, Spec_NumSpecifiers };
|
||||
typedef enum Specifier_Def Specifier;
|
||||
|
||||
inline bool spec_is_trailing( Specifier specifier )
|
||||
enum Specifier : u32
|
||||
{
|
||||
return specifier > Spec_Virtual;
|
||||
Spec_Invalid,Spec_Consteval,Spec_Constexpr,Spec_Constinit,Spec_Explicit,Spec_External_Linkage,Spec_ForceInline,Spec_Global,Spec_Inline,Spec_Internal_Linkage,Spec_Local_Persist,Spec_Mutable,Spec_NeverInline,Spec_Ptr,Spec_Ref,Spec_Register,Spec_RValue,Spec_Static,Spec_Thread_Local,Spec_Virtual,Spec_Const,Spec_Final,Spec_NoExceptions,Spec_Override,Spec_Pure,Spec_Volatile,Spec_NumSpecifiers
|
||||
};
|
||||
typedef enum Specifier Specifier;
|
||||
inline
|
||||
bool spec_is_trailing( Specifier specifier)
|
||||
{
|
||||
return specifier > Spec_Virtual;
|
||||
}
|
||||
inline
|
||||
StrC spec_to_str( Specifier type)
|
||||
{
|
||||
local_persist StrC lookup[26] = { { sizeof("INVALID"), "INVALID" },
|
||||
{ sizeof("consteval"), "consteval" },
|
||||
{ sizeof("constexpr"), "constexpr" },
|
||||
{ sizeof("constinit"), "constinit" },
|
||||
{ sizeof("explicit"), "explicit" },
|
||||
{ sizeof("extern"), "extern" },
|
||||
{ sizeof("forceinline"), "forceinline" },
|
||||
{ sizeof("global"), "global" },
|
||||
{ sizeof("inline"), "inline" },
|
||||
{ sizeof("internal"), "internal" },
|
||||
{ sizeof("local_persist"), "local_persist" },
|
||||
{ sizeof("mutable"), "mutable" },
|
||||
{ sizeof("neverinline"), "neverinline" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("register"), "register" },
|
||||
{ sizeof("&&"), "&&" },
|
||||
{ sizeof("static"), "static" },
|
||||
{ sizeof("thread_local"), "thread_local" },
|
||||
{ sizeof("virtual"), "virtual" },
|
||||
{ sizeof("const"), "const" },
|
||||
{ sizeof("final"), "final" },
|
||||
{ sizeof("noexcept"), "noexcept" },
|
||||
{ sizeof("override"), "override" },
|
||||
{ sizeof("= 0"), "= 0" },
|
||||
{ sizeof("volatile"), "volatile" },
|
||||
}; return lookup[ type ];
|
||||
}
|
||||
inline
|
||||
Specifier strc_to_specifier( StrC str)
|
||||
{
|
||||
local_persist u32 keymap[ Spec_NumSpecifiers ]; do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { StrC enum_str = spec_to_str( (Specifier)index ); keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Spec_NumSpecifiers; index++ ) { if ( keymap[index] == hash ) return (Specifier)index; } return Spec_Invalid;
|
||||
}
|
||||
|
||||
inline StrC spec_to_str( Specifier type )
|
||||
{
|
||||
local_persist StrC lookup[26] = {
|
||||
{ sizeof( "INVALID" ), "INVALID" },
|
||||
{ sizeof( "consteval" ), "consteval" },
|
||||
{ sizeof( "constexpr" ), "constexpr" },
|
||||
{ sizeof( "constinit" ), "constinit" },
|
||||
{ sizeof( "explicit" ), "explicit" },
|
||||
{ sizeof( "extern" ), "extern" },
|
||||
{ sizeof( "forceinline" ), "forceinline" },
|
||||
{ sizeof( "global" ), "global" },
|
||||
{ sizeof( "inline" ), "inline" },
|
||||
{ sizeof( "internal" ), "internal" },
|
||||
{ sizeof( "local_persist" ), "local_persist" },
|
||||
{ sizeof( "mutable" ), "mutable" },
|
||||
{ sizeof( "neverinline" ), "neverinline" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "register" ), "register" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( "static" ), "static" },
|
||||
{ sizeof( "thread_local" ), "thread_local" },
|
||||
{ sizeof( "virtual" ), "virtual" },
|
||||
{ sizeof( "const" ), "const" },
|
||||
{ sizeof( "final" ), "final" },
|
||||
{ sizeof( "noexcept" ), "noexcept" },
|
||||
{ sizeof( "override" ), "override" },
|
||||
{ sizeof( "= 0" ), "= 0" },
|
||||
{ sizeof( "volatile" ), "volatile" },
|
||||
};
|
||||
return lookup[type];
|
||||
}
|
||||
|
||||
inline Specifier strc_to_specifier( StrC str )
|
||||
{
|
||||
local_persist u32 keymap[Spec_NumSpecifiers];
|
||||
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||
{
|
||||
StrC enum_str = spec_to_str( (Specifier)index );
|
||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
||||
}
|
||||
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
||||
for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
|
||||
{
|
||||
if ( keymap[index] == hash )
|
||||
return (Specifier)index;
|
||||
}
|
||||
return Spec_Invalid;
|
||||
}
|
||||
|
@ -1,234 +1,124 @@
|
||||
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
||||
#pragma once #include "components/types.hpp"
|
||||
#pragma once
|
||||
#include "components/types.hpp"
|
||||
#endif
|
||||
|
||||
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
|
||||
|
||||
GEN_NS_PARSER_BEGIN
|
||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
|
||||
#define GEN_DEFINE_ATTRIBUTE_TOKENS Entry( Tok_Attribute_API_Export, "GEN_API_Export_Code" ) \
|
||||
Entry( Tok_Attribute_API_Import, "GEN_API_Import_Code" )
|
||||
|
||||
enum TokType_Def : u32
|
||||
{
|
||||
Tok_Invalid,
|
||||
Tok_Access_Private,
|
||||
Tok_Access_Protected,
|
||||
Tok_Access_Public,
|
||||
Tok_Access_MemberSymbol,
|
||||
Tok_Access_StaticSymbol,
|
||||
Tok_Ampersand,
|
||||
Tok_Ampersand_DBL,
|
||||
Tok_Assign_Classifer,
|
||||
Tok_Attribute_Open,
|
||||
Tok_Attribute_Close,
|
||||
Tok_BraceCurly_Open,
|
||||
Tok_BraceCurly_Close,
|
||||
Tok_BraceSquare_Open,
|
||||
Tok_BraceSquare_Close,
|
||||
Tok_Capture_Start,
|
||||
Tok_Capture_End,
|
||||
Tok_Comment,
|
||||
Tok_Comment_End,
|
||||
Tok_Comment_Start,
|
||||
Tok_Char,
|
||||
Tok_Comma,
|
||||
Tok_Decl_Class,
|
||||
Tok_Decl_GNU_Attribute,
|
||||
Tok_Decl_MSVC_Attribute,
|
||||
Tok_Decl_Enum,
|
||||
Tok_Decl_Extern_Linkage,
|
||||
Tok_Decl_Friend,
|
||||
Tok_Decl_Module,
|
||||
Tok_Decl_Namespace,
|
||||
Tok_Decl_Operator,
|
||||
Tok_Decl_Struct,
|
||||
Tok_Decl_Template,
|
||||
Tok_Decl_Typedef,
|
||||
Tok_Decl_Using,
|
||||
Tok_Decl_Union,
|
||||
Tok_Identifier,
|
||||
Tok_Module_Import,
|
||||
Tok_Module_Export,
|
||||
Tok_NewLine,
|
||||
Tok_Number,
|
||||
Tok_Operator,
|
||||
Tok_Preprocess_Hash,
|
||||
Tok_Preprocess_Define,
|
||||
Tok_Preprocess_If,
|
||||
Tok_Preprocess_IfDef,
|
||||
Tok_Preprocess_IfNotDef,
|
||||
Tok_Preprocess_ElIf,
|
||||
Tok_Preprocess_Else,
|
||||
Tok_Preprocess_EndIf,
|
||||
Tok_Preprocess_Include,
|
||||
Tok_Preprocess_Pragma,
|
||||
Tok_Preprocess_Content,
|
||||
Tok_Preprocess_Macro,
|
||||
Tok_Preprocess_Unsupported,
|
||||
Tok_Spec_Alignas,
|
||||
Tok_Spec_Const,
|
||||
Tok_Spec_Consteval,
|
||||
Tok_Spec_Constexpr,
|
||||
Tok_Spec_Constinit,
|
||||
Tok_Spec_Explicit,
|
||||
Tok_Spec_Extern,
|
||||
Tok_Spec_Final,
|
||||
Tok_Spec_ForceInline,
|
||||
Tok_Spec_Global,
|
||||
Tok_Spec_Inline,
|
||||
Tok_Spec_Internal_Linkage,
|
||||
Tok_Spec_LocalPersist,
|
||||
Tok_Spec_Mutable,
|
||||
Tok_Spec_NeverInline,
|
||||
Tok_Spec_Override,
|
||||
Tok_Spec_Static,
|
||||
Tok_Spec_ThreadLocal,
|
||||
Tok_Spec_Volatile,
|
||||
Tok_Spec_Virtual,
|
||||
Tok_Star,
|
||||
Tok_Statement_End,
|
||||
Tok_StaticAssert,
|
||||
Tok_String,
|
||||
Tok_Type_Typename,
|
||||
Tok_Type_Unsigned,
|
||||
Tok_Type_Signed,
|
||||
Tok_Type_Short,
|
||||
Tok_Type_Long,
|
||||
Tok_Type_bool,
|
||||
Tok_Type_char,
|
||||
Tok_Type_int,
|
||||
Tok_Type_double,
|
||||
Tok_Type_MS_int8,
|
||||
Tok_Type_MS_int16,
|
||||
Tok_Type_MS_int32,
|
||||
Tok_Type_MS_int64,
|
||||
Tok_Type_MS_W64,
|
||||
Tok_Varadic_Argument,
|
||||
Tok___Attributes_Start,
|
||||
Tok_Attribute_API_Export,
|
||||
Tok_Attribute_API_Import,
|
||||
Tok_NumTokens
|
||||
Tok_Invalid,Tok_Access_Private,Tok_Access_Protected,Tok_Access_Public,Tok_Access_MemberSymbol,Tok_Access_StaticSymbol,Tok_Ampersand,Tok_Ampersand_DBL,Tok_Assign_Classifer,Tok_Attribute_Open,Tok_Attribute_Close,Tok_BraceCurly_Open,Tok_BraceCurly_Close,Tok_BraceSquare_Open,Tok_BraceSquare_Close,Tok_Capture_Start,Tok_Capture_End,Tok_Comment,Tok_Comment_End,Tok_Comment_Start,Tok_Char,Tok_Comma,Tok_Decl_Class,Tok_Decl_GNU_Attribute,Tok_Decl_MSVC_Attribute,Tok_Decl_Enum,Tok_Decl_Extern_Linkage,Tok_Decl_Friend,Tok_Decl_Module,Tok_Decl_Namespace,Tok_Decl_Operator,Tok_Decl_Struct,Tok_Decl_Template,Tok_Decl_Typedef,Tok_Decl_Using,Tok_Decl_Union,Tok_Identifier,Tok_Module_Import,Tok_Module_Export,Tok_NewLine,Tok_Number,Tok_Operator,Tok_Preprocess_Hash,Tok_Preprocess_Define,Tok_Preprocess_If,Tok_Preprocess_IfDef,Tok_Preprocess_IfNotDef,Tok_Preprocess_ElIf,Tok_Preprocess_Else,Tok_Preprocess_EndIf,Tok_Preprocess_Include,Tok_Preprocess_Pragma,Tok_Preprocess_Content,Tok_Preprocess_Macro,Tok_Preprocess_Unsupported,Tok_Spec_Alignas,Tok_Spec_Const,Tok_Spec_Consteval,Tok_Spec_Constexpr,Tok_Spec_Constinit,Tok_Spec_Explicit,Tok_Spec_Extern,Tok_Spec_Final,Tok_Spec_ForceInline,Tok_Spec_Global,Tok_Spec_Inline,Tok_Spec_Internal_Linkage,Tok_Spec_LocalPersist,Tok_Spec_Mutable,Tok_Spec_NeverInline,Tok_Spec_Override,Tok_Spec_Static,Tok_Spec_ThreadLocal,Tok_Spec_Volatile,Tok_Spec_Virtual,Tok_Star,Tok_Statement_End,Tok_StaticAssert,Tok_String,Tok_Type_Typename,Tok_Type_Unsigned,Tok_Type_Signed,Tok_Type_Short,Tok_Type_Long,Tok_Type_bool,Tok_Type_char,Tok_Type_int,Tok_Type_double,Tok_Type_MS_int8,Tok_Type_MS_int16,Tok_Type_MS_int32,Tok_Type_MS_int64,Tok_Type_MS_W64,Tok_Varadic_Argument,Tok___Attributes_Start,Tok_Attribute_API_Export,Tok_Attribute_API_Import,Tok_NumTokens
|
||||
};
|
||||
typedef enum TokType_Def TokType;
|
||||
|
||||
inline StrC to_str( TokType type )
|
||||
inline
|
||||
StrC to_str( TokType type)
|
||||
{
|
||||
local_persist StrC lookup[] {
|
||||
{ sizeof( "__invalid__" ), "__invalid__" },
|
||||
{ sizeof( "private" ), "private" },
|
||||
{ sizeof( "protected" ), "protected" },
|
||||
{ sizeof( "public" ), "public" },
|
||||
{ sizeof( "." ), "." },
|
||||
{ sizeof( "::" ), "::" },
|
||||
{ sizeof( "&" ), "&" },
|
||||
{ sizeof( "&&" ), "&&" },
|
||||
{ sizeof( ":" ), ":" },
|
||||
{ sizeof( "[[" ), "[[" },
|
||||
{ sizeof( "]]" ), "]]" },
|
||||
{ sizeof( "{" ), "{" },
|
||||
{ sizeof( "}" ), "}" },
|
||||
{ sizeof( "[" ), "[" },
|
||||
{ sizeof( "]" ), "]" },
|
||||
{ sizeof( "(" ), "(" },
|
||||
{ sizeof( ")" ), ")" },
|
||||
{ sizeof( "__comment__" ), "__comment__" },
|
||||
{ sizeof( "__comment_end__" ), "__comment_end__" },
|
||||
{ sizeof( "__comment_start__" ), "__comment_start__" },
|
||||
{ sizeof( "__character__" ), "__character__" },
|
||||
{ sizeof( "," ), "," },
|
||||
{ sizeof( "class" ), "class" },
|
||||
{ sizeof( "__attribute__" ), "__attribute__" },
|
||||
{ sizeof( "__declspec" ), "__declspec" },
|
||||
{ sizeof( "enum" ), "enum" },
|
||||
{ sizeof( "extern" ), "extern" },
|
||||
{ sizeof( "friend" ), "friend" },
|
||||
{ sizeof( "module" ), "module" },
|
||||
{ sizeof( "namespace" ), "namespace" },
|
||||
{ sizeof( "operator" ), "operator" },
|
||||
{ sizeof( "struct" ), "struct" },
|
||||
{ sizeof( "template" ), "template" },
|
||||
{ sizeof( "typedef" ), "typedef" },
|
||||
{ sizeof( "using" ), "using" },
|
||||
{ sizeof( "union" ), "union" },
|
||||
{ sizeof( "__identifier__" ), "__identifier__" },
|
||||
{ sizeof( "import" ), "import" },
|
||||
{ sizeof( "export" ), "export" },
|
||||
{ sizeof( "__new_line__" ), "__new_line__" },
|
||||
{ sizeof( "__number__" ), "__number__" },
|
||||
{ sizeof( "__operator__" ), "__operator__" },
|
||||
{ sizeof( "#" ), "#" },
|
||||
{ sizeof( "define" ), "define" },
|
||||
{ sizeof( "if" ), "if" },
|
||||
{ sizeof( "ifdef" ), "ifdef" },
|
||||
{ sizeof( "ifndef" ), "ifndef" },
|
||||
{ sizeof( "elif" ), "elif" },
|
||||
{ sizeof( "else" ), "else" },
|
||||
{ sizeof( "endif" ), "endif" },
|
||||
{ sizeof( "include" ), "include" },
|
||||
{ sizeof( "pragma" ), "pragma" },
|
||||
{ sizeof( "__macro_content__" ), "__macro_content__" },
|
||||
{ sizeof( "__macro__" ), "__macro__" },
|
||||
{ sizeof( "__unsupported__" ), "__unsupported__" },
|
||||
{ sizeof( "alignas" ), "alignas" },
|
||||
{ sizeof( "const" ), "const" },
|
||||
{ sizeof( "consteval" ), "consteval" },
|
||||
{ sizeof( "constexpr" ), "constexpr" },
|
||||
{ sizeof( "constinit" ), "constinit" },
|
||||
{ sizeof( "explicit" ), "explicit" },
|
||||
{ sizeof( "extern" ), "extern" },
|
||||
{ sizeof( "final" ), "final" },
|
||||
{ sizeof( "forceinline" ), "forceinline" },
|
||||
{ sizeof( "global" ), "global" },
|
||||
{ sizeof( "inline" ), "inline" },
|
||||
{ sizeof( "internal" ), "internal" },
|
||||
{ sizeof( "local_persist" ), "local_persist" },
|
||||
{ sizeof( "mutable" ), "mutable" },
|
||||
{ sizeof( "neverinline" ), "neverinline" },
|
||||
{ sizeof( "override" ), "override" },
|
||||
{ sizeof( "static" ), "static" },
|
||||
{ sizeof( "thread_local" ), "thread_local" },
|
||||
{ sizeof( "volatile" ), "volatile" },
|
||||
{ sizeof( "virtual" ), "virtual" },
|
||||
{ sizeof( "*" ), "*" },
|
||||
{ sizeof( ";" ), ";" },
|
||||
{ sizeof( "static_assert" ), "static_assert" },
|
||||
{ sizeof( "__string__" ), "__string__" },
|
||||
{ sizeof( "typename" ), "typename" },
|
||||
{ sizeof( "unsigned" ), "unsigned" },
|
||||
{ sizeof( "signed" ), "signed" },
|
||||
{ sizeof( "short" ), "short" },
|
||||
{ sizeof( "long" ), "long" },
|
||||
{ sizeof( "bool" ), "bool" },
|
||||
{ sizeof( "char" ), "char" },
|
||||
{ sizeof( "int" ), "int" },
|
||||
{ sizeof( "double" ), "double" },
|
||||
{ sizeof( "__int8" ), "__int8" },
|
||||
{ sizeof( "__int16" ), "__int16" },
|
||||
{ sizeof( "__int32" ), "__int32" },
|
||||
{ sizeof( "__int64" ), "__int64" },
|
||||
{ sizeof( "_W64" ), "_W64" },
|
||||
{ sizeof( "..." ), "..." },
|
||||
{ sizeof( "__attrib_start__" ), "__attrib_start__" },
|
||||
{ sizeof( "GEN_API_Export_Code" ), "GEN_API_Export_Code" },
|
||||
{ sizeof( "GEN_API_Import_Code" ), "GEN_API_Import_Code" },
|
||||
};
|
||||
return lookup[type];
|
||||
local_persist StrC lookup[] { { sizeof("__invalid__"), "__invalid__" },
|
||||
{ sizeof("private"), "private" },
|
||||
{ sizeof("protected"), "protected" },
|
||||
{ sizeof("public"), "public" },
|
||||
{ sizeof("."), "." },
|
||||
{ sizeof("::"), "::" },
|
||||
{ sizeof("&"), "&" },
|
||||
{ sizeof("&&"), "&&" },
|
||||
{ sizeof(":"), ":" },
|
||||
{ sizeof("[["), "[[" },
|
||||
{ sizeof("]]"), "]]" },
|
||||
{ sizeof("{"), "{" },
|
||||
{ sizeof("}"), "}" },
|
||||
{ sizeof("["), "[" },
|
||||
{ sizeof("]"), "]" },
|
||||
{ sizeof("("), "(" },
|
||||
{ sizeof(")"), ")" },
|
||||
{ sizeof("__comment__"), "__comment__" },
|
||||
{ sizeof("__comment_end__"), "__comment_end__" },
|
||||
{ sizeof("__comment_start__"), "__comment_start__" },
|
||||
{ sizeof("__character__"), "__character__" },
|
||||
{ sizeof(","), "," },
|
||||
{ sizeof("class"), "class" },
|
||||
{ sizeof("__attribute__"), "__attribute__" },
|
||||
{ sizeof("__declspec"), "__declspec" },
|
||||
{ sizeof("enum"), "enum" },
|
||||
{ sizeof("extern"), "extern" },
|
||||
{ sizeof("friend"), "friend" },
|
||||
{ sizeof("module"), "module" },
|
||||
{ sizeof("namespace"), "namespace" },
|
||||
{ sizeof("operator"), "operator" },
|
||||
{ sizeof("struct"), "struct" },
|
||||
{ sizeof("template"), "template" },
|
||||
{ sizeof("typedef"), "typedef" },
|
||||
{ sizeof("using"), "using" },
|
||||
{ sizeof("union"), "union" },
|
||||
{ sizeof("__identifier__"), "__identifier__" },
|
||||
{ sizeof("import"), "import" },
|
||||
{ sizeof("export"), "export" },
|
||||
{ sizeof("__new_line__"), "__new_line__" },
|
||||
{ sizeof("__number__"), "__number__" },
|
||||
{ sizeof("__operator__"), "__operator__" },
|
||||
{ sizeof("#"), "#" },
|
||||
{ sizeof("define"), "define" },
|
||||
{ sizeof("if"), "if" },
|
||||
{ sizeof("ifdef"), "ifdef" },
|
||||
{ sizeof("ifndef"), "ifndef" },
|
||||
{ sizeof("elif"), "elif" },
|
||||
{ sizeof("else"), "else" },
|
||||
{ sizeof("endif"), "endif" },
|
||||
{ sizeof("include"), "include" },
|
||||
{ sizeof("pragma"), "pragma" },
|
||||
{ sizeof("__macro_content__"), "__macro_content__" },
|
||||
{ sizeof("__macro__"), "__macro__" },
|
||||
{ sizeof("__unsupported__"), "__unsupported__" },
|
||||
{ sizeof("alignas"), "alignas" },
|
||||
{ sizeof("const"), "const" },
|
||||
{ sizeof("consteval"), "consteval" },
|
||||
{ sizeof("constexpr"), "constexpr" },
|
||||
{ sizeof("constinit"), "constinit" },
|
||||
{ sizeof("explicit"), "explicit" },
|
||||
{ sizeof("extern"), "extern" },
|
||||
{ sizeof("final"), "final" },
|
||||
{ sizeof("forceinline"), "forceinline" },
|
||||
{ sizeof("global"), "global" },
|
||||
{ sizeof("inline"), "inline" },
|
||||
{ sizeof("internal"), "internal" },
|
||||
{ sizeof("local_persist"), "local_persist" },
|
||||
{ sizeof("mutable"), "mutable" },
|
||||
{ sizeof("neverinline"), "neverinline" },
|
||||
{ sizeof("override"), "override" },
|
||||
{ sizeof("static"), "static" },
|
||||
{ sizeof("thread_local"), "thread_local" },
|
||||
{ sizeof("volatile"), "volatile" },
|
||||
{ sizeof("virtual"), "virtual" },
|
||||
{ sizeof("*"), "*" },
|
||||
{ sizeof(";"), ";" },
|
||||
{ sizeof("static_assert"), "static_assert" },
|
||||
{ sizeof("__string__"), "__string__" },
|
||||
{ sizeof("typename"), "typename" },
|
||||
{ sizeof("unsigned"), "unsigned" },
|
||||
{ sizeof("signed"), "signed" },
|
||||
{ sizeof("short"), "short" },
|
||||
{ sizeof("long"), "long" },
|
||||
{ sizeof("bool"), "bool" },
|
||||
{ sizeof("char"), "char" },
|
||||
{ sizeof("int"), "int" },
|
||||
{ sizeof("double"), "double" },
|
||||
{ sizeof("__int8"), "__int8" },
|
||||
{ sizeof("__int16"), "__int16" },
|
||||
{ sizeof("__int32"), "__int32" },
|
||||
{ sizeof("__int64"), "__int64" },
|
||||
{ sizeof("_W64"), "_W64" },
|
||||
{ sizeof("..."), "..." },
|
||||
{ sizeof("__attrib_start__"), "__attrib_start__" },
|
||||
{ sizeof("GEN_API_Export_Code"), "GEN_API_Export_Code" },
|
||||
{ sizeof("GEN_API_Import_Code"), "GEN_API_Import_Code" },
|
||||
}; return lookup[ type ];
|
||||
}
|
||||
|
||||
inline TokType to_toktype( StrC str )
|
||||
inline
|
||||
TokType to_toktype( StrC str)
|
||||
{
|
||||
local_persist u32 keymap[Tok_NumTokens];
|
||||
do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||
{
|
||||
StrC enum_str = to_str( (TokType)index );
|
||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1 );
|
||||
}
|
||||
do_once_end u32 hash = crc32( str.Ptr, str.Len );
|
||||
for ( u32 index = 0; index < Tok_NumTokens; index++ )
|
||||
{
|
||||
if ( keymap[index] == hash )
|
||||
return (TokType)index;
|
||||
}
|
||||
return Tok_Invalid;
|
||||
local_persist u32 keymap[ Tok_NumTokens ]; do_once_start for ( u32 index = 0; index < Tok_NumTokens; index++ ) { StrC enum_str = to_str( (TokType)index ); keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1); } do_once_end u32 hash = crc32( str.Ptr, str.Len ); for ( u32 index = 0; index < Tok_NumTokens; index++ ) { if ( keymap[index] == hash ) return (TokType)index; } return Tok_Invalid;
|
||||
}
|
||||
|
||||
GEN_NS_PARSER_END
|
||||
|
@ -7,10 +7,11 @@
|
||||
inline
|
||||
void code_append( Code self, Code other )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(other.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(other);
|
||||
GEN_ASSERT_MSG(self != other, "Attempted to recursively append Code AST to itself.");
|
||||
|
||||
if ( other->Parent )
|
||||
if ( other->Parent != nullptr )
|
||||
other = code_duplicate(other);
|
||||
|
||||
other->Parent = self;
|
||||
@ -34,7 +35,7 @@ void code_append( Code self, Code other )
|
||||
inline
|
||||
bool code_is_body(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
switch (self->Type)
|
||||
{
|
||||
case CT_Enum_Body:
|
||||
@ -53,7 +54,7 @@ bool code_is_body(Code self)
|
||||
inline
|
||||
Code* code_entry( Code self, u32 idx )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self != nullptr);
|
||||
Code* current = & self->Front;
|
||||
while ( idx >= 0 && current != nullptr )
|
||||
{
|
||||
@ -66,29 +67,31 @@ Code* code_entry( Code self, u32 idx )
|
||||
|
||||
return rcast( Code*, current);
|
||||
}
|
||||
inline
|
||||
forceinline
|
||||
bool code_is_valid(Code self)
|
||||
{
|
||||
return self.ast != nullptr && self.ast->Type != CT_Invalid;
|
||||
GEN_ASSERT(self);
|
||||
return self != nullptr && self->Type != CT_Invalid;
|
||||
}
|
||||
inline
|
||||
forceinline
|
||||
bool code_has_entries(AST* self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
inline
|
||||
forceinline
|
||||
void code_set_global(Code self)
|
||||
{
|
||||
if ( self.ast == nullptr )
|
||||
if ( self == nullptr )
|
||||
{
|
||||
log_failure("Code::set_global: Cannot set code as global, AST is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
self->Parent.ast = Code_Global.ast;
|
||||
self->Parent = Code_Global;
|
||||
}
|
||||
inline
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline
|
||||
Code& Code::operator ++()
|
||||
{
|
||||
if ( ast )
|
||||
@ -96,7 +99,8 @@ Code& Code::operator ++()
|
||||
|
||||
return * this;
|
||||
}
|
||||
inline
|
||||
#endif
|
||||
forceinline
|
||||
char const* code_type_str(Code self)
|
||||
{
|
||||
GEN_ASSERT(self != nullptr);
|
||||
@ -106,49 +110,57 @@ char const* code_type_str(Code self)
|
||||
|
||||
#pragma region CodeBody
|
||||
inline
|
||||
void append( CodeBody self, Code other )
|
||||
void body_append( CodeBody self, Code other )
|
||||
{
|
||||
GEN_ASSERT(other.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(other);
|
||||
|
||||
if (code_is_body(other)) {
|
||||
append( self, cast(CodeBody, other) );
|
||||
body_append_body( self, cast(CodeBody, other) );
|
||||
return;
|
||||
}
|
||||
|
||||
code_append( cast(Code, self), other );
|
||||
}
|
||||
inline
|
||||
void append( CodeBody self, CodeBody body )
|
||||
void body_append_body( CodeBody self, CodeBody body )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(body);
|
||||
GEN_ASSERT_MSG(self != body, "Attempted to append body to itself.");
|
||||
|
||||
for ( Code entry : body ) {
|
||||
append( self, entry );
|
||||
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); entry = next_CodeBody(body, entry) ) {
|
||||
body_append( self, entry );
|
||||
}
|
||||
}
|
||||
inline
|
||||
Code begin( CodeBody body) {
|
||||
if ( body.ast )
|
||||
return { rcast( AST*, body.ast)->Front };
|
||||
Code begin_CodeBody( CodeBody body) {
|
||||
GEN_ASSERT(body);
|
||||
if ( body != nullptr )
|
||||
return body->Front;
|
||||
return { nullptr };
|
||||
}
|
||||
inline
|
||||
Code end(CodeBody body ){
|
||||
return { rcast(AST*, body.ast)->Back->Next };
|
||||
forceinline
|
||||
Code end_CodeBody(CodeBody body ){
|
||||
GEN_ASSERT(body);
|
||||
return body->Back->Next;
|
||||
}
|
||||
inline
|
||||
Code next(CodeBody body, Code entry) {
|
||||
Code next_CodeBody(CodeBody body, Code entry) {
|
||||
GEN_ASSERT(body);
|
||||
GEN_ASSERT(entry);
|
||||
return entry->Next;
|
||||
}
|
||||
#pragma endregion CodeBody
|
||||
|
||||
#pragma region CodeClass
|
||||
inline
|
||||
void add_interface( CodeClass self, CodeTypename type )
|
||||
void class_add_interface( CodeClass self, CodeTypename type )
|
||||
{
|
||||
GEN_ASSERT(self.ast !=nullptr);
|
||||
GEN_ASSERT(self);
|
||||
GEN_ASSERT(type);
|
||||
CodeTypename possible_slot = self->ParentType;
|
||||
if ( possible_slot.ast )
|
||||
if ( possible_slot != nullptr )
|
||||
{
|
||||
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
||||
self->ParentAccess = AccessSpec_Public;
|
||||
@ -156,24 +168,25 @@ void add_interface( CodeClass self, CodeTypename type )
|
||||
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
||||
}
|
||||
|
||||
while ( possible_slot.ast != nullptr )
|
||||
while ( possible_slot != nullptr )
|
||||
{
|
||||
possible_slot.ast = (AST_Typename*) possible_slot->Next.ast;
|
||||
possible_slot = possible_slot->Next;
|
||||
}
|
||||
|
||||
possible_slot.ast = type.ast;
|
||||
possible_slot = type;
|
||||
}
|
||||
#pragma endregion CodeClass
|
||||
|
||||
#pragma region CodeParam
|
||||
inline
|
||||
void append( CodeParam appendee, CodeParam other )
|
||||
void params_append( CodeParam appendee, CodeParam other )
|
||||
{
|
||||
GEN_ASSERT(appendee.ast != nullptr);
|
||||
GEN_ASSERT(appendee);
|
||||
GEN_ASSERT(other);
|
||||
Code self = cast(Code, appendee);
|
||||
Code entry = cast(Code, other);
|
||||
|
||||
if ( entry->Parent )
|
||||
if ( entry->Parent != nullptr )
|
||||
entry = code_duplicate( entry );
|
||||
|
||||
entry->Parent = self;
|
||||
@ -191,54 +204,61 @@ void append( CodeParam appendee, CodeParam other )
|
||||
self->NumEntries++;
|
||||
}
|
||||
inline
|
||||
CodeParam get(CodeParam self, s32 idx )
|
||||
CodeParam params_get(CodeParam self, s32 idx )
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
CodeParam param = * self;
|
||||
GEN_ASSERT(self);
|
||||
CodeParam param = self;
|
||||
do
|
||||
{
|
||||
if ( ! ++ param )
|
||||
if ( ++ param != nullptr )
|
||||
return { nullptr };
|
||||
|
||||
param = cast(Code, param)->Next;
|
||||
param = cast(CodeParam, cast(Code, param)->Next);
|
||||
}
|
||||
while ( --idx );
|
||||
|
||||
return param;
|
||||
}
|
||||
inline
|
||||
bool has_entries(CodeParam self)
|
||||
forceinline
|
||||
bool params_has_entries(CodeParam self)
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self);
|
||||
return self->NumEntries > 0;
|
||||
}
|
||||
inline
|
||||
#if GEN_COMPILER_CPP
|
||||
forceinline
|
||||
CodeParam& CodeParam::operator ++()
|
||||
{
|
||||
ast = ast->Next.ast;
|
||||
* this = ast->Next;
|
||||
return * this;
|
||||
}
|
||||
inline
|
||||
CodeParam begin(CodeParam params)
|
||||
#endif
|
||||
forceinline
|
||||
CodeParam begin_CodeParam(CodeParam params)
|
||||
{
|
||||
if ( params.ast )
|
||||
return { params.ast };
|
||||
if ( params != nullptr )
|
||||
return params;
|
||||
|
||||
return { nullptr };
|
||||
return NullCode;
|
||||
}
|
||||
inline
|
||||
CodeParam end(CodeParam params)
|
||||
forceinline
|
||||
CodeParam end_CodeParam(CodeParam params)
|
||||
{
|
||||
// return { (AST_Param*) rcast( AST*, ast)->Last };
|
||||
return { nullptr };
|
||||
}
|
||||
forceinline
|
||||
CodeParam next_CodeParam(CodeParam params, CodeParam param_iter)
|
||||
{
|
||||
return params->Next;
|
||||
}
|
||||
#pragma endregion CodeParam
|
||||
|
||||
#pragma region CodeSpecifiers
|
||||
inline
|
||||
bool append(CodeSpecifiers self, Specifier spec )
|
||||
bool specifiers_append(CodeSpecifiers self, Specifier spec )
|
||||
{
|
||||
if ( self.ast == nullptr )
|
||||
if ( self == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return false;
|
||||
@ -254,9 +274,9 @@ bool append(CodeSpecifiers self, Specifier spec )
|
||||
return true;
|
||||
}
|
||||
inline
|
||||
s32 has(CodeSpecifiers self, Specifier spec)
|
||||
s32 specifiers_has(CodeSpecifiers self, Specifier spec)
|
||||
{
|
||||
GEN_ASSERT(self.ast != nullptr);
|
||||
GEN_ASSERT(self != nullptr);
|
||||
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
|
||||
if ( self->ArrSpecs[ idx ] == spec )
|
||||
return idx;
|
||||
@ -264,10 +284,9 @@ s32 has(CodeSpecifiers self, Specifier spec)
|
||||
return -1;
|
||||
}
|
||||
inline
|
||||
s32 remove( CodeSpecifiers self, Specifier to_remove )
|
||||
s32 specifiers_remove( CodeSpecifiers self, Specifier to_remove )
|
||||
{
|
||||
AST_Specifiers* ast = self.ast;
|
||||
if ( ast == nullptr )
|
||||
if ( self == nullptr )
|
||||
{
|
||||
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
||||
return -1;
|
||||
@ -304,19 +323,24 @@ s32 remove( CodeSpecifiers self, Specifier to_remove )
|
||||
}
|
||||
return result;
|
||||
}
|
||||
inline
|
||||
Specifier* begin(CodeSpecifiers self)
|
||||
forceinline
|
||||
Specifier* begin_CodeSpecifiers(CodeSpecifiers self)
|
||||
{
|
||||
if ( self.ast )
|
||||
if ( self != nullptr )
|
||||
return & self->ArrSpecs[0];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
inline
|
||||
Specifier* end(CodeSpecifiers self)
|
||||
forceinline
|
||||
Specifier* end_CodeSpecifiers(CodeSpecifiers self)
|
||||
{
|
||||
return self->ArrSpecs + self->NumEntries;
|
||||
}
|
||||
forceinline
|
||||
Specifier* next_CodeSpecifiers(CodeSpecifiers self, Specifier* spec_iter)
|
||||
{
|
||||
return spec_iter + 1;
|
||||
}
|
||||
#pragma endregion CodeSpecifiers
|
||||
|
||||
#pragma region CodeStruct
|
||||
@ -324,7 +348,7 @@ inline
|
||||
void add_interface(CodeStruct self, CodeTypename type )
|
||||
{
|
||||
CodeTypename possible_slot = self->ParentType;
|
||||
if ( possible_slot.ast )
|
||||
if ( possible_slot != nullptr )
|
||||
{
|
||||
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
||||
self->ParentAccess = AccessSpec_Public;
|
||||
@ -332,12 +356,12 @@ void add_interface(CodeStruct self, CodeTypename type )
|
||||
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
||||
}
|
||||
|
||||
while ( possible_slot.ast != nullptr )
|
||||
while ( possible_slot != nullptr )
|
||||
{
|
||||
possible_slot.ast = (AST_Typename*) possible_slot->Next.ast;
|
||||
possible_slot = possible_slot->Next;
|
||||
}
|
||||
|
||||
possible_slot.ast = type.ast;
|
||||
possible_slot = type;
|
||||
}
|
||||
#pragma endregion Code
|
||||
|
||||
|
@ -84,12 +84,12 @@ void define_constants()
|
||||
t_empty = (CodeTypename) make_code();
|
||||
t_empty->Type = CT_Typename;
|
||||
t_empty->Name = get_cached_string( txt("") );
|
||||
code_set_global(t_empty);
|
||||
code_set_global(cast(Code, t_empty));
|
||||
|
||||
access_private = make_code();
|
||||
access_private->Type = CT_Access_Private;
|
||||
access_private->Name = get_cached_string( txt("private:\n") );
|
||||
code_set_global(access_private);
|
||||
code_set_global(cast(Code, access_private));
|
||||
|
||||
access_protected = make_code();
|
||||
access_protected->Type = CT_Access_Protected;
|
||||
@ -102,50 +102,50 @@ void define_constants()
|
||||
code_set_global(access_public);
|
||||
|
||||
attrib_api_export = def_attributes( code(GEN_API_Export_Code));
|
||||
code_set_global(attrib_api_export);
|
||||
code_set_global(cast(Code, attrib_api_export));
|
||||
|
||||
attrib_api_import = def_attributes( code(GEN_API_Import_Code));
|
||||
code_set_global(attrib_api_import);
|
||||
code_set_global(cast(Code, attrib_api_import));
|
||||
|
||||
module_global_fragment = make_code();
|
||||
module_global_fragment->Type = CT_Untyped;
|
||||
module_global_fragment->Name = get_cached_string( txt("module;") );
|
||||
module_global_fragment->Content = module_global_fragment->Name;
|
||||
code_set_global(module_global_fragment);
|
||||
code_set_global(cast(Code, module_global_fragment));
|
||||
|
||||
module_private_fragment = make_code();
|
||||
module_private_fragment->Type = CT_Untyped;
|
||||
module_private_fragment->Name = get_cached_string( txt("module : private;") );
|
||||
module_private_fragment->Content = module_private_fragment->Name;
|
||||
code_set_global(module_private_fragment);
|
||||
code_set_global(cast(Code, module_private_fragment));
|
||||
|
||||
fmt_newline = make_code();
|
||||
fmt_newline->Type = CT_NewLine;
|
||||
code_set_global(fmt_newline);
|
||||
|
||||
code_set_global((Code)fmt_newline);
|
||||
|
||||
pragma_once = (CodePragma) make_code();
|
||||
pragma_once->Type = CT_Preprocess_Pragma;
|
||||
pragma_once->Name = get_cached_string( txt("once") );
|
||||
pragma_once->Content = pragma_once->Name;
|
||||
code_set_global(pragma_once);
|
||||
code_set_global((Code)pragma_once);
|
||||
|
||||
param_varadic = (CodeTypename) make_code();
|
||||
param_varadic = (CodeParam) make_code();
|
||||
param_varadic->Type = CT_Parameters;
|
||||
param_varadic->Name = get_cached_string( txt("...") );
|
||||
param_varadic->ValueType = t_empty;
|
||||
code_set_global(param_varadic);
|
||||
code_set_global((Code)param_varadic);
|
||||
|
||||
preprocess_else = (CodePreprocessCond) make_code();
|
||||
preprocess_else->Type = CT_Preprocess_Else;
|
||||
code_set_global(preprocess_else);
|
||||
code_set_global((Code)preprocess_else);
|
||||
|
||||
preprocess_endif = (CodePreprocessCond) make_code();
|
||||
preprocess_endif->Type = CT_Preprocess_EndIf;
|
||||
code_set_global(preprocess_endif);
|
||||
code_set_global((Code)preprocess_endif);
|
||||
|
||||
# define def_constant_code_type( Type_ ) \
|
||||
t_##Type_ = def_type( name(Type_) ); \
|
||||
code_set_global(t_##Type_);
|
||||
code_set_global( cast(Code, t_##Type_));
|
||||
|
||||
def_constant_code_type( auto );
|
||||
def_constant_code_type( void );
|
||||
@ -180,7 +180,7 @@ void define_constants()
|
||||
|
||||
# define def_constant_spec( Type_, ... ) \
|
||||
spec_##Type_ = def_specifiers( num_args(__VA_ARGS__), __VA_ARGS__); \
|
||||
code_set_global(spec_##Type_);
|
||||
code_set_global( cast(Code, spec_##Type_));
|
||||
|
||||
# pragma push_macro("forceinline")
|
||||
# pragma push_macro("global")
|
||||
@ -218,7 +218,7 @@ void define_constants()
|
||||
def_constant_spec( volatile, Spec_Volatile)
|
||||
|
||||
spec_local_persist = def_specifiers( 1, Spec_Local_Persist );
|
||||
code_set_global(spec_local_persist);
|
||||
code_set_global(cast(Code, spec_local_persist));
|
||||
|
||||
# pragma pop_macro("forceinline")
|
||||
# pragma pop_macro("global")
|
||||
@ -426,7 +426,7 @@ Code make_code()
|
||||
}
|
||||
|
||||
Code result { rcast( AST*, alloc( pool_allocator_info(allocator), sizeof(AST) )) };
|
||||
mem_set( result.ast, 0, sizeof(AST) );
|
||||
mem_set( rcast(void*, cast(AST*, result)), 0, sizeof(AST) );
|
||||
// result->Type = ECode::Invalid;
|
||||
|
||||
// result->Content = { nullptr };
|
||||
|
@ -29,19 +29,19 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
} \
|
||||
if ( params_code->Type != CT_Parameters ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code)); \
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str( cast(Code, params_code))); \
|
||||
return OpValResult_Fail; \
|
||||
}
|
||||
|
||||
# define check_param_eq_ret() \
|
||||
if ( ! is_member_symbol && ! code_is_equal(params_code->ValueType, ret_type) ) \
|
||||
if ( ! is_member_symbol && ! code_is_equal(cast(Code, params_code->ValueType), cast(Code, ret_type)) ) \
|
||||
{ \
|
||||
log_failure("gen::def_operator: operator%s requires first parameter to equal return type\n" \
|
||||
"param types: %s\n" \
|
||||
"return type: %s", \
|
||||
operator_to_str(op).Ptr, \
|
||||
code_debug_str(params_code), \
|
||||
code_debug_str(ret_type) \
|
||||
code_debug_str(cast(Code, params_code)), \
|
||||
code_debug_str(cast(Code, ret_type)) \
|
||||
); \
|
||||
return OpValResult_Fail; \
|
||||
}
|
||||
@ -54,7 +54,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
|
||||
if ( ret_type->Type != CT_Typename )
|
||||
{
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(ret_type));
|
||||
log_failure("gen::def_operator: ret_type is not of typename type - %s", code_debug_str(cast(Code, ret_type)));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s does not support non-member definition (more than one parameter provided) - %s",
|
||||
operator_to_str(op),
|
||||
code_debug_str(params_code)
|
||||
code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -102,7 +102,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
log_failure("gen::def_operator: operator%s may not be defined with more than two parametes - param count; %d\n%s"
|
||||
, operator_to_str(op)
|
||||
, params_code->NumEntries
|
||||
, code_debug_str(params_code)
|
||||
, code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -117,7 +117,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s params code provided is not of Parameters type - %s"
|
||||
, operator_to_str(op)
|
||||
, code_debug_str(params_code)
|
||||
, code_debug_str(cast(Code, params_code))
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -125,7 +125,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
switch ( params_code->NumEntries )
|
||||
{
|
||||
case 1:
|
||||
if ( code_is_equal(params_code->ValueType, t_int ) )
|
||||
if ( code_is_equal((Code)params_code->ValueType, (Code)t_int ) )
|
||||
is_member_symbol = true;
|
||||
|
||||
else
|
||||
@ -135,7 +135,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
case 2:
|
||||
check_param_eq_ret();
|
||||
|
||||
if ( ! code_is_equal(get(params_code, 1), t_int ) )
|
||||
if ( ! code_is_equal((Code)params_get(params_code, 1), (Code)t_int ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s requires second parameter of non-member definition to be int for post-decrement",
|
||||
@ -164,18 +164,18 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code));
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
if ( code_is_equal(params_code->ValueType, ret_type ) )
|
||||
if ( code_is_equal((Code)params_code->ValueType, (Code)ret_type ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, code_debug_str(params_code)
|
||||
, code_debug_str(ret_type)
|
||||
, code_debug_str((Code)params_code)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -209,7 +209,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code) );
|
||||
log_failure( "gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code) );
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -245,14 +245,14 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( ! code_is_equal(params_code->ValueType, ret_type ) )
|
||||
if ( ! code_is_equal((Code)params_code->ValueType, (Code)ret_type ) )
|
||||
{
|
||||
log_failure("gen::def_operator: "
|
||||
"operator%s is non-member symbol yet first paramter does not equal return type\n"
|
||||
"param type: %s\n"
|
||||
"return type: %s\n"
|
||||
, code_debug_str(params_code)
|
||||
, code_debug_str(ret_type)
|
||||
, code_debug_str((Code)params_code)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -275,7 +275,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
{
|
||||
if ( params_code->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str(params_code));
|
||||
log_failure("gen::def_operator: params is not of Parameters type - %s", code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
|
||||
@ -289,11 +289,11 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! code_is_equal(ret_type, t_bool ))
|
||||
if ( ! code_is_equal((Code)ret_type, (Code)t_bool ))
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s return type must be of type bool - %s"
|
||||
, operator_to_str(op)
|
||||
, code_debug_str(ret_type)
|
||||
, code_debug_str((Code)ret_type)
|
||||
);
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
@ -347,7 +347,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
case Op_PtrToMemOfPtr:
|
||||
if ( params_code )
|
||||
{
|
||||
log_failure("gen::def_operator: operator%s expects no paramters - %s", operator_to_str(op), code_debug_str(params_code));
|
||||
log_failure("gen::def_operator: operator%s expects no paramters - %s", operator_to_str(op), code_debug_str((Code)params_code));
|
||||
return OpValResult_Fail;
|
||||
}
|
||||
break;
|
||||
@ -390,7 +390,7 @@ OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTyp
|
||||
}
|
||||
|
||||
#define null_check( Context_, Code_ ) \
|
||||
if ( ! Code_ ) \
|
||||
if ( Code_ != nullptr ) \
|
||||
{ \
|
||||
log_failure( "gen::" stringize(Context_) ": " stringize(Code_) " provided is null" ); \
|
||||
return InvalidCode; \
|
||||
@ -501,7 +501,7 @@ CodeConstructor def_constructor( Opts_def_constructor p )
|
||||
|
||||
if ( params && params->Type != CT_Parameters )
|
||||
{
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", code_debug_str(params));
|
||||
log_failure("gen::def_constructor: params must be of Parameters type - %s", code_debug_str((Code)params));
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ CodeClass def_class( StrC name, Opts_def_struct p )
|
||||
{
|
||||
for (s32 idx = 0; idx < num_interfaces; idx++ )
|
||||
{
|
||||
add_interface(result, interfaces[idx] );
|
||||
class_add_interface(result, interfaces[idx] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -692,13 +692,13 @@ CodeEnum def_enum( StrC name, Opts_def_enum p )
|
||||
|
||||
if ( type && type->Type != CT_Typename )
|
||||
{
|
||||
log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", code_debug_str(type) );
|
||||
log_failure( "gen::def_enum: enum underlying type provided was not of type Typename: %s", code_debug_str((Code)type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( attributes && attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", code_debug_str(attributes) );
|
||||
log_failure( "gen::def_enum: attributes was not a 'PlatformAttributes' type: %s", code_debug_str((Code)attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1161,7 +1161,7 @@ CodeSpecifiers def_specifier( Specifier spec )
|
||||
CodeSpecifiers
|
||||
result = (CodeSpecifiers) make_code();
|
||||
result->Type = CT_Specifiers;
|
||||
append(result, spec );
|
||||
specifiers_append(result, spec );
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1178,7 +1178,7 @@ CodeStruct def_struct( StrC name, Opts_def_struct p )
|
||||
|
||||
if ( attributes && attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(attributes) );
|
||||
log_failure( "gen::def_struct: attributes was not a `PlatformAttributes` type - %s", code_debug_str(cast(Code, attributes)) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1273,19 +1273,19 @@ CodeTypename def_type( StrC name, Opts_def_type p )
|
||||
|
||||
if ( attributes && attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_type: attributes is not of attributes type - %s", code_debug_str(attributes) );
|
||||
log_failure( "gen::def_type: attributes is not of attributes type - %s", code_debug_str((Code)attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( specifiers && specifiers->Type != CT_Specifiers )
|
||||
{
|
||||
log_failure( "gen::def_type: specifiers is not of specifiers type - %s", code_debug_str(specifiers) );
|
||||
log_failure( "gen::def_type: specifiers is not of specifiers type - %s", code_debug_str((Code)specifiers) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( arrayexpr && arrayexpr->Type != CT_Untyped )
|
||||
{
|
||||
log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str(arrayexpr) );
|
||||
log_failure( "gen::def_type: arrayexpr is not of untyped type - %s", code_debug_str((Code)arrayexpr) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1325,13 +1325,13 @@ CodeTypedef def_typedef( StrC name, Code type, Opts_def_typedef p )
|
||||
case CT_Typename:
|
||||
break;
|
||||
default:
|
||||
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", code_debug_str(type) );
|
||||
log_failure( "gen::def_typedef: type was not a Class, Enum, Function Forward, Struct, Typename, or Union - %s", code_debug_str((Code)type) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
if ( p.attributes && p.attributes->Type != CT_PlatformAttributes )
|
||||
{
|
||||
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", code_debug_str(p.attributes) );
|
||||
log_failure( "gen::def_typedef: attributes was not a PlatformAttributes - %s", code_debug_str((Code)p.attributes) );
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
@ -1553,7 +1553,7 @@ CodeBody def_class_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1590,7 +1590,7 @@ CodeBody def_class_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1624,7 +1624,7 @@ CodeBody def_enum_body( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( num--, num > 0 );
|
||||
va_end(va);
|
||||
@ -1656,7 +1656,7 @@ CodeBody def_enum_body( s32 num, Code* codes )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( codes++, num--, num > 0 );
|
||||
|
||||
@ -1694,7 +1694,7 @@ CodeBody def_export_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1731,7 +1731,7 @@ CodeBody def_export_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1769,7 +1769,7 @@ CodeBody def_extern_link_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1806,8 +1806,7 @@ CodeBody def_extern_link_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1846,7 +1845,7 @@ CodeBody def_function_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1882,7 +1881,7 @@ CodeBody def_function_body( s32 num, Code* codes )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -1913,8 +1912,8 @@ CodeBody def_global_body( s32 num, ... )
|
||||
switch (entry->Type)
|
||||
{
|
||||
case CT_Global_Body:
|
||||
// result.append( entry.code_cast<CodeBody>() ) ;
|
||||
append( result, cast(CodeBody, entry) );
|
||||
// result.body_append( entry.code_cast<CodeBody>() ) ;
|
||||
body_append( result, cast(CodeBody, entry) );
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
@ -1925,7 +1924,7 @@ CodeBody def_global_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -1955,7 +1954,7 @@ CodeBody def_global_body( s32 num, Code* codes )
|
||||
switch (entry->Type)
|
||||
{
|
||||
case CT_Global_Body:
|
||||
append(result, cast(CodeBody, entry) );
|
||||
body_append(result, cast(CodeBody, entry) );
|
||||
continue;
|
||||
|
||||
GEN_AST_BODY_GLOBAL_UNALLOWED_TYPES
|
||||
@ -1966,7 +1965,7 @@ CodeBody def_global_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -2004,7 +2003,7 @@ CodeBody def_namespace_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -2040,7 +2039,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
|
||||
default: break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -2078,7 +2077,7 @@ CodeParam def_params( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, param );
|
||||
params_append(result, param );
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
@ -2114,7 +2113,7 @@ CodeParam def_params( s32 num, CodeParam* codes )
|
||||
while( codes++, current = * codes, num--, num > 0 )
|
||||
{
|
||||
check_current();
|
||||
append(result, current );
|
||||
params_append(result, current );
|
||||
}
|
||||
# undef check_current
|
||||
|
||||
@ -2145,7 +2144,7 @@ CodeSpecifiers def_specifiers( s32 num, ... )
|
||||
{
|
||||
Specifier type = (Specifier)va_arg(va, int);
|
||||
|
||||
append(result, type );
|
||||
specifiers_append(result, type );
|
||||
}
|
||||
while ( --num, num );
|
||||
va_end(va);
|
||||
@ -2174,7 +2173,7 @@ CodeSpecifiers def_specifiers( s32 num, Specifier* specs )
|
||||
s32 idx = 0;
|
||||
do
|
||||
{
|
||||
append(result, specs[idx] );
|
||||
specifiers_append(result, specs[idx] );
|
||||
idx++;
|
||||
}
|
||||
while ( --num, num );
|
||||
@ -2213,7 +2212,7 @@ CodeBody def_struct_body( s32 num, ... )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
va_end(va);
|
||||
@ -2250,7 +2249,7 @@ CodeBody def_struct_body( s32 num, Code* codes )
|
||||
break;
|
||||
}
|
||||
|
||||
append(result, entry);
|
||||
body_append(result, entry);
|
||||
}
|
||||
while (num--, num > 0);
|
||||
|
||||
@ -2284,7 +2283,7 @@ CodeBody def_union_body( s32 num, ... )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( num--, num > 0 );
|
||||
va_end(va);
|
||||
@ -2316,7 +2315,7 @@ CodeBody def_union_body( s32 num, CodeUnion* codes )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, entry );
|
||||
body_append(result, entry );
|
||||
}
|
||||
while ( codes++, num--, num > 0 );
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ CodeBody parse_class_struct_body( TokType which, Token name )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(result, member );
|
||||
body_append(result, member );
|
||||
}
|
||||
|
||||
eat( Tok_BraceCurly_Close );
|
||||
@ -1438,7 +1438,7 @@ CodeFn parse_function_after_name(
|
||||
CodeParam params = parse_params();
|
||||
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Parameters> )
|
||||
|
||||
// TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers.
|
||||
// TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers.
|
||||
while ( left && is_specifier(currtok) )
|
||||
{
|
||||
if ( specifiers.ast == nullptr )
|
||||
@ -1448,7 +1448,7 @@ CodeFn parse_function_after_name(
|
||||
continue;
|
||||
}
|
||||
|
||||
append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
specifiers_append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
eat( currtok.Type );
|
||||
}
|
||||
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Paraemters> ) <Specifiers>
|
||||
@ -1468,7 +1468,7 @@ CodeFn parse_function_after_name(
|
||||
else if ( check(Tok_Operator) && currtok.Text[0] == '=' )
|
||||
{
|
||||
eat(Tok_Operator);
|
||||
append(specifiers, Spec_Pure );
|
||||
specifiers_append(specifiers, Spec_Pure );
|
||||
|
||||
eat( Tok_Number);
|
||||
Token stmt_end = currtok;
|
||||
@ -1544,7 +1544,7 @@ CodeFn parse_function_after_name(
|
||||
internal
|
||||
Code parse_function_body()
|
||||
{
|
||||
|
||||
|
||||
push_scope();
|
||||
|
||||
eat( Tok_BraceCurly_Open );
|
||||
@ -1574,7 +1574,7 @@ Code parse_function_body()
|
||||
|
||||
if ( len > 0 )
|
||||
{
|
||||
append( result, def_execution( { len, start.Text } ) );
|
||||
body_append( result, def_execution( { len, start.Text } ) );
|
||||
}
|
||||
|
||||
eat( Tok_BraceCurly_Close );
|
||||
@ -1891,7 +1891,7 @@ CodeBody parse_global_nspace( CodeType which )
|
||||
}
|
||||
|
||||
// log_fmt("Global Body Member: %s", member->debug_str());
|
||||
append(result, member );
|
||||
body_append(result, member );
|
||||
}
|
||||
|
||||
if ( which != CT_Global_Body )
|
||||
@ -2032,7 +2032,7 @@ Code parse_global_nspace_constructor_destructor( CodeSpecifiers specifiers )
|
||||
|
||||
// TODO(Ed): I want to eventually change the identifier to its own AST type.
|
||||
// This would allow distinction of the qualifier for a symbol <qualifier>::<nested symboL>
|
||||
// This would also allow
|
||||
// This would also allow
|
||||
internal
|
||||
Token parse_identifier( bool* possible_member_function )
|
||||
{
|
||||
@ -2455,7 +2455,7 @@ CodeOperator parse_operator_after_ret_type(
|
||||
continue;
|
||||
}
|
||||
|
||||
append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
specifiers_append(specifiers, strc_to_specifier( to_str(currtok)) );
|
||||
eat( currtok.Type );
|
||||
}
|
||||
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> ) <Specifiers>
|
||||
@ -2771,7 +2771,7 @@ CodeParam parse_params( bool use_template_capture )
|
||||
if ( check( Tok_Varadic_Argument ) )
|
||||
{
|
||||
eat( Tok_Varadic_Argument );
|
||||
append(result, param_varadic );
|
||||
params_append(result, param_varadic );
|
||||
continue;
|
||||
// ( <Macro> <ValueType> <Name> = <Expression>, ...
|
||||
}
|
||||
@ -2875,7 +2875,7 @@ CodeParam parse_params( bool use_template_capture )
|
||||
if ( value )
|
||||
param->Value = value;
|
||||
|
||||
append(result, param );
|
||||
params_append(result, param );
|
||||
}
|
||||
|
||||
if ( ! use_template_capture )
|
||||
@ -2933,7 +2933,7 @@ CodePreprocessCond parse_preprocess_cond()
|
||||
return cond;
|
||||
}
|
||||
|
||||
internal
|
||||
internal
|
||||
Code parse_simple_preprocess( TokType which, bool dont_consume_braces )
|
||||
{
|
||||
// TODO(Ed): We can handle a macro a bit better than this. It's AST can be made more robust..
|
||||
@ -3305,7 +3305,7 @@ CodeVar parse_variable_declaration_list()
|
||||
"(Parser will add and continue to specifiers, but will most likely fail to compile)\n%s"
|
||||
, to_string(Context) );
|
||||
|
||||
append(specifiers, spec );
|
||||
specifiers_append(specifiers, spec );
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3327,7 +3327,7 @@ CodeVar parse_variable_declaration_list()
|
||||
// eat(currtok.Type);
|
||||
|
||||
if ( specifiers )
|
||||
append(specifiers, spec );
|
||||
specifiers_append(specifiers, spec );
|
||||
else
|
||||
specifiers = def_specifier( spec );
|
||||
}
|
||||
@ -3467,7 +3467,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
|
||||
if ( check( Tok_Spec_Virtual ) )
|
||||
{
|
||||
if ( specifiers )
|
||||
append(specifiers, Spec_Virtual );
|
||||
specifiers_append(specifiers, Spec_Virtual );
|
||||
else
|
||||
specifiers = def_specifier( Spec_Virtual );
|
||||
eat( Tok_Spec_Virtual );
|
||||
@ -3510,7 +3510,7 @@ CodeDestructor parse_destructor( CodeSpecifiers specifiers )
|
||||
eat( Tok_Number );
|
||||
// <Virtual Specifier> ~<Name>() = 0
|
||||
|
||||
append(specifiers, Spec_Pure );
|
||||
specifiers_append(specifiers, Spec_Pure );
|
||||
}
|
||||
else if ( left && str_compare_len( upcoming.Text, "default", sizeof("default") - 1 ) == 0)
|
||||
{
|
||||
@ -3762,7 +3762,7 @@ CodeEnum parse_enum( bool inplace_def )
|
||||
return InvalidCode;
|
||||
}
|
||||
|
||||
append(body, member );
|
||||
body_append(body, member );
|
||||
}
|
||||
|
||||
eat( Tok_BraceCurly_Close );
|
||||
@ -4206,7 +4206,7 @@ CodeOpCast parse_operator_cast( CodeSpecifiers specifiers )
|
||||
specifiers = def_specifier( Spec_Const );
|
||||
|
||||
else
|
||||
append(specifiers, Spec_Const );
|
||||
specifiers_append(specifiers, Spec_Const );
|
||||
|
||||
eat( Tok_Spec_Const );
|
||||
}
|
||||
@ -4965,6 +4965,7 @@ CodeTypedef parse_typedef()
|
||||
name = currtok;
|
||||
eat(Tok_Identifier);
|
||||
}
|
||||
// <ModuleFalgs> typedef <Preprocessed_Macro> <Identifier>
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5250,7 +5251,7 @@ CodeUnion parse_union( bool inplace_def )
|
||||
}
|
||||
|
||||
if ( member )
|
||||
append(body, member );
|
||||
body_append(body, member );
|
||||
}
|
||||
// <ModuleFlags> union <Attributes> <Name> { <Body>
|
||||
|
||||
|
Reference in New Issue
Block a user