Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OpCode.cs
Go to the documentation of this file.
3
5
6public readonly struct OpCode : IEquatable<OpCode>
7{
8 private readonly OpCodeValues m_value;
9
10 private readonly int m_flags;
11
12 private static volatile string[] g_nameCache;
13
15
16 public FlowControl FlowControl => (FlowControl)((m_flags >> 5) & 0xF);
17
18 public OpCodeType OpCodeType => (OpCodeType)((m_flags >> 9) & 7);
19
21
23
24 public int Size => (m_flags >> 22) & 3;
25
26 public short Value => (short)m_value;
27
28 public string? Name
29 {
30 get
31 {
32 if (Size == 0)
33 {
34 return null;
35 }
36 string[] array = g_nameCache;
37 if (array == null)
38 {
39 array = (g_nameCache = new string[287]);
40 }
41 OpCodeValues opCodeValues = (OpCodeValues)(ushort)Value;
42 int num = (int)opCodeValues;
43 if (num > 255)
44 {
45 if (num < 65024 || num > 65054)
46 {
47 return null;
48 }
49 num = 256 + (num - 65024);
50 }
51 string text = Volatile.Read(ref array[num]);
52 if (text != null)
53 {
54 return text;
55 }
56 text = Enum.GetName(typeof(OpCodeValues), opCodeValues).ToLowerInvariant().Replace('_', '.');
57 Volatile.Write(ref array[num], text);
58 return text;
59 }
60 }
61
62 internal OpCode(OpCodeValues value, int flags)
63 {
64 m_value = value;
65 m_flags = flags;
66 }
67
68 internal bool EndsUncondJmpBlk()
69 {
70 return (m_flags & 0x1000000) != 0;
71 }
72
73 internal int StackChange()
74 {
75 return m_flags >> 28;
76 }
77
78 public override bool Equals([NotNullWhen(true)] object? obj)
79 {
80 if (obj is OpCode obj2)
81 {
82 return Equals(obj2);
83 }
84 return false;
85 }
86
87 public bool Equals(OpCode obj)
88 {
89 return obj.Value == Value;
90 }
91
92 public static bool operator ==(OpCode a, OpCode b)
93 {
94 return a.Equals(b);
95 }
96
97 public static bool operator !=(OpCode a, OpCode b)
98 {
99 return !(a == b);
100 }
101
102 public override int GetHashCode()
103 {
104 return Value;
105 }
106
107 public override string? ToString()
108 {
109 return Name;
110 }
111}
static ? string GetName(Type enumType, object value)
Definition Enum.cs:281
static bool Read(ref bool location)
Definition Volatile.cs:67
static void Write(ref bool location, bool value)
Definition Volatile.cs:74
bool Equals(OpCode obj)
Definition OpCode.cs:87
override? string ToString()
Definition OpCode.cs:107
StackBehaviour StackBehaviourPop
Definition OpCode.cs:20
override int GetHashCode()
Definition OpCode.cs:102
StackBehaviour StackBehaviourPush
Definition OpCode.cs:22
OpCode(OpCodeValues value, int flags)
Definition OpCode.cs:62
readonly OpCodeValues m_value
Definition OpCode.cs:8
static bool operator!=(OpCode a, OpCode b)
Definition OpCode.cs:97
override bool Equals([NotNullWhen(true)] object? obj)
Definition OpCode.cs:78
static bool operator==(OpCode a, OpCode b)
Definition OpCode.cs:92
static volatile string[] g_nameCache
Definition OpCode.cs:12