Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NullableMethodCallInstruction.cs
Go to the documentation of this file.
5
7
9{
11 {
12 public override int Run(InterpretedFrame frame)
13 {
14 object obj = frame.Pop();
15 frame.Push(obj != null);
16 return 1;
17 }
18 }
19
21 {
22 public override int Run(InterpretedFrame frame)
23 {
24 if (frame.Peek() == null)
25 {
26 return ((int?)null).Value;
27 }
28 return 1;
29 }
30 }
31
33 {
34 private readonly Type _defaultValueType;
35
40
41 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2077:UnrecognizedReflectionPattern", Justification = "_defaultValueType is a ValueType. You can always get an uninitialized ValueType.")]
42 public override int Run(InterpretedFrame frame)
43 {
44 if (frame.Peek() == null)
45 {
46 frame.Pop();
48 }
49 return 1;
50 }
51 }
52
54 {
55 public override int ConsumedStack => 2;
56
57 public override int Run(InterpretedFrame frame)
58 {
59 object obj = frame.Pop();
60 object obj2 = frame.Pop();
61 frame.Push(obj2 ?? obj);
62 return 1;
63 }
64 }
65
67 {
68 public override int ConsumedStack => 2;
69
70 public override int Run(InterpretedFrame frame)
71 {
72 object obj = frame.Pop();
73 object obj2 = frame.Pop();
74 if (obj2 == null)
75 {
76 frame.Push(obj == null);
77 }
78 else if (obj == null)
79 {
80 frame.Push(Utils.BoxedFalse);
81 }
82 else
83 {
84 frame.Push(obj2.Equals(obj));
85 }
86 return 1;
87 }
88 }
89
91 {
92 public override int Run(InterpretedFrame frame)
93 {
94 object obj = frame.Pop();
95 frame.Push((obj == null) ? "" : obj.ToString());
96 return 1;
97 }
98 }
99
101 {
102 public override int Run(InterpretedFrame frame)
103 {
104 frame.Push(frame.Pop()?.GetHashCode() ?? 0);
105 return 1;
106 }
107 }
108
110
112
114
116
118
120
121 public override int ConsumedStack => 1;
122
123 public override int ProducedStack => 1;
124
125 public override string InstructionName => "NullableMethod";
126
128 {
129 }
130
131 public static Instruction Create(string method, int argCount, MethodInfo mi)
132 {
133 switch (method)
134 {
135 case "get_HasValue":
136 return s_hasValue ?? (s_hasValue = new HasValue());
137 case "get_Value":
138 return s_value ?? (s_value = new GetValue());
139 case "Equals":
140 return s_equals ?? (s_equals = new EqualsClass());
141 case "GetHashCode":
142 return s_getHashCode ?? (s_getHashCode = new GetHashCodeClass());
143 case "GetValueOrDefault":
144 if (argCount == 0)
145 {
146 return new GetValueOrDefault(mi);
147 }
149 case "ToString":
150 return s_toString ?? (s_toString = new ToStringClass());
151 default:
153 }
154 }
155
157 {
158 return s_value ?? (s_value = new GetValue());
159 }
160}
static Instruction Create(string method, int argCount, MethodInfo mi)
static readonly object BoxedFalse
Definition Utils.cs:8
static object GetUninitializedObject([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type)