-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wordlists #5
Open
vuokko
wants to merge
12
commits into
philburk:master
Choose a base branch
from
vuokko:wordlists
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Wordlists #5
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8537f5b
supress biary objects
vuokko b0f10cb
more binaries
vuokko 0dd201e
First version of wordlists and search order
vuokko a306979
Cosmetic changes
vuokko 51ed40e
IT WORKS. About...
vuokko c0afc73
bugfixes
vuokko c954699
FORGET WORDS
vuokko 9fc8639
Makefile devchanges...
vuokko b36ee82
BUGFIX: Auto.term ran auto.init
vuokko bbce831
Should work
vuokko e35c3a5
Test set fix for non WL compilation
vuokko 07dfd0e
Word list avare FORGET and MARKER tst cases
vuokko File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.eo | ||
*.o | ||
pfdicdat.h | ||
pforth | ||
pforth.dic | ||
pforth_standalone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* @(#) search.c 15/04/09 1.0 */ | ||
/*************************************************************** | ||
** search order for PForth based on 'C' | ||
** | ||
** Author: Hannu Vuolasaho | ||
** Copyright 2015 3DO, Phil Burk, Larry Polansky, David Rosenboom | ||
** | ||
** The pForth software code is dedicated to the public domain, | ||
** and any third party may reproduce, distribute and modify | ||
** the pForth software code or any derivative works thereof | ||
** without any compensation or license. The pForth software | ||
** code is provided on an "as is" basis without any warranty | ||
** of any kind, including, without limitation, the implied | ||
** warranties of merchantability and fitness for a particular | ||
** purpose and their equivalents under the laws of any jurisdiction. | ||
**/ | ||
#include "pf_all.h" | ||
#ifdef PF_SUPPORT_WORDLIST | ||
|
||
/* Search order and word list arrays */ | ||
cell_t arrSearchOrder; | ||
|
||
/* global search order start index. points wl.order.first on forth. */ | ||
cell_t gVarWlOrderFirst; | ||
cell_t gVarWordLists; | ||
/* gVarWlCompileIndex is gVarWordLists[compilationIdnex], head of comp. list. */ | ||
cell_t gVarWlCompileIndex; | ||
|
||
|
||
|
||
/* (init-wordlists) ( search_addr search_index wl_addr comp_index -- ) */ | ||
void ffInitWordLists( cell_t search_addr, cell_t search_index, | ||
cell_t wl_addr, cell_t comp_index ) | ||
{ | ||
gVarWlCompileIndex = comp_index; | ||
gVarWordLists = wl_addr; | ||
gVarWlOrderFirst = search_index; | ||
arrSearchOrder = search_addr; | ||
/* Debug Stuff. remove. | ||
MSG_NUM_D("comp ind ", gVarWlCompileIndex); | ||
MSG_NUM_D("comp ind * ", *(cell_t *)gVarWlCompileIndex); | ||
MSG_NUM_D("wl ", gVarWordLists ); | ||
MSG_NUM_D("wl * ", *(cell_t *)gVarWordLists ); | ||
MSG_NUM_D("wl * * ", *(cell_t *)(*(cell_t *)gVarWordLists)); | ||
MSG_NUM_D("wl+1 * * ", *(cell_t *)(*(cell_t *)gVarWordLists+1)); | ||
MSG_NUM_D("first ", gVarWlOrderFirst); | ||
MSG_NUM_D("first * ", *(cell_t *) gVarWlOrderFirst); | ||
MSG_NUM_D("order ", arrSearchOrder); | ||
MSG_NUM_D("order * ", *(cell_t *)arrSearchOrder); | ||
MSG_NUM_D("order name * ", NAMEREL_TO_ABS((*(cell_t *)arrSearchOrder))); | ||
MSG_NUM_D("order code * ", CODEREL_TO_ABS((*(cell_t *)arrSearchOrder))); | ||
MSG_NUM_D("order code * * ", *(cell_t *)(CODEREL_TO_ABS((*(cell_t *)arrSearchOrder)))); | ||
*/ | ||
} | ||
cell_t getWordList( cell_t index ) | ||
{ | ||
cell_t temp_addr, *tmp_arr; | ||
if(gVarWordLists) | ||
{ | ||
/* Don't underflow search */ | ||
if( index < 0 ) return (cell_t) NULL; | ||
/* Address to wordlist */ | ||
tmp_arr = (cell_t *) arrSearchOrder; | ||
temp_addr = tmp_arr[index]; | ||
if(temp_addr) | ||
{ | ||
temp_addr = CODEREL_TO_ABS(temp_addr); | ||
return *(cell_t *)temp_addr; | ||
} | ||
else | ||
{ | ||
/* Empty wordlist in search order */ | ||
return (cell_t) NULL; | ||
} | ||
} | ||
else | ||
{ | ||
return gVarContext; | ||
} | ||
} | ||
|
||
/* This should be written in forth */ | ||
/* search-wordlist ( c-addr u wid -- 0 | xt 1 | xt -1 ) */ | ||
cell_t ffSearchWordList( cell_t c_addr, cell_t u, cell_t wid) | ||
{ | ||
cell_t Searching = TRUE; | ||
cell_t Result = 0; | ||
uint8_t NameLen; | ||
const char *NameField; | ||
|
||
if( wid == 0 || !(*((cell_t *) (CODEREL_TO_ABS(wid))) )) return 0; | ||
/* wid is code relative address of wordlists | ||
* referencing give content of gVarContext of | ||
* compilation time of last word in word list*/ | ||
NameField = (ForthString *) *((cell_t *) (CODEREL_TO_ABS(wid)) ); | ||
do | ||
{ | ||
NameLen = (uint8_t) ((ucell_t)(*NameField) & MASK_NAME_SIZE); | ||
if( ((*NameField & FLAG_SMUDGE) == 0) && | ||
(NameLen == u) && | ||
ffCompareTextCaseN( NameField +1, (const char *) c_addr, u ) ) | ||
{ | ||
PUSH_DATA_STACK(NameToToken(NameField)); /* XT to stack */ | ||
Result = ((*NameField) & FLAG_IMMEDIATE) ? 1 : -1; | ||
Searching = FALSE; | ||
} | ||
else | ||
{ | ||
NameField = NameToPrevious( NameField ); | ||
if( NameField == NULL ) | ||
{ | ||
Searching = FALSE; | ||
} | ||
} | ||
}while(Searching); | ||
return Result; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* @(#) search.h 15/04/09 1.0 */ | ||
#ifndef _pf_search_h | ||
#define _pf_search_h | ||
/*************************************************************** | ||
** search order for PForth based on 'C' | ||
** | ||
** Author: Hannu Vuolasaho | ||
** Copyright 2015 3DO, Phil Burk, Larry Polansky, David Rosenboom | ||
** | ||
** The pForth software code is dedicated to the public domain, | ||
** and any third party may reproduce, distribute and modify | ||
** the pForth software code or any derivative works thereof | ||
** without any compensation or license. The pForth software | ||
** code is provided on an "as is" basis without any warranty | ||
** of any kind, including, without limitation, the implied | ||
** warranties of merchantability and fitness for a particular | ||
** purpose and their equivalents under the laws of any jurisdiction. | ||
**/ | ||
|
||
#ifdef PF_SUPPORT_WORDLIST | ||
#define PF_WORDLIST_EXPORT_FUNCTIONS (2) | ||
|
||
/* Search order and word list arrays */ | ||
|
||
extern cell_t gVarWlOrderFirst; | ||
extern cell_t gVarWordLists; | ||
|
||
/* compilationIndex is gVarWordLists[compilationIdnex], head of comp. list. */ | ||
extern cell_t gVarWlCompileIndex; | ||
|
||
/* (init-wordlists) ( search_addr search_index wl_addr comp_index -- ) */ | ||
void ffInitWordLists( cell_t search_addr, cell_t search_index, | ||
cell_t wl_addr, cell_t comp_index ); | ||
/* search-wordlist ( c-addr u wid -- 0 | xt 1 | xt -1 ) */ | ||
cell_t ffSearchWordList( cell_t c_addr, cell_t u, cell_t wid); | ||
|
||
/* Helper function. | ||
* Get the head of wordlist in search order index 'index' */ | ||
cell_t getWordList( cell_t index ); | ||
|
||
#else | ||
#define PF_WORDLIST_EXPORT_FUNCTIONS (0) | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,11 +35,11 @@ | |
void pfReportError( const char *FunctionName, Err ErrCode ) | ||
{ | ||
const char *s; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These white space errors have all been fixed. |
||
MSG("Error in "); | ||
MSG(FunctionName); | ||
MSG(" - "); | ||
|
||
switch(ErrCode & 0xFF) | ||
{ | ||
case PF_ERR_NO_MEM & 0xFF: | ||
|
@@ -107,6 +107,12 @@ void pfReportThrow( ThrowCode code ) | |
s = "Executing a compile-only word!"; break; | ||
case THROW_FLOAT_STACK_UNDERFLOW: | ||
s = "Float Stack underflow!"; break; | ||
#ifdef PF_SUPPORT_WORDLIST | ||
case THROW_SEARCH_OVERFLOW: | ||
s = "Search order or wordlist owerflow!"; break; | ||
case THROW_SEARCH_UNDERFLOW: | ||
s = "Search order or wordlist underflow!"; break; | ||
#endif | ||
case THROW_UNDEFINED_WORD: | ||
s = "Undefined word!"; break; | ||
case THROW_PAIRS: | ||
|
@@ -121,7 +127,7 @@ void pfReportThrow( ThrowCode code ) | |
default: | ||
s = "Unrecognized throw code!"; break; | ||
} | ||
|
||
if( s ) | ||
{ | ||
MSG_NUM_D("THROW code = ", code ); | ||
|
@@ -178,7 +184,7 @@ char *CStringToForth( char *dst, const char *CString, cell_t dstSize ) | |
cell_t ffCompareText( const char *s1, const char *s2, cell_t len ) | ||
{ | ||
cell_t i, Result; | ||
|
||
Result = TRUE; | ||
for( i=0; i<len; i++ ) | ||
{ | ||
|
@@ -201,7 +207,7 @@ cell_t ffCompareTextCaseN( const char *s1, const char *s2, cell_t len ) | |
{ | ||
cell_t i, Result; | ||
char c1,c2; | ||
|
||
Result = TRUE; | ||
for( i=0; i<len; i++ ) | ||
{ | ||
|
@@ -225,7 +231,7 @@ DBUGX(("ffCompareText: return 0x%x\n", Result )); | |
cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 ) | ||
{ | ||
cell_t i, result, n, diff; | ||
|
||
result = 0; | ||
n = MIN(len1,len2); | ||
for( i=0; i<n; i++ ) | ||
|
@@ -262,7 +268,7 @@ char *ConvertNumberToText( cell_t Num, cell_t Base, int32_t IfSigned, int32_t Mi | |
char *p,c; | ||
ucell_t NewNum, Rem, uNum; | ||
cell_t i = 0; | ||
|
||
uNum = Num; | ||
if( IfSigned ) | ||
{ | ||
|
@@ -273,11 +279,11 @@ char *ConvertNumberToText( cell_t Num, cell_t Base, int32_t IfSigned, int32_t Mi | |
uNum = -Num; | ||
} | ||
} | ||
|
||
/* Point past end of Pad */ | ||
p = cnttPad + CNTT_PAD_SIZE; | ||
*(--p) = (char) 0; /* NUL terminate */ | ||
|
||
while( (i++<MinChars) || (uNum != 0) ) | ||
{ | ||
NewNum = uNum / Base; | ||
|
@@ -286,7 +292,7 @@ char *ConvertNumberToText( cell_t Num, cell_t Base, int32_t IfSigned, int32_t Mi | |
*(--p) = c; | ||
uNum = NewNum; | ||
} | ||
|
||
if( IfSigned ) | ||
{ | ||
if( IfNegative ) *(--p) = '-'; | ||
|
@@ -307,7 +313,7 @@ void DumpMemory( void *addr, cell_t cnt) | |
ptr = (unsigned char *) addr; | ||
|
||
EMIT_CR; | ||
|
||
for (ln=0; ln<nlines; ln++) | ||
{ | ||
MSG( ConvertNumberToText( (cell_t) ptr, 16, FALSE, 8 ) ); | ||
|
@@ -335,10 +341,10 @@ void TypeName( const char *Name ) | |
{ | ||
const char *FirstChar; | ||
cell_t Len; | ||
|
||
FirstChar = Name+1; | ||
Len = *Name & 0x1F; | ||
|
||
ioType( FirstChar, Len ); | ||
} | ||
|
||
|
@@ -365,43 +371,43 @@ cell_t pfUnitTestText( void ) | |
ASSERT_PAD_IS( 0, 4, "CS len 6" ); | ||
ASSERT_PAD_IS( 4, 'g', "CS end 6" ); | ||
ASSERT_PAD_IS( 5, 0xA5, "CS past 6" ); | ||
|
||
pfSetMemory(pad,0xA5,sizeof(pad)); | ||
CStringToForth( pad, "frog", 5 ); | ||
ASSERT_PAD_IS( 0, 4, "CS len 5" ); | ||
ASSERT_PAD_IS( 4, 'g', "CS end 5" ); | ||
ASSERT_PAD_IS( 5, 0xA5, "CS past 5" ); | ||
|
||
pfSetMemory(pad,0xA5,sizeof(pad)); | ||
CStringToForth( pad, "frog", 4 ); | ||
ASSERT_PAD_IS( 0, 3, "CS len 4" ); | ||
ASSERT_PAD_IS( 3, 'o', "CS end 4" ); | ||
ASSERT_PAD_IS( 4, 0xA5, "CS past 4" ); | ||
|
||
/* Make a Forth string for testing ForthStringToC. */ | ||
CStringToForth( fpad, "frog", sizeof(fpad) ); | ||
|
||
pfSetMemory(pad,0xA5,sizeof(pad)); | ||
ForthStringToC( pad, fpad, 6 ); | ||
ASSERT_PAD_IS( 0, 'f', "FS len 6" ); | ||
ASSERT_PAD_IS( 3, 'g', "FS end 6" ); | ||
ASSERT_PAD_IS( 4, 0, "FS nul 6" ); | ||
ASSERT_PAD_IS( 5, 0xA5, "FS past 6" ); | ||
|
||
pfSetMemory(pad,0xA5,sizeof(pad)); | ||
ForthStringToC( pad, fpad, 5 ); | ||
ASSERT_PAD_IS( 0, 'f', "FS len 5" ); | ||
ASSERT_PAD_IS( 3, 'g', "FS end 5" ); | ||
ASSERT_PAD_IS( 4, 0, "FS nul 5" ); | ||
ASSERT_PAD_IS( 5, 0xA5, "FS past 5" ); | ||
|
||
pfSetMemory(pad,0xA5,sizeof(pad)); | ||
ForthStringToC( pad, fpad, 4 ); | ||
ASSERT_PAD_IS( 0, 'f', "FS len 4" ); | ||
ASSERT_PAD_IS( 2, 'o', "FS end 4" ); | ||
ASSERT_PAD_IS( 3, 0, "FS nul 4" ); | ||
ASSERT_PAD_IS( 4, 0xA5, "FS past 4" ); | ||
|
||
return numErrors; | ||
} | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be written in Forth? Is something in pForth preventing that?