From: dpvc v. a. <we...@ma...> - 2005-06-04 13:52:40
|
Log Message: ----------- Avoid possible infinite loop with length and typeref calls. Modified Files: -------------- pg/lib: Value.pm pg/lib/Value: Complex.pm Formula.pm List.pm Matrix.pm Point.pm Real.pm Union.pm Vector.pm Revision Data ------------- Index: Value.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value.pm,v retrieving revision 1.34 retrieving revision 1.35 diff -Llib/Value.pm -Llib/Value.pm -u -r1.34 -r1.35 --- lib/Value.pm +++ lib/Value.pm @@ -326,7 +326,7 @@ # sub value {return @{(shift)->{data}}} # the value of the object (as an array) sub data {return (shift)->{data}} # the reference to the value -sub length {return (shift)->typeRef->{length}} # the number of coordinates +sub length {return scalar(@{(shift)->{data}})} # the number of coordinates sub type {return (shift)->typeRef->{name}} # the object type sub entryType {return (shift)->typeRef->{entryType}} # the coordinate type # Index: Real.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Real.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -Llib/Value/Real.pm -Llib/Value/Real.pm -u -r1.14 -r1.15 --- lib/Value/Real.pm +++ lib/Value/Real.pm @@ -72,6 +72,7 @@ # Return the real number type # sub typeRef {return $Value::Type{number}} +sub length {1} # # return the real number Index: Complex.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Complex.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -Llib/Value/Complex.pm -Llib/Value/Complex.pm -u -r1.13 -r1.14 --- lib/Value/Complex.pm +++ lib/Value/Complex.pm @@ -73,6 +73,7 @@ # Return the complex type # sub typeRef {return $Value::Type{complex}} +sub length {2} sub isZero {shift eq "0"} sub isOne {shift eq "1"} Index: List.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/List.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -Llib/Value/List.pm -Llib/Value/List.pm -u -r1.14 -r1.15 --- lib/Value/List.pm +++ lib/Value/List.pm @@ -43,7 +43,6 @@ # # Return the proper data # -sub length {return scalar(@{shift->{data}})} sub typeRef { my $self = shift; return Value::Type($self->class, $self->length, Value::Type($self->{type},1)); Index: Union.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Union.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -Llib/Value/Union.pm -Llib/Value/Union.pm -u -r1.12 -r1.13 --- lib/Value/Union.pm +++ lib/Value/Union.pm @@ -51,7 +51,6 @@ # # Return the appropriate data. # -sub length {return scalar(@{shift->{data}})} sub typeRef { my $self = shift; return Value::Type($self->class, $self->length, $self->data->[0]->typeRef); Index: Vector.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Vector.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -Llib/Value/Vector.pm -Llib/Value/Vector.pm -u -r1.15 -r1.16 --- lib/Value/Vector.pm +++ lib/Value/Vector.pm @@ -57,11 +57,6 @@ } # -# The number of coordinates -# -sub length {return scalar(@{shift->{data}})} - -# # Try to promote arbitary data to a vector # sub promote { Index: Formula.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Formula.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -Llib/Value/Formula.pm -Llib/Value/Formula.pm -u -r1.24 -r1.25 --- lib/Value/Formula.pm +++ lib/Value/Formula.pm @@ -48,6 +48,7 @@ # Get the type from the tree # sub typeRef {(shift)->{tree}->typeRef} +sub length {(shift)->{tree}->typeRef->{length}} sub isZero {(shift)->{tree}{isZero}} sub isOne {(shift)->{tree}{isOne}} Index: Matrix.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Matrix.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -Llib/Value/Matrix.pm -Llib/Value/Matrix.pm -u -r1.17 -r1.18 --- lib/Value/Matrix.pm +++ lib/Value/Matrix.pm @@ -95,11 +95,6 @@ return @M; } # -# The number of rows in the matrix (for n x m) -# or the number of entries in a 1 x n matrix -# -sub length {return scalar(@{shift->{data}})} -# # Recursively get the dimensions of the matrix. # Returns (n) for a 1 x n, or (n,m) for an n x m, etc. # Index: Point.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Point.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -Llib/Value/Point.pm -Llib/Value/Point.pm -u -r1.13 -r1.14 --- lib/Value/Point.pm +++ lib/Value/Point.pm @@ -58,11 +58,6 @@ } # -# The number of coordinates -# -sub length {return scalar(@{shift->{data}})} - -# # Try to promote arbitrary data to a point # sub promote { |