improved log message handling more

This commit is contained in:
hyunghwan.chung 2016-06-03 16:16:23 +00:00
parent eeb2fdebbd
commit f43240ca4d
4 changed files with 48 additions and 13 deletions

View File

@ -49,6 +49,11 @@
} }
} }
#pooldic ABC
{
#KKK := 20.
}
#class MyObject(TestObject) #class MyObject(TestObject)
{ {
@ -92,6 +97,7 @@
s1 wait. s1 wait.
ABC.KKK dump.
'END OF MAIN' dump. 'END OF MAIN' dump.
@ -183,3 +189,4 @@
] ]
} }
} }

View File

@ -4545,9 +4545,15 @@ static int __compile_class_definition (stix_t* stix, int extend)
{ {
int super_is_nil = 0; int super_is_nil = 0;
printf ("DEFININING CLASS "); if (STIX_LOG_ENABLED(stix,STIX_LOG_COMPILER | STIX_LOG_DEBUG))
print_oocs (&stix->c->cls.name); {
printf ("\n"); stix_logbfmt (stix,
STIX_LOG_COMPILER | STIX_LOG_DEBUG,
"Defining a class %.*S\n",
stix->c->cls.fqn.len,
stix->c->cls.fqn.ptr);
}
if (stix->c->tok.type == STIX_IOTOK_LPAREN) if (stix->c->tok.type == STIX_IOTOK_LPAREN)
{ {
/* superclass is specified. new class defintion. /* superclass is specified. new class defintion.
@ -4820,9 +4826,14 @@ static int __compile_pooldic_definition (stix_t* stix)
return -1; return -1;
} }
printf ("DEFININING POOL DICTIONARY "); if (STIX_LOG_ENABLED(stix,STIX_LOG_COMPILER | STIX_LOG_DEBUG))
print_oocs (&stix->c->cls.name); {
printf ("\n"); stix_logbfmt (stix,
STIX_LOG_COMPILER | STIX_LOG_DEBUG,
"Defining a pool dictionary %.*S\n",
stix->c->cls.fqn.len,
stix->c->cls.fqn.ptr);
}
GET_TOKEN (stix); GET_TOKEN (stix);

View File

@ -130,15 +130,15 @@ static stix_ooch_t ooch_nullstr[] = { '(','n','u','l','l', ')','\0' };
static stix_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' }; static stix_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' };
typedef int (*stix_fmtout_putch_t) ( typedef int (*stix_fmtout_putch_t) (
stix_t* stix, stix_t* stix,
int mask, unsigned int mask,
stix_ooch_t c, stix_ooch_t c,
stix_oow_t len stix_oow_t len
); );
typedef int (*stix_fmtout_putcs_t) ( typedef int (*stix_fmtout_putcs_t) (
stix_t* stix, stix_t* stix,
int mask, unsigned int mask,
const stix_ooch_t* ptr, const stix_ooch_t* ptr,
stix_oow_t len stix_oow_t len
); );
@ -196,6 +196,7 @@ static int put_ooch (stix_t* stix, unsigned int mask, stix_ooch_t ch, stix_oow_t
stix->log.len = 0; stix->log.len = 0;
} }
redo:
if (len > stix->log.capa - stix->log.len) if (len > stix->log.capa - stix->log.len)
{ {
stix_oow_t newcapa; stix_oow_t newcapa;
@ -210,7 +211,17 @@ static int put_ooch (stix_t* stix, unsigned int mask, stix_ooch_t ch, stix_oow_t
newcapa = STIX_ALIGN(stix->log.len + len, 512); /* TODO: adjust this capacity */ newcapa = STIX_ALIGN(stix->log.len + len, 512); /* TODO: adjust this capacity */
tmp = stix_reallocmem (stix, stix->log.ptr, newcapa * STIX_SIZEOF(*tmp)); tmp = stix_reallocmem (stix, stix->log.ptr, newcapa * STIX_SIZEOF(*tmp));
if (!tmp) return -1; if (!tmp)
{
if (stix->log.len > 0)
{
/* can't expand the buffer. just flush the existing contents */
stix->vmprim.log_write (stix, stix->log.last_mask, stix->log.ptr, stix->log.len);
stix->log.len = 0;
goto redo;
}
return -1;
}
stix->log.ptr = tmp; stix->log.ptr = tmp;
stix->log.capa = newcapa; stix->log.capa = newcapa;

View File

@ -906,9 +906,15 @@ enum stix_log_mask_t
}; };
typedef enum stix_log_mask_t stix_log_mask_t; typedef enum stix_log_mask_t stix_log_mask_t;
#define STIX_LOG_ENABLED(stix,mask) ((stix)->option.log_mask & mask) #define STIX_LOG_ENABLED(stix,mask) ((stix)->option.log_mask & (mask))
/*
#define STIX_DEBUG0(stix,fmt) if (STIX_LOG_ENABLED(stix,STIX_LOG_DEBUG)) stix_logbfmt(stix, STIX_LOG_DEBUG, fmt)
#define STIX_DEBUG1(stix,fmt,a1)
#define STIX_DEBUG2(stix,fmt,a1,a2)
*/
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif