Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IncrementInstruction.cs
Go to the documentation of this file.
2
4
5internal abstract class IncrementInstruction : Instruction
6{
7 private sealed class IncrementInt16 : IncrementInstruction
8 {
9 public override int Run(InterpretedFrame frame)
10 {
11 object obj = frame.Pop();
12 if (obj == null)
13 {
14 frame.Push(null);
15 }
16 else
17 {
18 frame.Push((short)(1 + (short)obj));
19 }
20 return 1;
21 }
22 }
23
24 private sealed class IncrementInt32 : IncrementInstruction
25 {
26 public override int Run(InterpretedFrame frame)
27 {
28 object obj = frame.Pop();
29 if (obj == null)
30 {
31 frame.Push(null);
32 }
33 else
34 {
35 frame.Push(1 + (int)obj);
36 }
37 return 1;
38 }
39 }
40
41 private sealed class IncrementInt64 : IncrementInstruction
42 {
43 public override int Run(InterpretedFrame frame)
44 {
45 object obj = frame.Pop();
46 if (obj == null)
47 {
48 frame.Push(null);
49 }
50 else
51 {
52 frame.Push(1 + (long)obj);
53 }
54 return 1;
55 }
56 }
57
59 {
60 public override int Run(InterpretedFrame frame)
61 {
62 object obj = frame.Pop();
63 if (obj == null)
64 {
65 frame.Push(null);
66 }
67 else
68 {
69 frame.Push((ushort)(1 + (ushort)obj));
70 }
71 return 1;
72 }
73 }
74
76 {
77 public override int Run(InterpretedFrame frame)
78 {
79 object obj = frame.Pop();
80 if (obj == null)
81 {
82 frame.Push(null);
83 }
84 else
85 {
86 frame.Push(1 + (uint)obj);
87 }
88 return 1;
89 }
90 }
91
93 {
94 public override int Run(InterpretedFrame frame)
95 {
96 object obj = frame.Pop();
97 if (obj == null)
98 {
99 frame.Push(null);
100 }
101 else
102 {
103 frame.Push(1 + (ulong)obj);
104 }
105 return 1;
106 }
107 }
108
110 {
111 public override int Run(InterpretedFrame frame)
112 {
113 object obj = frame.Pop();
114 if (obj == null)
115 {
116 frame.Push(null);
117 }
118 else
119 {
120 frame.Push(1f + (float)obj);
121 }
122 return 1;
123 }
124 }
125
127 {
128 public override int Run(InterpretedFrame frame)
129 {
130 object obj = frame.Pop();
131 if (obj == null)
132 {
133 frame.Push(null);
134 }
135 else
136 {
137 frame.Push(1.0 + (double)obj);
138 }
139 return 1;
140 }
141 }
142
143 private static Instruction s_Int16;
144
145 private static Instruction s_Int32;
146
147 private static Instruction s_Int64;
148
149 private static Instruction s_UInt16;
150
151 private static Instruction s_UInt32;
152
153 private static Instruction s_UInt64;
154
155 private static Instruction s_Single;
156
157 private static Instruction s_Double;
158
159 public override int ConsumedStack => 1;
160
161 public override int ProducedStack => 1;
162
163 public override string InstructionName => "Increment";
164
166 {
167 }
168
170 {
171 return type.GetNonNullableType().GetTypeCode() switch
172 {
173 TypeCode.Int16 => s_Int16 ?? (s_Int16 = new IncrementInt16()),
174 TypeCode.Int32 => s_Int32 ?? (s_Int32 = new IncrementInt32()),
175 TypeCode.Int64 => s_Int64 ?? (s_Int64 = new IncrementInt64()),
176 TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new IncrementUInt16()),
177 TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new IncrementUInt32()),
178 TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new IncrementUInt64()),
179 TypeCode.Single => s_Single ?? (s_Single = new IncrementSingle()),
180 TypeCode.Double => s_Double ?? (s_Double = new IncrementDouble()),
181 _ => throw ContractUtils.Unreachable,
182 };
183 }
184}
TypeCode
Definition TypeCode.cs:4