4 * Copyright (C) 2008 Vincent Geddes
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include "st-behavior.h"
26 #include "st-object.h"
27 #include "st-dictionary.h"
28 #include "st-universe.h"
29 #include "st-symbol.h"
30 #include "st-object.h"
33 #include "st-handle.h"
37 st_behavior_all_instance_variables (st_oop
class)
46 names
= ST_BEHAVIOR_INSTANCE_VARIABLES (class);
47 if (names
!= ST_NIL
) {
48 size
= st_smi_value (st_arrayed_object_size (names
));
49 for (int i
= 1; i
<= size
; i
++)
50 list
= st_list_prepend (list
, (st_pointer
) st_strdup (st_byte_array_bytes (st_array_at (names
, i
))));
53 return st_list_concat (st_behavior_all_instance_variables (ST_BEHAVIOR_SUPERCLASS (class)),
54 st_list_reverse (list
));
59 st_object_new (st_oop
class)
61 switch (st_smi_value (ST_BEHAVIOR_FORMAT (class))) {
62 case ST_FORMAT_OBJECT
:
63 return st_object_allocate (class);
64 case ST_FORMAT_CONTEXT
:
69 return st_float_allocate (class);
70 case ST_FORMAT_LARGE_INTEGER
:
71 return st_large_integer_allocate (class, NULL
);
72 case ST_FORMAT_HANDLE
:
73 return st_handle_allocate (class);
75 /* should not reach */
81 st_object_new_arrayed (st_oop
class, int size
)
83 switch (st_smi_value (ST_BEHAVIOR_FORMAT (class))) {
85 return st_array_allocate (class, size
);
86 case ST_FORMAT_BYTE_ARRAY
:
87 return st_byte_array_allocate (class, size
);
88 case ST_FORMAT_WORD_ARRAY
:
89 return st_word_array_allocate (class, size
);
90 case ST_FORMAT_FLOAT_ARRAY
:
91 return st_float_array_allocate (class, size
);
92 case ST_FORMAT_INTEGER_ARRAY
:
97 /* should not reach */