HashTable non-parsed implemented.

Improved the text to string macros!
This commit is contained in:
2023-07-01 00:23:40 -04:00
parent ef790fdda5
commit 4db9aadea7
9 changed files with 661 additions and 59 deletions

View File

@ -36,6 +36,7 @@
// # define ZPL_MODULE_PARSER
#include "zpl.h"
using zpl::b32;
using zpl::s8;
using zpl::s16;
using zpl::s32;
@ -157,9 +158,9 @@ using zpl::str_len;
#define scast( Type_, Value_ ) static_cast< Type_ >( Value_ )
#define rcast( Type_, Value_ ) reinterpret_cast< Type_ >( Value_ )
#define pcast( Type_, Value_ ) ( * (Type_*)( & (Value_) ) )
#define txt_impl( Value_ ) #Value_
#define txt( Value_ ) txt_impl( Value_ )
#define txt_n_len( Value_ ) sizeof( txt_impl( Value_ ) ), txt_impl( Value_ )
#define txt_impl( ... ) #__VA_ARGS__
#define txt( ... ) txt_impl( __VA_ARGS__ )
#define txt_n_len( ... ) sizeof( txt_impl( __VA_ARGS__ ) ), txt_impl( __VA_ARGS__ )
#define do_once() \
do \
{ \
@ -513,7 +514,7 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
return Data;
}
operator StrC()
operator StrC() const
{
return
{

View File

@ -25,7 +25,6 @@ namespace gen
}
#pragma region Constants
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
Code type_ns(auto);
Code type_ns(void);
Code type_ns(int);
@ -33,6 +32,9 @@ namespace gen
Code type_ns(char);
Code type_ns(wchar_t);
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
Code type_ns(b32);
Code type_ns(s8);
Code type_ns(s16);
Code type_ns(s32);
@ -296,6 +298,7 @@ namespace gen
break;
case Untyped:
case Execution:
result.append( Content );
break;
@ -328,7 +331,6 @@ namespace gen
case Access_Private:
case Access_Protected:
case Access_Public:
result.append( indent );
result.append( Name );
break;
@ -508,10 +510,6 @@ namespace gen
}
break;
case Execution:
result.append( Content );
break;
case Export_Body:
{
result.append_fmt( "%sexport\n%s{\n", indent_str, indent_str );
@ -1107,6 +1105,8 @@ namespace gen
def_constant_code_type( wchar_t );
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
type_ns(b32) = def_type( name(b32) );
def_constant_code_type( s8 );
def_constant_code_type( s16 );
def_constant_code_type( s32 );
@ -1129,21 +1129,21 @@ namespace gen
access_private_write = ccast( Code, access_private );
access_private_write = make_code();
access_private_write->Type = ECode::Access_Private;
access_private_write->Name = get_cached_string( StrC::from("private") );
access_private_write->Name = get_cached_string( StrC::from("private:") );
access_private_write.lock();
Code&
access_protected_write = ccast( Code, access_protected );
access_protected_write = make_code();
access_protected_write->Type = ECode::Access_Protected;
access_protected_write->Name = get_cached_string( StrC::from("protected") );
access_protected_write->Name = get_cached_string( StrC::from("protected:") );
access_protected_write.lock();
Code&
access_public_write = ccast( Code, access_public );
access_public_write = make_code();
access_public_write->Type = ECode::Access_Public;
access_public_write->Name = get_cached_string( StrC::from("public") );
access_public_write->Name = get_cached_string( StrC::from("public:") );
access_public_write.lock();
module_global_fragment = make_code();
@ -2088,12 +2088,13 @@ namespace gen
switch ( body->Type )
{
case Function_Body:
case Execution:
case Untyped:
break;
default:
{
log_failure("gen::def_function: body must be either of Function_Body or Untyped type. %s", body->debug_str());
log_failure("gen::def_function: body must be either of Function_Body, Execution, or Untyped type. %s", body->debug_str());
return Code::Invalid;
}
}
@ -2193,12 +2194,6 @@ namespace gen
{
using namespace ECode;
if ( body && body->Type != Function_Body && body->Type != Untyped )
{
log_failure( "gen::def_operator: Body was provided but its not of function body type: %s", body->debug_str() );
return Code::Invalid;
}
if ( attributes && attributes->Type != Attributes )
{
log_failure( "gen::def_operator: Attributes was provided but its not of attributes type: %s", attributes->debug_str() );
@ -2227,6 +2222,20 @@ namespace gen
if ( body )
{
switch ( body->Type )
{
case Function_Body:
case Execution:
case Untyped:
break;
default:
{
log_failure("gen::def_operator: body must be either of Function_Body, Execution, or Untyped type. %s", body->debug_str());
return Code::Invalid;
}
}
result->Type = check_result == OpValidateResult::Global ?
Operator : Operator_Member;
@ -5270,7 +5279,10 @@ namespace gen
tokmap_clear( & tok_map );
return buf_size - remaining;
sw result = buf_size - remaining;
// buf[ result ] = '\0';
return result;
}
Code untyped_str( StrC content )

View File

@ -866,6 +866,7 @@ namespace gen
{
local_persist thread_local
char buf[ZPL_PRINTF_MAXLEN] = { 0 };
mem_set( buf, 0, ZPL_PRINTF_MAXLEN );
va_list va;
va_start(va, fmt);
@ -1014,11 +1015,7 @@ namespace gen
# define name( Id_ ) { txt_n_len( Id_ ) }
// Same as name just used to indicate intention of literal for code instead of names.
# define code( Code_ ) { txt_n_len( Code_ ) }
# define code_args( num, ... ) num, (Code[num]){ __VA_ARGS__ }
# define enum_entry( id ) "\t" #id ",\n"
# define code( ... ) { txt_n_len( __VA_ARGS__ ) }
#pragma endregion Macros
#pragma region Constants
@ -1027,6 +1024,8 @@ namespace gen
{
// Predefined typename codes. Are set to readonly and are setup during gen::init()
extern Code type_ns( b32 );
extern Code type_ns( s8 );
extern Code type_ns( s16 );
extern Code type_ns( s32 );