Lines Matching defs:system

6  * $Id: system.c,v 1.2 2010/09/10 10:35:54 asau Exp $
16 * in a multitasking system. Unlike Forth, Ficl's outer interpreter
63 * sequence. This is shared by all virtual machines of that system.
65 * at a time. The system imports a locking function that
79 ficlSystemSetVersion(ficlSystem *system)
84 ficlDictionary *environment = ficlSystemGetEnvironment(system);
92 * Binds a global dictionary to the interpreter system.
107 ficlSystem *system;
120 callback.system = NULL;
129 system = ficlMalloc(sizeof (ficlSystem));
131 FICL_ASSERT(&callback, system);
133 memset(system, 0, sizeof (ficlSystem));
147 system->dictionary = ficlDictionaryCreateHashed(system,
149 system->dictionary->forthWordlist->name = "forth-wordlist";
151 environment = ficlDictionaryCreate(system, (unsigned)environmentSize);
152 system->environment = environment;
153 system->environment->forthWordlist->name = "environment";
155 system->callback.textOut = fsi->textOut;
156 system->callback.errorOut = fsi->errorOut;
157 system->callback.context = fsi->context;
158 system->callback.system = system;
159 system->callback.vm = NULL;
160 system->stackSize = stackSize;
170 system->locals = ficlDictionaryCreate(system,
177 * the system VM list. ficlCompilePlatform (defined in win32.c,
180 ficlSystemCompileCore(system);
181 ficlSystemCompilePrefix(system);
184 ficlSystemCompileFloat(system);
188 ficlSystemCompilePlatform(system);
191 ficlSystemSetVersion(system);
198 ficlSystemAddPrimitiveParseStep(system, "?word", ficlVmParseWord);
199 ficlSystemAddPrimitiveParseStep(system, "?prefix", ficlVmParsePrefix);
200 ficlSystemAddPrimitiveParseStep(system, "?number", ficlVmParseNumber);
202 ficlSystemAddPrimitiveParseStep(system, "?float",
214 ficlSystemCreateVm(system);
239 ficlSystemCompileSoftCore(system);
240 ficlSystemDestroyVm(system->vmList);
243 ficlSystemGlobal = system;
245 return (system);
250 * Tear the system down by deleting the dictionaries and all VMs.
254 ficlSystemDestroy(ficlSystem *system)
256 if (system->dictionary)
257 ficlDictionaryDestroy(system->dictionary);
258 system->dictionary = NULL;
260 if (system->environment)
261 ficlDictionaryDestroy(system->environment);
262 system->environment = NULL;
265 if (system->locals)
266 ficlDictionaryDestroy(system->locals);
267 system->locals = NULL;
270 while (system->vmList != NULL) {
271 ficlVm *vm = system->vmList;
272 system->vmList = system->vmList->link;
276 if (ficlSystemGlobal == system)
279 ficlFree(system);
280 system = NULL;
290 ficlSystemAddParseStep(ficlSystem *system, ficlWord *word)
294 if (system->parseList[i] == NULL) {
295 system->parseList[i] = word;
310 ficlSystemAddPrimitiveParseStep(ficlSystem *system, char *name,
313 ficlDictionary *dictionary = system->dictionary;
322 ficlSystemAddParseStep(system, word);
327 * Create a new virtual machine and link it into the system list
331 ficlSystemCreateVm(ficlSystem *system)
333 ficlVm *vm = ficlVmCreate(NULL, system->stackSize, system->stackSize);
334 vm->link = system->vmList;
336 memcpy(&(vm->callback), &(system->callback), sizeof (system->callback));
338 vm->callback.system = system;
340 system->vmList = vm;
346 * Removes the VM in question from the system VM list and deletes the
354 ficlSystem *system = vm->callback.system;
355 ficlVm *pList = system->vmList;
359 if (system->vmList == vm) {
360 system->vmList = system->vmList->link;
375 * Look in the system dictionary for a match to the given name. If
380 ficlSystemLookup(ficlSystem *system, char *name)
384 return (ficlDictionaryLookup(system->dictionary, s));
389 * Returns the address of the system dictionary
392 ficlSystemGetDictionary(ficlSystem *system)
394 return (system->dictionary);
399 * Returns the address of the system environment space
402 ficlSystemGetEnvironment(ficlSystem *system)
404 return (system->environment);
409 * Returns the address of the system locals dictionary. This dictionary is
414 ficlSystemGetLocals(ficlSystem *system)
416 return (system->locals);
422 * Same as dictLookup, but looks in system locals dictionary first...
427 ficlSystemLookupLocal(ficlSystem *system, ficlString name)
430 ficlDictionary *dictionary = system->dictionary;
431 ficlHash *hash = ficlSystemGetLocals(system)->forthWordlist;
435 FICL_SYSTEM_ASSERT(system, hash);
436 FICL_SYSTEM_ASSERT(system, dictionary);