line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::References::RewriteDereferences; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
748
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
5
|
use Readonly; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :severities }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
112
|
use base 'Perl::ToPerl6::Transformer'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
366
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform %x{a} to %x{'a'}}; |
15
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => |
16
|
|
|
|
|
|
|
q{Perl6 assumes that braces are code blocks, so any content must be compilable}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
0
|
4
|
sub run_after { return 'Operators::FormatOperators' } |
21
|
1
|
|
|
1
|
0
|
3
|
sub supported_parameters { return () } |
22
|
1
|
|
|
1
|
1
|
5
|
sub default_necessity { return $NECESSITY_HIGHEST } |
23
|
0
|
|
|
0
|
1
|
|
sub default_themes { return qw( core ) } |
24
|
|
|
|
|
|
|
sub applies_to { |
25
|
|
|
|
|
|
|
return sub { |
26
|
0
|
0
|
0
|
0
|
|
|
$_[1]->isa('PPI::Token::Cast') and |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
27
|
|
|
|
|
|
|
$_[1]->next_sibling and |
28
|
|
|
|
|
|
|
$_[1]->next_sibling->isa('PPI::Structure::Block') and |
29
|
|
|
|
|
|
|
$_[1]->next_sibling->start->content eq '{' and |
30
|
|
|
|
|
|
|
$_[1]->next_sibling->finish->content eq '}' |
31
|
|
|
|
|
|
|
} |
32
|
0
|
|
|
0
|
1
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub transform { |
37
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
38
|
0
|
|
|
|
|
|
my $next = $elem->next_sibling; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$next->start->set_content('('); |
41
|
0
|
|
|
|
|
|
$next->finish->set_content(')'); |
42
|
0
|
0
|
|
|
|
|
if ( $elem->content eq '$#' ) { |
43
|
0
|
|
|
|
|
|
$elem->set_content('@'); |
44
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after( |
45
|
|
|
|
|
|
|
PPI::Token::Word->new('end') |
46
|
|
|
|
|
|
|
); |
47
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after( |
48
|
|
|
|
|
|
|
PPI::Token::Operator->new('.') |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::References::RewriteDereferences - Transform %{$foo} to %($foo) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AFFILIATION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
71
|
|
|
|
|
|
|
distribution. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Perl6 dereferencing uses C<%()> and C<@()> because C<()> would be a code block otherwise: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
%{$foo} --> %($foo) |
79
|
|
|
|
|
|
|
%$foo --> %$foo |
80
|
|
|
|
|
|
|
@{$foo} --> @($foo) |
81
|
|
|
|
|
|
|
@$foo --> @$foo |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Transforms dereferences outside of comments, heredocs, strings and POD. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 CONFIGURATION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
98
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
############################################################################## |
103
|
|
|
|
|
|
|
# Local Variables: |
104
|
|
|
|
|
|
|
# mode: cperl |
105
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
106
|
|
|
|
|
|
|
# fill-column: 78 |
107
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
108
|
|
|
|
|
|
|
# c-indentation-style: bsd |
109
|
|
|
|
|
|
|
# End: |
110
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |