Beispiel #1
0
ficlWord *
ficlDictionarySetInstruction(ficlDictionary *dictionary, char *name,
    ficlInstruction i, ficlUnsigned8 flags)
{
	return (ficlDictionarySetPrimitive(dictionary, name,
	    (ficlPrimitive)i, (ficlUnsigned8)(FICL_WORD_INSTRUCTION | flags)));
}
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
void ficlSystemCompileExtras(ficlSystem *system)
{
    ficlDictionary *dictionary = ficlSystemGetDictionary(system);

    ficlDictionarySetPrimitive(dictionary, "break",    ficlPrimitiveBreak,    FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "load",     ficlPrimitiveLoad,     FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "spewhash", ficlPrimitiveSpewHash, FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "system",   ficlPrimitiveSystem,   FICL_WORD_DEFAULT);

#ifndef FICL_ANSI
    ficlDictionarySetPrimitive(dictionary, "clock",    ficlPrimitiveClock,    FICL_WORD_DEFAULT);
    ficlDictionarySetConstant(dictionary, "clocks/sec", CLOCKS_PER_SEC);
    ficlDictionarySetPrimitive(dictionary, "pwd",      ficlPrimitiveGetCwd,   FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "cd",       ficlPrimitiveChDir,    FICL_WORD_DEFAULT);
#endif /* FICL_ANSI */

    return;
}
Beispiel #4
0
void simon_init(ficlVm *vm)
{
  ficlDictionary *dict;
  dict = ficlVmGetDictionary(vm);
  ficlDictionarySetPrimitive(dict,"dcr!",ficl_sysDcrEbcSet,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"dcr@",ficl_sysDcrEbcGet,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"load",ficlPrimitiveLoad,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"load?",ficlPrimitiveLoadQuestion,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"file!",ficlIcatFileWrite,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"pfile!",ficlIcatPFileWrite,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"isfdir",ficlIsfDir,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"isfdel",ficlIsfDel,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"pcp",ficlPcp,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"icat-load",ficlIcatLoad,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"task-delay",ficl_task_delay,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"wait-fifo",ficl_wait_fifo,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"fifo-return-status",ficl_fifo_return_status,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"reboot",ficl_reboot,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"task-spawn",ficl_taskSpawn,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"diag-print",ficl_diagPrint,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"ftw1",ficl_ftw1,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"ftw2",ficl_ftw2,FICL_WORD_DEFAULT);
  ficlDictionarySetPrimitive(dict,"rfswitch",ficl_switch,FICL_WORD_DEFAULT);
  install_fifo_finished();
}
Beispiel #5
0
/*
 * f i c l C o m p i l e S e a r c h
 * Builds the primitive wordset and the environment-query namespace.
 */
void
ficlSystemCompileSearch(ficlSystem *system)
{
	ficlDictionary *dictionary = ficlSystemGetDictionary(system);
	ficlDictionary *environment = ficlSystemGetEnvironment(system);

	FICL_SYSTEM_ASSERT(system, dictionary);
	FICL_SYSTEM_ASSERT(system, environment);

	/*
	 * optional SEARCH-ORDER word set
	 */
	(void) ficlDictionarySetPrimitive(dictionary, ">search",
	    ficlPrimitiveSearchPush, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "search>",
	    ficlPrimitiveSearchPop, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "definitions",
	    ficlPrimitiveDefinitions, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "forth-wordlist",
	    ficlPrimitiveForthWordlist, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "get-current",
	    ficlPrimitiveGetCurrent, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "get-order",
	    ficlPrimitiveGetOrder, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "search-wordlist",
	    ficlPrimitiveSearchWordlist, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "set-current",
	    ficlPrimitiveSetCurrent, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "set-order",
	    ficlPrimitiveSetOrder, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "ficl-wordlist",
	    ficlPrimitiveFiclWordlist, FICL_WORD_DEFAULT);

	/*
	 * Set SEARCH environment query values
	 */
	(void) ficlDictionarySetConstant(environment, "search-order",
	    FICL_TRUE);
	(void) ficlDictionarySetConstant(environment, "search-order-ext",
	    FICL_TRUE);
	(void) ficlDictionarySetConstant(environment, "wordlists",
	    FICL_MAX_WORDLISTS);
	(void) ficlDictionarySetPrimitive(dictionary, "wid-get-name",
	    ficlPrimitiveWidGetName, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "wid-set-name",
	    ficlPrimitiveWidSetName, FICL_WORD_DEFAULT);
	(void) ficlDictionarySetPrimitive(dictionary, "wid-set-super",
	    ficlPrimitiveSetParentWid, FICL_WORD_DEFAULT);
}
Beispiel #6
0
void ficlSystemCompileFile(ficlSystem *system)
{
#if !FICL_WANT_FILE
    FICL_IGNORE(system);
#else
    ficlDictionary *dictionary = ficlSystemGetDictionary(system);
    ficlDictionary *environment = ficlSystemGetEnvironment(system);

    FICL_SYSTEM_ASSERT(system, dictionary);
    FICL_SYSTEM_ASSERT(system, environment);

    ficlDictionarySetPrimitive(dictionary, "create-file", ficlPrimitiveCreateFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "open-file", ficlPrimitiveOpenFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "close-file", ficlPrimitiveCloseFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "include-file", ficlPrimitiveIncludeFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "read-file", ficlPrimitiveReadFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "read-line", ficlPrimitiveReadLine,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "write-file", ficlPrimitiveWriteFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "write-line", ficlPrimitiveWriteLine,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "file-position", ficlPrimitiveFilePosition,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "file-size", ficlPrimitiveFileSize,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "reposition-file", ficlPrimitiveRepositionFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "file-status", ficlPrimitiveFileStatus,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "flush-file", ficlPrimitiveFlushFile,  FICL_WORD_DEFAULT);

    ficlDictionarySetPrimitive(dictionary, "delete-file", ficlPrimitiveDeleteFile,  FICL_WORD_DEFAULT);
    ficlDictionarySetPrimitive(dictionary, "rename-file", ficlPrimitiveRenameFile,  FICL_WORD_DEFAULT);

#if FICL_PLATFORM_HAS_FTRUNCATE
    ficlDictionarySetPrimitive(dictionary, "resize-file", ficlPrimitiveResizeFile,  FICL_WORD_DEFAULT);

    ficlDictionarySetConstant(environment, "file", FICL_TRUE);
    ficlDictionarySetConstant(environment, "file-ext", FICL_TRUE);
#else /*  FICL_PLATFORM_HAS_FTRUNCATE */
    ficlDictionarySetConstant(environment, "file", FICL_FALSE);
    ficlDictionarySetConstant(environment, "file-ext", FICL_FALSE);
#endif /* FICL_PLATFORM_HAS_FTRUNCATE */

#endif /* !FICL_WANT_FILE */
}