X-Git-Url: http://git.subgeniuskitty.com/pforth/.git/blobdiff_plain/b3ad2602f4c6a2236081ed2d913d4e03892182a6..4f2379351847bdadd3fa6ff698dc381c6bee5bea:/csrc/pf_core.c diff --git a/csrc/pf_core.c b/csrc/pf_core.c index 41fa5f7..19e75a8 100644 --- a/csrc/pf_core.c +++ b/csrc/pf_core.c @@ -92,7 +92,6 @@ static void pfInit( void ) gVarEcho = 0; /* Echo input. */ gVarTraceLevel = 0; /* Trace Level for Inner Interpreter. */ gVarTraceFlags = 0; /* Enable various internal debug messages. */ - gVarQuiet = 0; /* Suppress unnecessary messages, OK, etc. */ gVarReturnCode = 0; /* Returned to caller of Forth, eg. UNIX shell. */ gIncludeIndex = 0; @@ -224,32 +223,32 @@ PForthDictionary pfCreateDictionary( cell_t HeaderSize, cell_t CodeSize ) * to (ucell_t) on 16 bit systems. */ #define DIC_ALIGNMENT_SIZE ((ucell_t)(0x10)) -#define DIC_ALIGN(addr) ((uint8_t *)((((ucell_t)(addr)) + DIC_ALIGNMENT_SIZE - 1) & ~(DIC_ALIGNMENT_SIZE - 1))) +#define DIC_ALIGN(addr) ((((ucell_t)(addr)) + DIC_ALIGNMENT_SIZE - 1) & ~(DIC_ALIGNMENT_SIZE - 1)) /* Allocate memory for header. */ if( HeaderSize > 0 ) { - dic->dic_HeaderBaseUnaligned = ( uint8_t * ) pfAllocMem( (ucell_t) HeaderSize + DIC_ALIGNMENT_SIZE ); + dic->dic_HeaderBaseUnaligned = (ucell_t) pfAllocMem( (ucell_t) HeaderSize + DIC_ALIGNMENT_SIZE ); if( !dic->dic_HeaderBaseUnaligned ) goto nomem; /* Align header base. */ dic->dic_HeaderBase = DIC_ALIGN(dic->dic_HeaderBaseUnaligned); - pfSetMemory( dic->dic_HeaderBase, 0xA5, (ucell_t) HeaderSize); + pfSetMemory( (char *) dic->dic_HeaderBase, 0xA5, (ucell_t) HeaderSize); dic->dic_HeaderLimit = dic->dic_HeaderBase + HeaderSize; dic->dic_HeaderPtr = dic->dic_HeaderBase; } else { - dic->dic_HeaderBase = NULL; + dic->dic_HeaderBase = 0; } /* Allocate memory for code. */ - dic->dic_CodeBaseUnaligned = ( uint8_t * ) pfAllocMem( (ucell_t) CodeSize + DIC_ALIGNMENT_SIZE ); + dic->dic_CodeBaseUnaligned = (ucell_t) pfAllocMem( (ucell_t) CodeSize + DIC_ALIGNMENT_SIZE ); if( !dic->dic_CodeBaseUnaligned ) goto nomem; dic->dic_CodeBase = DIC_ALIGN(dic->dic_CodeBaseUnaligned); - pfSetMemory( dic->dic_CodeBase, 0x5A, (ucell_t) CodeSize); + pfSetMemory( (char *) dic->dic_CodeBase, 0x5A, (ucell_t) CodeSize); dic->dic_CodeLimit = dic->dic_CodeBase + CodeSize; - dic->dic_CodePtr.Byte = dic->dic_CodeBase + QUADUP(NUM_PRIMITIVES); + dic->dic_CodePtr.Byte = ((uint8_t *) (dic->dic_CodeBase + QUADUP(NUM_PRIMITIVES))); return (PForthDictionary) dic; nomem: @@ -371,12 +370,11 @@ cell_t pfIncludeFile( const char *FileName ) pfCopyMemory( &buffer[4], &FileName[len-numChars], numChars+1 ); CreateDicEntryC( ID_NOOP, buffer, 0 ); - Result = ffIncludeFile( fid ); + Result = ffIncludeFile( fid ); /* Also close the file. */ /* Create a dictionary word named ;;;; for FILE? */ CreateDicEntryC( ID_NOOP, ";;;;", 0 ); - sdCloseFile(fid); return Result; } @@ -451,7 +449,7 @@ cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit { pfSetCurrentTask( cftd ); - if( !pfQueryQuiet() ) + if( !gVarQuiet ) { MSG( "PForth V"PFORTH_VERSION ); if( IsHostLittleEndian() ) MSG("-LE"); @@ -498,19 +496,29 @@ cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit if( DicFileName ) { pfDebugMessage("DicFileName = "); pfDebugMessage(DicFileName); pfDebugMessage("\n"); - EMIT_CR; + if( !gVarQuiet ) + { + EMIT_CR; + } dic = pfLoadDictionary( DicFileName, &EntryPoint ); } else { - MSG(" (static)"); - EMIT_CR; + if( !gVarQuiet ) + { + MSG(" (static)"); + EMIT_CR; + } dic = pfLoadStaticDictionary(); } } if( dic == NULL ) goto error2; - EMIT_CR; - + + if( !gVarQuiet ) + { + EMIT_CR; + } + pfDebugMessage("pfDoForth: try AUTO.INIT\n"); Result = pfExecIfDefined("AUTO.INIT"); if( Result != 0 ) @@ -561,7 +569,7 @@ cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit error2: MSG("pfDoForth: Error occured.\n"); pfDeleteTask( cftd ); - // Terminate so we restore normal shell tty mode. + /* Terminate so we restore normal shell tty mode. */ pfTerm(); #ifdef PF_USER_INIT @@ -570,3 +578,13 @@ error1: return -1; } + + +#ifdef PF_UNIT_TEST +cell_t pfUnitTest( void ) +{ + cell_t numErrors = 0; + numErrors += pfUnitTestText(); + return numErrors; +} +#endif