string GetValue(Constant constant) { switch (constant.Kind) { case ConstantKind.Char: var c = (char)constant.ValueUInt64; return("'" + c.ToString() + "'"); case ConstantKind.String: if (constant.RefValue is string s) { return("\"" + EscapeStringValue(s) + "\""); } throw new InvalidOperationException(); case ConstantKind.Int32: case ConstantKind.Index: if (constant.UseHex) { return(NumberFormatter.FormatHexUInt32WithSep((uint)constant.ValueUInt64)); } return(((int)constant.ValueUInt64).ToString()); case ConstantKind.UInt32: if (constant.UseHex) { return(NumberFormatter.FormatHexUInt32WithSep((uint)constant.ValueUInt64)); } return(((uint)constant.ValueUInt64).ToString()); case ConstantKind.UInt64: if (constant.UseHex) { return(NumberFormatter.FormatHexUInt64WithSep(constant.ValueUInt64)); } return(constant.ValueUInt64.ToString()); case ConstantKind.Register: case ConstantKind.MemorySize: return(GetValueString(constant)); default: throw new InvalidOperationException(); } }