Ejemplo n.º 1
0
/*
 * Initialise the Forth interpreter, create all our commands as words.
 */
void
bf_init(void)
{
    struct bootblk_command	**cmdp;
    char create_buf[41];	/* 31 characters-long builtins */
    int fd;
   
    ficlInitSystem(8000);	/* Default dictionary ~4000 cells */
    bf_vm = ficlNewVM();

    /* Builtin constructor word  */
    ficlExec(bf_vm, BUILTIN_CONSTRUCTOR, -1);

    /* make all commands appear as Forth words */
    SET_FOREACH(cmdp, Xcommand_set) {
	ficlBuild((*cmdp)->c_name, bf_command, FW_DEFAULT);
	sprintf(create_buf, "builtin: %s", (*cmdp)->c_name);
	ficlExec(bf_vm, create_buf, -1);
    }
Ejemplo n.º 2
0
/*
 * Initialise the Forth interpreter, create all our commands as words.
 */
void
bf_init(void)
{
    struct bootblk_command	**cmdp;
    char create_buf[41];	/* 31 characters-long builtins */
    int fd;
   
    bf_sys = ficlInitSystem(10000);	/* Default dictionary ~4000 cells */
    bf_vm = ficlNewVM(bf_sys);

    /* Put all private definitions in a "builtins" vocabulary */
    ficlExec(bf_vm, "vocabulary builtins also builtins definitions");

    /* Builtin constructor word  */
    ficlExec(bf_vm, BUILTIN_CONSTRUCTOR);

    /* make all commands appear as Forth words */
    SET_FOREACH(cmdp, Xcommand_set) {
	ficlBuild(bf_sys, (char *)(*cmdp)->c_name, bf_command, FW_DEFAULT);
	ficlExec(bf_vm, "forth definitions builtins");
	sprintf(create_buf, "builtin: %s", (*cmdp)->c_name);
	ficlExec(bf_vm, create_buf);
	ficlExec(bf_vm, "builtins definitions");
    }
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    char in[256];
    FICL_VM *pVM;
	FICL_SYSTEM *pSys;

    pSys = ficlInitSystem(10000);
    buildTestInterface(pSys);
    pVM = ficlNewVM(pSys);

    ficlEvaluate(pVM, ".ver .( " __DATE__ " ) cr quit");

    /*
    ** load file from cmd line...
    */
    if (argc  > 1)
    {
        sprintf(in, ".( loading %s ) cr load %s\n cr", argv[1], argv[1]);
        ficlEvaluate(pVM, in);
    }

    for (;;)
    {
        int ret;
        if (fgets(in, sizeof(in) - 1, stdin) == NULL)
	    break;
        ret = ficlExec(pVM, in);
        if (ret == VM_USEREXIT)
        {
            ficlTermSystem(pSys);
            break;
        }
    }

    return 0;
}