Beispiel #1
0
/*
 * f i c l - w o r d l i s t
 * SEARCH ( -- wid )
 * Create a new empty word list, returning its word list identifier wid.
 * The new word list may be returned from a pool of preallocated word
 * lists or may be dynamically allocated in data space. A system shall
 * allow the creation of at least 8 new word lists in addition to any
 * provided as part of the system.
 * Notes:
 * 1. Ficl creates a new single-list hash in the dictionary and returns
 *    its address.
 * 2. ficl-wordlist takes an arg off the stack indicating the number of
 *    hash entries in the wordlist. Ficl 2.02 and later define WORDLIST as
 *    : wordlist 1 ficl-wordlist ;
 */
static void
ficlPrimitiveFiclWordlist(ficlVm *vm)
{
	ficlDictionary *dictionary = ficlVmGetDictionary(vm);
	ficlHash *hash;
	ficlUnsigned nBuckets;

	FICL_STACK_CHECK(vm->dataStack, 1, 1);

	nBuckets = ficlStackPopUnsigned(vm->dataStack);
	hash = ficlDictionaryCreateWordlist(dictionary, nBuckets);
	ficlStackPushPointer(vm->dataStack, hash);
}
Beispiel #2
0
/**************************************************************************
                        f i c l C o m p i l e P r e f i x
** Build prefix support into the dictionary and the parser
** Note: since prefixes always execute, they are effectively IMMEDIATE.
** If they need to generate code in compile state you must add
** this code explicitly.
**************************************************************************/
void ficlSystemCompilePrefix(ficlSystem *system)
{
    ficlDictionary *dictionary = system->dictionary;
    ficlHash *hash;
    
    /*
    ** Create a named wordlist for prefixes to reside in...
    ** Since we're doing a special kind of search, make it
    ** a single bucket hashtable - hashing does not help here.
    */
    hash = ficlDictionaryCreateWordlist(dictionary, 1);
    hash->name = list_name;
    ficlDictionaryAppendConstantPointer(dictionary, list_name, hash);

    /*
    ** Put __tempbase in the forth-wordlist
    */
    ficlDictionarySetPrimitive(dictionary, "__tempbase", ficlPrimitiveTempBase, FICL_WORD_DEFAULT);

    /*
    ** If you want to add some prefixes at compilation-time, copy this line to the top of this function:
    **
    ficlHash *oldCompilationWordlist;

    **
    ** then copy this code to the bottom, just above the return:
    **

    oldCompilationWordlist = dictionary->compilationWordlist;
    dictionary->compilationWordlist = hash;
    ficlDictionarySetPrimitive(dictionary, YOUR WORD HERE, FICL_WORD_DEFAULT);
    dictionary->compilationWordlist = oldCompilationWordlist;

    **
    ** and substitute in your own actual calls to ficlDictionarySetPrimitive() as needed.
    **
    ** Or--better yet--do it in your own code, so you don't have to re-modify the Ficl
    ** source code every time we cut a new release!
    */

    return;
}
Beispiel #3
0
FICL_PLATFORM_EXTERN ficlHash  *dictCreateWordlist(ficlDictionary *dictionary, int nBuckets) { return ficlDictionaryCreateWordlist(dictionary, nBuckets); }