Skip to content

Commit

Permalink
P6Invocation should become more Iterator-ish.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed May 6, 2009
1 parent 663cde0 commit ee7d456
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions src/pmc/p6invocation.pmc
Expand Up @@ -92,6 +92,16 @@ pmclass P6Invocation need_ext dynpmc group perl6_group {
SETATTR_P6Invocation_position(interp, copy, position);
return copy;
}

VTABLE INTVAL get_bool() {
PMC *candidates;
INTVAL position;

/* Get candidates and position, and check if we have more candidates. */
GETATTR_P6Invocation_candidate_list(interp, SELF, candidates);
GETATTR_P6Invocation_position(interp, SELF, position);
return position < VTABLE_elements(interp, candidates);
}

VTABLE opcode_t *invoke(void *next) {
STRING *lexname = CONST_STRING(interp, "__CANDIATE_LIST__");
Expand All @@ -115,14 +125,8 @@ pmclass P6Invocation need_ext dynpmc group perl6_group {
return addr;
}

METHOD INTVAL have_more_candidates() {
PMC *candidates;
INTVAL position, result;

/* Get candidates and position, and check if we have more candidates. */
GETATTR_P6Invocation_candidate_list(interp, SELF, candidates);
GETATTR_P6Invocation_position(interp, SELF, position);
result = position < VTABLE_elements(interp, candidates);
RETURN(INTVAL result);
METHOD PMC *get() {
PMC *next = get_next_candidate(interp, SELF);
RETURN(PMC *next);
}
}
6 changes: 3 additions & 3 deletions t/pmc/p6invocation-1.t
Expand Up @@ -46,7 +46,7 @@ Test the P6Invocation PMC.
ok_3:
say "ok 3"

$I0 = $P0.'have_more_candidates'()
$I0 = istrue $P0
if $I0 != 0 goto ok_4
print "not"
ok_4:
Expand All @@ -59,7 +59,7 @@ Test the P6Invocation PMC.
.lex '__CANDIATE_LIST__', $P0
say "ok 5"

$I0 = $P0.'have_more_candidates'()
$I0 = istrue $P0
if $I0 != 0 goto ok_6
print "not"
ok_6:
Expand All @@ -72,7 +72,7 @@ Test the P6Invocation PMC.
.lex '__CANDIATE_LIST__', $P0
say "ok 7"

$I0 = $P0.'have_more_candidates'()
$I0 = istrue $P0
if $I0 == 0 goto ok_8
print "not"
ok_8:
Expand Down

0 comments on commit ee7d456

Please sign in to comment.