Beispiel #1
0
static void ficlIcatPFileWrite(ficlVm *vm)
{
  uint32_t len;
  char *buffer, md5[36];
  uint32_t filename_len;
  char *filename;

  FICL_STACK_CHECK(vm->dataStack,2,0);
  filename_len = ficlStackPopUnsigned(vm->dataStack);
  filename = (char *) ficlStackPopPointer(vm->dataStack);
  len = ficlStackPopUnsigned(vm->dataStack);
  buffer = (char *) ficlStackPopPointer(vm->dataStack);
  calcMd5(buffer,len,md5);
  writeIsfFile(filename,md5,len,buffer,1);
}
Beispiel #2
0
void ficl_taskSpawn(ficlVm *vm)
{
  int tNameLen;
  char *tName;
  int priority;
  int flags;
  int stackSize;
  unsigned command;

  char *taskName;

  FICL_STACK_CHECK(vm->dataStack,6,0);

  tNameLen = ficlStackPopInteger(vm->dataStack);
  tName =  ficlStackPopPointer(vm->dataStack);
  priority = ficlStackPopInteger(vm->dataStack);
  flags = ficlStackPopInteger(vm->dataStack);
  stackSize = ficlStackPopInteger(vm->dataStack);
  command = ficlStackPopUnsigned(vm->dataStack);

  if (simon_system == NULL)
    simon_boot(NULL);

  taskName = malloc(strlen(tName)+1);
  strcpy(taskName,tName);

  taskSpawn(taskName,priority,flags,stackSize,
	    spawn_helper,command,(int)taskName,0,0,0,0,0,0,0,0);
}
Beispiel #3
0
void ficl_diagPrint(ficlVm *vm)
{
  int len;
  char *buffer;

  FICL_STACK_CHECK(vm->dataStack,2,0);
  len = ficlStackPopUnsigned(vm->dataStack);
  buffer = (char *) ficlStackPopPointer(vm->dataStack);
  diagPrint(" ",buffer);
}
Beispiel #4
0
/*
 * f i c l - w o r d l i s t
 * SEARCH ( -- wid )
 * Create a new empty word list, returning its word list identifier wid.
 * The new word list may be returned from a pool of preallocated word
 * lists or may be dynamically allocated in data space. A system shall
 * allow the creation of at least 8 new word lists in addition to any
 * provided as part of the system.
 * Notes:
 * 1. Ficl creates a new single-list hash in the dictionary and returns
 *    its address.
 * 2. ficl-wordlist takes an arg off the stack indicating the number of
 *    hash entries in the wordlist. Ficl 2.02 and later define WORDLIST as
 *    : wordlist 1 ficl-wordlist ;
 */
static void
ficlPrimitiveFiclWordlist(ficlVm *vm)
{
	ficlDictionary *dictionary = ficlVmGetDictionary(vm);
	ficlHash *hash;
	ficlUnsigned nBuckets;

	FICL_STACK_CHECK(vm->dataStack, 1, 1);

	nBuckets = ficlStackPopUnsigned(vm->dataStack);
	hash = ficlDictionaryCreateWordlist(dictionary, nBuckets);
	ficlStackPushPointer(vm->dataStack, hash);
}
Beispiel #5
0
static void ficlIcatFileWrite(ficlVm *vm)
{
  uint32_t len;
  char *buffer, md5[36];
  char filename[FICL_COUNTED_STRING_MAX];
  ficlCountedString *counted = (ficlCountedString *)filename;

  FICL_STACK_CHECK(vm->dataStack,2,0);
  len = ficlStackPopUnsigned(vm->dataStack);
  buffer = (char *) ficlStackPopPointer(vm->dataStack);
  calcMd5(buffer,len,md5);
  ficlVmGetString(vm, counted, '\n');
  writeIsfFile(FICL_COUNTED_STRING_GET_POINTER(*counted),md5,len,buffer,1);
}
Beispiel #6
0
/*
 * s e a r c h - w o r d l i s t
 * SEARCH ( c-addr u wid -- 0 | xt 1 | xt -1 )
 * Find the definition identified by the string c-addr u in the word list
 * identified by wid. If the definition is not found, return zero. If the
 * definition is found, return its execution token xt and one (1) if the
 * definition is immediate, minus-one (-1) otherwise.
 */
static void
ficlPrimitiveSearchWordlist(ficlVm *vm)
{
	ficlString name;
	ficlUnsigned16 hashCode;
	ficlWord *word;
	ficlHash *hash = ficlStackPopPointer(vm->dataStack);

	name.length = (ficlUnsigned8)ficlStackPopUnsigned(vm->dataStack);
	name.text = ficlStackPopPointer(vm->dataStack);
	hashCode = ficlHashCode(name);

	ficlDictionaryLock(ficlVmGetDictionary(vm), FICL_TRUE);
	word = ficlHashLookup(hash, name, hashCode);
	ficlDictionaryLock(ficlVmGetDictionary(vm), FICL_FALSE);

	if (word) {
		ficlStackPushPointer(vm->dataStack, word);
		ficlStackPushInteger(vm->dataStack,
		    (ficlWordIsImmediate(word) ? 1 : -1));
	} else {
		ficlStackPushUnsigned(vm->dataStack, 0);
	}
}
Beispiel #7
0
FICL_PLATFORM_EXTERN ficlUnsigned stackPopUNS   (ficlStack *stack) { return ficlStackPopUnsigned(stack); }