@ -113,7 +113,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
call :
if ( ! w ) { return FH_ERR_INTERNAL ; }
LOG ( " Run user word: %s " , w - > name ) ;
LOG ( " \x1b [35mExec: Called user word: %s \x1b [m " , w - > name ) ;
TRY ( rs_push ( fh , fh - > execptr ) ) ;
fh - > execptr = w - > param ;
@ -167,7 +167,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
// TRY(rs_pop(fh, &fh->execptr));
// }
} else {
LOG ( " Add postponed word: %s" , w2 - > name ) ;
LOG ( " \x1b [35mExec: Add postponed word \x1b [m %s" , w2 - > name ) ;
TRY ( fh_put_instr ( fh , FH_INSTR_WORD , instr - > data ) ) ;
}
/*} else {
@ -184,7 +184,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
}
call_w2 :
if ( w2 - > flags & WORDFLAG_BUILTIN ) {
LOG ( " Exec: native-word \" %s \" " , w2 - > name ) ;
LOG ( " \x1b [35m Exec: native-word \" %s \" \x1b [m " , w2 - > name ) ;
TRY ( w2 - > handler ( fh , w2 ) ) ;
if ( fh - > substate = = FH_SUBSTATE_EXIT ) {
fh_setsubstate ( fh , 0 ) ;
@ -196,7 +196,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
}
goto instr ;
} else {
LOG ( " Exec: user-word %s (CALL) " , w2 - > name ) ;
LOG ( " \x1b [35m Exec: user-word %s\x1b [m (CALL)" , w2 - > name ) ;
w = fh_word_at ( fh , instr - > data ) ;
if ( ! w ) {
LOGE ( " CALL instr bad word addr! " ) ;
@ -206,6 +206,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
}
case FH_INSTR_JUMPZERO :
LOG ( " \x1b [35mExec: jump if zero -> 0x%08x \x1b [m " , instr - > data ) ;
if ( instr - > data = = MAGICADDR_UNRESOLVED ) {
LOGE ( " Encountered unresolved jump! " ) ;
goto end ;
@ -213,11 +214,15 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
TRY ( ds_pop ( fh , & val ) ) ;
if ( 0 = = val ) {
LOG ( " Jumping " ) ;
fh - > execptr = instr - > data ;
} else {
LOG ( " No jump " ) ;
}
goto instr ;
case FH_INSTR_JUMP :
LOG ( " \x1b [35mExec: jump -> 0x%08x \x1b [m " , instr - > data ) ;
if ( instr - > data = = MAGICADDR_UNRESOLVED ) {
LOGE ( " Encountered unresolved jump! " ) ;
goto end ;
@ -232,7 +237,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
LOGE ( " TO instr bad variable addr! " ) ;
return FH_ERR_INTERNAL ;
}
LOG ( " Exec: %d->%s " , val , w2 - > name ) ;
LOG ( " \x1b [35mExec: %d TO %s \x1b [m " , val , w2 - > name ) ;
if ( w2 - > flags & WORDFLAG_CONSTANT ) {
LOGE ( " Cannot assign to constant! " ) ;
@ -243,6 +248,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
goto instr ;
case FH_INSTR_DO :
LOG ( " \x1b [35mExec: do \x1b [m " ) ;
TRY ( ds_pop ( fh , & index ) ) ;
TRY ( ds_pop ( fh , & limit ) ) ; // just make sure it exists
TRY ( fh_loop_nest ( fh , index ) ) ;
@ -250,6 +256,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
goto instr ;
case FH_INSTR_DO_QUESTION :
LOG ( " \x1b [35mExec: ?do \x1b [m " ) ;
if ( instr - > data = = MAGICADDR_UNRESOLVED ) {
LOGE ( " Encountered unresolved jump! " ) ;
goto end ;
@ -277,7 +284,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
// R: index,limit
TRY ( rs_peek ( fh , & limit ) ) ;
LOG ( " +LOOP, i=%d, step %d, limit %d " , fh - > loop_i , val , limit ) ;
LOG ( " \x1b [35mExec: +LOOP\x1b [m , i=%d, step %d, limit %d" , fh - > loop_i , val , limit ) ;
const int32_t vi = ( int32_t ) val ;
const int32_t bdr = ( int32_t ) limit - ( int32_t ) 1 ;
@ -304,6 +311,7 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
goto instr ;
case FH_INSTR_LEAVE :
LOG ( " \x1b [35mExec: leave \x1b [m " ) ;
if ( instr - > data = = MAGICADDR_UNRESOLVED ) {
LOGE ( " Encountered unresolved jump! " ) ;
goto end ;
@ -318,18 +326,18 @@ enum fh_error w_user_word(struct fh_thread_s *fh, const struct fh_word_s *w0)
case FH_INSTR_TYPESTR :
strl = instr - > data ;
if ( instr - > kind = = FH_INSTR_ALLOCSTR ) {
LOG ( " Exec: alloc-str \" %.*s \" " , strl , fh_str_at ( fh , fh - > execptr ) ) ;
LOG ( " \x1b [35m Exec: alloc-str\x1b [m \" %.*s \" " , strl , fh_str_at ( fh , fh - > execptr ) ) ;
TRY ( ds_push ( fh , fh - > execptr ) ) ; // give pointer directly into the definition
TRY ( ds_push ( fh , strl ) ) ;
} else {
LOG ( " Exec: type-str \" %.*s \" " , strl , fh_str_at ( fh , fh - > execptr ) ) ;
LOG ( " \x1b [35m Exec: type-str\x1b [m \" %.*s \" " , strl , fh_str_at ( fh , fh - > execptr ) ) ;
FHPRINT ( " %.*s " , ( int ) strl , fh_str_at ( fh , fh - > execptr ) ) ;
}
fh - > execptr + = strl ;
goto instr ;
case FH_INSTR_ENDWORD :
LOG ( " Exec: word-end " ) ;
LOG ( " \x1b [35m Exec: word-end\x1b [m " ) ;
TRY ( rs_pop ( fh , & fh - > execptr ) ) ;
if ( fh - > execptr = = MAGICADDR_EXEC_INTERACTIVE ) {
LOG ( " Done running compiled word " ) ;