Branch: refs/heads/davem/line Home: https://github.com/Perl/perl5 Commit: 193e8180e5b95830b28369f5dfd1fdfffddaae79 https://github.com/Perl/perl5/commit/193e8180e5b95830b28369f5dfd1fdfffddaae79 Author: David Mitchell <da...@iabyn.com> Date: 2024-02-22 (Thu, 22 Feb 2024)
Changed paths: M Porting/deparse-skips.txt M lib/B/Deparse.pm M lib/B/Deparse.t M lib/B/Op_private.pm M opcode.h M regen/op_private M toke.c Log Message: ----------- add OPpCONST_TOKEN_* flags to aid deparsing Code like my $line = __LINE__; my $file = __FILE__; my $pkg = __PACKAGE__; was being deparsed as my $line = '42'; my $file = 'foo.pl'; my $pkg = 'Foo::Bar'; because __LINE__ etc are converted by the lexer into an ordinary OP_CONST, whose SV is just a plain string holding the line number or whatever. This commit uses two spare bits in op_private on OP_CONST ops to create a 4-valued bit field, indicating whether the op is a normal constant or one of those three special constant tokens. This field is then used by Deparse to output a literal "__LINE__" or whatever rather than the value of the constant. This fixes one failing test file under cd t; ./TEST -deparse and removes one (but not all) sources of failure from three others. Note that __SUB__ is already special-cased to deparse literally (except when used outside a sub where it deparses as 'undef'), while the special tokens __DATA__, __END__ and __CLASS__ don't generate OP_CONSTs. To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications