forked from icsharpcode/ILSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointerArithmetic.cs
More file actions
127 lines (103 loc) · 2.69 KB
/
PointerArithmetic.cs
File metadata and controls
127 lines (103 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public class PointerArithmetic
{
public unsafe static void AssignmentVoidPointerToIntPointer(void* ptr)
{
((int*)ptr)[2] = 1;
}
public unsafe static int AccessVoidPointerToIntPointer(void* ptr)
{
return ((int*)ptr)[2];
}
public unsafe static void AssignmentLongPointerToIntPointer_2(long* ptr)
{
((int*)ptr)[2] = 1;
}
public unsafe static int AccessLongPointerToIntPointer_2(long* ptr)
{
return ((int*)ptr)[2];
}
public unsafe static void AssignmentLongPointerToIntPointer_3(long* ptr)
{
((int*)ptr)[3] = 1;
}
public unsafe static int AccessLongPointerToIntPointer_3(long* ptr)
{
return ((int*)ptr)[3];
}
public unsafe static void AssignmentGuidPointerToIntPointer(Guid* ptr)
{
((int*)ptr)[2] = 1;
}
public unsafe static int AccessGuidPointerToIntPointer(Guid* ptr)
{
return ((int*)ptr)[2];
}
public unsafe static uint AccessGuidPointerToUIntPointer(Guid* ptr)
{
return ((uint*)ptr)[2];
}
public unsafe static void AssignmentGuidPointerToDateTimePointer(Guid* ptr)
{
((DateTime*)ptr)[2] = DateTime.Now;
}
public unsafe static void AssignmentGuidPointerToDateTimePointerDefault(Guid* ptr)
{
((DateTime*)ptr)[2] = default(DateTime);
}
public unsafe static void AssignmentGuidPointerToDateTimePointer_2(Guid* ptr)
{
*(DateTime*)(ptr + 2) = DateTime.Now;
}
public unsafe static void AssignmentGuidPointerToDateTimePointerDefault_2(Guid* ptr)
{
*(DateTime*)(ptr + 2) = default(DateTime);
}
public unsafe static DateTime AccessGuidPointerToDateTimePointer(Guid* ptr)
{
return ((DateTime*)ptr)[2];
}
public unsafe static DateTime AccessGuidPointerToDateTimePointer_2(Guid* ptr)
{
return *(DateTime*)(ptr + 2);
}
public unsafe static void AssignmentIntPointer(int* ptr)
{
ptr[2] = 1;
}
public unsafe static int AccessIntPointer(int* ptr)
{
return ptr[2];
}
public unsafe static void AssignmentGuidPointer(Guid* ptr)
{
ptr[2] = Guid.NewGuid();
}
public unsafe static Guid AccessGuidPointer(Guid* ptr)
{
return ptr[2];
}
public unsafe static void AssignmentVoidPointerToGuidPointer(void* ptr)
{
((Guid*)ptr)[2] = Guid.NewGuid();
}
public unsafe static Guid AccessVoidPointerToGuidPointer(void* ptr)
{
return ((Guid*)ptr)[2];
}
public unsafe static void AssignmentIntPointerToGuidPointer(int* ptr)
{
((Guid*)ptr)[2] = Guid.NewGuid();
}
public unsafe static void AssignmentIntPointerToGuidPointer_2(int* ptr)
{
*(Guid*)(ptr + 2) = Guid.NewGuid();
}
public unsafe static Guid AccessIntPointerToGuidPointer(int* ptr)
{
return ((Guid*)ptr)[2];
}
}
}