2023-08-28 20:46:50 -07:00
|
|
|
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
2023-08-21 17:30:13 -07:00
|
|
|
#pragma once
|
2023-08-21 20:02:20 -07:00
|
|
|
#include "interface.hpp"
|
2023-08-28 20:46:50 -07:00
|
|
|
#endif
|
2023-08-21 17:30:13 -07:00
|
|
|
|
2024-12-02 17:20:30 -08:00
|
|
|
#pragma region Code
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-06 02:29:17 -08:00
|
|
|
void code_append( Code self, Code other )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
|
|
|
GEN_ASSERT(other);
|
|
|
|
GEN_ASSERT_MSG(self != other, "Attempted to recursively append Code AST to itself.");
|
2024-12-01 15:50:37 -08:00
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( other->Parent != nullptr )
|
2024-12-06 02:29:17 -08:00
|
|
|
other = code_duplicate(other);
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-01 15:50:37 -08:00
|
|
|
other->Parent = self;
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-01 15:50:37 -08:00
|
|
|
if ( self->Front == nullptr )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-01 15:50:37 -08:00
|
|
|
self->Front = other;
|
|
|
|
self->Back = other;
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-01 15:50:37 -08:00
|
|
|
self->NumEntries++;
|
2023-08-03 08:01:43 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-02 17:20:30 -08:00
|
|
|
Code
|
2024-12-01 15:50:37 -08:00
|
|
|
Current = self->Back;
|
2023-08-03 08:01:43 -07:00
|
|
|
Current->Next = other;
|
|
|
|
other->Prev = Current;
|
2024-12-01 15:50:37 -08:00
|
|
|
self->Back = other;
|
|
|
|
self->NumEntries++;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-06 02:29:17 -08:00
|
|
|
bool code_is_body(Code self)
|
2024-12-01 10:29:33 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
2024-12-01 15:50:37 -08:00
|
|
|
switch (self->Type)
|
2024-12-01 10:29:33 -08:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Enum_Body:
|
|
|
|
case CT_Class_Body:
|
|
|
|
case CT_Union_Body:
|
|
|
|
case CT_Export_Body:
|
|
|
|
case CT_Global_Body:
|
|
|
|
case CT_Struct_Body:
|
|
|
|
case CT_Function_Body:
|
|
|
|
case CT_Namespace_Body:
|
|
|
|
case CT_Extern_Linkage_Body:
|
2024-12-01 10:29:33 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2024-12-01 21:10:24 -08:00
|
|
|
inline
|
2024-12-06 02:29:17 -08:00
|
|
|
Code* code_entry( Code self, u32 idx )
|
2024-12-01 21:10:24 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self != nullptr);
|
2024-12-02 17:20:30 -08:00
|
|
|
Code* current = & self->Front;
|
|
|
|
while ( idx >= 0 && current != nullptr )
|
2024-12-01 21:16:11 -08:00
|
|
|
{
|
2024-12-02 17:20:30 -08:00
|
|
|
if ( idx == 0 )
|
|
|
|
return rcast( Code*, current);
|
2024-12-01 21:16:11 -08:00
|
|
|
|
2024-12-02 17:20:30 -08:00
|
|
|
current = & ( * current )->Next;
|
|
|
|
idx--;
|
2024-12-01 21:18:54 -08:00
|
|
|
}
|
2024-12-02 17:20:30 -08:00
|
|
|
|
|
|
|
return rcast( Code*, current);
|
2024-12-01 21:18:54 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
2024-12-06 02:29:17 -08:00
|
|
|
bool code_is_valid(Code self)
|
2024-12-01 21:34:40 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
|
|
|
return self != nullptr && self->Type != CT_Invalid;
|
2024-12-01 21:34:40 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
2024-12-06 02:29:17 -08:00
|
|
|
bool code_has_entries(AST* self)
|
2024-12-01 21:41:41 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
2024-12-02 17:20:30 -08:00
|
|
|
return self->NumEntries > 0;
|
2024-12-01 21:41:41 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
2024-12-06 02:29:17 -08:00
|
|
|
void code_set_global(Code self)
|
2024-12-01 21:43:57 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( self == nullptr )
|
2024-12-01 21:43:57 -08:00
|
|
|
{
|
|
|
|
log_failure("Code::set_global: Cannot set code as global, AST is null!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
self->Parent = Code_Global;
|
2024-12-01 21:43:57 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
#if GEN_COMPILER_CPP
|
|
|
|
forceinline
|
2023-08-03 08:01:43 -07:00
|
|
|
Code& Code::operator ++()
|
|
|
|
{
|
|
|
|
if ( ast )
|
2024-12-02 17:20:30 -08:00
|
|
|
ast = ast->Next.ast;
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-02 17:20:30 -08:00
|
|
|
return * this;
|
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
#endif
|
|
|
|
forceinline
|
2024-12-12 09:55:15 -08:00
|
|
|
Str code_type_str(Code self)
|
2024-12-02 17:20:30 -08:00
|
|
|
{
|
|
|
|
GEN_ASSERT(self != nullptr);
|
2024-12-08 20:10:10 -08:00
|
|
|
return codetype_to_str( self->Type );
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-12-01 21:10:24 -08:00
|
|
|
#pragma endregion Code
|
|
|
|
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma region CodeBody
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
void body_append( CodeBody self, Code other )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
|
|
|
GEN_ASSERT(other);
|
2024-12-02 01:12:09 -08:00
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
if (code_is_body(other)) {
|
2024-12-06 21:21:09 -08:00
|
|
|
body_append_body( self, cast(CodeBody, other) );
|
2024-12-02 01:12:09 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-06 02:29:17 -08:00
|
|
|
code_append( cast(Code, self), other );
|
2024-12-02 01:12:09 -08:00
|
|
|
}
|
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
void body_append_body( CodeBody self, CodeBody body )
|
2024-12-02 01:12:09 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
|
|
|
GEN_ASSERT(body);
|
|
|
|
GEN_ASSERT_MSG(self != body, "Attempted to append body to itself.");
|
2024-12-02 07:58:24 -08:00
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
for ( Code entry = begin_CodeBody(body); entry != end_CodeBody(body); entry = next_CodeBody(body, entry) ) {
|
|
|
|
body_append( self, entry );
|
2024-12-02 01:12:09 -08:00
|
|
|
}
|
|
|
|
}
|
2024-12-02 07:58:24 -08:00
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
Code begin_CodeBody( CodeBody body) {
|
|
|
|
GEN_ASSERT(body);
|
|
|
|
if ( body != nullptr )
|
|
|
|
return body->Front;
|
2024-12-08 13:37:04 -08:00
|
|
|
|
|
|
|
return NullCode;
|
2024-12-02 07:58:24 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
|
|
|
Code end_CodeBody(CodeBody body ){
|
|
|
|
GEN_ASSERT(body);
|
|
|
|
return body->Back->Next;
|
2024-12-02 07:58:24 -08:00
|
|
|
}
|
2024-12-06 02:29:17 -08:00
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
Code next_CodeBody(CodeBody body, Code entry) {
|
|
|
|
GEN_ASSERT(body);
|
|
|
|
GEN_ASSERT(entry);
|
2024-12-06 02:29:17 -08:00
|
|
|
return entry->Next;
|
|
|
|
}
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma endregion CodeBody
|
2024-12-02 01:12:09 -08:00
|
|
|
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma region CodeClass
|
2024-12-02 01:12:09 -08:00
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
void class_add_interface( CodeClass self, CodeTypename type )
|
2024-12-02 01:12:09 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
|
|
|
GEN_ASSERT(type);
|
2024-12-03 12:19:39 -08:00
|
|
|
CodeTypename possible_slot = self->ParentType;
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( possible_slot != nullptr )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2023-09-06 00:06:30 -07:00
|
|
|
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
2024-12-02 01:12:09 -08:00
|
|
|
self->ParentAccess = AccessSpec_Public;
|
2023-09-06 00:06:30 -07:00
|
|
|
// If your planning on adding a proper parent,
|
|
|
|
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
|
|
|
}
|
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
while ( possible_slot != nullptr )
|
2023-09-06 00:06:30 -07:00
|
|
|
{
|
2024-12-08 13:37:04 -08:00
|
|
|
possible_slot = cast(CodeTypename, possible_slot->Next);
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
possible_slot = type;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma endregion CodeClass
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-11 10:33:35 -08:00
|
|
|
#pragma region CodeParams
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-11 10:33:35 -08:00
|
|
|
void params_append( CodeParams appendee, CodeParams other )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(appendee);
|
|
|
|
GEN_ASSERT(other);
|
2024-12-07 14:17:02 -08:00
|
|
|
GEN_ASSERT_MSG(appendee != other, "Attempted to append parameter to itself.");
|
2024-12-02 17:20:30 -08:00
|
|
|
Code self = cast(Code, appendee);
|
|
|
|
Code entry = cast(Code, other);
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( entry->Parent != nullptr )
|
2024-12-06 02:29:17 -08:00
|
|
|
entry = code_duplicate( entry );
|
2023-08-03 08:01:43 -07:00
|
|
|
|
|
|
|
entry->Parent = self;
|
|
|
|
|
|
|
|
if ( self->Last == nullptr )
|
|
|
|
{
|
|
|
|
self->Last = entry;
|
|
|
|
self->Next = entry;
|
|
|
|
self->NumEntries++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self->Last->Next = entry;
|
|
|
|
self->Last = entry;
|
|
|
|
self->NumEntries++;
|
|
|
|
}
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-11 10:33:35 -08:00
|
|
|
CodeParams params_get(CodeParams self, s32 idx )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
2024-12-11 10:33:35 -08:00
|
|
|
CodeParams param = self;
|
2023-08-03 08:01:43 -07:00
|
|
|
do
|
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( ++ param != nullptr )
|
2024-12-08 13:37:04 -08:00
|
|
|
return NullCode;
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-11 10:33:35 -08:00
|
|
|
param = cast(CodeParams, cast(Code, param)->Next);
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
|
|
|
while ( --idx );
|
|
|
|
|
2024-10-25 02:01:37 -07:00
|
|
|
return param;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
2024-12-11 10:33:35 -08:00
|
|
|
bool params_has_entries(CodeParams self)
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self);
|
2024-12-02 07:58:24 -08:00
|
|
|
return self->NumEntries > 0;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
#if GEN_COMPILER_CPP
|
|
|
|
forceinline
|
2024-12-11 10:33:35 -08:00
|
|
|
CodeParams& CodeParams::operator ++()
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
* this = ast->Next;
|
2023-08-03 08:01:43 -07:00
|
|
|
return * this;
|
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
#endif
|
|
|
|
forceinline
|
2024-12-11 10:33:35 -08:00
|
|
|
CodeParams begin_CodeParams(CodeParams params)
|
2024-12-02 13:59:13 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( params != nullptr )
|
|
|
|
return params;
|
2024-12-02 13:59:13 -08:00
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
return NullCode;
|
2024-12-02 13:59:13 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
2024-12-11 10:33:35 -08:00
|
|
|
CodeParams end_CodeParams(CodeParams params)
|
2024-12-02 13:59:13 -08:00
|
|
|
{
|
2024-12-11 10:33:35 -08:00
|
|
|
// return { (AST_Params*) rcast( AST*, ast)->Last };
|
2024-12-08 13:37:04 -08:00
|
|
|
return NullCode;
|
2024-12-02 13:59:13 -08:00
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
2024-12-11 10:33:35 -08:00
|
|
|
CodeParams next_CodeParams(CodeParams params, CodeParams param_iter)
|
2024-12-06 21:21:09 -08:00
|
|
|
{
|
2024-12-07 14:17:02 -08:00
|
|
|
GEN_ASSERT(param_iter);
|
|
|
|
return param_iter->Next;
|
2024-12-06 21:21:09 -08:00
|
|
|
}
|
2024-12-11 10:33:35 -08:00
|
|
|
#pragma endregion CodeParams
|
2024-12-02 07:58:24 -08:00
|
|
|
|
2024-12-14 11:02:16 -08:00
|
|
|
#pragma region CodeDefineParams
|
|
|
|
forceinline void define_params_append (CodeDefineParams appendee, CodeDefineParams other ) { params_append( cast(CodeParams, appendee), cast(CodeParams, other) ); }
|
2024-12-14 18:21:13 -08:00
|
|
|
forceinline CodeDefineParams define_params_get (CodeDefineParams self, s32 idx ) { return (CodeDefineParams) (Code) params_get( cast(CodeParams, self), idx); }
|
2024-12-14 11:02:16 -08:00
|
|
|
forceinline bool define_params_has_entries(CodeDefineParams self) { return params_has_entries( cast(CodeParams, self)); }
|
|
|
|
|
2024-12-15 14:52:31 -08:00
|
|
|
forceinline CodeDefineParams begin_CodeDefineParams(CodeDefineParams params) { return (CodeDefineParams) (Code) begin_CodeParams( cast(CodeParams, (Code)params)); }
|
|
|
|
forceinline CodeDefineParams end_CodeDefineParams (CodeDefineParams params) { return (CodeDefineParams) (Code) end_CodeParams ( cast(CodeParams, (Code)params)); }
|
|
|
|
forceinline CodeDefineParams next_CodeDefineParams (CodeDefineParams params, CodeDefineParams entry_iter) { return (CodeDefineParams) (Code) next_CodeParams ( cast(CodeParams, (Code)params), cast(CodeParams, (Code)entry_iter)); }
|
2024-12-14 20:10:23 -08:00
|
|
|
|
|
|
|
#if GEN_COMPILER_CPP
|
|
|
|
forceinline
|
|
|
|
CodeDefineParams& CodeDefineParams::operator ++()
|
|
|
|
{
|
|
|
|
* this = ast->Next;
|
|
|
|
return * this;
|
|
|
|
}
|
|
|
|
#endif
|
2024-12-14 11:02:16 -08:00
|
|
|
#pragma endregion CodeDefineParams
|
|
|
|
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma region CodeSpecifiers
|
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
bool specifiers_append(CodeSpecifiers self, Specifier spec )
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( self == nullptr )
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
|
|
|
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ( self->NumEntries == AST_ArrSpecs_Cap )
|
|
|
|
{
|
|
|
|
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap );
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-02 07:58:24 -08:00
|
|
|
self->ArrSpecs[ self->NumEntries ] = spec;
|
|
|
|
self->NumEntries++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
s32 specifiers_has(CodeSpecifiers self, Specifier spec)
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
GEN_ASSERT(self != nullptr);
|
2024-12-02 07:58:24 -08:00
|
|
|
for ( s32 idx = 0; idx < self->NumEntries; idx++ ) {
|
|
|
|
if ( self->ArrSpecs[ idx ] == spec )
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
inline
|
2024-12-06 21:21:09 -08:00
|
|
|
s32 specifiers_remove( CodeSpecifiers self, Specifier to_remove )
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( self == nullptr )
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
|
|
|
log_failure("CodeSpecifiers: Attempted to append to a null specifiers AST!");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if ( self->NumEntries == AST_ArrSpecs_Cap )
|
|
|
|
{
|
|
|
|
log_failure("CodeSpecifiers: Attempted to append over %d specifiers to a specifiers AST!", AST_ArrSpecs_Cap );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 result = -1;
|
|
|
|
|
|
|
|
s32 curr = 0;
|
|
|
|
s32 next = 0;
|
|
|
|
for(; next < self->NumEntries; ++ curr, ++ next)
|
|
|
|
{
|
2024-12-03 10:14:14 -08:00
|
|
|
Specifier spec = self->ArrSpecs[next];
|
2024-12-02 07:58:24 -08:00
|
|
|
if (spec == to_remove)
|
|
|
|
{
|
|
|
|
result = next;
|
|
|
|
|
|
|
|
next ++;
|
|
|
|
if (next >= self->NumEntries)
|
|
|
|
break;
|
|
|
|
|
|
|
|
spec = self->ArrSpecs[next];
|
|
|
|
}
|
|
|
|
|
|
|
|
self->ArrSpecs[ curr ] = spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result > -1) {
|
|
|
|
self->NumEntries --;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
|
|
|
Specifier* begin_CodeSpecifiers(CodeSpecifiers self)
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( self != nullptr )
|
2024-12-02 07:58:24 -08:00
|
|
|
return & self->ArrSpecs[0];
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
|
|
|
Specifier* end_CodeSpecifiers(CodeSpecifiers self)
|
2024-12-02 07:58:24 -08:00
|
|
|
{
|
|
|
|
return self->ArrSpecs + self->NumEntries;
|
|
|
|
}
|
2024-12-06 21:21:09 -08:00
|
|
|
forceinline
|
|
|
|
Specifier* next_CodeSpecifiers(CodeSpecifiers self, Specifier* spec_iter)
|
|
|
|
{
|
|
|
|
return spec_iter + 1;
|
|
|
|
}
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma endregion CodeSpecifiers
|
|
|
|
|
|
|
|
#pragma region CodeStruct
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-08 13:37:04 -08:00
|
|
|
void struct_add_interface(CodeStruct self, CodeTypename type )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
CodeTypename possible_slot = self->ParentType;
|
2024-12-06 21:21:09 -08:00
|
|
|
if ( possible_slot != nullptr )
|
2023-09-06 00:06:30 -07:00
|
|
|
{
|
|
|
|
// Were adding an interface to parent type, so we need to make sure the parent type is public.
|
2024-12-02 08:20:31 -08:00
|
|
|
self->ParentAccess = AccessSpec_Public;
|
2023-09-06 00:06:30 -07:00
|
|
|
// If your planning on adding a proper parent,
|
|
|
|
// then you'll need to move this over to ParentType->next and update ParentAccess accordingly.
|
|
|
|
}
|
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
while ( possible_slot != nullptr )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
2024-12-08 13:37:04 -08:00
|
|
|
possible_slot = cast(CodeTypename, possible_slot->Next);
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
|
|
|
|
2024-12-06 21:21:09 -08:00
|
|
|
possible_slot = type;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma endregion Code
|
2023-08-03 08:01:43 -07:00
|
|
|
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma region Interface
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-03 12:19:39 -08:00
|
|
|
CodeBody def_body( CodeType type )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
|
|
|
switch ( type )
|
|
|
|
{
|
2024-12-03 12:19:39 -08:00
|
|
|
case CT_Class_Body:
|
|
|
|
case CT_Enum_Body:
|
|
|
|
case CT_Export_Body:
|
|
|
|
case CT_Extern_Linkage:
|
|
|
|
case CT_Function_Body:
|
|
|
|
case CT_Global_Body:
|
|
|
|
case CT_Namespace_Body:
|
|
|
|
case CT_Struct_Body:
|
|
|
|
case CT_Union_Body:
|
2023-08-03 08:01:43 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-12-08 13:37:04 -08:00
|
|
|
log_failure( "def_body: Invalid type %s", codetype_to_str(type).Ptr );
|
2024-12-01 21:03:38 -08:00
|
|
|
return (CodeBody)Code_Invalid;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Code
|
|
|
|
result = make_code();
|
|
|
|
result->Type = type;
|
|
|
|
return (CodeBody)result;
|
|
|
|
}
|
|
|
|
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-12 09:55:15 -08:00
|
|
|
Str token_fmt_impl( ssize num, ... )
|
2023-08-03 08:01:43 -07:00
|
|
|
{
|
|
|
|
local_persist thread_local
|
|
|
|
char buf[GEN_PRINTF_MAXLEN] = { 0 };
|
|
|
|
mem_set( buf, 0, GEN_PRINTF_MAXLEN );
|
|
|
|
|
|
|
|
va_list va;
|
|
|
|
va_start(va, num );
|
2024-10-27 15:58:37 -07:00
|
|
|
ssize result = token_fmt_va(buf, GEN_PRINTF_MAXLEN, num, va);
|
2023-08-03 08:01:43 -07:00
|
|
|
va_end(va);
|
|
|
|
|
2024-12-13 10:20:16 -08:00
|
|
|
Str str = { buf, result };
|
2024-12-08 13:37:04 -08:00
|
|
|
return str;
|
2023-08-03 08:01:43 -07:00
|
|
|
}
|
2024-12-02 07:58:24 -08:00
|
|
|
#pragma endregion Interface
|