2005-05-08 07:39:51 +00:00
|
|
|
/*
|
2007-03-22 11:19:28 +00:00
|
|
|
* $Id: stx.c,v 1.41 2007-03-22 11:19:28 bacon Exp $
|
2005-05-08 07:39:51 +00:00
|
|
|
*/
|
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
#include <ase/stx/stx.h>
|
|
|
|
#include <ase/stx/memory.h>
|
|
|
|
#include <ase/stx/misc.h>
|
2005-05-08 07:39:51 +00:00
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
ase_stx_t* ase_stx_open (ase_stx_t* stx, ase_word_t capacity)
|
2005-05-08 07:39:51 +00:00
|
|
|
{
|
2007-03-22 11:19:28 +00:00
|
|
|
ase_word_t i;
|
2005-07-24 16:50:53 +00:00
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
if (stx == ASE_NULL) {
|
|
|
|
stx = (ase_stx_t*)ase_malloc (ase_sizeof(stx));
|
|
|
|
if (stx == ASE_NULL) return ASE_NULL;
|
|
|
|
stx->__dynamic = ase_true;
|
2005-05-08 07:39:51 +00:00
|
|
|
}
|
2007-03-22 11:19:28 +00:00
|
|
|
else stx->__dynamic = ase_false;
|
2005-05-08 07:39:51 +00:00
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
if (ase_stx_memory_open (&stx->memory, capacity) == ASE_NULL) {
|
|
|
|
if (stx->__dynamic) ase_free (stx);
|
|
|
|
return ASE_NULL;
|
2005-05-08 07:39:51 +00:00
|
|
|
}
|
|
|
|
|
2005-07-24 16:50:53 +00:00
|
|
|
stx->symtab.size = 0;
|
2005-08-11 09:57:54 +00:00
|
|
|
stx->symtab.capacity = 128; /* TODO: symbol table size */
|
2007-03-22 11:19:28 +00:00
|
|
|
stx->symtab.datum = (ase_word_t*)ase_malloc (
|
|
|
|
ase_sizeof(ase_word_t) * stx->symtab.capacity);
|
|
|
|
if (stx->symtab.datum == ASE_NULL) {
|
|
|
|
ase_stx_memory_close (&stx->memory);
|
|
|
|
if (stx->__dynamic) ase_free (stx);
|
|
|
|
return ASE_NULL;
|
2005-07-24 16:50:53 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
stx->nil = ASE_STX_NIL;
|
|
|
|
stx->true = ASE_STX_TRUE;
|
|
|
|
stx->false = ASE_STX_FALSE;
|
2005-05-08 10:31:25 +00:00
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
stx->smalltalk = ASE_STX_NIL;
|
2005-05-17 16:18:56 +00:00
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
stx->class_symbol = ASE_STX_NIL;
|
|
|
|
stx->class_metaclass = ASE_STX_NIL;
|
|
|
|
stx->class_association = ASE_STX_NIL;
|
2005-05-17 16:18:56 +00:00
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
stx->class_object = ASE_STX_NIL;
|
|
|
|
stx->class_class = ASE_STX_NIL;
|
|
|
|
stx->class_array = ASE_STX_NIL;
|
|
|
|
stx->class_bytearray = ASE_STX_NIL;
|
|
|
|
stx->class_string = ASE_STX_NIL;
|
|
|
|
stx->class_character = ASE_STX_NIL;
|
|
|
|
stx->class_context = ASE_STX_NIL;
|
|
|
|
stx->class_system_dictionary = ASE_STX_NIL;
|
|
|
|
stx->class_method = ASE_STX_NIL;
|
|
|
|
stx->class_smallinteger = ASE_STX_NIL;
|
2005-05-10 06:08:57 +00:00
|
|
|
|
2005-07-24 16:50:53 +00:00
|
|
|
for (i = 0; i < stx->symtab.capacity; i++) {
|
2005-08-11 09:57:54 +00:00
|
|
|
stx->symtab.datum[i] = stx->nil;
|
2005-07-24 16:50:53 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
stx->__wantabort = ase_false;
|
2005-05-08 07:39:51 +00:00
|
|
|
return stx;
|
|
|
|
}
|
|
|
|
|
2007-03-22 11:19:28 +00:00
|
|
|
void ase_stx_close (ase_stx_t* stx)
|
2005-05-08 07:39:51 +00:00
|
|
|
{
|
2007-03-22 11:19:28 +00:00
|
|
|
ase_free (stx->symtab.datum);
|
|
|
|
ase_stx_memory_close (&stx->memory);
|
|
|
|
if (stx->__dynamic) ase_free (stx);
|
2005-05-08 07:39:51 +00:00
|
|
|
}
|
|
|
|
|