[system] / trunk / pg / lib / Parser / Item.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Parser/Item.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5508 Revision 5509
4# are things like binary operator, function call, and so on. 4# are things like binary operator, function call, and so on.
5# 5#
6package Parser::Item; 6package Parser::Item;
7use strict; 7use strict;
8use UNIVERSAL; 8use UNIVERSAL;
9use Scalar::Util;
9 10
10# 11#
11# Make these available to Parser items 12# Make these available to Parser items
12# 13#
13sub isa {UNIVERSAL::isa(@_)} 14sub isa {UNIVERSAL::isa(@_)}
14sub can {UNIVERSAL::can(@_)} 15sub can {UNIVERSAL::can(@_)}
16
17sub weaken {Scalar::Util::weaken((shift)->{equation})}
15 18
16# 19#
17# Return the class name of an item 20# Return the class name of an item
18# 21#
19sub class { 22sub class {
133# 136#
134sub copy { 137sub copy {
135 my $self = shift; my $equation = shift; 138 my $self = shift; my $equation = shift;
136 my $new = {%{$self}}; 139 my $new = {%{$self}};
137 if (ref($self) ne 'HASH') { 140 if (ref($self) ne 'HASH') {
138 bless $new, ref($self);
139 $new->{equation} = $equation if defined($equation); 141 $new->{equation} = $equation if defined($equation);
140 $new->{ref} = undef; 142 $new->{ref} = undef;
143 bless $new, ref($self);
144 $new->weaken;
141 } 145 }
142 $new->{type} = copy($self->{type}) if defined($self->{type}); 146 $new->{type} = copy($self->{type}) if defined($self->{type});
143 return $new; 147 return $new;
144} 148}
145 149

Legend:
Removed from v.5508  
changed lines
  Added in v.5509

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9