Beispiel #1
0
int main(int argc, char **argv)
{
    int returnValue = 0;
    char buffer[256];
    char *gotline;
    ficlVm *vm;
	ficlSystem *system;

    system = ficlSystemCreate(NULL);
    ficlSystemCompileExtras(system);
    vm = ficlSystemCreateVm(system);

    returnValue = ficlVmEvaluate(vm, ".ver .( " __DATE__ " ) cr quit");

    /*
    ** load files specified on command-line
    */
    if (argc  > 1)
    {
        sprintf(buffer, ".( loading %s ) cr load %s\n cr", argv[1], argv[1]);
        returnValue = ficlVmEvaluate(vm, buffer);
    }

    while (returnValue != FICL_VM_STATUS_USER_EXIT)
    {
	    fputs(FICL_PROMPT, stdout);
        gotline = fgets(buffer, sizeof(buffer), stdin);
        returnValue = ficlVmEvaluate(vm, gotline);
    }

    ficlSystemDestroy(system);
    return 0;
}
Beispiel #2
0
FICL_PLATFORM_EXTERN ficlSystem *ficlInitSystem(int nDictCells)
{
	ficlSystemInformation fsi;
	ficlSystemInformationInitialize(&fsi);
	fsi.dictionarySize = nDictCells;
	if (fsi.stackSize < defaultStackSize)
		fsi.stackSize = defaultStackSize;
	return ficlSystemCreate(&fsi);
}
Beispiel #3
0
/*
 * Initialise the Forth interpreter, create all our commands as words.
 */
void
bf_init(char *rc)
{
	struct bootblk_command	**cmdp;
	char create_buf[41];	/* 31 characters-long builtins */
	int fd, rv;
	ficlDictionary *dict;
	ficlDictionary *env;

	fsi = malloc(sizeof (ficlSystemInformation));
	ficlSystemInformationInitialize(fsi);
	fsi->dictionarySize = BF_DICTSIZE;

	bf_sys = ficlSystemCreate(fsi);
	bf_vm = ficlSystemCreateVm(bf_sys);

	/* Put all private definitions in a "builtins" vocabulary */
	rv = ficlVmEvaluate(bf_vm,
	    "vocabulary builtins also builtins definitions");
	if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
		panic("error interpreting forth: %d", rv);
	}

	/* Builtin constructor word  */
	rv = ficlVmEvaluate(bf_vm, BUILTIN_CONSTRUCTOR);
	if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
		panic("error interpreting forth: %d", rv);
	}

	/* make all commands appear as Forth words */
	dict = ficlSystemGetDictionary(bf_sys);
	SET_FOREACH(cmdp, Xcommand_set) {
		ficlDictionaryAppendPrimitive(dict, (char *)(*cmdp)->c_name,
		    bf_command, FICL_WORD_DEFAULT);
		rv = ficlVmEvaluate(bf_vm, "forth definitions builtins");
		if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
			panic("error interpreting forth: %d", rv);
		}
		sprintf(create_buf, "builtin: %s", (*cmdp)->c_name);
		rv = ficlVmEvaluate(bf_vm, create_buf);
		if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
			panic("error interpreting forth: %d", rv);
		}
		rv = ficlVmEvaluate(bf_vm, "builtins definitions");
		if (rv != FICL_VM_STATUS_OUT_OF_TEXT) {
			panic("error interpreting forth: %d", rv);
		}
	}
Beispiel #4
0
void full_simon(void)
{
  int returnValue = 0;
  char buffer[256];
  ficlVm *vm;
  ficlSystem *system;
  ficlSystemInformation fsi;
  ficlDictionary *dict;
  FILE *fd;
  int led_id;

  ficlSystemInformationInitialize(&fsi);
  fsi.dictionarySize = 256*1024;

  printf("creating ficl system\n");
  system = ficlSystemCreate(&fsi);

  printf("compiling ficl extras\n");
  ficlSystemCompileExtras(system);

  printf("creating ficl vm\n");
  vm = ficlSystemCreateVm(system);

  printf("initializing silkworm customizations\n");
  rf_spi_init(vm);

  printf("getting ficl version\n");
  returnValue = ficlVmEvaluate(vm, ".ver .( " __DATE__ " ) cr quit");

  simon_init(vm);
  rf_spi_init(vm);

  printf("ficl initialization complete\n");

  led_id = ledOpen(fileno(stdin),fileno(stdout),100);

  while (returnValue != FICL_VM_STATUS_USER_EXIT)
    {
      fputs(FICL_PROMPT, stdout);
      fflush(stdout);
      ledRead(led_id,buffer,sizeof(buffer));
      returnValue = ficlVmEvaluate(vm, buffer);
    }

  ledClose(led_id);

  ficlSystemDestroy(system);
}
Beispiel #5
0
FICL_PLATFORM_EXTERN ficlSystem *ficlInitSystemEx(ficlSystemInformation *fsi)
{
	ficlSystem *returnValue;
	ficlCompatibilityOutputFunction thunkedTextout;
	ficlSystemInformation clone;

	memcpy(&clone, fsi, sizeof(clone));
	thunkedTextout = (ficlCompatibilityOutputFunction)clone.textOut;
	clone.textOut = clone.errorOut = thunkTextOut;

	returnValue = ficlSystemCreate(&clone);
	if (returnValue != NULL)
	{
		returnValue->thunkedTextout = thunkedTextout;
	}
	return returnValue;
}
Beispiel #6
0
int simon_boot(char *eval)
{
  ficlVm *vm;
  ficlSystemInformation fsi;

  ficlSystemInformationInitialize(&fsi);
  fsi.dictionarySize = 256*1024;

  simon_system = ficlSystemCreate(&fsi);
  ficlSystemCompileExtras(simon_system);
  vm = ficlSystemCreateVm(simon_system);
  simon_init(vm);
  rf_spi_init(vm);

  if (eval != NULL) ficlVmEvaluate(vm,eval);
  ficlSystemDestroyVm(vm);
  return 0; 
}
Beispiel #7
0
int main(int argc, char **argv) {
    int returnValue = 0;
    char buffer[256];
    ficlVm *vm;
    ficlSystem *system;

    int i=0;
    int ch;
    char *fileName=(char *)NULL;
    char *loadPath=(char *)NULL;

    strcpy(prompt, FICL_PROMPT);
    verbose=-1; // Default is to be talkative.

    i = tcgetattr( 0, &orig_termios); 

    loadPath = getenv("FICL_PATH");


    system = ficlSystemCreate(NULL);
    ficlSystemCompileExtras(system);
    vm = ficlSystemCreateVm(system);

    if(verbose !=0) {
        returnValue = ficlVmEvaluate(vm, ".ver .( " __DATE__ " ) cr quit");
        // returnValue = ficlVmEvaluate(vm, ".ver cr quit");
    }

    while (returnValue != FICL_VM_STATUS_USER_EXIT) {
        //        fputs(FICL_PROMPT, stdout);
        fputs(prompt, stdout);
        if (fgets(buffer, sizeof(buffer), stdin) == NULL) break;
        returnValue = ficlVmEvaluate(vm, buffer);
    }

    ficlSystemDestroy(system);
    return 0;
}