Skip to content

Conversation

@dgrunwald
Copy link
Member

@dgrunwald dgrunwald commented Oct 16, 2017

The new decompiler ILSpy 3 is lacking support for pointer arithmetic.
The code is instead decompiled into arithmetic on IntPtr, which requires a whole mess of casts (#851):

return (char)(*(ushort*)((long)ptr + (long)(System.IntPtr)(void*)((long)(int)num * 2L)));

This PR introduces support for pointer arithmetic to the expression builder.

  • *ptr
  • *ptr + int
  • Test ptr + long, ptr - long
  • Test (byte*)ptr - (byte*)ptr
  • Test pointer arithmetic with pointer-to-struct
  • Allow pointer comparisons without casting to IntPtr
  • Foreach over pointer array: needs Add foreach over array pattern. #946
  • Pointer arithmetic compound assignments -> Pointer arithmetic compound assignments #947
  • fixed() statement
  • Fixed size buffers (unsafe fixed int array[3];)
  • stackalloc[]

@dgrunwald dgrunwald changed the title [WIP] Pointer arithmetic Pointer arithmetic Oct 30, 2017
@dgrunwald dgrunwald merged commit 00759d2 into master Oct 30, 2017
@siegfriedpammer siegfriedpammer deleted the unsafe branch November 25, 2017 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant