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

Diff of /trunk/pg/lib/Parser/Context/Functions.pm

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

Revision 3482 Revision 3483
17 17
18# 18#
19# Remove a function from the list by assigning it 19# Remove a function from the list by assigning it
20# the undefined function. This means it will still 20# the undefined function. This means it will still
21# be recognized by the parser, but will generate an 21# be recognized by the parser, but will generate an
22# error message whenever it is used. 22# error message whenever it is used. The old class
23# is saved so that it can be redefined again.
23# 24#
24sub undefine { 25sub undefine {
25 my $self = shift; 26 my $self = shift;
26 my @data = (); 27 my @data = ();
27 foreach my $x (@_) {push(@data,$x => {class => 'Parser::Function::undefined'})} 28 foreach my $x (@_) {
29 push(@data,$x => {
30 oldClass => $self->get($x)->{class},
31 class => 'Parser::Function::undefined',
32 });
33 }
34 $self->set(@data);
35}
36
37sub redefine {
38 my $self = shift; my $X = shift;
39 return $self->SUPER::redefine($X,@_) if scalar(@_) > 0;
40 $X = [$X] unless ref($X) eq 'ARRAY';
41 my @data = ();
42 foreach my $x (@{$X}) {
43 my $oldClass = $self->get($x)->{oldClass};
44 push(@data,$x => {class => $oldClass, oldClass => undef})
45 if $oldClass;
46 }
28 $self->set(@data); 47 $self->set(@data);
29} 48}
30 49
31######################################################################### 50#########################################################################
32# 51#
69} 88}
70 89
71sub enable {Enable(@_)} 90sub enable {Enable(@_)}
72sub Enable { 91sub Enable {
73 my $context = Parser::Context->current; 92 my $context = Parser::Context->current;
93 my $functions = $Parser::Context::Default::fullContext->{functions};
74 if (ref($_[0]) ne "") {$context = (shift)->{context}} 94 if (ref($_[0]) ne "") {$context = (shift)->{context}}
75 my @names = @_; my ($list,$name); 95 my @names = @_; my ($list,$name);
76 while ($name = shift(@names)) { 96 while ($name = shift(@names)) {
77 $list = $Category{$name}; 97 $list = $Category{$name};
78 $list = [$name] if !$list && $context->{functions}{$name}; 98 $list = [$name] if !$list && $context->{functions}{$name};
79 unless (defined($list)) {warn "Undefined function or category '$name'"; next} 99 unless (defined($list)) {warn "Undefined function or category '$name'"; next}
80 if ($list->[0] eq '_alias_') 100 if ($list->[0] eq '_alias_')
81 {unshift @names, @{$list}[1..scalar(@{$list})-1]; next} 101 {unshift @names, @{$list}[1..scalar(@{$list})-1]; next}
82 my @fn; foreach my $f (@{$list}) { 102 my @fn; foreach my $f (@{$list})
83 push @fn, $f => 103 {push @fn, $f => {class => $functions->{$f}{class}}}
84 {class => $Parser::Context::Default::fullContext->{functions}{$f}{class}};
85 }
86 $context->functions->set(@fn); 104 $context->functions->set(@fn);
87 } 105 }
88} 106}
89 107
90######################################################################### 108#########################################################################

Legend:
Removed from v.3482  
changed lines
  Added in v.3483

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9