# Patch created by springjp # Date: Mon Oct 14 18:11:25 EDT 2002 # Repository: pnet # Comments: # # # * Fix segmentation fault in managed pointer casting. # * Add equality and inequality comparisons for managed pointers. #### End of Preamble #### #### Patch data follows #### Index: ChangeLog =================================================================== RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v retrieving revision 1.1736 diff -u -c -r1.1736 ChangeLog *** ChangeLog 14 Oct 2002 13:32:49 -0000 1.1736 --- ChangeLog 14 Oct 2002 22:11:26 -0000 *************** *** 1,4 **** --- 1,10 ---- + 2001-10-14 Jonathan Springer + + * codegen/cg_coerce.c, codeget/cg_optable.c: Fixed segmentation + fault in prior patch. Added equality and inequality operators + for unmanaged pointers. + 2001-10-12 Jonathan Springer * codegen/cg_coerce.c: Allow casting among unmanaged pointers Index: codegen/cg_coerce.c =================================================================== RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_coerce.c,v retrieving revision 1.11 diff -u -c -r1.11 cg_coerce.c *** codegen/cg_coerce.c 14 Oct 2002 13:32:50 -0000 1.11 --- codegen/cg_coerce.c 14 Oct 2002 22:11:27 -0000 *************** *** 335,351 **** if (explicit) { /* Numeric -> pointer conversion */ ! if ( ! (ILIsBuiltinNumeric(fromType) ! && ILType_Kind(toType) == IL_TYPE_COMPLEX_PTR) ! || (ILType_Kind(fromType) == IL_TYPE_COMPLEX_PTR ! && ILIsBuiltinNumeric(toType)) ! || (ILType_Kind(fromType) == IL_TYPE_COMPLEX_PTR ! && ILType_Kind(toType) == IL_TYPE_COMPLEX_PTR) ! ) { ! /* Let the external operator handle the real work */ ! return 1; } } --- 335,363 ---- if (explicit) { /* Numeric -> pointer conversion */ ! if ( ILIsBuiltinNumeric(toType) && ILType_IsComplex(fromType) ) { ! if (ILType_Kind(fromType) == IL_TYPE_COMPLEX_PTR) ! { ! return 1; ! } ! } ! ! if ( ILType_IsComplex(toType) && ILIsBuiltinNumeric(fromType) ) ! { ! if (ILType_Kind(toType) == IL_TYPE_COMPLEX_PTR) ! { ! return 1; ! } ! } ! ! if ( ILType_IsComplex(toType) && ILType_IsComplex(fromType) ) ! { ! if (ILType_Kind(toType) == IL_TYPE_COMPLEX_PTR ! && ILType_Kind(fromType) == IL_TYPE_COMPLEX_PTR) ! { ! return 1; ! } } } Index: codegen/cg_optable.c =================================================================== RCS file: /cvsroot/dotgnu-pnet/pnet/codegen/cg_optable.c,v retrieving revision 1.12 diff -u -c -r1.12 cg_optable.c *** codegen/cg_optable.c 10 Sep 2002 00:36:05 -0000 1.12 --- codegen/cg_optable.c 14 Oct 2002 22:11:28 -0000 *************** *** 113,118 **** --- 113,122 ---- {ILType_UInt64, ILMachineType_UInt64, 1}; + static ILBuiltinType const ILUnmanagedPtr = + {ILType_Invalid, /* This is a reference, really */ + ILMachineType_UnmanagedPtr, 1}; + #define IL_BEGIN_OPERATOR_TABLE(op) \ ILOperator const ILOp_##op[] = { #define IL_UNARY_OPERATOR(outtype,intype) \ *************** *** 438,443 **** --- 442,448 ---- {&ILSystemBoolean, &ILEnumUInt32, &ILEnumUInt32}, {&ILSystemBoolean, &ILEnumInt64, &ILEnumInt64}, {&ILSystemBoolean, &ILEnumUInt64, &ILEnumUInt64}, + {&ILSystemBoolean, &ILUnmanagedPtr, &ILUnmanagedPtr}, IL_END_OPERATOR_TABLE /* *************** *** 475,480 **** --- 480,486 ---- {&ILSystemBoolean, &ILEnumUInt32, &ILEnumUInt32}, {&ILSystemBoolean, &ILEnumInt64, &ILEnumInt64}, {&ILSystemBoolean, &ILEnumUInt64, &ILEnumUInt64}, + {&ILSystemBoolean, &ILUnmanagedPtr, &ILUnmanagedPtr}, IL_END_OPERATOR_TABLE /* *************** *** 1264,1269 **** --- 1270,1283 ---- { return &ILEnumUInt64; } + } + return 0; + } + else if (ILType_IsComplex(type)) + { + if (ILType_Kind(type) == IL_TYPE_COMPLEX_PTR) + { + return &ILUnmanagedPtr; } return 0; } #### End of Patch data ####