Log Message:
-----------
Modified the perl() method to make calles to Value:: directly rather
than to the main:: stubs for creating Value objects. This will make
it work better from within packages or when Parser.pl hasn't been
loaded.
A few things still won't work in this case; e.g., calls to Closed()
for intervals (these could be handled better using ->with()) and to
functions like Factorial and log10 that are defined in Parser.pl.
Finally, there should be better object-based control over what
routines are called to create these objects, so that subclasses of the
Value objects will be able to be generated correctly.
Modified Files:
--------------
pg/lib:
Parser.pm
Value.pm
pg/lib/Parser:
List.pm
pg/lib/Parser/BOP:
union.pm
pg/lib/Parser/List:
Interval.pm
Matrix.pm
Revision Data
-------------
Index: Value.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -Llib/Value.pm -Llib/Value.pm -u -r1.37 -r1.38
--- lib/Value.pm
+++ lib/Value.pm
@@ -461,7 +461,7 @@
sub string {shift->value}
sub TeX {shift->string(@_)}
#
-# For perl, call the appropriate constructor around the objects data
+# For perl, call the appropriate constructor around the object's data
#
sub perl {
my $self = shift; my $parens = shift; my $matrix = shift;
@@ -476,7 +476,7 @@
$perl = join(',',@p);
$perl = '['.$perl.']' if $mtype > 0;
} else {
- $perl = $class.'('.join(',',@p).')';
+ $perl = 'new '.ref($self).'('.join(',',@p).')';
$perl = '('.$perl.')' if $parens == 1;
}
return $perl;
Index: Parser.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -Llib/Parser.pm -Llib/Parser.pm -u -r1.23 -r1.24
--- lib/Parser.pm
+++ lib/Parser.pm
@@ -625,7 +625,7 @@
my $self = shift;
$self->setValues(@_);
my $perl = $self->{tree}->perl;
- $perl = 'Real('.$perl.')' if $self->isRealNumber;
+ $perl = 'new Value::Real('.$perl.')' if $self->isRealNumber;
return $perl;
}
Index: List.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/List.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -Llib/Parser/List.pm -Llib/Parser/List.pm -u -r1.12 -r1.13
--- lib/Parser/List.pm
+++ lib/Parser/List.pm
@@ -227,7 +227,7 @@
my $self = shift; my $parens = shift; my $matrix = shift;
my $perl; my @p = ();
foreach my $x (@{$self->{coords}}) {push(@p,$x->perl)}
- $perl = $self->type.'('.join(',',@p).')';
+ $perl = 'new Value::'.$self->type.'('.join(',',@p).')';
$perl = 'Closed('.$perl.')'
if $self->{canBeInterval} && $self->{open}.$self->{close} eq '[]';
$perl = '('.$perl.')' if $parens;
Index: union.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/BOP/union.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -Llib/Parser/BOP/union.pm -Llib/Parser/BOP/union.pm -u -r1.4 -r1.5
--- lib/Parser/BOP/union.pm
+++ lib/Parser/BOP/union.pm
@@ -38,7 +38,7 @@
sub perl {
my $self = shift; my $parens = shift; my @union = ();
foreach my $x ($self->makeUnion) {push(@union,$x->perl)}
- my $perl = 'Union('.join(',',@union).')';
+ my $perl = 'new Value::Union('.join(',',@union).')';
$perl = '('.$perl.')' if $parens;
return $perl;
}
Index: Interval.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/List/Interval.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -Llib/Parser/List/Interval.pm -Llib/Parser/List/Interval.pm -u -r1.6 -r1.7
--- lib/Parser/List/Interval.pm
+++ lib/Parser/List/Interval.pm
@@ -45,7 +45,7 @@
my $self = shift; my $parens = shift;
my $perl; my @p = ();
foreach my $x (@{$self->{coords}}) {push(@p,$x->perl)}
- $perl = $self->type.'('.join(',',"'".$self->{open}."'",@p,"'".$self->{close}."'").')';
+ $perl = 'new Value::'.$self->type.'('.join(',',"'".$self->{open}."'",@p,"'".$self->{close}."'").')';
$perl = '('.$perl.')' if $parens;
return $perl;
}
Index: Matrix.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Parser/List/Matrix.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -Llib/Parser/List/Matrix.pm -Llib/Parser/List/Matrix.pm -u -r1.3 -r1.4
--- lib/Parser/List/Matrix.pm
+++ lib/Parser/List/Matrix.pm
@@ -50,7 +50,7 @@
if ($matrix) {
$perl = '['.join(',',@p).']';
} else {
- $perl = $self->type.'('.join(',',@p).')';
+ $perl = 'new Value::'.$self->type.'('.join(',',@p).')';
$perl = '('.$perl.')' if $parens;
}
return $perl;
|