Skip to content
Newer
Older
100644 638 lines (401 sloc) 12.5 KB
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
1 /*
0e36289 @allisonrandal [cage] Updating all copyrights in src/ to Parrot Foundation.
allisonrandal authored Feb 17, 2009
2 Copyright (C) 2001-2009, Parrot Foundation.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
3 $Id$
4
5 =head1 NAME
6
f474cd7 @bschmalhofer [perl #38235] Rename (dyn)?classes to (dyn)?pmc
bschmalhofer authored Jan 18, 2006
7 src/pmc/fixedintegerarray.pmc - fixed size array for integers only
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
8
9 =head1 DESCRIPTION
10
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
11 This class, FixedIntegerArray, implements an array of fixed size which stores
12 INTVALs. It uses Integer PMCs for all of the conversions.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
13
14 =head2 Functions
15
16 =over 4
17
18 =cut
19
20 */
21
6bdd5f9 @petdance headerizer now runs on PMC files
petdance authored Mar 28, 2010
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
25
6b81760 @Whiteknight [pmc] we don't need need_ext anymore, so BALEETED
Whiteknight authored Aug 23, 2009
26 pmclass FixedIntegerArray auto_attrs provides array {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
27 ATTR INTVAL size; /* number of INTVALs stored in this array */
28 ATTR INTVAL * int_array; /* INTVALs are stored here */
d1f7c98 JIT/i386 ord_i_s*
Leopold Toetsch authored Mar 22, 2005
29
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
30 /*
31
32 =back
33
34 =head2 Methods
35
36 =over 4
37
38 =item C<void init()>
39
40 Initializes the array.
41
42 =cut
43
44 */
45
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
46 VTABLE void init() {
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored Sep 3, 2009
47 PObj_custom_destroy_SET(SELF);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
48 }
49
50 /*
51
714df2a @tewk VTABLE_init_int commented out tests
tewk authored Mar 10, 2010
52 =item C<void init_int(INTVAL size)>
53
54 Initializes the array.
55
56 =cut
57
58 */
59
60 VTABLE void init_int(INTVAL size) {
4d64842 @leto [t][TT#1509] Prevent core dumps by preventing negative length array c…
leto authored Mar 11, 2010
61 if (size < 0)
62 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
63 _("FixedIntegerArray: Cannot set array size to a negative number (%d)"), size);
714df2a @tewk VTABLE_init_int commented out tests
tewk authored Mar 10, 2010
64 SET_ATTR_size(INTERP, SELF, size);
65 SET_ATTR_int_array(INTERP, SELF, mem_gc_allocate_n_typed(INTERP, size, INTVAL));
66 PObj_custom_destroy_SET(SELF);
67 }
68
69 /*
70
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
71 =item C<void destroy()>
72
73 Destroys the array.
74
75 =cut
76
77 */
78
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
79 VTABLE void destroy() {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
80 INTVAL* int_array;
81 GET_ATTR_int_array(INTERP, SELF, int_array);
82 if (int_array)
4833868 @bacek Merge branch 'sys_mem' into trunk
bacek authored Feb 22, 2010
83 Parrot_gc_free_memory_chunk(INTERP, int_array);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
84 }
85
86 /*
87
88 =item C<PMC *clone()>
89
90 Creates and returns a copy of the array.
91
92 =cut
93
94 */
95
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
96 VTABLE PMC *clone() {
9822a24 var_args 8 - verify signature during bytecode creation
Leopold Toetsch authored Jun 14, 2005
97 /* a quick hack to create a clone in the constant PMC arena
98 * this is needed for the call signatures
99 *
100 * a better way would be probably to supply a flag to the clone
101 * vtable
102 */
103
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
104 INTVAL * int_array;
105 PMC * const dest =
a35f6fd @petdance consting & localizing
petdance authored Feb 9, 2008
106 PObj_constant_TEST(SELF)
dc5a60b @Whiteknight finish the bulk of the conversions, parrot builds
Whiteknight authored Feb 16, 2010
107 ? Parrot_pmc_new_constant(INTERP, SELF->vtable->base_type)
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored Feb 16, 2010
108 : Parrot_pmc_new(INTERP, SELF->vtable->base_type);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
109
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
110 GET_ATTR_int_array(INTERP, SELF, int_array);
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
111
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
112 if (int_array) {
113 INTVAL *dest_int_array;
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
114 INTVAL size;
115
116 GET_ATTR_size(INTERP, SELF, size);
117
4833868 @bacek Merge branch 'sys_mem' into trunk
bacek authored Feb 22, 2010
118 dest_int_array = mem_gc_allocate_n_typed(INTERP, size, INTVAL);
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
119 SET_ATTR_size(INTERP, dest, size);
120 SET_ATTR_int_array(INTERP, dest, dest_int_array);
d1f7c98 JIT/i386 ord_i_s*
Leopold Toetsch authored Mar 22, 2005
121
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
122 mem_sys_memcopy(dest_int_array, int_array, size * sizeof (INTVAL));
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored Sep 3, 2009
123 PObj_custom_destroy_SET(dest);
a35f6fd @petdance consting & localizing
petdance authored Feb 9, 2008
124 }
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
125
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
126 return dest;
127 }
128
129 /*
130
131 =item C<INTVAL get_bool()>
132
133 Returns whether the array has any elements (meaning been initialized, for a
134 fixed sized array).
135
136 =cut
137
138 */
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
139 VTABLE INTVAL get_bool() {
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
140 INTVAL size;
141 GET_ATTR_size(INTERP, SELF, size);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
142 return (INTVAL)(size != 0);
143 }
144
145 /*
146
147 =item C<INTVAL elements()>
148
149 =cut
150
151 */
152
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
153 VTABLE INTVAL elements() {
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
154 INTVAL size;
155 GET_ATTR_size(INTERP, SELF, size);
156
157 return size;
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
158 }
159
160 /*
161
162 =item C<INTVAL get_integer()>
163
164 Returns the number of elements in the array.
165
166 =cut
167
168 */
169
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
170 VTABLE INTVAL get_integer() {
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
171 INTVAL size;
172 GET_ATTR_size(INTERP, SELF, size);
173 return size;
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
174 }
175
176
177 /*
178
179 =item C<INTVAL get_integer_keyed_int(INTVAL key)>
180
181 Returns the integer value of the element at index C<key>.
182
183 =cut
184
185 */
186
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
187 VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
188 INTVAL *int_array;
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
189 INTVAL size;
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
190
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
191 GET_ATTR_size(INTERP, SELF, size);
192
193 if (key < 0 || key >= size)
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
194 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
d185452 @chromatic Standardize internal exception calls (James deBoer, james at huronbox…
chromatic authored Dec 12, 2004
195 "FixedIntegerArray: index out of bounds!");
d1f7c98 JIT/i386 ord_i_s*
Leopold Toetsch authored Mar 22, 2005
196
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
197 GET_ATTR_int_array(INTERP, SELF, int_array);
198 return int_array[key];
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
199 }
200
201 /*
202
203 =item C<INTVAL get_integer_keyed(PMC *key)>
204
205 Returns the integer value of the element at index C<*key>.
206
207 =cut
208
209 */
210
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
211 VTABLE INTVAL get_integer_keyed(PMC *key) {
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
212 /* simple int keys only */
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
213 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
214 return SELF.get_integer_keyed_int(k);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
215 }
216
217
218 /*
219
220 =item C<FLOATVAL get_number_keyed_int(INTVAL key)>
221
222 Returns the floating-point value of the element at index C<key>.
223
224 =cut
225
226 */
227
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
228 VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
229 const INTVAL i = SELF.get_integer_keyed_int(key);
8275ff5 @chromatic [PMC] Fixed a couple of casting warnings of function return values.
chromatic authored Aug 18, 2007
230 return (FLOATVAL)i;
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
231 }
232
233 /*
234
95e3676 @Infinoid [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
Infinoid authored Aug 9, 2007
235 =item C<FLOATVAL get_number_keyed(PMC *key)>
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
236
237 Returns the floating-point value of the element at index C<*key>.
238
239 =cut
240
241 */
242
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
243 VTABLE FLOATVAL get_number_keyed(PMC *key) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
244 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
245 return SELF.get_number_keyed_int(k);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
246 }
247
248 /*
249
250 =item C<STRING *get_string_keyed_int(INTVAL key)>
251
252 Returns the Parrot string value of the element at index C<key>.
253
254 =cut
255
256 */
257
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
258 VTABLE STRING *get_string_keyed_int(INTVAL key) {
259 PMC * const temp = SELF.get_pmc_keyed_int(key);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
260 return VTABLE_get_string(INTERP, temp);
261 }
bf41b66 @particle [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
particle authored Oct 25, 2006
262
5a67dac @tewk Add get_repr to fixedintegerarray and integer
tewk authored Oct 18, 2006
263 /*
264
265 =item C<STRING *get_repr()>
266
267 Returns the Parrot string representation C<key>.
268
269 =cut
270
271 */
272
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
273 VTABLE STRING *get_repr() {
a35f6fd @petdance consting & localizing
petdance authored Feb 9, 2008
274 STRING *res = CONST_STRING(INTERP, "[ ");
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
275 INTVAL n;
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
276 INTVAL j;
5a67dac @tewk Add get_repr to fixedintegerarray and integer
tewk authored Oct 18, 2006
277
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
278 GET_ATTR_size(INTERP, SELF, n);
279
5a67dac @tewk Add get_repr to fixedintegerarray and integer
tewk authored Oct 18, 2006
280 for (j = 0; j < n; ++j) {
a35f6fd @petdance consting & localizing
petdance authored Feb 9, 2008
281 PMC * const val = SELF.get_pmc_keyed_int(j);
b025176 @bacek Sync branch with trunk.
bacek authored Apr 22, 2010
282 res = Parrot_str_concat(INTERP, res, VTABLE_get_repr(INTERP, val));
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
283
5a67dac @tewk Add get_repr to fixedintegerarray and integer
tewk authored Oct 18, 2006
284 if (j < n - 1)
b025176 @bacek Sync branch with trunk.
bacek authored Apr 22, 2010
285 res = Parrot_str_concat(INTERP, res, CONST_STRING(INTERP, ", "));
5a67dac @tewk Add get_repr to fixedintegerarray and integer
tewk authored Oct 18, 2006
286 }
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
287
b025176 @bacek Sync branch with trunk.
bacek authored Apr 22, 2010
288 res = Parrot_str_concat(INTERP, res, CONST_STRING(INTERP, " ]"));
5a67dac @tewk Add get_repr to fixedintegerarray and integer
tewk authored Oct 18, 2006
289 return res;
290 }
291
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
292
293 /*
294
295 =item C<STRING *get_string_keyed(PMC *key)>
296
297 Returns the Parrot string value of the element at index C<*key>.
298
299 =cut
300
301 */
302
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
303 VTABLE STRING *get_string_keyed(PMC *key) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
304 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
305 return SELF.get_string_keyed_int(k);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
306 }
307
308
309 /*
310
311 =item C<PMC *get_pmc_keyed_int(INTVAL key)>
312
313 Returns the PMC value of the element at index C<key>.
314
315 =cut
316
317 */
318
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
319 VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored Feb 16, 2010
320 PMC * const ret = Parrot_pmc_new(INTERP, enum_class_Integer);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
321 const INTVAL val = SELF.get_integer_keyed_int(key);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
322 VTABLE_set_integer_native(INTERP, ret, val);
323 return ret;
324 }
325
326 /*
327
328 =item C<PMC *get_pmc_keyed(PMC *key)>
329
330 Returns the PMC value of the element at index C<*key>.
331
332 =cut
333
334 */
335
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
336 VTABLE PMC *get_pmc_keyed(PMC *key) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
337 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
338 return SELF.get_pmc_keyed_int(k);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
339 }
340
341 /*
342
343 =item C<void set_integer_native(INTVAL size)>
344
345 Resizes the array to C<size> elements.
346
347 =cut
348
349 */
350
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
351 VTABLE void set_integer_native(INTVAL size) {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
352 INTVAL *int_array;
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
353 INTVAL cur_size;
354
355 GET_ATTR_size(INTERP, SELF, cur_size);
356
357 if (cur_size || size < 1)
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
358 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1f7c98 JIT/i386 ord_i_s*
Leopold Toetsch authored Mar 22, 2005
359 "FixedIntegerArray: Can't resize!");
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
360
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
361 SET_ATTR_size(INTERP, SELF, size);
362 GET_ATTR_int_array(INTERP, SELF, int_array);
7a96a21 @bschmalhofer [codingstd] tabs.t and trailing_space.t
bschmalhofer authored Jan 28, 2009
363 SET_ATTR_int_array(INTERP, SELF,
4833868 @bacek Merge branch 'sys_mem' into trunk
bacek authored Feb 22, 2010
364 mem_gc_realloc_n_typed(INTERP, int_array, size, INTVAL));
4591dbb @chromatic [HLL] Fixed two compilation-breaking typos accidentally committed in …
chromatic authored Sep 3, 2009
365 PObj_custom_destroy_SET(SELF);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
366 }
367
368 /*
369
370 =item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>
371
372 Sets the integer value of the element at index C<key> to C<value>.
373
374 =cut
375
376 */
377
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
378 VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
379 INTVAL *int_array;
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
380 INTVAL size;
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
381
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
382 GET_ATTR_size(INTERP, SELF, size);
383
384 if (key < 0 || key >= size)
2255840 @allisonrandal [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
allisonrandal authored Aug 2, 2008
385 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
d185452 @chromatic Standardize internal exception calls (James deBoer, james at huronbox…
chromatic authored Dec 12, 2004
386 "FixedIntegerArray: index out of bounds!");
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
387
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
388 GET_ATTR_int_array(INTERP, SELF, int_array);
389 int_array[key] = value;
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
390 }
391
392 /*
393
394 =item C<void set_integer_keyed(PMC *key, INTVAL value)>
395
396 Sets the integer value of the element at index C<key> to C<value>.
397
398 =cut
399
400 */
401
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
402 VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
403 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
404 SELF.set_integer_keyed_int(k, value);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
405 }
406
407 /*
408
409 =item C<void set_number_keyed_int(INTVAL key, FLOATVAL value)>
410
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
411 Sets the floating-point value of the element at index C<key> to C<value>.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
412
413 =cut
414
415 */
416
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
417 VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) {
418 SELF.set_integer_keyed_int(key, (INTVAL)value);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
419 }
420
421 /*
422
423 =item C<void set_number_keyed(PMC *key, FLOATVAL value)>
424
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
425 Sets the floating-point value of the element at index C<key> to C<value>.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
426
427 =cut
428
429 */
430
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
431 VTABLE void set_number_keyed(PMC *key, FLOATVAL value) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
432 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
433 SELF.set_number_keyed_int(k, value);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
434 }
d1f7c98 JIT/i386 ord_i_s*
Leopold Toetsch authored Mar 22, 2005
435
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
436 /*
437
438 =item C<void set_string_keyed_int(INTVAL key, STRING *value)>
439
440 Sets the Parrot string value of the element at index C<key> to C<value>.
441
442 =cut
443
444 */
445
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
446 VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
447 INTVAL tempInt;
dc5a60b @Whiteknight finish the bulk of the conversions, parrot builds
Whiteknight authored Feb 16, 2010
448 PMC * const tempPMC = Parrot_pmc_new_temporary(INTERP, enum_class_Integer);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
449 VTABLE_set_string_native(INTERP, tempPMC, value);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
450 tempInt = VTABLE_get_integer(INTERP, tempPMC);
dc5a60b @Whiteknight finish the bulk of the conversions, parrot builds
Whiteknight authored Feb 16, 2010
451 Parrot_pmc_free_temporary(interp, tempPMC);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
452 SELF.set_integer_keyed_int(key, tempInt);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
453 }
454
455 /*
456
95e3676 @Infinoid [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
Infinoid authored Aug 9, 2007
457 =item C<void set_string_keyed(PMC *key, STRING *value)>
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
458
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
459 Sets the string value of the element at index C<key> to C<value>.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
460
461 =cut
462
463 */
464
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
465 VTABLE void set_string_keyed(PMC *key, STRING *value) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
466 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
467 SELF.set_string_keyed_int(k, value);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
468 }
469
470 /*
471
472 =item C<void set_pmc_keyed_int(INTVAL key, PMC *src)>
473
474 Sets the PMC value of the element at index C<key> to C<*src>.
475
476 =cut
477
478 */
479
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
480 VTABLE void set_pmc_keyed_int(INTVAL key, PMC *src) {
a35f6fd @petdance consting & localizing
petdance authored Feb 9, 2008
481 const INTVAL tempInt = VTABLE_get_integer(INTERP, src);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
482 SELF.set_integer_keyed_int(key, tempInt);
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
483 }
484
485 /*
486
95e3676 @Infinoid [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
Infinoid authored Aug 9, 2007
487 =item C<void set_pmc_keyed(PMC *key, PMC *value)>
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
488
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
489 Sets the string value of the element at index C<key> to C<value>.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
490
491 =cut
492
493 */
494
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
495 VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
757f3a8 @chromatic [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
chromatic authored May 8, 2009
496 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
497 SELF.set_pmc_keyed_int(k, value);
498 }
499
500 METHOD sort(PMC *cmp_func) {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
501 INTVAL *int_array;
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
502 UINTVAL n;
503 INTVAL size;
504
505 GET_ATTR_size(INTERP, SELF, size);
506
507 n = (UINTVAL)size;
59661f1 @allisonrandal [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
allisonrandal authored Mar 11, 2008
508
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
509 if (n > 1) {
510 GET_ATTR_int_array(INTERP, SELF, int_array);
511 Parrot_quicksort(interp, (void**)int_array, n, cmp_func);
512 }
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
513 }
514
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
515 /*
516
0c38764 @bacek [core] Implement FixedIntegerArray.is_equal
bacek authored Sep 20, 2009
517 =item C<INTVAL is_equal(PMC *value)>
518
519 The C<==> operation. Compares two array to hold equal elements.
520
521 =cut
522
523 */
524
525 VTABLE INTVAL is_equal(PMC *value) {
526 INTVAL j, n;
527
528 if (value->vtable->base_type != SELF->vtable->base_type)
529 return 0;
530
531 n = SELF.elements();
532
533 if (VTABLE_elements(INTERP, value) != n)
534 return 0;
535
536 for (j = 0; j < n; ++j) {
537 INTVAL item1 = SELF.get_integer_keyed_int(j);
538 INTVAL item2 = VTABLE_get_integer_keyed_int(INTERP, value, j);
539
540 if (item1 != item2)
541 return 0;
542 }
543
544 return 1;
545 }
546
547 /*
548
bd8aacd @cotto [PMC] add get_iter VTABLE function and tests to *IntegerArray
cotto authored Mar 22, 2009
549 =item C<PMC *get_iter()>
550
551 Return a new Iterator for this PMC.
552
553 =cut
554
555 */
556
557 VTABLE PMC *get_iter() {
083213a @Whiteknight start rename of pmc_new to Parrot_pmc_new
Whiteknight authored Feb 16, 2010
558 return Parrot_pmc_new_init(INTERP, enum_class_ArrayIterator, SELF);
bd8aacd @cotto [PMC] add get_iter VTABLE function and tests to *IntegerArray
cotto authored Mar 22, 2009
559 }
560
561 /*
562
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
563 =item C<void visit(PMC *info)>
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
564
565 This is used by freeze/thaw to visit the contents of the array.
566
567 C<*info> is the visit info, (see F<include/parrot/pmc_freeze.h>).
568
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
569 =item C<void freeze(PMC *info)>
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
570
571 Used to archive the array.
572
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
573 =item C<void thaw(PMC *info)>
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
574
575 Used to unarchive the array.
576
577 =cut
578
579 */
580
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
581 /*VTABLE void visit(PMC *info) {
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
582 SUPER(info);
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
583 }*/
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
584
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
585 VTABLE void freeze(PMC *info) {
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
586 INTVAL *int_array;
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
587 INTVAL i, n;
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
588
589 SUPER(info);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
590
8d33429 @chromatic [PMC] Replaced vtable function calls to find size of fixed integer ar…
chromatic authored May 1, 2009
591 GET_ATTR_size(INTERP, SELF, n);
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
592 VTABLE_push_integer(INTERP, info, n);
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
593 GET_ATTR_int_array(INTERP, SELF, int_array);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
594
595 for (i = 0; i < n; ++i)
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
596 VTABLE_push_integer(INTERP, info, int_array[i]);
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
597 }
598
b101f2c @darbelo Merge pmc_freeze_with_pmcs into trunk.
darbelo authored Feb 2, 2010
599 VTABLE void thaw(PMC *info) {
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
600 INTVAL n;
e5dead2 @cotto [pmc] update *IntegerArray to use ATTRs
cotto authored Jan 27, 2009
601
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
602 SUPER(info);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
603
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
604 SET_ATTR_size(INTERP, SELF, 0);
605 SET_ATTR_int_array(INTERP, SELF, NULL);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
606
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
607 if ((n = VTABLE_shift_integer(INTERP, info))) {
608 INTVAL i;
609 INTVAL *int_array;
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
610
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
611 SELF.set_integer_native(n);
612 GET_ATTR_int_array(INTERP, SELF, int_array);
894d448 @chromatic [PMC] Minor cleanups and tidyings.
chromatic authored Sep 4, 2007
613
4c43475 @plobsing merge branch pmc_freeze_cleanup
plobsing authored Jan 13, 2010
614 for (i = 0; i < n; ++i)
615 int_array[i] = VTABLE_shift_integer(INTERP, info);
6287ae3 add missing fixedintegerarray.freeze and .thaw
Leopold Toetsch authored Jul 3, 2005
616 }
617 }
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
618 }
619
620 /*
621
622 =back
623
624 =head1 SEE ALSO
625
1e8a4ab this patch adds some relevant 'push' ops to the resizable PMCs, descr…
Dan Sugalski authored Oct 19, 2004
626 F<docs/pdds/pdd17_basic_types.pod>.
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
627
628 =cut
629
630 */
631
632 /*
633 * Local variables:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored Oct 9, 2006
634 * c-file-style: "parrot"
4498fea This patch adds the above Fixed*Array classes. They are basic tests for
Dan Sugalski authored Jun 12, 2004
635 * End:
636 * vim: expandtab shiftwidth=4:
72575ae @bschmalhofer #40481: [PATCH] C-code coda in pmc files
bschmalhofer authored Oct 9, 2006
637 */
Something went wrong with that request. Please try again.