Updates to docs and various changes to project from working on them.

- CodeParam -> CodeParams
- interfaces array weren't being used in parse_class_struct
- added enum_underlying_sig
This commit is contained in:
2024-12-11 13:33:35 -05:00
parent 9b86d84dd6
commit cb898595b0
31 changed files with 308 additions and 249 deletions

View File

@ -497,7 +497,7 @@ void code_to_string_ptr( Code self, String* result )
break;
case CT_Parameters:
params_to_string_ref(cast(CodeParam, self), result );
params_to_string_ref(cast(CodeParams, self), result );
break;
case CT_Preprocess_Define:

View File

@ -37,7 +37,7 @@ struct AST_Module;
struct AST_NS;
struct AST_Operator;
struct AST_OpCast;
struct AST_Param;
struct AST_Params;
struct AST_Pragma;
struct AST_PreprocessCond;
struct AST_Specifiers;
@ -109,7 +109,7 @@ typedef AST_Module* CodeModule;
typedef AST_NS* CodeNS;
typedef AST_Operator* CodeOperator;
typedef AST_OpCast* CodeOpCast;
typedef AST_Param* CodeParam;
typedef AST_Params* CodeParams;
typedef AST_PreprocessCond* CodePreprocessCond;
typedef AST_Pragma* CodePragma;
typedef AST_Specifiers* CodeSpecifiers;
@ -131,7 +131,7 @@ struct CodeModule;
struct CodeNS;
struct CodeOperator;
struct CodeOpCast;
struct CodeParam;
struct CodeParams;
struct CodePreprocessCond;
struct CodePragma;
struct CodeSpecifiers;
@ -209,6 +209,7 @@ struct CodeStmt_Switch;
struct CodeStmt_While;
#endif
// GEN_EXECUTION_EXPRESSION_SUPPORT
#endif
#if GEN_COMPILER_C
@ -229,8 +230,6 @@ struct CodeUsing;
struct CodeVar;
#endif
#undef Define_Code
GEN_NS_PARSER_BEGIN
struct Token;
@ -343,7 +342,7 @@ struct Code
operator CodeNS() const;
operator CodeOperator() const;
operator CodeOpCast() const;
operator CodeParam() const;
operator CodeParams() const;
operator CodePragma() const;
operator CodePreprocessCond() const;
operator CodeSpecifiers() const;
@ -423,7 +422,7 @@ struct AST
union {
Code NextVar; // Variable; Possible way to handle comma separated variables declarations. ( , NextVar->Specs NextVar->Name NextVar->ArrExpr = NextVar->Value )
Code SuffixSpecs; // Only used with typenames, to store the function suffix if typename is function signature. ( May not be needed )
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
Code PostNameMacro; // Only used with parameters for specifically UE_REQUIRES (Thanks Unreal)
};
};
StringCached Content; // Attributes, Comment, Execution, Include
@ -456,7 +455,7 @@ struct AST
Operator Op;
AccessSpec ParentAccess;
s32 NumEntries;
s32 VarConstructorInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
s32 VarParenthesizedInit; // Used by variables to know that initialization is using a constructor expression instead of an assignment expression.
};
};
static_assert( sizeof(AST) == AST_POD_Size, "ERROR: AST is not size of AST_POD_Size" );

View File

@ -127,7 +127,7 @@ struct AST_Constructor
char _PAD_PROPERTIES_ [ sizeof(AST*) * 1 ];
CodeSpecifiers Specs;
Code InitializerList;
CodeParam Params;
CodeParams Params;
Code Body;
char _PAD_PROPERTIES_2_ [ sizeof(AST*) * 2 ];
};
@ -550,7 +550,7 @@ struct AST_Fn
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeTypename ReturnType;
CodeParam Params;
CodeParams Params;
CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
};
@ -613,7 +613,7 @@ struct AST_Operator
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeTypename ReturnType;
CodeParam Params;
CodeParams Params;
CodeBody Body;
char _PAD_PROPERTIES_ [ sizeof(AST*) ];
};
@ -639,9 +639,9 @@ struct AST_OpCast
char _PAD_PROPERTIES_[ sizeof(AST*) ];
CodeSpecifiers Specs;
CodeTypename ValueType;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
CodeBody Body;
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
CodeBody Body;
char _PAD_PROPERTIES_3_[ sizeof(AST*) ];
};
};
StringCached Name;
@ -654,7 +654,7 @@ struct AST_OpCast
};
static_assert( sizeof(AST_OpCast) == sizeof(AST), "ERROR: AST_OpCast is not the same size as AST");
struct AST_Param
struct AST_Params
{
union {
char _PAD_[ sizeof(Specifier) * AST_ArrSpecs_Cap + sizeof(AST*) ];
@ -669,15 +669,15 @@ struct AST_Param
};
};
StringCached Name;
CodeParam Last;
CodeParam Next;
CodeParams Last;
CodeParams Next;
Token* Tok;
Code Parent;
CodeType Type;
char _PAD_UNUSED_[ sizeof(ModuleFlag) ];
s32 NumEntries;
};
static_assert( sizeof(AST_Param) == sizeof(AST), "ERROR: AST_Param is not the same size as AST");
static_assert( sizeof(AST_Params) == sizeof(AST), "ERROR: AST_Params is not the same size as AST");
struct AST_Pragma
{
@ -971,7 +971,7 @@ struct AST_Template
struct
{
char _PAD_PROPERTIES_[ sizeof(AST*) * 4 ];
CodeParam Params;
CodeParams Params;
Code Declaration;
char _PAD_PROPERTIES_2_[ sizeof(AST*) ];
};
@ -1000,7 +1000,7 @@ struct AST_Type
CodeSpecifiers Specs;
Code QualifierID;
// CodeTypename ReturnType; // Only used for function signatures
// CodeParam Params; // Only used for function signatures
// CodeParams Params; // Only used for function signatures
Code ArrExpr;
// CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
};
@ -1017,7 +1017,6 @@ struct AST_Type
static_assert( sizeof(AST_Type) == sizeof(AST), "ERROR: AST_Type is not the same size as AST");
#endif
// TODO(Ed): Add support for preserving the typename's keyword qualifier (struct, class, enum, etc), mostly needed for C.
struct AST_Typename
{
union {
@ -1028,7 +1027,7 @@ struct AST_Typename
CodeAttributes Attributes;
CodeSpecifiers Specs;
CodeTypename ReturnType; // Only used for function signatures
CodeParam Params; // Only used for function signatures
CodeParams Params; // Only used for function signatures
Code ArrExpr;
CodeSpecifiers SpecsFuncSuffix; // Only used for function signatures
};
@ -1140,7 +1139,7 @@ struct AST_Var
Code Parent;
CodeType Type;
ModuleFlag ModuleFlags;
s32 VarConstructorInit;
s32 VarParenthesizedInit;
};
static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST");

View File

@ -197,7 +197,7 @@ void class_to_string_def( CodeClass self, String* result )
while ( interface )
{
string_append_fmt( result, ", %S", typename_to_string(interface) );
string_append_fmt( result, ", public %S", typename_to_string(interface) );
interface = interface->Next ? cast(CodeTypename, interface->Next) : NullCode;
}
}
@ -863,7 +863,7 @@ void opcast_to_string_fwd(CodeOpCast self, String* result )
string_append_fmt( result, "operator %S();\n", typename_to_string(self->ValueType) );
}
String params_to_string(CodeParam self)
String params_to_string(CodeParams self)
{
GEN_ASSERT(self);
GEN_ASSERT(self);
@ -872,7 +872,7 @@ String params_to_string(CodeParam self)
return result;
}
void params_to_string_ref( CodeParam self, String* result )
void params_to_string_ref( CodeParams self, String* result )
{
GEN_ASSERT(self);
GEN_ASSERT(result);
@ -904,7 +904,7 @@ void params_to_string_ref( CodeParam self, String* result )
if ( self->NumEntries - 1 > 0 )
{
for ( CodeParam param = begin_CodeParam(self->Next); param != end_CodeParam(self->Next); param = next_CodeParam(self->Next, param) )
for ( CodeParams param = begin_CodeParams(self->Next); param != end_CodeParams(self->Next); param = next_CodeParams(self->Next, param) )
{
string_append_fmt( result, ", %S", params_to_string(param) );
}
@ -1385,7 +1385,7 @@ void var_to_string_ref(CodeVar self, String* result )
if ( self->Value )
{
if ( self->VarConstructorInit )
if ( self->VarParenthesizedInit )
string_append_fmt( result, "( %S ", code_to_string(self->Value) );
else
string_append_fmt( result, " = %S", code_to_string(self->Value) );
@ -1395,7 +1395,7 @@ void var_to_string_ref(CodeVar self, String* result )
if ( self->NextVar )
string_append_fmt( result, ", %S", var_to_string(self->NextVar) );
if ( self->VarConstructorInit )
if ( self->VarParenthesizedInit )
string_append_strc( result, txt(" )"));
return;
@ -1431,7 +1431,7 @@ void var_to_string_ref(CodeVar self, String* result )
if ( self->Value )
{
if ( self->VarConstructorInit )
if ( self->VarParenthesizedInit )
string_append_fmt( result, "( %S ", code_to_string(self->Value) );
else
string_append_fmt( result, " = %S", code_to_string(self->Value) );
@ -1440,7 +1440,7 @@ void var_to_string_ref(CodeVar self, String* result )
if ( self->NextVar )
string_append_fmt( result, ", %S", var_to_string(self->NextVar) );
if ( self->VarConstructorInit )
if ( self->VarParenthesizedInit )
string_append_strc( result, txt(" )"));
if ( self->InlineCmt )
@ -1471,7 +1471,7 @@ void var_to_string_ref(CodeVar self, String* result )
if ( self->Value )
{
if ( self->VarConstructorInit )
if ( self->VarParenthesizedInit )
string_append_fmt( result, "( %S ", code_to_string(self->Value) );
else
string_append_fmt( result, " = %S", code_to_string(self->Value) );
@ -1480,7 +1480,7 @@ void var_to_string_ref(CodeVar self, String* result )
if ( self->NextVar )
string_append_fmt( result, ", %S", var_to_string( self->NextVar) );
if ( self->VarConstructorInit )
if ( self->VarParenthesizedInit )
string_append_strc( result, txt(" )"));
string_append_strc( result, txt(";") );

View File

@ -32,15 +32,15 @@ String class_to_string ( CodeClass self );
void class_to_string_def( CodeClass self, String* result );
void class_to_string_fwd( CodeClass self, String* result );
void params_append (CodeParam params, CodeParam param );
CodeParam params_get (CodeParam params, s32 idx);
bool params_has_entries (CodeParam params );
String params_to_string (CodeParam params );
void params_to_string_ref(CodeParam params, String* result );
void params_append (CodeParams params, CodeParams param );
CodeParams params_get (CodeParams params, s32 idx);
bool params_has_entries (CodeParams params );
String params_to_string (CodeParams params );
void params_to_string_ref(CodeParams params, String* result );
CodeParam begin_CodeParam(CodeParam params);
CodeParam end_CodeParam (CodeParam params);
CodeParam next_CodeParam (CodeParam params, CodeParam entry_iter);
CodeParams begin_CodeParams(CodeParams params);
CodeParams end_CodeParams (CodeParams params);
CodeParams next_CodeParams (CodeParams params, CodeParams entry_iter);
bool specifiers_append (CodeSpecifiers specifiers, Specifier spec);
s32 specifiers_has (CodeSpecifiers specifiers, Specifier spec);
@ -188,28 +188,28 @@ struct CodeClass
AST_Class* ast;
};
struct CodeParam
struct CodeParams
{
#if ! GEN_C_LIKE_CPP
Using_Code( CodeParam );
forceinline void append( CodeParam other );
forceinline CodeParam get( s32 idx );
Using_Code( CodeParams );
forceinline void append( CodeParams other );
forceinline CodeParams get( s32 idx );
forceinline bool has_entries();
forceinline String to_string();
forceinline void to_string( String& result );
forceinline CodeParam begin() { return begin_CodeParam(* this); }
forceinline CodeParam end() { return end_CodeParam(* this); }
forceinline CodeParams begin() { return begin_CodeParams(* this); }
forceinline CodeParams end() { return end_CodeParams(* this); }
#endif
Using_CodeOps( CodeParam );
Using_CodeOps( CodeParams );
forceinline operator Code() { return { (AST*)ast }; }
forceinline CodeParam operator*() { return * this; }
forceinline AST_Param* operator->() {
forceinline CodeParams operator*() { return * this; }
forceinline AST_Params* operator->() {
GEN_ASSERT(ast);
return ast;
}
CodeParam& operator++();
AST_Param* ast;
CodeParams& operator++();
AST_Params* ast;
};
struct CodeSpecifiers
@ -951,7 +951,7 @@ struct InvalidCode_ImplictCaster
operator CodeNS () const { return cast(CodeNS, Code_Invalid); }
operator CodeOperator () const { return cast(CodeOperator, Code_Invalid); }
operator CodeOpCast () const { return cast(CodeOpCast, Code_Invalid); }
operator CodeParam () const { return cast(CodeParam, Code_Invalid); }
operator CodeParams () const { return cast(CodeParams, Code_Invalid); }
operator CodePragma () const { return cast(CodePragma, Code_Invalid); }
operator CodePreprocessCond() const { return cast(CodePreprocessCond, Code_Invalid); }
operator CodeSpecifiers () const { return cast(CodeSpecifiers, Code_Invalid); }
@ -984,7 +984,7 @@ struct NullCode_ImplicitCaster
operator CodeNS () const { return {nullptr}; }
operator CodeOperator () const { return {nullptr}; }
operator CodeOpCast () const { return {nullptr}; }
operator CodeParam () const { return {nullptr}; }
operator CodeParams () const { return {nullptr}; }
operator CodePragma () const { return {nullptr}; }
operator CodePreprocessCond() const { return {nullptr}; }
operator CodeSpecifiers () const { return {nullptr}; }
@ -1011,19 +1011,19 @@ forceinline Code end ( CodeBody body ) { return end_CodeBody(b
forceinline Code next ( CodeBody body, Code entry_iter ) { return next_CodeBody(body, entry_iter); }
forceinline void add_interface( CodeClass self, CodeTypename interface ) { return class_add_interface(self, interface); }
forceinline String to_string ( CodeClass self ) { return class_to_string(self); }
forceinline void to_string_def( CodeClass self, String& result ) { return class_to_string_def(self, & result); }
forceinline void to_string_fwd( CodeClass self, String& result ) { return class_to_string_fwd(self, & result); }
forceinline String to_string ( CodeClass self ) { return class_to_string(self); }
forceinline void to_string_def( CodeClass self, String& result ) { return class_to_string_def(self, & result); }
forceinline void to_string_fwd( CodeClass self, String& result ) { return class_to_string_fwd(self, & result); }
forceinline void append (CodeParam params, CodeParam param ) { return params_append(params, param); }
forceinline CodeParam get (CodeParam params, s32 idx) { return params_get(params, idx); }
forceinline bool has_entries(CodeParam params ) { return params_has_entries(params); }
forceinline String to_string (CodeParam params ) { return params_to_string(params); }
forceinline void to_string (CodeParam params, String& result ) { return params_to_string_ref(params, & result); }
forceinline CodeParam begin(CodeParam params) { return begin_CodeParam(params); }
forceinline CodeParam end (CodeParam params) { return end_CodeParam(params); }
forceinline CodeParam next (CodeParam params, CodeParam entry_iter) { return next_CodeParam(params, entry_iter); }
forceinline void append (CodeParams params, CodeParams param ) { return params_append(params, param); }
forceinline CodeParams get (CodeParams params, s32 idx) { return params_get(params, idx); }
forceinline bool has_entries(CodeParams params ) { return params_has_entries(params); }
forceinline String to_string (CodeParams params ) { return params_to_string(params); }
forceinline void to_string (CodeParams params, String& result ) { return params_to_string_ref(params, & result); }
forceinline CodeParams begin(CodeParams params) { return begin_CodeParams(params); }
forceinline CodeParams end (CodeParams params) { return end_CodeParams(params); }
forceinline CodeParams next (CodeParams params, CodeParams entry_iter) { return next_CodeParams(params, entry_iter); }
forceinline bool append (CodeSpecifiers specifiers, Specifier spec) { return specifiers_append(specifiers, spec); }
forceinline s32 has (CodeSpecifiers specifiers, Specifier spec) { return specifiers_has(specifiers, spec); }

View File

@ -520,7 +520,7 @@ inline AST_OpCast* CodeOpCast::operator->()
return ast;
}
inline CodeParam& CodeParam::operator=( Code other )
inline CodeParams& CodeParams::operator=( Code other )
{
if ( other.ast != nullptr && other->Parent != nullptr )
{
@ -531,7 +531,7 @@ inline CodeParam& CodeParam::operator=( Code other )
return *this;
}
inline CodeParam::operator bool()
inline CodeParams::operator bool()
{
return ast != nullptr;
}
@ -906,9 +906,9 @@ forceinline Code::operator CodeOpCast() const
return { (AST_OpCast*)ast };
}
forceinline Code::operator CodeParam() const
forceinline Code::operator CodeParams() const
{
return { (AST_Param*)ast };
return { (AST_Params*)ast };
}
forceinline Code::operator CodePragma() const

View File

@ -53,6 +53,8 @@ constexpr s32 MaxUntypedStrLength = GEN_MAX_UNTYPED_STR_LENGTH;
constexpr s32 LexAllocator_Size = GEN_LEX_ALLOCATOR_SIZE;
constexpr s32 Builder_StrBufferReserve = GEN_BUILDER_STR_BUFFER_RESERVE;
extern StrC enum_underlying_sig;
extern Code access_public;
extern Code access_protected;
extern Code access_private;
@ -67,7 +69,7 @@ extern Code fmt_newline;
extern CodePragma pragma_once;
extern CodeParam param_varadic;
extern CodeParams param_varadic;
extern CodePreprocessCond preprocess_else;
extern CodePreprocessCond preprocess_endif;

View File

@ -178,9 +178,9 @@ void class_add_interface( CodeClass self, CodeTypename type )
}
#pragma endregion CodeClass
#pragma region CodeParam
#pragma region CodeParams
inline
void params_append( CodeParam appendee, CodeParam other )
void params_append( CodeParams appendee, CodeParams other )
{
GEN_ASSERT(appendee);
GEN_ASSERT(other);
@ -206,37 +206,37 @@ void params_append( CodeParam appendee, CodeParam other )
self->NumEntries++;
}
inline
CodeParam params_get(CodeParam self, s32 idx )
CodeParams params_get(CodeParams self, s32 idx )
{
GEN_ASSERT(self);
CodeParam param = self;
CodeParams param = self;
do
{
if ( ++ param != nullptr )
return NullCode;
param = cast(CodeParam, cast(Code, param)->Next);
param = cast(CodeParams, cast(Code, param)->Next);
}
while ( --idx );
return param;
}
forceinline
bool params_has_entries(CodeParam self)
bool params_has_entries(CodeParams self)
{
GEN_ASSERT(self);
return self->NumEntries > 0;
}
#if GEN_COMPILER_CPP
forceinline
CodeParam& CodeParam::operator ++()
CodeParams& CodeParams::operator ++()
{
* this = ast->Next;
return * this;
}
#endif
forceinline
CodeParam begin_CodeParam(CodeParam params)
CodeParams begin_CodeParams(CodeParams params)
{
if ( params != nullptr )
return params;
@ -244,18 +244,18 @@ CodeParam begin_CodeParam(CodeParam params)
return NullCode;
}
forceinline
CodeParam end_CodeParam(CodeParam params)
CodeParams end_CodeParams(CodeParams params)
{
// return { (AST_Param*) rcast( AST*, ast)->Last };
// return { (AST_Params*) rcast( AST*, ast)->Last };
return NullCode;
}
forceinline
CodeParam next_CodeParam(CodeParam params, CodeParam param_iter)
CodeParams next_CodeParams(CodeParams params, CodeParams param_iter)
{
GEN_ASSERT(param_iter);
return param_iter->Next;
}
#pragma endregion CodeParam
#pragma endregion CodeParams
#pragma region CodeSpecifiers
inline

View File

@ -131,7 +131,7 @@ void define_constants()
pragma_once->Content = pragma_once->Name;
code_set_global((Code)pragma_once);
param_varadic = (CodeParam) make_code();
param_varadic = (CodeParams) make_code();
param_varadic->Type = CT_Parameters;
param_varadic->Name = get_cached_string( txt("...") );
param_varadic->ValueType = t_empty;
@ -183,7 +183,6 @@ void define_constants()
#endif
# undef def_constant_code_type
spec_const = def_specifier( Spec_Const); code_set_global( cast(Code, spec_const ));
spec_consteval = def_specifier( Spec_Consteval); code_set_global( cast(Code, spec_consteval ));;
spec_constexpr = def_specifier( Spec_Constexpr); code_set_global( cast(Code, spec_constexpr ));;
@ -212,9 +211,10 @@ void define_constants()
spec_local_persist = def_specifiers( 1, Spec_Local_Persist );
code_set_global(cast(Code, spec_local_persist));
# pragma push_macro("enum_underlying")
array_append(PreprocessorDefines, txt("enum_underlying("));
# pragma pop_macro("enum_underlying")
if (enum_underlying_sig.Len == 0) {
enum_underlying_sig = txt("enum_underlying(");
}
array_append(PreprocessorDefines, enum_underlying_sig);
# undef def_constant_spec
}

View File

@ -63,7 +63,7 @@ struct Opts_def_struct {
CodeClass def_class( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT );
struct Opts_def_constructor {
CodeParam params;
CodeParams params;
Code initializer_list;
Code body;
};
@ -86,6 +86,7 @@ struct Opts_def_enum {
EnumT specifier;
CodeAttributes attributes;
ModuleFlag mflags;
Code type_macro;
};
CodeEnum def_enum( StrC name, Opts_def_enum opts GEN_PARAM_DEFAULT );
@ -94,7 +95,7 @@ CodeExtern def_extern_link( StrC name, CodeBody body );
CodeFriend def_friend ( Code symbol );
struct Opts_def_function {
CodeParam params;
CodeParams params;
CodeTypename ret_type;
CodeBody body;
CodeSpecifiers specs;
@ -111,7 +112,7 @@ CodeModule def_module ( StrC name, Opts_def_module opts GEN
CodeNS def_namespace( StrC name, CodeBody body, Opts_def_namespace opts GEN_PARAM_DEFAULT );
struct Opts_def_operator {
CodeParam params;
CodeParams params;
CodeTypename ret_type;
CodeBody body;
CodeSpecifiers specifiers;
@ -127,7 +128,7 @@ struct Opts_def_operator_cast {
CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast opts GEN_PARAM_DEFAULT );
struct Opts_def_param { Code value; };
CodeParam def_param ( CodeTypename type, StrC name, Opts_def_param opts GEN_PARAM_DEFAULT );
CodeParams def_param ( CodeTypename type, StrC name, Opts_def_param opts GEN_PARAM_DEFAULT );
CodePragma def_pragma( StrC directive );
CodePreprocessCond def_preprocess_cond( EPreprocessCond type, StrC content );
@ -137,7 +138,7 @@ CodeSpecifiers def_specifier( Specifier specifier );
CodeStruct def_struct( StrC name, Opts_def_struct opts GEN_PARAM_DEFAULT );
struct Opts_def_template { ModuleFlag mflags; };
CodeTemplate def_template( CodeParam params, Code definition, Opts_def_template opts GEN_PARAM_DEFAULT );
CodeTemplate def_template( CodeParams params, Code definition, Opts_def_template opts GEN_PARAM_DEFAULT );
struct Opts_def_type {
ETypenameTag type_tag;
@ -196,8 +197,8 @@ CodeBody def_global_body ( s32 num, ... );
CodeBody def_global_body ( s32 num, Code* codes );
CodeBody def_namespace_body ( s32 num, ... );
CodeBody def_namespace_body ( s32 num, Code* codes );
CodeParam def_params ( s32 num, ... );
CodeParam def_params ( s32 num, CodeParam* params );
CodeParams def_params ( s32 num, ... );
CodeParams def_params ( s32 num, CodeParams* params );
CodeSpecifiers def_specifiers ( s32 num, ... );
CodeSpecifiers def_specifiers ( s32 num, Specifier* specs );
CodeBody def_struct_body ( s32 num, ... );

View File

@ -13,7 +13,7 @@ enum OpValidateResult : u32
};
internal neverinline
OpValidateResult operator__validate( Operator op, CodeParam params_code, CodeTypename ret_type, CodeSpecifiers specifier )
OpValidateResult operator__validate( Operator op, CodeParams params_code, CodeTypename ret_type, CodeSpecifiers specifier )
{
if ( op == Op_Invalid )
{
@ -497,7 +497,7 @@ CodeComment def_comment( StrC content )
CodeConstructor def_constructor( Opts_def_constructor p )
{
CodeParam params = p.params;
CodeParams params = p.params;
Code initializer_list = p.initializer_list;
Code body = p.body;
@ -700,6 +700,7 @@ CodeEnum def_enum( StrC name, Opts_def_enum p )
EnumT specifier = p.specifier;
CodeAttributes attributes = p.attributes;
ModuleFlag mflags = p.mflags;
Code type_macro = p.type_macro;
name_check( def_enum, name );
@ -751,6 +752,10 @@ CodeEnum def_enum( StrC name, Opts_def_enum p )
{
result->UnderlyingType = type;
}
else if ( type_macro )
{
result->UnderlyingTypeMacro = type_macro;
}
else if ( result->Type != CT_Enum_Class_Fwd && result->Type != CT_Enum_Fwd )
{
log_failure( "gen::def_enum: enum forward declaration must have an underlying type" );
@ -829,7 +834,7 @@ CodeFriend def_friend( Code declaration )
CodeFn def_function( StrC name, Opts_def_function p )
{
CodeParam params = p.params;
CodeParams params = p.params;
CodeTypename ret_type = p.ret_type;
CodeBody body = p.body;
CodeSpecifiers specifiers = p.specs;
@ -969,7 +974,7 @@ CodeNS def_namespace( StrC name, CodeBody body, Opts_def_namespace p )
CodeOperator def_operator( Operator op, StrC nspace, Opts_def_operator p )
{
CodeParam params_code = p.params;
CodeParams params_code = p.params;
CodeTypename ret_type = p.ret_type;
CodeBody body = p.body;
CodeSpecifiers specifiers = p.specifiers;
@ -1093,7 +1098,7 @@ CodeOpCast def_operator_cast( CodeTypename type, Opts_def_operator_cast p )
return result;
}
CodeParam def_param( CodeTypename type, StrC name, Opts_def_param p )
CodeParams def_param( CodeTypename type, StrC name, Opts_def_param p )
{
name_check( def_param, name );
null_check( def_param, type );
@ -1110,8 +1115,8 @@ CodeParam def_param( CodeTypename type, StrC name, Opts_def_param p )
return InvalidCode;
}
CodeParam
result = (CodeParam) make_code();
CodeParams
result = (CodeParams) make_code();
result->Type = CT_Parameters;
result->Name = get_cached_string( name );
@ -1247,7 +1252,7 @@ CodeStruct def_struct( StrC name, Opts_def_struct p )
return result;
}
CodeTemplate def_template( CodeParam params, Code declaration, Opts_def_template p )
CodeTemplate def_template( CodeParams params, Code declaration, Opts_def_template p )
{
null_check( def_template, declaration );
@ -2064,7 +2069,7 @@ CodeBody def_namespace_body( s32 num, Code* codes )
return result;
}
CodeParam def_params( s32 num, ... )
CodeParams def_params( s32 num, ... )
{
def_body_start( def_params );
@ -2072,7 +2077,7 @@ CodeParam def_params( s32 num, ... )
va_start(va, num);
Code_POD pod = va_arg(va, Code_POD);
CodeParam param = pcast( CodeParam, pod );
CodeParams param = pcast( CodeParams, pod );
null_check( def_params, param );
@ -2082,12 +2087,12 @@ CodeParam def_params( s32 num, ... )
return InvalidCode;
}
CodeParam result = (CodeParam) code_duplicate(param);
CodeParams result = (CodeParams) code_duplicate(param);
while ( -- num )
{
pod = va_arg(va, Code_POD);
param = pcast( CodeParam, pod );
param = pcast( CodeParams, pod );
if ( param->Type != CT_Parameters )
{
@ -2102,7 +2107,7 @@ CodeParam def_params( s32 num, ... )
return result;
}
CodeParam def_params( s32 num, CodeParam* codes )
CodeParams def_params( s32 num, CodeParams* codes )
{
def_body_code_array_start( def_params );
@ -2119,11 +2124,11 @@ CodeParam def_params( s32 num, CodeParam* codes )
return InvalidCode; \
}
CodeParam current = (CodeParam)code_duplicate(* codes);
CodeParams current = (CodeParams)code_duplicate(* codes);
check_current(current);
CodeParam
result = (CodeParam) make_code();
CodeParams
result = (CodeParams) make_code();
result->Name = current->Name;
result->Type = current->Type;
result->ValueType = current->ValueType;

View File

@ -663,6 +663,10 @@ TokArray lex( StrC content )
switch ( current )
{
if (array_back(Lexer_Tokens)->Length > 100 ) {
__debugbreak();
}
case '#':
{
s32 result = lex_preprocessor_directive( ctx );

View File

@ -225,7 +225,7 @@ internal CodeInclude parse_include ();
internal CodeOperator parse_operator_after_ret_type ( ModuleFlag mflags, CodeAttributes attributes, CodeSpecifiers specifiers, CodeTypename ret_type );
internal Code parse_operator_function_or_variable( bool expects_function, CodeAttributes attributes, CodeSpecifiers specifiers );
internal CodePragma parse_pragma ();
internal CodeParam parse_params ( bool use_template_capture );
internal CodeParams parse_params ( bool use_template_capture );
internal CodePreprocessCond parse_preprocess_cond ();
internal Code parse_simple_preprocess ( TokType which, bool dont_consume_braces );
internal Code parse_static_assert ();
@ -797,11 +797,10 @@ Code parse_class_struct( TokType which, bool inplace_def )
}
if ( which == Tok_Decl_Class )
result = cast(Code, def_class( tok_to_str(name), def_assign( body, parent, access, attributes, nullptr, 0, mflags ) ));
result = cast(Code, def_class( tok_to_str(name), def_assign( body, parent, access, attributes, interfaces, scast(s32, array_num(interfaces)), mflags ) ));
else
result = cast(Code, def_struct( tok_to_str(name), def_assign( body, (CodeTypename)parent, access, attributes, nullptr, 0, mflags ) ));
result = cast(Code, def_struct( tok_to_str(name), def_assign( body, (CodeTypename)parent, access, attributes, interfaces, scast(s32, array_num(interfaces)), mflags ) ));
if ( inline_cmt )
result->InlineCmt = cast(Code, inline_cmt);
@ -1479,7 +1478,7 @@ CodeFn parse_function_after_name(
)
{
push_scope();
CodeParam params = parse_params(parser_use_parenthesis);
CodeParams params = parse_params(parser_use_parenthesis);
// <Attributes> <Specifiers> <ReturnType> <Name> ( <Parameters> )
// TODO(Ed), Review old comment : These have to be kept separate from the return type's specifiers.
@ -2516,7 +2515,7 @@ CodeOperator parse_operator_after_ret_type(
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op>
// Parse Params
CodeParam params = parse_params(parser_use_parenthesis);
CodeParams params = parse_params(parser_use_parenthesis);
// <ExportFlag> <Attributes> <Specifiers> <ReturnType> <Qualifier::...> operator <Op> ( <Parameters> )
if ( params == nullptr && op == Op_Multiply )
@ -2694,7 +2693,7 @@ CodePragma parse_pragma()
}
internal inline
CodeParam parse_params( bool use_template_capture )
CodeParams parse_params( bool use_template_capture )
{
push_scope();
@ -2823,7 +2822,7 @@ CodeParam parse_params( bool use_template_capture )
}
}
CodeParam result = ( CodeParam )make_code();
CodeParams result = ( CodeParams )make_code();
result->Type = CT_Parameters;
result->Macro = macro;
@ -2940,7 +2939,7 @@ CodeParam parse_params( bool use_template_capture )
// ( <Macro> <ValueType> <Name> = <Expression>, <Macro> <ValueType> <Name> = <Expression>, ..
}
CodeParam param = ( CodeParam )make_code();
CodeParams param = ( CodeParams )make_code();
param->Type = CT_Parameters;
param->Macro = macro;
@ -3372,7 +3371,7 @@ CodeVar parse_variable_after_name(
result->NextVar->Parent = cast(Code, result);
}
result->VarConstructorInit = using_constructor_initializer;
result->VarParenthesizedInit = using_constructor_initializer;
parser_pop(& Context);
return result;
@ -3476,7 +3475,7 @@ CodeConstructor parser_parse_constructor( CodeSpecifiers specifiers )
push_scope();
Token identifier = parse_identifier(nullptr);
CodeParam params = parse_params(parser_not_from_template);
CodeParams params = parse_params(parser_not_from_template);
// <Name> ( <Parameters> )
Code initializer_list = NullCode;
@ -3731,8 +3730,7 @@ CodeEnum parser_parse_enum( bool inplace_def )
else if ( currtok.Type == Tok_Preprocess_Macro )
{
// We'll support the enum_underlying macro
StrC sig = txt("enum_underlying(");
if ( strc_contains( tok_to_str(currtok), sig) )
if ( strc_contains( tok_to_str(currtok), enum_underlying_sig) )
{
use_macro_underlying = true;
underlying_macro = parse_simple_preprocess( Tok_Preprocess_Macro, parser_dont_consume_braces );
@ -4040,7 +4038,7 @@ CodeFriend parser_parse_friend()
function = parse_function_after_name( ModuleFlag_None, NullCode, specifiers, type, name );
// Parameter list
// CodeParam params = parse_params();
// CodeParams params = parse_params();
// friend <ReturnType> <Name> ( <Parameters> )
// function = make_code();
@ -4410,7 +4408,7 @@ CodeTemplate parser_parse_template()
eat( Tok_Decl_Template );
// <export> template
CodeParam params = parse_params( UseTemplateCapture );
CodeParams params = parse_params( UseTemplateCapture );
if ( cast(Code, params) == Code_Invalid )
{
parser_pop(& Context);
@ -4775,10 +4773,10 @@ else if ( currtok.Type == Tok_DeclType )
// For function type signatures
CodeTypename return_type = NullCode;
CodeParam params = NullCode;
CodeParams params = NullCode;
#ifdef GEN_USE_NEW_TYPENAME_PARSING
CodeParam params_nested = NullCode;
CodeParams params_nested = NullCode;
#endif
bool is_function_typename = false;
@ -5583,6 +5581,12 @@ CodeVar parser_parse_variable()
}
internal
CodeTypename parser_parse_type_alt( bool from_template, bool* typedef_is_functon )
{
}
GEN_NS_PARSER_END
#ifdef CHECK_WAS_DEFINED

View File

@ -28,6 +28,8 @@ global AllocatorInfo Allocator_TypeTable = {0};
#pragma region Constants
global StrC enum_underlying_sig;
global Code access_public;
global Code access_protected;
global Code access_private;
@ -40,7 +42,7 @@ global Code module_private_fragment;
global Code fmt_newline;
global CodeParam param_varadic;
global CodeParams param_varadic;
global CodePragma pragma_once;