1 /* @(#) pforth.h 98/01/26 1.2 */
5 /***************************************************************
6 ** Include file for pForth, a portable Forth based on 'C'
8 ** This file is included in any application that uses pForth as a library.
11 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
13 ** Permission to use, copy, modify, and/or distribute this
14 ** software for any purpose with or without fee is hereby granted.
16 ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
17 ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
18 ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
19 ** THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
20 ** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
21 ** FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
22 ** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
23 ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 ***************************************************************/
28 /* Define stubs for data types so we can pass pointers but not touch inside. */
29 typedef void *PForthTask;
30 typedef void *PForthDictionary;
33 /* Integer types for Forth cells, signed and unsigned: */
34 typedef intptr_t cell_t;
35 typedef uintptr_t ucell_t;
37 typedef ucell_t ExecToken; /* Execution Token */
38 typedef cell_t ThrowCode;
44 /* Main entry point to pForth. */
45 ThrowCode pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit );
47 /* Turn off messages. */
48 void pfSetQuiet( cell_t IfQuiet );
50 /* Query message status. */
51 cell_t pfQueryQuiet( void );
53 /* Send a message using low level I/O of pForth */
54 void pfMessage( const char *CString );
56 /* Create a task used to maintain context of execution. */
57 PForthTask pfCreateTask( cell_t UserStackDepth, cell_t ReturnStackDepth );
59 /* Establish this task as the current task. */
60 void pfSetCurrentTask( PForthTask task );
62 /* Delete task created by pfCreateTask */
63 void pfDeleteTask( PForthTask task );
65 /* Build a dictionary with all the basic kernel words. */
66 PForthDictionary pfBuildDictionary( cell_t HeaderSize, cell_t CodeSize );
68 /* Create an empty dictionary. */
69 PForthDictionary pfCreateDictionary( cell_t HeaderSize, cell_t CodeSize );
71 /* Load dictionary from a file. */
72 PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr );
74 /* Load dictionary from static array in "pfdicdat.h". */
75 PForthDictionary pfLoadStaticDictionary( void );
77 /* Delete dictionary data. */
78 void pfDeleteDictionary( PForthDictionary dict );
80 /* Execute the pForth interpreter. Yes, QUIT is an odd name but it has historical meaning. */
81 ThrowCode pfQuit( void );
83 /* Execute a single execution token in the current task and return 0 or an error code. */
84 ThrowCode pfCatch( ExecToken XT );
86 /* Include the given pForth source code file. */
87 ThrowCode pfIncludeFile( const char *FileName );
89 /* Execute a Forth word by name. */
90 ThrowCode pfExecIfDefined( const char *CString );
96 #endif /* _pforth_h */