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