@@ -5,6 +5,21 @@ my class ParseShared is export {
5
5
has int $ ! highwater ;
6
6
has @ ! highexpect ;
7
7
has % ! marks ;
8
+
9
+ # Follow is a little simple usage tracing infrastructure, used by the
10
+ # !cursor_start_* methods when uncommented.
11
+ my % cursors_created ;
12
+ my $ cursors_total ;
13
+ method log_cc ($ name ) {
14
+ % cursors_created {$ name }++ ;
15
+ $ cursors_total ++ ;
16
+ }
17
+ method log_dump () {
18
+ for % cursors_created {
19
+ say ($ _ . value ~ " \t " ~ $ _ . key );
20
+ }
21
+ say (" TOTAL: " ~ $ cursors_total );
22
+ }
8
23
}
9
24
10
25
role NQPCursorRole is export {
@@ -109,6 +124,8 @@ role NQPCursorRole is export {
109
124
my @ start_result ;
110
125
my $ new := nqp ::create(self );
111
126
my $ sub := nqp ::callercode();
127
+ # Uncomment following to log cursor creation.
128
+ # $!shared.log_cc(nqp::getcodename($sub));
112
129
nqp ::bindattr($ new , $ ? CLASS , ' $!shared' , $ ! shared );
113
130
nqp ::bindattr($ new , $ ? CLASS , ' $!regexsub' , nqp ::ifnull(nqp ::getcodeobj($ sub ), $ sub ));
114
131
if nqp :: defined ($ ! restart ) {
@@ -138,6 +155,8 @@ role NQPCursorRole is export {
138
155
method ! cursor_start_cur () {
139
156
my $ new := nqp ::create(self );
140
157
my $ sub := nqp ::callercode();
158
+ # Uncomment following to log cursor creation.
159
+ # $!shared.log_cc(nqp::getcodename($sub));
141
160
nqp ::bindattr($ new , $ ? CLASS , ' $!shared' , $ ! shared );
142
161
nqp ::bindattr($ new , $ ? CLASS , ' $!regexsub' , nqp ::ifnull(nqp ::getcodeobj($ sub ), $ sub ));
143
162
if nqp :: defined ($ ! restart ) {
0 commit comments