Author: rolf
Date: 2006-06-02 07:51:46 -0400 (Fri, 02 Jun 2006)
New Revision: 61402

Added:
   trunk/vbnc/vbnc/tests/RunTime/CType_Array6.vb
   trunk/vbnc/vbnc/tests/RunTime/CType_Interface1.vb
   trunk/vbnc/vbnc/tests/RunTime/CType_Interface2.vb
   trunk/vbnc/vbnc/tests/RunTime/CType_Interface3.vb
   trunk/vbnc/vbnc/tests/RunTime/CType_ValueType1.vb
Modified:
   trunk/vbnc/changelog.txt
   trunk/vbnc/progress.txt
   trunk/vbnc/vbnc/bin/debug.rsp
   trunk/vbnc/vbnc/source/Descriptors/TypeDescriptor.vb
   trunk/vbnc/vbnc/source/Emit/Emitter.vb
   trunk/vbnc/vbnc/source/Expressions/Conversions/CTypeExpression.vb
   trunk/vbnc/vbnc/source/General/AssemblyInfo.vb
   trunk/vbnc/vbnc/source/General/Helper.vb
   trunk/vbnc/vbnc/tests/RunTime/CType_Array5.vb
Log:
2006-06-02  Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
        * Finished implementing CType conversions, most of them should work now.

Modified: trunk/vbnc/changelog.txt
===================================================================
--- trunk/vbnc/changelog.txt    2006-06-02 11:03:12 UTC (rev 61401)
+++ trunk/vbnc/changelog.txt    2006-06-02 11:51:46 UTC (rev 61402)
@@ -1,3 +1,6 @@
+2006-06-02  Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+       * Finished implementing CType conversions, most of them should work now.
+
 2006-06-01  Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
        * Some non-elemental CType conversions work now (Object to whatever, 
array conversions).
 

Modified: trunk/vbnc/progress.txt
===================================================================
--- trunk/vbnc/progress.txt     2006-06-02 11:03:12 UTC (rev 61401)
+++ trunk/vbnc/progress.txt     2006-06-02 11:51:46 UTC (rev 61402)
@@ -1,3 +1,9 @@
+2006-06-02:
+# of Tests: 1673
+# of Tests (Successful): 544 = 32,5%
+# of Tests (Failed): 1128 = 67,4%
+# of Tests (NotRun): 1 = 0,1%
+
 2006-06-01:
 # of Tests: 1717
 # of Tests (Successful): 537 = 31,3%

Modified: trunk/vbnc/vbnc/bin/debug.rsp
===================================================================
--- trunk/vbnc/vbnc/bin/debug.rsp       2006-06-02 11:03:12 UTC (rev 61401)
+++ trunk/vbnc/vbnc/bin/debug.rsp       2006-06-02 11:51:46 UTC (rev 61402)
@@ -1,5 +1,5 @@
 /Debug
-"/out:G:\Rolf\Proyectos\VB.NET\Compilers\vbnc\mono\vbnc\tests\RunTime\test 
output\CType_Array4.dll"
-"G:\Rolf\Proyectos\VB.NET\Compilers\vbnc\mono\vbnc\tests\RunTime\CType_Array4.vb"
+"/out:G:\Rolf\Proyectos\VB.NET\Compilers\vbnc\mono\vbnc\tests\RunTime\test 
output\CType_Interface3.dll"
+"G:\Rolf\Proyectos\VB.NET\Compilers\vbnc\mono\vbnc\tests\RunTime\CType_Interface3.vb"
 "/libpath:G:\Rolf\Proyectos\VB.NET\Compilers\vbnc\mono\vbnc\tests\RunTime"
 "@G:\Rolf\Proyectos\VB.NET\Compilers\vbnc\mono\vbnc\tests\RunTime\all.rsp"

Modified: trunk/vbnc/vbnc/source/Descriptors/TypeDescriptor.vb
===================================================================
--- trunk/vbnc/vbnc/source/Descriptors/TypeDescriptor.vb        2006-06-02 
11:03:12 UTC (rev 61401)
+++ trunk/vbnc/vbnc/source/Descriptors/TypeDescriptor.vb        2006-06-02 
11:51:46 UTC (rev 61402)
@@ -353,7 +353,11 @@
     End Function
 
     Public Overloads Overrides Function GetField(ByVal name As String, ByVal 
bindingAttr As System.Reflection.BindingFlags) As System.Reflection.FieldInfo
-        DumpMethodInfo()
+        Dim result As FieldInfo
+
+        result = CType(m_Declaration.Members.Index.Item(name), 
IFieldMember).FieldBuilder
+
+        DumpMethodInfo(result)
         Helper.NotImplemented() : Return Nothing
     End Function
 
@@ -368,8 +372,13 @@
     End Function
 
     Public Overrides Function GetInterfaces() As System.Type()
-        DumpMethodInfo()
-        Helper.NotImplemented() : Return Nothing
+        Dim result As New Generic.List(Of Type)
+        Dim tmp As Type()
+        tmp = m_Declaration.ImplementedTypes
+        If tmp IsNot Nothing Then 
result.AddRange(m_Declaration.ImplementedTypes)
+        If Me.BaseType IsNot Nothing Then 
result.AddRange(Me.BaseType.GetInterfaces)
+        DumpMethodInfo(result.ToArray)
+        Return result.ToArray
     End Function
 
     Function Filter(ByVal members As Generic.IEnumerable(Of 
IConstructorMember), ByVal bindingAttr As BindingFlags) As Generic.List(Of 
ConstructorInfo)

Modified: trunk/vbnc/vbnc/source/Emit/Emitter.vb
===================================================================
--- trunk/vbnc/vbnc/source/Emit/Emitter.vb      2006-06-02 11:03:12 UTC (rev 
61401)
+++ trunk/vbnc/vbnc/source/Emit/Emitter.vb      2006-06-02 11:51:46 UTC (rev 
61402)
@@ -1850,6 +1850,7 @@
 
     Shared Sub EmitBox(ByVal Info As EmitInfo)
         Dim tp As Type = Info.Stack.Peek
+        Helper.Assert(tp.IsValueType)
         If tp.IsValueType Then
             Info.Stack.Pop(tp)
             Info.ILGen.Emit(OpCodes.Box, tp)

Modified: trunk/vbnc/vbnc/source/Expressions/Conversions/CTypeExpression.vb
===================================================================
--- trunk/vbnc/vbnc/source/Expressions/Conversions/CTypeExpression.vb   
2006-06-02 11:03:12 UTC (rev 61401)
+++ trunk/vbnc/vbnc/source/Expressions/Conversions/CTypeExpression.vb   
2006-06-02 11:51:46 UTC (rev 61402)
@@ -99,15 +99,21 @@
                 Dim SourceElementType As Type = SourceType.GetElementType
                 Dim DestinationElementType As Type = 
DestinationType.GetElementType
                 'For any two reference types A and B, if A is a derived type 
of B or implements B, a conversion exists from an array of type A to a 
compatible array of type B. A compatible array is an array of the same rank and 
type. This relationship is known as array covariance. Array covariance in 
particular means that an element of an array whose element type is B may 
actually be an element of an array whose element type is A, provided that both 
A and B are reference types and that B is a base type of A or is implemented by 
A. 
-                If Helper.CompareType(SourceElementType, 
DestinationElementType) OrElse 
DestinationElementType.IsSubclassOf(SourceElementType) OrElse 
Helper.IsAssignable(SourceElementType, DestinationElementType) Then
+                If Helper.CompareType(TypeCache.Object, SourceElementType) Then
                     Emitter.EmitCastClass(Info, SourceType, DestinationType)
+                ElseIf Helper.CompareType(SourceElementType, 
DestinationElementType) OrElse 
DestinationElementType.IsSubclassOf(SourceElementType) Then
+                    Emitter.EmitCastClass(Info, SourceType, DestinationType)
+                ElseIf Helper.DoesTypeImplementInterface(SourceElementType, 
DestinationElementType) Then
+                    Emitter.EmitCastClass(Info, SourceType, DestinationType)
                 ElseIf DestinationElementType.IsInterface AndAlso 
Helper.CompareType(TypeCache.Object, SourceElementType) Then
                     Emitter.EmitCastClass(Info, SourceType, DestinationType)
+                ElseIf SourceElementType.IsEnum AndAlso 
Helper.CompareType(Helper.GetEnumType(SourceElementType), 
DestinationElementType) Then
+                    'Conversions also exist between an array of an enumerated 
type and an array of the enumerated type�s underlying type of the same rank.
+                    Emitter.EmitCastClass(Info, SourceType, DestinationType)
                 Else
                     Info.Compiler.Report.ShowMessage(Messages.VBNC30311, 
SourceType.Name, DestinationType.Name)
                     result = False
                 End If
-                'Conversions also exist between an array of an enumerated type 
and an array of the enumerated type�s underlying type of the same rank.
 
             End If
         ElseIf SourceType.IsClass Then
@@ -125,6 +131,31 @@
             Else
                 Throw New InternalException
             End If
+        ElseIf SourceType.IsValueType Then
+            'A value type value can be converted to one of its base reference 
types or an interface type that it implements through a process called boxing
+            If Helper.CompareType(DestinationType, TypeCache.Object) Then
+                Throw New InternalException 'This is an elemental conversion 
already covered. 'Emitter.EmitBox(Info)
+            ElseIf Helper.DoesTypeImplementInterface(SourceType, 
DestinationType) Then
+                Emitter.EmitBox(Info)
+                Emitter.EmitCastClass(Info, TypeCache.Object, DestinationType)
+            Else
+                Throw New InternalException
+            End If
+        ElseIf SourceType.IsInterface Then
+            If Helper.DoesTypeImplementInterface(DestinationType, SourceType) 
Then
+                If DestinationType.IsValueType Then
+                    Emitter.EmitUnbox(Info, DestinationType)
+                    Emitter.EmitLdobj(Info, DestinationType)
+                Else
+                    Emitter.EmitCastClass(Info, SourceType, TypeCache.Object)
+                End If
+
+            ElseIf DestinationType.IsClass OrElse DestinationType.IsInterface 
Then
+                Emitter.EmitCastClass(Info, SourceType, DestinationType)
+            Else
+                'However, classes that represent COM classes may have 
interface implementations that are not known until run time. Consequently, a 
class type may also be converted to an interface type that it does not 
implement, an interface type may be converted to a class type that does not 
implement it, and an interface type may be converted to another interface type 
with which it has no inheritance relationship
+                Helper.NotImplemented()
+            End If
         Else
             Helper.NotImplemented()
         End If

Modified: trunk/vbnc/vbnc/source/General/AssemblyInfo.vb
===================================================================
--- trunk/vbnc/vbnc/source/General/AssemblyInfo.vb      2006-06-02 11:03:12 UTC 
(rev 61401)
+++ trunk/vbnc/vbnc/source/General/AssemblyInfo.vb      2006-06-02 11:51:46 UTC 
(rev 61402)
@@ -49,5 +49,5 @@
 ' You can specify all the values or you can default the Build and Revision 
Numbers 
 ' by using the '*' as shown below:
 
-<Assembly: AssemblyVersion("0.0.0.2947")>
+<Assembly: AssemblyVersion("0.0.0.2972")>
 

Modified: trunk/vbnc/vbnc/source/General/Helper.vb
===================================================================
--- trunk/vbnc/vbnc/source/General/Helper.vb    2006-06-02 11:03:12 UTC (rev 
61401)
+++ trunk/vbnc/vbnc/source/General/Helper.vb    2006-06-02 11:51:46 UTC (rev 
61402)
@@ -961,17 +961,35 @@
     End Sub
 
     Shared Function IsAssignable(ByVal FromType As Type, ByVal ToType As Type) 
As Boolean
-        If TypeOf FromType Is TypeDescriptor Then FromType = 
FromType.UnderlyingSystemType
-        If TypeOf ToType Is TypeDescriptor Then ToType = 
ToType.UnderlyingSystemType
+        'If TypeOf FromType Is TypeDescriptor Then FromType = 
FromType.UnderlyingSystemType
+        'If TypeOf ToType Is TypeDescriptor Then ToType = 
ToType.UnderlyingSystemType
         If CompareType(ToType, TypeCache.Object) Then
             Return True
         ElseIf ToType.IsAssignableFrom(FromType) Then
             Return True
+        ElseIf ToType.IsInterface Then
+            Dim ifaces() As Type = FromType.GetInterfaces()
+            Return Array.IndexOf(ifaces, ToType) >= 0
+        ElseIf FromType.IsEnum AndAlso 
TypeResolution.IsImplicitlyConvertible(GetEnumType(FromType), ToType) Then
+            Return True
         Else
             Helper.NotImplemented()
         End If
     End Function
 
+    Shared Function DoesTypeImplementInterface(ByVal Type As Type, ByVal 
[Interface] As Type) As Boolean
+        Return Array.IndexOf(Type.GetInterfaces, [Interface]) >= 0
+    End Function
+
+    Shared Function GetEnumType(ByVal EnumType As Type) As Type
+        Helper.Assert(EnumType.IsEnum)
+        If TypeOf EnumType Is TypeDescriptor Then
+            Return DirectCast(DirectCast(EnumType, 
TypeDescriptor).Declaration, EnumDeclaration).EnumConstantType
+        Else
+            Return EnumType.GetField(EnumDeclaration.EnumTypeMemberName, 
BindingFlags.ExactBinding Or BindingFlags.Static Or 
BindingFlags.Public).FieldType
+        End If
+    End Function
+
     Shared Function CompareType(ByVal t1 As Type, ByVal t2 As Type) As Boolean
         Helper.Assert(t1 IsNot Nothing AndAlso t2 IsNot Nothing)
 

Modified: trunk/vbnc/vbnc/tests/RunTime/CType_Array5.vb
===================================================================
(Binary files differ)

Added: trunk/vbnc/vbnc/tests/RunTime/CType_Array6.vb
===================================================================
(Binary files differ)


Property changes on: trunk/vbnc/vbnc/tests/RunTime/CType_Array6.vb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/vbnc/vbnc/tests/RunTime/CType_Interface1.vb
===================================================================
(Binary files differ)


Property changes on: trunk/vbnc/vbnc/tests/RunTime/CType_Interface1.vb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/vbnc/vbnc/tests/RunTime/CType_Interface2.vb
===================================================================
(Binary files differ)


Property changes on: trunk/vbnc/vbnc/tests/RunTime/CType_Interface2.vb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/vbnc/vbnc/tests/RunTime/CType_Interface3.vb
===================================================================
(Binary files differ)


Property changes on: trunk/vbnc/vbnc/tests/RunTime/CType_Interface3.vb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/vbnc/vbnc/tests/RunTime/CType_ValueType1.vb
===================================================================
(Binary files differ)


Property changes on: trunk/vbnc/vbnc/tests/RunTime/CType_ValueType1.vb
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to