Author: rolf
Date: 2007-05-09 12:51:15 -0400 (Wed, 09 May 2007)
New Revision: 77038
Modified:
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ChangeLog
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Operators.vb
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Utils.vb
Log:
* Operators.vb: Remove warnings.
* Utils.vb: Implement multi-dimensional arrays correctly in CopyArray.
Modified:
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ChangeLog
===================================================================
---
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ChangeLog
2007-05-09 16:51:02 UTC (rev 77037)
+++
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/ChangeLog
2007-05-09 16:51:15 UTC (rev 77038)
@@ -1,3 +1,8 @@
+2007-05-09 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+
+ * Operators.vb: Remove warnings.
+ * Utils.vb: Implement multi-dimensional arrays correctly in CopyArray.
+
2007-05-06 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* DecimalType.vb: Add 2.0 conversion cases.
Modified:
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Operators.vb
===================================================================
---
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Operators.vb
2007-05-09 16:51:02 UTC (rev 77037)
+++
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Operators.vb
2007-05-09 16:51:15 UTC (rev 77038)
@@ -1992,7 +1992,7 @@
End Function
End Class
- Class VBConvert
+ Friend Class VBConvert
Public Shared Function ToBoolean(ByVal obj As Object) As Boolean
Return Convert.ToBoolean(obj)
End Function
@@ -2087,7 +2087,7 @@
Return Convert.ToChar(obj)
End Function
- Public Shared Function ToString(ByVal obj As Object) As String
+ Public Shared Shadows Function ToString(ByVal obj As Object) As
String
Return Convert.ToString(obj)
End Function
Modified:
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Utils.vb
===================================================================
---
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Utils.vb
2007-05-09 16:51:02 UTC (rev 77037)
+++
trunk/mono-basic/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.CompilerServices/Utils.vb
2007-05-09 16:51:15 UTC (rev 77038)
@@ -51,22 +51,47 @@
Return aryDest
End If
- Dim CopyLength As Long
- CopyLength = arySrc.Length
+ If arySrc.Rank <> aryDest.Rank Then
+ Throw New InvalidCastException("'ReDim' cannot change the
number of dimensions.")
+ End If
- If CopyLength = 0 Then
-#If TRACE Then
- Console.WriteLine("TRACE:Utils.CopyArray:arySrc.Length:" +
arySrc.Length.ToString())
-#End If
+ Dim lastRank As Integer
+ Dim destLength As Integer
+ Dim srcLength As Integer
+ Dim lastLength As Integer
+ Dim copies As Long
+
+ lastRank = arySrc.Rank - 1
+ destLength = aryDest.GetUpperBound(lastRank) + 1
+ srcLength = arySrc.GetUpperBound(lastRank) + 1
+
+ 'Check that all but the last dimension have the same length
+ For i As Integer = 0 To lastRank - 1
+ If arySrc.GetLongLength(i) <> aryDest.GetLongLength(i) Then
+ Throw New InvalidCastException("'ReDim' can only change
the rightmost dimension.")
+ End If
+ Next
+
+ If destLength = srcLength Then
+ 'All dimensions have the same size, copy the entire array
+ Array.Copy(arySrc, aryDest, arySrc.LongLength)
Return aryDest
End If
- If CopyLength > aryDest.Length Then
- CopyLength = aryDest.Length
+ lastLength = Math.Min(destLength, srcLength)
+
+ If lastRank = 0 Then
+ 'There's only one dimension, copy the length
+ Array.Copy(arySrc, aryDest, lastLength)
+ Return aryDest
End If
- Array.Copy(arySrc, 0, aryDest, 0, CopyLength)
+ copies = arySrc.LongLength \ srcLength
+ For i As Long = 0 To copies - 1
+ Array.Copy(arySrc, i * srcLength, aryDest, i * destLength,
lastLength)
+ Next
+
Return aryDest
End Function
Public Shared Function MethodToString(ByVal Method As
System.Reflection.MethodBase) As String
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches