diff --git a/stix/kernel/test-010.st b/stix/kernel/test-010.st index 3f5fb68..fcce120 100644 --- a/stix/kernel/test-010.st +++ b/stix/kernel/test-010.st @@ -49,6 +49,11 @@ } } +#pooldic ABC +{ + #KKK := 20. +} + #class MyObject(TestObject) { @@ -92,6 +97,7 @@ s1 wait. + ABC.KKK dump. 'END OF MAIN' dump. @@ -183,3 +189,4 @@ ] } } + diff --git a/stix/lib/comp.c b/stix/lib/comp.c index 7703feb..bcbe064 100644 --- a/stix/lib/comp.c +++ b/stix/lib/comp.c @@ -4545,9 +4545,15 @@ static int __compile_class_definition (stix_t* stix, int extend) { int super_is_nil = 0; -printf ("DEFININING CLASS "); -print_oocs (&stix->c->cls.name); -printf ("\n"); + if (STIX_LOG_ENABLED(stix,STIX_LOG_COMPILER | STIX_LOG_DEBUG)) + { + 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) { /* superclass is specified. new class defintion. @@ -4820,9 +4826,14 @@ static int __compile_pooldic_definition (stix_t* stix) return -1; } -printf ("DEFININING POOL DICTIONARY "); -print_oocs (&stix->c->cls.name); -printf ("\n"); + if (STIX_LOG_ENABLED(stix,STIX_LOG_COMPILER | STIX_LOG_DEBUG)) + { + 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); diff --git a/stix/lib/logfmt.c b/stix/lib/logfmt.c index fa4da61..6924405 100644 --- a/stix/lib/logfmt.c +++ b/stix/lib/logfmt.c @@ -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' }; typedef int (*stix_fmtout_putch_t) ( - stix_t* stix, - int mask, - stix_ooch_t c, - stix_oow_t len + stix_t* stix, + unsigned int mask, + stix_ooch_t c, + stix_oow_t len ); typedef int (*stix_fmtout_putcs_t) ( stix_t* stix, - int mask, + unsigned int mask, const stix_ooch_t* ptr, 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; } +redo: if (len > stix->log.capa - stix->log.len) { 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 */ 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.capa = newcapa; diff --git a/stix/lib/stix.h b/stix/lib/stix.h index 50e275e..1d2d9c1 100644 --- a/stix/lib/stix.h +++ b/stix/lib/stix.h @@ -906,9 +906,15 @@ enum 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) extern "C" { #endif