Skip to content
This repository
Newer
Older
100644 632 lines (399 sloc) 12.539 kb
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
1 /*
0e362895 » allisonrandal
2009-02-17 [cage] Updating all copyrights in src/ to Parrot Foundation.
2 Copyright (C) 2001-2009, Parrot Foundation.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
3 $Id$
4
5 =head1 NAME
6
f474cd7f » bschmalhofer
2006-01-18 [perl #38235] Rename (dyn)?classes to (dyn)?pmc
7 src/pmc/fixedintegerarray.pmc - fixed size array for integers only
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
8
9 =head1 DESCRIPTION
10
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
11 This class, FixedIntegerArray, implements an array of fixed size which stores
12 INTVALs. It uses Integer PMCs for all of the conversions.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
13
14 =head2 Functions
15
16 =over 4
17
18 =cut
19
20 */
21
6bdd5f99 » petdance
2010-03-28 headerizer now runs on PMC files
22 /* HEADERIZER HFILE: none */
23 /* HEADERIZER BEGIN: static */
24 /* HEADERIZER END: static */
25
6b817608 » Whiteknight
2009-08-23 [pmc] we don't need need_ext anymore, so BALEETED
26 pmclass FixedIntegerArray auto_attrs provides array {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
27 ATTR INTVAL size; /* number of INTVALs stored in this array */
28 ATTR INTVAL * int_array; /* INTVALs are stored here */
d1f7c985 » Leopold Toetsch
2005-03-22 JIT/i386 ord_i_s*
29
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
46 VTABLE void init() {
4591dbb8 » chromatic
2009-09-03 [HLL] Fixed two compilation-breaking typos accidentally committed in …
47 PObj_custom_destroy_SET(SELF);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
48 }
49
50 /*
51
714df2a3 » tewk
2010-03-10 VTABLE_init_int commented out tests
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) {
4d64842d » leto
2010-03-11 [t][TT#1509] Prevent core dumps by preventing negative length array c…
61 if (size < 0)
26914e12 » Jimmy Zhuo
2010-05-05 changed interp in pmc class to INTERP for unification
62 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
4d64842d » leto
2010-03-11 [t][TT#1509] Prevent core dumps by preventing negative length array c…
63 _("FixedIntegerArray: Cannot set array size to a negative number (%d)"), size);
714df2a3 » tewk
2010-03-10 VTABLE_init_int commented out tests
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
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
71 =item C<void destroy()>
72
73 Destroys the array.
74
75 =cut
76
77 */
78
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
79 VTABLE void destroy() {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
80 INTVAL* int_array;
81 GET_ATTR_int_array(INTERP, SELF, int_array);
82 if (int_array)
4833868f » bacek
2010-02-22 Merge branch 'sys_mem' into trunk
83 Parrot_gc_free_memory_chunk(INTERP, int_array);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
96 VTABLE PMC *clone() {
9822a243 » Leopold Toetsch
2005-06-14 var_args 8 - verify signature during bytecode creation
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
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
104 INTVAL * int_array;
105 PMC * const dest =
a35f6fdb » petdance
2008-02-09 consting & localizing
106 PObj_constant_TEST(SELF)
dc5a60b3 » Whiteknight
2010-02-16 finish the bulk of the conversions, parrot builds
107 ? Parrot_pmc_new_constant(INTERP, SELF->vtable->base_type)
083213a2 » Whiteknight
2010-02-16 start rename of pmc_new to Parrot_pmc_new
108 : Parrot_pmc_new(INTERP, SELF->vtable->base_type);
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
109
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
110 GET_ATTR_int_array(INTERP, SELF, int_array);
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
111
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
112 if (int_array) {
42f27d4d » NotFound
2010-04-24 clean FIA.clone
113 INTVAL size;
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
114 GET_ATTR_size(INTERP, SELF, size);
42f27d4d » NotFound
2010-04-24 clean FIA.clone
115 {
116 INTVAL * const dest_int_array = mem_gc_allocate_n_typed(INTERP,
117 size, INTVAL);
118 mem_copy_n_typed(dest_int_array, int_array,
119 size, INTVAL);
120 SET_ATTR_int_array(INTERP, dest, dest_int_array);
121 }
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
122 SET_ATTR_size(INTERP, dest, size);
4591dbb8 » chromatic
2009-09-03 [HLL] Fixed two compilation-breaking typos accidentally committed in …
123 PObj_custom_destroy_SET(dest);
a35f6fdb » petdance
2008-02-09 consting & localizing
124 }
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
125
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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 */
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
139 VTABLE INTVAL get_bool() {
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
140 INTVAL size;
141 GET_ATTR_size(INTERP, SELF, size);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
142 return (INTVAL)(size != 0);
143 }
144
145 /*
146
147 =item C<INTVAL elements()>
148
149 =cut
150
151 */
152
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
153 VTABLE INTVAL elements() {
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
154 INTVAL size;
155 GET_ATTR_size(INTERP, SELF, size);
156
157 return size;
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
170 VTABLE INTVAL get_integer() {
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
171 INTVAL size;
172 GET_ATTR_size(INTERP, SELF, size);
173 return size;
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
187 VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
188 INTVAL *int_array;
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
189 INTVAL size;
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
190
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
191 GET_ATTR_size(INTERP, SELF, size);
192
193 if (key < 0 || key >= size)
26914e12 » Jimmy Zhuo
2010-05-05 changed interp in pmc class to INTERP for unification
194 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1854520 » chromatic
2004-12-12 Standardize internal exception calls (James deBoer, james at huronbox…
195 "FixedIntegerArray: index out of bounds!");
d1f7c985 » Leopold Toetsch
2005-03-22 JIT/i386 ord_i_s*
196
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
197 GET_ATTR_int_array(INTERP, SELF, int_array);
198 return int_array[key];
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
211 VTABLE INTVAL get_integer_keyed(PMC *key) {
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
212 /* simple int keys only */
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
213 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
214 return SELF.get_integer_keyed_int(k);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
228 VTABLE FLOATVAL get_number_keyed_int(INTVAL key) {
229 const INTVAL i = SELF.get_integer_keyed_int(key);
8275ff5f » chromatic
2007-08-18 [PMC] Fixed a couple of casting warnings of function return values.
230 return (FLOATVAL)i;
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
231 }
232
233 /*
234
95e36766 » Infinoid
2007-08-09 [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
235 =item C<FLOATVAL get_number_keyed(PMC *key)>
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
236
237 Returns the floating-point value of the element at index C<*key>.
238
239 =cut
240
241 */
242
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
243 VTABLE FLOATVAL get_number_keyed(PMC *key) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
244 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
245 return SELF.get_number_keyed_int(k);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
258 VTABLE STRING *get_string_keyed_int(INTVAL key) {
259 PMC * const temp = SELF.get_pmc_keyed_int(key);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
260 return VTABLE_get_string(INTERP, temp);
261 }
bf41b66b » particle
2006-10-25 [PDD07]: ws cleanup in src/, src/dynpmc/, and src/pmc/
262
5a67dace » tewk
2006-10-18 Add get_repr to fixedintegerarray and integer
263 /*
264
265 =item C<STRING *get_repr()>
266
267 Returns the Parrot string representation C<key>.
268
269 =cut
270
271 */
272
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
273 VTABLE STRING *get_repr() {
a35f6fdb » petdance
2008-02-09 consting & localizing
274 STRING *res = CONST_STRING(INTERP, "[ ");
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
275 INTVAL n;
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
276 INTVAL j;
5a67dace » tewk
2006-10-18 Add get_repr to fixedintegerarray and integer
277
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
278 GET_ATTR_size(INTERP, SELF, n);
279
5a67dace » tewk
2006-10-18 Add get_repr to fixedintegerarray and integer
280 for (j = 0; j < n; ++j) {
a35f6fdb » petdance
2008-02-09 consting & localizing
281 PMC * const val = SELF.get_pmc_keyed_int(j);
9b0f14ac » bacek
2010-04-21 Everybody freeze! Immutable strings enters the building.
282 res = Parrot_str_concat(INTERP, res, VTABLE_get_repr(INTERP, val));
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
283
5a67dace » tewk
2006-10-18 Add get_repr to fixedintegerarray and integer
284 if (j < n - 1)
9b0f14ac » bacek
2010-04-21 Everybody freeze! Immutable strings enters the building.
285 res = Parrot_str_concat(INTERP, res, CONST_STRING(INTERP, ", "));
5a67dace » tewk
2006-10-18 Add get_repr to fixedintegerarray and integer
286 }
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
287
9b0f14ac » bacek
2010-04-21 Everybody freeze! Immutable strings enters the building.
288 res = Parrot_str_concat(INTERP, res, CONST_STRING(INTERP, " ]"));
5a67dace » tewk
2006-10-18 Add get_repr to fixedintegerarray and integer
289 return res;
290 }
291
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
303 VTABLE STRING *get_string_keyed(PMC *key) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
304 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
305 return SELF.get_string_keyed_int(k);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
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
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
319 VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
320 const INTVAL val = SELF.get_integer_keyed_int(key);
75d112fd » NotFound
2010-05-01 implement Integer vtable init_int and use it in several places where …
321 PMC * const ret = Parrot_pmc_new_init_int(INTERP, enum_class_Integer, val);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
322 return ret;
323 }
324
325 /*
326
327 =item C<PMC *get_pmc_keyed(PMC *key)>
328
329 Returns the PMC value of the element at index C<*key>.
330
331 =cut
332
333 */
334
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
335 VTABLE PMC *get_pmc_keyed(PMC *key) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
336 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
337 return SELF.get_pmc_keyed_int(k);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
338 }
339
340 /*
341
342 =item C<void set_integer_native(INTVAL size)>
343
344 Resizes the array to C<size> elements.
345
346 =cut
347
348 */
349
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
350 VTABLE void set_integer_native(INTVAL size) {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
351 INTVAL *int_array;
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
352 INTVAL cur_size;
353
354 GET_ATTR_size(INTERP, SELF, cur_size);
355
356 if (cur_size || size < 1)
2255840f » allisonrandal
2008-08-02 [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
357 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1f7c985 » Leopold Toetsch
2005-03-22 JIT/i386 ord_i_s*
358 "FixedIntegerArray: Can't resize!");
2255840f » allisonrandal
2008-08-02 [pdd17pmc] Merging the pdd25cx branch into trunk for r26555 to r29949.
359
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
360 SET_ATTR_size(INTERP, SELF, size);
361 GET_ATTR_int_array(INTERP, SELF, int_array);
7a96a218 » bschmalhofer
2009-01-28 [codingstd] tabs.t and trailing_space.t
362 SET_ATTR_int_array(INTERP, SELF,
4833868f » bacek
2010-02-22 Merge branch 'sys_mem' into trunk
363 mem_gc_realloc_n_typed(INTERP, int_array, size, INTVAL));
4591dbb8 » chromatic
2009-09-03 [HLL] Fixed two compilation-breaking typos accidentally committed in …
364 PObj_custom_destroy_SET(SELF);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
365 }
366
367 /*
368
369 =item C<void set_integer_keyed_int(INTVAL key, INTVAL value)>
370
371 Sets the integer value of the element at index C<key> to C<value>.
372
373 =cut
374
375 */
376
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
377 VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
378 INTVAL *int_array;
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
379 INTVAL size;
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
380
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
381 GET_ATTR_size(INTERP, SELF, size);
382
383 if (key < 0 || key >= size)
26914e12 » Jimmy Zhuo
2010-05-05 changed interp in pmc class to INTERP for unification
384 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
d1854520 » chromatic
2004-12-12 Standardize internal exception calls (James deBoer, james at huronbox…
385 "FixedIntegerArray: index out of bounds!");
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
386
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
387 GET_ATTR_int_array(INTERP, SELF, int_array);
388 int_array[key] = value;
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
389 }
390
391 /*
392
393 =item C<void set_integer_keyed(PMC *key, INTVAL value)>
394
395 Sets the integer value of the element at index C<key> to C<value>.
396
397 =cut
398
399 */
400
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
401 VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
402 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
403 SELF.set_integer_keyed_int(k, value);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
404 }
405
406 /*
407
408 =item C<void set_number_keyed_int(INTVAL key, FLOATVAL value)>
409
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
410 Sets the floating-point value of the element at index C<key> to C<value>.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
411
412 =cut
413
414 */
415
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
416 VTABLE void set_number_keyed_int(INTVAL key, FLOATVAL value) {
417 SELF.set_integer_keyed_int(key, (INTVAL)value);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
418 }
419
420 /*
421
422 =item C<void set_number_keyed(PMC *key, FLOATVAL value)>
423
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
424 Sets the floating-point value of the element at index C<key> to C<value>.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
425
426 =cut
427
428 */
429
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
430 VTABLE void set_number_keyed(PMC *key, FLOATVAL value) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
431 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
432 SELF.set_number_keyed_int(k, value);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
433 }
d1f7c985 » Leopold Toetsch
2005-03-22 JIT/i386 ord_i_s*
434
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
435 /*
436
437 =item C<void set_string_keyed_int(INTVAL key, STRING *value)>
438
439 Sets the Parrot string value of the element at index C<key> to C<value>.
440
441 =cut
442
443 */
444
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
445 VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
06e2d1ee » NotFound
2010-04-30 avoid a temporary PMC in FPA set_string_keyed_int
446 const INTVAL tempInt = Parrot_str_to_int(INTERP, value);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
447 SELF.set_integer_keyed_int(key, tempInt);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
448 }
449
450 /*
451
95e36766 » Infinoid
2007-08-09 [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
452 =item C<void set_string_keyed(PMC *key, STRING *value)>
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
453
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
454 Sets the string value of the element at index C<key> to C<value>.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
455
456 =cut
457
458 */
459
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
460 VTABLE void set_string_keyed(PMC *key, STRING *value) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
461 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
462 SELF.set_string_keyed_int(k, value);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
463 }
464
465 /*
466
467 =item C<void set_pmc_keyed_int(INTVAL key, PMC *src)>
468
469 Sets the PMC value of the element at index C<key> to C<*src>.
470
471 =cut
472
473 */
474
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
475 VTABLE void set_pmc_keyed_int(INTVAL key, PMC *src) {
a35f6fdb » petdance
2008-02-09 consting & localizing
476 const INTVAL tempInt = VTABLE_get_integer(INTERP, src);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
477 SELF.set_integer_keyed_int(key, tempInt);
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
478 }
479
480 /*
481
95e36766 » Infinoid
2007-08-09 [pmc] PDD07-ize function signatures in src/pmc/[b-f]*.pmc
482 =item C<void set_pmc_keyed(PMC *key, PMC *value)>
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
483
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
484 Sets the string value of the element at index C<key> to C<value>.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
485
486 =cut
487
488 */
489
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
490 VTABLE void set_pmc_keyed(PMC *key, PMC *value) {
757f3a87 » chromatic
2009-05-08 [PMC] Replaced all uses of key_integer() outside of Key PMC and src/k…
491 const INTVAL k = VTABLE_get_integer(INTERP, key);
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
492 SELF.set_pmc_keyed_int(k, value);
493 }
494
495 METHOD sort(PMC *cmp_func) {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
496 INTVAL *int_array;
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
497 UINTVAL n;
498 INTVAL size;
499
500 GET_ATTR_size(INTERP, SELF, size);
501
502 n = (UINTVAL)size;
59661f18 » allisonrandal
2008-03-11 [pdd17pmc] Merging the pdd17pmc branch into trunk (r24435 to r26307).
503
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
504 if (n > 1) {
505 GET_ATTR_int_array(INTERP, SELF, int_array);
26914e12 » Jimmy Zhuo
2010-05-05 changed interp in pmc class to INTERP for unification
506 Parrot_quicksort(INTERP, (void**)int_array, n, cmp_func);
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
507 }
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
508 }
509
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
510 /*
511
0c38764c » bacek
2009-09-20 [core] Implement FixedIntegerArray.is_equal
512 =item C<INTVAL is_equal(PMC *value)>
513
514 The C<==> operation. Compares two array to hold equal elements.
515
516 =cut
517
518 */
519
520 VTABLE INTVAL is_equal(PMC *value) {
521 INTVAL j, n;
522
523 if (value->vtable->base_type != SELF->vtable->base_type)
524 return 0;
525
526 n = SELF.elements();
527
528 if (VTABLE_elements(INTERP, value) != n)
529 return 0;
530
531 for (j = 0; j < n; ++j) {
532 INTVAL item1 = SELF.get_integer_keyed_int(j);
533 INTVAL item2 = VTABLE_get_integer_keyed_int(INTERP, value, j);
534
535 if (item1 != item2)
536 return 0;
537 }
538
539 return 1;
540 }
541
542 /*
543
bd8aacd2 » cotto
2009-03-22 [PMC] add get_iter VTABLE function and tests to *IntegerArray
544 =item C<PMC *get_iter()>
545
546 Return a new Iterator for this PMC.
547
548 =cut
549
550 */
551
552 VTABLE PMC *get_iter() {
083213a2 » Whiteknight
2010-02-16 start rename of pmc_new to Parrot_pmc_new
553 return Parrot_pmc_new_init(INTERP, enum_class_ArrayIterator, SELF);
bd8aacd2 » cotto
2009-03-22 [PMC] add get_iter VTABLE function and tests to *IntegerArray
554 }
555
556 /*
557
b101f2ca » darbelo
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
558 =item C<void visit(PMC *info)>
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
559
560 This is used by freeze/thaw to visit the contents of the array.
561
562 C<*info> is the visit info, (see F<include/parrot/pmc_freeze.h>).
563
b101f2ca » darbelo
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
564 =item C<void freeze(PMC *info)>
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
565
566 Used to archive the array.
567
b101f2ca » darbelo
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
568 =item C<void thaw(PMC *info)>
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
569
570 Used to unarchive the array.
571
572 =cut
573
574 */
575
b101f2ca » darbelo
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
576 /*VTABLE void visit(PMC *info) {
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
577 SUPER(info);
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
578 }*/
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
579
b101f2ca » darbelo
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
580 VTABLE void freeze(PMC *info) {
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
581 INTVAL *int_array;
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
582 INTVAL i, n;
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
583
584 SUPER(info);
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
585
8d334299 » chromatic
2009-05-01 [PMC] Replaced vtable function calls to find size of fixed integer ar…
586 GET_ATTR_size(INTERP, SELF, n);
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
587 VTABLE_push_integer(INTERP, info, n);
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
588 GET_ATTR_int_array(INTERP, SELF, int_array);
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
589
590 for (i = 0; i < n; ++i)
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
591 VTABLE_push_integer(INTERP, info, int_array[i]);
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
592 }
593
b101f2ca » darbelo
2010-02-02 Merge pmc_freeze_with_pmcs into trunk.
594 VTABLE void thaw(PMC *info) {
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
595 INTVAL n;
e5dead2e » cotto
2009-01-27 [pmc] update *IntegerArray to use ATTRs
596
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
597 SUPER(info);
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
598
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
599 SET_ATTR_size(INTERP, SELF, 0);
600 SET_ATTR_int_array(INTERP, SELF, NULL);
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
601
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
602 if ((n = VTABLE_shift_integer(INTERP, info))) {
603 INTVAL i;
604 INTVAL *int_array;
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
605
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
606 SELF.set_integer_native(n);
607 GET_ATTR_int_array(INTERP, SELF, int_array);
894d4481 » chromatic
2007-09-04 [PMC] Minor cleanups and tidyings.
608
4c434759 » plobsing
2010-01-13 merge branch pmc_freeze_cleanup
609 for (i = 0; i < n; ++i)
610 int_array[i] = VTABLE_shift_integer(INTERP, info);
6287ae3c » Leopold Toetsch
2005-07-03 add missing fixedintegerarray.freeze and .thaw
611 }
612 }
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
613 }
614
615 /*
616
617 =back
618
619 =head1 SEE ALSO
620
1e8a4ab7 » Dan Sugalski
2004-10-19 this patch adds some relevant 'push' ops to the resizable PMCs, descr…
621 F<docs/pdds/pdd17_basic_types.pod>.
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
622
623 =cut
624
625 */
626
627 /*
628 * Local variables:
72575ae0 » bschmalhofer
2006-10-09 #40481: [PATCH] C-code coda in pmc files
629 * c-file-style: "parrot"
4498fea9 » Dan Sugalski
2004-06-12 This patch adds the above Fixed*Array classes. They are basic tests for
630 * End:
631 * vim: expandtab shiftwidth=4:
72575ae0 » bschmalhofer
2006-10-09 #40481: [PATCH] C-code coda in pmc files
632 */
Something went wrong with that request. Please try again.