forth.cpp File Reference

Internal implementation of the forth virtual machine. More...

#include "common.h"
#include "forth.h"
Include dependency graph for forth.cpp:

Go to the source code of this file.

Classes

class  WordHeader
 Representation of a forth word's header in the dictionary. More...
struct  Wordlist
 Representaion of a forth wordlist. More...
class  ForthVM
 Implementation of the forth virtual machine. More...

Defines

#define LITTLE_ENDIAN
#define CELLS(x)   ((CELL)(((CELL*)256)+(x))-(CELL)((CELL*)256))
#define CHARS(x)   ((CELL)(((CHAR*)256)+(x))-(CELL)((CHAR*)256))
#define SLASH_CELL(x)   ((CELL*)(256+(x))-((CELL*)256))
#define SLASH_CHAR(x)   ((CHAR*)(256+(x))-((CHAR*)256))
#define ALIGNED(x)   (((x)+CELLS(1)-1)&~(CELLS(1)-1))
#define XT_BRANCH(offset)   XT_PAREN_BRANCH,CELLS(offset)
#define XT_0BRANCH(offset)   XT_PAREN_0BRANCH,CELLS(offset)
#define LIT(x)   XT_PAREN_LITERAL,(CELL)x
#define XT_M_SLASH_MOD   (((-1)/2) ? (CELL)XT_FM_SLASH_MOD : (CELL)XT_SM_SLASH_REM)

Enumerations

enum  Exception
enum  ControlStackMarkers {
  ColonMagic = 12340,
  OrigMagic = 12341,
  DestMagic = 12342
}
enum  ForthXT {
  XT_STORE,
  XT_NUMBER_SIGN,
  XT_NUMBER_SIGN_GREATER,
  XT_STAR,
  XT_PLUS,
  XT_PLUS_STORE,
  XT_PAREN_PLUS_LOOP,
  XT_COMMA,
  XT_MINUS,
  XT_0_LESS,
  XT_0_EQUALS,
  XT_1_PLUS,
  XT_1_MINUS,
  XT_2_STORE,
  XT_2_STAR,
  XT_2_SLASH,
  XT_2_FETCH,
  XT_2DROP,
  XT_2DUP,
  XT_2OVER,
  XT_2SWAP,
  XT_LESS_THAN,
  XT_LESS_NUMBER_SIGN,
  XT_EQUALS,
  XT_GREATER_THAN,
  XT_TO_IN,
  XT_TO_NUMBER,
  XT_TO_R,
  XT_QUESTION_DUP,
  XT_FETCH,
  XT_ABS,
  XT_ACCEPT,
  XT_ALIGN,
  XT_ALIGNED,
  XT_ALLOT,
  XT_AND,
  XT_BASE,
  XT_C_STORE,
  XT_C_COMMA,
  XT_C_FETCH,
  XT_CELL_PLUS,
  XT_CELLS,
  XT_CHAR_PLUS,
  XT_CHARS,
  XT_PAREN_CONSTANT,
  XT_COUNT,
  XT_DEPTH,
  XT_PAREN_DO,
  XT_DROP,
  XT_DUP,
  XT_PAREN_BRANCH,
  XT_EMIT,
  XT_EXECUTE,
  XT_EXIT,
  XT_FILL,
  XT_HERE,
  XT_HOLD,
  XT_I,
  XT_PAREN_0BRANCH,
  XT_INVERT,
  XT_J,
  XT_KEY,
  XT_LEAVE,
  XT_PAREN_LITERAL,
  XT_PAREN_LOOP,
  XT_LSHIFT,
  XT_MAX,
  XT_MIN,
  XT_MOVE,
  XT_NEGATE,
  XT_OR,
  XT_OVER,
  XT_R_FROM,
  XT_R_FETCH,
  XT_ROT,
  XT_RSHIFT,
  XT_S_TO_D,
  XT_SIGN,
  XT_SPACE,
  XT_STATE,
  XT_SWAP,
  XT_TYPE,
  XT_U_LESS_THAN,
  XT_UM_STAR,
  XT_UNLOOP,
  XT_XOR,
  XT_LEFT_BRACKET,
  XT_RIGHT_BRACKET,
  XT_0_NOT_EQUALS,
  XT_0_GREATER,
  XT_2_TO_R,
  XT_2_R_FROM,
  XT_2_R_FETCH,
  XT_NOT_EQUALS,
  XT_PAREN_QUESTION_DO,
  XT_ERASE,
  XT_FALSE,
  XT_NIP,
  XT_PAD,
  XT_PARSE,
  XT_PICK,
  XT_ROLL,
  XT_TRUE,
  XT_TUCK,
  XT_U_GREATER_THAN,
  XT_UNUSED,
  XT_D_PLUS,
  XT_DABS,
  XT_DNEGATE,
  XT_M_PLUS,
  XT_CATCH,
  XT_THROW,
  XT_CMOVE,
  XT_CMOVE_UP
}

Variables

static const CELL BitsPerCell = BITS_PER_CHAR*CHARS_PER_CELL
static const CELL CellLoMask = ((CELL)1<<(BitsPerCell/2))-1
static const CELL SlashCountedString = 255
static const CELL NameLengthMask = 31
static const CELL NumberTIB = 80
static const CELL SlashPad = 84
static const CELL DictionaryOverhead = CHARS(SlashCountedString+2+SlashPad)
static const CELL MaxWordlists = 16
static const CELL StackCells = 256
static const CELL ReturnStackCells = 256
static const CELL XT_NEST_CHECK []
static const CELL XT_FORWARD_BRANCH_COMMA []
static const CELL XT_BACKWARD_BRANCH_COMMA []
static const CELL XT_IF []
static const CELL XT_AHEAD []
static const CELL XT_THEN []
static const CELL XT_BEGIN []
static const CELL XT_AGAIN []
static const CELL XT_UM_SLASH_MOD []
static const CELL XT_CHECK_NEG []
static const CELL XT_CHECK_POS []
static const CELL XT_SM_SLASH_REM []
static const CELL XT_FM_SLASH_MOD []
static const CELL XT_SLASH_MOD []
static const CELL XT_M_STAR []
static const CELL XT_STAR_SLASH_MOD []
static const CELL XT_NUMBER_SIGN_S []
static const CELL XT_D_DOT []
static const CELL XT_DOT []
static const CELL XT_CR []
static const CELL XT_CREATE_WORD []
static const CELL XT_VALIDATE []
static const CELL XT_PAREN_CREATE []
static const CELL XT_CREATE []
static const CELL XT_PAREN_DOES []
static const CELL XT_LITERAL []
static const CELL XT_PAREN_S_QUOTE []
static const CELL XT_S_QUOTE []
static const CELL XT_CHAR []
static const CELL XT_PAREN_FIND []
static const CELL XT_THROW_QUOTE []
static const CELL XT_PAREN_TICK []
static const CELL XT_TICK []
static const CELL XT_TO_SIGN []
static const CELL XT_NUMBER_QUERY []
static const CELL XT_INTERPRET_WORD []
static const CELL XT_COMPILE_WORD []
static const CELL XT_INTERPRET []
static const CELL XT_EVALUATE []
static const CELL XT_REFILL_TIB []
static const CELL XT_REFILL []
static const CELL XT_DO_QUIT []
const CELL XT_EXCEPTION_DOT []
const CELL XT_QUIT []
static const CELL ForthDictionary []
static const CELL EnvironmentDictionary []

Detailed Description

Internal implementation of the forth virtual machine.

Definition in file forth.cpp.


Generated by  doxygen 1.6.1