1' Licensed to the .NET Foundation under one or more agreements. 2' The .NET Foundation licenses this file to you under the MIT license. 3' See the LICENSE file in the project root for more information. 4 5Option Strict On 6 7Imports System 8Imports System.Diagnostics 9Imports System.Globalization 10Imports System.Collections.Generic 11Imports System.Reflection 12 13Imports Microsoft.VisualBasic.CompilerServices.ExceptionUtils 14Imports Microsoft.VisualBasic.CompilerServices.Symbols 15Imports Microsoft.VisualBasic.CompilerServices.Utils 16 17 18Namespace Microsoft.VisualBasic.CompilerServices 19 20 ' Implements Object operators 21 Public NotInheritable Class Operators 22 23 Friend Shared ReadOnly Boxed_ZeroDouble As Object = 0.0R 24 Friend Shared ReadOnly Boxed_ZeroSinge As Object = 0.0F 25 Friend Shared ReadOnly Boxed_ZeroDecimal As Object = CDec(0) 26 Friend Shared ReadOnly Boxed_ZeroLong As Object = 0L 27 Friend Shared ReadOnly Boxed_ZeroInteger As Object = 0I 28 Friend Shared ReadOnly Boxed_ZeroShort As Object = 0S 29 Friend Shared ReadOnly Boxed_ZeroULong As Object = 0UL 30 Friend Shared ReadOnly Boxed_ZeroUInteger As Object = 0UI 31 Friend Shared ReadOnly Boxed_ZeroUShort As Object = 0US 32 Friend Shared ReadOnly Boxed_ZeroSByte As Object = CSByte(0) 33 Friend Shared ReadOnly Boxed_ZeroByte As Object = CByte(0) 34 35 Private Sub New() 36 End Sub 37 38 Private Const s_TCMAX As Integer = TypeCode.String + 1 39 40 Private Shared Function ToVBBool(ByVal conv As Object) As SByte 41 Return CSByte(Convert.ToBoolean(conv)) 42 End Function 43 44 Private Shared Function GetTypeCode(ByVal o As Object) As TypeCode 45 If o Is Nothing Then 46 Return TypeCode.Empty 47 Else 48 Return o.GetType.GetTypeCode 49 End If 50 End Function 51 52 'This function determines the enum result type of And, Or, Xor operations. 53 'If the type of Left and Right are the same enum type, then return that type, otherwise if 54 'one is an enum and the other is Nothing, return that type, otherwise return Nothing. 55 Private Shared Function GetEnumResult(ByVal left As Object, ByVal right As Object) As Type 56 57 Debug.Assert(left Is Nothing OrElse right Is Nothing OrElse left.GetType.GetTypeCode = right.GetType.GetTypeCode, 58 "Expected identical type codes for checking enum result") 59 60 61 If left IsNot Nothing Then 62 63 If TypeOf left Is System.Enum Then 64 65 If right Is Nothing Then 66 Return left.GetType 67 68 ElseIf TypeOf right Is System.Enum Then 69 Dim leftType As Type = left.GetType 70 If leftType Is right.GetType Then 71 Return leftType 72 End If 73 74 End If 75 76 End If 77 78 ElseIf TypeOf right Is System.Enum Then 79 Return right.GetType 80 81 End If 82 83 Return Nothing 84 85 End Function 86 87 Private Shared Function GetNoValidOperatorException(ByVal op As UserDefinedOperator, ByVal operand As Object) As Exception 88 Return New InvalidCastException(GetResourceString(SR.UnaryOperand2, OperatorNames(op), VBFriendlyName(operand))) 89 End Function 90 91 Private Shared Function GetNoValidOperatorException(ByVal op As UserDefinedOperator, ByVal left As Object, ByVal right As Object) As Exception 92 Const maxInsertionSize As Integer = 32 93 94 Dim substitution1 As String 95 Dim substitution2 As String 96 97 If left Is Nothing Then 98 substitution1 = "'Nothing'" 99 Else 100 Dim leftString As String = TryCast(left, String) 101 102 If leftString IsNot Nothing Then 103 substitution1 = 104 GetResourceString(SR.NoValidOperator_StringType1, Strings.Left(leftString, maxInsertionSize)) 105 Else 106 substitution1 = GetResourceString(SR.NoValidOperator_NonStringType1, VBFriendlyName(left)) 107 End If 108 End If 109 110 If right Is Nothing Then 111 substitution2 = "'Nothing'" 112 Else 113 Dim rightString As String = TryCast(right, String) 114 115 If rightString IsNot Nothing Then 116 substitution2 = 117 GetResourceString(SR.NoValidOperator_StringType1, Strings.Left(rightString, maxInsertionSize)) 118 Else 119 substitution2 = GetResourceString(SR.NoValidOperator_NonStringType1, VBFriendlyName(right)) 120 End If 121 End If 122 123 Return New InvalidCastException(GetResourceString(SR.BinaryOperands3, OperatorNames(op), substitution1, substitution2)) 124 End Function 125 126#Region " Comparison Operators = <> < <= > >= " 127 128 Private Enum CompareClass 129 Less = -1 130 Equal = 0 131 Greater = 1 132 Unordered 133 UserDefined 134 Undefined 135 End Enum 136 137 Public Shared Function CompareObjectEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Object 138 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 139 140 Select Case comparison 141 Case CompareClass.Unordered 142 Return False 143 Case CompareClass.UserDefined 144 Return InvokeUserDefinedOperator(UserDefinedOperator.Equal, left, right) 145 Case CompareClass.Undefined 146 Throw GetNoValidOperatorException(UserDefinedOperator.Equal, left, right) 147 Case Else 148 Debug.Assert(comparison = CompareClass.Less OrElse 149 comparison = CompareClass.Equal OrElse 150 comparison = CompareClass.Greater) 151 Return comparison = 0 152 End Select 153 End Function 154 155 Public Shared Function ConditionalCompareObjectEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Boolean 156 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 157 158 Select Case comparison 159 Case CompareClass.Unordered 160 Return False 161 Case CompareClass.UserDefined 162 Return CBool(InvokeUserDefinedOperator(UserDefinedOperator.Equal, left, right)) 163 Case CompareClass.Undefined 164 Throw GetNoValidOperatorException(UserDefinedOperator.Equal, left, right) 165 Case Else 166 Debug.Assert(comparison = CompareClass.Less OrElse 167 comparison = CompareClass.Equal OrElse 168 comparison = CompareClass.Greater) 169 Return comparison = 0 170 End Select 171 End Function 172 173 Public Shared Function CompareObjectNotEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Object 174 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 175 176 Select Case comparison 177 Case CompareClass.Unordered 178 Return True 179 Case CompareClass.UserDefined 180 Return InvokeUserDefinedOperator(UserDefinedOperator.NotEqual, left, right) 181 Case CompareClass.Undefined 182 Throw GetNoValidOperatorException(UserDefinedOperator.NotEqual, left, right) 183 Case Else 184 Debug.Assert(comparison = CompareClass.Less OrElse 185 comparison = CompareClass.Equal OrElse 186 comparison = CompareClass.Greater) 187 Return comparison <> 0 188 End Select 189 End Function 190 191 Public Shared Function ConditionalCompareObjectNotEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Boolean 192 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 193 194 Select Case comparison 195 Case CompareClass.Unordered 196 Return True 197 Case CompareClass.UserDefined 198 Return CBool(InvokeUserDefinedOperator(UserDefinedOperator.NotEqual, left, right)) 199 Case CompareClass.Undefined 200 Throw GetNoValidOperatorException(UserDefinedOperator.NotEqual, left, right) 201 Case Else 202 Debug.Assert(comparison = CompareClass.Less OrElse 203 comparison = CompareClass.Equal OrElse 204 comparison = CompareClass.Greater) 205 Return comparison <> 0 206 End Select 207 End Function 208 209 Public Shared Function CompareObjectLess(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Object 210 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 211 212 Select Case comparison 213 Case CompareClass.Unordered 214 Return False 215 Case CompareClass.UserDefined 216 Return InvokeUserDefinedOperator(UserDefinedOperator.Less, left, right) 217 Case CompareClass.Undefined 218 Throw GetNoValidOperatorException(UserDefinedOperator.Less, left, right) 219 Case Else 220 Debug.Assert(comparison = CompareClass.Less OrElse 221 comparison = CompareClass.Equal OrElse 222 comparison = CompareClass.Greater) 223 Return comparison < 0 224 End Select 225 End Function 226 227 Public Shared Function ConditionalCompareObjectLess(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Boolean 228 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 229 230 Select Case comparison 231 Case CompareClass.Unordered 232 Return False 233 Case CompareClass.UserDefined 234 Return CBool(InvokeUserDefinedOperator(UserDefinedOperator.Less, left, right)) 235 Case CompareClass.Undefined 236 Throw GetNoValidOperatorException(UserDefinedOperator.Less, left, right) 237 Case Else 238 Debug.Assert(comparison = CompareClass.Less OrElse 239 comparison = CompareClass.Equal OrElse 240 comparison = CompareClass.Greater) 241 Return comparison < 0 242 End Select 243 End Function 244 245 Public Shared Function CompareObjectLessEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Object 246 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 247 248 Select Case comparison 249 Case CompareClass.Unordered 250 Return False 251 Case CompareClass.UserDefined 252 Return InvokeUserDefinedOperator(UserDefinedOperator.LessEqual, left, right) 253 Case CompareClass.Undefined 254 Throw GetNoValidOperatorException(UserDefinedOperator.LessEqual, left, right) 255 Case Else 256 Debug.Assert(comparison = CompareClass.Less OrElse 257 comparison = CompareClass.Equal OrElse 258 comparison = CompareClass.Greater) 259 Return comparison <= 0 260 End Select 261 End Function 262 263 Public Shared Function ConditionalCompareObjectLessEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Boolean 264 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 265 266 Select Case comparison 267 Case CompareClass.Unordered 268 Return False 269 Case CompareClass.UserDefined 270 Return CBool(InvokeUserDefinedOperator(UserDefinedOperator.LessEqual, left, right)) 271 Case CompareClass.Undefined 272 Throw GetNoValidOperatorException(UserDefinedOperator.LessEqual, left, right) 273 Case Else 274 Debug.Assert(comparison = CompareClass.Less OrElse 275 comparison = CompareClass.Equal OrElse 276 comparison = CompareClass.Greater) 277 Return comparison <= 0 278 End Select 279 End Function 280 281 Public Shared Function CompareObjectGreaterEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Object 282 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 283 284 Select Case comparison 285 Case CompareClass.Unordered 286 Return False 287 Case CompareClass.UserDefined 288 Return InvokeUserDefinedOperator(UserDefinedOperator.GreaterEqual, left, right) 289 Case CompareClass.Undefined 290 Throw GetNoValidOperatorException(UserDefinedOperator.GreaterEqual, left, right) 291 Case Else 292 Debug.Assert(comparison = CompareClass.Less OrElse 293 comparison = CompareClass.Equal OrElse 294 comparison = CompareClass.Greater) 295 Return comparison >= 0 296 End Select 297 End Function 298 299 Public Shared Function ConditionalCompareObjectGreaterEqual(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Boolean 300 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 301 302 Select Case comparison 303 Case CompareClass.Unordered 304 Return False 305 Case CompareClass.UserDefined 306 Return CBool(InvokeUserDefinedOperator(UserDefinedOperator.GreaterEqual, left, right)) 307 Case CompareClass.Undefined 308 Throw GetNoValidOperatorException(UserDefinedOperator.GreaterEqual, left, right) 309 Case Else 310 Debug.Assert(comparison = CompareClass.Less OrElse 311 comparison = CompareClass.Equal OrElse 312 comparison = CompareClass.Greater) 313 Return comparison >= 0 314 End Select 315 End Function 316 317 Public Shared Function CompareObjectGreater(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Object 318 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 319 320 Select Case comparison 321 Case CompareClass.Unordered 322 Return False 323 Case CompareClass.UserDefined 324 Return InvokeUserDefinedOperator(UserDefinedOperator.Greater, left, right) 325 Case CompareClass.Undefined 326 Throw GetNoValidOperatorException(UserDefinedOperator.Greater, left, right) 327 Case Else 328 Debug.Assert(comparison = CompareClass.Less OrElse 329 comparison = CompareClass.Equal OrElse 330 comparison = CompareClass.Greater) 331 Return comparison > 0 332 End Select 333 End Function 334 335 Public Shared Function ConditionalCompareObjectGreater(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Boolean 336 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 337 338 Select Case comparison 339 Case CompareClass.Unordered 340 Return False 341 Case CompareClass.UserDefined 342 Return CBool(InvokeUserDefinedOperator(UserDefinedOperator.Greater, left, right)) 343 Case CompareClass.Undefined 344 Throw GetNoValidOperatorException(UserDefinedOperator.Greater, left, right) 345 Case Else 346 Debug.Assert(comparison = CompareClass.Less OrElse 347 comparison = CompareClass.Equal OrElse 348 comparison = CompareClass.Greater) 349 Return comparison > 0 350 End Select 351 End Function 352 353 Public Shared Function CompareObject(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As Integer 354 Dim comparison As CompareClass = CompareObject2(left, right, textCompare) 355 356 Select Case comparison 357 Case CompareClass.Unordered 358 Return 0 359 Case CompareClass.UserDefined, 360 CompareClass.Undefined 361 Throw GetNoValidOperatorException(UserDefinedOperator.IsTrue, left, right) 362 Case Else 363 Return comparison 364 End Select 365 End Function 366 367 Private Shared Function CompareObject2(ByVal left As Object, ByVal right As Object, ByVal textCompare As Boolean) As CompareClass 368 369 Dim tc1 As TypeCode = GetTypeCode(left) 370 Dim tc2 As TypeCode = GetTypeCode(right) 371 372 'Special cases for Char() 373 If tc1 = TypeCode.Object Then 374 Dim leftCharArray As Char() = TryCast(left, Char()) 375 376 If leftCharArray IsNot Nothing Then 377 If tc2 = TypeCode.String OrElse tc2 = TypeCode.Empty OrElse ((tc2 = TypeCode.Object) AndAlso (TypeOf right Is Char())) Then 378 'Treat Char() as String for these cases 379 left = CStr(leftCharArray) 380 tc1 = TypeCode.String 381 End If 382 End If 383 End If 384 385 If (tc2 = TypeCode.Object) Then 386 Dim rightCharArray As Char() = TryCast(right, Char()) 387 388 If rightCharArray IsNot Nothing Then 389 If tc1 = TypeCode.String OrElse tc1 = TypeCode.Empty Then 390 right = CStr(rightCharArray) 391 tc2 = TypeCode.String 392 End If 393 End If 394 End If 395 396 Select Case tc1 * s_TCMAX + tc2 397 398 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 399 Return 0 400 401 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 402 Return CompareBoolean(Nothing, Convert.ToBoolean(right)) 403 404 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte 405 Return CompareInt32(Nothing, Convert.ToSByte(right)) 406 407 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte 408 Return CompareInt32(Nothing, Convert.ToByte(right)) 409 410 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16 411 Return CompareInt32(Nothing, Convert.ToInt16(right)) 412 413 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16 414 Return CompareInt32(Nothing, Convert.ToUInt16(right)) 415 416 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32 417 Return CompareInt32(Nothing, Convert.ToInt32(right)) 418 419 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32 420 Return CompareUInt32(Nothing, Convert.ToUInt32(right)) 421 422 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64 423 Return CompareInt64(Nothing, Convert.ToInt64(right)) 424 425 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64 426 Return CompareUInt64(Nothing, Convert.ToUInt64(right)) 427 428 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal 429 Return CompareDecimal(0D, right) 430 431 Case TypeCode.Empty * s_TCMAX + TypeCode.Single 432 Return CompareSingle(Nothing, Convert.ToSingle(right)) 433 434 Case TypeCode.Empty * s_TCMAX + TypeCode.Double 435 Return CompareDouble(Nothing, Convert.ToDouble(right)) 436 437 Case TypeCode.Empty * s_TCMAX + TypeCode.DateTime 438 Return CompareDate(Nothing, Convert.ToDateTime(right)) 439 440 Case TypeCode.Empty * s_TCMAX + TypeCode.Char 441 Return CompareChar(Nothing, Convert.ToChar(right)) 442 443 Case TypeCode.Empty * s_TCMAX + TypeCode.String 444 Return CType(CompareString(Nothing, Convert.ToString(right), textCompare), CompareClass) 445 446 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 447 Return CompareBoolean(Convert.ToBoolean(left), Nothing) 448 449 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 450 Return CompareBoolean(Convert.ToBoolean(left), Convert.ToBoolean(right)) 451 452 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 453 Return CompareInt32(ToVBBool(left), Convert.ToSByte(right)) 454 455 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 456 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 457 Return CompareInt32(ToVBBool(left), Convert.ToInt16(right)) 458 459 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 460 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 461 Return CompareInt32(ToVBBool(left), Convert.ToInt32(right)) 462 463 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 464 TypeCode.Boolean * s_TCMAX + TypeCode.Int64 465 Return CompareInt64(ToVBBool(left), Convert.ToInt64(right)) 466 467 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 468 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal 469 Return CompareDecimal(ToVBBool(left), right) 470 471 Case TypeCode.Boolean * s_TCMAX + TypeCode.Single 472 Return CompareSingle(ToVBBool(left), Convert.ToSingle(right)) 473 474 Case TypeCode.Boolean * s_TCMAX + TypeCode.Double 475 Return CompareDouble(ToVBBool(left), Convert.ToDouble(right)) 476 477 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 478 Return CompareBoolean(Convert.ToBoolean(left), CBool(Convert.ToString(right))) 479 480 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty 481 Return CompareInt32(Convert.ToSByte(left), Nothing) 482 483 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 484 Return CompareInt32(Convert.ToSByte(left), ToVBBool(right)) 485 486 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 487 Return CompareInt32(Convert.ToSByte(left), Convert.ToSByte(right)) 488 489 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 490 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 491 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 492 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 493 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 494 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 495 TypeCode.Int16 * s_TCMAX + TypeCode.Int16 496 497 Return CompareInt32(Convert.ToInt16(left), Convert.ToInt16(right)) 498 499 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 500 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 501 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 502 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 503 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 504 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 505 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 506 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 507 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 508 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 509 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 510 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 511 TypeCode.Int32 * s_TCMAX + TypeCode.Int32 512 513 Return CompareInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 514 515 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 516 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 517 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 518 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 519 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 520 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 521 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 522 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 523 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 524 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 525 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 526 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 527 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 528 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 529 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 530 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 531 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 532 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 533 TypeCode.Int64 * s_TCMAX + TypeCode.Int64 534 535 Return CompareInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 536 537 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 538 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 539 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 540 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 541 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 542 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 543 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 544 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 545 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 546 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 547 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 548 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 549 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 550 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 551 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 552 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 553 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 554 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 555 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 556 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 557 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 558 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 559 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 560 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 561 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal 562 563 Return CompareDecimal(left, right) 564 565 Case TypeCode.SByte * s_TCMAX + TypeCode.Single, 566 TypeCode.Byte * s_TCMAX + TypeCode.Single, 567 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 568 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 569 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 570 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 571 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 572 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 573 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 574 TypeCode.Single * s_TCMAX + TypeCode.SByte, 575 TypeCode.Single * s_TCMAX + TypeCode.Byte, 576 TypeCode.Single * s_TCMAX + TypeCode.Int16, 577 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 578 TypeCode.Single * s_TCMAX + TypeCode.Int32, 579 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 580 TypeCode.Single * s_TCMAX + TypeCode.Int64, 581 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 582 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 583 TypeCode.Single * s_TCMAX + TypeCode.Single 584 585 Return CompareSingle(Convert.ToSingle(left), Convert.ToSingle(right)) 586 587 Case TypeCode.SByte * s_TCMAX + TypeCode.Double, 588 TypeCode.Byte * s_TCMAX + TypeCode.Double, 589 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 590 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 591 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 592 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 593 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 594 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 595 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 596 TypeCode.Single * s_TCMAX + TypeCode.Double, 597 TypeCode.Double * s_TCMAX + TypeCode.SByte, 598 TypeCode.Double * s_TCMAX + TypeCode.Byte, 599 TypeCode.Double * s_TCMAX + TypeCode.Int16, 600 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 601 TypeCode.Double * s_TCMAX + TypeCode.Int32, 602 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 603 TypeCode.Double * s_TCMAX + TypeCode.Int64, 604 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 605 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 606 TypeCode.Double * s_TCMAX + TypeCode.Single, 607 TypeCode.Double * s_TCMAX + TypeCode.Double 608 609 Return CompareDouble(Convert.ToDouble(left), Convert.ToDouble(right)) 610 611 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 612 TypeCode.Byte * s_TCMAX + TypeCode.String, 613 TypeCode.Int16 * s_TCMAX + TypeCode.String, 614 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 615 TypeCode.Int32 * s_TCMAX + TypeCode.String, 616 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 617 TypeCode.Int64 * s_TCMAX + TypeCode.String, 618 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 619 TypeCode.Decimal * s_TCMAX + TypeCode.String, 620 TypeCode.Single * s_TCMAX + TypeCode.String, 621 TypeCode.Double * s_TCMAX + TypeCode.String 622 623 Return CompareDouble(Convert.ToDouble(left), CDbl(Convert.ToString(right))) 624 625 Case TypeCode.Byte * s_TCMAX + TypeCode.Empty 626 Return CompareInt32(Convert.ToByte(left), Nothing) 627 628 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean 629 Return CompareInt32(Convert.ToInt16(left), ToVBBool(right)) 630 631 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 632 Return CompareInt32(Convert.ToByte(left), Convert.ToByte(right)) 633 634 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 635 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 636 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 637 638 Return CompareInt32(Convert.ToUInt16(left), Convert.ToUInt16(right)) 639 640 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 641 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 642 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 643 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 644 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 645 646 Return CompareUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 647 648 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 649 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 650 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 651 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 652 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 653 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 654 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 655 656 Return CompareUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 657 658 Case TypeCode.Int16 * s_TCMAX + TypeCode.Empty 659 Return CompareInt32(Convert.ToInt16(left), Nothing) 660 661 Case TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 662 Return CompareInt32(Convert.ToInt16(left), ToVBBool(right)) 663 664 665 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 666 Return CompareInt32(Convert.ToUInt16(left), Nothing) 667 668 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean 669 Return CompareInt32(Convert.ToInt32(left), ToVBBool(right)) 670 671 Case TypeCode.Int32 * s_TCMAX + TypeCode.Empty 672 Return CompareInt32(Convert.ToInt32(left), Nothing) 673 674 Case TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 675 Return CompareInt32(Convert.ToInt32(left), ToVBBool(right)) 676 677 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 678 Return CompareUInt32(Convert.ToUInt32(left), Nothing) 679 680 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean 681 Return CompareInt64(Convert.ToInt64(left), ToVBBool(right)) 682 683 Case TypeCode.Int64 * s_TCMAX + TypeCode.Empty 684 Return CompareInt64(Convert.ToInt64(left), Nothing) 685 686 Case TypeCode.Int64 * s_TCMAX + TypeCode.Boolean 687 Return CompareInt64(Convert.ToInt64(left), ToVBBool(right)) 688 689 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 690 Return CompareUInt64(Convert.ToUInt64(left), Nothing) 691 692 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean 693 Return CompareDecimal(left, ToVBBool(right)) 694 695 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty 696 Return CompareDecimal(left, 0D) 697 698 Case TypeCode.Decimal * s_TCMAX + TypeCode.Boolean 699 Return CompareDecimal(left, ToVBBool(right)) 700 701 Case TypeCode.Single * s_TCMAX + TypeCode.Empty 702 Return CompareSingle(Convert.ToSingle(left), Nothing) 703 704 Case TypeCode.Single * s_TCMAX + TypeCode.Boolean 705 Return CompareSingle(Convert.ToSingle(left), ToVBBool(right)) 706 707 Case TypeCode.Double * s_TCMAX + TypeCode.Empty 708 Return CompareDouble(Convert.ToDouble(left), Nothing) 709 710 Case TypeCode.Double * s_TCMAX + TypeCode.Boolean 711 Return CompareDouble(Convert.ToDouble(left), ToVBBool(right)) 712 713 Case TypeCode.DateTime * s_TCMAX + TypeCode.Empty 714 Return CompareDate(Convert.ToDateTime(left), Nothing) 715 716 Case TypeCode.DateTime * s_TCMAX + TypeCode.DateTime 717 Return CompareDate(Convert.ToDateTime(left), Convert.ToDateTime(right)) 718 719 Case TypeCode.DateTime * s_TCMAX + TypeCode.String 720 Return CompareDate(Convert.ToDateTime(left), CDate(Convert.ToString(right))) 721 722 Case TypeCode.Char * s_TCMAX + TypeCode.Empty 723 Return CompareChar(Convert.ToChar(left), Nothing) 724 725 Case TypeCode.Char * s_TCMAX + TypeCode.Char 726 Return CompareChar(Convert.ToChar(left), Convert.ToChar(right)) 727 728 Case TypeCode.Char * s_TCMAX + TypeCode.String, 729 TypeCode.String * s_TCMAX + TypeCode.Char, 730 TypeCode.String * s_TCMAX + TypeCode.String 731 Return CType(CompareString(Convert.ToString(left), Convert.ToString(right), textCompare), CompareClass) 732 733 Case TypeCode.String * s_TCMAX + TypeCode.Empty 734 Return CType(CompareString(Convert.ToString(left), Nothing, textCompare), CompareClass) 735 736 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 737 Return CompareBoolean(CBool(Convert.ToString(left)), Convert.ToBoolean(right)) 738 739 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 740 TypeCode.String * s_TCMAX + TypeCode.Byte, 741 TypeCode.String * s_TCMAX + TypeCode.Int16, 742 TypeCode.String * s_TCMAX + TypeCode.UInt16, 743 TypeCode.String * s_TCMAX + TypeCode.Int32, 744 TypeCode.String * s_TCMAX + TypeCode.UInt32, 745 TypeCode.String * s_TCMAX + TypeCode.Int64, 746 TypeCode.String * s_TCMAX + TypeCode.UInt64, 747 TypeCode.String * s_TCMAX + TypeCode.Decimal, 748 TypeCode.String * s_TCMAX + TypeCode.Single, 749 TypeCode.String * s_TCMAX + TypeCode.Double 750 751 Return CompareDouble(CDbl(Convert.ToString(left)), Convert.ToDouble(right)) 752 753 Case TypeCode.String * s_TCMAX + TypeCode.DateTime 754 Return CompareDate(CDate(Convert.ToString(left)), Convert.ToDateTime(right)) 755 756 End Select 757 758 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 759 Return CompareClass.UserDefined 760 End If 761 762 Return CompareClass.Undefined 763 End Function 764 765 Private Shared Function CompareBoolean(ByVal left As Boolean, ByVal right As Boolean) As CompareClass 766 If left = right Then Return CompareClass.Equal 767 If left > right Then Return CompareClass.Greater 768 Return CompareClass.Less 769 End Function 770 771 Private Shared Function CompareInt32(ByVal left As Int32, ByVal right As Int32) As CompareClass 772 If left = right Then Return CompareClass.Equal 773 If left > right Then Return CompareClass.Greater 774 Return CompareClass.Less 775 End Function 776 777 Private Shared Function CompareUInt32(ByVal left As UInt32, ByVal right As UInt32) As CompareClass 778 If left = right Then Return CompareClass.Equal 779 If left > right Then Return CompareClass.Greater 780 Return CompareClass.Less 781 End Function 782 783 Private Shared Function CompareInt64(ByVal left As Int64, ByVal right As Int64) As CompareClass 784 If left = right Then Return CompareClass.Equal 785 If left > right Then Return CompareClass.Greater 786 Return CompareClass.Less 787 End Function 788 789 Private Shared Function CompareUInt64(ByVal left As UInt64, ByVal right As UInt64) As CompareClass 790 If left = right Then Return CompareClass.Equal 791 If left > right Then Return CompareClass.Greater 792 Return CompareClass.Less 793 End Function 794 795 'This function takes IConvertible because the JIT does not behave properly with Decimal temps 796 Private Shared Function CompareDecimal(ByVal left As Object, ByVal right As Object) As CompareClass 797 Dim result As Integer = System.Decimal.Compare(Convert.ToDecimal(left), Convert.ToDecimal(right)) 798 799 'Normalize the result. 800 If result = 0 Then 801 Return CompareClass.Equal 802 ElseIf result > 0 Then 803 Return CompareClass.Greater 804 Else 805 Return CompareClass.Less 806 End If 807 End Function 808 809 Private Shared Function CompareSingle(ByVal left As Single, ByVal right As Single) As CompareClass 810 If left = right Then Return CompareClass.Equal 811 If left < right Then Return CompareClass.Less 812 If left > right Then Return CompareClass.Greater 813 Return CompareClass.Unordered 814 End Function 815 816 Private Shared Function CompareDouble(ByVal left As Double, ByVal right As Double) As CompareClass 817 If left = right Then Return CompareClass.Equal 818 If left < right Then Return CompareClass.Less 819 If left > right Then Return CompareClass.Greater 820 Return CompareClass.Unordered 821 End Function 822 823 Private Shared Function CompareDate(ByVal left As Date, ByVal right As Date) As CompareClass 824 Dim result As Integer = System.DateTime.Compare(left, right) 825 826 'Normalize the result. 827 If result = 0 Then 828 Return CompareClass.Equal 829 ElseIf result > 0 Then 830 Return CompareClass.Greater 831 Else 832 Return CompareClass.Less 833 End If 834 End Function 835 836 Private Shared Function CompareChar(ByVal left As Char, ByVal right As Char) As CompareClass 837 If left = right Then Return CompareClass.Equal 838 If left > right Then Return CompareClass.Greater 839 Return CompareClass.Less 840 End Function 841 842 'String comparisons occur often enough that maybe the TextCompare should be broken out into two members that the compiler statically selects 843 Public Shared Function CompareString(ByVal left As String, ByVal right As String, ByVal textCompare As Boolean) As Integer 844 If left Is right Then 845 Return CompareClass.Equal 846 End If 847 848 If left Is Nothing Then 849 If right.Length() = 0 Then 850 Return CompareClass.Equal 851 End If 852 853 Return CompareClass.Less 854 End If 855 856 If right Is Nothing Then 857 If left.Length() = 0 Then 858 Return CompareClass.Equal 859 End If 860 861 Return CompareClass.Greater 862 End If 863 864 Dim result As Integer 865 866 If textCompare Then 867 result = GetCultureInfo().CompareInfo.Compare(left, right, OptionCompareTextFlags) 868 Else 869 result = System.String.CompareOrdinal(left, right) 870 End If 871 872 'Normalize the result. 873 If result = 0 Then 874 Return CompareClass.Equal 875 ElseIf result > 0 Then 876 Return CompareClass.Greater 877 Else 878 Return CompareClass.Less 879 End If 880 End Function 881 882#End Region 883 884#Region " Operator Unary Plus + " 885 886 Public Shared Function PlusObject(ByVal operand As Object) As Object 887 888 If operand Is Nothing Then 889 Return Boxed_ZeroInteger 890 End If 891 892 Dim typ As TypeCode = GetTypeCode(operand) 893 894 895 Select Case typ 896 897 Case TypeCode.Empty 898 Return Boxed_ZeroInteger 899 900 Case TypeCode.Boolean 901 Return CShort(Convert.ToBoolean(operand)) 902 903 Case TypeCode.SByte 904 Return Convert.ToSByte(operand) 905 906 Case TypeCode.Byte 907 Return Convert.ToByte(operand) 908 909 Case TypeCode.Int16 910 Return Convert.ToInt16(operand) 911 912 Case TypeCode.UInt16 913 Return Convert.ToUInt16(operand) 914 915 Case TypeCode.Int32 916 Return Convert.ToInt32(operand) 917 918 Case TypeCode.UInt32 919 Return Convert.ToUInt32(operand) 920 921 Case TypeCode.Int64 922 Return Convert.ToInt64(operand) 923 924 Case TypeCode.UInt64 925 Return Convert.ToUInt64(operand) 926 927 Case TypeCode.Decimal, 928 TypeCode.Single, 929 TypeCode.Double 930 Return operand 931 932 Case TypeCode.DateTime, 933 TypeCode.Char 934 ' Fall through to error 935 936 Case TypeCode.String 937 Return CDbl(Convert.ToString(operand)) 938 939 Case TypeCode.Object 940 Return InvokeUserDefinedOperator(UserDefinedOperator.UnaryPlus, operand) 941 942 Case Else 943 ' Fall through to error 944 End Select 945 946 Throw GetNoValidOperatorException(UserDefinedOperator.UnaryPlus, operand) 947 End Function 948 949#End Region 950 951#Region " Operator Negate - " 952 953 Public Shared Function NegateObject(ByVal operand As Object) As Object 954 955 Dim tc As TypeCode = GetTypeCode(operand) 956 957 If operand Is Nothing Then 958 tc = TypeCode.Empty 959 Else 960 tc = operand.GetType.GetTypeCode 961 End If 962 963 Select Case tc 964 965 Case TypeCode.Empty 966 Return Boxed_ZeroInteger 967 968 Case TypeCode.Boolean 969 If TypeOf operand Is Boolean Then 970 Return NegateBoolean(DirectCast(operand, Boolean)) 971 Else 972 Return NegateBoolean(Convert.ToBoolean(operand)) 973 End If 974 975 Case TypeCode.SByte 976 If TypeOf operand Is SByte Then 977 Return NegateSByte(DirectCast(operand, SByte)) 978 Else 979 Return NegateSByte(Convert.ToSByte(operand)) 980 End If 981 982 Case TypeCode.Byte 983 If TypeOf operand Is Byte Then 984 Return NegateByte(DirectCast(operand, Byte)) 985 Else 986 Return NegateByte(Convert.ToByte(operand)) 987 End If 988 989 Case TypeCode.Int16 990 If TypeOf operand Is Int16 Then 991 Return NegateInt16(DirectCast(operand, Int16)) 992 Else 993 Return NegateInt16(Convert.ToInt16(operand)) 994 End If 995 996 Case TypeCode.UInt16 997 If TypeOf operand Is UInt16 Then 998 Return NegateUInt16(DirectCast(operand, UInt16)) 999 Else 1000 Return NegateUInt16(Convert.ToUInt16(operand)) 1001 End If 1002 1003 Case TypeCode.Int32 1004 If TypeOf operand Is Int32 Then 1005 Return NegateInt32(DirectCast(operand, Int32)) 1006 Else 1007 Return NegateInt32(Convert.ToInt32(operand)) 1008 End If 1009 1010 Case TypeCode.UInt32 1011 If TypeOf operand Is UInt32 Then 1012 Return NegateUInt32(DirectCast(operand, UInt32)) 1013 Else 1014 Return NegateUInt32(Convert.ToUInt32(operand)) 1015 End If 1016 1017 Case TypeCode.Int64 1018 If TypeOf operand Is Int64 Then 1019 Return NegateInt64(DirectCast(operand, Int64)) 1020 Else 1021 Return NegateInt64(Convert.ToInt64(operand)) 1022 End If 1023 1024 Case TypeCode.UInt64 1025 If TypeOf operand Is UInt64 Then 1026 Return NegateUInt64(DirectCast(operand, UInt64)) 1027 Else 1028 Return NegateUInt64(Convert.ToUInt64(operand)) 1029 End If 1030 1031 Case TypeCode.Decimal 1032 If TypeOf operand Is Decimal Then 1033 Return NegateDecimal(DirectCast(operand, Decimal)) 1034 Else 1035 Return NegateDecimal(Convert.ToDecimal(operand)) 1036 End If 1037 1038 Case TypeCode.Single 1039 If TypeOf operand Is Single Then 1040 Return NegateSingle(DirectCast(operand, Single)) 1041 Else 1042 Return NegateSingle(Convert.ToSingle(operand)) 1043 End If 1044 1045 Case TypeCode.Double 1046 If TypeOf operand Is Double Then 1047 Return NegateDouble(DirectCast(operand, Double)) 1048 Else 1049 Return NegateDouble(Convert.ToDouble(operand)) 1050 End If 1051 1052 Case TypeCode.DateTime, 1053 TypeCode.Char 1054 'Fall through to error. 1055 1056 Case TypeCode.String 1057 Dim stringOperand As String = TryCast(operand, String) 1058 1059 If stringOperand IsNot Nothing Then 1060 Return NegateString(stringOperand) 1061 Else 1062 Return NegateString(Convert.ToString(operand)) 1063 End If 1064 1065 Case TypeCode.Object 1066 Return InvokeUserDefinedOperator(UserDefinedOperator.Negate, operand) 1067 1068 Case Else 1069 'Fall through to error. 1070 End Select 1071 1072 Throw GetNoValidOperatorException(UserDefinedOperator.Negate, operand) 1073 End Function 1074 1075 Private Shared Function NegateBoolean(ByVal operand As Boolean) As Object 1076 Return -CShort(operand) 1077 End Function 1078 1079 Private Shared Function NegateSByte(ByVal operand As SByte) As Object 1080 If operand = SByte.MinValue Then 1081 Return -CShort(SByte.MinValue) 1082 End If 1083 Return -operand 1084 End Function 1085 1086 Private Shared Function NegateByte(ByVal operand As Byte) As Object 1087 Return -CShort(operand) 1088 End Function 1089 1090 Private Shared Function NegateInt16(ByVal operand As Int16) As Object 1091 If operand = Int16.MinValue Then 1092 Return -CInt(Int16.MinValue) 1093 End If 1094 Return -operand 1095 End Function 1096 1097 Private Shared Function NegateUInt16(ByVal operand As UInt16) As Object 1098 Return -CInt(operand) 1099 End Function 1100 1101 Private Shared Function NegateInt32(ByVal operand As Int32) As Object 1102 If operand = Int32.MinValue Then 1103 Return -CLng(Int32.MinValue) 1104 End If 1105 Return -operand 1106 End Function 1107 1108 Private Shared Function NegateUInt32(ByVal operand As UInt32) As Object 1109 Return -CLng(operand) 1110 End Function 1111 1112 Private Shared Function NegateInt64(ByVal operand As Int64) As Object 1113 If operand = Int64.MinValue Then 1114 Return -CDec(Int64.MinValue) 1115 End If 1116 Return -operand 1117 End Function 1118 1119 Private Shared Function NegateUInt64(ByVal operand As UInt64) As Object 1120 Return -CDec(operand) 1121 End Function 1122 1123 Private Shared Function NegateDecimal(ByVal operand As Decimal) As Object 1124 'Using try/catch instead of check with MinValue since the overflow case should be very rare 1125 'and a compare would be a big cost for the normal case. 1126 Try 1127 Return -operand 1128 Catch ex As OverflowException 1129 Return -CDbl(operand) 1130 End Try 1131 End Function 1132 1133 Private Shared Function NegateSingle(ByVal operand As Single) As Object 1134 Return -operand 1135 End Function 1136 1137 Private Shared Function NegateDouble(ByVal operand As Double) As Object 1138 Return -operand 1139 End Function 1140 1141 Private Shared Function NegateString(ByVal operand As String) As Object 1142 Return -CDbl(operand) 1143 End Function 1144 1145#End Region 1146 1147#Region " Operator Not " 1148 1149 Public Shared Function NotObject(ByVal operand As Object) As Object 1150 1151 Dim tc As TypeCode = GetTypeCode(operand) 1152 1153 Select Case tc 1154 1155 Case TypeCode.Empty 1156 Return Not 0I 1157 1158 Case TypeCode.Boolean 1159 Return NotBoolean(Convert.ToBoolean(operand)) 1160 1161 Case TypeCode.SByte 1162 Return NotSByte(Convert.ToSByte(operand), operand.GetType()) 1163 1164 Case TypeCode.Byte 1165 Return NotByte(Convert.ToByte(operand), operand.GetType()) 1166 1167 Case TypeCode.Int16 1168 Return NotInt16(Convert.ToInt16(operand), operand.GetType()) 1169 1170 Case TypeCode.UInt16 1171 Return NotUInt16(Convert.ToUInt16(operand), operand.GetType()) 1172 1173 Case TypeCode.Int32 1174 Return NotInt32(Convert.ToInt32(operand), operand.GetType()) 1175 1176 Case TypeCode.UInt32 1177 Return NotUInt32(Convert.ToUInt32(operand), operand.GetType()) 1178 1179 Case TypeCode.Int64 1180 Return NotInt64(Convert.ToInt64(operand), operand.GetType()) 1181 1182 Case TypeCode.UInt64 1183 Return NotUInt64(Convert.ToUInt64(operand), operand.GetType()) 1184 1185 Case TypeCode.Decimal, 1186 TypeCode.Single, 1187 TypeCode.Double 1188 Return NotInt64(Convert.ToInt64(operand)) 1189 1190 Case TypeCode.DateTime, 1191 TypeCode.Char 1192 'Fall through to error. 1193 1194 Case TypeCode.String 1195 Return NotInt64(CLng(Convert.ToString(operand))) 1196 1197 Case TypeCode.Object 1198 Return InvokeUserDefinedOperator(UserDefinedOperator.Not, operand) 1199 1200 Case Else 1201 'Fall through to error. 1202 End Select 1203 1204 Throw GetNoValidOperatorException(UserDefinedOperator.Not, operand) 1205 End Function 1206 1207 Private Shared Function NotBoolean(ByVal operand As Boolean) As Object 1208 Return Not operand 1209 End Function 1210 1211 Private Shared Function NotSByte(ByVal operand As SByte, ByVal operandType As Type) As Object 1212 Dim result As SByte = Not operand 1213 1214 If operandType.IsEnum Then 1215 Return System.Enum.ToObject(operandType, result) 1216 End If 1217 Return result 1218 End Function 1219 1220 Private Shared Function NotByte(ByVal operand As Byte, ByVal operandType As Type) As Object 1221 Dim result As Byte = Not operand 1222 1223 If operandType.IsEnum Then 1224 Return System.Enum.ToObject(operandType, result) 1225 End If 1226 Return result 1227 End Function 1228 1229 Private Shared Function NotInt16(ByVal operand As Int16, ByVal operandType As Type) As Object 1230 Dim result As Int16 = Not operand 1231 1232 If operandType.IsEnum Then 1233 Return System.Enum.ToObject(operandType, result) 1234 End If 1235 Return result 1236 End Function 1237 1238 Private Shared Function NotUInt16(ByVal operand As UInt16, ByVal operandType As Type) As Object 1239 Dim result As UInt16 = Not operand 1240 1241 If operandType.IsEnum Then 1242 Return System.Enum.ToObject(operandType, result) 1243 End If 1244 Return result 1245 End Function 1246 1247 Private Shared Function NotInt32(ByVal operand As Int32, ByVal operandType As Type) As Object 1248 Dim result As Int32 = Not operand 1249 1250 If operandType.IsEnum Then 1251 Return System.Enum.ToObject(operandType, result) 1252 End If 1253 Return result 1254 End Function 1255 1256 Private Shared Function NotUInt32(ByVal operand As UInt32, ByVal operandType As Type) As Object 1257 Dim result As UInt32 = Not operand 1258 1259 If operandType.IsEnum Then 1260 Return System.Enum.ToObject(operandType, result) 1261 End If 1262 Return result 1263 End Function 1264 1265 Private Shared Function NotInt64(ByVal operand As Int64) As Object 1266 Return Not operand 1267 End Function 1268 1269 Private Shared Function NotInt64(ByVal operand As Int64, ByVal operandType As Type) As Object 1270 Dim result As Int64 = Not operand 1271 1272 If operandType.IsEnum Then 1273 Return System.Enum.ToObject(operandType, result) 1274 End If 1275 Return result 1276 End Function 1277 1278 Private Shared Function NotUInt64(ByVal operand As UInt64, ByVal operandType As Type) As Object 1279 Dim result As UInt64 = Not operand 1280 1281 If operandType.IsEnum Then 1282 Return System.Enum.ToObject(operandType, result) 1283 End If 1284 Return result 1285 End Function 1286 1287#End Region 1288 1289#Region " Operator And " 1290 1291 Public Shared Function AndObject(ByVal left As Object, ByVal right As Object) As Object 1292 1293 Dim tc1 As TypeCode = GetTypeCode(left) 1294 Dim tc2 As TypeCode = GetTypeCode(right) 1295 1296 1297 Select Case tc1 * s_TCMAX + tc2 1298 1299 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 1300 Return Boxed_ZeroInteger 1301 1302 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean, 1303 TypeCode.Boolean * s_TCMAX + TypeCode.Empty 1304 Return False 1305 1306 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte, 1307 TypeCode.SByte * s_TCMAX + TypeCode.Empty 1308 Return AndSByte(CSByte(0), CSByte(0), GetEnumResult(left, right)) 1309 1310 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte, 1311 TypeCode.Byte * s_TCMAX + TypeCode.Empty 1312 Return AndByte(CByte(0), CByte(0), GetEnumResult(left, right)) 1313 1314 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16, 1315 TypeCode.Int16 * s_TCMAX + TypeCode.Empty 1316 Return AndInt16(0S, 0S, GetEnumResult(left, right)) 1317 1318 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16, 1319 TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 1320 Return AndUInt16(0US, 0US, GetEnumResult(left, right)) 1321 1322 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32, 1323 TypeCode.Int32 * s_TCMAX + TypeCode.Empty 1324 Return AndInt32(0I, 0I, GetEnumResult(left, right)) 1325 1326 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32, 1327 TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 1328 Return AndUInt32(0UI, 0UI, GetEnumResult(left, right)) 1329 1330 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64, 1331 TypeCode.Int64 * s_TCMAX + TypeCode.Empty 1332 Return AndInt64(0L, 0L, GetEnumResult(left, right)) 1333 1334 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64, 1335 TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 1336 Return AndUInt64(0UL, 0UL, GetEnumResult(left, right)) 1337 1338 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal, 1339 TypeCode.Empty * s_TCMAX + TypeCode.Single, 1340 TypeCode.Empty * s_TCMAX + TypeCode.Double 1341 Return AndInt64(Nothing, Convert.ToInt64(right)) 1342 1343 Case TypeCode.Empty * s_TCMAX + TypeCode.String 1344 Return AndInt64(Nothing, CLng(Convert.ToString(right))) 1345 1346 1347 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 1348 Return AndBoolean(Convert.ToBoolean(left), Convert.ToBoolean(right)) 1349 1350 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 1351 Return AndSByte(ToVBBool(left), Convert.ToSByte(right)) 1352 1353 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 1354 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 1355 Return AndInt16(ToVBBool(left), Convert.ToInt16(right)) 1356 1357 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 1358 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 1359 Return AndInt32(ToVBBool(left), Convert.ToInt32(right)) 1360 1361 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 1362 TypeCode.Boolean * s_TCMAX + TypeCode.Int64, 1363 TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 1364 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal, 1365 TypeCode.Boolean * s_TCMAX + TypeCode.Single, 1366 TypeCode.Boolean * s_TCMAX + TypeCode.Double 1367 1368 Return AndInt64(ToVBBool(left), Convert.ToInt64(right)) 1369 1370 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 1371 Return AndBoolean(Convert.ToBoolean(left), CBool(Convert.ToString(right))) 1372 1373 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 1374 Return AndSByte(Convert.ToSByte(left), ToVBBool(right)) 1375 1376 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 1377 Return AndSByte(Convert.ToSByte(left), Convert.ToSByte(right), GetEnumResult(left, right)) 1378 1379 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 1380 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 1381 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 1382 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 1383 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 1384 TypeCode.Int16 * s_TCMAX + TypeCode.Byte 1385 1386 Return AndInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 1387 1388 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 1389 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 1390 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 1391 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 1392 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 1393 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 1394 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 1395 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 1396 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 1397 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 1398 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 1399 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16 1400 1401 Return AndInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 1402 1403 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 1404 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 1405 TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 1406 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 1407 TypeCode.SByte * s_TCMAX + TypeCode.Single, 1408 TypeCode.SByte * s_TCMAX + TypeCode.Double, 1409 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 1410 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 1411 TypeCode.Byte * s_TCMAX + TypeCode.Single, 1412 TypeCode.Byte * s_TCMAX + TypeCode.Double, 1413 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 1414 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 1415 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 1416 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 1417 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 1418 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 1419 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 1420 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 1421 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 1422 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 1423 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 1424 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 1425 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 1426 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 1427 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 1428 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 1429 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 1430 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 1431 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 1432 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 1433 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 1434 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 1435 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 1436 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 1437 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 1438 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 1439 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 1440 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 1441 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 1442 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 1443 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 1444 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 1445 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 1446 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 1447 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 1448 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 1449 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 1450 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 1451 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 1452 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 1453 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 1454 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 1455 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 1456 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 1457 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 1458 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 1459 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 1460 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 1461 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal, 1462 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 1463 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 1464 TypeCode.Single * s_TCMAX + TypeCode.SByte, 1465 TypeCode.Single * s_TCMAX + TypeCode.Byte, 1466 TypeCode.Single * s_TCMAX + TypeCode.Int16, 1467 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 1468 TypeCode.Single * s_TCMAX + TypeCode.Int32, 1469 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 1470 TypeCode.Single * s_TCMAX + TypeCode.Int64, 1471 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 1472 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 1473 TypeCode.Single * s_TCMAX + TypeCode.Single, 1474 TypeCode.Single * s_TCMAX + TypeCode.Double, 1475 TypeCode.Double * s_TCMAX + TypeCode.SByte, 1476 TypeCode.Double * s_TCMAX + TypeCode.Byte, 1477 TypeCode.Double * s_TCMAX + TypeCode.Int16, 1478 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 1479 TypeCode.Double * s_TCMAX + TypeCode.Int32, 1480 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 1481 TypeCode.Double * s_TCMAX + TypeCode.Int64, 1482 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 1483 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 1484 TypeCode.Double * s_TCMAX + TypeCode.Single, 1485 TypeCode.Double * s_TCMAX + TypeCode.Double 1486 1487 Return AndInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 1488 1489 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 1490 TypeCode.Byte * s_TCMAX + TypeCode.String, 1491 TypeCode.Int16 * s_TCMAX + TypeCode.String, 1492 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 1493 TypeCode.Int32 * s_TCMAX + TypeCode.String, 1494 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 1495 TypeCode.Int64 * s_TCMAX + TypeCode.String, 1496 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 1497 TypeCode.Decimal * s_TCMAX + TypeCode.String, 1498 TypeCode.Single * s_TCMAX + TypeCode.String, 1499 TypeCode.Double * s_TCMAX + TypeCode.String 1500 1501 Return AndInt64(Convert.ToInt64(left), CLng(Convert.ToString(right))) 1502 1503 1504 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 1505 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 1506 Return AndInt16(Convert.ToInt16(left), ToVBBool(right)) 1507 1508 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 1509 Return AndByte(Convert.ToByte(left), Convert.ToByte(right), GetEnumResult(left, right)) 1510 1511 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 1512 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte 1513 Return AndUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 1514 1515 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 1516 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 1517 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 1518 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16 1519 1520 Return AndUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 1521 1522 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 1523 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 1524 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 1525 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 1526 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 1527 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32 1528 1529 Return AndUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 1530 1531 1532 Case TypeCode.Int16 * s_TCMAX + TypeCode.Int16 1533 Return AndInt16(Convert.ToInt16(left), Convert.ToInt16(right), GetEnumResult(left, right)) 1534 1535 1536 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 1537 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 1538 Return AndInt32(Convert.ToInt32(left), ToVBBool(right)) 1539 1540 Case TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 1541 Return AndUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right), GetEnumResult(left, right)) 1542 1543 1544 Case TypeCode.Int32 * s_TCMAX + TypeCode.Int32 1545 Return AndInt32(Convert.ToInt32(left), Convert.ToInt32(right), GetEnumResult(left, right)) 1546 1547 1548 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 1549 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean, 1550 TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 1551 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean, 1552 TypeCode.Single * s_TCMAX + TypeCode.Boolean, 1553 TypeCode.Double * s_TCMAX + TypeCode.Boolean 1554 Return AndInt64(Convert.ToInt64(left), ToVBBool(right)) 1555 1556 Case TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 1557 Return AndUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right), GetEnumResult(left, right)) 1558 1559 1560 Case TypeCode.Int64 * s_TCMAX + TypeCode.Int64 1561 Return AndInt64(Convert.ToInt64(left), Convert.ToInt64(right), GetEnumResult(left, right)) 1562 1563 1564 Case TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 1565 Return AndUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right), GetEnumResult(left, right)) 1566 1567 1568 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty, 1569 TypeCode.Single * s_TCMAX + TypeCode.Empty, 1570 TypeCode.Double * s_TCMAX + TypeCode.Empty 1571 Return AndInt64(Convert.ToInt64(left), Nothing) 1572 1573 1574 Case TypeCode.String * s_TCMAX + TypeCode.Empty 1575 Return AndInt64(CLng(Convert.ToString(left)), Nothing) 1576 1577 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 1578 Return AndBoolean(CBool(Convert.ToString(left)), Convert.ToBoolean(right)) 1579 1580 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 1581 TypeCode.String * s_TCMAX + TypeCode.Byte, 1582 TypeCode.String * s_TCMAX + TypeCode.Int16, 1583 TypeCode.String * s_TCMAX + TypeCode.UInt16, 1584 TypeCode.String * s_TCMAX + TypeCode.Int32, 1585 TypeCode.String * s_TCMAX + TypeCode.UInt32, 1586 TypeCode.String * s_TCMAX + TypeCode.Int64, 1587 TypeCode.String * s_TCMAX + TypeCode.UInt64, 1588 TypeCode.String * s_TCMAX + TypeCode.Decimal, 1589 TypeCode.String * s_TCMAX + TypeCode.Single, 1590 TypeCode.String * s_TCMAX + TypeCode.Double 1591 1592 Return AndInt64(CLng(Convert.ToString(left)), Convert.ToInt64(right)) 1593 1594 Case TypeCode.String * s_TCMAX + TypeCode.String 1595 Return AndInt64(CLng(Convert.ToString(left)), CLng(Convert.ToString(right))) 1596 1597 End Select 1598 1599 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 1600 Return InvokeUserDefinedOperator(UserDefinedOperator.And, left, right) 1601 End If 1602 1603 Throw GetNoValidOperatorException(UserDefinedOperator.And, left, right) 1604 End Function 1605 1606 Private Shared Function AndBoolean(ByVal left As Boolean, ByVal right As Boolean) As Object 1607 Return left And right 1608 End Function 1609 1610 Private Shared Function AndSByte(ByVal left As SByte, ByVal right As SByte, Optional ByVal enumType As Type = Nothing) As Object 1611 Dim result As SByte = left And right 1612 1613 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1614 Return result 1615 End Function 1616 1617 Private Shared Function AndByte(ByVal left As Byte, ByVal right As Byte, Optional ByVal enumType As Type = Nothing) As Object 1618 Dim result As Byte = left And right 1619 1620 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1621 Return result 1622 End Function 1623 1624 Private Shared Function AndInt16(ByVal left As Int16, ByVal right As Int16, Optional ByVal enumType As Type = Nothing) As Object 1625 Dim result As Int16 = left And right 1626 1627 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1628 Return result 1629 End Function 1630 1631 Private Shared Function AndUInt16(ByVal left As UInt16, ByVal right As UInt16, Optional ByVal enumType As Type = Nothing) As Object 1632 Dim result As UInt16 = left And right 1633 1634 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1635 Return result 1636 End Function 1637 1638 Private Shared Function AndInt32(ByVal left As Int32, ByVal right As Int32, Optional ByVal enumType As Type = Nothing) As Object 1639 Dim result As Int32 = left And right 1640 1641 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1642 Return result 1643 End Function 1644 1645 Private Shared Function AndUInt32(ByVal left As UInt32, ByVal right As UInt32, Optional ByVal enumType As Type = Nothing) As Object 1646 Dim result As UInt32 = left And right 1647 1648 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1649 Return result 1650 End Function 1651 1652 Private Shared Function AndInt64(ByVal left As Int64, ByVal right As Int64, Optional ByVal enumType As Type = Nothing) As Object 1653 Dim result As Int64 = left And right 1654 1655 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1656 Return result 1657 End Function 1658 1659 Private Shared Function AndUInt64(ByVal left As UInt64, ByVal right As UInt64, Optional ByVal enumType As Type = Nothing) As Object 1660 Dim result As UInt64 = left And right 1661 1662 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1663 Return result 1664 End Function 1665 1666#End Region 1667 1668#Region " Operator Or " 1669 1670 Public Shared Function OrObject(ByVal left As Object, ByVal right As Object) As Object 1671 1672 Dim tc1 As TypeCode = GetTypeCode(left) 1673 Dim tc2 As TypeCode = GetTypeCode(right) 1674 1675 Select Case tc1 * s_TCMAX + tc2 1676 1677 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 1678 Return Boxed_ZeroInteger 1679 1680 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 1681 Return OrBoolean(Nothing, Convert.ToBoolean(right)) 1682 1683 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte, 1684 TypeCode.Empty * s_TCMAX + TypeCode.Byte, 1685 TypeCode.Empty * s_TCMAX + TypeCode.Int16, 1686 TypeCode.Empty * s_TCMAX + TypeCode.UInt16, 1687 TypeCode.Empty * s_TCMAX + TypeCode.Int32, 1688 TypeCode.Empty * s_TCMAX + TypeCode.UInt32, 1689 TypeCode.Empty * s_TCMAX + TypeCode.Int64, 1690 TypeCode.Empty * s_TCMAX + TypeCode.UInt64 1691 1692 Return right 1693 1694 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal, 1695 TypeCode.Empty * s_TCMAX + TypeCode.Single, 1696 TypeCode.Empty * s_TCMAX + TypeCode.Double 1697 Return OrInt64(Nothing, Convert.ToInt64(right)) 1698 1699 Case TypeCode.Empty * s_TCMAX + TypeCode.String 1700 Return OrInt64(Nothing, CLng(Convert.ToString(right))) 1701 1702 1703 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 1704 Return OrBoolean(Convert.ToBoolean(left), Nothing) 1705 1706 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 1707 Return OrBoolean(Convert.ToBoolean(left), Convert.ToBoolean(right)) 1708 1709 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 1710 Return OrSByte(ToVBBool(left), Convert.ToSByte(right)) 1711 1712 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 1713 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 1714 Return OrInt16(ToVBBool(left), Convert.ToInt16(right)) 1715 1716 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 1717 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 1718 Return OrInt32(ToVBBool(left), Convert.ToInt32(right)) 1719 1720 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 1721 TypeCode.Boolean * s_TCMAX + TypeCode.Int64, 1722 TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 1723 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal, 1724 TypeCode.Boolean * s_TCMAX + TypeCode.Single, 1725 TypeCode.Boolean * s_TCMAX + TypeCode.Double 1726 1727 Return OrInt64(ToVBBool(left), Convert.ToInt64(right)) 1728 1729 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 1730 Return OrBoolean(Convert.ToBoolean(left), CBool(Convert.ToString(right))) 1731 1732 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty, 1733 TypeCode.Byte * s_TCMAX + TypeCode.Empty, 1734 TypeCode.Int16 * s_TCMAX + TypeCode.Empty, 1735 TypeCode.UInt16 * s_TCMAX + TypeCode.Empty, 1736 TypeCode.Int32 * s_TCMAX + TypeCode.Empty, 1737 TypeCode.UInt32 * s_TCMAX + TypeCode.Empty, 1738 TypeCode.Int64 * s_TCMAX + TypeCode.Empty, 1739 TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 1740 1741 Return left 1742 1743 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 1744 Return OrSByte(Convert.ToSByte(left), ToVBBool(right)) 1745 1746 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 1747 Return OrSByte(Convert.ToSByte(left), Convert.ToSByte(right), GetEnumResult(left, right)) 1748 1749 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 1750 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 1751 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 1752 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 1753 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 1754 TypeCode.Int16 * s_TCMAX + TypeCode.Byte 1755 1756 Return OrInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 1757 1758 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 1759 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 1760 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 1761 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 1762 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 1763 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 1764 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 1765 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 1766 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 1767 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 1768 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 1769 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16 1770 1771 Return OrInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 1772 1773 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 1774 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 1775 TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 1776 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 1777 TypeCode.SByte * s_TCMAX + TypeCode.Single, 1778 TypeCode.SByte * s_TCMAX + TypeCode.Double, 1779 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 1780 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 1781 TypeCode.Byte * s_TCMAX + TypeCode.Single, 1782 TypeCode.Byte * s_TCMAX + TypeCode.Double, 1783 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 1784 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 1785 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 1786 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 1787 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 1788 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 1789 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 1790 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 1791 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 1792 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 1793 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 1794 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 1795 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 1796 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 1797 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 1798 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 1799 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 1800 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 1801 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 1802 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 1803 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 1804 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 1805 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 1806 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 1807 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 1808 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 1809 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 1810 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 1811 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 1812 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 1813 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 1814 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 1815 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 1816 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 1817 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 1818 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 1819 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 1820 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 1821 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 1822 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 1823 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 1824 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 1825 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 1826 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 1827 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 1828 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 1829 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 1830 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 1831 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal, 1832 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 1833 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 1834 TypeCode.Single * s_TCMAX + TypeCode.SByte, 1835 TypeCode.Single * s_TCMAX + TypeCode.Byte, 1836 TypeCode.Single * s_TCMAX + TypeCode.Int16, 1837 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 1838 TypeCode.Single * s_TCMAX + TypeCode.Int32, 1839 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 1840 TypeCode.Single * s_TCMAX + TypeCode.Int64, 1841 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 1842 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 1843 TypeCode.Single * s_TCMAX + TypeCode.Single, 1844 TypeCode.Single * s_TCMAX + TypeCode.Double, 1845 TypeCode.Double * s_TCMAX + TypeCode.SByte, 1846 TypeCode.Double * s_TCMAX + TypeCode.Byte, 1847 TypeCode.Double * s_TCMAX + TypeCode.Int16, 1848 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 1849 TypeCode.Double * s_TCMAX + TypeCode.Int32, 1850 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 1851 TypeCode.Double * s_TCMAX + TypeCode.Int64, 1852 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 1853 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 1854 TypeCode.Double * s_TCMAX + TypeCode.Single, 1855 TypeCode.Double * s_TCMAX + TypeCode.Double 1856 1857 Return OrInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 1858 1859 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 1860 TypeCode.Byte * s_TCMAX + TypeCode.String, 1861 TypeCode.Int16 * s_TCMAX + TypeCode.String, 1862 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 1863 TypeCode.Int32 * s_TCMAX + TypeCode.String, 1864 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 1865 TypeCode.Int64 * s_TCMAX + TypeCode.String, 1866 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 1867 TypeCode.Decimal * s_TCMAX + TypeCode.String, 1868 TypeCode.Single * s_TCMAX + TypeCode.String, 1869 TypeCode.Double * s_TCMAX + TypeCode.String 1870 1871 Return OrInt64(Convert.ToInt64(left), CLng(Convert.ToString(right))) 1872 1873 1874 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 1875 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 1876 Return OrInt16(Convert.ToInt16(left), ToVBBool(right)) 1877 1878 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 1879 Return OrByte(Convert.ToByte(left), Convert.ToByte(right), GetEnumResult(left, right)) 1880 1881 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 1882 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte 1883 Return OrUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 1884 1885 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 1886 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 1887 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 1888 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16 1889 1890 Return OrUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 1891 1892 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 1893 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 1894 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 1895 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 1896 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 1897 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32 1898 1899 Return OrUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 1900 1901 1902 Case TypeCode.Int16 * s_TCMAX + TypeCode.Int16 1903 Return OrInt16(Convert.ToInt16(left), Convert.ToInt16(right), GetEnumResult(left, right)) 1904 1905 1906 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 1907 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 1908 Return OrInt32(Convert.ToInt32(left), ToVBBool(right)) 1909 1910 Case TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 1911 Return OrUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right), GetEnumResult(left, right)) 1912 1913 1914 Case TypeCode.Int32 * s_TCMAX + TypeCode.Int32 1915 Return OrInt32(Convert.ToInt32(left), Convert.ToInt32(right), GetEnumResult(left, right)) 1916 1917 1918 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 1919 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean, 1920 TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 1921 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean, 1922 TypeCode.Single * s_TCMAX + TypeCode.Boolean, 1923 TypeCode.Double * s_TCMAX + TypeCode.Boolean 1924 1925 Return OrInt64(Convert.ToInt64(left), ToVBBool(right)) 1926 1927 Case TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 1928 Return OrUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right), GetEnumResult(left, right)) 1929 1930 1931 Case TypeCode.Int64 * s_TCMAX + TypeCode.Int64 1932 Return OrInt64(Convert.ToInt64(left), Convert.ToInt64(right), GetEnumResult(left, right)) 1933 1934 1935 Case TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 1936 Return OrUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right), GetEnumResult(left, right)) 1937 1938 1939 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty, 1940 TypeCode.Single * s_TCMAX + TypeCode.Empty, 1941 TypeCode.Double * s_TCMAX + TypeCode.Empty 1942 Return OrInt64(Convert.ToInt64(left), Nothing) 1943 1944 1945 Case TypeCode.String * s_TCMAX + TypeCode.Empty 1946 Return OrInt64(CLng(Convert.ToString(left)), Nothing) 1947 1948 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 1949 Return OrBoolean(CBool(Convert.ToString(left)), Convert.ToBoolean(right)) 1950 1951 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 1952 TypeCode.String * s_TCMAX + TypeCode.Byte, 1953 TypeCode.String * s_TCMAX + TypeCode.Int16, 1954 TypeCode.String * s_TCMAX + TypeCode.UInt16, 1955 TypeCode.String * s_TCMAX + TypeCode.Int32, 1956 TypeCode.String * s_TCMAX + TypeCode.UInt32, 1957 TypeCode.String * s_TCMAX + TypeCode.Int64, 1958 TypeCode.String * s_TCMAX + TypeCode.UInt64, 1959 TypeCode.String * s_TCMAX + TypeCode.Decimal, 1960 TypeCode.String * s_TCMAX + TypeCode.Single, 1961 TypeCode.String * s_TCMAX + TypeCode.Double 1962 1963 Return OrInt64(CLng(Convert.ToString(left)), Convert.ToInt64(right)) 1964 1965 Case TypeCode.String * s_TCMAX + TypeCode.String 1966 Return OrInt64(CLng(Convert.ToString(left)), CLng(Convert.ToString(right))) 1967 1968 End Select 1969 1970 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 1971 Return InvokeUserDefinedOperator(UserDefinedOperator.Or, left, right) 1972 End If 1973 1974 Throw GetNoValidOperatorException(UserDefinedOperator.Or, left, right) 1975 End Function 1976 1977 Private Shared Function OrBoolean(ByVal left As Boolean, ByVal right As Boolean) As Object 1978 Return left Or right 1979 End Function 1980 1981 Private Shared Function OrSByte(ByVal left As SByte, ByVal right As SByte, Optional ByVal enumType As Type = Nothing) As Object 1982 Dim result As SByte = left Or right 1983 1984 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1985 Return result 1986 End Function 1987 1988 Private Shared Function OrByte(ByVal left As Byte, ByVal right As Byte, Optional ByVal enumType As Type = Nothing) As Object 1989 Dim result As Byte = left Or right 1990 1991 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1992 Return result 1993 End Function 1994 1995 Private Shared Function OrInt16(ByVal left As Int16, ByVal right As Int16, Optional ByVal enumType As Type = Nothing) As Object 1996 Dim result As Int16 = left Or right 1997 1998 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 1999 Return result 2000 End Function 2001 2002 Private Shared Function OrUInt16(ByVal left As UInt16, ByVal right As UInt16, Optional ByVal enumType As Type = Nothing) As Object 2003 Dim result As UInt16 = left Or right 2004 2005 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2006 Return result 2007 End Function 2008 2009 Private Shared Function OrInt32(ByVal left As Int32, ByVal right As Int32, Optional ByVal enumType As Type = Nothing) As Object 2010 Dim result As Int32 = left Or right 2011 2012 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2013 Return result 2014 End Function 2015 2016 Private Shared Function OrUInt32(ByVal left As UInt32, ByVal right As UInt32, Optional ByVal enumType As Type = Nothing) As Object 2017 Dim result As UInt32 = left Or right 2018 2019 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2020 Return result 2021 End Function 2022 2023 Private Shared Function OrInt64(ByVal left As Int64, ByVal right As Int64, Optional ByVal enumType As Type = Nothing) As Object 2024 Dim result As Int64 = left Or right 2025 2026 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2027 Return result 2028 End Function 2029 2030 Private Shared Function OrUInt64(ByVal left As UInt64, ByVal right As UInt64, Optional ByVal enumType As Type = Nothing) As Object 2031 Dim result As UInt64 = left Or right 2032 2033 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2034 Return result 2035 End Function 2036 2037#End Region 2038 2039#Region " Operator Xor " 2040 2041 Public Shared Function XorObject(ByVal left As Object, ByVal right As Object) As Object 2042 2043 Dim tc1 As TypeCode = GetTypeCode(left) 2044 Dim tc2 As TypeCode = GetTypeCode(right) 2045 2046 Select Case tc1 * s_TCMAX + tc2 2047 2048 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 2049 Return Boxed_ZeroInteger 2050 2051 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 2052 Return XorBoolean(Nothing, Convert.ToBoolean(right)) 2053 2054 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte 2055 Return XorSByte(Nothing, Convert.ToSByte(right), GetEnumResult(left, right)) 2056 2057 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte 2058 Return XorByte(Nothing, Convert.ToByte(right), GetEnumResult(left, right)) 2059 2060 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16 2061 Return XorInt16(Nothing, Convert.ToInt16(right), GetEnumResult(left, right)) 2062 2063 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16 2064 Return XorUInt16(Nothing, Convert.ToUInt16(right), GetEnumResult(left, right)) 2065 2066 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32 2067 Return XorInt32(Nothing, Convert.ToInt32(right), GetEnumResult(left, right)) 2068 2069 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32 2070 Return XorUInt32(Nothing, Convert.ToUInt32(right), GetEnumResult(left, right)) 2071 2072 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64 2073 Return XorInt64(Nothing, Convert.ToInt64(right), GetEnumResult(left, right)) 2074 2075 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64 2076 Return XorUInt64(Nothing, Convert.ToUInt64(right), GetEnumResult(left, right)) 2077 2078 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal, 2079 TypeCode.Empty * s_TCMAX + TypeCode.Single, 2080 TypeCode.Empty * s_TCMAX + TypeCode.Double 2081 Return XorInt64(Nothing, Convert.ToInt64(right)) 2082 2083 Case TypeCode.Empty * s_TCMAX + TypeCode.String 2084 Return XorInt64(Nothing, CLng(Convert.ToString(right))) 2085 2086 2087 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 2088 Return XorBoolean(Convert.ToBoolean(left), Nothing) 2089 2090 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 2091 Return XorBoolean(Convert.ToBoolean(left), Convert.ToBoolean(right)) 2092 2093 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 2094 Return XorSByte(ToVBBool(left), Convert.ToSByte(right)) 2095 2096 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 2097 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 2098 Return XorInt16(ToVBBool(left), Convert.ToInt16(right)) 2099 2100 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 2101 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 2102 Return XorInt32(ToVBBool(left), Convert.ToInt32(right)) 2103 2104 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 2105 TypeCode.Boolean * s_TCMAX + TypeCode.Int64, 2106 TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 2107 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal, 2108 TypeCode.Boolean * s_TCMAX + TypeCode.Single, 2109 TypeCode.Boolean * s_TCMAX + TypeCode.Double 2110 2111 Return XorInt64(ToVBBool(left), Convert.ToInt64(right)) 2112 2113 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 2114 Return XorBoolean(Convert.ToBoolean(left), CBool(Convert.ToString(right))) 2115 2116 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty 2117 Return XorSByte(Convert.ToSByte(left), Nothing, GetEnumResult(left, right)) 2118 2119 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 2120 Return XorSByte(Convert.ToSByte(left), ToVBBool(right)) 2121 2122 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 2123 Return XorSByte(Convert.ToSByte(left), Convert.ToSByte(right), GetEnumResult(left, right)) 2124 2125 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 2126 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 2127 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 2128 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 2129 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 2130 TypeCode.Int16 * s_TCMAX + TypeCode.Byte 2131 2132 Return XorInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 2133 2134 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 2135 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 2136 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 2137 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 2138 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 2139 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 2140 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 2141 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 2142 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 2143 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 2144 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 2145 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16 2146 2147 Return XorInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 2148 2149 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 2150 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 2151 TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 2152 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 2153 TypeCode.SByte * s_TCMAX + TypeCode.Single, 2154 TypeCode.SByte * s_TCMAX + TypeCode.Double, 2155 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 2156 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 2157 TypeCode.Byte * s_TCMAX + TypeCode.Single, 2158 TypeCode.Byte * s_TCMAX + TypeCode.Double, 2159 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 2160 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 2161 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 2162 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 2163 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 2164 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 2165 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 2166 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 2167 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 2168 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 2169 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 2170 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 2171 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 2172 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 2173 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 2174 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 2175 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 2176 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 2177 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 2178 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 2179 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 2180 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 2181 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 2182 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 2183 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 2184 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 2185 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 2186 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 2187 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 2188 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 2189 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 2190 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 2191 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 2192 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 2193 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 2194 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 2195 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 2196 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 2197 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 2198 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 2199 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 2200 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 2201 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 2202 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 2203 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 2204 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 2205 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 2206 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 2207 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal, 2208 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 2209 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 2210 TypeCode.Single * s_TCMAX + TypeCode.SByte, 2211 TypeCode.Single * s_TCMAX + TypeCode.Byte, 2212 TypeCode.Single * s_TCMAX + TypeCode.Int16, 2213 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 2214 TypeCode.Single * s_TCMAX + TypeCode.Int32, 2215 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 2216 TypeCode.Single * s_TCMAX + TypeCode.Int64, 2217 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 2218 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 2219 TypeCode.Single * s_TCMAX + TypeCode.Single, 2220 TypeCode.Single * s_TCMAX + TypeCode.Double, 2221 TypeCode.Double * s_TCMAX + TypeCode.SByte, 2222 TypeCode.Double * s_TCMAX + TypeCode.Byte, 2223 TypeCode.Double * s_TCMAX + TypeCode.Int16, 2224 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 2225 TypeCode.Double * s_TCMAX + TypeCode.Int32, 2226 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 2227 TypeCode.Double * s_TCMAX + TypeCode.Int64, 2228 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 2229 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 2230 TypeCode.Double * s_TCMAX + TypeCode.Single, 2231 TypeCode.Double * s_TCMAX + TypeCode.Double 2232 2233 Return XorInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 2234 2235 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 2236 TypeCode.Byte * s_TCMAX + TypeCode.String, 2237 TypeCode.Int16 * s_TCMAX + TypeCode.String, 2238 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 2239 TypeCode.Int32 * s_TCMAX + TypeCode.String, 2240 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 2241 TypeCode.Int64 * s_TCMAX + TypeCode.String, 2242 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 2243 TypeCode.Decimal * s_TCMAX + TypeCode.String, 2244 TypeCode.Single * s_TCMAX + TypeCode.String, 2245 TypeCode.Double * s_TCMAX + TypeCode.String 2246 2247 Return XorInt64(Convert.ToInt64(left), CLng(Convert.ToString(right))) 2248 2249 2250 Case TypeCode.Byte * s_TCMAX + TypeCode.Empty 2251 Return XorByte(Convert.ToByte(left), Nothing, GetEnumResult(left, right)) 2252 2253 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 2254 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 2255 Return XorInt16(Convert.ToInt16(left), ToVBBool(right)) 2256 2257 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 2258 Return XorByte(Convert.ToByte(left), Convert.ToByte(right), GetEnumResult(left, right)) 2259 2260 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 2261 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte 2262 Return XorUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 2263 2264 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 2265 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 2266 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 2267 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16 2268 2269 Return XorUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 2270 2271 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 2272 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 2273 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 2274 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 2275 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 2276 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32 2277 2278 Return XorUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 2279 2280 2281 Case TypeCode.Int16 * s_TCMAX + TypeCode.Empty 2282 Return XorInt16(Convert.ToInt16(left), Nothing, GetEnumResult(left, right)) 2283 2284 Case TypeCode.Int16 * s_TCMAX + TypeCode.Int16 2285 Return XorInt16(Convert.ToInt16(left), Convert.ToInt16(right), GetEnumResult(left, right)) 2286 2287 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 2288 Return XorUInt16(Convert.ToUInt16(left), Nothing, GetEnumResult(left, right)) 2289 2290 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 2291 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 2292 Return XorInt32(Convert.ToInt32(left), ToVBBool(right)) 2293 2294 Case TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 2295 Return XorUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right), GetEnumResult(left, right)) 2296 2297 Case TypeCode.Int32 * s_TCMAX + TypeCode.Empty 2298 Return XorInt32(Convert.ToInt32(left), Nothing, GetEnumResult(left, right)) 2299 2300 Case TypeCode.Int32 * s_TCMAX + TypeCode.Int32 2301 Return XorInt32(Convert.ToInt32(left), Convert.ToInt32(right), GetEnumResult(left, right)) 2302 2303 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 2304 Return XorUInt32(Convert.ToUInt32(left), Nothing, GetEnumResult(left, right)) 2305 2306 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 2307 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean, 2308 TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 2309 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean, 2310 TypeCode.Single * s_TCMAX + TypeCode.Boolean, 2311 TypeCode.Double * s_TCMAX + TypeCode.Boolean 2312 2313 Return XorInt64(Convert.ToInt64(left), ToVBBool(right)) 2314 2315 Case TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 2316 Return XorUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right), GetEnumResult(left, right)) 2317 2318 Case TypeCode.Int64 * s_TCMAX + TypeCode.Empty 2319 Return XorInt64(Convert.ToInt64(left), Nothing, GetEnumResult(left, right)) 2320 2321 Case TypeCode.Int64 * s_TCMAX + TypeCode.Int64 2322 Return XorInt64(Convert.ToInt64(left), Convert.ToInt64(right), GetEnumResult(left, right)) 2323 2324 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 2325 Return XorUInt64(Convert.ToUInt64(left), Nothing, GetEnumResult(left, right)) 2326 2327 Case TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 2328 Return XorUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right), GetEnumResult(left, right)) 2329 2330 2331 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty, 2332 TypeCode.Single * s_TCMAX + TypeCode.Empty, 2333 TypeCode.Double * s_TCMAX + TypeCode.Empty 2334 Return XorInt64(Convert.ToInt64(left), Nothing) 2335 2336 2337 Case TypeCode.String * s_TCMAX + TypeCode.Empty 2338 Return XorInt64(CLng(Convert.ToString(left)), Nothing) 2339 2340 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 2341 Return XorBoolean(CBool(Convert.ToString(left)), Convert.ToBoolean(right)) 2342 2343 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 2344 TypeCode.String * s_TCMAX + TypeCode.Byte, 2345 TypeCode.String * s_TCMAX + TypeCode.Int16, 2346 TypeCode.String * s_TCMAX + TypeCode.UInt16, 2347 TypeCode.String * s_TCMAX + TypeCode.Int32, 2348 TypeCode.String * s_TCMAX + TypeCode.UInt32, 2349 TypeCode.String * s_TCMAX + TypeCode.Int64, 2350 TypeCode.String * s_TCMAX + TypeCode.UInt64, 2351 TypeCode.String * s_TCMAX + TypeCode.Decimal, 2352 TypeCode.String * s_TCMAX + TypeCode.Single, 2353 TypeCode.String * s_TCMAX + TypeCode.Double 2354 2355 Return XorInt64(CLng(Convert.ToString(left)), Convert.ToInt64(right)) 2356 2357 Case TypeCode.String * s_TCMAX + TypeCode.String 2358 Return XorInt64(CLng(Convert.ToString(left)), CLng(Convert.ToString(right))) 2359 2360 End Select 2361 2362 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 2363 Return InvokeUserDefinedOperator(UserDefinedOperator.Xor, left, right) 2364 End If 2365 2366 Throw GetNoValidOperatorException(UserDefinedOperator.Xor, left, right) 2367 End Function 2368 2369 Private Shared Function XorBoolean(ByVal left As Boolean, ByVal right As Boolean) As Object 2370 Return left Xor right 2371 End Function 2372 2373 Private Shared Function XorSByte(ByVal left As SByte, ByVal right As SByte, Optional ByVal enumType As Type = Nothing) As Object 2374 Dim result As SByte = left Xor right 2375 2376 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2377 Return result 2378 End Function 2379 2380 Private Shared Function XorByte(ByVal left As Byte, ByVal right As Byte, Optional ByVal enumType As Type = Nothing) As Object 2381 Dim result As Byte = left Xor right 2382 2383 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2384 Return result 2385 End Function 2386 2387 Private Shared Function XorInt16(ByVal left As Int16, ByVal right As Int16, Optional ByVal enumType As Type = Nothing) As Object 2388 Dim result As Int16 = left Xor right 2389 2390 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2391 Return result 2392 End Function 2393 2394 Private Shared Function XorUInt16(ByVal left As UInt16, ByVal right As UInt16, Optional ByVal enumType As Type = Nothing) As Object 2395 Dim result As UInt16 = left Xor right 2396 2397 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2398 Return result 2399 End Function 2400 2401 Private Shared Function XorInt32(ByVal left As Int32, ByVal right As Int32, Optional ByVal enumType As Type = Nothing) As Object 2402 Dim result As Int32 = left Xor right 2403 2404 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2405 Return result 2406 End Function 2407 2408 Private Shared Function XorUInt32(ByVal left As UInt32, ByVal right As UInt32, Optional ByVal enumType As Type = Nothing) As Object 2409 Dim result As UInt32 = left Xor right 2410 2411 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2412 Return result 2413 End Function 2414 2415 Private Shared Function XorInt64(ByVal left As Int64, ByVal right As Int64, Optional ByVal enumType As Type = Nothing) As Object 2416 Dim result As Int64 = left Xor right 2417 2418 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2419 Return result 2420 End Function 2421 2422 Private Shared Function XorUInt64(ByVal left As UInt64, ByVal right As UInt64, Optional ByVal enumType As Type = Nothing) As Object 2423 Dim result As UInt64 = left Xor right 2424 2425 If enumType IsNot Nothing Then Return System.Enum.ToObject(enumType, result) 2426 Return result 2427 End Function 2428 2429#End Region 2430 2431#Region " Operator Plus + " 2432 2433 Public Shared Function AddObject(ByVal left As Object, ByVal right As Object) As Object 2434 2435 Dim tc1 As TypeCode = GetTypeCode(left) 2436 Dim tc2 As TypeCode = GetTypeCode(right) 2437 2438 2439 'Special cases for Char() 2440 If tc1 = TypeCode.Object Then 2441 Dim leftCharArray As Char() = TryCast(left, Char()) 2442 2443 If leftCharArray IsNot Nothing Then 2444 If tc2 = TypeCode.String OrElse tc2 = TypeCode.Empty OrElse ((tc2 = TypeCode.Object) AndAlso (TypeOf right Is Char())) Then 2445 'Treat Char() as String for these cases 2446 left = CStr(leftCharArray) 2447 tc1 = TypeCode.String 2448 End If 2449 End If 2450 End If 2451 2452 If (tc2 = TypeCode.Object) Then 2453 Dim rightCharArray As Char() = TryCast(right, Char()) 2454 2455 If rightCharArray IsNot Nothing Then 2456 If tc1 = TypeCode.String OrElse tc1 = TypeCode.Empty Then 2457 right = CStr(rightCharArray) 2458 tc2 = TypeCode.String 2459 End If 2460 End If 2461 End If 2462 2463 2464 Select Case tc1 * s_TCMAX + tc2 2465 2466 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 2467 Return Boxed_ZeroInteger 2468 2469 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 2470 Return AddInt16(Nothing, ToVBBool(right)) 2471 2472 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte 2473 Return Convert.ToSByte(right) 2474 2475 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte 2476 Return Convert.ToByte(right) 2477 2478 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16 2479 Return Convert.ToInt16(right) 2480 2481 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16 2482 Return Convert.ToUInt16(right) 2483 2484 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32 2485 Return Convert.ToInt32(right) 2486 2487 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32 2488 Return Convert.ToUInt32(right) 2489 2490 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64 2491 Return Convert.ToInt64(right) 2492 2493 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64 2494 Return Convert.ToUInt64(right) 2495 2496 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal, 2497 TypeCode.Empty * s_TCMAX + TypeCode.Single, 2498 TypeCode.Empty * s_TCMAX + TypeCode.Double, 2499 TypeCode.Empty * s_TCMAX + TypeCode.String 2500 2501 Return right 2502 2503 Case TypeCode.Empty * s_TCMAX + TypeCode.DateTime 2504 Return AddString(CStr(CDate(Nothing)), CStr(Convert.ToDateTime(right))) 2505 2506 Case TypeCode.Empty * s_TCMAX + TypeCode.Char 2507 Return AddString(ControlChars.NullChar, Convert.ToString(right)) 2508 2509 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 2510 Return AddInt16(ToVBBool(left), Nothing) 2511 2512 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 2513 Return AddInt16(ToVBBool(left), ToVBBool(right)) 2514 2515 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 2516 Return AddSByte(ToVBBool(left), Convert.ToSByte(right)) 2517 2518 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 2519 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 2520 Return AddInt16(ToVBBool(left), Convert.ToInt16(right)) 2521 2522 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 2523 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 2524 Return AddInt32(ToVBBool(left), Convert.ToInt32(right)) 2525 2526 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 2527 TypeCode.Boolean * s_TCMAX + TypeCode.Int64 2528 Return AddInt64(ToVBBool(left), Convert.ToInt64(right)) 2529 2530 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 2531 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal 2532 Return AddDecimal(ToVBBool(left), Convert.ToDecimal(right)) 2533 2534 Case TypeCode.Boolean * s_TCMAX + TypeCode.Single 2535 Return AddSingle(ToVBBool(left), Convert.ToSingle(right)) 2536 2537 Case TypeCode.Boolean * s_TCMAX + TypeCode.Double 2538 Return AddDouble(ToVBBool(left), Convert.ToDouble(right)) 2539 2540 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 2541 Return AddDouble(ToVBBool(left), CDbl(Convert.ToString(right))) 2542 2543 2544 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty 2545 Return Convert.ToSByte(left) 2546 2547 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 2548 Return AddSByte(Convert.ToSByte(left), ToVBBool(right)) 2549 2550 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 2551 Return AddSByte(Convert.ToSByte(left), Convert.ToSByte(right)) 2552 2553 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 2554 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 2555 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 2556 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 2557 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 2558 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 2559 TypeCode.Int16 * s_TCMAX + TypeCode.Int16 2560 2561 Return AddInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 2562 2563 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 2564 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 2565 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 2566 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 2567 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 2568 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 2569 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 2570 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 2571 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 2572 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 2573 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 2574 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 2575 TypeCode.Int32 * s_TCMAX + TypeCode.Int32 2576 2577 Return AddInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 2578 2579 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 2580 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 2581 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 2582 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 2583 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 2584 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 2585 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 2586 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 2587 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 2588 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 2589 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 2590 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 2591 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 2592 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 2593 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 2594 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 2595 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 2596 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 2597 TypeCode.Int64 * s_TCMAX + TypeCode.Int64 2598 2599 Return AddInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 2600 2601 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 2602 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 2603 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 2604 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 2605 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 2606 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 2607 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 2608 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 2609 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 2610 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 2611 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 2612 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 2613 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 2614 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 2615 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 2616 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 2617 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 2618 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 2619 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 2620 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 2621 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 2622 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 2623 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 2624 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 2625 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal 2626 2627 Return AddDecimal(left, right) 2628 2629 Case TypeCode.SByte * s_TCMAX + TypeCode.Single, 2630 TypeCode.Byte * s_TCMAX + TypeCode.Single, 2631 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 2632 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 2633 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 2634 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 2635 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 2636 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 2637 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 2638 TypeCode.Single * s_TCMAX + TypeCode.SByte, 2639 TypeCode.Single * s_TCMAX + TypeCode.Byte, 2640 TypeCode.Single * s_TCMAX + TypeCode.Int16, 2641 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 2642 TypeCode.Single * s_TCMAX + TypeCode.Int32, 2643 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 2644 TypeCode.Single * s_TCMAX + TypeCode.Int64, 2645 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 2646 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 2647 TypeCode.Single * s_TCMAX + TypeCode.Single 2648 2649 Return AddSingle(Convert.ToSingle(left), Convert.ToSingle(right)) 2650 2651 Case TypeCode.SByte * s_TCMAX + TypeCode.Double, 2652 TypeCode.Byte * s_TCMAX + TypeCode.Double, 2653 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 2654 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 2655 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 2656 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 2657 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 2658 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 2659 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 2660 TypeCode.Single * s_TCMAX + TypeCode.Double, 2661 TypeCode.Double * s_TCMAX + TypeCode.SByte, 2662 TypeCode.Double * s_TCMAX + TypeCode.Byte, 2663 TypeCode.Double * s_TCMAX + TypeCode.Int16, 2664 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 2665 TypeCode.Double * s_TCMAX + TypeCode.Int32, 2666 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 2667 TypeCode.Double * s_TCMAX + TypeCode.Int64, 2668 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 2669 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 2670 TypeCode.Double * s_TCMAX + TypeCode.Single, 2671 TypeCode.Double * s_TCMAX + TypeCode.Double 2672 2673 Return AddDouble(Convert.ToDouble(left), Convert.ToDouble(right)) 2674 2675 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 2676 TypeCode.Byte * s_TCMAX + TypeCode.String, 2677 TypeCode.Int16 * s_TCMAX + TypeCode.String, 2678 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 2679 TypeCode.Int32 * s_TCMAX + TypeCode.String, 2680 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 2681 TypeCode.Int64 * s_TCMAX + TypeCode.String, 2682 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 2683 TypeCode.Decimal * s_TCMAX + TypeCode.String, 2684 TypeCode.Single * s_TCMAX + TypeCode.String, 2685 TypeCode.Double * s_TCMAX + TypeCode.String 2686 2687 Return AddDouble(Convert.ToDouble(left), CDbl(Convert.ToString(right))) 2688 2689 Case TypeCode.Byte * s_TCMAX + TypeCode.Empty 2690 Return Convert.ToByte(left) 2691 2692 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 2693 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 2694 Return AddInt16(Convert.ToInt16(left), ToVBBool(right)) 2695 2696 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 2697 Return AddByte(Convert.ToByte(left), Convert.ToByte(right)) 2698 2699 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 2700 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 2701 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 2702 Return AddUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 2703 2704 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 2705 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 2706 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 2707 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 2708 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 2709 Return AddUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 2710 2711 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 2712 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 2713 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 2714 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 2715 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 2716 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 2717 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 2718 2719 Return AddUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 2720 2721 2722 Case TypeCode.Int16 * s_TCMAX + TypeCode.Empty 2723 Return Convert.ToInt16(left) 2724 2725 2726 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 2727 Return Convert.ToUInt16(left) 2728 2729 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 2730 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 2731 Return AddInt32(Convert.ToInt32(left), ToVBBool(right)) 2732 2733 2734 Case TypeCode.Int32 * s_TCMAX + TypeCode.Empty 2735 Return Convert.ToInt32(left) 2736 2737 2738 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 2739 Return Convert.ToUInt32(left) 2740 2741 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 2742 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean 2743 Return AddInt64(Convert.ToInt64(left), ToVBBool(right)) 2744 2745 2746 Case TypeCode.Int64 * s_TCMAX + TypeCode.Empty 2747 Return Convert.ToInt64(left) 2748 2749 2750 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 2751 Return Convert.ToUInt64(left) 2752 2753 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 2754 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean 2755 Return AddDecimal(left, ToVBBool(right)) 2756 2757 2758 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty, 2759 TypeCode.Single * s_TCMAX + TypeCode.Empty, 2760 TypeCode.Double * s_TCMAX + TypeCode.Empty, 2761 TypeCode.String * s_TCMAX + TypeCode.Empty 2762 2763 Return left 2764 2765 2766 Case TypeCode.Single * s_TCMAX + TypeCode.Boolean 2767 Return AddSingle(Convert.ToSingle(left), ToVBBool(right)) 2768 2769 2770 Case TypeCode.Double * s_TCMAX + TypeCode.Boolean 2771 Return AddDouble(Convert.ToDouble(left), ToVBBool(right)) 2772 2773 2774 Case TypeCode.DateTime * s_TCMAX + TypeCode.Empty 2775 Return AddString(CStr(CDate(Nothing)), CStr(CDate(left))) 2776 2777 Case TypeCode.DateTime * s_TCMAX + TypeCode.DateTime 2778 Return AddString(CStr(Convert.ToDateTime(left)), CStr(Convert.ToDateTime(right))) 2779 2780 Case TypeCode.DateTime * s_TCMAX + TypeCode.String 2781 Return AddString(CStr(Convert.ToDateTime(left)), Convert.ToString(right)) 2782 2783 2784 Case TypeCode.Char * s_TCMAX + TypeCode.Empty 2785 Return AddString(Convert.ToString(left), ControlChars.NullChar) 2786 2787 Case TypeCode.Char * s_TCMAX + TypeCode.Char, 2788 TypeCode.Char * s_TCMAX + TypeCode.String, 2789 TypeCode.String * s_TCMAX + TypeCode.Char 2790 Return AddString(Convert.ToString(left), Convert.ToString(right)) 2791 2792 2793 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 2794 Return AddDouble(CDbl(Convert.ToString(left)), ToVBBool(right)) 2795 2796 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 2797 TypeCode.String * s_TCMAX + TypeCode.Byte, 2798 TypeCode.String * s_TCMAX + TypeCode.Int16, 2799 TypeCode.String * s_TCMAX + TypeCode.UInt16, 2800 TypeCode.String * s_TCMAX + TypeCode.Int32, 2801 TypeCode.String * s_TCMAX + TypeCode.UInt32, 2802 TypeCode.String * s_TCMAX + TypeCode.Int64, 2803 TypeCode.String * s_TCMAX + TypeCode.UInt64, 2804 TypeCode.String * s_TCMAX + TypeCode.Decimal, 2805 TypeCode.String * s_TCMAX + TypeCode.Single, 2806 TypeCode.String * s_TCMAX + TypeCode.Double 2807 2808 Return AddDouble(CDbl(Convert.ToString(left)), Convert.ToDouble(right)) 2809 2810 Case TypeCode.String * s_TCMAX + TypeCode.DateTime 2811 Return AddString(Convert.ToString(left), CStr(Convert.ToDateTime(right))) 2812 2813 Case TypeCode.String * s_TCMAX + TypeCode.String 2814 Return AddString(Convert.ToString(left), Convert.ToString(right)) 2815 2816 Case Else 2817 2818 End Select 2819 2820 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 2821 Return InvokeUserDefinedOperator(UserDefinedOperator.Plus, left, right) 2822 End If 2823 2824 Throw GetNoValidOperatorException(UserDefinedOperator.Plus, left, right) 2825 End Function 2826 2827 Private Shared Function AddByte(ByVal left As Byte, ByVal right As Byte) As Object 2828 'Range of possible values: [0, 510] 2829 Dim result As Int16 = CShort(left) + CShort(right) 2830 2831 If result > Byte.MaxValue Then 2832 Return result 2833 Else 2834 Return CByte(result) 2835 End If 2836 End Function 2837 2838 Private Shared Function AddSByte(ByVal left As SByte, ByVal right As SByte) As Object 2839 'Range of possible values: [-256, 254] 2840 Dim result As Int16 = CShort(left) + CShort(right) 2841 2842 If result > SByte.MaxValue OrElse result < SByte.MinValue Then 2843 Return result 2844 Else 2845 Return CSByte(result) 2846 End If 2847 End Function 2848 2849 Private Shared Function AddInt16(ByVal left As Int16, ByVal right As Int16) As Object 2850 'Range of possible values: [-65536, 65534] 2851 Dim result As Int32 = CInt(left) + CInt(right) 2852 2853 If result > Int16.MaxValue OrElse result < Int16.MinValue Then 2854 Return result 2855 Else 2856 Return CShort(result) 2857 End If 2858 End Function 2859 2860 Private Shared Function AddUInt16(ByVal left As UInt16, ByVal right As UInt16) As Object 2861 'Range of possible values: [0, 131070] 2862 Dim result As Int32 = CInt(left) + CInt(right) 2863 2864 If result > UInt16.MaxValue Then 2865 Return result 2866 Else 2867 Return CUShort(result) 2868 End If 2869 End Function 2870 2871 Private Shared Function AddInt32(ByVal left As Int32, ByVal right As Int32) As Object 2872 'Range of possible values: [-4294967296, 4294967294] 2873 Dim result As Int64 = CLng(left) + CLng(right) 2874 2875 If result > Int32.MaxValue OrElse result < Int32.MinValue Then 2876 Return result 2877 Else 2878 Return CInt(result) 2879 End If 2880 End Function 2881 2882 Private Shared Function AddUInt32(ByVal left As UInt32, ByVal right As UInt32) As Object 2883 'Range of possible values: [0, 8589934590] 2884 Dim result As Int64 = CLng(left) + CLng(right) 2885 2886 If result > UInt32.MaxValue Then 2887 Return result 2888 Else 2889 Return CUInt(result) 2890 End If 2891 End Function 2892 2893 Private Shared Function AddInt64(ByVal left As Int64, ByVal right As Int64) As Object 2894 'Range of possible values: [-18446744073709551616, 18446744073709551614] 2895 Try 2896 Return left + right 2897 Catch e As OverflowException 2898 Return CDec(left) + CDec(right) 2899 End Try 2900 2901 End Function 2902 2903 Private Shared Function AddUInt64(ByVal left As UInt64, ByVal right As UInt64) As Object 2904 'Range of possible values: [0, 36893488147419103230] 2905 Try 2906 Return left + right 2907 Catch e As OverflowException 2908 Return CDec(left) + CDec(right) 2909 End Try 2910 2911 End Function 2912 2913 Private Shared Function AddDecimal(ByVal left As Object, ByVal right As Object) As Object 2914 Dim leftValue As Decimal = Convert.ToDecimal(left) 2915 Dim rightValue As Decimal = Convert.ToDecimal(right) 2916 2917 Try 2918 Return leftValue + rightValue 2919 Catch ex As OverflowException 2920 Return CDbl(leftValue) + CDbl(rightValue) 2921 End Try 2922 End Function 2923 2924 Private Shared Function AddSingle(ByVal left As Single, ByVal right As Single) As Object 2925 Dim result As Double = CDbl(left) + CDbl(right) 2926 2927 If ((result <= Single.MaxValue AndAlso result >= Single.MinValue)) Then 2928 Return CSng(result) 2929 ElseIf Double.IsInfinity(result) AndAlso (Single.IsInfinity(left) OrElse Single.IsInfinity(right)) Then 2930 Return CSng(result) 2931 Else 2932 Return result 2933 End If 2934 End Function 2935 2936 Private Shared Function AddDouble(ByVal left As Double, ByVal right As Double) As Object 2937 Return left + right 2938 End Function 2939 2940 Private Shared Function AddString(ByVal left As String, ByVal right As String) As Object 2941 Return left & right 2942 End Function 2943 2944#End Region 2945 2946#Region " Operator Minus - " 2947 2948 Public Shared Function SubtractObject(ByVal left As Object, ByVal right As Object) As Object 2949 Dim tc1 As TypeCode = GetTypeCode(left) 2950 Dim tc2 As TypeCode = GetTypeCode(right) 2951 2952 Select Case tc1 * s_TCMAX + tc2 2953 2954 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 2955 Return Boxed_ZeroInteger 2956 2957 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 2958 Return SubtractInt16(Nothing, ToVBBool(right)) 2959 2960 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte 2961 Return SubtractSByte(Nothing, Convert.ToSByte(right)) 2962 2963 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte 2964 Return SubtractByte(Nothing, Convert.ToByte(right)) 2965 2966 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16 2967 Return SubtractInt16(Nothing, Convert.ToInt16(right)) 2968 2969 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16 2970 Return SubtractUInt16(Nothing, Convert.ToUInt16(right)) 2971 2972 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32 2973 Return SubtractInt32(Nothing, Convert.ToInt32(right)) 2974 2975 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32 2976 Return SubtractUInt32(Nothing, Convert.ToUInt32(right)) 2977 2978 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64 2979 Return SubtractInt64(Nothing, Convert.ToInt64(right)) 2980 2981 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64 2982 Return SubtractUInt64(Nothing, Convert.ToUInt64(right)) 2983 2984 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal 2985 Return SubtractDecimal(0D, right) 2986 2987 Case TypeCode.Empty * s_TCMAX + TypeCode.Single 2988 Return SubtractSingle(Nothing, Convert.ToSingle(right)) 2989 2990 Case TypeCode.Empty * s_TCMAX + TypeCode.Double 2991 Return SubtractDouble(Nothing, Convert.ToDouble(right)) 2992 2993 Case TypeCode.Empty * s_TCMAX + TypeCode.String 2994 Return SubtractDouble(Nothing, CDbl(Convert.ToString(right))) 2995 2996 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 2997 Return SubtractInt16(ToVBBool(left), Nothing) 2998 2999 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 3000 Return SubtractInt16(ToVBBool(left), ToVBBool(right)) 3001 3002 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 3003 Return SubtractSByte(ToVBBool(left), Convert.ToSByte(right)) 3004 3005 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 3006 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 3007 Return SubtractInt16(ToVBBool(left), Convert.ToInt16(right)) 3008 3009 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 3010 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 3011 Return SubtractInt32(ToVBBool(left), Convert.ToInt32(right)) 3012 3013 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 3014 TypeCode.Boolean * s_TCMAX + TypeCode.Int64 3015 Return SubtractInt64(ToVBBool(left), Convert.ToInt64(right)) 3016 3017 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 3018 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal 3019 Return SubtractDecimal(ToVBBool(left), Convert.ToDecimal(right)) 3020 3021 Case TypeCode.Boolean * s_TCMAX + TypeCode.Single 3022 Return SubtractSingle(ToVBBool(left), Convert.ToSingle(right)) 3023 3024 Case TypeCode.Boolean * s_TCMAX + TypeCode.Double 3025 Return SubtractDouble(ToVBBool(left), Convert.ToDouble(right)) 3026 3027 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 3028 Return SubtractDouble(ToVBBool(left), CDbl(Convert.ToString(right))) 3029 3030 3031 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty 3032 Return Convert.ToSByte(left) 3033 3034 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 3035 Return SubtractSByte(Convert.ToSByte(left), ToVBBool(right)) 3036 3037 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 3038 Return SubtractSByte(Convert.ToSByte(left), Convert.ToSByte(right)) 3039 3040 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 3041 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 3042 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 3043 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 3044 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 3045 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 3046 TypeCode.Int16 * s_TCMAX + TypeCode.Int16 3047 3048 Return SubtractInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 3049 3050 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 3051 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 3052 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 3053 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 3054 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 3055 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 3056 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 3057 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 3058 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 3059 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 3060 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 3061 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 3062 TypeCode.Int32 * s_TCMAX + TypeCode.Int32 3063 3064 Return SubtractInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 3065 3066 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 3067 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 3068 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 3069 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 3070 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 3071 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 3072 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 3073 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 3074 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 3075 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 3076 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 3077 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 3078 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 3079 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 3080 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 3081 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 3082 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 3083 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 3084 TypeCode.Int64 * s_TCMAX + TypeCode.Int64 3085 3086 Return SubtractInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 3087 3088 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 3089 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 3090 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 3091 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 3092 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 3093 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 3094 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 3095 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 3096 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 3097 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 3098 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 3099 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 3100 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 3101 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 3102 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 3103 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 3104 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 3105 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 3106 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 3107 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 3108 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 3109 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 3110 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 3111 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 3112 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal 3113 3114 Return SubtractDecimal(left, right) 3115 3116 Case TypeCode.SByte * s_TCMAX + TypeCode.Single, 3117 TypeCode.Byte * s_TCMAX + TypeCode.Single, 3118 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 3119 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 3120 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 3121 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 3122 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 3123 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 3124 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 3125 TypeCode.Single * s_TCMAX + TypeCode.SByte, 3126 TypeCode.Single * s_TCMAX + TypeCode.Byte, 3127 TypeCode.Single * s_TCMAX + TypeCode.Int16, 3128 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 3129 TypeCode.Single * s_TCMAX + TypeCode.Int32, 3130 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 3131 TypeCode.Single * s_TCMAX + TypeCode.Int64, 3132 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 3133 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 3134 TypeCode.Single * s_TCMAX + TypeCode.Single 3135 3136 Return SubtractSingle(Convert.ToSingle(left), Convert.ToSingle(right)) 3137 3138 Case TypeCode.SByte * s_TCMAX + TypeCode.Double, 3139 TypeCode.Byte * s_TCMAX + TypeCode.Double, 3140 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 3141 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 3142 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 3143 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 3144 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 3145 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 3146 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 3147 TypeCode.Single * s_TCMAX + TypeCode.Double, 3148 TypeCode.Double * s_TCMAX + TypeCode.SByte, 3149 TypeCode.Double * s_TCMAX + TypeCode.Byte, 3150 TypeCode.Double * s_TCMAX + TypeCode.Int16, 3151 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 3152 TypeCode.Double * s_TCMAX + TypeCode.Int32, 3153 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 3154 TypeCode.Double * s_TCMAX + TypeCode.Int64, 3155 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 3156 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 3157 TypeCode.Double * s_TCMAX + TypeCode.Single, 3158 TypeCode.Double * s_TCMAX + TypeCode.Double 3159 3160 Return SubtractDouble(Convert.ToDouble(left), Convert.ToDouble(right)) 3161 3162 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 3163 TypeCode.Byte * s_TCMAX + TypeCode.String, 3164 TypeCode.Int16 * s_TCMAX + TypeCode.String, 3165 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 3166 TypeCode.Int32 * s_TCMAX + TypeCode.String, 3167 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 3168 TypeCode.Int64 * s_TCMAX + TypeCode.String, 3169 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 3170 TypeCode.Decimal * s_TCMAX + TypeCode.String, 3171 TypeCode.Single * s_TCMAX + TypeCode.String, 3172 TypeCode.Double * s_TCMAX + TypeCode.String 3173 3174 Return SubtractDouble(Convert.ToDouble(left), CDbl(Convert.ToString(right))) 3175 3176 3177 Case TypeCode.Byte * s_TCMAX + TypeCode.Empty 3178 Return Convert.ToByte(left) 3179 3180 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 3181 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 3182 Return SubtractInt16(Convert.ToInt16(left), ToVBBool(right)) 3183 3184 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 3185 Return SubtractByte(Convert.ToByte(left), Convert.ToByte(right)) 3186 3187 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 3188 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 3189 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 3190 Return SubtractUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 3191 3192 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 3193 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 3194 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 3195 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 3196 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 3197 Return SubtractUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 3198 3199 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 3200 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 3201 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 3202 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 3203 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 3204 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 3205 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 3206 3207 Return SubtractUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 3208 3209 3210 Case TypeCode.Int16 * s_TCMAX + TypeCode.Empty 3211 Return Convert.ToInt16(left) 3212 3213 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 3214 Return Convert.ToUInt16(left) 3215 3216 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 3217 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 3218 Return SubtractInt32(Convert.ToInt32(left), ToVBBool(right)) 3219 3220 3221 Case TypeCode.Int32 * s_TCMAX + TypeCode.Empty 3222 Return Convert.ToInt32(left) 3223 3224 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 3225 Return Convert.ToUInt32(left) 3226 3227 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 3228 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean 3229 Return SubtractInt64(Convert.ToInt64(left), ToVBBool(right)) 3230 3231 3232 Case TypeCode.Int64 * s_TCMAX + TypeCode.Empty 3233 Return Convert.ToInt64(left) 3234 3235 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 3236 Return Convert.ToUInt64(left) 3237 3238 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 3239 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean 3240 Return SubtractDecimal(left, ToVBBool(right)) 3241 3242 3243 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty, 3244 TypeCode.Single * s_TCMAX + TypeCode.Empty, 3245 TypeCode.Double * s_TCMAX + TypeCode.Empty 3246 Return left 3247 3248 3249 Case TypeCode.Single * s_TCMAX + TypeCode.Boolean 3250 Return SubtractSingle(Convert.ToSingle(left), ToVBBool(right)) 3251 3252 Case TypeCode.Double * s_TCMAX + TypeCode.Boolean 3253 Return SubtractDouble(Convert.ToDouble(left), ToVBBool(right)) 3254 3255 Case TypeCode.String * s_TCMAX + TypeCode.Empty 3256 Return CDbl(Convert.ToString(left)) 3257 3258 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 3259 Return SubtractDouble(CDbl(Convert.ToString(left)), ToVBBool(right)) 3260 3261 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 3262 TypeCode.String * s_TCMAX + TypeCode.Byte, 3263 TypeCode.String * s_TCMAX + TypeCode.Int16, 3264 TypeCode.String * s_TCMAX + TypeCode.UInt16, 3265 TypeCode.String * s_TCMAX + TypeCode.Int32, 3266 TypeCode.String * s_TCMAX + TypeCode.UInt32, 3267 TypeCode.String * s_TCMAX + TypeCode.Int64, 3268 TypeCode.String * s_TCMAX + TypeCode.UInt64, 3269 TypeCode.String * s_TCMAX + TypeCode.Decimal, 3270 TypeCode.String * s_TCMAX + TypeCode.Single, 3271 TypeCode.String * s_TCMAX + TypeCode.Double 3272 3273 Return SubtractDouble(CDbl(Convert.ToString(left)), Convert.ToDouble(right)) 3274 3275 Case TypeCode.String * s_TCMAX + TypeCode.String 3276 Return SubtractDouble(CDbl(Convert.ToString(left)), CDbl(Convert.ToString(right))) 3277 3278 Case Else 3279 3280 End Select 3281 3282 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object OrElse 3283 (tc1 = TypeCode.DateTime AndAlso tc2 = TypeCode.DateTime) OrElse 3284 (tc1 = TypeCode.DateTime AndAlso tc2 = TypeCode.Empty) OrElse 3285 (tc1 = TypeCode.Empty AndAlso tc2 = TypeCode.DateTime) Then 3286 3287 Return InvokeUserDefinedOperator(UserDefinedOperator.Minus, left, right) 3288 End If 3289 3290 Throw GetNoValidOperatorException(UserDefinedOperator.Minus, left, right) 3291 3292 End Function 3293 3294 Private Shared Function SubtractByte(ByVal left As Byte, ByVal right As Byte) As Object 3295 'Range of possible values: [-255, 255] 3296 Dim result As Int16 = CShort(left) - CShort(right) 3297 3298 If result < Byte.MinValue Then 3299 Return result 3300 Else 3301 Return CByte(result) 3302 End If 3303 End Function 3304 3305 Private Shared Function SubtractSByte(ByVal left As SByte, ByVal right As SByte) As Object 3306 'Range of possible values: [-255, 255] 3307 Dim result As Int16 = CShort(left) - CShort(right) 3308 3309 If result < SByte.MinValue OrElse result > SByte.MaxValue Then 3310 Return result 3311 Else 3312 Return CSByte(result) 3313 End If 3314 End Function 3315 3316 Private Shared Function SubtractInt16(ByVal left As Int16, ByVal right As Int16) As Object 3317 'Range of possible values: [-65535, 65535] 3318 Dim result As Int32 = CInt(left) - CInt(right) 3319 3320 If result < Int16.MinValue OrElse result > Int16.MaxValue Then 3321 Return result 3322 Else 3323 Return CShort(result) 3324 End If 3325 End Function 3326 3327 Private Shared Function SubtractUInt16(ByVal left As UInt16, ByVal right As UInt16) As Object 3328 'Range of possible values: [-65535, 65535] 3329 Dim result As Int32 = CInt(left) - CInt(right) 3330 3331 If result < UInt16.MinValue Then 3332 Return result 3333 Else 3334 Return CUShort(result) 3335 End If 3336 End Function 3337 3338 Private Shared Function SubtractInt32(ByVal left As Int32, ByVal right As Int32) As Object 3339 'Range of possible values: [-4294967295, 4294967295] 3340 Dim result As Int64 = CLng(left) - CLng(right) 3341 3342 If result < Int32.MinValue OrElse result > Int32.MaxValue Then 3343 Return result 3344 Else 3345 Return CInt(result) 3346 End If 3347 End Function 3348 3349 Private Shared Function SubtractUInt32(ByVal left As UInt32, ByVal right As UInt32) As Object 3350 'Range of possible values: [-4294967295, 4294967295] 3351 Dim result As Int64 = CLng(left) - CLng(right) 3352 3353 If result < UInt32.MinValue Then 3354 Return result 3355 Else 3356 Return CUInt(result) 3357 End If 3358 End Function 3359 3360 Private Shared Function SubtractInt64(ByVal left As Int64, ByVal right As Int64) As Object 3361 'Range of possible values: [-18446744073709551615, 18446744073709551615] 3362 Try 3363 Return left - right 3364 Catch ex As OverflowException 3365 Return CDec(left) - CDec(right) 3366 End Try 3367 3368 End Function 3369 3370 Private Shared Function SubtractUInt64(ByVal left As UInt64, ByVal right As UInt64) As Object 3371 'Range of possible values: [-18446744073709551615, 18446744073709551615] 3372 Try 3373 Return left - right 3374 Catch ex As OverflowException 3375 Return CDec(left) - CDec(right) 3376 End Try 3377 3378 End Function 3379 3380 Private Shared Function SubtractDecimal(ByVal left As Object, ByVal right As Object) As Object 3381 Dim leftValue As Decimal = Convert.ToDecimal(left) 3382 Dim rightValue As Decimal = Convert.ToDecimal(right) 3383 3384 Try 3385 Return leftValue - rightValue 3386 Catch ex As OverflowException 3387 Return CDbl(leftValue) - CDbl(rightValue) 3388 End Try 3389 End Function 3390 3391 Private Shared Function SubtractSingle(ByVal left As Single, ByVal right As Single) As Object 3392 Dim result As Double = CDbl(left) - CDbl(right) 3393 3394 If ((result <= Single.MaxValue AndAlso result >= Single.MinValue)) Then 3395 Return CSng(result) 3396 ElseIf Double.IsInfinity(result) AndAlso (Single.IsInfinity(left) OrElse Single.IsInfinity(right)) Then 3397 Return CSng(result) 3398 Else 3399 Return result 3400 End If 3401 End Function 3402 3403 Private Shared Function SubtractDouble(ByVal left As Double, ByVal right As Double) As Object 3404 Return left - right 3405 End Function 3406 3407#End Region 3408 3409#Region " Operator Multiply * " 3410 3411 Public Shared Function MultiplyObject(ByVal left As Object, ByVal right As Object) As Object 3412 3413 Dim tc1 As TypeCode = GetTypeCode(left) 3414 Dim tc2 As TypeCode = GetTypeCode(right) 3415 3416 Select Case tc1 * s_TCMAX + tc2 3417 3418 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty, 3419 TypeCode.Empty * s_TCMAX + TypeCode.Int32, 3420 TypeCode.Int32 * s_TCMAX + TypeCode.Empty 3421 Return Boxed_ZeroInteger 3422 3423 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean, 3424 TypeCode.Boolean * s_TCMAX + TypeCode.Empty, 3425 TypeCode.Empty * s_TCMAX + TypeCode.Int16, 3426 TypeCode.Int16 * s_TCMAX + TypeCode.Empty 3427 Return Boxed_ZeroShort 3428 3429 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte, 3430 TypeCode.SByte * s_TCMAX + TypeCode.Empty 3431 Return Boxed_ZeroSByte 3432 3433 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte, 3434 TypeCode.Byte * s_TCMAX + TypeCode.Empty 3435 Return Boxed_ZeroByte 3436 3437 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16, 3438 TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 3439 Return Boxed_ZeroUShort 3440 3441 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32, 3442 TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 3443 Return Boxed_ZeroUInteger 3444 3445 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64, 3446 TypeCode.Int64 * s_TCMAX + TypeCode.Empty 3447 Return Boxed_ZeroLong 3448 3449 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64, 3450 TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 3451 Return Boxed_ZeroULong 3452 3453 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal, 3454 TypeCode.Decimal * s_TCMAX + TypeCode.Empty 3455 Return Boxed_ZeroDecimal 3456 3457 Case TypeCode.Empty * s_TCMAX + TypeCode.Single, 3458 TypeCode.Single * s_TCMAX + TypeCode.Empty 3459 Return Boxed_ZeroSinge 3460 3461 Case TypeCode.Empty * s_TCMAX + TypeCode.Double, 3462 TypeCode.Double * s_TCMAX + TypeCode.Empty 3463 Return Boxed_ZeroDouble 3464 3465 Case TypeCode.Empty * s_TCMAX + TypeCode.String 3466 Return MultiplyDouble(Nothing, CDbl(Convert.ToString(right))) 3467 3468 3469 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 3470 Return MultiplyInt16(ToVBBool(left), ToVBBool(right)) 3471 3472 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 3473 Return MultiplySByte(ToVBBool(left), Convert.ToSByte(right)) 3474 3475 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 3476 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 3477 Return MultiplyInt16(ToVBBool(left), Convert.ToInt16(right)) 3478 3479 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 3480 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 3481 Return MultiplyInt32(ToVBBool(left), Convert.ToInt32(right)) 3482 3483 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 3484 TypeCode.Boolean * s_TCMAX + TypeCode.Int64 3485 Return MultiplyInt64(ToVBBool(left), Convert.ToInt64(right)) 3486 3487 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 3488 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal 3489 Return MultiplyDecimal(ToVBBool(left), Convert.ToDecimal(right)) 3490 3491 Case TypeCode.Boolean * s_TCMAX + TypeCode.Single 3492 Return MultiplySingle(ToVBBool(left), Convert.ToSingle(right)) 3493 3494 Case TypeCode.Boolean * s_TCMAX + TypeCode.Double 3495 Return MultiplyDouble(ToVBBool(left), Convert.ToDouble(right)) 3496 3497 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 3498 Return MultiplyDouble(ToVBBool(left), CDbl(Convert.ToString(right))) 3499 3500 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 3501 Return MultiplySByte(Convert.ToSByte(left), ToVBBool(right)) 3502 3503 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 3504 Return MultiplySByte(Convert.ToSByte(left), Convert.ToSByte(right)) 3505 3506 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 3507 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 3508 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 3509 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 3510 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 3511 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 3512 TypeCode.Int16 * s_TCMAX + TypeCode.Int16 3513 3514 Return MultiplyInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 3515 3516 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 3517 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 3518 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 3519 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 3520 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 3521 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 3522 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 3523 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 3524 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 3525 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 3526 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 3527 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 3528 TypeCode.Int32 * s_TCMAX + TypeCode.Int32 3529 3530 Return MultiplyInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 3531 3532 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 3533 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 3534 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 3535 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 3536 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 3537 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 3538 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 3539 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 3540 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 3541 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 3542 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 3543 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 3544 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 3545 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 3546 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 3547 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 3548 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 3549 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 3550 TypeCode.Int64 * s_TCMAX + TypeCode.Int64 3551 3552 Return MultiplyInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 3553 3554 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 3555 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 3556 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 3557 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 3558 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 3559 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 3560 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 3561 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 3562 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 3563 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 3564 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 3565 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 3566 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 3567 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 3568 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 3569 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 3570 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 3571 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 3572 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 3573 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 3574 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 3575 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 3576 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 3577 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 3578 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal 3579 3580 Return MultiplyDecimal(left, right) 3581 3582 Case TypeCode.SByte * s_TCMAX + TypeCode.Single, 3583 TypeCode.Byte * s_TCMAX + TypeCode.Single, 3584 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 3585 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 3586 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 3587 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 3588 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 3589 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 3590 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 3591 TypeCode.Single * s_TCMAX + TypeCode.SByte, 3592 TypeCode.Single * s_TCMAX + TypeCode.Byte, 3593 TypeCode.Single * s_TCMAX + TypeCode.Int16, 3594 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 3595 TypeCode.Single * s_TCMAX + TypeCode.Int32, 3596 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 3597 TypeCode.Single * s_TCMAX + TypeCode.Int64, 3598 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 3599 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 3600 TypeCode.Single * s_TCMAX + TypeCode.Single 3601 3602 Return MultiplySingle(Convert.ToSingle(left), Convert.ToSingle(right)) 3603 3604 Case TypeCode.SByte * s_TCMAX + TypeCode.Double, 3605 TypeCode.Byte * s_TCMAX + TypeCode.Double, 3606 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 3607 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 3608 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 3609 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 3610 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 3611 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 3612 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 3613 TypeCode.Single * s_TCMAX + TypeCode.Double, 3614 TypeCode.Double * s_TCMAX + TypeCode.SByte, 3615 TypeCode.Double * s_TCMAX + TypeCode.Byte, 3616 TypeCode.Double * s_TCMAX + TypeCode.Int16, 3617 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 3618 TypeCode.Double * s_TCMAX + TypeCode.Int32, 3619 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 3620 TypeCode.Double * s_TCMAX + TypeCode.Int64, 3621 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 3622 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 3623 TypeCode.Double * s_TCMAX + TypeCode.Single, 3624 TypeCode.Double * s_TCMAX + TypeCode.Double 3625 3626 Return MultiplyDouble(Convert.ToDouble(left), Convert.ToDouble(right)) 3627 3628 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 3629 TypeCode.Byte * s_TCMAX + TypeCode.String, 3630 TypeCode.Int16 * s_TCMAX + TypeCode.String, 3631 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 3632 TypeCode.Int32 * s_TCMAX + TypeCode.String, 3633 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 3634 TypeCode.Int64 * s_TCMAX + TypeCode.String, 3635 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 3636 TypeCode.Decimal * s_TCMAX + TypeCode.String, 3637 TypeCode.Single * s_TCMAX + TypeCode.String, 3638 TypeCode.Double * s_TCMAX + TypeCode.String 3639 3640 Return MultiplyDouble(Convert.ToDouble(left), CDbl(Convert.ToString(right))) 3641 3642 3643 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 3644 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 3645 Return MultiplyInt16(Convert.ToInt16(left), ToVBBool(right)) 3646 3647 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 3648 Return MultiplyByte(Convert.ToByte(left), Convert.ToByte(right)) 3649 3650 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 3651 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 3652 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 3653 Return MultiplyUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 3654 3655 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 3656 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 3657 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 3658 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 3659 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 3660 Return MultiplyUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 3661 3662 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 3663 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 3664 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 3665 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 3666 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 3667 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 3668 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 3669 3670 Return MultiplyUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 3671 3672 3673 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 3674 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 3675 Return MultiplyInt32(Convert.ToInt32(left), ToVBBool(right)) 3676 3677 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 3678 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean 3679 Return MultiplyInt64(Convert.ToInt64(left), ToVBBool(right)) 3680 3681 3682 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 3683 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean 3684 Return MultiplyDecimal(left, ToVBBool(right)) 3685 3686 Case TypeCode.Single * s_TCMAX + TypeCode.Boolean 3687 Return MultiplySingle(Convert.ToSingle(left), ToVBBool(right)) 3688 3689 3690 Case TypeCode.Double * s_TCMAX + TypeCode.Boolean 3691 Return MultiplyDouble(Convert.ToDouble(left), ToVBBool(right)) 3692 3693 3694 Case TypeCode.String * s_TCMAX + TypeCode.Empty 3695 Return MultiplyDouble(CDbl(Convert.ToString(left)), Nothing) 3696 3697 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 3698 Return MultiplyDouble(CDbl(Convert.ToString(left)), ToVBBool(right)) 3699 3700 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 3701 TypeCode.String * s_TCMAX + TypeCode.Byte, 3702 TypeCode.String * s_TCMAX + TypeCode.Int16, 3703 TypeCode.String * s_TCMAX + TypeCode.UInt16, 3704 TypeCode.String * s_TCMAX + TypeCode.Int32, 3705 TypeCode.String * s_TCMAX + TypeCode.UInt32, 3706 TypeCode.String * s_TCMAX + TypeCode.Int64, 3707 TypeCode.String * s_TCMAX + TypeCode.UInt64, 3708 TypeCode.String * s_TCMAX + TypeCode.Decimal, 3709 TypeCode.String * s_TCMAX + TypeCode.Single, 3710 TypeCode.String * s_TCMAX + TypeCode.Double 3711 3712 Return MultiplyDouble(CDbl(Convert.ToString(left)), Convert.ToDouble(right)) 3713 3714 Case TypeCode.String * s_TCMAX + TypeCode.String 3715 Return MultiplyDouble(CDbl(Convert.ToString(left)), CDbl(Convert.ToString(right))) 3716 3717 Case Else 3718 3719 End Select 3720 3721 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 3722 Return InvokeUserDefinedOperator(UserDefinedOperator.Multiply, left, right) 3723 End If 3724 3725 Throw GetNoValidOperatorException(UserDefinedOperator.Multiply, left, right) 3726 3727 End Function 3728 3729 Private Shared Function MultiplyByte(ByVal left As Byte, ByVal right As Byte) As Object 3730 'Range of possible values: [0, 65025] 3731 Dim result As Int32 = CInt(left) * CInt(right) 3732 3733 If result > Byte.MaxValue Then 3734 If result > Int16.MaxValue Then 3735 Return result 3736 Else 3737 Return CShort(result) 3738 End If 3739 Else 3740 Return CByte(result) 3741 End If 3742 End Function 3743 3744 Private Shared Function MultiplySByte(ByVal left As SByte, ByVal right As SByte) As Object 3745 'Range of possible values: [-16256 ,16384] 3746 Dim result As Int16 = CShort(left) * CShort(right) 3747 3748 If result > SByte.MaxValue OrElse result < SByte.MinValue Then 3749 Return result 3750 Else 3751 Return CSByte(result) 3752 End If 3753 End Function 3754 3755 Private Shared Function MultiplyInt16(ByVal left As Int16, ByVal right As Int16) As Object 3756 'Range of possible values: [-1073709056, 1073741824] 3757 Dim result As Int32 = CInt(left) * CInt(right) 3758 3759 If result > Int16.MaxValue OrElse result < Int16.MinValue Then 3760 Return result 3761 Else 3762 Return CShort(result) 3763 End If 3764 End Function 3765 3766 Private Shared Function MultiplyUInt16(ByVal left As UInt16, ByVal right As UInt16) As Object 3767 'Range of possible values: [0, 4294836225] 3768 Dim result As Int64 = CLng(left) * CLng(right) 3769 3770 If result > UInt16.MaxValue Then 3771 If result > Int32.MaxValue Then 3772 Return result 3773 Else 3774 Return CInt(result) 3775 End If 3776 Else 3777 Return CUShort(result) 3778 End If 3779 End Function 3780 3781 Private Shared Function MultiplyInt32(ByVal left As Int32, ByVal right As Int32) As Object 3782 'Range of possible values: [-4611686016279904256, 4611686018427387904] 3783 Dim result As Int64 = CLng(left) * CLng(right) 3784 3785 If result > Int32.MaxValue OrElse result < Int32.MinValue Then 3786 Return result 3787 Else 3788 Return CInt(result) 3789 End If 3790 End Function 3791 3792 Private Shared Function MultiplyUInt32(ByVal left As UInt32, ByVal right As UInt32) As Object 3793 'Range of possible values: [0, 18446744065119617025] 3794 Dim result As UInt64 = CULng(left) * CULng(right) 3795 3796 If result > UInt32.MaxValue Then 3797 If result > Int64.MaxValue Then 3798 Return CDec(result) 3799 Else 3800 Return CLng(result) 3801 End If 3802 Else 3803 Return CUInt(result) 3804 End If 3805 End Function 3806 3807 Private Shared Function MultiplyInt64(ByVal left As Int64, ByVal right As Int64) As Object 3808 Try 3809 Return left * right 3810 Catch ex As OverflowException 3811 End Try 3812 3813 Try 3814 Return CDec(left) * CDec(right) 3815 Catch ex As OverflowException 3816 Return CDbl(left) * CDbl(right) 3817 End Try 3818 End Function 3819 3820 Private Shared Function MultiplyUInt64(ByVal left As UInt64, ByVal right As UInt64) As Object 3821 Try 3822 Return left * right 3823 Catch ex As OverflowException 3824 End Try 3825 3826 Try 3827 Return CDec(left) * CDec(right) 3828 Catch ex As OverflowException 3829 Return CDbl(left) * CDbl(right) 3830 End Try 3831 End Function 3832 3833 Private Shared Function MultiplyDecimal(ByVal left As Object, ByVal right As Object) As Object 3834 Dim leftValue As Decimal = Convert.ToDecimal(left) 3835 Dim rightValue As Decimal = Convert.ToDecimal(right) 3836 3837 Try 3838 Return leftValue * rightValue 3839 Catch ex As OverflowException 3840 'Converting to Double is inconsistent with Division, where we convert to Single. 3841 Return CDbl(leftValue) * CDbl(rightValue) 3842 End Try 3843 End Function 3844 3845 Private Shared Function MultiplySingle(ByVal left As Single, ByVal right As Single) As Object 3846 Dim result As Double = CDbl(left) * CDbl(right) 3847 3848 If ((result <= Single.MaxValue AndAlso result >= Single.MinValue)) Then 3849 Return CSng(result) 3850 ElseIf Double.IsInfinity(result) AndAlso (Single.IsInfinity(left) OrElse Single.IsInfinity(right)) Then 3851 Return CSng(result) 3852 Else 3853 Return result 3854 End If 3855 End Function 3856 3857 Private Shared Function MultiplyDouble(ByVal left As Double, ByVal right As Double) As Object 3858 Return left * right 3859 End Function 3860 3861#End Region 3862 3863#Region " Operator Divide / " 3864 3865 Public Shared Function DivideObject(ByVal left As Object, ByVal right As Object) As Object 3866 3867 Dim tc1 As TypeCode = GetTypeCode(left) 3868 Dim tc2 As TypeCode = GetTypeCode(right) 3869 3870 Select Case tc1 * s_TCMAX + tc2 3871 3872 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 3873 Return DivideDouble(Nothing, Nothing) 3874 3875 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 3876 Return DivideDouble(Nothing, ToVBBool(right)) 3877 3878 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte, 3879 TypeCode.Empty * s_TCMAX + TypeCode.Byte, 3880 TypeCode.Empty * s_TCMAX + TypeCode.Int16, 3881 TypeCode.Empty * s_TCMAX + TypeCode.UInt16, 3882 TypeCode.Empty * s_TCMAX + TypeCode.Int32, 3883 TypeCode.Empty * s_TCMAX + TypeCode.UInt32, 3884 TypeCode.Empty * s_TCMAX + TypeCode.Int64, 3885 TypeCode.Empty * s_TCMAX + TypeCode.UInt64, 3886 TypeCode.Empty * s_TCMAX + TypeCode.Double 3887 Return DivideDouble(Nothing, Convert.ToDouble(right)) 3888 3889 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal 3890 Return DivideDecimal(0D, right) 3891 3892 Case TypeCode.Empty * s_TCMAX + TypeCode.Single 3893 Return DivideSingle(Nothing, Convert.ToSingle(right)) 3894 3895 Case TypeCode.Empty * s_TCMAX + TypeCode.String 3896 Return DivideDouble(Nothing, CDbl(Convert.ToString(right))) 3897 3898 3899 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 3900 Return DivideDouble(ToVBBool(left), Nothing) 3901 3902 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 3903 Return DivideDouble(ToVBBool(left), ToVBBool(right)) 3904 3905 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte, 3906 TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 3907 TypeCode.Boolean * s_TCMAX + TypeCode.Int16, 3908 TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 3909 TypeCode.Boolean * s_TCMAX + TypeCode.Int32, 3910 TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 3911 TypeCode.Boolean * s_TCMAX + TypeCode.Int64, 3912 TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 3913 TypeCode.Boolean * s_TCMAX + TypeCode.Double 3914 Return DivideDouble(ToVBBool(left), Convert.ToDouble(right)) 3915 3916 Case TypeCode.Boolean * s_TCMAX + TypeCode.Decimal 3917 Return DivideDecimal(ToVBBool(left), right) 3918 3919 Case TypeCode.Boolean * s_TCMAX + TypeCode.Single 3920 Return DivideSingle(ToVBBool(left), Convert.ToSingle(right)) 3921 3922 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 3923 Return DivideDouble(ToVBBool(left), CDbl(Convert.ToString(right))) 3924 3925 3926 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty, 3927 TypeCode.Byte * s_TCMAX + TypeCode.Empty, 3928 TypeCode.Int16 * s_TCMAX + TypeCode.Empty, 3929 TypeCode.UInt16 * s_TCMAX + TypeCode.Empty, 3930 TypeCode.Int32 * s_TCMAX + TypeCode.Empty, 3931 TypeCode.UInt32 * s_TCMAX + TypeCode.Empty, 3932 TypeCode.Int64 * s_TCMAX + TypeCode.Empty, 3933 TypeCode.UInt64 * s_TCMAX + TypeCode.Empty, 3934 TypeCode.Double * s_TCMAX + TypeCode.Empty 3935 Return DivideDouble(Convert.ToDouble(left), Nothing) 3936 3937 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean, 3938 TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 3939 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean, 3940 TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 3941 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean, 3942 TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 3943 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean, 3944 TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 3945 TypeCode.Double * s_TCMAX + TypeCode.Boolean 3946 Return DivideDouble(Convert.ToDouble(left), ToVBBool(right)) 3947 3948 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte, 3949 TypeCode.SByte * s_TCMAX + TypeCode.Byte, 3950 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 3951 TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 3952 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 3953 TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 3954 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 3955 TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 3956 TypeCode.SByte * s_TCMAX + TypeCode.Double, 3957 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 3958 TypeCode.Byte * s_TCMAX + TypeCode.Byte, 3959 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 3960 TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 3961 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 3962 TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 3963 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 3964 TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 3965 TypeCode.Byte * s_TCMAX + TypeCode.Double, 3966 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 3967 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 3968 TypeCode.Int16 * s_TCMAX + TypeCode.Int16, 3969 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 3970 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 3971 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 3972 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 3973 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 3974 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 3975 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 3976 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 3977 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 3978 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16, 3979 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 3980 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 3981 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 3982 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 3983 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 3984 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 3985 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 3986 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 3987 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 3988 TypeCode.Int32 * s_TCMAX + TypeCode.Int32, 3989 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 3990 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 3991 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 3992 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 3993 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 3994 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 3995 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 3996 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 3997 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 3998 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32, 3999 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 4000 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 4001 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 4002 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 4003 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 4004 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 4005 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 4006 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 4007 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 4008 TypeCode.Int64 * s_TCMAX + TypeCode.Int64, 4009 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 4010 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 4011 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 4012 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 4013 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 4014 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 4015 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 4016 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 4017 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 4018 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64, 4019 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 4020 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 4021 TypeCode.Single * s_TCMAX + TypeCode.Double, 4022 TypeCode.Double * s_TCMAX + TypeCode.SByte, 4023 TypeCode.Double * s_TCMAX + TypeCode.Byte, 4024 TypeCode.Double * s_TCMAX + TypeCode.Int16, 4025 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 4026 TypeCode.Double * s_TCMAX + TypeCode.Int32, 4027 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 4028 TypeCode.Double * s_TCMAX + TypeCode.Int64, 4029 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 4030 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 4031 TypeCode.Double * s_TCMAX + TypeCode.Single, 4032 TypeCode.Double * s_TCMAX + TypeCode.Double 4033 Return DivideDouble(Convert.ToDouble(left), Convert.ToDouble(right)) 4034 4035 Case TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 4036 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 4037 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 4038 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 4039 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 4040 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 4041 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 4042 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 4043 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 4044 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 4045 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 4046 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 4047 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 4048 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 4049 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 4050 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 4051 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal 4052 Return DivideDecimal(left, right) 4053 4054 Case TypeCode.SByte * s_TCMAX + TypeCode.Single, 4055 TypeCode.Byte * s_TCMAX + TypeCode.Single, 4056 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 4057 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 4058 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 4059 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 4060 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 4061 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 4062 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 4063 TypeCode.Single * s_TCMAX + TypeCode.SByte, 4064 TypeCode.Single * s_TCMAX + TypeCode.Byte, 4065 TypeCode.Single * s_TCMAX + TypeCode.Int16, 4066 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 4067 TypeCode.Single * s_TCMAX + TypeCode.Int32, 4068 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 4069 TypeCode.Single * s_TCMAX + TypeCode.Int64, 4070 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 4071 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 4072 TypeCode.Single * s_TCMAX + TypeCode.Single 4073 Return DivideSingle(Convert.ToSingle(left), Convert.ToSingle(right)) 4074 4075 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 4076 TypeCode.Byte * s_TCMAX + TypeCode.String, 4077 TypeCode.Int16 * s_TCMAX + TypeCode.String, 4078 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 4079 TypeCode.Int32 * s_TCMAX + TypeCode.String, 4080 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 4081 TypeCode.Int64 * s_TCMAX + TypeCode.String, 4082 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 4083 TypeCode.Decimal * s_TCMAX + TypeCode.String, 4084 TypeCode.Single * s_TCMAX + TypeCode.String, 4085 TypeCode.Double * s_TCMAX + TypeCode.String 4086 Return DivideDouble(Convert.ToDouble(left), CDbl(Convert.ToString(right))) 4087 4088 4089 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty 4090 Return DivideDecimal(left, 0D) 4091 4092 Case TypeCode.Decimal * s_TCMAX + TypeCode.Boolean 4093 Return DivideDecimal(left, ToVBBool(right)) 4094 4095 4096 Case TypeCode.Single * s_TCMAX + TypeCode.Empty 4097 Return DivideSingle(Convert.ToSingle(left), Nothing) 4098 4099 Case TypeCode.Single * s_TCMAX + TypeCode.Boolean 4100 Return DivideSingle(Convert.ToSingle(left), ToVBBool(right)) 4101 4102 4103 Case TypeCode.String * s_TCMAX + TypeCode.Empty 4104 Return DivideDouble(CDbl(Convert.ToString(left)), Nothing) 4105 4106 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 4107 Return DivideDouble(CDbl(Convert.ToString(left)), ToVBBool(right)) 4108 4109 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 4110 TypeCode.String * s_TCMAX + TypeCode.Byte, 4111 TypeCode.String * s_TCMAX + TypeCode.Int16, 4112 TypeCode.String * s_TCMAX + TypeCode.UInt16, 4113 TypeCode.String * s_TCMAX + TypeCode.Int32, 4114 TypeCode.String * s_TCMAX + TypeCode.UInt32, 4115 TypeCode.String * s_TCMAX + TypeCode.Int64, 4116 TypeCode.String * s_TCMAX + TypeCode.UInt64, 4117 TypeCode.String * s_TCMAX + TypeCode.Decimal, 4118 TypeCode.String * s_TCMAX + TypeCode.Single, 4119 TypeCode.String * s_TCMAX + TypeCode.Double 4120 Return DivideDouble(CDbl(Convert.ToString(left)), Convert.ToDouble(right)) 4121 4122 Case TypeCode.String * s_TCMAX + TypeCode.String 4123 Return DivideDouble(CDbl(Convert.ToString(left)), CDbl(Convert.ToString(right))) 4124 4125 Case Else 4126 4127 End Select 4128 4129 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 4130 Return InvokeUserDefinedOperator(UserDefinedOperator.Divide, left, right) 4131 End If 4132 4133 Throw GetNoValidOperatorException(UserDefinedOperator.Divide, left, right) 4134 4135 End Function 4136 4137 Private Shared Function DivideDecimal(ByVal left As Object, ByVal right As Object) As Object 4138 Dim leftValue As Decimal = Convert.ToDecimal(left) 4139 Dim rightValue As Decimal = Convert.ToDecimal(right) 4140 4141 Try 4142 Return leftValue / rightValue 4143 Catch ex As OverflowException 4144 'Converting to Single is inconsistent with Multiplication, where we convert to Double. 4145 Return CSng(leftValue) / CSng(rightValue) 4146 End Try 4147 End Function 4148 4149 Private Shared Function DivideSingle(ByVal left As Single, ByVal right As Single) As Object 4150 Dim result As Single = left / right 4151 4152 If Single.IsInfinity(result) Then 4153 If Single.IsInfinity(left) OrElse Single.IsInfinity(right) Then 4154 Return result 4155 End If 4156 Return CDbl(left) / CDbl(right) 4157 Else 4158 Return result 4159 End If 4160 4161 End Function 4162 4163 Private Shared Function DivideDouble(ByVal left As Double, ByVal right As Double) As Object 4164 Return left / right 4165 End Function 4166 4167#End Region 4168 4169#Region " Operator Power ^ " 4170 4171 Public Shared Function ExponentObject(ByVal left As Object, ByVal right As Object) As Object 4172 4173 Dim tc1 As TypeCode = GetTypeCode(left) 4174 Dim tc2 As TypeCode = GetTypeCode(right) 4175 4176 Dim leftValue As Double 4177 Dim rightValue As Double 4178 4179 4180 Select Case tc1 4181 Case TypeCode.Empty 4182 leftValue = 0.0R 4183 4184 Case TypeCode.Boolean 4185 leftValue = ToVBBool(left) 4186 4187 Case TypeCode.SByte, 4188 TypeCode.Byte, 4189 TypeCode.Int16, 4190 TypeCode.UInt16, 4191 TypeCode.Int32, 4192 TypeCode.UInt32, 4193 TypeCode.Int64, 4194 TypeCode.UInt64, 4195 TypeCode.Decimal, 4196 TypeCode.Single, 4197 TypeCode.Double 4198 leftValue = Convert.ToDouble(left) 4199 4200 Case TypeCode.String 4201 leftValue = CDbl(Convert.ToString(left)) 4202 4203 Case TypeCode.Object 4204 Return InvokeUserDefinedOperator(UserDefinedOperator.Power, left, right) 4205 4206 Case Else 4207 'DateTime 4208 'Char 4209 Throw GetNoValidOperatorException(UserDefinedOperator.Power, left, right) 4210 End Select 4211 4212 Select Case tc2 4213 Case TypeCode.Empty 4214 rightValue = 0.0R 4215 4216 Case TypeCode.Boolean 4217 rightValue = ToVBBool(right) 4218 4219 Case TypeCode.SByte, 4220 TypeCode.Byte, 4221 TypeCode.Int16, 4222 TypeCode.UInt16, 4223 TypeCode.Int32, 4224 TypeCode.UInt32, 4225 TypeCode.Int64, 4226 TypeCode.UInt64, 4227 TypeCode.Decimal, 4228 TypeCode.Single, 4229 TypeCode.Double 4230 rightValue = Convert.ToDouble(right) 4231 4232 Case TypeCode.String 4233 rightValue = CDbl(Convert.ToString(right)) 4234 4235 Case TypeCode.Object 4236 Return InvokeUserDefinedOperator(UserDefinedOperator.Power, left, right) 4237 4238 Case Else 4239 'DateTime 4240 'Char 4241 Throw GetNoValidOperatorException(UserDefinedOperator.Power, left, right) 4242 End Select 4243 4244 Return leftValue ^ rightValue 4245 4246 End Function 4247 4248#End Region 4249 4250#Region " Operator Mod " 4251 4252 Public Shared Function ModObject(ByVal left As Object, ByVal right As Object) As Object 4253 4254 Dim tc1 As TypeCode = GetTypeCode(left) 4255 Dim tc2 As TypeCode = GetTypeCode(right) 4256 4257 Select Case tc1 * s_TCMAX + tc2 4258 4259 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 4260 Return ModInt32(Nothing, Nothing) 4261 4262 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 4263 Return ModInt16(Nothing, ToVBBool(right)) 4264 4265 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte 4266 Return ModSByte(Nothing, Convert.ToSByte(right)) 4267 4268 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte 4269 Return ModByte(Nothing, Convert.ToByte(right)) 4270 4271 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16 4272 Return ModInt16(Nothing, Convert.ToInt16(right)) 4273 4274 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16 4275 Return ModUInt16(Nothing, Convert.ToUInt16(right)) 4276 4277 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32 4278 Return ModInt32(Nothing, Convert.ToInt32(right)) 4279 4280 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32 4281 Return ModUInt32(Nothing, Convert.ToUInt32(right)) 4282 4283 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64 4284 Return ModInt64(Nothing, Convert.ToInt64(right)) 4285 4286 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64 4287 Return ModUInt64(Nothing, Convert.ToUInt64(right)) 4288 4289 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal 4290 Return ModDecimal(0D, Convert.ToDecimal(right)) 4291 4292 Case TypeCode.Empty * s_TCMAX + TypeCode.Single 4293 Return ModSingle(Nothing, Convert.ToSingle(right)) 4294 4295 Case TypeCode.Empty * s_TCMAX + TypeCode.Double 4296 Return ModDouble(Nothing, Convert.ToDouble(right)) 4297 4298 Case TypeCode.Empty * s_TCMAX + TypeCode.String 4299 Return ModDouble(Nothing, CDbl(Convert.ToString(right))) 4300 4301 4302 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 4303 Return ModInt16(ToVBBool(left), Nothing) 4304 4305 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 4306 Return ModInt16(ToVBBool(left), ToVBBool(right)) 4307 4308 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 4309 Return ModSByte(ToVBBool(left), Convert.ToSByte(right)) 4310 4311 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 4312 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 4313 Return ModInt16(ToVBBool(left), Convert.ToInt16(right)) 4314 4315 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 4316 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 4317 Return ModInt32(ToVBBool(left), Convert.ToInt32(right)) 4318 4319 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 4320 TypeCode.Boolean * s_TCMAX + TypeCode.Int64 4321 Return ModInt64(ToVBBool(left), Convert.ToInt64(right)) 4322 4323 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 4324 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal 4325 Return ModDecimal(ToVBBool(left), Convert.ToDecimal(right)) 4326 4327 Case TypeCode.Boolean * s_TCMAX + TypeCode.Single 4328 Return ModSingle(ToVBBool(left), Convert.ToSingle(right)) 4329 4330 Case TypeCode.Boolean * s_TCMAX + TypeCode.Double 4331 Return ModDouble(ToVBBool(left), Convert.ToDouble(right)) 4332 4333 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 4334 Return ModDouble(ToVBBool(left), CDbl(Convert.ToString(right))) 4335 4336 4337 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty 4338 Return ModSByte(Convert.ToSByte(left), Nothing) 4339 4340 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 4341 Return ModSByte(Convert.ToSByte(left), ToVBBool(right)) 4342 4343 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 4344 Return ModSByte(Convert.ToSByte(left), Convert.ToSByte(right)) 4345 4346 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 4347 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 4348 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 4349 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 4350 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 4351 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 4352 TypeCode.Int16 * s_TCMAX + TypeCode.Int16 4353 4354 Return ModInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 4355 4356 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 4357 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 4358 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 4359 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 4360 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 4361 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 4362 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 4363 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 4364 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 4365 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 4366 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 4367 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 4368 TypeCode.Int32 * s_TCMAX + TypeCode.Int32 4369 4370 Return ModInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 4371 4372 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 4373 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 4374 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 4375 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 4376 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 4377 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 4378 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 4379 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 4380 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 4381 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 4382 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 4383 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 4384 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 4385 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 4386 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 4387 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 4388 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 4389 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 4390 TypeCode.Int64 * s_TCMAX + TypeCode.Int64 4391 4392 Return ModInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 4393 4394 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 4395 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 4396 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 4397 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 4398 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 4399 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 4400 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 4401 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 4402 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 4403 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 4404 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 4405 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 4406 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 4407 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 4408 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 4409 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 4410 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 4411 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 4412 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 4413 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 4414 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 4415 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 4416 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 4417 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 4418 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal 4419 4420 Return ModDecimal(left, right) 4421 4422 Case TypeCode.SByte * s_TCMAX + TypeCode.Single, 4423 TypeCode.Byte * s_TCMAX + TypeCode.Single, 4424 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 4425 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 4426 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 4427 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 4428 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 4429 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 4430 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 4431 TypeCode.Single * s_TCMAX + TypeCode.SByte, 4432 TypeCode.Single * s_TCMAX + TypeCode.Byte, 4433 TypeCode.Single * s_TCMAX + TypeCode.Int16, 4434 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 4435 TypeCode.Single * s_TCMAX + TypeCode.Int32, 4436 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 4437 TypeCode.Single * s_TCMAX + TypeCode.Int64, 4438 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 4439 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 4440 TypeCode.Single * s_TCMAX + TypeCode.Single 4441 4442 Return ModSingle(Convert.ToSingle(left), Convert.ToSingle(right)) 4443 4444 Case TypeCode.SByte * s_TCMAX + TypeCode.Double, 4445 TypeCode.Byte * s_TCMAX + TypeCode.Double, 4446 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 4447 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 4448 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 4449 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 4450 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 4451 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 4452 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 4453 TypeCode.Single * s_TCMAX + TypeCode.Double, 4454 TypeCode.Double * s_TCMAX + TypeCode.SByte, 4455 TypeCode.Double * s_TCMAX + TypeCode.Byte, 4456 TypeCode.Double * s_TCMAX + TypeCode.Int16, 4457 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 4458 TypeCode.Double * s_TCMAX + TypeCode.Int32, 4459 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 4460 TypeCode.Double * s_TCMAX + TypeCode.Int64, 4461 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 4462 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 4463 TypeCode.Double * s_TCMAX + TypeCode.Single, 4464 TypeCode.Double * s_TCMAX + TypeCode.Double 4465 4466 Return ModDouble(Convert.ToDouble(left), Convert.ToDouble(right)) 4467 4468 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 4469 TypeCode.Byte * s_TCMAX + TypeCode.String, 4470 TypeCode.Int16 * s_TCMAX + TypeCode.String, 4471 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 4472 TypeCode.Int32 * s_TCMAX + TypeCode.String, 4473 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 4474 TypeCode.Int64 * s_TCMAX + TypeCode.String, 4475 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 4476 TypeCode.Decimal * s_TCMAX + TypeCode.String, 4477 TypeCode.Single * s_TCMAX + TypeCode.String, 4478 TypeCode.Double * s_TCMAX + TypeCode.String 4479 4480 Return ModDouble(Convert.ToDouble(left), CDbl(Convert.ToString(right))) 4481 4482 4483 Case TypeCode.Byte * s_TCMAX + TypeCode.Empty 4484 Return ModByte(Convert.ToByte(left), Nothing) 4485 4486 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 4487 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 4488 Return ModInt16(Convert.ToInt16(left), ToVBBool(right)) 4489 4490 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 4491 Return ModByte(Convert.ToByte(left), Convert.ToByte(right)) 4492 4493 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 4494 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 4495 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 4496 Return ModUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 4497 4498 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 4499 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 4500 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 4501 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 4502 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 4503 Return ModUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 4504 4505 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 4506 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 4507 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 4508 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 4509 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 4510 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 4511 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 4512 4513 Return ModUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 4514 4515 4516 Case TypeCode.Int16 * s_TCMAX + TypeCode.Empty 4517 Return ModInt16(Convert.ToInt16(left), Nothing) 4518 4519 4520 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 4521 Return ModUInt16(Convert.ToUInt16(left), Nothing) 4522 4523 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 4524 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 4525 Return ModInt32(Convert.ToInt32(left), ToVBBool(right)) 4526 4527 4528 Case TypeCode.Int32 * s_TCMAX + TypeCode.Empty 4529 Return ModInt32(Convert.ToInt32(left), Nothing) 4530 4531 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 4532 Return ModUInt32(Convert.ToUInt32(left), Nothing) 4533 4534 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 4535 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean 4536 Return ModInt64(Convert.ToInt64(left), ToVBBool(right)) 4537 4538 Case TypeCode.Int64 * s_TCMAX + TypeCode.Empty 4539 Return ModInt64(Convert.ToInt64(left), Nothing) 4540 4541 4542 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 4543 Return ModUInt64(Convert.ToUInt64(left), Nothing) 4544 4545 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 4546 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean 4547 Return ModDecimal(left, ToVBBool(right)) 4548 4549 4550 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty 4551 Return ModDecimal(left, 0D) 4552 4553 4554 Case TypeCode.Single * s_TCMAX + TypeCode.Empty 4555 Return ModSingle(Convert.ToSingle(left), Nothing) 4556 4557 Case TypeCode.Single * s_TCMAX + TypeCode.Boolean 4558 Return ModSingle(Convert.ToSingle(left), ToVBBool(right)) 4559 4560 4561 Case TypeCode.Double * s_TCMAX + TypeCode.Empty 4562 Return ModDouble(Convert.ToDouble(left), Nothing) 4563 4564 Case TypeCode.Double * s_TCMAX + TypeCode.Boolean 4565 Return ModDouble(Convert.ToDouble(left), ToVBBool(right)) 4566 4567 4568 Case TypeCode.String * s_TCMAX + TypeCode.Empty 4569 Return ModDouble(CDbl(Convert.ToString(left)), Nothing) 4570 4571 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 4572 Return ModDouble(CDbl(Convert.ToString(left)), ToVBBool(right)) 4573 4574 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 4575 TypeCode.String * s_TCMAX + TypeCode.Byte, 4576 TypeCode.String * s_TCMAX + TypeCode.Int16, 4577 TypeCode.String * s_TCMAX + TypeCode.UInt16, 4578 TypeCode.String * s_TCMAX + TypeCode.Int32, 4579 TypeCode.String * s_TCMAX + TypeCode.UInt32, 4580 TypeCode.String * s_TCMAX + TypeCode.Int64, 4581 TypeCode.String * s_TCMAX + TypeCode.UInt64, 4582 TypeCode.String * s_TCMAX + TypeCode.Decimal, 4583 TypeCode.String * s_TCMAX + TypeCode.Single, 4584 TypeCode.String * s_TCMAX + TypeCode.Double 4585 4586 Return ModDouble(CDbl(Convert.ToString(left)), Convert.ToDouble(right)) 4587 4588 Case TypeCode.String * s_TCMAX + TypeCode.String 4589 Return ModDouble(CDbl(Convert.ToString(left)), CDbl(Convert.ToString(right))) 4590 4591 Case Else 4592 4593 End Select 4594 4595 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 4596 Return InvokeUserDefinedOperator(UserDefinedOperator.Modulus, left, right) 4597 End If 4598 4599 Throw GetNoValidOperatorException(UserDefinedOperator.Modulus, left, right) 4600 End Function 4601 4602 Private Shared Function ModSByte(ByVal left As SByte, ByVal right As SByte) As Object 4603 Return left Mod right 4604 End Function 4605 4606 Private Shared Function ModByte(ByVal left As Byte, ByVal right As Byte) As Object 4607 Return left Mod right 4608 End Function 4609 4610 Private Shared Function ModInt16(ByVal left As Int16, ByVal right As Int16) As Object 4611 Dim result As Integer = CInt(left) Mod CInt(right) 4612 4613 If result < Int16.MinValue OrElse result > Int16.MaxValue Then 4614 Return result 4615 Else 4616 Return CShort(result) 4617 End If 4618 End Function 4619 4620 Private Shared Function ModUInt16(ByVal left As UInt16, ByVal right As UInt16) As Object 4621 Return left Mod right 4622 End Function 4623 4624 Private Shared Function ModInt32(ByVal left As Integer, ByVal right As Integer) As Object 4625 'Do operation with Int64 to avoid OverflowException with Int32.MinValue and -1 4626 Dim result As Long = CLng(left) Mod CLng(right) 4627 4628 If result < Int32.MinValue OrElse result > Int32.MaxValue Then 4629 Return result 4630 Else 4631 Return CInt(result) 4632 End If 4633 End Function 4634 4635 Private Shared Function ModUInt32(ByVal left As UInt32, ByVal right As UInt32) As Object 4636 Return left Mod right 4637 End Function 4638 4639 Private Shared Function ModInt64(ByVal left As Int64, ByVal right As Int64) As Object 4640 4641 If left = Int64.MinValue AndAlso right = -1 Then 4642 Return 0L 4643 Else 4644 Return left Mod right 4645 End If 4646 4647 End Function 4648 4649 Private Shared Function ModUInt64(ByVal left As UInt64, ByVal right As UInt64) As Object 4650 Return left Mod right 4651 End Function 4652 4653 Private Shared Function ModDecimal(ByVal left As Object, ByVal right As Object) As Object 4654 Dim leftValue As Decimal = Convert.ToDecimal(left) 4655 Dim rightValue As Decimal = Convert.ToDecimal(right) 4656 4657 Return leftValue Mod rightValue 4658 End Function 4659 4660 Private Shared Function ModSingle(ByVal left As Single, ByVal right As Single) As Object 4661 Return left Mod right 4662 End Function 4663 4664 Private Shared Function ModDouble(ByVal left As Double, ByVal right As Double) As Object 4665 Return left Mod right 4666 End Function 4667 4668#End Region 4669 4670#Region " Operator Integral Divide \ " 4671 4672 Public Shared Function IntDivideObject(ByVal left As Object, ByVal right As Object) As Object 4673 4674 Dim tc1 As TypeCode = GetTypeCode(left) 4675 Dim tc2 As TypeCode = GetTypeCode(right) 4676 4677 Select Case tc1 * s_TCMAX + tc2 4678 4679 Case TypeCode.Empty * s_TCMAX + TypeCode.Empty 4680 Return IntDivideInt32(Nothing, Nothing) 4681 4682 Case TypeCode.Empty * s_TCMAX + TypeCode.Boolean 4683 Return IntDivideInt16(Nothing, ToVBBool(right)) 4684 4685 Case TypeCode.Empty * s_TCMAX + TypeCode.SByte 4686 Return IntDivideSByte(Nothing, Convert.ToSByte(right)) 4687 4688 Case TypeCode.Empty * s_TCMAX + TypeCode.Byte 4689 Return IntDivideByte(Nothing, Convert.ToByte(right)) 4690 4691 Case TypeCode.Empty * s_TCMAX + TypeCode.Int16 4692 Return IntDivideInt16(Nothing, Convert.ToInt16(right)) 4693 4694 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt16 4695 Return IntDivideUInt16(Nothing, Convert.ToUInt16(right)) 4696 4697 Case TypeCode.Empty * s_TCMAX + TypeCode.Int32 4698 Return IntDivideInt32(Nothing, Convert.ToInt32(right)) 4699 4700 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt32 4701 Return IntDivideUInt32(Nothing, Convert.ToUInt32(right)) 4702 4703 Case TypeCode.Empty * s_TCMAX + TypeCode.Int64 4704 Return IntDivideInt64(Nothing, Convert.ToInt64(right)) 4705 4706 Case TypeCode.Empty * s_TCMAX + TypeCode.UInt64 4707 Return IntDivideUInt64(Nothing, Convert.ToUInt64(right)) 4708 4709 Case TypeCode.Empty * s_TCMAX + TypeCode.Decimal, 4710 TypeCode.Empty * s_TCMAX + TypeCode.Single, 4711 TypeCode.Empty * s_TCMAX + TypeCode.Double 4712 Return IntDivideInt64(Nothing, Convert.ToInt64(right)) 4713 4714 Case TypeCode.Empty * s_TCMAX + TypeCode.String 4715 Return IntDivideInt64(Nothing, CLng(Convert.ToString(right))) 4716 4717 4718 Case TypeCode.Boolean * s_TCMAX + TypeCode.Empty 4719 Return IntDivideInt16(ToVBBool(left), Nothing) 4720 4721 Case TypeCode.Boolean * s_TCMAX + TypeCode.Boolean 4722 Return IntDivideInt16(ToVBBool(left), ToVBBool(right)) 4723 4724 Case TypeCode.Boolean * s_TCMAX + TypeCode.SByte 4725 Return IntDivideSByte(ToVBBool(left), Convert.ToSByte(right)) 4726 4727 Case TypeCode.Boolean * s_TCMAX + TypeCode.Byte, 4728 TypeCode.Boolean * s_TCMAX + TypeCode.Int16 4729 Return IntDivideInt16(ToVBBool(left), Convert.ToInt16(right)) 4730 4731 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt16, 4732 TypeCode.Boolean * s_TCMAX + TypeCode.Int32 4733 Return IntDivideInt32(ToVBBool(left), Convert.ToInt32(right)) 4734 4735 Case TypeCode.Boolean * s_TCMAX + TypeCode.UInt32, 4736 TypeCode.Boolean * s_TCMAX + TypeCode.Int64, 4737 TypeCode.Boolean * s_TCMAX + TypeCode.UInt64, 4738 TypeCode.Boolean * s_TCMAX + TypeCode.Decimal, 4739 TypeCode.Boolean * s_TCMAX + TypeCode.Single, 4740 TypeCode.Boolean * s_TCMAX + TypeCode.Double 4741 4742 Return IntDivideInt64(ToVBBool(left), Convert.ToInt64(right)) 4743 4744 Case TypeCode.Boolean * s_TCMAX + TypeCode.String 4745 Return IntDivideInt64(ToVBBool(left), CLng(Convert.ToString(right))) 4746 4747 4748 Case TypeCode.SByte * s_TCMAX + TypeCode.Empty 4749 Return IntDivideSByte(Convert.ToSByte(left), Nothing) 4750 4751 Case TypeCode.SByte * s_TCMAX + TypeCode.Boolean 4752 Return IntDivideSByte(Convert.ToSByte(left), ToVBBool(right)) 4753 4754 Case TypeCode.SByte * s_TCMAX + TypeCode.SByte 4755 Return IntDivideSByte(Convert.ToSByte(left), Convert.ToSByte(right)) 4756 4757 Case TypeCode.SByte * s_TCMAX + TypeCode.Byte, 4758 TypeCode.SByte * s_TCMAX + TypeCode.Int16, 4759 TypeCode.Byte * s_TCMAX + TypeCode.SByte, 4760 TypeCode.Byte * s_TCMAX + TypeCode.Int16, 4761 TypeCode.Int16 * s_TCMAX + TypeCode.SByte, 4762 TypeCode.Int16 * s_TCMAX + TypeCode.Byte, 4763 TypeCode.Int16 * s_TCMAX + TypeCode.Int16 4764 4765 Return IntDivideInt16(Convert.ToInt16(left), Convert.ToInt16(right)) 4766 4767 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt16, 4768 TypeCode.SByte * s_TCMAX + TypeCode.Int32, 4769 TypeCode.Byte * s_TCMAX + TypeCode.Int32, 4770 TypeCode.Int16 * s_TCMAX + TypeCode.UInt16, 4771 TypeCode.Int16 * s_TCMAX + TypeCode.Int32, 4772 TypeCode.UInt16 * s_TCMAX + TypeCode.SByte, 4773 TypeCode.UInt16 * s_TCMAX + TypeCode.Int16, 4774 TypeCode.UInt16 * s_TCMAX + TypeCode.Int32, 4775 TypeCode.Int32 * s_TCMAX + TypeCode.SByte, 4776 TypeCode.Int32 * s_TCMAX + TypeCode.Byte, 4777 TypeCode.Int32 * s_TCMAX + TypeCode.Int16, 4778 TypeCode.Int32 * s_TCMAX + TypeCode.UInt16, 4779 TypeCode.Int32 * s_TCMAX + TypeCode.Int32 4780 4781 Return IntDivideInt32(Convert.ToInt32(left), Convert.ToInt32(right)) 4782 4783 Case TypeCode.SByte * s_TCMAX + TypeCode.UInt32, 4784 TypeCode.SByte * s_TCMAX + TypeCode.Int64, 4785 TypeCode.SByte * s_TCMAX + TypeCode.UInt64, 4786 TypeCode.SByte * s_TCMAX + TypeCode.Decimal, 4787 TypeCode.SByte * s_TCMAX + TypeCode.Single, 4788 TypeCode.SByte * s_TCMAX + TypeCode.Double, 4789 TypeCode.Byte * s_TCMAX + TypeCode.Int64, 4790 TypeCode.Byte * s_TCMAX + TypeCode.Decimal, 4791 TypeCode.Byte * s_TCMAX + TypeCode.Single, 4792 TypeCode.Byte * s_TCMAX + TypeCode.Double, 4793 TypeCode.Int16 * s_TCMAX + TypeCode.UInt32, 4794 TypeCode.Int16 * s_TCMAX + TypeCode.Int64, 4795 TypeCode.Int16 * s_TCMAX + TypeCode.UInt64, 4796 TypeCode.Int16 * s_TCMAX + TypeCode.Decimal, 4797 TypeCode.Int16 * s_TCMAX + TypeCode.Single, 4798 TypeCode.Int16 * s_TCMAX + TypeCode.Double, 4799 TypeCode.UInt16 * s_TCMAX + TypeCode.Int64, 4800 TypeCode.UInt16 * s_TCMAX + TypeCode.Decimal, 4801 TypeCode.UInt16 * s_TCMAX + TypeCode.Single, 4802 TypeCode.UInt16 * s_TCMAX + TypeCode.Double, 4803 TypeCode.Int32 * s_TCMAX + TypeCode.UInt32, 4804 TypeCode.Int32 * s_TCMAX + TypeCode.Int64, 4805 TypeCode.Int32 * s_TCMAX + TypeCode.UInt64, 4806 TypeCode.Int32 * s_TCMAX + TypeCode.Decimal, 4807 TypeCode.Int32 * s_TCMAX + TypeCode.Single, 4808 TypeCode.Int32 * s_TCMAX + TypeCode.Double, 4809 TypeCode.UInt32 * s_TCMAX + TypeCode.SByte, 4810 TypeCode.UInt32 * s_TCMAX + TypeCode.Int16, 4811 TypeCode.UInt32 * s_TCMAX + TypeCode.Int32, 4812 TypeCode.UInt32 * s_TCMAX + TypeCode.Int64, 4813 TypeCode.UInt32 * s_TCMAX + TypeCode.Decimal, 4814 TypeCode.UInt32 * s_TCMAX + TypeCode.Single, 4815 TypeCode.UInt32 * s_TCMAX + TypeCode.Double, 4816 TypeCode.Int64 * s_TCMAX + TypeCode.SByte, 4817 TypeCode.Int64 * s_TCMAX + TypeCode.Byte, 4818 TypeCode.Int64 * s_TCMAX + TypeCode.Int16, 4819 TypeCode.Int64 * s_TCMAX + TypeCode.UInt16, 4820 TypeCode.Int64 * s_TCMAX + TypeCode.Int32, 4821 TypeCode.Int64 * s_TCMAX + TypeCode.UInt32, 4822 TypeCode.Int64 * s_TCMAX + TypeCode.Int64, 4823 TypeCode.Int64 * s_TCMAX + TypeCode.UInt64, 4824 TypeCode.Int64 * s_TCMAX + TypeCode.Decimal, 4825 TypeCode.Int64 * s_TCMAX + TypeCode.Single, 4826 TypeCode.Int64 * s_TCMAX + TypeCode.Double, 4827 TypeCode.UInt64 * s_TCMAX + TypeCode.SByte, 4828 TypeCode.UInt64 * s_TCMAX + TypeCode.Int16, 4829 TypeCode.UInt64 * s_TCMAX + TypeCode.Int32, 4830 TypeCode.UInt64 * s_TCMAX + TypeCode.Int64, 4831 TypeCode.UInt64 * s_TCMAX + TypeCode.Decimal, 4832 TypeCode.UInt64 * s_TCMAX + TypeCode.Single, 4833 TypeCode.UInt64 * s_TCMAX + TypeCode.Double, 4834 TypeCode.Decimal * s_TCMAX + TypeCode.SByte, 4835 TypeCode.Decimal * s_TCMAX + TypeCode.Byte, 4836 TypeCode.Decimal * s_TCMAX + TypeCode.Int16, 4837 TypeCode.Decimal * s_TCMAX + TypeCode.UInt16, 4838 TypeCode.Decimal * s_TCMAX + TypeCode.Int32, 4839 TypeCode.Decimal * s_TCMAX + TypeCode.UInt32, 4840 TypeCode.Decimal * s_TCMAX + TypeCode.Int64, 4841 TypeCode.Decimal * s_TCMAX + TypeCode.UInt64, 4842 TypeCode.Decimal * s_TCMAX + TypeCode.Decimal, 4843 TypeCode.Decimal * s_TCMAX + TypeCode.Single, 4844 TypeCode.Decimal * s_TCMAX + TypeCode.Double, 4845 TypeCode.Single * s_TCMAX + TypeCode.SByte, 4846 TypeCode.Single * s_TCMAX + TypeCode.Byte, 4847 TypeCode.Single * s_TCMAX + TypeCode.Int16, 4848 TypeCode.Single * s_TCMAX + TypeCode.UInt16, 4849 TypeCode.Single * s_TCMAX + TypeCode.Int32, 4850 TypeCode.Single * s_TCMAX + TypeCode.UInt32, 4851 TypeCode.Single * s_TCMAX + TypeCode.Int64, 4852 TypeCode.Single * s_TCMAX + TypeCode.UInt64, 4853 TypeCode.Single * s_TCMAX + TypeCode.Decimal, 4854 TypeCode.Single * s_TCMAX + TypeCode.Single, 4855 TypeCode.Single * s_TCMAX + TypeCode.Double, 4856 TypeCode.Double * s_TCMAX + TypeCode.SByte, 4857 TypeCode.Double * s_TCMAX + TypeCode.Byte, 4858 TypeCode.Double * s_TCMAX + TypeCode.Int16, 4859 TypeCode.Double * s_TCMAX + TypeCode.UInt16, 4860 TypeCode.Double * s_TCMAX + TypeCode.Int32, 4861 TypeCode.Double * s_TCMAX + TypeCode.UInt32, 4862 TypeCode.Double * s_TCMAX + TypeCode.Int64, 4863 TypeCode.Double * s_TCMAX + TypeCode.UInt64, 4864 TypeCode.Double * s_TCMAX + TypeCode.Decimal, 4865 TypeCode.Double * s_TCMAX + TypeCode.Single, 4866 TypeCode.Double * s_TCMAX + TypeCode.Double 4867 4868 Return IntDivideInt64(Convert.ToInt64(left), Convert.ToInt64(right)) 4869 4870 Case TypeCode.SByte * s_TCMAX + TypeCode.String, 4871 TypeCode.Byte * s_TCMAX + TypeCode.String, 4872 TypeCode.Int16 * s_TCMAX + TypeCode.String, 4873 TypeCode.UInt16 * s_TCMAX + TypeCode.String, 4874 TypeCode.Int32 * s_TCMAX + TypeCode.String, 4875 TypeCode.UInt32 * s_TCMAX + TypeCode.String, 4876 TypeCode.Int64 * s_TCMAX + TypeCode.String, 4877 TypeCode.UInt64 * s_TCMAX + TypeCode.String, 4878 TypeCode.Decimal * s_TCMAX + TypeCode.String, 4879 TypeCode.Single * s_TCMAX + TypeCode.String, 4880 TypeCode.Double * s_TCMAX + TypeCode.String 4881 4882 Return IntDivideInt64(Convert.ToInt64(left), CLng(Convert.ToString(right))) 4883 4884 4885 Case TypeCode.Byte * s_TCMAX + TypeCode.Empty 4886 Return IntDivideByte(Convert.ToByte(left), Nothing) 4887 4888 Case TypeCode.Byte * s_TCMAX + TypeCode.Boolean, 4889 TypeCode.Int16 * s_TCMAX + TypeCode.Boolean 4890 Return IntDivideInt16(Convert.ToInt16(left), ToVBBool(right)) 4891 4892 Case TypeCode.Byte * s_TCMAX + TypeCode.Byte 4893 Return IntDivideByte(Convert.ToByte(left), Convert.ToByte(right)) 4894 4895 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt16, 4896 TypeCode.UInt16 * s_TCMAX + TypeCode.Byte, 4897 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt16 4898 Return IntDivideUInt16(Convert.ToUInt16(left), Convert.ToUInt16(right)) 4899 4900 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt32, 4901 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt32, 4902 TypeCode.UInt32 * s_TCMAX + TypeCode.Byte, 4903 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt16, 4904 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt32 4905 4906 Return IntDivideUInt32(Convert.ToUInt32(left), Convert.ToUInt32(right)) 4907 4908 Case TypeCode.Byte * s_TCMAX + TypeCode.UInt64, 4909 TypeCode.UInt16 * s_TCMAX + TypeCode.UInt64, 4910 TypeCode.UInt32 * s_TCMAX + TypeCode.UInt64, 4911 TypeCode.UInt64 * s_TCMAX + TypeCode.Byte, 4912 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt16, 4913 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt32, 4914 TypeCode.UInt64 * s_TCMAX + TypeCode.UInt64 4915 4916 Return IntDivideUInt64(Convert.ToUInt64(left), Convert.ToUInt64(right)) 4917 4918 4919 Case TypeCode.Int16 * s_TCMAX + TypeCode.Empty 4920 Return IntDivideInt16(Convert.ToInt16(left), Nothing) 4921 4922 4923 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Empty 4924 Return IntDivideUInt16(Convert.ToUInt16(left), Nothing) 4925 4926 Case TypeCode.UInt16 * s_TCMAX + TypeCode.Boolean, 4927 TypeCode.Int32 * s_TCMAX + TypeCode.Boolean 4928 Return IntDivideInt32(Convert.ToInt32(left), ToVBBool(right)) 4929 4930 4931 Case TypeCode.Int32 * s_TCMAX + TypeCode.Empty 4932 Return IntDivideInt32(Convert.ToInt32(left), Nothing) 4933 4934 4935 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Empty 4936 Return IntDivideUInt32(Convert.ToUInt32(left), Nothing) 4937 4938 Case TypeCode.UInt32 * s_TCMAX + TypeCode.Boolean, 4939 TypeCode.Int64 * s_TCMAX + TypeCode.Boolean, 4940 TypeCode.UInt64 * s_TCMAX + TypeCode.Boolean, 4941 TypeCode.Decimal * s_TCMAX + TypeCode.Boolean, 4942 TypeCode.Single * s_TCMAX + TypeCode.Boolean, 4943 TypeCode.Double * s_TCMAX + TypeCode.Boolean 4944 4945 Return IntDivideInt64(Convert.ToInt64(left), ToVBBool(right)) 4946 4947 4948 Case TypeCode.Int64 * s_TCMAX + TypeCode.Empty 4949 Return IntDivideInt64(Convert.ToInt64(left), Nothing) 4950 4951 4952 Case TypeCode.UInt64 * s_TCMAX + TypeCode.Empty 4953 Return IntDivideUInt64(Convert.ToUInt64(left), Nothing) 4954 4955 4956 Case TypeCode.Decimal * s_TCMAX + TypeCode.Empty, 4957 TypeCode.Single * s_TCMAX + TypeCode.Empty, 4958 TypeCode.Double * s_TCMAX + TypeCode.Empty 4959 Return IntDivideInt64(Convert.ToInt64(left), Nothing) 4960 4961 4962 Case TypeCode.String * s_TCMAX + TypeCode.Empty 4963 Return IntDivideInt64(CLng(Convert.ToString(left)), Nothing) 4964 4965 Case TypeCode.String * s_TCMAX + TypeCode.Boolean 4966 Return IntDivideInt64(CLng(Convert.ToString(left)), ToVBBool(right)) 4967 4968 Case TypeCode.String * s_TCMAX + TypeCode.SByte, 4969 TypeCode.String * s_TCMAX + TypeCode.Byte, 4970 TypeCode.String * s_TCMAX + TypeCode.Int16, 4971 TypeCode.String * s_TCMAX + TypeCode.UInt16, 4972 TypeCode.String * s_TCMAX + TypeCode.Int32, 4973 TypeCode.String * s_TCMAX + TypeCode.UInt32, 4974 TypeCode.String * s_TCMAX + TypeCode.Int64, 4975 TypeCode.String * s_TCMAX + TypeCode.UInt64, 4976 TypeCode.String * s_TCMAX + TypeCode.Decimal, 4977 TypeCode.String * s_TCMAX + TypeCode.Single, 4978 TypeCode.String * s_TCMAX + TypeCode.Double 4979 4980 Return IntDivideInt64(CLng(Convert.ToString(left)), Convert.ToInt64(right)) 4981 4982 Case TypeCode.String * s_TCMAX + TypeCode.String 4983 Return IntDivideInt64(CLng(Convert.ToString(left)), CLng(Convert.ToString(right))) 4984 4985 End Select 4986 4987 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 4988 Return InvokeUserDefinedOperator(UserDefinedOperator.IntegralDivide, left, right) 4989 End If 4990 4991 Throw GetNoValidOperatorException(UserDefinedOperator.IntegralDivide, left, right) 4992 End Function 4993 4994 Private Shared Function IntDivideSByte(ByVal left As SByte, ByVal right As SByte) As Object 4995 If left = SByte.MinValue AndAlso right = -1 Then 4996 Return -CShort(SByte.MinValue) 4997 End If 4998 4999 Return left \ right 5000 End Function 5001 5002 Private Shared Function IntDivideByte(ByVal left As Byte, ByVal right As Byte) As Object 5003 Return left \ right 5004 End Function 5005 5006 Private Shared Function IntDivideInt16(ByVal left As Int16, ByVal right As Int16) As Object 5007 If left = Short.MinValue AndAlso right = -1 Then 5008 Return -CInt(Short.MinValue) 5009 End If 5010 5011 Return left \ right 5012 End Function 5013 5014 Private Shared Function IntDivideUInt16(ByVal left As UInt16, ByVal right As UInt16) As Object 5015 Return left \ right 5016 End Function 5017 5018 Private Shared Function IntDivideInt32(ByVal left As Int32, ByVal right As Int32) As Object 5019 If left = Integer.MinValue AndAlso right = -1 Then 5020 Return -CLng(Integer.MinValue) 5021 End If 5022 5023 Return left \ right 5024 End Function 5025 5026 Private Shared Function IntDivideUInt32(ByVal left As UInt32, ByVal right As UInt32) As Object 5027 Return left \ right 5028 End Function 5029 5030 Private Shared Function IntDivideInt64(ByVal left As Int64, ByVal right As Int64) As Object 5031 Return left \ right 5032 End Function 5033 5034 Private Shared Function IntDivideUInt64(ByVal left As UInt64, ByVal right As UInt64) As Object 5035 Return left \ right 5036 End Function 5037 5038#End Region 5039 5040#Region " Operator Shift Left << " 5041 5042 Public Shared Function LeftShiftObject(ByVal operand As Object, ByVal amount As Object) As Object 5043 5044 Dim tc1 As TypeCode = GetTypeCode(operand) 5045 Dim tc2 As TypeCode = GetTypeCode(amount) 5046 5047 5048 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 5049 Return InvokeUserDefinedOperator(UserDefinedOperator.ShiftLeft, operand, amount) 5050 End If 5051 5052 Select Case tc1 5053 Case TypeCode.Empty 5054 Return Nothing << CInt(amount) 5055 Case TypeCode.Boolean 5056 Return CShort(Convert.ToBoolean(operand)) << CInt(amount) 5057 Case TypeCode.SByte 5058 Return Convert.ToSByte(operand) << CInt(amount) 5059 Case TypeCode.Byte 5060 Return Convert.ToByte(operand) << CInt(amount) 5061 Case TypeCode.Int16 5062 Return Convert.ToInt16(operand) << CInt(amount) 5063 Case TypeCode.UInt16 5064 Return Convert.ToUInt16(operand) << CInt(amount) 5065 Case TypeCode.Int32 5066 Return Convert.ToInt32(operand) << CInt(amount) 5067 Case TypeCode.UInt32 5068 Return Convert.ToUInt32(operand) << CInt(amount) 5069 Case TypeCode.Int64, 5070 TypeCode.Single, 5071 TypeCode.Double, 5072 TypeCode.Decimal 5073 Return Convert.ToInt64(operand) << CInt(amount) 5074 Case TypeCode.UInt64 5075 Return Convert.ToUInt64(operand) << CInt(amount) 5076 Case TypeCode.String 5077 Return CLng(Convert.ToString(operand)) << CInt(amount) 5078 End Select 5079 5080 Throw GetNoValidOperatorException(UserDefinedOperator.ShiftLeft, operand) 5081 End Function 5082 5083#End Region 5084 5085#Region " Operator Shift Right >> " 5086 5087 Public Shared Function RightShiftObject(ByVal operand As Object, ByVal amount As Object) As Object 5088 5089 Dim tc1 As TypeCode = GetTypeCode(operand) 5090 Dim tc2 As TypeCode = GetTypeCode(amount) 5091 5092 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 5093 Return InvokeUserDefinedOperator(UserDefinedOperator.ShiftRight, operand, amount) 5094 End If 5095 5096 Select Case tc1 5097 Case TypeCode.Empty 5098 Return Nothing >> CInt(amount) 5099 Case TypeCode.Boolean 5100 Return CShort(Convert.ToBoolean(operand)) >> CInt(amount) 5101 Case TypeCode.SByte 5102 Return Convert.ToSByte(operand) >> CInt(amount) 5103 Case TypeCode.Byte 5104 Return Convert.ToByte(operand) >> CInt(amount) 5105 Case TypeCode.Int16 5106 Return Convert.ToInt16(operand) >> CInt(amount) 5107 Case TypeCode.UInt16 5108 Return Convert.ToUInt16(operand) >> CInt(amount) 5109 Case TypeCode.Int32 5110 Return Convert.ToInt32(operand) >> CInt(amount) 5111 Case TypeCode.UInt32 5112 Return Convert.ToUInt32(operand) >> CInt(amount) 5113 Case TypeCode.Int64, 5114 TypeCode.Single, 5115 TypeCode.Double, 5116 TypeCode.Decimal 5117 Return Convert.ToInt64(operand) >> CInt(amount) 5118 Case TypeCode.UInt64 5119 Return Convert.ToUInt64(operand) >> CInt(amount) 5120 Case TypeCode.String 5121 Return CLng(Convert.ToString(operand)) >> CInt(amount) 5122 End Select 5123 5124 Throw GetNoValidOperatorException(UserDefinedOperator.ShiftRight, operand) 5125 End Function 5126 5127#End Region 5128 5129 5130#Region " Operator Concatenate & " 5131 5132 Public Shared Function ConcatenateObject(ByVal left As Object, ByVal right As Object) As Object 5133 5134 Dim tc1 As TypeCode = GetTypeCode(left) 5135 Dim tc2 As TypeCode = GetTypeCode(right) 5136 5137 'Special cases for Char() 5138 If (tc1 = TypeCode.Object) AndAlso (TypeOf left Is Char()) Then 5139 tc1 = TypeCode.String 5140 End If 5141 5142 If (tc2 = TypeCode.Object) AndAlso (TypeOf right Is Char()) Then 5143 tc2 = TypeCode.String 5144 End If 5145 5146 If tc1 = TypeCode.Object OrElse tc2 = TypeCode.Object Then 5147 Return InvokeUserDefinedOperator(UserDefinedOperator.Concatenate, left, right) 5148 End If 5149 5150 Return CStr(left) & CStr(right) 5151 End Function 5152 5153#End Region 5154 5155 End Class 5156 5157End Namespace 5158 5159