Skip to content

Commit

Permalink
Stub out capture snapshots in signatures. Note we can't do them as re…
Browse files Browse the repository at this point in the history
…al snapshots until we get CaptureCursor style stuff in place, but we should be able to quickly get equivalent semantics in place, and when we do get CaptureCursor the infrastructure is there to use.
  • Loading branch information
jnthn committed Feb 13, 2010
1 parent da4a858 commit 2b06cc0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/binder/bind.c
Expand Up @@ -509,8 +509,26 @@ Rakudo_binding_bind_signature(PARROT_INTERP, PMC *lexpad, PMC *signature,

/* Now we'll walk through the signature and go about binding things. */
for (i = 0; i < num_elements; i++) {
/* Is it looking for us to bind a capture here? */
if (elements[i]->flags & SIG_ELEM_IS_CAPTURE) {
/* XXX In the long run, we need to snapshot any current CaptureCursor.
* For now, we don't have that, so we just build off the current
* capture. */
PMC *ns = Parrot_get_ctx_HLL_namespace(interp);
PMC *snapper = Parrot_get_global(interp, ns, string_from_literal(interp, "!snapshot_capture"));
PMC *snapshot = PMCNULL;
Parrot_ext_call(interp, snapper, "PiIP->P", capture, cur_pos_arg, named_args_copy, &snapshot);
bind_fail = Rakudo_binding_bind_one_param(interp, lexpad, elements[i], snapshot,
no_nom_type_check, error);
if (bind_fail) {
if (pos_from_named)
mem_sys_free(pos_from_named);
return bind_fail;
}
}

/* Is it a positional sourced from a named? */
if (pos_from_named && pos_from_named[i]) {
else if (pos_from_named && pos_from_named[i]) {
/* We have the value - try bind this parameter. */
bind_fail = Rakudo_binding_bind_one_param(interp, lexpad, elements[i],
pos_from_named[i], no_nom_type_check, error);
Expand Down
23 changes: 23 additions & 0 deletions src/builtins/Capture.pir
Expand Up @@ -92,6 +92,29 @@ XXX Returns Parrot Hash, not Perl 6 Hash.

=back

=head2 Functions

=over 4

=item !snapshot_capture

Snapshots the current capture cursor.

Well, akshually...until we implement Capture Cursor it just kinda pretends
to. :-) Hands back a Capture containing the snapshot.

=cut

.namespace []
.sub '!snapshot_capture'
.param pmc capture
.param int pos_position
.param pmc nameds_unbound
die "Capture snapshots in signatures not yet implemented."
.end

=back

=cut

# Local Variables:
Expand Down

0 comments on commit 2b06cc0

Please sign in to comment.