1 INLINE CELL tag_boolean(CELL untagged)
3 return (untagged == false ? F : T);
6 DLLEXPORT void box_boolean(bool value);
7 DLLEXPORT bool unbox_boolean(void);
9 INLINE F_ARRAY* untag_array_fast(CELL tagged)
11 return (F_ARRAY*)UNTAG(tagged);
14 INLINE F_ARRAY* untag_array(CELL tagged)
16 type_check(ARRAY_TYPE,tagged);
17 return untag_array_fast(tagged);
20 INLINE CELL array_size(CELL size)
22 return sizeof(F_ARRAY) + size * CELLS;
25 F_ARRAY *allot_array_internal(CELL type, F_FIXNUM capacity);
26 F_ARRAY *allot_array(CELL type, F_FIXNUM capacity, CELL fill);
27 F_ARRAY *allot_byte_array(F_FIXNUM size);
29 CELL allot_array_4(CELL v1, CELL v2, CELL v3, CELL v4);
31 void primitive_array(void);
32 void primitive_byte_array(void);
34 F_ARRAY *reallot_array(F_ARRAY* array, F_FIXNUM capacity, CELL fill);
35 void primitive_resize_array(void);
37 void primitive_become(void);
39 #define AREF(array,index) ((CELL)(array) + sizeof(F_ARRAY) + (index) * CELLS)
40 #define UNAREF(array,ptr) (((CELL)(ptr)-(CELL)(array)-sizeof(F_ARRAY)) / CELLS)
42 INLINE void set_array_nth(F_ARRAY *array, CELL slot, CELL value)
44 put(AREF(array,slot),value);
45 write_barrier((CELL)array);
48 INLINE CELL array_capacity(F_ARRAY* array)
50 return array->capacity >> TAG_BITS;
53 #define GROWABLE_ARRAY(result) \
54 CELL result##_count = 0; \
55 F_ARRAY *result = allot_array(ARRAY_TYPE,100,F)
57 INLINE F_ARRAY *growable_add(F_ARRAY *result, CELL elt, CELL *result_count)
61 if(*result_count == array_capacity(result))
63 result = reallot_array(result,
68 set_array_nth(result,*result_count,elt);
69 *result_count = *result_count + 1;
74 #define GROWABLE_ADD(result,elt) \
75 result = growable_add(result,elt,&result##_count)
77 #define GROWABLE_TRIM(result) result = reallot_array(result,result##_count,F)
79 INLINE F_VECTOR* untag_vector(CELL tagged)
81 type_check(VECTOR_TYPE,tagged);
82 return (F_VECTOR*)UNTAG(tagged);
85 F_VECTOR* vector(F_FIXNUM capacity);
87 void primitive_array_to_vector(void);
89 #define SREF(string,index) ((CELL)string + sizeof(F_STRING) + index * CHARS)
91 INLINE F_STRING* untag_string_fast(CELL tagged)
93 return (F_STRING*)UNTAG(tagged);
96 INLINE F_STRING* untag_string(CELL tagged)
98 type_check(STRING_TYPE,tagged);
99 return untag_string_fast(tagged);
102 INLINE CELL string_capacity(F_STRING* str)
104 return str->length >> TAG_BITS;
107 INLINE CELL string_size(CELL size)
109 return sizeof(F_STRING) + (size + 1) * CHARS;
112 F_STRING* allot_string_internal(F_FIXNUM capacity);
113 void rehash_string(F_STRING* str);
114 void primitive_rehash_string(void);
115 F_STRING* allot_string(F_FIXNUM capacity, CELL fill);
116 void primitive_string(void);
117 F_STRING *reallot_string(F_STRING *string, F_FIXNUM capacity, u16 fill);
118 void primitive_resize_string(void);
120 bool check_string(F_STRING *s, CELL max);
122 F_STRING *memory_to_char_string(const char *string, CELL length);
123 void primitive_memory_to_char_string(void);
124 F_STRING *from_char_string(const char *c_string);
125 DLLEXPORT void box_char_string(const char *c_string);
126 void primitive_alien_to_char_string(void);
128 F_STRING *memory_to_u16_string(const u16 *string, CELL length);
129 void primitive_memory_to_u16_string(void);
130 F_STRING *from_u16_string(const u16 *c_string);
131 DLLEXPORT void box_u16_string(const u16 *c_string);
132 void primitive_alien_to_u16_string(void);
134 void char_string_to_memory(F_STRING *s, char *string);
135 void primitive_char_string_to_memory(void);
136 F_ARRAY *string_to_char_alien(F_STRING *s, bool check);
137 char* to_char_string(F_STRING *s, bool check);
138 DLLEXPORT char *unbox_char_string(void);
139 void primitive_string_to_char_alien(void);
141 void u16_string_to_memory(F_STRING *s, u16 *string);
142 void primitive_u16_string_to_memory(void);
143 F_ARRAY *string_to_u16_alien(F_STRING *s, bool check);
144 u16* to_u16_string(F_STRING *s, bool check);
145 DLLEXPORT u16 *unbox_u16_string(void);
146 void primitive_string_to_u16_alien(void);
148 /* untagged & unchecked */
149 INLINE CELL string_nth(F_STRING* string, CELL index)
151 return cget(SREF(string,index));
154 /* untagged & unchecked */
155 INLINE void set_string_nth(F_STRING* string, CELL index, u16 value)
157 cput(SREF(string,index),value);
160 void primitive_char_slot(void);
161 void primitive_set_char_slot(void);
163 void primitive_string_to_sbuf(void);
165 void primitive_hashtable(void);
167 typedef void (*XT)(F_WORD *word);
169 INLINE F_WORD *untag_word_fast(CELL tagged)
171 return (F_WORD*)UNTAG(tagged);
174 INLINE F_WORD *untag_word(CELL tagged)
176 type_check(WORD_TYPE,tagged);
177 return untag_word_fast(tagged);
180 INLINE CELL tag_word(F_WORD *word)
182 return RETAG(word,WORD_TYPE);
185 void update_xt(F_WORD* word);
186 F_WORD *allot_word(CELL vocab, CELL name);
187 void primitive_word(void);
188 void primitive_update_xt(void);
189 void primitive_word_xt(void);
190 void fixup_word(F_WORD* word);
192 INLINE F_WRAPPER *untag_wrapper_fast(CELL tagged)
194 return (F_WRAPPER*)UNTAG(tagged);
197 INLINE CELL tag_wrapper(F_WRAPPER *wrapper)
199 return RETAG(wrapper,WRAPPER_TYPE);
202 void primitive_wrapper(void);