Skip to content
This repository
Newer
Older
100644 722 lines (462 sloc) 14.486 kb
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
1 /*
09dc23bc »
2011-02-04 rarrange initialization and freeze/thaw of FIA and RIA to avoid redun…
2 Copyright (C) 2001-2011, Parrot Foundation.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
3
4 =head1 NAME
5
f474cd7f »
2006-01-18 [perl #38235] Rename (dyn)?classes to (dyn)?pmc
6 src/pmc/fixedintegerarray.pmc - fixed size array for integers only
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
7
8 =head1 DESCRIPTION
9
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
10 This class, FixedIntegerArray, implements an array of fixed size which stores
11 INTVALs. It uses Integer PMCs for all of the conversions.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
12
13 =cut
14
15 */
16
6bdd5f99 »
2010-03-28 headerizer now runs on PMC files
17 /* HEADERIZER HFILE: none */
18 /* HEADERIZER BEGIN: static */
4927d8a6 »
2010-06-10 make FIA sort method half-usable
19 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
20
f9cca7da »
2010-06-30 consting and annotating
21 PARROT_PURE_FUNCTION
22 static int auxcmpfunc(ARGIN(const INTVAL *i), ARGIN(const INTVAL *j))
23 __attribute__nonnull__(1)
24 __attribute__nonnull__(2);
25
26 #define ASSERT_ARGS_auxcmpfunc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
27 PARROT_ASSERT_ARG(i) \
28 , PARROT_ASSERT_ARG(j))
4927d8a6 »
2010-06-10 make FIA sort method half-usable
29 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
6bdd5f99 »
2010-03-28 headerizer now runs on PMC files
30 /* HEADERIZER END: static */
31
4927d8a6 »
2010-06-10 make FIA sort method half-usable
32
6b817608 »
2009-08-23 [pmc] we don't need need_ext anymore, so BALEETED
33 pmclass FixedIntegerArray auto_attrs provides array {
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
34 ATTR INTVAL size; /* number of INTVALs stored in this array */
35 ATTR INTVAL * int_array; /* INTVALs are stored here */
d1f7c985 »
2005-03-22 JIT/i386 ord_i_s*
36
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
37 /*
38
ac9988d8 »
2010-08-12 some cleaning of FIA: put METHOD after vtable functions and fix and i…
39 =head2 Vtable functions
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
40
41 =over 4
42
43 =item C<void init()>
44
45 Initializes the array.
46
47 =cut
48
49 */
50
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
51 VTABLE void init() {
4591dbb8 »
2009-09-03 [HLL] Fixed two compilation-breaking typos accidentally committed in …
52 PObj_custom_destroy_SET(SELF);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
53 }
54
55 /*
56
714df2a3 »
2010-03-10 VTABLE_init_int commented out tests
57 =item C<void init_int(INTVAL size)>
58
59 Initializes the array.
60
61 =cut
62
63 */
64
65 VTABLE void init_int(INTVAL size) {
4d64842d »
2010-03-11 [t][TT#1509] Prevent core dumps by preventing negative length array c…
66 if (size < 0)
26914e12 »
2010-05-05 changed interp in pmc class to INTERP for unification
67 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
4d64842d »
2010-03-11 [t][TT#1509] Prevent core dumps by preventing negative length array c…
68 _("FixedIntegerArray: Cannot set array size to a negative number (%d)"), size);
09dc23bc »
2011-02-04 rarrange initialization and freeze/thaw of FIA and RIA to avoid redun…
69 if (size > 0) {
70 SET_ATTR_size(INTERP, SELF, size);
71 SET_ATTR_int_array(INTERP, SELF, mem_gc_allocate_n_typed(INTERP, size, INTVAL));
72 }
714df2a3 »
2010-03-10 VTABLE_init_int commented out tests
73 PObj_custom_destroy_SET(SELF);
74 }
75
76 /*
77
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
78 =item C<void destroy()>
79
80 Destroys the array.
81
82 =cut
83
84 */
85
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
86 VTABLE void destroy() {
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
87 INTVAL* int_array;
88 GET_ATTR_int_array(INTERP, SELF, int_array);
89 if (int_array)
4833868f »
2010-02-22 Merge branch 'sys_mem' into trunk
90 Parrot_gc_free_memory_chunk(INTERP, int_array);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
91 }
92
93 /*
94
95 =item C<PMC *clone()>
96
97 Creates and returns a copy of the array.
98
99 =cut
100
101 */
102
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
103 VTABLE PMC *clone() {
9822a243 »
2005-06-14 var_args 8 - verify signature during bytecode creation
104 /* a quick hack to create a clone in the constant PMC arena
105 * this is needed for the call signatures
106 *
107 * a better way would be probably to supply a flag to the clone
108 * vtable
109 */
110
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
111 INTVAL * int_array;
84fbdb51 »
2011-11-18 Don't clone self to constant PMC.
112 PMC * const dest = Parrot_pmc_new(INTERP, SELF->vtable->base_type);
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
113
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
114 GET_ATTR_int_array(INTERP, SELF, int_array);
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
115
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
116 if (int_array) {
42f27d4d »
2010-04-24 clean FIA.clone
117 INTVAL size;
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
118 GET_ATTR_size(INTERP, SELF, size);
42f27d4d »
2010-04-24 clean FIA.clone
119 {
120 INTVAL * const dest_int_array = mem_gc_allocate_n_typed(INTERP,
121 size, INTVAL);
122 mem_copy_n_typed(dest_int_array, int_array,
123 size, INTVAL);
124 SET_ATTR_int_array(INTERP, dest, dest_int_array);
125 }
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
126 SET_ATTR_size(INTERP, dest, size);
4591dbb8 »
2009-09-03 [HLL] Fixed two compilation-breaking typos accidentally committed in …
127 PObj_custom_destroy_SET(dest);
a35f6fdb »
2008-02-09 consting & localizing
128 }
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
129
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
130 return dest;
131 }
132
133 /*
134
135 =item C<INTVAL get_bool()>
136
137 Returns whether the array has any elements (meaning been initialized, for a
138 fixed sized array).
139
140 =cut
141
142 */
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
143 VTABLE INTVAL get_bool() {
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
144 INTVAL size;
145 GET_ATTR_size(INTERP, SELF, size);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
146 return (INTVAL)(size != 0);
147 }
148
149 /*
150
151 =item C<INTVAL elements()>
152
153 =cut
154
155 */
156
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
157 VTABLE INTVAL elements() {
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
158 INTVAL size;
159 GET_ATTR_size(INTERP, SELF, size);
160
161 return size;
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
162 }
163
164 /*
165
166 =item C<INTVAL get_integer()>
167
168 Returns the number of elements in the array.
169
170 =cut
171
172 */
173
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
174 VTABLE INTVAL get_integer() {
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
175 INTVAL size;
176 GET_ATTR_size(INTERP, SELF, size);
177 return size;
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
178 }
179
180
181 /*
182
183 =item C<INTVAL get_integer_keyed_int(INTVAL key)>
184
185 Returns the integer value of the element at index C<key>.
186
187 =cut
188
189 */
190
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
191 VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
192 INTVAL *int_array;
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
193 INTVAL size;
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
194
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
195 GET_ATTR_size(INTERP, SELF, size);
196
197 if (key < 0 || key >= size)
26914e12 »
2010-05-05 changed interp in pmc class to INTERP for unification
198 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1854520 »
2004-12-12 Standardize internal exception calls (James deBoer, james at huronbox…
199 "FixedIntegerArray: index out of bounds!");
d1f7c985 »
2005-03-22 JIT/i386 ord_i_s*
200
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
201 GET_ATTR_int_array(INTERP, SELF, int_array);
202 return int_array[key];
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
203 }
204
205 /*
206
207 =item C<INTVAL get_integer_keyed(PMC *key)>
208
209 Returns the integer value of the element at index C<*key>.
210
211 =cut
212
213 */
214
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
215 VTABLE INTVAL get_integer_keyed(PMC *key) {
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
216 /* simple int keys only */
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
217 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
218 return SELF.get_integer_keyed_int(k);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
219 }
220
221
222 /*
223
224 =item C<FLOATVAL get_number_keyed_int(INTVAL key)>
225
226 Returns the floating-point value of the element at index C<key>.
227
228 =cut
229
230 */
231
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
232 VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
233 const INTVAL i = SELF.get_integer_keyed_int(key);
8275ff5f »
2007-08-18 [PMC] Fixed a couple of casting warnings of function return values.
234 return (FLOATVAL)i;
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
235 }
236
237 /*
238
95e36766 »
2007-08-09 [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
239 =item C<FLOATVAL get_number_keyed(PMC *key)>
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
240
241 Returns the floating-point value of the element at index C<*key>.
242
243 =cut
244
245 */
246
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
247 VTABLE FLOATVAL get_number_keyed(PMC *key) {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
248 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
249 return SELF.get_number_keyed_int(k);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
250 }
251
252 /*
253
254 =item C<STRING *get_string_keyed_int(INTVAL key)>
255
256 Returns the Parrot string value of the element at index C<key>.
257
258 =cut
259
260 */
261
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
262 VTABLE STRING *get_string_keyed_int(INTVAL key) {
263 PMC * const temp = SELF.get_pmc_keyed_int(key);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
264 return VTABLE_get_string(INTERP, temp);
265 }
bf41b66b »
2006-10-25 [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
266
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
267 /*
268
fccdff0d »
2011-10-16 Add get_string to Fixed Float and Integer Array
269 =item C<STRING *get_string()>
270
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
271 =item C<STRING *get_repr()>
272
273 Returns the Parrot string representation C<key>.
274
275 =cut
276
277 */
278
fccdff0d »
2011-10-16 Add get_string to Fixed Float and Integer Array
279 VTABLE STRING *get_string() {
280 return STATICSELF.get_repr();
281 }
282
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
283 VTABLE STRING *get_repr() {
a35f6fdb »
2008-02-09 consting & localizing
284 STRING *res = CONST_STRING(INTERP, "[ ");
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
285 INTVAL n;
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
286 INTVAL j;
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
287
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
288 GET_ATTR_size(INTERP, SELF, n);
289
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
290 for (j = 0; j < n; ++j) {
a35f6fdb »
2008-02-09 consting & localizing
291 PMC * const val = SELF.get_pmc_keyed_int(j);
9b0f14ac »
2010-04-21 Everybody freeze! Immutable strings enters the building.
292 res = Parrot_str_concat(INTERP, res, VTABLE_get_repr(INTERP, val));
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
293
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
294 if (j < n - 1)
9b0f14ac »
2010-04-21 Everybody freeze! Immutable strings enters the building.
295 res = Parrot_str_concat(INTERP, res, CONST_STRING(INTERP, ", "));
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
296 }
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
297
9b0f14ac »
2010-04-21 Everybody freeze! Immutable strings enters the building.
298 res = Parrot_str_concat(INTERP, res, CONST_STRING(INTERP, " ]"));
5a67dace »
2006-10-18 Add get_repr to fixedintegerarray and integer
299 return res;
300 }
301
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
302
303 /*
304
f3c2cd19 »
2011-03-02 add hashval() implementation to FIA for faster, more efficient hashing
305 =item C<INTVAL hashvalue()>
306
307 Get a hashvalue for this PMC.
308
309 Providing a non-default C<hashvalue()> implementation avoids creating
310 unecessary string temporaries.
311
312 =cut
313
314 */
315
316 VTABLE INTVAL hashvalue() {
317 INTVAL *int_array;
318 INTVAL size;
319 GET_ATTR_int_array(INTERP, SELF, int_array);
320 GET_ATTR_size(INTERP, SELF, size);
c114262d »
2011-03-06 s/Parrot_hsh_hash_buffer/Parrot_hash_buffer/
321 return Parrot_hash_buffer((const unsigned char *)int_array,
f3c2cd19 »
2011-03-02 add hashval() implementation to FIA for faster, more efficient hashing
322 size * sizeof (INTVAL), INTERP->hash_seed);
323 }
324
325
326 /*
327
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
328 =item C<STRING *get_string_keyed(PMC *key)>
329
330 Returns the Parrot string value of the element at index C<*key>.
331
332 =cut
333
334 */
335
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
336 VTABLE STRING *get_string_keyed(PMC *key) {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
337 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
338 return SELF.get_string_keyed_int(k);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
339 }
340
341
342 /*
343
344 =item C<PMC *get_pmc_keyed_int(INTVAL key)>
345
346 Returns the PMC value of the element at index C<key>.
347
348 =cut
349
350 */
351
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
352 VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
353 const INTVAL val = SELF.get_integer_keyed_int(key);
75d112fd »
2010-05-01 implement Integer vtable init_int and use it in several places where …
354 PMC * const ret = Parrot_pmc_new_init_int(INTERP, enum_class_Integer, val);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
355 return ret;
356 }
357
358 /*
359
360 =item C<PMC *get_pmc_keyed(PMC *key)>
361
362 Returns the PMC value of the element at index C<*key>.
363
364 =cut
365
366 */
367
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
368 VTABLE PMC *get_pmc_keyed(PMC *key) {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
369 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
370 return SELF.get_pmc_keyed_int(k);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
371 }
372
373 /*
374
375 =item C<void set_integer_native(INTVAL size)>
376
377 Resizes the array to C<size> elements.
378
379 =cut
380
381 */
382
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
383 VTABLE void set_integer_native(INTVAL size) {
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
384 INTVAL *int_array;
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
385 INTVAL cur_size;
386
387 GET_ATTR_size(INTERP, SELF, cur_size);
388
389 if (cur_size || size < 1)
2255840f »
2008-08-02 [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
390 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1f7c985 »
2005-03-22 JIT/i386 ord_i_s*
391 "FixedIntegerArray: Can't resize!");
2255840f »
2008-08-02 [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
392
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
393 SET_ATTR_size(INTERP, SELF, size);
394 GET_ATTR_int_array(INTERP, SELF, int_array);
7a96a218 »
2009-01-28 [codingstd] tabs.t and trailing_space.t
395 SET_ATTR_int_array(INTERP, SELF,
4833868f »
2010-02-22 Merge branch 'sys_mem' into trunk
396 mem_gc_realloc_n_typed(INTERP, int_array, size, INTVAL));
4591dbb8 »
2009-09-03 [HLL] Fixed two compilation-breaking typos accidentally committed in …
397 PObj_custom_destroy_SET(SELF);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
398 }
399
400 /*
401
402 =item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>
403
404 Sets the integer value of the element at index C<key> to C<value>.
405
406 =cut
407
408 */
409
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
410 VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) :manual_wb {
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
411 INTVAL *int_array;
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
412 INTVAL size;
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
413
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
414 GET_ATTR_size(INTERP, SELF, size);
415
416 if (key < 0 || key >= size)
26914e12 »
2010-05-05 changed interp in pmc class to INTERP for unification
417 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1854520 »
2004-12-12 Standardize internal exception calls (James deBoer, james at huronbox…
418 "FixedIntegerArray: index out of bounds!");
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
419
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
420 GET_ATTR_int_array(INTERP, SELF, int_array);
421 int_array[key] = value;
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
422 }
423
424 /*
425
426 =item C<void set_integer_keyed(PMC *key, INTVAL value)>
427
428 Sets the integer value of the element at index C<key> to C<value>.
429
430 =cut
431
432 */
433
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
434 VTABLE void set_integer_keyed(PMC *key, INTVAL value) :manual_wb {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
435 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
436 SELF.set_integer_keyed_int(k, value);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
437 }
438
439 /*
440
441 =item C<void set_number_keyed_int(INTVAL key, FLOATVAL value)>
442
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
443 Sets the floating-point value of the element at index C<key> to C<value>.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
444
445 =cut
446
447 */
448
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
449 VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) :manual_wb {
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
450 SELF.set_integer_keyed_int(key, (INTVAL)value);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
451 }
452
453 /*
454
455 =item C<void set_number_keyed(PMC *key, FLOATVAL value)>
456
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
457 Sets the floating-point value of the element at index C<key> to C<value>.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
458
459 =cut
460
461 */
462
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
463 VTABLE void set_number_keyed(PMC *key, FLOATVAL value) :manual_wb {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
464 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
465 SELF.set_number_keyed_int(k, value);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
466 }
d1f7c985 »
2005-03-22 JIT/i386 ord_i_s*
467
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
468 /*
469
470 =item C<void set_string_keyed_int(INTVAL key, STRING *value)>
471
472 Sets the Parrot string value of the element at index C<key> to C<value>.
473
474 =cut
475
476 */
477
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
478 VTABLE void set_string_keyed_int(INTVAL key, STRING *value) :manual_wb {
06e2d1ee »
2010-04-30 avoid a temporary PMC in FPA set_string_keyed_int
479 const INTVAL tempInt = Parrot_str_to_int(INTERP, value);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
480 SELF.set_integer_keyed_int(key, tempInt);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
481 }
482
483 /*
484
95e36766 »
2007-08-09 [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
485 =item C<void set_string_keyed(PMC *key, STRING *value)>
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
486
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
487 Sets the string value of the element at index C<key> to C<value>.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
488
489 =cut
490
491 */
492
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
493 VTABLE void set_string_keyed(PMC *key, STRING *value) :manual_wb {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
494 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
495 SELF.set_string_keyed_int(k, value);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
496 }
497
498 /*
499
500 =item C<void set_pmc_keyed_int(INTVAL key, PMC *src)>
501
502 Sets the PMC value of the element at index C<key> to C<*src>.
503
504 =cut
505
506 */
507
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
508 VTABLE void set_pmc_keyed_int(INTVAL key, PMC *src) :manual_wb {
a35f6fdb »
2008-02-09 consting & localizing
509 const INTVAL tempInt = VTABLE_get_integer(INTERP, src);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
510 SELF.set_integer_keyed_int(key, tempInt);
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
511 }
512
513 /*
514
95e36766 »
2007-08-09 [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
515 =item C<void set_pmc_keyed(PMC *key, PMC *value)>
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
516
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
517 Sets the string value of the element at index C<key> to C<value>.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
518
519 =cut
520
521 */
522
8fcbee35 »
2011-02-17 Mark set_foo_keyed_bar methods with :manual_wb in FIA
523 VTABLE void set_pmc_keyed(PMC *key, PMC *value) :manual_wb {
757f3a87 »
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
524 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 »
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
525 SELF.set_pmc_keyed_int(k, value);
526 }
527
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
528 /*
529
0c38764c »
2009-09-20 [core] Implement FixedIntegerArray.is_equal
530 =item C<INTVAL is_equal(PMC *value)>
531
532 The C<==> operation. Compares two array to hold equal elements.
533
534 =cut
535
536 */
537
538 VTABLE INTVAL is_equal(PMC *value) {
539 INTVAL j, n;
540
541 if (value->vtable->base_type != SELF->vtable->base_type)
542 return 0;
543
544 n = SELF.elements();
545
546 if (VTABLE_elements(INTERP, value) != n)
547 return 0;
548
549 for (j = 0; j < n; ++j) {
f9cca7da »
2010-06-30 consting and annotating
550 const INTVAL item1 = SELF.get_integer_keyed_int(j);
551 const INTVAL item2 = VTABLE_get_integer_keyed_int(INTERP, value, j);
0c38764c »
2009-09-20 [core] Implement FixedIntegerArray.is_equal
552
553 if (item1 != item2)
554 return 0;
555 }
556
557 return 1;
558 }
559
560 /*
561
bd8aacd2 »
2009-03-22 [PMC] add get_iter VTABLE function and tests to *IntegerArray
562 =item C<PMC *get_iter()>
563
564 Return a new Iterator for this PMC.
565
566 =cut
567
568 */
569
570 VTABLE PMC *get_iter() {
083213a2 »
2010-02-16 start rename of pmc_new to Parrot_pmc_new
571 return Parrot_pmc_new_init(INTERP, enum_class_ArrayIterator, SELF);
bd8aacd2 »
2009-03-22 [PMC] add get_iter VTABLE function and tests to *IntegerArray
572 }
573
574 /*
575
b101f2ca »
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
576 =item C<void freeze(PMC *info)>
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
577
578 Used to archive the array.
579
b101f2ca »
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
580 =item C<void thaw(PMC *info)>
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
581
582 Used to unarchive the array.
583
09dc23bc »
2011-02-04 rarrange initialization and freeze/thaw of FIA and RIA to avoid redun…
584 C<*info> is the visit info, (see F<include/parrot/pmc_freeze.h>).
585
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
586 =cut
587
588 */
589
b101f2ca »
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
590 VTABLE void freeze(PMC *info) {
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
591 INTVAL *int_array;
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
592 INTVAL i, n;
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
593
594 SUPER(info);
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
595
8d334299 »
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
596 GET_ATTR_size(INTERP, SELF, n);
4c434759 »
2010-01-13 merge branch pmc_freeze_cleanup
597 VTABLE_push_integer(INTERP, info, n);
e5dead2e »
2009-01-27 [pmc] update *IntegerArray to use ATTRs
598 GET_ATTR_int_array(INTERP, SELF, int_array);
894d4481 »
2007-09-04 [PMC] Minor cleanups and tidyings.
599
600 for (i = 0; i < n; ++i)
4c434759 »
2010-01-13 merge branch pmc_freeze_cleanup
601 VTABLE_push_integer(INTERP, info, int_array[i]);
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
602 }
603
b101f2ca »
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
604 VTABLE void thaw(PMC *info) {
8640c338 »
2011-02-26 consting vars. Fixed some POD.
605 const INTVAL n = VTABLE_shift_integer(INTERP, info);
09dc23bc »
2011-02-04 rarrange initialization and freeze/thaw of FIA and RIA to avoid redun…
606 SELF.init_int(n);
607 if (n > 0) {
4c434759 »
2010-01-13 merge branch pmc_freeze_cleanup
608 INTVAL i;
609 INTVAL *int_array;
610 GET_ATTR_int_array(INTERP, SELF, int_array);
611 for (i = 0; i < n; ++i)
612 int_array[i] = VTABLE_shift_integer(INTERP, info);
6287ae3c »
2005-07-03 add missing fixedintegerarray.freeze and .thaw
613 }
614 }
ac9988d8 »
2010-08-12 some cleaning of FIA: put METHOD after vtable functions and fix and i…
615
616 /*
617
618 =back
619
620 =head2 Methods
621
622 =over 4
623
624 =item C<PMC *sort()>
625
626 Sort the array and return self.
627
628 =cut
629
630 */
631
632 METHOD sort(PMC *cmp_func :optional) {
633 UINTVAL n;
634 INTVAL size;
635
636 GET_ATTR_size(INTERP, SELF, size);
637 n = (UINTVAL)size;
638
639 if (n > 1) {
640 INTVAL *int_array;
641 GET_ATTR_int_array(INTERP, SELF, int_array);
642 if (PMC_IS_NULL(cmp_func))
643 qsort(int_array, n, sizeof (INTVAL),
644 (int (*)(const void *, const void*))auxcmpfunc);
645 else
4379aa40 »
2010-12-25 Pass cmp signature to quicksort to avoid segmentation fault during fe…
646 Parrot_util_quicksort(INTERP, (void**)int_array, n, cmp_func, "II->I");
ac9988d8 »
2010-08-12 some cleaning of FIA: put METHOD after vtable functions and fix and i…
647 }
648 RETURN(PMC *SELF);
649 }
650
47a64b48 »
2011-10-20 add a "reverse" method for the array types (except boolarray)
651 /*
652
653 =item C<METHOD reverse()>
654
655 Reverse the contents of the array.
656
657 =cut
658
659 */
660
661 METHOD reverse() {
662 INTVAL n;
663 GET_ATTR_size(INTERP, SELF, n);
664 if (n > 1) {
665 INTVAL val;
666 INTVAL *data;
667 INTVAL i;
668
669 GET_ATTR_int_array(INTERP, SELF, data);
670 for (i = 0; i <= --n; i++) {
671 val = data[i];
672 data[i] = data[n];
673 data[n] = val;
674 }
675 }
f55a4889 »
2011-10-20 codingstd fixes
676 }
47a64b48 »
2011-10-20 add a "reverse" method for the array types (except boolarray)
677
ac9988d8 »
2010-08-12 some cleaning of FIA: put METHOD after vtable functions and fix and i…
678 }
679
680 /*
681
682 =back
683
cbe26174 »
2010-08-14 Correct spelling error in POD.
684 =head2 Auxiliary functions
ac9988d8 »
2010-08-12 some cleaning of FIA: put METHOD after vtable functions and fix and i…
685
686 =over 4
687
688 =item C<static int auxcmpfunc(const INTVAL *i, const INTVAL *j)>
689
690 INTVAL compare function for qsort usage.
691
692 =cut
693
694 */
695
696 PARROT_PURE_FUNCTION
697 static int
698 auxcmpfunc(ARGIN(const INTVAL *i), ARGIN(const INTVAL *j))
699 {
700 ASSERT_ARGS(auxcmpfunc)
701 return *i - *j;
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
702 }
703
704 /*
705
706 =back
707
708 =head1 SEE ALSO
709
1e8a4ab7 »
2004-10-19 this patch adds some relevant 'push' ops to the resizable PMCs, descr…
710 F<docs/pdds/pdd17_basic_types.pod>.
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
711
712 =cut
713
714 */
715
716 /*
717 * Local variables:
72575ae0 »
2006-10-09 #40481: [PATCH] C-code coda in pmc files
718 * c-file-style: "parrot"
4498fea9 »
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
719 * End:
1d7dded8 »
2010-11-29 update C file vim modelines
720 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
72575ae0 »
2006-10-09 #40481: [PATCH] C-code coda in pmc files
721 */
Something went wrong with that request. Please try again.