[svn:parrot] r39562 - branches/tt761_keys_revamp/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun Jun 14 10:17:09 UTC 2009
Author: bacek
Date: Sun Jun 14 10:17:08 2009
New Revision: 39562
URL: https://trac.parrot.org/parrot/changeset/39562
Log:
[pmc] When we try to instanciate Iterator for Array fall to ArrayIterator.
Modified:
branches/tt761_keys_revamp/src/pmc/iterator.pmc
Modified: branches/tt761_keys_revamp/src/pmc/iterator.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/iterator.pmc Sun Jun 14 10:16:46 2009 (r39561)
+++ branches/tt761_keys_revamp/src/pmc/iterator.pmc Sun Jun 14 10:17:08 2009 (r39562)
@@ -101,17 +101,23 @@
*/
VTABLE void init_pmc(PMC *aggregate) {
- Parrot_Iterator_attributes *attrs =
- mem_allocate_zeroed_typed(Parrot_Iterator_attributes);
-
- attrs->aggregate = aggregate;
- attrs->key = PMCNULL;
- PMC_data(SELF) = attrs;
+ if (VTABLE_does(INTERP, aggregate, CONST_STRING(INTERP, "array"))) {
+ SELF = pmc_reuse_init(INTERP, SELF, enum_class_ArrayIterator, aggregate, 0);
+ return;
+ }
+ else {
+ Parrot_Iterator_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_Iterator_attributes);
+
+ attrs->aggregate = aggregate;
+ attrs->key = PMCNULL;
+ PMC_data(SELF) = attrs;
- PObj_custom_mark_destroy_SETALL(SELF);
+ PObj_custom_mark_destroy_SETALL(SELF);
- /* by default, iterate from start */
- SELF.set_integer_native(ITERATE_FROM_START);
+ /* by default, iterate from start */
+ SELF.set_integer_native(ITERATE_FROM_START);
+ }
}
/*
More information about the parrot-commits
mailing list