Skip to content

Commit 978dc43

Browse files
committed
Prepare for eliminating clone callback prop use.
1 parent afaf87d commit 978dc43

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/NQP/Actions.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class NQP::Actions is HLL::Actions {
123123
$unit
124124
);
125125

126+
$*W.cleanup();
127+
126128
make $compunit;
127129
}
128130

src/NQP/World.pm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ class NQP::World is HLL::World {
2323
# Mapping of sub IDs to SC indexes of code stubs.
2424
has %!code_stub_sc_idx;
2525

26+
# Clear-up tasks.
27+
has @!clearup_tasks;
28+
2629
method BUILD(*%opts) {
2730
@!BLOCKS := nqp::list();
2831
%!code_objects_to_fix_up := nqp::hash();
2932
%!code_object_types := nqp::hash();
3033
%!code_object_fixup_list := nqp::hash();
3134
%!code_stub_sc_idx := nqp::hash();
35+
@!clearup_tasks := nqp::list();
3236

3337
if nqp::defined(%*COMPILING<%?OPTIONS><dynext>) {
3438
my $dynext_path := %*COMPILING<%?OPTIONS><dynext>;
@@ -256,6 +260,12 @@ class NQP::World is HLL::World {
256260
$compiled(|@args, |%named);
257261
};
258262

263+
# Create code object, if we'll need one.
264+
my $code_obj;
265+
if $have_code_type {
266+
$code_obj := nqp::create($code_type);
267+
}
268+
259269
# See if we already have our compile-time dummy. If not, create it.
260270
my $fixups := QAST::Stmts.new();
261271
my $dummy;
@@ -319,7 +329,6 @@ class NQP::World is HLL::World {
319329
# code object.
320330
if $have_code_type {
321331
# Create it now.
322-
my $code_obj := nqp::create($code_type);
323332
nqp::bindattr($code_obj, $code_type, '$!do', $dummy);
324333
nqp::bindattr($code_obj, $code_type, '$!dispatchees', nqp::list())
325334
if $is_dispatcher;
@@ -500,6 +509,11 @@ class NQP::World is HLL::World {
500509
)));
501510
}
502511

512+
# Does cleanups.
513+
method cleanup() {
514+
for @!clearup_tasks { $_() }
515+
}
516+
503517
# Checks if the given name is known anywhere in the lexpad
504518
# and with lexical scope.
505519
method is_lexical($name) {

src/core/NQPRoutine.pm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ my knowhow NQPRoutine {
44
has $!dispatchees;
55
has $!dispatch_cache;
66
has $!dispatch_order;
7+
has $!clone_callback;
78

89
# Adds a multi-dispatch candidate.
910
method add_dispatchee($code) {
@@ -35,6 +36,9 @@ my knowhow NQPRoutine {
3536
if nqp::defined($clone_callback) {
3637
$clone_callback($!do, $do, $der);
3738
}
39+
unless nqp::isnull($!clone_callback) {
40+
$!clone_callback($!do, $do, $der);
41+
}
3842

3943
$der
4044
}
@@ -334,6 +338,9 @@ my knowhow NQPRoutine {
334338
if nqp::defined($clone_callback) {
335339
$clone_callback($!do, $do, $der);
336340
}
341+
unless nqp::isnull($!clone_callback) {
342+
$!clone_callback($!do, $do, $der);
343+
}
337344

338345
$der
339346
}
@@ -367,6 +374,7 @@ my knowhow NQPRegex {
367374
has %!alt_nfas;
368375
has $!generic_nfa;
369376
has @!nested_codes;
377+
has $!clone_callback;
370378
method SET_CAPS($caps) {
371379
$!caps := $caps;
372380
}
@@ -413,6 +421,9 @@ my knowhow NQPRegex {
413421
if nqp::defined($clone_callback) {
414422
$clone_callback($!do, $do, $der);
415423
}
424+
unless nqp::isnull($!clone_callback) {
425+
$!clone_callback($!do, $do, $der);
426+
}
416427

417428
$der
418429
}

0 commit comments

Comments
 (0)