diff options
author | Gerard Goossen <gerard@ggoossen.net> | 2009-11-12 14:31:43 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-11-12 16:25:36 +0100 |
commit | d343c3ef4538135207ab69cd65d1bb1ef5403ccc (patch) | |
tree | 1993aef1b199c1df713033677bb02fdac2e8dfd5 /scope.h | |
parent | af24cc9d0ee84635a0e9165232ec7b091c4596f3 (diff) | |
download | perl-d343c3ef4538135207ab69cd65d1bb1ef5403ccc.tar.gz |
Add ENTER_with_name and LEAVE_with_name to automaticly check for matching ENTER/LEAVE when debugging is enabled
Diffstat (limited to 'scope.h')
-rw-r--r-- | scope.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -100,6 +100,20 @@ Opening bracket on a callback. See C<LEAVE> and L<perlcall>. =for apidoc Ams||LEAVE Closing bracket on a callback. See C<ENTER> and L<perlcall>. +=over + +=item ENTER_with_name(name) + +Same as C<ENTER>, but when debugging is enabled it also associates the +given literal string with the new scope. + +=item LEAVE_with_name(name) + +Same as C<LEAVE>, but when debugging is enabled it first checks that the +scope has the given name. Name must be a literal string. + +=back + =cut */ @@ -117,9 +131,23 @@ Closing bracket on a callback. See C<ENTER> and L<perlcall>. DEBUG_SCOPE("LEAVE") \ pop_scope(); \ } STMT_END +#define ENTER_with_name(name) \ + STMT_START { \ + push_scope(); \ + PL_scopestack_name[PL_scopestack_ix-1] = name; \ + DEBUG_SCOPE("ENTER \"" name "\"") \ + } STMT_END +#define LEAVE_with_name(name) \ + STMT_START { \ + DEBUG_SCOPE("LEAVE \"" name "\"") \ + assert(strEQ(PL_scopestack_name[PL_scopestack_ix-1], name)); \ + pop_scope(); \ + } STMT_END #else #define ENTER push_scope() #define LEAVE pop_scope() +#define ENTER_with_name(name) ENTER +#define LEAVE_with_name(name) LEAVE #endif #define LEAVE_SCOPE(old) if (PL_savestack_ix > old) leave_scope(old) |