Skip to content

Instantly share code, notes, and snippets.

@mlschroe
Created November 15, 2011 17:35
Show Gist options
  • Save mlschroe/1367725 to your computer and use it in GitHub Desktop.
Save mlschroe/1367725 to your computer and use it in GitHub Desktop.
diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm
index cc1e558..9b731ac 100644
--- a/src/Perl6/Actions.pm
+++ b/src/Perl6/Actions.pm
@@ -3811,6 +3814,7 @@ class Perl6::Actions is HLL::Actions {
:pasttype('callmethod'), :name('clone'),
$code
);
+ $closure := PAST::Op.new( :pirop('perl6_capture_lex__0P'), $closure);
$closure<past_block> := $code<past_block>;
$closure<code_object> := $code<code_object>;
return $closure;
diff --git a/src/ops/perl6.ops b/src/ops/perl6.ops
index 7569467..cea1fa4 100644
--- a/src/ops/perl6.ops
+++ b/src/ops/perl6.ops
@@ -1428,6 +1428,17 @@ inline op perl6_invoke_catchhandler(invar PMC, in PMC) :flow {
}
+inline op perl6_capture_lex(in PMC) {
+ if ($1->vtable->base_type == smo_id) {
+ Rakudo_Code *code_obj = (Rakudo_Code *)PMC_data($1);
+ Parrot_sub_capture_lex(interp, code_obj->_do);
+ }
+ else {
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Can only use perl6_capture_lex with a SixModelObject");
+ }
+}
+
/*
* Local variables:
* c-file-style: "parrot"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment