*** empty log message ***
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: memory.c,v 1.2 2005-05-06 16:07:58 bacon Exp $
|
||||
* $Id: memory.c,v 1.3 2005-05-06 17:17:59 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/memory.h>
|
||||
@ -71,7 +71,7 @@ xp_stx_word_t xp_stx_alloc_object (xp_stx_memory_t* mem, xp_stx_word_t nbytes)
|
||||
/* find the free object slot */
|
||||
if (mem->free == XP_NULL) {
|
||||
xp_stx_garbage_collect (mem);
|
||||
if (mem->free == XP_NULL) return mem->capacity;
|
||||
if (mem->free == XP_NULL) return mem->capacity;;
|
||||
}
|
||||
|
||||
object = (xp_stx_object_t*)xp_malloc (nbytes);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: memory.h,v 1.2 2005-05-06 16:07:58 bacon Exp $
|
||||
* $Id: memory.h,v 1.3 2005-05-06 17:17:59 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_MEMORY_H_
|
||||
@ -10,24 +10,38 @@
|
||||
|
||||
typedef struct xp_stx_memory_t xp_stx_memory_t;
|
||||
typedef struct xp_stx_object_t xp_stx_object_t;
|
||||
typedef struct xp_stx_byte_object_t xp_stx_byte_object_t;
|
||||
typedef struct xp_stx_string_object_t xp_stx_string_object_t;
|
||||
|
||||
typedef xp_byte_t xp_stx_byte_t;
|
||||
typedef xp_char_t xp_stx_char_t;
|
||||
typedef xp_size_t xp_stx_word_t;
|
||||
typedef xp_size_t xp_stx_size_t;
|
||||
typedef xp_size_t xp_stx_index_t;
|
||||
typedef xp_stx_object_t* xp_stx_pointer_t;
|
||||
|
||||
#define XP_STX_OBJECT(mem,index) (mem->slots[index>>1])
|
||||
|
||||
/* access - is_byte_indexed: 1; size: rest */
|
||||
#define XP_STX_OBJECT_HEADER \
|
||||
xp_stx_word_t access; \
|
||||
xp_stx_word_t class
|
||||
|
||||
/* common object header structure */
|
||||
struct xp_stx_object_t
|
||||
{
|
||||
XP_STX_OBJECT_HEADER;
|
||||
/* access - is_byte_indexed: 1; size: rest */
|
||||
xp_stx_word_t access;
|
||||
xp_stx_word_t class;
|
||||
xp_stx_word_t data[1];
|
||||
};
|
||||
|
||||
struct xp_stx_byte_object_t
|
||||
{
|
||||
xp_stx_word_t access;
|
||||
xp_stx_word_t class;
|
||||
xp_stx_byte_t data[1];
|
||||
};
|
||||
|
||||
struct xp_stx_string_object_t
|
||||
{
|
||||
xp_stx_word_t access;
|
||||
xp_stx_word_t class;
|
||||
xp_stx_char_t data[1];
|
||||
};
|
||||
|
||||
struct xp_stx_memory_t
|
||||
@ -35,15 +49,29 @@ struct xp_stx_memory_t
|
||||
xp_stx_word_t capacity;
|
||||
xp_stx_object_t** slots;
|
||||
xp_stx_object_t** free;
|
||||
|
||||
xp_stx_word_t nil;
|
||||
//xp_stx_word_t smalltalk;
|
||||
//xp_stx_word_t classes[];
|
||||
xp_stx_word_t symbol_table;
|
||||
|
||||
xp_bool_t __malloced;
|
||||
};
|
||||
|
||||
#define XP_STX_NIL (0)
|
||||
|
||||
#define XP_STX_OBJECT(mem,at) \
|
||||
((xp_stx_object_t*)(mem->slots[at]))
|
||||
#define XP_STX_BYTE_OBJECT(mem,at) \
|
||||
((xp_stx_byte_object_t*)(mem->slots[at]))
|
||||
#define XP_STX_STRING_OBJECT(mem,at) \
|
||||
((xp_stx_string_object_t*)(mem->slots[at]))
|
||||
|
||||
#define XP_STX_OBJECT_ACCESS(mem,at) ((XP_STX_OBJECT(mem,at))->access)
|
||||
#define XP_STX_OBJECT_CLASS(mem,at) ((XP_STX_OBJECT(mem,at))->class)
|
||||
|
||||
#define XP_STX_OBJECT_DATA(mem,at) \
|
||||
(((XP_STX_OBJECT_ACCESS(mem,at) & 0x04) == 0x00)? \
|
||||
(XP_STX_OBJECT(mem,at)).data): \
|
||||
(((XP_STX_OBJECT_ACCESS(mem,at) & 0x04) == 0x01)? \
|
||||
(XP_STX_BYTE_OBJECT(mem,at)).data): \
|
||||
(XP_STX_STRING_OBJECT(mem,at)).data))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
50
ase/stx/object.c
Normal file
50
ase/stx/object.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* $Id: object.c,v 1.1 2005-05-06 17:17:59 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/stx/object.h>
|
||||
|
||||
/* n: number of instance variables */
|
||||
xp_stx_word_t xp_stx_instantiate (xp_stx_memory_t* mem, xp_size_t n)
|
||||
{
|
||||
xp_stx_word_t at;
|
||||
|
||||
/* bytes to allocated =
|
||||
* number of instance variables * word_size
|
||||
*/
|
||||
at = xp_stx_alloc_object (mem, n * xp_sizeof(xp_stx_word_t));
|
||||
if (at >= mem->capacity) return at; /* failed */
|
||||
|
||||
XP_STX_OBJECT_CLASS(mem,at) = XP_STX_NIL;
|
||||
XP_STX_OBJECT_ACCESS(mem,at) = ((n << 2) | 0x00);
|
||||
while (n--) XP_STX_OBJECT(mem,at)->data[n] = XP_STX_NIL;
|
||||
return at;
|
||||
}
|
||||
|
||||
xp_stx_word_t xp_stx_instantiate_byte (xp_stx_memory_t* mem, xp_size_t n)
|
||||
{
|
||||
xp_stx_word_t at;
|
||||
|
||||
at = xp_stx_alloc_object (mem, n);
|
||||
if (at >= mem->capacity) return at; /* failed */
|
||||
|
||||
XP_STX_OBJECT_CLASS(mem,at) = XP_STX_NIL;
|
||||
XP_STX_OBJECT_ACCESS(mem,at) = ((n << 2) | 0x01);
|
||||
while (n--) XP_STX_BYTE_OBJECT(mem,at)->data[n] = 0;
|
||||
return at;
|
||||
}
|
||||
|
||||
xp_stx_word_t xp_stx_instantiate_string (
|
||||
xp_stx_memory_t* mem, xp_stx_char_t* str, xp_stx_word_t n)
|
||||
{
|
||||
xp_stx_word_t at;
|
||||
|
||||
at = xp_stx_alloc_object (mem, n * xp_sizeof(xp_stx_char_t));
|
||||
if (at >= mem->capacity) return at; /* failed */
|
||||
|
||||
XP_STX_OBJECT_CLASS(mem,at) = XP_STX_NIL;
|
||||
XP_STX_OBJECT_ACCESS(mem,at) = ((n << 2) | 0x02);
|
||||
while (n--) XP_STX_BYTE_OBJECT(mem,at)->data[n] = str[n];
|
||||
|
||||
return at;
|
||||
}
|
14
ase/stx/object.h
Normal file
14
ase/stx/object.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* $Id: object.h,v 1.1 2005-05-06 17:17:59 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_STX_OBJECT_H_
|
||||
#define _XP_STX_OBJECT_H_
|
||||
|
||||
#include <xp/stx/memory.h>
|
||||
|
||||
#define XP_STX_IS_SMALLINT(x) (((x) & 0x01) == 0x01)
|
||||
#define XP_STX_TO_SMALLINT(x) ((x) << 1) | 0x01)
|
||||
#define XP_STX_FROM_SMALLINT(x) ((x) >> 1)
|
||||
|
||||
#endif
|
@ -42,7 +42,7 @@ WVList
|
||||
0
|
||||
10
|
||||
WPickList
|
||||
4
|
||||
6
|
||||
11
|
||||
MItem
|
||||
3
|
||||
@ -121,26 +121,26 @@ WVList
|
||||
0
|
||||
29
|
||||
MItem
|
||||
3
|
||||
*.h
|
||||
8
|
||||
object.c
|
||||
30
|
||||
WString
|
||||
3
|
||||
NIL
|
||||
4
|
||||
COBJ
|
||||
31
|
||||
WVList
|
||||
0
|
||||
32
|
||||
WVList
|
||||
0
|
||||
-1
|
||||
11
|
||||
1
|
||||
1
|
||||
0
|
||||
33
|
||||
MItem
|
||||
8
|
||||
memory.h
|
||||
3
|
||||
*.h
|
||||
34
|
||||
WString
|
||||
3
|
||||
@ -151,7 +151,43 @@ WVList
|
||||
36
|
||||
WVList
|
||||
0
|
||||
29
|
||||
-1
|
||||
1
|
||||
1
|
||||
0
|
||||
37
|
||||
MItem
|
||||
8
|
||||
memory.h
|
||||
38
|
||||
WString
|
||||
3
|
||||
NIL
|
||||
39
|
||||
WVList
|
||||
0
|
||||
40
|
||||
WVList
|
||||
0
|
||||
33
|
||||
1
|
||||
1
|
||||
0
|
||||
41
|
||||
MItem
|
||||
8
|
||||
object.h
|
||||
42
|
||||
WString
|
||||
3
|
||||
NIL
|
||||
43
|
||||
WVList
|
||||
0
|
||||
44
|
||||
WVList
|
||||
0
|
||||
33
|
||||
1
|
||||
1
|
||||
0
|
||||
|
@ -4,8 +4,8 @@ projectIdent
|
||||
VpeMain
|
||||
1
|
||||
WRect
|
||||
4300
|
||||
333
|
||||
1500
|
||||
440
|
||||
4330
|
||||
9200
|
||||
2
|
||||
|
Reference in New Issue
Block a user