using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Diagnostics.SymbolStore; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Xml; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mono.CSharp; using Mono.CSharp.IL2CPP; using Mono.CSharp.Linq; using Mono.CSharp.Nullable; using Mono.CSharp.yyParser; using Mono.CSharp.yydebug; using Mono.CompilerServices.SymbolWriter; using MonoMod.RuntimeDetour; using Tomlet; using Tomlet.Attributes; using Tomlet.Exceptions; using Tomlet.Models; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityExplorer.CSConsole; using UnityExplorer.CSConsole.Lexers; using UnityExplorer.CacheObject; using UnityExplorer.CacheObject.IValues; using UnityExplorer.CacheObject.Views; using UnityExplorer.Config; using UnityExplorer.Hooks; using UnityExplorer.Inspectors; using UnityExplorer.Inspectors.MouseInspectors; using UnityExplorer.Loader.BIE; using UnityExplorer.ObjectExplorer; using UnityExplorer.Runtime; using UnityExplorer.UI; using UnityExplorer.UI.Panels; using UnityExplorer.UI.Widgets; using UnityExplorer.UI.Widgets.AutoComplete; using UniverseLib; using UniverseLib.Config; using UniverseLib.Input; using UniverseLib.Runtime; using UniverseLib.UI; using UniverseLib.UI.Models; using UniverseLib.UI.ObjectPool; using UniverseLib.UI.Panels; using UniverseLib.UI.Widgets; using UniverseLib.UI.Widgets.ButtonList; using UniverseLib.UI.Widgets.ScrollView; using UniverseLib.Utility; [assembly: AssemblyTitle("UnityExplorer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyCompany("Sinai, yukieiji, Jettcodey")] [assembly: Guid("b21dbde3-5d6f-4726-93ab-cc3cc68bae7d")] [assembly: AssemblyFileVersion("4.14.1")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: ComVisible(false)] [assembly: AssemblyProduct("UnityExplorer")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.14.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<1443f3da-2346-4a1b-9fa6-7e29da059fc0>Embedded] internal sealed class <1443f3da-2346-4a1b-9fa6-7e29da059fc0>EmbeddedAttribute : System.Attribute { } } namespace System.Runtime.CompilerServices { [<1443f3da-2346-4a1b-9fa6-7e29da059fc0>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class <51f39266-096c-4d87-ba52-c28899f938d4>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <51f39266-096c-4d87-ba52-c28899f938d4>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <51f39266-096c-4d87-ba52-c28899f938d4>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] [<1443f3da-2346-4a1b-9fa6-7e29da059fc0>Embedded] [CompilerGenerated] internal sealed class <1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContextAttribute : Attribute { public readonly byte Flag; public <1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<1443f3da-2346-4a1b-9fa6-7e29da059fc0>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] [CompilerGenerated] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UnityExplorer { public class ExplorerBehaviour : MonoBehaviour { internal bool quitting; internal static ExplorerBehaviour Instance { get; private set; } internal static void Setup() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ExplorerBehaviour"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; Instance = val.AddComponent(); } internal void Update() { ExplorerCore.Update(); } internal void OnDestroy() { OnApplicationQuit(); } internal void OnApplicationQuit() { if (!quitting) { quitting = true; if (Object.op_Implicit((Object)(object)UIManager.UIRoot)) { TryDestroy(((Component)UIManager.UIRoot.transform.root).gameObject); } object? value = typeof(Universe).Assembly.GetType("UniverseLib.UniversalBehaviour").GetProperty("Instance", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null, null); TryDestroy(((Component)((value is Component) ? value : null)).gameObject); TryDestroy(((Component)this).gameObject); } } internal void TryDestroy(GameObject obj) { try { if (Object.op_Implicit((Object)(object)obj)) { Object.Destroy((Object)(object)obj); } } catch (Exception ex) { ExplorerCore.LogError("Destroy Error!! " + ex.Message); } } } public static class ExplorerCore { public const string NAME = "UnityExplorer"; public const string VERSION = "4.14.1"; public const string AUTHOR = "Sinai, yukieiji, Jettcodey"; public const string GUID = "com.sinai.unityexplorer"; public const string DEFAULT_EXPLORER_FOLDER_NAME = "sinai-dev-UnityExplorer"; public static IExplorerLoader Loader { get; private set; } public static string ExplorerFolder => Path.Combine(Loader.ExplorerFolderDestination, Loader.ExplorerFolderName); public static Harmony Harmony { get; } = new Harmony("com.sinai.unityexplorer"); public static void Init(IExplorerLoader loader) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (Loader != null) { throw new Exception("UnityExplorer is already loaded."); } Loader = loader; Log("UnityExplorer 4.14.1 initializing..."); CheckLegacyExplorerFolder(); Directory.CreateDirectory(ExplorerFolder); ConfigManager.Init(Loader.ConfigHandler); Universe.Init(ConfigManager.Startup_Delay_Time.Value, (Action)LateInit, (Action)Log, new UniverseLibConfig { Disable_EventSystem_Override = ConfigManager.Disable_EventSystem_Override.Value, Force_Unlock_Mouse = ConfigManager.Force_Unlock_Mouse.Value, Disable_Setup_Force_ReLoad_ManagedAssemblies = ConfigManager.Disable_Setup_Force_ReLoad_ManagedAssemblies.Value, Bypass_UniverseLib_ICall = ConfigManager.Bypass_UniverseLib_ICall.Value, Unhollowed_Modules_Folder = loader.UnhollowedModulesFolder }); UERuntimeHelper.Init(); ExplorerBehaviour.Setup(); UnityCrashPrevention.Init(); } private static void LateInit() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) SceneHandler.Init(); Log("Creating UI..."); UIManager.InitUI(); Log(string.Format("{0} {1} ({2}) initialized.", "UnityExplorer", "4.14.1", Universe.Context)); } internal static void Update() { ExplorerKeybind.Update(); } public static void Log(object message) { Log(message, (LogType)3); } public static void LogWarning(object message) { Log(message, (LogType)2); } public static void LogError(object message) { Log(message, (LogType)0); } public static void LogUnity(object message, LogType logType) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (ConfigManager.Log_Unity_Debug.Value) { Log($"[Unity] {message}", logType); } } private static void Log(object message, LogType logType) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected I4, but got Unknown string text = message?.ToString() ?? ""; LogPanel.Log(text, logType); switch ((int)logType) { case 1: case 3: Loader.OnLogMessage(text); break; case 2: Loader.OnLogWarning(text); break; case 0: case 4: Loader.OnLogError(text); break; } } private static void CheckLegacyExplorerFolder() { string text = Path.Combine(Loader.ExplorerFolderDestination, "UnityExplorer"); if (!Directory.Exists(text)) { return; } LogWarning("Attempting to migrate old 'UnityExplorer/' folder to 'sinai-dev-UnityExplorer/'..."); if (!Directory.Exists(ExplorerFolder)) { try { Directory.Move(text, ExplorerFolder); Log("Migrated successfully."); return; } catch (Exception arg) { LogWarning($"Exception migrating folder: {arg}"); return; } } try { CopyAll(new DirectoryInfo(text), new DirectoryInfo(ExplorerFolder)); Directory.Delete(text, recursive: true); Log("Migrated successfully."); } catch (Exception arg2) { LogWarning($"Exception migrating folder: {arg2}"); } } public static void CopyAll(DirectoryInfo source, DirectoryInfo target) { Directory.CreateDirectory(target.FullName); FileInfo[] files = source.GetFiles(); foreach (FileInfo fileInfo in files) { fileInfo.MoveTo(Path.Combine(target.ToString(), fileInfo.Name)); } DirectoryInfo[] directories = source.GetDirectories(); foreach (DirectoryInfo directoryInfo in directories) { DirectoryInfo target2 = target.CreateSubdirectory(directoryInfo.Name); CopyAll(directoryInfo, target2); } } } public static class ExplorerKeybind { public static void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (InputManager.GetKeyDown(ConfigManager.Master_Toggle.Value)) { UIManager.ShowMenu = !UIManager.ShowMenu; } TimeScaleKeyBindUpdate(); } private static void TimeScaleKeyBindUpdate() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) TimeScaleWidget instance = TimeScaleWidget.Instance; if (instance != null) { if (InputManager.GetKeyDown(ConfigManager.TIME_SCALE_TOGGLE.Value)) { instance.OnPauseButtonClicked(); } if (InputManager.GetKeyDown(ConfigManager.LOCK_TIME_SCALE_TO_ZERO.Value)) { instance.LockTo(0f); } if (InputManager.GetKeyDown(ConfigManager.LOCK_TIME_SCALE_TO_NORMAL.Value)) { instance.LockTo(1f); } if (InputManager.GetKeyDown(ConfigManager.LOCK_TIME_SCALE_TO_HALF.Value)) { instance.LockTo(instance.DesiredTime * 0.5f); } if (InputManager.GetKeyDown(ConfigManager.LOCK_TIME_SCALE_TO_DOUBLE.Value)) { instance.LockTo(instance.DesiredTime * 2f); } } } } public static class InspectorManager { public static readonly List Inspectors = new List(); private static InspectorBase lastActiveInspector; public static float PanelWidth; public static InspectorBase ActiveInspector { get; private set; } public static event Action OnInspectedTabsChanged; public static void Inspect(object obj, CacheObjectBase parent = null) { if (UnityHelpers.IsNullOrDestroyed(obj, true)) { return; } obj = ReflectionExtensions.TryCast(obj); if (!TryFocusActiveInspector(obj)) { if ((Object)(object)ReflectionExtensions.TryCast(obj) != (Object)null) { CreateInspector(obj); } else { CreateInspector(obj, staticReflection: false, parent); } } } public static void Inspect(Type type) { if (!TryFocusActiveInspector(type)) { CreateInspector(type, staticReflection: true); } } private static bool TryFocusActiveInspector(object target) { foreach (InspectorBase inspector in Inspectors) { bool flag = false; if (target is Type type) { if (inspector.TargetType.FullName == type.FullName) { flag = true; } } else if (ReflectionExtensions.ReferenceEqual(inspector.Target, target)) { flag = true; } if (flag) { UIManager.SetPanelActive(UIManager.Panels.Inspector, active: true); SetInspectorActive(inspector); return true; } } return false; } public static void SetInspectorActive(InspectorBase inspector) { UnsetActiveInspector(); ActiveInspector = inspector; inspector.OnSetActive(); } public static void UnsetActiveInspector() { if (ActiveInspector != null) { lastActiveInspector = ActiveInspector; ActiveInspector.OnSetInactive(); ActiveInspector = null; } } public static void CloseAllTabs() { if (Inspectors.Any()) { for (int num = Inspectors.Count - 1; num >= 0; num--) { Inspectors[num].CloseInspector(); } Inspectors.Clear(); } UIManager.SetPanelActive(UIManager.Panels.Inspector, active: false); } private static void CreateInspector(object target, bool staticReflection = false, CacheObjectBase parent = null) where T : InspectorBase { T val = Pool.Borrow(); Inspectors.Add(val); val.Target = target; if (parent != null && parent.CanWrite && target.GetType().IsValueType && val is ReflectionInspector reflectionInspector) { reflectionInspector.ParentCacheObject = parent; } UIManager.SetPanelActive(UIManager.Panels.Inspector, active: true); val.UIRoot.transform.SetParent(InspectorPanel.Instance.ContentHolder.transform, false); if (val is ReflectionInspector reflectionInspector2) { reflectionInspector2.StaticOnly = staticReflection; } val.OnBorrowedFromPool(target); SetInspectorActive(val); InspectorManager.OnInspectedTabsChanged?.Invoke(); } public static void ReleaseInspector(T inspector) where T : InspectorBase { if (lastActiveInspector == inspector) { lastActiveInspector = null; } bool num = ActiveInspector == inspector; int num2 = Inspectors.IndexOf(inspector); Inspectors.Remove(inspector); inspector.OnReturnToPool(); Pool.Return(inspector); if (num) { ActiveInspector = null; if (lastActiveInspector != null) { SetInspectorActive(lastActiveInspector); lastActiveInspector = null; } else if (Inspectors.Any()) { int index = Math.Min(Inspectors.Count - 1, Math.Max(0, num2 - 1)); SetInspectorActive(Inspectors[index]); } else { UIManager.SetPanelActive(UIManager.Panels.Inspector, active: false); } } InspectorManager.OnInspectedTabsChanged?.Invoke(); } internal static void Update() { for (int num = Inspectors.Count - 1; num >= 0; num--) { Inspectors[num].Update(); } } internal static void OnPanelResized(float width) { PanelWidth = width; foreach (InspectorBase inspector in Inspectors) { if (inspector is ReflectionInspector reflectionInspector) { reflectionInspector.SetLayouts(); } } } } [BepInPlugin("com.sinai.unityexplorer", "UnityExplorer", "4.14.1")] public class ExplorerBepInPlugin : BaseUnityPlugin, IExplorerLoader { public static ExplorerBepInPlugin Instance; private const string IL2CPP_LIBS_FOLDER = "interop"; private BepInExConfigHandler _configHandler; private static readonly Harmony s_harmony = new Harmony("com.sinai.unityexplorer"); public ManualLogSource LogSource => ((BaseUnityPlugin)this).Logger; public string UnhollowedModulesFolder => Path.Combine(Paths.BepInExRootPath, "interop"); public ConfigHandler ConfigHandler => _configHandler; public Harmony HarmonyInstance => s_harmony; public string ExplorerFolderName => "sinai-dev-UnityExplorer"; public string ExplorerFolderDestination => Paths.PluginPath; public Action OnLogMessage => LogSource.LogMessage; public Action OnLogWarning => LogSource.LogWarning; public Action OnLogError => LogSource.LogError; private void Init() { Instance = this; _configHandler = new BepInExConfigHandler(); ExplorerCore.Init(this); } internal void Awake() { Init(); } } public interface IExplorerLoader { string ExplorerFolderDestination { get; } string ExplorerFolderName { get; } string UnhollowedModulesFolder { get; } ConfigHandler ConfigHandler { get; } Action OnLogMessage { get; } Action OnLogWarning { get; } Action OnLogError { get; } } } namespace UnityExplorer.UI { public static class DisplayManager { private static Camera canvasCamera; public static int ActiveDisplayIndex { get; private set; } public static Display ActiveDisplay => Display.displays[ActiveDisplayIndex]; public static int Width => ActiveDisplay.renderingWidth; public static int Height => ActiveDisplay.renderingHeight; public static Vector3 MousePosition { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!Application.isEditor) { return Display.RelativeMouseAt(InputManager.MousePosition); } return InputManager.MousePosition; } } public static bool MouseInTargetDisplay => MousePosition.z == (float)ActiveDisplayIndex; internal static void Init() { SetDisplay(ConfigManager.Target_Display.Value); ConfigElement target_Display = ConfigManager.Target_Display; target_Display.OnValueChanged = (Action)System.Delegate.Combine(target_Display.OnValueChanged, new Action(SetDisplay)); } public static void SetDisplay(int display) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (ActiveDisplayIndex == display) { return; } if (Display.displays.Length <= display) { ExplorerCore.LogWarning($"Cannot set display index to {display} as there are not enough monitors connected!"); if (ConfigManager.Target_Display.Value == display) { ConfigManager.Target_Display.Value = 0; } return; } ActiveDisplayIndex = display; ActiveDisplay.Activate(); UIManager.UICanvas.targetDisplay = display; if (!Object.op_Implicit((Object)(object)Camera.main) || Camera.main.targetDisplay != display) { if (!Object.op_Implicit((Object)(object)canvasCamera)) { canvasCamera = new GameObject("UnityExplorer_CanvasCamera").AddComponent(); Object.DontDestroyOnLoad((Object)(object)((Component)canvasCamera).gameObject); ((Object)canvasCamera).hideFlags = (HideFlags)61; } canvasCamera.targetDisplay = display; } RuntimeHelper.StartCoroutine(FixPanels()); } private static IEnumerator FixPanels() { yield return null; yield return null; foreach (UEPanel value in UIManager.UIPanels.Values) { ((PanelBase)value).EnsureValidSize(); ((PanelBase)value).EnsureValidPosition(); ((PanelBase)value).Dragger.OnEndResize(); } } } internal class ExplorerUIBase : UIBase { public ExplorerUIBase(string id, Action updateMethod) : base(id, updateMethod) { } protected override PanelManager CreatePanelManager() { return (PanelManager)(object)new UEPanelManager((UIBase)(object)this); } } [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] public sealed class Notification { private readonly Text popupLabel; private float _timeOfLastNotification; [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] private static Notification _instance; public static void Init(GameObject parent) { if (_instance == null) { _instance = new Notification(parent); } } private Notification(GameObject parent) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) popupLabel = UIFactory.CreateLabel(parent, "ClipboardNotification", "", (TextAnchor)4, default(Color), true, 14); ((Graphic)popupLabel).rectTransform.sizeDelta = new Vector2(500f, 100f); ((Component)popupLabel).gameObject.AddComponent(); ((Component)popupLabel).gameObject.AddComponent().blocksRaycasts = false; } private void ShowMessageImp(string message) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) popupLabel.text = message; _timeOfLastNotification = Time.realtimeSinceStartup; ((Component)popupLabel).transform.localPosition = ((Transform)UIManager.UIRootRect).InverseTransformPoint(DisplayManager.MousePosition) + Vector3.up * 25f; } private void UpdateImp() { if (popupLabel.text != string.Empty && Time.realtimeSinceStartup - _timeOfLastNotification > 2f) { popupLabel.text = string.Empty; } } public static void ShowMessage(string message) { _instance?.ShowMessageImp(message); } public static void Update() { _instance?.UpdateImp(); } } public class UEPanelManager : PanelManager { protected override Vector3 MousePosition => DisplayManager.MousePosition; protected override Vector2 ScreenDimensions => new Vector2((float)DisplayManager.Width, (float)DisplayManager.Height); protected override bool MouseInTargetDisplay => DisplayManager.MouseInTargetDisplay; public UEPanelManager(UIBase owner) : base(owner) { } internal void DoInvokeOnPanelsReordered() { ((PanelManager)this).InvokeOnPanelsReordered(); } protected override void SortDraggerHeirarchy() { ((PanelManager)this).SortDraggerHeirarchy(); if (!UIManager.Initializing && AutoCompleteModal.Instance != null) { base.draggerInstances.Remove(((PanelBase)AutoCompleteModal.Instance).Dragger); base.draggerInstances.Insert(0, ((PanelBase)AutoCompleteModal.Instance).Dragger); } } } public static class UIManager { public enum Panels { ObjectExplorer, Inspector, CSConsole, Options, ConsoleLog, AutoCompleter, UIInspectorResults, HookManager, Clipboard, Freecam } public enum VerticalAnchor { Top, Bottom } public static VerticalAnchor NavbarAnchor = VerticalAnchor.Top; internal static readonly Dictionary UIPanels = new Dictionary(); public static RectTransform NavBarRect; public static GameObject NavbarTabButtonHolder; private static readonly Vector2 NAVBAR_DIMENSIONS = new Vector2(1020f, 35f); private static ButtonRef closeBtn; private static int lastScreenWidth; private static int lastScreenHeight; public static bool Initializing { get; internal set; } = true; internal static UIBase UiBase { get; private set; } public static GameObject UIRoot { get { UIBase uiBase = UiBase; if (uiBase == null) { return null; } return uiBase.RootObject; } } public static RectTransform UIRootRect { get; private set; } public static Canvas UICanvas { get; private set; } public static bool ShowMenu { get { if (UiBase != null) { return UiBase.Enabled; } return false; } set { if (UiBase != null && Object.op_Implicit((Object)(object)UIRoot) && UiBase.Enabled != value) { UniversalUI.SetUIActive("com.sinai.unityexplorer", value); UniversalUI.SetUIActive(MouseInspector.UIBaseGUID, value); } } } internal static void InitUI() { UiBase = (UIBase)(object)UniversalUI.RegisterUI("com.sinai.unityexplorer", (Action)Update); UIRootRect = UIRoot.GetComponent(); UICanvas = UIRoot.GetComponent(); DisplayManager.Init(); Display activeDisplay = DisplayManager.ActiveDisplay; lastScreenWidth = activeDisplay.renderingWidth; lastScreenHeight = activeDisplay.renderingHeight; CreateTopNavBar(); UIPanels.Add(Panels.AutoCompleter, new AutoCompleteModal(UiBase)); UIPanels.Add(Panels.ObjectExplorer, new ObjectExplorerPanel(UiBase)); UIPanels.Add(Panels.Inspector, new InspectorPanel(UiBase)); UIPanels.Add(Panels.CSConsole, new CSConsolePanel(UiBase)); UIPanels.Add(Panels.HookManager, new HookManagerPanel(UiBase)); UIPanels.Add(Panels.Freecam, new FreeCamPanel(UiBase)); UIPanels.Add(Panels.Clipboard, new ClipboardPanel(UiBase)); UIPanels.Add(Panels.ConsoleLog, new LogPanel(UiBase)); UIPanels.Add(Panels.Options, new OptionsPanel(UiBase)); UIPanels.Add(Panels.UIInspectorResults, new MouseInspectorResultsPanel(UiBase)); MouseInspector.inspectorUIBase = UniversalUI.RegisterUI(MouseInspector.UIBaseGUID, (Action)null); new MouseInspector(MouseInspector.inspectorUIBase); Notification.Init(UIRoot); ConsoleController.Init(); Dropdown[] componentsInChildren = UIRoot.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].RefreshShownValue(); } Initializing = false; if (ConfigManager.Hide_On_Startup.Value) { ShowMenu = false; } } public static void Update() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)UIRoot) && !MouseInspector.Instance.TryUpdate()) { Notification.Update(); if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value)) { ConfigManager.Force_Unlock_Mouse = !ConfigManager.Force_Unlock_Mouse; } TimeScaleWidget.Instance?.Update(); Display activeDisplay = DisplayManager.ActiveDisplay; if (activeDisplay.renderingWidth != lastScreenWidth || activeDisplay.renderingHeight != lastScreenHeight) { OnScreenDimensionsChanged(); } } } public static UEPanel GetPanel(Panels panel) { return UIPanels[panel]; } public static T GetPanel(Panels panel) where T : UEPanel { return (T)UIPanels[panel]; } public static void TogglePanel(Panels panel) { UEPanel panel2 = GetPanel(panel); SetPanelActive(panel, !((UIModel)panel2).Enabled); } public static void SetPanelActive(Panels panelType, bool active) { ((UIModel)GetPanel(panelType)).SetActive(active); } public static void SetPanelActive(UEPanel panel, bool active) { ((UIModel)panel).SetActive(active); } public static void SetNavBarAnchor() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) switch (NavbarAnchor) { case VerticalAnchor.Top: NavBarRect.anchorMin = new Vector2(0.5f, 1f); NavBarRect.anchorMax = new Vector2(0.5f, 1f); NavBarRect.anchoredPosition = new Vector2(NavBarRect.anchoredPosition.x, 0f); NavBarRect.sizeDelta = NAVBAR_DIMENSIONS; break; case VerticalAnchor.Bottom: NavBarRect.anchorMin = new Vector2(0.5f, 0f); NavBarRect.anchorMax = new Vector2(0.5f, 0f); NavBarRect.anchoredPosition = new Vector2(NavBarRect.anchoredPosition.x, 35f); NavBarRect.sizeDelta = NAVBAR_DIMENSIONS; break; } } private static void OnScreenDimensionsChanged() { Display activeDisplay = DisplayManager.ActiveDisplay; lastScreenWidth = activeDisplay.renderingWidth; lastScreenHeight = activeDisplay.renderingHeight; foreach (KeyValuePair uIPanel in UIPanels) { ((PanelBase)uIPanel.Value).EnsureValidSize(); ((PanelBase)uIPanel.Value).EnsureValidPosition(); ((PanelBase)uIPanel.Value).Dragger.OnEndResize(); } } private static void OnCloseButtonClicked() { ShowMenu = false; } private unsafe static void Master_Toggle_OnValueChanged(KeyCode val) { closeBtn.ButtonText.text = ((object)(*(KeyCode*)(&val))/*cast due to .constrained prefix*/).ToString(); } private static void CreateTopNavBar() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateUIObject("MainNavbar", UIRoot, default(Vector2)); UIFactory.SetLayoutGroup(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)4, (int?)4, (int?)4, (int?)4, (TextAnchor?)(TextAnchor)4); ((Graphic)val.AddComponent()).color = new Color(0.1f, 0.1f, 0.1f); NavBarRect = val.GetComponent(); NavBarRect.pivot = new Vector2(0.5f, 1f); NavbarAnchor = ConfigManager.Main_Navbar_Anchor.Value; SetNavBarAnchor(); ConfigElement main_Navbar_Anchor = ConfigManager.Main_Navbar_Anchor; main_Navbar_Anchor.OnValueChanged = (Action)System.Delegate.Combine(main_Navbar_Anchor.OnValueChanged, (Action)delegate(VerticalAnchor navbarAnchor) { NavbarAnchor = navbarAnchor; SetNavBarAnchor(); }); string text = "UE 4.14.1"; GameObject gameObject = ((Component)UIFactory.CreateLabel(val, "Title", text, (TextAnchor)4, default(Color), true, 14)).gameObject; int? num = 75; int? num2 = 0; UIFactory.SetLayoutElement(gameObject, num, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); NavbarTabButtonHolder = UIFactory.CreateUIObject("NavTabButtonHolder", val, default(Vector2)); GameObject navbarTabButtonHolder = NavbarTabButtonHolder; num2 = 25; int? num3 = 999; int? num4 = 999; UIFactory.SetLayoutElement(navbarTabButtonHolder, (int?)null, num2, num4, num3, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(NavbarTabButtonHolder, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)4, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null); TimeScaleWidget.SetUp(val); UIFactory.SetLayoutElement(UIFactory.CreateUIObject("Spacer", val, default(Vector2)), (int?)15, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); closeBtn = UIFactory.CreateButton(val, "CloseButton", ((object)ConfigManager.Master_Toggle.Value/*cast due to .constrained prefix*/).ToString(), (Color?)null); GameObject gameObject2 = ((Component)closeBtn.Component).gameObject; num4 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)60, num4, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); RuntimeHelper.SetColorBlock((Selectable)(object)closeBtn.Component, (Color?)new Color(0.63f, 0.32f, 0.31f), (Color?)new Color(0.81f, 0.25f, 0.2f), (Color?)new Color(0.6f, 0.18f, 0.16f), (Color?)null); ConfigElement master_Toggle = ConfigManager.Master_Toggle; master_Toggle.OnValueChanged = (Action)System.Delegate.Combine(master_Toggle.OnValueChanged, new Action(Master_Toggle_OnValueChanged)); ButtonRef obj = closeBtn; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnCloseButtonClicked)); } } } namespace UnityExplorer.UI.Widgets { public abstract class BaseArgumentHandler : IPooledObject { internal Text argNameLabel; internal InputFieldRef inputField; internal TypeCompleter typeCompleter; public float DefaultHeight => 25f; public GameObject UIRoot { get; set; } public abstract void CreateSpecialContent(); public GameObject CreateContent(GameObject parent) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject("ArgRow", parent, default(Vector2)); GameObject uIRoot = UIRoot; int? num = 25; int? num2 = 50; UIFactory.SetLayoutElement(uIRoot, (int?)50, num, (int?)9999, num2, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(UIRoot, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); UIRoot.AddComponent().verticalFit = (FitMode)2; argNameLabel = UIFactory.CreateLabel(UIRoot, "ArgLabel", "not set", (TextAnchor)3, default(Color), true, 14); GameObject gameObject = ((Component)argNameLabel).gameObject; int? num3 = 40; num2 = 90; UIFactory.SetLayoutElement(gameObject, num3, (int?)25, num2, (int?)50, (int?)null, (int?)null, (bool?)null); argNameLabel.horizontalOverflow = (HorizontalWrapMode)0; inputField = UIFactory.CreateInputField(UIRoot, "InputField", "..."); GameObject uIRoot2 = ((UIModel)inputField).UIRoot; num2 = 25; num = 50; UIFactory.SetLayoutElement(uIRoot2, (int?)100, num2, (int?)1000, num, (int?)null, (int?)null, (bool?)null); inputField.Component.lineType = (LineType)2; ((UIModel)inputField).UIRoot.AddComponent().verticalFit = (FitMode)2; typeCompleter = new TypeCompleter(typeof(object), inputField) { Enabled = false }; CreateSpecialContent(); return UIRoot; } } public class EvaluateWidget : IPooledObject { private ParameterInfo[] parameters; internal GameObject parametersHolder; private ParameterHandler[] paramHandlers; private Type[] genericArguments; internal GameObject genericArgumentsHolder; private GenericArgumentHandler[] genericHandlers; public CacheMember Owner { get; set; } public GameObject UIRoot { get; set; } public float DefaultHeight => -1f; public void OnBorrowedFromPool(CacheMember owner) { Owner = owner; parameters = owner.Arguments; paramHandlers = new ParameterHandler[parameters.Length]; genericArguments = owner.GenericArguments; genericHandlers = new GenericArgumentHandler[genericArguments.Length]; SetArgRows(); UIRoot.SetActive(true); } public void OnReturnToPool() { ParameterHandler[] array = paramHandlers; foreach (ParameterHandler obj in array) { obj.OnReturned(); Pool.Return(obj); } paramHandlers = null; GenericArgumentHandler[] array2 = genericHandlers; foreach (GenericArgumentHandler obj2 in array2) { obj2.OnReturned(); Pool.Return(obj2); } genericHandlers = null; Owner = null; } public Type[] TryParseGenericArguments() { Type[] array = new Type[genericArguments.Length]; for (int i = 0; i < genericArguments.Length; i++) { array[i] = genericHandlers[i].Evaluate(); } return array; } public object[] TryParseArguments() { if (!parameters.Any()) { return ArgumentUtility.EmptyArgs; } object[] array = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { array[i] = paramHandlers[i].Evaluate(); } return array; } private void SetArgRows() { if (genericArguments.Any()) { genericArgumentsHolder.SetActive(true); SetGenericRows(); } else { genericArgumentsHolder.SetActive(false); } if (parameters.Any()) { parametersHolder.SetActive(true); SetNormalArgRows(); } else { parametersHolder.SetActive(false); } } private void SetGenericRows() { for (int i = 0; i < genericArguments.Length; i++) { Type genericArgument = genericArguments[i]; GenericArgumentHandler obj = (genericHandlers[i] = Pool.Borrow()); obj.UIRoot.transform.SetParent(genericArgumentsHolder.transform, false); obj.OnBorrowed(genericArgument); } } private void SetNormalArgRows() { for (int i = 0; i < parameters.Length; i++) { ParameterInfo paramInfo = parameters[i]; ParameterHandler obj = (paramHandlers[i] = Pool.Borrow()); obj.UIRoot.transform.SetParent(parametersHolder.transform, false); obj.OnBorrowed(paramInfo); } } public GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateVerticalGroup(parent, "EvaluateWidget", false, false, true, true, 3, new Vector4(2f, 2f, 2f, 2f), new Color(0.15f, 0.15f, 0.15f), (TextAnchor?)null); GameObject uIRoot = UIRoot; int? num = 50; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot, num, (int?)50, num2, (int?)800, (int?)null, (int?)null, (bool?)null); genericArgumentsHolder = UIFactory.CreateUIObject("GenericHolder", UIRoot, default(Vector2)); GameObject obj = genericArgumentsHolder; num2 = 1000; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(genericArgumentsHolder, "GenericsTitle", "Generic Arguments", (TextAnchor)3, default(Color), true, 14)).gameObject; num2 = 25; int? num3 = 1000; UIFactory.SetLayoutElement(gameObject, (int?)null, num2, num3, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(genericArgumentsHolder, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)3, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject obj2 = genericArgumentsHolder; num3 = 25; num2 = 750; UIFactory.SetLayoutElement(obj2, (int?)50, num3, (int?)9999, num2, (int?)null, (int?)null, (bool?)null); parametersHolder = UIFactory.CreateUIObject("ArgHolder", UIRoot, default(Vector2)); GameObject obj3 = parametersHolder; num2 = 1000; UIFactory.SetLayoutElement(obj3, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject2 = ((Component)UIFactory.CreateLabel(parametersHolder, "ArgsTitle", "Arguments", (TextAnchor)3, default(Color), true, 14)).gameObject; num2 = 25; num3 = 1000; UIFactory.SetLayoutElement(gameObject2, (int?)null, num2, num3, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(parametersHolder, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)3, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject obj4 = parametersHolder; num3 = 25; num2 = 750; UIFactory.SetLayoutElement(obj4, (int?)50, num3, (int?)9999, num2, (int?)null, (int?)null, (bool?)null); ButtonRef obj5 = UIFactory.CreateButton(UIRoot, "EvaluateButton", "Evaluate", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject3 = ((Component)obj5.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)150, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj5.OnClick = (Action)System.Delegate.Combine(obj5.OnClick, (Action)delegate { Owner.EvaluateAndSetCell(); }); return UIRoot; } } public class GenericArgumentHandler : BaseArgumentHandler { private Type genericArgument; public void OnBorrowed(Type genericArgument) { this.genericArgument = genericArgument; typeCompleter.Enabled = true; typeCompleter.BaseType = this.genericArgument; typeCompleter.CacheTypes(); Type[] genericParameterConstraints = this.genericArgument.GetGenericParameterConstraints(); StringBuilder stringBuilder = new StringBuilder("" + this.genericArgument.Name + ""); for (int i = 0; i < genericParameterConstraints.Length; i++) { if (i == 0) { stringBuilder.Append(' ').Append('('); } else { stringBuilder.Append(',').Append(' '); } stringBuilder.Append(SignatureHighlighter.Parse(genericParameterConstraints[i], false, (MemberInfo)null)); if (i + 1 == genericParameterConstraints.Length) { stringBuilder.Append(')'); } } argNameLabel.text = stringBuilder.ToString(); } public void OnReturned() { genericArgument = null; typeCompleter.Enabled = false; inputField.Text = ""; } public Type Evaluate() { return ReflectionUtility.GetTypeByName(inputField.Text) ?? throw new Exception("Could not find any type by name '" + inputField.Text + "'!"); } public override void CreateSpecialContent() { } } public class GenericConstructorWidget { private GenericArgumentHandler[] handlers; private Type[] currentGenericParameters; private Action currentOnSubmit; private Action currentOnCancel; public GameObject UIRoot; private Text Title; private GameObject ArgsHolder; public void Show(Action onSubmit, Action onCancel, Type genericTypeDefinition) { Title.text = "Setting generic arguments for " + SignatureHighlighter.Parse(genericTypeDefinition, false, (MemberInfo)null) + "..."; OnShow(onSubmit, onCancel, genericTypeDefinition.GetGenericArguments()); } public void Show(Action onSubmit, Action onCancel, MethodInfo genericMethodDefinition) { Title.text = "Setting generic arguments for " + SignatureHighlighter.ParseMethod(genericMethodDefinition) + "..."; OnShow(onSubmit, onCancel, genericMethodDefinition.GetGenericArguments()); } private void OnShow(Action onSubmit, Action onCancel, Type[] genericParameters) { currentOnSubmit = onSubmit; currentOnCancel = onCancel; SetGenericParameters(genericParameters); } private void SetGenericParameters(Type[] genericParameters) { currentGenericParameters = genericParameters; handlers = new GenericArgumentHandler[genericParameters.Length]; for (int i = 0; i < genericParameters.Length; i++) { Type genericArgument = genericParameters[i]; GenericArgumentHandler obj = (handlers[i] = Pool.Borrow()); obj.UIRoot.transform.SetParent(ArgsHolder.transform, false); obj.OnBorrowed(genericArgument); } } public void TrySubmit() { Type[] array = new Type[currentGenericParameters.Length]; for (int i = 0; i < array.Length; i++) { GenericArgumentHandler genericArgumentHandler = handlers[i]; Type type; try { type = genericArgumentHandler.Evaluate(); if (type == null) { throw new Exception(); } } catch { ExplorerCore.LogWarning("Generic argument '" + genericArgumentHandler.inputField.Text + "' is not a valid type."); return; } array[i] = type; } OnClose(); currentOnSubmit(array); } public void Cancel() { OnClose(); currentOnCancel?.Invoke(); } private void OnClose() { if (handlers != null) { GenericArgumentHandler[] array = handlers; foreach (GenericArgumentHandler obj in array) { obj.OnReturned(); Pool.Return(obj); } handlers = null; } } internal void ConstructUI(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) Vector4 val = new Vector4(5f, 5f, 5f, 5f); TextAnchor? val2 = (TextAnchor)4; UIRoot = UIFactory.CreateVerticalGroup(parent, "GenericArgsHandler", false, false, true, true, 5, val, default(Color), val2); GameObject uIRoot = UIRoot; int? num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); ButtonRef obj = UIFactory.CreateButton(UIRoot, "SubmitButton", "Submit", (Color?)new Color(0.2f, 0.3f, 0.2f)); GameObject gameObject = obj.GameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)200, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(TrySubmit)); ButtonRef obj2 = UIFactory.CreateButton(UIRoot, "CancelButton", "Cancel", (Color?)new Color(0.3f, 0.2f, 0.2f)); GameObject gameObject2 = obj2.GameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)200, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, new Action(Cancel)); Title = UIFactory.CreateLabel(UIRoot, "Title", "Generic Arguments", (TextAnchor)4, default(Color), true, 14); GameObject gameObject3 = ((Component)Title).gameObject; num2 = 25; num = 9999; UIFactory.SetLayoutElement(gameObject3, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); AutoSliderScrollbar val3 = default(AutoSliderScrollbar); GameObject obj3 = UIFactory.CreateScrollView(UIRoot, "GenericArgsScrollView", ref ArgsHolder, ref val3, new Color(0.1f, 0.1f, 0.1f)); num = 9999; num2 = 9999; UIFactory.SetLayoutElement(obj3, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); GameObject argsHolder = ArgsHolder; num2 = 5; num = 5; int? num3 = 5; int? num4 = 5; UIFactory.SetLayoutGroup(argsHolder, (bool?)null, (bool?)null, (bool?)null, (bool?)null, (int?)null, num2, num3, num, num4, (TextAnchor?)null); } } public class ParameterHandler : BaseArgumentHandler { private ParameterInfo paramInfo; private Type paramType; internal EnumCompleter enumCompleter; private ButtonRef enumHelperButton; private bool usingBasicLabel; private object basicValue; private GameObject basicLabelHolder; private Text basicLabel; private ButtonRef pasteButton; public void OnBorrowed(ParameterInfo paramInfo) { this.paramInfo = paramInfo; paramType = paramInfo.ParameterType; if (paramType.IsByRef) { paramType = paramType.GetElementType(); } argNameLabel.text = SignatureHighlighter.Parse(paramType, false, (MemberInfo)null) + " " + paramInfo.Name + ""; if (ParseUtility.CanParse(paramType) || typeof(Type).IsAssignableFrom(paramType)) { usingBasicLabel = false; ((Component)inputField.Component).gameObject.SetActive(true); basicLabelHolder.SetActive(false); typeCompleter.Enabled = typeof(Type).IsAssignableFrom(paramType); enumCompleter.Enabled = paramType.IsEnum; ((Component)enumHelperButton.Component).gameObject.SetActive(paramType.IsEnum); if (!typeCompleter.Enabled) { if (paramType == typeof(string)) { inputField.PlaceholderText.text = "..."; } else { inputField.PlaceholderText.text = "eg. " + ParseUtility.GetExampleInput(paramType); } } else { inputField.PlaceholderText.text = "Enter a Type name..."; typeCompleter.BaseType = typeof(object); typeCompleter.CacheTypes(); } if (enumCompleter.Enabled) { enumCompleter.EnumType = paramType; enumCompleter.CacheEnumValues(); } } else { usingBasicLabel = true; ((Component)inputField.Component).gameObject.SetActive(false); basicLabelHolder.SetActive(true); typeCompleter.Enabled = false; enumCompleter.Enabled = false; ((Component)enumHelperButton.Component).gameObject.SetActive(false); SetDisplayedValueFromPaste(); } } public void OnReturned() { paramInfo = null; enumCompleter.Enabled = false; typeCompleter.Enabled = false; inputField.Text = ""; usingBasicLabel = false; basicValue = null; } public object Evaluate() { if (usingBasicLabel) { return basicValue; } string text = inputField.Text; if (typeof(Type).IsAssignableFrom(paramType)) { return ReflectionUtility.GetTypeByName(text); } if (paramType == typeof(string)) { return text; } if (string.IsNullOrEmpty(text)) { if (paramInfo.IsOptional) { return paramInfo.DefaultValue; } return null; } object result = default(object); Exception ex = default(Exception); if (!ParseUtility.TryParse(text, paramType, ref result, ref ex)) { ExplorerCore.LogWarning("Cannot parse argument '" + paramInfo.Name + "' (" + paramInfo.ParameterType.Name + ")" + ((ex == null) ? "" : (", " + ex.GetType().Name + ": " + ex.Message))); return null; } return result; } private void OnPasteClicked() { if (ClipboardPanel.TryPaste(paramType, out var paste)) { basicValue = paste; SetDisplayedValueFromPaste(); } } private void SetDisplayedValueFromPaste() { if (usingBasicLabel) { basicLabel.text = ToStringUtility.ToStringWithType(basicValue, paramType, false); } else if (typeof(Type).IsAssignableFrom(paramType)) { inputField.Text = GeneralExtensions.FullDescription(basicValue as Type); } else { inputField.Text = ParseUtility.ToStringForInput(basicValue, paramType); } } public override void CreateSpecialContent() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) enumCompleter = new EnumCompleter(paramType, inputField) { Enabled = false }; enumHelperButton = UIFactory.CreateButton(base.UIRoot, "EnumHelper", "▼", (Color?)null); UIFactory.SetLayoutElement(((Component)enumHelperButton.Component).gameObject, (int?)25, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef obj = enumHelperButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(enumCompleter.HelperButtonClicked)); GameObject uIRoot = base.UIRoot; Color val = default(Color); ((Color)(ref val))..ctor(0.1f, 0.1f, 0.1f); basicLabelHolder = UIFactory.CreateHorizontalGroup(uIRoot, "BasicLabelHolder", true, true, true, true, 0, default(Vector4), val, (TextAnchor?)null); GameObject obj2 = basicLabelHolder; int? num = 25; int? num2 = 50; UIFactory.SetLayoutElement(obj2, (int?)100, num, (int?)1000, num2, (int?)null, (int?)null, (bool?)null); GameObject obj3 = basicLabelHolder; val = default(Color); basicLabel = UIFactory.CreateLabel(obj3, "BasicLabel", "null", (TextAnchor)3, val, true, 14); ((Component)basicLabel).gameObject.AddComponent().verticalFit = (FitMode)2; pasteButton = UIFactory.CreateButton(base.UIRoot, "PasteButton", "Paste", (Color?)new Color(0.13f, 0.13f, 0.13f, 1f)); GameObject gameObject = ((Component)pasteButton.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)28, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)pasteButton.ButtonText).color = Color.green; pasteButton.ButtonText.fontSize = 10; ButtonRef obj4 = pasteButton; obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, new Action(OnPasteClicked)); } } public class AxisControl { public readonly Vector3Control parent; public readonly int axis; public readonly Slider slider; public AxisControl(int axis, Slider slider, Vector3Control parentControl) { parent = parentControl; this.axis = axis; this.slider = slider; } private void OnVectorSliderChanged(float value) { parent.Owner.CurrentSlidingAxisControl = ((value == 0f) ? null : this); } private void OnVectorMinusClicked() { parent.Owner.AxisControlOperation(0f - parent.Increment, parent, axis); } private void OnVectorPlusClicked() { parent.Owner.AxisControlOperation(parent.Increment, parent, axis); } public static AxisControl Create(GameObject parent, string title, int axis, Vector3Control owner) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)UIFactory.CreateLabel(parent, "Label_" + title, title + ":", (TextAnchor)5, Color.grey, true, 14)).gameObject; int? num = 25; UIFactory.SetLayoutElement(gameObject, (int?)30, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); Slider val = default(Slider); GameObject obj = UIFactory.CreateSlider(parent, "Slider_" + title, ref val); num = 25; UIFactory.SetLayoutElement(obj, (int?)75, num, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); Image val2 = (Image)typeof(Slider).GetField("m_FillImage", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val); if ((Object)(object)val2 != (Object)null) { ((Graphic)val2).color = Color.clear; } val.minValue = -0.1f; val.maxValue = 0.1f; AxisControl axisControl = new AxisControl(axis, val, owner); ((UnityEvent)(object)val.onValueChanged).AddListener((UnityAction)axisControl.OnVectorSliderChanged); ButtonRef obj2 = UIFactory.CreateButton(parent, "MinusIncrementButton", "-", (Color?)null); GameObject gameObject2 = obj2.GameObject; int? num2 = 20; num = 0; UIFactory.SetLayoutElement(gameObject2, num2, (int?)25, num, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, new Action(axisControl.OnVectorMinusClicked)); ButtonRef obj3 = UIFactory.CreateButton(parent, "PlusIncrementButton", "+", (Color?)null); GameObject gameObject3 = obj3.GameObject; int? num3 = 20; num = 0; UIFactory.SetLayoutElement(gameObject3, num3, (int?)25, num, (int?)null, (int?)null, (int?)null, (bool?)null); obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(axisControl.OnVectorPlusClicked)); return axisControl; } } public class ComponentCell : ButtonCell { public Toggle BehaviourToggle; public ButtonRef DestroyButton; public Action OnBehaviourToggled; public Action OnDestroyClicked; private void BehaviourToggled(bool val) { OnBehaviourToggled?.Invoke(val, ((ButtonCell)this).CurrentDataIndex); } private void DestroyClicked() { OnDestroyClicked?.Invoke(((ButtonCell)this).CurrentDataIndex); } public override GameObject CreateContent(GameObject parent) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) GameObject result = ((ButtonCell)this).CreateContent(parent); ((ButtonCell)this).Button.ButtonText.horizontalOverflow = (HorizontalWrapMode)0; Text val = default(Text); GameObject obj = UIFactory.CreateToggle(((ButtonCell)this).UIRoot, "BehaviourToggle", ref BehaviourToggle, ref val, default(Color), 20, 20); int? num = 25; UIFactory.SetLayoutElement(obj, (int?)25, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ((UnityEvent)(object)BehaviourToggle.onValueChanged).AddListener((UnityAction)BehaviourToggled); obj.transform.SetSiblingIndex(0); DestroyButton = UIFactory.CreateButton(((ButtonCell)this).UIRoot, "DestroyButton", "X", (Color?)new Color(0.3f, 0.2f, 0.2f)); GameObject gameObject = ((Component)DestroyButton.Component).gameObject; num = 21; UIFactory.SetLayoutElement(gameObject, (int?)25, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef destroyButton = DestroyButton; destroyButton.OnClick = (Action)System.Delegate.Combine(destroyButton.OnClick, new Action(DestroyClicked)); return result; } } public class ComponentList : ButtonListHandler { public GameObjectInspector Parent; private static readonly Dictionary compToStringCache = new Dictionary(); public ComponentList(ScrollPool scrollPool, Func> getEntriesMethod) : base(scrollPool, getEntriesMethod, (Action)null, (Func)null, (Action)null) { base.SetICell = SetComponentCell; base.ShouldDisplay = CheckShouldDisplay; base.OnCellClicked = OnComponentClicked; } public void Clear() { base.RefreshData(); base.ScrollPool.Refresh(true, true); } private bool CheckShouldDisplay(Component _, string __) { return true; } public override void OnCellBorrowed(ComponentCell cell) { base.OnCellBorrowed(cell); cell.OnBehaviourToggled = (Action)System.Delegate.Combine(cell.OnBehaviourToggled, new Action(OnBehaviourToggled)); cell.OnDestroyClicked = (Action)System.Delegate.Combine(cell.OnDestroyClicked, new Action(OnDestroyClicked)); } public override void SetCell(ComponentCell cell, int index) { base.SetCell(cell, index); } private void OnComponentClicked(int index) { List list = base.GetEntries(); if (index >= 0 && index < list.Count) { Component val = list[index]; if (Object.op_Implicit((Object)(object)val)) { InspectorManager.Inspect(val); } } } private void OnBehaviourToggled(bool value, int index) { try { Behaviour val = ReflectionExtensions.TryCast((object)base.GetEntries()[index]); if (val != null) { val.enabled = value; } } catch (Exception ex) { ExplorerCore.LogWarning("Exception toggling Behaviour.enabled: " + ReflectionExtensions.ReflectionExToString(ex, true)); } } private void OnDestroyClicked(int index) { try { Object.DestroyImmediate((Object)(object)base.GetEntries()[index]); Parent.UpdateComponents(); } catch (Exception ex) { ExplorerCore.LogWarning("Exception destroying Component: " + ReflectionExtensions.ReflectionExToString(ex, true)); } } private void SetComponentCell(ComponentCell cell, int index) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) List list = base.GetEntries(); ((ButtonCell)cell).Enable(); Component val = list[index]; Type actualType = ReflectionExtensions.GetActualType((object)val); if (!compToStringCache.ContainsKey(actualType.AssemblyQualifiedName)) { compToStringCache.Add(actualType.AssemblyQualifiedName, SignatureHighlighter.Parse(actualType, true, (MemberInfo)null)); } ((ButtonCell)cell).Button.ButtonText.text = compToStringCache[actualType.AssemblyQualifiedName]; if (typeof(Behaviour).IsAssignableFrom(actualType)) { ((Selectable)cell.BehaviourToggle).interactable = true; cell.BehaviourToggle.SetIsOnWithoutNotify(ReflectionExtensions.TryCast((object)val).enabled); cell.BehaviourToggle.graphic.color = new Color(0.8f, 1f, 0.8f, 0.3f); } else { ((Selectable)cell.BehaviourToggle).interactable = false; cell.BehaviourToggle.SetIsOnWithoutNotify(true); cell.BehaviourToggle.graphic.color = new Color(0.2f, 0.2f, 0.2f); } if (index == 0 && ((Component)cell.DestroyButton.Component).gameObject.activeSelf) { ((Component)cell.DestroyButton.Component).gameObject.SetActive(false); } else if (index > 0 && !((Component)cell.DestroyButton.Component).gameObject.activeSelf) { ((Component)cell.DestroyButton.Component).gameObject.SetActive(true); } } } public class GameObjectControls { public GameObjectInspector Parent { get; } public GameObject Target => Parent.Target; public GameObjectInfoPanel GameObjectInfo { get; } public TransformControls TransformControl { get; } public GameObjectControls(GameObjectInspector parent) { Parent = parent; GameObjectInfo = new GameObjectInfoPanel(this); TransformControl = new TransformControls(this); } public void UpdateGameObjectInfo(bool firstUpdate, bool force) { GameObjectInfo.UpdateGameObjectInfo(firstUpdate, force); } public void UpdateVectorSlider() { TransformControl.UpdateVectorSlider(); } } public class GameObjectInfoPanel { private string lastGoName; private string lastPath; private bool lastParentState; private int lastSceneHandle; private string lastTag; private int lastLayer; private int lastFlags; private ButtonRef ViewParentButton; private InputFieldRef PathInput; private InputFieldRef NameInput; private Toggle ActiveSelfToggle; private Text ActiveSelfText; private Toggle IsStaticToggle; private ButtonRef SceneButton; private InputFieldRef InstanceIDInput; private InputFieldRef TagInput; private Dropdown LayerDropdown; private Dropdown FlagsDropdown; private static List layerToNames; private static Dictionary hideFlagsValues; public GameObjectControls Owner { get; } private GameObject Target => Owner.Target; public GameObjectInfoPanel(GameObjectControls owner) { Owner = owner; Create(); } public void UpdateGameObjectInfo(bool firstUpdate, bool force) { //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Expected I4, but got Unknown //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Invalid comparison between Unknown and I4 if (firstUpdate) { InstanceIDInput.Text = ((Object)Target).GetInstanceID().ToString(); } if (force || (!NameInput.Component.isFocused && ((Object)Target).name != lastGoName)) { lastGoName = ((Object)Target).name; Owner.Parent.Tab.TabText.text = "[G] " + ((Object)Target).name; NameInput.Text = ((Object)Target).name; } if (force || !PathInput.Component.isFocused) { string transformPath = UnityHelpers.GetTransformPath(Target.transform, false); if (transformPath != lastPath) { lastPath = transformPath; PathInput.Text = transformPath; } } if (force || Object.op_Implicit((Object)(object)Target.transform.parent) != lastParentState) { lastParentState = Object.op_Implicit((Object)(object)Target.transform.parent); ((Selectable)ViewParentButton.Component).interactable = lastParentState; if (lastParentState) { ((Graphic)ViewParentButton.ButtonText).color = Color.white; ViewParentButton.ButtonText.text = "◄ View Parent"; } else { ((Graphic)ViewParentButton.ButtonText).color = Color.grey; ViewParentButton.ButtonText.text = "No parent"; } } if (force || Target.activeSelf != ActiveSelfToggle.isOn) { ActiveSelfToggle.SetIsOnWithoutNotify(Target.activeSelf); ((Graphic)ActiveSelfText).color = (ActiveSelfToggle.isOn ? Color.green : Color.red); } if (force || Target.isStatic != IsStaticToggle.isOn) { IsStaticToggle.SetIsOnWithoutNotify(Target.isStatic); } Scene scene; if (!force) { scene = Target.scene; if (!(((Scene)(ref scene)).handle != SceneHandle.op_Implicit(lastSceneHandle))) { goto IL_02a9; } } scene = Target.scene; lastSceneHandle = SceneHandle.op_Implicit(((Scene)(ref scene)).handle); Text buttonText = SceneButton.ButtonText; scene = Target.scene; object text; if (!((Scene)(ref scene)).IsValid()) { text = "None (Asset/Resource)"; } else { scene = Target.scene; text = ((Scene)(ref scene)).name; } buttonText.text = (string)text; goto IL_02a9; IL_02a9: if (force || (!TagInput.Component.isFocused && Target.tag != lastTag)) { lastTag = Target.tag; TagInput.Text = lastTag; } if (force || Target.layer != lastLayer) { lastLayer = Target.layer; LayerDropdown.value = Target.layer; } if (force || (int)((Object)Target).hideFlags != lastFlags) { lastFlags = (int)((Object)Target).hideFlags; FlagsDropdown.captionText.text = ((object)((Object)Target).hideFlags/*cast due to .constrained prefix*/).ToString(); } } private void DoSetParent(Transform transform) { ExplorerCore.Log("Setting target's transform parent to: " + (((Object)(object)transform == (Object)null) ? "null" : ("'" + ((Object)transform).name + "'"))); if (Object.op_Implicit((Object)(object)Target.GetComponent())) { Target.transform.SetParent(transform, false); } else { Target.transform.parent = transform; } UpdateGameObjectInfo(firstUpdate: false, force: false); Owner.TransformControl.UpdateTransformControlValues(force: false); } private void OnViewParentClicked() { if (Object.op_Implicit((Object)(object)Target) && Object.op_Implicit((Object)(object)Target.transform.parent)) { Owner.Parent.OnTransformCellClicked(((Component)Target.transform.parent).gameObject); } } private void OnPathEndEdit(string input) { lastPath = input; if (string.IsNullOrEmpty(input)) { DoSetParent(null); return; } Transform val = null; if (input.EndsWith("/")) { input = input.Remove(input.Length - 1); } GameObject val2 = GameObject.Find(input); if (val2 != null) { val = val2.transform; } else { string text = input.Split(new char[1] { '/' }).Last(); Object[] array = RuntimeHelper.FindObjectsOfTypeAll(typeof(GameObject)); List list = new List(); Object[] array2 = array; foreach (Object val3 in array2) { if (val3.name == text) { list.Add(ReflectionExtensions.TryCast((object)val3)); } } foreach (GameObject item in list) { string text2 = UnityHelpers.GetTransformPath(item.transform, true); if (text2.EndsWith("/")) { text2 = text2.Remove(text2.Length - 1); } if (text2 == input) { val = item.transform; break; } } } if (Object.op_Implicit((Object)(object)val)) { DoSetParent(val); return; } ExplorerCore.LogWarning("Could not find any GameObject name or path '" + input + "'!"); UpdateGameObjectInfo(firstUpdate: false, force: true); } private void OnNameEndEdit(string value) { ((Object)Target).name = value; UpdateGameObjectInfo(firstUpdate: false, force: true); } private void OnCopyClicked() { ClipboardPanel.Copy(Target); } private void OnActiveSelfToggled(bool value) { Target.SetActive(value); UpdateGameObjectInfo(firstUpdate: false, force: true); } private void OnTagEndEdit(string value) { try { Target.tag = value; UpdateGameObjectInfo(firstUpdate: false, force: true); } catch (Exception ex) { ExplorerCore.LogWarning("Exception setting tag! " + ReflectionExtensions.ReflectionExToString(ex, true)); } } private void OnSceneButtonClicked() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) InspectorManager.Inspect(Target.scene); } private void OnExploreButtonClicked() { UIManager.GetPanel(UIManager.Panels.ObjectExplorer).SceneExplorer.JumpToTransform(Owner.Parent.Target.transform); } private void OnLayerDropdownChanged(int value) { Target.layer = value; UpdateGameObjectInfo(firstUpdate: false, force: true); } private void OnFlagsDropdownChanged(int value) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { HideFlags hideFlags = hideFlagsValues[FlagsDropdown.options[value].text]; ((Object)Target).hideFlags = hideFlags; UpdateGameObjectInfo(firstUpdate: false, force: true); } catch (Exception arg) { ExplorerCore.LogWarning($"Exception setting hideFlags: {arg}"); } } private void OnDestroyClicked() { Object.Destroy((Object)(object)Target); InspectorManager.ReleaseInspector(Owner.Parent); } private void OnInstantiateClicked() { InspectorManager.Inspect(Object.Instantiate(Target)); } public void Create() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_0717: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_08f6: Unknown result type (might be due to invalid IL or missing references) //IL_093b: Unknown result type (might be due to invalid IL or missing references) //IL_09da: Unknown result type (might be due to invalid IL or missing references) //IL_0a67: Unknown result type (might be due to invalid IL or missing references) //IL_0a6d: Unknown result type (might be due to invalid IL or missing references) //IL_0b2c: Unknown result type (might be due to invalid IL or missing references) //IL_0bcb: Unknown result type (might be due to invalid IL or missing references) //IL_0cd6: Unknown result type (might be due to invalid IL or missing references) //IL_0dad: Unknown result type (might be due to invalid IL or missing references) //IL_0de7: Unknown result type (might be due to invalid IL or missing references) //IL_0df1: Expected O, but got Unknown //IL_0e2e: Unknown result type (might be due to invalid IL or missing references) //IL_0ebb: Unknown result type (might be due to invalid IL or missing references) //IL_0f47: Unknown result type (might be due to invalid IL or missing references) //IL_0f51: Expected O, but got Unknown GameObject val = UIFactory.CreateVerticalGroup(Owner.Parent.Content, "TopInfoHolder", false, false, true, true, 3, new Vector4(3f, 3f, 3f, 3f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)(TextAnchor)3); int? num = 100; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); val.AddComponent().verticalFit = (FitMode)2; GameObject val2 = UIFactory.CreateUIObject("ParentRow", val, default(Vector2)); UIFactory.SetLayoutGroup(val2, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)null); num2 = 25; num = 9999; UIFactory.SetLayoutElement(val2, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); ViewParentButton = UIFactory.CreateButton(val2, "ViewParentButton", "◄ View Parent", (Color?)new Color(0.2f, 0.2f, 0.2f)); ViewParentButton.ButtonText.fontSize = 13; GameObject gameObject = ((Component)ViewParentButton.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject, (int?)100, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef viewParentButton = ViewParentButton; viewParentButton.OnClick = (Action)System.Delegate.Combine(viewParentButton.OnClick, new Action(OnViewParentClicked)); PathInput = UIFactory.CreateInputField(val2, "PathInput", "..."); ((Graphic)PathInput.Component.textComponent).color = Color.grey; PathInput.Component.textComponent.fontSize = 14; GameObject uIRoot = ((UIModel)PathInput).UIRoot; num = 25; UIFactory.SetLayoutElement(uIRoot, (int?)100, num, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); PathInput.Component.lineType = (LineType)1; ButtonRef obj = UIFactory.CreateButton(val2, "CopyButton", "Copy to Clipboard", (Color?)new Color(0.2f, 0.2f, 0.2f, 1f)); ((Graphic)obj.ButtonText).color = Color.yellow; GameObject gameObject2 = ((Component)obj.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject2, (int?)120, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnCopyClicked)); UnityHelpers.GetOnEndEdit(PathInput.Component).AddListener((UnityAction)delegate(string input) { OnPathEndEdit(input); }); GameObject val3 = UIFactory.CreateUIObject("TitleRow", val, default(Vector2)); UIFactory.SetLayoutGroup(val3, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject gameObject3 = ((Component)UIFactory.CreateLabel(val3, "Title", SignatureHighlighter.Parse(typeof(GameObject), false, (MemberInfo)null), (TextAnchor)3, default(Color), true, 17)).gameObject; num = 30; UIFactory.SetLayoutElement(gameObject3, (int?)100, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); NameInput = UIFactory.CreateInputField(val3, "NameInput", "untitled"); GameObject gameObject4 = ((Component)NameInput.Component).gameObject; num = 30; UIFactory.SetLayoutElement(gameObject4, (int?)100, num, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); NameInput.Component.textComponent.fontSize = 15; UnityHelpers.GetOnEndEdit(NameInput.Component).AddListener((UnityAction)delegate(string value) { OnNameEndEdit(value); }); GameObject val4 = UIFactory.CreateUIObject("ParentRow", val, default(Vector2)); UIFactory.SetLayoutGroup(val4, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)null); num = 25; num2 = 9999; UIFactory.SetLayoutElement(val4, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj2 = UIFactory.CreateToggle(val4, "ActiveSelf", ref ActiveSelfToggle, ref ActiveSelfText, default(Color), 20, 20); num2 = 25; UIFactory.SetLayoutElement(obj2, (int?)100, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ActiveSelfText.text = "ActiveSelf"; ((UnityEvent)(object)ActiveSelfToggle.onValueChanged).AddListener((UnityAction)OnActiveSelfToggled); Text val5 = default(Text); GameObject obj3 = UIFactory.CreateToggle(val4, "IsStatic", ref IsStaticToggle, ref val5, default(Color), 20, 20); num2 = 25; UIFactory.SetLayoutElement(obj3, (int?)80, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); val5.text = "IsStatic"; ((Graphic)val5).color = Color.grey; ((Selectable)IsStaticToggle).interactable = false; GameObject gameObject5 = ((Component)UIFactory.CreateLabel(val4, "InstanceIDLabel", "Instance ID:", (TextAnchor)5, Color.grey, true, 14)).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject5, (int?)90, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); InstanceIDInput = UIFactory.CreateInputField(val4, "InstanceIDInput", "error"); GameObject gameObject6 = ((Component)InstanceIDInput.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject6, (int?)110, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)InstanceIDInput.Component.textComponent).color = Color.grey; InstanceIDInput.Component.readOnly = true; GameObject gameObject7 = ((Component)UIFactory.CreateLabel(val4, "TagLabel", "Tag:", (TextAnchor)5, Color.grey, true, 14)).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject7, (int?)40, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); TagInput = UIFactory.CreateInputField(val4, "TagInput", "none"); GameObject gameObject8 = ((Component)TagInput.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject8, (int?)100, num2, (int?)999, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)TagInput.Component.textComponent).color = Color.white; UnityHelpers.GetOnEndEdit(TagInput.Component).AddListener((UnityAction)delegate(string value) { OnTagEndEdit(value); }); ButtonRef obj4 = UIFactory.CreateButton(val4, "InstantiateBtn", "Instantiate", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject9 = ((Component)obj4.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject9, (int?)120, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, new Action(OnInstantiateClicked)); ButtonRef obj5 = UIFactory.CreateButton(val4, "DestroyBtn", "Destroy", (Color?)new Color(0.3f, 0.2f, 0.2f)); GameObject gameObject10 = ((Component)obj5.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject10, (int?)80, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj5.OnClick = (Action)System.Delegate.Combine(obj5.OnClick, new Action(OnDestroyClicked)); GameObject val6 = UIFactory.CreateUIObject("ParentRow", val, default(Vector2)); UIFactory.SetLayoutGroup(val6, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)null); num2 = 25; num = 9999; UIFactory.SetLayoutElement(val6, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj6 = UIFactory.CreateButton(val6, "ExploreBtn", "Show in Explorer", (Color?)new Color(0.15f, 0.15f, 0.15f)); GameObject gameObject11 = ((Component)obj6.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject11, (int?)100, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj6.ButtonText.fontSize = 12; obj6.OnClick = (Action)System.Delegate.Combine(obj6.OnClick, new Action(OnExploreButtonClicked)); GameObject gameObject12 = ((Component)UIFactory.CreateLabel(val6, "SceneLabel", "Scene:", (TextAnchor)3, Color.grey, true, 14)).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject12, (int?)50, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); SceneButton = UIFactory.CreateButton(val6, "SceneButton", "untitled", (Color?)null); GameObject gameObject13 = ((Component)SceneButton.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject13, (int?)120, num, (int?)999, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef sceneButton = SceneButton; sceneButton.OnClick = (Action)System.Delegate.Combine(sceneButton.OnClick, new Action(OnSceneButtonClicked)); GameObject gameObject14 = ((Component)UIFactory.CreateLabel(val6, "LayerLabel", "Layer:", (TextAnchor)3, Color.grey, true, 14)).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject14, (int?)50, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj7 = UIFactory.CreateDropdown(val6, "LayerDropdown", ref LayerDropdown, "0", 14, (Action)OnLayerDropdownChanged, (string[])null); num = 25; UIFactory.SetLayoutElement(obj7, (int?)110, num, (int?)999, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)LayerDropdown.captionText).color = SignatureHighlighter.EnumGreen; if (layerToNames == null) { GetLayerNames(); } foreach (string layerToName in layerToNames) { LayerDropdown.options.Add(new OptionData(layerToName)); } LayerDropdown.value = 0; LayerDropdown.RefreshShownValue(); GameObject gameObject15 = ((Component)UIFactory.CreateLabel(val6, "FlagsLabel", "Flags:", (TextAnchor)5, Color.grey, true, 14)).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject15, (int?)50, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj8 = UIFactory.CreateDropdown(val6, "FlagsDropdown", ref FlagsDropdown, "None", 14, (Action)OnFlagsDropdownChanged, (string[])null); ((Graphic)FlagsDropdown.captionText).color = SignatureHighlighter.EnumGreen; num = 25; UIFactory.SetLayoutElement(obj8, (int?)135, num, (int?)999, (int?)null, (int?)null, (int?)null, (bool?)null); if (hideFlagsValues == null) { GetHideFlagNames(); } foreach (string key in hideFlagsValues.Keys) { FlagsDropdown.options.Add(new OptionData(key)); } FlagsDropdown.value = 0; FlagsDropdown.RefreshShownValue(); } private static void GetLayerNames() { layerToNames = new List(); for (int i = 0; i < 32; i++) { string text = RuntimeHelper.LayerToName(i); if (string.IsNullOrEmpty(text)) { text = i.ToString(); } layerToNames.Add(text); } } private static void GetHideFlagNames() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) hideFlagsValues = new Dictionary(); foreach (HideFlags value in System.Enum.GetValues(typeof(HideFlags))) { hideFlagsValues.Add(((object)value/*cast due to .constrained prefix*/).ToString(), value); } } } public class TransformControls { private Vector3Control PositionControl; private Vector3Control LocalPositionControl; private Vector3Control RotationControl; private Vector3Control ScaleControl; public GameObjectControls Owner { get; } private GameObject Target => Owner.Target; public AxisControl CurrentSlidingAxisControl { get; set; } public TransformControls(GameObjectControls owner) { Owner = owner; Create(); } public void UpdateTransformControlValues(bool force) { PositionControl.Update(force); LocalPositionControl.Update(force); RotationControl.Update(force); ScaleControl.Update(force); } public void UpdateVectorSlider() { AxisControl currentSlidingAxisControl = CurrentSlidingAxisControl; if (currentSlidingAxisControl != null) { if (!InputManager.GetMouseButton(0)) { currentSlidingAxisControl.slider.value = 0f; currentSlidingAxisControl = null; } else { AxisControlOperation(currentSlidingAxisControl.slider.value, currentSlidingAxisControl.parent, currentSlidingAxisControl.axis); } } } public void AxisControlOperation(float value, Vector3Control parent, int axis) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Transform transform = Target.transform; Vector3 val = (Vector3)(parent.Type switch { TransformType.Position => transform.position, TransformType.LocalPosition => transform.localPosition, TransformType.Rotation => transform.localEulerAngles, TransformType.Scale => transform.localScale, _ => throw new NotImplementedException(), }); switch (axis) { case 0: val.x += value; break; case 1: val.y += value; break; case 2: val.z += value; break; } switch (parent.Type) { case TransformType.Position: transform.position = val; break; case TransformType.LocalPosition: transform.localPosition = val; break; case TransformType.Rotation: transform.localEulerAngles = val; break; case TransformType.Scale: transform.localScale = val; break; } UpdateTransformControlValues(force: false); } public void Create() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateVerticalGroup(Owner.Parent.Content, "TransformControls", false, false, true, true, 2, new Vector4(2f, 2f, 0f, 0f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); int? num = 100; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); PositionControl = Vector3Control.Create(this, val, "Position:", TransformType.Position); LocalPositionControl = Vector3Control.Create(this, val, "Local Position:", TransformType.LocalPosition); RotationControl = Vector3Control.Create(this, val, "Rotation:", TransformType.Rotation); ScaleControl = Vector3Control.Create(this, val, "Scale:", TransformType.Scale); } } public enum TransformType { Position, LocalPosition, Rotation, Scale } public class Vector3Control { private Vector3 lastValue; public TransformControls Owner { get; } public GameObject Target => Owner.Owner.Target; public Transform Transform => Target.transform; public TransformType Type { get; } public InputFieldRef MainInput { get; } public AxisControl[] AxisControls { get; } = new AxisControl[3]; public InputFieldRef IncrementInput { get; set; } public float Increment { get; set; } = 0.1f; private Vector3 CurrentValue => (Vector3)(Type switch { TransformType.Position => Transform.position, TransformType.LocalPosition => Transform.localPosition, TransformType.Rotation => Transform.localEulerAngles, TransformType.Scale => Transform.localScale, _ => throw new NotImplementedException(), }); public Vector3Control(TransformControls owner, TransformType type, InputFieldRef input) { Owner = owner; Type = type; MainInput = input; } public void Update(bool force) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 currentValue = CurrentValue; if (force || (!MainInput.Component.isFocused && !((Vector3)(ref lastValue)).Equals(currentValue))) { MainInput.Text = ParseUtility.ToStringForInput((object)currentValue); lastValue = currentValue; } } private void OnTransformInputEndEdit(TransformType type, string input) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) Exception ex = default(Exception); switch (type) { case TransformType.Position: { Vector3 position = default(Vector3); if (ParseUtility.TryParse(input, ref position, ref ex)) { Target.transform.position = position; } break; } case TransformType.LocalPosition: { Vector3 localPosition = default(Vector3); if (ParseUtility.TryParse(input, ref localPosition, ref ex)) { Target.transform.localPosition = localPosition; } break; } case TransformType.Rotation: { Vector3 localEulerAngles = default(Vector3); if (ParseUtility.TryParse(input, ref localEulerAngles, ref ex)) { Target.transform.localEulerAngles = localEulerAngles; } break; } case TransformType.Scale: { Vector3 localScale = default(Vector3); if (ParseUtility.TryParse(input, ref localScale, ref ex)) { Target.transform.localScale = localScale; } break; } } Owner.UpdateTransformControlValues(force: true); } private void IncrementInput_OnEndEdit(string value) { float num = default(float); Exception ex = default(Exception); if (!ParseUtility.TryParse(value, ref num, ref ex)) { IncrementInput.Text = ParseUtility.ToStringForInput((object)Increment); return; } Increment = num; AxisControl[] axisControls = AxisControls; foreach (AxisControl obj in axisControls) { obj.slider.minValue = 0f - num; obj.slider.maxValue = num; } } public static Vector3Control Create(TransformControls owner, GameObject transformGroup, string title, TransformType type) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateUIObject("Row_" + title, transformGroup, default(Vector2)); UIFactory.SetLayoutGroup(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)null); int? num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(val, "PositionLabel", title, (TextAnchor)5, Color.grey, true, 14)).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)110, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); InputFieldRef val2 = UIFactory.CreateInputField(val, "InputField", "..."); GameObject gameObject2 = ((Component)val2.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)100, num2, (int?)999, (int?)null, (int?)null, (int?)null, (bool?)null); Vector3Control control = new Vector3Control(owner, type, val2); UnityHelpers.GetOnEndEdit(val2.Component).AddListener((UnityAction)delegate(string value) { control.OnTransformInputEndEdit(type, value); }); control.AxisControls[0] = AxisControl.Create(val, "X", 0, control); control.AxisControls[1] = AxisControl.Create(val, "Y", 1, control); control.AxisControls[2] = AxisControl.Create(val, "Z", 2, control); control.IncrementInput = UIFactory.CreateInputField(val, "IncrementInput", "..."); control.IncrementInput.Text = "0.1"; GameObject gameObject3 = control.IncrementInput.GameObject; int? num3 = 30; num2 = 0; UIFactory.SetLayoutElement(gameObject3, num3, (int?)25, num2, (int?)null, (int?)null, (int?)null, (bool?)null); UnityHelpers.GetOnEndEdit(control.IncrementInput.Component).AddListener((UnityAction)control.IncrementInput_OnEndEdit); return control; } } [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] internal class TimeScaleWidget { [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] public static TimeScaleWidget Instance; private readonly InputFieldRef timeInput; private readonly ButtonRef lockBtn; private bool locked; private bool settingTimeScale; public float DesiredTime { get; private set; } public static void SetUp(GameObject parent) { if (Instance == null) { Instance = new TimeScaleWidget(parent); } } private TimeScaleWidget(GameObject parent) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)UIFactory.CreateLabel(parent, "TimeLabel", "Time:", (TextAnchor)5, Color.grey, true, 14)).gameObject; int? num = 25; UIFactory.SetLayoutElement(gameObject, (int?)35, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); timeInput = UIFactory.CreateInputField(parent, "TimeInput", "timeScale"); GameObject gameObject2 = ((Component)timeInput.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject2, (int?)40, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); UnityHelpers.GetOnEndEdit(timeInput.Component).AddListener((UnityAction)OnTimeInputEndEdit); timeInput.Text = string.Empty; timeInput.Text = Time.timeScale.ToString(); lockBtn = UIFactory.CreateButton(parent, "PauseButton", "Lock", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject3 = ((Component)lockBtn.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject3, (int?)50, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = lockBtn; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnPauseButtonClicked)); } public void Update() { if (locked) { UpdateTimeScale(); } if (!timeInput.Component.isFocused) { timeInput.Text = Time.timeScale.ToString("F2"); } } public void LockTo(float timeScale) { locked = true; SetTimeScale(timeScale); UpdateUi(); } public void OnPauseButtonClicked() { OnTimeInputEndEdit(timeInput.Text); locked = !locked; UpdateUi(); } private void UpdateTimeScale() { settingTimeScale = true; Time.timeScale = DesiredTime; settingTimeScale = false; } private void SetTimeScale(float floatVal) { DesiredTime = floatVal; UpdateTimeScale(); } private void OnTimeInputEndEdit(string val) { if (float.TryParse(val, out var result)) { SetTimeScale(result); } } private void UpdateUi() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Color val = (locked ? new Color(0.3f, 0.3f, 0.2f) : new Color(0.2f, 0.2f, 0.2f)); RuntimeHelper.SetColorBlock((Selectable)(object)lockBtn.Component, (Color?)val, (Color?)(val * 1.2f), (Color?)(val * 0.7f), (Color?)null); lockBtn.ButtonText.text = (locked ? "Unlock" : "Lock"); } private static void InitPatch() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown try { MethodInfo methodInfo = typeof(Time).GetProperty("timeScale")?.GetSetMethod(); if (!(methodInfo == null)) { ExplorerCore.Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(TimeScaleWidget), "Prefix_Time_set_timeScale", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { ExplorerCore.LogError("Failed to patch Time.timeScale setter, " + ex.Message); } } private static bool Prefix_Time_set_timeScale() { if (Instance != null && Instance.locked) { return Instance.settingTimeScale; } return true; } } public class AudioClipWidget : UnityObjectWidget { private static GameObject AudioPlayerObject; private static AudioSource Source; private static AudioClipWidget CurrentlyPlaying; private static Coroutine CurrentlyPlayingCoroutine; private static readonly string zeroLengthString = GetLengthString(0f); public AudioClip audioClip; private string fullLengthText; private ButtonRef toggleButton; private bool audioPlayerWanted; private GameObject audioPlayerRoot; private ButtonRef playStopButton; private Text progressLabel; private GameObject saveObjectRow; private InputFieldRef savePathInput; private GameObject cantSaveRow; public override void OnBorrowed(object target, Type targetType, ReflectionInspector inspector) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) base.OnBorrowed(target, targetType, inspector); audioPlayerRoot.transform.SetParent(inspector.UIRoot.transform); audioPlayerRoot.transform.SetSiblingIndex(inspector.UIRoot.transform.childCount - 2); audioClip = ReflectionExtensions.TryCast(target); fullLengthText = GetLengthString(audioClip.length); if ((int)audioClip.loadType == 0) { cantSaveRow.SetActive(false); saveObjectRow.SetActive(true); SetDefaultSavePath(); } else { cantSaveRow.SetActive(true); saveObjectRow.SetActive(false); } ResetProgressLabel(); } public override void OnReturnToPool() { audioClip = null; if (audioPlayerWanted) { ToggleAudioWidget(); } if (CurrentlyPlaying == this) { StopClip(); } audioPlayerRoot.transform.SetParent(Pool.Instance.InactiveHolder.transform); base.OnReturnToPool(); } private void ToggleAudioWidget() { if (audioPlayerWanted) { audioPlayerWanted = false; toggleButton.ButtonText.text = "Show Player"; audioPlayerRoot.SetActive(false); } else { audioPlayerWanted = true; toggleButton.ButtonText.text = "Hide Player"; audioPlayerRoot.SetActive(true); } } private void SetDefaultSavePath() { string text = ((Object)audioClip).name; if (string.IsNullOrEmpty(text)) { text = "untitled"; } savePathInput.Text = Path.Combine(ConfigManager.Default_Output_Path.Value, text + ".wav"); } private static string GetLengthString(float seconds) { TimeSpan timeSpan = TimeSpan.FromSeconds(seconds); StringBuilder stringBuilder = new StringBuilder(); if (timeSpan.Hours > 0) { stringBuilder.Append($"{timeSpan.Hours}:"); } stringBuilder.Append($"{timeSpan.Minutes:00}:"); stringBuilder.Append($"{timeSpan.Seconds:00}:"); stringBuilder.Append($"{timeSpan.Milliseconds:000}"); return stringBuilder.ToString(); } private void ResetProgressLabel() { progressLabel.text = zeroLengthString + " / " + fullLengthText; } private void OnPlayStopClicked() { SetupAudioPlayer(); if (CurrentlyPlaying == this) { StopClip(); return; } if (CurrentlyPlaying != null) { CurrentlyPlaying.StopClip(); } CurrentlyPlayingCoroutine = RuntimeHelper.StartCoroutine(PlayClipCoroutine()); } private static void SetupAudioPlayer() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)AudioPlayerObject)) { AudioPlayerObject = new GameObject("UnityExplorer.AudioPlayer"); Object.DontDestroyOnLoad((Object)(object)AudioPlayerObject); ((Object)AudioPlayerObject).hideFlags = (HideFlags)61; AudioPlayerObject.transform.position = new Vector3(-2.1474836E+09f, -2.1474836E+09f); Source = AudioPlayerObject.AddComponent(); AudioPlayerObject.AddComponent(); } } private IEnumerator PlayClipCoroutine() { playStopButton.ButtonText.text = "Stop Clip"; CurrentlyPlaying = this; Source.clip = audioClip; Source.Play(); while (Source.isPlaying) { progressLabel.text = GetLengthString(Source.time) + " / " + fullLengthText; yield return null; } CurrentlyPlayingCoroutine = null; StopClip(); } private void StopClip() { if (CurrentlyPlayingCoroutine != null) { RuntimeHelper.StopCoroutine(CurrentlyPlayingCoroutine); } Source.Stop(); CurrentlyPlaying = null; CurrentlyPlayingCoroutine = null; playStopButton.ButtonText.text = "Play Clip"; ResetProgressLabel(); } public void OnSaveClipClicked() { if (!Object.op_Implicit((Object)(object)audioClip)) { ExplorerCore.LogWarning("AudioClip is null, maybe it was destroyed?"); return; } if (string.IsNullOrEmpty(savePathInput.Text)) { ExplorerCore.LogWarning("Save path cannot be empty!"); return; } string text = savePathInput.Text; if (!text.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase)) { text += ".wav"; } text = IOUtility.EnsureValidFilePath(text); if (File.Exists(text)) { File.Delete(text); } SavWav.Save(audioClip, text); } public override GameObject CreateContent(GameObject uiRoot) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) GameObject result = base.CreateContent(uiRoot); toggleButton = UIFactory.CreateButton(base.UIRoot, "AudioWidgetToggleButton", "Show Player", (Color?)new Color(0.2f, 0.3f, 0.2f)); ((Transform)toggleButton.Transform).SetSiblingIndex(0); GameObject gameObject = ((Component)toggleButton.Component).gameObject; int? num = 25; UIFactory.SetLayoutElement(gameObject, (int?)170, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = toggleButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(ToggleAudioWidget)); audioPlayerRoot = UIFactory.CreateVerticalGroup(uiRoot, "AudioWidget", false, false, true, true, 5, default(Vector4), default(Color), (TextAnchor?)null); GameObject obj2 = audioPlayerRoot; num = 9999; int? num2 = 50; UIFactory.SetLayoutElement(obj2, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); audioPlayerRoot.SetActive(false); GameObject val = UIFactory.CreateHorizontalGroup(audioPlayerRoot, "PlayerWidget", false, false, true, true, 5, new Vector4 { x = 3f, w = 3f, y = 3f, z = 3f }, default(Color), (TextAnchor?)null); playStopButton = UIFactory.CreateButton(val, "PlayerButton", "Play", (Color?)new Color(0.2f, 0.4f, 0.2f)); ButtonRef obj3 = playStopButton; obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(OnPlayStopClicked)); UIFactory.SetLayoutElement(playStopButton.GameObject, (int?)60, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); progressLabel = UIFactory.CreateLabel(val, "ProgressLabel", "0 / 0", (TextAnchor)3, default(Color), true, 14); GameObject gameObject2 = ((Component)progressLabel).gameObject; num2 = 9999; num = 25; UIFactory.SetLayoutElement(gameObject2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); ResetProgressLabel(); saveObjectRow = UIFactory.CreateHorizontalGroup(audioPlayerRoot, "SaveRow", false, false, true, true, 2, new Vector4(2f, 2f, 2f, 2f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); ButtonRef obj4 = UIFactory.CreateButton(saveObjectRow, "SaveButton", "Save .WAV", (Color?)new Color(0.2f, 0.25f, 0.2f)); GameObject gameObject3 = ((Component)obj4.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject3, (int?)100, num, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, new Action(OnSaveClipClicked)); savePathInput = UIFactory.CreateInputField(saveObjectRow, "SaveInput", "..."); GameObject uIRoot = ((UIModel)savePathInput).UIRoot; num = 25; UIFactory.SetLayoutElement(uIRoot, (int?)100, num, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); cantSaveRow = UIFactory.CreateHorizontalGroup(audioPlayerRoot, "CantSaveRow", true, true, true, true, 0, default(Vector4), default(Color), (TextAnchor?)null); GameObject obj5 = cantSaveRow; num = 25; num2 = 9999; UIFactory.SetLayoutElement(obj5, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.CreateLabel(cantSaveRow, "CantSaveLabel", "Cannot save this AudioClip as the data is compressed or streamed. Try a tool such as AssetRipper to unpack it.", (TextAnchor)3, Color.grey, true, 14); return result; } } public static class SavWav { public const int HEADER_SIZE = 44; public const float RESCALE_FACTOR = 32767f; public static void Save(AudioClip clip, string filepath) { using FileStream fileStream = CreateEmpty(filepath); ConvertAndWrite(fileStream, clip); WriteHeader(fileStream, clip); } private static FileStream CreateEmpty(string filepath) { FileStream fileStream = new FileStream(filepath, FileMode.Create); byte value = 0; for (int i = 0; i < 44; i++) { fileStream.WriteByte(value); } return fileStream; } private static void ConvertAndWrite(FileStream fileStream, AudioClip clip) { float[] array = new float[clip.samples * clip.channels]; ((object)clip).GetType().GetMethod("GetData", new Type[2] { typeof(float[]), typeof(int) })?.Invoke(clip, new object[2] { array, 0 }); int num = array.Length; short[] array2 = new short[num]; byte[] array3 = new byte[num * 2]; for (int i = 0; i < num; i++) { array2[i] = (short)(array[i] * 32767f); BitConverter.GetBytes(array2[i]).CopyTo(array3, i * 2); } fileStream.Write(array3, 0, array3.Length); } private static void WriteHeader(FileStream stream, AudioClip clip) { int frequency = clip.frequency; int channels = clip.channels; int samples = clip.samples; stream.Seek(0L, SeekOrigin.Begin); byte[] bytes = Encoding.UTF8.GetBytes("RIFF"); stream.Write(bytes, 0, 4); byte[] bytes2 = BitConverter.GetBytes(stream.Length - 8); stream.Write(bytes2, 0, 4); byte[] bytes3 = Encoding.ASCII.GetBytes("WAVE"); stream.Write(bytes3, 0, 4); byte[] bytes4 = Encoding.ASCII.GetBytes("fmt "); stream.Write(bytes4, 0, 4); byte[] bytes5 = BitConverter.GetBytes(16); stream.Write(bytes5, 0, 4); byte[] bytes6 = BitConverter.GetBytes(1); stream.Write(bytes6, 0, 2); byte[] bytes7 = BitConverter.GetBytes(channels); stream.Write(bytes7, 0, 2); byte[] bytes8 = BitConverter.GetBytes(frequency); stream.Write(bytes8, 0, 4); byte[] bytes9 = BitConverter.GetBytes(frequency * channels * 2); stream.Write(bytes9, 0, 4); ushort value = (ushort)(channels * 2); stream.Write(BitConverter.GetBytes(value), 0, 2); byte[] bytes10 = BitConverter.GetBytes((ushort)16); stream.Write(bytes10, 0, 2); byte[] bytes11 = Encoding.UTF8.GetBytes("data"); stream.Write(bytes11, 0, 4); byte[] bytes12 = BitConverter.GetBytes(samples * channels * 2); stream.Write(bytes12, 0, 4); stream.Seek(0L, SeekOrigin.Begin); } } public class MaterialWidget : UnityObjectWidget { private static readonly MethodInfo mi_GetTexturePropertyNames; private Material material; private Texture2D activeTexture; private readonly Dictionary textures = new Dictionary(); private readonly HashSet texturesToDestroy = new HashSet(); private bool textureViewerWanted; private ButtonRef toggleButton; private GameObject textureViewerRoot; private Dropdown textureDropdown; private InputFieldRef savePathInput; private Image image; private LayoutElement imageLayout; internal static bool MaterialWidgetSupported { get; } static MaterialWidget() { mi_GetTexturePropertyNames = typeof(Material).GetMethod("GetTexturePropertyNames", ArgumentUtility.EmptyTypes); MaterialWidgetSupported = mi_GetTexturePropertyNames != null; } public override void OnBorrowed(object target, Type targetType, ReflectionInspector inspector) { base.OnBorrowed(target, targetType, inspector); material = ReflectionExtensions.TryCast(target); if (Object.op_Implicit((Object)(object)material.mainTexture)) { SetActiveTexture(material.mainTexture); } if (mi_GetTexturePropertyNames.Invoke(material, ArgumentUtility.EmptyArgs) is IEnumerable enumerable) { foreach (string item in enumerable) { Texture texture = material.GetTexture(item); if (texture != null && (!((Object)(object)ReflectionExtensions.TryCast((object)texture) == (Object)null) || !((Object)(object)ReflectionExtensions.TryCast((object)texture) == (Object)null))) { textures.Add(item, texture); if (!Object.op_Implicit((Object)(object)activeTexture)) { SetActiveTexture(texture); } } } } if (Object.op_Implicit((Object)(object)textureViewerRoot)) { textureViewerRoot.transform.SetParent(inspector.UIRoot.transform); RefreshTextureDropdown(); } ((PanelBase)InspectorPanel.Instance).Dragger.OnFinishResize += OnInspectorFinishResize; } private void SetActiveTexture(Texture texture) { Texture2D val = ReflectionExtensions.TryCast((object)texture); if (val != null) { activeTexture = val; return; } Cubemap val2 = ReflectionExtensions.TryCast((object)texture); if (val2 != null) { activeTexture = TextureHelper.UnwrapCubemap(val2); texturesToDestroy.Add(activeTexture); } } public override void OnReturnToPool() { ((PanelBase)InspectorPanel.Instance).Dragger.OnFinishResize -= OnInspectorFinishResize; if (texturesToDestroy.Any()) { foreach (Texture2D item in texturesToDestroy) { Object.Destroy((Object)(object)item); } texturesToDestroy.Clear(); } material = null; activeTexture = null; textures.Clear(); if (Object.op_Implicit((Object)(object)image.sprite)) { Object.Destroy((Object)(object)image.sprite); } if (textureViewerWanted) { ToggleTextureViewer(); } if (Object.op_Implicit((Object)(object)textureViewerRoot)) { textureViewerRoot.transform.SetParent(Pool.Instance.InactiveHolder.transform); } base.OnReturnToPool(); } private void ToggleTextureViewer() { if (textureViewerWanted) { textureViewerWanted = false; textureViewerRoot.SetActive(false); toggleButton.ButtonText.text = "View Material"; owner.ContentRoot.SetActive(true); return; } if (!Object.op_Implicit((Object)(object)image.sprite)) { RefreshTextureViewer(); RefreshTextureDropdown(); } SetImageSize(); textureViewerWanted = true; textureViewerRoot.SetActive(true); toggleButton.ButtonText.text = "Hide Material"; owner.ContentRoot.gameObject.SetActive(false); } private void RefreshTextureViewer() { if (!Object.op_Implicit((Object)(object)activeTexture)) { ExplorerCore.LogWarning("Material has no active textures!"); savePathInput.Text = string.Empty; return; } if (Object.op_Implicit((Object)(object)image.sprite)) { Object.Destroy((Object)(object)image.sprite); } string text = ((Object)activeTexture).name; if (string.IsNullOrEmpty(text)) { text = "untitled"; } savePathInput.Text = Path.Combine(ConfigManager.Default_Output_Path.Value, text + ".png"); Sprite sprite = TextureHelper.CreateSprite(activeTexture); image.sprite = sprite; } private void RefreshTextureDropdown() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)textureDropdown)) { return; } textureDropdown.options.Clear(); foreach (string key in textures.Keys) { textureDropdown.options.Add(new OptionData(key)); } int num = 0; foreach (Texture value in textures.Values) { if (ReflectionExtensions.ReferenceEqual((object)activeTexture, (object)value)) { textureDropdown.value = num; break; } num++; } textureDropdown.RefreshShownValue(); } private void OnTextureDropdownChanged(int value) { Texture value2 = textures.ElementAt(value).Value; if (!ReflectionExtensions.ReferenceEqual((object)activeTexture, (object)value2)) { SetActiveTexture(value2); RefreshTextureViewer(); } } private void OnInspectorFinishResize() { SetImageSize(); } private void SetImageSize() { if (Object.op_Implicit((Object)(object)imageLayout)) { RuntimeHelper.StartCoroutine(SetImageSizeCoro()); } } private IEnumerator SetImageSizeCoro() { if (!Object.op_Implicit((Object)(object)activeTexture)) { yield break; } yield return null; RectTransform rect = ((PanelBase)InspectorPanel.Instance).Rect; Rect rect2 = rect.rect; float num = ((Rect)(ref rect2)).width - 25f; rect2 = rect.rect; float num2 = ((Rect)(ref rect2)).height - 196f; if ((float)((Texture)activeTexture).width < num && (float)((Texture)activeTexture).height < num2) { imageLayout.minWidth = ((Texture)activeTexture).width; imageLayout.minHeight = ((Texture)activeTexture).height; yield break; } float num3 = (float)((decimal)num / (decimal)((Texture)activeTexture).width); float num4 = (float)((decimal)num2 / (decimal)((Texture)activeTexture).height); if (num3 < num4) { imageLayout.minWidth = (float)((Texture)activeTexture).width * num3; imageLayout.minHeight = (float)((Texture)activeTexture).height * num3; } else { imageLayout.minWidth = (float)((Texture)activeTexture).width * num4; imageLayout.minHeight = (float)((Texture)activeTexture).height * num4; } } private void OnSaveTextureClicked() { if (!Object.op_Implicit((Object)(object)activeTexture)) { ExplorerCore.LogWarning("Texture is null, maybe it was destroyed?"); return; } if (string.IsNullOrEmpty(savePathInput.Text)) { ExplorerCore.LogWarning("Save path cannot be empty!"); return; } string text = savePathInput.Text; if (!text.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) { text += ".png"; } text = IOUtility.EnsureValidFilePath(text); if (File.Exists(text)) { File.Delete(text); } TextureHelper.SaveTextureAsPNG(activeTexture, text); } public override GameObject CreateContent(GameObject uiRoot) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) GameObject result = base.CreateContent(uiRoot); toggleButton = UIFactory.CreateButton(base.UIRoot, "MaterialButton", "View Material", (Color?)new Color(0.2f, 0.3f, 0.2f)); ((Transform)toggleButton.Transform).SetSiblingIndex(0); GameObject gameObject = ((Component)toggleButton.Component).gameObject; int? num = 25; UIFactory.SetLayoutElement(gameObject, (int?)150, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = toggleButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(ToggleTextureViewer)); textureViewerRoot = UIFactory.CreateVerticalGroup(uiRoot, "MaterialViewer", false, false, true, true, 2, new Vector4(5f, 5f, 5f, 5f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)(TextAnchor)0); GameObject obj2 = textureViewerRoot; num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); GameObject obj3 = textureViewerRoot; Vector4 val = new Vector4(3f, 3f, 3f, 3f); Color val2 = default(Color); GameObject obj4 = UIFactory.CreateHorizontalGroup(obj3, "DropdownRow", false, true, true, true, 5, val, val2, (TextAnchor?)null); num2 = 30; num = 9999; UIFactory.SetLayoutElement(obj4, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); val2 = default(Color); UIFactory.SetLayoutElement(((Component)UIFactory.CreateLabel(obj4, "DropdownLabel", "Texture:", (TextAnchor)3, val2, true, 14)).gameObject, (int?)75, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutElement(UIFactory.CreateDropdown(obj4, "TextureDropdown", ref textureDropdown, "NOT SET", 13, (Action)OnTextureDropdownChanged, (string[])null), (int?)350, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject val3 = UIFactory.CreateHorizontalGroup(textureViewerRoot, "SaveRow", false, false, true, true, 2, new Vector4(2f, 2f, 2f, 2f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); ButtonRef obj5 = UIFactory.CreateButton(val3, "SaveButton", "Save .PNG", (Color?)new Color(0.2f, 0.25f, 0.2f)); GameObject gameObject2 = ((Component)obj5.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject2, (int?)100, num, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj5.OnClick = (Action)System.Delegate.Combine(obj5.OnClick, new Action(OnSaveTextureClicked)); savePathInput = UIFactory.CreateInputField(val3, "SaveInput", "..."); GameObject uIRoot = ((UIModel)savePathInput).UIRoot; num = 25; UIFactory.SetLayoutElement(uIRoot, (int?)100, num, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj6 = textureViewerRoot; ((Color)(ref val2))..ctor(1f, 1f, 1f, 0f); TextAnchor? val4 = (TextAnchor)4; GameObject val5 = UIFactory.CreateVerticalGroup(obj6, "ImageViewport", false, false, true, true, 0, default(Vector4), val2, val4); num = 9999; num2 = 9999; UIFactory.SetLayoutElement(val5, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); GameObject val6 = UIFactory.CreateUIObject("ImageHolder", val5, default(Vector2)); imageLayout = UIFactory.SetLayoutElement(val6, (int?)1, (int?)1, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); GameObject val7 = UIFactory.CreateUIObject("ActualImage", val6, default(Vector2)); RectTransform obj7 = val7.GetComponent(); obj7.anchorMin = new Vector2(0f, 0f); obj7.anchorMax = new Vector2(1f, 1f); image = val7.AddComponent(); textureViewerRoot.SetActive(false); return result; } } public class Texture2DWidget : UnityObjectWidget { private Texture2D texture; private bool shouldDestroyTexture; private bool textureViewerWanted; private ButtonRef toggleButton; private GameObject textureViewerRoot; private InputFieldRef savePathInput; private Image image; private LayoutElement imageLayout; public override void OnBorrowed(object target, Type targetType, ReflectionInspector inspector) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) base.OnBorrowed(target, targetType, inspector); Cubemap val = ReflectionExtensions.TryCast(target); if (val != null) { texture = TextureHelper.UnwrapCubemap(val); shouldDestroyTexture = true; } else { Sprite val2 = ReflectionExtensions.TryCast(target); if (val2 != null) { if (val2.packed && (int)val2.packingMode == 0) { texture = val2.texture; } else { texture = TextureHelper.CopyTexture((Texture)(object)val2.texture, val2.textureRect, 0, 0, 0); shouldDestroyTexture = true; } } else { Image val3 = ReflectionExtensions.TryCast(target); if (val3 != null) { if (val3.sprite.packed && (int)val3.sprite.packingMode == 0) { texture = val3.sprite.texture; } else { texture = TextureHelper.CopyTexture((Texture)(object)val3.sprite.texture, val3.sprite.textureRect, 0, 0, 0); shouldDestroyTexture = true; } } else { texture = ReflectionExtensions.TryCast(target); } } } if (Object.op_Implicit((Object)(object)textureViewerRoot)) { textureViewerRoot.transform.SetParent(inspector.UIRoot.transform); } ((PanelBase)InspectorPanel.Instance).Dragger.OnFinishResize += OnInspectorFinishResize; } public override void OnReturnToPool() { ((PanelBase)InspectorPanel.Instance).Dragger.OnFinishResize -= OnInspectorFinishResize; if (shouldDestroyTexture) { Object.Destroy((Object)(object)texture); } texture = null; shouldDestroyTexture = false; if (Object.op_Implicit((Object)(object)image.sprite)) { Object.Destroy((Object)(object)image.sprite); } if (textureViewerWanted) { ToggleTextureViewer(); } if (Object.op_Implicit((Object)(object)textureViewerRoot)) { textureViewerRoot.transform.SetParent(Pool.Instance.InactiveHolder.transform); } base.OnReturnToPool(); } private void ToggleTextureViewer() { if (textureViewerWanted) { textureViewerWanted = false; textureViewerRoot.SetActive(false); toggleButton.ButtonText.text = "View Texture"; owner.ContentRoot.SetActive(true); return; } if (!Object.op_Implicit((Object)(object)image.sprite)) { SetupTextureViewer(); } SetImageSize(); textureViewerWanted = true; textureViewerRoot.SetActive(true); toggleButton.ButtonText.text = "Hide Texture"; owner.ContentRoot.gameObject.SetActive(false); } private void SetupTextureViewer() { if (Object.op_Implicit((Object)(object)texture)) { string text = ((Object)texture).name; if (string.IsNullOrEmpty(text)) { text = "untitled"; } savePathInput.Text = Path.Combine(ConfigManager.Default_Output_Path.Value, text + ".png"); Sprite sprite = TextureHelper.CreateSprite(texture); image.sprite = sprite; } } private void OnInspectorFinishResize() { SetImageSize(); } private void SetImageSize() { if (Object.op_Implicit((Object)(object)imageLayout)) { RuntimeHelper.StartCoroutine(SetImageSizeCoro()); } } private IEnumerator SetImageSizeCoro() { yield return null; RectTransform rect = ((PanelBase)InspectorPanel.Instance).Rect; Rect rect2 = rect.rect; float num = ((Rect)(ref rect2)).width - 25f; rect2 = rect.rect; float num2 = ((Rect)(ref rect2)).height - 196f; if ((float)((Texture)texture).width < num && (float)((Texture)texture).height < num2) { imageLayout.minWidth = ((Texture)texture).width; imageLayout.minHeight = ((Texture)texture).height; yield break; } float num3 = (float)((decimal)num / (decimal)((Texture)texture).width); float num4 = (float)((decimal)num2 / (decimal)((Texture)texture).height); if (num3 < num4) { imageLayout.minWidth = (float)((Texture)texture).width * num3; imageLayout.minHeight = (float)((Texture)texture).height * num3; } else { imageLayout.minWidth = (float)((Texture)texture).width * num4; imageLayout.minHeight = (float)((Texture)texture).height * num4; } } private void OnSaveTextureClicked() { if (!Object.op_Implicit((Object)(object)texture)) { ExplorerCore.LogWarning("Texture is null, maybe it was destroyed?"); return; } if (string.IsNullOrEmpty(savePathInput.Text)) { ExplorerCore.LogWarning("Save path cannot be empty!"); return; } string text = savePathInput.Text; if (!text.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) { text += ".png"; } text = IOUtility.EnsureValidFilePath(text); if (File.Exists(text)) { File.Delete(text); } TextureHelper.SaveTextureAsPNG(texture, text); } public override GameObject CreateContent(GameObject uiRoot) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) GameObject result = base.CreateContent(uiRoot); toggleButton = UIFactory.CreateButton(base.UIRoot, "TextureButton", "View Texture", (Color?)new Color(0.2f, 0.3f, 0.2f)); ((Transform)toggleButton.Transform).SetSiblingIndex(0); GameObject gameObject = ((Component)toggleButton.Component).gameObject; int? num = 25; UIFactory.SetLayoutElement(gameObject, (int?)150, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = toggleButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(ToggleTextureViewer)); textureViewerRoot = UIFactory.CreateVerticalGroup(uiRoot, "TextureViewer", false, false, true, true, 2, new Vector4(5f, 5f, 5f, 5f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)(TextAnchor)0); GameObject obj2 = textureViewerRoot; num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); GameObject val = UIFactory.CreateHorizontalGroup(textureViewerRoot, "SaveRow", false, false, true, true, 2, new Vector4(2f, 2f, 2f, 2f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); ButtonRef obj3 = UIFactory.CreateButton(val, "SaveButton", "Save .PNG", (Color?)new Color(0.2f, 0.25f, 0.2f)); GameObject gameObject2 = ((Component)obj3.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)100, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(OnSaveTextureClicked)); savePathInput = UIFactory.CreateInputField(val, "SaveInput", "..."); GameObject uIRoot = ((UIModel)savePathInput).UIRoot; num2 = 25; UIFactory.SetLayoutElement(uIRoot, (int?)100, num2, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj4 = textureViewerRoot; Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 1f, 1f, 0f); TextAnchor? val3 = (TextAnchor)4; GameObject val4 = UIFactory.CreateVerticalGroup(obj4, "ImageViewport", false, false, true, true, 0, default(Vector4), val2, val3); num2 = 9999; num = 9999; UIFactory.SetLayoutElement(val4, (int?)null, (int?)null, num2, num, (int?)null, (int?)null, (bool?)null); GameObject val5 = UIFactory.CreateUIObject("ImageHolder", val4, default(Vector2)); imageLayout = UIFactory.SetLayoutElement(val5, (int?)1, (int?)1, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); GameObject val6 = UIFactory.CreateUIObject("ActualImage", val5, default(Vector2)); RectTransform obj5 = val6.GetComponent(); obj5.anchorMin = new Vector2(0f, 0f); obj5.anchorMax = new Vector2(1f, 1f); image = val6.AddComponent(); textureViewerRoot.SetActive(false); return result; } } public class UnityObjectWidget : IPooledObject { public Object unityObject; public Component component; public ReflectionInspector owner; protected ButtonRef gameObjectButton; protected InputFieldRef nameInput; protected InputFieldRef instanceIdInput; public GameObject UIRoot { get; set; } public float DefaultHeight => -1f; public static UnityObjectWidget GetUnityWidget(object target, Type targetType, ReflectionInspector inspector) { if (!typeof(Object).IsAssignableFrom(targetType)) { return null; } UnityObjectWidget unityObjectWidget; if (!(target is Texture2D) && !(target is Cubemap)) { Sprite val = (Sprite)((target is Sprite) ? target : null); if (val == null) { Image val2 = (Image)((target is Image) ? target : null); if (val2 == null) { if (!(target is Material)) { if (!(target is AudioClip)) { goto IL_00a7; } unityObjectWidget = Pool.Borrow(); } else { if (!MaterialWidget.MaterialWidgetSupported) { goto IL_00a7; } unityObjectWidget = Pool.Borrow(); } } else { if (!Object.op_Implicit((Object)(object)val2.sprite) || !Object.op_Implicit((Object)(object)val2.sprite.texture)) { goto IL_00a7; } unityObjectWidget = Pool.Borrow(); } } else { if (!Object.op_Implicit((Object)(object)val.texture)) { goto IL_00a7; } unityObjectWidget = Pool.Borrow(); } } else { unityObjectWidget = Pool.Borrow(); } goto IL_00ad; IL_00ad: UnityObjectWidget unityObjectWidget2 = unityObjectWidget; unityObjectWidget2.OnBorrowed(target, targetType, inspector); return unityObjectWidget2; IL_00a7: unityObjectWidget = Pool.Borrow(); goto IL_00ad; } public virtual void OnBorrowed(object target, Type targetType, ReflectionInspector inspector) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown owner = inspector; if (!Object.op_Implicit((Object)(object)UIRoot)) { CreateContent(inspector.UIRoot); } else { UIRoot.transform.SetParent(inspector.UIRoot.transform); } UIRoot.transform.SetSiblingIndex(inspector.UIRoot.transform.childCount - 2); unityObject = ReflectionExtensions.TryCast(target); UIRoot.SetActive(true); nameInput.Text = unityObject.name; instanceIdInput.Text = unityObject.GetInstanceID().ToString(); if (typeof(Component).IsAssignableFrom(targetType)) { component = (Component)ReflectionExtensions.TryCast(target, typeof(Component)); ((Component)gameObjectButton.Component).gameObject.SetActive(true); } else { ((Component)gameObjectButton.Component).gameObject.SetActive(false); } } public virtual void OnReturnToPool() { unityObject = null; component = null; owner = null; } public virtual void Update() { if (Object.op_Implicit(unityObject)) { nameInput.Text = unityObject.name; owner.Tab.TabText.text = owner.TabButtonText + " \"" + unityObject.name + "\""; } } private void OnGameObjectButtonClicked() { if (!Object.op_Implicit((Object)(object)component)) { ExplorerCore.LogWarning("Component reference is null or destroyed!"); } else { InspectorManager.Inspect(component.gameObject); } } public virtual GameObject CreateContent(GameObject uiRoot) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject("UnityObjectRow", uiRoot, default(Vector2)); UIFactory.SetLayoutGroup(UIRoot, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject uIRoot = UIRoot; int? num = 25; int? num2 = 0; int? num3 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(UIRoot, "NameLabel", "Name:", (TextAnchor)3, Color.grey, true, 14)).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject, (int?)45, num3, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); nameInput = UIFactory.CreateInputField(UIRoot, "NameInput", "untitled"); GameObject uIRoot2 = ((UIModel)nameInput).UIRoot; num3 = 25; UIFactory.SetLayoutElement(uIRoot2, (int?)100, num3, (int?)1000, (int?)null, (int?)null, (int?)null, (bool?)null); nameInput.Component.readOnly = true; gameObjectButton = UIFactory.CreateButton(UIRoot, "GameObjectButton", "Inspect GameObject", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject2 = ((Component)gameObjectButton.Component).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)160, num3, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = gameObjectButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnGameObjectButtonClicked)); GameObject gameObject3 = ((Component)UIFactory.CreateLabel(UIRoot, "InstanceLabel", "Instance ID:", (TextAnchor)5, Color.grey, true, 14)).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)100, num3, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); instanceIdInput = UIFactory.CreateInputField(UIRoot, "InstanceIDInput", "ERROR"); GameObject uIRoot3 = ((UIModel)instanceIdInput).UIRoot; num3 = 25; UIFactory.SetLayoutElement(uIRoot3, (int?)100, num3, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); instanceIdInput.Component.readOnly = true; UIRoot.SetActive(false); return UIRoot; } } } namespace UnityExplorer.UI.Widgets.AutoComplete { public class EnumCompleter : ISuggestionProvider { private bool _enabled = true; private readonly List suggestions = new List(); private readonly HashSet suggestedValues = new HashSet(); private OrderedDictionary enumValues; internal string chosenSuggestion; internal static readonly Dictionary sharedValueToLabel = new Dictionary(4096); public bool Enabled { get { return _enabled; } set { _enabled = value; if (!_enabled) { AutoCompleteModal.Instance.ReleaseOwnership(this); } } } public Type EnumType { get; set; } public InputFieldRef InputField { get; } public bool AnchorToCaretPosition => false; bool ISuggestionProvider.AllowNavigation => false; public event Action SuggestionClicked; public EnumCompleter(Type enumType, InputFieldRef inputField) { EnumType = enumType; InputField = inputField; inputField.OnValueChanged += OnInputFieldChanged; if (EnumType != null) { CacheEnumValues(); } } public void CacheEnumValues() { enumValues = InteractiveEnum.GetEnumValues(EnumType); } private string GetLastSplitInput(string fullInput) { string result = fullInput; int num = fullInput.LastIndexOf(','); if (num >= 0) { num++; result = ((num != fullInput.Length) ? fullInput.Substring(num) : ""); } return result; } public void OnSuggestionClicked(Suggestion suggestion) { chosenSuggestion = suggestion.UnderlyingValue; string lastSplitInput = GetLastSplitInput(InputField.Text); if (lastSplitInput != suggestion.UnderlyingValue) { string text = InputField.Text; if (text.Length > 0) { text = text.Substring(0, InputField.Text.Length - lastSplitInput.Length); } text += suggestion.UnderlyingValue; InputField.Text = text; } this.SuggestionClicked?.Invoke(suggestion); suggestions.Clear(); AutoCompleteModal.Instance.SetSuggestions(suggestions); } public void HelperButtonClicked() { GetSuggestions(""); AutoCompleteModal.TakeOwnership(this); AutoCompleteModal.Instance.SetSuggestions(suggestions); } private void OnInputFieldChanged(string value) { if (Enabled) { if (string.IsNullOrEmpty(value) || GetLastSplitInput(value) == chosenSuggestion) { chosenSuggestion = null; AutoCompleteModal.Instance.ReleaseOwnership(this); } else { GetSuggestions(value); AutoCompleteModal.TakeOwnership(this); AutoCompleteModal.Instance.SetSuggestions(suggestions); } } } private void GetSuggestions(string value) { suggestions.Clear(); suggestedValues.Clear(); if (EnumType == null) { ExplorerCore.LogWarning("Autocompleter Base enum type is null!"); return; } value = GetLastSplitInput(value); for (int i = 0; i < enumValues.Count; i++) { CachedEnumValue cachedEnumValue = (CachedEnumValue)enumValues[i]; if (MiscUtility.ContainsIgnoreCase(cachedEnumValue.Name, value)) { AddSuggestion(cachedEnumValue.Name); } } } private void AddSuggestion(string value) { if (!suggestedValues.Contains(value)) { suggestedValues.Add(value); if (!sharedValueToLabel.ContainsKey(value)) { sharedValueToLabel.Add(value, "" + value + ""); } suggestions.Add(new Suggestion(sharedValueToLabel[value], value)); } } } public interface ISuggestionProvider { InputFieldRef InputField { get; } bool AnchorToCaretPosition { get; } bool AllowNavigation { get; } void OnSuggestionClicked(Suggestion suggestion); } public struct Suggestion { public readonly string DisplayText; public readonly string UnderlyingValue; public Suggestion(string displayText, string underlyingValue) { DisplayText = displayText; UnderlyingValue = underlyingValue; } } public class TypeCompleter : ISuggestionProvider { private bool enabled = true; private readonly bool allowAbstract; private readonly bool allowEnum; private readonly bool allowGeneric; private HashSet allowedTypes; private string pendingInput; private Coroutine getSuggestionsCoroutine; private readonly Stopwatch cacheTypesStopwatch = new Stopwatch(); private readonly List suggestions = new List(); private readonly HashSet suggestedTypes = new HashSet(); private string chosenSuggestion; private readonly List loadingSuggestions = new List { new Suggestion("Loading...", "") }; private static readonly Dictionary shorthandToType = new Dictionary { { "object", typeof(object) }, { "string", typeof(string) }, { "bool", typeof(bool) }, { "byte", typeof(byte) }, { "sbyte", typeof(sbyte) }, { "char", typeof(char) }, { "decimal", typeof(decimal) }, { "double", typeof(double) }, { "float", typeof(float) }, { "int", typeof(int) }, { "uint", typeof(uint) }, { "long", typeof(long) }, { "ulong", typeof(ulong) }, { "short", typeof(short) }, { "ushort", typeof(ushort) }, { "void", typeof(void) } }; internal static readonly Dictionary sharedTypeToLabel = new Dictionary(); public bool Enabled { get { return enabled; } set { enabled = value; if (!enabled) { AutoCompleteModal.Instance.ReleaseOwnership(this); if (getSuggestionsCoroutine != null) { RuntimeHelper.StopCoroutine(getSuggestionsCoroutine); } } } } public InputFieldRef InputField { get; } public bool AnchorToCaretPosition => false; public Type BaseType { get; set; } bool ISuggestionProvider.AllowNavigation => false; public event Action SuggestionClicked; public TypeCompleter(Type baseType, InputFieldRef inputField) : this(baseType, inputField, allowAbstract: true, allowEnum: true, allowGeneric: true) { } public TypeCompleter(Type baseType, InputFieldRef inputField, bool allowAbstract, bool allowEnum, bool allowGeneric) { BaseType = baseType; InputField = inputField; this.allowAbstract = allowAbstract; this.allowEnum = allowEnum; this.allowGeneric = allowGeneric; inputField.OnValueChanged += OnInputFieldChanged; CacheTypes(); } public void OnSuggestionClicked(Suggestion suggestion) { chosenSuggestion = suggestion.UnderlyingValue; InputField.Text = suggestion.UnderlyingValue; this.SuggestionClicked?.Invoke(suggestion); suggestions.Clear(); AutoCompleteModal.Instance.ReleaseOwnership(this); } public void CacheTypes() { allowedTypes = null; cacheTypesStopwatch.Reset(); cacheTypesStopwatch.Start(); ReflectionUtility.GetImplementationsOf(BaseType, (Action>)OnTypesCached, allowAbstract, allowGeneric, allowEnum); } private void OnTypesCached(HashSet set) { allowedTypes = set; if (pendingInput != null) { GetSuggestions(pendingInput); pendingInput = null; } } private void OnInputFieldChanged(string input) { if (!Enabled) { return; } if (input != chosenSuggestion) { chosenSuggestion = null; } if (string.IsNullOrEmpty(input) || input == chosenSuggestion) { if (getSuggestionsCoroutine != null) { RuntimeHelper.StopCoroutine(getSuggestionsCoroutine); } AutoCompleteModal.Instance.ReleaseOwnership(this); } else { GetSuggestions(input); } } private void GetSuggestions(string input) { if (allowedTypes == null) { if (pendingInput != null) { AutoCompleteModal.TakeOwnership(this); AutoCompleteModal.Instance.SetSuggestions(loadingSuggestions); } pendingInput = input; } else { if (getSuggestionsCoroutine != null) { RuntimeHelper.StopCoroutine(getSuggestionsCoroutine); } getSuggestionsCoroutine = RuntimeHelper.StartCoroutine(GetSuggestionsAsync(input)); } } private IEnumerator GetSuggestionsAsync(string input) { suggestions.Clear(); suggestedTypes.Clear(); AutoCompleteModal.TakeOwnership(this); AutoCompleteModal.Instance.SetSuggestions(suggestions); if (shorthandToType.TryGetValue(input, out var value) && allowedTypes.Contains(value)) { AddSuggestion(value); } foreach (KeyValuePair item in shorthandToType) { if (allowedTypes.Contains(item.Value) && item.Key.StartsWith(input, StringComparison.InvariantCultureIgnoreCase)) { AddSuggestion(item.Value); } } Type typeByName = ReflectionUtility.GetTypeByName(input); if ((object)typeByName != null && allowedTypes.Contains(typeByName)) { AddSuggestion(typeByName); } if (!suggestions.Any()) { AutoCompleteModal.Instance.SetSuggestions(loadingSuggestions, jumpToTop: false); } else { AutoCompleteModal.Instance.SetSuggestions(suggestions, jumpToTop: false); } Stopwatch sw = new Stopwatch(); sw.Start(); foreach (Type entry in allowedTypes) { if (AutoCompleteModal.CurrentHandler == null) { yield break; } if (sw.ElapsedMilliseconds > 10) { yield return null; if (suggestions.Any()) { AutoCompleteModal.Instance.SetSuggestions(suggestions, jumpToTop: false); } sw.Reset(); sw.Start(); } if (MiscUtility.ContainsIgnoreCase(entry.FullName, input)) { AddSuggestion(entry); } } AutoCompleteModal.Instance.SetSuggestions(suggestions, jumpToTop: false); } private void AddSuggestion(Type type) { if (!suggestedTypes.Contains(type.FullName)) { suggestedTypes.Add(type.FullName); if (!sharedTypeToLabel.ContainsKey(type.FullName)) { sharedTypeToLabel.Add(type.FullName, SignatureHighlighter.Parse(type, true, (MemberInfo)null)); } suggestions.Add(new Suggestion(sharedTypeToLabel[type.FullName], type.FullName)); } } } } namespace UnityExplorer.UI.Panels { public class AutoCompleteModal : UEPanel { private const float MIN_X = 0.42f; private const float MAX_Y = 0.6f; public static ButtonListHandler buttonListDataHandler; public static ScrollPool scrollPool; private static GameObject navigationTipRow; private static List Suggestions = new List(); private static int SelectedIndex = 0; private static float timeOfLastNavHold = -1f; private readonly Color selectedSuggestionColor = new Color(0.1764706f, 0.29411766f, 16f / 51f); private readonly Color inactiveSuggestionColor = new Color(0.11f, 0.11f, 0.11f); private bool setFirstCell; private int lastCaretPosition; private Vector3 lastInputPosition; public static AutoCompleteModal Instance => UIManager.GetPanel(UIManager.Panels.AutoCompleter); public override string Name => "AutoCompleter"; public override UIManager.Panels PanelType => UIManager.Panels.AutoCompleter; public override int MinWidth => 100; public override int MinHeight => 25; public override Vector2 DefaultAnchorMin => new Vector2(0.42f, 0.4f); public override Vector2 DefaultAnchorMax => new Vector2(0.68f, 0.6f); public override bool CanDragAndResize => true; public override bool ShouldSaveActiveState => false; public override bool NavButtonWanted => false; public static ISuggestionProvider CurrentHandler { get; private set; } public static Suggestion SelectedSuggestion => Suggestions[SelectedIndex]; public static bool Suggesting(ISuggestionProvider handler) { if (CurrentHandler == handler) { return ((UIModel)Instance).UIRoot.activeSelf; } return false; } public AutoCompleteModal(UIBase owner) : base(owner) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) UIManager.UiBase.Panels.OnPanelsReordered += UIPanel_OnPanelsReordered; UIManager.UiBase.Panels.OnClickedOutsidePanels += AutoCompleter_OnClickedOutsidePanels; } public static void TakeOwnership(ISuggestionProvider provider) { CurrentHandler = provider; navigationTipRow.SetActive(provider.AllowNavigation); } public void ReleaseOwnership(ISuggestionProvider provider) { if (CurrentHandler != null && CurrentHandler == provider) { Suggestions.Clear(); CurrentHandler = null; ((UIModel)this).UIRoot.SetActive(false); } } public void SetSuggestions(List suggestions, bool jumpToTop = true) { Suggestions = suggestions; if (jumpToTop) { SelectedIndex = 0; if (scrollPool.DataSource.ItemCount > 0) { scrollPool.JumpToIndex(0, (Action)null); } } if (!Suggestions.Any()) { ((PanelBase)this).UIRoot.SetActive(false); return; } ((PanelBase)this).UIRoot.SetActive(true); ((PanelBase)this).UIRoot.transform.SetAsLastSibling(); buttonListDataHandler.RefreshData(); scrollPool.Refresh(true, jumpToTop); } public static bool CheckNavigation(ISuggestionProvider handler) { if (!Suggesting(handler)) { return false; } bool key = InputManager.GetKey((KeyCode)273); bool key2 = InputManager.GetKey((KeyCode)274); if (key || key2) { if (key) { if (InputManager.GetKeyDown((KeyCode)273)) { SetSelectedSuggestion(SelectedIndex - 1); timeOfLastNavHold = Time.realtimeSinceStartup + 0.3f; } else if (UnityHelpers.OccuredEarlierThan(timeOfLastNavHold, 0.05f)) { SetSelectedSuggestion(SelectedIndex - 1); timeOfLastNavHold = Time.realtimeSinceStartup; } } else if (InputManager.GetKeyDown((KeyCode)274)) { SetSelectedSuggestion(SelectedIndex + 1); timeOfLastNavHold = Time.realtimeSinceStartup + 0.3f; } else if (UnityHelpers.OccuredEarlierThan(timeOfLastNavHold, 0.05f)) { SetSelectedSuggestion(SelectedIndex + 1); timeOfLastNavHold = Time.realtimeSinceStartup; } return true; } return !UnityHelpers.OccuredEarlierThan(timeOfLastNavHold, 0.2f); } public static bool CheckEnter(ISuggestionProvider handler) { if (Suggesting(handler)) { return InputManager.GetKeyDown((KeyCode)13); } return false; } public static bool CheckEscape(ISuggestionProvider handler) { if (Suggesting(handler)) { return InputManager.GetKeyDown((KeyCode)27); } return false; } private static void SetSelectedSuggestion(int index) { if (index >= 0 && index < Suggestions.Count) { SelectedIndex = index; scrollPool.JumpToIndex(index, (Action)null); } } public override void Update() { if (Object.op_Implicit((Object)(object)((UIModel)this).UIRoot) && ((UIModel)this).UIRoot.activeSelf && Suggestions.Any() && CurrentHandler != null) { if (!((UIModel)CurrentHandler.InputField).UIRoot.activeInHierarchy) { ReleaseOwnership(CurrentHandler); } else { UpdatePosition(); } } } private List GetEntries() { return Suggestions; } private bool ShouldDisplay(Suggestion data, string filter) { return true; } private void OnCellClicked(int dataIndex) { Suggestion suggestion = Suggestions[dataIndex]; CurrentHandler.OnSuggestionClicked(suggestion); } private void SetCell(ButtonCell cell, int index) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (CurrentHandler == null) { ((UIModel)this).UIRoot.SetActive(false); return; } if (index < 0 || index >= Suggestions.Count) { cell.Disable(); return; } Suggestion suggestion = Suggestions[index]; cell.Button.ButtonText.text = suggestion.DisplayText; if (CurrentHandler.AllowNavigation && index == SelectedIndex && setFirstCell) { RuntimeHelper.SetColorBlock((Selectable)(object)cell.Button.Component, (Color?)selectedSuggestionColor, (Color?)null, (Color?)null, (Color?)null); } else { RuntimeHelper.SetColorBlock((Selectable)(object)cell.Button.Component, (Color?)inactiveSuggestionColor, (Color?)null, (Color?)null, (Color?)null); } setFirstCell = true; } internal void UpdatePosition() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (CurrentHandler == null) { return; } InputFieldRef inputField = CurrentHandler.InputField; if (inputField.Component.caretPosition == lastCaretPosition && ((UIModel)inputField).UIRoot.transform.position == lastInputPosition) { return; } Rect rect; if (CurrentHandler.AnchorToCaretPosition) { if (!inputField.Component.isFocused) { return; } TextGenerator val = (TextGenerator)typeof(InputField).GetProperty("cachedInputTextGenerator", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(inputField.Component, null); int index = Math.Max(0, Math.Min(val.characterCount - 1, inputField.Component.caretPosition)); Vector3 val2 = Vector2.op_Implicit(val.characters[index].cursorPos); val2 = ((UIModel)inputField).UIRoot.transform.TransformPoint(val2); Vector3 val3 = val2; rect = inputField.Transform.rect; float num = ((Rect)(ref rect)).width * 0.5f; rect = inputField.Transform.rect; val2 = val3 + new Vector3(num, 0f - ((Rect)(ref rect)).height * 0.5f, 0f); ((PanelBase)this).uiRoot.transform.position = new Vector3(val2.x + 10f, val2.y - 30f, 0f); } else { Transform transform = ((PanelBase)this).uiRoot.transform; Vector3 position = ((Transform)inputField.Transform).position; rect = inputField.Transform.rect; transform.position = position + new Vector3(0f - ((Rect)(ref rect)).width / 2f + 10f, -20f, 0f); } lastInputPosition = ((UIModel)inputField).UIRoot.transform.position; lastCaretPosition = inputField.Component.caretPosition; ((PanelBase)this).Dragger.OnEndResize(); } private void AutoCompleter_OnClickedOutsidePanels() { if (Object.op_Implicit((Object)(object)((UIModel)this).UIRoot) && ((UIModel)this).UIRoot.activeInHierarchy) { if (CurrentHandler != null) { ReleaseOwnership(CurrentHandler); } else { ((UIModel)this).UIRoot.SetActive(false); } } } private void UIPanel_OnPanelsReordered() { if (Object.op_Implicit((Object)(object)((UIModel)this).UIRoot) && ((UIModel)this).UIRoot.activeInHierarchy && ((UIModel)this).UIRoot.transform.GetSiblingIndex() != UIManager.UiBase.Panels.PanelHolder.transform.childCount - 1) { if (CurrentHandler != null) { ReleaseOwnership(CurrentHandler); } else { ((UIModel)this).UIRoot.SetActive(false); } } } public override void OnFinishResize() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) float num = ((PanelBase)this).Rect.anchorMin.x - 0.42f; float num2 = ((PanelBase)this).Rect.anchorMax.y - 0.6f; if (num != 0f || num2 != 0f) { ((PanelBase)this).Rect.anchorMin = new Vector2(0.42f, ((PanelBase)this).Rect.anchorMin.y - num2); ((PanelBase)this).Rect.anchorMax = new Vector2(((PanelBase)this).Rect.anchorMax.x - num, 0.6f); } base.OnFinishResize(); } protected override void ConstructPanelContent() { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) ((PanelBase)this).TitleBar.gameObject.SetActive(false); buttonListDataHandler = new ButtonListHandler(scrollPool, (Func>)GetEntries, (Action)SetCell, (Func)ShouldDisplay, (Action)OnCellClicked); GameObject val = default(GameObject); GameObject val2 = default(GameObject); scrollPool = UIFactory.CreateScrollPool(((PanelBase)this).ContentRoot, "AutoCompleter", ref val, ref val2, (Color?)null); scrollPool.Initialize((ICellPoolDataSource)(object)buttonListDataHandler, (Action)null); GameObject obj = val; int? num = 9999; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, (int?)null, num, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(val2, (bool?)true, (bool?)false, (bool?)true, (bool?)false, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); navigationTipRow = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "BottomRow", true, true, true, true, 0, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj2 = navigationTipRow; num = 20; int? num2 = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.CreateLabel(navigationTipRow, "HelpText", "Up/Down to select, Enter to use, Esc to close", (TextAnchor)3, Color.grey, false, 13); ((UIModel)this).UIRoot.SetActive(false); } } public class ClipboardPanel : UEPanel { private static Text CurrentPasteLabel; public static object Current { get; private set; } public override string Name => "Clipboard"; public override UIManager.Panels PanelType => UIManager.Panels.Clipboard; public override int MinWidth => 500; public override int MinHeight => 95; public override Vector2 DefaultAnchorMin => new Vector2(0.1f, 0.05f); public override Vector2 DefaultAnchorMax => new Vector2(0.4f, 0.15f); public override bool CanDragAndResize => true; public override bool NavButtonWanted => true; public override bool ShouldSaveActiveState => true; public override bool ShowByDefault => true; public ClipboardPanel(UIBase owner) : base(owner) { } public static void Copy(object obj) { Current = obj; Notification.ShowMessage("Copied!"); UpdateCurrentPasteInfo(); } public static bool TryPaste(Type targetType, out object paste) { paste = Current; object current = Current; Type type = ((current != null) ? ReflectionExtensions.GetActualType(current) : null); if (Current != null && !targetType.IsAssignableFrom(type)) { Notification.ShowMessage("Cannot assign '" + type.Name + "' to '" + targetType.Name + "'!"); return false; } Notification.ShowMessage("Pasted!"); return true; } public static void ClearClipboard() { Current = null; UpdateCurrentPasteInfo(); } private static void UpdateCurrentPasteInfo() { CurrentPasteLabel.text = ToStringUtility.ToStringWithType(Current, typeof(object), false); } private static void InspectClipboard() { if (UnityHelpers.IsNullOrDestroyed(Current, true)) { Notification.ShowMessage("Cannot inspect a null or destroyed object!"); } else { InspectorManager.Inspect(Current); } } public override void SetDefaultSizeAndPosition() { base.SetDefaultSizeAndPosition(); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)0, (float)((PanelBase)this).MinWidth); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)1, (float)((PanelBase)this).MinHeight); } protected override void ConstructPanelContent() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) ((Graphic)((UIModel)this).UIRoot.GetComponent()).color = new Color(0.1f, 0.1f, 0.1f); GameObject obj = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "FirstRow", false, false, true, true, 5, new Vector4(2f, 2f, 2f, 2f), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null); int? num = 25; int? num2 = 999; UIFactory.SetLayoutElement(obj, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(obj, "CurrentPasteTitle", "Current paste:", (TextAnchor)3, Color.grey, true, 14)).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)100, num2, (int?)999, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj2 = UIFactory.CreateButton(obj, "ClearPasteButton", "Clear Clipboard", (Color?)null); UIFactory.SetLayoutElement(((Component)obj2.Component).gameObject, (int?)120, (int?)25, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, (Action)delegate { Copy(null); }); GameObject contentRoot = ((PanelBase)this).ContentRoot; Vector4 val = new Vector4(2f, 2f, 2f, 2f); TextAnchor? val2 = (TextAnchor)1; GameObject obj3 = UIFactory.CreateHorizontalGroup(contentRoot, "SecondRow", false, false, true, true, 0, val, default(Color), val2); CurrentPasteLabel = UIFactory.CreateLabel(obj3, "CurrentPasteInfo", "not set", (TextAnchor)0, default(Color), true, 14); GameObject gameObject2 = ((Component)CurrentPasteLabel).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)100, num2, (int?)999, (int?)999, (int?)null, (int?)null, (bool?)null); UpdateCurrentPasteInfo(); ButtonRef obj4 = UIFactory.CreateButton(obj3, "InspectButton", "Inspect", (Color?)null); GameObject gameObject3 = ((Component)obj4.Component).gameObject; num2 = 25; num = 0; UIFactory.SetLayoutElement(gameObject3, (int?)80, num2, (int?)0, num, (int?)null, (int?)null, (bool?)null); obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, new Action(InspectClipboard)); } } public class CSConsolePanel : UEPanel { public Action OnInputChanged; public Action OnResetClicked; public Action OnCompileClicked; public Action OnDropdownChanged; public Action OnCtrlRToggled; public Action OnSuggestionsToggled; public Action OnAutoIndentToggled; public Action OnPanelResized; public override string Name => "C# Console"; public override UIManager.Panels PanelType => UIManager.Panels.CSConsole; public override int MinWidth => 750; public override int MinHeight => 300; public override Vector2 DefaultAnchorMin => new Vector2(0.4f, 0.175f); public override Vector2 DefaultAnchorMax => new Vector2(0.85f, 0.925f); public InputFieldScroller InputScroller { get; private set; } public InputFieldRef Input => InputScroller.InputField; public Text InputText { get; private set; } public Text HighlightText { get; private set; } public Text LineNumberText { get; private set; } public Dropdown Dropdown { get; private set; } public CSConsolePanel(UIBase owner) : base(owner) { } private void InvokeOnValueChanged(string value) { if (value.Length == 16000) { ExplorerCore.LogWarning($"Reached maximum InputField character length! ({16000})"); } OnInputChanged?.Invoke(value); } public override void Update() { ((UIBehaviourModel)this).Update(); ConsoleController.Update(); } public override void OnFinishResize() { OnPanelResized?.Invoke(); } protected override void ConstructPanelContent() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Unknown result type (might be due to invalid IL or missing references) //IL_07b2: Unknown result type (might be due to invalid IL or missing references) //IL_07b8: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_07de: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_081b: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "ToggleRow", false, false, true, true, 5, new Vector4(8f, 8f, 10f, 5f), default(Color), (TextAnchor?)(TextAnchor)3); int? num = 25; int? num2 = 0; int? num3 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null); ButtonRef obj2 = UIFactory.CreateButton(obj, "CompileButton", "Compile", (Color?)new Color(0.33f, 0.5f, 0.33f)); GameObject gameObject = ((Component)obj2.Component).gameObject; num3 = 28; int? num4 = 130; int? num5 = num3; num2 = 0; UIFactory.SetLayoutElement(gameObject, num4, num5, (int?)null, num2, (int?)null, (int?)null, (bool?)null); obj2.ButtonText.fontSize = 15; obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, (Action)delegate { OnCompileClicked?.Invoke(); }); ButtonRef obj3 = UIFactory.CreateButton(obj, "ResetButton", "Refresh", (Color?)new Color(0.33f, 0.33f, 0.33f)); GameObject gameObject2 = ((Component)obj3.Component).gameObject; num2 = 28; int? num6 = 80; int? num7 = num2; num3 = 0; UIFactory.SetLayoutElement(gameObject2, num6, num7, (int?)null, num3, (int?)null, (int?)null, (bool?)null); obj3.ButtonText.fontSize = 15; obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, (Action)delegate { OnResetClicked?.Invoke(); }); Dropdown dropdown = default(Dropdown); GameObject obj4 = UIFactory.CreateDropdown(obj, "HelpDropdown", ref dropdown, "Help", 14, (Action)null, (string[])null); num3 = 25; UIFactory.SetLayoutElement(obj4, (int?)100, num3, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); Dropdown = dropdown; ((UnityEvent)(object)Dropdown.onValueChanged).AddListener((UnityAction)delegate(int obj8) { OnDropdownChanged?.Invoke(obj8); }); Toggle val = default(Toggle); Text val2 = default(Text); GameObject obj5 = UIFactory.CreateToggle(obj, "CtrlRToggle", ref val, ref val2, default(Color), 20, 20); int? num8 = 150; num3 = 0; UIFactory.SetLayoutElement(obj5, num8, (int?)25, num3, (int?)null, (int?)null, (int?)null, (bool?)null); val2.alignment = (TextAnchor)0; val2.text = "Compile on Ctrl+R"; ((UnityEvent)(object)val.onValueChanged).AddListener((UnityAction)delegate(bool obj8) { OnCtrlRToggled?.Invoke(obj8); }); Toggle val3 = default(Toggle); Text val4 = default(Text); GameObject obj6 = UIFactory.CreateToggle(obj, "SuggestionToggle", ref val3, ref val4, default(Color), 20, 20); int? num9 = 120; num3 = 0; UIFactory.SetLayoutElement(obj6, num9, (int?)25, num3, (int?)null, (int?)null, (int?)null, (bool?)null); val4.alignment = (TextAnchor)0; val4.text = "Suggestions"; ((UnityEvent)(object)val3.onValueChanged).AddListener((UnityAction)delegate(bool obj8) { OnSuggestionsToggled?.Invoke(obj8); }); Toggle val5 = default(Toggle); Text val6 = default(Text); GameObject obj7 = UIFactory.CreateToggle(obj, "IndentToggle", ref val5, ref val6, default(Color), 20, 20); int? num10 = 120; num3 = 0; UIFactory.SetLayoutElement(obj7, num10, (int?)25, num3, (int?)null, (int?)null, (int?)null, (bool?)null); val6.alignment = (TextAnchor)0; val6.text = "Auto-indent"; ((UnityEvent)(object)val5.onValueChanged).AddListener((UnityAction)delegate(bool obj8) { OnAutoIndentToggled?.Invoke(obj8); }); GameObject val7 = UIFactory.CreateUIObject("InputGroup", ((PanelBase)this).ContentRoot, default(Vector2)); num3 = 9999; num2 = 9999; UIFactory.SetLayoutElement(val7, (int?)null, (int?)null, num3, num2, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(val7, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); ((Graphic)val7.AddComponent()).color = Color.white; val7.AddComponent().showMaskGraphic = false; GameObject val8 = UIFactory.CreateUIObject("LinesHolder", val7, default(Vector2)); RectTransform linesRect = val8.GetComponent(); linesRect.pivot = new Vector2(0f, 1f); linesRect.anchorMin = new Vector2(0f, 0f); linesRect.anchorMax = new Vector2(0f, 1f); linesRect.sizeDelta = new Vector2(0f, 305000f); linesRect.SetInsetAndSizeFromParentEdge((Edge)0, 0f, 50f); ((Graphic)val8.AddComponent()).color = new Color(0.05f, 0.05f, 0.05f); UIFactory.SetLayoutGroup(val8, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); LineNumberText = UIFactory.CreateLabel(val8, "LineNumbers", "1", (TextAnchor)1, Color.grey, true, 16); LineNumberText.font = UniversalUI.ConsoleFont; int num11 = 16; InputFieldScroller inputScroller = default(InputFieldScroller); GameObject val9 = UIFactory.CreateScrollInputField(val7, "ConsoleInput", "// Welcome to the UnityExplorer C# Console!\r\n\r\n// It is recommended to use the Log panel (or a console log window) while using this tool.\r\n// Use the Help dropdown to see detailed examples of how to use the console.\r\n\r\n// To execute a script automatically on startup, put the script at 'sinai-dev-UnityExplorer\\Scripts\\startup.cs'", ref inputScroller, num11, default(Color)); InputScroller = inputScroller; ConsoleController.DefaultInputFieldAlpha = Input.Component.selectionColor.a; Input.OnValueChanged += InvokeOnValueChanged; ((Component)linesRect).transform.SetParent(val9.transform.Find("Viewport"), false); ((UnityEvent)(object)inputScroller.Slider.Scrollbar.onValueChanged).AddListener((UnityAction)delegate { SetLinesPosition(); }); ((UnityEvent)(object)inputScroller.Slider.Slider.onValueChanged).AddListener((UnityAction)delegate { SetLinesPosition(); }); InputText = Input.Component.textComponent; InputText.supportRichText = false; ((Graphic)InputText).color = Color.clear; Input.Component.customCaretColor = true; Input.Component.caretColor = Color.white; Input.PlaceholderText.fontSize = num11; GameObject val10 = UIFactory.CreateUIObject("HighlightText", ((Component)InputText).gameObject, default(Vector2)); RectTransform component = val10.GetComponent(); component.pivot = new Vector2(0f, 1f); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; HighlightText = val10.AddComponent(); ((Graphic)HighlightText).color = Color.white; HighlightText.supportRichText = true; HighlightText.fontSize = num11; InputText.font = UniversalUI.ConsoleFont; Input.PlaceholderText.font = UniversalUI.ConsoleFont; HighlightText.font = UniversalUI.ConsoleFont; RuntimeHelper.StartCoroutine(DelayedLayoutSetup()); void SetLinesPosition() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) linesRect.anchoredPosition = new Vector2(linesRect.anchoredPosition.x, inputScroller.ContentRect.anchoredPosition.y); } } private IEnumerator DelayedLayoutSetup() { yield return null; SetInputLayout(); } public void SetInputLayout() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Input.Transform.offsetMin = new Vector2(52f, Input.Transform.offsetMin.y); Input.Transform.offsetMax = new Vector2(2f, Input.Transform.offsetMax.y); } } internal class FreeCamPanel : UEPanel { internal static bool inFreeCamMode; internal static bool usingGameCamera; internal static Camera ourCamera; internal static Camera lastMainCamera; internal static FreeCamBehaviour freeCamScript; internal static float desiredMoveSpeed = 10f; internal static Vector3 originalCameraPosition; internal static Quaternion originalCameraRotation; internal static Vector3? currentUserCameraPosition; internal static Quaternion? currentUserCameraRotation; internal static Vector3 previousMousePosition; internal static Vector3 lastSetCameraPosition; private static ButtonRef startStopButton; private static Toggle useGameCameraToggle; private static InputFieldRef positionInput; private static InputFieldRef moveSpeedInput; private static ButtonRef inspectButton; public override string Name => "Freecam"; public override UIManager.Panels PanelType => UIManager.Panels.Freecam; public override int MinWidth => 400; public override int MinHeight => 320; public override Vector2 DefaultAnchorMin => new Vector2(0.4f, 0.4f); public override Vector2 DefaultAnchorMax => new Vector2(0.6f, 0.6f); public override bool NavButtonWanted => true; public override bool ShouldSaveActiveState => true; public FreeCamPanel(UIBase owner) : base(owner) { } internal static void BeginFreecam() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) inFreeCamMode = true; previousMousePosition = InputManager.MousePosition; CacheMainCamera(); SetupFreeCamera(); inspectButton.GameObject.SetActive(true); } private static void CacheMainCamera() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main)) { lastMainCamera = main; originalCameraPosition = ((Component)main).transform.position; originalCameraRotation = ((Component)main).transform.rotation; if (!currentUserCameraPosition.HasValue) { currentUserCameraPosition = ((Component)main).transform.position; currentUserCameraRotation = ((Component)main).transform.rotation; } } else { originalCameraRotation = Quaternion.identity; } } private static void SetupFreeCamera() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (useGameCameraToggle.isOn) { if (!Object.op_Implicit((Object)(object)lastMainCamera)) { ExplorerCore.LogWarning("There is no previous Camera found, reverting to default Free Cam."); useGameCameraToggle.isOn = false; } else { usingGameCamera = true; ourCamera = lastMainCamera; } } if (!useGameCameraToggle.isOn) { usingGameCamera = false; if (Object.op_Implicit((Object)(object)lastMainCamera)) { ((Behaviour)lastMainCamera).enabled = false; } } if (!Object.op_Implicit((Object)(object)ourCamera)) { ourCamera = new GameObject("UE_Freecam").AddComponent(); ((Component)ourCamera).gameObject.tag = "MainCamera"; Object.DontDestroyOnLoad((Object)(object)((Component)ourCamera).gameObject); ((Object)((Component)ourCamera).gameObject).hideFlags = (HideFlags)61; } if (!Object.op_Implicit((Object)(object)freeCamScript)) { freeCamScript = ((Component)ourCamera).gameObject.AddComponent(); } ((Component)ourCamera).transform.position = currentUserCameraPosition.Value; ((Component)ourCamera).transform.rotation = currentUserCameraRotation.Value; ((Component)ourCamera).gameObject.SetActive(true); ((Behaviour)ourCamera).enabled = true; } internal static void EndFreecam() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) inFreeCamMode = false; if (usingGameCamera) { ourCamera = null; if (Object.op_Implicit((Object)(object)lastMainCamera)) { ((Component)lastMainCamera).transform.position = originalCameraPosition; ((Component)lastMainCamera).transform.rotation = originalCameraRotation; } } if (Object.op_Implicit((Object)(object)ourCamera)) { ((Component)ourCamera).gameObject.SetActive(false); } else { inspectButton.GameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)freeCamScript)) { Object.Destroy((Object)(object)freeCamScript); freeCamScript = null; } if (Object.op_Implicit((Object)(object)lastMainCamera)) { ((Behaviour)lastMainCamera).enabled = true; } } private static void SetCameraPosition(Vector3 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ourCamera) && !(lastSetCameraPosition == pos)) { ((Component)ourCamera).transform.position = pos; lastSetCameraPosition = pos; } } internal static void UpdatePositionInput() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ourCamera) && !positionInput.Component.isFocused) { lastSetCameraPosition = ((Component)ourCamera).transform.position; positionInput.Text = ParseUtility.ToStringForInput((object)lastSetCameraPosition); } } protected override void ConstructPanelContent() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) startStopButton = UIFactory.CreateButton(((PanelBase)this).ContentRoot, "ToggleButton", "Freecam", (Color?)null); UIFactory.SetLayoutElement(startStopButton.GameObject, (int?)150, (int?)25, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = startStopButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(StartStopButton_OnClick)); SetToggleButtonState(); AddSpacer(5); Text val = default(Text); GameObject obj2 = UIFactory.CreateToggle(((PanelBase)this).ContentRoot, "UseGameCameraToggle", ref useGameCameraToggle, ref val, default(Color), 20, 20); int? num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); ((UnityEvent)(object)useGameCameraToggle.onValueChanged).AddListener((UnityAction)OnUseGameCameraToggled); useGameCameraToggle.isOn = false; val.text = "Use Game Camera?"; AddSpacer(5); ButtonRef obj3 = UIFactory.CreateButton(AddInputField("Position", "Freecam Pos:", "eg. 0 0 0", out positionInput, PositionInput_OnEndEdit), "ResetButton", "Reset", (Color?)null); UIFactory.SetLayoutElement(obj3.GameObject, (int?)70, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(OnResetPosButtonClicked)); AddSpacer(5); AddInputField("MoveSpeed", "Move Speed:", "Default: 1", out moveSpeedInput, MoveSpeedInput_OnEndEdit); moveSpeedInput.Text = desiredMoveSpeed.ToString(); AddSpacer(5); string text = "Controls:\r\n- WASD / Arrows: Movement\r\n- Space / PgUp: Move up\r\n- LeftCtrl / PgDown: Move down\r\n- Right Mouse Button: Free look\r\n- Shift: Super speed"; GameObject gameObject = ((Component)UIFactory.CreateLabel(((PanelBase)this).ContentRoot, "Instructions", text, (TextAnchor)0, default(Color), true, 14)).gameObject; num2 = 9999; num = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, (int?)null, num2, num, (int?)null, (int?)null, (bool?)null); AddSpacer(5); inspectButton = UIFactory.CreateButton(((PanelBase)this).ContentRoot, "InspectButton", "Inspect Free Camera", (Color?)null); GameObject gameObject2 = inspectButton.GameObject; num = 9999; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj4 = inspectButton; obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, (Action)delegate { InspectorManager.Inspect(ourCamera); }); inspectButton.GameObject.SetActive(false); AddSpacer(5); } private void AddSpacer(int height) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UIFactory.CreateUIObject("Spacer", ((PanelBase)this).ContentRoot, default(Vector2)); int? num = height; int? num2 = 0; UIFactory.SetLayoutElement(obj, (int?)null, num, (int?)null, num2, (int?)null, (int?)null, (bool?)null); } private GameObject AddInputField(string name, string labelText, string placeHolder, out InputFieldRef inputField, Action onInputEndEdit) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, name + "_Group", false, false, true, true, 3, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null); UIFactory.SetLayoutElement(((Component)UIFactory.CreateLabel(val, name + "_Label", labelText, (TextAnchor)3, default(Color), true, 14)).gameObject, (int?)100, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); inputField = UIFactory.CreateInputField(val, name + "_Input", placeHolder); UIFactory.SetLayoutElement(inputField.GameObject, (int?)125, (int?)25, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); MonoExtensions.AddListener(UnityHelpers.GetOnEndEdit(inputField.Component), onInputEndEdit); return val; } private void StartStopButton_OnClick() { EventSystemHelper.SetSelectedGameObject((GameObject)null); if (inFreeCamMode) { EndFreecam(); } else { BeginFreecam(); } SetToggleButtonState(); } private void SetToggleButtonState() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (inFreeCamMode) { RuntimeHelper.SetColorBlockAuto((Selectable)(object)startStopButton.Component, new Color(0.4f, 0.2f, 0.2f)); startStopButton.ButtonText.text = "End Freecam"; } else { RuntimeHelper.SetColorBlockAuto((Selectable)(object)startStopButton.Component, new Color(0.2f, 0.4f, 0.2f)); startStopButton.ButtonText.text = "Begin Freecam"; } } private void OnUseGameCameraToggled(bool value) { EventSystemHelper.SetSelectedGameObject((GameObject)null); if (inFreeCamMode) { EndFreecam(); BeginFreecam(); } } private void OnResetPosButtonClicked() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) currentUserCameraPosition = originalCameraPosition; currentUserCameraRotation = originalCameraRotation; if (inFreeCamMode && Object.op_Implicit((Object)(object)ourCamera)) { ((Component)ourCamera).transform.position = currentUserCameraPosition.Value; ((Component)ourCamera).transform.rotation = currentUserCameraRotation.Value; } positionInput.Text = ParseUtility.ToStringForInput((object)originalCameraPosition); } private void PositionInput_OnEndEdit(string input) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) EventSystemHelper.SetSelectedGameObject((GameObject)null); Vector3 cameraPosition = default(Vector3); Exception ex = default(Exception); if (!ParseUtility.TryParse(input, ref cameraPosition, ref ex)) { ExplorerCore.LogWarning("Could not parse position to Vector3: " + ReflectionExtensions.ReflectionExToString(ex, true)); UpdatePositionInput(); } else { SetCameraPosition(cameraPosition); } } private void MoveSpeedInput_OnEndEdit(string input) { EventSystemHelper.SetSelectedGameObject((GameObject)null); float num = default(float); Exception ex = default(Exception); if (!ParseUtility.TryParse(input, ref num, ref ex)) { ExplorerCore.LogWarning("Could not parse value: " + ReflectionExtensions.ReflectionExToString(ex, true)); moveSpeedInput.Text = desiredMoveSpeed.ToString(); } else { desiredMoveSpeed = num; } } } internal class FreeCamBehaviour : MonoBehaviour { internal void Update() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (!FreeCamPanel.inFreeCamMode) { return; } if (!Object.op_Implicit((Object)(object)FreeCamPanel.ourCamera)) { FreeCamPanel.EndFreecam(); return; } Transform transform = ((Component)FreeCamPanel.ourCamera).transform; FreeCamPanel.currentUserCameraPosition = transform.position; FreeCamPanel.currentUserCameraRotation = transform.rotation; float num = FreeCamPanel.desiredMoveSpeed * Time.deltaTime; if (InputManager.GetKey((KeyCode)304) || InputManager.GetKey((KeyCode)303)) { num *= 10f; } if (InputManager.GetKey((KeyCode)276) || InputManager.GetKey((KeyCode)97)) { transform.position += transform.right * -1f * num; } if (InputManager.GetKey((KeyCode)275) || InputManager.GetKey((KeyCode)100)) { transform.position += transform.right * num; } if (InputManager.GetKey((KeyCode)273) || InputManager.GetKey((KeyCode)119)) { transform.position += transform.forward * num; } if (InputManager.GetKey((KeyCode)274) || InputManager.GetKey((KeyCode)115)) { transform.position += transform.forward * -1f * num; } if (InputManager.GetKey((KeyCode)32) || InputManager.GetKey((KeyCode)280)) { transform.position += transform.up * num; } if (InputManager.GetKey((KeyCode)306) || InputManager.GetKey((KeyCode)281)) { transform.position += transform.up * -1f * num; } if (InputManager.GetMouseButton(1)) { Vector3 val = InputManager.MousePosition - FreeCamPanel.previousMousePosition; float num2 = transform.localEulerAngles.y + val.x * 0.3f; float num3 = transform.localEulerAngles.x - val.y * 0.3f; transform.localEulerAngles = new Vector3(num3, num2, 0f); } FreeCamPanel.UpdatePositionInput(); FreeCamPanel.previousMousePosition = InputManager.MousePosition; } } public class HookManagerPanel : UEPanel { public enum Pages { ClassMethodSelector, HookSourceEditor, GenericArgsSelector } public static HookCreator hookCreator; public static HookList hookList; public static GenericConstructorWidget genericArgsHandler; public static HookManagerPanel Instance { get; private set; } public override UIManager.Panels PanelType => UIManager.Panels.HookManager; public override string Name => "Hooks"; public override bool ShowByDefault => false; public override int MinWidth => 400; public override int MinHeight => 400; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f); public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f); public Pages CurrentPage { get; private set; } public HookManagerPanel(UIBase owner) : base(owner) { } public void SetPage(Pages page) { switch (page) { case Pages.ClassMethodSelector: HookCreator.AddHooksRoot.SetActive(true); HookCreator.EditorRoot.SetActive(false); genericArgsHandler.UIRoot.SetActive(false); break; case Pages.HookSourceEditor: HookCreator.AddHooksRoot.SetActive(false); HookCreator.EditorRoot.SetActive(true); genericArgsHandler.UIRoot.SetActive(false); break; case Pages.GenericArgsSelector: HookCreator.AddHooksRoot.SetActive(false); HookCreator.EditorRoot.SetActive(false); genericArgsHandler.UIRoot.SetActive(true); break; } } public override void SetDefaultSizeAndPosition() { base.SetDefaultSizeAndPosition(); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)0, (float)((PanelBase)this).MinWidth); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)1, (float)((PanelBase)this).MinHeight); } protected override void ConstructPanelContent() { Instance = this; hookList = new HookList(); hookCreator = new HookCreator(); genericArgsHandler = new GenericConstructorWidget(); UIFactory.SetLayoutGroup(((PanelBase)this).ContentRoot, (bool?)true, (bool?)false, (bool?)null, (bool?)null, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject gameObject = ((PanelBase)this).ContentRoot.gameObject; int? num = 300; int? num2 = 9999; int? num3 = 9999; UIFactory.SetLayoutElement(gameObject, num, (int?)null, num2, num3, (int?)null, (int?)null, (bool?)null); hookList.ConstructUI(((PanelBase)this).ContentRoot); GameObject contentRoot = ((PanelBase)this).ContentRoot; int? num4 = 300; num3 = 9999; num2 = 9999; UIFactory.SetLayoutElement(contentRoot, num4, (int?)null, num3, num2, (int?)null, (int?)null, (bool?)null); hookCreator.ConstructAddHooksView(((PanelBase)this).ContentRoot); hookCreator.ConstructEditor(((PanelBase)this).ContentRoot); HookCreator.EditorRoot.SetActive(false); genericArgsHandler.ConstructUI(((PanelBase)this).ContentRoot); genericArgsHandler.UIRoot.SetActive(false); } } public class InspectorPanel : UEPanel { public GameObject NavbarHolder; public Dropdown MouseInspectDropdown; public GameObject ContentHolder; public RectTransform ContentRect; public static InspectorPanel Instance { get; private set; } public override string Name => "Inspector"; public override UIManager.Panels PanelType => UIManager.Panels.Inspector; public override bool ShouldSaveActiveState => false; public override int MinWidth => 810; public override int MinHeight => 350; public override Vector2 DefaultAnchorMin => new Vector2(0.35f, 0.175f); public override Vector2 DefaultAnchorMax => new Vector2(0.8f, 0.925f); public static float CurrentPanelWidth { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((PanelBase)Instance).Rect.rect; return ((Rect)(ref rect)).width; } } public static float CurrentPanelHeight { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((PanelBase)Instance).Rect.rect; return ((Rect)(ref rect)).height; } } public InspectorPanel(UIBase owner) : base(owner) { Instance = this; } public override void Update() { InspectorManager.Update(); } public override void OnFinishResize() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) base.OnFinishResize(); Rect rect = ((PanelBase)this).Rect.rect; InspectorManager.PanelWidth = ((Rect)(ref rect)).width; rect = ((PanelBase)this).Rect.rect; InspectorManager.OnPanelResized(((Rect)(ref rect)).width); } protected override void ConstructPanelContent() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)((PanelBase)this).TitleBar.transform.Find("CloseHolder")).gameObject; GameObject obj = UIFactory.CreateDropdown(gameObject, "MouseInspectDropdown", ref MouseInspectDropdown, "Mouse Inspect", 14, (Action)MouseInspector.OnDropdownSelect, (string[])null); int? num = 25; UIFactory.SetLayoutElement(obj, (int?)140, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); MouseInspectDropdown.options.Add(new OptionData("Mouse Inspect")); MouseInspectDropdown.options.Add(new OptionData("World")); MouseInspectDropdown.options.Add(new OptionData("UI")); obj.transform.SetSiblingIndex(0); ButtonRef val = UIFactory.CreateButton(gameObject.gameObject, "CloseAllBtn", "Close All", (Color?)new Color(0.3f, 0.2f, 0.2f)); GameObject gameObject2 = ((Component)val.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject2, (int?)80, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ((Component)val.Component).transform.SetSiblingIndex(((Component)val.Component).transform.GetSiblingIndex() - 1); val.OnClick = (Action)System.Delegate.Combine(val.OnClick, new Action(InspectorManager.CloseAllTabs)); GameObject contentRoot = ((PanelBase)this).ContentRoot; bool? flag = true; bool? flag2 = true; bool? flag3 = true; bool? flag4 = true; int? num2 = 4; num = 5; int? num3 = 5; UIFactory.SetLayoutGroup(contentRoot, flag, flag2, flag3, flag4, num2, (int?)null, (int?)null, num, num3, (TextAnchor?)null); NavbarHolder = UIFactory.CreateGridGroup(((PanelBase)this).ContentRoot, "Navbar", new Vector2(200f, 22f), new Vector2(4f, 4f), new Color(0.05f, 0.05f, 0.05f)); NavbarHolder.AddComponent().verticalFit = (FitMode)2; ContentHolder = UIFactory.CreateVerticalGroup(((PanelBase)this).ContentRoot, "ContentHolder", true, true, true, true, 0, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); GameObject contentHolder = ContentHolder; num3 = 9999; UIFactory.SetLayoutElement(contentHolder, (int?)null, (int?)null, (int?)null, num3, (int?)null, (int?)null, (bool?)null); ContentRect = ContentHolder.GetComponent(); ((UIModel)this).SetActive(false); } } public class LogPanel : UEPanel, ICellPoolDataSource { public struct LogInfo { public string message; public LogType type; public LogInfo(string message, LogType type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) this.message = message; this.type = type; } } private static readonly List Logs = new List(); private static string CurrentStreamPath; private static ScrollPool logScrollPool; private static bool DoneScrollPoolInit; private static readonly Dictionary logColors = new Dictionary { { (LogType)3, Color.white }, { (LogType)2, Color.yellow }, { (LogType)1, Color.yellow }, { (LogType)0, Color.red }, { (LogType)4, Color.red } }; private readonly Color logEvenColor = new Color(0.34f, 0.34f, 0.34f); private readonly Color logOddColor = new Color(0.28f, 0.28f, 0.28f); public override string Name => "Log"; public override UIManager.Panels PanelType => UIManager.Panels.ConsoleLog; public override int MinWidth => 350; public override int MinHeight => 75; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.03f); public override Vector2 DefaultAnchorMax => new Vector2(0.9f, 0.2f); public override bool ShouldSaveActiveState => true; public override bool ShowByDefault => true; public int ItemCount => Logs.Count; public LogPanel(UIBase owner) : base(owner) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) SetupIO(); } public override void SetActive(bool active) { base.SetActive(active); if (active && !DoneScrollPoolInit) { LayoutRebuilder.ForceRebuildLayoutImmediate(((PanelBase)this).Rect); logScrollPool.Initialize((ICellPoolDataSource)this, (Action)null); DoneScrollPoolInit = true; } logScrollPool.Refresh(true, false); } private void SetupIO() { string text = $"UnityExplorer {DateTime.Now:u}.txt"; text = IOUtility.EnsureValidFilename(text); string text2 = Path.Combine(ExplorerCore.ExplorerFolder, "Logs"); CurrentStreamPath = IOUtility.EnsureValidFilePath(Path.Combine(text2, text)); string[] files = Directory.GetFiles(text2); if (files.Length >= 10) { files.ToList().Sort(); for (int i = 0; i < files.Length - 9; i++) { File.Delete(files[i]); } } if (ConfigManager.Log_To_Disk.Value) { File.WriteAllLines(CurrentStreamPath, Logs.Select((LogInfo it) => it.message).ToArray()); } } public static void Log(string message, LogType type) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Logs.Add(new LogInfo(message, type)); if (CurrentStreamPath != null && ConfigManager.Log_To_Disk.Value) { File.AppendAllText(CurrentStreamPath, "\n" + message); } if (logScrollPool != null) { logScrollPool.Refresh(true, false); } } private static void ClearLogs() { Logs.Clear(); logScrollPool.Refresh(true, true); } private static void OpenLogFile() { if (File.Exists(CurrentStreamPath)) { Process.Start(CurrentStreamPath); } } public void OnCellBorrowed(ConsoleLogCell cell) { } public void SetCell(ConsoleLogCell cell, int index) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (index >= Logs.Count) { cell.Disable(); return; } index = Logs.Count - index - 1; LogInfo logInfo = Logs[index]; cell.IndexLabel.text = $"{index}:"; cell.Input.Text = logInfo.message; ((Graphic)cell.Input.Component.textComponent).color = logColors[logInfo.type]; Color value = ((index % 2 == 0) ? logEvenColor : logOddColor); RuntimeHelper.SetColorBlock((Selectable)(object)cell.Input.Component, (Color?)value, (Color?)null, (Color?)null, (Color?)null); } protected override void ConstructPanelContent() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) GameObject val = default(GameObject); GameObject val2 = default(GameObject); logScrollPool = UIFactory.CreateScrollPool(((PanelBase)this).ContentRoot, "Logs", ref val, ref val2, (Color?)new Color(0.03f, 0.03f, 0.03f)); GameObject obj = val; int? num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); GameObject obj2 = UIFactory.CreateUIObject("OptionsRow", ((PanelBase)this).ContentRoot, default(Vector2)); num2 = 25; num = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(obj2, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null); ButtonRef obj3 = UIFactory.CreateButton(obj2, "ClearButton", "Clear", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject = ((Component)obj3.Component).gameObject; num = 23; num2 = 0; UIFactory.SetLayoutElement(gameObject, (int?)60, num, (int?)null, num2, (int?)null, (int?)null, (bool?)null); obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(ClearLogs)); ((Component)obj3.Component).transform.SetSiblingIndex(1); ButtonRef obj4 = UIFactory.CreateButton(obj2, "FileButton", "Open Log File", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject2 = ((Component)obj4.Component).gameObject; num2 = 23; num = 0; UIFactory.SetLayoutElement(gameObject2, (int?)100, num2, (int?)null, num, (int?)null, (int?)null, (bool?)null); obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, new Action(OpenLogFile)); ((Component)obj4.Component).transform.SetSiblingIndex(2); Toggle toggle = default(Toggle); Text val3 = default(Text); GameObject obj5 = UIFactory.CreateToggle(obj2, "UnityLogToggle", ref toggle, ref val3, default(Color), 20, 20); num = 25; UIFactory.SetLayoutElement(obj5, (int?)150, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); val3.text = "Log Unity Debug?"; toggle.isOn = ConfigManager.Log_Unity_Debug.Value; ConfigElement log_Unity_Debug = ConfigManager.Log_Unity_Debug; log_Unity_Debug.OnValueChanged = (Action)System.Delegate.Combine(log_Unity_Debug.OnValueChanged, (Action)delegate(bool isOn) { toggle.isOn = isOn; }); ((UnityEvent)(object)toggle.onValueChanged).AddListener((UnityAction)delegate(bool value) { ConfigManager.Log_Unity_Debug.Value = value; }); } } public class ConsoleLogCell : ICell, IPooledObject { public Text IndexLabel; public InputFieldRef Input; public RectTransform Rect { get; set; } public GameObject UIRoot { get; set; } public float DefaultHeight => 25f; public bool Enabled => UIRoot.activeInHierarchy; public void Enable() { UIRoot.SetActive(true); } public void Disable() { UIRoot.SetActive(false); } public GameObject CreateContent(GameObject parent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject("LogCell", parent, new Vector2(25f, 25f)); Rect = UIRoot.GetComponent(); UIFactory.SetLayoutGroup(UIRoot, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)3, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject uIRoot = UIRoot; int? num = 25; UIFactory.SetLayoutElement(uIRoot, (int?)50, num, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); IndexLabel = UIFactory.CreateLabel(UIRoot, "IndexLabel", "i:", (TextAnchor)4, Color.grey, false, 12); GameObject gameObject = ((Component)IndexLabel).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject, (int?)30, num, (int?)40, (int?)null, (int?)null, (int?)null, (bool?)null); Input = UIFactory.CreateInputField(UIRoot, "Input", ""); GameObject uIRoot2 = ((UIModel)Input).UIRoot; num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); RuntimeHelper.SetColorBlock((Selectable)(object)Input.Component, (Color?)new Color(0.1f, 0.1f, 0.1f), (Color?)new Color(0.13f, 0.13f, 0.13f), (Color?)new Color(0.07f, 0.07f, 0.07f), (Color?)null); ((Graphic)((Component)Input.Component).GetComponent()).color = new Color(0.2f, 0.2f, 0.2f); Input.Component.readOnly = true; Input.Component.textComponent.supportRichText = true; Input.Component.lineType = (LineType)2; Input.Component.textComponent.font = UniversalUI.ConsoleFont; Input.PlaceholderText.font = UniversalUI.ConsoleFont; return UIRoot; } } public class MouseInspectorResultsPanel : UEPanel { private ButtonListHandler dataHandler; private ScrollPool buttonScrollPool; public override UIManager.Panels PanelType => UIManager.Panels.UIInspectorResults; public override string Name => "UI Inspector Results"; public override int MinWidth => 500; public override int MinHeight => 500; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.5f); public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.5f); public override bool CanDragAndResize => true; public override bool NavButtonWanted => false; public override bool ShouldSaveActiveState => false; public override bool ShowByDefault => false; public MouseInspectorResultsPanel(UIBase owner) : base(owner) { } public void ShowResults() { dataHandler.RefreshData(); buttonScrollPool.Refresh(true, true); } private List GetEntries() { return UiInspector.LastHitObjects; } private bool ShouldDisplayCell(object cell, string filter) { return true; } private void OnCellClicked(int index) { if (index < UiInspector.LastHitObjects.Count) { InspectorManager.Inspect(UiInspector.LastHitObjects[index]); } } private void SetCell(ButtonCell cell, int index) { if (index < UiInspector.LastHitObjects.Count) { GameObject val = UiInspector.LastHitObjects[index]; cell.Button.ButtonText.text = "" + ((Object)val).name + " (" + UnityHelpers.GetTransformPath(val.transform, true) + ")"; } } public override void SetDefaultSizeAndPosition() { base.SetDefaultSizeAndPosition(); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)0, 500f); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)1, 500f); } protected override void ConstructPanelContent() { dataHandler = new ButtonListHandler(buttonScrollPool, (Func>)GetEntries, (Action)SetCell, (Func)ShouldDisplayCell, (Action)OnCellClicked); GameObject val = default(GameObject); GameObject val2 = default(GameObject); buttonScrollPool = UIFactory.CreateScrollPool(((PanelBase)this).ContentRoot, "ResultsList", ref val, ref val2, (Color?)null); buttonScrollPool.Initialize((ICellPoolDataSource)(object)dataHandler, (Action)null); GameObject obj = val; int? num = 9999; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, (int?)null, num, (int?)null, (int?)null, (bool?)null); } } public class ObjectExplorerPanel : UEPanel { public SceneExplorer SceneExplorer; public ObjectSearch ObjectSearch; public int SelectedTab; private readonly List tabPages = new List(); private readonly List tabButtons = new List(); public override string Name => "Object Explorer"; public override UIManager.Panels PanelType => UIManager.Panels.ObjectExplorer; public override int MinWidth => 350; public override int MinHeight => 200; public override Vector2 DefaultAnchorMin => new Vector2(0.125f, 0.175f); public override Vector2 DefaultAnchorMax => new Vector2(0.325f, 0.925f); public override bool ShowByDefault => true; public override bool ShouldSaveActiveState => true; public ObjectExplorerPanel(UIBase owner) : base(owner) { } public void SetTab(int tabIndex) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (SelectedTab != -1) { DisableTab(SelectedTab); } tabPages[tabIndex].SetActive(true); RuntimeHelper.SetColorBlock((Selectable)(object)tabButtons[tabIndex].Component, (Color?)UniversalUI.EnabledButtonColor, (Color?)(UniversalUI.EnabledButtonColor * 1.2f), (Color?)null, (Color?)null); SelectedTab = tabIndex; SaveInternalData(); } private void DisableTab(int tabIndex) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) tabPages[tabIndex].SetActive(false); RuntimeHelper.SetColorBlock((Selectable)(object)tabButtons[tabIndex].Component, (Color?)UniversalUI.DisabledButtonColor, (Color?)(UniversalUI.DisabledButtonColor * 1.2f), (Color?)null, (Color?)null); } public override void Update() { if (SelectedTab == 0) { SceneExplorer.Update(); } else { ObjectSearch.Update(); } } public override string ToSaveData() { return string.Join("|", base.ToSaveData(), SelectedTab.ToString()); } protected override void ApplySaveData(string data) { base.ApplySaveData(data); try { int selectedTab = int.Parse(data.Split(new char[1] { '|' }).Last()); SelectedTab = selectedTab; } catch { SelectedTab = 0; } SelectedTab = Math.Max(0, SelectedTab); SelectedTab = Math.Min(1, SelectedTab); SetTab(SelectedTab); } protected override void ConstructPanelContent() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "TabBar", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); int? num = 25; int? num2 = 0; UIFactory.SetLayoutElement(val, (int?)null, num, (int?)null, num2, (int?)null, (int?)null, (bool?)null); SceneExplorer = new SceneExplorer(this); ((UIModel)SceneExplorer).ConstructUI(((PanelBase)this).ContentRoot); tabPages.Add((UIModel)(object)SceneExplorer); ObjectSearch = new ObjectSearch(this); ((UIModel)ObjectSearch).ConstructUI(((PanelBase)this).ContentRoot); tabPages.Add((UIModel)(object)ObjectSearch); AddTabButton(val, "Scene Explorer"); AddTabButton(val, "Object Search"); ((UIModel)this).SetActive(true); } private void AddTabButton(GameObject tabGroup, string label) { ButtonRef val = UIFactory.CreateButton(tabGroup, "Button_" + label, label, (Color?)null); int idx = tabButtons.Count; val.OnClick = (Action)System.Delegate.Combine(val.OnClick, (Action)delegate { SetTab(idx); }); tabButtons.Add(val); DisableTab(tabButtons.Count - 1); } } public class OptionsPanel : UEPanel, ICacheObjectController, ICellPoolDataSource { private readonly List configEntries = new List(); public override string Name => "Options"; public override UIManager.Panels PanelType => UIManager.Panels.Options; public override int MinWidth => 600; public override int MinHeight => 200; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 0.1f); public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 0.85f); public override bool ShouldSaveActiveState => false; public override bool ShowByDefault => false; public CacheObjectBase ParentCacheObject => null; public object Target => null; public Type TargetType => null; public bool CanWrite => true; public int ItemCount => configEntries.Count; public OptionsPanel(UIBase owner) : base(owner) { using (Dictionary.Enumerator enumerator = ConfigManager.ConfigElements.GetEnumerator()) { while (enumerator.MoveNext()) { CacheConfigEntry item = new CacheConfigEntry(enumerator.Current.Value) { Owner = this }; configEntries.Add(item); } } foreach (CacheConfigEntry configEntry in configEntries) { configEntry.UpdateValueFromSource(); } } public void OnCellBorrowed(ConfigEntryCell cell) { } public void SetCell(ConfigEntryCell cell, int index) { CacheObjectControllerHelper.SetCell(cell, index, configEntries, null); } public override void SetDefaultSizeAndPosition() { base.SetDefaultSizeAndPosition(); ((PanelBase)this).Rect.SetSizeWithCurrentAnchors((Axis)0, 600f); } protected override void ConstructPanelContent() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) ButtonRef obj = UIFactory.CreateButton(((PanelBase)this).ContentRoot, "Save", "Save Options", (Color?)new Color(0.2f, 0.3f, 0.2f)); GameObject gameObject = ((Component)obj.Component).gameObject; int? num = 9999; int? num2 = 30; int? num3 = 0; UIFactory.SetLayoutElement(gameObject, (int?)null, num2, num, num3, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(ConfigManager.Handler.SaveConfig)); GameObject val = default(GameObject); GameObject val2 = default(GameObject); UIFactory.CreateScrollPool(((PanelBase)this).ContentRoot, "ConfigEntries", ref val, ref val2, (Color?)null).Initialize((ICellPoolDataSource)this, (Action)null); } } public abstract class UEPanel : PanelBase { private bool setDefault; public abstract UIManager.Panels PanelType { get; } public virtual bool ShowByDefault => false; public virtual bool ShouldSaveActiveState => true; public virtual bool NavButtonWanted => true; public ButtonRef NavButton { get; internal set; } public bool ApplyingSaveData { get; set; } protected UEPanel(UIBase owner) : base(owner) { } protected override PanelDragger CreatePanelDragger() { return (PanelDragger)(object)new UEPanelDragger((PanelBase)(object)this); } public override void OnFinishDrag() { ((PanelBase)this).OnFinishDrag(); SaveInternalData(); } public override void OnFinishResize() { ((PanelBase)this).OnFinishResize(); SaveInternalData(); } public override void SetActive(bool active) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (((UIModel)this).Enabled != active) { ((PanelBase)this).SetActive(active); if (!ApplyingSaveData) { SaveInternalData(); } if (NavButtonWanted && NavButton != null) { Color val = (active ? UniversalUI.EnabledButtonColor : UniversalUI.DisabledButtonColor); RuntimeHelper.SetColorBlock((Selectable)(object)NavButton.Component, (Color?)val, (Color?)(val * 1.2f), (Color?)null, (Color?)null); } } if (!active) { if (((PanelBase)this).Dragger != null) { ((PanelBase)this).Dragger.WasDragging = false; } } else { ((UIModel)this).UIRoot.transform.SetAsLastSibling(); (((PanelBase)this).Owner.Panels as UEPanelManager).DoInvokeOnPanelsReordered(); } } public override void SetDefaultSizeAndPosition() { if (!setDefault) { setDefault = true; ((PanelBase)this).SetDefaultSizeAndPosition(); } } public void SaveInternalData() { if (!UIManager.Initializing && !ApplyingSaveData) { SetSaveDataToConfigValue(); } } private void SetSaveDataToConfigValue() { ConfigManager.GetPanelSaveData(PanelType).Value = ToSaveData(); } public virtual string ToSaveData() { try { return string.Join("|", $"{ShouldSaveActiveState && ((UIModel)this).Enabled}", ((PanelBase)this).Rect.RectAnchorsToString(), ((PanelBase)this).Rect.RectPositionToString()); } catch (Exception arg) { ExplorerCore.LogWarning($"Exception generating Panel save data: {arg}"); return ""; } } public virtual void ApplySaveData() { string value = ConfigManager.GetPanelSaveData(PanelType).Value; ApplySaveData(value); } protected virtual void ApplySaveData(string data) { if (string.IsNullOrEmpty(data)) { return; } string[] array = data.Split(new char[1] { '|' }); try { ((PanelBase)this).Rect.SetAnchorsFromString(array[1]); ((PanelBase)this).Rect.SetPositionFromString(array[2]); ((PanelBase)this).EnsureValidSize(); ((PanelBase)this).EnsureValidPosition(); ((UIModel)this).SetActive(bool.Parse(array[0])); } catch { ExplorerCore.LogWarning("Invalid or corrupt panel save data! Restoring to default."); ((PanelBase)this).SetDefaultSizeAndPosition(); SetSaveDataToConfigValue(); } } public override void ConstructUI() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) ((PanelBase)this).ConstructUI(); if (NavButtonWanted) { NavButton = UIFactory.CreateButton(UIManager.NavbarTabButtonHolder, $"Button_{PanelType}", ((PanelBase)this).Name, (Color?)null); GameObject gameObject = ((Component)NavButton.Component).gameObject; gameObject.AddComponent().horizontalFit = (FitMode)2; UIFactory.SetLayoutGroup(gameObject, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)0, (int?)0, (int?)0, (int?)5, (int?)5, (TextAnchor?)(TextAnchor)4); UIFactory.SetLayoutElement(gameObject, (int?)80, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); RuntimeHelper.SetColorBlock((Selectable)(object)NavButton.Component, (Color?)UniversalUI.DisabledButtonColor, (Color?)(UniversalUI.DisabledButtonColor * 1.2f), (Color?)null, (Color?)null); ButtonRef navButton = NavButton; navButton.OnClick = (Action)System.Delegate.Combine(navButton.OnClick, (Action)delegate { UIManager.TogglePanel(PanelType); }); ((Component)gameObject.transform.Find("Text")).gameObject.AddComponent().horizontalFit = (FitMode)2; } ((UIModel)this).SetActive(true); ((UIModel)this).SetActive(false); ((UIModel)this).SetActive(ShowByDefault); } protected override void LateConstructUI() { ApplyingSaveData = true; ((PanelBase)this).LateConstructUI(); try { ApplySaveData(); } catch (Exception arg) { ExplorerCore.Log($"Exception loading panel save data: {arg}"); ((PanelBase)this).SetDefaultSizeAndPosition(); } ((UIModel)this).OnToggleEnabled += delegate { SaveInternalData(); }; ApplyingSaveData = false; ((PanelBase)this).Dragger.OnEndResize(); } } public static class RectSaveExtensions { internal static string RectAnchorsToString(this RectTransform rect) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)rect)) { throw new ArgumentNullException("rect"); } return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", rect.anchorMin.x, rect.anchorMin.y, rect.anchorMax.x, rect.anchorMax.y); } internal static void SetAnchorsFromString(this RectTransform panel, string stringAnchors) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(stringAnchors)) { throw new ArgumentNullException("stringAnchors"); } if (stringAnchors.Contains(" ")) { throw new Exception("invalid save data, resetting."); } string[] array = stringAnchors.Split(new char[1] { ',' }); if (array.Length != 4) { throw new Exception($"stringAnchors split is unexpected length: {array.Length}"); } Vector4 val = default(Vector4); val.x = float.Parse(array[0], CultureInfo.InvariantCulture); val.y = float.Parse(array[1], CultureInfo.InvariantCulture); val.z = float.Parse(array[2], CultureInfo.InvariantCulture); val.w = float.Parse(array[3], CultureInfo.InvariantCulture); panel.anchorMin = new Vector2(val.x, val.y); panel.anchorMax = new Vector2(val.z, val.w); } internal static string RectPositionToString(this RectTransform rect) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)rect)) { throw new ArgumentNullException("rect"); } return string.Format(CultureInfo.InvariantCulture, "{0},{1}", new object[2] { rect.anchoredPosition.x, rect.anchoredPosition.y }); } internal static void SetPositionFromString(this RectTransform rect, string stringPosition) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(stringPosition)) { throw new ArgumentNullException(stringPosition); } if (stringPosition.Contains(" ")) { throw new Exception("invalid save data, resetting."); } string[] array = stringPosition.Split(new char[1] { ',' }); if (array.Length != 2) { throw new Exception($"stringPosition split is unexpected length: {array.Length}"); } Vector3 val = Vector2.op_Implicit(rect.anchoredPosition); val.x = float.Parse(array[0], CultureInfo.InvariantCulture); val.y = float.Parse(array[1], CultureInfo.InvariantCulture); rect.anchoredPosition = Vector2.op_Implicit(val); } } public class UEPanelDragger : PanelDragger { public UEPanelDragger(PanelBase uiPanel) : base(uiPanel) { } protected override bool MouseInResizeArea(Vector2 mousePos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Rect rect = UIManager.NavBarRect.rect; if (!((Rect)(ref rect)).Contains(((Transform)UIManager.NavBarRect).InverseTransformPoint(Vector2.op_Implicit(mousePos)))) { return ((PanelDragger)this).MouseInResizeArea(mousePos); } return false; } } } namespace UnityExplorer.Tests { public class TestClass { public static object LiterallyAnything; private static bool shouldThrow; public static int[,,] MultiDimensionalArray; public static List ListOfInts; public static List>> NestedList; public static IDictionary MixedDictionary; public static Hashtable Hashtable; public static byte[] ByteArray; public static List ABigList; public const int ConstantInt5 = 5; public static BindingFlags EnumTest; public static CameraClearFlags EnumTest2; public static Color Color; public static Color32 Color32; public static string ALongString; public static string Exception { get { if (!shouldThrow) { shouldThrow = true; throw new Exception("This is a test."); } shouldThrow = false; return "No exception"; } } public static List RandomList { get { List list = new List(); int num = Random.Range(0, 100); for (int i = 0; i < num; i++) { list.Add(GetRandomObject()); } return list; } } public int this[int index] { get { return Random.Range(0, int.MaxValue); } set { ExplorerCore.Log(index); } } static TestClass() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) LiterallyAnything = null; MultiDimensionalArray = new int[45, 45, 45]; ByteArray = new byte[16]; ABigList = new List(10000); Color = Color.magenta; Color32 = Color32.op_Implicit(Color.red); ALongString = new string('#', 10000); Init_Mono(); } public static float[] AParseTest(ref List arg0, ref float[,] arg1) { return new float[3] { 1f, 2f, 3f }; } private static object GetRandomObject() { return Random.Range(0, 7) switch { 0 => null, 1 => 123, 2 => true, 3 => "hello", 4 => 50.5f, 5 => (object)(CameraClearFlags)2, 6 => new List { "one", "two" }, _ => null, }; } public static void TestComponent() where T : Component { ExplorerCore.Log("Test3 " + typeof(T).FullName); } public static void TestArgumentParse(string _string, int integer, Color color, CameraClearFlags flags, Vector3 vector, Quaternion quaternion, object obj, Type type, GameObject go) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ExplorerCore.Log($"_string: {_string}, integer: {integer}, color: {color}, flags: {flags}, " + string.Format("vector: {0}, quaternion: {1}, obj: {2},", vector, quaternion, obj?.ToString() ?? "null") + string.Format("type: {0}, go: {1}", type?.FullName ?? "null", go)); } private static void Init_Mono() { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) ExplorerCore.Log("1: Basic list"); ListOfInts = new List { 1, 2, 3, 4, 5 }; ExplorerCore.Log("2: Nested list"); NestedList = new List>> { new List> { new List { "1", "2", "3" }, new List { "4", "5", "6" } }, new List> { new List { "7", "8", "9" } } }; ExplorerCore.Log("3: Dictionary"); MixedDictionary = new Dictionary { { 1, 2 }, { "one", "two" }, { true, false }, { (object)new Vector3(0f, 1f, 2f), (object)new Vector3(1f, 2f, 3f) }, { (object)(CameraClearFlags)3, (object)(CameraClearFlags)2 }, { "################################################\r\n##########", null }, { "subdict", new Dictionary { { "key", "value" } } } }; ExplorerCore.Log("4: Hashtable"); Hashtable = new Hashtable { { "One", 1 }, { "Two", 2 } }; ExplorerCore.Log("5: Big list"); for (int i = 0; i < ABigList.Capacity; i++) { ABigList.Add((short)Random.Range(0, 32767)); } ExplorerCore.Log("Finished TestClass Init_Mono"); } } } namespace UnityExplorer.Runtime { public class MonoHelper : UERuntimeHelper { public override void SetupEvents() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Application.logMessageReceived += new LogCallback(Application_logMessageReceived); } private void Application_logMessageReceived(string condition, string stackTrace, LogType type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ExplorerCore.LogUnity(condition, type); } } public abstract class UERuntimeHelper { public static UERuntimeHelper Instance; private static readonly HashSet currentBlacklist = new HashSet(); public virtual string[] DefaultReflectionBlacklist => new string[0]; public static void Init() { Instance = new MonoHelper(); Instance.SetupEvents(); LoadBlacklistString(ConfigManager.Reflection_Signature_Blacklist.Value); ConfigElement reflection_Signature_Blacklist = ConfigManager.Reflection_Signature_Blacklist; reflection_Signature_Blacklist.OnValueChanged = (Action)System.Delegate.Combine(reflection_Signature_Blacklist.OnValueChanged, (Action)delegate(string val) { LoadBlacklistString(val); }); } public abstract void SetupEvents(); public static void LoadBlacklistString(string blacklist) { try { if (string.IsNullOrEmpty(blacklist) && !Instance.DefaultReflectionBlacklist.Any()) { return; } string[] array; try { array = blacklist.Split(new char[1] { ';' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (!string.IsNullOrEmpty(text) && !currentBlacklist.Contains(text)) { currentBlacklist.Add(text); } } } catch (Exception ex) { ExplorerCore.LogWarning("Exception parsing blacklist string: " + ReflectionExtensions.ReflectionExToString(ex, true)); } array = Instance.DefaultReflectionBlacklist; foreach (string item in array) { if (!currentBlacklist.Contains(item)) { currentBlacklist.Add(item); } } Blacklist.SignatureBlacklist = currentBlacklist; } catch (Exception ex2) { ExplorerCore.LogWarning("Exception setting up reflection blacklist: " + ReflectionExtensions.ReflectionExToString(ex2, true)); } } public static bool IsBlacklisted(MemberInfo member) { if (string.IsNullOrEmpty(member.DeclaringType?.Namespace)) { return false; } string item = member.DeclaringType.FullName + "." + member.Name; return currentBlacklist.Contains(item); } } internal static class UnityCrashPrevention { private static readonly Harmony harmony = new Harmony("com.sinai.unityexplorer.crashprevention"); internal static void Init() { TryPatch("get_renderingDisplaySize", "Canvas_renderingDisplaySize_Prefix"); IEnumerable patchedMethods = harmony.GetPatchedMethods(); if (patchedMethods.Any()) { ExplorerCore.Log("Initialized UnityCrashPrevention for: " + string.Join(", ", patchedMethods.Select((MethodBase it) => it.DeclaringType.Name + "." + it.Name).ToArray())); } } internal static void TryPatch(string orig, string prefix, Type[] argTypes = null) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown try { harmony.Patch((MethodBase)AccessTools.Method(typeof(T), orig, argTypes, (Type[])null), new HarmonyMethod(AccessTools.Method(typeof(UnityCrashPrevention), prefix, (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch { } } internal static void Canvas_renderingDisplaySize_Prefix(Canvas __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)__instance.renderMode == 2 && !Object.op_Implicit((Object)(object)__instance.worldCamera)) { throw new InvalidOperationException("Canvas is set to RenderMode.WorldSpace but not worldCamera is set."); } } } } namespace UnityExplorer.ObjectExplorer { public class ObjectSearch : UIModel { private SearchContext context; private SceneFilter sceneFilter; private ChildFilter childFilter; private string desiredTypeInput; private string lastCheckedTypeInput; private bool lastTypeCanHaveGameObject; public ButtonListHandler dataHandler; private ScrollPool resultsScrollPool; private List currentResults = new List(); public TypeCompleter unityObjectTypeCompleter; public TypeCompleter allTypesCompleter; private GameObject uiRoot; private GameObject sceneFilterRow; private GameObject childFilterRow; private GameObject classInputRow; private GameObject nameInputRow; private InputFieldRef nameInputField; private Text resultsLabel; private static readonly Dictionary cachedCellTexts = new Dictionary(); public ObjectExplorerPanel Parent { get; } public override GameObject UIRoot => uiRoot; public ObjectSearch(ObjectExplorerPanel parent) { Parent = parent; } public List GetEntries() { return currentResults; } public void DoSearch() { cachedCellTexts.Clear(); if (context == SearchContext.Singleton) { currentResults = SearchProvider.InstanceSearch(desiredTypeInput).ToList(); } else if (context == SearchContext.Class) { currentResults = SearchProvider.ClassSearch(desiredTypeInput); } else { currentResults = SearchProvider.UnityObjectSearch(nameInputField.Text, desiredTypeInput, childFilter, sceneFilter); } dataHandler.RefreshData(); resultsScrollPool.Refresh(true, false); resultsLabel.text = $"{currentResults.Count} results"; } public void Update() { if (context == SearchContext.UnityObject && lastCheckedTypeInput != desiredTypeInput) { lastCheckedTypeInput = desiredTypeInput; Type typeByName = ReflectionUtility.GetTypeByName(desiredTypeInput); if ((object)typeByName != null) { Type type = typeByName; lastTypeCanHaveGameObject = typeof(Component).IsAssignableFrom(type) || type == typeof(GameObject); sceneFilterRow.SetActive(lastTypeCanHaveGameObject); childFilterRow.SetActive(lastTypeCanHaveGameObject); } else { sceneFilterRow.SetActive(false); childFilterRow.SetActive(false); lastTypeCanHaveGameObject = false; } } } private void OnContextDropdownChanged(int value) { context = (SearchContext)value; lastCheckedTypeInput = null; sceneFilterRow.SetActive(false); childFilterRow.SetActive(false); nameInputRow.SetActive(context == SearchContext.UnityObject); switch (context) { case SearchContext.UnityObject: unityObjectTypeCompleter.Enabled = true; allTypesCompleter.Enabled = false; break; case SearchContext.Singleton: case SearchContext.Class: allTypesCompleter.Enabled = true; unityObjectTypeCompleter.Enabled = false; break; } } private void OnSceneFilterDropChanged(int value) { sceneFilter = (SceneFilter)value; } private void OnChildFilterDropChanged(int value) { childFilter = (ChildFilter)value; } private void OnTypeInputChanged(string val) { desiredTypeInput = val; if (string.IsNullOrEmpty(val)) { sceneFilterRow.SetActive(false); childFilterRow.SetActive(false); lastCheckedTypeInput = val; } } public void SetCell(ButtonCell cell, int index) { if (!cachedCellTexts.ContainsKey(index)) { string value; if (context == SearchContext.Class) { Type type = currentResults[index] as Type; value = SignatureHighlighter.Parse(type, true, (MemberInfo)null) + " (" + type.Assembly.GetName().Name + ")"; } else { object obj = currentResults[index]; object obj2 = currentResults[index]; value = ToStringUtility.ToStringWithType(obj, (obj2 != null) ? ReflectionExtensions.GetActualType(obj2) : null, true); } cachedCellTexts.Add(index, value); } cell.Button.ButtonText.text = cachedCellTexts[index]; } private void OnCellClicked(int dataIndex) { if (context == SearchContext.Class) { InspectorManager.Inspect(currentResults[dataIndex] as Type); } else { InspectorManager.Inspect(currentResults[dataIndex]); } } private bool ShouldDisplayCell(object arg1, string arg2) { return true; } public override void ConstructUI(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Expected O, but got Unknown //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07e0: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0862: Unknown result type (might be due to invalid IL or missing references) //IL_09db: Unknown result type (might be due to invalid IL or missing references) //IL_09e1: Unknown result type (might be due to invalid IL or missing references) //IL_09e5: Unknown result type (might be due to invalid IL or missing references) //IL_09eb: Unknown result type (might be due to invalid IL or missing references) //IL_0a5d: Unknown result type (might be due to invalid IL or missing references) //IL_0a63: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Expected O, but got Unknown uiRoot = UIFactory.CreateVerticalGroup(parent, "ObjectSearch", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj = uiRoot; int? num = 9999; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, (int?)null, num, (int?)null, (int?)null, (bool?)null); GameObject obj2 = UIFactory.CreateHorizontalGroup(uiRoot, "SearchContextRow", false, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); num = 25; int? num2 = 0; UIFactory.SetLayoutElement(obj2, (int?)null, num, (int?)null, num2, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(obj2, "SearchContextLabel", "Searching for:", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num3 = 110; num2 = 0; UIFactory.SetLayoutElement(gameObject, num3, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); Dropdown val2 = default(Dropdown); GameObject val = UIFactory.CreateDropdown(obj2, "ContextDropdown", ref val2, (string)null, 14, (Action)OnContextDropdownChanged, (string[])null); string[] names = System.Enum.GetNames(typeof(SearchContext)); foreach (string text in names) { val2.options.Add(new OptionData(text)); } num2 = 25; num = 0; int? num4 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num2, num4, num, (int?)null, (int?)null, (bool?)null); classInputRow = UIFactory.CreateHorizontalGroup(uiRoot, "ClassRow", false, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj3 = classInputRow; num4 = 25; num = 0; UIFactory.SetLayoutElement(obj3, (int?)null, num4, (int?)null, num, (int?)null, (int?)null, (bool?)null); GameObject gameObject2 = ((Component)UIFactory.CreateLabel(classInputRow, "ClassLabel", "Class filter:", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num5 = 110; num = 0; UIFactory.SetLayoutElement(gameObject2, num5, (int?)null, num, (int?)null, (int?)null, (int?)null, (bool?)null); InputFieldRef val3 = UIFactory.CreateInputField(classInputRow, "ClassInput", "..."); GameObject uIRoot = ((UIModel)val3).UIRoot; num = 25; num4 = 0; num2 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, num2, num4, (int?)null, (int?)null, (bool?)null); unityObjectTypeCompleter = new TypeCompleter(typeof(Object), val3, allowAbstract: true, allowEnum: false, allowGeneric: true); allTypesCompleter = new TypeCompleter(null, val3, allowAbstract: true, allowEnum: false, allowGeneric: true); allTypesCompleter.Enabled = false; val3.OnValueChanged += OnTypeInputChanged; childFilterRow = UIFactory.CreateHorizontalGroup(uiRoot, "ChildFilterRow", false, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj4 = childFilterRow; num2 = 25; num4 = 0; UIFactory.SetLayoutElement(obj4, (int?)null, num2, (int?)null, num4, (int?)null, (int?)null, (bool?)null); GameObject gameObject3 = ((Component)UIFactory.CreateLabel(childFilterRow, "ChildLabel", "Child filter:", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num6 = 110; num4 = 0; UIFactory.SetLayoutElement(gameObject3, num6, (int?)null, num4, (int?)null, (int?)null, (int?)null, (bool?)null); Dropdown val5 = default(Dropdown); GameObject val4 = UIFactory.CreateDropdown(childFilterRow, "ChildFilterDropdown", ref val5, (string)null, 14, (Action)OnChildFilterDropChanged, (string[])null); names = System.Enum.GetNames(typeof(ChildFilter)); foreach (string text2 in names) { val5.options.Add(new OptionData(text2)); } num4 = 25; num2 = 0; num = 9999; UIFactory.SetLayoutElement(val4, (int?)null, num4, num, num2, (int?)null, (int?)null, (bool?)null); childFilterRow.SetActive(false); sceneFilterRow = UIFactory.CreateHorizontalGroup(uiRoot, "SceneFilterRow", false, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj5 = sceneFilterRow; num = 25; num2 = 0; UIFactory.SetLayoutElement(obj5, (int?)null, num, (int?)null, num2, (int?)null, (int?)null, (bool?)null); GameObject gameObject4 = ((Component)UIFactory.CreateLabel(sceneFilterRow, "SceneLabel", "Scene filter:", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num7 = 110; num2 = 0; UIFactory.SetLayoutElement(gameObject4, num7, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); Dropdown val7 = default(Dropdown); GameObject val6 = UIFactory.CreateDropdown(sceneFilterRow, "SceneFilterDropdown", ref val7, (string)null, 14, (Action)OnSceneFilterDropChanged, (string[])null); names = System.Enum.GetNames(typeof(SceneFilter)); foreach (string text3 in names) { if (SceneHandler.DontDestroyExists || !(text3 == "DontDestroyOnLoad")) { val7.options.Add(new OptionData(text3)); } } num2 = 25; num = 0; num4 = 9999; UIFactory.SetLayoutElement(val6, (int?)null, num2, num4, num, (int?)null, (int?)null, (bool?)null); sceneFilterRow.SetActive(false); nameInputRow = UIFactory.CreateHorizontalGroup(uiRoot, "NameRow", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj6 = nameInputRow; num4 = 25; num = 0; UIFactory.SetLayoutElement(obj6, (int?)null, num4, (int?)null, num, (int?)null, (int?)null, (bool?)null); GameObject gameObject5 = ((Component)UIFactory.CreateLabel(nameInputRow, "NameFilterLabel", "Name contains:", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num8 = 110; num = 0; UIFactory.SetLayoutElement(gameObject5, num8, (int?)null, num, (int?)null, (int?)null, (int?)null, (bool?)null); nameInputField = UIFactory.CreateInputField(nameInputRow, "NameFilterInput", "..."); GameObject uIRoot2 = ((UIModel)nameInputField).UIRoot; num = 25; num4 = 0; num2 = 9999; UIFactory.SetLayoutElement(uIRoot2, (int?)null, num, num2, num4, (int?)null, (int?)null, (bool?)null); ButtonRef obj7 = UIFactory.CreateButton(uiRoot, "SearchButton", "Search", (Color?)null); GameObject gameObject6 = ((Component)obj7.Component).gameObject; num2 = 25; num4 = 0; UIFactory.SetLayoutElement(gameObject6, (int?)null, num2, (int?)null, num4, (int?)null, (int?)null, (bool?)null); obj7.OnClick = (Action)System.Delegate.Combine(obj7.OnClick, new Action(DoSearch)); GameObject val8 = UIFactory.CreateHorizontalGroup(uiRoot, "ResultsCountRow", true, true, true, true, 0, default(Vector4), default(Color), (TextAnchor?)null); num4 = 25; num2 = 0; UIFactory.SetLayoutElement(val8, (int?)null, num4, (int?)null, num2, (int?)null, (int?)null, (bool?)null); resultsLabel = UIFactory.CreateLabel(val8, "ResultsLabel", "0 results", (TextAnchor)4, default(Color), true, 14); dataHandler = new ButtonListHandler(resultsScrollPool, (Func>)GetEntries, (Action)SetCell, (Func)ShouldDisplayCell, (Action)OnCellClicked); GameObject val9 = default(GameObject); GameObject val10 = default(GameObject); resultsScrollPool = UIFactory.CreateScrollPool(uiRoot, "ResultsList", ref val9, ref val10, (Color?)null); resultsScrollPool.Initialize((ICellPoolDataSource)(object)dataHandler, (Action)null); GameObject obj8 = val9; num2 = 9999; UIFactory.SetLayoutElement(obj8, (int?)null, (int?)null, (int?)null, num2, (int?)null, (int?)null, (bool?)null); } } public class SceneExplorer : UIModel { private GameObject uiRoot; public bool AutoUpdate; public TransformTree Tree; private float timeOfLastUpdate = -1f; private GameObject refreshRow; private Dropdown sceneDropdown; private readonly Dictionary sceneToDropdownOption = new Dictionary(); private Dropdown allSceneDropdown; private ButtonRef loadButton; private ButtonRef loadAdditiveButton; private const string DEFAULT_LOAD_TEXT = "[Select a scene]"; public ObjectExplorerPanel Parent { get; } public override GameObject UIRoot => uiRoot; public SceneExplorer(ObjectExplorerPanel parent) { Parent = parent; SceneHandler.OnInspectedSceneChanged += SceneHandler_OnInspectedSceneChanged; SceneHandler.OnLoadedScenesUpdated += SceneHandler_OnLoadedScenesUpdated; } private IEnumerable GetRootEntries() { return SceneHandler.CurrentRootObjects; } public void Update() { if ((AutoUpdate || !SceneHandler.InspectingAssetScene) && UnityHelpers.OccuredEarlierThan(timeOfLastUpdate, 1f)) { timeOfLastUpdate = Time.realtimeSinceStartup; UpdateTree(); } } public void UpdateTree() { SceneHandler.Update(); Tree.RefreshData(true, false, false, false); } public void JumpToTransform(Transform transform) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)transform)) { return; } UIManager.SetPanelActive(Parent, active: true); Parent.SetTab(0); GameObject gameObject = ((Component)transform).gameObject; Scene? selectedScene = SceneHandler.SelectedScene; Scene val = gameObject.scene; int value; if (!selectedScene.HasValue || selectedScene.GetValueOrDefault() != val) { Scene scene = gameObject.scene; val = default(Scene); if (!(scene == val)) { val = gameObject.scene; if (!(((Scene)(ref val)).handle == SceneHandle.op_Implicit(-1))) { value = sceneDropdown.options.IndexOf(sceneToDropdownOption[gameObject.scene]); goto IL_00b8; } } value = sceneDropdown.options.Count - 1; goto IL_00b8; } goto IL_00c4; IL_00b8: sceneDropdown.value = value; goto IL_00c4; IL_00c4: Tree.JumpAndExpandToTransform(transform); } private void OnSceneSelectionDropdownChanged(int value) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (value >= 0 && SceneHandler.LoadedScenes.Count > value) { SceneHandler.SelectedScene = SceneHandler.LoadedScenes[value]; SceneHandler.Update(); Tree.RefreshData(true, true, true, false); OnSelectedSceneChanged(SceneHandler.SelectedScene.Value); } } private void SceneHandler_OnInspectedSceneChanged(Scene scene) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!sceneToDropdownOption.ContainsKey(scene)) { PopulateSceneDropdown(SceneHandler.LoadedScenes); } if (sceneToDropdownOption.ContainsKey(scene)) { OptionData val = sceneToDropdownOption[scene]; int num = sceneDropdown.options.IndexOf(val); if (sceneDropdown.value != num) { sceneDropdown.value = num; } else { sceneDropdown.captionText.text = val.text; } } OnSelectedSceneChanged(scene); } private void OnSelectedSceneChanged(Scene scene) { if (Object.op_Implicit((Object)(object)refreshRow)) { refreshRow.SetActive(!((Scene)(ref scene)).IsValid()); } } private void SceneHandler_OnLoadedScenesUpdated(List loadedScenes) { PopulateSceneDropdown(loadedScenes); } private void PopulateSceneDropdown(List loadedScenes) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) sceneToDropdownOption.Clear(); sceneDropdown.options.Clear(); foreach (Scene loadedScene in loadedScenes) { Scene current = loadedScene; if (!sceneToDropdownOption.ContainsKey(current)) { string text = ((Scene)(ref current)).name?.Trim(); if (!((Scene)(ref current)).IsValid()) { text = "HideAndDontSave"; } else if (string.IsNullOrEmpty(text)) { text = ""; } OptionData val = new OptionData(text); sceneDropdown.options.Add(val); sceneToDropdownOption.Add(current, val); } } } private void OnFilterInput(string input) { if ((!string.IsNullOrEmpty(input) && !Tree.Filtering) || (string.IsNullOrEmpty(input) && Tree.Filtering)) { Tree.Clear(); } Tree.CurrentFilter = input; Tree.RefreshData(true, false, true, false); } private void TryLoadScene(LoadSceneMode mode, Dropdown allSceneDrop) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) string text = allSceneDrop.captionText.text; if (text == "[Select a scene]") { return; } try { SceneManager.LoadScene(text, mode); allSceneDrop.value = 0; } catch (Exception ex) { ExplorerCore.LogWarning("Unable to load the Scene! " + ReflectionExtensions.ReflectionExToString(ex, true)); } } public override void ConstructUI(GameObject content) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) //IL_0727: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Expected O, but got Unknown uiRoot = UIFactory.CreateUIObject("SceneExplorer", content, default(Vector2)); UIFactory.SetLayoutGroup(uiRoot, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)0, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null); GameObject obj = uiRoot; int? num = 9999; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, (int?)null, num, (int?)null, (int?)null, (bool?)null); GameObject val = UIFactory.CreateVerticalGroup(uiRoot, "Toolbar", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), new Color(0.15f, 0.15f, 0.15f), (TextAnchor?)null); GameObject obj2 = UIFactory.CreateHorizontalGroup(val, "DropdownRow", true, true, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null); num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(obj2, "SelectorLabel", "Scene:", (TextAnchor)3, Color.cyan, false, 15)).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)60, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj3 = UIFactory.CreateDropdown(obj2, "SceneDropdown", ref sceneDropdown, "", 13, (Action)OnSceneSelectionDropdownChanged, (string[])null); num2 = 25; num = 0; int? num3 = 9999; UIFactory.SetLayoutElement(obj3, (int?)null, num2, num3, num, (int?)null, (int?)null, (bool?)null); SceneHandler.Update(); PopulateSceneDropdown(SceneHandler.LoadedScenes); sceneDropdown.captionText.text = sceneToDropdownOption.First().Value.text; GameObject obj4 = UIFactory.CreateHorizontalGroup(val, "FilterGroup", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); num3 = 25; num = 0; UIFactory.SetLayoutElement(obj4, (int?)null, num3, (int?)null, num, (int?)null, (int?)null, (bool?)null); InputFieldRef obj5 = UIFactory.CreateInputField(obj4, "FilterInput", "Search and press enter..."); ((Selectable)obj5.Component).targetGraphic.color = new Color(0.2f, 0.2f, 0.2f); RuntimeHelper.SetColorBlock((Selectable)(object)obj5.Component, (Color?)new Color(0.4f, 0.4f, 0.4f), (Color?)new Color(0.2f, 0.2f, 0.2f), (Color?)new Color(0.08f, 0.08f, 0.08f), (Color?)null); GameObject uIRoot = ((UIModel)obj5).UIRoot; num = 25; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); UnityHelpers.GetOnEndEdit(obj5.Component).AddListener((UnityAction)OnFilterInput); refreshRow = UIFactory.CreateHorizontalGroup(val, "RefreshGroup", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); GameObject obj6 = refreshRow; num = 30; num3 = 0; UIFactory.SetLayoutElement(obj6, (int?)null, num, (int?)null, num3, (int?)null, (int?)null, (bool?)null); ButtonRef obj7 = UIFactory.CreateButton(refreshRow, "RefreshButton", "Update", (Color?)null); GameObject gameObject2 = ((Component)obj7.Component).gameObject; int? num4 = 65; num3 = 0; UIFactory.SetLayoutElement(gameObject2, num4, (int?)null, num3, (int?)null, (int?)null, (int?)null, (bool?)null); obj7.OnClick = (Action)System.Delegate.Combine(obj7.OnClick, new Action(UpdateTree)); Toggle val2 = default(Toggle); Text val3 = default(Text); GameObject obj8 = UIFactory.CreateToggle(refreshRow, "RefreshToggle", ref val2, ref val3, default(Color), 20, 20); num3 = 9999; UIFactory.SetLayoutElement(obj8, (int?)null, (int?)null, num3, (int?)null, (int?)null, (int?)null, (bool?)null); val3.text = "Auto-update (1 second)"; val3.alignment = (TextAnchor)3; ((Graphic)val3).color = Color.white; val3.fontSize = 12; val2.isOn = false; ((UnityEvent)(object)val2.onValueChanged).AddListener((UnityAction)delegate(bool autoUpdate) { AutoUpdate = autoUpdate; }); refreshRow.SetActive(false); GameObject obj9 = UIFactory.CreateHorizontalGroup(val, "LabelsRow", true, true, true, true, 2, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); num3 = 30; num = 0; UIFactory.SetLayoutElement(obj9, (int?)null, num3, (int?)null, num, (int?)null, (int?)null, (bool?)null); GameObject gameObject3 = ((Component)UIFactory.CreateLabel(obj9, "NameLabel", "Name", (TextAnchor)3, Color.grey, true, 14)).gameObject; num = 9999; num3 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)null, num3, num, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject4 = ((Component)UIFactory.CreateLabel(obj9, "IndexLabel", "Sibling Index", (TextAnchor)3, Color.grey, true, 12)).gameObject; int? num5 = 100; num3 = 0; UIFactory.SetLayoutElement(gameObject4, num5, (int?)25, num3, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject val5 = default(GameObject); GameObject val6 = default(GameObject); ScrollPool val4 = UIFactory.CreateScrollPool(uiRoot, "TransformTree", ref val5, ref val6, (Color?)new Color(0.11f, 0.11f, 0.11f)); GameObject obj10 = val5; num3 = 9999; UIFactory.SetLayoutElement(obj10, (int?)null, (int?)null, (int?)null, num3, (int?)null, (int?)null, (bool?)null); GameObject obj11 = val6; num3 = 9999; UIFactory.SetLayoutElement(obj11, (int?)null, (int?)null, (int?)null, num3, (int?)null, (int?)null, (bool?)null); Tree = new TransformTree(val4, (Func>)GetRootEntries, (Action)OnCellClicked); Tree.RefreshData(true, true, true, false); ConstructSceneLoader(); RuntimeHelper.StartCoroutine(TempFixCoro()); } private void OnCellClicked(GameObject obj) { InspectorManager.Inspect(obj); } private IEnumerator TempFixCoro() { float start = Time.realtimeSinceStartup; while (Time.realtimeSinceStartup - start < 2.5f) { yield return null; } sceneDropdown.value = sceneDropdown.options.Count - 1; sceneDropdown.value = 0; } private void RefreshSceneLoaderOptions(string filter) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown allSceneDropdown.options.Clear(); allSceneDropdown.options.Add(new OptionData("[Select a scene]")); foreach (string allSceneName in SceneHandler.AllSceneNames) { if (string.IsNullOrEmpty(filter) || MiscUtility.ContainsIgnoreCase(allSceneName, filter)) { allSceneDropdown.options.Add(new OptionData(Path.GetFileNameWithoutExtension(allSceneName))); } } allSceneDropdown.RefreshShownValue(); if (loadButton != null) { RefreshSceneLoaderButtons(); } } private void RefreshSceneLoaderButtons() { if (allSceneDropdown.captionText.text == "[Select a scene]") { ((Selectable)loadButton.Component).interactable = false; ((Selectable)loadAdditiveButton.Component).interactable = false; } else { ((Selectable)loadButton.Component).interactable = true; ((Selectable)loadAdditiveButton.Component).interactable = true; } } private void ConstructSceneLoader() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) try { if (SceneHandler.WasAbleToGetScenesInBuild) { GameObject obj = UIFactory.CreateVerticalGroup(uiRoot, "SceneLoader", true, true, true, true, 0, default(Vector4), default(Color), (TextAnchor?)null); int? num = 25; UIFactory.SetLayoutElement(obj, (int?)null, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(obj, "SceneLoaderLabel", "Scene Loader", (TextAnchor)3, Color.white, true, 14)).gameObject; num = 25; int? num2 = 0; UIFactory.SetLayoutElement(gameObject, (int?)null, num, (int?)null, num2, (int?)null, (int?)null, (bool?)null); InputFieldRef obj2 = UIFactory.CreateInputField(obj, "SearchFilterInput", "Filter scene names..."); GameObject uIRoot = ((UIModel)obj2).UIRoot; num2 = 25; num = 0; UIFactory.SetLayoutElement(uIRoot, (int?)null, num2, (int?)null, num, (int?)null, (int?)null, (bool?)null); obj2.OnValueChanged += RefreshSceneLoaderOptions; GameObject obj3 = UIFactory.CreateDropdown(obj, "SceneLoaderDropdown", ref allSceneDropdown, "", 14, (Action)null, (string[])null); num = 25; UIFactory.SetLayoutElement(obj3, (int?)150, num, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); RefreshSceneLoaderOptions(string.Empty); GameObject val = UIFactory.CreateHorizontalGroup(obj, "LoadButtons", true, true, true, true, 4, default(Vector4), default(Color), (TextAnchor?)null); loadButton = UIFactory.CreateButton(val, "LoadSceneButton", "Load (Single)", (Color?)new Color(0.1f, 0.3f, 0.3f)); GameObject gameObject2 = ((Component)loadButton.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject2, (int?)150, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj4 = loadButton; obj4.OnClick = (Action)System.Delegate.Combine(obj4.OnClick, (Action)delegate { TryLoadScene((LoadSceneMode)0, allSceneDropdown); }); loadAdditiveButton = UIFactory.CreateButton(val, "LoadSceneButton", "Load (Additive)", (Color?)new Color(0.1f, 0.3f, 0.3f)); GameObject gameObject3 = ((Component)loadAdditiveButton.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject3, (int?)150, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj5 = loadAdditiveButton; obj5.OnClick = (Action)System.Delegate.Combine(obj5.OnClick, (Action)delegate { TryLoadScene((LoadSceneMode)1, allSceneDropdown); }); Color value = default(Color); ((Color)(ref value))..ctor(0.24f, 0.24f, 0.24f); Button component = loadButton.Component; Color? val2 = value; RuntimeHelper.SetColorBlock((Selectable)(object)component, (Color?)null, (Color?)null, (Color?)null, val2); Button component2 = loadAdditiveButton.Component; val2 = value; RuntimeHelper.SetColorBlock((Selectable)(object)component2, (Color?)null, (Color?)null, (Color?)null, val2); ((Selectable)loadButton.Component).interactable = false; ((Selectable)loadAdditiveButton.Component).interactable = false; ((UnityEvent)(object)allSceneDropdown.onValueChanged).AddListener((UnityAction)delegate { RefreshSceneLoaderButtons(); }); } } catch (Exception ex) { ExplorerCore.LogWarning("Could not create the Scene Loader helper! " + ReflectionExtensions.ReflectionExToString(ex, true)); } } } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] public static class SceneHandler { private static Scene? selectedScene; private const string dontDestroyName = "DontDestroyOnLoad"; public static Scene? SelectedScene { get { return selectedScene; } internal set { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (selectedScene.HasValue) { Scene? val = selectedScene; Scene? val2 = value; if (val.HasValue == val2.HasValue && (!val.HasValue || val.GetValueOrDefault() == val2.GetValueOrDefault())) { return; } } if (value.HasValue) { selectedScene = value; SceneHandler.OnInspectedSceneChanged?.Invoke(selectedScene.Value); } } } public static IEnumerable CurrentRootObjects { get; private set; } = (IEnumerable)(object)new GameObject[0]; public static List LoadedScenes { get; private set; } = new List(); public static List AllSceneNames { get; private set; } = new List(); internal static int DefaultSceneCount => 1 + (DontDestroyExists ? 1 : 0); public static bool InspectingAssetScene { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (SelectedScene.HasValue) { Scene value = SelectedScene.Value; return ((Scene)(ref value)).handle == SceneHandle.op_Implicit(-1); } return false; } } public static bool WasAbleToGetScenesInBuild { get; private set; } public static bool DontDestroyExists { get; private set; } [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] [method: <1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(2)] [field: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] public static event Action OnInspectedSceneChanged; [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(new byte[] { 2, 1 })] [method: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(new byte[] { 2, 1 })] [field: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(new byte[] { 2, 1 })] public static event Action> OnLoadedScenesUpdated; internal static void Init() { try { Type typeByName = ReflectionUtility.GetTypeByName("UnityEngine.SceneManagement.Scene"); if (typeByName == null) { throw new Exception("This version of Unity does not ship with the 'Scene' class."); } MethodInfo method = typeByName.GetMethod("GetNameInternal", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); object[] array = new object[1]; MethodInfo method2 = method.GetParameters()[0].ParameterType.GetMethod("op_Implicit", new Type[1] { typeof(int) }); array[0] = method2.Invoke(null, new object[1] { -12 }); string obj = (string)method?.Invoke(null, array); if (string.IsNullOrEmpty(obj)) { throw new Exception("Scene.GetNameInternal returned null for DontDestroyOnLoad scene."); } DontDestroyExists = obj == "DontDestroyOnLoad"; } catch (Exception ex) { ExplorerCore.LogWarning("Unable to check for existence of DontDestroyOnLoad scene via Scene.GetNameInternal: " + ex.Message); DontDestroyExists = SceneManager.GetAllScenes().Any((Scene s) => ((Scene)(ref s)).name == "DontDestroyOnLoad"); } try { Type typeByName2 = ReflectionUtility.GetTypeByName("UnityEngine.SceneManagement.SceneUtility"); if (typeByName2 == null) { throw new Exception("This version of Unity does not ship with the 'SceneUtility' class, or it was not unstripped."); } MethodInfo method3 = typeByName2.GetMethod("GetScenePathByBuildIndex", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); int sceneCountInBuildSettings = SceneManager.sceneCountInBuildSettings; for (int num = 0; num < sceneCountInBuildSettings; num++) { string text = (string)method3?.Invoke(null, new object[1] { num }); if (!string.IsNullOrEmpty(text)) { AllSceneNames.Add(text); } } WasAbleToGetScenesInBuild = true; } catch (Exception arg) { WasAbleToGetScenesInBuild = false; ExplorerCore.LogWarning($"Unable to generate list of all Scenes in the build: {arg}"); } } private static Scene CreateSceneWithHandle(int id) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) object obj = (object)default(Scene); object value = SceneHandle.op_Implicit(id); typeof(Scene).GetField("m_Handle", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, value); return (Scene)obj; } internal static void Update() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) Scene val; int num; if (SelectedScene.HasValue) { if (DontDestroyExists) { val = SelectedScene.Value; if (((Scene)(ref val)).handle == SceneHandle.op_Implicit(-12)) { num = 1; goto IL_005f; } } val = SelectedScene.Value; num = ((((Scene)(ref val)).handle == SceneHandle.op_Implicit(-1)) ? 1 : 0); } else { num = 0; } goto IL_005f; IL_005f: bool flag = (byte)num != 0; LoadedScenes.Clear(); for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); Scene val2 = sceneAt; val = default(Scene); if (val2 == val || !((Scene)(ref sceneAt)).isLoaded || !((Scene)(ref sceneAt)).IsValid()) { continue; } if (!flag) { val = sceneAt; Scene? val3 = SelectedScene; if (val3.HasValue && val == val3.GetValueOrDefault()) { flag = true; } } LoadedScenes.Add(sceneAt); } if (DontDestroyExists) { LoadedScenes.Add(CreateSceneWithHandle(-12)); } LoadedScenes.Add(CreateSceneWithHandle(-1)); if (!flag) { SelectedScene = LoadedScenes.First(); } SceneHandler.OnLoadedScenesUpdated?.Invoke(LoadedScenes); if (SelectedScene.HasValue) { val = SelectedScene.Value; if (((Scene)(ref val)).IsValid()) { CurrentRootObjects = RuntimeHelper.GetRootGameObjects(SelectedScene.Value); return; } } Object[] array = RuntimeHelper.FindObjectsOfTypeAll(typeof(GameObject)); List list = new List(); Object[] array2 = array; for (int j = 0; j < array2.Length; j++) { GameObject val4 = ReflectionExtensions.TryCast((object)array2[j]); if ((Object)(object)val4 != (Object)null && (Object)(object)val4.transform != (Object)null && (Object)(object)val4.transform.parent == (Object)null) { val = val4.scene; if (!((Scene)(ref val)).IsValid()) { list.Add(val4); } } } CurrentRootObjects = list; } } public enum SearchContext { UnityObject, Singleton, Class } public enum ChildFilter { Any, RootObject, HasParent } public enum SceneFilter { Any, ActivelyLoaded, DontDestroyOnLoad, HideAndDontSave } public static class SearchProvider { internal static string[] instanceNames = new string[10] { "m_instance", "m_Instance", "s_instance", "s_Instance", "_instance", "_Instance", "instance", "Instance", "k__BackingField", "k__BackingField" }; private static bool Filter(Scene scene, SceneFilter filter) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) return filter switch { SceneFilter.Any => true, SceneFilter.DontDestroyOnLoad => ((Scene)(ref scene)).handle == SceneHandle.op_Implicit(-12), SceneFilter.HideAndDontSave => scene == default(Scene), SceneFilter.ActivelyLoaded => ((Scene)(ref scene)).buildIndex != -1, _ => false, }; } internal static List UnityObjectSearch(string input, string customTypeInput, ChildFilter childFilter, SceneFilter sceneFilter) { //IL_015e: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Type type = null; if (!string.IsNullOrEmpty(customTypeInput)) { Type typeByName = ReflectionUtility.GetTypeByName(customTypeInput); if ((object)typeByName != null) { if (typeof(Object).IsAssignableFrom(typeByName)) { type = typeByName; } else { ExplorerCore.LogWarning("Custom type '" + typeByName.FullName + "' is not assignable from UnityEngine.Object!"); } } else { ExplorerCore.LogWarning("Could not find any type by name '" + customTypeInput + "'!"); } } if (type == null) { type = typeof(Object); } Object[] array = RuntimeHelper.FindObjectsOfTypeAll(type); string text = null; if (!string.IsNullOrEmpty(input)) { text = input; } bool flag = type == typeof(GameObject) || typeof(Component).IsAssignableFrom(type); Object[] array2 = array; foreach (Object val in array2) { if (!string.IsNullOrEmpty(text) && !MiscUtility.ContainsIgnoreCase(val.name, text)) { continue; } GameObject val2 = null; Type actualType = ReflectionExtensions.GetActualType((object)val); if (actualType == typeof(GameObject)) { val2 = ReflectionExtensions.TryCast((object)val); } else if (typeof(Component).IsAssignableFrom(actualType)) { Component val3 = (Component)(object)((val is Component) ? val : null); if (val3 != null) { val2 = val3.gameObject; } } if (!Object.op_Implicit((Object)(object)val2) || (!(((Object)val2.transform.root).name == "UniverseLibCanvas") && (!flag || ((sceneFilter == SceneFilter.Any || Filter(val2.scene, sceneFilter)) && (childFilter == ChildFilter.Any || (Object.op_Implicit((Object)(object)val2) && (childFilter != ChildFilter.HasParent || Object.op_Implicit((Object)(object)val2.transform.parent)) && (childFilter != ChildFilter.RootObject || !Object.op_Implicit((Object)(object)val2.transform.parent)))))))) { list.Add(val); } } return list; } internal static List ClassSearch(string input) { List list = new List(); if (string.IsNullOrEmpty(input)) { return list; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type[] array = ReflectionExtensions.TryGetTypes(assemblies[i]); foreach (Type type in array) { try { if (MiscUtility.ContainsIgnoreCase(type.FullName, input)) { list.Add(type); } } catch (Exception ex) { ExplorerCore.LogError("Error while searching for singletons in " + type.FullName + "! " + ex.Message); } } } return list; } internal static List InstanceSearch(string input) { List list = new List(); if (string.IsNullOrEmpty(input)) { return list; } BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { foreach (Type item in from it in ReflectionExtensions.TryGetTypes(assemblies[i]) where (!it.IsSealed || !it.IsAbstract) && !it.IsEnum select it) { try { if (MiscUtility.ContainsIgnoreCase(item.FullName, input)) { ReflectionUtility.FindSingleton(instanceNames, item, bindingFlags, list); } } catch (Exception ex) { ExplorerCore.LogError("Error while searching for singletons in " + item.FullName + "! " + ex.Message); } } } return list.Distinct().ToList(); } } } namespace UnityExplorer.Loader.BIE { public class BepInExConfigHandler : ConfigHandler { private const string CTG_NAME = "UnityExplorer"; private ConfigFile Config => ((BaseUnityPlugin)ExplorerBepInPlugin.Instance).Config; public override void Init() { } public override void RegisterConfigElement(ConfigElement config) { ConfigEntry entry = Config.Bind("UnityExplorer", config.Name, config.Value, config.Description); entry.SettingChanged += delegate { config.Value = entry.Value; }; } public override T GetConfigValue(ConfigElement element) { ConfigEntry val = default(ConfigEntry); if (Config.TryGetEntry("UnityExplorer", element.Name, ref val)) { return val.Value; } throw new Exception("Could not get config entry '" + element.Name + "'"); } public override void SetConfigValue(ConfigElement element, T value) { ConfigEntry val = default(ConfigEntry); if (Config.TryGetEntry("UnityExplorer", element.Name, ref val)) { val.Value = value; } else { ExplorerCore.Log("Could not get config entry '" + element.Name + "'"); } } public override void LoadConfig() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown foreach (KeyValuePair configElement in ConfigManager.ConfigElements) { string key = configElement.Key; ConfigDefinition val = new ConfigDefinition("UnityExplorer", key); if (Config.ContainsKey(val)) { ConfigEntryBase val2 = Config[val]; if (val2 != null) { configElement.Value.BoxedValue = val2.BoxedValue; } } } } public override void SaveConfig() { Config.Save(); } } } namespace UnityExplorer.Inspectors { public class GameObjectInspector : InspectorBase { public GameObject Content; public GameObjectControls Controls; public TransformTree TransformTree; private ScrollPool transformScroll; private readonly List cachedChildren = new List(); public ComponentList ComponentList; private ScrollPool componentScroll; private InputFieldRef addChildInput; private InputFieldRef addCompInput; private float timeOfLastUpdate; private readonly List componentEntries = new List(); private readonly HashSet compInstanceIDs = new HashSet(); private readonly List behaviourEntries = new List(); private readonly List behaviourEnabledStates = new List(); public new GameObject Target => ReflectionExtensions.TryCast(base.Target); public override void OnBorrowedFromPool(object target) { base.OnBorrowedFromPool(target); base.Target = ReflectionExtensions.TryCast(target); Controls.UpdateGameObjectInfo(firstUpdate: true, force: true); Controls.TransformControl.UpdateTransformControlValues(force: true); RuntimeHelper.StartCoroutine(InitCoroutine()); } private IEnumerator InitCoroutine() { yield return null; LayoutRebuilder.ForceRebuildLayoutImmediate(InspectorPanel.Instance.ContentRect); TransformTree.Rebuild(); ((ButtonListHandler)ComponentList).ScrollPool.Refresh(true, true); UpdateComponents(); } public override void OnReturnToPool() { base.OnReturnToPool(); addChildInput.Text = ""; addCompInput.Text = ""; TransformTree.Clear(); UpdateComponents(); } public override void CloseInspector() { InspectorManager.ReleaseInspector(this); } public void OnTransformCellClicked(GameObject newTarget) { base.Target = newTarget; Controls.UpdateGameObjectInfo(firstUpdate: true, force: true); Controls.TransformControl.UpdateTransformControlValues(force: true); TransformTree.RefreshData(true, false, true, false); UpdateComponents(); } public override void Update() { if (!base.IsActive) { return; } if (UnityHelpers.IsNullOrDestroyed(base.Target, false)) { InspectorManager.ReleaseInspector(this); return; } Controls.UpdateVectorSlider(); Controls.TransformControl.UpdateTransformControlValues(force: false); if (UnityHelpers.OccuredEarlierThan(timeOfLastUpdate, 1f)) { timeOfLastUpdate = Time.realtimeSinceStartup; Controls.UpdateGameObjectInfo(firstUpdate: false, force: false); TransformTree.RefreshData(true, false, false, false); UpdateComponents(); } } private IEnumerable GetTransformEntries() { if (!Object.op_Implicit((Object)(object)Target)) { return Enumerable.Empty(); } cachedChildren.Clear(); for (int i = 0; i < Target.transform.childCount; i++) { cachedChildren.Add(((Component)Target.transform.GetChild(i)).gameObject); } return cachedChildren; } private List GetComponentEntries() { if (!Object.op_Implicit((Object)(object)Target)) { return Enumerable.Empty().ToList(); } return componentEntries; } public void UpdateComponents() { if (!Object.op_Implicit((Object)(object)Target)) { componentEntries.Clear(); compInstanceIDs.Clear(); behaviourEntries.Clear(); behaviourEnabledStates.Clear(); ((ButtonListHandler)ComponentList).RefreshData(); ((ButtonListHandler)ComponentList).ScrollPool.Refresh(true, true); return; } IEnumerable components = Target.GetComponents(); IEnumerable components2 = Target.GetComponents(); bool flag = false; int num = 0; foreach (Component item in components) { if (Object.op_Implicit((Object)(object)item)) { num++; if (!compInstanceIDs.Contains(((Object)item).GetInstanceID())) { flag = true; break; } } } if (!flag) { if (num != componentEntries.Count) { flag = true; } else { num = 0; foreach (Behaviour item2 in components2) { if (Object.op_Implicit((Object)(object)item2)) { if (num >= behaviourEnabledStates.Count || item2.enabled != behaviourEnabledStates[num]) { flag = true; break; } num++; } } if (!flag && num != behaviourEntries.Count) { flag = true; } } } if (!flag) { return; } componentEntries.Clear(); compInstanceIDs.Clear(); foreach (Component item3 in components) { if (Object.op_Implicit((Object)(object)item3)) { componentEntries.Add(item3); compInstanceIDs.Add(((Object)item3).GetInstanceID()); } } behaviourEntries.Clear(); behaviourEnabledStates.Clear(); foreach (Behaviour item4 in components2) { if (Object.op_Implicit((Object)(object)item4) && typeof(Behaviour).IsAssignableFrom(((object)item4).GetType())) { try { behaviourEntries.Add(item4); } catch (Exception message) { ExplorerCore.LogWarning(message); } behaviourEnabledStates.Add(item4.enabled); } } ((ButtonListHandler)ComponentList).RefreshData(); ((ButtonListHandler)ComponentList).ScrollPool.Refresh(true, false); } private void OnAddChildClicked(string input) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) new GameObject(input).transform.parent = Target.transform; TransformTree.RefreshData(true, false, true, false); } private void OnAddComponentClicked(string input) { Type typeByName = ReflectionUtility.GetTypeByName(input); if ((object)typeByName != null) { try { RuntimeHelper.AddComponent(Target, typeByName); UpdateComponents(); return; } catch (Exception ex) { ExplorerCore.LogWarning("Exception adding component: " + ReflectionExtensions.ReflectionExToString(ex, true)); return; } } ExplorerCore.LogWarning("Could not find any Type by the name '" + input + "'!"); } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "GameObjectInspector", true, false, true, true, 5, new Vector4(4f, 4f, 4f, 4f), new Color(0.065f, 0.065f, 0.065f), (TextAnchor?)null); AutoSliderScrollbar val = default(AutoSliderScrollbar); GameObject obj = UIFactory.CreateScrollView(base.UIRoot, "GameObjectInspector", ref Content, ref val, new Color(0.065f, 0.065f, 0.065f)); int? num = 250; int? num2 = 300; int? num3 = 0; int? num4 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num, num4, num3, (int?)null, num2, (bool?)null); GameObject content = Content; num4 = 3; num3 = 2; num2 = 2; num = 2; int? num5 = 2; UIFactory.SetLayoutGroup(content, (bool?)null, (bool?)null, (bool?)null, (bool?)null, num4, num3, num2, num, num5, (TextAnchor?)null); Controls = new GameObjectControls(this); ConstructLists(); return base.UIRoot; } private void ConstructLists() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Expected O, but got Unknown //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateUIObject("ListHolders", base.UIRoot, default(Vector2)); UIFactory.SetLayoutGroup(val, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)8, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null); int? num = 150; int? num2 = 9999; int? num3 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, num3, (int?)null, (int?)null, (bool?)null); GameObject val2 = UIFactory.CreateUIObject("ChildrenGroup", val, default(Vector2)); num3 = 9999; num2 = 9999; UIFactory.SetLayoutElement(val2, (int?)null, (int?)null, num3, num2, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(val2, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(val2, "ChildListTitle", "Children", (TextAnchor)4, default(Color), false, 16)).gameObject; num2 = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject val3 = UIFactory.CreateUIObject("AddChildRow", val2, default(Vector2)); UIFactory.SetLayoutGroup(val3, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); addChildInput = UIFactory.CreateInputField(val3, "AddChildInput", "Enter a name..."); GameObject gameObject2 = ((Component)addChildInput.Component).gameObject; num2 = 25; num3 = 9999; UIFactory.SetLayoutElement(gameObject2, (int?)null, num2, (int?)null, (int?)null, num3, (int?)null, (bool?)null); ButtonRef obj = UIFactory.CreateButton(val3, "AddChildButton", "Add Child", (Color?)null); GameObject gameObject3 = ((Component)obj.Component).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)80, num3, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, (Action)delegate { OnAddChildClicked(addChildInput.Text); }); GameObject val4 = default(GameObject); GameObject val5 = default(GameObject); transformScroll = UIFactory.CreateScrollPool(val2, "TransformTree", ref val4, ref val5, (Color?)new Color(0.11f, 0.11f, 0.11f)); TransformTree = new TransformTree(transformScroll, (Func>)GetTransformEntries, (Action)OnTransformCellClicked); GameObject val6 = UIFactory.CreateUIObject("ComponentGroup", val, default(Vector2)); num3 = 9999; num2 = 9999; UIFactory.SetLayoutElement(val6, (int?)null, (int?)null, num3, num2, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(val6, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject gameObject4 = ((Component)UIFactory.CreateLabel(val6, "CompListTitle", "Components", (TextAnchor)4, default(Color), false, 16)).gameObject; num2 = 9999; UIFactory.SetLayoutElement(gameObject4, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject val7 = UIFactory.CreateUIObject("AddCompRow", val6, default(Vector2)); UIFactory.SetLayoutGroup(val7, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); addCompInput = UIFactory.CreateInputField(val7, "AddCompInput", "Enter a Component type..."); GameObject gameObject5 = ((Component)addCompInput.Component).gameObject; num2 = 25; num3 = 9999; UIFactory.SetLayoutElement(gameObject5, (int?)null, num2, (int?)null, (int?)null, num3, (int?)null, (bool?)null); ButtonRef obj2 = UIFactory.CreateButton(val7, "AddCompButton", "Add Comp", (Color?)null); GameObject gameObject6 = ((Component)obj2.Component).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject6, (int?)80, num3, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, (Action)delegate { OnAddComponentClicked(addCompInput.Text); }); new TypeCompleter(typeof(Component), addCompInput, allowAbstract: false, allowEnum: false, allowGeneric: false); GameObject val8 = default(GameObject); GameObject val9 = default(GameObject); componentScroll = UIFactory.CreateScrollPool(val6, "ComponentList", ref val8, ref val9, (Color?)new Color(0.11f, 0.11f, 0.11f)); GameObject obj3 = val8; num3 = 9999; UIFactory.SetLayoutElement(obj3, (int?)null, (int?)null, (int?)null, num3, (int?)null, (int?)null, (bool?)null); GameObject obj4 = val9; num3 = 9999; UIFactory.SetLayoutElement(obj4, (int?)null, (int?)null, (int?)null, num3, (int?)null, (int?)null, (bool?)null); ComponentList = new ComponentList(componentScroll, GetComponentEntries) { Parent = this }; componentScroll.Initialize((ICellPoolDataSource)(object)ComponentList, (Action)null); } } public abstract class InspectorBase : IPooledObject { public bool IsActive { get; internal set; } public object Target { get; set; } public Type TargetType { get; protected set; } public InspectorTab Tab { get; internal set; } public GameObject UIRoot { get; set; } public float DefaultHeight => -1f; public abstract GameObject CreateContent(GameObject parent); public abstract void Update(); public abstract void CloseInspector(); public virtual void OnBorrowedFromPool(object target) { Target = target; TargetType = ((target is Type type) ? type : ReflectionExtensions.GetActualType(target)); Tab = Pool.Borrow(); Tab.UIRoot.transform.SetParent(InspectorPanel.Instance.NavbarHolder.transform, false); ButtonRef tabButton = Tab.TabButton; tabButton.OnClick = (Action)System.Delegate.Combine(tabButton.OnClick, new Action(OnTabButtonClicked)); ButtonRef closeButton = Tab.CloseButton; closeButton.OnClick = (Action)System.Delegate.Combine(closeButton.OnClick, new Action(CloseInspector)); } public virtual void OnReturnToPool() { Pool.Return(Tab); Target = null; ButtonRef tabButton = Tab.TabButton; tabButton.OnClick = (Action)System.Delegate.Remove(tabButton.OnClick, new Action(OnTabButtonClicked)); ButtonRef closeButton = Tab.CloseButton; closeButton.OnClick = (Action)System.Delegate.Remove(closeButton.OnClick, new Action(CloseInspector)); } public virtual void OnSetActive() { Tab.SetTabColor(active: true); UIRoot.SetActive(true); IsActive = true; LayoutRebuilder.ForceRebuildLayoutImmediate(UIRoot.GetComponent()); } public virtual void OnSetInactive() { Tab.SetTabColor(active: false); UIRoot.SetActive(false); IsActive = false; } private void OnTabButtonClicked() { InspectorManager.SetInspectorActive(this); } } public class InspectorTab : IPooledObject { public ButtonRef TabButton; public Text TabText; public ButtonRef CloseButton; private static readonly Color enabledTabColor = new Color(0.15f, 0.22f, 0.15f); private static readonly Color disabledTabColor = new Color(0.13f, 0.13f, 0.13f); public GameObject UIRoot { get; set; } public float DefaultHeight => 25f; public void SetTabColor(bool active) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Color val = (active ? enabledTabColor : disabledTabColor); RuntimeHelper.SetColorBlock((Selectable)(object)TabButton.Component, (Color?)val, (Color?)(val * 1.2f), (Color?)null, (Color?)null); } public GameObject CreateContent(GameObject parent) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", false, true, true, true, 1, default(Vector4), new Color(0.13f, 0.13f, 0.13f), (TextAnchor?)(TextAnchor)3); GameObject uIRoot = UIRoot; int? num = 200; int? num2 = 0; UIFactory.SetLayoutElement(uIRoot, num, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); UIRoot.AddComponent(); UIRoot.AddComponent(); TabButton = UIFactory.CreateButton(UIRoot, "TabButton", "", (Color?)null); GameObject gameObject = ((Component)TabButton.Component).gameObject; int? num3 = 173; num2 = 0; UIFactory.SetLayoutElement(gameObject, num3, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(((Component)TabButton.Component).gameObject, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)0, (int?)0, (int?)0, (int?)3, (int?)null, (TextAnchor?)null); TabButton.GameObject.AddComponent(); TabText = TabButton.ButtonText; GameObject gameObject2 = ((Component)TabText).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)150, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); TabText.alignment = (TextAnchor)3; TabText.fontSize = 12; TabText.horizontalOverflow = (HorizontalWrapMode)1; CloseButton = UIFactory.CreateButton(UIRoot, "CloseButton", "X", (Color?)new Color(0.15f, 0.15f, 0.15f, 1f)); GameObject gameObject3 = ((Component)CloseButton.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)25, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)CloseButton.ButtonText).color = Color.red; return UIRoot; } } public enum MouseInspectMode { World, UI } public class MouseInspector : PanelBase { private readonly WorldInspector worldInspector; private readonly UiInspector uiInspector; private static Vector3 lastMousePos; internal static readonly string UIBaseGUID = "com.sinai.unityexplorer.MouseInspector"; internal static UIBase inspectorUIBase; private Text inspectorLabelTitle; private Text objNameLabel; private Text objPathLabel; private Text mousePosLabel; private static float timeOfLastRaycast; public static MouseInspector Instance { get; private set; } public static bool Inspecting { get; set; } public static MouseInspectMode Mode { get; set; } public MouseInspectorBase CurrentInspector => Mode switch { MouseInspectMode.UI => uiInspector, MouseInspectMode.World => worldInspector, _ => null, }; public override string Name => "Inspect Under Mouse"; public override int MinWidth => -1; public override int MinHeight => -1; public override Vector2 DefaultAnchorMin => Vector2.zero; public override Vector2 DefaultAnchorMax => Vector2.zero; public override bool CanDragAndResize => false; public MouseInspector(UIBase owner) : base(owner) { Instance = this; worldInspector = new WorldInspector(); uiInspector = new UiInspector(); } public static void OnDropdownSelect(int index) { switch (index) { case 0: return; case 1: Instance.StartInspect(MouseInspectMode.World); break; case 2: Instance.StartInspect(MouseInspectMode.UI); break; } InspectorPanel.Instance.MouseInspectDropdown.value = 0; } public void StartInspect(MouseInspectMode mode) { Mode = mode; Inspecting = true; CurrentInspector.OnBeginMouseInspect(); PanelManager.ForceEndResize(); ((Component)UIManager.NavBarRect).gameObject.SetActive(false); UIManager.UiBase.Panels.PanelHolder.SetActive(false); UIManager.UiBase.SetOnTop(); ((UIModel)this).SetActive(true); } internal void ClearHitData() { CurrentInspector.ClearHitData(); objNameLabel.text = "No hits..."; objPathLabel.text = ""; } public void StopInspect() { CurrentInspector.OnEndInspect(); ClearHitData(); Inspecting = false; ((Component)UIManager.NavBarRect).gameObject.SetActive(true); UIManager.UiBase.Panels.PanelHolder.SetActive(true); Dropdown mouseInspectDropdown = InspectorPanel.Instance.MouseInspectDropdown; Transform val = ((Component)mouseInspectDropdown).transform.Find("Dropdown List"); if (val != null) { typeof(Dropdown).GetMethod("DestroyDropdownList", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(mouseInspectDropdown, new object[1] { ((Component)val).gameObject }); } ((UIModel)this).UIRoot.SetActive(false); } public bool TryUpdate() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value)) { Instance.StartInspect(MouseInspectMode.World); } if (InputManager.GetKeyDown(ConfigManager.UI_MouseInspect_Keybind.Value)) { Instance.StartInspect(MouseInspectMode.UI); } if (Inspecting) { UpdateInspect(); } return Inspecting; } internal void UpdateInspectorTitle(string title) { if (Object.op_Implicit((Object)(object)inspectorLabelTitle)) { inspectorLabelTitle.text = title; } } internal void UpdateObjectNameLabel(string name) { if (Object.op_Implicit((Object)(object)objNameLabel)) { objNameLabel.text = name; } } internal void UpdateObjectPathLabel(string path) { if (Object.op_Implicit((Object)(object)objPathLabel)) { objPathLabel.text = path; } } public void UpdateInspect() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (InputManager.GetKeyDown((KeyCode)27)) { StopInspect(); return; } if (InputManager.GetMouseButtonDown(0)) { CurrentInspector.OnSelectMouseInspect(); StopInspect(); return; } Vector3 mousePosition = InputManager.MousePosition; if (mousePosition != lastMousePos) { UpdatePosition(Vector2.op_Implicit(mousePosition)); } if (UnityHelpers.OccuredEarlierThan(timeOfLastRaycast, 0.1f)) { timeOfLastRaycast = Time.realtimeSinceStartup; CurrentInspector.UpdateMouseInspect(Vector2.op_Implicit(mousePosition)); } } internal unsafe void UpdatePosition(Vector2 mousePos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) lastMousePos = Vector2.op_Implicit(mousePos); mousePosLabel.text = "Mouse Position: " + ((object)(*(Vector2*)(&mousePos))/*cast due to .constrained prefix*/).ToString(); if (mousePos.x < 350f) { mousePos.x = 350f; } if (mousePos.x > (float)(Screen.width - 350)) { mousePos.x = Screen.width - 350; } float y = mousePos.y; Rect rect = ((PanelBase)this).Rect.rect; if (y < ((Rect)(ref rect)).height) { ref float y2 = ref mousePos.y; float num = y2; rect = ((PanelBase)this).Rect.rect; y2 = num + (((Rect)(ref rect)).height + 10f); } else { mousePos.y -= 10f; } Vector3 val = inspectorUIBase.RootObject.transform.InverseTransformPoint(Vector2.op_Implicit(mousePos)); ((UIModel)this).UIRoot.transform.localPosition = new Vector3(val.x, val.y, 0f); } public override void SetDefaultSizeAndPosition() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) ((PanelBase)this).SetDefaultSizeAndPosition(); ((PanelBase)this).Rect.anchorMin = Vector2.zero; ((PanelBase)this).Rect.anchorMax = Vector2.zero; ((PanelBase)this).Rect.pivot = new Vector2(0.5f, 1f); ((PanelBase)this).Rect.sizeDelta = new Vector2(700f, 150f); } protected override void ConstructPanelContent() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) ((PanelBase)this).TitleBar.SetActive(false); ((UIModel)this).UIRoot.transform.SetParent(UIManager.UIRoot.transform, false); GameObject val = UIFactory.CreateVerticalGroup(((PanelBase)this).ContentRoot, "InspectContent", true, true, true, true, 3, new Vector4(2f, 2f, 2f, 2f), default(Color), (TextAnchor?)null); int? num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, (int?)null, num, num2, (int?)null, (int?)null, (bool?)null); inspectorLabelTitle = UIFactory.CreateLabel(val, "InspectLabel", "", (TextAnchor)4, default(Color), true, 14); GameObject gameObject = ((Component)inspectorLabelTitle).gameObject; num2 = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); mousePosLabel = UIFactory.CreateLabel(val, "MousePosLabel", "Mouse Position:", (TextAnchor)4, default(Color), true, 14); objNameLabel = UIFactory.CreateLabel(val, "HitLabelObj", "No hits...", (TextAnchor)3, default(Color), true, 14); objNameLabel.horizontalOverflow = (HorizontalWrapMode)1; objPathLabel = UIFactory.CreateLabel(val, "PathLabel", "", (TextAnchor)3, default(Color), true, 14); objPathLabel.fontStyle = (FontStyle)2; objPathLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject2 = ((Component)objPathLabel).gameObject; num2 = 75; UIFactory.SetLayoutElement(gameObject2, (int?)null, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ((UIModel)this).UIRoot.SetActive(false); } } [Flags] public enum MemberFilter { None = 0, Property = 1, Field = 2, Constructor = 4, Method = 8, All = 0xF } public class ReflectionInspector : InspectorBase, ICellPoolDataSource, ICacheObjectController { private List members = new List(); private readonly List filteredMembers = new List(); private string nameFilter; private BindingFlags scopeFlagsFilter; private MemberFilter memberFilter = MemberFilter.All; private bool refreshWanted; private string lastNameFilter; private BindingFlags lastFlagsFilter; private MemberFilter lastMemberFilter = MemberFilter.All; private float timeOfLastAutoUpdate; private static readonly Color disabledButtonColor = new Color(0.24f, 0.24f, 0.24f); private static readonly Color enabledButtonColor = new Color(0.2f, 0.27f, 0.2f); private InputFieldRef hiddenNameText; private Text nameText; private Text assemblyText; private Toggle autoUpdateToggle; private ButtonRef dnSpyButton; private ButtonRef makeGenericButton; private GenericConstructorWidget genericConstructor; private InputFieldRef filterInputField; private readonly List memberTypeToggles = new List(); private readonly Dictionary scopeFilterButtons = new Dictionary(); public CacheObjectBase ParentCacheObject { get; set; } public bool StaticOnly { get; internal set; } public bool CanWrite => true; public bool AutoUpdateWanted => autoUpdateToggle.isOn; private static int LeftGroupWidth { get; set; } private static int RightGroupWidth { get; set; } public GameObject ContentRoot { get; private set; } public ScrollPool MemberScrollPool { get; private set; } public int ItemCount => filteredMembers.Count; public UnityObjectWidget UnityWidget { get; private set; } public string TabButtonText { get; set; } public override void OnBorrowedFromPool(object target) { base.OnBorrowedFromPool(target); CalculateLayouts(); SetTarget(target); RuntimeHelper.StartCoroutine(InitCoroutine()); } private IEnumerator InitCoroutine() { yield return null; LayoutRebuilder.ForceRebuildLayoutImmediate(InspectorPanel.Instance.ContentRect); } public override void CloseInspector() { InspectorManager.ReleaseInspector(this); } public override void OnReturnToPool() { foreach (CacheMember member in members) { member.UnlinkFromView(); member.ReleasePooledObjects(); } members.Clear(); filteredMembers.Clear(); autoUpdateToggle.isOn = false; if (UnityWidget != null) { UnityWidget.OnReturnToPool(); Pool.Return(UnityWidget.GetType(), (IPooledObject)(object)UnityWidget); UnityWidget = null; } genericConstructor?.Cancel(); base.OnReturnToPool(); } private void SetTarget(object target) { string text; if (StaticOnly) { base.Target = null; base.TargetType = target as Type; text = "[S]"; makeGenericButton.GameObject.SetActive(base.TargetType.IsGenericTypeDefinition); } else { base.TargetType = ReflectionExtensions.GetActualType(target); text = "[R]"; } TabButtonText = text + " " + SignatureHighlighter.Parse(base.TargetType, false, (MemberInfo)null); base.Tab.TabText.text = TabButtonText; nameText.text = SignatureHighlighter.Parse(base.TargetType, true, (MemberInfo)null); hiddenNameText.Text = SignatureHighlighter.RemoveHighlighting(nameText.text); string text2; if (base.TargetType.Assembly is AssemblyBuilder || string.IsNullOrEmpty(base.TargetType.Assembly.Location)) { text2 = base.TargetType.Assembly.GetName().Name + " (in memory)"; dnSpyButton.GameObject.SetActive(false); } else { text2 = Path.GetFileName(base.TargetType.Assembly.Location); dnSpyButton.GameObject.SetActive(true); } assemblyText.text = "Assembly: " + text2; if (!StaticOnly) { UnityWidget = UnityObjectWidget.GetUnityWidget(target, base.TargetType, this); } members = CacheMemberFactory.GetCacheMembers(base.TargetType, this); filterInputField.Text = string.Empty; SetFilter(string.Empty, StaticOnly ? BindingFlags.Static : BindingFlags.Default); ((Component)scopeFilterButtons[BindingFlags.Default].Component).gameObject.SetActive(!StaticOnly); ((Component)scopeFilterButtons[BindingFlags.Instance].Component).gameObject.SetActive(!StaticOnly); foreach (Toggle memberTypeToggle in memberTypeToggles) { memberTypeToggle.isOn = true; } refreshWanted = true; } public override void Update() { if (!base.IsActive) { return; } if (!StaticOnly && UnityHelpers.IsNullOrDestroyed(base.Target, false)) { InspectorManager.ReleaseInspector(this); return; } if (refreshWanted || nameFilter != lastNameFilter || scopeFlagsFilter != lastFlagsFilter || lastMemberFilter != memberFilter) { lastNameFilter = nameFilter; lastFlagsFilter = scopeFlagsFilter; lastMemberFilter = memberFilter; FilterMembers(); MemberScrollPool.Refresh(true, true); refreshWanted = false; } if (UnityHelpers.OccuredEarlierThan(timeOfLastAutoUpdate, 1f)) { timeOfLastAutoUpdate = Time.realtimeSinceStartup; if (UnityWidget != null) { UnityWidget.Update(); } if (AutoUpdateWanted) { UpdateDisplayedMembers(); } } } public void SetFilter(string name, BindingFlags flags) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) nameFilter = name; if (flags != scopeFlagsFilter) { RuntimeHelper.SetColorBlock((Selectable)(object)scopeFilterButtons[scopeFlagsFilter].Component, (Color?)disabledButtonColor, (Color?)(disabledButtonColor * 1.3f), (Color?)null, (Color?)null); scopeFlagsFilter = flags; RuntimeHelper.SetColorBlock((Selectable)(object)scopeFilterButtons[scopeFlagsFilter].Component, (Color?)enabledButtonColor, (Color?)(enabledButtonColor * 1.3f), (Color?)null, (Color?)null); } } private void FilterMembers() { filteredMembers.Clear(); for (int i = 0; i < members.Count; i++) { CacheMember cacheMember = members[i]; if ((scopeFlagsFilter == BindingFlags.Default || ((scopeFlagsFilter != BindingFlags.Instance || !cacheMember.IsStatic) && (scopeFlagsFilter != BindingFlags.Static || cacheMember.IsStatic))) && (!(cacheMember is CacheMethod) || memberFilter.HasFlag(MemberFilter.Method)) && (!(cacheMember is CacheField) || memberFilter.HasFlag(MemberFilter.Field)) && (!(cacheMember is CacheProperty) || memberFilter.HasFlag(MemberFilter.Property)) && (!(cacheMember is CacheConstructor) || memberFilter.HasFlag(MemberFilter.Constructor)) && (string.IsNullOrEmpty(nameFilter) || MiscUtility.ContainsIgnoreCase(cacheMember.NameForFiltering, nameFilter))) { filteredMembers.Add(cacheMember); } } } private void UpdateDisplayedMembers() { bool flag = false; foreach (CacheMemberCell item in MemberScrollPool.CellPool) { if (item.Enabled && item.Occupant != null) { CacheMember memberOccupant = item.MemberOccupant; if (memberOccupant.ShouldAutoEvaluate) { flag = true; memberOccupant.Evaluate(); memberOccupant.SetDataToCell(memberOccupant.CellView); } } } if (flag) { MemberScrollPool.Refresh(false, false); } } public void OnCellBorrowed(CacheMemberCell cell) { } public void SetCell(CacheMemberCell cell, int index) { CacheObjectControllerHelper.SetCell(cell, index, filteredMembers, SetCellLayout); } internal void SetLayouts() { CalculateLayouts(); foreach (CacheMemberCell item in MemberScrollPool.CellPool) { SetCellLayout(item); } } private void CalculateLayouts() { LeftGroupWidth = (int)Math.Max(200f, 0.4f * InspectorManager.PanelWidth - 5f); RightGroupWidth = (int)Math.Max(200f, InspectorManager.PanelWidth - (float)LeftGroupWidth - 65f); } private void SetCellLayout(CacheObjectCell cell) { cell.NameLayout.minWidth = LeftGroupWidth; cell.RightGroupLayout.minWidth = RightGroupWidth; if (cell.Occupant?.IValue != null) { cell.Occupant.IValue.SetLayout(); } } private void OnUpdateClicked() { UpdateDisplayedMembers(); } public void OnSetNameFilter(string name) { SetFilter(name, scopeFlagsFilter); } public void OnSetFlags(BindingFlags flags) { SetFilter(nameFilter, flags); } private void OnMemberTypeToggled(MemberFilter flag, bool val) { if (!val) { memberFilter &= ~flag; } else { memberFilter |= flag; } } private void OnCopyClicked() { ClipboardPanel.Copy(base.Target ?? base.TargetType); } private void OnDnSpyButtonClicked() { string value = ConfigManager.DnSpy_Path.Value; if (File.Exists(value) && value.EndsWith("dnspy.exe", StringComparison.OrdinalIgnoreCase)) { Type type = base.TargetType; if (type.IsGenericType && !type.IsGenericTypeDefinition) { type = type.GetGenericTypeDefinition(); } string arguments = "\"" + type.Assembly.Location + "\" --select T:" + type.FullName; Process.Start(value, arguments); } else { Notification.ShowMessage("Please set a valid dnSpy path in UnityExplorer Settings."); } } private void OnMakeGenericClicked() { ContentRoot.SetActive(false); if (genericConstructor == null) { genericConstructor = new GenericConstructorWidget(); genericConstructor.ConstructUI(base.UIRoot); } genericConstructor.UIRoot.SetActive(true); genericConstructor.Show(OnGenericSubmit, OnGenericCancel, base.TargetType); } private void OnGenericSubmit(Type[] args) { ContentRoot.SetActive(true); genericConstructor.UIRoot.SetActive(false); InspectorManager.Inspect(base.TargetType.MakeGenericType(args)); } private void OnGenericCancel() { ContentRoot.SetActive(true); genericConstructor.UIRoot.SetActive(false); } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_074f: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "ReflectionInspector", true, true, true, true, 5, new Vector4(4f, 4f, 4f, 4f), new Color(0.065f, 0.065f, 0.065f), (TextAnchor?)null); GameObject val = UIFactory.CreateHorizontalGroup(base.UIRoot, "TopRow", false, false, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)(TextAnchor)3); int? num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject val2 = UIFactory.CreateUIObject("TitleHolder", val, default(Vector2)); num2 = 35; num = 0; int? num3 = 9999; UIFactory.SetLayoutElement(val2, (int?)null, num2, num3, num, (int?)null, (int?)null, (bool?)null); nameText = UIFactory.CreateLabel(val2, "VisibleTitle", "NotSet", (TextAnchor)3, default(Color), true, 14); RectTransform component = ((Component)nameText).GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); nameText.fontSize = 17; GameObject gameObject = ((Component)nameText).gameObject; num3 = 35; num = 0; UIFactory.SetLayoutElement(gameObject, (int?)300, num3, (int?)9999, num, (int?)null, (int?)null, (bool?)null); hiddenNameText = UIFactory.CreateInputField(val2, "Title", "not set"); RectTransform component2 = ((Component)hiddenNameText.Component).gameObject.GetComponent(); component2.anchorMin = new Vector2(0f, 0f); component2.anchorMax = new Vector2(1f, 1f); hiddenNameText.Component.readOnly = true; hiddenNameText.Component.lineType = (LineType)2; ((Graphic)((Component)hiddenNameText.Component).gameObject.GetComponent()).color = Color.clear; hiddenNameText.Component.textComponent.horizontalOverflow = (HorizontalWrapMode)0; hiddenNameText.Component.textComponent.fontSize = 17; ((Graphic)hiddenNameText.Component.textComponent).color = Color.clear; GameObject gameObject2 = ((Component)hiddenNameText.Component).gameObject; num = 35; num3 = 0; num2 = 9999; UIFactory.SetLayoutElement(gameObject2, (int?)null, num, num2, num3, (int?)null, (int?)null, (bool?)null); makeGenericButton = UIFactory.CreateButton(val, "MakeGenericButton", "Construct Generic", (Color?)new Color(0.2f, 0.3f, 0.2f)); UIFactory.SetLayoutElement(makeGenericButton.GameObject, (int?)140, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = makeGenericButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnMakeGenericClicked)); makeGenericButton.GameObject.SetActive(false); ButtonRef obj2 = UIFactory.CreateButton(val, "CopyButton", "Copy to Clipboard", (Color?)new Color(0.2f, 0.2f, 0.2f, 1f)); ((Graphic)obj2.ButtonText).color = Color.yellow; GameObject gameObject3 = ((Component)obj2.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)120, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, new Action(OnCopyClicked)); GameObject val3 = UIFactory.CreateHorizontalGroup(base.UIRoot, "AssemblyRow", false, false, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null); num2 = 9999; num3 = 25; UIFactory.SetLayoutElement(val3, (int?)null, num3, num2, (int?)null, (int?)null, (int?)null, (bool?)null); assemblyText = UIFactory.CreateLabel(val3, "AssemblyLabel", "not set", (TextAnchor)3, default(Color), true, 14); GameObject gameObject4 = ((Component)assemblyText).gameObject; num3 = 25; num2 = 9999; UIFactory.SetLayoutElement(gameObject4, (int?)null, num3, num2, (int?)null, (int?)null, (int?)null, (bool?)null); dnSpyButton = UIFactory.CreateButton(val3, "DnSpyButton", "View in dnSpy", (Color?)null); UIFactory.SetLayoutElement(dnSpyButton.GameObject, (int?)120, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj3 = dnSpyButton; obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(OnDnSpyButtonClicked)); ContentRoot = UIFactory.CreateVerticalGroup(base.UIRoot, "ContentRoot", false, false, true, true, 5, new Vector4(2f, 2f, 2f, 2f), new Color(0.12f, 0.12f, 0.12f), (TextAnchor?)null); GameObject contentRoot = ContentRoot; num2 = 9999; num3 = 9999; UIFactory.SetLayoutElement(contentRoot, (int?)null, (int?)null, num2, num3, (int?)null, (int?)null, (bool?)null); ConstructFirstRow(ContentRoot); ConstructSecondRow(ContentRoot); GameObject val4 = UIFactory.CreateVerticalGroup(ContentRoot, "ScrollPoolHolder", false, false, true, true, 0, new Vector4(2f, 2f, 2f, 2f), new Color(0.05f, 0.05f, 0.05f), (TextAnchor?)null); num3 = 9999; num2 = 9999; UIFactory.SetLayoutElement(val4, (int?)null, (int?)null, num3, num2, (int?)null, (int?)null, (bool?)null); GameObject val5 = default(GameObject); GameObject val6 = default(GameObject); MemberScrollPool = UIFactory.CreateScrollPool(val4, "MemberList", ref val5, ref val6, (Color?)new Color(0.09f, 0.09f, 0.09f)); GameObject obj4 = val5; num2 = 9999; UIFactory.SetLayoutElement(obj4, (int?)null, (int?)null, (int?)null, num2, (int?)null, (int?)null, (bool?)null); MemberScrollPool.Initialize((ICellPoolDataSource)this, (Action)null); return base.UIRoot; } private void ConstructFirstRow(GameObject parent) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateUIObject("FirstRow", parent, default(Vector2)); UIFactory.SetLayoutGroup(val, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)5, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null); int? num = 25; int? num2 = 0; int? num3 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(val, "NameFilterLabel", "Filter names:", (TextAnchor)3, Color.grey, true, 14)).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject, (int?)90, num3, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); filterInputField = UIFactory.CreateInputField(val, "NameFilterInput", "..."); GameObject uIRoot = ((UIModel)filterInputField).UIRoot; num3 = 25; num2 = 300; UIFactory.SetLayoutElement(uIRoot, (int?)null, num3, num2, (int?)null, (int?)null, (int?)null, (bool?)null); filterInputField.OnValueChanged += delegate(string name) { OnSetNameFilter(name); }; UIFactory.SetLayoutElement(UIFactory.CreateUIObject("Spacer", val, default(Vector2)), (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = UIFactory.CreateButton(val, "UpdateButton", "Update displayed values", (Color?)new Color(0.22f, 0.28f, 0.22f)); GameObject gameObject2 = ((Component)obj.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)175, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnUpdateClicked)); Text val2 = default(Text); UIFactory.SetLayoutElement(UIFactory.CreateToggle(val, "AutoUpdateToggle", ref autoUpdateToggle, ref val2, default(Color), 20, 20), (int?)125, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); autoUpdateToggle.isOn = false; val2.text = "Auto-update"; } private void ConstructSecondRow(GameObject parent) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateUIObject("SecondRow", parent, default(Vector2)); UIFactory.SetLayoutGroup(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null); int? num = 25; int? num2 = 0; int? num3 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(val, "ScopeLabel", "Scope:", (TextAnchor)3, Color.grey, true, 14)).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject, (int?)60, num3, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); AddScopeFilterButton(val, BindingFlags.Default, setAsActive: true); AddScopeFilterButton(val, BindingFlags.Instance); AddScopeFilterButton(val, BindingFlags.Static); UIFactory.SetLayoutElement(UIFactory.CreateUIObject("Spacer", val, default(Vector2)), (int?)15, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); AddMemberTypeToggle(val, MemberTypes.Property, 90); AddMemberTypeToggle(val, MemberTypes.Field, 70); AddMemberTypeToggle(val, MemberTypes.Method, 90); AddMemberTypeToggle(val, MemberTypes.Constructor, 110); } private void AddScopeFilterButton(GameObject parent, BindingFlags flags, bool setAsActive = false) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) string text = ((flags == BindingFlags.Default) ? "All" : flags.ToString()); Color value = (setAsActive ? enabledButtonColor : disabledButtonColor); ButtonRef val = UIFactory.CreateButton(parent, "Filter_" + flags, text, (Color?)value); GameObject gameObject = ((Component)val.Component).gameObject; int? num = 25; int? num2 = 0; UIFactory.SetLayoutElement(gameObject, (int?)70, num, (int?)0, num2, (int?)null, (int?)null, (bool?)null); scopeFilterButtons.Add(flags, val); val.OnClick = (Action)System.Delegate.Combine(val.OnClick, (Action)delegate { OnSetFlags(flags); }); } private void AddMemberTypeToggle(GameObject parent, MemberTypes type, int width) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) Toggle val = default(Toggle); Text val2 = default(Text); GameObject obj = UIFactory.CreateToggle(parent, "Toggle_" + type, ref val, ref val2, default(Color), 20, 20); int? num = 25; UIFactory.SetLayoutElement(obj, (int?)width, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); string text = type switch { MemberTypes.Method => "#ff8000", MemberTypes.Field => "#c266ff", MemberTypes.Property => "#55a38e", MemberTypes.Constructor => "#2df7b2", _ => throw new NotImplementedException(), }; val2.text = $"{type}"; ((Graphic)ReflectionExtensions.TryCast((object)val.graphic)).color = UnityHelpers.ToColor(text) * 0.65f; MemberFilter flag = type switch { MemberTypes.Method => MemberFilter.Method, MemberTypes.Property => MemberFilter.Property, MemberTypes.Field => MemberFilter.Field, MemberTypes.Constructor => MemberFilter.Constructor, _ => throw new NotImplementedException(), }; ((UnityEvent)(object)val.onValueChanged).AddListener((UnityAction)delegate(bool val3) { OnMemberTypeToggled(flag, val3); }); memberTypeToggles.Add(val); } } } namespace UnityExplorer.Inspectors.MouseInspectors { public abstract class MouseInspectorBase { public abstract void OnBeginMouseInspect(); public abstract void UpdateMouseInspect(Vector2 mousePos); public abstract void OnSelectMouseInspect(); public abstract void ClearHitData(); public abstract void OnEndInspect(); } public class UiInspector : MouseInspectorBase { public static readonly List LastHitObjects = new List(); private static GraphicRaycaster[] graphicRaycasters; private static readonly List currentHitObjects = new List(); private static readonly List wasDisabledGraphics = new List(); private static readonly List wasDisabledCanvasGroups = new List(); private static readonly List objectsAddedCastersTo = new List(); private const string DEFAULT_INSPECTOR_TITLE = "UI Inspector (press ESC to cancel)"; public override void OnBeginMouseInspect() { SetupUIRaycast(); MouseInspector.Instance.UpdateInspectorTitle("UI Inspector (press ESC to cancel)"); MouseInspector.Instance.UpdateObjectPathLabel(""); } public override void ClearHitData() { currentHitObjects.Clear(); } public override void OnSelectMouseInspect() { LastHitObjects.Clear(); LastHitObjects.AddRange(currentHitObjects); RuntimeHelper.StartCoroutine(SetPanelActiveCoro()); } private IEnumerator SetPanelActiveCoro() { yield return null; MouseInspectorResultsPanel panel = UIManager.GetPanel(UIManager.Panels.UIInspectorResults); ((UIModel)panel).SetActive(true); panel.ShowResults(); } public override void UpdateMouseInspect(Vector2 mousePos) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) currentHitObjects.Clear(); PointerEventData val = new PointerEventData((EventSystem)null) { position = mousePos }; GraphicRaycaster[] array = graphicRaycasters; foreach (GraphicRaycaster val2 in array) { if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)((Component)val2).GetComponent())) { continue; } List list = new List(); RuntimeHelper.GraphicRaycast(val2, val, list); if (list.Count <= 0) { continue; } foreach (RaycastResult item in list) { RaycastResult current = item; if (Object.op_Implicit((Object)(object)((RaycastResult)(ref current)).gameObject)) { currentHitObjects.Add(((RaycastResult)(ref current)).gameObject); } } } if (currentHitObjects.Any()) { MouseInspector.Instance.UpdateObjectNameLabel($"Click to view UI Objects under mouse: {currentHitObjects.Count}"); } else { MouseInspector.Instance.UpdateObjectNameLabel("No UI objects under mouse."); } } private static void SetupUIRaycast() { Object[] array = RuntimeHelper.FindObjectsOfTypeAll(typeof(Canvas)); for (int i = 0; i < array.Length; i++) { Canvas val = ReflectionExtensions.TryCast((object)array[i]); if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).enabled && ((Component)val).gameObject.activeInHierarchy && !Object.op_Implicit((Object)(object)((Component)val).GetComponent())) { ((Component)val).gameObject.AddComponent(); objectsAddedCastersTo.Add(((Component)val).gameObject); } } Object[] array2 = RuntimeHelper.FindObjectsOfTypeAll(typeof(GraphicRaycaster)); graphicRaycasters = (GraphicRaycaster[])(object)new GraphicRaycaster[array2.Length]; for (int j = 0; j < array2.Length; j++) { graphicRaycasters[j] = ReflectionExtensions.TryCast((object)array2[j]); } array = RuntimeHelper.FindObjectsOfTypeAll(typeof(Graphic)); for (int i = 0; i < array.Length; i++) { Graphic val2 = ReflectionExtensions.TryCast((object)array[i]); if (Object.op_Implicit((Object)(object)val2) && ((Behaviour)val2).enabled && !val2.raycastTarget && ((Component)val2).gameObject.activeInHierarchy) { val2.raycastTarget = true; wasDisabledGraphics.Add(val2); } } array = RuntimeHelper.FindObjectsOfTypeAll(typeof(CanvasGroup)); for (int i = 0; i < array.Length; i++) { CanvasGroup val3 = ReflectionExtensions.TryCast((object)array[i]); if (Object.op_Implicit((Object)(object)val3) && ((Component)val3).gameObject.activeInHierarchy && !val3.blocksRaycasts) { val3.blocksRaycasts = true; wasDisabledCanvasGroups.Add(val3); } } } public override void OnEndInspect() { foreach (GameObject item in objectsAddedCastersTo) { GraphicRaycaster component = item.GetComponent(); if (component != null) { Object.Destroy((Object)(object)component); } } foreach (Graphic wasDisabledGraphic in wasDisabledGraphics) { wasDisabledGraphic.raycastTarget = false; } foreach (CanvasGroup wasDisabledCanvasGroup in wasDisabledCanvasGroups) { wasDisabledCanvasGroup.blocksRaycasts = false; } objectsAddedCastersTo.Clear(); wasDisabledCanvasGroups.Clear(); wasDisabledGraphics.Clear(); } } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(2)] [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] public class WorldInspector : MouseInspectorBase { private static Camera MainCamera; private static GameObject lastHitObject; public override void OnBeginMouseInspect() { if (!Object.op_Implicit((Object)(object)EnsureMainCamera())) { ExplorerCore.LogWarning("No valid cameras found! Cannot inspect world!"); } } public override void ClearHitData() { lastHitObject = null; } public override void OnSelectMouseInspect() { InspectorManager.Inspect(lastHitObject); } public override void UpdateMouseInspect(Vector2 mousePos) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Camera val = EnsureMainCamera(); if ((Object)(object)val == (Object)null) { ExplorerCore.LogWarning("No Main Camera was found, unable to inspect world!"); MouseInspector.Instance.StopInspect(); return; } RaycastHit val2 = default(RaycastHit); Physics.Raycast(val.ScreenPointToRay(Vector2.op_Implicit(mousePos)), ref val2, 1000f); if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).transform)) { OnHitGameObject(((Component)((RaycastHit)(ref val2)).transform).gameObject); } else if (Object.op_Implicit((Object)(object)lastHitObject)) { MouseInspector.Instance.ClearHitData(); } } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] internal void OnHitGameObject(GameObject obj) { if ((Object)(object)obj != (Object)(object)lastHitObject) { lastHitObject = obj; MouseInspector.Instance.UpdateObjectNameLabel("Click to Inspect: " + ((Object)obj).name + ""); MouseInspector.Instance.UpdateObjectPathLabel("Path: " + UnityHelpers.GetTransformPath(obj.transform, true)); } } public override void OnEndInspect() { } private static Camera EnsureMainCamera() { if ((Object)(object)MainCamera != (Object)null) { return MainCamera; } if (TryGetValidMainCamera(out var camera)) { MainCamera = camera; MouseInspector.Instance.UpdateInspectorTitle("World Inspector (" + ((Object)camera).name + ") (press ESC to cancel)"); ExplorerCore.Log("Using '" + UnityHelpers.GetTransformPath(((Component)camera).transform, true) + "'"); return camera; } return null; } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] private static bool TryGetValidMainCamera(out Camera camera) { camera = Camera.main; if ((Object)(object)camera != (Object)null) { return true; } ExplorerCore.LogWarning("No Camera.main found, trying to find a camera named 'Main Camera' or 'MainCamera'..."); camera = ((IEnumerable)Camera.allCameras).FirstOrDefault((Func)([<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(0)] (Camera c) => ((Object)c).name == "Main Camera" || ((Object)c).name == "MainCamera")); if ((Object)(object)camera != (Object)null) { return true; } ExplorerCore.LogWarning("No camera named 'Main Camera' or 'MainCamera' found, using the first camera created..."); camera = Camera.allCameras.FirstOrDefault(); if ((Object)(object)camera != (Object)null) { return true; } ExplorerCore.LogWarning("No valid main cameras found!"); return false; } } } namespace UnityExplorer.Hooks { public class AddHookCell : ICell, IPooledObject { public Text MethodNameLabel; public ButtonRef HookButton; public int CurrentDisplayedIndex; public bool Enabled => UIRoot.activeSelf; public RectTransform Rect { get; set; } public GameObject UIRoot { get; set; } public float DefaultHeight => 30f; private void OnHookClicked() { HookCreator.AddHookClicked(CurrentDisplayedIndex); } public void Enable() { UIRoot.SetActive(true); } public void Disable() { UIRoot.SetActive(false); } public GameObject CreateContent(GameObject parent) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject(GetType().Name, parent, new Vector2(100f, 30f)); Rect = UIRoot.GetComponent(); GameObject uIRoot = UIRoot; bool? flag = false; bool? flag2 = false; bool? flag3 = true; bool? flag4 = true; int? num = 5; TextAnchor? val = (TextAnchor)0; UIFactory.SetLayoutGroup(uIRoot, flag, flag2, flag3, flag4, num, (int?)null, (int?)null, (int?)null, (int?)null, val); GameObject uIRoot2 = UIRoot; int? num2 = 100; int? num3 = 9999; UIFactory.SetLayoutElement(uIRoot2, num2, (int?)30, num3, (int?)600, (int?)null, (int?)null, (bool?)null); UIRoot.AddComponent().verticalFit = (FitMode)2; HookButton = UIFactory.CreateButton(UIRoot, "HookButton", "Hook", (Color?)new Color(0.2f, 0.25f, 0.2f)); GameObject gameObject = ((Component)HookButton.Component).gameObject; num3 = 25; UIFactory.SetLayoutElement(gameObject, (int?)100, num3, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef hookButton = HookButton; hookButton.OnClick = (Action)System.Delegate.Combine(hookButton.OnClick, new Action(OnHookClicked)); MethodNameLabel = UIFactory.CreateLabel(UIRoot, "MethodName", "NOT SET", (TextAnchor)3, default(Color), true, 14); GameObject gameObject2 = ((Component)MethodNameLabel).gameObject; num3 = 25; int? num4 = 9999; UIFactory.SetLayoutElement(gameObject2, (int?)null, num3, num4, (int?)null, (int?)null, (int?)null, (bool?)null); return UIRoot; } } public class HookCell : ICell, IPooledObject { public Text MethodNameLabel; public ButtonRef EditPatchButton; public ButtonRef ToggleActiveButton; public ButtonRef DeleteButton; public int CurrentDisplayedIndex; public bool Enabled => UIRoot.activeSelf; public RectTransform Rect { get; set; } public GameObject UIRoot { get; set; } public float DefaultHeight => 30f; private void OnToggleActiveClicked() { HookList.EnableOrDisableHookClicked(CurrentDisplayedIndex); } private void OnDeleteClicked() { HookList.DeleteHookClicked(CurrentDisplayedIndex); HookCreator.AddHooksScrollPool.Refresh(true, false); } private void OnEditPatchClicked() { HookList.EditPatchClicked(CurrentDisplayedIndex); } public GameObject CreateContent(GameObject parent) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject(GetType().Name, parent, new Vector2(100f, 30f)); Rect = UIRoot.GetComponent(); GameObject uIRoot = UIRoot; bool? flag = false; bool? flag2 = false; bool? flag3 = true; bool? flag4 = true; int? num = 4; TextAnchor? val = (TextAnchor)0; UIFactory.SetLayoutGroup(uIRoot, flag, flag2, flag3, flag4, num, (int?)null, (int?)null, (int?)null, (int?)null, val); GameObject uIRoot2 = UIRoot; int? num2 = 100; int? num3 = 9999; UIFactory.SetLayoutElement(uIRoot2, num2, (int?)30, num3, (int?)600, (int?)null, (int?)null, (bool?)null); UIRoot.AddComponent().verticalFit = (FitMode)2; MethodNameLabel = UIFactory.CreateLabel(UIRoot, "MethodName", "NOT SET", (TextAnchor)3, default(Color), true, 14); GameObject gameObject = ((Component)MethodNameLabel).gameObject; num3 = 25; int? num4 = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, num3, num4, (int?)null, (int?)null, (int?)null, (bool?)null); ToggleActiveButton = UIFactory.CreateButton(UIRoot, "ToggleActiveBtn", "On", (Color?)new Color(0.15f, 0.2f, 0.15f)); GameObject gameObject2 = ((Component)ToggleActiveButton.Component).gameObject; num4 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)35, num4, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef toggleActiveButton = ToggleActiveButton; toggleActiveButton.OnClick = (Action)System.Delegate.Combine(toggleActiveButton.OnClick, new Action(OnToggleActiveClicked)); EditPatchButton = UIFactory.CreateButton(UIRoot, "EditButton", "Edit", (Color?)new Color(0.15f, 0.15f, 0.15f)); GameObject gameObject3 = ((Component)EditPatchButton.Component).gameObject; num4 = 25; UIFactory.SetLayoutElement(gameObject3, (int?)35, num4, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef editPatchButton = EditPatchButton; editPatchButton.OnClick = (Action)System.Delegate.Combine(editPatchButton.OnClick, new Action(OnEditPatchClicked)); DeleteButton = UIFactory.CreateButton(UIRoot, "DeleteButton", "X", (Color?)new Color(0.2f, 0.15f, 0.15f)); GameObject gameObject4 = ((Component)DeleteButton.Component).gameObject; num4 = 25; UIFactory.SetLayoutElement(gameObject4, (int?)35, num4, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef deleteButton = DeleteButton; deleteButton.OnClick = (Action)System.Delegate.Combine(deleteButton.OnClick, new Action(OnDeleteClicked)); return UIRoot; } public void Disable() { UIRoot.SetActive(false); } public void Enable() { UIRoot.SetActive(true); } } public class HookCreator : ICellPoolDataSource { private static readonly List currentAddEligibleMethods = new List(); private static readonly List filteredEligibleMethods = new List(); private static readonly List currentEligibleNamesForFiltering = new List(); private static readonly LexerBuilder Lexer = new LexerBuilder(); internal static HookInstance CurrentEditedHook; internal static GameObject AddHooksRoot; internal static ScrollPool AddHooksScrollPool; internal static Text AddHooksLabel; internal static InputFieldRef AddHooksMethodFilterInput; internal static InputFieldRef ClassSelectorInputField; internal static Type pendingGenericDefinition; internal static MethodInfo pendingGenericMethod; public int ItemCount => filteredEligibleMethods.Count; public static bool PendingGeneric { get { if (!(pendingGenericDefinition != null)) { return pendingGenericMethod != null; } return true; } } public static GameObject EditorRoot { get; private set; } public static Text EditingHookLabel { get; private set; } public static InputFieldScroller EditorInputScroller { get; private set; } public static InputFieldRef EditorInput => EditorInputScroller.InputField; public static Text EditorInputText { get; private set; } public static Text EditorHighlightText { get; private set; } public void OnClassSelectedForHooks(string typeFullName) { Type typeByName = ReflectionUtility.GetTypeByName(typeFullName); if (typeByName == null) { ExplorerCore.LogWarning("Could not find any type by name " + typeFullName + "!"); } else if (typeByName.IsGenericType) { pendingGenericDefinition = typeByName; HookManagerPanel.genericArgsHandler.Show(OnGenericClassChosen, OnGenericClassCancel, typeByName); HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.GenericArgsSelector); } else { ShowMethodsForType(typeByName); } } private void ShowMethodsForType(Type type) { SetAddHooksLabelType(SignatureHighlighter.Parse(type, true, (MemberInfo)null)); AddHooksMethodFilterInput.Text = string.Empty; filteredEligibleMethods.Clear(); currentAddEligibleMethods.Clear(); currentEligibleNamesForFiltering.Clear(); MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (!UERuntimeHelper.IsBlacklisted(methodInfo)) { currentAddEligibleMethods.Add(methodInfo); currentEligibleNamesForFiltering.Add(SignatureHighlighter.RemoveHighlighting(SignatureHighlighter.ParseMethod(methodInfo))); filteredEligibleMethods.Add(methodInfo); } } AddHooksScrollPool.Refresh(true, true); } private void OnGenericClassChosen(Type[] genericArgs) { Type type = pendingGenericDefinition.MakeGenericType(genericArgs); ShowMethodsForType(type); HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector); } private void OnGenericClassCancel() { pendingGenericDefinition = null; HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector); } public void SetAddHooksLabelType(string typeText) { AddHooksLabel.text = "Adding hooks to: " + typeText; AddHooksMethodFilterInput.GameObject.SetActive(true); ((UIModel)AddHooksScrollPool).UIRoot.SetActive(true); } public static void AddHookClicked(int index) { if (index < filteredEligibleMethods.Count) { MethodInfo methodInfo = filteredEligibleMethods[index]; if (!methodInfo.IsGenericMethod && HookList.hookedSignatures.Contains(GeneralExtensions.FullDescription((MethodBase)methodInfo))) { ExplorerCore.Log("Non-generic methods can only be hooked once."); } else if (methodInfo.IsGenericMethod) { pendingGenericMethod = methodInfo; HookManagerPanel.genericArgsHandler.Show(OnGenericMethodChosen, OnGenericMethodCancel, methodInfo); HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.GenericArgsSelector); } else { AddHook(filteredEligibleMethods[index]); } } } private static void OnGenericMethodChosen(Type[] arguments) { AddHook(pendingGenericMethod.MakeGenericMethod(arguments)); } private static void OnGenericMethodCancel() { pendingGenericMethod = null; HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector); } public static void AddHook(MethodInfo method) { HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector); string text = GeneralExtensions.FullDescription((MethodBase)method); if (HookList.hookedSignatures.Contains(text)) { ExplorerCore.LogWarning("Method is already hooked!"); return; } HookInstance value = new HookInstance(method); HookList.hookedSignatures.Add(text); HookList.currentHooks.Add(text, value); AddHooksScrollPool.Refresh(true, false); HookList.HooksScrollPool.Refresh(true, false); } public void OnAddHookFilterInputChanged(string input) { filteredEligibleMethods.Clear(); if (string.IsNullOrEmpty(input)) { filteredEligibleMethods.AddRange(currentAddEligibleMethods); } else { for (int i = 0; i < currentAddEligibleMethods.Count; i++) { MethodInfo item = currentAddEligibleMethods[i]; if (MiscUtility.ContainsIgnoreCase(currentEligibleNamesForFiltering[i], input)) { filteredEligibleMethods.Add(item); } } } AddHooksScrollPool.Refresh(true, true); } public void OnCellBorrowed(AddHookCell cell) { } public void SetCell(AddHookCell cell, int index) { if (index >= filteredEligibleMethods.Count) { cell.Disable(); return; } cell.CurrentDisplayedIndex = index; MethodInfo methodInfo = filteredEligibleMethods[index]; cell.MethodNameLabel.text = SignatureHighlighter.ParseMethod(methodInfo); } internal static void SetEditedHook(HookInstance hook) { CurrentEditedHook = hook; EditingHookLabel.text = "Editing: " + SignatureHighlighter.Parse(hook.TargetMethod.DeclaringType, false, (MemberInfo)hook.TargetMethod); EditorInput.Text = hook.PatchSourceCode; } internal static void OnEditorInputChanged(string value) { EditorHighlightText.text = Lexer.BuildHighlightedString(value, 0, value.Length - 1, 0, EditorInput.Component.caretPosition, out var _); } internal static void EditorInputCancel() { CurrentEditedHook = null; HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector); } internal static void EditorInputSave() { string text = EditorInput.Text; bool enabled = CurrentEditedHook.Enabled; if (CurrentEditedHook.CompileAndGenerateProcessor(text)) { if (enabled) { CurrentEditedHook.Patch(); } CurrentEditedHook.PatchSourceCode = text; CurrentEditedHook = null; HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector); } HookList.HooksScrollPool.Refresh(true, false); } internal void ConstructAddHooksView(GameObject rightGroup) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) AddHooksRoot = UIFactory.CreateUIObject("AddHooksPanel", rightGroup, default(Vector2)); GameObject addHooksRoot = AddHooksRoot; int? num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(addHooksRoot, (int?)null, (int?)null, num2, num, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(AddHooksRoot, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject obj = UIFactory.CreateHorizontalGroup(AddHooksRoot, "AddRow", false, true, true, true, 4, new Vector4(2f, 2f, 2f, 2f), new Color(0.2f, 0.2f, 0.2f), (TextAnchor?)null); num2 = 25; num = 0; int? num3 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num2, num3, num, (int?)null, (int?)null, (bool?)null); ClassSelectorInputField = UIFactory.CreateInputField(obj, "ClassInput", "Enter a class to add hooks to..."); GameObject gameObject = ((Component)ClassSelectorInputField.Component).gameObject; num3 = 9999; num = 25; num2 = 0; UIFactory.SetLayoutElement(gameObject, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null); new TypeCompleter(typeof(object), ClassSelectorInputField, allowAbstract: true, allowEnum: false, allowGeneric: true); ButtonRef obj2 = UIFactory.CreateButton(obj, "AddButton", "View Methods", (Color?)null); UIFactory.SetLayoutElement(((Component)obj2.Component).gameObject, (int?)110, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, (Action)delegate { OnClassSelectedForHooks(ClassSelectorInputField.Text); }); AddHooksLabel = UIFactory.CreateLabel(AddHooksRoot, "AddLabel", "Choose a class to begin...", (TextAnchor)4, default(Color), true, 14); GameObject gameObject2 = ((Component)AddHooksLabel).gameObject; num2 = 30; UIFactory.SetLayoutElement(gameObject2, (int?)100, num2, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null); AddHooksMethodFilterInput = UIFactory.CreateInputField(AddHooksRoot, "FilterInputField", "Filter method names..."); GameObject gameObject3 = ((Component)AddHooksMethodFilterInput.Component).gameObject; num2 = 30; num = 9999; UIFactory.SetLayoutElement(gameObject3, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); AddHooksMethodFilterInput.OnValueChanged += OnAddHookFilterInputChanged; GameObject val = default(GameObject); GameObject val2 = default(GameObject); AddHooksScrollPool = UIFactory.CreateScrollPool(AddHooksRoot, "MethodAddScrollPool", ref val, ref val2, (Color?)null); GameObject obj3 = val; num = 9999; UIFactory.SetLayoutElement(obj3, (int?)null, (int?)null, (int?)null, num, (int?)null, (int?)null, (bool?)null); AddHooksScrollPool.Initialize((ICellPoolDataSource)this, (Action)null); AddHooksMethodFilterInput.GameObject.SetActive(false); ((UIModel)AddHooksScrollPool).UIRoot.SetActive(false); } public void ConstructEditor(GameObject parent) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) EditorRoot = UIFactory.CreateUIObject("HookSourceEditor", parent, default(Vector2)); GameObject editorRoot = EditorRoot; int? num = 9999; int? num2 = 9999; UIFactory.SetLayoutElement(editorRoot, (int?)null, (int?)null, num2, num, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(EditorRoot, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)2, (int?)3, (int?)3, (int?)3, (int?)3, (TextAnchor?)null); EditingHookLabel = UIFactory.CreateLabel(EditorRoot, "EditingHookLabel", "NOT SET", (TextAnchor)4, default(Color), true, 14); EditingHookLabel.fontStyle = (FontStyle)1; GameObject gameObject = ((Component)EditingHookLabel).gameObject; num2 = 9999; num = 25; UIFactory.SetLayoutElement(gameObject, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject gameObject2 = ((Component)UIFactory.CreateLabel(EditorRoot, "EditorLabel", "* Accepted method names are Prefix, Postfix, Finalizer and Transpiler (can define multiple).\n* Your patch methods must be static.\n* Hooks are temporary! Copy the source into your IDE to avoid losing work if you wish to keep it!", (TextAnchor)3, default(Color), true, 14)).gameObject; num = 25; num2 = 9999; UIFactory.SetLayoutElement(gameObject2, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject obj = UIFactory.CreateHorizontalGroup(EditorRoot, "ButtonRow", false, false, true, true, 5, default(Vector4), default(Color), (TextAnchor?)null); num2 = 25; num = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj2 = UIFactory.CreateButton(obj, "DoneButton", "Save and Return", (Color?)new Color(0.2f, 0.3f, 0.2f)); GameObject gameObject3 = ((Component)obj2.Component).gameObject; num = 25; num2 = 9999; UIFactory.SetLayoutElement(gameObject3, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, new Action(EditorInputSave)); ButtonRef obj3 = UIFactory.CreateButton(obj, "DoneButton", "Cancel and Return", (Color?)new Color(0.2f, 0.2f, 0.2f)); GameObject gameObject4 = ((Component)obj3.Component).gameObject; num2 = 25; num = 9999; UIFactory.SetLayoutElement(gameObject4, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); obj3.OnClick = (Action)System.Delegate.Combine(obj3.OnClick, new Action(EditorInputCancel)); int num3 = 16; InputFieldScroller editorInputScroller = default(InputFieldScroller); UIFactory.CreateScrollInputField(EditorRoot, "EditorInput", "", ref editorInputScroller, num3, default(Color)); EditorInputScroller = editorInputScroller; EditorInput.OnValueChanged += OnEditorInputChanged; EditorInputText = EditorInput.Component.textComponent; EditorInputText.supportRichText = false; ((Graphic)EditorInputText).color = Color.clear; EditorInput.Component.customCaretColor = true; EditorInput.Component.caretColor = Color.white; EditorInput.PlaceholderText.fontSize = num3; GameObject obj4 = UIFactory.CreateUIObject("HighlightText", ((Component)EditorInputText).gameObject, default(Vector2)); RectTransform component = obj4.GetComponent(); component.pivot = new Vector2(0f, 1f); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; EditorHighlightText = obj4.AddComponent(); ((Graphic)EditorHighlightText).color = Color.white; EditorHighlightText.supportRichText = true; EditorHighlightText.fontSize = num3; EditorInputText.font = UniversalUI.ConsoleFont; EditorInput.PlaceholderText.font = UniversalUI.ConsoleFont; EditorHighlightText.font = UniversalUI.ConsoleFont; } } public class HookInstance { private static readonly StringBuilder evaluatorOutput; private static readonly ScriptEvaluator scriptEvaluator; public bool Enabled; public MethodInfo TargetMethod; public string PatchSourceCode; private readonly string signature; private PatchProcessor patchProcessor; private MethodInfo postfix; private MethodInfo prefix; private MethodInfo finalizer; private MethodInfo transpiler; private static readonly FieldInfo fi_sourceFile; private static readonly PropertyInfo pi_Definition; static HookInstance() { scriptEvaluator = new ScriptEvaluator(new StringWriter(evaluatorOutput = new StringBuilder())); fi_sourceFile = AccessTools.Field(typeof(Evaluator), "source_file"); pi_Definition = AccessTools.Property(typeof(TypeDefinition), "Definition"); scriptEvaluator.Run("using System;"); scriptEvaluator.Run("using System.Text;"); scriptEvaluator.Run("using System.Reflection;"); scriptEvaluator.Run("using System.Collections;"); scriptEvaluator.Run("using System.Collections.Generic;"); } public HookInstance(MethodInfo targetMethod) { TargetMethod = targetMethod; signature = GeneralExtensions.FullDescription((MethodBase)TargetMethod); GenerateDefaultPatchSourceCode(targetMethod); if (CompileAndGenerateProcessor(PatchSourceCode)) { Patch(); } } public bool CompileAndGenerateProcessor(string patchSource) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown Unpatch(); StringBuilder stringBuilder = new StringBuilder(); try { patchProcessor = ExplorerCore.Harmony.CreateProcessor((MethodBase)TargetMethod); stringBuilder.AppendLine($"static class DynamicPatch_{DateTime.Now.Ticks}"); stringBuilder.AppendLine("{"); stringBuilder.AppendLine(patchSource); stringBuilder.AppendLine("}"); scriptEvaluator.Run(stringBuilder.ToString()); if (ScriptEvaluator._reportPrinter.ErrorsCount > 0) { throw new FormatException("Unable to compile the generated patch!"); } TypeContainer typeContainer = ((CompilationSourceFile)fi_sourceFile.GetValue(scriptEvaluator)).Containers.Last((TypeContainer it) => it.MemberName.Name.StartsWith("DynamicPatch_")); Type metaInfo = ((TypeSpec)pi_Definition.GetValue((Class)typeContainer, null)).GetMetaInfo(); postfix = metaInfo.GetMethod("Postfix", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (postfix != null) { patchProcessor.AddPostfix(new HarmonyMethod(postfix)); } prefix = metaInfo.GetMethod("Prefix", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (prefix != null) { patchProcessor.AddPrefix(new HarmonyMethod(prefix)); } finalizer = metaInfo.GetMethod("Finalizer", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (finalizer != null) { patchProcessor.AddFinalizer(new HarmonyMethod(finalizer)); } transpiler = metaInfo.GetMethod("Transpiler", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (transpiler != null) { patchProcessor.AddTranspiler(new HarmonyMethod(transpiler)); } return true; } catch (Exception ex) { if (ex is FormatException) { string text = scriptEvaluator.ToString(); string[] array = text.Split(new char[1] { '\n' }); if (array.Length >= 2) { text = array[^2]; } evaluatorOutput.Clear(); if (ScriptEvaluator._reportPrinter.ErrorsCount > 0) { ExplorerCore.LogWarning("Unable to compile the code. Evaluator's last output was:\r\n" + text); } else { ExplorerCore.LogWarning($"Exception generating patch source code: {ex}"); } } else { ExplorerCore.LogWarning($"Exception generating patch source code: {ex}"); } return false; } } private static string FullDescriptionClean(Type type) { string text = GeneralExtensions.FullDescription(type).Replace("+", "."); if (text.EndsWith("&")) { text = "ref " + text.Substring(0, text.Length - 1); } return text; } private string GenerateDefaultPatchSourceCode(MethodInfo targetMethod) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("static void Postfix("); bool isStatic = targetMethod.IsStatic; List list = new List(); if (!isStatic) { list.Add(FullDescriptionClean(targetMethod.DeclaringType) + " __instance"); } if (targetMethod.ReturnType != typeof(void)) { list.Add(FullDescriptionClean(targetMethod.ReturnType) + " __result"); } ParameterInfo[] parameters = targetMethod.GetParameters(); int num = 0; ParameterInfo[] array = parameters; foreach (ParameterInfo parameterInfo in array) { list.Add($"{FullDescriptionClean(parameterInfo.ParameterType)} __{num}"); num++; } stringBuilder.Append(string.Join(", ", list.ToArray())); stringBuilder.Append(")\n"); stringBuilder.AppendLine("{"); stringBuilder.AppendLine(" try {"); stringBuilder.AppendLine(" StringBuilder sb = new StringBuilder();"); stringBuilder.AppendLine(" sb.AppendLine(\"--------------------\");"); stringBuilder.AppendLine(" sb.AppendLine(\"" + signature + "\");"); if (!targetMethod.IsStatic) { stringBuilder.AppendLine(" sb.Append(\"- __instance: \").AppendLine(__instance.ToString());"); } num = 0; array = parameters; foreach (ParameterInfo parameterInfo2 in array) { stringBuilder.Append($" sb.Append(\"- Parameter {num} '{parameterInfo2.Name}': \")"); Type type = parameterInfo2.ParameterType; if (type.IsByRef) { type = type.GetElementType(); } if (type.IsValueType) { stringBuilder.AppendLine($".AppendLine(__{num}.ToString());"); } else { stringBuilder.AppendLine($".AppendLine(__{num}?.ToString() ?? \"null\");"); } num++; } if (targetMethod.ReturnType != typeof(void)) { stringBuilder.Append(" sb.Append(\"- Return value: \")"); if (targetMethod.ReturnType.IsValueType) { stringBuilder.AppendLine(".AppendLine(__result.ToString());"); } else { stringBuilder.AppendLine(".AppendLine(__result?.ToString() ?? \"null\");"); } } stringBuilder.AppendLine(" UnityExplorer.ExplorerCore.Log(sb.ToString());"); stringBuilder.AppendLine(" }"); stringBuilder.AppendLine(" catch (System.Exception ex) {"); stringBuilder.AppendLine(" UnityExplorer.ExplorerCore.LogWarning($\"Exception in patch of " + signature + ":\\n{ex}\");"); stringBuilder.AppendLine(" }"); stringBuilder.AppendLine("}"); return PatchSourceCode = stringBuilder.ToString(); } public void TogglePatch() { if (!Enabled) { Patch(); } else { Unpatch(); } } public void Patch() { try { patchProcessor.Patch(); Enabled = true; } catch (Exception arg) { ExplorerCore.LogWarning($"Exception hooking method!\r\n{arg}"); } } public void Unpatch() { try { if (prefix != null) { patchProcessor.Unpatch(prefix); } if (postfix != null) { patchProcessor.Unpatch(postfix); } if (finalizer != null) { patchProcessor.Unpatch(finalizer); } if (transpiler != null) { patchProcessor.Unpatch(transpiler); } Enabled = false; } catch (Exception arg) { ExplorerCore.LogWarning($"Exception unpatching method: {arg}"); } } } public class HookList : ICellPoolDataSource { internal static readonly HashSet hookedSignatures = new HashSet(); internal static readonly OrderedDictionary currentHooks = new OrderedDictionary(); internal static GameObject UIRoot; internal static ScrollPool HooksScrollPool; public int ItemCount => currentHooks.Count; public static void EnableOrDisableHookClicked(int index) { ((HookInstance)currentHooks[index]).TogglePatch(); HooksScrollPool.Refresh(true, false); } public static void DeleteHookClicked(int index) { HookInstance hookInstance = (HookInstance)currentHooks[index]; if (HookCreator.CurrentEditedHook == hookInstance) { HookCreator.EditorInputCancel(); } hookInstance.Unpatch(); currentHooks.RemoveAt(index); hookedSignatures.Remove(GeneralExtensions.FullDescription((MethodBase)hookInstance.TargetMethod)); HooksScrollPool.Refresh(true, false); } public static void EditPatchClicked(int index) { if (HookCreator.PendingGeneric) { HookManagerPanel.genericArgsHandler.Cancel(); } HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.HookSourceEditor); HookCreator.SetEditedHook((HookInstance)currentHooks[index]); } public void OnCellBorrowed(HookCell cell) { } public void SetCell(HookCell cell, int index) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (index >= currentHooks.Count) { cell.Disable(); return; } cell.CurrentDisplayedIndex = index; HookInstance hookInstance = (HookInstance)currentHooks[index]; cell.MethodNameLabel.text = SignatureHighlighter.ParseMethod(hookInstance.TargetMethod); cell.ToggleActiveButton.ButtonText.text = (hookInstance.Enabled ? "On" : "Off"); RuntimeHelper.SetColorBlockAuto((Selectable)(object)cell.ToggleActiveButton.Component, hookInstance.Enabled ? new Color(0.15f, 0.2f, 0.15f) : new Color(0.2f, 0.2f, 0.15f)); } internal void ConstructUI(GameObject leftGroup) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject("CurrentHooksPanel", leftGroup, default(Vector2)); GameObject uIRoot = UIRoot; int? num = 150; int? num2 = 0; int? num3 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, (int?)null, num3, num2, (int?)null, num, (bool?)null); UIFactory.SetLayoutGroup(UIRoot, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(UIRoot, "HooksLabel", "Current Hooks", (TextAnchor)4, default(Color), true, 14)).gameObject; num3 = 30; num2 = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, num3, num2, (int?)null, (int?)null, (int?)null, (bool?)null); GameObject val = default(GameObject); GameObject val2 = default(GameObject); HooksScrollPool = UIFactory.CreateScrollPool(UIRoot, "HooksScrollPool", ref val, ref val2, (Color?)null); GameObject obj = val; num2 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, (int?)null, (int?)null, num2, (int?)null, (int?)null, (bool?)null); HooksScrollPool.Initialize((ICellPoolDataSource)this, (Action)null); } } } namespace UnityExplorer.CSConsole { [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] public class ConsoleController { [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] private class CodeInfo(string label, string code) { public string Label { get; } = label; public string Code { get; set; } = code; } private readonly ConsoleScriptEvaluator _evaluator; private readonly LexerBuilder _lexer; private readonly CSAutoCompleter _completer; private readonly HashSet usingDirectives = new HashSet(); private float timeOfLastCtrlR; private bool settingCaretCoroutine; private string previousInput = ""; private int previousContentLength; private static readonly string[] DefaultUsing = new string[8] { "System", "System.Linq", "System.Text", "System.Collections", "System.Collections.Generic", "System.Reflection", "UnityEngine", "UniverseLib" }; private const int CSCONSOLE_LINEHEIGHT = 18; private readonly List codes = new List(5) { new CodeInfo("Welcome", "// Welcome to the UnityExplorer C# Console!\r\n\r\n// It is recommended to use the Log panel (or a console log window) while using this tool.\r\n// Use the Help dropdown to see detailed examples of how to use the console.\r\n\r\n// To execute a script automatically on startup, put the script at 'sinai-dev-UnityExplorer\\Scripts\\startup.cs'"), new CodeInfo("Usings", "// You can add a using directive to any namespace, but you must compile for it to take effect.\r\n// It will remain in effect until you Reset the console.\r\nusing UnityEngine.UI;\r\n\r\n// To see your current usings, use the \"GetUsing();\" helper.\r\n// Note: You cannot add usings and evaluate REPL at the same time."), new CodeInfo("REPL", "/* REPL (Read-Evaluate-Print-Loop) is a way to execute code immediately.\r\n * REPL code cannot contain any using directives or classes.\r\n * The return value of the last line of your REPL will be printed to the log.\r\n * Variables defined in REPL will exist until you Reset the console.\r\n*/\r\n\r\n// eg: This code would print 'Hello, World!', and then print 6 as the return value.\r\nLog(\"Hello, world!\");\r\nvar x = 5;\r\n++x;\r\n\r\n/* The following helpers are available in REPL mode:\r\n * CurrentTarget; - System.Object, the target of the active Inspector tab\r\n * AllTargets; - System.Object[], the targets of all Inspector tabs\r\n * Log(obj); - prints a message to the console log\r\n * Inspect(obj); - inspect the object with the Inspector\r\n * Inspect(someType); - inspect a Type with static reflection\r\n * Start(enumerator); - Coroutine, starts the IEnumerator as a Coroutine, and returns the Coroutine.\r\n * Stop(coroutine); - stop the Coroutine ONLY if it was started with Start(ienumerator).\r\n * Copy(obj); - copies the object to the UnityExplorer Clipboard\r\n * Paste(); - System.Object, the contents of the Clipboard.\r\n * GetUsing(); - prints the current using directives to the console log\r\n * GetVars(); - prints the names and values of the REPL variables you have defined\r\n * GetClasses(); - prints the names and members of the classes you have defined\r\n * help; - the default REPL help command, contains additional helpers.\r\n*/"), new CodeInfo("Classes", "// Classes you compile will exist until the application closes.\r\n// You can soft-overwrite a class by compiling it again with the same name. The old class will still technically exist in memory.\r\n\r\n// Compiled classes can be accessed from both inside and outside this console.\r\n// Note: in IL2CPP, you must declare a Namespace to inject these classes with ClassInjector or it will crash the game.\r\n\r\npublic class HelloWorld\r\n{\r\n public static void Main()\r\n {\r\n UnityExplorer.ExplorerCore.Log(\"Hello, world!\");\r\n }\r\n}\r\n\r\n// In REPL, you could call the example method above with \"HelloWorld.Main();\"\r\n// Note: The compiler does not allow you to run REPL code and define classes at the same time.\r\n\r\n// In REPL, use the \"GetClasses();\" helper to see the classes you have defined since the last Reset."), new CodeInfo("Coroutines", "// To start a Coroutine directly, use \"Start(SomeCoroutine());\" in REPL mode.\r\n\r\n// To declare a coroutine, you will need to compile it separately. For example:\r\npublic class MyCoro\r\n{\r\n public static IEnumerator Main()\r\n {\r\n yield return null;\r\n UnityExplorer.ExplorerCore.Log(\"Hello, world after one frame!\");\r\n }\r\n}\r\n// To run this Coroutine in REPL, it would look like \"Start(MyCoro.Main());\"") }; internal const string STARTUP_TEXT = "// Welcome to the UnityExplorer C# Console!\r\n\r\n// It is recommended to use the Log panel (or a console log window) while using this tool.\r\n// Use the Help dropdown to see detailed examples of how to use the console.\r\n\r\n// To execute a script automatically on startup, put the script at 'sinai-dev-UnityExplorer\\Scripts\\startup.cs'"; internal const string HELP_USINGS = "// You can add a using directive to any namespace, but you must compile for it to take effect.\r\n// It will remain in effect until you Reset the console.\r\nusing UnityEngine.UI;\r\n\r\n// To see your current usings, use the \"GetUsing();\" helper.\r\n// Note: You cannot add usings and evaluate REPL at the same time."; internal const string HELP_REPL = "/* REPL (Read-Evaluate-Print-Loop) is a way to execute code immediately.\r\n * REPL code cannot contain any using directives or classes.\r\n * The return value of the last line of your REPL will be printed to the log.\r\n * Variables defined in REPL will exist until you Reset the console.\r\n*/\r\n\r\n// eg: This code would print 'Hello, World!', and then print 6 as the return value.\r\nLog(\"Hello, world!\");\r\nvar x = 5;\r\n++x;\r\n\r\n/* The following helpers are available in REPL mode:\r\n * CurrentTarget; - System.Object, the target of the active Inspector tab\r\n * AllTargets; - System.Object[], the targets of all Inspector tabs\r\n * Log(obj); - prints a message to the console log\r\n * Inspect(obj); - inspect the object with the Inspector\r\n * Inspect(someType); - inspect a Type with static reflection\r\n * Start(enumerator); - Coroutine, starts the IEnumerator as a Coroutine, and returns the Coroutine.\r\n * Stop(coroutine); - stop the Coroutine ONLY if it was started with Start(ienumerator).\r\n * Copy(obj); - copies the object to the UnityExplorer Clipboard\r\n * Paste(); - System.Object, the contents of the Clipboard.\r\n * GetUsing(); - prints the current using directives to the console log\r\n * GetVars(); - prints the names and values of the REPL variables you have defined\r\n * GetClasses(); - prints the names and members of the classes you have defined\r\n * help; - the default REPL help command, contains additional helpers.\r\n*/"; internal const string HELP_CLASSES = "// Classes you compile will exist until the application closes.\r\n// You can soft-overwrite a class by compiling it again with the same name. The old class will still technically exist in memory.\r\n\r\n// Compiled classes can be accessed from both inside and outside this console.\r\n// Note: in IL2CPP, you must declare a Namespace to inject these classes with ClassInjector or it will crash the game.\r\n\r\npublic class HelloWorld\r\n{\r\n public static void Main()\r\n {\r\n UnityExplorer.ExplorerCore.Log(\"Hello, world!\");\r\n }\r\n}\r\n\r\n// In REPL, you could call the example method above with \"HelloWorld.Main();\"\r\n// Note: The compiler does not allow you to run REPL code and define classes at the same time.\r\n\r\n// In REPL, use the \"GetClasses();\" helper to see the classes you have defined since the last Reset."; internal const string HELP_COROUTINES = "// To start a Coroutine directly, use \"Start(SomeCoroutine());\" in REPL mode.\r\n\r\n// To declare a coroutine, you will need to compile it separately. For example:\r\npublic class MyCoro\r\n{\r\n public static IEnumerator Main()\r\n {\r\n yield return null;\r\n UnityExplorer.ExplorerCore.Log(\"Hello, world after one frame!\");\r\n }\r\n}\r\n// To run this Coroutine in REPL, it would look like \"Start(MyCoro.Main());\""; private bool sreNotSupported { get; set; } private int lastCaretPosition { get; set; } public static float DefaultInputFieldAlpha { get; set; } private bool enableCtrlRShortcut { get; set; } = true; private bool enableAutoIndent { get; set; } = true; private bool enableSuggestions { get; set; } = true; private static CSConsolePanel _panel => UIManager.GetPanel(UIManager.Panels.CSConsole); public static InputFieldRef Input => _panel.Input; public static string ScriptsFolder => Path.Combine(ExplorerCore.ExplorerFolder, "Scripts"); [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] [field: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] private static ConsoleController _instance { [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(2)] get; [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(2)] set; } public ConsoleController() { _evaluator = new ConsoleScriptEvaluator(); _lexer = new LexerBuilder(); _completer = new CSAutoCompleter(); SetupHelpInteraction(); try { ResetConsole(logSuccess: false); _evaluator.Compile("0 == 0"); } catch (Exception ex) { DisableConsole(ex); return; } CSConsolePanel panel = _panel; panel.OnInputChanged = (Action)System.Delegate.Combine(panel.OnInputChanged, new Action(OnInputChanged)); InputFieldScroller inputScroller = _panel.InputScroller; inputScroller.OnScroll = (Action)System.Delegate.Combine(inputScroller.OnScroll, new Action(OnInputScrolled)); CSConsolePanel panel2 = _panel; panel2.OnCompileClicked = (Action)System.Delegate.Combine(panel2.OnCompileClicked, new Action(Evaluate)); CSConsolePanel panel3 = _panel; panel3.OnResetClicked = (Action)System.Delegate.Combine(panel3.OnResetClicked, new Action(ResetConsole)); CSConsolePanel panel4 = _panel; panel4.OnDropdownChanged = (Action)System.Delegate.Combine(panel4.OnDropdownChanged, new Action(SelectedDropDown)); CSConsolePanel panel5 = _panel; panel5.OnAutoIndentToggled = (Action)System.Delegate.Combine(panel5.OnAutoIndentToggled, new Action(OnToggleAutoIndent)); CSConsolePanel panel6 = _panel; panel6.OnCtrlRToggled = (Action)System.Delegate.Combine(panel6.OnCtrlRToggled, new Action(OnToggleCtrlRShortcut)); CSConsolePanel panel7 = _panel; panel7.OnSuggestionsToggled = (Action)System.Delegate.Combine(panel7.OnSuggestionsToggled, new Action(OnToggleSuggestions)); CSConsolePanel panel8 = _panel; panel8.OnPanelResized = (Action)System.Delegate.Combine(panel8.OnPanelResized, new Action(OnInputScrolled)); try { if (!Directory.Exists(ScriptsFolder)) { Directory.CreateDirectory(ScriptsFolder); } if (File.Exists(Path.Combine(ScriptsFolder, "startup.cs"))) { int num = codes.FindIndex((CodeInfo x) => x.Label == "startup.cs"); if (num <= 0) { throw new Exception("Can't loaded script"); } SelectedDropDown(num); Evaluate(); } } catch (Exception arg) { ExplorerCore.LogWarning($"Exception executing startup script: {arg}"); } } public static void Init() { _instance = new ConsoleController(); } [return: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(new byte[] { 2, 1 })] public static string[] GetCompletions(string inputs, out string prefix) { prefix = ""; return _instance?._evaluator.GetCompletions(inputs, out prefix); } public static void Update() { _instance?.UpdateImp(); } public void ResetConsole() { ResetConsole(logSuccess: true); } public void ResetConsole(bool logSuccess = true) { if (!sreNotSupported) { _evaluator.Recreate(); usingDirectives.Clear(); string[] defaultUsing = DefaultUsing; foreach (string assemblyName in defaultUsing) { AddUsing(assemblyName); } ReloadAndRefreshScript(); if (logSuccess) { ExplorerCore.Log("C# Console reset"); } } } public void AddUsing(string assemblyName) { if (!usingDirectives.Contains(assemblyName)) { Evaluate("using " + assemblyName + ";", supressLog: true); usingDirectives.Add(assemblyName); } } public void Evaluate() { if (!sreNotSupported) { string text = Input.Text; Evaluate(text); TryUpdateScript(text); } } public void Evaluate(string input, bool supressLog = false) { if (sreNotSupported) { return; } _evaluator.Initialize(); try { Compile(input, supressLog); } catch (FormatException ex) { if (!supressLog) { ExplorerCore.LogWarning(ex.Message); } } catch (Exception message) { if (!supressLog) { ExplorerCore.LogWarning(message); } } } private void Compile(string input, bool supressLog = false) { CompiledMethod compiledMethod = _evaluator.Compile(input); if (compiledMethod != null) { REPLInvoke(compiledMethod); } else { CsCompile(supressLog); } } private void REPLInvoke(CompiledMethod repl) { try { object retvalue = null; repl(ref retvalue); if (!string.IsNullOrEmpty(retvalue?.ToString())) { ExplorerCore.Log($"Invoked REPL, result: {retvalue}"); } else { ExplorerCore.Log("Invoked REPL (no return value)"); } } catch (Exception arg) { ExplorerCore.LogWarning($"Exception invoking REPL: {arg}"); } } private void CsCompile(bool supressLog = false) { string text = _evaluator.ToString(); if (text != null && !string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[1] { '\n' }); if (array.Length >= 2) { text = array[^2]; } _evaluator.ClearOutput(); StreamReportPrinter reportPrinter = ScriptEvaluator._reportPrinter; if (reportPrinter != null && reportPrinter.ErrorsCount > 0) { throw new FormatException("Unable to compile the code. Evaluator's last output was:\r\n" + text); } if (!supressLog) { ExplorerCore.Log("Code compiled without errors."); } } } private void TryUpdateScript(string newScript) { int value = _panel.Dropdown.value; if (value <= 4 || codes.Count <= value) { return; } ExplorerCore.Log("Try Update exists code...."); CodeInfo codeInfo = codes[value]; string label = codeInfo.Label; codeInfo.Code = newScript; string path = Path.Combine(ScriptsFolder, label); if (!File.Exists(path)) { ExplorerCore.Log("File not found!!"); return; } try { File.WriteAllText(path, newScript); ExplorerCore.Log("Success!! override"); } catch { ExplorerCore.LogWarning("Can't override code"); } } public void UpdateImp() { if (sreNotSupported) { return; } if (!InputManager.GetKey((KeyCode)306) && !InputManager.GetKey((KeyCode)305)) { if (InputManager.GetKeyDown((KeyCode)278)) { JumpToStartOrEndOfLine(toStart: true); } else if (InputManager.GetKeyDown((KeyCode)279)) { JumpToStartOrEndOfLine(toStart: false); } } UpdateCaret(out var caretMoved); if (!settingCaretCoroutine && enableSuggestions) { if (AutoCompleteModal.CheckEscape(_completer)) { OnAutocompleteEscaped(); return; } if (caretMoved) { AutoCompleteModal.Instance.ReleaseOwnership(_completer); } } if (enableCtrlRShortcut && (InputManager.GetKey((KeyCode)306) || InputManager.GetKey((KeyCode)305)) && InputManager.GetKeyDown((KeyCode)114) && UnityHelpers.OccuredEarlierThanDefault(timeOfLastCtrlR)) { timeOfLastCtrlR = Time.realtimeSinceStartup; Evaluate(); } } private void OnInputScrolled() { HighlightVisibleInput(out var _); } private void OnInputChanged(string value) { if (sreNotSupported) { return; } if (InputManager.GetKeyDown((KeyCode)27)) { Input.Text = previousInput; if (enableSuggestions && AutoCompleteModal.CheckEscape(_completer)) { OnAutocompleteEscaped(); } return; } previousInput = value; if (enableSuggestions && AutoCompleteModal.CheckEnter(_completer)) { OnAutocompleteEnter(); } if (!settingCaretCoroutine && enableAutoIndent) { DoAutoIndent(); } HighlightVisibleInput(out var inStringOrComment); if (!settingCaretCoroutine && enableSuggestions) { if (inStringOrComment) { AutoCompleteModal.Instance.ReleaseOwnership(_completer); } else { _completer.CheckAutocompletes(); } } UpdateCaret(out var _); } private void OnToggleAutoIndent(bool value) { enableAutoIndent = value; } private void OnToggleCtrlRShortcut(bool value) { enableCtrlRShortcut = value; } private void OnToggleSuggestions(bool value) { enableSuggestions = value; } private void UpdateCaret(out bool caretMoved) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) int num = lastCaretPosition; caretMoved = false; if (enableSuggestions && AutoCompleteModal.CheckNavigation(_completer)) { Input.Component.caretPosition = lastCaretPosition; return; } if (Input.Component.isFocused) { lastCaretPosition = Input.Component.caretPosition; caretMoved = lastCaretPosition != num; } if (Input.Text.Length != 0 && caretMoved) { float y = Input.TextGenerator.characters[lastCaretPosition].cursorPos.y; float num2 = y - 18f; Rect rect = Input.Transform.rect; float num3 = ((Rect)(ref rect)).height - Input.Transform.anchoredPosition.y; rect = Input.Transform.rect; float num4 = num3 - ((Rect)(ref rect)).height * 0.5f; rect = _panel.InputScroller.ViewportRect.rect; float num5 = num4 - ((Rect)(ref rect)).height; float num6 = 0f; if (y > num4) { num6 = y - num4; } else if (num2 < num5) { num6 = num2 - num5; } if (Math.Abs(num6) > 1f) { RectTransform transform = Input.Transform; transform.anchoredPosition = new Vector2(transform.anchoredPosition.x, transform.anchoredPosition.y - num6); } } } public void SetCaretPosition(int caretPosition) { Input.Component.caretPosition = caretPosition; settingCaretCoroutine = true; Input.Component.readOnly = true; RuntimeHelper.StartCoroutine(DoSetCaretCoroutine(caretPosition)); } private IEnumerator DoSetCaretCoroutine(int caretPosition) { Color color = Input.Component.selectionColor; color.a = 0f; Input.Component.selectionColor = color; EventSystemHelper.SetSelectionGuard(false); ((Selectable)Input.Component).Select(); yield return null; Input.Component.caretPosition = caretPosition; Input.Component.selectionFocusPosition = caretPosition; lastCaretPosition = Input.Component.caretPosition; color.a = DefaultInputFieldAlpha; Input.Component.selectionColor = color; Input.Component.readOnly = false; settingCaretCoroutine = false; } private void JumpToStartOrEndOfLine(bool toStart) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) TextGenerator val = (TextGenerator)typeof(InputField).GetProperty("cachedInputTextGenerator", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Input.Component, null); UILineInfo val2 = default(UILineInfo); UILineInfo? val3 = null; for (int i = 0; i < val.lineCount; i++) { UILineInfo val4 = val.lines[i]; if (val4.startCharIdx > lastCaretPosition) { val3 = val4; break; } val2 = val4; } if (toStart) { int num = ((!val3.HasValue) ? Input.Text.Length : val3.Value.startCharIdx); int j; for (j = val2.startCharIdx; j < num - 1 && char.IsWhiteSpace(Input.Text[j]); j++) { } SetCaretPosition((lastCaretPosition == j) ? val2.startCharIdx : j); } else { SetCaretPosition((!val3.HasValue) ? Input.Text.Length : (val3.Value.startCharIdx - 1)); } } private void HighlightVisibleInput(out bool inStringOrComment) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) inStringOrComment = false; if (string.IsNullOrEmpty(Input.Text)) { _panel.HighlightText.text = ""; _panel.LineNumberText.text = "1"; return; } TextGenerator val = (TextGenerator)typeof(InputField).GetProperty("cachedInputTextGenerator", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Input.Component, null); int num = -1; int num2 = -1; Rect rect = Input.Transform.rect; float num3 = ((Rect)(ref rect)).height - Input.Transform.anchoredPosition.y; rect = Input.Transform.rect; float num4 = num3 - ((Rect)(ref rect)).height * 0.5f; rect = _panel.InputScroller.ViewportRect.rect; float num5 = num4 - ((Rect)(ref rect)).height; for (int i = 0; i < val.lineCount; i++) { UILineInfo val2 = val.lines[i]; if (num == -1 && val2.topY <= num4) { num = i; } if (val2.topY - (float)val2.height >= num5) { num2 = i; } } num = Math.Max(0, num - 1); num2 = Math.Min(val.lineCount - 1, num2 + 1); int startCharIdx = val.lines[num].startCharIdx; int endIdx = ((num2 >= val.lineCount - 1) ? (Input.Text.Length - 1) : (val.lines[num2 + 1].startCharIdx - 1)); _panel.HighlightText.text = _lexer.BuildHighlightedString(Input.Text, startCharIdx, endIdx, num, lastCaretPosition, out inStringOrComment); int num6 = 0; for (int j = 0; j < startCharIdx; j++) { if (LexerBuilder.IsNewLine(Input.Text[j])) { num6++; } } num6++; char c = '\n'; StringBuilder stringBuilder = new StringBuilder(); for (int k = 0; k < num; k++) { stringBuilder.Append('\n'); } for (int l = num; l <= num2; l++) { if (l > 0) { c = Input.Text[val.lines[l].startCharIdx - 1]; } if (LexerBuilder.IsNewLine(c)) { stringBuilder.Append(num6.ToString()); num6++; } stringBuilder.Append('\n'); } _panel.LineNumberText.text = stringBuilder.ToString(); } public static void InsertSuggestionAtCaret(string suggestion) { _instance?.InsertSuggestionAtCaretImp(suggestion); } private void InsertSuggestionAtCaretImp(string suggestion) { settingCaretCoroutine = true; Input.Text = Input.Text.Insert(lastCaretPosition, suggestion); SetCaretPosition(lastCaretPosition + suggestion.Length); lastCaretPosition = Input.Component.caretPosition; } private void OnAutocompleteEnter() { int startIndex = Input.Component.caretPosition - 1; Input.Text = Input.Text.Remove(startIndex, 1); Input.Component.caretPosition = lastCaretPosition; _completer.OnSuggestionClicked(AutoCompleteModal.SelectedSuggestion); } private void OnAutocompleteEscaped() { AutoCompleteModal.Instance.ReleaseOwnership(_completer); SetCaretPosition(lastCaretPosition); } private void DoAutoIndent() { if (Input.Text.Length > previousContentLength && Input.Text.Length - previousContentLength == 1) { int caretIndex = Input.Component.caretPosition; Input.Text = _lexer.IndentCharacter(Input.Text, ref caretIndex); Input.Component.caretPosition = caretIndex; lastCaretPosition = caretIndex; } previousContentLength = Input.Text.Length; } private void DisableConsole(Exception ex) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) sreNotSupported = true; Input.Component.readOnly = true; ((Graphic)Input.Component.textComponent).color = UnityHelpers.ToColor("5d8556"); if (ex is NotSupportedException) { Input.Text = "The C# Console has been disabled because System.Reflection.Emit threw a NotSupportedException.\r\n\r\nEasy, dirty fix: (will likely break on game updates)\r\n * Download the corlibs for the game's Unity version from here: https://unity.bepinex.dev/corlibs/\r\n * Unzip and copy mscorlib.dll (and System.Reflection.Emit DLLs, if present) from the folder\r\n * Paste and overwrite the files into _Data/Managed/\r\n\r\nWith UnityDoorstop: (BepInEx only, or if you use UnityDoorstop + Standalone release):\r\n * Download the corlibs for the game's Unity version from here: https://unity.bepinex.dev/corlibs/\r\n * Unzip and copy mscorlib.dll (and System.Reflection.Emit DLLs, if present) from the folder\r\n * Find the folder which contains doorstop_config.ini (the game folder, or your r2modman/ThunderstoreModManager profile folder)\r\n * Make a subfolder called 'corlibs' inside this folder.\r\n * Paste the DLLs inside the corlibs folder.\r\n * In doorstop_config.ini, set 'dllSearchPathOverride=corlibs'.\r\n\r\nDoorstop example:\r\n- \\\r\n - _Data\\...\r\n - BepInEx\\...\r\n - corlibs\\\r\n - mscorlib.dll\r\n - doorstop_config.ini (with dllSearchPathOverride=corlibs)\r\n - .exe\r\n - winhttp.dll"; } else { Input.Text = $"The C# Console has been disabled. {ex}"; } } public void SetupHelpInteraction() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Dropdown dropdown = _panel.Dropdown; foreach (CodeInfo code in codes) { dropdown.options.Add(new OptionData(code.Label)); } ReloadAndRefreshScript(); } public void SelectedDropDown(int index) { if (codes.Count > index) { Input.Text = codes[index].Code; } } public void ReloadAndRefreshScript() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown if (!Directory.Exists(ScriptsFolder)) { return; } string[] files = Directory.GetFiles(ScriptsFolder, "*.cs", SearchOption.AllDirectories); if (files.Length == 0) { return; } ExplorerCore.Log("Reloading all script..."); Dropdown dropdown = _panel.Dropdown; int value = dropdown.value; int count = dropdown.options.Count; if (count > 5) { dropdown.options.RemoveRange(5, count - 5); } count = codes.Count; if (count > 5) { codes.RemoveRange(5, count - 5); } string[] array = files; foreach (string text in array) { try { ExplorerCore.Log("loading... : " + text); string fileName = Path.GetFileName(text); string code = File.ReadAllText(Path.Combine(ScriptsFolder, text)); codes.Add(new CodeInfo(fileName, code)); dropdown.options.Add(new OptionData(fileName)); } catch { ExplorerCore.LogWarning("fail load : " + text); } } SelectedDropDown(value); } } [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(2)] public sealed class ConsoleScriptEvaluator { private ScriptEvaluator _evaluator; private ScriptEvaluatorResult _result; public override string ToString() { return _evaluator?.ToString(); } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] [return: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(new byte[] { 2, 1 })] public string[] GetCompletions(string inputs, out string prefix) { prefix = string.Empty; return _evaluator?.GetCompletions(inputs, out prefix); } public void ClearOutput() { _result?.Clear(); } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] [return: <51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] public CompiledMethod Compile(string text) { return _evaluator?.Compile(text); } public void Initialize() { if (_evaluator == null) { Recreate(); } if (_evaluator == null) { ExplorerCore.LogError("Can't init evaluator"); } else if (_result == null || _result.IsNull()) { _result = new ScriptEvaluatorResult(); _evaluator.TextWriter = _result.Writer; } } public void Recreate() { _evaluator?.Dispose(); _result = new ScriptEvaluatorResult(); _evaluator = new ScriptEvaluator(_result.Writer) { InteractiveBaseClass = typeof(ScriptInteraction) }; } } public class CSAutoCompleter : ISuggestionProvider { private readonly HashSet delimiters = new HashSet { '{', '}', ',', ';', '<', '>', '(', ')', '[', ']', '=', '|', '&', '?' }; private readonly List suggestions = new List(); private readonly Dictionary namespaceHighlights = new Dictionary(); private readonly Dictionary keywordHighlights = new Dictionary(); private readonly StringBuilder highlightBuilder = new StringBuilder(); private const string OPEN_HIGHLIGHT = ""; public InputFieldRef InputField => ConsoleController.Input; public bool AnchorToCaretPosition => true; bool ISuggestionProvider.AllowNavigation => true; public void OnSuggestionClicked(Suggestion suggestion) { ConsoleController.InsertSuggestionAtCaret(suggestion.UnderlyingValue); AutoCompleteModal.Instance.ReleaseOwnership(this); } public void CheckAutocompletes() { if (string.IsNullOrEmpty(InputField.Text)) { AutoCompleteModal.Instance.ReleaseOwnership(this); return; } suggestions.Clear(); int num = Math.Max(0, Math.Min(InputField.Text.Length - 1, InputField.Component.caretPosition - 1)); int num2 = num; if (char.IsWhiteSpace(InputField.Text[num]) || delimiters.Contains(InputField.Text[num]) || (InputField.Text.Length > num + 1 && !char.IsWhiteSpace(InputField.Text[num + 1]))) { AutoCompleteModal.Instance.ReleaseOwnership(this); return; } while (num2 > 0) { num2--; char c = InputField.Text[num2]; if (delimiters.Contains(c) || char.IsWhiteSpace(c)) { num2++; break; } } string text = InputField.Text.Substring(num2, num - num2 + 1); string prefix; string[] completions = ConsoleController.GetCompletions(text, out prefix); if (completions != null && completions.Any()) { suggestions.AddRange(completions.Select((string completion) => new Suggestion(GetHighlightString(prefix, completion), completion))); } foreach (string allNamespace in ReflectionUtility.AllNamespaces) { if (allNamespace.StartsWith(text)) { if (!namespaceHighlights.ContainsKey(allNamespace)) { namespaceHighlights.Add(allNamespace, "" + allNamespace + ""); } string underlyingValue = allNamespace.Substring(text.Length, allNamespace.Length - text.Length); suggestions.Add(new Suggestion(namespaceHighlights[allNamespace], underlyingValue)); } } foreach (string keyword in KeywordLexer.keywords) { if (keyword.StartsWith(text)) { if (!keywordHighlights.ContainsKey(keyword)) { keywordHighlights.Add(keyword, "" + keyword + ""); } string underlyingValue2 = keyword.Substring(text.Length, keyword.Length - text.Length); suggestions.Add(new Suggestion(keywordHighlights[keyword], underlyingValue2)); } } if (suggestions.Any()) { AutoCompleteModal.TakeOwnership(this); AutoCompleteModal.Instance.SetSuggestions(suggestions); } else { AutoCompleteModal.Instance.ReleaseOwnership(this); } } private string GetHighlightString(string prefix, string completion) { highlightBuilder.Clear(); highlightBuilder.Append(""); highlightBuilder.Append(prefix); highlightBuilder.Append(""); highlightBuilder.Append(completion); return highlightBuilder.ToString(); } } public struct MatchInfo { public int startIndex; public int endIndex; public bool isStringOrComment; public bool matchToEndOfLine; public string htmlColorTag; } public class LexerBuilder { public const char WHITESPACE = ' '; public readonly HashSet IndentOpenChars = new HashSet { '{', '(' }; public readonly HashSet IndentCloseChars = new HashSet { '}', ')' }; private readonly Lexer[] lexers; private readonly HashSet delimiters = new HashSet(); private readonly StringLexer stringLexer = new StringLexer(); private readonly CommentLexer commentLexer = new CommentLexer(); private string currentInput; private int currentStartIdx; private int currentEndIdx; public int CommittedIndex { get; private set; } public int CurrentIndex { get; private set; } public char Current { get { if (EndOfInput) { return ' '; } return currentInput[CurrentIndex]; } } public char Previous { get { if (CurrentIndex < 1) { return ' '; } return currentInput[CurrentIndex - 1]; } } public bool EndOfInput => CurrentIndex > currentEndIdx; public bool EndOrNewLine { get { if (!EndOfInput) { return IsNewLine(Current); } return true; } } public LexerBuilder() { lexers = new Lexer[5] { commentLexer, stringLexer, new SymbolLexer(), new NumberLexer(), new KeywordLexer() }; Lexer[] array = lexers; for (int i = 0; i < array.Length; i++) { foreach (char delimiter in array[i].Delimiters) { if (!delimiters.Contains(delimiter)) { delimiters.Add(delimiter); } } } } public static bool IsNewLine(char c) { if (c != '\n') { return c == '\r'; } return true; } public string BuildHighlightedString(string input, int startIdx, int endIdx, int leadingLines, int caretIdx, out bool caretInStringOrComment) { caretInStringOrComment = false; if (string.IsNullOrEmpty(input) || endIdx <= startIdx) { return input; } currentInput = input; currentStartIdx = startIdx; currentEndIdx = endIdx; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < leadingLines; i++) { stringBuilder.Append('\n'); } int j = startIdx; foreach (MatchInfo match in GetMatches()) { for (int k = j; k < match.startIndex; k++) { stringBuilder.Append(input[k]); } stringBuilder.Append(match.htmlColorTag); for (int l = match.startIndex; l <= match.endIndex && l <= currentEndIdx; l++) { stringBuilder.Append(input[l]); } stringBuilder.Append(""); j = match.endIndex + 1; int num = match.endIndex; if (match.matchToEndOfLine) { while (input.Length - 1 >= num) { num++; if (IsNewLine(input[num])) { break; } } } if (caretIdx >= match.startIndex && (caretIdx <= num + 1 || (caretIdx >= input.Length && num >= input.Length - 1))) { caretInStringOrComment = match.isStringOrComment; } } for (; j <= endIdx; j++) { stringBuilder.Append(input[j]); } return stringBuilder.ToString(); } public IEnumerable GetMatches() { CommittedIndex = currentStartIdx - 1; Rollback(); while (!EndOfInput) { SkipWhitespace(); bool anyMatch = false; int startIndex = CommittedIndex + 1; Lexer[] array = lexers; foreach (Lexer lexer in array) { if (lexer.TryMatchCurrent(this)) { anyMatch = true; yield return new MatchInfo { startIndex = startIndex, endIndex = CommittedIndex, htmlColorTag = lexer.ColorTag, isStringOrComment = (lexer is StringLexer || lexer is CommentLexer) }; break; } Rollback(); } if (!anyMatch) { CurrentIndex = CommittedIndex + 1; Commit(); } } } public char PeekNext(int amount = 1) { CurrentIndex += amount; return Current; } public void Commit() { CommittedIndex = Math.Min(currentEndIdx, CurrentIndex); } public void Rollback() { CurrentIndex = CommittedIndex + 1; } public void RollbackBy(int amount) { CurrentIndex = Math.Max(CommittedIndex + 1, CurrentIndex - amount); } public bool IsDelimiter(char character, bool orWhitespace = false, bool orLetterOrDigit = false) { if (!delimiters.Contains(character) && (!orWhitespace || !char.IsWhiteSpace(character))) { if (orLetterOrDigit) { return char.IsLetterOrDigit(character); } return false; } return true; } private void SkipWhitespace() { while (!EndOfInput && char.IsWhiteSpace(Current)) { Commit(); PeekNext(); } if (!char.IsWhiteSpace(Current)) { Rollback(); } } public string IndentCharacter(string input, ref int caretIndex) { int num = caretIndex - 1; char c = input[num]; if (!IsNewLine(c) && !IndentCloseChars.Contains(c)) { return input; } currentInput = input; currentStartIdx = 0; currentEndIdx = num; CommittedIndex = -1; Rollback(); int num2 = 0; while (!EndOfInput) { if (CurrentIndex >= num) { if (num2 > 0) { input = ((!IsNewLine(c)) ? IndentCloseDelimiter(input, num2, num, ref caretIndex) : IndentNewLine(input, num2, ref caretIndex)); } break; } if (stringLexer.TryMatchCurrent(this) || commentLexer.TryMatchCurrent(this)) { PeekNext(); continue; } if (IndentOpenChars.Contains(Current)) { num2++; } else if (IndentCloseChars.Contains(Current)) { num2--; } Commit(); PeekNext(); } return input; } private string IndentNewLine(string input, int indent, ref int caretIndex) { while (CurrentIndex < input.Length - 1) { CurrentIndex++; char c = input[CurrentIndex]; if (IsNewLine(c)) { break; } if (!char.IsWhiteSpace(c)) { if (IndentCloseChars.Contains(c)) { indent--; } break; } } if (indent > 0) { input = input.Insert(caretIndex, new string('\t', indent)); caretIndex += indent; } return input; } private string IndentCloseDelimiter(string input, int indent, int lastCharIndex, ref int caretIndex) { if (CurrentIndex > lastCharIndex) { return input; } indent--; while (CurrentIndex > 0) { CurrentIndex--; char c = input[CurrentIndex]; if (IsNewLine(c)) { break; } if (!char.IsWhiteSpace(c)) { indent = 0; break; } if (c == '\t') { indent--; } } if (indent > 0) { input = input.Insert(caretIndex, new string('\t', indent)); caretIndex += indent; } else if (indent < 0) { input = input.Remove(lastCharIndex - 1, -indent); caretIndex += indent; } return input; } } [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] public sealed class ScriptEvaluator : Evaluator, IDisposable { [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] internal static StreamReportPrinter _reportPrinter; private static readonly HashSet StdLib = new HashSet(StringComparer.InvariantCultureIgnoreCase) { "mscorlib", "System.Core", "System", "System.Xml" }; internal TextWriter TextWriter { private get; set; } public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw)) { TextWriter = tw; ImportAppdomainAssemblies(); AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad; } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(2)] public override string ToString() { return TextWriter.ToString(); } public void Dispose() { AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoad; TextWriter.Dispose(); } private void OnAssemblyLoad([<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(2)] object _, AssemblyLoadEventArgs args) { string name = args.LoadedAssembly.GetName().Name; if (!string.IsNullOrEmpty(name) && !StdLib.Contains(name)) { Reference(args.LoadedAssembly); } } private void Reference(Assembly asm) { string name = asm.GetName().Name; if (string.IsNullOrEmpty(name) || name == "completions") { return; } string[] array = ConfigManager.CSConsole_Assembly_Blacklist.Value.Split(new char[1] { ';' }); foreach (string text in array) { string text2 = text; if (text2.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { text2 = text.Substring(0, text2.Length - 4); } if (string.Equals(text2, name, StringComparison.OrdinalIgnoreCase)) { return; } } ReferenceAssembly(asm); } private static CompilerContext BuildContext(TextWriter tw) { _reportPrinter = new StreamReportPrinter(tw); return new CompilerContext(new CompilerSettings { Version = LanguageVersion.Experimental, GenerateDebugInfo = false, StdLib = true, Target = Target.Library, WarningLevel = 0, EnhancedWarnings = false, Unsafe = true }, _reportPrinter); } private void ImportAppdomainAssemblies() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string name = assembly.GetName().Name; if (!string.IsNullOrEmpty(name) && !StdLib.Contains(name)) { try { Reference(assembly); } catch { } } } } } [<1c3246b5-de04-4fad-97b0-7d66086b477f>NullableContext(1)] [<51f39266-096c-4d87-ba52-c28899f938d4>Nullable(0)] public sealed class ScriptEvaluatorResult { private readonly StringBuilder _output; public StringWriter Writer { get; } public ScriptEvaluatorResult() { _output = new StringBuilder(); Writer = new StringWriter(_output); } public void Clear() { _output.Clear(); } public bool IsNull() { if (_output != null) { return Writer == null; } return true; } } public class ScriptInteraction : InteractiveBase { public static object CurrentTarget => InspectorManager.ActiveInspector?.Target; public static object[] AllTargets => InspectorManager.Inspectors.Select((InspectorBase it) => it.Target).ToArray(); public static void Log(object message) { ExplorerCore.Log(message); } public static void Inspect(object obj) { InspectorManager.Inspect(obj); } public static void Inspect(Type type) { InspectorManager.Inspect(type); } public static Coroutine Start(IEnumerator ienumerator) { return RuntimeHelper.StartCoroutine(ienumerator); } public static void Stop(Coroutine coro) { RuntimeHelper.StopCoroutine(coro); } public static void Copy(object obj) { ClipboardPanel.Copy(obj); } public static object Paste() { return ClipboardPanel.Current; } public static void GetUsing() { Log(InteractiveBase.Evaluator.GetUsing()); } public static void GetVars() { string text = InteractiveBase.Evaluator.GetVars()?.Trim(); if (string.IsNullOrEmpty(text)) { ExplorerCore.LogWarning("No variables seem to be defined!"); } else { Log(text); } } public static void GetClasses() { if (AccessTools.Field(typeof(Evaluator), "source_file").GetValue(InteractiveBase.Evaluator) is CompilationSourceFile compilationSourceFile && compilationSourceFile.Containers.Any()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"There are {compilationSourceFile.Containers.Count} defined classes:"); foreach (TypeDefinition item in compilationSourceFile.Containers.Where((TypeContainer it) => it is TypeDefinition)) { stringBuilder.Append("\n\n" + item.MemberName.Name + ":"); foreach (MemberCore member in item.Members) { stringBuilder.Append($"\n\t- {member.AttributeTargets}: \"{member.MemberName.Name}\" ({member.ModFlags})"); } } Log(stringBuilder.ToString()); } else { ExplorerCore.LogWarning("No classes seem to be defined."); } } } } namespace UnityExplorer.CSConsole.Lexers { public class CommentLexer : Lexer { private enum CommentType { Line, Block } protected override Color HighlightColor => new Color(0.34f, 0.65f, 0.29f, 1f); public override bool TryMatchCurrent(LexerBuilder lexer) { if (lexer.Current == '/') { lexer.PeekNext(); if (lexer.Current == '/') { do { lexer.Commit(); lexer.PeekNext(); } while (!lexer.EndOrNewLine); return true; } if (lexer.Current == '*') { lexer.PeekNext(); do { lexer.PeekNext(); lexer.Commit(); } while (!lexer.EndOfInput && (lexer.Current != '/' || lexer.Previous != '*')); return true; } } return false; } } public class KeywordLexer : Lexer { public static readonly HashSet keywords = new HashSet { "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while", "add", "and", "alias", "ascending", "async", "await", "by", "descending", "dynamic", "equals", "from", "get", "global", "group", "init", "into", "join", "let", "managed", "nameof", "not", "notnull", "on", "or", "orderby", "partial", "record", "remove", "select", "set", "unmanaged", "value", "var", "when", "where", "where", "with", "yield", "nint", "nuint" }; protected override Color HighlightColor => new Color(0.33f, 0.61f, 0.83f, 1f); public override bool TryMatchCurrent(LexerBuilder lexer) { char previous = lexer.Previous; char current = lexer.Current; if (lexer.IsDelimiter(previous, orWhitespace: true) && char.IsLetter(current)) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(lexer.Current); while (!lexer.EndOfInput && char.IsLetter(lexer.PeekNext())) { stringBuilder.Append(lexer.Current); } if (!lexer.EndOfInput && !char.IsWhiteSpace(lexer.Current) && !lexer.IsDelimiter(lexer.Current)) { return false; } if (keywords.Contains(stringBuilder.ToString())) { if (!lexer.EndOfInput) { lexer.RollbackBy(1); } lexer.Commit(); return true; } return false; } return false; } } public abstract class Lexer { private string colorTag; public virtual IEnumerable Delimiters => Enumerable.Empty(); protected abstract Color HighlightColor { get; } public string ColorTag => colorTag ?? (colorTag = ""); public abstract bool TryMatchCurrent(LexerBuilder lexer); } public class NumberLexer : Lexer { protected override Color HighlightColor => new Color(0.58f, 0.33f, 0.33f, 1f); private bool IsNumeric(char c) { if (!char.IsNumber(c)) { return c == '.'; } return true; } public override bool TryMatchCurrent(LexerBuilder lexer) { if (!lexer.IsDelimiter(lexer.Previous, orWhitespace: true)) { return false; } if (!IsNumeric(lexer.Current)) { return false; } while (!lexer.EndOfInput) { lexer.Commit(); if (!IsNumeric(lexer.PeekNext())) { break; } } return true; } } public class StringLexer : Lexer { public override IEnumerable Delimiters => new char[2] { '"', '\'' }; protected override Color HighlightColor => new Color(0.79f, 0.52f, 0.32f, 1f); public override bool TryMatchCurrent(LexerBuilder lexer) { if (lexer.Current == '"') { if (lexer.Previous == '@') { while (!lexer.EndOfInput) { lexer.Commit(); if (lexer.PeekNext() == '"') { lexer.Commit(); bool flag = false; while (lexer.PeekNext() == '"') { lexer.Commit(); flag = !flag; } if (!flag) { break; } } } } else { while (!lexer.EndOfInput) { lexer.Commit(); lexer.PeekNext(); if (lexer.Current == '"' && lexer.Previous != '\\') { lexer.Commit(); break; } } } return true; } if (lexer.Current == '\'') { while (!lexer.EndOfInput) { lexer.Commit(); lexer.PeekNext(); if (lexer.Current == '\'' && lexer.Previous != '\\') { lexer.Commit(); break; } } return true; } return false; } } public class SymbolLexer : Lexer { public static readonly HashSet symbols = new HashSet { '[', '{', '(', ']', '}', ')', '.', ',', ';', ':', '?', '@', '+', '-', '*', '/', '%', '&', '|', '^', '~', '=', '<', '>', '!' }; protected override Color HighlightColor => new Color(0.6f, 0.6f, 0.6f); public override IEnumerable Delimiters => symbols.Where((char it) => it != '.'); public static bool IsSymbol(char c) { return symbols.Contains(c); } public override bool TryMatchCurrent(LexerBuilder lexer) { if (!lexer.IsDelimiter(lexer.Previous, orWhitespace: true, orLetterOrDigit: true)) { return false; } if (IsSymbol(lexer.Current)) { lexer.Commit(); return true; } return false; } } } namespace UnityExplorer.Config { public class ConfigElement : IConfigElement { public Action OnValueChanged; private T m_value; public string Name { get; } public string Description { get; } public bool IsInternal { get; } public Type ElementType => typeof(T); public Action OnValueChangedNotify { get; set; } public object DefaultValue { get; } public ConfigHandler Handler { get { if (!IsInternal) { return ConfigManager.Handler; } return ConfigManager.InternalHandler; } } public T Value { get { return m_value; } set { SetValue(value); } } object IConfigElement.BoxedValue { get { return m_value; } set { SetValue((T)value); } } public ConfigElement(string name, string description, T defaultValue, bool isInternal = false) { Name = name; Description = description; m_value = defaultValue; DefaultValue = defaultValue; IsInternal = isInternal; ConfigManager.RegisterConfigElement(this); } private void SetValue(T value) { if (m_value == null && value == null) { return; } if (m_value != null) { ref T value2 = ref m_value; object obj = value; if (value2.Equals(obj)) { return; } } m_value = value; Handler.SetConfigValue(this, value); OnValueChanged?.Invoke(value); OnValueChangedNotify?.Invoke(); Handler.OnAnyConfigChanged(); } object IConfigElement.GetLoaderConfigValue() { return GetLoaderConfigValue(); } public T GetLoaderConfigValue() { return Handler.GetConfigValue(this); } public void RevertToDefaultValue() { Value = (T)DefaultValue; } } public abstract class ConfigHandler { public abstract void RegisterConfigElement(ConfigElement element); public abstract void SetConfigValue(ConfigElement element, T value); public abstract T GetConfigValue(ConfigElement element); public abstract void Init(); public abstract void LoadConfig(); public abstract void SaveConfig(); public virtual void OnAnyConfigChanged() { } } public static class ConfigManager { internal static readonly Dictionary ConfigElements = new Dictionary(); internal static readonly Dictionary InternalConfigs = new Dictionary(); public static ConfigElement Master_Toggle; public static ConfigElement Hide_On_Startup; public static ConfigElement Startup_Delay_Time; public static ConfigElement Disable_EventSystem_Override; public static ConfigElement Disable_Setup_Force_ReLoad_ManagedAssemblies; public static ConfigElement Bypass_UniverseLib_ICall; public static ConfigElement Target_Display; public static ConfigElement Force_Unlock_Mouse; public static ConfigElement Force_Unlock_Toggle; public static ConfigElement Default_Output_Path; public static ConfigElement DnSpy_Path; public static ConfigElement Log_Unity_Debug; public static ConfigElement Log_To_Disk; public static ConfigElement Main_Navbar_Anchor; public static ConfigElement World_MouseInspect_Keybind; public static ConfigElement UI_MouseInspect_Keybind; public static ConfigElement CSConsole_Assembly_Blacklist; public static ConfigElement Reflection_Signature_Blacklist; public static ConfigElement TIME_SCALE_TOGGLE; public static ConfigElement LOCK_TIME_SCALE_TO_ZERO; public static ConfigElement LOCK_TIME_SCALE_TO_NORMAL; public static ConfigElement LOCK_TIME_SCALE_TO_HALF; public static ConfigElement LOCK_TIME_SCALE_TO_DOUBLE; internal static readonly Dictionary> PanelSaveData = new Dictionary>(); public static ConfigHandler Handler { get; private set; } internal static InternalConfigHandler InternalHandler { get; private set; } internal static ConfigElement GetPanelSaveData(UIManager.Panels panel) { if (!PanelSaveData.ContainsKey(panel)) { PanelSaveData.Add(panel, new ConfigElement(panel.ToString(), string.Empty, string.Empty, isInternal: true)); } return PanelSaveData[panel]; } public static void Init(ConfigHandler configHandler) { Handler = configHandler; Handler.Init(); InternalHandler = new InternalConfigHandler(); InternalHandler.Init(); CreateConfigElements(); Handler.LoadConfig(); InternalHandler.LoadConfig(); } internal static void RegisterConfigElement(ConfigElement configElement) { if (!configElement.IsInternal) { Handler.RegisterConfigElement(configElement); ConfigElements.Add(configElement.Name, configElement); } else { InternalHandler.RegisterConfigElement(configElement); InternalConfigs.Add(configElement.Name, configElement); } } private static void CreateConfigElements() { Master_Toggle = new ConfigElement("UnityExplorer Toggle", "The key to enable or disable UnityExplorer's menu and features.", (KeyCode)288); Hide_On_Startup = new ConfigElement("Hide On Startup", "Should UnityExplorer be hidden on startup?", defaultValue: false); Startup_Delay_Time = new ConfigElement("Startup Delay Time", "The delay on startup before the UI is created.", 1f); Target_Display = new ConfigElement("Target Display", "The monitor index for UnityExplorer to use, if you have multiple. 0 is the default display, 1 is secondary, etc. Restart recommended when changing this setting. Make sure your extra monitors are the same resolution as your primary monitor.", 0); Force_Unlock_Mouse = new ConfigElement("Force Unlock Mouse", "Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.", defaultValue: true); ConfigElement force_Unlock_Mouse = Force_Unlock_Mouse; force_Unlock_Mouse.OnValueChanged = (Action)System.Delegate.Combine(force_Unlock_Mouse.OnValueChanged, (Action)delegate(bool value) { ConfigManager.Force_Unlock_Mouse = value; }); Force_Unlock_Toggle = new ConfigElement("Force Unlock Toggle Key", "The keybind to toggle the 'Force Unlock Mouse' setting. Only usable when UnityExplorer is open.", (KeyCode)0); Disable_EventSystem_Override = new ConfigElement("Disable EventSystem override", "If enabled, UnityExplorer will not override the EventSystem from the game.\nMay require restart to take effect.", defaultValue: false); ConfigElement disable_EventSystem_Override = Disable_EventSystem_Override; disable_EventSystem_Override.OnValueChanged = (Action)System.Delegate.Combine(disable_EventSystem_Override.OnValueChanged, (Action)delegate(bool value) { ConfigManager.Disable_EventSystem_Override = value; }); Disable_Setup_Force_ReLoad_ManagedAssemblies = new ConfigElement("Disable Force reload ManagedAssemblies", "If enabled, UnityExplorer will not reload ManagedAssemblies on setup(Currently only Mono is supported).\nMay require restart to take effect.", defaultValue: false); Bypass_UniverseLib_ICall = new ConfigElement("Bypass UniverseLib ICall", "If enabled, UnityExplorer will bypass UniverseLib's ICall Reflection system. This may help with compatibility in some games.\nMay require restart to take effect.", defaultValue: false); Default_Output_Path = new ConfigElement("Default Output Path", "The default output path when exporting things from UnityExplorer.", Path.Combine(ExplorerCore.ExplorerFolder, "Output")); DnSpy_Path = new ConfigElement("dnSpy Path", "The full path to dnSpy.exe (64-bit).", "C:/Program Files/dnspy/dnSpy.exe"); Main_Navbar_Anchor = new ConfigElement("Main Navbar Anchor", "The vertical anchor of the main UnityExplorer Navbar, in case you want to move it.", UIManager.VerticalAnchor.Top); Log_Unity_Debug = new ConfigElement("Log Unity Debug", "Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?", defaultValue: false); Log_To_Disk = new ConfigElement("Log To Disk", "Should UnityExplorer save log files to the disk?", defaultValue: true); World_MouseInspect_Keybind = new ConfigElement("World Mouse-Inspect Keybind", "Optional keybind to being a World-mode Mouse Inspect.", (KeyCode)0); UI_MouseInspect_Keybind = new ConfigElement("UI Mouse-Inspect Keybind", "Optional keybind to begin a UI-mode Mouse Inspect.", (KeyCode)0); CSConsole_Assembly_Blacklist = new ConfigElement("CSharp Console Assembly Blacklist", "Use this to blacklist Assembly names from being referenced by the C# Console. Requires a Reset of the C# Console.\nSeparate each Assembly with a semicolon ';'.For example, to blacklist Assembly-CSharp, you would add 'Assembly-CSharp;'", ""); Reflection_Signature_Blacklist = new ConfigElement("Member Signature Blacklist", "Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\nSeperate signatures with a semicolon ';'.\r\nFor example, to blacklist Camera.main, you would add 'UnityEngine.Camera.main;'", ""); TIME_SCALE_TOGGLE = new ConfigElement("TimeScale Toggle", "Shortcut key for locking/unlocking TimeScale", (KeyCode)0); LOCK_TIME_SCALE_TO_ZERO = new ConfigElement("Pause Keybind", "Shortcut key for setting TimeScale to 0.0", (KeyCode)0); LOCK_TIME_SCALE_TO_NORMAL = new ConfigElement("Playback Keybind", "Shortcut key for setting TimeScale to 1.0", (KeyCode)0); LOCK_TIME_SCALE_TO_HALF = new ConfigElement("Speed-Down Keybind", "Shortcut key for setting TimeScale to half", (KeyCode)0); LOCK_TIME_SCALE_TO_DOUBLE = new ConfigElement("Speed-Up Keybind", "Shortcut key for setting TimeScale to double", (KeyCode)0); } } public interface IConfigElement { string Name { get; } string Description { get; } bool IsInternal { get; } Type ElementType { get; } object BoxedValue { get; set; } object DefaultValue { get; } Action OnValueChangedNotify { get; set; } object GetLoaderConfigValue(); void RevertToDefaultValue(); } public class InternalConfigHandler : ConfigHandler { internal static string CONFIG_PATH; public override void Init() { CONFIG_PATH = Path.Combine(ExplorerCore.ExplorerFolder, "data.cfg"); } public override void LoadConfig() { if (!TryLoadConfig()) { SaveConfig(); } } public override void RegisterConfigElement(ConfigElement element) { } public override void SetConfigValue(ConfigElement element, T value) { } public override T GetConfigValue(ConfigElement element) { return element.Value; } public override void OnAnyConfigChanged() { SaveConfig(); } public bool TryLoadConfig() { try { if (!File.Exists(CONFIG_PATH)) { return false; } TomlDocument tomlDocument = TomlParser.ParseFile(CONFIG_PATH); foreach (string key in tomlDocument.Keys) { if (System.Enum.IsDefined(typeof(UIManager.Panels), key)) { ConfigManager.GetPanelSaveData((UIManager.Panels)System.Enum.Parse(typeof(UIManager.Panels), key)).Value = tomlDocument.GetString(key); } } return true; } catch (Exception ex) { ExplorerCore.LogWarning("Error loading internal data: " + ex.ToString()); return false; } } public override void SaveConfig() { if (UIManager.Initializing) { return; } TomlDocument tomlDocument = TomlDocument.CreateEmpty(); foreach (KeyValuePair internalConfig in ConfigManager.InternalConfigs) { tomlDocument.Put(internalConfig.Key, internalConfig.Value.BoxedValue as string); } File.WriteAllText(CONFIG_PATH, tomlDocument.SerializedValue); } } } namespace UnityExplorer.CacheObject { public class CacheConfigEntry : CacheObjectBase { public IConfigElement RefConfigElement; public override bool ShouldAutoEvaluate => true; public override bool HasArguments => false; public override bool CanWrite => true; public CacheConfigEntry(IConfigElement configElement) { RefConfigElement = configElement; base.FallbackType = configElement.ElementType; base.NameLabelText = "" + configElement.Name + "\r\n" + configElement.Description + ""; base.NameLabelTextRaw = string.Empty; configElement.OnValueChangedNotify = (Action)System.Delegate.Combine(configElement.OnValueChangedNotify, new Action(UpdateValueFromSource)); } public void UpdateValueFromSource() { SetValueFromSource(RefConfigElement.BoxedValue); if (base.CellView != null) { SetDataToCell(base.CellView); } } public override void TrySetUserValue(object value) { base.Value = value; RefConfigElement.BoxedValue = value; } protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell) { return true; } } public class CacheConstructor : CacheMember { private readonly Type typeForStructConstructor; public ConstructorInfo CtorInfo { get; } public override Type DeclaringType => typeForStructConstructor ?? CtorInfo.DeclaringType; public override bool IsStatic => true; public override bool ShouldAutoEvaluate => false; public override bool CanWrite => false; public CacheConstructor(ConstructorInfo ci) { CtorInfo = ci; } public CacheConstructor(Type typeForStructConstructor) { this.typeForStructConstructor = typeForStructConstructor; } public override void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member) { if (typeForStructConstructor != null) { Type type = typeForStructConstructor; base.Owner = inspector; base.NameLabelText = SignatureHighlighter.Parse(typeForStructConstructor, false, (MemberInfo)null); base.NameLabelText = base.NameLabelText + "." + base.NameLabelText + "()"; base.NameForFiltering = SignatureHighlighter.RemoveHighlighting(base.NameLabelText); base.NameLabelTextRaw = base.NameForFiltering; } else { base.SetInspectorOwner(inspector, member); base.Arguments = CtorInfo.GetParameters(); Type type = CtorInfo.DeclaringType; if (type.IsGenericTypeDefinition) { base.GenericArguments = type.GetGenericArguments(); } } } protected override object TryEvaluate() { try { Type type = DeclaringType; if (type.IsGenericTypeDefinition) { type = DeclaringType.MakeGenericType(base.Evaluator.TryParseGenericArguments()); } object result = ((!HasArguments) ? Activator.CreateInstance(type, ArgumentUtility.EmptyArgs) : Activator.CreateInstance(type, base.Evaluator.TryParseArguments())); base.LastException = null; return result; } catch (Exception lastException) { base.LastException = lastException; return null; } } protected override void TrySetValue(object value) { throw new NotImplementedException("You can't set a constructor"); } } public class CacheField : CacheMember { private bool? m_canWrite; public FieldInfo FieldInfo { get; internal set; } public override Type DeclaringType => FieldInfo.DeclaringType; public override bool IsStatic => FieldInfo.IsStatic; public override bool CanWrite { get { bool? canWrite = m_canWrite; if (!canWrite.HasValue) { bool? flag = (m_canWrite = !FieldInfo.IsLiteral || FieldInfo.IsInitOnly); return flag.Value; } return canWrite == true; } } public override bool ShouldAutoEvaluate => true; public CacheField(FieldInfo fi) { FieldInfo = fi; } public override void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member) { base.SetInspectorOwner(inspector, member); } protected override object TryEvaluate() { try { object? value = FieldInfo.GetValue(base.DeclaringInstance); base.LastException = null; return value; } catch (Exception lastException) { base.LastException = lastException; return null; } } protected override void TrySetValue(object value) { try { FieldInfo.SetValue(base.DeclaringInstance, value); } catch (Exception message) { ExplorerCore.LogWarning(message); } } } public class CacheKeyValuePair : CacheObjectBase { public int DictIndex; public object DictKey; public object DisplayedKey; public bool KeyInputWanted; public bool InspectWanted; public string KeyLabelText; public string KeyInputText; public string KeyInputTypeText; public float DesiredKeyWidth; public float DesiredValueWidth; public override bool ShouldAutoEvaluate => true; public override bool HasArguments => false; public override bool CanWrite => base.Owner.CanWrite; public void SetDictOwner(InteractiveDictionary dict, int index) { base.Owner = dict; DictIndex = index; } public void SetKey(object key) { DictKey = key; DisplayedKey = ReflectionExtensions.TryCast(key); Type type = DisplayedKey.GetType(); if (ParseUtility.CanParse(type)) { KeyInputWanted = true; KeyInputText = ParseUtility.ToStringForInput(DisplayedKey, type); KeyInputTypeText = SignatureHighlighter.Parse(type, false, (MemberInfo)null); } else { KeyInputWanted = false; InspectWanted = type != typeof(bool) && !type.IsEnum; KeyLabelText = ToStringUtility.ToStringWithType(DisplayedKey, type, true); } } public override void SetDataToCell(CacheObjectCell cell) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) base.SetDataToCell(cell); CacheKeyValuePairCell cacheKeyValuePairCell = cell as CacheKeyValuePairCell; cacheKeyValuePairCell.NameLabel.text = $"{DictIndex}:"; cacheKeyValuePairCell.HiddenNameLabel.Text = ""; ((Graphic)cacheKeyValuePairCell.Image).color = ((DictIndex % 2 == 0) ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor); if (KeyInputWanted) { ((UIModel)cacheKeyValuePairCell.KeyInputField).UIRoot.SetActive(true); ((Component)cacheKeyValuePairCell.KeyInputTypeLabel).gameObject.SetActive(true); ((Component)cacheKeyValuePairCell.KeyLabel).gameObject.SetActive(false); ((Component)cacheKeyValuePairCell.KeyInspectButton.Component).gameObject.SetActive(false); cacheKeyValuePairCell.KeyInputField.Text = KeyInputText; cacheKeyValuePairCell.KeyInputTypeLabel.text = KeyInputTypeText; } else { ((UIModel)cacheKeyValuePairCell.KeyInputField).UIRoot.SetActive(false); ((Component)cacheKeyValuePairCell.KeyInputTypeLabel).gameObject.SetActive(false); ((Component)cacheKeyValuePairCell.KeyLabel).gameObject.SetActive(true); ((Component)cacheKeyValuePairCell.KeyInspectButton.Component).gameObject.SetActive(InspectWanted); cacheKeyValuePairCell.KeyLabel.text = KeyLabelText; } } public override void TrySetUserValue(object value) { (base.Owner as InteractiveDictionary).TrySetValueToKey(DictKey, value, DictIndex); } protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell) { return true; } } public class CacheListEntry : CacheObjectBase { public int ListIndex; public override bool ShouldAutoEvaluate => true; public override bool HasArguments => false; public override bool CanWrite => base.Owner?.CanWrite ?? false; public void SetListOwner(InteractiveList list, int listIndex) { base.Owner = list; ListIndex = listIndex; } public override void SetDataToCell(CacheObjectCell cell) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) base.SetDataToCell(cell); CacheListEntryCell obj = cell as CacheListEntryCell; obj.NameLabel.text = $"{ListIndex}:"; obj.HiddenNameLabel.Text = ""; ((Graphic)obj.Image).color = ((ListIndex % 2 == 0) ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor); } public override void TrySetUserValue(object value) { (base.Owner as InteractiveList).TrySetValueToIndex(value, ListIndex); } protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell) { return true; } } public abstract class CacheMember : CacheObjectBase { private object m_declaringInstance; private static readonly Color evalEnabledColor = new Color(0.15f, 0.25f, 0.15f); private static readonly Color evalDisabledColor = new Color(0.15f, 0.15f, 0.15f); public abstract Type DeclaringType { get; } public string NameForFiltering { get; protected set; } public object DeclaringInstance { get { object obj; if (!IsStatic) { obj = m_declaringInstance; if (obj == null) { return m_declaringInstance = ReflectionExtensions.TryCast(base.Owner.Target, DeclaringType); } } else { obj = null; } return obj; } } public abstract bool IsStatic { get; } public override bool HasArguments { get { ParameterInfo[] arguments = Arguments; if (arguments == null || arguments.Length == 0) { return GenericArguments.Length != 0; } return true; } } public ParameterInfo[] Arguments { get; protected set; } = new ParameterInfo[0]; public Type[] GenericArguments { get; protected set; } = ArgumentUtility.EmptyTypes; public EvaluateWidget Evaluator { get; protected set; } public bool Evaluating { get { if (Evaluator != null) { return Evaluator.UIRoot.activeSelf; } return false; } } public virtual void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member) { base.Owner = inspector; string nameLabelText = ((this is CacheMethod) ? SignatureHighlighter.ParseMethod(member as MethodInfo) : ((!(this is CacheConstructor)) ? SignatureHighlighter.Parse(member.DeclaringType, false, member) : SignatureHighlighter.ParseConstructor(member as ConstructorInfo))); base.NameLabelText = nameLabelText; NameForFiltering = SignatureHighlighter.RemoveHighlighting(base.NameLabelText); base.NameLabelTextRaw = NameForFiltering; } public override void ReleasePooledObjects() { base.ReleasePooledObjects(); if (Evaluator != null) { Evaluator.OnReturnToPool(); Pool.Return(Evaluator); Evaluator = null; } } public override void UnlinkFromView() { if (Evaluator != null) { Evaluator.UIRoot.transform.SetParent(Pool.Instance.InactiveHolder.transform, false); } base.UnlinkFromView(); } protected abstract object TryEvaluate(); protected abstract void TrySetValue(object value); public void Evaluate() { SetValueFromSource(TryEvaluate()); } public void EvaluateAndSetCell() { Evaluate(); if (base.CellView != null) { SetDataToCell(base.CellView); } } public override void TrySetUserValue(object value) { TrySetValue(value); Evaluate(); } protected override void SetValueState(CacheObjectCell cell, ValueStateArgs args) { base.SetValueState(cell, args); } protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell objectcell) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) CacheMemberCell cacheMemberCell = objectcell as CacheMemberCell; cacheMemberCell.EvaluateHolder.SetActive(!ShouldAutoEvaluate); if (!ShouldAutoEvaluate) { ((Component)cacheMemberCell.EvaluateButton.Component).gameObject.SetActive(true); if (HasArguments) { if (!Evaluating) { cacheMemberCell.EvaluateButton.ButtonText.text = $"Evaluate ({Arguments.Length + GenericArguments.Length})"; } else { cacheMemberCell.EvaluateButton.ButtonText.text = "Hide"; Evaluator.UIRoot.transform.SetParent(cacheMemberCell.EvaluateHolder.transform, false); RuntimeHelper.SetColorBlock((Selectable)(object)cacheMemberCell.EvaluateButton.Component, (Color?)evalEnabledColor, (Color?)(evalEnabledColor * 1.3f), (Color?)null, (Color?)null); } } else { cacheMemberCell.EvaluateButton.ButtonText.text = "Evaluate"; } if (!Evaluating) { RuntimeHelper.SetColorBlock((Selectable)(object)cacheMemberCell.EvaluateButton.Component, (Color?)evalDisabledColor, (Color?)(evalDisabledColor * 1.3f), (Color?)null, (Color?)null); } } if (base.State == ValueState.NotEvaluated && !ShouldAutoEvaluate) { SetValueState(cacheMemberCell, ValueStateArgs.Default); cacheMemberCell.RefreshSubcontentButton(); return false; } if (base.State == ValueState.NotEvaluated) { Evaluate(); } return true; } public void OnEvaluateClicked() { if (!HasArguments) { EvaluateAndSetCell(); } else if (Evaluator == null) { Evaluator = Pool.Borrow(); Evaluator.OnBorrowedFromPool(this); Evaluator.UIRoot.transform.SetParent((base.CellView as CacheMemberCell).EvaluateHolder.transform, false); TryAutoEvaluateIfUnitialized(base.CellView); } else { if (Evaluator.UIRoot.activeSelf) { Evaluator.UIRoot.SetActive(false); } else { Evaluator.UIRoot.SetActive(true); } TryAutoEvaluateIfUnitialized(base.CellView); } } } public static class CacheMemberFactory { public static List GetCacheMembers(Type type, ReflectionInspector inspector) { HashSet cachedSigs = new HashSet(); List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); Type[] types = ReflectionUtility.GetAllBaseTypes(type); BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; if (!inspector.StaticOnly) { bindingFlags |= BindingFlags.Instance; } if (!type.IsAbstract) { ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); for (int i = 0; i < constructors.Length; i++) { TryCacheMember(constructors[i], list3, cachedSigs, type, inspector); } if (type.IsValueType) { CacheConstructor cacheConstructor = new CacheConstructor(type); cacheConstructor.SetFallbackType(type); cacheConstructor.SetInspectorOwner(inspector, null); list3.Add(cacheConstructor); } } Type[] array = types; foreach (Type type2 in array) { PropertyInfo[] properties = type2.GetProperties(bindingFlags); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.DeclaringType == type2) { TryCacheMember(propertyInfo, list, cachedSigs, type2, inspector); } } FieldInfo[] fields = type2.GetFields(bindingFlags); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.DeclaringType == type2) { TryCacheMember(fieldInfo, list2, cachedSigs, type2, inspector); } } MethodInfo[] methods = type2.GetMethods(bindingFlags); foreach (MethodInfo methodInfo in methods) { if (methodInfo.DeclaringType == type2) { TryCacheMember(methodInfo, list4, cachedSigs, type2, inspector); } } } List list5 = new List(); list5.AddRange(from it in list orderby Array.IndexOf(types, it.DeclaringType), it.NameForFiltering select it); list5.AddRange(from it in list2 orderby Array.IndexOf(types, it.DeclaringType), it.NameForFiltering select it); list5.AddRange(from it in list3 orderby Array.IndexOf(types, it.DeclaringType), it.NameForFiltering select it); list5.AddRange(from it in list4 orderby Array.IndexOf(types, it.DeclaringType), it.NameForFiltering select it); return list5; } private static void TryCacheMember(MemberInfo member, List list, HashSet cachedSigs, Type declaringType, ReflectionInspector inspector, bool ignorePropertyMethodInfos = true) where T : CacheMember { try { if (UERuntimeHelper.IsBlacklisted(member)) { return; } string text; if (!(member is MethodBase methodBase)) { if (!(member is PropertyInfo) && !(member is FieldInfo)) { throw new NotImplementedException(); } text = GeneralExtensions.FullDescription(member.DeclaringType) + "." + member.Name; } else { text = GeneralExtensions.FullDescription(methodBase); } string item = text; if (cachedSigs.Contains(item)) { return; } CacheMember cacheMember; Type fallbackType; switch (member.MemberType) { case MemberTypes.Constructor: { ConstructorInfo obj2 = member as ConstructorInfo; cacheMember = new CacheConstructor(obj2); fallbackType = obj2.DeclaringType; break; } case MemberTypes.Method: { MethodInfo methodInfo = member as MethodInfo; if (ignorePropertyMethodInfos && (methodInfo.Name.StartsWith("get_") || methodInfo.Name.StartsWith("set_"))) { return; } cacheMember = new CacheMethod(methodInfo); fallbackType = methodInfo.ReturnType; break; } case MemberTypes.Property: { PropertyInfo propertyInfo = member as PropertyInfo; if (!propertyInfo.CanRead && propertyInfo.CanWrite) { MethodInfo setMethod = propertyInfo.GetSetMethod(nonPublic: true); if (setMethod != null) { TryCacheMember(setMethod, list, cachedSigs, declaringType, inspector, ignorePropertyMethodInfos: false); } return; } cacheMember = new CacheProperty(propertyInfo); fallbackType = propertyInfo.PropertyType; break; } case MemberTypes.Field: { FieldInfo obj = member as FieldInfo; cacheMember = new CacheField(obj); fallbackType = obj.FieldType; break; } default: throw new NotImplementedException(); } cachedSigs.Add(item); cacheMember.SetFallbackType(fallbackType); cacheMember.SetInspectorOwner(inspector, member); list.Add((T)cacheMember); } catch (Exception message) { ExplorerCore.LogWarning("Exception caching member " + member.DeclaringType.FullName + "." + member.Name + "!"); ExplorerCore.Log(message); } } } public class CacheMethod : CacheMember { public MethodInfo MethodInfo { get; } public override Type DeclaringType => MethodInfo.DeclaringType; public override bool CanWrite => false; public override bool IsStatic => MethodInfo.IsStatic; public override bool ShouldAutoEvaluate => false; public CacheMethod(MethodInfo mi) { MethodInfo = mi; } public override void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member) { base.SetInspectorOwner(inspector, member); base.Arguments = MethodInfo.GetParameters(); if (MethodInfo.IsGenericMethod) { base.GenericArguments = MethodInfo.GetGenericArguments(); } } protected override object TryEvaluate() { try { MethodInfo methodInfo = MethodInfo; if (methodInfo.IsGenericMethod) { methodInfo = MethodInfo.MakeGenericMethod(base.Evaluator.TryParseGenericArguments()); } object result = ((!HasArguments) ? methodInfo.Invoke(base.DeclaringInstance, ArgumentUtility.EmptyArgs) : methodInfo.Invoke(base.DeclaringInstance, base.Evaluator.TryParseArguments())); base.LastException = null; return result; } catch (Exception lastException) { base.LastException = lastException; return null; } } protected override void TrySetValue(object value) { throw new NotImplementedException("You can't set a method"); } } public enum ValueState { NotEvaluated, Exception, Boolean, Number, String, Enum, Collection, Dictionary, ValueStruct, Color, Unsupported } public abstract class CacheObjectBase { public struct ValueStateArgs { public Color valueColor; public bool valueActive; public bool valueRichText; public bool typeLabelActive; public bool toggleActive; public bool inputActive; public bool applyActive; public bool inspectActive; public bool subContentButtonActive; public static ValueStateArgs Default { get; } = new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive: false, subContentButtonActive: false); public ValueStateArgs(bool valueActive = true, bool valueRichText = true, Color? valueColor = null, bool typeLabelActive = false, bool toggleActive = false, bool inputActive = false, bool applyActive = false, bool inspectActive = false, bool subContentButtonActive = false) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) this.valueActive = valueActive; this.valueRichText = valueRichText; this.valueColor = ((!valueColor.HasValue) ? Color.white : valueColor.Value); this.typeLabelActive = typeLabelActive; this.toggleActive = toggleActive; this.inputActive = inputActive; this.applyActive = applyActive; this.inspectActive = inspectActive; this.subContentButtonActive = subContentButtonActive; } } private bool valueIsNull; private Type currentValueType; private static GameObject inactiveIValueHolder; public ICacheObjectController Owner { get; set; } public CacheObjectCell CellView { get; internal set; } public object Value { get; protected set; } public Type FallbackType { get; protected set; } public ValueState State { get; set; } public Exception LastException { get; protected set; } public InteractiveValue IValue { get; private set; } public Type CurrentIValueType { get; private set; } public bool SubContentShowWanted { get; private set; } public string NameLabelText { get; protected set; } public string NameLabelTextRaw { get; protected set; } public string ValueLabelText { get; protected set; } public abstract bool ShouldAutoEvaluate { get; } public abstract bool HasArguments { get; } public abstract bool CanWrite { get; } protected virtual string NOT_YET_EVAL => "Not yet evaluated"; internal static GameObject InactiveIValueHolder { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)inactiveIValueHolder)) { inactiveIValueHolder = new GameObject("Temp_IValue_Holder"); Object.DontDestroyOnLoad((Object)(object)inactiveIValueHolder); ((Object)inactiveIValueHolder).hideFlags = (HideFlags)61; inactiveIValueHolder.transform.parent = UniversalUI.PoolHolder.transform; inactiveIValueHolder.SetActive(false); } return inactiveIValueHolder; } } public virtual void SetFallbackType(Type fallbackType) { FallbackType = fallbackType; ValueLabelText = GetValueLabel(); } public virtual void SetView(CacheObjectCell cellView) { CellView = cellView; cellView.Occupant = this; } public virtual void UnlinkFromView() { if (CellView != null) { CellView.Occupant = null; CellView = null; if (IValue != null) { IValue.UIRoot.transform.SetParent(InactiveIValueHolder.transform, false); } } } public virtual void ReleasePooledObjects() { if (IValue != null) { ReleaseIValue(); } if (CellView != null) { UnlinkFromView(); } } public virtual void SetValueFromSource(object value) { Value = value; if (!UnityHelpers.IsNullOrDestroyed(Value, true)) { Value = ReflectionExtensions.TryCast(Value); } ProcessOnEvaluate(); if (IValue != null) { if (SubContentShowWanted) { IValue.SetValue(Value); } else { IValue.PendingValueWanted = true; } } } public void SetUserValue(object value) { value = ReflectionExtensions.TryCast(value, FallbackType); TrySetUserValue(value); if (CellView != null) { SetDataToCell(CellView); } if (Owner.ParentCacheObject != null) { Owner.ParentCacheObject.SetUserValue(Owner.Target); } } public abstract void TrySetUserValue(object value); protected virtual void ProcessOnEvaluate() { ValueState state = State; if (LastException != null) { valueIsNull = true; currentValueType = FallbackType; State = ValueState.Exception; } else if (UnityHelpers.IsNullOrDestroyed(Value, true)) { valueIsNull = true; State = GetStateForType(FallbackType); } else { valueIsNull = false; State = GetStateForType(ReflectionExtensions.GetActualType(Value)); } if (IValue != null && (State != state || (State != ValueState.String && State != ValueState.Exception && UnityHelpers.IsNullOrDestroyed(Value, true)))) { ReleaseIValue(); SubContentShowWanted = false; } ValueLabelText = GetValueLabel(); } public ValueState GetStateForType(Type type) { if (currentValueType == type && (State != ValueState.Exception || LastException != null)) { return State; } currentValueType = type; if (type == typeof(bool)) { return ValueState.Boolean; } if (type.IsPrimitive || type == typeof(decimal)) { return ValueState.Number; } if (type == typeof(string)) { return ValueState.String; } if (type.IsEnum) { return ValueState.Enum; } if (type == typeof(Color) || type == typeof(Color32)) { return ValueState.Color; } if (InteractiveValueStruct.SupportsType(type)) { return ValueState.ValueStruct; } if (ReflectionUtility.IsDictionary(type)) { return ValueState.Dictionary; } if (!typeof(Transform).IsAssignableFrom(type) && ReflectionUtility.IsEnumerable(type)) { return ValueState.Collection; } return ValueState.Unsupported; } protected string GetValueLabel() { string text = string.Empty; switch (State) { case ValueState.NotEvaluated: return "" + NOT_YET_EVAL + " (" + SignatureHighlighter.Parse(FallbackType, true, (MemberInfo)null) + ")"; case ValueState.Exception: return "" + ReflectionExtensions.ReflectionExToString(LastException, true) + ""; case ValueState.Boolean: case ValueState.Number: return null; case ValueState.ValueStruct: if (ParseUtility.CanParse(currentValueType)) { return null; } break; case ValueState.String: if (!valueIsNull) { return "\"" + ToStringUtility.PruneString(Value as string, 200, 5) + "\""; } break; case ValueState.Collection: if (!valueIsNull) { text = ((Value is IList list) ? $"[{list.Count}] " : ((!(Value is ICollection collection)) ? "[?] " : $"[{collection.Count}] ")); } break; case ValueState.Dictionary: if (!valueIsNull) { text = ((!(Value is IDictionary dictionary)) ? "[?] " : $"[{dictionary.Count}] "); } break; } return text += ToStringUtility.ToStringWithType(Value, FallbackType, true); } protected abstract bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell); public virtual void SetDataToCell(CacheObjectCell cell) { //IL_01cd: Unknown result type (might be due to invalid IL or missing references) cell.NameLabel.text = NameLabelText; if (cell.HiddenNameLabel != null) { cell.HiddenNameLabel.Text = NameLabelTextRaw ?? string.Empty; } ((Component)cell.ValueLabel).gameObject.SetActive(true); cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted); if (IValue != null) { IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false); IValue.SetLayout(); } bool num = TryAutoEvaluateIfUnitialized(cell); if (cell.CopyButton != null) { bool flag = State != ValueState.NotEvaluated && State != ValueState.Exception; ((Component)cell.CopyButton.Component).gameObject.SetActive(flag); ((Component)cell.PasteButton.Component).gameObject.SetActive(flag && CanWrite); } if (!num) { return; } switch (State) { case ValueState.Exception: SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive: false, subContentButtonActive: true)); break; case ValueState.Boolean: { bool inspectActive2 = CanWrite; SetValueState(cell, new ValueStateArgs(valueActive: false, valueRichText: true, null, typeLabelActive: false, toggleActive: true, inputActive: false, inspectActive2)); break; } case ValueState.Number: { bool inspectActive2 = CanWrite; SetValueState(cell, new ValueStateArgs(valueActive: false, valueRichText: true, null, typeLabelActive: true, toggleActive: false, inputActive: true, inspectActive2)); break; } case ValueState.String: if (valueIsNull) { SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive: false, subContentButtonActive: true)); } else { SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: false, SignatureHighlighter.StringOrange, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive: false, subContentButtonActive: true)); } break; case ValueState.Enum: { bool inspectActive2 = CanWrite; SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive: false, inspectActive2)); break; } case ValueState.ValueStruct: case ValueState.Color: if (ParseUtility.CanParse(currentValueType)) { SetValueState(cell, new ValueStateArgs(valueActive: false, valueRichText: false, null, typeLabelActive: true, toggleActive: false, inputActive: true, CanWrite, inspectActive: true, subContentButtonActive: true)); } else { SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive: true, subContentButtonActive: true)); } break; case ValueState.Collection: case ValueState.Dictionary: { bool inspectActive2 = !valueIsNull; bool inspectActive = !valueIsNull; SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive2, inspectActive)); break; } case ValueState.Unsupported: { bool inspectActive = !valueIsNull; SetValueState(cell, new ValueStateArgs(valueActive: true, valueRichText: true, null, typeLabelActive: false, toggleActive: false, inputActive: false, applyActive: false, inspectActive)); break; } } cell.RefreshSubcontentButton(); } protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (args.valueActive) { cell.ValueLabel.text = ValueLabelText; cell.ValueLabel.supportRichText = args.valueRichText; ((Graphic)cell.ValueLabel).color = args.valueColor; } else { cell.ValueLabel.text = ""; } ((Component)cell.TypeLabel).gameObject.SetActive(args.typeLabelActive); if (args.typeLabelActive) { cell.TypeLabel.text = SignatureHighlighter.Parse(currentValueType, false, (MemberInfo)null); } ((Component)cell.Toggle).gameObject.SetActive(args.toggleActive); if (args.toggleActive) { ((Selectable)cell.Toggle).interactable = CanWrite; cell.Toggle.isOn = (bool)Value; cell.ToggleText.text = Value.ToString(); } ((UIModel)cell.InputField).UIRoot.SetActive(args.inputActive); if (args.inputActive) { cell.InputField.Text = ParseUtility.ToStringForInput(Value, currentValueType); cell.InputField.Component.readOnly = !CanWrite; } ((Component)cell.ApplyButton.Component).gameObject.SetActive(args.applyActive); if (cell.InspectButton != null) { ((Component)cell.InspectButton.Component).gameObject.SetActive(args.inspectActive && !valueIsNull); } ((Component)cell.SubContentButton.Component).gameObject.SetActive(args.subContentButtonActive && (!valueIsNull || State == ValueState.String || State == ValueState.Exception)); } public virtual void OnCellApplyClicked() { object userValue = default(object); Exception ex = default(Exception); if (State == ValueState.Boolean) { SetUserValue(CellView.Toggle.isOn); } else if (ParseUtility.TryParse(CellView.InputField.Text, currentValueType, ref userValue, ref ex)) { SetUserValue(userValue); } else { ExplorerCore.LogWarning("Unable to parse input!"); if (ex != null) { ExplorerCore.Log(ReflectionExtensions.ReflectionExToString(ex, true)); } } SetDataToCell(CellView); } public virtual void OnCellSubContentToggle() { if (IValue == null) { Type iValueTypeForState = InteractiveValue.GetIValueTypeForState(State); if (iValueTypeForState == null) { return; } IValue = (InteractiveValue)(object)Pool.Borrow(iValueTypeForState); CurrentIValueType = iValueTypeForState; IValue.OnBorrowed(this); IValue.SetValue(Value); IValue.UIRoot.transform.SetParent(CellView.SubContentHolder.transform, false); CellView.SubContentHolder.SetActive(true); SubContentShowWanted = true; ProcessOnEvaluate(); SetDataToCell(CellView); } else { SubContentShowWanted = !SubContentShowWanted; CellView.SubContentHolder.SetActive(SubContentShowWanted); if (SubContentShowWanted && IValue.PendingValueWanted) { IValue.PendingValueWanted = false; ProcessOnEvaluate(); SetDataToCell(CellView); IValue.SetValue(Value); } } CellView.RefreshSubcontentButton(); } public virtual void ReleaseIValue() { if (IValue != null) { IValue.ReleaseFromOwner(); Pool.Return(CurrentIValueType, (IPooledObject)(object)IValue); IValue = null; } } } public class CacheProperty : CacheMember { private bool? m_isStatic; private bool m_shouldAutoEvaluate; private string m_skipReason; public PropertyInfo PropertyInfo { get; internal set; } public override Type DeclaringType => PropertyInfo.DeclaringType; public override bool CanWrite => PropertyInfo.CanWrite; public override bool IsStatic { get { bool? isStatic = m_isStatic; if (!isStatic.HasValue) { bool? flag = (m_isStatic = PropertyInfo.GetAccessors(nonPublic: true)[0].IsStatic); return flag.Value; } return isStatic == true; } } protected override string NOT_YET_EVAL => m_skipReason ?? base.NOT_YET_EVAL; public override bool ShouldAutoEvaluate { get { if (HasArguments) { return false; } if (base.LastException != null) { return false; } return m_shouldAutoEvaluate; } } public CacheProperty(PropertyInfo pi) { PropertyInfo = pi; bool isPointer = PropertyInfo.PropertyType.IsPointer; if (PropertyInfo.IsDefined(typeof(ObsoleteAttribute), inherit: true)) { m_skipReason = "Skipped [Obsolete] attribute"; m_shouldAutoEvaluate = false; } else if (isPointer) { m_skipReason = "Skipped an Unmanaged Pointer"; m_shouldAutoEvaluate = false; } else { m_shouldAutoEvaluate = true; } } public override void SetInspectorOwner(ReflectionInspector inspector, MemberInfo member) { base.SetInspectorOwner(inspector, member); base.Arguments = PropertyInfo.GetIndexParameters(); } protected override object TryEvaluate() { try { object result = ((!HasArguments) ? PropertyInfo.GetValue(base.DeclaringInstance, null) : PropertyInfo.GetValue(base.DeclaringInstance, base.Evaluator.TryParseArguments())); base.LastException = null; return result; } catch (Exception lastException) { base.LastException = lastException; return null; } } protected override void TrySetValue(object value) { if (!CanWrite) { return; } try { _ = PropertyInfo.GetAccessors(nonPublic: true)[0].IsStatic; if (HasArguments) { PropertyInfo.SetValue(base.DeclaringInstance, value, base.Evaluator.TryParseArguments()); } else { PropertyInfo.SetValue(base.DeclaringInstance, value, null); } } catch (Exception message) { ExplorerCore.LogWarning(message); } } } public interface ICacheObjectController { CacheObjectBase ParentCacheObject { get; } object Target { get; } Type TargetType { get; } bool CanWrite { get; } } public static class CacheObjectControllerHelper { public static void SetCell(CacheObjectCell cell, int index, IList cachedEntries, Action onDataSetToCell) { if (index < 0 || index >= cachedEntries.Count) { if (cell.Occupant != null) { cell.Occupant.UnlinkFromView(); } cell.Disable(); return; } CacheObjectBase cacheObjectBase = (CacheObjectBase)cachedEntries[index]; if (cacheObjectBase.CellView != null && cacheObjectBase.CellView != cell) { cacheObjectBase.UnlinkFromView(); } if (cell.Occupant != null && cell.Occupant != cacheObjectBase) { cell.Occupant.UnlinkFromView(); } if (cacheObjectBase.CellView != cell) { cacheObjectBase.SetView(cell); } cacheObjectBase.SetDataToCell(cell); onDataSetToCell?.Invoke(cell); } } } namespace UnityExplorer.CacheObject.Views { public class ConfigEntryCell : CacheObjectCell { public override GameObject CreateContent(GameObject parent) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_06bd: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateUIObject(GetType().Name, parent, new Vector2(100f, 30f)); base.Rect = base.UIRoot.GetComponent(); UIFactory.SetLayoutGroup(base.UIRoot, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)4, (int?)4, (int?)4, (int?)4, (int?)4, (TextAnchor?)(TextAnchor)0); GameObject uIRoot = base.UIRoot; int? num = 100; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot, num, (int?)30, num2, (int?)600, (int?)null, (int?)null, (bool?)null); base.UIRoot.AddComponent().verticalFit = (FitMode)2; NameLabel = UIFactory.CreateLabel(base.UIRoot, "NameLabel", "", (TextAnchor)3, default(Color), true, 14); NameLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject = ((Component)NameLabel).gameObject; num2 = 25; int? num3 = 9999; int? num4 = 300; UIFactory.SetLayoutElement(gameObject, (int?)null, num2, num3, num4, (int?)null, (int?)null, (bool?)null); NameLayout = ((Component)NameLabel).GetComponent(); GameObject val = UIFactory.CreateUIObject("RightHoriGroup", base.UIRoot, default(Vector2)); bool? flag = false; bool? flag2 = false; bool? flag3 = true; bool? flag4 = true; int? num5 = 4; TextAnchor? val2 = (TextAnchor)0; UIFactory.SetLayoutGroup(val, flag, flag2, flag3, flag4, num5, (int?)null, (int?)null, (int?)null, (int?)null, val2); num4 = 25; UIFactory.SetLayoutElement(val, (int?)200, num4, (int?)9999, (int?)800, (int?)null, (int?)null, (bool?)null); SubContentButton = UIFactory.CreateButton(val, "SubContentButton", "▲", (Color?)subInactiveColor); UIFactory.SetLayoutElement(((Component)SubContentButton.Component).gameObject, (int?)25, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef subContentButton = SubContentButton; subContentButton.OnClick = (Action)System.Delegate.Combine(subContentButton.OnClick, new Action(SubContentClicked)); TypeLabel = UIFactory.CreateLabel(val, "TypeLabel", "", (TextAnchor)3, default(Color), true, 14); TypeLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject2 = ((Component)TypeLabel).gameObject; num4 = 25; num3 = 150; UIFactory.SetLayoutElement(gameObject2, (int?)60, num4, (int?)0, num3, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutElement(UIFactory.CreateToggle(val, "Toggle", ref Toggle, ref ToggleText, default(Color), 20, 20), (int?)70, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ((Graphic)ToggleText).color = SignatureHighlighter.KeywordBlue; ((UnityEvent)(object)Toggle.onValueChanged).AddListener((UnityAction)ToggleClicked); InputField = UIFactory.CreateInputField(val, "InputField", "..."); GameObject uIRoot2 = ((UIModel)InputField).UIRoot; int? num6 = 150; num3 = 0; UIFactory.SetLayoutElement(uIRoot2, num6, (int?)25, num3, (int?)0, (int?)null, (int?)null, (bool?)null); ApplyButton = UIFactory.CreateButton(val, "ApplyButton", "Apply", (Color?)new Color(0.15f, 0.19f, 0.15f)); UIFactory.SetLayoutElement(((Component)ApplyButton.Component).gameObject, (int?)70, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef applyButton = ApplyButton; applyButton.OnClick = (Action)System.Delegate.Combine(applyButton.OnClick, new Action(ApplyClicked)); ValueLabel = UIFactory.CreateLabel(val, "ValueLabel", "Value goes here", (TextAnchor)3, default(Color), true, 14); ValueLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject3 = ((Component)ValueLabel).gameObject; num3 = 25; num4 = 150; num2 = 9999; UIFactory.SetLayoutElement(gameObject3, (int?)null, num3, num2, num4, (int?)null, (int?)null, (bool?)null); SubContentHolder = UIFactory.CreateUIObject("SubContent", base.UIRoot, default(Vector2)); GameObject gameObject4 = SubContentHolder.gameObject; num2 = 30; num4 = 600; UIFactory.SetLayoutElement(gameObject4, (int?)100, num2, (int?)9999, num4, (int?)null, (int?)null, (bool?)null); GameObject subContentHolder = SubContentHolder; bool? flag5 = true; bool? flag6 = true; bool? flag7 = true; bool? flag8 = true; int? num7 = 2; val2 = (TextAnchor)0; UIFactory.SetLayoutGroup(subContentHolder, flag5, flag6, flag7, flag8, num7, (int?)null, (int?)null, (int?)null, (int?)null, val2); SubContentHolder.SetActive(false); GameObject obj = UIFactory.CreateUIObject("BottomSeperator", base.UIRoot, default(Vector2)); num4 = 1; num2 = 0; num3 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num4, num3, num2, (int?)null, (int?)null, (bool?)null); ((Graphic)obj.AddComponent()).color = Color.black; return base.UIRoot; } protected override void ConstructEvaluateHolder(GameObject parent) { } } public class CacheKeyValuePairCell : CacheObjectCell { public LayoutElement KeyGroupLayout; public Text KeyLabel; public ButtonRef KeyInspectButton; public InputFieldRef KeyInputField; public Text KeyInputTypeLabel; public static Color EvenColor = new Color(0.07f, 0.07f, 0.07f); public static Color OddColor = new Color(0.063f, 0.063f, 0.063f); public Image Image { get; private set; } public InteractiveDictionary DictOwner => base.Occupant.Owner as InteractiveDictionary; public int AdjustedWidth { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Rect rect = base.Rect.rect; return (int)((Rect)(ref rect)).width - 70; } } private void KeyInspectClicked() { InspectorManager.Inspect((base.Occupant as CacheKeyValuePair).DictKey, base.Occupant); } public override GameObject CreateContent(GameObject parent) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) GameObject val = base.CreateContent(parent); Image = val.AddComponent(); NameLayout.minWidth = 70f; NameLayout.flexibleWidth = 0f; NameLayout.minHeight = 30f; NameLayout.flexibleHeight = 0f; NameLabel.alignment = (TextAnchor)5; RightGroupLayout.minWidth = (float)AdjustedWidth * 0.55f; GameObject val2 = UIFactory.CreateUIObject("KeyHolder", ((Component)val.transform.Find("HoriGroup")).gameObject, default(Vector2)); UIFactory.SetLayoutGroup(val2, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)0, (int?)0, (int?)4, (int?)4, (TextAnchor?)(TextAnchor)3); int? num = 30; KeyGroupLayout = UIFactory.SetLayoutElement(val2, (int?)(int)((float)AdjustedWidth * 0.44f), num, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); val2.transform.SetSiblingIndex(1); KeyInspectButton = UIFactory.CreateButton(val2, "KeyInspectButton", "Inspect", (Color?)new Color(0.15f, 0.15f, 0.15f)); GameObject gameObject = ((Component)KeyInspectButton.Component).gameObject; int? num2 = 60; num = 0; UIFactory.SetLayoutElement(gameObject, num2, (int?)25, num, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef keyInspectButton = KeyInspectButton; keyInspectButton.OnClick = (Action)System.Delegate.Combine(keyInspectButton.OnClick, new Action(KeyInspectClicked)); KeyLabel = UIFactory.CreateLabel(val2, "KeyLabel", "empty", (TextAnchor)3, default(Color), true, 14); GameObject gameObject2 = ((Component)KeyLabel).gameObject; int? num3 = 50; num = 999; UIFactory.SetLayoutElement(gameObject2, num3, (int?)25, num, (int?)null, (int?)null, (int?)null, (bool?)null); KeyInputTypeLabel = UIFactory.CreateLabel(val2, "InputTypeLabel", "null", (TextAnchor)3, default(Color), true, 14); GameObject gameObject3 = ((Component)KeyInputTypeLabel).gameObject; int? num4 = 55; num = 0; UIFactory.SetLayoutElement(gameObject3, num4, (int?)25, num, (int?)0, (int?)null, (int?)null, (bool?)null); KeyInputField = UIFactory.CreateInputField(val2, "KeyInput", "empty"); GameObject uIRoot = ((UIModel)KeyInputField).UIRoot; num = 25; int? num5 = 0; int? num6 = 0; int? num7 = 200; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, num6, num5, num7, (int?)null, (bool?)null); KeyInputField.Component.readOnly = true; return val; } protected override void ConstructEvaluateHolder(GameObject parent) { } } public class CacheListEntryCell : CacheObjectCell { public static Color EvenColor = new Color(0.12f, 0.12f, 0.12f); public static Color OddColor = new Color(0.1f, 0.1f, 0.1f); public Image Image { get; private set; } public InteractiveList ListOwner => base.Occupant.Owner as InteractiveList; public override GameObject CreateContent(GameObject parent) { GameObject val = base.CreateContent(parent); Image = val.AddComponent(); NameLayout.minWidth = 40f; NameLayout.flexibleWidth = 50f; NameLayout.minHeight = 25f; NameLayout.flexibleHeight = 0f; NameLabel.alignment = (TextAnchor)5; return val; } protected override void ConstructEvaluateHolder(GameObject parent) { } } public class CacheMemberCell : CacheObjectCell { public GameObject EvaluateHolder; public ButtonRef EvaluateButton; public CacheMember MemberOccupant => base.Occupant as CacheMember; protected virtual void EvaluateClicked() { MemberOccupant.OnEvaluateClicked(); } protected override void ConstructEvaluateHolder(GameObject parent) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) EvaluateHolder = UIFactory.CreateUIObject("EvalGroup", parent, default(Vector2)); UIFactory.SetLayoutGroup(EvaluateHolder, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)3, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject evaluateHolder = EvaluateHolder; int? num = 25; int? num2 = 9999; int? num3 = 775; UIFactory.SetLayoutElement(evaluateHolder, (int?)null, num, num2, num3, (int?)null, (int?)null, (bool?)null); EvaluateButton = UIFactory.CreateButton(EvaluateHolder, "EvaluateButton", "Evaluate", (Color?)new Color(0.15f, 0.15f, 0.15f)); UIFactory.SetLayoutElement(((Component)EvaluateButton.Component).gameObject, (int?)100, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef evaluateButton = EvaluateButton; evaluateButton.OnClick = (Action)System.Delegate.Combine(evaluateButton.OnClick, new Action(EvaluateClicked)); } } public abstract class CacheObjectCell : ICell, IPooledObject { private bool m_enabled; public LayoutElement NameLayout; public GameObject RightGroupContent; public LayoutElement RightGroupLayout; public GameObject SubContentHolder; public Text NameLabel; public InputFieldRef HiddenNameLabel; public Text TypeLabel; public Text ValueLabel; public Toggle Toggle; public Text ToggleText; public InputFieldRef InputField; public ButtonRef InspectButton; public ButtonRef SubContentButton; public ButtonRef ApplyButton; public ButtonRef CopyButton; public ButtonRef PasteButton; public readonly Color subInactiveColor = new Color(0.23f, 0.23f, 0.23f); public readonly Color subActiveColor = new Color(0.23f, 0.33f, 0.23f); public float DefaultHeight => 30f; public GameObject UIRoot { get; set; } public bool Enabled => m_enabled; public RectTransform Rect { get; set; } public CacheObjectBase Occupant { get; set; } public bool SubContentActive => SubContentHolder.activeSelf; public void Disable() { m_enabled = false; UIRoot.SetActive(false); } public void Enable() { m_enabled = true; UIRoot.SetActive(true); } protected virtual void ApplyClicked() { Occupant.OnCellApplyClicked(); } protected virtual void InspectClicked() { InspectorManager.Inspect(Occupant.Value, Occupant); } protected virtual void ToggleClicked(bool value) { ToggleText.text = value.ToString(); } protected virtual void SubContentClicked() { Occupant.OnCellSubContentToggle(); } protected virtual void OnCopyClicked() { ClipboardPanel.Copy(Occupant.Value); } protected virtual void OnPasteClicked() { if (ClipboardPanel.TryPaste(Occupant.FallbackType, out var paste)) { Occupant.SetUserValue(paste); } } public void RefreshSubcontentButton() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) SubContentButton.ButtonText.text = (SubContentHolder.activeSelf ? "▼" : "▲"); Color val = (SubContentHolder.activeSelf ? subActiveColor : subInactiveColor); RuntimeHelper.SetColorBlock((Selectable)(object)SubContentButton.Component, (Color?)val, (Color?)(val * 1.3f), (Color?)null, (Color?)null); } protected abstract void ConstructEvaluateHolder(GameObject parent); public virtual GameObject CreateContent(GameObject parent) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_08dc: Unknown result type (might be due to invalid IL or missing references) //IL_08e2: Unknown result type (might be due to invalid IL or missing references) //IL_098d: Unknown result type (might be due to invalid IL or missing references) //IL_0993: Unknown result type (might be due to invalid IL or missing references) //IL_0995: Unknown result type (might be due to invalid IL or missing references) //IL_0a08: Unknown result type (might be due to invalid IL or missing references) //IL_0a7d: Unknown result type (might be due to invalid IL or missing references) //IL_0ae1: Unknown result type (might be due to invalid IL or missing references) //IL_0b56: Unknown result type (might be due to invalid IL or missing references) //IL_0ba8: Unknown result type (might be due to invalid IL or missing references) //IL_0bae: Unknown result type (might be due to invalid IL or missing references) //IL_0c87: Unknown result type (might be due to invalid IL or missing references) //IL_0c8d: Unknown result type (might be due to invalid IL or missing references) //IL_0cea: Unknown result type (might be due to invalid IL or missing references) UIRoot = UIFactory.CreateUIObject(GetType().Name, parent, new Vector2(100f, 30f)); Rect = UIRoot.GetComponent(); GameObject uIRoot = UIRoot; bool? flag = false; bool? flag2 = false; bool? flag3 = true; bool? flag4 = true; TextAnchor? val = (TextAnchor)0; UIFactory.SetLayoutGroup(uIRoot, flag, flag2, flag3, flag4, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, val); GameObject uIRoot2 = UIRoot; int? num = 100; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot2, num, (int?)30, num2, (int?)600, (int?)null, (int?)null, (bool?)null); UIRoot.AddComponent().verticalFit = (FitMode)2; GameObject val2 = UIFactory.CreateUIObject("HoriGroup", UIRoot, default(Vector2)); num2 = 29; int? num3 = 150; int? num4 = 9999; UIFactory.SetLayoutElement(val2, (int?)null, num2, num4, num3, (int?)null, (int?)null, (bool?)null); bool? flag5 = false; bool? flag6 = false; bool? flag7 = true; bool? flag8 = true; int? num5 = 5; int? num6 = 2; val = (TextAnchor)0; UIFactory.SetLayoutGroup(val2, flag5, flag6, flag7, flag8, num5, num6, (int?)null, (int?)null, (int?)null, val); val2.AddComponent().verticalFit = (FitMode)2; Color val3 = default(Color); NameLabel = UIFactory.CreateLabel(val2, "NameLabel", "", (TextAnchor)3, val3, true, 14); NameLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject = ((Component)NameLabel).gameObject; num4 = 25; int? num7 = 20; int? num8 = num4; num3 = 300; NameLayout = UIFactory.SetLayoutElement(gameObject, num7, num8, (int?)0, num3, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(((Component)NameLabel).gameObject, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); HiddenNameLabel = UIFactory.CreateInputField(((Component)NameLabel).gameObject, "HiddenNameLabel", ""); RectTransform component = ((Component)HiddenNameLabel.Component).GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; HiddenNameLabel.Component.readOnly = true; HiddenNameLabel.Component.lineType = (LineType)2; HiddenNameLabel.Component.textComponent.horizontalOverflow = (HorizontalWrapMode)0; ((Graphic)((Component)HiddenNameLabel.Component).gameObject.GetComponent()).color = Color.clear; ((Graphic)HiddenNameLabel.Component.textComponent).color = Color.clear; GameObject gameObject2 = ((Component)HiddenNameLabel.Component).gameObject; num3 = 25; int? num9 = 20; int? num10 = num3; num4 = 300; UIFactory.SetLayoutElement(gameObject2, num9, num10, (int?)0, num4, (int?)null, (int?)null, (bool?)null); RightGroupContent = UIFactory.CreateUIObject("RightGroup", val2, default(Vector2)); GameObject rightGroupContent = RightGroupContent; bool? flag9 = false; bool? flag10 = false; bool? flag11 = true; bool? flag12 = true; int? num11 = 4; val = (TextAnchor)0; UIFactory.SetLayoutGroup(rightGroupContent, flag9, flag10, flag11, flag12, num11, (int?)null, (int?)null, (int?)null, (int?)null, val); GameObject rightGroupContent2 = RightGroupContent; num4 = 25; UIFactory.SetLayoutElement(rightGroupContent2, (int?)200, num4, (int?)9999, (int?)800, (int?)null, (int?)null, (bool?)null); RightGroupLayout = RightGroupContent.GetComponent(); ConstructEvaluateHolder(RightGroupContent); GameObject val4 = UIFactory.CreateUIObject("RightHoriGroup", RightGroupContent, default(Vector2)); bool? flag13 = false; bool? flag14 = false; bool? flag15 = true; bool? flag16 = true; int? num12 = 4; val = (TextAnchor)0; UIFactory.SetLayoutGroup(val4, flag13, flag14, flag15, flag16, num12, (int?)null, (int?)null, (int?)null, (int?)null, val); num4 = 25; UIFactory.SetLayoutElement(val4, (int?)200, num4, (int?)9999, (int?)800, (int?)null, (int?)null, (bool?)null); SubContentButton = UIFactory.CreateButton(val4, "SubContentButton", "▲", (Color?)subInactiveColor); UIFactory.SetLayoutElement(((Component)SubContentButton.Component).gameObject, (int?)25, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef subContentButton = SubContentButton; subContentButton.OnClick = (Action)System.Delegate.Combine(subContentButton.OnClick, new Action(SubContentClicked)); val3 = default(Color); TypeLabel = UIFactory.CreateLabel(val4, "ReturnLabel", "", (TextAnchor)3, val3, true, 14); TypeLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject3 = ((Component)TypeLabel).gameObject; num4 = 25; num3 = 150; UIFactory.SetLayoutElement(gameObject3, (int?)45, num4, (int?)0, num3, (int?)null, (int?)null, (bool?)null); ref Toggle toggle = ref Toggle; ref Text toggleText = ref ToggleText; val3 = default(Color); UIFactory.SetLayoutElement(UIFactory.CreateToggle(val4, "Toggle", ref toggle, ref toggleText, val3, 20, 20), (int?)70, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ((Graphic)ToggleText).color = SignatureHighlighter.KeywordBlue; ((UnityEvent)(object)Toggle.onValueChanged).AddListener((UnityAction)ToggleClicked); InputField = UIFactory.CreateInputField(val4, "InputField", "..."); GameObject uIRoot3 = ((UIModel)InputField).UIRoot; int? num13 = 150; num3 = 0; UIFactory.SetLayoutElement(uIRoot3, num13, (int?)25, num3, (int?)0, (int?)null, (int?)null, (bool?)null); ApplyButton = UIFactory.CreateButton(val4, "ApplyButton", "Apply", (Color?)new Color(0.15f, 0.19f, 0.15f)); UIFactory.SetLayoutElement(((Component)ApplyButton.Component).gameObject, (int?)70, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef applyButton = ApplyButton; applyButton.OnClick = (Action)System.Delegate.Combine(applyButton.OnClick, new Action(ApplyClicked)); InspectButton = UIFactory.CreateButton(val4, "InspectButton", "Inspect", (Color?)new Color(0.15f, 0.15f, 0.15f)); GameObject gameObject4 = ((Component)InspectButton.Component).gameObject; int? num14 = 70; num3 = 0; UIFactory.SetLayoutElement(gameObject4, num14, (int?)25, num3, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef inspectButton = InspectButton; inspectButton.OnClick = (Action)System.Delegate.Combine(inspectButton.OnClick, new Action(InspectClicked)); val3 = default(Color); ValueLabel = UIFactory.CreateLabel(val4, "ValueLabel", "Value goes here", (TextAnchor)3, val3, true, 14); ValueLabel.horizontalOverflow = (HorizontalWrapMode)0; GameObject gameObject5 = ((Component)ValueLabel).gameObject; num3 = 25; num4 = 150; num2 = 9999; UIFactory.SetLayoutElement(gameObject5, (int?)null, num3, num2, num4, (int?)null, (int?)null, (bool?)null); ((Color)(ref val3))..ctor(1f, 1f, 1f, 0f); val = (TextAnchor)3; GameObject val5 = UIFactory.CreateHorizontalGroup(val4, "CopyPasteButtons", false, false, true, true, 4, default(Vector4), val3, val); int? num15 = 60; num2 = 0; UIFactory.SetLayoutElement(val5, num15, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); CopyButton = UIFactory.CreateButton(val5, "CopyButton", "Copy", (Color?)new Color(0.13f, 0.13f, 0.13f, 1f)); GameObject gameObject6 = ((Component)CopyButton.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject6, (int?)28, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)CopyButton.ButtonText).color = Color.yellow; CopyButton.ButtonText.fontSize = 10; ButtonRef copyButton = CopyButton; copyButton.OnClick = (Action)System.Delegate.Combine(copyButton.OnClick, new Action(OnCopyClicked)); PasteButton = UIFactory.CreateButton(val5, "PasteButton", "Paste", (Color?)new Color(0.13f, 0.13f, 0.13f, 1f)); GameObject gameObject7 = ((Component)PasteButton.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject7, (int?)28, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); ((Graphic)PasteButton.ButtonText).color = Color.green; PasteButton.ButtonText.fontSize = 10; ButtonRef pasteButton = PasteButton; pasteButton.OnClick = (Action)System.Delegate.Combine(pasteButton.OnClick, new Action(OnPasteClicked)); SubContentHolder = UIFactory.CreateUIObject("SubContent", UIRoot, default(Vector2)); GameObject gameObject8 = SubContentHolder.gameObject; num2 = 30; num4 = 600; UIFactory.SetLayoutElement(gameObject8, (int?)100, num2, (int?)9999, num4, (int?)null, (int?)null, (bool?)null); GameObject subContentHolder = SubContentHolder; bool? flag17 = true; bool? flag18 = true; bool? flag19 = true; bool? flag20 = true; int? num16 = 2; val = (TextAnchor)0; UIFactory.SetLayoutGroup(subContentHolder, flag17, flag18, flag19, flag20, num16, (int?)null, (int?)null, (int?)null, (int?)null, val); SubContentHolder.SetActive(false); GameObject obj = UIFactory.CreateUIObject("BottomSeperator", UIRoot, default(Vector2)); num4 = 1; num2 = 0; num3 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num4, num3, num2, (int?)null, (int?)null, (bool?)null); ((Graphic)obj.AddComponent()).color = Color.black; return UIRoot; } } } namespace UnityExplorer.CacheObject.IValues { public class InteractiveColor : InteractiveValue { public bool IsValueColor32; public Color EditedColor; private Image colorImage; private readonly InputFieldRef[] inputs = (InputFieldRef[])(object)new InputFieldRef[4]; private readonly Slider[] sliders = (Slider[])(object)new Slider[4]; private ButtonRef applyButton; private static readonly string[] fieldNames = new string[4] { "R", "G", "B", "A" }; public override void OnBorrowed(CacheObjectBase owner) { base.OnBorrowed(owner); ((Component)applyButton.Component).gameObject.SetActive(owner.CanWrite); Slider[] array = sliders; for (int i = 0; i < array.Length; i++) { ((Selectable)array[i]).interactable = owner.CanWrite; } InputFieldRef[] array2 = inputs; for (int i = 0; i < array2.Length; i++) { array2[i].Component.readOnly = !owner.CanWrite; } } public override void SetValue(object value) { OnOwnerSetValue(value); } private void OnOwnerSetValue(object value) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) if (value is Color32 val) { IsValueColor32 = true; EditedColor = Color32.op_Implicit(val); inputs[0].Text = val.r.ToString(); inputs[1].Text = val.g.ToString(); inputs[2].Text = val.b.ToString(); inputs[3].Text = val.a.ToString(); Slider[] array = sliders; for (int i = 0; i < array.Length; i++) { array[i].maxValue = 255f; } } else { IsValueColor32 = false; EditedColor = (Color)value; inputs[0].Text = EditedColor.r.ToString(); inputs[1].Text = EditedColor.g.ToString(); inputs[2].Text = EditedColor.b.ToString(); inputs[3].Text = EditedColor.a.ToString(); Slider[] array = sliders; for (int i = 0; i < array.Length; i++) { array[i].maxValue = 1f; } } if (Object.op_Implicit((Object)(object)colorImage)) { ((Graphic)colorImage).color = EditedColor; } } public void SetValueToOwner() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (IsValueColor32) { base.CurrentOwner.SetUserValue(Color32.op_Implicit(EditedColor)); } else { base.CurrentOwner.SetUserValue(EditedColor); } } private void SetColorField(float val, int fieldIndex) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) switch (fieldIndex) { case 0: EditedColor.r = val; break; case 1: EditedColor.g = val; break; case 2: EditedColor.b = val; break; case 3: EditedColor.a = val; break; } if (Object.op_Implicit((Object)(object)colorImage)) { ((Graphic)colorImage).color = EditedColor; } } private void OnInputChanged(string val, int fieldIndex) { try { float num; if (IsValueColor32) { byte b = byte.Parse(val); sliders[fieldIndex].value = (int)b; num = (float)((decimal)b / 255m); } else { num = float.Parse(val); sliders[fieldIndex].value = num; } SetColorField(num, fieldIndex); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } catch (Exception ex4) { ExplorerCore.LogWarning("InteractiveColor OnInput: " + ex4.ToString()); } } private void OnSliderValueChanged(float val, int fieldIndex) { try { if (IsValueColor32) { inputs[fieldIndex].Text = ((byte)val).ToString(); val /= 255f; } else { inputs[fieldIndex].Text = val.ToString(); } SetColorField(val, fieldIndex); } catch (Exception ex) { ExplorerCore.LogWarning("InteractiveColor OnSlider: " + ex.ToString()); } } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveColor", false, false, true, true, 3, new Vector4(4f, 4f, 4f, 4f), new Color(0.06f, 0.06f, 0.06f), (TextAnchor?)null); GameObject val = UIFactory.CreateHorizontalGroup(base.UIRoot, "ColorEditor", false, false, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)(TextAnchor)3); GameObject val2 = UIFactory.CreateGridGroup(val, "Grid", new Vector2(140f, 25f), new Vector2(2f, 2f), new Color(1f, 1f, 1f, 0f)); UIFactory.SetLayoutElement(val2, (int?)580, (int?)25, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); for (int i = 0; i < 4; i++) { AddEditorRow(i, val2); } applyButton = UIFactory.CreateButton(val, "ApplyButton", "Apply", (Color?)new Color(0.2f, 0.26f, 0.2f)); GameObject gameObject = ((Component)applyButton.Component).gameObject; int? num = 25; UIFactory.SetLayoutElement(gameObject, (int?)90, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = applyButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(SetValueToOwner)); GameObject val3 = UIFactory.CreateUIObject("ColorImageHelper", val, default(Vector2)); num = 25; UIFactory.SetLayoutElement(val3, (int?)50, num, (int?)50, (int?)null, (int?)null, (int?)null, (bool?)null); colorImage = val3.AddComponent(); return base.UIRoot; } internal void AddEditorRow(int index, GameObject groupObj) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UIFactory.CreateHorizontalGroup(groupObj, "EditorRow_" + fieldNames[index], false, true, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(obj, "RowLabel", fieldNames[index] + ":", (TextAnchor)5, Color.cyan, true, 14)).gameObject; int? num = 17; int? num2 = 0; UIFactory.SetLayoutElement(gameObject, num, (int?)25, num2, (int?)null, (int?)null, (int?)null, (bool?)null); InputFieldRef val = UIFactory.CreateInputField(obj, "Input", "..."); GameObject uIRoot = ((UIModel)val).UIRoot; int? num3 = 40; int? num4 = 25; num2 = 0; UIFactory.SetLayoutElement(uIRoot, num3, num4, (int?)null, num2, (int?)null, (int?)null, (bool?)null); inputs[index] = val; val.OnValueChanged += delegate(string val3) { OnInputChanged(val3, index); }; Slider val2 = default(Slider); GameObject obj2 = UIFactory.CreateSlider(obj, "Slider", ref val2); sliders[index] = val2; num2 = 25; UIFactory.SetLayoutElement(obj2, (int?)70, num2, (int?)999, (int?)0, (int?)null, (int?)null, (bool?)null); val2.minValue = 0f; val2.maxValue = 1f; ((UnityEvent)(object)val2.onValueChanged).AddListener((UnityAction)delegate(float val3) { OnSliderValueChanged(val3, index); }); } } public class InteractiveDictionary : InteractiveValue, ICellPoolDataSource, ICacheObjectController { public Type KeysType; public Type ValuesType; public IDictionary RefIDictionary; private readonly List cachedEntries = new List(); private Text NotSupportedLabel; public Text TopLabel; public LayoutElement KeyTitleLayout; public LayoutElement ValueTitleLayout; private LayoutElement scrollLayout; private RectTransform UIRect; CacheObjectBase ICacheObjectController.ParentCacheObject => base.CurrentOwner; object ICacheObjectController.Target => base.CurrentOwner.Value; public Type TargetType { get; private set; } public override bool CanWrite { get { if (base.CanWrite && RefIDictionary != null) { return !RefIDictionary.IsReadOnly; } return false; } } public int ItemCount => cachedEntries.Count; public ScrollPool DictScrollPool { get; private set; } public int AdjustedWidth { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Rect rect = UIRect.rect; return (int)((Rect)(ref rect)).width - 80; } } public override void OnBorrowed(CacheObjectBase owner) { base.OnBorrowed(owner); DictScrollPool.Refresh(true, true); } public override void ReleaseFromOwner() { base.ReleaseFromOwner(); ClearAndRelease(); } private void ClearAndRelease() { RefIDictionary = null; foreach (CacheKeyValuePair cachedEntry in cachedEntries) { cachedEntry.UnlinkFromView(); cachedEntry.ReleasePooledObjects(); } cachedEntries.Clear(); } public override void SetValue(object value) { if (value == null) { ClearAndRelease(); return; } Type actualType = ReflectionExtensions.GetActualType(value); ReflectionUtility.TryGetEntryTypes(actualType, ref KeysType, ref ValuesType); CacheEntries(value); TopLabel.text = $"[{cachedEntries.Count}] {SignatureHighlighter.Parse(actualType, false, (MemberInfo)null)}"; DictScrollPool.Refresh(true, false); } private void CacheEntries(object value) { RefIDictionary = value as IDictionary; IEnumerator enumerator = default(IEnumerator); if (ReflectionUtility.TryGetDictEnumerator(value, ref enumerator)) { ((Component)NotSupportedLabel).gameObject.SetActive(false); int num = 0; while (enumerator.MoveNext()) { CacheKeyValuePair cacheKeyValuePair; if (num >= cachedEntries.Count) { cacheKeyValuePair = new CacheKeyValuePair(); cacheKeyValuePair.SetDictOwner(this, num); cachedEntries.Add(cacheKeyValuePair); } else { cacheKeyValuePair = cachedEntries[num]; } cacheKeyValuePair.SetFallbackType(ValuesType); cacheKeyValuePair.SetKey(enumerator.Current.Key); cacheKeyValuePair.SetValueFromSource(enumerator.Current.Value); num++; } if (cachedEntries.Count <= num) { return; } for (int num2 = cachedEntries.Count - 1; num2 >= num; num2--) { CacheKeyValuePair cacheKeyValuePair2 = cachedEntries[num2]; if (cacheKeyValuePair2.CellView != null) { cacheKeyValuePair2.UnlinkFromView(); } cacheKeyValuePair2.ReleasePooledObjects(); cachedEntries.RemoveAt(num2); } } else { ((Component)NotSupportedLabel).gameObject.SetActive(true); } } public void TrySetValueToKey(object key, object value, int keyIndex) { try { if (!RefIDictionary.Contains(key)) { ExplorerCore.LogWarning("Unable to set key! Key may have been boxed to/from Il2Cpp Object."); return; } RefIDictionary[key] = value; CacheKeyValuePair cacheKeyValuePair = cachedEntries[keyIndex]; cacheKeyValuePair.SetValueFromSource(value); if (cacheKeyValuePair.CellView != null) { cacheKeyValuePair.SetDataToCell(cacheKeyValuePair.CellView); } } catch (Exception arg) { ExplorerCore.LogWarning($"Exception setting IDictionary key! {arg}"); } } public void OnCellBorrowed(CacheKeyValuePairCell cell) { } public void SetCell(CacheKeyValuePairCell cell, int index) { CacheObjectControllerHelper.SetCell(cell, index, cachedEntries, SetCellLayout); } public override void SetLayout() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) float num = 5f; KeyTitleLayout.minWidth = (float)AdjustedWidth * 0.44f; ValueTitleLayout.minWidth = (float)AdjustedWidth * 0.55f; foreach (CacheKeyValuePairCell item in DictScrollPool.CellPool) { SetCellLayout(item); if (item.Enabled) { float num2 = num; Rect rect = item.Rect.rect; num = num2 + ((Rect)(ref rect)).height; } } scrollLayout.minHeight = Math.Min(InspectorPanel.CurrentPanelHeight - 400f, num); } private void SetCellLayout(CacheObjectCell objcell) { CacheKeyValuePairCell cacheKeyValuePairCell = objcell as CacheKeyValuePairCell; cacheKeyValuePairCell.KeyGroupLayout.minWidth = (float)cacheKeyValuePairCell.AdjustedWidth * 0.44f; cacheKeyValuePairCell.RightGroupLayout.minWidth = (float)cacheKeyValuePairCell.AdjustedWidth * 0.55f; if (cacheKeyValuePairCell.Occupant?.IValue != null) { cacheKeyValuePairCell.Occupant.IValue.SetLayout(); } } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveDict", true, true, true, true, 6, new Vector4(10f, 3f, 15f, 4f), new Color(0.05f, 0.05f, 0.05f), (TextAnchor?)null); GameObject uIRoot = base.UIRoot; int? num = 9999; int? num2 = 25; int? num3 = 475; UIFactory.SetLayoutElement(uIRoot, (int?)null, num2, num, num3, (int?)null, (int?)null, (bool?)null); base.UIRoot.AddComponent().verticalFit = (FitMode)2; UIRect = base.UIRoot.GetComponent(); TopLabel = UIFactory.CreateLabel(base.UIRoot, "EntryLabel", "not set", (TextAnchor)3, default(Color), true, 16); TopLabel.horizontalOverflow = (HorizontalWrapMode)1; GameObject obj = UIFactory.CreateUIObject("TitleGroup", base.UIRoot, default(Vector2)); num3 = 25; num2 = 9999; num = 0; UIFactory.SetLayoutElement(obj, (int?)null, num3, num2, num, (int?)null, (int?)null, (bool?)null); bool? flag = false; bool? flag2 = true; bool? flag3 = true; bool? flag4 = true; num = 65; num2 = 0; TextAnchor? val = (TextAnchor)6; UIFactory.SetLayoutGroup(obj, flag, flag2, flag3, flag4, (int?)null, (int?)null, (int?)null, num, num2, val); Text val2 = UIFactory.CreateLabel(obj, "KeyTitle", "Keys", (TextAnchor)3, default(Color), true, 14); GameObject gameObject = ((Component)val2).gameObject; int? num4 = 100; num2 = 0; UIFactory.SetLayoutElement(gameObject, num4, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); KeyTitleLayout = ((Component)val2).GetComponent(); Text val3 = UIFactory.CreateLabel(obj, "ValueTitle", "Values", (TextAnchor)3, default(Color), true, 14); GameObject gameObject2 = ((Component)val3).gameObject; int? num5 = 100; num2 = 0; UIFactory.SetLayoutElement(gameObject2, num5, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null); ValueTitleLayout = ((Component)val3).GetComponent(); GameObject val4 = default(GameObject); GameObject val5 = default(GameObject); DictScrollPool = UIFactory.CreateScrollPool(base.UIRoot, "EntryList", ref val4, ref val5, (Color?)new Color(0.09f, 0.09f, 0.09f)); GameObject obj2 = val4; num2 = 150; num = 0; UIFactory.SetLayoutElement(obj2, (int?)null, num2, (int?)null, num, (int?)null, (int?)null, (bool?)null); DictScrollPool.Initialize((ICellPoolDataSource)this, (Action)SetLayout); scrollLayout = val4.GetComponent(); NotSupportedLabel = UIFactory.CreateLabel(((Component)DictScrollPool.Content).gameObject, "NotSupportedMessage", "The IDictionary failed to enumerate. This is likely due to an issue with Unhollowed interfaces.", (TextAnchor)3, Color.red, true, 14); GameObject gameObject3 = ((Component)NotSupportedLabel).gameObject; num = 25; num2 = 9999; UIFactory.SetLayoutElement(gameObject3, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); ((Component)NotSupportedLabel).gameObject.SetActive(false); return base.UIRoot; } } public class InteractiveEnum : InteractiveValue { public bool IsFlags; public Type EnumType; private Type lastType; public OrderedDictionary CurrentValues; private InputFieldRef inputField; private ButtonRef enumHelperButton; private EnumCompleter enumCompleter; private GameObject toggleHolder; private readonly List flagToggles = new List(); private readonly List flagTexts = new List(); internal static readonly Dictionary enumCache = new Dictionary(); public CachedEnumValue ValueAtIndex(int idx) { return (CachedEnumValue)CurrentValues[idx]; } public CachedEnumValue ValueAtKey(object key) { return (CachedEnumValue)CurrentValues[key]; } public override void SetValue(object value) { EnumType = value.GetType(); if (lastType != EnumType) { CurrentValues = GetEnumValues(EnumType); IsFlags = EnumType.GetCustomAttributes(typeof(FlagsAttribute), inherit: true)?.Any() ?? false; if (IsFlags) { SetupTogglesForEnumType(); } else { ((Component)inputField.Component).gameObject.SetActive(true); ((Component)enumHelperButton.Component).gameObject.SetActive(true); toggleHolder.SetActive(false); } enumCompleter.EnumType = EnumType; enumCompleter.CacheEnumValues(); lastType = EnumType; } if (!IsFlags) { inputField.Text = value.ToString(); } else { SetTogglesForValue(value); } enumCompleter.chosenSuggestion = value.ToString(); AutoCompleteModal.Instance.ReleaseOwnership(enumCompleter); } private void SetTogglesForValue(object value) { try { for (int i = 0; i < CurrentValues.Count; i++) { flagToggles[i].isOn = (value as System.Enum).HasFlag(ValueAtIndex(i).ActualValue as System.Enum); } } catch (Exception ex) { ExplorerCore.LogWarning("Exception setting flag toggles: " + ex); } } private void OnApplyClicked() { try { if (!IsFlags) { object userValue = default(object); Exception ex = default(Exception); if (!ParseUtility.TryParse(inputField.Text, EnumType, ref userValue, ref ex)) { throw ex; } base.CurrentOwner.SetUserValue(userValue); } else { SetValueFromFlags(); } } catch (Exception ex2) { ExplorerCore.LogWarning("Exception setting from dropdown: " + ex2); } } private void SetValueFromFlags() { try { List list = new List(); for (int i = 0; i < CurrentValues.Count; i++) { if (flagToggles[i].isOn) { list.Add(ValueAtIndex(i).Name); } } base.CurrentOwner.SetUserValue(System.Enum.Parse(EnumType, string.Join(", ", list.ToArray()))); } catch (Exception ex) { ExplorerCore.LogWarning("Exception setting from flag toggles: " + ex); } } private void EnumHelper_OnClick() { enumCompleter.HelperButtonClicked(); } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveEnum", false, false, true, true, 3, new Vector4(4f, 4f, 4f, 4f), new Color(0.06f, 0.06f, 0.06f), (TextAnchor?)null); GameObject uIRoot = base.UIRoot; int? num = 25; int? num2 = 9999; int? num3 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null); GameObject val = UIFactory.CreateUIObject("Hori", base.UIRoot, default(Vector2)); num3 = 25; num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num3, num2, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); ButtonRef obj = UIFactory.CreateButton(val, "ApplyButton", "Apply", (Color?)new Color(0.2f, 0.27f, 0.2f)); GameObject gameObject = ((Component)obj.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)100, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnApplyClicked)); inputField = UIFactory.CreateInputField(val, "InputField", "Enter name or underlying value..."); GameObject uIRoot2 = ((UIModel)inputField).UIRoot; num2 = 25; num3 = 50; UIFactory.SetLayoutElement(uIRoot2, (int?)100, num2, (int?)1000, num3, (int?)null, (int?)null, (bool?)null); inputField.Component.lineType = (LineType)2; ((UIModel)inputField).UIRoot.AddComponent().verticalFit = (FitMode)2; enumHelperButton = UIFactory.CreateButton(val, "EnumHelper", "▼", (Color?)null); UIFactory.SetLayoutElement(((Component)enumHelperButton.Component).gameObject, (int?)25, (int?)25, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null); ButtonRef obj2 = enumHelperButton; obj2.OnClick = (Action)System.Delegate.Combine(obj2.OnClick, new Action(EnumHelper_OnClick)); enumCompleter = new EnumCompleter(EnumType, inputField); toggleHolder = UIFactory.CreateUIObject("ToggleHolder", base.UIRoot, default(Vector2)); UIFactory.SetLayoutGroup(toggleHolder, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)4, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); GameObject obj3 = toggleHolder; num3 = 25; num2 = 9999; num = 9999; UIFactory.SetLayoutElement(obj3, (int?)null, num3, num2, num, (int?)null, (int?)null, (bool?)null); return base.UIRoot; } private void SetupTogglesForEnumType() { toggleHolder.SetActive(true); ((Component)inputField.Component).gameObject.SetActive(false); ((Component)enumHelperButton.Component).gameObject.SetActive(false); for (int i = 0; i < CurrentValues.Count || i < flagToggles.Count; i++) { if (i >= CurrentValues.Count) { if (i < flagToggles.Count) { ((Component)flagToggles[i]).gameObject.SetActive(false); continue; } break; } if (i >= flagToggles.Count) { AddToggleRow(); } flagToggles[i].isOn = false; flagTexts[i].text = ValueAtIndex(i).Name; } } private void AddToggleRow() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UIFactory.CreateUIObject("ToggleRow", toggleHolder, default(Vector2)); UIFactory.SetLayoutGroup(obj, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); int? num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(obj, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); Toggle item = default(Toggle); Text item2 = default(Text); GameObject obj2 = UIFactory.CreateToggle(obj, "ToggleObj", ref item, ref item2, default(Color), 20, 20); num2 = 25; num = 9999; UIFactory.SetLayoutElement(obj2, (int?)null, num2, num, (int?)null, (int?)null, (int?)null, (bool?)null); flagToggles.Add(item); flagTexts.Add(item2); } internal static OrderedDictionary GetEnumValues(Type enumType) { if (!enumCache.ContainsKey(enumType.AssemblyQualifiedName)) { OrderedDictionary orderedDictionary = new OrderedDictionary(); HashSet hashSet = new HashSet(); int num = 0; foreach (object value in System.Enum.GetValues(enumType)) { string text = value.ToString(); if (!hashSet.Contains(text)) { hashSet.Add(text); orderedDictionary.Add(value, new CachedEnumValue(value, num, text)); num++; } } enumCache.Add(enumType.AssemblyQualifiedName, orderedDictionary); } return enumCache[enumType.AssemblyQualifiedName]; } } public struct CachedEnumValue { public readonly object ActualValue; public int EnumIndex; public readonly string Name; public CachedEnumValue(object value, int index, string name) { EnumIndex = index; Name = name; ActualValue = value; } } public class InteractiveList : InteractiveValue, ICellPoolDataSource, ICacheObjectController { public Type EntryType; public IList RefIList; private bool IsWritableGenericIList; private PropertyInfo genericIndexer; private readonly List cachedEntries = new List(); public Text TopLabel; private LayoutElement scrollLayout; private Text NotSupportedLabel; CacheObjectBase ICacheObjectController.ParentCacheObject => base.CurrentOwner; object ICacheObjectController.Target => base.CurrentOwner.Value; public Type TargetType { get; private set; } public override bool CanWrite { get { if (base.CanWrite) { if (RefIList == null || RefIList.IsReadOnly) { return IsWritableGenericIList; } return true; } return false; } } public int ItemCount => cachedEntries.Count; public ScrollPool ListScrollPool { get; private set; } public override void OnBorrowed(CacheObjectBase owner) { base.OnBorrowed(owner); ListScrollPool.Refresh(true, true); } public override void ReleaseFromOwner() { base.ReleaseFromOwner(); ClearAndRelease(); } private void ClearAndRelease() { RefIList = null; foreach (CacheListEntry cachedEntry in cachedEntries) { cachedEntry.UnlinkFromView(); cachedEntry.ReleasePooledObjects(); } cachedEntries.Clear(); } public override void SetLayout() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) float num = 5f; foreach (CacheListEntryCell item in ListScrollPool.CellPool) { if (item.Enabled) { float num2 = num; Rect rect = item.Rect.rect; num = num2 + ((Rect)(ref rect)).height; } } scrollLayout.minHeight = Math.Min(InspectorPanel.CurrentPanelHeight - 400f, num); } public void OnCellBorrowed(CacheListEntryCell cell) { } public void SetCell(CacheListEntryCell cell, int index) { CacheObjectControllerHelper.SetCell(cell, index, cachedEntries, null); } public override void SetValue(object value) { if (value == null) { if (cachedEntries.Any()) { ClearAndRelease(); } } else { Type actualType = ReflectionExtensions.GetActualType(value); ReflectionUtility.TryGetEntryType(actualType, ref EntryType); CacheEntries(value); TopLabel.text = $"[{cachedEntries.Count}] {SignatureHighlighter.Parse(actualType, false, (MemberInfo)null)}"; } ListScrollPool.Refresh(true, false); } private void CacheEntries(object value) { RefIList = value as IList; if (RefIList == null) { CheckGenericIList(value); } else { IsWritableGenericIList = false; } int num = 0; IEnumerator enumerator = default(IEnumerator); if (ReflectionUtility.TryGetEnumerator(value, ref enumerator)) { ((Component)NotSupportedLabel).gameObject.SetActive(false); while (enumerator.MoveNext()) { object current = enumerator.Current; CacheListEntry cacheListEntry; if (num >= cachedEntries.Count) { cacheListEntry = new CacheListEntry(); cacheListEntry.SetListOwner(this, num); cachedEntries.Add(cacheListEntry); } else { cacheListEntry = cachedEntries[num]; } cacheListEntry.SetFallbackType(EntryType); cacheListEntry.SetValueFromSource(current); num++; } if (cachedEntries.Count <= num) { return; } for (int num2 = cachedEntries.Count - 1; num2 >= num; num2--) { CacheListEntry cacheListEntry2 = cachedEntries[num2]; if (cacheListEntry2.CellView != null) { cacheListEntry2.UnlinkFromView(); } cacheListEntry2.ReleasePooledObjects(); cachedEntries.RemoveAt(num2); } } else { ((Component)NotSupportedLabel).gameObject.SetActive(true); } } private void CheckGenericIList(object value) { try { Type type = value.GetType(); if (type.GetInterfaces().Any((Type it) => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IList<>))) { IsWritableGenericIList = !(bool)type.GetProperty("IsReadOnly").GetValue(value, null); } else { IsWritableGenericIList = false; } if (!IsWritableGenericIList) { return; } PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name == "Item" || (propertyInfo.Name.StartsWith("System.Collections.Generic.IList<") && propertyInfo.Name.EndsWith(">.Item"))) { ParameterInfo[] indexParameters = propertyInfo.GetIndexParameters(); if (indexParameters != null && indexParameters.Length == 1 && indexParameters[0].ParameterType == typeof(int)) { genericIndexer = propertyInfo; break; } } } if (genericIndexer == null) { ExplorerCore.LogWarning("Failed to find indexer property for IList type '" + type.FullName + "'!"); IsWritableGenericIList = false; } } catch (Exception ex) { ExplorerCore.LogWarning("Exception processing IEnumerable for IList check: " + ReflectionExtensions.ReflectionExToString(ex, true)); IsWritableGenericIList = false; } } public void TrySetValueToIndex(object value, int index) { try { if (!IsWritableGenericIList) { RefIList[index] = value; } else { genericIndexer.SetValue(base.CurrentOwner.Value, value, new object[1] { index }); } CacheListEntry cacheListEntry = cachedEntries[index]; cacheListEntry.SetValueFromSource(value); if (cacheListEntry.CellView != null) { cacheListEntry.SetDataToCell(cacheListEntry.CellView); } } catch (Exception arg) { ExplorerCore.LogWarning($"Exception setting IList value: {arg}"); } } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveList", true, true, true, true, 6, new Vector4(10f, 3f, 15f, 4f), new Color(0.05f, 0.05f, 0.05f), (TextAnchor?)null); GameObject uIRoot = base.UIRoot; int? num = 9999; int? num2 = 25; int? num3 = 600; UIFactory.SetLayoutElement(uIRoot, (int?)null, num2, num, num3, (int?)null, (int?)null, (bool?)null); base.UIRoot.AddComponent().verticalFit = (FitMode)2; TopLabel = UIFactory.CreateLabel(base.UIRoot, "EntryLabel", "not set", (TextAnchor)3, default(Color), true, 16); TopLabel.horizontalOverflow = (HorizontalWrapMode)1; GameObject val = default(GameObject); GameObject val2 = default(GameObject); ListScrollPool = UIFactory.CreateScrollPool(base.UIRoot, "EntryList", ref val, ref val2, (Color?)new Color(0.09f, 0.09f, 0.09f)); GameObject obj = val; num3 = 400; num2 = 0; UIFactory.SetLayoutElement(obj, (int?)null, num3, (int?)null, num2, (int?)null, (int?)null, (bool?)null); ListScrollPool.Initialize((ICellPoolDataSource)this, (Action)SetLayout); scrollLayout = val.GetComponent(); NotSupportedLabel = UIFactory.CreateLabel(((Component)ListScrollPool.Content).gameObject, "NotSupportedMessage", "The IEnumerable failed to enumerate. This is likely due to an issue with Unhollowed interfaces.", (TextAnchor)3, Color.red, true, 14); GameObject gameObject = ((Component)NotSupportedLabel).gameObject; num2 = 25; num3 = 9999; UIFactory.SetLayoutElement(gameObject, (int?)null, num2, num3, (int?)null, (int?)null, (int?)null, (bool?)null); ((Component)NotSupportedLabel).gameObject.SetActive(false); return base.UIRoot; } } public class InteractiveString : InteractiveValue { private string RealValue; public string EditedValue = ""; public InputFieldRef inputField; public ButtonRef ApplyButton; public GameObject SaveFileRow; public InputFieldRef SaveFilePath; public override void OnBorrowed(CacheObjectBase owner) { base.OnBorrowed(owner); bool flag = owner.CanWrite && owner.State != ValueState.Exception; inputField.Component.readOnly = !flag; ((Component)ApplyButton.Component).gameObject.SetActive(flag); SaveFilePath.Text = Path.Combine(ConfigManager.Default_Output_Path.Value, "untitled.txt"); } private bool IsStringTooLong(string s) { if (s == null) { return false; } return s.Length >= 16000; } public override void SetValue(object value) { if (base.CurrentOwner.State == ValueState.Exception) { value = base.CurrentOwner.LastException.ToString(); } RealValue = value as string; SaveFileRow.SetActive(IsStringTooLong(RealValue)); if (value == null) { inputField.Text = ""; EditedValue = ""; } else { EditedValue = (string)value; inputField.Text = EditedValue; } } private void OnApplyClicked() { base.CurrentOwner.SetUserValue(EditedValue); } private void OnInputChanged(string input) { EditedValue = input; SaveFileRow.SetActive(IsStringTooLong(EditedValue)); } private void OnSaveFileClicked() { if (RealValue == null) { return; } if (string.IsNullOrEmpty(SaveFilePath.Text)) { ExplorerCore.LogWarning("Cannot save an empty file path!"); return; } string path = IOUtility.EnsureValidFilePath(SaveFilePath.Text); if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, RealValue); } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveString", false, false, true, true, 3, new Vector4(4f, 4f, 4f, 4f), new Color(0.06f, 0.06f, 0.06f), (TextAnchor?)null); SaveFileRow = UIFactory.CreateUIObject("SaveFileRow", base.UIRoot, default(Vector2)); GameObject saveFileRow = SaveFileRow; int? num = 9999; UIFactory.SetLayoutElement(saveFileRow, (int?)null, (int?)null, num, (int?)null, (int?)null, (int?)null, (bool?)null); UIFactory.SetLayoutGroup(SaveFileRow, (bool?)false, (bool?)true, (bool?)true, (bool?)true, (int?)3, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); UIFactory.CreateLabel(SaveFileRow, "Info", "String is too long! Save to file if you want to see the full string.", (TextAnchor)3, default(Color), true, 14); GameObject val = UIFactory.CreateUIObject("Horiz", SaveFileRow, default(Vector2)); UIFactory.SetLayoutGroup(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)4, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null); ButtonRef obj = UIFactory.CreateButton(val, "SaveButton", "Save file", (Color?)null); GameObject gameObject = ((Component)obj.Component).gameObject; num = 25; UIFactory.SetLayoutElement(gameObject, (int?)100, num, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnSaveFileClicked)); SaveFilePath = UIFactory.CreateInputField(val, "SaveInput", "..."); GameObject uIRoot = ((UIModel)SaveFilePath).UIRoot; num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); ApplyButton = UIFactory.CreateButton(base.UIRoot, "ApplyButton", "Apply", (Color?)new Color(0.2f, 0.27f, 0.2f)); GameObject gameObject2 = ((Component)ApplyButton.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject2, (int?)100, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef applyButton = ApplyButton; applyButton.OnClick = (Action)System.Delegate.Combine(applyButton.OnClick, new Action(OnApplyClicked)); inputField = UIFactory.CreateInputField(base.UIRoot, "InputField", "empty"); ((UIModel)inputField).UIRoot.AddComponent().verticalFit = (FitMode)2; GameObject uIRoot2 = ((UIModel)inputField).UIRoot; num2 = 25; num = 500; int? num3 = 9999; UIFactory.SetLayoutElement(uIRoot2, (int?)null, num2, num3, num, (int?)null, (int?)null, (bool?)null); inputField.Component.lineType = (LineType)2; inputField.OnValueChanged += OnInputChanged; return base.UIRoot; } } public abstract class InteractiveValue : IPooledObject { private CacheObjectBase owner; public bool PendingValueWanted; public GameObject UIRoot { get; set; } public float DefaultHeight => -1f; public virtual bool CanWrite => CurrentOwner.CanWrite; public CacheObjectBase CurrentOwner => owner; public static Type GetIValueTypeForState(ValueState state) { switch (state) { case ValueState.Exception: case ValueState.String: return typeof(InteractiveString); case ValueState.Enum: return typeof(InteractiveEnum); case ValueState.Collection: return typeof(InteractiveList); case ValueState.Dictionary: return typeof(InteractiveDictionary); case ValueState.ValueStruct: return typeof(InteractiveValueStruct); case ValueState.Color: return typeof(InteractiveColor); default: return null; } } public virtual void OnBorrowed(CacheObjectBase owner) { if (this.owner != null) { ExplorerCore.LogWarning("Setting an IValue's owner but there is already one set. Maybe it wasn't cleaned up?"); ReleaseFromOwner(); } this.owner = owner; } public virtual void ReleaseFromOwner() { if (owner != null) { owner = null; } } public abstract void SetValue(object value); public virtual void SetLayout() { } public abstract GameObject CreateContent(GameObject parent); } public class InteractiveValueStruct : InteractiveValue { public class StructInfo { public bool IsSupported; public FieldInfo[] Fields; public StructInfo(bool isSupported, FieldInfo[] fields) { IsSupported = isSupported; Fields = fields; } public void SetValue(object instance, string input, int fieldIndex) { FieldInfo fieldInfo = Fields[fieldIndex]; object value = default(object); Exception ex = default(Exception); if (fieldInfo.FieldType == typeof(string)) { value = input; } else if (!ParseUtility.TryParse(input, fieldInfo.FieldType, ref value, ref ex)) { ExplorerCore.LogWarning("Unable to parse input!"); if (ex != null) { ExplorerCore.Log(ReflectionExtensions.ReflectionExToString(ex, true)); } return; } fieldInfo.SetValue(instance, value); } public string GetValue(object instance, int fieldIndex) { FieldInfo fieldInfo = Fields[fieldIndex]; return ParseUtility.ToStringForInput(fieldInfo.GetValue(instance), fieldInfo.FieldType); } } private static readonly Dictionary typeSupportCache = new Dictionary(); private const BindingFlags INSTANCE_FLAGS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private const string SYSTEM_VOID = "System.Void"; public object RefInstance; public StructInfo CurrentInfo; private Type lastStructType; private ButtonRef applyButton; private readonly List fieldRows = new List(); private readonly List inputFields = new List(); private readonly List labels = new List(); public static bool SupportsType(Type type) { if (!type.IsValueType || string.IsNullOrEmpty(type.AssemblyQualifiedName) || type.FullName == "System.Void") { return false; } if (typeSupportCache.TryGetValue(type.AssemblyQualifiedName, out var value)) { return value.IsSupported; } bool flag = false; FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fields.Length != 0) { if (fields.Any((FieldInfo it) => !ParseUtility.CanParse(it.FieldType))) { flag = false; value = new StructInfo(flag, null); } else { flag = true; value = new StructInfo(flag, fields); } } typeSupportCache.Add(type.AssemblyQualifiedName, value); return flag; } public override void OnBorrowed(CacheObjectBase owner) { base.OnBorrowed(owner); ((Component)applyButton.Component).gameObject.SetActive(owner.CanWrite); } public override void SetValue(object value) { RefInstance = value; Type type = RefInstance.GetType(); if (type != lastStructType) { CurrentInfo = typeSupportCache[type.AssemblyQualifiedName]; SetupUIForType(); lastStructType = type; } for (int i = 0; i < CurrentInfo.Fields.Length; i++) { inputFields[i].Text = CurrentInfo.GetValue(RefInstance, i); } } private void OnApplyClicked() { try { for (int i = 0; i < CurrentInfo.Fields.Length; i++) { CurrentInfo.SetValue(RefInstance, inputFields[i].Text, i); } base.CurrentOwner.SetUserValue(RefInstance); } catch (Exception ex) { ExplorerCore.LogWarning("Exception setting value: " + ex); } } private void SetupUIForType() { for (int i = 0; i < CurrentInfo.Fields.Length || i <= inputFields.Count; i++) { if (i >= CurrentInfo.Fields.Length) { if (i < inputFields.Count) { fieldRows[i].SetActive(false); continue; } break; } if (i >= inputFields.Count) { AddEditorRow(); } fieldRows[i].SetActive(true); string text = SignatureHighlighter.Parse(CurrentInfo.Fields[i].FieldType, false, (MemberInfo)null); text = text + " " + CurrentInfo.Fields[i].Name + ":"; labels[i].text = text; } } private void AddEditorRow() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.CreateUIObject("HoriGroup", base.UIRoot, default(Vector2)); int? num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(val, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); bool? flag = false; bool? flag2 = false; bool? flag3 = true; bool? flag4 = true; int? num3 = 8; TextAnchor? val2 = (TextAnchor)3; UIFactory.SetLayoutGroup(val, flag, flag2, flag3, flag4, num3, (int?)null, (int?)null, (int?)null, (int?)null, val2); fieldRows.Add(val); Text val3 = UIFactory.CreateLabel(val, "Label", "notset", (TextAnchor)3, default(Color), true, 14); GameObject gameObject = ((Component)val3).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)50, num2, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null); val3.horizontalOverflow = (HorizontalWrapMode)0; labels.Add(val3); InputFieldRef val4 = UIFactory.CreateInputField(val, "InputField", "..."); GameObject uIRoot = ((UIModel)val4).UIRoot; num2 = 25; UIFactory.SetLayoutElement(uIRoot, (int?)200, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ContentSizeFitter obj = ((UIModel)val4).UIRoot.AddComponent(); obj.verticalFit = (FitMode)2; obj.horizontalFit = (FitMode)2; val4.Component.lineType = (LineType)2; inputFields.Add(val4); } public override GameObject CreateContent(GameObject parent) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) base.UIRoot = UIFactory.CreateVerticalGroup(parent, "InteractiveValueStruct", false, false, true, true, 3, new Vector4(4f, 4f, 4f, 4f), new Color(0.06f, 0.06f, 0.06f), (TextAnchor?)(TextAnchor)3); GameObject uIRoot = base.UIRoot; int? num = 25; int? num2 = 9999; UIFactory.SetLayoutElement(uIRoot, (int?)null, num, num2, (int?)null, (int?)null, (int?)null, (bool?)null); applyButton = UIFactory.CreateButton(base.UIRoot, "ApplyButton", "Apply", (Color?)new Color(0.2f, 0.27f, 0.2f)); GameObject gameObject = ((Component)applyButton.Component).gameObject; num2 = 25; UIFactory.SetLayoutElement(gameObject, (int?)175, num2, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null); ButtonRef obj = applyButton; obj.OnClick = (Action)System.Delegate.Combine(obj.OnClick, new Action(OnApplyClicked)); return base.UIRoot; } } } [CompilerGenerated] internal sealed class { [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 12)] internal struct __StaticArrayInitTypeSize=12 { } internal static readonly __StaticArrayInitTypeSize=12 8E628779E6A74EE0B36991C10158F63CAFEC7D340AD4E075592502C8708524DD/* Not supported: data(00 00 80 3F 00 00 00 40 00 00 40 40) */; } namespace Mono.CompilerServices.SymbolWriter { internal class MonoSymbolFileException : Exception { public MonoSymbolFileException() { } public MonoSymbolFileException(string message, params object[] args) : base(string.Format(message, args)) { } public MonoSymbolFileException(string message, Exception innerException) : base(message, innerException) { } } internal sealed class MyBinaryWriter : BinaryWriter { public MyBinaryWriter(Stream stream) : base(stream) { } public void WriteLeb128(int value) { Write7BitEncodedInt(value); } } internal class MyBinaryReader : BinaryReader { public MyBinaryReader(Stream stream) : base(stream) { } public int ReadLeb128() { return Read7BitEncodedInt(); } public string ReadString(int offset) { long position = BaseStream.Position; BaseStream.Position = offset; string result = ReadString(); BaseStream.Position = position; return result; } } internal interface ISourceFile { SourceFileEntry Entry { get; } } internal interface ICompileUnit { CompileUnitEntry Entry { get; } } internal interface IMethodDef { string Name { get; } int Token { get; } } internal class MonoSymbolFile : IDisposable { private List methods = new List(); private List sources = new List(); private List comp_units = new List(); private Dictionary anonymous_scopes; private OffsetTable ot; private int last_type_index; private int last_method_index; private int last_namespace_index; public readonly int MajorVersion = 50; public readonly int MinorVersion = 0; public int NumLineNumbers; private MyBinaryReader reader; private Dictionary source_file_hash; private Dictionary compile_unit_hash; private List method_list; private Dictionary method_token_hash; private Dictionary source_name_hash; private Guid guid; internal int LineNumberCount = 0; internal int LocalCount = 0; internal int StringSize = 0; internal int LineNumberSize = 0; internal int ExtendedLineNumberSize = 0; public int CompileUnitCount => ot.CompileUnitCount; public int SourceCount => ot.SourceCount; public int MethodCount => ot.MethodCount; public int TypeCount => ot.TypeCount; public int AnonymousScopeCount => ot.AnonymousScopeCount; public int NamespaceCount => last_namespace_index; public Guid Guid => guid; public OffsetTable OffsetTable => ot; public SourceFileEntry[] Sources { get { if (reader == null) { throw new InvalidOperationException(); } SourceFileEntry[] array = new SourceFileEntry[SourceCount]; for (int i = 0; i < SourceCount; i++) { array[i] = GetSourceFile(i + 1); } return array; } } public CompileUnitEntry[] CompileUnits { get { if (reader == null) { throw new InvalidOperationException(); } CompileUnitEntry[] array = new CompileUnitEntry[CompileUnitCount]; for (int i = 0; i < CompileUnitCount; i++) { array[i] = GetCompileUnit(i + 1); } return array; } } public MethodEntry[] Methods { get { if (reader == null) { throw new InvalidOperationException(); } lock (this) { read_methods(); MethodEntry[] array = new MethodEntry[MethodCount]; method_list.CopyTo(array, 0); return array; } } } internal MyBinaryReader BinaryReader { get { if (reader == null) { throw new InvalidOperationException(); } return reader; } } public MonoSymbolFile() { ot = new OffsetTable(); } public int AddSource(SourceFileEntry source) { sources.Add(source); return sources.Count; } public int AddCompileUnit(CompileUnitEntry entry) { comp_units.Add(entry); return comp_units.Count; } public void AddMethod(MethodEntry entry) { methods.Add(entry); } public MethodEntry DefineMethod(CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, MethodEntry.Flags flags, int namespace_id) { if (reader != null) { throw new InvalidOperationException(); } MethodEntry methodEntry = new MethodEntry(this, comp_unit, token, scope_vars, locals, lines, code_blocks, real_name, flags, namespace_id); AddMethod(methodEntry); return methodEntry; } internal void DefineAnonymousScope(int id) { if (reader != null) { throw new InvalidOperationException(); } if (anonymous_scopes == null) { anonymous_scopes = new Dictionary(); } anonymous_scopes.Add(id, new AnonymousScopeEntry(id)); } internal void DefineCapturedVariable(int scope_id, string name, string captured_name, CapturedVariable.CapturedKind kind) { if (reader != null) { throw new InvalidOperationException(); } AnonymousScopeEntry anonymousScopeEntry = anonymous_scopes[scope_id]; anonymousScopeEntry.AddCapturedVariable(name, captured_name, kind); } internal void DefineCapturedScope(int scope_id, int id, string captured_name) { if (reader != null) { throw new InvalidOperationException(); } AnonymousScopeEntry anonymousScopeEntry = anonymous_scopes[scope_id]; anonymousScopeEntry.AddCapturedScope(id, captured_name); } internal int GetNextTypeIndex() { return ++last_type_index; } internal int GetNextMethodIndex() { return ++last_method_index; } internal int GetNextNamespaceIndex() { return ++last_namespace_index; } private void Write(MyBinaryWriter bw, Guid guid) { bw.Write(5037318119232611860L); bw.Write(MajorVersion); bw.Write(MinorVersion); bw.Write(guid.ToByteArray()); long position = bw.BaseStream.Position; ot.Write(bw, MajorVersion, MinorVersion); methods.Sort(); for (int i = 0; i < methods.Count; i++) { methods[i].Index = i + 1; } ot.DataSectionOffset = (int)bw.BaseStream.Position; foreach (SourceFileEntry source in sources) { source.WriteData(bw); } foreach (CompileUnitEntry comp_unit in comp_units) { comp_unit.WriteData(bw); } foreach (MethodEntry method in methods) { method.WriteData(this, bw); } ot.DataSectionSize = (int)bw.BaseStream.Position - ot.DataSectionOffset; ot.MethodTableOffset = (int)bw.BaseStream.Position; for (int j = 0; j < methods.Count; j++) { MethodEntry methodEntry = methods[j]; methodEntry.Write(bw); } ot.MethodTableSize = (int)bw.BaseStream.Position - ot.MethodTableOffset; ot.SourceTableOffset = (int)bw.BaseStream.Position; for (int k = 0; k < sources.Count; k++) { SourceFileEntry sourceFileEntry = sources[k]; sourceFileEntry.Write(bw); } ot.SourceTableSize = (int)bw.BaseStream.Position - ot.SourceTableOffset; ot.CompileUnitTableOffset = (int)bw.BaseStream.Position; for (int l = 0; l < comp_units.Count; l++) { CompileUnitEntry compileUnitEntry = comp_units[l]; compileUnitEntry.Write(bw); } ot.CompileUnitTableSize = (int)bw.BaseStream.Position - ot.CompileUnitTableOffset; ot.AnonymousScopeCount = ((anonymous_scopes != null) ? anonymous_scopes.Count : 0); ot.AnonymousScopeTableOffset = (int)bw.BaseStream.Position; if (anonymous_scopes != null) { foreach (AnonymousScopeEntry value in anonymous_scopes.Values) { value.Write(bw); } } ot.AnonymousScopeTableSize = (int)bw.BaseStream.Position - ot.AnonymousScopeTableOffset; ot.TypeCount = last_type_index; ot.MethodCount = methods.Count; ot.SourceCount = sources.Count; ot.CompileUnitCount = comp_units.Count; ot.TotalFileSize = (int)bw.BaseStream.Position; bw.Seek((int)position, SeekOrigin.Begin); ot.Write(bw, MajorVersion, MinorVersion); bw.Seek(0, SeekOrigin.End); } public void CreateSymbolFile(Guid guid, FileStream fs) { if (reader != null) { throw new InvalidOperationException(); } Write(new MyBinaryWriter(fs), guid); } private MonoSymbolFile(Stream stream) { reader = new MyBinaryReader(stream); try { long num = reader.ReadInt64(); int num2 = reader.ReadInt32(); int num3 = reader.ReadInt32(); if (num != 5037318119232611860L) { throw new MonoSymbolFileException("Symbol file is not a valid"); } if (num2 != 50) { throw new MonoSymbolFileException("Symbol file has version {0} but expected {1}", num2, 50); } if (num3 != 0) { throw new MonoSymbolFileException("Symbol file has version {0}.{1} but expected {2}.{3}", num2, num3, 50, 0); } MajorVersion = num2; MinorVersion = num3; guid = new Guid(reader.ReadBytes(16)); ot = new OffsetTable(reader, num2, num3); } catch (Exception innerException) { throw new MonoSymbolFileException("Cannot read symbol file", innerException); } source_file_hash = new Dictionary(); compile_unit_hash = new Dictionary(); } public static MonoSymbolFile ReadSymbolFile(Assembly assembly) { string location = assembly.Location; string mdbFilename = location + ".mdb"; Module[] modules = assembly.GetModules(); Guid moduleVersionId = modules[0].ModuleVersionId; return ReadSymbolFile(mdbFilename, moduleVersionId); } public static MonoSymbolFile ReadSymbolFile(string mdbFilename) { return ReadSymbolFile(new FileStream(mdbFilename, FileMode.Open, FileAccess.Read)); } public static MonoSymbolFile ReadSymbolFile(string mdbFilename, Guid assemblyGuid) { MonoSymbolFile monoSymbolFile = ReadSymbolFile(mdbFilename); if (assemblyGuid != monoSymbolFile.guid) { throw new MonoSymbolFileException("Symbol file `{0}' does not match assembly", mdbFilename); } return monoSymbolFile; } public static MonoSymbolFile ReadSymbolFile(Stream stream) { return new MonoSymbolFile(stream); } public SourceFileEntry GetSourceFile(int index) { if (index < 1 || index > ot.SourceCount) { throw new ArgumentException(); } if (reader == null) { throw new InvalidOperationException(); } lock (this) { if (source_file_hash.TryGetValue(index, out var value)) { return value; } long position = reader.BaseStream.Position; reader.BaseStream.Position = ot.SourceTableOffset + SourceFileEntry.Size * (index - 1); value = new SourceFileEntry(this, reader); source_file_hash.Add(index, value); reader.BaseStream.Position = position; return value; } } public CompileUnitEntry GetCompileUnit(int index) { if (index < 1 || index > ot.CompileUnitCount) { throw new ArgumentException(); } if (reader == null) { throw new InvalidOperationException(); } lock (this) { if (compile_unit_hash.TryGetValue(index, out var value)) { return value; } long position = reader.BaseStream.Position; reader.BaseStream.Position = ot.CompileUnitTableOffset + CompileUnitEntry.Size * (index - 1); value = new CompileUnitEntry(this, reader); compile_unit_hash.Add(index, value); reader.BaseStream.Position = position; return value; } } private void read_methods() { lock (this) { if (method_token_hash == null) { method_token_hash = new Dictionary(); method_list = new List(); long position = reader.BaseStream.Position; reader.BaseStream.Position = ot.MethodTableOffset; for (int i = 0; i < MethodCount; i++) { MethodEntry methodEntry = new MethodEntry(this, reader, i + 1); method_token_hash.Add(methodEntry.Token, methodEntry); method_list.Add(methodEntry); } reader.BaseStream.Position = position; } } } public MethodEntry GetMethodByToken(int token) { if (reader == null) { throw new InvalidOperationException(); } lock (this) { read_methods(); method_token_hash.TryGetValue(token, out var value); return value; } } public MethodEntry GetMethod(int index) { if (index < 1 || index > ot.MethodCount) { throw new ArgumentException(); } if (reader == null) { throw new InvalidOperationException(); } lock (this) { read_methods(); return method_list[index - 1]; } } public int FindSource(string file_name) { if (reader == null) { throw new InvalidOperationException(); } lock (this) { if (source_name_hash == null) { source_name_hash = new Dictionary(); for (int i = 0; i < ot.SourceCount; i++) { SourceFileEntry sourceFile = GetSourceFile(i + 1); source_name_hash.Add(sourceFile.FileName, i); } } if (!source_name_hash.TryGetValue(file_name, out var value)) { return -1; } return value; } } public AnonymousScopeEntry GetAnonymousScope(int id) { if (reader == null) { throw new InvalidOperationException(); } lock (this) { if (anonymous_scopes != null) { anonymous_scopes.TryGetValue(id, out var value); return value; } anonymous_scopes = new Dictionary(); reader.BaseStream.Position = ot.AnonymousScopeTableOffset; for (int i = 0; i < ot.AnonymousScopeCount; i++) { AnonymousScopeEntry value = new AnonymousScopeEntry(reader); anonymous_scopes.Add(value.ID, value); } return anonymous_scopes[id]; } } public void Dispose() { Dispose(disposing: true); } protected virtual void Dispose(bool disposing) { if (disposing && reader != null) { reader.Close(); reader = null; } } } internal class OffsetTable { [Flags] public enum Flags { IsAspxSource = 1, WindowsFileNames = 2 } public const int MajorVersion = 50; public const int MinorVersion = 0; public const long Magic = 5037318119232611860L; public int TotalFileSize; public int DataSectionOffset; public int DataSectionSize; public int CompileUnitCount; public int CompileUnitTableOffset; public int CompileUnitTableSize; public int SourceCount; public int SourceTableOffset; public int SourceTableSize; public int MethodCount; public int MethodTableOffset; public int MethodTableSize; public int TypeCount; public int AnonymousScopeCount; public int AnonymousScopeTableOffset; public int AnonymousScopeTableSize; public Flags FileFlags; public int LineNumberTable_LineBase = -1; public int LineNumberTable_LineRange = 8; public int LineNumberTable_OpcodeBase = 9; internal OffsetTable() { int platform = (int)Environment.OSVersion.Platform; if (platform != 4 && platform != 128) { FileFlags |= Flags.WindowsFileNames; } } internal OffsetTable(BinaryReader reader, int major_version, int minor_version) { TotalFileSize = reader.ReadInt32(); DataSectionOffset = reader.ReadInt32(); DataSectionSize = reader.ReadInt32(); CompileUnitCount = reader.ReadInt32(); CompileUnitTableOffset = reader.ReadInt32(); CompileUnitTableSize = reader.ReadInt32(); SourceCount = reader.ReadInt32(); SourceTableOffset = reader.ReadInt32(); SourceTableSize = reader.ReadInt32(); MethodCount = reader.ReadInt32(); MethodTableOffset = reader.ReadInt32(); MethodTableSize = reader.ReadInt32(); TypeCount = reader.ReadInt32(); AnonymousScopeCount = reader.ReadInt32(); AnonymousScopeTableOffset = reader.ReadInt32(); AnonymousScopeTableSize = reader.ReadInt32(); LineNumberTable_LineBase = reader.ReadInt32(); LineNumberTable_LineRange = reader.ReadInt32(); LineNumberTable_OpcodeBase = reader.ReadInt32(); FileFlags = (Flags)reader.ReadInt32(); } internal void Write(BinaryWriter bw, int major_version, int minor_version) { bw.Write(TotalFileSize); bw.Write(DataSectionOffset); bw.Write(DataSectionSize); bw.Write(CompileUnitCount); bw.Write(CompileUnitTableOffset); bw.Write(CompileUnitTableSize); bw.Write(SourceCount); bw.Write(SourceTableOffset); bw.Write(SourceTableSize); bw.Write(MethodCount); bw.Write(MethodTableOffset); bw.Write(MethodTableSize); bw.Write(TypeCount); bw.Write(AnonymousScopeCount); bw.Write(AnonymousScopeTableOffset); bw.Write(AnonymousScopeTableSize); bw.Write(LineNumberTable_LineBase); bw.Write(LineNumberTable_LineRange); bw.Write(LineNumberTable_OpcodeBase); bw.Write((int)FileFlags); } public override string ToString() { return $"OffsetTable [{TotalFileSize} - {DataSectionOffset}:{DataSectionSize} - {SourceCount}:{SourceTableOffset}:{SourceTableSize} - {MethodCount}:{MethodTableOffset}:{MethodTableSize} - {TypeCount}]"; } } internal class LineNumberEntry { public sealed class LocationComparer : IComparer { public static readonly LocationComparer Default = new LocationComparer(); public int Compare(LineNumberEntry l1, LineNumberEntry l2) { int result; if (l1.Row != l2.Row) { int row = l1.Row; result = row.CompareTo(l2.Row); } else { result = l1.Column.CompareTo(l2.Column); } return result; } } public readonly int Row; public int Column; public int EndRow; public int EndColumn; public readonly int File; public readonly int Offset; public readonly bool IsHidden; public static readonly LineNumberEntry Null = new LineNumberEntry(0, 0, 0, 0); public LineNumberEntry(int file, int row, int column, int offset) : this(file, row, column, offset, is_hidden: false) { } public LineNumberEntry(int file, int row, int offset) : this(file, row, -1, offset, is_hidden: false) { } public LineNumberEntry(int file, int row, int column, int offset, bool is_hidden) : this(file, row, column, -1, -1, offset, is_hidden) { } public LineNumberEntry(int file, int row, int column, int end_row, int end_column, int offset, bool is_hidden) { File = file; Row = row; Column = column; EndRow = end_row; EndColumn = end_column; Offset = offset; IsHidden = is_hidden; } public override string ToString() { return string.Format("[Line {0}:{1,2}-{3,4}:{5}]", File, Row, Column, EndRow, EndColumn, Offset); } } internal class CodeBlockEntry { public enum Type { Lexical = 1, CompilerGenerated, IteratorBody, IteratorDispatcher } public int Index; public int Parent; public Type BlockType; public int StartOffset; public int EndOffset; public CodeBlockEntry(int index, int parent, Type type, int start_offset) { Index = index; Parent = parent; BlockType = type; StartOffset = start_offset; } internal CodeBlockEntry(int index, MyBinaryReader reader) { Index = index; int num = reader.ReadLeb128(); BlockType = (Type)(num & 0x3F); Parent = reader.ReadLeb128(); StartOffset = reader.ReadLeb128(); EndOffset = reader.ReadLeb128(); if ((num & 0x40) != 0) { int num2 = reader.ReadInt16(); reader.BaseStream.Position += num2; } } public void Close(int end_offset) { EndOffset = end_offset; } internal void Write(MyBinaryWriter bw) { bw.WriteLeb128((int)BlockType); bw.WriteLeb128(Parent); bw.WriteLeb128(StartOffset); bw.WriteLeb128(EndOffset); } public override string ToString() { return $"[CodeBlock {Index}:{Parent}:{BlockType}:{StartOffset}:{EndOffset}]"; } } internal struct LocalVariableEntry { public readonly int Index; public readonly string Name; public readonly int BlockIndex; public LocalVariableEntry(int index, string name, int block) { Index = index; Name = name; BlockIndex = block; } internal LocalVariableEntry(MonoSymbolFile file, MyBinaryReader reader) { Index = reader.ReadLeb128(); Name = reader.ReadString(); BlockIndex = reader.ReadLeb128(); } internal void Write(MonoSymbolFile file, MyBinaryWriter bw) { bw.WriteLeb128(Index); bw.Write(Name); bw.WriteLeb128(BlockIndex); } public override string ToString() { return $"[LocalVariable {Name}:{Index}:{BlockIndex - 1}]"; } } internal struct CapturedVariable { public enum CapturedKind : byte { Local, Parameter, This } public readonly string Name; public readonly string CapturedName; public readonly CapturedKind Kind; public CapturedVariable(string name, string captured_name, CapturedKind kind) { Name = name; CapturedName = captured_name; Kind = kind; } internal CapturedVariable(MyBinaryReader reader) { Name = reader.ReadString(); CapturedName = reader.ReadString(); Kind = (CapturedKind)reader.ReadByte(); } internal void Write(MyBinaryWriter bw) { bw.Write(Name); bw.Write(CapturedName); bw.Write((byte)Kind); } public override string ToString() { return $"[CapturedVariable {Name}:{CapturedName}:{Kind}]"; } } internal struct CapturedScope { public readonly int Scope; public readonly string CapturedName; public CapturedScope(int scope, string captured_name) { Scope = scope; CapturedName = captured_name; } internal CapturedScope(MyBinaryReader reader) { Scope = reader.ReadLeb128(); CapturedName = reader.ReadString(); } internal void Write(MyBinaryWriter bw) { bw.WriteLeb128(Scope); bw.Write(CapturedName); } public override string ToString() { return $"[CapturedScope {Scope}:{CapturedName}]"; } } internal struct ScopeVariable { public readonly int Scope; public readonly int Index; public ScopeVariable(int scope, int index) { Scope = scope; Index = index; } internal ScopeVariable(MyBinaryReader reader) { Scope = reader.ReadLeb128(); Index = reader.ReadLeb128(); } internal void Write(MyBinaryWriter bw) { bw.WriteLeb128(Scope); bw.WriteLeb128(Index); } public override string ToString() { return $"[ScopeVariable {Scope}:{Index}]"; } } internal class AnonymousScopeEntry { public readonly int ID; private List captured_vars = new List(); private List captured_scopes = new List(); public CapturedVariable[] CapturedVariables { get { CapturedVariable[] array = new CapturedVariable[captured_vars.Count]; captured_vars.CopyTo(array, 0); return array; } } public CapturedScope[] CapturedScopes { get { CapturedScope[] array = new CapturedScope[captured_scopes.Count]; captured_scopes.CopyTo(array, 0); return array; } } public AnonymousScopeEntry(int id) { ID = id; } internal AnonymousScopeEntry(MyBinaryReader reader) { ID = reader.ReadLeb128(); int num = reader.ReadLeb128(); for (int i = 0; i < num; i++) { captured_vars.Add(new CapturedVariable(reader)); } int num2 = reader.ReadLeb128(); for (int j = 0; j < num2; j++) { captured_scopes.Add(new CapturedScope(reader)); } } internal void AddCapturedVariable(string name, string captured_name, CapturedVariable.CapturedKind kind) { captured_vars.Add(new CapturedVariable(name, captured_name, kind)); } internal void AddCapturedScope(int scope, string captured_name) { captured_scopes.Add(new CapturedScope(scope, captured_name)); } internal void Write(MyBinaryWriter bw) { bw.WriteLeb128(ID); bw.WriteLeb128(captured_vars.Count); foreach (CapturedVariable captured_var in captured_vars) { captured_var.Write(bw); } bw.WriteLeb128(captured_scopes.Count); foreach (CapturedScope captured_scope in captured_scopes) { captured_scope.Write(bw); } } public override string ToString() { return $"[AnonymousScope {ID}]"; } } internal class CompileUnitEntry : ICompileUnit { public readonly int Index; private int DataOffset; private MonoSymbolFile file; private SourceFileEntry source; private List include_files; private List namespaces; private bool creating; public static int Size => 8; CompileUnitEntry ICompileUnit.Entry => this; public SourceFileEntry SourceFile { get { if (creating) { return source; } ReadData(); return source; } } public NamespaceEntry[] Namespaces { get { ReadData(); NamespaceEntry[] array = new NamespaceEntry[namespaces.Count]; namespaces.CopyTo(array, 0); return array; } } public SourceFileEntry[] IncludeFiles { get { ReadData(); if (include_files == null) { return new SourceFileEntry[0]; } SourceFileEntry[] array = new SourceFileEntry[include_files.Count]; include_files.CopyTo(array, 0); return array; } } public CompileUnitEntry(MonoSymbolFile file, SourceFileEntry source) { this.file = file; this.source = source; Index = file.AddCompileUnit(this); creating = true; namespaces = new List(); } public void AddFile(SourceFileEntry file) { if (!creating) { throw new InvalidOperationException(); } if (include_files == null) { include_files = new List(); } include_files.Add(file); } public int DefineNamespace(string name, string[] using_clauses, int parent) { if (!creating) { throw new InvalidOperationException(); } int nextNamespaceIndex = file.GetNextNamespaceIndex(); NamespaceEntry item = new NamespaceEntry(name, nextNamespaceIndex, using_clauses, parent); namespaces.Add(item); return nextNamespaceIndex; } internal void WriteData(MyBinaryWriter bw) { DataOffset = (int)bw.BaseStream.Position; bw.WriteLeb128(source.Index); int value = ((include_files != null) ? include_files.Count : 0); bw.WriteLeb128(value); if (include_files != null) { foreach (SourceFileEntry include_file in include_files) { bw.WriteLeb128(include_file.Index); } } bw.WriteLeb128(namespaces.Count); foreach (NamespaceEntry @namespace in namespaces) { @namespace.Write(file, bw); } } internal void Write(BinaryWriter bw) { bw.Write(Index); bw.Write(DataOffset); } internal CompileUnitEntry(MonoSymbolFile file, MyBinaryReader reader) { this.file = file; Index = reader.ReadInt32(); DataOffset = reader.ReadInt32(); } public void ReadAll() { ReadData(); } private void ReadData() { if (creating) { throw new InvalidOperationException(); } lock (file) { if (namespaces != null) { return; } MyBinaryReader binaryReader = file.BinaryReader; int num = (int)binaryReader.BaseStream.Position; binaryReader.BaseStream.Position = DataOffset; int index = binaryReader.ReadLeb128(); source = file.GetSourceFile(index); int num2 = binaryReader.ReadLeb128(); if (num2 > 0) { include_files = new List(); for (int i = 0; i < num2; i++) { include_files.Add(file.GetSourceFile(binaryReader.ReadLeb128())); } } int num3 = binaryReader.ReadLeb128(); namespaces = new List(); for (int j = 0; j < num3; j++) { namespaces.Add(new NamespaceEntry(file, binaryReader)); } binaryReader.BaseStream.Position = num; } } } internal class SourceFileEntry { public readonly int Index; private int DataOffset; private MonoSymbolFile file; private string file_name; private byte[] guid; private byte[] hash; private bool creating; private bool auto_generated; private readonly string sourceFile; public static int Size => 8; public byte[] Checksum => hash; public string FileName { get { return file_name; } set { file_name = value; } } public bool AutoGenerated => auto_generated; public SourceFileEntry(MonoSymbolFile file, string file_name) { this.file = file; this.file_name = file_name; Index = file.AddSource(this); creating = true; } public SourceFileEntry(MonoSymbolFile file, string sourceFile, byte[] guid, byte[] checksum) : this(file, sourceFile, sourceFile, guid, checksum) { } public SourceFileEntry(MonoSymbolFile file, string fileName, string sourceFile, byte[] guid, byte[] checksum) : this(file, fileName) { this.guid = guid; hash = checksum; this.sourceFile = sourceFile; } internal void WriteData(MyBinaryWriter bw) { DataOffset = (int)bw.BaseStream.Position; bw.Write(file_name); if (guid == null) { guid = new byte[16]; } if (hash == null) { try { using FileStream inputStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read); MD5 mD = MD5.Create(); hash = mD.ComputeHash(inputStream); } catch { hash = new byte[16]; } } bw.Write(guid); bw.Write(hash); bw.Write((byte)(auto_generated ? 1u : 0u)); } internal void Write(BinaryWriter bw) { bw.Write(Index); bw.Write(DataOffset); } internal SourceFileEntry(MonoSymbolFile file, MyBinaryReader reader) { this.file = file; Index = reader.ReadInt32(); DataOffset = reader.ReadInt32(); int num = (int)reader.BaseStream.Position; reader.BaseStream.Position = DataOffset; sourceFile = (file_name = reader.ReadString()); guid = reader.ReadBytes(16); hash = reader.ReadBytes(16); auto_generated = reader.ReadByte() == 1; reader.BaseStream.Position = num; } public void SetAutoGenerated() { if (!creating) { throw new InvalidOperationException(); } auto_generated = true; file.OffsetTable.FileFlags |= OffsetTable.Flags.IsAspxSource; } public bool CheckChecksum() { try { using FileStream inputStream = new FileStream(sourceFile, FileMode.Open); MD5 mD = MD5.Create(); byte[] array = mD.ComputeHash(inputStream); for (int i = 0; i < 16; i++) { if (array[i] != hash[i]) { return false; } } return true; } catch { return false; } } public override string ToString() { return $"SourceFileEntry ({Index}:{DataOffset})"; } } internal class LineNumberTable { protected LineNumberEntry[] _line_numbers; public readonly int LineBase; public readonly int LineRange; public readonly byte OpcodeBase; public readonly int MaxAddressIncrement; public const int Default_LineBase = -1; public const int Default_LineRange = 8; public const byte Default_OpcodeBase = 9; public const byte DW_LNS_copy = 1; public const byte DW_LNS_advance_pc = 2; public const byte DW_LNS_advance_line = 3; public const byte DW_LNS_set_file = 4; public const byte DW_LNS_const_add_pc = 8; public const byte DW_LNE_end_sequence = 1; public const byte DW_LNE_MONO_negate_is_hidden = 64; internal const byte DW_LNE_MONO__extensions_start = 64; internal const byte DW_LNE_MONO__extensions_end = 127; public LineNumberEntry[] LineNumbers => _line_numbers; protected LineNumberTable(MonoSymbolFile file) { LineBase = file.OffsetTable.LineNumberTable_LineBase; LineRange = file.OffsetTable.LineNumberTable_LineRange; OpcodeBase = (byte)file.OffsetTable.LineNumberTable_OpcodeBase; MaxAddressIncrement = (255 - OpcodeBase) / LineRange; } internal LineNumberTable(MonoSymbolFile file, LineNumberEntry[] lines) : this(file) { _line_numbers = lines; } internal void Write(MonoSymbolFile file, MyBinaryWriter bw, bool hasColumnsInfo, bool hasEndInfo) { int num = (int)bw.BaseStream.Position; bool flag = false; int num2 = 1; int num3 = 0; int num4 = 1; for (int i = 0; i < LineNumbers.Length; i++) { int num5 = LineNumbers[i].Row - num2; int num6 = LineNumbers[i].Offset - num3; if (LineNumbers[i].File != num4) { bw.Write((byte)4); bw.WriteLeb128(LineNumbers[i].File); num4 = LineNumbers[i].File; } if (LineNumbers[i].IsHidden != flag) { bw.Write((byte)0); bw.Write((byte)1); bw.Write((byte)64); flag = LineNumbers[i].IsHidden; } if (num6 >= MaxAddressIncrement) { if (num6 < 2 * MaxAddressIncrement) { bw.Write((byte)8); num6 -= MaxAddressIncrement; } else { bw.Write((byte)2); bw.WriteLeb128(num6); num6 = 0; } } if (num5 < LineBase || num5 >= LineBase + LineRange) { bw.Write((byte)3); bw.WriteLeb128(num5); if (num6 != 0) { bw.Write((byte)2); bw.WriteLeb128(num6); } bw.Write((byte)1); } else { byte value = (byte)(num5 - LineBase + LineRange * num6 + OpcodeBase); bw.Write(value); } num2 = LineNumbers[i].Row; num3 = LineNumbers[i].Offset; } bw.Write((byte)0); bw.Write((byte)1); bw.Write((byte)1); if (hasColumnsInfo) { for (int j = 0; j < LineNumbers.Length; j++) { LineNumberEntry lineNumberEntry = LineNumbers[j]; if (lineNumberEntry.Row >= 0) { bw.WriteLeb128(lineNumberEntry.Column); } } } if (hasEndInfo) { for (int k = 0; k < LineNumbers.Length; k++) { LineNumberEntry lineNumberEntry2 = LineNumbers[k]; if (lineNumberEntry2.EndRow == -1 || lineNumberEntry2.EndColumn == -1 || lineNumberEntry2.Row > lineNumberEntry2.EndRow) { bw.WriteLeb128(16777215); continue; } bw.WriteLeb128(lineNumberEntry2.EndRow - lineNumberEntry2.Row); bw.WriteLeb128(lineNumberEntry2.EndColumn); } } file.ExtendedLineNumberSize += (int)bw.BaseStream.Position - num; } internal static LineNumberTable Read(MonoSymbolFile file, MyBinaryReader br, bool readColumnsInfo, bool readEndInfo) { LineNumberTable lineNumberTable = new LineNumberTable(file); lineNumberTable.DoRead(file, br, readColumnsInfo, readEndInfo); return lineNumberTable; } private void DoRead(MonoSymbolFile file, MyBinaryReader br, bool includesColumns, bool includesEnds) { List list = new List(); bool flag = false; bool flag2 = false; int num = 1; int num2 = 0; int file2 = 1; while (true) { byte b = br.ReadByte(); if (b == 0) { byte b2 = br.ReadByte(); long position = br.BaseStream.Position + b2; b = br.ReadByte(); if (b == 1) { if (flag2) { list.Add(new LineNumberEntry(file2, num, -1, num2, flag)); } break; } if (b == 64) { flag = !flag; flag2 = true; } else if (b < 64 || b > 127) { throw new MonoSymbolFileException("Unknown extended opcode {0:x}", b); } br.BaseStream.Position = position; } else if (b < OpcodeBase) { switch (b) { case 1: list.Add(new LineNumberEntry(file2, num, -1, num2, flag)); flag2 = false; break; case 2: num2 += br.ReadLeb128(); flag2 = true; break; case 3: num += br.ReadLeb128(); flag2 = true; break; case 4: file2 = br.ReadLeb128(); flag2 = true; break; case 8: num2 += MaxAddressIncrement; flag2 = true; break; default: throw new MonoSymbolFileException("Unknown standard opcode {0:x} in LNT", b); } } else { b -= OpcodeBase; num2 += b / LineRange; num += LineBase + b % LineRange; list.Add(new LineNumberEntry(file2, num, -1, num2, flag)); flag2 = false; } } _line_numbers = list.ToArray(); if (includesColumns) { for (int i = 0; i < _line_numbers.Length; i++) { LineNumberEntry lineNumberEntry = _line_numbers[i]; if (lineNumberEntry.Row >= 0) { lineNumberEntry.Column = br.ReadLeb128(); } } } if (!includesEnds) { return; } for (int j = 0; j < _line_numbers.Length; j++) { LineNumberEntry lineNumberEntry2 = _line_numbers[j]; int num3 = br.ReadLeb128(); if (num3 == 16777215) { lineNumberEntry2.EndRow = -1; lineNumberEntry2.EndColumn = -1; } else { lineNumberEntry2.EndRow = lineNumberEntry2.Row + num3; lineNumberEntry2.EndColumn = br.ReadLeb128(); } } } public bool GetMethodBounds(out LineNumberEntry start, out LineNumberEntry end) { if (_line_numbers.Length > 1) { start = _line_numbers[0]; end = _line_numbers[_line_numbers.Length - 1]; return true; } start = LineNumberEntry.Null; end = LineNumberEntry.Null; return false; } } internal class MethodEntry : IComparable { [Flags] public enum Flags { LocalNamesAmbiguous = 1, ColumnsInfoIncluded = 2, EndInfoIncluded = 4 } public readonly int CompileUnitIndex; public readonly int Token; public readonly int NamespaceID; private int DataOffset; private int LocalVariableTableOffset; private int LineNumberTableOffset; private int CodeBlockTableOffset; private int ScopeVariableTableOffset; private int RealNameOffset; private Flags flags; private int index; public readonly CompileUnitEntry CompileUnit; private LocalVariableEntry[] locals; private CodeBlockEntry[] code_blocks; private ScopeVariable[] scope_vars; private LineNumberTable lnt; private string real_name; public readonly MonoSymbolFile SymbolFile; public const int Size = 12; public Flags MethodFlags => flags; public int Index { get { return index; } set { index = value; } } internal MethodEntry(MonoSymbolFile file, MyBinaryReader reader, int index) { SymbolFile = file; this.index = index; Token = reader.ReadInt32(); DataOffset = reader.ReadInt32(); LineNumberTableOffset = reader.ReadInt32(); long position = reader.BaseStream.Position; reader.BaseStream.Position = DataOffset; CompileUnitIndex = reader.ReadLeb128(); LocalVariableTableOffset = reader.ReadLeb128(); NamespaceID = reader.ReadLeb128(); CodeBlockTableOffset = reader.ReadLeb128(); ScopeVariableTableOffset = reader.ReadLeb128(); RealNameOffset = reader.ReadLeb128(); flags = (Flags)reader.ReadLeb128(); reader.BaseStream.Position = position; CompileUnit = file.GetCompileUnit(CompileUnitIndex); } internal MethodEntry(MonoSymbolFile file, CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, Flags flags, int namespace_id) { SymbolFile = file; this.real_name = real_name; this.locals = locals; this.code_blocks = code_blocks; this.scope_vars = scope_vars; this.flags = flags; index = -1; Token = token; CompileUnitIndex = comp_unit.Index; CompileUnit = comp_unit; NamespaceID = namespace_id; CheckLineNumberTable(lines); lnt = new LineNumberTable(file, lines); file.NumLineNumbers += lines.Length; int num = ((locals != null) ? locals.Length : 0); if (num <= 32) { for (int i = 0; i < num; i++) { string name = locals[i].Name; for (int j = i + 1; j < num; j++) { if (locals[j].Name == name) { flags |= Flags.LocalNamesAmbiguous; return; } } } return; } Dictionary dictionary = new Dictionary(); for (int k = 0; k < locals.Length; k++) { LocalVariableEntry value = locals[k]; if (dictionary.ContainsKey(value.Name)) { flags |= Flags.LocalNamesAmbiguous; break; } dictionary.Add(value.Name, value); } } private static void CheckLineNumberTable(LineNumberEntry[] line_numbers) { int num = -1; int num2 = -1; if (line_numbers == null) { return; } foreach (LineNumberEntry lineNumberEntry in line_numbers) { if (lineNumberEntry.Equals(LineNumberEntry.Null)) { throw new MonoSymbolFileException(); } if (lineNumberEntry.Offset < num) { throw new MonoSymbolFileException(); } if (lineNumberEntry.Offset > num) { num2 = lineNumberEntry.Row; num = lineNumberEntry.Offset; } else if (lineNumberEntry.Row > num2) { num2 = lineNumberEntry.Row; } } } internal void Write(MyBinaryWriter bw) { if (index <= 0 || DataOffset == 0) { throw new InvalidOperationException(); } bw.Write(Token); bw.Write(DataOffset); bw.Write(LineNumberTableOffset); } internal void WriteData(MonoSymbolFile file, MyBinaryWriter bw) { if (index <= 0) { throw new InvalidOperationException(); } LocalVariableTableOffset = (int)bw.BaseStream.Position; int num = ((locals != null) ? locals.Length : 0); bw.WriteLeb128(num); for (int i = 0; i < num; i++) { locals[i].Write(file, bw); } file.LocalCount += num; CodeBlockTableOffset = (int)bw.BaseStream.Position; int num2 = ((code_blocks != null) ? code_blocks.Length : 0); bw.WriteLeb128(num2); for (int j = 0; j < num2; j++) { code_blocks[j].Write(bw); } ScopeVariableTableOffset = (int)bw.BaseStream.Position; int num3 = ((scope_vars != null) ? scope_vars.Length : 0); bw.WriteLeb128(num3); for (int k = 0; k < num3; k++) { scope_vars[k].Write(bw); } if (real_name != null) { RealNameOffset = (int)bw.BaseStream.Position; bw.Write(real_name); } LineNumberEntry[] lineNumbers = lnt.LineNumbers; foreach (LineNumberEntry lineNumberEntry in lineNumbers) { if (lineNumberEntry.EndRow != -1 || lineNumberEntry.EndColumn != -1) { flags |= Flags.EndInfoIncluded; } } LineNumberTableOffset = (int)bw.BaseStream.Position; lnt.Write(file, bw, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0); DataOffset = (int)bw.BaseStream.Position; bw.WriteLeb128(CompileUnitIndex); bw.WriteLeb128(LocalVariableTableOffset); bw.WriteLeb128(NamespaceID); bw.WriteLeb128(CodeBlockTableOffset); bw.WriteLeb128(ScopeVariableTableOffset); bw.WriteLeb128(RealNameOffset); bw.WriteLeb128((int)flags); } public void ReadAll() { GetLineNumberTable(); GetLocals(); GetCodeBlocks(); GetScopeVariables(); GetRealName(); } public LineNumberTable GetLineNumberTable() { lock (SymbolFile) { if (lnt != null) { return lnt; } if (LineNumberTableOffset == 0) { return null; } MyBinaryReader binaryReader = SymbolFile.BinaryReader; long position = binaryReader.BaseStream.Position; binaryReader.BaseStream.Position = LineNumberTableOffset; lnt = LineNumberTable.Read(SymbolFile, binaryReader, (flags & Flags.ColumnsInfoIncluded) != 0, (flags & Flags.EndInfoIncluded) != 0); binaryReader.BaseStream.Position = position; return lnt; } } public LocalVariableEntry[] GetLocals() { lock (SymbolFile) { if (locals != null) { return locals; } if (LocalVariableTableOffset == 0) { return null; } MyBinaryReader binaryReader = SymbolFile.BinaryReader; long position = binaryReader.BaseStream.Position; binaryReader.BaseStream.Position = LocalVariableTableOffset; int num = binaryReader.ReadLeb128(); locals = new LocalVariableEntry[num]; for (int i = 0; i < num; i++) { locals[i] = new LocalVariableEntry(SymbolFile, binaryReader); } binaryReader.BaseStream.Position = position; return locals; } } public CodeBlockEntry[] GetCodeBlocks() { lock (SymbolFile) { if (code_blocks != null) { return code_blocks; } if (CodeBlockTableOffset == 0) { return null; } MyBinaryReader binaryReader = SymbolFile.BinaryReader; long position = binaryReader.BaseStream.Position; binaryReader.BaseStream.Position = CodeBlockTableOffset; int num = binaryReader.ReadLeb128(); code_blocks = new CodeBlockEntry[num]; for (int i = 0; i < num; i++) { code_blocks[i] = new CodeBlockEntry(i, binaryReader); } binaryReader.BaseStream.Position = position; return code_blocks; } } public ScopeVariable[] GetScopeVariables() { lock (SymbolFile) { if (scope_vars != null) { return scope_vars; } if (ScopeVariableTableOffset == 0) { return null; } MyBinaryReader binaryReader = SymbolFile.BinaryReader; long position = binaryReader.BaseStream.Position; binaryReader.BaseStream.Position = ScopeVariableTableOffset; int num = binaryReader.ReadLeb128(); scope_vars = new ScopeVariable[num]; for (int i = 0; i < num; i++) { scope_vars[i] = new ScopeVariable(binaryReader); } binaryReader.BaseStream.Position = position; return scope_vars; } } public string GetRealName() { lock (SymbolFile) { if (real_name != null) { return real_name; } if (RealNameOffset == 0) { return null; } real_name = SymbolFile.BinaryReader.ReadString(RealNameOffset); return real_name; } } public int CompareTo(object obj) { MethodEntry methodEntry = (MethodEntry)obj; if (methodEntry.Token < Token) { return 1; } if (methodEntry.Token > Token) { return -1; } return 0; } public override string ToString() { return $"[Method {index}:{Token:x}:{CompileUnitIndex}:{CompileUnit}]"; } } internal struct NamespaceEntry { public readonly string Name; public readonly int Index; public readonly int Parent; public readonly string[] UsingClauses; public NamespaceEntry(string name, int index, string[] using_clauses, int parent) { Name = name; Index = index; Parent = parent; UsingClauses = ((using_clauses != null) ? using_clauses : new string[0]); } internal NamespaceEntry(MonoSymbolFile file, MyBinaryReader reader) { Name = reader.ReadString(); Index = reader.ReadLeb128(); Parent = reader.ReadLeb128(); int num = reader.ReadLeb128(); UsingClauses = new string[num]; for (int i = 0; i < num; i++) { UsingClauses[i] = reader.ReadString(); } } internal void Write(MonoSymbolFile file, MyBinaryWriter bw) { bw.Write(Name); bw.WriteLeb128(Index); bw.WriteLeb128(Parent); bw.WriteLeb128(UsingClauses.Length); string[] usingClauses = UsingClauses; foreach (string value in usingClauses) { bw.Write(value); } } public override string ToString() { return $"[Namespace {Name}:{Index}:{Parent}]"; } } internal class MonoSymbolWriter { private List methods; private List sources; private List comp_units; protected readonly MonoSymbolFile file; private string filename; private SourceMethodBuilder current_method; private Stack current_method_stack = new Stack(); public MonoSymbolFile SymbolFile => file; public MonoSymbolWriter(string filename) { methods = new List(); sources = new List(); comp_units = new List(); file = new MonoSymbolFile(); this.filename = filename + ".mdb"; } public void CloseNamespace() { } public void DefineLocalVariable(int index, string name) { if (current_method != null) { current_method.AddLocal(index, name); } } public void DefineCapturedLocal(int scope_id, string name, string captured_name) { file.DefineCapturedVariable(scope_id, name, captured_name, CapturedVariable.CapturedKind.Local); } public void DefineCapturedParameter(int scope_id, string name, string captured_name) { file.DefineCapturedVariable(scope_id, name, captured_name, CapturedVariable.CapturedKind.Parameter); } public void DefineCapturedThis(int scope_id, string captured_name) { file.DefineCapturedVariable(scope_id, "this", captured_name, CapturedVariable.CapturedKind.This); } public void DefineCapturedScope(int scope_id, int id, string captured_name) { file.DefineCapturedScope(scope_id, id, captured_name); } public void DefineScopeVariable(int scope, int index) { if (current_method != null) { current_method.AddScopeVariable(scope, index); } } public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden) { if (current_method != null) { current_method.MarkSequencePoint(offset, file, line, column, is_hidden); } } public SourceMethodBuilder OpenMethod(ICompileUnit file, int ns_id, IMethodDef method) { SourceMethodBuilder result = new SourceMethodBuilder(file, ns_id, method); current_method_stack.Push(current_method); current_method = result; methods.Add(current_method); return result; } public void CloseMethod() { current_method = current_method_stack.Pop(); } public SourceFileEntry DefineDocument(string url) { SourceFileEntry sourceFileEntry = new SourceFileEntry(file, url); sources.Add(sourceFileEntry); return sourceFileEntry; } public SourceFileEntry DefineDocument(string url, byte[] guid, byte[] checksum) { SourceFileEntry sourceFileEntry = new SourceFileEntry(file, url, guid, checksum); sources.Add(sourceFileEntry); return sourceFileEntry; } public CompileUnitEntry DefineCompilationUnit(SourceFileEntry source) { CompileUnitEntry compileUnitEntry = new CompileUnitEntry(file, source); comp_units.Add(compileUnitEntry); return compileUnitEntry; } public int DefineNamespace(string name, CompileUnitEntry unit, string[] using_clauses, int parent) { if (unit == null || using_clauses == null) { throw new NullReferenceException(); } return unit.DefineNamespace(name, using_clauses, parent); } public int OpenScope(int start_offset) { if (current_method == null) { return 0; } current_method.StartBlock(CodeBlockEntry.Type.Lexical, start_offset); return 0; } public void CloseScope(int end_offset) { if (current_method != null) { current_method.EndBlock(end_offset); } } public void OpenCompilerGeneratedBlock(int start_offset) { if (current_method != null) { current_method.StartBlock(CodeBlockEntry.Type.CompilerGenerated, start_offset); } } public void CloseCompilerGeneratedBlock(int end_offset) { if (current_method != null) { current_method.EndBlock(end_offset); } } public void StartIteratorBody(int start_offset) { current_method.StartBlock(CodeBlockEntry.Type.IteratorBody, start_offset); } public void EndIteratorBody(int end_offset) { current_method.EndBlock(end_offset); } public void StartIteratorDispatcher(int start_offset) { current_method.StartBlock(CodeBlockEntry.Type.IteratorDispatcher, start_offset); } public void EndIteratorDispatcher(int end_offset) { current_method.EndBlock(end_offset); } public void DefineAnonymousScope(int id) { file.DefineAnonymousScope(id); } public void WriteSymbolFile(Guid guid) { foreach (SourceMethodBuilder method in methods) { method.DefineMethod(file); } try { File.Delete(filename); } catch { } using FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write); file.CreateSymbolFile(guid, fs); } } internal class SourceMethodBuilder { private List _locals; private List _blocks; private List _scope_vars; private Stack _block_stack; private readonly List method_lines; private readonly ICompileUnit _comp_unit; private readonly int ns_id; private readonly IMethodDef method; public CodeBlockEntry[] Blocks { get { if (_blocks == null) { return new CodeBlockEntry[0]; } CodeBlockEntry[] array = new CodeBlockEntry[_blocks.Count]; _blocks.CopyTo(array, 0); return array; } } public CodeBlockEntry CurrentBlock { get { if (_block_stack != null && _block_stack.Count > 0) { return _block_stack.Peek(); } return null; } } public LocalVariableEntry[] Locals { get { if (_locals == null) { return new LocalVariableEntry[0]; } return _locals.ToArray(); } } public ICompileUnit SourceFile => _comp_unit; public ScopeVariable[] ScopeVariables { get { if (_scope_vars == null) { return new ScopeVariable[0]; } return _scope_vars.ToArray(); } } public SourceMethodBuilder(ICompileUnit comp_unit) { _comp_unit = comp_unit; method_lines = new List(); } public SourceMethodBuilder(ICompileUnit comp_unit, int ns_id, IMethodDef method) : this(comp_unit) { this.ns_id = ns_id; this.method = method; } public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, bool is_hidden) { MarkSequencePoint(offset, file, line, column, -1, -1, is_hidden); } public void MarkSequencePoint(int offset, SourceFileEntry file, int line, int column, int end_line, int end_column, bool is_hidden) { int file2 = file?.Index ?? 0; LineNumberEntry lineNumberEntry = new LineNumberEntry(file2, line, column, end_line, end_column, offset, is_hidden); if (method_lines.Count > 0) { LineNumberEntry lineNumberEntry2 = method_lines[method_lines.Count - 1]; if (lineNumberEntry2.Offset == offset) { if (LineNumberEntry.LocationComparer.Default.Compare(lineNumberEntry, lineNumberEntry2) > 0) { method_lines[method_lines.Count - 1] = lineNumberEntry; } return; } } method_lines.Add(lineNumberEntry); } public void StartBlock(CodeBlockEntry.Type type, int start_offset) { StartBlock(type, start_offset, (_blocks == null) ? 1 : (_blocks.Count + 1)); } public void StartBlock(CodeBlockEntry.Type type, int start_offset, int scopeIndex) { if (_block_stack == null) { _block_stack = new Stack(); } if (_blocks == null) { _blocks = new List(); } int parent = ((CurrentBlock != null) ? CurrentBlock.Index : (-1)); CodeBlockEntry item = new CodeBlockEntry(scopeIndex, parent, type, start_offset); _block_stack.Push(item); _blocks.Add(item); } public void EndBlock(int end_offset) { CodeBlockEntry codeBlockEntry = _block_stack.Pop(); codeBlockEntry.Close(end_offset); } public void AddLocal(int index, string name) { if (_locals == null) { _locals = new List(); } int block = ((CurrentBlock != null) ? CurrentBlock.Index : 0); _locals.Add(new LocalVariableEntry(index, name, block)); } public void AddScopeVariable(int scope, int index) { if (_scope_vars == null) { _scope_vars = new List(); } _scope_vars.Add(new ScopeVariable(scope, index)); } public void DefineMethod(MonoSymbolFile file) { DefineMethod(file, method.Token); } public void DefineMethod(MonoSymbolFile file, int token) { CodeBlockEntry[] array = Blocks; if (array.Length != 0) { List list = new List(array.Length); int num = 0; for (int i = 0; i < array.Length; i++) { num = Math.Max(num, array[i].Index); } for (int j = 0; j < num; j++) { int num2 = j + 1; if (j < array.Length && array[j].Index == num2) { list.Add(array[j]); continue; } bool flag = false; for (int k = 0; k < array.Length; k++) { if (array[k].Index == num2) { list.Add(array[k]); flag = true; break; } } if (!flag) { list.Add(new CodeBlockEntry(num2, -1, CodeBlockEntry.Type.CompilerGenerated, 0)); } } array = list.ToArray(); } MethodEntry entry = new MethodEntry(file, _comp_unit.Entry, token, ScopeVariables, Locals, method_lines.ToArray(), array, null, MethodEntry.Flags.ColumnsInfoIncluded, ns_id); file.AddMethod(entry); } } internal class SymbolWriterImpl : ISymbolWriter { private delegate Guid GetGuidFunc(ModuleBuilder mb); private MonoSymbolWriter msw; private int nextLocalIndex; private int currentToken; private string methodName; private Stack namespaceStack = new Stack(); private bool methodOpened; private Hashtable documents = new Hashtable(); private ModuleBuilder mb; private GetGuidFunc get_guid_func; public SymbolWriterImpl(ModuleBuilder mb) { this.mb = mb; } public void Close() { MethodInfo method = typeof(ModuleBuilder).GetMethod("Mono_GetGuid", BindingFlags.Static | BindingFlags.NonPublic); if ((object)method != null) { get_guid_func = (GetGuidFunc)System.Delegate.CreateDelegate(typeof(GetGuidFunc), method); msw.WriteSymbolFile(get_guid_func(mb)); } } public void CloseMethod() { if (methodOpened) { methodOpened = false; nextLocalIndex = 0; msw.CloseMethod(); } } public void CloseNamespace() { namespaceStack.Pop(); msw.CloseNamespace(); } public void CloseScope(int endOffset) { msw.CloseScope(endOffset); } public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType) { SymbolDocumentWriterImpl symbolDocumentWriterImpl = (SymbolDocumentWriterImpl)documents[url]; if (symbolDocumentWriterImpl == null) { SourceFileEntry source = msw.DefineDocument(url); CompileUnitEntry comp_unit = msw.DefineCompilationUnit(source); symbolDocumentWriterImpl = new SymbolDocumentWriterImpl(comp_unit); documents[url] = symbolDocumentWriterImpl; } return symbolDocumentWriterImpl; } public void DefineField(SymbolToken parent, string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3) { } public void DefineGlobalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3) { } public void DefineLocalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, int addr1, int addr2, int addr3, int startOffset, int endOffset) { msw.DefineLocalVariable(nextLocalIndex++, name); } public void DefineParameter(string name, ParameterAttributes attributes, int sequence, SymAddressKind addrKind, int addr1, int addr2, int addr3) { } public void DefineSequencePoints(ISymbolDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns) { SourceFileEntry file = ((SymbolDocumentWriterImpl)document)?.Entry.SourceFile; for (int i = 0; i < offsets.Length; i++) { if (i <= 0 || offsets[i] != offsets[i - 1] || lines[i] != lines[i - 1] || columns[i] != columns[i - 1]) { msw.MarkSequencePoint(offsets[i], file, lines[i], columns[i], is_hidden: false); } } } public void Initialize(IntPtr emitter, string filename, bool fFullBuild) { msw = new MonoSymbolWriter(filename); } public void OpenMethod(SymbolToken method) { currentToken = method.GetToken(); } public void OpenNamespace(string name) { NamespaceInfo namespaceInfo = new NamespaceInfo(); namespaceInfo.NamespaceID = -1; namespaceInfo.Name = name; namespaceStack.Push(namespaceInfo); } public int OpenScope(int startOffset) { return msw.OpenScope(startOffset); } public void SetMethodSourceRange(ISymbolDocumentWriter startDoc, int startLine, int startColumn, ISymbolDocumentWriter endDoc, int endLine, int endColumn) { int currentNamespace = GetCurrentNamespace(startDoc); SourceMethodImpl method = new SourceMethodImpl(methodName, currentToken, currentNamespace); msw.OpenMethod(((ICompileUnit)startDoc).Entry, currentNamespace, method); methodOpened = true; } public void SetScopeRange(int scopeID, int startOffset, int endOffset) { } public void SetSymAttribute(SymbolToken parent, string name, byte[] data) { if (name == "__name") { methodName = Encoding.UTF8.GetString(data); } } public void SetUnderlyingWriter(IntPtr underlyingWriter) { } public void SetUserEntryPoint(SymbolToken entryMethod) { } public void UsingNamespace(string fullName) { if (namespaceStack.Count == 0) { OpenNamespace(""); } NamespaceInfo namespaceInfo = (NamespaceInfo)namespaceStack.Peek(); if (namespaceInfo.NamespaceID != -1) { NamespaceInfo namespaceInfo2 = namespaceInfo; CloseNamespace(); OpenNamespace(namespaceInfo2.Name); namespaceInfo = (NamespaceInfo)namespaceStack.Peek(); namespaceInfo.UsingClauses = namespaceInfo2.UsingClauses; } namespaceInfo.UsingClauses.Add(fullName); } private int GetCurrentNamespace(ISymbolDocumentWriter doc) { if (namespaceStack.Count == 0) { OpenNamespace(""); } NamespaceInfo namespaceInfo = (NamespaceInfo)namespaceStack.Peek(); if (namespaceInfo.NamespaceID == -1) { string[] using_clauses = (string[])namespaceInfo.UsingClauses.ToArray(typeof(string)); int parent = 0; if (namespaceStack.Count > 1) { namespaceStack.Pop(); parent = ((NamespaceInfo)namespaceStack.Peek()).NamespaceID; namespaceStack.Push(namespaceInfo); } namespaceInfo.NamespaceID = msw.DefineNamespace(namespaceInfo.Name, ((ICompileUnit)doc).Entry, using_clauses, parent); } return namespaceInfo.NamespaceID; } } internal class SymbolDocumentWriterImpl : ISymbolDocumentWriter, ISourceFile, ICompileUnit { private CompileUnitEntry comp_unit; SourceFileEntry ISourceFile.Entry => comp_unit.SourceFile; public CompileUnitEntry Entry => comp_unit; public SymbolDocumentWriterImpl(CompileUnitEntry comp_unit) { this.comp_unit = comp_unit; } public void SetCheckSum(Guid algorithmId, byte[] checkSum) { } public void SetSource(byte[] source) { } } internal class SourceMethodImpl : IMethodDef { private string name; private int token; private int namespaceID; public string Name => name; public int NamespaceID => namespaceID; public int Token => token; public SourceMethodImpl(string name, int token, int namespaceID) { this.name = name; this.token = token; this.namespaceID = namespaceID; } } internal class NamespaceInfo { public string Name; public int NamespaceID; public ArrayList UsingClauses = new ArrayList(); } } namespace Mono.CSharp { internal abstract class CompilerGeneratedContainer : ClassOrStruct { protected CompilerGeneratedContainer(TypeContainer parent, MemberName name, Modifiers mod) : this(parent, name, mod, MemberKind.Class) { } protected CompilerGeneratedContainer(TypeContainer parent, MemberName name, Modifiers mod, MemberKind kind) : base(parent, name, null, kind) { base.ModFlags = mod | Modifiers.COMPILER_GENERATED | Modifiers.SEALED; spec = new TypeSpec(Kind, null, this, null, base.ModFlags); } protected void CheckMembersDefined() { if (base.HasMembersDefined) { throw new InternalErrorException("Helper class already defined!"); } } protected override bool DoDefineMembers() { if (Kind == MemberKind.Class && !base.IsStatic && !base.PartialContainer.HasInstanceConstructor) { DefineDefaultConstructor(is_static: false); } return base.DoDefineMembers(); } protected static MemberName MakeMemberName(MemberBase host, string name, int unique_id, TypeParameters tparams, Location loc) { string host2 = ((host == null) ? null : ((host is InterfaceMemberBase) ? ((InterfaceMemberBase)host).GetFullName(host.MemberName) : host.MemberName.Name)); string name2 = MakeName(host2, "c", name, unique_id); TypeParameters typeParameters = null; if (tparams != null) { typeParameters = new TypeParameters(tparams.Count); for (int i = 0; i < tparams.Count; i++) { typeParameters.Add((TypeParameter)null); } } return new MemberName(name2, typeParameters, loc); } public static string MakeName(string host, string typePrefix, string name, int id) { return "<" + host + ">" + typePrefix + "__" + name + id.ToString("X"); } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { base_type = Compiler.BuiltinTypes.Object; base_class = null; return null; } } internal class HoistedStoreyClass : CompilerGeneratedContainer { public sealed class HoistedField : Field { public HoistedField(HoistedStoreyClass parent, FullNamedExpression type, Modifiers mod, string name, Attributes attrs, Location loc) : base(parent, type, mod, new MemberName(name, loc), attrs) { } protected override bool ResolveMemberType() { if (!base.ResolveMemberType()) { return false; } HoistedStoreyClass genericStorey = ((HoistedStoreyClass)Parent).GetGenericStorey(); if (genericStorey != null && genericStorey.Mutator != null) { member_type = genericStorey.Mutator.Mutate(base.MemberType); } return true; } } protected TypeParameterMutator mutator; public TypeParameterMutator Mutator { get { return mutator; } set { mutator = value; } } public HoistedStoreyClass(TypeDefinition parent, MemberName name, TypeParameters tparams, Modifiers mods, MemberKind kind) : base(parent, name, mods | Modifiers.PRIVATE, kind) { if (tparams != null) { TypeParameters typeParameters = name.TypeParameters; TypeParameterSpec[] array = new TypeParameterSpec[tparams.Count]; TypeParameterSpec[] array2 = new TypeParameterSpec[tparams.Count]; for (int i = 0; i < tparams.Count; i++) { typeParameters[i] = tparams[i].CreateHoistedCopy(spec); array[i] = tparams[i].Type; array2[i] = typeParameters[i].Type; } TypeSpec[] targs = array2; TypeParameterInflator inflator = new TypeParameterInflator(this, null, array, targs); for (int j = 0; j < tparams.Count; j++) { array[j].InflateConstraints(inflator, array2[j]); } mutator = new TypeParameterMutator(tparams, typeParameters); } } public HoistedStoreyClass GetGenericStorey() { TypeContainer typeContainer = this; while (typeContainer != null && typeContainer.CurrentTypeParameters == null) { typeContainer = typeContainer.Parent; } return typeContainer as HoistedStoreyClass; } } internal class AnonymousMethodStorey : HoistedStoreyClass { private struct StoreyFieldPair { public readonly AnonymousMethodStorey Storey; public readonly Field Field; public StoreyFieldPair(AnonymousMethodStorey storey, Field field) { Storey = storey; Field = field; } } private sealed class ThisInitializer : Statement { private readonly HoistedThis hoisted_this; private readonly AnonymousMethodStorey parent; public ThisInitializer(HoistedThis hoisted_this, AnonymousMethodStorey parent) { this.hoisted_this = hoisted_this; this.parent = parent; } protected override void DoEmit(EmitContext ec) { Expression source = ((parent != null) ? ((Expression)new FieldExpr(parent.HoistedThis.Field, Location.Null) { InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, Location.Null) }) : ((Expression)new CompilerGeneratedThis(ec.CurrentType, loc))); hoisted_this.EmitAssign(ec, source, leave_copy: false, isCompound: false); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return false; } protected override void CloneTo(CloneContext clonectx, Statement target) { } } public readonly int ID; public readonly ExplicitBlock OriginalSourceBlock; private List used_parent_storeys; private List children_references; protected List hoisted_params; private List hoisted_local_params; protected List hoisted_locals; protected HoistedThis hoisted_this; public Expression Instance; private bool initialize_hoisted_this; private AnonymousMethodStorey hoisted_this_parent; public HoistedThis HoistedThis { get { return hoisted_this; } set { hoisted_this = value; } } public IList ReferencesFromChildrenBlock => children_references; public AnonymousMethodStorey(ExplicitBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind) : base(parent, CompilerGeneratedContainer.MakeMemberName(host, name, parent.PartialContainer.CounterAnonymousContainers, tparams, block.StartLocation), tparams, (Modifiers)0, kind) { OriginalSourceBlock = block; ID = parent.PartialContainer.CounterAnonymousContainers++; } public void AddCapturedThisField(EmitContext ec, AnonymousMethodStorey parent) { TypeExpr type = new TypeExpression(ec.CurrentType, base.Location); Field field = AddCompilerGeneratedField("$this", type); hoisted_this = new HoistedThis(this, field); initialize_hoisted_this = true; hoisted_this_parent = parent; } public Field AddCapturedVariable(string name, TypeSpec type) { CheckMembersDefined(); FullNamedExpression type2 = new TypeExpression(type, base.Location); if (!spec.IsGenericOrParentIsGeneric) { return AddCompilerGeneratedField(name, type2); } Field field = new HoistedField(this, type2, Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED, name, null, base.Location); AddField(field); return field; } protected Field AddCompilerGeneratedField(string name, FullNamedExpression type) { return AddCompilerGeneratedField(name, type, privateAccess: false); } protected Field AddCompilerGeneratedField(string name, FullNamedExpression type, bool privateAccess) { Modifiers mod = (Modifiers)(0x100000 | (privateAccess ? 4 : 8)); Field field = new Field(this, type, mod, new MemberName(name, base.Location), null); AddField(field); return field; } public void AddReferenceFromChildrenBlock(ExplicitBlock block) { if (children_references == null) { children_references = new List(); } if (!children_references.Contains(block)) { children_references.Add(block); } } public void AddParentStoreyReference(EmitContext ec, AnonymousMethodStorey storey) { CheckMembersDefined(); if (used_parent_storeys == null) { used_parent_storeys = new List(); } else if (used_parent_storeys.Exists((StoreyFieldPair i) => i.Storey == storey)) { return; } TypeExpr type = storey.CreateStoreyTypeExpression(ec); int iD = storey.ID; Field field = AddCompilerGeneratedField("<>f__ref$" + iD, type); used_parent_storeys.Add(new StoreyFieldPair(storey, field)); } public void CaptureLocalVariable(ResolveContext ec, LocalVariable localVariable) { if (this is StateMachine) { if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock) { ec.CurrentBlock.Explicit.HasCapturedVariable = true; } } else { ec.CurrentBlock.Explicit.HasCapturedVariable = true; } HoistedVariable hoistedVariable = localVariable.HoistedVariant; if (hoistedVariable != null && hoistedVariable.Storey != this && hoistedVariable.Storey is StateMachine) { hoistedVariable.Storey.hoisted_locals.Remove(hoistedVariable); hoistedVariable.Storey.Members.Remove(hoistedVariable.Field); hoistedVariable = null; } if (hoistedVariable == null) { hoistedVariable = (localVariable.HoistedVariant = new HoistedLocalVariable(this, localVariable, GetVariableMangledName(ec, localVariable))); if (hoisted_locals == null) { hoisted_locals = new List(); } hoisted_locals.Add(hoistedVariable); } if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoistedVariable.Storey is StateMachine) && hoistedVariable.Storey != null) { hoistedVariable.Storey.AddReferenceFromChildrenBlock(ec.CurrentBlock.Explicit); } } public void CaptureParameter(ResolveContext ec, ParametersBlock.ParameterInfo parameterInfo, ParameterReference parameterReference) { if (!(this is StateMachine)) { ec.CurrentBlock.Explicit.HasCapturedVariable = true; } HoistedParameter hoistedParameter = parameterInfo.Parameter.HoistedVariant; if (parameterInfo.Block.StateMachine != null) { if (hoistedParameter == null && parameterInfo.Block.StateMachine != this) { StateMachine stateMachine = parameterInfo.Block.StateMachine; hoistedParameter = new HoistedParameter(stateMachine, parameterReference); parameterInfo.Parameter.HoistedVariant = hoistedParameter; if (stateMachine.hoisted_params == null) { stateMachine.hoisted_params = new List(); } stateMachine.hoisted_params.Add(hoistedParameter); } if (hoistedParameter != null && hoistedParameter.Storey != this && hoistedParameter.Storey is StateMachine) { if (hoisted_local_params == null) { hoisted_local_params = new List(); } hoisted_local_params.Add(hoistedParameter); hoistedParameter = null; } } if (hoistedParameter == null) { hoistedParameter = new HoistedParameter(this, parameterReference); parameterInfo.Parameter.HoistedVariant = hoistedParameter; if (hoisted_params == null) { hoisted_params = new List(); } hoisted_params.Add(hoistedParameter); } if (ec.CurrentBlock.Explicit != parameterInfo.Block) { hoistedParameter.Storey.AddReferenceFromChildrenBlock(ec.CurrentBlock.Explicit); } } private TypeExpr CreateStoreyTypeExpression(EmitContext ec) { if (CurrentTypeParameters != null) { TypeParameters typeParameters = ((ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null) ? ec.CurrentAnonymousMethod.Storey.CurrentTypeParameters : ec.CurrentTypeParameters); TypeArguments typeArguments = new TypeArguments(); for (int i = 0; i < typeParameters.Count; i++) { typeArguments.Add(new SimpleName(typeParameters[i].Name, base.Location)); } return new GenericTypeExpr(base.Definition, typeArguments, base.Location); } return new TypeExpression(CurrentType, base.Location); } public void SetNestedStoryParent(AnonymousMethodStorey parentStorey) { Parent = parentStorey; spec.IsGeneric = false; spec.DeclaringType = parentStorey.CurrentType; base.MemberName.TypeParameters = null; } protected override bool DoResolveTypeParameters() { if (CurrentTypeParameters != null) { for (int i = 0; i < CurrentTypeParameters.Count; i++) { TypeParameterSpec type = CurrentTypeParameters[i].Type; type.BaseType = mutator.Mutate(type.BaseType); if (type.InterfacesDefined != null) { TypeSpec[] array = new TypeSpec[type.InterfacesDefined.Length]; for (int j = 0; j < array.Length; j++) { array[j] = mutator.Mutate(type.InterfacesDefined[j]); } type.InterfacesDefined = array; } if (type.TypeArguments != null) { type.TypeArguments = mutator.Mutate(type.TypeArguments); } } } Parent.CurrentType.MemberCache.AddMember(spec); return true; } public void EmitStoreyInstantiation(EmitContext ec, ExplicitBlock block) { if (Instance != null) { throw new InternalErrorException(); } ResolveContext resolveContext = new ResolveContext(ec.MemberContext); resolveContext.CurrentBlock = block; TypeExpr typeExpr = CreateStoreyTypeExpression(ec); Expression expression = new New(typeExpr, null, base.Location).Resolve(resolveContext); if (ec.CurrentAnonymousMethod is StateMachineInitializer && (block.HasYield || block.HasAwait)) { Field field = ec.CurrentAnonymousMethod.Storey.AddCompilerGeneratedField(LocalVariable.GetCompilerGeneratedName(block), typeExpr, privateAccess: true); field.Define(); field.Emit(); FieldExpr fieldExpr = new FieldExpr(field, base.Location); fieldExpr.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, base.Location); fieldExpr.EmitAssign(ec, expression, leave_copy: false, isCompound: false); Instance = fieldExpr; } else { TemporaryVariableReference temporaryVariableReference = TemporaryVariableReference.Create(expression.Type, block, base.Location, writeToSymbolFile: true); if (expression.Type.IsStruct) { temporaryVariableReference.LocalInfo.CreateBuilder(ec); } else { temporaryVariableReference.EmitAssign(ec, expression); } Instance = temporaryVariableReference; } EmitHoistedFieldsInitialization(resolveContext, ec); } private void EmitHoistedFieldsInitialization(ResolveContext rc, EmitContext ec) { if (used_parent_storeys != null) { foreach (StoreyFieldPair used_parent_storey in used_parent_storeys) { Expression storeyInstanceExpression = GetStoreyInstanceExpression(ec); FieldSpec member = used_parent_storey.Field.Spec; if (TypeManager.IsGenericType(storeyInstanceExpression.Type)) { member = MemberCache.GetMember(storeyInstanceExpression.Type, member); } FieldExpr fieldExpr = new FieldExpr(member, base.Location); fieldExpr.InstanceExpression = storeyInstanceExpression; SimpleAssign simpleAssign = new SimpleAssign(fieldExpr, used_parent_storey.Storey.GetStoreyInstanceExpression(ec)); if (simpleAssign.Resolve(rc) != null) { simpleAssign.EmitStatement(ec); } } } if (initialize_hoisted_this) { rc.CurrentBlock.AddScopeStatement(new ThisInitializer(hoisted_this, hoisted_this_parent)); } AnonymousExpression currentAnonymousMethod = ec.CurrentAnonymousMethod; ec.CurrentAnonymousMethod = null; if (hoisted_params != null) { EmitHoistedParameters(ec, hoisted_params); } ec.CurrentAnonymousMethod = currentAnonymousMethod; } protected virtual void EmitHoistedParameters(EmitContext ec, List hoisted) { foreach (HoistedParameter hp in hoisted) { if (hp == null) { continue; } if (hoisted_local_params != null) { HoistedParameter hoistedParameter = hoisted_local_params.Find((HoistedParameter l) => l.Parameter.Parameter == hp.Parameter.Parameter); FieldExpr fieldExpr = new FieldExpr(hoistedParameter.Field, base.Location); fieldExpr.InstanceExpression = new CompilerGeneratedThis(CurrentType, base.Location); hp.EmitAssign(ec, fieldExpr, leave_copy: false, isCompound: false); } else { hp.EmitHoistingAssignment(ec); } } } private Field GetReferencedStoreyField(AnonymousMethodStorey storey) { if (used_parent_storeys == null) { return null; } foreach (StoreyFieldPair used_parent_storey in used_parent_storeys) { if (used_parent_storey.Storey == storey) { return used_parent_storey.Field; } } return null; } public Expression GetStoreyInstanceExpression(EmitContext ec) { AnonymousExpression currentAnonymousMethod = ec.CurrentAnonymousMethod; if (currentAnonymousMethod == null) { return Instance; } if (currentAnonymousMethod.Storey == null) { return Instance; } Field referencedStoreyField = currentAnonymousMethod.Storey.GetReferencedStoreyField(this); if (referencedStoreyField == null) { if (currentAnonymousMethod.Storey == this) { return new CompilerGeneratedThis(CurrentType, base.Location); } return Instance; } FieldExpr fieldExpr = new FieldExpr(referencedStoreyField, base.Location); fieldExpr.InstanceExpression = new CompilerGeneratedThis(CurrentType, base.Location); return fieldExpr; } protected virtual string GetVariableMangledName(ResolveContext rc, LocalVariable local_info) { return local_info.Name; } } internal abstract class HoistedVariable { private class ExpressionTreeVariableReference : Expression { private readonly HoistedVariable hv; public ExpressionTreeVariableReference(HoistedVariable hv) { this.hv = hv; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { return hv.CreateExpressionTree(); } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Value; type = ec.Module.PredefinedTypes.Expression.Resolve(); return this; } public override void Emit(EmitContext ec) { ResolveContext resolveContext = new ResolveContext(ec.MemberContext); Expression expression = hv.GetFieldExpression(ec).CreateExpressionTree(resolveContext, convertInstance: false); expression.Resolve(resolveContext)?.Emit(ec); } } protected readonly AnonymousMethodStorey storey; protected Field field; private Dictionary cached_inner_access; private FieldExpr cached_outer_access; public Field Field => field; public AnonymousMethodStorey Storey => storey; protected HoistedVariable(AnonymousMethodStorey storey, string name, TypeSpec type) : this(storey, storey.AddCapturedVariable(name, type)) { } protected HoistedVariable(AnonymousMethodStorey storey, Field field) { this.storey = storey; this.field = field; } public void AddressOf(EmitContext ec, AddressOp mode) { GetFieldExpression(ec).AddressOf(ec, mode); } public Expression CreateExpressionTree() { return new ExpressionTreeVariableReference(this); } public void Emit(EmitContext ec) { GetFieldExpression(ec).Emit(ec); } public Expression EmitToField(EmitContext ec) { return GetFieldExpression(ec); } protected virtual FieldExpr GetFieldExpression(EmitContext ec) { if (ec.CurrentAnonymousMethod == null || ec.CurrentAnonymousMethod.Storey == null) { if (cached_outer_access != null) { return cached_outer_access; } if (storey.Instance.Type.IsGenericOrParentIsGeneric) { FieldSpec member = MemberCache.GetMember(storey.Instance.Type, field.Spec); cached_outer_access = new FieldExpr(member, field.Location); } else { cached_outer_access = new FieldExpr(field, field.Location); } cached_outer_access.InstanceExpression = storey.GetStoreyInstanceExpression(ec); return cached_outer_access; } FieldExpr value; if (cached_inner_access != null) { if (!cached_inner_access.TryGetValue(ec.CurrentAnonymousMethod, out value)) { value = null; } } else { value = null; cached_inner_access = new Dictionary(4); } if (value == null) { if (field.Parent.IsGenericOrParentIsGeneric) { FieldSpec member2 = MemberCache.GetMember(field.Parent.CurrentType, field.Spec); value = new FieldExpr(member2, field.Location); } else { value = new FieldExpr(field, field.Location); } value.InstanceExpression = storey.GetStoreyInstanceExpression(ec); cached_inner_access.Add(ec.CurrentAnonymousMethod, value); } return value; } public void Emit(EmitContext ec, bool leave_copy) { GetFieldExpression(ec).Emit(ec, leave_copy); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { GetFieldExpression(ec).EmitAssign(ec, source, leave_copy, isCompound: false); } public void EmitAssignFromStack(EmitContext ec) { GetFieldExpression(ec).EmitAssignFromStack(ec); } } internal class HoistedParameter : HoistedVariable { private sealed class HoistedFieldAssign : CompilerAssign { public HoistedFieldAssign(Expression target, Expression source) : base(target, source, target.Location) { } protected override Expression ResolveConversions(ResolveContext ec) { return this; } } private readonly ParameterReference parameter; public bool IsAssigned { get; set; } public ParameterReference Parameter => parameter; public HoistedParameter(AnonymousMethodStorey scope, ParameterReference par) : base(scope, par.Name, par.Type) { parameter = par; } public HoistedParameter(HoistedParameter hp, string name) : base(hp.storey, name, hp.parameter.Type) { parameter = hp.parameter; } public void EmitHoistingAssignment(EmitContext ec) { HoistedParameter hoistedVariant = parameter.Parameter.HoistedVariant; parameter.Parameter.HoistedVariant = null; HoistedFieldAssign hoistedFieldAssign = new HoistedFieldAssign(GetFieldExpression(ec), parameter); hoistedFieldAssign.EmitStatement(ec); parameter.Parameter.HoistedVariant = hoistedVariant; } } internal class HoistedLocalVariable : HoistedVariable { public HoistedLocalVariable(AnonymousMethodStorey storey, LocalVariable local, string name) : base(storey, name, local.Type) { } } internal class HoistedThis : HoistedVariable { public HoistedThis(AnonymousMethodStorey storey, Field field) : base(storey, field) { } } internal class AnonymousMethodExpression : Expression { private class Quote : ShimExpression { public Quote(Expression expr) : base(expr) { } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(expr.CreateExpressionTree(ec))); return CreateExpressionFactoryCall(ec, "Quote", arguments); } protected override Expression DoResolve(ResolveContext rc) { expr = expr.Resolve(rc); if (expr == null) { return null; } eclass = expr.eclass; type = expr.Type; return this; } } private readonly Dictionary compatibles; public ParametersBlock Block; public override string ExprClassName => "anonymous method"; public virtual bool HasExplicitParameters => Parameters != ParametersCompiled.Undefined; public override bool IsSideEffectFree => true; public ParametersCompiled Parameters => Block.Parameters; public ReportPrinter TypeInferenceReportPrinter { get; set; } public AnonymousMethodExpression(Location loc) { base.loc = loc; compatibles = new Dictionary(); } public bool ImplicitStandardConversionExists(ResolveContext ec, TypeSpec delegate_type) { using (ec.With(ResolveContext.Options.InferReturnType, enable: false)) { using (ec.Set(ResolveContext.Options.ProbingMode)) { ReportPrinter printer = ec.Report.SetPrinter(TypeInferenceReportPrinter ?? new NullReportPrinter()); bool result = Compatible(ec, delegate_type) != null; ec.Report.SetPrinter(printer); return result; } } } private TypeSpec CompatibleChecks(ResolveContext ec, TypeSpec delegate_type) { if (delegate_type.IsDelegate) { return delegate_type; } if (delegate_type.IsExpressionTreeType) { delegate_type = delegate_type.TypeArguments[0]; if (delegate_type.IsDelegate) { return delegate_type; } ec.Report.Error(835, loc, "Cannot convert `{0}' to an expression tree of non-delegate type `{1}'", GetSignatureForError(), delegate_type.GetSignatureForError()); return null; } ec.Report.Error(1660, loc, "Cannot convert `{0}' to non-delegate type `{1}'", GetSignatureForError(), delegate_type.GetSignatureForError()); return null; } protected bool VerifyExplicitParameters(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type, AParametersCollection parameters) { if (VerifyParameterCompatibility(ec, tic, delegate_type, parameters, ec.IsInProbingMode)) { return true; } if (!ec.IsInProbingMode) { ec.Report.Error(1661, loc, "Cannot convert `{0}' to delegate type `{1}' since there is a parameter mismatch", GetSignatureForError(), delegate_type.GetSignatureForError()); } return false; } protected bool VerifyParameterCompatibility(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type, AParametersCollection invoke_pd, bool ignore_errors) { if (Parameters.Count != invoke_pd.Count) { if (ignore_errors) { return false; } ec.Report.Error(1593, loc, "Delegate `{0}' does not take `{1}' arguments", delegate_type.GetSignatureForError(), Parameters.Count.ToString()); return false; } bool flag = !HasExplicitParameters; bool flag2 = false; for (int i = 0; i < Parameters.Count; i++) { Parameter.Modifier modFlags = invoke_pd.FixedParameters[i].ModFlags; if (Parameters.FixedParameters[i].ModFlags != modFlags && modFlags != Parameter.Modifier.PARAMS) { if (ignore_errors) { return false; } if (modFlags == Parameter.Modifier.NONE) { ec.Report.Error(1677, Parameters[i].Location, "Parameter `{0}' should not be declared with the `{1}' keyword", (i + 1).ToString(), Parameter.GetModifierSignature(Parameters[i].ModFlags)); } else { ec.Report.Error(1676, Parameters[i].Location, "Parameter `{0}' must be declared with the `{1}' keyword", (i + 1).ToString(), Parameter.GetModifierSignature(modFlags)); } flag2 = true; } if (flag) { continue; } TypeSpec typeSpec = invoke_pd.Types[i]; if (tic != null) { typeSpec = tic.InflateGenericArgument(ec, typeSpec); } if (!TypeSpecComparer.IsEqual(typeSpec, Parameters.Types[i])) { if (ignore_errors) { return false; } ec.Report.Error(1678, Parameters[i].Location, "Parameter `{0}' is declared as type `{1}' but should be `{2}'", (i + 1).ToString(), Parameters.Types[i].GetSignatureForError(), invoke_pd.Types[i].GetSignatureForError()); flag2 = true; } } return !flag2; } public bool ExplicitTypeInference(TypeInferenceContext type_inference, TypeSpec delegate_type) { if (!HasExplicitParameters) { return false; } if (!delegate_type.IsDelegate) { if (!delegate_type.IsExpressionTreeType) { return false; } delegate_type = TypeManager.GetTypeArguments(delegate_type)[0]; if (!delegate_type.IsDelegate) { return false; } } AParametersCollection parameters = Delegate.GetParameters(delegate_type); if (parameters.Count != Parameters.Count) { return false; } TypeSpec[] types = Parameters.Types; TypeSpec[] types2 = parameters.Types; for (int i = 0; i < Parameters.Count; i++) { if (type_inference.ExactInference(types[i], types2[i]) == 0 && types[i] != types2[i]) { return false; } } return true; } public TypeSpec InferReturnType(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type) { if (compatibles.TryGetValue(delegate_type, out var value)) { return (!(value is AnonymousExpression anonymousExpression)) ? null : anonymousExpression.ReturnType; } AnonymousExpression anonymousExpression2; using (ec.Set(ResolveContext.Options.ProbingMode | ResolveContext.Options.InferReturnType)) { ReportPrinter printer = ((TypeInferenceReportPrinter == null) ? null : ec.Report.SetPrinter(TypeInferenceReportPrinter)); HashSet undeclaredVariables = null; AnonymousMethodBody anonymousMethodBody = CompatibleMethodBody(ec, tic, null, delegate_type, ref undeclaredVariables); anonymousExpression2 = anonymousMethodBody?.Compatible(ec, anonymousMethodBody); if (TypeInferenceReportPrinter != null) { ec.Report.SetPrinter(printer); } if (undeclaredVariables != null) { anonymousMethodBody.Block.TopBlock.SetUndeclaredVariables(undeclaredVariables); } } return anonymousExpression2?.ReturnType; } public override bool ContainsEmitWithAwait() { return false; } public Expression Compatible(ResolveContext ec, TypeSpec type) { if (compatibles.TryGetValue(type, out var value)) { return value; } if (type == InternalType.ErrorType) { return null; } TypeSpec typeSpec = CompatibleChecks(ec, type); if (typeSpec == null) { return null; } MethodSpec invokeMethod = Delegate.GetInvokeMethod(typeSpec); TypeSpec returnType = invokeMethod.ReturnType; HashSet undeclaredVariables = null; AnonymousMethodBody anonymousMethodBody = CompatibleMethodBody(ec, null, returnType, typeSpec, ref undeclaredVariables); if (anonymousMethodBody == null) { return null; } bool flag = typeSpec != type; try { if (flag) { if (ec.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { value = anonymousMethodBody.Compatible(ec, ec.CurrentAnonymousMethod); if (value != null) { value = new Quote(value); } } else { int errors = ec.Report.Errors; if (Block.IsAsync) { ec.Report.Error(1989, loc, "Async lambda expressions cannot be converted to expression trees"); } using (ec.Set(ResolveContext.Options.ExpressionTreeConversion)) { value = anonymousMethodBody.Compatible(ec); } if (value != null && errors == ec.Report.Errors) { value = CreateExpressionTree(ec, typeSpec); } } } else { value = anonymousMethodBody.Compatible(ec); if (anonymousMethodBody.DirectMethodGroupConversion != null) { SessionReportPrinter sessionReportPrinter = new SessionReportPrinter(); ReportPrinter printer = ec.Report.SetPrinter(sessionReportPrinter); Expression expression = new ImplicitDelegateCreation(typeSpec, anonymousMethodBody.DirectMethodGroupConversion, loc) { AllowSpecialMethodsInvocation = true }.Resolve(ec); ec.Report.SetPrinter(printer); if (expression != null && sessionReportPrinter.ErrorsCount == 0) { value = expression; } } } } catch (CompletionResult) { throw; } catch (FatalException) { throw; } catch (Exception e) { throw new InternalErrorException(e, loc); } finally { if (undeclaredVariables != null) { anonymousMethodBody.Block.TopBlock.SetUndeclaredVariables(undeclaredVariables); } } if (!ec.IsInProbingMode && !flag) { compatibles.Add(type, value ?? EmptyExpression.Null); } return value; } protected virtual Expression CreateExpressionTree(ResolveContext ec, TypeSpec delegate_type) { return CreateExpressionTree(ec); } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(1946, loc, "An anonymous method cannot be converted to an expression tree"); return null; } protected virtual ParametersCompiled ResolveParameters(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegate_type) { AParametersCollection parameters = Delegate.GetParameters(delegate_type); if (Parameters == ParametersCompiled.Undefined) { Parameter[] array = new Parameter[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { Parameter.Modifier modFlags = parameters.FixedParameters[i].ModFlags; if ((modFlags & Parameter.Modifier.OUT) != Parameter.Modifier.NONE) { if (!ec.IsInProbingMode) { ec.Report.Error(1688, loc, "Cannot convert anonymous method block without a parameter list to delegate type `{0}' because it has one or more `out' parameters", delegate_type.GetSignatureForError()); } return null; } array[i] = new Parameter(new TypeExpression(parameters.Types[i], loc), null, parameters.FixedParameters[i].ModFlags, null, loc); } return ParametersCompiled.CreateFullyResolved(array, parameters.Types); } if (!VerifyExplicitParameters(ec, tic, delegate_type, parameters)) { return null; } return Parameters; } protected override Expression DoResolve(ResolveContext rc) { if (rc.HasSet(ResolveContext.Options.ConstantScope)) { rc.Report.Error(1706, loc, "Anonymous methods and lambda expressions cannot be used in the current context"); return null; } if (rc.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer) && rc.CurrentMemberDefinition.Parent.PartialContainer.PrimaryConstructorParameters != null) { ToplevelBlock topBlock = rc.ConstructorBlock.ParametersBlock.TopBlock; if (Block.TopBlock != topBlock) { Block block = Block; while (block.Parent != Block.TopBlock && block != Block.TopBlock) { block = block.Parent; } block.Parent = topBlock; topBlock.IncludeBlock(Block, Block.TopBlock); block.ParametersBlock.TopBlock = topBlock; } } eclass = ExprClass.Value; type = InternalType.AnonymousMethod; if (!DoResolveParameters(rc)) { return null; } return this; } protected virtual bool DoResolveParameters(ResolveContext rc) { return Parameters.Resolve(rc); } public override void Emit(EmitContext ec) { } public static void Error_AddressOfCapturedVar(ResolveContext rc, IVariableReference var, Location loc) { if (!(rc.CurrentAnonymousMethod is AsyncInitializer)) { rc.Report.Error(1686, loc, "Local variable or parameter `{0}' cannot have their address taken and be used inside an anonymous method, lambda expression or query expression", var.Name); } } public override string GetSignatureForError() { return ExprClassName; } private AnonymousMethodBody CompatibleMethodBody(ResolveContext ec, TypeInferenceContext tic, TypeSpec return_type, TypeSpec delegate_type, ref HashSet undeclaredVariables) { ParametersCompiled parametersCompiled = ResolveParameters(ec, tic, delegate_type); if (parametersCompiled == null) { return null; } ParametersBlock parametersBlock = (ec.IsInProbingMode ? ((ParametersBlock)Block.PerformClone(ref undeclaredVariables)) : Block); if (parametersBlock.IsAsync) { if (return_type != null && return_type.Kind != MemberKind.Void && return_type != ec.Module.PredefinedTypes.Task.TypeSpec && !return_type.IsGenericTask) { ec.Report.Error(4010, loc, "Cannot convert async {0} to delegate type `{1}'", GetSignatureForError(), delegate_type.GetSignatureForError()); return null; } parametersBlock = parametersBlock.ConvertToAsyncTask(ec, ec.CurrentMemberDefinition.Parent.PartialContainer, parametersCompiled, return_type, delegate_type, loc); } return CompatibleMethodFactory(return_type ?? InternalType.ErrorType, delegate_type, parametersCompiled, parametersBlock); } protected virtual AnonymousMethodBody CompatibleMethodFactory(TypeSpec return_type, TypeSpec delegate_type, ParametersCompiled p, ParametersBlock b) { return new AnonymousMethodBody(p, b, return_type, delegate_type, loc); } protected override void CloneTo(CloneContext clonectx, Expression t) { AnonymousMethodExpression anonymousMethodExpression = (AnonymousMethodExpression)t; anonymousMethodExpression.Block = (ParametersBlock)clonectx.LookupBlock(Block); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class AnonymousExpression : ExpressionStatement { protected class AnonymousMethodMethod : Method { public readonly AnonymousExpression AnonymousMethod; public readonly AnonymousMethodStorey Storey; public AnonymousMethodMethod(TypeDefinition parent, AnonymousExpression am, AnonymousMethodStorey storey, TypeExpr return_type, Modifiers mod, MemberName name, ParametersCompiled parameters) : base(parent, return_type, mod | Modifiers.COMPILER_GENERATED, name, parameters, null) { AnonymousMethod = am; Storey = storey; Parent.PartialContainer.Members.Add(this); base.Block = new ToplevelBlock(am.block, parameters); } public override EmitContext CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod) { EmitContext emitContext = new EmitContext(this, ig, base.ReturnType, sourceMethod); emitContext.CurrentAnonymousMethod = AnonymousMethod; return emitContext; } protected override void DefineTypeParameters() { } protected override bool ResolveMemberType() { if (!base.ResolveMemberType()) { return false; } if (Storey != null && Storey.Mutator != null) { if (!parameters.IsEmpty) { TypeSpec[] array = Storey.Mutator.Mutate(parameters.Types); if (array != parameters.Types) { parameters = ParametersCompiled.CreateFullyResolved((Parameter[])parameters.FixedParameters, array); } } member_type = Storey.Mutator.Mutate(member_type); } return true; } public override void Emit() { if ((object)base.MethodBuilder == null) { Define(); } base.Emit(); } } protected readonly ParametersBlock block; public TypeSpec ReturnType; public abstract string ContainerType { get; } public abstract bool IsIterator { get; } public abstract AnonymousMethodStorey Storey { get; } public ParametersBlock Block => block; protected AnonymousExpression(ParametersBlock block, TypeSpec return_type, Location loc) { ReturnType = return_type; this.block = block; base.loc = loc; } public AnonymousExpression Compatible(ResolveContext ec) { return Compatible(ec, this); } public AnonymousExpression Compatible(ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) { return this; } BlockContext blockContext = new BlockContext(ec, block, ReturnType); blockContext.CurrentAnonymousMethod = ae; AnonymousMethodBody anonymousMethodBody = this as AnonymousMethodBody; if (ec.HasSet(ResolveContext.Options.InferReturnType) && anonymousMethodBody != null) { anonymousMethodBody.ReturnTypeInference = new TypeInferenceContext(); } BlockContext blockContext2 = ec as BlockContext; if (blockContext2 != null) { blockContext.AssignmentInfoOffset = blockContext2.AssignmentInfoOffset; blockContext.EnclosingLoop = blockContext2.EnclosingLoop; blockContext.EnclosingLoopOrSwitch = blockContext2.EnclosingLoopOrSwitch; blockContext.Switch = blockContext2.Switch; } int errors = ec.Report.Errors; bool flag = Block.Resolve(blockContext); if (flag && errors == ec.Report.Errors) { MarkReachable(default(Reachability)); if (!CheckReachableExit(ec.Report)) { return null; } if (blockContext2 != null) { blockContext2.AssignmentInfoOffset = blockContext.AssignmentInfoOffset; } } if (anonymousMethodBody != null && anonymousMethodBody.ReturnTypeInference != null) { anonymousMethodBody.ReturnTypeInference.FixAllTypes(ec); ReturnType = anonymousMethodBody.ReturnTypeInference.InferredTypeArguments[0]; anonymousMethodBody.ReturnTypeInference = null; if (block.IsAsync && ReturnType != null) { ReturnType = ((ReturnType.Kind == MemberKind.Void) ? ec.Module.PredefinedTypes.Task.TypeSpec : ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType(ec, new TypeSpec[1] { ReturnType })); } } if (flag && errors != ec.Report.Errors) { return null; } if (block.IsAsync && block.Original.ParametersBlock.HasCapturedThis && ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.block.IsAsync) { ec.CurrentBlock.ParametersBlock.HasReferenceToStoreyForInstanceLambdas = true; } return flag ? this : null; } public override bool ContainsEmitWithAwait() { return false; } private bool CheckReachableExit(Report report) { if (block.HasReachableClosingBrace && ReturnType.Kind != MemberKind.Void && !IsIterator) { report.Error(1643, StartLocation, "Not all code paths return a value in anonymous method of type `{0}'", GetSignatureForError()); return false; } return true; } public override void FlowAnalysis(FlowAnalysisContext fc) { MarkReachable(default(Reachability)); CheckReachableExit(fc.Report); DefiniteAssignmentBitSet definiteAssignment = fc.BranchDefiniteAssignment(); ParametersBlock parametersBlock = fc.ParametersBlock; fc.ParametersBlock = Block; DefiniteAssignmentBitSet definiteAssignmentOnTrue = fc.DefiniteAssignmentOnTrue; DefiniteAssignmentBitSet definiteAssignmentOnFalse = fc.DefiniteAssignmentOnFalse; TryFinally tryFinally = fc.TryFinally; DefiniteAssignmentBitSet definiteAssignmentOnTrue2 = (fc.DefiniteAssignmentOnFalse = null); fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue2; fc.TryFinally = null; block.FlowAnalysis(fc); fc.ParametersBlock = parametersBlock; fc.DefiniteAssignment = definiteAssignment; fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue; fc.DefiniteAssignmentOnFalse = definiteAssignmentOnFalse; fc.TryFinally = tryFinally; } public override Reachability MarkReachable(Reachability rc) { block.MarkReachable(rc); return rc; } public void SetHasThisAccess() { ExplicitBlock explicitBlock = block; while (!explicitBlock.HasCapturedThis) { explicitBlock.HasCapturedThis = true; explicitBlock = ((explicitBlock.Parent == null) ? null : explicitBlock.Parent.Explicit); if (explicitBlock == null) { break; } } } } internal class AnonymousMethodBody : AnonymousExpression { protected readonly ParametersCompiled parameters; private AnonymousMethodStorey storey; private AnonymousMethodMethod method; private Field am_cache; private string block_name; private TypeInferenceContext return_inference; public override string ContainerType => "anonymous method"; public MethodGroupExpr DirectMethodGroupConversion { get; set; } public override bool IsIterator => false; public ParametersCompiled Parameters => parameters; public TypeInferenceContext ReturnTypeInference { get { return return_inference; } set { return_inference = value; } } public override AnonymousMethodStorey Storey => storey; public AnonymousMethodBody(ParametersCompiled parameters, ParametersBlock block, TypeSpec return_type, TypeSpec delegate_type, Location loc) : base(block, return_type, loc) { type = delegate_type; this.parameters = parameters; } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(1945, loc, "An expression tree cannot contain an anonymous method expression"); return null; } private bool Define(ResolveContext ec) { if (!base.Block.Resolved && Compatible(ec) == null) { return false; } if (block_name == null) { MemberCore memberCore = (MemberCore)ec.MemberContext; block_name = memberCore.MemberName.Basename; } return true; } private AnonymousMethodMethod DoCreateMethodHost(EmitContext ec) { TypeDefinition typeDefinition = null; TypeParameters typeParameters = null; ParametersCompiled parametersCompiled = parameters; ExplicitBlock explicitBlock = base.Block.Original.Explicit; Modifiers mod; if (explicitBlock.HasCapturedVariable || explicitBlock.HasCapturedThis) { typeDefinition = (storey = FindBestMethodStorey()); if (storey == null) { ToplevelBlock topBlock = explicitBlock.ParametersBlock.TopBlock; StateMachine stateMachine = topBlock.StateMachine; if (explicitBlock.HasCapturedThis) { ParametersBlock parametersBlock = explicitBlock.ParametersBlock; StateMachine stateMachine2; do { stateMachine2 = parametersBlock.StateMachine; parametersBlock = ((parametersBlock.Parent == null) ? null : parametersBlock.Parent.ParametersBlock); } while (stateMachine2 == null && parametersBlock != null); if (stateMachine2 == null) { topBlock.RemoveThisReferenceFromChildrenBlock(explicitBlock); } else if (stateMachine2.Kind == MemberKind.Struct) { typeDefinition = stateMachine2.Parent.PartialContainer; typeParameters = stateMachine2.OriginalTypeParameters; } else if (stateMachine is IteratorStorey) { typeDefinition = (storey = stateMachine); } } } else if (explicitBlock.ParametersBlock.HasReferenceToStoreyForInstanceLambdas) { explicitBlock.ParametersBlock.StateMachine.AddParentStoreyReference(ec, storey); } mod = ((storey != null) ? Modifiers.INTERNAL : Modifiers.PRIVATE); } else { if (ec.CurrentAnonymousMethod != null) { typeDefinition = (storey = ec.CurrentAnonymousMethod.Storey); } mod = Modifiers.PRIVATE | Modifiers.STATIC; } if (storey == null && typeParameters == null) { typeParameters = ec.CurrentTypeParameters; } if (typeDefinition == null) { typeDefinition = ec.CurrentTypeDefinition.Parent.PartialContainer; } string name = CompilerGeneratedContainer.MakeName((typeDefinition != storey) ? block_name : null, "m", null, typeDefinition.PartialContainer.CounterAnonymousMethods++); MemberName name2; if (typeParameters != null) { TypeParameters typeParameters2 = new TypeParameters(typeParameters.Count); for (int i = 0; i < typeParameters.Count; i++) { typeParameters2.Add(typeParameters[i].CreateHoistedCopy(null)); } name2 = new MemberName(name, typeParameters2, base.Location); } else { name2 = new MemberName(name, base.Location); } return new AnonymousMethodMethod(typeDefinition, this, storey, new TypeExpression(ReturnType, base.Location), mod, name2, parametersCompiled); } protected override Expression DoResolve(ResolveContext ec) { if (!Define(ec)) { return null; } eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { if (method == null) { method = DoCreateMethodHost(ec); method.Define(); method.PrepareEmit(); } bool flag = (method.ModFlags & Modifiers.STATIC) != 0; if (flag && am_cache == null && !ec.IsStaticConstructor && !method.MemberName.IsGeneric) { TypeDefinition partialContainer = method.Parent.PartialContainer; int id = partialContainer.AnonymousMethodsCounter++; TypeSpec t = ((storey != null && storey.Mutator != null) ? storey.Mutator.Mutate(type) : type); am_cache = new Field(partialContainer, new TypeExpression(t, loc), Modifiers.PRIVATE | Modifiers.STATIC | Modifiers.COMPILER_GENERATED, new MemberName(CompilerGeneratedContainer.MakeName(null, "f", "am$cache", id), loc), null); am_cache.Define(); partialContainer.AddField(am_cache); } Label label = ec.DefineLabel(); if (am_cache != null) { ec.Emit(OpCodes.Ldsfld, am_cache.Spec); ec.Emit(OpCodes.Brtrue_S, label); } if (flag) { ec.EmitNull(); } else if (storey != null) { storey.GetStoreyInstanceExpression(ec).Resolve(new ResolveContext(ec.MemberContext))?.Emit(ec); } else { ec.EmitThis(); if (ec.CurrentAnonymousMethod != null && ec.AsyncTaskStorey != null) { ec.Emit(OpCodes.Ldfld, ec.AsyncTaskStorey.HoistedThis.Field.Spec); } } MethodSpec methodSpec = method.Spec; if (storey != null && storey.MemberName.IsGeneric) { if (ec.IsAnonymousStoreyMutateRequired) { ec.Emit(OpCodes.Ldftn, methodSpec); } else { TypeSpec typeSpec = storey.Instance.Type; ec.Emit(OpCodes.Ldftn, TypeBuilder.GetMethod(typeSpec.GetMetaInfo(), (MethodInfo)methodSpec.GetMetaInfo())); } } else { if (methodSpec.IsGeneric) { StateMachine stateMachine = ((ec.CurrentAnonymousMethod == null) ? null : (ec.CurrentAnonymousMethod.Storey as StateMachine)); TypeParameterSpec[] array = ((stateMachine == null || stateMachine.OriginalTypeParameters == null) ? method.TypeParameters : stateMachine.CurrentTypeParameters.Types); MethodSpec methodSpec2 = methodSpec; IMemberContext memberContext = ec.MemberContext; TypeSpec[] targs = array; methodSpec = methodSpec2.MakeGenericMethod(memberContext, targs); } ec.Emit(OpCodes.Ldftn, methodSpec); } MethodSpec constructor = Delegate.GetConstructor(type); ec.Emit(OpCodes.Newobj, constructor); if (am_cache != null) { ec.Emit(OpCodes.Stsfld, am_cache.Spec); ec.MarkLabel(label); ec.Emit(OpCodes.Ldsfld, am_cache.Spec); } } public override void EmitStatement(EmitContext ec) { throw new NotImplementedException(); } private AnonymousMethodStorey FindBestMethodStorey() { for (Block parent = base.Block.Parent; parent != null; parent = parent.Parent) { AnonymousMethodStorey anonymousMethodStorey = parent.Explicit.AnonymousMethodStorey; if (anonymousMethodStorey != null) { return anonymousMethodStorey; } } return null; } public override string GetSignatureForError() { return type.GetSignatureForError(); } } internal class AnonymousTypeClass : CompilerGeneratedContainer { public const string ClassNamePrefix = "<>__AnonType"; public const string SignatureForError = "anonymous type"; private readonly IList parameters; public IList Parameters => parameters; private AnonymousTypeClass(ModuleContainer parent, MemberName name, IList parameters, Location loc) : base(parent, name, (parent.Evaluator != null) ? Modifiers.PUBLIC : Modifiers.INTERNAL) { this.parameters = parameters; } public static AnonymousTypeClass Create(TypeContainer parent, IList parameters, Location loc) { string name = "<>__AnonType" + parent.Module.CounterAnonymousTypes++; TypeParameters typeParameters = null; ParametersCompiled args; SimpleName[] array; if (parameters.Count == 0) { args = ParametersCompiled.EmptyReadOnlyParameters; array = null; } else { array = new SimpleName[parameters.Count]; typeParameters = new TypeParameters(); Parameter[] array2 = new Parameter[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { AnonymousTypeParameter anonymousTypeParameter = parameters[i]; for (int j = 0; j < i; j++) { if (parameters[j].Name == anonymousTypeParameter.Name) { parent.Compiler.Report.Error(833, parameters[j].Location, "`{0}': An anonymous type cannot have multiple properties with the same name", anonymousTypeParameter.Name); anonymousTypeParameter = (parameters[i] = new AnonymousTypeParameter(null, "$" + i, anonymousTypeParameter.Location)); break; } } array[i] = new SimpleName("<" + anonymousTypeParameter.Name + ">__T", anonymousTypeParameter.Location); typeParameters.Add(new TypeParameter(i, new MemberName(array[i].Name, anonymousTypeParameter.Location), null, null, Variance.None)); array2[i] = new Parameter(array[i], anonymousTypeParameter.Name, Parameter.Modifier.NONE, null, anonymousTypeParameter.Location); } args = new ParametersCompiled(array2); } AnonymousTypeClass anonymousTypeClass = new AnonymousTypeClass(parent.Module, new MemberName(name, typeParameters, loc), parameters, loc); Constructor constructor = new Constructor(anonymousTypeClass, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, null, args, loc); constructor.Block = new ToplevelBlock(parent.Module.Compiler, constructor.ParameterInfo, loc); bool flag = false; for (int k = 0; k < parameters.Count; k++) { AnonymousTypeParameter anonymousTypeParameter3 = parameters[k]; Field field = new Field(anonymousTypeClass, array[k], Modifiers.PRIVATE | Modifiers.READONLY | Modifiers.DEBUGGER_HIDDEN, new MemberName("<" + anonymousTypeParameter3.Name + ">", anonymousTypeParameter3.Location), null); if (!anonymousTypeClass.AddField(field)) { flag = true; continue; } constructor.Block.AddStatement(new StatementExpression(new SimpleAssign(new MemberAccess(new This(anonymousTypeParameter3.Location), field.Name), constructor.Block.GetParameterReference(k, anonymousTypeParameter3.Location)))); ToplevelBlock toplevelBlock = new ToplevelBlock(parent.Module.Compiler, anonymousTypeParameter3.Location); toplevelBlock.AddStatement(new Return(new MemberAccess(new This(anonymousTypeParameter3.Location), field.Name), anonymousTypeParameter3.Location)); Property property = new Property(anonymousTypeClass, array[k], Modifiers.PUBLIC, new MemberName(anonymousTypeParameter3.Name, anonymousTypeParameter3.Location), null); property.Get = new PropertyBase.GetMethod(property, (Modifiers)0, null, anonymousTypeParameter3.Location); property.Get.Block = toplevelBlock; anonymousTypeClass.AddMember(property); } if (flag) { return null; } anonymousTypeClass.AddConstructor(constructor); return anonymousTypeClass; } protected override bool DoDefineMembers() { if (!base.DoDefineMembers()) { return false; } Location location = base.Location; ParametersCompiled parametersCompiled = ParametersCompiled.CreateFullyResolved(new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, location), "obj", Parameter.Modifier.NONE, null, location), Compiler.BuiltinTypes.Object); Method method = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Bool, location), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName("Equals", location), parametersCompiled, null); parametersCompiled[0].Resolve(method, 0); Method method2 = new Method(this, new TypeExpression(Compiler.BuiltinTypes.String, location), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName("ToString", location), ParametersCompiled.EmptyReadOnlyParameters, null); ToplevelBlock toplevelBlock = new ToplevelBlock(Compiler, method.ParameterInfo, location); TypeExpr probe_type; if (CurrentTypeParameters != null) { TypeArguments typeArguments = new TypeArguments(); for (int i = 0; i < CurrentTypeParameters.Count; i++) { typeArguments.Add(new TypeParameterExpr(CurrentTypeParameters[i], base.Location)); } probe_type = new GenericTypeExpr(base.Definition, typeArguments, location); } else { probe_type = new TypeExpression(base.Definition, location); } LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(CurrentType, toplevelBlock, location); toplevelBlock.AddStatement(new BlockVariable(new TypeExpression(localVariable.Type, location), localVariable)); LocalVariableReference localVariableReference = new LocalVariableReference(localVariable, location); MemberAccess expr = new MemberAccess(new MemberAccess(new QualifiedAliasMember("global", "System", location), "Collections", location), "Generic", location); Expression expression = null; Expression left = new StringConstant(Compiler.BuiltinTypes, "{", location); Expression expression2 = new IntConstant(Compiler.BuiltinTypes, -2128831035, location); for (int j = 0; j < parameters.Count; j++) { AnonymousTypeParameter anonymousTypeParameter = parameters[j]; Field field = (Field)base.Members[j * 2]; MemberAccess expr2 = new MemberAccess(new MemberAccess(expr, "EqualityComparer", new TypeArguments(new SimpleName(CurrentTypeParameters[j].Name, location)), location), "Default", location); Arguments arguments = new Arguments(2); arguments.Add(new Argument(new MemberAccess(new This(field.Location), field.Name))); arguments.Add(new Argument(new MemberAccess(localVariableReference, field.Name))); Expression expression3 = new Invocation(new MemberAccess(expr2, "Equals", location), arguments); Arguments arguments2 = new Arguments(1); arguments2.Add(new Argument(new MemberAccess(new This(field.Location), field.Name))); Expression right = new Invocation(new MemberAccess(expr2, "GetHashCode", location), arguments2); IntConstant right2 = new IntConstant(Compiler.BuiltinTypes, 16777619, location); expression2 = new Binary(Binary.Operator.Multiply, new Binary(Binary.Operator.ExclusiveOr, expression2, right), right2); Expression right3 = new Conditional(new BooleanExpression(new Binary(Binary.Operator.Inequality, new MemberAccess(new This(field.Location), field.Name), new NullLiteral(location))), new Invocation(new MemberAccess(new MemberAccess(new This(field.Location), field.Name), "ToString"), null), new StringConstant(Compiler.BuiltinTypes, string.Empty, location), location); if (expression == null) { expression = expression3; left = new Binary(Binary.Operator.Addition, left, new Binary(Binary.Operator.Addition, new StringConstant(Compiler.BuiltinTypes, " " + anonymousTypeParameter.Name + " = ", location), right3)); } else { left = new Binary(Binary.Operator.Addition, new Binary(Binary.Operator.Addition, left, new StringConstant(Compiler.BuiltinTypes, ", " + anonymousTypeParameter.Name + " = ", location)), right3); expression = new Binary(Binary.Operator.LogicalAnd, expression, expression3); } } left = new Binary(Binary.Operator.Addition, left, new StringConstant(Compiler.BuiltinTypes, " }", location)); TemporaryVariableReference target = new TemporaryVariableReference(localVariable, location); toplevelBlock.AddStatement(new StatementExpression(new SimpleAssign(target, new As(toplevelBlock.GetParameterReference(0, location), probe_type, location), location))); Expression expression4 = new Binary(Binary.Operator.Inequality, localVariableReference, new NullLiteral(location)); if (expression != null) { expression4 = new Binary(Binary.Operator.LogicalAnd, expression4, expression); } toplevelBlock.AddStatement(new Return(expression4, location)); method.Block = toplevelBlock; method.Define(); base.Members.Add(method); Method method3 = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Int, location), Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName("GetHashCode", location), ParametersCompiled.EmptyReadOnlyParameters, null); ToplevelBlock toplevelBlock2 = new ToplevelBlock(Compiler, location); Block block = new Block(toplevelBlock2, location, location); toplevelBlock2.AddStatement(new Unchecked(block, location)); LocalVariable localVariable2 = LocalVariable.CreateCompilerGenerated(Compiler.BuiltinTypes.Int, toplevelBlock2, location); block.AddStatement(new BlockVariable(new TypeExpression(localVariable2.Type, location), localVariable2)); LocalVariableReference target2 = new LocalVariableReference(localVariable2, location); block.AddStatement(new StatementExpression(new SimpleAssign(target2, expression2))); LocalVariableReference localVariableReference2 = new LocalVariableReference(localVariable2, location); block.AddStatement(new StatementExpression(new CompoundAssign(Binary.Operator.Addition, localVariableReference2, new Binary(Binary.Operator.LeftShift, localVariableReference2, new IntConstant(Compiler.BuiltinTypes, 13, location))))); block.AddStatement(new StatementExpression(new CompoundAssign(Binary.Operator.ExclusiveOr, localVariableReference2, new Binary(Binary.Operator.RightShift, localVariableReference2, new IntConstant(Compiler.BuiltinTypes, 7, location))))); block.AddStatement(new StatementExpression(new CompoundAssign(Binary.Operator.Addition, localVariableReference2, new Binary(Binary.Operator.LeftShift, localVariableReference2, new IntConstant(Compiler.BuiltinTypes, 3, location))))); block.AddStatement(new StatementExpression(new CompoundAssign(Binary.Operator.ExclusiveOr, localVariableReference2, new Binary(Binary.Operator.RightShift, localVariableReference2, new IntConstant(Compiler.BuiltinTypes, 17, location))))); block.AddStatement(new StatementExpression(new CompoundAssign(Binary.Operator.Addition, localVariableReference2, new Binary(Binary.Operator.LeftShift, localVariableReference2, new IntConstant(Compiler.BuiltinTypes, 5, location))))); block.AddStatement(new Return(localVariableReference2, location)); method3.Block = toplevelBlock2; method3.Define(); base.Members.Add(method3); ToplevelBlock toplevelBlock3 = new ToplevelBlock(Compiler, location); toplevelBlock3.AddStatement(new Return(left, location)); method2.Block = toplevelBlock3; method2.Define(); base.Members.Add(method2); return true; } public override string GetSignatureForError() { return "anonymous type"; } public override CompilationSourceFile GetCompilationSourceFile() { return null; } } internal class Argument { public enum AType : byte { None = 0, Ref = 1, Out = 2, Default = 3, DynamicTypeName = 4, ExtensionType = 5, ExtensionTypeConditionalAccess = 133, ConditionalAccessFlag = 128 } public readonly AType ArgType; public Expression Expr; public bool IsByRef => ArgType == AType.Ref || ArgType == AType.Out; public bool IsDefaultArgument => ArgType == AType.Default; public bool IsExtensionType => (ArgType & AType.ExtensionType) == AType.ExtensionType; public Parameter.Modifier Modifier => ArgType switch { AType.Out => Parameter.Modifier.OUT, AType.Ref => Parameter.Modifier.REF, _ => Parameter.Modifier.NONE, }; public TypeSpec Type => Expr.Type; public Argument(Expression expr, AType type) { Expr = expr; ArgType = type; } public Argument(Expression expr) { Expr = expr; } public Argument Clone(Expression expr) { Argument argument = (Argument)MemberwiseClone(); argument.Expr = expr; return argument; } public Argument Clone(CloneContext clonectx) { return Clone(Expr.Clone(clonectx)); } public virtual Expression CreateExpressionTree(ResolveContext rc) { if (ArgType == AType.Default) { rc.Report.Error(854, Expr.Location, "An expression tree cannot contain an invocation which uses optional parameter"); } return Expr.CreateExpressionTree(rc); } public virtual void Emit(EmitContext ec) { if (!IsByRef) { if (ArgType == AType.ExtensionTypeConditionalAccess) { new InstanceEmitter(Expr, addressLoad: false).Emit(ec, conditionalAccess: true); } else { Expr.Emit(ec); } return; } if (Expr.Type.Kind == MemberKind.ByRef) { Expr.Emit(ec); return; } AddressOp addressOp = AddressOp.Store; if (ArgType == AType.Ref) { addressOp |= AddressOp.Load; } ((IMemoryLocation)Expr).AddressOf(ec, addressOp); } public Argument EmitToField(EmitContext ec, bool cloneResult) { Expression expression = Expr.EmitToField(ec); if (cloneResult && expression != Expr) { return new Argument(expression, ArgType); } Expr = expression; return this; } public void FlowAnalysis(FlowAnalysisContext fc) { if (ArgType == AType.Out) { if (Expr is VariableReference variableReference) { if (variableReference.VariableInfo != null) { fc.SetVariableAssigned(variableReference.VariableInfo); } } else if (Expr is FieldExpr fieldExpr) { fieldExpr.SetFieldAssigned(fc); } } else { Expr.FlowAnalysis(fc); } } public string GetSignatureForError() { if (Expr.eclass == ExprClass.MethodGroup) { return Expr.ExprClassName; } return Expr.Type.GetSignatureForError(); } public bool ResolveMethodGroup(ResolveContext ec) { if (Expr is SimpleName simpleName) { Expr = simpleName.GetMethodGroup(); } Expr = Expr.Resolve(ec, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup); if (Expr == null) { return false; } return true; } public void Resolve(ResolveContext ec) { if (ArgType != AType.Out) { Expr = Expr.Resolve(ec); } if (Expr != null && IsByRef) { Expr = Expr.ResolveLValue(ec, EmptyExpression.OutAccess); } if (Expr == null) { Expr = ErrorExpression.Instance; } } } internal class MovableArgument : Argument { private LocalTemporary variable; public MovableArgument(Argument arg) : this(arg.Expr, arg.ArgType) { } protected MovableArgument(Expression expr, AType modifier) : base(expr, modifier) { } public override void Emit(EmitContext ec) { base.Emit(ec); if (variable != null) { variable.Release(ec); } } public void EmitToVariable(EmitContext ec) { TypeSpec typeSpec = Expr.Type; if (base.IsByRef) { IMemoryLocation memoryLocation = (IMemoryLocation)Expr; memoryLocation.AddressOf(ec, AddressOp.LoadStore); typeSpec = ReferenceContainer.MakeType(ec.Module, typeSpec); } else { Expr.Emit(ec); } variable = new LocalTemporary(typeSpec); variable.Store(ec); Expr = variable; } } internal class NamedArgument : MovableArgument { public readonly string Name; private readonly Location loc; public Location Location => loc; public NamedArgument(string name, Location loc, Expression expr) : this(name, loc, expr, AType.None) { } public NamedArgument(string name, Location loc, Expression expr, AType modifier) : base(expr, modifier) { Name = name; this.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(853, loc, "An expression tree cannot contain named argument"); return base.CreateExpressionTree(ec); } } internal class Arguments { private sealed class ArgumentsOrdered : Arguments { private readonly List ordered; public ArgumentsOrdered(Arguments args) : base(args.Count) { AddRange(args); ordered = new List(); } public void AddOrdered(MovableArgument arg) { ordered.Add(arg); } public override void FlowAnalysis(FlowAnalysisContext fc, List movable = null) { foreach (MovableArgument item in ordered) { if (item.ArgType != Argument.AType.Out) { item.FlowAnalysis(fc); } } base.FlowAnalysis(fc, ordered); } public override Arguments Emit(EmitContext ec, bool dup_args, bool prepareAwait) { foreach (MovableArgument item in ordered) { if (prepareAwait) { item.EmitToField(ec, cloneResult: false); } else { item.EmitToVariable(ec); } } return base.Emit(ec, dup_args, prepareAwait); } } private List args; public int Count => args.Count; public bool HasDynamic { get { foreach (Argument arg in args) { if (arg.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && !arg.IsByRef) { return true; } } return false; } } public bool HasNamed { get { foreach (Argument arg in args) { if (arg is NamedArgument) { return true; } } return false; } } public Argument this[int index] { get { return args[index]; } set { args[index] = value; } } public Arguments(int capacity) { args = new List(capacity); } private Arguments(List args) { this.args = args; } public void Add(Argument arg) { args.Add(arg); } public void AddRange(Arguments args) { this.args.AddRange(args.args); } public bool ContainsEmitWithAwait() { foreach (Argument arg in args) { if (arg.Expr.ContainsEmitWithAwait()) { return true; } } return false; } public ArrayInitializer CreateDynamicBinderArguments(ResolveContext rc) { Location loc = Location.Null; ArrayInitializer arrayInitializer = new ArrayInitializer(args.Count, loc); MemberAccess binderNamespace = DynamicExpressionStatement.GetBinderNamespace(loc); foreach (Argument arg in args) { Arguments arguments = new Arguments(2); Expression expression = new IntLiteral(rc.BuiltinTypes, 0, loc); if (arg.Expr is Constant) { expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "Constant", loc)); } else if (arg.ArgType == Argument.AType.Ref) { expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "IsRef", loc)); expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "UseCompileTimeType", loc)); } else if (arg.ArgType == Argument.AType.Out) { expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "IsOut", loc)); expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "UseCompileTimeType", loc)); } else if (arg.ArgType == Argument.AType.DynamicTypeName) { expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "IsStaticType", loc)); } TypeSpec type = arg.Expr.Type; if (type.BuiltinType != BuiltinTypeSpec.Type.Dynamic && type != InternalType.NullLiteral) { if (arg.Expr is MethodGroupExpr methodGroupExpr) { rc.Report.Error(1976, arg.Expr.Location, "The method group `{0}' cannot be used as an argument of dynamic operation. Consider using parentheses to invoke the method", methodGroupExpr.Name); } else if (type == InternalType.AnonymousMethod) { rc.Report.Error(1977, arg.Expr.Location, "An anonymous method or lambda expression cannot be used as an argument of dynamic operation. Consider using a cast"); } else if (type.Kind == MemberKind.Void || type == InternalType.Arglist || type.IsPointer) { rc.Report.Error(1978, arg.Expr.Location, "An expression of type `{0}' cannot be used as an argument of dynamic operation", type.GetSignatureForError()); } expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "UseCompileTimeType", loc)); } string s; if (arg is NamedArgument namedArgument) { expression = new Binary(Binary.Operator.BitwiseOr, expression, new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfoFlags", loc), "NamedArgument", loc)); s = namedArgument.Name; } else { s = null; } arguments.Add(new Argument(expression)); arguments.Add(new Argument(new StringLiteral(rc.BuiltinTypes, s, loc))); arrayInitializer.Add(new Invocation(new MemberAccess(new MemberAccess(binderNamespace, "CSharpArgumentInfo", loc), "Create", loc), arguments)); } return arrayInitializer; } public static Arguments CreateForExpressionTree(ResolveContext rc, Arguments args, params Expression[] e) { Arguments arguments = new Arguments((args?.Count ?? 0) + e.Length); foreach (Expression expression in e) { if (expression != null) { arguments.Add(new Argument(expression)); } } if (args != null) { foreach (Argument arg in args.args) { Expression expression2 = arg.CreateExpressionTree(rc); if (expression2 != null) { arguments.Add(new Argument(expression2)); } } } return arguments; } public void CheckArrayAsAttribute(CompilerContext ctx) { foreach (Argument arg in args) { if (arg.Type != null && arg.Type.IsArray) { ctx.Report.Warning(3016, 1, arg.Expr.Location, "Arrays as attribute arguments are not CLS-compliant"); } } } public Arguments Clone(CloneContext ctx) { Arguments arguments = new Arguments(args.Count); foreach (Argument arg in args) { arguments.Add(arg.Clone(ctx)); } return arguments; } public void Emit(EmitContext ec) { Emit(ec, dup_args: false, prepareAwait: false); } public void EmitPrepare(EmitContext ec) { foreach (Argument arg in args) { arg.Expr.EmitPrepare(ec); } } public virtual Arguments Emit(EmitContext ec, bool dup_args, bool prepareAwait) { List list = ((!((dup_args && Count != 0) || prepareAwait)) ? null : new List(Count)); foreach (Argument arg in args) { if (prepareAwait) { list.Add(arg.EmitToField(ec, cloneResult: true)); continue; } arg.Emit(ec); if (dup_args) { if (arg.Expr.IsSideEffectFree) { list.Add(arg); continue; } ec.Emit(OpCodes.Dup); LocalTemporary localTemporary = new LocalTemporary(arg.Type); localTemporary.Store(ec); list.Add(new Argument(localTemporary, arg.ArgType)); } } if (list != null) { return new Arguments(list); } return null; } public virtual void FlowAnalysis(FlowAnalysisContext fc, List movable = null) { bool flag = false; foreach (Argument arg in args) { if (arg.ArgType == Argument.AType.Out) { flag = true; } else if (movable == null) { arg.FlowAnalysis(fc); } else if (arg is MovableArgument item && !movable.Contains(item)) { arg.FlowAnalysis(fc); } } if (!flag) { return; } foreach (Argument arg2 in args) { if (arg2.ArgType == Argument.AType.Out) { arg2.FlowAnalysis(fc); } } } public List.Enumerator GetEnumerator() { return args.GetEnumerator(); } public void Insert(int index, Argument arg) { args.Insert(index, arg); } public static System.Linq.Expressions.Expression[] MakeExpression(Arguments args, BuilderContext ctx) { if (args == null || args.Count == 0) { return null; } System.Linq.Expressions.Expression[] array = new System.Linq.Expressions.Expression[args.Count]; for (int i = 0; i < array.Length; i++) { Argument argument = args.args[i]; array[i] = argument.Expr.MakeExpression(ctx); } return array; } public Arguments MarkOrderedArgument(NamedArgument a) { if (a.Expr.IsSideEffectFree) { return this; } ArgumentsOrdered argumentsOrdered = this as ArgumentsOrdered; if (argumentsOrdered == null) { argumentsOrdered = new ArgumentsOrdered(this); for (int i = 0; i < args.Count; i++) { Argument argument = args[i]; if (argument == a) { break; } if (argument != null) { MovableArgument movableArgument = argument as MovableArgument; if (movableArgument == null) { movableArgument = new MovableArgument(argument); argumentsOrdered.args[i] = movableArgument; } argumentsOrdered.AddOrdered(movableArgument); } } } argumentsOrdered.AddOrdered(a); return argumentsOrdered; } public void Resolve(ResolveContext rc, out bool dynamic) { dynamic = false; List list = null; foreach (Argument arg in args) { arg.Resolve(rc); if (arg.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && !arg.IsByRef) { dynamic = true; } else { if (arg.Type != InternalType.VarOutType) { continue; } if (arg.Expr is DeclarationExpression declarationExpression) { if (list == null) { list = new List(); } list.Add(declarationExpression.Variable); } else if (arg.Expr is LocalVariableReference localVariableReference && list != null && list.Contains(localVariableReference.local_info)) { rc.Report.Error(8196, localVariableReference.Location, "Reference to an implicitly typed out variable `{0}' is not permitted in the same argument list", localVariableReference.Name); localVariableReference.Type = InternalType.ErrorType; } } } } public void RemoveAt(int index) { args.RemoveAt(index); } } internal interface IAssemblyDefinition { string FullName { get; } bool IsCLSCompliant { get; } bool IsMissing { get; } string Name { get; } byte[] GetPublicKeyToken(); bool IsFriendAssemblyTo(IAssemblyDefinition assembly); } internal class AssemblyReferenceMessageInfo { public AssemblyName DependencyName { get; private set; } public Action ReportMessage { get; private set; } public AssemblyReferenceMessageInfo(AssemblyName dependencyName, Action reportMessage) { DependencyName = dependencyName; ReportMessage = reportMessage; } } internal abstract class AssemblyDefinition : IAssemblyDefinition { public AssemblyBuilder Builder; protected AssemblyBuilderExtension builder_extra; private MonoSymbolFile symbol_writer; private bool is_cls_compliant; private bool wrap_non_exception_throws; private bool wrap_non_exception_throws_custom; private bool has_user_debuggable; protected ModuleContainer module; private readonly string name; protected readonly string file_name; private byte[] public_key; private byte[] public_key_token; private bool delay_sign; private StrongNameKeyPair private_key; private Attribute cls_attribute; private Method entry_point; protected List added_modules; private Dictionary declarative_security; private Dictionary emitted_forwarders; private AssemblyAttributesPlaceholder module_target_attrs; private string vi_product; private string vi_product_version; private string vi_company; private string vi_copyright; private string vi_trademark; private string pa_file_version; private string pa_assembly_version; public Attribute CLSCompliantAttribute => cls_attribute; public CompilerContext Compiler => module.Compiler; public Method EntryPoint { get { return entry_point; } set { entry_point = value; } } public string FullName => Builder.FullName; public bool HasCLSCompliantAttribute => cls_attribute != null; public MetadataImporter Importer { get; set; } public bool IsCLSCompliant => is_cls_compliant; bool IAssemblyDefinition.IsMissing => false; public bool IsSatelliteAssembly { get; private set; } public string Name => name; public bool WrapNonExceptionThrows => wrap_non_exception_throws; protected Report Report => Compiler.Report; public MonoSymbolFile SymbolWriter => symbol_writer; protected AssemblyDefinition(ModuleContainer module, string name) { this.module = module; this.name = Path.GetFileNameWithoutExtension(name); wrap_non_exception_throws = true; delay_sign = Compiler.Settings.StrongNameDelaySign; if (Compiler.Settings.HasKeyFileOrContainer) { LoadPublicKey(Compiler.Settings.StrongNameKeyFile, Compiler.Settings.StrongNameKeyContainer); } } protected AssemblyDefinition(ModuleContainer module, string name, string fileName) : this(module, name) { file_name = fileName; } public void AddModule(ImportedModuleDefinition module) { if (added_modules == null) { added_modules = new List(); added_modules.Add(module); } } public void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.IsValidSecurityAttribute()) { a.ExtractSecurityPermissionSet(ctor, ref declarative_security); return; } if (a.Type == pa.AssemblyCulture) { string text = a.GetString(); if (text == null || text.Length == 0) { return; } if (Compiler.Settings.Target == Target.Exe) { Report.Error(7059, a.Location, "Executables cannot be satellite assemblies. Remove the attribute or keep it empty"); return; } if (text == "neutral") { text = ""; } if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute(ctor, cdata); } else { builder_extra.SetCulture(text, a.Location); } IsSatelliteAssembly = true; return; } if (a.Type == pa.AssemblyVersion) { string text2 = a.GetString(); if (text2 != null && text2.Length != 0) { Version version = IsValidAssemblyVersion(text2, allowGenerated: true); if (version == null) { Report.Error(7034, a.Location, "The specified version string `{0}' does not conform to the required format - major[.minor[.build[.revision]]]", text2); return; } if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute(ctor, cdata); return; } builder_extra.SetVersion(version, a.Location); pa_assembly_version = version.ToString(); } return; } if (a.Type == pa.AssemblyAlgorithmId) { uint num = cdata[2]; num |= (uint)(cdata[3] << 8); num |= (uint)(cdata[4] << 16); num |= (uint)(cdata[5] << 24); if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute(ctor, cdata); } else { builder_extra.SetAlgorithmId(num, a.Location); } return; } if (a.Type == pa.AssemblyFlags) { uint num2 = cdata[2]; num2 |= (uint)(cdata[3] << 8); num2 |= (uint)(cdata[4] << 16); num2 |= (uint)(cdata[5] << 24); if ((num2 & 1) != 0 && public_key == null) { num2 &= 0xFFFFFFFEu; } if (Compiler.Settings.Target == Target.Module) { SetCustomAttribute(ctor, cdata); } else { builder_extra.SetFlags(num2, a.Location); } return; } if (a.Type == pa.TypeForwarder) { TypeSpec argumentType = a.GetArgumentType(); if (argumentType == null || TypeManager.HasElementType(argumentType)) { Report.Error(735, a.Location, "Invalid type specified as an argument for TypeForwardedTo attribute"); return; } if (emitted_forwarders == null) { emitted_forwarders = new Dictionary(); } else if (emitted_forwarders.ContainsKey(argumentType.MemberDefinition)) { Report.SymbolRelatedToPreviousError(emitted_forwarders[argumentType.MemberDefinition].Location, null); Report.Error(739, a.Location, "A duplicate type forward of type `{0}'", argumentType.GetSignatureForError()); return; } emitted_forwarders.Add(argumentType.MemberDefinition, a); if (argumentType.MemberDefinition.DeclaringAssembly == this) { Report.SymbolRelatedToPreviousError(argumentType); Report.Error(729, a.Location, "Cannot forward type `{0}' because it is defined in this assembly", argumentType.GetSignatureForError()); } else if (argumentType.IsNested) { Report.Error(730, a.Location, "Cannot forward type `{0}' because it is a nested type", argumentType.GetSignatureForError()); } else { AddTypeForwarders(argumentType, a.Location); } return; } if (a.Type == pa.Extension) { a.Error_MisusedExtensionAttribute(); return; } if (a.Type == pa.InternalsVisibleTo) { string text3 = a.GetString(); if (text3 == null) { Report.Error(7030, a.Location, "Friend assembly reference cannot have `null' value"); return; } if (text3.Length == 0) { return; } } else if (a.Type == pa.RuntimeCompatibility) { wrap_non_exception_throws_custom = true; } else { if (a.Type == pa.AssemblyFileVersion) { pa_file_version = a.GetString(); if (string.IsNullOrEmpty(pa_file_version) || IsValidAssemblyVersion(pa_file_version, allowGenerated: false) == null) { Report.Warning(7035, 1, a.Location, "The specified version string `{0}' does not conform to the recommended format major.minor.build.revision", pa_file_version, a.Name); return; } CustomAttributeBuilder customAttribute = new CustomAttributeBuilder((ConstructorInfo)ctor.GetMetaInfo(), new object[1] { pa_file_version }); Builder.SetCustomAttribute(customAttribute); return; } if (a.Type == pa.AssemblyProduct) { vi_product = a.GetString(); } else if (a.Type == pa.AssemblyCompany) { vi_company = a.GetString(); } else if (a.Type == pa.AssemblyCopyright) { vi_copyright = a.GetString(); } else if (a.Type == pa.AssemblyTrademark) { vi_trademark = a.GetString(); } else if (a.Type == pa.Debuggable) { has_user_debuggable = true; } else if (a.Type == pa.AssemblyInformationalVersion) { vi_product_version = a.GetString(); } } SetCustomAttribute(ctor, cdata); } private void AddTypeForwarders(TypeSpec type, Location loc) { builder_extra.AddTypeForwarder(type.GetDefinition(), loc); List declaredNestedTypes = MemberCache.GetDeclaredNestedTypes(type); if (declaredNestedTypes == null) { return; } foreach (TypeSpec item in declaredNestedTypes) { if (!item.IsPrivate) { AddTypeForwarders(item, loc); } } } private void CheckReferencesPublicToken() { AssemblyName[] referencedAssemblies = builder_extra.GetReferencedAssemblies(); if (referencedAssemblies == null) { return; } AssemblyName[] array = referencedAssemblies; foreach (AssemblyName assemblyName in array) { if (public_key != null && assemblyName.GetPublicKey().Length == 0) { Report.Error(1577, "Referenced assembly `{0}' does not have a strong name", assemblyName.FullName); } CultureInfo cultureInfo = assemblyName.CultureInfo; if (!cultureInfo.Equals(CultureInfo.InvariantCulture)) { Report.Warning(8009, 1, "Referenced assembly `{0}' has different culture setting of `{1}'", assemblyName.Name, cultureInfo.Name); } ImportedAssemblyDefinition importedAssemblyDefinition = Importer.GetImportedAssemblyDefinition(assemblyName); if (importedAssemblyDefinition == null) { continue; } List notUnifiedReferences = GetNotUnifiedReferences(assemblyName); if (notUnifiedReferences != null) { foreach (AssemblyReferenceMessageInfo r in notUnifiedReferences) { if (referencedAssemblies.Any((AssemblyName l) => l.Name == r.DependencyName.Name)) { r.ReportMessage(Report); } } } if (importedAssemblyDefinition.IsFriendAssemblyTo(this)) { AssemblyName assemblyVisibleToName = importedAssemblyDefinition.GetAssemblyVisibleToName(this); byte[] publicKeyToken = assemblyVisibleToName.GetPublicKeyToken(); if (!ArrayComparer.IsEqual(GetPublicKeyToken(), publicKeyToken)) { Report.SymbolRelatedToPreviousError(importedAssemblyDefinition.Location); Report.Error(281, "Friend access was granted to `{0}', but the output assembly is named `{1}'. Try adding a reference to `{0}' or change the output assembly name to match it", assemblyVisibleToName.FullName, FullName); } } } } protected AssemblyName CreateAssemblyName() { return new AssemblyName(name); } public virtual ModuleBuilder CreateModuleBuilder() { if (file_name == null) { throw new NotSupportedException("transient module in static assembly"); } string fileName = Path.GetFileName(file_name); return Builder.DefineDynamicModule(fileName); } public virtual void Emit() { if (Compiler.Settings.Target == Target.Module) { module_target_attrs = new AssemblyAttributesPlaceholder(module, name); module_target_attrs.CreateContainer(); module_target_attrs.DefineContainer(); module_target_attrs.Define(); module.AddCompilerGeneratedClass(module_target_attrs); } else if (added_modules != null) { ReadModulesAssemblyAttributes(); } if (Compiler.Settings.GenerateDebugInfo) { symbol_writer = new MonoSymbolFile(); } module.EmitContainer(); if (module.HasExtensionMethod) { PredefinedAttribute extension = module.PredefinedAttributes.Extension; if (extension.IsDefined) { SetCustomAttribute(extension.Constructor, AttributeEncoder.Empty); } } if (!IsSatelliteAssembly) { if (!has_user_debuggable && Compiler.Settings.GenerateDebugInfo) { PredefinedDebuggableAttribute debuggable = module.PredefinedAttributes.Debuggable; if (debuggable.IsDefined) { DebuggableAttribute.DebuggingModes debuggingModes = DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints; if (!Compiler.Settings.Optimize) { debuggingModes |= DebuggableAttribute.DebuggingModes.DisableOptimizations; } debuggable.EmitAttribute(Builder, debuggingModes); } } if (!wrap_non_exception_throws_custom) { PredefinedAttribute runtimeCompatibility = module.PredefinedAttributes.RuntimeCompatibility; if (runtimeCompatibility.IsDefined && runtimeCompatibility.ResolveBuilder()) { PropertySpec propertySpec = module.PredefinedMembers.RuntimeCompatibilityWrapNonExceptionThrows.Get(); if (propertySpec != null) { AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.EncodeNamedPropertyArgument(propertySpec, new BoolLiteral(Compiler.BuiltinTypes, val: true, Location.Null)); SetCustomAttribute(runtimeCompatibility.Constructor, attributeEncoder.ToArray(out var assemblyReferences)); module.AddAssemblyReferences(assemblyReferences); } } } if (declarative_security != null) { throw new NotSupportedException("Assembly-level security"); } } CheckReferencesPublicToken(); SetEntryPoint(); } public byte[] GetPublicKeyToken() { if (public_key == null || public_key_token != null) { return public_key_token; } HashAlgorithm hashAlgorithm = SHA1.Create(); byte[] array = hashAlgorithm.ComputeHash(public_key); public_key_token = new byte[8]; Buffer.BlockCopy(array, array.Length - 8, public_key_token, 0, 8); Array.Reverse((Array)public_key_token, 0, 8); return public_key_token; } protected virtual List GetNotUnifiedReferences(AssemblyName assemblyName) { return null; } private void LoadPublicKey(string keyFile, string keyContainer) { if (keyContainer != null) { try { private_key = new StrongNameKeyPair(keyContainer); public_key = private_key.PublicKey; return; } catch { Error_AssemblySigning("The specified key container `" + keyContainer + "' does not exist"); return; } } bool flag = File.Exists(keyFile); if (!flag && Compiler.Settings.StrongNameKeyFile == null) { string text = Path.Combine(Path.GetDirectoryName(file_name), keyFile); flag = File.Exists(text); if (flag) { keyFile = text; } } if (!flag) { Error_AssemblySigning("The specified key file `" + keyFile + "' does not exist"); return; } using FileStream fileStream = new FileStream(keyFile, FileMode.Open, FileAccess.Read); byte[] array = new byte[fileStream.Length]; fileStream.Read(array, 0, array.Length); if (array.Length == 16) { public_key = array; return; } try { RSA rsa = CryptoConvert.FromCapiKeyBlob(array); byte[] array2 = CryptoConvert.ToCapiPublicKeyBlob(rsa); byte[] array3 = new byte[8] { 0, 36, 0, 0, 4, 128, 0, 0 }; public_key = new byte[12 + array2.Length]; Buffer.BlockCopy(array3, 0, public_key, 0, array3.Length); int num = public_key.Length - 12; public_key[8] = (byte)(num & 0xFF); public_key[9] = (byte)((num >> 8) & 0xFF); public_key[10] = (byte)((num >> 16) & 0xFF); public_key[11] = (byte)((num >> 24) & 0xFF); Buffer.BlockCopy(array2, 0, public_key, 12, array2.Length); } catch { Error_AssemblySigning("The specified key file `" + keyFile + "' has incorrect format"); return; } if (delay_sign) { return; } try { CryptoConvert.FromCapiPrivateKeyBlob(array); private_key = new StrongNameKeyPair(array); } catch { } } private void ReadModulesAssemblyAttributes() { foreach (ImportedModuleDefinition added_module in added_modules) { List list = added_module.ReadAssemblyAttributes(); if (list != null) { module.OptAttributes.AddAttributes(list); } } } public void Resolve() { if (Compiler.Settings.Unsafe && module.PredefinedTypes.SecurityAction.Define()) { Location location = Location.Null; MemberAccess expr = new MemberAccess(new MemberAccess(new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", location), "Security", location), "Permissions", location); ConstSpec constSpec = module.PredefinedMembers.SecurityActionRequestMinimum.Resolve(location); Arguments arguments = new Arguments(1); arguments.Add(new Argument(constSpec.GetConstant(null))); Arguments arguments2 = new Arguments(1); arguments2.Add(new NamedArgument("SkipVerification", location, new BoolLiteral(Compiler.BuiltinTypes, val: true, location))); Attribute attribute = new Attribute("assembly", new MemberAccess(expr, "SecurityPermissionAttribute"), new Arguments[2] { arguments, arguments2 }, location, nameEscaped: false); attribute.AttachTo(module, module); Compiler.Report.DisableReporting(); try { MethodSpec methodSpec = attribute.Resolve(); if (methodSpec != null) { attribute.ExtractSecurityPermissionSet(methodSpec, ref declarative_security); } } finally { Compiler.Report.EnableReporting(); } } if (module.OptAttributes == null || !module.OptAttributes.CheckTargets()) { return; } cls_attribute = module.ResolveAssemblyAttribute(module.PredefinedAttributes.CLSCompliant); if (cls_attribute != null) { is_cls_compliant = cls_attribute.GetClsCompliantAttributeValue(); } if (added_modules != null && Compiler.Settings.VerifyClsCompliance && is_cls_compliant) { foreach (ImportedModuleDefinition added_module in added_modules) { if (!added_module.IsCLSCompliant) { Report.Error(3013, "Added modules must be marked with the CLSCompliant attribute to match the assembly", added_module.Name); } } } Attribute attribute2 = module.ResolveAssemblyAttribute(module.PredefinedAttributes.RuntimeCompatibility); if (attribute2 != null && attribute2.GetNamedValue("WrapNonExceptionThrows") is BoolConstant boolConstant) { wrap_non_exception_throws = boolConstant.Value; } } protected void ResolveAssemblySecurityAttributes() { string text = null; string text2 = null; if (module.OptAttributes != null) { foreach (Attribute attr in module.OptAttributes.Attrs) { if (attr.ExplicitTarget != "assembly") { continue; } switch (attr.Name) { case "AssemblyKeyFile": case "AssemblyKeyFileAttribute": case "System.Reflection.AssemblyKeyFileAttribute": { if (Compiler.Settings.StrongNameKeyFile != null) { Report.SymbolRelatedToPreviousError(attr.Location, attr.GetSignatureForError()); Report.Warning(1616, 1, "Option `{0}' overrides attribute `{1}' given in a source file or added module", "keyfile", "System.Reflection.AssemblyKeyFileAttribute"); break; } string text3 = attr.GetString(); if (!string.IsNullOrEmpty(text3)) { Error_ObsoleteSecurityAttribute(attr, "keyfile"); text = text3; } break; } case "AssemblyKeyName": case "AssemblyKeyNameAttribute": case "System.Reflection.AssemblyKeyNameAttribute": { if (Compiler.Settings.StrongNameKeyContainer != null) { Report.SymbolRelatedToPreviousError(attr.Location, attr.GetSignatureForError()); Report.Warning(1616, 1, "Option `{0}' overrides attribute `{1}' given in a source file or added module", "keycontainer", "System.Reflection.AssemblyKeyNameAttribute"); break; } string text4 = attr.GetString(); if (!string.IsNullOrEmpty(text4)) { Error_ObsoleteSecurityAttribute(attr, "keycontainer"); text2 = text4; } break; } case "AssemblyDelaySign": case "AssemblyDelaySignAttribute": case "System.Reflection.AssemblyDelaySignAttribute": { bool boolean = attr.GetBoolean(); if (boolean) { Error_ObsoleteSecurityAttribute(attr, "delaysign"); } delay_sign = boolean; break; } } } } if (public_key == null) { if (text != null || text2 != null) { LoadPublicKey(text, text2); } else if (delay_sign) { Report.Warning(1607, 1, "Delay signing was requested but no key file was given"); } } } public void EmbedResources() { if (Compiler.Settings.Win32IconFile != null) { builder_extra.DefineWin32IconResource(Compiler.Settings.Win32IconFile); } } public void Save() { } protected virtual void SaveModule(PortableExecutableKinds pekind, ImageFileMachine machine) { Report.RuntimeMissingSupport(Location.Null, "-target:module"); } private void SetCustomAttribute(MethodSpec ctor, byte[] data) { if (module_target_attrs != null) { module_target_attrs.AddAssemblyAttribute(ctor, data); } else { Builder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), data); } } private void SetEntryPoint() { } private void Error_ObsoleteSecurityAttribute(Attribute a, string option) { Report.Warning(1699, 1, a.Location, "Use compiler option `{0}' or appropriate project settings instead of `{1}' attribute", option, a.Name); } private void Error_AssemblySigning(string text) { Report.Error(1548, "Error during assembly signing. " + text); } public bool IsFriendAssemblyTo(IAssemblyDefinition assembly) { return false; } private static Version IsValidAssemblyVersion(string version, bool allowGenerated) { string[] array = version.Split(new char[1] { '.' }); if (array.Length < 1 || array.Length > 4) { return null; } int[] array2 = new int[4]; for (int i = 0; i < array.Length; i++) { if (!int.TryParse(array[i], out array2[i])) { if (array[i].Length == 1 && array[i][0] == '*' && allowGenerated) { if (i == 2) { if (array.Length > 3) { return null; } array2[i] = Math.Max((DateTime.Today - new DateTime(2000, 1, 1)).Days, 0); i = 3; } if (i == 3) { array2[i] = (int)(DateTime.Now - DateTime.Today).TotalSeconds / 2; continue; } } return null; } if (array2[i] > 65535) { return null; } } return new Version(array2[0], array2[1], array2[2], array2[3]); } } internal class AssemblyResource : IEquatable { public ResourceAttributes Attributes { get; private set; } public string Name { get; private set; } public string FileName { get; private set; } public bool IsEmbeded { get; set; } public AssemblyResource(string fileName, string name) : this(fileName, name, isPrivate: false) { } public AssemblyResource(string fileName, string name, bool isPrivate) { FileName = fileName; Name = name; Attributes = ((!isPrivate) ? ResourceAttributes.Public : ResourceAttributes.Private); } public bool Equals(AssemblyResource other) { return Name == other.Name; } } internal class AssemblyAttributesPlaceholder : CompilerGeneratedContainer { private static readonly string TypeNamePrefix = "<$AssemblyAttributes${0}>"; public static readonly string AssemblyFieldName = "attributes"; private Field assembly; public AssemblyAttributesPlaceholder(ModuleContainer parent, string outputName) : base(parent, new MemberName(GetGeneratedName(outputName)), Modifiers.INTERNAL | Modifiers.STATIC) { assembly = new Field(this, new TypeExpression(parent.Compiler.BuiltinTypes.Object, base.Location), Modifiers.PUBLIC | Modifiers.STATIC, new MemberName(AssemblyFieldName), null); AddField(assembly); } public void AddAssemblyAttribute(MethodSpec ctor, byte[] data) { assembly.SetCustomAttribute(ctor, data); } public static string GetGeneratedName(string outputName) { return string.Format(TypeNamePrefix, outputName); } } internal class AssemblyBuilderExtension { protected readonly CompilerContext ctx; public AssemblyBuilderExtension(CompilerContext ctx) { this.ctx = ctx; } public virtual Module AddModule(string module) { ctx.Report.RuntimeMissingSupport(Location.Null, "-addmodule"); return null; } public virtual void AddPermissionRequests(PermissionSet[] permissions) { ctx.Report.RuntimeMissingSupport(Location.Null, "assembly declarative security"); } public virtual void AddTypeForwarder(TypeSpec type, Location loc) { ctx.Report.RuntimeMissingSupport(loc, "TypeForwardedToAttribute"); } public virtual void DefineWin32IconResource(string fileName) { ctx.Report.RuntimeMissingSupport(Location.Null, "-win32icon"); } public virtual AssemblyName[] GetReferencedAssemblies() { return null; } public virtual void SetAlgorithmId(uint value, Location loc) { ctx.Report.RuntimeMissingSupport(loc, "AssemblyAlgorithmIdAttribute"); } public virtual void SetCulture(string culture, Location loc) { ctx.Report.RuntimeMissingSupport(loc, "AssemblyCultureAttribute"); } public virtual void SetFlags(uint flags, Location loc) { ctx.Report.RuntimeMissingSupport(loc, "AssemblyFlagsAttribute"); } public virtual void SetVersion(Version version, Location loc) { ctx.Report.RuntimeMissingSupport(loc, "AssemblyVersionAttribute"); } } internal abstract class AssemblyReferencesLoader where T : class { public readonly CompilerContext compiler; public readonly List paths; public AssemblyReferencesLoader(CompilerContext compiler) { this.compiler = compiler; paths = new List(); paths.Add(Directory.GetCurrentDirectory()); paths.AddRange(compiler.Settings.ReferencesLookupPaths); } public abstract T HasObjectType(T assembly); public abstract string[] GetDefaultReferences(); public abstract T LoadAssemblyFile(string fileName, bool isImplicitReference); public abstract void LoadReferences(ModuleContainer module); protected void Error_FileNotFound(string fileName) { compiler.Report.Error(6, "Metadata file `{0}' could not be found", fileName); } protected void Error_FileCorrupted(string fileName) { compiler.Report.Error(9, "Metadata file `{0}' does not contain valid metadata", fileName); } protected void Error_AssemblyIsModule(string fileName) { compiler.Report.Error(1509, "Referenced assembly file `{0}' is a module. Consider using `-addmodule' option to add the module", fileName); } protected void Error_ModuleIsAssembly(string fileName) { compiler.Report.Error(1542, "Added module file `{0}' is an assembly. Consider using `-r' option to reference the file", fileName); } public void LoadReferencesCore(ModuleContainer module, out T corlib_assembly, out List> loaded) { compiler.TimeReporter.Start(TimeReporter.TimerType.ReferencesLoading); loaded = new List>(); if (module.Compiler.Settings.StdLib) { corlib_assembly = LoadAssemblyFile("mscorlib.dll", isImplicitReference: true); } else { corlib_assembly = null; } foreach (string assemblyReference in module.Compiler.Settings.AssemblyReferences) { T val = LoadAssemblyFile(assemblyReference, isImplicitReference: false); if (val != null && !EqualityComparer.Default.Equals(val, corlib_assembly)) { Tuple item = Tuple.Create(module.GlobalRootNamespace, val); if (!loaded.Contains(item)) { loaded.Add(item); } } } if (corlib_assembly == null) { for (int i = 0; i < loaded.Count; i++) { Tuple tuple = loaded[i]; corlib_assembly = HasObjectType(tuple.Item2); if (corlib_assembly == null) { continue; } if (corlib_assembly != tuple.Item2) { T ca = corlib_assembly; i = loaded.FindIndex((Tuple l) => l.Item2 == ca); } if (i >= 0) { loaded.RemoveAt(i); } break; } } foreach (Tuple assemblyReferencesAlias in module.Compiler.Settings.AssemblyReferencesAliases) { T val = LoadAssemblyFile(assemblyReferencesAlias.Item2, isImplicitReference: false); if (val != null) { Tuple item2 = Tuple.Create(module.CreateRootNamespace(assemblyReferencesAlias.Item1), val); if (!loaded.Contains(item2)) { loaded.Add(item2); } } } if (compiler.Settings.LoadDefaultReferences) { string[] defaultReferences = GetDefaultReferences(); foreach (string fileName in defaultReferences) { T val = LoadAssemblyFile(fileName, isImplicitReference: true); if (val != null) { Tuple item3 = Tuple.Create(module.GlobalRootNamespace, val); if (!loaded.Contains(item3)) { loaded.Add(item3); } } } } compiler.TimeReporter.Stop(TimeReporter.TimerType.ReferencesLoading); } } internal interface IAssignMethod { void Emit(EmitContext ec, bool leave_copy); void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound); } internal class LocalTemporary : Expression, IMemoryLocation, IAssignMethod { private LocalBuilder builder; public LocalBuilder Builder => builder; public LocalTemporary(TypeSpec t) { type = t; eclass = ExprClass.Value; } public LocalTemporary(LocalBuilder b, TypeSpec t) : this(t) { builder = b; } public void Release(EmitContext ec) { ec.FreeTemporaryLocal(builder, type); builder = null; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(this)); return CreateExpressionFactoryCall(ec, "Constant", arguments); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return this; } public override void Emit(EmitContext ec) { if (builder == null) { throw new InternalErrorException("Emit without Store, or after Release"); } ec.Emit(OpCodes.Ldloc, builder); } public void Emit(EmitContext ec, bool leave_copy) { Emit(ec); if (leave_copy) { Emit(ec); } } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { if (isCompound) { throw new NotImplementedException(); } source.Emit(ec); Store(ec); if (leave_copy) { Emit(ec); } } public void Store(EmitContext ec) { if (builder == null) { builder = ec.GetTemporaryLocal(type); } ec.Emit(OpCodes.Stloc, builder); } public void AddressOf(EmitContext ec, AddressOp mode) { if (builder == null) { builder = ec.GetTemporaryLocal(type); } if (builder.LocalType.IsByRef) { ec.Emit(OpCodes.Ldloc, builder); } else { ec.Emit(OpCodes.Ldloca, builder); } } } internal abstract class Assign : ExpressionStatement { protected Expression target; protected Expression source; public Expression Target => target; public Expression Source => source; public override Location StartLocation => target.StartLocation; protected Assign(Expression target, Expression source, Location loc) { this.target = target; this.source = source; base.loc = loc; } public override bool ContainsEmitWithAwait() { return target.ContainsEmitWithAwait() || source.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(832, loc, "An expression tree cannot contain an assignment operator"); return null; } protected override Expression DoResolve(ResolveContext ec) { bool flag = true; source = source.Resolve(ec); if (source == null) { flag = false; source = ErrorExpression.Instance; } target = target.ResolveLValue(ec, source); if (target == null || !flag) { return null; } TypeSpec typeSpec = target.Type; TypeSpec typeSpec2 = source.Type; eclass = ExprClass.Value; type = typeSpec; if (!(target is IAssignMethod)) { target.Error_ValueAssignment(ec, source); return null; } if (typeSpec != typeSpec2) { Expression expression = ResolveConversions(ec); if (expression != this) { return expression; } } return this; } protected virtual Expression ResolveConversions(ResolveContext rc) { TypeSpec typeSpec = target.Type; if (source is StackAlloc stackAlloc && typeSpec.Arity == 1 && typeSpec.GetDefinition() == rc.Module.PredefinedTypes.SpanGeneric.TypeSpec && rc.Module.Compiler.Settings.Version >= LanguageVersion.V_7_2) { TypeSpec typeSpec2 = typeSpec.TypeArguments[0]; TypeSpec element = ((PointerContainer)source.Type).Element; if (typeSpec2 == element && stackAlloc.ResolveSpanConversion(rc, typeSpec)) { return this; } } source = Convert.ImplicitConversionRequired(rc, source, typeSpec, source.Location); if (source == null) { return null; } return this; } private void Emit(EmitContext ec, bool is_statement) { IAssignMethod assignMethod = (IAssignMethod)target; assignMethod.EmitAssign(ec, source, !is_statement, this is CompoundAssign); } public override void Emit(EmitContext ec) { Emit(ec, is_statement: false); } public override void EmitStatement(EmitContext ec) { Emit(ec, is_statement: true); } public override void FlowAnalysis(FlowAnalysisContext fc) { source.FlowAnalysis(fc); if (target is ArrayAccess || target is IndexerExpr) { target.FlowAnalysis(fc); } else if (target is PropertyExpr { IsAutoPropertyAccess: false }) { target.FlowAnalysis(fc); } } protected override void CloneTo(CloneContext clonectx, Expression t) { Assign assign = (Assign)t; assign.target = target.Clone(clonectx); assign.source = source.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class SimpleAssign : Assign { public SimpleAssign(Expression target, Expression source) : this(target, source, target.Location) { } public SimpleAssign(Expression target, Expression source, Location loc) : base(target, source, loc) { } private bool CheckEqualAssign(Expression t) { if (source is Assign) { Assign assign = (Assign)source; if (t.Equals(assign.Target)) { return true; } return assign is SimpleAssign && ((SimpleAssign)assign).CheckEqualAssign(t); } return t.Equals(source); } protected override Expression DoResolve(ResolveContext ec) { Expression expression = base.DoResolve(ec); if (expression == null || expression != this) { return expression; } if (CheckEqualAssign(target)) { ec.Report.Warning(1717, 3, loc, "Assignment made to same variable; did you mean to assign something else?"); } return this; } public override void FlowAnalysis(FlowAnalysisContext fc) { base.FlowAnalysis(fc); if (target is VariableReference variableReference) { if (variableReference.VariableInfo != null) { fc.SetVariableAssigned(variableReference.VariableInfo); } } else if (target is FieldExpr fieldExpr) { fieldExpr.SetFieldAssigned(fc); } else if (target is PropertyExpr propertyExpr) { propertyExpr.SetBackingFieldAssigned(fc); } else if (target is TupleDeconstruct tupleDeconstruct) { tupleDeconstruct.SetGeneratedFieldAssigned(fc); } } public override Reachability MarkReachable(Reachability rc) { return source.MarkReachable(rc); } } internal class RuntimeExplicitAssign : Assign { public RuntimeExplicitAssign(Expression target, Expression source) : base(target, source, target.Location) { } protected override Expression ResolveConversions(ResolveContext ec) { source = EmptyCast.Create(source, target.Type); return this; } } internal class CompilerAssign : Assign { public CompilerAssign(Expression target, Expression source, Location loc) : base(target, source, loc) { if (target.Type != null) { type = target.Type; eclass = ExprClass.Value; } } protected override Expression DoResolve(ResolveContext ec) { Expression result = base.DoResolve(ec); if (target is VariableReference { VariableInfo: not null } variableReference) { variableReference.VariableInfo.IsEverAssigned = false; } return result; } public void UpdateSource(Expression source) { base.source = source; } } internal class FieldInitializer : Assign { private sealed class FieldInitializerContext : BlockContext { private readonly ExplicitBlock ctor_block; public override ExplicitBlock ConstructorBlock => ctor_block; public FieldInitializerContext(IMemberContext mc, BlockContext constructorContext) : base(mc, null, constructorContext.ReturnType) { flags |= Options.FieldInitializerScope | Options.ConstructorScope; ctor_block = constructorContext.CurrentBlock.Explicit; if (ctor_block.IsCompilerGenerated) { CurrentBlock = ctor_block; } } } private ExpressionStatement resolved; private FieldBase mc; public int AssignmentOffset { get; private set; } public FieldBase Field => mc; public override Location StartLocation => loc; public bool IsDefaultInitializer { get { if (!(source is Constant constant)) { return false; } FieldExpr fieldExpr = (FieldExpr)target; return constant.IsDefaultInitializer(fieldExpr.Type); } } public override bool IsSideEffectFree => source.IsSideEffectFree; public FieldInitializer(FieldBase mc, Expression expression, Location loc) : base(new FieldExpr(mc.Spec, expression.Location), expression, loc) { this.mc = mc; if (!mc.IsStatic) { ((FieldExpr)target).InstanceExpression = new CompilerGeneratedThis(mc.CurrentType, expression.Location); } } protected override Expression DoResolve(ResolveContext rc) { if (source == null) { return null; } if (resolved == null) { BlockContext blockContext = (BlockContext)rc; FieldInitializerContext fieldInitializerContext = new FieldInitializerContext(mc, blockContext); resolved = base.DoResolve((ResolveContext)fieldInitializerContext) as ExpressionStatement; AssignmentOffset = fieldInitializerContext.AssignmentInfoOffset - blockContext.AssignmentInfoOffset; } return resolved; } public override void EmitStatement(EmitContext ec) { if (resolved == null) { return; } if (ec.HasSet(BuilderContext.Options.OmitDebugInfo) && ec.HasMethodSymbolBuilder) { using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: false)) { ec.Mark(loc); } } if (resolved != this) { resolved.EmitStatement(ec); } else { base.EmitStatement(ec); } } public override void FlowAnalysis(FlowAnalysisContext fc) { source.FlowAnalysis(fc); ((FieldExpr)target).SetFieldAssigned(fc); } } internal class PrimaryConstructorAssign : SimpleAssign { private readonly Field field; private readonly Parameter parameter; public PrimaryConstructorAssign(Field field, Parameter parameter) : base(null, null, parameter.Location) { this.field = field; this.parameter = parameter; } protected override Expression DoResolve(ResolveContext rc) { target = new FieldExpr(field, loc); source = rc.CurrentBlock.ParametersBlock.GetParameterInfo(parameter).CreateReferenceExpression(rc, loc); return base.DoResolve(rc); } public override void EmitStatement(EmitContext ec) { using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { base.EmitStatement(ec); } } } internal class CompoundAssign : Assign { public sealed class TargetExpression : Expression { private readonly Expression child; public bool RequiresEmitWithAwait { get; set; } public TargetExpression(Expression child) { this.child = child; loc = child.Location; } public override bool ContainsEmitWithAwait() { return RequiresEmitWithAwait || child.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext ec) { type = child.Type; eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { child.Emit(ec); } public override Expression EmitToField(EmitContext ec) { return child.EmitToField(ec); } } private readonly Binary.Operator op; private Expression right; private Expression left; public Binary.Operator Operator => op; public CompoundAssign(Binary.Operator op, Expression target, Expression source) : base(target, source, target.Location) { right = source; this.op = op; } public CompoundAssign(Binary.Operator op, Expression target, Expression source, Expression left) : this(op, target, source) { this.left = left; } protected override Expression DoResolve(ResolveContext ec) { right = right.Resolve(ec); if (right == null) { return null; } MemberAccess memberAccess = target as MemberAccess; using (ec.Set(ResolveContext.Options.CompoundAssignmentScope)) { target = target.Resolve(ec); } if (target == null) { return null; } if (target is MethodGroupExpr) { ec.Report.Error(1656, loc, "Cannot assign to `{0}' because it is a `{1}'", ((MethodGroupExpr)target).Name, target.ExprClassName); return null; } if (target is EventExpr eventExpr) { source = Convert.ImplicitConversionRequired(ec, right, target.Type, loc); if (source == null) { return null; } Expression right_side = ((op == Binary.Operator.Addition) ? EmptyExpression.EventAddition : ((op != Binary.Operator.Subtraction) ? null : EmptyExpression.EventSubtraction)); target = target.ResolveLValue(ec, right_side); if (target == null) { return null; } eclass = ExprClass.Value; type = eventExpr.Operator.ReturnType; return this; } if (left == null) { left = new TargetExpression(target); } source = new Binary(op, left, right, isCompound: true); if (target is DynamicMemberAssignable) { Arguments arguments = ((DynamicMemberAssignable)target).Arguments; source = source.Resolve(ec); Arguments arguments2 = new Arguments(arguments.Count + 1); arguments2.AddRange(arguments); arguments2.Add(new Argument(source)); CSharpBinderFlags cSharpBinderFlags = CSharpBinderFlags.ValueFromCompoundAssignment; if (ec.HasSet(ResolveContext.Options.CheckedScope)) { cSharpBinderFlags |= CSharpBinderFlags.CheckedContext; } if (target is DynamicMemberBinder) { source = new DynamicMemberBinder(memberAccess.Name, cSharpBinderFlags, arguments2, loc).Resolve(ec); if (op == Binary.Operator.Addition || op == Binary.Operator.Subtraction) { arguments2 = new Arguments(arguments.Count + 1); arguments2.AddRange(arguments); arguments2.Add(new Argument(right)); string text = ((op == Binary.Operator.Addition) ? "add_" : "remove_"); Expression expression = DynamicInvocation.CreateSpecialNameInvoke(new MemberAccess(right, text + memberAccess.Name, loc), arguments2, loc).Resolve(ec); arguments2 = new Arguments(arguments.Count); arguments2.AddRange(arguments); source = new DynamicEventCompoundAssign(memberAccess.Name, arguments2, (ExpressionStatement)source, (ExpressionStatement)expression, loc).Resolve(ec); } } else { source = new DynamicIndexBinder(cSharpBinderFlags, arguments2, loc).Resolve(ec); } return source; } return base.DoResolve(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { target.FlowAnalysis(fc); source.FlowAnalysis(fc); } protected override Expression ResolveConversions(ResolveContext ec) { if (target is RuntimeValueExpression) { return this; } TypeSpec typeSpec = target.Type; if (Convert.ImplicitConversionExists(ec, source, typeSpec)) { source = Convert.ImplicitConversion(ec, source, typeSpec, loc); return this; } Binary binary = source as Binary; if (binary == null) { if (source is ReducedExpression) { binary = ((ReducedExpression)source).OriginalExpression as Binary; } else if (source is ReducedExpression.ReducedConstantExpression) { binary = ((ReducedExpression.ReducedConstantExpression)source).OriginalExpression as Binary; } else if (source is LiftedBinaryOperator) { LiftedBinaryOperator liftedBinaryOperator = (LiftedBinaryOperator)source; if (liftedBinaryOperator.UserOperator == null) { binary = liftedBinaryOperator.Binary; } } else if (source is TypeCast) { binary = ((TypeCast)source).Child as Binary; } } if (binary != null && ((binary.Oper & Binary.Operator.ShiftMask) != 0 || Convert.ImplicitConversionExists(ec, right, typeSpec))) { source = Convert.ExplicitConversion(ec, source, typeSpec, loc); return this; } if (source.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(source)); return new SimpleAssign(target, new DynamicConversion(typeSpec, CSharpBinderFlags.ConvertExplicit, arguments, loc), loc).Resolve(ec); } right.Error_ValueCannotBeConverted(ec, typeSpec, expl: false); return null; } protected override void CloneTo(CloneContext clonectx, Expression t) { CompoundAssign compoundAssign = (CompoundAssign)t; compoundAssign.right = (compoundAssign.source = source.Clone(clonectx)); compoundAssign.target = target.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Await : ExpressionStatement { private Expression expr; private AwaitStatement stmt; public Expression Expr => expr; public AwaitStatement Statement => stmt; public Await(Expression expr, Location loc) { this.expr = expr; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression target) { Await obj = (Await)target; obj.expr = expr.Clone(clonectx); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotImplementedException("ET"); } public override bool ContainsEmitWithAwait() { return true; } public override void FlowAnalysis(FlowAnalysisContext fc) { stmt.Expr.FlowAnalysis(fc); stmt.RegisterResumePoint(); } protected override Expression DoResolve(ResolveContext rc) { if (rc.HasSet(ResolveContext.Options.LockScope)) { rc.Report.Error(1996, loc, "The `await' operator cannot be used in the body of a lock statement"); } if (rc.IsUnsafe) { rc.Report.Error(4004, loc, "The `await' operator cannot be used in an unsafe context"); } BlockContext bc = (BlockContext)rc; stmt = new AwaitStatement(expr, loc); if (!stmt.Resolve(bc)) { return null; } if (rc.HasSet(ResolveContext.Options.FinallyScope) && rc.CurrentAnonymousMethod != null) { AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)rc.CurrentAnonymousMethod.Storey; asyncTaskStorey.HasAwaitInsideFinally = true; } type = stmt.ResultType; eclass = ExprClass.Variable; return this; } public override void Emit(EmitContext ec) { stmt.EmitPrologue(ec); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { stmt.Emit(ec); } } public override Expression EmitToField(EmitContext ec) { stmt.EmitPrologue(ec); return stmt.GetResultExpression(ec); } public void EmitAssign(EmitContext ec, FieldExpr field) { stmt.EmitPrologue(ec); field.InstanceExpression.Emit(ec); stmt.Emit(ec); } public override void EmitStatement(EmitContext ec) { stmt.EmitStatement(ec); } public override Reachability MarkReachable(Reachability rc) { return stmt.MarkReachable(rc); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class AwaitStatement : YieldStatement { public sealed class AwaitableMemberAccess : MemberAccess { public bool ProbingMode { get; set; } public AwaitableMemberAccess(Expression expr) : base(expr, "GetAwaiter") { } public override void Error_TypeDoesNotContainDefinition(ResolveContext rc, TypeSpec type, string name) { Error_OperatorCannotBeApplied(rc, type); } protected override void Error_OperatorCannotBeApplied(ResolveContext rc, TypeSpec type) { if (!ProbingMode) { if (base.LeftExpression is Invocation { MethodGroup: not null } invocation && (invocation.MethodGroup.BestCandidate.Modifiers & Modifiers.ASYNC) != 0) { rc.Report.Error(4008, loc, "Cannot await void method `{0}'. Consider changing method return type to `Task'", invocation.GetSignatureForError()); } else if (type != InternalType.ErrorType) { rc.Report.Error(4001, loc, "Cannot await `{0}' expression", type.GetSignatureForError()); } } } } private sealed class GetResultInvocation : Invocation { public GetResultInvocation(MethodGroupExpr mge, Arguments arguments) : base(null, arguments) { mg = mge; type = mg.BestCandidateReturnType; } public override Expression EmitToField(EmitContext ec) { return this; } } private Field awaiter; private AwaiterDefinition awaiter_definition; private TypeSpec type; private TypeSpec result_type; private bool IsDynamic => awaiter_definition == null; public TypeSpec ResultType => result_type; public AwaitStatement(Expression expr, Location loc) : base(expr, loc) { unwind_protect = true; } protected override void DoEmit(EmitContext ec) { using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { GetResultExpression(ec).Emit(ec); } } public Expression GetResultExpression(EmitContext ec) { FieldExpr fieldExpr = new FieldExpr(awaiter, loc); fieldExpr.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc); if (IsDynamic) { ResolveContext rc = new ResolveContext(ec.MemberContext); return new Invocation(new MemberAccess(fieldExpr, "GetResult"), new Arguments(0)).Resolve(rc); } MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(awaiter_definition.GetResult, fieldExpr.Type, loc); methodGroupExpr.InstanceExpression = fieldExpr; return new GetResultInvocation(methodGroupExpr, new Arguments(0)); } public void EmitPrologue(EmitContext ec) { awaiter = ((AsyncTaskStorey)machine_initializer.Storey).AddAwaiter(expr.Type); FieldExpr fieldExpr = new FieldExpr(awaiter, loc); fieldExpr.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc); Label label = ec.DefineLabel(); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { fieldExpr.EmitAssign(ec, expr, leave_copy: false, isCompound: false); Expression expression; if (IsDynamic) { ResolveContext rc = new ResolveContext(ec.MemberContext); Arguments arguments = new Arguments(1); arguments.Add(new Argument(fieldExpr)); expression = new DynamicMemberBinder("IsCompleted", arguments, loc).Resolve(rc); arguments = new Arguments(1); arguments.Add(new Argument(expression)); expression = new DynamicConversion(ec.Module.Compiler.BuiltinTypes.Bool, CSharpBinderFlags.None, arguments, loc).Resolve(rc); } else { PropertyExpr propertyExpr = PropertyExpr.CreatePredefined(awaiter_definition.IsCompleted, loc); propertyExpr.InstanceExpression = fieldExpr; expression = propertyExpr; } expression.EmitBranchable(ec, label, on_true: true); } base.DoEmit(ec); ec.AssertEmptyStack(); AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)machine_initializer.Storey; if (IsDynamic) { asyncTaskStorey.EmitAwaitOnCompletedDynamic(ec, fieldExpr); } else { asyncTaskStorey.EmitAwaitOnCompleted(ec, fieldExpr); } machine_initializer.EmitLeave(ec, unwind_protect); ec.MarkLabel(resume_point); ec.MarkLabel(label); } public void EmitStatement(EmitContext ec) { EmitPrologue(ec); DoEmit(ec); awaiter.IsAvailableForReuse = true; if (ResultType.Kind != MemberKind.Void) { ec.Emit(OpCodes.Pop); } } private void Error_WrongAwaiterPattern(ResolveContext rc, TypeSpec awaiter) { rc.Report.Error(4011, loc, "The awaiter type `{0}' must have suitable IsCompleted and GetResult members", awaiter.GetSignatureForError()); } public override bool Resolve(BlockContext bc) { if (bc.CurrentBlock is QueryBlock) { bc.Report.Error(1995, loc, "The `await' operator may only be used in a query expression within the first collection expression of the initial `from' clause or within the collection expression of a `join' clause"); return false; } if (!base.Resolve(bc)) { return false; } type = expr.Type; Arguments arguments = new Arguments(0); if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { result_type = type; expr = new Invocation(new MemberAccess(expr, "GetAwaiter"), arguments).Resolve(bc); return true; } Expression expression = new AwaitableMemberAccess(expr).Resolve(bc); if (expression == null) { return false; } SessionReportPrinter sessionReportPrinter = new SessionReportPrinter(); ReportPrinter printer = bc.Report.SetPrinter(sessionReportPrinter); expression = new Invocation(new ParenthesizedExpression(expression, Location.Null), arguments).Resolve(bc); bc.Report.SetPrinter(printer); if (sessionReportPrinter.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression(expression.Type)) { bc.Report.Error(1986, expr.Location, "The `await' operand type `{0}' must have suitable GetAwaiter method", expr.Type.GetSignatureForError()); return false; } TypeSpec typeSpec = expression.Type; awaiter_definition = bc.Module.GetAwaiter(typeSpec); if (!awaiter_definition.IsValidPattern) { Error_WrongAwaiterPattern(bc, typeSpec); return false; } if (!awaiter_definition.INotifyCompletion) { bc.Report.Error(4027, loc, "The awaiter type `{0}' must implement interface `{1}'", typeSpec.GetSignatureForError(), bc.Module.PredefinedTypes.INotifyCompletion.GetSignatureForError()); return false; } expr = expression; result_type = awaiter_definition.GetResult.ReturnType; return true; } } internal class AsyncInitializerStatement : StatementExpression { public AsyncInitializerStatement(AsyncInitializer expr) : base(expr) { } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { base.DoFlowAnalysis(fc); AsyncInitializer asyncInitializer = (AsyncInitializer)base.Expr; bool result = !asyncInitializer.Block.HasReachableClosingBrace; AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)asyncInitializer.Storey; if (asyncTaskStorey.ReturnType.IsGenericTask) { return result; } return true; } public override Reachability MarkReachable(Reachability rc) { if (!rc.IsUnreachable) { reachable = true; } AsyncInitializer asyncInitializer = (AsyncInitializer)base.Expr; rc = asyncInitializer.Block.MarkReachable(rc); AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)asyncInitializer.Storey; if (asyncTaskStorey.ReturnType != null && asyncTaskStorey.ReturnType.IsGenericTask) { return rc; } return Reachability.CreateUnreachable(); } } internal class AsyncInitializer : StateMachineInitializer { private TypeInferenceContext return_inference; public override string ContainerType => "async state machine block"; public TypeSpec DelegateType { get; set; } public StackFieldExpr HoistedReturnState { get; set; } public override bool IsIterator => false; public TypeInferenceContext ReturnTypeInference => return_inference; public AsyncInitializer(ParametersBlock block, TypeDefinition host, TypeSpec returnType) : base(block, host, returnType) { } protected override BlockContext CreateBlockContext(BlockContext bc) { BlockContext blockContext = base.CreateBlockContext(bc); if (bc.CurrentAnonymousMethod is AnonymousMethodBody anonymousMethodBody) { return_inference = anonymousMethodBody.ReturnTypeInference; } blockContext.Set(ResolveContext.Options.TryScope); return blockContext; } public override void Emit(EmitContext ec) { throw new NotImplementedException(); } public void EmitCatchBlock(EmitContext ec) { LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(ec.Module.Compiler.BuiltinTypes.Exception, block, base.Location); ec.BeginCatchBlock(localVariable.Type); localVariable.EmitAssign(ec); ec.EmitThis(); ec.EmitInt(-1); ec.Emit(OpCodes.Stfld, storey.PC.Spec); ((AsyncTaskStorey)Storey).EmitSetException(ec, new LocalVariableReference(localVariable, base.Location)); ec.Emit(OpCodes.Leave, move_next_ok); ec.EndExceptionBlock(); } protected override void EmitMoveNextEpilogue(EmitContext ec) { AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)Storey; asyncTaskStorey.EmitSetResult(ec); } public override void EmitStatement(EmitContext ec) { AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)Storey; asyncTaskStorey.EmitInitializer(ec); ec.Emit(OpCodes.Ret); } public override Reachability MarkReachable(Reachability rc) { return rc; } } internal class AsyncTaskStorey : StateMachine { private int awaiters; private Field builder; private readonly TypeSpec return_type; private MethodSpec set_result; private MethodSpec set_exception; private MethodSpec builder_factory; private MethodSpec builder_start; private PropertySpec task; private int locals_captured; private Dictionary> stack_fields; private Dictionary> awaiter_fields; public bool HasAwaitInsideFinally { get; set; } public Expression HoistedReturnValue { get; set; } public TypeSpec ReturnType => return_type; public PropertySpec Task => task; protected override TypeAttributes TypeAttr => base.TypeAttr & ~TypeAttributes.SequentialLayout; public AsyncTaskStorey(ParametersBlock block, IMemberContext context, AsyncInitializer initializer, TypeSpec type) : base(block, initializer.Host, context.CurrentMemberDefinition as MemberBase, context.CurrentTypeParameters, "async", MemberKind.Struct) { return_type = type; awaiter_fields = new Dictionary>(); } public Field AddAwaiter(TypeSpec type) { if (mutator != null) { type = mutator.Mutate(type); } if (awaiter_fields.TryGetValue(type, out var value)) { foreach (Field item in value) { if (item.IsAvailableForReuse) { item.IsAvailableForReuse = false; return item; } } } Field field = AddCompilerGeneratedField("$awaiter" + awaiters++.ToString("X"), new TypeExpression(type, base.Location), privateAccess: true); field.Define(); if (value == null) { value = new List(); awaiter_fields.Add(type, value); } value.Add(field); return field; } public Field AddCapturedLocalVariable(TypeSpec type, bool requiresUninitialized = false) { if (mutator != null) { type = mutator.Mutate(type); } List value = null; if (stack_fields == null) { stack_fields = new Dictionary>(); } else if (stack_fields.TryGetValue(type, out value) && !requiresUninitialized) { foreach (Field item in value) { if (item.IsAvailableForReuse) { item.IsAvailableForReuse = false; return item; } } } Field field = AddCompilerGeneratedField("$stack" + locals_captured++.ToString("X"), new TypeExpression(type, base.Location), privateAccess: true); field.Define(); if (value == null) { value = new List(); stack_fields.Add(type, value); } value.Add(field); return field; } protected override bool DoDefineMembers() { bool flag = false; PredefinedType iAsyncStateMachine = Module.PredefinedTypes.IAsyncStateMachine; TypeSpec typeSpec; MethodSpec methodSpec2; if (return_type.IsCustomTaskType()) { BuiltinTypes builtinTypes = Compiler.BuiltinTypes; typeSpec = return_type.MemberDefinition.GetAsyncMethodBuilder(); TypeSpec type; TypeSpec[] typeParameters; if (return_type.IsGeneric) { TypeSpec typeSpec2 = typeSpec; ModuleContainer module = Module; typeParameters = typeSpec.MemberDefinition.TypeParameters; type = typeSpec2.MakeGenericType(module, typeParameters); } else { type = typeSpec; } typeParameters = typeSpec.MemberDefinition.TypeParameters; MemberFilter filter = MemberFilter.Method("SetResult", 0, ParametersCompiled.CreateFullyResolved(typeParameters), builtinTypes.Void); set_result = new PredefinedMember(Module, typeSpec, filter).Resolve(base.Location); MemberFilter filter2 = MemberFilter.Method("SetException", 0, ParametersCompiled.CreateFullyResolved(builtinTypes.Exception), builtinTypes.Void); set_exception = new PredefinedMember(Module, typeSpec, filter2).Resolve(base.Location); MemberFilter filter3 = MemberFilter.Method("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, type); builder_factory = new PredefinedMember(Module, typeSpec, filter3).Resolve(base.Location); MethodSpec methodSpec = builder_factory; if (methodSpec != null && !methodSpec.IsStatic) { throw new NotImplementedException("report better error message"); } IParameterData[] param = new ParameterData[1] { new ParameterData(null, Parameter.Modifier.REF) }; typeParameters = new TypeParameterSpec[1] { new TypeParameterSpec(0, null, SpecialConstraint.None, Variance.None, null) }; MemberFilter filter4 = MemberFilter.Method("Start", 1, new ParametersImported(param, typeParameters, hasParams: false), builtinTypes.Void); builder_start = new PredefinedMember(Module, typeSpec, filter4).Resolve(base.Location); if (!iAsyncStateMachine.Define()) { return false; } MemberFilter filter5 = MemberFilter.Method("SetStateMachine", 0, ParametersCompiled.CreateFullyResolved(iAsyncStateMachine.TypeSpec), builtinTypes.Void); methodSpec2 = new PredefinedMember(Module, typeSpec, filter5).Resolve(base.Location); MemberFilter filter6 = MemberFilter.Property("Task", return_type.MemberDefinition as TypeSpec); task = new PredefinedMember(Module, typeSpec, filter6).Resolve(base.Location); if (set_result == null || set_exception == null || builder_factory == null || builder_start == null || methodSpec2 == null || task == null || !Module.PredefinedTypes.INotifyCompletion.Define()) { return false; } flag = return_type.IsGeneric; } else { PredefinedMembers predefinedMembers = Module.PredefinedMembers; PredefinedType predefinedType; PredefinedMember predefinedMember; PredefinedMember predefinedMember2; PredefinedMember predefinedMember3; PredefinedMember predefinedMember4; PredefinedMember predefinedMember5; if (return_type.Kind == MemberKind.Void) { predefinedType = Module.PredefinedTypes.AsyncVoidMethodBuilder; predefinedMember = predefinedMembers.AsyncVoidMethodBuilderCreate; predefinedMember2 = predefinedMembers.AsyncVoidMethodBuilderStart; predefinedMember3 = predefinedMembers.AsyncVoidMethodBuilderSetResult; predefinedMember4 = predefinedMembers.AsyncVoidMethodBuilderSetException; predefinedMember5 = predefinedMembers.AsyncVoidMethodBuilderSetStateMachine; } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { predefinedType = Module.PredefinedTypes.AsyncTaskMethodBuilder; predefinedMember = predefinedMembers.AsyncTaskMethodBuilderCreate; predefinedMember2 = predefinedMembers.AsyncTaskMethodBuilderStart; predefinedMember3 = predefinedMembers.AsyncTaskMethodBuilderSetResult; predefinedMember4 = predefinedMembers.AsyncTaskMethodBuilderSetException; predefinedMember5 = predefinedMembers.AsyncTaskMethodBuilderSetStateMachine; task = predefinedMembers.AsyncTaskMethodBuilderTask.Get(); } else { predefinedType = Module.PredefinedTypes.AsyncTaskMethodBuilderGeneric; predefinedMember = predefinedMembers.AsyncTaskMethodBuilderGenericCreate; predefinedMember2 = predefinedMembers.AsyncTaskMethodBuilderGenericStart; predefinedMember3 = predefinedMembers.AsyncTaskMethodBuilderGenericSetResult; predefinedMember4 = predefinedMembers.AsyncTaskMethodBuilderGenericSetException; predefinedMember5 = predefinedMembers.AsyncTaskMethodBuilderGenericSetStateMachine; task = predefinedMembers.AsyncTaskMethodBuilderGenericTask.Get(); flag = true; } set_result = predefinedMember3.Get(); set_exception = predefinedMember4.Get(); builder_factory = predefinedMember.Get(); builder_start = predefinedMember2.Get(); methodSpec2 = predefinedMember5.Get(); if (!predefinedType.Define() || !iAsyncStateMachine.Define() || set_result == null || builder_factory == null || set_exception == null || methodSpec2 == null || builder_start == null || !Module.PredefinedTypes.INotifyCompletion.Define()) { base.Report.Error(1993, base.Location, "Cannot find compiler required types for asynchronous functions support. Are you targeting the wrong framework version?"); return base.DoDefineMembers(); } typeSpec = predefinedType.TypeSpec; } if (flag) { TypeSpec[] targs = return_type.TypeArguments; if (mutator != null) { targs = mutator.Mutate(targs); } typeSpec = typeSpec.MakeGenericType(Module, targs); set_result = MemberCache.GetMember(typeSpec, set_result); set_exception = MemberCache.GetMember(typeSpec, set_exception); methodSpec2 = MemberCache.GetMember(typeSpec, methodSpec2); if (task != null) { task = MemberCache.GetMember(typeSpec, task); } } builder = AddCompilerGeneratedField("$builder", new TypeExpression(typeSpec, base.Location)); Field field = ((!flag || !HasAwaitInsideFinally) ? null : AddCompilerGeneratedField("$return", new TypeExpression(typeSpec.TypeArguments[0], base.Location))); Method method = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Void, base.Location), Modifiers.PUBLIC | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN, new MemberName("SetStateMachine"), ParametersCompiled.CreateFullyResolved(new Parameter(new TypeExpression(iAsyncStateMachine.TypeSpec, base.Location), "stateMachine", Parameter.Modifier.NONE, null, base.Location), iAsyncStateMachine.TypeSpec), null); ToplevelBlock toplevelBlock = new ToplevelBlock(Compiler, method.ParameterInfo, base.Location); toplevelBlock.IsCompilerGenerated = true; method.Block = toplevelBlock; base.Members.Add(method); if (!base.DoDefineMembers()) { return false; } MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(methodSpec2, typeSpec, base.Location); methodGroupExpr.InstanceExpression = new FieldExpr(builder, base.Location); ParameterReference parameterReference = toplevelBlock.GetParameterReference(0, base.Location); parameterReference.Type = iAsyncStateMachine.TypeSpec; parameterReference.eclass = ExprClass.Variable; Arguments arguments = new Arguments(1); arguments.Add(new Argument(parameterReference)); method.Block.AddStatement(new StatementExpression(new Invocation(methodGroupExpr, arguments))); if (flag) { if (field != null) { HoistedReturnValue = new FieldExpr(field, base.Location) { InstanceExpression = new CompilerGeneratedThis(CurrentType, Location.Null) }; } else { HoistedReturnValue = TemporaryVariableReference.Create(typeSpec.TypeArguments[0], base.StateMachineMethod.Block, base.Location); } } return true; } public void EmitAwaitOnCompletedDynamic(EmitContext ec, FieldExpr awaiter) { PredefinedType iCriticalNotifyCompletion = Module.PredefinedTypes.ICriticalNotifyCompletion; if (!iCriticalNotifyCompletion.Define()) { throw new NotImplementedException(); } LocalTemporary localTemporary = new LocalTemporary(iCriticalNotifyCompletion.TypeSpec); Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); awaiter.Emit(ec); ec.Emit(OpCodes.Isinst, iCriticalNotifyCompletion.TypeSpec); localTemporary.Store(ec); localTemporary.Emit(ec); ec.Emit(OpCodes.Brtrue_S, label); LocalTemporary localTemporary2 = new LocalTemporary(Module.PredefinedTypes.INotifyCompletion.TypeSpec); awaiter.Emit(ec); ec.Emit(OpCodes.Castclass, localTemporary2.Type); localTemporary2.Store(ec); EmitOnCompleted(ec, localTemporary2, unsafeVersion: false); localTemporary2.Release(ec); ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); EmitOnCompleted(ec, localTemporary, unsafeVersion: true); ec.MarkLabel(label2); localTemporary.Release(ec); } public void EmitAwaitOnCompleted(EmitContext ec, FieldExpr awaiter) { bool unsafeVersion = false; if (Module.PredefinedTypes.ICriticalNotifyCompletion.Define()) { unsafeVersion = awaiter.Type.ImplementsInterface(Module.PredefinedTypes.ICriticalNotifyCompletion.TypeSpec, variantly: false); } EmitOnCompleted(ec, awaiter, unsafeVersion); } private void EmitOnCompleted(EmitContext ec, Expression awaiter, bool unsafeVersion) { PredefinedMembers predefinedMembers = Module.PredefinedMembers; bool flag = false; PredefinedMember predefinedMember; if (return_type.Kind == MemberKind.Void) { predefinedMember = (unsafeVersion ? predefinedMembers.AsyncVoidMethodBuilderOnCompletedUnsafe : predefinedMembers.AsyncVoidMethodBuilderOnCompleted); } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { predefinedMember = (unsafeVersion ? predefinedMembers.AsyncTaskMethodBuilderOnCompletedUnsafe : predefinedMembers.AsyncTaskMethodBuilderOnCompleted); } else if (return_type.IsGenericTask) { predefinedMember = (unsafeVersion ? predefinedMembers.AsyncTaskMethodBuilderGenericOnCompletedUnsafe : predefinedMembers.AsyncTaskMethodBuilderGenericOnCompleted); flag = true; } else { IParameterData[] param = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; TypeSpec[] types = new TypeParameterSpec[2] { new TypeParameterSpec(0, null, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, null, SpecialConstraint.None, Variance.None, null) }; ParametersImported param2 = new ParametersImported(param, types, hasParams: false); MemberFilter filter = (unsafeVersion ? MemberFilter.Method("AwaitUnsafeOnCompleted", 2, param2, Compiler.BuiltinTypes.Void) : MemberFilter.Method("AwaitOnCompleted", 2, param2, Compiler.BuiltinTypes.Void)); predefinedMember = new PredefinedMember(Module, return_type.MemberDefinition.GetAsyncMethodBuilder(), filter); flag = return_type.IsGeneric; } MethodSpec methodSpec = predefinedMember.Resolve(base.Location); if (methodSpec == null) { return; } if (flag) { methodSpec = MemberCache.GetMember(set_result.DeclaringType, methodSpec); } methodSpec = methodSpec.MakeGenericMethod(this, awaiter.Type, ec.CurrentType); MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(methodSpec, methodSpec.DeclaringType, base.Location); methodGroupExpr.InstanceExpression = new FieldExpr(builder, base.Location) { InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, base.Location) }; Arguments arguments = new Arguments(2); arguments.Add(new Argument(awaiter, Argument.AType.Ref)); arguments.Add(new Argument(new CompilerGeneratedThis(CurrentType, base.Location), Argument.AType.Ref)); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { methodGroupExpr.EmitCall(ec, arguments, statement: true); } } public void EmitInitializer(EmitContext ec) { if (builder == null) { return; } TemporaryVariableReference temporaryVariableReference = (TemporaryVariableReference)Instance; FieldSpec member = builder.Spec; if (base.MemberName.Arity > 0) { member = MemberCache.GetMember(temporaryVariableReference.Type, member); } if (builder_factory.DeclaringType.IsGeneric) { TypeSpec[] typeArguments = return_type.TypeArguments; InflatedTypeSpec container = builder_factory.DeclaringType.MakeGenericType(Module, typeArguments); builder_factory = MemberCache.GetMember(container, builder_factory); builder_start = MemberCache.GetMember(container, builder_start); } temporaryVariableReference.AddressOf(ec, AddressOp.Store); ec.Emit(OpCodes.Call, builder_factory); ec.Emit(OpCodes.Stfld, member); temporaryVariableReference.AddressOf(ec, AddressOp.Store); bool isStruct = builder.MemberType.IsStruct; ec.Emit(isStruct ? OpCodes.Ldflda : OpCodes.Ldfld, member); if (Task != null) { ec.Emit(OpCodes.Dup); } temporaryVariableReference.AddressOf(ec, AddressOp.Store); ec.Emit(isStruct ? OpCodes.Call : OpCodes.Callvirt, builder_start.MakeGenericMethod(Module, temporaryVariableReference.Type)); if (Task != null) { MethodSpec getter = Task.Get; if (base.MemberName.Arity > 0) { getter = MemberCache.GetMember(member.MemberType, getter); } PropertyExpr propertyExpr = new PropertyExpr(Task, base.Location) { InstanceExpression = EmptyExpression.Null, Getter = getter }; propertyExpr.Emit(ec); } } public void EmitSetException(EmitContext ec, LocalVariableReference exceptionVariable) { MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(set_exception, set_exception.DeclaringType, base.Location); methodGroupExpr.InstanceExpression = new FieldExpr(builder, base.Location) { InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, base.Location) }; Arguments arguments = new Arguments(1); arguments.Add(new Argument(exceptionVariable)); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { methodGroupExpr.EmitCall(ec, arguments, statement: true); } } public void EmitSetResult(EmitContext ec) { MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(set_result, set_result.DeclaringType, base.Location); methodGroupExpr.InstanceExpression = new FieldExpr(builder, base.Location) { InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, base.Location) }; Arguments arguments; if (HoistedReturnValue == null) { arguments = new Arguments(0); } else { arguments = new Arguments(1); arguments.Add(new Argument(HoistedReturnValue)); } using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { methodGroupExpr.EmitCall(ec, arguments, statement: true); } } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { base_type = Compiler.BuiltinTypes.ValueType; base_class = null; PredefinedType iAsyncStateMachine = Module.PredefinedTypes.IAsyncStateMachine; if (iAsyncStateMachine.Define()) { return new TypeSpec[1] { iAsyncStateMachine.TypeSpec }; } return null; } } internal class StackFieldExpr : FieldExpr, IExpressionCleanup { public bool AutomaticallyReuse { get; set; } public bool IsAvailableForReuse { get { Field field = (Field)spec.MemberDefinition; return field.IsAvailableForReuse; } private set { Field field = (Field)spec.MemberDefinition; field.IsAvailableForReuse = value; } } public StackFieldExpr(Field field) : base(field, Location.Null) { AutomaticallyReuse = true; } public override void AddressOf(EmitContext ec, AddressOp mode) { base.AddressOf(ec, mode); if (mode == AddressOp.Load && AutomaticallyReuse) { IsAvailableForReuse = true; } } public override void Emit(EmitContext ec) { base.Emit(ec); if (AutomaticallyReuse) { PrepareCleanup(ec); } } public void EmitLoad(EmitContext ec) { base.Emit(ec); } public void PrepareCleanup(EmitContext ec) { IsAvailableForReuse = true; if (TypeSpec.IsReferenceType(type)) { ec.AddStatementEpilog(this); } } void IExpressionCleanup.EmitCleanup(EmitContext ec) { EmitAssign(ec, new NullConstant(type, loc), leave_copy: false, isCompound: false); } } internal static class TypeSpecAsyncExtensions { public static bool IsCustomTaskType(this TypeSpec type) { if (type.Arity > 1) { return false; } TypeSpec asyncMethodBuilder = type.MemberDefinition.GetAsyncMethodBuilder(); if (asyncMethodBuilder == null) { return false; } return asyncMethodBuilder.Arity == type.Arity; } } internal abstract class Attributable { protected Attributes attributes; public Attributes OptAttributes { get { return attributes; } set { attributes = value; } } public abstract AttributeTargets AttributeTargets { get; } public abstract string[] ValidAttributeTargets { get; } public void AddAttributes(Attributes attrs, IMemberContext context) { if (attrs != null) { if (attributes == null) { attributes = attrs; } else { attributes.AddAttributes(attrs.Attrs); } attrs.AttachTo(this, context); } } public abstract void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa); public abstract bool IsClsComplianceRequired(); } internal class Attribute { public readonly string ExplicitTarget; public AttributeTargets Target; private readonly ATypeNameExpression expression; private Arguments pos_args; private Arguments named_args; private bool resolve_error; private bool arg_resolved; private readonly bool nameEscaped; private readonly Location loc; public TypeSpec Type; private Attributable[] targets; private IMemberContext context; public static readonly AttributeUsageAttribute DefaultUsageAttribute = new AttributeUsageAttribute(AttributeTargets.All); public static readonly object[] EmptyObject = new object[0]; private List> named_values; public Location Location => loc; public Arguments NamedArguments => named_args; public Arguments PositionalArguments => pos_args; public bool ResolveError => resolve_error; public ATypeNameExpression TypeExpression => expression; private Attributable Owner => targets[0]; public bool HasSecurityAttribute { get { PredefinedAttribute security = context.Module.PredefinedAttributes.Security; return security.IsDefined && TypeSpec.IsBaseClass(Type, security.TypeSpec, dynamicIsObject: false); } } public string Name => expression.Name; public Report Report => context.Module.Compiler.Report; public Attribute(string target, ATypeNameExpression expr, Arguments[] args, Location loc, bool nameEscaped) { expression = expr; if (args != null) { pos_args = args[0]; named_args = args[1]; } this.loc = loc; ExplicitTarget = target; this.nameEscaped = nameEscaped; } private void AddModuleCharSet(ResolveContext rc) { if (!HasField("CharSet") && rc.Module.PredefinedTypes.CharSet.Define()) { if (NamedArguments == null) { named_args = new Arguments(1); } Constant expr = Constant.CreateConstantFromValue(rc.Module.PredefinedTypes.CharSet.TypeSpec, rc.Module.DefaultCharSet, Location); NamedArguments.Add(new NamedArgument("CharSet", loc, expr)); } } public Attribute Clone() { Attribute attribute = new Attribute(ExplicitTarget, expression, null, loc, nameEscaped); attribute.pos_args = pos_args; attribute.named_args = NamedArguments; return attribute; } public void AttachTo(Attributable target, IMemberContext context) { if (targets == null) { targets = new Attributable[1] { target }; this.context = context; } else if (context is NamespaceContainer) { targets[0] = target; this.context = context; } else { Attributable[] array = new Attributable[targets.Length + 1]; targets.CopyTo(array, 0); array[targets.Length] = target; targets = array; target.OptAttributes = null; } } public ResolveContext CreateResolveContext() { return new ResolveContext(context, ResolveContext.Options.ConstantScope); } private static void Error_InvalidNamedArgument(ResolveContext rc, NamedArgument name) { rc.Report.Error(617, name.Location, "`{0}' is not a valid named attribute argument. Named attribute arguments must be fields which are not readonly, static, const or read-write properties which are public and not static", name.Name); } private static void Error_InvalidNamedArgumentType(ResolveContext rc, NamedArgument name) { rc.Report.Error(655, name.Location, "`{0}' is not a valid named attribute argument because it is not a valid attribute parameter type", name.Name); } public static void Error_AttributeArgumentIsDynamic(IMemberContext context, Location loc) { context.Module.Compiler.Report.Error(1982, loc, "An attribute argument cannot be dynamic expression"); } public void Error_MissingGuidAttribute() { Report.Error(596, Location, "The Guid attribute must be specified with the ComImport attribute"); } public void Error_MisusedExtensionAttribute() { Report.Error(1112, Location, "Do not use `{0}' directly. Use parameter modifier `this' instead", GetSignatureForError()); } public void Error_MisusedDynamicAttribute() { Report.Error(1970, loc, "Do not use `{0}' directly. Use `dynamic' keyword instead", GetSignatureForError()); } public void Error_MisusedTupleAttribute() { Report.Error(8138, loc, "Do not use `{0}' directly. Use the tuple syntax instead", GetSignatureForError()); } private void Error_AttributeEmitError(string inner) { Report.Error(647, Location, "Error during emitting `{0}' attribute. The reason is `{1}'", Type.GetSignatureForError(), inner); } public void Error_InvalidArgumentValue(TypeSpec attributeType) { Report.Error(591, Location, "Invalid value for argument to `{0}' attribute", attributeType.GetSignatureForError()); } public void Error_InvalidSecurityParent() { Report.Error(7070, Location, "Security attribute `{0}' is not valid on this declaration type. Security attributes are only valid on assembly, type and method declarations", Type.GetSignatureForError()); } public void SetOwner(Attributable owner) { targets[0] = owner; } private void ResolveAttributeType(bool comparisonOnly) { SessionReportPrinter sessionReportPrinter = new SessionReportPrinter(); SessionReportPrinter sessionReportPrinter2 = null; ReportPrinter reportPrinter = Report.SetPrinter(sessionReportPrinter); bool flag = false; bool flag2 = false; ATypeNameExpression aTypeNameExpression = null; TypeSpec typeSpec; TypeSpec typeSpec2; try { typeSpec = expression.ResolveAsType(context); sessionReportPrinter.EndSession(); if (typeSpec != null && sessionReportPrinter.ErrorsCount == 0) { flag = typeSpec.IsAttribute; } if (nameEscaped) { typeSpec2 = null; } else { aTypeNameExpression = (ATypeNameExpression)expression.Clone(null); aTypeNameExpression.Name += "Attribute"; sessionReportPrinter2 = new SessionReportPrinter(); Report.SetPrinter(sessionReportPrinter2); typeSpec2 = aTypeNameExpression.ResolveAsType(context); sessionReportPrinter2.EndSession(); if (typeSpec2 != null && sessionReportPrinter2.ErrorsCount == 0) { flag2 = typeSpec2.IsAttribute; } sessionReportPrinter2.EndSession(); } } finally { context.Module.Compiler.Report.SetPrinter(reportPrinter); } if (flag && flag2 && typeSpec != typeSpec2) { if (!comparisonOnly) { Report.Error(1614, Location, "`{0}' is ambiguous between `{1}' and `{2}'. Use either `@{0}' or `{0}Attribute'", GetSignatureForError(), expression.GetSignatureForError(), aTypeNameExpression.GetSignatureForError()); resolve_error = true; } } else if (flag) { Type = typeSpec; } else if (flag2) { Type = typeSpec2; } else { if (comparisonOnly) { return; } resolve_error = true; if (typeSpec != null) { if (sessionReportPrinter.IsEmpty) { Report.SymbolRelatedToPreviousError(typeSpec); Report.Error(616, Location, "`{0}': is not an attribute class", typeSpec.GetSignatureForError()); } else { sessionReportPrinter.Merge(reportPrinter); } } else if (typeSpec2 != null) { if (sessionReportPrinter2.IsEmpty) { Report.SymbolRelatedToPreviousError(typeSpec2); Report.Error(616, Location, "`{0}': is not an attribute class", typeSpec2.GetSignatureForError()); } else { sessionReportPrinter2.Merge(reportPrinter); } } else { sessionReportPrinter.Merge(reportPrinter); } } } public TypeSpec ResolveTypeForComparison() { if (Type == null && !resolve_error) { ResolveAttributeType(comparisonOnly: true); } return Type; } public string GetSignatureForError() { if (Type != null) { return Type.GetSignatureForError(); } return expression.GetSignatureForError(); } public bool IsValidSecurityAttribute() { return HasSecurityAttribute && IsSecurityActionValid(); } private static bool IsValidMethodImplOption(int value) { MethodImplOptions methodImplOptions = MethodImplOptions.AggressiveInlining; foreach (MethodImplOptions value2 in System.Enum.GetValues(typeof(MethodImplOptions))) { methodImplOptions |= value2; } return ((uint)value | (uint)methodImplOptions) == (uint)methodImplOptions; } public static bool IsValidArgumentType(TypeSpec t) { if (t.IsArray) { ArrayContainer arrayContainer = (ArrayContainer)t; if (arrayContainer.Rank > 1) { return false; } t = arrayContainer.Element; } BuiltinTypeSpec.Type builtinType = t.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 1) <= 11u || (uint)(type - 16) <= 3u) { return true; } return t.IsEnum; } public MethodSpec Resolve() { if (resolve_error) { return null; } resolve_error = true; arg_resolved = true; if (Type == null) { ResolveAttributeType(comparisonOnly: false); if (Type == null) { return null; } } if (Type.IsAbstract) { Report.Error(653, Location, "Cannot apply attribute class `{0}' because it is abstract", GetSignatureForError()); return null; } Type.CheckObsoleteness(context, expression.StartLocation); ResolveContext resolveContext = null; if (pos_args != null || !context.Module.AttributeConstructorCache.TryGetValue(Type, out var value)) { resolveContext = CreateResolveContext(); value = ResolveConstructor(resolveContext); if (value == null) { return null; } if (pos_args == null && value.Parameters.IsEmpty) { context.Module.AttributeConstructorCache.Add(Type, value); } } ModuleContainer module = context.Module; if ((Type == module.PredefinedAttributes.DllImport || Type == module.PredefinedAttributes.UnmanagedFunctionPointer) && module.HasDefaultCharSet) { if (resolveContext == null) { resolveContext = CreateResolveContext(); } AddModuleCharSet(resolveContext); } if (NamedArguments != null) { if (resolveContext == null) { resolveContext = CreateResolveContext(); } if (!ResolveNamedArguments(resolveContext)) { return null; } } resolve_error = false; return value; } private MethodSpec ResolveConstructor(ResolveContext ec) { if (pos_args != null) { pos_args.Resolve(ec, out var dynamic); if (dynamic) { Error_AttributeArgumentIsDynamic(ec.MemberContext, loc); return null; } } return Expression.ConstructorLookup(ec, Type, ref pos_args, loc); } private bool ResolveNamedArguments(ResolveContext ec) { int count = NamedArguments.Count; List list = new List(count); named_values = new List>(count); foreach (NamedArgument namedArgument in NamedArguments) { string name = namedArgument.Name; if (list.Contains(name)) { ec.Report.Error(643, namedArgument.Location, "Duplicate named attribute `{0}' argument", name); continue; } list.Add(name); namedArgument.Resolve(ec); Expression expression = Expression.MemberLookup(ec, errorMode: false, Type, name, 0, Expression.MemberLookupRestrictions.ExactArity, loc); if (expression == null) { expression = Expression.MemberLookup(ec, errorMode: true, Type, name, 0, Expression.MemberLookupRestrictions.ExactArity, loc); if (expression != null) { Expression.ErrorIsInaccesible(ec, expression.GetSignatureForError(), loc); return false; } } if (expression == null) { Expression.Error_TypeDoesNotContainDefinition(ec, Location, Type, name); return false; } if (!(expression is PropertyExpr) && !(expression is FieldExpr)) { Error_InvalidNamedArgument(ec, namedArgument); return false; } if (expression is PropertyExpr) { PropertySpec propertyInfo = ((PropertyExpr)expression).PropertyInfo; if (!propertyInfo.HasSet || !propertyInfo.HasGet || propertyInfo.IsStatic || !propertyInfo.Get.IsPublic || !propertyInfo.Set.IsPublic) { ec.Report.SymbolRelatedToPreviousError(propertyInfo); Error_InvalidNamedArgument(ec, namedArgument); return false; } if (!IsValidArgumentType(expression.Type)) { ec.Report.SymbolRelatedToPreviousError(propertyInfo); Error_InvalidNamedArgumentType(ec, namedArgument); return false; } propertyInfo.CheckObsoleteness(ec, expression.StartLocation); propertyInfo.MemberDefinition.SetIsAssigned(); } else { FieldSpec spec = ((FieldExpr)expression).Spec; if (spec.IsReadOnly || spec.IsStatic || !spec.IsPublic) { Error_InvalidNamedArgument(ec, namedArgument); return false; } if (!IsValidArgumentType(expression.Type)) { ec.Report.SymbolRelatedToPreviousError(spec); Error_InvalidNamedArgumentType(ec, namedArgument); return false; } spec.CheckObsoleteness(ec, expression.StartLocation); spec.MemberDefinition.SetIsAssigned(); } if (namedArgument.Type != expression.Type) { namedArgument.Expr = Convert.ImplicitConversionRequired(ec, namedArgument.Expr, expression.Type, namedArgument.Expr.Location); } if (namedArgument.Expr != null) { named_values.Add(new KeyValuePair((MemberExpr)expression, namedArgument)); } } return true; } public string GetValidTargets() { StringBuilder stringBuilder = new StringBuilder(); AttributeTargets validOn = Type.GetAttributeUsage(context.Module.PredefinedAttributes.AttributeUsage).ValidOn; if ((validOn & AttributeTargets.Assembly) != 0) { stringBuilder.Append("assembly, "); } if ((validOn & AttributeTargets.Module) != 0) { stringBuilder.Append("module, "); } if ((validOn & AttributeTargets.Class) != 0) { stringBuilder.Append("class, "); } if ((validOn & AttributeTargets.Struct) != 0) { stringBuilder.Append("struct, "); } if ((validOn & AttributeTargets.Enum) != 0) { stringBuilder.Append("enum, "); } if ((validOn & AttributeTargets.Constructor) != 0) { stringBuilder.Append("constructor, "); } if ((validOn & AttributeTargets.Method) != 0) { stringBuilder.Append("method, "); } if ((validOn & AttributeTargets.Property) != 0) { stringBuilder.Append("property, indexer, "); } if ((validOn & AttributeTargets.Field) != 0) { stringBuilder.Append("field, "); } if ((validOn & AttributeTargets.Event) != 0) { stringBuilder.Append("event, "); } if ((validOn & AttributeTargets.Interface) != 0) { stringBuilder.Append("interface, "); } if ((validOn & AttributeTargets.Parameter) != 0) { stringBuilder.Append("parameter, "); } if ((validOn & AttributeTargets.Delegate) != 0) { stringBuilder.Append("delegate, "); } if ((validOn & AttributeTargets.ReturnValue) != 0) { stringBuilder.Append("return, "); } if ((validOn & AttributeTargets.GenericParameter) != 0) { stringBuilder.Append("type parameter, "); } return stringBuilder.Remove(stringBuilder.Length - 2, 2).ToString(); } public AttributeUsageAttribute GetAttributeUsageAttribute() { if (!arg_resolved) { Resolve(); } if (resolve_error) { return DefaultUsageAttribute; } AttributeUsageAttribute attributeUsageAttribute = new AttributeUsageAttribute((AttributeTargets)((Constant)pos_args[0].Expr).GetValue()); if (GetNamedValue("AllowMultiple") is BoolConstant boolConstant) { attributeUsageAttribute.AllowMultiple = boolConstant.Value; } if (GetNamedValue("Inherited") is BoolConstant boolConstant2) { attributeUsageAttribute.Inherited = boolConstant2.Value; } return attributeUsageAttribute; } public string GetIndexerAttributeValue() { if (!arg_resolved) { Resolve(); } if (resolve_error || pos_args.Count != 1 || !(pos_args[0].Expr is Constant)) { return null; } return ((Constant)pos_args[0].Expr).GetValue() as string; } public string GetConditionalAttributeValue() { if (!arg_resolved) { Resolve(); } if (resolve_error) { return null; } return ((Constant)pos_args[0].Expr).GetValue() as string; } public ObsoleteAttribute GetObsoleteAttribute() { if (!arg_resolved) { if (Type.MemberDefinition is Class { HasMembersDefined: false } obj) { obj.Define(); } Resolve(); } if (resolve_error) { return null; } if (pos_args == null) { return new ObsoleteAttribute(); } string message = ((Constant)pos_args[0].Expr).GetValue() as string; if (pos_args.Count == 1) { return new ObsoleteAttribute(message); } return new ObsoleteAttribute(message, ((BoolConstant)pos_args[1].Expr).Value); } public bool GetClsCompliantAttributeValue() { if (!arg_resolved) { Resolve(); } if (resolve_error) { return false; } return ((BoolConstant)pos_args[0].Expr).Value; } public TypeSpec GetAsyncMethodBuilderValue() { if (!arg_resolved) { Resolve(); } if (resolve_error) { return null; } return GetArgumentType(); } public TypeSpec GetCoClassAttributeValue() { if (!arg_resolved) { Resolve(); } if (resolve_error) { return null; } return GetArgumentType(); } public bool CheckTarget() { string[] validAttributeTargets = Owner.ValidAttributeTargets; if (ExplicitTarget == null || ExplicitTarget == validAttributeTargets[0]) { Target = Owner.AttributeTargets; return true; } if (Array.Exists(validAttributeTargets, (string i) => i == ExplicitTarget)) { switch (ExplicitTarget) { case "return": Target = AttributeTargets.ReturnValue; return true; case "param": Target = AttributeTargets.Parameter; return true; case "field": Target = AttributeTargets.Field; return true; case "method": Target = AttributeTargets.Method; return true; case "property": Target = AttributeTargets.Property; return true; case "module": Target = AttributeTargets.Module; return true; default: throw new InternalErrorException("Unknown explicit target: " + ExplicitTarget); } } StringBuilder stringBuilder = new StringBuilder(); string[] array = validAttributeTargets; foreach (string value in array) { stringBuilder.Append(value); stringBuilder.Append(", "); } stringBuilder.Remove(stringBuilder.Length - 2, 2); Report.Warning(657, 1, Location, "`{0}' is not a valid attribute location for this declaration. Valid attribute locations for this declaration are `{1}'. All attributes in this section will be ignored", ExplicitTarget, stringBuilder.ToString()); return false; } private bool IsSecurityActionValid() { Constant value = null; SecurityAction? securityActionValue = GetSecurityActionValue(ref value); bool flag = Target == AttributeTargets.Assembly || Target == AttributeTargets.Module; switch (securityActionValue) { case SecurityAction.Demand: case SecurityAction.Assert: case SecurityAction.Deny: case SecurityAction.PermitOnly: case SecurityAction.LinkDemand: case SecurityAction.InheritanceDemand: if (!flag) { return true; } break; case SecurityAction.RequestMinimum: case SecurityAction.RequestOptional: case SecurityAction.RequestRefuse: if (flag) { return true; } break; case null: Report.Error(7048, loc, "First argument of a security attribute `{0}' must be a valid SecurityAction", Type.GetSignatureForError()); return false; default: Report.Error(7049, value.Location, "Security attribute `{0}' has an invalid SecurityAction value `{1}'", Type.GetSignatureForError(), value.GetValueAsLiteral()); return false; } AttributeTargets target = Target; AttributeTargets attributeTargets = target; if (attributeTargets == AttributeTargets.Assembly) { Report.Error(7050, value.Location, "SecurityAction value `{0}' is invalid for security attributes applied to an assembly", value.GetSignatureForError()); } else { Report.Error(7051, value.Location, "SecurityAction value `{0}' is invalid for security attributes applied to a type or a method", value.GetSignatureForError()); } return false; } private SecurityAction? GetSecurityActionValue(ref Constant value) { if (pos_args == null) { PredefinedAttributes predefinedAttributes = context.Module.PredefinedAttributes; if (Type == predefinedAttributes.HostProtection.TypeSpec) { value = new IntConstant(context.Module.Compiler.BuiltinTypes, 6, loc); return SecurityAction.LinkDemand; } return null; } value = (Constant)pos_args[0].Expr; return (SecurityAction)value.GetValue(); } public void ExtractSecurityPermissionSet(MethodSpec ctor, ref Dictionary permissions) { throw new NotSupportedException(); } public Constant GetNamedValue(string name) { if (named_values == null) { return null; } for (int i = 0; i < named_values.Count; i++) { if (named_values[i].Value.Name == name) { return named_values[i].Value.Expr as Constant; } } return null; } public CharSet GetCharSetValue() { return (CharSet)System.Enum.Parse(typeof(CharSet), ((Constant)pos_args[0].Expr).GetValue().ToString()); } public bool HasField(string fieldName) { if (named_values == null) { return false; } foreach (KeyValuePair named_value in named_values) { if (named_value.Value.Name == fieldName) { return true; } } return false; } public bool IsInternalCall() { return (GetMethodImplOptions() & MethodImplOptions.InternalCall) != 0; } public MethodImplOptions GetMethodImplOptions() { MethodImplOptions result = (MethodImplOptions)0; if (pos_args.Count == 1) { result = (MethodImplOptions)System.Enum.Parse(typeof(MethodImplOptions), ((Constant)pos_args[0].Expr).GetValue().ToString()); } else if (HasField("Value")) { Constant namedValue = GetNamedValue("Value"); result = (MethodImplOptions)System.Enum.Parse(typeof(MethodImplOptions), namedValue.GetValue().ToString()); } return result; } public bool IsExplicitLayoutKind() { if (pos_args == null || pos_args.Count != 1) { return false; } LayoutKind layoutKind = (LayoutKind)System.Enum.Parse(typeof(LayoutKind), ((Constant)pos_args[0].Expr).GetValue().ToString()); return layoutKind == LayoutKind.Explicit; } public Expression GetParameterDefaultValue() { if (pos_args == null) { return null; } return pos_args[0].Expr; } public override bool Equals(object obj) { if (!(obj is Attribute attribute)) { return false; } return Type == attribute.Type && Target == attribute.Target; } public override int GetHashCode() { return Type.GetHashCode() ^ Target.GetHashCode(); } public void Emit(Dictionary> allEmitted) { MethodSpec methodSpec = Resolve(); if (methodSpec == null) { return; } PredefinedAttributes predefinedAttributes = context.Module.PredefinedAttributes; AttributeUsageAttribute attributeUsage = Type.GetAttributeUsage(predefinedAttributes.AttributeUsage); if ((attributeUsage.ValidOn & Target) == 0) { Report.Error(592, Location, "The attribute `{0}' is not valid on this declaration type. It is valid on `{1}' declarations only", GetSignatureForError(), GetValidTargets()); return; } byte[] cdata; List assemblyReferences; if (pos_args == null && named_values == null) { cdata = AttributeEncoder.Empty; assemblyReferences = null; } else { AttributeEncoder attributeEncoder = new AttributeEncoder(); if (pos_args != null) { TypeSpec[] types = methodSpec.Parameters.Types; for (int i = 0; i < pos_args.Count; i++) { TypeSpec typeSpec = types[i]; Expression expr = pos_args[i].Expr; if (i == 0) { if ((Type == predefinedAttributes.IndexerName || Type == predefinedAttributes.Conditional) && expr is Constant) { string s = ((Constant)expr).GetValue() as string; if (!Tokenizer.IsValidIdentifier(s) || (Type == predefinedAttributes.IndexerName && Tokenizer.IsKeyword(s))) { context.Module.Compiler.Report.Error(633, expr.Location, "The argument to the `{0}' attribute must be a valid identifier", GetSignatureForError()); return; } } else if (Type == predefinedAttributes.Guid) { string value = ((StringConstant)expr).Value; try { new Guid(value); } catch { Error_InvalidArgumentValue(Type); return; } } else if (Type == predefinedAttributes.AttributeUsage) { if (((IntConstant)((EnumConstant)expr).Child).Value == 0) { Error_InvalidArgumentValue(Type); } } else if (Type == predefinedAttributes.MarshalAs) { if (pos_args.Count == 1) { UnmanagedType unmanagedType = (UnmanagedType)System.Enum.Parse(typeof(UnmanagedType), ((Constant)pos_args[0].Expr).GetValue().ToString()); if (unmanagedType == UnmanagedType.ByValArray && !(Owner is FieldBase)) { Report.Error(7055, pos_args[0].Expr.Location, "Unmanaged type `ByValArray' is only valid for fields"); } } } else if (Type == predefinedAttributes.DllImport) { if (pos_args.Count == 1 && pos_args[0].Expr is Constant) { string value2 = ((Constant)pos_args[0].Expr).GetValue() as string; if (string.IsNullOrEmpty(value2)) { Error_InvalidArgumentValue(Type); } } } else if (Type == predefinedAttributes.MethodImpl && pos_args.Count == 1) { int value3 = (int)((Constant)expr).GetValueAsLong(); if (!IsValidMethodImplOption(value3)) { Error_InvalidArgumentValue(Type); } } } expr.EncodeAttributeValue(context, attributeEncoder, typeSpec, typeSpec); } } if (named_values != null) { attributeEncoder.Encode((ushort)named_values.Count); foreach (KeyValuePair named_value in named_values) { if (named_value.Key is FieldExpr) { attributeEncoder.Encode((byte)83); } else { attributeEncoder.Encode((byte)84); } attributeEncoder.Encode(named_value.Key.Type); attributeEncoder.Encode(named_value.Value.Name); named_value.Value.Expr.EncodeAttributeValue(context, attributeEncoder, named_value.Key.Type, named_value.Key.Type); } } else { attributeEncoder.EncodeEmptyNamedArguments(); } cdata = attributeEncoder.ToArray(out assemblyReferences); } if (!IsConditionallyExcluded(methodSpec.DeclaringType)) { if (Type == predefinedAttributes.TupleElementNames) { Error_MisusedTupleAttribute(); return; } try { Attributable[] array = targets; foreach (Attributable attributable in array) { attributable.ApplyAttributeBuilder(this, methodSpec, cdata, predefinedAttributes); } } catch (Exception ex) { if (!(ex is BadImageFormatException) || Report.Errors <= 0) { Error_AttributeEmitError(ex.Message); } return; } context.Module.AddAssemblyReferences(assemblyReferences); } if (!attributeUsage.AllowMultiple && allEmitted != null) { if (allEmitted.ContainsKey(this)) { List list = allEmitted[this]; if (list == null) { list = (allEmitted[this] = new List(2)); } list.Add(this); } else { allEmitted.Add(this, null); } } if (context.Module.Compiler.Settings.VerifyClsCompliance && Owner.IsClsComplianceRequired()) { if (pos_args != null) { pos_args.CheckArrayAsAttribute(context.Module.Compiler); } if (NamedArguments != null) { NamedArguments.CheckArrayAsAttribute(context.Module.Compiler); } } } private bool IsConditionallyExcluded(TypeSpec type) { do { if (type.IsConditionallyExcluded(context)) { return true; } type = type.BaseType; } while (type != null); return false; } private Expression GetValue() { if (pos_args == null || pos_args.Count < 1) { return null; } return pos_args[0].Expr; } public string GetString() { Expression value = GetValue(); if (value is StringConstant) { return ((StringConstant)value).Value; } return null; } public bool GetBoolean() { Expression value = GetValue(); if (value is BoolConstant) { return ((BoolConstant)value).Value; } return false; } public TypeSpec GetArgumentType() { if (!(GetValue() is TypeOf { TypeArgument: var typeArgument })) { return null; } return typeArgument; } } internal class Attributes { public readonly List Attrs; public Attributes(Attribute a) { Attrs = new List(); Attrs.Add(a); } public Attributes(List attrs) { Attrs = attrs ?? new List(); } public void AddAttribute(Attribute attr) { Attrs.Add(attr); } public void AddAttributes(List attrs) { Attrs.AddRange(attrs); } public static void AttachFromPartial(Attributable target, Attributable partialSrc) { if (target.OptAttributes == null) { target.OptAttributes = partialSrc.OptAttributes; } else { target.OptAttributes.Attrs.AddRange(partialSrc.OptAttributes.Attrs); } foreach (Attribute attr in partialSrc.OptAttributes.Attrs) { attr.SetOwner(target); } } public void AttachTo(Attributable attributable, IMemberContext context) { foreach (Attribute attr in Attrs) { attr.AttachTo(attributable, context); } } public Attributes Clone() { List list = new List(Attrs.Count); foreach (Attribute attr in Attrs) { list.Add(attr.Clone()); } return new Attributes(list); } public bool CheckTargets() { for (int i = 0; i < Attrs.Count; i++) { if (!Attrs[i].CheckTarget()) { Attrs.RemoveAt(i--); } } return true; } public void ConvertGlobalAttributes(TypeContainer member, NamespaceContainer currentNamespace, bool isGlobal) { string[] validAttributeTargets = member.ValidAttributeTargets; for (int i = 0; i < Attrs.Count; i++) { Attribute attribute = Attrs[0]; if (attribute.ExplicitTarget == null) { continue; } int j; for (j = 0; j < validAttributeTargets.Length; j++) { if (attribute.ExplicitTarget == validAttributeTargets[j]) { j = -1; break; } } if (j >= 0 && isGlobal) { member.Module.AddAttribute(attribute, currentNamespace); Attrs.RemoveAt(i); i--; } } } public bool HasResolveError() { foreach (Attribute attr in Attrs) { if (attr.ResolveError) { return true; } } return false; } public Attribute Search(PredefinedAttribute t) { return Search(null, t); } public Attribute Search(string explicitTarget, PredefinedAttribute t) { foreach (Attribute attr in Attrs) { if ((explicitTarget == null || !(attr.ExplicitTarget != explicitTarget)) && attr.ResolveTypeForComparison() == t) { return attr; } } return null; } public Attribute[] SearchMulti(PredefinedAttribute t) { List list = null; foreach (Attribute attr in Attrs) { if (attr.ResolveTypeForComparison() == t) { if (list == null) { list = new List(Attrs.Count); } list.Add(attr); } } return list?.ToArray(); } public void Emit() { CheckTargets(); Dictionary> dictionary = ((Attrs.Count > 1) ? new Dictionary>() : null); foreach (Attribute attr in Attrs) { attr.Emit(dictionary); } if (dictionary == null || dictionary.Count == 0) { return; } foreach (KeyValuePair> item in dictionary) { if (item.Value == null) { continue; } Attribute key = item.Key; foreach (Attribute item2 in item.Value) { key.Report.SymbolRelatedToPreviousError(item2.Location, ""); } key.Report.Error(579, key.Location, "The attribute `{0}' cannot be applied multiple times", key.GetSignatureForError()); } } public bool Contains(PredefinedAttribute t) { return Search(t) != null; } } internal sealed class AttributeEncoder { [Flags] public enum EncodedTypeProperties { None = 0, DynamicType = 1, TypeParameter = 2 } public static readonly byte[] Empty; private byte[] buffer; private int pos; private const ushort Version = 1; private List imports; static AttributeEncoder() { Empty = new byte[4]; Empty[0] = 1; } public AttributeEncoder() { buffer = new byte[32]; Encode((ushort)1); } public void Encode(bool value) { Encode((byte)(value ? 1 : 0)); } public void Encode(byte value) { if (pos == buffer.Length) { Grow(1); } buffer[pos++] = value; } public void Encode(sbyte value) { Encode((byte)value); } public void Encode(short value) { if (pos + 2 > buffer.Length) { Grow(2); } buffer[pos++] = (byte)value; buffer[pos++] = (byte)(value >> 8); } public void Encode(ushort value) { Encode((short)value); } public void Encode(int value) { if (pos + 4 > buffer.Length) { Grow(4); } buffer[pos++] = (byte)value; buffer[pos++] = (byte)(value >> 8); buffer[pos++] = (byte)(value >> 16); buffer[pos++] = (byte)(value >> 24); } public void Encode(uint value) { Encode((int)value); } public void Encode(long value) { if (pos + 8 > buffer.Length) { Grow(8); } buffer[pos++] = (byte)value; buffer[pos++] = (byte)(value >> 8); buffer[pos++] = (byte)(value >> 16); buffer[pos++] = (byte)(value >> 24); buffer[pos++] = (byte)(value >> 32); buffer[pos++] = (byte)(value >> 40); buffer[pos++] = (byte)(value >> 48); buffer[pos++] = (byte)(value >> 56); } public void Encode(ulong value) { Encode((long)value); } public void Encode(float value) { Encode(SingleConverter.SingleToInt32Bits(value)); } public void Encode(double value) { Encode(BitConverter.DoubleToInt64Bits(value)); } public void Encode(string value) { if (value == null) { Encode(byte.MaxValue); return; } byte[] bytes = Encoding.UTF8.GetBytes(value); WriteCompressedValue(bytes.Length); if (pos + bytes.Length > buffer.Length) { Grow(bytes.Length); } Buffer.BlockCopy(bytes, 0, buffer, pos, bytes.Length); pos += bytes.Length; } public EncodedTypeProperties Encode(TypeSpec type) { switch (type.BuiltinType) { case BuiltinTypeSpec.Type.FirstPrimitive: Encode((byte)2); break; case BuiltinTypeSpec.Type.Char: Encode((byte)3); break; case BuiltinTypeSpec.Type.SByte: Encode((byte)4); break; case BuiltinTypeSpec.Type.Byte: Encode((byte)5); break; case BuiltinTypeSpec.Type.Short: Encode((byte)6); break; case BuiltinTypeSpec.Type.UShort: Encode((byte)7); break; case BuiltinTypeSpec.Type.Int: Encode((byte)8); break; case BuiltinTypeSpec.Type.UInt: Encode((byte)9); break; case BuiltinTypeSpec.Type.Long: Encode((byte)10); break; case BuiltinTypeSpec.Type.ULong: Encode((byte)11); break; case BuiltinTypeSpec.Type.Float: Encode((byte)12); break; case BuiltinTypeSpec.Type.Double: Encode((byte)13); break; case BuiltinTypeSpec.Type.String: Encode((byte)14); break; case BuiltinTypeSpec.Type.Type: Encode((byte)80); break; case BuiltinTypeSpec.Type.Object: Encode((byte)81); break; case BuiltinTypeSpec.Type.Dynamic: Encode((byte)81); return EncodedTypeProperties.DynamicType; default: if (type.IsArray) { Encode((byte)29); return Encode(TypeManager.GetElementType(type)); } if (type.Kind == MemberKind.Enum) { Encode((byte)85); EncodeTypeName(type); } break; } return EncodedTypeProperties.None; } public void EncodeTypeName(TypeSpec type) { Type metaInfo = type.GetMetaInfo(); if (type.MemberDefinition.IsImported) { if (imports == null) { imports = new List(); } imports.Add(metaInfo.Assembly); Encode(metaInfo.AssemblyQualifiedName); } else { Encode(metaInfo.FullName); } } public void EncodeTypeName(TypeContainer type) { Encode(type.GetSignatureForMetadata()); } public void EncodeNamedPropertyArgument(PropertySpec property, Constant value) { Encode((ushort)1); Encode((byte)84); Encode(property.MemberType); Encode(property.Name); value.EncodeAttributeValue(null, this, property.MemberType, property.MemberType); } public void EncodeNamedFieldArgument(FieldSpec field, Constant value) { Encode((ushort)1); Encode((byte)83); Encode(field.MemberType); Encode(field.Name); value.EncodeAttributeValue(null, this, field.MemberType, field.MemberType); } public void EncodeNamedArguments(T[] members, Constant[] values) where T : MemberSpec, IInterfaceMemberSpec { Encode((ushort)members.Length); for (int i = 0; i < members.Length; i++) { T val = members[i]; if (val.Kind == MemberKind.Field) { Encode((byte)83); } else { if (val.Kind != MemberKind.Property) { throw new NotImplementedException(val.Kind.ToString()); } Encode((byte)84); } Encode(val.MemberType); Encode(val.Name); values[i].EncodeAttributeValue(null, this, val.MemberType, val.MemberType); } } public void EncodeEmptyNamedArguments() { Encode((ushort)0); } private void Grow(int inc) { int newSize = Math.Max(pos * 4, pos + inc + 2); Array.Resize(ref buffer, newSize); } private void WriteCompressedValue(int value) { if (value < 128) { Encode((byte)value); } else if (value < 16384) { Encode((byte)(0x80 | (value >> 8))); Encode((byte)value); } else { Encode(value); } } public byte[] ToArray(out List assemblyReferences) { assemblyReferences = imports; byte[] array = new byte[pos]; Array.Copy(buffer, array, pos); return array; } } internal static class AttributeTester { public static void Report_ObsoleteMessage(ObsoleteAttribute oa, string member, Location loc, Report Report) { if (oa.IsError) { Report.Error(619, loc, "`{0}' is obsolete: `{1}'", member, oa.Message); } else if (oa.Message == null || oa.Message.Length == 0) { Report.Warning(612, 1, loc, "`{0}' is obsolete", member); } else { Report.Warning(618, 2, loc, "`{0}' is obsolete: `{1}'", member, oa.Message); } } } internal class PredefinedAttributes { public readonly PredefinedAttribute ParamArray; public readonly PredefinedAttribute Out; public readonly PredefinedAttribute Obsolete; public readonly PredefinedAttribute DllImport; public readonly PredefinedAttribute MethodImpl; public readonly PredefinedAttribute MarshalAs; public readonly PredefinedAttribute In; public readonly PredefinedAttribute IndexerName; public readonly PredefinedAttribute Conditional; public readonly PredefinedAttribute CLSCompliant; public readonly PredefinedAttribute Security; public readonly PredefinedAttribute Required; public readonly PredefinedAttribute Guid; public readonly PredefinedAttribute AssemblyCulture; public readonly PredefinedAttribute AssemblyVersion; public readonly PredefinedAttribute AssemblyAlgorithmId; public readonly PredefinedAttribute AssemblyFlags; public readonly PredefinedAttribute AssemblyFileVersion; public readonly PredefinedAttribute AssemblyInformationalVersion; public readonly PredefinedAttribute ComImport; public readonly PredefinedAttribute CoClass; public readonly PredefinedAttribute AttributeUsage; public readonly PredefinedAttribute DefaultParameterValue; public readonly PredefinedAttribute OptionalParameter; public readonly PredefinedAttribute UnverifiableCode; public readonly PredefinedAttribute DefaultCharset; public readonly PredefinedAttribute TypeForwarder; public readonly PredefinedAttribute FixedBuffer; public readonly PredefinedAttribute CompilerGenerated; public readonly PredefinedAttribute InternalsVisibleTo; public readonly PredefinedAttribute RuntimeCompatibility; public readonly PredefinedAttribute DebuggerHidden; public readonly PredefinedAttribute UnsafeValueType; public readonly PredefinedAttribute UnmanagedFunctionPointer; public readonly PredefinedDebuggerBrowsableAttribute DebuggerBrowsable; public readonly PredefinedAttribute DebuggerStepThrough; public readonly PredefinedDebuggableAttribute Debuggable; public readonly PredefinedAttribute HostProtection; public readonly PredefinedAttribute Extension; public readonly PredefinedDynamicAttribute Dynamic; public readonly PredefinedStateMachineAttribute AsyncStateMachine; public readonly PredefinedTupleElementNamesAttribute TupleElementNames; public readonly PredefinedAttribute AsyncMethodBuilder; public readonly PredefinedAttribute IsReadOnly; public readonly PredefinedAttribute IsByRefLike; public readonly PredefinedAttribute DefaultMember; public readonly PredefinedDecimalAttribute DecimalConstant; public readonly PredefinedAttribute StructLayout; public readonly PredefinedAttribute FieldOffset; public readonly PredefinedAttribute AssemblyProduct; public readonly PredefinedAttribute AssemblyCompany; public readonly PredefinedAttribute AssemblyCopyright; public readonly PredefinedAttribute AssemblyTrademark; public readonly PredefinedAttribute CallerMemberNameAttribute; public readonly PredefinedAttribute CallerLineNumberAttribute; public readonly PredefinedAttribute CallerFilePathAttribute; public PredefinedAttributes(ModuleContainer module) { ParamArray = new PredefinedAttribute(module, "System", "ParamArrayAttribute"); Out = new PredefinedAttribute(module, "System.Runtime.InteropServices", "OutAttribute"); ParamArray.Resolve(); Out.Resolve(); Obsolete = new PredefinedAttribute(module, "System", "ObsoleteAttribute"); DllImport = new PredefinedAttribute(module, "System.Runtime.InteropServices", "DllImportAttribute"); MethodImpl = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "MethodImplAttribute"); MarshalAs = new PredefinedAttribute(module, "System.Runtime.InteropServices", "MarshalAsAttribute"); In = new PredefinedAttribute(module, "System.Runtime.InteropServices", "InAttribute"); IndexerName = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "IndexerNameAttribute"); Conditional = new PredefinedAttribute(module, "System.Diagnostics", "ConditionalAttribute"); CLSCompliant = new PredefinedAttribute(module, "System", "CLSCompliantAttribute"); Security = new PredefinedAttribute(module, "System.Security.Permissions", "SecurityAttribute"); Required = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "RequiredAttributeAttribute"); Guid = new PredefinedAttribute(module, "System.Runtime.InteropServices", "GuidAttribute"); AssemblyCulture = new PredefinedAttribute(module, "System.Reflection", "AssemblyCultureAttribute"); AssemblyVersion = new PredefinedAttribute(module, "System.Reflection", "AssemblyVersionAttribute"); AssemblyAlgorithmId = new PredefinedAttribute(module, "System.Reflection", "AssemblyAlgorithmIdAttribute"); AssemblyFlags = new PredefinedAttribute(module, "System.Reflection", "AssemblyFlagsAttribute"); AssemblyFileVersion = new PredefinedAttribute(module, "System.Reflection", "AssemblyFileVersionAttribute"); ComImport = new PredefinedAttribute(module, "System.Runtime.InteropServices", "ComImportAttribute"); CoClass = new PredefinedAttribute(module, "System.Runtime.InteropServices", "CoClassAttribute"); AttributeUsage = new PredefinedAttribute(module, "System", "AttributeUsageAttribute"); DefaultParameterValue = new PredefinedAttribute(module, "System.Runtime.InteropServices", "DefaultParameterValueAttribute"); OptionalParameter = new PredefinedAttribute(module, "System.Runtime.InteropServices", "OptionalAttribute"); UnverifiableCode = new PredefinedAttribute(module, "System.Security", "UnverifiableCodeAttribute"); HostProtection = new PredefinedAttribute(module, "System.Security.Permissions", "HostProtectionAttribute"); DefaultCharset = new PredefinedAttribute(module, "System.Runtime.InteropServices", "DefaultCharSetAttribute"); TypeForwarder = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "TypeForwardedToAttribute"); FixedBuffer = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "FixedBufferAttribute"); CompilerGenerated = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "CompilerGeneratedAttribute"); InternalsVisibleTo = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "InternalsVisibleToAttribute"); RuntimeCompatibility = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "RuntimeCompatibilityAttribute"); DebuggerHidden = new PredefinedAttribute(module, "System.Diagnostics", "DebuggerHiddenAttribute"); UnsafeValueType = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "UnsafeValueTypeAttribute"); UnmanagedFunctionPointer = new PredefinedAttribute(module, "System.Runtime.InteropServices", "UnmanagedFunctionPointerAttribute"); DebuggerBrowsable = new PredefinedDebuggerBrowsableAttribute(module, "System.Diagnostics", "DebuggerBrowsableAttribute"); DebuggerStepThrough = new PredefinedAttribute(module, "System.Diagnostics", "DebuggerStepThroughAttribute"); Debuggable = new PredefinedDebuggableAttribute(module, "System.Diagnostics", "DebuggableAttribute"); Extension = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "ExtensionAttribute"); Dynamic = new PredefinedDynamicAttribute(module, "System.Runtime.CompilerServices", "DynamicAttribute"); DefaultMember = new PredefinedAttribute(module, "System.Reflection", "DefaultMemberAttribute"); DecimalConstant = new PredefinedDecimalAttribute(module, "System.Runtime.CompilerServices", "DecimalConstantAttribute"); StructLayout = new PredefinedAttribute(module, "System.Runtime.InteropServices", "StructLayoutAttribute"); FieldOffset = new PredefinedAttribute(module, "System.Runtime.InteropServices", "FieldOffsetAttribute"); AssemblyProduct = new PredefinedAttribute(module, "System.Reflection", "AssemblyProductAttribute"); AssemblyCompany = new PredefinedAttribute(module, "System.Reflection", "AssemblyCompanyAttribute"); AssemblyCopyright = new PredefinedAttribute(module, "System.Reflection", "AssemblyCopyrightAttribute"); AssemblyTrademark = new PredefinedAttribute(module, "System.Reflection", "AssemblyTrademarkAttribute"); AssemblyInformationalVersion = new PredefinedAttribute(module, "System.Reflection", "AssemblyInformationalVersionAttribute"); AsyncStateMachine = new PredefinedStateMachineAttribute(module, "System.Runtime.CompilerServices", "AsyncStateMachineAttribute"); CallerMemberNameAttribute = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "CallerMemberNameAttribute"); CallerLineNumberAttribute = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "CallerLineNumberAttribute"); CallerFilePathAttribute = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "CallerFilePathAttribute"); AsyncMethodBuilder = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "AsyncMethodBuilderAttribute"); TupleElementNames = new PredefinedTupleElementNamesAttribute(module, "System.Runtime.CompilerServices", "TupleElementNamesAttribute"); IsReadOnly = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "IsReadOnlyAttribute"); IsByRefLike = new PredefinedAttribute(module, "System.Runtime.CompilerServices", "IsByRefLikeAttribute"); FieldInfo[] fields = GetType().GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { ((PredefinedAttribute)fieldInfo.GetValue(this)).Define(); } } } internal class PredefinedAttribute : PredefinedType { protected MethodSpec ctor; public MethodSpec Constructor => ctor; public PredefinedAttribute(ModuleContainer module, string ns, string name) : base(module, MemberKind.Class, ns, name) { } public static bool operator ==(TypeSpec type, PredefinedAttribute pa) { return type == pa.type && pa.type != null; } public static bool operator !=(TypeSpec type, PredefinedAttribute pa) { return type != pa.type; } public override int GetHashCode() { return base.GetHashCode(); } public override bool Equals(object obj) { throw new NotSupportedException(); } public void EmitAttribute(ConstructorBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(MethodBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(PropertyBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(FieldBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(TypeBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(AssemblyBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(ModuleBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } public void EmitAttribute(ParameterBuilder builder) { if (ResolveBuilder()) { builder.SetCustomAttribute(GetCtorMetaInfo(), AttributeEncoder.Empty); } } private ConstructorInfo GetCtorMetaInfo() { return (ConstructorInfo)ctor.GetMetaInfo(); } public bool ResolveBuilder() { if (ctor != null) { return true; } if (!Define()) { return false; } ctor = (MethodSpec)MemberCache.FindMember(type, MemberFilter.Constructor(ParametersCompiled.EmptyReadOnlyParameters), BindingRestriction.DeclaredOnly); return ctor != null; } } internal class PredefinedDebuggerBrowsableAttribute : PredefinedAttribute { public PredefinedDebuggerBrowsableAttribute(ModuleContainer module, string ns, string name) : base(module, ns, name) { } public void EmitAttribute(FieldBuilder builder, DebuggerBrowsableState state) { MethodSpec methodSpec = module.PredefinedMembers.DebuggerBrowsableAttributeCtor.Get(); if (methodSpec != null) { AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.Encode((int)state); attributeEncoder.EncodeEmptyNamedArguments(); builder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences)); module.AddAssemblyReferences(assemblyReferences); } } } internal class PredefinedDebuggableAttribute : PredefinedAttribute { public PredefinedDebuggableAttribute(ModuleContainer module, string ns, string name) : base(module, ns, name) { } public void EmitAttribute(AssemblyBuilder builder, DebuggableAttribute.DebuggingModes modes) { PredefinedDebuggableAttribute debuggable = module.PredefinedAttributes.Debuggable; if (!debuggable.Define()) { return; } MethodSpec methodSpec = null; foreach (MethodSpec item in MemberCache.FindMembers(debuggable.TypeSpec, Mono.CSharp.Constructor.ConstructorName, declaredOnlyClass: true)) { if (item.Parameters.Count == 1 && item.Parameters.Types[0].Kind == MemberKind.Enum) { methodSpec = item; } } if (methodSpec != null) { AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.Encode((int)modes); attributeEncoder.EncodeEmptyNamedArguments(); builder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences)); module.AddAssemblyReferences(assemblyReferences); } } } internal class PredefinedDecimalAttribute : PredefinedAttribute { public PredefinedDecimalAttribute(ModuleContainer module, string ns, string name) : base(module, ns, name) { } public void EmitAttribute(ParameterBuilder builder, decimal value, Location loc) { MethodSpec methodSpec = module.PredefinedMembers.DecimalConstantAttributeCtor.Resolve(loc); if (methodSpec != null) { int[] bits = decimal.GetBits(value); AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.Encode((byte)(bits[3] >> 16)); attributeEncoder.Encode((byte)(bits[3] >> 31)); attributeEncoder.Encode((uint)bits[2]); attributeEncoder.Encode((uint)bits[1]); attributeEncoder.Encode((uint)bits[0]); attributeEncoder.EncodeEmptyNamedArguments(); builder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences)); module.AddAssemblyReferences(assemblyReferences); } } public void EmitAttribute(FieldBuilder builder, decimal value, Location loc) { MethodSpec methodSpec = module.PredefinedMembers.DecimalConstantAttributeCtor.Resolve(loc); if (methodSpec != null) { int[] bits = decimal.GetBits(value); AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.Encode((byte)((bits[3] & 0xFF0000) >> 16)); attributeEncoder.Encode((byte)(bits[3] >> 31 << 7)); attributeEncoder.Encode((uint)bits[2]); attributeEncoder.Encode((uint)bits[1]); attributeEncoder.Encode((uint)bits[0]); attributeEncoder.EncodeEmptyNamedArguments(); builder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences)); module.AddAssemblyReferences(assemblyReferences); } } } internal class PredefinedStateMachineAttribute : PredefinedAttribute { public PredefinedStateMachineAttribute(ModuleContainer module, string ns, string name) : base(module, ns, name) { } public void EmitAttribute(MethodBuilder builder, StateMachine type) { PredefinedMember asyncStateMachineAttributeCtor = module.PredefinedMembers.AsyncStateMachineAttributeCtor; MethodSpec methodSpec = asyncStateMachineAttributeCtor.Get(); if (methodSpec != null) { AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.EncodeTypeName(type); attributeEncoder.EncodeEmptyNamedArguments(); builder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences)); module.AddAssemblyReferences(assemblyReferences); } } } internal class PredefinedDynamicAttribute : PredefinedAttribute { private MethodSpec tctor; public PredefinedDynamicAttribute(ModuleContainer module, string ns, string name) : base(module, ns, name) { } public void EmitAttribute(FieldBuilder builder, TypeSpec type, Location loc) { if (ResolveTransformationCtor(loc)) { CustomAttributeBuilder customAttribute = new CustomAttributeBuilder((ConstructorInfo)tctor.GetMetaInfo(), new object[1] { GetTransformationFlags(type) }); builder.SetCustomAttribute(customAttribute); } } public void EmitAttribute(ParameterBuilder builder, TypeSpec type, Location loc) { if (ResolveTransformationCtor(loc)) { CustomAttributeBuilder customAttribute = new CustomAttributeBuilder((ConstructorInfo)tctor.GetMetaInfo(), new object[1] { GetTransformationFlags(type) }); builder.SetCustomAttribute(customAttribute); } } public void EmitAttribute(PropertyBuilder builder, TypeSpec type, Location loc) { if (ResolveTransformationCtor(loc)) { CustomAttributeBuilder customAttribute = new CustomAttributeBuilder((ConstructorInfo)tctor.GetMetaInfo(), new object[1] { GetTransformationFlags(type) }); builder.SetCustomAttribute(customAttribute); } } public void EmitAttribute(TypeBuilder builder, TypeSpec type, Location loc) { if (ResolveTransformationCtor(loc)) { CustomAttributeBuilder customAttribute = new CustomAttributeBuilder((ConstructorInfo)tctor.GetMetaInfo(), new object[1] { GetTransformationFlags(type) }); builder.SetCustomAttribute(customAttribute); } } private static bool[] GetTransformationFlags(TypeSpec t) { if (t is ArrayContainer arrayContainer) { bool[] transformationFlags = GetTransformationFlags(arrayContainer.Element); if (transformationFlags == null) { return new bool[2]; } bool[] array = new bool[transformationFlags.Length + 1]; array[0] = false; Array.Copy(transformationFlags, 0, array, 1, transformationFlags.Length); return array; } if (t == null) { return null; } if (t.IsGeneric) { List list = null; TypeSpec[] typeArguments = t.TypeArguments; for (int i = 0; i < typeArguments.Length; i++) { bool[] transformationFlags = GetTransformationFlags(typeArguments[i]); if (transformationFlags != null) { if (list == null) { list = new List(); for (int j = 0; j <= i; j++) { list.Add(item: false); } } list.AddRange(transformationFlags); } else { list?.Add(item: false); } } if (list != null) { return list.ToArray(); } } if (t.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return new bool[1] { true }; } return null; } private bool ResolveTransformationCtor(Location loc) { if (tctor != null) { return true; } tctor = module.PredefinedMembers.DynamicAttributeCtor.Resolve(loc); return tctor != null; } } internal class PredefinedTupleElementNamesAttribute : PredefinedAttribute { private MethodSpec tctor; public PredefinedTupleElementNamesAttribute(ModuleContainer module, string ns, string name) : base(module, ns, name) { } public void EmitAttribute(FieldBuilder builder, TypeSpec type, Location loc) { CustomAttributeBuilder customAttributeBuilder = CreateCustomAttributeBuilder(type, loc); if (customAttributeBuilder != null) { builder.SetCustomAttribute(customAttributeBuilder); } } public void EmitAttribute(ParameterBuilder builder, TypeSpec type, Location loc) { CustomAttributeBuilder customAttributeBuilder = CreateCustomAttributeBuilder(type, loc); if (customAttributeBuilder != null) { builder.SetCustomAttribute(customAttributeBuilder); } } public void EmitAttribute(PropertyBuilder builder, TypeSpec type, Location loc) { CustomAttributeBuilder customAttributeBuilder = CreateCustomAttributeBuilder(type, loc); if (customAttributeBuilder != null) { builder.SetCustomAttribute(customAttributeBuilder); } } public void EmitAttribute(TypeBuilder builder, TypeSpec type, Location loc) { CustomAttributeBuilder customAttributeBuilder = CreateCustomAttributeBuilder(type, loc); if (customAttributeBuilder != null) { builder.SetCustomAttribute(customAttributeBuilder); } } private CustomAttributeBuilder CreateCustomAttributeBuilder(TypeSpec type, Location loc) { if (tctor == null) { tctor = module.PredefinedMembers.TupleElementNamesAttributeCtor.Resolve(loc); if (tctor == null) { return null; } } List list = new List(type.TypeArguments.Length); BuildStringElements(type, list); return new CustomAttributeBuilder((ConstructorInfo)tctor.GetMetaInfo(), new object[1] { list.ToArray() }); } private static void BuildStringElements(TypeSpec type, List names) { while (type is ArrayContainer) { type = ((ArrayContainer)type).Element; } if (type is NamedTupleSpec namedTupleSpec) { names.AddRange(namedTupleSpec.Elements); } else { for (int i = 0; i < type.Arity; i++) { names.Add(null); } } TypeSpec[] typeArguments = type.TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { BuildStringElements(typeSpec, names); } } } internal static class ConstantFold { public static TypeSpec[] CreateBinaryPromotionsTypes(BuiltinTypes types) { return new TypeSpec[6] { types.Decimal, types.Double, types.Float, types.ULong, types.Long, types.UInt }; } private static bool DoBinaryNumericPromotions(ResolveContext rc, ref Constant left, ref Constant right) { TypeSpec type = left.Type; TypeSpec type2 = right.Type; TypeSpec[] binaryPromotionsTypes = rc.BuiltinTypes.BinaryPromotionsTypes; foreach (TypeSpec typeSpec in binaryPromotionsTypes) { if (typeSpec == type) { return typeSpec == type2 || ConvertPromotion(rc, ref right, ref left, typeSpec); } if (typeSpec == type2) { return typeSpec == type || ConvertPromotion(rc, ref left, ref right, typeSpec); } } left = left.ConvertImplicitly(rc.BuiltinTypes.Int); right = right.ConvertImplicitly(rc.BuiltinTypes.Int); return left != null && right != null; } private static bool ConvertPromotion(ResolveContext rc, ref Constant prim, ref Constant second, TypeSpec type) { Constant constant = prim.ConvertImplicitly(type); if (constant != null) { prim = constant; return true; } if (type.BuiltinType == BuiltinTypeSpec.Type.UInt) { type = rc.BuiltinTypes.Long; prim = prim.ConvertImplicitly(type); second = second.ConvertImplicitly(type); return prim != null && second != null; } return false; } internal static void Error_CompileTimeOverflow(ResolveContext rc, Location loc) { rc.Report.Error(220, loc, "The operation overflows at compile time in checked mode"); } public static Constant BinaryFold(ResolveContext ec, Binary.Operator oper, Constant left, Constant right, Location loc) { Constant result = null; if (left is EmptyConstantCast) { return BinaryFold(ec, oper, ((EmptyConstantCast)left).child, right, loc); } if (left is SideEffectConstant) { result = BinaryFold(ec, oper, ((SideEffectConstant)left).value, right, loc); if (result == null) { return null; } return new SideEffectConstant(result, left, loc); } if (right is EmptyConstantCast) { return BinaryFold(ec, oper, left, ((EmptyConstantCast)right).child, loc); } if (right is SideEffectConstant) { result = BinaryFold(ec, oper, left, ((SideEffectConstant)right).value, loc); if (result == null) { return null; } return new SideEffectConstant(result, right, loc); } TypeSpec type = left.Type; TypeSpec type2 = right.Type; if (type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && type == type2) { bool flag = (bool)left.GetValue(); bool flag2 = (bool)right.GetValue(); switch (oper) { case Binary.Operator.BitwiseAnd: case Binary.Operator.LogicalAnd: return new BoolConstant(ec.BuiltinTypes, flag && flag2, left.Location); case Binary.Operator.BitwiseOr: case Binary.Operator.LogicalOr: return new BoolConstant(ec.BuiltinTypes, flag || flag2, left.Location); case Binary.Operator.ExclusiveOr: return new BoolConstant(ec.BuiltinTypes, flag ^ flag2, left.Location); case Binary.Operator.Equality: return new BoolConstant(ec.BuiltinTypes, flag == flag2, left.Location); case Binary.Operator.Inequality: return new BoolConstant(ec.BuiltinTypes, flag != flag2, left.Location); default: return null; } } if (ec.HasSet(ResolveContext.Options.EnumScope)) { if (left is EnumConstant) { left = ((EnumConstant)left).Child; } if (right is EnumConstant) { right = ((EnumConstant)right).Child; } } else if (left is EnumConstant && type2 == type) { switch (oper) { case Binary.Operator.BitwiseAnd: case Binary.Operator.ExclusiveOr: case Binary.Operator.BitwiseOr: result = BinaryFold(ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); if (result != null) { result = result.Reduce(ec, type); } return result; case Binary.Operator.Subtraction: result = BinaryFold(ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); if (result != null) { result = result.Reduce(ec, EnumSpec.GetUnderlyingType(type)); } return result; case Binary.Operator.Equality: case Binary.Operator.Inequality: case Binary.Operator.LessThan: case Binary.Operator.GreaterThan: case Binary.Operator.LessThanOrEqual: case Binary.Operator.GreaterThanOrEqual: return BinaryFold(ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc); default: return null; } } switch (oper) { case Binary.Operator.BitwiseOr: if ((type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && right is NullLiteral) || (type2.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && left is NullLiteral)) { Expression expression2 = new Binary(oper, left, right).ResolveOperator(ec); if ((right is NullLiteral && left.IsDefaultValue) || (left is NullLiteral && right.IsDefaultValue)) { return LiftedNull.CreateFromExpression(ec, expression2); } return ReducedExpression.Create(new BoolConstant(ec.BuiltinTypes, val: true, loc), expression2); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } if (left is IntConstant) { int v9 = ((IntConstant)left).Value | ((IntConstant)right).Value; return new IntConstant(ec.BuiltinTypes, v9, left.Location); } if (left is UIntConstant) { uint v10 = ((UIntConstant)left).Value | ((UIntConstant)right).Value; return new UIntConstant(ec.BuiltinTypes, v10, left.Location); } if (left is LongConstant) { long v11 = ((LongConstant)left).Value | ((LongConstant)right).Value; return new LongConstant(ec.BuiltinTypes, v11, left.Location); } if (left is ULongConstant) { ulong v12 = ((ULongConstant)left).Value | ((ULongConstant)right).Value; return new ULongConstant(ec.BuiltinTypes, v12, left.Location); } break; case Binary.Operator.BitwiseAnd: if ((type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && right is NullLiteral) || (type2.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && left is NullLiteral)) { Expression expression = new Binary(oper, left, right).ResolveOperator(ec); if ((right is NullLiteral && left.IsDefaultValue) || (left is NullLiteral && right.IsDefaultValue)) { return ReducedExpression.Create(new BoolConstant(ec.BuiltinTypes, val: false, loc), expression); } return LiftedNull.CreateFromExpression(ec, expression); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } if (left is IntConstant) { int v5 = ((IntConstant)left).Value & ((IntConstant)right).Value; return new IntConstant(ec.BuiltinTypes, v5, left.Location); } if (left is UIntConstant) { uint v6 = ((UIntConstant)left).Value & ((UIntConstant)right).Value; return new UIntConstant(ec.BuiltinTypes, v6, left.Location); } if (left is LongConstant) { long v7 = ((LongConstant)left).Value & ((LongConstant)right).Value; return new LongConstant(ec.BuiltinTypes, v7, left.Location); } if (left is ULongConstant) { ulong v8 = ((ULongConstant)left).Value & ((ULongConstant)right).Value; return new ULongConstant(ec.BuiltinTypes, v8, left.Location); } break; case Binary.Operator.ExclusiveOr: if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } if (left is IntConstant) { int v = ((IntConstant)left).Value ^ ((IntConstant)right).Value; return new IntConstant(ec.BuiltinTypes, v, left.Location); } if (left is UIntConstant) { uint v2 = ((UIntConstant)left).Value ^ ((UIntConstant)right).Value; return new UIntConstant(ec.BuiltinTypes, v2, left.Location); } if (left is LongConstant) { long v3 = ((LongConstant)left).Value ^ ((LongConstant)right).Value; return new LongConstant(ec.BuiltinTypes, v3, left.Location); } if (left is ULongConstant) { ulong v4 = ((ULongConstant)left).Value ^ ((ULongConstant)right).Value; return new ULongConstant(ec.BuiltinTypes, v4, left.Location); } break; case Binary.Operator.Addition: { if (type.BuiltinType == BuiltinTypeSpec.Type.String || type2.BuiltinType == BuiltinTypeSpec.Type.String) { if (type == type2) { return new StringConstant(ec.BuiltinTypes, (string)left.GetValue() + (string)right.GetValue(), left.Location); } if (type == InternalType.NullLiteral || left.IsNull) { return new StringConstant(ec.BuiltinTypes, right.GetValue()?.ToString() ?? "", left.Location); } if (type2 == InternalType.NullLiteral || right.IsNull) { return new StringConstant(ec.BuiltinTypes, left.GetValue()?.ToString() ?? "", left.Location); } return null; } if (type == InternalType.NullLiteral) { if (type2.BuiltinType == BuiltinTypeSpec.Type.Object) { return new StringConstant(ec.BuiltinTypes, right.GetValue()?.ToString() ?? "", left.Location); } if (type == type2) { ec.Report.Error(34, loc, "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'", "+", type.GetSignatureForError(), type2.GetSignatureForError()); return null; } return right; } if (type2 == InternalType.NullLiteral) { if (type.BuiltinType == BuiltinTypeSpec.Type.Object) { return new StringConstant(ec.BuiltinTypes, right.GetValue()?.ToString() ?? "", left.Location); } return left; } EnumConstant enumConstant = left as EnumConstant; EnumConstant enumConstant2 = right as EnumConstant; if (enumConstant != null || enumConstant2 != null) { if (enumConstant == null) { enumConstant = enumConstant2; type = enumConstant.Type; right = left; } right = right.ConvertImplicitly(enumConstant.Child.Type); if (right == null) { return null; } result = BinaryFold(ec, oper, enumConstant.Child, right, loc); if (result == null) { return null; } result = result.Reduce(ec, type); if (result == null || type.IsEnum) { return result; } return new EnumConstant(result, type); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } try { if (left is DoubleConstant) { return new DoubleConstant(v: (!ec.ConstantCheckState) ? (((DoubleConstant)left).Value + ((DoubleConstant)right).Value) : (((DoubleConstant)left).Value + ((DoubleConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } if (left is FloatConstant) { double doubleValue3 = ((FloatConstant)left).DoubleValue; double doubleValue4 = ((FloatConstant)right).DoubleValue; result = new FloatConstant(v: (!ec.ConstantCheckState) ? (doubleValue3 + doubleValue4) : (doubleValue3 + doubleValue4), types: ec.BuiltinTypes, loc: left.Location); } else if (left is ULongConstant) { result = new ULongConstant(v: (!ec.ConstantCheckState) ? (((ULongConstant)left).Value + ((ULongConstant)right).Value) : checked(((ULongConstant)left).Value + ((ULongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is LongConstant) { result = new LongConstant(v: (!ec.ConstantCheckState) ? (((LongConstant)left).Value + ((LongConstant)right).Value) : checked(((LongConstant)left).Value + ((LongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is UIntConstant) { result = new UIntConstant(v: (!ec.ConstantCheckState) ? (((UIntConstant)left).Value + ((UIntConstant)right).Value) : checked(((UIntConstant)left).Value + ((UIntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is IntConstant) { result = new IntConstant(v: (!ec.ConstantCheckState) ? (((IntConstant)left).Value + ((IntConstant)right).Value) : checked(((IntConstant)left).Value + ((IntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is DecimalConstant) { result = new DecimalConstant(d: (!ec.ConstantCheckState) ? (((DecimalConstant)left).Value + ((DecimalConstant)right).Value) : (((DecimalConstant)left).Value + ((DecimalConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } } catch (OverflowException) { Error_CompileTimeOverflow(ec, loc); } return result; } case Binary.Operator.Subtraction: { EnumConstant enumConstant = left as EnumConstant; EnumConstant enumConstant2 = right as EnumConstant; if (enumConstant != null || enumConstant2 != null) { TypeSpec type3; if (enumConstant == null) { type3 = right.Type; left = left.ConvertImplicitly(enumConstant2.Child.Type); if (left == null) { return null; } right = enumConstant2.Child; } else { type3 = left.Type; right = right.ConvertImplicitly(enumConstant.Child.Type); if (right == null) { return null; } left = enumConstant.Child; } result = BinaryFold(ec, oper, left, right, loc); if (result == null) { return null; } result = result.Reduce(ec, type3); if (result == null) { return null; } return new EnumConstant(result, type3); } if (left is NullLiteral && right is NullLiteral) { NullableType nullableType4 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType4.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType4, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } try { if (left is DoubleConstant) { result = new DoubleConstant(v: (!ec.ConstantCheckState) ? (((DoubleConstant)left).Value - ((DoubleConstant)right).Value) : (((DoubleConstant)left).Value - ((DoubleConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is FloatConstant) { double doubleValue = ((FloatConstant)left).DoubleValue; double doubleValue2 = ((FloatConstant)right).DoubleValue; result = new FloatConstant(v: (!ec.ConstantCheckState) ? (doubleValue - doubleValue2) : (doubleValue - doubleValue2), types: ec.BuiltinTypes, loc: left.Location); } else if (left is ULongConstant) { result = new ULongConstant(v: (!ec.ConstantCheckState) ? (((ULongConstant)left).Value - ((ULongConstant)right).Value) : checked(((ULongConstant)left).Value - ((ULongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is LongConstant) { result = new LongConstant(v: (!ec.ConstantCheckState) ? (((LongConstant)left).Value - ((LongConstant)right).Value) : checked(((LongConstant)left).Value - ((LongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else if (left is UIntConstant) { result = new UIntConstant(v: (!ec.ConstantCheckState) ? (((UIntConstant)left).Value - ((UIntConstant)right).Value) : checked(((UIntConstant)left).Value - ((UIntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } else { if (!(left is IntConstant)) { if (!(left is DecimalConstant)) { throw new Exception("Unexepected subtraction input: " + left); } return new DecimalConstant(d: (!ec.ConstantCheckState) ? (((DecimalConstant)left).Value - ((DecimalConstant)right).Value) : (((DecimalConstant)left).Value - ((DecimalConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } result = new IntConstant(v: (!ec.ConstantCheckState) ? (((IntConstant)left).Value - ((IntConstant)right).Value) : checked(((IntConstant)left).Value - ((IntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } } catch (OverflowException) { Error_CompileTimeOverflow(ec, loc); } return result; } case Binary.Operator.Multiply: if (left is NullLiteral && right is NullLiteral) { NullableType nullableType10 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType10.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType10, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } try { if (!(left is DoubleConstant)) { if (left is FloatConstant) { double doubleValue9 = ((FloatConstant)left).DoubleValue; double doubleValue10 = ((FloatConstant)right).DoubleValue; return new FloatConstant(v: (!ec.ConstantCheckState) ? (doubleValue9 * doubleValue10) : (doubleValue9 * doubleValue10), types: ec.BuiltinTypes, loc: left.Location); } if (!(left is ULongConstant)) { if (!(left is LongConstant)) { if (!(left is UIntConstant)) { if (!(left is IntConstant)) { if (!(left is DecimalConstant)) { throw new Exception("Unexepected multiply input: " + left); } return new DecimalConstant(d: (!ec.ConstantCheckState) ? (((DecimalConstant)left).Value * ((DecimalConstant)right).Value) : (((DecimalConstant)left).Value * ((DecimalConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new IntConstant(v: (!ec.ConstantCheckState) ? (((IntConstant)left).Value * ((IntConstant)right).Value) : checked(((IntConstant)left).Value * ((IntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new UIntConstant(v: (!ec.ConstantCheckState) ? (((UIntConstant)left).Value * ((UIntConstant)right).Value) : checked(((UIntConstant)left).Value * ((UIntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new LongConstant(v: (!ec.ConstantCheckState) ? (((LongConstant)left).Value * ((LongConstant)right).Value) : checked(((LongConstant)left).Value * ((LongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new ULongConstant(v: (!ec.ConstantCheckState) ? (((ULongConstant)left).Value * ((ULongConstant)right).Value) : checked(((ULongConstant)left).Value * ((ULongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new DoubleConstant(v: (!ec.ConstantCheckState) ? (((DoubleConstant)left).Value * ((DoubleConstant)right).Value) : (((DoubleConstant)left).Value * ((DoubleConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } catch (OverflowException) { Error_CompileTimeOverflow(ec, loc); } break; case Binary.Operator.Division: if (left is NullLiteral && right is NullLiteral) { NullableType nullableType8 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType8.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType8, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } try { if (!(left is DoubleConstant)) { if (left is FloatConstant) { double doubleValue7 = ((FloatConstant)left).DoubleValue; double doubleValue8 = ((FloatConstant)right).DoubleValue; return new FloatConstant(v: (!ec.ConstantCheckState) ? (doubleValue7 / doubleValue8) : (doubleValue7 / doubleValue8), types: ec.BuiltinTypes, loc: left.Location); } if (!(left is ULongConstant)) { if (!(left is LongConstant)) { if (!(left is UIntConstant)) { if (!(left is IntConstant)) { if (!(left is DecimalConstant)) { throw new Exception("Unexepected division input: " + left); } return new DecimalConstant(d: (!ec.ConstantCheckState) ? (((DecimalConstant)left).Value / ((DecimalConstant)right).Value) : (((DecimalConstant)left).Value / ((DecimalConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new IntConstant(v: (!ec.ConstantCheckState) ? (((IntConstant)left).Value / ((IntConstant)right).Value) : (((IntConstant)left).Value / ((IntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new UIntConstant(v: (!ec.ConstantCheckState) ? (((UIntConstant)left).Value / ((UIntConstant)right).Value) : (((UIntConstant)left).Value / ((UIntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new LongConstant(v: (!ec.ConstantCheckState) ? (((LongConstant)left).Value / ((LongConstant)right).Value) : (((LongConstant)left).Value / ((LongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new ULongConstant(v: (!ec.ConstantCheckState) ? (((ULongConstant)left).Value / ((ULongConstant)right).Value) : (((ULongConstant)left).Value / ((ULongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new DoubleConstant(v: (!ec.ConstantCheckState) ? (((DoubleConstant)left).Value / ((DoubleConstant)right).Value) : (((DoubleConstant)left).Value / ((DoubleConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } catch (OverflowException) { Error_CompileTimeOverflow(ec, loc); } catch (DivideByZeroException) { ec.Report.Error(20, loc, "Division by constant zero"); } break; case Binary.Operator.Modulus: if (left is NullLiteral && right is NullLiteral) { NullableType nullableType7 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType7.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType7, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } try { if (!(left is DoubleConstant)) { if (left is FloatConstant) { double doubleValue5 = ((FloatConstant)left).DoubleValue; double doubleValue6 = ((FloatConstant)right).DoubleValue; return new FloatConstant(v: (!ec.ConstantCheckState) ? (doubleValue5 % doubleValue6) : (doubleValue5 % doubleValue6), types: ec.BuiltinTypes, loc: left.Location); } if (!(left is ULongConstant)) { if (!(left is LongConstant)) { if (!(left is UIntConstant)) { if (!(left is IntConstant)) { if (!(left is DecimalConstant)) { throw new Exception("Unexepected modulus input: " + left); } return new DecimalConstant(d: (!ec.ConstantCheckState) ? (((DecimalConstant)left).Value % ((DecimalConstant)right).Value) : (((DecimalConstant)left).Value % ((DecimalConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new IntConstant(v: (!ec.ConstantCheckState) ? (((IntConstant)left).Value % ((IntConstant)right).Value) : (((IntConstant)left).Value % ((IntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new UIntConstant(v: (!ec.ConstantCheckState) ? (((UIntConstant)left).Value % ((UIntConstant)right).Value) : (((UIntConstant)left).Value % ((UIntConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new LongConstant(v: (!ec.ConstantCheckState) ? (((LongConstant)left).Value % ((LongConstant)right).Value) : (((LongConstant)left).Value % ((LongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new ULongConstant(v: (!ec.ConstantCheckState) ? (((ULongConstant)left).Value % ((ULongConstant)right).Value) : (((ULongConstant)left).Value % ((ULongConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } return new DoubleConstant(v: (!ec.ConstantCheckState) ? (((DoubleConstant)left).Value % ((DoubleConstant)right).Value) : (((DoubleConstant)left).Value % ((DoubleConstant)right).Value), types: ec.BuiltinTypes, loc: left.Location); } catch (DivideByZeroException) { ec.Report.Error(20, loc, "Division by constant zero"); } catch (OverflowException) { Error_CompileTimeOverflow(ec, loc); } break; case Binary.Operator.LeftShift: if (left is NullLiteral && right is NullLiteral) { NullableType nullableType3 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType3.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType3, right).ResolveOperator(ec); } if (!(right.ConvertImplicitly(ec.BuiltinTypes.Int) is IntConstant { Value: var value2 })) { return null; } switch (left.Type.BuiltinType) { case BuiltinTypeSpec.Type.ULong: return new ULongConstant(ec.BuiltinTypes, ((ULongConstant)left).Value << value2, left.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(ec.BuiltinTypes, ((LongConstant)left).Value << value2, left.Location); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(ec.BuiltinTypes, ((UIntConstant)left).Value << value2, left.Location); default: if (left is NullLiteral) { return (Constant)new Binary(oper, left, right).ResolveOperator(ec); } left = left.ConvertImplicitly(ec.BuiltinTypes.Int); if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) { return new IntConstant(ec.BuiltinTypes, ((IntConstant)left).Value << value2, left.Location); } return null; } case Binary.Operator.RightShift: if (left is NullLiteral && right is NullLiteral) { NullableType nullableType2 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType2.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType2, right).ResolveOperator(ec); } if (!(right.ConvertImplicitly(ec.BuiltinTypes.Int) is IntConstant { Value: var value })) { return null; } switch (left.Type.BuiltinType) { case BuiltinTypeSpec.Type.ULong: return new ULongConstant(ec.BuiltinTypes, ((ULongConstant)left).Value >> value, left.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(ec.BuiltinTypes, ((LongConstant)left).Value >> value, left.Location); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(ec.BuiltinTypes, ((UIntConstant)left).Value >> value, left.Location); default: if (left is NullLiteral) { return (Constant)new Binary(oper, left, right).ResolveOperator(ec); } left = left.ConvertImplicitly(ec.BuiltinTypes.Int); if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Int) { return new IntConstant(ec.BuiltinTypes, ((IntConstant)left).Value >> value, left.Location); } return null; } case Binary.Operator.Equality: { if ((TypeSpec.IsReferenceType(type) && TypeSpec.IsReferenceType(type2)) || (left is LiftedNull && right.IsNull) || (right is LiftedNull && left.IsNull)) { if (left.IsNull || right.IsNull) { return ReducedExpression.Create(new BoolConstant(ec.BuiltinTypes, left.IsNull == right.IsNull, left.Location), new Binary(oper, left, right)); } if (left is StringConstant && right is StringConstant) { return new BoolConstant(ec.BuiltinTypes, ((StringConstant)left).Value == ((StringConstant)right).Value, left.Location); } return null; } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } bool flag3 = false; if (left is DoubleConstant) { flag3 = ((DoubleConstant)left).Value == ((DoubleConstant)right).Value; } else if (left is FloatConstant) { flag3 = ((FloatConstant)left).DoubleValue == ((FloatConstant)right).DoubleValue; } else if (left is ULongConstant) { flag3 = ((ULongConstant)left).Value == ((ULongConstant)right).Value; } else if (left is LongConstant) { flag3 = ((LongConstant)left).Value == ((LongConstant)right).Value; } else if (left is UIntConstant) { flag3 = ((UIntConstant)left).Value == ((UIntConstant)right).Value; } else { if (!(left is IntConstant)) { return null; } flag3 = ((IntConstant)left).Value == ((IntConstant)right).Value; } return new BoolConstant(ec.BuiltinTypes, flag3, left.Location); } case Binary.Operator.Inequality: { if ((TypeSpec.IsReferenceType(type) && TypeSpec.IsReferenceType(type2)) || (left is LiftedNull && right.IsNull) || (right is LiftedNull && left.IsNull)) { if (left.IsNull || right.IsNull) { return ReducedExpression.Create(new BoolConstant(ec.BuiltinTypes, left.IsNull != right.IsNull, left.Location), new Binary(oper, left, right)); } if (left is StringConstant && right is StringConstant) { return new BoolConstant(ec.BuiltinTypes, ((StringConstant)left).Value != ((StringConstant)right).Value, left.Location); } return null; } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } bool flag3 = false; if (left is DoubleConstant) { flag3 = ((DoubleConstant)left).Value != ((DoubleConstant)right).Value; } else if (left is FloatConstant) { flag3 = ((FloatConstant)left).DoubleValue != ((FloatConstant)right).DoubleValue; } else if (left is ULongConstant) { flag3 = ((ULongConstant)left).Value != ((ULongConstant)right).Value; } else if (left is LongConstant) { flag3 = ((LongConstant)left).Value != ((LongConstant)right).Value; } else if (left is UIntConstant) { flag3 = ((UIntConstant)left).Value != ((UIntConstant)right).Value; } else { if (!(left is IntConstant)) { return null; } flag3 = ((IntConstant)left).Value != ((IntConstant)right).Value; } return new BoolConstant(ec.BuiltinTypes, flag3, left.Location); } case Binary.Operator.LessThan: { if (right is NullLiteral && left is NullLiteral) { NullableType nullableType9 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType9.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType9, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } bool flag3 = false; if (left is DoubleConstant) { flag3 = ((DoubleConstant)left).Value < ((DoubleConstant)right).Value; } else if (left is FloatConstant) { flag3 = ((FloatConstant)left).DoubleValue < ((FloatConstant)right).DoubleValue; } else if (left is ULongConstant) { flag3 = ((ULongConstant)left).Value < ((ULongConstant)right).Value; } else if (left is LongConstant) { flag3 = ((LongConstant)left).Value < ((LongConstant)right).Value; } else if (left is UIntConstant) { flag3 = ((UIntConstant)left).Value < ((UIntConstant)right).Value; } else { if (!(left is IntConstant)) { return null; } flag3 = ((IntConstant)left).Value < ((IntConstant)right).Value; } return new BoolConstant(ec.BuiltinTypes, flag3, left.Location); } case Binary.Operator.GreaterThan: { if (right is NullLiteral && left is NullLiteral) { NullableType nullableType6 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType6.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType6, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } bool flag3 = false; if (left is DoubleConstant) { flag3 = ((DoubleConstant)left).Value > ((DoubleConstant)right).Value; } else if (left is FloatConstant) { flag3 = ((FloatConstant)left).DoubleValue > ((FloatConstant)right).DoubleValue; } else if (left is ULongConstant) { flag3 = ((ULongConstant)left).Value > ((ULongConstant)right).Value; } else if (left is LongConstant) { flag3 = ((LongConstant)left).Value > ((LongConstant)right).Value; } else if (left is UIntConstant) { flag3 = ((UIntConstant)left).Value > ((UIntConstant)right).Value; } else { if (!(left is IntConstant)) { return null; } flag3 = ((IntConstant)left).Value > ((IntConstant)right).Value; } return new BoolConstant(ec.BuiltinTypes, flag3, left.Location); } case Binary.Operator.GreaterThanOrEqual: { if (right is NullLiteral && left is NullLiteral) { NullableType nullableType5 = new NullableType(ec.BuiltinTypes.Int, loc); nullableType5.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType5, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } bool flag3 = false; if (left is DoubleConstant) { flag3 = ((DoubleConstant)left).Value >= ((DoubleConstant)right).Value; } else if (left is FloatConstant) { flag3 = ((FloatConstant)left).DoubleValue >= ((FloatConstant)right).DoubleValue; } else if (left is ULongConstant) { flag3 = ((ULongConstant)left).Value >= ((ULongConstant)right).Value; } else if (left is LongConstant) { flag3 = ((LongConstant)left).Value >= ((LongConstant)right).Value; } else if (left is UIntConstant) { flag3 = ((UIntConstant)left).Value >= ((UIntConstant)right).Value; } else { if (!(left is IntConstant)) { return null; } flag3 = ((IntConstant)left).Value >= ((IntConstant)right).Value; } return new BoolConstant(ec.BuiltinTypes, flag3, left.Location); } case Binary.Operator.LessThanOrEqual: { if (right is NullLiteral && left is NullLiteral) { NullableType nullableType = new NullableType(ec.BuiltinTypes.Int, loc); nullableType.ResolveAsType(ec); return (Constant)new Binary(oper, nullableType, right).ResolveOperator(ec); } if (!DoBinaryNumericPromotions(ec, ref left, ref right)) { return null; } bool flag3 = false; if (left is DoubleConstant) { flag3 = ((DoubleConstant)left).Value <= ((DoubleConstant)right).Value; } else if (left is FloatConstant) { flag3 = ((FloatConstant)left).DoubleValue <= ((FloatConstant)right).DoubleValue; } else if (left is ULongConstant) { flag3 = ((ULongConstant)left).Value <= ((ULongConstant)right).Value; } else if (left is LongConstant) { flag3 = ((LongConstant)left).Value <= ((LongConstant)right).Value; } else if (left is UIntConstant) { flag3 = ((UIntConstant)left).Value <= ((UIntConstant)right).Value; } else { if (!(left is IntConstant)) { return null; } flag3 = ((IntConstant)left).Value <= ((IntConstant)right).Value; } return new BoolConstant(ec.BuiltinTypes, flag3, left.Location); } } return null; } } internal abstract class TypeContainer : MemberCore { public readonly MemberKind Kind; protected List containers; private TypeDefinition main_container; protected Dictionary defined_names; protected bool is_defined; public int CounterAnonymousMethods { get; set; } public int CounterAnonymousContainers { get; set; } public int CounterSwitchTypes { get; set; } public override TypeSpec CurrentType => null; public Dictionary DefinedNames => defined_names; public TypeDefinition PartialContainer { get { return main_container; } protected set { main_container = value; } } public IList Containers => containers; public Attributes UnattachedAttributes { get; set; } protected TypeContainer(TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base(parent, name, attrs) { Kind = kind; defined_names = new Dictionary(); } public void AddCompilerGeneratedClass(CompilerGeneratedContainer c) { AddTypeContainerMember(c); } public virtual void AddPartial(TypeDefinition next_part) { (PartialContainer ?? this).defined_names.TryGetValue(next_part.MemberName.Basename, out var value); AddPartial(next_part, value as TypeDefinition); } protected void AddPartial(TypeDefinition next_part, TypeDefinition existing) { next_part.ModFlags |= Modifiers.PARTIAL; if (existing == null) { AddTypeContainer(next_part); return; } if ((existing.ModFlags & Modifiers.PARTIAL) == 0) { if (existing.Kind != next_part.Kind) { AddTypeContainer(next_part); return; } base.Report.SymbolRelatedToPreviousError(next_part); Error_MissingPartialModifier(existing); return; } if (existing.Kind != next_part.Kind) { base.Report.SymbolRelatedToPreviousError(existing); base.Report.Error(261, next_part.Location, "Partial declarations of `{0}' must be all classes, all structs or all interfaces", next_part.GetSignatureForError()); } if ((existing.ModFlags & Modifiers.AccessibilityMask) != (next_part.ModFlags & Modifiers.AccessibilityMask) && (existing.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFIER) == 0 && (next_part.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFIER) == 0) { base.Report.SymbolRelatedToPreviousError(existing); base.Report.Error(262, next_part.Location, "Partial declarations of `{0}' have conflicting accessibility modifiers", next_part.GetSignatureForError()); } TypeParameters currentTypeParameters = existing.CurrentTypeParameters; if (currentTypeParameters != null) { for (int i = 0; i < currentTypeParameters.Count; i++) { TypeParameter typeParameter = next_part.MemberName.TypeParameters[i]; if (currentTypeParameters[i].MemberName.Name != typeParameter.MemberName.Name) { base.Report.SymbolRelatedToPreviousError(existing.Location, ""); base.Report.Error(264, next_part.Location, "Partial declarations of `{0}' must have the same type parameter names in the same order", next_part.GetSignatureForError()); break; } if (currentTypeParameters[i].Variance != typeParameter.Variance) { base.Report.SymbolRelatedToPreviousError(existing.Location, ""); base.Report.Error(1067, next_part.Location, "Partial declarations of `{0}' must have the same type parameter variance modifiers", next_part.GetSignatureForError()); break; } } } if ((next_part.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFIER) != 0) { existing.ModFlags |= next_part.ModFlags & ~(Modifiers.AccessibilityMask | Modifiers.DEFAULT_ACCESS_MODIFIER); } else if ((existing.ModFlags & Modifiers.DEFAULT_ACCESS_MODIFIER) != 0) { existing.ModFlags &= ~(Modifiers.AccessibilityMask | Modifiers.DEFAULT_ACCESS_MODIFIER); existing.ModFlags |= next_part.ModFlags; } else { existing.ModFlags |= next_part.ModFlags; } existing.Definition.Modifiers = existing.ModFlags; if (next_part.attributes != null) { if (existing.attributes == null) { existing.attributes = next_part.attributes; } else { existing.attributes.AddAttributes(next_part.attributes.Attrs); } } next_part.PartialContainer = existing; existing.AddPartialPart(next_part); AddTypeContainerMember(next_part); } public virtual void AddTypeContainer(TypeContainer tc) { AddTypeContainerMember(tc); TypeParameters typeParameters = tc.MemberName.TypeParameters; if (typeParameters == null || tc.PartialContainer == null) { return; } TypeDefinition typeDefinition = (TypeDefinition)tc; for (int i = 0; i < typeParameters.Count; i++) { TypeParameter typeParameter = typeParameters[i]; if (typeParameter.MemberName != null) { typeDefinition.AddNameToContainer(typeParameter, typeParameter.Name); } } } protected virtual void AddTypeContainerMember(TypeContainer tc) { containers.Add(tc); } public virtual void CloseContainer() { if (containers == null) { return; } foreach (TypeContainer container in containers) { container.CloseContainer(); } } public void CloseContainerEarlyForReflectionEmit() { if (containers == null) { return; } foreach (TypeContainer container in containers) { if (container.Kind == MemberKind.Enum) { container.CloseContainer(); } else { container.CloseContainerEarlyForReflectionEmit(); } } } public virtual void CreateMetadataName(StringBuilder sb) { if (Parent != null && Parent.MemberName != null) { Parent.CreateMetadataName(sb); } base.MemberName.CreateMetadataName(sb); } public virtual bool CreateContainer() { if (containers != null) { foreach (TypeContainer container in containers) { container.CreateContainer(); } } return true; } public override bool Define() { if (containers != null) { foreach (TypeContainer container in containers) { container.Define(); } } if (Module.Evaluator == null) { defined_names = null; } else { defined_names.Clear(); } return true; } public virtual void PrepareEmit() { if (containers == null) { return; } foreach (TypeContainer container in containers) { try { container.PrepareEmit(); } catch (Exception e) { if (base.MemberName == MemberName.Null) { throw; } throw new InternalErrorException(container, e); } } } public virtual bool DefineContainer() { if (is_defined) { return true; } is_defined = true; DoDefineContainer(); if (containers != null) { foreach (TypeContainer container in containers) { try { container.DefineContainer(); } catch (Exception e) { if (base.MemberName == MemberName.Null) { throw; } throw new InternalErrorException(container, e); } } if (PartialContainer != null && PartialContainer != this) { containers = null; } } return true; } public virtual void ExpandBaseInterfaces() { if (containers == null) { return; } foreach (TypeContainer container in containers) { container.ExpandBaseInterfaces(); } } protected virtual void DefineNamespace() { if (containers == null) { return; } foreach (TypeContainer container in containers) { try { container.DefineNamespace(); } catch (Exception e) { throw new InternalErrorException(container, e); } } } protected virtual void DoDefineContainer() { } public virtual void EmitContainer() { if (containers != null) { for (int i = 0; i < containers.Count; i++) { containers[i].EmitContainer(); } } } protected void Error_MissingPartialModifier(MemberCore type) { base.Report.Error(260, type.Location, "Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists", type.GetSignatureForError()); } public override string GetSignatureForDocumentation() { if (Parent != null && Parent.MemberName != null) { return Parent.GetSignatureForDocumentation() + "." + base.MemberName.GetSignatureForDocumentation(); } return base.MemberName.GetSignatureForDocumentation(); } public override string GetSignatureForError() { if (Parent != null && Parent.MemberName != null) { return Parent.GetSignatureForError() + "." + base.MemberName.GetSignatureForError(); } return base.MemberName.GetSignatureForError(); } public virtual string GetSignatureForMetadata() { StringBuilder stringBuilder = new StringBuilder(); CreateMetadataName(stringBuilder); return stringBuilder.ToString(); } public virtual void RemoveContainer(TypeContainer cont) { if (containers != null) { containers.Remove(cont); } TypeContainer typeContainer = ((Parent == Module) ? Module : this); typeContainer.defined_names.Remove(cont.MemberName.Basename); } public virtual void VerifyMembers() { if (containers == null) { return; } foreach (TypeContainer container in containers) { container.VerifyMembers(); } } public override void WriteDebugSymbol(MonoSymbolFile file) { if (containers == null) { return; } foreach (TypeContainer container in containers) { container.WriteDebugSymbol(file); } } } internal abstract class TypeDefinition : TypeContainer, ITypeDefinition, IMemberDefinition { public struct BaseContext : IMemberContext, IModuleContext { private TypeContainer tc; public CompilerContext Compiler => tc.Compiler; public TypeSpec CurrentType => tc.PartialContainer.CurrentType; public TypeParameters CurrentTypeParameters => tc.PartialContainer.CurrentTypeParameters; public MemberCore CurrentMemberDefinition => tc; public bool IsObsolete => tc.IsObsolete; public bool IsUnsafe => tc.IsUnsafe; public bool IsStatic => tc.IsStatic; public ModuleContainer Module => tc.Module; public BaseContext(TypeContainer tc) { this.tc = tc; } public string GetSignatureForError() { return tc.GetSignatureForError(); } public ExtensionMethodCandidates LookupExtensionMethod(string name, int arity) { return null; } public FullNamedExpression LookupNamespaceAlias(string name) { return tc.Parent.LookupNamespaceAlias(name); } public FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { if (arity == 0) { TypeParameters currentTypeParameters = CurrentTypeParameters; if (currentTypeParameters != null) { TypeParameter typeParameter = currentTypeParameters.Find(name); if (typeParameter != null) { return new TypeParameterExpr(typeParameter, loc); } } } return tc.Parent.LookupNamespaceOrType(name, arity, mode, loc); } } [Flags] private enum CachedMethods { Equals = 1, GetHashCode = 2, HasStaticFieldInitializer = 4 } private readonly List members; protected List initialized_fields; protected List initialized_static_fields; private Dictionary hoisted_base_call_proxies; private Dictionary Cache = new Dictionary(); protected FieldBase first_nonstatic_field; protected TypeSpec base_type; private FullNamedExpression base_type_expr; protected TypeSpec[] iface_exprs; protected List type_bases; private List class_partial_parts; private TypeDefinition InTransit; public TypeBuilder TypeBuilder; private GenericTypeParameterBuilder[] all_tp_builders; private TypeParameters all_type_parameters; public const string DefaultIndexerName = "Item"; private bool has_normal_indexers; private string indexer_name; private bool error; private bool members_defined; private bool members_defined_ok; protected bool has_static_constructor; private CachedMethods cached_method; protected TypeSpec spec; private TypeSpec current_type; public int DynamicSitesCounter; public int AnonymousMethodsCounter; public int MethodGroupsCounter; private static readonly string[] attribute_targets = new string[1] { "type" }; private static readonly string[] attribute_targets_primary = new string[2] { "type", "method" }; private PendingImplementation pending; public List BaseTypeExpressions => type_bases; public override TypeSpec CurrentType { get { if (current_type == null) { if (IsGenericOrParentIsGeneric) { TypeSpec[] array; if (CurrentTypeParameters != null) { TypeSpec[] types = CurrentTypeParameters.Types; array = types; } else { array = TypeSpec.EmptyTypes; } TypeSpec[] targs = array; current_type = spec.MakeGenericType(this, targs); } else { current_type = spec; } } return current_type; } } public override TypeParameters CurrentTypeParameters => base.PartialContainer.MemberName.TypeParameters; private int CurrentTypeParametersStartIndex { get { int num = all_tp_builders.Length; if (CurrentTypeParameters != null) { return num - CurrentTypeParameters.Count; } return num; } } public virtual AssemblyDefinition DeclaringAssembly => Module.DeclaringAssembly; IAssemblyDefinition ITypeDefinition.DeclaringAssembly => Module.DeclaringAssembly; public TypeSpec Definition => spec; public bool HasMembersDefined => members_defined; public bool HasInstanceConstructor { get { return (caching_flags & Flags.HasInstanceConstructor) != 0; } set { caching_flags |= Flags.HasInstanceConstructor; } } public bool HasInstanceField { get { return (caching_flags & Flags.HasInstanceField) != 0; } set { caching_flags |= Flags.HasInstanceField; } } public bool HasExplicitLayout { get { return (caching_flags & Flags.HasExplicitLayout) != 0; } set { caching_flags |= Flags.HasExplicitLayout; } } public bool HasOperators { get { return (caching_flags & Flags.HasUserOperators) != 0; } set { caching_flags |= Flags.HasUserOperators; } } public bool HasStructLayout { get { return (caching_flags & Flags.HasStructLayout) != 0; } set { caching_flags |= Flags.HasStructLayout; } } public TypeSpec[] Interfaces => iface_exprs; public bool IsGenericOrParentIsGeneric => all_type_parameters != null; public bool IsTopLevel => !(Parent is TypeDefinition); public bool IsPartial => (base.ModFlags & Modifiers.PARTIAL) != 0; bool ITypeDefinition.IsTypeForwarder => false; bool ITypeDefinition.IsCyclicTypeForwarder => false; private bool IsPartialPart => base.PartialContainer != this; public MemberCache MemberCache => spec.MemberCache; public List Members => members; string ITypeDefinition.Namespace { get { TypeContainer parent = Parent; while (parent.Kind != MemberKind.Namespace) { parent = parent.Parent; } return (parent.MemberName == null) ? null : parent.GetSignatureForError(); } } public ParametersCompiled PrimaryConstructorParameters { get; set; } public Arguments PrimaryConstructorBaseArguments { get; set; } public Location PrimaryConstructorBaseArgumentsStart { get; set; } public TypeParameters TypeParametersAll => all_type_parameters; public override string[] ValidAttributeTargets => (PrimaryConstructorParameters != null) ? attribute_targets_primary : attribute_targets; public override AttributeTargets AttributeTargets { get { throw new NotSupportedException(); } } public TypeSpec BaseType => spec.BaseType; protected virtual TypeAttributes TypeAttr => ModifiersExtensions.TypeAttr(base.ModFlags, IsTopLevel); public int TypeParametersCount => base.MemberName.Arity; TypeParameterSpec[] ITypeDefinition.TypeParameters { get { TypeParameters currentTypeParameters = base.PartialContainer.CurrentTypeParameters; return (currentTypeParameters == null) ? TypeParameterSpec.EmptyTypes : currentTypeParameters.Types; } } public bool IsComImport { get { if (base.OptAttributes == null) { return false; } return base.OptAttributes.Contains(Module.PredefinedAttributes.ComImport); } } public override string DocComment { get { return comment; } set { if (value != null) { comment += value; } } } public PendingImplementation PendingImplementations => pending; public bool HasEquals => (cached_method & CachedMethods.Equals) != 0; public bool HasGetHashCode => (cached_method & CachedMethods.GetHashCode) != 0; public bool HasStaticFieldInitializer { get { return (cached_method & CachedMethods.HasStaticFieldInitializer) != 0; } set { if (value) { cached_method |= CachedMethods.HasStaticFieldInitializer; } else { cached_method &= ~CachedMethods.HasStaticFieldInitializer; } } } public override string DocCommentHeader => "T:"; protected TypeDefinition(TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base(parent, name, attrs, kind) { base.PartialContainer = this; members = new List(); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public void AddMember(MemberCore symbol) { if (symbol.MemberName.ExplicitInterface != null && Kind != MemberKind.Class && Kind != MemberKind.Struct) { base.Report.Error(541, symbol.Location, "`{0}': explicit interface declaration can only be declared in a class or struct", symbol.GetSignatureForError()); } AddNameToContainer(symbol, symbol.MemberName.Name); members.Add(symbol); } public override void AddTypeContainer(TypeContainer tc) { AddNameToContainer(tc, tc.MemberName.Basename); base.AddTypeContainer(tc); } protected override void AddTypeContainerMember(TypeContainer tc) { members.Add(tc); if (containers == null) { containers = new List(); } base.AddTypeContainerMember(tc); } public virtual void AddNameToContainer(MemberCore symbol, string name) { if (((base.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0) { return; } if (!base.PartialContainer.defined_names.TryGetValue(name, out var value)) { base.PartialContainer.defined_names.Add(name, symbol); } else if (!symbol.EnableOverloadChecks(value) && !(value is InterfaceMemberBase { IsExplicitImpl: not false })) { base.Report.SymbolRelatedToPreviousError(value); if ((value.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) { Error_MissingPartialModifier(symbol); } else if (symbol is TypeParameter) { base.Report.Error(692, symbol.Location, "Duplicate type parameter `{0}'", symbol.GetSignatureForError()); } else { base.Report.Error(102, symbol.Location, "The type `{0}' already contains a definition for `{1}'", GetSignatureForError(), name); } } } public void AddConstructor(Constructor c) { AddConstructor(c, isDefault: false); } public void AddConstructor(Constructor c, bool isDefault) { bool flag = (c.ModFlags & Modifiers.STATIC) != 0; if (!isDefault) { AddNameToContainer(c, flag ? Constructor.TypeConstructorName : Constructor.ConstructorName); } if (flag && c.ParameterInfo.IsEmpty) { base.PartialContainer.has_static_constructor = true; } else { base.PartialContainer.HasInstanceConstructor = true; } members.Add(c); } public bool AddField(FieldBase field) { AddMember(field); if ((field.ModFlags & Modifiers.STATIC) != 0) { return true; } if (!base.PartialContainer.HasInstanceField) { base.PartialContainer.HasInstanceField = true; base.PartialContainer.first_nonstatic_field = field; return true; } if (Kind == MemberKind.Struct) { FieldBase fieldBase = base.PartialContainer.first_nonstatic_field; if (fieldBase.Parent != field.Parent) { base.Report.SymbolRelatedToPreviousError(fieldBase.Parent); base.Report.Warning(282, 3, field.Location, "struct instance field `{0}' found in different declaration from instance field `{1}'", field.GetSignatureForError(), fieldBase.GetSignatureForError()); } } return true; } public void AddIndexer(Indexer i) { members.Add(i); } public void AddOperator(Operator op) { base.PartialContainer.HasOperators = true; AddMember(op); } public void AddPartialPart(TypeDefinition part) { if (Kind == MemberKind.Class) { if (class_partial_parts == null) { class_partial_parts = new List(); } class_partial_parts.Add(part); } } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Method) { foreach (MemberCore member in members) { if (!(member is Constructor { IsPrimaryConstructor: not false } constructor)) { continue; } constructor.ApplyAttributeBuilder(a, ctor, cdata, pa); return; } throw new InternalErrorException(); } if (has_normal_indexers && a.Type == pa.DefaultMember) { base.Report.Error(646, a.Location, "Cannot specify the `DefaultMember' attribute on type containing an indexer"); } else if (a.Type == pa.Required) { base.Report.Error(1608, a.Location, "The RequiredAttribute attribute is not permitted on C# types"); } else { TypeBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } } public string GetAttributeDefaultMember() { return indexer_name ?? "Item"; } public void RegisterFieldForInitialization(MemberCore field, FieldInitializer expression) { if (IsPartialPart) { base.PartialContainer.RegisterFieldForInitialization(field, expression); } if ((field.ModFlags & Modifiers.STATIC) != 0) { if (initialized_static_fields == null) { HasStaticFieldInitializer = true; initialized_static_fields = new List(4); } initialized_static_fields.Add(expression); return; } if (Kind == MemberKind.Struct && Compiler.Settings.Version != LanguageVersion.Experimental) { base.Report.Error(573, expression.Location, "'{0}': Structs cannot have instance property or field initializers", GetSignatureForError()); } if (initialized_fields == null) { initialized_fields = new List(4); } initialized_fields.Add(expression); } public void ResolveFieldInitializers(BlockContext ec) { if (ec.IsStatic) { if (initialized_static_fields == null) { return; } bool flag = !ec.Module.Compiler.Settings.Optimize; ExpressionStatement[] array = new ExpressionStatement[initialized_static_fields.Count]; for (int i = 0; i < initialized_static_fields.Count; i++) { FieldInitializer fieldInitializer = initialized_static_fields[i]; ExpressionStatement expressionStatement = fieldInitializer.ResolveStatement(ec); if (expressionStatement == null) { expressionStatement = EmptyExpressionStatement.Instance; } else if (!fieldInitializer.IsSideEffectFree) { flag = true; } array[i] = expressionStatement; } for (int i = 0; i < initialized_static_fields.Count; i++) { FieldInitializer fieldInitializer2 = initialized_static_fields[i]; if (flag || !fieldInitializer2.IsDefaultInitializer) { ec.AssignmentInfoOffset += fieldInitializer2.AssignmentOffset; ec.CurrentBlock.AddScopeStatement(new StatementExpression(array[i])); } } } else { if (initialized_fields == null) { return; } for (int j = 0; j < initialized_fields.Count; j++) { FieldInitializer fieldInitializer3 = initialized_fields[j]; Expression expression = fieldInitializer3.Clone(new CloneContext()); ExpressionStatement expressionStatement2 = fieldInitializer3.ResolveStatement(ec); if (expressionStatement2 == null) { initialized_fields[j] = new FieldInitializer(fieldInitializer3.Field, ErrorExpression.Instance, Location.Null); } else if (!fieldInitializer3.IsDefaultInitializer || Kind == MemberKind.Struct || !ec.Module.Compiler.Settings.Optimize) { ec.AssignmentInfoOffset += fieldInitializer3.AssignmentOffset; ec.CurrentBlock.AddScopeStatement(new StatementExpression(expressionStatement2)); initialized_fields[j] = (FieldInitializer)expression; } } } } public TypeSpec GetAsyncMethodBuilder() { if (base.OptAttributes == null) { return null; } return base.OptAttributes.Search(Module.PredefinedAttributes.AsyncMethodBuilder)?.GetAsyncMethodBuilderValue(); } public TypeSpec GetAttributeCoClass() { if (base.OptAttributes == null) { return null; } return base.OptAttributes.Search(Module.PredefinedAttributes.CoClass)?.GetCoClassAttributeValue(); } public AttributeUsageAttribute GetAttributeUsage(PredefinedAttribute pa) { Attribute attribute = null; if (base.OptAttributes != null) { attribute = base.OptAttributes.Search(pa); } return attribute?.GetAttributeUsageAttribute(); } public virtual CompilationSourceFile GetCompilationSourceFile() { TypeContainer parent = Parent; CompilationSourceFile compilationSourceFile; while (true) { compilationSourceFile = parent as CompilationSourceFile; if (compilationSourceFile != null) { break; } parent = parent.Parent; } return compilationSourceFile; } public override string GetSignatureForMetadata() { if (Parent is TypeDefinition) { return Parent.GetSignatureForMetadata() + "+" + TypeNameParser.Escape(FilterNestedName(base.MemberName.Basename)); } return base.GetSignatureForMetadata(); } public virtual void SetBaseTypes(List baseTypes) { type_bases = baseTypes; } protected virtual TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { base_class = null; if (type_bases == null) { return null; } int count = type_bases.Count; TypeSpec[] array = null; BaseContext baseContext = new BaseContext(this); int i = 0; int num = 0; for (; i < count; i++) { FullNamedExpression fullNamedExpression = type_bases[i]; TypeSpec typeSpec = fullNamedExpression.ResolveAsType(baseContext); if (typeSpec == null) { continue; } if (i == 0 && Kind == MemberKind.Class && !typeSpec.IsInterface) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { base.Report.Error(1965, base.Location, "Class `{0}' cannot derive from the dynamic type", GetSignatureForError()); continue; } base_type = typeSpec; base_class = fullNamedExpression; continue; } if (array == null) { array = new TypeSpec[count - i]; } if (typeSpec.IsInterface) { for (int j = 0; j < num; j++) { if (typeSpec == array[j]) { base.Report.Error(528, base.Location, "`{0}' is already listed in interface list", typeSpec.GetSignatureForError()); break; } } if (Kind == MemberKind.Interface && !IsAccessibleAs(typeSpec)) { base.Report.Error(61, fullNamedExpression.Location, "Inconsistent accessibility: base interface `{0}' is less accessible than interface `{1}'", typeSpec.GetSignatureForError(), GetSignatureForError()); } } else { base.Report.SymbolRelatedToPreviousError(typeSpec); if (Kind != MemberKind.Class) { base.Report.Error(527, fullNamedExpression.Location, "Type `{0}' in interface list is not an interface", typeSpec.GetSignatureForError()); } else if (base_class != null) { base.Report.Error(1721, fullNamedExpression.Location, "`{0}': Classes cannot have multiple base classes (`{1}' and `{2}')", GetSignatureForError(), base_class.GetSignatureForError(), typeSpec.GetSignatureForError()); } else { base.Report.Error(1722, fullNamedExpression.Location, "`{0}': Base class `{1}' must be specified as first", GetSignatureForError(), typeSpec.GetSignatureForError()); } } array[num++] = typeSpec; } return array; } private void CheckPairedOperators() { bool flag = false; List list = new List(); for (int i = 0; i < members.Count; i++) { if (!(members[i] is Operator { OperatorType: var operatorType } obj)) { continue; } if (operatorType == Operator.OpType.Equality || operatorType == Operator.OpType.Inequality) { flag = true; } if (list.Contains(operatorType)) { continue; } Operator.OpType matchingOperator = obj.GetMatchingOperator(); if (matchingOperator == Operator.OpType.TOP) { continue; } bool flag2 = false; for (int j = 0; j < members.Count; j++) { if (members[j] is Operator obj2 && obj2.OperatorType == matchingOperator && TypeSpecComparer.IsEqual(obj.ReturnType, obj2.ReturnType) && TypeSpecComparer.Equals(obj.ParameterTypes, obj2.ParameterTypes)) { list.Add(matchingOperator); flag2 = true; break; } } if (!flag2) { base.Report.Error(216, obj.Location, "The operator `{0}' requires a matching operator `{1}' to also be defined", obj.GetSignatureForError(), Operator.GetName(matchingOperator)); } } if (flag) { if (!HasEquals) { base.Report.Warning(660, 2, base.Location, "`{0}' defines operator == or operator != but does not override Object.Equals(object o)", GetSignatureForError()); } if (!HasGetHashCode) { base.Report.Warning(661, 2, base.Location, "`{0}' defines operator == or operator != but does not override Object.GetHashCode()", GetSignatureForError()); } } } public override void CreateMetadataName(StringBuilder sb) { if (Parent.MemberName != null) { Parent.CreateMetadataName(sb); if (sb.Length != 0) { sb.Append("."); } } sb.Append(base.MemberName.Basename); } private bool CreateTypeBuilder() { int typeSize = ((Kind == MemberKind.Struct && !HasInstanceField && !(this is StateMachine)) ? 1 : 0); TypeDefinition typeDefinition = Parent as TypeDefinition; if (typeDefinition == null) { StringBuilder stringBuilder = new StringBuilder(); CreateMetadataName(stringBuilder); TypeBuilder = Module.CreateBuilder(stringBuilder.ToString(), TypeAttr, typeSize); } else { TypeBuilder = typeDefinition.TypeBuilder.DefineNestedType(FilterNestedName(base.MemberName.Basename), TypeAttr, null, typeSize); } if (DeclaringAssembly.Importer != null) { DeclaringAssembly.Importer.AddCompiledType(TypeBuilder, spec); } spec.SetMetaInfo(TypeBuilder); spec.MemberCache = new MemberCache(this); TypeParameters typeParameters = null; if (typeDefinition != null) { spec.DeclaringType = Parent.CurrentType; typeDefinition.MemberCache.AddMember(spec); typeParameters = typeDefinition.all_type_parameters; } if (base.MemberName.TypeParameters != null || typeParameters != null) { string[] names = CreateTypeParameters(typeParameters); all_tp_builders = TypeBuilder.DefineGenericParameters(names); if (CurrentTypeParameters != null) { CurrentTypeParameters.Create(spec, CurrentTypeParametersStartIndex, this); CurrentTypeParameters.Define(all_tp_builders); } } return true; } public static string FilterNestedName(string name) { return name.Replace('.', '_'); } private string[] CreateTypeParameters(TypeParameters parentAllTypeParameters) { int num = 0; string[] array; if (parentAllTypeParameters != null) { if (CurrentTypeParameters == null) { all_type_parameters = parentAllTypeParameters; return parentAllTypeParameters.GetAllNames(); } array = new string[parentAllTypeParameters.Count + CurrentTypeParameters.Count]; all_type_parameters = new TypeParameters(array.Length); all_type_parameters.Add(parentAllTypeParameters); num = all_type_parameters.Count; for (int i = 0; i < num; i++) { array[i] = all_type_parameters[i].MemberName.Name; } } else { array = new string[CurrentTypeParameters.Count]; } for (int j = 0; j < CurrentTypeParameters.Count; j++) { if (all_type_parameters != null) { all_type_parameters.Add(base.MemberName.TypeParameters[j]); } string text = (array[num + j] = CurrentTypeParameters[j].MemberName.Name); for (int k = 0; k < num + j; k++) { if (!(array[k] != text)) { TypeParameter typeParameter = CurrentTypeParameters[j]; TypeParameter conflict = all_type_parameters[k]; typeParameter.WarningParentNameConflict(conflict); } } } if (all_type_parameters == null) { all_type_parameters = CurrentTypeParameters; } return array; } public SourceMethodBuilder CreateMethodSymbolEntry() { if (Module.DeclaringAssembly.SymbolWriter == null || (base.ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) { return null; } CompilationSourceFile compilationSourceFile = GetCompilationSourceFile(); if (compilationSourceFile == null) { return null; } return new SourceMethodBuilder(compilationSourceFile.SymbolUnitEntry); } public MethodSpec CreateHoistedBaseCallProxy(ResolveContext rc, MethodSpec method) { Method value; if (hoisted_base_call_proxies == null) { hoisted_base_call_proxies = new Dictionary(); value = null; } else { hoisted_base_call_proxies.TryGetValue(method, out value); } if (value == null) { string name = CompilerGeneratedContainer.MakeName(method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count); TypeArguments typeArguments = null; TypeSpec typeSpec = method.ReturnType; TypeSpec[] array = method.Parameters.Types; MemberName name3; if (method.IsGeneric) { TypeParameterSpec[] typeParameters = method.GenericDefinition.TypeParameters; TypeParameters typeParameters2 = new TypeParameters(); typeArguments = new TypeArguments(); typeArguments.Arguments = new TypeSpec[typeParameters.Length]; for (int i = 0; i < typeParameters.Length; i++) { TypeParameterSpec typeParameterSpec = typeParameters[i]; string name2 = typeParameterSpec.Name; TypeParameter typeParameter = new TypeParameter(typeParameterSpec, null, new MemberName(name2, base.Location), null); typeParameters2.Add(typeParameter); typeArguments.Add(new SimpleName(typeParameterSpec.Name, base.Location)); typeArguments.Arguments[i] = typeParameter.Type; } name3 = new MemberName(name, typeParameters2, base.Location); TypeParameterMutator typeParameterMutator = new TypeParameterMutator(typeParameters, typeParameters2); typeSpec = typeParameterMutator.Mutate(typeSpec); array = typeParameterMutator.Mutate(array); TypeParameterInflator inflator = new TypeParameterInflator(this, null, typeParameters, typeArguments.Arguments); for (int j = 0; j < typeParameters.Length; j++) { TypeParameterSpec typeParameterSpec2 = (TypeParameterSpec)typeArguments.Arguments[j]; typeParameterSpec2.InflateConstraints(inflator, typeParameterSpec2); } } else { name3 = new MemberName(name); } Parameter[] array2 = new Parameter[method.Parameters.Count]; for (int k = 0; k < array2.Length; k++) { IParameterData parameterData = method.Parameters.FixedParameters[k]; array2[k] = new Parameter(new TypeExpression(array[k], base.Location), parameterData.Name, parameterData.ModFlags, null, base.Location); array2[k].Resolve(this, k); } ParametersCompiled parametersCompiled = ParametersCompiled.CreateFullyResolved(array2, array); if (method.Parameters.HasArglist) { parametersCompiled.FixedParameters[0] = new Parameter(null, "__arglist", Parameter.Modifier.NONE, null, base.Location); parametersCompiled.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve(); } value = new Method(this, new TypeExpression(typeSpec, base.Location), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN, name3, parametersCompiled, null); ToplevelBlock toplevelBlock = new ToplevelBlock(Compiler, value.ParameterInfo, base.Location) { IsCompilerGenerated = true }; MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(method, method.DeclaringType, base.Location); methodGroupExpr.InstanceExpression = new BaseThis(method.DeclaringType, base.Location); if (typeArguments != null) { methodGroupExpr.SetTypeArguments(rc, typeArguments); } Invocation expr = new Invocation(methodGroupExpr, toplevelBlock.GetAllParametersArguments()); Statement s = ((method.ReturnType.Kind != MemberKind.Void) ? ((Statement)new Return(expr, base.Location)) : ((Statement)new StatementExpression(expr))); toplevelBlock.AddStatement(s); value.Block = toplevelBlock; members.Add(value); value.Define(); value.PrepareEmit(); hoisted_base_call_proxies.Add(method, value); } return value.Spec; } protected bool DefineBaseTypes() { if (IsPartialPart && Kind == MemberKind.Class) { return true; } return DoDefineBaseType(); } private bool DoDefineBaseType() { iface_exprs = ResolveBaseTypes(out base_type_expr); bool flag; if (IsPartialPart) { flag = false; if (base_type_expr != null) { if (base.PartialContainer.base_type_expr != null && base.PartialContainer.base_type != base_type) { base.Report.SymbolRelatedToPreviousError(base_type_expr.Location, ""); base.Report.Error(263, base.Location, "Partial declarations of `{0}' must not specify different base classes", GetSignatureForError()); } else { base.PartialContainer.base_type_expr = base_type_expr; base.PartialContainer.base_type = base_type; flag = true; } } if (iface_exprs != null) { if (base.PartialContainer.iface_exprs == null) { base.PartialContainer.iface_exprs = iface_exprs; } else { List list = new List(base.PartialContainer.iface_exprs); TypeSpec[] array = iface_exprs; foreach (TypeSpec item in array) { if (!list.Contains(item)) { list.Add(item); } } base.PartialContainer.iface_exprs = list.ToArray(); } } base.PartialContainer.members.AddRange(members); if (containers != null) { if (base.PartialContainer.containers == null) { base.PartialContainer.containers = new List(); } base.PartialContainer.containers.AddRange(containers); } if (PrimaryConstructorParameters != null) { if (base.PartialContainer.PrimaryConstructorParameters != null) { base.Report.Error(8036, base.Location, "Only one part of a partial type can declare primary constructor parameters"); } else { base.PartialContainer.PrimaryConstructorParameters = PrimaryConstructorParameters; } } members_defined = (members_defined_ok = true); caching_flags |= Flags.CloseTypeCreated; } else { flag = true; } TypeSpec typeSpec = CheckRecursiveDefinition(this); if (typeSpec != null) { base.Report.SymbolRelatedToPreviousError(typeSpec); if (this is Interface) { base.Report.Error(529, base.Location, "Inherited interface `{0}' causes a cycle in the interface hierarchy of `{1}'", GetSignatureForError(), typeSpec.GetSignatureForError()); iface_exprs = null; base.PartialContainer.iface_exprs = null; } else { base.Report.Error(146, base.Location, "Circular base class dependency involving `{0}' and `{1}'", GetSignatureForError(), typeSpec.GetSignatureForError()); base_type = null; base.PartialContainer.base_type = null; } } if (iface_exprs != null) { if (!PrimaryConstructorBaseArgumentsStart.IsNull) { base.Report.Error(8049, PrimaryConstructorBaseArgumentsStart, "Implemented interfaces cannot have arguments"); } TypeSpec[] array2 = iface_exprs; foreach (TypeSpec typeSpec2 in array2) { if (typeSpec2 != null && spec.AddInterfaceDefined(typeSpec2)) { TypeBuilder.AddInterfaceImplementation(typeSpec2.GetMetaInfo()); } } } if (Kind == MemberKind.Interface) { spec.BaseType = Compiler.BuiltinTypes.Object; return true; } if (flag) { SetBaseType(); } if (class_partial_parts != null) { foreach (TypeDefinition class_partial_part in class_partial_parts) { if (class_partial_part.PrimaryConstructorBaseArguments != null) { PrimaryConstructorBaseArguments = class_partial_part.PrimaryConstructorBaseArguments; } class_partial_part.DoDefineBaseType(); } } return true; } private void SetBaseType() { if (base_type == null) { TypeBuilder.SetParent(null); } else if (spec.BaseType != base_type) { spec.BaseType = base_type; if (IsPartialPart) { spec.UpdateInflatedInstancesBaseType(); } TypeBuilder.SetParent(base_type.GetMetaInfo()); } } public override void ExpandBaseInterfaces() { DoResolveTypeParameters(); if (!IsPartialPart) { DoExpandBaseInterfaces(); } base.ExpandBaseInterfaces(); } public void DoExpandBaseInterfaces() { if ((caching_flags & Flags.InterfacesExpanded) != 0) { return; } caching_flags |= Flags.InterfacesExpanded; if (iface_exprs != null) { TypeSpec[] array = iface_exprs; foreach (TypeSpec typeSpec in array) { if (typeSpec == null) { continue; } if (typeSpec.MemberDefinition is TypeDefinition typeDefinition) { typeDefinition.DoExpandBaseInterfaces(); } if (typeSpec.Interfaces == null) { continue; } foreach (TypeSpec @interface in typeSpec.Interfaces) { if (spec.AddInterfaceDefined(@interface)) { TypeBuilder.AddInterfaceImplementation(@interface.GetMetaInfo()); } } } } if (base_type == null) { return; } if (base_type.MemberDefinition is TypeDefinition typeDefinition2) { typeDefinition2.DoExpandBaseInterfaces(); } if (base_type.Interfaces == null) { return; } foreach (TypeSpec interface2 in base_type.Interfaces) { spec.AddInterfaceDefined(interface2); } } public override void PrepareEmit() { if ((caching_flags & Flags.CloseTypeCreated) != 0) { return; } foreach (MemberCore member in members) { if (member is MemberBase memberBase) { memberBase.PrepareEmit(); } } base.PrepareEmit(); } public override bool CreateContainer() { if ((object)TypeBuilder != null) { return !error; } if (error) { return false; } if (IsPartialPart) { spec = base.PartialContainer.spec; TypeBuilder = base.PartialContainer.TypeBuilder; all_tp_builders = base.PartialContainer.all_tp_builders; all_type_parameters = base.PartialContainer.all_type_parameters; } else if (!CreateTypeBuilder()) { error = true; return false; } return base.CreateContainer(); } protected override void DoDefineContainer() { DefineBaseTypes(); } public void SetPredefinedSpec(BuiltinTypeSpec spec) { spec.SetMetaInfo(TypeBuilder); spec.MemberCache = this.spec.MemberCache; spec.DeclaringType = this.spec.DeclaringType; this.spec = spec; current_type = null; if (class_partial_parts == null) { return; } foreach (TypeDefinition class_partial_part in class_partial_parts) { class_partial_part.spec = spec; class_partial_part.current_type = null; } } public override void RemoveContainer(TypeContainer cont) { base.RemoveContainer(cont); Members.Remove(cont); Cache.Remove(cont.MemberName.Basename); } protected virtual bool DoResolveTypeParameters() { TypeParameters typeParameters = base.MemberName.TypeParameters; if (typeParameters == null) { return true; } BaseContext baseContext = new BaseContext(this); for (int i = 0; i < typeParameters.Count; i++) { TypeParameter typeParameter = typeParameters[i]; if (!typeParameter.ResolveConstraints(baseContext)) { error = true; return false; } if (!IsPartialPart) { continue; } TypeParameter typeParameter2 = base.PartialContainer.CurrentTypeParameters[i]; typeParameter.Create(spec, this); typeParameter.Define(typeParameter2); if (typeParameter.OptAttributes != null) { if (typeParameter2.OptAttributes == null) { typeParameter2.OptAttributes = typeParameter.OptAttributes; } else { typeParameter2.OptAttributes.Attrs.AddRange(typeParameter.OptAttributes.Attrs); } } } if (IsPartialPart) { base.PartialContainer.CurrentTypeParameters.UpdateConstraints(this); } return true; } private TypeSpec CheckRecursiveDefinition(TypeDefinition tc) { if (InTransit != null) { return spec; } InTransit = tc; if (base_type != null && base_type.MemberDefinition is TypeDefinition typeDefinition && typeDefinition.CheckRecursiveDefinition(this) != null) { return base_type; } if (iface_exprs != null && this is Interface) { TypeSpec[] array = iface_exprs; foreach (TypeSpec typeSpec in array) { if (typeSpec != null && typeSpec.MemberDefinition is Interface obj && obj.CheckRecursiveDefinition(this) != null) { return typeSpec; } } } if (!IsTopLevel && Parent.PartialContainer.CheckRecursiveDefinition(this) != null) { return spec; } InTransit = null; return null; } public sealed override bool Define() { if (members_defined) { return members_defined_ok; } members_defined_ok = DoDefineMembers(); members_defined = true; base.Define(); return members_defined_ok; } protected virtual bool DoDefineMembers() { if (iface_exprs != null) { TypeSpec[] array = iface_exprs; foreach (TypeSpec typeSpec in array) { if (typeSpec == null) { continue; } if (typeSpec.MemberDefinition is Interface obj) { obj.Define(); } typeSpec.CheckObsoleteness(this, base.Location); if (typeSpec.Arity > 0) { VarianceDecl.CheckTypeVariance(typeSpec, Variance.Covariant, this); if (((InflatedTypeSpec)typeSpec).HasDynamicArgument() && !base.IsCompilerGenerated) { base.Report.Error(1966, base.Location, "`{0}': cannot implement a dynamic interface `{1}'", GetSignatureForError(), typeSpec.GetSignatureForError()); return false; } } if (!typeSpec.IsGenericOrParentIsGeneric) { continue; } TypeSpec[] array2 = iface_exprs; foreach (TypeSpec typeSpec2 in array2) { if (typeSpec2 == typeSpec || typeSpec2 == null) { break; } if (TypeSpecComparer.Unify.IsEqual(typeSpec, typeSpec2)) { base.Report.Error(695, base.Location, "`{0}' cannot implement both `{1}' and `{2}' because they may unify for some type parameter substitutions", GetSignatureForError(), typeSpec2.GetSignatureForError(), typeSpec.GetSignatureForError()); } } } if (Kind == MemberKind.Interface) { foreach (TypeSpec @interface in spec.Interfaces) { MemberCache.AddInterface(@interface); } } } if (base_type != null) { if (base_type_expr != null) { base_type.CheckObsoleteness(this, base_type_expr.Location); if (IsGenericOrParentIsGeneric && base_type.IsAttribute) { base.Report.Error(698, base_type_expr.Location, "A generic type cannot derive from `{0}' because it is an attribute class", base_type.GetSignatureForError()); } } if (base_type.MemberDefinition is ClassOrStruct classOrStruct) { classOrStruct.Define(); if (HasMembersDefined) { return true; } } } if (Kind == MemberKind.Struct || Kind == MemberKind.Class) { pending = PendingImplementation.GetPendingImplementations(this); } int count = members.Count; for (int k = 0; k < count; k++) { if (members[k] is InterfaceMemberBase { IsExplicitImpl: not false } interfaceMemberBase) { try { interfaceMemberBase.Define(); } catch (Exception e) { throw new InternalErrorException(interfaceMemberBase, e); } } } for (int l = 0; l < count; l++) { if (!(members[l] is InterfaceMemberBase { IsExplicitImpl: not false }) && !(members[l] is TypeContainer)) { try { members[l].Define(); } catch (Exception e2) { throw new InternalErrorException(members[l], e2); } } } if (HasOperators) { CheckPairedOperators(); } ComputeIndexerName(); if (HasEquals && !HasGetHashCode) { base.Report.Warning(659, 3, base.Location, "`{0}' overrides Object.Equals(object) but does not override Object.GetHashCode()", GetSignatureForError()); } if (Kind == MemberKind.Interface && iface_exprs != null) { MemberCache.RemoveHiddenMembers(spec); } return true; } private void ComputeIndexerName() { IList list = MemberCache.FindMembers(spec, MemberCache.IndexerNameAlias, declaredOnlyClass: true); if (list == null) { return; } string text = null; foreach (MemberSpec item in list) { if (item.DeclaringType == spec) { has_normal_indexers = true; if (text == null) { text = (indexer_name = item.Name); } else if (item.Name != text) { base.Report.Error(668, ((Indexer)item.MemberDefinition).Location, "Two indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type"); } } } } private void EmitIndexerName() { if (has_normal_indexers) { MethodSpec methodSpec = Module.PredefinedMembers.DefaultMemberAttributeCtor.Get(); if (methodSpec != null) { AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.Encode(GetAttributeDefaultMember()); attributeEncoder.EncodeEmptyNamedArguments(); TypeBuilder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences)); Module.AddAssemblyReferences(assemblyReferences); } } } public override void VerifyMembers() { if (!base.IsCompilerGenerated && Compiler.Settings.WarningLevel >= 3 && this == base.PartialContainer) { bool flag = Kind == MemberKind.Struct || IsExposedFromAssembly(); foreach (MemberCore member in members) { if (member is Event) { if (!member.IsUsed && !base.PartialContainer.HasStructLayout) { base.Report.Warning(67, 3, member.Location, "The event `{0}' is never used", member.GetSignatureForError()); } continue; } if ((member.ModFlags & Modifiers.AccessibilityMask) != Modifiers.PRIVATE) { if (flag) { continue; } member.SetIsUsed(); } if (!(member is Field field)) { continue; } if (!member.IsUsed) { if (!base.PartialContainer.HasStructLayout) { if ((member.caching_flags & Flags.IsAssigned) == 0) { base.Report.Warning(169, 3, member.Location, "The private field `{0}' is never used", member.GetSignatureForError()); } else { base.Report.Warning(414, 3, member.Location, "The private field `{0}' is assigned but its value is never used", member.GetSignatureForError()); } } } else if ((field.caching_flags & Flags.IsAssigned) == 0 && Compiler.Settings.WarningLevel >= 4 && field.OptAttributes == null && !base.PartialContainer.HasStructLayout) { Constant constant = New.Constantify(field.MemberType, field.Location); string text = ((constant != null) ? constant.GetValueAsLiteral() : ((!TypeSpec.IsReferenceType(field.MemberType)) ? null : "null")); if (text != null) { text = " `" + text + "'"; } base.Report.Warning(649, 4, field.Location, "Field `{0}' is never assigned to, and will always have its default value{1}", field.GetSignatureForError(), text); } } } base.VerifyMembers(); } public override void Emit() { if (Interfaces != null && (base.ModFlags & Modifiers.PRIVATE) == 0) { TypeSpec[] interfaces = Interfaces; foreach (TypeSpec typeSpec in interfaces) { if (typeSpec.HasNamedTupleElement) { throw new NotImplementedException("named tuples for .interfaceimpl"); } } } if (base.OptAttributes != null) { base.OptAttributes.Emit(); } if (!base.IsCompilerGenerated) { if (!IsTopLevel) { bool overrides = false; MemberSpec bestCandidate; MemberSpec memberSpec = MemberCache.FindBaseMember(this, out bestCandidate, ref overrides); if (memberSpec == null && bestCandidate == null) { if ((base.ModFlags & Modifiers.NEW) != 0) { base.Report.Warning(109, 4, base.Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError()); } } else if ((base.ModFlags & Modifiers.NEW) == 0) { if (bestCandidate == null) { bestCandidate = memberSpec; } base.Report.SymbolRelatedToPreviousError(bestCandidate); base.Report.Warning(108, 2, base.Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended", GetSignatureForError(), bestCandidate.GetSignatureForError()); } } if (base_type != null && base_type_expr != null) { ConstraintChecker.Check(this, base_type, base_type_expr.Location); } if (iface_exprs != null) { TypeSpec[] array = iface_exprs; foreach (TypeSpec typeSpec2 in array) { if (typeSpec2 != null) { ConstraintChecker.Check(this, typeSpec2, base.Location); } } } } if (all_tp_builders != null) { int currentTypeParametersStartIndex = CurrentTypeParametersStartIndex; for (int k = 0; k < all_tp_builders.Length; k++) { if (k < currentTypeParametersStartIndex) { all_type_parameters[k].EmitConstraints(all_tp_builders[k]); continue; } TypeParameter typeParameter = CurrentTypeParameters[k - currentTypeParametersStartIndex]; typeParameter.CheckGenericConstraints(!base.IsObsolete); typeParameter.Emit(); } } if ((base.ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) { Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(TypeBuilder); } base.Emit(); for (int l = 0; l < members.Count; l++) { MemberCore memberCore = members[l]; if ((memberCore.caching_flags & Flags.CloseTypeCreated) == 0) { memberCore.Emit(); } } EmitIndexerName(); CheckAttributeClsCompliance(); if (pending != null) { pending.VerifyPendingMethods(); } } private void CheckAttributeClsCompliance() { if (!spec.IsAttribute || !IsExposedFromAssembly() || !Compiler.Settings.VerifyClsCompliance || !IsClsComplianceRequired()) { return; } foreach (MemberCore member in members) { if (!(member is Constructor { HasCompliantArgs: not false })) { continue; } return; } base.Report.Warning(3015, 1, base.Location, "`{0}' has no accessible constructors which use only CLS-compliant types", GetSignatureForError()); } public sealed override void EmitContainer() { if ((caching_flags & Flags.CloseTypeCreated) == 0) { Emit(); } } public override void CloseContainer() { if ((caching_flags & Flags.CloseTypeCreated) != 0) { return; } if (spec.BaseType != null && spec.BaseType.MemberDefinition is TypeContainer typeContainer) { typeContainer.CloseContainer(); if ((caching_flags & Flags.CloseTypeCreated) != 0) { return; } } try { caching_flags |= Flags.CloseTypeCreated; TypeBuilder.CreateType(); } catch (TypeLoadException) { } catch (Exception e) { throw new InternalErrorException(this, e); } base.CloseContainer(); containers = null; initialized_fields = null; initialized_static_fields = null; type_bases = null; base.OptAttributes = null; } public bool MethodModifiersValid(MemberCore mc) { bool result = true; Modifiers modFlags = mc.ModFlags; if ((modFlags & Modifiers.STATIC) != 0 && (modFlags & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0) { base.Report.Error(112, mc.Location, "A static member `{0}' cannot be marked as override, virtual or abstract", mc.GetSignatureForError()); result = false; } if ((modFlags & Modifiers.OVERRIDE) != 0 && (modFlags & (Modifiers.NEW | Modifiers.VIRTUAL)) != 0) { base.Report.Error(113, mc.Location, "A member `{0}' marked as override cannot be marked as new or virtual", mc.GetSignatureForError()); result = false; } if ((modFlags & Modifiers.ABSTRACT) != 0) { if ((modFlags & Modifiers.EXTERN) != 0) { base.Report.Error(180, mc.Location, "`{0}' cannot be both extern and abstract", mc.GetSignatureForError()); result = false; } if ((modFlags & Modifiers.SEALED) != 0) { base.Report.Error(502, mc.Location, "`{0}' cannot be both abstract and sealed", mc.GetSignatureForError()); result = false; } if ((modFlags & Modifiers.VIRTUAL) != 0) { base.Report.Error(503, mc.Location, "The abstract method `{0}' cannot be marked virtual", mc.GetSignatureForError()); result = false; } if ((base.ModFlags & Modifiers.ABSTRACT) == 0) { base.Report.SymbolRelatedToPreviousError(this); base.Report.Error(513, mc.Location, "`{0}' is abstract but it is declared in the non-abstract class `{1}'", mc.GetSignatureForError(), GetSignatureForError()); result = false; } } if ((modFlags & Modifiers.PRIVATE) != 0 && (modFlags & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0) { base.Report.Error(621, mc.Location, "`{0}': virtual or abstract members cannot be private", mc.GetSignatureForError()); result = false; } if ((modFlags & Modifiers.SEALED) != 0 && (modFlags & Modifiers.OVERRIDE) == 0) { base.Report.Error(238, mc.Location, "`{0}' cannot be sealed because it is not an override", mc.GetSignatureForError()); result = false; } return result; } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } if (Kind != MemberKind.Delegate) { MemberCache.VerifyClsCompliance(Definition, base.Report); } if (BaseType != null && !BaseType.IsCLSCompliant()) { base.Report.Warning(3009, 1, base.Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError(), BaseType.GetSignatureForError()); } return true; } public bool VerifyImplements(InterfaceMemberBase mb) { TypeSpec[] interfaces = base.PartialContainer.Interfaces; if (interfaces != null) { TypeSpec[] array = interfaces; foreach (TypeSpec typeSpec in array) { if (typeSpec == mb.InterfaceType || typeSpec == null) { return true; } IList interfaces2 = typeSpec.Interfaces; if (interfaces2 == null) { continue; } foreach (TypeSpec item in interfaces2) { if (item == mb.InterfaceType) { return true; } } } } base.Report.SymbolRelatedToPreviousError(mb.InterfaceType); base.Report.Error(540, mb.Location, "`{0}': containing type does not implement interface `{1}'", mb.GetSignatureForError(), mb.InterfaceType.GetSignatureForError()); return false; } public bool IsBaseTypeDefinition(TypeSpec baseType) { if ((object)TypeBuilder == null) { return false; } TypeSpec baseType2 = spec; do { if (baseType2.MemberDefinition == baseType.MemberDefinition) { return true; } baseType2 = baseType2.BaseType; } while (baseType2 != null); return false; } public override bool IsClsComplianceRequired() { if (IsPartialPart) { return base.PartialContainer.IsClsComplianceRequired(); } return base.IsClsComplianceRequired(); } bool ITypeDefinition.IsInternalAsPublic(IAssemblyDefinition assembly) { return Module.DeclaringAssembly == assembly; } public virtual bool IsUnmanagedType() { return false; } public void LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { throw new NotSupportedException("Not supported for compiled definition " + GetSignatureForError()); } public override FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { if (arity == 0 && Cache.TryGetValue(name, out var value) && mode != LookupMode.IgnoreAccessibility) { return value; } value = null; if (arity == 0) { TypeParameters currentTypeParameters = CurrentTypeParameters; if (currentTypeParameters != null) { TypeParameter typeParameter = currentTypeParameters.Find(name); if (typeParameter != null) { value = new TypeParameterExpr(typeParameter, Location.Null); } } } if (value == null) { TypeSpec typeSpec = LookupNestedTypeInHierarchy(name, arity); if (typeSpec != null && (typeSpec.IsAccessible(this) || mode == LookupMode.IgnoreAccessibility)) { value = new TypeExpression(typeSpec, Location.Null); } else { int errors = Compiler.Report.Errors; value = Parent.LookupNamespaceOrType(name, arity, mode, loc); if (errors != Compiler.Report.Errors) { return value; } } } if (arity == 0 && mode == LookupMode.Normal) { Cache[name] = value; } return value; } private TypeSpec LookupNestedTypeInHierarchy(string name, int arity) { TypeSpec currentType = base.PartialContainer.CurrentType; return MemberCache.FindNestedType(currentType, name, arity, declaredOnlyClass: false); } public void Mark_HasEquals() { cached_method |= CachedMethods.Equals; } public void Mark_HasGetHashCode() { cached_method |= CachedMethods.GetHashCode; } public override void WriteDebugSymbol(MonoSymbolFile file) { if (IsPartialPart) { return; } foreach (MemberCore member in members) { member.WriteDebugSymbol(file); } } } internal abstract class ClassOrStruct : TypeDefinition { public const TypeAttributes StaticClassAttribute = TypeAttributes.Abstract | TypeAttributes.Sealed; private Dictionary declarative_security; protected Constructor generated_primary_constructor; public ToplevelBlock PrimaryConstructorBlock { get; set; } protected override TypeAttributes TypeAttr { get { TypeAttributes typeAttributes = base.TypeAttr; if (!has_static_constructor) { typeAttributes |= TypeAttributes.BeforeFieldInit; } if (Kind == MemberKind.Class) { typeAttributes |= TypeAttributes.NotPublic; if (base.IsStatic) { typeAttributes |= TypeAttributes.Abstract | TypeAttributes.Sealed; } } else { typeAttributes |= TypeAttributes.SequentialLayout; } return typeAttributes; } } protected ClassOrStruct(TypeContainer parent, MemberName name, Attributes attrs, MemberKind kind) : base(parent, name, attrs, kind) { } public override void AddNameToContainer(MemberCore symbol, string name) { if (!(symbol is Constructor) && symbol.MemberName.Name == base.MemberName.Name) { if (symbol is TypeParameter) { base.Report.Error(694, symbol.Location, "Type parameter `{0}' has same name as containing type, or method", symbol.GetSignatureForError()); return; } if (!(symbol is InterfaceMemberBase { IsExplicitImpl: not false })) { base.Report.SymbolRelatedToPreviousError(this); base.Report.Error(542, symbol.Location, "`{0}': member names cannot be the same as their enclosing type", symbol.GetSignatureForError()); return; } } base.AddNameToContainer(symbol, name); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.IsValidSecurityAttribute()) { a.ExtractSecurityPermissionSet(ctor, ref declarative_security); return; } if (a.Type == pa.StructLayout) { base.PartialContainer.HasStructLayout = true; if (a.IsExplicitLayoutKind()) { base.PartialContainer.HasExplicitLayout = true; } } if (a.Type == pa.Dynamic) { a.Error_MisusedDynamicAttribute(); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } protected virtual Constructor DefineDefaultConstructor(bool is_static) { ParametersCompiled parametersCompiled = null; Modifiers mod; if (is_static) { mod = Modifiers.PRIVATE | Modifiers.STATIC; parametersCompiled = ParametersCompiled.EmptyReadOnlyParameters; } else { mod = (((base.ModFlags & Modifiers.ABSTRACT) != 0) ? Modifiers.PROTECTED : Modifiers.PUBLIC); parametersCompiled = base.PrimaryConstructorParameters ?? ParametersCompiled.EmptyReadOnlyParameters; } Constructor constructor = new Constructor(this, base.MemberName.Name, mod, null, parametersCompiled, base.Location); if (Kind == MemberKind.Class) { constructor.Initializer = new GeneratedBaseInitializer(base.Location, base.PrimaryConstructorBaseArguments); } if (base.PrimaryConstructorParameters != null && !is_static) { constructor.IsPrimaryConstructor = true; constructor.caching_flags |= Flags.MethodOverloadsExist; } AddConstructor(constructor, isDefault: true); if (PrimaryConstructorBlock == null) { constructor.Block = new ToplevelBlock(Compiler, parametersCompiled, base.Location) { IsCompilerGenerated = true }; } else { constructor.Block = PrimaryConstructorBlock; } return constructor; } protected override bool DoDefineMembers() { CheckProtectedModifier(); if (base.PrimaryConstructorParameters != null) { IParameterData[] fixedParameters = base.PrimaryConstructorParameters.FixedParameters; for (int i = 0; i < fixedParameters.Length; i++) { Parameter parameter = (Parameter)fixedParameters[i]; if (parameter.Name == base.MemberName.Name) { base.Report.Error(8039, parameter.Location, "Primary constructor of type `{0}' has parameter of same name as containing type", GetSignatureForError()); } if (CurrentTypeParameters == null) { continue; } for (int j = 0; j < CurrentTypeParameters.Count; j++) { TypeParameter typeParameter = CurrentTypeParameters[j]; if (parameter.Name == typeParameter.Name) { base.Report.Error(8038, parameter.Location, "Primary constructor of type `{0}' has parameter of same name as type parameter `{1}'", GetSignatureForError(), parameter.GetSignatureForError()); } } } } base.DoDefineMembers(); return true; } public override void PrepareEmit() { if (!(this is Struct { HasUnmanagedCheckDone: not false })) { for (int i = 0; i < base.Members.Count; i++) { if (base.Members[i] is Field { MemberType: not null } field && field.MemberType.IsPointer) { TypeManager.VerifyUnmanaged(Module, field.MemberType, field.Location); } } } base.PrepareEmit(); } public override void Emit() { if (!has_static_constructor && base.HasStaticFieldInitializer) { Constructor constructor = DefineDefaultConstructor(is_static: true); constructor.Define(); } base.Emit(); } } internal sealed class Class : ClassOrStruct { private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.UNSAFE; public override AttributeTargets AttributeTargets => AttributeTargets.Class; public Class(TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base(parent, name, attrs, MemberKind.Class) { base.ModFlags = ModifiersExtensions.Check(Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.UNSAFE, mod, base.IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, base.Location, base.Report); spec = new TypeSpec(Kind, null, this, null, base.ModFlags); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void SetBaseTypes(List baseTypes) { MemberName memberName = base.MemberName; if (memberName.Name == "Object" && !memberName.IsGeneric && Parent.MemberName.Name == "System" && Parent.MemberName.Left == null) { base.Report.Error(537, base.Location, "The class System.Object cannot have a base class or implement an interface."); } base.SetBaseTypes(baseTypes); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.AttributeUsage && !base.BaseType.IsAttribute && spec.BuiltinType != BuiltinTypeSpec.Type.Attribute) { base.Report.Error(641, a.Location, "Attribute `{0}' is only valid on classes derived from System.Attribute", a.GetSignatureForError()); } if (a.Type == pa.Conditional && !base.BaseType.IsAttribute) { base.Report.Error(1689, a.Location, "Attribute `System.Diagnostics.ConditionalAttribute' is only valid on methods or attribute classes"); } else if (a.Type == pa.ComImport && !attributes.Contains(pa.Guid)) { a.Error_MissingGuidAttribute(); } else if (a.Type == pa.Extension) { a.Error_MisusedExtensionAttribute(); } else if (!a.Type.IsConditionallyExcluded(this)) { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } protected override bool DoDefineMembers() { if ((base.ModFlags & Modifiers.ABSTRACT) == Modifiers.ABSTRACT && (base.ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) != 0) { base.Report.Error(418, base.Location, "`{0}': an abstract class cannot be sealed or static", GetSignatureForError()); } if ((base.ModFlags & (Modifiers.SEALED | Modifiers.STATIC)) == (Modifiers.SEALED | Modifiers.STATIC)) { base.Report.Error(441, base.Location, "`{0}': a class cannot be both static and sealed", GetSignatureForError()); } if (base.IsStatic) { if (base.PrimaryConstructorParameters != null) { base.Report.Error(-800, base.Location, "`{0}': Static classes cannot have primary constructor", GetSignatureForError()); base.PrimaryConstructorParameters = null; } foreach (MemberCore member in base.Members) { if (member is Operator) { base.Report.Error(715, member.Location, "`{0}': Static classes cannot contain user-defined operators", member.GetSignatureForError()); } else if (member is Destructor) { base.Report.Error(711, member.Location, "`{0}': Static classes cannot contain destructor", GetSignatureForError()); } else if (member is Indexer) { base.Report.Error(720, member.Location, "`{0}': cannot declare indexers in a static class", member.GetSignatureForError()); } else if ((member.ModFlags & Modifiers.STATIC) == 0 && !(member is TypeContainer)) { if (member is Constructor) { base.Report.Error(710, member.Location, "`{0}': Static classes cannot have instance constructors", GetSignatureForError()); } else { base.Report.Error(708, member.Location, "`{0}': cannot declare instance members in a static class", member.GetSignatureForError()); } } } } else if (!base.PartialContainer.HasInstanceConstructor || base.PrimaryConstructorParameters != null) { generated_primary_constructor = DefineDefaultConstructor(is_static: false); } return base.DoDefineMembers(); } public override void Emit() { base.Emit(); if ((base.ModFlags & Modifiers.METHOD_EXTENSION) != 0) { Module.PredefinedAttributes.Extension.EmitAttribute(TypeBuilder); } if (base_type != null) { if (base_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(TypeBuilder, base_type, base.Location); } if (base_type.HasNamedTupleElement) { Module.PredefinedAttributes.TupleElementNames.EmitAttribute(TypeBuilder, base_type, base.Location); } } } public override void GetCompletionStartingWith(string prefix, List results) { base.GetCompletionStartingWith(prefix, results); for (TypeSpec baseType = base_type; baseType != null; baseType = baseType.BaseType) { results.AddRange(from l in MemberCache.GetCompletitionMembers(this, baseType, prefix) where l.IsStatic select l.Name); } } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { TypeSpec[] array = base.ResolveBaseTypes(out base_class); if (base_class == null) { if (spec.BuiltinType != BuiltinTypeSpec.Type.Object) { base_type = Compiler.BuiltinTypes.Object; } } else { if (base_type.IsGenericParameter) { base.Report.Error(689, base_class.Location, "`{0}': Cannot derive from type parameter `{1}'", GetSignatureForError(), base_type.GetSignatureForError()); } else if (base_type.IsStatic) { base.Report.SymbolRelatedToPreviousError(base_type); base.Report.Error(709, base.Location, "`{0}': Cannot derive from static class `{1}'", GetSignatureForError(), base_type.GetSignatureForError()); } else if (base_type.IsSealed) { base.Report.SymbolRelatedToPreviousError(base_type); base.Report.Error(509, base.Location, "`{0}': cannot derive from sealed type `{1}'", GetSignatureForError(), base_type.GetSignatureForError()); } else if (base.PartialContainer.IsStatic && base_type.BuiltinType != BuiltinTypeSpec.Type.Object) { base.Report.Error(713, base.Location, "Static class `{0}' cannot derive from type `{1}'. Static classes must derive from object", GetSignatureForError(), base_type.GetSignatureForError()); } BuiltinTypeSpec.Type builtinType = base_type.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 20) <= 4u && !(spec is BuiltinTypeSpec)) { base.Report.Error(644, base.Location, "`{0}' cannot derive from special class `{1}'", GetSignatureForError(), base_type.GetSignatureForError()); base_type = Compiler.BuiltinTypes.Object; } if (!IsAccessibleAs(base_type)) { base.Report.SymbolRelatedToPreviousError(base_type); base.Report.Error(60, base.Location, "Inconsistent accessibility: base class `{0}' is less accessible than class `{1}'", base_type.GetSignatureForError(), GetSignatureForError()); } } if (base.PartialContainer.IsStatic && array != null) { TypeSpec[] array2 = array; foreach (TypeSpec ms in array2) { base.Report.SymbolRelatedToPreviousError(ms); } base.Report.Error(714, base.Location, "Static class `{0}' cannot implement interfaces", GetSignatureForError()); } return array; } public override string[] ConditionalConditions() { if ((caching_flags & (Flags.Excluded_Undetected | Flags.Excluded)) == 0) { return null; } caching_flags &= ~Flags.Excluded_Undetected; if (base.OptAttributes == null) { return null; } Attribute[] array = base.OptAttributes.SearchMulti(Module.PredefinedAttributes.Conditional); if (array == null) { return null; } string[] array2 = new string[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i].GetConditionalAttributeValue(); } caching_flags |= Flags.Excluded; return array2; } } internal sealed class Struct : ClassOrStruct { private bool is_unmanaged; private bool has_unmanaged_check_done; private bool requires_delayed_unmanagedtype_check; private bool InTransit; private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.READONLY | Modifiers.UNSAFE | Modifiers.REF; public override AttributeTargets AttributeTargets => AttributeTargets.Struct; public bool HasUnmanagedCheckDone => has_unmanaged_check_done; public Struct(TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base(parent, name, attrs, MemberKind.Struct) { base.ModFlags = ModifiersExtensions.Check(Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.READONLY | Modifiers.UNSAFE | Modifiers.REF, mod, base.IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, base.Location, base.Report) | Modifiers.SEALED; spec = new TypeSpec(Kind, null, this, null, base.ModFlags); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { base.ApplyAttributeBuilder(a, ctor, cdata, pa); if (!(a.Type == pa.StructLayout)) { return; } Constant namedValue = a.GetNamedValue("CharSet"); if (namedValue == null) { return; } for (int i = 0; i < base.Members.Count; i++) { if (base.Members[i] is FixedField fixedField) { fixedField.CharSetValue = (CharSet)System.Enum.Parse(typeof(CharSet), namedValue.GetValue().ToString()); } } } private bool CheckStructCycles() { if (InTransit) { return false; } InTransit = true; foreach (MemberCore member in base.Members) { if (!(member is Field field)) { continue; } TypeSpec memberType = field.Spec.MemberType; if (!memberType.IsStruct || memberType is BuiltinTypeSpec) { continue; } TypeSpec[] typeArguments = memberType.TypeArguments; foreach (TypeSpec ts in typeArguments) { if (!CheckFieldTypeCycle(ts)) { base.Report.Error(523, field.Location, "Struct member `{0}' of type `{1}' causes a cycle in the struct layout", field.GetSignatureForError(), memberType.GetSignatureForError()); break; } } if ((field.IsStatic && memberType == CurrentType) || CheckFieldTypeCycle(memberType)) { continue; } base.Report.Error(523, field.Location, "Struct member `{0}' of type `{1}' causes a cycle in the struct layout", field.GetSignatureForError(), memberType.GetSignatureForError()); break; } InTransit = false; return true; } private static bool CheckFieldTypeCycle(TypeSpec ts) { if (!(ts.MemberDefinition is Struct obj)) { return true; } return obj.CheckStructCycles(); } protected override bool DoDefineMembers() { bool result = base.DoDefineMembers(); if (base.PrimaryConstructorParameters != null || (initialized_fields != null && !HasUserDefaultConstructor())) { generated_primary_constructor = DefineDefaultConstructor(is_static: false); generated_primary_constructor.Define(); } return result; } public override void Emit() { if ((base.ModFlags & Modifiers.READONLY) != 0) { Module.PredefinedAttributes.IsReadOnly.EmitAttribute(TypeBuilder); } if ((base.ModFlags & Modifiers.REF) != 0) { Module.PredefinedAttributes.IsByRefLike.EmitAttribute(TypeBuilder); } CheckStructCycles(); base.Emit(); } private bool HasUserDefaultConstructor() { foreach (MemberCore member in base.PartialContainer.Members) { if (!(member is Constructor { IsStatic: false } constructor) || !constructor.ParameterInfo.IsEmpty) { continue; } return true; } return false; } public override bool IsUnmanagedType() { if (has_unmanaged_check_done) { return is_unmanaged; } if (requires_delayed_unmanagedtype_check) { return true; } TypeDefinition partialContainer = Parent.PartialContainer; if (partialContainer != null && partialContainer.IsGenericOrParentIsGeneric) { has_unmanaged_check_done = true; return false; } if (base.HasInstanceField) { requires_delayed_unmanagedtype_check = true; foreach (MemberCore member in base.Members) { if (member is Field { IsStatic: false, MemberType: var memberType }) { if (memberType == null) { return true; } if (!memberType.IsUnmanaged) { has_unmanaged_check_done = true; return false; } } } has_unmanaged_check_done = true; } is_unmanaged = true; return true; } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { TypeSpec[] array = base.ResolveBaseTypes(out base_class); if (array != null && (base.ModFlags & Modifiers.REF) != 0) { base.Report.Error(8343, base.Location, "`{0}': ref structs cannot implement interfaces", GetSignatureForError()); } base_type = Compiler.BuiltinTypes.ValueType; return array; } } internal sealed class Interface : TypeDefinition { private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.UNSAFE; public override AttributeTargets AttributeTargets => AttributeTargets.Interface; protected override TypeAttributes TypeAttr => base.TypeAttr | (TypeAttributes.ClassSemanticsMask | TypeAttributes.Abstract); public Interface(TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) : base(parent, name, attrs, MemberKind.Interface) { base.ModFlags = ModifiersExtensions.Check(Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.UNSAFE, mod, base.IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, name.Location, base.Report); spec = new TypeSpec(Kind, null, this, null, base.ModFlags); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.ComImport && !attributes.Contains(pa.Guid)) { a.Error_MissingGuidAttribute(); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } if (iface_exprs != null) { TypeSpec[] array = iface_exprs; foreach (TypeSpec typeSpec in array) { if (!typeSpec.IsCLSCompliant()) { base.Report.SymbolRelatedToPreviousError(typeSpec); base.Report.Warning(3027, 1, base.Location, "`{0}' is not CLS-compliant because base interface `{1}' is not CLS-compliant", GetSignatureForError(), typeSpec.GetSignatureForError()); } } } return true; } } internal abstract class InterfaceMemberBase : MemberBase { protected const Modifiers AllowedModifiersClass = Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.VIRTUAL | Modifiers.OVERRIDE; protected const Modifiers AllowedModifiersStruct = Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.STATIC | Modifiers.OVERRIDE; protected const Modifiers AllowedModifiersInterface = Modifiers.NEW | Modifiers.UNSAFE; public bool IsInterface; public readonly bool IsExplicitImpl; protected bool is_external_implementation; public TypeSpec InterfaceType; protected MethodSpec base_method; private readonly Modifiers explicit_mod_flags; public MethodAttributes flags; public abstract Variance ExpectedMemberTypeVariance { get; } public string ShortName => base.MemberName.Name; public override bool IsUsed => IsExplicitImpl || base.IsUsed; protected InterfaceMemberBase(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs) : base(parent, type, mod, allowed_mod, Modifiers.PRIVATE, name, attrs) { IsInterface = parent.Kind == MemberKind.Interface; IsExplicitImpl = base.MemberName.ExplicitInterface != null; explicit_mod_flags = mod; } protected override bool CheckBase() { if (!base.CheckBase()) { return false; } if ((caching_flags & Flags.MethodOverloadsExist) != 0) { CheckForDuplications(); } if (IsExplicitImpl) { return true; } if (Parent.BaseType == null) { return true; } bool overrides = false; MemberSpec bestCandidate; MemberSpec memberSpec = FindBaseMember(out bestCandidate, ref overrides); if ((base.ModFlags & Modifiers.OVERRIDE) != 0) { if (memberSpec == null) { if (bestCandidate == null) { if (this is Method && ((Method)this).ParameterInfo.IsEmpty && base.MemberName.Name == Destructor.MetadataName && base.MemberName.Arity == 0) { base.Report.Error(249, base.Location, "Do not override `{0}'. Use destructor syntax instead", "object.Finalize()"); } else { base.Report.Error(115, base.Location, "`{0}' is marked as an override but no suitable {1} found to override", GetSignatureForError(), ATypeNameExpression.GetMemberType(this)); } } else { base.Report.SymbolRelatedToPreviousError(bestCandidate); if (this is Event) { base.Report.Error(72, base.Location, "`{0}': cannot override because `{1}' is not an event", GetSignatureForError(), TypeManager.GetFullNameSignature(bestCandidate)); } else if (this is PropertyBase) { base.Report.Error(544, base.Location, "`{0}': cannot override because `{1}' is not a property", GetSignatureForError(), TypeManager.GetFullNameSignature(bestCandidate)); } else { base.Report.Error(505, base.Location, "`{0}': cannot override because `{1}' is not a method", GetSignatureForError(), TypeManager.GetFullNameSignature(bestCandidate)); } } return false; } if (bestCandidate != null) { base.Report.SymbolRelatedToPreviousError(bestCandidate); base.Report.SymbolRelatedToPreviousError(memberSpec); MemberSpec member = MemberCache.GetMember(memberSpec.DeclaringType.GetDefinition(), memberSpec); MemberSpec member2 = MemberCache.GetMember(bestCandidate.DeclaringType.GetDefinition(), bestCandidate); base.Report.Error(462, base.Location, "`{0}' cannot override inherited members `{1}' and `{2}' because they have the same signature when used in type `{3}'", GetSignatureForError(), member.GetSignatureForError(), member2.GetSignatureForError(), Parent.GetSignatureForError()); } if (!CheckOverrideAgainstBase(memberSpec)) { return false; } ObsoleteAttribute attributeObsolete = memberSpec.GetAttributeObsolete(); if (attributeObsolete != null) { if (base.OptAttributes == null || !base.OptAttributes.Contains(Module.PredefinedAttributes.Obsolete)) { base.Report.SymbolRelatedToPreviousError(memberSpec); base.Report.Warning(672, 1, base.Location, "Member `{0}' overrides obsolete member `{1}'. Add the Obsolete attribute to `{0}'", GetSignatureForError(), memberSpec.GetSignatureForError()); } } else if (base.OptAttributes != null && base.OptAttributes.Contains(Module.PredefinedAttributes.Obsolete)) { base.Report.SymbolRelatedToPreviousError(memberSpec); base.Report.Warning(809, 1, base.Location, "Obsolete member `{0}' overrides non-obsolete member `{1}'", GetSignatureForError(), memberSpec.GetSignatureForError()); } base_method = memberSpec as MethodSpec; return true; } if (memberSpec == null && bestCandidate != null && (!(bestCandidate is IParametersMember) || !(this is IParametersMember))) { memberSpec = bestCandidate; } if (memberSpec == null) { if ((base.ModFlags & Modifiers.NEW) != 0 && memberSpec == null) { base.Report.Warning(109, 4, base.Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError()); } } else { if ((base.ModFlags & Modifiers.NEW) == 0) { base.ModFlags |= Modifiers.NEW; if (!base.IsCompilerGenerated) { base.Report.SymbolRelatedToPreviousError(memberSpec); if ((memberSpec.Kind & MemberKind.NestedMask) == 0 && !IsInterface && (memberSpec.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0) { base.Report.Warning(114, 2, base.Location, "`{0}' hides inherited member `{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError(), memberSpec.GetSignatureForError()); } else { base.Report.Warning(108, 2, base.Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended", GetSignatureForError(), memberSpec.GetSignatureForError()); } } } if (!IsInterface && memberSpec.IsAbstract && !overrides && !base.IsStatic) { switch (memberSpec.Kind) { case MemberKind.Event: case MemberKind.Method: case MemberKind.Property: case MemberKind.Indexer: base.Report.SymbolRelatedToPreviousError(memberSpec); base.Report.Error(533, base.Location, "`{0}' hides inherited abstract member `{1}'", GetSignatureForError(), memberSpec.GetSignatureForError()); break; } } } return true; } protected virtual bool CheckForDuplications() { return Parent.MemberCache.CheckExistingMembersOverloads(this, ParametersCompiled.EmptyReadOnlyParameters); } protected virtual bool CheckOverrideAgainstBase(MemberSpec base_member) { bool result = true; if ((base_member.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0) { base.Report.SymbolRelatedToPreviousError(base_member); base.Report.Error(506, base.Location, "`{0}': cannot override inherited member `{1}' because it is not marked virtual, abstract or override", GetSignatureForError(), TypeManager.CSharpSignature(base_member)); result = false; } if ((base_member.Modifiers & Modifiers.SEALED) != 0) { base.Report.SymbolRelatedToPreviousError(base_member); base.Report.Error(239, base.Location, "`{0}': cannot override inherited member `{1}' because it is sealed", GetSignatureForError(), TypeManager.CSharpSignature(base_member)); result = false; } TypeSpec memberType = ((IInterfaceMemberSpec)base_member).MemberType; if (!TypeSpecComparer.Override.IsEqual(base.MemberType, memberType)) { base.Report.SymbolRelatedToPreviousError(base_member); if (((memberType.Kind ^ base.MemberType.Kind) & MemberKind.ByRef) != 0) { base.Report.Error(8148, base.Location, "`{0}': must {2}return by reference to match overridden member `{1}'", GetSignatureForError(), base_member.GetSignatureForError(), (memberType.Kind == MemberKind.ByRef) ? "" : "not "); } else if (this is PropertyBasedMember) { base.Report.Error(1715, base.Location, "`{0}': type must be `{1}' to match overridden member `{2}'", GetSignatureForError(), memberType.GetSignatureForError(), base_member.GetSignatureForError()); } else { base.Report.Error(508, base.Location, "`{0}': return type must be `{1}' to match overridden member `{2}'", GetSignatureForError(), memberType.GetSignatureForError(), base_member.GetSignatureForError()); } result = false; } else if (!NamedTupleSpec.CheckOverrideName(base.MemberType, memberType)) { base.Report.Error(8139, base.Location, "`{0}': cannot change return type tuple element names when overriding inherited member `{1}'", GetSignatureForError(), base_member.GetSignatureForError()); result = false; } if (base_member is IParametersMember baseMember && !NamedTupleSpec.CheckOverrideName((IParametersMember)this, baseMember)) { base.Report.Error(8139, base.Location, "`{0}': cannot change tuple element names when overriding inherited member `{1}'", GetSignatureForError(), base_member.GetSignatureForError()); result = false; } return result; } protected static bool CheckAccessModifiers(MemberCore this_member, MemberSpec base_member) { Modifiers modifiers = this_member.ModFlags & Modifiers.AccessibilityMask; Modifiers modifiers2 = base_member.Modifiers & Modifiers.AccessibilityMask; if ((modifiers2 & (Modifiers.PROTECTED | Modifiers.INTERNAL)) == (Modifiers.PROTECTED | Modifiers.INTERNAL)) { if ((modifiers & Modifiers.PROTECTED) == 0) { return false; } if ((modifiers & Modifiers.INTERNAL) != 0) { return base_member.DeclaringType.MemberDefinition.IsInternalAsPublic(this_member.Module.DeclaringAssembly); } if (base_member.DeclaringType.MemberDefinition.IsInternalAsPublic(this_member.Module.DeclaringAssembly)) { return false; } return true; } return modifiers == modifiers2; } public override bool Define() { if (IsInterface) { base.ModFlags = Modifiers.PUBLIC | Modifiers.ABSTRACT | Modifiers.VIRTUAL | (base.ModFlags & (Modifiers.NEW | Modifiers.UNSAFE)); flags = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask | MethodAttributes.Abstract; } else { Parent.PartialContainer.MethodModifiersValid(this); flags = ModifiersExtensions.MethodAttr(base.ModFlags); } if (IsExplicitImpl) { InterfaceType = base.MemberName.ExplicitInterface.ResolveAsType(Parent); if (InterfaceType == null) { return false; } if ((base.ModFlags & Modifiers.PARTIAL) != 0) { base.Report.Error(754, base.Location, "A partial method `{0}' cannot explicitly implement an interface", GetSignatureForError()); } if (!InterfaceType.IsInterface) { base.Report.SymbolRelatedToPreviousError(InterfaceType); base.Report.Error(538, base.Location, "The type `{0}' in explicit interface declaration is not an interface", InterfaceType.GetSignatureForError()); } else { Parent.PartialContainer.VerifyImplements(this); } Modifiers modifiers = Modifiers.AllowedExplicitImplFlags; if (this is Method) { modifiers |= Modifiers.ASYNC; } ModifiersExtensions.Check(modifiers, explicit_mod_flags, (Modifiers)0, base.Location, base.Report); } return base.Define(); } protected bool DefineParameters(ParametersCompiled parameters) { if (!parameters.Resolve(this)) { return false; } bool flag = false; for (int i = 0; i < parameters.Count; i++) { Parameter parameter = parameters[i]; if (parameter.HasDefaultValue && (IsExplicitImpl || this is Operator || (this is Indexer && parameters.Count == 1))) { parameter.Warning_UselessOptionalParameter(base.Report); } if (!parameter.CheckAccessibility(this)) { TypeSpec typeSpec = parameters.Types[i]; base.Report.SymbolRelatedToPreviousError(typeSpec); if (this is Indexer) { base.Report.Error(55, base.Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than indexer `{1}'", typeSpec.GetSignatureForError(), GetSignatureForError()); } else if (this is Operator) { base.Report.Error(57, base.Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than operator `{1}'", typeSpec.GetSignatureForError(), GetSignatureForError()); } else { base.Report.Error(51, base.Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than method `{1}'", typeSpec.GetSignatureForError(), GetSignatureForError()); } flag = true; } } return !flag; } protected override void DoMemberTypeDependentChecks() { base.DoMemberTypeDependentChecks(); VarianceDecl.CheckTypeVariance(base.MemberType, ExpectedMemberTypeVariance, this); } public override void Emit() { if ((base.ModFlags & Modifiers.EXTERN) != 0 && !is_external_implementation && (base.OptAttributes == null || !base.OptAttributes.HasResolveError())) { if (this is Constructor) { base.Report.Warning(824, 1, base.Location, "Constructor `{0}' is marked `external' but has no external implementation specified", GetSignatureForError()); } else { base.Report.Warning(626, 1, base.Location, "`{0}' is marked as an external but has no DllImport attribute. Consider adding a DllImport attribute to specify the external implementation", GetSignatureForError()); } } base.Emit(); } public override bool EnableOverloadChecks(MemberCore overload) { if (overload is InterfaceMemberBase { IsExplicitImpl: not false }) { if (IsExplicitImpl) { caching_flags |= Flags.MethodOverloadsExist; } return true; } return IsExplicitImpl; } protected void Error_CannotChangeAccessModifiers(MemberCore member, MemberSpec base_member) { Modifiers modifiers = base_member.Modifiers; if ((modifiers & Modifiers.AccessibilityMask) == (Modifiers.PROTECTED | Modifiers.INTERNAL) && !base_member.DeclaringType.MemberDefinition.IsInternalAsPublic(member.Module.DeclaringAssembly)) { modifiers = Modifiers.PROTECTED; } base.Report.SymbolRelatedToPreviousError(base_member); base.Report.Error(507, member.Location, "`{0}': cannot change access modifiers when overriding `{1}' inherited member `{2}'", member.GetSignatureForError(), ModifiersExtensions.AccessibilityName(modifiers), base_member.GetSignatureForError()); } protected void Error_StaticReturnType() { base.Report.Error(722, base.Location, "`{0}': static types cannot be used as return types", base.MemberType.GetSignatureForError()); } protected virtual MemberSpec FindBaseMember(out MemberSpec bestCandidate, ref bool overrides) { return MemberCache.FindBaseMember(this, out bestCandidate, ref overrides); } public string GetFullName(MemberName name) { return GetFullName(name.Name); } public string GetFullName(string name) { if (!IsExplicitImpl) { return name; } return InterfaceType.GetSignatureForError() + "." + name; } public override string GetSignatureForDocumentation() { if (IsExplicitImpl) { return Parent.GetSignatureForDocumentation() + "." + InterfaceType.GetSignatureForDocumentation(explicitName: true) + "#" + ShortName; } return Parent.GetSignatureForDocumentation() + "." + ShortName; } public override void SetConstraints(List constraints_list) { if ((base.ModFlags & Modifiers.OVERRIDE) != 0 || IsExplicitImpl) { base.Report.Error(460, base.Location, "`{0}': Cannot specify constraints for overrides and explicit interface implementation methods", GetSignatureForError()); } base.SetConstraints(constraints_list); } } internal abstract class MemberBase : MemberCore { protected FullNamedExpression type_expr; protected TypeSpec member_type; public new TypeDefinition Parent; public TypeSpec MemberType => member_type; public FullNamedExpression TypeExpression { get { return type_expr; } set { type_expr = value; } } protected MemberBase(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, Modifiers def_mod, MemberName name, Attributes attrs) : base(parent, name, attrs) { Parent = parent; type_expr = type; if (name != MemberName.Null) { base.ModFlags = ModifiersExtensions.Check(allowed_mod, mod, def_mod, base.Location, base.Report); } } public override bool Define() { DoMemberTypeIndependentChecks(); if (!ResolveMemberType()) { return false; } DoMemberTypeDependentChecks(); return true; } protected virtual void DoMemberTypeIndependentChecks() { if ((Parent.ModFlags & Modifiers.SEALED) != 0 && (base.ModFlags & (Modifiers.ABSTRACT | Modifiers.VIRTUAL)) != 0) { base.Report.Error(549, base.Location, "New virtual member `{0}' is declared in a sealed class `{1}'", GetSignatureForError(), Parent.GetSignatureForError()); } } protected virtual void DoMemberTypeDependentChecks() { if (IsAccessibleAs(MemberType)) { return; } base.Report.SymbolRelatedToPreviousError(MemberType); if (this is Property) { base.Report.Error(53, base.Location, "Inconsistent accessibility: property type `" + MemberType.GetSignatureForError() + "' is less accessible than property `" + GetSignatureForError() + "'"); } else if (this is Indexer) { base.Report.Error(54, base.Location, "Inconsistent accessibility: indexer return type `" + MemberType.GetSignatureForError() + "' is less accessible than indexer `" + GetSignatureForError() + "'"); } else if (this is MethodCore) { if (this is Operator) { base.Report.Error(56, base.Location, "Inconsistent accessibility: return type `" + MemberType.GetSignatureForError() + "' is less accessible than operator `" + GetSignatureForError() + "'"); } else { base.Report.Error(50, base.Location, "Inconsistent accessibility: return type `" + MemberType.GetSignatureForError() + "' is less accessible than method `" + GetSignatureForError() + "'"); } } else if (this is Event) { base.Report.Error(7025, base.Location, "Inconsistent accessibility: event type `{0}' is less accessible than event `{1}'", MemberType.GetSignatureForError(), GetSignatureForError()); } else { base.Report.Error(52, base.Location, "Inconsistent accessibility: field type `" + MemberType.GetSignatureForError() + "' is less accessible than field `" + GetSignatureForError() + "'"); } } protected void IsTypePermitted() { if (!MemberType.IsSpecialRuntimeType && !MemberType.IsByRefLike) { return; } if (Parent is StateMachine) { base.Report.Error(4012, base.Location, "Parameters or local variables of type `{0}' cannot be declared in async methods or iterators", MemberType.GetSignatureForError()); } else if (Parent is HoistedStoreyClass) { base.Report.Error(4013, base.Location, "Local variables of type `{0}' cannot be used inside anonymous methods, lambda expressions or query expressions", MemberType.GetSignatureForError()); } else if (MemberType.IsByRefLike) { if ((base.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 && ((base.ModFlags & Modifiers.AutoProperty) != 0 || !(this is Property)) && ((base.ModFlags & Modifiers.STATIC) != 0 || (Parent.ModFlags & Modifiers.REF) == 0)) { base.Report.Error(8345, base.Location, "Field or auto-implemented property cannot be of type `{0}' unless it is an instance member of a ref struct", MemberType.GetSignatureForError()); } } else { base.Report.Error(610, base.Location, "Field or property cannot be of type `{0}'", MemberType.GetSignatureForError()); } } protected virtual bool CheckBase() { CheckProtectedModifier(); return true; } public override string GetSignatureForDocumentation() { return Parent.GetSignatureForDocumentation() + "." + base.MemberName.Basename; } public virtual void PrepareEmit() { if (member_type != null && type_expr != null) { member_type.CheckObsoleteness(this, type_expr.Location); } } protected virtual bool ResolveMemberType() { if (member_type != null) { throw new InternalErrorException("Multi-resolve"); } member_type = type_expr.ResolveAsType(this); return member_type != null; } } internal class EmitContext : BuilderContext { public readonly ILGenerator ig; private readonly TypeSpec return_type; private Dictionary temporary_storage; public LocalBuilder return_value; public Label LoopBegin; public Label LoopEnd; public Label DefaultTarget; public Switch Switch; public AnonymousExpression CurrentAnonymousMethod; private readonly IMemberContext member_context; private readonly SourceMethodBuilder methodSymbols; private DynamicSiteClass dynamic_site_container; private Label? return_label; private List epilogue_expressions; internal AsyncTaskStorey AsyncTaskStorey => CurrentAnonymousMethod.Storey as AsyncTaskStorey; public BuiltinTypes BuiltinTypes => MemberContext.Module.Compiler.BuiltinTypes; public ConditionalAccessContext ConditionalAccess { get; set; } public TypeSpec CurrentType => member_context.CurrentType; public TypeParameters CurrentTypeParameters => member_context.CurrentTypeParameters; public MemberCore CurrentTypeDefinition => member_context.CurrentMemberDefinition; public bool EmitAccurateDebugInfo => (flags & Options.AccurateDebugInfo) != 0; public bool HasMethodSymbolBuilder => methodSymbols != null; public bool HasReturnLabel => return_label.HasValue; public bool IsStatic => member_context.IsStatic; public bool IsStaticConstructor => member_context.IsStatic && (flags & Options.ConstructorScope) != 0; public bool IsAnonymousStoreyMutateRequired => CurrentAnonymousMethod != null && CurrentAnonymousMethod.Storey != null && CurrentAnonymousMethod.Storey.Mutator != null; public IMemberContext MemberContext => member_context; public ModuleContainer Module => member_context.Module; public bool NotifyEvaluatorOnStore => Module.Evaluator != null && Module.Evaluator.ModificationListener != null; public Report Report => member_context.Module.Compiler.Report; public TypeSpec ReturnType => return_type; public Label ReturnLabel => return_label.Value; public List StatementEpilogue => epilogue_expressions; public LocalVariable AsyncThrowVariable { get; set; } public List TryFinallyUnwind { get; set; } public Label RecursivePatternLabel { get; set; } public EmitContext(IMemberContext rc, ILGenerator ig, TypeSpec return_type, SourceMethodBuilder methodSymbols) { member_context = rc; this.ig = ig; this.return_type = return_type; if (rc.Module.Compiler.Settings.Checked) { flags |= Options.CheckedScope; } if (methodSymbols != null) { this.methodSymbols = methodSymbols; if (!rc.Module.Compiler.Settings.Optimize) { flags |= Options.AccurateDebugInfo; } } else { flags |= Options.OmitDebugInfo; } } public void AddStatementEpilog(IExpressionCleanup cleanupExpression) { if (epilogue_expressions == null) { epilogue_expressions = new List(); } else if (epilogue_expressions.Contains(cleanupExpression)) { return; } epilogue_expressions.Add(cleanupExpression); } public void AssertEmptyStack() { } public bool Mark(Location loc) { if ((flags & Options.OmitDebugInfo) != 0) { return false; } if (loc.IsNull || methodSymbols == null) { return false; } SourceFile sourceFile = loc.SourceFile; if (sourceFile.IsHiddenLocation(loc)) { return false; } return true; } public void MarkCallEntry(Location loc) { if (EmitAccurateDebugInfo) { Mark(loc); } } public void DefineLocalVariable(string name, LocalBuilder builder) { if ((flags & Options.OmitDebugInfo) == 0) { methodSymbols.AddLocal(builder.LocalIndex, name); } } public void BeginCatchBlock(TypeSpec type) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.BeginCatchBlock(type.GetMetaInfo()); } public void BeginFilterHandler() { ig.BeginCatchBlock(null); } public void BeginExceptionBlock() { ig.BeginExceptionBlock(); } public void BeginExceptionFilterBlock() { ig.BeginExceptFilterBlock(); } public void BeginFinallyBlock() { ig.BeginFinallyBlock(); } public void BeginScope(int scopeIndex) { if ((flags & Options.OmitDebugInfo) == 0) { } } public void BeginCompilerScope(int scopeIndex) { if ((flags & Options.OmitDebugInfo) == 0) { } } public void EndExceptionBlock() { ig.EndExceptionBlock(); } public void EndScope() { if ((flags & Options.OmitDebugInfo) == 0) { } } public void CloseConditionalAccess(TypeSpec type) { if (type != null) { Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); } MarkLabel(ConditionalAccess.EndLabel); ConditionalAccess = null; } internal DynamicSiteClass CreateDynamicSite() { if (dynamic_site_container == null) { MemberBase host = member_context.CurrentMemberDefinition as MemberBase; dynamic_site_container = new DynamicSiteClass(CurrentTypeDefinition.Parent.PartialContainer, host, member_context.CurrentTypeParameters); CurrentTypeDefinition.Module.AddCompilerGeneratedClass(dynamic_site_container); dynamic_site_container.CreateContainer(); dynamic_site_container.DefineContainer(); dynamic_site_container.Define(); TypeParameterInflator inflator = new TypeParameterInflator(Module, CurrentType, TypeParameterSpec.EmptyTypes, TypeSpec.EmptyTypes); MemberSpec ms = dynamic_site_container.CurrentType.InflateMember(inflator); CurrentType.MemberCache.AddMember(ms); } return dynamic_site_container; } public Label CreateReturnLabel() { if (!return_label.HasValue) { return_label = DefineLabel(); } return return_label.Value; } public LocalBuilder DeclareLocal(TypeSpec type, bool pinned) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } if (pinned && type is PointerContainer pointerContainer) { type = pointerContainer.Element; if (type.Kind == MemberKind.Void) { type = Module.Compiler.BuiltinTypes.IntPtr; } return ig.DeclareLocal(type.GetMetaInfo().MakeByRefType(), pinned: true); } return ig.DeclareLocal(type.GetMetaInfo(), pinned); } public Label DefineLabel() { return ig.DefineLabel(); } public StackFieldExpr GetTemporaryField(TypeSpec type, bool initializedFieldRequired = false) { Field field = AsyncTaskStorey.AddCapturedLocalVariable(type, initializedFieldRequired); StackFieldExpr stackFieldExpr = new StackFieldExpr(field); stackFieldExpr.InstanceExpression = new CompilerGeneratedThis(CurrentType, Location.Null); return stackFieldExpr; } public void MarkLabel(Label label) { ig.MarkLabel(label); } public void Emit(OpCode opcode) { ig.Emit(opcode); } public void Emit(OpCode opcode, LocalBuilder local) { ig.Emit(opcode, local); } public void Emit(OpCode opcode, string arg) { ig.Emit(opcode, arg); } public void Emit(OpCode opcode, double arg) { ig.Emit(opcode, arg); } public void Emit(OpCode opcode, float arg) { ig.Emit(opcode, arg); } public void Emit(OpCode opcode, Label label) { ig.Emit(opcode, label); } public void Emit(OpCode opcode, Label[] labels) { ig.Emit(opcode, labels); } public void Emit(OpCode opcode, TypeSpec type) { if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(opcode, type.GetMetaInfo()); } public void Emit(OpCode opcode, FieldSpec field) { if (IsAnonymousStoreyMutateRequired) { field = field.Mutate(CurrentAnonymousMethod.Storey.Mutator); } ig.Emit(opcode, field.GetMetaInfo()); } public void Emit(OpCode opcode, MethodSpec method) { if (IsAnonymousStoreyMutateRequired) { method = method.Mutate(CurrentAnonymousMethod.Storey.Mutator); } if (method.IsConstructor) { ig.Emit(opcode, (ConstructorInfo)method.GetMetaInfo()); } else { ig.Emit(opcode, (MethodInfo)method.GetMetaInfo()); } } public void Emit(OpCode opcode, MethodInfo method) { ig.Emit(opcode, method); } public void Emit(OpCode opcode, MethodSpec method, Type[] vargs) { ig.EmitCall(opcode, (MethodInfo)method.GetMetaInfo(), vargs); } public void EmitArrayNew(ArrayContainer ac) { if (ac.Rank == 1) { TypeSpec typeSpec = (IsAnonymousStoreyMutateRequired ? CurrentAnonymousMethod.Storey.Mutator.Mutate(ac.Element) : ac.Element); ig.Emit(OpCodes.Newarr, typeSpec.GetMetaInfo()); return; } if (IsAnonymousStoreyMutateRequired) { ac = (ArrayContainer)ac.Mutate(CurrentAnonymousMethod.Storey.Mutator); } ig.Emit(OpCodes.Newobj, ac.GetConstructor()); } public void EmitArrayAddress(ArrayContainer ac) { if (ac.Rank > 1) { if (IsAnonymousStoreyMutateRequired) { ac = (ArrayContainer)ac.Mutate(CurrentAnonymousMethod.Storey.Mutator); } ig.Emit(OpCodes.Call, ac.GetAddressMethod()); } else { TypeSpec typeSpec = (IsAnonymousStoreyMutateRequired ? CurrentAnonymousMethod.Storey.Mutator.Mutate(ac.Element) : ac.Element); ig.Emit(OpCodes.Ldelema, typeSpec.GetMetaInfo()); } } public void EmitArrayLoad(ArrayContainer ac) { if (ac.Rank > 1) { if (IsAnonymousStoreyMutateRequired) { ac = (ArrayContainer)ac.Mutate(CurrentAnonymousMethod.Storey.Mutator); } ig.Emit(OpCodes.Call, ac.GetGetMethod()); return; } TypeSpec typeSpec = ac.Element; if (typeSpec.Kind == MemberKind.Enum) { typeSpec = EnumSpec.GetUnderlyingType(typeSpec); } switch (typeSpec.BuiltinType) { case BuiltinTypeSpec.Type.FirstPrimitive: case BuiltinTypeSpec.Type.Byte: ig.Emit(OpCodes.Ldelem_U1); return; case BuiltinTypeSpec.Type.SByte: ig.Emit(OpCodes.Ldelem_I1); return; case BuiltinTypeSpec.Type.Short: ig.Emit(OpCodes.Ldelem_I2); return; case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.UShort: ig.Emit(OpCodes.Ldelem_U2); return; case BuiltinTypeSpec.Type.Int: ig.Emit(OpCodes.Ldelem_I4); return; case BuiltinTypeSpec.Type.UInt: ig.Emit(OpCodes.Ldelem_U4); return; case BuiltinTypeSpec.Type.Long: case BuiltinTypeSpec.Type.ULong: ig.Emit(OpCodes.Ldelem_I8); return; case BuiltinTypeSpec.Type.Float: ig.Emit(OpCodes.Ldelem_R4); return; case BuiltinTypeSpec.Type.Double: ig.Emit(OpCodes.Ldelem_R8); return; case BuiltinTypeSpec.Type.IntPtr: ig.Emit(OpCodes.Ldelem_I); return; } switch (typeSpec.Kind) { case MemberKind.Struct: if (IsAnonymousStoreyMutateRequired) { typeSpec = CurrentAnonymousMethod.Storey.Mutator.Mutate(typeSpec); } ig.Emit(OpCodes.Ldelema, typeSpec.GetMetaInfo()); ig.Emit(OpCodes.Ldobj, typeSpec.GetMetaInfo()); break; case MemberKind.TypeParameter: if (IsAnonymousStoreyMutateRequired) { typeSpec = CurrentAnonymousMethod.Storey.Mutator.Mutate(typeSpec); } ig.Emit(OpCodes.Ldelem, typeSpec.GetMetaInfo()); break; case MemberKind.PointerType: ig.Emit(OpCodes.Ldelem_I); break; default: ig.Emit(OpCodes.Ldelem_Ref); break; } } public void EmitArrayStore(ArrayContainer ac) { if (ac.Rank > 1) { if (IsAnonymousStoreyMutateRequired) { ac = (ArrayContainer)ac.Mutate(CurrentAnonymousMethod.Storey.Mutator); } ig.Emit(OpCodes.Call, ac.GetSetMethod()); return; } TypeSpec typeSpec = ac.Element; if (typeSpec.Kind == MemberKind.Enum) { typeSpec = EnumSpec.GetUnderlyingType(typeSpec); } switch (typeSpec.BuiltinType) { case BuiltinTypeSpec.Type.FirstPrimitive: case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.SByte: Emit(OpCodes.Stelem_I1); return; case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.UShort: Emit(OpCodes.Stelem_I2); return; case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: Emit(OpCodes.Stelem_I4); return; case BuiltinTypeSpec.Type.Long: case BuiltinTypeSpec.Type.ULong: Emit(OpCodes.Stelem_I8); return; case BuiltinTypeSpec.Type.Float: Emit(OpCodes.Stelem_R4); return; case BuiltinTypeSpec.Type.Double: Emit(OpCodes.Stelem_R8); return; } switch (typeSpec.Kind) { case MemberKind.Struct: Emit(OpCodes.Stobj, typeSpec); break; case MemberKind.TypeParameter: Emit(OpCodes.Stelem, typeSpec); break; case MemberKind.PointerType: Emit(OpCodes.Stelem_I); break; default: Emit(OpCodes.Stelem_Ref); break; } } public void EmitInt(int i) { EmitIntConstant(i); } private void EmitIntConstant(int i) { switch (i) { case -1: ig.Emit(OpCodes.Ldc_I4_M1); return; case 0: ig.Emit(OpCodes.Ldc_I4_0); return; case 1: ig.Emit(OpCodes.Ldc_I4_1); return; case 2: ig.Emit(OpCodes.Ldc_I4_2); return; case 3: ig.Emit(OpCodes.Ldc_I4_3); return; case 4: ig.Emit(OpCodes.Ldc_I4_4); return; case 5: ig.Emit(OpCodes.Ldc_I4_5); return; case 6: ig.Emit(OpCodes.Ldc_I4_6); return; case 7: ig.Emit(OpCodes.Ldc_I4_7); return; case 8: ig.Emit(OpCodes.Ldc_I4_8); return; } if (i >= -128 && i <= 127) { ig.Emit(OpCodes.Ldc_I4_S, (sbyte)i); } else { ig.Emit(OpCodes.Ldc_I4, i); } } public void EmitLong(long l) { if (l >= int.MinValue && l <= int.MaxValue) { EmitIntConstant((int)l); ig.Emit(OpCodes.Conv_I8); } else if (l >= 0 && l <= uint.MaxValue) { EmitIntConstant((int)l); ig.Emit(OpCodes.Conv_U8); } else { ig.Emit(OpCodes.Ldc_I8, l); } } public void EmitLoadFromPtr(TypeSpec type) { if (type.Kind == MemberKind.Enum) { type = EnumSpec.GetUnderlyingType(type); } switch (type.BuiltinType) { case BuiltinTypeSpec.Type.Int: ig.Emit(OpCodes.Ldind_I4); return; case BuiltinTypeSpec.Type.UInt: ig.Emit(OpCodes.Ldind_U4); return; case BuiltinTypeSpec.Type.Short: ig.Emit(OpCodes.Ldind_I2); return; case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.UShort: ig.Emit(OpCodes.Ldind_U2); return; case BuiltinTypeSpec.Type.Byte: ig.Emit(OpCodes.Ldind_U1); return; case BuiltinTypeSpec.Type.FirstPrimitive: case BuiltinTypeSpec.Type.SByte: ig.Emit(OpCodes.Ldind_I1); return; case BuiltinTypeSpec.Type.Long: case BuiltinTypeSpec.Type.ULong: ig.Emit(OpCodes.Ldind_I8); return; case BuiltinTypeSpec.Type.Float: ig.Emit(OpCodes.Ldind_R4); return; case BuiltinTypeSpec.Type.Double: ig.Emit(OpCodes.Ldind_R8); return; case BuiltinTypeSpec.Type.IntPtr: ig.Emit(OpCodes.Ldind_I); return; } switch (type.Kind) { case MemberKind.Struct: case MemberKind.TypeParameter: if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(OpCodes.Ldobj, type.GetMetaInfo()); break; case MemberKind.PointerType: ig.Emit(OpCodes.Ldind_I); break; default: ig.Emit(OpCodes.Ldind_Ref); break; } } public void EmitNull() { ig.Emit(OpCodes.Ldnull); } public void EmitArgumentAddress(int pos) { if (!IsStatic) { pos++; } if (pos > 255) { ig.Emit(OpCodes.Ldarga, pos); } else { ig.Emit(OpCodes.Ldarga_S, (byte)pos); } } public void EmitArgumentLoad(int pos) { if (!IsStatic) { pos++; } switch (pos) { case 0: ig.Emit(OpCodes.Ldarg_0); return; case 1: ig.Emit(OpCodes.Ldarg_1); return; case 2: ig.Emit(OpCodes.Ldarg_2); return; case 3: ig.Emit(OpCodes.Ldarg_3); return; } if (pos > 255) { ig.Emit(OpCodes.Ldarg, pos); } else { ig.Emit(OpCodes.Ldarg_S, (byte)pos); } } public void EmitArgumentStore(int pos) { if (!IsStatic) { pos++; } if (pos > 255) { ig.Emit(OpCodes.Starg, pos); } else { ig.Emit(OpCodes.Starg_S, (byte)pos); } } public void EmitStoreFromPtr(TypeSpec type) { if (type.IsEnum) { type = EnumSpec.GetUnderlyingType(type); } switch (type.BuiltinType) { case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: ig.Emit(OpCodes.Stind_I4); return; case BuiltinTypeSpec.Type.Long: case BuiltinTypeSpec.Type.ULong: ig.Emit(OpCodes.Stind_I8); return; case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.UShort: ig.Emit(OpCodes.Stind_I2); return; case BuiltinTypeSpec.Type.Float: ig.Emit(OpCodes.Stind_R4); return; case BuiltinTypeSpec.Type.Double: ig.Emit(OpCodes.Stind_R8); return; case BuiltinTypeSpec.Type.FirstPrimitive: case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.SByte: ig.Emit(OpCodes.Stind_I1); return; case BuiltinTypeSpec.Type.IntPtr: ig.Emit(OpCodes.Stind_I); return; } switch (type.Kind) { case MemberKind.Struct: case MemberKind.TypeParameter: if (IsAnonymousStoreyMutateRequired) { type = CurrentAnonymousMethod.Storey.Mutator.Mutate(type); } ig.Emit(OpCodes.Stobj, type.GetMetaInfo()); break; case MemberKind.PointerType: ig.Emit(OpCodes.Stind_I); break; default: ig.Emit(OpCodes.Stind_Ref); break; } } public void EmitThis() { ig.Emit(OpCodes.Ldarg_0); } public void EmitEpilogue() { if (epilogue_expressions == null) { return; } foreach (IExpressionCleanup epilogue_expression in epilogue_expressions) { epilogue_expression.EmitCleanup(this); } epilogue_expressions = null; } public LocalBuilder GetTemporaryLocal(TypeSpec t) { if (temporary_storage != null) { if (temporary_storage.TryGetValue(t, out var value)) { if (value is Stack) { Stack stack = (Stack)value; value = ((stack.Count == 0) ? null : stack.Pop()); } else { temporary_storage.Remove(t); } } if (value != null) { return (LocalBuilder)value; } } return DeclareLocal(t, pinned: false); } public void FreeTemporaryLocal(LocalBuilder b, TypeSpec t) { if (temporary_storage == null) { temporary_storage = new Dictionary(ReferenceEquality.Default); temporary_storage.Add(t, b); return; } if (!temporary_storage.TryGetValue(t, out var value)) { temporary_storage.Add(t, b); return; } Stack stack = value as Stack; if (stack == null) { stack = new Stack(); stack.Push((LocalBuilder)value); temporary_storage[t] = stack; } stack.Push(b); } public LocalBuilder TemporaryReturn() { if (return_value == null) { return_value = DeclareLocal(return_type, pinned: false); } return return_value; } } internal class ConditionalAccessContext { public bool Statement { get; set; } public Label EndLabel { get; private set; } public TypeSpec Type { get; private set; } public ConditionalAccessContext(TypeSpec type, Label endLabel) { Type = type; EndLabel = endLabel; } } internal struct CallEmitter { public Expression InstanceExpression; public bool DuplicateArguments; public bool InstanceExpressionOnStack; public bool HasAwaitArguments; public bool ConditionalAccess; public Arguments EmittedArguments; public void Emit(EmitContext ec, MethodSpec method, Arguments Arguments, Location loc) { EmitPredefined(ec, method, Arguments, statement: false, loc); } public void EmitStatement(EmitContext ec, MethodSpec method, Arguments Arguments, Location loc) { EmitPredefined(ec, method, Arguments, statement: true, loc); } public void EmitPredefined(EmitContext ec, MethodSpec method, Arguments Arguments, bool statement = false, Location? loc = null) { Expression expression = null; if (!HasAwaitArguments && ec.HasSet(BuilderContext.Options.AsyncBody)) { HasAwaitArguments = Arguments?.ContainsEmitWithAwait() ?? false; if (HasAwaitArguments && InstanceExpressionOnStack) { throw new NotSupportedException(); } } LocalTemporary localTemporary = null; OpCode opCode; if (method.IsStatic) { opCode = OpCodes.Call; } else { opCode = (IsVirtualCallRequired(InstanceExpression, method) ? OpCodes.Callvirt : OpCodes.Call); if (HasAwaitArguments) { expression = InstanceExpression.EmitToField(ec); InstanceEmitter instanceEmitter = new InstanceEmitter(expression, IsAddressCall(expression, opCode, method.DeclaringType)); if (Arguments == null) { if (ConditionalAccess) { instanceEmitter.Emit(ec, conditionalAccess: true); } else { instanceEmitter.EmitLoad(ec, boxInstance: true); } } } else if (!InstanceExpressionOnStack) { InstanceEmitter instanceEmitter2 = new InstanceEmitter(InstanceExpression, IsAddressCall(InstanceExpression, opCode, method.DeclaringType)); instanceEmitter2.Emit(ec, ConditionalAccess); if (DuplicateArguments) { ec.Emit(OpCodes.Dup); if (Arguments != null && Arguments.Count != 0) { localTemporary = new LocalTemporary(instanceEmitter2.GetStackType(ec)); localTemporary.Store(ec); expression = localTemporary; } } } } if (Arguments != null && !InstanceExpressionOnStack) { EmittedArguments = Arguments.Emit(ec, DuplicateArguments, HasAwaitArguments); if (EmittedArguments != null) { if (expression != null) { new InstanceEmitter(expression, IsAddressCall(expression, opCode, method.DeclaringType)).Emit(ec, ConditionalAccess); localTemporary?.Release(ec); } EmittedArguments.Emit(ec); } } if (opCode == OpCodes.Callvirt && (InstanceExpression.Type.IsGenericParameter || InstanceExpression.Type.IsStructOrEnum)) { ec.Emit(OpCodes.Constrained, InstanceExpression.Type); } if (loc.HasValue) { ec.MarkCallEntry(loc.Value); } InstanceExpression = expression; if (method.Parameters.HasArglist) { Type[] varargsTypes = GetVarargsTypes(method, Arguments); ec.Emit(opCode, method, varargsTypes); } else { ec.Emit(opCode, method); } if (statement && method.ReturnType.Kind != MemberKind.Void) { ec.Emit(OpCodes.Pop); } } private static Type[] GetVarargsTypes(MethodSpec method, Arguments arguments) { AParametersCollection parameters = method.Parameters; Argument argument = arguments[parameters.Count - 1]; Arglist arglist = (Arglist)argument.Expr; return arglist.ArgumentTypes; } private static bool IsVirtualCallRequired(Expression instance, MethodSpec method) { TypeSpec declaringType = method.DeclaringType; if (declaringType.IsStruct || declaringType.IsEnum) { return false; } if (instance is BaseThis) { return false; } if (!method.IsVirtual && Expression.IsNeverNull(instance) && !instance.Type.IsGenericParameter) { return false; } return true; } private static bool IsAddressCall(Expression instance, OpCode callOpcode, TypeSpec declaringType) { TypeSpec type = instance.Type; return (type.IsStructOrEnum && (callOpcode == OpCodes.Callvirt || (callOpcode == OpCodes.Call && declaringType.IsStruct))) || type.IsGenericParameter || declaringType.IsNullableType; } } internal struct InstanceEmitter { private readonly Expression instance; private readonly bool addressRequired; public InstanceEmitter(Expression instance, bool addressLoad) { this.instance = instance; addressRequired = addressLoad; } public void Emit(EmitContext ec, bool conditionalAccess) { if (conditionalAccess && Expression.IsNeverNull(instance)) { conditionalAccess = false; } Label label; Unwrap unwrap; if (conditionalAccess) { label = ec.DefineLabel(); unwrap = instance as Unwrap; } else { label = default(Label); unwrap = null; } IMemoryLocation memoryLocation = null; bool flag = false; if (unwrap != null) { unwrap.Store(ec); unwrap.EmitCheck(ec); ec.Emit(OpCodes.Brtrue_S, label); } else { if (conditionalAccess && addressRequired) { memoryLocation = instance as VariableReference; if (memoryLocation == null) { memoryLocation = instance as LocalTemporary; } if (memoryLocation == null) { EmitLoad(ec, boxInstance: false); ec.Emit(OpCodes.Dup); ec.EmitLoadFromPtr(instance.Type); flag = true; } else { instance.Emit(ec); } } else { EmitLoad(ec, !conditionalAccess); if (conditionalAccess) { flag = !ExpressionAnalyzer.IsInexpensiveLoad(instance); if (flag) { ec.Emit(OpCodes.Dup); } } } if (conditionalAccess) { if (instance.Type.Kind == MemberKind.TypeParameter) { ec.Emit(OpCodes.Box, instance.Type); } ec.Emit(OpCodes.Brtrue_S, label); if (flag) { ec.Emit(OpCodes.Pop); } } } if (!conditionalAccess) { return; } if (!ec.ConditionalAccess.Statement) { TypeSpec type = ec.ConditionalAccess.Type; if (type.IsNullableType) { LiftedNull.Create(type, Location.Null).Emit(ec); } else { ec.EmitNull(); if (type.IsGenericParameter) { ec.Emit(OpCodes.Unbox_Any, type); } } } ec.Emit(OpCodes.Br, ec.ConditionalAccess.EndLabel); ec.MarkLabel(label); if (memoryLocation != null) { memoryLocation.AddressOf(ec, AddressOp.Load); } else if (unwrap != null) { unwrap.Emit(ec); if (addressRequired) { LocalBuilder temporaryLocal = ec.GetTemporaryLocal(unwrap.Type); ec.Emit(OpCodes.Stloc, temporaryLocal); ec.Emit(OpCodes.Ldloca, temporaryLocal); ec.FreeTemporaryLocal(temporaryLocal, unwrap.Type); } } else if (!flag) { instance.Emit(ec); } } public void EmitLoad(EmitContext ec, bool boxInstance) { TypeSpec type = instance.Type; if (addressRequired) { if (instance is IMemoryLocation memoryLocation) { memoryLocation.AddressOf(ec, AddressOp.Load); return; } LocalTemporary localTemporary = new LocalTemporary(type); instance.Emit(ec); localTemporary.Store(ec); localTemporary.AddressOf(ec, AddressOp.Load); } else { instance.Emit(ec); if (boxInstance && ExpressionAnalyzer.RequiresBoxing(instance)) { ec.Emit(OpCodes.Box, type); } } } public TypeSpec GetStackType(EmitContext ec) { TypeSpec type = instance.Type; if (addressRequired) { return ReferenceContainer.MakeType(ec.Module, type); } if (type.IsStructOrEnum) { return ec.Module.Compiler.BuiltinTypes.Object; } return type; } } internal static class ExpressionAnalyzer { public static bool RequiresBoxing(Expression instance) { TypeSpec type = instance.Type; if (type.IsGenericParameter && !(instance is This) && TypeSpec.IsReferenceType(type)) { return true; } if (type.IsStructOrEnum) { return true; } return false; } public static bool IsInexpensiveLoad(Expression instance) { if (instance is Constant) { return instance.IsSideEffectFree; } if (RequiresBoxing(instance)) { return false; } if (instance is VariableReference variableReference) { return !variableReference.IsRef && !variableReference.IsHoisted; } if (instance is LocalTemporary) { return true; } if (instance is FieldExpr fieldExpr) { return fieldExpr.IsStatic || fieldExpr.InstanceExpression is This; } return false; } } internal class Outline { private bool declared_only; private bool show_private; private bool filter_obsolete; private IndentedTextWriter o; private Type t; private BindingFlags DefaultFlags { get { BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; if (declared_only) { bindingFlags |= BindingFlags.DeclaredOnly; } return bindingFlags; } } public Outline(Type t, TextWriter output, bool declared_only, bool show_private, bool filter_obsolete) { this.t = t; o = new IndentedTextWriter(output, "\t"); this.declared_only = declared_only; this.show_private = show_private; this.filter_obsolete = filter_obsolete; } public void OutlineType() { OutlineAttributes(); o.Write(GetTypeVisibility(t)); if (t.IsClass && !t.IsSubclassOf(typeof(MulticastDelegate))) { if (t.IsSealed) { o.Write(t.IsAbstract ? " static" : " sealed"); } else if (t.IsAbstract) { o.Write(" abstract"); } } o.Write(" "); o.Write(GetTypeKind(t)); o.Write(" "); MemberInfo[] inf = TypeGetInterfaces(t, declared_only); Type[] array = (Type[])Comparer.Sort(inf); Type baseType = t.BaseType; if (t.IsSubclassOf(typeof(MulticastDelegate))) { MethodInfo method = t.GetMethod("Invoke"); o.Write(FormatType(method.ReturnType)); o.Write(" "); o.Write(GetTypeName(t)); o.Write(" ("); OutlineParams(method.GetParameters()); o.Write(")"); WriteGenericConstraints(t.GetGenericArguments()); o.WriteLine(";"); return; } o.Write(GetTypeName(t)); bool flag; if ((((object)baseType != null && (object)baseType != typeof(object) && (object)baseType != typeof(ValueType)) || array.Length != 0) && !t.IsEnum) { flag = true; o.Write(" : "); if ((object)baseType != null && (object)baseType != typeof(object) && (object)baseType != typeof(ValueType)) { o.Write(FormatType(baseType)); flag = false; } Type[] array2 = array; foreach (Type type in array2) { if (!flag) { o.Write(", "); } flag = false; o.Write(FormatType(type)); } } if (t.IsEnum) { Type underlyingType = System.Enum.GetUnderlyingType(t); if ((object)underlyingType != typeof(int)) { o.Write(" : {0}", FormatType(underlyingType)); } } WriteGenericConstraints(t.GetGenericArguments()); o.WriteLine(" {"); o.Indent++; if (t.IsEnum) { bool flag2 = true; FieldInfo[] fields = t.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (!flag2) { o.WriteLine(","); } flag2 = false; o.Write(fieldInfo.Name); } o.WriteLine(); o.Indent--; o.WriteLine("}"); return; } flag = true; ConstructorInfo[] constructors = t.GetConstructors(DefaultFlags); foreach (ConstructorInfo constructorInfo in constructors) { if (ShowMember(constructorInfo)) { if (flag) { o.WriteLine(); } flag = false; OutlineConstructor(constructorInfo); o.WriteLine(); } } flag = true; MethodBase[] methods = t.GetMethods(DefaultFlags); MethodBase[] array3 = Comparer.Sort(methods); for (int l = 0; l < array3.Length; l++) { MethodInfo methodInfo = (MethodInfo)array3[l]; if (ShowMember(methodInfo) && (methodInfo.Attributes & MethodAttributes.SpecialName) == 0) { if (flag) { o.WriteLine(); } flag = false; OutlineMethod(methodInfo); o.WriteLine(); } } flag = true; MethodInfo[] methods2 = t.GetMethods(DefaultFlags); foreach (MethodInfo methodInfo2 in methods2) { if (ShowMember(methodInfo2) && (methodInfo2.Attributes & MethodAttributes.SpecialName) != MethodAttributes.PrivateScope && methodInfo2.Name.StartsWith("op_")) { if (flag) { o.WriteLine(); } flag = false; OutlineOperator(methodInfo2); o.WriteLine(); } } flag = true; PropertyInfo[] array4 = Comparer.Sort(t.GetProperties(DefaultFlags)); foreach (PropertyInfo propertyInfo in array4) { if ((propertyInfo.CanRead && ShowMember(propertyInfo.GetGetMethod(nonPublic: true))) || (propertyInfo.CanWrite && ShowMember(propertyInfo.GetSetMethod(nonPublic: true)))) { if (flag) { o.WriteLine(); } flag = false; OutlineProperty(propertyInfo); o.WriteLine(); } } flag = true; FieldInfo[] fields2 = t.GetFields(DefaultFlags); foreach (FieldInfo fieldInfo2 in fields2) { if (ShowMember(fieldInfo2)) { if (flag) { o.WriteLine(); } flag = false; OutlineField(fieldInfo2); o.WriteLine(); } } flag = true; EventInfo[] array5 = Comparer.Sort(t.GetEvents(DefaultFlags)); foreach (EventInfo eventInfo in array5) { if (ShowMember(eventInfo.GetAddMethod(nonPublic: true))) { if (flag) { o.WriteLine(); } flag = false; OutlineEvent(eventInfo); o.WriteLine(); } } flag = true; inf = t.GetNestedTypes(DefaultFlags); MemberInfo[] array6 = Comparer.Sort(inf); for (int num3 = 0; num3 < array6.Length; num3++) { Type mi = (Type)array6[num3]; if (ShowMember(mi)) { if (flag) { o.WriteLine(); } flag = false; new Outline(mi, o, declared_only, show_private, filter_obsolete).OutlineType(); } } o.Indent--; o.WriteLine("}"); } private void OutlineAttributes() { if (t.IsSerializable) { o.WriteLine("[Serializable]"); } if (t.IsDefined(typeof(FlagsAttribute), inherit: true)) { o.WriteLine("[Flags]"); } if (t.IsDefined(typeof(ObsoleteAttribute), inherit: true)) { o.WriteLine("[Obsolete]"); } } private void OutlineEvent(EventInfo ei) { MethodBase addMethod = ei.GetAddMethod(nonPublic: true); o.Write(GetMethodVisibility(addMethod)); o.Write("event "); o.Write(FormatType(ei.EventHandlerType)); o.Write(" "); o.Write(ei.Name); o.Write(";"); } private void OutlineConstructor(ConstructorInfo ci) { o.Write(GetMethodVisibility(ci)); o.Write(RemoveGenericArity(t.Name)); o.Write(" ("); OutlineParams(ci.GetParameters()); o.Write(");"); } private void OutlineProperty(PropertyInfo pi) { ParameterInfo[] indexParameters = pi.GetIndexParameters(); MethodBase getMethod = pi.GetGetMethod(nonPublic: true); MethodBase setMethod = pi.GetSetMethod(nonPublic: true); MethodBase methodBase = (((object)getMethod != null) ? getMethod : setMethod); if (pi.CanRead && pi.CanWrite && (getMethod.Attributes & MethodAttributes.MemberAccessMask) != (setMethod.Attributes & MethodAttributes.MemberAccessMask)) { if (getMethod.IsPublic) { methodBase = getMethod; } else if (setMethod.IsPublic) { methodBase = setMethod; } else if (getMethod.IsFamilyOrAssembly) { methodBase = getMethod; } else if (setMethod.IsFamilyOrAssembly) { methodBase = setMethod; } else if (getMethod.IsAssembly || getMethod.IsFamily) { methodBase = getMethod; } else if (setMethod.IsAssembly || setMethod.IsFamily) { methodBase = setMethod; } } o.Write(GetMethodVisibility(methodBase)); o.Write(GetMethodModifiers(methodBase)); o.Write(FormatType(pi.PropertyType)); o.Write(" "); if (indexParameters.Length == 0) { o.Write(pi.Name); } else { o.Write("this ["); OutlineParams(indexParameters); o.Write("]"); } o.WriteLine(" {"); o.Indent++; if ((object)getMethod != null && ShowMember(getMethod)) { if ((getMethod.Attributes & MethodAttributes.MemberAccessMask) != (methodBase.Attributes & MethodAttributes.MemberAccessMask)) { o.Write(GetMethodVisibility(getMethod)); } o.WriteLine("get;"); } if ((object)setMethod != null && ShowMember(setMethod)) { if ((setMethod.Attributes & MethodAttributes.MemberAccessMask) != (methodBase.Attributes & MethodAttributes.MemberAccessMask)) { o.Write(GetMethodVisibility(setMethod)); } o.WriteLine("set;"); } o.Indent--; o.Write("}"); } private void OutlineMethod(MethodInfo mi) { if (MethodIsExplicitIfaceImpl(mi)) { o.Write(FormatType(mi.ReturnType)); o.Write(" "); } else { o.Write(GetMethodVisibility(mi)); o.Write(GetMethodModifiers(mi)); o.Write(FormatType(mi.ReturnType)); o.Write(" "); } o.Write(mi.Name); o.Write(FormatGenericParams(mi.GetGenericArguments())); o.Write(" ("); OutlineParams(mi.GetParameters()); o.Write(")"); WriteGenericConstraints(mi.GetGenericArguments()); o.Write(";"); } private void OutlineOperator(MethodInfo mi) { o.Write(GetMethodVisibility(mi)); o.Write(GetMethodModifiers(mi)); if (mi.Name == "op_Explicit" || mi.Name == "op_Implicit") { o.Write(mi.Name.Substring(3).ToLower()); o.Write(" operator "); o.Write(FormatType(mi.ReturnType)); } else { o.Write(FormatType(mi.ReturnType)); o.Write(" operator "); o.Write(OperatorFromName(mi.Name)); } o.Write(" ("); OutlineParams(mi.GetParameters()); o.Write(");"); } private void OutlineParams(ParameterInfo[] pi) { int num = 0; foreach (ParameterInfo parameterInfo in pi) { if (parameterInfo.ParameterType.IsByRef) { o.Write(parameterInfo.IsOut ? "out " : "ref "); o.Write(FormatType(parameterInfo.ParameterType.GetElementType())); } else if (parameterInfo.IsDefined(typeof(ParamArrayAttribute), inherit: false)) { o.Write("params "); o.Write(FormatType(parameterInfo.ParameterType)); } else { o.Write(FormatType(parameterInfo.ParameterType)); } o.Write(" "); o.Write(parameterInfo.Name); if (num + 1 < pi.Length) { o.Write(", "); } num++; } } private void OutlineField(FieldInfo fi) { if (fi.IsPublic) { o.Write("public "); } if (fi.IsFamily) { o.Write("protected "); } if (fi.IsPrivate) { o.Write("private "); } if (fi.IsAssembly) { o.Write("internal "); } if (fi.IsLiteral) { o.Write("const "); } else if (fi.IsStatic) { o.Write("static "); } if (fi.IsInitOnly) { o.Write("readonly "); } o.Write(FormatType(fi.FieldType)); o.Write(" "); o.Write(fi.Name); if (fi.IsLiteral) { object value = fi.GetValue(this); o.Write(" = "); if (value is char) { o.Write("'{0}'", value); } else if (value is string) { o.Write("\"{0}\"", value); } else { o.Write(fi.GetValue(this)); } } o.Write(";"); } private static string GetMethodVisibility(MethodBase m) { if (m.DeclaringType.IsInterface) { return ""; } if (m.IsPublic) { return "public "; } if (m.IsFamily) { return "protected "; } if (m.IsPrivate) { return "private "; } if (m.IsAssembly) { return "internal "; } return null; } private static string GetMethodModifiers(MethodBase method) { if (method.IsStatic) { return "static "; } if (method.IsFinal) { if (method.IsVirtual) { return null; } return "sealed "; } if (method.IsVirtual && !method.DeclaringType.IsInterface) { if (method.IsAbstract) { return "abstract "; } return ((method.Attributes & MethodAttributes.VtableLayoutMask) != MethodAttributes.PrivateScope) ? "virtual " : "override "; } return null; } private static string GetTypeKind(Type t) { if (t.IsEnum) { return "enum"; } if (t.IsClass) { if (t.IsSubclassOf(typeof(MulticastDelegate))) { return "delegate"; } return "class"; } if (t.IsInterface) { return "interface"; } if (t.IsValueType) { return "struct"; } return "class"; } private static string GetTypeVisibility(Type t) { switch (t.Attributes & TypeAttributes.VisibilityMask) { case TypeAttributes.Public: case TypeAttributes.NestedPublic: return "public"; case TypeAttributes.NestedFamily: case TypeAttributes.NestedFamANDAssem: case TypeAttributes.VisibilityMask: return "protected"; default: return "internal"; } } private string FormatGenericParams(Type[] args) { StringBuilder stringBuilder = new StringBuilder(); if (args.Length == 0) { return ""; } stringBuilder.Append("<"); for (int i = 0; i < args.Length; i++) { if (i > 0) { stringBuilder.Append(","); } stringBuilder.Append(FormatType(args[i])); } stringBuilder.Append(">"); return stringBuilder.ToString(); } private string FormatType(Type t) { if ((object)t == null) { return ""; } string fullName = GetFullName(t); if (fullName == null) { return t.ToString(); } if (!fullName.StartsWith("System.")) { if (t.Namespace == this.t.Namespace) { return t.Name; } return fullName; } if (t.HasElementType) { Type elementType = t.GetElementType(); if (t.IsArray) { return FormatType(elementType) + " []"; } if (t.IsPointer) { return FormatType(elementType) + " *"; } if (t.IsByRef) { return "ref " + FormatType(elementType); } } switch (fullName) { case "System.Byte": return "byte"; case "System.SByte": return "sbyte"; case "System.Int16": return "short"; case "System.Int32": return "int"; case "System.Int64": return "long"; case "System.UInt16": return "ushort"; case "System.UInt32": return "uint"; case "System.UInt64": return "ulong"; case "System.Single": return "float"; case "System.Double": return "double"; case "System.Decimal": return "decimal"; case "System.Boolean": return "bool"; case "System.Char": return "char"; case "System.String": return "string"; case "System.Object": return "object"; case "System.Void": return "void"; default: if (fullName.LastIndexOf(".") == 6) { return fullName.Substring(7); } if (this.t.Namespace.StartsWith(t.Namespace + ".") || t.Namespace == this.t.Namespace) { return fullName.Substring(t.Namespace.Length + 1); } return fullName; } } public static string RemoveGenericArity(string name) { int num = 0; StringBuilder stringBuilder = new StringBuilder(); while (num < name.Length) { int num2 = name.IndexOf('`', num); if (num2 < 0) { stringBuilder.Append(name.Substring(num)); break; } stringBuilder.Append(name.Substring(num, num2 - num)); for (num2++; num2 < name.Length && char.IsNumber(name[num2]); num2++) { } num = num2; } return stringBuilder.ToString(); } private string GetTypeName(Type t) { StringBuilder stringBuilder = new StringBuilder(); GetTypeName(stringBuilder, t); return stringBuilder.ToString(); } private void GetTypeName(StringBuilder sb, Type t) { sb.Append(RemoveGenericArity(t.Name)); sb.Append(FormatGenericParams(t.GetGenericArguments())); } private string GetFullName(Type t) { StringBuilder stringBuilder = new StringBuilder(); GetFullName_recursed(stringBuilder, t, recursed: false); return stringBuilder.ToString(); } private void GetFullName_recursed(StringBuilder sb, Type t, bool recursed) { if (t.IsGenericParameter) { sb.Append(t.Name); return; } if ((object)t.DeclaringType != null) { GetFullName_recursed(sb, t.DeclaringType, recursed: true); sb.Append("."); } if (!recursed) { string text = t.Namespace; if (text != null && text != "") { sb.Append(text); sb.Append("."); } } GetTypeName(sb, t); } private void WriteGenericConstraints(Type[] args) { foreach (Type type in args) { bool flag = true; Type[] array = TypeGetInterfaces(type, declonly: true); GenericParameterAttributes genericParameterAttributes = type.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask; GenericParameterAttributes[] array2 = new GenericParameterAttributes[3] { GenericParameterAttributes.ReferenceTypeConstraint, GenericParameterAttributes.NotNullableValueTypeConstraint, GenericParameterAttributes.DefaultConstructorConstraint }; if ((object)type.BaseType != typeof(object) || array.Length != 0 || genericParameterAttributes != GenericParameterAttributes.None) { o.Write(" where "); o.Write(FormatType(type)); o.Write(" : "); } if ((object)type.BaseType != typeof(object)) { o.Write(FormatType(type.BaseType)); flag = false; } Type[] array3 = array; foreach (Type type2 in array3) { if (!flag) { o.Write(", "); } flag = false; o.Write(FormatType(type2)); } GenericParameterAttributes[] array4 = array2; foreach (GenericParameterAttributes genericParameterAttributes2 in array4) { if ((genericParameterAttributes & genericParameterAttributes2) != GenericParameterAttributes.None) { if (!flag) { o.Write(", "); } flag = false; switch (genericParameterAttributes2) { case GenericParameterAttributes.ReferenceTypeConstraint: o.Write("class"); break; case GenericParameterAttributes.NotNullableValueTypeConstraint: o.Write("struct"); break; case GenericParameterAttributes.DefaultConstructorConstraint: o.Write("new ()"); break; } } } } } private string OperatorFromName(string name) { return name switch { "op_UnaryPlus" => "+", "op_UnaryNegation" => "-", "op_LogicalNot" => "!", "op_OnesComplement" => "~", "op_Increment" => "++", "op_Decrement" => "--", "op_True" => "true", "op_False" => "false", "op_Addition" => "+", "op_Subtraction" => "-", "op_Multiply" => "*", "op_Division" => "/", "op_Modulus" => "%", "op_BitwiseAnd" => "&", "op_BitwiseOr" => "|", "op_ExclusiveOr" => "^", "op_LeftShift" => "<<", "op_RightShift" => ">>", "op_Equality" => "==", "op_Inequality" => "!=", "op_GreaterThan" => ">", "op_LessThan" => "<", "op_GreaterThanOrEqual" => ">=", "op_LessThanOrEqual" => "<=", _ => name, }; } private bool MethodIsExplicitIfaceImpl(MethodBase mb) { if (!mb.IsFinal || !mb.IsVirtual || !mb.IsPrivate) { return false; } return true; } private bool ShowMember(MemberInfo mi) { if (mi.MemberType == MemberTypes.Constructor && ((MethodBase)mi).IsStatic) { return false; } if (show_private) { return true; } if (filter_obsolete && mi.IsDefined(typeof(ObsoleteAttribute), inherit: false)) { return false; } switch (mi.MemberType) { case MemberTypes.Constructor: case MemberTypes.Method: { MethodBase methodBase = mi as MethodBase; if (methodBase.IsFamily || methodBase.IsPublic || methodBase.IsFamilyOrAssembly) { return true; } if (MethodIsExplicitIfaceImpl(methodBase)) { return true; } return false; } case MemberTypes.Field: { FieldInfo fieldInfo = mi as FieldInfo; if (fieldInfo.IsFamily || fieldInfo.IsPublic || fieldInfo.IsFamilyOrAssembly) { return true; } return false; } case MemberTypes.TypeInfo: case MemberTypes.NestedType: { Type type = mi as Type; switch (type.Attributes & TypeAttributes.VisibilityMask) { case TypeAttributes.Public: case TypeAttributes.NestedPublic: case TypeAttributes.NestedFamily: case TypeAttributes.VisibilityMask: return true; default: return false; } } default: return true; } } private static Type[] TypeGetInterfaces(Type t, bool declonly) { Type[] interfaces = t.GetInterfaces(); if (!declonly) { return interfaces; } if ((object)t.BaseType == null || interfaces.Length == 0) { return interfaces; } ArrayList arrayList = new ArrayList(); Type[] array = interfaces; foreach (Type type in array) { if (!type.IsAssignableFrom(t.BaseType)) { arrayList.Add(type); } } return (Type[])arrayList.ToArray(typeof(Type)); } } internal class Comparer : IComparer { private delegate int ComparerFunc(object a, object b); private ComparerFunc cmp; private static Comparer MemberInfoComparer = new Comparer(CompareMemberInfo); private static Comparer MethodBaseComparer = new Comparer(CompareMethodBase); private static Comparer PropertyInfoComparer = new Comparer(ComparePropertyInfo); private static Comparer EventInfoComparer = new Comparer(CompareEventInfo); private Comparer(ComparerFunc f) { cmp = f; } public int Compare(object a, object b) { return cmp(a, b); } private static int CompareType(object a, object b) { Type type = (Type)a; Type type2 = (Type)b; if (type.IsSubclassOf(typeof(MulticastDelegate)) != type2.IsSubclassOf(typeof(MulticastDelegate))) { return (!type.IsSubclassOf(typeof(MulticastDelegate))) ? 1 : (-1); } return string.Compare(type.Name, type2.Name); } private static int CompareMemberInfo(object a, object b) { return string.Compare(((MemberInfo)a).Name, ((MemberInfo)b).Name); } public static MemberInfo[] Sort(MemberInfo[] inf) { Array.Sort(inf, MemberInfoComparer); return inf; } private static int CompareMethodBase(object a, object b) { MethodBase methodBase = (MethodBase)a; MethodBase methodBase2 = (MethodBase)b; if (methodBase.IsStatic == methodBase2.IsStatic) { int num = CompareMemberInfo(a, b); if (num != 0) { return num; } ParameterInfo[] parameters = methodBase.GetParameters(); ParameterInfo[] parameters2 = methodBase2.GetParameters(); int num2 = Math.Min(parameters.Length, parameters2.Length); for (int i = 0; i < num2; i++) { if ((num = CompareType(parameters[i].ParameterType, parameters2[i].ParameterType)) != 0) { return num; } } return parameters.Length.CompareTo(parameters2.Length); } if (methodBase.IsStatic) { return -1; } return 1; } public static MethodBase[] Sort(MethodBase[] inf) { Array.Sort(inf, MethodBaseComparer); return inf; } private static int ComparePropertyInfo(object a, object b) { PropertyInfo propertyInfo = (PropertyInfo)a; PropertyInfo propertyInfo2 = (PropertyInfo)b; bool isStatic = (propertyInfo.CanRead ? propertyInfo.GetGetMethod(nonPublic: true) : propertyInfo.GetSetMethod(nonPublic: true)).IsStatic; bool isStatic2 = (propertyInfo2.CanRead ? propertyInfo2.GetGetMethod(nonPublic: true) : propertyInfo2.GetSetMethod(nonPublic: true)).IsStatic; if (isStatic == isStatic2) { return CompareMemberInfo(a, b); } if (isStatic) { return -1; } return 1; } public static PropertyInfo[] Sort(PropertyInfo[] inf) { Array.Sort(inf, PropertyInfoComparer); return inf; } private static int CompareEventInfo(object a, object b) { EventInfo eventInfo = (EventInfo)a; EventInfo eventInfo2 = (EventInfo)b; bool isStatic = eventInfo.GetAddMethod(nonPublic: true).IsStatic; bool isStatic2 = eventInfo2.GetAddMethod(nonPublic: true).IsStatic; if (isStatic == isStatic2) { return CompareMemberInfo(a, b); } if (isStatic) { return -1; } return 1; } public static EventInfo[] Sort(EventInfo[] inf) { Array.Sort(inf, EventInfoComparer); return inf; } } internal class Tuple : IEquatable> { public T1 Item1 { get; private set; } public T2 Item2 { get; private set; } public Tuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } public override int GetHashCode() { return Item1.GetHashCode() ^ Item2.GetHashCode(); } public bool Equals(Tuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2); } } internal class Tuple : IEquatable> { public T1 Item1 { get; private set; } public T2 Item2 { get; private set; } public T3 Item3 { get; private set; } public Tuple(T1 item1, T2 item2, T3 item3) { Item1 = item1; Item2 = item2; Item3 = item3; } public override int GetHashCode() { return Item1.GetHashCode() ^ Item2.GetHashCode() ^ Item3.GetHashCode(); } public bool Equals(Tuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) && EqualityComparer.Default.Equals(Item3, other.Item3); } } internal static class Tuple { public static Tuple Create(T1 item1, T2 item2) { return new Tuple(item1, item2); } public static Tuple Create(T1 item1, T2 item2, T3 item3) { return new Tuple(item1, item2, item3); } } internal abstract class CompletingExpression : ExpressionStatement { public static void AppendResults(List results, string prefix, IEnumerable names) { foreach (string name in names) { if (name != null && (prefix == null || name.StartsWith(prefix)) && !results.Contains(name)) { if (prefix != null) { results.Add(name.Substring(prefix.Length)); } else { results.Add(name); } } } } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { return null; } public override void EmitStatement(EmitContext ec) { } public override void Emit(EmitContext ec) { } } internal class CompletionSimpleName : CompletingExpression { public string Prefix; public CompletionSimpleName(string prefix, Location l) { loc = l; Prefix = prefix; } protected override Expression DoResolve(ResolveContext ec) { List list = new List(); ec.CurrentMemberDefinition.GetCompletionStartingWith(Prefix, list); throw new CompletionResult(Prefix, (from l in list.Distinct() select l.Substring(Prefix.Length)).ToArray()); } protected override void CloneTo(CloneContext clonectx, Expression t) { } } internal class CompletionMemberAccess : CompletingExpression { private Expression expr; private string partial_name; private TypeArguments targs; public CompletionMemberAccess(Expression e, string partial_name, Location l) { expr = e; loc = l; this.partial_name = partial_name; } public CompletionMemberAccess(Expression e, string partial_name, TypeArguments targs, Location l) { expr = e; loc = l; this.partial_name = partial_name; this.targs = targs; } protected override Expression DoResolve(ResolveContext rc) { if (expr is SimpleName simpleName) { SessionReportPrinter sessionReportPrinter = new SessionReportPrinter(); ReportPrinter printer = rc.Report.SetPrinter(sessionReportPrinter); try { expr = simpleName.LookupNameExpression(rc, MemberLookupRestrictions.ExactArity | MemberLookupRestrictions.ReadAccess); } finally { rc.Report.SetPrinter(printer); } if (sessionReportPrinter.ErrorsCount != 0) { return null; } if (expr is VariableReference || expr is ConstantExpr || expr is TransparentMemberAccess) { expr = expr.Resolve(rc); } else if (expr is TypeParameterExpr) { expr.Error_UnexpectedKind(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type, simpleName.Location); expr = null; } } else { expr = expr.Resolve(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type); } if (expr == null) { return null; } TypeSpec typeSpec = expr.Type; if (typeSpec.IsPointer || typeSpec.Kind == MemberKind.Void || typeSpec == InternalType.NullLiteral || typeSpec == InternalType.AnonymousMethod) { expr.Error_OperatorCannotBeApplied(rc, loc, ".", typeSpec); return null; } if (targs != null && !targs.Resolve(rc, allowUnbound: true)) { return null; } List list = new List(); if (expr is NamespaceExpression namespaceExpression) { string prefix = ((partial_name != null) ? (namespaceExpression.Namespace.Name + "." + partial_name) : namespaceExpression.Namespace.Name); rc.CurrentMemberDefinition.GetCompletionStartingWith(prefix, list); if (partial_name != null) { list = list.Select((string l) => l.Substring(partial_name.Length)).ToList(); } } else { IEnumerable names = from l in MemberCache.GetCompletitionMembers(rc, typeSpec, partial_name) select l.Name; CompletingExpression.AppendResults(list, partial_name, names); } throw new CompletionResult((partial_name == null) ? "" : partial_name, list.Distinct().ToArray()); } protected override void CloneTo(CloneContext clonectx, Expression t) { CompletionMemberAccess completionMemberAccess = (CompletionMemberAccess)t; if (targs != null) { completionMemberAccess.targs = targs.Clone(); } completionMemberAccess.expr = expr.Clone(clonectx); } } internal class CompletionElementInitializer : CompletingExpression { private string partial_name; public CompletionElementInitializer(string partial_name, Location l) { this.partial_name = partial_name; loc = l; } protected override Expression DoResolve(ResolveContext ec) { IList completitionMembers = MemberCache.GetCompletitionMembers(ec, ec.CurrentInitializerVariable.Type, partial_name); List list = (from l in completitionMembers where (l.Kind & (MemberKind.Field | MemberKind.Property)) != 0 select l.Name).ToList(); if (partial_name != null) { List list2 = new List(); CompletingExpression.AppendResults(list2, partial_name, list); list = list2; } throw new CompletionResult((partial_name == null) ? "" : partial_name, list.Distinct().ToArray()); } protected override void CloneTo(CloneContext clonectx, Expression t) { } } internal class EmptyCompletion : CompletingExpression { protected override void CloneTo(CloneContext clonectx, Expression target) { } protected override Expression DoResolve(ResolveContext rc) { throw new CompletionResult("", new string[0]); } } internal class Const : FieldBase { private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW; public Const(TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base(parent, type, mod_flags, Modifiers.AccessibilityMask | Modifiers.NEW, name, attrs) { base.ModFlags |= Modifiers.STATIC; } public override bool Define() { if (!base.Define()) { return false; } if (!member_type.IsConstantCompatible) { Error_InvalidConstantType(member_type, base.Location, base.Report); } FieldAttributes fieldAttributes = FieldAttributes.Static | ModifiersExtensions.FieldAttr(base.ModFlags); fieldAttributes = ((member_type.BuiltinType != BuiltinTypeSpec.Type.Decimal) ? (fieldAttributes | FieldAttributes.Literal) : (fieldAttributes | FieldAttributes.InitOnly)); FieldBuilder = Parent.TypeBuilder.DefineField(base.Name, base.MemberType.GetMetaInfo(), fieldAttributes); spec = new ConstSpec(Parent.Definition, this, base.MemberType, FieldBuilder, base.ModFlags, initializer); Parent.MemberCache.AddMember(spec); if ((fieldAttributes & FieldAttributes.InitOnly) != FieldAttributes.PrivateScope) { Parent.PartialContainer.RegisterFieldForInitialization(this, new FieldInitializer(this, initializer, base.Location)); } if (declarators != null) { TypeExpression type = new TypeExpression(base.MemberType, base.TypeExpression.Location); foreach (FieldDeclarator declarator in declarators) { Const obj = new Const(Parent, type, base.ModFlags & ~Modifiers.STATIC, new MemberName(declarator.Name.Value, declarator.Name.Location), base.OptAttributes); obj.initializer = declarator.Initializer; ((ConstInitializer)obj.initializer).Name = declarator.Name.Value; obj.Define(); Parent.PartialContainer.Members.Add(obj); } } return true; } public void DefineValue() { ResolveContext rc = new ResolveContext(this); ((ConstSpec)spec).GetConstant(rc); } public override void Emit() { Constant constant = ((ConstSpec)spec).Value as Constant; if (constant.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { Module.PredefinedAttributes.DecimalConstant.EmitAttribute(FieldBuilder, (decimal)constant.GetValue(), constant.Location); } else { FieldBuilder.SetConstant(constant.GetValue()); } base.Emit(); } public static void Error_InvalidConstantType(TypeSpec t, Location loc, Report Report) { if (t.IsGenericParameter) { Report.Error(1959, loc, "Type parameter `{0}' cannot be declared const", t.GetSignatureForError()); } else { Report.Error(283, loc, "The type `{0}' cannot be declared const", t.GetSignatureForError()); } } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void PrepareEmit() { base.PrepareEmit(); DefineValue(); } } internal class ConstSpec : FieldSpec { private Expression value; public Expression Value => value; public ConstSpec(TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo fi, Modifiers mod, Expression value) : base(declaringType, definition, memberType, fi, mod) { this.value = value; } public Constant GetConstant(ResolveContext rc) { if (value.eclass != ExprClass.Value) { value = value.Resolve(rc); } return (Constant)value; } } internal class ConstInitializer : ShimExpression { private bool in_transit; private readonly FieldBase field; public string Name { get; set; } public ConstInitializer(FieldBase field, Expression value, Location loc) : base(value) { base.loc = loc; this.field = field; } protected override Expression DoResolve(ResolveContext unused) { if (type != null) { return expr; } ResolveContext.Options options = ResolveContext.Options.ConstantScope; if (field is EnumMember) { options |= ResolveContext.Options.EnumScope; } ResolveContext rc = new ResolveContext(field, options); expr = DoResolveInitializer(rc); type = expr.Type; return expr; } protected virtual Expression DoResolveInitializer(ResolveContext rc) { if (in_transit) { field.Compiler.Report.Error(110, expr.Location, "The evaluation of the constant value for `{0}' involves a circular definition", GetSignatureForError()); expr = null; } else { in_transit = true; expr = expr.Resolve(rc); } in_transit = false; if (expr != null) { Constant constant = expr as Constant; if (constant != null) { constant = field.ConvertInitializer(rc, constant); } if (constant == null && !(expr is DefaultLiteralExpression)) { if (TypeSpec.IsReferenceType(field.MemberType)) { Error_ConstantCanBeInitializedWithNullOnly(rc, field.MemberType, expr.Location, GetSignatureForError()); } else if (!(expr is Constant)) { Error_ExpressionMustBeConstant(rc, expr.Location, GetSignatureForError()); } else { expr.Error_ValueCannotBeConverted(rc, field.MemberType, expl: false); } } expr = constant; } if (expr == null) { expr = New.Constantify(field.MemberType, base.Location); if (expr == null) { expr = Constant.CreateConstantFromValue(field.MemberType, null, base.Location); } expr = expr.Resolve(rc); } return expr; } public override string GetSignatureForError() { if (Name == null) { return field.GetSignatureForError(); } return field.Parent.GetSignatureForError() + "." + Name; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class Constant : Expression { private static readonly NumberFormatInfo nfi = CultureInfo.InvariantCulture.NumberFormat; public abstract bool IsDefaultValue { get; } public abstract bool IsNegative { get; } public virtual bool IsLiteral => false; public virtual bool IsOneInteger => false; public override bool IsSideEffectFree => true; public virtual bool IsZeroInteger => false; protected Constant(Location loc) { base.loc = loc; } public override string ToString() { return GetType().Name + " (" + GetValueAsLiteral() + ")"; } public abstract object GetValue(); public abstract long GetValueAsLong(); public abstract string GetValueAsLiteral(); public virtual object GetTypedValue() { return GetValue(); } public override void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec target, bool expl) { if (!expl && IsLiteral && type.BuiltinType != BuiltinTypeSpec.Type.Double && BuiltinTypeSpec.IsPrimitiveTypeOrDecimal(target) && BuiltinTypeSpec.IsPrimitiveTypeOrDecimal(type)) { ec.Report.Error(31, loc, "Constant value `{0}' cannot be converted to a `{1}'", GetValueAsLiteral(), target.GetSignatureForError()); } else { base.Error_ValueCannotBeConverted(ec, target, expl); } } public Constant ImplicitConversionRequired(ResolveContext ec, TypeSpec type) { Constant constant = ConvertImplicitly(type); if (constant == null) { Error_ValueCannotBeConverted(ec, type, expl: false); } return constant; } public override bool ContainsEmitWithAwait() { return false; } public virtual Constant ConvertImplicitly(TypeSpec type) { if (base.type == type) { return this; } if (!Convert.ImplicitNumericConversionExists(base.type, type)) { return null; } bool error; object v = ChangeType(GetValue(), type, out error); if (error) { throw new InternalErrorException("Missing constant conversion between `{0}' and `{1}'", base.Type.GetSignatureForError(), type.GetSignatureForError()); } return CreateConstantFromValue(type, v, loc); } public static Constant CreateConstantFromValue(TypeSpec t, object v, Location loc) { switch (t.BuiltinType) { case BuiltinTypeSpec.Type.Int: return new IntConstant(t, (int)v, loc); case BuiltinTypeSpec.Type.String: return new StringConstant(t, (string)v, loc); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(t, (uint)v, loc); case BuiltinTypeSpec.Type.Long: return new LongConstant(t, (long)v, loc); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(t, (ulong)v, loc); case BuiltinTypeSpec.Type.Float: return new FloatConstant(t, (float)v, loc); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(t, (double)v, loc); case BuiltinTypeSpec.Type.Short: return new ShortConstant(t, (short)v, loc); case BuiltinTypeSpec.Type.UShort: return new UShortConstant(t, (ushort)v, loc); case BuiltinTypeSpec.Type.SByte: return new SByteConstant(t, (sbyte)v, loc); case BuiltinTypeSpec.Type.Byte: return new ByteConstant(t, (byte)v, loc); case BuiltinTypeSpec.Type.Char: return new CharConstant(t, (char)v, loc); case BuiltinTypeSpec.Type.FirstPrimitive: return new BoolConstant(t, (bool)v, loc); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(t, (decimal)v, loc); default: if (t.IsEnum) { TypeSpec underlyingType = EnumSpec.GetUnderlyingType(t); return new EnumConstant(CreateConstantFromValue(underlyingType, v, loc), t); } if (v == null) { if (t.IsNullableType) { return LiftedNull.Create(t, loc); } if (TypeSpec.IsReferenceType(t)) { return new NullConstant(t, loc); } } return null; } } public static Constant ExtractConstantFromValue(TypeSpec t, object v, Location loc) { switch (t.BuiltinType) { case BuiltinTypeSpec.Type.Int: if (v is int) { return new IntConstant(t, (int)v, loc); } break; case BuiltinTypeSpec.Type.String: if (v is string) { return new StringConstant(t, (string)v, loc); } break; case BuiltinTypeSpec.Type.UInt: if (v is uint) { return new UIntConstant(t, (uint)v, loc); } break; case BuiltinTypeSpec.Type.Long: if (v is long) { return new LongConstant(t, (long)v, loc); } break; case BuiltinTypeSpec.Type.ULong: if (v is ulong) { return new ULongConstant(t, (ulong)v, loc); } break; case BuiltinTypeSpec.Type.Float: if (v is float) { return new FloatConstant(t, (float)v, loc); } break; case BuiltinTypeSpec.Type.Double: if (v is double) { return new DoubleConstant(t, (double)v, loc); } break; case BuiltinTypeSpec.Type.Short: if (v is short) { return new ShortConstant(t, (short)v, loc); } break; case BuiltinTypeSpec.Type.UShort: if (v is ushort) { return new UShortConstant(t, (ushort)v, loc); } break; case BuiltinTypeSpec.Type.SByte: if (v is sbyte) { return new SByteConstant(t, (sbyte)v, loc); } break; case BuiltinTypeSpec.Type.Byte: if (v is byte) { return new ByteConstant(t, (byte)v, loc); } break; case BuiltinTypeSpec.Type.Char: if (v is char) { return new CharConstant(t, (char)v, loc); } break; case BuiltinTypeSpec.Type.FirstPrimitive: if (v is bool) { return new BoolConstant(t, (bool)v, loc); } break; case BuiltinTypeSpec.Type.Decimal: if (v is decimal) { return new DecimalConstant(t, (decimal)v, loc); } break; } if (t.IsEnum) { TypeSpec underlyingType = EnumSpec.GetUnderlyingType(t); return new EnumConstant(CreateConstantFromValue(underlyingType, v, loc), t); } if (v == null) { if (t.IsNullableType) { return LiftedNull.Create(t, loc); } if (TypeSpec.IsReferenceType(t)) { return new NullConstant(t, loc); } } return null; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(this)); arguments.Add(new Argument(new TypeOf(type, loc))); return CreateExpressionFactoryCall(ec, "Constant", arguments); } public abstract Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type); private static object ChangeType(object value, TypeSpec targetType, out bool error) { if (!(value is IConvertible convertible)) { error = true; return null; } error = false; try { switch (targetType.BuiltinType) { case BuiltinTypeSpec.Type.FirstPrimitive: return convertible.ToBoolean(nfi); case BuiltinTypeSpec.Type.Byte: return convertible.ToByte(nfi); case BuiltinTypeSpec.Type.Char: return convertible.ToChar(nfi); case BuiltinTypeSpec.Type.Short: return convertible.ToInt16(nfi); case BuiltinTypeSpec.Type.Int: return convertible.ToInt32(nfi); case BuiltinTypeSpec.Type.Long: return convertible.ToInt64(nfi); case BuiltinTypeSpec.Type.SByte: return convertible.ToSByte(nfi); case BuiltinTypeSpec.Type.Decimal: if ((object)convertible.GetType() == typeof(char)) { return (decimal)convertible.ToInt32(nfi); } return convertible.ToDecimal(nfi); case BuiltinTypeSpec.Type.Double: if ((object)convertible.GetType() == typeof(char)) { return (double)convertible.ToInt32(nfi); } return convertible.ToDouble(nfi); case BuiltinTypeSpec.Type.Float: if ((object)convertible.GetType() == typeof(char)) { return (float)convertible.ToInt32(nfi); } return convertible.ToSingle(nfi); case BuiltinTypeSpec.Type.String: return convertible.ToString(nfi); case BuiltinTypeSpec.Type.UShort: return convertible.ToUInt16(nfi); case BuiltinTypeSpec.Type.UInt: return convertible.ToUInt32(nfi); case BuiltinTypeSpec.Type.ULong: return convertible.ToUInt64(nfi); case BuiltinTypeSpec.Type.Object: return value; case BuiltinTypeSpec.Type.IntPtr: case BuiltinTypeSpec.Type.UIntPtr: case BuiltinTypeSpec.Type.Dynamic: break; } } catch { } error = true; return null; } protected override Expression DoResolve(ResolveContext rc) { return this; } public Constant Reduce(ResolveContext ec, TypeSpec target_type) { try { return TryReduceConstant(ec, target_type); } catch (OverflowException) { if (ec.ConstantCheckState && base.Type.BuiltinType != BuiltinTypeSpec.Type.Decimal) { ec.Report.Error(221, loc, "Constant value `{0}' cannot be converted to a `{1}' (use `unchecked' syntax to override)", GetValueAsLiteral(), target_type.GetSignatureForError()); } else { Error_ValueCannotBeConverted(ec, target_type, expl: false); } return New.Constantify(target_type, loc); } } public Constant TryReduce(ResolveContext rc, TypeSpec targetType) { try { return TryReduceConstant(rc, targetType); } catch (OverflowException) { return null; } } private Constant TryReduceConstant(ResolveContext ec, TypeSpec target_type) { if (base.Type == target_type) { if (IsLiteral) { return CreateConstantFromValue(target_type, GetValue(), loc); } return this; } if (target_type.IsEnum) { Constant constant = TryReduceConstant(ec, EnumSpec.GetUnderlyingType(target_type)); if (constant == null) { return null; } return new EnumConstant(constant, target_type); } return ConvertExplicitly(ec.ConstantCheckState, target_type); } public bool IsDefaultInitializer(TypeSpec type) { if (type == base.Type) { return IsDefaultValue; } return this is NullLiteral; } public override void EmitSideEffect(EmitContext ec) { } public sealed override Expression Clone(CloneContext clonectx) { return this; } protected override void CloneTo(CloneContext clonectx, Expression target) { throw new NotSupportedException("should not be reached"); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Constant(GetTypedValue(), type.GetMetaInfo()); } public new bool Resolve(ResolveContext rc) { return true; } } internal abstract class IntegralConstant : Constant { protected IntegralConstant(TypeSpec type, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Value; } public override void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec target, bool expl) { try { ConvertExplicitly(in_checked_context: true, target); base.Error_ValueCannotBeConverted(ec, target, expl); } catch { ec.Report.Error(31, loc, "Constant value `{0}' cannot be converted to a `{1}'", GetValueAsLiteral(), target.GetSignatureForError()); } } public override string GetValueAsLiteral() { return GetValue().ToString(); } public abstract Constant Increment(); } internal class BoolConstant : Constant { public readonly bool Value; public override bool IsDefaultValue => !Value; public override bool IsNegative => false; public override bool IsZeroInteger => !Value; public BoolConstant(BuiltinTypes types, bool val, Location loc) : this(types.Bool, val, loc) { } public BoolConstant(TypeSpec type, bool val, Location loc) : base(loc) { eclass = ExprClass.Value; base.type = type; Value = val; } public override object GetValue() { return Value; } public override string GetValueAsLiteral() { return Value ? "true" : "false"; } public override long GetValueAsLong() { return Value ? 1 : 0; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { if (Value) { ec.EmitInt(1); } else { ec.EmitInt(0); } } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { return null; } } internal class ByteConstant : IntegralConstant { public readonly byte Value; public override bool IsDefaultValue => Value == 0; public override bool IsOneInteger => Value == 1; public override bool IsNegative => false; public override bool IsZeroInteger => Value == 0; public ByteConstant(BuiltinTypes types, byte v, Location loc) : this(types.Byte, v, loc) { } public ByteConstant(TypeSpec type, byte v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt(Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new ByteConstant(type, checked((byte)(Value + 1)), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: if (in_checked_context && Value > 127) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: return new ShortConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UShort: return new UShortConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Int: return new IntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)(int)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.Char: return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class CharConstant : Constant { public readonly char Value; public override bool IsDefaultValue => Value == '\0'; public override bool IsNegative => false; public override bool IsZeroInteger => Value == '\0'; public CharConstant(BuiltinTypes types, char v, Location loc) : this(types.Char, v, loc) { } public CharConstant(TypeSpec type, char v, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Value; Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt(Value); } private static string descape(char c) { return c switch { '\a' => "\\a", '\b' => "\\b", '\n' => "\\n", '\t' => "\\t", '\v' => "\\v", '\r' => "\\r", '\\' => "\\\\", '\f' => "\\f", '\0' => "\\0", '"' => "\\\"", '\'' => "\\'", _ => c.ToString(), }; } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override string GetValueAsLiteral() { return "\"" + descape(Value) + "\""; } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < '\0' || Value > 'ÿ')) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && Value > '\u007f') { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && Value > '翿') { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.Int: return new IntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)(int)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class SByteConstant : IntegralConstant { public readonly sbyte Value; public override bool IsDefaultValue => Value == 0; public override bool IsNegative => Value < 0; public override bool IsOneInteger => Value == 1; public override bool IsZeroInteger => Value == 0; public SByteConstant(BuiltinTypes types, sbyte v, Location loc) : this(types.SByte, v, loc) { } public SByteConstant(TypeSpec type, sbyte v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt(Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new SByteConstant(type, checked((sbyte)(Value + 1)), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.Short: return new ShortConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.Int: return new IntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new ULongConstant(target_type, (ulong)Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class ShortConstant : IntegralConstant { public readonly short Value; public override bool IsDefaultValue => Value == 0; public override bool IsZeroInteger => Value == 0; public override bool IsNegative => Value < 0; public override bool IsOneInteger => Value == 1; public ShortConstant(BuiltinTypes types, short v, Location loc) : this(types.Short, v, loc) { } public ShortConstant(TypeSpec type, short v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt(Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new ShortConstant(type, checked((short)(Value + 1)), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < 0 || Value > 255)) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && (Value < -128 || Value > 127)) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.Int: return new IntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new ULongConstant(target_type, (ulong)Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class UShortConstant : IntegralConstant { public readonly ushort Value; public override bool IsDefaultValue => Value == 0; public override bool IsNegative => false; public override bool IsOneInteger => Value == 1; public override bool IsZeroInteger => Value == 0; public UShortConstant(BuiltinTypes types, ushort v, Location loc) : this(types.UShort, v, loc) { } public UShortConstant(TypeSpec type, ushort v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt(Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new UShortConstant(type, checked((ushort)(Value + 1)), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && Value > 255) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && Value > 127) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && Value > 32767) { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.Int: return new IntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)(int)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && Value > ushort.MaxValue) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class IntConstant : IntegralConstant { public readonly int Value; public override bool IsDefaultValue => Value == 0; public override bool IsNegative => Value < 0; public override bool IsOneInteger => Value == 1; public override bool IsZeroInteger => Value == 0; public IntConstant(BuiltinTypes types, int v, Location loc) : this(types.Int, v, loc) { } public IntConstant(TypeSpec type, int v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt(Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new IntConstant(type, checked(Value + 1), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < 0 || Value > 255)) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && (Value < -128 || Value > 127)) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && (Value < -32768 || Value > 32767)) { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && (Value < 0 || Value > 65535)) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && (long)Value < 0L) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new ULongConstant(target_type, (ulong)Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && (Value < 0 || Value > 65535)) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } public override Constant ConvertImplicitly(TypeSpec type) { if (base.type == type) { return this; } Constant constant = TryImplicitIntConversion(type); if (constant != null) { return constant; } return base.ConvertImplicitly(type); } private Constant TryImplicitIntConversion(TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: if (Value >= -128 && Value <= 127) { return new SByteConstant(target_type, (sbyte)Value, loc); } break; case BuiltinTypeSpec.Type.Byte: if (Value >= 0 && Value <= 255) { return new ByteConstant(target_type, (byte)Value, loc); } break; case BuiltinTypeSpec.Type.Short: if (Value >= -32768 && Value <= 32767) { return new ShortConstant(target_type, (short)Value, loc); } break; case BuiltinTypeSpec.Type.UShort: if (Value >= 0 && Value <= 65535) { return new UShortConstant(target_type, (ushort)Value, loc); } break; case BuiltinTypeSpec.Type.UInt: if (Value >= 0) { return new UIntConstant(target_type, (uint)Value, loc); } break; case BuiltinTypeSpec.Type.ULong: if (Value >= 0) { return new ULongConstant(target_type, (ulong)Value, loc); } break; case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, loc); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, loc); } return null; } } internal class UIntConstant : IntegralConstant { public readonly uint Value; public override bool IsDefaultValue => Value == 0; public override bool IsNegative => false; public override bool IsOneInteger => Value == 1; public override bool IsZeroInteger => Value == 0; public UIntConstant(BuiltinTypes types, uint v, Location loc) : this(types.UInt, v, loc) { } public UIntConstant(TypeSpec type, uint v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitInt((int)Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new UIntConstant(type, checked(Value + 1), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < 0 || Value > 255)) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && (long)Value > 127L) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && (long)Value > 32767L) { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && (Value < 0 || Value > 65535)) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.Int: if (in_checked_context && Value > int.MaxValue) { throw new OverflowException(); } return new IntConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && (Value < 0 || Value > 65535)) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class LongConstant : IntegralConstant { public readonly long Value; public override bool IsDefaultValue => Value == 0; public override bool IsNegative => Value < 0; public override bool IsOneInteger => Value == 1; public override bool IsZeroInteger => Value == 0; public LongConstant(BuiltinTypes types, long v, Location loc) : this(types.Long, v, loc) { } public LongConstant(TypeSpec type, long v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitLong(Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return Value; } public override Constant Increment() { return new LongConstant(type, checked(Value + 1), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < 0 || Value > 255)) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && (Value < -128 || Value > 127)) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && (Value < -32768 || Value > 32767)) { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && (Value < 0 || Value > 65535)) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.Int: if (in_checked_context && (Value < int.MinValue || Value > int.MaxValue)) { throw new OverflowException(); } return new IntConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && (Value < 0 || Value > uint.MaxValue)) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)Value, base.Location); case BuiltinTypeSpec.Type.ULong: if (in_checked_context && Value < 0) { throw new OverflowException(); } return new ULongConstant(target_type, (ulong)Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && (Value < 0 || Value > 65535)) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } public override Constant ConvertImplicitly(TypeSpec type) { if (Value >= 0 && type.BuiltinType == BuiltinTypeSpec.Type.ULong) { return new ULongConstant(type, (ulong)Value, loc); } return base.ConvertImplicitly(type); } } internal class ULongConstant : IntegralConstant { public readonly ulong Value; public override bool IsDefaultValue => Value == 0; public override bool IsNegative => false; public override bool IsOneInteger => Value == 1; public override bool IsZeroInteger => Value == 0; public ULongConstant(BuiltinTypes types, ulong v, Location loc) : this(types.ULong, v, loc) { } public ULongConstant(TypeSpec type, ulong v, Location loc) : base(type, loc) { Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.EmitLong((long)Value); } public override object GetValue() { return Value; } public override long GetValueAsLong() { return (long)Value; } public override Constant Increment() { return new ULongConstant(type, checked(Value + 1), loc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && Value > 255) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && Value > 127) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && Value > 32767) { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && Value > 65535) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.Int: if (in_checked_context && Value > uint.MaxValue) { throw new OverflowException(); } return new IntConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && Value > uint.MaxValue) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)Value, base.Location); case BuiltinTypeSpec.Type.Long: if (in_checked_context && Value > long.MaxValue) { throw new OverflowException(); } return new LongConstant(target_type, (long)Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && Value > 65535) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, Value, base.Location); default: return null; } } } internal class FloatConstant : Constant { public readonly double DoubleValue; public float Value => (float)DoubleValue; public override bool IsDefaultValue => Value == 0f; public override bool IsNegative => Value < 0f; public FloatConstant(BuiltinTypes types, double v, Location loc) : this(types.Float, v, loc) { } public FloatConstant(TypeSpec type, double v, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Value; DoubleValue = v; } public override Constant ConvertImplicitly(TypeSpec type) { if (type.BuiltinType == BuiltinTypeSpec.Type.Double) { return new DoubleConstant(type, DoubleValue, loc); } return base.ConvertImplicitly(type); } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Ldc_R4, Value); } public override object GetValue() { return Value; } public override string GetValueAsLiteral() { return Value.ToString(CultureInfo.InvariantCulture); } public override long GetValueAsLong() { throw new NotSupportedException(); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < 0f || Value > 255f || float.IsNaN(Value))) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)DoubleValue, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && (Value < -128f || Value > 127f || float.IsNaN(Value))) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)DoubleValue, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && (Value < -32768f || Value > 32767f || float.IsNaN(Value))) { throw new OverflowException(); } return new ShortConstant(target_type, (short)DoubleValue, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && (Value < 0f || Value > 65535f || float.IsNaN(Value))) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)DoubleValue, base.Location); case BuiltinTypeSpec.Type.Int: if (in_checked_context && (Value < -2.1474836E+09f || Value > 2.1474836E+09f || float.IsNaN(Value))) { throw new OverflowException(); } return new IntConstant(target_type, (int)DoubleValue, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && (Value < 0f || Value > 4.2949673E+09f || float.IsNaN(Value))) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)DoubleValue, base.Location); case BuiltinTypeSpec.Type.Long: if (in_checked_context && (Value < -9.223372E+18f || Value > 9.223372E+18f || float.IsNaN(Value))) { throw new OverflowException(); } return new LongConstant(target_type, (long)DoubleValue, base.Location); case BuiltinTypeSpec.Type.ULong: if (in_checked_context && (Value < 0f || Value > 1.8446744E+19f || float.IsNaN(Value))) { throw new OverflowException(); } return new ULongConstant(target_type, (ulong)DoubleValue, base.Location); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(target_type, DoubleValue, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && (Value < 0f || Value > 65535f || float.IsNaN(Value))) { throw new OverflowException(); } return new CharConstant(target_type, (char)DoubleValue, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, (decimal)DoubleValue, base.Location); default: return null; } } } internal class DoubleConstant : Constant { public readonly double Value; public override bool IsDefaultValue => Value == 0.0; public override bool IsNegative => Value < 0.0; public DoubleConstant(BuiltinTypes types, double v, Location loc) : this(types.Double, v, loc) { } public DoubleConstant(TypeSpec type, double v, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Value; Value = v; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { enc.Encode(Value); } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Ldc_R8, Value); } public override object GetValue() { return Value; } public override string GetValueAsLiteral() { double value = Value; return value.ToString(CultureInfo.InvariantCulture); } public override long GetValueAsLong() { throw new NotSupportedException(); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: if (in_checked_context && (Value < 0.0 || Value > 255.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new ByteConstant(target_type, (byte)Value, base.Location); case BuiltinTypeSpec.Type.SByte: if (in_checked_context && (Value < -128.0 || Value > 127.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new SByteConstant(target_type, (sbyte)Value, base.Location); case BuiltinTypeSpec.Type.Short: if (in_checked_context && (Value < -32768.0 || Value > 32767.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new ShortConstant(target_type, (short)Value, base.Location); case BuiltinTypeSpec.Type.UShort: if (in_checked_context && (Value < 0.0 || Value > 65535.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new UShortConstant(target_type, (ushort)Value, base.Location); case BuiltinTypeSpec.Type.Int: if (in_checked_context && (Value < -2147483648.0 || Value > 2147483647.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new IntConstant(target_type, (int)Value, base.Location); case BuiltinTypeSpec.Type.UInt: if (in_checked_context && (Value < 0.0 || Value > 4294967295.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new UIntConstant(target_type, (uint)Value, base.Location); case BuiltinTypeSpec.Type.Long: if (in_checked_context && (Value < -9.223372036854776E+18 || Value > 9.223372036854776E+18 || double.IsNaN(Value))) { throw new OverflowException(); } return new LongConstant(target_type, (long)Value, base.Location); case BuiltinTypeSpec.Type.ULong: if (in_checked_context && (Value < 0.0 || Value > 1.8446744073709552E+19 || double.IsNaN(Value))) { throw new OverflowException(); } return new ULongConstant(target_type, (ulong)Value, base.Location); case BuiltinTypeSpec.Type.Float: return new FloatConstant(target_type, (float)Value, base.Location); case BuiltinTypeSpec.Type.Char: if (in_checked_context && (Value < 0.0 || Value > 65535.0 || double.IsNaN(Value))) { throw new OverflowException(); } return new CharConstant(target_type, (char)Value, base.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(target_type, (decimal)Value, base.Location); default: return null; } } } internal class DecimalConstant : Constant { public readonly decimal Value; public override bool IsDefaultValue => Value == 0m; public override bool IsNegative => Value < 0m; public DecimalConstant(BuiltinTypes types, decimal d, Location loc) : this(types.Decimal, d, loc) { } public DecimalConstant(TypeSpec type, decimal d, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Value; Value = d; } public override void Emit(EmitContext ec) { int[] bits = decimal.GetBits(Value); int num = (bits[3] >> 16) & 0xFF; MethodSpec methodSpec; if (num == 0) { if (Value <= 2147483647m && Value >= -2147483648m) { methodSpec = ec.Module.PredefinedMembers.DecimalCtorInt.Resolve(loc); if (methodSpec != null) { ec.EmitInt((int)Value); ec.Emit(OpCodes.Newobj, methodSpec); } return; } if (Value <= 9223372036854775807m && Value >= -9223372036854775808m) { methodSpec = ec.Module.PredefinedMembers.DecimalCtorLong.Resolve(loc); if (methodSpec != null) { ec.EmitLong((long)Value); ec.Emit(OpCodes.Newobj, methodSpec); } return; } } ec.EmitInt(bits[0]); ec.EmitInt(bits[1]); ec.EmitInt(bits[2]); ec.EmitInt(bits[3] >> 31); ec.EmitInt(num); methodSpec = ec.Module.PredefinedMembers.DecimalCtor.Resolve(loc); if (methodSpec != null) { ec.Emit(OpCodes.Newobj, methodSpec); } } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { return target_type.BuiltinType switch { BuiltinTypeSpec.Type.SByte => new SByteConstant(target_type, (sbyte)Value, loc), BuiltinTypeSpec.Type.Byte => new ByteConstant(target_type, (byte)Value, loc), BuiltinTypeSpec.Type.Short => new ShortConstant(target_type, (short)Value, loc), BuiltinTypeSpec.Type.UShort => new UShortConstant(target_type, (ushort)Value, loc), BuiltinTypeSpec.Type.Int => new IntConstant(target_type, (int)Value, loc), BuiltinTypeSpec.Type.UInt => new UIntConstant(target_type, (uint)Value, loc), BuiltinTypeSpec.Type.Long => new LongConstant(target_type, (long)Value, loc), BuiltinTypeSpec.Type.ULong => new ULongConstant(target_type, (ulong)Value, loc), BuiltinTypeSpec.Type.Char => new CharConstant(target_type, (char)Value, loc), BuiltinTypeSpec.Type.Float => new FloatConstant(target_type, (float)Value, loc), BuiltinTypeSpec.Type.Double => new DoubleConstant(target_type, (double)Value, loc), _ => null, }; } public override object GetValue() { return Value; } public override string GetValueAsLiteral() { decimal value = Value; return value.ToString(CultureInfo.InvariantCulture) + "M"; } public override long GetValueAsLong() { throw new NotSupportedException(); } } internal class StringConstant : Constant { public string Value { get; protected set; } public override bool IsDefaultValue => Value == null; public override bool IsNegative => false; public override bool IsNull => IsDefaultValue; public StringConstant(BuiltinTypes types, string s, Location loc) : this(types.String, s, loc) { } public StringConstant(TypeSpec type, string s, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Value; Value = s; } protected StringConstant(Location loc) : base(loc) { } public override object GetValue() { return Value; } public override string GetValueAsLiteral() { return "\"" + Value + "\""; } public override long GetValueAsLong() { throw new NotSupportedException(); } public override void Emit(EmitContext ec) { if (Value == null) { ec.EmitNull(); return; } if (Value.Length == 0 && ec.Module.Compiler.Settings.Optimize) { BuiltinTypeSpec builtinTypeSpec = ec.BuiltinTypes.String; if (ec.CurrentType != builtinTypeSpec) { FieldSpec fieldSpec = ec.Module.PredefinedMembers.StringEmpty.Get(); if (fieldSpec != null) { ec.Emit(OpCodes.Ldsfld, fieldSpec); return; } } } string value = Value; if (ec.Module.GetResourceStrings != null && !ec.Module.GetResourceStrings.TryGetValue(value, out value)) { value = Value; } ec.Emit(OpCodes.Ldstr, value); } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { if (type != targetType) { enc.Encode(type); } enc.Encode(Value); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { return null; } public override Constant ConvertImplicitly(TypeSpec type) { if (IsDefaultValue && type.BuiltinType == BuiltinTypeSpec.Type.Object) { return new NullConstant(type, loc); } return base.ConvertImplicitly(type); } } internal class NameOf : StringConstant { private readonly SimpleName name; public NameOf(SimpleName name) : base(name.Location) { this.name = name; } protected override Expression DoResolve(ResolveContext rc) { throw new NotSupportedException(); } private bool ResolveArgumentExpression(ResolveContext rc, Expression expr) { if (expr is SimpleName simpleName) { base.Value = simpleName.Name; if (rc.Module.Compiler.Settings.Version < LanguageVersion.V_6) { rc.Report.FeatureIsNotAvailable(rc.Module.Compiler, base.Location, "nameof operator"); } Expression expression = simpleName.LookupNameExpression(rc, MemberLookupRestrictions.IgnoreAmbiguity | MemberLookupRestrictions.NameOfExcluded); if (expression is MemberExpr memberExpr) { memberExpr.ResolveNameOf(rc, simpleName); } return true; } if (expr is MemberAccess { LeftExpression: var leftExpression } memberAccess) { Expression expression2; using (rc.Set(ResolveContext.Options.NameOfScope)) { expression2 = memberAccess.LookupNameExpression(rc, MemberLookupRestrictions.IgnoreAmbiguity); } if (expression2 == null) { return false; } if (rc.Module.Compiler.Settings.Version < LanguageVersion.V_6) { rc.Report.FeatureIsNotAvailable(rc.Module.Compiler, base.Location, "nameof operator"); } if (memberAccess is QualifiedAliasMember) { rc.Report.Error(8083, loc, "An alias-qualified name is not an expression"); return false; } if (expression2 is MemberExpr memberExpr2) { memberExpr2.ResolveNameOf(rc, memberAccess); } if (!IsLeftResolvedExpressionValid(memberAccess.LeftExpression) || memberAccess.HasConditionalAccess()) { rc.Report.Error(8082, leftExpression.Location, "An argument to nameof operator cannot include sub-expression"); return false; } base.Value = memberAccess.Name; return true; } rc.Report.Error(8081, loc, "Expression does not have a name"); return false; } private static bool IsLeftResolvedExpressionValid(Expression expr) { if (expr is FieldExpr fieldExpr) { return fieldExpr.InstanceExpression == null || IsLeftResolvedExpressionValid(fieldExpr.InstanceExpression); } if (expr is PropertyExpr propertyExpr) { return propertyExpr.InstanceExpression == null || IsLeftResolvedExpressionValid(propertyExpr.InstanceExpression); } if (expr is DynamicMemberBinder dynamicMemberBinder) { return IsLeftResolvedExpressionValid(dynamicMemberBinder.Arguments[0].Expr); } if (expr is ConstantExpr || expr is TypeExpr || expr is NamespaceExpression || expr is VariableReference) { return true; } return false; } public Expression ResolveOverload(ResolveContext rc, Arguments args) { if (args == null || args.Count != 1) { name.Error_NameDoesNotExist(rc); return null; } Argument argument = args[0]; if (!ResolveArgumentExpression(rc, argument.Expr)) { return null; } type = rc.BuiltinTypes.String; eclass = ExprClass.Value; return this; } } internal class NullConstant : Constant { public override string ExprClassName => GetSignatureForError(); public override bool IsDefaultValue => true; public override bool IsNegative => false; public override bool IsNull => true; public override bool IsZeroInteger => true; public NullConstant(TypeSpec type, Location loc) : base(loc) { eclass = ExprClass.Value; base.type = type; } public override Expression CreateExpressionTree(ResolveContext ec) { if (type == InternalType.NullLiteral || type.BuiltinType == BuiltinTypeSpec.Type.Object) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(this)); return CreateExpressionFactoryCall(ec, "Constant", arguments); } return base.CreateExpressionTree(ec); } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { BuiltinTypeSpec.Type builtinType = targetType.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if (type != BuiltinTypeSpec.Type.Object) { if ((uint)(type - 18) > 1u) { if (targetType is ArrayContainer { Rank: 1 } arrayContainer && !arrayContainer.Element.IsArray) { enc.Encode(uint.MaxValue); } else { base.EncodeAttributeValue(rc, enc, targetType, parameterType); } return; } } else { enc.Encode(rc.Module.Compiler.BuiltinTypes.String); } enc.Encode(byte.MaxValue); } public override void Emit(EmitContext ec) { ec.EmitNull(); if (type.IsGenericParameter) { ec.Emit(OpCodes.Unbox_Any, type); } } public override Constant ConvertExplicitly(bool inCheckedContext, TypeSpec targetType) { if (targetType.IsPointer) { if (IsLiteral || this is NullPointer) { return new NullPointer(targetType, loc); } return null; } if (targetType.Kind == MemberKind.InternalCompilerType && targetType.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { return null; } if (!IsLiteral && !Convert.ImplicitStandardConversionExists(this, targetType)) { return null; } if (TypeSpec.IsReferenceType(targetType)) { return new NullConstant(targetType, loc); } if (targetType.IsNullableType) { return LiftedNull.Create(targetType, loc); } return null; } public override Constant ConvertImplicitly(TypeSpec targetType) { return ConvertExplicitly(inCheckedContext: false, targetType); } public override string GetSignatureForError() { return "null"; } public override object GetValue() { return null; } public override string GetValueAsLiteral() { return GetSignatureForError(); } public override long GetValueAsLong() { throw new NotSupportedException(); } } internal class NullPointer : NullConstant { public NullPointer(TypeSpec type, Location loc) : base(type, loc) { } public override Expression CreateExpressionTree(ResolveContext ec) { Error_PointerInsideExpressionTree(ec); return base.CreateExpressionTree(ec); } public override void Emit(EmitContext ec) { ec.EmitInt(0); ec.Emit(OpCodes.Conv_U); } } internal class SideEffectConstant : Constant { public readonly Constant value; private Expression side_effect; public override bool IsSideEffectFree => false; public override bool IsDefaultValue => value.IsDefaultValue; public override bool IsNegative => value.IsNegative; public override bool IsZeroInteger => value.IsZeroInteger; public SideEffectConstant(Constant value, Expression side_effect, Location loc) : base(loc) { this.value = value; type = value.Type; eclass = ExprClass.Value; while (side_effect is SideEffectConstant) { side_effect = ((SideEffectConstant)side_effect).side_effect; } this.side_effect = side_effect; } public override bool ContainsEmitWithAwait() { return side_effect.ContainsEmitWithAwait(); } public override object GetValue() { return value.GetValue(); } public override string GetValueAsLiteral() { return value.GetValueAsLiteral(); } public override long GetValueAsLong() { return value.GetValueAsLong(); } public override void Emit(EmitContext ec) { side_effect.EmitSideEffect(ec); value.Emit(ec); } public override void EmitSideEffect(EmitContext ec) { side_effect.EmitSideEffect(ec); value.EmitSideEffect(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { side_effect.FlowAnalysis(fc); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { Constant constant = value.ConvertExplicitly(in_checked_context, target_type); if (constant == null) { return null; } SideEffectConstant sideEffectConstant = new SideEffectConstant(constant, side_effect, constant.Location); sideEffectConstant.type = target_type; sideEffectConstant.eclass = eclass; return sideEffectConstant; } } internal enum LookupMode { Normal = 0, Probing = 1, IgnoreAccessibility = 2, IgnoreStaticUsing = 0x400 } internal interface IMemberContext : IModuleContext { TypeSpec CurrentType { get; } TypeParameters CurrentTypeParameters { get; } MemberCore CurrentMemberDefinition { get; } bool IsObsolete { get; } bool IsUnsafe { get; } bool IsStatic { get; } string GetSignatureForError(); ExtensionMethodCandidates LookupExtensionMethod(string name, int arity); FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc); FullNamedExpression LookupNamespaceAlias(string name); } internal interface IModuleContext { ModuleContainer Module { get; } } internal class BlockContext : ResolveContext { private readonly TypeSpec return_type; public int AssignmentInfoOffset; public ExceptionStatement CurrentTryBlock { get; set; } public TryCatch CurrentTryCatch { get; set; } public LoopStatement EnclosingLoop { get; set; } public LoopStatement EnclosingLoopOrSwitch { get; set; } public Switch Switch { get; set; } public TypeSpec ReturnType => return_type; public BlockContext(IMemberContext mc, ExplicitBlock block, TypeSpec returnType) : base(mc) { if (returnType == null) { throw new ArgumentNullException("returnType"); } return_type = returnType; CurrentBlock = block; } public BlockContext(ResolveContext rc, ExplicitBlock block, TypeSpec returnType) : this(rc.MemberContext, block, returnType) { if (rc.IsUnsafe) { flags |= Options.UnsafeScope; } if (rc.HasSet(Options.CheckedScope)) { flags |= Options.CheckedScope; } if (!rc.ConstantCheckState) { flags &= ~Options.ConstantCheckState; } if (rc.IsInProbingMode) { flags |= Options.ProbingMode; } if (rc.HasSet(Options.FieldInitializerScope)) { flags |= Options.FieldInitializerScope; } if (rc.HasSet(Options.ExpressionTreeConversion)) { flags |= Options.ExpressionTreeConversion; } if (rc.HasSet(Options.BaseInitializer)) { flags |= Options.BaseInitializer; } if (rc.HasSet(Options.QueryClauseScope)) { flags |= Options.QueryClauseScope; } } } internal class ResolveContext : IMemberContext, IModuleContext { [Flags] public enum Options { CheckedScope = 1, ConstantCheckState = 2, AllCheckStateFlags = 3, UnsafeScope = 4, CatchScope = 8, FinallyScope = 0x10, FieldInitializerScope = 0x20, CompoundAssignmentScope = 0x40, FixedInitializerScope = 0x80, BaseInitializer = 0x100, EnumScope = 0x200, ConstantScope = 0x400, ConstructorScope = 0x800, UsingInitializerScope = 0x1000, LockScope = 0x2000, TryScope = 0x4000, TryWithCatchScope = 0x8000, DontSetConditionalAccessReceiver = 0x10000, NameOfScope = 0x20000, QueryClauseScope = 0x40000, ProbingMode = 0x400000, InferReturnType = 0x800000, OmitDebuggingInfo = 0x1000000, ExpressionTreeConversion = 0x2000000, InvokeSpecialName = 0x4000000 } public struct FlagsHandle : IDisposable { private readonly ResolveContext ec; private readonly Options invmask; private readonly Options oldval; public FlagsHandle(ResolveContext ec, Options flagsToSet) : this(ec, flagsToSet, flagsToSet) { } internal FlagsHandle(ResolveContext ec, Options mask, Options val) { this.ec = ec; invmask = ~mask; oldval = ec.flags & mask; ec.flags = (ec.flags & invmask) | (val & mask); } public void Dispose() { ec.flags = (ec.flags & invmask) | oldval; } } protected Options flags; public AnonymousExpression CurrentAnonymousMethod; public Expression CurrentInitializerVariable; public Block CurrentBlock; public readonly IMemberContext MemberContext; public BuiltinTypes BuiltinTypes => MemberContext.Module.Compiler.BuiltinTypes; public virtual ExplicitBlock ConstructorBlock => CurrentBlock.Explicit; public Iterator CurrentIterator => CurrentAnonymousMethod as Iterator; public TypeSpec CurrentType => MemberContext.CurrentType; public TypeParameters CurrentTypeParameters => MemberContext.CurrentTypeParameters; public MemberCore CurrentMemberDefinition => MemberContext.CurrentMemberDefinition; public bool ConstantCheckState => (flags & Options.ConstantCheckState) != 0; public bool IsInProbingMode => (flags & Options.ProbingMode) != 0; public bool IsObsolete => MemberContext.IsObsolete; public bool IsStatic => MemberContext.IsStatic; public bool IsUnsafe => HasSet(Options.UnsafeScope) || MemberContext.IsUnsafe; public bool IsRuntimeBinder => Module.Compiler.IsRuntimeBinder; public bool IsVariableCapturingRequired => !IsInProbingMode; public ModuleContainer Module => MemberContext.Module; public Report Report => Module.Compiler.Report; public ResolveContext(IMemberContext mc) { if (mc == null) { throw new ArgumentNullException(); } MemberContext = mc; if (mc.Module.Compiler.Settings.Checked) { flags |= Options.CheckedScope; } flags |= Options.ConstantCheckState; } public ResolveContext(IMemberContext mc, Options options) : this(mc) { flags |= options; } public bool MustCaptureVariable(INamedBlockVariable local) { if (CurrentAnonymousMethod == null) { return false; } if (CurrentAnonymousMethod.IsIterator) { return local.IsParameter || local.Block.Explicit.HasYield; } if (CurrentAnonymousMethod is AsyncInitializer) { return local.IsParameter || local.Block.Explicit.HasAwait || CurrentBlock.Explicit.HasAwait || local.Block.ParametersBlock != CurrentBlock.ParametersBlock.Original; } return local.Block.ParametersBlock != CurrentBlock.ParametersBlock.Original; } public bool HasSet(Options options) { return (flags & options) == options; } public bool HasAny(Options options) { return (flags & options) != 0; } public FlagsHandle Set(Options options) { return new FlagsHandle(this, options); } public FlagsHandle With(Options options, bool enable) { return new FlagsHandle(this, options, enable ? options : ((Options)0)); } public string GetSignatureForError() { return MemberContext.GetSignatureForError(); } public ExtensionMethodCandidates LookupExtensionMethod(string name, int arity) { return MemberContext.LookupExtensionMethod(name, arity); } public FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { return MemberContext.LookupNamespaceOrType(name, arity, mode, loc); } public FullNamedExpression LookupNamespaceAlias(string name) { return MemberContext.LookupNamespaceAlias(name); } } internal class FlowAnalysisContext { private readonly CompilerContext ctx; public DefiniteAssignmentBitSet DefiniteAssignment { get; set; } public DefiniteAssignmentBitSet DefiniteAssignmentOnTrue { get; set; } public DefiniteAssignmentBitSet DefiniteAssignmentOnFalse { get; set; } private Dictionary> LabelStack { get; set; } public ParametersBlock ParametersBlock { get; set; } public Report Report => ctx.Report; public DefiniteAssignmentBitSet SwitchInitialDefinitiveAssignment { get; set; } public TryFinally TryFinally { get; set; } public bool UnreachableReported { get; set; } public FlowAnalysisContext(CompilerContext ctx, ParametersBlock parametersBlock, int definiteAssignmentLength) { this.ctx = ctx; ParametersBlock = parametersBlock; DefiniteAssignment = ((definiteAssignmentLength == 0) ? DefiniteAssignmentBitSet.Empty : new DefiniteAssignmentBitSet(definiteAssignmentLength)); } public bool AddReachedLabel(Statement label) { List value; if (LabelStack == null) { LabelStack = new Dictionary>(); value = null; } else { LabelStack.TryGetValue(label, out value); } if (value == null) { value = new List(); value.Add(new DefiniteAssignmentBitSet(DefiniteAssignment)); LabelStack.Add(label, value); return false; } foreach (DefiniteAssignmentBitSet item in value) { if (DefiniteAssignmentBitSet.IsIncluded(item, DefiniteAssignment)) { return true; } } if (DefiniteAssignment == DefiniteAssignmentBitSet.Empty) { value.Add(DefiniteAssignment); } else { value.Add(new DefiniteAssignmentBitSet(DefiniteAssignment)); } return false; } public DefiniteAssignmentBitSet BranchDefiniteAssignment() { return BranchDefiniteAssignment(DefiniteAssignment); } public DefiniteAssignmentBitSet BranchDefiniteAssignment(DefiniteAssignmentBitSet da) { if (da != DefiniteAssignmentBitSet.Empty) { DefiniteAssignment = new DefiniteAssignmentBitSet(da); } return da; } public Dictionary> CopyLabelStack() { if (LabelStack == null) { return null; } Dictionary> dictionary = new Dictionary>(); foreach (KeyValuePair> item in LabelStack) { dictionary.Add(item.Key, new List(item.Value)); } return dictionary; } public bool IsDefinitelyAssigned(VariableInfo variable) { return variable.IsAssigned(DefiniteAssignment); } public bool IsStructFieldDefinitelyAssigned(VariableInfo variable, string name) { return variable.IsStructFieldAssigned(DefiniteAssignment, name); } public void SetLabelStack(Dictionary> labelStack) { LabelStack = labelStack; } public void SetVariableAssigned(VariableInfo variable, bool generatedAssignment = false) { variable.SetAssigned(DefiniteAssignment, generatedAssignment); } public void SetVariableAssigned(VariableInfo variable, DefiniteAssignmentBitSet da) { variable.SetAssigned(da, generatedAssignment: false); } public void SetStructFieldAssigned(VariableInfo variable, string name) { variable.SetStructFieldAssigned(DefiniteAssignment, name); } } internal class CloneContext { private Dictionary block_map = new Dictionary(); public void AddBlockMap(Block from, Block to) { block_map.Add(from, to); } public Block LookupBlock(Block from) { if (!block_map.TryGetValue(from, out var value)) { return (Block)from.Clone(this); } return value; } public Block RemapBlockCopy(Block from) { if (!block_map.TryGetValue(from, out var value)) { return from; } return value; } } internal class CompilerContext { private static readonly TimeReporter DisabledTimeReporter = new TimeReporter(enabled: false); private readonly Report report; private readonly BuiltinTypes builtin_types; private readonly CompilerSettings settings; private Dictionary all_source_files; public BuiltinTypes BuiltinTypes => builtin_types; public bool IsRuntimeBinder { get; set; } public Report Report => report; public CompilerSettings Settings => settings; public List SourceFiles => settings.SourceFiles; internal TimeReporter TimeReporter { get; set; } public CompilerContext(CompilerSettings settings, ReportPrinter reportPrinter) { this.settings = settings; report = new Report(this, reportPrinter); builtin_types = new BuiltinTypes(); TimeReporter = DisabledTimeReporter; } public SourceFile LookupFile(CompilationSourceFile comp_unit, string name) { if (all_source_files == null) { all_source_files = new Dictionary(); foreach (SourceFile sourceFile2 in SourceFiles) { all_source_files[sourceFile2.OriginalFullPathName] = sourceFile2; } } string text; if (!Path.IsPathRooted(name)) { SourceFile sourceFile = comp_unit.SourceFile; string directoryName = Path.GetDirectoryName(sourceFile.OriginalFullPathName); text = Path.GetFullPath(Path.Combine(directoryName, name)); string directoryName2 = Path.GetDirectoryName(sourceFile.Name); if (!string.IsNullOrEmpty(directoryName2)) { name = Path.Combine(directoryName2, name); } } else { text = name; } if (all_source_files.TryGetValue(text, out var value)) { return value; } value = new SourceFile(name, text, all_source_files.Count + 1); Location.AddFile(value); all_source_files.Add(text, value); return value; } } internal class BuilderContext { [Flags] public enum Options { CheckedScope = 1, AccurateDebugInfo = 2, OmitDebugInfo = 4, ConstructorScope = 8, AsyncBody = 0x10 } public struct FlagsHandle : IDisposable { private readonly BuilderContext ec; private readonly Options invmask; private readonly Options oldval; public FlagsHandle(BuilderContext ec, Options flagsToSet) : this(ec, flagsToSet, flagsToSet) { } internal FlagsHandle(BuilderContext ec, Options mask, Options val) { this.ec = ec; invmask = ~mask; oldval = ec.flags & mask; ec.flags = (ec.flags & invmask) | (val & mask); } public void Dispose() { ec.flags = (ec.flags & invmask) | oldval; } } protected Options flags; public bool HasSet(Options options) { return (flags & options) == options; } public FlagsHandle With(Options options, bool enable) { return new FlagsHandle(this, options, enable ? options : ((Options)0)); } } internal class ParserSession { private MD5 md5; public readonly char[] StreamReaderBuffer = new char[4096]; public readonly Dictionary[] Identifiers = new Dictionary[513]; public readonly List ParametersStack = new List(4); public readonly char[] IDBuilder = new char[512]; public readonly char[] NumberBuilder = new char[512]; public LocationsBag LocationsBag { get; set; } public bool UseJayGlobalArrays { get; set; } public LocatedToken[] LocatedTokens { get; set; } public MD5 GetChecksumAlgorithm() { return md5 ?? (md5 = MD5.Create()); } } internal static class Convert { [Flags] public enum UserConversionRestriction { None = 0, ImplicitOnly = 1, ProbingOnly = 2, NullableSourceOnly = 4 } private static bool ArrayToIList(ArrayContainer array, TypeSpec list, bool isExplicit) { if (array.Rank != 1 || !list.IsArrayGenericInterface) { return false; } TypeSpec typeSpec = list.TypeArguments[0]; if (array.Element == typeSpec) { return true; } if (typeSpec.IsGenericParameter) { return false; } if (isExplicit) { return ExplicitReferenceConversionExists(array.Element, typeSpec); } return ImplicitReferenceConversionExists(array.Element, typeSpec); } private static bool IList_To_Array(TypeSpec list, ArrayContainer array) { if (array.Rank != 1 || !list.IsArrayGenericInterface) { return false; } TypeSpec typeSpec = list.TypeArguments[0]; if (array.Element == typeSpec) { return true; } return ImplicitReferenceConversionExists(array.Element, typeSpec) || ExplicitReferenceConversionExists(array.Element, typeSpec); } public static Expression ImplicitTypeParameterConversion(Expression expr, TypeParameterSpec expr_type, TypeSpec target_type) { if (target_type.IsGenericParameter) { if (expr_type.TypeArguments != null && expr_type.HasDependencyOn(target_type)) { if (expr == null) { return EmptyExpression.Null; } if (expr_type.IsReferenceType && !((TypeParameterSpec)target_type).IsReferenceType) { return new BoxedCast(expr, target_type); } return new ClassCast(expr, target_type); } return null; } if (target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { if (expr == null) { return EmptyExpression.Null; } if (expr_type.IsReferenceType) { return new ClassCast(expr, target_type); } return new BoxedCast(expr, target_type); } TypeSpec effectiveBase = expr_type.GetEffectiveBase(); if (effectiveBase == target_type || TypeSpec.IsBaseClass(effectiveBase, target_type, dynamicIsObject: false) || effectiveBase.ImplementsInterface(target_type, variantly: true)) { if (expr == null) { return EmptyExpression.Null; } if (expr_type.IsReferenceType) { return new ClassCast(expr, target_type); } return new BoxedCast(expr, target_type); } if (target_type.IsInterface && expr_type.IsConvertibleToInterface(target_type)) { if (expr == null) { return EmptyExpression.Null; } if (expr_type.IsReferenceType) { return new ClassCast(expr, target_type); } return new BoxedCast(expr, target_type); } return null; } private static Expression ExplicitTypeParameterConversionFromT(Expression source, TypeSpec source_type, TypeSpec target_type) { if (target_type is TypeParameterSpec { TypeArguments: not null } typeParameterSpec && typeParameterSpec.HasDependencyOn(source_type)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } if (target_type.IsInterface) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type, forced: true); } return null; } private static Expression ExplicitTypeParameterConversionToT(Expression source, TypeSpec source_type, TypeParameterSpec target_type) { TypeSpec effectiveBase = target_type.GetEffectiveBase(); if (TypeSpecComparer.IsEqual(effectiveBase, source_type) || TypeSpec.IsBaseClass(effectiveBase, source_type, dynamicIsObject: false)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } return null; } public static Expression ImplicitReferenceConversion(Expression expr, TypeSpec target_type, bool explicit_cast) { TypeSpec type = expr.Type; if (type.Kind == MemberKind.TypeParameter) { return ImplicitTypeParameterConversion(expr, (TypeParameterSpec)expr.Type, target_type); } if (expr is NullLiteral nullLiteral) { return nullLiteral.ConvertImplicitly(target_type); } if (ImplicitReferenceConversionExists(type, target_type)) { if (!explicit_cast) { return expr; } return EmptyCast.Create(expr, target_type); } return null; } public static bool ImplicitReferenceConversionExists(TypeSpec expr_type, TypeSpec target_type) { return ImplicitReferenceConversionExists(expr_type, target_type, refOnlyTypeParameter: true); } public static bool ImplicitReferenceConversionExists(TypeSpec expr_type, TypeSpec target_type, bool refOnlyTypeParameter) { if (target_type.IsStruct) { return false; } switch (expr_type.Kind) { case MemberKind.TypeParameter: return ImplicitTypeParameterConversion(null, (TypeParameterSpec)expr_type, target_type) != null && (!refOnlyTypeParameter || TypeSpec.IsReferenceType(expr_type)); case MemberKind.Class: if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object || target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return true; } if (target_type.IsClass) { if (TypeSpecComparer.IsEqual(expr_type, target_type)) { return true; } return TypeSpec.IsBaseClass(expr_type, target_type, dynamicIsObject: true); } if (target_type.IsInterface) { return expr_type.ImplementsInterface(target_type, variantly: true); } return false; case MemberKind.ArrayType: { if (expr_type == target_type) { return true; } BuiltinTypeSpec.Type builtinType2 = target_type.BuiltinType; BuiltinTypeSpec.Type type2 = builtinType2; if ((uint)(type2 - 16) <= 1u || type2 == BuiltinTypeSpec.Type.Array) { return true; } ArrayContainer arrayContainer = (ArrayContainer)expr_type; if (target_type is ArrayContainer arrayContainer2 && arrayContainer.Rank == arrayContainer2.Rank) { TypeSpec element = arrayContainer.Element; if (!TypeSpec.IsReferenceType(element)) { return false; } return ImplicitReferenceConversionExists(element, arrayContainer2.Element); } if (target_type.IsInterface) { if (expr_type.ImplementsInterface(target_type, variantly: false)) { return true; } if (ArrayToIList(arrayContainer, target_type, isExplicit: false)) { return true; } } return false; } case MemberKind.Delegate: { BuiltinTypeSpec.Type builtinType = target_type.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 16) <= 1u || (uint)(type - 22) <= 1u) { return true; } if (TypeSpecComparer.IsEqual(expr_type, target_type)) { return true; } return expr_type.ImplementsInterface(target_type, variantly: false) || TypeSpecComparer.Variant.IsEqual(expr_type, target_type); } case MemberKind.Interface: if (TypeSpecComparer.IsEqual(expr_type, target_type)) { return true; } if (target_type.IsInterface) { return TypeSpecComparer.Variant.IsEqual(expr_type, target_type) || expr_type.ImplementsInterface(target_type, variantly: true); } return target_type.BuiltinType == BuiltinTypeSpec.Type.Object || target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; case MemberKind.InternalCompilerType: if (expr_type == InternalType.NullLiteral) { if (target_type.Kind == MemberKind.InternalCompilerType) { return target_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; } return TypeSpec.IsReferenceType(target_type) || target_type.Kind == MemberKind.PointerType; } if (expr_type.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { break; } switch (target_type.Kind) { case MemberKind.Class: case MemberKind.Delegate: case MemberKind.Interface: case MemberKind.TypeParameter: case MemberKind.ArrayType: return true; default: if (target_type == InternalType.Arglist) { return true; } return false; } } return false; } public static Expression ImplicitBoxingConversion(Expression expr, TypeSpec expr_type, TypeSpec target_type) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Object: case BuiltinTypeSpec.Type.Dynamic: case BuiltinTypeSpec.Type.ValueType: if (!TypeSpec.IsValueType(expr_type)) { return null; } if (expr_type.IsByRefLike) { return null; } return (expr == null) ? EmptyExpression.Null : new BoxedCast(expr, target_type); case BuiltinTypeSpec.Type.Enum: if (expr_type.IsEnum) { return (expr == null) ? EmptyExpression.Null : new BoxedCast(expr, target_type); } break; } if (expr_type.IsNullableType) { if (!TypeSpec.IsReferenceType(target_type)) { return null; } Expression expression = ImplicitBoxingConversion(expr, NullableInfo.GetUnderlyingType(expr_type), target_type); if (expression != null && expr != null) { expression = new UnboxCast(expression, target_type); } return expression; } if (target_type.IsInterface && TypeSpec.IsValueType(expr_type) && expr_type.ImplementsInterface(target_type, variantly: true)) { return (expr == null) ? EmptyExpression.Null : new BoxedCast(expr, target_type); } return null; } public static Expression ImplicitNulableConversion(ResolveContext ec, Expression expr, TypeSpec target_type) { TypeSpec typeSpec = expr.Type; if (typeSpec == InternalType.NullLiteral) { return (ec == null) ? EmptyExpression.Null : LiftedNull.Create(target_type, expr.Location); } TypeSpec underlyingType = NullableInfo.GetUnderlyingType(target_type); if (typeSpec.IsNullableType) { typeSpec = NullableInfo.GetUnderlyingType(typeSpec); } if (ec == null) { if (TypeSpecComparer.IsEqual(typeSpec, underlyingType)) { return EmptyExpression.Null; } if (expr is Constant) { return ((Constant)expr).ConvertImplicitly(underlyingType); } return ImplicitNumericConversion(null, typeSpec, underlyingType); } Expression expression = ((typeSpec == expr.Type) ? expr : Unwrap.Create(expr)); Expression expression2 = expression; if (!TypeSpecComparer.IsEqual(typeSpec, underlyingType)) { expression2 = ((!(expression2 is Constant)) ? ImplicitNumericConversion(expression2, typeSpec, underlyingType) : ((Constant)expression2).ConvertImplicitly(underlyingType)); if (expression2 == null) { return null; } } if (typeSpec != expr.Type) { return new LiftedConversion(expression2, expression, target_type).Resolve(ec); } return Wrap.Create(expression2, target_type); } public static Expression ImplicitNumericConversion(Expression expr, TypeSpec target_type) { return ImplicitNumericConversion(expr, expr.Type, target_type); } public static bool ImplicitNumericConversionExists(TypeSpec expr_type, TypeSpec target_type) { return ImplicitNumericConversion(null, expr_type, target_type) != null; } private static Expression ImplicitNumericConversion(Expression expr, TypeSpec expr_type, TypeSpec target_type) { switch (expr_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Int: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I4); case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I8); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Short: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I2); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.Byte: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: return (expr == null) ? EmptyExpression.Null : EmptyCast.Create(expr, target_type); case BuiltinTypeSpec.Type.ULong: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_U8); case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.Short: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Int: return (expr == null) ? EmptyExpression.Null : EmptyCast.Create(expr, target_type); case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I8); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.UShort: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: return (expr == null) ? EmptyExpression.Null : EmptyCast.Create(expr, target_type); case BuiltinTypeSpec.Type.ULong: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_U8); case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I8); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.Int: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I8); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.UInt: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_U8); case BuiltinTypeSpec.Type.ULong: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_U8); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCastDuplex(expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCastDuplex(expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.Long: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.ULong: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCastDuplex(expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCastDuplex(expr, target_type, OpCodes.Conv_R_Un, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.Char: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: return (expr == null) ? EmptyExpression.Null : EmptyCast.Create(expr, target_type); case BuiltinTypeSpec.Type.ULong: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_U8); case BuiltinTypeSpec.Type.Long: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_I8); case BuiltinTypeSpec.Type.Float: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R4); case BuiltinTypeSpec.Type.Double: return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); case BuiltinTypeSpec.Type.Decimal: return (expr == null) ? EmptyExpression.Null : new OperatorCast(expr, target_type); } break; case BuiltinTypeSpec.Type.Float: if (target_type.BuiltinType == BuiltinTypeSpec.Type.Double) { return (expr == null) ? EmptyExpression.Null : new OpcodeCast(expr, target_type, OpCodes.Conv_R8); } break; } return null; } private static Expression ImplicitTupleLiteralConversion(ResolveContext rc, Expression source, TypeSpec targetType, Location loc) { TypeSpec[] typeArguments = targetType.TypeArguments; if (source.Type.Arity != typeArguments.Length) { return null; } NamedTupleSpec namedTupleSpec = targetType as NamedTupleSpec; TupleLiteral tupleLiteral = source as TupleLiteral; Expression expr; if (tupleLiteral == null && !ExpressionAnalyzer.IsInexpensiveLoad(source)) { LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(source.Type, rc.CurrentBlock, loc); source = new CompilerAssign(localVariable.CreateReferenceExpression(rc, loc), source, loc); expr = localVariable.CreateReferenceExpression(rc, loc); } else { expr = null; } List list = new List(targetType.Arity); for (int i = 0; i < targetType.Arity; i++) { Expression expr2; if (tupleLiteral != null) { expr2 = tupleLiteral.Elements[i].Expr; if (namedTupleSpec != null) { string name = tupleLiteral.Elements[i].Name; if (name != null && name != namedTupleSpec.Elements[i]) { rc.Report.Warning(8123, 1, loc, "The tuple element name `{0}' is ignored because a different name or no name is specified by the target type `{1}'", name, namedTupleSpec.GetSignatureForErrorWithNames()); } } } else { expr2 = new MemberAccess(expr, NamedTupleSpec.GetElementPropertyName(i)).Resolve(rc); } Expression expression = ImplicitConversionStandard(rc, expr2, typeArguments[i], loc); if (expression == null) { return null; } list.Add(expression); } return new TupleLiteralConversion(source, targetType, list, loc); } private static bool ImplicitTupleLiteralConversionExists(Expression source, TypeSpec targetType) { if (source.Type.Arity != targetType.Arity) { return false; } TypeSpec[] typeArguments = source.Type.TypeArguments; TypeSpec[] typeArguments2 = targetType.TypeArguments; List list = (source as TupleLiteral)?.Elements; for (int i = 0; i < targetType.Arity; i++) { if (list != null) { if (!ImplicitStandardConversionExists(list[i].Expr, typeArguments2[i])) { return false; } } else if (!ImplicitStandardConversionExists(new EmptyExpression(typeArguments[i]), typeArguments2[i])) { return false; } } return true; } public static bool ImplicitConversionExists(ResolveContext ec, Expression expr, TypeSpec target_type) { if (ImplicitStandardConversionExists(ec, expr, target_type)) { return true; } if (expr.Type == InternalType.AnonymousMethod) { if (!target_type.IsDelegate && !target_type.IsExpressionTreeType) { return false; } AnonymousMethodExpression anonymousMethodExpression = (AnonymousMethodExpression)expr; return anonymousMethodExpression.ImplicitStandardConversionExists(ec, target_type); } if (expr.Type == InternalType.Arglist) { return target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec; } return UserDefinedConversion(ec, expr, target_type, UserConversionRestriction.ImplicitOnly | UserConversionRestriction.ProbingOnly, Location.Null) != null; } public static bool ImplicitStandardConversionExists(ResolveContext rc, Expression expr, TypeSpec target_type) { if (expr.eclass == ExprClass.MethodGroup) { if (target_type.IsDelegate && rc.Module.Compiler.Settings.Version != LanguageVersion.ISO_1 && expr is MethodGroupExpr mg) { return DelegateCreation.ImplicitStandardConversionExists(rc, mg, target_type); } return false; } if (expr is InterpolatedString && (target_type == rc.Module.PredefinedTypes.IFormattable.TypeSpec || target_type == rc.Module.PredefinedTypes.FormattableString.TypeSpec)) { return true; } return ImplicitStandardConversionExists(expr, target_type); } public static bool ImplicitStandardConversionExists(Expression expr, TypeSpec target_type) { TypeSpec type = expr.Type; if (type == target_type) { return true; } if (type == InternalType.ThrowExpr || type == InternalType.DefaultType) { return target_type.Kind != MemberKind.InternalCompilerType; } if (target_type.IsNullableType) { return ImplicitNulableConversion(null, expr, target_type) != null; } if (ImplicitNumericConversion(null, type, target_type) != null) { return true; } if (ImplicitReferenceConversionExists(type, target_type, refOnlyTypeParameter: false)) { return true; } if (ImplicitBoxingConversion(null, type, target_type) != null) { return true; } if (type.IsTupleType && target_type.IsTupleType) { return ImplicitTupleLiteralConversionExists(expr, target_type); } if (expr is IntConstant) { int value = ((IntConstant)expr).Value; switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: if (value >= -128 && value <= 127) { return true; } break; case BuiltinTypeSpec.Type.Byte: if (value >= 0 && value <= 255) { return true; } break; case BuiltinTypeSpec.Type.Short: if (value >= -32768 && value <= 32767) { return true; } break; case BuiltinTypeSpec.Type.UShort: if (value >= 0 && value <= 65535) { return true; } break; case BuiltinTypeSpec.Type.UInt: if (value >= 0) { return true; } break; case BuiltinTypeSpec.Type.ULong: if (value >= 0) { return true; } break; } } if (expr is LongConstant && target_type.BuiltinType == BuiltinTypeSpec.Type.ULong) { long value2 = ((LongConstant)expr).Value; if (value2 >= 0) { return true; } } if (expr is IntegralConstant && target_type.IsEnum) { IntegralConstant integralConstant = (IntegralConstant)expr; return integralConstant.IsZeroInteger; } if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { MemberKind kind = target_type.Kind; MemberKind memberKind = kind; if (memberKind == MemberKind.Struct || memberKind == MemberKind.Enum) { return true; } return false; } if (target_type.IsPointer && expr.Type.IsPointer && ((PointerContainer)target_type).Element.Kind == MemberKind.Void) { return true; } if (type.IsStruct && TypeSpecComparer.IsEqual(type, target_type)) { return true; } return false; } public static TypeSpec FindMostEncompassedType(IList types) { TypeSpec typeSpec = null; EmptyExpression expr; foreach (TypeSpec type in types) { if (typeSpec == null) { typeSpec = type; continue; } expr = new EmptyExpression(type); if (ImplicitStandardConversionExists(expr, typeSpec)) { typeSpec = type; } } expr = new EmptyExpression(typeSpec); foreach (TypeSpec type2 in types) { if (typeSpec == type2 || ImplicitStandardConversionExists(expr, type2)) { continue; } typeSpec = null; break; } return typeSpec; } private static TypeSpec FindMostEncompassingType(IList types) { if (types.Count == 0) { return null; } if (types.Count == 1) { return types[0]; } TypeSpec typeSpec = null; for (int i = 0; i < types.Count; i++) { int j; for (j = 0; j < types.Count; j++) { if (j != i) { EmptyExpression expr = new EmptyExpression(types[j]); if (!ImplicitStandardConversionExists(expr, types[i])) { j = 0; break; } } } if (j != 0) { if (typeSpec != null) { return InternalType.FakeInternalType; } typeSpec = types[i]; } } return typeSpec; } private static TypeSpec FindMostSpecificSource(ResolveContext rc, List list, TypeSpec sourceType, Expression source, bool apply_explicit_conv_rules) { TypeSpec[] array = null; for (int i = 0; i < list.Count; i++) { TypeSpec typeSpec = list[i].Parameters.Types[0]; if (typeSpec == sourceType) { return typeSpec; } if (array == null) { array = new TypeSpec[list.Count]; } array[i] = typeSpec; } if (apply_explicit_conv_rules) { List list2 = new List(); TypeSpec[] array2 = array; foreach (TypeSpec typeSpec2 in array2) { if (ImplicitStandardConversionExists(rc, source, typeSpec2)) { list2.Add(typeSpec2); } } if (list2.Count != 0) { if (source.eclass == ExprClass.MethodGroup) { return InternalType.FakeInternalType; } return FindMostEncompassedType(list2); } } if (apply_explicit_conv_rules) { return FindMostEncompassingType(array); } return FindMostEncompassedType(array); } public static TypeSpec FindMostSpecificTarget(IList list, TypeSpec target, bool apply_explicit_conv_rules) { List list2 = null; foreach (MethodSpec item in list) { TypeSpec returnType = item.ReturnType; if (returnType == target) { return returnType; } if (list2 == null) { list2 = new List(list.Count); } else if (list2.Contains(returnType)) { continue; } list2.Add(returnType); } if (apply_explicit_conv_rules) { List list3 = new List(); foreach (TypeSpec item2 in list2) { EmptyExpression expr = new EmptyExpression(item2); if (ImplicitStandardConversionExists(expr, target)) { list3.Add(item2); } } if (list3.Count != 0) { return FindMostEncompassingType(list3); } } if (apply_explicit_conv_rules) { return FindMostEncompassedType(list2); } return FindMostEncompassingType(list2); } public static Expression ImplicitUserConversion(ResolveContext ec, Expression source, TypeSpec target, Location loc) { return UserDefinedConversion(ec, source, target, UserConversionRestriction.ImplicitOnly, loc); } private static Expression ExplicitUserConversion(ResolveContext ec, Expression source, TypeSpec target, Location loc) { return UserDefinedConversion(ec, source, target, UserConversionRestriction.None, loc); } private static void FindApplicableUserDefinedConversionOperators(ResolveContext rc, IList operators, Expression source, TypeSpec target, UserConversionRestriction restr, ref List candidates) { if (source.Type.IsInterface) { return; } Expression expression = null; foreach (MethodSpec @operator in operators) { if (@operator == null) { continue; } TypeSpec typeSpec = @operator.Parameters.Types[0]; if ((source.Type != typeSpec && !ImplicitStandardConversionExists(rc, source, typeSpec) && ((restr & UserConversionRestriction.ImplicitOnly) != UserConversionRestriction.None || !ImplicitStandardConversionExists(new EmptyExpression(typeSpec), source.Type))) || ((restr & UserConversionRestriction.NullableSourceOnly) != UserConversionRestriction.None && !typeSpec.IsNullableType)) { continue; } typeSpec = @operator.ReturnType; if (typeSpec.IsInterface) { continue; } if (target != typeSpec) { if (typeSpec.IsNullableType) { typeSpec = NullableInfo.GetUnderlyingType(typeSpec); } if (!ImplicitStandardConversionExists(new EmptyExpression(typeSpec), target)) { if ((restr & UserConversionRestriction.ImplicitOnly) != UserConversionRestriction.None) { continue; } if (expression == null) { expression = new EmptyExpression(target); } if (!ImplicitStandardConversionExists(expression, typeSpec)) { continue; } } } if (candidates == null) { candidates = new List(); } candidates.Add(@operator); } } public static Expression UserDefinedConversion(ResolveContext rc, Expression source, TypeSpec target, UserConversionRestriction restr, Location loc) { List candidates = null; TypeSpec type = source.Type; TypeSpec typeSpec = target; bool flag = false; bool flag2 = (restr & UserConversionRestriction.ImplicitOnly) != 0; Expression expression; if (type.IsNullableType) { if (flag2 && !TypeSpec.IsReferenceType(typeSpec) && !typeSpec.IsNullableType) { expression = source; } else { expression = Unwrap.CreateUnwrapped(source); type = expression.Type; flag = true; } } else { expression = source; } if (typeSpec.IsNullableType) { typeSpec = NullableInfo.GetUnderlyingType(typeSpec); } if ((type.Kind & (MemberKind.Class | MemberKind.Struct | MemberKind.TypeParameter)) != 0 && type.BuiltinType != BuiltinTypeSpec.Type.Decimal) { bool isStruct = type.IsStruct; IList userOperator = MemberCache.GetUserOperator(type, Operator.OpType.Implicit, isStruct); if (userOperator != null) { FindApplicableUserDefinedConversionOperators(rc, userOperator, expression, typeSpec, restr, ref candidates); } if (expression == source && type.IsNullableType) { userOperator = MemberCache.GetUserOperator(type.TypeArguments[0], Operator.OpType.Implicit, isStruct); if (userOperator != null) { FindApplicableUserDefinedConversionOperators(rc, userOperator, expression, typeSpec, restr, ref candidates); } } if (!flag2) { userOperator = MemberCache.GetUserOperator(type, Operator.OpType.Explicit, isStruct); if (userOperator != null) { FindApplicableUserDefinedConversionOperators(rc, userOperator, expression, typeSpec, restr, ref candidates); } } } if ((target.Kind & (MemberKind.Class | MemberKind.Struct | MemberKind.TypeParameter)) != 0 && typeSpec.BuiltinType != BuiltinTypeSpec.Type.Decimal) { bool declaredOnly = target.IsStruct || flag2; IList userOperator2 = MemberCache.GetUserOperator(typeSpec, Operator.OpType.Implicit, declaredOnly); if (userOperator2 != null) { FindApplicableUserDefinedConversionOperators(rc, userOperator2, expression, typeSpec, restr, ref candidates); } if (!flag2) { userOperator2 = MemberCache.GetUserOperator(typeSpec, Operator.OpType.Explicit, declaredOnly); if (userOperator2 != null) { FindApplicableUserDefinedConversionOperators(rc, userOperator2, expression, typeSpec, restr, ref candidates); } } } if (candidates == null) { return null; } TypeSpec typeSpec2; TypeSpec typeSpec3; MethodSpec methodSpec; if (candidates.Count == 1) { methodSpec = candidates[0]; typeSpec2 = methodSpec.Parameters.Types[0]; typeSpec3 = methodSpec.ReturnType; } else { typeSpec2 = FindMostSpecificSource(rc, candidates, source.Type, expression, !flag2); if (typeSpec2 == null) { return null; } typeSpec3 = FindMostSpecificTarget(candidates, target, !flag2); if (typeSpec3 == null) { return null; } methodSpec = null; for (int i = 0; i < candidates.Count; i++) { if (candidates[i].ReturnType == typeSpec3 && candidates[i].Parameters.Types[0] == typeSpec2) { methodSpec = candidates[i]; break; } } if (methodSpec == null) { if ((restr & UserConversionRestriction.ProbingOnly) == 0) { MethodSpec methodSpec2 = candidates[0]; methodSpec = candidates[1]; rc.Report.Error(457, loc, "Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' to `{3}'", methodSpec2.GetSignatureForError(), methodSpec.GetSignatureForError(), source.Type.GetSignatureForError(), target.GetSignatureForError()); } return ErrorExpression.Instance; } } if (typeSpec2 != type) { Constant constant = source as Constant; if (constant != null) { source = constant.Reduce(rc, typeSpec2); if (source == null) { constant = null; } } if (constant == null) { source = (flag2 ? ImplicitConversionStandard(rc, expression, typeSpec2, loc) : ExplicitConversionStandard(rc, expression, typeSpec2, loc)); } } else { source = expression; } source = new UserCast(methodSpec, source, loc).Resolve(rc); if (typeSpec3 != typeSpec) { if (typeSpec3.IsNullableType && (target.IsNullableType || !flag2)) { if (typeSpec3 != target) { Expression expression2 = Unwrap.CreateUnwrapped(source); source = (flag2 ? ImplicitConversionStandard(rc, expression2, typeSpec, loc) : ExplicitConversionStandard(rc, expression2, typeSpec, loc)); if (source == null) { return null; } if (target.IsNullableType) { source = new LiftedConversion(source, expression2, target).Resolve(rc); } } } else { source = (flag2 ? ImplicitConversionStandard(rc, source, typeSpec, loc) : ExplicitConversionStandard(rc, source, typeSpec, loc)); if (source == null) { return null; } } } if (flag && !typeSpec2.IsNullableType) { return new LiftedConversion(source, expression, target).Resolve(rc); } if (target.IsNullableType && !typeSpec3.IsNullableType) { source = Wrap.Create(source, target); } return source; } public static Expression ImplicitConversion(ResolveContext ec, Expression expr, TypeSpec target_type, Location loc) { if (target_type == null) { throw new Exception("Target type is null"); } Expression expression = ImplicitConversionStandard(ec, expr, target_type, loc); if (expression != null) { return expression; } expression = ImplicitUserConversion(ec, expr, target_type, loc); if (expression != null) { return expression; } return null; } public static Expression ImplicitConversionStandard(ResolveContext ec, Expression expr, TypeSpec target_type, Location loc) { return ImplicitConversionStandard(ec, expr, target_type, loc, explicit_cast: false); } private static Expression ImplicitConversionStandard(ResolveContext ec, Expression expr, TypeSpec target_type, Location loc, bool explicit_cast) { if (expr.eclass == ExprClass.MethodGroup) { if (!target_type.IsDelegate) { return null; } if (ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1 && expr is MethodGroupExpr mg) { return new ImplicitDelegateCreation(target_type, mg, loc).Resolve(ec); } } TypeSpec type = expr.Type; if (type == target_type) { if (type != InternalType.NullLiteral && type != InternalType.AnonymousMethod && type != InternalType.ThrowExpr) { return expr; } return null; } if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { MemberKind kind = target_type.Kind; MemberKind memberKind = kind; if (memberKind <= MemberKind.Delegate) { if (memberKind == MemberKind.Class) { goto IL_013e; } if (memberKind == MemberKind.Struct || memberKind == MemberKind.Delegate) { goto IL_015e; } } else if (memberKind <= MemberKind.Interface) { if (memberKind == MemberKind.Enum || memberKind == MemberKind.Interface) { goto IL_015e; } } else { if (memberKind == MemberKind.TypeParameter) { goto IL_015e; } if (memberKind == MemberKind.ArrayType) { goto IL_013e; } } return null; } if (type == InternalType.ThrowExpr) { return (target_type.Kind == MemberKind.InternalCompilerType) ? null : EmptyCast.Create(expr, target_type); } if (type == InternalType.DefaultType) { return new DefaultValueExpression(new TypeExpression(target_type, expr.Location), expr.Location).Resolve(ec); } if (target_type.IsNullableType) { return ImplicitNulableConversion(ec, expr, target_type); } if (expr is Constant constant) { Constant constant2; try { constant2 = constant.ConvertImplicitly(target_type); } catch { throw new InternalErrorException("Conversion error", loc); } if (constant2 != null) { return constant2; } } if (type.IsTupleType) { if (target_type.IsTupleType) { return ImplicitTupleLiteralConversion(ec, expr, target_type, loc); } if (expr is TupleLiteral && TupleLiteral.ContainsNoTypeElement(type)) { return null; } } if (expr is ReferenceExpression) { return null; } Expression expression = ImplicitNumericConversion(expr, type, target_type); if (expression != null) { return expression; } expression = ImplicitReferenceConversion(expr, target_type, explicit_cast); if (expression != null) { return expression; } expression = ImplicitBoxingConversion(expr, type, target_type); if (expression != null) { return expression; } if (expr is IntegralConstant && target_type.IsEnum) { IntegralConstant integralConstant = (IntegralConstant)expr; if (integralConstant.IsZeroInteger) { return new EnumConstant(new IntLiteral(ec.BuiltinTypes, 0, integralConstant.Location), target_type); } } if (target_type is PointerContainer pointerContainer) { if (type.IsPointer) { if (type == pointerContainer) { return expr; } if (pointerContainer.Element.Kind == MemberKind.Void) { return EmptyCast.Create(expr, target_type); } } if (type == InternalType.NullLiteral) { return new NullPointer(target_type, loc); } } if (type == InternalType.AnonymousMethod) { AnonymousMethodExpression anonymousMethodExpression = (AnonymousMethodExpression)expr; Expression expression2 = anonymousMethodExpression.Compatible(ec, target_type); if (expression2 != null) { return expression2.Resolve(ec); } return ErrorExpression.Instance; } if (type == InternalType.Arglist && target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec) { return expr; } if (type.IsStruct && TypeSpecComparer.IsEqual(type, target_type)) { return (type == target_type) ? expr : EmptyCast.Create(expr, target_type); } if (expr is InterpolatedString interpolatedString && (target_type == ec.Module.PredefinedTypes.IFormattable.TypeSpec || target_type == ec.Module.PredefinedTypes.FormattableString.TypeSpec)) { return interpolatedString.ConvertTo(ec, target_type); } return null; IL_013e: if (target_type.BuiltinType == BuiltinTypeSpec.Type.Object) { return EmptyCast.Create(expr, target_type); } goto IL_015e; IL_015e: Arguments arguments = new Arguments(1); arguments.Add(new Argument(expr)); return new DynamicConversion(target_type, explicit_cast ? CSharpBinderFlags.ConvertExplicit : CSharpBinderFlags.None, arguments, loc).Resolve(ec); } public static Expression ImplicitConversionRequired(ResolveContext ec, Expression source, TypeSpec target_type, Location loc) { Expression expression = ImplicitConversion(ec, source, target_type, loc); if (expression != null) { return expression; } if (target_type != InternalType.ErrorType) { source.Error_ValueCannotBeConverted(ec, target_type, expl: false); } return null; } public static Expression ExplicitNumericConversion(ResolveContext rc, Expression expr, TypeSpec target_type) { switch (expr.Type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.I1_U1); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.I1_U2); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.I1_U4); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.I1_U8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.I1_CH); case BuiltinTypeSpec.Type.UIntPtr: return new OperatorCast(new ConvCast(expr, rc.BuiltinTypes.ULong, ConvCast.Mode.I1_U8), target_type, target_type, isExplicit: true); } break; case BuiltinTypeSpec.Type.Byte: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.U1_I1); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.U1_CH); } break; case BuiltinTypeSpec.Type.Short: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.I2_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.I2_U1); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.I2_U2); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.I2_U4); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.I2_U8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.I2_CH); case BuiltinTypeSpec.Type.UIntPtr: return new OperatorCast(new ConvCast(expr, rc.BuiltinTypes.ULong, ConvCast.Mode.I2_U8), target_type, target_type, isExplicit: true); } break; case BuiltinTypeSpec.Type.UShort: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.U2_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.U2_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.U2_I2); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.U2_CH); } break; case BuiltinTypeSpec.Type.Int: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.I4_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.I4_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.I4_I2); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.I4_U2); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.I4_U4); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.I4_U8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.I4_CH); case BuiltinTypeSpec.Type.UIntPtr: return new OperatorCast(new ConvCast(expr, rc.BuiltinTypes.ULong, ConvCast.Mode.I2_U8), target_type, target_type, isExplicit: true); } break; case BuiltinTypeSpec.Type.UInt: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.U4_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.U4_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.U4_I2); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.U4_U2); case BuiltinTypeSpec.Type.Int: return new ConvCast(expr, target_type, ConvCast.Mode.U4_I4); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.U4_CH); } break; case BuiltinTypeSpec.Type.Long: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.I8_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.I8_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.I8_I2); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.I8_U2); case BuiltinTypeSpec.Type.Int: return new ConvCast(expr, target_type, ConvCast.Mode.I8_I4); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.I8_U4); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.I8_U8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.I8_CH); } break; case BuiltinTypeSpec.Type.ULong: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.U8_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.U8_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.U8_I2); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.U8_U2); case BuiltinTypeSpec.Type.Int: return new ConvCast(expr, target_type, ConvCast.Mode.U8_I4); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.U8_U4); case BuiltinTypeSpec.Type.Long: return new ConvCast(expr, target_type, ConvCast.Mode.U8_I8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.U8_CH); case BuiltinTypeSpec.Type.IntPtr: return new OperatorCast(EmptyCast.Create(expr, rc.BuiltinTypes.Long), target_type, find_explicit: true); } break; case BuiltinTypeSpec.Type.Char: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.CH_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.CH_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.CH_I2); } break; case BuiltinTypeSpec.Type.Float: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.R4_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.R4_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.R4_I2); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.R4_U2); case BuiltinTypeSpec.Type.Int: return new ConvCast(expr, target_type, ConvCast.Mode.R4_I4); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.R4_U4); case BuiltinTypeSpec.Type.Long: return new ConvCast(expr, target_type, ConvCast.Mode.R4_I8); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.R4_U8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.R4_CH); case BuiltinTypeSpec.Type.Decimal: return new OperatorCast(expr, target_type, find_explicit: true); } break; case BuiltinTypeSpec.Type.Double: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(expr, target_type, ConvCast.Mode.R8_I1); case BuiltinTypeSpec.Type.Byte: return new ConvCast(expr, target_type, ConvCast.Mode.R8_U1); case BuiltinTypeSpec.Type.Short: return new ConvCast(expr, target_type, ConvCast.Mode.R8_I2); case BuiltinTypeSpec.Type.UShort: return new ConvCast(expr, target_type, ConvCast.Mode.R8_U2); case BuiltinTypeSpec.Type.Int: return new ConvCast(expr, target_type, ConvCast.Mode.R8_I4); case BuiltinTypeSpec.Type.UInt: return new ConvCast(expr, target_type, ConvCast.Mode.R8_U4); case BuiltinTypeSpec.Type.Long: return new ConvCast(expr, target_type, ConvCast.Mode.R8_I8); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.R8_U8); case BuiltinTypeSpec.Type.Char: return new ConvCast(expr, target_type, ConvCast.Mode.R8_CH); case BuiltinTypeSpec.Type.Float: return new ConvCast(expr, target_type, ConvCast.Mode.R8_R4); case BuiltinTypeSpec.Type.Decimal: return new OperatorCast(expr, target_type, find_explicit: true); } break; case BuiltinTypeSpec.Type.UIntPtr: switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new ConvCast(new OperatorCast(expr, expr.Type, rc.BuiltinTypes.UInt, isExplicit: true), target_type, ConvCast.Mode.U4_I1); case BuiltinTypeSpec.Type.Short: return new ConvCast(new OperatorCast(expr, expr.Type, rc.BuiltinTypes.UInt, isExplicit: true), target_type, ConvCast.Mode.U4_I2); case BuiltinTypeSpec.Type.Int: return EmptyCast.Create(new OperatorCast(expr, expr.Type, rc.BuiltinTypes.UInt, isExplicit: true), target_type); case BuiltinTypeSpec.Type.UInt: return new OperatorCast(expr, expr.Type, target_type, isExplicit: true); case BuiltinTypeSpec.Type.Long: return EmptyCast.Create(new OperatorCast(expr, expr.Type, rc.BuiltinTypes.ULong, isExplicit: true), target_type); } break; case BuiltinTypeSpec.Type.IntPtr: if (target_type.BuiltinType == BuiltinTypeSpec.Type.UInt) { return EmptyCast.Create(new OperatorCast(expr, expr.Type, rc.BuiltinTypes.Int, isExplicit: true), target_type); } if (target_type.BuiltinType == BuiltinTypeSpec.Type.ULong) { return EmptyCast.Create(new OperatorCast(expr, expr.Type, rc.BuiltinTypes.Long, isExplicit: true), target_type); } break; case BuiltinTypeSpec.Type.Decimal: { BuiltinTypeSpec.Type builtinType = target_type.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 2) > 10u) { break; } return new OperatorCast(expr, expr.Type, target_type, isExplicit: true); } } return null; } public static bool ExplicitReferenceConversionExists(TypeSpec source_type, TypeSpec target_type) { Expression expression = ExplicitReferenceConversion(null, source_type, target_type); if (expression == null) { return false; } if (expression == EmptyExpression.Null) { return true; } throw new InternalErrorException("Invalid probing conversion result"); } private static Expression ExplicitReferenceConversion(Expression source, TypeSpec source_type, TypeSpec target_type) { if (source_type.BuiltinType == BuiltinTypeSpec.Type.Object && TypeManager.IsGenericParameter(target_type)) { return (source == null) ? EmptyExpression.Null : new UnboxCast(source, target_type); } if (source_type.Kind == MemberKind.TypeParameter) { return ExplicitTypeParameterConversionFromT(source, source_type, target_type); } bool flag = target_type.Kind == MemberKind.Struct || target_type.Kind == MemberKind.Enum; if (source_type.BuiltinType == BuiltinTypeSpec.Type.ValueType && flag) { return (source == null) ? EmptyExpression.Null : new UnboxCast(source, target_type); } if (source_type.BuiltinType == BuiltinTypeSpec.Type.Object || source_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { if (target_type.IsPointer || target_type.IsByRefLike) { return null; } return (source == null) ? EmptyExpression.Null : (flag ? new UnboxCast(source, target_type) : ((source is Constant) ? ((Expression)new EmptyConstantCast((Constant)source, target_type)) : ((Expression)new ClassCast(source, target_type)))); } if (source_type.Kind == MemberKind.Class && TypeSpec.IsBaseClass(target_type, source_type, dynamicIsObject: true)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } if (source_type.Kind == MemberKind.Interface) { if (!target_type.IsSealed || target_type.ImplementsInterface(source_type, variantly: true)) { if (source == null) { return EmptyExpression.Null; } return flag ? ((TypeCast)new UnboxCast(source, target_type)) : ((TypeCast)new ClassCast(source, target_type)); } if (target_type is ArrayContainer array && IList_To_Array(source_type, array)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } return null; } if (source_type is ArrayContainer arrayContainer) { if (target_type is ArrayContainer arrayContainer2) { if (source_type.BuiltinType == BuiltinTypeSpec.Type.Array) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } if (arrayContainer.Rank == arrayContainer2.Rank) { source_type = arrayContainer.Element; TypeSpec element = arrayContainer2.Element; if ((source_type.Kind & element.Kind & MemberKind.TypeParameter) == MemberKind.TypeParameter) { if (TypeSpec.IsValueType(source_type)) { return null; } } else if (!TypeSpec.IsReferenceType(source_type)) { return null; } if (!TypeSpec.IsReferenceType(element)) { return null; } if (ExplicitReferenceConversionExists(source_type, element)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } return null; } } if (ArrayToIList(arrayContainer, target_type, isExplicit: true)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } return null; } if (target_type.IsInterface && !source_type.IsSealed && !source_type.ImplementsInterface(target_type, variantly: true)) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } if (source_type.BuiltinType == BuiltinTypeSpec.Type.Delegate && target_type.IsDelegate) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } if (source_type.IsDelegate && target_type.IsDelegate && source_type.MemberDefinition == target_type.MemberDefinition) { TypeParameterSpec[] typeParameters = source_type.MemberDefinition.TypeParameters; TypeSpec[] typeArguments = source_type.TypeArguments; TypeSpec[] typeArguments2 = target_type.TypeArguments; int i; for (i = 0; i < typeParameters.Length; i++) { if (TypeSpecComparer.IsEqual(typeArguments[i], typeArguments2[i])) { continue; } if (typeParameters[i].Variance == Variance.Covariant) { if (!ImplicitReferenceConversionExists(typeArguments[i], typeArguments2[i]) && !ExplicitReferenceConversionExists(typeArguments[i], typeArguments2[i])) { break; } } else if (typeParameters[i].Variance != Variance.Contravariant || !TypeSpec.IsReferenceType(typeArguments[i]) || !TypeSpec.IsReferenceType(typeArguments2[i])) { break; } } if (i == typeParameters.Length) { return (source == null) ? EmptyExpression.Null : new ClassCast(source, target_type); } } if (target_type is TypeParameterSpec target_type2) { return ExplicitTypeParameterConversionToT(source, source_type, target_type2); } return null; } public static Expression ExplicitConversionCore(ResolveContext ec, Expression expr, TypeSpec target_type, Location loc) { TypeSpec type = expr.Type; Expression expression = ImplicitConversionStandard(ec, expr, target_type, loc, explicit_cast: true); if (expression != null) { return expression; } if (type.IsEnum) { TypeSpec typeSpec = (target_type.IsEnum ? EnumSpec.GetUnderlyingType(target_type) : target_type); Expression expression2 = EmptyCast.Create(expr, EnumSpec.GetUnderlyingType(type)); if (expression2.Type == typeSpec) { expression = expression2; } if (expression == null) { expression = ImplicitNumericConversion(expression2, typeSpec); } if (expression == null) { expression = ExplicitNumericConversion(ec, expression2, typeSpec); } if (expression == null && (typeSpec.BuiltinType == BuiltinTypeSpec.Type.IntPtr || typeSpec.BuiltinType == BuiltinTypeSpec.Type.UIntPtr)) { expression = ExplicitUserConversion(ec, expression2, typeSpec, loc); } return (expression != null) ? EmptyCast.Create(expression, target_type) : null; } if (target_type.IsEnum) { if (type.BuiltinType == BuiltinTypeSpec.Type.Enum) { return new UnboxCast(expr, target_type); } TypeSpec typeSpec2 = (target_type.IsEnum ? EnumSpec.GetUnderlyingType(target_type) : target_type); if (type == typeSpec2) { return EmptyCast.Create(expr, target_type); } if (expr is Constant constant) { Constant constant2 = constant.TryReduce(ec, typeSpec2); if (constant2 != null) { return constant2; } } else { expression = ImplicitNumericConversion(expr, typeSpec2); if (expression != null) { return EmptyCast.Create(expression, target_type); } expression = ExplicitNumericConversion(ec, expr, typeSpec2); if (expression != null) { return EmptyCast.Create(expression, target_type); } if (type.BuiltinType == BuiltinTypeSpec.Type.IntPtr || type.BuiltinType == BuiltinTypeSpec.Type.UIntPtr) { expression = ExplicitUserConversion(ec, expr, typeSpec2, loc); if (expression != null) { return ExplicitConversionCore(ec, expression, target_type, loc); } } } } else { expression = ExplicitNumericConversion(ec, expr, target_type); if (expression != null) { return expression; } } if (type != InternalType.NullLiteral) { expression = ExplicitReferenceConversion(expr, type, target_type); if (expression != null) { return expression; } } if (ec.IsUnsafe) { expression = ExplicitUnsafe(expr, target_type); if (expression != null) { return expression; } } return null; } public static Expression ExplicitUnsafe(Expression expr, TypeSpec target_type) { TypeSpec type = expr.Type; if (target_type.IsPointer) { if (type.IsPointer) { return EmptyCast.Create(expr, target_type); } switch (type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.Int: return new OpcodeCast(expr, target_type, OpCodes.Conv_I); case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: return new OpcodeCast(expr, target_type, OpCodes.Conv_U); case BuiltinTypeSpec.Type.Long: return new ConvCast(expr, target_type, ConvCast.Mode.I8_I); case BuiltinTypeSpec.Type.ULong: return new ConvCast(expr, target_type, ConvCast.Mode.U8_I); } } if (type.IsPointer) { switch (target_type.BuiltinType) { case BuiltinTypeSpec.Type.SByte: return new OpcodeCast(expr, target_type, OpCodes.Conv_I1); case BuiltinTypeSpec.Type.Byte: return new OpcodeCast(expr, target_type, OpCodes.Conv_U1); case BuiltinTypeSpec.Type.Short: return new OpcodeCast(expr, target_type, OpCodes.Conv_I2); case BuiltinTypeSpec.Type.UShort: return new OpcodeCast(expr, target_type, OpCodes.Conv_U2); case BuiltinTypeSpec.Type.Int: return new OpcodeCast(expr, target_type, OpCodes.Conv_I4); case BuiltinTypeSpec.Type.UInt: return new OpcodeCast(expr, target_type, OpCodes.Conv_U4); case BuiltinTypeSpec.Type.Long: return new ConvCast(expr, target_type, ConvCast.Mode.I_I8); case BuiltinTypeSpec.Type.ULong: return new OpcodeCast(expr, target_type, OpCodes.Conv_U8); } } return null; } public static Expression ExplicitConversionStandard(ResolveContext ec, Expression expr, TypeSpec target_type, Location l) { int errors = ec.Report.Errors; Expression expression = ImplicitConversionStandard(ec, expr, target_type, l); if (ec.Report.Errors > errors) { return null; } if (expression != null) { return expression; } expression = ExplicitNumericConversion(ec, expr, target_type); if (expression != null) { return expression; } expression = ExplicitReferenceConversion(expr, expr.Type, target_type); if (expression != null) { return expression; } if (ec.IsUnsafe && expr.Type.IsPointer && target_type.IsPointer && ((PointerContainer)expr.Type).Element.Kind == MemberKind.Void) { return EmptyCast.Create(expr, target_type); } expr.Error_ValueCannotBeConverted(ec, target_type, expl: true); return null; } public static Expression ExplicitConversion(ResolveContext ec, Expression expr, TypeSpec target_type, Location loc) { Expression expression = ExplicitConversionCore(ec, expr, target_type, loc); if (expression != null) { if (expression == expr) { if (target_type.BuiltinType == BuiltinTypeSpec.Type.Float) { return new OpcodeCast(expr, target_type, OpCodes.Conv_R4); } if (target_type.BuiltinType == BuiltinTypeSpec.Type.Double) { return new OpcodeCast(expr, target_type, OpCodes.Conv_R8); } } return expression; } TypeSpec type = expr.Type; if (target_type.IsNullableType) { TypeSpec underlyingType; if (type.IsNullableType) { underlyingType = NullableInfo.GetUnderlyingType(target_type); Expression expression2 = Unwrap.Create(expr); expression = ExplicitConversion(ec, expression2, underlyingType, expr.Location); if (expression == null) { return null; } return new LiftedConversion(expression, expression2, target_type).Resolve(ec); } if (type.BuiltinType == BuiltinTypeSpec.Type.Object) { return new UnboxCast(expr, target_type); } underlyingType = TypeManager.GetTypeArguments(target_type)[0]; expression = ExplicitConversionCore(ec, expr, underlyingType, loc); if (expression != null) { return TypeSpec.IsReferenceType(expr.Type) ? new UnboxCast(expr, target_type) : Wrap.Create(expression, target_type); } } else if (type.IsNullableType) { expression = ImplicitBoxingConversion(expr, NullableInfo.GetUnderlyingType(type), target_type); if (expression != null) { return expression; } expression = Unwrap.Create(expr, useDefaultValue: false); expression = ExplicitConversionCore(ec, expression, target_type, loc); if (expression != null) { return EmptyCast.Create(expression, target_type); } } expression = ExplicitUserConversion(ec, expr, target_type, loc); if (expression != null) { return expression; } expr.Error_ValueCannotBeConverted(ec, target_type, expl: true); return null; } } internal sealed class CryptoConvert { private CryptoConvert() { } private static int ToInt32LE(byte[] bytes, int offset) { return (bytes[offset + 3] << 24) | (bytes[offset + 2] << 16) | (bytes[offset + 1] << 8) | bytes[offset]; } private static uint ToUInt32LE(byte[] bytes, int offset) { return (uint)((bytes[offset + 3] << 24) | (bytes[offset + 2] << 16) | (bytes[offset + 1] << 8) | bytes[offset]); } private static byte[] GetBytesLE(int val) { return new byte[4] { (byte)(val & 0xFF), (byte)((val >> 8) & 0xFF), (byte)((val >> 16) & 0xFF), (byte)((val >> 24) & 0xFF) }; } private static byte[] Trim(byte[] array) { for (int i = 0; i < array.Length; i++) { if (array[i] != 0) { byte[] array2 = new byte[array.Length - i]; Buffer.BlockCopy(array, i, array2, 0, array2.Length); return array2; } } return null; } public static RSA FromCapiPrivateKeyBlob(byte[] blob) { return FromCapiPrivateKeyBlob(blob, 0); } public static RSA FromCapiPrivateKeyBlob(byte[] blob, int offset) { RSAParameters parametersFromCapiPrivateKeyBlob = GetParametersFromCapiPrivateKeyBlob(blob, offset); RSA rSA = null; try { rSA = RSA.Create(); rSA.ImportParameters(parametersFromCapiPrivateKeyBlob); } catch (CryptographicException ex) { try { CspParameters cspParameters = new CspParameters(); cspParameters.Flags = CspProviderFlags.UseMachineKeyStore; rSA = new RSACryptoServiceProvider(cspParameters); rSA.ImportParameters(parametersFromCapiPrivateKeyBlob); } catch { throw ex; } } return rSA; } private static RSAParameters GetParametersFromCapiPrivateKeyBlob(byte[] blob, int offset) { if (blob == null) { throw new ArgumentNullException("blob"); } if (offset >= blob.Length) { throw new ArgumentException("blob is too small."); } RSAParameters result = default(RSAParameters); try { if (blob[offset] != 7 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || ToUInt32LE(blob, offset + 8) != 843141970) { throw new CryptographicException("Invalid blob header"); } int num = ToInt32LE(blob, offset + 12); byte[] array = new byte[4]; Buffer.BlockCopy(blob, offset + 16, array, 0, 4); Array.Reverse((Array)array); result.Exponent = Trim(array); int num2 = offset + 20; int num3 = num >> 3; result.Modulus = new byte[num3]; Buffer.BlockCopy(blob, num2, result.Modulus, 0, num3); Array.Reverse((Array)result.Modulus); num2 += num3; int num4 = num3 >> 1; result.P = new byte[num4]; Buffer.BlockCopy(blob, num2, result.P, 0, num4); Array.Reverse((Array)result.P); num2 += num4; result.Q = new byte[num4]; Buffer.BlockCopy(blob, num2, result.Q, 0, num4); Array.Reverse((Array)result.Q); num2 += num4; result.DP = new byte[num4]; Buffer.BlockCopy(blob, num2, result.DP, 0, num4); Array.Reverse((Array)result.DP); num2 += num4; result.DQ = new byte[num4]; Buffer.BlockCopy(blob, num2, result.DQ, 0, num4); Array.Reverse((Array)result.DQ); num2 += num4; result.InverseQ = new byte[num4]; Buffer.BlockCopy(blob, num2, result.InverseQ, 0, num4); Array.Reverse((Array)result.InverseQ); num2 += num4; result.D = new byte[num3]; if (num2 + num3 + offset <= blob.Length) { Buffer.BlockCopy(blob, num2, result.D, 0, num3); Array.Reverse((Array)result.D); } return result; } catch (Exception inner) { throw new CryptographicException("Invalid blob.", inner); } } public static DSA FromCapiPrivateKeyBlobDSA(byte[] blob) { return FromCapiPrivateKeyBlobDSA(blob, 0); } public static DSA FromCapiPrivateKeyBlobDSA(byte[] blob, int offset) { if (blob == null) { throw new ArgumentNullException("blob"); } if (offset >= blob.Length) { throw new ArgumentException("blob is too small."); } DSAParameters parameters = default(DSAParameters); try { if (blob[offset] != 7 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || ToUInt32LE(blob, offset + 8) != 844321604) { throw new CryptographicException("Invalid blob header"); } int num = ToInt32LE(blob, offset + 12); int num2 = num >> 3; int num3 = offset + 16; parameters.P = new byte[num2]; Buffer.BlockCopy(blob, num3, parameters.P, 0, num2); Array.Reverse((Array)parameters.P); num3 += num2; parameters.Q = new byte[20]; Buffer.BlockCopy(blob, num3, parameters.Q, 0, 20); Array.Reverse((Array)parameters.Q); num3 += 20; parameters.G = new byte[num2]; Buffer.BlockCopy(blob, num3, parameters.G, 0, num2); Array.Reverse((Array)parameters.G); num3 += num2; parameters.X = new byte[20]; Buffer.BlockCopy(blob, num3, parameters.X, 0, 20); Array.Reverse((Array)parameters.X); num3 += 20; parameters.Counter = ToInt32LE(blob, num3); num3 += 4; parameters.Seed = new byte[20]; Buffer.BlockCopy(blob, num3, parameters.Seed, 0, 20); Array.Reverse((Array)parameters.Seed); num3 += 20; } catch (Exception inner) { throw new CryptographicException("Invalid blob.", inner); } DSA dSA = null; try { dSA = DSA.Create(); dSA.ImportParameters(parameters); } catch (CryptographicException ex) { try { CspParameters cspParameters = new CspParameters(); cspParameters.Flags = CspProviderFlags.UseMachineKeyStore; dSA = new DSACryptoServiceProvider(cspParameters); dSA.ImportParameters(parameters); } catch { throw ex; } } return dSA; } public static byte[] ToCapiPrivateKeyBlob(RSA rsa) { RSAParameters rSAParameters = rsa.ExportParameters(includePrivateParameters: true); int num = rSAParameters.Modulus.Length; byte[] array = new byte[20 + (num << 2) + (num >> 1)]; array[0] = 7; array[1] = 2; array[5] = 36; array[8] = 82; array[9] = 83; array[10] = 65; array[11] = 50; byte[] bytesLE = GetBytesLE(num << 3); array[12] = bytesLE[0]; array[13] = bytesLE[1]; array[14] = bytesLE[2]; array[15] = bytesLE[3]; int num2 = 16; int num3 = rSAParameters.Exponent.Length; while (num3 > 0) { array[num2++] = rSAParameters.Exponent[--num3]; } num2 = 20; byte[] modulus = rSAParameters.Modulus; int num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; modulus = rSAParameters.P; num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; modulus = rSAParameters.Q; num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; modulus = rSAParameters.DP; num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; modulus = rSAParameters.DQ; num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; modulus = rSAParameters.InverseQ; num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; modulus = rSAParameters.D; num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); return array; } public static byte[] ToCapiPrivateKeyBlob(DSA dsa) { DSAParameters dSAParameters = dsa.ExportParameters(includePrivateParameters: true); int num = dSAParameters.P.Length; byte[] array = new byte[16 + num + 20 + num + 20 + 4 + 20]; array[0] = 7; array[1] = 2; array[5] = 34; array[8] = 68; array[9] = 83; array[10] = 83; array[11] = 50; byte[] bytesLE = GetBytesLE(num << 3); array[12] = bytesLE[0]; array[13] = bytesLE[1]; array[14] = bytesLE[2]; array[15] = bytesLE[3]; int num2 = 16; byte[] p = dSAParameters.P; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, num); num2 += num; p = dSAParameters.Q; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, 20); num2 += 20; p = dSAParameters.G; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, num); num2 += num; p = dSAParameters.X; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, 20); num2 += 20; Buffer.BlockCopy(GetBytesLE(dSAParameters.Counter), 0, array, num2, 4); num2 += 4; p = dSAParameters.Seed; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, 20); return array; } public static RSA FromCapiPublicKeyBlob(byte[] blob) { return FromCapiPublicKeyBlob(blob, 0); } public static RSA FromCapiPublicKeyBlob(byte[] blob, int offset) { RSAParameters parametersFromCapiPublicKeyBlob = GetParametersFromCapiPublicKeyBlob(blob, offset); try { RSA rSA = null; try { rSA = RSA.Create(); rSA.ImportParameters(parametersFromCapiPublicKeyBlob); } catch (CryptographicException) { CspParameters cspParameters = new CspParameters(); cspParameters.Flags = CspProviderFlags.UseMachineKeyStore; rSA = new RSACryptoServiceProvider(cspParameters); rSA.ImportParameters(parametersFromCapiPublicKeyBlob); } return rSA; } catch (Exception inner) { throw new CryptographicException("Invalid blob.", inner); } } private static RSAParameters GetParametersFromCapiPublicKeyBlob(byte[] blob, int offset) { if (blob == null) { throw new ArgumentNullException("blob"); } if (offset >= blob.Length) { throw new ArgumentException("blob is too small."); } try { if (blob[offset] != 6 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || ToUInt32LE(blob, offset + 8) != 826364754) { throw new CryptographicException("Invalid blob header"); } int num = ToInt32LE(blob, offset + 12); RSAParameters result = new RSAParameters { Exponent = new byte[3] }; result.Exponent[0] = blob[offset + 18]; result.Exponent[1] = blob[offset + 17]; result.Exponent[2] = blob[offset + 16]; int srcOffset = offset + 20; int num2 = num >> 3; result.Modulus = new byte[num2]; Buffer.BlockCopy(blob, srcOffset, result.Modulus, 0, num2); Array.Reverse((Array)result.Modulus); return result; } catch (Exception inner) { throw new CryptographicException("Invalid blob.", inner); } } public static DSA FromCapiPublicKeyBlobDSA(byte[] blob) { return FromCapiPublicKeyBlobDSA(blob, 0); } public static DSA FromCapiPublicKeyBlobDSA(byte[] blob, int offset) { if (blob == null) { throw new ArgumentNullException("blob"); } if (offset >= blob.Length) { throw new ArgumentException("blob is too small."); } try { if (blob[offset] != 6 || blob[offset + 1] != 2 || blob[offset + 2] != 0 || blob[offset + 3] != 0 || ToUInt32LE(blob, offset + 8) != 827544388) { throw new CryptographicException("Invalid blob header"); } int num = ToInt32LE(blob, offset + 12); DSAParameters parameters = default(DSAParameters); int num2 = num >> 3; int num3 = offset + 16; parameters.P = new byte[num2]; Buffer.BlockCopy(blob, num3, parameters.P, 0, num2); Array.Reverse((Array)parameters.P); num3 += num2; parameters.Q = new byte[20]; Buffer.BlockCopy(blob, num3, parameters.Q, 0, 20); Array.Reverse((Array)parameters.Q); num3 += 20; parameters.G = new byte[num2]; Buffer.BlockCopy(blob, num3, parameters.G, 0, num2); Array.Reverse((Array)parameters.G); num3 += num2; parameters.Y = new byte[num2]; Buffer.BlockCopy(blob, num3, parameters.Y, 0, num2); Array.Reverse((Array)parameters.Y); num3 += num2; parameters.Counter = ToInt32LE(blob, num3); num3 += 4; parameters.Seed = new byte[20]; Buffer.BlockCopy(blob, num3, parameters.Seed, 0, 20); Array.Reverse((Array)parameters.Seed); num3 += 20; DSA dSA = DSA.Create(); dSA.ImportParameters(parameters); return dSA; } catch (Exception inner) { throw new CryptographicException("Invalid blob.", inner); } } public static byte[] ToCapiPublicKeyBlob(RSA rsa) { RSAParameters rSAParameters = rsa.ExportParameters(includePrivateParameters: false); int num = rSAParameters.Modulus.Length; byte[] array = new byte[20 + num]; array[0] = 6; array[1] = 2; array[5] = 36; array[8] = 82; array[9] = 83; array[10] = 65; array[11] = 49; byte[] bytesLE = GetBytesLE(num << 3); array[12] = bytesLE[0]; array[13] = bytesLE[1]; array[14] = bytesLE[2]; array[15] = bytesLE[3]; int num2 = 16; int num3 = rSAParameters.Exponent.Length; while (num3 > 0) { array[num2++] = rSAParameters.Exponent[--num3]; } num2 = 20; byte[] modulus = rSAParameters.Modulus; int num4 = modulus.Length; Array.Reverse((Array)modulus, 0, num4); Buffer.BlockCopy(modulus, 0, array, num2, num4); num2 += num4; return array; } public static byte[] ToCapiPublicKeyBlob(DSA dsa) { DSAParameters dSAParameters = dsa.ExportParameters(includePrivateParameters: false); int num = dSAParameters.P.Length; byte[] array = new byte[16 + num + 20 + num + num + 4 + 20]; array[0] = 6; array[1] = 2; array[5] = 34; array[8] = 68; array[9] = 83; array[10] = 83; array[11] = 49; byte[] bytesLE = GetBytesLE(num << 3); array[12] = bytesLE[0]; array[13] = bytesLE[1]; array[14] = bytesLE[2]; array[15] = bytesLE[3]; int num2 = 16; byte[] p = dSAParameters.P; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, num); num2 += num; p = dSAParameters.Q; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, 20); num2 += 20; p = dSAParameters.G; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, num); num2 += num; p = dSAParameters.Y; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, num); num2 += num; Buffer.BlockCopy(GetBytesLE(dSAParameters.Counter), 0, array, num2, 4); num2 += 4; p = dSAParameters.Seed; Array.Reverse((Array)p); Buffer.BlockCopy(p, 0, array, num2, 20); return array; } public static RSA FromCapiKeyBlob(byte[] blob) { return FromCapiKeyBlob(blob, 0); } public static RSA FromCapiKeyBlob(byte[] blob, int offset) { if (blob == null) { throw new ArgumentNullException("blob"); } if (offset >= blob.Length) { throw new ArgumentException("blob is too small."); } switch (blob[offset]) { case 0: if (blob[offset + 12] == 6) { return FromCapiPublicKeyBlob(blob, offset + 12); } break; case 6: return FromCapiPublicKeyBlob(blob, offset); case 7: return FromCapiPrivateKeyBlob(blob, offset); } throw new CryptographicException("Unknown blob format."); } public static DSA FromCapiKeyBlobDSA(byte[] blob) { return FromCapiKeyBlobDSA(blob, 0); } public static DSA FromCapiKeyBlobDSA(byte[] blob, int offset) { if (blob == null) { throw new ArgumentNullException("blob"); } if (offset >= blob.Length) { throw new ArgumentException("blob is too small."); } return blob[offset] switch { 6 => FromCapiPublicKeyBlobDSA(blob, offset), 7 => FromCapiPrivateKeyBlobDSA(blob, offset), _ => throw new CryptographicException("Unknown blob format."), }; } public static byte[] ToCapiKeyBlob(AsymmetricAlgorithm keypair, bool includePrivateKey) { if (keypair == null) { throw new ArgumentNullException("keypair"); } if (keypair is RSA) { return ToCapiKeyBlob((RSA)keypair, includePrivateKey); } if (keypair is DSA) { return ToCapiKeyBlob((DSA)keypair, includePrivateKey); } return null; } public static byte[] ToCapiKeyBlob(RSA rsa, bool includePrivateKey) { if (rsa == null) { throw new ArgumentNullException("rsa"); } if (includePrivateKey) { return ToCapiPrivateKeyBlob(rsa); } return ToCapiPublicKeyBlob(rsa); } public static byte[] ToCapiKeyBlob(DSA dsa, bool includePrivateKey) { if (dsa == null) { throw new ArgumentNullException("dsa"); } if (includePrivateKey) { return ToCapiPrivateKeyBlob(dsa); } return ToCapiPublicKeyBlob(dsa); } public static string ToHex(byte[] input) { if (input == null) { return null; } StringBuilder stringBuilder = new StringBuilder(input.Length * 2); foreach (byte b in input) { stringBuilder.Append(b.ToString("X2", CultureInfo.InvariantCulture)); } return stringBuilder.ToString(); } private static byte FromHexChar(char c) { if (c >= 'a' && c <= 'f') { return (byte)(c - 97 + 10); } if (c >= 'A' && c <= 'F') { return (byte)(c - 65 + 10); } if (c >= '0' && c <= '9') { return (byte)(c - 48); } throw new ArgumentException("invalid hex char"); } public static byte[] FromHex(string hex) { if (hex == null) { return null; } if ((hex.Length & 1) == 1) { throw new ArgumentException("Length must be a multiple of 2"); } byte[] array = new byte[hex.Length >> 1]; int num = 0; int num2 = 0; while (num < array.Length) { array[num] = (byte)(FromHexChar(hex[num2++]) << 4); array[num++] += FromHexChar(hex[num2++]); } return array; } } internal class CSharpParser { [Flags] private enum ParameterModifierType { Ref = 2, Out = 4, This = 8, Params = 0x10, Arglist = 0x20, DefaultValue = 0x40, ReadOnly = 0x80, All = 0xFE, PrimaryConstructor = 0x56 } private class OperatorDeclaration { public readonly Operator.OpType optype; public readonly FullNamedExpression ret_type; public readonly Location location; public OperatorDeclaration(Operator.OpType op, FullNamedExpression ret_type, Location location) { optype = op; this.ret_type = ret_type; this.location = location; } } private static readonly object ModifierNone = 0; private static readonly object RefStructToken = new object(); private static readonly object RefPartialStructToken = new object(); private NamespaceContainer current_namespace; private TypeContainer current_container; private TypeDefinition current_type; private PropertyBase current_property; private EventProperty current_event; private EventField current_event_field; private FieldBase current_field; private Block current_block; private BlockVariable current_variable; private Delegate current_delegate; private AnonymousMethodExpression current_anonymous_method; private ParametersCompiled current_local_parameters; private bool parsing_anonymous_method; private bool async_block; private Stack oob_stack; private int yacc_verbose_flag; public bool UnexpectedEOF; private readonly CompilationSourceFile file; private string tmpComment; private string enumTypeComment; private string current_attr_target; private ParameterModifierType valid_param_mod; private bool default_parameter_used; public Class InteractiveResult; public Undo undo; private bool? interactive_async; private Stack linq_clause_blocks; private static int class_count; private ModuleContainer module; private readonly CompilerContext compiler; private readonly LanguageVersion lang_version; private readonly bool doc_support; private readonly CompilerSettings settings; private readonly Report report; private List parameters_bucket; private LocationsBag lbag; private List> mod_locations; private Stack location_stack; public TextWriter ErrorOutput = Console.Out; public int eof_token; protected const int yyFinal = 7; protected static readonly string[] yyNames = new string[440] { "end-of-file", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "EOF", "NONE", "ERROR", "FIRST_KEYWORD", "ABSTRACT", "AS", "ADD", "BASE", "BOOL", "BREAK", "BYTE", "CASE", "CATCH", "CHAR", "CHECKED", "CLASS", "CONST", "CONTINUE", "DECIMAL", "DEFAULT", "DEFAULT_VALUE", "DELEGATE", "DO", "DOUBLE", "ELSE", "ENUM", "EVENT", "EXPLICIT", "EXTERN", "FALSE", "FINALLY", "FIXED", "FLOAT", "FOR", "FOREACH", "GOTO", "IF", "IMPLICIT", "IN", "INT", "INTERFACE", "INTERNAL", "IS", "LOCK", "LONG", "NAMESPACE", "NEW", "NULL", "OBJECT", "OPERATOR", "OUT", "OVERRIDE", "PARAMS", "PRIVATE", "PROTECTED", "PUBLIC", "READONLY", "REF", "RETURN", "REMOVE", "SBYTE", "SEALED", "SHORT", "SIZEOF", "STACKALLOC", "STATIC", "STRING", "STRUCT", "SWITCH", "THIS", "THROW", "TRUE", "TRY", "TYPEOF", "UINT", "ULONG", "UNCHECKED", "UNSAFE", "USHORT", "USING", "VIRTUAL", "VOID", "VOLATILE", "WHERE", "WHILE", "ARGLIST", "PARTIAL", "ARROW", "FROM", "FROM_FIRST", "JOIN", "ON", "EQUALS", "SELECT", "GROUP", "BY", "LET", "ORDERBY", "ASCENDING", "DESCENDING", "INTO", "INTERR_NULLABLE", "EXTERN_ALIAS", "REFVALUE", "REFTYPE", "MAKEREF", "ASYNC", "AWAIT", "INTERR_OPERATOR", "WHEN", "INTERPOLATED_STRING", "INTERPOLATED_STRING_END", "THROW_EXPR", "GET", "SET", "LAST_KEYWORD", "OPEN_BRACE", "CLOSE_BRACE", "OPEN_BRACKET", "CLOSE_BRACKET", "OPEN_PARENS", "CLOSE_PARENS", "DOT", "COMMA", "COLON", "SEMICOLON", "TILDE", "PLUS", "MINUS", "BANG", "ASSIGN", "OP_LT", "OP_GT", "BITWISE_AND", "BITWISE_OR", "STAR", "PERCENT", "DIV", "CARRET", "INTERR", "DOUBLE_COLON", "OP_INC", "OP_DEC", "OP_SHIFT_LEFT", "OP_SHIFT_RIGHT", "OP_LE", "OP_GE", "OP_EQ", "OP_NE", "OP_AND", "OP_OR", "OP_MULT_ASSIGN", "OP_DIV_ASSIGN", "OP_MOD_ASSIGN", "OP_ADD_ASSIGN", "OP_SUB_ASSIGN", "OP_SHIFT_LEFT_ASSIGN", "OP_SHIFT_RIGHT_ASSIGN", "OP_AND_ASSIGN", "OP_XOR_ASSIGN", "OP_OR_ASSIGN", "OP_PTR", "OP_COALESCING", "OP_GENERICS_LT", "OP_GENERICS_LT_DECL", "OP_GENERICS_GT", "LITERAL", "IDENTIFIER", "OPEN_PARENS_LAMBDA", "OPEN_PARENS_CAST", "GENERIC_DIMENSION", "DEFAULT_COLON", "OPEN_BRACKET_EXPR", "OPEN_PARENS_DECONSTRUCT", "REF_STRUCT", "REF_PARTIAL", "EVAL_STATEMENT_PARSER", "EVAL_COMPILATION_UNIT_PARSER", "EVAL_USING_DECLARATIONS_UNIT_PARSER", "DOC_SEE", "GENERATE_COMPLETION", "COMPLETE_COMPLETION", "UMINUS" }; private int yyExpectingState; protected int yyMax; private static int[] global_yyStates; private static object[] global_yyVals; protected bool use_global_stacks; private object[] yyVals; private object yyVal; private int yyToken; private int yyTop; private static readonly short[] yyLhs = new short[1155] { -1, 0, 4, 0, 0, 1, 1, 1, 1, 2, 2, 11, 11, 12, 12, 13, 13, 14, 15, 15, 15, 16, 16, 20, 21, 18, 18, 23, 23, 23, 19, 19, 19, 24, 24, 25, 25, 7, 7, 6, 6, 22, 22, 8, 8, 26, 26, 26, 27, 27, 27, 27, 27, 9, 9, 10, 10, 35, 33, 38, 34, 34, 34, 34, 36, 36, 36, 37, 37, 42, 39, 40, 41, 41, 43, 43, 43, 43, 43, 44, 44, 44, 48, 45, 47, 47, 51, 52, 52, 50, 50, 55, 55, 56, 56, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 71, 66, 73, 73, 73, 78, 81, 82, 83, 29, 29, 86, 58, 58, 87, 87, 88, 88, 89, 91, 85, 85, 90, 90, 96, 59, 100, 59, 59, 95, 103, 95, 97, 97, 104, 104, 105, 106, 105, 101, 101, 107, 107, 108, 109, 99, 99, 102, 102, 102, 112, 60, 94, 114, 94, 115, 94, 118, 119, 110, 120, 121, 122, 110, 110, 110, 111, 111, 111, 126, 127, 127, 129, 127, 131, 125, 117, 117, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 133, 133, 136, 136, 136, 136, 139, 136, 137, 137, 140, 140, 141, 141, 141, 141, 134, 134, 134, 142, 142, 142, 135, 144, 146, 147, 149, 61, 150, 61, 148, 152, 148, 151, 151, 154, 156, 63, 155, 155, 145, 145, 145, 145, 145, 160, 157, 161, 158, 159, 159, 159, 159, 162, 163, 164, 166, 30, 30, 165, 165, 167, 167, 168, 168, 168, 168, 168, 168, 168, 168, 168, 170, 64, 171, 171, 174, 169, 169, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 176, 175, 177, 175, 175, 175, 65, 179, 181, 178, 180, 180, 184, 182, 185, 182, 182, 182, 186, 67, 188, 62, 191, 192, 62, 62, 187, 194, 187, 189, 189, 195, 195, 196, 196, 197, 193, 190, 190, 190, 190, 190, 201, 198, 202, 199, 200, 200, 200, 68, 69, 204, 206, 207, 31, 203, 203, 203, 205, 205, 205, 208, 208, 209, 210, 209, 209, 209, 211, 212, 213, 32, 214, 214, 17, 17, 17, 215, 215, 215, 219, 219, 217, 217, 217, 220, 220, 222, 76, 143, 116, 116, 153, 153, 223, 223, 223, 221, 221, 224, 224, 225, 225, 227, 227, 113, 84, 84, 98, 98, 138, 138, 172, 172, 229, 229, 229, 229, 233, 233, 235, 235, 234, 228, 232, 232, 232, 237, 237, 238, 236, 236, 236, 236, 236, 236, 236, 239, 239, 239, 239, 239, 239, 239, 239, 239, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 241, 241, 241, 242, 242, 242, 242, 264, 264, 265, 266, 266, 267, 267, 261, 261, 268, 268, 269, 269, 270, 269, 271, 269, 272, 272, 273, 273, 244, 244, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 263, 246, 246, 246, 275, 275, 276, 276, 277, 277, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 281, 281, 183, 183, 274, 274, 274, 274, 274, 286, 286, 285, 285, 287, 287, 287, 287, 287, 54, 288, 247, 247, 247, 247, 284, 284, 290, 290, 291, 291, 248, 249, 249, 250, 251, 252, 252, 243, 243, 243, 243, 243, 296, 292, 253, 253, 297, 297, 298, 298, 299, 299, 299, 299, 300, 300, 300, 300, 293, 293, 230, 230, 295, 295, 301, 301, 294, 294, 93, 93, 302, 302, 254, 303, 303, 218, 216, 255, 255, 256, 256, 257, 257, 258, 305, 259, 306, 259, 304, 304, 308, 307, 245, 262, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 311, 311, 311, 311, 311, 311, 311, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 313, 315, 315, 315, 315, 315, 315, 315, 315, 316, 317, 317, 318, 319, 319, 320, 320, 320, 320, 320, 321, 321, 321, 321, 321, 321, 321, 321, 321, 322, 322, 322, 322, 322, 323, 323, 323, 324, 324, 324, 325, 325, 325, 326, 326, 326, 327, 327, 327, 328, 328, 329, 329, 331, 331, 331, 331, 331, 331, 331, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 334, 334, 335, 335, 335, 336, 336, 337, 337, 337, 337, 338, 338, 340, 339, 339, 339, 130, 130, 53, 53, 342, 341, 343, 341, 344, 341, 345, 346, 341, 347, 348, 341, 46, 46, 282, 282, 282, 282, 260, 260, 260, 92, 350, 77, 77, 351, 352, 352, 352, 352, 354, 352, 355, 356, 357, 358, 28, 75, 75, 74, 74, 123, 123, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 359, 79, 79, 353, 353, 80, 80, 360, 360, 361, 361, 362, 362, 363, 363, 363, 363, 226, 226, 364, 364, 365, 124, 72, 72, 366, 128, 70, 70, 367, 367, 368, 368, 368, 368, 372, 372, 373, 373, 373, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 374, 388, 388, 388, 388, 375, 389, 371, 289, 289, 390, 390, 390, 390, 390, 391, 392, 392, 231, 231, 393, 49, 49, 395, 369, 398, 369, 400, 369, 401, 369, 394, 394, 394, 396, 396, 404, 404, 403, 403, 405, 405, 397, 397, 399, 399, 406, 406, 407, 402, 402, 402, 402, 330, 330, 332, 376, 376, 376, 387, 387, 408, 409, 409, 377, 377, 410, 410, 410, 413, 411, 411, 412, 412, 414, 414, 414, 415, 416, 416, 417, 417, 417, 417, 378, 378, 378, 378, 418, 418, 419, 419, 419, 423, 420, 426, 422, 422, 429, 425, 425, 428, 428, 430, 430, 424, 424, 433, 432, 432, 427, 427, 431, 431, 435, 434, 434, 421, 421, 436, 421, 379, 379, 379, 379, 379, 379, 437, 438, 438, 439, 439, 439, 440, 440, 440, 440, 441, 441, 441, 441, 442, 442, 442, 443, 443, 380, 380, 380, 380, 444, 444, 314, 314, 445, 448, 445, 445, 447, 447, 446, 449, 446, 381, 382, 450, 385, 383, 383, 452, 453, 386, 455, 456, 384, 384, 384, 454, 454, 451, 451, 349, 349, 349, 349, 457, 457, 459, 459, 461, 460, 462, 460, 458, 458, 458, 458, 458, 466, 464, 467, 469, 464, 468, 468, 463, 463, 470, 470, 470, 470, 470, 475, 471, 476, 472, 477, 478, 479, 473, 481, 482, 483, 473, 480, 480, 485, 474, 484, 488, 484, 487, 490, 487, 486, 486, 486, 489, 489, 489, 465, 491, 465, 3, 3, 492, 3, 3, 493, 493, 283, 283, 278, 278, 5, 494, 494, 494, 494, 494, 498, 494, 494, 494, 494, 495, 495, 496, 499, 496, 497, 497, 500, 500, 501 }; private static readonly short[] yyLen = new short[1155] { 2, 2, 0, 3, 1, 2, 4, 3, 1, 0, 1, 1, 2, 4, 2, 1, 2, 1, 4, 6, 2, 0, 1, 0, 0, 11, 3, 0, 1, 1, 1, 3, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 0, 1, 1, 2, 0, 3, 0, 6, 3, 2, 1, 1, 1, 1, 1, 3, 0, 3, 1, 0, 3, 0, 1, 1, 3, 3, 1, 1, 1, 0, 4, 4, 4, 1, 1, 1, 0, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 1, 1, 2, 0, 0, 0, 0, 16, 5, 0, 9, 5, 0, 1, 1, 2, 3, 0, 3, 1, 1, 1, 0, 8, 0, 9, 6, 0, 0, 3, 0, 1, 1, 2, 2, 0, 5, 0, 1, 1, 2, 3, 0, 4, 2, 1, 1, 1, 0, 3, 1, 0, 3, 0, 4, 0, 0, 10, 0, 0, 0, 12, 8, 5, 1, 1, 1, 1, 1, 1, 0, 4, 0, 4, 0, 1, 1, 3, 3, 3, 5, 3, 5, 1, 1, 1, 1, 3, 4, 6, 2, 4, 0, 7, 0, 1, 1, 2, 1, 1, 1, 1, 4, 6, 4, 1, 2, 2, 1, 0, 0, 0, 0, 12, 0, 6, 0, 0, 4, 1, 1, 0, 0, 10, 3, 1, 1, 2, 1, 2, 1, 0, 5, 0, 5, 1, 1, 1, 1, 0, 0, 0, 0, 15, 5, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 5, 1, 1, 0, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 7, 0, 7, 2, 2, 2, 0, 0, 9, 0, 1, 0, 6, 0, 6, 2, 1, 0, 8, 0, 9, 0, 0, 10, 5, 0, 0, 3, 0, 1, 1, 2, 2, 4, 0, 2, 2, 2, 1, 1, 1, 0, 5, 0, 5, 1, 1, 1, 2, 4, 0, 0, 0, 12, 0, 2, 2, 0, 1, 2, 1, 3, 2, 0, 5, 3, 1, 0, 0, 0, 13, 0, 1, 1, 3, 3, 1, 4, 4, 2, 2, 0, 3, 2, 1, 3, 0, 3, 1, 1, 3, 1, 2, 3, 4, 4, 0, 3, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 4, 2, 4, 0, 1, 1, 1, 2, 2, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 1, 3, 3, 1, 1, 3, 1, 3, 0, 4, 0, 6, 1, 1, 1, 1, 3, 3, 4, 4, 5, 4, 4, 4, 3, 3, 3, 4, 3, 4, 4, 4, 3, 0, 1, 3, 4, 0, 1, 1, 3, 2, 3, 3, 1, 2, 3, 5, 2, 1, 1, 0, 1, 1, 3, 3, 3, 2, 1, 1, 1, 1, 2, 2, 2, 4, 3, 2, 1, 4, 5, 4, 3, 1, 3, 1, 3, 1, 1, 1, 4, 3, 2, 2, 6, 3, 7, 4, 3, 7, 3, 0, 2, 4, 3, 1, 2, 0, 1, 1, 3, 1, 2, 3, 1, 1, 1, 0, 1, 1, 2, 2, 3, 1, 2, 0, 1, 2, 4, 1, 3, 4, 1, 1, 1, 2, 4, 4, 4, 2, 4, 2, 4, 0, 4, 0, 5, 0, 1, 0, 4, 4, 1, 1, 2, 2, 4, 2, 2, 2, 2, 4, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 1, 1, 2, 2, 1, 1, 4, 1, 1, 4, 1, 3, 3, 1, 2, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 1, 1, 1, 5, 6, 5, 4, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 3, 2, 4, 3, 1, 3, 3, 2, 1, 1, 0, 1, 0, 2, 1, 1, 1, 1, 1, 1, 0, 4, 0, 4, 0, 5, 0, 0, 7, 0, 0, 8, 1, 1, 1, 1, 1, 1, 6, 4, 4, 1, 1, 0, 1, 3, 0, 1, 1, 2, 0, 6, 0, 0, 0, 0, 15, 0, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 0, 1, 1, 2, 4, 3, 1, 3, 1, 3, 1, 1, 0, 1, 1, 1, 0, 4, 1, 1, 0, 4, 0, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 1, 2, 2, 2, 1, 2, 1, 3, 5, 4, 1, 2, 1, 1, 1, 0, 6, 0, 7, 0, 7, 0, 8, 0, 2, 1, 0, 1, 0, 1, 1, 2, 2, 4, 0, 2, 0, 1, 1, 2, 4, 1, 5, 2, 1, 5, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 5, 7, 4, 0, 8, 4, 0, 1, 1, 2, 1, 2, 1, 2, 3, 3, 4, 1, 1, 1, 1, 1, 5, 4, 7, 3, 6, 0, 4, 0, 5, 1, 0, 4, 2, 2, 2, 1, 1, 0, 1, 0, 5, 1, 0, 1, 0, 1, 1, 1, 3, 4, 5, 0, 9, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 4, 3, 3, 3, 3, 2, 3, 2, 3, 2, 4, 4, 3, 0, 1, 3, 4, 5, 3, 1, 2, 0, 1, 3, 0, 7, 3, 2, 1, 0, 0, 5, 2, 2, 0, 3, 5, 4, 0, 0, 10, 0, 0, 9, 5, 4, 2, 1, 0, 2, 2, 2, 2, 2, 4, 5, 4, 5, 0, 5, 0, 6, 3, 2, 2, 2, 1, 0, 3, 0, 0, 5, 2, 1, 1, 2, 1, 1, 1, 1, 1, 0, 5, 0, 3, 0, 0, 0, 12, 0, 0, 0, 13, 0, 2, 0, 3, 1, 0, 4, 1, 0, 4, 1, 2, 2, 1, 2, 2, 0, 0, 4, 2, 3, 0, 4, 2, 2, 3, 0, 1, 1, 1, 2, 2, 2, 2, 4, 3, 0, 7, 4, 4, 3, 1, 3, 0, 0, 4, 0, 1, 1, 3, 2 }; private static readonly short[] yyDefRed = new short[1813] { 0, 8, 0, 0, 0, 0, 0, 0, 0, 2, 4, 0, 0, 11, 14, 0, 1123, 0, 0, 1127, 0, 0, 15, 17, 431, 437, 444, 432, 434, 0, 433, 0, 440, 442, 429, 0, 436, 438, 430, 441, 443, 439, 0, 386, 1145, 0, 435, 1134, 0, 10, 1, 0, 0, 0, 12, 0, 943, 0, 0, 0, 0, 0, 621, 0, 0, 0, 475, 0, 0, 0, 0, 0, 0, 0, 473, 0, 0, 0, 0, 558, 0, 474, 0, 0, 0, 1045, 0, 0, 0, 775, 0, 0, 0, 0, 0, 0, 0, 0, 482, 0, 836, 0, 885, 0, 0, 0, 0, 0, 0, 0, 0, 472, 0, 764, 0, 0, 942, 0, 868, 0, 467, 894, 892, 0, 0, 0, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 469, 470, 471, 771, 0, 632, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 772, 770, 773, 774, 852, 854, 0, 850, 853, 869, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 870, 0, 0, 0, 944, 945, 964, 965, 966, 967, 1001, 1002, 1003, 1004, 1005, 1006, 0, 0, 0, 20, 22, 0, 1131, 16, 1124, 0, 0, 281, 298, 280, 277, 282, 283, 276, 295, 294, 287, 288, 284, 286, 285, 289, 278, 279, 290, 291, 297, 296, 292, 293, 0, 1148, 1137, 0, 0, 1136, 0, 1135, 3, 57, 0, 0, 0, 46, 43, 45, 48, 49, 50, 51, 52, 55, 13, 0, 0, 0, 1007, 608, 491, 492, 1043, 0, 0, 0, 0, 0, 0, 0, 0, 1009, 1008, 0, 618, 612, 617, 884, 941, 855, 882, 881, 883, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 0, 0, 0, 973, 0, 0, 0, 902, 901, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1016, 0, 0, 0, 0, 0, 0, 445, 0, 0, 0, 0, 1020, 1018, 0, 0, 0, 610, 1044, 0, 0, 0, 900, 425, 0, 0, 0, 0, 0, 0, 0, 405, 373, 0, 376, 406, 0, 415, 0, 0, 0, 0, 0, 0, 0, 767, 0, 631, 0, 0, 760, 0, 0, 626, 0, 0, 483, 627, 0, 0, 0, 0, 0, 0, 0, 629, 624, 639, 633, 640, 634, 628, 623, 644, 638, 643, 637, 641, 635, 642, 636, 758, 604, 0, 603, 468, 379, 380, 0, 0, 0, 0, 0, 0, 0, 0, 0, 886, 0, 372, 0, 423, 424, 0, 0, 561, 562, 0, 0, 0, 890, 891, 903, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1126, 851, 889, 0, 893, 939, 940, 1077, 1094, 0, 0, 1078, 1080, 0, 1106, 1063, 1061, 1087, 0, 0, 1085, 1088, 1089, 1090, 1091, 1064, 1062, 0, 0, 0, 0, 0, 0, 1144, 0, 0, 387, 0, 0, 1146, 0, 0, 44, 806, 812, 804, 0, 801, 811, 805, 803, 802, 809, 807, 808, 814, 810, 813, 815, 0, 0, 799, 47, 56, 560, 0, 556, 557, 0, 0, 554, 0, 905, 0, 0, 0, 971, 0, 938, 936, 937, 0, 0, 0, 779, 0, 1012, 1010, 780, 0, 0, 585, 0, 0, 573, 580, 0, 0, 0, 574, 0, 0, 590, 592, 0, 569, 0, 0, 0, 0, 0, 564, 0, 567, 571, 408, 407, 0, 907, 935, 1015, 1014, 1013, 0, 0, 1019, 1017, 1029, 0, 0, 0, 1030, 602, 0, 402, 601, 0, 0, 1046, 0, 0, 899, 0, 0, 421, 409, 0, 0, 0, 413, 414, 0, 0, 0, 412, 0, 0, 0, 645, 0, 0, 614, 0, 762, 663, 662, 0, 0, 0, 487, 0, 481, 849, 0, 0, 844, 846, 847, 848, 0, 495, 496, 476, 0, 0, 0, 895, 0, 0, 383, 384, 0, 212, 210, 209, 211, 747, 0, 0, 0, 0, 742, 0, 0, 0, 739, 0, 0, 0, 0, 1023, 0, 0, 0, 503, 504, 0, 507, 0, 0, 0, 0, 505, 0, 0, 551, 0, 511, 0, 0, 0, 0, 537, 540, 0, 0, 532, 539, 538, 0, 724, 725, 726, 727, 728, 729, 730, 731, 732, 734, 733, 649, 646, 651, 648, 650, 647, 660, 657, 661, 0, 0, 671, 0, 0, 0, 0, 0, 664, 0, 659, 672, 655, 0, 656, 0, 682, 0, 0, 683, 0, 689, 0, 690, 0, 691, 0, 692, 0, 696, 0, 697, 0, 700, 0, 703, 0, 706, 0, 709, 0, 712, 0, 714, 0, 715, 0, 716, 0, 589, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1076, 1075, 0, 1086, 0, 1074, 0, 18, 1142, 1143, 0, 0, 207, 0, 0, 1152, 401, 0, 0, 0, 398, 1138, 1140, 63, 65, 66, 0, 0, 58, 0, 0, 67, 69, 32, 30, 0, 0, 0, 796, 0, 800, 501, 0, 559, 0, 607, 0, 620, 196, 219, 0, 0, 0, 186, 0, 0, 0, 197, 613, 0, 1049, 977, 0, 995, 974, 0, 986, 0, 997, 0, 1011, 948, 0, 1048, 0, 0, 572, 0, 581, 591, 593, 0, 0, 0, 0, 523, 0, 0, 518, 0, 0, 757, 756, 552, 0, 595, 566, 0, 0, 158, 596, 156, 157, 598, 0, 909, 0, 606, 605, 951, 0, 1041, 0, 0, 1027, 0, 1031, 600, 609, 1056, 0, 1052, 969, 0, 0, 0, 420, 417, 0, 1067, 0, 374, 375, 1065, 0, 0, 777, 778, 0, 0, 0, 753, 752, 761, 0, 502, 0, 0, 484, 838, 839, 837, 845, 480, 479, 478, 477, 0, 0, 759, 0, 382, 745, 0, 0, 0, 630, 625, 737, 0, 738, 0, 741, 0, 1022, 1021, 887, 508, 500, 0, 0, 506, 497, 498, 611, 550, 548, 547, 543, 542, 0, 541, 0, 536, 493, 494, 509, 510, 0, 913, 0, 0, 666, 667, 0, 0, 1033, 658, 0, 721, 0, 0, 1095, 1069, 0, 1096, 0, 1079, 1081, 1092, 0, 1107, 0, 1073, 1121, 0, 1154, 208, 1149, 0, 835, 834, 0, 833, 0, 397, 0, 62, 59, 0, 0, 0, 0, 0, 0, 0, 161, 404, 0, 790, 0, 111, 112, 0, 0, 0, 90, 0, 555, 0, 0, 0, 0, 0, 201, 619, 0, 0, 0, 0, 0, 987, 975, 0, 998, 0, 0, 1047, 582, 579, 0, 527, 0, 0, 0, 1132, 1133, 514, 520, 0, 524, 0, 0, 0, 0, 0, 0, 0, 0, 949, 0, 1037, 0, 1034, 1028, 1055, 0, 968, 416, 0, 377, 378, 1068, 1066, 0, 615, 0, 763, 754, 751, 755, 489, 488, 0, 897, 385, 744, 743, 765, 735, 736, 740, 499, 549, 546, 545, 0, 535, 534, 533, 0, 929, 932, 912, 0, 0, 0, 918, 0, 0, 0, 674, 0, 722, 0, 723, 718, 720, 0, 1071, 0, 1100, 0, 0, 1115, 1116, 1109, 0, 19, 1153, 400, 399, 0, 0, 68, 61, 0, 70, 31, 24, 164, 0, 0, 0, 350, 0, 255, 0, 113, 119, 114, 85, 87, 88, 84, 86, 923, 131, 132, 0, 0, 0, 926, 217, 218, 0, 0, 0, 0, 189, 198, 190, 192, 972, 0, 0, 0, 0, 0, 996, 0, 0, 528, 529, 522, 525, 521, 0, 515, 519, 0, 587, 0, 553, 563, 513, 599, 597, 0, 0, 0, 0, 0, 1058, 0, 0, 418, 776, 768, 0, 896, 0, 544, 0, 0, 904, 919, 670, 0, 673, 0, 0, 719, 1070, 0, 0, 0, 1084, 0, 1082, 1093, 0, 1122, 1141, 0, 81, 0, 0, 75, 76, 79, 80, 0, 0, 163, 367, 356, 355, 0, 791, 251, 0, 0, 906, 927, 202, 0, 215, 0, 0, 0, 970, 1060, 0, 0, 0, 991, 0, 0, 999, 947, 0, 568, 565, 0, 908, 956, 0, 963, 0, 0, 954, 0, 958, 0, 1035, 1057, 1053, 0, 490, 766, 0, 0, 0, 677, 676, 675, 933, 1072, 1097, 0, 1083, 0, 0, 1111, 0, 82, 73, 0, 0, 165, 0, 351, 0, 0, 0, 0, 782, 0, 0, 203, 0, 193, 191, 1050, 988, 976, 984, 983, 978, 980, 0, 526, 910, 0, 0, 950, 955, 0, 959, 1042, 0, 0, 769, 0, 921, 678, 0, 1101, 1118, 1119, 1112, 60, 0, 77, 78, 0, 0, 0, 0, 0, 0, 785, 0, 817, 0, 0, 928, 200, 0, 214, 0, 0, 1000, 961, 960, 0, 1039, 0, 1036, 1054, 930, 0, 0, 0, 83, 0, 0, 368, 0, 0, 366, 352, 0, 360, 428, 0, 426, 0, 0, 792, 0, 822, 252, 783, 115, 204, 1051, 979, 0, 0, 993, 962, 840, 1038, 1098, 0, 1113, 0, 0, 0, 348, 0, 0, 819, 0, 788, 0, 0, 823, 0, 0, 982, 981, 0, 0, 1102, 29, 28, 25, 369, 365, 0, 0, 361, 427, 0, 825, 0, 0, 0, 116, 0, 0, 0, 0, 0, 34, 353, 0, 830, 0, 831, 828, 0, 826, 108, 109, 0, 105, 0, 0, 93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 106, 107, 159, 0, 0, 268, 260, 261, 262, 263, 264, 265, 266, 267, 0, 0, 258, 0, 841, 0, 1099, 0, 370, 364, 789, 0, 0, 0, 0, 793, 94, 0, 181, 180, 305, 179, 0, 253, 259, 0, 1105, 1103, 829, 827, 0, 0, 0, 0, 0, 0, 0, 0, 317, 0, 0, 0, 269, 0, 0, 275, 0, 183, 177, 160, 175, 176, 0, 0, 117, 110, 0, 0, 304, 0, 0, 303, 0, 169, 0, 0, 391, 0, 389, 0, 0, 0, 0, 0, 0, 349, 0, 0, 794, 0, 0, 254, 0, 122, 120, 324, 0, 388, 0, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 174, 166, 0, 0, 0, 232, 0, 392, 0, 270, 0, 0, 182, 118, 0, 321, 0, 301, 137, 0, 299, 0, 0, 0, 139, 0, 393, 0, 0, 221, 226, 0, 0, 0, 390, 273, 184, 130, 128, 0, 0, 326, 0, 0, 0, 0, 0, 170, 0, 307, 0, 0, 0, 0, 143, 0, 0, 0, 0, 394, 395, 0, 0, 0, 0, 0, 125, 340, 0, 322, 0, 0, 334, 0, 0, 0, 330, 0, 155, 0, 0, 0, 0, 150, 0, 0, 178, 318, 0, 140, 0, 134, 144, 167, 173, 241, 0, 222, 0, 0, 233, 0, 129, 0, 121, 126, 0, 0, 0, 336, 0, 337, 327, 0, 0, 320, 331, 302, 0, 0, 136, 151, 300, 0, 316, 0, 308, 310, 146, 0, 0, 0, 238, 240, 0, 274, 127, 341, 343, 323, 0, 0, 335, 334, 154, 152, 171, 315, 0, 0, 0, 168, 242, 244, 223, 0, 236, 234, 0, 0, 333, 0, 311, 313, 147, 0, 0, 0, 0, 345, 346, 347, 342, 344, 172, 0, 0, 249, 248, 246, 247, 243, 245, 228, 224, 235, 0, 0, 0, 312, 314, 230, 231, 0, 229 }; protected static readonly short[] yyDgoto = new short[502] { 7, 8, 50, 9, 51, 10, 11, 52, 245, 832, 833, 12, 13, 53, 22, 23, 206, 345, 248, 817, 1025, 1264, 1409, 1461, 1787, 1022, 249, 250, 251, 252, 253, 254, 255, 256, 810, 503, 811, 812, 1155, 813, 814, 1159, 1023, 1259, 1260, 1261, 281, 696, 1375, 117, 1039, 1176, 1173, 875, 970, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 636, 1532, 933, 1036, 522, 821, 1587, 1338, 1273, 1385, 1422, 1453, 1522, 1601, 1417, 1657, 1632, 1682, 1683, 1684, 1178, 1680, 1179, 884, 1559, 1643, 1616, 1670, 577, 1663, 1637, 1699, 1123, 1668, 1671, 1672, 1768, 1700, 1701, 1697, 1507, 1568, 1536, 1028, 1163, 1265, 1588, 834, 1645, 1747, 1613, 1703, 1779, 523, 282, 1570, 1705, 1539, 1436, 1571, 1101, 1598, 835, 836, 837, 838, 839, 792, 661, 1391, 793, 794, 1045, 1590, 1621, 1715, 1675, 1749, 1802, 1785, 1622, 1811, 1806, 1591, 1649, 1775, 1752, 1716, 1717, 1799, 1783, 1784, 1169, 1336, 1452, 1519, 1572, 1520, 1521, 1561, 1595, 1562, 348, 235, 1679, 1564, 1664, 1661, 1508, 1584, 1744, 1706, 1745, 697, 1793, 1794, 1583, 1660, 1634, 1692, 1687, 1658, 1725, 1730, 1690, 1693, 1694, 1731, 1688, 1689, 1790, 1776, 1777, 1166, 1270, 1414, 1380, 1444, 1415, 1416, 1464, 1333, 1441, 1477, 418, 349, 119, 403, 404, 120, 654, 499, 238, 1608, 801, 802, 1014, 1029, 121, 353, 465, 340, 354, 609, 610, 909, 323, 1418, 1419, 46, 124, 324, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 378, 379, 372, 373, 929, 1231, 266, 978, 880, 1216, 1205, 868, 1069, 869, 870, 1206, 150, 209, 876, 699, 700, 701, 971, 151, 532, 533, 312, 1214, 878, 466, 314, 561, 562, 563, 564, 567, 886, 599, 278, 538, 920, 279, 537, 152, 153, 154, 155, 732, 989, 733, 734, 1132, 1133, 1317, 156, 157, 158, 159, 160, 161, 162, 163, 164, 769, 770, 165, 1102, 166, 410, 411, 663, 664, 665, 925, 926, 167, 651, 629, 922, 405, 1233, 625, 1310, 168, 552, 1339, 1383, 1386, 1468, 1167, 1335, 1450, 1565, 524, 1423, 1424, 1486, 1487, 1015, 375, 1456, 637, 638, 283, 284, 285, 171, 172, 173, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 185, 298, 676, 186, 187, 381, 341, 983, 702, 1127, 1042, 828, 1182, 888, 1079, 1125, 1128, 1286, 1129, 1183, 1184, 299, 188, 189, 190, 1301, 1222, 1302, 1303, 1304, 1305, 191, 192, 193, 194, 846, 545, 847, 1289, 1200, 1290, 1430, 1394, 1352, 1431, 848, 1199, 849, 1433, 1353, 195, 196, 197, 198, 199, 200, 326, 593, 594, 895, 1401, 1363, 1082, 337, 1198, 1052, 1393, 1227, 1088, 1364, 201, 479, 202, 480, 1140, 1246, 481, 482, 787, 778, 779, 1251, 1144, 483, 484, 485, 486, 487, 1145, 773, 1142, 1369, 1457, 1525, 1248, 1405, 1476, 1003, 781, 1004, 1325, 1253, 1326, 1406, 1149, 17, 19, 47, 48, 237, 795, 1018, 497, 796, 797 }; protected static readonly short[] yySindex = new short[1813] { -84, 0, -141, 133, 45, 94, 2539, 0, 184, 0, 0, 94, 45, 0, 0, 105, 0, 9799, 94, 0, -116, -192, 0, 0, 0, 0, 0, 0, 0, 274, 0, 383, 0, 0, 0, 9409, 0, 0, 0, 0, 0, 0, 214, 0, 0, 614, 0, 0, 638, 0, 0, 184, 221, 94, 0, 342, 0, 330, 359, -138, 21246, -151, 0, 270, 439, 9970, 0, 270, 270, 270, 88, 270, 270, 789, 0, 21138, 11296, 270, 270, 0, 11460, 0, 411, 270, -119, 0, 270, 462, 270, 0, 20618, 20618, 450, 270, 270, 19, 13995, 20001, 0, 20742, 0, 19149, 0, 14412, 14551, 14690, 14829, 14968, 15107, 15246, 15385, 0, 609, 0, 18885, 19291, 0, 337, 0, -228, 0, 0, 0, 719, 988, 409, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -228, 0, 967, 444, 193, 503, 814, 677, 472, 477, 523, 516, 521, 606, 0, 0, 0, 0, 0, 0, 4904, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 680, 733, -249, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 168, 221, 0, 0, 649, 0, 0, 0, 18885, 18885, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 0, 0, 706, 691, 0, 65, 0, 0, 0, 221, 22017, 981, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 845, -228, 20143, 0, 0, 0, 0, 0, 20001, -156, -139, 874, 760, -256, 988, -228, 0, 0, 18885, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130, 226, 21246, 0, 18885, 20001, 781, 0, 0, 799, 20001, 20001, 7892, 568, -149, 769, 18885, 21246, -228, 0, 20001, 13995, 20285, 609, 933, 818, 0, 826, 837, 18885, 20001, 0, 0, -98, 732, 1781, 0, 0, 20001, 411, 19291, 0, 0, 462, 20001, 19169, 738, 721, 939, -228, 0, 0, 804, 0, 0, 680, 0, 409, 951, -228, 20601, 20001, 20001, 439, 0, 931, 0, 18885, 18885, 0, 14273, -228, 0, 1045, 1037, 0, 0, 10141, 598, 285, 831, 889, 871, 847, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1840, 0, 0, 0, 0, 21716, 738, 937, 945, -228, 908, 955, 927, 20001, 0, 699, 0, 290, 0, 0, -241, 329, 0, 0, 905, 12280, 10476, 0, 0, 0, 20001, 20001, 20001, 20001, 20001, 20001, 20001, 20001, 20001, 20001, 20001, 15524, 15663, 15802, 12789, 18165, 15941, 16080, 16219, 16358, 16497, 16636, 16775, 16914, 17053, 17192, 17331, 17470, 17609, 17748, 17887, 20878, 19007, 0, 0, 0, 680, 0, 0, 0, 0, 0, 20618, 20618, 0, 0, -228, 0, 0, 0, 0, 217, 985, 0, 0, 0, 0, 0, 0, 0, 221, 981, 629, 570, 214, 214, 0, 823, 155, 0, 214, 984, 0, -148, 22017, 0, 0, 0, 0, -131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -135, 22047, 0, 0, 0, 0, 942, 0, 0, 992, 877, 0, 991, 0, 1018, 230, 411, 0, 270, 0, 0, 0, -228, 11624, -161, 0, 1010, 0, 0, 0, -137, 146, 0, 760, -256, 0, 0, 979, 0, 1025, 0, 1029, 977, 0, 0, 901, 0, 13056, 903, 12444, 769, 18865, 0, 10968, 0, 0, 0, 0, -228, 0, 0, 0, 0, 0, 154, 156, 0, 0, 0, -227, 411, -109, 0, 0, 462, 0, 0, 1042, 1051, 0, 191, -228, 0, 205, 462, 0, 0, 959, 1022, 1030, 0, 0, 20001, 1162, 699, 0, 20001, 1185, 1102, 0, 1106, 1108, 0, 21716, 0, 0, 0, 115, 942, 20001, 0, 20001, 0, 0, 11, 10141, 0, 0, 0, 0, 20001, 0, 0, 0, 20285, 20285, 1115, 0, 21246, 115, 0, 0, 76, 0, 0, 0, 0, 0, 738, -228, 19169, 1120, 0, 1129, 18026, 20001, 0, 1132, 20001, 1141, 21354, 0, 1260, 1111, 10141, 0, 0, 1092, 0, 942, -228, 20143, 1095, 0, 699, 942, 0, 101, 0, 19291, 20001, 1146, 1274, 0, 0, 322, -160, 0, 0, 0, -147, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20742, 20742, 0, 18885, 692, 0, 0, 0, 0, -228, 0, 0, 0, 444, 0, 444, 0, 14134, 193, 0, 193, 0, 503, 0, 503, 0, 503, 0, 503, 0, 814, 0, 814, 0, 677, 0, 472, 0, 477, 0, 523, 0, 516, 0, 18885, 0, -23, 0, 1153, 0, 12444, 1240, -228, 1242, -228, 12444, 12444, 1151, 20001, 0, 0, 985, 0, -228, 0, 1117, 0, 0, 0, 19169, 823, 0, 1164, 1160, 0, 0, 779, 221, 430, 0, 0, 0, 0, 0, 0, -163, 1165, 0, 1166, 1163, 0, 0, 0, 0, 1167, 12934, 1126, 0, 196, 0, 0, 853, 0, 20143, 0, 1168, 0, 0, 0, 864, 201, 1174, 0, 1173, 1176, 1177, 0, 0, 20001, 0, 0, -228, 0, 0, 1180, 0, 1178, 0, 487, 0, 0, 9970, 0, 9970, 11788, 0, 18358, 0, 0, 0, 13856, 11952, 504, 18865, 0, 173, -143, 0, 1121, 1137, 0, 0, 0, 904, 0, 0, 1187, 1183, 0, 0, 0, 0, 0, 1188, 0, -147, 0, 0, 0, 1194, 0, 18427, 411, 0, 411, 0, 0, 0, 0, 9970, 0, 0, 9970, 733, 19169, 0, 0, 699, 0, 20001, 0, 0, 0, 20001, 18885, 0, 0, 411, 1191, 115, 0, 0, 0, 19433, 0, 1193, 1149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21246, 1152, 0, 18885, 0, 0, -228, 21716, 1233, 0, 0, 0, 20001, 0, 20001, 0, -228, 0, 0, 0, 0, 0, 942, 918, 0, 0, 0, 0, 0, 0, 0, 0, 0, -228, 0, 18723, 0, 0, 0, 0, 0, 11132, 0, 10640, 1198, 0, 0, 1201, -228, 0, 0, 1154, 0, 10804, 1268, 0, 0, 1289, 0, 1291, 0, 0, 0, 1113, 0, 1207, 0, 0, 588, 0, 0, 0, 823, 0, 0, 1169, 0, 155, 0, 823, 0, 0, 1117, 1212, 1214, 1171, 1216, 1279, 1126, 0, 0, 1213, 0, 1340, 0, 0, 1273, -130, 12116, 0, 12444, 0, 19575, 1218, 864, 19169, 18885, 0, 0, 469, 1343, 1344, 206, 1217, 0, 0, 20001, 0, 20001, 1320, 0, 0, 0, 19717, 0, 802, 19717, 925, 0, 0, 0, 0, 12914, 0, 1349, 680, 12444, 1234, 11788, 1232, -147, 1198, 0, 270, 0, -228, 0, 0, 0, -128, 0, 0, 1022, 0, 0, 0, 0, 1230, 0, 1265, 0, 0, 0, 0, 0, 0, 1189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 960, 0, 0, 0, 18885, 0, 0, 0, -228, 1229, 1198, 0, 20742, 1313, 811, 0, 20001, 0, 20742, 0, 0, 0, 12444, 0, 12444, 0, -133, 12444, 0, 0, 0, 633, 0, 0, 0, 0, 1241, 1117, 0, 0, 12608, 0, 0, 0, 0, 18885, 1239, 18496, 0, 1126, 0, 1126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -228, 1236, 1218, 0, 0, 0, -134, -124, 1244, 1246, 0, 0, 0, 0, 0, 1238, 11788, 1198, -147, 20001, 0, 1243, 9970, 0, 0, 0, 0, 0, 1235, 0, 0, 1252, 0, 769, 0, 0, 0, 0, 0, 1198, 1247, -157, 20001, 1254, 0, 1198, 1255, 0, 0, 0, 1196, 0, 115, 0, 1205, 1248, 0, 0, 0, 21014, 0, -228, 1262, 0, 0, 12444, 1282, 12444, 0, 12444, 0, 0, 20001, 0, 0, 1163, 0, 607, 969, 0, 0, 0, 0, 45, 18885, 0, 0, 0, 0, 1263, 0, 0, 1266, 1259, 0, 0, 0, 703, 0, 1261, 1383, 1391, 0, 0, 1198, 1271, 1198, 0, 9970, -212, 0, 0, 19717, 0, 0, 1270, 0, 0, 19291, 0, 1276, -115, 0, 9628, 0, 1275, 0, 0, 0, 115, 0, 0, 20001, 10640, -228, 0, 0, 0, 0, 0, 0, 1306, 0, 1133, 1277, 0, 1283, 0, 0, 12608, 94, 0, 230, 0, 863, 1280, 230, 1280, 0, 19575, 1286, 0, 20001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9970, 0, 0, -5, 1231, 0, 0, 10141, 0, 0, -153, 9970, 0, 1288, 0, 0, 12444, 0, 0, 0, 0, 0, 20001, 0, 0, 221, 1287, 221, 18885, 1280, 1318, 0, 1318, 0, 1292, 1318, 0, 0, 20001, 0, 9970, 20001, 0, 0, 0, 1290, 0, 1294, 0, 0, 0, 1325, 12444, 20001, 0, 221, 1301, 0, 1253, 1116, 0, 0, 1298, 0, 0, 147, 0, 1302, 1258, 0, 1318, 0, 0, 0, 0, 0, 0, 0, 929, 1178, 0, 0, 0, 0, 0, 1335, 0, -8, 1318, 1429, 0, 1312, 221, 0, 18885, 0, 83, 1314, 0, 1315, 1316, 0, 0, 10141, 12444, 0, 0, 0, 0, 0, 0, 1303, 1310, 0, 0, 18865, 0, 21928, 178, 221, 0, 1319, 1337, 12444, 1321, 20001, 0, 0, 1317, 0, 1323, 0, 0, 1322, 0, 0, 0, 22047, 0, 1324, 178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -196, 22047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1327, 221, 0, 178, 0, -228, 0, 1337, 0, 0, 0, 1326, 21928, 10141, 21462, 0, 0, 538, 0, 0, 0, 0, 21536, 0, 0, 1331, 0, 0, 0, 0, 11, 18885, 18885, 142, 18885, 494, 462, 1358, 0, 738, 835, 1332, 0, 1401, 0, 0, 1310, 0, 0, 0, 0, 0, 20001, 1310, 0, 0, -110, -107, 0, 18885, -93, 0, 18885, 0, 1295, 1334, 0, 415, 0, 172, 1990, 0, 1338, 1296, 79, 0, 538, 9409, 0, 19433, 1330, 0, 1310, 0, 0, 0, 415, 0, 1345, 1297, 1339, 1341, 0, 1347, 1304, 1350, 230, 1346, 1351, 0, 0, 1354, 1353, 1378, 0, 942, 0, 1076, 0, 1355, 1352, 0, 0, -9, 0, 1356, 0, 0, 1362, 0, 1361, 1363, 1364, 0, 1359, 0, 230, 230, 0, 0, 230, 1365, 1366, 0, 0, 0, 0, 0, 1367, 210, 0, 1369, 230, 1441, 1370, 230, 0, 538, 0, 11788, 1328, 1372, 1359, 0, 1368, 1380, 213, 1384, 0, 0, 230, 19575, 1357, 1379, 1367, 0, 0, 22047, 0, 221, 221, 0, 1360, 1381, 1369, 0, 1386, 0, 20001, 1388, 1387, 1370, 0, 1390, 230, 0, 0, 110, 0, 1375, 0, 0, 0, 0, 0, 22047, 0, 213, 213, 0, 1392, 0, -9, 0, 0, -121, 1397, 22047, 0, 22047, 0, 0, 11788, 1393, 0, 0, 0, 1389, 1362, 0, 0, 0, 1400, 0, 413, 0, 0, 0, 1318, 1128, 1405, 0, 0, 511, 0, 0, 0, 0, 0, 1459, 1520, 0, 0, 0, 0, 0, 0, 1409, 1410, 11788, 0, 0, 0, 0, 213, 0, 0, 548, 548, 0, 1318, 0, 0, 0, 258, 258, 1404, 1414, 0, 0, 0, 0, 0, 0, 18865, 18865, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1424, 1425, 19575, 0, 0, 0, 0, 1426, 0 }; protected static readonly short[] yyRindex = new short[1813] { 4182, 0, 0, 10312, 4182, 0, 0, 0, 1792, 0, 0, 4426, 2054, 0, 0, 0, 0, 0, 4426, 0, 1394, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1810, 0, 0, 1810, 0, 0, 1810, 0, 0, 1792, 4469, 4269, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1442, 0, 0, 0, 0, 0, 0, 0, 0, 19311, 0, 0, 1432, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3876, 0, 0, 0, 0, 0, 0, 0, 0, 404, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6553, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7280, 6482, 6785, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7360, 7513, 7894, 8153, 1601, 8755, 8901, 1526, 9120, 6421, 2164, 2374, 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7433, 7280, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4543, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1810, 0, 0, 392, 0, 0, 0, 0, 0, 0, 4607, 360, 4679, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5327, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1443, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5492, 1437, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3588, 0, 0, 215, 3724, 0, 0, 0, 0, 0, 0, 0, 4028, 0, 3724, 0, 0, 0, 0, 0, 1442, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1134, 0, 0, 0, 247, 9462, 1445, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1444, 3436, 0, 0, 0, 0, 0, 0, 1432, 0, 5327, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 338, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2603, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5759, 0, 0, 0, 0, 0, 0, 0, 4722, 4794, 651, 0, 1810, 1810, 0, 21371, 72, 0, 1810, 1823, 0, 0, 202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 228, 18281, 0, 0, 0, 0, 5327, 0, 0, 0, 0, 0, 0, 0, 0, 21568, 0, 0, 0, 0, 0, 0, 0, 1446, 0, 0, 0, 0, 0, 0, 0, 0, 0, 441, 2474, 0, 0, 308, 893, 0, 0, 1453, 838, 0, 0, 0, 0, 275, 0, 0, 5987, 1451, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1457, 0, 3000, 0, 0, 436, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126, 0, 0, 0, 970, 0, 0, 0, 0, 0, 3284, 0, 0, 0, 0, 0, 0, 0, 0, 1444, 0, 0, 0, 19859, 5327, 0, 0, 0, 0, 0, 0, 317, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19859, 0, 0, 0, 0, 0, 0, 0, 0, 776, 0, 0, 1454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1437, 0, 0, 0, 0, 5162, 0, 5327, 0, 0, 4996, 0, 5327, 6152, 0, 0, 0, 0, 0, -186, 0, 0, 0, 0, 339, 0, 0, 0, 861, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6718, 6950, 7060, 7170, 0, 7586, 0, 0, 0, 7666, 0, 7739, 0, 0, 8001, 0, 8077, 0, 8229, 0, 8305, 0, 8381, 0, 8457, 0, 8609, 0, 8682, 0, 8828, 0, 8974, 0, 9047, 0, 9193, 0, 9266, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5759, 0, 0, 0, 0, 0, 0, 0, 0, 19453, 0, 0, 1024, 0, 0, 1407, 13225, 0, 0, 0, 0, 0, 0, 0, 1014, -201, 0, 0, 1458, 0, 0, 0, 0, 2343, 0, 0, 0, 0, 0, 0, 12772, 0, 0, 0, 1039, 0, 0, 0, 19595, 21790, 0, 0, 1054, 1057, 1060, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1455, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1461, 0, 0, 0, 0, 0, 8517, 0, 0, 0, 320, 0, 299, 5657, 0, 0, 0, 0, 0, 0, 0, 1462, 0, 0, 0, 0, 0, 1465, 0, 861, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3724, 0, 0, 0, 3284, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19859, 0, 0, 0, 0, 0, 1136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5327, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1466, 0, 0, 0, 0, 0, 0, 2790, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -136, 0, 443, 0, 0, 0, 0, 0, 0, 19595, 0, 0, 0, 0, 72, 0, 18743, 0, 0, 1460, 0, 936, 0, 0, 19737, 0, 0, 0, 1470, 0, 1420, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1467, 19879, 0, 0, 0, 0, 21859, 0, 0, 0, 1072, 0, 0, 0, 0, 0, 3175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5822, 0, 6317, 1473, 0, 861, 1466, 0, 0, 0, 1474, 0, 0, 0, 1072, 0, 0, 970, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1471, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1075, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1472, 0, 0, 0, 0, 0, 1082, 1086, 0, 0, 0, 0, 0, 0, 0, 1480, 861, -209, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5987, 0, 0, 0, 0, 0, 1466, 0, 1485, 0, 0, 0, 1480, 0, 0, 0, 0, 0, 0, 19859, 0, 734, 842, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1458, 0, 5229, 0, 0, 0, 0, 0, 13693, 0, 0, 0, 0, 0, 0, 0, 0, 480, 0, 0, 0, 0, 816, 0, 876, 0, 0, 0, 0, 1482, 0, 1466, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1489, 0, 0, 0, 0, 0, 0, 0, 19859, 0, 0, 0, 0, 841, 0, 0, 0, 0, 0, 0, 0, 0, 357, 524, 0, 0, 0, 0, 0, 13776, 0, 21568, 0, -188, 566, 21568, 566, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -162, 0, 0, 1457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5491, 0, 401, 0, 670, 1491, 0, 1491, 0, 0, 1491, 0, 0, 0, 0, 0, 943, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5986, 0, 0, 0, 13477, 0, 0, 1493, 0, 0, 546, 0, 714, 0, 0, 556, 0, 0, 0, 0, 0, 0, 0, 0, 946, 0, 0, 0, 0, 0, 0, 0, 4343, 1483, 618, 0, 0, 407, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1494, 0, 0, 0, 0, 0, 0, 0, 0, 2786, 0, 0, 1451, 0, 0, 13309, 13561, 0, 0, 543, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 659, 0, 0, 0, 18565, 0, 0, 13393, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18639, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13645, 0, 13309, 0, 0, 0, 543, 0, 0, 0, 0, 0, 247, 228, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2924, 302, 0, 20536, 0, 1487, 0, 0, 5160, 0, 2786, 0, 0, 0, 0, 0, 0, 2786, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 715, 0, 554, 0, 664, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2786, 0, 0, 0, 684, 0, 742, 0, 0, 0, 0, 0, 0, 0, 21568, 1085, 0, 0, 0, 0, 0, 0, 0, 1490, 0, 486, 0, 0, 0, 0, 0, 0, 0, 1093, 0, 0, 0, 0, 0, 0, 0, 0, 1488, 0, 21568, 21568, 0, 0, 21642, 0, 0, 0, 0, 0, 0, 0, 1502, 1100, 0, 1503, 21568, 20427, 1504, 21568, 0, 0, 0, 0, 0, 0, 1505, 0, 0, 0, 4226, 0, 0, 0, 21568, 0, 0, 0, 1507, 0, 0, 435, 0, 6947, 21959, 0, 0, 0, 1508, 0, 0, 0, 0, 0, 0, 1509, 0, 0, 21568, 0, 0, 573, 0, 1097, 0, 0, 0, 0, 0, 1135, 0, 6316, 6717, 0, 0, 0, 0, 0, 0, 0, 0, 1517, 0, 1609, 0, 0, 0, 1101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 694, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4226, 0, 0, 5654, 6149, 0, 694, 0, 0, 0, 0, 0, 9404, 0, 0, 0, 0, 0, 0, 0, 1451, 1451, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; protected static readonly short[] yyGindex = new short[502] { 0, 0, 1841, 0, 0, 0, 2, -13, -190, -48, -44, 0, 1883, 1892, 380, 0, 0, -170, 0, 0, 0, 0, 0, 0, -1078, -830, -229, -511, 0, 0, 0, 0, 0, -235, 0, 0, 0, 743, 0, 880, 0, 0, 0, 0, 575, 579, -17, -245, 0, -37, 0, 0, 0, -713, 866, 388, 0, 419, -1035, -794, -752, -742, -718, -715, -686, -674, 0, 0, -987, 0, -912, 0, 364, 0, -1380, 0, 26, 0, 0, 576, -1296, 0, 0, 0, 631, 194, 0, 0, 0, 233, -1283, 0, -292, -312, 1105, 0, 0, 0, -745, 181, 0, 0, -561, 0, 0, 248, 0, 0, 220, 0, 0, -1461, 0, 391, 0, 0, -644, -978, 0, 0, 0, 0, 0, 366, -10, -1377, 0, 0, 418, 0, 332, 0, 0, 0, 879, 886, 887, 1096, -297, 0, 0, -353, 894, 362, 0, -1178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0, 420, 0, 0, 0, -231, 343, 0, 0, 0, 0, 0, 0, 0, 0, 0, -543, 0, 0, 0, 0, 0, 0, 0, 0, 0, 200, 0, 0, 267, 0, 273, 277, 189, 0, 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, -83, 0, 1237, -318, -351, 1645, 0, 344, 0, 412, 0, 957, 0, 1641, 766, -304, -268, -46, 167, 0, 1069, 895, 899, 0, 533, 0, 8, 1170, -414, 0, 0, -408, 0, 0, 0, 0, 0, 0, 0, 0, 0, -407, 0, 0, 0, 0, 0, 0, 0, -255, 0, 0, 0, 865, 0, 1376, 0, 0, -43, 0, -365, 0, -289, 0, 0, 0, 913, -977, -319, -123, 1123, 0, 1005, 0, 1307, 15, -354, 1172, 0, 0, 775, 1917, 0, 0, 0, 0, 1142, 0, 0, 0, 1632, 0, 0, 0, 0, 0, 2123, 1063, 1066, -568, -1011, 754, 0, 0, 753, 0, 810, 1067, 1544, 1545, 1554, 1555, 1543, 0, 1552, 1023, 0, 0, -67, 0, 0, 0, 0, 1070, 1398, -582, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -324, 682, 0, -532, 0, 0, 0, 0, 0, -506, 0, 595, 0, 488, 0, 0, 0, 718, -590, -15, -348, -14, 0, 1856, 0, 84, 0, 114, 134, 151, 165, 166, 170, 174, 176, 183, 199, 0, -778, 0, 0, 0, 0, 0, -826, 0, -1013, 0, 0, 0, 0, 0, 716, -609, 806, -1007, 0, 850, -524, 0, 0, 0, 0, 0, 0, 726, 0, 730, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 641, 0, 0, 0, 0, 0, 0, 0, 0, 1623, 0, 1447, 675, 0, 0, 0, 0, 953, 0, 0, 0, 0, 0, 0, -183, 0, 0, 0, 0, 0, 1561, 1269, 0, 0, 0, 0, 1562, 0, 0, 0, 0, 0, 0, 0, 0, 0, 518, 0, 0, 0, 0, 0, 0, 0, 0, 643, 0, 0, 0, 0, 0, 0, 46, 1034, 0, 0, 0, 1036 }; protected static readonly short[] yyTable = new short[22411] { 116, 576, 169, 170, 246, 203, 18, 118, 247, 325, 579, 548, 526, 490, 885, 530, 505, 822, 605, 489, 276, 845, 990, 574, 300, 301, 302, 640, 308, 309, 879, 728, 44, 307, 327, 328, 493, 729, 730, 620, 333, 336, 427, 338, 572, 342, 607, 934, 463, 265, 359, 360, 662, 346, 356, 560, 1078, 1389, 363, 322, 994, 698, 1080, 331, 678, 999, 1000, 1221, 272, 941, 775, 689, 332, 1224, 335, 273, 1058, 419, 1059, 428, 371, 426, 415, 272, 377, 617, 958, 1130, 1208, 1425, 316, 240, 1427, 1019, 242, 850, 979, 677, 408, 1298, 262, 174, 597, 1399, 467, 274, 957, 568, 805, 981, 1533, 1299, 608, 1070, 429, 14, 380, 334, 262, 853, 1114, 1238, 1277, 1249, 1087, 815, 1171, 1089, 1225, 1541, 409, 175, 1279, 468, 1627, 806, 305, 334, 682, 893, 204, 399, 1755, 818, 20, 1462, 1602, 819, 1537, 1604, 263, 176, 784, 1299, 116, 246, 169, 170, 588, 491, 591, 118, 1349, 1610, 400, 990, 1350, 807, 177, 990, 1351, 401, 1, 990, 608, 71, 71, 1435, 897, 71, 530, 402, 178, 179, 122, 784, 1538, 180, 683, 469, 775, 181, 775, 182, 775, 1756, 306, 504, 772, 264, 183, 491, 6, 305, 1114, 1704, 205, 1296, 820, 1114, 823, 1114, 957, 893, 1114, 1114, 184, 1114, 1114, 1250, 980, 263, 528, 531, 569, 336, 570, 122, 263, 426, 305, 275, 122, 991, 399, 100, 535, 1071, 263, 263, 982, 854, 122, 529, 1114, 1648, 207, 1655, 1459, 534, 871, 1396, 775, 1220, 100, 174, 526, 400, 263, 1197, 877, 505, 612, 306, 401, 914, 957, 502, 122, 573, 264, 1300, 662, 559, 1347, 2, 808, 264, 1238, 581, 571, 496, 122, 15, 589, 175, 547, 264, 264, 640, 306, 551, 553, 816, 43, 604, 1060, 361, 913, 613, 1280, 582, 1114, 377, 1368, 176, 1724, 264, 272, 419, 615, 587, 927, 1300, 1603, 544, 1354, 1605, 272, 600, 619, 602, 177, 272, 1174, 551, 1177, 601, 640, 962, 580, 1611, 630, 809, 1748, 965, 178, 179, 122, 1469, 1099, 180, 622, 623, 1130, 181, 1758, 182, 1759, 3, 4, 5, 6, 603, 183, 1379, 303, 967, 992, 1387, 639, 641, 1215, 960, 304, 945, 1742, 53, 964, 966, 184, 923, 668, 1287, 1460, 1774, 1397, 1235, 1656, 53, 681, 470, 410, 305, 686, 931, 539, 1480, 531, 531, 16, 501, 396, 1413, 608, 771, 674, 1720, 1577, 1789, 1789, 208, 855, 1446, 2, 1625, 1798, 1798, 529, 695, 889, 798, 891, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 470, 1292, 1327, 1245, 1618, 1247, 20, 608, 1252, 208, 1488, 774, 776, 1511, 530, 780, 1009, 49, 246, 306, 362, 768, 491, 901, 1578, 932, 799, 1769, 305, 272, 800, 444, 942, 1046, 1413, 6, 731, 904, 1195, 579, 1470, 471, 1685, 122, 1031, 1713, 472, 540, 473, 782, 797, 474, 475, 968, 476, 477, 797, 826, 122, 1792, 797, 1511, 830, 1597, 100, 43, 410, 1743, 445, 1032, 1600, 1008, 53, 841, 943, 797, 795, 1066, 410, 1626, 410, 122, 410, 842, 471, 851, 901, 1348, 306, 472, 1795, 473, 1218, 1051, 474, 475, 1033, 476, 477, 1631, 856, 795, 797, 1447, 840, 55, 244, 1201, 890, 1320, 892, 1322, 531, 1323, 1750, 1751, 790, 791, 122, 887, 1474, 797, 803, 1067, 894, 1619, 410, 1489, 795, 244, 874, 1130, 695, 471, 883, 1093, 844, 608, 472, 478, 473, 526, 903, 474, 475, 902, 476, 477, 831, 381, 796, 1395, 244, 446, 447, 381, 210, 530, 896, 905, 1196, 244, 1402, 597, 244, 1285, 381, 236, 1092, 662, 381, 1786, 244, 911, 526, 796, 541, 915, 1566, 412, 560, 244, 488, 381, 542, 1118, 607, 1068, 122, 1117, 928, 1429, 371, 1285, 1007, 924, 1549, 842, 639, 641, 944, 935, 796, 1034, 1035, 936, 936, 100, 797, 797, 797, 954, 1284, 1641, 797, 381, 1796, 924, 797, 1114, 427, 961, 531, 263, 396, 516, 950, 1312, 413, 952, 305, 783, 1404, 797, 272, 795, 795, 639, 641, 643, 543, 940, 529, 1673, 1674, 1765, 902, 1676, 1315, 1130, 969, 969, 608, 1766, 1512, 1130, 272, 428, 583, 1695, 797, 842, 1702, 955, 583, 211, 1185, 843, 1438, 305, 517, 988, 264, 1117, 797, 1108, 976, 1719, 1117, 797, 1117, 258, 972, 1117, 1117, 259, 1117, 1117, 122, 516, 679, 608, 530, 531, 414, 902, 1513, 347, 357, 644, 257, 1741, 1512, 680, 1365, 1180, 1514, 1357, 396, 796, 796, 1120, 396, 1117, 996, 1767, 998, 261, 396, 1056, 1475, 407, 583, 1187, 1072, 1006, 1580, 797, 871, 684, 1515, 843, 874, 1516, 517, 260, 977, 874, 874, 1526, 1002, 396, 685, 416, 1513, 396, 934, 396, 396, 396, 396, 357, 530, 531, 1514, 396, 1110, 359, 1057, 1108, 100, 902, 1517, 1217, 1108, 531, 1108, 797, 797, 1108, 1108, 1117, 1108, 1108, 1518, 1104, 1581, 339, 1515, 1384, 122, 1516, 1213, 1053, 1579, 529, 1016, 1189, 399, 608, 403, 902, 277, 122, 579, 902, 781, 902, 559, 1090, 551, 53, 728, 358, 902, 531, 396, 53, 729, 730, 1517, 400, 441, 442, 443, 122, 883, 494, 495, 122, 244, 1030, 1518, 874, 398, 695, 1420, 809, 1017, 781, 339, 1566, 352, 352, 122, 396, 403, 781, 456, 396, 1110, 381, 396, 272, 396, 1110, 845, 1110, 457, 396, 1110, 1110, 1288, 1110, 1110, 902, 352, 1108, 1566, 1104, 1773, 1085, 818, 1086, 1104, 470, 1104, 1065, 1566, 1104, 1104, 1094, 1104, 1104, 388, 1095, 821, 399, 877, 448, 449, 45, 816, 536, 1108, 1100, 1097, 100, 924, 1263, 458, 1124, 123, 309, 1113, 818, 1567, 100, 459, 818, 400, 1481, 1139, 388, 460, 821, 1479, 401, 1606, 546, 1111, 1116, 1112, 531, 821, 816, 461, 402, 398, 531, 565, 1620, 309, 272, 566, 611, 1131, 398, 789, 398, 1105, 309, 640, 695, 586, 123, 1491, 1510, 1110, 695, 123, 883, 1254, 611, 799, 1639, 1150, 386, 800, 471, 123, 768, 352, 352, 472, 642, 473, 1104, 1491, 474, 475, 809, 476, 477, 590, 355, 355, 236, 362, 239, 1328, 399, 627, 628, 362, 824, 123, 591, 462, 824, 399, 363, 399, 1356, 225, 1510, 786, 1491, 640, 355, 123, 236, 788, 241, 400, 592, 874, 122, 874, 122, 547, 401, 399, 400, 1180, 400, 381, 653, 824, 381, 401, 402, 401, 220, 820, 1223, 1202, 824, 352, 786, 402, 1204, 402, 988, 1204, 400, 416, 1392, 972, 1164, 787, 311, 401, 386, 874, 386, 883, 386, 1172, 381, 386, 987, 386, 820, 352, 122, 123, 386, 122, 492, 1012, 721, 820, 416, 1341, 416, 578, 454, 455, 822, 339, 1263, 1013, 787, 386, 1236, 1342, 416, 386, 352, 381, 133, 506, 133, 417, 1428, 611, 527, 133, 775, 777, 386, 122, 1707, 640, 355, 355, 339, 931, 339, 931, 500, 931, 1243, 655, 400, 507, 531, 319, 874, 319, 874, 401, 498, 874, 319, 656, 352, 352, 508, 381, 399, 386, 657, 510, 369, 381, 1262, 575, 511, 1274, 512, 513, 514, 515, 658, 1278, 381, 361, 516, 746, 381, 746, 517, 400, 655, 1037, 1585, 310, 549, 311, 401, 352, 1038, 381, 518, 1760, 656, 519, 1043, 520, 355, 1207, 526, 657, 505, 883, 550, 1075, 551, 640, 1241, 1528, 125, 1408, 583, 658, 1242, 199, 1271, 199, 1272, 199, 417, 521, 123, 381, 355, 450, 451, 122, 1131, 1306, 1782, 584, 645, 352, 646, 578, 355, 123, 1032, 452, 453, 578, 585, 920, 1032, 920, 924, 920, 649, 355, 650, 616, 874, 125, 874, 355, 874, 614, 125, 1324, 123, 352, 352, 1337, 911, 355, 911, 1381, 125, 618, 1124, 272, 579, 1804, 1805, 213, 825, 213, 731, 213, 826, 469, 1586, 745, 747, 749, 751, 355, 355, 1331, 584, 1617, 647, 469, 125, 469, 584, 123, 626, 1204, 861, 988, 872, 1074, 862, 547, 566, 1075, 125, 669, 1617, 670, 639, 641, 469, 469, 531, 1115, 648, 1366, 883, 826, 355, 924, 1209, 1563, 1454, 355, 980, 1650, 1455, 1651, 673, 1563, 469, 72, 1262, 731, 666, 72, 992, 1378, 469, 994, 992, 469, 547, 994, 667, 547, 350, 350, 687, 246, 584, 1411, 671, 491, 672, 1412, 906, 1234, 907, 980, 125, 786, 355, 123, 639, 641, 1329, 419, 1330, 419, 350, 874, 420, 430, 525, 244, 986, 1407, 804, 246, 53, 400, 53, 491, 263, 857, 421, 1180, 827, 122, 355, 355, 824, 547, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 53, 422, 423, 874, 1324, 381, 381, 852, 381, 381, 64, 829, 1411, 53, 858, 1151, 1412, 1151, 53, 633, 634, 424, 122, 53, 859, 53, 53, 53, 53, 264, 860, 53, 425, 53, 922, 899, 922, 53, 1490, 1509, 631, 632, 1412, 800, 900, 187, 531, 187, 194, 53, 194, 195, 53, 195, 53, 874, 639, 641, 350, 123, 1490, 908, 350, 350, 1412, 1059, 695, 1059, 74, 910, 74, 122, 912, 219, 874, 219, 547, 188, 53, 188, 138, 122, 138, 1146, 1147, 125, 122, 1509, 325, 1490, 325, 800, 145, 1412, 145, 916, 332, 917, 332, 918, 125, 919, 1545, 1371, 1372, 1443, 244, 352, 957, 1810, 939, 400, 498, 1770, 1771, 946, 485, 485, 486, 486, 797, 797, 947, 125, 736, 738, 937, 938, 350, 741, 743, 956, 639, 641, 951, 122, 753, 755, 974, 355, 1084, 1569, 122, 953, 959, 975, 122, 963, 578, 993, 995, 123, 997, 1001, 350, 1011, 406, 1010, 1021, 611, 125, 1024, 1020, 1096, 123, 43, 350, 1047, 1048, 1599, 1041, 1049, 1050, 1055, 207, 122, 355, 1054, 980, 350, 1076, 1073, 1081, 1077, 1098, 350, 123, 1104, 1107, 1103, 123, 1106, 1110, 1126, 1130, 350, 1100, 318, 1134, 1141, 1569, 1143, 1148, 1157, 1161, 123, 1158, 1162, 1152, 1165, 1160, 1168, 1170, 1181, 1193, 1194, 1203, 350, 350, 1197, 1212, 1219, 569, 1229, 1230, 1686, 1237, 1240, 1232, 800, 727, 1267, 1255, 1275, 1311, 1283, 1291, 1293, 122, 1281, 355, 1282, 1714, 1294, 1297, 1321, 800, 1307, 1309, 1313, 1314, 1334, 350, 1319, 1344, 1726, 1728, 350, 1337, 800, 800, 1340, 1345, 1343, 1346, 1358, 883, 1355, 1362, 1370, 1398, 1569, 1373, 1421, 1374, 352, 1381, 1390, 547, 1403, 1410, 355, 1435, 1714, 1714, 1426, 1434, 800, 800, 1437, 1440, 1188, 1442, 1445, 1448, 1736, 350, 1449, 352, 1458, 1463, 1465, 1471, 1472, 1473, 1478, 355, 1479, 1523, 1524, 1529, 1582, 1696, 1534, 122, 1530, 1542, 1531, 1527, 1547, 1573, 1594, 1596, 352, 350, 350, 1615, 1630, 1623, 883, 125, 1635, 355, 1633, 1614, 1624, 1626, 1566, 1636, 1638, 1714, 1647, 1640, 1605, 800, 1644, 1646, 1653, 1642, 1654, 351, 351, 1662, 1665, 1669, 350, 1666, 1667, 1659, 1677, 1678, 1711, 1681, 161, 1691, 1698, 883, 1708, 123, 1709, 123, 531, 531, 1712, 351, 1718, 1722, 1746, 1733, 1735, 1762, 1788, 1788, 1740, 1738, 1753, 1757, 161, 1797, 1797, 1756, 695, 695, 1764, 1772, 1761, 1721, 704, 1755, 1732, 161, 1780, 1781, 1803, 1809, 161, 1801, 9, 355, 1266, 161, 1269, 161, 161, 161, 161, 123, 1807, 1808, 123, 161, 355, 125, 1812, 161, 1147, 352, 1737, 161, 1024, 616, 355, 576, 21, 1025, 125, 161, 748, 1139, 161, 479, 161, 577, 985, 530, 1040, 832, 749, 797, 35, 575, 36, 989, 123, 35, 531, 355, 125, 354, 250, 355, 125, 36, 914, 924, 161, 351, 1032, 915, 925, 351, 351, 693, 916, 952, 917, 125, 350, 953, 820, 820, 704, 358, 842, 381, 141, 704, 797, 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, 123, 328, 148, 142, 578, 124, 329, 149, 243, 704, 704, 54, 1332, 21, 1256, 350, 704, 1156, 704, 1175, 704, 1376, 704, 704, 704, 1377, 1544, 161, 1535, 1574, 1388, 1754, 1723, 704, 1763, 1710, 1739, 351, 704, 1027, 1560, 1589, 1540, 1190, 1044, 352, 1629, 352, 704, 704, 1191, 1192, 123, 1186, 1607, 1628, 1543, 693, 1800, 355, 355, 704, 693, 351, 693, 693, 693, 693, 693, 693, 693, 693, 693, 693, 693, 351, 1734, 1778, 1729, 350, 704, 1727, 1791, 1466, 693, 693, 1652, 1593, 351, 1153, 598, 693, 1091, 693, 351, 693, 1467, 693, 693, 693, 1211, 1121, 1228, 1064, 351, 1295, 313, 693, 693, 624, 1316, 1318, 693, 693, 1040, 973, 757, 1061, 759, 765, 350, 693, 693, 693, 693, 930, 351, 351, 761, 766, 763, 1138, 1109, 1382, 1451, 1548, 693, 355, 1360, 921, 125, 350, 125, 464, 1359, 350, 1367, 352, 1308, 1276, 1361, 1432, 675, 595, 1400, 693, 898, 1226, 784, 785, 1546, 351, 24, 1151, 25, 1439, 351, 26, 1154, 1005, 40, 350, 27, 0, 0, 0, 0, 28, 355, 0, 355, 0, 0, 0, 0, 0, 30, 0, 125, 0, 0, 125, 0, 32, 0, 0, 0, 0, 33, 0, 0, 0, 34, 0, 0, 351, 0, 0, 0, 0, 0, 0, 652, 0, 36, 0, 37, 1485, 123, 0, 38, 24, 0, 25, 0, 125, 26, 0, 39, 40, 0, 27, 41, 351, 351, 596, 28, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 350, 0, 0, 0, 0, 32, 0, 0, 123, 0, 33, 0, 0, 350, 34, 0, 352, 351, 0, 0, 0, 0, 0, 350, 0, 0, 36, 343, 37, 0, 0, 1485, 38, 355, 0, 0, 0, 0, 0, 0, 39, 40, 0, 0, 41, 0, 0, 87, 350, 0, 1575, 1576, 350, 0, 0, 0, 0, 123, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 0, 123, 0, 406, 0, 125, 0, 1609, 0, 0, 1612, 352, 0, 0, 0, 343, 0, 370, 0, 0, 374, 0, 0, 0, 383, 385, 387, 389, 391, 393, 395, 397, 0, 0, 352, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 506, 123, 0, 0, 0, 0, 0, 350, 123, 0, 0, 0, 123, 406, 0, 0, 0, 0, 0, 351, 0, 0, 0, 0, 507, 0, 0, 0, 0, 355, 350, 350, 0, 0, 0, 0, 0, 508, 0, 0, 0, 123, 510, 0, 0, 0, 352, 511, 0, 512, 513, 514, 515, 0, 0, 0, 351, 516, 0, 0, 40, 517, 0, 0, 40, 352, 352, 0, 578, 0, 0, 0, 0, 518, 0, 40, 519, 0, 520, 0, 0, 40, 0, 0, 0, 40, 0, 0, 40, 0, 0, 0, 26, 352, 0, 355, 352, 0, 0, 0, 40, 40, 521, 0, 123, 40, 40, 0, 350, 0, 0, 40, 0, 40, 40, 40, 40, 0, 355, 0, 351, 40, 125, 0, 0, 40, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 40, 40, 350, 40, 0, 0, 0, 40, 0, 0, 350, 0, 350, 0, 0, 0, 0, 0, 0, 0, 727, 0, 351, 0, 1605, 0, 0, 40, 0, 0, 713, 0, 0, 0, 0, 0, 0, 0, 40, 40, 355, 123, 355, 351, 0, 0, 0, 351, 0, 0, 355, 0, 370, 0, 0, 0, 0, 0, 0, 355, 355, 0, 355, 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, 351, 0, 0, 0, 0, 0, 125, 0, 0, 0, 0, 125, 0, 0, 355, 0, 0, 355, 621, 0, 0, 0, 40, 40, 0, 0, 0, 0, 370, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 350, 0, 713, 0, 0, 0, 0, 713, 0, 713, 713, 713, 713, 713, 713, 713, 713, 713, 713, 713, 0, 125, 0, 0, 0, 0, 0, 0, 125, 713, 713, 0, 125, 0, 0, 0, 713, 351, 713, 0, 713, 0, 713, 713, 713, 0, 0, 0, 0, 0, 351, 0, 0, 0, 0, 0, 0, 0, 713, 0, 351, 125, 715, 717, 719, 0, 0, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 621, 0, 0, 351, 0, 0, 0, 351, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 713, 588, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 350, 0, 0, 26, 0, 0, 0, 26, 125, 0, 26, 0, 717, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 26, 0, 0, 0, 26, 26, 0, 0, 0, 0, 26, 0, 26, 26, 26, 26, 0, 0, 0, 0, 26, 0, 0, 0, 26, 351, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 26, 0, 26, 0, 350, 0, 26, 0, 0, 351, 351, 0, 621, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, 26, 350, 0, 0, 0, 0, 0, 0, 717, 0, 23, 26, 26, 717, 0, 717, 717, 717, 717, 717, 717, 717, 717, 717, 717, 717, 0, 0, 0, 0, 0, 0, 0, 0, 0, 717, 717, 0, 0, 0, 0, 0, 717, 0, 717, 0, 717, 0, 717, 717, 717, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 351, 350, 0, 350, 0, 0, 0, 26, 26, 0, 0, 350, 0, 0, 0, 0, 0, 0, 0, 33, 350, 350, 949, 350, 0, 0, 0, 0, 0, 1592, 0, 0, 0, 351, 0, 0, 0, 24, 0, 25, 0, 351, 26, 351, 0, 717, 1592, 27, 350, 0, 0, 350, 28, 0, 0, 0, 29, 0, 0, 1592, 0, 30, 0, 0, 0, 381, 31, 0, 32, 0, 0, 381, 381, 33, 0, 0, 0, 34, 35, 984, 985, 901, 381, 1592, 381, 901, 381, 901, 0, 36, 0, 37, 588, 0, 901, 38, 370, 588, 588, 381, 0, 0, 0, 39, 40, 381, 381, 41, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 588, 0, 0, 0, 381, 0, 0, 0, 0, 0, 381, 0, 381, 588, 588, 381, 0, 0, 588, 0, 0, 588, 351, 588, 901, 588, 588, 588, 588, 0, 0, 0, 0, 588, 0, 0, 0, 588, 0, 0, 0, 588, 0, 0, 0, 0, 0, 0, 0, 588, 0, 0, 588, 0, 588, 588, 0, 0, 0, 588, 588, 0, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 0, 0, 43, 0, 0, 588, 588, 588, 0, 588, 588, 0, 0, 0, 0, 588, 588, 0, 588, 588, 588, 588, 588, 588, 588, 370, 588, 588, 0, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 1026, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 588, 0, 0, 588, 351, 588, 0, 588, 0, 0, 588, 0, 0, 0, 0, 0, 0, 0, 0, 588, 33, 33, 0, 0, 934, 33, 0, 0, 0, 33, 0, 33, 0, 0, 33, 0, 33, 33, 0, 33, 0, 0, 33, 0, 33, 0, 33, 33, 33, 33, 0, 0, 33, 33, 0, 0, 0, 0, 33, 0, 33, 33, 33, 0, 0, 33, 33, 33, 0, 33, 351, 0, 33, 0, 33, 33, 33, 33, 33, 0, 0, 33, 33, 33, 0, 0, 33, 33, 33, 0, 0, 0, 0, 351, 0, 33, 33, 0, 33, 33, 0, 33, 33, 33, 0, 0, 0, 33, 934, 0, 0, 0, 0, 934, 0, 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, 0, 33, 0, 0, 0, 0, 0, 0, 0, 934, 934, 33, 33, 33, 0, 33, 934, 0, 934, 0, 934, 33, 934, 934, 934, 0, 0, 946, 351, 0, 351, 0, 0, 0, 0, 0, 0, 403, 351, 0, 0, 0, 0, 0, 0, 0, 621, 351, 351, 0, 351, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 403, 33, 0, 0, 0, 0, 0, 0, 33, 33, 0, 0, 0, 403, 351, 0, 0, 351, 403, 934, 0, 272, 0, 403, 0, 403, 403, 403, 403, 0, 0, 0, 0, 403, 0, 0, 0, 403, 0, 0, 0, 403, 0, 0, 1239, 0, 0, 1026, 1026, 403, 1244, 0, 403, 0, 403, 1026, 1026, 1026, 1026, 1026, 0, 1026, 1026, 0, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 0, 0, 381, 0, 1026, 403, 1026, 1026, 1026, 1026, 1026, 1026, 0, 0, 1026, 0, 403, 0, 1026, 1026, 0, 1026, 1026, 1026, 0, 0, 0, 0, 0, 0, 0, 0, 1026, 1026, 0, 1026, 0, 1026, 1026, 0, 0, 1026, 0, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 1026, 0, 1026, 0, 0, 1026, 1026, 0, 0, 1026, 1026, 0, 403, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1026, 1026, 1026, 1026, 1026, 0, 0, 1026, 1026, 1026, 0, 0, 0, 1026, 1026, 0, 0, 1026, 0, 0, 0, 0, 1026, 1026, 1026, 1026, 1026, 0, 0, 0, 1026, 0, 1026, 0, 0, 0, 0, 0, 1026, 1026, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1026, 1026, 1026, 1026, 0, 1026, 0, 1026, 946, 946, 0, 0, 0, 381, 0, 1026, 946, 946, 946, 946, 946, 0, 946, 946, 0, 946, 946, 946, 946, 946, 946, 946, 946, 0, 0, 0, 0, 0, 946, 0, 946, 946, 946, 946, 946, 946, 0, 0, 946, 0, 0, 0, 946, 946, 0, 946, 946, 946, 0, 0, 0, 0, 0, 0, 0, 0, 946, 946, 0, 946, 0, 946, 946, 0, 0, 946, 0, 946, 946, 946, 946, 946, 946, 946, 946, 946, 946, 946, 946, 0, 946, 0, 0, 946, 946, 0, 0, 946, 946, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 946, 946, 946, 946, 946, 381, 0, 946, 946, 946, 381, 381, 0, 946, 946, 0, 0, 946, 0, 0, 0, 0, 946, 946, 946, 946, 946, 0, 0, 0, 946, 0, 946, 0, 381, 0, 0, 0, 946, 946, 0, 0, 0, 0, 0, 0, 0, 381, 381, 0, 0, 0, 381, 898, 0, 381, 0, 381, 0, 381, 381, 381, 381, 946, 946, 946, 946, 381, 946, 0, 946, 381, 0, 0, 0, 381, 0, 0, 946, 0, 0, 0, 0, 381, 0, 0, 381, 0, 381, 381, 0, 0, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 0, 381, 381, 0, 0, 381, 381, 0, 0, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 0, 0, 381, 381, 381, 381, 381, 0, 0, 381, 381, 0, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 0, 381, 381, 0, 0, 0, 0, 381, 0, 0, 381, 0, 381, 0, 381, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 381, 381, 0, 371, 0, 0, 0, 0, 0, 0, 0, 0, 0, 381, 381, 0, 0, 0, 381, 0, 0, 0, 0, 381, 0, 381, 381, 381, 381, 0, 0, 0, 0, 381, 0, 0, 0, 381, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 381, 0, 381, 381, 0, 0, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 0, 381, 381, 0, 0, 381, 381, 0, 0, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 0, 0, 381, 381, 381, 381, 381, 0, 0, 381, 381, 0, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 898, 0, 0, 0, 0, 898, 898, 0, 0, 0, 0, 381, 0, 0, 381, 0, 381, 0, 381, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 898, 381, 0, 422, 0, 0, 0, 0, 0, 0, 0, 0, 0, 898, 898, 0, 0, 0, 898, 0, 0, 898, 0, 898, 0, 898, 898, 898, 898, 0, 0, 0, 0, 898, 0, 0, 0, 898, 0, 0, 0, 898, 0, 0, 0, 0, 0, 0, 0, 898, 0, 0, 898, 0, 898, 898, 0, 0, 0, 898, 898, 0, 898, 898, 898, 898, 898, 898, 898, 898, 898, 898, 898, 0, 0, 0, 0, 0, 898, 898, 0, 0, 898, 898, 0, 0, 0, 0, 898, 898, 898, 898, 898, 898, 0, 898, 898, 898, 0, 898, 898, 0, 0, 898, 898, 898, 898, 371, 0, 0, 898, 898, 371, 371, 0, 898, 898, 898, 898, 898, 898, 898, 898, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 898, 0, 371, 898, 0, 898, 0, 898, 0, 0, 898, 0, 0, 0, 0, 371, 371, 0, 0, 898, 371, 411, 0, 371, 0, 371, 0, 371, 371, 371, 371, 0, 0, 0, 0, 371, 0, 0, 0, 371, 0, 0, 0, 371, 0, 0, 0, 0, 0, 0, 0, 371, 0, 0, 371, 0, 371, 371, 0, 0, 0, 371, 371, 0, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 0, 0, 0, 0, 0, 371, 371, 0, 0, 371, 371, 0, 0, 0, 0, 371, 371, 371, 371, 371, 371, 0, 371, 371, 371, 0, 371, 371, 0, 0, 371, 371, 371, 371, 0, 0, 0, 371, 371, 0, 0, 0, 371, 371, 371, 371, 371, 371, 371, 371, 422, 0, 0, 0, 0, 422, 422, 0, 0, 0, 0, 371, 0, 0, 371, 0, 371, 0, 371, 0, 0, 371, 0, 0, 0, 0, 0, 0, 0, 422, 371, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 422, 422, 0, 0, 0, 422, 0, 0, 39, 0, 422, 0, 422, 422, 422, 422, 0, 0, 0, 0, 422, 0, 0, 0, 422, 0, 0, 0, 422, 0, 0, 0, 0, 0, 0, 0, 422, 0, 0, 422, 0, 422, 422, 0, 0, 0, 422, 422, 0, 422, 422, 422, 422, 422, 422, 422, 422, 422, 422, 422, 0, 0, 0, 0, 0, 422, 422, 0, 0, 422, 422, 0, 0, 0, 0, 422, 422, 422, 422, 422, 422, 0, 422, 422, 422, 0, 422, 422, 0, 0, 422, 422, 422, 422, 0, 38, 0, 422, 422, 0, 0, 0, 422, 422, 422, 422, 422, 422, 422, 422, 411, 0, 0, 0, 0, 411, 411, 0, 0, 0, 0, 422, 0, 0, 422, 0, 422, 0, 422, 0, 0, 422, 0, 0, 0, 0, 0, 0, 0, 411, 422, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 411, 411, 0, 0, 0, 411, 0, 0, 411, 0, 411, 0, 411, 411, 411, 411, 0, 27, 0, 0, 411, 0, 0, 0, 411, 0, 0, 0, 411, 0, 0, 0, 0, 0, 0, 0, 411, 0, 0, 411, 0, 411, 411, 0, 0, 0, 411, 411, 0, 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, 411, 0, 0, 0, 0, 0, 411, 411, 0, 0, 411, 411, 0, 0, 0, 0, 411, 411, 0, 411, 411, 411, 0, 411, 411, 411, 0, 411, 411, 0, 0, 411, 411, 411, 411, 0, 0, 0, 411, 411, 0, 37, 0, 411, 411, 411, 411, 411, 411, 411, 411, 0, 0, 0, 39, 0, 0, 0, 39, 0, 0, 0, 411, 0, 0, 411, 0, 411, 0, 39, 0, 0, 0, 0, 0, 39, 0, 0, 0, 39, 0, 411, 39, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 39, 0, 0, 0, 39, 39, 0, 53, 0, 0, 39, 0, 39, 39, 39, 39, 0, 0, 0, 0, 39, 0, 0, 0, 39, 0, 39, 0, 0, 0, 0, 53, 0, 0, 0, 0, 39, 0, 39, 39, 0, 39, 0, 0, 53, 39, 38, 0, 0, 53, 38, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 38, 0, 1128, 53, 39, 0, 38, 53, 0, 0, 38, 0, 0, 38, 0, 0, 39, 0, 0, 53, 0, 0, 53, 0, 53, 38, 38, 0, 0, 0, 38, 38, 0, 0, 0, 0, 38, 0, 38, 38, 38, 38, 0, 0, 0, 0, 38, 0, 53, 0, 38, 0, 38, 0, 0, 53, 53, 0, 0, 27, 0, 0, 38, 27, 0, 38, 53, 38, 0, 0, 0, 38, 39, 39, 27, 0, 0, 0, 0, 0, 27, 0, 0, 0, 27, 0, 0, 27, 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 27, 27, 0, 38, 38, 27, 27, 0, 0, 0, 0, 27, 0, 27, 27, 27, 27, 0, 0, 0, 0, 27, 0, 0, 0, 27, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 7, 27, 0, 27, 37, 0, 0, 27, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 38, 38, 0, 0, 37, 0, 27, 0, 37, 0, 0, 37, 0, 0, 0, 0, 0, 27, 27, 0, 0, 0, 1129, 37, 37, 0, 5, 0, 37, 37, 53, 0, 0, 0, 37, 0, 37, 37, 37, 37, 0, 53, 0, 0, 37, 0, 0, 53, 37, 0, 37, 53, 0, 0, 53, 0, 0, 0, 0, 0, 37, 0, 0, 37, 0, 37, 53, 53, 0, 37, 0, 53, 53, 0, 27, 27, 0, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 0, 37, 0, 53, 0, 53, 54, 0, 0, 0, 0, 0, 1128, 37, 0, 53, 53, 0, 53, 0, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 53, 53, 0, 0, 0, 53, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 37, 37, 0, 0, 53, 0, 0, 53, 53, 0, 53, 53, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 53, 53, 0, 53, 0, 0, 53, 53, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 53, 53, 0, 0, 53, 53, 53, 0, 0, 53, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 53, 0, 0, 0, 0, 7, 0, 0, 0, 54, 53, 0, 0, 53, 0, 53, 0, 0, 0, 53, 54, 0, 0, 0, 0, 0, 54, 0, 0, 0, 54, 0, 0, 54, 0, 0, 0, 0, 0, 53, 0, 0, 0, 53, 53, 54, 54, 0, 1129, 0, 54, 54, 53, 0, 0, 0, 54, 0, 54, 54, 54, 54, 0, 53, 0, 0, 54, 0, 0, 53, 54, 0, 54, 53, 0, 0, 53, 0, 0, 0, 0, 0, 54, 0, 0, 54, 0, 54, 53, 53, 0, 54, 0, 53, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 53, 53, 53, 0, 54, 0, 53, 0, 53, 0, 0, 0, 0, 54, 0, 0, 0, 54, 53, 0, 0, 53, 0, 53, 0, 0, 0, 53, 54, 0, 0, 0, 0, 0, 54, 0, 0, 0, 54, 0, 0, 54, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 54, 54, 0, 0, 0, 54, 54, 0, 0, 0, 0, 54, 0, 54, 54, 54, 54, 0, 0, 54, 54, 54, 0, 0, 0, 54, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, 54, 0, 54, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 53, 0, 0, 54, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 57, 24, 58, 25, 0, 0, 26, 59, 0, 60, 61, 27, 62, 63, 64, 65, 28, 0, 0, 0, 0, 0, 66, 0, 67, 30, 68, 69, 70, 71, 0, 0, 32, 0, 0, 0, 72, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 0, 36, 0, 37, 77, 54, 54, 38, 0, 78, 79, 80, 81, 82, 83, 39, 40, 84, 85, 41, 86, 0, 87, 0, 0, 88, 89, 0, 0, 90, 91, 0, 901, 0, 0, 0, 0, 0, 901, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 100, 0, 0, 0, 101, 0, 0, 0, 0, 102, 103, 104, 105, 106, 0, 0, 0, 107, 901, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 113, 114, 0, 0, 0, 115, 0, 901, 0, 0, 0, 0, 901, 207, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 0, 0, 0, 0, 901, 901, 0, 901, 901, 0, 0, 0, 0, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 901, 901, 0, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 901, 0, 901, 402, 901, 901, 901, 901, 0, 0, 0, 0, 0, 0, 0, 0, 901, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 402, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 402, 0, 0, 901, 0, 402, 0, 0, 271, 0, 402, 0, 402, 402, 402, 402, 0, 0, 0, 0, 402, 0, 0, 0, 402, 0, 0, 0, 402, 0, 0, 0, 0, 381, 0, 0, 402, 0, 0, 402, 0, 402, 0, 0, 901, 0, 0, 0, 0, 901, 0, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 0, 402, 0, 0, 901, 901, 381, 901, 901, 0, 0, 0, 402, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 901, 901, 0, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 0, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 901, 381, 402, 0, 901, 0, 901, 381, 0, 901, 0, 0, 381, 0, 0, 0, 0, 0, 901, 0, 0, 0, 0, 0, 381, 381, 381, 381, 901, 0, 0, 381, 381, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 0, 0, 0, 381, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 0, 0, 381, 381, 0, 381, 381, 0, 0, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 0, 0, 381, 53, 381, 381, 0, 381, 0, 0, 0, 0, 0, 0, 53, 0, 381, 0, 0, 0, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 53, 0, 381, 0, 53, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 381, 0, 53, 0, 0, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 53, 0, 381, 381, 0, 381, 381, 0, 0, 0, 0, 41, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 590, 0, 33, 381, 0, 381, 590, 0, 381, 53, 53, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 590, 33, 0, 0, 0, 0, 33, 0, 33, 33, 33, 33, 0, 0, 33, 0, 33, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 33, 0, 33, 0, 0, 0, 590, 0, 0, 0, 0, 590, 0, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 1120, 0, 33, 0, 0, 0, 0, 590, 0, 590, 590, 0, 0, 33, 33, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 0, 590, 590, 0, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 0, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 590, 0, 586, 0, 0, 0, 0, 590, 586, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 590, 0, 0, 0, 1120, 0, 0, 0, 0, 1120, 0, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 1120, 0, 0, 0, 0, 0, 586, 0, 0, 0, 0, 1120, 1120, 0, 0, 0, 0, 0, 1120, 0, 1120, 0, 1120, 0, 1120, 1120, 1120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 586, 0, 0, 0, 0, 586, 0, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 0, 0, 0, 0, 0, 0, 0, 586, 0, 586, 586, 0, 0, 0, 0, 586, 586, 1120, 586, 586, 586, 586, 586, 586, 586, 0, 586, 586, 0, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 0, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 586, 0, 594, 0, 0, 0, 53, 586, 594, 0, 586, 0, 0, 0, 0, 0, 0, 53, 0, 586, 0, 0, 0, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 53, 0, 594, 0, 53, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 594, 0, 53, 0, 0, 594, 0, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 0, 0, 0, 0, 53, 0, 0, 594, 0, 594, 594, 0, 0, 0, 0, 42, 594, 0, 594, 594, 594, 594, 594, 594, 594, 0, 594, 594, 0, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 0, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 594, 0, 381, 0, 33, 0, 33, 594, 381, 0, 594, 53, 53, 0, 0, 0, 0, 0, 0, 594, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 381, 33, 0, 0, 0, 0, 33, 0, 33, 33, 33, 33, 0, 0, 0, 0, 33, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 33, 0, 33, 0, 0, 0, 381, 0, 0, 0, 0, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 33, 0, 0, 0, 0, 381, 0, 381, 381, 0, 0, 33, 33, 0, 381, 0, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 512, 0, 0, 0, 53, 381, 512, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 512, 0, 0, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 512, 0, 0, 0, 0, 512, 0, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0, 710, 0, 53, 0, 0, 512, 0, 512, 512, 53, 53, 0, 0, 237, 512, 0, 512, 512, 512, 512, 512, 512, 512, 0, 512, 512, 0, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 622, 0, 0, 0, 0, 512, 622, 0, 512, 0, 0, 0, 0, 0, 0, 0, 0, 512, 0, 0, 0, 0, 0, 710, 0, 0, 0, 0, 710, 0, 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, 710, 0, 0, 622, 0, 0, 0, 0, 0, 0, 710, 710, 0, 0, 0, 0, 0, 710, 0, 710, 0, 710, 0, 710, 710, 710, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 381, 0, 710, 0, 901, 0, 0, 622, 0, 0, 0, 0, 622, 710, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 710, 0, 0, 0, 0, 0, 0, 0, 0, 622, 622, 0, 381, 0, 0, 0, 622, 0, 622, 710, 622, 0, 622, 622, 622, 0, 622, 622, 901, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 0, 0, 0, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 622, 0, 622, 0, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 381, 381, 0, 622, 0, 0, 0, 0, 0, 0, 381, 381, 381, 381, 381, 381, 381, 901, 381, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 371, 0, 0, 381, 53, 381, 371, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 371, 0, 0, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 445, 0, 0, 0, 0, 0, 445, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 371, 0, 0, 0, 0, 371, 0, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 0, 0, 0, 0, 53, 0, 371, 445, 445, 371, 371, 53, 53, 0, 0, 239, 371, 371, 371, 445, 371, 445, 371, 371, 371, 0, 371, 371, 0, 0, 371, 371, 371, 371, 0, 0, 0, 371, 371, 0, 445, 445, 371, 371, 371, 371, 371, 371, 371, 371, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 445, 371, 0, 0, 0, 0, 371, 0, 445, 0, 0, 445, 0, 371, 445, 0, 0, 0, 0, 0, 371, 0, 0, 445, 371, 445, 445, 445, 445, 445, 445, 445, 0, 445, 445, 0, 445, 445, 445, 445, 445, 0, 445, 445, 445, 445, 0, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 445, 0, 665, 0, 53, 371, 0, 445, 665, 0, 445, 0, 0, 0, 0, 0, 0, 0, 0, 445, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 665, 53, 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, 0, 0, 53, 0, 53, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 0, 0, 665, 0, 0, 0, 0, 665, 0, 665, 665, 665, 665, 665, 665, 665, 665, 665, 665, 665, 0, 0, 53, 0, 0, 0, 0, 446, 669, 665, 665, 0, 0, 338, 669, 0, 665, 0, 665, 446, 665, 446, 665, 665, 665, 0, 665, 665, 0, 0, 665, 665, 665, 665, 0, 0, 0, 665, 665, 0, 446, 446, 665, 665, 665, 665, 665, 665, 665, 665, 0, 669, 0, 0, 0, 0, 0, 0, 0, 0, 446, 665, 0, 0, 0, 0, 0, 0, 446, 0, 0, 446, 0, 0, 0, 0, 0, 0, 0, 0, 665, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 669, 0, 0, 0, 0, 669, 0, 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, 669, 0, 0, 0, 0, 0, 0, 0, 449, 668, 669, 669, 0, 0, 0, 668, 0, 669, 0, 669, 449, 669, 449, 669, 669, 669, 0, 669, 669, 0, 0, 669, 669, 669, 669, 0, 0, 0, 669, 669, 0, 449, 449, 669, 669, 669, 669, 669, 669, 669, 669, 0, 668, 0, 0, 0, 0, 0, 0, 0, 0, 449, 669, 0, 0, 0, 0, 0, 0, 449, 0, 0, 449, 0, 0, 0, 0, 0, 0, 0, 0, 669, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 668, 0, 0, 0, 0, 668, 0, 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, 668, 0, 0, 0, 0, 0, 0, 0, 459, 371, 668, 668, 0, 0, 0, 371, 0, 668, 0, 668, 459, 668, 459, 668, 668, 668, 0, 668, 668, 0, 0, 668, 668, 668, 668, 0, 0, 0, 668, 668, 0, 459, 459, 668, 668, 668, 668, 668, 668, 668, 668, 0, 371, 0, 0, 0, 0, 0, 0, 0, 0, 459, 668, 0, 0, 0, 0, 0, 0, 459, 0, 0, 459, 0, 0, 0, 0, 0, 0, 0, 0, 668, 0, 0, 0, 0, 0, 0, 0, 645, 0, 0, 0, 371, 0, 645, 0, 0, 371, 0, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 0, 0, 0, 0, 0, 0, 371, 0, 0, 371, 371, 0, 0, 0, 0, 0, 371, 371, 371, 0, 371, 645, 371, 371, 371, 0, 371, 371, 0, 0, 371, 371, 371, 371, 0, 0, 0, 371, 371, 0, 0, 0, 371, 371, 371, 371, 371, 371, 371, 371, 0, 888, 0, 0, 0, 0, 0, 888, 0, 0, 0, 371, 645, 0, 0, 0, 371, 645, 0, 645, 645, 645, 645, 645, 645, 645, 645, 645, 645, 645, 371, 0, 0, 0, 0, 0, 0, 0, 0, 645, 645, 0, 0, 0, 888, 0, 645, 0, 645, 0, 645, 0, 645, 645, 645, 0, 645, 645, 0, 0, 645, 645, 645, 645, 645, 645, 645, 645, 645, 0, 0, 0, 645, 645, 645, 645, 645, 645, 645, 645, 0, 652, 0, 0, 0, 888, 0, 652, 0, 0, 888, 645, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 888, 0, 0, 0, 0, 0, 0, 888, 645, 0, 888, 888, 0, 0, 0, 0, 0, 888, 0, 888, 0, 888, 652, 888, 888, 888, 0, 888, 888, 0, 0, 888, 888, 888, 888, 0, 0, 0, 888, 888, 0, 0, 0, 888, 888, 888, 888, 888, 888, 888, 888, 0, 1032, 0, 0, 0, 0, 0, 1032, 0, 0, 0, 888, 652, 0, 0, 0, 888, 652, 0, 652, 652, 652, 652, 652, 652, 652, 652, 652, 652, 652, 888, 0, 0, 0, 0, 0, 0, 0, 0, 652, 652, 0, 0, 0, 1032, 0, 652, 0, 652, 0, 652, 0, 652, 652, 652, 0, 652, 652, 0, 0, 652, 652, 652, 652, 0, 0, 0, 652, 652, 0, 0, 0, 652, 652, 652, 652, 652, 652, 652, 652, 0, 653, 0, 0, 0, 1032, 0, 653, 0, 0, 1032, 652, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 0, 0, 0, 0, 0, 0, 0, 652, 0, 1032, 1032, 0, 0, 0, 0, 0, 1032, 0, 1032, 0, 1032, 653, 1032, 1032, 1032, 0, 1032, 1032, 0, 0, 1032, 1032, 1032, 1032, 0, 0, 0, 1032, 1032, 0, 0, 0, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 0, 654, 0, 0, 0, 0, 0, 654, 0, 0, 0, 1032, 653, 0, 0, 0, 0, 653, 0, 653, 653, 653, 653, 653, 653, 653, 653, 653, 653, 653, 1032, 0, 0, 0, 0, 0, 0, 0, 0, 653, 653, 0, 0, 0, 654, 0, 653, 0, 653, 0, 653, 0, 653, 653, 653, 0, 653, 653, 0, 0, 653, 653, 653, 653, 0, 0, 0, 653, 653, 0, 0, 0, 653, 653, 653, 653, 653, 653, 653, 653, 0, 0, 0, 0, 0, 654, 0, 0, 0, 0, 654, 653, 654, 654, 654, 654, 654, 654, 654, 654, 654, 654, 654, 0, 0, 0, 0, 0, 0, 0, 653, 0, 654, 654, 0, 0, 0, 0, 0, 654, 0, 654, 0, 654, 0, 654, 654, 654, 0, 654, 654, 0, 0, 654, 654, 654, 654, 0, 0, 0, 654, 654, 0, 0, 0, 654, 654, 654, 654, 654, 654, 654, 654, 0, 554, 0, 679, 0, 0, 0, 0, 0, 57, 24, 654, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 654, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 679, 0, 0, 0, 0, 679, 0, 679, 679, 679, 679, 679, 679, 679, 679, 679, 679, 679, 92, 93, 94, 269, 555, 680, 0, 97, 98, 679, 679, 0, 0, 0, 0, 0, 679, 320, 679, 0, 679, 0, 679, 679, 679, 0, 0, 0, 0, 0, 679, 679, 679, 679, 0, 0, 0, 679, 679, 0, 0, 0, 679, 679, 679, 679, 679, 679, 679, 679, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 679, 0, 111, 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 557, 558, 0, 679, 681, 0, 0, 0, 0, 0, 0, 0, 680, 0, 0, 0, 0, 680, 0, 680, 680, 680, 680, 680, 680, 680, 680, 680, 680, 680, 0, 0, 0, 0, 0, 0, 0, 0, 0, 680, 680, 0, 0, 0, 0, 0, 680, 0, 680, 0, 680, 0, 680, 680, 680, 0, 0, 0, 0, 0, 680, 680, 680, 680, 0, 0, 0, 680, 680, 0, 0, 0, 680, 680, 680, 680, 680, 680, 680, 680, 684, 0, 0, 0, 0, 0, 0, 0, 681, 0, 0, 680, 0, 681, 0, 681, 681, 681, 681, 681, 681, 681, 681, 681, 681, 681, 0, 0, 0, 0, 680, 0, 0, 0, 0, 681, 681, 0, 0, 0, 0, 0, 681, 0, 681, 0, 681, 0, 681, 681, 681, 0, 0, 0, 0, 0, 681, 681, 681, 681, 0, 0, 0, 681, 681, 0, 0, 0, 681, 681, 681, 681, 681, 681, 681, 681, 685, 0, 0, 0, 0, 0, 0, 0, 684, 0, 0, 681, 0, 684, 0, 684, 684, 684, 684, 684, 684, 684, 684, 684, 684, 684, 0, 0, 0, 0, 681, 0, 0, 0, 0, 684, 684, 0, 0, 0, 0, 0, 684, 0, 684, 0, 684, 0, 684, 684, 684, 0, 0, 0, 0, 0, 684, 684, 684, 684, 0, 0, 0, 684, 684, 0, 0, 0, 0, 0, 684, 684, 684, 684, 684, 684, 686, 0, 0, 0, 0, 0, 0, 0, 685, 0, 0, 684, 0, 685, 0, 685, 685, 685, 685, 685, 685, 685, 685, 685, 685, 685, 0, 0, 0, 0, 684, 0, 0, 0, 0, 685, 685, 0, 0, 0, 0, 0, 685, 0, 685, 0, 685, 0, 685, 685, 685, 0, 0, 0, 0, 0, 685, 685, 685, 685, 0, 0, 0, 685, 685, 0, 0, 0, 0, 0, 685, 685, 685, 685, 685, 685, 687, 0, 0, 0, 0, 0, 0, 0, 686, 0, 0, 685, 0, 686, 0, 686, 686, 686, 686, 686, 686, 686, 686, 686, 686, 686, 0, 0, 0, 0, 685, 0, 0, 0, 0, 686, 686, 0, 0, 0, 0, 0, 686, 0, 686, 0, 686, 0, 686, 686, 686, 0, 0, 0, 0, 0, 686, 686, 686, 686, 0, 0, 0, 686, 686, 0, 0, 0, 0, 0, 686, 686, 686, 686, 686, 686, 688, 0, 0, 0, 0, 0, 0, 0, 687, 0, 0, 686, 0, 687, 0, 687, 687, 687, 687, 687, 687, 687, 687, 687, 687, 687, 0, 0, 0, 0, 686, 0, 0, 0, 0, 687, 687, 0, 0, 0, 0, 0, 687, 0, 687, 0, 687, 0, 687, 687, 687, 0, 0, 0, 0, 0, 687, 687, 687, 687, 381, 0, 0, 687, 687, 0, 381, 0, 0, 0, 687, 687, 687, 687, 687, 687, 0, 0, 0, 0, 0, 0, 0, 0, 688, 0, 0, 687, 0, 688, 0, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 688, 0, 381, 0, 0, 687, 0, 0, 0, 0, 688, 688, 0, 0, 0, 0, 0, 688, 0, 688, 0, 688, 0, 688, 688, 688, 0, 0, 0, 0, 0, 688, 688, 688, 688, 0, 0, 0, 688, 688, 0, 0, 0, 0, 0, 688, 688, 688, 688, 688, 688, 694, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 688, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 381, 688, 381, 381, 0, 0, 0, 381, 381, 0, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 381, 381, 0, 695, 0, 0, 0, 0, 381, 0, 0, 381, 0, 0, 694, 0, 0, 0, 0, 694, 381, 694, 694, 694, 694, 694, 694, 694, 694, 694, 694, 694, 0, 0, 0, 0, 0, 0, 0, 0, 0, 694, 694, 0, 0, 0, 0, 0, 694, 0, 694, 0, 694, 0, 694, 694, 694, 0, 0, 0, 0, 0, 0, 0, 694, 694, 0, 0, 0, 694, 694, 0, 0, 0, 0, 0, 698, 0, 694, 694, 694, 694, 0, 0, 0, 0, 0, 695, 0, 0, 0, 0, 695, 694, 695, 695, 695, 695, 695, 695, 695, 695, 695, 695, 695, 0, 0, 0, 0, 0, 0, 0, 694, 0, 695, 695, 0, 0, 0, 0, 0, 695, 0, 695, 0, 695, 0, 695, 695, 695, 0, 0, 0, 0, 0, 0, 0, 695, 695, 0, 0, 0, 695, 695, 0, 0, 0, 0, 0, 699, 0, 695, 695, 695, 695, 0, 0, 0, 0, 0, 698, 0, 0, 0, 0, 698, 695, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 698, 0, 0, 0, 0, 0, 0, 0, 695, 0, 698, 698, 0, 0, 0, 0, 0, 698, 0, 698, 0, 698, 0, 698, 698, 698, 0, 0, 0, 0, 0, 0, 0, 698, 698, 0, 0, 0, 698, 698, 0, 0, 0, 0, 0, 701, 0, 0, 0, 698, 698, 0, 0, 0, 0, 0, 699, 0, 0, 0, 0, 699, 698, 699, 699, 699, 699, 699, 699, 699, 699, 699, 699, 699, 0, 0, 0, 0, 0, 0, 0, 698, 0, 699, 699, 0, 0, 0, 0, 0, 699, 0, 699, 0, 699, 0, 699, 699, 699, 0, 0, 0, 0, 0, 0, 0, 699, 699, 0, 0, 0, 699, 699, 0, 0, 0, 0, 0, 702, 0, 0, 0, 699, 699, 0, 0, 0, 0, 0, 701, 0, 0, 0, 0, 701, 699, 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, 701, 0, 0, 0, 0, 0, 0, 0, 699, 0, 701, 701, 0, 0, 0, 0, 0, 701, 0, 701, 0, 701, 0, 701, 701, 701, 0, 0, 0, 0, 0, 0, 0, 0, 701, 0, 0, 0, 701, 701, 0, 0, 0, 0, 0, 705, 0, 0, 0, 701, 701, 0, 0, 0, 0, 0, 702, 0, 0, 0, 0, 702, 701, 702, 702, 702, 702, 702, 702, 702, 702, 702, 702, 702, 0, 0, 0, 0, 0, 0, 0, 701, 0, 702, 702, 0, 0, 0, 0, 0, 702, 0, 702, 0, 702, 0, 702, 702, 702, 0, 0, 0, 0, 0, 0, 0, 0, 702, 0, 0, 0, 702, 702, 0, 0, 0, 0, 0, 707, 0, 0, 0, 702, 702, 0, 0, 0, 0, 0, 705, 0, 0, 0, 0, 705, 702, 705, 705, 705, 705, 705, 705, 705, 705, 705, 705, 705, 0, 0, 0, 0, 0, 0, 0, 702, 0, 705, 705, 0, 0, 0, 0, 0, 705, 0, 705, 0, 705, 0, 705, 705, 705, 0, 0, 0, 0, 0, 0, 0, 0, 705, 0, 0, 0, 0, 705, 0, 0, 0, 0, 0, 708, 0, 0, 0, 705, 705, 0, 0, 0, 0, 0, 707, 0, 0, 0, 0, 707, 705, 707, 707, 707, 707, 707, 707, 707, 707, 707, 707, 707, 0, 0, 0, 0, 0, 0, 0, 705, 0, 707, 707, 0, 0, 0, 0, 0, 707, 0, 707, 0, 707, 0, 707, 707, 707, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 707, 0, 0, 0, 0, 0, 711, 0, 0, 0, 707, 707, 0, 0, 0, 0, 0, 708, 0, 0, 0, 0, 708, 707, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 0, 0, 0, 0, 0, 0, 0, 707, 0, 708, 708, 0, 0, 0, 0, 0, 708, 0, 708, 0, 708, 0, 708, 708, 708, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 708, 0, 0, 0, 0, 0, 0, 0, 0, 0, 708, 708, 0, 0, 0, 0, 0, 711, 0, 0, 0, 0, 711, 708, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 711, 0, 0, 0, 0, 0, 0, 0, 708, 0, 711, 711, 0, 0, 0, 0, 0, 711, 0, 711, 0, 711, 0, 711, 711, 711, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227, 0, 711, 0, 0, 227, 0, 0, 0, 227, 0, 227, 0, 711, 227, 0, 227, 227, 0, 227, 0, 0, 227, 0, 227, 711, 227, 227, 227, 227, 0, 0, 227, 227, 0, 212, 0, 0, 227, 0, 227, 227, 227, 0, 711, 227, 0, 227, 213, 227, 0, 0, 227, 0, 227, 227, 227, 227, 227, 0, 0, 227, 227, 227, 381, 0, 227, 227, 227, 0, 0, 0, 0, 0, 0, 227, 227, 214, 227, 227, 0, 227, 227, 227, 0, 0, 0, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227, 227, 227, 0, 227, 0, 0, 0, 0, 0, 227, 0, 0, 0, 0, 215, 216, 217, 218, 0, 219, 220, 221, 222, 223, 224, 225, 226, 0, 0, 227, 228, 229, 230, 231, 232, 233, 234, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 0, 0, 381, 227, 0, 0, 0, 0, 0, 0, 227, 227, 381, 0, 381, 381, 381, 381, 0, 0, 0, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 0, 0, 635, 0, 381, 0, 381, 0, 0, 381, 57, 24, 58, 25, 1299, 0, 26, 59, 381, 60, 61, 27, 62, 63, 64, 65, 28, 0, 0, 0, 0, 0, 66, 0, 67, 30, 68, 69, 70, 71, 0, 0, 32, 0, 0, 0, 72, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 0, 36, 0, 37, 77, 0, 0, 38, 0, 78, 79, 80, 81, 82, 83, 39, 40, 84, 85, 41, 86, 0, 87, 0, 0, 88, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 100, 0, 0, 0, 101, 0, 0, 0, 0, 102, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 113, 114, 56, 1300, 0, 115, 0, 0, 0, 0, 57, 24, 58, 25, 0, 0, 26, 59, 0, 60, 61, 27, 62, 63, 64, 65, 28, 0, 0, 0, 0, 0, 66, 0, 67, 30, 68, 69, 70, 71, 0, 0, 32, 0, 0, 0, 72, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 0, 36, 0, 37, 77, 0, 0, 38, 0, 78, 79, 80, 81, 82, 83, 39, 40, 84, 85, 41, 86, 0, 87, 0, 0, 88, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 100, 0, 0, 0, 101, 0, 0, 0, 0, 102, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 113, 114, 280, 0, 0, 115, 0, 0, 0, 0, 57, 24, 58, 25, 0, 0, 26, 59, 0, 60, 61, 27, 62, 63, 64, 65, 28, 0, 0, 0, 0, 0, 66, 0, 67, 30, 68, 69, 70, 71, 0, 0, 32, 0, 0, 0, 72, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 0, 36, 0, 37, 77, 0, 0, 38, 0, 78, 79, 80, 81, 82, 83, 39, 40, 84, 85, 41, 86, 0, 87, 0, 0, 88, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 100, 0, 0, 0, 101, 0, 0, 0, 0, 102, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 113, 114, 635, 0, 0, 115, 0, 0, 0, 0, 57, 24, 58, 25, 0, 0, 26, 59, 0, 60, 61, 27, 62, 63, 64, 65, 28, 0, 0, 0, 0, 0, 66, 0, 67, 30, 68, 69, 70, 71, 0, 0, 32, 0, 0, 0, 72, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 75, 76, 0, 36, 0, 37, 77, 0, 0, 38, 0, 78, 79, 80, 81, 82, 83, 39, 40, 84, 85, 41, 86, 0, 87, 0, 0, 88, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 100, 0, 0, 0, 101, 0, 0, 0, 0, 102, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, 113, 114, 1125, 0, 0, 115, 0, 0, 0, 0, 1125, 1125, 1125, 1125, 0, 0, 1125, 1125, 0, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 0, 0, 0, 0, 0, 1125, 0, 1125, 1125, 1125, 1125, 1125, 1125, 0, 0, 1125, 0, 0, 0, 1125, 1125, 0, 1125, 1125, 1125, 0, 0, 0, 0, 0, 0, 0, 0, 1125, 1125, 0, 1125, 0, 1125, 1125, 0, 0, 1125, 0, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 1125, 0, 1125, 0, 0, 1125, 1125, 0, 0, 1125, 1125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1125, 1125, 1125, 1125, 1125, 0, 0, 1125, 1125, 1125, 0, 0, 0, 1125, 0, 0, 0, 1125, 0, 0, 0, 0, 1125, 1125, 1125, 1125, 1125, 0, 0, 0, 1125, 0, 1125, 0, 0, 0, 0, 0, 1125, 1125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 690, 0, 0, 1125, 1125, 1125, 1125, 0, 57, 24, 1125, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 691, 0, 0, 0, 0, 0, 0, 692, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 693, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 694, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 881, 0, 0, 111, 112, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 318, 0, 0, 36, 0, 37, 77, 1122, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 575, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1135, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 767, 0, 38, 0, 0, 79, 1136, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 1137, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 881, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 575, 882, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1119, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 691, 0, 0, 0, 0, 0, 0, 692, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 693, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 317, 0, 0, 111, 112, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 318, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 329, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 330, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 843, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 87, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 881, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 575, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 873, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 1063, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 873, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 87, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 688, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 873, 0, 0, 111, 112, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1257, 0, 0, 111, 321, 113, 114, 0, 57, 24, 115, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 111, 1258, 113, 114, 0, 89, 89, 115, 89, 0, 0, 89, 89, 0, 720, 0, 89, 89, 89, 89, 0, 89, 0, 24, 0, 25, 0, 89, 26, 0, 89, 0, 0, 27, 0, 0, 0, 89, 28, 0, 0, 0, 89, 0, 89, 89, 89, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 89, 33, 89, 89, 0, 34, 89, 0, 0, 89, 0, 89, 0, 89, 89, 89, 89, 36, 89, 37, 0, 0, 0, 38, 0, 89, 0, 0, 89, 89, 0, 39, 40, 0, 0, 41, 0, 0, 87, 0, 0, 0, 0, 89, 89, 89, 89, 89, 0, 0, 89, 89, 89, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, 89, 89, 89, 89, 0, 0, 0, 89, 0, 89, 0, 343, 0, 0, 0, 89, 89, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 89, 89, 89, 89, 24, 66, 25, 89, 30, 26, 0, 0, 0, 0, 27, 32, 0, 0, 406, 28, 33, 0, 73, 74, 34, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 36, 0, 37, 77, 33, 0, 38, 0, 34, 79, 0, 81, 0, 83, 39, 40, 268, 1026, 41, 0, 36, 0, 37, 0, 0, 89, 38, 0, 90, 91, 0, 0, 0, 0, 39, 40, 0, 0, 41, 0, 0, 596, 0, 92, 93, 94, 95, 863, 0, 0, 97, 98, 99, 0, 0, 0, 864, 1210, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 343, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 865, 113, 114, 0, 66, 866, 0, 30, 0, 0, 0, 0, 0, 867, 32, 0, 0, 0, 0, 33, 406, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 863, 0, 0, 97, 98, 99, 0, 0, 0, 864, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 865, 113, 114, 0, 0, 866, 54, 0, 54, 0, 54, 0, 54, 867, 0, 54, 0, 54, 54, 0, 54, 0, 0, 54, 0, 54, 0, 54, 54, 54, 54, 0, 0, 54, 54, 0, 0, 0, 0, 54, 54, 54, 54, 54, 0, 0, 54, 0, 54, 0, 54, 0, 54, 54, 0, 54, 54, 54, 54, 54, 0, 54, 54, 54, 54, 0, 0, 54, 54, 54, 0, 0, 0, 0, 0, 0, 54, 54, 0, 54, 54, 0, 54, 54, 54, 0, 0, 0, 54, 0, 53, 0, 0, 0, 53, 0, 53, 0, 0, 53, 0, 53, 53, 0, 53, 0, 0, 53, 54, 53, 0, 53, 53, 53, 53, 54, 54, 53, 53, 0, 0, 0, 54, 53, 0, 53, 53, 53, 0, 0, 53, 0, 53, 0, 53, 0, 0, 53, 0, 53, 53, 53, 53, 53, 0, 0, 53, 53, 53, 0, 0, 53, 53, 53, 0, 0, 0, 0, 0, 0, 53, 53, 0, 53, 53, 0, 53, 53, 53, 54, 0, 0, 53, 0, 53, 0, 54, 54, 53, 0, 53, 0, 0, 53, 0, 53, 53, 0, 53, 0, 0, 53, 53, 53, 0, 53, 53, 53, 53, 0, 0, 53, 53, 91, 0, 0, 53, 53, 0, 53, 53, 53, 53, 0, 53, 0, 53, 0, 53, 0, 0, 53, 0, 53, 53, 53, 53, 53, 0, 0, 53, 53, 53, 0, 0, 53, 53, 53, 0, 0, 0, 0, 0, 0, 53, 53, 0, 53, 53, 0, 53, 53, 53, 53, 0, 0, 53, 0, 54, 0, 53, 53, 54, 0, 54, 0, 0, 54, 0, 54, 54, 0, 54, 0, 0, 54, 53, 54, 0, 54, 54, 54, 54, 0, 0, 54, 54, 92, 0, 0, 53, 54, 0, 54, 54, 54, 53, 0, 54, 0, 54, 0, 54, 0, 0, 54, 0, 54, 54, 54, 54, 54, 0, 0, 54, 54, 54, 0, 0, 54, 54, 54, 0, 0, 0, 0, 0, 0, 54, 54, 0, 54, 54, 0, 54, 54, 54, 53, 0, 0, 54, 0, 53, 0, 53, 53, 53, 0, 53, 0, 0, 53, 0, 53, 53, 0, 53, 0, 0, 53, 54, 53, 0, 53, 53, 53, 53, 0, 0, 53, 53, 0, 0, 0, 54, 53, 0, 53, 53, 53, 54, 0, 53, 0, 53, 0, 53, 0, 0, 53, 0, 53, 53, 53, 53, 53, 0, 0, 53, 53, 53, 0, 0, 53, 53, 53, 0, 0, 0, 0, 0, 0, 53, 53, 0, 53, 53, 0, 53, 53, 53, 54, 0, 0, 53, 0, 53, 0, 54, 54, 53, 0, 53, 0, 0, 53, 0, 53, 53, 0, 53, 0, 0, 53, 53, 53, 0, 53, 53, 53, 53, 0, 0, 53, 53, 256, 0, 0, 53, 53, 0, 53, 53, 53, 0, 0, 53, 0, 53, 0, 53, 0, 0, 53, 39, 53, 53, 53, 53, 53, 0, 0, 53, 53, 53, 39, 0, 53, 53, 53, 0, 39, 0, 0, 0, 39, 53, 53, 39, 53, 53, 0, 53, 53, 53, 53, 0, 0, 53, 0, 39, 39, 53, 53, 0, 39, 39, 0, 0, 0, 0, 39, 0, 39, 39, 39, 39, 0, 53, 0, 0, 39, 0, 0, 0, 39, 0, 39, 0, 257, 0, 0, 53, 0, 0, 0, 0, 39, 0, 39, 39, 0, 39, 0, 0, 0, 39, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 37, 0, 39, 0, 37, 0, 0, 37, 0, 0, 0, 0, 0, 39, 39, 53, 0, 0, 0, 37, 37, 0, 53, 53, 37, 37, 0, 0, 0, 0, 37, 0, 37, 37, 37, 37, 0, 0, 0, 0, 37, 0, 0, 0, 37, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 364, 37, 0, 37, 0, 0, 365, 37, 57, 24, 0, 25, 39, 39, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 37, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 37, 37, 32, 0, 0, 366, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, 0, 0, 0, 37, 37, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 369, 0, 0, 0, 103, 104, 105, 106, 1062, 0, 0, 107, 0, 108, 0, 0, 364, 0, 0, 109, 110, 0, 365, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 366, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 367, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 369, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 364, 0, 0, 109, 110, 0, 365, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 366, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 369, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 364, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 369, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 382, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 384, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 386, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 388, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 390, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 392, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 394, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 396, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 714, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 716, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 718, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 735, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 737, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 739, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 742, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 744, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 746, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 748, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 750, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 752, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 754, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 756, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 758, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 760, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 762, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 764, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 948, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 722, 0, 0, 109, 110, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 111, 271, 66, 114, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 270, 0, 0, 97, 98, 0, 0, 0, 0, 0, 0, 0, 0, 101, 0, 798, 0, 798, 0, 798, 723, 724, 798, 0, 798, 798, 0, 798, 725, 0, 798, 0, 798, 0, 798, 798, 798, 0, 0, 0, 798, 798, 0, 0, 0, 0, 798, 0, 798, 798, 0, 0, 0, 798, 0, 0, 0, 798, 0, 111, 271, 0, 726, 0, 0, 0, 798, 0, 798, 798, 0, 798, 0, 0, 0, 798, 798, 0, 0, 0, 0, 0, 0, 798, 798, 554, 0, 798, 0, 0, 798, 0, 0, 57, 24, 798, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 798, 798, 0, 32, 0, 0, 0, 798, 33, 0, 73, 74, 34, 798, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 1083, 79, 0, 81, 0, 83, 39, 40, 268, 24, 41, 25, 0, 0, 26, 0, 0, 0, 0, 27, 0, 0, 798, 0, 28, 0, 0, 0, 0, 798, 798, 0, 0, 30, 0, 92, 93, 94, 269, 555, 32, 0, 97, 98, 0, 33, 0, 0, 0, 34, 0, 0, 320, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 0, 0, 0, 38, 0, 1268, 0, 0, 0, 0, 0, 39, 40, 0, 24, 41, 25, 0, 87, 26, 0, 0, 0, 0, 27, 0, 0, 0, 0, 28, 0, 0, 0, 0, 111, 556, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 0, 0, 34, 0, 0, 343, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 39, 40, 0, 797, 41, 797, 0, 87, 797, 0, 797, 797, 0, 797, 0, 0, 797, 0, 797, 0, 797, 797, 797, 0, 406, 0, 797, 797, 0, 0, 0, 0, 797, 0, 797, 797, 0, 0, 0, 797, 0, 0, 0, 797, 0, 0, 343, 0, 0, 0, 0, 0, 797, 0, 0, 797, 0, 797, 0, 0, 0, 797, 797, 0, 0, 0, 0, 0, 0, 797, 797, 0, 0, 797, 0, 0, 797, 797, 0, 797, 0, 797, 797, 0, 797, 797, 0, 797, 0, 0, 797, 0, 797, 406, 797, 797, 797, 0, 0, 0, 797, 797, 0, 0, 0, 0, 797, 0, 797, 797, 0, 0, 0, 797, 0, 797, 0, 797, 0, 0, 0, 797, 0, 0, 0, 0, 797, 0, 0, 797, 0, 797, 0, 0, 0, 797, 797, 0, 0, 0, 0, 0, 0, 797, 797, 0, 0, 797, 0, 0, 797, 0, 0, 0, 0, 797, 0, 0, 0, 0, 57, 24, 797, 25, 0, 0, 26, 267, 0, 797, 797, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 205, 66, 205, 0, 30, 205, 0, 0, 797, 0, 205, 32, 0, 0, 0, 205, 33, 0, 73, 74, 34, 0, 691, 0, 205, 0, 0, 0, 0, 692, 0, 205, 36, 0, 37, 77, 205, 0, 38, 0, 205, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 205, 0, 205, 797, 0, 693, 205, 0, 90, 91, 797, 797, 0, 0, 205, 205, 0, 0, 205, 0, 0, 205, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 1117, 0, 694, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 1150, 205, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 112, 113, 114, 24, 66, 25, 115, 30, 26, 0, 0, 0, 0, 27, 32, 0, 0, 0, 28, 33, 205, 73, 74, 34, 0, 691, 0, 30, 0, 0, 0, 0, 692, 0, 32, 36, 0, 37, 77, 33, 0, 38, 0, 34, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 36, 0, 37, 0, 0, 693, 38, 0, 90, 91, 0, 0, 0, 0, 39, 40, 0, 0, 41, 0, 0, 87, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 694, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 343, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 112, 113, 114, 0, 66, 0, 115, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 406, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 318, 0, 0, 36, 0, 37, 77, 767, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 321, 113, 114, 24, 66, 25, 115, 30, 26, 0, 0, 0, 0, 27, 32, 0, 0, 0, 28, 33, 0, 73, 74, 34, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 36, 0, 37, 77, 33, 0, 38, 0, 34, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 36, 87, 37, 0, 0, 89, 38, 0, 90, 91, 0, 0, 0, 0, 39, 40, 0, 0, 41, 0, 0, 606, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 343, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 376, 113, 114, 570, 66, 570, 115, 30, 570, 0, 0, 0, 0, 570, 32, 0, 0, 0, 570, 33, 406, 73, 74, 34, 0, 0, 0, 570, 0, 0, 0, 0, 0, 0, 570, 36, 0, 37, 77, 570, 0, 38, 0, 570, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 570, 87, 570, 0, 0, 89, 570, 0, 90, 91, 0, 0, 0, 0, 570, 570, 0, 0, 570, 0, 0, 570, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 570, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 321, 113, 114, 206, 66, 206, 115, 30, 206, 0, 0, 0, 0, 206, 32, 0, 0, 0, 206, 33, 570, 73, 74, 34, 0, 0, 0, 206, 0, 0, 0, 0, 318, 0, 206, 36, 0, 37, 77, 206, 0, 38, 0, 206, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 206, 0, 206, 0, 0, 89, 206, 0, 90, 91, 0, 0, 0, 0, 206, 206, 0, 0, 206, 0, 0, 206, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 206, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 321, 113, 114, 205, 66, 205, 115, 30, 205, 0, 0, 0, 0, 205, 32, 0, 0, 0, 205, 33, 206, 73, 74, 34, 0, 0, 0, 205, 0, 0, 0, 0, 0, 0, 205, 36, 0, 37, 77, 205, 0, 38, 0, 205, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 205, 0, 205, 0, 0, 89, 205, 0, 90, 91, 0, 0, 0, 0, 205, 205, 0, 0, 205, 0, 0, 205, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 575, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 205, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 321, 113, 114, 162, 66, 162, 115, 30, 162, 0, 0, 0, 0, 162, 32, 0, 0, 0, 162, 33, 205, 73, 74, 34, 0, 0, 0, 162, 0, 0, 0, 0, 0, 0, 162, 36, 0, 37, 77, 162, 0, 38, 0, 162, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 162, 0, 162, 0, 0, 89, 162, 0, 90, 91, 0, 0, 0, 0, 162, 162, 0, 0, 162, 0, 0, 162, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 569, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 162, 109, 110, 0, 0, 0, 0, 0, 0, 750, 750, 0, 750, 0, 0, 750, 750, 0, 0, 0, 750, 750, 750, 750, 0, 750, 111, 321, 113, 114, 216, 750, 216, 115, 750, 216, 0, 0, 0, 0, 216, 750, 0, 0, 0, 216, 750, 162, 750, 750, 750, 0, 0, 0, 216, 0, 0, 0, 0, 750, 0, 216, 750, 0, 750, 750, 216, 0, 750, 0, 216, 750, 0, 750, 0, 750, 750, 750, 750, 0, 750, 0, 216, 0, 216, 0, 0, 750, 216, 0, 750, 750, 0, 0, 0, 0, 216, 216, 0, 0, 216, 0, 0, 216, 0, 750, 750, 750, 750, 750, 0, 0, 750, 750, 750, 0, 0, 0, 0, 0, 0, 0, 750, 0, 0, 0, 0, 0, 750, 750, 750, 750, 0, 0, 0, 750, 0, 750, 0, 0, 0, 0, 216, 750, 750, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 750, 750, 750, 750, 0, 66, 0, 750, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 216, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 321, 113, 114, 0, 66, 0, 115, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 111, 112, 113, 114, 0, 66, 0, 115, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 89, 0, 0, 90, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 0, 153, 153, 0, 153, 0, 0, 153, 153, 0, 0, 0, 153, 153, 153, 153, 0, 153, 111, 376, 113, 114, 0, 153, 0, 115, 153, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 153, 0, 153, 153, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 153, 153, 0, 0, 153, 0, 0, 153, 0, 153, 0, 153, 153, 153, 153, 0, 153, 0, 0, 0, 0, 0, 0, 153, 0, 0, 153, 153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 153, 153, 153, 153, 153, 0, 0, 153, 153, 153, 381, 0, 0, 0, 0, 0, 0, 153, 0, 0, 0, 0, 0, 153, 153, 153, 153, 0, 0, 0, 153, 0, 153, 0, 381, 0, 0, 0, 153, 153, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 381, 0, 0, 381, 0, 381, 0, 381, 381, 381, 381, 153, 153, 153, 153, 381, 0, 0, 153, 381, 0, 0, 0, 381, 0, 0, 57, 24, 0, 25, 0, 381, 26, 267, 381, 0, 381, 27, 62, 63, 64, 0, 28, 0, 24, 0, 25, 0, 66, 26, 0, 30, 0, 0, 27, 381, 0, 0, 32, 28, 381, 0, 0, 33, 0, 73, 74, 34, 30, 0, 0, 381, 381, 0, 306, 32, 381, 0, 0, 36, 33, 37, 77, 0, 34, 38, 0, 0, 79, 381, 81, 0, 83, 39, 40, 268, 36, 41, 37, 0, 0, 0, 38, 0, 89, 0, 0, 90, 91, 0, 39, 40, 0, 0, 41, 0, 0, 87, 0, 0, 0, 381, 92, 93, 94, 95, 319, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 305, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 343, 0, 0, 0, 109, 110, 0, 0, 0, 0, 0, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 111, 321, 113, 114, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 344, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 368, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 111, 271, 30, 114, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 740, 0, 0, 97, 98, 99, 0, 0, 0, 0, 0, 0, 0, 320, 0, 0, 0, 0, 0, 103, 104, 105, 106, 0, 0, 0, 107, 0, 108, 0, 0, 0, 0, 0, 109, 110, 57, 24, 0, 25, 0, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 111, 271, 30, 114, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 270, 0, 0, 97, 98, 0, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 0, 723, 724, 0, 0, 57, 24, 0, 25, 725, 0, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 111, 271, 33, 726, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 315, 0, 0, 0, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 270, 0, 0, 97, 98, 0, 0, 0, 57, 24, 0, 25, 0, 101, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 0, 0, 0, 0, 66, 0, 0, 30, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 33, 0, 73, 74, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, 271, 36, 0, 37, 77, 0, 0, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 0, 41, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 269, 270, 0, 0, 97, 98, 0, 0, 0, 57, 24, 0, 25, 0, 101, 26, 267, 0, 0, 0, 27, 62, 63, 64, 0, 28, 0, 205, 0, 205, 0, 66, 205, 0, 30, 0, 0, 205, 0, 0, 0, 32, 205, 0, 0, 0, 33, 0, 73, 74, 34, 205, 0, 0, 0, 0, 0, 0, 205, 0, 111, 271, 36, 205, 37, 77, 0, 205, 38, 0, 0, 79, 0, 81, 0, 83, 39, 40, 268, 205, 41, 205, 0, 87, 0, 205, 0, 0, 0, 0, 0, 0, 0, 205, 205, 0, 0, 205, 0, 0, 205, 0, 0, 0, 0, 92, 93, 94, 269, 555, 0, 0, 97, 98, 0, 0, 0, 0, 24, 0, 25, 0, 101, 26, 0, 0, 1550, 0, 27, 0, 0, 818, 0, 28, 0, 819, 1551, 1552, 0, 205, 1150, 1553, 30, 0, 0, 0, 0, 1554, 0, 32, 0, 0, 0, 0, 33, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 1026, 111, 556, 36, 0, 37, 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 39, 40, 205, 0, 41, 0, 0, 1555, 24, 0, 25, 0, 1556, 26, 0, 0, 1550, 0, 27, 0, 0, 818, 0, 28, 0, 819, 1551, 1552, 0, 0, 0, 1553, 30, 0, 0, 0, 0, 1554, 0, 32, 53, 0, 53, 0, 33, 53, 343, 0, 34, 0, 53, 0, 1557, 0, 0, 53, 0, 1026, 0, 0, 36, 0, 37, 0, 53, 0, 38, 0, 0, 0, 53, 53, 0, 0, 39, 40, 53, 0, 41, 0, 53, 1555, 53, 0, 53, 0, 1556, 0, 0, 53, 0, 0, 53, 1558, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 53, 53, 0, 0, 53, 0, 0, 53, 53, 0, 53, 0, 0, 53, 343, 0, 0, 0, 53, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 53, 53, 0, 0, 0, 0, 53, 0, 53, 185, 53, 0, 53, 0, 53, 0, 0, 0, 0, 53, 0, 0, 53, 1558, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 53, 53, 0, 0, 53, 0, 0, 53, 24, 0, 25, 0, 0, 26, 0, 0, 0, 0, 27, 53, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 655, 32, 0, 0, 0, 0, 33, 185, 53, 0, 34, 0, 656, 0, 0, 0, 0, 0, 0, 657, 0, 0, 36, 0, 37, 0, 0, 0, 38, 0, 0, 658, 0, 0, 0, 0, 39, 40, 0, 0, 41, 0, 0, 606, 54, 0, 54, 0, 0, 54, 0, 0, 0, 0, 54, 53, 0, 0, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 54, 659, 0, 0, 0, 0, 54, 54, 0, 0, 0, 0, 54, 0, 343, 0, 54, 0, 54, 0, 54, 0, 0, 0, 0, 54, 0, 0, 54, 0, 54, 0, 0, 0, 54, 0, 0, 54, 0, 0, 0, 0, 54, 54, 0, 53, 54, 53, 0, 54, 53, 0, 0, 0, 0, 53, 0, 0, 0, 0, 53, 660, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 53, 53, 0, 0, 0, 0, 53, 0, 0, 0, 53, 0, 53, 54, 53, 0, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 0, 0, 53, 0, 0, 53, 0, 0, 0, 0, 53, 53, 0, 24, 53, 25, 0, 53, 26, 0, 1482, 0, 0, 27, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 54, 0, 0, 30, 0, 0, 53, 0, 53, 0, 32, 0, 0, 0, 0, 33, 0, 1483, 0, 34, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 53, 36, 0, 37, 0, 0, 0, 38, 1484, 0, 0, 0, 0, 53, 0, 39, 40, 0, 53, 41, 0, 0, 87, 53, 0, 53, 53, 53, 53, 0, 0, 0, 0, 53, 506, 0, 0, 53, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 53, 0, 53, 0, 0, 0, 507, 0, 0, 343, 0, 0, 506, 0, 0, 0, 0, 0, 0, 508, 0, 0, 0, 509, 510, 0, 53, 0, 0, 511, 0, 512, 513, 514, 515, 0, 507, 339, 0, 516, 0, 0, 0, 517, 0, 0, 0, 0, 0, 508, 0, 0, 0, 0, 510, 518, 406, 0, 519, 511, 520, 512, 513, 514, 515, 0, 0, 0, 0, 516, 0, 0, 0, 517, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 521, 518, 0, 0, 519, 0, 520, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 521 }; protected static readonly short[] yyCheck = new short[22411] { 17, 313, 17, 17, 52, 18, 4, 17, 52, 76, 314, 303, 247, 203, 575, 260, 245, 523, 342, 202, 63, 545, 767, 312, 67, 68, 69, 375, 71, 72, 573, 445, 6, 70, 77, 78, 206, 445, 445, 358, 83, 84, 125, 86, 312, 88, 343, 637, 171, 59, 93, 94, 405, 90, 91, 310, 886, 1340, 95, 76, 773, 426, 888, 80, 415, 778, 779, 1080, 60, 651, 256, 425, 82, 1084, 84, 60, 854, 123, 856, 125, 97, 124, 119, 75, 101, 353, 676, 0, 1065, 1385, 75, 45, 1388, 256, 48, 256, 256, 415, 115, 256, 256, 17, 333, 256, 187, 256, 268, 256, 256, 256, 1490, 268, 343, 256, 151, 256, 101, 256, 256, 256, 256, 1128, 256, 256, 902, 256, 256, 905, 256, 1509, 115, 17, 256, 382, 1595, 283, 364, 256, 379, 366, 256, 397, 263, 278, 336, 1441, 256, 282, 344, 256, 377, 17, 340, 268, 171, 203, 171, 171, 256, 203, 269, 171, 374, 256, 420, 374, 378, 315, 17, 378, 382, 427, 256, 382, 405, 376, 377, 373, 287, 380, 425, 437, 17, 17, 17, 373, 382, 17, 429, 438, 376, 17, 378, 17, 380, 316, 424, 245, 466, 426, 17, 245, 0, 364, 340, 1666, 322, 1220, 343, 345, 528, 347, 374, 366, 350, 351, 17, 353, 354, 352, 380, 377, 259, 260, 373, 268, 375, 60, 377, 272, 364, 382, 65, 256, 397, 373, 273, 380, 377, 377, 387, 378, 75, 260, 380, 1622, 438, 256, 256, 266, 569, 256, 438, 1079, 373, 171, 491, 420, 377, 387, 572, 490, 345, 424, 427, 616, 428, 241, 101, 312, 426, 428, 625, 310, 1287, 359, 424, 426, 1285, 316, 429, 235, 115, 424, 382, 171, 303, 426, 426, 637, 424, 308, 309, 424, 424, 341, 857, 278, 616, 345, 424, 318, 438, 320, 1315, 171, 1686, 426, 300, 355, 347, 328, 630, 428, 424, 300, 1293, 424, 310, 336, 357, 338, 171, 315, 1037, 342, 1039, 337, 676, 683, 315, 424, 369, 503, 1714, 686, 171, 171, 171, 256, 922, 171, 359, 360, 257, 171, 1726, 171, 1728, 433, 434, 435, 436, 338, 171, 1333, 268, 256, 381, 1337, 375, 375, 1075, 681, 276, 662, 256, 295, 686, 687, 171, 256, 409, 1199, 382, 1752, 381, 1122, 387, 307, 417, 256, 256, 364, 421, 374, 256, 1465, 425, 426, 257, 326, 0, 1380, 625, 462, 413, 1680, 256, 1776, 1777, 21, 256, 256, 359, 326, 1783, 1784, 425, 426, 256, 256, 256, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 256, 1203, 1256, 1140, 256, 1142, 336, 662, 1145, 53, 256, 472, 473, 1472, 683, 476, 793, 257, 490, 424, 425, 462, 490, 256, 306, 438, 498, 1747, 364, 445, 498, 262, 380, 256, 1445, 257, 445, 256, 256, 767, 381, 340, 256, 300, 272, 256, 345, 341, 347, 256, 272, 350, 351, 376, 353, 354, 278, 380, 315, 1779, 282, 1520, 256, 1565, 373, 424, 364, 381, 299, 297, 1572, 792, 424, 540, 422, 297, 272, 866, 376, 424, 378, 338, 380, 544, 340, 546, 295, 1289, 424, 345, 256, 347, 1077, 841, 350, 351, 324, 353, 354, 1601, 378, 297, 324, 380, 538, 424, 375, 1055, 378, 1246, 378, 1248, 573, 1250, 1716, 1717, 494, 495, 375, 580, 1456, 343, 500, 374, 591, 377, 424, 373, 324, 375, 571, 256, 573, 340, 575, 910, 545, 792, 345, 438, 347, 800, 603, 350, 351, 378, 353, 354, 342, 358, 272, 1353, 375, 384, 385, 364, 306, 826, 592, 378, 378, 375, 1364, 818, 375, 1198, 375, 377, 910, 946, 379, 1773, 375, 614, 833, 297, 374, 618, 344, 266, 859, 375, 438, 392, 382, 974, 907, 438, 445, 256, 631, 1393, 633, 1226, 788, 629, 1532, 374, 637, 637, 661, 642, 324, 431, 432, 646, 647, 373, 272, 431, 432, 672, 1197, 1615, 278, 424, 382, 651, 282, 961, 727, 682, 683, 377, 256, 374, 667, 1233, 315, 670, 364, 438, 1369, 297, 650, 431, 432, 676, 676, 378, 438, 650, 683, 1645, 1646, 256, 266, 1649, 1240, 374, 691, 692, 907, 264, 1472, 380, 672, 727, 374, 1661, 324, 438, 1664, 672, 380, 306, 1043, 374, 1405, 364, 374, 732, 426, 340, 263, 256, 378, 1679, 345, 343, 347, 375, 691, 350, 351, 379, 353, 354, 545, 438, 424, 946, 378, 378, 381, 315, 1472, 90, 91, 438, 382, 1703, 1520, 437, 1310, 1041, 1472, 1299, 340, 431, 432, 980, 344, 380, 775, 326, 777, 382, 256, 256, 1457, 114, 438, 1044, 871, 786, 256, 316, 1071, 424, 1472, 438, 773, 1472, 438, 429, 438, 778, 779, 1476, 781, 373, 437, 358, 1520, 377, 1360, 379, 380, 381, 382, 374, 438, 438, 1520, 387, 256, 374, 295, 340, 373, 381, 1472, 1076, 345, 826, 347, 431, 432, 350, 351, 438, 353, 354, 1472, 256, 306, 392, 1520, 1335, 637, 1520, 1074, 844, 1553, 826, 380, 342, 397, 1044, 378, 374, 377, 650, 1122, 378, 340, 380, 859, 906, 841, 424, 1240, 377, 387, 866, 344, 424, 1240, 1240, 1520, 420, 392, 393, 394, 672, 857, 210, 211, 676, 375, 819, 1520, 864, 344, 866, 1382, 1021, 422, 373, 392, 344, 90, 91, 691, 373, 424, 381, 390, 377, 340, 379, 380, 859, 382, 345, 1394, 347, 395, 387, 350, 351, 1200, 353, 354, 438, 114, 438, 344, 340, 373, 895, 340, 897, 345, 256, 347, 387, 344, 350, 351, 912, 353, 354, 344, 916, 344, 397, 1214, 400, 401, 6, 340, 276, 945, 926, 920, 373, 922, 1158, 391, 982, 17, 344, 955, 373, 382, 373, 406, 377, 420, 1468, 993, 373, 407, 373, 382, 427, 1576, 302, 951, 972, 953, 974, 382, 373, 419, 437, 344, 980, 376, 1589, 373, 939, 380, 379, 987, 344, 382, 344, 939, 382, 1304, 974, 327, 60, 1471, 1472, 438, 980, 65, 982, 1149, 379, 1016, 1613, 382, 256, 1016, 340, 75, 992, 210, 211, 345, 381, 347, 438, 1493, 350, 351, 1155, 353, 354, 256, 90, 91, 377, 374, 379, 387, 397, 365, 366, 380, 340, 101, 269, 396, 344, 397, 387, 397, 1299, 344, 1520, 340, 1522, 1360, 114, 115, 377, 387, 379, 420, 287, 1037, 854, 1039, 856, 1041, 427, 397, 420, 1340, 420, 379, 400, 373, 382, 427, 437, 427, 373, 344, 1082, 1057, 382, 276, 373, 437, 1062, 437, 1084, 1065, 420, 358, 1343, 1037, 1027, 340, 375, 427, 373, 1075, 344, 1077, 377, 1036, 379, 380, 373, 382, 373, 302, 902, 171, 387, 905, 424, 295, 444, 382, 358, 375, 358, 314, 404, 405, 1589, 392, 1330, 307, 373, 373, 1126, 387, 358, 377, 327, 379, 380, 261, 382, 379, 1391, 379, 256, 387, 472, 473, 421, 939, 1668, 1456, 210, 211, 392, 378, 392, 380, 424, 382, 1134, 295, 420, 285, 1158, 380, 1140, 382, 1142, 427, 421, 1145, 387, 307, 365, 366, 298, 358, 397, 421, 314, 303, 379, 364, 1158, 373, 308, 1181, 310, 311, 312, 313, 326, 1187, 375, 278, 318, 378, 379, 380, 322, 420, 295, 307, 326, 373, 382, 375, 427, 400, 314, 392, 334, 1731, 307, 337, 309, 339, 276, 374, 1412, 314, 1408, 1197, 382, 380, 1200, 1532, 374, 1478, 17, 1378, 256, 326, 380, 376, 1167, 378, 1169, 380, 379, 363, 300, 424, 302, 388, 389, 1037, 1242, 1223, 1768, 382, 378, 444, 380, 374, 314, 315, 374, 402, 403, 380, 382, 378, 380, 380, 1233, 382, 378, 327, 380, 424, 1246, 60, 1248, 333, 1250, 295, 65, 1253, 338, 472, 473, 377, 380, 343, 382, 381, 75, 295, 1314, 1240, 1553, 1793, 1794, 376, 376, 378, 1240, 380, 380, 365, 424, 450, 451, 452, 453, 365, 366, 1264, 374, 1586, 380, 377, 101, 379, 380, 375, 344, 1293, 376, 1315, 376, 376, 380, 1299, 380, 380, 115, 378, 1605, 380, 1304, 1304, 398, 399, 1330, 376, 424, 1313, 1314, 380, 400, 1310, 376, 1533, 374, 405, 380, 1624, 378, 1626, 382, 1541, 418, 376, 1330, 1299, 378, 380, 374, 1331, 426, 374, 378, 429, 1340, 378, 380, 1343, 90, 91, 424, 1378, 438, 1380, 378, 1378, 380, 1380, 378, 378, 380, 380, 171, 357, 444, 445, 1360, 1360, 378, 378, 380, 380, 114, 1369, 365, 387, 374, 375, 726, 1375, 375, 1408, 261, 420, 263, 1408, 377, 387, 379, 1680, 378, 1203, 472, 473, 381, 1391, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 285, 398, 399, 1405, 1406, 376, 377, 382, 379, 380, 381, 378, 1445, 298, 374, 376, 1445, 378, 303, 367, 368, 418, 1240, 308, 380, 310, 311, 312, 313, 426, 438, 316, 429, 318, 380, 378, 382, 322, 1471, 1472, 380, 381, 1471, 1472, 378, 376, 1468, 378, 376, 334, 378, 376, 337, 378, 339, 1457, 1456, 1456, 206, 545, 1493, 424, 210, 211, 1493, 378, 1468, 380, 378, 424, 380, 1289, 295, 376, 1476, 378, 1478, 376, 363, 378, 380, 1299, 382, 355, 356, 300, 1304, 1520, 380, 1522, 382, 1520, 380, 1522, 382, 295, 380, 380, 382, 378, 315, 378, 1524, 355, 356, 374, 375, 726, 382, 1806, 380, 420, 421, 370, 371, 380, 367, 368, 367, 368, 370, 371, 378, 338, 446, 447, 646, 647, 276, 448, 449, 256, 1532, 1532, 387, 1353, 454, 455, 377, 625, 894, 1536, 1360, 387, 437, 256, 1364, 437, 767, 381, 295, 637, 295, 387, 302, 380, 424, 378, 380, 379, 375, 379, 381, 917, 650, 424, 314, 378, 380, 1571, 387, 380, 380, 380, 438, 1393, 662, 382, 380, 327, 378, 429, 373, 380, 378, 333, 672, 423, 942, 381, 676, 424, 344, 380, 378, 343, 1598, 314, 429, 295, 1595, 295, 380, 376, 373, 691, 377, 313, 424, 381, 424, 256, 324, 380, 256, 256, 281, 365, 366, 387, 256, 374, 373, 378, 344, 1658, 382, 299, 424, 1658, 445, 377, 376, 382, 423, 382, 378, 387, 1456, 380, 726, 380, 1675, 376, 382, 348, 1675, 378, 378, 429, 387, 373, 400, 376, 256, 1688, 1689, 405, 377, 1688, 1689, 387, 256, 387, 378, 374, 1668, 382, 378, 348, 424, 1666, 380, 340, 376, 894, 381, 376, 1680, 376, 378, 767, 373, 1716, 1717, 378, 381, 1716, 1717, 349, 374, 1045, 424, 380, 377, 1697, 444, 424, 917, 349, 256, 374, 373, 373, 373, 387, 792, 382, 374, 357, 378, 338, 256, 374, 1532, 377, 374, 380, 382, 378, 374, 374, 306, 942, 472, 473, 377, 382, 375, 1731, 545, 377, 818, 373, 424, 424, 424, 344, 382, 377, 1773, 373, 377, 424, 1773, 379, 377, 377, 387, 382, 90, 91, 375, 377, 380, 503, 378, 378, 387, 379, 379, 378, 380, 261, 380, 380, 1768, 424, 854, 382, 856, 1793, 1794, 378, 114, 376, 382, 387, 382, 378, 376, 1776, 1777, 378, 382, 378, 374, 285, 1783, 1784, 316, 1793, 1794, 378, 374, 387, 424, 256, 263, 424, 298, 377, 377, 374, 1806, 303, 387, 0, 894, 1163, 308, 1165, 310, 311, 312, 313, 902, 378, 378, 905, 318, 907, 637, 382, 322, 0, 1045, 424, 326, 382, 373, 917, 374, 424, 382, 650, 334, 378, 0, 337, 380, 339, 374, 382, 378, 373, 424, 378, 316, 376, 374, 376, 382, 939, 374, 378, 942, 672, 373, 424, 946, 676, 374, 382, 382, 363, 206, 378, 382, 382, 210, 211, 256, 378, 374, 378, 691, 625, 374, 373, 382, 340, 374, 374, 379, 382, 345, 263, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 382, 382, 382, 382, 1122, 382, 382, 382, 51, 367, 368, 12, 1265, 5, 1155, 662, 374, 1021, 376, 1037, 378, 1330, 380, 381, 382, 1330, 1522, 424, 1493, 1549, 1338, 1721, 1683, 391, 1737, 1671, 1700, 276, 396, 818, 1533, 1559, 1508, 1048, 832, 1163, 1598, 1165, 406, 407, 1048, 1048, 1037, 1043, 1576, 1596, 1520, 340, 1784, 1044, 1045, 419, 345, 302, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 314, 1693, 1761, 1689, 726, 438, 1688, 1777, 1445, 367, 368, 1626, 1559, 327, 1016, 333, 374, 907, 376, 333, 378, 1447, 380, 381, 382, 1071, 980, 1091, 864, 343, 1214, 73, 390, 391, 361, 1240, 1242, 395, 396, 826, 692, 456, 859, 457, 460, 767, 404, 405, 406, 407, 633, 365, 366, 458, 461, 459, 992, 946, 1335, 1423, 1531, 419, 1122, 1304, 625, 854, 788, 856, 171, 1302, 792, 1314, 1265, 1226, 1183, 1304, 1394, 413, 256, 1363, 438, 593, 1088, 481, 481, 1526, 400, 265, 1011, 267, 1406, 405, 270, 1018, 784, 0, 818, 275, -1, -1, -1, -1, 280, 1163, -1, 1165, -1, -1, -1, -1, -1, 289, -1, 902, -1, -1, 905, -1, 296, -1, -1, -1, -1, 301, -1, -1, -1, 305, -1, -1, 444, -1, -1, -1, -1, -1, -1, 256, -1, 317, -1, 319, 1470, 1203, -1, 323, 265, -1, 267, -1, 939, 270, -1, 331, 332, -1, 275, 335, 472, 473, 338, 280, -1, -1, -1, -1, -1, -1, -1, -1, 289, -1, 894, -1, -1, -1, -1, 296, -1, -1, 1240, -1, 301, -1, -1, 907, 305, -1, 1381, 503, -1, -1, -1, -1, -1, 917, -1, -1, 317, 377, 319, -1, -1, 1531, 323, 1265, -1, -1, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, 942, -1, 1550, 1551, 946, -1, -1, -1, -1, 1289, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1299, -1, -1, -1, -1, 1304, -1, 424, -1, 1037, -1, 1578, -1, -1, 1581, 1447, -1, -1, -1, 377, -1, 96, -1, -1, 99, -1, -1, -1, 103, 104, 105, 106, 107, 108, 109, 110, -1, -1, 1470, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 261, 1353, -1, -1, -1, -1, -1, 1021, 1360, -1, -1, -1, 1364, 424, -1, -1, -1, -1, -1, 625, -1, -1, -1, -1, 285, -1, -1, -1, -1, 1381, 1044, 1045, -1, -1, -1, -1, -1, 298, -1, -1, -1, 1393, 303, -1, -1, -1, 1531, 308, -1, 310, 311, 312, 313, -1, -1, -1, 662, 318, -1, -1, 257, 322, -1, -1, 261, 1550, 1551, -1, 1553, -1, -1, -1, -1, 334, -1, 272, 337, -1, 339, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, 0, 1578, -1, 1447, 1581, -1, -1, -1, 297, 298, 363, -1, 1456, 302, 303, -1, 1122, -1, -1, 308, -1, 310, 311, 312, 313, -1, 1470, -1, 726, 318, 1203, -1, -1, 322, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, 336, 337, 1155, 339, -1, -1, -1, 343, -1, -1, 1163, -1, 1165, -1, -1, -1, -1, -1, -1, -1, 1240, -1, 767, -1, 424, -1, -1, 363, -1, -1, 256, -1, -1, -1, -1, -1, -1, -1, 374, 375, 1531, 1532, 1533, 788, -1, -1, -1, 792, -1, -1, 1541, -1, 319, -1, -1, -1, -1, -1, -1, 1550, 1551, -1, 1553, -1, -1, -1, -1, -1, -1, 1289, -1, -1, -1, 818, -1, -1, -1, -1, -1, 1299, -1, -1, -1, -1, 1304, -1, -1, 1578, -1, -1, 1581, 358, -1, -1, -1, 431, 432, -1, -1, -1, -1, 368, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1265, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, 1353, -1, -1, -1, -1, -1, -1, 1360, 367, 368, -1, 1364, -1, -1, -1, 374, 894, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 907, -1, -1, -1, -1, -1, -1, -1, 396, -1, 917, 1393, 441, 442, 443, -1, -1, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, -1, -1, 942, -1, -1, -1, 946, -1, -1, -1, -1, -1, -1, -1, -1, 257, -1, 438, 0, 261, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, -1, -1, 1381, -1, -1, 278, -1, -1, -1, 282, 1456, -1, 285, -1, 256, -1, -1, -1, -1, -1, -1, -1, -1, -1, 297, 298, -1, -1, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, 1021, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, 1447, -1, 343, -1, -1, 1044, 1045, -1, 569, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1532, -1, -1, -1, 363, 1470, -1, -1, -1, -1, -1, -1, 340, -1, 373, 374, 375, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1122, 1531, -1, 1533, -1, -1, -1, 431, 432, -1, -1, 1541, -1, -1, -1, -1, -1, -1, -1, 0, 1550, 1551, 666, 1553, -1, -1, -1, -1, -1, 1559, -1, -1, -1, 1155, -1, -1, -1, 265, -1, 267, -1, 1163, 270, 1165, -1, 438, 1576, 275, 1578, -1, -1, 1581, 280, -1, -1, -1, 284, -1, -1, 1589, -1, 289, -1, -1, -1, 358, 294, -1, 296, -1, -1, 364, 365, 301, -1, -1, -1, 305, 306, 723, 724, 374, 375, 1613, 377, 378, 379, 380, -1, 317, -1, 319, 256, -1, 387, 323, 740, 261, 262, 392, -1, -1, -1, 331, 332, 398, 399, 335, -1, -1, 338, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, 418, -1, -1, -1, -1, -1, 424, -1, 426, 298, 299, 429, -1, -1, 303, -1, -1, 306, 1265, 308, 438, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, 424, -1, -1, 363, 364, 365, -1, 367, 368, -1, -1, -1, -1, 373, 374, -1, 376, 377, 378, 379, 380, 381, 382, 863, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 0, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, -1, 422, 1381, 424, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, 256, 257, -1, -1, 256, 261, -1, -1, -1, 265, -1, 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, -1, 280, -1, 282, 283, 284, 285, -1, -1, 288, 289, -1, -1, -1, -1, 294, -1, 296, 297, 298, -1, -1, 301, 302, 303, -1, 305, 1447, -1, 308, -1, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, -1, -1, 322, 323, 324, -1, -1, -1, -1, 1470, -1, 331, 332, -1, 334, 335, -1, 337, 338, 339, -1, -1, -1, 343, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, 363, -1, -1, -1, -1, -1, -1, -1, 367, 368, 373, 374, 375, -1, 377, 374, -1, 376, -1, 378, 383, 380, 381, 382, -1, -1, 0, 1531, -1, 1533, -1, -1, -1, -1, -1, -1, 261, 1541, -1, -1, -1, -1, -1, -1, -1, 1071, 1550, 1551, -1, 1553, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285, 424, -1, -1, -1, -1, -1, -1, 431, 432, -1, -1, -1, 298, 1578, -1, -1, 1581, 303, 438, -1, 306, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, 1130, -1, -1, 256, 257, 334, 1136, -1, 337, -1, 339, 264, 265, 266, 267, 268, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, 281, -1, -1, 0, -1, 286, 363, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, 374, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, 424, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, 374, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, -1, 428, -1, 430, 256, 257, -1, -1, -1, 0, -1, 438, 264, 265, 266, 267, 268, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, 256, -1, 367, 368, 369, 261, 262, -1, 373, 374, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, 285, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, 298, 299, -1, -1, -1, 303, 0, -1, 306, -1, 308, -1, 310, 311, 312, 313, 423, 424, 425, 426, 318, 428, -1, 430, 322, -1, -1, -1, 326, -1, -1, 438, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, -1, -1, -1, -1, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, 392, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, 261, 262, -1, -1, -1, -1, 419, -1, -1, 422, -1, 424, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, 285, 438, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, 299, -1, -1, -1, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, -1, -1, -1, -1, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, 392, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, 261, 262, -1, -1, -1, -1, 419, -1, -1, 422, -1, 424, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, 285, 438, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, 299, -1, -1, -1, 303, -1, -1, 306, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, 256, -1, -1, 395, 396, 261, 262, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 419, -1, 285, 422, -1, 424, -1, 426, -1, -1, 429, -1, -1, -1, -1, 298, 299, -1, -1, 438, 303, 0, -1, 306, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, 261, 262, -1, -1, -1, -1, 419, -1, -1, 422, -1, 424, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, 285, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, 299, -1, -1, -1, 303, -1, -1, 0, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, 0, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, 261, 262, -1, -1, -1, -1, 419, -1, -1, 422, -1, 424, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, 285, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, 299, -1, -1, -1, 303, -1, -1, 306, -1, 308, -1, 310, 311, 312, 313, -1, 0, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 340, -1, -1, -1, 344, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 373, 374, -1, 376, 377, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, 0, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, -1, -1, 257, -1, -1, -1, 261, -1, -1, -1, 419, -1, -1, 422, -1, 424, -1, 272, -1, -1, -1, -1, -1, 278, -1, -1, -1, 282, -1, 438, 285, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 297, 298, -1, -1, -1, 302, 303, -1, 261, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, 285, -1, -1, -1, -1, 334, -1, 336, 337, -1, 339, -1, -1, 298, 343, 257, -1, -1, 303, 261, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, 272, -1, 0, 318, 363, -1, 278, 322, -1, -1, 282, -1, -1, 285, -1, -1, 375, -1, -1, 334, -1, -1, 337, -1, 339, 297, 298, -1, -1, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, 363, -1, 322, -1, 324, -1, -1, 370, 371, -1, -1, 257, -1, -1, 334, 261, -1, 337, 0, 339, -1, -1, -1, 343, 431, 432, 272, -1, -1, -1, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, 363, -1, -1, -1, -1, -1, -1, -1, 297, 298, -1, 374, 375, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, 0, 337, -1, 339, 257, -1, -1, 343, 261, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, -1, 431, 432, -1, -1, 278, -1, 363, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, 374, 375, -1, -1, -1, 0, 297, 298, -1, 257, -1, 302, 303, 261, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, 272, -1, -1, 318, -1, -1, 278, 322, -1, 324, 282, -1, -1, 285, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 297, 298, -1, 343, -1, 302, 303, -1, 431, 432, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, 363, -1, 322, -1, 324, 0, -1, -1, -1, -1, -1, 257, 375, -1, 334, 261, -1, 337, -1, 339, -1, -1, -1, 343, -1, -1, 272, -1, -1, -1, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, 363, -1, -1, -1, -1, -1, -1, -1, 297, 298, -1, -1, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, 431, 432, -1, -1, 318, -1, -1, 257, 322, -1, 324, 261, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, 272, 337, -1, 339, -1, -1, 278, 343, -1, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, 431, 432, -1, -1, 297, 298, 363, -1, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, 257, -1, -1, -1, 261, 334, -1, -1, 337, -1, 339, -1, -1, -1, 343, 272, -1, -1, -1, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, 363, -1, -1, -1, 431, 432, 297, 298, -1, 257, -1, 302, 303, 261, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, 272, -1, -1, 318, -1, -1, 278, 322, -1, 324, 282, -1, -1, 285, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, 297, 298, -1, 343, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, 431, 432, 318, -1, 363, -1, 322, -1, 324, -1, -1, -1, -1, 257, -1, -1, -1, 261, 334, -1, -1, 337, -1, 339, -1, -1, -1, 343, 272, -1, -1, -1, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, 363, -1, -1, -1, -1, -1, 297, 298, -1, -1, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, 431, 432, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, -1, -1, 343, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 431, 432, -1, -1, 363, -1, -1, 256, -1, -1, -1, -1, -1, -1, -1, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, 431, 432, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, 256, -1, -1, -1, -1, -1, 262, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, 299, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, -1, -1, -1, 430, -1, 340, -1, -1, -1, -1, 345, 438, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, -1, -1, -1, -1, -1, 364, 365, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, -1, 256, -1, 424, 261, 426, 427, 262, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, -1, -1, 299, -1, 303, -1, -1, 306, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, 326, -1, -1, -1, -1, 262, -1, -1, 334, -1, -1, 337, -1, 339, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, -1, -1, 363, -1, -1, 364, 365, 299, 367, 368, -1, -1, -1, 374, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 256, 424, -1, 424, -1, 426, 262, -1, 429, -1, -1, 365, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, 377, 378, 379, 380, 381, -1, -1, 384, 385, -1, -1, 388, 389, 390, 391, 392, 393, 394, 395, 396, 299, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, -1, -1, -1, -1, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, -1, -1, -1, -1, -1, 364, 365, -1, 367, 368, -1, -1, -1, -1, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, -1, 424, 261, 426, 262, -1, 429, -1, -1, -1, -1, -1, -1, 272, -1, 438, -1, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 297, 298, -1, 299, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, 340, -1, 343, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, -1, -1, -1, 363, -1, 364, 365, -1, 367, 368, -1, -1, -1, -1, 374, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, 261, 424, -1, 426, 262, -1, 429, 431, 432, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, -1, -1, -1, 299, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, 316, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 256, -1, 363, -1, -1, -1, -1, 365, -1, 367, 368, -1, -1, 374, 375, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, -1, -1, -1, 426, 262, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, -1, -1, -1, -1, -1, 299, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 365, -1, 367, 368, -1, -1, -1, -1, 373, 374, 438, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, -1, -1, 261, 426, 262, -1, 429, -1, -1, -1, -1, -1, -1, 272, -1, 438, -1, -1, -1, 278, -1, -1, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 297, 298, -1, 299, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, 340, -1, 343, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 363, -1, -1, 365, -1, 367, 368, -1, -1, -1, -1, 374, 374, -1, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, 261, -1, 263, 426, 262, -1, 429, 431, 432, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, -1, -1, -1, 299, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, 363, -1, -1, -1, -1, 365, -1, 367, 368, -1, -1, 374, 375, -1, 374, -1, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, -1, -1, 261, 426, 262, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, -1, 299, -1, -1, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, 256, -1, 363, -1, -1, 365, -1, 367, 368, 370, 371, -1, -1, 374, 374, -1, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, -1, -1, -1, 426, 262, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, 299, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 256, -1, -1, -1, -1, -1, 262, -1, 396, -1, 266, -1, -1, 340, -1, -1, -1, -1, 345, 407, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 419, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, 299, -1, -1, -1, 374, -1, 376, 438, 378, -1, 380, 381, 382, -1, 384, 385, 315, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, -1, 419, -1, -1, -1, -1, -1, -1, -1, -1, -1, 358, -1, -1, -1, -1, -1, 364, 365, -1, 438, -1, -1, -1, -1, -1, -1, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, -1, 424, 261, 426, 262, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, -1, 299, -1, -1, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 256, -1, -1, -1, -1, -1, 262, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 363, -1, 364, 365, 299, 367, 368, 370, 371, -1, -1, 374, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 418, 419, -1, -1, -1, -1, 424, -1, 426, -1, -1, 429, -1, 364, 365, -1, -1, -1, -1, -1, 438, -1, -1, 374, 375, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, 387, 388, 389, 390, 391, -1, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, 256, -1, 261, 424, -1, 426, 262, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 298, -1, -1, -1, 299, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, 316, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, 363, -1, -1, -1, -1, 365, 256, 367, 368, -1, -1, 374, 262, -1, 374, -1, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, -1, 299, -1, -1, -1, -1, -1, -1, -1, -1, 418, 419, -1, -1, -1, -1, -1, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 365, 256, 367, 368, -1, -1, -1, 262, -1, 374, -1, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, -1, 299, -1, -1, -1, -1, -1, -1, -1, -1, 418, 419, -1, -1, -1, -1, -1, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 365, 256, 367, 368, -1, -1, -1, 262, -1, 374, -1, 376, 377, 378, 379, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, -1, 299, -1, -1, -1, -1, -1, -1, -1, -1, 418, 419, -1, -1, -1, -1, -1, -1, 426, -1, -1, 429, -1, -1, -1, -1, -1, -1, -1, -1, 438, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, 340, -1, 262, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, 364, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, 375, 376, -1, 378, 299, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, 256, -1, -1, -1, -1, -1, 262, -1, -1, -1, 419, 340, -1, -1, -1, 424, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 438, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, 299, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, 256, -1, -1, -1, 340, -1, 262, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, 364, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, 299, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, 256, -1, -1, -1, -1, -1, 262, -1, -1, -1, 419, 340, -1, -1, -1, 424, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 438, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, 299, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, 256, -1, -1, -1, 340, -1, 262, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, 299, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, 256, -1, -1, -1, -1, -1, 262, -1, -1, -1, 419, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 438, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, 299, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, 384, 385, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, 256, -1, 256, -1, -1, -1, -1, -1, 264, 265, 419, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, 438, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 360, 361, 362, 363, 364, 256, -1, 367, 368, 367, 368, -1, -1, -1, -1, -1, 374, 377, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 419, -1, 423, 424, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 437, 438, -1, 438, 256, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, 419, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 438, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, 400, 401, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, 419, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 438, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, 419, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 438, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, 419, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 438, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, 419, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, 438, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, 256, -1, -1, 395, 396, -1, 262, -1, -1, -1, 402, 403, 404, 405, 406, 407, -1, -1, -1, -1, -1, -1, -1, -1, 340, -1, -1, 419, -1, 345, -1, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, 299, -1, -1, 438, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, 388, 389, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 402, 403, 404, 405, 406, 407, 256, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 419, -1, -1, -1, -1, -1, 365, -1, -1, -1, -1, -1, -1, -1, -1, 374, -1, -1, 377, 438, 379, 380, -1, -1, -1, 384, 385, -1, -1, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 418, 419, -1, 256, -1, -1, -1, -1, 426, -1, -1, 429, -1, -1, 340, -1, -1, -1, -1, 345, 438, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, -1, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 256, -1, 404, 405, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 256, -1, 404, 405, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 256, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, 390, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 256, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 256, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, 391, -1, -1, -1, 395, 396, -1, -1, -1, -1, -1, 256, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, 391, -1, -1, -1, -1, 396, -1, -1, -1, -1, -1, 256, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 396, -1, -1, -1, -1, -1, 256, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 396, -1, -1, -1, -1, -1, -1, -1, -1, -1, 406, 407, -1, -1, -1, -1, -1, 340, -1, -1, -1, -1, 345, 419, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, -1, -1, -1, -1, -1, -1, -1, 438, -1, 367, 368, -1, -1, -1, -1, -1, 374, -1, 376, -1, 378, -1, 380, 381, 382, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, 396, -1, -1, 261, -1, -1, -1, 265, -1, 267, -1, 407, 270, -1, 272, 273, -1, 275, -1, -1, 278, -1, 280, 419, 282, 283, 284, 285, -1, -1, 288, 289, -1, 286, -1, -1, 294, -1, 296, 297, 298, -1, 438, 301, -1, 303, 299, 305, -1, -1, 308, -1, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, 262, -1, 322, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, 328, 334, 335, -1, 337, 338, 339, -1, -1, -1, 343, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 299, -1, -1, -1, -1, -1, 363, -1, -1, -1, -1, -1, -1, -1, -1, -1, 373, 374, 375, -1, 377, -1, -1, -1, -1, -1, 383, -1, -1, -1, -1, 383, 384, 385, 386, -1, 388, 389, 390, 391, 392, 393, 394, 395, -1, -1, 398, 399, 400, 401, 402, 403, 404, 405, -1, -1, -1, -1, -1, 358, -1, -1, -1, -1, -1, -1, 365, 424, -1, -1, -1, -1, -1, -1, 431, 432, 375, -1, 377, 378, 379, 380, -1, -1, -1, 384, 385, -1, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, -1, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, -1, -1, 256, -1, 424, -1, 426, -1, -1, 429, 264, 265, 266, 267, 268, -1, 270, 271, 438, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, 256, 428, -1, 430, -1, -1, -1, -1, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, 256, -1, -1, 430, -1, -1, -1, -1, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, 256, -1, -1, 430, -1, -1, -1, -1, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, 256, -1, -1, 430, -1, -1, -1, -1, 264, 265, 266, 267, -1, -1, 270, 271, -1, 273, 274, 275, 276, 277, 278, 279, 280, -1, -1, -1, -1, -1, 286, -1, 288, 289, 290, 291, 292, 293, -1, -1, 296, -1, -1, -1, 300, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 315, -1, 317, -1, 319, 320, -1, -1, 323, -1, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, -1, 338, -1, -1, 341, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, 307, -1, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, 380, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, 320, 321, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, 321, -1, 323, -1, -1, 326, 327, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, 374, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, 374, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, 307, -1, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, 382, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, 338, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, 374, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, 338, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, 423, 424, 425, 426, -1, 264, 265, 430, 267, -1, -1, 270, 271, -1, 256, -1, 275, 276, 277, 278, -1, 280, -1, 265, -1, 267, -1, 286, 270, -1, 289, -1, -1, 275, -1, -1, -1, 296, 280, -1, -1, -1, 301, -1, 303, 304, 305, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, 317, 301, 319, 320, -1, 305, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, 317, 335, 319, -1, -1, -1, 323, -1, 342, -1, -1, 345, 346, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, 377, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, 424, 280, 301, -1, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, 314, 335, -1, 317, -1, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, 374, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, -1, 286, 429, -1, 289, -1, -1, -1, -1, -1, 437, 296, -1, -1, -1, -1, 301, 424, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, 426, -1, -1, 429, 261, -1, 263, -1, 265, -1, 267, 437, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, -1, 280, -1, 282, 283, 284, 285, -1, -1, 288, 289, -1, -1, -1, -1, 294, 295, 296, 297, 298, -1, -1, 301, -1, 303, -1, 305, -1, 307, 308, -1, 310, 311, 312, 313, 314, -1, 316, 317, 318, 319, -1, -1, 322, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, 334, 335, -1, 337, 338, 339, -1, -1, -1, 343, -1, 261, -1, -1, -1, 265, -1, 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, 363, 280, -1, 282, 283, 284, 285, 370, 371, 288, 289, -1, -1, -1, 377, 294, -1, 296, 297, 298, -1, -1, 301, -1, 303, -1, 305, -1, -1, 308, -1, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, -1, -1, 322, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, 334, 335, -1, 337, 338, 339, 424, -1, -1, 343, -1, 261, -1, 431, 432, 265, -1, 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, 363, 280, -1, 282, 283, 284, 285, -1, -1, 288, 289, 374, -1, -1, 377, 294, -1, 296, 297, 298, 383, -1, 301, -1, 303, -1, 305, -1, -1, 308, -1, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, -1, -1, 322, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, 334, 335, -1, 337, 338, 339, 424, -1, -1, 343, -1, 261, -1, 431, 432, 265, -1, 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, 363, 280, -1, 282, 283, 284, 285, -1, -1, 288, 289, 374, -1, -1, 377, 294, -1, 296, 297, 298, 383, -1, 301, -1, 303, -1, 305, -1, -1, 308, -1, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, -1, -1, 322, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, 334, 335, -1, 337, 338, 339, 424, -1, -1, 343, -1, 261, -1, 431, 432, 265, -1, 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, 363, 280, -1, 282, 283, 284, 285, -1, -1, 288, 289, -1, -1, -1, 377, 294, -1, 296, 297, 298, 383, -1, 301, -1, 303, -1, 305, -1, -1, 308, -1, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, -1, -1, 322, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, 334, 335, -1, 337, 338, 339, 424, -1, -1, 343, -1, 261, -1, 431, 432, 265, -1, 267, -1, -1, 270, -1, 272, 273, -1, 275, -1, -1, 278, 363, 280, -1, 282, 283, 284, 285, -1, -1, 288, 289, 374, -1, -1, 377, 294, -1, 296, 297, 298, -1, -1, 301, -1, 303, -1, 305, -1, -1, 308, 261, 310, 311, 312, 313, 314, -1, -1, 317, 318, 319, 272, -1, 322, 323, 324, -1, 278, -1, -1, -1, 282, 331, 332, 285, 334, 335, -1, 337, 338, 339, 424, -1, -1, 343, -1, 297, 298, 431, 432, -1, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, 363, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, 374, -1, -1, 377, -1, -1, -1, -1, 334, -1, 336, 337, -1, 339, -1, -1, -1, 343, 261, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 272, -1, -1, -1, -1, -1, 278, -1, 363, -1, 282, -1, -1, 285, -1, -1, -1, -1, -1, 374, 375, 424, -1, -1, -1, 297, 298, -1, 431, 432, 302, 303, -1, -1, -1, -1, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, 324, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, 256, 337, -1, 339, -1, -1, 262, 343, 264, 265, -1, 267, 431, 432, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, 363, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, 374, 375, 296, -1, -1, 299, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, 344, -1, -1, -1, -1, -1, -1, 431, 432, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, 379, -1, -1, -1, 383, 384, 385, 386, 387, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, 262, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, 299, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, 344, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, 379, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, 262, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, 299, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, 379, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, 379, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, 256, -1, -1, 398, 399, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, 423, 424, 286, 426, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, 338, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, -1, -1, -1, -1, 377, -1, 263, -1, 265, -1, 267, 384, 385, 270, -1, 272, 273, -1, 275, 392, -1, 278, -1, 280, -1, 282, 283, 284, -1, -1, -1, 288, 289, -1, -1, -1, -1, 294, -1, 296, 297, -1, -1, -1, 301, -1, -1, -1, 305, -1, 423, 424, -1, 426, -1, -1, -1, 314, -1, 316, 317, -1, 319, -1, -1, -1, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, 256, -1, 335, -1, -1, 338, -1, -1, 264, 265, 343, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, 370, 371, -1, 296, -1, -1, -1, 377, 301, -1, 303, 304, 305, 383, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, 256, 326, -1, 328, -1, 330, 331, 332, 333, 265, 335, 267, -1, -1, 270, -1, -1, -1, -1, 275, -1, -1, 424, -1, 280, -1, -1, -1, -1, 431, 432, -1, -1, 289, -1, 360, 361, 362, 363, 364, 296, -1, 367, 368, -1, 301, -1, -1, -1, 305, -1, -1, 377, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, -1, -1, -1, 323, -1, 256, -1, -1, -1, -1, -1, 331, 332, -1, 265, 335, 267, -1, 338, 270, -1, -1, -1, -1, 275, -1, -1, -1, -1, 280, -1, -1, -1, -1, 423, 424, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, -1, -1, 305, -1, -1, 377, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, -1, -1, -1, 323, -1, -1, -1, -1, -1, -1, -1, 331, 332, -1, 265, 335, 267, -1, 338, 270, -1, 272, 273, -1, 275, -1, -1, 278, -1, 280, -1, 282, 283, 284, -1, 424, -1, 288, 289, -1, -1, -1, -1, 294, -1, 296, 297, -1, -1, -1, 301, -1, -1, -1, 305, -1, -1, 377, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, -1, -1, -1, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, 265, -1, 267, -1, 343, 270, -1, 272, 273, -1, 275, -1, -1, 278, -1, 280, 424, 282, 283, 284, -1, -1, -1, 288, 289, -1, -1, -1, -1, 294, -1, 296, 297, -1, -1, -1, 301, -1, 377, -1, 305, -1, -1, -1, 383, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, -1, -1, -1, 323, 324, -1, -1, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, -1, -1, -1, 343, -1, -1, -1, -1, 264, 265, 424, 267, -1, -1, 270, 271, -1, 431, 432, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, 265, 286, 267, -1, 289, 270, -1, -1, 377, -1, 275, 296, -1, -1, -1, 280, 301, -1, 303, 304, 305, -1, 307, -1, 289, -1, -1, -1, -1, 314, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, -1, 319, 424, -1, 342, 323, -1, 345, 346, 431, 432, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, 378, -1, 380, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, 376, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, 424, 303, 304, 305, -1, 307, -1, 289, -1, -1, -1, -1, 314, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, -1, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, 380, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, -1, 286, -1, 430, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, 424, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, 320, 321, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, -1, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, 338, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, 424, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, 338, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, 424, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, 314, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, -1, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, 424, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, -1, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, 424, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, -1, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, 373, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, 265, 286, 267, 430, 289, 270, -1, -1, -1, -1, 275, 296, -1, -1, -1, 280, 301, 424, 303, 304, 305, -1, -1, -1, 289, -1, -1, -1, -1, 314, -1, 296, 317, -1, 319, 320, 301, -1, 323, -1, 305, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, 317, -1, 319, -1, -1, 342, 323, -1, 345, 346, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, 377, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, -1, 286, -1, 430, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, 424, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, -1, 286, -1, 430, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, -1, 286, -1, 430, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, 423, 424, 425, 426, -1, 286, -1, 430, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, 342, -1, -1, 345, 346, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, 261, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, 285, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, -1, -1, 298, -1, -1, -1, -1, 303, -1, -1, 306, -1, 308, -1, 310, 311, 312, 313, 423, 424, 425, 426, 318, -1, -1, 430, 322, -1, -1, -1, 326, -1, -1, 264, 265, -1, 267, -1, 334, 270, 271, 337, -1, 339, 275, 276, 277, 278, -1, 280, -1, 265, -1, 267, -1, 286, 270, -1, 289, -1, -1, 275, 358, -1, -1, 296, 280, 363, -1, -1, 301, -1, 303, 304, 305, 289, -1, -1, 374, 375, -1, 377, 296, 379, -1, -1, 317, 301, 319, 320, -1, 305, 323, -1, -1, 326, 392, 328, -1, 330, 331, 332, 333, 317, 335, 319, -1, -1, -1, 323, -1, 342, -1, -1, 345, 346, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, -1, -1, 424, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, 364, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, 377, -1, -1, -1, 398, 399, -1, -1, -1, -1, -1, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, 423, 424, 425, 426, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, 424, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, 423, 424, 289, 426, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, 369, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, 383, 384, 385, 386, -1, -1, -1, 390, -1, 392, -1, -1, -1, -1, -1, 398, 399, 264, 265, -1, 267, -1, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, 423, 424, 289, 426, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, 338, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, -1, -1, -1, -1, 377, -1, -1, -1, -1, -1, -1, 384, 385, -1, -1, 264, 265, -1, 267, 392, -1, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, 423, 424, 301, 426, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, 313, -1, -1, -1, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, 338, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, -1, -1, -1, 264, 265, -1, 267, -1, 377, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, -1, -1, -1, -1, 286, -1, -1, 289, -1, -1, -1, -1, -1, -1, 296, -1, -1, -1, -1, 301, -1, 303, 304, 305, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 317, -1, 319, 320, -1, -1, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, -1, 335, -1, -1, 338, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, -1, -1, -1, 264, 265, -1, 267, -1, 377, 270, 271, -1, -1, -1, 275, 276, 277, 278, -1, 280, -1, 265, -1, 267, -1, 286, 270, -1, 289, -1, -1, 275, -1, -1, -1, 296, 280, -1, -1, -1, 301, -1, 303, 304, 305, 289, -1, -1, -1, -1, -1, -1, 296, -1, 423, 424, 317, 301, 319, 320, -1, 305, 323, -1, -1, 326, -1, 328, -1, 330, 331, 332, 333, 317, 335, 319, -1, 338, -1, 323, -1, -1, -1, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, -1, -1, -1, -1, 360, 361, 362, 363, 364, -1, -1, 367, 368, -1, -1, -1, -1, 265, -1, 267, -1, 377, 270, -1, -1, 273, -1, 275, -1, -1, 278, -1, 280, -1, 282, 283, 284, -1, 377, 378, 288, 289, -1, -1, -1, -1, 294, -1, 296, -1, -1, -1, -1, 301, -1, -1, -1, 305, -1, -1, -1, -1, -1, -1, -1, -1, 314, 423, 424, 317, -1, 319, -1, -1, -1, 323, -1, -1, -1, -1, -1, -1, -1, 331, 332, 424, -1, 335, -1, -1, 338, 265, -1, 267, -1, 343, 270, -1, -1, 273, -1, 275, -1, -1, 278, -1, 280, -1, 282, 283, 284, -1, -1, -1, 288, 289, -1, -1, -1, -1, 294, -1, 296, 265, -1, 267, -1, 301, 270, 377, -1, 305, -1, 275, -1, 383, -1, -1, 280, -1, 314, -1, -1, 317, -1, 319, -1, 289, -1, 323, -1, -1, -1, 295, 296, -1, -1, 331, 332, 301, -1, 335, -1, 305, 338, 307, -1, 309, -1, 343, -1, -1, 314, -1, -1, 317, 424, 319, -1, -1, -1, 323, -1, -1, 326, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, 265, -1, 267, -1, -1, 270, 377, -1, -1, -1, 275, -1, -1, -1, -1, 280, -1, -1, -1, -1, -1, -1, -1, -1, 289, -1, -1, -1, -1, -1, 295, 296, -1, -1, -1, -1, 301, -1, 377, 378, 305, -1, 307, -1, 309, -1, -1, -1, -1, 314, -1, -1, 317, 424, 319, -1, -1, -1, 323, -1, -1, 326, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, 265, -1, 267, -1, -1, 270, -1, -1, -1, -1, 275, 424, -1, -1, -1, 280, -1, -1, -1, -1, -1, -1, -1, -1, 289, -1, -1, -1, -1, -1, 295, 296, -1, -1, -1, -1, 301, 376, 377, -1, 305, -1, 307, -1, -1, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, -1, -1, -1, 323, -1, -1, 326, -1, -1, -1, -1, 331, 332, -1, -1, 335, -1, -1, 338, 265, -1, 267, -1, -1, 270, -1, -1, -1, -1, 275, 424, -1, -1, -1, 280, -1, -1, -1, -1, -1, -1, -1, -1, 289, 364, -1, -1, -1, -1, 295, 296, -1, -1, -1, -1, 301, -1, 377, -1, 305, -1, 307, -1, 309, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, -1, -1, -1, 323, -1, -1, 326, -1, -1, -1, -1, 331, 332, -1, 265, 335, 267, -1, 338, 270, -1, -1, -1, -1, 275, -1, -1, -1, -1, 280, 424, -1, -1, -1, -1, -1, -1, -1, 289, -1, -1, -1, -1, -1, 295, 296, -1, -1, -1, -1, 301, -1, -1, -1, 305, -1, 307, 377, 309, -1, -1, -1, -1, 314, -1, -1, 317, -1, 319, -1, -1, -1, 323, -1, -1, 326, -1, -1, -1, -1, 331, 332, -1, 265, 335, 267, -1, 338, 270, -1, 272, -1, -1, 275, -1, -1, -1, -1, 280, -1, -1, -1, -1, -1, 424, -1, -1, 289, -1, -1, 261, -1, 263, -1, 296, -1, -1, -1, -1, 301, -1, 303, -1, 305, -1, -1, 377, -1, -1, -1, -1, -1, -1, -1, 285, 317, -1, 319, -1, -1, -1, 323, 324, -1, -1, -1, -1, 298, -1, 331, 332, -1, 303, 335, -1, -1, 338, 308, -1, 310, 311, 312, 313, -1, -1, -1, -1, 318, 261, -1, -1, 322, -1, 424, -1, -1, -1, -1, -1, -1, -1, -1, -1, 334, -1, -1, 337, -1, 339, -1, -1, -1, 285, -1, -1, 377, -1, -1, 261, -1, -1, -1, -1, -1, -1, 298, -1, -1, -1, 302, 303, -1, 363, -1, -1, 308, -1, 310, 311, 312, 313, -1, 285, 374, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, 298, -1, -1, -1, -1, 303, 334, 424, -1, 337, 308, 339, 310, 311, 312, 313, -1, -1, -1, -1, 318, -1, -1, -1, 322, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 363, 334, -1, -1, 337, -1, 339, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 363 }; private Tokenizer lexer; public Tokenizer Lexer => lexer; public void yyerror(string message) { yyerror(message, null); } public void yyerror(string message, string[] expected) { if (yacc_verbose_flag > 0 && expected != null && expected.Length != 0) { ErrorOutput.Write(message + ", expecting"); for (int i = 0; i < expected.Length; i++) { ErrorOutput.Write(" " + expected[i]); } ErrorOutput.WriteLine(); } else { ErrorOutput.WriteLine(message); } } protected int[] yyExpectingTokens(int state) { int num = 0; bool[] array = new bool[yyNames.Length]; int num2; int i; if ((num2 = yySindex[state]) != 0) { for (i = ((num2 < 0) ? (-num2) : 0); i < yyNames.Length && num2 + i < yyTable.Length; i++) { if (yyCheck[num2 + i] == i && !array[i] && yyNames[i] != null) { num++; array[i] = true; } } } if ((num2 = yyRindex[state]) != 0) { for (i = ((num2 < 0) ? (-num2) : 0); i < yyNames.Length && num2 + i < yyTable.Length; i++) { if (yyCheck[num2 + i] == i && !array[i] && yyNames[i] != null) { num++; array[i] = true; } } } int[] array2 = new int[num]; num2 = (i = 0); while (num2 < num) { if (array[i]) { array2[num2++] = i; } i++; } return array2; } protected string[] yyExpecting(int state) { int[] array = yyExpectingTokens(state); string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i++] = yyNames[array[i]]; } return array2; } internal object yyparse(yyInput yyLex, object yyd) { return yyparse(yyLex); } protected object yyDefault(object first) { return first; } internal object yyparse(yyInput yyLex) { if (yyMax <= 0) { yyMax = 256; } int num = 0; yyVal = null; yyToken = -1; int num2 = 0; int[] array; if (use_global_stacks && global_yyStates != null) { yyVals = global_yyVals; array = global_yyStates; } else { yyVals = new object[yyMax]; array = new int[yyMax]; if (use_global_stacks) { global_yyVals = yyVals; global_yyStates = array; } } yyTop = 0; while (true) { if (yyTop >= array.Length) { Array.Resize(ref array, array.Length + yyMax); Array.Resize(ref yyVals, yyVals.Length + yyMax); } array[yyTop] = num; yyVals[yyTop] = yyVal; int num4; while (true) { int num3; if ((num3 = yyDefRed[num]) == 0) { if (yyToken < 0) { yyToken = (yyLex.advance() ? yyLex.token() : 0); } if ((num3 = yySindex[num]) != 0 && (num3 += yyToken) >= 0 && num3 < yyTable.Length && yyCheck[num3] == yyToken) { num = yyTable[num3]; yyVal = yyLex.value(); yyToken = -1; if (num2 > 0) { num4 = num2 - 1; num2 = num4; } break; } if ((num3 = yyRindex[num]) == 0 || (num3 += yyToken) < 0 || num3 >= yyTable.Length || yyCheck[num3] != yyToken) { switch (num2) { case 0: yyExpectingState = num; if (yyToken == 0 || yyToken == eof_token) { throw new yyUnexpectedEof(); } break; case 1: case 2: break; case 3: goto IL_02ee; default: goto IL_0316; } num2 = 3; while ((num3 = yySindex[array[yyTop]]) == 0 || (num3 += 256) < 0 || num3 >= yyTable.Length || yyCheck[num3] != 256) { if (--yyTop < 0) { throw new yyException("irrecoverable syntax error"); } } num = yyTable[num3]; yyVal = yyLex.value(); break; } num3 = yyTable[num3]; } goto IL_0316; IL_0316: int num5 = yyTop + 1 - yyLen[num3]; yyVal = ((num5 > yyTop) ? null : yyVals[num5]); switch (num3) { case 1: Lexer.check_incorrect_doc_comment(); break; case 2: Lexer.CompleteOnEOF = false; break; case 6: case_6(); break; case 7: case_7(); break; case 8: case_8(); break; case 13: case_13(); break; case 14: Error_SyntaxError(yyToken); break; case 17: case_17(); break; case 18: case_18(); break; case 19: case_19(); break; case 20: case_20(); break; case 23: case_23(); break; case 24: case_24(); break; case 25: case_25(); break; case 26: case_26(); break; case 29: case_29(); break; case 30: case_30(); break; case 31: case_31(); break; case 32: case_32(); break; case 45: case_45(); break; case 46: current_namespace.DeclarationFound = true; break; case 47: case_47(); break; case 55: case_55(); break; case 56: case_56(); break; case 57: case_57(); break; case 58: case_58(); break; case 59: case_59(); break; case 60: case_60(); break; case 61: case_61(); break; case 62: case_62(); break; case 63: case_63(); break; case 64: case_64(); break; case 65: yyVal = "event"; break; case 66: yyVal = "return"; break; case 67: yyVal = new List(4) { (Attribute)yyVals[yyTop] }; break; case 68: case_68(); break; case 69: { Tokenizer tokenizer = lexer; Tokenizer tokenizer11 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer11.parsing_block = num4; break; } case 70: case_70(); break; case 72: yyVal = null; break; case 73: yyVal = yyVals[-1 + yyTop]; break; case 74: yyVal = null; break; case 75: case_75(); break; case 76: case_76(); break; case 77: case_77(); break; case 78: case_78(); break; case 79: yyVal = new Argument((Expression)yyVals[yyTop]); break; case 81: case_81(); break; case 82: { Tokenizer tokenizer = lexer; Tokenizer tokenizer10 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer10.parsing_block = num4; break; } case 83: case_83(); break; case 84: case_84(); break; case 85: case_85(); break; case 89: yyVal = null; break; case 90: yyVal = Argument.AType.Ref; break; case 93: case_93(); break; case 94: case_94(); break; case 108: case_108(); break; case 109: case_109(); break; case 110: case_110(); break; case 111: yyVal = null; break; case 112: case_112(); break; case 113: case_113(); break; case 114: case_114(); break; case 115: case_115(); break; case 116: case_116(); break; case 117: case_117(); break; case 118: case_118(); break; case 119: Error_SyntaxError(yyToken); break; case 120: case_120(); break; case 121: case_121(); break; case 122: case_122(); break; case 125: current_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 126: current_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 127: case_127(); break; case 128: { Tokenizer tokenizer = lexer; Tokenizer tokenizer9 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer9.parsing_block = num4; break; } case 129: case_129(); break; case 130: case_130(); break; case 133: case_133(); break; case 134: case_134(); break; case 135: case_135(); break; case 136: case_136(); break; case 137: report.Error(1641, GetLocation(yyVals[-1 + yyTop]), "A fixed size buffer field must have the array size specifier after the field name"); break; case 139: case_139(); break; case 140: case_140(); break; case 143: current_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 144: current_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 145: case_145(); break; case 146: { Tokenizer tokenizer = lexer; Tokenizer tokenizer8 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer8.parsing_block = num4; break; } case 147: case_147(); break; case 150: current_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 151: current_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 152: case_152(); break; case 153: { Tokenizer tokenizer = lexer; Tokenizer tokenizer7 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer7.parsing_block = num4; break; } case 154: case_154(); break; case 155: case_155(); break; case 158: case_158(); break; case 159: case_159(); break; case 160: case_160(); break; case 161: yyVal = yyVals[yyTop]; break; case 162: lexer.parsing_generic_declaration = true; break; case 163: case_163(); break; case 164: lexer.parsing_generic_declaration = true; break; case 165: case_165(); break; case 166: valid_param_mod = ParameterModifierType.All; break; case 167: case_167(); break; case 168: case_168(); break; case 169: lexer.parsing_generic_declaration = true; break; case 170: case_170(); break; case 171: lexer.ConstraintsParsing = true; break; case 172: case_172(); break; case 173: case_173(); break; case 174: case_174(); break; case 177: yyVal = null; break; case 180: current_block = null; yyVal = null; break; case 181: case_181(); break; case 182: case_182(); break; case 183: case_183(); break; case 184: case_184(); break; case 185: yyVal = ParametersCompiled.EmptyReadOnlyParameters; break; case 187: case_187(); break; case 188: case_188(); break; case 189: case_189(); break; case 190: case_190(); break; case 191: case_191(); break; case 192: case_192(); break; case 193: case_193(); break; case 194: yyVal = new ParametersCompiled((Parameter)yyVals[yyTop]); break; case 195: yyVal = new ParametersCompiled(new Parameter[1] { new ArglistParameter(GetLocation(yyVals[yyTop])) }, has_arglist: true); break; case 196: case_196(); break; case 197: case_197(); break; case 198: case_198(); break; case 199: case_199(); break; case 200: case_200(); break; case 201: case_201(); break; case 202: case_202(); break; case 203: { Tokenizer tokenizer = lexer; Tokenizer tokenizer6 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer6.parsing_block = num4; break; } case 204: case_204(); break; case 205: yyVal = Parameter.Modifier.NONE; break; case 207: yyVal = yyVals[yyTop]; break; case 208: case_208(); break; case 209: case_209(); break; case 210: case_210(); break; case 211: case_211(); break; case 212: case_212(); break; case 213: case_213(); break; case 214: case_214(); break; case 215: case_215(); break; case 216: case_216(); break; case 217: case_217(); break; case 218: Error_DuplicateParameterModifier(GetLocation(yyVals[-1 + yyTop]), Parameter.Modifier.PARAMS); break; case 219: case_219(); break; case 220: case_220(); break; case 221: case_221(); break; case 222: case_222(); break; case 223: case_223(); break; case 224: current_property = null; break; case 225: case_225(); break; case 226: case_226(); break; case 228: case_228(); break; case 229: case_229(); break; case 232: valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue | ParameterModifierType.ReadOnly; break; case 233: case_233(); break; case 234: case_234(); break; case 236: case_236(); break; case 241: case_241(); break; case 242: case_242(); break; case 243: case_243(); break; case 244: case_244(); break; case 245: case_245(); break; case 248: case_248(); break; case 249: case_249(); break; case 251: case_251(); break; case 252: case_252(); break; case 253: case_253(); break; case 254: case_254(); break; case 255: Error_SyntaxError(yyToken); break; case 258: case_258(); break; case 259: case_259(); break; case 260: report.Error(525, GetLocation(yyVals[yyTop]), "Interfaces cannot contain fields or constants"); break; case 261: report.Error(525, GetLocation(yyVals[yyTop]), "Interfaces cannot contain fields or constants"); break; case 266: report.Error(567, GetLocation(yyVals[yyTop]), "Interfaces cannot contain operators"); break; case 267: report.Error(526, GetLocation(yyVals[yyTop]), "Interfaces cannot contain contructors"); break; case 268: report.Error(524, GetLocation(yyVals[yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations"); break; case 270: case_270(); break; case 272: case_272(); break; case 273: case_273(); break; case 274: case_274(); break; case 276: yyVal = Operator.OpType.LogicalNot; break; case 277: yyVal = Operator.OpType.OnesComplement; break; case 278: yyVal = Operator.OpType.Increment; break; case 279: yyVal = Operator.OpType.Decrement; break; case 280: yyVal = Operator.OpType.True; break; case 281: yyVal = Operator.OpType.False; break; case 282: yyVal = Operator.OpType.Addition; break; case 283: yyVal = Operator.OpType.Subtraction; break; case 284: yyVal = Operator.OpType.Multiply; break; case 285: yyVal = Operator.OpType.Division; break; case 286: yyVal = Operator.OpType.Modulus; break; case 287: yyVal = Operator.OpType.BitwiseAnd; break; case 288: yyVal = Operator.OpType.BitwiseOr; break; case 289: yyVal = Operator.OpType.ExclusiveOr; break; case 290: yyVal = Operator.OpType.LeftShift; break; case 291: yyVal = Operator.OpType.RightShift; break; case 292: yyVal = Operator.OpType.Equality; break; case 293: yyVal = Operator.OpType.Inequality; break; case 294: yyVal = Operator.OpType.GreaterThan; break; case 295: yyVal = Operator.OpType.LessThan; break; case 296: yyVal = Operator.OpType.GreaterThanOrEqual; break; case 297: yyVal = Operator.OpType.LessThanOrEqual; break; case 298: case_298(); break; case 299: valid_param_mod = ParameterModifierType.DefaultValue | ParameterModifierType.ReadOnly; break; case 300: case_300(); break; case 301: valid_param_mod = ParameterModifierType.DefaultValue | ParameterModifierType.ReadOnly; break; case 302: case_302(); break; case 303: case_303(); break; case 304: case_304(); break; case 305: case_305(); break; case 306: case_306(); break; case 307: case_307(); break; case 308: case_308(); break; case 311: { Tokenizer tokenizer = lexer; Tokenizer tokenizer5 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer5.parsing_block = num4; break; } case 312: case_312(); break; case 313: { Tokenizer tokenizer = lexer; Tokenizer tokenizer4 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer4.parsing_block = num4; break; } case 314: case_314(); break; case 315: case_315(); break; case 316: case_316(); break; case 317: case_317(); break; case 318: case_318(); break; case 319: case_319(); break; case 320: case_320(); break; case 321: case_321(); break; case 322: case_322(); break; case 323: case_323(); break; case 324: case_324(); break; case 326: { Tokenizer tokenizer = lexer; Tokenizer tokenizer3 = tokenizer; num4 = tokenizer.parsing_block + 1; tokenizer3.parsing_block = num4; break; } case 327: case_327(); break; case 330: current_event_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 331: current_event_field.AddDeclarator((FieldDeclarator)yyVals[yyTop]); break; case 332: case_332(); break; case 333: case_333(); break; case 334: case_334(); break; case 335: case_335(); break; case 338: case_338(); break; case 339: case_339(); break; case 340: case_340(); break; case 341: case_341(); break; case 342: case_342(); break; case 343: case_343(); break; case 344: case_344(); break; case 345: case_345(); break; case 348: case_348(); break; case 349: case_349(); break; case 350: case_350(); break; case 351: case_351(); break; case 352: case_352(); break; case 353: case_353(); break; case 355: yyVal = yyVals[yyTop]; break; case 356: case_356(); break; case 361: case_361(); break; case 362: case_362(); break; case 363: case_363(); break; case 364: case_364(); break; case 365: case_365(); break; case 367: valid_param_mod = ParameterModifierType.PrimaryConstructor | ParameterModifierType.ReadOnly; break; case 368: case_368(); break; case 369: lexer.ConstraintsParsing = false; break; case 370: case_370(); break; case 372: case_372(); break; case 374: case_374(); break; case 375: case_375(); break; case 377: case_377(); break; case 378: case_378(); break; case 379: case_379(); break; case 380: case_380(); break; case 382: case_382(); break; case 383: case_383(); break; case 384: case_384(); break; case 385: case_385(); break; case 386: lexer.parsing_generic_declaration = true; break; case 387: case_387(); break; case 388: case_388(); break; case 390: case_390(); break; case 391: case_391(); break; case 392: case_392(); break; case 393: case_393(); break; case 394: case_394(); break; case 395: case_395(); break; case 397: case_397(); break; case 398: case_398(); break; case 399: case_399(); break; case 400: case_400(); break; case 401: case_401(); break; case 403: yyVal = new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[yyTop])); break; case 404: lexer.parsing_generic_declaration = true; break; case 410: case_410(); break; case 412: yyVal = new ComposedCast((FullNamedExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); break; case 413: case_413(); break; case 414: yyVal = new ComposedCast((ATypeNameExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); break; case 416: case_416(); break; case 417: case_417(); break; case 418: case_418(); break; case 422: case_422(); break; case 423: case_423(); break; case 424: yyVal = new ComposedCast((FullNamedExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); break; case 425: yyVal = new ComposedCast(new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[-1 + yyTop])), (ComposedTypeSpecifier)yyVals[yyTop]); break; case 426: case_426(); break; case 427: case_427(); break; case 428: case_428(); break; case 429: yyVal = new TypeExpression(compiler.BuiltinTypes.Object, GetLocation(yyVals[yyTop])); break; case 430: yyVal = new TypeExpression(compiler.BuiltinTypes.String, GetLocation(yyVals[yyTop])); break; case 431: yyVal = new TypeExpression(compiler.BuiltinTypes.Bool, GetLocation(yyVals[yyTop])); break; case 432: yyVal = new TypeExpression(compiler.BuiltinTypes.Decimal, GetLocation(yyVals[yyTop])); break; case 433: yyVal = new TypeExpression(compiler.BuiltinTypes.Float, GetLocation(yyVals[yyTop])); break; case 434: yyVal = new TypeExpression(compiler.BuiltinTypes.Double, GetLocation(yyVals[yyTop])); break; case 436: yyVal = new TypeExpression(compiler.BuiltinTypes.SByte, GetLocation(yyVals[yyTop])); break; case 437: yyVal = new TypeExpression(compiler.BuiltinTypes.Byte, GetLocation(yyVals[yyTop])); break; case 438: yyVal = new TypeExpression(compiler.BuiltinTypes.Short, GetLocation(yyVals[yyTop])); break; case 439: yyVal = new TypeExpression(compiler.BuiltinTypes.UShort, GetLocation(yyVals[yyTop])); break; case 440: yyVal = new TypeExpression(compiler.BuiltinTypes.Int, GetLocation(yyVals[yyTop])); break; case 441: yyVal = new TypeExpression(compiler.BuiltinTypes.UInt, GetLocation(yyVals[yyTop])); break; case 442: yyVal = new TypeExpression(compiler.BuiltinTypes.Long, GetLocation(yyVals[yyTop])); break; case 443: yyVal = new TypeExpression(compiler.BuiltinTypes.ULong, GetLocation(yyVals[yyTop])); break; case 444: yyVal = new TypeExpression(compiler.BuiltinTypes.Char, GetLocation(yyVals[yyTop])); break; case 468: case_468(); break; case 473: yyVal = new NullLiteral(GetLocation(yyVals[yyTop])); break; case 474: yyVal = new BoolLiteral(compiler.BuiltinTypes, val: true, GetLocation(yyVals[yyTop])); break; case 475: yyVal = new BoolLiteral(compiler.BuiltinTypes, val: false, GetLocation(yyVals[yyTop])); break; case 476: case_476(); break; case 477: case_477(); break; case 478: case_478(); break; case 479: yyVal = new TupleLiteralElement((Expression)yyVals[yyTop]); break; case 480: case_480(); break; case 481: case_481(); break; case 482: case_482(); break; case 483: case_483(); break; case 484: case_484(); break; case 485: yyVal = new InterpolatedStringInsert((Expression)yyVals[yyTop]); break; case 486: case_486(); break; case 487: lexer.parsing_interpolation_format = true; break; case 488: case_488(); break; case 489: lexer.parsing_interpolation_format = true; break; case 490: case_490(); break; case 495: case_495(); break; case 496: yyVal = new ParenthesizedExpression((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); break; case 497: case_497(); break; case 498: case_498(); break; case 499: case_499(); break; case 500: case_500(); break; case 501: case_501(); break; case 502: case_502(); break; case 503: case_503(); break; case 504: case_504(); break; case 505: yyVal = new CompletionMemberAccess((Expression)yyVals[-2 + yyTop], null, GetLocation(yyVals[yyTop])); break; case 506: case_506(); break; case 507: yyVal = new CompletionMemberAccess((Expression)yyVals[-2 + yyTop], null, lexer.Location); break; case 508: case_508(); break; case 509: case_509(); break; case 510: case_510(); break; case 511: case_511(); break; case 512: yyVal = null; break; case 514: case_514(); break; case 515: case_515(); break; case 516: yyVal = null; break; case 517: yyVal = yyVals[yyTop]; break; case 518: case_518(); break; case 519: case_519(); break; case 520: case_520(); break; case 521: case_521(); break; case 522: case_522(); break; case 523: yyVal = new CompletionElementInitializer(null, GetLocation(yyVals[yyTop])); break; case 524: case_524(); break; case 525: case_525(); break; case 526: case_526(); break; case 527: case_527(); break; case 530: yyVal = null; break; case 532: case_532(); break; case 533: case_533(); break; case 534: case_534(); break; case 535: case_535(); break; case 536: case_536(); break; case 537: yyVal = new Argument((Expression)yyVals[yyTop]); break; case 541: case_541(); break; case 542: case_542(); break; case 543: yyVal = new Argument((Expression)yyVals[yyTop], Argument.AType.Out); break; case 544: case_544(); break; case 545: case_545(); break; case 546: case_546(); break; case 548: case_548(); break; case 549: case_549(); break; case 550: case_550(); break; case 551: case_551(); break; case 552: case_552(); break; case 553: case_553(); break; case 554: case_554(); break; case 555: case_555(); break; case 556: yyVal = new Argument((Expression)yyVals[yyTop]); break; case 558: yyVal = new This(GetLocation(yyVals[yyTop])); break; case 559: case_559(); break; case 560: case_560(); break; case 561: yyVal = new UnaryMutator(UnaryMutator.Mode.IsPost, (Expression)yyVals[-1 + yyTop], GetLocation(yyVals[yyTop])); break; case 562: yyVal = new UnaryMutator(UnaryMutator.Mode.PostDecrement, (Expression)yyVals[-1 + yyTop], GetLocation(yyVals[yyTop])); break; case 563: case_563(); break; case 564: case_564(); break; case 565: case_565(); break; case 566: case_566(); break; case 567: case_567(); break; case 568: case_568(); break; case 569: case_569(); break; case 570: { Tokenizer tokenizer = lexer; Tokenizer tokenizer2 = tokenizer; num4 = tokenizer.parsing_type + 1; tokenizer2.parsing_type = num4; break; } case 571: case_571(); break; case 572: case_572(); break; case 573: yyVal = new EmptyCompletion(); break; case 576: yyVal = null; break; case 578: case_578(); break; case 579: case_579(); break; case 580: yyVal = new EmptyCompletion(); break; case 581: yyVal = yyVals[-1 + yyTop]; break; case 582: case_582(); break; case 583: case_583(); break; case 584: case_584(); break; case 585: case_585(); break; case 589: case_589(); break; case 590: case_590(); break; case 591: case_591(); break; case 592: yyVal = 2; break; case 593: yyVal = (int)yyVals[-1 + yyTop] + 1; break; case 594: yyVal = null; break; case 595: yyVal = yyVals[yyTop]; break; case 596: case_596(); break; case 597: case_597(); break; case 598: case_598(); break; case 599: case_599(); break; case 600: case_600(); break; case 602: case_602(); break; case 603: case_603(); break; case 604: case_604(); break; case 605: case_605(); break; case 606: case_606(); break; case 607: case_607(); break; case 608: case_608(); break; case 609: case_609(); break; case 610: case_610(); break; case 611: case_611(); break; case 612: start_anonymous(isLambda: false, (ParametersCompiled)yyVals[yyTop], isAsync: false, GetLocation(yyVals[-1 + yyTop])); break; case 613: yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); break; case 614: start_anonymous(isLambda: false, (ParametersCompiled)yyVals[yyTop], isAsync: true, GetLocation(yyVals[-2 + yyTop])); break; case 615: yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); break; case 616: yyVal = ParametersCompiled.Undefined; break; case 618: valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.ReadOnly; break; case 619: case_619(); break; case 620: case_620(); break; case 621: case_621(); break; case 623: yyVal = new Unary(Unary.Operator.LogicalNot, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 624: yyVal = new Unary(Unary.Operator.OnesComplement, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 625: case_625(); break; case 626: case_626(); break; case 627: case_627(); break; case 628: case_628(); break; case 629: case_629(); break; case 630: case_630(); break; case 631: case_631(); break; case 633: yyVal = new Unary(Unary.Operator.UnaryPlus, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 634: yyVal = new Unary(Unary.Operator.UnaryNegation, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 635: yyVal = new UnaryMutator(UnaryMutator.Mode.IsIncrement, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 636: yyVal = new UnaryMutator(UnaryMutator.Mode.IsDecrement, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 637: yyVal = new Indirection((Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 638: yyVal = new Unary(Unary.Operator.AddressOf, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 639: case_639(); break; case 640: case_640(); break; case 641: case_641(); break; case 642: case_642(); break; case 643: case_643(); break; case 644: case_644(); break; case 646: case_646(); break; case 647: case_647(); break; case 648: case_648(); break; case 649: case_649(); break; case 650: case_650(); break; case 651: case_651(); break; case 653: case_653(); break; case 654: case_654(); break; case 655: case_655(); break; case 656: case_656(); break; case 657: yyVal = new As((Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 658: case_658(); break; case 659: case_659(); break; case 660: case_660(); break; case 661: case_661(); break; case 662: case_662(); break; case 663: case_663(); break; case 666: yyVal = new Unary(Unary.Operator.UnaryPlus, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 667: yyVal = new Unary(Unary.Operator.UnaryNegation, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 670: case_670(); break; case 671: yyVal = new WildcardPattern(GetLocation(yyVals[yyTop])); break; case 673: yyVal = new PropertyPattern((ATypeNameExpression)yyVals[-3 + yyTop], (List)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); break; case 674: case_674(); break; case 675: case_675(); break; case 676: case_676(); break; case 678: case_678(); break; case 680: case_680(); break; case 681: case_681(); break; case 682: case_682(); break; case 683: case_683(); break; case 685: case_685(); break; case 686: case_686(); break; case 687: case_687(); break; case 688: case_688(); break; case 689: case_689(); break; case 690: case_690(); break; case 691: case_691(); break; case 692: case_692(); break; case 694: case_694(); break; case 695: case_695(); break; case 696: case_696(); break; case 697: case_697(); break; case 699: case_699(); break; case 700: case_700(); break; case 702: case_702(); break; case 703: case_703(); break; case 705: case_705(); break; case 706: case_706(); break; case 708: case_708(); break; case 709: case_709(); break; case 711: case_711(); break; case 712: case_712(); break; case 714: case_714(); break; case 718: case_718(); break; case 719: case_719(); break; case 720: case_720(); break; case 721: case_721(); break; case 722: case_722(); break; case 723: case_723(); break; case 724: case_724(); break; case 725: case_725(); break; case 726: case_726(); break; case 727: case_727(); break; case 728: case_728(); break; case 729: case_729(); break; case 730: case_730(); break; case 731: case_731(); break; case 732: case_732(); break; case 733: case_733(); break; case 734: case_734(); break; case 735: case_735(); break; case 736: case_736(); break; case 737: case_737(); break; case 738: case_738(); break; case 739: case_739(); break; case 740: case_740(); break; case 741: case_741(); break; case 742: case_742(); break; case 743: case_743(); break; case 744: case_744(); break; case 745: case_745(); break; case 746: case_746(); break; case 747: case_747(); break; case 748: yyVal = ParametersCompiled.EmptyReadOnlyParameters; break; case 749: case_749(); break; case 750: start_block(Location.Null); break; case 751: case_751(); break; case 753: case_753(); break; case 757: case_757(); break; case 758: case_758(); break; case 759: case_759(); break; case 760: case_760(); break; case 761: case_761(); break; case 762: case_762(); break; case 763: case_763(); break; case 764: valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.ReadOnly; break; case 765: case_765(); break; case 766: case_766(); break; case 767: valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.ReadOnly; break; case 768: case_768(); break; case 769: case_769(); break; case 775: yyVal = new ArglistAccess(GetLocation(yyVals[yyTop])); break; case 776: case_776(); break; case 777: case_777(); break; case 778: case_778(); break; case 780: yyVal = new BooleanExpression((Expression)yyVals[yyTop]); break; case 781: yyVal = null; break; case 783: case_783(); break; case 784: yyVal = null; break; case 785: yyVal = null; break; case 786: yyVal = yyVals[yyTop]; break; case 787: yyVal = yyVals[-1 + yyTop]; break; case 788: case_788(); break; case 789: case_789(); break; case 791: case_791(); break; case 792: case_792(); break; case 793: case_793(); break; case 794: case_794(); break; case 795: yyVal = null; break; case 796: yyVal = yyVals[yyTop]; break; case 797: case_797(); break; case 798: lexer.parsing_modifiers = false; break; case 800: case_800(); break; case 801: case_801(); break; case 802: case_802(); break; case 803: case_803(); break; case 804: case_804(); break; case 805: case_805(); break; case 806: case_806(); break; case 807: case_807(); break; case 808: case_808(); break; case 809: case_809(); break; case 810: case_810(); break; case 811: case_811(); break; case 812: case_812(); break; case 813: case_813(); break; case 814: case_814(); break; case 815: case_815(); break; case 818: current_type.SetBaseTypes((List)yyVals[yyTop]); break; case 819: case_819(); break; case 821: yyVal = yyVals[yyTop]; break; case 822: case_822(); break; case 823: case_823(); break; case 824: case_824(); break; case 825: case_825(); break; case 826: case_826(); break; case 827: case_827(); break; case 828: case_828(); break; case 829: case_829(); break; case 830: yyVal = new SpecialContraintExpr(SpecialConstraint.Class, GetLocation(yyVals[yyTop])); break; case 831: yyVal = new SpecialContraintExpr(SpecialConstraint.Struct, GetLocation(yyVals[yyTop])); break; case 832: yyVal = null; break; case 833: case_833(); break; case 834: yyVal = new VarianceDecl(Variance.Covariant, GetLocation(yyVals[yyTop])); break; case 835: yyVal = new VarianceDecl(Variance.Contravariant, GetLocation(yyVals[yyTop])); break; case 836: case_836(); break; case 837: yyVal = yyVals[yyTop]; break; case 838: case_838(); break; case 839: case_839(); break; case 840: case_840(); break; case 841: case_841(); break; case 846: current_block.AddStatement((Statement)yyVals[yyTop]); break; case 847: current_block.AddStatement((Statement)yyVals[yyTop]); break; case 849: case_849(); break; case 852: current_block.AddStatement((Statement)yyVals[yyTop]); break; case 853: current_block.AddStatement((Statement)yyVals[yyTop]); break; case 882: case_882(); break; case 883: case_883(); break; case 884: case_884(); break; case 885: case_885(); break; case 886: case_886(); break; case 889: case_889(); break; case 890: case_890(); break; case 891: case_891(); break; case 893: case_893(); break; case 895: case_895(); break; case 896: case_896(); break; case 897: case_897(); break; case 899: case_899(); break; case 900: yyVal = ComposedTypeSpecifier.CreatePointer(GetLocation(yyVals[yyTop])); break; case 902: yyVal = Error_AwaitAsIdentifier(yyVals[yyTop]); break; case 903: case_903(); break; case 904: case_904(); break; case 905: case_905(); break; case 906: case_906(); break; case 907: case_907(); break; case 908: case_908(); break; case 909: case_909(); break; case 910: case_910(); break; case 912: case_912(); break; case 913: case_913(); break; case 917: case_917(); break; case 920: case_920(); break; case 921: case_921(); break; case 922: report.Error(145, lexer.Location, "A const field requires a value to be provided"); break; case 923: current_variable.Initializer = (Expression)yyVals[yyTop]; break; case 928: case_928(); break; case 930: case_930(); break; case 931: case_931(); break; case 933: case_933(); break; case 934: case_934(); break; case 935: case_935(); break; case 936: case_936(); break; case 937: yyVal = yyVals[-1 + yyTop]; break; case 938: case_938(); break; case 939: yyVal = yyVals[-1 + yyTop]; break; case 940: yyVal = yyVals[-1 + yyTop]; break; case 941: case_941(); break; case 942: case_942(); break; case 943: case_943(); break; case 946: case_946(); break; case 947: case_947(); break; case 948: case_948(); break; case 949: start_block(GetLocation(yyVals[yyTop])); break; case 950: case_950(); break; case 951: case_951(); break; case 952: report.Warning(1522, 1, current_block.StartLocation, "Empty switch block"); break; case 956: Error_SyntaxError(yyToken); break; case 958: case_958(); break; case 959: current_block.AddStatement((Statement)yyVals[yyTop]); break; case 960: case_960(); break; case 961: case_961(); break; case 962: case_962(); break; case 963: yyVal = new SwitchLabel(null, GetLocation(yyVals[yyTop])); break; case 968: case_968(); break; case 969: case_969(); break; case 970: case_970(); break; case 971: case_971(); break; case 972: case_972(); break; case 973: case_973(); break; case 974: yyVal = yyVals[yyTop]; break; case 975: case_975(); break; case 976: case_976(); break; case 977: case_977(); break; case 978: case_978(); break; case 979: yyVal = new Tuple(GetLocation(yyVals[-2 + yyTop]), (Location)yyVals[yyTop]); break; case 980: case_980(); break; case 981: case_981(); break; case 982: case_982(); break; case 984: lexer.putback(125); break; case 985: yyVal = new EmptyStatement(lexer.Location); break; case 987: case_987(); break; case 988: case_988(); break; case 990: yyVal = null; break; case 992: yyVal = new EmptyStatement(lexer.Location); break; case 996: case_996(); break; case 997: case_997(); break; case 998: case_998(); break; case 999: case_999(); break; case 1000: case_1000(); break; case 1007: case_1007(); break; case 1008: case_1008(); break; case 1009: case_1009(); break; case 1010: case_1010(); break; case 1011: case_1011(); break; case 1012: case_1012(); break; case 1013: case_1013(); break; case 1014: case_1014(); break; case 1015: case_1015(); break; case 1016: case_1016(); break; case 1017: case_1017(); break; case 1018: case_1018(); break; case 1019: case_1019(); break; case 1020: case_1020(); break; case 1021: case_1021(); break; case 1022: case_1022(); break; case 1023: case_1023(); break; case 1026: yyVal = new TryCatch((Block)yyVals[-1 + yyTop], (List)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop]), inside_try_finally: false); break; case 1027: case_1027(); break; case 1028: case_1028(); break; case 1029: case_1029(); break; case 1030: case_1030(); break; case 1031: case_1031(); break; case 1034: case_1034(); break; case 1035: case_1035(); break; case 1036: case_1036(); break; case 1037: case_1037(); break; case 1038: yyVal = yyVals[-1 + yyTop]; break; case 1039: case_1039(); break; case 1040: lexer.parsing_catch_when = false; break; case 1041: lexer.parsing_catch_when = false; break; case 1042: case_1042(); break; case 1043: yyVal = new Checked((Block)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 1044: yyVal = new Unchecked((Block)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); break; case 1045: case_1045(); break; case 1046: yyVal = new Unsafe((Block)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); break; case 1047: case_1047(); break; case 1048: case_1048(); break; case 1049: case_1049(); break; case 1050: case_1050(); break; case 1051: case_1051(); break; case 1052: case_1052(); break; case 1053: case_1053(); break; case 1054: case_1054(); break; case 1055: case_1055(); break; case 1056: case_1056(); break; case 1058: case_1058(); break; case 1059: Error_MissingInitializer(lexer.Location); break; case 1060: case_1060(); break; case 1061: case_1061(); break; case 1062: case_1062(); break; case 1063: case_1063(); break; case 1064: case_1064(); break; case 1065: case_1065(); break; case 1066: case_1066(); break; case 1067: case_1067(); break; case 1068: case_1068(); break; case 1069: current_block = new QueryBlock(current_block, lexer.Location); break; case 1070: case_1070(); break; case 1071: current_block = new QueryBlock(current_block, lexer.Location); break; case 1072: case_1072(); break; case 1073: case_1073(); break; case 1074: case_1074(); break; case 1076: case_1076(); break; case 1077: case_1077(); break; case 1078: current_block = new QueryBlock(current_block, lexer.Location); break; case 1079: case_1079(); break; case 1080: case_1080(); break; case 1081: case_1081(); break; case 1082: case_1082(); break; case 1083: yyVal = new object[2] { yyVals[yyTop], GetLocation(yyVals[-1 + yyTop]) }; break; case 1084: case_1084(); break; case 1086: case_1086(); break; case 1092: current_block = new QueryBlock(current_block, lexer.Location); break; case 1093: case_1093(); break; case 1094: current_block = new QueryBlock(current_block, lexer.Location); break; case 1095: case_1095(); break; case 1096: case_1096(); break; case 1097: case_1097(); break; case 1098: case_1098(); break; case 1099: case_1099(); break; case 1100: case_1100(); break; case 1101: case_1101(); break; case 1102: case_1102(); break; case 1103: case_1103(); break; case 1105: yyVal = yyVals[yyTop]; break; case 1106: current_block = new QueryBlock(current_block, lexer.Location); break; case 1107: case_1107(); break; case 1109: case_1109(); break; case 1110: case_1110(); break; case 1112: case_1112(); break; case 1113: case_1113(); break; case 1114: yyVal = new OrderByAscending((QueryBlock)current_block, (Expression)yyVals[yyTop]); break; case 1115: case_1115(); break; case 1116: case_1116(); break; case 1117: yyVal = new ThenByAscending((QueryBlock)current_block, (Expression)yyVals[yyTop]); break; case 1118: case_1118(); break; case 1119: case_1119(); break; case 1121: case_1121(); break; case 1122: case_1122(); break; case 1125: case_1125(); break; case 1126: case_1126(); break; case 1134: module.DocumentationBuilder.ParsedName = (MemberName)yyVals[yyTop]; break; case 1135: module.DocumentationBuilder.ParsedParameters = (List)yyVals[yyTop]; break; case 1136: case_1136(); break; case 1137: case_1137(); break; case 1138: case_1138(); break; case 1139: yyVal = new MemberName((MemberName)yyVals[-2 + yyTop], MemberCache.IndexerNameAlias, Location.Null); break; case 1140: valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.ReadOnly; break; case 1141: case_1141(); break; case 1142: case_1142(); break; case 1143: case_1143(); break; case 1144: case_1144(); break; case 1146: yyVal = new MemberName((MemberName)yyVals[-2 + yyTop], (MemberName)yyVals[yyTop]); break; case 1148: valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.ReadOnly; break; case 1149: yyVal = yyVals[-1 + yyTop]; break; case 1150: yyVal = new List(0); break; case 1152: case_1152(); break; case 1153: case_1153(); break; case 1154: case_1154(); break; } yyTop -= yyLen[num3]; num = array[yyTop]; int num6 = yyLhs[num3]; if (num == 0 && num6 == 0) { num = 7; if (yyToken < 0) { yyToken = (yyLex.advance() ? yyLex.token() : 0); } if (yyToken == 0) { return yyVal; } break; } num = (((num3 = yyGindex[num6]) == 0 || (num3 += num) < 0 || num3 >= yyTable.Length || yyCheck[num3] != num) ? yyDgoto[num6] : yyTable[num3]); break; IL_02ee: if (yyToken == 0) { throw new yyException("irrecoverable syntax error at end-of-file"); } yyToken = -1; } num4 = yyTop + 1; yyTop = num4; } } private void case_6() { if (yyVals[yyTop] != null) { Attributes attributes = (Attributes)yyVals[yyTop]; report.Error(1730, attributes.Attrs[0].Location, "Assembly and module attributes must precede all other elements except using clauses and extern alias declarations"); current_namespace.UnattachedAttributes = attributes; } } private void case_7() { Attributes attributes = (Attributes)yyVals[yyTop]; if (attributes != null) { foreach (Attribute attr in attributes.Attrs) { if (!(attr.ExplicitTarget == "assembly") && !(attr.ExplicitTarget == "module") && attr.ExplicitTarget == null) { report.Error(-1671, attr.Location, "Global attributes must have attribute target specified"); } } } module.AddAttributes((Attributes)yyVals[yyTop], current_namespace); } private void case_8() { if (yyToken == 359) { report.Error(439, lexer.Location, "An extern alias declaration must precede all other elements"); } else { Error_SyntaxError(yyToken); } } private void case_13() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; string value = locatedToken.Value; if (value != "alias") { syntax_error(locatedToken.Location, "`alias' expected"); return; } if (lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(locatedToken.Location, "external alias"); } locatedToken = (LocatedToken)yyVals[-1 + yyTop]; if (locatedToken.Value == QualifiedAliasMember.GlobalAlias) { RootNamespace.Error_GlobalNamespaceRedefined(report, locatedToken.Location); } UsingExternAlias un = new UsingExternAlias(new SimpleMemberName(locatedToken.Value, locatedToken.Location), GetLocation(yyVals[-3 + yyTop])); current_namespace.AddUsing(un); } private void case_17() { if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_18() { UsingClause un; if (yyVals[-2 + yyTop] != null) { if (lang_version <= LanguageVersion.V_5) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "using static"); } un = new UsingType((ATypeNameExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } else { un = new UsingNamespace((ATypeNameExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } current_namespace.AddUsing(un); } private void case_19() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; if (lang_version != LanguageVersion.ISO_1 && locatedToken.Value == "global") { report.Warning(440, 2, locatedToken.Location, "An alias named `global' will not be used when resolving `global::'. The global namespace will be used instead"); } if (yyVals[-4 + yyTop] != null) { report.Error(8085, GetLocation(yyVals[-4 + yyTop]), "A `using static' directive cannot be used to declare an alias"); } UsingAliasNamespace un = new UsingAliasNamespace(new SimpleMemberName(locatedToken.Value, locatedToken.Location), (ATypeNameExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-5 + yyTop])); current_namespace.AddUsing(un); } private void case_20() { Error_SyntaxError(yyToken); yyVal = null; } private void case_23() { Attributes attributes = (Attributes)yyVals[-2 + yyTop]; MemberName memberName = (MemberName)yyVals[yyTop]; if (attributes != null) { bool flag = true; if (current_namespace.DeclarationFound || current_namespace != file) { flag = false; } else { foreach (Attribute attr in attributes.Attrs) { if (attr.ExplicitTarget == "assembly" || attr.ExplicitTarget == "module") { continue; } flag = false; break; } } if (!flag) { report.Error(1671, memberName.Location, "A namespace declaration cannot have modifiers or attributes"); } } module.AddAttributes(attributes, current_namespace); NamespaceContainer tc = new NamespaceContainer(memberName, current_namespace); current_namespace.AddTypeContainer(tc); current_container = (current_namespace = tc); } private void case_24() { if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_25() { if (yyVals[yyTop] != null) { } current_container = (current_namespace = current_namespace.Parent); } private void case_26() { report.Error(1514, lexer.Location, "Unexpected symbol `{0}', expecting `.' or `{{'", GetSymbolName(yyToken)); MemberName name = (MemberName)yyVals[yyTop]; NamespaceContainer tc = new NamespaceContainer(name, current_namespace); current_namespace.AddTypeContainer(tc); } private void case_29() { Error_SyntaxError(yyToken); yyVal = null; } private void case_30() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new MemberName(locatedToken.Value, locatedToken.Location); } private void case_31() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new MemberName((MemberName)yyVals[-2 + yyTop], locatedToken.Value, locatedToken.Location); } private void case_32() { Error_SyntaxError(yyToken); yyVal = new MemberName("", lexer.Location); } private void case_45() { if (yyVals[yyTop] != null) { TypeContainer typeContainer = (TypeContainer)yyVals[yyTop]; if ((typeContainer.ModFlags & (Modifiers.PROTECTED | Modifiers.PRIVATE)) != 0) { report.Error(1527, typeContainer.Location, "Namespace elements cannot be explicitly declared as private, protected, protected internal, or private protected"); } if (typeContainer.OptAttributes != null) { typeContainer.OptAttributes.ConvertGlobalAttributes(typeContainer, current_namespace, !current_namespace.DeclarationFound && current_namespace == file); } } current_namespace.DeclarationFound = true; } private void case_47() { current_namespace.UnattachedAttributes = (Attributes)yyVals[-1 + yyTop]; report.Error(1518, lexer.Location, "Attributes must be attached to class, delegate, enum, interface or struct"); lexer.putback(125); } private void case_55() { List attrs = (List)yyVals[yyTop]; yyVal = new Attributes(attrs); } private void case_56() { Attributes attributes = yyVals[-1 + yyTop] as Attributes; List list = (List)yyVals[yyTop]; if (attributes == null) { attributes = new Attributes(list); } else if (list != null) { attributes.AddAttributes(list); } yyVal = attributes; } private void case_57() { lexer.parsing_attribute_section = true; } private void case_58() { lexer.parsing_attribute_section = false; yyVal = yyVals[yyTop]; } private void case_59() { current_attr_target = (string)yyVals[-1 + yyTop]; if (current_attr_target == "assembly" || current_attr_target == "module") { Lexer.check_incorrect_doc_comment(); } } private void case_60() { if (current_attr_target == string.Empty) { yyVal = new List(0); } else { yyVal = yyVals[-2 + yyTop]; } if (yyVals[-1 + yyTop] != null) { } current_attr_target = null; lexer.parsing_attribute_section = false; } private void case_61() { yyVal = yyVals[-2 + yyTop]; if (yyVals[-1 + yyTop] == null) { } } private void case_62() { Error_SyntaxError(yyToken); LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; SimpleName expr = new SimpleName(locatedToken.Value, null, locatedToken.Location); yyVal = new List { new Attribute(null, expr, null, GetLocation(yyVals[-1 + yyTop]), nameEscaped: false) }; } private void case_63() { if (CheckAttributeTarget(yyToken, GetTokenName(yyToken), GetLocation(yyVals[yyTop])).Length > 0) { Error_SyntaxError(yyToken); } yyVal = null; } private void case_64() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = CheckAttributeTarget(yyToken, locatedToken.Value, locatedToken.Location); } private void case_68() { List list = (List)yyVals[-2 + yyTop]; list?.Add((Attribute)yyVals[yyTop]); yyVal = list; } private void case_70() { lexer.parsing_block--; ATypeNameExpression aTypeNameExpression = (ATypeNameExpression)yyVals[-2 + yyTop]; if (aTypeNameExpression.HasTypeArguments) { report.Error(404, aTypeNameExpression.Location, "Attributes cannot be generic"); } yyVal = new Attribute(current_attr_target, aTypeNameExpression, (Arguments[])yyVals[yyTop], GetLocation(yyVals[-2 + yyTop]), lexer.IsEscapedIdentifier(aTypeNameExpression)); } private void case_75() { Arguments arguments = new Arguments(4); arguments.Add((Argument)yyVals[yyTop]); yyVal = new Arguments[2] { arguments, null }; } private void case_76() { Arguments arguments = new Arguments(4); arguments.Add((Argument)yyVals[yyTop]); yyVal = new Arguments[2] { null, arguments }; } private void case_77() { Arguments[] array = (Arguments[])yyVals[-2 + yyTop]; if (array[1] != null) { report.Error(1016, ((Argument)yyVals[yyTop]).Expr.Location, "Named attribute arguments must appear after the positional arguments"); array[0] = new Arguments(4); } Arguments arguments = array[0]; if (lang_version < LanguageVersion.V_7_2 && arguments.Count > 0 && !(yyVals[yyTop] is NamedArgument) && arguments[arguments.Count - 1] is NamedArgument) { Error_NamedArgumentExpected((NamedArgument)arguments[arguments.Count - 1]); } arguments.Add((Argument)yyVals[yyTop]); } private void case_78() { Arguments[] array = (Arguments[])yyVals[-2 + yyTop]; if (array[1] == null) { array[1] = new Arguments(4); } array[1].Add((Argument)yyVals[yyTop]); } private void case_81() { Error_SyntaxError(yyToken); yyVal = null; } private void case_83() { lexer.parsing_block--; LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; yyVal = new NamedArgument(locatedToken.Value, locatedToken.Location, (Expression)yyVals[yyTop]); } private void case_84() { if (lang_version <= LanguageVersion.V_3) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "named argument"); } Argument.AType modifier = ((yyVals[-1 + yyTop] != null) ? ((Argument.AType)yyVals[-1 + yyTop]) : Argument.AType.None); LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; yyVal = new NamedArgument(locatedToken.Value, locatedToken.Location, (Expression)yyVals[yyTop], modifier); } private void case_85() { if (lang_version <= LanguageVersion.V_3) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "named argument"); } LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; yyVal = new NamedArgument(locatedToken.Value, locatedToken.Location, (Expression)yyVals[yyTop], Argument.AType.Out); } private void case_93() { lexer.parsing_modifiers = true; lexer.parsing_block = 0; } private void case_94() { lexer.parsing_modifiers = true; lexer.parsing_block = 0; } private void case_108() { report.Error(1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration", GetSymbolName(yyToken)); yyVal = null; lexer.parsing_generic_declaration = false; } private void case_109() { current_local_parameters = current_type.PrimaryConstructorParameters; if (current_local_parameters == null) { report.Error(9010, GetLocation(yyVals[yyTop]), "Primary constructor body is not allowed"); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } lexer.parsing_block++; start_block(GetLocation(yyVals[yyTop])); } private void case_110() { current_local_parameters = null; if (current_type is ClassOrStruct classOrStruct) { ToplevelBlock toplevelBlock = (ToplevelBlock)yyVals[yyTop]; if (classOrStruct.PrimaryConstructorBlock != null) { report.Error(8041, toplevelBlock.StartLocation, "Primary constructor already has a body"); } else { classOrStruct.PrimaryConstructorBlock = toplevelBlock; } } } private void case_112() { if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "ref structs"); } yyVal = RefStructToken; } private void case_113() { if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "ref structs"); } yyVal = RefPartialStructToken; } private void case_114() { Modifiers modifiers = (Modifiers)yyVals[-3 + yyTop]; if ((modifiers & Modifiers.READONLY) != 0 && lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "readonly structs"); } if (yyVals[-1 + yyTop] != null) { modifiers |= Modifiers.REF; if (yyVals[-1 + yyTop] == RefPartialStructToken) { modifiers |= Modifiers.PARTIAL; yyVals[-2 + yyTop] = yyVals[-1 + yyTop]; } } lexer.ConstraintsParsing = true; valid_param_mod = ParameterModifierType.PrimaryConstructor; push_current_container(new Struct(current_container, (MemberName)yyVals[yyTop], modifiers, (Attributes)yyVals[-4 + yyTop]), yyVals[-2 + yyTop]); } private void case_115() { valid_param_mod = (ParameterModifierType)0; lexer.ConstraintsParsing = false; if (yyVals[-2 + yyTop] != null) { current_type.PrimaryConstructorParameters = (ParametersCompiled)yyVals[-2 + yyTop]; } if (yyVals[yyTop] != null) { current_container.SetConstraints((List)yyVals[yyTop]); } if (doc_support) { current_container.PartialContainer.DocComment = Lexer.consume_doc_comment(); } lexer.parsing_modifiers = true; } private void case_116() { if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_117() { lexer.parsing_declaration--; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_118() { if (yyVals[-1 + yyTop] == null) { } yyVal = pop_current_class(); } private void case_120() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; Modifiers modifiers = (Modifiers)yyVals[-3 + yyTop]; current_field = new Const(current_type, (FullNamedExpression)yyVals[-1 + yyTop], modifiers, new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-4 + yyTop]); current_type.AddMember(current_field); if ((modifiers & Modifiers.STATIC) != 0) { report.Error(504, current_field.Location, "The constant `{0}' cannot be marked static", current_field.GetSignatureForError()); } yyVal = current_field; } private void case_121() { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } current_field.Initializer = (ConstInitializer)yyVals[-2 + yyTop]; current_field = null; } private void case_122() { Error_SyntaxError(yyToken); current_type.AddMember(new Const(current_type, (FullNamedExpression)yyVals[-1 + yyTop], (Modifiers)yyVals[-3 + yyTop], MemberName.Null, (Attributes)yyVals[-4 + yyTop])); } private void case_127() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new FieldDeclarator(new SimpleMemberName(locatedToken.Value, locatedToken.Location), (ConstInitializer)yyVals[yyTop]); } private void case_129() { lexer.parsing_block--; yyVal = new ConstInitializer(current_field, (Expression)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_130() { report.Error(145, lexer.Location, "A const field requires a value to be provided"); yyVal = null; } private void case_133() { lexer.parsing_generic_declaration = false; FullNamedExpression fullNamedExpression = (FullNamedExpression)yyVals[-1 + yyTop]; if (fullNamedExpression.Type != null && fullNamedExpression.Type.Kind == MemberKind.Void) { report.Error(670, GetLocation(yyVals[-1 + yyTop]), "Fields cannot have void type"); } LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; current_field = new Field(current_type, fullNamedExpression, (Modifiers)yyVals[-2 + yyTop], new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-3 + yyTop]); current_type.AddField(current_field); yyVal = current_field; } private void case_134() { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } yyVal = current_field; current_field = null; } private void case_135() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "fixed size buffers"); } LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; current_field = new FixedField(current_type, (FullNamedExpression)yyVals[-1 + yyTop], (Modifiers)yyVals[-3 + yyTop], new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-4 + yyTop]); current_type.AddField(current_field); } private void case_136() { if (doc_support) { current_field.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } current_field.Initializer = (ConstInitializer)yyVals[-2 + yyTop]; yyVal = current_field; current_field = null; } private void case_139() { lexer.parsing_block++; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; start_block(GetLocation(yyVals[yyTop])); } private void case_140() { lexer.parsing_block--; current_field.Initializer = (Expression)yyVals[yyTop]; end_block(lexer.Location); current_local_parameters = null; } private void case_145() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new FieldDeclarator(new SimpleMemberName(locatedToken.Value, locatedToken.Location), null); } private void case_147() { lexer.parsing_block--; LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; yyVal = new FieldDeclarator(new SimpleMemberName(locatedToken.Value, locatedToken.Location), (Expression)yyVals[yyTop]); } private void case_152() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new FieldDeclarator(new SimpleMemberName(locatedToken.Value, locatedToken.Location), (ConstInitializer)yyVals[yyTop]); } private void case_154() { lexer.parsing_block--; yyVal = new ConstInitializer(current_field, (Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_155() { report.Error(443, lexer.Location, "Value or constant expected"); yyVal = null; } private void case_158() { Error_SyntaxError(yyToken); yyVal = null; } private void case_159() { if (doc_support) { Lexer.doc_state = XmlCommentState.NotAllowed; } } private void case_160() { Method method = (Method)yyVals[-2 + yyTop]; method.Block = (ToplevelBlock)yyVals[yyTop]; async_block = false; if (method.Block == null) { method.ParameterInfo.CheckParameters(method); if ((method.ModFlags & Modifiers.ASYNC) != 0) { report.Error(1994, method.Location, "`{0}': The async modifier can only be used with methods that have a body", method.GetSignatureForError()); } } else if (current_container.Kind == MemberKind.Interface) { report.Error(531, method.Location, "`{0}': interface members cannot have a definition", method.GetSignatureForError()); } current_local_parameters = null; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_163() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "byref locals and returns"); } yyVal = new ReferenceTypeExpr((FullNamedExpression)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_165() { if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "readonly references"); } yyVal = new ReferenceTypeExpr((FullNamedExpression)yyVals[yyTop], readOnly: true, GetLocation(yyVals[-3 + yyTop])); } private void case_167() { valid_param_mod = (ParameterModifierType)0; MemberName name = (MemberName)yyVals[-4 + yyTop]; current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; Method method = Method.Create(current_type, (FullNamedExpression)yyVals[-5 + yyTop], (Modifiers)yyVals[-6 + yyTop], name, current_local_parameters, (Attributes)yyVals[-7 + yyTop]); current_type.AddMember(method); async_block = (method.ModFlags & Modifiers.ASYNC) != 0; if (doc_support) { method.DocComment = Lexer.consume_doc_comment(); } yyVal = method; lexer.ConstraintsParsing = true; } private void case_168() { lexer.ConstraintsParsing = false; if (yyVals[yyTop] != null) { Method method = (Method)yyVals[-1 + yyTop]; method.SetConstraints((List)yyVals[yyTop]); } yyVal = yyVals[-1 + yyTop]; } private void case_170() { lexer.parsing_generic_declaration = false; valid_param_mod = ParameterModifierType.All; } private void case_172() { lexer.ConstraintsParsing = false; valid_param_mod = (ParameterModifierType)0; MemberName name = (MemberName)yyVals[-6 + yyTop]; current_local_parameters = (ParametersCompiled)yyVals[-3 + yyTop]; Modifiers modifiers = (Modifiers)yyVals[-10 + yyTop]; modifiers |= Modifiers.PARTIAL; Method method = Method.Create(current_type, new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[-8 + yyTop])), modifiers, name, current_local_parameters, (Attributes)yyVals[-11 + yyTop]); current_type.AddMember(method); async_block = (method.ModFlags & Modifiers.ASYNC) != 0; if (yyVals[yyTop] != null) { method.SetConstraints((List)yyVals[yyTop]); } if (doc_support) { method.DocComment = Lexer.consume_doc_comment(); } yyVal = method; } private void case_173() { MemberName memberName = (MemberName)yyVals[-3 + yyTop]; report.Error(1585, memberName.Location, "Member modifier `{0}' must precede the member type and name", ModifiersExtensions.Name((Modifiers)yyVals[-4 + yyTop])); Method method = Method.Create(current_type, (FullNamedExpression)yyVals[-5 + yyTop], (Modifiers)0, memberName, (ParametersCompiled)yyVals[-1 + yyTop], (Attributes)yyVals[-7 + yyTop]); current_type.AddMember(method); current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; if (doc_support) { method.DocComment = Lexer.consume_doc_comment(); } yyVal = method; } private void case_174() { Error_SyntaxError(yyToken); current_local_parameters = ParametersCompiled.Undefined; MemberName name = (MemberName)yyVals[-1 + yyTop]; Method method = Method.Create(current_type, (FullNamedExpression)yyVals[-2 + yyTop], (Modifiers)yyVals[-3 + yyTop], name, current_local_parameters, (Attributes)yyVals[-4 + yyTop]); current_type.AddMember(method); if (doc_support) { method.DocComment = Lexer.consume_doc_comment(); } yyVal = method; } private void case_181() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "expression body constructor"); } lexer.parsing_block++; } private void case_182() { lexer.parsing_block = 0; current_block.AddStatement(new ContextualReturn((Expression)yyVals[-1 + yyTop])); Block block = end_block(GetLocation(yyVals[yyTop])); block.IsCompilerGenerated = true; yyVal = block; current_block = null; } private void case_183() { if (lang_version < LanguageVersion.V_6) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "expression bodied members"); } lexer.parsing_block++; start_block(GetLocation(yyVals[yyTop])); } private void case_184() { lexer.parsing_block = 0; current_block.AddStatement(new ContextualReturn((Expression)yyVals[-1 + yyTop])); Block block = end_block(GetLocation(yyVals[yyTop])); block.IsCompilerGenerated = true; yyVal = block; } private void case_187() { List list = (List)yyVals[yyTop]; yyVal = new ParametersCompiled(list.ToArray()); } private void case_188() { List list = (List)yyVals[-2 + yyTop]; list.Add((Parameter)yyVals[yyTop]); yyVal = new ParametersCompiled(list.ToArray()); } private void case_189() { List list = (List)yyVals[-2 + yyTop]; list.Add(new ArglistParameter(GetLocation(yyVals[yyTop]))); yyVal = new ParametersCompiled(list.ToArray(), has_arglist: true); } private void case_190() { if (yyVals[-2 + yyTop] != null) { report.Error(231, ((Parameter)yyVals[-2 + yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list"); } yyVal = new ParametersCompiled((Parameter)yyVals[-2 + yyTop]); } private void case_191() { if (yyVals[-2 + yyTop] != null) { report.Error(231, ((Parameter)yyVals[-2 + yyTop]).Location, "A params parameter must be the last parameter in a formal parameter list"); } List list = (List)yyVals[-4 + yyTop]; list.Add(new ArglistParameter(GetLocation(yyVals[-2 + yyTop]))); yyVal = new ParametersCompiled(list.ToArray(), has_arglist: true); } private void case_192() { report.Error(257, GetLocation(yyVals[-2 + yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); yyVal = new ParametersCompiled(new Parameter[1] { new ArglistParameter(GetLocation(yyVals[-2 + yyTop])) }, has_arglist: true); } private void case_193() { report.Error(257, GetLocation(yyVals[-2 + yyTop]), "An __arglist parameter must be the last parameter in a formal parameter list"); List list = (List)yyVals[-4 + yyTop]; list.Add(new ArglistParameter(GetLocation(yyVals[-2 + yyTop]))); yyVal = new ParametersCompiled(list.ToArray(), has_arglist: true); } private void case_196() { Error_SyntaxError(yyToken); yyVal = ParametersCompiled.EmptyReadOnlyParameters; } private void case_197() { parameters_bucket.Clear(); Parameter parameter = (Parameter)yyVals[yyTop]; parameters_bucket.Add(parameter); default_parameter_used = parameter.HasDefaultValue; yyVal = parameters_bucket; } private void case_198() { List list = (List)yyVals[-2 + yyTop]; Parameter parameter = (Parameter)yyVals[yyTop]; if (parameter != null) { if (parameter.HasExtensionMethodModifier) { report.Error(1100, parameter.Location, "The parameter modifier `this' can only be used on the first parameter"); } else if (!parameter.HasDefaultValue && default_parameter_used) { report.Error(1737, parameter.Location, "Optional parameter cannot precede required parameters"); } default_parameter_used |= parameter.HasDefaultValue; list.Add(parameter); } yyVal = yyVals[-2 + yyTop]; } private void case_199() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new Parameter((FullNamedExpression)yyVals[-1 + yyTop], locatedToken.Value, (Parameter.Modifier)yyVals[-2 + yyTop], (Attributes)yyVals[-3 + yyTop], locatedToken.Location); } private void case_200() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; report.Error(1552, locatedToken.Location, "Array type specifier, [], must appear before parameter name"); yyVal = new Parameter((FullNamedExpression)yyVals[-3 + yyTop], locatedToken.Value, (Parameter.Modifier)yyVals[-4 + yyTop], (Attributes)yyVals[-5 + yyTop], locatedToken.Location); } private void case_201() { Error_SyntaxError(yyToken); Location location = GetLocation(yyVals[yyTop]); yyVal = new Parameter(null, null, Parameter.Modifier.NONE, (Attributes)yyVals[-1 + yyTop], location); } private void case_202() { Error_SyntaxError(yyToken); Location location = GetLocation(yyVals[yyTop]); yyVal = new Parameter((FullNamedExpression)yyVals[-1 + yyTop], null, (Parameter.Modifier)yyVals[-2 + yyTop], (Attributes)yyVals[-3 + yyTop], location); } private void case_204() { lexer.parsing_block--; if (lang_version <= LanguageVersion.V_3) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "optional parameter"); } Parameter.Modifier modifier = (Parameter.Modifier)yyVals[-5 + yyTop]; if (modifier != Parameter.Modifier.NONE) { switch (modifier) { case Parameter.Modifier.REF: case Parameter.Modifier.OUT: report.Error(1741, GetLocation(yyVals[-5 + yyTop]), "Cannot specify a default value for the `{0}' parameter", Parameter.GetModifierSignature(modifier)); break; case Parameter.Modifier.This: report.Error(1743, GetLocation(yyVals[-5 + yyTop]), "Cannot specify a default value for the `{0}' parameter", Parameter.GetModifierSignature(modifier)); break; default: throw new NotImplementedException(modifier.ToString()); } modifier = Parameter.Modifier.NONE; } if ((valid_param_mod & ParameterModifierType.DefaultValue) == 0) { report.Error(1065, GetLocation(yyVals[-2 + yyTop]), "Optional parameter is not valid in this context"); } LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; yyVal = new Parameter((FullNamedExpression)yyVals[-4 + yyTop], locatedToken.Value, modifier, (Attributes)yyVals[-6 + yyTop], locatedToken.Location); if (yyVals[yyTop] != null) { ((Parameter)yyVal).DefaultValue = new DefaultParameterValueExpression((Expression)yyVals[yyTop]); } } private void case_208() { Parameter.Modifier modifier = (Parameter.Modifier)yyVals[yyTop]; Parameter.Modifier modifier2 = (Parameter.Modifier)yyVals[-1 + yyTop] | modifier; if (((Parameter.Modifier)yyVals[-1 + yyTop] & modifier) == modifier) { Error_DuplicateParameterModifier(lexer.Location, modifier); } else if ((modifier2 & ~(Parameter.Modifier.This | Parameter.Modifier.ReadOnly)) != Parameter.Modifier.NONE) { switch (modifier2 & ~Parameter.Modifier.This) { case Parameter.Modifier.REF: report.Error(1101, lexer.Location, "The parameter modifiers `this' and `ref' cannot be used altogether"); break; case Parameter.Modifier.OUT: report.Error(1102, lexer.Location, "The parameter modifiers `this' and `out' cannot be used altogether"); break; default: report.Error(1108, lexer.Location, "A parameter cannot have specified more than one modifier"); break; } } yyVal = modifier2; } private void case_209() { if ((valid_param_mod & ParameterModifierType.Ref) == 0) { Error_ParameterModifierNotValid("ref", GetLocation(yyVals[yyTop])); } yyVal = Parameter.Modifier.REF; } private void case_210() { if ((valid_param_mod & ParameterModifierType.Out) == 0) { Error_ParameterModifierNotValid("out", GetLocation(yyVals[yyTop])); } yyVal = Parameter.Modifier.OUT; } private void case_211() { if ((valid_param_mod & ParameterModifierType.This) == 0) { Error_ParameterModifierNotValid("this", GetLocation(yyVals[yyTop])); } if (lang_version <= LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "extension methods"); } yyVal = Parameter.Modifier.This; } private void case_212() { if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "readonly references"); } yyVal = Parameter.Modifier.ReadOnly; } private void case_213() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new ParamsParameter((FullNamedExpression)yyVals[-1 + yyTop], locatedToken.Value, (Attributes)yyVals[-3 + yyTop], locatedToken.Location); } private void case_214() { report.Error(1751, GetLocation(yyVals[-4 + yyTop]), "Cannot specify a default value for a parameter array"); LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new ParamsParameter((FullNamedExpression)yyVals[-3 + yyTop], locatedToken.Value, (Attributes)yyVals[-5 + yyTop], locatedToken.Location); } private void case_215() { Error_SyntaxError(yyToken); yyVal = new ParamsParameter((FullNamedExpression)yyVals[-1 + yyTop], null, (Attributes)yyVals[-3 + yyTop], Location.Null); } private void case_216() { if ((valid_param_mod & ParameterModifierType.Params) == 0) { report.Error(1670, GetLocation(yyVals[yyTop]), "The `params' modifier is not allowed in current context"); } } private void case_217() { Parameter.Modifier modifier = (Parameter.Modifier)yyVals[yyTop]; if ((modifier & Parameter.Modifier.This) != Parameter.Modifier.NONE) { report.Error(1104, GetLocation(yyVals[-1 + yyTop]), "The parameter modifiers `this' and `params' cannot be used altogether"); } else { report.Error(1611, GetLocation(yyVals[-1 + yyTop]), "The params parameter cannot be declared as ref, out or in"); } } private void case_219() { if ((valid_param_mod & ParameterModifierType.Arglist) == 0) { report.Error(1669, GetLocation(yyVals[yyTop]), "__arglist is not valid in this context"); } } private void case_220() { lexer.parsing_generic_declaration = false; if (doc_support) { tmpComment = Lexer.consume_doc_comment(); } } private void case_221() { FullNamedExpression fullNamedExpression = (FullNamedExpression)yyVals[-3 + yyTop]; current_property = new Property(current_type, fullNamedExpression, (Modifiers)yyVals[-4 + yyTop], (MemberName)yyVals[-2 + yyTop], (Attributes)yyVals[-5 + yyTop]); if (fullNamedExpression.Type != null && fullNamedExpression.Type.Kind == MemberKind.Void) { report.Error(547, GetLocation(yyVals[-3 + yyTop]), "`{0}': property or indexer cannot have void type", current_property.GetSignatureForError()); } current_type.AddMember(current_property); lexer.PropertyParsing = true; } private void case_222() { lexer.PropertyParsing = false; if (doc_support) { current_property.DocComment = ConsumeStoredComment(); } if (yyVals[-5 + yyTop] is ReferenceTypeExpr) { if (current_property.Get == null) { report.Error(8146, GetLocation(yyVals[-4 + yyTop]), "`{0}': property and indexer which return by reference must have a get accessor", current_property.GetSignatureForError()); } if (current_property.Set != null) { report.Error(8147, GetLocation(yyVals[-4 + yyTop]), "`{0}': property and indexer which return by reference cannot have set accessors", current_property.GetSignatureForError()); } } } private void case_223() { lexer.parsing_modifiers = true; } private void case_225() { lexer.parsing_generic_declaration = false; if (doc_support) { tmpComment = Lexer.consume_doc_comment(); } current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } private void case_226() { FullNamedExpression fullNamedExpression = (FullNamedExpression)yyVals[-3 + yyTop]; Property property = new Property(current_type, fullNamedExpression, (Modifiers)yyVals[-4 + yyTop], (MemberName)yyVals[-2 + yyTop], (Attributes)yyVals[-5 + yyTop]); property.Get = new PropertyBase.GetMethod(property, Modifiers.COMPILER_GENERATED, null, property.Location); property.Get.Block = (ToplevelBlock)yyVals[yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error(531, property.Get.Block.StartLocation, "`{0}': interface members cannot have a definition", property.GetSignatureForError()); } if (fullNamedExpression.Type != null && fullNamedExpression.Type.Kind == MemberKind.Void) { report.Error(547, GetLocation(yyVals[-3 + yyTop]), "`{0}': property or indexer cannot have void type", property.GetSignatureForError()); } if (doc_support) { property.DocComment = ConsumeStoredComment(); } current_type.AddMember(property); current_local_parameters = null; } private void case_228() { lexer.parsing_block++; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; start_block(GetLocation(yyVals[yyTop])); } private void case_229() { lexer.parsing_block--; ((Property)current_property).Initializer = (Expression)yyVals[-1 + yyTop]; end_block(GetLocation(yyVals[yyTop])); current_local_parameters = null; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_233() { valid_param_mod = (ParameterModifierType)0; FullNamedExpression fullNamedExpression = (FullNamedExpression)yyVals[-5 + yyTop]; Indexer indexer = (Indexer)(current_property = new Indexer(current_type, fullNamedExpression, (MemberName)yyVals[-4 + yyTop], (Modifiers)yyVals[-6 + yyTop], (ParametersCompiled)yyVals[-1 + yyTop], (Attributes)yyVals[-7 + yyTop])); current_type.AddIndexer(indexer); if (fullNamedExpression.Type != null && fullNamedExpression.Type.Kind == MemberKind.Void) { report.Error(620, GetLocation(yyVals[-5 + yyTop]), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError()); } if (indexer.ParameterInfo.IsEmpty) { report.Error(1551, GetLocation(yyVals[-3 + yyTop]), "Indexers must have at least one parameter"); } if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } lexer.PropertyParsing = true; current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; } private void case_234() { lexer.PropertyParsing = false; current_local_parameters = null; if (current_property.AccessorFirst != null && current_property.AccessorFirst.Block == null) { ((Indexer)current_property).ParameterInfo.CheckParameters(current_property); } if (doc_support) { current_property.DocComment = ConsumeStoredComment(); } if (yyVals[-7 + yyTop] is ReferenceTypeExpr) { if (current_property.Get == null) { report.Error(8146, GetLocation(yyVals[-6 + yyTop]), "`{0}': property and indexer which return by reference must have a get accessor", current_property.GetSignatureForError()); } if (current_property.Set != null) { report.Error(8147, GetLocation(yyVals[-6 + yyTop]), "`{0}': property and indexer which return by reference cannot have set accessors", current_property.GetSignatureForError()); } } current_property = null; } private void case_236() { current_property.Get = new Indexer.GetIndexerMethod(current_property, Modifiers.COMPILER_GENERATED, current_local_parameters, null, current_property.Location); current_property.Get.Block = (ToplevelBlock)yyVals[yyTop]; } private void case_241() { if (yyToken == 374) { report.Error(548, lexer.Location, "`{0}': property or indexer must have at least one accessor", current_property.GetSignatureForError()); } else if (yyToken == 382) { report.Error(1597, lexer.Location, "Semicolon after method or accessor block is not valid"); } else { report.Error(1014, GetLocation(yyVals[yyTop]), "A get or set accessor expected"); } } private void case_242() { if (yyVals[-1 + yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "access modifiers on properties"); } if (current_property.Get != null) { report.Error(1007, GetLocation(yyVals[yyTop]), "Property accessor already defined"); } if (current_property is Indexer) { current_property.Get = new Indexer.GetIndexerMethod(current_property, (Modifiers)yyVals[-1 + yyTop], ((Indexer)current_property).ParameterInfo.Clone(), (Attributes)yyVals[-2 + yyTop], GetLocation(yyVals[yyTop])); } else { current_property.Get = new PropertyBase.GetMethod(current_property, (Modifiers)yyVals[-1 + yyTop], (Attributes)yyVals[-2 + yyTop], GetLocation(yyVals[yyTop])); } current_local_parameters = current_property.Get.ParameterInfo; lexer.PropertyParsing = false; } private void case_243() { if (yyVals[yyTop] != null) { current_property.Get.Block = (ToplevelBlock)yyVals[yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error(531, current_property.Get.Block.StartLocation, "`{0}': interface members cannot have a definition", current_property.Get.GetSignatureForError()); } } current_local_parameters = null; lexer.PropertyParsing = true; if (doc_support && Lexer.doc_state == XmlCommentState.Error) { Lexer.doc_state = XmlCommentState.NotAllowed; } } private void case_244() { if (yyVals[-1 + yyTop] != ModifierNone && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "access modifiers on properties"); } if (current_property.Set != null) { report.Error(1007, GetLocation(yyVals[yyTop]), "Property accessor already defined"); } if (current_property is Indexer) { current_property.Set = new Indexer.SetIndexerMethod(current_property, (Modifiers)yyVals[-1 + yyTop], ParametersCompiled.MergeGenerated(compiler, ((Indexer)current_property).ParameterInfo, checkConflicts: true, new Parameter(current_property.TypeExpression, "value", Parameter.Modifier.NONE, null, GetLocation(yyVals[yyTop])), null), (Attributes)yyVals[-2 + yyTop], GetLocation(yyVals[yyTop])); } else { current_property.Set = new PropertyBase.SetMethod(current_property, (Modifiers)yyVals[-1 + yyTop], ParametersCompiled.CreateImplicitParameter(current_property.TypeExpression, GetLocation(yyVals[yyTop])), (Attributes)yyVals[-2 + yyTop], GetLocation(yyVals[yyTop])); } current_local_parameters = current_property.Set.ParameterInfo; lexer.PropertyParsing = false; } private void case_245() { if (yyVals[yyTop] != null) { current_property.Set.Block = (ToplevelBlock)yyVals[yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error(531, current_property.Set.Block.StartLocation, "`{0}': interface members cannot have a definition", current_property.Set.GetSignatureForError()); } } current_local_parameters = null; lexer.PropertyParsing = true; if (doc_support && Lexer.doc_state == XmlCommentState.Error) { Lexer.doc_state = XmlCommentState.NotAllowed; } } private void case_248() { yyVal = null; } private void case_249() { Error_SyntaxError(1043, yyToken, "Invalid accessor body"); yyVal = null; } private void case_251() { lexer.ConstraintsParsing = true; push_current_container(new Interface(current_container, (MemberName)yyVals[yyTop], (Modifiers)yyVals[-4 + yyTop], (Attributes)yyVals[-5 + yyTop]), yyVals[-3 + yyTop]); } private void case_252() { lexer.ConstraintsParsing = false; if (yyVals[yyTop] != null) { current_container.SetConstraints((List)yyVals[yyTop]); } if (doc_support) { current_container.PartialContainer.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } lexer.parsing_modifiers = true; } private void case_253() { lexer.parsing_declaration--; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_254() { if (yyVals[yyTop] == null) { } yyVal = pop_current_class(); } private void case_258() { lexer.parsing_modifiers = true; lexer.parsing_block = 0; } private void case_259() { lexer.parsing_modifiers = true; lexer.parsing_block = 0; } private void case_270() { OperatorDeclaration operatorDeclaration = (OperatorDeclaration)yyVals[-2 + yyTop]; if (operatorDeclaration != null) { Operator obj = new Operator(current_type, operatorDeclaration.optype, operatorDeclaration.ret_type, (Modifiers)yyVals[-3 + yyTop], current_local_parameters, (ToplevelBlock)yyVals[yyTop], (Attributes)yyVals[-4 + yyTop], operatorDeclaration.location); if (obj.Block == null) { obj.ParameterInfo.CheckParameters(obj); } if (doc_support) { obj.DocComment = tmpComment; Lexer.doc_state = XmlCommentState.Allowed; } current_type.AddOperator(obj); } current_local_parameters = null; } private void case_272() { report.Error(590, GetLocation(yyVals[yyTop]), "User-defined operators cannot return void"); yyVal = new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[yyTop])); } private void case_273() { valid_param_mod = ParameterModifierType.DefaultValue | ParameterModifierType.ReadOnly; if ((Operator.OpType)yyVals[-1 + yyTop] == Operator.OpType.Is) { valid_param_mod |= ParameterModifierType.Out; } } private void case_274() { valid_param_mod = (ParameterModifierType)0; Location location = GetLocation(yyVals[-5 + yyTop]); Operator.OpType opType = (Operator.OpType)yyVals[-4 + yyTop]; current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; int count = current_local_parameters.Count; if (count == 1) { switch (opType) { case Operator.OpType.Addition: opType = Operator.OpType.UnaryPlus; break; case Operator.OpType.Subtraction: opType = Operator.OpType.UnaryNegation; break; } } if (IsUnaryOperator(opType)) { switch (count) { case 2: report.Error(1020, location, "Overloadable binary operator expected"); break; default: report.Error(1535, location, "Overloaded unary operator `{0}' takes one parameter", Operator.GetName(opType)); break; case 1: break; } } else if (opType != Operator.OpType.Is) { switch (count) { case 1: report.Error(1019, location, "Overloadable unary operator expected"); break; default: report.Error(1534, location, "Overloaded binary operator `{0}' takes two parameters", Operator.GetName(opType)); break; case 2: break; } } if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.NotAllowed; } yyVal = new OperatorDeclaration(opType, (FullNamedExpression)yyVals[-6 + yyTop], location); } private void case_298() { if (lang_version != LanguageVersion.Experimental) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "is user operator"); } yyVal = Operator.OpType.Is; } private void case_300() { valid_param_mod = (ParameterModifierType)0; Location location = GetLocation(yyVals[-5 + yyTop]); current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; if (current_local_parameters.Count != 1) { report.Error(1535, location, "Overloaded unary operator `implicit' takes one parameter"); } if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.NotAllowed; } yyVal = new OperatorDeclaration(Operator.OpType.Implicit, (FullNamedExpression)yyVals[-4 + yyTop], location); } private void case_302() { valid_param_mod = (ParameterModifierType)0; Location location = GetLocation(yyVals[-5 + yyTop]); current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; if (current_local_parameters.Count != 1) { report.Error(1535, location, "Overloaded unary operator `explicit' takes one parameter"); } if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.NotAllowed; } yyVal = new OperatorDeclaration(Operator.OpType.Explicit, (FullNamedExpression)yyVals[-4 + yyTop], location); } private void case_303() { Error_SyntaxError(yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration(Operator.OpType.Implicit, null, GetLocation(yyVals[-1 + yyTop])); } private void case_304() { Error_SyntaxError(yyToken); current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; yyVal = new OperatorDeclaration(Operator.OpType.Explicit, null, GetLocation(yyVals[-1 + yyTop])); } private void case_305() { Constructor constructor = (Constructor)yyVals[-1 + yyTop]; constructor.Block = (ToplevelBlock)yyVals[yyTop]; if (doc_support) { constructor.DocComment = ConsumeStoredComment(); } current_local_parameters = null; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_306() { if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } valid_param_mod = ParameterModifierType.All; } private void case_307() { valid_param_mod = (ParameterModifierType)0; current_local_parameters = (ParametersCompiled)yyVals[-1 + yyTop]; LocatedToken locatedToken = (LocatedToken)yyVals[-4 + yyTop]; Modifiers modifiers = (Modifiers)yyVals[-5 + yyTop]; Constructor constructor = new Constructor(current_type, locatedToken.Value, modifiers, (Attributes)yyVals[-6 + yyTop], current_local_parameters, locatedToken.Location); if (locatedToken.Value != current_container.MemberName.Name) { report.Error(1520, constructor.Location, "Class, struct, or interface method must have a return type"); } else if ((modifiers & Modifiers.STATIC) != 0) { if (!current_local_parameters.IsEmpty) { report.Error(132, constructor.Location, "`{0}': The static constructor must be parameterless", constructor.GetSignatureForError()); } if ((modifiers & Modifiers.AccessibilityMask) != 0) { report.Error(515, constructor.Location, "`{0}': static constructor cannot have an access modifier", constructor.GetSignatureForError()); } } else if (current_type.Kind == MemberKind.Struct && current_local_parameters.IsEmpty) { report.Error(568, constructor.Location, "Structs cannot contain explicit parameterless constructors"); } current_type.AddConstructor(constructor); yyVal = constructor; start_block(lexer.Location); } private void case_308() { if (yyVals[yyTop] != null) { Constructor constructor = (Constructor)yyVals[-1 + yyTop]; constructor.Initializer = (ConstructorInitializer)yyVals[yyTop]; if (constructor.IsStatic) { report.Error(514, constructor.Location, "`{0}': static constructor cannot have an explicit `this' or `base' constructor call", constructor.GetSignatureForError()); } } yyVal = yyVals[-1 + yyTop]; } private void case_312() { lexer.parsing_block--; yyVal = new ConstructorBaseInitializer((Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_314() { lexer.parsing_block--; yyVal = new ConstructorThisInitializer((Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_315() { Error_SyntaxError(yyToken); yyVal = new ConstructorThisInitializer(null, GetLocation(yyVals[yyTop])); } private void case_316() { Error_SyntaxError(yyToken); yyVal = null; } private void case_317() { if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.NotAllowed; } current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; } private void case_318() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; if (locatedToken.Value != current_container.MemberName.Name) { report.Error(574, locatedToken.Location, "Name of destructor must match name of class"); } else if (current_container.Kind != MemberKind.Class) { report.Error(575, locatedToken.Location, "Only class types can contain destructor"); } Destructor destructor = new Destructor(current_type, (Modifiers)yyVals[-6 + yyTop], ParametersCompiled.EmptyReadOnlyParameters, (Attributes)yyVals[-7 + yyTop], locatedToken.Location); if (doc_support) { destructor.DocComment = ConsumeStoredComment(); } destructor.Block = (ToplevelBlock)yyVals[yyTop]; current_type.AddMember(destructor); current_local_parameters = null; } private void case_319() { current_event_field = new EventField(current_type, (FullNamedExpression)yyVals[-1 + yyTop], (Modifiers)yyVals[-3 + yyTop], (MemberName)yyVals[yyTop], (Attributes)yyVals[-4 + yyTop]); current_type.AddMember(current_event_field); if (current_event_field.MemberName.ExplicitInterface != null) { report.Error(71, current_event_field.Location, "`{0}': An explicit interface implementation of an event must use property syntax", current_event_field.GetSignatureForError()); } yyVal = current_event_field; } private void case_320() { if (doc_support) { current_event_field.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } current_event_field = null; } private void case_321() { current_event = new EventProperty(current_type, (FullNamedExpression)yyVals[-2 + yyTop], (Modifiers)yyVals[-4 + yyTop], (MemberName)yyVals[-1 + yyTop], (Attributes)yyVals[-5 + yyTop]); current_type.AddMember(current_event); lexer.EventParsing = true; } private void case_322() { if (current_container.Kind == MemberKind.Interface) { report.Error(69, GetLocation(yyVals[-2 + yyTop]), "Event in interface cannot have add or remove accessors"); } lexer.EventParsing = false; } private void case_323() { if (doc_support) { current_event.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } current_event = null; current_local_parameters = null; } private void case_324() { Error_SyntaxError(yyToken); current_type.AddMember(new EventField(current_type, (FullNamedExpression)yyVals[-1 + yyTop], (Modifiers)yyVals[-3 + yyTop], MemberName.Null, (Attributes)yyVals[-4 + yyTop])); } private void case_327() { lexer.parsing_block--; current_event_field.Initializer = (Expression)yyVals[yyTop]; } private void case_332() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new FieldDeclarator(new SimpleMemberName(locatedToken.Value, locatedToken.Location), null); } private void case_333() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new FieldDeclarator(new SimpleMemberName(locatedToken.Value, locatedToken.Location), (Expression)yyVals[yyTop]); } private void case_334() { if (current_container.Kind == MemberKind.Interface) { report.Error(68, lexer.Location, "`{0}': event in interface cannot have an initializer", current_event_field.GetSignatureForError()); } if ((current_event_field.ModFlags & Modifiers.ABSTRACT) != 0) { report.Error(74, lexer.Location, "`{0}': abstract event cannot have an initializer", current_event_field.GetSignatureForError()); } lexer.parsing_block++; current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters; start_block(lexer.Location); } private void case_335() { yyVal = yyVals[yyTop]; lexer.parsing_block--; end_block(lexer.Location); current_local_parameters = null; } private void case_338() { report.Error(65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError()); } private void case_339() { report.Error(65, lexer.Location, "`{0}': event property must have both add and remove accessors", current_event.GetSignatureForError()); } private void case_340() { report.Error(1055, GetLocation(yyVals[yyTop]), "An add or remove accessor expected"); yyVal = null; } private void case_341() { if (yyVals[-1 + yyTop] != ModifierNone) { report.Error(1609, GetLocation(yyVals[-1 + yyTop]), "Modifiers cannot be placed on event accessor declarations"); } current_event.Add = new EventProperty.AddDelegateMethod(current_event, (Attributes)yyVals[-2 + yyTop], GetLocation(yyVals[yyTop])); current_local_parameters = current_event.Add.ParameterInfo; lexer.EventParsing = false; } private void case_342() { lexer.EventParsing = true; current_event.Add.Block = (ToplevelBlock)yyVals[yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error(531, current_event.Add.Block.StartLocation, "`{0}': interface members cannot have a definition", current_event.Add.GetSignatureForError()); } current_local_parameters = null; } private void case_343() { if (yyVals[-1 + yyTop] != ModifierNone) { report.Error(1609, GetLocation(yyVals[-1 + yyTop]), "Modifiers cannot be placed on event accessor declarations"); } current_event.Remove = new EventProperty.RemoveDelegateMethod(current_event, (Attributes)yyVals[-2 + yyTop], GetLocation(yyVals[yyTop])); current_local_parameters = current_event.Remove.ParameterInfo; lexer.EventParsing = false; } private void case_344() { lexer.EventParsing = true; current_event.Remove.Block = (ToplevelBlock)yyVals[yyTop]; if (current_container.Kind == MemberKind.Interface) { report.Error(531, current_event.Remove.Block.StartLocation, "`{0}': interface members cannot have a definition", current_event.Remove.GetSignatureForError()); } current_local_parameters = null; } private void case_345() { report.Error(73, lexer.Location, "An add or remove accessor must have a body"); yyVal = null; } private void case_348() { current_type.UnattachedAttributes = (Attributes)yyVals[-1 + yyTop]; report.Error(1519, GetLocation(yyVals[-1 + yyTop]), "An attribute is missing member declaration"); lexer.putback(125); } private void case_349() { report.Error(1519, lexer.Location, "Unexpected symbol `}' in class, struct, or interface member declaration"); lexer.putback(125); lexer.parsing_generic_declaration = false; FullNamedExpression type = (FullNamedExpression)yyVals[-1 + yyTop]; current_field = new Field(current_type, type, (Modifiers)yyVals[-2 + yyTop], MemberName.Null, (Attributes)yyVals[-3 + yyTop]); current_type.AddField(current_field); yyVal = current_field; } private void case_350() { if (doc_support) { enumTypeComment = Lexer.consume_doc_comment(); } } private void case_351() { if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } MemberName memberName = (MemberName)yyVals[-3 + yyTop]; if (memberName.IsGeneric) { report.Error(1675, memberName.Location, "Enums cannot have type parameters"); } push_current_container(new Enum(current_container, (FullNamedExpression)yyVals[-2 + yyTop], (Modifiers)yyVals[-5 + yyTop], memberName, (Attributes)yyVals[-6 + yyTop]), null); } private void case_352() { lexer.parsing_modifiers = true; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_353() { if (doc_support) { current_container.DocComment = enumTypeComment; } lexer.parsing_declaration--; yyVal = pop_current_class(); } private void case_356() { Error_TypeExpected(GetLocation(yyVals[-1 + yyTop])); yyVal = null; } private void case_361() { yyVal = yyVals[yyTop]; } private void case_362() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; EnumMember enumMember = new EnumMember((Enum)current_type, new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-1 + yyTop]); ((Enum)current_type).AddEnumMember(enumMember); if (doc_support) { enumMember.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } yyVal = enumMember; } private void case_363() { lexer.parsing_block++; if (doc_support) { tmpComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.NotAllowed; } } private void case_364() { lexer.parsing_block--; LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; EnumMember enumMember = new EnumMember((Enum)current_type, new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-4 + yyTop]); enumMember.Initializer = new ConstInitializer(enumMember, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); ((Enum)current_type).AddEnumMember(enumMember); if (doc_support) { enumMember.DocComment = ConsumeStoredComment(); } yyVal = enumMember; } private void case_365() { Error_SyntaxError(yyToken); LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; EnumMember enumMember = new EnumMember((Enum)current_type, new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-2 + yyTop]); ((Enum)current_type).AddEnumMember(enumMember); if (doc_support) { enumMember.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } yyVal = enumMember; } private void case_368() { valid_param_mod = (ParameterModifierType)0; ParametersCompiled parametersCompiled = (ParametersCompiled)yyVals[-1 + yyTop]; Delegate obj = new Delegate(current_container, (FullNamedExpression)yyVals[-5 + yyTop], (Modifiers)yyVals[-7 + yyTop], (MemberName)yyVals[-4 + yyTop], parametersCompiled, (Attributes)yyVals[-8 + yyTop]); parametersCompiled.CheckParameters(obj); current_container.AddTypeContainer(obj); current_delegate = obj; lexer.ConstraintsParsing = true; } private void case_370() { if (doc_support) { current_delegate.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } if (yyVals[-2 + yyTop] != null) { current_delegate.SetConstraints((List)yyVals[-2 + yyTop]); } yyVal = current_delegate; current_delegate = null; } private void case_372() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "nullable types"); } yyVal = ComposedTypeSpecifier.CreateNullable(GetLocation(yyVals[yyTop])); } private void case_374() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; LocatedToken locatedToken2 = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new QualifiedAliasMember(locatedToken.Value, locatedToken2.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_375() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; LocatedToken locatedToken2 = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new QualifiedAliasMember(locatedToken.Value, locatedToken2.Value, (int)yyVals[yyTop], locatedToken.Location); } private void case_377() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_378() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, (int)yyVals[yyTop], locatedToken.Location); } private void case_379() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new SimpleName(locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_380() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new SimpleName(locatedToken.Value, (int)yyVals[yyTop], locatedToken.Location); } private void case_382() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "generics"); } yyVal = yyVals[-1 + yyTop]; } private void case_383() { Error_TypeExpected(lexer.Location); yyVal = new TypeArguments(); } private void case_384() { TypeArguments typeArguments = new TypeArguments(); typeArguments.Add((FullNamedExpression)yyVals[yyTop]); yyVal = typeArguments; } private void case_385() { TypeArguments typeArguments = (TypeArguments)yyVals[-2 + yyTop]; typeArguments.Add((FullNamedExpression)yyVals[yyTop]); yyVal = typeArguments; } private void case_387() { lexer.parsing_generic_declaration = false; LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new MemberName(locatedToken.Value, (TypeParameters)yyVals[yyTop], locatedToken.Location); } private void case_388() { MemberName memberName = (MemberName)yyVals[yyTop]; if (memberName.TypeParameters != null) { syntax_error(memberName.Location, $"Member `{memberName.GetSignatureForError()}' cannot declare type arguments"); } } private void case_390() { lexer.parsing_generic_declaration = false; LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberName(locatedToken.Value, (TypeParameters)yyVals[yyTop], (ATypeNameExpression)yyVals[-2 + yyTop], locatedToken.Location); } private void case_391() { lexer.parsing_generic_declaration = false; yyVal = new MemberName("Item", GetLocation(yyVals[yyTop])); } private void case_392() { lexer.parsing_generic_declaration = false; yyVal = new MemberName("Item", null, (ATypeNameExpression)yyVals[-1 + yyTop], GetLocation(yyVals[yyTop])); } private void case_393() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new SimpleName(locatedToken.Value, (TypeArguments)yyVals[-1 + yyTop], locatedToken.Location); } private void case_394() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; LocatedToken locatedToken2 = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new QualifiedAliasMember(locatedToken.Value, locatedToken2.Value, (TypeArguments)yyVals[-1 + yyTop], locatedToken.Location); } private void case_395() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new MemberAccess((ATypeNameExpression)yyVals[-3 + yyTop], locatedToken.Value, (TypeArguments)yyVals[-1 + yyTop], locatedToken.Location); } private void case_397() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "generics"); } yyVal = yyVals[-1 + yyTop]; } private void case_398() { TypeParameters typeParameters = new TypeParameters(); typeParameters.Add((TypeParameter)yyVals[yyTop]); yyVal = typeParameters; } private void case_399() { TypeParameters typeParameters = (TypeParameters)yyVals[-2 + yyTop]; typeParameters.Add((TypeParameter)yyVals[yyTop]); yyVal = typeParameters; } private void case_400() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new TypeParameter(new MemberName(locatedToken.Value, locatedToken.Location), (Attributes)yyVals[-2 + yyTop], (VarianceDecl)yyVals[-1 + yyTop]); } private void case_401() { if (GetTokenName(yyToken) == "type") { report.Error(81, GetLocation(yyVals[yyTop]), "Type parameter declaration must be an identifier not a type"); } else { Error_SyntaxError(yyToken); } yyVal = new TypeParameter(MemberName.Null, null, null); } private void case_410() { report.Error(1536, GetLocation(yyVals[yyTop]), "Invalid parameter type `void'"); yyVal = new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[yyTop])); } private void case_413() { if (yyVals[yyTop] != null) { yyVal = new ComposedCast((ATypeNameExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); } else if (yyVals[-1 + yyTop] is SimpleName { Name: "var" } simpleName) { yyVal = new VarExpr(simpleName.Location); } else { yyVal = yyVals[-1 + yyTop]; } } private void case_416() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "tuples"); } Tuple> tuple = (Tuple>)yyVals[-2 + yyTop]; if (tuple.Item1.Count < 2) { report.Error(8124, GetLocation(yyVals[-3 + yyTop]), "Tuple must contain at least two elements"); } yyVal = new TupleTypeExpr(tuple.Item1, tuple.Item2, GetLocation(yyVals[-3 + yyTop])); if (yyVals[yyTop] != null) { yyVal = new ComposedCast((FullNamedExpression)yyVal, (ComposedTypeSpecifier)yyVals[yyTop]); } } private void case_417() { TypeArguments typeArguments = new TypeArguments(); typeArguments.Add((FullNamedExpression)yyVals[-1 + yyTop]); List list = new List(2); list.Add(((LocatedToken)yyVals[yyTop])?.Value); yyVal = Tuple.Create(typeArguments, list); } private void case_418() { Tuple> tuple = (Tuple>)yyVals[-3 + yyTop]; tuple.Item1.Add((FullNamedExpression)yyVals[-1 + yyTop]); LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; tuple.Item2.Add(locatedToken?.Value); yyVal = tuple; } private void case_422() { Expression.Error_VoidInvalidInTheContext(GetLocation(yyVals[yyTop]), report); yyVal = new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[yyTop])); } private void case_423() { if (yyVals[yyTop] != null) { yyVal = new ComposedCast((FullNamedExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); } } private void case_426() { List list = new List(2); list.Add((FullNamedExpression)yyVals[yyTop]); yyVal = list; } private void case_427() { List list = (List)yyVals[-2 + yyTop]; list.Add((FullNamedExpression)yyVals[yyTop]); yyVal = list; } private void case_428() { if (yyVals[yyTop] is ComposedCast) { report.Error(1521, GetLocation(yyVals[yyTop]), "Invalid base type `{0}'", ((ComposedCast)yyVals[yyTop]).GetSignatureForError()); } yyVal = yyVals[yyTop]; } private void case_468() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new CompletionSimpleName(MemberName.MakeName(locatedToken.Value, null), locatedToken.Location); } private void case_476() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "tuples"); } yyVal = new TupleLiteral((List)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_477() { yyVal = new List { (TupleLiteralElement)yyVals[-2 + yyTop], (TupleLiteralElement)yyVals[yyTop] }; } private void case_478() { List list = (List)yyVals[-2 + yyTop]; list.Add((TupleLiteralElement)yyVals[yyTop]); } private void case_480() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new TupleLiteralElement(locatedToken.Value, (Expression)yyVals[yyTop], locatedToken.Location); } private void case_481() { if (lang_version < LanguageVersion.V_6) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "interpolated strings"); } yyVal = new InterpolatedString((StringLiteral)yyVals[-2 + yyTop], (List)yyVals[-1 + yyTop], (StringLiteral)yyVals[yyTop]); } private void case_482() { if (lang_version < LanguageVersion.V_6) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "interpolated strings"); } yyVal = new InterpolatedString((StringLiteral)yyVals[yyTop], null, null); } private void case_483() { List list = new List(); list.Add((InterpolatedStringInsert)yyVals[yyTop]); yyVal = list; } private void case_484() { List list = (List)yyVals[-2 + yyTop]; list.Add((StringLiteral)yyVals[-1 + yyTop]); list.Add((InterpolatedStringInsert)yyVals[yyTop]); yyVal = list; } private void case_486() { yyVal = new InterpolatedStringInsert((Expression)yyVals[-2 + yyTop]) { Alignment = (Expression)yyVals[yyTop] }; } private void case_488() { lexer.parsing_interpolation_format = false; yyVal = new InterpolatedStringInsert((Expression)yyVals[-3 + yyTop]) { Format = (string)yyVals[yyTop] }; } private void case_490() { lexer.parsing_interpolation_format = false; yyVal = new InterpolatedStringInsert((Expression)yyVals[-5 + yyTop]) { Alignment = (Expression)yyVals[-3 + yyTop], Format = (string)yyVals[yyTop] }; } private void case_495() { yyVal = new ParenthesizedExpression((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_497() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_498() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, (int)yyVals[yyTop], locatedToken.Location); } private void case_499() { if (lang_version < LanguageVersion.V_6) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "null propagating operator"); } LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new ConditionalMemberAccess((Expression)yyVals[-4 + yyTop], locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_500() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_501() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess(new BaseThis(GetLocation(yyVals[-3 + yyTop])), locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_502() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess(new SimpleName("await", ((LocatedToken)yyVals[-3 + yyTop]).Location), locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_503() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; LocatedToken locatedToken2 = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new QualifiedAliasMember(locatedToken.Value, locatedToken2.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_504() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; LocatedToken locatedToken2 = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new QualifiedAliasMember(locatedToken.Value, locatedToken2.Value, (int)yyVals[yyTop], locatedToken.Location); } private void case_506() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new CompletionMemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, locatedToken.Location); } private void case_508() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new CompletionMemberAccess((Expression)yyVals[-3 + yyTop], locatedToken.Value, locatedToken.Location); } private void case_509() { yyVal = new Invocation((Expression)yyVals[-3 + yyTop], (Arguments)yyVals[-1 + yyTop]); } private void case_510() { Error_SyntaxError(yyToken); yyVal = new Invocation((Expression)yyVals[-3 + yyTop], (Arguments)yyVals[-1 + yyTop]); } private void case_511() { Error_SyntaxError(yyToken); yyVal = new Invocation((Expression)yyVals[-2 + yyTop], null); } private void case_514() { if (yyVals[-1 + yyTop] == null) { yyVal = new CollectionOrObjectInitializers(GetLocation(yyVals[-2 + yyTop])); } else { yyVal = new CollectionOrObjectInitializers((List)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } } private void case_515() { yyVal = new CollectionOrObjectInitializers((List)yyVals[-2 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_518() { List list = new List(); list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_519() { List list = (List)yyVals[-2 + yyTop]; list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_520() { Error_SyntaxError(yyToken); yyVal = yyVals[-1 + yyTop]; } private void case_521() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new ElementInitializer(locatedToken.Value, (Expression)yyVals[yyTop], locatedToken.Location); } private void case_522() { LocatedToken locatedToken = (LocatedToken)Error_AwaitAsIdentifier(yyVals[-2 + yyTop]); yyVal = new ElementInitializer(locatedToken.Value, (Expression)yyVals[yyTop], locatedToken.Location); } private void case_524() { if (!(yyVals[-1 + yyTop] is CompletionSimpleName completionSimpleName)) { yyVal = new CollectionElementInitializer((Expression)yyVals[-1 + yyTop]); } else { yyVal = new CompletionElementInitializer(completionSimpleName.Prefix, completionSimpleName.Location); } } private void case_525() { if (yyVals[-1 + yyTop] == null) { yyVal = new CollectionElementInitializer(GetLocation(yyVals[-2 + yyTop])); } else { yyVal = new CollectionElementInitializer((List)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } } private void case_526() { if (lang_version < LanguageVersion.V_6) { FeatureIsNotAvailable(GetLocation(yyVals[-4 + yyTop]), "dictionary initializer"); } yyVal = new DictionaryElementInitializer((Arguments)yyVals[-3 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_527() { report.Error(1920, GetLocation(yyVals[-1 + yyTop]), "An element initializer cannot be empty"); yyVal = new CollectionElementInitializer(GetLocation(yyVals[-1 + yyTop])); } private void case_532() { Arguments arguments = new Arguments(4); arguments.Add((Argument)yyVals[yyTop]); yyVal = arguments; } private void case_533() { Arguments arguments = (Arguments)yyVals[-2 + yyTop]; if (lang_version < LanguageVersion.V_7_2 && arguments[arguments.Count - 1] is NamedArgument) { Error_NamedArgumentExpected((NamedArgument)arguments[arguments.Count - 1]); } arguments.Add((Argument)yyVals[yyTop]); yyVal = arguments; } private void case_534() { Arguments arguments = (Arguments)yyVals[-2 + yyTop]; NamedArgument namedArgument = (NamedArgument)yyVals[yyTop]; for (int i = 0; i < arguments.Count; i++) { if (arguments[i] is NamedArgument namedArgument2 && namedArgument2.Name == namedArgument.Name) { report.Error(1740, namedArgument2.Location, "Named argument `{0}' specified multiple times", namedArgument2.Name); } } arguments.Add(namedArgument); yyVal = arguments; } private void case_535() { if (lexer.putback_char == -1) { lexer.putback(41); } Error_SyntaxError(yyToken); yyVal = yyVals[-2 + yyTop]; } private void case_536() { report.Error(839, GetLocation(yyVals[-1 + yyTop]), "An argument is missing"); yyVal = null; } private void case_541() { yyVal = new Argument((Expression)yyVals[yyTop], Argument.AType.Ref); } private void case_542() { yyVal = new Argument((Expression)yyVals[yyTop], Argument.AType.Out); } private void case_544() { yyVal = new Argument(new Arglist((Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop]))); } private void case_545() { yyVal = new Argument(new Arglist(GetLocation(yyVals[-2 + yyTop]))); } private void case_546() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "out variable declaration"); } LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable localVariable = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(localVariable); yyVal = new DeclarationExpression((FullNamedExpression)yyVals[-1 + yyTop], localVariable); } private void case_548() { yyVal = new ElementAccess((Expression)yyVals[-3 + yyTop], (Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_549() { if (lang_version < LanguageVersion.V_6) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "null propagating operator"); } yyVal = new ElementAccess((Expression)yyVals[-4 + yyTop], (Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])) { ConditionalAccess = true }; } private void case_550() { Error_SyntaxError(yyToken); yyVal = new ElementAccess((Expression)yyVals[-3 + yyTop], (Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_551() { Error_SyntaxError(yyToken); yyVal = new ElementAccess((Expression)yyVals[-2 + yyTop], null, GetLocation(yyVals[-1 + yyTop])); } private void case_552() { List list = new List(4); list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_553() { List list = (List)yyVals[-2 + yyTop]; list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_554() { Arguments arguments = new Arguments(4); arguments.Add((Argument)yyVals[yyTop]); yyVal = arguments; } private void case_555() { Arguments arguments = (Arguments)yyVals[-2 + yyTop]; if (lang_version < LanguageVersion.V_7_2 && arguments[arguments.Count - 1] is NamedArgument && !(yyVals[yyTop] is NamedArgument)) { Error_NamedArgumentExpected((NamedArgument)arguments[arguments.Count - 1]); } arguments.Add((Argument)yyVals[yyTop]); yyVal = arguments; } private void case_559() { yyVal = new ElementAccess(new BaseThis(GetLocation(yyVals[-3 + yyTop])), (Arguments)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_560() { Error_SyntaxError(yyToken); yyVal = new ElementAccess(null, null, GetLocation(yyVals[-1 + yyTop])); } private void case_563() { if (yyVals[yyTop] != null) { if (lang_version <= LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-5 + yyTop]), "object initializers"); } yyVal = new NewInitialize((FullNamedExpression)yyVals[-4 + yyTop], (Arguments)yyVals[-2 + yyTop], (CollectionOrObjectInitializers)yyVals[yyTop], GetLocation(yyVals[-5 + yyTop])); } else { yyVal = new New((FullNamedExpression)yyVals[-4 + yyTop], (Arguments)yyVals[-2 + yyTop], GetLocation(yyVals[-5 + yyTop])); } } private void case_564() { if (lang_version <= LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "collection initializers"); } yyVal = new NewInitialize((FullNamedExpression)yyVals[-1 + yyTop], null, (CollectionOrObjectInitializers)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_565() { yyVal = new ArrayCreation((FullNamedExpression)yyVals[-5 + yyTop], (List)yyVals[-3 + yyTop], new ComposedTypeSpecifier(((List)yyVals[-3 + yyTop]).Count, GetLocation(yyVals[-4 + yyTop])) { Next = (ComposedTypeSpecifier)yyVals[-1 + yyTop] }, (ArrayInitializer)yyVals[yyTop], GetLocation(yyVals[-6 + yyTop])) { NoEmptyInterpolation = true }; } private void case_566() { if (yyVals[yyTop] == null) { report.Error(1586, GetLocation(yyVals[-3 + yyTop]), "Array creation must have array size or array initializer"); } yyVal = new ArrayCreation((FullNamedExpression)yyVals[-2 + yyTop], (ComposedTypeSpecifier)yyVals[-1 + yyTop], (ArrayInitializer)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])) { NoEmptyInterpolation = true }; } private void case_567() { if (lang_version <= LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "implicitly typed arrays"); } yyVal = new ImplicitlyTypedArrayCreation((ComposedTypeSpecifier)yyVals[-1 + yyTop], (ArrayInitializer)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_568() { report.Error(178, GetLocation(yyVals[-1 + yyTop]), "Invalid rank specifier, expecting `,' or `]'"); yyVal = new ArrayCreation((FullNamedExpression)yyVals[-5 + yyTop], null, GetLocation(yyVals[-6 + yyTop])); } private void case_569() { Error_SyntaxError(yyToken); yyVal = new New((FullNamedExpression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-2 + yyTop])); } private void case_571() { lexer.parsing_type--; yyVal = yyVals[yyTop]; } private void case_572() { if (lang_version <= LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "anonymous types"); } yyVal = new NewAnonymousType((List)yyVals[-1 + yyTop], current_container, GetLocation(yyVals[-3 + yyTop])); } private void case_578() { List list = new List(4); list.Add((AnonymousTypeParameter)yyVals[yyTop]); yyVal = list; } private void case_579() { List list = (List)yyVals[-2 + yyTop]; list.Add((AnonymousTypeParameter)yyVals[yyTop]); yyVal = list; } private void case_582() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new AnonymousTypeParameter((Expression)yyVals[yyTop], locatedToken.Value, locatedToken.Location); } private void case_583() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new AnonymousTypeParameter(new SimpleName(locatedToken.Value, locatedToken.Location), locatedToken.Value, locatedToken.Location); } private void case_584() { MemberAccess memberAccess = (MemberAccess)yyVals[yyTop]; yyVal = new AnonymousTypeParameter(memberAccess, memberAccess.Name, memberAccess.Location); } private void case_585() { report.Error(746, lexer.Location, "Invalid anonymous type member declarator. Anonymous type members must be a member assignment, simple name or member access expression"); yyVal = null; } private void case_589() { ((ComposedTypeSpecifier)yyVals[-1 + yyTop]).Next = (ComposedTypeSpecifier)yyVals[yyTop]; yyVal = yyVals[-1 + yyTop]; } private void case_590() { yyVal = ComposedTypeSpecifier.CreateArrayDimension(1, GetLocation(yyVals[-1 + yyTop])); } private void case_591() { yyVal = ComposedTypeSpecifier.CreateArrayDimension((int)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_596() { ArrayInitializer arrayInitializer = new ArrayInitializer(0, GetLocation(yyVals[-1 + yyTop])); arrayInitializer.VariableDeclaration = current_variable; yyVal = arrayInitializer; } private void case_597() { ArrayInitializer arrayInitializer = new ArrayInitializer((List)yyVals[-2 + yyTop], GetLocation(yyVals[-3 + yyTop])); arrayInitializer.VariableDeclaration = current_variable; if (yyVals[-1 + yyTop] != null) { } yyVal = arrayInitializer; } private void case_598() { List list = new List(4); list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_599() { List list = (List)yyVals[-2 + yyTop]; list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_600() { yyVal = new TypeOf((FullNamedExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_602() { Error_TypeExpected(lexer.Location); yyVal = null; } private void case_603() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "generics"); } yyVal = yyVals[yyTop]; } private void case_604() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; if (lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(locatedToken.Location, "namespace alias qualifier"); } yyVal = locatedToken; } private void case_605() { yyVal = new SizeOf((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_606() { Error_SyntaxError(yyToken); yyVal = new SizeOf((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_607() { yyVal = new CheckedExpr((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_608() { Error_SyntaxError(yyToken); yyVal = new CheckedExpr(null, GetLocation(yyVals[-1 + yyTop])); } private void case_609() { yyVal = new UnCheckedExpr((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_610() { Error_SyntaxError(yyToken); yyVal = new UnCheckedExpr(null, GetLocation(yyVals[-1 + yyTop])); } private void case_611() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberAccess(new Indirection((Expression)yyVals[-3 + yyTop], GetLocation(yyVals[-2 + yyTop])), locatedToken.Value, (TypeArguments)yyVals[yyTop], locatedToken.Location); } private void case_619() { valid_param_mod = (ParameterModifierType)0; yyVal = yyVals[-1 + yyTop]; } private void case_620() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "default value expression"); } yyVal = new DefaultValueExpression((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_621() { if (lang_version < LanguageVersion.V_7_1) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "default literal"); } yyVal = new DefaultLiteralExpression(GetLocation(yyVals[yyTop])); } private void case_625() { yyVal = new Cast((FullNamedExpression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_626() { if (!async_block) { if (current_anonymous_method is LambdaExpression) { report.Error(4034, GetLocation(yyVals[-1 + yyTop]), "The `await' operator can only be used when its containing lambda expression is marked with the `async' modifier"); } else if (current_anonymous_method != null) { report.Error(4035, GetLocation(yyVals[-1 + yyTop]), "The `await' operator can only be used when its containing anonymous method is marked with the `async' modifier"); } else if (interactive_async.HasValue) { current_block.Explicit.RegisterAsyncAwait(); interactive_async = true; } else { report.Error(4033, GetLocation(yyVals[-1 + yyTop]), "The `await' operator can only be used when its containing method is marked with the `async' modifier"); } } else { current_block.Explicit.RegisterAsyncAwait(); } yyVal = new Await((Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_627() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(lexer.Location, "throw expression"); } yyVal = new ThrowExpression((Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_628() { Error_SyntaxError(yyToken); yyVal = new Unary(Unary.Operator.LogicalNot, null, GetLocation(yyVals[-1 + yyTop])); } private void case_629() { Error_SyntaxError(yyToken); yyVal = new Unary(Unary.Operator.OnesComplement, null, GetLocation(yyVals[-1 + yyTop])); } private void case_630() { Error_SyntaxError(yyToken); yyVal = new Cast((FullNamedExpression)yyVals[-2 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_631() { Error_SyntaxError(yyToken); yyVal = new Await(null, GetLocation(yyVals[-1 + yyTop])); } private void case_639() { Error_SyntaxError(yyToken); yyVal = new Unary(Unary.Operator.UnaryPlus, null, GetLocation(yyVals[-1 + yyTop])); } private void case_640() { Error_SyntaxError(yyToken); yyVal = new Unary(Unary.Operator.UnaryNegation, null, GetLocation(yyVals[-1 + yyTop])); } private void case_641() { Error_SyntaxError(yyToken); yyVal = new UnaryMutator(UnaryMutator.Mode.IsIncrement, null, GetLocation(yyVals[-1 + yyTop])); } private void case_642() { Error_SyntaxError(yyToken); yyVal = new UnaryMutator(UnaryMutator.Mode.IsDecrement, null, GetLocation(yyVals[-1 + yyTop])); } private void case_643() { Error_SyntaxError(yyToken); yyVal = new Indirection(null, GetLocation(yyVals[-1 + yyTop])); } private void case_644() { Error_SyntaxError(yyToken); yyVal = new Unary(Unary.Operator.AddressOf, null, GetLocation(yyVals[-1 + yyTop])); } private void case_646() { yyVal = new Binary(Binary.Operator.Multiply, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_647() { yyVal = new Binary(Binary.Operator.Division, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_648() { yyVal = new Binary(Binary.Operator.Modulus, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_649() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Multiply, (Expression)yyVals[-2 + yyTop], null); } private void case_650() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Division, (Expression)yyVals[-2 + yyTop], null); } private void case_651() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Modulus, (Expression)yyVals[-2 + yyTop], null); } private void case_653() { yyVal = new Binary(Binary.Operator.Addition, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_654() { yyVal = new Binary(Binary.Operator.Subtraction, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_655() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Addition, (Expression)yyVals[-2 + yyTop], null); } private void case_656() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Subtraction, (Expression)yyVals[-2 + yyTop], null); } private void case_658() { Is obj = new Is((Expression)yyVals[-3 + yyTop], (FullNamedExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); if (yyVals[yyTop] != null) { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[yyTop]), "pattern matching"); } LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable localVariable = (obj.Variable = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location)); current_block.AddLocalName(localVariable.Name, localVariable, canShadowChildrenBlockName: true); } yyVal = obj; } private void case_659() { Is obj = new Is((Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); if (lang_version != LanguageVersion.Experimental) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "pattern matching"); } yyVal = obj; } private void case_660() { Error_SyntaxError(yyToken); yyVal = new As((Expression)yyVals[-2 + yyTop], null, GetLocation(yyVals[-1 + yyTop])); } private void case_661() { Error_SyntaxError(yyToken); yyVal = new Is((Expression)yyVals[-2 + yyTop], null, GetLocation(yyVals[-1 + yyTop])); } private void case_662() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new Is(new SimpleName(locatedToken.Value, locatedToken.Location), (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_663() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new As(new SimpleName(locatedToken.Value, locatedToken.Location), (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_670() { yyVal = new Cast((FullNamedExpression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_674() { List list = new List(); list.Add((PropertyPatternMember)yyVals[yyTop]); yyVal = list; } private void case_675() { List list = (List)yyVals[-2 + yyTop]; list.Add((PropertyPatternMember)yyVals[yyTop]); yyVal = list; } private void case_676() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new PropertyPatternMember(locatedToken.Value, (Expression)yyVals[yyTop], locatedToken.Location); } private void case_678() { if (yyVals[yyTop] != null) { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(li); } } private void case_680() { yyVal = new Binary(Binary.Operator.LeftShift, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_681() { yyVal = new Binary(Binary.Operator.RightShift, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_682() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.LeftShift, (Expression)yyVals[-2 + yyTop], null); } private void case_683() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.RightShift, (Expression)yyVals[-2 + yyTop], null); } private void case_685() { yyVal = new Binary(Binary.Operator.LessThan, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_686() { yyVal = new Binary(Binary.Operator.GreaterThan, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_687() { yyVal = new Binary(Binary.Operator.LessThanOrEqual, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_688() { yyVal = new Binary(Binary.Operator.GreaterThanOrEqual, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_689() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.LessThan, (Expression)yyVals[-2 + yyTop], null); } private void case_690() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.GreaterThan, (Expression)yyVals[-2 + yyTop], null); } private void case_691() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.LessThanOrEqual, (Expression)yyVals[-2 + yyTop], null); } private void case_692() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.GreaterThanOrEqual, (Expression)yyVals[-2 + yyTop], null); } private void case_694() { yyVal = new Binary(Binary.Operator.Equality, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_695() { yyVal = new Binary(Binary.Operator.Inequality, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_696() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Equality, (Expression)yyVals[-2 + yyTop], null); } private void case_697() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.Inequality, (Expression)yyVals[-2 + yyTop], null); } private void case_699() { yyVal = new Binary(Binary.Operator.BitwiseAnd, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_700() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.BitwiseAnd, (Expression)yyVals[-2 + yyTop], null); } private void case_702() { yyVal = new Binary(Binary.Operator.ExclusiveOr, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_703() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.ExclusiveOr, (Expression)yyVals[-2 + yyTop], null); } private void case_705() { yyVal = new Binary(Binary.Operator.BitwiseOr, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_706() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.BitwiseOr, (Expression)yyVals[-2 + yyTop], null); } private void case_708() { yyVal = new Binary(Binary.Operator.LogicalAnd, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_709() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.LogicalAnd, (Expression)yyVals[-2 + yyTop], null); } private void case_711() { yyVal = new Binary(Binary.Operator.LogicalOr, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_712() { Error_SyntaxError(yyToken); yyVal = new Binary(Binary.Operator.LogicalOr, (Expression)yyVals[-2 + yyTop], null); } private void case_714() { if (lang_version < LanguageVersion.ISO_2) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "null coalescing operator"); } yyVal = new NullCoalescingOperator((Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_718() { yyVal = new Conditional(new BooleanExpression((Expression)yyVals[-4 + yyTop]), (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_719() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "throw expression"); } ThrowExpression false_expr = new ThrowExpression((Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); yyVal = new Conditional(new BooleanExpression((Expression)yyVals[-5 + yyTop]), (Expression)yyVals[-3 + yyTop], false_expr, GetLocation(yyVals[-4 + yyTop])); } private void case_720() { yyVal = new Conditional(new BooleanExpression((Expression)yyVals[-4 + yyTop]), (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_721() { Error_SyntaxError(yyToken); yyVal = new Conditional(new BooleanExpression((Expression)yyVals[-3 + yyTop]), (Expression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-2 + yyTop])); } private void case_722() { Error_SyntaxError(yyToken); yyVal = new Conditional(new BooleanExpression((Expression)yyVals[-4 + yyTop]), (Expression)yyVals[-2 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_723() { Error_SyntaxError(374); yyVal = new Conditional(new BooleanExpression((Expression)yyVals[-4 + yyTop]), (Expression)yyVals[-2 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); lexer.putback(125); } private void case_724() { yyVal = new SimpleAssign((Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_725() { yyVal = new CompoundAssign(Binary.Operator.Multiply, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_726() { yyVal = new CompoundAssign(Binary.Operator.Division, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_727() { yyVal = new CompoundAssign(Binary.Operator.Modulus, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_728() { yyVal = new CompoundAssign(Binary.Operator.Addition, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_729() { yyVal = new CompoundAssign(Binary.Operator.Subtraction, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_730() { yyVal = new CompoundAssign(Binary.Operator.LeftShift, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_731() { yyVal = new CompoundAssign(Binary.Operator.RightShift, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_732() { yyVal = new CompoundAssign(Binary.Operator.BitwiseAnd, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_733() { yyVal = new CompoundAssign(Binary.Operator.BitwiseOr, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_734() { yyVal = new CompoundAssign(Binary.Operator.ExclusiveOr, (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop]); } private void case_735() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-4 + yyTop]), "tuples"); } List targetExprs = (List)yyVals[-3 + yyTop]; yyVal = new TupleDeconstruct(targetExprs, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_736() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-4 + yyTop]), "tuples"); } List variables = (List)yyVals[-3 + yyTop]; yyVal = new TupleDeconstruct(variables, (Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_737() { yyVal = new List { (Expression)yyVals[-2 + yyTop], (Expression)yyVals[yyTop] }; } private void case_738() { List list = (List)yyVals[-2 + yyTop]; list.Add((Expression)yyVals[yyTop]); yyVal = list; } private void case_739() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(li); yyVal = new List(2) { new BlockVariable((FullNamedExpression)yyVals[-1 + yyTop], li) }; } private void case_740() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(li); List list = (List)yyVals[-3 + yyTop]; list.Add(new BlockVariable((FullNamedExpression)yyVals[-1 + yyTop], li)); yyVal = list; } private void case_741() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable localVariable = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); if (locatedToken.Value != "_") { report.Error(8184, locatedToken.Location, "A deconstruction cannot mix declarations and expressions on the left-hand-side"); } else { localVariable.Type = InternalType.Discard; } List list = (List)yyVals[-2 + yyTop]; list.Add(new BlockVariable(new TypeExpression(localVariable.Type, locatedToken.Location), localVariable)); yyVal = list; } private void case_742() { List list = new List(4); list.Add((Parameter)yyVals[yyTop]); yyVal = list; } private void case_743() { List list = (List)yyVals[-2 + yyTop]; Parameter parameter = (Parameter)yyVals[yyTop]; if ((object)list[0].GetType() != parameter.GetType()) { report.Error(748, parameter.Location, "All lambda parameters must be typed either explicitly or implicitly"); } list.Add(parameter); yyVal = list; } private void case_744() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new Parameter((FullNamedExpression)yyVals[-1 + yyTop], locatedToken.Value, (Parameter.Modifier)yyVals[-2 + yyTop], null, locatedToken.Location); } private void case_745() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new Parameter((FullNamedExpression)yyVals[-1 + yyTop], locatedToken.Value, Parameter.Modifier.NONE, null, locatedToken.Location); } private void case_746() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; yyVal = new ImplicitLambdaParameter(locatedToken.Value, locatedToken.Location); } private void case_747() { LocatedToken locatedToken = (LocatedToken)Error_AwaitAsIdentifier(yyVals[yyTop]); yyVal = new ImplicitLambdaParameter(locatedToken.Value, locatedToken.Location); } private void case_749() { List list = (List)yyVals[yyTop]; yyVal = new ParametersCompiled(list.ToArray()); } private void case_751() { Block block = end_block(Location.Null); block.IsCompilerGenerated = true; block.AddStatement(new ContextualReturn((Expression)yyVals[yyTop])); yyVal = block; } private void case_753() { Block block = end_block(Location.Null); block.IsCompilerGenerated = true; Error_SyntaxError(yyToken); yyVal = null; } private void case_757() { Error_SyntaxError(yyToken); yyVal = null; } private void case_758() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; Parameter parameter = new ImplicitLambdaParameter(locatedToken.Value, locatedToken.Location); start_anonymous(isLambda: true, new ParametersCompiled(parameter), isAsync: false, locatedToken.Location); } private void case_759() { yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); } private void case_760() { LocatedToken locatedToken = (LocatedToken)Error_AwaitAsIdentifier(yyVals[-1 + yyTop]); Parameter parameter = new ImplicitLambdaParameter(locatedToken.Value, locatedToken.Location); start_anonymous(isLambda: true, new ParametersCompiled(parameter), isAsync: false, locatedToken.Location); } private void case_761() { yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); } private void case_762() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; Parameter parameter = new ImplicitLambdaParameter(locatedToken.Value, locatedToken.Location); start_anonymous(isLambda: true, new ParametersCompiled(parameter), isAsync: true, locatedToken.Location); } private void case_763() { yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); } private void case_765() { valid_param_mod = (ParameterModifierType)0; start_anonymous(isLambda: true, (ParametersCompiled)yyVals[-2 + yyTop], isAsync: false, GetLocation(yyVals[-4 + yyTop])); } private void case_766() { yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); } private void case_768() { valid_param_mod = (ParameterModifierType)0; start_anonymous(isLambda: true, (ParametersCompiled)yyVals[-2 + yyTop], isAsync: true, GetLocation(yyVals[-5 + yyTop])); } private void case_769() { yyVal = end_anonymous((ParametersBlock)yyVals[yyTop]); } private void case_776() { yyVal = new RefValueExpr((Expression)yyVals[-3 + yyTop], (FullNamedExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-5 + yyTop])); } private void case_777() { yyVal = new RefTypeExpr((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_778() { yyVal = new MakeRefExpr((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_783() { yyVal = yyVals[-1 + yyTop]; if (lang_version != LanguageVersion.Experimental) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "primary constructor"); } } private void case_788() { lexer.parsing_block++; current_type.PrimaryConstructorBaseArgumentsStart = GetLocation(yyVals[yyTop]); } private void case_789() { current_type.PrimaryConstructorBaseArguments = (Arguments)yyVals[-1 + yyTop]; lexer.parsing_block--; yyVal = yyVals[-5 + yyTop]; } private void case_791() { lexer.ConstraintsParsing = true; Class obj = new Class(current_container, (MemberName)yyVals[yyTop], (Modifiers)yyVals[-4 + yyTop], (Attributes)yyVals[-5 + yyTop]); if ((obj.ModFlags & Modifiers.STATIC) != 0 && lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(obj.Location, "static classes"); } push_current_container(obj, yyVals[-3 + yyTop]); valid_param_mod = ParameterModifierType.PrimaryConstructor; } private void case_792() { valid_param_mod = (ParameterModifierType)0; lexer.ConstraintsParsing = false; if (yyVals[-1 + yyTop] != null) { current_type.PrimaryConstructorParameters = (ParametersCompiled)yyVals[-1 + yyTop]; } if (yyVals[yyTop] != null) { current_container.SetConstraints((List)yyVals[yyTop]); } if (doc_support) { current_container.PartialContainer.DocComment = Lexer.consume_doc_comment(); Lexer.doc_state = XmlCommentState.Allowed; } lexer.parsing_modifiers = true; } private void case_793() { lexer.parsing_declaration--; if (doc_support) { Lexer.doc_state = XmlCommentState.Allowed; } } private void case_794() { if (yyVals[yyTop] == null) { } yyVal = pop_current_class(); } private void case_797() { mod_locations = null; yyVal = ModifierNone; lexer.parsing_modifiers = false; } private void case_800() { Modifiers modifiers = (Modifiers)yyVals[-1 + yyTop]; Modifiers modifiers2 = (Modifiers)yyVals[yyTop]; if ((modifiers & modifiers2) != 0) { report.Error(1004, lexer.Location - ModifiersExtensions.Name(modifiers2).Length, "Duplicate `{0}' modifier", ModifiersExtensions.Name(modifiers2)); } else if ((modifiers2 & Modifiers.AccessibilityMask) != 0 && (modifiers & Modifiers.AccessibilityMask) != 0) { switch (modifiers2 | (modifiers & Modifiers.AccessibilityMask)) { case Modifiers.PROTECTED | Modifiers.PRIVATE: if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(lexer.Location, "private protected"); } break; default: report.Error(107, lexer.Location - ModifiersExtensions.Name(modifiers2).Length, "More than one protection modifier specified"); break; case Modifiers.PROTECTED | Modifiers.INTERNAL: break; } } yyVal = modifiers | modifiers2; } private void case_801() { yyVal = Modifiers.NEW; if (current_container.Kind == MemberKind.Namespace) { report.Error(1530, GetLocation(yyVals[yyTop]), "Keyword `new' is not allowed on namespace elements"); } } private void case_802() { yyVal = Modifiers.PUBLIC; } private void case_803() { yyVal = Modifiers.PROTECTED; } private void case_804() { yyVal = Modifiers.INTERNAL; } private void case_805() { yyVal = Modifiers.PRIVATE; } private void case_806() { yyVal = Modifiers.ABSTRACT; } private void case_807() { yyVal = Modifiers.SEALED; } private void case_808() { yyVal = Modifiers.STATIC; } private void case_809() { yyVal = Modifiers.READONLY; } private void case_810() { yyVal = Modifiers.VIRTUAL; } private void case_811() { yyVal = Modifiers.OVERRIDE; } private void case_812() { yyVal = Modifiers.EXTERN; } private void case_813() { yyVal = Modifiers.VOLATILE; } private void case_814() { yyVal = Modifiers.UNSAFE; if (!settings.Unsafe) { Error_UnsafeCodeNotAllowed(GetLocation(yyVals[yyTop])); } } private void case_815() { yyVal = Modifiers.ASYNC; } private void case_819() { Error_SyntaxError(yyToken); current_type.SetBaseTypes((List)yyVals[-1 + yyTop]); } private void case_822() { List list = new List(1); list.Add((Constraints)yyVals[yyTop]); yyVal = list; } private void case_823() { List list = (List)yyVals[-1 + yyTop]; Constraints constraints = (Constraints)yyVals[yyTop]; foreach (Constraints item in list) { if (constraints.TypeParameter.Value == item.TypeParameter.Value) { report.Error(409, constraints.Location, "A constraint clause has already been specified for type parameter `{0}'", constraints.TypeParameter.Value); } } list.Add(constraints); yyVal = list; } private void case_824() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; yyVal = new Constraints(new SimpleMemberName(locatedToken.Value, locatedToken.Location), (List)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_825() { Error_SyntaxError(yyToken); LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new Constraints(new SimpleMemberName(locatedToken.Value, locatedToken.Location), null, GetLocation(yyVals[-2 + yyTop])); } private void case_826() { List list = new List(1); list.Add((FullNamedExpression)yyVals[yyTop]); yyVal = list; } private void case_827() { List list = (List)yyVals[-2 + yyTop]; if (list[list.Count - 1] is SpecialContraintExpr specialContraintExpr && (specialContraintExpr.Constraint & SpecialConstraint.Constructor) != SpecialConstraint.None) { report.Error(401, GetLocation(yyVals[-1 + yyTop]), "The `new()' constraint must be the last constraint specified"); } if (yyVals[yyTop] is SpecialContraintExpr specialContraintExpr2) { if ((specialContraintExpr2.Constraint & (SpecialConstraint.Class | SpecialConstraint.Struct)) != SpecialConstraint.None) { report.Error(449, specialContraintExpr2.Location, "The `class' or `struct' constraint must be the first constraint specified"); } else if (list[0] is SpecialContraintExpr specialContraintExpr3 && (specialContraintExpr3.Constraint & SpecialConstraint.Struct) != SpecialConstraint.None) { report.Error(451, GetLocation(yyVals[yyTop]), "The `new()' constraint cannot be used with the `struct' constraint"); } } list.Add((FullNamedExpression)yyVals[yyTop]); yyVal = list; } private void case_828() { if (yyVals[yyTop] is ComposedCast) { report.Error(706, GetLocation(yyVals[yyTop]), "Invalid constraint type `{0}'", ((ComposedCast)yyVals[yyTop]).GetSignatureForError()); } yyVal = yyVals[yyTop]; } private void case_829() { yyVal = new SpecialContraintExpr(SpecialConstraint.Constructor, GetLocation(yyVals[-2 + yyTop])); } private void case_833() { if (lang_version <= LanguageVersion.V_3) { FeatureIsNotAvailable(lexer.Location, "generic type variance"); } yyVal = yyVals[yyTop]; } private void case_836() { lexer.parsing_block++; start_block(GetLocation(yyVals[yyTop])); } private void case_838() { lexer.parsing_block--; yyVal = end_block(GetLocation(yyVals[yyTop])); } private void case_839() { lexer.parsing_block--; yyVal = end_block(lexer.Location); } private void case_840() { lexer.parsing_block++; current_block.StartLocation = GetLocation(yyVals[yyTop]); } private void case_841() { lexer.parsing_block--; yyVal = end_block(GetLocation(yyVals[yyTop])); } private void case_849() { Error_SyntaxError(yyToken); yyVal = null; } private void case_882() { report.Error(1023, GetLocation(yyVals[yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } private void case_883() { report.Error(1023, GetLocation(yyVals[yyTop]), "An embedded statement may not be a declaration or labeled statement"); yyVal = null; } private void case_884() { Error_SyntaxError(yyToken); yyVal = new EmptyStatement(GetLocation(yyVals[yyTop])); } private void case_885() { yyVal = new EmptyStatement(lexer.Location); } private void case_886() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; LabeledStatement labeledStatement = new LabeledStatement(locatedToken.Value, current_block, locatedToken.Location); current_block.AddLabel(labeledStatement); current_block.AddStatement(labeledStatement); } private void case_889() { if (yyVals[-1 + yyTop] is VarExpr) { yyVals[-1 + yyTop] = new SimpleName("var", ((VarExpr)yyVals[-1 + yyTop]).Location); } yyVal = new ComposedCast((FullNamedExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); } private void case_890() { ATypeNameExpression aTypeNameExpression = (ATypeNameExpression)yyVals[-1 + yyTop]; if (yyVals[yyTop] == null) { if (aTypeNameExpression.Name == "var" && aTypeNameExpression is SimpleName) { yyVal = new VarExpr(aTypeNameExpression.Location); } else { yyVal = yyVals[-1 + yyTop]; } } else { yyVal = new ComposedCast(aTypeNameExpression, (ComposedTypeSpecifier)yyVals[yyTop]); } } private void case_891() { ATypeNameExpression left = (ATypeNameExpression)yyVals[-1 + yyTop]; yyVal = new ComposedCast(left, (ComposedTypeSpecifier)yyVals[yyTop]); } private void case_893() { if (yyVals[yyTop] == null) { yyVal = yyVals[-1 + yyTop]; } else { yyVal = new ComposedCast((FullNamedExpression)yyVals[-1 + yyTop], (ComposedTypeSpecifier)yyVals[yyTop]); } } private void case_895() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "tuples"); } Tuple> tuple = (Tuple>)yyVals[-1 + yyTop]; yyVal = new TupleTypeExpr(tuple.Item1, tuple.Item2, GetLocation(yyVals[-2 + yyTop])); } private void case_896() { TypeArguments typeArguments = new TypeArguments(); typeArguments.Add((FullNamedExpression)yyVals[-4 + yyTop]); typeArguments.Add((FullNamedExpression)yyVals[-1 + yyTop]); List list = new List(2); list.Add(((LocatedToken)yyVals[-3 + yyTop])?.Value); list.Add(((LocatedToken)yyVals[yyTop])?.Value); yyVal = Tuple.Create(typeArguments, list); } private void case_897() { Tuple> tuple = (Tuple>)yyVals[-3 + yyTop]; tuple.Item1.Add((FullNamedExpression)yyVals[-1 + yyTop]); LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; tuple.Item2.Add(locatedToken?.Value); yyVal = tuple; } private void case_899() { ((ComposedTypeSpecifier)yyVals[-1 + yyTop]).Next = (ComposedTypeSpecifier)yyVals[yyTop]; yyVal = yyVals[-1 + yyTop]; } private void case_903() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(li); current_variable = new BlockVariable((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_904() { yyVal = current_variable; current_variable = null; if (yyVals[-2 + yyTop] == null) { } } private void case_905() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.Constant, locatedToken.Location); current_block.AddLocalName(li); current_variable = new BlockConstant((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_906() { yyVal = current_variable; current_variable = null; } private void case_907() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "byref locals and returns"); } LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.ByRef, locatedToken.Location); current_block.AddLocalName(li); current_variable = new BlockVariable((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_908() { yyVal = current_variable; current_variable = null; if (yyVals[-2 + yyTop] == null) { report.Error(8174, GetLocation(yyVals[-4 + yyTop]), "A declaration of a by-reference variable must have an initializer"); } } private void case_909() { if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[-2 + yyTop]), "readonly references"); } LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.ByRef | LocalVariable.Flags.ReadonlyMask, locatedToken.Location); current_block.AddLocalName(li); current_variable = new BlockVariable((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_910() { yyVal = current_variable; current_variable = null; if (yyVals[-2 + yyTop] == null) { report.Error(8174, GetLocation(yyVals[-5 + yyTop]), "A declaration of a by-reference variable must have an initializer"); } } private void case_912() { current_variable.Initializer = (Expression)yyVals[yyTop]; yyVal = current_variable; } private void case_913() { if (yyToken == 429) { report.Error(650, lexer.Location, "Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier. To declare a fixed size buffer field, use the fixed keyword before the field type"); } else { Error_SyntaxError(yyToken); } } private void case_917() { foreach (BlockVariableDeclarator declarator in current_variable.Declarators) { if (declarator.Initializer == null) { Error_MissingInitializer(declarator.Variable.Location); } } } private void case_920() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_variable.Variable, locatedToken.Value, locatedToken.Location); BlockVariableDeclarator decl = new BlockVariableDeclarator(li, null); current_variable.AddDeclarator(decl); current_block.AddLocalName(li); } private void case_921() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; LocalVariable li = new LocalVariable(current_variable.Variable, locatedToken.Value, locatedToken.Location); BlockVariableDeclarator decl = new BlockVariableDeclarator(li, (Expression)yyVals[yyTop]); current_variable.AddDeclarator(decl); current_block.AddLocalName(li); } private void case_928() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.Constant, locatedToken.Location); BlockVariableDeclarator decl = new BlockVariableDeclarator(li, (Expression)yyVals[yyTop]); current_variable.AddDeclarator(decl); current_block.AddLocalName(li); } private void case_930() { yyVal = new StackAlloc((Expression)yyVals[-3 + yyTop], (Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_931() { report.Error(1575, GetLocation(yyVals[-1 + yyTop]), "A stackalloc expression requires [] after type"); yyVal = new StackAlloc((Expression)yyVals[yyTop], null, GetLocation(yyVals[-1 + yyTop])); } private void case_933() { if (lang_version < LanguageVersion.V_7_2) { FeatureIsNotAvailable(GetLocation(yyVals[-4 + yyTop]), "ref structs"); } yyVal = new SpanStackAlloc((Expression)yyVals[-3 + yyTop], (Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_934() { report.Error(1575, GetLocation(yyVals[-1 + yyTop]), "A stackalloc expression requires [] after type"); yyVal = new StackAlloc((Expression)yyVals[yyTop], null, GetLocation(yyVals[-1 + yyTop])); } private void case_935() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-1 + yyTop]), "byref locals and returns"); } yyVal = new ReferenceExpression((Expression)yyVals[yyTop], GetLocation(yyVals[-1 + yyTop])); } private void case_936() { yyVal = yyVals[-1 + yyTop]; } private void case_938() { yyVal = yyVals[-1 + yyTop]; report.Error(1002, GetLocation(yyVals[yyTop]), "; expected"); lexer.putback(125); } private void case_941() { if (!(yyVals[yyTop] is ExpressionStatement expr)) { Expression expr2 = yyVals[yyTop] as Expression; yyVal = new StatementErrorExpression(expr2); } else { yyVal = new StatementExpression(expr); } } private void case_942() { Expression s = (Expression)yyVals[yyTop]; yyVal = new StatementExpression(new OptionalAssign(s, lexer.Location)); } private void case_943() { Error_SyntaxError(yyToken); yyVal = new EmptyStatement(GetLocation(yyVals[yyTop])); } private void case_946() { if (yyVals[yyTop] is EmptyStatement) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } yyVal = new If((BooleanExpression)yyVals[-2 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_947() { yyVal = new If((BooleanExpression)yyVals[-4 + yyTop], (Statement)yyVals[-2 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-6 + yyTop])); if (yyVals[-2 + yyTop] is EmptyStatement) { Warning_EmptyStatement(GetLocation(yyVals[-2 + yyTop])); } if (yyVals[yyTop] is EmptyStatement) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } } private void case_948() { Error_SyntaxError(yyToken); yyVal = new If((BooleanExpression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_950() { yyVal = new Switch((Expression)yyVals[-5 + yyTop], current_block.Explicit, GetLocation(yyVals[-7 + yyTop])); end_block(GetLocation(yyVals[yyTop])); } private void case_951() { Error_SyntaxError(yyToken); yyVal = new Switch((Expression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_958() { SwitchLabel switchLabel = (SwitchLabel)yyVals[yyTop]; switchLabel.SectionStart = true; current_block.AddStatement(switchLabel); } private void case_960() { yyVal = new SwitchLabel((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_961() { Error_SyntaxError(yyToken); yyVal = new SwitchLabel((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_962() { if (lang_version < LanguageVersion.V_7) { FeatureIsNotAvailable(GetLocation(yyVals[-3 + yyTop]), "pattern matching"); } throw new NotImplementedException("type pattern matching"); } private void case_968() { if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } yyVal = new While((BooleanExpression)yyVals[-2 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_969() { Error_SyntaxError(yyToken); yyVal = new While((BooleanExpression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_970() { yyVal = new Do((Statement)yyVals[-5 + yyTop], (BooleanExpression)yyVals[-2 + yyTop], GetLocation(yyVals[-6 + yyTop]), GetLocation(yyVals[-4 + yyTop])); } private void case_971() { Error_SyntaxError(yyToken); yyVal = new Do((Statement)yyVals[-1 + yyTop], null, GetLocation(yyVals[-2 + yyTop]), Location.Null); } private void case_972() { Error_SyntaxError(yyToken); yyVal = new Do((Statement)yyVals[-4 + yyTop], (BooleanExpression)yyVals[-1 + yyTop], GetLocation(yyVals[-5 + yyTop]), GetLocation(yyVals[-3 + yyTop])); } private void case_973() { start_block(GetLocation(yyVals[yyTop])); current_block.IsCompilerGenerated = true; For s = new For(GetLocation(yyVals[-1 + yyTop])); current_block.AddStatement(s); yyVal = s; } private void case_975() { ((For)yyVals[-2 + yyTop]).Initializer = (Statement)yyVals[-1 + yyTop]; oob_stack.Push(yyVals[-2 + yyTop]); } private void case_976() { Tuple tuple = (Tuple)yyVals[-1 + yyTop]; oob_stack.Pop(); if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } For obj = (For)yyVals[-5 + yyTop]; obj.Statement = (Statement)yyVals[yyTop]; yyVal = end_block(GetLocation(yyVals[-3 + yyTop])); } private void case_977() { Error_SyntaxError(yyToken); yyVal = end_block(current_block.StartLocation); } private void case_978() { For obj = (For)oob_stack.Peek(); obj.Condition = (BooleanExpression)yyVals[-1 + yyTop]; } private void case_980() { report.Error(1525, GetLocation(yyVals[yyTop]), "Unexpected symbol `}'"); For obj = (For)oob_stack.Peek(); obj.Condition = (BooleanExpression)yyVals[-1 + yyTop]; yyVal = new Tuple(GetLocation(yyVals[yyTop]), GetLocation(yyVals[yyTop])); } private void case_981() { For obj = (For)oob_stack.Peek(); obj.Iterator = (Statement)yyVals[-1 + yyTop]; yyVal = GetLocation(yyVals[yyTop]); } private void case_982() { report.Error(1525, GetLocation(yyVals[yyTop]), "Unexpected symbol expected ')'"); For obj = (For)oob_stack.Peek(); obj.Iterator = (Statement)yyVals[-1 + yyTop]; yyVal = GetLocation(yyVals[yyTop]); } private void case_987() { LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(li); current_variable = new BlockVariable((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_988() { yyVal = current_variable; if (yyVals[-1 + yyTop] != null) { } current_variable = null; } private void case_996() { StatementList statementList = yyVals[-2 + yyTop] as StatementList; if (statementList == null) { statementList = new StatementList((Statement)yyVals[-2 + yyTop], (Statement)yyVals[yyTop]); } else { statementList.Add((Statement)yyVals[yyTop]); } yyVal = statementList; } private void case_997() { report.Error(230, GetLocation(yyVals[-3 + yyTop]), "Type and identifier are both required in a foreach statement"); start_block(GetLocation(yyVals[-2 + yyTop])); current_block.IsCompilerGenerated = true; Foreach s = new Foreach((Expression)yyVals[-1 + yyTop], null, null, null, null, GetLocation(yyVals[-3 + yyTop])); current_block.AddStatement(s); yyVal = end_block(GetLocation(yyVals[yyTop])); } private void case_998() { Error_SyntaxError(yyToken); start_block(GetLocation(yyVals[-3 + yyTop])); current_block.IsCompilerGenerated = true; LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; LocalVariable localVariable = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, locatedToken.Location); current_block.AddLocalName(localVariable); Foreach s = new Foreach((Expression)yyVals[-2 + yyTop], localVariable, null, null, null, GetLocation(yyVals[-4 + yyTop])); current_block.AddStatement(s); yyVal = end_block(GetLocation(yyVals[yyTop])); } private void case_999() { start_block(GetLocation(yyVals[-5 + yyTop])); current_block.IsCompilerGenerated = true; LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, locatedToken.Location); current_block.AddLocalName(li); yyVal = li; } private void case_1000() { if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } Foreach obj = new Foreach((Expression)yyVals[-6 + yyTop], (LocalVariable)yyVals[-1 + yyTop], (Expression)yyVals[-3 + yyTop], (Statement)yyVals[yyTop], current_block, GetLocation(yyVals[-8 + yyTop])); end_block(GetLocation(yyVals[-2 + yyTop])); yyVal = obj; } private void case_1007() { yyVal = new Break(GetLocation(yyVals[-1 + yyTop])); } private void case_1008() { yyVal = new Continue(GetLocation(yyVals[-1 + yyTop])); } private void case_1009() { Error_SyntaxError(yyToken); yyVal = new Continue(GetLocation(yyVals[-1 + yyTop])); } private void case_1010() { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new Goto(locatedToken.Value, GetLocation(yyVals[-2 + yyTop])); } private void case_1011() { yyVal = new GotoCase((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_1012() { yyVal = new GotoDefault(GetLocation(yyVals[-2 + yyTop])); } private void case_1013() { yyVal = new Return((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_1014() { yyVal = new Return((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_1015() { Error_SyntaxError(yyToken); yyVal = new Return((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_1016() { Error_SyntaxError(yyToken); yyVal = new Return(null, GetLocation(yyVals[-1 + yyTop])); } private void case_1017() { yyVal = new Throw((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_1018() { yyVal = new Throw(null, GetLocation(yyVals[-1 + yyTop])); } private void case_1019() { Error_SyntaxError(yyToken); yyVal = new Throw((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-2 + yyTop])); } private void case_1020() { Error_SyntaxError(yyToken); yyVal = new Throw(null, GetLocation(yyVals[-1 + yyTop])); } private void case_1021() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; string value = locatedToken.Value; if (value != "yield") { report.Error(1003, locatedToken.Location, "; expected"); } else if (yyVals[-1 + yyTop] == null) { report.Error(1627, GetLocation(yyVals[yyTop]), "Expression expected after yield return"); } else if (lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(locatedToken.Location, "iterators"); } current_block.Explicit.RegisterIteratorYield(); yyVal = new Yield((Expression)yyVals[-1 + yyTop], locatedToken.Location); } private void case_1022() { Error_SyntaxError(yyToken); LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; string value = locatedToken.Value; if (value != "yield") { report.Error(1003, locatedToken.Location, "; expected"); } else if (yyVals[-1 + yyTop] == null) { report.Error(1627, GetLocation(yyVals[yyTop]), "Expression expected after yield return"); } else if (lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(locatedToken.Location, "iterators"); } current_block.Explicit.RegisterIteratorYield(); yyVal = new Yield((Expression)yyVals[-1 + yyTop], locatedToken.Location); } private void case_1023() { LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; string value = locatedToken.Value; if (value != "yield") { report.Error(1003, locatedToken.Location, "; expected"); } else if (lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(locatedToken.Location, "iterators"); } current_block.ParametersBlock.TopBlock.IsIterator = true; yyVal = new YieldBreak(locatedToken.Location); } private void case_1027() { yyVal = new TryFinally((Statement)yyVals[-2 + yyTop], (ExplicitBlock)yyVals[yyTop], GetLocation(yyVals[-3 + yyTop])); } private void case_1028() { yyVal = new TryFinally(new TryCatch((Block)yyVals[-3 + yyTop], (List)yyVals[-2 + yyTop], Location.Null, inside_try_finally: true), (ExplicitBlock)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_1029() { Error_SyntaxError(1524, yyToken); yyVal = new TryCatch((Block)yyVals[-1 + yyTop], null, GetLocation(yyVals[-2 + yyTop]), inside_try_finally: false); } private void case_1030() { List list = new List(2); list.Add((Catch)yyVals[yyTop]); yyVal = list; } private void case_1031() { List list = (List)yyVals[-1 + yyTop]; Catch obj = (Catch)yyVals[yyTop]; Catch obj2 = list[list.Count - 1]; if (obj2.IsGeneral && obj2.Filter == null) { report.Error(1017, obj.loc, "Try statement already has an empty catch block"); } list.Add(obj); yyVal = list; } private void case_1034() { Catch obj = new Catch((ExplicitBlock)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); obj.Filter = (CatchFilterExpression)yyVals[-1 + yyTop]; yyVal = obj; } private void case_1035() { start_block(GetLocation(yyVals[-3 + yyTop])); Catch obj = new Catch((ExplicitBlock)current_block, GetLocation(yyVals[-4 + yyTop])); obj.TypeExpression = (FullNamedExpression)yyVals[-2 + yyTop]; if (yyVals[-1 + yyTop] != null) { LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; obj.Variable = new LocalVariable(current_block, locatedToken.Value, locatedToken.Location); current_block.AddLocalName(obj.Variable); } yyVal = obj; lexer.parsing_catch_when = true; } private void case_1036() { ((Catch)yyVals[-1 + yyTop]).Filter = (CatchFilterExpression)yyVals[yyTop]; yyVal = yyVals[-1 + yyTop]; } private void case_1037() { if (yyToken == 378) { report.Error(1015, lexer.Location, "A type that derives from `System.Exception', `object', or `string' expected"); } else { Error_SyntaxError(yyToken); } yyVal = new Catch(null, GetLocation(yyVals[-2 + yyTop])); } private void case_1039() { end_block(Location.Null); Error_SyntaxError(yyToken); yyVal = null; } private void case_1042() { if (lang_version <= LanguageVersion.V_5) { FeatureIsNotAvailable(GetLocation(yyVals[-4 + yyTop]), "exception filter"); } yyVal = new CatchFilterExpression((Expression)yyVals[-1 + yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_1045() { if (!settings.Unsafe) { Error_UnsafeCodeNotAllowed(GetLocation(yyVals[yyTop])); } } private void case_1047() { if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } yyVal = new Lock((Expression)yyVals[-2 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_1048() { Error_SyntaxError(yyToken); yyVal = new Lock((Expression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_1049() { start_block(GetLocation(yyVals[-2 + yyTop])); current_block.IsCompilerGenerated = true; LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.FixedVariable | LocalVariable.Flags.Used, locatedToken.Location); current_block.AddLocalName(li); current_variable = new Fixed.VariableDeclaration((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_1050() { yyVal = current_variable; current_variable = null; } private void case_1051() { if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } Fixed s = new Fixed((Fixed.VariableDeclaration)yyVals[-1 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-9 + yyTop])); current_block.AddStatement(s); yyVal = end_block(GetLocation(yyVals[-2 + yyTop])); } private void case_1052() { start_block(GetLocation(yyVals[-2 + yyTop])); current_block.IsCompilerGenerated = true; LocatedToken locatedToken = (LocatedToken)yyVals[yyTop]; LocalVariable li = new LocalVariable(current_block, locatedToken.Value, LocalVariable.Flags.UsingVariable | LocalVariable.Flags.Used, locatedToken.Location); current_block.AddLocalName(li); current_variable = new Using.VariableDeclaration((FullNamedExpression)yyVals[-1 + yyTop], li); } private void case_1053() { yyVal = current_variable; current_variable = null; } private void case_1054() { if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } Using s = new Using((Using.VariableDeclaration)yyVals[-1 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-8 + yyTop])); current_block.AddStatement(s); yyVal = end_block(GetLocation(yyVals[-2 + yyTop])); } private void case_1055() { if (yyVals[yyTop] is EmptyStatement && lexer.peek_token() == 373) { Warning_EmptyStatement(GetLocation(yyVals[yyTop])); } yyVal = new Using((Expression)yyVals[-2 + yyTop], (Statement)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); } private void case_1056() { Error_SyntaxError(yyToken); yyVal = new Using((Expression)yyVals[-1 + yyTop], null, GetLocation(yyVals[-3 + yyTop])); } private void case_1058() { Error_SyntaxError(yyToken); } private void case_1060() { current_variable.Initializer = (Expression)yyVals[yyTop]; yyVal = current_variable; } private void case_1061() { lexer.query_parsing = false; AQueryClause aQueryClause = yyVals[-1 + yyTop] as AQueryClause; aQueryClause.Tail.Next = (AQueryClause)yyVals[yyTop]; yyVal = aQueryClause; current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1062() { AQueryClause aQueryClause = yyVals[-1 + yyTop] as AQueryClause; aQueryClause.Tail.Next = (AQueryClause)yyVals[yyTop]; yyVal = aQueryClause; current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1063() { lexer.query_parsing = false; yyVal = yyVals[-1 + yyTop]; current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1064() { yyVal = yyVals[-1 + yyTop]; current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1065() { current_block = new QueryBlock(current_block, lexer.Location); LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; RangeVariable identifier = new RangeVariable(locatedToken.Value, locatedToken.Location); QueryStartClause start = new QueryStartClause((QueryBlock)current_block, (Expression)yyVals[yyTop], identifier, GetLocation(yyVals[-3 + yyTop])); yyVal = new QueryExpression(start); } private void case_1066() { current_block = new QueryBlock(current_block, lexer.Location); LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; RangeVariable identifier = new RangeVariable(locatedToken.Value, locatedToken.Location); QueryStartClause start = new QueryStartClause((QueryBlock)current_block, (Expression)yyVals[yyTop], identifier, GetLocation(yyVals[-4 + yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-3 + yyTop] }; yyVal = new QueryExpression(start); } private void case_1067() { current_block = new QueryBlock(current_block, lexer.Location); LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; RangeVariable identifier = new RangeVariable(locatedToken.Value, locatedToken.Location); QueryStartClause start = new QueryStartClause((QueryBlock)current_block, (Expression)yyVals[yyTop], identifier, GetLocation(yyVals[-3 + yyTop])); yyVal = new QueryExpression(start); } private void case_1068() { current_block = new QueryBlock(current_block, lexer.Location); LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; RangeVariable identifier = new RangeVariable(locatedToken.Value, locatedToken.Location); QueryStartClause start = new QueryStartClause((QueryBlock)current_block, (Expression)yyVals[yyTop], identifier, GetLocation(yyVals[-4 + yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-3 + yyTop] }; yyVal = new QueryExpression(start); } private void case_1070() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; RangeVariable rangeVariable = new RangeVariable(locatedToken.Value, locatedToken.Location); yyVal = new SelectMany((QueryBlock)current_block, rangeVariable, (Expression)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable); } private void case_1072() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; RangeVariable rangeVariable = new RangeVariable(locatedToken.Value, locatedToken.Location); yyVal = new SelectMany((QueryBlock)current_block, rangeVariable, (Expression)yyVals[yyTop], GetLocation(yyVals[-5 + yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-4 + yyTop] }; current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable); } private void case_1073() { AQueryClause aQueryClause = (AQueryClause)yyVals[-1 + yyTop]; if (yyVals[yyTop] != null) { aQueryClause.Next = (AQueryClause)yyVals[yyTop]; } if (yyVals[-2 + yyTop] != null) { AQueryClause aQueryClause2 = (AQueryClause)yyVals[-2 + yyTop]; aQueryClause2.Tail.Next = aQueryClause; aQueryClause = aQueryClause2; } yyVal = aQueryClause; } private void case_1074() { AQueryClause next = (AQueryClause)yyVals[yyTop]; if (yyVals[-1 + yyTop] != null) { AQueryClause aQueryClause = (AQueryClause)yyVals[-1 + yyTop]; aQueryClause.Tail.Next = next; next = aQueryClause; } yyVal = next; } private void case_1076() { report.Error(742, GetLocation(yyVals[yyTop]), "Unexpected symbol `{0}'. A query body must end with select or group clause", GetSymbolName(yyToken)); yyVal = yyVals[-1 + yyTop]; } private void case_1077() { Error_SyntaxError(yyToken); yyVal = null; } private void case_1079() { yyVal = new Select((QueryBlock)current_block, (Expression)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1080() { if (linq_clause_blocks == null) { linq_clause_blocks = new Stack(); } current_block = new QueryBlock(current_block, lexer.Location); linq_clause_blocks.Push((QueryBlock)current_block); } private void case_1081() { current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); } private void case_1082() { object[] array = (object[])yyVals[yyTop]; yyVal = new GroupBy((QueryBlock)current_block, (Expression)yyVals[-2 + yyTop], linq_clause_blocks.Pop(), (Expression)array[0], GetLocation(yyVals[-4 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1084() { Error_SyntaxError(yyToken); yyVal = new object[2] { null, Location.Null }; } private void case_1086() { ((AQueryClause)yyVals[-1 + yyTop]).Tail.Next = (AQueryClause)yyVals[yyTop]; yyVal = yyVals[-1 + yyTop]; } private void case_1093() { LocatedToken locatedToken = (LocatedToken)yyVals[-3 + yyTop]; RangeVariable rangeVariable = new RangeVariable(locatedToken.Value, locatedToken.Location); yyVal = new Let((QueryBlock)current_block, rangeVariable, (Expression)yyVals[yyTop], GetLocation(yyVals[-4 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable); } private void case_1095() { yyVal = new Where((QueryBlock)current_block, (Expression)yyVals[yyTop], GetLocation(yyVals[-2 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; } private void case_1096() { if (linq_clause_blocks == null) { linq_clause_blocks = new Stack(); } current_block = new QueryBlock(current_block, lexer.Location); linq_clause_blocks.Push((QueryBlock)current_block); } private void case_1097() { current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); linq_clause_blocks.Push((QueryBlock)current_block); } private void case_1098() { current_block.AddStatement(new ContextualReturn((Expression)yyVals[-1 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); } private void case_1099() { current_block.AddStatement(new ContextualReturn((Expression)yyVals[-1 + yyTop])); current_block.SetEndLocation(lexer.Location); QueryBlock outerSelector = linq_clause_blocks.Pop(); QueryBlock queryBlock = linq_clause_blocks.Pop(); LocatedToken locatedToken = (LocatedToken)yyVals[-10 + yyTop]; RangeVariable rangeVariable = new RangeVariable(locatedToken.Value, locatedToken.Location); RangeVariable rangeVariable2; if (yyVals[yyTop] == null) { rangeVariable2 = rangeVariable; yyVal = new Join(queryBlock, rangeVariable, (Expression)yyVals[-7 + yyTop], outerSelector, (QueryBlock)current_block, GetLocation(yyVals[-11 + yyTop])); } else { Block parent = queryBlock.Parent; while (parent is QueryBlock) { parent = parent.Parent; } current_block.Parent = parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable); locatedToken = (LocatedToken)yyVals[yyTop]; rangeVariable2 = new RangeVariable(locatedToken.Value, locatedToken.Location); yyVal = new GroupJoin(queryBlock, rangeVariable, (Expression)yyVals[-7 + yyTop], outerSelector, (QueryBlock)current_block, rangeVariable2, GetLocation(yyVals[-11 + yyTop])); } current_block = queryBlock.Parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable2); } private void case_1100() { if (linq_clause_blocks == null) { linq_clause_blocks = new Stack(); } current_block = new QueryBlock(current_block, lexer.Location); linq_clause_blocks.Push((QueryBlock)current_block); } private void case_1101() { current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); linq_clause_blocks.Push((QueryBlock)current_block); } private void case_1102() { current_block.AddStatement(new ContextualReturn((Expression)yyVals[-1 + yyTop])); current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); } private void case_1103() { current_block.AddStatement(new ContextualReturn((Expression)yyVals[-1 + yyTop])); current_block.SetEndLocation(lexer.Location); QueryBlock outerSelector = linq_clause_blocks.Pop(); QueryBlock queryBlock = linq_clause_blocks.Pop(); LocatedToken locatedToken = (LocatedToken)yyVals[-10 + yyTop]; RangeVariable rangeVariable = new RangeVariable(locatedToken.Value, locatedToken.Location); RangeVariable rangeVariable2; if (yyVals[yyTop] == null) { rangeVariable2 = rangeVariable; yyVal = new Join(queryBlock, rangeVariable, (Expression)yyVals[-7 + yyTop], outerSelector, (QueryBlock)current_block, GetLocation(yyVals[-12 + yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-11 + yyTop] }; } else { Block parent = queryBlock.Parent; while (parent is QueryBlock) { parent = parent.Parent; } current_block.Parent = parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable); locatedToken = (LocatedToken)yyVals[yyTop]; rangeVariable2 = new RangeVariable(locatedToken.Value, locatedToken.Location); yyVal = new GroupJoin(queryBlock, rangeVariable, (Expression)yyVals[-7 + yyTop], outerSelector, (QueryBlock)current_block, rangeVariable2, GetLocation(yyVals[-12 + yyTop])) { IdentifierType = (FullNamedExpression)yyVals[-11 + yyTop] }; } current_block = queryBlock.Parent; ((QueryBlock)current_block).AddRangeVariable(rangeVariable2); } private void case_1107() { current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; yyVal = yyVals[yyTop]; } private void case_1109() { current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); } private void case_1110() { ((AQueryClause)yyVals[-3 + yyTop]).Next = (AQueryClause)yyVals[yyTop]; yyVal = yyVals[-3 + yyTop]; } private void case_1112() { current_block.SetEndLocation(lexer.Location); current_block = current_block.Parent; current_block = new QueryBlock((QueryBlock)current_block, lexer.Location); } private void case_1113() { ((AQueryClause)yyVals[-3 + yyTop]).Tail.Next = (AQueryClause)yyVals[yyTop]; yyVal = yyVals[-3 + yyTop]; } private void case_1115() { yyVal = new OrderByAscending((QueryBlock)current_block, (Expression)yyVals[-1 + yyTop]); } private void case_1116() { yyVal = new OrderByDescending((QueryBlock)current_block, (Expression)yyVals[-1 + yyTop]); } private void case_1118() { yyVal = new ThenByAscending((QueryBlock)current_block, (Expression)yyVals[-1 + yyTop]); } private void case_1119() { yyVal = new ThenByDescending((QueryBlock)current_block, (Expression)yyVals[-1 + yyTop]); } private void case_1121() { current_block.SetEndLocation(GetLocation(yyVals[-1 + yyTop])); current_block = current_block.Parent; current_block = new QueryBlock(current_block, lexer.Location); if (linq_clause_blocks == null) { linq_clause_blocks = new Stack(); } linq_clause_blocks.Push((QueryBlock)current_block); } private void case_1122() { QueryBlock block = linq_clause_blocks.Pop(); LocatedToken locatedToken = (LocatedToken)yyVals[-2 + yyTop]; RangeVariable identifier = new RangeVariable(locatedToken.Value, locatedToken.Location); yyVal = new QueryStartClause(block, null, identifier, GetLocation(yyVals[-3 + yyTop])) { next = (AQueryClause)yyVals[yyTop] }; } private void case_1125() { current_container = (current_type = new Class(current_container, new MemberName(""), Modifiers.PUBLIC, null)); ParametersCompiled parameters = new ParametersCompiled(new Parameter(new TypeExpression(compiler.BuiltinTypes.Object, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null)); Modifiers modifiers = Modifiers.PUBLIC | Modifiers.STATIC; if (settings.Unsafe) { modifiers |= Modifiers.UNSAFE; } current_local_parameters = parameters; InteractiveMethod interactiveMethod = new InteractiveMethod(current_type, new TypeExpression(compiler.BuiltinTypes.Void, Location.Null), modifiers, parameters); current_type.AddMember(interactiveMethod); oob_stack.Push(interactiveMethod); interactive_async = false; lexer.parsing_block++; start_block(lexer.Location); } private void case_1126() { lexer.parsing_block--; InteractiveMethod interactiveMethod = (InteractiveMethod)oob_stack.Pop(); interactiveMethod.Block = (ToplevelBlock)end_block(lexer.Location); if (interactive_async == true) { interactiveMethod.ChangeToAsync(); } InteractiveResult = (Class)pop_current_class(); current_local_parameters = null; } private void case_1136() { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-1 + yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[yyTop]; yyVal = null; } private void case_1137() { module.DocumentationBuilder.ParsedBuiltinType = new TypeExpression(compiler.BuiltinTypes.Void, GetLocation(yyVals[-1 + yyTop])); module.DocumentationBuilder.ParsedParameters = (List)yyVals[yyTop]; yyVal = null; } private void case_1138() { module.DocumentationBuilder.ParsedBuiltinType = (TypeExpression)yyVals[-3 + yyTop]; module.DocumentationBuilder.ParsedParameters = (List)yyVals[yyTop]; LocatedToken locatedToken = (LocatedToken)yyVals[-1 + yyTop]; yyVal = new MemberName(locatedToken.Value); } private void case_1141() { module.DocumentationBuilder.ParsedParameters = (List)yyVals[-1 + yyTop]; yyVal = new MemberName((MemberName)yyVals[-6 + yyTop], MemberCache.IndexerNameAlias, Location.Null); } private void case_1142() { List list = ((List)yyVals[yyTop]) ?? new List(1); list.Add(new DocumentationParameter((FullNamedExpression)yyVals[-1 + yyTop])); module.DocumentationBuilder.ParsedParameters = list; module.DocumentationBuilder.ParsedOperator = Operator.OpType.Explicit; yyVal = null; } private void case_1143() { List list = ((List)yyVals[yyTop]) ?? new List(1); list.Add(new DocumentationParameter((FullNamedExpression)yyVals[-1 + yyTop])); module.DocumentationBuilder.ParsedParameters = list; module.DocumentationBuilder.ParsedOperator = Operator.OpType.Implicit; yyVal = null; } private void case_1144() { List parsedParameters = (List)yyVals[yyTop]; module.DocumentationBuilder.ParsedParameters = parsedParameters; module.DocumentationBuilder.ParsedOperator = (Operator.OpType)yyVals[-1 + yyTop]; yyVal = null; } private void case_1152() { List list = new List(); list.Add((DocumentationParameter)yyVals[yyTop]); yyVal = list; } private void case_1153() { List list = yyVals[-2 + yyTop] as List; list.Add((DocumentationParameter)yyVals[yyTop]); yyVal = list; } private void case_1154() { if (yyVals[-1 + yyTop] != null) { yyVal = new DocumentationParameter((Parameter.Modifier)yyVals[-1 + yyTop], (FullNamedExpression)yyVals[yyTop]); } else { yyVal = new DocumentationParameter((FullNamedExpression)yyVals[yyTop]); } } private void Error_ExpectingTypeName(Expression expr) { if (expr is Invocation) { report.Error(1002, expr.Location, "Expecting `;'"); } else { expr.Error_InvalidExpressionStatement(report); } } private void Error_ParameterModifierNotValid(string modifier, Location loc) { report.Error(631, loc, "The parameter modifier `{0}' is not valid in this context", modifier); } private void Error_DuplicateParameterModifier(Location loc, Parameter.Modifier mod) { report.Error(1107, loc, "Duplicate parameter modifier `{0}'", Parameter.GetModifierSignature(mod)); } private void Error_TypeExpected(Location loc) { report.Error(1031, loc, "Type expected"); } private void Error_UnsafeCodeNotAllowed(Location loc) { report.Error(227, loc, "Unsafe code requires the `unsafe' command line option to be specified"); } private void Warning_EmptyStatement(Location loc) { report.Warning(642, 3, loc, "Possible mistaken empty statement"); } private void Error_NamedArgumentExpected(NamedArgument a) { report.Error(1738, a.Location, "Named arguments must appear after the positional arguments when using language version older than 7.2"); } private void Error_MissingInitializer(Location loc) { report.Error(210, loc, "You must provide an initializer in a fixed or using statement declaration"); } private object Error_AwaitAsIdentifier(object token) { if (async_block) { report.Error(4003, GetLocation(token), "`await' cannot be used as an identifier within an async method or lambda expression"); return new LocatedToken("await", GetLocation(token)); } return token; } private void push_current_container(TypeDefinition tc, object partial_token) { if (module.Evaluator != null) { TypeSpec definition = tc.Definition; Modifiers modifiers = (tc.ModFlags = (tc.ModFlags & ~Modifiers.AccessibilityMask) | Modifiers.PUBLIC); definition.Modifiers = modifiers; if (undo == null) { undo = new Undo(); } undo.AddTypeContainer(current_container, tc); } if (partial_token != null) { current_container.AddPartial(tc); } else { current_container.AddTypeContainer(tc); } lexer.parsing_declaration++; current_container = tc; current_type = tc; } private TypeContainer pop_current_class() { TypeContainer result = current_container; current_container = current_container.Parent; current_type = current_type.Parent as TypeDefinition; return result; } [Conditional("FULL_AST")] private void StoreModifierLocation(object token, Location loc) { if (lbag != null) { if (mod_locations == null) { mod_locations = new List>(); } mod_locations.Add(Tuple.Create((Modifiers)token, loc)); } } [Conditional("FULL_AST")] private void PushLocation(Location loc) { if (location_stack == null) { location_stack = new Stack(); } location_stack.Push(loc); } private Location PopLocation() { if (location_stack == null) { return Location.Null; } return location_stack.Pop(); } private string CheckAttributeTarget(int token, string a, Location l) { switch (a) { case "assembly": case "module": case "field": case "method": case "param": case "property": case "type": return a; default: if (!Tokenizer.IsValidIdentifier(a)) { Error_SyntaxError(token); } else { report.Warning(658, 1, l, "`{0}' is invalid attribute target. All attributes in this attribute section will be ignored", a); } return string.Empty; } } private static bool IsUnaryOperator(Operator.OpType op) { Operator.OpType opType = op; Operator.OpType opType2 = opType; if (opType2 <= Operator.OpType.False || opType2 - 8 <= Operator.OpType.OnesComplement) { return true; } return false; } private void syntax_error(Location l, string msg) { report.Error(1003, l, "Syntax error, " + msg); } public CSharpParser(SeekableStreamReader reader, CompilationSourceFile file, ParserSession session) : this(reader, file, file.Compiler.Report, session) { } public CSharpParser(SeekableStreamReader reader, CompilationSourceFile file, Report report, ParserSession session) { this.file = file; current_container = (current_namespace = file); module = file.Module; compiler = file.Compiler; settings = compiler.Settings; this.report = report; lang_version = settings.Version; yacc_verbose_flag = settings.VerboseParserFlag; doc_support = settings.DocumentationFile != null; lexer = new Tokenizer(reader, file, session, report); oob_stack = new Stack(); lbag = session.LocationsBag; use_global_stacks = session.UseJayGlobalArrays; parameters_bucket = session.ParametersStack; } public void parse() { eof_token = 257; try { if (yacc_verbose_flag > 1) { yyparse(lexer, new yyDebugSimple()); } else { yyparse(lexer); } Tokenizer tokenizer = lexer; tokenizer.cleanup(); } catch (Exception ex) { if (ex is yyUnexpectedEof) { Error_SyntaxError(yyToken); UnexpectedEOF = true; return; } if (ex is yyException) { if (report.Errors == 0) { report.Error(-25, lexer.Location, "Parsing error"); } return; } if (yacc_verbose_flag > 0 || ex is FatalException) { throw; } report.Error(589, lexer.Location, "Internal compiler error during parsing" + ex); } } private void CheckToken(int error, int yyToken, string msg, Location loc) { if (yyToken >= 260 && yyToken <= 372) { report.Error(error, loc, "{0}: `{1}' is a keyword", msg, GetTokenName(yyToken)); } else { report.Error(error, loc, msg); } } private string ConsumeStoredComment() { string result = tmpComment; tmpComment = null; Lexer.doc_state = XmlCommentState.Allowed; return result; } private void FeatureIsNotAvailable(Location loc, string feature) { report.FeatureIsNotAvailable(compiler, loc, feature); } private Location GetLocation(object obj) { if (obj is LocatedToken { Location: var location }) { return location; } if (obj is MemberName { Location: var location2 }) { return location2; } if (!(obj is Expression { Location: var location3 })) { return lexer.Location; } return location3; } private void start_block(Location loc) { if (current_block == null) { current_block = new ToplevelBlock(compiler, current_local_parameters, loc); parsing_anonymous_method = false; } else if (parsing_anonymous_method) { current_block = new ParametersBlock(current_block, current_local_parameters, loc); parsing_anonymous_method = false; } else { current_block = new ExplicitBlock(current_block, loc, Location.Null); } } private Block end_block(Location loc) { Block block = current_block.Explicit; block.SetEndLocation(loc); current_block = block.Parent; return block; } private void start_anonymous(bool isLambda, ParametersCompiled parameters, bool isAsync, Location loc) { oob_stack.Push(current_anonymous_method); oob_stack.Push(current_local_parameters); oob_stack.Push(current_variable); oob_stack.Push(async_block); current_local_parameters = parameters; if (isLambda) { if (lang_version <= LanguageVersion.ISO_2) { FeatureIsNotAvailable(loc, "lambda expressions"); } current_anonymous_method = new LambdaExpression(loc); } else { if (lang_version == LanguageVersion.ISO_1) { FeatureIsNotAvailable(loc, "anonymous methods"); } current_anonymous_method = new AnonymousMethodExpression(loc); } async_block = isAsync; parsing_anonymous_method = true; } private AnonymousMethodExpression end_anonymous(ParametersBlock anon_block) { if (async_block) { anon_block.IsAsync = true; } current_anonymous_method.Block = anon_block; AnonymousMethodExpression result = current_anonymous_method; async_block = (bool)oob_stack.Pop(); current_variable = (BlockVariable)oob_stack.Pop(); current_local_parameters = (ParametersCompiled)oob_stack.Pop(); current_anonymous_method = (AnonymousMethodExpression)oob_stack.Pop(); return result; } private void Error_SyntaxError(int token) { Error_SyntaxError(0, token); } private void Error_SyntaxError(int error_code, int token) { Error_SyntaxError(error_code, token, "Unexpected symbol"); } private void Error_SyntaxError(int error_code, int token, string msg) { Lexer.CompleteOnEOF = false; switch (token) { case 259: return; case 423: if (lexer.Location.Column == 0) { return; } break; } string symbolName = GetSymbolName(token); string text = GetExpecting(); Location loc = lexer.Location - symbolName.Length; if (error_code == 0) { if (!(text == "`identifier'")) { error_code = ((!(text == "`)'")) ? 1525 : 1026); } else { if (token > 260 && token < 372) { report.Error(1041, loc, "Identifier expected, `{0}' is a keyword", symbolName); return; } error_code = 1001; text = "identifier"; } } if (string.IsNullOrEmpty(text)) { report.Error(error_code, loc, "{1} `{0}'", symbolName, msg); return; } report.Error(error_code, loc, "{2} `{0}', expecting {1}", symbolName, text, msg); } private string GetExpecting() { int[] array = yyExpectingTokens(yyExpectingState); List list = new List(array.Length); bool flag = false; bool flag2 = false; foreach (int num in array) { flag2 = flag2 || num == 424; string tokenName = GetTokenName(num); if (!(tokenName == "")) { flag |= tokenName == "type"; if (!list.Contains(tokenName)) { list.Add(tokenName); } } } if (list.Count > 8) { return null; } if (flag && flag2) { list.Remove("identifier"); } if (list.Count == 1) { return "`" + GetTokenName(array[0]) + "'"; } StringBuilder stringBuilder = new StringBuilder(); list.Sort(); int count = list.Count; for (int j = 0; j < count; j++) { bool flag3 = j + 1 == count; if (flag3) { stringBuilder.Append("or "); } stringBuilder.Append('`'); stringBuilder.Append(list[j]); stringBuilder.Append(flag3 ? "'" : ((count < 3) ? "' " : "', ")); } return stringBuilder.ToString(); } private string GetSymbolName(int token) { switch (token) { case 423: return ((Constant)lexer.Value).GetValue().ToString(); case 424: return ((LocatedToken)lexer.Value).Value; case 265: return "bool"; case 267: return "byte"; case 270: return "char"; case 338: return "void"; case 275: return "decimal"; case 280: return "double"; case 289: return "float"; case 296: return "int"; case 301: return "long"; case 317: return "sbyte"; case 319: return "short"; case 323: return "string"; case 331: return "uint"; case 332: return "ulong"; case 335: return "ushort"; case 305: return "object"; case 384: return "+"; case 385: case 439: return "-"; case 386: return "!"; case 390: return "&"; case 391: return "|"; case 392: return "*"; case 393: return "%"; case 394: return "/"; case 395: return "^"; case 398: return "++"; case 399: return "--"; case 400: return "<<"; case 401: return ">>"; case 388: return "<"; case 389: return ">"; case 402: return "<="; case 403: return ">="; case 404: return "=="; case 405: return "!="; case 406: return "&&"; case 407: return "||"; case 418: return "->"; case 419: return "??"; case 408: return "*="; case 409: return "/="; case 410: return "%="; case 411: return "+="; case 412: return "-="; case 413: return "<<="; case 414: return ">>="; case 415: return "&="; case 416: return "^="; case 417: return "|="; default: return GetTokenName(token); } } private static string GetTokenName(int token) { switch (token) { case 261: return "abstract"; case 262: return "as"; case 263: return "add"; case 363: return "async"; case 264: return "base"; case 266: return "break"; case 268: return "case"; case 269: return "catch"; case 271: return "checked"; case 272: return "class"; case 273: return "const"; case 274: return "continue"; case 276: case 277: return "default"; case 278: return "delegate"; case 279: return "do"; case 281: return "else"; case 282: return "enum"; case 283: return "event"; case 284: return "explicit"; case 285: case 359: return "extern"; case 286: return "false"; case 287: return "finally"; case 288: return "fixed"; case 290: return "for"; case 291: return "foreach"; case 292: return "goto"; case 293: return "if"; case 294: return "implicit"; case 295: return "in"; case 297: return "interface"; case 298: return "internal"; case 299: return "is"; case 300: return "lock"; case 302: return "namespace"; case 303: return "new"; case 304: return "null"; case 306: return "operator"; case 307: return "out"; case 308: return "override"; case 309: return "params"; case 310: return "private"; case 311: return "protected"; case 312: return "public"; case 313: return "readonly"; case 314: case 431: case 432: return "ref"; case 315: return "return"; case 316: return "remove"; case 318: return "sealed"; case 320: return "sizeof"; case 321: return "stackalloc"; case 322: return "static"; case 324: return "struct"; case 325: return "switch"; case 326: return "this"; case 327: case 369: return "throw"; case 328: return "true"; case 329: return "try"; case 330: return "typeof"; case 333: return "unchecked"; case 334: return "unsafe"; case 336: return "using"; case 337: return "virtual"; case 339: return "volatile"; case 340: return "where"; case 341: return "while"; case 342: return "__arglist"; case 360: return "__refvalue"; case 361: return "__reftype"; case 362: return "__makeref"; case 343: return "partial"; case 344: return "=>"; case 345: case 346: return "from"; case 347: return "join"; case 348: return "on"; case 349: return "equals"; case 350: return "select"; case 351: return "group"; case 352: return "by"; case 353: return "let"; case 354: return "orderby"; case 355: return "ascending"; case 356: return "descending"; case 357: return "into"; case 370: return "get"; case 371: return "set"; case 373: return "{"; case 374: return "}"; case 375: case 429: return "["; case 376: return "]"; case 377: case 425: case 426: case 430: return "("; case 378: return ")"; case 379: return "."; case 380: return ","; case 428: return "default:"; case 381: return ":"; case 382: return ";"; case 383: return "~"; case 366: return "when"; case 368: return "}"; case 367: return "${"; case 365: case 384: case 385: case 386: case 388: case 389: case 390: case 391: case 392: case 393: case 394: case 395: case 398: case 399: case 400: case 401: case 402: case 403: case 404: case 405: case 406: case 407: case 408: case 409: case 410: case 411: case 412: case 413: case 414: case 415: case 416: case 417: case 418: case 419: case 439: return ""; case 265: case 267: case 270: case 275: case 280: case 289: case 296: case 301: case 305: case 317: case 319: case 323: case 331: case 332: case 335: case 338: return "type"; case 387: return "="; case 420: case 427: return "<"; case 422: return ">"; case 358: case 396: return "?"; case 397: return "::"; case 423: return "value"; case 364: case 424: return "identifier"; case 257: return "end-of-file"; case 258: case 259: case 260: case 372: case 433: case 434: case 435: case 437: case 438: return ""; default: return yyNames[token]; } } } internal class Token { public const int EOF = 257; public const int NONE = 258; public const int ERROR = 259; public const int FIRST_KEYWORD = 260; public const int ABSTRACT = 261; public const int AS = 262; public const int ADD = 263; public const int BASE = 264; public const int BOOL = 265; public const int BREAK = 266; public const int BYTE = 267; public const int CASE = 268; public const int CATCH = 269; public const int CHAR = 270; public const int CHECKED = 271; public const int CLASS = 272; public const int CONST = 273; public const int CONTINUE = 274; public const int DECIMAL = 275; public const int DEFAULT = 276; public const int DEFAULT_VALUE = 277; public const int DELEGATE = 278; public const int DO = 279; public const int DOUBLE = 280; public const int ELSE = 281; public const int ENUM = 282; public const int EVENT = 283; public const int EXPLICIT = 284; public const int EXTERN = 285; public const int FALSE = 286; public const int FINALLY = 287; public const int FIXED = 288; public const int FLOAT = 289; public const int FOR = 290; public const int FOREACH = 291; public const int GOTO = 292; public const int IF = 293; public const int IMPLICIT = 294; public const int IN = 295; public const int INT = 296; public const int INTERFACE = 297; public const int INTERNAL = 298; public const int IS = 299; public const int LOCK = 300; public const int LONG = 301; public const int NAMESPACE = 302; public const int NEW = 303; public const int NULL = 304; public const int OBJECT = 305; public const int OPERATOR = 306; public const int OUT = 307; public const int OVERRIDE = 308; public const int PARAMS = 309; public const int PRIVATE = 310; public const int PROTECTED = 311; public const int PUBLIC = 312; public const int READONLY = 313; public const int REF = 314; public const int RETURN = 315; public const int REMOVE = 316; public const int SBYTE = 317; public const int SEALED = 318; public const int SHORT = 319; public const int SIZEOF = 320; public const int STACKALLOC = 321; public const int STATIC = 322; public const int STRING = 323; public const int STRUCT = 324; public const int SWITCH = 325; public const int THIS = 326; public const int THROW = 327; public const int TRUE = 328; public const int TRY = 329; public const int TYPEOF = 330; public const int UINT = 331; public const int ULONG = 332; public const int UNCHECKED = 333; public const int UNSAFE = 334; public const int USHORT = 335; public const int USING = 336; public const int VIRTUAL = 337; public const int VOID = 338; public const int VOLATILE = 339; public const int WHERE = 340; public const int WHILE = 341; public const int ARGLIST = 342; public const int PARTIAL = 343; public const int ARROW = 344; public const int FROM = 345; public const int FROM_FIRST = 346; public const int JOIN = 347; public const int ON = 348; public const int EQUALS = 349; public const int SELECT = 350; public const int GROUP = 351; public const int BY = 352; public const int LET = 353; public const int ORDERBY = 354; public const int ASCENDING = 355; public const int DESCENDING = 356; public const int INTO = 357; public const int INTERR_NULLABLE = 358; public const int EXTERN_ALIAS = 359; public const int REFVALUE = 360; public const int REFTYPE = 361; public const int MAKEREF = 362; public const int ASYNC = 363; public const int AWAIT = 364; public const int INTERR_OPERATOR = 365; public const int WHEN = 366; public const int INTERPOLATED_STRING = 367; public const int INTERPOLATED_STRING_END = 368; public const int THROW_EXPR = 369; public const int GET = 370; public const int SET = 371; public const int LAST_KEYWORD = 372; public const int OPEN_BRACE = 373; public const int CLOSE_BRACE = 374; public const int OPEN_BRACKET = 375; public const int CLOSE_BRACKET = 376; public const int OPEN_PARENS = 377; public const int CLOSE_PARENS = 378; public const int DOT = 379; public const int COMMA = 380; public const int COLON = 381; public const int SEMICOLON = 382; public const int TILDE = 383; public const int PLUS = 384; public const int MINUS = 385; public const int BANG = 386; public const int ASSIGN = 387; public const int OP_LT = 388; public const int OP_GT = 389; public const int BITWISE_AND = 390; public const int BITWISE_OR = 391; public const int STAR = 392; public const int PERCENT = 393; public const int DIV = 394; public const int CARRET = 395; public const int INTERR = 396; public const int DOUBLE_COLON = 397; public const int OP_INC = 398; public const int OP_DEC = 399; public const int OP_SHIFT_LEFT = 400; public const int OP_SHIFT_RIGHT = 401; public const int OP_LE = 402; public const int OP_GE = 403; public const int OP_EQ = 404; public const int OP_NE = 405; public const int OP_AND = 406; public const int OP_OR = 407; public const int OP_MULT_ASSIGN = 408; public const int OP_DIV_ASSIGN = 409; public const int OP_MOD_ASSIGN = 410; public const int OP_ADD_ASSIGN = 411; public const int OP_SUB_ASSIGN = 412; public const int OP_SHIFT_LEFT_ASSIGN = 413; public const int OP_SHIFT_RIGHT_ASSIGN = 414; public const int OP_AND_ASSIGN = 415; public const int OP_XOR_ASSIGN = 416; public const int OP_OR_ASSIGN = 417; public const int OP_PTR = 418; public const int OP_COALESCING = 419; public const int OP_GENERICS_LT = 420; public const int OP_GENERICS_LT_DECL = 421; public const int OP_GENERICS_GT = 422; public const int LITERAL = 423; public const int IDENTIFIER = 424; public const int OPEN_PARENS_LAMBDA = 425; public const int OPEN_PARENS_CAST = 426; public const int GENERIC_DIMENSION = 427; public const int DEFAULT_COLON = 428; public const int OPEN_BRACKET_EXPR = 429; public const int OPEN_PARENS_DECONSTRUCT = 430; public const int REF_STRUCT = 431; public const int REF_PARTIAL = 432; public const int EVAL_STATEMENT_PARSER = 433; public const int EVAL_COMPILATION_UNIT_PARSER = 434; public const int EVAL_USING_DECLARATIONS_UNIT_PARSER = 435; public const int DOC_SEE = 436; public const int GENERATE_COMPLETION = 437; public const int COMPLETE_COMPLETION = 438; public const int UMINUS = 439; public const int yyErrorCode = 256; } internal class LocatedToken { public int row; public int column; public string value; public SourceFile file; public Location Location => new Location(file, row, column); public string Value => value; public LocatedToken() { } public LocatedToken(string value, Location loc) { this.value = value; file = loc.SourceFile; row = loc.Row; column = loc.Column; } public override string ToString() { return $"Token '{Value}' at {row},{column}"; } } internal class Tokenizer : yyInput { private class KeywordEntry { public readonly T Token; public KeywordEntry Next; public readonly char[] Value; public KeywordEntry(string value, T token) { Value = value.ToCharArray(); Token = token; } } private sealed class IdentifiersComparer : IEqualityComparer { private readonly int length; public IdentifiersComparer(int length) { this.length = length; } public bool Equals(char[] x, char[] y) { for (int i = 0; i < length; i++) { if (x[i] != y[i]) { return false; } } return true; } public int GetHashCode(char[] obj) { int num = 0; for (int i = 0; i < length; i++) { num = (num << 5) - num + obj[i]; } return num; } } public class LocatedTokenBuffer { private readonly LocatedToken[] buffer; public int pos; public LocatedTokenBuffer() { buffer = new LocatedToken[0]; } public LocatedTokenBuffer(LocatedToken[] buffer) { this.buffer = buffer ?? new LocatedToken[0]; } public LocatedToken Create(SourceFile file, int row, int column) { return Create(null, file, row, column); } public LocatedToken Create(string value, SourceFile file, int row, int column) { LocatedToken locatedToken; if (pos >= buffer.Length) { locatedToken = new LocatedToken(); } else { locatedToken = buffer[pos]; if (locatedToken == null) { locatedToken = new LocatedToken(); buffer[pos] = locatedToken; } pos++; } locatedToken.value = value; locatedToken.file = file; locatedToken.row = row; locatedToken.column = column; return locatedToken; } [Conditional("FULL_AST")] public void CreateOptional(SourceFile file, int row, int col, ref object token) { token = Create(file, row, col); } } public enum PreprocessorDirective { Invalid = 0, Region = 1, Endregion = 2, If = 2051, Endif = 4, Elif = 2053, Else = 6, Define = 2055, Undef = 2056, Error = 9, Warning = 10, Pragma = 1035, Line = 1036, CustomArgumentsParsing = 1024, RequiresArgument = 2048 } private class Position { public int position; public int line; public int ref_line; public int col; public Location hidden; public int putback_char; public int previous_col; public Stack ifstack; public int parsing_generic_less_than; public int current_token; public object val; public int parsing_string_interpolation; public int string_interpolation_section; public Stack parsing_string_interpolation_quoted; public Position(Tokenizer t) { position = t.reader.Position; line = t.line; ref_line = t.ref_line; col = t.col; hidden = t.hidden_block_start; putback_char = t.putback_char; previous_col = t.previous_col; if (t.ifstack != null && t.ifstack.Count != 0) { int[] array = t.ifstack.ToArray(); Array.Reverse((Array)array); ifstack = new Stack(array); } parsing_generic_less_than = t.parsing_generic_less_than; string_interpolation_section = t.string_interpolation_section; current_token = t.current_token; val = t.val; parsing_string_interpolation = t.parsing_string_interpolation; string_interpolation_section = t.string_interpolation_section; if (t.parsing_string_interpolation_quoted != null && t.parsing_string_interpolation_quoted.Count != 0) { bool[] array2 = t.parsing_string_interpolation_quoted.ToArray(); Array.Reverse((Array)array2); parsing_string_interpolation_quoted = new Stack(array2); } } } private readonly SeekableStreamReader reader; private readonly CompilationSourceFile source_file; private readonly CompilerContext context; private readonly Report Report; private SourceFile current_source; private Location hidden_block_start; private int ref_line = 1; private int line = 1; private int col = 0; private int previous_col; private int current_token; private readonly int tab_size; private bool handle_get_set = false; private bool handle_remove_add = false; private bool handle_where; private bool lambda_arguments_parsing; private List escaped_identifiers; private int parsing_generic_less_than; private readonly bool doc_processing; private readonly LocatedTokenBuffer ltb; public int parsing_block; internal bool query_parsing; public int parsing_type; public bool parsing_generic_declaration; public bool parsing_generic_declaration_doc; public int parsing_declaration; public bool parsing_attribute_section; public bool parsing_modifiers; public bool parsing_catch_when; private int parsing_string_interpolation; private int string_interpolation_section; private Stack parsing_string_interpolation_quoted; public bool parsing_interpolation_format; public const int EvalStatementParserCharacter = 1048576; public const int EvalCompilationUnitParserCharacter = 1048577; public const int EvalUsingDeclarationsParserCharacter = 1048578; public const int DocumentationXref = 1048579; private const int UnicodeLS = 8232; private const int UnicodePS = 8233; private StringBuilder xml_comment_buffer; private XmlCommentState xml_doc_state = XmlCommentState.Allowed; private bool tokens_seen = false; private bool generated; private bool any_token_seen; private static readonly KeywordEntry[][] keywords; private static readonly KeywordEntry[][] keywords_preprocessor; private static readonly HashSet keyword_strings; private static readonly NumberStyles styles; private static readonly NumberFormatInfo csharp_format_info; private static readonly char[] pragma_warning; private static readonly char[] pragma_warning_disable; private static readonly char[] pragma_warning_restore; private static readonly char[] pragma_checksum; private static readonly char[] line_hidden; private static readonly char[] line_default; private static readonly char[] simple_whitespaces; public bool CompleteOnEOF; internal int putback_char; private object val; private const int TAKING = 1; private const int ELSE_SEEN = 4; private const int PARENT_TAKING = 8; private const int REGION = 16; private Stack ifstack; public const int MaxIdentifierLength = 512; public const int MaxNumberLength = 512; private readonly char[] id_builder; private readonly Dictionary[] identifiers; private readonly char[] number_builder; private int number_pos; private char[] value_builder = new char[64]; private Stack position_stack = new Stack(2); public bool PropertyParsing { get { return handle_get_set; } set { handle_get_set = value; } } public bool EventParsing { get { return handle_remove_add; } set { handle_remove_add = value; } } public bool ConstraintsParsing { get { return handle_where; } set { handle_where = value; } } public XmlCommentState doc_state { get { return xml_doc_state; } set { if (value == XmlCommentState.Allowed) { check_incorrect_doc_comment(); reset_doc_comment(); } xml_doc_state = value; } } public int Line => ref_line; public Location Location => new Location(current_source, ref_line, col); public object Value => val; private void AddEscapedIdentifier(Location loc) { if (escaped_identifiers == null) { escaped_identifiers = new List(); } escaped_identifiers.Add(loc); } public bool IsEscapedIdentifier(ATypeNameExpression name) { return escaped_identifiers != null && escaped_identifiers.Contains(name.Location); } public Tokenizer(SeekableStreamReader input, CompilationSourceFile file, ParserSession session, Report report) { source_file = file; context = file.Compiler; current_source = file.SourceFile; identifiers = session.Identifiers; id_builder = session.IDBuilder; number_builder = session.NumberBuilder; ltb = new LocatedTokenBuffer(session.LocatedTokens); Report = report; reader = input; putback_char = -1; xml_comment_buffer = new StringBuilder(); doc_processing = context.Settings.DocumentationFile != null; tab_size = context.Settings.TabSize; } public void PushPosition() { position_stack.Push(new Position(this)); } public void PopPosition() { Position position = position_stack.Pop(); reader.Position = position.position; ref_line = position.ref_line; line = position.line; col = position.col; hidden_block_start = position.hidden; putback_char = position.putback_char; previous_col = position.previous_col; ifstack = position.ifstack; parsing_generic_less_than = position.parsing_generic_less_than; parsing_string_interpolation = position.parsing_string_interpolation; parsing_string_interpolation_quoted = position.parsing_string_interpolation_quoted; current_token = position.current_token; val = position.val; } public void DiscardPosition() { position_stack.Pop(); } private static void AddKeyword(string kw, int token) { keyword_strings.Add(kw); AddKeyword(keywords, kw, token); } private static void AddPreprocessorKeyword(string kw, PreprocessorDirective directive) { AddKeyword(keywords_preprocessor, kw, directive); } private static void AddKeyword(KeywordEntry[][] keywords, string kw, T token) { int length = kw.Length; if (keywords[length] == null) { keywords[length] = new KeywordEntry[28]; } int num = kw[0] - 95; KeywordEntry keywordEntry = keywords[length][num]; if (keywordEntry == null) { keywords[length][num] = new KeywordEntry(kw, token); return; } while (keywordEntry.Next != null) { keywordEntry = keywordEntry.Next; } keywordEntry.Next = new KeywordEntry(kw, token); } static Tokenizer() { pragma_warning = "warning".ToCharArray(); pragma_warning_disable = "disable".ToCharArray(); pragma_warning_restore = "restore".ToCharArray(); pragma_checksum = "checksum".ToCharArray(); line_hidden = "hidden".ToCharArray(); line_default = "default".ToCharArray(); simple_whitespaces = new char[2] { ' ', '\t' }; keyword_strings = new HashSet(); keywords = new KeywordEntry[11][]; AddKeyword("__arglist", 342); AddKeyword("__makeref", 362); AddKeyword("__reftype", 361); AddKeyword("__refvalue", 360); AddKeyword("abstract", 261); AddKeyword("as", 262); AddKeyword("add", 263); AddKeyword("base", 264); AddKeyword("bool", 265); AddKeyword("break", 266); AddKeyword("byte", 267); AddKeyword("case", 268); AddKeyword("catch", 269); AddKeyword("char", 270); AddKeyword("checked", 271); AddKeyword("class", 272); AddKeyword("const", 273); AddKeyword("continue", 274); AddKeyword("decimal", 275); AddKeyword("default", 276); AddKeyword("delegate", 278); AddKeyword("do", 279); AddKeyword("double", 280); AddKeyword("else", 281); AddKeyword("enum", 282); AddKeyword("event", 283); AddKeyword("explicit", 284); AddKeyword("extern", 285); AddKeyword("false", 286); AddKeyword("finally", 287); AddKeyword("fixed", 288); AddKeyword("float", 289); AddKeyword("for", 290); AddKeyword("foreach", 291); AddKeyword("goto", 292); AddKeyword("get", 370); AddKeyword("if", 293); AddKeyword("implicit", 294); AddKeyword("in", 295); AddKeyword("int", 296); AddKeyword("interface", 297); AddKeyword("internal", 298); AddKeyword("is", 299); AddKeyword("lock", 300); AddKeyword("long", 301); AddKeyword("namespace", 302); AddKeyword("new", 303); AddKeyword("null", 304); AddKeyword("object", 305); AddKeyword("operator", 306); AddKeyword("out", 307); AddKeyword("override", 308); AddKeyword("params", 309); AddKeyword("private", 310); AddKeyword("protected", 311); AddKeyword("public", 312); AddKeyword("readonly", 313); AddKeyword("ref", 314); AddKeyword("remove", 316); AddKeyword("return", 315); AddKeyword("sbyte", 317); AddKeyword("sealed", 318); AddKeyword("set", 371); AddKeyword("short", 319); AddKeyword("sizeof", 320); AddKeyword("stackalloc", 321); AddKeyword("static", 322); AddKeyword("string", 323); AddKeyword("struct", 324); AddKeyword("switch", 325); AddKeyword("this", 326); AddKeyword("throw", 327); AddKeyword("true", 328); AddKeyword("try", 329); AddKeyword("typeof", 330); AddKeyword("uint", 331); AddKeyword("ulong", 332); AddKeyword("unchecked", 333); AddKeyword("unsafe", 334); AddKeyword("ushort", 335); AddKeyword("using", 336); AddKeyword("virtual", 337); AddKeyword("void", 338); AddKeyword("volatile", 339); AddKeyword("while", 341); AddKeyword("partial", 343); AddKeyword("where", 340); AddKeyword("from", 345); AddKeyword("join", 347); AddKeyword("on", 348); AddKeyword("equals", 349); AddKeyword("select", 350); AddKeyword("group", 351); AddKeyword("by", 352); AddKeyword("let", 353); AddKeyword("orderby", 354); AddKeyword("ascending", 355); AddKeyword("descending", 356); AddKeyword("into", 357); AddKeyword("async", 363); AddKeyword("await", 364); AddKeyword("when", 366); keywords_preprocessor = new KeywordEntry[10][]; AddPreprocessorKeyword("region", PreprocessorDirective.Region); AddPreprocessorKeyword("endregion", PreprocessorDirective.Endregion); AddPreprocessorKeyword("if", PreprocessorDirective.If); AddPreprocessorKeyword("endif", PreprocessorDirective.Endif); AddPreprocessorKeyword("elif", PreprocessorDirective.Elif); AddPreprocessorKeyword("else", PreprocessorDirective.Else); AddPreprocessorKeyword("define", PreprocessorDirective.Define); AddPreprocessorKeyword("undef", PreprocessorDirective.Undef); AddPreprocessorKeyword("error", PreprocessorDirective.Error); AddPreprocessorKeyword("warning", PreprocessorDirective.Warning); AddPreprocessorKeyword("pragma", PreprocessorDirective.Pragma); AddPreprocessorKeyword("line", PreprocessorDirective.Line); csharp_format_info = NumberFormatInfo.InvariantInfo; styles = NumberStyles.Float; } private int GetKeyword(char[] id, int id_len) { if (id_len >= keywords.Length || keywords[id_len] == null) { return -1; } int num = id[0] - 95; if (num > 27) { return -1; } KeywordEntry keywordEntry = keywords[id_len][num]; if (keywordEntry == null) { return -1; } int num2; do { num2 = keywordEntry.Token; for (int i = 1; i < id_len; i++) { if (id[i] != keywordEntry.Value[i]) { num2 = 0; keywordEntry = keywordEntry.Next; break; } } } while (num2 == 0 && keywordEntry != null); if (num2 == 0) { return -1; } int num5; switch (num2) { case 370: case 371: if (!handle_get_set) { num2 = -1; } break; case 263: case 316: if (!handle_remove_add) { num2 = -1; } break; case 285: if (parsing_declaration == 0) { num2 = 359; } break; case 276: switch (peek_token()) { case 381: if (current_token != 396) { token(); num2 = 428; } break; case 377: case 426: num2 = 277; break; } break; case 366: if (current_token != 269 && !parsing_catch_when) { num2 = -1; } break; case 340: if ((!handle_where || current_token == 381) && !query_parsing) { num2 = -1; } break; case 345: { if (query_parsing) { break; } if (lambda_arguments_parsing || parsing_block == 0) { num2 = -1; break; } PushPosition(); parsing_generic_less_than = 1; int num8 = xtoken(); int num9 = num8; if (num9 <= 289) { if (num9 <= 270) { if (num9 == 265 || num9 == 267 || num9 == 270) { goto IL_0420; } } else if (num9 == 275 || num9 == 280 || num9 == 289) { goto IL_0420; } } else if (num9 <= 305) { if (num9 == 296 || num9 == 301 || num9 == 305) { goto IL_0420; } } else if (num9 <= 332) { if (num9 == 323 || (uint)(num9 - 331) <= 1u) { goto IL_0420; } } else { if (num9 == 338) { Expression.Error_VoidInvalidInTheContext(Location, Report); goto IL_04e5; } if (num9 == 424) { goto IL_0420; } } goto IL_04ae; } case 347: case 348: case 349: case 350: case 351: case 352: case 353: case 354: case 355: case 356: case 357: if (!query_parsing) { num2 = -1; } break; case 302: case 336: check_incorrect_doc_comment(); parsing_modifiers = false; break; case 343: { if (parsing_block > 0) { num2 = -1; break; } PushPosition(); num5 = token(); bool flag = num5 == 272 || num5 == 324 || num5 == 297 || num5 == 338; PopPosition(); if (flag) { if (num5 == 338) { if (context.Settings.Version <= LanguageVersion.ISO_2) { Report.FeatureIsNotAvailable(context, Location, "partial methods"); } } else if (context.Settings.Version == LanguageVersion.ISO_1) { Report.FeatureIsNotAvailable(context, Location, "partial types"); } return num2; } if (num5 < 372) { Report.Error(267, Location, "The `partial' modifier can be used only immediately before `class', `struct', `interface', or `void' keyword"); return token(); } id_builder[0] = 'p'; id_builder[1] = 'a'; id_builder[2] = 'r'; id_builder[3] = 't'; id_builder[4] = 'i'; id_builder[5] = 'a'; id_builder[6] = 'l'; num2 = -1; break; } case 363: if (parsing_modifiers) { if (parsing_attribute_section || peek_token() == 377) { num2 = -1; } } else if (parsing_block > 0) { int num6 = peek_token(); int num7 = num6; if (num7 != 278) { if (num7 != 424) { if (num7 != 425) { goto IL_0738; } } else { PushPosition(); xtoken(); if (xtoken() != 344) { PopPosition(); goto IL_0738; } PopPosition(); } } } else { num2 = -1; } goto IL_0775; case 364: if (parsing_block == 0) { num2 = -1; } break; case 327: { int num3 = current_token; int num4 = num3; if (num4 == 344 || num4 == 396 || num4 == 419) { num2 = 369; } break; } case 314: { switch (peek_token()) { case 324: token(); num2 = 431; break; case 343: token(); num2 = 432; break; } break; } IL_0775: if (num2 == 363 && context.Settings.Version <= LanguageVersion.V_4) { Report.FeatureIsNotAvailable(context, Location, "asynchronous functions"); } break; IL_0420: num5 = xtoken(); if (num5 == 382 || num5 == 380 || num5 == 349 || num5 == 387) { goto IL_04ae; } num2 = 346; query_parsing = true; if (context.Settings.Version <= LanguageVersion.ISO_2) { Report.FeatureIsNotAvailable(context, Location, "query expressions"); } goto IL_04e5; IL_04e5: PopPosition(); break; IL_0738: id_builder[0] = 'a'; id_builder[1] = 's'; id_builder[2] = 'y'; id_builder[3] = 'n'; id_builder[4] = 'c'; num2 = -1; goto IL_0775; IL_04ae: PopPosition(); id_builder[0] = 'f'; id_builder[1] = 'r'; id_builder[2] = 'o'; id_builder[3] = 'm'; return -1; } return num2; } private static PreprocessorDirective GetPreprocessorDirective(char[] id, int id_len) { if (id_len >= keywords_preprocessor.Length || keywords_preprocessor[id_len] == null) { return PreprocessorDirective.Invalid; } int num = id[0] - 95; if (num > 27) { return PreprocessorDirective.Invalid; } KeywordEntry keywordEntry = keywords_preprocessor[id_len][num]; if (keywordEntry == null) { return PreprocessorDirective.Invalid; } PreprocessorDirective preprocessorDirective = PreprocessorDirective.Invalid; do { preprocessorDirective = keywordEntry.Token; for (int i = 1; i < id_len; i++) { if (id[i] != keywordEntry.Value[i]) { preprocessorDirective = PreprocessorDirective.Invalid; keywordEntry = keywordEntry.Next; break; } } } while (preprocessorDirective == PreprocessorDirective.Invalid && keywordEntry != null); return preprocessorDirective; } private static bool is_identifier_start_character(int c) { if ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 95) { return true; } if (c < 128) { return false; } return is_identifier_start_character_slow_part((char)c); } private static bool is_identifier_part_character(char c) { if (c >= 'a' && c <= 'z') { return true; } if (c >= 'A' && c <= 'Z') { return true; } if (c == '_' || (c >= '0' && c <= '9')) { return true; } if (c < '\u0080') { return false; } return is_identifier_part_character_slow_part(c); } private static bool is_identifier_start_character_slow_part(char c) { UnicodeCategory unicodeCategory = char.GetUnicodeCategory(c); UnicodeCategory unicodeCategory2 = unicodeCategory; if ((uint)unicodeCategory2 <= 4u || unicodeCategory2 == UnicodeCategory.LetterNumber) { return true; } return false; } private static bool is_identifier_part_character_slow_part(char c) { switch (char.GetUnicodeCategory(c)) { case UnicodeCategory.UppercaseLetter: case UnicodeCategory.LowercaseLetter: case UnicodeCategory.TitlecaseLetter: case UnicodeCategory.ModifierLetter: case UnicodeCategory.OtherLetter: case UnicodeCategory.NonSpacingMark: case UnicodeCategory.SpacingCombiningMark: case UnicodeCategory.DecimalDigitNumber: case UnicodeCategory.LetterNumber: case UnicodeCategory.ConnectorPunctuation: return true; case UnicodeCategory.Format: return c != '\ufeff'; default: return false; } } public static bool IsKeyword(string s) { return keyword_strings.Contains(s); } private int TokenizeOpenParens() { current_token = -1; int num = 0; bool flag = false; bool flag2 = false; bool flag3 = false; while (true) { int num2 = current_token; token(); switch (current_token) { case 378: token(); if (current_token == 344) { return 425; } if (current_token == 387 && flag3) { return 430; } if (flag) { if (current_token == 382) { return 377; } return 426; } if (flag2) { switch (current_token) { case 264: case 265: case 267: case 270: case 271: case 275: case 276: case 277: case 278: case 280: case 286: case 288: case 289: case 296: case 301: case 303: case 304: case 317: case 319: case 320: case 323: case 326: case 327: case 328: case 330: case 331: case 332: case 333: case 334: case 335: case 364: case 377: case 383: case 386: case 423: case 424: return 426; } } return 377; case 379: case 397: if (num2 != 424 && num2 != 422) { break; } continue; case 364: case 424: switch (num2) { case 379: if (num == 0) { flag = false; flag2 = true; } break; case -1: case 380: case 397: case 420: if (num == 0) { flag2 = true; } break; default: flag2 = (flag = false); break; } continue; case 265: case 267: case 270: case 275: case 280: case 289: case 296: case 301: case 305: case 317: case 319: case 323: case 331: case 332: case 335: case 338: if (num == 0) { flag = true; } continue; case 380: if (num == 0) { num = 100; flag2 = (flag = false); flag3 = true; } continue; case 375: case 420: if (num++ == 0) { flag = true; } continue; case 376: case 422: num--; continue; case 358: case 392: if (num == 0) { flag = true; } continue; case 295: case 307: case 314: flag2 = (flag = false); continue; } break; } return 377; } public static bool IsValidIdentifier(string s) { if (s == null || s.Length == 0) { return false; } if (!is_identifier_start_character(s[0])) { return false; } for (int i = 1; i < s.Length; i++) { if (!is_identifier_part_character(s[i])) { return false; } } return true; } private bool parse_less_than(ref int genericDimension) { while (true) { int num = token(); if (num == 375) { do { num = token(); if (num == 257) { return true; } } while (num != 376); num = token(); } else if (num == 295 || num == 307) { num = token(); } int num2 = num; int num3 = num2; if (num3 <= 305) { if (num3 <= 280) { if (num3 <= 267) { if (num3 != 265 && num3 != 267) { break; } } else if (num3 != 270 && num3 != 275 && num3 != 280) { break; } } else if (num3 <= 295) { if (num3 != 289) { if (num3 != 295) { break; } goto IL_01ef; } } else if (num3 != 296 && num3 != 301 && num3 != 305) { break; } } else if (num3 <= 332) { if (num3 <= 317) { if (num3 == 307) { goto IL_01ef; } if (num3 != 317) { break; } } else if (num3 != 319 && num3 != 323 && (uint)(num3 - 331) > 1u) { break; } } else if (num3 <= 377) { if (num3 != 335 && num3 != 338) { if (num3 != 377) { break; } int num4 = 1; while (true) { switch (token()) { case 380: if (num4 == 1) { return true; } break; case 377: num4++; break; case 378: if (--num4 <= 0) { return false; } break; case 257: case 422: return false; } } } } else { if (num3 == 380) { while (true) { genericDimension++; switch (token()) { case 380: break; case 422: genericDimension++; return true; default: return false; } } } if (num3 == 422) { genericDimension = 1; return true; } if (num3 != 424) { break; } } while (true) { num = token(); if (num == 422) { return true; } if (num == 380 || num == 379 || num == 397) { break; } if (num == 358 || num == 392) { continue; } switch (num) { case 420: { int genericDimension2 = 0; if (!parse_less_than(ref genericDimension2)) { return false; } break; } case 375: while (true) { switch (token()) { case 376: break; case 380: continue; default: return false; } break; } break; default: return false; } } continue; IL_01ef: return true; } return false; } public int peek_token() { PushPosition(); int result = token(); PopPosition(); return result; } private int TokenizePossibleNullableType() { if (parsing_block == 0 || parsing_type > 0) { return 358; } int num = peek_char(); if (num == 63) { get_char(); return 419; } if (num == 46) { num = reader.Peek(); return (num >= 48 && num <= 57) ? 396 : 365; } if (num != 32) { if (num == 44 || num == 59 || num == 62) { return 358; } if (num == 42 || (num >= 48 && num <= 57)) { return 396; } } PushPosition(); current_token = 258; int num2 = 0; int num3 = 0; int num4 = 0; int num5; switch (xtoken()) { case 379: case 429: num5 = 365; break; case 286: case 303: case 304: case 314: case 321: case 326: case 327: case 328: case 367: case 423: case 428: num5 = 396; break; case 375: case 378: case 380: case 381: case 382: case 396: case 419: case 422: num5 = 358; break; case 377: case 425: case 426: num5 = -1; num2++; break; case 420: case 421: case 427: num5 = -1; num3++; break; default: num5 = -1; break; } if (num5 == -1) { switch (xtoken()) { case 295: case 373: case 380: case 382: num5 = 358; break; case 381: num5 = 396; break; case 377: case 425: case 426: num2++; goto default; case 375: case 429: num4++; goto default; case 378: num2--; goto default; case 420: case 421: case 427: num3++; goto default; default: { int num6 = 1; int num7 = 0; int num8 = 0; int num9; while ((num9 = xtoken()) != 257) { switch (num9) { case 373: num8++; continue; case 377: case 425: case 426: num2++; continue; case 374: num8--; continue; case 420: case 421: case 427: num3++; continue; case 375: case 429: num4++; continue; case 376: num4--; continue; case 378: if (num2 > 0) { num2--; continue; } PopPosition(); return 358; case 422: if (num3 > 0) { num3--; continue; } PopPosition(); return 358; } if (num8 != 0) { continue; } if (num9 == 382) { break; } if (num2 != 0) { continue; } switch (num9) { case 380: if (num3 != 0 || num4 != 0) { continue; } PopPosition(); return 358; case 381: break; case 396: num6++; continue; default: continue; } if (++num7 != num6) { continue; } break; } num5 = ((num7 != num6 && num8 == 0) ? 358 : 396); break; } } } PopPosition(); return num5; } private bool decimal_digits(int c) { bool result = false; if (c != -1) { if (number_pos == 512) { Error_NumericConstantTooLong(); } number_builder[number_pos++] = (char)c; } int num; while ((num = peek_char2()) != -1 && num >= 48 && num <= 57) { if (number_pos == 512) { Error_NumericConstantTooLong(); } number_builder[number_pos++] = (char)num; get_char(); result = true; } return result; } private static bool is_hex(int e) { return (e >= 48 && e <= 57) || (e >= 65 && e <= 70) || (e >= 97 && e <= 102); } private static TypeCode real_type_suffix(int c) { switch (c) { case 70: case 102: return TypeCode.Single; case 68: case 100: return TypeCode.Double; case 77: case 109: return TypeCode.Decimal; default: return TypeCode.Empty; } } private ILiteralConstant integer_type_suffix(ulong ul, int c, Location loc) { bool flag = false; bool flag2 = false; if (c != -1) { bool flag3 = true; do { int num = c; int num2 = num; if (num2 <= 85) { if (num2 == 76) { goto IL_0080; } if (num2 == 85) { goto IL_0044; } } else { if (num2 == 108) { if (!flag) { Report.Warning(78, 4, Location, "The `l' suffix is easily confused with the digit `1' (use `L' for clarity)"); } goto IL_0080; } if (num2 == 117) { goto IL_0044; } } flag3 = false; goto IL_0098; IL_0080: if (flag2) { flag3 = false; } flag2 = true; get_char(); goto IL_0098; IL_0098: c = peek_char(); continue; IL_0044: if (flag) { flag3 = false; } flag = true; get_char(); goto IL_0098; } while (flag3); } if (flag2 && flag) { return new ULongLiteral(context.BuiltinTypes, ul, loc); } if (flag) { if ((ul & 0xFFFFFFFF00000000uL) == 0) { return new UIntLiteral(context.BuiltinTypes, (uint)ul, loc); } return new ULongLiteral(context.BuiltinTypes, ul, loc); } if (flag2) { if ((ul & 0x8000000000000000uL) != 0) { return new ULongLiteral(context.BuiltinTypes, ul, loc); } return new LongLiteral(context.BuiltinTypes, (long)ul, loc); } if ((ul & 0xFFFFFFFF00000000uL) == 0) { uint num3 = (uint)ul; if ((num3 & 0x80000000u) != 0) { return new UIntLiteral(context.BuiltinTypes, num3, loc); } return new IntLiteral(context.BuiltinTypes, (int)num3, loc); } if ((ul & 0x8000000000000000uL) != 0) { return new ULongLiteral(context.BuiltinTypes, ul, loc); } return new LongLiteral(context.BuiltinTypes, (long)ul, loc); } private ILiteralConstant adjust_int(int c, Location loc) { try { if (number_pos > 9) { ulong num = (uint)(number_builder[0] - 48); for (int i = 1; i < number_pos; i++) { num = checked(num * 10 + (uint)(number_builder[i] - 48)); } return integer_type_suffix(num, c, loc); } uint num2 = (uint)(number_builder[0] - 48); for (int j = 1; j < number_pos; j++) { num2 = checked(num2 * 10 + (uint)(number_builder[j] - 48)); } return integer_type_suffix(num2, c, loc); } catch (OverflowException) { Error_NumericConstantTooLong(); return new IntLiteral(context.BuiltinTypes, 0, loc); } catch (FormatException) { Error_InvalidNumber(); return new IntLiteral(context.BuiltinTypes, 0, loc); } } private ILiteralConstant adjust_real(TypeCode t, Location loc) { string s = new string(number_builder, 0, number_pos); switch (t) { case TypeCode.Decimal: try { return new DecimalLiteral(context.BuiltinTypes, decimal.Parse(s, styles, csharp_format_info), loc); } catch (OverflowException) { Report.Error(594, Location, "Floating-point constant is outside the range of type `{0}'", "decimal"); return new DecimalLiteral(context.BuiltinTypes, 0m, loc); } case TypeCode.Single: try { return new FloatLiteral(context.BuiltinTypes, float.Parse(s, styles, csharp_format_info), loc); } catch (OverflowException) { Report.Error(594, Location, "Floating-point constant is outside the range of type `{0}'", "float"); return new FloatLiteral(context.BuiltinTypes, 0f, loc); } default: try { return new DoubleLiteral(context.BuiltinTypes, double.Parse(s, styles, csharp_format_info), loc); } catch (OverflowException) { Report.Error(594, loc, "Floating-point constant is outside the range of type `{0}'", "double"); return new DoubleLiteral(context.BuiltinTypes, 0.0, loc); } } } private ILiteralConstant handle_hex(Location loc) { bool flag = false; int num = 0; get_char(); int num2; while ((num2 = peek_char()) != -1) { if (is_hex(num2)) { number_builder[number_pos++] = (char)num2; get_char(); num = num2; continue; } if (num2 != 95) { break; } get_char(); if (!flag) { if (context.Settings.Version < LanguageVersion.V_7) { Report.FeatureIsNotAvailable(context, Location, "digit separators"); } flag = true; } num = num2; } if (number_pos == 0 || num == 95) { Error_InvalidNumber(); return new IntLiteral(context.BuiltinTypes, 0, loc); } string s = new string(number_builder, 0, number_pos); try { ulong ul = ((number_pos > 8) ? ulong.Parse(s, NumberStyles.HexNumber) : uint.Parse(s, NumberStyles.HexNumber)); return integer_type_suffix(ul, peek_char(), loc); } catch (OverflowException) { Error_NumericConstantTooLong(); return new IntLiteral(context.BuiltinTypes, 0, loc); } catch (FormatException) { Error_InvalidNumber(); return new IntLiteral(context.BuiltinTypes, 0, loc); } } private ILiteralConstant handle_binary(Location loc) { ulong num = 0uL; bool flag = false; int num2 = -1; int num3 = 0; get_char(); int num4; while ((num4 = peek_char()) != -1) { if (num4 == 48 || num4 == 49) { num <<= 1; num3++; if (num4 == 49) { num |= 1; } get_char(); if (num3 > 64) { Error_NumericConstantTooLong(); return new IntLiteral(context.BuiltinTypes, 0, loc); } num2 = num4; continue; } if (num4 != 95) { break; } get_char(); if (!flag) { if (context.Settings.Version < LanguageVersion.V_7) { Report.FeatureIsNotAvailable(context, Location, "digit separators"); } flag = true; } num2 = num4; } if (num3 == 0 || num2 == 95) { Error_InvalidNumber(); return new IntLiteral(context.BuiltinTypes, 0, loc); } return integer_type_suffix(num, peek_char(), loc); } private int is_number(int c, bool dotLead) { number_pos = 0; Location location = Location; bool flag = false; ILiteralConstant literalConstant; if (!dotLead) { if (c == 48) { int num = peek_char(); if (num == 120 || num == 88) { literalConstant = (ILiteralConstant)(val = handle_hex(location)); return 423; } if (num == 98 || num == 66) { if (context.Settings.Version < LanguageVersion.V_7) { Report.FeatureIsNotAvailable(context, Location, "binary literals"); } literalConstant = (ILiteralConstant)(val = handle_binary(location)); return 423; } } do { decimal_digits(c); c = peek_char(); if (c != 95) { break; } if (!flag) { if (context.Settings.Version < LanguageVersion.V_7) { Report.FeatureIsNotAvailable(context, Location, "digit separators"); } flag = true; } do { get_char(); c = peek_char(); } while (c == 95); } while (c >= 48 && c <= 57); } bool flag2 = false; if (c == 46) { if (!dotLead) { get_char(); } if (!decimal_digits(46)) { putback(46); number_pos--; literalConstant = (ILiteralConstant)(val = adjust_int(-1, location)); return 423; } flag2 = true; c = peek_char(); } if (c == 101 || c == 69) { flag2 = true; get_char(); if (number_pos == 512) { Error_NumericConstantTooLong(); } number_builder[number_pos++] = (char)c; c = get_char(); switch (c) { case 43: if (number_pos == 512) { Error_NumericConstantTooLong(); } number_builder[number_pos++] = '+'; c = -1; break; case 45: if (number_pos == 512) { Error_NumericConstantTooLong(); } number_builder[number_pos++] = '-'; c = -1; break; default: if (number_pos == 512) { Error_NumericConstantTooLong(); } number_builder[number_pos++] = '+'; break; } do { bool flag3 = decimal_digits(c); c = peek_char(); if (!(c == 95 && flag3)) { break; } if (!flag) { if (context.Settings.Version < LanguageVersion.V_7) { Report.FeatureIsNotAvailable(context, Location, "digit separators"); } flag = true; } do { get_char(); c = peek_char(); } while (c == 95); } while (c >= 48 && c <= 57); } TypeCode typeCode = real_type_suffix(c); if (typeCode == TypeCode.Empty && !flag2) { literalConstant = adjust_int(c, location); } else { flag2 = true; if (typeCode != TypeCode.Empty) { get_char(); } literalConstant = adjust_real(typeCode, location); } val = literalConstant; return 423; } private int getHex(int count, out int surrogate, out bool error) { int num = 0; int num2 = ((count != -1) ? count : 4); get_char(); error = false; surrogate = 0; for (int i = 0; i < num2; i++) { int num3 = get_char(); if (num3 >= 48 && num3 <= 57) { num3 -= 48; } else if (num3 >= 65 && num3 <= 70) { num3 = num3 - 65 + 10; } else { if (num3 < 97 || num3 > 102) { error = true; return 0; } num3 = num3 - 97 + 10; } num = num * 16 + num3; if (count == -1) { int num4 = peek_char(); if (num4 == -1 || !is_hex((ushort)num4)) { break; } } } if (num2 == 8) { if (num > 1114111) { error = true; return 0; } if (num >= 65536) { surrogate = (num - 65536) % 1024 + 56320; num = (num - 65536) / 1024 + 55296; } } return num; } private int escape(int c, out int surrogate) { int num = peek_char(); if (c != 92) { surrogate = 0; return c; } int hex; switch (num) { case 97: hex = 7; break; case 98: hex = 8; break; case 110: hex = 10; break; case 116: hex = 9; break; case 118: hex = 11; break; case 114: hex = 13; break; case 92: hex = 92; break; case 102: hex = 12; break; case 48: hex = 0; break; case 34: hex = 34; break; case 39: hex = 39; break; case 120: { hex = getHex(-1, out surrogate, out var error); if (error) { goto default; } return hex; } case 85: case 117: return EscapeUnicode(num, out surrogate); default: surrogate = 0; Report.Error(1009, Location, "Unrecognized escape sequence `\\{0}'", ((char)num).ToString()); return num; } get_char(); surrogate = 0; return hex; } private int EscapeUnicode(int ch, out int surrogate) { ch = ((ch != 85) ? getHex(4, out surrogate, out var error) : getHex(8, out surrogate, out error)); if (error) { Report.Error(1009, Location, "Unrecognized escape sequence"); } return ch; } private int get_char() { int num; if (putback_char != -1) { num = putback_char; putback_char = -1; } else { num = reader.Read(); } if (num <= 13) { switch (num) { case 13: if (peek_char() == 10) { putback_char = -1; } num = 10; advance_line(); break; case 10: advance_line(); break; default: col++; break; } } else if (num >= 8232 && num <= 8233) { advance_line(); } else { col++; } return num; } private void advance_line() { line++; ref_line++; previous_col = col; col = 0; } private int peek_char() { if (putback_char == -1) { putback_char = reader.Read(); } return putback_char; } private int peek_char2() { if (putback_char != -1) { return putback_char; } return reader.Peek(); } public void putback(int c) { if (putback_char != -1) { throw new InternalErrorException($"Secondary putback [{(char)putback_char}] putting back [{(char)c}] is not allowed", Location); } if (c == 10 || col == 0 || (c >= 8232 && c <= 8233)) { line--; ref_line--; col = previous_col; } else { col--; } putback_char = c; } public bool advance() { return peek_char() != -1 || CompleteOnEOF; } public object value() { return val; } public int token() { current_token = xtoken(); return current_token; } private int TokenizePreprocessorKeyword(out int c) { do { c = get_char(); } while (c == 32 || c == 9); int result = 0; while (c != -1 && c >= 97 && c <= 122) { id_builder[result++] = (char)c; c = get_char(); if (c != 92) { continue; } int num = peek_char(); if (num != 85 && num != 117) { continue; } c = EscapeUnicode(c, out var surrogate); if (surrogate != 0) { if (is_identifier_part_character((char)c)) { id_builder[result++] = (char)c; } c = surrogate; } } return result; } private PreprocessorDirective get_cmd_arg(out string arg) { tokens_seen = false; arg = ""; int c; PreprocessorDirective preprocessorDirective = GetPreprocessorDirective(id_builder, TokenizePreprocessorKeyword(out c)); if ((preprocessorDirective & PreprocessorDirective.CustomArgumentsParsing) != PreprocessorDirective.Invalid) { return preprocessorDirective; } while (c == 32 || c == 9) { c = get_char(); } int num = (int)(preprocessorDirective & PreprocessorDirective.RequiresArgument); int num2 = 0; while (c != -1 && c != 10 && c != 8232 && c != 8233) { if (c == 92 && num >= 0) { if (num != 0) { num = 1; int num3 = peek_char(); if (num3 == 85 || num3 == 117) { c = EscapeUnicode(c, out var surrogate); if (surrogate != 0) { if (is_identifier_part_character((char)c)) { if (num2 == value_builder.Length) { Array.Resize(ref value_builder, num2 * 2); } value_builder[num2++] = (char)c; } c = surrogate; } } } else { num = -1; } } else if (c == 47 && peek_char() == 47) { get_char(); ReadToEndOfLine(); break; } if (num2 == value_builder.Length) { Array.Resize(ref value_builder, num2 * 2); } value_builder[num2++] = (char)c; c = get_char(); } if (num2 != 0) { if (num2 > 512) { arg = new string(value_builder, 0, num2); } else { arg = InternIdentifier(value_builder, num2); } arg = arg.Trim(simple_whitespaces); } return preprocessorDirective; } private bool PreProcessLine() { Location location = Location; int c; int num = TokenizePreprocessorKeyword(out c); if (num == line_default.Length) { if (!IsTokenIdentifierEqual(line_default)) { return false; } current_source = source_file.SourceFile; if (!hidden_block_start.IsNull) { current_source.RegisterHiddenScope(hidden_block_start, location); hidden_block_start = Location.Null; } ref_line = line; return true; } if (num == line_hidden.Length) { if (!IsTokenIdentifierEqual(line_hidden)) { return false; } if (hidden_block_start.IsNull) { hidden_block_start = location; } return true; } if (num != 0 || c < 48 || c > 57) { ReadToEndOfLine(); return false; } int num2 = TokenizeNumber(c); if (num2 < 1) { ReadToEndOfLine(); return num2 != 0; } c = get_char(); if (c == 32) { do { c = get_char(); } while (c == 32 || c == 9); } else if (c == 34) { c = 0; } if (c != 10 && c != 47 && c != 34 && c != 8232 && c != 8233) { ReadToEndOfLine(); Report.Error(1578, location, "Filename, single-line comment or end-of-line expected"); return true; } string text = null; if (c == 34) { text = TokenizeFileName(ref c); while (c == 32 || c == 9) { c = get_char(); } } if (c != 10 && c != 8232 && c != 8233) { if (c != 47) { ReadToEndOfLine(); Error_EndLineExpected(); return true; } ReadSingleLineComment(); } if (text != null) { current_source = context.LookupFile(source_file, text); source_file.AddIncludeFile(current_source); } if (!hidden_block_start.IsNull) { current_source.RegisterHiddenScope(hidden_block_start, location); hidden_block_start = Location.Null; } ref_line = num2; return true; } private void PreProcessDefinition(bool is_define, string ident, bool caller_is_taking) { if (ident.Length == 0 || ident == "true" || ident == "false") { Report.Error(1001, Location, "Missing identifier to pre-processor directive"); return; } if (ident.IndexOfAny(simple_whitespaces) != -1) { Error_EndLineExpected(); return; } if (!is_identifier_start_character(ident[0])) { Report.Error(1001, Location, "Identifier expected: {0}", ident); } string text = ident.Substring(1); foreach (char c in text) { if (!is_identifier_part_character(c)) { Report.Error(1001, Location, "Identifier expected: {0}", ident); return; } } if (!caller_is_taking) { return; } if (is_define) { if (!context.Settings.IsConditionalSymbolDefined(ident)) { source_file.AddDefine(ident); } } else { source_file.AddUndefine(ident); } } private byte read_hex(out bool error) { int num = get_char(); int num2; if (num >= 48 && num <= 57) { num2 = num - 48; } else if (num >= 65 && num <= 70) { num2 = num - 65 + 10; } else { if (num < 97 || num > 102) { error = true; return 0; } num2 = num - 97 + 10; } num2 *= 16; num = get_char(); if (num >= 48 && num <= 57) { num2 += num - 48; } else if (num >= 65 && num <= 70) { num2 += num - 65 + 10; } else { if (num < 97 || num > 102) { error = true; return 0; } num2 += num - 97 + 10; } error = false; return (byte)num2; } private bool ParsePragmaChecksum() { int c = get_char(); if (c != 34) { return false; } string name = TokenizeFileName(ref c); if (c != 32) { return false; } SourceFile sourceFile = context.LookupFile(source_file, name); if (get_char() != 34 || get_char() != 123) { return false; } byte[] array = new byte[16]; int i; bool error; for (i = 0; i < 4; i++) { array[i] = read_hex(out error); if (error) { return false; } } if (get_char() != 45) { return false; } for (; i < 10; i++) { array[i] = read_hex(out error); if (error) { return false; } array[i++] = read_hex(out error); if (error) { return false; } if (get_char() != 45) { return false; } } for (; i < 16; i++) { array[i] = read_hex(out error); if (error) { return false; } } if (get_char() != 125 || get_char() != 34) { return false; } c = get_char(); if (c != 32) { return false; } if (get_char() != 34) { return false; } List list = new List(16); Location location = Location; c = peek_char(); while (c != 34 && c != -1) { list.Add(read_hex(out error)); if (error) { return false; } c = peek_char(); } if (c == 47) { ReadSingleLineComment(); } else if (get_char() != 34) { return false; } if (context.Settings.GenerateDebugInfo) { byte[] array2 = list.ToArray(); if (sourceFile.HasChecksum && !ArrayComparer.IsEqual(sourceFile.Checksum, array2)) { Report.Warning(1697, 1, location, "Different checksum values specified for file `{0}'", sourceFile.Name); } sourceFile.SetChecksum(array, array2); current_source.AutoGenerated = true; } return true; } private bool IsTokenIdentifierEqual(char[] identifier) { for (int i = 0; i < identifier.Length; i++) { if (identifier[i] != id_builder[i]) { return false; } } return true; } private bool ScanClosingInterpolationBrace() { PushPosition(); bool? flag = null; int num = 0; do { switch (reader.Read()) { case 34: num++; break; case 92: { int num2 = reader.Read(); if (num2 == -1) { flag = false; } break; } case -1: flag = false; break; case 125: if (num % 2 == 1) { flag = true; } break; } } while (!flag.HasValue); PopPosition(); return flag.Value; } private int TokenizeNumber(int value) { number_pos = 0; decimal_digits(value); uint num = (uint)(number_builder[0] - 48); try { for (int i = 1; i < number_pos; i++) { num = checked(num * 10 + (uint)(number_builder[i] - 48)); } return (int)num; } catch (OverflowException) { Error_NumericConstantTooLong(); return -1; } } private string TokenizeFileName(ref int c) { StringBuilder stringBuilder = new StringBuilder(); while (c != -1 && c != 10 && c != 8232 && c != 8233) { c = get_char(); if (c == 34) { c = get_char(); break; } stringBuilder.Append((char)c); } if (stringBuilder.Length == 0) { Report.Warning(1709, 1, Location, "Filename specified for preprocessor directive is empty"); } return stringBuilder.ToString(); } private int TokenizePragmaWarningIdentifier(ref int c, ref bool identifier) { if ((c >= 48 && c <= 57) || is_identifier_start_character(c)) { int num; if (c >= 48 && c <= 57) { number_pos = 0; num = TokenizeNumber(c); c = get_char(); if (c != 32 && c != 9 && c != 44 && c != 10 && c != -1 && c != 8232 && c != 8233) { return ReadPragmaWarningComment(c); } } else { int num2 = 0; num = -1; id_builder[num2++] = (char)c; while (c < 512) { c = reader.Read(); id_builder[num2] = (char)c; if (c >= 48 && c <= 57) { if (num2 == 5 && id_builder[0] == 'C' && id_builder[1] == 'S') { num = 0; int num3 = 1000; for (int i = 0; i < 4; i++) { char c2 = id_builder[i + 2]; if (c2 < '0' || c2 > '9') { num = -1; break; } num += (c2 - 48) * num3; num3 /= 10; } } } else { if (c == 10 || c == 8232 || c == 8233) { advance_line(); break; } if ((c < 97 || c > 122) && (c < 65 || c > 90) && c != 95) { break; } } num2++; } if (num < 0) { identifier = true; num = num2; } } while (c == 32 || c == 9) { c = get_char(); } if (c == 44) { c = get_char(); } while (c == 32 || c == 9) { c = get_char(); } return num; } return ReadPragmaWarningComment(c); } private int ReadPragmaWarningComment(int c) { if (c == 47) { ReadSingleLineComment(); } else { Report.Warning(1692, 1, Location, "Invalid number"); ReadToEndOfLine(); } return -1; } private void ReadToEndOfLine() { int num; do { num = get_char(); } while (num != -1 && num != 10 && num != 8232 && num != 8233); } private void ReadSingleLineComment() { if (peek_char() != 47) { Report.Warning(1696, 1, Location, "Single-line comment or end-of-line expected"); } ReadToEndOfLine(); } private void ParsePragmaDirective() { int num = TokenizePreprocessorKeyword(out var c); if (num == pragma_warning.Length && IsTokenIdentifierEqual(pragma_warning)) { num = TokenizePreprocessorKeyword(out c); if (num == pragma_warning_disable.Length) { bool flag = IsTokenIdentifierEqual(pragma_warning_disable); if (flag || IsTokenIdentifierEqual(pragma_warning_restore)) { while (c == 32 || c == 9) { c = get_char(); } Location location = Location; if (c == 10 || c == 47 || c == 8232 || c == 8233) { if (c == 47) { ReadSingleLineComment(); } if (flag) { Report.RegisterWarningRegion(location).WarningDisable(location.Row); } else { Report.RegisterWarningRegion(location).WarningEnable(location.Row); } return; } int num2; do { bool identifier = false; num2 = TokenizePragmaWarningIdentifier(ref c, ref identifier); if (num2 > 0 && !identifier) { if (flag) { Report.RegisterWarningRegion(location).WarningDisable(location, num2, context.Report); } else { Report.RegisterWarningRegion(location).WarningEnable(location, num2, context); } } } while (num2 >= 0 && c != 10 && c != -1 && c != 8232 && c != 8233); return; } } Report.Warning(1634, 1, Location, "Expected disable or restore"); ReadToEndOfLine(); } else if (num == pragma_checksum.Length && IsTokenIdentifierEqual(pragma_checksum)) { if (c != 32 || !ParsePragmaChecksum()) { Report.Warning(1695, 1, Location, "Invalid #pragma checksum syntax. Expected \"filename\" \"{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\" \"XXXX...\""); } } else { Report.Warning(1633, 1, Location, "Unrecognized #pragma directive"); ReadToEndOfLine(); } } private bool eval_val(string s) { if (s == "true") { return true; } if (s == "false") { return false; } return source_file.IsConditionalDefined(s); } private bool pp_primary(ref string s) { s = s.Trim(); int length = s.Length; if (length > 0) { char c = s[0]; if (c == '(') { s = s.Substring(1); bool result = pp_expr(ref s, isTerm: false); if (s.Length > 0 && s[0] == ')') { s = s.Substring(1); return result; } Error_InvalidDirective(); return false; } if (is_identifier_start_character(c)) { for (int i = 1; i < length; i++) { c = s[i]; if (!is_identifier_part_character(c)) { bool result2 = eval_val(s.Substring(0, i)); s = s.Substring(i); return result2; } } bool result3 = eval_val(s); s = ""; return result3; } } Error_InvalidDirective(); return false; } private bool pp_unary(ref string s) { s = s.Trim(); int length = s.Length; if (length > 0) { if (s[0] == '!') { if (length > 1 && s[1] == '=') { Error_InvalidDirective(); return false; } s = s.Substring(1); return !pp_primary(ref s); } return pp_primary(ref s); } Error_InvalidDirective(); return false; } private bool pp_eq(ref string s) { bool flag = pp_unary(ref s); s = s.Trim(); int length = s.Length; if (length > 0) { if (s[0] == '=') { if (length > 2 && s[1] == '=') { s = s.Substring(2); return flag == pp_unary(ref s); } Error_InvalidDirective(); return false; } if (s[0] == '!' && length > 1 && s[1] == '=') { s = s.Substring(2); return flag != pp_unary(ref s); } } return flag; } private bool pp_and(ref string s) { bool flag = pp_eq(ref s); s = s.Trim(); int length = s.Length; if (length > 0 && s[0] == '&') { if (length > 2 && s[1] == '&') { s = s.Substring(2); return flag & pp_and(ref s); } Error_InvalidDirective(); return false; } return flag; } private bool pp_expr(ref string s, bool isTerm) { bool flag = pp_and(ref s); s = s.Trim(); int length = s.Length; if (length > 0) { char c = s[0]; if (c == '|') { if (length > 2 && s[1] == '|') { s = s.Substring(2); return flag | pp_expr(ref s, isTerm); } Error_InvalidDirective(); return false; } if (isTerm) { Error_EndLineExpected(); return false; } } return flag; } private bool eval(string s) { bool result = pp_expr(ref s, isTerm: true); s = s.Trim(); if (s.Length != 0) { return false; } return result; } private void Error_NumericConstantTooLong() { Report.Error(1021, Location, "Integral constant is too large"); } private void Error_InvalidNumber() { Report.Error(1013, Location, "Invalid number"); } private void Error_InvalidDirective() { Report.Error(1517, Location, "Invalid preprocessor directive"); } private void Error_UnexpectedDirective(string extra) { Report.Error(1028, Location, "Unexpected processor directive ({0})", extra); } private void Error_TokensSeen() { Report.Error(1032, Location, "Cannot define or undefine preprocessor symbols after first token in file"); } private void Eror_WrongPreprocessorLocation() { Report.Error(1040, Location, "Preprocessor directives must appear as the first non-whitespace character on a line"); } private void Error_EndLineExpected() { Report.Error(1025, Location, "Single-line comment or end-of-line expected"); } private void WarningMisplacedComment(Location loc) { if (doc_state != XmlCommentState.Error) { doc_state = XmlCommentState.Error; Report.Warning(1587, 2, loc, "XML comment is not placed on a valid language element"); } } private bool ParsePreprocessingDirective(bool caller_is_taking) { bool flag = false; string arg; PreprocessorDirective preprocessorDirective = get_cmd_arg(out arg); switch (preprocessorDirective) { case PreprocessorDirective.Region: flag = true; arg = "true"; goto case PreprocessorDirective.If; case PreprocessorDirective.Endregion: { if (ifstack == null || ifstack.Count == 0) { Error_UnexpectedDirective("no #region for this #endregion"); return true; } int num2 = ifstack.Pop(); if ((num2 & 0x10) == 0) { Report.Error(1027, Location, "Expected `#endif' directive"); } return caller_is_taking; } case PreprocessorDirective.If: { if (ifstack == null) { ifstack = new Stack(2); } int num5 = (flag ? 16 : 0); if (ifstack.Count == 0) { num5 |= 8; } else { int num6 = ifstack.Peek(); if ((num6 & 1) != 0) { num5 |= 8; } } if (eval(arg) && caller_is_taking) { ifstack.Push(num5 | 1); return true; } ifstack.Push(num5); return false; } case PreprocessorDirective.Endif: { if (ifstack == null || ifstack.Count == 0) { Error_UnexpectedDirective("no #if for this #endif"); return true; } int num2 = ifstack.Pop(); if ((num2 & 0x10) != 0) { Report.Error(1038, Location, "#endregion directive expected"); } if (arg.Length != 0) { Error_EndLineExpected(); } if (ifstack.Count == 0) { return true; } int num3 = ifstack.Peek(); return (num3 & 1) != 0; } case PreprocessorDirective.Elif: { if (ifstack == null || ifstack.Count == 0) { Error_UnexpectedDirective("no #if for this #elif"); return true; } int num = ifstack.Pop(); if ((num & 0x10) != 0) { Report.Error(1038, Location, "#endregion directive expected"); return true; } if ((num & 4) != 0) { Error_UnexpectedDirective("#elif not valid after #else"); return true; } if ((num & 1) != 0) { ifstack.Push(0); return false; } if (eval(arg) && (num & 8) != 0) { ifstack.Push(num | 1); return true; } ifstack.Push(num); return false; } case PreprocessorDirective.Else: { if (ifstack == null || ifstack.Count == 0) { Error_UnexpectedDirective("no #if for this #else"); return true; } int num4 = ifstack.Peek(); if ((num4 & 0x10) != 0) { Report.Error(1038, Location, "#endregion directive expected"); return true; } if ((num4 & 4) != 0) { Error_UnexpectedDirective("#else within #else"); return true; } ifstack.Pop(); if (arg.Length != 0) { Error_EndLineExpected(); return true; } bool flag2 = false; if ((num4 & 8) != 0) { flag2 = (num4 & 1) == 0; num4 = ((!flag2) ? (num4 & -2) : (num4 | 1)); } ifstack.Push(num4 | 4); return flag2; } case PreprocessorDirective.Define: if (any_token_seen) { if (caller_is_taking) { Error_TokensSeen(); } return caller_is_taking; } PreProcessDefinition(is_define: true, arg, caller_is_taking); return caller_is_taking; case PreprocessorDirective.Undef: if (any_token_seen) { if (caller_is_taking) { Error_TokensSeen(); } return caller_is_taking; } PreProcessDefinition(is_define: false, arg, caller_is_taking); return caller_is_taking; case PreprocessorDirective.Invalid: Report.Error(1024, Location, "Wrong preprocessor directive"); return true; default: if (!caller_is_taking) { return false; } switch (preprocessorDirective) { case PreprocessorDirective.Error: Report.Error(1029, Location, "#error: '{0}'", arg); return true; case PreprocessorDirective.Warning: Report.Warning(1030, 1, Location, "#warning: `{0}'", arg); return true; case PreprocessorDirective.Pragma: if (context.Settings.Version == LanguageVersion.ISO_1) { Report.FeatureIsNotAvailable(context, Location, "#pragma"); } ParsePragmaDirective(); return true; case PreprocessorDirective.Line: { Location location = Location; if (!PreProcessLine()) { Report.Error(1576, location, "The line number specified for #line directive is missing or invalid"); } return caller_is_taking; } default: throw new NotImplementedException(preprocessorDirective.ToString()); } } } private int consume_string(bool quoted) { int num = 0; Location location = Location; if (quoted) { location -= 1; } while (true) { int num2; if (putback_char != -1) { num2 = putback_char; putback_char = -1; } else { num2 = reader.Read(); } if (num2 == 34) { col++; if (quoted && peek_char() == 34) { if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } value_builder[num++] = (char)num2; get_char(); continue; } ILiteralConstant literalConstant = new StringLiteral(context.BuiltinTypes, CreateStringFromBuilder(num), location); val = literalConstant; return 423; } if (num2 == 10 || num2 == 8232 || num2 == 8233) { if (!quoted) { Report.Error(1010, Location, "Newline in constant"); advance_line(); if (num > 1 && value_builder[num - 1] == '\r') { num--; } val = new StringLiteral(context.BuiltinTypes, new string(value_builder, 0, num), location); return 423; } advance_line(); } else if (num2 == 92 && !quoted) { col++; num2 = escape(num2, out var surrogate); if (num2 == -1) { return 259; } if (surrogate != 0) { if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } value_builder[num++] = (char)num2; num2 = surrogate; } } else { if (num2 == -1) { break; } col++; } if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } value_builder[num++] = (char)num2; } Report.Error(1039, Location, "Unterminated string literal"); return 257; } private int consume_identifier(int s) { int result = consume_identifier(s, quoted: false); if (doc_state == XmlCommentState.Allowed) { doc_state = XmlCommentState.NotAllowed; } return result; } private int consume_identifier(int c, bool quoted) { int num = 0; int num2 = col; if (quoted) { num2--; } if (c == 92) { c = escape(c, out var surrogate); if (!quoted && !is_identifier_start_character(c)) { if (surrogate == 0) { Report.Error(1056, Location, "Unexpected character `\\{0}'", c.ToString("x4")); return 259; } id_builder[num++] = (char)c; c = surrogate; } } id_builder[num++] = (char)c; try { while (true) { c = reader.Read(); if ((c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 95 || (c >= 48 && c <= 57)) { id_builder[num++] = (char)c; } else if (c < 128) { if (c != 92) { break; } c = escape(c, out var surrogate2); if (is_identifier_part_character((char)c)) { id_builder[num++] = (char)c; continue; } if (surrogate2 != 0) { c = surrogate2; continue; } int num3 = c; int num4 = num3; if (num4 != 65279) { Report.Error(1056, Location, "Unexpected character `\\{0}'", c.ToString("x4")); return 259; } putback_char = c; } else { if (!is_identifier_part_character_slow_part((char)c)) { break; } id_builder[num++] = (char)c; } } putback_char = c; } catch (IndexOutOfRangeException) { Report.Error(645, Location, "Identifier too long (limit is 512 chars)"); num--; col += num; } col += num - 1; if (id_builder[0] >= '_' && !quoted) { int keyword = GetKeyword(id_builder, num); if (keyword != -1) { val = ltb.Create((keyword == 364) ? "await" : null, current_source, ref_line, num2); return keyword; } } string text = InternIdentifier(id_builder, num); val = ltb.Create(text, current_source, ref_line, num2); if (quoted && parsing_attribute_section) { AddEscapedIdentifier(((LocatedToken)val).Location); } return 424; } private string InternIdentifier(char[] charBuffer, int length) { Dictionary dictionary = identifiers[length]; string result; if (dictionary != null) { if (dictionary.TryGetValue(charBuffer, out result)) { return result; } } else { int capacity = ((length > 20) ? 10 : 100); dictionary = new Dictionary(capacity, new IdentifiersComparer(length)); identifiers[length] = dictionary; } char[] array = new char[length]; Array.Copy(charBuffer, array, length); result = new string(charBuffer, 0, length); dictionary.Add(array, result); return result; } public int xtoken() { if (parsing_interpolation_format) { return TokenizeInterpolationFormat(); } bool flag = false; int num; while ((num = get_char()) != -1) { switch (num) { case 9: col = (col - 1 + tab_size) / tab_size * tab_size; continue; case 92: tokens_seen = true; return consume_identifier(num); case 123: val = ltb.Create(current_source, ref_line, col); if (parsing_string_interpolation > 0) { string_interpolation_section++; } return 373; case 125: if (parsing_string_interpolation > 0) { if (string_interpolation_section == 0) { parsing_string_interpolation--; bool quoted = parsing_string_interpolation_quoted != null && parsing_string_interpolation_quoted.Count > 0 && parsing_string_interpolation_quoted.Pop(); return TokenizeInterpolatedString(quoted); } string_interpolation_section--; } val = ltb.Create(current_source, ref_line, col); return 374; case 91: if (doc_state == XmlCommentState.Allowed) { doc_state = XmlCommentState.NotAllowed; } val = ltb.Create(current_source, ref_line, col); if (parsing_block == 0 || lambda_arguments_parsing) { return 375; } switch (peek_char()) { case 44: case 93: return 375; case 10: case 11: case 12: case 13: case 32: case 47: case 8232: case 8233: { int num6 = peek_token(); if (num6 == 380 || num6 == 376) { return 375; } return 429; } default: return 429; } case 93: return 376; case 40: val = ltb.Create(current_source, ref_line, col); if (parsing_block != 0 && !lambda_arguments_parsing) { switch (current_token) { case 276: case 277: case 278: case 290: case 291: case 293: case 325: case 330: case 336: case 341: case 360: case 422: case 424: return 377; default: { int num3 = peek_char(); int num4 = num3; int num5 = num4; if (num5 == 34 || (uint)(num5 - 39) <= 1u || (uint)(num5 - 48) <= 1u) { return 377; } lambda_arguments_parsing = true; PushPosition(); int num2 = TokenizeOpenParens(); PopPosition(); lambda_arguments_parsing = false; return num2; } } } return 377; case 41: return 378; case 44: return 380; case 59: return 382; case 126: val = ltb.Create(current_source, ref_line, col); return 383; case 63: val = ltb.Create(current_source, ref_line, col); return TokenizePossibleNullableType(); case 60: val = ltb.Create(current_source, ref_line, col); if (parsing_generic_less_than++ > 0) { return 420; } return TokenizeLessThan(); case 62: { val = ltb.Create(current_source, ref_line, col); int num2 = peek_char(); if (num2 == 61) { get_char(); return 403; } if (parsing_generic_less_than > 1 || (parsing_generic_less_than == 1 && num2 != 62)) { parsing_generic_less_than--; return 422; } if (num2 == 62) { get_char(); num2 = peek_char(); if (num2 == 61) { get_char(); return 414; } return 401; } return 389; } case 43: { val = ltb.Create(current_source, ref_line, col); int num2; switch (peek_char()) { case 43: num2 = 398; break; case 61: num2 = 411; break; default: return 384; } get_char(); return num2; } case 45: { val = ltb.Create(current_source, ref_line, col); int num2; switch (peek_char()) { case 45: num2 = 399; break; case 61: num2 = 412; break; case 62: num2 = 418; break; default: return 385; } get_char(); return num2; } case 33: val = ltb.Create(current_source, ref_line, col); if (peek_char() == 61) { get_char(); return 405; } return 386; case 61: val = ltb.Create(current_source, ref_line, col); switch (peek_char()) { case 61: get_char(); return 404; case 62: get_char(); return 344; default: return 387; } case 38: val = ltb.Create(current_source, ref_line, col); switch (peek_char()) { case 38: get_char(); return 406; case 61: get_char(); return 415; default: return 390; } case 124: val = ltb.Create(current_source, ref_line, col); switch (peek_char()) { case 124: get_char(); return 407; case 61: get_char(); return 417; default: return 391; } case 42: val = ltb.Create(current_source, ref_line, col); if (peek_char() == 61) { get_char(); return 408; } return 392; case 47: { int num2 = peek_char(); if (num2 == 61) { val = ltb.Create(current_source, ref_line, col); get_char(); return 409; } if (num2 == 47) { if (parsing_string_interpolation > 0) { Report.Error(8077, Location, "A single-line comment may not be used in an interpolated string"); goto case 125; } get_char(); if (doc_processing) { if (peek_char() == 47) { get_char(); if ((num2 = peek_char()) != 47) { if (doc_state == XmlCommentState.Allowed) { handle_one_line_xml_comment(); } else if (doc_state == XmlCommentState.NotAllowed) { WarningMisplacedComment(Location - 3); } } } else if (xml_comment_buffer.Length > 0) { doc_state = XmlCommentState.NotAllowed; } } ReadToEndOfLine(); any_token_seen |= tokens_seen; tokens_seen = false; flag = false; continue; } if (num2 == 42) { get_char(); bool flag2 = false; if (doc_processing && peek_char() == 42) { get_char(); if (peek_char() == 47) { get_char(); continue; } if (doc_state == XmlCommentState.Allowed) { flag2 = true; } else if (doc_state == XmlCommentState.NotAllowed) { WarningMisplacedComment(Location - 2); } } int current_comment_start = 0; if (flag2) { current_comment_start = xml_comment_buffer.Length; xml_comment_buffer.Append(Environment.NewLine); } while ((num2 = get_char()) != -1) { if (num2 == 42 && peek_char() == 47) { get_char(); flag = true; break; } if (flag2) { xml_comment_buffer.Append((char)num2); } if (num2 == 10 || num2 == 8232 || num2 == 8233) { any_token_seen |= tokens_seen; tokens_seen = false; flag = false; } } if (!flag) { Report.Error(1035, Location, "End-of-file found, '*/' expected"); } if (flag2) { update_formatted_doc_comment(current_comment_start); } continue; } val = ltb.Create(current_source, ref_line, col); return 394; } case 37: val = ltb.Create(current_source, ref_line, col); if (peek_char() == 61) { get_char(); return 410; } return 393; case 94: val = ltb.Create(current_source, ref_line, col); if (peek_char() == 61) { get_char(); return 416; } return 395; case 58: val = ltb.Create(current_source, ref_line, col); if (peek_char() == 58) { get_char(); return 397; } return 381; case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: tokens_seen = true; return is_number(num, dotLead: false); case 10: case 8232: case 8233: any_token_seen |= tokens_seen; tokens_seen = false; flag = false; continue; case 46: { tokens_seen = true; int num2 = peek_char(); if (num2 >= 48 && num2 <= 57) { return is_number(num, dotLead: true); } return 379; } case 35: { if (tokens_seen || flag) { Eror_WrongPreprocessorLocation(); return 259; } if (ParsePreprocessingDirective(caller_is_taking: true)) { continue; } bool flag3 = false; while ((num = get_char()) != -1) { if (col == 1) { flag3 = true; } else if (!flag3) { continue; } if (num != 32 && num != 9 && num != 10 && num != 12 && num != 11 && num != 8232 && num != 8233) { if (num == 35 && ParsePreprocessingDirective(caller_is_taking: false)) { break; } flag3 = false; } } if (num != -1) { tokens_seen = false; continue; } return 257; } case 34: if (parsing_string_interpolation > 0 && !ScanClosingInterpolationBrace()) { parsing_string_interpolation = 0; Report.Error(8076, Location, "Missing close delimiter `}' for interpolated expression"); val = new StringLiteral(context.BuiltinTypes, "", Location); return 368; } return consume_string(quoted: false); case 39: return TokenizeBackslash(); case 64: num = get_char(); if (num == 34) { tokens_seen = true; return consume_string(quoted: true); } if (is_identifier_start_character(num)) { return consume_identifier(num, quoted: true); } Report.Error(1646, Location, "Keyword, identifier, or string expected after verbatim specifier: @"); return 259; case 36: switch (peek_char()) { case 34: get_char(); return TokenizeInterpolatedString(quoted: false); case 64: get_char(); if (peek_char() == 34) { get_char(); return TokenizeInterpolatedString(quoted: true); } break; } break; case 1048576: return 433; case 1048577: return 434; case 1048578: return 435; case 1048579: return 436; case 0: case 11: case 12: case 32: case 160: case 65279: continue; } if (is_identifier_start_character(num)) { tokens_seen = true; return consume_identifier(num); } if (!char.IsWhiteSpace((char)num)) { Report.Error(1056, Location, "Unexpected character `{0}'", ((char)num).ToString()); } } if (CompleteOnEOF) { if (generated) { return 438; } generated = true; return 437; } return 257; } private int TokenizeBackslash() { Location location = Location; int num = get_char(); tokens_seen = true; switch (num) { case 39: val = new CharLiteral(context.BuiltinTypes, (char)num, location); Report.Error(1011, location, "Empty character literal"); return 423; default: if (num != 8233) { num = escape(num, out var surrogate); if (num == -1) { return 259; } if (surrogate != 0) { throw new NotImplementedException(); } ILiteralConstant literalConstant = new CharLiteral(context.BuiltinTypes, (char)num, location); val = literalConstant; num = get_char(); if (num != 39) { Report.Error(1012, location, "Too many characters in character literal"); while ((num = get_char()) != -1 && num != 10 && num != 39 && num != 8232 && num != 8233) { } } return 423; } goto case 10; case 10: case 8232: Report.Error(1010, location, "Newline in constant"); return 259; } } private int TokenizeLessThan() { if (current_token != 306) { PushPosition(); int genericDimension = 0; if (parse_less_than(ref genericDimension)) { int result; if (parsing_generic_declaration && (parsing_generic_declaration_doc || token() != 379)) { result = 421; } else { if (genericDimension > 0) { val = genericDimension; DiscardPosition(); return 427; } result = 420; } PopPosition(); return result; } PopPosition(); } parsing_generic_less_than = 0; switch (peek_char()) { case 60: { get_char(); int result = peek_char(); if (result == 61) { get_char(); return 413; } return 400; } case 61: get_char(); return 402; default: return 388; } } private int TokenizeInterpolatedString(bool quoted) { int num = 0; Location location = Location; while (true) { int num2 = get_char(); switch (num2) { case 34: if (quoted && peek_char() == 34) { get_char(); break; } val = new StringLiteral(context.BuiltinTypes, CreateStringFromBuilder(num), location); return 368; case 123: if (peek_char() == 123) { value_builder[num++] = (char)num2; get_char(); break; } parsing_string_interpolation++; if (quoted && parsing_string_interpolation_quoted == null) { parsing_string_interpolation_quoted = new Stack(); } if (parsing_string_interpolation_quoted != null) { parsing_string_interpolation_quoted.Push(quoted); } val = new StringLiteral(context.BuiltinTypes, CreateStringFromBuilder(num), location); return 367; case 92: { if (quoted) { break; } col++; num2 = escape(num2, out var surrogate); if (num2 == -1) { return 259; } if (num2 == 123 || num2 == 125) { Report.Error(8087, Location, "A `{0}' character may only be escaped by doubling `{0}{0}' in an interpolated string", ((char)num2).ToString()); } if (surrogate != 0) { if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } value_builder[num++] = (char)num2; num2 = surrogate; } break; } case -1: return 257; } col++; if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } value_builder[num++] = (char)num2; } } private int TokenizeInterpolationFormat() { int num = 0; int num2 = 0; while (true) { int num3 = get_char(); switch (num3) { case 123: num2++; break; case 125: if (num2 == 0) { putback_char = num3; if (num == 0) { Report.Error(8089, Location, "Empty interpolated expression format specifier"); } else if (Array.IndexOf(simple_whitespaces, value_builder[num - 1]) >= 0) { Report.Error(8088, Location, "A interpolated expression format specifier may not contain trailing whitespace"); } val = CreateStringFromBuilder(num); return 423; } num2--; break; case 92: { if (parsing_string_interpolation_quoted != null && parsing_string_interpolation_quoted.Peek()) { break; } col++; num3 = escape(num3, out var surrogate); if (num3 == -1) { return 259; } if (num3 == 123 || num3 == 125) { Report.Error(8087, Location, "A `{0}' character may only be escaped by doubling `{0}{0}' in an interpolated string", ((char)num3).ToString()); } if (surrogate != 0) { if (num == value_builder.Length) { Array.Resize(ref value_builder, num * 2); } value_builder[num++] = (char)num3; num3 = surrogate; } break; } case -1: return 257; } col++; value_builder[num++] = (char)num3; } } private string CreateStringFromBuilder(int pos) { if (pos == 0) { return string.Empty; } if (pos <= 4) { return InternIdentifier(value_builder, pos); } return new string(value_builder, 0, pos); } private void handle_one_line_xml_comment() { int num; while ((num = peek_char()) != -1 && num != 10 && num != 13) { xml_comment_buffer.Append((char)get_char()); } if (num == 13 || num == 10) { xml_comment_buffer.Append(Environment.NewLine); } } private void update_formatted_doc_comment(int current_comment_start) { int num = xml_comment_buffer.Length - current_comment_start; string[] array = xml_comment_buffer.ToString(current_comment_start, num).Replace("\r", "").Split(new char[1] { '\n' }); for (int i = 1; i < array.Length; i++) { string text = array[i]; int num2 = text.IndexOf('*'); string text2 = null; if (num2 < 0) { if (i < array.Length - 1) { return; } text2 = text; } else { text2 = text.Substring(0, num2); } string text3 = text2; foreach (char c in text3) { if (c != ' ') { return; } } array[i] = text.Substring(num2 + 1); } xml_comment_buffer.Remove(current_comment_start, num); xml_comment_buffer.Insert(current_comment_start, string.Join(Environment.NewLine, array)); } public void check_incorrect_doc_comment() { if (xml_comment_buffer.Length > 0) { WarningMisplacedComment(Location); } } public string consume_doc_comment() { if (xml_comment_buffer.Length > 0) { string result = xml_comment_buffer.ToString(); reset_doc_comment(); return result; } return null; } private void reset_doc_comment() { xml_comment_buffer.Length = 0; } public void cleanup() { if (ifstack != null && ifstack.Count >= 1) { int num = ifstack.Pop(); if ((num & 0x10) != 0) { Report.Error(1038, Location, "#endregion directive expected"); } else { Report.Error(1027, Location, "Expected `#endif' directive"); } } } } internal enum XmlCommentState { Allowed, NotAllowed, Error } [DebuggerDisplay("{GetSignatureForError()}")] internal class MemberName { public static readonly MemberName Null = new MemberName(""); public readonly string Name; public TypeParameters TypeParameters; public readonly FullNamedExpression ExplicitInterface; public readonly Location Location; public readonly MemberName Left; public int Arity => (TypeParameters != null) ? TypeParameters.Count : 0; public bool IsGeneric => TypeParameters != null; public string Basename { get { if (TypeParameters != null) { return MakeName(Name, TypeParameters); } return Name; } } public MemberName(string name) : this(name, Location.Null) { } public MemberName(string name, Location loc) : this(null, name, loc) { } public MemberName(string name, TypeParameters tparams, Location loc) { Name = name; Location = loc; TypeParameters = tparams; } public MemberName(string name, TypeParameters tparams, FullNamedExpression explicitInterface, Location loc) : this(name, tparams, loc) { ExplicitInterface = explicitInterface; } public MemberName(MemberName left, string name, Location loc) { Name = name; Location = loc; Left = left; } public MemberName(MemberName left, string name, FullNamedExpression explicitInterface, Location loc) : this(left, name, loc) { ExplicitInterface = explicitInterface; } public MemberName(MemberName left, MemberName right) { Name = right.Name; Location = right.Location; TypeParameters = right.TypeParameters; Left = left; } public void CreateMetadataName(StringBuilder sb) { if (Left != null) { Left.CreateMetadataName(sb); } if (sb.Length != 0) { sb.Append("."); } sb.Append(Basename); } public string GetSignatureForDocumentation() { string text = Basename; if (ExplicitInterface != null) { text = ExplicitInterface.GetSignatureForError() + "." + text; } if (Left == null) { return text; } return Left.GetSignatureForDocumentation() + "." + text; } public string GetSignatureForError() { string text = ((TypeParameters == null) ? null : ("<" + TypeParameters.GetSignatureForError() + ">")); text = Name + text; if (ExplicitInterface != null) { text = ExplicitInterface.GetSignatureForError() + "." + text; } if (Left == null) { return text; } return Left.GetSignatureForError() + "." + text; } public override bool Equals(object other) { return Equals(other as MemberName); } public bool Equals(MemberName other) { if (this == other) { return true; } if (other == null || Name != other.Name) { return false; } if (TypeParameters != null && (other.TypeParameters == null || TypeParameters.Count != other.TypeParameters.Count)) { return false; } if (TypeParameters == null && other.TypeParameters != null) { return false; } if (Left == null) { return other.Left == null; } return Left.Equals(other.Left); } public override int GetHashCode() { int num = Name.GetHashCode(); for (MemberName left = Left; left != null; left = left.Left) { num ^= left.Name.GetHashCode(); } if (TypeParameters != null) { num ^= TypeParameters.Count << 5; } return num & 0x7FFFFFFF; } public static string MakeName(string name, TypeParameters args) { if (args == null) { return name; } return name + "`" + args.Count; } } internal class SimpleMemberName { public string Value; public Location Location; public SimpleMemberName(string name, Location loc) { Value = name; Location = loc; } } [DebuggerDisplay("{GetSignatureForError()}")] internal abstract class MemberCore : Attributable, IMemberContext, IModuleContext, IMemberDefinition { [Flags] public enum Flags { Obsolete_Undetected = 1, Obsolete = 2, ClsCompliance_Undetected = 4, ClsCompliant = 8, CloseTypeCreated = 0x10, HasCompliantAttribute_Undetected = 0x20, HasClsCompliantAttribute = 0x40, ClsCompliantAttributeFalse = 0x80, Excluded_Undetected = 0x100, Excluded = 0x200, MethodOverloadsExist = 0x400, IsUsed = 0x800, IsAssigned = 0x1000, HasExplicitLayout = 0x2000, PartialDefinitionExists = 0x4000, HasStructLayout = 0x8000, HasInstanceConstructor = 0x10000, HasUserOperators = 0x20000, CanBeReused = 0x40000, InterfacesExpanded = 0x80000, HasInstanceField = 0x100000 } private MemberName member_name; private Modifiers mod_flags; public TypeContainer Parent; protected string comment; internal Flags caching_flags; string IMemberDefinition.Name => member_name.Name; public MemberName MemberName => member_name; public Modifiers ModFlags { get { return mod_flags; } set { mod_flags = value; if ((value & Modifiers.COMPILER_GENERATED) != 0) { caching_flags = Flags.IsUsed | Flags.IsAssigned; } } } public virtual ModuleContainer Module => Parent.Module; public Location Location => member_name.Location; public abstract string DocCommentHeader { get; } public virtual string DocComment { get { return comment; } set { comment = value; } } public bool IsAvailableForReuse { get { return (caching_flags & Flags.CanBeReused) != 0; } set { caching_flags = (value ? (caching_flags | Flags.CanBeReused) : (caching_flags & ~Flags.CanBeReused)); } } public bool IsCompilerGenerated { get { if ((mod_flags & Modifiers.COMPILER_GENERATED) != 0) { return true; } return Parent != null && Parent.IsCompilerGenerated; } } public bool IsImported => false; public virtual bool IsUsed => (caching_flags & Flags.IsUsed) != 0; protected Report Report => Compiler.Report; public bool? CLSAttributeValue { get { if ((caching_flags & Flags.HasCompliantAttribute_Undetected) == 0) { if ((caching_flags & Flags.HasClsCompliantAttribute) == 0) { return null; } return (caching_flags & Flags.ClsCompliantAttributeFalse) == 0; } caching_flags &= ~Flags.HasCompliantAttribute_Undetected; if (base.OptAttributes != null) { Attribute attribute = base.OptAttributes.Search(Module.PredefinedAttributes.CLSCompliant); if (attribute != null) { caching_flags |= Flags.HasClsCompliantAttribute; if (attribute.GetClsCompliantAttributeValue()) { return true; } caching_flags |= Flags.ClsCompliantAttributeFalse; return false; } } return null; } } protected bool HasClsCompliantAttribute => CLSAttributeValue.HasValue; public virtual CompilerContext Compiler => Module.Compiler; public virtual TypeSpec CurrentType => Parent.CurrentType; public MemberCore CurrentMemberDefinition => this; public virtual TypeParameters CurrentTypeParameters => null; public bool IsObsolete { get { if (GetAttributeObsolete() != null) { return true; } return Parent != null && Parent.IsObsolete; } } public bool IsUnsafe { get { if ((ModFlags & Modifiers.UNSAFE) != 0) { return true; } return Parent != null && Parent.IsUnsafe; } } public bool IsStatic => (ModFlags & Modifiers.STATIC) != 0; protected MemberCore(TypeContainer parent, MemberName name, Attributes attrs) { Parent = parent; member_name = name; caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected; AddAttributes(attrs, this); } protected virtual void SetMemberName(MemberName new_name) { member_name = new_name; } public virtual void Accept(StructuralVisitor visitor) { visitor.Visit(this); } protected bool CheckAbstractAndExtern(bool has_block) { if (Parent.PartialContainer.Kind == MemberKind.Interface) { return true; } if (has_block) { if ((ModFlags & Modifiers.EXTERN) != 0) { Report.Error(179, Location, "`{0}' cannot declare a body because it is marked extern", GetSignatureForError()); return false; } if ((ModFlags & Modifiers.ABSTRACT) != 0) { Report.Error(500, Location, "`{0}' cannot declare a body because it is marked abstract", GetSignatureForError()); return false; } } else if ((ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN | Modifiers.PARTIAL)) == 0 && !(Parent is Delegate)) { if (Compiler.Settings.Version >= LanguageVersion.V_3) { PropertyBase.PropertyMethod propertyMethod = this as PropertyBase.PropertyMethod; if (propertyMethod is Indexer.GetIndexerMethod || propertyMethod is Indexer.SetIndexerMethod) { propertyMethod = null; } if (propertyMethod != null && propertyMethod.Property.AccessorSecond == null) { Report.Error(840, Location, "`{0}' must have a body because it is not marked abstract or extern. The property can be automatically implemented when you define both accessors", GetSignatureForError()); return false; } } Report.Error(501, Location, "`{0}' must have a body because it is not marked abstract, extern, or partial", GetSignatureForError()); return false; } return true; } protected void CheckProtectedModifier() { if ((ModFlags & Modifiers.PROTECTED) != 0) { if (Parent.PartialContainer.Kind == MemberKind.Struct) { Report.Error(666, Location, "`{0}': Structs cannot contain protected members", GetSignatureForError()); } else if ((Parent.ModFlags & Modifiers.STATIC) != 0) { Report.Error(1057, Location, "`{0}': Static classes cannot contain protected members", GetSignatureForError()); } else if ((Parent.ModFlags & Modifiers.SEALED) != 0 && (ModFlags & Modifiers.OVERRIDE) == 0 && !(this is Destructor)) { Report.Warning(628, 4, Location, "`{0}': new protected member declared in sealed class", GetSignatureForError()); } } } public abstract bool Define(); public virtual string GetSignatureForError() { string signatureForError = Parent.GetSignatureForError(); if (signatureForError == null) { return member_name.GetSignatureForError(); } return signatureForError + "." + member_name.GetSignatureForError(); } public virtual void Emit() { if (Compiler.Settings.VerifyClsCompliance) { VerifyClsCompliance(); } } public void SetIsUsed() { caching_flags |= Flags.IsUsed; } public void SetIsAssigned() { caching_flags |= Flags.IsAssigned; } public virtual void SetConstraints(List constraints_list) { TypeParameters typeParameters = member_name.TypeParameters; if (typeParameters == null) { Report.Error(80, Location, "Constraints are not allowed on non-generic declarations"); return; } foreach (Constraints item in constraints_list) { TypeParameter typeParameter = typeParameters.Find(item.TypeParameter.Value); if (typeParameter == null) { Report.Error(699, item.Location, "`{0}': A constraint references nonexistent type parameter `{1}'", GetSignatureForError(), item.TypeParameter.Value); } else { typeParameter.Constraints = item; } } } public virtual ObsoleteAttribute GetAttributeObsolete() { if ((caching_flags & (Flags.Obsolete_Undetected | Flags.Obsolete)) == 0) { return null; } caching_flags &= ~Flags.Obsolete_Undetected; if (base.OptAttributes == null) { return null; } Attribute attribute = base.OptAttributes.Search(Module.PredefinedAttributes.Obsolete); if (attribute == null) { return null; } caching_flags |= Flags.Obsolete; ObsoleteAttribute obsoleteAttribute = attribute.GetObsoleteAttribute(); if (obsoleteAttribute == null) { return null; } return obsoleteAttribute; } public bool IsAccessibleAs(TypeSpec p) { if ((mod_flags & Modifiers.PRIVATE) != 0) { return true; } while (TypeManager.HasElementType(p)) { p = TypeManager.GetElementType(p); } if (p.BuiltinType != BuiltinTypeSpec.Type.None) { return true; } if (p.IsGenericParameter) { return true; } while (p != null) { TypeSpec declaringType = p.DeclaringType; if (p.IsGeneric) { TypeSpec[] typeArguments = p.TypeArguments; foreach (TypeSpec p2 in typeArguments) { if (!IsAccessibleAs(p2)) { return false; } } } Modifiers modifiers = p.Modifiers & Modifiers.AccessibilityMask; if (modifiers != Modifiers.PUBLIC) { bool flag = false; for (MemberCore memberCore = this; !flag && memberCore != null && memberCore.Parent != null; memberCore = memberCore.Parent) { if (memberCore is TypeContainer { PartialContainer: not null } typeContainer) { memberCore = typeContainer.PartialContainer; } Modifiers modifiers2 = memberCore.ModFlags & Modifiers.AccessibilityMask; Modifiers modifiers3 = modifiers; Modifiers modifiers4 = modifiers3; if (modifiers4 <= Modifiers.PRIVATE) { if (modifiers4 == Modifiers.PROTECTED) { goto IL_016e; } if (modifiers4 == Modifiers.PRIVATE) { if (modifiers2 == Modifiers.PRIVATE) { TypeContainer parent = memberCore.Parent; do { flag = parent.CurrentType.MemberDefinition == declaringType.MemberDefinition; } while (!flag && !parent.PartialContainer.IsTopLevel && (parent = parent.Parent) != null); } continue; } } else { if (modifiers4 == Modifiers.INTERNAL) { if (modifiers2 == Modifiers.PRIVATE || modifiers2 == Modifiers.INTERNAL) { flag = p.MemberDefinition.IsInternalAsPublic(memberCore.Module.DeclaringAssembly); } continue; } if (modifiers4 == (Modifiers.PROTECTED | Modifiers.INTERNAL)) { if (modifiers2 == Modifiers.INTERNAL) { flag = p.MemberDefinition.IsInternalAsPublic(memberCore.Module.DeclaringAssembly); continue; } if (modifiers2 == (Modifiers.PROTECTED | Modifiers.INTERNAL)) { flag = memberCore.Parent.PartialContainer.IsBaseTypeDefinition(declaringType) && p.MemberDefinition.IsInternalAsPublic(memberCore.Module.DeclaringAssembly); continue; } if (modifiers2 != Modifiers.PROTECTED) { if (modifiers2 != Modifiers.PRIVATE) { continue; } if (p.MemberDefinition.IsInternalAsPublic(memberCore.Module.DeclaringAssembly)) { flag = true; continue; } } goto IL_016e; } } throw new InternalErrorException(modifiers2.ToString()); IL_016e: switch (modifiers2) { case Modifiers.PROTECTED: flag = memberCore.Parent.PartialContainer.IsBaseTypeDefinition(declaringType); continue; case Modifiers.PRIVATE: break; default: continue; } while (memberCore.Parent != null && memberCore.Parent.PartialContainer != null) { if (memberCore.Parent.PartialContainer.IsBaseTypeDefinition(declaringType)) { flag = true; break; } memberCore = memberCore.Parent; } } if (!flag) { return false; } } p = declaringType; } return true; } public override bool IsClsComplianceRequired() { if ((caching_flags & Flags.ClsCompliance_Undetected) == 0) { return (caching_flags & Flags.ClsCompliant) != 0; } caching_flags &= ~Flags.ClsCompliance_Undetected; if (HasClsCompliantAttribute) { if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) { return false; } caching_flags |= Flags.ClsCompliant; return true; } if (Parent.IsClsComplianceRequired()) { caching_flags |= Flags.ClsCompliant; return true; } return false; } public virtual string[] ConditionalConditions() { return null; } public bool IsExposedFromAssembly() { if ((ModFlags & (Modifiers.PROTECTED | Modifiers.PUBLIC)) == 0) { return this is NamespaceContainer; } for (TypeDefinition partialContainer = Parent.PartialContainer; partialContainer != null; partialContainer = partialContainer.Parent.PartialContainer) { if ((partialContainer.ModFlags & (Modifiers.PROTECTED | Modifiers.PUBLIC)) == 0) { return false; } } return true; } public ExtensionMethodCandidates LookupExtensionMethod(string name, int arity) { TypeContainer parent = Parent; do { if (parent is NamespaceContainer namespaceContainer) { return namespaceContainer.LookupExtensionMethod(this, name, arity, 0); } parent = parent.Parent; } while (parent != null); return null; } public virtual FullNamedExpression LookupNamespaceAlias(string name) { return Parent.LookupNamespaceAlias(name); } public virtual FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { return Parent.LookupNamespaceOrType(name, arity, mode, loc); } public virtual bool EnableOverloadChecks(MemberCore overload) { return false; } protected virtual bool VerifyClsCompliance() { if (HasClsCompliantAttribute) { if (!Module.DeclaringAssembly.HasCLSCompliantAttribute) { Attribute attribute = base.OptAttributes.Search(Module.PredefinedAttributes.CLSCompliant); if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) { Report.Warning(3021, 2, attribute.Location, "`{0}' does not need a CLSCompliant attribute because the assembly is not marked as CLS-compliant", GetSignatureForError()); } else { Report.Warning(3014, 1, attribute.Location, "`{0}' cannot be marked as CLS-compliant because the assembly is not marked as CLS-compliant", GetSignatureForError()); } return false; } if (!IsExposedFromAssembly()) { Attribute attribute2 = base.OptAttributes.Search(Module.PredefinedAttributes.CLSCompliant); Report.Warning(3019, 2, attribute2.Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError()); return false; } if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) { if (Parent is Interface && Parent.IsClsComplianceRequired()) { Report.Warning(3010, 1, Location, "`{0}': CLS-compliant interfaces must have only CLS-compliant members", GetSignatureForError()); } else if (Parent.Kind == MemberKind.Class && (ModFlags & Modifiers.ABSTRACT) != 0 && Parent.IsClsComplianceRequired()) { Report.Warning(3011, 1, Location, "`{0}': only CLS-compliant members can be abstract", GetSignatureForError()); } return false; } if (Parent.Kind != MemberKind.Namespace && Parent.Kind != 0 && !Parent.IsClsComplianceRequired()) { Attribute attribute3 = base.OptAttributes.Search(Module.PredefinedAttributes.CLSCompliant); Report.Warning(3018, 1, attribute3.Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'", GetSignatureForError(), Parent.GetSignatureForError()); return false; } } else { if (!IsExposedFromAssembly()) { return false; } if (!Parent.IsClsComplianceRequired()) { return false; } } if (member_name.Name[0] == '_') { Warning_IdentifierNotCompliant(); } if (member_name.TypeParameters != null) { member_name.TypeParameters.VerifyClsCompliance(); } return true; } protected void Warning_IdentifierNotCompliant() { Report.Warning(3008, 1, MemberName.Location, "Identifier `{0}' is not CLS-compliant", GetSignatureForError()); } public virtual string GetCallerMemberName() { return MemberName.Name; } public abstract string GetSignatureForDocumentation(); public virtual void GetCompletionStartingWith(string prefix, List results) { Parent.GetCompletionStartingWith(prefix, results); } public virtual void WriteDebugSymbol(MonoSymbolFile file) { } } internal abstract class MemberSpec { [Flags] public enum StateFlags { Obsolete_Undetected = 1, Obsolete = 2, CLSCompliant_Undetected = 4, CLSCompliant = 8, MissingDependency_Undetected = 0x10, MissingDependency = 0x20, HasDynamicElement = 0x40, ConstraintsChecked = 0x80, HasNamedTupleElement = 0x100, IsAccessor = 0x200, IsGeneric = 0x400, PendingMetaInflate = 0x1000, PendingMakeMethod = 0x2000, PendingMemberCacheMembers = 0x4000, PendingBaseTypeInflate = 0x8000, InterfacesExpanded = 0x10000, IsNotCSharpCompatible = 0x20000, SpecialRuntimeType = 0x40000, InflatedExpressionType = 0x80000, InflatedNullableType = 0x100000, GenericIterateInterface = 0x200000, GenericTask = 0x400000, InterfacesImported = 0x800000, Tuple = 0x1000000 } protected const StateFlags SharedStateFlags = StateFlags.Obsolete_Undetected | StateFlags.Obsolete | StateFlags.CLSCompliant_Undetected | StateFlags.CLSCompliant | StateFlags.MissingDependency_Undetected | StateFlags.MissingDependency | StateFlags.HasDynamicElement | StateFlags.HasNamedTupleElement; protected Modifiers modifiers; public StateFlags state; protected IMemberDefinition definition; public readonly MemberKind Kind; protected TypeSpec declaringType; public virtual int Arity => 0; public TypeSpec DeclaringType { get { return declaringType; } set { declaringType = value; } } public IMemberDefinition MemberDefinition => definition; public Modifiers Modifiers { get { return modifiers; } set { modifiers = value; } } public virtual string Name => definition.Name; public bool IsAbstract => (modifiers & Modifiers.ABSTRACT) != 0; public bool IsAccessor { get { return (state & StateFlags.IsAccessor) != 0; } set { state = (value ? (state | StateFlags.IsAccessor) : (state & ~StateFlags.IsAccessor)); } } public bool IsGeneric { get { return (state & StateFlags.IsGeneric) != 0; } set { state = (value ? (state | StateFlags.IsGeneric) : (state & ~StateFlags.IsGeneric)); } } public bool IsNotCSharpCompatible { get { return (state & StateFlags.IsNotCSharpCompatible) != 0; } set { state = (value ? (state | StateFlags.IsNotCSharpCompatible) : (state & ~StateFlags.IsNotCSharpCompatible)); } } public bool IsPrivate => (modifiers & Modifiers.PRIVATE) != 0; public bool IsPublic => (modifiers & Modifiers.PUBLIC) != 0; public bool IsStatic => (modifiers & Modifiers.STATIC) != 0; protected MemberSpec(MemberKind kind, TypeSpec declaringType, IMemberDefinition definition, Modifiers modifiers) { Kind = kind; this.declaringType = declaringType; this.definition = definition; this.modifiers = modifiers; if (kind == MemberKind.MissingType) { state = StateFlags.MissingDependency; } else { state = StateFlags.Obsolete_Undetected | StateFlags.CLSCompliant_Undetected | StateFlags.MissingDependency_Undetected; } } public virtual void CheckObsoleteness(IMemberContext mc, Location loc) { ObsoleteAttribute attributeObsolete = GetAttributeObsolete(); if (attributeObsolete != null && !mc.IsObsolete) { AttributeTester.Report_ObsoleteMessage(attributeObsolete, GetSignatureForError(), loc, mc.Module.Compiler.Report); } } public virtual ObsoleteAttribute GetAttributeObsolete() { if ((state & (StateFlags.Obsolete_Undetected | StateFlags.Obsolete)) == 0) { return null; } state &= ~StateFlags.Obsolete_Undetected; ObsoleteAttribute attributeObsolete = definition.GetAttributeObsolete(); if (attributeObsolete != null) { state |= StateFlags.Obsolete; } return attributeObsolete; } public List GetMissingDependencies() { return GetMissingDependencies(this); } public List GetMissingDependencies(MemberSpec caller) { if ((state & (StateFlags.MissingDependency_Undetected | StateFlags.MissingDependency)) == 0) { return null; } state &= ~StateFlags.MissingDependency_Undetected; List list = ((!(definition is ImportedDefinition)) ? ((!(this is ElementTypeSpec)) ? null : ((ElementTypeSpec)this).Element.GetMissingDependencies(caller)) : ResolveMissingDependencies(caller)); if (list != null) { state |= StateFlags.MissingDependency; } return list; } public abstract List ResolveMissingDependencies(MemberSpec caller); protected virtual bool IsNotCLSCompliant(out bool attrValue) { bool? cLSAttributeValue = MemberDefinition.CLSAttributeValue; attrValue = cLSAttributeValue == true; return cLSAttributeValue == false; } public virtual string GetSignatureForDocumentation() { return DeclaringType.GetSignatureForDocumentation() + "." + Name; } public virtual string GetSignatureForError() { return string.Concat(str2: (MemberDefinition is Property.BackingFieldDeclaration backingFieldDeclaration) ? backingFieldDeclaration.OriginalProperty.MemberName.Name : Name, str0: DeclaringType.GetSignatureForError(), str1: "."); } public virtual MemberSpec InflateMember(TypeParameterInflator inflator) { MemberSpec memberSpec = (MemberSpec)MemberwiseClone(); memberSpec.declaringType = inflator.TypeInstance; if (DeclaringType.IsGenericOrParentIsGeneric) { memberSpec.state |= StateFlags.PendingMetaInflate; } return memberSpec; } public bool IsAccessible(IMemberContext ctx) { return true; } public bool IsCLSCompliant() { if ((state & StateFlags.CLSCompliant_Undetected) != 0) { state &= ~StateFlags.CLSCompliant_Undetected; if (IsNotCLSCompliant(out var attrValue)) { return false; } if (!attrValue) { attrValue = ((DeclaringType == null) ? ((ITypeDefinition)MemberDefinition).DeclaringAssembly.IsCLSCompliant : DeclaringType.IsCLSCompliant()); } if (attrValue) { state |= StateFlags.CLSCompliant; } } return (state & StateFlags.CLSCompliant) != 0; } public bool IsConditionallyExcluded(IMemberContext ctx) { if ((Kind & (MemberKind.Method | MemberKind.Class)) == 0) { return false; } string[] array = MemberDefinition.ConditionalConditions(); if (array == null) { return false; } MemberCore memberCore = ctx.CurrentMemberDefinition; CompilationSourceFile compilationSourceFile = null; while (memberCore != null && compilationSourceFile == null) { compilationSourceFile = memberCore as CompilationSourceFile; memberCore = memberCore.Parent; } if (compilationSourceFile != null) { string[] array2 = array; foreach (string value in array2) { if (compilationSourceFile.IsConditionalDefined(value)) { return false; } } } return true; } public override string ToString() { return GetSignatureForError(); } } internal interface IMemberDefinition { bool? CLSAttributeValue { get; } string Name { get; } bool IsImported { get; } string[] ConditionalConditions(); ObsoleteAttribute GetAttributeObsolete(); void SetIsAssigned(); void SetIsUsed(); } internal interface IMethodDefinition : IMemberDefinition { MethodBase Metadata { get; } } internal interface IParametersMember : IInterfaceMemberSpec { AParametersCollection Parameters { get; } } internal interface IInterfaceMemberSpec { TypeSpec MemberType { get; } } internal class Delegate : TypeDefinition, IParametersMember, IInterfaceMemberSpec { private FullNamedExpression ReturnType; private readonly ParametersCompiled parameters; private Constructor Constructor; private Method InvokeBuilder; private Method BeginInvokeBuilder; private Method EndInvokeBuilder; private static readonly string[] attribute_targets = new string[2] { "type", "return" }; public static readonly string InvokeMethodName = "Invoke"; private Expression instance_expr; private ReturnParameter return_attributes; private Dictionary declarative_security; private const Modifiers MethodModifiers = Modifiers.PUBLIC | Modifiers.VIRTUAL; private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.UNSAFE; public TypeSpec MemberType => ReturnType.Type; public AParametersCollection Parameters => parameters; public FullNamedExpression TypExpression => ReturnType; public override AttributeTargets AttributeTargets => AttributeTargets.Delegate; protected override TypeAttributes TypeAttr => base.TypeAttr | TypeAttributes.NotPublic | TypeAttributes.Sealed; public override string[] ValidAttributeTargets => attribute_targets; public Expression InstanceExpression { get { return instance_expr; } set { instance_expr = value; } } public Delegate(TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, ParametersCompiled param_list, Attributes attrs) : base(parent, name, attrs, MemberKind.Delegate) { ReturnType = type; base.ModFlags = ModifiersExtensions.Check(Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.UNSAFE, mod_flags, base.IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, name.Location, base.Report); parameters = param_list; spec = new TypeSpec(Kind, null, this, null, base.ModFlags | Modifiers.SEALED); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.ReturnValue) { CreateReturnBuilder(); return_attributes.ApplyAttributeBuilder(a, ctor, cdata, pa); } else if (a.IsValidSecurityAttribute()) { a.ExtractSecurityPermissionSet(ctor, ref declarative_security); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } private ReturnParameter CreateReturnBuilder() { return return_attributes ?? (return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, base.Location)); } protected override bool DoDefineMembers() { BuiltinTypes builtinTypes = Compiler.BuiltinTypes; Parameter[] obj = new Parameter[2] { new Parameter(new TypeExpression(builtinTypes.Object, base.Location), "object", Parameter.Modifier.NONE, null, base.Location), new Parameter(new TypeExpression(builtinTypes.IntPtr, base.Location), "method", Parameter.Modifier.NONE, null, base.Location) }; TypeSpec[] types = new BuiltinTypeSpec[2] { builtinTypes.Object, builtinTypes.IntPtr }; ParametersCompiled args = ParametersCompiled.CreateFullyResolved(obj, types); Constructor = new Constructor(this, Constructor.ConstructorName, Modifiers.PUBLIC, null, args, base.Location); Constructor.Define(); ParametersCompiled parametersCompiled = parameters; if (!parametersCompiled.Resolve(this)) { return false; } TypeSpec[] types2 = parametersCompiled.Types; foreach (TypeSpec typeSpec in types2) { if (!IsAccessibleAs(typeSpec)) { base.Report.SymbolRelatedToPreviousError(typeSpec); base.Report.Error(59, base.Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'", typeSpec.GetSignatureForError(), GetSignatureForError()); } } TypeSpec typeSpec2 = ReturnType.ResolveAsType(this); if (typeSpec2 == null) { return false; } if (!IsAccessibleAs(typeSpec2)) { base.Report.SymbolRelatedToPreviousError(typeSpec2); base.Report.Error(58, base.Location, "Inconsistent accessibility: return type `" + typeSpec2.GetSignatureForError() + "' is less accessible than delegate `" + GetSignatureForError() + "'"); return false; } CheckProtectedModifier(); if (typeSpec2.IsSpecialRuntimeType && Compiler.Settings.StdLib) { MethodOrOperator.Error_ReturnTypeCantBeRefAny(base.Location, typeSpec2, base.Report); return false; } VarianceDecl.CheckTypeVariance(typeSpec2, Variance.Covariant, this); TypeExpression typeExpression = new TypeExpression(typeSpec2, base.Location); InvokeBuilder = new Method(this, typeExpression, Modifiers.PUBLIC | Modifiers.VIRTUAL, new MemberName(InvokeMethodName), parametersCompiled, null); InvokeBuilder.Define(); if (!base.IsCompilerGenerated) { DefineAsyncMethods(typeExpression); } return true; } private void DefineAsyncMethods(TypeExpression returnType) { PredefinedType iAsyncResult = Module.PredefinedTypes.IAsyncResult; PredefinedType asyncCallback = Module.PredefinedTypes.AsyncCallback; if (!iAsyncResult.Define() || !asyncCallback.Define()) { return; } ParametersCompiled userParams; if (Parameters.Count == 0) { userParams = ParametersCompiled.EmptyReadOnlyParameters; } else { Parameter[] array = new Parameter[Parameters.Count]; for (int i = 0; i < array.Length; i++) { Parameter parameter = parameters[i]; array[i] = new Parameter(new TypeExpression(parameters.Types[i], base.Location), parameter.Name, parameter.ModFlags & Parameter.Modifier.RefOutMask, (parameter.OptAttributes == null) ? null : parameter.OptAttributes.Clone(), base.Location); } userParams = new ParametersCompiled(array); } userParams = ParametersCompiled.MergeGenerated(Compiler, userParams, checkConflicts: false, new Parameter[2] { new Parameter(new TypeExpression(asyncCallback.TypeSpec, base.Location), "callback", Parameter.Modifier.NONE, null, base.Location), new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, base.Location), "object", Parameter.Modifier.NONE, null, base.Location) }, new TypeSpec[2] { asyncCallback.TypeSpec, Compiler.BuiltinTypes.Object }); BeginInvokeBuilder = new Method(this, new TypeExpression(iAsyncResult.TypeSpec, base.Location), Modifiers.PUBLIC | Modifiers.VIRTUAL, new MemberName("BeginInvoke"), userParams, null); BeginInvokeBuilder.Define(); int num = 0; IParameterData[] fixedParameters = Parameters.FixedParameters; for (int j = 0; j < fixedParameters.Length; j++) { Parameter parameter2 = (Parameter)fixedParameters[j]; if ((parameter2.ModFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { num++; } } ParametersCompiled userParams2; if (num > 0) { Parameter[] array2 = new Parameter[num]; int num2 = 0; for (int k = 0; k < Parameters.FixedParameters.Length; k++) { Parameter parameter3 = parameters[k]; if ((parameter3.ModFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { array2[num2++] = new Parameter(new TypeExpression(parameter3.Type, base.Location), parameter3.Name, parameter3.ModFlags & Parameter.Modifier.RefOutMask, (parameter3.OptAttributes == null) ? null : parameter3.OptAttributes.Clone(), base.Location); } } userParams2 = new ParametersCompiled(array2); } else { userParams2 = ParametersCompiled.EmptyReadOnlyParameters; } userParams2 = ParametersCompiled.MergeGenerated(Compiler, userParams2, checkConflicts: false, new Parameter(new TypeExpression(iAsyncResult.TypeSpec, base.Location), "result", Parameter.Modifier.NONE, null, base.Location), iAsyncResult.TypeSpec); EndInvokeBuilder = new Method(this, returnType, Modifiers.PUBLIC | Modifiers.VIRTUAL, new MemberName("EndInvoke"), userParams2, null); EndInvokeBuilder.Define(); } public override void PrepareEmit() { if ((caching_flags & Flags.CloseTypeCreated) == 0) { InvokeBuilder.PrepareEmit(); if (BeginInvokeBuilder != null) { BeginInvokeBuilder.TypeExpression = null; EndInvokeBuilder.TypeExpression = null; BeginInvokeBuilder.PrepareEmit(); EndInvokeBuilder.PrepareEmit(); } } } public override void Emit() { base.Emit(); TypeSpec type = ReturnType.Type; if (type != null) { if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder); } else if (type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder, type, base.Location); } else if (type is ReadOnlyReferenceContainer) { Module.PredefinedAttributes.IsReadOnly.EmitAttribute(CreateReturnBuilder().Builder); } if (type.HasNamedTupleElement) { Module.PredefinedAttributes.TupleElementNames.EmitAttribute(CreateReturnBuilder().Builder, type, base.Location); } ConstraintChecker.Check(this, ReturnType.Type, ReturnType.Location); } Constructor.ParameterInfo.ApplyAttributes(this, Constructor.ConstructorBuilder); Constructor.ConstructorBuilder.SetImplementationFlags(MethodImplAttributes.CodeTypeMask); parameters.CheckConstraints(this); parameters.ApplyAttributes(this, InvokeBuilder.MethodBuilder); InvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.CodeTypeMask); if (BeginInvokeBuilder != null) { BeginInvokeBuilder.ParameterInfo.ApplyAttributes(this, BeginInvokeBuilder.MethodBuilder); EndInvokeBuilder.ParameterInfo.ApplyAttributes(this, EndInvokeBuilder.MethodBuilder); BeginInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.CodeTypeMask); EndInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.CodeTypeMask); } } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { base_type = Compiler.BuiltinTypes.MulticastDelegate; base_class = null; return null; } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } parameters.VerifyClsCompliance(this); if (!InvokeBuilder.MemberType.IsCLSCompliant()) { base.Report.Warning(3002, 1, base.Location, "Return type of `{0}' is not CLS-compliant", GetSignatureForError()); } return true; } public static MethodSpec GetConstructor(TypeSpec delType) { MemberSpec memberSpec = MemberCache.FindMember(delType, MemberFilter.Constructor(null), BindingRestriction.DeclaredOnly); return (MethodSpec)memberSpec; } public static MethodSpec GetInvokeMethod(TypeSpec delType) { MemberSpec memberSpec = MemberCache.FindMember(delType, MemberFilter.Method(InvokeMethodName, 0, null, null), BindingRestriction.DeclaredOnly); return (MethodSpec)memberSpec; } public static AParametersCollection GetParameters(TypeSpec delType) { MethodSpec invokeMethod = GetInvokeMethod(delType); return invokeMethod.Parameters; } public static bool IsTypeCovariant(ResolveContext rc, TypeSpec a, TypeSpec b) { if (a == b) { return true; } if (rc.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) { return false; } if (a.IsGenericParameter && b.IsGenericParameter) { return a == b; } return Convert.ImplicitReferenceConversionExists(a, b); } public static string FullDelegateDesc(MethodSpec invoke_method) { return TypeManager.GetFullNameSignature(invoke_method).Replace(".Invoke", ""); } } internal abstract class DelegateCreation : Expression, OverloadResolver.IErrorHandler { protected MethodSpec constructor_method; protected MethodGroupExpr method_group; public bool AllowSpecialMethodsInvocation { get; set; } public override bool ContainsEmitWithAwait() { return method_group.InstanceExpression?.ContainsEmitWithAwait() ?? false; } public static Arguments CreateDelegateMethodArguments(ResolveContext rc, AParametersCollection pd, TypeSpec[] types, Location loc) { Arguments arguments = new Arguments(pd.Count); for (int i = 0; i < pd.Count; i++) { Argument.AType aType = (pd.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) switch { Parameter.Modifier.REF => Argument.AType.Ref, Parameter.Modifier.OUT => Argument.AType.Out, _ => Argument.AType.None, }; TypeSpec typeSpec = types[i]; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { typeSpec = rc.BuiltinTypes.Object; } arguments.Add(new Argument(new TypeExpression(typeSpec, loc), aType)); } return arguments; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(new TypeOf(type, loc))); if (method_group.InstanceExpression == null) { arguments.Add(new Argument(new NullLiteral(loc))); } else { arguments.Add(new Argument(method_group.InstanceExpression)); } MethodSpec methodSpec = ec.Module.PredefinedMembers.MethodInfoCreateDelegate.Get(); Expression expr; if (methodSpec != null) { MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(methodSpec, methodSpec.DeclaringType, loc); methodGroupExpr.InstanceExpression = method_group.CreateExpressionTree(ec); expr = methodGroupExpr; } else { expr = new MemberAccess(new MemberAccess(new QualifiedAliasMember("global", "System", loc), "Delegate", loc), "CreateDelegate", loc); arguments.Add(new Argument(method_group.CreateExpressionTree(ec))); } Expression expression = new Invocation(expr, arguments).Resolve(ec); if (expression == null) { return null; } return Convert.ExplicitConversion(ec, expression, type, loc)?.CreateExpressionTree(ec); } private void ResolveConditionalAccessReceiver(ResolveContext rc) { if (!rc.HasSet(ResolveContext.Options.DontSetConditionalAccessReceiver) && method_group.HasConditionalAccess()) { Error_OperatorCannotBeApplied(rc, loc, "?", method_group.Type); } } protected override Expression DoResolve(ResolveContext ec) { constructor_method = Delegate.GetConstructor(type); MethodSpec invokeMethod = Delegate.GetInvokeMethod(type); ResolveConditionalAccessReceiver(ec); Arguments args = CreateDelegateMethodArguments(ec, invokeMethod.Parameters, invokeMethod.Parameters.Types, loc); method_group = method_group.OverloadResolve(ec, ref args, this, OverloadResolver.Restrictions.CovariantDelegate); if (method_group == null) { return null; } MethodSpec bestCandidate = method_group.BestCandidate; if (bestCandidate.DeclaringType.IsNullableType) { ec.Report.Error(1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable type", bestCandidate.GetSignatureForError()); return null; } if (!AllowSpecialMethodsInvocation) { Invocation.IsSpecialMethodInvocation(ec, bestCandidate, loc); } if (method_group is ExtensionMethodGroupExpr extensionMethodGroupExpr) { method_group.InstanceExpression = extensionMethodGroupExpr.ExtensionExpression; TypeSpec typeSpec = extensionMethodGroupExpr.ExtensionExpression.Type; if (TypeSpec.IsValueType(typeSpec)) { ec.Report.Error(1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates", bestCandidate.GetSignatureForError(), typeSpec.GetSignatureForError()); } } TypeSpec typeSpec2 = method_group.BestCandidateReturnType; if (typeSpec2.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { typeSpec2 = ec.BuiltinTypes.Object; } if (!Delegate.IsTypeCovariant(ec, typeSpec2, invokeMethod.ReturnType)) { Error_ConversionFailed(ec, bestCandidate, bestCandidate.ReturnType); } if (method_group.IsConditionallyExcluded) { ec.Report.SymbolRelatedToPreviousError(bestCandidate); if (bestCandidate.MemberDefinition is MethodOrOperator { IsPartialDefinition: not false }) { ec.Report.Error(762, loc, "Cannot create delegate from partial method declaration `{0}'", bestCandidate.GetSignatureForError()); } else { ec.Report.Error(1618, loc, "Cannot create delegate with `{0}' because it has a Conditional attribute", TypeManager.CSharpSignature(bestCandidate)); } } Expression instanceExpression = method_group.InstanceExpression; if (instanceExpression != null && (instanceExpression.Type.IsGenericParameter || !TypeSpec.IsReferenceType(instanceExpression.Type))) { if (instanceExpression.Type.IsByRefLike || instanceExpression.Type.IsSpecialRuntimeType) { Error_ConversionFailed(ec, bestCandidate, null); } method_group.InstanceExpression = new BoxedCast(instanceExpression, ec.BuiltinTypes.Object); } eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { if (method_group.InstanceExpression == null) { ec.EmitNull(); } else { new InstanceEmitter(method_group.InstanceExpression, addressLoad: false).Emit(ec, method_group.ConditionalAccess); } MethodSpec bestCandidate = method_group.BestCandidate; if (!bestCandidate.DeclaringType.IsDelegate && bestCandidate.IsVirtual && !method_group.IsBase) { ec.Emit(OpCodes.Dup); ec.Emit(OpCodes.Ldvirtftn, bestCandidate); } else { ec.Emit(OpCodes.Ldftn, bestCandidate); } ec.Emit(OpCodes.Newobj, constructor_method); } public override void FlowAnalysis(FlowAnalysisContext fc) { base.FlowAnalysis(fc); method_group.FlowAnalysis(fc); } private void Error_ConversionFailed(ResolveContext ec, MethodSpec method, TypeSpec return_type) { MethodSpec invokeMethod = Delegate.GetInvokeMethod(type); string text = ((method_group.InstanceExpression != null) ? Delegate.FullDelegateDesc(method) : TypeManager.GetFullNameSignature(method)); ec.Report.SymbolRelatedToPreviousError(type); ec.Report.SymbolRelatedToPreviousError(method); if (ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) { ec.Report.Error(410, loc, "A method or delegate `{0} {1}' parameters and return type must be same as delegate `{2} {3}' parameters and return type", method.ReturnType.GetSignatureForError(), text, invokeMethod.ReturnType.GetSignatureForError(), Delegate.FullDelegateDesc(invokeMethod)); } else if (return_type == null) { ec.Report.Error(123, loc, "A method or delegate `{0}' parameters do not match delegate `{1}' parameters", text, Delegate.FullDelegateDesc(invokeMethod)); } else if (invokeMethod.ReturnType.Kind == MemberKind.ByRef) { ec.Report.Error(8189, loc, "By reference return delegate does not match `{0}' return type", Delegate.FullDelegateDesc(invokeMethod)); } else { ec.Report.Error(407, loc, "A method or delegate `{0} {1}' return type does not match delegate `{2} {3}' return type", return_type.GetSignatureForError(), text, invokeMethod.ReturnType.GetSignatureForError(), Delegate.FullDelegateDesc(invokeMethod)); } } public static bool ImplicitStandardConversionExists(ResolveContext ec, MethodGroupExpr mg, TypeSpec target_type) { MethodSpec invokeMethod = Delegate.GetInvokeMethod(target_type); Arguments args = CreateDelegateMethodArguments(ec, invokeMethod.Parameters, invokeMethod.Parameters.Types, mg.Location); mg = mg.OverloadResolve(ec, ref args, null, OverloadResolver.Restrictions.ProbingOnly | OverloadResolver.Restrictions.CovariantDelegate); return mg != null && Delegate.IsTypeCovariant(ec, mg.BestCandidateReturnType, invokeMethod.ReturnType); } bool OverloadResolver.IErrorHandler.AmbiguousCandidates(ResolveContext ec, MemberSpec best, MemberSpec ambiguous) { return false; } bool OverloadResolver.IErrorHandler.ArgumentMismatch(ResolveContext rc, MemberSpec best, Argument arg, int index) { Error_ConversionFailed(rc, best as MethodSpec, null); return true; } bool OverloadResolver.IErrorHandler.NoArgumentMatch(ResolveContext rc, MemberSpec best) { Error_ConversionFailed(rc, best as MethodSpec, null); return true; } bool OverloadResolver.IErrorHandler.TypeInferenceFailed(ResolveContext rc, MemberSpec best) { return false; } } internal class ImplicitDelegateCreation : DelegateCreation { private Field mg_cache; public ImplicitDelegateCreation(TypeSpec delegateType, MethodGroupExpr mg, Location loc) { type = delegateType; method_group = mg; base.loc = loc; } public static bool ContainsMethodTypeParameter(TypeSpec type) { if (!(type is TypeParameterSpec { IsMethodOwned: var isMethodOwned })) { if (type is ElementTypeSpec elementTypeSpec) { return ContainsMethodTypeParameter(elementTypeSpec.Element); } TypeSpec[] typeArguments = type.TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (ContainsMethodTypeParameter(typeSpec)) { return true; } } if (type.IsNested) { return ContainsMethodTypeParameter(type.DeclaringType); } return false; } return isMethodOwned; } private bool HasMvar() { if (ContainsMethodTypeParameter(type)) { return false; } MethodSpec bestCandidate = method_group.BestCandidate; if (ContainsMethodTypeParameter(bestCandidate.DeclaringType)) { return false; } if (bestCandidate.TypeArguments != null) { TypeSpec[] typeArguments = bestCandidate.TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (ContainsMethodTypeParameter(typeSpec)) { return false; } } } return true; } protected override Expression DoResolve(ResolveContext ec) { Expression expression = base.DoResolve(ec); if (expression == null) { return ErrorExpression.Instance; } if (ec.IsInProbingMode) { return expression; } if (method_group.InstanceExpression != null) { return expression; } if (!HasMvar()) { return expression; } TypeDefinition partialContainer = ec.CurrentMemberDefinition.Parent.PartialContainer; int id = partialContainer.MethodGroupsCounter++; mg_cache = new Field(partialContainer, new TypeExpression(type, loc), Modifiers.PRIVATE | Modifiers.STATIC | Modifiers.COMPILER_GENERATED, new MemberName(CompilerGeneratedContainer.MakeName(null, "f", "mg$cache", id), loc), null); mg_cache.Define(); partialContainer.AddField(mg_cache); return expression; } public override void Emit(EmitContext ec) { Label label = ec.DefineLabel(); if (mg_cache != null) { ec.Emit(OpCodes.Ldsfld, mg_cache.Spec); ec.Emit(OpCodes.Brtrue_S, label); } base.Emit(ec); if (mg_cache != null) { ec.Emit(OpCodes.Stsfld, mg_cache.Spec); ec.MarkLabel(label); ec.Emit(OpCodes.Ldsfld, mg_cache.Spec); } } } internal class NewDelegate : DelegateCreation { public Arguments Arguments; public NewDelegate(TypeSpec type, Arguments Arguments, Location loc) { base.type = type; this.Arguments = Arguments; base.loc = loc; } protected override Expression DoResolve(ResolveContext ec) { if (Arguments == null || Arguments.Count != 1) { ec.Report.Error(149, loc, "Method name expected"); return null; } Argument argument = Arguments[0]; if (!argument.ResolveMethodGroup(ec)) { return null; } Expression expression = argument.Expr; if (expression is AnonymousMethodExpression anonymousMethodExpression && ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1) { return anonymousMethodExpression.Compatible(ec, type)?.Resolve(ec); } method_group = expression as MethodGroupExpr; if (method_group == null) { if (expression.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { expression = Convert.ImplicitConversionRequired(ec, expression, type, loc); } else if (!expression.Type.IsDelegate) { expression.Error_UnexpectedKind(ec, ResolveFlags.Type | ResolveFlags.MethodGroup, loc); return null; } method_group = new MethodGroupExpr(Delegate.GetInvokeMethod(expression.Type), expression.Type, loc); method_group.InstanceExpression = expression; } return base.DoResolve(ec); } } internal class DelegateInvocation : ExpressionStatement { private readonly Expression InstanceExpr; private readonly bool conditionalAccessReceiver; private Arguments arguments; private MethodSpec method; public DelegateInvocation(Expression instance_expr, Arguments args, bool conditionalAccessReceiver, Location loc) { InstanceExpr = instance_expr; arguments = args; this.conditionalAccessReceiver = conditionalAccessReceiver; base.loc = loc; } public override bool ContainsEmitWithAwait() { return InstanceExpr.ContainsEmitWithAwait() || (arguments != null && arguments.ContainsEmitWithAwait()); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments args = Arguments.CreateForExpressionTree(ec, arguments, InstanceExpr.CreateExpressionTree(ec)); return CreateExpressionFactoryCall(ec, "Invoke", args); } public override void FlowAnalysis(FlowAnalysisContext fc) { InstanceExpr.FlowAnalysis(fc); if (arguments != null) { arguments.FlowAnalysis(fc); } } protected override Expression DoResolve(ResolveContext ec) { TypeSpec typeSpec = InstanceExpr.Type; if (typeSpec == null) { return null; } method = Delegate.GetInvokeMethod(typeSpec); OverloadResolver overloadResolver = new OverloadResolver(new MemberSpec[1] { method }, OverloadResolver.Restrictions.DelegateInvoke, loc); MethodSpec methodSpec = overloadResolver.ResolveMember(ec, ref arguments); if (methodSpec == null && !overloadResolver.BestCandidateIsDynamic) { return null; } type = method.ReturnType; if (conditionalAccessReceiver) { type = LiftMemberType(ec, type); } eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { if (conditionalAccessReceiver) { ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()); } CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = InstanceExpr; callEmitter.Emit(ec, method, arguments, loc); if (conditionalAccessReceiver) { ec.CloseConditionalAccess((type.IsNullableType && type != method.ReturnType) ? type : null); } } public override void EmitStatement(EmitContext ec) { if (conditionalAccessReceiver) { ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()) { Statement = true }; } CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = InstanceExpr; callEmitter.EmitStatement(ec, method, arguments, loc); if (conditionalAccessReceiver) { ec.CloseConditionalAccess(null); } } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return Invocation.MakeExpression(ctx, InstanceExpr, method, arguments); } } internal class DocumentationBuilder { private readonly ModuleContainer module; private readonly ModuleContainer doc_module; private static readonly string line_head = Environment.NewLine + " "; private ParserSession session; private Report Report => module.Compiler.Report; public MemberName ParsedName { get; set; } public List ParsedParameters { get; set; } public TypeExpression ParsedBuiltinType { get; set; } public Operator.OpType? ParsedOperator { get; set; } public DocumentationBuilder(ModuleContainer module) { } internal void GenerateDocumentationForMember(MemberCore mc) { } public bool OutputDocComment(string asmfilename, string xmlFileName) { return true; } } internal sealed class DocumentationMemberContext : IMemberContext, IModuleContext { private readonly MemberCore host; private MemberName contextName; public TypeSpec CurrentType => host.CurrentType; public TypeParameters CurrentTypeParameters => contextName.TypeParameters; public MemberCore CurrentMemberDefinition => host.CurrentMemberDefinition; public bool IsObsolete => false; public bool IsUnsafe => host.IsStatic; public bool IsStatic => host.IsStatic; public ModuleContainer Module => host.Module; public DocumentationMemberContext(MemberCore host, MemberName contextName) { this.host = host; this.contextName = contextName; } public string GetSignatureForError() { return host.GetSignatureForError(); } public ExtensionMethodCandidates LookupExtensionMethod(string name, int arity) { return null; } public FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { if (arity == 0) { TypeParameters currentTypeParameters = CurrentTypeParameters; if (currentTypeParameters != null) { for (int i = 0; i < currentTypeParameters.Count; i++) { TypeParameter typeParameter = currentTypeParameters[i]; if (typeParameter.Name == name) { typeParameter.Type.DeclaredPosition = i; return new TypeParameterExpr(typeParameter, loc); } } } } return host.Parent.LookupNamespaceOrType(name, arity, mode, loc); } public FullNamedExpression LookupNamespaceAlias(string name) { throw new NotImplementedException(); } } internal class DocumentationParameter { public readonly Parameter.Modifier Modifier; public FullNamedExpression Type; private TypeSpec type; public TypeSpec TypeSpec => type; public DocumentationParameter(Parameter.Modifier modifier, FullNamedExpression type) : this(type) { Modifier = modifier; } public DocumentationParameter(FullNamedExpression type) { Type = type; } public void Resolve(IMemberContext context) { type = Type.ResolveAsType(context); } } internal class Driver { private readonly CompilerContext ctx; private Report Report => ctx.Report; public Driver(CompilerContext ctx) { this.ctx = ctx; } private void tokenize_file(SourceFile sourceFile, ModuleContainer module, ParserSession session) { Stream stream = null; SeekableStreamReader seekableStreamReader = null; try { if (sourceFile.GetInputStream != null) { seekableStreamReader = sourceFile.GetInputStream(sourceFile); if (seekableStreamReader == null) { throw new FileNotFoundException("Delegate returned null", sourceFile.Name); } } else { stream = File.OpenRead(sourceFile.Name); } } catch { Report.Error(2001, "Source file `" + sourceFile.Name + "' could not be found"); return; } if (seekableStreamReader == null) { using (stream) { seekableStreamReader = new SeekableStreamReader(stream, ctx.Settings.Encoding); DoTokenize(sourceFile, module, session, seekableStreamReader); return; } } DoTokenize(sourceFile, module, session, seekableStreamReader); } private void DoTokenize(SourceFile sourceFile, ModuleContainer module, ParserSession session, SeekableStreamReader reader) { CompilationSourceFile file = new CompilationSourceFile(module, sourceFile); Tokenizer tokenizer = new Tokenizer(reader, file, session, ctx.Report); int num = 0; int num2 = 0; int num3; while ((num3 = tokenizer.token()) != 257) { num++; if (num3 == 259) { num2++; } } Console.WriteLine("Tokenized: " + num + " found " + num2 + " errors"); } private void Parse(ModuleContainer module) { bool tokenizeOnly = module.Compiler.Settings.TokenizeOnly; List sourceFiles = module.Compiler.SourceFiles; Location.Initialize(sourceFiles); ParserSession parserSession = new ParserSession(); parserSession.UseJayGlobalArrays = true; parserSession.LocatedTokens = new LocatedToken[15000]; ParserSession session = parserSession; for (int i = 0; i < sourceFiles.Count; i++) { if (tokenizeOnly) { tokenize_file(sourceFiles[i], module, session); } else { Parse(sourceFiles[i], module, session, Report); } } } public void Parse(SourceFile file, ModuleContainer module, ParserSession session, Report report) { Stream stream = null; SeekableStreamReader seekableStreamReader = null; try { if (file.GetInputStream != null) { seekableStreamReader = file.GetInputStream(file); if (seekableStreamReader == null) { throw new FileNotFoundException("Delegate returned null", file.Name); } } else { stream = File.OpenRead(file.Name); } } catch { report.Error(2001, "Source file `{0}' could not be found", file.Name); return; } if (seekableStreamReader == null) { using (stream) { if (stream.ReadByte() == 77 && stream.ReadByte() == 90) { report.Error(2015, "Source file `{0}' is a binary file and not a text file", file.Name); } else { stream.Position = 0L; seekableStreamReader = new SeekableStreamReader(stream, ctx.Settings.Encoding, session.StreamReaderBuffer); DoParse(file, module, session, report, seekableStreamReader); } return; } } DoParse(file, module, session, report, seekableStreamReader); } private void DoParse(SourceFile file, ModuleContainer module, ParserSession session, Report report, SeekableStreamReader reader) { Parse(reader, file, module, session, report); if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum) { reader.Stream.Position = 0L; MD5 checksumAlgorithm = session.GetChecksumAlgorithm(); file.SetChecksum(checksumAlgorithm.ComputeHash(reader.Stream)); } } public static void Parse(SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, ParserSession session, Report report) { CompilationSourceFile compilationSourceFile = new CompilationSourceFile(module, sourceFile); module.AddTypeContainer(compilationSourceFile); CSharpParser cSharpParser = new CSharpParser(reader, compilationSourceFile, report, session); cSharpParser.parse(); } public static int Main(string[] args) { Location.InEmacs = Environment.GetEnvironmentVariable("EMACS") == "t"; CommandLineParser commandLineParser = new CommandLineParser(Console.Out); CompilerSettings compilerSettings = commandLineParser.ParseArguments(args); if (compilerSettings == null) { return 1; } if (commandLineParser.HasBeenStopped) { return 0; } Driver driver = new Driver(new CompilerContext(compilerSettings, new ConsoleReportPrinter())); if (driver.Compile() && driver.Report.Errors == 0) { if (driver.Report.Warnings > 0) { Console.WriteLine("Compilation succeeded - {0} warning(s)", driver.Report.Warnings); } Environment.Exit(0); return 0; } Console.WriteLine("Compilation failed: {0} error(s), {1} warnings", driver.Report.Errors, driver.Report.Warnings); Environment.Exit(1); return 1; } public static string GetPackageFlags(string packages, Report report) { throw new NotSupportedException("Process.Start is not supported on this platform."); } public bool Compile() { CompilerSettings settings = ctx.Settings; if (settings.FirstSourceFile == null && (settings.Target == Target.Exe || settings.Target == Target.WinExe || settings.Target == Target.Module || settings.Resources == null)) { Report.Error(2008, "No files to compile were specified"); return false; } if (settings.Platform == Platform.AnyCPU32Preferred && (settings.Target == Target.Library || settings.Target == Target.Module)) { Report.Error(4023, "Platform option `anycpu32bitpreferred' is valid only for executables"); return false; } TimeReporter timeReporter = new TimeReporter(settings.Timestamps); ctx.TimeReporter = timeReporter; timeReporter.StartTotal(); ModuleContainer moduleContainer = (RootContext.ToplevelTypes = new ModuleContainer(ctx)); timeReporter.Start(TimeReporter.TimerType.ParseTotal); Parse(moduleContainer); timeReporter.Stop(TimeReporter.TimerType.ParseTotal); if (Report.Errors > 0) { return false; } if (settings.TokenizeOnly || settings.ParseOnly) { timeReporter.StopTotal(); timeReporter.ShowStats(); return true; } string text = settings.OutputFile; string text2; if (text == null) { SourceFile firstSourceFile = settings.FirstSourceFile; if (firstSourceFile == null) { Report.Error(1562, "If no source files are specified you must specify the output file with -out:"); return false; } text2 = firstSourceFile.Name; int num = text2.LastIndexOf('.'); if (num > 0) { text2 = text2.Substring(0, num); } text2 += settings.TargetExt; text = text2; } else { text2 = Path.GetFileName(text); if (string.IsNullOrEmpty(Path.GetFileNameWithoutExtension(text2)) || text2.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { Report.Error(2021, "Output file name is not valid"); return false; } } AssemblyDefinitionDynamic assemblyDefinitionDynamic = new AssemblyDefinitionDynamic(moduleContainer, text2, text); moduleContainer.SetDeclaringAssembly(assemblyDefinitionDynamic); ReflectionImporter importer = (ReflectionImporter)(assemblyDefinitionDynamic.Importer = new ReflectionImporter(moduleContainer, ctx.BuiltinTypes)); DynamicLoader dynamicLoader = new DynamicLoader(importer, ctx); dynamicLoader.LoadReferences(moduleContainer); if (!ctx.BuiltinTypes.CheckDefinitions(moduleContainer)) { return false; } if (!assemblyDefinitionDynamic.Create(AppDomain.CurrentDomain, AssemblyBuilderAccess.Run)) { return false; } moduleContainer.CreateContainer(); dynamicLoader.LoadModules(assemblyDefinitionDynamic, moduleContainer.GlobalRootNamespace); moduleContainer.InitializePredefinedTypes(); if (settings.GetResourceStrings != null) { moduleContainer.LoadGetResourceStrings(settings.GetResourceStrings); } timeReporter.Start(TimeReporter.TimerType.ModuleDefinitionTotal); moduleContainer.Define(); timeReporter.Stop(TimeReporter.TimerType.ModuleDefinitionTotal); if (Report.Errors > 0) { return false; } assemblyDefinitionDynamic.Resolve(); if (Report.Errors > 0) { return false; } timeReporter.Start(TimeReporter.TimerType.EmitTotal); assemblyDefinitionDynamic.Emit(); timeReporter.Stop(TimeReporter.TimerType.EmitTotal); if (Report.Errors > 0) { return false; } timeReporter.Start(TimeReporter.TimerType.CloseTypes); moduleContainer.CloseContainer(); timeReporter.Stop(TimeReporter.TimerType.CloseTypes); timeReporter.Start(TimeReporter.TimerType.Resouces); if (!settings.WriteMetadataOnly) { assemblyDefinitionDynamic.EmbedResources(); } timeReporter.Stop(TimeReporter.TimerType.Resouces); if (Report.Errors > 0) { return false; } assemblyDefinitionDynamic.Save(); timeReporter.StopTotal(); timeReporter.ShowStats(); return Report.Errors == 0; } } internal class CompilerCallableEntryPoint : MarshalByRefObject { public static int[] AllWarningNumbers => Report.AllWarnings; public static bool InvokeCompiler(string[] args, TextWriter error) { try { CommandLineParser commandLineParser = new CommandLineParser(error); CompilerSettings compilerSettings = commandLineParser.ParseArguments(args); if (compilerSettings == null) { return false; } Driver driver = new Driver(new CompilerContext(compilerSettings, new StreamReportPrinter(error))); return driver.Compile(); } finally { Reset(); } } public static void Reset() { Reset(full_flag: true); } public static void PartialReset() { Reset(full_flag: false); } public static void Reset(bool full_flag) { Location.Reset(); if (full_flag) { QueryBlock.TransparentParameter.Reset(); TypeInfo.Reset(); } } } [Flags] internal enum CSharpBinderFlags { None = 0, CheckedContext = 1, InvokeSimpleName = 2, InvokeSpecialName = 4, BinaryOperationLogical = 8, ConvertExplicit = 0x10, ConvertArrayIndex = 0x20, ResultIndexed = 0x40, ValueFromCompoundAssignment = 0x80, ResultDiscarded = 0x100 } internal class DynamicTypeExpr : TypeExpr { public DynamicTypeExpr(Location loc) { base.loc = loc; } public override TypeSpec ResolveAsType(IMemberContext ec, bool allowUnboundTypeArguments) { eclass = ExprClass.Type; type = ec.Module.Compiler.BuiltinTypes.Dynamic; return type; } } internal class RuntimeValueExpression : Expression, IDynamicAssign, IAssignMethod, IMemoryLocation { public class DynamicMetaObject { public TypeSpec RuntimeType; public TypeSpec LimitType; public System.Linq.Expressions.Expression Expression; } private readonly DynamicMetaObject obj; public bool IsSuggestionOnly { get; set; } public DynamicMetaObject MetaObject => obj; public RuntimeValueExpression(DynamicMetaObject obj, TypeSpec type) { this.obj = obj; base.type = type; eclass = ExprClass.Variable; } public void AddressOf(EmitContext ec, AddressOp mode) { throw new NotImplementedException(); } public override bool ContainsEmitWithAwait() { throw new NotSupportedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException(); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return this; } public override void Emit(EmitContext ec) { throw new NotImplementedException(); } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { throw new NotImplementedException(); } public System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source) { return obj.Expression; } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Convert(obj.Expression, type.GetMetaInfo()); } } internal class DynamicResultCast : ShimExpression { public DynamicResultCast(TypeSpec type, Expression expr) : base(expr) { base.type = type; } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); eclass = ExprClass.Value; return this; } } internal interface IDynamicBinder { Expression CreateCallSiteBinder(ResolveContext ec, Arguments args); } internal interface IDynamicAssign : IAssignMethod { System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source); } internal class DynamicExpressionStatement : ExpressionStatement { protected class BinderFlags : EnumConstant { private readonly DynamicExpressionStatement statement; private readonly CSharpBinderFlags flags; public BinderFlags(CSharpBinderFlags flags, DynamicExpressionStatement statement) : base(statement.loc) { this.flags = flags; this.statement = statement; eclass = ExprClass.Unresolved; } protected override Expression DoResolve(ResolveContext ec) { Child = new IntConstant(ec.BuiltinTypes, (int)(flags | statement.flags), statement.loc); type = ec.Module.PredefinedTypes.BinderFlags.Resolve(); eclass = Child.eclass; return this; } } private readonly Arguments arguments; protected IDynamicBinder binder; protected Expression binder_expr; protected CSharpBinderFlags flags; private TypeSpec binder_type; private TypeParameters context_mvars; public Arguments Arguments => arguments; protected virtual bool IsConditionalAccessReceiver => false; public DynamicExpressionStatement(IDynamicBinder binder, Arguments args, Location loc) { this.binder = binder; arguments = args; base.loc = loc; } public override bool ContainsEmitWithAwait() { return arguments.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(1963, loc, "An expression tree cannot contain a dynamic operation"); return null; } protected override Expression DoResolve(ResolveContext rc) { if (DoResolveCore(rc)) { binder_expr = binder.CreateCallSiteBinder(rc, arguments); } return this; } protected bool DoResolveCore(ResolveContext rc) { int num = 0; foreach (Argument argument in arguments) { if (argument.Type == InternalType.VarOutType) { rc.Report.Error(8197, argument.Expr.Location, "Cannot infer the type of implicitly-typed out variable `{0}'", ((DeclarationExpression)argument.Expr).Variable.Name); } else if (argument.Type == InternalType.DefaultType) { rc.Report.Error(8311, argument.Expr.Location, "Cannot use a default literal as an argument to a dynamically dispatched operation"); } if (num > 0 && arguments[num - 1] is NamedArgument && !(arguments[num] is NamedArgument)) { rc.Report.Error(8324, loc, "Named argument specifications must appear after all fixed arguments have been specified in a dynamic invocation"); } num++; } if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter) { context_mvars = rc.CurrentTypeParameters; } int errors = rc.Report.Errors; PredefinedTypes predefinedTypes = rc.Module.PredefinedTypes; binder_type = predefinedTypes.Binder.Resolve(); predefinedTypes.CallSite.Resolve(); predefinedTypes.CallSiteGeneric.Resolve(); eclass = ExprClass.Value; if (type == null) { type = rc.BuiltinTypes.Dynamic; } if (rc.Report.Errors == errors) { return true; } rc.Report.Error(1969, loc, "Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly reference"); return false; } public override void Emit(EmitContext ec) { EmitCall(ec, binder_expr, arguments, isStatement: false); } public override void EmitStatement(EmitContext ec) { EmitCall(ec, binder_expr, arguments, isStatement: true); } protected void EmitConditionalAccess(EmitContext ec) { Expression expr = arguments[0].Expr; if (expr is DynamicExpressionStatement dynamicExpressionStatement) { dynamicExpressionStatement.EmitConditionalAccess(ec); } if (HasConditionalAccess()) { Label label = ec.DefineLabel(); if (ExpressionAnalyzer.IsInexpensiveLoad(expr)) { expr.Emit(ec); } else { LocalTemporary localTemporary = new LocalTemporary(expr.Type); localTemporary.EmitAssign(ec, expr, leave_copy: true, isCompound: false); Arguments[0].Expr = localTemporary; } ec.Emit(OpCodes.Brtrue_S, label); if (!ec.ConditionalAccess.Statement) { if (ec.ConditionalAccess.Type.IsNullableType) { LiftedNull.Create(ec.ConditionalAccess.Type, Location.Null).Emit(ec); } else { ec.EmitNull(); } } ec.Emit(OpCodes.Br, ec.ConditionalAccess.EndLabel); ec.MarkLabel(label); } else if (expr.HasConditionalAccess()) { LocalTemporary localTemporary2 = new LocalTemporary(expr.Type); localTemporary2.EmitAssign(ec, expr, leave_copy: false, isCompound: false); Arguments[0].Expr = localTemporary2; } } protected void EmitCall(EmitContext ec, Expression binder, Arguments arguments, bool isStatement) { int num = arguments?.Count ?? 0; int num2 = (isStatement ? 1 : 2); ModuleContainer module = ec.Module; bool flag = false; TypeExpression[] array = new TypeExpression[num + num2]; array[0] = new TypeExpression(module.PredefinedTypes.CallSite.TypeSpec, loc); TypeExpression[] array2 = null; DynamicSiteClass dynamicSiteClass = ec.CreateDynamicSite(); TypeParameterMutator typeParameterMutator; if (context_mvars != null) { TypeContainer typeContainer = dynamicSiteClass; TypeParameters currentTypeParameters; do { currentTypeParameters = typeContainer.CurrentTypeParameters; typeContainer = typeContainer.Parent; } while (currentTypeParameters == null); typeParameterMutator = new TypeParameterMutator(context_mvars, currentTypeParameters); if (!ec.IsAnonymousStoreyMutateRequired) { array2 = new TypeExpression[array.Length]; array2[0] = array[0]; } } else { typeParameterMutator = null; } for (int i = 0; i < num; i++) { Argument argument = arguments[i]; if (argument.ArgType == Argument.AType.Out || argument.ArgType == Argument.AType.Ref) { flag = true; } TypeSpec typeSpec = argument.Type; if (typeSpec.Kind == MemberKind.InternalCompilerType) { typeSpec = ec.BuiltinTypes.Object; } if (array2 != null) { array2[i + 1] = new TypeExpression(typeSpec, loc); } if (typeParameterMutator != null) { typeSpec = typeSpec.Mutate(typeParameterMutator); } array[i + 1] = new TypeExpression(typeSpec, loc); } TypeExpr typeExpr = null; TypeExpr typeExpr2 = null; if (!flag) { string name = (isStatement ? "Action" : "Func"); TypeSpec typeSpec2 = null; Namespace obj = module.GlobalRootNamespace.GetNamespace("System", create: true); if (obj != null) { typeSpec2 = obj.LookupType(module, name, num + num2, LookupMode.IgnoreAccessibility, loc); } if (typeSpec2 != null) { if (!isStatement) { TypeSpec typeSpec3 = type; if (typeSpec3.Kind == MemberKind.InternalCompilerType) { typeSpec3 = ec.BuiltinTypes.Object; } if (array2 != null) { array2[^1] = new TypeExpression(typeSpec3, loc); } if (typeParameterMutator != null) { typeSpec3 = typeSpec3.Mutate(typeParameterMutator); } array[^1] = new TypeExpression(typeSpec3, loc); } TypeSpec open_type = typeSpec2; FullNamedExpression[] types = array; typeExpr = new GenericTypeExpr(open_type, new TypeArguments(types), loc); if (array2 != null) { TypeSpec open_type2 = typeSpec2; types = array2; typeExpr2 = new GenericTypeExpr(open_type2, new TypeArguments(types), loc); } else { typeExpr2 = typeExpr; } } } Delegate obj2; if (typeExpr == null) { TypeSpec typeSpec4 = (isStatement ? ec.BuiltinTypes.Void : type); Parameter[] array3 = new Parameter[num + 1]; array3[0] = new Parameter(array[0], "p0", Parameter.Modifier.NONE, null, loc); DynamicSiteClass dynamicSiteClass2 = ec.CreateDynamicSite(); int num3 = ((dynamicSiteClass2.Containers != null) ? dynamicSiteClass2.Containers.Count : 0); if (typeParameterMutator != null) { typeSpec4 = typeParameterMutator.Mutate(typeSpec4); } for (int j = 1; j < num + 1; j++) { array3[j] = new Parameter(array[j], "p" + j.ToString("X"), arguments[j - 1].Modifier, null, loc); } obj2 = new Delegate(dynamicSiteClass2, new TypeExpression(typeSpec4, loc), Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED, new MemberName("Container" + num3.ToString("X")), new ParametersCompiled(array3), null); obj2.CreateContainer(); obj2.DefineContainer(); obj2.Define(); obj2.PrepareEmit(); dynamicSiteClass2.AddTypeContainer(obj2); if (dynamicSiteClass2.CurrentType is InflatedTypeSpec && num3 > 0) { dynamicSiteClass2.CurrentType.MemberCache.AddMember(obj2.CurrentType); } typeExpr = new TypeExpression(obj2.CurrentType, loc); typeExpr2 = ((array2 == null) ? typeExpr : null); } else { obj2 = null; } GenericTypeExpr genericTypeExpr = new GenericTypeExpr(module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments(typeExpr), loc); FieldSpec fieldSpec = dynamicSiteClass.CreateCallSiteField(genericTypeExpr, loc); if (fieldSpec == null) { return; } if (typeExpr2 == null) { TypeSpec declaringType = obj2.CurrentType.DeclaringType; TypeSpec[] types2 = context_mvars.Types; InflatedTypeSpec container = declaringType.MakeGenericType(module, types2); typeExpr2 = new TypeExpression(MemberCache.GetMember(container, obj2.CurrentType), loc); } GenericTypeExpr genericTypeExpr2 = new GenericTypeExpr(module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments(typeExpr2), loc); if (genericTypeExpr2.ResolveAsType(ec.MemberContext) == null) { return; } bool flag2 = context_mvars != null && ec.IsAnonymousStoreyMutateRequired; TypeSpec typeSpec5; if (flag2 || context_mvars == null) { typeSpec5 = dynamicSiteClass.CurrentType; } else { TypeSpec currentType = dynamicSiteClass.CurrentType; TypeSpec[] types2 = context_mvars.Types; typeSpec5 = currentType.MakeGenericType(module, types2); } if (typeSpec5 is InflatedTypeSpec && dynamicSiteClass.AnonymousMethodsCounter > 1) { TypeParameterSpec[] tparams = ((typeSpec5.MemberDefinition.TypeParametersCount > 0) ? typeSpec5.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes); TypeParameterInflator inflator = new TypeParameterInflator(module, typeSpec5, tparams, typeSpec5.TypeArguments); typeSpec5.MemberCache.AddMember(fieldSpec.InflateMember(inflator)); } FieldExpr fieldExpr = new FieldExpr(MemberCache.GetMember(typeSpec5, fieldSpec), loc); BlockContext blockContext = new BlockContext(ec.MemberContext, null, ec.BuiltinTypes.Void); Arguments arguments2 = new Arguments(1); arguments2.Add(new Argument(binder)); StatementExpression statementExpression = new StatementExpression(new SimpleAssign(fieldExpr, new Invocation(new MemberAccess(genericTypeExpr2, "Create"), arguments2))); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { bool isConditionalAccessReceiver = IsConditionalAccessReceiver; ConditionalAccessContext conditionalAccess = ec.ConditionalAccess; if (isConditionalAccessReceiver) { ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()) { Statement = isStatement }; EmitConditionalAccess(ec); } if (statementExpression.Resolve(blockContext)) { Statement statement = new If(new Binary(Binary.Operator.Equality, fieldExpr, new NullLiteral(loc)), statementExpression, loc); statement.Emit(ec); } arguments2 = new Arguments(1 + num); arguments2.Add(new Argument(fieldExpr)); if (arguments != null) { int num4 = 1; foreach (Argument argument2 in arguments) { if (argument2 is NamedArgument) { arguments2.Add(new Argument(argument2.Expr, argument2.ArgType)); } else { arguments2.Add(argument2); } if (flag2 && argument2.Type != array[num4].Type) { argument2.Expr.Type = array[num4].Type; } num4++; } } new DelegateInvocation(new MemberAccess(fieldExpr, "Target", loc).Resolve(blockContext), arguments2, conditionalAccessReceiver: false, loc).Resolve(blockContext)?.Emit(ec); if (isConditionalAccessReceiver) { ec.CloseConditionalAccess((!isStatement && type.IsNullableType) ? type : null); ec.ConditionalAccess = conditionalAccess; } } } public override void FlowAnalysis(FlowAnalysisContext fc) { arguments.FlowAnalysis(fc); } public static MemberAccess GetBinderNamespace(Location loc) { return new MemberAccess(new MemberAccess(new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "Microsoft", loc), "CSharp", loc), "RuntimeBinder", loc); } protected MemberAccess GetBinder(string name, Location loc) { return new MemberAccess(new TypeExpression(binder_type, loc), name, loc); } } internal class DynamicEventCompoundAssign : ExpressionStatement { private class IsEvent : DynamicExpressionStatement, IDynamicBinder { private string name; public IsEvent(string name, Arguments args, Location loc) : base(null, args, loc) { this.name = name; binder = this; } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { type = ec.BuiltinTypes.Bool; Arguments arguments = new Arguments(3); arguments.Add(new Argument(new BinderFlags(CSharpBinderFlags.None, this))); arguments.Add(new Argument(new StringLiteral(ec.BuiltinTypes, name, loc))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); return new Invocation(GetBinder("IsEvent", loc), arguments); } } private Expression condition; private ExpressionStatement invoke; private ExpressionStatement assign; public DynamicEventCompoundAssign(string name, Arguments args, ExpressionStatement assignment, ExpressionStatement invoke, Location loc) { condition = new IsEvent(name, args, loc); this.invoke = invoke; assign = assignment; base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { return condition.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext rc) { type = rc.BuiltinTypes.Dynamic; eclass = ExprClass.Value; condition = condition.Resolve(rc); return this; } public override void Emit(EmitContext ec) { ResolveContext rc = new ResolveContext(ec.MemberContext); Expression expression = new Conditional(new BooleanExpression(condition), invoke, assign, loc).Resolve(rc); expression.Emit(ec); } public override void EmitStatement(EmitContext ec) { If obj = new If(condition, new StatementExpression(invoke), new StatementExpression(assign), loc); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { obj.Emit(ec); } } public override void FlowAnalysis(FlowAnalysisContext fc) { invoke.FlowAnalysis(fc); } } internal class DynamicConversion : DynamicExpressionStatement, IDynamicBinder { public DynamicConversion(TypeSpec targetType, CSharpBinderFlags flags, Arguments args, Location loc) : base(null, args, loc) { type = targetType; base.flags = flags; binder = this; } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { Arguments arguments = new Arguments(3); flags |= (CSharpBinderFlags)(ec.HasSet(ResolveContext.Options.CheckedScope) ? 1 : 0); arguments.Add(new Argument(new BinderFlags(flags, this))); arguments.Add(new Argument(new TypeOf(type, loc))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); return new Invocation(GetBinder("Convert", loc), arguments); } } internal class DynamicConstructorBinder : DynamicExpressionStatement, IDynamicBinder { public DynamicConstructorBinder(TypeSpec type, Arguments args, Location loc) : base(null, args, loc) { base.type = type; binder = this; } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { Arguments arguments = new Arguments(3); arguments.Add(new Argument(new BinderFlags(CSharpBinderFlags.None, this))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(args.CreateDynamicBinderArguments(ec), loc))); return new Invocation(GetBinder("InvokeConstructor", loc), arguments); } } internal class DynamicIndexBinder : DynamicMemberAssignable { private bool can_be_mutator; private readonly bool conditional_access_receiver; private readonly bool conditional_access; protected override bool IsConditionalAccessReceiver => conditional_access_receiver; public DynamicIndexBinder(Arguments args, bool conditionalAccessReceiver, bool conditionalAccess, Location loc) : base(args, loc) { conditional_access_receiver = conditionalAccessReceiver; conditional_access = conditionalAccess; } public DynamicIndexBinder(CSharpBinderFlags flags, Arguments args, Location loc) : this(args, conditionalAccessReceiver: false, conditionalAccess: false, loc) { base.flags = flags; } protected override Expression DoResolve(ResolveContext ec) { can_be_mutator = true; return base.DoResolve(ec); } protected override Expression CreateCallSiteBinder(ResolveContext ec, Arguments args, bool isSet) { Arguments arguments = new Arguments(3); arguments.Add(new Argument(new BinderFlags(flags, this))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(args.CreateDynamicBinderArguments(ec), loc))); isSet |= (flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0; return new Invocation(GetBinder(isSet ? "SetIndex" : "GetIndex", loc), arguments); } protected override Arguments CreateSetterArguments(ResolveContext rc, Expression rhs) { if (!can_be_mutator) { return base.CreateSetterArguments(rc, rhs); } Arguments arguments = new Arguments(base.Arguments.Count + 1); for (int i = 0; i < base.Arguments.Count; i++) { Expression expr = base.Arguments[i].Expr; if (expr is Constant || expr is VariableReference || expr is This) { arguments.Add(base.Arguments[i]); continue; } LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(expr.Type, rc.CurrentBlock, loc); expr = new SimpleAssign(localVariable.CreateReferenceExpression(rc, expr.Location), expr).Resolve(rc); base.Arguments[i].Expr = localVariable.CreateReferenceExpression(rc, expr.Location).Resolve(rc); arguments.Add(base.Arguments[i].Clone(expr)); } arguments.Add(new Argument(rhs)); return arguments; } public override bool HasConditionalAccess() { return conditional_access; } } internal class DynamicInvocation : DynamicExpressionStatement, IDynamicBinder { private readonly ATypeNameExpression member; private readonly bool conditional_access_receiver; protected override bool IsConditionalAccessReceiver => conditional_access_receiver; public DynamicInvocation(ATypeNameExpression member, Arguments args, bool conditionalAccessReceiver, Location loc) : base(null, args, loc) { binder = this; this.member = member; conditional_access_receiver = conditionalAccessReceiver; } public static DynamicInvocation CreateSpecialNameInvoke(ATypeNameExpression member, Arguments args, Location loc) { return new DynamicInvocation(member, args, conditionalAccessReceiver: false, loc) { flags = CSharpBinderFlags.InvokeSpecialName }; } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { Arguments arguments = new Arguments((member != null) ? 5 : 3); bool flag = member is MemberAccess; CSharpBinderFlags cSharpBinderFlags; if (!flag && member is SimpleName) { cSharpBinderFlags = CSharpBinderFlags.InvokeSimpleName; flag = true; } else { cSharpBinderFlags = CSharpBinderFlags.None; } arguments.Add(new Argument(new BinderFlags(cSharpBinderFlags, this))); if (flag) { arguments.Add(new Argument(new StringLiteral(ec.BuiltinTypes, member.Name, member.Location))); } if (member != null && member.HasTypeArguments) { TypeArguments typeArguments = member.TypeArguments; if (typeArguments.Resolve(ec, allowUnbound: false)) { ArrayInitializer arrayInitializer = new ArrayInitializer(typeArguments.Count, loc); TypeSpec[] array = typeArguments.Arguments; foreach (TypeSpec typeSpec in array) { arrayInitializer.Add(new TypeOf(typeSpec, loc)); } arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(arrayInitializer, loc))); } } else if (flag) { arguments.Add(new Argument(new NullLiteral(loc))); } arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); Expression expr = ((args != null) ? new ImplicitlyTypedArrayCreation(args.CreateDynamicBinderArguments(ec), loc) : new ArrayCreation(new MemberAccess(DynamicExpressionStatement.GetBinderNamespace(loc), "CSharpArgumentInfo", loc), new ArrayInitializer(0, loc), loc)); arguments.Add(new Argument(expr)); return new Invocation(GetBinder(flag ? "InvokeMember" : "Invoke", loc), arguments); } public override void EmitStatement(EmitContext ec) { flags |= CSharpBinderFlags.ResultDiscarded; base.EmitStatement(ec); } public override bool HasConditionalAccess() { return member is ConditionalMemberAccess; } } internal class DynamicConditionalMemberBinder : DynamicMemberBinder { public DynamicConditionalMemberBinder(string name, Arguments args, Location loc) : base(name, args, loc) { } public override bool HasConditionalAccess() { return true; } } internal class DynamicMemberBinder : DynamicMemberAssignable { private readonly string name; private bool conditionalAccessReceiver; protected override bool IsConditionalAccessReceiver => conditionalAccessReceiver; public DynamicMemberBinder(string name, Arguments args, Location loc) : base(args, loc) { this.name = name; } public DynamicMemberBinder(string name, CSharpBinderFlags flags, Arguments args, Location loc) : this(name, args, loc) { base.flags = flags; } protected override Expression CreateCallSiteBinder(ResolveContext ec, Arguments args, bool isSet) { Arguments arguments = new Arguments(4); arguments.Add(new Argument(new BinderFlags(flags, this))); arguments.Add(new Argument(new StringLiteral(ec.BuiltinTypes, name, loc))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(args.CreateDynamicBinderArguments(ec), loc))); isSet |= (flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0; return new Invocation(GetBinder(isSet ? "SetMember" : "GetMember", loc), arguments); } protected override Expression DoResolve(ResolveContext rc) { if (!rc.HasSet(ResolveContext.Options.DontSetConditionalAccessReceiver)) { conditionalAccessReceiver = HasConditionalAccess() || base.Arguments[0].Expr.HasConditionalAccess(); } return base.DoResolve(rc); } } internal abstract class DynamicMemberAssignable : DynamicExpressionStatement, IDynamicBinder, IAssignMethod { private Expression setter; private Arguments setter_args; protected DynamicMemberAssignable(Arguments args, Location loc) : base(null, args, loc) { binder = this; } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { return CreateCallSiteBinder(ec, args, isSet: false); } protected abstract Expression CreateCallSiteBinder(ResolveContext ec, Arguments args, bool isSet); protected virtual Arguments CreateSetterArguments(ResolveContext rc, Expression rhs) { Arguments arguments = new Arguments(base.Arguments.Count + 1); arguments.AddRange(base.Arguments); arguments.Add(new Argument(rhs)); return arguments; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (right_side == EmptyExpression.OutAccess) { right_side.DoResolveLValue(rc, this); return null; } if (DoResolveCore(rc)) { setter_args = CreateSetterArguments(rc, right_side); setter = CreateCallSiteBinder(rc, setter_args, isSet: true); } eclass = ExprClass.Variable; return this; } public override void Emit(EmitContext ec) { if (binder_expr == null) { EmitCall(ec, setter, base.Arguments, isStatement: false); } else { base.Emit(ec); } } public override void EmitStatement(EmitContext ec) { if (binder_expr == null) { EmitCall(ec, setter, base.Arguments, isStatement: true); } else { base.EmitStatement(ec); } } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { EmitCall(ec, setter, setter_args, !leave_copy); } } internal class DynamicUnaryConversion : DynamicExpressionStatement, IDynamicBinder { private readonly string name; public DynamicUnaryConversion(string name, Arguments args, Location loc) : base(null, args, loc) { this.name = name; binder = this; } public static DynamicUnaryConversion CreateIsTrue(ResolveContext rc, Arguments args, Location loc) { return new DynamicUnaryConversion("IsTrue", args, loc) { type = rc.BuiltinTypes.Bool }; } public static DynamicUnaryConversion CreateIsFalse(ResolveContext rc, Arguments args, Location loc) { return new DynamicUnaryConversion("IsFalse", args, loc) { type = rc.BuiltinTypes.Bool }; } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { Arguments arguments = new Arguments(4); MemberAccess expr = new MemberAccess(new MemberAccess(new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", loc), "Linq", loc), "Expressions", loc); CSharpBinderFlags cSharpBinderFlags = (ec.HasSet(ResolveContext.Options.CheckedScope) ? CSharpBinderFlags.CheckedContext : CSharpBinderFlags.None); arguments.Add(new Argument(new BinderFlags(cSharpBinderFlags, this))); arguments.Add(new Argument(new MemberAccess(new MemberAccess(expr, "ExpressionType", loc), name, loc))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(args.CreateDynamicBinderArguments(ec), loc))); return new Invocation(GetBinder("UnaryOperation", loc), arguments); } } internal sealed class DynamicSiteClass : HoistedStoreyClass { public DynamicSiteClass(TypeDefinition parent, MemberBase host, TypeParameters tparams) : base(parent, CompilerGeneratedContainer.MakeMemberName(host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC, MemberKind.Class) { parent.DynamicSitesCounter++; } public FieldSpec CreateCallSiteField(FullNamedExpression type, Location loc) { Field field = new HoistedField(this, type, Modifiers.PUBLIC | Modifiers.STATIC, "Site" + AnonymousMethodsCounter++.ToString("X"), null, loc); field.Define(); AddField(field); return field.Spec; } } internal enum ExprClass : byte { Unresolved, Value, Variable, Namespace, Type, TypeParameter, MethodGroup, PropertyAccess, EventAccess, IndexerAccess, Nothing } [Flags] internal enum ResolveFlags { VariableOrValue = 1, Type = 2, MethodGroup = 4, TypeParameter = 8, MaskExprClass = 0xF } [Flags] internal enum AddressOp { Store = 1, Load = 2, LoadStore = 3 } internal interface IMemoryLocation { void AddressOf(EmitContext ec, AddressOp mode); } internal interface IVariableReference : IFixedExpression { bool IsHoisted { get; } string Name { get; } VariableInfo VariableInfo { get; } void SetHasAddressTaken(); } internal interface IFixedExpression { bool IsFixed { get; } } internal interface IExpressionCleanup { void EmitCleanup(EmitContext ec); } internal abstract class Expression { [Flags] public enum MemberLookupRestrictions { None = 0, InvocableOnly = 1, ExactArity = 4, ReadAccess = 8, EmptyArguments = 0x10, IgnoreArity = 0x20, IgnoreAmbiguity = 0x40, NameOfExcluded = 0x80, DontSetConditionalAccess = 0x100 } public ExprClass eclass; protected TypeSpec type; protected Location loc; public TypeSpec Type { get { return type; } set { type = value; } } public virtual bool IsSideEffectFree => false; public Location Location => loc; public virtual bool IsNull => false; public virtual Location StartLocation => loc; public ResolveFlags ExprClassToResolveFlags { get { switch (eclass) { case ExprClass.Namespace: case ExprClass.Type: return ResolveFlags.Type; case ExprClass.MethodGroup: return ResolveFlags.MethodGroup; case ExprClass.TypeParameter: return ResolveFlags.TypeParameter; case ExprClass.Value: case ExprClass.Variable: case ExprClass.PropertyAccess: case ExprClass.EventAccess: case ExprClass.IndexerAccess: return ResolveFlags.VariableOrValue; default: throw new InternalErrorException(loc.ToString() + " " + GetType()?.ToString() + " ExprClass is Invalid after resolve"); } } } public virtual string ExprClassName => eclass switch { ExprClass.Unresolved => "Unresolved", ExprClass.Value => "value", ExprClass.Variable => "variable", ExprClass.Namespace => "namespace", ExprClass.Type => "type", ExprClass.MethodGroup => "method group", ExprClass.PropertyAccess => "property access", ExprClass.EventAccess => "event access", ExprClass.IndexerAccess => "indexer access", ExprClass.Nothing => "null", ExprClass.TypeParameter => "type parameter", _ => throw new Exception("Should not happen"), }; public virtual MethodGroupExpr CanReduceLambda(AnonymousMethodBody body) { return null; } public virtual bool ContainsEmitWithAwait() { return false; } protected abstract Expression DoResolve(ResolveContext rc); public virtual Expression DoResolveLValue(ResolveContext rc, Expression right_side) { return null; } public virtual TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments = false) { ResolveContext resolveContext = (mc as ResolveContext) ?? new ResolveContext(mc); Resolve(resolveContext)?.Error_UnexpectedKind(resolveContext, ResolveFlags.Type, loc); return null; } protected void CheckExpressionVariable(ResolveContext rc) { if (rc.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer) && rc.CurrentAnonymousMethod == null) { rc.Report.Error(8200, loc, "Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers"); } else if (rc.HasSet(ResolveContext.Options.QueryClauseScope)) { rc.Report.Error(8201, loc, "Out variable and pattern variable declarations are not allowed within a query clause"); } } public static void ErrorIsInaccesible(IMemberContext rc, string member, Location loc) { rc.Module.Compiler.Report.Error(122, loc, "`{0}' is inaccessible due to its protection level", member); } public void Error_ExpressionMustBeConstant(ResolveContext rc, Location loc, string e_name) { rc.Report.Error(133, loc, "The expression being assigned to `{0}' must be a constant or default value", e_name); } public void Error_ConstantCanBeInitializedWithNullOnly(ResolveContext rc, TypeSpec type, Location loc, string name) { rc.Report.Error(134, loc, "A constant `{0}' of reference type `{1}' can only be initialized with null", name, type.GetSignatureForError()); } protected virtual void Error_InvalidExpressionStatement(Report report, Location loc) { report.Error(201, loc, "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement"); } public void Error_InvalidExpressionStatement(BlockContext bc) { Error_InvalidExpressionStatement(bc.Report, loc); } public void Error_InvalidExpressionStatement(Report report) { Error_InvalidExpressionStatement(report, loc); } public static void Error_VoidInvalidInTheContext(Location loc, Report Report) { Report.Error(1547, loc, "Keyword `void' cannot be used in this context"); } public virtual void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec target, bool expl) { Error_ValueCannotBeConvertedCore(ec, loc, target, expl); } protected void Error_ValueCannotBeConvertedCore(ResolveContext ec, Location loc, TypeSpec target, bool expl) { if (type == InternalType.AnonymousMethod || type == InternalType.ErrorType || target == InternalType.ErrorType || type.MemberDefinition.DeclaringAssembly.IsMissing || target.MemberDefinition.DeclaringAssembly.IsMissing) { return; } string text = type.GetSignatureForError(); if (type.Kind == MemberKind.ByRef) { text = "ref " + text; } string text2 = target.GetSignatureForError(); if (target.Kind == MemberKind.ByRef) { text2 = "ref " + text2; } if (text == text2) { text = type.GetSignatureForErrorIncludingAssemblyName(); text2 = target.GetSignatureForErrorIncludingAssemblyName(); } if (expl) { ec.Report.Error(30, loc, "Cannot convert type `{0}' to `{1}'", text, text2); return; } ec.Report.DisableReporting(); bool flag = Convert.ExplicitConversion(ec, this, target, Location.Null) != null; ec.Report.EnableReporting(); if (flag) { ec.Report.Error(266, loc, "Cannot implicitly convert type `{0}' to `{1}'. An explicit conversion exists (are you missing a cast?)", text, text2); } else { ec.Report.Error(29, loc, "Cannot implicitly convert type `{0}' to `{1}'", text, text2); } } public void Error_TypeArgumentsCannotBeUsed(IMemberContext context, MemberSpec member, Location loc) { if (member != null && (member.Kind & MemberKind.GenericMask) != 0) { Report report = context.Module.Compiler.Report; report.SymbolRelatedToPreviousError(member); member = ((!(member is TypeSpec)) ? ((MemberSpec)((MethodSpec)member).GetGenericMethodDefinition()) : ((MemberSpec)((TypeSpec)member).GetDefinition())); string text = ((member.Kind == MemberKind.Method) ? "method" : "type"); if (member.IsGeneric) { report.Error(305, loc, "Using the generic {0} `{1}' requires `{2}' type argument(s)", text, member.GetSignatureForError(), member.Arity.ToString()); } else { report.Error(308, loc, "The non-generic {0} `{1}' cannot be used with the type arguments", text, member.GetSignatureForError()); } } else { Error_TypeArgumentsCannotBeUsed(context, ExprClassName, GetSignatureForError(), loc); } } public static void Error_TypeArgumentsCannotBeUsed(IMemberContext context, string exprType, string name, Location loc) { context.Module.Compiler.Report.Error(307, loc, "The {0} `{1}' cannot be used with type arguments", exprType, name); } public virtual void Error_TypeDoesNotContainDefinition(ResolveContext ec, TypeSpec type, string name) { Error_TypeDoesNotContainDefinition(ec, loc, type, name); } public static void Error_TypeDoesNotContainDefinition(ResolveContext ec, Location loc, TypeSpec type, string name) { ec.Report.SymbolRelatedToPreviousError(type); ec.Report.Error(117, loc, "`{0}' does not contain a definition for `{1}'", type.GetSignatureForError(), name); } public virtual void Error_ValueAssignment(ResolveContext rc, Expression rhs) { if (rhs != EmptyExpression.LValueMemberAccess && rhs != EmptyExpression.LValueMemberOutAccess) { if (rhs == EmptyExpression.OutAccess) { rc.Report.Error(1510, loc, "A ref or out argument must be an assignable variable"); } else { rc.Report.Error(131, loc, "The left-hand side of an assignment must be a variable, a property or an indexer"); } } } protected void Error_VoidPointerOperation(ResolveContext rc) { rc.Report.Error(242, loc, "The operation in question is undefined on void pointers"); } public static void Warning_UnreachableExpression(ResolveContext rc, Location loc) { rc.Report.Warning(429, 4, loc, "Unreachable expression code detected"); } public Expression ProbeIdenticalTypeName(ResolveContext rc, Expression left, SimpleName name) { TypeSpec typeSpec = left.Type; if (typeSpec.Kind == MemberKind.InternalCompilerType || typeSpec is ElementTypeSpec || typeSpec.Arity > 0) { return left; } if ((left is MemberExpr || left is VariableReference) && rc.LookupNamespaceOrType(name.Name, 0, LookupMode.IgnoreAccessibility, loc) is TypeExpr typeExpr && typeExpr.Type == left.Type) { return typeExpr; } return left; } public virtual string GetSignatureForError() { return type.GetDefinition().GetSignatureForError(); } public static bool IsNeverNull(Expression expr) { if (expr is This || expr is New || expr is ArrayCreation || expr is DelegateCreation || expr is ConditionalMemberAccess) { return true; } if (expr is Constant constant) { return !constant.IsNull; } if (expr is TypeCast typeCast) { return IsNeverNull(typeCast.Child); } return false; } protected static bool IsNullPropagatingValid(TypeSpec type) { switch (type.Kind) { case MemberKind.Struct: return type.IsNullableType; case MemberKind.Enum: case MemberKind.PointerType: case MemberKind.Void: return false; case MemberKind.InternalCompilerType: return type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; case MemberKind.TypeParameter: return !((TypeParameterSpec)type).IsValueType; default: return true; } } public virtual bool HasConditionalAccess() { return false; } protected TypeSpec LiftMemberType(ResolveContext rc, TypeSpec type) { if (type is TypeParameterSpec { IsReferenceType: false, IsValueType: false }) { Error_OperatorCannotBeApplied(rc, loc, "?", type); } return (TypeSpec.IsValueType(type) && !type.IsNullableType) ? NullableInfo.MakeType(rc.Module, type) : type; } public Expression Resolve(ResolveContext ec, ResolveFlags flags) { if (eclass != ExprClass.Unresolved) { if ((flags & ExprClassToResolveFlags) == 0) { Error_UnexpectedKind(ec, flags, loc); return null; } return this; } try { Expression expression = DoResolve(ec); if (expression == null) { return null; } if ((flags & expression.ExprClassToResolveFlags) == 0) { expression.Error_UnexpectedKind(ec, flags, loc); return null; } if (expression.type == null) { throw new InternalErrorException("Expression `{0}' didn't set its type in DoResolve", expression.GetType()); } return expression; } catch (Exception ex) { if (loc.IsNull || ec.Module.Compiler.Settings.BreakOnInternalError || ex is CompletionResult || ec.Report.IsDisabled || ex is FatalException || ec.Report.Printer is NullReportPrinter) { throw; } ec.Report.Error(584, loc, "Internal compiler error: {0}", ex.Message); return ErrorExpression.Instance; } } public Expression Resolve(ResolveContext rc) { return Resolve(rc, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup); } public Expression ResolveLValue(ResolveContext ec, Expression right_side) { int errors = ec.Report.Errors; Expression expression = DoResolveLValue(ec, right_side); if (expression == null) { if (errors == ec.Report.Errors) { Error_ValueAssignment(ec, right_side); } return null; } if (expression.eclass == ExprClass.Unresolved) { throw new Exception("Expression " + expression?.ToString() + " ExprClass is Invalid after resolve"); } if (expression.type == null && !(expression is GenericTypeExpr)) { throw new Exception("Expression " + expression?.ToString() + " did not set its type after Resolve"); } return expression; } public Constant ResolveLabelConstant(ResolveContext rc) { Expression expression = Resolve(rc); if (expression == null) { return null; } if (!(expression is Constant result)) { if (expression.type != InternalType.ErrorType) { rc.Report.Error(150, expression.StartLocation, "A constant value is expected"); } return null; } return result; } public virtual void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { if (Attribute.IsValidArgumentType(parameterType)) { rc.Module.Compiler.Report.Error(182, loc, "An attribute argument must be a constant expression, typeof expression or array creation expression"); } else { rc.Module.Compiler.Report.Error(181, loc, "Attribute constructor parameter has type `{0}', which is not a valid attribute parameter type", targetType.GetSignatureForError()); } } public abstract void Emit(EmitContext ec); public virtual void EmitBranchable(EmitContext ec, Label target, bool on_true) { Emit(ec); ec.Emit(on_true ? OpCodes.Brtrue : OpCodes.Brfalse, target); } public virtual void EmitSideEffect(EmitContext ec) { Emit(ec); ec.Emit(OpCodes.Pop); } public virtual void EmitPrepare(EmitContext ec) { } public virtual Expression EmitToField(EmitContext ec) { if (IsSideEffectFree) { return this; } bool flag = ContainsEmitWithAwait(); if (!flag) { ec.EmitThis(); } FieldExpr fieldExpr = EmitToFieldSource(ec); if (fieldExpr == null) { fieldExpr = ec.GetTemporaryField(type); if (flag) { LocalBuilder temporaryLocal = ec.GetTemporaryLocal(type); ec.Emit(OpCodes.Stloc, temporaryLocal); ec.EmitThis(); ec.Emit(OpCodes.Ldloc, temporaryLocal); fieldExpr.EmitAssignFromStack(ec); ec.FreeTemporaryLocal(temporaryLocal, type); } else { fieldExpr.EmitAssignFromStack(ec); } } return fieldExpr; } protected virtual FieldExpr EmitToFieldSource(EmitContext ec) { Emit(ec); return null; } protected static void EmitExpressionsList(EmitContext ec, List expressions) { if (ec.HasSet(BuilderContext.Options.AsyncBody)) { bool flag = false; for (int i = 1; i < expressions.Count; i++) { if (expressions[i].ContainsEmitWithAwait()) { flag = true; break; } } if (flag) { for (int j = 0; j < expressions.Count; j++) { expressions[j] = expressions[j].EmitToField(ec); } } } for (int k = 0; k < expressions.Count; k++) { expressions[k].Emit(ec); } } private static Expression ExprClassFromMemberInfo(MemberSpec spec, Location loc) { if (spec is EventSpec) { return new EventExpr((EventSpec)spec, loc); } if (spec is ConstSpec) { return new ConstantExpr((ConstSpec)spec, loc); } if (spec is FieldSpec) { return new FieldExpr((FieldSpec)spec, loc); } if (spec is PropertySpec) { return new PropertyExpr((PropertySpec)spec, loc); } if (spec is TypeSpec) { return new TypeExpression((TypeSpec)spec, loc); } return null; } public static MethodSpec ConstructorLookup(ResolveContext rc, TypeSpec type, ref Arguments args, Location loc) { IList list = MemberCache.FindMembers(type, Constructor.ConstructorName, declaredOnlyClass: true); if (list == null) { switch (type.Kind) { case MemberKind.Struct: if (args == null) { return null; } rc.Report.SymbolRelatedToPreviousError(type); OverloadResolver.Error_ConstructorMismatch(rc, type, (args != null) ? args.Count : 0, loc); break; default: rc.Report.SymbolRelatedToPreviousError(type); rc.Report.Error(143, loc, "The class `{0}' has no constructors defined", type.GetSignatureForError()); break; case MemberKind.InternalCompilerType: case MemberKind.MissingType: break; } return null; } if (args == null && type.IsStruct) { bool flag = false; foreach (MethodSpec item in list) { if (item.Parameters.IsEmpty) { flag = true; } } if (!flag) { return null; } } OverloadResolver overloadResolver = new OverloadResolver(list, OverloadResolver.Restrictions.NoBaseMembers, loc); if (!rc.HasSet(ResolveContext.Options.BaseInitializer)) { overloadResolver.InstanceQualifier = new ConstructorInstanceQualifier(type); } return overloadResolver.ResolveMember(rc, ref args); } public static Expression MemberLookup(IMemberContext rc, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc) { IList list = MemberCache.FindMembers(queried_type, name, declaredOnlyClass: false); if (list != null) { do { Expression expression = MemberLookupToExpression(rc, list, errorMode, queried_type, name, arity, restrictions, loc); if (expression != null) { return expression; } list = ((list[0].DeclaringType.BaseType != null) ? MemberCache.FindMembers(list[0].DeclaringType.BaseType, name, declaredOnlyClass: false) : null); } while (list != null); } if (queried_type is TypeParameterSpec typeParameter) { list = MemberCache.FindInterfaceMembers(typeParameter, name); if (list != null) { return MemberLookupToExpression(rc, list, errorMode, queried_type, name, arity, restrictions, loc); } } if ((restrictions & MemberLookupRestrictions.InvocableOnly) == 0 && queried_type is NamedTupleSpec namedTupleSpec) { MemberSpec memberSpec = namedTupleSpec.FindElement(rc, name, loc); if (memberSpec != null) { return ExprClassFromMemberInfo(memberSpec, loc); } } return null; } public static Expression MemberLookupToExpression(IMemberContext rc, IList members, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc) { MemberSpec memberSpec = null; MemberSpec memberSpec2 = null; for (int i = 0; i < members.Count; i++) { MemberSpec memberSpec3 = members[i]; if (((memberSpec3.Modifiers & Modifiers.OVERRIDE) != 0 && memberSpec3.Kind != MemberKind.Event) || (memberSpec3.Modifiers & Modifiers.BACKING_FIELD) != 0 || memberSpec3.Kind == MemberKind.Operator || ((arity > 0 || (restrictions & MemberLookupRestrictions.ExactArity) != MemberLookupRestrictions.None) && memberSpec3.Arity != arity) || (!errorMode && (!memberSpec3.IsAccessible(rc) || (rc.Module.Compiler.IsRuntimeBinder && !memberSpec3.DeclaringType.IsAccessible(rc))))) { continue; } if ((restrictions & MemberLookupRestrictions.InvocableOnly) != MemberLookupRestrictions.None) { if (memberSpec3 is MethodSpec) { return new MethodGroupExpr(members, queried_type, loc); } if (!Invocation.IsMemberInvocable(memberSpec3)) { continue; } } if (memberSpec == null || memberSpec3 is MethodSpec || memberSpec.IsNotCSharpCompatible) { memberSpec = memberSpec3; } else { if (errorMode || memberSpec3.IsNotCSharpCompatible) { continue; } if (queried_type is TypeParameterSpec { HasTypeConstraint: not false }) { if (memberSpec.DeclaringType.IsClass && memberSpec3.DeclaringType.IsInterface) { continue; } if (memberSpec.DeclaringType.IsInterface && memberSpec3.DeclaringType.IsInterface) { memberSpec = memberSpec3; continue; } } memberSpec2 = memberSpec3; } } if (memberSpec != null) { if (memberSpec2 != null && rc != null && (restrictions & MemberLookupRestrictions.IgnoreAmbiguity) == 0) { Report report = rc.Module.Compiler.Report; report.SymbolRelatedToPreviousError(memberSpec); report.SymbolRelatedToPreviousError(memberSpec2); report.Error(229, loc, "Ambiguity between `{0}' and `{1}'", memberSpec.GetSignatureForError(), memberSpec2.GetSignatureForError()); } if (memberSpec is MethodSpec) { return new MethodGroupExpr(members, queried_type, loc); } return ExprClassFromMemberInfo(memberSpec, loc); } return null; } protected static void Error_NamedArgument(NamedArgument na, Report Report) { Report.Error(1742, na.Location, "An element access expression cannot use named argument"); } protected virtual void Error_NegativeArrayIndex(ResolveContext ec, Location loc) { throw new NotImplementedException(); } public virtual void Error_OperatorCannotBeApplied(ResolveContext rc, Location loc, string oper, TypeSpec t) { if (t != InternalType.ErrorType) { rc.Report.Error(23, loc, "The `{0}' operator cannot be applied to operand of type `{1}'", oper, t.GetSignatureForError()); } } protected void Error_PointerInsideExpressionTree(ResolveContext ec) { ec.Report.Error(1944, loc, "An expression tree cannot contain an unsafe pointer operation"); } protected void Error_NullShortCircuitInsideExpressionTree(ResolveContext rc) { rc.Report.Error(8072, loc, "An expression tree cannot contain a null propagating operator"); } protected void Error_NullPropagatingLValue(ResolveContext rc) { rc.Report.Error(-1030, loc, "The left-hand side of an assignment cannot contain a null propagating operator"); } public virtual void FlowAnalysis(FlowAnalysisContext fc) { } public virtual Reachability MarkReachable(Reachability rc) { return rc; } public virtual void FlowAnalysisConditional(FlowAnalysisContext fc) { FlowAnalysis(fc); DefiniteAssignmentBitSet definiteAssignmentOnTrue = (fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment); fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue; } protected static Expression GetOperatorTrue(ResolveContext ec, Expression e, Location loc) { return GetOperatorTrueOrFalse(ec, e, is_true: true, loc); } protected static Expression GetOperatorFalse(ResolveContext ec, Expression e, Location loc) { return GetOperatorTrueOrFalse(ec, e, is_true: false, loc); } private static Expression GetOperatorTrueOrFalse(ResolveContext ec, Expression e, bool is_true, Location loc) { Operator.OpType op = (is_true ? Operator.OpType.True : Operator.OpType.False); TypeSpec underlyingType = e.type; if (underlyingType.IsNullableType) { underlyingType = NullableInfo.GetUnderlyingType(underlyingType); } IList userOperator = MemberCache.GetUserOperator(underlyingType, op, declaredOnly: false); if (userOperator == null) { return null; } Arguments args = new Arguments(1); args.Add(new Argument(e)); MethodSpec methodSpec = new OverloadResolver(userOperator, OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded, loc).ResolveOperator(ec, ref args); if (methodSpec == null) { return null; } return new UserOperatorCall(methodSpec, args, null, loc); } public static void Error_UnexpectedKind(IMemberContext ctx, Expression memberExpr, string expected, string was, Location loc) { string signatureForError = memberExpr.GetSignatureForError(); ctx.Module.Compiler.Report.Error(118, loc, "`{0}' is a `{1}' but a `{2}' was expected", signatureForError, was, expected); } public virtual void Error_UnexpectedKind(ResolveContext ec, ResolveFlags flags, Location loc) { string[] array = new string[4]; int num = 0; if ((flags & ResolveFlags.VariableOrValue) != 0) { array[num++] = "variable"; array[num++] = "value"; } if ((flags & ResolveFlags.Type) != 0) { array[num++] = "type"; } if ((flags & ResolveFlags.MethodGroup) != 0) { array[num++] = "method group"; } if (num == 0) { array[num++] = "unknown"; } StringBuilder stringBuilder = new StringBuilder(array[0]); for (int i = 1; i < num - 1; i++) { stringBuilder.Append("', `"); stringBuilder.Append(array[i]); } if (num > 1) { stringBuilder.Append("' or `"); stringBuilder.Append(array[num - 1]); } ec.Report.Error(119, loc, "Expression denotes a `{0}', where a `{1}' was expected", ExprClassName, stringBuilder.ToString()); } public static void UnsafeError(ResolveContext ec, Location loc) { UnsafeError(ec.Report, loc); } public static void UnsafeError(Report Report, Location loc) { Report.Error(214, loc, "Pointers and fixed size buffers may only be used in an unsafe context"); } public static void UnsafeInsideIteratorError(ResolveContext rc, Location loc) { UnsafeInsideIteratorError(rc.Report, loc); } public static void UnsafeInsideIteratorError(Report report, Location loc) { report.Error(1629, loc, "Unsafe code may not appear in iterators"); } protected Expression ConvertExpressionToArrayIndex(ResolveContext ec, Expression source, bool pointerArray = false) { BuiltinTypes builtinTypes = ec.BuiltinTypes; if (source.type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(source)); return new DynamicConversion(builtinTypes.Int, CSharpBinderFlags.ConvertArrayIndex, arguments, source.loc).Resolve(ec); } Expression expression; using (ec.Set(ResolveContext.Options.CheckedScope)) { expression = Convert.ImplicitConversion(ec, source, builtinTypes.Int, source.loc); if (expression == null) { expression = Convert.ImplicitConversion(ec, source, builtinTypes.UInt, source.loc); } if (expression == null) { expression = Convert.ImplicitConversion(ec, source, builtinTypes.Long, source.loc); } if (expression == null) { expression = Convert.ImplicitConversion(ec, source, builtinTypes.ULong, source.loc); } if (expression == null) { source.Error_ValueCannotBeConverted(ec, builtinTypes.Int, expl: false); return null; } } if (pointerArray) { return expression; } if (expression is Constant { IsNegative: not false }) { Error_NegativeArrayIndex(ec, source.loc); } if (expression.Type.BuiltinType == BuiltinTypeSpec.Type.Int) { return expression; } return new ArrayIndexCast(expression, builtinTypes.Int).Resolve(ec); } public Expression MakePointerAccess(ResolveContext rc, TypeSpec type, Arguments args) { if (args.Count != 1) { rc.Report.Error(196, loc, "A pointer must be indexed by only one value"); return null; } Argument argument = args[0]; if (argument is NamedArgument) { Error_NamedArgument((NamedArgument)argument, rc.Report); } Expression expression = argument.Expr.Resolve(rc); if (expression == null) { return null; } expression = ConvertExpressionToArrayIndex(rc, expression, pointerArray: true); Expression expr = new PointerArithmetic(Binary.Operator.Addition, this, expression, type, loc); return new Indirection(expr, loc); } protected virtual void CloneTo(CloneContext clonectx, Expression target) { throw new NotImplementedException($"CloneTo not implemented for expression {GetType()}"); } public virtual Expression Clone(CloneContext clonectx) { Expression expression = (Expression)MemberwiseClone(); CloneTo(clonectx, expression); return expression; } public abstract Expression CreateExpressionTree(ResolveContext ec); protected Expression CreateExpressionFactoryCall(ResolveContext ec, string name, Arguments args) { return CreateExpressionFactoryCall(ec, name, null, args, loc); } protected Expression CreateExpressionFactoryCall(ResolveContext ec, string name, TypeArguments typeArguments, Arguments args) { return CreateExpressionFactoryCall(ec, name, typeArguments, args, loc); } public static Expression CreateExpressionFactoryCall(ResolveContext ec, string name, TypeArguments typeArguments, Arguments args, Location loc) { return new Invocation(new MemberAccess(CreateExpressionTypeExpression(ec, loc), name, typeArguments, loc), args); } protected static TypeExpr CreateExpressionTypeExpression(ResolveContext ec, Location loc) { TypeSpec typeSpec = ec.Module.PredefinedTypes.Expression.Resolve(); if (typeSpec == null) { return null; } return new TypeExpression(typeSpec, loc); } public virtual System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { throw new NotImplementedException("MakeExpression for " + GetType()); } public virtual object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class ExpressionStatement : Expression { public virtual ExpressionStatement ResolveStatement(BlockContext ec) { Expression expression = Resolve(ec); if (expression == null) { return null; } ExpressionStatement expressionStatement = expression as ExpressionStatement; if (expressionStatement == null || expression is AnonymousMethodBody) { if (expression is IReducedExpressionStatement) { return EmptyExpressionStatement.Instance; } Error_InvalidExpressionStatement(ec); } if (MemberAccess.IsValidDotExpression(expression.Type) && !(expression is Assign) && !(expression is Await)) { WarningAsyncWithoutWait(ec, expression); } return expressionStatement; } private static void WarningAsyncWithoutWait(BlockContext bc, Expression e) { if (bc.CurrentAnonymousMethod is AsyncInitializer) { AwaitStatement.AwaitableMemberAccess awaitableMemberAccess = new AwaitStatement.AwaitableMemberAccess(e) { ProbingMode = true }; if (!(awaitableMemberAccess.Resolve(bc) is MethodGroupExpr methodGroupExpr)) { return; } Arguments args = new Arguments(0); MethodGroupExpr methodGroupExpr2 = methodGroupExpr.OverloadResolve(bc, ref args, null, OverloadResolver.Restrictions.ProbingOnly); if (methodGroupExpr2 != null) { AwaiterDefinition awaiter = bc.Module.GetAwaiter(methodGroupExpr2.BestCandidateReturnType); if (awaiter.IsValidPattern && awaiter.INotifyCompletion) { bc.Report.Warning(4014, 1, e.Location, "The statement is not awaited and execution of current method continues before the call is completed. Consider using `await' operator"); } } } else if (e is Invocation { MethodGroup: not null } invocation && invocation.MethodGroup.BestCandidate.IsAsync) { bc.Report.Warning(4014, 1, e.Location, "The statement is not awaited and execution of current method continues before the call is completed. Consider using `await' operator or calling `Wait' method"); } } public abstract void EmitStatement(EmitContext ec); public override void EmitSideEffect(EmitContext ec) { EmitStatement(ec); } } internal interface IReducedExpressionStatement { } internal abstract class TypeCast : Expression { protected readonly Expression child; public Expression Child => child; public override bool IsNull => child.IsNull; protected TypeCast(Expression child, TypeSpec return_type) { eclass = child.eclass; loc = child.Location; type = return_type; this.child = child; } public override bool ContainsEmitWithAwait() { return child.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(child.CreateExpressionTree(ec))); arguments.Add(new Argument(new TypeOf(type, loc))); if (type.IsPointer || child.Type.IsPointer) { Error_PointerInsideExpressionTree(ec); } return CreateExpressionFactoryCall(ec, ec.HasSet(ResolveContext.Options.CheckedScope) ? "ConvertChecked" : "Convert", arguments); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { child.Emit(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { child.FlowAnalysis(fc); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return ctx.HasSet(BuilderContext.Options.CheckedScope) ? System.Linq.Expressions.Expression.ConvertChecked(child.MakeExpression(ctx), type.GetMetaInfo()) : System.Linq.Expressions.Expression.Convert(child.MakeExpression(ctx), type.GetMetaInfo()); } public override Reachability MarkReachable(Reachability rc) { return child.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Expression t) { } } internal class EmptyCast : TypeCast { private EmptyCast(Expression child, TypeSpec target_type) : base(child, target_type) { } public static Expression Create(Expression child, TypeSpec type) { Constant constant = child as Constant; if (constant != null) { if (constant is EnumConstant enumConstant) { constant = enumConstant.Child; } if (!(constant is ReducedExpression.ReducedConstantExpression)) { if (constant.Type == type) { return constant; } Constant constant2 = constant.ConvertImplicitly(type); if (constant2 != null) { return constant2; } } } if (child is EmptyCast emptyCast) { return new EmptyCast(emptyCast.child, type); } return new EmptyCast(child, type); } public override void EmitBranchable(EmitContext ec, Label label, bool on_true) { child.EmitBranchable(ec, label, on_true); } public override void EmitSideEffect(EmitContext ec) { child.EmitSideEffect(ec); } } internal class OperatorCast : TypeCast { private readonly MethodSpec conversion_operator; public OperatorCast(Expression expr, TypeSpec target_type) : this(expr, target_type, target_type, isExplicit: false) { } public OperatorCast(Expression expr, TypeSpec target_type, bool find_explicit) : this(expr, target_type, target_type, find_explicit) { } public OperatorCast(Expression expr, TypeSpec declaringType, TypeSpec returnType, bool isExplicit) : base(expr, returnType) { IList userOperator = MemberCache.GetUserOperator(declaringType, isExplicit ? Operator.OpType.Explicit : Operator.OpType.Implicit, declaredOnly: true); if (userOperator != null) { foreach (MethodSpec item in userOperator) { if (item.ReturnType != returnType || item.Parameters.Types[0] != expr.Type) { continue; } conversion_operator = item; return; } } throw new InternalErrorException("Missing predefined user operator between `{0}' and `{1}'", returnType.GetSignatureForError(), expr.Type.GetSignatureForError()); } public override void Emit(EmitContext ec) { child.Emit(ec); ec.Emit(OpCodes.Call, conversion_operator); } } internal class EmptyConstantCast : Constant { public readonly Constant child; public override bool IsDefaultValue => child.IsDefaultValue; public override bool IsNegative => child.IsNegative; public override bool IsNull => child.IsNull; public override bool IsOneInteger => child.IsOneInteger; public override bool IsSideEffectFree => child.IsSideEffectFree; public override bool IsZeroInteger => child.IsZeroInteger; public EmptyConstantCast(Constant child, TypeSpec type) : base(child.Location) { if (child == null) { throw new ArgumentNullException("child"); } this.child = child; eclass = child.eclass; base.type = type; } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { if (child.Type == target_type) { return child; } return child.ConvertExplicitly(in_checked_context, target_type); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments args = Arguments.CreateForExpressionTree(ec, null, child.CreateExpressionTree(ec), new TypeOf(type, loc)); if (type.IsPointer) { Error_PointerInsideExpressionTree(ec); } return CreateExpressionFactoryCall(ec, "Convert", args); } public override void Emit(EmitContext ec) { child.Emit(ec); } public override void EmitBranchable(EmitContext ec, Label label, bool on_true) { child.EmitBranchable(ec, label, on_true); if (TypeManager.IsGenericParameter(type) && child.IsNull) { ec.Emit(OpCodes.Unbox_Any, type); } } public override void EmitSideEffect(EmitContext ec) { child.EmitSideEffect(ec); } public override object GetValue() { return child.GetValue(); } public override string GetValueAsLiteral() { return child.GetValueAsLiteral(); } public override long GetValueAsLong() { return child.GetValueAsLong(); } public override Constant ConvertImplicitly(TypeSpec target_type) { if (type == target_type) { return this; } if (!Convert.ImplicitStandardConversionExists(this, target_type)) { return null; } return child.ConvertImplicitly(target_type); } } internal class EnumConstant : Constant { public Constant Child; public override bool IsDefaultValue => Child.IsDefaultValue; public override bool IsSideEffectFree => Child.IsSideEffectFree; public override bool IsZeroInteger => Child.IsZeroInteger; public override bool IsNegative => Child.IsNegative; public EnumConstant(Constant child, TypeSpec enum_type) : base(child.Location) { Child = child; eclass = ExprClass.Value; type = enum_type; } protected EnumConstant(Location loc) : base(loc) { } public override void Emit(EmitContext ec) { Child.Emit(ec); } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { Child.EncodeAttributeValue(rc, enc, Child.Type, parameterType); } public override void EmitBranchable(EmitContext ec, Label label, bool on_true) { Child.EmitBranchable(ec, label, on_true); } public override void EmitSideEffect(EmitContext ec) { Child.EmitSideEffect(ec); } public override string GetSignatureForError() { return base.Type.GetSignatureForError(); } public override object GetValue() { return Child.GetValue(); } public override object GetTypedValue() { return System.Enum.ToObject(type.GetMetaInfo(), Child.GetValue()); } public override string GetValueAsLiteral() { return Child.GetValueAsLiteral(); } public override long GetValueAsLong() { return Child.GetValueAsLong(); } public EnumConstant Increment() { return new EnumConstant(((IntegralConstant)Child).Increment(), type); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { if (Child.Type == target_type) { return Child; } return Child.ConvertExplicitly(in_checked_context, target_type); } public override Constant ConvertImplicitly(TypeSpec type) { if (base.type == type) { return this; } if (!Convert.ImplicitStandardConversionExists(this, type)) { return null; } return Child.ConvertImplicitly(type); } } internal class BoxedCast : TypeCast { public BoxedCast(Expression expr, TypeSpec target_type) : base(expr, target_type) { eclass = ExprClass.Value; } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { if (targetType.BuiltinType != BuiltinTypeSpec.Type.Object) { base.EncodeAttributeValue(rc, enc, targetType, parameterType); return; } enc.Encode(child.Type); child.EncodeAttributeValue(rc, enc, child.Type, parameterType); } public override void Emit(EmitContext ec) { base.Emit(ec); ec.Emit(OpCodes.Box, child.Type); } public override void EmitSideEffect(EmitContext ec) { if (child.Type.IsStruct && (type.BuiltinType == BuiltinTypeSpec.Type.Object || type.BuiltinType == BuiltinTypeSpec.Type.ValueType)) { child.EmitSideEffect(ec); } else { base.EmitSideEffect(ec); } } } internal class UnboxCast : TypeCast { public UnboxCast(Expression expr, TypeSpec return_type) : base(expr, return_type) { } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { base.Emit(ec); ec.Emit(OpCodes.Unbox_Any, type); } } internal class ConvCast : TypeCast { public enum Mode : byte { I1_U1, I1_U2, I1_U4, I1_U8, I1_CH, U1_I1, U1_CH, I2_I1, I2_U1, I2_U2, I2_U4, I2_U8, I2_CH, U2_I1, U2_U1, U2_I2, U2_CH, I4_I1, I4_U1, I4_I2, I4_U2, I4_U4, I4_U8, I4_CH, U4_I1, U4_U1, U4_I2, U4_U2, U4_I4, U4_CH, I8_I1, I8_U1, I8_I2, I8_U2, I8_I4, I8_U4, I8_U8, I8_CH, I8_I, U8_I1, U8_U1, U8_I2, U8_U2, U8_I4, U8_U4, U8_I8, U8_CH, U8_I, CH_I1, CH_U1, CH_I2, R4_I1, R4_U1, R4_I2, R4_U2, R4_I4, R4_U4, R4_I8, R4_U8, R4_CH, R8_I1, R8_U1, R8_I2, R8_U2, R8_I4, R8_U4, R8_I8, R8_U8, R8_CH, R8_R4, I_I8 } private Mode mode; public ConvCast(Expression child, TypeSpec return_type, Mode m) : base(child, return_type) { mode = m; } protected override Expression DoResolve(ResolveContext ec) { return this; } public override string ToString() { return $"ConvCast ({mode}, {child})"; } public override void Emit(EmitContext ec) { base.Emit(ec); Emit(ec, mode); } public static void Emit(EmitContext ec, Mode mode) { if (ec.HasSet(BuilderContext.Options.CheckedScope)) { switch (mode) { case Mode.I1_U1: ec.Emit(OpCodes.Conv_Ovf_U1); break; case Mode.I1_U2: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.I1_U4: ec.Emit(OpCodes.Conv_Ovf_U4); break; case Mode.I1_U8: ec.Emit(OpCodes.Conv_Ovf_U8); break; case Mode.I1_CH: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.U1_I1: ec.Emit(OpCodes.Conv_Ovf_I1_Un); break; case Mode.U1_CH: break; case Mode.I2_I1: ec.Emit(OpCodes.Conv_Ovf_I1); break; case Mode.I2_U1: ec.Emit(OpCodes.Conv_Ovf_U1); break; case Mode.I2_U2: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.I2_U4: ec.Emit(OpCodes.Conv_Ovf_U4); break; case Mode.I2_U8: ec.Emit(OpCodes.Conv_Ovf_U8); break; case Mode.I2_CH: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.U2_I1: ec.Emit(OpCodes.Conv_Ovf_I1_Un); break; case Mode.U2_U1: ec.Emit(OpCodes.Conv_Ovf_U1_Un); break; case Mode.U2_I2: ec.Emit(OpCodes.Conv_Ovf_I2_Un); break; case Mode.U2_CH: break; case Mode.I4_I1: ec.Emit(OpCodes.Conv_Ovf_I1); break; case Mode.I4_U1: ec.Emit(OpCodes.Conv_Ovf_U1); break; case Mode.I4_I2: ec.Emit(OpCodes.Conv_Ovf_I2); break; case Mode.I4_U4: ec.Emit(OpCodes.Conv_Ovf_U4); break; case Mode.I4_U2: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.I4_U8: ec.Emit(OpCodes.Conv_Ovf_U8); break; case Mode.I4_CH: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.U4_I1: ec.Emit(OpCodes.Conv_Ovf_I1_Un); break; case Mode.U4_U1: ec.Emit(OpCodes.Conv_Ovf_U1_Un); break; case Mode.U4_I2: ec.Emit(OpCodes.Conv_Ovf_I2_Un); break; case Mode.U4_U2: ec.Emit(OpCodes.Conv_Ovf_U2_Un); break; case Mode.U4_I4: ec.Emit(OpCodes.Conv_Ovf_I4_Un); break; case Mode.U4_CH: ec.Emit(OpCodes.Conv_Ovf_U2_Un); break; case Mode.I8_I1: ec.Emit(OpCodes.Conv_Ovf_I1); break; case Mode.I8_U1: ec.Emit(OpCodes.Conv_Ovf_U1); break; case Mode.I8_I2: ec.Emit(OpCodes.Conv_Ovf_I2); break; case Mode.I8_U2: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.I8_I4: ec.Emit(OpCodes.Conv_Ovf_I4); break; case Mode.I8_U4: ec.Emit(OpCodes.Conv_Ovf_U4); break; case Mode.I8_U8: ec.Emit(OpCodes.Conv_Ovf_U8); break; case Mode.I8_CH: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.I8_I: ec.Emit(OpCodes.Conv_Ovf_U); break; case Mode.U8_I1: ec.Emit(OpCodes.Conv_Ovf_I1_Un); break; case Mode.U8_U1: ec.Emit(OpCodes.Conv_Ovf_U1_Un); break; case Mode.U8_I2: ec.Emit(OpCodes.Conv_Ovf_I2_Un); break; case Mode.U8_U2: ec.Emit(OpCodes.Conv_Ovf_U2_Un); break; case Mode.U8_I4: ec.Emit(OpCodes.Conv_Ovf_I4_Un); break; case Mode.U8_U4: ec.Emit(OpCodes.Conv_Ovf_U4_Un); break; case Mode.U8_I8: ec.Emit(OpCodes.Conv_Ovf_I8_Un); break; case Mode.U8_CH: ec.Emit(OpCodes.Conv_Ovf_U2_Un); break; case Mode.U8_I: ec.Emit(OpCodes.Conv_Ovf_U_Un); break; case Mode.CH_I1: ec.Emit(OpCodes.Conv_Ovf_I1_Un); break; case Mode.CH_U1: ec.Emit(OpCodes.Conv_Ovf_U1_Un); break; case Mode.CH_I2: ec.Emit(OpCodes.Conv_Ovf_I2_Un); break; case Mode.R4_I1: ec.Emit(OpCodes.Conv_Ovf_I1); break; case Mode.R4_U1: ec.Emit(OpCodes.Conv_Ovf_U1); break; case Mode.R4_I2: ec.Emit(OpCodes.Conv_Ovf_I2); break; case Mode.R4_U2: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.R4_I4: ec.Emit(OpCodes.Conv_Ovf_I4); break; case Mode.R4_U4: ec.Emit(OpCodes.Conv_Ovf_U4); break; case Mode.R4_I8: ec.Emit(OpCodes.Conv_Ovf_I8); break; case Mode.R4_U8: ec.Emit(OpCodes.Conv_Ovf_U8); break; case Mode.R4_CH: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.R8_I1: ec.Emit(OpCodes.Conv_Ovf_I1); break; case Mode.R8_U1: ec.Emit(OpCodes.Conv_Ovf_U1); break; case Mode.R8_I2: ec.Emit(OpCodes.Conv_Ovf_I2); break; case Mode.R8_U2: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.R8_I4: ec.Emit(OpCodes.Conv_Ovf_I4); break; case Mode.R8_U4: ec.Emit(OpCodes.Conv_Ovf_U4); break; case Mode.R8_I8: ec.Emit(OpCodes.Conv_Ovf_I8); break; case Mode.R8_U8: ec.Emit(OpCodes.Conv_Ovf_U8); break; case Mode.R8_CH: ec.Emit(OpCodes.Conv_Ovf_U2); break; case Mode.R8_R4: ec.Emit(OpCodes.Conv_R4); break; case Mode.I_I8: ec.Emit(OpCodes.Conv_Ovf_I8_Un); break; } } else { switch (mode) { case Mode.I1_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.I1_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.I1_U4: ec.Emit(OpCodes.Conv_U4); break; case Mode.I1_U8: ec.Emit(OpCodes.Conv_I8); break; case Mode.I1_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.U1_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.U1_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.I2_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.I2_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.I2_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.I2_U4: ec.Emit(OpCodes.Conv_U4); break; case Mode.I2_U8: ec.Emit(OpCodes.Conv_I8); break; case Mode.I2_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.U2_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.U2_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.U2_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.U2_CH: break; case Mode.I4_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.I4_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.I4_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.I4_U4: break; case Mode.I4_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.I4_U8: ec.Emit(OpCodes.Conv_I8); break; case Mode.I4_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.U4_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.U4_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.U4_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.U4_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.U4_I4: break; case Mode.U4_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.I8_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.I8_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.I8_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.I8_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.I8_I4: ec.Emit(OpCodes.Conv_I4); break; case Mode.I8_U4: ec.Emit(OpCodes.Conv_U4); break; case Mode.I8_U8: break; case Mode.I8_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.I8_I: ec.Emit(OpCodes.Conv_U); break; case Mode.U8_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.U8_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.U8_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.U8_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.U8_I4: ec.Emit(OpCodes.Conv_I4); break; case Mode.U8_U4: ec.Emit(OpCodes.Conv_U4); break; case Mode.U8_I8: break; case Mode.U8_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.U8_I: ec.Emit(OpCodes.Conv_U); break; case Mode.CH_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.CH_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.CH_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.R4_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.R4_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.R4_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.R4_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.R4_I4: ec.Emit(OpCodes.Conv_I4); break; case Mode.R4_U4: ec.Emit(OpCodes.Conv_U4); break; case Mode.R4_I8: ec.Emit(OpCodes.Conv_I8); break; case Mode.R4_U8: ec.Emit(OpCodes.Conv_U8); break; case Mode.R4_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.R8_I1: ec.Emit(OpCodes.Conv_I1); break; case Mode.R8_U1: ec.Emit(OpCodes.Conv_U1); break; case Mode.R8_I2: ec.Emit(OpCodes.Conv_I2); break; case Mode.R8_U2: ec.Emit(OpCodes.Conv_U2); break; case Mode.R8_I4: ec.Emit(OpCodes.Conv_I4); break; case Mode.R8_U4: ec.Emit(OpCodes.Conv_U4); break; case Mode.R8_I8: ec.Emit(OpCodes.Conv_I8); break; case Mode.R8_U8: ec.Emit(OpCodes.Conv_U8); break; case Mode.R8_CH: ec.Emit(OpCodes.Conv_U2); break; case Mode.R8_R4: ec.Emit(OpCodes.Conv_R4); break; case Mode.I_I8: ec.Emit(OpCodes.Conv_U8); break; } } } } internal class OpcodeCast : TypeCast { private readonly OpCode op; public TypeSpec UnderlyingType => child.Type; public OpcodeCast(Expression child, TypeSpec return_type, OpCode op) : base(child, return_type) { this.op = op; } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { base.Emit(ec); ec.Emit(op); } } internal class OpcodeCastDuplex : OpcodeCast { private readonly OpCode second; public OpcodeCastDuplex(Expression child, TypeSpec returnType, OpCode first, OpCode second) : base(child, returnType, first) { this.second = second; } public override void Emit(EmitContext ec) { base.Emit(ec); ec.Emit(second); } } internal sealed class ClassCast : TypeCast { private readonly bool forced; public ClassCast(Expression child, TypeSpec return_type) : base(child, return_type) { } public ClassCast(Expression child, TypeSpec return_type, bool forced) : base(child, return_type) { this.forced = forced; } public override void Emit(EmitContext ec) { base.Emit(ec); bool flag = TypeManager.IsGenericParameter(child.Type); if (flag) { ec.Emit(OpCodes.Box, child.Type); } if (type.IsGenericParameter) { ec.Emit(OpCodes.Unbox_Any, type); } else if (!flag || forced) { ec.Emit(OpCodes.Castclass, type); } } } internal class ReducedExpression : Expression { public class ReducedConstantExpression : EmptyConstantCast { private readonly Expression orig_expr; public Expression OriginalExpression => orig_expr; public ReducedConstantExpression(Constant expr, Expression orig_expr) : base(expr, expr.Type) { this.orig_expr = orig_expr; } public override Constant ConvertImplicitly(TypeSpec target_type) { Constant constant = base.ConvertImplicitly(target_type); if (constant != null) { constant = new ReducedConstantExpression(constant, orig_expr); } return constant; } public override Expression CreateExpressionTree(ResolveContext ec) { return orig_expr.CreateExpressionTree(ec); } public override Constant ConvertExplicitly(bool in_checked_context, TypeSpec target_type) { Constant constant = base.ConvertExplicitly(in_checked_context, target_type); if (constant != null) { constant = new ReducedConstantExpression(constant, orig_expr); } return constant; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { if (orig_expr is Conditional) { child.EncodeAttributeValue(rc, enc, targetType, parameterType); } else { base.EncodeAttributeValue(rc, enc, targetType, parameterType); } } } private sealed class ReducedConstantStatement : ReducedConstantExpression, IReducedExpressionStatement { public ReducedConstantStatement(Constant expr, Expression origExpr) : base(expr, origExpr) { } } private sealed class ReducedExpressionStatement : ExpressionStatement { private readonly Expression orig_expr; private readonly ExpressionStatement stm; public ReducedExpressionStatement(ExpressionStatement stm, Expression orig) { orig_expr = orig; this.stm = stm; eclass = stm.eclass; type = stm.Type; loc = orig.Location; } public override bool ContainsEmitWithAwait() { return stm.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { return orig_expr.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { stm.Emit(ec); } public override void EmitStatement(EmitContext ec) { stm.EmitStatement(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { stm.FlowAnalysis(fc); } } private readonly Expression expr; private readonly Expression orig_expr; public override bool IsSideEffectFree => expr.IsSideEffectFree; public Expression OriginalExpression => orig_expr; private ReducedExpression(Expression expr, Expression orig_expr) { this.expr = expr; eclass = expr.eclass; type = expr.Type; this.orig_expr = orig_expr; loc = orig_expr.Location; } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } public static Constant Create(Constant expr, Expression originalExpr) { if (expr.eclass == ExprClass.Unresolved) { throw new ArgumentException("Unresolved expression"); } if (originalExpr is ExpressionStatement) { return new ReducedConstantStatement(expr, originalExpr); } return new ReducedConstantExpression(expr, originalExpr); } public static ExpressionStatement Create(ExpressionStatement s, Expression orig) { return new ReducedExpressionStatement(s, orig); } public static Expression Create(Expression expr, Expression original_expr) { return Create(expr, original_expr, canBeConstant: true); } public static Expression Create(Expression expr, Expression original_expr, bool canBeConstant) { if (canBeConstant && expr is Constant constant) { return Create(constant, original_expr); } if (expr is ExpressionStatement s) { return Create(s, original_expr); } if (expr.eclass == ExprClass.Unresolved) { throw new ArgumentException("Unresolved expression"); } return new ReducedExpression(expr, original_expr); } public override Expression CreateExpressionTree(ResolveContext ec) { return orig_expr.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { expr.Emit(ec); } public override Expression EmitToField(EmitContext ec) { return expr.EmitToField(ec); } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { expr.EmitBranchable(ec, target, on_true); } public override void FlowAnalysis(FlowAnalysisContext fc) { orig_expr.FlowAnalysis(fc); } public override void FlowAnalysisConditional(FlowAnalysisContext fc) { orig_expr.FlowAnalysisConditional(fc); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return orig_expr.MakeExpression(ctx); } public override Reachability MarkReachable(Reachability rc) { return expr.MarkReachable(rc); } } internal abstract class CompositeExpression : Expression { protected Expression expr; public Expression Child => expr; public override bool IsNull => expr.IsNull; protected CompositeExpression(Expression expr) { this.expr = expr; loc = expr.Location; } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext rc) { return expr.CreateExpressionTree(rc); } protected override Expression DoResolve(ResolveContext rc) { expr = expr.Resolve(rc); if (expr == null) { return null; } type = expr.Type; eclass = expr.eclass; return this; } public override void Emit(EmitContext ec) { expr.Emit(ec); } } internal abstract class ShimExpression : Expression { protected Expression expr; public Expression Expr => expr; protected ShimExpression(Expression expr) { this.expr = expr; } protected override void CloneTo(CloneContext clonectx, Expression t) { if (expr != null) { ShimExpression shimExpression = (ShimExpression)t; shimExpression.expr = expr.Clone(clonectx); } } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } public override void Emit(EmitContext ec) { throw new InternalErrorException("Missing Resolve call"); } } internal class UnreachableExpression : Expression { public UnreachableExpression(Expression expr) { loc = expr.Location; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotImplementedException(); } protected override Expression DoResolve(ResolveContext rc) { throw new NotSupportedException(); } public override void FlowAnalysis(FlowAnalysisContext fc) { fc.Report.Warning(429, 4, loc, "Unreachable expression code detected"); } public override void Emit(EmitContext ec) { } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { } } internal abstract class ATypeNameExpression : FullNamedExpression { private string name; protected TypeArguments targs; public int Arity => (targs != null) ? targs.Count : 0; public bool HasTypeArguments => targs != null && !targs.IsEmpty; public string Name { get { return name; } set { name = value; } } public TypeArguments TypeArguments => targs; protected ATypeNameExpression(string name, Location l) { this.name = name; loc = l; } protected ATypeNameExpression(string name, TypeArguments targs, Location l) { this.name = name; this.targs = targs; loc = l; } protected ATypeNameExpression(string name, int arity, Location l) : this(name, new UnboundTypeArguments(arity, l), l) { } public override bool Equals(object obj) { return obj is ATypeNameExpression aTypeNameExpression && aTypeNameExpression.Name == Name && (targs == null || targs.Equals(aTypeNameExpression.targs)); } public override int GetHashCode() { return Name.GetHashCode(); } public static string GetMemberType(MemberCore mc) { if (mc is Property) { return "property"; } if (mc is Indexer) { return "indexer"; } if (mc is FieldBase) { return "field"; } if (mc is MethodCore) { return "method"; } if (mc is EnumMember) { return "enum"; } if (mc is Event) { return "event"; } return "type"; } public override string GetSignatureForError() { if (targs != null) { return Name + "<" + targs.GetSignatureForError() + ">"; } return Name; } public abstract Expression LookupNameExpression(ResolveContext rc, MemberLookupRestrictions restriction); } internal class SimpleName : ATypeNameExpression { public SimpleName(string name, Location l) : base(name, l) { } public SimpleName(string name, TypeArguments args, Location l) : base(name, args, l) { } public SimpleName(string name, int arity, Location l) : base(name, arity, l) { } public SimpleName GetMethodGroup() { return new SimpleName(base.Name, targs, loc); } protected override Expression DoResolve(ResolveContext rc) { return SimpleNameResolve(rc, null); } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return SimpleNameResolve(ec, right_side); } public void Error_NameDoesNotExist(ResolveContext rc) { rc.Report.Error(103, loc, "The name `{0}' does not exist in the current context", base.Name); } protected virtual void Error_TypeOrNamespaceNotFound(IMemberContext ctx) { if (ctx.CurrentType != null && Expression.MemberLookup(ctx, errorMode: false, ctx.CurrentType, base.Name, 0, MemberLookupRestrictions.ExactArity, loc) is MemberExpr memberExpr) { Expression.Error_UnexpectedKind(ctx, memberExpr, "type", memberExpr.KindName, loc); return; } Report report = ctx.Module.Compiler.Report; FullNamedExpression fullNamedExpression = ctx.LookupNamespaceOrType(base.Name, base.Arity, LookupMode.IgnoreAccessibility, loc); if (fullNamedExpression != null) { report.SymbolRelatedToPreviousError(fullNamedExpression.Type); Expression.ErrorIsInaccesible(ctx, fullNamedExpression.GetSignatureForError(), loc); return; } fullNamedExpression = ctx.LookupNamespaceOrType(base.Name, -Math.Max(1, base.Arity), LookupMode.IgnoreAccessibility, loc); if (fullNamedExpression != null) { Error_TypeArgumentsCannotBeUsed(ctx, fullNamedExpression.Type, loc); return; } List list = ctx.Module.GlobalRootNamespace.FindTypeNamespaces(ctx, base.Name, base.Arity); if (list != null) { if (ctx is UsingAliasNamespace.AliasContext) { report.Error(246, loc, "The type or namespace name `{1}' could not be found. Consider using fully qualified name `{0}.{1}'", list[0], base.Name); return; } string arg = string.Join("' or `", list.ToArray()); report.Error(246, loc, "The type or namespace name `{0}' could not be found. Are you missing `{1}' using directive?", base.Name, arg); } else { report.Error(246, loc, "The type or namespace name `{0}' could not be found. Are you missing an assembly reference?", base.Name); } } public override FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext mc, bool allowUnboundTypeArguments) { FullNamedExpression fullNamedExpression = mc.LookupNamespaceOrType(base.Name, base.Arity, LookupMode.IgnoreAccessibility, loc); if (fullNamedExpression != null) { if (fullNamedExpression.Type != null && base.Arity > 0) { if (base.HasTypeArguments) { GenericTypeExpr genericTypeExpr = new GenericTypeExpr(fullNamedExpression.Type, targs, loc); if (genericTypeExpr.ResolveAsType(mc) == null) { return null; } return genericTypeExpr; } targs.Resolve(mc, allowUnboundTypeArguments); return new GenericOpenTypeExpr(fullNamedExpression.Type, loc); } if (!(fullNamedExpression is NamespaceExpression)) { return fullNamedExpression; } } if (base.Arity == 0 && base.Name == "dynamic" && !(mc is NamespaceContainer) && mc.Module.Compiler.Settings.Version > LanguageVersion.V_3) { if (!mc.Module.PredefinedAttributes.Dynamic.IsDefined) { mc.Module.Compiler.Report.Error(1980, base.Location, "Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?", mc.Module.PredefinedAttributes.Dynamic.GetSignatureForError()); } fullNamedExpression = new DynamicTypeExpr(loc); fullNamedExpression.ResolveAsType(mc); } if (fullNamedExpression != null) { return fullNamedExpression; } Error_TypeOrNamespaceNotFound(mc); return null; } private bool IsPossibleTypeOrNamespace(IMemberContext mc) { return mc.LookupNamespaceOrType(base.Name, base.Arity, (LookupMode)1026, loc) != null; } public bool IsPossibleType(IMemberContext mc) { return mc.LookupNamespaceOrType(base.Name, base.Arity, LookupMode.IgnoreAccessibility, loc) is TypeExpr; } public override Expression LookupNameExpression(ResolveContext rc, MemberLookupRestrictions restrictions) { int num = base.Arity; bool flag = false; Block currentBlock = rc.CurrentBlock; INamedBlockVariable variable = null; bool flag2 = false; Tuple tuple; while (true) { if (currentBlock != null && num == 0 && currentBlock.ParametersBlock.TopBlock.GetLocalName(base.Name, currentBlock.Original, ref variable)) { if (!variable.IsDeclared) { flag = true; flag2 = true; } else { Expression expression = variable.CreateReferenceExpression(rc, loc); if (expression != null) { if (base.Arity > 0) { Expression.Error_TypeArgumentsCannotBeUsed(rc, "variable", base.Name, loc); } return expression; } } } for (TypeSpec typeSpec = rc.CurrentType; typeSpec != null; typeSpec = typeSpec.DeclaringType) { Expression expression = Expression.MemberLookup(rc, flag, typeSpec, base.Name, num, restrictions, loc); if (expression != null) { if (expression is MemberExpr memberExpr) { if (flag) { if (variable != null) { if (!(memberExpr is FieldExpr) && !(memberExpr is ConstantExpr) && !(memberExpr is EventExpr) && !(memberExpr is PropertyExpr)) { break; } rc.Report.Error(844, loc, "A local variable `{0}' cannot be used before it is declared. Consider renaming the local variable when it hides the member `{1}'", base.Name, memberExpr.GetSignatureForError()); } else if (!(memberExpr is MethodGroupExpr) && !(memberExpr is PropertyExpr) && !(memberExpr is IndexerExpr)) { Expression.ErrorIsInaccesible(rc, memberExpr.GetSignatureForError(), loc); } } else if (memberExpr is PropertyExpr propertyExpr) { if ((restrictions & MemberLookupRestrictions.ReadAccess) != MemberLookupRestrictions.None) { if (!propertyExpr.PropertyInfo.HasGet || !propertyExpr.PropertyInfo.Get.IsAccessible(rc)) { break; } propertyExpr.Getter = propertyExpr.PropertyInfo.Get; } else { if (!propertyExpr.PropertyInfo.HasSet) { if (rc.HasSet(ResolveContext.Options.ConstructorScope) && propertyExpr.IsAutoPropertyAccess && propertyExpr.PropertyInfo.DeclaringType == rc.CurrentType && propertyExpr.IsStatic == rc.IsStatic) { Property property = (Property)propertyExpr.PropertyInfo.MemberDefinition; return new FieldExpr(property.BackingField, loc); } flag2 = true; break; } if (!propertyExpr.PropertyInfo.Set.IsAccessible(rc)) { flag2 = true; break; } propertyExpr.Setter = propertyExpr.PropertyInfo.Set; } } MemberExpr memberExpr2 = memberExpr.ResolveMemberAccess(rc, null, null); if (base.Arity > 0) { targs.Resolve(rc, allowUnbound: false); memberExpr2.SetTypeArguments(rc, targs); } return memberExpr2; } if (expression is TypeExpr) { break; } } } if ((restrictions & MemberLookupRestrictions.InvocableOnly) == 0 && !flag2 && IsPossibleTypeOrNamespace(rc)) { return ResolveAsTypeOrNamespace(rc, allowUnboundTypeArguments: false); } Expression expression2 = NamespaceContainer.LookupStaticUsings(rc, base.Name, base.Arity, loc); if (expression2 != null) { if (base.Arity > 0) { targs.Resolve(rc, allowUnbound: false); if (expression2 is MemberExpr memberExpr3) { memberExpr3.SetTypeArguments(rc, targs); } } return expression2; } if ((restrictions & MemberLookupRestrictions.NameOfExcluded) == 0 && base.Name == "nameof") { return new NameOf(this); } if ((restrictions & MemberLookupRestrictions.ReadAccess) == 0 && base.Name == "_") { if (rc.Module.Compiler.Settings.Version < LanguageVersion.V_7) { rc.Report.FeatureIsNotAvailable(rc.Module.Compiler, loc, "discards"); } return new Discard(loc).Resolve(rc); } if (flag) { if (flag2) { rc.Report.Error(841, loc, "A local variable `{0}' cannot be used before it is declared", base.Name); } else { if (base.Arity > 0) { TypeParameters currentTypeParameters = rc.CurrentTypeParameters; if (currentTypeParameters != null && currentTypeParameters.Find(base.Name) != null) { Expression.Error_TypeArgumentsCannotBeUsed(rc, "type parameter", base.Name, loc); return null; } TypeSpec typeSpec2 = rc.CurrentType; do { if (typeSpec2.MemberDefinition.TypeParametersCount > 0) { TypeParameterSpec[] typeParameters = typeSpec2.MemberDefinition.TypeParameters; foreach (TypeParameterSpec typeParameterSpec in typeParameters) { if (typeParameterSpec.Name == base.Name) { Expression.Error_TypeArgumentsCannotBeUsed(rc, "type parameter", base.Name, loc); return null; } } } typeSpec2 = typeSpec2.DeclaringType; } while (typeSpec2 != null); } Expression expression; if ((restrictions & MemberLookupRestrictions.InvocableOnly) == 0) { expression = rc.LookupNamespaceOrType(base.Name, base.Arity, LookupMode.IgnoreAccessibility, loc); if (expression != null) { rc.Report.SymbolRelatedToPreviousError(expression.Type); Expression.ErrorIsInaccesible(rc, expression.GetSignatureForError(), loc); return expression; } } else if (Expression.MemberLookup(rc, errorMode: false, rc.CurrentType, base.Name, base.Arity, restrictions & ~MemberLookupRestrictions.InvocableOnly, loc) is MemberExpr memberExpr4) { Expression.Error_UnexpectedKind(rc, memberExpr4, "method group", memberExpr4.KindName, loc); return ErrorExpression.Instance; } expression = rc.LookupNamespaceOrType(base.Name, -Math.Max(1, base.Arity), LookupMode.IgnoreAccessibility, loc); if (expression != null) { if (expression.Type.Arity != base.Arity && (restrictions & MemberLookupRestrictions.IgnoreArity) == 0) { Error_TypeArgumentsCannotBeUsed(rc, expression.Type, loc); return expression; } if (expression is TypeExpr) { if (expression is TypeExpression) { expression = new TypeExpression(expression.Type, loc); } return expression; } } Error_NameDoesNotExist(rc); } return ErrorExpression.Instance; } if (rc.Module.Evaluator != null) { tuple = rc.Module.Evaluator.LookupField(base.Name); if (tuple != null) { break; } } num = 0; flag = true; } return new FieldExpr(tuple.Item1, loc); } private Expression SimpleNameResolve(ResolveContext ec, Expression right_side) { Expression expression = LookupNameExpression(ec, (right_side == null) ? MemberLookupRestrictions.ReadAccess : MemberLookupRestrictions.None); if (expression == null) { return null; } if (expression is FullNamedExpression && expression.eclass != ExprClass.Unresolved) { Expression.Error_UnexpectedKind(ec, expression, "variable", expression.ExprClassName, loc); return expression; } return (right_side == null) ? expression.Resolve(ec) : expression.ResolveLValue(ec, right_side); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class FullNamedExpression : Expression { protected override void CloneTo(CloneContext clonectx, Expression target) { } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } public abstract FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext mc, bool allowUnboundTypeArguments); public override TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments = false) { FullNamedExpression fullNamedExpression = ResolveAsTypeOrNamespace(mc, allowUnboundTypeArguments); if (fullNamedExpression == null) { return null; } if (!(fullNamedExpression is TypeExpr typeExpr)) { Expression.Error_UnexpectedKind(mc, fullNamedExpression, "type", fullNamedExpression.ExprClassName, loc); return null; } typeExpr.loc = loc; type = typeExpr.Type; List missingDependencies = type.GetMissingDependencies(); if (missingDependencies != null) { ImportedTypeDefinition.Error_MissingDependency(mc, missingDependencies, loc); } if (type.Kind == MemberKind.Void) { mc.Module.Compiler.Report.Error(673, loc, "System.Void cannot be used from C#. Consider using `void'"); } if (mc is ResolveContext) { ObsoleteAttribute attributeObsolete = type.GetAttributeObsolete(); if (attributeObsolete != null && !mc.IsObsolete) { AttributeTester.Report_ObsoleteMessage(attributeObsolete, type.GetSignatureForError(), fullNamedExpression.Location, mc.Module.Compiler.Report); } } return type; } public override void Emit(EmitContext ec) { throw new InternalErrorException("FullNamedExpression `{0}' found in resolved tree", GetSignatureForError()); } } internal abstract class TypeExpr : FullNamedExpression { public sealed override FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext mc, bool allowUnboundTypeArguments) { ResolveAsType(mc); return this; } protected sealed override Expression DoResolve(ResolveContext ec) { ResolveAsType(ec); return this; } public override bool Equals(object obj) { if (!(obj is TypeExpr typeExpr)) { return false; } return base.Type == typeExpr.Type; } public override int GetHashCode() { return base.Type.GetHashCode(); } } internal class TypeExpression : TypeExpr { public TypeExpression(TypeSpec t, Location l) { base.Type = t; eclass = ExprClass.Type; loc = l; } public sealed override TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments = false) { return type; } } internal class NamespaceExpression : FullNamedExpression { private readonly Namespace ns; public Namespace Namespace => ns; public NamespaceExpression(Namespace ns, Location loc) { this.ns = ns; base.Type = InternalType.Namespace; eclass = ExprClass.Namespace; base.loc = loc; } protected override Expression DoResolve(ResolveContext rc) { throw new NotImplementedException(); } public override FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext mc, bool allowUnboundTypeArguments) { return this; } public void Error_NamespaceDoesNotExist(IMemberContext ctx, string name, int arity, Location loc) { TypeSpec typeSpec = Namespace.LookupType(ctx, name, arity, LookupMode.IgnoreAccessibility, loc); if (typeSpec != null) { Expression.ErrorIsInaccesible(ctx, typeSpec.GetSignatureForError(), loc); return; } typeSpec = Namespace.LookupType(ctx, name, -Math.Max(1, arity), LookupMode.IgnoreAccessibility, loc); if (typeSpec != null) { Error_TypeArgumentsCannotBeUsed(ctx, typeSpec, loc); return; } if (arity > 0 && Namespace.TryGetNamespace(name, out var obj)) { Expression.Error_TypeArgumentsCannotBeUsed(ctx, ExprClassName, obj.GetSignatureForError(), loc); return; } string text = null; string text2 = Namespace.GetSignatureForError() + "." + name; switch (text2) { case "System.Drawing": case "System.Web.Services": case "System.Web": case "System.Data": case "System.Configuration": case "System.Data.Services": case "System.DirectoryServices": case "System.Json": case "System.Net.Http": case "System.Numerics": case "System.Runtime.Caching": case "System.ServiceModel": case "System.Transactions": case "System.Web.Routing": case "System.Xml.Linq": case "System.Xml": text = text2; break; case "System.Linq": case "System.Linq.Expressions": text = "System.Core"; break; case "System.Windows.Forms": case "System.Windows.Forms.Layout": text = "System.Windows.Forms"; break; } text = ((text == null) ? "an" : ("`" + text + "'")); if (Namespace is GlobalRootNamespace) { ctx.Module.Compiler.Report.Error(400, loc, "The type or namespace name `{0}' could not be found in the global namespace. Are you missing {1} assembly reference?", name, text); return; } ctx.Module.Compiler.Report.Error(234, loc, "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing {2} assembly reference?", name, GetSignatureForError(), text); } public override string GetSignatureForError() { return ns.GetSignatureForError(); } public FullNamedExpression LookupTypeOrNamespace(IMemberContext ctx, string name, int arity, LookupMode mode, Location loc) { return ns.LookupTypeOrNamespace(ctx, name, arity, mode, loc); } public override string ToString() { return Namespace.Name; } } internal abstract class MemberExpr : Expression, OverloadResolver.IInstanceQualifier { protected bool conditional_access_receiver; public Expression InstanceExpression; public abstract string Name { get; } public bool IsBase => InstanceExpression is BaseThis; public abstract bool IsInstance { get; } public abstract bool IsStatic { get; } public abstract string KindName { get; } public bool ConditionalAccess { get; set; } protected abstract TypeSpec DeclaringType { get; } TypeSpec OverloadResolver.IInstanceQualifier.InstanceType => InstanceExpression.Type; protected MethodSpec CandidateToBaseOverride(ResolveContext rc, MethodSpec method) { if (!IsBase) { return method; } if ((method.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0) { TypeSpec[] array = null; if (method.DeclaringType != InstanceExpression.Type) { AParametersCollection aParametersCollection = method.Parameters; if (method.Arity > 0) { aParametersCollection = ((IParametersMember)method.MemberDefinition).Parameters; if (method.DeclaringType is InflatedTypeSpec inflatedTypeSpec) { aParametersCollection = aParametersCollection.Inflate(inflatedTypeSpec.CreateLocalInflator(rc)); } } if (MemberCache.FindMember(filter: new MemberFilter(method.Name, method.Arity, MemberKind.Method, aParametersCollection, null), container: InstanceExpression.Type, restrictions: BindingRestriction.InstanceOnly | BindingRestriction.OverrideOnly) is MethodSpec methodSpec && methodSpec.DeclaringType != method.DeclaringType) { if (methodSpec.IsGeneric) { array = method.TypeArguments; } method = methodSpec; } } if (rc.CurrentAnonymousMethod != null) { if (array == null && method.IsGeneric) { array = method.TypeArguments; method = method.GetGenericMethodDefinition(); } if (method.Parameters.HasArglist) { throw new NotImplementedException("__arglist base call proxy"); } method = rc.CurrentMemberDefinition.Parent.PartialContainer.CreateHoistedBaseCallProxy(rc, method); if (rc.CurrentType.IsStruct || rc.CurrentAnonymousMethod.Storey is AsyncTaskStorey) { InstanceExpression = new This(loc).Resolve(rc); } } if (array != null) { method = method.MakeGenericMethod(rc, array); } } if (method.IsAbstract) { rc.Report.SymbolRelatedToPreviousError(method); Error_CannotCallAbstractBase(rc, method.GetSignatureForError()); } return method; } protected void CheckProtectedMemberAccess(ResolveContext rc, MemberSpec member) { if (InstanceExpression != null && (member.Modifiers & Modifiers.PROTECTED) != 0 && !(InstanceExpression is This) && !CheckProtectedMemberAccess(rc, member, InstanceExpression.Type)) { Error_ProtectedMemberAccess(rc, member, InstanceExpression.Type, loc); } } bool OverloadResolver.IInstanceQualifier.CheckProtectedMemberAccess(ResolveContext rc, MemberSpec member) { if (InstanceExpression == null) { return true; } return InstanceExpression is This || CheckProtectedMemberAccess(rc, member, InstanceExpression.Type); } public static bool CheckProtectedMemberAccess(ResolveContext rc, T member, TypeSpec qualifier) where T : MemberSpec { return true; } public override bool ContainsEmitWithAwait() { return InstanceExpression != null && InstanceExpression.ContainsEmitWithAwait(); } public override bool HasConditionalAccess() { return ConditionalAccess || (InstanceExpression != null && InstanceExpression.HasConditionalAccess()); } private static bool IsSameOrBaseQualifier(TypeSpec type, TypeSpec qtype) { do { type = type.GetDefinition(); if (type == qtype || TypeManager.IsFamilyAccessible(qtype, type)) { return true; } type = type.DeclaringType; } while (type != null); return false; } protected void DoBestMemberChecks(ResolveContext rc, T member) where T : MemberSpec, IInterfaceMemberSpec { if (InstanceExpression != null) { InstanceExpression = InstanceExpression.Resolve(rc); CheckProtectedMemberAccess(rc, member); } if (member.MemberType.IsPointer) { if (rc.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(rc, loc); } else if (!rc.IsUnsafe) { Expression.UnsafeError(rc, loc); } } List missingDependencies = member.GetMissingDependencies(); if (missingDependencies != null) { ImportedTypeDefinition.Error_MissingDependency(rc, missingDependencies, loc); } member.CheckObsoleteness(rc, loc); if (!(member is FieldSpec)) { member.MemberDefinition.SetIsUsed(); } } protected virtual void Error_CannotCallAbstractBase(ResolveContext rc, string name) { rc.Report.Error(205, loc, "Cannot call an abstract base member `{0}'", name); } public static void Error_ProtectedMemberAccess(ResolveContext rc, MemberSpec member, TypeSpec qualifier, Location loc) { rc.Report.SymbolRelatedToPreviousError(member); rc.Report.Error(1540, loc, "Cannot access protected member `{0}' via a qualifier of type `{1}'. The qualifier must be of type `{2}' or derived from it", member.GetSignatureForError(), qualifier.GetSignatureForError(), rc.CurrentType.GetSignatureForError()); } public override void FlowAnalysis(FlowAnalysisContext fc) { if (InstanceExpression != null) { InstanceExpression.FlowAnalysis(fc); } } protected void ResolveConditionalAccessReceiver(ResolveContext rc) { if (!rc.HasSet(ResolveContext.Options.DontSetConditionalAccessReceiver) && HasConditionalAccess()) { conditional_access_receiver = true; } } public bool ResolveInstanceExpression(ResolveContext rc, Expression rhs) { if (!ResolveInstanceExpressionCore(rc, rhs)) { return false; } if (rhs != null && TypeSpec.IsValueType(InstanceExpression.Type)) { if (InstanceExpression is FieldExpr fieldExpr) { if (!fieldExpr.Spec.IsReadOnly || rc.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.ConstructorScope)) { return true; } if (fieldExpr.IsStatic) { rc.Report.Error(1650, loc, "Fields of static readonly field `{0}' cannot be assigned to (except in a static constructor or a variable initializer)", fieldExpr.GetSignatureForError()); } else { rc.Report.Error(1648, loc, "Members of readonly field `{0}' cannot be modified (except in a constructor or a variable initializer)", fieldExpr.GetSignatureForError()); } return true; } if (InstanceExpression is PropertyExpr || InstanceExpression is IndexerExpr || InstanceExpression is Invocation) { if (rc.CurrentInitializerVariable != null) { rc.Report.Error(1918, loc, "Members of value type `{0}' cannot be assigned using a property `{1}' object initializer", InstanceExpression.Type.GetSignatureForError(), InstanceExpression.GetSignatureForError()); } else { rc.Report.Error(1612, loc, "Cannot modify a value type return value of `{0}'. Consider storing the value in a temporary variable", InstanceExpression.GetSignatureForError()); } return true; } if (InstanceExpression is LocalVariableReference localVariableReference) { if (!localVariableReference.local_info.IsReadonly) { return true; } rc.Report.Error(1654, loc, "Cannot assign to members of `{0}' because it is a `{1}'", InstanceExpression.GetSignatureForError(), localVariableReference.local_info.GetReadOnlyContext()); } } return true; } private bool ResolveInstanceExpressionCore(ResolveContext rc, Expression rhs) { if (IsStatic) { if (InstanceExpression != null) { if (InstanceExpression is TypeExpr) { TypeSpec declaringType = InstanceExpression.Type; do { declaringType.CheckObsoleteness(rc, loc); declaringType = declaringType.DeclaringType; } while (declaringType != null); } else if (!(InstanceExpression is RuntimeValueExpression { IsSuggestionOnly: not false })) { rc.Report.Error(176, loc, "Static member `{0}' cannot be accessed with an instance reference, qualify it with a type name instead", GetSignatureForError()); } InstanceExpression = null; } return false; } if (InstanceExpression == null || InstanceExpression is TypeExpr) { if (InstanceExpression != null || !This.IsThisAvailable(rc, ignoreAnonymous: true)) { if (rc.HasSet(ResolveContext.Options.FieldInitializerScope)) { rc.Report.Error(236, loc, "A field initializer cannot reference the nonstatic field, method, or property `{0}'", GetSignatureForError()); } else if (this is FieldExpr fieldExpr && fieldExpr.Spec.MemberDefinition is PrimaryConstructorField) { if (rc.HasSet(ResolveContext.Options.BaseInitializer)) { rc.Report.Error(9005, loc, "Constructor initializer cannot access primary constructor parameters"); } else { rc.Report.Error(9006, loc, "An object reference is required to access primary constructor parameter `{0}'", fieldExpr.Name); } } else { rc.Report.Error(120, loc, "An object reference is required to access non-static member `{0}'", GetSignatureForError()); } InstanceExpression = new CompilerGeneratedThis(rc.CurrentType, loc).Resolve(rc); return false; } if (!TypeManager.IsFamilyAccessible(rc.CurrentType, DeclaringType)) { rc.Report.Error(38, loc, "Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'", DeclaringType.GetSignatureForError(), rc.CurrentType.GetSignatureForError()); } InstanceExpression = new This(loc).Resolve(rc); return false; } if (InstanceExpression is MemberExpr memberExpr) { memberExpr.ResolveInstanceExpressionCore(rc, rhs); if (memberExpr is FieldExpr fieldExpr2 && fieldExpr2.IsMarshalByRefAccess(rc)) { rc.Report.SymbolRelatedToPreviousError(memberExpr.DeclaringType); rc.Report.Warning(1690, 1, loc, "Cannot call methods, properties, or indexers on `{0}' because it is a value type member of a marshal-by-reference class", memberExpr.GetSignatureForError()); } return true; } if (rhs != null && InstanceExpression is UnboxCast) { rc.Report.Error(445, InstanceExpression.Location, "Cannot modify the result of an unboxing conversion"); } return true; } public virtual MemberExpr ResolveMemberAccess(ResolveContext ec, Expression left, SimpleName original) { if (left != null && !ConditionalAccess && !ec.HasSet(ResolveContext.Options.NameOfScope) && left.IsNull && TypeSpec.IsReferenceType(left.Type)) { ec.Report.Warning(1720, 1, left.Location, "Expression will always cause a `{0}'", "System.NullReferenceException"); } InstanceExpression = left; return this; } public virtual void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { } protected void EmitInstance(EmitContext ec, bool prepare_for_load) { new InstanceEmitter(InstanceExpression, TypeSpec.IsValueType(InstanceExpression.Type)).Emit(ec, ConditionalAccess); if (prepare_for_load) { ec.Emit(OpCodes.Dup); } } public abstract void SetTypeArguments(ResolveContext ec, TypeArguments ta); } internal class ExtensionMethodCandidates { private readonly NamespaceContainer container; private readonly IList methods; private readonly int index; private readonly IMemberContext context; public NamespaceContainer Container => container; public IMemberContext Context => context; public int LookupIndex => index; public IList Methods => methods; public ExtensionMethodCandidates(IMemberContext context, IList methods, NamespaceContainer nsContainer, int lookupIndex) { this.context = context; this.methods = methods; container = nsContainer; index = lookupIndex; } } internal class ExtensionMethodGroupExpr : MethodGroupExpr, OverloadResolver.IErrorHandler { private ExtensionMethodCandidates candidates; public Expression ExtensionExpression; public override bool IsStatic => true; public ExtensionMethodGroupExpr(ExtensionMethodCandidates candidates, Expression extensionExpr, Location loc) : base(candidates.Methods.Cast().ToList(), extensionExpr.Type, loc) { this.candidates = candidates; ExtensionExpression = extensionExpr; } public override IList GetBaseMembers(TypeSpec type) { if (candidates == null) { return null; } int arity = ((type_arguments != null) ? type_arguments.Count : 0); candidates = candidates.Container.LookupExtensionMethod(candidates.Context, Name, arity, candidates.LookupIndex); if (candidates == null) { return null; } return candidates.Methods.Cast().ToList(); } public static bool IsExtensionTypeCompatible(TypeSpec argType, TypeSpec extensionType) { return argType == extensionType || TypeSpecComparer.IsEqual(argType, extensionType) || Convert.ImplicitReferenceConversionExists(argType, extensionType, refOnlyTypeParameter: false) || Convert.ImplicitBoxingConversion(null, argType, extensionType) != null; } public override void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { rc.Report.Error(8093, expr.Location, "An argument to nameof operator cannot be extension method group"); } public override MethodGroupExpr LookupExtensionMethod(ResolveContext rc) { return null; } public override MethodGroupExpr OverloadResolve(ResolveContext ec, ref Arguments arguments, OverloadResolver.IErrorHandler ehandler, OverloadResolver.Restrictions restr) { if (arguments == null) { arguments = new Arguments(1); } ExtensionExpression = ExtensionExpression.Resolve(ec); if (ExtensionExpression == null) { return null; } ExtensionMethodCandidates extensionMethodCandidates = candidates; Argument.AType aType = (base.ConditionalAccess ? Argument.AType.ExtensionTypeConditionalAccess : Argument.AType.ExtensionType); arguments.Insert(0, new Argument(ExtensionExpression, aType)); MethodGroupExpr methodGroupExpr = base.OverloadResolve(ec, ref arguments, ehandler ?? this, restr); candidates = extensionMethodCandidates; if (methodGroupExpr == null) { arguments.RemoveAt(0); return null; } if (ExtensionExpression is MemberExpr memberExpr) { memberExpr.ResolveInstanceExpression(ec, null); if (memberExpr is FieldExpr fieldExpr) { fieldExpr.Spec.MemberDefinition.SetIsUsed(); } } InstanceExpression = null; return this; } bool OverloadResolver.IErrorHandler.AmbiguousCandidates(ResolveContext rc, MemberSpec best, MemberSpec ambiguous) { return false; } bool OverloadResolver.IErrorHandler.ArgumentMismatch(ResolveContext rc, MemberSpec best, Argument arg, int index) { rc.Report.SymbolRelatedToPreviousError(best); if (index == 0) { rc.Report.Error(1929, loc, "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' requires an instance of type `{3}'", queried_type.GetSignatureForError(), Name, best.GetSignatureForError(), ((MethodSpec)best).Parameters.ExtensionMethodType.GetSignatureForError()); } else { rc.Report.Error(1928, loc, "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' has some invalid arguments", queried_type.GetSignatureForError(), Name, best.GetSignatureForError()); } return true; } bool OverloadResolver.IErrorHandler.NoArgumentMatch(ResolveContext rc, MemberSpec best) { return false; } bool OverloadResolver.IErrorHandler.TypeInferenceFailed(ResolveContext rc, MemberSpec best) { return false; } } internal class MethodGroupExpr : MemberExpr, OverloadResolver.IBaseMembersProvider { private static readonly MemberSpec[] Excluded = new MemberSpec[0]; protected IList Methods; private MethodSpec best_candidate; private TypeSpec best_candidate_return; protected TypeArguments type_arguments; private SimpleName simple_name; protected TypeSpec queried_type; public MethodSpec BestCandidate => best_candidate; public TypeSpec BestCandidateReturnType => best_candidate_return; public IList Candidates => Methods; protected override TypeSpec DeclaringType => queried_type; public bool IsConditionallyExcluded => Methods == Excluded; public override bool IsInstance { get { if (best_candidate != null) { return !best_candidate.IsStatic; } return false; } } public override bool IsSideEffectFree => InstanceExpression == null || InstanceExpression.IsSideEffectFree; public override bool IsStatic { get { if (best_candidate != null) { return best_candidate.IsStatic; } return false; } } public override string KindName => "method"; public override string Name { get { if (best_candidate != null) { return best_candidate.Name; } return Methods.First().Name; } } public MethodGroupExpr(IList mi, TypeSpec type, Location loc) { Methods = mi; base.loc = loc; base.type = InternalType.MethodGroup; eclass = ExprClass.MethodGroup; queried_type = type; } public MethodGroupExpr(MethodSpec m, TypeSpec type, Location loc) : this(new MemberSpec[1] { m }, type, loc) { } public static MethodGroupExpr CreatePredefined(MethodSpec best, TypeSpec queriedType, Location loc) { return new MethodGroupExpr(best, queriedType, loc) { best_candidate = best, best_candidate_return = best.ReturnType }; } public override string GetSignatureForError() { if (best_candidate != null) { return best_candidate.GetSignatureForError(); } return Methods.First().GetSignatureForError(); } private static MethodSpec CandidateDevirtualization(TypeSpec type, MethodSpec method) { MemberFilter filter = new MemberFilter(method.Name, method.Arity, MemberKind.Method, method.Parameters, null); return MemberCache.FindMember(type, filter, BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly | BindingRestriction.OverrideOnly) as MethodSpec; } public override Expression CreateExpressionTree(ResolveContext ec) { if (best_candidate == null) { ec.Report.Error(1953, loc, "An expression tree cannot contain an expression with method group"); return null; } if (IsConditionallyExcluded) { ec.Report.Error(765, loc, "Partial methods with only a defining declaration or removed conditional methods cannot be used in an expression tree"); } if (base.ConditionalAccess) { Error_NullShortCircuitInsideExpressionTree(ec); } return new TypeOfMethod(best_candidate, loc); } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.MethodGroup; if (InstanceExpression != null) { InstanceExpression = InstanceExpression.Resolve(ec); if (InstanceExpression == null) { return null; } } return this; } public override void Emit(EmitContext ec) { throw new NotSupportedException(); } public override void EmitPrepare(EmitContext ec) { InstanceExpression?.EmitPrepare(ec); } public void EmitCall(EmitContext ec, Arguments arguments, bool statement) { CallEmitter callEmitter = new CallEmitter { InstanceExpression = InstanceExpression, ConditionalAccess = base.ConditionalAccess }; if (statement) { callEmitter.EmitStatement(ec, best_candidate, arguments, loc); } else { callEmitter.Emit(ec, best_candidate, arguments, loc); } } public void EmitCall(EmitContext ec, Arguments arguments, TypeSpec conditionalAccessReceiver, bool statement) { ConditionalAccessContext conditionalAccess = ec.ConditionalAccess; ec.ConditionalAccess = new ConditionalAccessContext(conditionalAccessReceiver, ec.DefineLabel()) { Statement = statement }; EmitCall(ec, arguments, statement); ec.CloseConditionalAccess((!statement && best_candidate_return != conditionalAccessReceiver && conditionalAccessReceiver.IsNullableType) ? conditionalAccessReceiver : null); ec.ConditionalAccess = conditionalAccess; } public override void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec target, bool expl) { if (target != InternalType.ErrorType) { ec.Report.Error(428, loc, "Cannot convert method group `{0}' to non-delegate type `{1}'. Consider using parentheses to invoke the method", Name, target.GetSignatureForError()); } } public bool HasAccessibleCandidate(ResolveContext rc) { foreach (MemberSpec candidate in Candidates) { if (candidate.IsAccessible(rc)) { return true; } } return false; } public static bool IsExtensionMethodArgument(Expression expr) { return !(expr is TypeExpr) && !(expr is BaseThis); } public virtual MethodGroupExpr OverloadResolve(ResolveContext ec, ref Arguments args, OverloadResolver.IErrorHandler cerrors, OverloadResolver.Restrictions restr) { if (best_candidate != null && best_candidate.Kind == MemberKind.Destructor) { return this; } OverloadResolver overloadResolver = new OverloadResolver(Methods, type_arguments, restr, loc); if ((restr & OverloadResolver.Restrictions.NoBaseMembers) == 0) { overloadResolver.BaseMembersProvider = this; overloadResolver.InstanceQualifier = this; } if (cerrors != null) { overloadResolver.CustomErrors = cerrors; } best_candidate = overloadResolver.ResolveMember(ec, ref args); if (best_candidate == null) { if (!overloadResolver.BestCandidateIsDynamic) { return null; } if (simple_name != null && ec.IsStatic) { InstanceExpression = ProbeIdenticalTypeName(ec, InstanceExpression, simple_name); } return this; } if (overloadResolver.BestCandidateNewMethodGroup != null) { return overloadResolver.BestCandidateNewMethodGroup; } if (best_candidate.Kind == MemberKind.Method && (restr & OverloadResolver.Restrictions.ProbingOnly) == 0) { if (InstanceExpression != null) { if (best_candidate.IsExtensionMethod && args[0].Expr == InstanceExpression) { InstanceExpression = null; } else { if (simple_name != null && best_candidate.IsStatic) { InstanceExpression = ProbeIdenticalTypeName(ec, InstanceExpression, simple_name); } InstanceExpression.Resolve(ec, ResolveFlags.VariableOrValue | ResolveFlags.Type | ResolveFlags.MethodGroup); TypeSpec typeSpec = InstanceExpression.Type; if ((typeSpec.IsByRefLike || typeSpec.IsSpecialRuntimeType) && best_candidate.DeclaringType != typeSpec) { MethodSpec methodSpec = null; if ((best_candidate.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0) { methodSpec = CandidateDevirtualization(typeSpec, best_candidate); } if (methodSpec == null) { ec.Report.Error(29, InstanceExpression.Location, "Cannot implicitly convert type `{0}' to `{1}'", InstanceExpression.Type.GetSignatureForError(), best_candidate.DeclaringType.GetSignatureForError()); } else { best_candidate = methodSpec; } } } } ResolveInstanceExpression(ec, null); } MethodSpec methodSpec2 = CandidateToBaseOverride(ec, best_candidate); if (methodSpec2 == best_candidate) { best_candidate_return = overloadResolver.BestCandidateReturnType; } else { best_candidate = methodSpec2; best_candidate_return = best_candidate.ReturnType; } if (best_candidate.IsGeneric && (restr & OverloadResolver.Restrictions.ProbingOnly) == 0 && TypeParameterSpec.HasAnyTypeParameterConstrained(best_candidate.GenericDefinition)) { new ConstraintChecker(ec).CheckAll(best_candidate.GetGenericMethodDefinition(), best_candidate.TypeArguments, best_candidate.Constraints, loc); } if (best_candidate.IsVirtual && (best_candidate.DeclaringType.Modifiers & Modifiers.PROTECTED) != 0 && best_candidate.MemberDefinition.IsImported && !best_candidate.DeclaringType.IsAccessible(ec)) { ec.Report.SymbolRelatedToPreviousError(best_candidate); Expression.ErrorIsInaccesible(ec, best_candidate.GetSignatureForError(), loc); } if (best_candidate_return.Kind == MemberKind.Void && best_candidate.IsConditionallyExcluded(ec)) { Methods = Excluded; } return this; } public override MemberExpr ResolveMemberAccess(ResolveContext ec, Expression left, SimpleName original) { if (left is FieldExpr fieldExpr) { fieldExpr.Spec.MemberDefinition.SetIsAssigned(); } simple_name = original; return base.ResolveMemberAccess(ec, left, original); } public override void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { if (!HasAccessibleCandidate(rc)) { Expression.ErrorIsInaccesible(rc, expr.GetSignatureForError(), loc); } if (expr.HasTypeArguments) { rc.Report.Error(8084, expr.Location, "An argument to nameof operator cannot be method group with type arguments"); } } public override void SetTypeArguments(ResolveContext ec, TypeArguments ta) { type_arguments = ta; } public virtual IList GetBaseMembers(TypeSpec type) { TypeSpec baseType = type.BaseType; IList list = ((baseType == null) ? null : MemberCache.FindMembers(baseType, Methods[0].Name, declaredOnlyClass: false)); if (list == null && !type.IsInterface && queried_type is TypeParameterSpec typeParameter) { list = MemberCache.FindInterfaceMembers(typeParameter, Methods[0].Name); } return list; } public IParametersMember GetOverrideMemberParameters(MemberSpec member) { if (queried_type == member.DeclaringType) { return null; } return MemberCache.FindMember(queried_type, new MemberFilter((MethodSpec)member), BindingRestriction.InstanceOnly | BindingRestriction.OverrideOnly) as IParametersMember; } public virtual MethodGroupExpr LookupExtensionMethod(ResolveContext rc) { if (InstanceExpression == null || InstanceExpression.eclass == ExprClass.Type) { return null; } if (!IsExtensionMethodArgument(InstanceExpression)) { return null; } int arity = ((type_arguments != null) ? type_arguments.Count : 0); ExtensionMethodCandidates extensionMethodCandidates = rc.LookupExtensionMethod(Methods[0].Name, arity); if (extensionMethodCandidates == null) { return null; } ExtensionMethodGroupExpr extensionMethodGroupExpr = new ExtensionMethodGroupExpr(extensionMethodCandidates, InstanceExpression, loc); extensionMethodGroupExpr.SetTypeArguments(rc, type_arguments); extensionMethodGroupExpr.ConditionalAccess = base.ConditionalAccess; return extensionMethodGroupExpr; } } internal struct ConstructorInstanceQualifier : OverloadResolver.IInstanceQualifier { public TypeSpec InstanceType { get; private set; } public ConstructorInstanceQualifier(TypeSpec type) { this = default(ConstructorInstanceQualifier); InstanceType = type; } public bool CheckProtectedMemberAccess(ResolveContext rc, MemberSpec member) { return MemberExpr.CheckProtectedMemberAccess(rc, member, InstanceType); } } internal struct OverloadResolver { [Flags] public enum Restrictions { None = 0, DelegateInvoke = 1, ProbingOnly = 2, CovariantDelegate = 4, NoBaseMembers = 8, BaseMembersIncluded = 0x10, GetEnumeratorLookup = 0x20 } public interface IBaseMembersProvider { IList GetBaseMembers(TypeSpec baseType); IParametersMember GetOverrideMemberParameters(MemberSpec member); MethodGroupExpr LookupExtensionMethod(ResolveContext rc); } public interface IErrorHandler { bool AmbiguousCandidates(ResolveContext rc, MemberSpec best, MemberSpec ambiguous); bool ArgumentMismatch(ResolveContext rc, MemberSpec best, Argument a, int index); bool NoArgumentMatch(ResolveContext rc, MemberSpec best); bool TypeInferenceFailed(ResolveContext rc, MemberSpec best); } public interface IInstanceQualifier { TypeSpec InstanceType { get; } bool CheckProtectedMemberAccess(ResolveContext rc, MemberSpec member); } private sealed class NoBaseMembers : IBaseMembersProvider { public static readonly IBaseMembersProvider Instance = new NoBaseMembers(); public IList GetBaseMembers(TypeSpec baseType) { return null; } public IParametersMember GetOverrideMemberParameters(MemberSpec member) { return null; } public MethodGroupExpr LookupExtensionMethod(ResolveContext rc) { return null; } } private struct AmbiguousCandidate { public readonly MemberSpec Member; public readonly bool Expanded; public readonly AParametersCollection Parameters; public AmbiguousCandidate(MemberSpec member, AParametersCollection parameters, bool expanded) { Member = member; Parameters = parameters; Expanded = expanded; } } private Location loc; private IList members; private TypeArguments type_arguments; private IBaseMembersProvider base_provider; private IErrorHandler custom_errors; private IInstanceQualifier instance_qualifier; private Restrictions restrictions; private MethodGroupExpr best_candidate_extension_group; private TypeSpec best_candidate_return_type; private SessionReportPrinter lambda_conv_msgs; public IBaseMembersProvider BaseMembersProvider { get { return base_provider; } set { base_provider = value; } } public bool BestCandidateIsDynamic { get; set; } public MethodGroupExpr BestCandidateNewMethodGroup => best_candidate_extension_group; public TypeSpec BestCandidateReturnType => best_candidate_return_type; public IErrorHandler CustomErrors { get { return custom_errors; } set { custom_errors = value; } } private TypeSpec DelegateType { get { if ((restrictions & Restrictions.DelegateInvoke) == 0) { throw new InternalErrorException("Not running in delegate mode", loc); } return members[0].DeclaringType; } } public IInstanceQualifier InstanceQualifier { get { return instance_qualifier; } set { instance_qualifier = value; } } private bool IsProbingOnly => (restrictions & Restrictions.ProbingOnly) != 0; private bool IsDelegateInvoke => (restrictions & Restrictions.DelegateInvoke) != 0; public OverloadResolver(IList members, Restrictions restrictions, Location loc) : this(members, null, restrictions, loc) { } public OverloadResolver(IList members, TypeArguments targs, Restrictions restrictions, Location loc) { this = default(OverloadResolver); if (members == null || members.Count == 0) { throw new ArgumentException("empty members set"); } this.members = members; this.loc = loc; type_arguments = targs; this.restrictions = restrictions; if (IsDelegateInvoke) { this.restrictions |= Restrictions.NoBaseMembers; } base_provider = NoBaseMembers.Instance; } private static int BetterExpressionConversion(ResolveContext ec, Argument a, TypeSpec p, TypeSpec q) { TypeSpec type = a.Type; if (type == InternalType.AnonymousMethod && ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2) { if (p.IsExpressionTreeType || q.IsExpressionTreeType) { if (q.MemberDefinition != p.MemberDefinition) { return 0; } q = TypeManager.GetTypeArguments(q)[0]; p = TypeManager.GetTypeArguments(p)[0]; } MethodSpec invokeMethod = Delegate.GetInvokeMethod(p); MethodSpec invokeMethod2 = Delegate.GetInvokeMethod(q); if (!TypeSpecComparer.Equals(invokeMethod.Parameters.Types, invokeMethod2.Parameters.Types)) { return 0; } p = invokeMethod.ReturnType; TypeSpec delegate_type = q; q = invokeMethod2.ReturnType; if (p.Kind == MemberKind.Void) { return (q.Kind != MemberKind.Void) ? 2 : 0; } if (q.Kind == MemberKind.Void) { return (p.Kind != MemberKind.Void) ? 1 : 0; } AnonymousMethodExpression anonymousMethodExpression = (AnonymousMethodExpression)a.Expr; if ((p.IsGenericTask || q.IsGenericTask) && anonymousMethodExpression.Block.IsAsync && p.IsGenericTask && q.IsGenericTask) { q = q.TypeArguments[0]; p = p.TypeArguments[0]; } if (q != p) { TypeSpec typeSpec = anonymousMethodExpression.InferReturnType(ec, null, delegate_type); if (typeSpec != null) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { typeSpec = ec.BuiltinTypes.Object; } if (typeSpec == p) { return 1; } if (typeSpec == q) { return 2; } } } } if (type == p) { return 1; } if (type == q) { return 2; } return IsBetterConversionTarget(ec, p, q); } private static int IsBetterConversionTarget(ResolveContext rc, TypeSpec p, TypeSpec q) { if ((p.Kind == MemberKind.Delegate || p.IsExpressionTreeType) && (q.Kind == MemberKind.Delegate || q.IsExpressionTreeType)) { if (p.Kind != MemberKind.Delegate) { p = TypeManager.GetTypeArguments(p)[0]; } if (q.Kind != MemberKind.Delegate) { q = TypeManager.GetTypeArguments(q)[0]; } MethodSpec invokeMethod = Delegate.GetInvokeMethod(p); MethodSpec invokeMethod2 = Delegate.GetInvokeMethod(q); p = invokeMethod.ReturnType; q = invokeMethod2.ReturnType; if (p.Kind == MemberKind.Void) { return (q.Kind != MemberKind.Void) ? 2 : 0; } if (q.Kind == MemberKind.Void) { return (p.Kind != MemberKind.Void) ? 1 : 0; } return IsBetterConversionTarget(rc, p, q); } if (p.IsGenericTask && q.IsGenericTask) { q = q.TypeArguments[0]; p = p.TypeArguments[0]; return IsBetterConversionTarget(rc, p, q); } TypeSpec p2 = p; if (p.IsNullableType) { p = NullableInfo.GetUnderlyingType(p); if (!BuiltinTypeSpec.IsPrimitiveTypeOrDecimal(p)) { return BetterTypeConversionImplicitConversion(rc, p2, q); } if (p == q) { return 2; } } TypeSpec q2 = q; if (q.IsNullableType) { q = NullableInfo.GetUnderlyingType(q); if (!BuiltinTypeSpec.IsPrimitiveTypeOrDecimal(q)) { return BetterTypeConversionImplicitConversion(rc, p2, q2); } if (q == p) { return 1; } } return BetterTypeConversion(rc, p, q); } public static int BetterTypeConversion(ResolveContext ec, TypeSpec p, TypeSpec q) { if (p == null || q == null) { throw new InternalErrorException("BetterTypeConversion got a null conversion"); } switch (p.BuiltinType) { case BuiltinTypeSpec.Type.Int: if (q.BuiltinType == BuiltinTypeSpec.Type.UInt || q.BuiltinType == BuiltinTypeSpec.Type.ULong) { return 1; } break; case BuiltinTypeSpec.Type.Long: if (q.BuiltinType == BuiltinTypeSpec.Type.ULong) { return 1; } break; case BuiltinTypeSpec.Type.SByte: switch (q.BuiltinType) { case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.ULong: return 1; } break; case BuiltinTypeSpec.Type.Short: switch (q.BuiltinType) { case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.ULong: return 1; } break; case BuiltinTypeSpec.Type.Dynamic: p = ec.Module.Compiler.BuiltinTypes.Object; break; } switch (q.BuiltinType) { case BuiltinTypeSpec.Type.Int: if (p.BuiltinType == BuiltinTypeSpec.Type.UInt || p.BuiltinType == BuiltinTypeSpec.Type.ULong) { return 2; } break; case BuiltinTypeSpec.Type.Long: if (p.BuiltinType == BuiltinTypeSpec.Type.ULong) { return 2; } break; case BuiltinTypeSpec.Type.SByte: switch (p.BuiltinType) { case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.ULong: return 2; } break; case BuiltinTypeSpec.Type.Short: switch (p.BuiltinType) { case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.ULong: return 2; } break; case BuiltinTypeSpec.Type.Dynamic: q = ec.Module.Compiler.BuiltinTypes.Object; break; } return BetterTypeConversionImplicitConversion(ec, p, q); } private static int BetterTypeConversionImplicitConversion(ResolveContext rc, TypeSpec p, TypeSpec q) { Expression expr = new EmptyExpression(p); Expression expr2 = new EmptyExpression(q); bool flag = Convert.ImplicitConversionExists(rc, expr, q); bool flag2 = Convert.ImplicitConversionExists(rc, expr2, p); if (flag && !flag2) { return 1; } if (flag2 && !flag) { return 2; } return 0; } private bool BetterFunction(ResolveContext ec, Arguments args, MemberSpec candidate, AParametersCollection cparam, bool candidate_params, MemberSpec best, AParametersCollection bparam, bool best_params) { AParametersCollection parameters = ((IParametersMember)candidate).Parameters; AParametersCollection parameters2 = ((IParametersMember)best).Parameters; int num = 0; int num2 = 0; bool flag = true; int num3 = args?.Count ?? 0; int num4 = 0; Argument argument = null; int num5 = 0; int num6 = 0; while (num4 < num3) { argument = args[num4]; if (argument.IsDefaultArgument) { break; } TypeSpec typeSpec; TypeSpec typeSpec2; if (argument is NamedArgument namedArgument) { int parameterIndexByName = cparam.GetParameterIndexByName(namedArgument.Name); typeSpec = parameters.Types[parameterIndexByName]; if (candidate_params && parameters.FixedParameters[parameterIndexByName].ModFlags == Parameter.Modifier.PARAMS) { typeSpec = TypeManager.GetElementType(typeSpec); } parameterIndexByName = bparam.GetParameterIndexByName(namedArgument.Name); typeSpec2 = parameters2.Types[parameterIndexByName]; if (best_params && parameters2.FixedParameters[parameterIndexByName].ModFlags == Parameter.Modifier.PARAMS) { typeSpec2 = TypeManager.GetElementType(typeSpec2); } } else { typeSpec = parameters.Types[num5]; typeSpec2 = parameters2.Types[num6]; if (candidate_params && parameters.FixedParameters[num5].ModFlags == Parameter.Modifier.PARAMS) { typeSpec = TypeManager.GetElementType(typeSpec); num5--; } if (best_params && parameters2.FixedParameters[num6].ModFlags == Parameter.Modifier.PARAMS) { typeSpec2 = TypeManager.GetElementType(typeSpec2); num6--; } } if (!TypeSpecComparer.IsEqual(typeSpec, typeSpec2)) { flag = false; switch (BetterExpressionConversion(ec, argument, typeSpec, typeSpec2)) { case 2: if ((restrictions & Restrictions.CovariantDelegate) != Restrictions.None) { return false; } num2++; break; default: num++; break; case 0: break; } } num4++; num5++; num6++; } if (num != 0 && num2 == 0) { return true; } if (num2 > 0 && num == 0) { return false; } if (!flag) { while (num4 < num3 && !args[num4++].IsDefaultArgument) { } if (parameters.Count < parameters2.Count) { if (candidate_params) { return false; } if (!parameters.FixedParameters[num4 - 1].HasDefaultValue) { return true; } if (parameters2.FixedParameters[num4].HasDefaultValue) { return true; } } else if (parameters.Count == parameters2.Count) { if (candidate_params) { return false; } if (!parameters.FixedParameters[num4 - 1].HasDefaultValue && parameters2.FixedParameters[num4 - 1].HasDefaultValue) { return true; } if (parameters.FixedParameters[num4 - 1].HasDefaultValue && parameters2.HasParams) { return true; } } return false; } if (candidate_params != best_params) { return !candidate_params; } bool flag2 = false; while (num4 < parameters.Count && num4 < parameters2.Count) { IParameterData parameterData = parameters.FixedParameters[num4]; IParameterData parameterData2 = parameters2.FixedParameters[num4]; if (parameterData.HasDefaultValue != parameterData2.HasDefaultValue && (!parameters.HasParams || !parameters2.HasParams)) { return parameterData.HasDefaultValue; } flag2 = true; if (parameters.Count == parameters2.Count) { if (!parameterData.HasDefaultValue) { break; } num4++; } else { num4++; } } if (parameters.Count != parameters2.Count) { if (flag2 && parameters2.Count - 1 == num4) { return parameters2.HasParams; } return parameters.Count < parameters2.Count; } if (best.IsGeneric != candidate.IsGeneric) { return best.IsGeneric; } AParametersCollection parameters3 = ((IParametersMember)candidate.MemberDefinition).Parameters; AParametersCollection parameters4 = ((IParametersMember)best.MemberDefinition).Parameters; bool flag3 = false; for (num4 = 0; num4 < num3; num4++) { NamedArgument namedArgument2 = ((num3 == 0) ? null : (args[num4] as NamedArgument)); TypeSpec typeSpec; TypeSpec typeSpec2; if (namedArgument2 != null) { typeSpec = parameters3.Types[cparam.GetParameterIndexByName(namedArgument2.Name)]; typeSpec2 = parameters4.Types[bparam.GetParameterIndexByName(namedArgument2.Name)]; } else { typeSpec = parameters3.Types[num4]; typeSpec2 = parameters4.Types[num4]; } if (typeSpec != typeSpec2) { TypeSpec typeSpec3 = MoreSpecific(typeSpec, typeSpec2); if (typeSpec3 == typeSpec2) { return false; } if (typeSpec3 == typeSpec) { flag3 = true; } } } if (flag3) { return true; } return false; } private static bool CheckInflatedArguments(MethodSpec ms) { if (!TypeParameterSpec.HasAnyTypeParameterTypeConstrained(ms.GenericDefinition)) { return true; } ConstraintChecker constraintChecker = new ConstraintChecker(null); TypeSpec[] types = ms.Parameters.Types; for (int i = 0; i < types.Length; i++) { if (types[i] is InflatedTypeSpec { TypeArguments: var typeArguments } inflatedTypeSpec && typeArguments.Length != 0 && !constraintChecker.CheckAll(inflatedTypeSpec.GetDefinition(), typeArguments, inflatedTypeSpec.Constraints, Location.Null)) { return false; } } return true; } public static void Error_ConstructorMismatch(ResolveContext rc, TypeSpec type, int argCount, Location loc) { rc.Report.Error(1729, loc, "The type `{0}' does not contain a constructor that takes `{1}' arguments", type.GetSignatureForError(), argCount.ToString()); } private int IsApplicable(ResolveContext ec, ref Arguments arguments, int arg_count, ref MemberSpec candidate, IParametersMember pm, ref bool params_expanded_form, ref bool dynamicArgument, ref TypeSpec returnType, bool errorMode) { AParametersCollection parameters = pm.Parameters; AParametersCollection parameters2 = ((IParametersMember)candidate).Parameters; int num = parameters.Count; int num2 = 0; Arguments arguments2 = arguments; if (arg_count != num) { if ((restrictions & Restrictions.CovariantDelegate) == 0) { for (int i = 0; i < parameters.Count; i++) { if (parameters.FixedParameters[i].HasDefaultValue) { num2 = parameters.Count - i; break; } } } if (num2 != 0) { if (parameters2.HasParams) { num2--; if (arg_count < num) { num--; } } else { if (arg_count > num) { int num3 = Math.Abs(arg_count - num); return 1000000000 + num3; } if (arg_count < num - num2) { int num4 = Math.Abs(num - num2 - arg_count); return 1000000000 + num4; } } } else if (arg_count != num) { int num5 = Math.Abs(arg_count - num); if (!parameters2.HasParams) { return 1000000000 + num5; } if (arg_count < num - 1) { return 1000000000 + num5; } } if (num2 != 0) { if (arguments == null) { arguments = new Arguments(num2); } else { Arguments arguments3 = new Arguments(num); arguments3.AddRange(arguments); arguments = arguments3; } for (int j = arg_count; j < num; j++) { arguments.Add(null); } } } if (arg_count > 0) { if (arguments[arg_count - 1] is NamedArgument) { arg_count = arguments.Count; for (int k = 0; k < arg_count; k++) { bool flag = false; while (arguments[k] is NamedArgument namedArgument) { int parameterIndexByName = parameters.GetParameterIndexByName(namedArgument.Name); if (parameterIndexByName < 0) { return 100000000 - k; } if (parameterIndexByName == k) { break; } Argument argument; if (parameterIndexByName >= num) { if ((parameters2.FixedParameters[parameterIndexByName].ModFlags & Parameter.Modifier.PARAMS) == 0) { break; } arguments.Add(null); arg_count++; argument = null; } else { if (parameterIndexByName == arg_count) { return 100000000 - k - 1; } argument = arguments[parameterIndexByName]; if (argument != null && !(argument is NamedArgument)) { return 100000000 - k - 1; } } if (!flag) { arguments = arguments.MarkOrderedArgument(namedArgument); flag = true; } if (arguments == arguments2) { arguments = new Arguments(arguments2.Count); arguments.AddRange(arguments2); } arguments[parameterIndexByName] = arguments[k]; arguments[k] = argument; if (argument == null) { break; } } } } else { arg_count = arguments.Count; } } else if (arguments != null) { arg_count = arguments.Count; } if (arg_count != num && !parameters2.HasParams) { return 10000000 - Math.Abs(num - arg_count); } List missingDependencies = candidate.GetMissingDependencies(); if (missingDependencies != null) { ImportedTypeDefinition.Error_MissingDependency(ec, missingDependencies, loc); return -1; } MethodSpec methodSpec = candidate as MethodSpec; TypeSpec[] types; if (methodSpec != null && methodSpec.IsGeneric) { if (type_arguments != null) { int arity = methodSpec.Arity; if (arity != type_arguments.Count) { return 100000 - Math.Abs(type_arguments.Count - arity); } if (type_arguments.Arguments != null) { methodSpec = methodSpec.MakeGenericMethod(ec, type_arguments.Arguments); } } else { if (lambda_conv_msgs == null) { for (int l = 0; l < arg_count; l++) { Argument argument2 = arguments[l]; if (argument2 != null && argument2.Expr is AnonymousMethodExpression anonymousMethodExpression) { if (lambda_conv_msgs == null) { lambda_conv_msgs = new SessionReportPrinter(); } anonymousMethodExpression.TypeInferenceReportPrinter = lambda_conv_msgs; } } } TypeInference typeInference = new TypeInference(arguments); TypeSpec[] array = typeInference.InferMethodArguments(ec, methodSpec); if (array == null) { return 100000 - typeInference.InferenceScore; } if (lambda_conv_msgs != null) { lambda_conv_msgs.ClearSession(); } if (array.Length != 0) { if (!errorMode) { for (int m = 0; m < array.Length; m++) { TypeSpec typeSpec = array[m]; if (!typeSpec.IsAccessible(ec)) { return 100000 - m; } } } methodSpec = methodSpec.MakeGenericMethod(ec, array); } } if (!CheckInflatedArguments(methodSpec)) { candidate = methodSpec; return 10000; } if (candidate != pm) { MethodSpec methodSpec2 = (MethodSpec)pm; returnType = new TypeParameterInflator(ec, methodSpec.DeclaringType, methodSpec2.GenericDefinition.TypeParameters, methodSpec.TypeArguments).Inflate(returnType); } else { returnType = methodSpec.ReturnType; } candidate = methodSpec; parameters = methodSpec.Parameters; types = parameters.Types; } else { if (type_arguments != null) { return 1000000; } types = parameters2.Types; } Parameter.Modifier modifier = Parameter.Modifier.NONE; TypeSpec typeSpec2 = null; for (int n = 0; n < arg_count; n++) { Argument argument3 = arguments[n]; if (argument3 == null) { IParameterData parameterData = parameters.FixedParameters[n]; if (!parameterData.HasDefaultValue) { arguments = arguments2; return arg_count * 2 + 2; } Expression expression = parameterData.DefaultValue; if (expression != null) { expression = ResolveDefaultValueArgument(ec, types[n], expression, loc); if (expression == null) { for (int num6 = n; num6 < arg_count; num6++) { arguments.RemoveAt(n); } return (arg_count - n) * 2 + 1; } } if ((parameterData.ModFlags & Parameter.Modifier.CallerMask) != Parameter.Modifier.NONE) { if ((parameterData.ModFlags & Parameter.Modifier.CallerLineNumber) != Parameter.Modifier.NONE) { expression = new IntLiteral(ec.BuiltinTypes, loc.Row, loc); } else if ((parameterData.ModFlags & Parameter.Modifier.CallerFilePath) != Parameter.Modifier.NONE) { expression = new StringLiteral(ec.BuiltinTypes, loc.SourceFile.GetFullPathName(ec.Module.Compiler.Settings.PathMap), loc); } else if (ec.MemberContext.CurrentMemberDefinition != null) { expression = new StringLiteral(ec.BuiltinTypes, ec.MemberContext.CurrentMemberDefinition.GetCallerMemberName(), loc); } } arguments[n] = new Argument(expression, Argument.AType.Default); continue; } if (modifier != Parameter.Modifier.PARAMS) { modifier = (parameters.FixedParameters[n].ModFlags & ~Parameter.Modifier.PARAMS) | (parameters2.FixedParameters[n].ModFlags & Parameter.Modifier.PARAMS); typeSpec2 = types[n]; } else if (!params_expanded_form) { params_expanded_form = true; typeSpec2 = ((ElementTypeSpec)typeSpec2).Element; n -= 2; continue; } int num7 = 1; if (!params_expanded_form) { if (argument3.IsExtensionType) { if (ExtensionMethodGroupExpr.IsExtensionTypeCompatible(argument3.Type, typeSpec2)) { num7 = 0; continue; } } else { num7 = IsArgumentCompatible(ec, argument3, modifier, typeSpec2); if (num7 < 0) { dynamicArgument = true; } } } if (num7 != 0 && (modifier & Parameter.Modifier.PARAMS) != Parameter.Modifier.NONE && (restrictions & Restrictions.CovariantDelegate) == 0) { if (!params_expanded_form) { typeSpec2 = ((ElementTypeSpec)typeSpec2).Element; } if (num7 > 0) { num7 = IsArgumentCompatible(ec, argument3, Parameter.Modifier.NONE, typeSpec2); } if (num7 < 0) { params_expanded_form = true; dynamicArgument = true; } else if (num7 == 0 || arg_count > parameters.Count) { params_expanded_form = true; } } if (num7 <= 0) { continue; } if (params_expanded_form) { num7++; } return (arg_count - n) * 2 + num7; } if (dynamicArgument) { arguments = arguments2; } return 0; } public static Expression ResolveDefaultValueArgument(ResolveContext ec, TypeSpec ptype, Expression e, Location loc) { if (e is Constant && e.Type == ptype) { return e; } if (e == EmptyExpression.MissingValue && (ptype.BuiltinType == BuiltinTypeSpec.Type.Object || ptype.BuiltinType == BuiltinTypeSpec.Type.Dynamic)) { e = new MemberAccess(new MemberAccess(new MemberAccess(new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", loc), "Reflection", loc), "Missing", loc), "Value", loc); } else if (e is Constant) { e = Convert.ImplicitConversionStandard(ec, e, ptype, loc); if (e == null) { return null; } } else { e = new DefaultValueExpression(new TypeExpression(ptype, loc), loc); } return e.Resolve(ec); } private int IsArgumentCompatible(ResolveContext ec, Argument argument, Parameter.Modifier param_mod, TypeSpec parameter) { if (((argument.Modifier | param_mod) & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { TypeSpec typeSpec = argument.Type; if ((argument.Modifier & Parameter.Modifier.RefOutMask) != (param_mod & Parameter.Modifier.RefOutMask)) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) { return -1; } return 1; } if (typeSpec != parameter) { if (typeSpec == InternalType.VarOutType || typeSpec == InternalType.Discard) { return 0; } if (typeSpec is ReferenceContainer referenceContainer) { typeSpec = referenceContainer.Element; } if (!TypeSpecComparer.IsEqual(typeSpec, parameter)) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (argument.Modifier & Parameter.Modifier.RefOutMask) == 0 && (restrictions & Restrictions.CovariantDelegate) == 0) { return -1; } return 2; } } } else { if (argument.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && (restrictions & Restrictions.CovariantDelegate) == 0) { return -1; } if (!Convert.ImplicitConversionExists(ec, argument.Expr, parameter)) { return (parameter.IsDelegate && argument.Expr is AnonymousMethodExpression) ? 2 : 3; } } return 0; } private static TypeSpec MoreSpecific(TypeSpec p, TypeSpec q) { if (p.IsGenericParameter != q.IsGenericParameter) { return p.IsGenericParameter ? q : p; } if (p is ArrayContainer arrayContainer) { if (!(q is ArrayContainer arrayContainer2)) { return null; } TypeSpec typeSpec = MoreSpecific(arrayContainer.Element, arrayContainer2.Element); if (typeSpec == arrayContainer.Element) { return p; } if (typeSpec == arrayContainer2.Element) { return q; } return null; } if (p.IsGeneric && q.IsGeneric) { TypeSpec[] typeArguments = p.TypeArguments; TypeSpec[] typeArguments2 = q.TypeArguments; bool flag = false; bool flag2 = false; for (int i = 0; i < typeArguments.Length; i++) { TypeSpec typeSpec2 = MoreSpecific(typeArguments[i], typeArguments2[i]); if (typeSpec2 == typeArguments[i]) { flag = true; } if (typeSpec2 == typeArguments2[i]) { flag2 = true; } } if (flag && !flag2) { return p; } if (!flag && flag2) { return q; } } return null; } public T ResolveMember(ResolveContext rc, ref Arguments args) where T : MemberSpec, IParametersMember { List list = null; Arguments args2 = null; bool flag = false; bool flag2 = false; IParametersMember parametersMember = null; int arg_count = ((args != null) ? args.Count : 0); Arguments arguments = args; bool flag3 = false; MemberSpec memberSpec = null; int num = 0; MemberSpec memberSpec2; int num2; while (true) { memberSpec2 = null; num2 = int.MaxValue; IList baseMembers = members; do { for (int i = 0; i < baseMembers.Count; i++) { MemberSpec candidate = baseMembers[i]; if ((candidate.Modifiers & Modifiers.OVERRIDE) != 0 || (!flag3 && (!candidate.IsAccessible(rc) || (rc.IsRuntimeBinder && !candidate.DeclaringType.IsAccessible(rc)) || ((candidate.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED && instance_qualifier != null && !instance_qualifier.CheckProtectedMemberAccess(rc, candidate))))) { continue; } IParametersMember parametersMember2 = candidate as IParametersMember; if (parametersMember2 == null) { if (Invocation.IsMemberInvocable(candidate)) { memberSpec = candidate; } continue; } if ((candidate.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL)) != 0) { IParametersMember overrideMemberParameters = base_provider.GetOverrideMemberParameters(candidate); if (overrideMemberParameters != null) { parametersMember2 = overrideMemberParameters; } } bool params_expanded_form = false; bool dynamicArgument = false; TypeSpec returnType = parametersMember2.MemberType; int num3 = IsApplicable(rc, ref arguments, arg_count, ref candidate, parametersMember2, ref params_expanded_form, ref dynamicArgument, ref returnType, flag3); if (lambda_conv_msgs != null) { lambda_conv_msgs.EndSession(); } if (num3 < num2) { if (num3 < 0) { return null; } num = 1; if ((restrictions & Restrictions.GetEnumeratorLookup) == 0 || arguments.Count == 0) { num2 = num3; memberSpec2 = candidate; args2 = arguments; flag = params_expanded_form; flag2 = dynamicArgument; parametersMember = parametersMember2; best_candidate_return_type = returnType; } } else if (num3 == 0) { if ((restrictions & Restrictions.BaseMembersIncluded) != Restrictions.None && TypeSpec.IsBaseClass(memberSpec2.DeclaringType, candidate.DeclaringType, dynamicIsObject: true)) { continue; } num++; bool flag4; if (memberSpec2.DeclaringType.IsInterface && candidate.DeclaringType.ImplementsInterface(memberSpec2.DeclaringType, variantly: false)) { flag4 = true; if (list != null) { foreach (AmbiguousCandidate item in list) { if (candidate.DeclaringType.ImplementsInterface(memberSpec2.DeclaringType, variantly: false)) { continue; } flag4 = false; break; } if (flag4) { list = null; } } } else { flag4 = BetterFunction(rc, arguments, candidate, parametersMember2.Parameters, params_expanded_form, memberSpec2, parametersMember.Parameters, flag); } if (flag4) { memberSpec2 = candidate; args2 = arguments; flag = params_expanded_form; flag2 = dynamicArgument; parametersMember = parametersMember2; best_candidate_return_type = returnType; } else { if (list == null) { list = new List(); } list.Add(new AmbiguousCandidate(candidate, parametersMember2.Parameters, params_expanded_form)); } } arguments = args; } } while (num2 != 0 && (baseMembers = base_provider.GetBaseMembers(baseMembers[0].DeclaringType)) != null); if (num2 == 0) { break; } if (!flag3) { MethodGroupExpr methodGroupExpr = base_provider.LookupExtensionMethod(rc); if (methodGroupExpr != null) { methodGroupExpr = methodGroupExpr.OverloadResolve(rc, ref args, null, restrictions); if (methodGroupExpr != null) { best_candidate_extension_group = methodGroupExpr; return (T)(MemberSpec)methodGroupExpr.BestCandidate; } } } if (IsProbingOnly) { return null; } if (flag3 || (lambda_conv_msgs != null && !lambda_conv_msgs.IsEmpty)) { break; } lambda_conv_msgs = null; flag3 = true; } if (num2 != 0 || flag3) { ReportOverloadError(rc, memberSpec2, parametersMember, args2, flag); return null; } if (flag2) { if (args[0].IsExtensionType) { rc.Report.Error(1973, loc, "Type `{0}' does not contain a member `{1}' and the best extension method overload `{2}' cannot be dynamically dispatched. Consider calling the method without the extension method syntax", args[0].Type.GetSignatureForError(), memberSpec2.Name, memberSpec2.GetSignatureForError()); } if (num == 1 && memberSpec2.IsGeneric && type_arguments != null && memberSpec2 is MethodSpec methodSpec && TypeParameterSpec.HasAnyTypeParameterConstrained(methodSpec.GenericDefinition)) { new ConstraintChecker(rc).CheckAll(methodSpec.GetGenericMethodDefinition(), methodSpec.TypeArguments, methodSpec.Constraints, loc); } BestCandidateIsDynamic = true; return null; } if ((restrictions & (Restrictions.ProbingOnly | Restrictions.CovariantDelegate)) == (Restrictions.ProbingOnly | Restrictions.CovariantDelegate)) { return (T)memberSpec2; } if (list != null) { for (int j = 0; j < list.Count; j++) { AmbiguousCandidate ambiguousCandidate = list[j]; if (!BetterFunction(rc, args2, memberSpec2, parametersMember.Parameters, flag, ambiguousCandidate.Member, ambiguousCandidate.Parameters, ambiguousCandidate.Expanded)) { MemberSpec member = ambiguousCandidate.Member; if (custom_errors == null || !custom_errors.AmbiguousCandidates(rc, memberSpec2, member)) { rc.Report.SymbolRelatedToPreviousError(memberSpec2); rc.Report.SymbolRelatedToPreviousError(member); rc.Report.Error(121, loc, "The call is ambiguous between the following methods or properties: `{0}' and `{1}'", memberSpec2.GetSignatureForError(), member.GetSignatureForError()); } return (T)memberSpec2; } } } if (memberSpec != null && !IsProbingOnly) { rc.Report.SymbolRelatedToPreviousError(memberSpec2); rc.Report.SymbolRelatedToPreviousError(memberSpec); rc.Report.Warning(467, 2, loc, "Ambiguity between method `{0}' and invocable non-method `{1}'. Using method group", memberSpec2.GetSignatureForError(), memberSpec.GetSignatureForError()); } if (!VerifyArguments(rc, ref args2, memberSpec2, parametersMember, flag)) { return null; } if (memberSpec2 == null) { return null; } if (!IsProbingOnly && !rc.IsInProbingMode) { memberSpec2.CheckObsoleteness(rc, loc); memberSpec2.MemberDefinition.SetIsUsed(); } args = args2; return (T)memberSpec2; } public MethodSpec ResolveOperator(ResolveContext rc, ref Arguments args) { return ResolveMember(rc, ref args); } private void ReportArgumentMismatch(ResolveContext ec, int idx, MemberSpec method, Argument a, AParametersCollection expected_par, TypeSpec paramType) { if ((custom_errors != null && custom_errors.ArgumentMismatch(ec, method, a, idx)) || a.Type == InternalType.ErrorType) { return; } if (a is CollectionElementInitializer.ElementInitializerArgument) { ec.Report.SymbolRelatedToPreviousError(method); if ((expected_par.FixedParameters[idx].ModFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { ec.Report.Error(1954, loc, "The best overloaded collection initalizer method `{0}' cannot have `ref' or `out' modifier", TypeManager.CSharpSignature(method)); return; } ec.Report.Error(1950, loc, "The best overloaded collection initalizer method `{0}' has some invalid arguments", TypeManager.CSharpSignature(method)); } else if (IsDelegateInvoke) { ec.Report.Error(1594, loc, "Delegate `{0}' has some invalid arguments", DelegateType.GetSignatureForError()); } else { ec.Report.SymbolRelatedToPreviousError(method); ec.Report.Error(1502, loc, "The best overloaded method match for `{0}' has some invalid arguments", method.GetSignatureForError()); } Parameter.Modifier modifier = ((idx < expected_par.Count) ? expected_par.FixedParameters[idx].ModFlags : Parameter.Modifier.NONE); string text = (idx + 1).ToString(); if (((modifier & Parameter.Modifier.RefOutMask) ^ (a.Modifier & Parameter.Modifier.RefOutMask)) != Parameter.Modifier.NONE) { if ((modifier & Parameter.Modifier.RefOutMask) == 0) { ec.Report.Error(1615, a.Expr.Location, "Argument `#{0}' does not require `{1}' modifier. Consider removing `{1}' modifier", text, Parameter.GetModifierSignature(a.Modifier)); } else { ec.Report.Error(1620, a.Expr.Location, "Argument `#{0}' is missing `{1}' modifier", text, Parameter.GetModifierSignature(modifier)); } return; } string text2 = a.GetSignatureForError(); string text3 = paramType.GetSignatureForError(); if (text2 == text3) { text2 = a.Type.GetSignatureForErrorIncludingAssemblyName(); text3 = paramType.GetSignatureForErrorIncludingAssemblyName(); } if ((modifier & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { text2 = Parameter.GetModifierSignature(a.Modifier) + " " + text2; text3 = Parameter.GetModifierSignature(a.Modifier) + " " + text3; } ec.Report.Error(1503, a.Expr.Location, "Argument `#{0}' cannot convert `{1}' expression to type `{2}'", text, text2, text3); } private void ReportOverloadError(ResolveContext rc, MemberSpec best_candidate, IParametersMember pm, Arguments args, bool params_expanded) { int num = ((type_arguments != null) ? type_arguments.Count : 0); int num2 = args?.Count ?? 0; if (num != best_candidate.Arity && (num > 0 || ((IParametersMember)best_candidate).Parameters.IsEmpty)) { MethodGroupExpr methodGroupExpr = new MethodGroupExpr(new MemberSpec[1] { best_candidate }, best_candidate.DeclaringType, loc); methodGroupExpr.Error_TypeArgumentsCannotBeUsed(rc, best_candidate, loc); } else { if (lambda_conv_msgs != null && lambda_conv_msgs.Merge(rc.Report.Printer)) { return; } if ((best_candidate.Modifiers & (Modifiers.PROTECTED | Modifiers.STATIC)) == Modifiers.PROTECTED && InstanceQualifier != null && !InstanceQualifier.CheckProtectedMemberAccess(rc, best_candidate)) { MemberExpr.Error_ProtectedMemberAccess(rc, best_candidate, InstanceQualifier.InstanceType, loc); } if (pm != null && (pm.Parameters.Count == num2 || params_expanded || HasUnfilledParams(best_candidate, pm, args))) { if (!best_candidate.IsAccessible(rc) || !best_candidate.DeclaringType.IsAccessible(rc)) { rc.Report.SymbolRelatedToPreviousError(best_candidate); Expression.ErrorIsInaccesible(rc, best_candidate.GetSignatureForError(), loc); return; } if (best_candidate is MethodSpec { IsGeneric: not false } methodSpec) { bool flag = true; if (methodSpec.TypeArguments != null) { flag = new ConstraintChecker(rc.MemberContext).CheckAll(methodSpec.GetGenericMethodDefinition(), methodSpec.TypeArguments, methodSpec.Constraints, loc); } if (num == 0 && methodSpec.TypeArguments == null) { if ((custom_errors == null || !custom_errors.TypeInferenceFailed(rc, best_candidate)) && flag) { rc.Report.Error(411, loc, "The type arguments for method `{0}' cannot be inferred from the usage. Try specifying the type arguments explicitly", methodSpec.GetGenericMethodDefinition().GetSignatureForError()); } return; } } VerifyArguments(rc, ref args, best_candidate, pm, params_expanded); } else if (custom_errors == null || !custom_errors.NoArgumentMatch(rc, best_candidate)) { if (best_candidate.Kind == MemberKind.Constructor) { rc.Report.SymbolRelatedToPreviousError(best_candidate); Error_ConstructorMismatch(rc, best_candidate.DeclaringType, num2, loc); } else if (IsDelegateInvoke) { rc.Report.SymbolRelatedToPreviousError(DelegateType); rc.Report.Error(1593, loc, "Delegate `{0}' does not take `{1}' arguments", DelegateType.GetSignatureForError(), num2.ToString()); } else { string arg = ((best_candidate.Kind == MemberKind.Indexer) ? "this" : best_candidate.Name); rc.Report.SymbolRelatedToPreviousError(best_candidate); rc.Report.Error(1501, loc, "No overload for method `{0}' takes `{1}' arguments", arg, num2.ToString()); } } } } private static bool HasUnfilledParams(MemberSpec best_candidate, IParametersMember pm, Arguments args) { AParametersCollection parameters = ((IParametersMember)best_candidate).Parameters; if (!parameters.HasParams) { return false; } string text = null; for (int num = parameters.Count - 1; num != 0; num--) { IParameterData parameterData = parameters.FixedParameters[num]; if ((parameterData.ModFlags & Parameter.Modifier.PARAMS) != Parameter.Modifier.NONE) { text = parameterData.Name; break; } } if (args == null) { return false; } foreach (Argument arg in args) { if (!(arg is NamedArgument namedArgument) || !(namedArgument.Name == text)) { continue; } text = null; break; } if (text == null) { return false; } return args.Count + 1 == pm.Parameters.Count; } private bool VerifyArguments(ResolveContext ec, ref Arguments args, MemberSpec member, IParametersMember pm, bool chose_params_expanded) { AParametersCollection parameters = pm.Parameters; AParametersCollection parameters2 = ((IParametersMember)member).Parameters; TypeSpec[] types = parameters2.Types; Parameter.Modifier modifier = Parameter.Modifier.NONE; TypeSpec typeSpec = null; int i = 0; int j = 0; Argument argument = null; ArrayInitializer arrayInitializer = null; bool flag = pm.MemberType.IsPointer; int num; for (num = ((args != null) ? args.Count : 0); i < num; i++, j++) { argument = args[i]; if (argument == null) { continue; } if (modifier != Parameter.Modifier.PARAMS) { modifier = parameters2.FixedParameters[i].ModFlags; typeSpec = types[i]; flag |= typeSpec.IsPointer; if (modifier == Parameter.Modifier.PARAMS && chose_params_expanded) { arrayInitializer = new ArrayInitializer(num - i, argument.Expr.Location); typeSpec = TypeManager.GetElementType(typeSpec); } } if (((argument.Modifier | modifier) & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { if ((argument.Modifier & Parameter.Modifier.RefOutMask) != (modifier & Parameter.Modifier.RefOutMask)) { break; } TypeSpec type = argument.Type; if (type == typeSpec) { continue; } if (type == InternalType.VarOutType) { ((DeclarationExpression)argument.Expr).Variable.Type = typeSpec; continue; } if (type == InternalType.Discard) { argument.Expr.Type = typeSpec; continue; } if (type is ReferenceContainer referenceContainer) { if (referenceContainer.Element != typeSpec) { break; } return true; } if (!TypeSpecComparer.IsEqual(type, typeSpec)) { break; } } if (argument is NamedArgument namedArgument) { int parameterIndexByName = parameters.GetParameterIndexByName(namedArgument.Name); if (parameterIndexByName < 0 || parameterIndexByName >= parameters.Count) { if (IsDelegateInvoke) { ec.Report.SymbolRelatedToPreviousError(DelegateType); ec.Report.Error(1746, namedArgument.Location, "The delegate `{0}' does not contain a parameter named `{1}'", DelegateType.GetSignatureForError(), namedArgument.Name); } else { ec.Report.SymbolRelatedToPreviousError(member); ec.Report.Error(1739, namedArgument.Location, "The best overloaded method match for `{0}' does not contain a parameter named `{1}'", TypeManager.CSharpSignature(member), namedArgument.Name); } } else if (args[parameterIndexByName] != argument && args[parameterIndexByName] != null) { if (IsDelegateInvoke) { ec.Report.SymbolRelatedToPreviousError(DelegateType); } else { ec.Report.SymbolRelatedToPreviousError(member); } if (parameterIndexByName > i) { ec.Report.Error(8323, namedArgument.Location, "Named argument `{0}' is used out of position but is followed by positional argument", namedArgument.Name); } else { ec.Report.Error(1744, namedArgument.Location, "Named argument `{0}' cannot be used for a parameter which has positional argument specified", namedArgument.Name); } } } if (argument.Expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { continue; } if ((restrictions & Restrictions.CovariantDelegate) != Restrictions.None && !Delegate.IsTypeCovariant(ec, argument.Expr.Type, typeSpec)) { if (argument.IsExtensionType) { MemberAccess memberAccess = new MemberAccess(argument.Expr, member.Name, loc); memberAccess.Error_TypeDoesNotContainDefinition(ec, argument.Expr.Type, memberAccess.Name); } else { custom_errors.NoArgumentMatch(ec, member); } return false; } Expression expression; if (argument.IsExtensionType) { if (argument.Expr.Type == typeSpec || TypeSpecComparer.IsEqual(argument.Expr.Type, typeSpec)) { expression = argument.Expr; } else { expression = Convert.ImplicitReferenceConversion(argument.Expr, typeSpec, explicit_cast: false); if (expression == null) { expression = Convert.ImplicitBoxingConversion(argument.Expr, argument.Expr.Type, typeSpec); } } } else { expression = Convert.ImplicitConversion(ec, argument.Expr, typeSpec, loc); } if (expression == null) { break; } if (arrayInitializer != null) { arrayInitializer.Add(argument.Expr); args.RemoveAt(i--); num--; argument.Expr = expression; } else { argument.Expr = expression; } } if (i != num) { for (; i < num; i++) { Argument argument2 = args[i]; if (argument2 != null && argument2.Type == InternalType.VarOutType) { ((DeclarationExpression)argument2.Expr).Variable.Type = InternalType.ErrorType; } } ReportArgumentMismatch(ec, j, member, argument, parameters, typeSpec); return false; } if (arrayInitializer == null && num + 1 == parameters.Count) { if (args == null) { args = new Arguments(1); } typeSpec = types[parameters.Count - 1]; typeSpec = TypeManager.GetElementType(typeSpec); flag |= typeSpec.IsPointer; arrayInitializer = new ArrayInitializer(0, loc); } if (arrayInitializer != null) { args.Add(new Argument(new ArrayCreation(new TypeExpression(typeSpec, loc), arrayInitializer, loc).Resolve(ec))); num++; } if (flag) { if (ec.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(ec, loc); } else if (!ec.IsUnsafe) { Expression.UnsafeError(ec, loc); } } if (type_arguments == null && member.IsGeneric) { MethodSpec methodSpec = (MethodSpec)member; TypeSpec[] typeArguments = methodSpec.TypeArguments; foreach (TypeSpec typeSpec2 in typeArguments) { if (!typeSpec2.IsAccessible(ec)) { ec.Report.SymbolRelatedToPreviousError(typeSpec2); Expression.ErrorIsInaccesible(ec, member.GetSignatureForError(), loc); break; } } } return true; } } internal class ConstantExpr : MemberExpr { private readonly ConstSpec constant; public override string Name { get { throw new NotImplementedException(); } } public override string KindName => "constant"; public override bool IsInstance => !IsStatic; public override bool IsStatic => true; protected override TypeSpec DeclaringType => constant.DeclaringType; public ConstantExpr(ConstSpec constant, Location loc) { this.constant = constant; base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext rc) { ResolveInstanceExpression(rc, null); DoBestMemberChecks(rc, this.constant); if (rc.HasSet(ResolveContext.Options.NameOfScope)) { eclass = ExprClass.Value; type = this.constant.MemberType; return this; } Constant constant = this.constant.GetConstant(rc); return Constant.CreateConstantFromValue(this.constant.MemberType, constant.GetValue(), loc); } public override void Emit(EmitContext ec) { throw new NotSupportedException(); } public override string GetSignatureForError() { return constant.GetSignatureForError(); } public override void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { constant.CheckObsoleteness(rc, expr.Location); } public override void SetTypeArguments(ResolveContext ec, TypeArguments ta) { Expression.Error_TypeArgumentsCannotBeUsed(ec, "constant", GetSignatureForError(), loc); } } internal class FieldExpr : MemberExpr, IDynamicAssign, IAssignMethod, IMemoryLocation, IVariableReference, IFixedExpression { protected FieldSpec spec; private VariableInfo variable_info; private LocalTemporary temp; private bool prepared; public override string Name => spec.Name; public bool IsHoisted => InstanceExpression is IVariableReference variableReference && variableReference.IsHoisted; public override bool IsInstance => !spec.IsStatic; public override bool IsStatic => spec.IsStatic; public override string KindName => "field"; public FieldSpec Spec => spec; protected override TypeSpec DeclaringType => spec.DeclaringType; public VariableInfo VariableInfo => variable_info; public bool IsFixed { get { if (InstanceExpression is IVariableReference variableReference) { return InstanceExpression.Type.IsStruct && variableReference.IsFixed; } return InstanceExpression is IFixedExpression fixedExpression && fixedExpression.IsFixed; } } protected FieldExpr(Location l) { loc = l; } public FieldExpr(FieldSpec spec, Location loc) { this.spec = spec; base.loc = loc; type = spec.MemberType; } public FieldExpr(FieldBase fi, Location l) : this(fi.Spec, l) { } public override string GetSignatureForError() { return spec.GetSignatureForError(); } public bool IsMarshalByRefAccess(ResolveContext rc) { return !spec.IsStatic && TypeSpec.IsValueType(spec.MemberType) && !(InstanceExpression is This) && rc.Module.PredefinedTypes.MarshalByRefObject.Define() && TypeSpec.IsBaseClass(spec.DeclaringType, rc.Module.PredefinedTypes.MarshalByRefObject.TypeSpec, dynamicIsObject: false); } public void SetHasAddressTaken() { if (InstanceExpression is IVariableReference variableReference) { variableReference.SetHasAddressTaken(); } } protected override void CloneTo(CloneContext clonectx, Expression target) { FieldExpr fieldExpr = (FieldExpr)target; if (InstanceExpression != null) { fieldExpr.InstanceExpression = InstanceExpression.Clone(clonectx); } } public override Expression CreateExpressionTree(ResolveContext ec) { if (base.ConditionalAccess) { Error_NullShortCircuitInsideExpressionTree(ec); } return CreateExpressionTree(ec, convertInstance: true); } public Expression CreateExpressionTree(ResolveContext ec, bool convertInstance) { Expression expression; Arguments arguments; if (InstanceExpression == null) { expression = new NullLiteral(loc); } else if (convertInstance) { expression = InstanceExpression.CreateExpressionTree(ec); } else { arguments = new Arguments(1); arguments.Add(new Argument(InstanceExpression)); expression = CreateExpressionFactoryCall(ec, "Constant", arguments); } arguments = Arguments.CreateForExpressionTree(ec, null, expression, CreateTypeOfExpression()); return CreateExpressionFactoryCall(ec, "Field", arguments); } public Expression CreateTypeOfExpression() { return new TypeOfField(spec, loc); } protected override Expression DoResolve(ResolveContext ec) { spec.MemberDefinition.SetIsUsed(); return DoResolve(ec, null); } private Expression DoResolve(ResolveContext ec, Expression rhs) { bool flag = rhs != null && IsInstance && spec.DeclaringType.IsStruct; if (rhs != this) { ResolveConditionalAccessReceiver(ec); if (ResolveInstanceExpression(ec, rhs)) { if (flag) { Expression right_side = ((rhs == EmptyExpression.OutAccess || rhs == EmptyExpression.LValueMemberOutAccess) ? EmptyExpression.LValueMemberOutAccess : EmptyExpression.LValueMemberAccess); InstanceExpression = InstanceExpression.ResolveLValue(ec, right_side); } else { InstanceExpression = InstanceExpression.Resolve(ec, ResolveFlags.VariableOrValue); } if (InstanceExpression == null) { return null; } } DoBestMemberChecks(ec, spec); if (conditional_access_receiver) { ec.With(ResolveContext.Options.DontSetConditionalAccessReceiver, enable: false); } } FixedFieldSpec fixedFieldSpec = spec as FixedFieldSpec; IVariableReference variableReference = InstanceExpression as IVariableReference; if (fixedFieldSpec != null) { IFixedExpression fixedExpression = InstanceExpression as IFixedExpression; if (!ec.HasSet(ResolveContext.Options.FixedInitializerScope) && (fixedExpression == null || !fixedExpression.IsFixed)) { ec.Report.Error(1666, loc, "You cannot use fixed size buffers contained in unfixed expressions. Try using the fixed statement"); } if (InstanceExpression.eclass != ExprClass.Variable) { ec.Report.SymbolRelatedToPreviousError(spec); ec.Report.Error(1708, loc, "`{0}': Fixed size buffers can only be accessed through locals or fields", TypeManager.GetFullNameSignature(spec)); } else if (variableReference != null && variableReference.IsHoisted) { AnonymousMethodExpression.Error_AddressOfCapturedVar(ec, variableReference, loc); } return new FixedBufferPtr(this, fixedFieldSpec.ElementType, loc).Resolve(ec); } if (variableReference != null && variableReference.VariableInfo != null && InstanceExpression.Type.IsStruct) { variable_info = variableReference.VariableInfo.GetStructFieldInfo(Name); } if (conditional_access_receiver) { type = LiftMemberType(ec, type); } if (base.ConditionalAccess && InstanceExpression != null && InstanceExpression.IsNull) { return Constant.CreateConstantFromValue(type, null, loc); } eclass = ExprClass.Variable; return this; } public override void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { spec.CheckObsoleteness(rc, expr.Location); } public void SetFieldAssigned(FlowAnalysisContext fc) { if (!IsInstance) { return; } if (spec.DeclaringType.IsStruct && InstanceExpression is IVariableReference { VariableInfo: not null } variableReference) { fc.SetStructFieldAssigned(variableReference.VariableInfo, Name); } FieldExpr fieldExpr = InstanceExpression as FieldExpr; if (fieldExpr != null) { Expression instanceExpression; while (true) { instanceExpression = fieldExpr.InstanceExpression; FieldExpr fieldExpr2 = instanceExpression as FieldExpr; if ((fieldExpr2 != null && !fieldExpr2.IsStatic) || instanceExpression is LocalVariableReference) { if (TypeSpec.IsReferenceType(fieldExpr.Type) && instanceExpression.Type.IsStruct && InstanceExpression is IVariableReference { VariableInfo: null } && (!(instanceExpression is IVariableReference variableReference3) || (variableReference3.VariableInfo != null && !fc.IsDefinitelyAssigned(variableReference3.VariableInfo)))) { fc.Report.Warning(1060, 1, fieldExpr.loc, "Use of possibly unassigned field `{0}'", fieldExpr.Name); } if (fieldExpr2 != null) { fieldExpr = fieldExpr2; bool flag = true; continue; } break; } break; } if (instanceExpression != null && TypeSpec.IsReferenceType(instanceExpression.Type)) { instanceExpression.FlowAnalysis(fc); } } else if (TypeSpec.IsReferenceType(InstanceExpression.Type)) { InstanceExpression.FlowAnalysis(fc); } } private Expression Error_AssignToReadonly(ResolveContext rc, Expression right_side) { if (right_side == EmptyExpression.OutAccess) { if (IsStatic) { rc.Report.Error(199, loc, "A static readonly field `{0}' cannot be passed ref or out (except in a static constructor)", GetSignatureForError()); } else { rc.Report.Error(192, loc, "A readonly field `{0}' cannot be passed ref or out (except in a constructor)", GetSignatureForError()); } return ErrorExpression.Instance; } if (right_side == EmptyExpression.LValueMemberAccess) { return ErrorExpression.Instance; } if (right_side == EmptyExpression.LValueMemberOutAccess) { if (IsStatic) { rc.Report.Error(1651, loc, "Fields of static readonly field `{0}' cannot be passed ref or out (except in a static constructor)", GetSignatureForError()); } else { rc.Report.Error(1649, loc, "Members of readonly field `{0}' cannot be passed ref or out (except in a constructor)", GetSignatureForError()); } return ErrorExpression.Instance; } if (IsStatic) { rc.Report.Error(198, loc, "A static readonly field `{0}' cannot be assigned to (except in a static constructor or a variable initializer)", GetSignatureForError()); } else { rc.Report.Error(191, loc, "A readonly field `{0}' cannot be assigned to (except in a constructor or a variable initializer)", GetSignatureForError()); } return ErrorExpression.Instance; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { if (HasConditionalAccess()) { Error_NullPropagatingLValue(ec); } if (spec is FixedFieldSpec) { Error_ValueAssignment(ec, right_side); } Expression expression = DoResolve(ec, right_side); if (expression == null) { return null; } spec.MemberDefinition.SetIsAssigned(); if ((right_side == EmptyExpression.UnaryAddress || right_side == EmptyExpression.OutAccess) && (spec.Modifiers & Modifiers.VOLATILE) != 0) { ec.Report.Warning(420, 1, loc, "`{0}': A volatile field references will not be treated as volatile", spec.GetSignatureForError()); } if (spec.IsReadOnly) { if (!ec.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.ConstructorScope)) { return Error_AssignToReadonly(ec, right_side); } if (ec.HasSet(ResolveContext.Options.ConstructorScope)) { if (ec.CurrentMemberDefinition.Parent.PartialContainer.Definition != spec.DeclaringType.GetDefinition()) { return Error_AssignToReadonly(ec, right_side); } if (IsStatic && !ec.IsStatic) { return Error_AssignToReadonly(ec, right_side); } if (!IsStatic && !(InstanceExpression is This)) { return Error_AssignToReadonly(ec, right_side); } } } if (right_side == EmptyExpression.OutAccess && IsMarshalByRefAccess(ec)) { ec.Report.SymbolRelatedToPreviousError(spec.DeclaringType); ec.Report.Warning(197, 1, loc, "Passing `{0}' as ref or out or taking its address may cause a runtime exception because it is a field of a marshal-by-reference class", GetSignatureForError()); } eclass = ExprClass.Variable; return this; } public override void FlowAnalysis(FlowAnalysisContext fc) { if (InstanceExpression is IVariableReference { VariableInfo: var variableInfo }) { if (variableInfo != null && !fc.IsStructFieldDefinitelyAssigned(variableInfo, Name)) { fc.Report.Error(170, loc, "Use of possibly unassigned field `{0}'", Name); return; } if (TypeSpec.IsValueType(InstanceExpression.Type)) { SkipLeftValueTypeAccess(InstanceExpression)?.FlowAnalysis(fc); return; } } DefiniteAssignmentBitSet definiteAssignment = (conditional_access_receiver ? fc.BranchDefiniteAssignment() : null); base.FlowAnalysis(fc); if (conditional_access_receiver) { fc.DefiniteAssignment = definiteAssignment; } } private static Expression SkipLeftValueTypeAccess(Expression expr) { if (!TypeSpec.IsValueType(expr.Type)) { return expr; } if (expr is VariableReference) { return null; } if (!(expr is FieldExpr fieldExpr)) { return expr; } if (fieldExpr.InstanceExpression == null) { return expr; } return SkipLeftValueTypeAccess(fieldExpr.InstanceExpression); } public override int GetHashCode() { return spec.GetHashCode(); } public override bool Equals(object obj) { if (!(obj is FieldExpr fieldExpr)) { return false; } if (spec != fieldExpr.spec) { return false; } if (InstanceExpression == null || fieldExpr.InstanceExpression == null) { return true; } return InstanceExpression.Equals(fieldExpr.InstanceExpression); } public void Emit(EmitContext ec, bool leave_copy) { bool flag = (spec.Modifiers & Modifiers.VOLATILE) != 0; if (IsStatic) { if (flag) { ec.Emit(OpCodes.Volatile); } ec.Emit(OpCodes.Ldsfld, spec); } else { ConditionalAccessContext conditionalAccess = ec.ConditionalAccess; if (!prepared) { if (conditional_access_receiver) { ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()); } EmitInstance(ec, prepare_for_load: false); } if (type.IsStruct && type == ec.CurrentType && InstanceExpression.Type == type) { ec.EmitLoadFromPtr(type); } else if (spec is FixedFieldSpec fixedFieldSpec) { ec.Emit(OpCodes.Ldflda, spec); ec.Emit(OpCodes.Ldflda, fixedFieldSpec.Element); } else { if (flag) { ec.Emit(OpCodes.Volatile); } ec.Emit(OpCodes.Ldfld, spec); } if (conditional_access_receiver) { ec.CloseConditionalAccess((type.IsNullableType && type != spec.MemberType) ? type : null); ec.ConditionalAccess = conditionalAccess; } } if (leave_copy) { ec.Emit(OpCodes.Dup); if (!IsStatic) { temp = new LocalTemporary(base.Type); temp.Store(ec); } } } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { bool flag = ec.HasSet(BuilderContext.Options.AsyncBody) && source.ContainsEmitWithAwait(); if (isCompound && !(source is DynamicExpressionStatement) && !flag) { prepared = true; } if (IsInstance) { if (base.ConditionalAccess) { throw new NotImplementedException("null operator assignment"); } if (flag) { source = source.EmitToField(ec); } EmitInstance(ec, prepared); } source.Emit(ec); if (leave_copy || ec.NotifyEvaluatorOnStore) { ec.Emit(OpCodes.Dup); if (!IsStatic) { temp = new LocalTemporary(base.Type); temp.Store(ec); } } if ((spec.Modifiers & Modifiers.VOLATILE) != 0) { ec.Emit(OpCodes.Volatile); } spec.MemberDefinition.SetIsAssigned(); if (IsStatic) { ec.Emit(OpCodes.Stsfld, spec); } else { ec.Emit(OpCodes.Stfld, spec); } if (ec.NotifyEvaluatorOnStore) { if (!IsStatic) { throw new NotImplementedException("instance field write"); } if (leave_copy) { ec.Emit(OpCodes.Dup); } ec.Module.Evaluator.EmitValueChangedCallback(ec, Name, type, loc); } if (temp != null) { temp.Emit(ec); temp.Release(ec); temp = null; } } public void EmitAssignFromStack(EmitContext ec) { if (IsStatic) { ec.Emit(OpCodes.Stsfld, spec); } else { ec.Emit(OpCodes.Stfld, spec); } } public override void Emit(EmitContext ec) { Emit(ec, leave_copy: false); } public override void EmitSideEffect(EmitContext ec) { if ((spec.Modifiers & Modifiers.VOLATILE) != 0) { base.EmitSideEffect(ec); } } public virtual void AddressOf(EmitContext ec, AddressOp mode) { if ((mode & AddressOp.Store) != 0) { spec.MemberDefinition.SetIsAssigned(); } if ((mode & AddressOp.Load) != 0) { spec.MemberDefinition.SetIsUsed(); } bool flag; if (spec.IsReadOnly) { flag = true; if (ec.HasSet(BuilderContext.Options.ConstructorScope) && spec.DeclaringType == ec.CurrentType) { if (IsStatic) { if (ec.IsStatic) { flag = false; } } else { flag = false; } } } else { flag = false; } if (flag) { Emit(ec); LocalBuilder temporaryLocal = ec.GetTemporaryLocal(type); ec.Emit(OpCodes.Stloc, temporaryLocal); ec.Emit(OpCodes.Ldloca, temporaryLocal); } else if (IsStatic) { ec.Emit(OpCodes.Ldsflda, spec); } else { if (!prepared) { EmitInstance(ec, prepare_for_load: false); } ec.Emit(OpCodes.Ldflda, spec); } } public System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source) { return MakeExpression(ctx); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Field(IsStatic ? null : InstanceExpression.MakeExpression(ctx), spec.GetMetaInfo()); } public override void SetTypeArguments(ResolveContext ec, TypeArguments ta) { Expression.Error_TypeArgumentsCannotBeUsed(ec, "field", GetSignatureForError(), loc); } } internal sealed class PropertyExpr : PropertyOrIndexerExpr { private Arguments arguments; private FieldExpr backing_field; protected override Arguments Arguments { get { return arguments; } set { arguments = value; } } protected override TypeSpec DeclaringType => best_candidate.DeclaringType; public override string Name => best_candidate.Name; public bool IsAutoPropertyAccess => best_candidate.MemberDefinition is Property property && property.BackingField != null; public override bool IsInstance => !IsStatic; public override bool IsStatic => best_candidate.IsStatic; public override string KindName => "property"; public PropertySpec PropertyInfo => best_candidate; public PropertyExpr(PropertySpec spec, Location l) : base(l) { best_candidate = spec; type = spec.MemberType; } public override MethodGroupExpr CanReduceLambda(AnonymousMethodBody body) { if (best_candidate == null || (!best_candidate.IsStatic && !(InstanceExpression is This))) { return null; } int num = ((arguments != null) ? arguments.Count : 0); if (num != body.Parameters.Count && num == 0) { return null; } MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(best_candidate.Get, DeclaringType, loc); methodGroupExpr.InstanceExpression = InstanceExpression; return methodGroupExpr; } public static PropertyExpr CreatePredefined(PropertySpec spec, Location loc) { return new PropertyExpr(spec, loc) { Getter = spec.Get, Setter = spec.Set }; } public override Expression CreateExpressionTree(ResolveContext ec) { if (base.ConditionalAccess) { Error_NullShortCircuitInsideExpressionTree(ec); } Arguments arguments; if (IsSingleDimensionalArrayLength()) { arguments = new Arguments(1); arguments.Add(new Argument(InstanceExpression.CreateExpressionTree(ec))); return CreateExpressionFactoryCall(ec, "ArrayLength", arguments); } arguments = new Arguments(2); if (InstanceExpression == null) { arguments.Add(new Argument(new NullLiteral(loc))); } else { arguments.Add(new Argument(InstanceExpression.CreateExpressionTree(ec))); } arguments.Add(new Argument(new TypeOfMethod(base.Getter, loc))); return CreateExpressionFactoryCall(ec, "Property", arguments); } public Expression CreateSetterTypeOfExpression(ResolveContext rc) { DoResolveLValue(rc, null); return new TypeOfMethod(base.Setter, loc); } public override string GetSignatureForError() { return best_candidate.GetSignatureForError(); } public override System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source) { return System.Linq.Expressions.Expression.Property(InstanceExpression.MakeExpression(ctx), (MethodInfo)base.Setter.GetMetaInfo()); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Property(InstanceExpression.MakeExpression(ctx), (MethodInfo)base.Getter.GetMetaInfo()); } private void Error_PropertyNotValid(ResolveContext ec) { ec.Report.SymbolRelatedToPreviousError(best_candidate); ec.Report.Error(1546, loc, "Property or event `{0}' is not supported by the C# language", GetSignatureForError()); } private bool IsSingleDimensionalArrayLength() { if (best_candidate.DeclaringType.BuiltinType != BuiltinTypeSpec.Type.Array || !best_candidate.HasGet || Name != "Length") { return false; } return InstanceExpression.Type is ArrayContainer arrayContainer && arrayContainer.Rank == 1; } public override void Emit(EmitContext ec, bool leave_copy) { if (IsSingleDimensionalArrayLength()) { if (conditional_access_receiver) { ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()); } EmitInstance(ec, prepare_for_load: false); ec.Emit(OpCodes.Ldlen); ec.Emit(OpCodes.Conv_I4); if (conditional_access_receiver) { ec.CloseConditionalAccess(type); } } else { base.Emit(ec, leave_copy); } } public override void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { if (backing_field != null) { backing_field.EmitAssign(ec, source, leave_copy, isCompound: false); return; } LocalTemporary localTemporary = null; Arguments arguments; if (isCompound && !(source is DynamicExpressionStatement)) { emitting_compound_assignment = true; source.Emit(ec); if (has_await_arguments) { localTemporary = new LocalTemporary(base.Type); localTemporary.Store(ec); arguments = new Arguments(1); arguments.Add(new Argument(localTemporary)); if (leave_copy) { temp = localTemporary; } has_await_arguments = false; } else { arguments = null; if (leave_copy) { ec.Emit(OpCodes.Dup); temp = new LocalTemporary(base.Type); temp.Store(ec); } } } else { arguments = this.arguments ?? new Arguments(1); if (leave_copy) { source.Emit(ec); temp = new LocalTemporary(base.Type); temp.Store(ec); arguments.Add(new Argument(temp)); } else { arguments.Add(new Argument(source)); } } emitting_compound_assignment = false; CallEmitter callEmitter = new CallEmitter { InstanceExpression = InstanceExpression }; if (arguments == null) { callEmitter.InstanceExpressionOnStack = true; } if (base.ConditionalAccess) { callEmitter.ConditionalAccess = true; } if (leave_copy) { callEmitter.Emit(ec, base.Setter, arguments, loc); } else { callEmitter.EmitStatement(ec, base.Setter, arguments, loc); } if (temp != null) { temp.Emit(ec); temp.Release(ec); } localTemporary?.Release(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { if (best_candidate.MemberDefinition is Property { BackingField: not null } property && InstanceExpression is IVariableReference { VariableInfo: var variableInfo }) { if (variableInfo != null && !fc.IsStructFieldDefinitelyAssigned(variableInfo, property.BackingField.Name)) { fc.Report.Error(8079, loc, "Use of possibly unassigned auto-implemented property `{0}'", Name); return; } if (TypeSpec.IsValueType(InstanceExpression.Type) && InstanceExpression is VariableReference) { return; } } DefiniteAssignmentBitSet definiteAssignment = (conditional_access_receiver ? fc.BranchDefiniteAssignment() : null); base.FlowAnalysis(fc); if (conditional_access_receiver) { fc.DefiniteAssignment = definiteAssignment; } } protected override Expression OverloadResolve(ResolveContext rc, Expression right_side) { eclass = ExprClass.PropertyAccess; if (best_candidate.IsNotCSharpCompatible) { Error_PropertyNotValid(rc); } ResolveInstanceExpression(rc, right_side); if ((best_candidate.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL)) != 0 && best_candidate.DeclaringType != InstanceExpression.Type && MemberCache.FindMember(filter: new MemberFilter(best_candidate.Name, 0, MemberKind.Property, null, null), container: InstanceExpression.Type, restrictions: BindingRestriction.InstanceOnly | BindingRestriction.OverrideOnly) is PropertySpec propertySpec) { type = propertySpec.MemberType; } DoBestMemberChecks(rc, best_candidate); if (best_candidate.HasGet && !best_candidate.Get.Parameters.IsEmpty) { AParametersCollection parameters = best_candidate.Get.Parameters; arguments = new Arguments(parameters.Count); for (int i = 0; i < parameters.Count; i++) { arguments.Add(new Argument(OverloadResolver.ResolveDefaultValueArgument(rc, parameters.Types[i], parameters.FixedParameters[i].DefaultValue, loc))); } } else if (best_candidate.HasSet && best_candidate.Set.Parameters.Count > 1) { AParametersCollection parameters2 = best_candidate.Set.Parameters; arguments = new Arguments(parameters2.Count - 1); for (int j = 0; j < parameters2.Count - 1; j++) { arguments.Add(new Argument(OverloadResolver.ResolveDefaultValueArgument(rc, parameters2.Types[j], parameters2.FixedParameters[j].DefaultValue, loc))); } } return this; } protected override bool ResolveAutopropertyAssignment(ResolveContext rc, Expression rhs) { if (!rc.HasSet(ResolveContext.Options.ConstructorScope)) { return false; } Property property = best_candidate.MemberDefinition as Property; if (property == null || property.Parent.PartialContainer != rc.CurrentMemberDefinition.Parent.PartialContainer) { if (!(MemberCache.FindMember(rc.CurrentType, MemberFilter.Property(best_candidate.Name, best_candidate.MemberType), BindingRestriction.DeclaredOnly) is PropertySpec propertySpec)) { return false; } property = (Property)propertySpec.MemberDefinition; } Property.BackingFieldDeclaration backingField = property.BackingField; if (backingField == null) { return false; } if (rc.IsStatic != backingField.IsStatic) { return false; } if (!backingField.IsStatic && (!(InstanceExpression is This) || InstanceExpression is BaseThis)) { return false; } backing_field = new FieldExpr(property.BackingField, loc); backing_field.ResolveLValue(rc, rhs); return true; } public override void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { if (!best_candidate.IsAccessible(rc)) { Expression.ErrorIsInaccesible(rc, best_candidate.GetSignatureForError(), expr.Location); } best_candidate.CheckObsoleteness(rc, expr.Location); } public void SetBackingFieldAssigned(FlowAnalysisContext fc) { if (backing_field != null) { backing_field.SetFieldAssigned(fc); } else if (IsAutoPropertyAccess && best_candidate.MemberDefinition is Property { BackingField: not null } property && best_candidate.DeclaringType.IsStruct && InstanceExpression is IVariableReference { VariableInfo: not null } variableReference) { fc.SetStructFieldAssigned(variableReference.VariableInfo, property.BackingField.Name); } } public override void SetTypeArguments(ResolveContext ec, TypeArguments ta) { Expression.Error_TypeArgumentsCannotBeUsed(ec, "property", GetSignatureForError(), loc); } } internal abstract class PropertyOrIndexerExpr : MemberExpr, IDynamicAssign, IAssignMethod where T : PropertySpec { private MethodSpec getter; private MethodSpec setter; protected T best_candidate; protected LocalTemporary temp; protected bool emitting_compound_assignment; protected bool has_await_arguments; protected abstract Arguments Arguments { get; set; } public MethodSpec Getter { get { return getter; } set { getter = value; } } public MethodSpec Setter { get { return setter; } set { setter = value; } } protected PropertyOrIndexerExpr(Location l) { loc = l; } protected override Expression DoResolve(ResolveContext ec) { if (eclass == ExprClass.Unresolved) { ResolveConditionalAccessReceiver(ec); Expression expression = OverloadResolve(ec, null); if (expression == null) { return null; } if (expression != this) { using (ec.With(ResolveContext.Options.DontSetConditionalAccessReceiver, conditional_access_receiver)) { return expression.Resolve(ec); } } if (conditional_access_receiver) { type = LiftMemberType(ec, type); } } if (!ResolveGetter(ec)) { return null; } if (type.Kind == MemberKind.ByRef) { return ByRefDereference.Create(this).Resolve(ec); } return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (HasConditionalAccess()) { Error_NullPropagatingLValue(rc); } if (right_side == EmptyExpression.OutAccess) { if (OverloadResolve(rc, null) == null) { return null; } T val = best_candidate; if (val != null && val.MemberType.Kind == MemberKind.ByRef) { getter = CandidateToBaseOverride(rc, best_candidate.Get); return this; } INamedBlockVariable variable = null; if (best_candidate != null && rc.CurrentBlock.ParametersBlock.TopBlock.GetLocalName(best_candidate.Name, rc.CurrentBlock, ref variable) && variable is RangeVariable) { rc.Report.Error(1939, loc, "A range variable `{0}' may not be passes as `ref' or `out' parameter", best_candidate.Name); } else { right_side.DoResolveLValue(rc, this); } return null; } if (eclass == ExprClass.Unresolved) { Expression expression = OverloadResolve(rc, right_side); if (expression == null) { return null; } if (expression != this) { return expression.ResolveLValue(rc, right_side); } } else { ResolveInstanceExpression(rc, right_side); } if (!best_candidate.HasSet) { if (ResolveAutopropertyAssignment(rc, right_side)) { return this; } if (best_candidate.MemberType.Kind == MemberKind.ByRef) { getter = CandidateToBaseOverride(rc, best_candidate.Get); return ByRefDereference.Create(this).Resolve(rc); } rc.Report.Error(200, loc, "Property or indexer `{0}' cannot be assigned to (it is read-only)", GetSignatureForError()); return null; } if (!best_candidate.Set.IsAccessible(rc) || !best_candidate.Set.DeclaringType.IsAccessible(rc)) { if (best_candidate.HasDifferentAccessibility) { rc.Report.SymbolRelatedToPreviousError(best_candidate.Set); rc.Report.Error(272, loc, "The property or indexer `{0}' cannot be used in this context because the set accessor is inaccessible", GetSignatureForError()); } else { rc.Report.SymbolRelatedToPreviousError(best_candidate.Set); Expression.ErrorIsInaccesible(rc, best_candidate.GetSignatureForError(), loc); } } if (best_candidate.HasDifferentAccessibility) { CheckProtectedMemberAccess(rc, best_candidate.Set); } setter = CandidateToBaseOverride(rc, best_candidate.Set); return this; } private void EmitConditionalAccess(EmitContext ec, ref CallEmitter call, MethodSpec method, Arguments arguments) { ConditionalAccessContext conditionalAccess = ec.ConditionalAccess; ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()); call.Emit(ec, method, arguments, loc); ec.CloseConditionalAccess((method.ReturnType != type && type.IsNullableType) ? type : null); ec.ConditionalAccess = conditionalAccess; } public virtual void Emit(EmitContext ec, bool leave_copy) { CallEmitter call = new CallEmitter { ConditionalAccess = base.ConditionalAccess, InstanceExpression = InstanceExpression }; if (has_await_arguments) { call.HasAwaitArguments = true; } else { call.DuplicateArguments = emitting_compound_assignment; } if (conditional_access_receiver) { EmitConditionalAccess(ec, ref call, Getter, Arguments); } else { call.Emit(ec, Getter, Arguments, loc); } if (call.HasAwaitArguments) { InstanceExpression = call.InstanceExpression; Arguments = call.EmittedArguments; has_await_arguments = true; } if (leave_copy) { ec.Emit(OpCodes.Dup); temp = new LocalTemporary(base.Type); temp.Store(ec); } } public abstract void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound); public override void Emit(EmitContext ec) { Emit(ec, leave_copy: false); } protected override FieldExpr EmitToFieldSource(EmitContext ec) { has_await_arguments = true; Emit(ec, leave_copy: false); return null; } public abstract System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source); protected abstract Expression OverloadResolve(ResolveContext rc, Expression right_side); private bool ResolveGetter(ResolveContext rc) { if (!best_candidate.HasGet) { if (InstanceExpression != EmptyExpression.Null) { rc.Report.SymbolRelatedToPreviousError(best_candidate); rc.Report.Error(154, loc, "The property or indexer `{0}' cannot be used in this context because it lacks the `get' accessor", best_candidate.GetSignatureForError()); return false; } } else if (!best_candidate.Get.IsAccessible(rc) || !best_candidate.Get.DeclaringType.IsAccessible(rc)) { if (best_candidate.HasDifferentAccessibility) { rc.Report.SymbolRelatedToPreviousError(best_candidate.Get); rc.Report.Error(271, loc, "The property or indexer `{0}' cannot be used in this context because the get accessor is inaccessible", TypeManager.CSharpSignature(best_candidate)); } else { rc.Report.SymbolRelatedToPreviousError(best_candidate.Get); Expression.ErrorIsInaccesible(rc, best_candidate.Get.GetSignatureForError(), loc); } } if (best_candidate.HasDifferentAccessibility) { CheckProtectedMemberAccess(rc, best_candidate.Get); } getter = CandidateToBaseOverride(rc, best_candidate.Get); return true; } protected virtual bool ResolveAutopropertyAssignment(ResolveContext rc, Expression rhs) { return false; } } internal class EventExpr : MemberExpr, IAssignMethod { private readonly EventSpec spec; private MethodSpec op; protected override TypeSpec DeclaringType => spec.DeclaringType; public override string Name => spec.Name; public override bool IsInstance => !spec.IsStatic; public override bool IsStatic => spec.IsStatic; public override string KindName => "event"; public MethodSpec Operator => op; public EventExpr(EventSpec spec, Location loc) { this.spec = spec; base.loc = loc; } public override MemberExpr ResolveMemberAccess(ResolveContext ec, Expression left, SimpleName original) { if (!ec.HasSet(ResolveContext.Options.CompoundAssignmentScope) && spec.BackingField != null && (spec.DeclaringType == ec.CurrentType || TypeManager.IsNestedChildOf(ec.CurrentType, spec.DeclaringType.MemberDefinition))) { spec.MemberDefinition.SetIsUsed(); spec.CheckObsoleteness(ec, loc); if ((spec.Modifiers & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0) { Error_AssignmentEventOnly(ec); } FieldExpr fieldExpr = new FieldExpr(spec.BackingField, loc); InstanceExpression = null; return fieldExpr.ResolveMemberAccess(ec, left, original); } return base.ResolveMemberAccess(ec, left, original); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { if (right_side == EmptyExpression.EventAddition) { op = spec.AccessorAdd; } else if (right_side == EmptyExpression.EventSubtraction) { op = spec.AccessorRemove; } if (op == null) { Error_AssignmentEventOnly(ec); return null; } if (HasConditionalAccess()) { Error_NullPropagatingLValue(ec); } op = CandidateToBaseOverride(ec, op); return this; } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.EventAccess; type = spec.MemberType; ResolveInstanceExpression(ec, null); if (!ec.HasSet(ResolveContext.Options.CompoundAssignmentScope)) { Error_AssignmentEventOnly(ec); } DoBestMemberChecks(ec, spec); return this; } public override void Emit(EmitContext ec) { throw new NotSupportedException(); } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { if (leave_copy || !isCompound) { throw new NotImplementedException("EventExpr::EmitAssign"); } Arguments arguments = new Arguments(1); arguments.Add(new Argument(source)); CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = InstanceExpression; callEmitter.ConditionalAccess = base.ConditionalAccess; callEmitter.EmitStatement(ec, op, arguments, loc); } private void Error_AssignmentEventOnly(ResolveContext ec) { if (spec.DeclaringType == ec.CurrentType || TypeManager.IsNestedChildOf(ec.CurrentType, spec.DeclaringType.MemberDefinition)) { ec.Report.Error(79, loc, "The event `{0}' can only appear on the left hand side of `+=' or `-=' operator", GetSignatureForError()); } else { ec.Report.Error(70, loc, "The event `{0}' can only appear on the left hand side of += or -= when used outside of the type `{1}'", GetSignatureForError(), spec.DeclaringType.GetSignatureForError()); } } protected override void Error_CannotCallAbstractBase(ResolveContext rc, string name) { name = name.Substring(0, name.LastIndexOf('.')); base.Error_CannotCallAbstractBase(rc, name); } public override string GetSignatureForError() { return TypeManager.CSharpSignature(spec); } public override void ResolveNameOf(ResolveContext rc, ATypeNameExpression expr) { spec.CheckObsoleteness(rc, expr.Location); } public override void SetTypeArguments(ResolveContext ec, TypeArguments ta) { Expression.Error_TypeArgumentsCannotBeUsed(ec, "event", GetSignatureForError(), loc); } } internal class TemporaryVariableReference : VariableReference { public class Declarator : Statement { private TemporaryVariableReference variable; public Declarator(TemporaryVariableReference variable) { this.variable = variable; loc = variable.loc; } protected override void DoEmit(EmitContext ec) { variable.li.CreateBuilder(ec); } public override void Emit(EmitContext ec) { DoEmit(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return false; } protected override void CloneTo(CloneContext clonectx, Statement target) { } } private LocalVariable li; public override bool IsLockedByStatement { get { return false; } set { } } public LocalVariable LocalInfo => li; public override bool IsFixed => true; public override bool IsRef => false; public override string Name { get { throw new NotImplementedException(); } } protected override ILocalVariable Variable => li; public override VariableInfo VariableInfo => null; public TemporaryVariableReference(LocalVariable li, Location loc) { this.li = li; type = li.Type; base.loc = loc; } public static TemporaryVariableReference Create(TypeSpec type, Block block, Location loc, bool writeToSymbolFile = false) { LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(type, block, loc, writeToSymbolFile); return new TemporaryVariableReference(localVariable, loc); } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Variable; if (ec.CurrentAnonymousMethod is StateMachineInitializer && (ec.CurrentBlock.Explicit.HasYield || ec.CurrentBlock.Explicit.HasAwait) && ec.IsVariableCapturingRequired) { AnonymousMethodStorey anonymousMethodStorey = li.Block.Explicit.CreateAnonymousMethodStorey(ec); anonymousMethodStorey.CaptureLocalVariable(ec, li); } return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return Resolve(ec); } public override void Emit(EmitContext ec) { li.CreateBuilder(ec); Emit(ec, leave_copy: false); } public void EmitAssign(EmitContext ec, Expression source) { li.CreateBuilder(ec); EmitAssign(ec, source, leave_copy: false, prepare_for_load: false); } public override HoistedVariable GetHoistedVariable(AnonymousExpression ae) { return li.HoistedVariant; } public override void SetHasAddressTaken() { throw new NotImplementedException(); } } internal class VarExpr : SimpleName { public VarExpr(Location loc) : base("var", loc) { } public bool InferType(ResolveContext ec, Expression rhs) { if (type != null) { throw new InternalErrorException("An implicitly typed local variable could not be redefined"); } type = rhs.Type; if (type.Kind == MemberKind.Void || InternalType.HasNoType(type) || (rhs is TupleLiteral && TupleLiteral.ContainsNoTypeElement(type))) { ec.Report.Error(815, loc, "An implicitly typed local variable declaration cannot be initialized with `{0}'", type.GetSignatureForError()); type = InternalType.ErrorType; return false; } eclass = ExprClass.Variable; return true; } protected override void Error_TypeOrNamespaceNotFound(IMemberContext ec) { if (ec.Module.Compiler.Settings.Version < LanguageVersion.V_3) { base.Error_TypeOrNamespaceNotFound(ec); } else { ec.Module.Compiler.Report.Error(825, loc, "The contextual keyword `var' may only appear within a local variable declaration"); } } } internal class EnumMember : Const { private class MemberTypeDelegator : TypeDelegator { private Type underlyingType; public override Type UnderlyingSystemType => underlyingType; public MemberTypeDelegator(Type delegatingType, Type underlyingType) : base(delegatingType) { this.underlyingType = underlyingType; } } private class EnumTypeExpr : TypeExpr { public override TypeSpec ResolveAsType(IMemberContext ec, bool allowUnboundTypeArguments) { type = ec.CurrentType; eclass = ExprClass.Type; return type; } } public EnumMember(Enum parent, MemberName name, Attributes attrs) : base(parent, new EnumTypeExpr(), Modifiers.PUBLIC, name, attrs) { } private static bool IsValidEnumType(TypeSpec t) { BuiltinTypeSpec.Type builtinType = t.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 2) <= 8u) { return true; } return t.IsEnum; } public override Constant ConvertInitializer(ResolveContext rc, Constant expr) { if (expr is EnumConstant) { expr = ((EnumConstant)expr).Child; } Enum obj = (Enum)Parent; TypeSpec underlyingType = obj.UnderlyingType; if (expr != null) { expr = expr.ImplicitConversionRequired(rc, underlyingType); if (expr != null && !IsValidEnumType(expr.Type)) { obj.Error_UnderlyingType(base.Location); expr = null; } } if (expr == null) { expr = New.Constantify(underlyingType, base.Location); } return new EnumConstant(expr, base.MemberType); } public override bool Define() { if (!ResolveMemberType()) { return false; } Type metaInfo = base.MemberType.GetMetaInfo(); metaInfo = new MemberTypeDelegator(metaInfo, ((Enum)Parent).UnderlyingType.GetMetaInfo()); FieldBuilder = Parent.TypeBuilder.DefineField(base.Name, metaInfo, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); spec = new ConstSpec(Parent.Definition, this, base.MemberType, FieldBuilder, base.ModFlags, initializer); Parent.MemberCache.AddMember(spec); return true; } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } } internal class Enum : TypeDefinition { private sealed class ImplicitInitializer : Expression { private readonly EnumMember prev; private readonly EnumMember current; public ImplicitInitializer(EnumMember current, EnumMember prev) { this.current = current; this.prev = prev; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("Missing Resolve call"); } protected override Expression DoResolve(ResolveContext rc) { if (prev == null) { return New.Constantify(current.Parent.Definition, base.Location); } EnumConstant enumConstant = ((ConstSpec)prev.Spec).GetConstant(rc) as EnumConstant; try { return enumConstant.Increment(); } catch (OverflowException) { rc.Report.Error(543, current.Location, "The enumerator value `{0}' is outside the range of enumerator underlying type `{1}'", current.GetSignatureForError(), ((Enum)current.Parent).UnderlyingType.GetSignatureForError()); return New.Constantify(current.Parent.Definition, current.Location); } } public override void Emit(EmitContext ec) { throw new NotSupportedException("Missing Resolve call"); } } public static readonly string UnderlyingValueField = "value__"; private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW; private readonly FullNamedExpression underlying_type_expr; public override AttributeTargets AttributeTargets => AttributeTargets.Enum; public FullNamedExpression BaseTypeExpression => underlying_type_expr; protected override TypeAttributes TypeAttr => base.TypeAttr | TypeAttributes.NotPublic | TypeAttributes.Sealed; public TypeSpec UnderlyingType => ((EnumSpec)spec).UnderlyingType; public Enum(TypeContainer parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base(parent, name, attrs, MemberKind.Enum) { underlying_type_expr = type; base.ModFlags = ModifiersExtensions.Check(Modifiers.AccessibilityMask | Modifiers.NEW, mod_flags, base.IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE, base.Location, base.Report); spec = new EnumSpec(null, this, null, null, base.ModFlags); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public void AddEnumMember(EnumMember em) { if (em.Name == UnderlyingValueField) { base.Report.Error(76, em.Location, "An item in an enumeration cannot have an identifier `{0}'", UnderlyingValueField); } else { AddMember(em); } } public void Error_UnderlyingType(Location loc) { base.Report.Error(1008, loc, "Type byte, sbyte, short, ushort, int, uint, long or ulong expected"); } protected override void DoDefineContainer() { TypeSpec typeSpec; if (underlying_type_expr != null) { typeSpec = underlying_type_expr.ResolveAsType(this); if (!EnumSpec.IsValidUnderlyingType(typeSpec)) { Error_UnderlyingType(underlying_type_expr.Location); typeSpec = null; } } else { typeSpec = null; } if (typeSpec == null) { typeSpec = Compiler.BuiltinTypes.Int; } ((EnumSpec)spec).UnderlyingType = typeSpec; TypeBuilder.DefineField(UnderlyingValueField, UnderlyingType.GetMetaInfo(), FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); DefineBaseTypes(); } protected override bool DoDefineMembers() { for (int i = 0; i < base.Members.Count; i++) { EnumMember enumMember = (EnumMember)base.Members[i]; if (enumMember.Initializer == null) { enumMember.Initializer = new ImplicitInitializer(enumMember, (i == 0) ? null : ((EnumMember)base.Members[i - 1])); } enumMember.Define(); } return true; } public override bool IsUnmanagedType() { return true; } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { base_type = Compiler.BuiltinTypes.Enum; base_class = null; return null; } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } switch (UnderlyingType.BuiltinType) { case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.ULong: base.Report.Warning(3009, 1, base.Location, "`{0}': base type `{1}' is not CLS-compliant", GetSignatureForError(), UnderlyingType.GetSignatureForError()); break; } return true; } } internal class EnumSpec : TypeSpec { private TypeSpec underlying; public TypeSpec UnderlyingType { get { return underlying; } set { if (underlying != null) { throw new InternalErrorException("UnderlyingType reset"); } underlying = value; } } public EnumSpec(TypeSpec declaringType, ITypeDefinition definition, TypeSpec underlyingType, Type info, Modifiers modifiers) : base(MemberKind.Enum, declaringType, definition, info, modifiers | Modifiers.SEALED) { underlying = underlyingType; } public static TypeSpec GetUnderlyingType(TypeSpec t) { return ((EnumSpec)t.GetDefinition()).UnderlyingType; } public static bool IsValidUnderlyingType(TypeSpec type) { BuiltinTypeSpec.Type builtinType = type.BuiltinType; BuiltinTypeSpec.Type type2 = builtinType; if ((uint)(type2 - 2) <= 1u || (uint)(type2 - 5) <= 5u) { return true; } return false; } } internal delegate void ValueModificationHandler(string variableName, int row, int column, object value); internal class Evaluator { public enum ParseMode { Silent, ReportErrors, GetCompletions } private enum InputKind { EOF, StatementOrExpression, CompilationUnit, Error } internal static class QuitValue { } private static object evaluator_lock = new object(); private static volatile bool invoking; private static int count; private static Thread invoke_thread; public Dictionary> fields; public Type base_class; public Type prev_host; public bool inited; private int startup_files; private readonly CompilerContext ctx; private readonly ModuleContainer module; private readonly ReflectionImporter importer; private readonly CompilationSourceFile source_file; private int? listener_id; public bool DescribeTypeExpressions; public bool Terse = true; private static MethodInfo listener_proxy_value; public bool WaitOnTask { get; set; } public Type InteractiveBaseClass { get { return base_class; } set { base_class = value; prev_host = null; if ((object)value != null && typeof(InteractiveBase).IsAssignableFrom(value)) { InteractiveBase.Evaluator = this; } } } public ValueModificationHandler ModificationListener { get; set; } public Evaluator(CompilerContext ctx) { this.ctx = ctx; module = new ModuleContainer(ctx); module.Evaluator = this; source_file = new CompilationSourceFile(module, null); module.AddTypeContainer(source_file); startup_files = ctx.SourceFiles.Count; module.SetDeclaringAssembly(new AssemblyDefinitionDynamic(module, "evaluator")); importer = new ReflectionImporter(module, ctx.BuiltinTypes) { IgnorePrivateMembers = false, IgnoreCompilerGeneratedField = false }; InteractiveBaseClass = typeof(InteractiveBase); fields = new Dictionary>(); } private void Init() { DynamicLoader dynamicLoader = new DynamicLoader(importer, ctx); CompilerCallableEntryPoint.Reset(); RootContext.ToplevelTypes = module; dynamicLoader.LoadReferences(module); ctx.BuiltinTypes.CheckDefinitions(module); module.InitializePredefinedTypes(); inited = true; } private void ParseStartupFiles() { Driver driver = new Driver(ctx); Location.Initialize(ctx.SourceFiles); ParserSession session = new ParserSession(); for (int i = 0; i < startup_files; i++) { SourceFile file = ctx.SourceFiles[i]; driver.Parse(file, module, session, ctx.Report); } } private void Reset() { CompilerCallableEntryPoint.PartialReset(); Location.Reset(); Location.Initialize(ctx.SourceFiles); } public void Interrupt() { if (inited && invoking && invoke_thread != null) { invoke_thread.Interrupt(); } } public string Compile(string input, out CompiledMethod compiled) { if (input == null || input.Length == 0) { compiled = null; return null; } lock (evaluator_lock) { if (!inited) { Init(); ParseStartupFiles(); } else { ctx.Report.Printer.Reset(); } bool partial_input; CSharpParser cSharpParser = ParseString(ParseMode.Silent, input, out partial_input); if (cSharpParser == null && Terse && partial_input && ParseString(ParseMode.Silent, input + "{}", out var partial_input2) == null) { cSharpParser = ParseString(ParseMode.Silent, input + ";", out partial_input2); } if (cSharpParser == null) { compiled = null; if (partial_input) { return input; } ParseString(ParseMode.ReportErrors, input, out partial_input); return null; } Class interactiveResult = cSharpParser.InteractiveResult; compiled = CompileBlock(interactiveResult, cSharpParser.undo, ctx.Report); return null; } } public CompiledMethod Compile(string input) { if (Compile(input, out var compiled) != null) { return null; } return compiled; } internal void EmitValueChangedCallback(EmitContext ec, string name, TypeSpec type, Location loc) { if (!listener_id.HasValue) { listener_id = ListenerProxy.Register(ModificationListener); } if ((object)listener_proxy_value == null) { listener_proxy_value = typeof(ListenerProxy).GetMethod("ValueChanged"); } if (type.IsStructOrEnum) { ec.Emit(OpCodes.Box, type); } ec.EmitInt(loc.Row); ec.EmitInt(loc.Column); ec.Emit(OpCodes.Ldstr, name); ec.EmitInt(listener_id.Value); ec.Emit(OpCodes.Call, listener_proxy_value); } public string Evaluate(string input, out object result, out bool result_set) { result_set = false; result = null; input = Compile(input, out var compiled); if (input != null) { return input; } if (compiled == null) { return null; } object retvalue = typeof(QuitValue); try { invoke_thread = Thread.CurrentThread; invoking = true; compiled(ref retvalue); } catch (ThreadInterruptedException arg) { Console.WriteLine("Interrupted!\n{0}", arg); } finally { invoking = false; if (listener_id.HasValue) { ListenerProxy.Unregister(listener_id.Value); listener_id = null; } } if (retvalue != typeof(QuitValue)) { result_set = true; result = retvalue; } return null; } public string[] GetCompletions(string input, out string prefix) { prefix = ""; if (input == null || input.Length == 0) { return null; } lock (evaluator_lock) { if (!inited) { Init(); } bool partial_input; CSharpParser cSharpParser = ParseString(ParseMode.GetCompletions, input, out partial_input); if (cSharpParser == null) { return null; } Class interactiveResult = cSharpParser.InteractiveResult; TypeSpec t = importer.ImportType(prev_host ?? base_class); List baseTypes = new List { new TypeExpression(t, interactiveResult.Location) }; interactiveResult.SetBaseTypes(baseTypes); AssemblyBuilderAccess access = AssemblyBuilderAccess.Run; AssemblyDefinitionDynamic assemblyDefinitionDynamic = new AssemblyDefinitionDynamic(module, "completions"); assemblyDefinitionDynamic.Create(AppDomain.CurrentDomain, access); module.SetDeclaringAssembly(assemblyDefinitionDynamic); interactiveResult.CreateContainer(); interactiveResult.DefineContainer(); Method method = interactiveResult.Members[0] as Method; BlockContext bc = new BlockContext(method, method.Block, ctx.BuiltinTypes.Void); try { method.Block.Resolve(bc, method); } catch (CompletionResult completionResult) { prefix = completionResult.BaseText; return completionResult.Result; } } return null; } public bool Run(string statement) { object result; bool result_set; return Evaluate(statement, out result, out result_set) == null; } public object Evaluate(string input) { object result; bool result_set; string text = Evaluate(input, out result, out result_set); if (text != null) { throw new ArgumentException("Syntax error on input: partial input"); } if (!result_set) { throw new ArgumentException("The expression failed to resolve"); } return result; } private InputKind ToplevelOrStatement(SeekableStreamReader seekable) { Tokenizer tokenizer = new Tokenizer(seekable, source_file, new ParserSession(), ctx.Report); tokenizer.parsing_block++; switch (tokenizer.token()) { case 257: return InputKind.EOF; case 261: case 272: case 282: case 285: case 297: case 298: case 302: case 310: case 311: case 312: case 318: case 322: case 324: case 375: case 429: return InputKind.CompilationUnit; case 265: case 267: case 270: case 275: case 280: case 288: case 289: case 296: case 301: case 303: case 305: case 317: case 319: case 323: case 331: case 332: return InputKind.StatementOrExpression; case 336: { int num = tokenizer.token(); switch (num) { case 257: return InputKind.EOF; default: if (num != 322) { return InputKind.StatementOrExpression; } goto case 424; case 424: return InputKind.CompilationUnit; } } case 278: { int num = tokenizer.token(); switch (num) { case 257: return InputKind.EOF; default: if (num != 373) { return InputKind.CompilationUnit; } goto case 377; case 377: return InputKind.StatementOrExpression; } } case 334: return tokenizer.token() switch { 257 => InputKind.EOF, 377 => InputKind.StatementOrExpression, _ => InputKind.CompilationUnit, }; case 259: case 308: case 313: return InputKind.Error; default: return InputKind.StatementOrExpression; } } public CSharpParser ParseString(ParseMode mode, string input, out bool partial_input) { partial_input = false; Reset(); Encoding encoding = ctx.Settings.Encoding; MemoryStream stream = new MemoryStream(encoding.GetBytes(input)); SeekableStreamReader seekableStreamReader = new SeekableStreamReader(stream, encoding); InputKind inputKind = ToplevelOrStatement(seekableStreamReader); switch (inputKind) { case InputKind.Error: if (mode == ParseMode.ReportErrors) { ctx.Report.Error(-25, "Detection Parsing Error"); } partial_input = false; return null; case InputKind.EOF: if (mode == ParseMode.ReportErrors) { Console.Error.WriteLine("Internal error: EOF condition should have been detected in a previous call with silent=true"); } partial_input = true; return null; default: { seekableStreamReader.Position = 0; source_file.DeclarationFound = false; CSharpParser cSharpParser = new CSharpParser(seekableStreamReader, source_file, new ParserSession()); if (inputKind == InputKind.StatementOrExpression) { cSharpParser.Lexer.putback_char = 1048576; cSharpParser.Lexer.parsing_block++; ctx.Settings.StatementMode = true; } else { cSharpParser.Lexer.putback_char = 1048577; ctx.Settings.StatementMode = false; } if (mode == ParseMode.GetCompletions) { cSharpParser.Lexer.CompleteOnEOF = true; } ReportPrinter reportPrinter = null; if (mode == ParseMode.Silent || mode == ParseMode.GetCompletions) { reportPrinter = ctx.Report.SetPrinter(new StreamReportPrinter(TextWriter.Null)); } try { cSharpParser.parse(); } finally { if (ctx.Report.Errors != 0) { if (mode != ParseMode.ReportErrors && cSharpParser.UnexpectedEOF) { partial_input = true; } if (cSharpParser.undo != null) { cSharpParser.undo.ExecuteUndo(); } cSharpParser = null; } if (reportPrinter != null) { ctx.Report.SetPrinter(reportPrinter); } } return cSharpParser; } } } private CompiledMethod CompileBlock(Class host, Undo undo, Report Report) { string text = "eval-" + count + ".dll"; count++; AssemblyBuilderAccess assemblyBuilderAccess; AssemblyDefinitionDynamic assemblyDefinitionDynamic; if (Environment.GetEnvironmentVariable("SAVE") != null) { assemblyBuilderAccess = AssemblyBuilderAccess.Run; assemblyDefinitionDynamic = new AssemblyDefinitionDynamic(module, text, text); assemblyDefinitionDynamic.Importer = importer; } else { assemblyBuilderAccess = AssemblyBuilderAccess.Run; assemblyDefinitionDynamic = new AssemblyDefinitionDynamic(module, text); } assemblyDefinitionDynamic.Create(AppDomain.CurrentDomain, assemblyBuilderAccess); Method method; if (host != null) { TypeSpec t = importer.ImportType(prev_host ?? base_class); List baseTypes = new List(1) { new TypeExpression(t, host.Location) }; host.SetBaseTypes(baseTypes); method = (Method)host.Members[0]; if ((method.ModFlags & Modifiers.ASYNC) != 0) { ParametersCompiled parametersCompiled = new ParametersCompiled(new Parameter(new TypeExpression(module.Compiler.BuiltinTypes.Object, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null)); Method method2 = new Method(host, new TypeExpression(module.Compiler.BuiltinTypes.Void, Location.Null), Modifiers.PUBLIC | Modifiers.STATIC, new MemberName("AsyncWait"), parametersCompiled, null); method2.Block = new ToplevelBlock(method2.Compiler, parametersCompiled, Location.Null); method2.Block.AddStatement(new StatementExpression(new SimpleAssign(new SimpleName(parametersCompiled[0].Name, Location.Null), new Invocation(new SimpleName(method.MemberName.Name, Location.Null), new Arguments(0)), Location.Null), Location.Null)); if (WaitOnTask) { Cast expr = new Cast(method.TypeExpression, new SimpleName(parametersCompiled[0].Name, Location.Null), Location.Null); method2.Block.AddStatement(new StatementExpression(new Invocation(new MemberAccess(expr, "Wait", Location.Null), new Arguments(0)), Location.Null)); } host.AddMember(method2); method = method2; } host.CreateContainer(); host.DefineContainer(); host.Define(); } else { method = null; } module.CreateContainer(); module.EnableRedefinition(); source_file.EnableRedefinition(); module.Define(); if (Report.Errors != 0) { undo?.ExecuteUndo(); return null; } if (host != null) { host.PrepareEmit(); host.EmitContainer(); } module.EmitContainer(); if (Report.Errors != 0) { undo?.ExecuteUndo(); return null; } module.CloseContainerEarlyForReflectionEmit(); module.CloseContainer(); host?.CloseContainer(); if (assemblyBuilderAccess == AssemblyBuilderAccess.Run) { assemblyDefinitionDynamic.Save(); } if (host == null) { return null; } Type type = (prev_host = assemblyDefinitionDynamic.Builder.GetType(host.TypeBuilder.Name)); MethodInfo method3 = type.GetMethod(method.MemberName.Name); foreach (MemberCore member in host.Members) { if (!(member is Field field)) { continue; } FieldInfo field2 = type.GetField(field.Name); if (fields.TryGetValue(field.Name, out var value) && !value.Item1.MemberType.IsStruct) { try { value.Item2.SetValue(null, null); } catch { } } Console.WriteLine("replacing fieldspec for " + field.Name); fields[field.Name] = Tuple.Create(field.Spec, field2); } return (CompiledMethod)System.Delegate.CreateDelegate(typeof(CompiledMethod), method3); } internal Tuple LookupField(string name) { fields.TryGetValue(name, out var value); return value; } private static string Quote(string s) { if (s.IndexOf('"') != -1) { s = s.Replace("\"", "\\\""); } return "\"" + s + "\""; } public string GetUsing() { if (source_file == null || source_file.Usings == null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); foreach (UsingClause @using in source_file.Usings) { if (@using.Alias == null && @using.ResolvedExpression != null) { stringBuilder.AppendFormat("using {0};", @using.ToString()); stringBuilder.Append(Environment.NewLine); } } return stringBuilder.ToString(); } internal List GetUsingList() { List list = new List(); if (source_file == null || source_file.Usings == null) { return list; } foreach (UsingClause @using in source_file.Usings) { if (@using.Alias == null && @using.ResolvedExpression != null) { list.Add(@using.NamespaceExpression.Name); } } return list; } internal string[] GetVarNames() { lock (evaluator_lock) { return new List(fields.Keys).ToArray(); } } public string GetVars() { lock (evaluator_lock) { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair> field in fields) { Tuple tuple = LookupField(field.Key); object obj; try { obj = tuple.Item2.GetValue(null); if (obj is string) { obj = Quote((string)obj); } } catch { obj = ""; } stringBuilder.AppendFormat("{0} {1} = {2}", tuple.Item1.MemberType.GetSignatureForError(), field.Key, obj); stringBuilder.AppendLine(); } return stringBuilder.ToString(); } } public void LoadAssembly(string file) { DynamicLoader dynamicLoader = new DynamicLoader(importer, ctx); Assembly assembly = dynamicLoader.LoadAssemblyFile(file, isImplicitReference: false); if ((object)assembly == null) { return; } lock (evaluator_lock) { importer.ImportAssembly(assembly, module.GlobalRootNamespace); } } public void ReferenceAssembly(Assembly a) { lock (evaluator_lock) { importer.ImportAssembly(a, module.GlobalRootNamespace); } } public void ImportTypes(bool importExtensionTypes, params Type[] types) { importer.ImportTypes(types, module.GlobalRootNamespace, importExtensionTypes); } } internal delegate void CompiledMethod(ref object retvalue); internal class InteractiveBase { public static TextWriter Output = Console.Out; public static TextWriter Error = Console.Error; public static string Prompt = "csharp> "; public static string ContinuationPrompt = " > "; public static bool QuitRequested; public static Evaluator Evaluator; public static string help => "Static methods:\n Describe (object); - Describes the object's type\n LoadPackage (package); - Loads the given Package (like -pkg:FILE)\n LoadAssembly (assembly); - Loads the given assembly (like -r:ASSEMBLY)\n ShowVars (); - Shows defined local variables.\n ShowUsing (); - Show active using declarations.\n Prompt - The prompt used by the C# shell\n ContinuationPrompt - The prompt for partial input\n Time (() => { }); - Times the specified code\n print (obj); - Shorthand for Console.WriteLine\n quit; - You'll never believe it - this quits the repl!\n help; - This help text\n"; public static object quit { get { QuitRequested = true; return typeof(Evaluator.QuitValue); } } public static void ShowVars() { Output.Write(Evaluator.GetVars()); Output.Flush(); } public static void ShowUsing() { Output.Write(Evaluator.GetUsing()); Output.Flush(); } public static TimeSpan Time(Action a) { DateTime now = DateTime.Now; a(); return DateTime.Now - now; } public static void LoadPackage(string pkg) { if (pkg == null) { Error.WriteLine("Invalid package specified"); return; } string packageFlags = Driver.GetPackageFlags(pkg, null); string[] array = packageFlags.Trim(' ', '\n', '\r', '\t').Split(' ', '\t'); string[] array2 = array; foreach (string text in array2) { if (text.StartsWith("-r:") || text.StartsWith("/r:") || text.StartsWith("/reference:")) { string file = text.Substring(text.IndexOf(':') + 1); Evaluator.LoadAssembly(file); } } } public static void LoadAssembly(string assembly) { Evaluator.LoadAssembly(assembly); } public static void print(object obj) { Output.WriteLine(obj); } public static void print(string fmt, params object[] args) { Output.WriteLine(fmt, args); } public static void Quit() { QuitRequested = true; } public static string Describe(object x) { if (x == null) { return ""; } Type t = (x as Type) ?? x.GetType(); StringWriter stringWriter = new StringWriter(); new Outline(t, stringWriter, declared_only: true, show_private: false, filter_obsolete: false).OutlineType(); return stringWriter.ToString(); } } internal class InteractiveMethod : Method { public static int host_counter; public InteractiveMethod(TypeDefinition parent, FullNamedExpression returnType, Modifiers mod, ParametersCompiled parameters) : base(parent, returnType, mod, new MemberName("Host" + host_counter++), parameters, null) { } public void ChangeToAsync() { base.ModFlags |= Modifiers.ASYNC; base.ModFlags &= ~Modifiers.UNSAFE; type_expr = new TypeExpression(Module.PredefinedTypes.Task.TypeSpec, base.Location); parameters = ParametersCompiled.EmptyReadOnlyParameters; } public override string GetSignatureForError() { return "InteractiveHost"; } } internal class HoistedEvaluatorVariable : HoistedVariable { public HoistedEvaluatorVariable(Field field) : base(null, field) { } protected override FieldExpr GetFieldExpression(EmitContext ec) { return new FieldExpr(field, field.Location); } } internal class OptionalAssign : SimpleAssign { public override Location StartLocation => Location.Null; public OptionalAssign(Expression s, Location loc) : base(null, s, loc) { } protected override Expression DoResolve(ResolveContext ec) { Expression expression = source.Clone(new CloneContext()); expression = expression.Resolve(ec); if (expression == null) { return null; } if (ec.Module.Evaluator.DescribeTypeExpressions && !(ec.CurrentAnonymousMethod is AsyncInitializer)) { ReportPrinter printer = ec.Report.SetPrinter(new SessionReportPrinter()); Expression expression2; try { expression2 = source.Clone(new CloneContext()); expression2 = expression2.Resolve(ec, ResolveFlags.Type); if (ec.Report.Errors > 0) { expression2 = null; } } finally { ec.Report.SetPrinter(printer); } if (expression2 is TypeExpr) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(new TypeOf((TypeExpr)expression, base.Location))); return new Invocation(new SimpleName("Describe", base.Location), arguments).Resolve(ec); } } if (expression.Type.Kind == MemberKind.Void || expression is DynamicInvocation || expression is Assign) { return expression; } source = expression; Method method = (Method)ec.MemberContext.CurrentMemberDefinition; if (method.ParameterInfo.IsEmpty) { eclass = ExprClass.Value; type = InternalType.FakeInternalType; return this; } target = new SimpleName(method.ParameterInfo[0].Name, base.Location); return base.DoResolve(ec); } public override void EmitStatement(EmitContext ec) { if (target == null) { source.Emit(ec); } else { base.EmitStatement(ec); } } } internal class Undo { private List undo_actions; public void AddTypeContainer(TypeContainer current_container, TypeDefinition tc) { if (current_container == tc) { Console.Error.WriteLine("Internal error: inserting container into itself"); return; } if (undo_actions == null) { undo_actions = new List(); } if (current_container.Containers != null) { TypeContainer existing = current_container.Containers.FirstOrDefault((TypeContainer l) => l.MemberName.Basename == tc.MemberName.Basename); if (existing != null) { current_container.RemoveContainer(existing); undo_actions.Add(delegate { current_container.AddTypeContainer(existing); }); } } undo_actions.Add(delegate { current_container.RemoveContainer(tc); }); } public void ExecuteUndo() { if (undo_actions == null) { return; } foreach (Action undo_action in undo_actions) { undo_action(); } undo_actions = null; } } internal static class ListenerProxy { private static readonly Dictionary listeners = new Dictionary(); private static int counter; public static int Register(ValueModificationHandler listener) { lock (listeners) { int num = counter++; listeners.Add(num, listener); return num; } } public static void Unregister(int listenerId) { lock (listeners) { listeners.Remove(listenerId); } } public static void ValueChanged(object value, int row, int col, string name, int listenerId) { ValueModificationHandler value2; lock (listeners) { if (!listeners.TryGetValue(listenerId, out value2)) { return; } } value2(name, row, col, value); } } internal class UserOperatorCall : Expression { protected readonly Arguments arguments; protected readonly MethodSpec oper; private readonly Func expr_tree; public UserOperatorCall(MethodSpec oper, Arguments args, Func expr_tree, Location loc) { this.oper = oper; arguments = args; this.expr_tree = expr_tree; type = oper.ReturnType; eclass = ExprClass.Value; base.loc = loc; } public override bool ContainsEmitWithAwait() { return arguments.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { if (expr_tree != null) { return expr_tree(ec, new TypeOfMethod(oper, loc)); } Arguments args = Arguments.CreateForExpressionTree(ec, arguments, new NullLiteral(loc), new TypeOfMethod(oper, loc)); return CreateExpressionFactoryCall(ec, "Call", args); } protected override void CloneTo(CloneContext context, Expression target) { } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { default(CallEmitter).Emit(ec, oper, arguments, loc); } public override void FlowAnalysis(FlowAnalysisContext fc) { arguments.FlowAnalysis(fc); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Call((MethodInfo)oper.GetMetaInfo(), Arguments.MakeExpression(arguments, ctx)); } } internal class ParenthesizedExpression : ShimExpression { public ParenthesizedExpression(Expression expr, Location loc) : base(expr) { base.loc = loc; } protected override Expression DoResolve(ResolveContext rc) { Expression expression = null; using (rc.With(ResolveContext.Options.DontSetConditionalAccessReceiver, enable: false)) { expression = expr.Resolve(rc); } if (expression is Constant { IsLiteral: not false } constant) { if (expression is NullLiteral) { return expression; } return Constant.CreateConstantFromValue(expression.Type, constant.GetValue(), expr.Location); } return expression; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return expr.DoResolveLValue(ec, right_side); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public override bool HasConditionalAccess() { return false; } } internal class Unary : Expression { public enum Operator : byte { UnaryPlus, UnaryNegation, LogicalNot, OnesComplement, AddressOf, TOP } public readonly Operator Oper; public Expression Expr; private ConvCast.Mode enum_conversion; public Unary(Operator op, Expression expr, Location loc) { Oper = op; Expr = expr; base.loc = loc; } private Constant TryReduceConstant(ResolveContext ec, Constant constant) { Constant constant2 = constant; while (constant2 is EmptyConstantCast) { constant2 = ((EmptyConstantCast)constant2).child; } if (constant2 is SideEffectConstant) { Constant constant3 = TryReduceConstant(ec, ((SideEffectConstant)constant2).value); return (constant3 == null) ? null : new SideEffectConstant(constant3, constant2, constant3.Location); } TypeSpec typeSpec = constant2.Type; switch (Oper) { case Operator.UnaryPlus: switch (typeSpec.BuiltinType) { case BuiltinTypeSpec.Type.Byte: return new IntConstant(ec.BuiltinTypes, ((ByteConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.SByte: return new IntConstant(ec.BuiltinTypes, ((SByteConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Short: return new IntConstant(ec.BuiltinTypes, ((ShortConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.UShort: return new IntConstant(ec.BuiltinTypes, ((UShortConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Char: return new IntConstant(ec.BuiltinTypes, ((CharConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.Long: case BuiltinTypeSpec.Type.ULong: case BuiltinTypeSpec.Type.Float: case BuiltinTypeSpec.Type.Double: case BuiltinTypeSpec.Type.Decimal: return constant2; default: return null; } case Operator.UnaryNegation: switch (typeSpec.BuiltinType) { case BuiltinTypeSpec.Type.Byte: return new IntConstant(ec.BuiltinTypes, -((ByteConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.SByte: return new IntConstant(ec.BuiltinTypes, -((SByteConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Short: return new IntConstant(ec.BuiltinTypes, -((ShortConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.UShort: return new IntConstant(ec.BuiltinTypes, -((UShortConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Char: return new IntConstant(ec.BuiltinTypes, 0 - ((CharConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Int: { int value2 = ((IntConstant)constant2).Value; if (value2 == int.MinValue) { if (ec.ConstantCheckState) { ConstantFold.Error_CompileTimeOverflow(ec, loc); return null; } return constant2; } return new IntConstant(ec.BuiltinTypes, -value2, constant2.Location); } case BuiltinTypeSpec.Type.Long: { long value3 = ((LongConstant)constant2).Value; if (value3 == long.MinValue) { if (ec.ConstantCheckState) { ConstantFold.Error_CompileTimeOverflow(ec, loc); return null; } return constant2; } return new LongConstant(ec.BuiltinTypes, -value3, constant2.Location); } case BuiltinTypeSpec.Type.UInt: if (constant is UIntLiteral uIntLiteral) { if (uIntLiteral.Value == 2147483648u) { return new IntLiteral(ec.BuiltinTypes, int.MinValue, constant2.Location); } return new LongLiteral(ec.BuiltinTypes, 0L - (long)uIntLiteral.Value, constant2.Location); } return new LongConstant(ec.BuiltinTypes, 0L - (long)((UIntConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.ULong: if (constant is ULongLiteral { Value: 9223372036854775808uL }) { return new LongLiteral(ec.BuiltinTypes, long.MinValue, constant2.Location); } return null; case BuiltinTypeSpec.Type.Float: if (constant is FloatLiteral floatLiteral) { return new FloatLiteral(ec.BuiltinTypes, 0f - floatLiteral.Value, constant2.Location); } return new FloatConstant(ec.BuiltinTypes, 0f - ((FloatConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Double: if (constant is DoubleLiteral doubleLiteral) { return new DoubleLiteral(ec.BuiltinTypes, 0.0 - doubleLiteral.Value, constant2.Location); } return new DoubleConstant(ec.BuiltinTypes, 0.0 - ((DoubleConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(ec.BuiltinTypes, -((DecimalConstant)constant2).Value, constant2.Location); default: return null; } case Operator.LogicalNot: { if (typeSpec.BuiltinType != BuiltinTypeSpec.Type.FirstPrimitive) { return null; } bool flag = (bool)constant2.GetValue(); return new BoolConstant(ec.BuiltinTypes, !flag, constant2.Location); } case Operator.OnesComplement: switch (typeSpec.BuiltinType) { case BuiltinTypeSpec.Type.Byte: return new IntConstant(ec.BuiltinTypes, ~((ByteConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.SByte: return new IntConstant(ec.BuiltinTypes, ~((SByteConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Short: return new IntConstant(ec.BuiltinTypes, ~((ShortConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.UShort: return new IntConstant(ec.BuiltinTypes, ~((UShortConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Char: return new IntConstant(ec.BuiltinTypes, ~(int)((CharConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Int: return new IntConstant(ec.BuiltinTypes, ~((IntConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(ec.BuiltinTypes, ~((UIntConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.Long: return new LongConstant(ec.BuiltinTypes, ~((LongConstant)constant2).Value, constant2.Location); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(ec.BuiltinTypes, ~((ULongConstant)constant2).Value, constant2.Location); default: if (constant2 is EnumConstant) { Constant constant4 = TryReduceConstant(ec, ((EnumConstant)constant2).Child); if (constant4 != null) { if (constant4.Type.BuiltinType == BuiltinTypeSpec.Type.Int) { int value = ((IntConstant)constant4).Value; switch (((EnumConstant)constant2).Child.Type.BuiltinType) { case BuiltinTypeSpec.Type.UShort: constant4 = new UShortConstant(ec.BuiltinTypes, (ushort)value, constant2.Location); break; case BuiltinTypeSpec.Type.Short: constant4 = new ShortConstant(ec.BuiltinTypes, (short)value, constant2.Location); break; case BuiltinTypeSpec.Type.Byte: constant4 = new ByteConstant(ec.BuiltinTypes, (byte)value, constant2.Location); break; case BuiltinTypeSpec.Type.SByte: constant4 = new SByteConstant(ec.BuiltinTypes, (sbyte)value, constant2.Location); break; } } constant4 = new EnumConstant(constant4, typeSpec); } return constant4; } return null; } default: throw new Exception("Can not constant fold: " + Oper); } } protected virtual Expression ResolveOperator(ResolveContext ec, Expression expr) { eclass = ExprClass.Value; TypeSpec typeSpec = expr.Type; TypeSpec[] predefined = ec.BuiltinTypes.OperatorsUnary[(uint)Oper]; if (BuiltinTypeSpec.IsPrimitiveType(typeSpec)) { Expression expression = ResolvePrimitivePredefinedType(ec, expr, predefined); if (expression == null) { return null; } type = expression.Type; Expr = expression; return this; } if (Oper == Operator.OnesComplement && typeSpec.IsEnum) { return ResolveEnumOperator(ec, expr, predefined); } return ResolveUserType(ec, expr, predefined); } protected virtual Expression ResolveEnumOperator(ResolveContext ec, Expression expr, TypeSpec[] predefined) { TypeSpec underlyingType = EnumSpec.GetUnderlyingType(expr.Type); Expression expression = ResolvePrimitivePredefinedType(ec, EmptyCast.Create(expr, underlyingType), predefined); if (expression == null) { return null; } Expr = expression; enum_conversion = Binary.GetEnumResultCast(underlyingType); type = expr.Type; return EmptyCast.Create(this, type); } public override bool ContainsEmitWithAwait() { return Expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { return CreateExpressionTree(ec, null); } private Expression CreateExpressionTree(ResolveContext ec, Expression user_op) { string name; switch (Oper) { case Operator.AddressOf: Error_PointerInsideExpressionTree(ec); return null; case Operator.UnaryNegation: name = ((!ec.HasSet(ResolveContext.Options.CheckedScope) || user_op != null || IsFloat(type)) ? "Negate" : "NegateChecked"); break; case Operator.LogicalNot: case Operator.OnesComplement: name = "Not"; break; case Operator.UnaryPlus: name = "UnaryPlus"; break; default: throw new InternalErrorException("Unknown unary operator " + Oper); } Arguments arguments = new Arguments(2); arguments.Add(new Argument(Expr.CreateExpressionTree(ec))); if (user_op != null) { arguments.Add(new Argument(user_op)); } return CreateExpressionFactoryCall(ec, name, arguments); } public static TypeSpec[][] CreatePredefinedOperatorsTable(BuiltinTypes types) { return new TypeSpec[5][] { new TypeSpec[7] { types.Int, types.UInt, types.Long, types.ULong, types.Float, types.Double, types.Decimal }, new TypeSpec[5] { types.Int, types.Long, types.Float, types.Double, types.Decimal }, new TypeSpec[1] { types.Bool }, new TypeSpec[4] { types.Int, types.UInt, types.Long, types.ULong }, null }; } private static Expression DoNumericPromotion(ResolveContext rc, Operator op, Expression expr) { TypeSpec typeSpec = expr.Type; if (op == Operator.UnaryPlus || op == Operator.UnaryNegation || op == Operator.OnesComplement) { BuiltinTypeSpec.Type builtinType = typeSpec.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 2) <= 4u) { return Convert.ImplicitNumericConversion(expr, rc.BuiltinTypes.Int); } } if (op == Operator.UnaryNegation && typeSpec.BuiltinType == BuiltinTypeSpec.Type.UInt) { return Convert.ImplicitNumericConversion(expr, rc.BuiltinTypes.Long); } return expr; } protected override Expression DoResolve(ResolveContext ec) { if (Oper == Operator.AddressOf) { return ResolveAddressOf(ec); } Expr = Expr.Resolve(ec); if (Expr == null) { return null; } if (Expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(Expr)); return new DynamicUnaryConversion(GetOperatorExpressionTypeName(), arguments, loc).Resolve(ec); } if (Expr.Type.IsNullableType) { return new LiftedUnaryOperator(Oper, Expr, loc).Resolve(ec); } if (Expr is Constant constant) { Constant constant2 = TryReduceConstant(ec, constant); if (constant2 != null) { return constant2; } } Expression expression = ResolveOperator(ec, Expr); if (expression == null) { Error_OperatorCannotBeApplied(ec, loc, OperName(Oper), Expr.Type); } if (expression == this && Oper == Operator.UnaryPlus) { return Expr; } return expression; } public override Expression DoResolveLValue(ResolveContext ec, Expression right) { return null; } public override void Emit(EmitContext ec) { EmitOperator(ec, type); } protected void EmitOperator(EmitContext ec, TypeSpec type) { switch (Oper) { case Operator.UnaryPlus: Expr.Emit(ec); break; case Operator.UnaryNegation: if (ec.HasSet(BuilderContext.Options.CheckedScope) && !IsFloat(type)) { if (ec.HasSet(BuilderContext.Options.AsyncBody) && Expr.ContainsEmitWithAwait()) { Expr = Expr.EmitToField(ec); } ec.EmitInt(0); if (type.BuiltinType == BuiltinTypeSpec.Type.Long) { ec.Emit(OpCodes.Conv_U8); } Expr.Emit(ec); ec.Emit(OpCodes.Sub_Ovf); } else { Expr.Emit(ec); ec.Emit(OpCodes.Neg); } break; case Operator.LogicalNot: Expr.Emit(ec); ec.EmitInt(0); ec.Emit(OpCodes.Ceq); break; case Operator.OnesComplement: Expr.Emit(ec); ec.Emit(OpCodes.Not); break; case Operator.AddressOf: ((IMemoryLocation)Expr).AddressOf(ec, AddressOp.LoadStore); break; default: throw new Exception("This should not happen: Operator = " + Oper); } if (enum_conversion != ConvCast.Mode.I1_U1) { using (ec.With(BuilderContext.Options.CheckedScope, enable: false)) { ConvCast.Emit(ec, enum_conversion); } } } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { if (Oper == Operator.LogicalNot) { Expr.EmitBranchable(ec, target, !on_true); } else { base.EmitBranchable(ec, target, on_true); } } public override void EmitSideEffect(EmitContext ec) { Expr.EmitSideEffect(ec); } public static void Error_Ambiguous(ResolveContext rc, string oper, TypeSpec type, Location loc) { rc.Report.Error(35, loc, "Operator `{0}' is ambiguous on an operand of type `{1}'", oper, type.GetSignatureForError()); } public override void FlowAnalysis(FlowAnalysisContext fc) { FlowAnalysis(fc, conditional: false); } public override void FlowAnalysisConditional(FlowAnalysisContext fc) { FlowAnalysis(fc, conditional: true); } private void FlowAnalysis(FlowAnalysisContext fc, bool conditional) { if (Oper == Operator.AddressOf) { if (Expr is VariableReference { VariableInfo: not null } variableReference) { fc.SetVariableAssigned(variableReference.VariableInfo); } } else if (Oper == Operator.LogicalNot && conditional) { Expr.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignmentOnTrue = fc.DefiniteAssignmentOnTrue; fc.DefiniteAssignmentOnTrue = fc.DefiniteAssignmentOnFalse; fc.DefiniteAssignmentOnFalse = definiteAssignmentOnTrue; } else { Expr.FlowAnalysis(fc); } } private string GetOperatorExpressionTypeName() { return Oper switch { Operator.OnesComplement => "OnesComplement", Operator.LogicalNot => "Not", Operator.UnaryNegation => "Negate", Operator.UnaryPlus => "UnaryPlus", _ => throw new NotImplementedException("Unknown express type operator " + Oper), }; } private static bool IsFloat(TypeSpec t) { return t.BuiltinType == BuiltinTypeSpec.Type.Double || t.BuiltinType == BuiltinTypeSpec.Type.Float; } public static string OperName(Operator oper) { return oper switch { Operator.UnaryPlus => "+", Operator.UnaryNegation => "-", Operator.LogicalNot => "!", Operator.OnesComplement => "~", Operator.AddressOf => "&", _ => throw new NotImplementedException(oper.ToString()), }; } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { System.Linq.Expressions.Expression expression = Expr.MakeExpression(ctx); bool flag = ctx.HasSet(BuilderContext.Options.CheckedScope); return Oper switch { Operator.UnaryNegation => flag ? System.Linq.Expressions.Expression.NegateChecked(expression) : System.Linq.Expressions.Expression.Negate(expression), Operator.LogicalNot => System.Linq.Expressions.Expression.Not(expression), _ => throw new NotImplementedException(Oper.ToString()), }; } private Expression ResolveAddressOf(ResolveContext ec) { if (ec.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(ec, loc); } else if (!ec.IsUnsafe) { Expression.UnsafeError(ec, loc); } Expr = Expr.DoResolveLValue(ec, EmptyExpression.UnaryAddress); if (Expr == null || Expr.eclass != ExprClass.Variable) { ec.Report.Error(211, loc, "Cannot take the address of the given expression"); return null; } if (!TypeManager.VerifyUnmanaged(ec.Module, Expr.Type, loc)) { return null; } bool flag; if (Expr is IVariableReference variableReference) { flag = variableReference.IsFixed; variableReference.SetHasAddressTaken(); if (variableReference.IsHoisted && ec.CurrentIterator == null) { AnonymousMethodExpression.Error_AddressOfCapturedVar(ec, variableReference, loc); } } else { flag = Expr is IFixedExpression fixedExpression && fixedExpression.IsFixed; } if (!flag && !ec.HasSet(ResolveContext.Options.FixedInitializerScope)) { ec.Report.Error(212, loc, "You can only take the address of unfixed expression inside of a fixed statement initializer"); } type = PointerContainer.MakeType(ec.Module, Expr.Type); eclass = ExprClass.Value; return this; } private Expression ResolvePrimitivePredefinedType(ResolveContext rc, Expression expr, TypeSpec[] predefined) { expr = DoNumericPromotion(rc, Oper, expr); TypeSpec typeSpec = expr.Type; foreach (TypeSpec typeSpec2 in predefined) { if (typeSpec2 == typeSpec) { return expr; } } return null; } protected virtual Expression ResolveUserOperator(ResolveContext ec, Expression expr) { IList list = MemberCache.GetUserOperator(op: Oper switch { Operator.LogicalNot => Mono.CSharp.Operator.OpType.LogicalNot, Operator.OnesComplement => Mono.CSharp.Operator.OpType.OnesComplement, Operator.UnaryNegation => Mono.CSharp.Operator.OpType.UnaryNegation, Operator.UnaryPlus => Mono.CSharp.Operator.OpType.UnaryPlus, _ => throw new InternalErrorException(Oper.ToString()), }, container: expr.Type, declaredOnly: false); if (list == null) { return null; } Arguments args = new Arguments(1); args.Add(new Argument(expr)); MethodSpec methodSpec = new OverloadResolver(list, OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded, loc).ResolveOperator(ec, ref args); if (methodSpec == null) { return null; } Expr = args[0].Expr; return new UserOperatorCall(methodSpec, args, CreateExpressionTree, expr.Location); } private Expression ResolveUserType(ResolveContext ec, Expression expr, TypeSpec[] predefined) { Expression expression = ResolveUserOperator(ec, expr); if (expression != null) { return expression; } foreach (TypeSpec typeSpec in predefined) { Expression expression2 = Convert.ImplicitUserConversion(ec, expr, typeSpec, expr.Location); if (expression2 == null) { continue; } if (expression2 == ErrorExpression.Instance) { return expression2; } expression2 = ((expression2.Type.BuiltinType != BuiltinTypeSpec.Type.Decimal) ? ResolvePrimitivePredefinedType(ec, expression2, predefined) : ResolveUserType(ec, expression2, predefined)); if (expression2 == null) { continue; } if (expression == null) { expression = expression2; continue; } switch (OverloadResolver.BetterTypeConversion(ec, expression.Type, typeSpec)) { case 0: break; case 2: expression = expression2; continue; default: continue; } if ((expression2 is UserOperatorCall || expression2 is UserCast) && (expression is UserOperatorCall || expression is UserCast)) { Error_Ambiguous(ec, OperName(Oper), expr.Type, loc); } else { Error_OperatorCannotBeApplied(ec, loc, OperName(Oper), expr.Type); } break; } if (expression == null) { return null; } if (expression.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { return expression; } Expr = expression; type = expression.Type; return this; } protected override void CloneTo(CloneContext clonectx, Expression t) { Unary unary = (Unary)t; unary.Expr = Expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Indirection : Expression, IMemoryLocation, IAssignMethod, IFixedExpression { private Expression expr; private LocalTemporary temporary; private bool prepared; public Expression Expr => expr; public bool IsFixed => true; public override Location StartLocation => expr.StartLocation; public Indirection(Expression expr, Location l) { this.expr = expr; loc = l; } protected override void CloneTo(CloneContext clonectx, Expression t) { Indirection indirection = (Indirection)t; indirection.expr = expr.Clone(clonectx); } public override bool ContainsEmitWithAwait() { throw new NotImplementedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { Error_PointerInsideExpressionTree(ec); return null; } public override void Emit(EmitContext ec) { if (!prepared) { expr.Emit(ec); } ec.EmitLoadFromPtr(base.Type); } public void Emit(EmitContext ec, bool leave_copy) { Emit(ec); if (leave_copy) { ec.Emit(OpCodes.Dup); temporary = new LocalTemporary(expr.Type); temporary.Store(ec); } } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { prepared = isCompound; expr.Emit(ec); if (isCompound) { ec.Emit(OpCodes.Dup); } source.Emit(ec); if (leave_copy) { ec.Emit(OpCodes.Dup); temporary = new LocalTemporary(source.Type); temporary.Store(ec); } ec.EmitStoreFromPtr(type); if (temporary != null) { temporary.Emit(ec); temporary.Release(ec); } } public void AddressOf(EmitContext ec, AddressOp Mode) { expr.Emit(ec); } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return DoResolve(ec); } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); if (expr == null) { return null; } if (ec.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(ec, loc); } else if (!ec.IsUnsafe) { Expression.UnsafeError(ec, loc); } if (!(expr.Type is PointerContainer pointerContainer)) { ec.Report.Error(193, loc, "The * or -> operator must be applied to a pointer"); return null; } type = pointerContainer.Element; if (type.Kind == MemberKind.Void) { Error_VoidPointerOperation(ec); return null; } eclass = ExprClass.Variable; return this; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class UnaryMutator : ExpressionStatement { private class DynamicPostMutator : Expression, IAssignMethod { private LocalTemporary temp; private Expression expr; public DynamicPostMutator(Expression expr) { this.expr = expr; type = expr.Type; loc = expr.Location; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotImplementedException("ET"); } protected override Expression DoResolve(ResolveContext rc) { eclass = expr.eclass; return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { expr.DoResolveLValue(ec, right_side); return DoResolve(ec); } public override void Emit(EmitContext ec) { temp.Emit(ec); } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { temp = new LocalTemporary(type); expr.Emit(ec); temp.Store(ec); ((IAssignMethod)expr).EmitAssign(ec, source, leave_copy: false, isCompound); if (leave_copy) { Emit(ec); } temp.Release(ec); temp = null; } } [Flags] public enum Mode : byte { IsIncrement = 0, IsDecrement = 1, IsPre = 0, IsPost = 2, PreIncrement = 0, PreDecrement = 1, PostIncrement = 2, PostDecrement = 3 } private Mode mode; private bool is_expr; private bool recurse; protected Expression expr; private Expression operation; public Mode UnaryMutatorMode => mode; public Expression Expr => expr; public override Location StartLocation => ((mode & Mode.IsPost) != Mode.IsIncrement) ? expr.Location : loc; private bool IsDecrement => (mode & Mode.IsDecrement) != 0; public UnaryMutator(Mode m, Expression e, Location loc) { mode = m; base.loc = loc; expr = e; } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { return new SimpleAssign(this, this).CreateExpressionTree(ec); } public static TypeSpec[] CreatePredefinedOperatorsTable(BuiltinTypes types) { return new TypeSpec[11] { types.Int, types.Long, types.SByte, types.Byte, types.Short, types.UInt, types.ULong, types.Char, types.Float, types.Double, types.Decimal }; } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); if (expr == null || expr.Type == InternalType.ErrorType) { return null; } if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { if ((mode & Mode.IsPost) != Mode.IsIncrement) { expr = new DynamicPostMutator(expr); } Arguments arguments = new Arguments(1); arguments.Add(new Argument(expr)); return new SimpleAssign(expr, new DynamicUnaryConversion(GetOperatorExpressionTypeName(), arguments, loc)).Resolve(ec); } if (expr.Type.IsNullableType) { return new LiftedUnaryMutator(mode, expr, loc).Resolve(ec); } return DoResolveOperation(ec); } protected Expression DoResolveOperation(ResolveContext ec) { eclass = ExprClass.Value; base.type = expr.Type; if (expr is RuntimeValueExpression) { operation = expr; } else { operation = new EmptyExpression(base.type); } if (expr.eclass == ExprClass.Variable || expr.eclass == ExprClass.IndexerAccess || expr.eclass == ExprClass.PropertyAccess) { expr = expr.ResolveLValue(ec, expr); Operator.OpType opType = (IsDecrement ? Operator.OpType.Decrement : Operator.OpType.Increment); IList userOperator = MemberCache.GetUserOperator(base.type, opType, declaredOnly: false); if (userOperator != null) { Arguments args = new Arguments(1); args.Add(new Argument(expr)); MethodSpec methodSpec = new OverloadResolver(userOperator, OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded, loc).ResolveOperator(ec, ref args); if (methodSpec == null) { return null; } args[0].Expr = operation; operation = new UserOperatorCall(methodSpec, args, null, loc); operation = Convert.ImplicitConversionRequired(ec, operation, base.type, loc); return this; } Expression expression = null; BuiltinTypeSpec.Type builtinType = base.type.BuiltinType; BuiltinTypeSpec.Type type = builtinType; bool flag; if ((uint)(type - 2) <= 11u) { expression = operation; flag = true; } else { flag = false; if (base.type.IsPointer) { if (((PointerContainer)base.type).Element.Kind == MemberKind.Void) { Error_VoidPointerOperation(ec); return null; } expression = operation; } else { Expression expression2 = null; TypeSpec[] operatorsUnaryMutator = ec.BuiltinTypes.OperatorsUnaryMutator; foreach (TypeSpec target in operatorsUnaryMutator) { expression = Convert.ImplicitUserConversion(ec, operation, target, loc); if (expression == null) { continue; } if (expression2 == null) { expression2 = expression; continue; } switch (OverloadResolver.BetterTypeConversion(ec, expression2.Type, expression.Type)) { case 2: expression2 = expression; continue; case 1: continue; } Unary.Error_Ambiguous(ec, OperName(mode), base.type, loc); break; } expression = expression2; } if (expression == null && base.type.IsEnum) { expression = operation; } if (expression == null) { expr.Error_OperatorCannotBeApplied(ec, loc, Operator.GetName(opType), base.type); return null; } } IntConstant right = new IntConstant(ec.BuiltinTypes, 1, loc); Binary.Operator oper = (IsDecrement ? Binary.Operator.Subtraction : Binary.Operator.Addition); operation = new Binary(oper, expression, right); operation = operation.Resolve(ec); if (operation == null) { throw new NotImplementedException("should not be reached"); } if (operation.Type != base.type) { if (flag) { operation = Convert.ExplicitNumericConversion(ec, operation, base.type); } else { operation = Convert.ImplicitConversionRequired(ec, operation, base.type, loc); } } return this; } ec.Report.Error(1059, loc, "The operand of an increment or decrement operator must be a variable, property or indexer"); return null; } private void EmitCode(EmitContext ec, bool is_expr) { recurse = true; this.is_expr = is_expr; ((IAssignMethod)expr).EmitAssign(ec, this, is_expr && (mode == Mode.IsIncrement || mode == Mode.IsDecrement), isCompound: true); } public override void Emit(EmitContext ec) { if (recurse) { ((IAssignMethod)expr).Emit(ec, is_expr && (mode == Mode.IsPost || mode == Mode.PostDecrement)); EmitOperation(ec); recurse = false; } else { EmitCode(ec, is_expr: true); } } protected virtual void EmitOperation(EmitContext ec) { operation.Emit(ec); } public override void EmitStatement(EmitContext ec) { EmitCode(ec, is_expr: false); } public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); } private string GetOperatorExpressionTypeName() { return IsDecrement ? "Decrement" : "Increment"; } public static string OperName(Mode oper) { return ((oper & Mode.IsDecrement) != Mode.IsIncrement) ? "--" : "++"; } protected override void CloneTo(CloneContext clonectx, Expression t) { UnaryMutator unaryMutator = (UnaryMutator)t; unaryMutator.expr = expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class Probe : Expression { public Expression ProbeType; protected Expression expr; protected TypeSpec probe_type_expr; public Expression Expr => expr; protected abstract string OperatorName { get; } protected Probe(Expression expr, Expression probe_type, Location l) { ProbeType = probe_type; loc = l; this.expr = expr; } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } protected Expression ResolveCommon(ResolveContext rc) { expr = expr.Resolve(rc); if (expr == null) { return null; } ResolveProbeType(rc); if (probe_type_expr == null) { return this; } if (probe_type_expr.IsStatic) { rc.Report.Error(7023, loc, "The second operand of `is' or `as' operator cannot be static type `{0}'", probe_type_expr.GetSignatureForError()); return null; } if (expr.Type.IsPointer || probe_type_expr.IsPointer) { rc.Report.Error(244, loc, "The `{0}' operator cannot be applied to an operand of pointer type", OperatorName); return null; } if (expr.Type == InternalType.AnonymousMethod || expr.Type == InternalType.MethodGroup) { rc.Report.Error(837, loc, "The `{0}' operator cannot be applied to a lambda expression, anonymous method, or method group", OperatorName); return null; } if (expr.Type == InternalType.DefaultType) { Error_OperatorCannotBeApplied(rc, loc, OperatorName, expr.Type); return null; } return this; } protected virtual void ResolveProbeType(ResolveContext rc) { probe_type_expr = ProbeType.ResolveAsType(rc); } public override void EmitSideEffect(EmitContext ec) { expr.EmitSideEffect(ec); } public override void EmitPrepare(EmitContext ec) { expr.EmitPrepare(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); } public override bool HasConditionalAccess() { return expr.HasConditionalAccess(); } protected override void CloneTo(CloneContext clonectx, Expression t) { Probe probe = (Probe)t; probe.expr = expr.Clone(clonectx); probe.ProbeType = ProbeType.Clone(clonectx); } } internal class Is : Probe { private Unwrap expr_unwrap; private MethodSpec number_mg; private Arguments number_args; protected override string OperatorName => "is"; public LocalVariable Variable { get; set; } public Is(Expression expr, Expression probe_type, Location l) : base(expr, probe_type, l) { } public override Expression CreateExpressionTree(ResolveContext ec) { if (Variable != null) { ec.Report.Error(8122, loc, "An expression tree cannot contain a pattern matching operator"); } Arguments args = Arguments.CreateForExpressionTree(ec, null, expr.CreateExpressionTree(ec), new TypeOf(probe_type_expr, loc)); return CreateExpressionFactoryCall(ec, "TypeIs", args); } private Expression CreateConstantResult(ResolveContext rc, bool result) { if (result) { rc.Report.Warning(183, 1, loc, "The given expression is always of the provided (`{0}') type", probe_type_expr.GetSignatureForError()); } else { rc.Report.Warning(184, 1, loc, "The given expression is never of the provided (`{0}') type", probe_type_expr.GetSignatureForError()); } BoolConstant value = new BoolConstant(rc.BuiltinTypes, result, loc); return expr.IsSideEffectFree ? ReducedExpression.Create(value, this) : new SideEffectConstant(value, this, loc); } public override void Emit(EmitContext ec) { if (probe_type_expr == null) { if (ProbeType is WildcardPattern) { expr.EmitSideEffect(ec); ProbeType.Emit(ec); } else { EmitPatternMatch(ec); } return; } EmitLoad(ec); if (expr_unwrap == null) { ec.EmitNull(); ec.Emit(OpCodes.Cgt_Un); } } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { if (probe_type_expr == null) { EmitPatternMatch(ec); } else { EmitLoad(ec); } ec.Emit(on_true ? OpCodes.Brtrue : OpCodes.Brfalse, target); } public override void EmitPrepare(EmitContext ec) { base.EmitPrepare(ec); if (Variable != null) { Variable.CreateBuilder(ec); } } private void EmitPatternMatch(EmitContext ec) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); if (expr_unwrap != null) { expr_unwrap.EmitCheck(ec); if (ProbeType.IsNull) { ec.EmitInt(0); ec.Emit(OpCodes.Ceq); return; } ec.Emit(OpCodes.Brfalse_S, label); expr_unwrap.Emit(ec); ProbeType.Emit(ec); ec.Emit(OpCodes.Ceq); ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); ec.EmitInt(0); ec.MarkLabel(label2); return; } if (number_args != null && number_args.Count == 3) { default(CallEmitter).Emit(ec, number_mg, number_args, loc); return; } TypeSpec t = ProbeType.Type; base.Expr.Emit(ec); ec.Emit(OpCodes.Isinst, t); ec.Emit(OpCodes.Dup); ec.Emit(OpCodes.Brfalse, label); bool flag = ProbeType is ComplexPatternExpression; Label recursivePatternLabel = ec.RecursivePatternLabel; if (flag) { ec.RecursivePatternLabel = ec.DefineLabel(); } if (number_mg != null) { default(CallEmitter).Emit(ec, number_mg, number_args, loc); } else { if (TypeSpec.IsValueType(t)) { ec.Emit(OpCodes.Unbox_Any, t); } ProbeType.Emit(ec); if (flag) { ec.EmitInt(1); } else { ec.Emit(OpCodes.Ceq); } } ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); ec.Emit(OpCodes.Pop); if (flag) { ec.MarkLabel(ec.RecursivePatternLabel); } ec.RecursivePatternLabel = recursivePatternLabel; ec.EmitInt(0); ec.MarkLabel(label2); } private void EmitLoad(EmitContext ec) { if (expr_unwrap != null) { expr_unwrap.EmitCheck(ec); if (Variable == null) { return; } ec.Emit(OpCodes.Dup); Label label = ec.DefineLabel(); ec.Emit(OpCodes.Brfalse_S, label); if (Variable.HoistedVariant != null) { ec.EmitThis(); } expr_unwrap.Emit(ec); if (Variable.HoistedVariant != null) { Variable.HoistedVariant.EmitAssignFromStack(ec); } else { if (!Variable.Created) { Variable.CreateBuilder(ec); } Variable.EmitAssign(ec); } ec.MarkLabel(label); return; } expr.Emit(ec); bool flag = Variable != null && (probe_type_expr.IsGenericParameter || TypeSpec.IsValueType(ProbeType.Type)); LocalBuilder localBuilder = null; if (flag && !ExpressionAnalyzer.IsInexpensiveLoad(expr)) { localBuilder = ec.GetTemporaryLocal(expr.Type); ec.Emit(OpCodes.Stloc, localBuilder); ec.Emit(OpCodes.Ldloc, localBuilder); } else if (probe_type_expr.IsGenericParameter && TypeSpec.IsValueType(expr.Type)) { ec.Emit(OpCodes.Box, expr.Type); } ec.Emit(OpCodes.Isinst, probe_type_expr); if (Variable == null) { return; } ec.Emit(OpCodes.Dup); Label label2 = ec.DefineLabel(); ec.Emit(OpCodes.Brfalse_S, label2); if (flag) { if (localBuilder != null) { ec.Emit(OpCodes.Ldloc, localBuilder); ec.FreeTemporaryLocal(localBuilder, expr.Type); } else { expr.Emit(ec); } ec.Emit(OpCodes.Unbox_Any, probe_type_expr); } if (Variable.HoistedVariant != null) { LocalTemporary localTemporary = new LocalTemporary(ProbeType.Type); localTemporary.Store(ec); Variable.HoistedVariant.EmitAssign(ec, localTemporary, leave_copy: false, isCompound: false); localTemporary.Release(ec); if (!flag) { Variable.HoistedVariant.Emit(ec); } } else { if (!Variable.Created) { Variable.CreateBuilder(ec); } Variable.EmitAssign(ec); if (!flag) { Variable.Emit(ec); } } ec.MarkLabel(label2); } protected override Expression DoResolve(ResolveContext rc) { if (ResolveCommon(rc) == null) { return null; } type = rc.BuiltinTypes.Bool; eclass = ExprClass.Value; if (probe_type_expr == null) { return ResolveMatchingExpression(rc); } Expression expression = ResolveResultExpression(rc); if (Variable != null) { if (expression is Constant) { throw new NotImplementedException("constant in type pattern matching"); } Variable.Type = probe_type_expr; if (rc is BlockContext bc) { Variable.PrepareAssignmentAnalysis(bc); } } return expression; } public override void FlowAnalysis(FlowAnalysisContext fc) { base.FlowAnalysis(fc); if (Variable != null) { fc.SetVariableAssigned(Variable.VariableInfo, generatedAssignment: true); } } public override void FlowAnalysisConditional(FlowAnalysisContext fc) { if (Variable == null) { base.FlowAnalysisConditional(fc); return; } expr.FlowAnalysis(fc); fc.DefiniteAssignmentOnTrue = fc.BranchDefiniteAssignment(); fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment; fc.SetVariableAssigned(Variable.VariableInfo, fc.DefiniteAssignmentOnTrue); } protected override void ResolveProbeType(ResolveContext rc) { if (!(ProbeType is TypeExpr) && rc.Module.Compiler.Settings.Version == LanguageVersion.Experimental) { if (ProbeType is PatternExpression) { ProbeType.Resolve(rc); return; } SessionReportPrinter sessionReportPrinter = new SessionReportPrinter(); ReportPrinter printer = rc.Report.SetPrinter(sessionReportPrinter); probe_type_expr = ProbeType.ResolveAsType(rc); sessionReportPrinter.EndSession(); if (probe_type_expr != null) { sessionReportPrinter.Merge(rc.Report.Printer); rc.Report.SetPrinter(printer); return; } if (ProbeType is VarExpr varExpr && varExpr.InferType(rc, expr)) { probe_type_expr = varExpr.Type; rc.Report.SetPrinter(printer); return; } SessionReportPrinter sessionReportPrinter2 = new SessionReportPrinter(); rc.Report.SetPrinter(sessionReportPrinter2); ProbeType = ProbeType.Resolve(rc); sessionReportPrinter2.EndSession(); if (ProbeType != null) { sessionReportPrinter2.Merge(rc.Report.Printer); } else { sessionReportPrinter.Merge(rc.Report.Printer); } rc.Report.SetPrinter(printer); } else { base.ResolveProbeType(rc); } } private Expression ResolveMatchingExpression(ResolveContext rc) { if (ProbeType is Constant constant) { if (!Convert.ImplicitConversionExists(rc, ProbeType, base.Expr.Type)) { ProbeType.Error_ValueCannotBeConverted(rc, base.Expr.Type, expl: false); return null; } if (constant.IsNull) { return new Binary(Binary.Operator.Equality, base.Expr, constant).Resolve(rc); } if (base.Expr is Constant left) { Constant constant2 = ConstantFold.BinaryFold(rc, Binary.Operator.Equality, left, constant, loc); if (constant2 != null) { return constant2; } } if (base.Expr.Type.IsNullableType) { expr_unwrap = new Unwrap(base.Expr); expr_unwrap.Resolve(rc); ProbeType = Convert.ImplicitConversion(rc, ProbeType, expr_unwrap.Type, loc); } else { if (ProbeType.Type == base.Expr.Type) { return new Binary(Binary.Operator.Equality, base.Expr, constant, loc).Resolve(rc); } if (ProbeType.Type.IsEnum || (ProbeType.Type.BuiltinType >= BuiltinTypeSpec.Type.Byte && ProbeType.Type.BuiltinType <= BuiltinTypeSpec.Type.Decimal)) { ModuleContainer.PatternMatchingHelper patternMatchingHelper = rc.Module.CreatePatterMatchingHelper(); number_mg = patternMatchingHelper.NumberMatcher.Spec; number_args = new Arguments(3); if (!ProbeType.Type.IsEnum) { number_args.Add(new Argument(base.Expr)); } number_args.Add(new Argument(Convert.ImplicitConversion(rc, ProbeType, rc.BuiltinTypes.Object, loc))); number_args.Add(new Argument(new BoolLiteral(rc.BuiltinTypes, ProbeType.Type.IsEnum, loc))); } } return this; } if (ProbeType is PatternExpression) { if (!(ProbeType is WildcardPattern) && !Convert.ImplicitConversionExists(rc, ProbeType, base.Expr.Type)) { ProbeType.Error_ValueCannotBeConverted(rc, base.Expr.Type, expl: false); } return this; } rc.Report.Error(150, ProbeType.Location, "A constant value is expected"); return this; } private Expression ResolveResultExpression(ResolveContext ec) { if (Variable != null) { if (expr is NullLiteral) { ec.Report.Error(8117, loc, "Cannot use null as pattern matching operand"); return this; } CheckExpressionVariable(ec); } TypeSpec typeSpec = expr.Type; bool flag = false; if (expr.IsNull) { return CreateConstantResult(ec, result: false); } if (typeSpec.IsNullableType) { TypeSpec underlyingType = NullableInfo.GetUnderlyingType(typeSpec); if (!underlyingType.IsGenericParameter) { typeSpec = underlyingType; flag = true; } } TypeSpec typeSpec2 = probe_type_expr; bool flag2 = false; if (typeSpec2.IsNullableType) { if (Variable != null) { ec.Report.Error(8116, loc, "The nullable type `{0}' pattern matching is not allowed. Consider using underlying type `{1}'", typeSpec2.GetSignatureForError(), NullableInfo.GetUnderlyingType(typeSpec2).GetSignatureForError()); } TypeSpec underlyingType2 = NullableInfo.GetUnderlyingType(typeSpec2); if (!underlyingType2.IsGenericParameter) { typeSpec2 = underlyingType2; flag2 = true; } } if (typeSpec2.IsStruct) { if (typeSpec == typeSpec2) { if (flag && !flag2) { expr_unwrap = Unwrap.Create(expr, useDefaultValue: true); return this; } return CreateConstantResult(ec, result: true); } if (typeSpec is TypeParameterSpec t) { return ResolveGenericParameter(ec, typeSpec2, t); } if (Convert.ExplicitReferenceConversionExists(typeSpec, typeSpec2)) { return this; } if (typeSpec is InflatedTypeSpec && InflatedTypeSpec.ContainsTypeParameter(typeSpec)) { return this; } } else { if (typeSpec2 is TypeParameterSpec t2) { return ResolveGenericParameter(ec, typeSpec, t2); } if (typeSpec2.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { if (Variable != null) { ec.Report.Error(8208, loc, "The type `{0}' pattern matching is not allowed", typeSpec2.GetSignatureForError()); } else { ec.Report.Warning(1981, 3, loc, "Using `{0}' to test compatibility with `{1}' is identical to testing compatibility with `object'", OperatorName, typeSpec2.GetSignatureForError()); } } if (TypeManager.IsGenericParameter(typeSpec)) { return ResolveGenericParameter(ec, typeSpec2, (TypeParameterSpec)typeSpec); } if (TypeSpec.IsValueType(typeSpec)) { if (Convert.ImplicitBoxingConversion(null, typeSpec, typeSpec2) != null) { if (flag && !flag2) { expr_unwrap = Unwrap.Create(expr, useDefaultValue: false); return this; } return CreateConstantResult(ec, result: true); } } else { if (Convert.ImplicitReferenceConversionExists(typeSpec, typeSpec2)) { if (expr is Constant constant) { return CreateConstantResult(ec, !constant.IsNull); } if (typeSpec.MemberDefinition.IsImported && typeSpec.BuiltinType != BuiltinTypeSpec.Type.None && typeSpec.MemberDefinition.DeclaringAssembly != typeSpec2.MemberDefinition.DeclaringAssembly) { return this; } if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return this; } if (Variable != null) { return this; } return ReducedExpression.Create(new Binary(Binary.Operator.Inequality, expr, new NullLiteral(loc), Binary.State.UserOperatorsExcluded).Resolve(ec), this).Resolve(ec); } if (Convert.ExplicitReferenceConversionExists(typeSpec, typeSpec2)) { return this; } if ((typeSpec is InflatedTypeSpec || typeSpec.IsArray) && InflatedTypeSpec.ContainsTypeParameter(typeSpec)) { return this; } } } return CreateConstantResult(ec, result: false); } private Expression ResolveGenericParameter(ResolveContext ec, TypeSpec d, TypeParameterSpec t) { if (t.IsReferenceType && d.IsStruct) { return CreateConstantResult(ec, result: false); } if (expr.Type.IsGenericParameter) { if (expr.Type == d && TypeSpec.IsValueType(t) && TypeSpec.IsValueType(d)) { return CreateConstantResult(ec, result: true); } expr = new BoxedCast(expr, d); } return this; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class WildcardPattern : PatternExpression { public WildcardPattern(Location loc) : base(loc) { } protected override Expression DoResolve(ResolveContext rc) { eclass = ExprClass.Value; type = rc.BuiltinTypes.Object; return this; } public override void Emit(EmitContext ec) { ec.EmitInt(1); } } internal class RecursivePattern : ComplexPatternExpression { private MethodGroupExpr operator_mg; private Arguments operator_args; public Arguments Arguments { get; private set; } public RecursivePattern(ATypeNameExpression typeExpresion, Arguments arguments, Location loc) : base(typeExpresion, loc) { Arguments = arguments; } protected override Expression DoResolve(ResolveContext rc) { type = base.TypeExpression.ResolveAsType(rc); if (type == null) { return null; } IList userOperator = MemberCache.GetUserOperator(type, Operator.OpType.Is, declaredOnly: true); if (userOperator == null) { Error_TypeDoesNotContainDefinition(rc, type, Operator.GetName(Operator.OpType.Is) + " operator"); return null; } List list = FindMatchingOverloads(userOperator); if (list == null) { Error_TypeDoesNotContainDefinition(rc, type, Operator.GetName(Operator.OpType.Is) + " operator"); return null; } Arguments.Resolve(rc, out var dynamic); if (dynamic) { throw new NotImplementedException("dynamic argument"); } MethodSpec methodSpec = FindBestOverload(rc, list); if (methodSpec == null) { Error_TypeDoesNotContainDefinition(rc, type, Operator.GetName(Operator.OpType.Is) + " operator"); return null; } TypeSpec[] types = methodSpec.Parameters.Types; operator_args = new Arguments(types.Length); operator_args.Add(new Argument(new EmptyExpression(type))); for (int i = 0; i < Arguments.Count; i++) { LocalTemporary localTemporary = new LocalTemporary(types[i + 1]); operator_args.Add(new Argument(localTemporary, Argument.AType.Out)); if (comparisons == null) { comparisons = new Expression[Arguments.Count]; } Argument argument = Arguments[i]; int num; Expression expr; if (argument is NamedArgument namedArgument) { num = methodSpec.Parameters.GetParameterIndexByName(namedArgument.Name) - 1; expr = Arguments[num].Expr; } else { num = i; expr = argument.Expr; } comparisons[num] = ResolveComparison(rc, expr, localTemporary); } operator_mg = MethodGroupExpr.CreatePredefined(methodSpec, type, loc); eclass = ExprClass.Value; return this; } private List FindMatchingOverloads(IList members) { int num = Arguments.Count + 1; List list = null; foreach (MethodSpec member in members) { AParametersCollection parameters = member.Parameters; if (parameters.Count != num) { continue; } bool flag = true; for (int i = 1; i < parameters.Count; i++) { if ((parameters.FixedParameters[i].ModFlags & Parameter.Modifier.OUT) == 0) { flag = false; break; } } if (flag) { if (list == null) { list = new List(); } list.Add(member); } } return list; } private MethodSpec FindBestOverload(ResolveContext rc, List methods) { for (int i = 0; i < Arguments.Count; i++) { Argument argument = Arguments[i]; Expression expr = argument.Expr; if (expr is WildcardPattern) { continue; } NamedArgument namedArgument = argument as NamedArgument; for (int j = 0; j < methods.Count; j++) { AParametersCollection parameters = methods[j].Parameters; int num; if (namedArgument != null) { num = parameters.GetParameterIndexByName(namedArgument.Name); if (num < 1) { methods.RemoveAt(j--); continue; } } else { num = i + 1; } TypeSpec target_type = parameters.Types[num]; if (!Convert.ImplicitConversionExists(rc, expr, target_type)) { methods.RemoveAt(j--); } } } if (methods.Count != 1) { return null; } return methods[0]; } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { operator_mg.EmitCall(ec, operator_args, statement: false); ec.Emit(OpCodes.Brfalse, target); base.EmitBranchable(ec, target, on_true); } private static Expression ResolveComparison(ResolveContext rc, Expression expr, LocalTemporary lt) { if (expr is WildcardPattern) { return new EmptyExpression(expr.Type); } RecursivePattern recursivePattern = expr as RecursivePattern; expr = Convert.ImplicitConversionRequired(rc, expr, lt.Type, expr.Location); if (expr == null) { return null; } if (recursivePattern != null) { recursivePattern.SetParentInstance(lt); return expr; } return new Binary(Binary.Operator.Equality, lt, expr, expr.Location).Resolve(rc); } public void SetParentInstance(Expression instance) { operator_args[0] = new Argument(instance); } } internal class PropertyPattern : ComplexPatternExpression { private LocalTemporary instance; public List Members { get; private set; } public PropertyPattern(ATypeNameExpression typeExpresion, List members, Location loc) : base(typeExpresion, loc) { Members = members; } protected override Expression DoResolve(ResolveContext rc) { type = base.TypeExpression.ResolveAsType(rc); if (type == null) { return null; } comparisons = new Expression[Members.Count]; instance = new LocalTemporary(type); for (int i = 0; i < Members.Count; i++) { PropertyPatternMember propertyPatternMember = Members[i]; Expression expression = Expression.MemberLookup(rc, errorMode: false, type, propertyPatternMember.Name, 0, MemberLookupRestrictions.ExactArity, loc); if (expression == null) { expression = Expression.MemberLookup(rc, errorMode: true, type, propertyPatternMember.Name, 0, MemberLookupRestrictions.ExactArity, loc); if (expression != null) { Expression.ErrorIsInaccesible(rc, expression.GetSignatureForError(), loc); continue; } } if (expression == null) { Expression.Error_TypeDoesNotContainDefinition(rc, base.Location, base.Type, propertyPatternMember.Name); continue; } if (!(expression is PropertyExpr propertyExpr) || expression is FieldExpr) { rc.Report.Error(-2001, propertyPatternMember.Location, "`{0}' is not a valid pattern member", propertyPatternMember.Name); continue; } if (propertyExpr != null && !propertyExpr.PropertyInfo.HasGet) { rc.Report.Error(-2002, propertyPatternMember.Location, "Property `{0}.get' accessor is required", propertyExpr.GetSignatureForError()); continue; } Expression expression2 = propertyPatternMember.Expr.Resolve(rc); if (expression2 != null) { MemberExpr memberExpr = (MemberExpr)expression; memberExpr.InstanceExpression = instance; comparisons[i] = ResolveComparison(rc, expression2, memberExpr); } } eclass = ExprClass.Value; return this; } private static Expression ResolveComparison(ResolveContext rc, Expression expr, Expression instance) { if (expr is WildcardPattern) { return new EmptyExpression(expr.Type); } return new Is(instance, expr, expr.Location).Resolve(rc); } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { instance.Store(ec); base.EmitBranchable(ec, target, on_true); } } internal class PropertyPatternMember { public string Name { get; private set; } public Expression Expr { get; private set; } public Location Location { get; private set; } public PropertyPatternMember(string name, Expression expr, Location loc) { Name = name; Expr = expr; Location = loc; } } internal abstract class PatternExpression : Expression { protected PatternExpression(Location loc) { base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotImplementedException(); } } internal abstract class ComplexPatternExpression : PatternExpression { protected Expression[] comparisons; public ATypeNameExpression TypeExpression { get; private set; } protected ComplexPatternExpression(ATypeNameExpression typeExpresion, Location loc) : base(loc) { TypeExpression = typeExpresion; } public override void Emit(EmitContext ec) { EmitBranchable(ec, ec.RecursivePatternLabel, on_true: false); } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { if (comparisons != null) { Expression[] array = comparisons; foreach (Expression expression in array) { expression.EmitBranchable(ec, target, on_true: false); } } } } internal class As : Probe { protected override string OperatorName => "as"; public As(Expression expr, Expression probe_type, Location l) : base(expr, probe_type, l) { } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments args = Arguments.CreateForExpressionTree(ec, null, expr.CreateExpressionTree(ec), new TypeOf(probe_type_expr, loc)); return CreateExpressionFactoryCall(ec, "TypeAs", args); } public override void Emit(EmitContext ec) { expr.Emit(ec); ec.Emit(OpCodes.Isinst, type); if (TypeManager.IsGenericParameter(type) || type.IsNullableType) { ec.Emit(OpCodes.Unbox_Any, type); } } protected override Expression DoResolve(ResolveContext ec) { if (ResolveCommon(ec) == null) { return null; } type = probe_type_expr; eclass = ExprClass.Value; TypeSpec typeSpec = expr.Type; if (expr is TupleLiteral && TupleLiteral.ContainsNoTypeElement(typeSpec)) { ec.Report.Error(8307, expr.Location, "The first operand of an `as' operator may not be a tuple literal without a natural type"); type = InternalType.ErrorType; return this; } if (type == null) { type = InternalType.ErrorType; return this; } if (!TypeSpec.IsReferenceType(type) && !type.IsNullableType) { if (TypeManager.IsGenericParameter(type)) { ec.Report.Error(413, loc, "The `as' operator cannot be used with a non-reference type parameter `{0}'. Consider adding `class' or a reference type constraint", probe_type_expr.GetSignatureForError()); } else { ec.Report.Error(77, loc, "The `as' operator cannot be used with a non-nullable value type `{0}'", type.GetSignatureForError()); } return null; } if (expr.IsNull && type.IsNullableType) { return LiftedNull.CreateFromExpression(ec, this); } if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return this; } Expression expression = Convert.ImplicitConversionStandard(ec, expr, type, loc); if (expression != null) { expression = EmptyCast.Create(expression, type); return ReducedExpression.Create(expression, this).Resolve(ec); } if (Convert.ExplicitReferenceConversionExists(typeSpec, type)) { if (TypeManager.IsGenericParameter(typeSpec)) { expr = new BoxedCast(expr, typeSpec); } return this; } if (InflatedTypeSpec.ContainsTypeParameter(typeSpec) || InflatedTypeSpec.ContainsTypeParameter(type)) { expr = new BoxedCast(expr, typeSpec); return this; } if (typeSpec != InternalType.ErrorType) { ec.Report.Error(39, loc, "Cannot convert type `{0}' to `{1}' via a built-in conversion", typeSpec.GetSignatureForError(), type.GetSignatureForError()); } return null; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Cast : ShimExpression { private Expression target_type; public Expression TargetType => target_type; public Cast(Expression cast_type, Expression expr, Location loc) : base(expr) { target_type = cast_type; base.loc = loc; } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); if (expr == null) { return null; } type = target_type.ResolveAsType(ec); if (type == null) { return null; } if (type.IsStatic) { ec.Report.Error(716, loc, "Cannot convert to static type `{0}'", type.GetSignatureForError()); return null; } if (type.IsPointer) { if (ec.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(ec, loc); } else if (!ec.IsUnsafe) { Expression.UnsafeError(ec, loc); } } eclass = ExprClass.Value; if (expr is Constant constant) { Constant constant2 = constant.Reduce(ec, type); if (constant2 != null) { return constant2; } } Expression expression = Convert.ExplicitConversion(ec, expr, type, loc); if (expression == expr) { return EmptyCast.Create(expression, type); } return expression; } protected override void CloneTo(CloneContext clonectx, Expression t) { Cast cast = (Cast)t; cast.target_type = target_type.Clone(clonectx); cast.expr = expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ImplicitCast : ShimExpression { private bool arrayAccess; public ImplicitCast(Expression expr, TypeSpec target, bool arrayAccess) : base(expr) { loc = expr.Location; type = target; this.arrayAccess = arrayAccess; } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); if (expr == null) { return null; } if (arrayAccess) { expr = ConvertExpressionToArrayIndex(ec, expr); } else { expr = Convert.ImplicitConversionRequired(ec, expr, type, loc); } return expr; } } internal class DeclarationExpression : Expression, IMemoryLocation { private LocalVariableReference lvr; public LocalVariable Variable { get; set; } public Expression Initializer { get; set; } public FullNamedExpression VariableType { get; set; } public DeclarationExpression(FullNamedExpression variableType, LocalVariable variable) { VariableType = variableType; Variable = variable; loc = variable.Location; } public void AddressOf(EmitContext ec, AddressOp mode) { if (!Variable.Created) { Variable.CreateBuilder(ec); } if (Initializer != null) { lvr.EmitAssign(ec, Initializer, leave_copy: false, prepare_for_load: false); } lvr.AddressOf(ec, mode); } protected override void CloneTo(CloneContext clonectx, Expression t) { DeclarationExpression declarationExpression = (DeclarationExpression)t; declarationExpression.VariableType = (FullNamedExpression)VariableType.Clone(clonectx); if (Initializer != null) { declarationExpression.Initializer = Initializer.Clone(clonectx); } } public override Expression CreateExpressionTree(ResolveContext rc) { rc.Report.Error(8198, loc, "An expression tree cannot contain out variable declaration"); return null; } private bool DoResolveCommon(ResolveContext rc) { CheckExpressionVariable(rc); VarExpr varExpr = VariableType as VarExpr; if (varExpr != null) { type = InternalType.VarOutType; } else { type = VariableType.ResolveAsType(rc); if (type == null) { return false; } } if (Initializer != null) { Initializer = Initializer.Resolve(rc); if (varExpr != null && Initializer != null && varExpr.InferType(rc, Initializer)) { type = varExpr.Type; } } Variable.Type = type; lvr = new LocalVariableReference(Variable, loc); eclass = ExprClass.Variable; return true; } protected override Expression DoResolve(ResolveContext rc) { if (DoResolveCommon(rc)) { lvr.Resolve(rc); } return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (lvr == null && DoResolveCommon(rc)) { lvr.ResolveLValue(rc, right_side); } return this; } public override void Emit(EmitContext ec) { throw new NotImplementedException(); } public override void EmitPrepare(EmitContext ec) { Variable.CreateBuilder(ec); } } internal class DefaultValueExpression : Expression { private Expression expr; public Expression Expr => expr; public override bool IsSideEffectFree => true; public override bool IsNull => TypeSpec.IsReferenceType(type); public DefaultValueExpression(Expression expr, Location loc) { this.expr = expr; base.loc = loc; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(this)); arguments.Add(new Argument(new TypeOf(type, loc))); return CreateExpressionFactoryCall(ec, "Constant", arguments); } protected override Expression DoResolve(ResolveContext ec) { type = expr.ResolveAsType(ec); if (type == null) { return null; } if (type.IsStatic) { ec.Report.Error(-244, loc, "The `default value' operator cannot be applied to an operand of a static type"); } if (type.IsPointer) { return new NullLiteral(base.Location).ConvertImplicitly(type); } if (TypeSpec.IsReferenceType(type)) { return new NullConstant(type, loc); } Constant constant = New.Constantify(type, expr.Location); if (constant != null) { return constant; } eclass = ExprClass.Variable; return this; } public override void Emit(EmitContext ec) { LocalTemporary localTemporary = new LocalTemporary(type); localTemporary.AddressOf(ec, AddressOp.LoadStore); ec.Emit(OpCodes.Initobj, type); localTemporary.Emit(ec); localTemporary.Release(ec); } protected override void CloneTo(CloneContext clonectx, Expression t) { DefaultValueExpression defaultValueExpression = (DefaultValueExpression)t; defaultValueExpression.expr = expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Binary : Expression, IDynamicBinder { public class PredefinedOperator { protected readonly TypeSpec left; protected readonly TypeSpec right; protected readonly TypeSpec left_unwrap; protected readonly TypeSpec right_unwrap; public readonly Operator OperatorsMask; public TypeSpec ReturnType; public bool IsLifted => (OperatorsMask & Operator.NullableMask) != 0; public PredefinedOperator(TypeSpec ltype, TypeSpec rtype, Operator op_mask) : this(ltype, rtype, op_mask, ltype) { } public PredefinedOperator(TypeSpec type, Operator op_mask, TypeSpec return_type) : this(type, type, op_mask, return_type) { } public PredefinedOperator(TypeSpec type, Operator op_mask) : this(type, type, op_mask, type) { } public PredefinedOperator(TypeSpec ltype, TypeSpec rtype, Operator op_mask, TypeSpec return_type) { if ((op_mask & Operator.ValuesOnlyMask) != 0) { throw new InternalErrorException("Only masked values can be used"); } if ((op_mask & Operator.NullableMask) != 0) { left_unwrap = NullableInfo.GetUnderlyingType(ltype); right_unwrap = NullableInfo.GetUnderlyingType(rtype); } else { left_unwrap = ltype; right_unwrap = rtype; } left = ltype; right = rtype; OperatorsMask = op_mask; ReturnType = return_type; } public virtual Expression ConvertResult(ResolveContext rc, Binary b) { Expression expression = b.left; Expression expression2 = b.right; b.type = ReturnType; if (IsLifted) { if (rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { b.left = Convert.ImplicitConversion(rc, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(rc, b.right, right, b.right.Location); } if (expression2.IsNull) { if ((b.oper & Operator.EqualityMask) != 0) { if (!expression.Type.IsNullableType && BuiltinTypeSpec.IsPrimitiveType(expression.Type)) { return b.CreateLiftedValueTypeResult(rc, expression.Type); } } else { if ((b.oper & Operator.BitwiseMask) == 0) { b.left = Convert.ImplicitConversion(rc, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(rc, b.right, right, b.right.Location); if ((b.Oper & (Operator.Multiply | Operator.ShiftMask)) != 0) { return LiftedNull.CreateFromExpression(rc, b); } return b.CreateLiftedValueTypeResult(rc, left); } if (left_unwrap.BuiltinType != BuiltinTypeSpec.Type.FirstPrimitive) { return LiftedNull.CreateFromExpression(rc, b); } } } else if (expression.IsNull) { if ((b.oper & Operator.EqualityMask) != 0) { if (!expression2.Type.IsNullableType && BuiltinTypeSpec.IsPrimitiveType(expression2.Type)) { return b.CreateLiftedValueTypeResult(rc, expression2.Type); } } else { if ((b.oper & Operator.BitwiseMask) == 0) { b.left = Convert.ImplicitConversion(rc, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(rc, b.right, right, b.right.Location); if ((b.Oper & (Operator.Multiply | Operator.ShiftMask)) != 0) { return LiftedNull.CreateFromExpression(rc, b); } return b.CreateLiftedValueTypeResult(rc, right); } if (right_unwrap.BuiltinType != BuiltinTypeSpec.Type.FirstPrimitive) { return LiftedNull.CreateFromExpression(rc, b); } } } } if (left.BuiltinType == BuiltinTypeSpec.Type.Decimal) { b.left = Convert.ImplicitConversion(rc, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(rc, b.right, right, b.right.Location); return b.ResolveUserOperator(rc, b.left, b.right); } if (expression2 is Constant constant) { if (constant.IsDefaultValue) { if (b.oper == Operator.Addition || b.oper == Operator.Subtraction || (b.oper == Operator.BitwiseOr && left_unwrap.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && constant is BoolConstant)) { b.left = Convert.ImplicitConversion(rc, b.left, left, b.left.Location); return ReducedExpression.Create(b.left, b).Resolve(rc); } if ((b.oper == Operator.BitwiseAnd || b.oper == Operator.LogicalAnd) && !IsLifted) { Constant expr = new SideEffectConstant(constant, b.left, constant.Location); return ReducedExpression.Create(expr, b); } } else if (IsLifted && left_unwrap.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && b.oper == Operator.BitwiseAnd) { return ReducedExpression.Create(b.left, b).Resolve(rc); } if ((b.oper == Operator.Multiply || b.oper == Operator.Division) && constant.IsOneInteger) { return ReducedExpression.Create(b.left, b).Resolve(rc); } if ((b.oper & Operator.ShiftMask) != 0 && constant is IntConstant) { b.right = new IntConstant(rc.BuiltinTypes, ((IntConstant)constant).Value & GetShiftMask(left_unwrap), b.right.Location); } } if (b.left is Constant constant2) { if (constant2.IsDefaultValue) { if (b.oper == Operator.Addition || (b.oper == Operator.BitwiseOr && right_unwrap.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && constant2 is BoolConstant)) { b.right = Convert.ImplicitConversion(rc, b.right, right, b.right.Location); return ReducedExpression.Create(b.right, b).Resolve(rc); } if (b.oper == Operator.LogicalAnd && constant2.Type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive) { Expression.Warning_UnreachableExpression(rc, b.right.StartLocation); return ReducedExpression.Create(constant2, b); } if (b.oper == Operator.BitwiseAnd && !IsLifted) { Constant expr2 = new SideEffectConstant(constant2, b.right, constant2.Location); return ReducedExpression.Create(expr2, b); } } else { if (IsLifted && left_unwrap.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && b.oper == Operator.BitwiseAnd) { return ReducedExpression.Create(b.right, b).Resolve(rc); } if (b.oper == Operator.LogicalOr && constant2.Type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive) { Expression.Warning_UnreachableExpression(rc, b.right.StartLocation); return ReducedExpression.Create(constant2, b); } } if (b.oper == Operator.Multiply && constant2.IsOneInteger) { return ReducedExpression.Create(b.right, b).Resolve(rc); } } if (IsLifted) { LiftedBinaryOperator liftedBinaryOperator = new LiftedBinaryOperator(b); TypeSpec typeSpec; if (b.left.Type.IsNullableType) { liftedBinaryOperator.UnwrapLeft = new Unwrap(b.left); typeSpec = left_unwrap; } else { typeSpec = left; } TypeSpec typeSpec2; if (b.right.Type.IsNullableType) { liftedBinaryOperator.UnwrapRight = new Unwrap(b.right); typeSpec2 = right_unwrap; } else { typeSpec2 = right; } liftedBinaryOperator.Left = (b.left.IsNull ? LiftedNull.Create(typeSpec, b.left.Location) : Convert.ImplicitConversion(rc, liftedBinaryOperator.UnwrapLeft ?? b.left, typeSpec, b.left.Location)); liftedBinaryOperator.Right = (b.right.IsNull ? LiftedNull.Create(typeSpec2, b.right.Location) : Convert.ImplicitConversion(rc, liftedBinaryOperator.UnwrapRight ?? b.right, typeSpec2, b.right.Location)); return liftedBinaryOperator.Resolve(rc); } b.left = Convert.ImplicitConversion(rc, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(rc, b.right, right, b.right.Location); return b; } public bool IsPrimitiveApplicable(TypeSpec ltype, TypeSpec rtype) { return left == ltype && ltype == rtype; } public virtual bool IsApplicable(ResolveContext ec, Expression lexpr, Expression rexpr) { if (left == lexpr.Type && right == rexpr.Type) { return true; } return Convert.ImplicitConversionExists(ec, lexpr, left) && Convert.ImplicitConversionExists(ec, rexpr, right); } public PredefinedOperator ResolveBetterOperator(ResolveContext ec, PredefinedOperator best_operator) { if ((OperatorsMask & Operator.DecomposedMask) != 0) { return best_operator; } if ((best_operator.OperatorsMask & Operator.DecomposedMask) != 0) { return this; } int num = 0; if (left != null && best_operator.left != null) { num = OverloadResolver.BetterTypeConversion(ec, best_operator.left_unwrap, left_unwrap); } if (right != null && (left != right || best_operator.left != best_operator.right)) { num |= OverloadResolver.BetterTypeConversion(ec, best_operator.right_unwrap, right_unwrap); } if (num == 0 || num > 2) { return null; } return (num == 1) ? best_operator : this; } } private sealed class PredefinedStringOperator : PredefinedOperator { public PredefinedStringOperator(TypeSpec type, Operator op_mask, TypeSpec retType) : base(type, type, op_mask, retType) { } public PredefinedStringOperator(TypeSpec ltype, TypeSpec rtype, Operator op_mask, TypeSpec retType) : base(ltype, rtype, op_mask, retType) { } public override Expression ConvertResult(ResolveContext ec, Binary b) { if (b.left is Unwrap unwrap) { b.left = unwrap.Original; } if (b.right is Unwrap unwrap2) { b.right = unwrap2.Original; } b.left = Convert.ImplicitConversion(ec, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(ec, b.right, right, b.right.Location); return StringConcat.Create(ec, b.left, b.right, b.loc); } } private sealed class PredefinedEqualityOperator : PredefinedOperator { private MethodSpec equal_method; private MethodSpec inequal_method; public PredefinedEqualityOperator(TypeSpec arg, TypeSpec retType) : base(arg, arg, Operator.EqualityMask, retType) { } public override Expression ConvertResult(ResolveContext ec, Binary b) { b.type = ReturnType; b.left = Convert.ImplicitConversion(ec, b.left, left, b.left.Location); b.right = Convert.ImplicitConversion(ec, b.right, right, b.right.Location); Arguments arguments = new Arguments(2); arguments.Add(new Argument(b.left)); arguments.Add(new Argument(b.right)); MethodSpec oper; if (b.oper == Operator.Equality) { if (equal_method == null) { if (left.BuiltinType == BuiltinTypeSpec.Type.String) { equal_method = ec.Module.PredefinedMembers.StringEqual.Resolve(b.loc); } else { if (left.BuiltinType != BuiltinTypeSpec.Type.Delegate) { throw new NotImplementedException(left.GetSignatureForError()); } equal_method = ec.Module.PredefinedMembers.DelegateEqual.Resolve(b.loc); } } oper = equal_method; } else { if (inequal_method == null) { if (left.BuiltinType == BuiltinTypeSpec.Type.String) { inequal_method = ec.Module.PredefinedMembers.StringInequal.Resolve(b.loc); } else { if (left.BuiltinType != BuiltinTypeSpec.Type.Delegate) { throw new NotImplementedException(left.GetSignatureForError()); } inequal_method = ec.Module.PredefinedMembers.DelegateInequal.Resolve(b.loc); } } oper = inequal_method; } return new UserOperatorCall(oper, arguments, b.CreateExpressionTree, b.loc); } } private class PredefinedPointerOperator : PredefinedOperator { public PredefinedPointerOperator(TypeSpec ltype, TypeSpec rtype, Operator op_mask) : base(ltype, rtype, op_mask) { } public PredefinedPointerOperator(TypeSpec ltype, TypeSpec rtype, Operator op_mask, TypeSpec retType) : base(ltype, rtype, op_mask, retType) { } public PredefinedPointerOperator(TypeSpec type, Operator op_mask, TypeSpec return_type) : base(type, op_mask, return_type) { } public override bool IsApplicable(ResolveContext ec, Expression lexpr, Expression rexpr) { if (left == null) { if (!lexpr.Type.IsPointer) { return false; } } else if (!Convert.ImplicitConversionExists(ec, lexpr, left)) { return false; } if (right == null) { if (!rexpr.Type.IsPointer) { return false; } } else if (!Convert.ImplicitConversionExists(ec, rexpr, right)) { return false; } return true; } public override Expression ConvertResult(ResolveContext ec, Binary b) { if (left != null) { b.left = Convert.UserDefinedConversion(ec, b.left, left, Convert.UserConversionRestriction.ImplicitOnly, b.loc) ?? EmptyCast.Create(b.left, left); } else if (right != null) { b.right = Convert.UserDefinedConversion(ec, b.right, right, Convert.UserConversionRestriction.ImplicitOnly, b.loc) ?? EmptyCast.Create(b.right, right); } TypeSpec typeSpec = ReturnType; Expression l; Expression r; if (typeSpec == null) { if (left == null) { l = b.left; r = b.right; typeSpec = b.left.Type; } else { l = b.right; r = b.left; typeSpec = b.right.Type; } } else { l = b.left; r = b.right; } return new PointerArithmetic(b.oper, l, r, typeSpec, b.loc).Resolve(ec); } } [Flags] public enum Operator { Multiply = 0x20, Division = 0x21, Modulus = 0x22, Addition = 0x823, Subtraction = 0x1024, LeftShift = 0x45, RightShift = 0x46, LessThan = 0x2087, GreaterThan = 0x2088, LessThanOrEqual = 0x2089, GreaterThanOrEqual = 0x208A, Equality = 0x18B, Inequality = 0x18C, BitwiseAnd = 0x20D, ExclusiveOr = 0x20E, BitwiseOr = 0x20F, LogicalAnd = 0x410, LogicalOr = 0x411, ValuesOnlyMask = 0x1F, ArithmeticMask = 0x20, ShiftMask = 0x40, ComparisonMask = 0x80, EqualityMask = 0x100, BitwiseMask = 0x200, LogicalMask = 0x400, AdditionMask = 0x800, SubtractionMask = 0x1000, RelationalMask = 0x2000, DecomposedMask = 0x80000, NullableMask = 0x100000 } [Flags] public enum State : byte { None = 0, Compound = 2, UserOperatorsExcluded = 4 } private readonly Operator oper; private Expression left; private Expression right; private State state; private ConvCast.Mode enum_conversion; public bool IsCompound => (state & State.Compound) != 0; public Operator Oper => oper; public Expression Left => left; public Expression Right => right; public override Location StartLocation => left.StartLocation; public Binary(Operator oper, Expression left, Expression right, bool isCompound) : this(oper, left, right, State.Compound) { } public Binary(Operator oper, Expression left, Expression right, State state) : this(oper, left, right) { this.state = state; } public Binary(Operator oper, Expression left, Expression right) : this(oper, left, right, left.Location) { } public Binary(Operator oper, Expression left, Expression right, Location loc) { this.oper = oper; this.left = left; this.right = right; base.loc = loc; } private string OperName(Operator oper) { string text = oper switch { Operator.Multiply => "*", Operator.Division => "/", Operator.Modulus => "%", Operator.Addition => "+", Operator.Subtraction => "-", Operator.LeftShift => "<<", Operator.RightShift => ">>", Operator.LessThan => "<", Operator.GreaterThan => ">", Operator.LessThanOrEqual => "<=", Operator.GreaterThanOrEqual => ">=", Operator.Equality => "==", Operator.Inequality => "!=", Operator.BitwiseAnd => "&", Operator.BitwiseOr => "|", Operator.ExclusiveOr => "^", Operator.LogicalOr => "||", Operator.LogicalAnd => "&&", _ => oper.ToString(), }; if (IsCompound) { return text + "="; } return text; } public static void Error_OperatorCannotBeApplied(ResolveContext ec, Expression left, Expression right, Operator oper, Location loc) { new Binary(oper, left, right).Error_OperatorCannotBeApplied(ec, left, right); } public static void Error_OperatorCannotBeApplied(ResolveContext ec, Expression left, Expression right, string oper, Location loc) { if (left.Type != InternalType.ErrorType && right.Type != InternalType.ErrorType) { string signatureForError = left.Type.GetSignatureForError(); string signatureForError2 = right.Type.GetSignatureForError(); ec.Report.Error(19, loc, "Operator `{0}' cannot be applied to operands of type `{1}' and `{2}'", oper, signatureForError, signatureForError2); } } private void Error_OperatorCannotBeApplied(ResolveContext ec, Expression left, Expression right) { Error_OperatorCannotBeApplied(ec, left, right, OperName(oper), loc); } public override void FlowAnalysis(FlowAnalysisContext fc) { if ((oper & Operator.LogicalMask) == 0) { left.FlowAnalysis(fc); right.FlowAnalysis(fc); return; } left.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignmentOnTrue = fc.DefiniteAssignmentOnTrue; DefiniteAssignmentBitSet definiteAssignmentOnFalse = fc.DefiniteAssignmentOnFalse; DefiniteAssignmentBitSet definiteAssignmentBitSet = (fc.DefiniteAssignment = new DefiniteAssignmentBitSet((oper == Operator.LogicalOr) ? definiteAssignmentOnFalse : definiteAssignmentOnTrue)); DefiniteAssignmentBitSet definiteAssignmentOnTrue2 = (fc.DefiniteAssignmentOnFalse = definiteAssignmentBitSet); fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue2; right.FlowAnalysisConditional(fc); if (oper == Operator.LogicalOr) { fc.DefiniteAssignment = (definiteAssignmentOnFalse | (fc.DefiniteAssignmentOnFalse & fc.DefiniteAssignmentOnTrue)) & definiteAssignmentOnTrue; } else { fc.DefiniteAssignment = (definiteAssignmentOnTrue | (fc.DefiniteAssignmentOnFalse & fc.DefiniteAssignmentOnTrue)) & definiteAssignmentOnFalse; } } public override void FlowAnalysisConditional(FlowAnalysisContext fc) { if ((oper & Operator.LogicalMask) == 0) { base.FlowAnalysisConditional(fc); return; } left.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignmentOnTrue = fc.DefiniteAssignmentOnTrue; DefiniteAssignmentBitSet definiteAssignmentOnFalse = fc.DefiniteAssignmentOnFalse; DefiniteAssignmentBitSet definiteAssignmentBitSet = (fc.DefiniteAssignment = new DefiniteAssignmentBitSet((oper == Operator.LogicalOr) ? definiteAssignmentOnFalse : definiteAssignmentOnTrue)); DefiniteAssignmentBitSet definiteAssignmentOnTrue2 = (fc.DefiniteAssignmentOnFalse = definiteAssignmentBitSet); fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue2; right.FlowAnalysisConditional(fc); Constant constant = left as Constant; if (oper == Operator.LogicalOr) { fc.DefiniteAssignmentOnFalse = definiteAssignmentOnFalse | fc.DefiniteAssignmentOnFalse; if (constant != null && constant.IsDefaultValue) { fc.DefiniteAssignmentOnTrue = fc.DefiniteAssignmentOnFalse; } else { fc.DefiniteAssignmentOnTrue = new DefiniteAssignmentBitSet(definiteAssignmentOnTrue & (definiteAssignmentOnFalse | fc.DefiniteAssignmentOnTrue)); } } else { fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue | fc.DefiniteAssignmentOnTrue; if (constant != null && !constant.IsDefaultValue) { fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignmentOnTrue; } else { fc.DefiniteAssignmentOnFalse = new DefiniteAssignmentBitSet((definiteAssignmentOnTrue | fc.DefiniteAssignmentOnFalse) & definiteAssignmentOnFalse); } } } private string GetOperatorExpressionTypeName() { return oper switch { Operator.Addition => IsCompound ? "AddAssign" : "Add", Operator.BitwiseAnd => IsCompound ? "AndAssign" : "And", Operator.BitwiseOr => IsCompound ? "OrAssign" : "Or", Operator.Division => IsCompound ? "DivideAssign" : "Divide", Operator.ExclusiveOr => IsCompound ? "ExclusiveOrAssign" : "ExclusiveOr", Operator.Equality => "Equal", Operator.GreaterThan => "GreaterThan", Operator.GreaterThanOrEqual => "GreaterThanOrEqual", Operator.Inequality => "NotEqual", Operator.LeftShift => IsCompound ? "LeftShiftAssign" : "LeftShift", Operator.LessThan => "LessThan", Operator.LessThanOrEqual => "LessThanOrEqual", Operator.LogicalAnd => "And", Operator.LogicalOr => "Or", Operator.Modulus => IsCompound ? "ModuloAssign" : "Modulo", Operator.Multiply => IsCompound ? "MultiplyAssign" : "Multiply", Operator.RightShift => IsCompound ? "RightShiftAssign" : "RightShift", Operator.Subtraction => IsCompound ? "SubtractAssign" : "Subtract", _ => throw new NotImplementedException("Unknown expression type operator " + oper), }; } public static Mono.CSharp.Operator.OpType ConvertBinaryToUserOperator(Operator op) { switch (op) { case Operator.Addition: return Mono.CSharp.Operator.OpType.Addition; case Operator.BitwiseAnd: case Operator.LogicalAnd: return Mono.CSharp.Operator.OpType.BitwiseAnd; case Operator.BitwiseOr: case Operator.LogicalOr: return Mono.CSharp.Operator.OpType.BitwiseOr; case Operator.Division: return Mono.CSharp.Operator.OpType.Division; case Operator.Equality: return Mono.CSharp.Operator.OpType.Equality; case Operator.ExclusiveOr: return Mono.CSharp.Operator.OpType.ExclusiveOr; case Operator.GreaterThan: return Mono.CSharp.Operator.OpType.GreaterThan; case Operator.GreaterThanOrEqual: return Mono.CSharp.Operator.OpType.GreaterThanOrEqual; case Operator.Inequality: return Mono.CSharp.Operator.OpType.Inequality; case Operator.LeftShift: return Mono.CSharp.Operator.OpType.LeftShift; case Operator.LessThan: return Mono.CSharp.Operator.OpType.LessThan; case Operator.LessThanOrEqual: return Mono.CSharp.Operator.OpType.LessThanOrEqual; case Operator.Modulus: return Mono.CSharp.Operator.OpType.Modulus; case Operator.Multiply: return Mono.CSharp.Operator.OpType.Multiply; case Operator.RightShift: return Mono.CSharp.Operator.OpType.RightShift; case Operator.Subtraction: return Mono.CSharp.Operator.OpType.Subtraction; default: throw new InternalErrorException(op.ToString()); } } public override bool ContainsEmitWithAwait() { return left.ContainsEmitWithAwait() || right.ContainsEmitWithAwait(); } public static void EmitOperatorOpcode(EmitContext ec, Operator oper, TypeSpec l, Expression right) { OpCode opcode; switch (oper) { case Operator.Multiply: opcode = ((!ec.HasSet(BuilderContext.Options.CheckedScope)) ? OpCodes.Mul : ((l.BuiltinType != BuiltinTypeSpec.Type.Int && l.BuiltinType != BuiltinTypeSpec.Type.Long) ? (IsFloat(l) ? OpCodes.Mul : OpCodes.Mul_Ovf_Un) : OpCodes.Mul_Ovf)); break; case Operator.Division: opcode = ((!IsUnsigned(l)) ? OpCodes.Div : OpCodes.Div_Un); break; case Operator.Modulus: opcode = ((!IsUnsigned(l)) ? OpCodes.Rem : OpCodes.Rem_Un); break; case Operator.Addition: opcode = ((!ec.HasSet(BuilderContext.Options.CheckedScope)) ? OpCodes.Add : ((l.BuiltinType != BuiltinTypeSpec.Type.Int && l.BuiltinType != BuiltinTypeSpec.Type.Long) ? (IsFloat(l) ? OpCodes.Add : OpCodes.Add_Ovf_Un) : OpCodes.Add_Ovf)); break; case Operator.Subtraction: opcode = ((!ec.HasSet(BuilderContext.Options.CheckedScope)) ? OpCodes.Sub : ((l.BuiltinType != BuiltinTypeSpec.Type.Int && l.BuiltinType != BuiltinTypeSpec.Type.Long) ? (IsFloat(l) ? OpCodes.Sub : OpCodes.Sub_Ovf_Un) : OpCodes.Sub_Ovf)); break; case Operator.RightShift: if (!(right is IntConstant)) { ec.EmitInt(GetShiftMask(l)); ec.Emit(OpCodes.And); } opcode = ((!IsUnsigned(l)) ? OpCodes.Shr : OpCodes.Shr_Un); break; case Operator.LeftShift: if (!(right is IntConstant)) { ec.EmitInt(GetShiftMask(l)); ec.Emit(OpCodes.And); } opcode = OpCodes.Shl; break; case Operator.Equality: opcode = OpCodes.Ceq; break; case Operator.Inequality: ec.Emit(OpCodes.Ceq); ec.EmitInt(0); opcode = OpCodes.Ceq; break; case Operator.LessThan: opcode = ((!IsUnsigned(l)) ? OpCodes.Clt : OpCodes.Clt_Un); break; case Operator.GreaterThan: opcode = ((!IsUnsigned(l)) ? OpCodes.Cgt : OpCodes.Cgt_Un); break; case Operator.LessThanOrEqual: if (IsUnsigned(l) || IsFloat(l)) { ec.Emit(OpCodes.Cgt_Un); } else { ec.Emit(OpCodes.Cgt); } ec.EmitInt(0); opcode = OpCodes.Ceq; break; case Operator.GreaterThanOrEqual: if (IsUnsigned(l) || IsFloat(l)) { ec.Emit(OpCodes.Clt_Un); } else { ec.Emit(OpCodes.Clt); } ec.EmitInt(0); opcode = OpCodes.Ceq; break; case Operator.BitwiseOr: opcode = OpCodes.Or; break; case Operator.BitwiseAnd: opcode = OpCodes.And; break; case Operator.ExclusiveOr: opcode = OpCodes.Xor; break; default: throw new InternalErrorException(oper.ToString()); } ec.Emit(opcode); } private static int GetShiftMask(TypeSpec type) { return (type.BuiltinType == BuiltinTypeSpec.Type.Int || type.BuiltinType == BuiltinTypeSpec.Type.UInt) ? 31 : 63; } private static bool IsUnsigned(TypeSpec t) { switch (t.BuiltinType) { case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.ULong: return true; default: return t.IsPointer; } } private static bool IsFloat(TypeSpec t) { return t.BuiltinType == BuiltinTypeSpec.Type.Float || t.BuiltinType == BuiltinTypeSpec.Type.Double; } public Expression ResolveOperator(ResolveContext rc) { eclass = ExprClass.Value; TypeSpec typeSpec = left.Type; TypeSpec typeSpec2 = right.Type; bool flag = false; Expression expression; if ((BuiltinTypeSpec.IsPrimitiveType(typeSpec) || (typeSpec.IsNullableType && BuiltinTypeSpec.IsPrimitiveType(NullableInfo.GetUnderlyingType(typeSpec)))) && (BuiltinTypeSpec.IsPrimitiveType(typeSpec2) || (typeSpec2.IsNullableType && BuiltinTypeSpec.IsPrimitiveType(NullableInfo.GetUnderlyingType(typeSpec2))))) { if ((oper & Operator.ShiftMask) == 0) { if (!DoBinaryOperatorPromotion(rc)) { return null; } flag = BuiltinTypeSpec.IsPrimitiveType(typeSpec) && BuiltinTypeSpec.IsPrimitiveType(typeSpec2); } } else { if (typeSpec.IsPointer || typeSpec2.IsPointer) { return ResolveOperatorPointer(rc, typeSpec, typeSpec2); } if ((state & State.UserOperatorsExcluded) == 0) { expression = ResolveUserOperator(rc, left, right); if (expression != null) { return expression; } } bool isEnum = typeSpec.IsEnum; bool isEnum2 = typeSpec2.IsEnum; if ((oper & (Operator.ComparisonMask | Operator.BitwiseMask)) != 0) { if (IsEnumOrNullableEnum(typeSpec) || IsEnumOrNullableEnum(typeSpec2)) { expression = ResolveSingleEnumOperators(rc, isEnum, isEnum2, typeSpec, typeSpec2); if (expression == null) { return null; } if ((oper & Operator.BitwiseMask) != 0) { expression = EmptyCast.Create(expression, type); enum_conversion = GetEnumResultCast(type); if (oper == Operator.BitwiseAnd && left.Type.IsEnum && right.Type.IsEnum) { expression = OptimizeAndOperation(expression); } } left = ConvertEnumOperandToUnderlyingType(rc, left, typeSpec2.IsNullableType); right = ConvertEnumOperandToUnderlyingType(rc, right, typeSpec.IsNullableType); return expression; } } else if (oper == Operator.Addition || oper == Operator.Subtraction) { if (IsEnumOrNullableEnum(typeSpec) || IsEnumOrNullableEnum(typeSpec2)) { expression = ResolveEnumOperators(rc, isEnum, isEnum2, typeSpec, typeSpec2); if (expression != null) { left = ConvertEnumOperandToUnderlyingType(rc, left, liftType: false); right = ConvertEnumOperandToUnderlyingType(rc, right, liftType: false); return expression; } } else if (typeSpec.IsDelegate || typeSpec2.IsDelegate) { expression = ResolveOperatorDelegate(rc, typeSpec, typeSpec2); if (expression != null) { return expression; } } } } if ((oper & Operator.EqualityMask) != 0) { return ResolveEquality(rc, typeSpec, typeSpec2, flag); } expression = ResolveOperatorPredefined(rc, rc.BuiltinTypes.OperatorsBinaryStandard, flag); if (expression != null) { return expression; } if (flag) { return null; } return ResolveOperatorPredefined(rc, rc.Module.OperatorsBinaryLifted, primitives_only: false); } private static bool IsEnumOrNullableEnum(TypeSpec type) { return type.IsEnum || (type.IsNullableType && NullableInfo.GetUnderlyingType(type).IsEnum); } private Constant EnumLiftUp(ResolveContext ec, Constant left, Constant right) { switch (oper) { case Operator.Equality: case Operator.Inequality: case Operator.BitwiseAnd: case Operator.ExclusiveOr: case Operator.BitwiseOr: case Operator.LessThan: case Operator.GreaterThan: case Operator.LessThanOrEqual: case Operator.GreaterThanOrEqual: if (left.Type.IsEnum) { return left; } if (left.IsZeroInteger) { return left.Reduce(ec, right.Type); } break; case Operator.Addition: case Operator.Subtraction: return left; case Operator.Multiply: case Operator.Division: case Operator.Modulus: case Operator.LeftShift: case Operator.RightShift: if (right.Type.IsEnum || left.Type.IsEnum) { break; } return left; } return null; } private void CheckBitwiseOrOnSignExtended(ResolveContext ec) { OpcodeCast opcodeCast = left as OpcodeCast; if (opcodeCast != null && IsUnsigned(opcodeCast.UnderlyingType)) { opcodeCast = null; } OpcodeCast opcodeCast2 = right as OpcodeCast; if (opcodeCast2 != null && IsUnsigned(opcodeCast2.UnderlyingType)) { opcodeCast2 = null; } if (opcodeCast != null || opcodeCast2 != null) { TypeSpec typeSpec = ((opcodeCast != null) ? opcodeCast.UnderlyingType : opcodeCast2.UnderlyingType); ec.Report.Warning(675, 3, loc, "The operator `|' used on the sign-extended type `{0}'. Consider casting to a smaller unsigned type first", typeSpec.GetSignatureForError()); } } public static PredefinedOperator[] CreatePointerOperatorsTable(BuiltinTypes types) { return new PredefinedOperator[9] { new PredefinedPointerOperator(null, types.Int, Operator.AdditionMask | Operator.SubtractionMask), new PredefinedPointerOperator(null, types.UInt, Operator.AdditionMask | Operator.SubtractionMask), new PredefinedPointerOperator(null, types.Long, Operator.AdditionMask | Operator.SubtractionMask), new PredefinedPointerOperator(null, types.ULong, Operator.AdditionMask | Operator.SubtractionMask), new PredefinedPointerOperator(types.Int, null, Operator.AdditionMask, null), new PredefinedPointerOperator(types.UInt, null, Operator.AdditionMask, null), new PredefinedPointerOperator(types.Long, null, Operator.AdditionMask, null), new PredefinedPointerOperator(types.ULong, null, Operator.AdditionMask, null), new PredefinedPointerOperator(null, Operator.SubtractionMask, types.Long) }; } public static PredefinedOperator[] CreateStandardOperatorsTable(BuiltinTypes types) { TypeSpec return_type = types.Bool; return new PredefinedOperator[19] { new PredefinedOperator(types.Int, Operator.Multiply | Operator.ShiftMask | Operator.BitwiseMask), new PredefinedOperator(types.UInt, Operator.Multiply | Operator.BitwiseMask), new PredefinedOperator(types.Long, Operator.Multiply | Operator.BitwiseMask), new PredefinedOperator(types.ULong, Operator.Multiply | Operator.BitwiseMask), new PredefinedOperator(types.Float, Operator.Multiply), new PredefinedOperator(types.Double, Operator.Multiply), new PredefinedOperator(types.Decimal, Operator.Multiply), new PredefinedOperator(types.Int, Operator.ComparisonMask, return_type), new PredefinedOperator(types.UInt, Operator.ComparisonMask, return_type), new PredefinedOperator(types.Long, Operator.ComparisonMask, return_type), new PredefinedOperator(types.ULong, Operator.ComparisonMask, return_type), new PredefinedOperator(types.Float, Operator.ComparisonMask, return_type), new PredefinedOperator(types.Double, Operator.ComparisonMask, return_type), new PredefinedOperator(types.Decimal, Operator.ComparisonMask, return_type), new PredefinedStringOperator(types.String, Operator.AdditionMask, types.String), new PredefinedOperator(return_type, Operator.EqualityMask | Operator.BitwiseMask | Operator.LogicalMask, return_type), new PredefinedOperator(types.UInt, types.Int, Operator.ShiftMask), new PredefinedOperator(types.Long, types.Int, Operator.ShiftMask), new PredefinedOperator(types.ULong, types.Int, Operator.ShiftMask) }; } public static PredefinedOperator[] CreateStandardLiftedOperatorsTable(ModuleContainer module) { BuiltinTypes builtinTypes = module.Compiler.BuiltinTypes; PredefinedStringOperator[] array = new PredefinedStringOperator[2] { new PredefinedStringOperator(builtinTypes.String, builtinTypes.Object, Operator.AdditionMask, builtinTypes.String), new PredefinedStringOperator(builtinTypes.Object, builtinTypes.String, Operator.AdditionMask, builtinTypes.String) }; TypeSpec typeSpec = module.PredefinedTypes.Nullable.TypeSpec; if (typeSpec == null) { return array; } BuiltinTypeSpec builtinTypeSpec = builtinTypes.Bool; TypeSpec[] targs = new BuiltinTypeSpec[1] { builtinTypeSpec }; InflatedTypeSpec return_type = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Int }; InflatedTypeSpec rtype = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.UInt }; InflatedTypeSpec ltype = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Long }; InflatedTypeSpec ltype2 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.ULong }; InflatedTypeSpec ltype3 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Float }; InflatedTypeSpec inflatedTypeSpec = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Double }; InflatedTypeSpec inflatedTypeSpec2 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Decimal }; InflatedTypeSpec inflatedTypeSpec3 = typeSpec.MakeGenericType(module, targs); return new PredefinedOperator[20] { new PredefinedOperator(rtype, Operator.Multiply | Operator.ShiftMask | Operator.BitwiseMask | Operator.NullableMask), new PredefinedOperator(ltype, Operator.Multiply | Operator.BitwiseMask | Operator.NullableMask), new PredefinedOperator(ltype2, Operator.Multiply | Operator.BitwiseMask | Operator.NullableMask), new PredefinedOperator(ltype3, Operator.Multiply | Operator.BitwiseMask | Operator.NullableMask), new PredefinedOperator(inflatedTypeSpec, Operator.Multiply | Operator.NullableMask), new PredefinedOperator(inflatedTypeSpec2, Operator.Multiply | Operator.NullableMask), new PredefinedOperator(inflatedTypeSpec3, Operator.Multiply | Operator.NullableMask), new PredefinedOperator(rtype, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(ltype, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(ltype2, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(ltype3, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec2, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec3, Operator.ComparisonMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(return_type, Operator.BitwiseMask | Operator.NullableMask, return_type), new PredefinedOperator(ltype, rtype, Operator.ShiftMask | Operator.NullableMask), new PredefinedOperator(ltype2, rtype, Operator.ShiftMask | Operator.NullableMask), new PredefinedOperator(ltype3, rtype, Operator.ShiftMask | Operator.NullableMask), array[0], array[1] }; } public static PredefinedOperator[] CreateEqualityOperatorsTable(BuiltinTypes types) { TypeSpec typeSpec = types.Bool; return new PredefinedOperator[10] { new PredefinedEqualityOperator(types.String, typeSpec), new PredefinedEqualityOperator(types.Delegate, typeSpec), new PredefinedOperator(typeSpec, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.Int, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.UInt, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.Long, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.ULong, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.Float, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.Double, Operator.EqualityMask, typeSpec), new PredefinedOperator(types.Decimal, Operator.EqualityMask, typeSpec) }; } public static PredefinedOperator[] CreateEqualityLiftedOperatorsTable(ModuleContainer module) { TypeSpec typeSpec = module.PredefinedTypes.Nullable.TypeSpec; if (typeSpec == null) { return new PredefinedOperator[0]; } BuiltinTypes builtinTypes = module.Compiler.BuiltinTypes; BuiltinTypeSpec builtinTypeSpec = builtinTypes.Bool; TypeSpec[] targs = new BuiltinTypeSpec[1] { builtinTypeSpec }; InflatedTypeSpec inflatedTypeSpec = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Int }; InflatedTypeSpec inflatedTypeSpec2 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.UInt }; InflatedTypeSpec inflatedTypeSpec3 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Long }; InflatedTypeSpec inflatedTypeSpec4 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.ULong }; InflatedTypeSpec inflatedTypeSpec5 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Float }; InflatedTypeSpec inflatedTypeSpec6 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Double }; InflatedTypeSpec inflatedTypeSpec7 = typeSpec.MakeGenericType(module, targs); targs = new BuiltinTypeSpec[1] { builtinTypes.Decimal }; InflatedTypeSpec inflatedTypeSpec8 = typeSpec.MakeGenericType(module, targs); return new PredefinedOperator[8] { new PredefinedOperator(inflatedTypeSpec, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec2, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec3, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec4, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec5, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec6, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec7, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec), new PredefinedOperator(inflatedTypeSpec8, Operator.EqualityMask | Operator.NullableMask, builtinTypeSpec) }; } private bool DoBinaryOperatorPromotion(ResolveContext rc) { TypeSpec underlyingType = left.Type; if (underlyingType.IsNullableType) { underlyingType = NullableInfo.GetUnderlyingType(underlyingType); } if (underlyingType.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive) { return true; } TypeSpec underlyingType2 = right.Type; if (underlyingType2.IsNullableType) { underlyingType2 = NullableInfo.GetUnderlyingType(underlyingType2); } BuiltinTypeSpec.Type builtinType = underlyingType.BuiltinType; BuiltinTypeSpec.Type builtinType2 = underlyingType2.BuiltinType; TypeSpec typeSpec; if (builtinType == BuiltinTypeSpec.Type.Decimal || builtinType2 == BuiltinTypeSpec.Type.Decimal) { typeSpec = rc.BuiltinTypes.Decimal; } else if (builtinType == BuiltinTypeSpec.Type.Double || builtinType2 == BuiltinTypeSpec.Type.Double) { typeSpec = rc.BuiltinTypes.Double; } else if (builtinType == BuiltinTypeSpec.Type.Float || builtinType2 == BuiltinTypeSpec.Type.Float) { typeSpec = rc.BuiltinTypes.Float; } else if (builtinType == BuiltinTypeSpec.Type.ULong || builtinType2 == BuiltinTypeSpec.Type.ULong) { typeSpec = rc.BuiltinTypes.ULong; if (IsSignedType(builtinType)) { Expression expression = ConvertSignedConstant(left, typeSpec); if (expression == null) { return false; } left = expression; } else if (IsSignedType(builtinType2)) { Expression expression = ConvertSignedConstant(right, typeSpec); if (expression == null) { return false; } right = expression; } } else if (builtinType == BuiltinTypeSpec.Type.Long || builtinType2 == BuiltinTypeSpec.Type.Long) { typeSpec = rc.BuiltinTypes.Long; } else if (builtinType == BuiltinTypeSpec.Type.UInt || builtinType2 == BuiltinTypeSpec.Type.UInt) { typeSpec = rc.BuiltinTypes.UInt; if (IsSignedType(builtinType)) { Expression expression = ConvertSignedConstant(left, typeSpec); if (expression == null) { typeSpec = rc.BuiltinTypes.Long; } } else if (IsSignedType(builtinType2)) { Expression expression = ConvertSignedConstant(right, typeSpec); if (expression == null) { typeSpec = rc.BuiltinTypes.Long; } } } else { typeSpec = rc.BuiltinTypes.Int; } if (underlyingType != typeSpec) { Expression expression = PromoteExpression(rc, left, typeSpec); if (expression == null) { return false; } left = expression; } if (underlyingType2 != typeSpec) { Expression expression = PromoteExpression(rc, right, typeSpec); if (expression == null) { return false; } right = expression; } return true; } private static bool IsSignedType(BuiltinTypeSpec.Type type) { switch (type) { case BuiltinTypeSpec.Type.SByte: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.Long: return true; default: return false; } } private static Expression ConvertSignedConstant(Expression expr, TypeSpec type) { if (!(expr is Constant constant)) { return null; } return constant.ConvertImplicitly(type); } private static Expression PromoteExpression(ResolveContext rc, Expression expr, TypeSpec type) { if (expr.Type.IsNullableType) { return Convert.ImplicitConversionStandard(rc, expr, rc.Module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType(rc, new TypeSpec[1] { type }), expr.Location); } if (expr is Constant constant) { return constant.ConvertImplicitly(type); } return Convert.ImplicitNumericConversion(expr, type); } protected override Expression DoResolve(ResolveContext ec) { if (left == null) { return null; } if (oper == Operator.Subtraction && left is ParenthesizedExpression) { left = ((ParenthesizedExpression)left).Expr; left = left.Resolve(ec, ResolveFlags.VariableOrValue | ResolveFlags.Type); if (left == null) { return null; } if (left.eclass == ExprClass.Type) { ec.Report.Error(75, loc, "To cast a negative value, you must enclose the value in parentheses"); return null; } } else { left = left.Resolve(ec); } if (left == null) { return null; } right = right.Resolve(ec); if (right == null) { return null; } Constant constant = left as Constant; Constant constant2 = right as Constant; if (!ec.HasSet(ResolveContext.Options.EnumScope) && constant != null && constant2 != null && (left.Type.IsEnum || right.Type.IsEnum)) { constant = EnumLiftUp(ec, constant, constant2); if (constant != null) { constant2 = EnumLiftUp(ec, constant2, constant); } } if (constant2 != null && constant != null) { int errors = ec.Report.Errors; Expression expression = ConstantFold.BinaryFold(ec, oper, constant, constant2, loc); if (expression != null || ec.Report.Errors != errors) { return expression; } } if ((oper & Operator.ComparisonMask) != 0) { if (left.Equals(right)) { ec.Report.Warning(1718, 3, loc, "A comparison made to same variable. Did you mean to compare something else?"); } CheckOutOfRangeComparison(ec, constant, right.Type); CheckOutOfRangeComparison(ec, constant2, left.Type); } TypeSpec typeSpec = left.Type; TypeSpec typeSpec2 = right.Type; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic || typeSpec2.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return DoResolveDynamic(ec); } if (typeSpec == InternalType.DefaultType || typeSpec2 == InternalType.DefaultType) { if ((Oper & Operator.EqualityMask) == 0) { ec.Report.Error(8310, loc, "Operator `{0}' cannot be applied to operand `default'", OperName(Oper)); return null; } if (typeSpec == typeSpec2) { ec.Report.Error(8315, loc, "Operator `{0}' is ambiguous on operands `default' and `default'", OperName(Oper)); return null; } if (typeSpec2 == InternalType.DefaultType) { right = new DefaultValueExpression(new TypeExpression(typeSpec, right.Location), right.Location).Resolve(ec); } else { left = new DefaultValueExpression(new TypeExpression(typeSpec2, left.Location), left.Location).Resolve(ec); } } return DoResolveCore(ec, left, right); } private Expression DoResolveDynamic(ResolveContext rc) { TypeSpec typeSpec = left.Type; TypeSpec typeSpec2 = right.Type; if (typeSpec.Kind == MemberKind.Void || typeSpec == InternalType.MethodGroup || typeSpec == InternalType.AnonymousMethod || typeSpec2.Kind == MemberKind.Void || typeSpec2 == InternalType.MethodGroup || typeSpec2 == InternalType.AnonymousMethod) { Error_OperatorCannotBeApplied(rc, left, right); return null; } Arguments arguments; if ((oper & Operator.LogicalMask) != 0) { arguments = new Arguments(2); Expression expr; Expression true_expr; Expression false_expr; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(typeSpec, rc.CurrentBlock, loc); Arguments arguments2 = new Arguments(1); arguments2.Add(new Argument(new SimpleAssign(localVariable.CreateReferenceExpression(rc, loc), left).Resolve(rc))); left = localVariable.CreateReferenceExpression(rc, loc); if (oper == Operator.LogicalAnd) { expr = DynamicUnaryConversion.CreateIsFalse(rc, arguments2, loc); true_expr = left; } else { expr = DynamicUnaryConversion.CreateIsTrue(rc, arguments2, loc); true_expr = left; } arguments.Add(new Argument(left)); arguments.Add(new Argument(right)); false_expr = new DynamicExpressionStatement(this, arguments, loc); } else { LocalVariable localVariable2 = LocalVariable.CreateCompilerGenerated(rc.BuiltinTypes.Bool, rc.CurrentBlock, loc); if (!Convert.ImplicitConversionExists(rc, left, localVariable2.Type) && ((oper == Operator.LogicalAnd) ? Expression.GetOperatorFalse(rc, left, loc) : Expression.GetOperatorTrue(rc, left, loc)) == null) { rc.Report.Error(7083, left.Location, "Expression must be implicitly convertible to Boolean or its type `{0}' must define operator `{1}'", typeSpec.GetSignatureForError(), (oper == Operator.LogicalAnd) ? "false" : "true"); return null; } arguments.Add(new Argument(localVariable2.CreateReferenceExpression(rc, loc).Resolve(rc))); arguments.Add(new Argument(right)); right = new DynamicExpressionStatement(this, arguments, loc); if (oper == Operator.LogicalAnd) { true_expr = right; false_expr = localVariable2.CreateReferenceExpression(rc, loc); } else { true_expr = localVariable2.CreateReferenceExpression(rc, loc); false_expr = right; } expr = new BooleanExpression(new SimpleAssign(localVariable2.CreateReferenceExpression(rc, loc), left)); } return new Conditional(expr, true_expr, false_expr, loc).Resolve(rc); } arguments = new Arguments(2); arguments.Add(new Argument(left)); arguments.Add(new Argument(right)); return new DynamicExpressionStatement(this, arguments, loc).Resolve(rc); } private Expression DoResolveCore(ResolveContext ec, Expression left_orig, Expression right_orig) { Expression expression = ResolveOperator(ec); if (expression == null) { Error_OperatorCannotBeApplied(ec, left_orig, right_orig); } if (left == null || right == null) { throw new InternalErrorException("Invalid conversion"); } if (oper == Operator.BitwiseOr) { CheckBitwiseOrOnSignExtended(ec); } return expression; } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return MakeExpression(ctx, left, right); } public System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx, Expression left, Expression right) { System.Linq.Expressions.Expression expression = left.MakeExpression(ctx); System.Linq.Expressions.Expression expression2 = right.MakeExpression(ctx); bool flag = ctx.HasSet(BuilderContext.Options.CheckedScope); return oper switch { Operator.Addition => flag ? System.Linq.Expressions.Expression.AddChecked(expression, expression2) : System.Linq.Expressions.Expression.Add(expression, expression2), Operator.BitwiseAnd => System.Linq.Expressions.Expression.And(expression, expression2), Operator.BitwiseOr => System.Linq.Expressions.Expression.Or(expression, expression2), Operator.Division => System.Linq.Expressions.Expression.Divide(expression, expression2), Operator.Equality => System.Linq.Expressions.Expression.Equal(expression, expression2), Operator.ExclusiveOr => System.Linq.Expressions.Expression.ExclusiveOr(expression, expression2), Operator.GreaterThan => System.Linq.Expressions.Expression.GreaterThan(expression, expression2), Operator.GreaterThanOrEqual => System.Linq.Expressions.Expression.GreaterThanOrEqual(expression, expression2), Operator.Inequality => System.Linq.Expressions.Expression.NotEqual(expression, expression2), Operator.LeftShift => System.Linq.Expressions.Expression.LeftShift(expression, expression2), Operator.LessThan => System.Linq.Expressions.Expression.LessThan(expression, expression2), Operator.LessThanOrEqual => System.Linq.Expressions.Expression.LessThanOrEqual(expression, expression2), Operator.LogicalAnd => System.Linq.Expressions.Expression.AndAlso(expression, expression2), Operator.LogicalOr => System.Linq.Expressions.Expression.OrElse(expression, expression2), Operator.Modulus => System.Linq.Expressions.Expression.Modulo(expression, expression2), Operator.Multiply => flag ? System.Linq.Expressions.Expression.MultiplyChecked(expression, expression2) : System.Linq.Expressions.Expression.Multiply(expression, expression2), Operator.RightShift => System.Linq.Expressions.Expression.RightShift(expression, expression2), Operator.Subtraction => flag ? System.Linq.Expressions.Expression.SubtractChecked(expression, expression2) : System.Linq.Expressions.Expression.Subtract(expression, expression2), _ => throw new NotImplementedException(oper.ToString()), }; } private Expression ResolveOperatorDelegate(ResolveContext ec, TypeSpec l, TypeSpec r) { if (l != r && !TypeSpecComparer.Variant.IsEqual(r, l)) { if (right.eclass == ExprClass.MethodGroup || r == InternalType.AnonymousMethod || r == InternalType.NullLiteral) { Expression expression = Convert.ImplicitConversionRequired(ec, right, l, loc); if (expression == null) { return null; } right = expression; r = right.Type; } else { if (left.eclass != ExprClass.MethodGroup && l != InternalType.AnonymousMethod && l != InternalType.NullLiteral) { return null; } Expression expression = Convert.ImplicitConversionRequired(ec, left, r, loc); if (expression == null) { return null; } left = expression; l = left.Type; } } MethodSpec methodSpec = null; Arguments arguments = new Arguments(2); arguments.Add(new Argument(left)); arguments.Add(new Argument(right)); if (oper == Operator.Addition) { methodSpec = ec.Module.PredefinedMembers.DelegateCombine.Resolve(loc); } else if (oper == Operator.Subtraction) { methodSpec = ec.Module.PredefinedMembers.DelegateRemove.Resolve(loc); } if (methodSpec == null) { return new EmptyExpression(ec.BuiltinTypes.Decimal); } Expression child = new UserOperatorCall(methodSpec, arguments, CreateExpressionTree, loc); return new ClassCast(child, l); } private Expression ResolveSingleEnumOperators(ResolveContext rc, bool lenum, bool renum, TypeSpec ltype, TypeSpec rtype) { if ((oper & Operator.ComparisonMask) != 0) { type = rc.BuiltinTypes.Bool; } else if (lenum) { type = ltype; } else if (renum) { type = rtype; } else if (ltype.IsNullableType && NullableInfo.GetUnderlyingType(ltype).IsEnum) { type = ltype; } else { type = rtype; } if (ltype == rtype) { if (lenum || renum) { return this; } LiftedBinaryOperator liftedBinaryOperator = new LiftedBinaryOperator(this); liftedBinaryOperator.Left = left; liftedBinaryOperator.Right = right; return liftedBinaryOperator.Resolve(rc); } if (renum && !ltype.IsNullableType) { Expression expression = Convert.ImplicitConversion(rc, left, rtype, loc); if (expression != null) { left = expression; return this; } } else if (lenum && !rtype.IsNullableType) { Expression expression = Convert.ImplicitConversion(rc, right, ltype, loc); if (expression != null) { right = expression; return this; } } TypeSpec typeSpec = rc.Module.PredefinedTypes.Nullable.TypeSpec; if (typeSpec != null) { if (renum && !ltype.IsNullableType) { InflatedTypeSpec target_type = typeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { rtype }); Expression expression = Convert.ImplicitConversion(rc, left, target_type, loc); if (expression != null) { left = expression; right = Convert.ImplicitConversion(rc, right, target_type, loc); } if ((oper & Operator.BitwiseMask) != 0) { type = target_type; } if (left.IsNull) { if ((oper & Operator.BitwiseMask) != 0) { return LiftedNull.CreateFromExpression(rc, this); } return CreateLiftedValueTypeResult(rc, rtype); } if (expression != null) { LiftedBinaryOperator liftedBinaryOperator2 = new LiftedBinaryOperator(this); liftedBinaryOperator2.Left = expression; liftedBinaryOperator2.Right = right; return liftedBinaryOperator2.Resolve(rc); } } else if (lenum && !rtype.IsNullableType) { InflatedTypeSpec target_type2 = typeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { ltype }); Expression expression = Convert.ImplicitConversion(rc, right, target_type2, loc); if (expression != null) { right = expression; left = Convert.ImplicitConversion(rc, left, target_type2, loc); } if ((oper & Operator.BitwiseMask) != 0) { type = target_type2; } if (right.IsNull) { if ((oper & Operator.BitwiseMask) != 0) { return LiftedNull.CreateFromExpression(rc, this); } return CreateLiftedValueTypeResult(rc, ltype); } if (expression != null) { LiftedBinaryOperator liftedBinaryOperator3 = new LiftedBinaryOperator(this); liftedBinaryOperator3.Left = left; liftedBinaryOperator3.Right = expression; return liftedBinaryOperator3.Resolve(rc); } } else if (rtype.IsNullableType && NullableInfo.GetUnderlyingType(rtype).IsEnum) { Unwrap unwrapRight = null; Expression expression; if (left.IsNull || right.IsNull) { if (rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { left = Convert.ImplicitConversion(rc, left, rtype, left.Location); } if ((oper & Operator.RelationalMask) != 0) { return CreateLiftedValueTypeResult(rc, rtype); } if ((oper & Operator.BitwiseMask) != 0) { return LiftedNull.CreateFromExpression(rc, this); } if (right.IsNull) { return CreateLiftedValueTypeResult(rc, left.Type); } expression = left; unwrapRight = new Unwrap(right); } else { expression = Convert.ImplicitConversion(rc, left, NullableInfo.GetUnderlyingType(rtype), loc); if (expression == null) { return null; } if ((oper & Operator.BitwiseMask) != 0) { type = rtype; } } if (expression != null) { LiftedBinaryOperator liftedBinaryOperator4 = new LiftedBinaryOperator(this); liftedBinaryOperator4.Left = expression; liftedBinaryOperator4.Right = right; liftedBinaryOperator4.UnwrapRight = unwrapRight; return liftedBinaryOperator4.Resolve(rc); } } else if (ltype.IsNullableType && NullableInfo.GetUnderlyingType(ltype).IsEnum) { Unwrap unwrapLeft = null; Expression expression; if (right.IsNull || left.IsNull) { if (rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { right = Convert.ImplicitConversion(rc, right, ltype, right.Location); } if ((oper & Operator.RelationalMask) != 0) { return CreateLiftedValueTypeResult(rc, ltype); } if ((oper & Operator.BitwiseMask) != 0) { return LiftedNull.CreateFromExpression(rc, this); } if (left.IsNull) { return CreateLiftedValueTypeResult(rc, right.Type); } expression = right; unwrapLeft = new Unwrap(left); } else { expression = Convert.ImplicitConversion(rc, right, NullableInfo.GetUnderlyingType(ltype), loc); if (expression == null) { return null; } if ((oper & Operator.BitwiseMask) != 0) { type = ltype; } } if (expression != null) { LiftedBinaryOperator liftedBinaryOperator5 = new LiftedBinaryOperator(this); liftedBinaryOperator5.Left = left; liftedBinaryOperator5.UnwrapLeft = unwrapLeft; liftedBinaryOperator5.Right = expression; return liftedBinaryOperator5.Resolve(rc); } } } return null; } private static Expression ConvertEnumOperandToUnderlyingType(ResolveContext rc, Expression expr, bool liftType) { TypeSpec typeSpec; if (!expr.Type.IsNullableType) { typeSpec = ((!expr.Type.IsEnum) ? expr.Type : EnumSpec.GetUnderlyingType(expr.Type)); } else { TypeSpec underlyingType = NullableInfo.GetUnderlyingType(expr.Type); typeSpec = ((!underlyingType.IsEnum) ? underlyingType : EnumSpec.GetUnderlyingType(underlyingType)); } BuiltinTypeSpec.Type builtinType = typeSpec.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 2) <= 1u || (uint)(type - 5) <= 1u) { typeSpec = rc.BuiltinTypes.Int; } if (expr.Type.IsNullableType || liftType) { typeSpec = rc.Module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { typeSpec }); } if (expr.Type == typeSpec) { return expr; } return EmptyCast.Create(expr, typeSpec); } private Expression ResolveEnumOperators(ResolveContext rc, bool lenum, bool renum, TypeSpec ltype, TypeSpec rtype) { TypeSpec typeSpec = (lenum ? ltype : (renum ? rtype : ((!ltype.IsNullableType || !NullableInfo.GetUnderlyingType(ltype).IsEnum) ? rtype : ltype))); Expression expression; if (!typeSpec.IsNullableType) { expression = ResolveOperatorPredefined(rc, rc.Module.GetPredefinedEnumAritmeticOperators(typeSpec, nullable: false), primitives_only: false); if (expression != null) { expression = ((oper != Operator.Subtraction) ? ConvertEnumAdditionalResult(expression, typeSpec) : ConvertEnumSubtractionResult(rc, expression)); enum_conversion = GetEnumResultCast(expression.Type); return expression; } PredefinedType nullable = rc.Module.PredefinedTypes.Nullable; if (!nullable.IsDefined) { return null; } typeSpec = nullable.TypeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { typeSpec }); } expression = ResolveOperatorPredefined(rc, rc.Module.GetPredefinedEnumAritmeticOperators(typeSpec, nullable: true), primitives_only: false); if (expression != null) { expression = ((oper != Operator.Subtraction) ? ConvertEnumAdditionalResult(expression, typeSpec) : ConvertEnumSubtractionResult(rc, expression)); enum_conversion = GetEnumResultCast(expression.Type); } return expression; } private static Expression ConvertEnumAdditionalResult(Expression expr, TypeSpec enumType) { return EmptyCast.Create(expr, enumType); } private Expression ConvertEnumSubtractionResult(ResolveContext rc, Expression expr) { TypeSpec typeSpec; if (left.Type == right.Type) { typeSpec = ((!(right is EnumConstant { IsZeroInteger: not false }) || right.Type.IsEnum) ? (left.Type.IsNullableType ? NullableInfo.GetEnumUnderlyingType(rc.Module, left.Type) : EnumSpec.GetUnderlyingType(left.Type)) : left.Type); } else { typeSpec = ((!IsEnumOrNullableEnum(left.Type)) ? right.Type : left.Type); if (expr is LiftedBinaryOperator && !typeSpec.IsNullableType) { typeSpec = rc.Module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { typeSpec }); } } return EmptyCast.Create(expr, typeSpec); } public static ConvCast.Mode GetEnumResultCast(TypeSpec type) { if (type.IsNullableType) { type = NullableInfo.GetUnderlyingType(type); } if (type.IsEnum) { type = EnumSpec.GetUnderlyingType(type); } return type.BuiltinType switch { BuiltinTypeSpec.Type.SByte => ConvCast.Mode.I4_I1, BuiltinTypeSpec.Type.Byte => ConvCast.Mode.I4_U1, BuiltinTypeSpec.Type.Short => ConvCast.Mode.I4_I2, BuiltinTypeSpec.Type.UShort => ConvCast.Mode.I4_U2, _ => ConvCast.Mode.I1_U1, }; } private Expression ResolveEquality(ResolveContext ec, TypeSpec l, TypeSpec r, bool primitives_only) { type = ec.BuiltinTypes.Bool; bool flag = false; if (!primitives_only) { TypeParameterSpec typeParameterSpec = l as TypeParameterSpec; TypeParameterSpec typeParameterSpec2 = r as TypeParameterSpec; if (typeParameterSpec != null) { if (right is NullLiteral) { if (typeParameterSpec.GetEffectiveBase().BuiltinType == BuiltinTypeSpec.Type.ValueType) { return null; } left = new BoxedCast(left, ec.BuiltinTypes.Object); return this; } if (!typeParameterSpec.IsReferenceType) { return null; } l = typeParameterSpec.GetEffectiveBase(); left = new BoxedCast(left, l); } else if (left is NullLiteral && typeParameterSpec2 == null) { if (TypeSpec.IsReferenceType(r)) { return this; } if (r.Kind == MemberKind.InternalCompilerType) { return null; } } if (typeParameterSpec2 != null) { if (left is NullLiteral) { if (typeParameterSpec2.GetEffectiveBase().BuiltinType == BuiltinTypeSpec.Type.ValueType) { return null; } right = new BoxedCast(right, ec.BuiltinTypes.Object); return this; } if (!typeParameterSpec2.IsReferenceType) { return null; } r = typeParameterSpec2.GetEffectiveBase(); right = new BoxedCast(right, r); } else if (right is NullLiteral) { if (TypeSpec.IsReferenceType(l)) { return this; } if (l.Kind == MemberKind.InternalCompilerType) { return null; } } if (l.IsDelegate) { if (right.eclass == ExprClass.MethodGroup) { Expression expression = Convert.ImplicitConversion(ec, right, l, loc); if (expression == null) { return null; } right = expression; r = l; } else if (r.IsDelegate && l != r) { return null; } } else if (left.eclass == ExprClass.MethodGroup && r.IsDelegate) { Expression expression = Convert.ImplicitConversionRequired(ec, left, r, loc); if (expression == null) { return null; } left = expression; l = r; } else { flag = l == r && !l.IsStruct; } } if (r.BuiltinType != BuiltinTypeSpec.Type.Object && l.BuiltinType != BuiltinTypeSpec.Type.Object) { Expression expression = ResolveOperatorPredefined(ec, ec.BuiltinTypes.OperatorsBinaryEquality, flag); if (expression != null) { return expression; } if (!flag || l.IsNullableType) { expression = ResolveOperatorPredefined(ec, ec.Module.OperatorsBinaryEqualityLifted, flag); if (expression != null) { return expression; } } if ((l.IsNullableType && right.IsNull) || (r.IsNullableType && left.IsNull)) { LiftedBinaryOperator liftedBinaryOperator = new LiftedBinaryOperator(this); liftedBinaryOperator.Left = left; liftedBinaryOperator.Right = right; return liftedBinaryOperator.Resolve(ec); } } if (l == r) { return (l.Kind == MemberKind.InternalCompilerType || l.Kind == MemberKind.Struct) ? null : this; } if (!Convert.ExplicitReferenceConversionExists(l, r) && !Convert.ExplicitReferenceConversionExists(r, l)) { return null; } if (!TypeSpec.IsReferenceType(l) || !TypeSpec.IsReferenceType(r)) { return null; } if (l.BuiltinType == BuiltinTypeSpec.Type.String || l.BuiltinType == BuiltinTypeSpec.Type.Delegate || l.IsDelegate || MemberCache.GetUserOperator(l, Mono.CSharp.Operator.OpType.Equality, declaredOnly: false) != null) { ec.Report.Warning(253, 2, loc, "Possible unintended reference comparison. Consider casting the right side expression to type `{0}' to get value comparison", l.GetSignatureForError()); } if (r.BuiltinType == BuiltinTypeSpec.Type.String || r.BuiltinType == BuiltinTypeSpec.Type.Delegate || r.IsDelegate || MemberCache.GetUserOperator(r, Mono.CSharp.Operator.OpType.Equality, declaredOnly: false) != null) { ec.Report.Warning(252, 2, loc, "Possible unintended reference comparison. Consider casting the left side expression to type `{0}' to get value comparison", r.GetSignatureForError()); } return this; } private Expression ResolveOperatorPointer(ResolveContext ec, TypeSpec l, TypeSpec r) { if ((oper & Operator.ComparisonMask) != 0) { if (!l.IsPointer) { Expression expression = Convert.ImplicitConversion(ec, left, r, left.Location); if (expression == null) { return null; } left = expression; } if (!r.IsPointer) { Expression expression = Convert.ImplicitConversion(ec, right, l, right.Location); if (expression == null) { return null; } right = expression; } type = ec.BuiltinTypes.Bool; return this; } return ResolveOperatorPredefined(ec, ec.BuiltinTypes.OperatorsBinaryUnsafe, primitives_only: false); } private Expression ResolveOperatorPredefined(ResolveContext ec, PredefinedOperator[] operators, bool primitives_only) { PredefinedOperator predefinedOperator = null; TypeSpec typeSpec = left.Type; TypeSpec typeSpec2 = right.Type; Operator obj = oper & ~Operator.ValuesOnlyMask; foreach (PredefinedOperator predefinedOperator2 in operators) { if ((predefinedOperator2.OperatorsMask & obj) == 0) { continue; } if (primitives_only) { if (!predefinedOperator2.IsPrimitiveApplicable(typeSpec, typeSpec2)) { continue; } } else if (!predefinedOperator2.IsApplicable(ec, left, right)) { continue; } if (predefinedOperator == null) { predefinedOperator = predefinedOperator2; if (!primitives_only) { continue; } break; } predefinedOperator = predefinedOperator2.ResolveBetterOperator(ec, predefinedOperator); if (predefinedOperator != null) { continue; } ec.Report.Error(34, loc, "Operator `{0}' is ambiguous on operands of type `{1}' and `{2}'", OperName(oper), typeSpec.GetSignatureForError(), typeSpec2.GetSignatureForError()); predefinedOperator = predefinedOperator2; break; } return predefinedOperator?.ConvertResult(ec, this); } private Expression OptimizeAndOperation(Expression expr) { Constant constant = right as Constant; Constant constant2 = left as Constant; if ((constant2 != null && constant2.IsDefaultValue) || (constant != null && constant.IsDefaultValue)) { Constant expr2 = ((constant == null) ? new SideEffectConstant(constant2, right, loc) : new SideEffectConstant(constant, left, loc)); return ReducedExpression.Create(expr2, expr); } return expr; } public Expression CreateLiftedValueTypeResult(ResolveContext rc, TypeSpec valueType) { if (rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { type = rc.BuiltinTypes.Bool; return this; } Constant constant = new BoolConstant(rc.BuiltinTypes, Oper == Operator.Inequality, loc); if ((Oper & Operator.EqualityMask) != 0) { rc.Report.Warning(472, 2, loc, "The result of comparing value type `{0}' with null is always `{1}'", valueType.GetSignatureForError(), constant.GetValueAsLiteral()); } else { rc.Report.Warning(464, 2, loc, "The result of comparing type `{0}' with null is always `{1}'", valueType.GetSignatureForError(), constant.GetValueAsLiteral()); } return constant; } private Expression ResolveUserOperator(ResolveContext rc, Expression left, Expression right) { Mono.CSharp.Operator.OpType op = ConvertBinaryToUserOperator(oper); TypeSpec underlyingType = left.Type; if (underlyingType.IsNullableType) { underlyingType = NullableInfo.GetUnderlyingType(underlyingType); } TypeSpec underlyingType2 = right.Type; if (underlyingType2.IsNullableType) { underlyingType2 = NullableInfo.GetUnderlyingType(underlyingType2); } IList list = MemberCache.GetUserOperator(underlyingType, op, declaredOnly: false); IList list2 = null; if (underlyingType != underlyingType2) { list2 = MemberCache.GetUserOperator(underlyingType2, op, declaredOnly: false); if (list2 == null && list == null) { return null; } } else if (list == null) { return null; } Arguments args = new Arguments(2); Argument argument = new Argument(left); args.Add(argument); Argument argument2 = new Argument(right); args.Add(argument2); if (list != null && list2 != null) { list = CombineUserOperators(list, list2); } else if (list2 != null) { list = list2; } MethodSpec methodSpec = new OverloadResolver(list, OverloadResolver.Restrictions.ProbingOnly | OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded, loc).ResolveOperator(rc, ref args); if (methodSpec == null) { if ((oper & Operator.LogicalMask) != 0) { return null; } if (!IsLiftedOperatorApplicable()) { return null; } List list3 = CreateLiftedOperators(rc, list); if (list3 == null) { return null; } methodSpec = new OverloadResolver(list3, OverloadResolver.Restrictions.ProbingOnly | OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded, loc).ResolveOperator(rc, ref args); if (methodSpec == null) { return null; } MethodSpec methodSpec2 = null; foreach (MethodSpec item in list) { if (item.MemberDefinition == methodSpec.MemberDefinition) { methodSpec2 = item; break; } } if (rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { this.left = Convert.ImplicitConversion(rc, left, methodSpec.Parameters.Types[0], left.Location); this.right = Convert.ImplicitConversion(rc, right, methodSpec.Parameters.Types[1], left.Location); } TypeSpec[] types = methodSpec2.Parameters.Types; if (left.IsNull || right.IsNull) { if ((oper & (Operator.Multiply | Operator.ShiftMask | Operator.BitwiseMask)) != 0) { type = methodSpec.ReturnType; return LiftedNull.CreateFromExpression(rc, this); } if ((oper & Operator.RelationalMask) != 0) { return CreateLiftedValueTypeResult(rc, left.IsNull ? types[1] : types[0]); } if ((oper & Operator.EqualityMask) != 0 && ((left.IsNull && !right.Type.IsNullableType) || !left.Type.IsNullableType)) { return CreateLiftedValueTypeResult(rc, left.IsNull ? types[1] : types[0]); } } type = methodSpec.ReturnType; LiftedBinaryOperator liftedBinaryOperator = new LiftedBinaryOperator(this); liftedBinaryOperator.UserOperator = methodSpec2; if (left.Type.IsNullableType && !types[0].IsNullableType) { liftedBinaryOperator.UnwrapLeft = new Unwrap(left); } if (right.Type.IsNullableType && !types[1].IsNullableType) { liftedBinaryOperator.UnwrapRight = new Unwrap(right); } liftedBinaryOperator.Left = Convert.ImplicitConversion(rc, liftedBinaryOperator.UnwrapLeft ?? left, types[0], left.Location); liftedBinaryOperator.Right = Convert.ImplicitConversion(rc, liftedBinaryOperator.UnwrapRight ?? right, types[1], right.Location); return liftedBinaryOperator.Resolve(rc); } Expression result = (((oper & Operator.LogicalMask) == 0) ? new UserOperatorCall(methodSpec, args, CreateExpressionTree, loc) : new ConditionalLogicalOperator(methodSpec, args, CreateExpressionTree, oper == Operator.LogicalAnd, loc).Resolve(rc)); this.left = argument.Expr; this.right = argument2.Expr; return result; } private bool IsLiftedOperatorApplicable() { if (left.Type.IsNullableType) { if ((oper & Operator.EqualityMask) != 0) { return !right.IsNull; } return true; } if (right.Type.IsNullableType) { if ((oper & Operator.EqualityMask) != 0) { return !left.IsNull; } return true; } if (TypeSpec.IsValueType(left.Type)) { return right.IsNull; } if (TypeSpec.IsValueType(right.Type)) { return left.IsNull; } return false; } private List CreateLiftedOperators(ResolveContext rc, IList operators) { TypeSpec typeSpec = rc.Module.PredefinedTypes.Nullable.TypeSpec; if (typeSpec == null) { return null; } List list = null; foreach (MethodSpec @operator in operators) { TypeSpec typeSpec2; if ((Oper & Operator.ComparisonMask) != 0) { typeSpec2 = @operator.ReturnType; if (typeSpec2.BuiltinType != BuiltinTypeSpec.Type.FirstPrimitive) { continue; } } else { if (!TypeSpec.IsNonNullableValueType(@operator.ReturnType)) { continue; } typeSpec2 = null; } TypeSpec[] types = @operator.Parameters.Types; if (TypeSpec.IsNonNullableValueType(types[0]) && TypeSpec.IsNonNullableValueType(types[1]) && ((Oper & Operator.EqualityMask) == 0 || types[0] == types[1])) { if (list == null) { list = new List(); } if (typeSpec2 == null) { typeSpec2 = typeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { @operator.ReturnType }); } AParametersCollection parameters = ParametersCompiled.CreateFullyResolved(typeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { types[0] }), typeSpec.MakeGenericType(rc.Module, new TypeSpec[1] { types[1] })); MethodSpec item = new MethodSpec(@operator.Kind, @operator.DeclaringType, @operator.MemberDefinition, typeSpec2, parameters, @operator.Modifiers); list.Add(item); } } return list; } private static IList CombineUserOperators(IList left, IList right) { List list = new List(left.Count + right.Count); list.AddRange(left); foreach (MemberSpec item in right) { bool flag = false; foreach (MemberSpec item2 in left) { if (item2.DeclaringType == item.DeclaringType) { flag = true; break; } } if (!flag) { list.Add(item); } } return list; } private void CheckOutOfRangeComparison(ResolveContext ec, Constant c, TypeSpec type) { if (c is IntegralConstant || c is CharConstant) { try { c.ConvertExplicitly(in_checked_context: true, type); } catch (OverflowException) { ec.Report.Warning(652, 2, loc, "A comparison between a constant and a variable is useless. The constant is out of the range of the variable type `{0}'", type.GetSignatureForError()); } } } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { if (ec.HasSet(BuilderContext.Options.AsyncBody) && right.ContainsEmitWithAwait()) { left = left.EmitToField(ec); if ((oper & Operator.LogicalMask) == 0) { right = right.EmitToField(ec); } } if ((oper & Operator.EqualityMask) != 0 && (left is Constant || right is Constant)) { bool flag = ((oper == Operator.Inequality) ? on_true : (!on_true)); if (left is Constant) { Expression expression = right; right = left; left = expression; } if (((Constant)right).IsZeroInteger && right.Type.BuiltinType != BuiltinTypeSpec.Type.Long && right.Type.BuiltinType != BuiltinTypeSpec.Type.ULong) { left.EmitBranchable(ec, target, flag); return; } if (right.Type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive) { left.EmitBranchable(ec, target, !flag); return; } } else { if (oper == Operator.LogicalAnd) { if (on_true) { Label label = ec.DefineLabel(); left.EmitBranchable(ec, label, on_true: false); right.EmitBranchable(ec, target, on_true: true); ec.MarkLabel(label); return; } if (!(left is Constant)) { left.EmitBranchable(ec, target, on_true: false); } if (!(right is Constant)) { right.EmitBranchable(ec, target, on_true: false); } return; } if (oper == Operator.LogicalOr) { if (on_true) { left.EmitBranchable(ec, target, on_true: true); right.EmitBranchable(ec, target, on_true: true); return; } Label label2 = ec.DefineLabel(); left.EmitBranchable(ec, label2, on_true: true); right.EmitBranchable(ec, target, on_true: false); ec.MarkLabel(label2); return; } if ((oper & Operator.ComparisonMask) == 0) { base.EmitBranchable(ec, target, on_true); return; } } left.Emit(ec); right.Emit(ec); TypeSpec t = left.Type; bool flag2 = IsFloat(t); bool flag3 = flag2 || IsUnsigned(t); switch (oper) { case Operator.Equality: if (on_true) { ec.Emit(OpCodes.Beq, target); } else { ec.Emit(OpCodes.Bne_Un, target); } break; case Operator.Inequality: if (on_true) { ec.Emit(OpCodes.Bne_Un, target); } else { ec.Emit(OpCodes.Beq, target); } break; case Operator.LessThan: if (on_true) { if (flag3 && !flag2) { ec.Emit(OpCodes.Blt_Un, target); } else { ec.Emit(OpCodes.Blt, target); } } else if (flag3) { ec.Emit(OpCodes.Bge_Un, target); } else { ec.Emit(OpCodes.Bge, target); } break; case Operator.GreaterThan: if (on_true) { if (flag3 && !flag2) { ec.Emit(OpCodes.Bgt_Un, target); } else { ec.Emit(OpCodes.Bgt, target); } } else if (flag3) { ec.Emit(OpCodes.Ble_Un, target); } else { ec.Emit(OpCodes.Ble, target); } break; case Operator.LessThanOrEqual: if (on_true) { if (flag3 && !flag2) { ec.Emit(OpCodes.Ble_Un, target); } else { ec.Emit(OpCodes.Ble, target); } } else if (flag3) { ec.Emit(OpCodes.Bgt_Un, target); } else { ec.Emit(OpCodes.Bgt, target); } break; case Operator.GreaterThanOrEqual: if (on_true) { if (flag3 && !flag2) { ec.Emit(OpCodes.Bge_Un, target); } else { ec.Emit(OpCodes.Bge, target); } } else if (flag3) { ec.Emit(OpCodes.Blt_Un, target); } else { ec.Emit(OpCodes.Blt, target); } break; default: throw new InternalErrorException(oper.ToString()); } } public override void Emit(EmitContext ec) { if (ec.HasSet(BuilderContext.Options.AsyncBody) && right.ContainsEmitWithAwait()) { left = left.EmitToField(ec); if ((oper & Operator.LogicalMask) == 0) { right = right.EmitToField(ec); } } if ((oper & Operator.LogicalMask) != 0) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); bool flag = oper == Operator.LogicalOr; left.EmitBranchable(ec, label, flag); right.Emit(ec); ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); ec.EmitInt(flag ? 1 : 0); ec.MarkLabel(label2); } else if (oper == Operator.Subtraction && left is IntegralConstant { IsDefaultValue: not false }) { right.Emit(ec); ec.Emit(OpCodes.Neg); } else { EmitOperator(ec, left, right); } } public void EmitOperator(EmitContext ec, Expression left, Expression right) { left.Emit(ec); right.Emit(ec); EmitOperatorOpcode(ec, oper, left.Type, right); if (enum_conversion != ConvCast.Mode.I1_U1) { ConvCast.Emit(ec, enum_conversion); } } public override void EmitPrepare(EmitContext ec) { Left.EmitPrepare(ec); Right.EmitPrepare(ec); } public override void EmitSideEffect(EmitContext ec) { if ((oper & Operator.LogicalMask) != 0 || (ec.HasSet(BuilderContext.Options.CheckedScope) && (oper == Operator.Multiply || oper == Operator.Addition || oper == Operator.Subtraction))) { base.EmitSideEffect(ec); return; } left.EmitSideEffect(ec); right.EmitSideEffect(ec); } public override Expression EmitToField(EmitContext ec) { if ((oper & Operator.LogicalMask) == 0) { if (left is Await obj && right.IsSideEffectFree) { obj.Statement.EmitPrologue(ec); left = obj.Statement.GetResultExpression(ec); return this; } if (right is Await obj2 && left.IsSideEffectFree) { obj2.Statement.EmitPrologue(ec); right = obj2.Statement.GetResultExpression(ec); return this; } } return base.EmitToField(ec); } protected override void CloneTo(CloneContext clonectx, Expression t) { Binary binary = (Binary)t; binary.left = left.Clone(clonectx); binary.right = right.Clone(clonectx); } public Expression CreateCallSiteBinder(ResolveContext ec, Arguments args) { Arguments arguments = new Arguments(4); MemberAccess expr = new MemberAccess(new MemberAccess(new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", loc), "Linq", loc), "Expressions", loc); CSharpBinderFlags cSharpBinderFlags = CSharpBinderFlags.None; if (ec.HasSet(ResolveContext.Options.CheckedScope)) { cSharpBinderFlags = CSharpBinderFlags.CheckedContext; } if ((oper & Operator.LogicalMask) != 0) { cSharpBinderFlags |= CSharpBinderFlags.BinaryOperationLogical; } arguments.Add(new Argument(new EnumConstant(new IntLiteral(ec.BuiltinTypes, (int)cSharpBinderFlags, loc), ec.Module.PredefinedTypes.BinderFlags.Resolve()))); arguments.Add(new Argument(new MemberAccess(new MemberAccess(expr, "ExpressionType", loc), GetOperatorExpressionTypeName(), loc))); arguments.Add(new Argument(new TypeOf(ec.CurrentType, loc))); arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(args.CreateDynamicBinderArguments(ec), loc))); return new Invocation(new MemberAccess(new TypeExpression(ec.Module.PredefinedTypes.Binder.TypeSpec, loc), "BinaryOperation", loc), arguments); } public override Expression CreateExpressionTree(ResolveContext ec) { return CreateExpressionTree(ec, null); } public Expression CreateExpressionTree(ResolveContext ec, Expression method) { bool flag = false; string name; switch (oper) { case Operator.Addition: name = ((method != null || !ec.HasSet(ResolveContext.Options.CheckedScope) || IsFloat(type)) ? "Add" : "AddChecked"); break; case Operator.BitwiseAnd: name = "And"; break; case Operator.BitwiseOr: name = "Or"; break; case Operator.Division: name = "Divide"; break; case Operator.Equality: name = "Equal"; flag = true; break; case Operator.ExclusiveOr: name = "ExclusiveOr"; break; case Operator.GreaterThan: name = "GreaterThan"; flag = true; break; case Operator.GreaterThanOrEqual: name = "GreaterThanOrEqual"; flag = true; break; case Operator.Inequality: name = "NotEqual"; flag = true; break; case Operator.LeftShift: name = "LeftShift"; break; case Operator.LessThan: name = "LessThan"; flag = true; break; case Operator.LessThanOrEqual: name = "LessThanOrEqual"; flag = true; break; case Operator.LogicalAnd: name = "AndAlso"; break; case Operator.LogicalOr: name = "OrElse"; break; case Operator.Modulus: name = "Modulo"; break; case Operator.Multiply: name = ((method != null || !ec.HasSet(ResolveContext.Options.CheckedScope) || IsFloat(type)) ? "Multiply" : "MultiplyChecked"); break; case Operator.RightShift: name = "RightShift"; break; case Operator.Subtraction: name = ((method != null || !ec.HasSet(ResolveContext.Options.CheckedScope) || IsFloat(type)) ? "Subtract" : "SubtractChecked"); break; default: throw new InternalErrorException("Unknown expression tree binary operator " + oper); } Arguments arguments = new Arguments(2); arguments.Add(new Argument(left.CreateExpressionTree(ec))); arguments.Add(new Argument(right.CreateExpressionTree(ec))); if (method != null) { if (flag) { arguments.Add(new Argument(new BoolLiteral(ec.BuiltinTypes, val: false, loc))); } arguments.Add(new Argument(method)); } return CreateExpressionFactoryCall(ec, name, arguments); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class StringConcat : Expression { private Arguments arguments; private StringConcat(Location loc) { base.loc = loc; arguments = new Arguments(2); } public override bool ContainsEmitWithAwait() { return arguments.ContainsEmitWithAwait(); } public static StringConcat Create(ResolveContext rc, Expression left, Expression right, Location loc) { if (left.eclass == ExprClass.Unresolved || right.eclass == ExprClass.Unresolved) { throw new ArgumentException(); } StringConcat stringConcat = new StringConcat(loc); stringConcat.type = rc.BuiltinTypes.String; stringConcat.eclass = ExprClass.Value; stringConcat.Append(rc, left); stringConcat.Append(rc, right); return stringConcat; } public override Expression CreateExpressionTree(ResolveContext ec) { Argument argument = arguments[0]; return CreateExpressionAddCall(ec, argument, argument.CreateExpressionTree(ec), 1); } private Expression CreateExpressionAddCall(ResolveContext ec, Argument left, Expression left_etree, int pos) { Arguments args = new Arguments(2); Arguments arguments = new Arguments(3); args.Add(left); arguments.Add(new Argument(left_etree)); args.Add(this.arguments[pos]); arguments.Add(new Argument(this.arguments[pos].CreateExpressionTree(ec))); IList concatMethodCandidates = GetConcatMethodCandidates(); if (concatMethodCandidates == null) { return null; } MethodSpec methodSpec = new OverloadResolver(concatMethodCandidates, OverloadResolver.Restrictions.NoBaseMembers, loc).ResolveMember(ec, ref args); if (methodSpec == null) { return null; } arguments.Add(new Argument(new TypeOfMethod(methodSpec, loc))); Expression expression = CreateExpressionFactoryCall(ec, "Add", arguments); if (++pos == this.arguments.Count) { return expression; } left = new Argument(new EmptyExpression(methodSpec.ReturnType)); return CreateExpressionAddCall(ec, left, expression, pos); } protected override Expression DoResolve(ResolveContext ec) { return this; } private void Append(ResolveContext rc, Expression operand) { if (operand is StringConstant stringConstant) { if (arguments.Count != 0) { Argument argument = arguments[arguments.Count - 1]; if (argument.Expr is StringConstant stringConstant2) { argument.Expr = new StringConstant(rc.BuiltinTypes, stringConstant2.Value + stringConstant.Value, stringConstant.Location); return; } } } else if (operand is StringConcat stringConcat) { arguments.AddRange(stringConcat.arguments); return; } arguments.Add(new Argument(operand)); } private IList GetConcatMethodCandidates() { return MemberCache.FindMembers(type, "Concat", declaredOnlyClass: true); } public override void Emit(EmitContext ec) { for (int i = 0; i < arguments.Count; i++) { if (arguments[i].Expr is NullConstant) { arguments.RemoveAt(i--); } } IList concatMethodCandidates = GetConcatMethodCandidates(); MethodSpec methodSpec = new OverloadResolver(concatMethodCandidates, OverloadResolver.Restrictions.NoBaseMembers, loc).ResolveMember(new ResolveContext(ec.MemberContext), ref arguments); if (methodSpec != null) { default(CallEmitter).EmitPredefined(ec, methodSpec, arguments); } } public override void FlowAnalysis(FlowAnalysisContext fc) { arguments.FlowAnalysis(fc); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { if (arguments.Count != 2) { throw new NotImplementedException("arguments.Count != 2"); } MethodInfo method = typeof(string).GetMethod("Concat", new Type[2] { typeof(object), typeof(object) }); return System.Linq.Expressions.Expression.Add(arguments[0].Expr.MakeExpression(ctx), arguments[1].Expr.MakeExpression(ctx), method); } } internal class ConditionalLogicalOperator : UserOperatorCall { private readonly bool is_and; private Expression oper_expr; public ConditionalLogicalOperator(MethodSpec oper, Arguments arguments, Func expr_tree, bool is_and, Location loc) : base(oper, arguments, expr_tree, loc) { this.is_and = is_and; eclass = ExprClass.Unresolved; } protected override Expression DoResolve(ResolveContext ec) { AParametersCollection parameters = oper.Parameters; if (!TypeSpecComparer.IsEqual(type, parameters.Types[0]) || !TypeSpecComparer.IsEqual(type, parameters.Types[1])) { ec.Report.Error(217, loc, "A user-defined operator `{0}' must have each parameter type and return type of the same type in order to be applicable as a short circuit operator", oper.GetSignatureForError()); return null; } Expression e = new EmptyExpression(type); Expression operatorTrue = Expression.GetOperatorTrue(ec, e, loc); Expression operatorFalse = Expression.GetOperatorFalse(ec, e, loc); if (operatorTrue == null || operatorFalse == null) { ec.Report.Error(218, loc, "The type `{0}' must have operator `true' and operator `false' defined when `{1}' is used as a short circuit operator", type.GetSignatureForError(), oper.GetSignatureForError()); return null; } oper_expr = (is_and ? operatorFalse : operatorTrue); eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { Label label = ec.DefineLabel(); bool flag = ec.HasSet(BuilderContext.Options.AsyncBody) && arguments[1].Expr.ContainsEmitWithAwait(); if (flag) { arguments[0] = arguments[0].EmitToField(ec, cloneResult: false); arguments[0].Expr.Emit(ec); } else { arguments[0].Expr.Emit(ec); ec.Emit(OpCodes.Dup); arguments.RemoveAt(0); } oper_expr.EmitBranchable(ec, label, on_true: true); base.Emit(ec); if (flag) { Label label2 = ec.DefineLabel(); ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); arguments[0].Expr.Emit(ec); ec.MarkLabel(label2); } else { ec.MarkLabel(label); } } } internal class PointerArithmetic : Expression { private Expression left; private Expression right; private readonly Binary.Operator op; public PointerArithmetic(Binary.Operator op, Expression l, Expression r, TypeSpec t, Location loc) { type = t; base.loc = loc; left = l; right = r; this.op = op; } public override bool ContainsEmitWithAwait() { throw new NotImplementedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { Error_PointerInsideExpressionTree(ec); return null; } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Variable; if (left.Type is PointerContainer pointerContainer && pointerContainer.Element.Kind == MemberKind.Void) { Error_VoidPointerOperation(ec); return null; } return this; } public override void Emit(EmitContext ec) { TypeSpec typeSpec = left.Type; TypeSpec t = (TypeManager.HasElementType(typeSpec) ? TypeManager.GetElementType(typeSpec) : ((!(left is FieldExpr fieldExpr)) ? typeSpec : ((FixedFieldSpec)fieldExpr.Spec).ElementType)); int size = BuiltinTypeSpec.GetSize(t); TypeSpec typeSpec2 = right.Type; if ((op & Binary.Operator.SubtractionMask) != 0 && typeSpec2.IsPointer) { left.Emit(ec); right.Emit(ec); ec.Emit(OpCodes.Sub); if (size != 1) { if (size == 0) { ec.Emit(OpCodes.Sizeof, t); } else { ec.EmitInt(size); } ec.Emit(OpCodes.Div); } ec.Emit(OpCodes.Conv_I8); return; } Constant constant = left as Constant; if (constant != null) { if (constant.IsDefaultValue) { left = EmptyExpression.Null; } else { constant = null; } } left.Emit(ec); Constant constant2 = right as Constant; if (constant2 != null) { if (constant2.IsDefaultValue) { return; } if (size != 0) { right = new IntConstant(ec.BuiltinTypes, size, right.Location); } else { right = new SizeOf(new TypeExpression(t, right.Location), right.Location); } ResolveContext rc = new ResolveContext(ec.MemberContext, ResolveContext.Options.UnsafeScope); right = new Binary(Binary.Operator.Multiply, right, constant2).Resolve(rc); if (right == null) { return; } } right.Emit(ec); if (constant2 == null) { switch (typeSpec2.BuiltinType) { case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.SByte: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.Int: ec.Emit(OpCodes.Conv_I); break; case BuiltinTypeSpec.Type.UInt: ec.Emit(OpCodes.Conv_U); break; } } if (constant2 == null && size != 1) { if (size == 0) { ec.Emit(OpCodes.Sizeof, t); } else { ec.EmitInt(size); } if (typeSpec2.BuiltinType == BuiltinTypeSpec.Type.Long || typeSpec2.BuiltinType == BuiltinTypeSpec.Type.ULong) { ec.Emit(OpCodes.Conv_I8); } Binary.EmitOperatorOpcode(ec, Binary.Operator.Multiply, typeSpec2, right); } if (constant == null) { if (typeSpec2.BuiltinType == BuiltinTypeSpec.Type.Long) { ec.Emit(OpCodes.Conv_I); } else if (typeSpec2.BuiltinType == BuiltinTypeSpec.Type.ULong) { ec.Emit(OpCodes.Conv_U); } Binary.EmitOperatorOpcode(ec, op, typeSpec, right); } } } internal class BooleanExpression : ShimExpression { public BooleanExpression(Expression expr) : base(expr) { loc = expr.Location; } public override Expression CreateExpressionTree(ResolveContext ec) { return base.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); if (expr == null) { return null; } if (expr is Assign assign && assign.Source is Constant) { ec.Report.Warning(665, 3, loc, "Assignment in conditional expression is always constant. Did you mean to use `==' instead ?"); } if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive) { return expr; } if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(expr)); return DynamicUnaryConversion.CreateIsTrue(ec, arguments, loc).Resolve(ec); } type = ec.BuiltinTypes.Bool; Expression expression = Convert.ImplicitConversion(ec, expr, type, loc); if (expression != null) { return expression; } expression = Expression.GetOperatorTrue(ec, expr, loc); if (expression == null) { expr.Error_ValueCannotBeConverted(ec, type, expl: false); return null; } return expression; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class BooleanExpressionFalse : Unary { public BooleanExpressionFalse(Expression expr) : base(Operator.LogicalNot, expr, expr.Location) { } protected override Expression ResolveOperator(ResolveContext ec, Expression expr) { return Expression.GetOperatorFalse(ec, expr, loc) ?? base.ResolveOperator(ec, expr); } } internal class Conditional : Expression { private Expression expr; private Expression true_expr; private Expression false_expr; public Expression Expr => expr; public Expression TrueExpr => true_expr; public Expression FalseExpr => false_expr; public Conditional(Expression expr, Expression true_expr, Expression false_expr, Location loc) { this.expr = expr; this.true_expr = true_expr; this.false_expr = false_expr; base.loc = loc; } public override bool ContainsEmitWithAwait() { return Expr.ContainsEmitWithAwait() || true_expr.ContainsEmitWithAwait() || false_expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(3); arguments.Add(new Argument(expr.CreateExpressionTree(ec))); arguments.Add(new Argument(true_expr.CreateExpressionTree(ec))); arguments.Add(new Argument(false_expr.CreateExpressionTree(ec))); return CreateExpressionFactoryCall(ec, "Condition", arguments); } protected override Expression DoResolve(ResolveContext ec) { expr = expr.Resolve(ec); true_expr = true_expr.Resolve(ec); false_expr = false_expr.Resolve(ec); if (true_expr == null || false_expr == null || expr == null) { return null; } eclass = ExprClass.Value; TypeSpec typeSpec = true_expr.Type; TypeSpec typeSpec2 = false_expr.Type; type = typeSpec; if (!TypeSpecComparer.IsEqual(typeSpec, typeSpec2)) { Expression expression = Convert.ImplicitConversion(ec, true_expr, typeSpec2, loc); if (expression != null && typeSpec.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { type = typeSpec2; if (typeSpec2.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { Expression expression2 = Convert.ImplicitConversion(ec, false_expr, typeSpec, loc); if (expression2 != null) { if (expression2.Type.BuiltinType == BuiltinTypeSpec.Type.Int && expression is Constant) { type = typeSpec; expression2 = null; } else if (type.BuiltinType == BuiltinTypeSpec.Type.Int && expression2 is Constant) { expression2 = null; } } if (expression2 != null && typeSpec2 != InternalType.ErrorType && typeSpec != InternalType.ErrorType) { ec.Report.Error(172, true_expr.Location, "Type of conditional expression cannot be determined as `{0}' and `{1}' convert implicitly to each other", typeSpec.GetSignatureForError(), typeSpec2.GetSignatureForError()); } } true_expr = expression; if (true_expr.Type != type) { true_expr = EmptyCast.Create(true_expr, type); } } else { if ((expression = Convert.ImplicitConversion(ec, false_expr, typeSpec, loc)) == null) { if (typeSpec2 != InternalType.ErrorType && typeSpec != InternalType.ErrorType) { ec.Report.Error(173, true_expr.Location, "Type of conditional expression cannot be determined because there is no implicit conversion between `{0}' and `{1}'", typeSpec.GetSignatureForError(), typeSpec2.GetSignatureForError()); } return null; } false_expr = expression; } } if (expr is Constant { IsDefaultValue: var isDefaultValue }) { if (!(isDefaultValue ? (true_expr is Constant) : (false_expr is Constant))) { Expression.Warning_UnreachableExpression(ec, isDefaultValue ? true_expr.Location : false_expr.Location); } return ReducedExpression.Create(isDefaultValue ? false_expr : true_expr, this, false_expr is Constant && true_expr is Constant).Resolve(ec); } return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { expr = expr.Resolve(rc); true_expr = true_expr.Resolve(rc); false_expr = false_expr.Resolve(rc); if (true_expr == null || false_expr == null || expr == null) { return null; } if (!(true_expr is ReferenceExpression) || !(false_expr is ReferenceExpression)) { rc.Report.Error(8326, expr.Location, "Both ref conditional operators must be ref values"); return null; } if (!TypeSpecComparer.IsEqual(true_expr.Type, false_expr.Type)) { rc.Report.Error(8327, true_expr.Location, "The ref conditional expression types `{0}' and `{1}' have to match", true_expr.Type.GetSignatureForError(), false_expr.Type.GetSignatureForError()); } eclass = ExprClass.Value; type = true_expr.Type; return this; } public override void Emit(EmitContext ec) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); expr.EmitBranchable(ec, label, on_true: false); true_expr.Emit(ec); if (type.IsInterface && true_expr is EmptyCast && false_expr is EmptyCast) { LocalBuilder temporaryLocal = ec.GetTemporaryLocal(type); ec.Emit(OpCodes.Stloc, temporaryLocal); ec.Emit(OpCodes.Ldloc, temporaryLocal); ec.FreeTemporaryLocal(temporaryLocal, type); } ec.Emit(OpCodes.Br, label2); ec.MarkLabel(label); false_expr.Emit(ec); ec.MarkLabel(label2); } public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignmentOnTrue = fc.DefiniteAssignmentOnTrue; DefiniteAssignmentBitSet definiteAssignmentOnFalse = fc.DefiniteAssignmentOnFalse; fc.BranchDefiniteAssignment(definiteAssignmentOnTrue); true_expr.FlowAnalysis(fc); DefiniteAssignmentBitSet definiteAssignment = fc.DefiniteAssignment; fc.BranchDefiniteAssignment(definiteAssignmentOnFalse); false_expr.FlowAnalysis(fc); fc.DefiniteAssignment &= definiteAssignment; } public override void FlowAnalysisConditional(FlowAnalysisContext fc) { expr.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignmentOnTrue = fc.DefiniteAssignmentOnTrue; DefiniteAssignmentBitSet definiteAssignmentOnFalse = fc.DefiniteAssignmentOnFalse; DefiniteAssignmentBitSet definiteAssignmentBitSet = (fc.DefiniteAssignment = new DefiniteAssignmentBitSet(definiteAssignmentOnTrue)); DefiniteAssignmentBitSet definiteAssignmentOnTrue2 = (fc.DefiniteAssignmentOnFalse = definiteAssignmentBitSet); fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue2; true_expr.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignment = fc.DefiniteAssignment; DefiniteAssignmentBitSet definiteAssignmentOnTrue3 = fc.DefiniteAssignmentOnTrue; DefiniteAssignmentBitSet definiteAssignmentOnFalse2 = fc.DefiniteAssignmentOnFalse; definiteAssignmentBitSet = (fc.DefiniteAssignment = new DefiniteAssignmentBitSet(definiteAssignmentOnFalse)); definiteAssignmentOnTrue2 = (fc.DefiniteAssignmentOnFalse = definiteAssignmentBitSet); fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue2; false_expr.FlowAnalysisConditional(fc); fc.DefiniteAssignment &= definiteAssignment; fc.DefiniteAssignmentOnTrue = definiteAssignmentOnTrue3 & fc.DefiniteAssignmentOnTrue; fc.DefiniteAssignmentOnFalse = definiteAssignmentOnFalse2 & fc.DefiniteAssignmentOnFalse; } protected override void CloneTo(CloneContext clonectx, Expression t) { Conditional conditional = (Conditional)t; conditional.expr = expr.Clone(clonectx); conditional.true_expr = true_expr.Clone(clonectx); conditional.false_expr = false_expr.Clone(clonectx); } } internal abstract class VariableReference : Expression, IAssignMethod, IMemoryLocation, IVariableReference, IFixedExpression { private LocalTemporary temp; public abstract bool IsLockedByStatement { get; set; } public abstract bool IsFixed { get; } public abstract bool IsRef { get; } public abstract string Name { get; } protected abstract ILocalVariable Variable { get; } public abstract VariableInfo VariableInfo { get; } public bool IsHoisted => GetHoistedVariable((AnonymousExpression)null) != null; public abstract HoistedVariable GetHoistedVariable(AnonymousExpression ae); public abstract void SetHasAddressTaken(); public virtual void AddressOf(EmitContext ec, AddressOp mode) { HoistedVariable hoistedVariable = GetHoistedVariable(ec); if (hoistedVariable != null) { hoistedVariable.AddressOf(ec, mode); } else { Variable.EmitAddressOf(ec); } } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { HoistedVariable hoistedVariable = GetHoistedVariable(ec); if (hoistedVariable != null) { return hoistedVariable.CreateExpressionTree(); } Arguments arguments = new Arguments(1); arguments.Add(new Argument(this)); return CreateExpressionFactoryCall(ec, "Constant", arguments); } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (IsLockedByStatement) { rc.Report.Warning(728, 2, loc, "Possibly incorrect assignment to `{0}' which is the argument to a using or lock statement", Name); } return this; } public override void Emit(EmitContext ec) { Emit(ec, leave_copy: false); } public override void EmitSideEffect(EmitContext ec) { } public void EmitLoad(EmitContext ec) { Variable.Emit(ec); } public void Emit(EmitContext ec, bool leave_copy) { HoistedVariable hoistedVariable = GetHoistedVariable(ec); if (hoistedVariable != null) { hoistedVariable.Emit(ec, leave_copy); return; } EmitLoad(ec); if (IsRef) { ec.EmitLoadFromPtr(type); } if (leave_copy) { ec.Emit(OpCodes.Dup); if (IsRef) { temp = new LocalTemporary(base.Type); temp.Store(ec); } } } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool prepare_for_load) { HoistedVariable hoistedVariable = GetHoistedVariable(ec); if (hoistedVariable != null) { hoistedVariable.EmitAssign(ec, source, leave_copy, prepare_for_load); return; } bool flag = IsRef && !(source is ReferenceExpression); if (source is New obj && obj.CanEmitOptimizedLocalTarget(ec)) { if (!obj.Emit(ec, this)) { if (leave_copy) { EmitLoad(ec); if (flag) { ec.EmitLoadFromPtr(type); } } return; } } else { if (flag) { EmitLoad(ec); } source.Emit(ec); } if (leave_copy) { ec.Emit(OpCodes.Dup); if (flag) { temp = new LocalTemporary(base.Type); temp.Store(ec); } } if (flag) { ec.EmitStoreFromPtr(type); } else { Variable.EmitAssign(ec); } if (temp != null) { temp.Emit(ec); temp.Release(ec); } } public override Expression EmitToField(EmitContext ec) { HoistedVariable hoistedVariable = GetHoistedVariable(ec); if (hoistedVariable != null) { return hoistedVariable.EmitToField(ec); } return base.EmitToField(ec); } public HoistedVariable GetHoistedVariable(ResolveContext rc) { return GetHoistedVariable(rc.CurrentAnonymousMethod); } public HoistedVariable GetHoistedVariable(EmitContext ec) { return GetHoistedVariable(ec.CurrentAnonymousMethod); } public override string GetSignatureForError() { return Name; } } internal class LocalVariableReference : VariableReference { public LocalVariable local_info; public override VariableInfo VariableInfo => local_info.VariableInfo; public override bool IsFixed => true; public override bool IsLockedByStatement { get { return local_info.IsLocked; } set { local_info.IsLocked = value; } } public override bool IsRef => local_info.IsByRef; public override string Name => local_info.Name; protected override ILocalVariable Variable => local_info; public LocalVariableReference(LocalVariable li, Location l) { local_info = li; loc = l; } public override HoistedVariable GetHoistedVariable(AnonymousExpression ae) { return local_info.HoistedVariant; } public override void FlowAnalysis(FlowAnalysisContext fc) { VariableInfo variableInfo = VariableInfo; if (variableInfo != null && !fc.IsDefinitelyAssigned(variableInfo)) { fc.Report.Error(165, loc, "Use of unassigned local variable `{0}'", Name); variableInfo.SetAssigned(fc.DefiniteAssignment, generatedAssignment: true); } } public override void SetHasAddressTaken() { local_info.SetHasAddressTaken(); } private void DoResolveBase(ResolveContext ec) { eclass = ExprClass.Variable; type = local_info.Type; if (ec.MustCaptureVariable(local_info)) { if (local_info.AddressTaken) { AnonymousMethodExpression.Error_AddressOfCapturedVar(ec, this, loc); } else if (local_info.IsFixed) { ec.Report.Error(1764, loc, "Cannot use fixed variable `{0}' inside an anonymous method, lambda expression or query expression", GetSignatureForError()); } else if ((local_info.IsByRef || local_info.Type.IsByRefLike) && !(ec.CurrentAnonymousMethod is StateMachineInitializer)) { ec.Report.Error(8175, loc, "Cannot use by-reference variable `{0}' inside an anonymous method, lambda expression, or query expression", GetSignatureForError()); } if (ec.IsVariableCapturingRequired) { AnonymousMethodStorey anonymousMethodStorey = local_info.Block.Explicit.CreateAnonymousMethodStorey(ec); anonymousMethodStorey.CaptureLocalVariable(ec, local_info); } } } protected override Expression DoResolve(ResolveContext ec) { local_info.SetIsUsed(); DoResolveBase(ec); if (local_info.Type == InternalType.VarOutType) { ec.Report.Error(8048, loc, "Cannot use uninitialized variable `{0}'", GetSignatureForError()); type = InternalType.ErrorType; } return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression rhs) { if (rhs == EmptyExpression.OutAccess || rhs.eclass == ExprClass.PropertyAccess || rhs.eclass == ExprClass.IndexerAccess) { local_info.SetIsUsed(); } if (local_info.IsReadonly && !ec.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.UsingInitializerScope) && !local_info.IsByRef && rhs != EmptyExpression.LValueMemberAccess) { int code; string format; if (rhs == EmptyExpression.OutAccess) { code = 1657; format = "Cannot pass `{0}' as a ref or out argument because it is a `{1}'"; } else if (rhs == EmptyExpression.LValueMemberOutAccess) { code = 1655; format = "Cannot pass members of `{0}' as ref or out arguments because it is a `{1}'"; } else if (rhs == EmptyExpression.UnaryAddress) { code = 459; format = "Cannot take the address of {1} `{0}'"; } else { code = 1656; format = "Cannot assign to `{0}' because it is a `{1}'"; } ec.Report.Error(code, loc, format, Name, local_info.GetReadOnlyContext()); } if (eclass == ExprClass.Unresolved) { DoResolveBase(ec); } return base.DoResolveLValue(ec, rhs); } public override int GetHashCode() { return local_info.GetHashCode(); } public override bool Equals(object obj) { if (!(obj is LocalVariableReference localVariableReference)) { return false; } return local_info == localVariableReference.local_info; } public override string ToString() { return $"{GetType()} ({Name}:{loc})"; } protected override void CloneTo(CloneContext clonectx, Expression t) { } } internal class ParameterReference : VariableReference { protected ParametersBlock.ParameterInfo pi; public override bool IsLockedByStatement { get { return pi.IsLocked; } set { pi.IsLocked = value; } } public override bool IsRef => (pi.Parameter.ModFlags & Parameter.Modifier.RefOutMask) != 0; private bool HasOutModifier => (pi.Parameter.ModFlags & Parameter.Modifier.OUT) != 0; public override bool IsFixed => !IsRef; public override string Name => Parameter.Name; public Parameter Parameter => pi.Parameter; public override VariableInfo VariableInfo => pi.VariableInfo; protected override ILocalVariable Variable => Parameter; public ParameterReference(ParametersBlock.ParameterInfo pi, Location loc) { this.pi = pi; base.loc = loc; } public override HoistedVariable GetHoistedVariable(AnonymousExpression ae) { return pi.Parameter.HoistedVariant; } public override void AddressOf(EmitContext ec, AddressOp mode) { if (IsRef) { EmitLoad(ec); } else { base.AddressOf(ec, mode); } } public override void SetHasAddressTaken() { Parameter.HasAddressTaken = true; } private bool DoResolveBase(ResolveContext ec) { if (eclass != ExprClass.Unresolved) { return true; } type = pi.ParameterType; eclass = ExprClass.Variable; if (ec.MustCaptureVariable(pi)) { if (Parameter.HasAddressTaken) { AnonymousMethodExpression.Error_AddressOfCapturedVar(ec, this, loc); } if (IsRef) { ec.Report.Error(1628, loc, "Parameter `{0}' cannot be used inside `{1}' when using `ref' or `out' modifier", Name, ec.CurrentAnonymousMethod.ContainerType); } if (ec.IsVariableCapturingRequired && !pi.Block.ParametersBlock.IsExpressionTree) { AnonymousMethodStorey anonymousMethodStorey = pi.Block.Explicit.CreateAnonymousMethodStorey(ec); anonymousMethodStorey.CaptureParameter(ec, pi, this); } } return true; } public override int GetHashCode() { return Name.GetHashCode(); } public override bool Equals(object obj) { if (!(obj is ParameterReference parameterReference)) { return false; } return Name == parameterReference.Name; } protected override void CloneTo(CloneContext clonectx, Expression target) { } public override Expression CreateExpressionTree(ResolveContext ec) { HoistedVariable hoistedVariable = GetHoistedVariable(ec); if (hoistedVariable != null) { return hoistedVariable.CreateExpressionTree(); } return Parameter.ExpressionTreeVariableReference(); } protected override Expression DoResolve(ResolveContext ec) { if (!DoResolveBase(ec)) { return null; } return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { if (!DoResolveBase(ec)) { return null; } if (Parameter.HoistedVariant != null) { Parameter.HoistedVariant.IsAssigned = true; } return base.DoResolveLValue(ec, right_side); } public override void FlowAnalysis(FlowAnalysisContext fc) { VariableInfo variableInfo = VariableInfo; if (variableInfo != null && !fc.IsDefinitelyAssigned(variableInfo)) { fc.Report.Error(269, loc, "Use of unassigned out parameter `{0}'", Name); fc.SetVariableAssigned(variableInfo); } } } internal class Invocation : ExpressionStatement { public class Predefined : Invocation { public Predefined(MethodGroupExpr expr, Arguments arguments) : base(expr, arguments) { mg = expr; } protected override MethodGroupExpr DoResolveOverload(ResolveContext rc) { mg.BestCandidate.CheckObsoleteness(rc, loc); return mg; } } protected Arguments arguments; protected Expression expr; protected MethodGroupExpr mg; private bool conditional_access_receiver; private bool statement_resolve; public Arguments Arguments => arguments; public Expression Exp => expr; public MethodGroupExpr MethodGroup => mg; public override Location StartLocation => expr.StartLocation; public Invocation(Expression expr, Arguments arguments) { this.expr = expr; this.arguments = arguments; if (expr != null) { loc = expr.Location; } } public override MethodGroupExpr CanReduceLambda(AnonymousMethodBody body) { if (MethodGroup == null) { return null; } MethodSpec bestCandidate = MethodGroup.BestCandidate; if (bestCandidate == null || (!bestCandidate.IsStatic && !(Exp is This))) { return null; } int num = ((arguments != null) ? arguments.Count : 0); if (num != body.Parameters.Count) { return null; } IParameterData[] fixedParameters = body.Block.Parameters.FixedParameters; for (int i = 0; i < num; i++) { if (!(arguments[i].Expr is ParameterReference parameterReference)) { return null; } if (fixedParameters[i] != parameterReference.Parameter) { return null; } if ((fixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (parameterReference.Parameter.ModFlags & Parameter.Modifier.RefOutMask)) { return null; } } if (MethodGroup is ExtensionMethodGroupExpr) { MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(bestCandidate, bestCandidate.DeclaringType, MethodGroup.Location); if (bestCandidate.IsGeneric) { TypeExpression[] array = new TypeExpression[bestCandidate.Arity]; for (int j = 0; j < array.Length; j++) { array[j] = new TypeExpression(bestCandidate.TypeArguments[j], MethodGroup.Location); } FullNamedExpression[] types = array; methodGroupExpr.SetTypeArguments(null, new TypeArguments(types)); } return methodGroupExpr; } return MethodGroup; } protected override void CloneTo(CloneContext clonectx, Expression t) { Invocation invocation = (Invocation)t; if (arguments != null) { invocation.arguments = arguments.Clone(clonectx); } invocation.expr = expr.Clone(clonectx); } public override bool ContainsEmitWithAwait() { if (arguments != null && arguments.ContainsEmitWithAwait()) { return true; } return mg.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { Expression expression = (mg.IsInstance ? mg.InstanceExpression.CreateExpressionTree(ec) : new NullLiteral(loc)); Arguments args = Arguments.CreateForExpressionTree(ec, arguments, expression, mg.CreateExpressionTree(ec)); return CreateExpressionFactoryCall(ec, "Call", args); } private void ResolveConditionalAccessReceiver(ResolveContext rc) { if (!rc.HasSet(ResolveContext.Options.DontSetConditionalAccessReceiver) && expr.HasConditionalAccess()) { conditional_access_receiver = true; } } public override ExpressionStatement ResolveStatement(BlockContext bc) { statement_resolve = true; ExpressionStatement result = base.ResolveStatement(bc); statement_resolve = false; return result; } protected override Expression DoResolve(ResolveContext rc) { ResolveConditionalAccessReceiver(rc); return DoResolveInvocation(rc, null); } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (expr is SimpleName { Name: "var", Arity: 0 }) { Arguments obj = arguments; if (obj != null && obj.Count > 1) { List list = new List(arguments.Count); foreach (Argument argument in arguments) { if (!(argument.Expr is SimpleName { Arity: 0 } simpleName2)) { rc.Report.Error(8199, loc, "The syntax `var (...)' as an lvalue is reserved"); return ErrorExpression.Instance; } LocalVariable localVariable = new LocalVariable(rc.CurrentBlock, simpleName2.Name, argument.Expr.Location); rc.CurrentBlock.AddLocalName(localVariable); list.Add(new BlockVariable(new VarExpr(localVariable.Location), localVariable)); } TupleDeconstruct tupleDeconstruct = new TupleDeconstruct(list, right_side, loc); return tupleDeconstruct.Resolve(rc); } } if (right_side != null) { if (eclass != ExprClass.Unresolved) { return this; } Expression expression = DoResolveInvocation(rc, right_side); if (expression == null) { return null; } return expression; } return base.DoResolveLValue(rc, right_side); } private Expression DoResolveInvocation(ResolveContext ec, Expression rhs) { ATypeNameExpression aTypeNameExpression = expr as ATypeNameExpression; ResolveContext.FlagsHandle flagsHandle = default(ResolveContext.FlagsHandle); if (conditional_access_receiver) { flagsHandle = ec.Set(ResolveContext.Options.DontSetConditionalAccessReceiver); } Expression expression; if (aTypeNameExpression != null) { expression = aTypeNameExpression.LookupNameExpression(ec, MemberLookupRestrictions.InvocableOnly | MemberLookupRestrictions.ReadAccess); if (expression != null) { if (expression is NameOf nameOf) { return nameOf.ResolveOverload(ec, arguments); } expression = expression.Resolve(ec); } } else { expression = expr.Resolve(ec); } if (conditional_access_receiver) { flagsHandle.Dispose(); } if (expression == null) { return null; } bool dynamic = false; if (arguments != null) { using (ec.With(ResolveContext.Options.DontSetConditionalAccessReceiver, enable: false)) { arguments.Resolve(ec, out dynamic); } } TypeSpec typeSpec = expression.Type; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return DoResolveDynamic(ec, expression); } mg = expression as MethodGroupExpr; Expression expression2 = null; if (mg == null) { if (typeSpec == null || !typeSpec.IsDelegate) { if (expression is RuntimeValueExpression) { ec.Report.Error(10000, loc, "Cannot invoke a non-delegate type `{0}'", expression.Type.GetSignatureForError()); return null; } if (!(expression is MemberExpr)) { expression.Error_UnexpectedKind(ec, ResolveFlags.MethodGroup, loc); return null; } ec.Report.Error(1955, loc, "The member `{0}' cannot be used as method or delegate", expression.GetSignatureForError()); return null; } expression2 = new DelegateInvocation(expression, arguments, conditional_access_receiver, loc); expression2 = expression2.Resolve(ec); if (expression2 == null || !dynamic) { return expression2; } } if (expression2 == null) { mg = DoResolveOverload(ec); if (mg == null) { return null; } } if (dynamic) { return DoResolveDynamic(ec, expression); } MethodSpec bestCandidate = mg.BestCandidate; type = mg.BestCandidateReturnType; if (conditional_access_receiver && !statement_resolve) { type = LiftMemberType(ec, type); } if (arguments == null && bestCandidate.DeclaringType.BuiltinType == BuiltinTypeSpec.Type.Object && bestCandidate.Name == Destructor.MetadataName) { if (mg.IsBase) { ec.Report.Error(250, loc, "Do not directly call your base class Finalize method. It is called automatically from your destructor"); } else { ec.Report.Error(245, loc, "Destructors and object.Finalize cannot be called directly. Consider calling IDisposable.Dispose if available"); } return null; } IsSpecialMethodInvocation(ec, bestCandidate, loc); eclass = ExprClass.Value; if (type.Kind == MemberKind.ByRef && rhs != EmptyExpression.OutAccess) { return ByRefDereference.Create(this).Resolve(ec); } return this; } protected virtual Expression DoResolveDynamic(ResolveContext ec, Expression memberExpr) { Arguments arguments; if (memberExpr is DynamicMemberBinder dynamicMemberBinder) { arguments = dynamicMemberBinder.Arguments; if (this.arguments != null) { arguments.AddRange(this.arguments); } } else if (mg == null) { arguments = ((this.arguments != null) ? this.arguments : new Arguments(1)); arguments.Insert(0, new Argument(memberExpr)); expr = null; } else { if (mg.IsBase) { ec.Report.Error(1971, loc, "The base call to method `{0}' cannot be dynamically dispatched. Consider casting the dynamic arguments or eliminating the base access", mg.Name); return null; } arguments = ((this.arguments != null) ? this.arguments : new Arguments(1)); if (expr is MemberAccess) { Expression instanceExpression = mg.InstanceExpression; if (instanceExpression is TypeExpr typeExpr) { arguments.Insert(0, new Argument(new TypeOf(typeExpr.Type, loc).Resolve(ec), Argument.AType.DynamicTypeName)); } else if (instanceExpression != null) { Argument.AType aType = ((instanceExpression is IMemoryLocation && TypeSpec.IsValueType(instanceExpression.Type)) ? Argument.AType.Ref : Argument.AType.None); arguments.Insert(0, new Argument(instanceExpression.Resolve(ec), aType)); } } else if (ec.IsStatic || ec.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer)) { arguments.Insert(0, new Argument(new TypeOf(ec.CurrentType, loc).Resolve(ec), Argument.AType.DynamicTypeName)); } else { arguments.Insert(0, new Argument(new This(loc).Resolve(ec))); } } return new DynamicInvocation(expr as ATypeNameExpression, arguments, conditional_access_receiver, loc).Resolve(ec); } protected virtual MethodGroupExpr DoResolveOverload(ResolveContext ec) { return mg.OverloadResolve(ec, ref arguments, null, OverloadResolver.Restrictions.None); } public override void FlowAnalysis(FlowAnalysisContext fc) { if (!mg.IsConditionallyExcluded) { DefiniteAssignmentBitSet definiteAssignment = (conditional_access_receiver ? fc.BranchDefiniteAssignment() : null); mg.FlowAnalysis(fc); if (arguments != null) { arguments.FlowAnalysis(fc); } if (conditional_access_receiver) { fc.DefiniteAssignment = definiteAssignment; } } } public override string GetSignatureForError() { return mg.GetSignatureForError(); } public override bool HasConditionalAccess() { return expr.HasConditionalAccess(); } public static bool IsMemberInvocable(MemberSpec member) { switch (member.Kind) { case MemberKind.Event: return true; case MemberKind.Field: case MemberKind.Property: { IInterfaceMemberSpec interfaceMemberSpec = member as IInterfaceMemberSpec; return interfaceMemberSpec.MemberType.IsDelegate || interfaceMemberSpec.MemberType.BuiltinType == BuiltinTypeSpec.Type.Dynamic; } default: return false; } } public static bool IsSpecialMethodInvocation(ResolveContext ec, MethodSpec method, Location loc) { if (!method.IsReservedMethod) { return false; } if (ec.HasSet(ResolveContext.Options.InvokeSpecialName) || ec.CurrentMemberDefinition.IsCompilerGenerated) { return false; } ec.Report.SymbolRelatedToPreviousError(method); ec.Report.Error(571, loc, "`{0}': cannot explicitly call operator or accessor", method.GetSignatureForError()); return true; } public override void Emit(EmitContext ec) { if (!mg.IsConditionallyExcluded) { if (conditional_access_receiver) { mg.EmitCall(ec, arguments, type, statement: false); } else { mg.EmitCall(ec, arguments, statement: false); } } } public override void EmitPrepare(EmitContext ec) { mg.EmitPrepare(ec); arguments?.EmitPrepare(ec); } public override void EmitStatement(EmitContext ec) { if (!mg.IsConditionallyExcluded) { if (conditional_access_receiver) { mg.EmitCall(ec, arguments, type, statement: true); } else { mg.EmitCall(ec, arguments, statement: true); } } } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return MakeExpression(ctx, mg.InstanceExpression, mg.BestCandidate, arguments); } public static System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx, Expression instance, MethodSpec mi, Arguments args) { System.Linq.Expressions.Expression instance2 = instance?.MakeExpression(ctx); return System.Linq.Expressions.Expression.Call(instance2, (MethodInfo)mi.GetMetaInfo(), Arguments.MakeExpression(args, ctx)); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class New : ExpressionStatement, IMemoryLocation { protected Arguments arguments; protected Expression RequestedType; protected MethodSpec method; public Arguments Arguments => arguments; public bool IsGeneratedStructConstructor => arguments == null && method == null && type.IsStruct && (object)GetType() == typeof(New); public Expression TypeExpression => RequestedType; public New(Expression requested_type, Arguments arguments, Location l) { RequestedType = requested_type; this.arguments = arguments; loc = l; } public static Constant Constantify(TypeSpec t, Location loc) { switch (t.BuiltinType) { case BuiltinTypeSpec.Type.Int: return new IntConstant(t, 0, loc); case BuiltinTypeSpec.Type.UInt: return new UIntConstant(t, 0u, loc); case BuiltinTypeSpec.Type.Long: return new LongConstant(t, 0L, loc); case BuiltinTypeSpec.Type.ULong: return new ULongConstant(t, 0uL, loc); case BuiltinTypeSpec.Type.Float: return new FloatConstant(t, 0.0, loc); case BuiltinTypeSpec.Type.Double: return new DoubleConstant(t, 0.0, loc); case BuiltinTypeSpec.Type.Short: return new ShortConstant(t, 0, loc); case BuiltinTypeSpec.Type.UShort: return new UShortConstant(t, 0, loc); case BuiltinTypeSpec.Type.SByte: return new SByteConstant(t, 0, loc); case BuiltinTypeSpec.Type.Byte: return new ByteConstant(t, 0, loc); case BuiltinTypeSpec.Type.Char: return new CharConstant(t, '\0', loc); case BuiltinTypeSpec.Type.FirstPrimitive: return new BoolConstant(t, val: false, loc); case BuiltinTypeSpec.Type.Decimal: return new DecimalConstant(t, 0m, loc); default: if (t.IsEnum) { return new EnumConstant(Constantify(EnumSpec.GetUnderlyingType(t), loc), t); } if (t.IsNullableType) { return LiftedNull.Create(t, loc); } return null; } } public override bool ContainsEmitWithAwait() { return arguments != null && arguments.ContainsEmitWithAwait(); } public Expression CheckComImport(ResolveContext ec) { if (!type.IsInterface) { return null; } TypeSpec attributeCoClass = type.MemberDefinition.GetAttributeCoClass(); if (attributeCoClass == null) { return null; } New expr = new New(new TypeExpression(attributeCoClass, loc), arguments, loc); Cast cast = new Cast(new TypeExpression(type, loc), expr, loc); return cast.Resolve(ec); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments; if (method == null) { arguments = new Arguments(1); arguments.Add(new Argument(new TypeOf(type, loc))); } else { arguments = Arguments.CreateForExpressionTree(ec, this.arguments, new TypeOfMethod(method, loc)); } return CreateExpressionFactoryCall(ec, "New", arguments); } protected override Expression DoResolve(ResolveContext ec) { if (RequestedType is TupleTypeExpr) { ec.Report.Error(8181, loc, "Tuple type cannot be used in an object creation expression. Use a tuple literal expression instead."); } type = RequestedType.ResolveAsType(ec); if (type == null) { return null; } eclass = ExprClass.Value; if (type.IsPointer) { ec.Report.Error(1919, loc, "Unsafe type `{0}' cannot be used in an object creation expression", type.GetSignatureForError()); return null; } if (arguments == null) { Constant constant = Constantify(type, RequestedType.Location); if (constant != null) { return ReducedExpression.Create(constant, this); } } if (type.IsDelegate) { return new NewDelegate(type, arguments, loc).Resolve(ec); } if (type is TypeParameterSpec typeParameterSpec) { if ((typeParameterSpec.SpecialConstraint & (SpecialConstraint.Constructor | SpecialConstraint.Struct)) == 0 && !TypeSpec.IsValueType(typeParameterSpec)) { ec.Report.Error(304, loc, "Cannot create an instance of the variable type `{0}' because it does not have the new() constraint", type.GetSignatureForError()); } if (arguments != null && arguments.Count != 0) { ec.Report.Error(417, loc, "`{0}': cannot provide arguments when creating an instance of a variable type", type.GetSignatureForError()); } return this; } if (type.IsStatic) { ec.Report.SymbolRelatedToPreviousError(type); ec.Report.Error(712, loc, "Cannot create an instance of the static class `{0}'", type.GetSignatureForError()); return null; } if (type.IsInterface || type.IsAbstract) { if (!TypeManager.IsGenericType(type)) { RequestedType = CheckComImport(ec); if (RequestedType != null) { return RequestedType; } } ec.Report.SymbolRelatedToPreviousError(type); ec.Report.Error(144, loc, "Cannot create an instance of the abstract class or interface `{0}'", type.GetSignatureForError()); return null; } bool dynamic; if (arguments != null) { arguments.Resolve(ec, out dynamic); } else { dynamic = false; } method = Expression.ConstructorLookup(ec, type, ref arguments, loc); if (dynamic) { arguments.Insert(0, new Argument(new TypeOf(type, loc).Resolve(ec), Argument.AType.DynamicTypeName)); return new DynamicConstructorBinder(type, arguments, loc).Resolve(ec); } return this; } private void DoEmitTypeParameter(EmitContext ec) { MethodSpec methodSpec = ec.Module.PredefinedMembers.ActivatorCreateInstance.Resolve(loc); if (methodSpec != null) { MethodSpec methodSpec2 = methodSpec.MakeGenericMethod(ec.MemberContext, type); ec.Emit(OpCodes.Call, methodSpec2); } } public virtual bool Emit(EmitContext ec, IMemoryLocation target) { bool isStructOrEnum = type.IsStructOrEnum; VariableReference variableReference = target as VariableReference; bool flag = ec.HasSet(BuilderContext.Options.AsyncBody) && (arguments?.ContainsEmitWithAwait() ?? false); if (target != null && isStructOrEnum && (variableReference != null || method == null)) { if (flag) { arguments = arguments.Emit(ec, dup_args: false, prepareAwait: true); flag = false; } target.AddressOf(ec, AddressOp.Store); } else if (variableReference != null && variableReference.IsRef) { variableReference.EmitLoad(ec); } if (arguments != null) { if (flag) { arguments = arguments.Emit(ec, dup_args: false, prepareAwait: true); } arguments.Emit(ec); } if (isStructOrEnum) { if (method == null) { ec.Emit(OpCodes.Initobj, type); return false; } if (variableReference != null) { ec.MarkCallEntry(loc); ec.Emit(OpCodes.Call, method); return false; } } if (type is TypeParameterSpec) { DoEmitTypeParameter(ec); return true; } ec.MarkCallEntry(loc); ec.Emit(OpCodes.Newobj, method); return true; } public override void Emit(EmitContext ec) { LocalTemporary localTemporary = null; if (method == null && type.IsStructOrEnum) { localTemporary = new LocalTemporary(type); } if (!Emit(ec, localTemporary)) { localTemporary.Emit(ec); } } public override void EmitStatement(EmitContext ec) { LocalTemporary target = null; if (method == null && TypeSpec.IsValueType(type)) { target = new LocalTemporary(type); } if (Emit(ec, target)) { ec.Emit(OpCodes.Pop); } } public virtual bool CanEmitOptimizedLocalTarget(EmitContext ec) { return true; } public override void FlowAnalysis(FlowAnalysisContext fc) { if (arguments != null) { arguments.FlowAnalysis(fc); } } public void AddressOf(EmitContext ec, AddressOp mode) { EmitAddressOf(ec, mode); } protected virtual IMemoryLocation EmitAddressOf(EmitContext ec, AddressOp mode) { LocalTemporary localTemporary = new LocalTemporary(type); if (type is TypeParameterSpec) { DoEmitTypeParameter(ec); localTemporary.Store(ec); localTemporary.AddressOf(ec, mode); return localTemporary; } localTemporary.AddressOf(ec, AddressOp.Store); if (method == null) { ec.Emit(OpCodes.Initobj, type); } else { if (arguments != null) { arguments.Emit(ec); } ec.Emit(OpCodes.Call, method); } localTemporary.AddressOf(ec, mode); return localTemporary; } protected override void CloneTo(CloneContext clonectx, Expression t) { New obj = (New)t; obj.RequestedType = RequestedType.Clone(clonectx); if (arguments != null) { obj.arguments = arguments.Clone(clonectx); } } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.New((ConstructorInfo)method.GetMetaInfo(), Arguments.MakeExpression(arguments, ctx)); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ArrayInitializer : Expression { private List elements; private BlockVariable variable; public int Count => elements.Count; public List Elements => elements; public Expression this[int index] => elements[index]; public BlockVariable VariableDeclaration { get { return variable; } set { variable = value; } } public ArrayInitializer(List init, Location loc) { elements = init; base.loc = loc; } public ArrayInitializer(int count, Location loc) : this(new List(count), loc) { } public ArrayInitializer(Location loc) : this(4, loc) { } public void Add(Expression expr) { elements.Add(expr); } public override bool ContainsEmitWithAwait() { throw new NotSupportedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override void CloneTo(CloneContext clonectx, Expression t) { ArrayInitializer arrayInitializer = (ArrayInitializer)t; arrayInitializer.elements = new List(elements.Count); foreach (Expression element in elements) { arrayInitializer.elements.Add(element.Clone(clonectx)); } } protected override Expression DoResolve(ResolveContext rc) { TypeExpression requested_base_type; if (rc.CurrentMemberDefinition is FieldBase fieldBase && rc.CurrentAnonymousMethod == null) { requested_base_type = new TypeExpression(fieldBase.MemberType, fieldBase.Location); } else { if (variable == null) { throw new NotImplementedException("Unexpected array initializer context"); } if (variable.TypeExpression is VarExpr) { rc.Report.Error(820, loc, "An implicitly typed local variable declarator cannot use an array initializer"); return EmptyExpression.Null; } requested_base_type = new TypeExpression(variable.Variable.Type, variable.Variable.Location); } return new ArrayCreation(requested_base_type, this).Resolve(rc); } public override void Emit(EmitContext ec) { throw new InternalErrorException("Missing Resolve call"); } public override void FlowAnalysis(FlowAnalysisContext fc) { throw new InternalErrorException("Missing Resolve call"); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ArrayCreation : Expression { private FullNamedExpression requested_base_type; private ArrayInitializer initializers; protected List arguments; protected TypeSpec array_element_type; private int num_arguments; protected int dimensions; protected readonly ComposedTypeSpecifier rank; private Expression first_emit; private LocalTemporary first_emit_temp; protected List array_data; private Dictionary bounds; public bool NoEmptyInterpolation { get; set; } public ComposedTypeSpecifier Rank => rank; public FullNamedExpression TypeExpression => requested_base_type; public ArrayInitializer Initializers => initializers; public ArrayCreation(FullNamedExpression requested_base_type, List exprs, ComposedTypeSpecifier rank, ArrayInitializer initializers, Location l) : this(requested_base_type, rank, initializers, l) { arguments = new List(exprs); num_arguments = arguments.Count; } public ArrayCreation(FullNamedExpression requested_base_type, ComposedTypeSpecifier rank, ArrayInitializer initializers, Location loc) { this.requested_base_type = requested_base_type; this.rank = rank; this.initializers = initializers; base.loc = loc; if (rank != null) { num_arguments = rank.Dimension; } } public ArrayCreation(FullNamedExpression requested_base_type, ArrayInitializer initializers, Location loc) : this(requested_base_type, ComposedTypeSpecifier.SingleDimension, initializers, loc) { } public ArrayCreation(FullNamedExpression requested_base_type, ArrayInitializer initializers) : this(requested_base_type, null, initializers, initializers.Location) { } private bool CheckIndices(ResolveContext ec, ArrayInitializer probe, int idx, bool specified_dims, int child_bounds) { if (initializers != null && bounds == null) { array_data = new List(probe.Count); bounds = new Dictionary(); } if (specified_dims) { Expression expression = arguments[idx]; expression = expression.Resolve(ec); if (expression == null) { return false; } expression = ConvertExpressionToArrayIndex(ec, expression); if (expression == null) { return false; } arguments[idx] = expression; if (initializers != null) { Constant constant = expression as Constant; if (constant == null && expression is ArrayIndexCast) { constant = ((ArrayIndexCast)expression).Child as Constant; } if (constant == null) { ec.Report.Error(150, expression.Location, "A constant value is expected"); return false; } int num; try { num = System.Convert.ToInt32(constant.GetValue()); } catch { ec.Report.Error(150, expression.Location, "A constant value is expected"); return false; } if (num != probe.Count) { ec.Report.Error(847, loc, "An array initializer of length `{0}' was expected", num.ToString()); return false; } bounds[idx] = num; } } if (initializers == null) { return true; } for (int i = 0; i < probe.Count; i++) { Expression expression2 = probe[i]; if (expression2 is ArrayInitializer) { ArrayInitializer arrayInitializer = expression2 as ArrayInitializer; if (idx + 1 >= dimensions) { ec.Report.Error(623, loc, "Array initializers can only be used in a variable or field initializer. Try using a new expression instead"); return false; } if (!bounds.ContainsKey(idx + 1)) { bounds[idx + 1] = arrayInitializer.Count; } if (bounds[idx + 1] != arrayInitializer.Count) { ec.Report.Error(847, arrayInitializer.Location, "An array initializer of length `{0}' was expected", bounds[idx + 1].ToString()); return false; } if (!CheckIndices(ec, arrayInitializer, idx + 1, specified_dims, child_bounds - 1)) { return false; } } else if (child_bounds > 1) { ec.Report.Error(846, expression2.Location, "A nested array initializer was expected"); } else { Expression expression3 = ResolveArrayElement(ec, expression2); if (expression3 != null) { array_data.Add(expression3); } } } return true; } public override bool ContainsEmitWithAwait() { foreach (Expression argument in arguments) { if (argument.ContainsEmitWithAwait()) { return true; } } return InitializersContainAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments; if (array_data == null) { arguments = new Arguments(this.arguments.Count + 1); arguments.Add(new Argument(new TypeOf(array_element_type, loc))); foreach (Expression argument in this.arguments) { arguments.Add(new Argument(argument.CreateExpressionTree(ec))); } return CreateExpressionFactoryCall(ec, "NewArrayBounds", arguments); } if (dimensions > 1) { ec.Report.Error(838, loc, "An expression tree cannot contain a multidimensional array initializer"); return null; } arguments = new Arguments((array_data == null) ? 1 : (array_data.Count + 1)); arguments.Add(new Argument(new TypeOf(array_element_type, loc))); if (array_data != null) { for (int i = 0; i < array_data.Count; i++) { Expression expression = array_data[i]; arguments.Add(new Argument(expression.CreateExpressionTree(ec))); } } return CreateExpressionFactoryCall(ec, "NewArrayInit", arguments); } private void UpdateIndices(ResolveContext rc) { int num = 0; ArrayInitializer arrayInitializer = initializers; while (arrayInitializer != null) { Expression item = new IntConstant(rc.BuiltinTypes, arrayInitializer.Count, Location.Null); arguments.Add(item); bounds[num++] = arrayInitializer.Count; if (arrayInitializer.Count > 0 && arrayInitializer[0] is ArrayInitializer) { arrayInitializer = (ArrayInitializer)arrayInitializer[0]; } else if (dimensions <= num) { break; } } } protected override void Error_NegativeArrayIndex(ResolveContext ec, Location loc) { ec.Report.Error(248, loc, "Cannot create an array with a negative size"); } public override void FlowAnalysis(FlowAnalysisContext fc) { foreach (Expression argument in arguments) { argument.FlowAnalysis(fc); } if (array_data == null) { return; } foreach (Expression array_datum in array_data) { array_datum.FlowAnalysis(fc); } } private bool InitializersContainAwait() { if (array_data == null) { return false; } foreach (Expression array_datum in array_data) { if (array_datum.ContainsEmitWithAwait()) { return true; } } return false; } protected virtual Expression ResolveArrayElement(ResolveContext ec, Expression element) { element = element.Resolve(ec); if (element == null) { return null; } if (element is CompoundAssign.TargetExpression targetExpression) { for (int i = 1; i < initializers.Count; i++) { if (initializers[i].ContainsEmitWithAwait()) { targetExpression.RequiresEmitWithAwait = true; break; } } if (!targetExpression.RequiresEmitWithAwait) { if (first_emit != null) { throw new InternalErrorException("Can only handle one mutator at a time"); } first_emit = element; element = (first_emit_temp = new LocalTemporary(element.Type)); } } return Convert.ImplicitConversionRequired(ec, element, array_element_type, loc); } protected bool ResolveInitializers(ResolveContext ec) { if (arguments != null) { bool flag = true; for (int i = 0; i < arguments.Count; i++) { flag &= CheckIndices(ec, initializers, i, specified_dims: true, dimensions); if (initializers != null) { break; } } return flag; } arguments = new List(); if (!CheckIndices(ec, initializers, 0, specified_dims: false, dimensions)) { return false; } UpdateIndices(ec); return true; } private bool ResolveArrayType(ResolveContext ec) { FullNamedExpression fullNamedExpression = ((num_arguments <= 0) ? requested_base_type : new ComposedCast(requested_base_type, rank)); type = fullNamedExpression.ResolveAsType(ec); if (fullNamedExpression == null) { return false; } if (!(type is ArrayContainer arrayContainer)) { ec.Report.Error(622, loc, "Can only use array initializer expressions to assign to array types. Try using a new expression instead"); return false; } array_element_type = arrayContainer.Element; dimensions = arrayContainer.Rank; return true; } protected override Expression DoResolve(ResolveContext ec) { if (type != null) { return this; } if (!ResolveArrayType(ec)) { return null; } if (!ResolveInitializers(ec)) { return null; } eclass = ExprClass.Value; return this; } private byte[] MakeByteBlob() { int count = array_data.Count; TypeSpec underlyingType = array_element_type; if (underlyingType.IsEnum) { underlyingType = EnumSpec.GetUnderlyingType(underlyingType); } int size = BuiltinTypeSpec.GetSize(underlyingType); if (size == 0) { throw new Exception("unrecognized type in MakeByteBlob: " + underlyingType); } byte[] array = new byte[(count * size + 3) & -4]; int num = 0; for (int i = 0; i < count; i++) { if (!(array_data[i] is Constant constant)) { num += size; continue; } object value = constant.GetValue(); switch (underlyingType.BuiltinType) { case BuiltinTypeSpec.Type.Long: { long num7 = (long)value; for (int m = 0; m < size; m++) { array[num + m] = (byte)(num7 & 0xFF); num7 >>= 8; } break; } case BuiltinTypeSpec.Type.ULong: { ulong num6 = (ulong)value; for (int l = 0; l < size; l++) { array[num + l] = (byte)(num6 & 0xFF); num6 >>= 8; } break; } case BuiltinTypeSpec.Type.Float: { int num8 = SingleConverter.SingleToInt32Bits((float)value); array[num] = (byte)(num8 & 0xFF); array[num + 1] = (byte)((num8 >> 8) & 0xFF); array[num + 2] = (byte)((num8 >> 16) & 0xFF); array[num + 3] = (byte)(num8 >> 24); break; } case BuiltinTypeSpec.Type.Double: { byte[] bytes = BitConverter.GetBytes((double)value); for (int k = 0; k < size; k++) { array[num + k] = bytes[k]; } if (!BitConverter.IsLittleEndian) { Array.Reverse((Array)array, num, 8); } break; } case BuiltinTypeSpec.Type.Char: { int num3 = (char)value; array[num] = (byte)(num3 & 0xFF); array[num + 1] = (byte)(num3 >> 8); break; } case BuiltinTypeSpec.Type.Short: { int num2 = (short)value; array[num] = (byte)(num2 & 0xFF); array[num + 1] = (byte)(num2 >> 8); break; } case BuiltinTypeSpec.Type.UShort: { int num4 = (ushort)value; array[num] = (byte)(num4 & 0xFF); array[num + 1] = (byte)(num4 >> 8); break; } case BuiltinTypeSpec.Type.Int: { int num10 = (int)value; array[num] = (byte)(num10 & 0xFF); array[num + 1] = (byte)((num10 >> 8) & 0xFF); array[num + 2] = (byte)((num10 >> 16) & 0xFF); array[num + 3] = (byte)(num10 >> 24); break; } case BuiltinTypeSpec.Type.UInt: { uint num9 = (uint)value; array[num] = (byte)(num9 & 0xFF); array[num + 1] = (byte)((num9 >> 8) & 0xFF); array[num + 2] = (byte)((num9 >> 16) & 0xFF); array[num + 3] = (byte)(num9 >> 24); break; } case BuiltinTypeSpec.Type.SByte: array[num] = (byte)(sbyte)value; break; case BuiltinTypeSpec.Type.Byte: array[num] = (byte)value; break; case BuiltinTypeSpec.Type.FirstPrimitive: array[num] = (byte)(((bool)value) ? 1u : 0u); break; case BuiltinTypeSpec.Type.Decimal: { int[] bits = decimal.GetBits((decimal)value); int num5 = num; int[] array2 = new int[4] { bits[3], bits[2], bits[0], bits[1] }; for (int j = 0; j < 4; j++) { array[num5++] = (byte)(array2[j] & 0xFF); array[num5++] = (byte)((array2[j] >> 8) & 0xFF); array[num5++] = (byte)((array2[j] >> 16) & 0xFF); array[num5++] = (byte)(array2[j] >> 24); } break; } default: throw new Exception("Unrecognized type in MakeByteBlob: " + underlyingType); } num += size; } return array; } private void EmitDynamicInitializers(EmitContext ec, bool emitConstants, StackFieldExpr stackArray) { int count = bounds.Count; int[] array = new int[count]; for (int i = 0; i < array_data.Count; i++) { Expression expression = array_data[i]; if (!(expression is Constant constant) || (constant != null && emitConstants && !constant.IsDefaultInitializer(array_element_type))) { TypeSpec typeSpec = expression.Type; if (stackArray != null) { if (expression.ContainsEmitWithAwait()) { expression = expression.EmitToField(ec); } stackArray.EmitLoad(ec); } else { ec.Emit(OpCodes.Dup); } for (int j = 0; j < count; j++) { ec.EmitInt(array[j]); } if (count == 1 && typeSpec.IsStruct && !BuiltinTypeSpec.IsPrimitiveType(typeSpec)) { ec.Emit(OpCodes.Ldelema, typeSpec); } expression.Emit(ec); ec.EmitArrayStore((ArrayContainer)type); } for (int num = count - 1; num >= 0; num--) { array[num]++; if (array[num] < bounds[num]) { break; } array[num] = 0; } } stackArray?.PrepareCleanup(ec); } public override void Emit(EmitContext ec) { if (NoEmptyInterpolation || !EmitOptimizedEmpty(ec)) { EmitToFieldSource(ec)?.Emit(ec); } } private bool EmitOptimizedEmpty(EmitContext ec) { if (arguments.Count != 1 || dimensions != 1) { return false; } if (!(arguments[0] is Constant { IsZeroInteger: not false })) { return false; } MethodSpec methodSpec = ec.Module.PredefinedMembers.ArrayEmpty.Get(); if (methodSpec == null || ec.CurrentType.MemberDefinition.DeclaringAssembly == methodSpec.DeclaringType.MemberDefinition.DeclaringAssembly) { return false; } methodSpec = methodSpec.MakeGenericMethod(ec.MemberContext, array_element_type); ec.Emit(OpCodes.Call, methodSpec); return true; } protected sealed override FieldExpr EmitToFieldSource(EmitContext ec) { if (first_emit != null) { first_emit.Emit(ec); first_emit_temp.Store(ec); } StackFieldExpr stackFieldExpr; if (ec.HasSet(BuilderContext.Options.AsyncBody) && InitializersContainAwait()) { stackFieldExpr = ec.GetTemporaryField(type); ec.EmitThis(); } else { stackFieldExpr = null; } Expression.EmitExpressionsList(ec, arguments); ec.EmitArrayNew((ArrayContainer)type); if (initializers == null) { return stackFieldExpr; } stackFieldExpr?.EmitAssignFromStack(ec); EmitDynamicInitializers(ec, emitConstants: true, stackFieldExpr); if (first_emit_temp != null) { first_emit_temp.Release(ec); } return stackFieldExpr; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { if (arguments.Count != 1 || array_element_type.IsArray) { base.EncodeAttributeValue(rc, enc, targetType, parameterType); return; } if (type != targetType) { if (targetType.BuiltinType != BuiltinTypeSpec.Type.Object) { base.EncodeAttributeValue(rc, enc, targetType, parameterType); return; } if (enc.Encode(type) == AttributeEncoder.EncodedTypeProperties.DynamicType) { Attribute.Error_AttributeArgumentIsDynamic(rc, loc); return; } } if (array_data == null) { if (arguments[0] is IntConstant { IsDefaultValue: not false }) { enc.Encode(0); } else { base.EncodeAttributeValue(rc, enc, targetType, parameterType); } return; } enc.Encode(array_data.Count); foreach (Expression array_datum in array_data) { array_datum.EncodeAttributeValue(rc, enc, array_element_type, parameterType); } } protected override void CloneTo(CloneContext clonectx, Expression t) { ArrayCreation arrayCreation = (ArrayCreation)t; if (requested_base_type != null) { arrayCreation.requested_base_type = (FullNamedExpression)requested_base_type.Clone(clonectx); } if (arguments != null) { arrayCreation.arguments = new List(arguments.Count); foreach (Expression argument in arguments) { arrayCreation.arguments.Add(argument.Clone(clonectx)); } } if (initializers != null) { arrayCreation.initializers = (ArrayInitializer)initializers.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ImplicitlyTypedArrayCreation : ArrayCreation { private TypeInferenceContext best_type_inference; public ImplicitlyTypedArrayCreation(ComposedTypeSpecifier rank, ArrayInitializer initializers, Location loc) : base(null, rank, initializers, loc) { } public ImplicitlyTypedArrayCreation(ArrayInitializer initializers, Location loc) : base(null, initializers, loc) { } protected override Expression DoResolve(ResolveContext ec) { if (type != null) { return this; } dimensions = rank.Dimension; best_type_inference = new TypeInferenceContext(); if (!ResolveInitializers(ec)) { return null; } best_type_inference.FixAllTypes(ec); array_element_type = best_type_inference.InferredTypeArguments[0]; best_type_inference = null; if (array_element_type == null || InternalType.HasNoType(array_element_type) || arguments.Count != rank.Dimension) { ec.Report.Error(826, loc, "The type of an implicitly typed array cannot be inferred from the initializer. Try specifying array type explicitly"); return null; } UnifyInitializerElement(ec); type = ArrayContainer.MakeType(ec.Module, array_element_type, dimensions); eclass = ExprClass.Value; return this; } private void UnifyInitializerElement(ResolveContext ec) { for (int i = 0; i < array_data.Count; i++) { Expression expression = array_data[i]; if (expression != null) { array_data[i] = Convert.ImplicitConversion(ec, expression, array_element_type, Location.Null); } } } protected override Expression ResolveArrayElement(ResolveContext ec, Expression element) { element = element.Resolve(ec); if (element != null) { best_type_inference.AddCommonTypeBound(element.Type); } return element; } } internal sealed class CompilerGeneratedThis : This { public CompilerGeneratedThis(TypeSpec type, Location loc) : base(loc) { base.type = type; } protected override Expression DoResolve(ResolveContext rc) { eclass = ExprClass.Variable; Block currentBlock = rc.CurrentBlock; if (currentBlock != null) { ToplevelBlock topBlock = currentBlock.ParametersBlock.TopBlock; if (topBlock.ThisVariable != null) { variable_info = topBlock.ThisVariable.VariableInfo; } } return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { return DoResolve(rc); } public override HoistedVariable GetHoistedVariable(AnonymousExpression ae) { return null; } } internal class This : VariableReference { private sealed class ThisVariable : ILocalVariable { public static readonly ILocalVariable Instance = new ThisVariable(); public void Emit(EmitContext ec) { ec.EmitThis(); } public void EmitAssign(EmitContext ec) { throw new InvalidOperationException(); } public void EmitAddressOf(EmitContext ec) { ec.EmitThis(); } } protected VariableInfo variable_info; public override string Name => "this"; public override bool IsLockedByStatement { get { return false; } set { } } public override bool IsRef => type.IsStruct; public override bool IsSideEffectFree => true; protected override ILocalVariable Variable => ThisVariable.Instance; public override VariableInfo VariableInfo => variable_info; public override bool IsFixed => false; public This(Location loc) { base.loc = loc; } private void CheckStructThisDefiniteAssignment(FlowAnalysisContext fc) { if (variable_info != null && !fc.IsDefinitelyAssigned(variable_info)) { fc.Report.Error(188, loc, "The `this' object cannot be used before all of its fields are assigned to"); } } protected virtual void Error_ThisNotAvailable(ResolveContext ec) { if (ec.IsStatic && !ec.HasSet(ResolveContext.Options.ConstantScope)) { ec.Report.Error(26, loc, "Keyword `this' is not valid in a static property, static method, or static field initializer"); } else if (ec.CurrentAnonymousMethod != null) { ec.Report.Error(1673, loc, "Anonymous methods inside structs cannot access instance members of `this'. Consider copying `this' to a local variable outside the anonymous method and using the local instead"); } else { ec.Report.Error(27, loc, "Keyword `this' is not available in the current context"); } } public override void FlowAnalysis(FlowAnalysisContext fc) { CheckStructThisDefiniteAssignment(fc); } public override HoistedVariable GetHoistedVariable(AnonymousExpression ae) { return ae?.Storey?.HoistedThis; } public static bool IsThisAvailable(ResolveContext ec, bool ignoreAnonymous) { if (ec.IsStatic || ec.HasAny(ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer | ResolveContext.Options.ConstantScope)) { return false; } if (ignoreAnonymous || ec.CurrentAnonymousMethod == null) { return true; } if (ec.CurrentType.IsStruct && !(ec.CurrentAnonymousMethod is StateMachineInitializer)) { return false; } return true; } public virtual void ResolveBase(ResolveContext ec) { eclass = ExprClass.Variable; type = ec.CurrentType; if (!IsThisAvailable(ec, ignoreAnonymous: false)) { Error_ThisNotAvailable(ec); return; } Block currentBlock = ec.CurrentBlock; if (currentBlock != null) { ToplevelBlock topBlock = currentBlock.ParametersBlock.TopBlock; if (topBlock.ThisVariable != null) { variable_info = topBlock.ThisVariable.VariableInfo; } AnonymousExpression currentAnonymousMethod = ec.CurrentAnonymousMethod; if (currentAnonymousMethod != null && ec.IsVariableCapturingRequired && !currentBlock.Explicit.HasCapturedThis) { topBlock.AddThisReferenceFromChildrenBlock(currentBlock.Explicit); currentAnonymousMethod.SetHasThisAccess(); } } } protected override Expression DoResolve(ResolveContext ec) { ResolveBase(ec); return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { if (eclass == ExprClass.Unresolved) { ResolveBase(ec); } if (type.IsClass || (type.IsReadOnly && !ec.HasSet(ResolveContext.Options.ConstructorScope))) { if (right_side == EmptyExpression.UnaryAddress) { ec.Report.Error(459, loc, "Cannot take the address of `this' because it is read-only"); } else if (right_side == EmptyExpression.OutAccess) { ec.Report.Error(1605, loc, "Cannot pass `this' as a ref or out argument because it is read-only"); } else { ec.Report.Error(1604, loc, "Cannot assign to `this' because it is read-only"); } } return this; } public override int GetHashCode() { throw new NotImplementedException(); } public override bool Equals(object obj) { if (!(obj is This)) { return false; } return true; } protected override void CloneTo(CloneContext clonectx, Expression t) { } public override void SetHasAddressTaken() { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ArglistAccess : Expression { public ArglistAccess(Location loc) { base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression target) { } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Variable; type = ec.Module.PredefinedTypes.RuntimeArgumentHandle.Resolve(); if (ec.HasSet(ResolveContext.Options.FieldInitializerScope) || !ec.CurrentBlock.ParametersBlock.Parameters.HasArglist) { ec.Report.Error(190, loc, "The __arglist construct is valid only within a variable argument method"); } return this; } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Arglist); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Arglist : Expression { private Arguments arguments; public Arguments Arguments => arguments; public Type[] ArgumentTypes { get { if (arguments == null) { return System.Type.EmptyTypes; } Type[] array = new Type[arguments.Count]; for (int i = 0; i < array.Length; i++) { array[i] = arguments[i].Expr.Type.GetMetaInfo(); } return array; } } public Arglist(Location loc) : this(null, loc) { } public Arglist(Arguments args, Location l) { arguments = args; loc = l; } public override bool ContainsEmitWithAwait() { throw new NotImplementedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(1952, loc, "An expression tree cannot contain a method with variable arguments"); return null; } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Variable; type = InternalType.Arglist; if (arguments != null) { arguments.Resolve(ec, out var _); } return this; } public override void Emit(EmitContext ec) { if (arguments != null) { arguments.Emit(ec); } } protected override void CloneTo(CloneContext clonectx, Expression t) { Arglist arglist = (Arglist)t; if (arguments != null) { arglist.arguments = arguments.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class RefValueExpr : ShimExpression, IAssignMethod, IMemoryLocation { private FullNamedExpression texpr; public FullNamedExpression TypeExpression => texpr; public RefValueExpr(Expression expr, FullNamedExpression texpr, Location loc) : base(expr) { this.texpr = texpr; base.loc = loc; } public override bool ContainsEmitWithAwait() { return false; } public void AddressOf(EmitContext ec, AddressOp mode) { expr.Emit(ec); ec.Emit(OpCodes.Refanyval, type); } protected override Expression DoResolve(ResolveContext rc) { expr = expr.Resolve(rc); type = texpr.ResolveAsType(rc); if (expr == null || type == null) { return null; } expr = Convert.ImplicitConversionRequired(rc, expr, rc.Module.PredefinedTypes.TypedReference.Resolve(), loc); eclass = ExprClass.Variable; return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { return DoResolve(rc); } public override void Emit(EmitContext ec) { expr.Emit(ec); ec.Emit(OpCodes.Refanyval, type); ec.EmitLoadFromPtr(type); } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { expr.Emit(ec); ec.Emit(OpCodes.Refanyval, type); source.Emit(ec); LocalTemporary localTemporary = null; if (leave_copy) { ec.Emit(OpCodes.Dup); localTemporary = new LocalTemporary(source.Type); localTemporary.Store(ec); } ec.EmitStoreFromPtr(type); if (localTemporary != null) { localTemporary.Emit(ec); localTemporary.Release(ec); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class RefTypeExpr : ShimExpression { public RefTypeExpr(Expression expr, Location loc) : base(expr) { base.loc = loc; } protected override Expression DoResolve(ResolveContext rc) { expr = expr.Resolve(rc); if (expr == null) { return null; } expr = Convert.ImplicitConversionRequired(rc, expr, rc.Module.PredefinedTypes.TypedReference.Resolve(), loc); if (expr == null) { return null; } type = rc.BuiltinTypes.Type; eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { expr.Emit(ec); ec.Emit(OpCodes.Refanytype); MethodSpec methodSpec = ec.Module.PredefinedMembers.TypeGetTypeFromHandle.Resolve(loc); if (methodSpec != null) { ec.Emit(OpCodes.Call, methodSpec); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class MakeRefExpr : ShimExpression { public MakeRefExpr(Expression expr, Location loc) : base(expr) { base.loc = loc; } public override bool ContainsEmitWithAwait() { throw new NotImplementedException(); } protected override Expression DoResolve(ResolveContext rc) { expr = expr.ResolveLValue(rc, EmptyExpression.LValueMemberAccess); type = rc.Module.PredefinedTypes.TypedReference.Resolve(); eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { ((IMemoryLocation)expr).AddressOf(ec, AddressOp.Load); ec.Emit(OpCodes.Mkrefany, expr.Type); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class TypeOf : Expression { private FullNamedExpression QueriedType; private TypeSpec typearg; public override bool IsSideEffectFree => true; public TypeSpec TypeArgument => typearg; public FullNamedExpression TypeExpression => QueriedType; public TypeOf(FullNamedExpression queried_type, Location l) { QueriedType = queried_type; loc = l; } public TypeOf(TypeSpec type, Location loc) { typearg = type; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression t) { TypeOf typeOf = (TypeOf)t; if (QueriedType != null) { typeOf.QueriedType = (FullNamedExpression)QueriedType.Clone(clonectx); } } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(this)); arguments.Add(new Argument(new TypeOf(new TypeExpression(type, loc), loc))); return CreateExpressionFactoryCall(ec, "Constant", arguments); } protected override Expression DoResolve(ResolveContext ec) { if (eclass != ExprClass.Unresolved) { return this; } if (typearg == null) { using (ec.Set(ResolveContext.Options.UnsafeScope)) { typearg = QueriedType.ResolveAsType(ec, allowUnboundTypeArguments: true); } if (typearg == null) { return null; } if (typearg.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { ec.Report.Error(1962, QueriedType.Location, "The typeof operator cannot be used on the dynamic type"); } } type = ec.BuiltinTypes.Type; eclass = ExprClass.Value; return this; } private static bool ContainsDynamicType(TypeSpec type) { if (type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return true; } if (type is ElementTypeSpec elementTypeSpec) { return ContainsDynamicType(elementTypeSpec.Element); } TypeSpec[] typeArguments = type.TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (ContainsDynamicType(typeSpec)) { return true; } } return false; } public override void EncodeAttributeValue(IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType) { if (targetType != type) { enc.Encode(type); } if (typearg is InflatedTypeSpec) { TypeSpec declaringType = typearg; do { if (InflatedTypeSpec.ContainsTypeParameter(declaringType)) { rc.Module.Compiler.Report.Error(416, loc, "`{0}': an attribute argument cannot use type parameters", typearg.GetSignatureForError()); return; } declaringType = declaringType.DeclaringType; } while (declaringType != null); } if (ContainsDynamicType(typearg)) { Attribute.Error_AttributeArgumentIsDynamic(rc, loc); } else { enc.EncodeTypeName(typearg); } } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Ldtoken, typearg); MethodSpec methodSpec = ec.Module.PredefinedMembers.TypeGetTypeFromHandle.Resolve(loc); if (methodSpec != null) { ec.Emit(OpCodes.Call, methodSpec); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal sealed class TypeOfMethod : TypeOfMember { public TypeOfMethod(MethodSpec method, Location loc) : base(method, loc) { } protected override Expression DoResolve(ResolveContext ec) { if (member.IsConstructor) { type = ec.Module.PredefinedTypes.ConstructorInfo.Resolve(); } else { type = ec.Module.PredefinedTypes.MethodInfo.Resolve(); } if (type == null) { return null; } return base.DoResolve(ec); } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Ldtoken, member); base.Emit(ec); ec.Emit(OpCodes.Castclass, type); } protected override PredefinedMember GetTypeFromHandle(EmitContext ec) { return ec.Module.PredefinedMembers.MethodInfoGetMethodFromHandle; } protected override PredefinedMember GetTypeFromHandleGeneric(EmitContext ec) { return ec.Module.PredefinedMembers.MethodInfoGetMethodFromHandle2; } } internal abstract class TypeOfMember : Expression where T : MemberSpec { protected readonly T member; public override bool IsSideEffectFree => true; protected TypeOfMember(T member, Location loc) { this.member = member; base.loc = loc; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(this)); arguments.Add(new Argument(new TypeOf(type, loc))); return CreateExpressionFactoryCall(ec, "Constant", arguments); } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { PredefinedMember predefinedMember; if (member.DeclaringType.IsGenericOrParentIsGeneric) { predefinedMember = GetTypeFromHandleGeneric(ec); ec.Emit(OpCodes.Ldtoken, member.DeclaringType); } else { predefinedMember = GetTypeFromHandle(ec); } MethodSpec methodSpec = predefinedMember.Resolve(loc); if (methodSpec != null) { ec.Emit(OpCodes.Call, methodSpec); } } protected abstract PredefinedMember GetTypeFromHandle(EmitContext ec); protected abstract PredefinedMember GetTypeFromHandleGeneric(EmitContext ec); } internal sealed class TypeOfField : TypeOfMember { public TypeOfField(FieldSpec field, Location loc) : base(field, loc) { } protected override Expression DoResolve(ResolveContext ec) { type = ec.Module.PredefinedTypes.FieldInfo.Resolve(); if (type == null) { return null; } return base.DoResolve(ec); } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Ldtoken, member); base.Emit(ec); } protected override PredefinedMember GetTypeFromHandle(EmitContext ec) { return ec.Module.PredefinedMembers.FieldInfoGetFieldFromHandle; } protected override PredefinedMember GetTypeFromHandleGeneric(EmitContext ec) { return ec.Module.PredefinedMembers.FieldInfoGetFieldFromHandle2; } } internal class SizeOf : Expression { private readonly Expression texpr; private TypeSpec type_queried; public override bool IsSideEffectFree => true; public Expression TypeExpression => texpr; public SizeOf(Expression queried_type, Location l) { texpr = queried_type; loc = l; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { Error_PointerInsideExpressionTree(ec); return null; } protected override Expression DoResolve(ResolveContext ec) { type_queried = texpr.ResolveAsType(ec); if (type_queried == null) { return null; } if (type_queried.IsEnum) { type_queried = EnumSpec.GetUnderlyingType(type_queried); } int size = BuiltinTypeSpec.GetSize(type_queried); if (size > 0) { return new IntConstant(ec.BuiltinTypes, size, loc); } if (!TypeManager.VerifyUnmanaged(ec.Module, type_queried, loc)) { return null; } if (!ec.IsUnsafe) { ec.Report.Error(233, loc, "`{0}' does not have a predefined size, therefore sizeof can only be used in an unsafe context (consider using System.Runtime.InteropServices.Marshal.SizeOf)", type_queried.GetSignatureForError()); } type = ec.BuiltinTypes.Int; eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { ec.Emit(OpCodes.Sizeof, type_queried); } protected override void CloneTo(CloneContext clonectx, Expression t) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class QualifiedAliasMember : MemberAccess { private readonly string alias; public static readonly string GlobalAlias = "global"; public string Alias => alias; public QualifiedAliasMember(string alias, string identifier, Location l) : base(null, identifier, l) { this.alias = alias; } public QualifiedAliasMember(string alias, string identifier, TypeArguments targs, Location l) : base(null, identifier, targs, l) { this.alias = alias; } public QualifiedAliasMember(string alias, string identifier, int arity, Location l) : base(null, identifier, arity, l) { this.alias = alias; } public FullNamedExpression CreateExpressionFromAlias(IMemberContext mc) { if (alias == GlobalAlias) { return new NamespaceExpression(mc.Module.GlobalRootNamespace, loc); } int errors = mc.Module.Compiler.Report.Errors; FullNamedExpression fullNamedExpression = mc.LookupNamespaceAlias(alias); if (fullNamedExpression == null) { if (errors == mc.Module.Compiler.Report.Errors) { mc.Module.Compiler.Report.Error(432, loc, "Alias `{0}' not found", alias); } return null; } return fullNamedExpression; } public override FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext mc, bool allowUnboundTypeArguments) { expr = CreateExpressionFromAlias(mc); if (expr == null) { return null; } return base.ResolveAsTypeOrNamespace(mc, allowUnboundTypeArguments); } protected override Expression DoResolve(ResolveContext rc) { return ResolveAsTypeOrNamespace(rc, allowUnboundTypeArguments: false); } public override string GetSignatureForError() { string text = base.Name; if (targs != null) { text = base.Name + "<" + targs.GetSignatureForError() + ">"; } return alias + "::" + text; } public override bool HasConditionalAccess() { return false; } public override Expression LookupNameExpression(ResolveContext rc, MemberLookupRestrictions restrictions) { if ((restrictions & MemberLookupRestrictions.InvocableOnly) != MemberLookupRestrictions.None) { rc.Module.Compiler.Report.Error(687, loc, "The namespace alias qualifier `::' cannot be used to invoke a method. Consider using `.' instead", GetSignatureForError()); return null; } return DoResolve(rc); } protected override void CloneTo(CloneContext clonectx, Expression t) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class MemberAccess : ATypeNameExpression { protected Expression expr; public Expression LeftExpression => expr; public override Location StartLocation => (expr == null) ? loc : expr.StartLocation; public MemberAccess(Expression expr, string id) : base(id, expr.Location) { this.expr = expr; } public MemberAccess(Expression expr, string identifier, Location loc) : base(identifier, loc) { this.expr = expr; } public MemberAccess(Expression expr, string identifier, TypeArguments args, Location loc) : base(identifier, args, loc) { this.expr = expr; } public MemberAccess(Expression expr, string identifier, int arity, Location loc) : base(identifier, arity, loc) { this.expr = expr; } protected override Expression DoResolve(ResolveContext rc) { Expression expression = LookupNameExpression(rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.DontSetConditionalAccess); if (expression != null) { expression = expression.Resolve(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type | ResolveFlags.MethodGroup); } return expression; } public override Expression DoResolveLValue(ResolveContext rc, Expression rhs) { Expression expression = LookupNameExpression(rc, MemberLookupRestrictions.None); if (expression is TypeExpr) { expression.Error_UnexpectedKind(rc, ResolveFlags.VariableOrValue, loc); return null; } if (expression != null) { expression = expression.ResolveLValue(rc, rhs); } return expression; } protected virtual void Error_OperatorCannotBeApplied(ResolveContext rc, TypeSpec type) { if (type == InternalType.NullLiteral && rc.IsRuntimeBinder) { rc.Report.Error(10000, loc, "Cannot perform member binding on `null' value"); } else { expr.Error_OperatorCannotBeApplied(rc, loc, ".", type); } } public override bool HasConditionalAccess() { return LeftExpression.HasConditionalAccess(); } public static bool IsValidDotExpression(TypeSpec type) { return (type.Kind & (MemberKind.NestedMask | MemberKind.TypeParameter | MemberKind.ByRef | MemberKind.ArrayType)) != 0 || type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; } public override Expression LookupNameExpression(ResolveContext rc, MemberLookupRestrictions restrictions) { SimpleName simpleName = expr as SimpleName; if (simpleName != null) { expr = simpleName.LookupNameExpression(rc, MemberLookupRestrictions.ExactArity | MemberLookupRestrictions.ReadAccess); if (expr is VariableReference || expr is ConstantExpr || expr is TransparentMemberAccess || expr is EventExpr) { expr = expr.Resolve(rc); } else if (expr is TypeParameterExpr) { expr.Error_UnexpectedKind(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type, simpleName.Location); expr = null; } } else if ((restrictions & MemberLookupRestrictions.DontSetConditionalAccess) != MemberLookupRestrictions.None) { using (rc.Set(ResolveContext.Options.DontSetConditionalAccessReceiver)) { expr = expr.Resolve(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type); } } else { expr = expr.Resolve(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type); } if (expr == null) { return null; } if (expr is NamespaceExpression namespaceExpression) { FullNamedExpression fullNamedExpression = namespaceExpression.LookupTypeOrNamespace(rc, base.Name, base.Arity, LookupMode.IgnoreAccessibility, loc); if (fullNamedExpression == null) { namespaceExpression.Error_NamespaceDoesNotExist(rc, base.Name, base.Arity, loc); return null; } if (base.Arity > 0) { if (base.HasTypeArguments) { return new GenericTypeExpr(fullNamedExpression.Type, targs, loc); } targs.Resolve(rc, allowUnbound: false); } return fullNamedExpression; } ConditionalMemberAccess conditionalMemberAccess = this as ConditionalMemberAccess; TypeSpec typeSpec = expr.Type; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { if (expr is MemberExpr memberExpr) { memberExpr.ResolveInstanceExpression(rc, null); } Arguments arguments = new Arguments(1); arguments.Add(new Argument(expr)); if (conditionalMemberAccess != null) { return new DynamicConditionalMemberBinder(base.Name, arguments, loc); } return new DynamicMemberBinder(base.Name, arguments, loc); } if (conditionalMemberAccess != null) { if (!Expression.IsNullPropagatingValid(expr.Type)) { expr.Error_OperatorCannotBeApplied(rc, loc, "?", expr.Type); return null; } if (typeSpec.IsNullableType) { expr = Unwrap.Create(expr.Resolve(rc), useDefaultValue: true); typeSpec = expr.Type; } } if (!IsValidDotExpression(typeSpec)) { Error_OperatorCannotBeApplied(rc, typeSpec); return null; } int arity = base.Arity; bool flag = false; Expression expression; while (true) { expression = Expression.MemberLookup(rc, flag, typeSpec, base.Name, arity, restrictions, loc); if (expression == null && MethodGroupExpr.IsExtensionMethodArgument(expr)) { ExtensionMethodCandidates extensionMethodCandidates = rc.LookupExtensionMethod(base.Name, arity); if (extensionMethodCandidates != null) { ExtensionMethodGroupExpr extensionMethodGroupExpr = new ExtensionMethodGroupExpr(extensionMethodCandidates, expr, loc); if (base.HasTypeArguments) { if (!targs.Resolve(rc, allowUnbound: false)) { return null; } extensionMethodGroupExpr.SetTypeArguments(rc, targs); } if (conditionalMemberAccess != null) { extensionMethodGroupExpr.ConditionalAccess = true; } return extensionMethodGroupExpr.Resolve(rc); } } if (flag) { if (expression == null) { List missingDependencies = typeSpec.GetMissingDependencies(); if (missingDependencies != null) { ImportedTypeDefinition.Error_MissingDependency(rc, missingDependencies, loc); } else if (expr is TypeExpr) { base.Error_TypeDoesNotContainDefinition(rc, typeSpec, base.Name); } else { Error_TypeDoesNotContainDefinition(rc, typeSpec, base.Name); } return null; } if (!(expression is MethodGroupExpr) && !(expression is PropertyExpr) && !(expression is TypeExpr)) { Expression.ErrorIsInaccesible(rc, expression.GetSignatureForError(), loc); } break; } if (expression != null) { break; } arity = 0; restrictions &= ~MemberLookupRestrictions.InvocableOnly; flag = true; } if (expression is TypeExpr typeExpr) { if (!(expr is TypeExpr) && (simpleName == null || expr.ProbeIdenticalTypeName(rc, expr, simpleName) == expr)) { rc.Report.Error(572, loc, "`{0}': cannot reference a type through an expression. Consider using `{1}' instead", base.Name, typeExpr.GetSignatureForError()); } if (!typeExpr.Type.IsAccessible(rc)) { rc.Report.SymbolRelatedToPreviousError(expression.Type); Expression.ErrorIsInaccesible(rc, expression.Type.GetSignatureForError(), loc); return null; } if (base.HasTypeArguments) { return new GenericTypeExpr(expression.Type, targs, loc); } return expression; } MemberExpr memberExpr2 = expression as MemberExpr; if (simpleName != null && memberExpr2.IsStatic && (expr = memberExpr2.ProbeIdenticalTypeName(rc, expr, simpleName)) != expr) { simpleName = null; } if (conditionalMemberAccess != null) { memberExpr2.ConditionalAccess = true; } memberExpr2 = memberExpr2.ResolveMemberAccess(rc, expr, simpleName); if (base.Arity > 0) { if (!targs.Resolve(rc, allowUnbound: false)) { return null; } memberExpr2.SetTypeArguments(rc, targs); } return memberExpr2; } public override FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext rc, bool allowUnboundTypeArguments) { if (!(expr is FullNamedExpression fullNamedExpression)) { expr.ResolveAsType(rc); return null; } FullNamedExpression fullNamedExpression2 = fullNamedExpression.ResolveAsTypeOrNamespace(rc, allowUnboundTypeArguments); if (fullNamedExpression2 == null) { return null; } if (fullNamedExpression2 is NamespaceExpression namespaceExpression) { FullNamedExpression fullNamedExpression3 = namespaceExpression.LookupTypeOrNamespace(rc, base.Name, base.Arity, LookupMode.IgnoreAccessibility, loc); if (fullNamedExpression3 == null) { namespaceExpression.Error_NamespaceDoesNotExist(rc, base.Name, base.Arity, loc); } else if (base.Arity > 0) { if (base.HasTypeArguments) { fullNamedExpression3 = new GenericTypeExpr(fullNamedExpression3.Type, targs, loc); if (fullNamedExpression3.ResolveAsType(rc) == null) { return null; } } else { targs.Resolve(rc, allowUnboundTypeArguments); fullNamedExpression3 = new GenericOpenTypeExpr(fullNamedExpression3.Type, loc); } } return fullNamedExpression3; } TypeSpec typeSpec = fullNamedExpression2.ResolveAsType(rc); if (typeSpec == null) { return null; } TypeSpec typeSpec2 = typeSpec; if (TypeManager.IsGenericParameter(typeSpec2)) { rc.Module.Compiler.Report.Error(704, loc, "A nested type cannot be specified through a type parameter `{0}'", typeSpec.GetSignatureForError()); return null; } if (this is QualifiedAliasMember qualifiedAliasMember) { rc.Module.Compiler.Report.Error(431, loc, "Alias `{0}' cannot be used with `::' since it denotes a type. Consider replacing `::' with `.'", qualifiedAliasMember.Alias); } TypeSpec typeSpec3 = null; while (typeSpec2 != null) { typeSpec3 = MemberCache.FindNestedType(typeSpec2, base.Name, base.Arity, declaredOnlyClass: false); if (typeSpec3 == null) { if (typeSpec2 == typeSpec) { Error_IdentifierNotFound(rc, typeSpec2); return null; } typeSpec2 = typeSpec; typeSpec3 = MemberCache.FindNestedType(typeSpec2, base.Name, base.Arity, declaredOnlyClass: false); Expression.ErrorIsInaccesible(rc, typeSpec3.GetSignatureForError(), loc); break; } if (typeSpec3.IsAccessible(rc) || typeSpec2.MemberDefinition == rc.CurrentMemberDefinition) { break; } typeSpec2 = typeSpec2.BaseType; } TypeExpr typeExpr; if (base.Arity <= 0) { typeExpr = ((!(fullNamedExpression2 is GenericOpenTypeExpr)) ? new TypeExpression(typeSpec3, loc) : new GenericOpenTypeExpr(typeSpec3, loc)); } else if (base.HasTypeArguments) { typeExpr = new GenericTypeExpr(typeSpec3, targs, loc); } else { targs.Resolve(rc, allowUnboundTypeArguments && !(fullNamedExpression2 is GenericTypeExpr)); typeExpr = new GenericOpenTypeExpr(typeSpec3, loc); } if (typeExpr.ResolveAsType(rc) == null) { return null; } return typeExpr; } public void Error_IdentifierNotFound(IMemberContext rc, TypeSpec expr_type) { TypeSpec typeSpec = MemberCache.FindNestedType(expr_type, base.Name, -Math.Max(1, base.Arity), declaredOnlyClass: false); if (typeSpec != null) { Error_TypeArgumentsCannotBeUsed(rc, typeSpec, expr.Location); return; } Expression expression = Expression.MemberLookup(rc, errorMode: false, expr_type, base.Name, 0, MemberLookupRestrictions.None, loc); if (expression != null) { Expression.Error_UnexpectedKind(rc, expression, "type", expression.ExprClassName, loc); } else { rc.Module.Compiler.Report.Error(426, loc, "The nested type `{0}' does not exist in the type `{1}'", base.Name, expr_type.GetSignatureForError()); } } protected override void Error_InvalidExpressionStatement(Report report, Location loc) { base.Error_InvalidExpressionStatement(report, LeftExpression.Location); } public override void Error_TypeDoesNotContainDefinition(ResolveContext ec, TypeSpec type, string name) { if (ec.Module.Compiler.Settings.Version > LanguageVersion.ISO_2 && !ec.IsRuntimeBinder && MethodGroupExpr.IsExtensionMethodArgument(expr)) { ec.Report.SymbolRelatedToPreviousError(type); List list = ec.Module.GlobalRootNamespace.FindExtensionMethodNamespaces(ec, name, base.Arity); string text = ((list == null) ? "an assembly reference" : ("`" + string.Join("' or `", list.ToArray()) + "' using directive")); ec.Report.Error(1061, loc, "Type `{0}' does not contain a definition for `{1}' and no extension method `{1}' of type `{0}' could be found. Are you missing {2}?", type.GetSignatureForError(), name, text); } else { base.Error_TypeDoesNotContainDefinition(ec, type, name); } } public override string GetSignatureForError() { return expr.GetSignatureForError() + "." + base.GetSignatureForError(); } protected override void CloneTo(CloneContext clonectx, Expression t) { MemberAccess memberAccess = (MemberAccess)t; memberAccess.expr = expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ConditionalMemberAccess : MemberAccess { public ConditionalMemberAccess(Expression expr, string identifier, TypeArguments args, Location loc) : base(expr, identifier, args, loc) { } public override bool HasConditionalAccess() { return true; } } internal class CheckedExpr : Expression { public Expression Expr; public CheckedExpr(Expression e, Location l) { Expr = e; loc = l; } public override bool ContainsEmitWithAwait() { return Expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { using (ec.With(ResolveContext.Options.AllCheckStateFlags, enable: true)) { return Expr.CreateExpressionTree(ec); } } protected override Expression DoResolve(ResolveContext ec) { using (ec.With(ResolveContext.Options.AllCheckStateFlags, enable: true)) { Expr = Expr.Resolve(ec); } if (Expr == null) { return null; } if (Expr is Constant || Expr is MethodGroupExpr || Expr is AnonymousMethodExpression || Expr is DefaultValueExpression) { return Expr; } eclass = Expr.eclass; type = Expr.Type; return this; } public override void Emit(EmitContext ec) { using (ec.With(BuilderContext.Options.CheckedScope, enable: true)) { Expr.Emit(ec); } } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { using (ec.With(BuilderContext.Options.CheckedScope, enable: true)) { Expr.EmitBranchable(ec, target, on_true); } } public override void FlowAnalysis(FlowAnalysisContext fc) { Expr.FlowAnalysis(fc); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { using (ctx.With(BuilderContext.Options.CheckedScope, enable: true)) { return Expr.MakeExpression(ctx); } } protected override void CloneTo(CloneContext clonectx, Expression t) { CheckedExpr checkedExpr = (CheckedExpr)t; checkedExpr.Expr = Expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class UnCheckedExpr : Expression { public Expression Expr; public UnCheckedExpr(Expression e, Location l) { Expr = e; loc = l; } public override bool ContainsEmitWithAwait() { return Expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { using (ec.With(ResolveContext.Options.AllCheckStateFlags, enable: false)) { return Expr.CreateExpressionTree(ec); } } protected override Expression DoResolve(ResolveContext ec) { using (ec.With(ResolveContext.Options.AllCheckStateFlags, enable: false)) { Expr = Expr.Resolve(ec); } if (Expr == null) { return null; } if (Expr is Constant || Expr is MethodGroupExpr || Expr is AnonymousMethodExpression || Expr is DefaultValueExpression) { return Expr; } eclass = Expr.eclass; type = Expr.Type; return this; } public override void Emit(EmitContext ec) { using (ec.With(BuilderContext.Options.CheckedScope, enable: false)) { Expr.Emit(ec); } } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { using (ec.With(BuilderContext.Options.CheckedScope, enable: false)) { Expr.EmitBranchable(ec, target, on_true); } } public override void FlowAnalysis(FlowAnalysisContext fc) { Expr.FlowAnalysis(fc); } protected override void CloneTo(CloneContext clonectx, Expression t) { UnCheckedExpr unCheckedExpr = (UnCheckedExpr)t; unCheckedExpr.Expr = Expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ElementAccess : Expression { public Arguments Arguments; public Expression Expr; private bool conditional_access_receiver; public bool ConditionalAccess { get; set; } public override Location StartLocation => Expr.StartLocation; public ElementAccess(Expression e, Arguments args, Location loc) { Expr = e; base.loc = loc; Arguments = args; } public override bool ContainsEmitWithAwait() { return Expr.ContainsEmitWithAwait() || Arguments.ContainsEmitWithAwait(); } private Expression CreateAccessExpression(ResolveContext ec, bool conditionalAccessReceiver) { if (conditionalAccessReceiver) { ec.Set(ResolveContext.Options.DontSetConditionalAccessReceiver); } Expr = Expr.Resolve(ec); if (conditionalAccessReceiver) { ec.With(ResolveContext.Options.DontSetConditionalAccessReceiver, enable: false); } if (Expr == null) { return null; } type = Expr.Type; if (ConditionalAccess && !Expression.IsNullPropagatingValid(type)) { Error_OperatorCannotBeApplied(ec, loc, "?", type); return null; } if (type.IsArray) { ArrayAccess arrayAccess = new ArrayAccess(this, loc) { ConditionalAccess = ConditionalAccess }; if (conditionalAccessReceiver) { arrayAccess.SetConditionalAccessReceiver(); } return arrayAccess; } if (type.IsPointer) { return Expr.MakePointerAccess(ec, type, Arguments); } if (Expr is FieldExpr { Spec: FixedFieldSpec spec }) { return Expr.MakePointerAccess(ec, spec.ElementType, Arguments); } IList list = MemberCache.FindMembers(type, MemberCache.IndexerNameAlias, declaredOnlyClass: false); if (list != null || type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { IndexerExpr indexerExpr = new IndexerExpr(list, type, this) { ConditionalAccess = ConditionalAccess }; if (conditionalAccessReceiver) { indexerExpr.SetConditionalAccessReceiver(); } return indexerExpr; } Error_CannotApplyIndexing(ec, type, loc); return null; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments args = Arguments.CreateForExpressionTree(ec, Arguments, Expr.CreateExpressionTree(ec)); return CreateExpressionFactoryCall(ec, "ArrayIndex", args); } public static void Error_CannotApplyIndexing(ResolveContext rc, TypeSpec type, Location loc) { if (type != InternalType.ErrorType) { rc.Report.Error(21, loc, "Cannot apply indexing with [] to an expression of type `{0}'", type.GetSignatureForError()); } } public override bool HasConditionalAccess() { return ConditionalAccess || Expr.HasConditionalAccess(); } private void ResolveConditionalAccessReceiver(ResolveContext rc) { if (!rc.HasSet(ResolveContext.Options.DontSetConditionalAccessReceiver) && HasConditionalAccess()) { conditional_access_receiver = true; } } protected override Expression DoResolve(ResolveContext rc) { ResolveConditionalAccessReceiver(rc); return CreateAccessExpression(rc, conditional_access_receiver)?.Resolve(rc); } public override Expression DoResolveLValue(ResolveContext ec, Expression rhs) { return CreateAccessExpression(ec, conditionalAccessReceiver: false)?.ResolveLValue(ec, rhs); } public override void Emit(EmitContext ec) { throw new Exception("Should never be reached"); } public override void FlowAnalysis(FlowAnalysisContext fc) { Expr.FlowAnalysis(fc); Arguments.FlowAnalysis(fc); } public override string GetSignatureForError() { return Expr.GetSignatureForError(); } protected override void CloneTo(CloneContext clonectx, Expression t) { ElementAccess elementAccess = (ElementAccess)t; elementAccess.Expr = Expr.Clone(clonectx); if (Arguments != null) { elementAccess.Arguments = Arguments.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ArrayAccess : Expression, IDynamicAssign, IAssignMethod, IMemoryLocation { private ElementAccess ea; private LocalTemporary temp; private bool prepared; private bool? has_await_args; private bool conditional_access_receiver; public bool ConditionalAccess { get; set; } public ArrayAccess(ElementAccess ea_data, Location l) { ea = ea_data; loc = l; } public void AddressOf(EmitContext ec, AddressOp mode) { ArrayContainer arrayContainer = (ArrayContainer)ea.Expr.Type; if (!has_await_args.HasValue && ec.HasSet(BuilderContext.Options.AsyncBody) && ea.Arguments.ContainsEmitWithAwait()) { LoadInstanceAndArguments(ec, duplicateArguments: false, prepareAwait: true); } LoadInstanceAndArguments(ec, duplicateArguments: false, prepareAwait: false); if (arrayContainer.Element.IsGenericParameter && mode == AddressOp.Load) { ec.Emit(OpCodes.Readonly); } ec.EmitArrayAddress(arrayContainer); } public override Expression CreateExpressionTree(ResolveContext ec) { if (ConditionalAccess) { Error_NullShortCircuitInsideExpressionTree(ec); } return ea.CreateExpressionTree(ec); } public override bool ContainsEmitWithAwait() { return ea.ContainsEmitWithAwait(); } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { if (HasConditionalAccess()) { Error_NullPropagatingLValue(ec); } return DoResolve(ec); } protected override Expression DoResolve(ResolveContext ec) { ea.Arguments.Resolve(ec, out var _); ArrayContainer arrayContainer = ea.Expr.Type as ArrayContainer; int count = ea.Arguments.Count; if (arrayContainer.Rank != count) { ec.Report.Error(22, ea.Location, "Wrong number of indexes `{0}' inside [], expected `{1}'", count.ToString(), arrayContainer.Rank.ToString()); return null; } type = arrayContainer.Element; if (type.IsPointer) { if (ec.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(ec, ea.Location); } else if (!ec.IsUnsafe) { Expression.UnsafeError(ec, ea.Location); } } if (conditional_access_receiver) { type = LiftMemberType(ec, type); } foreach (Argument argument in ea.Arguments) { if (argument is NamedArgument na) { Expression.Error_NamedArgument(na, ec.Report); } argument.Expr = ConvertExpressionToArrayIndex(ec, argument.Expr); } eclass = ExprClass.Variable; return this; } protected override void Error_NegativeArrayIndex(ResolveContext ec, Location loc) { ec.Report.Warning(251, 2, loc, "Indexing an array with a negative index (array indices always start at zero)"); } public override void FlowAnalysis(FlowAnalysisContext fc) { DefiniteAssignmentBitSet definiteAssignment = (conditional_access_receiver ? fc.BranchDefiniteAssignment() : null); ea.FlowAnalysis(fc); if (conditional_access_receiver) { fc.DefiniteAssignment = definiteAssignment; } } public override bool HasConditionalAccess() { return ConditionalAccess || ea.Expr.HasConditionalAccess(); } private void LoadInstanceAndArguments(EmitContext ec, bool duplicateArguments, bool prepareAwait) { if (prepareAwait) { ea.Expr = ea.Expr.EmitToField(ec); } else { new InstanceEmitter(ea.Expr, addressLoad: false).Emit(ec, ConditionalAccess); if (duplicateArguments) { ec.Emit(OpCodes.Dup); LocalTemporary localTemporary = new LocalTemporary(ea.Expr.Type); localTemporary.Store(ec); ea.Expr = localTemporary; } } Arguments arguments = ea.Arguments.Emit(ec, duplicateArguments, prepareAwait); if (arguments != null) { ea.Arguments = arguments; } } public void Emit(EmitContext ec, bool leave_copy) { if (prepared) { ec.EmitLoadFromPtr(type); } else { if (!has_await_args.HasValue && ec.HasSet(BuilderContext.Options.AsyncBody) && ea.Arguments.ContainsEmitWithAwait()) { LoadInstanceAndArguments(ec, duplicateArguments: false, prepareAwait: true); } if (conditional_access_receiver) { ec.ConditionalAccess = new ConditionalAccessContext(type, ec.DefineLabel()); } ArrayContainer arrayContainer = (ArrayContainer)ea.Expr.Type; LoadInstanceAndArguments(ec, duplicateArguments: false, prepareAwait: false); ec.EmitArrayLoad(arrayContainer); if (conditional_access_receiver) { ec.CloseConditionalAccess((type.IsNullableType && type != arrayContainer.Element) ? type : null); } } if (leave_copy) { ec.Emit(OpCodes.Dup); temp = new LocalTemporary(type); temp.Store(ec); } } public override void Emit(EmitContext ec) { Emit(ec, leave_copy: false); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { ArrayContainer ac = (ArrayContainer)ea.Expr.Type; TypeSpec typeSpec = source.Type; has_await_args = ec.HasSet(BuilderContext.Options.AsyncBody) && (ea.Arguments.ContainsEmitWithAwait() || source.ContainsEmitWithAwait()); if (typeSpec.IsStruct && ((isCompound && !(source is DynamicExpressionStatement)) || !BuiltinTypeSpec.IsPrimitiveType(typeSpec))) { LoadInstanceAndArguments(ec, duplicateArguments: false, has_await_args.Value); if (has_await_args.Value) { if (source.ContainsEmitWithAwait()) { source = source.EmitToField(ec); isCompound = false; prepared = true; } LoadInstanceAndArguments(ec, isCompound, prepareAwait: false); } else { prepared = true; } ec.EmitArrayAddress(ac); if (isCompound) { ec.Emit(OpCodes.Dup); prepared = true; } } else { LoadInstanceAndArguments(ec, isCompound, has_await_args.Value); if (has_await_args.Value) { if (source.ContainsEmitWithAwait()) { source = source.EmitToField(ec); } LoadInstanceAndArguments(ec, duplicateArguments: false, prepareAwait: false); } } source.Emit(ec); if (isCompound && ea.Expr is LocalTemporary localTemporary) { localTemporary.Release(ec); } if (leave_copy) { ec.Emit(OpCodes.Dup); temp = new LocalTemporary(type); temp.Store(ec); } if (prepared) { ec.EmitStoreFromPtr(typeSpec); } else { ec.EmitArrayStore(ac); } if (temp != null) { temp.Emit(ec); temp.Release(ec); } } public override Expression EmitToField(EmitContext ec) { ea.Expr = ea.Expr.EmitToField(ec); ea.Arguments = ea.Arguments.Emit(ec, dup_args: false, prepareAwait: true); return this; } public System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source) { throw new NotImplementedException(); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.ArrayIndex(ea.Expr.MakeExpression(ctx), MakeExpressionArguments(ctx)); } private System.Linq.Expressions.Expression[] MakeExpressionArguments(BuilderContext ctx) { using (ctx.With(BuilderContext.Options.CheckedScope, enable: true)) { return Arguments.MakeExpression(ea.Arguments, ctx); } } public void SetConditionalAccessReceiver() { conditional_access_receiver = true; } } internal class IndexerExpr : PropertyOrIndexerExpr, OverloadResolver.IBaseMembersProvider { private IList indexers; private Arguments arguments; private TypeSpec queried_type; protected override Arguments Arguments { get { return arguments; } set { arguments = value; } } protected override TypeSpec DeclaringType => best_candidate.DeclaringType; public override bool IsInstance => true; public override bool IsStatic => false; public override string KindName => "indexer"; public override string Name => "this"; public IndexerExpr(IList indexers, TypeSpec queriedType, ElementAccess ea) : this(indexers, queriedType, ea.Expr, ea.Arguments, ea.Location) { } public IndexerExpr(IList indexers, TypeSpec queriedType, Expression instance, Arguments args, Location loc) : base(loc) { this.indexers = indexers; queried_type = queriedType; InstanceExpression = instance; arguments = args; } public override bool ContainsEmitWithAwait() { return base.ContainsEmitWithAwait() || arguments.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { if (base.ConditionalAccess) { Error_NullShortCircuitInsideExpressionTree(ec); } Arguments args = Arguments.CreateForExpressionTree(ec, arguments, InstanceExpression.CreateExpressionTree(ec), new TypeOfMethod(base.Getter, loc)); return CreateExpressionFactoryCall(ec, "Call", args); } public override void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { LocalTemporary localTemporary = null; if (isCompound) { emitting_compound_assignment = true; if (source is DynamicExpressionStatement) { Emit(ec, leave_copy: false); } else { source.Emit(ec); } emitting_compound_assignment = false; if (has_await_arguments) { localTemporary = new LocalTemporary(base.Type); localTemporary.Store(ec); arguments.Add(new Argument(localTemporary)); if (leave_copy) { temp = localTemporary; } has_await_arguments = false; } else { arguments = null; if (leave_copy) { ec.Emit(OpCodes.Dup); temp = new LocalTemporary(base.Type); temp.Store(ec); } } } else { if (leave_copy) { if (ec.HasSet(BuilderContext.Options.AsyncBody) && (arguments.ContainsEmitWithAwait() || source.ContainsEmitWithAwait())) { source = source.EmitToField(ec); } else { temp = new LocalTemporary(base.Type); source.Emit(ec); temp.Store(ec); source = temp; } } arguments.Add(new Argument(source)); } CallEmitter callEmitter = new CallEmitter { InstanceExpression = InstanceExpression }; if (arguments == null) { callEmitter.InstanceExpressionOnStack = true; } callEmitter.Emit(ec, base.Setter, arguments, loc); if (temp != null) { temp.Emit(ec); temp.Release(ec); } else if (leave_copy) { source.Emit(ec); } localTemporary?.Release(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { DefiniteAssignmentBitSet definiteAssignment = (conditional_access_receiver ? fc.BranchDefiniteAssignment() : null); base.FlowAnalysis(fc); arguments.FlowAnalysis(fc); if (conditional_access_receiver) { fc.DefiniteAssignment = definiteAssignment; } } public override string GetSignatureForError() { return best_candidate.GetSignatureForError(); } public override System.Linq.Expressions.Expression MakeAssignExpression(BuilderContext ctx, Expression source) { System.Linq.Expressions.Expression[] second = new System.Linq.Expressions.Expression[1] { source.MakeExpression(ctx) }; IEnumerable source2 = Arguments.MakeExpression(arguments, ctx).Concat(second); return source2.First(); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { System.Linq.Expressions.Expression[] array = Arguments.MakeExpression(arguments, ctx); return System.Linq.Expressions.Expression.Call(InstanceExpression.MakeExpression(ctx), (MethodInfo)base.Getter.GetMetaInfo(), array); } protected override Expression OverloadResolve(ResolveContext rc, Expression right_side) { if (best_candidate != null) { return this; } eclass = ExprClass.IndexerAccess; bool dynamic; using (rc.With(ResolveContext.Options.DontSetConditionalAccessReceiver, enable: false)) { this.arguments.Resolve(rc, out dynamic); } if (indexers == null && InstanceExpression.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { dynamic = true; } else { OverloadResolver overloadResolver = new OverloadResolver(indexers, OverloadResolver.Restrictions.None, loc); overloadResolver.BaseMembersProvider = this; overloadResolver.InstanceQualifier = this; best_candidate = overloadResolver.ResolveMember(rc, ref this.arguments); if (best_candidate != null) { type = overloadResolver.BestCandidateReturnType; } else if (!overloadResolver.BestCandidateIsDynamic) { return null; } } if (dynamic) { Arguments arguments = new Arguments(this.arguments.Count + 1); if (base.IsBase) { rc.Report.Error(1972, loc, "The indexer base access cannot be dynamically dispatched. Consider casting the dynamic arguments or eliminating the base access"); } else { arguments.Add(new Argument(InstanceExpression)); } arguments.AddRange(this.arguments); best_candidate = null; return new DynamicIndexBinder(arguments, conditional_access_receiver, base.ConditionalAccess, loc); } if (right_side != null) { ResolveInstanceExpression(rc, right_side); } return this; } protected override void CloneTo(CloneContext clonectx, Expression t) { IndexerExpr indexerExpr = (IndexerExpr)t; if (arguments != null) { indexerExpr.arguments = arguments.Clone(clonectx); } } public void SetConditionalAccessReceiver() { conditional_access_receiver = true; } public override void SetTypeArguments(ResolveContext ec, TypeArguments ta) { Expression.Error_TypeArgumentsCannotBeUsed(ec, "indexer", GetSignatureForError(), loc); } IList OverloadResolver.IBaseMembersProvider.GetBaseMembers(TypeSpec type) { TypeSpec baseType = type.BaseType; IList list = ((baseType == null) ? null : MemberCache.FindMembers(baseType, MemberCache.IndexerNameAlias, declaredOnlyClass: false)); if (list == null && !type.IsInterface && queried_type is TypeParameterSpec typeParameter) { list = MemberCache.FindInterfaceMembers(typeParameter, MemberCache.IndexerNameAlias); } return list; } IParametersMember OverloadResolver.IBaseMembersProvider.GetOverrideMemberParameters(MemberSpec member) { if (queried_type == member.DeclaringType) { return null; } return MemberCache.FindMember(filter: new MemberFilter(MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, ((IndexerSpec)member).Parameters, null), container: queried_type, restrictions: BindingRestriction.InstanceOnly | BindingRestriction.OverrideOnly) as IParametersMember; } MethodGroupExpr OverloadResolver.IBaseMembersProvider.LookupExtensionMethod(ResolveContext rc) { return null; } } internal class BaseThis : This { public override string Name => "base"; public BaseThis(Location loc) : base(loc) { } public BaseThis(TypeSpec type, Location loc) : base(loc) { base.type = type; eclass = ExprClass.Variable; } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(831, loc, "An expression tree may not contain a base access"); return base.CreateExpressionTree(ec); } public override void Emit(EmitContext ec) { base.Emit(ec); if (type == ec.Module.Compiler.BuiltinTypes.ValueType) { TypeSpec currentType = ec.CurrentType; ec.Emit(OpCodes.Ldobj, currentType); ec.Emit(OpCodes.Box, currentType); } } protected override void Error_ThisNotAvailable(ResolveContext ec) { if (ec.IsStatic) { ec.Report.Error(1511, loc, "Keyword `base' is not available in a static method"); } else { ec.Report.Error(1512, loc, "Keyword `base' is not available in the current context"); } } public override void ResolveBase(ResolveContext ec) { base.ResolveBase(ec); type = ec.CurrentType.BaseType; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class EmptyExpression : Expression { private sealed class OutAccessExpression : EmptyExpression { public OutAccessExpression(TypeSpec t) : base(t) { } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { rc.Report.Error(206, right_side.Location, "A property, indexer or dynamic member access may not be passed as `ref' or `out' parameter"); return null; } } public static readonly EmptyExpression LValueMemberAccess = new EmptyExpression(InternalType.FakeInternalType); public static readonly EmptyExpression LValueMemberOutAccess = new EmptyExpression(InternalType.FakeInternalType); public static readonly EmptyExpression UnaryAddress = new EmptyExpression(InternalType.FakeInternalType); public static readonly EmptyExpression EventAddition = new EmptyExpression(InternalType.FakeInternalType); public static readonly EmptyExpression EventSubtraction = new EmptyExpression(InternalType.FakeInternalType); public static readonly EmptyExpression MissingValue = new EmptyExpression(InternalType.FakeInternalType); public static readonly Expression Null = new EmptyExpression(InternalType.FakeInternalType); public static readonly EmptyExpression OutAccess = new OutAccessExpression(InternalType.FakeInternalType); public EmptyExpression(TypeSpec t) { type = t; eclass = ExprClass.Value; loc = Location.Null; } protected override void CloneTo(CloneContext clonectx, Expression target) { } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override void Emit(EmitContext ec) { } public override void EmitBranchable(EmitContext ec, Label target, bool on_true) { } public override void EmitSideEffect(EmitContext ec) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal sealed class EmptyAwaitExpression : EmptyExpression { public EmptyAwaitExpression(TypeSpec type) : base(type) { } public override bool ContainsEmitWithAwait() { return true; } } internal sealed class EmptyExpressionStatement : ExpressionStatement { public static readonly EmptyExpressionStatement Instance = new EmptyExpressionStatement(); private EmptyExpressionStatement() { loc = Location.Null; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { return null; } public override void EmitStatement(EmitContext ec) { } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Value; type = ec.BuiltinTypes.Object; return this; } public override void Emit(EmitContext ec) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ErrorExpression : EmptyExpression { public static readonly ErrorExpression Instance = new ErrorExpression(); private ErrorExpression() : base(InternalType.ErrorType) { } public override Expression CreateExpressionTree(ResolveContext ec) { return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { return this; } public override void Error_ValueAssignment(ResolveContext rc, Expression rhs) { } public override void Error_UnexpectedKind(ResolveContext ec, ResolveFlags flags, Location loc) { } public override void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec target, bool expl) { } public override void Error_OperatorCannotBeApplied(ResolveContext rc, Location loc, string oper, TypeSpec t) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class UserCast : Expression { private MethodSpec method; private Expression source; public Expression Source { get { return source; } set { source = value; } } public UserCast(MethodSpec method, Expression source, Location l) { if (source == null) { throw new ArgumentNullException("source"); } this.method = method; this.source = source; type = method.ReturnType; loc = l; } public override bool ContainsEmitWithAwait() { return source.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(3); arguments.Add(new Argument(source.CreateExpressionTree(ec))); arguments.Add(new Argument(new TypeOf(type, loc))); arguments.Add(new Argument(new TypeOfMethod(method, loc))); return CreateExpressionFactoryCall(ec, "Convert", arguments); } protected override Expression DoResolve(ResolveContext ec) { method.CheckObsoleteness(ec, source.Location); eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { source.Emit(ec); ec.MarkCallEntry(loc); ec.Emit(OpCodes.Call, method); } public override void FlowAnalysis(FlowAnalysisContext fc) { source.FlowAnalysis(fc); } public override string GetSignatureForError() { return TypeManager.CSharpSignature(method); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Convert(source.MakeExpression(ctx), type.GetMetaInfo(), (MethodInfo)method.GetMetaInfo()); } } internal class ComposedTypeSpecifier { public static readonly ComposedTypeSpecifier SingleDimension = new ComposedTypeSpecifier(1, Location.Null); public readonly int Dimension; public readonly Location Location; public bool IsNullable => Dimension == -1; public bool IsPointer => Dimension == -2; public ComposedTypeSpecifier Next { get; set; } public ComposedTypeSpecifier(int specifier, Location loc) { Dimension = specifier; Location = loc; } public static ComposedTypeSpecifier CreateArrayDimension(int dimension, Location loc) { return new ComposedTypeSpecifier(dimension, loc); } public static ComposedTypeSpecifier CreateNullable(Location loc) { return new ComposedTypeSpecifier(-1, loc); } public static ComposedTypeSpecifier CreatePointer(Location loc) { return new ComposedTypeSpecifier(-2, loc); } public string GetSignatureForError() { string text = (IsPointer ? "*" : (IsNullable ? "?" : ArrayContainer.GetPostfixSignature(Dimension))); return (Next != null) ? (text + Next.GetSignatureForError()) : text; } } internal class ComposedCast : TypeExpr { private FullNamedExpression left; private ComposedTypeSpecifier spec; public ComposedCast(FullNamedExpression left, ComposedTypeSpecifier spec) { if (spec == null) { throw new ArgumentNullException("spec"); } this.left = left; this.spec = spec; loc = left.Location; } public override TypeSpec ResolveAsType(IMemberContext ec, bool allowUnboundTypeArguments) { type = left.ResolveAsType(ec); if (type == null) { return null; } eclass = ExprClass.Type; ComposedTypeSpecifier next = spec; if (next.IsNullable) { type = new NullableType(type, loc).ResolveAsType(ec); if (type == null) { return null; } next = next.Next; } else if (next.IsPointer) { if (!(ec.CurrentMemberDefinition is Field) && !TypeManager.VerifyUnmanaged(ec.Module, type, loc)) { return null; } if (((ec is ResolveContext resolveContext) ? resolveContext.CurrentIterator : null) != null) { Expression.UnsafeInsideIteratorError(ec.Module.Compiler.Report, loc); } else if (!ec.IsUnsafe) { Expression.UnsafeError(ec.Module.Compiler.Report, loc); } do { type = PointerContainer.MakeType(ec.Module, type); next = next.Next; } while (next != null && next.IsPointer); } if (next != null && next.Dimension > 0) { if (type.IsSpecialRuntimeType || type.IsByRefLike) { ec.Module.Compiler.Report.Error(611, loc, "Array elements cannot be of type `{0}'", type.GetSignatureForError()); } else if (type.IsStatic) { ec.Module.Compiler.Report.SymbolRelatedToPreviousError(type); ec.Module.Compiler.Report.Error(719, loc, "Array elements cannot be of static type `{0}'", type.GetSignatureForError()); } else { MakeArray(ec.Module, next); } } return type; } private void MakeArray(ModuleContainer module, ComposedTypeSpecifier spec) { if (spec.Next != null) { MakeArray(module, spec.Next); } type = ArrayContainer.MakeType(module, type, spec.Dimension); } public override string GetSignatureForError() { return left.GetSignatureForError() + spec.GetSignatureForError(); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ReferenceTypeExpr : TypeExpr { private FullNamedExpression element; private readonly bool readOnly; public ReferenceTypeExpr(FullNamedExpression element, bool readOnly, Location loc) : this(element, loc) { this.readOnly = readOnly; } public ReferenceTypeExpr(FullNamedExpression element, Location loc) { this.element = element; base.loc = loc; } public override TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments = false) { type = element.ResolveAsType(mc); if (type == null) { return null; } eclass = ExprClass.Type; type = (readOnly ? ReadOnlyReferenceContainer.MakeType(mc.Module, type) : ReferenceContainer.MakeType(mc.Module, type)); return type; } public override string GetSignatureForError() { string text = (readOnly ? "ref " : "ref readonly "); return text + element.GetSignatureForError(); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class FixedBufferPtr : Expression { private readonly Expression array; public FixedBufferPtr(Expression array, TypeSpec array_type, Location l) { type = array_type; this.array = array; loc = l; } public override bool ContainsEmitWithAwait() { throw new NotImplementedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { Error_PointerInsideExpressionTree(ec); return null; } public override void Emit(EmitContext ec) { array.Emit(ec); } protected override Expression DoResolve(ResolveContext ec) { type = PointerContainer.MakeType(ec.Module, type); eclass = ExprClass.Value; return this; } } internal class ArrayPtr : FixedBufferPtr { public ArrayPtr(Expression array, TypeSpec array_type, Location l) : base(array, array_type, l) { } public override void Emit(EmitContext ec) { base.Emit(ec); ec.EmitInt(0); ec.Emit(OpCodes.Ldelema, ((PointerContainer)type).Element); } } internal class ArrayIndexCast : TypeCast { public ArrayIndexCast(Expression expr, TypeSpec returnType) : base(expr, returnType) { if (expr.Type == returnType) { throw new ArgumentException("unnecessary array index conversion"); } } public override Expression CreateExpressionTree(ResolveContext ec) { using (ec.Set(ResolveContext.Options.CheckedScope)) { return base.CreateExpressionTree(ec); } } public override void Emit(EmitContext ec) { child.Emit(ec); switch (child.Type.BuiltinType) { case BuiltinTypeSpec.Type.UInt: ec.Emit(OpCodes.Conv_U); break; case BuiltinTypeSpec.Type.Long: ec.Emit(OpCodes.Conv_Ovf_I); break; case BuiltinTypeSpec.Type.ULong: ec.Emit(OpCodes.Conv_Ovf_I_Un); break; default: throw new InternalErrorException("Cannot emit cast to unknown array element type", type); } } } internal class StackAlloc : Expression { private TypeSpec otype; private Expression texpr; private Expression count; private MethodSpec ctor; public Expression TypeExpression => texpr; public Expression CountExpression => count; public StackAlloc(Expression type, Expression count, Location l) { texpr = type; this.count = count; loc = l; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext ec) { count = count.Resolve(ec); if (count == null) { return null; } if (count.Type.BuiltinType != BuiltinTypeSpec.Type.UInt) { count = Convert.ImplicitConversionRequired(ec, count, ec.BuiltinTypes.Int, loc); if (count == null) { return null; } } if (count is Constant { IsNegative: not false }) { ec.Report.Error(247, loc, "Cannot use a negative size with stackalloc"); } if (ec.HasAny(ResolveContext.Options.CatchScope | ResolveContext.Options.FinallyScope)) { ec.Report.Error(255, loc, "Cannot use stackalloc in finally or catch"); } otype = texpr.ResolveAsType(ec); if (otype == null) { return null; } if (!TypeManager.VerifyUnmanaged(ec.Module, otype, loc)) { return null; } ResolveExpressionType(ec, otype); eclass = ExprClass.Value; return this; } protected virtual void ResolveExpressionType(ResolveContext rc, TypeSpec elementType) { type = PointerContainer.MakeType(rc.Module, elementType); } public override void Emit(EmitContext ec) { int size = BuiltinTypeSpec.GetSize(otype); count.Emit(ec); bool flag = false; if (ctor != null && !ExpressionAnalyzer.IsInexpensiveLoad(count)) { ec.Emit(OpCodes.Dup); flag = true; } if (size == 0) { ec.Emit(OpCodes.Sizeof, otype); } else { ec.EmitInt(size); } ec.Emit(OpCodes.Mul_Ovf_Un); ec.Emit(OpCodes.Localloc); if (ctor != null) { if (!flag) { count.Emit(ec); } ec.Emit(OpCodes.Newobj, ctor); } } public override void Error_ValueCannotBeConverted(ResolveContext rc, TypeSpec target, bool expl) { TypeSpec element = ((PointerContainer)type).Element; rc.Report.Error(8346, loc, "Cannot convert a stackalloc expression of type `{0}' to type `{1}'", element.GetSignatureForError(), target.GetSignatureForError()); } protected override void CloneTo(CloneContext clonectx, Expression t) { StackAlloc stackAlloc = (StackAlloc)t; stackAlloc.count = count.Clone(clonectx); stackAlloc.texpr = texpr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public bool ResolveSpanConversion(ResolveContext rc, TypeSpec spanType) { ctor = MemberCache.FindMember(spanType, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(PointerContainer.MakeType(rc.Module, rc.Module.Compiler.BuiltinTypes.Void), rc.Module.Compiler.BuiltinTypes.Int)), BindingRestriction.DeclaredOnly) as MethodSpec; if (ctor == null) { type = InternalType.ErrorType; return false; } type = spanType; return true; } } internal class SpanStackAlloc : StackAlloc { public SpanStackAlloc(Expression type, Expression count, Location l) : base(type, count, l) { } protected override void ResolveExpressionType(ResolveContext rc, TypeSpec elementType) { TypeSpec typeSpec = rc.Module.PredefinedTypes.SpanGeneric.Resolve(); if (typeSpec == null) { type = InternalType.ErrorType; return; } type = typeSpec.MakeGenericType(rc, new TypeSpec[1] { elementType }); ResolveSpanConversion(rc, type); } } internal class ElementInitializer : Assign { public readonly string Name; public bool IsDictionaryInitializer => Name == null; public ElementInitializer(string name, Expression initializer, Location loc) : base(null, initializer, loc) { Name = name; } protected override void CloneTo(CloneContext clonectx, Expression t) { ElementInitializer elementInitializer = (ElementInitializer)t; elementInitializer.source = source.Clone(clonectx); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); if (target is FieldExpr fieldExpr) { arguments.Add(new Argument(fieldExpr.CreateTypeOfExpression())); } else { arguments.Add(new Argument(((PropertyExpr)target).CreateSetterTypeOfExpression(ec))); } string name; Expression expr; if (!(source is CollectionOrObjectInitializers collectionOrObjectInitializers)) { name = "Bind"; expr = source.CreateExpressionTree(ec); } else { name = ((collectionOrObjectInitializers.IsEmpty || collectionOrObjectInitializers.Initializers[0] is ElementInitializer) ? "MemberBind" : "ListBind"); expr = collectionOrObjectInitializers.CreateExpressionTree(ec, !collectionOrObjectInitializers.IsEmpty); } arguments.Add(new Argument(expr)); return CreateExpressionFactoryCall(ec, name, arguments); } protected override Expression DoResolve(ResolveContext ec) { if (source == null) { return EmptyExpressionStatement.Instance; } if (!ResolveElement(ec)) { return null; } if (source is CollectionOrObjectInitializers) { target = target.Resolve(ec); if (target == null) { return null; } Expression currentInitializerVariable = ec.CurrentInitializerVariable; ec.CurrentInitializerVariable = target; source = source.Resolve(ec); ec.CurrentInitializerVariable = currentInitializerVariable; if (source == null) { return null; } eclass = source.eclass; type = source.Type; return this; } return base.DoResolve(ec); } public override void EmitStatement(EmitContext ec) { if (source is CollectionOrObjectInitializers) { source.Emit(ec); } else { base.EmitStatement(ec); } } protected virtual bool ResolveElement(ResolveContext rc) { TypeSpec typeSpec = rc.CurrentInitializerVariable.Type; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Arguments arguments = new Arguments(1); arguments.Add(new Argument(rc.CurrentInitializerVariable)); target = new DynamicMemberBinder(Name, arguments, loc); } else { Expression expression = Expression.MemberLookup(rc, errorMode: false, typeSpec, Name, 0, MemberLookupRestrictions.ExactArity, loc); if (expression == null) { expression = Expression.MemberLookup(rc, errorMode: true, typeSpec, Name, 0, MemberLookupRestrictions.ExactArity, loc); if (expression != null) { Expression.ErrorIsInaccesible(rc, expression.GetSignatureForError(), loc); return false; } } if (expression == null) { Expression.Error_TypeDoesNotContainDefinition(rc, loc, typeSpec, Name); return false; } MemberExpr memberExpr = expression as MemberExpr; if (memberExpr is EventExpr) { memberExpr = memberExpr.ResolveMemberAccess(rc, null, null); } else if (!(expression is PropertyExpr) && !(expression is FieldExpr)) { rc.Report.Error(1913, loc, "Member `{0}' cannot be initialized. An object initializer may only be used for fields, or properties", expression.GetSignatureForError()); return false; } if (memberExpr.IsStatic) { rc.Report.Error(1914, loc, "Static field or property `{0}' cannot be assigned in an object initializer", memberExpr.GetSignatureForError()); } target = memberExpr; memberExpr.InstanceExpression = rc.CurrentInitializerVariable; } return true; } } internal class CollectionElementInitializer : Invocation { public class ElementInitializerArgument : Argument { public ElementInitializerArgument(Expression e) : base(e) { } } private sealed class AddMemberAccess : MemberAccess { public AddMemberAccess(Expression expr, Location loc) : base(expr, "Add", loc) { } public override void Error_TypeDoesNotContainDefinition(ResolveContext ec, TypeSpec type, string name) { if (!TypeManager.HasElementType(type)) { base.Error_TypeDoesNotContainDefinition(ec, type, name); } } } public CollectionElementInitializer(Expression argument) : base(null, new Arguments(1)) { arguments.Add(new ElementInitializerArgument(argument)); loc = argument.Location; } public CollectionElementInitializer(List arguments, Location loc) : base(null, new Arguments(arguments.Count)) { foreach (Expression argument in arguments) { base.arguments.Add(new ElementInitializerArgument(argument)); } base.loc = loc; } public CollectionElementInitializer(Location loc) : base(null, null) { base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(mg.CreateExpressionTree(ec))); ArrayInitializer arrayInitializer = new ArrayInitializer(base.arguments.Count, loc); foreach (Argument argument in base.arguments) { if (argument.ArgType == Argument.AType.ExtensionType) { ec.Report.Error(8075, argument.Expr.Location, "An expression tree cannot contain a collection initializer with extension method"); } else { arrayInitializer.Add(argument.CreateExpressionTree(ec)); } } arguments.Add(new Argument(new ArrayCreation(Expression.CreateExpressionTypeExpression(ec, loc), arrayInitializer, loc))); return CreateExpressionFactoryCall(ec, "ElementInit", arguments); } protected override void CloneTo(CloneContext clonectx, Expression t) { CollectionElementInitializer collectionElementInitializer = (CollectionElementInitializer)t; if (arguments != null) { collectionElementInitializer.arguments = arguments.Clone(clonectx); } } protected override Expression DoResolve(ResolveContext ec) { expr = new AddMemberAccess(ec.CurrentInitializerVariable, loc); return base.DoResolve(ec); } } internal class DictionaryElementInitializer : ElementInitializer { private readonly Arguments args; public DictionaryElementInitializer(Arguments arguments, Expression initializer, Location loc) : base(null, initializer, loc) { args = arguments; } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(8074, loc, "Expression tree cannot contain a dictionary initializer"); return null; } protected override bool ResolveElement(ResolveContext rc) { Expression currentInitializerVariable = rc.CurrentInitializerVariable; TypeSpec typeSpec = currentInitializerVariable.Type; if (typeSpec.IsArray) { target = new ArrayAccess(new ElementAccess(currentInitializerVariable, args, loc), loc); return true; } if (typeSpec.IsPointer) { target = currentInitializerVariable.MakePointerAccess(rc, typeSpec, args); return true; } IList list = MemberCache.FindMembers(typeSpec, MemberCache.IndexerNameAlias, declaredOnlyClass: false); if (list == null && typeSpec.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { ElementAccess.Error_CannotApplyIndexing(rc, typeSpec, loc); return false; } target = new IndexerExpr(list, typeSpec, currentInitializerVariable, args, loc); return true; } } internal class CollectionOrObjectInitializers : ExpressionStatement { private IList initializers; private bool is_collection_initialization; public IList Initializers => initializers; public bool IsEmpty => initializers.Count == 0; public bool IsCollectionInitializer => is_collection_initialization; public CollectionOrObjectInitializers(Location loc) : this(new Expression[0], loc) { } public CollectionOrObjectInitializers(IList initializers, Location loc) { this.initializers = initializers; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression target) { CollectionOrObjectInitializers collectionOrObjectInitializers = (CollectionOrObjectInitializers)target; collectionOrObjectInitializers.initializers = new List(initializers.Count); foreach (Expression initializer in initializers) { collectionOrObjectInitializers.initializers.Add(initializer.Clone(clonectx)); } } public override bool ContainsEmitWithAwait() { foreach (Expression initializer in initializers) { if (initializer.ContainsEmitWithAwait()) { return true; } } return false; } public override Expression CreateExpressionTree(ResolveContext ec) { return CreateExpressionTree(ec, inferType: false); } public Expression CreateExpressionTree(ResolveContext ec, bool inferType) { ArrayInitializer arrayInitializer = new ArrayInitializer(initializers.Count, loc); foreach (Expression initializer in initializers) { Expression expression = initializer.CreateExpressionTree(ec); if (expression != null) { arrayInitializer.Add(expression); } } if (inferType) { return new ImplicitlyTypedArrayCreation(arrayInitializer, loc); } return new ArrayCreation(new TypeExpression(ec.Module.PredefinedTypes.MemberBinding.Resolve(), loc), arrayInitializer, loc); } protected override Expression DoResolve(ResolveContext ec) { List list = null; for (int i = 0; i < initializers.Count; i++) { Expression expression = initializers[i]; ElementInitializer elementInitializer = expression as ElementInitializer; if (i == 0) { if (elementInitializer != null) { list = new List(initializers.Count); if (!elementInitializer.IsDictionaryInitializer) { list.Add(elementInitializer.Name); } } else { if (expression is CompletingExpression) { expression.Resolve(ec); throw new InternalErrorException("This line should never be reached"); } TypeSpec typeSpec = ec.CurrentInitializerVariable.Type; if (!typeSpec.ImplementsInterface(ec.BuiltinTypes.IEnumerable, variantly: false) && typeSpec.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { ec.Report.Error(1922, loc, "A field or property `{0}' cannot be initialized with a collection object initializer because type `{1}' does not implement `{2}' interface", ec.CurrentInitializerVariable.GetSignatureForError(), ec.CurrentInitializerVariable.Type.GetSignatureForError(), ec.BuiltinTypes.IEnumerable.GetSignatureForError()); return null; } is_collection_initialization = true; } } else { if (is_collection_initialization != (elementInitializer == null)) { ec.Report.Error(747, expression.Location, "Inconsistent `{0}' member declaration", is_collection_initialization ? "collection initializer" : "object initializer"); continue; } if (!is_collection_initialization && !elementInitializer.IsDictionaryInitializer) { if (list.Contains(elementInitializer.Name)) { ec.Report.Error(1912, elementInitializer.Location, "An object initializer includes more than one member `{0}' initialization", elementInitializer.Name); } else { list.Add(elementInitializer.Name); } } } Expression expression2 = expression.Resolve(ec); if (expression2 == EmptyExpressionStatement.Instance) { initializers.RemoveAt(i--); } else { initializers[i] = expression2; } } type = ec.CurrentInitializerVariable.Type; if (is_collection_initialization && TypeManager.HasElementType(type)) { ec.Report.Error(1925, loc, "Cannot initialize object of type `{0}' with a collection initializer", type.GetSignatureForError()); } eclass = ExprClass.Variable; return this; } public override void Emit(EmitContext ec) { EmitStatement(ec); } public override void EmitStatement(EmitContext ec) { foreach (ExpressionStatement initializer in initializers) { ec.Mark(initializer.Location); initializer.EmitStatement(ec); } } public override void FlowAnalysis(FlowAnalysisContext fc) { foreach (Expression initializer in initializers) { initializer?.FlowAnalysis(fc); } } } internal class NewInitialize : New { private sealed class InitializerTargetExpression : Expression, IMemoryLocation { private NewInitialize new_instance; public InitializerTargetExpression(NewInitialize newInstance) { type = newInstance.type; loc = newInstance.loc; eclass = newInstance.eclass; new_instance = newInstance; } public override bool ContainsEmitWithAwait() { return false; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { return this; } public override void Emit(EmitContext ec) { Expression expression = (Expression)new_instance.instance; expression.Emit(ec); } public override Expression EmitToField(EmitContext ec) { return (Expression)new_instance.instance; } public void AddressOf(EmitContext ec, AddressOp mode) { new_instance.instance.AddressOf(ec, mode); } } private CollectionOrObjectInitializers initializers; private IMemoryLocation instance; private DynamicExpressionStatement dynamic; public CollectionOrObjectInitializers Initializers => initializers; public NewInitialize(FullNamedExpression requested_type, Arguments arguments, CollectionOrObjectInitializers initializers, Location l) : base(requested_type, arguments, l) { this.initializers = initializers; } protected override void CloneTo(CloneContext clonectx, Expression t) { base.CloneTo(clonectx, t); NewInitialize newInitialize = (NewInitialize)t; newInitialize.initializers = (CollectionOrObjectInitializers)initializers.Clone(clonectx); } public override bool ContainsEmitWithAwait() { return base.ContainsEmitWithAwait() || initializers.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(base.CreateExpressionTree(ec))); if (!initializers.IsEmpty) { arguments.Add(new Argument(initializers.CreateExpressionTree(ec, initializers.IsCollectionInitializer))); } return CreateExpressionFactoryCall(ec, initializers.IsCollectionInitializer ? "ListInit" : "MemberInit", arguments); } protected override Expression DoResolve(ResolveContext rc) { Expression expression = base.DoResolve(rc); if (type == null) { return null; } if (type.IsDelegate) { rc.Report.Error(1958, Initializers.Location, "Object and collection initializers cannot be used to instantiate a delegate"); } Expression currentInitializerVariable = rc.CurrentInitializerVariable; rc.CurrentInitializerVariable = new InitializerTargetExpression(this); using (rc.With(ResolveContext.Options.DontSetConditionalAccessReceiver, enable: false)) { initializers.Resolve(rc); } rc.CurrentInitializerVariable = currentInitializerVariable; dynamic = expression as DynamicExpressionStatement; if (dynamic != null) { return this; } return expression; } public override void Emit(EmitContext ec) { if (!CanEmitOptimizedLocalTarget(ec)) { StackFieldExpr temporaryField = ec.GetTemporaryField(type); if (!Emit(ec, temporaryField)) { temporaryField.Emit(ec); } } else { base.Emit(ec); } } public override bool Emit(EmitContext ec, IMemoryLocation target) { IMemoryLocation memoryLocation = target; LocalTemporary localTemporary = null; bool flag = false; if (!initializers.IsEmpty) { memoryLocation = target as LocalTemporary; if (memoryLocation == null) { memoryLocation = target as StackFieldExpr; } if (memoryLocation == null && target is VariableReference { IsRef: not false } variableReference) { variableReference.EmitLoad(ec); flag = true; } if (memoryLocation == null) { memoryLocation = (localTemporary = new LocalTemporary(type)); } } bool flag2; if (dynamic != null) { dynamic.Emit(ec); flag2 = true; } else { flag2 = base.Emit(ec, memoryLocation); } if (initializers.IsEmpty) { return flag2; } StackFieldExpr stackFieldExpr = null; if (flag2) { if (flag) { memoryLocation = (localTemporary = new LocalTemporary(type)); } localTemporary?.Store(ec); if (ec.HasSet(BuilderContext.Options.AsyncBody) && initializers.ContainsEmitWithAwait()) { if (localTemporary == null) { throw new NotImplementedException(); } stackFieldExpr = ec.GetTemporaryField(type); stackFieldExpr.AutomaticallyReuse = false; stackFieldExpr.EmitAssign(ec, localTemporary, leave_copy: false, isCompound: false); memoryLocation = stackFieldExpr; localTemporary.Release(ec); flag2 = false; } } instance = memoryLocation; initializers.Emit(ec); ((Expression)memoryLocation).Emit(ec); localTemporary?.Release(ec); stackFieldExpr?.PrepareCleanup(ec); return true; } public override bool CanEmitOptimizedLocalTarget(EmitContext ec) { return method != null || !TypeSpec.IsValueType(type) || initializers.Initializers.Count <= 1 || !ec.HasSet(BuilderContext.Options.AsyncBody) || !initializers.ContainsEmitWithAwait(); } protected override IMemoryLocation EmitAddressOf(EmitContext ec, AddressOp Mode) { instance = base.EmitAddressOf(ec, Mode); if (!initializers.IsEmpty) { initializers.Emit(ec); } return instance; } public override void FlowAnalysis(FlowAnalysisContext fc) { base.FlowAnalysis(fc); initializers.FlowAnalysis(fc); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class NewAnonymousType : New { private static readonly AnonymousTypeParameter[] EmptyParameters = new AnonymousTypeParameter[0]; private List parameters; private readonly TypeContainer parent; private AnonymousTypeClass anonymous_type; public List Parameters => parameters; public NewAnonymousType(List parameters, TypeContainer parent, Location loc) : base(null, null, loc) { this.parameters = parameters; this.parent = parent; } protected override void CloneTo(CloneContext clonectx, Expression target) { if (parameters == null) { return; } NewAnonymousType newAnonymousType = (NewAnonymousType)target; newAnonymousType.parameters = new List(parameters.Count); foreach (AnonymousTypeParameter parameter in parameters) { newAnonymousType.parameters.Add((AnonymousTypeParameter)parameter.Clone(clonectx)); } } private AnonymousTypeClass CreateAnonymousType(ResolveContext ec, IList parameters) { AnonymousTypeClass anonymousType = parent.Module.GetAnonymousType(parameters); if (anonymousType != null) { return anonymousType; } anonymousType = AnonymousTypeClass.Create(parent, parameters, loc); if (anonymousType == null) { return null; } int errors = ec.Report.Errors; anonymousType.CreateContainer(); anonymousType.DefineContainer(); anonymousType.ExpandBaseInterfaces(); anonymousType.Define(); if (ec.Report.Errors - errors == 0) { parent.Module.AddAnonymousType(anonymousType); anonymousType.PrepareEmit(); } return anonymousType; } public override Expression CreateExpressionTree(ResolveContext ec) { if (parameters == null) { return base.CreateExpressionTree(ec); } ArrayInitializer arrayInitializer = new ArrayInitializer(parameters.Count, loc); foreach (MemberCore member in anonymous_type.Members) { if (member is Property property) { arrayInitializer.Add(new TypeOfMethod(MemberCache.GetMember(type, property.Get.Spec), loc)); } } ArrayInitializer arrayInitializer2 = new ArrayInitializer(base.arguments.Count, loc); foreach (Argument argument in base.arguments) { arrayInitializer2.Add(argument.CreateExpressionTree(ec)); } Arguments arguments = new Arguments(3); arguments.Add(new Argument(new TypeOfMethod(method, loc))); arguments.Add(new Argument(new ArrayCreation(Expression.CreateExpressionTypeExpression(ec, loc), arrayInitializer2, loc))); arguments.Add(new Argument(new ImplicitlyTypedArrayCreation(arrayInitializer, loc))); return CreateExpressionFactoryCall(ec, "New", arguments); } protected override Expression DoResolve(ResolveContext ec) { if (ec.HasSet(ResolveContext.Options.ConstantScope)) { ec.Report.Error(836, loc, "Anonymous types cannot be used in this expression"); return null; } if (parameters == null) { anonymous_type = CreateAnonymousType(ec, EmptyParameters); RequestedType = new TypeExpression(anonymous_type.Definition, loc); return base.DoResolve(ec); } bool flag = false; arguments = new Arguments(parameters.Count); TypeSpec[] array = new TypeSpec[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { Expression expression = parameters[i].Resolve(ec); if (expression == null) { flag = true; continue; } arguments.Add(new Argument(expression)); array[i] = expression.Type; } if (flag) { return null; } anonymous_type = CreateAnonymousType(ec, parameters); if (anonymous_type == null) { return null; } type = anonymous_type.Definition.MakeGenericType(ec.Module, array); method = (MethodSpec)MemberCache.FindMember(type, MemberFilter.Constructor(null), BindingRestriction.DeclaredOnly); eclass = ExprClass.Value; return this; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class AnonymousTypeParameter : ShimExpression { public readonly string Name; public AnonymousTypeParameter(Expression initializer, string name, Location loc) : base(initializer) { Name = name; base.loc = loc; } public AnonymousTypeParameter(Parameter parameter) : base(new SimpleName(parameter.Name, parameter.Location)) { Name = parameter.Name; loc = parameter.Location; } public override bool Equals(object o) { return o is AnonymousTypeParameter anonymousTypeParameter && Name == anonymousTypeParameter.Name; } public override int GetHashCode() { return Name.GetHashCode(); } protected override Expression DoResolve(ResolveContext ec) { Expression expression = expr.Resolve(ec); if (expression == null) { return null; } if (expression.eclass == ExprClass.MethodGroup) { Error_InvalidInitializer(ec, expression.ExprClassName); return null; } type = expression.Type; if (type.Kind == MemberKind.Void || InternalType.HasNoType(type) || type.IsPointer || (expression is TupleLiteral && TupleLiteral.ContainsNoTypeElement(type))) { Error_InvalidInitializer(ec, type.GetSignatureForError()); return null; } return expression; } protected virtual void Error_InvalidInitializer(ResolveContext ec, string initializer) { ec.Report.Error(828, loc, "An anonymous type property `{0}' cannot be initialized with `{1}'", Name, initializer); } } internal class CatchFilterExpression : BooleanExpression { public CatchFilterExpression(Expression expr, Location loc) : base(expr) { base.loc = loc; } } internal class InterpolatedString : Expression { private readonly StringLiteral start; private readonly StringLiteral end; private List interpolations; private Arguments arguments; public InterpolatedString(StringLiteral start, List interpolations, StringLiteral end) { this.start = start; this.end = end; this.interpolations = interpolations; loc = start.Location; } protected override void CloneTo(CloneContext clonectx, Expression t) { InterpolatedString interpolatedString = (InterpolatedString)t; if (interpolations == null) { return; } interpolatedString.interpolations = new List(); foreach (Expression interpolation in interpolations) { interpolatedString.interpolations.Add(interpolation.Clone(clonectx)); } } public Expression ConvertTo(ResolveContext rc, TypeSpec type) { TypeSpec typeSpec = rc.Module.PredefinedTypes.FormattableStringFactory.Resolve(); if (typeSpec == null) { return null; } MemberAccess expr = new MemberAccess(new TypeExpression(typeSpec, loc), "Create", loc); Expression expression = new Invocation(expr, arguments).Resolve(rc); if (expression != null && expression.Type != type) { expression = Convert.ExplicitConversion(rc, expression, type, loc); } return expression; } public override bool ContainsEmitWithAwait() { if (interpolations == null) { return false; } foreach (Expression interpolation in interpolations) { if (interpolation.ContainsEmitWithAwait()) { return true; } } return false; } public override Expression CreateExpressionTree(ResolveContext rc) { MethodSpec methodSpec = ResolveBestFormatOverload(rc); if (methodSpec == null) { return null; } Expression expression = new NullLiteral(loc); Arguments args = Arguments.CreateForExpressionTree(rc, arguments, expression, new TypeOfMethod(methodSpec, loc)); return CreateExpressionFactoryCall(rc, "Call", args); } protected override Expression DoResolve(ResolveContext rc) { string s; if (interpolations == null) { s = start.Value; arguments = new Arguments(1); } else { arguments = new Arguments(interpolations.Count); StringBuilder stringBuilder = new StringBuilder(start.Value); for (int i = 0; i < interpolations.Count; i++) { if (i % 2 == 0) { stringBuilder.Append('{').Append(i / 2); InterpolatedStringInsert interpolatedStringInsert = (InterpolatedStringInsert)interpolations[i]; if (interpolatedStringInsert.Alignment != null) { stringBuilder.Append(','); int? num = interpolatedStringInsert.ResolveAligment(rc); if (num.HasValue) { stringBuilder.Append(num.Value); } } if (interpolatedStringInsert.Format != null) { stringBuilder.Append(':'); stringBuilder.Append(interpolatedStringInsert.Format); } stringBuilder.Append('}'); arguments.Add(new Argument(interpolatedStringInsert.Resolve(rc))); } else { stringBuilder.Append(((StringLiteral)interpolations[i]).Value); } } stringBuilder.Append(end.Value); s = stringBuilder.ToString(); } arguments.Insert(0, new Argument(new StringLiteral(rc.BuiltinTypes, s, start.Location))); eclass = ExprClass.Value; type = rc.BuiltinTypes.String; return this; } public override void Emit(EmitContext ec) { if (interpolations == null) { string text = start.Value.Replace("{{", "{").Replace("}}", "}"); if (text != start.Value) { new StringConstant(ec.BuiltinTypes, text, loc).Emit(ec); } else { start.Emit(ec); } } else { MethodSpec methodSpec = ResolveBestFormatOverload(new ResolveContext(ec.MemberContext)); if (methodSpec != null) { default(CallEmitter).Emit(ec, methodSpec, arguments, loc); } } } public override void FlowAnalysis(FlowAnalysisContext fc) { if (interpolations == null) { return; } foreach (Expression interpolation in interpolations) { interpolation.FlowAnalysis(fc); } } private MethodSpec ResolveBestFormatOverload(ResolveContext rc) { IList members = MemberCache.FindMembers(rc.BuiltinTypes.String, "Format", declaredOnlyClass: true); return new OverloadResolver(members, OverloadResolver.Restrictions.NoBaseMembers, loc).ResolveMember(rc, ref arguments); } } internal class InterpolatedStringInsert : CompositeExpression { public Expression Alignment { get; set; } public string Format { get; set; } public InterpolatedStringInsert(Expression expr) : base(expr) { } protected override void CloneTo(CloneContext clonectx, Expression t) { InterpolatedStringInsert interpolatedStringInsert = (InterpolatedStringInsert)t; interpolatedStringInsert.expr = expr.Clone(clonectx); if (Alignment != null) { interpolatedStringInsert.Alignment = Alignment.Clone(clonectx); } } protected override Expression DoResolve(ResolveContext rc) { Expression expression = base.DoResolve(rc); if (expression == null) { return null; } return Convert.ImplicitConversionRequired(rc, expression, rc.BuiltinTypes.Object, expression.Location); } public override void FlowAnalysis(FlowAnalysisContext fc) { base.Child.FlowAnalysis(fc); } public int? ResolveAligment(ResolveContext rc) { Constant constant = Alignment.ResolveLabelConstant(rc); if (constant == null) { return null; } constant = constant.ImplicitConversionRequired(rc, rc.BuiltinTypes.Int); if (constant == null) { return null; } int num = (int)constant.GetValueAsLong(); if (num > 32767 || num < -32767) { rc.Report.Warning(8094, 1, Alignment.Location, "Alignment value has a magnitude greater than 32767 and may result in a large formatted string"); } return num; } } internal class ThrowExpression : ExpressionStatement { private Expression expr; public ThrowExpression(Expression expr, Location loc) { this.expr = expr; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression t) { ThrowExpression throwExpression = (ThrowExpression)t; throwExpression.expr = expr.Clone(clonectx); } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext rc) { rc.Report.Error(8188, loc, "An expression tree cannot not contain a throw expression"); return expr; } protected override Expression DoResolve(ResolveContext rc) { expr = expr.Resolve(rc, ResolveFlags.VariableOrValue | ResolveFlags.Type); if (expr == null) { return null; } expr = Throw.ConvertType(rc, expr); eclass = ExprClass.Value; type = InternalType.ThrowExpr; return this; } public override void Emit(EmitContext ec) { EmitStatement(ec); } public override void EmitStatement(EmitContext ec) { expr.Emit(ec); ec.Emit(OpCodes.Throw); } public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); } public override Reachability MarkReachable(Reachability rc) { return Reachability.CreateUnreachable(); } } internal class ReferenceExpression : CompositeExpression { public ReferenceExpression(Expression expr, Location loc) : base(expr) { base.loc = loc; } private static bool CanBeByRef(Expression expr) { if (expr is IAssignMethod) { return true; } if (expr is Conditional) { return true; } if (expr is Invocation invocation && invocation.Type.Kind == MemberKind.ByRef) { return true; } return false; } public override Expression CreateExpressionTree(ResolveContext rc) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext rc) { Expression expression = expr.DoResolveLValue(rc, EmptyExpression.OutAccess); if (expression == null || !CanBeByRef(expression)) { if (expression?.Type != InternalType.ErrorType) { rc.Report.Error(8156, expr.Location, "An expression cannot be used in this context because it may not be returned by reference"); } return ErrorExpression.Instance; } type = expression.Type; if (type is ReferenceContainer referenceContainer) { type = referenceContainer.Element; } expr = expression; eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { if (expr is IMemoryLocation memoryLocation) { memoryLocation.AddressOf(ec, AddressOp.LoadStore); } else { expr.Emit(ec); } } public override void Error_ValueCannotBeConverted(ResolveContext rc, TypeSpec target, bool expl) { rc.Report.Error(8173, loc, "The expression must be of type `{0}' because it is being assigned by reference", target.GetSignatureForError()); } } internal class ByRefDereference : CompositeExpression, IMemoryLocation, IAssignMethod { private bool prepared; private LocalTemporary temporary; private ByRefDereference(Expression expr) : base(expr) { } public static Expression Create(Expression expr) { if (!(expr.Type is ReferenceContainer referenceContainer)) { return expr; } return new ByRefDereference(expr) { type = referenceContainer.Element }; } public void AddressOf(EmitContext ec, AddressOp mode) { expr.Emit(ec); } public override Expression CreateExpressionTree(ResolveContext rc) { rc.Report.Error(8153, base.Location, "An expression tree lambda cannot contain a call to a method, property, or indexer that returns by reference"); return null; } public void Emit(EmitContext ec, bool leave_copy) { Emit(ec); if (leave_copy) { ec.Emit(OpCodes.Dup); temporary = new LocalTemporary(type); temporary.Store(ec); } } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { prepared = isCompound; expr.Emit(ec); if (isCompound) { ec.Emit(OpCodes.Dup); } source.Emit(ec); if (leave_copy) { throw new NotImplementedException("leave_copy"); } ec.EmitStoreFromPtr(type); if (temporary != null) { temporary.Emit(ec); temporary.Release(ec); } } protected override Expression DoResolve(ResolveContext rc) { eclass = ExprClass.Variable; return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (expr.ContainsEmitWithAwait()) { rc.Report.Error(8178, loc, "`await' cannot be used in an expression containing a call to `{0}' because it returns by reference", expr.GetSignatureForError()); } return DoResolve(rc); } public override void Emit(EmitContext ec) { if (!prepared) { base.Emit(ec); } ec.EmitLoadFromPtr(type); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class DefaultLiteralExpression : Expression { public DefaultLiteralExpression(Location loc) { base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotImplementedException(); } protected override Expression DoResolve(ResolveContext rc) { type = InternalType.DefaultType; eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { throw new NotSupportedException(); } } internal class Discard : Expression, IAssignMethod, IMemoryLocation { public Discard(Location loc) { base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext rc) { rc.Report.Error(8207, loc, "An expression tree cannot contain a discard"); return null; } protected override Expression DoResolve(ResolveContext rc) { type = InternalType.Discard; eclass = ExprClass.Variable; return this; } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { if (right_side.Type == InternalType.DefaultType) { rc.Report.Error(8183, loc, "Cannot infer the type of implicitly-typed discard"); type = InternalType.ErrorType; return this; } if (right_side.Type.Kind == MemberKind.Void) { rc.Report.Error(8209, loc, "Cannot assign void to a discard"); type = InternalType.ErrorType; return this; } if (right_side != EmptyExpression.OutAccess) { type = right_side.Type; } return this; } public override void Emit(EmitContext ec) { throw new NotImplementedException(); } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { if (leave_copy) { source.Emit(ec); } else { source.EmitSideEffect(ec); } } public void AddressOf(EmitContext ec, AddressOp mode) { LocalBuilder temporaryLocal = ec.GetTemporaryLocal(type); ec.Emit(OpCodes.Ldloca, temporaryLocal); } } internal class FieldDeclarator { public SimpleMemberName Name { get; private set; } public Expression Initializer { get; private set; } public FieldDeclarator(SimpleMemberName name, Expression initializer) { Name = name; Initializer = initializer; } public virtual FullNamedExpression GetFieldTypeExpression(FieldBase field) { return new TypeExpression(field.MemberType, Name.Location); } } internal abstract class FieldBase : MemberBase { [Flags] public enum Status : byte { HAS_OFFSET = 4 } protected FieldBuilder FieldBuilder; protected FieldSpec spec; public Status status; protected Expression initializer; protected List declarators; private static readonly string[] attribute_targets = new string[1] { "field" }; public override AttributeTargets AttributeTargets => AttributeTargets.Field; public List Declarators => declarators; public Expression Initializer { get { return initializer; } set { initializer = value; } } public string Name => base.MemberName.Name; public FieldSpec Spec => spec; public override string[] ValidAttributeTargets => attribute_targets; public override string DocCommentHeader => "F:"; protected FieldBase(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs) : base(parent, type, mod, allowed_mod | Modifiers.ABSTRACT, Modifiers.PRIVATE, name, attrs) { if ((mod & Modifiers.ABSTRACT) != 0) { base.Report.Error(681, base.Location, "The modifier 'abstract' is not valid on fields. Try using a property instead"); } } public void AddDeclarator(FieldDeclarator declarator) { if (declarators == null) { declarators = new List(2); } declarators.Add(declarator); Parent.AddNameToContainer(this, declarator.Name.Value); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.FieldOffset) { status |= Status.HAS_OFFSET; if (!Parent.PartialContainer.HasExplicitLayout) { base.Report.Error(636, base.Location, "The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)"); return; } if ((base.ModFlags & Modifiers.STATIC) != 0 || this is Const) { base.Report.Error(637, base.Location, "The FieldOffset attribute is not allowed on static or const fields"); return; } } if (a.Type == pa.FixedBuffer) { base.Report.Error(1716, base.Location, "Do not use 'System.Runtime.CompilerServices.FixedBuffer' attribute. Use the 'fixed' field modifier instead"); } else if (a.HasSecurityAttribute) { a.Error_InvalidSecurityParent(); } else if (a.Type == pa.Dynamic) { a.Error_MisusedDynamicAttribute(); } else { FieldBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } } public void SetCustomAttribute(MethodSpec ctor, byte[] data) { FieldBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), data); } protected override bool CheckBase() { if (!base.CheckBase()) { return false; } bool overrides = false; MemberSpec bestCandidate; MemberSpec memberSpec = MemberCache.FindBaseMember(this, out bestCandidate, ref overrides); if (memberSpec == null) { memberSpec = bestCandidate; } if (memberSpec == null) { if ((base.ModFlags & Modifiers.NEW) != 0) { base.Report.Warning(109, 4, base.Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError()); } } else { if ((base.ModFlags & (Modifiers.NEW | Modifiers.OVERRIDE | Modifiers.BACKING_FIELD)) == 0) { base.Report.SymbolRelatedToPreviousError(memberSpec); base.Report.Warning(108, 2, base.Location, "`{0}' hides inherited member `{1}'. Use the new keyword if hiding was intended", GetSignatureForError(), memberSpec.GetSignatureForError()); } if (memberSpec.IsAbstract) { base.Report.SymbolRelatedToPreviousError(memberSpec); base.Report.Error(533, base.Location, "`{0}' hides inherited abstract member `{1}'", GetSignatureForError(), memberSpec.GetSignatureForError()); } } return true; } public virtual Constant ConvertInitializer(ResolveContext rc, Constant expr) { return expr.ConvertImplicitly(base.MemberType); } protected override void DoMemberTypeDependentChecks() { base.DoMemberTypeDependentChecks(); if (!base.MemberType.IsGenericParameter) { if (base.MemberType.IsStatic) { Error_VariableOfStaticClass(base.Location, GetSignatureForError(), base.MemberType, base.Report); } if (!base.IsCompilerGenerated) { CheckBase(); } IsTypePermitted(); } } public override void Emit() { if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(FieldBuilder); } else if (!Parent.IsCompilerGenerated && member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(FieldBuilder, member_type, base.Location); } if (member_type.HasNamedTupleElement) { Module.PredefinedAttributes.TupleElementNames.EmitAttribute(FieldBuilder, member_type, base.Location); } if ((base.ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) { Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(FieldBuilder); } if ((base.ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) { Module.PredefinedAttributes.DebuggerBrowsable.EmitAttribute(FieldBuilder, DebuggerBrowsableState.Never); } if (base.OptAttributes != null) { base.OptAttributes.Emit(); } if ((status & Status.HAS_OFFSET) == 0 && (base.ModFlags & (Modifiers.STATIC | Modifiers.BACKING_FIELD)) == 0 && Parent.PartialContainer.HasExplicitLayout) { base.Report.Error(625, base.Location, "`{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute", GetSignatureForError()); } if (!base.IsCompilerGenerated) { ConstraintChecker.Check(this, member_type, type_expr.Location); } base.Emit(); } public static void Error_VariableOfStaticClass(Location loc, string variable_name, TypeSpec static_class, Report Report) { Report.SymbolRelatedToPreviousError(static_class); Report.Error(723, loc, "`{0}': cannot declare variables of static types", variable_name); } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } if (!base.MemberType.IsCLSCompliant() || this is FixedField) { base.Report.Warning(3003, 1, base.Location, "Type of `{0}' is not CLS-compliant", GetSignatureForError()); } return true; } } internal class FieldSpec : MemberSpec, IInterfaceMemberSpec { private FieldInfo metaInfo; private TypeSpec memberType; public bool IsReadOnly => (base.Modifiers & Modifiers.READONLY) != 0; public TypeSpec MemberType => memberType; public FieldSpec(TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, FieldInfo info, Modifiers modifiers) : base(MemberKind.Field, declaringType, definition, modifiers) { metaInfo = info; this.memberType = memberType; } public FieldInfo GetMetaInfo() { if ((state & StateFlags.PendingMetaInflate) != 0) { Type type = base.DeclaringType.GetMetaInfo(); if (base.DeclaringType.IsTypeBuilder) { metaInfo = TypeBuilder.GetField(type, metaInfo); } else { int metadataToken = metaInfo.MetadataToken; metaInfo = type.GetField(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (metaInfo.MetadataToken != metadataToken) { throw new NotImplementedException("Resolved to wrong meta token"); } } state &= ~StateFlags.PendingMetaInflate; } return metaInfo; } public override MemberSpec InflateMember(TypeParameterInflator inflator) { FieldSpec fieldSpec = (FieldSpec)base.InflateMember(inflator); fieldSpec.memberType = inflator.Inflate(memberType); return fieldSpec; } public FieldSpec Mutate(TypeParameterMutator mutator) { TypeSpec typeSpec = base.DeclaringType; if (base.DeclaringType.IsGenericOrParentIsGeneric) { typeSpec = mutator.Mutate(typeSpec); } if (typeSpec == base.DeclaringType) { return this; } FieldSpec fieldSpec = (FieldSpec)MemberwiseClone(); fieldSpec.declaringType = typeSpec; fieldSpec.state |= StateFlags.PendingMetaInflate; fieldSpec.metaInfo = MemberCache.GetMember(TypeParameterMutator.GetMemberDeclaringType(base.DeclaringType), this).metaInfo; return fieldSpec; } public override List ResolveMissingDependencies(MemberSpec caller) { return memberType.ResolveMissingDependencies(this); } } internal class FixedField : FieldBase { public const string FixedElementName = "FixedElementField"; private static int GlobalCounter; private TypeBuilder fixed_buffer_type; private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.UNSAFE; public CharSet? CharSetValue { get; set; } public FixedField(TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base(parent, type, mod, Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.UNSAFE, name, attrs) { } public override Constant ConvertInitializer(ResolveContext rc, Constant expr) { return expr.ImplicitConversionRequired(rc, rc.BuiltinTypes.Int); } public override bool Define() { if (!base.Define()) { return false; } if (!BuiltinTypeSpec.IsPrimitiveType(base.MemberType)) { base.Report.Error(1663, base.Location, "`{0}': Fixed size buffers type must be one of the following: bool, byte, short, int, long, char, sbyte, ushort, uint, ulong, float or double", GetSignatureForError()); } else if (declarators != null) { foreach (FieldDeclarator declarator in declarators) { FixedField fixedField = new FixedField(Parent, declarator.GetFieldTypeExpression(this), base.ModFlags, new MemberName(declarator.Name.Value, declarator.Name.Location), base.OptAttributes); fixedField.initializer = declarator.Initializer; ((ConstInitializer)fixedField.initializer).Name = declarator.Name.Value; fixedField.Define(); Parent.PartialContainer.Members.Add(fixedField); } } string name = $"<{TypeDefinition.FilterNestedName(base.Name)}>__FixedBuffer{GlobalCounter++}"; fixed_buffer_type = Parent.TypeBuilder.DefineNestedType(name, TypeAttributes.NestedPublic | TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit, Compiler.BuiltinTypes.ValueType.GetMetaInfo()); FieldBuilder info = fixed_buffer_type.DefineField("FixedElementField", base.MemberType.GetMetaInfo(), FieldAttributes.Public); FieldBuilder = Parent.TypeBuilder.DefineField(base.Name, fixed_buffer_type, ModifiersExtensions.FieldAttr(base.ModFlags)); FieldSpec element = new FieldSpec(null, this, base.MemberType, info, base.ModFlags); spec = new FixedFieldSpec(Module, Parent.Definition, this, FieldBuilder, element, base.ModFlags); Parent.MemberCache.AddMember(spec); return true; } protected override void DoMemberTypeIndependentChecks() { base.DoMemberTypeIndependentChecks(); if (!base.IsUnsafe) { Expression.UnsafeError(base.Report, base.Location); } if (Parent.PartialContainer.Kind != MemberKind.Struct) { base.Report.Error(1642, base.Location, "`{0}': Fixed size buffer fields may only be members of structs", GetSignatureForError()); } } public override void Emit() { ResolveContext rc = new ResolveContext(this); if (initializer.Resolve(rc) is IntConstant { Value: var value }) { if (value <= 0) { base.Report.Error(1665, base.Location, "`{0}': Fixed size buffers must have a length greater than zero", GetSignatureForError()); return; } EmitFieldSize(value); Module.PredefinedAttributes.UnsafeValueType.EmitAttribute(fixed_buffer_type); Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(fixed_buffer_type); fixed_buffer_type.CreateType(); base.Emit(); } } private void EmitFieldSize(int buffer_size) { int size = BuiltinTypeSpec.GetSize(base.MemberType); if (buffer_size > int.MaxValue / size) { base.Report.Error(1664, base.Location, "Fixed size buffer `{0}' of length `{1}' and type `{2}' exceeded 2^31 limit", GetSignatureForError(), buffer_size.ToString(), base.MemberType.GetSignatureForError()); return; } CharSet v = CharSetValue ?? Module.DefaultCharSet.GetValueOrDefault(); MethodSpec methodSpec = Module.PredefinedMembers.StructLayoutAttributeCtor.Resolve(base.Location); if (methodSpec == null) { return; } FieldSpec fieldSpec = Module.PredefinedMembers.StructLayoutSize.Resolve(base.Location); FieldSpec fieldSpec2 = Module.PredefinedMembers.StructLayoutCharSet.Resolve(base.Location); if (fieldSpec == null || fieldSpec2 == null) { return; } AttributeEncoder attributeEncoder = new AttributeEncoder(); attributeEncoder.Encode((short)0); attributeEncoder.EncodeNamedArguments(new FieldSpec[2] { fieldSpec, fieldSpec2 }, new Constant[2] { new IntConstant(Compiler.BuiltinTypes, buffer_size * size, base.Location), new IntConstant(Compiler.BuiltinTypes, (int)v, base.Location) }); fixed_buffer_type.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var _)); if ((base.ModFlags & Modifiers.PRIVATE) == 0) { methodSpec = Module.PredefinedMembers.FixedBufferAttributeCtor.Resolve(base.Location); if (methodSpec != null) { attributeEncoder = new AttributeEncoder(); attributeEncoder.EncodeTypeName(base.MemberType); attributeEncoder.Encode(buffer_size); attributeEncoder.EncodeEmptyNamedArguments(); FieldBuilder.SetCustomAttribute((ConstructorInfo)methodSpec.GetMetaInfo(), attributeEncoder.ToArray(out var assemblyReferences2)); Module.AddAssemblyReferences(assemblyReferences2); } } } } internal class FixedFieldSpec : FieldSpec { private readonly FieldSpec element; public FieldSpec Element => element; public TypeSpec ElementType => element.MemberType; public FixedFieldSpec(ModuleContainer module, TypeSpec declaringType, IMemberDefinition definition, FieldInfo info, FieldSpec element, Modifiers modifiers) : base(declaringType, definition, PointerContainer.MakeType(module, element.MemberType), info, modifiers) { this.element = element; state &= ~StateFlags.CLSCompliant_Undetected; } } internal class Field : FieldBase { private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.STATIC | Modifiers.READONLY | Modifiers.VOLATILE | Modifiers.UNSAFE; public Field(TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base(parent, type, mod, Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.STATIC | Modifiers.READONLY | Modifiers.VOLATILE | Modifiers.UNSAFE, name, attrs) { } private bool CanBeVolatile() { switch (base.MemberType.BuiltinType) { case BuiltinTypeSpec.Type.FirstPrimitive: case BuiltinTypeSpec.Type.Byte: case BuiltinTypeSpec.Type.SByte: case BuiltinTypeSpec.Type.Char: case BuiltinTypeSpec.Type.Short: case BuiltinTypeSpec.Type.UShort: case BuiltinTypeSpec.Type.Int: case BuiltinTypeSpec.Type.UInt: case BuiltinTypeSpec.Type.Float: case BuiltinTypeSpec.Type.IntPtr: case BuiltinTypeSpec.Type.UIntPtr: return true; default: if (TypeSpec.IsReferenceType(base.MemberType)) { return true; } if (base.MemberType.IsPointer) { return true; } if (base.MemberType.IsEnum) { BuiltinTypeSpec.Type builtinType = EnumSpec.GetUnderlyingType(base.MemberType).BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 2) <= 1u || (uint)(type - 5) <= 3u) { return true; } return false; } return false; } } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override bool Define() { if (!base.Define()) { return false; } Type[] requiredCustomModifiers = null; if ((base.ModFlags & Modifiers.VOLATILE) != 0) { TypeSpec typeSpec = Module.PredefinedTypes.IsVolatile.Resolve(); if (typeSpec != null) { requiredCustomModifiers = new Type[1] { typeSpec.GetMetaInfo() }; } } FieldBuilder = Parent.TypeBuilder.DefineField(base.Name, member_type.GetMetaInfo(), requiredCustomModifiers, null, ModifiersExtensions.FieldAttr(base.ModFlags)); spec = new FieldSpec(Parent.Definition, this, base.MemberType, FieldBuilder, base.ModFlags); if ((base.ModFlags & Modifiers.BACKING_FIELD) == 0 || Parent.Kind == MemberKind.Struct) { Parent.MemberCache.AddMember(spec); } if (initializer != null) { Parent.RegisterFieldForInitialization(this, new FieldInitializer(this, initializer, base.TypeExpression.Location)); } if (declarators != null) { foreach (FieldDeclarator declarator in declarators) { Field field = new Field(Parent, declarator.GetFieldTypeExpression(this), base.ModFlags, new MemberName(declarator.Name.Value, declarator.Name.Location), base.OptAttributes); if (declarator.Initializer != null) { field.initializer = declarator.Initializer; } field.Define(); Parent.PartialContainer.Members.Add(field); } } return true; } protected override void DoMemberTypeIndependentChecks() { if ((Parent.PartialContainer.ModFlags & Modifiers.READONLY) != 0 && (base.ModFlags & (Modifiers.STATIC | Modifiers.READONLY)) == 0) { base.Report.Error(8340, base.Location, "`{0}': Instance fields in readonly structs must be readonly", GetSignatureForError()); } base.DoMemberTypeIndependentChecks(); } protected override void DoMemberTypeDependentChecks() { if ((base.ModFlags & Modifiers.BACKING_FIELD) != 0) { return; } base.DoMemberTypeDependentChecks(); if ((base.ModFlags & Modifiers.VOLATILE) != 0) { if (!CanBeVolatile()) { base.Report.Error(677, base.Location, "`{0}': A volatile field cannot be of the type `{1}'", GetSignatureForError(), base.MemberType.GetSignatureForError()); } if ((base.ModFlags & Modifiers.READONLY) != 0) { base.Report.Error(678, base.Location, "`{0}': A field cannot be both volatile and readonly", GetSignatureForError()); } } } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } if ((base.ModFlags & Modifiers.VOLATILE) != 0) { base.Report.Warning(3026, 1, base.Location, "CLS-compliant field `{0}' cannot be volatile", GetSignatureForError()); } return true; } } internal class PrimaryConstructorField : Field { private sealed class TypeExpressionFromParameter : TypeExpr { private Parameter parameter; public TypeExpressionFromParameter(Parameter parameter) { this.parameter = parameter; eclass = ExprClass.Type; loc = parameter.Location; } public override TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments) { return parameter.Type; } } public PrimaryConstructorField(TypeDefinition parent, Parameter parameter) : base(parent, new TypeExpressionFromParameter(parameter), Modifiers.PRIVATE, new MemberName(parameter.Name, parameter.Location), null) { caching_flags |= Flags.IsUsed | Flags.IsAssigned; } public override string GetSignatureForError() { return base.MemberName.Name; } } internal class TypeInfo { private class StructInfo { private readonly List fields; public readonly TypeInfo[] StructFields; public readonly int Length; public readonly int TotalLength; public static Dictionary field_type_hash; private Dictionary struct_field_hash; private Dictionary field_hash; private bool InTransit; public int Count => fields.Count; public List Fields => fields; public int this[string name] { get { if (!field_hash.TryGetValue(name, out var value)) { return 0; } return value; } } private StructInfo(TypeSpec type, IMemberContext context) { field_type_hash.Add(type, this); fields = MemberCache.GetAllFieldsForDefiniteAssignment(type, context); struct_field_hash = new Dictionary(); field_hash = new Dictionary(fields.Count); StructFields = new TypeInfo[fields.Count]; StructInfo[] array = new StructInfo[fields.Count]; InTransit = true; for (int i = 0; i < fields.Count; i++) { FieldSpec fieldSpec = fields[i]; if (fieldSpec.MemberType.IsStruct) { array[i] = GetStructInfo(fieldSpec.MemberType, context); } if (array[i] == null) { field_hash.Add(fieldSpec.Name, ++Length); } else if (array[i].InTransit) { array[i] = null; return; } } InTransit = false; TotalLength = Length + 1; for (int j = 0; j < fields.Count; j++) { FieldSpec fieldSpec2 = fields[j]; if (array[j] != null) { field_hash.Add(fieldSpec2.Name, TotalLength); StructFields[j] = new TypeInfo(array[j], TotalLength); struct_field_hash.Add(fieldSpec2.Name, StructFields[j]); TotalLength += array[j].TotalLength; } } } public TypeInfo GetStructField(string name) { if (struct_field_hash.TryGetValue(name, out var value)) { return value; } return null; } public static StructInfo GetStructInfo(TypeSpec type, IMemberContext context) { if (type.BuiltinType > BuiltinTypeSpec.Type.None && type != context.CurrentType) { return null; } if (field_type_hash.TryGetValue(type, out var value)) { return value; } return new StructInfo(type, context); } } public readonly int TotalLength; public readonly int Length; public readonly int Offset; public readonly bool IsStruct; public TypeInfo[] SubStructInfo; private readonly StructInfo struct_info; private static readonly TypeInfo simple_type; static TypeInfo() { simple_type = new TypeInfo(1); Reset(); } public static void Reset() { StructInfo.field_type_hash = new Dictionary(); } private TypeInfo(int totalLength) { TotalLength = totalLength; } private TypeInfo(StructInfo struct_info, int offset) { this.struct_info = struct_info; Offset = offset; Length = struct_info.Length; TotalLength = struct_info.TotalLength; SubStructInfo = struct_info.StructFields; IsStruct = true; } public int GetFieldIndex(string name) { if (struct_info == null) { return 0; } return struct_info[name]; } public TypeInfo GetStructField(string name) { if (struct_info == null) { return null; } return struct_info.GetStructField(name); } public static TypeInfo GetTypeInfo(TypeSpec type, IMemberContext context) { if (!type.IsStruct) { return simple_type; } Dictionary dictionary; TypeInfo value; if (type.BuiltinType > BuiltinTypeSpec.Type.None) { dictionary = null; } else { dictionary = context.Module.TypeInfoCache; if (dictionary.TryGetValue(type, out value)) { return value; } } StructInfo structInfo = StructInfo.GetStructInfo(type, context); value = ((structInfo == null) ? simple_type : new TypeInfo(structInfo, 0)); dictionary?.Add(type, value); return value; } public bool IsFullyInitialized(FlowAnalysisContext fc, VariableInfo vi, Location loc) { if (struct_info == null) { return true; } bool result = true; for (int i = 0; i < struct_info.Count; i++) { FieldSpec fieldSpec = struct_info.Fields[i]; if (fc.IsStructFieldDefinitelyAssigned(vi, fieldSpec.Name)) { continue; } if (fieldSpec.MemberDefinition is Property.BackingFieldDeclaration backingFieldDeclaration) { if (backingFieldDeclaration.Initializer == null) { fc.Report.Error(843, loc, "An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer", fieldSpec.GetSignatureForError()); result = false; } } else { fc.Report.Error(171, loc, "Field `{0}' must be fully assigned before control leaves the constructor", fieldSpec.GetSignatureForError()); result = false; } } return result; } public override string ToString() { return $"TypeInfo ({Offset}:{Length}:{TotalLength})"; } } internal class VariableInfo { private readonly string Name; private readonly TypeInfo TypeInfo; private readonly int Offset; private readonly int Length; public bool IsParameter; private VariableInfo[] sub_info; public bool IsEverAssigned { get; set; } private VariableInfo(string name, TypeSpec type, int offset, IMemberContext context) { Name = name; Offset = offset; TypeInfo = TypeInfo.GetTypeInfo(type, context); Length = TypeInfo.TotalLength; Initialize(); } private VariableInfo(VariableInfo parent, TypeInfo type) { Name = parent.Name; TypeInfo = type; Offset = parent.Offset + type.Offset; Length = type.TotalLength; IsParameter = parent.IsParameter; Initialize(); } private void Initialize() { TypeInfo[] subStructInfo = TypeInfo.SubStructInfo; if (subStructInfo != null) { sub_info = new VariableInfo[subStructInfo.Length]; for (int i = 0; i < subStructInfo.Length; i++) { if (subStructInfo[i] != null) { sub_info[i] = new VariableInfo(this, subStructInfo[i]); } } } else { sub_info = new VariableInfo[0]; } } public static VariableInfo Create(BlockContext bc, LocalVariable variable) { VariableInfo variableInfo = new VariableInfo(variable.Name, variable.Type, bc.AssignmentInfoOffset, bc); bc.AssignmentInfoOffset += variableInfo.Length; return variableInfo; } public static VariableInfo Create(BlockContext bc, Parameter parameter) { VariableInfo variableInfo = new VariableInfo(parameter.Name, parameter.Type, bc.AssignmentInfoOffset, bc) { IsParameter = true }; bc.AssignmentInfoOffset += variableInfo.Length; return variableInfo; } public bool IsAssigned(DefiniteAssignmentBitSet vector) { if (vector == null) { return true; } if (vector[Offset]) { return true; } if (!TypeInfo.IsStruct) { return false; } for (int i = Offset + 1; i <= TypeInfo.Length + Offset; i++) { if (!vector[i]) { return false; } } for (int j = 0; j < sub_info.Length; j++) { VariableInfo variableInfo = sub_info[j]; if (variableInfo != null && !variableInfo.IsAssigned(vector)) { return false; } } vector.Set(Offset); return true; } public bool IsFullyInitialized(FlowAnalysisContext fc, Location loc) { return TypeInfo.IsFullyInitialized(fc, this, loc); } public bool IsStructFieldAssigned(DefiniteAssignmentBitSet vector, string field_name) { int fieldIndex = TypeInfo.GetFieldIndex(field_name); if (fieldIndex == 0) { return true; } return vector[Offset + fieldIndex]; } public void SetAssigned(DefiniteAssignmentBitSet vector, bool generatedAssignment) { if (Length == 1) { vector.Set(Offset); } else { vector.Set(Offset, Length); } if (!generatedAssignment) { IsEverAssigned = true; } } public void SetStructFieldAssigned(DefiniteAssignmentBitSet vector, string field_name) { if (vector[Offset]) { return; } int fieldIndex = TypeInfo.GetFieldIndex(field_name); if (fieldIndex == 0) { return; } TypeInfo structField = TypeInfo.GetStructField(field_name); if (structField != null) { vector.Set(Offset + structField.Offset, structField.TotalLength); } else { vector.Set(Offset + fieldIndex); } IsEverAssigned = true; for (int i = Offset + 1; i < TypeInfo.TotalLength + Offset; i++) { if (!vector[i]) { return; } } vector.Set(Offset); } public VariableInfo GetStructFieldInfo(string fieldName) { TypeInfo structField = TypeInfo.GetStructField(fieldName); if (structField == null) { return null; } return new VariableInfo(this, structField); } public override string ToString() { return $"Name={Name} Offset={Offset} Length={Length} {TypeInfo})"; } } internal struct Reachability { private readonly bool unreachable; public bool IsUnreachable => unreachable; private Reachability(bool unreachable) { this.unreachable = unreachable; } public static Reachability CreateUnreachable() { return new Reachability(unreachable: true); } public static Reachability operator &(Reachability a, Reachability b) { return new Reachability(a.unreachable && b.unreachable); } public static Reachability operator |(Reachability a, Reachability b) { return new Reachability(a.unreachable | b.unreachable); } } internal class DefiniteAssignmentBitSet { private const uint copy_on_write_flag = 2147483648u; private uint bits; private int[] large_bits; public static readonly DefiniteAssignmentBitSet Empty = new DefiniteAssignmentBitSet(0); private bool CopyOnWrite => (bits & 0x80000000u) != 0; private int Length => (large_bits == null) ? 31 : (large_bits.Length * 32); public bool this[int index] => GetBit(index); public DefiniteAssignmentBitSet(int length) { if (length > 31) { large_bits = new int[(length + 31) / 32]; } } public DefiniteAssignmentBitSet(DefiniteAssignmentBitSet source) { if (source.large_bits != null) { large_bits = source.large_bits; bits = source.bits | 0x80000000u; } else { bits = source.bits & 0x7FFFFFFF; } } public static DefiniteAssignmentBitSet operator &(DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) { if (IsEqual(a, b)) { return a; } DefiniteAssignmentBitSet definiteAssignmentBitSet; if (a.large_bits == null) { definiteAssignmentBitSet = new DefiniteAssignmentBitSet(a); definiteAssignmentBitSet.bits &= b.bits & 0x7FFFFFFF; return definiteAssignmentBitSet; } definiteAssignmentBitSet = new DefiniteAssignmentBitSet(a); definiteAssignmentBitSet.Clone(); int[] array = definiteAssignmentBitSet.large_bits; int[] array2 = b.large_bits; for (int i = 0; i < array.Length; i++) { array[i] &= array2[i]; } return definiteAssignmentBitSet; } public static DefiniteAssignmentBitSet operator |(DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) { if (IsEqual(a, b)) { return a; } DefiniteAssignmentBitSet definiteAssignmentBitSet; if (a.large_bits == null) { definiteAssignmentBitSet = new DefiniteAssignmentBitSet(a); definiteAssignmentBitSet.bits |= b.bits; definiteAssignmentBitSet.bits &= 2147483647u; return definiteAssignmentBitSet; } definiteAssignmentBitSet = new DefiniteAssignmentBitSet(a); definiteAssignmentBitSet.Clone(); int[] array = definiteAssignmentBitSet.large_bits; int[] array2 = b.large_bits; for (int i = 0; i < array.Length; i++) { array[i] |= array2[i]; } return definiteAssignmentBitSet; } public static DefiniteAssignmentBitSet And(List das) { if (das.Count == 0) { throw new ArgumentException("Empty das"); } DefiniteAssignmentBitSet result = das[0]; for (int i = 1; i < das.Count; i++) { result &= das[i]; } return result; } public void Set(int index) { if (CopyOnWrite && !this[index]) { Clone(); } SetBit(index); } public void Set(int index, int length) { for (int i = 0; i < length; i++) { if (CopyOnWrite && !this[index + i]) { Clone(); } SetBit(index + i); } } public override string ToString() { int length = Length; StringBuilder stringBuilder = new StringBuilder(length); for (int i = 0; i < length; i++) { stringBuilder.Append(this[i] ? '1' : '0'); } return stringBuilder.ToString(); } private void Clone() { large_bits = (int[])large_bits.Clone(); } private bool GetBit(int index) { return (large_bits == null) ? ((bits & (1 << index)) != 0) : ((large_bits[index >> 5] & (1 << index)) != 0); } private void SetBit(int index) { if (large_bits == null) { bits |= (uint)(1 << index); } else { large_bits[index >> 5] |= 1 << index; } } private static bool IsEqual(DefiniteAssignmentBitSet a, DefiniteAssignmentBitSet b) { if (a.large_bits == null) { return (a.bits & 0x7FFFFFFF) == (b.bits & 0x7FFFFFFF); } for (int i = 0; i < a.large_bits.Length; i++) { if (a.large_bits[i] != b.large_bits[i]) { return false; } } return true; } public static bool IsIncluded(DefiniteAssignmentBitSet set, DefiniteAssignmentBitSet test) { int[] array = set.large_bits; if (array == null) { return (set.bits & test.bits & 0x7FFFFFFF) == (set.bits & 0x7FFFFFFF); } int[] array2 = test.large_bits; for (int i = 0; i < array.Length; i++) { if ((array[i] & array2[i]) != array[i]) { return false; } } return true; } } internal class VarianceDecl { public Variance Variance { get; private set; } public Location Location { get; private set; } public VarianceDecl(Variance variance, Location loc) { Variance = variance; Location = loc; } public static Variance CheckTypeVariance(TypeSpec t, Variance expected, IMemberContext member) { if (t is TypeParameterSpec { Variance: var variance } typeParameterSpec) { if ((expected == Variance.None && variance != expected) || (expected == Variance.Covariant && variance == Variance.Contravariant) || (expected == Variance.Contravariant && variance == Variance.Covariant)) { ((TypeParameter)typeParameterSpec.MemberDefinition).ErrorInvalidVariance(member, expected); } return expected; } if (t.TypeArguments.Length != 0) { TypeParameterSpec[] typeParameters = t.MemberDefinition.TypeParameters; TypeSpec[] typeArguments = TypeManager.GetTypeArguments(t); for (int i = 0; i < typeArguments.Length; i++) { Variance variance2 = typeParameters[i].Variance; CheckTypeVariance(typeArguments[i], (Variance)((int)variance2 * (int)expected), member); } return expected; } if (t is ArrayContainer arrayContainer) { return CheckTypeVariance(arrayContainer.Element, expected, member); } return Variance.None; } } internal enum Variance { None = 0, Covariant = 1, Contravariant = -1 } [Flags] internal enum SpecialConstraint { None = 0, Constructor = 4, Class = 8, Struct = 0x10 } internal class SpecialContraintExpr : FullNamedExpression { public SpecialConstraint Constraint { get; private set; } public SpecialContraintExpr(SpecialConstraint constraint, Location loc) { base.loc = loc; Constraint = constraint; } protected override Expression DoResolve(ResolveContext rc) { throw new NotImplementedException(); } public override FullNamedExpression ResolveAsTypeOrNamespace(IMemberContext mc, bool allowUnboundTypeArguments) { throw new NotImplementedException(); } } internal class Constraints { private readonly SimpleMemberName tparam; private readonly List constraints; private readonly Location loc; private bool resolved; private bool resolving; public List TypeExpressions => constraints; public Location Location => loc; public SimpleMemberName TypeParameter => tparam; public Constraints(SimpleMemberName tparam, List constraints, Location loc) { this.tparam = tparam; this.constraints = constraints; this.loc = loc; } public static bool CheckConflictingInheritedConstraint(TypeParameterSpec spec, TypeSpec bb, IMemberContext context, Location loc) { if (spec.HasSpecialClass && bb.IsStruct) { context.Module.Compiler.Report.Error(455, loc, "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'", spec.Name, "class", bb.GetSignatureForError()); return false; } return CheckConflictingInheritedConstraint(spec, spec.BaseType, bb, context, loc); } private static bool CheckConflictingInheritedConstraint(TypeParameterSpec spec, TypeSpec ba, TypeSpec bb, IMemberContext context, Location loc) { if (ba == bb) { return true; } if (TypeSpec.IsBaseClass(ba, bb, dynamicIsObject: false) || TypeSpec.IsBaseClass(bb, ba, dynamicIsObject: false)) { return true; } Error_ConflictingConstraints(context, spec, ba, bb, loc); return false; } public static void Error_ConflictingConstraints(IMemberContext context, TypeParameterSpec tp, TypeSpec ba, TypeSpec bb, Location loc) { context.Module.Compiler.Report.Error(455, loc, "Type parameter `{0}' inherits conflicting constraints `{1}' and `{2}'", tp.Name, ba.GetSignatureForError(), bb.GetSignatureForError()); } public void CheckGenericConstraints(IMemberContext context, bool obsoleteCheck) { foreach (FullNamedExpression constraint in constraints) { if (constraint == null) { continue; } TypeSpec type = constraint.Type; if (type != null) { if (obsoleteCheck) { type.CheckObsoleteness(context, constraint.Location); } ConstraintChecker.Check(context, type, constraint.Location); } } } public bool Resolve(IMemberContext context, TypeParameter tp) { if (resolved) { return true; } if (resolving) { return false; } resolving = true; TypeParameterSpec type = tp.Type; List list = null; bool flag = false; type.BaseType = context.Module.Compiler.BuiltinTypes.Object; for (int i = 0; i < constraints.Count; i++) { FullNamedExpression fullNamedExpression = constraints[i]; if (fullNamedExpression is SpecialContraintExpr) { type.SpecialConstraint |= ((SpecialContraintExpr)fullNamedExpression).Constraint; if (type.HasSpecialStruct) { type.BaseType = context.Module.Compiler.BuiltinTypes.ValueType; } constraints[i] = null; continue; } TypeSpec typeSpec = fullNamedExpression.ResolveAsType(context); if (typeSpec == null) { continue; } if (typeSpec.Arity > 0 && ((InflatedTypeSpec)typeSpec).HasDynamicArgument()) { context.Module.Compiler.Report.Error(1968, fullNamedExpression.Location, "A constraint cannot be the dynamic type `{0}'", typeSpec.GetSignatureForError()); continue; } if (!context.CurrentMemberDefinition.IsAccessibleAs(typeSpec)) { context.Module.Compiler.Report.SymbolRelatedToPreviousError(typeSpec); context.Module.Compiler.Report.Error(703, loc, "Inconsistent accessibility: constraint type `{0}' is less accessible than `{1}'", typeSpec.GetSignatureForError(), context.GetSignatureForError()); } if (typeSpec.IsInterface) { if (!type.AddInterface(typeSpec)) { context.Module.Compiler.Report.Error(405, fullNamedExpression.Location, "Duplicate constraint `{0}' for type parameter `{1}'", typeSpec.GetSignatureForError(), tparam.Value); } flag = true; continue; } if (typeSpec is TypeParameterSpec typeParameterSpec) { if (list == null) { list = new List(2); } else if (list.Contains(typeParameterSpec)) { context.Module.Compiler.Report.Error(405, fullNamedExpression.Location, "Duplicate constraint `{0}' for type parameter `{1}'", typeSpec.GetSignatureForError(), tparam.Value); continue; } if (tp.IsMethodTypeParameter) { VarianceDecl.CheckTypeVariance(typeSpec, Variance.Contravariant, context); } if (typeParameterSpec.MemberDefinition is TypeParameter typeParameter && !typeParameter.ResolveConstraints(context)) { context.Module.Compiler.Report.Error(454, fullNamedExpression.Location, "Circular constraint dependency involving `{0}' and `{1}'", typeParameterSpec.GetSignatureForError(), tp.GetSignatureForError()); continue; } if (typeParameterSpec.HasTypeConstraint) { if (type.HasTypeConstraint || type.HasSpecialStruct) { if (!CheckConflictingInheritedConstraint(type, typeParameterSpec.BaseType, context, fullNamedExpression.Location)) { continue; } } else { for (int j = 0; j < list.Count && (!list[j].HasTypeConstraint || CheckConflictingInheritedConstraint(type, list[j].BaseType, typeParameterSpec.BaseType, context, fullNamedExpression.Location)); j++) { } } } if (typeParameterSpec.TypeArguments != null) { TypeSpec effectiveBase = typeParameterSpec.GetEffectiveBase(); if (effectiveBase != null && !CheckConflictingInheritedConstraint(type, effectiveBase, type.BaseType, context, fullNamedExpression.Location)) { break; } } if (typeParameterSpec.HasSpecialStruct) { context.Module.Compiler.Report.Error(456, fullNamedExpression.Location, "Type parameter `{0}' has the `struct' constraint, so it cannot be used as a constraint for `{1}'", typeParameterSpec.GetSignatureForError(), tp.GetSignatureForError()); } else { list.Add(typeParameterSpec); } continue; } if (flag || type.HasTypeConstraint) { context.Module.Compiler.Report.Error(406, fullNamedExpression.Location, "The class type constraint `{0}' must be listed before any other constraints. Consider moving type constraint to the beginning of the constraint list", typeSpec.GetSignatureForError()); } if (type.HasSpecialStruct || type.HasSpecialClass) { context.Module.Compiler.Report.Error(450, fullNamedExpression.Location, "`{0}': cannot specify both a constraint class and the `class' or `struct' constraint", typeSpec.GetSignatureForError()); } switch (typeSpec.BuiltinType) { case BuiltinTypeSpec.Type.Object: case BuiltinTypeSpec.Type.ValueType: case BuiltinTypeSpec.Type.Enum: case BuiltinTypeSpec.Type.Delegate: case BuiltinTypeSpec.Type.MulticastDelegate: case BuiltinTypeSpec.Type.Array: context.Module.Compiler.Report.Error(702, fullNamedExpression.Location, "A constraint cannot be special class `{0}'", typeSpec.GetSignatureForError()); continue; case BuiltinTypeSpec.Type.Dynamic: context.Module.Compiler.Report.Error(1967, fullNamedExpression.Location, "A constraint cannot be the dynamic type"); continue; } if (typeSpec.IsSealed || !typeSpec.IsClass) { context.Module.Compiler.Report.Error(701, loc, "`{0}' is not a valid constraint. A constraint must be an interface, a non-sealed class or a type parameter", typeSpec.GetSignatureForError()); continue; } if (typeSpec.IsStatic) { context.Module.Compiler.Report.Error(717, fullNamedExpression.Location, "`{0}' is not a valid constraint. Static classes cannot be used as constraints", typeSpec.GetSignatureForError()); } type.BaseType = typeSpec; } if (list != null) { TypeSpec[] typeArguments = list.ToArray(); type.TypeArguments = typeArguments; } resolving = false; resolved = true; return true; } public void VerifyClsCompliance(Report report) { foreach (FullNamedExpression constraint in constraints) { if (constraint != null && !constraint.Type.IsCLSCompliant()) { report.SymbolRelatedToPreviousError(constraint.Type); report.Warning(3024, 1, loc, "Constraint type `{0}' is not CLS-compliant", constraint.Type.GetSignatureForError()); } } } } internal class TypeParameter : MemberCore, ITypeDefinition, IMemberDefinition { private static readonly string[] attribute_target = new string[1] { "type parameter" }; private Constraints constraints; private GenericTypeParameterBuilder builder; private readonly TypeParameterSpec spec; public override AttributeTargets AttributeTargets => AttributeTargets.GenericParameter; public Constraints Constraints { get { return constraints; } set { constraints = value; } } public IAssemblyDefinition DeclaringAssembly => Module.DeclaringAssembly; public override string DocCommentHeader { get { throw new InvalidOperationException("Unexpected attempt to get doc comment from " + GetType()); } } bool ITypeDefinition.IsComImport => false; bool ITypeDefinition.IsPartial => false; public bool IsMethodTypeParameter => spec.IsMethodOwned; bool ITypeDefinition.IsTypeForwarder => false; bool ITypeDefinition.IsCyclicTypeForwarder => false; public string Name => base.MemberName.Name; public string Namespace => null; public TypeParameterSpec Type => spec; public int TypeParametersCount => 0; public TypeParameterSpec[] TypeParameters => null; public override string[] ValidAttributeTargets => attribute_target; public Variance Variance => spec.Variance; public VarianceDecl VarianceDecl { get; private set; } public TypeParameter(int index, MemberName name, Constraints constraints, Attributes attrs, Variance Variance) : base(null, name, attrs) { this.constraints = constraints; spec = new TypeParameterSpec(null, index, this, SpecialConstraint.None, Variance, null); } public TypeParameter(MemberName name, Attributes attrs, VarianceDecl variance) : base(null, name, attrs) { spec = new TypeParameterSpec(null, -1, this, SpecialConstraint.None, variance?.Variance ?? Variance.None, null); VarianceDecl = variance; } public TypeParameter(TypeParameterSpec spec, TypeSpec parentSpec, MemberName name, Attributes attrs) : base(null, name, attrs) { this.spec = new TypeParameterSpec(parentSpec, spec.DeclaredPosition, this, spec.SpecialConstraint, spec.Variance, null) { BaseType = spec.BaseType, InterfacesDefined = spec.InterfacesDefined, TypeArguments = spec.TypeArguments }; } public bool AddPartialConstraints(TypeDefinition part, TypeParameter tp) { if ((object)builder == null) { throw new InvalidOperationException(); } Constraints constraints = tp.constraints; if (constraints == null) { return true; } tp.spec.DeclaringType = part.Definition; if (!tp.ResolveConstraints(part)) { return false; } if (this.constraints != null) { return spec.HasSameConstraintsDefinition(tp.Type); } spec.SpecialConstraint = tp.spec.SpecialConstraint; spec.InterfacesDefined = tp.spec.InterfacesDefined; spec.TypeArguments = tp.spec.TypeArguments; spec.BaseType = tp.spec.BaseType; return true; } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { builder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } public void CheckGenericConstraints(bool obsoleteCheck) { if (constraints != null) { constraints.CheckGenericConstraints(this, obsoleteCheck); } } public TypeParameter CreateHoistedCopy(TypeSpec declaringSpec) { return new TypeParameter(spec, declaringSpec, base.MemberName, null); } public override bool Define() { return true; } public void Create(TypeSpec declaringType, TypeContainer parent) { if ((object)builder != null) { throw new InternalErrorException(); } Parent = parent; spec.DeclaringType = declaringType; } public void Define(GenericTypeParameterBuilder type) { builder = type; spec.SetMetaInfo(type); } public void Define(TypeParameter tp) { builder = tp.builder; } public void EmitConstraints(GenericTypeParameterBuilder builder) { GenericParameterAttributes genericParameterAttributes = GenericParameterAttributes.None; if (spec.Variance == Variance.Contravariant) { genericParameterAttributes |= GenericParameterAttributes.Contravariant; } else if (spec.Variance == Variance.Covariant) { genericParameterAttributes |= GenericParameterAttributes.Covariant; } if (spec.HasSpecialClass) { genericParameterAttributes |= GenericParameterAttributes.ReferenceTypeConstraint; } else if (spec.HasSpecialStruct) { genericParameterAttributes |= GenericParameterAttributes.NotNullableValueTypeConstraint | GenericParameterAttributes.DefaultConstructorConstraint; } if (spec.HasSpecialConstructor) { genericParameterAttributes |= GenericParameterAttributes.DefaultConstructorConstraint; } if (spec.BaseType.BuiltinType != BuiltinTypeSpec.Type.Object) { builder.SetBaseTypeConstraint(spec.BaseType.GetMetaInfo()); } if (spec.InterfacesDefined != null) { builder.SetInterfaceConstraints(spec.InterfacesDefined.Select((TypeSpec l) => l.GetMetaInfo()).ToArray()); } if (spec.TypeArguments != null) { List list = new List(spec.TypeArguments.Length); TypeSpec[] typeArguments = spec.TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (!typeSpec.IsClass || spec.BaseType.BuiltinType == BuiltinTypeSpec.Type.Object) { list.Add(typeSpec.GetMetaInfo()); } } builder.SetInterfaceConstraints(list.ToArray()); } builder.SetGenericParameterAttributes(genericParameterAttributes); } public override void Emit() { EmitConstraints(builder); if (base.OptAttributes != null) { base.OptAttributes.Emit(); } base.Emit(); } public void ErrorInvalidVariance(IMemberContext mc, Variance expected) { base.Report.SymbolRelatedToPreviousError(mc.CurrentMemberDefinition); string text = ((Variance == Variance.Contravariant) ? "contravariant" : "covariant"); string text2 = expected switch { Variance.Contravariant => "contravariantly", Variance.Covariant => "covariantly", _ => "invariantly", }; string text3 = ((mc is Delegate obj) ? obj.Parameters.GetSignatureForError() : ""); base.Report.Error(1961, base.Location, "The {2} type parameter `{0}' must be {3} valid on `{1}{4}'", GetSignatureForError(), mc.GetSignatureForError(), text, text2, text3); } public TypeSpec GetAsyncMethodBuilder() { return null; } public TypeSpec GetAttributeCoClass() { return null; } public string GetAttributeDefaultMember() { throw new NotSupportedException(); } public AttributeUsageAttribute GetAttributeUsage(PredefinedAttribute pa) { throw new NotSupportedException(); } public override string GetSignatureForDocumentation() { throw new NotImplementedException(); } public override string GetSignatureForError() { return base.MemberName.Name; } bool ITypeDefinition.IsInternalAsPublic(IAssemblyDefinition assembly) { return spec.MemberDefinition.DeclaringAssembly == assembly; } public void LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { throw new NotSupportedException("Not supported for compiled definition"); } public bool ResolveConstraints(IMemberContext context) { if (constraints != null) { return constraints.Resolve(context, this); } if (spec.BaseType == null) { spec.BaseType = context.Module.Compiler.BuiltinTypes.Object; } return true; } public override bool IsClsComplianceRequired() { return false; } public new void VerifyClsCompliance() { if (constraints != null) { constraints.VerifyClsCompliance(base.Report); } } public void WarningParentNameConflict(TypeParameter conflict) { conflict.Report.SymbolRelatedToPreviousError(conflict.Location, null); conflict.Report.Warning(693, 3, base.Location, "Type parameter `{0}' has the same name as the type parameter from outer type `{1}'", GetSignatureForError(), conflict.CurrentType.GetSignatureForError()); } } [DebuggerDisplay("{DisplayDebugInfo()}")] internal class TypeParameterSpec : TypeSpec { public new static readonly TypeParameterSpec[] EmptyTypes = new TypeParameterSpec[0]; private Variance variance; private SpecialConstraint spec; private int tp_pos; private TypeSpec[] targs; private TypeSpec[] ifaces_defined; private TypeSpec effective_base; private MemberCache interface_cache; public int DeclaredPosition { get { return tp_pos; } set { tp_pos = value; } } public bool HasSpecialConstructor => (spec & SpecialConstraint.Constructor) != 0; public bool HasSpecialClass => (spec & SpecialConstraint.Class) != 0; public bool HasSpecialStruct => (spec & SpecialConstraint.Struct) != 0; public bool HasAnyTypeConstraint => (spec & (SpecialConstraint.Class | SpecialConstraint.Struct)) != SpecialConstraint.None || ifaces != null || targs != null || HasTypeConstraint; public bool HasTypeConstraint { get { BuiltinTypeSpec.Type builtinType = BaseType.BuiltinType; return builtinType != BuiltinTypeSpec.Type.Object && builtinType != BuiltinTypeSpec.Type.ValueType; } } public override IList Interfaces { get { if ((state & StateFlags.InterfacesExpanded) == 0) { if (ifaces != null) { if (ifaces_defined == null) { ifaces_defined = ifaces.ToArray(); } for (int i = 0; i < ifaces_defined.Length; i++) { TypeSpec typeSpec = ifaces_defined[i]; if (typeSpec.MemberDefinition is TypeDefinition typeDefinition) { typeDefinition.DoExpandBaseInterfaces(); } if (typeSpec.Interfaces != null) { for (int j = 0; j < typeSpec.Interfaces.Count; j++) { TypeSpec iface = typeSpec.Interfaces[j]; AddInterface(iface); } } } } else if (ifaces_defined == null) { ifaces_defined = ((ifaces == null) ? TypeSpec.EmptyTypes : ifaces.ToArray()); } if (BaseType != null) { if (BaseType.MemberDefinition is TypeDefinition typeDefinition2) { typeDefinition2.DoExpandBaseInterfaces(); } if (BaseType.Interfaces != null) { foreach (TypeSpec @interface in BaseType.Interfaces) { AddInterface(@interface); } } } state |= StateFlags.InterfacesExpanded; } return ifaces; } } public MemberCache InterfaceCache => interface_cache; public TypeSpec[] InterfacesDefined { get { if (ifaces_defined == null) { ifaces_defined = ((ifaces == null) ? TypeSpec.EmptyTypes : ifaces.ToArray()); } return (ifaces_defined.Length == 0) ? null : ifaces_defined; } set { ifaces_defined = value; if (value != null && value.Length != 0) { ifaces = new List(value); } } } public bool IsConstrained => spec != SpecialConstraint.None || ifaces != null || targs != null || HasTypeConstraint; public new bool IsReferenceType { get { if ((spec & (SpecialConstraint.Class | SpecialConstraint.Struct)) != SpecialConstraint.None) { return (spec & SpecialConstraint.Class) != 0; } if (HasTypeConstraint && TypeSpec.IsReferenceType(BaseType)) { return true; } if (targs != null) { TypeSpec[] array = targs; foreach (TypeSpec typeSpec in array) { if ((!(typeSpec is TypeParameterSpec typeParameterSpec) || (typeParameterSpec.spec & (SpecialConstraint.Class | SpecialConstraint.Struct)) == 0) && TypeSpec.IsReferenceType(typeSpec)) { return true; } } } return false; } } public new bool IsValueType { get { if (HasSpecialStruct) { return true; } if (targs != null) { TypeSpec[] array = targs; foreach (TypeSpec t in array) { if (TypeSpec.IsValueType(t)) { return true; } } } return false; } } public override string Name => definition.Name; public bool IsMethodOwned => base.DeclaringType == null; public SpecialConstraint SpecialConstraint { get { return spec; } set { spec = value; } } public new TypeSpec[] TypeArguments { get { return targs; } set { targs = value; } } public Variance Variance => variance; public TypeParameterSpec(TypeSpec declaringType, int index, ITypeDefinition definition, SpecialConstraint spec, Variance variance, Type info) : base(MemberKind.TypeParameter, declaringType, definition, info, Modifiers.PUBLIC) { this.variance = variance; this.spec = spec; state &= ~StateFlags.Obsolete_Undetected; tp_pos = index; } public TypeParameterSpec(int index, ITypeDefinition definition, SpecialConstraint spec, Variance variance, Type info) : this(null, index, definition, spec, variance, info) { } public string DisplayDebugInfo() { string signatureForError = GetSignatureForError(); return IsMethodOwned ? (signatureForError + "!!") : (signatureForError + "!"); } public TypeSpec GetEffectiveBase() { if (HasSpecialStruct) { return BaseType; } if (BaseType != null && targs == null) { return BaseType.IsStruct ? BaseType.BaseType : BaseType; } if (effective_base != null) { return effective_base; } TypeSpec[] array = new TypeSpec[HasTypeConstraint ? (targs.Length + 1) : targs.Length]; for (int i = 0; i < targs.Length; i++) { TypeSpec typeSpec = targs[i]; if (typeSpec.IsStruct) { array[i] = typeSpec.BaseType; continue; } TypeParameterSpec typeParameterSpec = typeSpec as TypeParameterSpec; array[i] = ((typeParameterSpec != null) ? typeParameterSpec.GetEffectiveBase() : typeSpec); } if (HasTypeConstraint) { array[^1] = BaseType; } return effective_base = Convert.FindMostEncompassedType(array); } public override string GetSignatureForDocumentation(bool explicitName) { if (explicitName) { return Name; } string text = (IsMethodOwned ? "``" : "`"); return text + DeclaredPosition; } public override string GetSignatureForError() { return Name; } public bool HasSameConstraintsDefinition(TypeParameterSpec other) { if (spec != other.spec) { return false; } if (BaseType != other.BaseType) { return false; } if (!TypeSpecComparer.Override.IsSame(InterfacesDefined, other.InterfacesDefined)) { return false; } if (!TypeSpecComparer.Override.IsSame(targs, other.targs)) { return false; } return true; } public bool HasSameConstraintsImplementation(TypeParameterSpec other) { if (spec != other.spec) { return false; } if (!TypeSpecComparer.Override.IsEqual(BaseType, other.BaseType)) { bool flag = false; if (other.targs != null) { TypeSpec[] array = other.targs; foreach (TypeSpec b in array) { if (TypeSpecComparer.Override.IsEqual(BaseType, b)) { flag = true; break; } } } else if (targs != null) { TypeSpec[] array2 = targs; foreach (TypeSpec a in array2) { if (TypeSpecComparer.Override.IsEqual(a, other.BaseType)) { flag = true; break; } } } if (!flag) { return false; } } if (InterfacesDefined != null) { TypeSpec[] interfacesDefined = InterfacesDefined; foreach (TypeSpec a2 in interfacesDefined) { bool flag = false; if (other.InterfacesDefined != null) { foreach (TypeSpec @interface in other.Interfaces) { if (TypeSpecComparer.Override.IsEqual(a2, @interface)) { flag = true; break; } } } if (flag) { continue; } if (other.targs != null) { TypeSpec[] array3 = other.targs; foreach (TypeSpec b2 in array3) { if (TypeSpecComparer.Override.IsEqual(a2, b2)) { flag = true; break; } } } if (!flag) { return false; } } } if (other.InterfacesDefined != null) { TypeSpec[] interfacesDefined2 = other.InterfacesDefined; foreach (TypeSpec b3 in interfacesDefined2) { bool flag = false; if (InterfacesDefined != null) { foreach (TypeSpec interface2 in Interfaces) { if (TypeSpecComparer.Override.IsEqual(interface2, b3)) { flag = true; break; } } } else if (targs != null) { TypeSpec[] array4 = targs; foreach (TypeSpec a3 in array4) { if (TypeSpecComparer.Override.IsEqual(a3, b3)) { flag = true; break; } } } if (!flag) { return false; } } } if (targs != null) { TypeSpec[] array5 = targs; foreach (TypeSpec typeSpec in array5) { bool flag = false; if (other.targs != null) { TypeSpec[] array6 = other.targs; foreach (TypeSpec b4 in array6) { if (TypeSpecComparer.Override.IsEqual(typeSpec, b4)) { flag = true; break; } } } if (other.InterfacesDefined != null && !flag) { foreach (TypeSpec interface3 in other.Interfaces) { if (TypeSpecComparer.Override.IsEqual(interface3, typeSpec)) { flag = true; break; } } } if (!flag) { flag = TypeSpecComparer.Override.IsEqual(typeSpec, other.BaseType); } if (!flag) { return false; } } } if (other.targs != null) { TypeSpec[] array7 = other.targs; foreach (TypeSpec typeSpec2 in array7) { if (!typeSpec2.IsGenericParameter) { continue; } if (targs == null) { return false; } bool flag = false; TypeSpec[] array8 = targs; foreach (TypeSpec a4 in array8) { if (TypeSpecComparer.Override.IsEqual(a4, typeSpec2)) { flag = true; break; } } if (!flag) { return false; } } } return true; } public static TypeParameterSpec[] InflateConstraints(TypeParameterInflator inflator, TypeParameterSpec[] tparams) { return InflateConstraints(tparams, (TypeParameterInflator l) => l, inflator); } public static TypeParameterSpec[] InflateConstraints(TypeParameterSpec[] tparams, Func inflatorFactory, T arg) { TypeParameterSpec[] array = null; TypeParameterInflator? typeParameterInflator = null; for (int i = 0; i < tparams.Length; i++) { TypeParameterSpec typeParameterSpec = tparams[i]; if (typeParameterSpec.HasTypeConstraint || typeParameterSpec.InterfacesDefined != null || typeParameterSpec.TypeArguments != null) { if (array == null) { array = new TypeParameterSpec[tparams.Length]; Array.Copy(tparams, array, array.Length); } if (!typeParameterInflator.HasValue) { typeParameterInflator = inflatorFactory(arg); } array[i] = (TypeParameterSpec)array[i].InflateMember(typeParameterInflator.Value); } } if (array == null) { array = tparams; } return array; } public void InflateConstraints(TypeParameterInflator inflator, TypeParameterSpec tps) { tps.BaseType = inflator.Inflate(BaseType); TypeSpec[] interfacesDefined = InterfacesDefined; if (interfacesDefined != null) { tps.ifaces_defined = new TypeSpec[interfacesDefined.Length]; for (int i = 0; i < interfacesDefined.Length; i++) { tps.ifaces_defined[i] = inflator.Inflate(interfacesDefined[i]); } } else if (ifaces_defined == TypeSpec.EmptyTypes) { tps.ifaces_defined = TypeSpec.EmptyTypes; } IList interfaces = Interfaces; if (interfaces != null) { tps.ifaces = new List(interfaces.Count); for (int j = 0; j < interfaces.Count; j++) { tps.ifaces.Add(inflator.Inflate(interfaces[j])); } tps.state |= StateFlags.InterfacesExpanded; } if (targs != null) { tps.targs = new TypeSpec[targs.Length]; for (int k = 0; k < targs.Length; k++) { tps.targs[k] = inflator.Inflate(targs[k]); } } } public override MemberSpec InflateMember(TypeParameterInflator inflator) { TypeParameterSpec typeParameterSpec = (TypeParameterSpec)MemberwiseClone(); InflateConstraints(inflator, typeParameterSpec); return typeParameterSpec; } protected override void InitializeMemberCache(bool onlyTypes) { cache = new MemberCache(); if (targs != null) { TypeSpec[] array = targs; foreach (TypeSpec typeSpec in array) { TypeSpec typeSpec2 = ((!(typeSpec is TypeParameterSpec typeParameterSpec)) ? typeSpec : typeParameterSpec.GetEffectiveBase()); if (typeSpec2 != null && !typeSpec2.IsStructOrEnum && TypeSpec.IsBaseClass(typeSpec2, BaseType, dynamicIsObject: false)) { BaseType = typeSpec2; } } } bool flag = false; if (BaseType.BuiltinType != BuiltinTypeSpec.Type.Object && BaseType.BuiltinType != BuiltinTypeSpec.Type.ValueType) { cache.AddBaseType(BaseType); flag = true; } if (InterfacesDefined != null) { MemberCache memberCache = cache; if (flag) { interface_cache = new MemberCache(); memberCache = interface_cache; } TypeSpec[] interfacesDefined = InterfacesDefined; foreach (TypeSpec iface in interfacesDefined) { memberCache.AddInterface(iface); } } if (targs == null) { return; } TypeSpec[] array2 = targs; foreach (TypeSpec typeSpec3 in array2) { IList list; if (typeSpec3 is TypeParameterSpec typeParameterSpec2) { IList interfacesDefined2 = typeParameterSpec2.InterfacesDefined; list = interfacesDefined2; } else { list = typeSpec3.Interfaces; } IList list2 = list; if (list2 == null) { continue; } MemberCache memberCache2 = cache; if (flag) { interface_cache = new MemberCache(); memberCache2 = interface_cache; } foreach (TypeSpec item in list2) { memberCache2.AddInterface(item); } } } public bool IsConvertibleToInterface(TypeSpec iface) { if (Interfaces != null) { foreach (TypeSpec @interface in Interfaces) { if (@interface == iface) { return true; } } } if (TypeArguments != null) { TypeSpec[] typeArguments = TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (typeSpec is TypeParameterSpec typeParameterSpec) { if (typeParameterSpec.IsConvertibleToInterface(iface)) { return true; } } else if (typeSpec.ImplementsInterface(iface, variantly: false)) { return true; } } } return false; } public static bool HasAnyTypeParameterTypeConstrained(IGenericMethodDefinition md) { TypeParameterSpec[] typeParameters = md.TypeParameters; for (int i = 0; i < md.TypeParametersCount; i++) { if (typeParameters[i].HasAnyTypeConstraint) { return true; } } return false; } public static bool HasAnyTypeParameterConstrained(IGenericMethodDefinition md) { TypeParameterSpec[] typeParameters = md.TypeParameters; for (int i = 0; i < md.TypeParametersCount; i++) { if (typeParameters[i].IsConstrained) { return true; } } return false; } public bool HasDependencyOn(TypeSpec type) { if (TypeArguments != null) { TypeSpec[] typeArguments = TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (TypeSpecComparer.Override.IsEqual(typeSpec, type)) { return true; } if (typeSpec is TypeParameterSpec typeParameterSpec && typeParameterSpec.HasDependencyOn(type)) { return true; } } } return false; } public override TypeSpec Mutate(TypeParameterMutator mutator) { return mutator.Mutate(this); } } internal struct TypeParameterInflator { private readonly TypeSpec type; private readonly TypeParameterSpec[] tparams; private readonly TypeSpec[] targs; private readonly IModuleContext context; public IModuleContext Context => context; public TypeSpec TypeInstance => type; public TypeParameterSpec[] TypeParameters => tparams; public TypeParameterInflator(TypeParameterInflator nested, TypeSpec type) : this(nested.context, type, nested.tparams, nested.targs) { } public TypeParameterInflator(IModuleContext context, TypeSpec type, TypeParameterSpec[] tparams, TypeSpec[] targs) { if (tparams.Length != targs.Length) { throw new ArgumentException("Invalid arguments"); } this.context = context; this.tparams = tparams; this.targs = targs; this.type = type; } public TypeSpec Inflate(TypeSpec type) { if (type is TypeParameterSpec tp) { return Inflate(tp); } if (type is ElementTypeSpec elementTypeSpec) { TypeSpec typeSpec = Inflate(elementTypeSpec.Element); if (typeSpec != elementTypeSpec.Element) { if (elementTypeSpec is ArrayContainer arrayContainer) { return ArrayContainer.MakeType(context.Module, typeSpec, arrayContainer.Rank); } if (elementTypeSpec is PointerContainer) { return PointerContainer.MakeType(context.Module, typeSpec); } if (elementTypeSpec is ReferenceContainer) { return ReferenceContainer.MakeType(context.Module, typeSpec); } throw new NotImplementedException(); } return elementTypeSpec; } if (type.Kind == MemberKind.MissingType) { return type; } int i = 0; TypeSpec[] array; if (type.IsNested) { TypeSpec container = Inflate(type.DeclaringType); array = type.TypeArguments; if (array.Length == 0 && type.Arity > 0) { TypeSpec[] typeParameters = type.MemberDefinition.TypeParameters; array = typeParameters; } type = MemberCache.FindNestedType(container, type.Name, type.Arity, declaredOnlyClass: false); if (array.Length != 0) { TypeSpec[] array2 = new TypeSpec[array.Length]; for (; i < array.Length; i++) { array2[i] = Inflate(array[i]); } type = type.MakeGenericType(context, array2); } return type; } if (type.Arity == 0) { return type; } array = new TypeSpec[type.Arity]; if (type is InflatedTypeSpec) { for (; i < array.Length; i++) { array[i] = Inflate(type.TypeArguments[i]); } type = type.GetDefinition(); } else { TypeParameterSpec[] typeParameters2 = type.MemberDefinition.TypeParameters; TypeParameterSpec[] array3 = typeParameters2; foreach (TypeParameterSpec tp2 in array3) { array[i++] = Inflate(tp2); } } return type.MakeGenericType(context, array); } public TypeSpec Inflate(TypeParameterSpec tp) { for (int i = 0; i < tparams.Length; i++) { if (tparams[i] == tp) { return targs[i]; } } return tp; } } internal class TypeParameterMutator { private readonly TypeParameters mvar; private readonly TypeParameters var; private readonly TypeParameterSpec[] src; private Dictionary mutated_typespec; public TypeParameters MethodTypeParameters => mvar; public TypeParameterMutator(TypeParameters mvar, TypeParameters var) { if (mvar.Count != var.Count) { throw new ArgumentException(); } this.mvar = mvar; this.var = var; } public TypeParameterMutator(TypeParameterSpec[] srcVar, TypeParameters destVar) { if (srcVar.Length != destVar.Count) { throw new ArgumentException(); } src = srcVar; var = destVar; } public static TypeSpec GetMemberDeclaringType(TypeSpec type) { if (type is InflatedTypeSpec) { if (type.DeclaringType == null) { return type.GetDefinition(); } TypeSpec memberDeclaringType = GetMemberDeclaringType(type.DeclaringType); type = MemberCache.GetMember(memberDeclaringType, type); } return type; } public TypeSpec Mutate(TypeSpec ts) { if (mutated_typespec != null && mutated_typespec.TryGetValue(ts, out var value)) { return value; } value = ts.Mutate(this); if (mutated_typespec == null) { mutated_typespec = new Dictionary(); } mutated_typespec.Add(ts, value); return value; } public TypeParameterSpec Mutate(TypeParameterSpec tp) { if (mvar != null) { for (int i = 0; i < mvar.Count; i++) { if (mvar[i].Type == tp) { return var[i].Type; } } } else { for (int j = 0; j < src.Length; j++) { if (src[j] == tp) { return var[j].Type; } } } return tp; } public TypeSpec[] Mutate(TypeSpec[] targs) { TypeSpec[] array = new TypeSpec[targs.Length]; bool flag = false; for (int i = 0; i < targs.Length; i++) { array[i] = Mutate(targs[i]); flag |= targs[i] != array[i]; } return flag ? array : targs; } } internal class TypeParameterExpr : TypeExpression { public TypeParameterExpr(TypeParameter type_parameter, Location loc) : base(type_parameter.Type, loc) { eclass = ExprClass.TypeParameter; } } internal class InflatedTypeSpec : TypeSpec { private TypeSpec[] targs; private TypeParameterSpec[] constraints; private readonly TypeSpec open_type; private readonly IModuleContext context; public override TypeSpec BaseType { get { if (cache == null || (state & StateFlags.PendingBaseTypeInflate) != 0) { InitializeMemberCache(onlyTypes: true); } return base.BaseType; } } public TypeParameterSpec[] Constraints { get { if (constraints == null) { constraints = TypeParameterSpec.InflateConstraints(base.MemberDefinition.TypeParameters, (InflatedTypeSpec l) => l.CreateLocalInflator(context), this); } return constraints; } } public bool HasConstraintsChecked { get { return (state & StateFlags.ConstraintsChecked) != 0; } set { state = (value ? (state | StateFlags.ConstraintsChecked) : (state & ~StateFlags.ConstraintsChecked)); } } public override IList Interfaces { get { if (cache == null) { InitializeMemberCache(onlyTypes: true); } return base.Interfaces; } } public override bool IsExpressionTreeType => (open_type.state & StateFlags.InflatedExpressionType) != 0; public override bool IsArrayGenericInterface => (open_type.state & StateFlags.GenericIterateInterface) != 0; public override bool IsGenericTask => (open_type.state & StateFlags.GenericTask) != 0; public override bool IsNullableType => (open_type.state & StateFlags.InflatedNullableType) != 0; public override bool IsTupleType => (open_type.state & StateFlags.Tuple) != 0; public override TypeSpec[] TypeArguments => targs; public InflatedTypeSpec(IModuleContext context, TypeSpec openType, TypeSpec declaringType, TypeSpec[] targs) : base(openType.Kind, declaringType, openType.MemberDefinition, null, openType.Modifiers) { if (targs == null) { throw new ArgumentNullException("targs"); } state &= ~(StateFlags.Obsolete_Undetected | StateFlags.Obsolete | StateFlags.CLSCompliant_Undetected | StateFlags.CLSCompliant | StateFlags.MissingDependency_Undetected | StateFlags.MissingDependency | StateFlags.HasDynamicElement | StateFlags.HasNamedTupleElement); state |= openType.state & (StateFlags.Obsolete_Undetected | StateFlags.Obsolete | StateFlags.CLSCompliant_Undetected | StateFlags.CLSCompliant | StateFlags.MissingDependency_Undetected | StateFlags.MissingDependency | StateFlags.HasDynamicElement | StateFlags.HasNamedTupleElement); this.context = context; open_type = openType; this.targs = targs; foreach (TypeSpec typeSpec in targs) { if (typeSpec.HasDynamicElement || typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { state |= StateFlags.HasDynamicElement; } if (typeSpec.HasNamedTupleElement) { state |= StateFlags.HasNamedTupleElement; } } if (open_type.Kind == MemberKind.MissingType) { base.MemberCache = MemberCache.Empty; } if ((open_type.Modifiers & Modifiers.COMPILER_GENERATED) != 0) { state |= StateFlags.ConstraintsChecked; } } public override bool AddInterface(TypeSpec iface) { iface = CreateLocalInflator(context).Inflate(iface); if (iface == null) { return false; } return base.AddInterface(iface); } public static bool ContainsTypeParameter(TypeSpec type) { if (type.Kind == MemberKind.TypeParameter) { return true; } if (type is ElementTypeSpec elementTypeSpec) { return ContainsTypeParameter(elementTypeSpec.Element); } TypeSpec[] typeArguments = type.TypeArguments; foreach (TypeSpec type2 in typeArguments) { if (ContainsTypeParameter(type2)) { return true; } } return false; } public TypeParameterInflator CreateLocalInflator(IModuleContext context) { TypeSpec[] array = targs; TypeParameterSpec[] tparams; if (!base.IsNested) { tparams = ((targs.Length != 0) ? open_type.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes); } else { List list = null; List list2 = null; TypeSpec typeSpec = base.DeclaringType; do { if (typeSpec.TypeArguments.Length != 0) { if (list == null) { list = new List(); list2 = new List(); if (targs.Length != 0) { list.AddRange(targs); list2.AddRange(open_type.MemberDefinition.TypeParameters); } } list2.AddRange(typeSpec.MemberDefinition.TypeParameters); list.AddRange(typeSpec.TypeArguments); } typeSpec = typeSpec.DeclaringType; } while (typeSpec != null); if (list == null) { tparams = ((targs.Length != 0) ? open_type.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes); } else { array = list.ToArray(); tparams = list2.ToArray(); } } return new TypeParameterInflator(context, this, tparams, array); } private Type CreateMetaInfo() { List list = new List(); TypeSpec typeSpec = this; TypeSpec typeSpec2 = typeSpec; do { if (typeSpec.GetDefinition().IsGeneric) { list.InsertRange(0, (typeSpec.TypeArguments != TypeSpec.EmptyTypes) ? typeSpec.TypeArguments.Select((TypeSpec l) => l.GetMetaInfo()) : typeSpec.MemberDefinition.TypeParameters.Select((TypeParameterSpec l) => l.GetMetaInfo())); } typeSpec2 = typeSpec2.GetDefinition(); typeSpec = typeSpec.DeclaringType; } while (typeSpec != null); return typeSpec2.GetMetaInfo().MakeGenericType(list.ToArray()); } public override void CheckObsoleteness(IMemberContext mc, Location loc) { base.CheckObsoleteness(mc, loc); TypeSpec[] typeArguments = TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { typeSpec.CheckObsoleteness(mc, loc); } } public override ObsoleteAttribute GetAttributeObsolete() { return open_type.GetAttributeObsolete(); } protected override bool IsNotCLSCompliant(out bool attrValue) { if (base.IsNotCLSCompliant(out attrValue)) { return true; } TypeSpec[] typeArguments = TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (typeSpec.MemberDefinition.CLSAttributeValue == false) { return true; } } return false; } public override TypeSpec GetDefinition() { return open_type; } public override Type GetMetaInfo() { if ((object)info == null) { info = CreateMetaInfo(); } return info; } public override string GetSignatureForError() { if (IsNullableType) { return targs[0].GetSignatureForError() + "?"; } return base.GetSignatureForError(); } protected override string GetTypeNameSignature() { if (targs.Length == 0 || base.MemberDefinition is AnonymousTypeClass) { return null; } return "<" + TypeManager.CSharpName(targs) + ">"; } public bool HasDynamicArgument() { for (int i = 0; i < targs.Length; i++) { TypeSpec typeSpec = targs[i]; if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return true; } if (typeSpec is InflatedTypeSpec) { if (((InflatedTypeSpec)typeSpec).HasDynamicArgument()) { return true; } } else if (typeSpec.IsArray) { while (typeSpec.IsArray) { typeSpec = ((ArrayContainer)typeSpec).Element; } if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return true; } } } return false; } protected override void InitializeMemberCache(bool onlyTypes) { if (cache == null) { MemberCache memberCache = (onlyTypes ? open_type.MemberCacheTypes : open_type.MemberCache); if (cache == null) { cache = new MemberCache(memberCache); } } TypeParameterInflator inflator = CreateLocalInflator(context); if ((state & StateFlags.PendingMemberCacheMembers) == 0) { open_type.MemberCacheTypes.InflateTypes(cache, inflator); if (open_type.Interfaces != null) { ifaces = new List(open_type.Interfaces.Count); foreach (TypeSpec @interface in open_type.Interfaces) { TypeSpec typeSpec = inflator.Inflate(@interface); if (typeSpec != null) { base.AddInterface(typeSpec); } } } if (open_type.BaseType == null) { if (base.IsClass) { state |= StateFlags.PendingBaseTypeInflate; } } else { BaseType = inflator.Inflate(open_type.BaseType); } } else if ((state & StateFlags.PendingBaseTypeInflate) != 0) { if (open_type.BaseType == null) { return; } BaseType = inflator.Inflate(open_type.BaseType); state &= ~StateFlags.PendingBaseTypeInflate; } if (onlyTypes) { state |= StateFlags.PendingMemberCacheMembers; } else if (!(open_type.MemberDefinition is TypeDefinition { HasMembersDefined: false })) { if ((state & StateFlags.PendingBaseTypeInflate) != 0) { BaseType = inflator.Inflate(open_type.BaseType); state &= ~StateFlags.PendingBaseTypeInflate; } state &= ~StateFlags.PendingMemberCacheMembers; open_type.MemberCache.InflateMembers(cache, open_type, inflator); } } public override TypeSpec Mutate(TypeParameterMutator mutator) { TypeSpec[] array = TypeArguments; if (array != null) { array = mutator.Mutate(array); } TypeSpec typeSpec = base.DeclaringType; if (base.IsNested && base.DeclaringType.IsGenericOrParentIsGeneric) { typeSpec = mutator.Mutate(typeSpec); } if (array == TypeArguments && typeSpec == base.DeclaringType) { return this; } InflatedTypeSpec inflatedTypeSpec = (InflatedTypeSpec)MemberwiseClone(); if (typeSpec != base.DeclaringType) { inflatedTypeSpec.declaringType = typeSpec; inflatedTypeSpec.state |= StateFlags.PendingMetaInflate; } if (array != null) { inflatedTypeSpec.targs = array; inflatedTypeSpec.info = null; } return inflatedTypeSpec; } } internal class TypeArguments { private List args; private TypeSpec[] atypes; public TypeSpec[] Arguments { get { return atypes; } set { atypes = value; } } public int Count => args.Count; public virtual bool IsEmpty => false; public List TypeExpressions => args; public TypeArguments(params FullNamedExpression[] types) { args = new List(types); } public void Add(FullNamedExpression type) { args.Add(type); } public string GetSignatureForError() { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < Count; i++) { FullNamedExpression fullNamedExpression = args[i]; if (fullNamedExpression != null) { stringBuilder.Append(fullNamedExpression.GetSignatureForError()); } if (i + 1 < Count) { stringBuilder.Append(','); } } return stringBuilder.ToString(); } public virtual bool Resolve(IMemberContext ec, bool allowUnbound) { if (atypes != null) { return true; } int count = args.Count; bool flag = true; atypes = new TypeSpec[count]; int errors = ec.Module.Compiler.Report.Errors; for (int i = 0; i < count; i++) { TypeSpec typeSpec = args[i].ResolveAsType(ec); if (typeSpec == null) { flag = false; continue; } atypes[i] = typeSpec; if (typeSpec.IsStatic) { ec.Module.Compiler.Report.Error(718, args[i].Location, "`{0}': static classes cannot be used as generic arguments", typeSpec.GetSignatureForError()); flag = false; } if (typeSpec.IsPointer || typeSpec.IsSpecialRuntimeType || typeSpec.IsByRefLike) { ec.Module.Compiler.Report.Error(306, args[i].Location, "The type `{0}' may not be used as a type argument", typeSpec.GetSignatureForError()); flag = false; } } if (!flag || errors != ec.Module.Compiler.Report.Errors) { atypes = null; } return flag; } public TypeArguments Clone() { TypeArguments typeArguments = new TypeArguments(); foreach (FullNamedExpression arg in args) { typeArguments.args.Add(arg); } return typeArguments; } } internal class UnboundTypeArguments : TypeArguments { private Location loc; public override bool IsEmpty => true; public UnboundTypeArguments(int arity, Location loc) : base(new FullNamedExpression[arity]) { this.loc = loc; } public override bool Resolve(IMemberContext mc, bool allowUnbound) { if (!allowUnbound) { mc.Module.Compiler.Report.Error(7003, loc, "Unbound generic name is not valid in this context"); } return true; } } internal class TypeParameters { private List names; private TypeParameterSpec[] types; public int Count => names.Count; public TypeParameterSpec[] Types => types; public TypeParameter this[int index] { get { return names[index]; } set { names[index] = value; } } public TypeParameters() { names = new List(); } public TypeParameters(int count) { names = new List(count); } public void Add(TypeParameter tparam) { names.Add(tparam); } public void Add(TypeParameters tparams) { names.AddRange(tparams.names); } public void Create(TypeSpec declaringType, int parentOffset, TypeContainer parent) { types = new TypeParameterSpec[Count]; for (int i = 0; i < types.Length; i++) { TypeParameter typeParameter = names[i]; typeParameter.Create(declaringType, parent); types[i] = typeParameter.Type; types[i].DeclaredPosition = i + parentOffset; if (typeParameter.Variance != Variance.None && (declaringType == null || (declaringType.Kind != MemberKind.Interface && declaringType.Kind != MemberKind.Delegate))) { parent.Compiler.Report.Error(1960, typeParameter.Location, "Variant type parameters can only be used with interfaces and delegates"); } } } public void Define(GenericTypeParameterBuilder[] builders) { for (int i = 0; i < types.Length; i++) { TypeParameter typeParameter = names[i]; typeParameter.Define(builders[types[i].DeclaredPosition]); } } public TypeParameter Find(string name) { foreach (TypeParameter name2 in names) { if (name2.Name == name) { return name2; } } return null; } public string[] GetAllNames() { return names.Select((TypeParameter l) => l.Name).ToArray(); } public string GetSignatureForError() { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < Count; i++) { if (i > 0) { stringBuilder.Append(','); } TypeParameter typeParameter = names[i]; if (typeParameter != null) { stringBuilder.Append(typeParameter.GetSignatureForError()); } } return stringBuilder.ToString(); } public void CheckPartialConstraints(Method part) { TypeParameters currentTypeParameters = part.CurrentTypeParameters; for (int i = 0; i < Count; i++) { TypeParameter typeParameter = names[i]; TypeParameter typeParameter2 = currentTypeParameters[i]; if (typeParameter.Constraints == null) { if (typeParameter2.Constraints == null) { continue; } } else if (typeParameter2.Constraints != null && typeParameter.Type.HasSameConstraintsDefinition(typeParameter2.Type)) { continue; } part.Compiler.Report.SymbolRelatedToPreviousError(this[i].CurrentMemberDefinition.Location, ""); part.Compiler.Report.Error(761, part.Location, "Partial method declarations of `{0}' have inconsistent constraints for type parameter `{1}'", part.GetSignatureForError(), currentTypeParameters[i].GetSignatureForError()); } } public void UpdateConstraints(TypeDefinition part) { TypeParameters typeParameters = part.MemberName.TypeParameters; for (int i = 0; i < Count; i++) { TypeParameter typeParameter = names[i]; if (!typeParameter.AddPartialConstraints(part, typeParameters[i])) { part.Compiler.Report.SymbolRelatedToPreviousError(this[i].CurrentMemberDefinition); part.Compiler.Report.Error(265, part.Location, "Partial declarations of `{0}' have inconsistent constraints for type parameter `{1}'", part.GetSignatureForError(), typeParameter.GetSignatureForError()); } } } public void VerifyClsCompliance() { foreach (TypeParameter name in names) { name.VerifyClsCompliance(); } } } internal class GenericTypeExpr : TypeExpr { private TypeArguments args; private TypeSpec open_type; public GenericTypeExpr(TypeSpec open_type, TypeArguments args, Location l) { this.open_type = open_type; loc = l; this.args = args; } public override string GetSignatureForError() { return type.GetSignatureForError(); } public override TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments = false) { if (eclass != ExprClass.Unresolved) { return type; } if (!args.Resolve(mc, allowUnboundTypeArguments)) { return null; } TypeSpec[] arguments = args.Arguments; if (arguments == null) { return null; } InflatedTypeSpec inflatedTypeSpec = (InflatedTypeSpec)(type = open_type.MakeGenericType(mc, arguments)); eclass = ExprClass.Type; if (!inflatedTypeSpec.HasConstraintsChecked && mc.Module.HasTypesFullyDefined) { TypeParameterSpec[] constraints = inflatedTypeSpec.Constraints; if (constraints != null && new ConstraintChecker(mc).CheckAll(open_type, arguments, constraints, loc)) { inflatedTypeSpec.HasConstraintsChecked = true; } } return type; } public override bool Equals(object obj) { if (!(obj is GenericTypeExpr genericTypeExpr)) { return false; } if (type == null || genericTypeExpr.type == null) { return false; } return type == genericTypeExpr.type; } public override int GetHashCode() { return base.GetHashCode(); } } internal class GenericOpenTypeExpr : TypeExpression { public GenericOpenTypeExpr(TypeSpec type, Location loc) : base(type.GetDefinition(), loc) { } } internal struct ConstraintChecker { private IMemberContext mc; private bool recursive_checks; public ConstraintChecker(IMemberContext ctx) { mc = ctx; recursive_checks = false; } public static bool Check(IMemberContext mc, TypeSpec type, Location loc) { if (type.DeclaringType != null && !Check(mc, type.DeclaringType, loc)) { return false; } while (type is ElementTypeSpec) { type = ((ElementTypeSpec)type).Element; } if (type.Arity == 0) { return true; } if (!(type is InflatedTypeSpec { Constraints: var constraints } inflatedTypeSpec)) { return true; } if (constraints == null) { return true; } if (inflatedTypeSpec.HasConstraintsChecked) { return true; } ConstraintChecker constraintChecker = new ConstraintChecker(mc); constraintChecker.recursive_checks = true; if (constraintChecker.CheckAll(inflatedTypeSpec.GetDefinition(), type.TypeArguments, constraints, loc)) { inflatedTypeSpec.HasConstraintsChecked = true; return true; } return false; } public bool CheckAll(MemberSpec context, TypeSpec[] targs, TypeParameterSpec[] tparams, Location loc) { if (targs == null) { return true; } for (int i = 0; i < tparams.Length; i++) { TypeSpec typeSpec = targs[i]; if (!CheckConstraint(context, typeSpec, tparams[i], loc)) { return false; } if (recursive_checks && !Check(mc, typeSpec, loc)) { return false; } } return true; } private bool CheckConstraint(MemberSpec context, TypeSpec atype, TypeParameterSpec tparam, Location loc) { if (tparam.HasSpecialClass && !TypeSpec.IsReferenceType(atype)) { if (mc != null) { mc.Module.Compiler.Report.Error(452, loc, "The type `{0}' must be a reference type in order to use it as type parameter `{1}' in the generic type or method `{2}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError()); } return false; } if (tparam.HasSpecialStruct && (!TypeSpec.IsValueType(atype) || atype.IsNullableType)) { if (mc != null) { mc.Module.Compiler.Report.Error(453, loc, "The type `{0}' must be a non-nullable value type in order to use it as type parameter `{1}' in the generic type or method `{2}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError()); } return false; } bool result = true; if (tparam.HasTypeConstraint && !CheckConversion(mc, context, atype, tparam, tparam.BaseType, loc)) { if (mc == null) { return false; } result = false; } if (tparam.InterfacesDefined != null) { TypeSpec[] interfacesDefined = tparam.InterfacesDefined; foreach (TypeSpec ttype in interfacesDefined) { if (!CheckConversion(mc, context, atype, tparam, ttype, loc)) { if (mc == null) { return false; } result = false; break; } } } if (tparam.TypeArguments != null) { TypeSpec[] typeArguments = tparam.TypeArguments; foreach (TypeSpec ttype2 in typeArguments) { if (!CheckConversion(mc, context, atype, tparam, ttype2, loc)) { if (mc == null) { return false; } result = false; break; } } } if (!tparam.HasSpecialConstructor) { return result; } if (!HasDefaultConstructor(atype)) { if (mc != null) { mc.Module.Compiler.Report.SymbolRelatedToPreviousError(atype); mc.Module.Compiler.Report.Error(310, loc, "The type `{0}' must have a public parameterless constructor in order to use it as parameter `{1}' in the generic type or method `{2}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError()); } return false; } return result; } private static bool HasDynamicTypeArgument(TypeSpec[] targs) { foreach (TypeSpec typeSpec in targs) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return true; } if (HasDynamicTypeArgument(typeSpec.TypeArguments)) { return true; } } return false; } private bool CheckConversion(IMemberContext mc, MemberSpec context, TypeSpec atype, TypeParameterSpec tparam, TypeSpec ttype, Location loc) { if (atype == ttype) { return true; } if (atype.IsGenericParameter) { TypeParameterSpec typeParameterSpec = (TypeParameterSpec)atype; if (typeParameterSpec.HasDependencyOn(ttype)) { return true; } if (Convert.ImplicitTypeParameterConversion(null, typeParameterSpec, ttype) != null) { return true; } } else if (TypeSpec.IsValueType(atype)) { if (atype.IsNullableType) { if (TypeSpec.IsBaseClass(atype, ttype, dynamicIsObject: false)) { return true; } } else if (Convert.ImplicitBoxingConversion(null, atype, ttype) != null) { return true; } } else if (Convert.ImplicitReferenceConversionExists(atype, ttype) || Convert.ImplicitBoxingConversion(null, atype, ttype) != null) { return true; } if (mc != null) { mc.Module.Compiler.Report.SymbolRelatedToPreviousError(tparam); if (atype.IsGenericParameter) { mc.Module.Compiler.Report.Error(314, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no boxing or type parameter conversion from `{0}' to `{3}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError(), ttype.GetSignatureForError()); } else if (TypeSpec.IsValueType(atype)) { if (atype.IsNullableType) { if (ttype.IsInterface) { mc.Module.Compiler.Report.Error(313, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. The nullable type `{0}' never satisfies interface constraint `{3}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError(), ttype.GetSignatureForError()); } else { mc.Module.Compiler.Report.Error(312, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. The nullable type `{0}' does not satisfy constraint `{3}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError(), ttype.GetSignatureForError()); } } else { mc.Module.Compiler.Report.Error(315, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no boxing conversion from `{0}' to `{3}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError(), ttype.GetSignatureForError()); } } else { mc.Module.Compiler.Report.Error(311, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'", atype.GetSignatureForError(), tparam.GetSignatureForError(), context.GetSignatureForError(), ttype.GetSignatureForError()); } } return false; } private static bool HasDefaultConstructor(TypeSpec atype) { if (atype is TypeParameterSpec typeParameterSpec) { return typeParameterSpec.HasSpecialConstructor || typeParameterSpec.HasSpecialStruct; } if (atype.IsStruct || atype.IsEnum) { return true; } if (atype.IsAbstract) { return false; } TypeSpec definition = atype.GetDefinition(); MemberSpec memberSpec = MemberCache.FindMember(definition, MemberFilter.Constructor(ParametersCompiled.EmptyReadOnlyParameters), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly); return memberSpec != null && (memberSpec.Modifiers & Modifiers.PUBLIC) != 0; } } internal class TypeInference { private int score; private readonly Arguments arguments; private readonly int arg_count; public int InferenceScore => score; public TypeInference(Arguments arguments) { this.arguments = arguments; if (arguments != null) { arg_count = arguments.Count; } } public TypeSpec[] InferMethodArguments(ResolveContext ec, MethodSpec method) { TypeParameterSpec[] typeParameters = method.GenericDefinition.TypeParameters; TypeSpec[] typeArguments = typeParameters; TypeInferenceContext typeInferenceContext = new TypeInferenceContext(typeArguments); if (!typeInferenceContext.UnfixedVariableExists) { return TypeSpec.EmptyTypes; } AParametersCollection parameters = method.Parameters; if (!InferInPhases(ec, typeInferenceContext, parameters)) { return null; } return typeInferenceContext.InferredTypeArguments; } private bool InferInPhases(ResolveContext ec, TypeInferenceContext tic, AParametersCollection methodParameters) { int num = ((!methodParameters.HasParams) ? arg_count : (methodParameters.Count - 1)); TypeSpec[] array = methodParameters.Types; TypeSpec typeSpec = null; for (int i = 0; i < arg_count; i++) { Argument argument = arguments[i]; if (argument == null) { continue; } if (i < num) { typeSpec = methodParameters.Types[i]; } else if (i == num) { typeSpec = ((arg_count != num + 1 || !TypeManager.HasElementType(argument.Type)) ? TypeManager.GetElementType(methodParameters.Types[num]) : methodParameters.Types[num]); array = (TypeSpec[])array.Clone(); array[i] = typeSpec; } if (argument.Expr is AnonymousMethodExpression anonymousMethodExpression) { if (anonymousMethodExpression.ExplicitTypeInference(tic, typeSpec)) { score++; } } else if (argument.IsByRef) { score += tic.ExactInference(argument.Type, typeSpec); } else if (argument.Expr.Type != InternalType.NullLiteral) { if (TypeSpec.IsValueType(typeSpec)) { score += tic.LowerBoundInference(argument.Type, typeSpec); } else { score += tic.OutputTypeInference(ec, argument.Expr, typeSpec); } } } bool fixed_any = false; if (!tic.FixIndependentTypeArguments(ec, array, ref fixed_any)) { return false; } return DoSecondPhase(ec, tic, array, !fixed_any); } private bool DoSecondPhase(ResolveContext ec, TypeInferenceContext tic, TypeSpec[] methodParameters, bool fixDependent) { bool fixed_any = false; if (fixDependent && !tic.FixDependentTypes(ec, ref fixed_any)) { return false; } if (!tic.UnfixedVariableExists) { return true; } if (!fixed_any && fixDependent) { return false; } for (int i = 0; i < arg_count; i++) { TypeSpec typeSpec = methodParameters[(i >= methodParameters.Length) ? (methodParameters.Length - 1) : i]; if (!typeSpec.IsDelegate) { if (!typeSpec.IsExpressionTreeType) { continue; } typeSpec = TypeManager.GetTypeArguments(typeSpec)[0]; } MethodSpec invokeMethod = Delegate.GetInvokeMethod(typeSpec); TypeSpec returnType = invokeMethod.ReturnType; if (tic.IsReturnTypeNonDependent(invokeMethod, returnType) && arguments[i] != null) { score += tic.OutputTypeInference(ec, arguments[i].Expr, typeSpec); } } return DoSecondPhase(ec, tic, methodParameters, fixDependent: true); } } internal class TypeInferenceContext { protected enum BoundKind { Exact, Lower, Upper } private struct BoundInfo : IEquatable { public readonly TypeSpec Type; public readonly BoundKind Kind; public BoundInfo(TypeSpec type, BoundKind kind) { Type = type; Kind = kind; } public override int GetHashCode() { return Type.GetHashCode(); } public Expression GetTypeExpression() { return new TypeExpression(Type, Location.Null); } public bool Equals(BoundInfo other) { return Type == other.Type && Kind == other.Kind; } } private readonly TypeSpec[] tp_args; private readonly TypeSpec[] fixed_types; private readonly List[] bounds; public TypeSpec[] InferredTypeArguments => fixed_types; public bool UnfixedVariableExists { get { TypeSpec[] array = fixed_types; foreach (TypeSpec typeSpec in array) { if (typeSpec == null) { return true; } } return false; } } public TypeInferenceContext(TypeSpec[] typeArguments) { if (typeArguments.Length == 0) { throw new ArgumentException("Empty generic arguments"); } fixed_types = new TypeSpec[typeArguments.Length]; for (int i = 0; i < typeArguments.Length; i++) { if (typeArguments[i].IsGenericParameter) { if (bounds == null) { bounds = new List[typeArguments.Length]; tp_args = new TypeSpec[typeArguments.Length]; } tp_args[i] = typeArguments[i]; } else { fixed_types[i] = typeArguments[i]; } } } public TypeInferenceContext() { fixed_types = new TypeSpec[1]; tp_args = new TypeSpec[1]; tp_args[0] = InternalType.Arglist; bounds = new List[1]; } public void AddCommonTypeBound(TypeSpec type) { AddToBounds(new BoundInfo(type, BoundKind.Lower), 0, voidAllowed: false); } public void AddCommonTypeBoundAsync(TypeSpec type) { AddToBounds(new BoundInfo(type, BoundKind.Lower), 0, voidAllowed: true); } private void AddToBounds(BoundInfo bound, int index, bool voidAllowed) { if ((bound.Type.Kind != MemberKind.Void || voidAllowed) && !bound.Type.IsPointer && !bound.Type.IsSpecialRuntimeType && !bound.Type.IsByRefLike && bound.Type != InternalType.MethodGroup && bound.Type != InternalType.AnonymousMethod && bound.Type != InternalType.VarOutType && bound.Type != InternalType.ThrowExpr && (!bound.Type.IsTupleType || !TupleLiteral.ContainsNoTypeElement(bound.Type)) && bound.Type != InternalType.DefaultType) { List list = bounds[index]; if (list == null) { list = new List(2); list.Add(bound); bounds[index] = list; } else if (!list.Contains(bound)) { list.Add(bound); } } } private bool AllTypesAreFixed(TypeSpec[] types) { foreach (TypeSpec typeSpec in types) { if (typeSpec.IsGenericParameter) { if (!IsFixed(typeSpec)) { return false; } } else if (typeSpec.IsGeneric && !AllTypesAreFixed(typeSpec.TypeArguments)) { return false; } } return true; } public int ExactInference(TypeSpec u, TypeSpec v) { if (v.IsArray) { if (!u.IsArray) { return 0; } ArrayContainer arrayContainer = (ArrayContainer)u; ArrayContainer arrayContainer2 = (ArrayContainer)v; if (arrayContainer.Rank != arrayContainer2.Rank) { return 0; } return ExactInference(arrayContainer.Element, arrayContainer2.Element); } if (TypeManager.IsGenericType(v)) { if (u.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { TypeSpec[] typeArguments = v.TypeArguments; int num = 0; for (int i = 0; i < typeArguments.Length; i++) { num += ExactInference(u, typeArguments[i]); } return Math.Min(1, num); } if (!TypeManager.IsGenericType(u) || v.MemberDefinition != u.MemberDefinition) { return 0; } TypeSpec[] typeArguments2 = u.TypeArguments; TypeSpec[] typeArguments3 = v.TypeArguments; if (u.TypeArguments.Length != v.TypeArguments.Length) { return 0; } int num2 = 0; for (int j = 0; j < typeArguments3.Length; j++) { num2 += ExactInference(typeArguments2[j], typeArguments3[j]); } return Math.Min(1, num2); } int num3 = IsUnfixed(v); if (num3 == -1) { return 0; } AddToBounds(new BoundInfo(u, BoundKind.Exact), num3, voidAllowed: false); return 1; } public bool FixAllTypes(ResolveContext ec) { for (int i = 0; i < tp_args.Length; i++) { if (!FixType(ec, i)) { return false; } } return true; } public bool FixDependentTypes(ResolveContext ec, ref bool fixed_any) { for (int i = 0; i < tp_args.Length; i++) { if (fixed_types[i] == null && bounds[i] != null) { if (!FixType(ec, i)) { return false; } fixed_any = true; } } return true; } public bool FixIndependentTypeArguments(ResolveContext ec, TypeSpec[] methodParameters, ref bool fixed_any) { List list = new List(tp_args); for (int i = 0; i < methodParameters.Length; i++) { TypeSpec typeSpec = methodParameters[i]; if (!typeSpec.IsDelegate) { if (!typeSpec.IsExpressionTreeType) { continue; } typeSpec = TypeManager.GetTypeArguments(typeSpec)[0]; } if (!typeSpec.IsGenericParameter) { MethodSpec invokeMethod = Delegate.GetInvokeMethod(typeSpec); TypeSpec typeSpec2 = invokeMethod.ReturnType; while (typeSpec2.IsArray) { typeSpec2 = ((ArrayContainer)typeSpec2).Element; } if (typeSpec2.IsGenericParameter || TypeManager.IsGenericType(typeSpec2)) { RemoveDependentTypes(list, typeSpec2); } } } foreach (TypeSpec item in list) { if (item != null) { int num = IsUnfixed(item); if (num >= 0 && !FixType(ec, num)) { return false; } } } fixed_any = list.Count > 0; return true; } public bool FixType(ResolveContext ec, int i) { if (fixed_types[i] != null) { throw new InternalErrorException("Type argument has been already fixed"); } List list = bounds[i]; if (list == null) { return false; } if (list.Count == 1) { TypeSpec type = list[0].Type; if (type == InternalType.NullLiteral) { return false; } fixed_types[i] = type; return true; } bool[] array = new bool[list.Count]; for (int j = 0; j < array.Length; j++) { array[j] = true; } for (int k = 0; k < array.Length; k++) { BoundInfo boundInfo = list[k]; int l = 0; switch (boundInfo.Kind) { case BoundKind.Exact: for (; l != array.Length; l++) { if (k != l && array[l] && list[l].Type != boundInfo.Type) { array[l] = false; } } continue; case BoundKind.Lower: for (; l != array.Length; l++) { if (k != l && array[l] && !Convert.ImplicitConversionExists(ec, boundInfo.GetTypeExpression(), list[l].Type)) { array[l] = false; } } continue; case BoundKind.Upper: break; default: continue; } for (; l != array.Length; l++) { if (k != l && array[l] && !Convert.ImplicitConversionExists(ec, list[l].GetTypeExpression(), boundInfo.Type)) { array[l] = false; } } } TypeSpec typeSpec = null; for (int m = 0; m < array.Length; m++) { if (!array[m]) { continue; } BoundInfo boundInfo2 = list[m]; if (TypeSpecComparer.IsEqual(boundInfo2.Type, typeSpec)) { continue; } int n; for (n = 0; n < array.Length && (m == n || !array[n] || Convert.ImplicitConversionExists(ec, list[n].GetTypeExpression(), boundInfo2.Type)); n++) { } if (n != array.Length) { continue; } if (typeSpec != null) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { continue; } if (boundInfo2.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic && typeSpec != boundInfo2.Type) { return false; } } typeSpec = boundInfo2.Type; } if (typeSpec == null) { return false; } fixed_types[i] = typeSpec; return true; } public bool HasBounds(int pos) { return bounds[pos] != null; } public TypeSpec InflateGenericArgument(IModuleContext context, TypeSpec parameter) { if (parameter is TypeParameterSpec typeParameterSpec) { if (!typeParameterSpec.IsMethodOwned) { return parameter; } if (typeParameterSpec.DeclaredPosition < tp_args.Length && tp_args[typeParameterSpec.DeclaredPosition] == parameter) { return fixed_types[typeParameterSpec.DeclaredPosition] ?? parameter; } return parameter; } if (parameter is InflatedTypeSpec inflatedTypeSpec) { TypeSpec[] array = new TypeSpec[inflatedTypeSpec.TypeArguments.Length]; for (int i = 0; i < array.Length; i++) { TypeSpec typeSpec = InflateGenericArgument(context, inflatedTypeSpec.TypeArguments[i]); if (typeSpec == null) { return null; } array[i] = typeSpec; } return inflatedTypeSpec.GetDefinition().MakeGenericType(context, array); } if (parameter is ArrayContainer arrayContainer) { TypeSpec typeSpec2 = InflateGenericArgument(context, arrayContainer.Element); if (typeSpec2 != arrayContainer.Element) { return ArrayContainer.MakeType(context.Module, typeSpec2); } } return parameter; } public bool IsReturnTypeNonDependent(MethodSpec invoke, TypeSpec returnType) { AParametersCollection parameters = invoke.Parameters; if (parameters.IsEmpty) { return true; } while (returnType.IsArray) { returnType = ((ArrayContainer)returnType).Element; } if (returnType.IsGenericParameter) { if (IsFixed(returnType)) { return false; } } else { if (!TypeManager.IsGenericType(returnType)) { return false; } TypeSpec[] typeArguments = TypeManager.GetTypeArguments(returnType); if (AllTypesAreFixed(typeArguments)) { return false; } } return AllTypesAreFixed(parameters.Types); } private bool IsFixed(TypeSpec type) { return IsUnfixed(type) == -1; } private int IsUnfixed(TypeSpec type) { if (!type.IsGenericParameter) { return -1; } for (int i = 0; i < tp_args.Length; i++) { if (tp_args[i] == type) { if (fixed_types[i] != null) { break; } return i; } } return -1; } public int LowerBoundInference(TypeSpec u, TypeSpec v) { return LowerBoundInference(u, v, inversed: false); } private int LowerBoundInference(TypeSpec u, TypeSpec v, bool inversed) { int num = IsUnfixed(v); if (num != -1) { AddToBounds(new BoundInfo(u, (!inversed) ? BoundKind.Lower : BoundKind.Upper), num, voidAllowed: false); return 1; } if (u is ArrayContainer arrayContainer) { if (v is ArrayContainer arrayContainer2) { if (arrayContainer.Rank != arrayContainer2.Rank) { return 0; } if (TypeSpec.IsValueType(arrayContainer.Element)) { return ExactInference(arrayContainer.Element, arrayContainer2.Element); } return LowerBoundInference(arrayContainer.Element, arrayContainer2.Element, inversed); } if (arrayContainer.Rank != 1 || !v.IsArrayGenericInterface) { return 0; } TypeSpec v2 = TypeManager.GetTypeArguments(v)[0]; if (TypeSpec.IsValueType(arrayContainer.Element)) { return ExactInference(arrayContainer.Element, v2); } return LowerBoundInference(arrayContainer.Element, v2); } if (v.IsGenericOrParentIsGeneric) { List list = new List(); ITypeDefinition memberDefinition = v.MemberDefinition; for (TypeSpec typeSpec = u; typeSpec != null; typeSpec = typeSpec.BaseType) { if (memberDefinition == typeSpec.MemberDefinition) { list.Add(typeSpec); } if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { list.Add(typeSpec); } } if (u.Interfaces != null) { foreach (TypeSpec @interface in u.Interfaces) { if (memberDefinition == @interface.MemberDefinition) { list.Add(@interface); } } } TypeSpec[] array = null; TypeSpec[] allTypeArguments = TypeSpec.GetAllTypeArguments(v); foreach (TypeSpec item in list) { if (array != null) { TypeSpec[] allTypeArguments2 = TypeSpec.GetAllTypeArguments(item); if (!TypeSpecComparer.Equals(array, allTypeArguments2)) { return 0; } array = allTypeArguments2; } else if (item.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { array = new TypeSpec[allTypeArguments.Length]; for (int i = 0; i < array.Length; i++) { array[i] = item; } } else { array = TypeSpec.GetAllTypeArguments(item); } } if (array != null) { int num2 = 0; int num3 = -1; TypeParameterSpec[] array2 = null; for (int j = 0; j < array.Length; j++) { if (num3 < 0) { while (v.Arity == 0) { v = v.DeclaringType; } array2 = v.MemberDefinition.TypeParameters; num3 = array2.Length - 1; } Variance variance = array2[num3--].Variance; TypeSpec typeSpec2 = array[j]; if (variance == Variance.None || TypeSpec.IsValueType(typeSpec2)) { if (ExactInference(typeSpec2, allTypeArguments[j]) == 0) { num2++; } continue; } bool inversed2 = (variance == Variance.Contravariant && !inversed) || (variance == Variance.Covariant && inversed); if (LowerBoundInference(typeSpec2, allTypeArguments[j], inversed2) == 0) { num2++; } } return num2; } } return 0; } public int OutputTypeInference(ResolveContext ec, Expression e, TypeSpec t) { if (e is AnonymousMethodExpression anonymousMethodExpression) { TypeSpec typeSpec = anonymousMethodExpression.InferReturnType(ec, this, t); MethodSpec invokeMethod = Delegate.GetInvokeMethod(t); if (typeSpec == null) { AParametersCollection parameters = invokeMethod.Parameters; return (anonymousMethodExpression.Parameters.Count == parameters.Count) ? 1 : 0; } TypeSpec returnType = invokeMethod.ReturnType; return LowerBoundInference(typeSpec, returnType) + 1; } if (e is MethodGroupExpr) { if (!t.IsDelegate) { if (!t.IsExpressionTreeType) { return 0; } t = TypeManager.GetTypeArguments(t)[0]; } MethodSpec invokeMethod2 = Delegate.GetInvokeMethod(t); TypeSpec returnType2 = invokeMethod2.ReturnType; if (!IsReturnTypeNonDependent(invokeMethod2, returnType2)) { return 0; } TypeSpec[] array = new TypeSpec[invokeMethod2.Parameters.Count]; for (int i = 0; i < array.Length; i++) { TypeSpec typeSpec2 = InflateGenericArgument(ec, invokeMethod2.Parameters.Types[i]); if (typeSpec2 == null) { return 0; } array[i] = typeSpec2; } MethodGroupExpr methodGroupExpr = (MethodGroupExpr)e; Arguments args = DelegateCreation.CreateDelegateMethodArguments(ec, invokeMethod2.Parameters, array, e.Location); methodGroupExpr = methodGroupExpr.OverloadResolve(ec, ref args, null, OverloadResolver.Restrictions.ProbingOnly | OverloadResolver.Restrictions.CovariantDelegate); if (methodGroupExpr == null) { return 0; } return LowerBoundInference(methodGroupExpr.BestCandidateReturnType, returnType2) + 1; } return LowerBoundInference(e.Type, t) * 2; } private void RemoveDependentTypes(List types, TypeSpec returnType) { int num = IsUnfixed(returnType); if (num >= 0) { types[num] = null; } else if (TypeManager.IsGenericType(returnType)) { TypeSpec[] typeArguments = TypeManager.GetTypeArguments(returnType); foreach (TypeSpec returnType2 in typeArguments) { RemoveDependentTypes(types, returnType2); } } } } internal abstract class MetadataImporter { protected struct AttributesTypeInfoReader { private static readonly bool[] single_attribute = new bool[1] { true }; public int DynamicPosition; private bool[] dynamicFlags; public int TuplePosition; private string[] tupleNames; private object provider; public AttributesTypeInfoReader(object provider) { DynamicPosition = 0; TuplePosition = 0; dynamicFlags = null; tupleNames = null; this.provider = provider; } public bool IsDynamicObject() { if (provider != null) { ReadAttribute(); } return dynamicFlags != null && DynamicPosition < dynamicFlags.Length && dynamicFlags[DynamicPosition]; } public bool HasDynamicAttribute() { if (provider != null) { ReadAttribute(); } return dynamicFlags != null; } public bool HasNamedTupleAttribute() { if (provider != null) { ReadAttribute(); } return tupleNames != null; } public IList GetNamedTupleElements(int length) { if (TuplePosition == 0 && length == tupleNames.Length) { return tupleNames; } for (int i = TuplePosition; i < length + TuplePosition; i++) { if (tupleNames[i] != null) { string[] array = new string[length]; Array.Copy(tupleNames, TuplePosition, array, 0, length); return array; } } return null; } private IList GetCustomAttributes() { if (provider is MemberInfo target) { return CustomAttributeData.GetCustomAttributes(target); } if (provider is ParameterInfo target2) { return CustomAttributeData.GetCustomAttributes(target2); } provider = null; return null; } private void ReadAttribute() { IList customAttributes = GetCustomAttributes(); if (customAttributes == null) { return; } if (customAttributes.Count > 0) { foreach (CustomAttributeData item in customAttributes) { Type declaringType = item.Constructor.DeclaringType; if (declaringType.Namespace != CompilerServicesNamespace) { continue; } string name = declaringType.Name; string text = name; if (!(text == "DynamicAttribute")) { if (!(text == "TupleElementNamesAttribute") || item.ConstructorArguments.Count != 1) { continue; } Type argumentType = item.ConstructorArguments[0].ArgumentType; if (!argumentType.IsArray || Type.GetTypeCode(argumentType.GetElementType()) != TypeCode.String) { continue; } IList list = (IList)item.ConstructorArguments[0].Value; tupleNames = new string[list.Count]; for (int i = 0; i < tupleNames.Length; i++) { if (Type.GetTypeCode(list[i].ArgumentType) == TypeCode.String) { tupleNames[i] = (string)list[i].Value; } } continue; } if (item.ConstructorArguments.Count == 0) { dynamicFlags = single_attribute; continue; } Type argumentType2 = item.ConstructorArguments[0].ArgumentType; if (!argumentType2.IsArray || Type.GetTypeCode(argumentType2.GetElementType()) != TypeCode.Boolean) { continue; } IList list2 = (IList)item.ConstructorArguments[0].Value; dynamicFlags = new bool[list2.Count]; for (int j = 0; j < dynamicFlags.Length; j++) { if (Type.GetTypeCode(list2[j].ArgumentType) == TypeCode.Boolean) { dynamicFlags[j] = (bool)list2[j].Value; } } } } provider = null; } } protected readonly Dictionary import_cache; protected readonly Dictionary compiled_types; protected readonly Dictionary assembly_2_definition; protected readonly ModuleContainer module; public static readonly string CompilerServicesNamespace = "System.Runtime.CompilerServices"; public ICollection Assemblies => assembly_2_definition.Values; public bool IgnorePrivateMembers { get; set; } public bool IgnoreCompilerGeneratedField { get; set; } protected MetadataImporter(ModuleContainer module) { this.module = module; import_cache = new Dictionary(1024, ReferenceEquality.Default); compiled_types = new Dictionary(40, ReferenceEquality.Default); assembly_2_definition = new Dictionary(ReferenceEquality.Default); IgnorePrivateMembers = true; IgnoreCompilerGeneratedField = true; } public abstract void AddCompiledType(TypeBuilder builder, TypeSpec spec); protected abstract MemberKind DetermineKindFromBaseType(Type baseType); protected abstract bool HasVolatileModifier(Type[] modifiers); public FieldSpec CreateField(FieldInfo fi, TypeSpec declaringType) { FieldAttributes attributes = fi.Attributes; Modifiers modifiers; switch (attributes & FieldAttributes.FieldAccessMask) { case FieldAttributes.Public: modifiers = Modifiers.PUBLIC; break; case FieldAttributes.Assembly: modifiers = Modifiers.INTERNAL; break; case FieldAttributes.Family: modifiers = Modifiers.PROTECTED; break; case FieldAttributes.FamORAssem: modifiers = Modifiers.PROTECTED | Modifiers.INTERNAL; break; default: if (IgnorePrivateMembers && !declaringType.IsStruct) { return null; } if (IgnoreCompilerGeneratedField && HasAttribute(CustomAttributeData.GetCustomAttributes(fi), "CompilerGeneratedAttribute", CompilerServicesNamespace)) { return null; } modifiers = Modifiers.PRIVATE; break; } TypeSpec typeSpec; try { typeSpec = ImportType(fi.FieldType, new AttributesTypeInfoReader(fi), declaringType); if (typeSpec == null) { return null; } } catch (Exception exception) { throw new InternalErrorException(exception, "Cannot import field `{0}.{1}' referenced in assembly `{2}'", declaringType.GetSignatureForError(), fi.Name, declaringType.MemberDefinition.DeclaringAssembly); } ImportedMemberDefinition definition = new ImportedMemberDefinition(fi, typeSpec, this); if ((attributes & FieldAttributes.Literal) != FieldAttributes.PrivateScope) { Constant value = ((typeSpec.Kind == MemberKind.MissingType) ? new NullConstant(InternalType.ErrorType, Location.Null) : CreateConstantFromValue(typeSpec, fi)); return new ConstSpec(declaringType, definition, typeSpec, fi, modifiers | Modifiers.STATIC, value); } if ((attributes & FieldAttributes.InitOnly) != FieldAttributes.PrivateScope) { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Decimal) { Constant constant = ReadDecimalConstant(CustomAttributeData.GetCustomAttributes(fi)); if (constant != null) { return new ConstSpec(declaringType, definition, typeSpec, fi, modifiers | Modifiers.STATIC, constant); } } modifiers |= Modifiers.READONLY; } else { Type[] requiredCustomModifiers = fi.GetRequiredCustomModifiers(); if (requiredCustomModifiers.Length != 0 && HasVolatileModifier(requiredCustomModifiers)) { modifiers |= Modifiers.VOLATILE; } } if ((attributes & FieldAttributes.Static) != FieldAttributes.PrivateScope) { modifiers |= Modifiers.STATIC; } else if (declaringType.IsStruct && typeSpec.IsStruct && typeSpec.IsNested && HasAttribute(CustomAttributeData.GetCustomAttributes(fi), "FixedBufferAttribute", CompilerServicesNamespace)) { FieldSpec element = CreateField(fi.FieldType.GetField("FixedElementField"), declaringType); return new FixedFieldSpec(module, declaringType, definition, fi, element, modifiers); } return new FieldSpec(declaringType, definition, typeSpec, fi, modifiers); } private Constant CreateConstantFromValue(TypeSpec fieldType, FieldInfo fi) { object rawConstantValue = fi.GetRawConstantValue(); if (rawConstantValue != null && !fieldType.IsEnum) { Constant constant = ImportConstant(rawConstantValue); if (constant != null) { return (fieldType == constant.Type) ? constant : constant.ConvertExplicitly(in_checked_context: false, fieldType); } } return Constant.CreateConstantFromValue(fieldType, rawConstantValue, Location.Null); } public EventSpec CreateEvent(EventInfo ei, TypeSpec declaringType, MethodSpec add, MethodSpec remove) { add.IsAccessor = true; remove.IsAccessor = true; if (add.Modifiers != remove.Modifiers) { throw new NotImplementedException("Different accessor modifiers " + ei.Name); } TypeSpec typeSpec = ImportType(ei.EventHandlerType, new AttributesTypeInfoReader(ei), declaringType); ImportedMemberDefinition definition = new ImportedMemberDefinition(ei, typeSpec, this); return new EventSpec(declaringType, definition, typeSpec, add.Modifiers, add, remove); } private TypeParameterSpec[] CreateGenericParameters(Type type, TypeSpec declaringType) { Type[] genericArguments = type.GetGenericArguments(); int num; if (type.IsNested) { num = type.DeclaringType.GetGenericArguments().Length; if (declaringType != null && num > 0) { int num2 = 0; while (num2 != num) { int arity = declaringType.Arity; if (arity != 0) { TypeParameterSpec[] typeParameters = declaringType.MemberDefinition.TypeParameters; num2 += arity; for (int i = 0; i < arity; i++) { import_cache.Add(genericArguments[num - num2 + i], typeParameters[i]); } } declaringType = declaringType.DeclaringType; } } } else { num = 0; } if (genericArguments.Length - num == 0) { return null; } return CreateGenericParameters(num, genericArguments); } private TypeParameterSpec[] CreateGenericParameters(int first, Type[] tparams) { TypeParameterSpec[] array = new TypeParameterSpec[tparams.Length - first]; for (int i = first; i < tparams.Length; i++) { Type type = tparams[i]; int num = i - first; array[num] = (TypeParameterSpec)CreateType(type, default(AttributesTypeInfoReader), canImportBaseType: false); } return array; } private TypeSpec[] CreateGenericArguments(int first, Type[] tparams, AttributesTypeInfoReader dtype) { dtype.DynamicPosition++; TypeSpec[] array = new TypeSpec[tparams.Length - first]; for (int i = first; i < tparams.Length; i++) { Type type = tparams[i]; int num = i - first; TypeSpec element; if (type.HasElementType) { Type elementType = type.GetElementType(); dtype.DynamicPosition++; element = ImportType(elementType, dtype, null); if (!type.IsArray) { throw new NotImplementedException("Unknown element type " + type.ToString()); } element = ArrayContainer.MakeType(module, element, type.GetArrayRank()); } else { element = CreateType(type, dtype, canImportBaseType: true); if (!IsMissingType(type) && type.IsGenericTypeDefinition) { int declaringTypesTypeParametersCount = GetDeclaringTypesTypeParametersCount(element); TypeSpec[] targs = CreateGenericArguments(declaringTypesTypeParametersCount, type.GetGenericArguments(), dtype); element = element.MakeGenericType(module, targs); } } if (element == null) { return null; } dtype.DynamicPosition++; array[num] = element; } return array; } private static int GetDeclaringTypesTypeParametersCount(TypeSpec spec) { int num = 0; while (spec.DeclaringType != null) { num += spec.DeclaringType.MemberDefinition.TypeParametersCount; spec = spec.DeclaringType; } return num; } public MethodSpec CreateMethod(MethodBase mb, TypeSpec declaringType) { Modifiers modifiers = ReadMethodModifiers(mb, declaringType); AParametersCollection aParametersCollection = CreateParameters(declaringType, mb.GetParameters(), mb); TypeParameterSpec[] array; if (mb.IsGenericMethod) { if (!mb.IsGenericMethodDefinition) { throw new NotSupportedException("assert"); } array = CreateGenericParameters(0, mb.GetGenericArguments()); } else { array = null; } MemberKind memberKind; TypeSpec typeSpec; if (mb.MemberType == MemberTypes.Constructor) { memberKind = MemberKind.Constructor; typeSpec = module.Compiler.BuiltinTypes.Void; } else { MethodInfo methodInfo = (MethodInfo)mb; typeSpec = ImportType(methodInfo.ReturnType, new AttributesTypeInfoReader(methodInfo.ReturnParameter), declaringType); string name = mb.Name; memberKind = MemberKind.Method; if (array == null && !mb.DeclaringType.IsInterface && name.Length > 6) { if ((modifiers & (Modifiers.PUBLIC | Modifiers.STATIC)) == (Modifiers.PUBLIC | Modifiers.STATIC)) { if (name[2] == '_' && name[1] == 'p' && name[0] == 'o' && (mb.Attributes & MethodAttributes.SpecialName) != MethodAttributes.PrivateScope && Operator.GetType(name).HasValue && aParametersCollection.Count > 0 && aParametersCollection.Count < 3) { memberKind = MemberKind.Operator; } } else if (aParametersCollection.IsEmpty && name == Destructor.MetadataName && typeSpec.Kind == MemberKind.Void) { memberKind = MemberKind.Destructor; if (declaringType.BuiltinType == BuiltinTypeSpec.Type.Object) { modifiers &= ~Modifiers.OVERRIDE; modifiers |= Modifiers.VIRTUAL; } } } if ((modifiers & Modifiers.OVERRIDE) != 0) { bool flag = false; if (memberKind == MemberKind.Method && declaringType.BaseType != null) { TypeSpec baseType = declaringType.BaseType; if (IsOverrideMethodBaseTypeAccessible(baseType)) { MemberFilter filter = MemberFilter.Method(name, (array != null) ? array.Length : 0, aParametersCollection, null); MemberSpec memberSpec = MemberCache.FindMember(baseType, filter, BindingRestriction.None); if (memberSpec != null && (memberSpec.Modifiers & (Modifiers.PROTECTED | Modifiers.PUBLIC | Modifiers.PRIVATE)) == (modifiers & (Modifiers.PROTECTED | Modifiers.PUBLIC | Modifiers.PRIVATE)) && !memberSpec.IsStatic) { flag = true; } } } if (!flag) { modifiers &= ~Modifiers.OVERRIDE; modifiers = (((modifiers & Modifiers.SEALED) == 0) ? (modifiers | Modifiers.VIRTUAL) : (modifiers & ~Modifiers.SEALED)); } } else if (aParametersCollection.HasExtensionMethodType) { modifiers |= Modifiers.METHOD_EXTENSION; } } IMethodDefinition details; if (array != null) { ImportedGenericMethodDefinition importedGenericMethodDefinition = new ImportedGenericMethodDefinition((MethodInfo)mb, typeSpec, aParametersCollection, array, this); TypeParameterSpec[] typeParameters = importedGenericMethodDefinition.TypeParameters; foreach (TypeParameterSpec typeParameterSpec in typeParameters) { ImportTypeParameterTypeConstraints(typeParameterSpec, typeParameterSpec.GetMetaInfo()); } details = importedGenericMethodDefinition; } else { details = new ImportedMethodDefinition(mb, typeSpec, aParametersCollection, this); } MethodSpec methodSpec = new MethodSpec(memberKind, declaringType, details, typeSpec, aParametersCollection, modifiers); if (array != null) { methodSpec.IsGeneric = true; } return methodSpec; } private bool IsOverrideMethodBaseTypeAccessible(TypeSpec baseType) { return (baseType.Modifiers & Modifiers.AccessibilityMask) switch { Modifiers.PUBLIC => true, Modifiers.INTERNAL => baseType.MemberDefinition.IsInternalAsPublic(module.DeclaringAssembly), Modifiers.PRIVATE => false, _ => true, }; } private AParametersCollection CreateParameters(TypeSpec parent, ParameterInfo[] pi, MethodBase method) { int num = (((object)method != null && (method.CallingConvention & CallingConventions.VarArgs) != 0) ? 1 : 0); if (pi.Length == 0 && num == 0) { return ParametersCompiled.EmptyReadOnlyParameters; } TypeSpec[] array = new TypeSpec[pi.Length + num]; IParameterData[] array2 = new IParameterData[pi.Length + num]; bool flag = false; for (int i = 0; i < pi.Length; i++) { ParameterInfo parameterInfo = pi[i]; Parameter.Modifier modifier = Parameter.Modifier.NONE; Expression expression = null; if (parameterInfo.ParameterType.IsByRef) { modifier = (((parameterInfo.Attributes & (ParameterAttributes.In | ParameterAttributes.Out)) != ParameterAttributes.Out) ? Parameter.Modifier.REF : Parameter.Modifier.OUT); Type elementType = parameterInfo.ParameterType.GetElementType(); array[i] = ImportType(elementType, new AttributesTypeInfoReader(parameterInfo), parent); } else if (i == 0 && method.IsStatic && (parent.Modifiers & Modifiers.METHOD_EXTENSION) != 0 && HasAttribute(CustomAttributeData.GetCustomAttributes(method), "ExtensionAttribute", CompilerServicesNamespace)) { modifier = Parameter.Modifier.This; array[i] = ImportType(parameterInfo.ParameterType, new AttributesTypeInfoReader(parameterInfo), parent); } else { array[i] = ImportType(parameterInfo.ParameterType, new AttributesTypeInfoReader(parameterInfo), parent); if (i >= pi.Length - 2 && array[i] is ArrayContainer && HasAttribute(CustomAttributeData.GetCustomAttributes(parameterInfo), "ParamArrayAttribute", "System")) { modifier = Parameter.Modifier.PARAMS; flag = true; } if (!flag && parameterInfo.IsOptional) { object rawDefaultValue = parameterInfo.RawDefaultValue; TypeSpec typeSpec = array[i]; if ((parameterInfo.Attributes & ParameterAttributes.HasDefault) != ParameterAttributes.None && typeSpec.Kind != MemberKind.TypeParameter && (rawDefaultValue != null || TypeSpec.IsReferenceType(typeSpec))) { if (rawDefaultValue == null) { expression = Constant.CreateConstantFromValue(typeSpec, null, Location.Null); } else { expression = ImportConstant(rawDefaultValue); if (typeSpec.IsEnum) { expression = new EnumConstant((Constant)expression, typeSpec); } } IList customAttributes = CustomAttributeData.GetCustomAttributes(parameterInfo); for (int j = 0; j < customAttributes.Count; j++) { CustomAttributeData customAttributeData = customAttributes[j]; Type declaringType = customAttributeData.Constructor.DeclaringType; if (!(declaringType.Namespace != CompilerServicesNamespace)) { if (declaringType.Name == "CallerLineNumberAttribute" && (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Int || Convert.ImplicitNumericConversionExists(module.Compiler.BuiltinTypes.Int, typeSpec))) { modifier |= Parameter.Modifier.CallerLineNumber; } else if (declaringType.Name == "CallerFilePathAttribute" && Convert.ImplicitReferenceConversionExists(module.Compiler.BuiltinTypes.String, typeSpec)) { modifier |= Parameter.Modifier.CallerFilePath; } else if (declaringType.Name == "CallerMemberNameAttribute" && Convert.ImplicitReferenceConversionExists(module.Compiler.BuiltinTypes.String, typeSpec)) { modifier |= Parameter.Modifier.CallerMemberName; } } } } else if (rawDefaultValue == Missing.Value) { expression = EmptyExpression.MissingValue; } else if (rawDefaultValue == null) { expression = new DefaultValueExpression(new TypeExpression(typeSpec, Location.Null), Location.Null); } else if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Decimal) { expression = ImportConstant(rawDefaultValue); } } } array2[i] = new ParameterData(parameterInfo.Name, modifier, expression); } if (num != 0) { array2[^1] = new ArglistParameter(Location.Null); array[^1] = InternalType.Arglist; } return ((object)method != null) ? new ParametersImported(array2, array, num != 0, flag) : new ParametersImported(array2, array, flag); } public PropertySpec CreateProperty(PropertyInfo pi, TypeSpec declaringType, MethodSpec get, MethodSpec set) { Modifiers modifiers = (Modifiers)0; AParametersCollection aParametersCollection = null; TypeSpec typeSpec = null; if (get != null) { modifiers = get.Modifiers; aParametersCollection = get.Parameters; typeSpec = get.ReturnType; } bool flag = true; if (set != null) { if (set.ReturnType.Kind != MemberKind.Void) { flag = false; } int num = set.Parameters.Count - 1; if (num < 0) { num = 0; flag = false; } TypeSpec typeSpec2 = set.Parameters.Types[num]; if (modifiers == (Modifiers)0) { AParametersCollection aParametersCollection2 = ((num != 0) ? ((AParametersCollection)IndexerSpec.CreateParametersFromSetter(set, num)) : ((AParametersCollection)ParametersCompiled.EmptyReadOnlyParameters)); modifiers = set.Modifiers; aParametersCollection = aParametersCollection2; typeSpec = typeSpec2; } else { if (num != get.Parameters.Count) { flag = false; } if (get.ReturnType != typeSpec2) { flag = false; } if ((modifiers & Modifiers.AccessibilityMask) != (set.Modifiers & Modifiers.AccessibilityMask)) { Modifiers modifiers2 = modifiers & Modifiers.AccessibilityMask; if (modifiers2 != Modifiers.PUBLIC) { Modifiers modifiers3 = set.Modifiers & Modifiers.AccessibilityMask; if (modifiers2 != modifiers3) { bool flag2 = ModifiersExtensions.IsRestrictedModifier(modifiers2, modifiers3); bool flag3 = ModifiersExtensions.IsRestrictedModifier(modifiers3, modifiers2); if (flag2 && flag3) { flag = false; } if (flag2) { modifiers &= ~Modifiers.AccessibilityMask; modifiers |= modifiers3; } } } } } } PropertySpec propertySpec = null; if (!aParametersCollection.IsEmpty && flag) { string attributeDefaultMember = declaringType.MemberDefinition.GetAttributeDefaultMember(); if (attributeDefaultMember == null || attributeDefaultMember != pi.Name) { flag = false; } else { if (get != null && get.IsStatic) { flag = false; } if (set != null && set.IsStatic) { flag = false; } } if (flag) { propertySpec = new IndexerSpec(declaringType, new ImportedParameterMemberDefinition(pi, typeSpec, aParametersCollection, this), typeSpec, aParametersCollection, pi, modifiers); } else if (declaringType.MemberDefinition.IsComImport && aParametersCollection.FixedParameters[0].HasDefaultValue) { flag = true; for (int i = 0; i < aParametersCollection.FixedParameters.Length; i++) { if (!aParametersCollection.FixedParameters[i].HasDefaultValue) { flag = false; break; } } } } if (propertySpec == null) { propertySpec = new PropertySpec(MemberKind.Property, declaringType, new ImportedMemberDefinition(pi, typeSpec, this), typeSpec, pi, modifiers); } if (!flag) { propertySpec.IsNotCSharpCompatible = true; return propertySpec; } if (set != null) { propertySpec.Set = set; } if (get != null) { propertySpec.Get = get; } return propertySpec; } public TypeSpec CreateType(Type type) { return CreateType(type, default(AttributesTypeInfoReader), canImportBaseType: true); } public TypeSpec CreateNestedType(Type type, TypeSpec declaringType) { return CreateType(type, declaringType, new AttributesTypeInfoReader(type), canImportBaseType: false); } private TypeSpec CreateType(Type type, AttributesTypeInfoReader dtype, bool canImportBaseType) { TypeSpec declaringType = ((!type.IsNested || type.IsGenericParameter) ? null : CreateType(type.DeclaringType, new AttributesTypeInfoReader(type.DeclaringType), canImportBaseType: true)); return CreateType(type, declaringType, dtype, canImportBaseType); } protected TypeSpec CreateType(Type type, TypeSpec declaringType, AttributesTypeInfoReader dtype, bool canImportBaseType) { if (import_cache.TryGetValue(type, out var value)) { if (value.BuiltinType == BuiltinTypeSpec.Type.Object) { if (dtype.IsDynamicObject()) { return module.Compiler.BuiltinTypes.Dynamic; } return value; } if (!value.IsGeneric || type.IsGenericTypeDefinition) { return value; } if (!dtype.HasDynamicAttribute()) { return value; } } if (IsMissingType(type)) { value = new TypeSpec(MemberKind.MissingType, declaringType, new ImportedTypeDefinition(type, this), type, Modifiers.PUBLIC); value.MemberCache = MemberCache.Empty; import_cache.Add(type, value); return value; } if (type.IsGenericType && !type.IsGenericTypeDefinition) { Type genericTypeDefinition = type.GetGenericTypeDefinition(); if (compiled_types.TryGetValue(genericTypeDefinition, out value)) { return value; } TypeSpec[] array = CreateGenericArguments(0, type.GetGenericArguments(), dtype); if (array == null) { return null; } if (declaringType == null) { value = CreateType(genericTypeDefinition, null, default(AttributesTypeInfoReader), canImportBaseType); value = value.MakeGenericType(module, array); } else { List list = new List(); while (declaringType.IsNested) { list.Add(declaringType); declaringType = declaringType.DeclaringType; } int num = 0; if (declaringType.Arity > 0) { value = declaringType.MakeGenericType(module, array.Skip(num).Take(declaringType.Arity).ToArray()); num = value.Arity; } else { value = declaringType; } for (int num2 = list.Count; num2 != 0; num2--) { TypeSpec typeSpec = list[num2 - 1]; value = ((typeSpec.Kind != MemberKind.MissingType) ? MemberCache.FindNestedType(value, typeSpec.Name, typeSpec.Arity, declaredOnlyClass: false) : typeSpec); if (typeSpec.Arity > 0) { value = value.MakeGenericType(module, array.Skip(num).Take(value.Arity).ToArray()); num += typeSpec.Arity; } } if (value.Kind == MemberKind.MissingType) { value = new TypeSpec(MemberKind.MissingType, value, new ImportedTypeDefinition(genericTypeDefinition, this), genericTypeDefinition, Modifiers.PUBLIC); value.MemberCache = MemberCache.Empty; } else { if ((genericTypeDefinition.Attributes & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPrivate && IgnorePrivateMembers) { return null; } string text = type.Name; int num3 = text.IndexOf('`'); if (num3 > 0) { text = text.Substring(0, num3); } value = MemberCache.FindNestedType(value, text, array.Length - num, declaredOnlyClass: false); if (value.Arity > 0) { value = value.MakeGenericType(module, array.Skip(num).ToArray()); } } } if (value.IsTupleType && dtype.HasNamedTupleAttribute()) { IList namedTupleElements = dtype.GetNamedTupleElements(value.Arity); if (namedTupleElements != null) { return NamedTupleSpec.MakeType(module, (InflatedTypeSpec)value, namedTupleElements); } dtype.TuplePosition += value.Arity; } if (!value.HasDynamicElement && !import_cache.ContainsKey(type)) { import_cache.Add(type, value); } return value; } TypeAttributes attributes = type.Attributes; Modifiers modifiers; switch (attributes & TypeAttributes.VisibilityMask) { case TypeAttributes.Public: case TypeAttributes.NestedPublic: modifiers = Modifiers.PUBLIC; break; case TypeAttributes.NestedPrivate: modifiers = Modifiers.PRIVATE; break; case TypeAttributes.NestedFamily: modifiers = Modifiers.PROTECTED; break; case TypeAttributes.VisibilityMask: modifiers = Modifiers.PROTECTED | Modifiers.INTERNAL; break; default: modifiers = Modifiers.INTERNAL; break; } MemberKind memberKind; if ((attributes & TypeAttributes.ClassSemanticsMask) != TypeAttributes.NotPublic) { memberKind = MemberKind.Interface; } else if (type.IsGenericParameter) { memberKind = MemberKind.TypeParameter; } else { Type baseType = type.BaseType; if ((object)baseType == null || (attributes & TypeAttributes.Abstract) != TypeAttributes.NotPublic) { memberKind = MemberKind.Class; } else { memberKind = DetermineKindFromBaseType(baseType); if (memberKind == MemberKind.Struct || memberKind == MemberKind.Delegate) { modifiers |= Modifiers.SEALED; } } switch (memberKind) { case MemberKind.Class: if ((attributes & TypeAttributes.Sealed) != TypeAttributes.NotPublic) { modifiers = (((attributes & TypeAttributes.Abstract) == 0) ? (modifiers | Modifiers.SEALED) : (modifiers | Modifiers.STATIC)); } else if ((attributes & TypeAttributes.Abstract) != TypeAttributes.NotPublic) { modifiers |= Modifiers.ABSTRACT; } break; case MemberKind.Struct: if (HasAttribute(CustomAttributeData.GetCustomAttributes(type), "IsReadOnlyAttribute", CompilerServicesNamespace)) { modifiers |= Modifiers.READONLY; } if (HasAttribute(CustomAttributeData.GetCustomAttributes(type), "IsByRefLikeAttribute", CompilerServicesNamespace)) { modifiers |= Modifiers.REF; } break; } } ImportedTypeDefinition importedTypeDefinition = new ImportedTypeDefinition(type, this); switch (memberKind) { case MemberKind.Enum: { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array2 = fields; int num4 = 0; if (num4 < array2.Length) { FieldInfo fieldInfo = array2[num4]; value = new EnumSpec(declaringType, importedTypeDefinition, CreateType(fieldInfo.FieldType), type, modifiers); } if (value == null) { memberKind = MemberKind.Class; } break; } case MemberKind.TypeParameter: value = CreateTypeParameter(type, declaringType); break; default: { TypeSpec value2; if (type.IsGenericTypeDefinition) { importedTypeDefinition.TypeParameters = CreateGenericParameters(type, declaringType); } else if (compiled_types.TryGetValue(type, out value2)) { value = value2; if (value2 is BuiltinTypeSpec builtinTypeSpec) { builtinTypeSpec.SetDefinition(importedTypeDefinition, type, modifiers); } } break; } } if (value == null) { value = new TypeSpec(memberKind, declaringType, importedTypeDefinition, type, modifiers); } import_cache.Add(type, value); if (memberKind == MemberKind.TypeParameter) { if (canImportBaseType) { ImportTypeParameterTypeConstraints((TypeParameterSpec)value, type); } return value; } if (canImportBaseType) { ImportTypeBase(value, type); } return value; } public IAssemblyDefinition GetAssemblyDefinition(Assembly assembly) { if (!assembly_2_definition.TryGetValue(assembly, out var value)) { ImportedAssemblyDefinition importedAssemblyDefinition = new ImportedAssemblyDefinition(assembly); assembly_2_definition.Add(assembly, importedAssemblyDefinition); importedAssemblyDefinition.ReadAttributes(); return importedAssemblyDefinition; } return value; } public ImportedAssemblyDefinition GetImportedAssemblyDefinition(AssemblyName assemblyName) { foreach (IAssemblyDefinition assembly in Assemblies) { if (!(assembly is ImportedAssemblyDefinition result) || !(assembly.Name == assemblyName.Name)) { continue; } return result; } return null; } public void ImportTypeBase(Type type) { TypeSpec typeSpec = import_cache[type]; if (typeSpec != null) { ImportTypeBase(typeSpec, type); } } private TypeParameterSpec CreateTypeParameter(Type type, TypeSpec declaringType) { Variance variance = (type.GenericParameterAttributes & GenericParameterAttributes.VarianceMask) switch { GenericParameterAttributes.Covariant => Variance.Covariant, GenericParameterAttributes.Contravariant => Variance.Contravariant, _ => Variance.None, }; SpecialConstraint specialConstraint = SpecialConstraint.None; GenericParameterAttributes genericParameterAttributes = type.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask; if ((genericParameterAttributes & GenericParameterAttributes.NotNullableValueTypeConstraint) != GenericParameterAttributes.None) { specialConstraint |= SpecialConstraint.Struct; } else if ((genericParameterAttributes & GenericParameterAttributes.DefaultConstructorConstraint) != GenericParameterAttributes.None) { specialConstraint = SpecialConstraint.Constructor; } if ((genericParameterAttributes & GenericParameterAttributes.ReferenceTypeConstraint) != GenericParameterAttributes.None) { specialConstraint |= SpecialConstraint.Class; } ImportedTypeParameterDefinition definition = new ImportedTypeParameterDefinition(type, this); if ((object)type.DeclaringMethod != null) { return new TypeParameterSpec(type.GenericParameterPosition, definition, specialConstraint, variance, type); } return new TypeParameterSpec(declaringType, type.GenericParameterPosition, definition, specialConstraint, variance, type); } public static bool HasAttribute(IList attributesData, string attrName, string attrNamespace) { if (attributesData.Count == 0) { return false; } foreach (CustomAttributeData attributesDatum in attributesData) { Type declaringType = attributesDatum.Constructor.DeclaringType; if (declaringType.Name == attrName && declaringType.Namespace == attrNamespace) { return true; } } return false; } private void ImportTypeBase(TypeSpec spec, Type type) { if (spec.Kind == MemberKind.Interface) { spec.BaseType = module.Compiler.BuiltinTypes.Object; } else if ((object)type.BaseType != null) { TypeSpec baseType = ((IsMissingType(type.BaseType) || !type.BaseType.IsGenericType) ? CreateType(type.BaseType) : CreateType(type.BaseType, new AttributesTypeInfoReader(type), canImportBaseType: true)); spec.BaseType = baseType; } if (spec.MemberDefinition.TypeParametersCount > 0) { TypeParameterSpec[] typeParameters = spec.MemberDefinition.TypeParameters; foreach (TypeParameterSpec typeParameterSpec in typeParameters) { ImportTypeParameterTypeConstraints(typeParameterSpec, typeParameterSpec.GetMetaInfo()); } } } public void ImportTypes(Type[] types, Namespace targetNamespace, bool importExtensionTypes) { Namespace obj = targetNamespace; string text = null; foreach (Type type in types) { if ((object)type == null || type.MemberType == MemberTypes.NestedType || type.Name[0] == '<') { continue; } TypeSpec typeSpec; try { typeSpec = CreateType(type, null, new AttributesTypeInfoReader(type), canImportBaseType: true); } catch { continue; } if (typeSpec != null) { if (text != type.Namespace) { obj = ((type.Namespace == null) ? targetNamespace : targetNamespace.GetNamespace(type.Namespace, create: true)); text = type.Namespace; } if (typeSpec.IsClass && typeSpec.Arity == 0 && importExtensionTypes && HasAttribute(CustomAttributeData.GetCustomAttributes(type), "ExtensionAttribute", CompilerServicesNamespace)) { typeSpec.SetExtensionMethodContainer(); } obj.AddType(module, typeSpec); } } } private void ImportTypeParameterTypeConstraints(TypeParameterSpec spec, Type type) { Type[] genericParameterConstraints = type.GetGenericParameterConstraints(); List list = null; Type[] array = genericParameterConstraints; foreach (Type type2 in array) { if (type2.IsGenericParameter) { if (list == null) { list = new List(); } list.Add(CreateType(type2)); } else { TypeSpec typeSpec = CreateType(type2); if (typeSpec.IsClass) { spec.BaseType = typeSpec; } else { spec.AddInterface(typeSpec); } } } if (spec.BaseType == null) { spec.BaseType = module.Compiler.BuiltinTypes.Object; } if (list != null) { spec.TypeArguments = list.ToArray(); } } private Constant ImportConstant(object value) { BuiltinTypes builtinTypes = module.Compiler.BuiltinTypes; return Type.GetTypeCode(value.GetType()) switch { TypeCode.Boolean => new BoolConstant(builtinTypes, (bool)value, Location.Null), TypeCode.Byte => new ByteConstant(builtinTypes, (byte)value, Location.Null), TypeCode.Char => new CharConstant(builtinTypes, (char)value, Location.Null), TypeCode.Decimal => new DecimalConstant(builtinTypes, (decimal)value, Location.Null), TypeCode.Double => new DoubleConstant(builtinTypes, (double)value, Location.Null), TypeCode.Int16 => new ShortConstant(builtinTypes, (short)value, Location.Null), TypeCode.Int32 => new IntConstant(builtinTypes, (int)value, Location.Null), TypeCode.Int64 => new LongConstant(builtinTypes, (long)value, Location.Null), TypeCode.SByte => new SByteConstant(builtinTypes, (sbyte)value, Location.Null), TypeCode.Single => new FloatConstant(builtinTypes, (float)value, Location.Null), TypeCode.String => new StringConstant(builtinTypes, (string)value, Location.Null), TypeCode.UInt16 => new UShortConstant(builtinTypes, (ushort)value, Location.Null), TypeCode.UInt32 => new UIntConstant(builtinTypes, (uint)value, Location.Null), TypeCode.UInt64 => new ULongConstant(builtinTypes, (ulong)value, Location.Null), _ => throw new NotImplementedException(value.GetType().ToString()), }; } public TypeSpec ImportType(Type type) { return ImportType(type, new AttributesTypeInfoReader(type), null); } private TypeSpec ImportType(Type type, AttributesTypeInfoReader dtype, TypeSpec currentType) { if (type.HasElementType) { Type elementType = type.GetElementType(); dtype.DynamicPosition++; TypeSpec element = ImportType(elementType, dtype, currentType); if (type.IsArray) { return ArrayContainer.MakeType(module, element, type.GetArrayRank()); } if (type.IsByRef) { return ReferenceContainer.MakeType(module, element); } if (type.IsPointer) { return PointerContainer.MakeType(module, element); } throw new NotImplementedException("Unknown element type " + type.ToString()); } if (compiled_types.TryGetValue(type, out var value)) { if (value.BuiltinType == BuiltinTypeSpec.Type.Object && dtype.IsDynamicObject()) { return module.Compiler.BuiltinTypes.Dynamic; } } else { value = CreateType(type, dtype, canImportBaseType: true); } if (currentType == value && currentType != null && currentType.IsGeneric) { TypeParameterSpec[] typeParameters = value.MemberDefinition.TypeParameters; TypeSpec typeSpec = value; ModuleContainer context = module; TypeSpec[] targs = typeParameters; value = typeSpec.MakeGenericType(context, targs); } return value; } private static bool IsMissingType(Type type) { return false; } private Constant ReadDecimalConstant(IList attrs) { if (attrs.Count == 0) { return null; } foreach (CustomAttributeData attr in attrs) { Type declaringType = attr.Constructor.DeclaringType; if (declaringType.Name != "DecimalConstantAttribute" || declaringType.Namespace != CompilerServicesNamespace) { continue; } decimal d = new decimal((int)(uint)attr.ConstructorArguments[4].Value, (int)(uint)attr.ConstructorArguments[3].Value, (int)(uint)attr.ConstructorArguments[2].Value, (byte)attr.ConstructorArguments[1].Value != 0, (byte)attr.ConstructorArguments[0].Value); return new DecimalConstant(module.Compiler.BuiltinTypes, d, Location.Null); } return null; } private static Modifiers ReadMethodModifiers(MethodBase mb, TypeSpec declaringType) { MethodAttributes attributes = mb.Attributes; Modifiers modifiers = (attributes & MethodAttributes.MemberAccessMask) switch { MethodAttributes.Public => Modifiers.PUBLIC, MethodAttributes.Assembly => Modifiers.INTERNAL, MethodAttributes.Family => Modifiers.PROTECTED, MethodAttributes.FamORAssem => Modifiers.PROTECTED | Modifiers.INTERNAL, _ => Modifiers.PRIVATE, }; if ((attributes & MethodAttributes.Static) != MethodAttributes.PrivateScope) { return modifiers | Modifiers.STATIC; } if ((attributes & MethodAttributes.Abstract) != MethodAttributes.PrivateScope && declaringType.IsClass) { return modifiers | Modifiers.ABSTRACT; } if ((attributes & MethodAttributes.Final) != MethodAttributes.PrivateScope) { modifiers |= Modifiers.SEALED; } if ((attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope) { modifiers = (((attributes & MethodAttributes.VtableLayoutMask) == 0) ? (modifiers | Modifiers.OVERRIDE) : (((modifiers & Modifiers.SEALED) == 0) ? (modifiers | Modifiers.VIRTUAL) : (modifiers & ~Modifiers.SEALED))); } return modifiers; } } internal abstract class ImportedDefinition : IMemberDefinition { protected class AttributesBag { public static readonly AttributesBag Default = new AttributesBag(); public AttributeUsageAttribute AttributeUsage; public ObsoleteAttribute Obsolete; public string[] Conditionals; public string DefaultIndexerName; public bool? CLSAttributeValue; public TypeSpec CoClass; public TypeSpec AsyncMethodBuilder; private static bool HasMissingType(ConstructorInfo ctor) { return false; } public static AttributesBag Read(MemberInfo mi, MetadataImporter importer) { AttributesBag attributesBag = null; List list = null; IList customAttributes = CustomAttributeData.GetCustomAttributes(mi); foreach (CustomAttributeData item in customAttributes) { Type declaringType = item.Constructor.DeclaringType; string name = declaringType.Name; switch (name) { case "ObsoleteAttribute": { if (declaringType.Namespace != "System") { continue; } if (attributesBag == null) { attributesBag = new AttributesBag(); } IList constructorArguments = item.ConstructorArguments; if (constructorArguments.Count == 1) { attributesBag.Obsolete = new ObsoleteAttribute((string)constructorArguments[0].Value); } else if (constructorArguments.Count == 2) { string text = (string)constructorArguments[0].Value; if (!(text == "Types with embedded references are not supported in this version of your compiler.")) { attributesBag.Obsolete = new ObsoleteAttribute(text, (bool)constructorArguments[1].Value); } } else { attributesBag.Obsolete = new ObsoleteAttribute(); } continue; } case "ConditionalAttribute": if (!(declaringType.Namespace != "System.Diagnostics")) { if (attributesBag == null) { attributesBag = new AttributesBag(); } if (list == null) { list = new List(2); } list.Add((string)item.ConstructorArguments[0].Value); } continue; case "CLSCompliantAttribute": if (!(declaringType.Namespace != "System")) { if (attributesBag == null) { attributesBag = new AttributesBag(); } attributesBag.CLSAttributeValue = (bool)item.ConstructorArguments[0].Value; } continue; } if (mi.MemberType != MemberTypes.TypeInfo && mi.MemberType != MemberTypes.NestedType) { continue; } switch (name) { case "DefaultMemberAttribute": if (!(declaringType.Namespace != "System.Reflection")) { if (attributesBag == null) { attributesBag = new AttributesBag(); } attributesBag.DefaultIndexerName = (string)item.ConstructorArguments[0].Value; } break; case "AttributeUsageAttribute": if (declaringType.Namespace != "System" || HasMissingType(item.Constructor)) { break; } if (attributesBag == null) { attributesBag = new AttributesBag(); } attributesBag.AttributeUsage = new AttributeUsageAttribute((AttributeTargets)item.ConstructorArguments[0].Value); foreach (CustomAttributeNamedArgument namedArgument in item.NamedArguments) { if (namedArgument.MemberInfo.Name == "AllowMultiple") { attributesBag.AttributeUsage.AllowMultiple = (bool)namedArgument.TypedValue.Value; } else if (namedArgument.MemberInfo.Name == "Inherited") { attributesBag.AttributeUsage.Inherited = (bool)namedArgument.TypedValue.Value; } } break; case "CoClassAttribute": if (!(declaringType.Namespace != "System.Runtime.InteropServices") && !HasMissingType(item.Constructor)) { if (attributesBag == null) { attributesBag = new AttributesBag(); } attributesBag.CoClass = importer.ImportType((Type)item.ConstructorArguments[0].Value); } break; case "AsyncMethodBuilderAttribute": if (!(declaringType.Namespace != "System.Runtime.CompilerServices") && !HasMissingType(item.Constructor)) { if (attributesBag == null) { attributesBag = new AttributesBag(); } attributesBag.AsyncMethodBuilder = importer.ImportType((Type)item.ConstructorArguments[0].Value); } break; } } if (attributesBag == null) { return Default; } if (list != null) { attributesBag.Conditionals = list.ToArray(); } return attributesBag; } } protected readonly MemberInfo provider; protected AttributesBag cattrs; protected readonly MetadataImporter importer; public bool IsImported => true; public virtual string Name => provider.Name; public bool? CLSAttributeValue { get { if (cattrs == null) { ReadAttributes(); } return cattrs.CLSAttributeValue; } } protected ImportedDefinition(MemberInfo provider, MetadataImporter importer) { this.provider = provider; this.importer = importer; } public string[] ConditionalConditions() { if (cattrs == null) { ReadAttributes(); } return cattrs.Conditionals; } public ObsoleteAttribute GetAttributeObsolete() { if (cattrs == null) { ReadAttributes(); } return cattrs.Obsolete; } protected void ReadAttributes() { cattrs = AttributesBag.Read(provider, importer); } public void SetIsAssigned() { } public void SetIsUsed() { } } internal class ImportedModuleDefinition { private readonly Module module; private bool cls_compliant; public bool IsCLSCompliant => cls_compliant; public string Name => module.Name; public ImportedModuleDefinition(Module module) { this.module = module; } public void ReadAttributes() { IList customAttributes = CustomAttributeData.GetCustomAttributes(module); foreach (CustomAttributeData item in customAttributes) { Type declaringType = item.Constructor.DeclaringType; if (declaringType.Name == "CLSCompliantAttribute" && !(declaringType.Namespace != "System")) { cls_compliant = (bool)item.ConstructorArguments[0].Value; } } } public List ReadAssemblyAttributes() { Type type = module.GetType(AssemblyAttributesPlaceholder.GetGeneratedName(Name)); if ((object)type == null) { return null; } FieldInfo field = type.GetField(AssemblyAttributesPlaceholder.AssemblyFieldName, BindingFlags.Static | BindingFlags.NonPublic); if ((object)field == null) { return null; } return null; } } internal class ImportedAssemblyDefinition : IAssemblyDefinition { private readonly Assembly assembly; private readonly AssemblyName aname; private bool cls_compliant; private List internals_visible_to; private Dictionary internals_visible_to_cache; public Assembly Assembly => assembly; public string FullName => aname.FullName; public bool HasStrongName => aname.GetPublicKey().Length != 0; public bool IsMissing => false; public bool IsCLSCompliant => cls_compliant; public string Location => assembly.Location; public string Name => aname.Name; public ImportedAssemblyDefinition(Assembly assembly) { this.assembly = assembly; aname = assembly.GetName(); } public byte[] GetPublicKeyToken() { return aname.GetPublicKeyToken(); } public AssemblyName GetAssemblyVisibleToName(IAssemblyDefinition assembly) { return internals_visible_to_cache[assembly]; } public bool IsFriendAssemblyTo(IAssemblyDefinition assembly) { if (internals_visible_to == null) { return false; } AssemblyName value = null; if (internals_visible_to_cache == null) { internals_visible_to_cache = new Dictionary(); } else if (internals_visible_to_cache.TryGetValue(assembly, out value)) { return value != null; } byte[] array = assembly.GetPublicKeyToken(); if (array != null && array.Length == 0) { array = null; } foreach (AssemblyName item in internals_visible_to) { if (string.Equals(item.Name, assembly.Name, StringComparison.OrdinalIgnoreCase)) { if (array == null && assembly is AssemblyDefinition) { value = item; break; } if (ArrayComparer.IsEqual(array, item.GetPublicKeyToken())) { value = item; break; } } } internals_visible_to_cache.Add(assembly, value); return value != null; } public void ReadAttributes() { IList customAttributes = CustomAttributeData.GetCustomAttributes(assembly); foreach (CustomAttributeData item2 in customAttributes) { Type declaringType = item2.Constructor.DeclaringType; string name = declaringType.Name; if (name == "CLSCompliantAttribute") { if (declaringType.Namespace == "System") { cls_compliant = (bool)item2.ConstructorArguments[0].Value; } } else if (name == "InternalsVisibleToAttribute" && !(declaringType.Namespace != MetadataImporter.CompilerServicesNamespace) && item2.ConstructorArguments[0].Value is string assemblyName) { AssemblyName item; try { item = new AssemblyName(assemblyName); } catch (FileLoadException) { continue; } if (internals_visible_to == null) { internals_visible_to = new List(); } internals_visible_to.Add(item); } } } public override string ToString() { return FullName; } } internal class ImportedMemberDefinition : ImportedDefinition { private readonly TypeSpec type; public TypeSpec MemberType => type; public ImportedMemberDefinition(MemberInfo member, TypeSpec type, MetadataImporter importer) : base(member, importer) { this.type = type; } } internal class ImportedParameterMemberDefinition : ImportedMemberDefinition, IParametersMember, IInterfaceMemberSpec { private readonly AParametersCollection parameters; public AParametersCollection Parameters => parameters; protected ImportedParameterMemberDefinition(MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer) : base(provider, type, importer) { this.parameters = parameters; } public ImportedParameterMemberDefinition(PropertyInfo provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer) : base(provider, type, importer) { this.parameters = parameters; } } internal class ImportedMethodDefinition : ImportedParameterMemberDefinition, IMethodDefinition, IMemberDefinition { MethodBase IMethodDefinition.Metadata => (MethodBase)provider; public ImportedMethodDefinition(MethodBase provider, TypeSpec type, AParametersCollection parameters, MetadataImporter importer) : base(provider, type, parameters, importer) { } } internal class ImportedGenericMethodDefinition : ImportedMethodDefinition, IGenericMethodDefinition, IMethodDefinition, IMemberDefinition { private readonly TypeParameterSpec[] tparams; public TypeParameterSpec[] TypeParameters => tparams; public int TypeParametersCount => tparams.Length; public ImportedGenericMethodDefinition(MethodInfo provider, TypeSpec type, AParametersCollection parameters, TypeParameterSpec[] tparams, MetadataImporter importer) : base(provider, type, parameters, importer) { this.tparams = tparams; } } internal class ImportedTypeDefinition : ImportedDefinition, ITypeDefinition, IMemberDefinition { private TypeParameterSpec[] tparams; private string name; public IAssemblyDefinition DeclaringAssembly => importer.GetAssemblyDefinition(provider.Module.Assembly); bool ITypeDefinition.IsComImport => ((Type)provider).IsImport; bool ITypeDefinition.IsPartial => false; bool ITypeDefinition.IsTypeForwarder => false; bool ITypeDefinition.IsCyclicTypeForwarder => false; public override string Name { get { if (name == null) { name = base.Name; if (tparams != null) { int num = name.IndexOf('`'); if (num > 0) { name = name.Substring(0, num); } } } return name; } } public string Namespace => ((Type)provider).Namespace; public int TypeParametersCount => (tparams != null) ? tparams.Length : 0; public TypeParameterSpec[] TypeParameters { get { return tparams; } set { tparams = value; } } public ImportedTypeDefinition(Type type, MetadataImporter importer) : base(type, importer) { } public void DefineInterfaces(TypeSpec spec) { Type type = (Type)provider; Type[] interfaces = type.GetInterfaces(); if (interfaces.Length != 0) { Type[] array = interfaces; foreach (Type type2 in array) { spec.AddInterface(importer.CreateType(type2)); } } } public static void Error_MissingDependency(IMemberContext ctx, List missing, Location loc) { Report report = ctx.Module.Compiler.Report; for (int i = 0; i < missing.Count; i++) { TypeSpec type = missing[i].Type; if (report.Printer.MissingTypeReported(type.MemberDefinition)) { continue; } string signatureForError = type.GetSignatureForError(); MemberSpec caller = missing[i].Caller; if (caller.Kind != MemberKind.MissingType) { report.SymbolRelatedToPreviousError(caller); } ITypeDefinition memberDefinition = type.MemberDefinition; if (memberDefinition.DeclaringAssembly == ctx.Module.DeclaringAssembly) { report.Error(1683, loc, "Reference to type `{0}' claims it is defined in this assembly, but it is not defined in source or any added modules", signatureForError); } else if (memberDefinition.DeclaringAssembly.IsMissing) { if (memberDefinition.IsTypeForwarder) { report.Error(1070, loc, "The type `{0}' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `{1}'", signatureForError, memberDefinition.DeclaringAssembly.FullName); } else { report.Error(12, loc, "The type `{0}' is defined in an assembly that is not referenced. Consider adding a reference to assembly `{1}'", signatureForError, memberDefinition.DeclaringAssembly.FullName); } } else if (memberDefinition.IsTypeForwarder) { report.Error(731, loc, "The type forwarder for type `{0}' in assembly `{1}' has circular dependency", signatureForError, memberDefinition.DeclaringAssembly.FullName); } else { report.Error(7069, loc, "Reference to type `{0}' claims it is defined assembly `{1}', but it could not be found", signatureForError, type.MemberDefinition.DeclaringAssembly.FullName); } } } public TypeSpec GetAsyncMethodBuilder() { if (cattrs == null) { ReadAttributes(); } return cattrs.AsyncMethodBuilder; } public TypeSpec GetAttributeCoClass() { if (cattrs == null) { ReadAttributes(); } return cattrs.CoClass; } public string GetAttributeDefaultMember() { if (cattrs == null) { ReadAttributes(); } return cattrs.DefaultIndexerName; } public AttributeUsageAttribute GetAttributeUsage(PredefinedAttribute pa) { if (cattrs == null) { ReadAttributes(); } return cattrs.AttributeUsage; } bool ITypeDefinition.IsInternalAsPublic(IAssemblyDefinition assembly) { IAssemblyDefinition assemblyDefinition = importer.GetAssemblyDefinition(provider.Module.Assembly); return assemblyDefinition == assembly || assemblyDefinition.IsFriendAssemblyTo(assembly); } public void LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { if (declaringType.IsPrivate && importer.IgnorePrivateMembers) { cache = MemberCache.Empty; return; } Type type = (Type)provider; Dictionary dictionary = null; List list = null; MemberInfo[] members; try { members = type.GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } catch (Exception exception) { throw new InternalErrorException(exception, "Could not import type `{0}' from `{1}'", declaringType.GetSignatureForError(), declaringType.MemberDefinition.DeclaringAssembly.FullName); } if (cache == null) { cache = new MemberCache(members.Length); MemberInfo[] array = members; foreach (MemberInfo memberInfo in array) { if (memberInfo.MemberType != MemberTypes.NestedType) { continue; } Type type2 = (Type)memberInfo; if ((type2.Attributes & TypeAttributes.VisibilityMask) != TypeAttributes.NestedPrivate || !importer.IgnorePrivateMembers) { MemberSpec ms; try { ms = importer.CreateNestedType(type2, declaringType); } catch (Exception exception2) { throw new InternalErrorException(exception2, "Could not import nested type `{0}' from `{1}'", type2.FullName, declaringType.MemberDefinition.DeclaringAssembly.FullName); } cache.AddMemberImported(ms); } } MemberInfo[] array2 = members; foreach (MemberInfo memberInfo2 in array2) { if (memberInfo2.MemberType == MemberTypes.NestedType) { Type type3 = (Type)memberInfo2; if ((type3.Attributes & TypeAttributes.VisibilityMask) != TypeAttributes.NestedPrivate || !importer.IgnorePrivateMembers) { importer.ImportTypeBase(type3); } } } } if (declaringType.IsInterface && declaringType.Interfaces != null) { foreach (TypeSpec @interface in declaringType.Interfaces) { cache.AddInterface(@interface); } } if (onlyTypes) { return; } MemberInfo[] array3 = members; foreach (MemberInfo memberInfo3 in array3) { if (Blacklist.IsBlacklisted(declaringType, memberInfo3)) { continue; } MemberSpec ms; switch (memberInfo3.MemberType) { case MemberTypes.Constructor: if (declaringType.IsInterface) { continue; } goto case MemberTypes.Method; case MemberTypes.Method: { MethodBase methodBase = (MethodBase)memberInfo3; MethodAttributes attributes = methodBase.Attributes; if ((attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private && (importer.IgnorePrivateMembers || (attributes & (MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask)) == (MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask) || MetadataImporter.HasAttribute(CustomAttributeData.GetCustomAttributes(methodBase), "CompilerGeneratedAttribute", MetadataImporter.CompilerServicesNamespace))) { continue; } ms = importer.CreateMethod(methodBase, declaringType); if (ms.Kind == MemberKind.Method && !ms.IsGeneric) { if (dictionary == null) { dictionary = new Dictionary(ReferenceEquality.Default); } dictionary.Add(methodBase, (MethodSpec)ms); } break; } case MemberTypes.Property: { if (dictionary == null) { continue; } PropertyInfo propertyInfo = (PropertyInfo)memberInfo3; MethodInfo addMethod = propertyInfo.GetGetMethod(nonPublic: true); if ((object)addMethod == null || !dictionary.TryGetValue(addMethod, out var value3)) { value3 = null; } addMethod = propertyInfo.GetSetMethod(nonPublic: true); if ((object)addMethod == null || !dictionary.TryGetValue(addMethod, out var value4)) { value4 = null; } if (value3 == null && value4 == null) { continue; } try { ms = importer.CreateProperty(propertyInfo, declaringType, value3, value4); } catch (Exception exception3) { throw new InternalErrorException(exception3, "Could not import property `{0}' inside `{1}'", propertyInfo.Name, declaringType.GetSignatureForError()); } if (ms == null) { continue; } break; } case MemberTypes.Event: { if (dictionary == null) { continue; } EventInfo eventInfo = (EventInfo)memberInfo3; MethodInfo addMethod = eventInfo.GetAddMethod(nonPublic: true); if ((object)addMethod == null || !dictionary.TryGetValue(addMethod, out var value)) { value = null; } addMethod = eventInfo.GetRemoveMethod(nonPublic: true); if ((object)addMethod == null || !dictionary.TryGetValue(addMethod, out var value2)) { value2 = null; } if (value == null || value2 == null) { continue; } EventSpec eventSpec2 = importer.CreateEvent(eventInfo, declaringType, value, value2); if (!importer.IgnorePrivateMembers) { if (list == null) { list = new List(); } list.Add(eventSpec2); } ms = eventSpec2; break; } case MemberTypes.Field: { FieldInfo fieldInfo = (FieldInfo)memberInfo3; ms = importer.CreateField(fieldInfo, declaringType); if (ms == null) { continue; } if (list == null) { break; } int l; for (l = 0; l < list.Count; l++) { EventSpec eventSpec = list[l]; if (eventSpec.Name == fieldInfo.Name) { eventSpec.BackingField = (FieldSpec)ms; list.RemoveAt(l); l = -1; break; } } if (l < 0) { continue; } break; } default: throw new NotImplementedException(memberInfo3.ToString()); case MemberTypes.NestedType: continue; } if (!ms.IsStatic || !declaringType.IsInterface) { cache.AddMemberImported(ms); } } } } internal class ImportedTypeParameterDefinition : ImportedDefinition, ITypeDefinition, IMemberDefinition { public IAssemblyDefinition DeclaringAssembly { get { throw new NotImplementedException(); } } bool ITypeDefinition.IsComImport => false; bool ITypeDefinition.IsPartial => false; bool ITypeDefinition.IsTypeForwarder => false; bool ITypeDefinition.IsCyclicTypeForwarder => false; public string Namespace => null; public int TypeParametersCount => 0; public TypeParameterSpec[] TypeParameters => null; public ImportedTypeParameterDefinition(Type type, MetadataImporter importer) : base(type, importer) { } public TypeSpec GetAsyncMethodBuilder() { return null; } public TypeSpec GetAttributeCoClass() { return null; } public string GetAttributeDefaultMember() { throw new NotSupportedException(); } public AttributeUsageAttribute GetAttributeUsage(PredefinedAttribute pa) { throw new NotSupportedException(); } bool ITypeDefinition.IsInternalAsPublic(IAssemblyDefinition assembly) { throw new NotImplementedException(); } public void LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { throw new NotImplementedException(); } } internal abstract class YieldStatement : ResumableStatement where T : StateMachineInitializer { protected Expression expr; protected bool unwind_protect; protected T machine_initializer; private int resume_pc; private ExceptionStatement inside_try_block; private TryCatch inside_catch_block; public Expression Expr => expr; protected YieldStatement(Expression expr, Location l) { this.expr = expr; loc = l; } protected override void CloneTo(CloneContext clonectx, Statement t) { YieldStatement yieldStatement = (YieldStatement)t; yieldStatement.expr = expr.Clone(clonectx); } protected override void DoEmit(EmitContext ec) { machine_initializer.InjectYield(ec, expr, resume_pc, unwind_protect, resume_point); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); RegisterResumePoint(); return false; } public override bool Resolve(BlockContext bc) { expr = expr.Resolve(bc); if (expr == null) { return false; } machine_initializer = bc.CurrentAnonymousMethod as T; inside_try_block = bc.CurrentTryBlock; inside_catch_block = bc.CurrentTryCatch; return true; } public void RegisterResumePoint() { if (resume_pc == 0) { if (inside_try_block == null) { resume_pc = machine_initializer.AddResumePoint(this); return; } resume_pc = inside_try_block.AddResumePoint(this, resume_pc, machine_initializer, inside_catch_block); unwind_protect = true; inside_try_block = null; } } } internal class Yield : YieldStatement { public Yield(Expression expr, Location loc) : base(expr, loc) { } public static bool CheckContext(BlockContext bc, Location loc) { if (!bc.CurrentAnonymousMethod.IsIterator) { bc.Report.Error(1621, loc, "The yield statement cannot be used inside anonymous method blocks"); return false; } if (bc.HasSet(ResolveContext.Options.FinallyScope)) { bc.Report.Error(1625, loc, "Cannot yield in the body of a finally clause"); return false; } return true; } public override bool Resolve(BlockContext bc) { if (!CheckContext(bc, loc)) { return false; } if (bc.HasAny(ResolveContext.Options.TryWithCatchScope)) { bc.Report.Error(1626, loc, "Cannot yield a value in the body of a try block with a catch clause"); } if (bc.HasSet(ResolveContext.Options.CatchScope)) { bc.Report.Error(1631, loc, "Cannot yield a value in the body of a catch clause"); } if (!base.Resolve(bc)) { return false; } TypeSpec originalIteratorType = bc.CurrentIterator.OriginalIteratorType; if (expr.Type != originalIteratorType) { expr = Convert.ImplicitConversionRequired(bc, expr, originalIteratorType, loc); if (expr == null) { return false; } } return true; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class YieldBreak : ExitStatement { private Iterator iterator; protected override bool IsLocalExit => false; public YieldBreak(Location l) { loc = l; } protected override void CloneTo(CloneContext clonectx, Statement target) { } protected override bool DoResolve(BlockContext bc) { iterator = bc.CurrentIterator; return Yield.CheckContext(bc, loc); } protected override void DoEmit(EmitContext ec) { iterator.EmitYieldBreak(ec, unwind_protect); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return true; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Reachability.CreateUnreachable(); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class StateMachine : AnonymousMethodStorey { public enum State { Running = -3, Uninitialized, After, Start } private Field pc_field; private StateMachineMethod method; public TypeParameters OriginalTypeParameters { get; private set; } public StateMachineMethod StateMachineMethod => method; public Field PC => pc_field; protected StateMachine(ParametersBlock block, TypeDefinition parent, MemberBase host, TypeParameters tparams, string name, MemberKind kind) : base(block, parent, host, tparams, name, kind) { OriginalTypeParameters = tparams; } public void AddEntryMethod(StateMachineMethod method) { if (this.method != null) { throw new InternalErrorException(); } this.method = method; base.Members.Add(method); } protected override bool DoDefineMembers() { pc_field = AddCompilerGeneratedField("$PC", new TypeExpression(Compiler.BuiltinTypes.Int, base.Location)); return base.DoDefineMembers(); } protected override string GetVariableMangledName(ResolveContext rc, LocalVariable local_info) { if (local_info.IsCompilerGenerated) { return base.GetVariableMangledName(rc, local_info); } int debugSymbolScopeIndex = rc.CurrentBlock.Explicit.GetDebugSymbolScopeIndex(); return "<" + local_info.Name + ">__" + debugSymbolScopeIndex; } } internal class IteratorStorey : StateMachine { private class GetEnumeratorMethod : StateMachineMethod { private sealed class GetEnumeratorStatement : Statement { private readonly IteratorStorey host; private readonly StateMachineMethod host_method; private Expression new_storey; public GetEnumeratorStatement(IteratorStorey host, StateMachineMethod host_method) { this.host = host; this.host_method = host_method; loc = host_method.Location; } protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotSupportedException(); } public override bool Resolve(BlockContext ec) { TypeExpression requested_type = new TypeExpression(host.Definition, loc); List list = null; if (host.hoisted_this != null) { list = new List((host.hoisted_params == null) ? 1 : (host.HoistedParameters.Count + 1)); HoistedThis hoisted_this = host.hoisted_this; FieldExpr fieldExpr = new FieldExpr(hoisted_this.Field, loc); fieldExpr.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc); list.Add(new ElementInitializer(hoisted_this.Field.Name, fieldExpr, loc)); } if (host.hoisted_params != null) { if (list == null) { list = new List(host.HoistedParameters.Count); } for (int i = 0; i < host.hoisted_params.Count; i++) { HoistedParameter hoistedParameter = host.hoisted_params[i]; HoistedParameter hoistedParameter2 = host.hoisted_params_copy[i] ?? hoistedParameter; FieldExpr fieldExpr2 = new FieldExpr(hoistedParameter2.Field, loc); fieldExpr2.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc); list.Add(new ElementInitializer(hoistedParameter.Field.Name, fieldExpr2, loc)); } } if (list != null) { new_storey = new NewInitialize(requested_type, null, new CollectionOrObjectInitializers(list, loc), loc); } else { new_storey = new New(requested_type, null, loc); } new_storey = new_storey.Resolve(ec); if (new_storey != null) { new_storey = Convert.ImplicitConversionRequired(ec, new_storey, host_method.MemberType, loc); } return true; } protected override void DoEmit(EmitContext ec) { Label label = ec.DefineLabel(); ec.EmitThis(); ec.Emit(OpCodes.Ldflda, host.PC.Spec); ec.EmitInt(0); ec.EmitInt(-2); MethodSpec methodSpec = ec.Module.PredefinedMembers.InterlockedCompareExchange.Resolve(loc); if (methodSpec != null) { ec.Emit(OpCodes.Call, methodSpec); } ec.EmitInt(-2); ec.Emit(OpCodes.Bne_Un_S, label); ec.EmitThis(); ec.Emit(OpCodes.Ret); ec.MarkLabel(label); new_storey.Emit(ec); ec.Emit(OpCodes.Ret); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { throw new NotImplementedException(); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Reachability.CreateUnreachable(); } } private GetEnumeratorMethod(IteratorStorey host, FullNamedExpression returnType, MemberName name) : base(host, null, returnType, Modifiers.DEBUGGER_HIDDEN, name, Mono.CSharp.Block.Flags.CompilerGenerated | Mono.CSharp.Block.Flags.NoFlowAnalysis) { } public static GetEnumeratorMethod Create(IteratorStorey host, FullNamedExpression returnType, MemberName name) { return Create(host, returnType, name, null); } public static GetEnumeratorMethod Create(IteratorStorey host, FullNamedExpression returnType, MemberName name, Statement statement) { GetEnumeratorMethod getEnumeratorMethod = new GetEnumeratorMethod(host, returnType, name); Statement s = statement ?? new GetEnumeratorStatement(host, getEnumeratorMethod); getEnumeratorMethod.block.AddStatement(s); return getEnumeratorMethod; } } private class DisposeMethod : StateMachineMethod { private sealed class DisposeMethodStatement : Statement { private Iterator iterator; public DisposeMethodStatement(Iterator iterator) { this.iterator = iterator; loc = iterator.Location; } protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotSupportedException(); } public override bool Resolve(BlockContext ec) { return true; } protected override void DoEmit(EmitContext ec) { ec.CurrentAnonymousMethod = iterator; iterator.EmitDispose(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { throw new NotImplementedException(); } } public DisposeMethod(IteratorStorey host) : base(host, null, new TypeExpression(host.Compiler.BuiltinTypes.Void, host.Location), Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN, new MemberName("Dispose", host.Location), Mono.CSharp.Block.Flags.CompilerGenerated | Mono.CSharp.Block.Flags.NoFlowAnalysis) { host.Members.Add(this); base.Block.AddStatement(new DisposeMethodStatement(host.Iterator)); } } private class DynamicMethodGroupExpr : MethodGroupExpr { private readonly Method method; public DynamicMethodGroupExpr(Method method, Location loc) : base((IList)null, (TypeSpec)null, loc) { this.method = method; eclass = ExprClass.Unresolved; } protected override Expression DoResolve(ResolveContext ec) { Methods = new List(1) { method.Spec }; type = method.Parent.Definition; InstanceExpression = new CompilerGeneratedThis(type, base.Location); return base.DoResolve(ec); } } private class DynamicFieldExpr : FieldExpr { private readonly Field field; public DynamicFieldExpr(Field field, Location loc) : base(loc) { this.field = field; } protected override Expression DoResolve(ResolveContext ec) { spec = field.Spec; type = spec.MemberType; InstanceExpression = new CompilerGeneratedThis(type, base.Location); return base.DoResolve(ec); } } public readonly Iterator Iterator; private List hoisted_params_copy; private TypeExpr iterator_type_expr; private Field current_field; private Field disposing_field; private TypeSpec generic_enumerator_type; private TypeSpec generic_enumerable_type; public Field CurrentField => current_field; public Field DisposingField => disposing_field; public IList HoistedParameters => hoisted_params; public IteratorStorey(Iterator iterator) : base(iterator.Container.ParametersBlock, iterator.Host, iterator.OriginalMethod as MemberBase, iterator.OriginalMethod.CurrentTypeParameters, "Iterator", MemberKind.Class) { Iterator = iterator; } protected override Constructor DefineDefaultConstructor(bool is_static) { Constructor constructor = base.DefineDefaultConstructor(is_static); constructor.ModFlags |= Modifiers.DEBUGGER_HIDDEN; return constructor; } protected override TypeSpec[] ResolveBaseTypes(out FullNamedExpression base_class) { TypeSpec typeSpec = Iterator.OriginalIteratorType; if (base.Mutator != null) { typeSpec = base.Mutator.Mutate(typeSpec); } iterator_type_expr = new TypeExpression(typeSpec, base.Location); List list = new List(5); if (Iterator.IsEnumerable) { list.Add(Compiler.BuiltinTypes.IEnumerable); if (Module.PredefinedTypes.IEnumerableGeneric.Define()) { generic_enumerable_type = Module.PredefinedTypes.IEnumerableGeneric.TypeSpec.MakeGenericType(Module, new TypeSpec[1] { typeSpec }); list.Add(generic_enumerable_type); } } list.Add(Compiler.BuiltinTypes.IEnumerator); list.Add(Compiler.BuiltinTypes.IDisposable); PredefinedType iEnumeratorGeneric = Module.PredefinedTypes.IEnumeratorGeneric; if (iEnumeratorGeneric.Define()) { generic_enumerator_type = iEnumeratorGeneric.TypeSpec.MakeGenericType(Module, new TypeSpec[1] { typeSpec }); list.Add(generic_enumerator_type); } base_class = null; base_type = Compiler.BuiltinTypes.Object; return list.ToArray(); } protected override bool DoDefineMembers() { current_field = AddCompilerGeneratedField("$current", iterator_type_expr); disposing_field = AddCompilerGeneratedField("$disposing", new TypeExpression(Compiler.BuiltinTypes.Bool, base.Location)); if (Iterator.IsEnumerable && hoisted_params != null) { hoisted_params_copy = new List(hoisted_params.Count); foreach (HoistedParameter hoisted_param in hoisted_params) { HoistedParameter item = ((!hoisted_param.IsAssigned) ? null : new HoistedParameter(hoisted_param, "<$>" + hoisted_param.Field.Name)); hoisted_params_copy.Add(item); } } if (generic_enumerator_type != null) { Define_Current(is_generic: true); } Define_Current(is_generic: false); new DisposeMethod(this); Define_Reset(); if (Iterator.IsEnumerable) { FullNamedExpression explicitInterface = new TypeExpression(Compiler.BuiltinTypes.IEnumerable, base.Location); MemberName name = new MemberName("GetEnumerator", null, explicitInterface, Location.Null); if (generic_enumerator_type != null) { explicitInterface = new TypeExpression(generic_enumerable_type, base.Location); MemberName name2 = new MemberName("GetEnumerator", null, explicitInterface, Location.Null); Method item2 = GetEnumeratorMethod.Create(this, new TypeExpression(generic_enumerator_type, base.Location), name2); Return statement = new Return(new Invocation(new DynamicMethodGroupExpr(item2, base.Location), null), base.Location); Method item3 = GetEnumeratorMethod.Create(this, new TypeExpression(Compiler.BuiltinTypes.IEnumerator, base.Location), name, statement); base.Members.Add(item3); base.Members.Add(item2); } else { base.Members.Add(GetEnumeratorMethod.Create(this, new TypeExpression(Compiler.BuiltinTypes.IEnumerator, base.Location), name)); } } return base.DoDefineMembers(); } private void Define_Current(bool is_generic) { FullNamedExpression explicitInterface; TypeExpr type; if (is_generic) { explicitInterface = new TypeExpression(generic_enumerator_type, base.Location); type = iterator_type_expr; } else { explicitInterface = new TypeExpression(Module.Compiler.BuiltinTypes.IEnumerator, base.Location); type = new TypeExpression(Compiler.BuiltinTypes.Object, base.Location); } MemberName name = new MemberName("Current", null, explicitInterface, base.Location); ToplevelBlock toplevelBlock = new ToplevelBlock(Compiler, ParametersCompiled.EmptyReadOnlyParameters, base.Location, Block.Flags.CompilerGenerated | Block.Flags.NoFlowAnalysis); toplevelBlock.AddStatement(new Return(new DynamicFieldExpr(CurrentField, base.Location), base.Location)); Property property = new Property(this, type, Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN, name, null); property.Get = new PropertyBase.GetMethod(property, Modifiers.COMPILER_GENERATED, null, base.Location); property.Get.Block = toplevelBlock; base.Members.Add(property); } private void Define_Reset() { Method method = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Void, base.Location), Modifiers.PUBLIC | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN, new MemberName("Reset", base.Location), ParametersCompiled.EmptyReadOnlyParameters, null); base.Members.Add(method); method.Block = new ToplevelBlock(Compiler, method.ParameterInfo, base.Location, Block.Flags.CompilerGenerated | Block.Flags.NoFlowAnalysis); TypeSpec typeSpec = Module.PredefinedTypes.NotSupportedException.Resolve(); if (typeSpec != null) { method.Block.AddStatement(new Throw(new New(new TypeExpression(typeSpec, base.Location), null, base.Location), base.Location)); } } protected override void EmitHoistedParameters(EmitContext ec, List hoisted) { base.EmitHoistedParameters(ec, hoisted); if (hoisted_params_copy != null) { base.EmitHoistedParameters(ec, hoisted_params_copy); } } } internal class StateMachineMethod : Method { private readonly StateMachineInitializer expr; public StateMachineMethod(StateMachine host, StateMachineInitializer expr, FullNamedExpression returnType, Modifiers mod, MemberName name, Block.Flags blockFlags) : base(host, returnType, mod | Modifiers.COMPILER_GENERATED, name, ParametersCompiled.EmptyReadOnlyParameters, null) { this.expr = expr; base.Block = new ToplevelBlock(host.Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null, blockFlags); } public override EmitContext CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod) { EmitContext emitContext = new EmitContext(this, ig, base.MemberType, sourceMethod); emitContext.CurrentAnonymousMethod = expr; if (expr is AsyncInitializer) { emitContext.With(BuilderContext.Options.AsyncBody, enable: true); } return emitContext; } } internal abstract class StateMachineInitializer : AnonymousExpression { private sealed class MoveNextBodyStatement : Statement { private readonly StateMachineInitializer state_machine; public MoveNextBodyStatement(StateMachineInitializer stateMachine) { state_machine = stateMachine; loc = stateMachine.Location; } protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotSupportedException(); } public override bool Resolve(BlockContext ec) { return true; } protected override void DoEmit(EmitContext ec) { state_machine.EmitMoveNext(ec); } public override void Emit(EmitContext ec) { DoEmit(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return state_machine.ReturnType.Kind != MemberKind.Void; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (state_machine.ReturnType.Kind != MemberKind.Void) { rc = Reachability.CreateUnreachable(); } return rc; } } public readonly TypeDefinition Host; protected StateMachine storey; protected Label move_next_ok; protected Label move_next_error; private LocalBuilder skip_finally; protected LocalBuilder current_pc; protected List resume_points; public Label BodyEnd { get; set; } public LocalBuilder CurrentPC => current_pc; public LocalBuilder SkipFinally => skip_finally; public override AnonymousMethodStorey Storey => storey; protected StateMachineInitializer(ParametersBlock block, TypeDefinition host, TypeSpec returnType) : base(block, returnType, block.StartLocation) { Host = host; } public int AddResumePoint(ResumableStatement stmt) { if (resume_points == null) { resume_points = new List(); } resume_points.Add(stmt); return resume_points.Count; } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected virtual BlockContext CreateBlockContext(BlockContext bc) { BlockContext blockContext = new BlockContext(bc, block, bc.ReturnType); blockContext.CurrentAnonymousMethod = this; blockContext.AssignmentInfoOffset = bc.AssignmentInfoOffset; blockContext.EnclosingLoop = bc.EnclosingLoop; blockContext.EnclosingLoopOrSwitch = bc.EnclosingLoopOrSwitch; blockContext.Switch = bc.Switch; return blockContext; } protected override Expression DoResolve(ResolveContext rc) { BlockContext blockContext = (BlockContext)rc; BlockContext blockContext2 = CreateBlockContext(blockContext); base.Block.Resolve(blockContext2); if (!rc.IsInProbingMode) { StateMachineMethod stateMachineMethod = new StateMachineMethod(storey, this, new TypeExpression(ReturnType, loc), Modifiers.PUBLIC, new MemberName("MoveNext", loc), (Block.Flags)0); stateMachineMethod.Block.AddStatement(new MoveNextBodyStatement(this)); storey.AddEntryMethod(stateMachineMethod); } blockContext.AssignmentInfoOffset = blockContext2.AssignmentInfoOffset; eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { storey.Instance.Emit(ec); } private void EmitMoveNext_NoResumePoints(EmitContext ec) { ec.EmitThis(); ec.Emit(OpCodes.Ldfld, storey.PC.Spec); ec.EmitThis(); ec.EmitInt(-1); ec.Emit(OpCodes.Stfld, storey.PC.Spec); ec.Emit(OpCodes.Brtrue, move_next_error); BodyEnd = ec.DefineLabel(); AsyncInitializer asyncInitializer = this as AsyncInitializer; if (asyncInitializer != null) { ec.BeginExceptionBlock(); } block.EmitEmbedded(ec); asyncInitializer?.EmitCatchBlock(ec); ec.MarkLabel(BodyEnd); EmitMoveNextEpilogue(ec); ec.MarkLabel(move_next_error); if (ReturnType.Kind != MemberKind.Void) { ec.EmitInt(0); ec.Emit(OpCodes.Ret); } ec.MarkLabel(move_next_ok); } private void EmitMoveNext(EmitContext ec) { move_next_ok = ec.DefineLabel(); move_next_error = ec.DefineLabel(); if (resume_points == null) { EmitMoveNext_NoResumePoints(ec); return; } current_pc = ec.GetTemporaryLocal(ec.BuiltinTypes.UInt); ec.EmitThis(); ec.Emit(OpCodes.Ldfld, storey.PC.Spec); ec.Emit(OpCodes.Stloc, current_pc); ec.EmitThis(); ec.EmitInt(-1); ec.Emit(OpCodes.Stfld, storey.PC.Spec); Label[] array = new Label[1 + resume_points.Count]; array[0] = ec.DefineLabel(); bool flag = false; for (int i = 0; i < resume_points.Count; i++) { ResumableStatement resumableStatement = resume_points[i]; flag = flag || resumableStatement is ExceptionStatement; array[i + 1] = resumableStatement.PrepareForEmit(ec); } if (flag) { skip_finally = ec.GetTemporaryLocal(ec.BuiltinTypes.Bool); ec.EmitInt(0); ec.Emit(OpCodes.Stloc, skip_finally); } AsyncInitializer asyncInitializer = this as AsyncInitializer; if (asyncInitializer != null) { ec.BeginExceptionBlock(); } ec.Emit(OpCodes.Ldloc, current_pc); ec.Emit(OpCodes.Switch, array); ec.Emit((asyncInitializer != null) ? OpCodes.Leave : OpCodes.Br, move_next_error); ec.MarkLabel(array[0]); BodyEnd = ec.DefineLabel(); block.EmitEmbedded(ec); ec.MarkLabel(BodyEnd); asyncInitializer?.EmitCatchBlock(ec); ec.Mark(base.Block.Original.EndLocation); ec.EmitThis(); ec.EmitInt(-1); ec.Emit(OpCodes.Stfld, storey.PC.Spec); EmitMoveNextEpilogue(ec); ec.MarkLabel(move_next_error); if (ReturnType.Kind != MemberKind.Void) { ec.EmitInt(0); ec.Emit(OpCodes.Ret); } ec.MarkLabel(move_next_ok); if (ReturnType.Kind != MemberKind.Void) { ec.EmitInt(1); ec.Emit(OpCodes.Ret); } } protected virtual void EmitMoveNextEpilogue(EmitContext ec) { } public void EmitLeave(EmitContext ec, bool unwind_protect) { ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_ok); } public virtual void InjectYield(EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point) { Label label = ec.DefineLabel(); IteratorStorey iteratorStorey = storey as IteratorStorey; if (iteratorStorey != null) { ec.EmitThis(); ec.Emit(OpCodes.Ldfld, iteratorStorey.DisposingField.Spec); ec.Emit(OpCodes.Brtrue_S, label); } ec.EmitThis(); ec.EmitInt(resume_pc); ec.Emit(OpCodes.Stfld, storey.PC.Spec); if (iteratorStorey != null) { ec.MarkLabel(label); } if (unwind_protect && skip_finally != null) { ec.EmitInt(1); ec.Emit(OpCodes.Stloc, skip_finally); } } public void SetStateMachine(StateMachine stateMachine) { storey = stateMachine; } } internal class Iterator : StateMachineInitializer { private sealed class TryFinallyBlockProxyStatement : Statement { private TryFinallyBlock block; private Iterator iterator; public TryFinallyBlockProxyStatement(Iterator iterator, TryFinallyBlock block) { this.iterator = iterator; this.block = block; } protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotSupportedException(); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { throw new NotSupportedException(); } protected override void DoEmit(EmitContext ec) { ec.CurrentAnonymousMethod = iterator; using (ec.With(BuilderContext.Options.OmitDebugInfo, !ec.HasMethodSymbolBuilder)) { block.EmitFinallyBody(ec); } } } public readonly IMethodData OriginalMethod; public readonly bool IsEnumerable; public readonly TypeSpec OriginalIteratorType; private int finally_hosts_counter; public ToplevelBlock Container => OriginalMethod.Block; public override string ContainerType => "iterator"; public override bool IsIterator => true; public Iterator(ParametersBlock block, IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable) : base(block, host, host.Compiler.BuiltinTypes.Bool) { OriginalMethod = method; OriginalIteratorType = iterator_type; IsEnumerable = is_enumerable; type = method.ReturnType; } public Method CreateFinallyHost(TryFinallyBlock block) { Method method = new Method(storey, new TypeExpression(storey.Compiler.BuiltinTypes.Void, loc), Modifiers.COMPILER_GENERATED, new MemberName(CompilerGeneratedContainer.MakeName(null, null, "Finally", finally_hosts_counter++), loc), ParametersCompiled.EmptyReadOnlyParameters, null); method.Block = new ToplevelBlock(method.Compiler, method.ParameterInfo, loc, Mono.CSharp.Block.Flags.CompilerGenerated | Mono.CSharp.Block.Flags.NoFlowAnalysis); method.Block.AddStatement(new TryFinallyBlockProxyStatement(this, block)); return method; } public void EmitYieldBreak(EmitContext ec, bool unwind_protect) { ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_error); } public override string GetSignatureForError() { return OriginalMethod.GetSignatureForError(); } public override void Emit(EmitContext ec) { storey.Instance.Emit(ec); if (IsEnumerable) { ec.Emit(OpCodes.Dup); ec.EmitInt(-2); FieldSpec fieldSpec = storey.PC.Spec; if (storey.MemberName.IsGeneric) { fieldSpec = MemberCache.GetMember(Storey.Instance.Type, fieldSpec); } ec.Emit(OpCodes.Stfld, fieldSpec); } } public void EmitDispose(EmitContext ec) { if (resume_points == null) { return; } Label label = ec.DefineLabel(); Label[] array = null; for (int i = 0; i < resume_points.Count; i++) { ResumableStatement resumableStatement = resume_points[i]; Label label2 = resumableStatement.PrepareForDispose(ec, label); if (label2.Equals(label) && array == null) { continue; } if (array == null) { array = new Label[resume_points.Count + 1]; for (int j = 0; j <= i; j++) { array[j] = label; } } array[i + 1] = label2; } if (array != null) { current_pc = ec.GetTemporaryLocal(ec.BuiltinTypes.UInt); ec.EmitThis(); ec.Emit(OpCodes.Ldfld, storey.PC.Spec); ec.Emit(OpCodes.Stloc, current_pc); } ec.EmitThis(); ec.EmitInt(1); ec.Emit(OpCodes.Stfld, ((IteratorStorey)storey).DisposingField.Spec); ec.EmitThis(); ec.EmitInt(-1); ec.Emit(OpCodes.Stfld, storey.PC.Spec); if (array != null) { ec.Emit(OpCodes.Ldloc, current_pc); ec.Emit(OpCodes.Switch, array); foreach (ResumableStatement resume_point in resume_points) { resume_point.EmitForDispose(ec, current_pc, label, have_dispatcher: true); } } ec.MarkLabel(label); } public override void EmitStatement(EmitContext ec) { throw new NotImplementedException(); } public override void InjectYield(EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point) { FieldExpr fieldExpr = new FieldExpr(((IteratorStorey)storey).CurrentField, loc); fieldExpr.InstanceExpression = new CompilerGeneratedThis(storey.CurrentType, loc); fieldExpr.EmitAssign(ec, expr, leave_copy: false, isCompound: false); base.InjectYield(ec, expr, resume_pc, unwind_protect, resume_point); EmitLeave(ec, unwind_protect); ec.MarkLabel(resume_point); } public static void CreateIterator(IMethodData method, TypeDefinition parent, Modifiers modifiers) { TypeSpec returnType = method.ReturnType; if (returnType == null) { return; } if (!CheckType(returnType, parent, out var original_iterator_type, out var is_enumerable)) { if (returnType.Kind == MemberKind.ByRef) { parent.Compiler.Report.Error(8154, method.Location, "The body of `{0}' cannot be an iterator block because the method returns by reference", method.GetSignatureForError()); } else { parent.Compiler.Report.Error(1624, method.Location, "The body of `{0}' cannot be an iterator block because `{1}' is not an iterator interface type", method.GetSignatureForError(), returnType.GetSignatureForError()); } return; } ParametersCompiled parameterInfo = method.ParameterInfo; for (int i = 0; i < parameterInfo.Count; i++) { Parameter parameter = parameterInfo[i]; Parameter.Modifier modFlags = parameter.ModFlags; if ((modFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { parent.Compiler.Report.Error(1623, parameter.Location, "Iterators cannot have ref or out parameters"); return; } if (parameter is ArglistParameter) { parent.Compiler.Report.Error(1636, method.Location, "__arglist is not allowed in parameter list of iterators"); return; } if (parameterInfo.Types[i].IsPointer) { parent.Compiler.Report.Error(1637, parameter.Location, "Iterators cannot have unsafe parameters or yield types"); return; } } if ((modifiers & Modifiers.UNSAFE) != 0) { Expression.UnsafeInsideIteratorError(parent.Compiler.Report, method.Location); } method.Block = method.Block.ConvertToIterator(method, parent, original_iterator_type, is_enumerable); } private static bool CheckType(TypeSpec ret, TypeContainer parent, out TypeSpec original_iterator_type, out bool is_enumerable) { original_iterator_type = null; is_enumerable = false; if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerable) { original_iterator_type = parent.Compiler.BuiltinTypes.Object; is_enumerable = true; return true; } if (ret.BuiltinType == BuiltinTypeSpec.Type.IEnumerator) { original_iterator_type = parent.Compiler.BuiltinTypes.Object; is_enumerable = false; return true; } if (!(ret is InflatedTypeSpec { MemberDefinition: var memberDefinition } inflatedTypeSpec)) { return false; } PredefinedType iEnumerableGeneric = parent.Module.PredefinedTypes.IEnumerableGeneric; if (iEnumerableGeneric.Define() && iEnumerableGeneric.TypeSpec.MemberDefinition == memberDefinition) { original_iterator_type = inflatedTypeSpec.TypeArguments[0]; is_enumerable = true; return true; } iEnumerableGeneric = parent.Module.PredefinedTypes.IEnumeratorGeneric; if (iEnumerableGeneric.Define() && iEnumerableGeneric.TypeSpec.MemberDefinition == memberDefinition) { original_iterator_type = inflatedTypeSpec.TypeArguments[0]; is_enumerable = false; return true; } return false; } } internal class LambdaExpression : AnonymousMethodExpression { public override bool HasExplicitParameters => base.Parameters.Count > 0 && !(base.Parameters.FixedParameters[0] is ImplicitLambdaParameter); public LambdaExpression(Location loc) : base(loc) { } protected override Expression CreateExpressionTree(ResolveContext ec, TypeSpec delegate_type) { if (ec.IsInProbingMode) { return this; } BlockContext ec2 = new BlockContext(ec.MemberContext, ec.ConstructorBlock, ec.BuiltinTypes.Void) { CurrentAnonymousMethod = ec.CurrentAnonymousMethod }; Expression expr = base.Parameters.CreateExpressionTree(ec2, loc); Expression expression = Block.CreateExpressionTree(ec); if (expression == null) { return null; } Arguments arguments = new Arguments(2); arguments.Add(new Argument(expression)); arguments.Add(new Argument(expr)); return CreateExpressionFactoryCall(ec, "Lambda", new TypeArguments(new TypeExpression(delegate_type, loc)), arguments); } protected override ParametersCompiled ResolveParameters(ResolveContext ec, TypeInferenceContext tic, TypeSpec delegateType) { if (!delegateType.IsDelegate) { return null; } AParametersCollection parameters = Delegate.GetParameters(delegateType); if (HasExplicitParameters) { if (!VerifyExplicitParameters(ec, tic, delegateType, parameters)) { return null; } return base.Parameters; } if (!VerifyParameterCompatibility(ec, tic, delegateType, parameters, ec.IsInProbingMode)) { return null; } TypeSpec[] array = new TypeSpec[base.Parameters.Count]; for (int i = 0; i < parameters.Count; i++) { if ((parameters.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { return null; } TypeSpec typeSpec = parameters.Types[i]; if (tic != null) { typeSpec = tic.InflateGenericArgument(ec, typeSpec); } array[i] = typeSpec; ImplicitLambdaParameter implicitLambdaParameter = (ImplicitLambdaParameter)base.Parameters.FixedParameters[i]; implicitLambdaParameter.SetParameterType(typeSpec); implicitLambdaParameter.Resolve(null, i); } base.Parameters.Types = array; return base.Parameters; } protected override AnonymousMethodBody CompatibleMethodFactory(TypeSpec returnType, TypeSpec delegateType, ParametersCompiled p, ParametersBlock b) { return new LambdaMethod(p, b, returnType, delegateType, loc); } protected override bool DoResolveParameters(ResolveContext rc) { if (HasExplicitParameters) { return base.Parameters.Resolve(rc); } return true; } public override string GetSignatureForError() { return "lambda expression"; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class LambdaMethod : AnonymousMethodBody { public override string ContainerType => "lambda expression"; public LambdaMethod(ParametersCompiled parameters, ParametersBlock block, TypeSpec return_type, TypeSpec delegate_type, Location loc) : base(parameters, block, return_type, delegate_type, loc) { } protected override void CloneTo(CloneContext clonectx, Expression target) { } public override Expression CreateExpressionTree(ResolveContext ec) { BlockContext ec2 = new BlockContext(ec.MemberContext, base.Block, ReturnType); Expression expr = parameters.CreateExpressionTree(ec2, loc); Expression expression = base.Block.CreateExpressionTree(ec); if (expression == null) { return null; } Arguments arguments = new Arguments(2); arguments.Add(new Argument(expression)); arguments.Add(new Argument(expr)); return CreateExpressionFactoryCall(ec, "Lambda", new TypeArguments(new TypeExpression(type, loc)), arguments); } } internal class ContextualReturn : Return { private ExpressionStatement statement; public ContextualReturn(Expression expr) : base(expr, expr.StartLocation) { } public override Expression CreateExpressionTree(ResolveContext ec) { if (base.Expr is ReferenceExpression) { ec.Report.Error(8155, base.Expr.Location, "Lambda expressions that return by reference cannot be converted to expression trees"); return null; } return base.Expr.CreateExpressionTree(ec); } protected override void DoEmit(EmitContext ec) { if (statement != null) { statement.EmitStatement(ec); if (unwind_protect) { ec.Emit(OpCodes.Leave, ec.CreateReturnLabel()); } else { ec.Emit(OpCodes.Ret); } } else { base.DoEmit(ec); } } protected override bool DoResolve(BlockContext ec) { if (ec.ReturnType.Kind == MemberKind.Void) { base.Expr = base.Expr.Resolve(ec); if (base.Expr == null) { return false; } if (base.Expr is ReferenceExpression) { ec.Report.Error(8149, loc, "By-reference returns can only be used in lambda expressions that return by reference"); return false; } statement = base.Expr as ExpressionStatement; if (statement == null) { if (base.Expr is IReducedExpressionStatement) { statement = EmptyExpressionStatement.Instance; } else { base.Expr.Error_InvalidExpressionStatement(ec); } } return true; } return base.DoResolve(ec); } } internal interface ILiteralConstant { } internal class NullLiteral : NullConstant { public override bool IsLiteral => true; public NullLiteral(Location loc) : base(InternalType.NullLiteral, loc) { } public override void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec t, bool expl) { if (t.IsGenericParameter) { ec.Report.Error(403, loc, "Cannot convert null to the type parameter `{0}' because it could be a value type. Consider using `default ({0})' instead", t.Name); } else if (TypeSpec.IsValueType(t)) { ec.Report.Error(37, loc, "Cannot convert null to `{0}' because it is a value type", t.GetSignatureForError()); } else { base.Error_ValueCannotBeConverted(ec, t, expl); } } public override string GetValueAsLiteral() { return "null"; } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return System.Linq.Expressions.Expression.Constant(null); } } internal class BoolLiteral : BoolConstant, ILiteralConstant { public override bool IsLiteral => true; public BoolLiteral(BuiltinTypes types, bool val, Location loc) : base(types, val, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class CharLiteral : CharConstant, ILiteralConstant { public override bool IsLiteral => true; public CharLiteral(BuiltinTypes types, char c, Location loc) : base(types, c, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class IntLiteral : IntConstant, ILiteralConstant { public override bool IsLiteral => true; public IntLiteral(BuiltinTypes types, int l, Location loc) : base(types, l, loc) { } public override Constant ConvertImplicitly(TypeSpec type) { if (Value == 0 && type.IsEnum) { Constant constant = ConvertImplicitly(EnumSpec.GetUnderlyingType(type)); if (constant == null) { return null; } return new EnumConstant(constant, type); } return base.ConvertImplicitly(type); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class UIntLiteral : UIntConstant, ILiteralConstant { public override bool IsLiteral => true; public UIntLiteral(BuiltinTypes types, uint l, Location loc) : base(types, l, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class LongLiteral : LongConstant, ILiteralConstant { public override bool IsLiteral => true; public LongLiteral(BuiltinTypes types, long l, Location loc) : base(types, l, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ULongLiteral : ULongConstant, ILiteralConstant { public override bool IsLiteral => true; public ULongLiteral(BuiltinTypes types, ulong l, Location loc) : base(types, l, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class FloatLiteral : FloatConstant, ILiteralConstant { public override bool IsLiteral => true; public FloatLiteral(BuiltinTypes types, float f, Location loc) : base(types, f, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class DoubleLiteral : DoubleConstant, ILiteralConstant { public override bool IsLiteral => true; public DoubleLiteral(BuiltinTypes types, double d, Location loc) : base(types, d, loc) { } public override void Error_ValueCannotBeConverted(ResolveContext ec, TypeSpec target, bool expl) { if (target.BuiltinType == BuiltinTypeSpec.Type.Float) { Error_664(ec, loc, "float", "f"); } else if (target.BuiltinType == BuiltinTypeSpec.Type.Decimal) { Error_664(ec, loc, "decimal", "m"); } else { base.Error_ValueCannotBeConverted(ec, target, expl); } } private static void Error_664(ResolveContext ec, Location loc, string type, string suffix) { ec.Report.Error(664, loc, "Literal of type double cannot be implicitly converted to type `{0}'. Add suffix `{1}' to create a literal of this type", type, suffix); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class DecimalLiteral : DecimalConstant, ILiteralConstant { public override bool IsLiteral => true; public DecimalLiteral(BuiltinTypes types, decimal d, Location loc) : base(types, d, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class StringLiteral : StringConstant, ILiteralConstant { public override bool IsLiteral => true; public StringLiteral(BuiltinTypes types, string s, Location loc) : base(types, s, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class SourceFile : IEquatable { private struct LocationRegion : IComparable { public readonly Location Start; public readonly Location End; public LocationRegion(Location start, Location end) { Start = start; End = end; } public int CompareTo(LocationRegion other) { if (Start.Row == other.Start.Row) { return Start.Column.CompareTo(other.Start.Column); } return Start.Row.CompareTo(other.Start.Row); } public override string ToString() { return Start.ToString() + " - " + End.ToString(); } } private static readonly byte[] MD5Algorith = new byte[16] { 96, 166, 110, 64, 207, 100, 130, 76, 182, 240, 66, 212, 129, 114, 167, 153 }; public readonly string Name; public readonly string OriginalFullPathName; public readonly int Index; public bool AutoGenerated; public Func GetInputStream; private SourceFileEntry file; private byte[] algGuid; private byte[] checksum; private List hidden_lines; public string FullPathName => OriginalFullPathName; public byte[] Checksum => checksum; public bool HasChecksum => checksum != null; public SourceFileEntry SourceFileEntry => file; public SourceFile(string name, string path, int index) { Index = index; Name = name; OriginalFullPathName = path; } public SourceFile(string name, string path, int index, Func inputStreamDelegate) : this(name, path, index) { GetInputStream = inputStreamDelegate; } public void SetChecksum(byte[] checksum) { SetChecksum(MD5Algorith, checksum); } public void SetChecksum(byte[] algorithmGuid, byte[] checksum) { algGuid = algorithmGuid; this.checksum = checksum; } public SourceFileEntry CreateSymbolInfo(MonoSymbolFile symwriter, List> pathMap) { if (hidden_lines != null) { hidden_lines.Sort(); } file = new SourceFileEntry(symwriter, GetFullPathName(pathMap), OriginalFullPathName, algGuid, checksum); if (AutoGenerated) { file.SetAutoGenerated(); } return file; } public string GetFullPathName(List> pathMap) { string text = OriginalFullPathName; if (pathMap != null) { foreach (KeyValuePair item in pathMap) { string key = item.Key; if (text.Length > key.Length && text[key.Length] == Path.DirectorySeparatorChar && text.StartsWith(key, StringComparison.Ordinal)) { text = item.Value + text.Substring(key.Length); } } } return text; } public bool Equals(SourceFile other) { return OriginalFullPathName == other.OriginalFullPathName; } public bool IsHiddenLocation(Location loc) { if (hidden_lines == null) { return false; } int num = hidden_lines.BinarySearch(new LocationRegion(loc, loc)); num = ~num; if (num > 0) { LocationRegion locationRegion = hidden_lines[num - 1]; if (loc.Row < locationRegion.End.Row) { return true; } } return false; } public void RegisterHiddenScope(Location start, Location end) { if (hidden_lines == null) { hidden_lines = new List(); } hidden_lines.Add(new LocationRegion(start, end)); } public override string ToString() { return $"SourceFile ({Name}:{OriginalFullPathName}:{Index})"; } } internal struct Location : IEquatable { private struct Checkpoint { public readonly int LineOffset; public readonly int File; public Checkpoint(int file, int line) { File = file; LineOffset = line - line % 256; } } private readonly int token; private const int column_bits = 8; private const int line_delta_bits = 8; private const int checkpoint_bits = 16; private const int column_mask = 255; private const int max_column = 255; private static List source_list; private static Checkpoint[] checkpoints; private static int checkpoint_index; public static readonly Location Null; public static bool InEmacs; public bool IsNull => token == 0; public string Name { get { int file = File; if (token == 0 || file <= 0) { return null; } SourceFile sourceFile = source_list[file - 1]; return sourceFile.Name; } } public string NameFullPath { get { int file = File; if (file <= 0) { return null; } return source_list[file - 1].OriginalFullPathName; } } private int CheckpointIndex => (token >> 16) & 0xFFFF; public int Row { get { if (token == 0) { return 1; } int lineOffset = checkpoints[CheckpointIndex].LineOffset; return lineOffset + ((token >> 8) & 0xFF); } } public int Column { get { if (token == 0) { return 1; } return token & 0xFF; } } public int File { get { if (token == 0) { return 0; } if (checkpoints.Length <= CheckpointIndex) { throw new Exception($"Should not happen. Token is {token:X04}, checkpoints are {checkpoints.Length}, index is {CheckpointIndex}"); } return checkpoints[CheckpointIndex].File; } } public SourceFile SourceFile { get { int file = File; if (file == 0) { return null; } return source_list[file - 1]; } } static Location() { Null = default(Location); Reset(); } public static void Reset() { source_list = new List(); checkpoint_index = 0; } public static void AddFile(SourceFile file) { source_list.Add(file); } public static void Initialize(List files) { source_list.AddRange(files); checkpoints = new Checkpoint[Math.Max(1, source_list.Count * 2)]; if (checkpoints.Length != 0) { checkpoints[0] = new Checkpoint(0, 0); } } public Location(SourceFile file, int row, int column) { if (row <= 0) { token = 0; return; } if (column > 255) { column = 255; } long num = -1L; long num2 = 0L; int num3 = file?.Index ?? 0; int num4 = ((checkpoint_index < 10) ? checkpoint_index : 10); for (int i = 0; i < num4; i++) { int lineOffset = checkpoints[checkpoint_index - i].LineOffset; num2 = row - lineOffset; if (num2 >= 0 && num2 < 256 && checkpoints[checkpoint_index - i].File == num3) { num = checkpoint_index - i; break; } } if (num == -1) { AddCheckpoint(num3, row); num = checkpoint_index; num2 = row % 256; } long num5 = column + (num2 << 8) + (num << 16); token = (int)((num5 <= uint.MaxValue) ? num5 : 0); } public static Location operator -(Location loc, int columns) { return new Location(loc.SourceFile, loc.Row, loc.Column - columns); } private static void AddCheckpoint(int file, int row) { if (checkpoints.Length == ++checkpoint_index) { Array.Resize(ref checkpoints, checkpoint_index * 2); } checkpoints[checkpoint_index] = new Checkpoint(file, row); } private string FormatLocation(string fileName) { if (InEmacs) { return fileName + "(" + Row + "):"; } return fileName + "(" + Row + "," + Column + ((Column == 255) ? "+):" : "):"); } public override string ToString() { return FormatLocation(Name); } public string ToStringFullName() { return FormatLocation(NameFullPath); } public bool Equals(Location other) { return token == other.token; } } internal class LocationsBag { public class MemberLocations { public readonly IList> Modifiers; private List locations; public Location this[int index] => locations[index]; public int Count => locations.Count; public MemberLocations(IList> mods) { Modifiers = mods; } public MemberLocations(IList> mods, Location loc) : this(mods) { AddLocations(loc); } public MemberLocations(IList> mods, Location[] locs) : this(mods) { AddLocations(locs); } public MemberLocations(IList> mods, List locs) : this(mods) { locations = locs; } public void AddLocations(Location loc) { if (locations == null) { locations = new List(); } locations.Add(loc); } public void AddLocations(params Location[] additional) { if (locations == null) { locations = new List(additional); } else { locations.AddRange(additional); } } } private Dictionary> simple_locs = new Dictionary>(ReferenceEquality.Default); private Dictionary member_locs = new Dictionary(ReferenceEquality.Default); [Conditional("FULL_AST")] public void AddLocation(object element, params Location[] locations) { simple_locs.Add(element, new List(locations)); } [Conditional("FULL_AST")] public void InsertLocation(object element, int index, Location location) { if (!simple_locs.TryGetValue(element, out var value)) { value = new List(); simple_locs.Add(element, value); } value.Insert(index, location); } [Conditional("FULL_AST")] public void AddStatement(object element, params Location[] locations) { if (locations.Length == 0) { throw new ArgumentException("Statement is missing semicolon location"); } } [Conditional("FULL_AST")] public void AddMember(MemberCore member, IList> modLocations) { member_locs.Add(member, new MemberLocations(modLocations)); } [Conditional("FULL_AST")] public void AddMember(MemberCore member, IList> modLocations, Location location) { member_locs.Add(member, new MemberLocations(modLocations, location)); } [Conditional("FULL_AST")] public void AddMember(MemberCore member, IList> modLocations, params Location[] locations) { member_locs.Add(member, new MemberLocations(modLocations, locations)); } [Conditional("FULL_AST")] public void AddMember(MemberCore member, IList> modLocations, List locations) { member_locs.Add(member, new MemberLocations(modLocations, locations)); } [Conditional("FULL_AST")] public void AppendTo(object element, Location location) { if (!simple_locs.TryGetValue(element, out var value)) { value = new List(); simple_locs.Add(element, value); } value.Add(location); } [Conditional("FULL_AST")] public void AppendToMember(MemberCore existing, params Location[] locations) { if (member_locs.TryGetValue(existing, out var value)) { value.AddLocations(locations); } } public List GetLocations(object element) { simple_locs.TryGetValue(element, out var value); return value; } public MemberLocations GetMemberLocation(MemberCore element) { member_locs.TryGetValue(element, out var value); return value; } } [Flags] internal enum MemberKind { Constructor = 1, Event = 2, Field = 4, Method = 8, Property = 0x10, Indexer = 0x20, Operator = 0x40, Destructor = 0x80, Class = 0x800, Struct = 0x1000, Delegate = 0x2000, Enum = 0x4000, Interface = 0x8000, TypeParameter = 0x10000, ByRef = 0x20000, ArrayType = 0x80000, PointerType = 0x100000, InternalCompilerType = 0x200000, MissingType = 0x400000, Void = 0x800000, Namespace = 0x1000000, NestedMask = 0xF800, GenericMask = 0xB808, MaskType = 0xF8FF } [Flags] internal enum BindingRestriction { None = 0, DeclaredOnly = 2, InstanceOnly = 4, NoAccessors = 8, OverrideOnly = 0x10 } internal struct MemberFilter : IEquatable { public readonly string Name; public readonly MemberKind Kind; public readonly AParametersCollection Parameters; public readonly TypeSpec MemberType; public readonly int Arity; public MemberFilter(MethodSpec m) { Name = m.Name; Kind = MemberKind.Method; Parameters = m.Parameters; MemberType = m.ReturnType; Arity = m.Arity; } public MemberFilter(string name, int arity, MemberKind kind, AParametersCollection param, TypeSpec type) { Name = name; Kind = kind; Parameters = param; MemberType = type; Arity = arity; } public static MemberFilter Constructor(AParametersCollection param) { return new MemberFilter(Mono.CSharp.Constructor.ConstructorName, 0, MemberKind.Constructor, param, null); } public static MemberFilter Property(string name, TypeSpec type) { return new MemberFilter(name, 0, MemberKind.Property, null, type); } public static MemberFilter Field(string name, TypeSpec type) { return new MemberFilter(name, 0, MemberKind.Field, null, type); } public static MemberFilter Method(string name, int arity, AParametersCollection param, TypeSpec type) { return new MemberFilter(name, arity, MemberKind.Method, param, type); } public bool Equals(MemberSpec other) { if ((other.Kind & Kind & MemberKind.MaskType) == 0) { return false; } if (Arity >= 0 && Arity != other.Arity) { return false; } if (Parameters != null) { if (!(other is IParametersMember)) { return false; } AParametersCollection parameters = ((IParametersMember)other).Parameters; if (!TypeSpecComparer.Override.IsEqual(Parameters, parameters)) { return false; } } if (MemberType != null) { if (!(other is IInterfaceMemberSpec)) { return false; } TypeSpec memberType = ((IInterfaceMemberSpec)other).MemberType; if (!TypeSpecComparer.Override.IsEqual(memberType, MemberType)) { return false; } } return true; } } internal class MemberCache { [Flags] private enum StateFlags { HasConversionOperator = 2, HasUserOperator = 4 } private readonly Dictionary> member_hash; private Dictionary locase_members; private IList missing_abstract; private StateFlags state; public static readonly string IndexerNameAlias = ""; public static readonly MemberCache Empty = new MemberCache(0); public MemberCache() : this(16) { } public MemberCache(int capacity) { member_hash = new Dictionary>(capacity); } public MemberCache(MemberCache cache) : this(cache.member_hash.Count) { state = cache.state; } public MemberCache(TypeContainer container) : this() { } public void AddBaseType(TypeSpec baseType) { MemberCache memberCache = baseType.MemberCache; foreach (KeyValuePair> item in memberCache.member_hash) { if (!member_hash.TryGetValue(item.Key, out var value)) { value = ((item.Value.Count != 1) ? new List(item.Value) : item.Value); member_hash.Add(item.Key, value); continue; } foreach (MemberSpec item2 in item.Value) { if (!value.Contains(item2)) { if (value is MemberSpec[]) { value = new List { value[0] }; member_hash[item.Key] = value; } value.Add(item2); } } } } public void AddInterface(TypeSpec iface) { MemberCache memberCache = iface.MemberCache; foreach (KeyValuePair> item in memberCache.member_hash) { if (!member_hash.TryGetValue(item.Key, out var value)) { value = ((item.Value.Count != 1) ? new List(item.Value) : item.Value); member_hash.Add(item.Key, value); continue; } foreach (MemberSpec item2 in item.Value) { if (!value.Contains(item2) && AddInterfaceMember(item2, ref value)) { member_hash[item.Key] = value; } } } } public void AddMember(InterfaceMemberBase imb, string exlicitName, MemberSpec ms) { if (imb.IsExplicitImpl) { AddMember(exlicitName, ms, removeHiddenMembers: false); } else { AddMember(ms); } } public void AddMember(MemberSpec ms) { AddMember(GetLookupName(ms), ms, removeHiddenMembers: false); } private void AddMember(string name, MemberSpec member, bool removeHiddenMembers) { if (member.Kind == MemberKind.Operator) { TypeSpec declaringType = member.DeclaringType; if (!BuiltinTypeSpec.IsPrimitiveType(declaringType) || declaringType.BuiltinType == BuiltinTypeSpec.Type.Char) { BuiltinTypeSpec.Type builtinType = declaringType.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 22) > 1u) { if (name == Operator.GetMetadataName(Operator.OpType.Implicit) || name == Operator.GetMetadataName(Operator.OpType.Explicit)) { state |= StateFlags.HasConversionOperator; } else if (declaringType.BuiltinType != BuiltinTypeSpec.Type.String) { state |= StateFlags.HasUserOperator; } } } } if (!member_hash.TryGetValue(name, out var value)) { member_hash.Add(name, new MemberSpec[1] { member }); return; } if (removeHiddenMembers && member.DeclaringType.IsInterface) { if (AddInterfaceMember(member, ref value)) { member_hash[name] = value; } return; } if (value.Count == 1) { value = new List { value[0] }; member_hash[name] = value; } value.Add(member); } public void AddMemberImported(MemberSpec ms) { AddMember(GetLookupName(ms), ms, removeHiddenMembers: true); } private static bool AddInterfaceMember(MemberSpec member, ref IList existing) { AParametersCollection aParametersCollection = ((member is IParametersMember) ? ((IParametersMember)member).Parameters : null); for (int i = 0; i < existing.Count; i++) { MemberSpec memberSpec = existing[i]; if (memberSpec.Arity != member.Arity) { continue; } AParametersCollection aParametersCollection2 = null; if (aParametersCollection != null && memberSpec is IParametersMember parametersMember) { aParametersCollection2 = parametersMember.Parameters; if (memberSpec.DeclaringType != member.DeclaringType) { if (!TypeSpecComparer.Override.IsEqual(aParametersCollection2, aParametersCollection)) { continue; } } else if (!TypeSpecComparer.Equals(aParametersCollection2.Types, aParametersCollection.Types)) { continue; } } if (member.DeclaringType.ImplementsInterface(memberSpec.DeclaringType, variantly: false)) { if (existing.Count == 1) { existing = new MemberSpec[1] { member }; return true; } existing.RemoveAt(i--); } else { if (memberSpec.DeclaringType == member.DeclaringType && memberSpec.IsAccessor == member.IsAccessor) { return false; } if (memberSpec.DeclaringType.ImplementsInterface(member.DeclaringType, variantly: false) && AParametersCollection.HasSameParameterDefaults(aParametersCollection2, aParametersCollection)) { return false; } } } if (existing.Count == 1) { existing = new List { existing[0], member }; return true; } existing.Add(member); return false; } public static MemberSpec FindMember(TypeSpec container, MemberFilter filter, BindingRestriction restrictions) { if (filter.Kind == MemberKind.Method && container.Kind == MemberKind.TypeParameter && filter.Parameters == null) { throw new NotSupportedException("type parameters methods cannot be lookup up due to two stage setup"); } TypeSpec typeSpec = container; IList value; do { if (container.MemberCache.member_hash.TryGetValue(filter.Name, out value)) { for (int num = value.Count - 1; num >= 0; num--) { MemberSpec memberSpec = value[num]; if (((restrictions & BindingRestriction.InstanceOnly) == 0 || !memberSpec.IsStatic) && ((restrictions & BindingRestriction.NoAccessors) == 0 || !memberSpec.IsAccessor) && ((restrictions & BindingRestriction.OverrideOnly) == 0 || (memberSpec.Modifiers & Modifiers.OVERRIDE) != 0) && filter.Equals(memberSpec) && ((restrictions & BindingRestriction.DeclaredOnly) == 0 || !container.IsInterface || memberSpec.DeclaringType == container)) { return memberSpec; } } } if ((restrictions & BindingRestriction.DeclaredOnly) != BindingRestriction.None) { break; } container = container.BaseType; } while (container != null); if (typeSpec is TypeParameterSpec { InterfaceCache: not null } typeParameterSpec && typeParameterSpec.InterfaceCache.member_hash.TryGetValue(filter.Name, out value)) { for (int num2 = value.Count - 1; num2 >= 0; num2--) { MemberSpec memberSpec2 = value[num2]; if (((restrictions & BindingRestriction.NoAccessors) == 0 || !memberSpec2.IsAccessor) && ((restrictions & BindingRestriction.OverrideOnly) == 0 || (memberSpec2.Modifiers & Modifiers.OVERRIDE) != 0) && filter.Equals(memberSpec2)) { return memberSpec2; } } } return null; } public static IList FindMembers(TypeSpec container, string name, bool declaredOnlyClass) { do { if (container.MemberCache.member_hash.TryGetValue(name, out var value) || declaredOnlyClass) { return value; } container = container.BaseType; } while (container != null); return null; } public static IList FindInterfaceMembers(TypeParameterSpec typeParameter, string name) { if (typeParameter.InterfaceCache != null) { typeParameter.InterfaceCache.member_hash.TryGetValue(name, out var value); return value; } return null; } public static TypeSpec FindNestedType(TypeSpec container, string name, int arity, bool declaredOnlyClass) { TypeSpec typeSpec = null; do { if (container.MemberDefinition is TypeContainer typeContainer) { typeContainer.DefineContainer(); } if (container.MemberCacheTypes.member_hash.TryGetValue(name, out var value)) { for (int num = value.Count - 1; num >= 0; num--) { MemberSpec memberSpec = value[num]; if ((memberSpec.Kind & MemberKind.NestedMask) != 0) { TypeSpec typeSpec2 = (TypeSpec)memberSpec; if (arity == typeSpec2.Arity) { return typeSpec2; } if (arity < 0) { if (typeSpec == null) { typeSpec = typeSpec2; } else if (Math.Abs(typeSpec2.Arity + arity) < Math.Abs(typeSpec.Arity + arity)) { typeSpec = typeSpec2; } } } } } container = container.BaseType; } while (container != null && !declaredOnlyClass); return typeSpec; } public List FindExtensionMethods(IMemberContext invocationContext, string name, int arity) { if (!member_hash.TryGetValue(name, out var value)) { return null; } List list = null; foreach (MemberSpec item in value) { if (item.Kind != MemberKind.Method || (arity > 0 && item.Arity != arity)) { continue; } MethodSpec methodSpec = (MethodSpec)item; if (methodSpec.IsExtensionMethod && methodSpec.IsAccessible(invocationContext) && ((methodSpec.DeclaringType.Modifiers & Modifiers.INTERNAL) == 0 || methodSpec.DeclaringType.MemberDefinition.IsInternalAsPublic(invocationContext.Module.DeclaringAssembly))) { if (list == null) { list = new List(); } list.Add(methodSpec); } } return list; } public static MemberSpec FindBaseMember(MemberCore member, out MemberSpec bestCandidate, ref bool overrides) { bestCandidate = null; TypeSpec typeSpec = member.Parent.PartialContainer.Definition; if (!typeSpec.IsInterface) { typeSpec = typeSpec.BaseType; if (typeSpec == null) { return null; } } string lookupName = GetLookupName(member); AParametersCollection b = ((member is IParametersMember) ? ((IParametersMember)member).Parameters : null); MemberKind memberCoreKind = GetMemberCoreKind(member); bool flag = memberCoreKind == MemberKind.Indexer || memberCoreKind == MemberKind.Property; MemberSpec memberSpec = null; do { if (typeSpec.MemberCache.member_hash.TryGetValue(lookupName, out var value)) { for (int i = 0; i < value.Count; i++) { MemberSpec memberSpec2 = value[i]; if ((memberSpec2.Modifiers & Modifiers.PUBLIC) == 0 && !memberSpec2.IsAccessible(member)) { continue; } if ((memberSpec2.Kind & ~MemberKind.Destructor & memberCoreKind & MemberKind.MaskType) == 0) { if ((memberSpec2.Kind & MemberKind.Destructor) == 0 && (memberCoreKind == MemberKind.Method || member.MemberName.Arity == memberSpec2.Arity)) { bestCandidate = memberSpec2; return null; } } else { if (member.MemberName.Arity != memberSpec2.Arity) { continue; } if ((memberSpec2.Kind & memberCoreKind & (MemberKind.Method | MemberKind.Indexer)) != 0) { if (memberSpec2.IsAccessor != member is AbstractPropertyEventMethod) { continue; } IParametersMember parametersMember = memberSpec2 as IParametersMember; if (!TypeSpecComparer.Override.IsEqual(parametersMember.Parameters, b)) { continue; } } if (flag && (memberSpec2.Modifiers & (Modifiers.SEALED | Modifiers.OVERRIDE)) == Modifiers.OVERRIDE) { overrides = true; continue; } if (memberSpec != null || (memberSpec2.Kind & memberCoreKind & (MemberKind.Method | MemberKind.Indexer)) == 0) { bestCandidate = memberSpec; return memberSpec2; } bestCandidate = null; memberSpec = memberSpec2; } } } if (typeSpec.IsInterface || memberSpec != null) { break; } typeSpec = typeSpec.BaseType; } while (typeSpec != null); return memberSpec; } public static List GetDeclaredNestedTypes(TypeSpec container) { List list = null; foreach (KeyValuePair> item in container.MemberCache.member_hash) { foreach (MemberSpec item2 in item.Value) { if ((item2.Kind & MemberKind.NestedMask) != 0) { if (list == null) { list = new List(); } list.Add((TypeSpec)item2); } } } return list; } public static T GetMember(TypeSpec container, T spec) where T : MemberSpec { if (container.MemberCache.member_hash.TryGetValue(GetLookupName(spec), out var value)) { for (int num = value.Count - 1; num >= 0; num--) { MemberSpec memberSpec = value[num]; if (memberSpec.MemberDefinition == spec.MemberDefinition) { return (T)memberSpec; } } } throw new InternalErrorException("Missing member `{0}' on inflated type `{1}'", spec.GetSignatureForError(), container.GetSignatureForError()); } private static MemberKind GetMemberCoreKind(MemberCore member) { if (member is FieldBase) { return MemberKind.Field; } if (member is Indexer) { return MemberKind.Indexer; } if (member is Class) { return MemberKind.Class; } if (member is Struct) { return MemberKind.Struct; } if (member is Destructor) { return MemberKind.Destructor; } if (member is Method) { return MemberKind.Method; } if (member is Property) { return MemberKind.Property; } if (member is EventField) { return MemberKind.Event; } if (member is Interface) { return MemberKind.Interface; } if (member is EventProperty) { return MemberKind.Event; } if (member is Delegate) { return MemberKind.Delegate; } if (member is Enum) { return MemberKind.Enum; } throw new NotImplementedException(member.GetType().ToString()); } public static List GetAllFieldsForDefiniteAssignment(TypeSpec container, IMemberContext context) { List list = null; bool isImported = container.MemberDefinition.IsImported; foreach (KeyValuePair> item in container.MemberCache.member_hash) { foreach (MemberSpec item2 in item.Value) { if (item2.Kind != MemberKind.Field || (item2.Modifiers & Modifiers.STATIC) != 0 || item2 is FixedFieldSpec || item2 is ConstSpec) { continue; } FieldSpec fieldSpec = (FieldSpec)item2; if (isImported && ShouldIgnoreFieldForDefiniteAssignment(fieldSpec, context)) { continue; } if (list == null) { list = new List(); } list.Add(fieldSpec); break; } } return list ?? new List(0); } private static bool ShouldIgnoreFieldForDefiniteAssignment(FieldSpec fs, IMemberContext context) { Modifiers modifiers = fs.Modifiers; if ((modifiers & Modifiers.PRIVATE) == 0 && (modifiers & Modifiers.INTERNAL) != 0 && fs.DeclaringType.MemberDefinition.IsInternalAsPublic(context.Module.DeclaringAssembly)) { return false; } TypeSpec memberType = fs.MemberType; MemberKind kind = memberType.Kind; MemberKind memberKind = kind; if (memberKind == MemberKind.TypeParameter || memberKind == MemberKind.ArrayType) { return false; } return TypeSpec.IsReferenceType(memberType); } public static IList GetCompletitionMembers(IMemberContext ctx, TypeSpec container, string name) { List list = new List(); foreach (KeyValuePair> item in container.MemberCache.member_hash) { foreach (MemberSpec item2 in item.Value) { if (!item2.IsAccessor && (item2.Kind & (MemberKind.Constructor | MemberKind.Operator | MemberKind.Destructor)) == 0 && item2.IsAccessible(ctx) && (name == null || item2.Name.StartsWith(name))) { list.Add(item2); } } } return list; } public static List GetInterfaceMethods(TypeSpec iface) { List list = new List(); foreach (IList value in iface.MemberCache.member_hash.Values) { foreach (MemberSpec item in value) { if (iface == item.DeclaringType && item.Kind == MemberKind.Method) { list.Add((MethodSpec)item); } } } return list; } public static IList GetNotImplementedAbstractMethods(TypeSpec type) { if (type.MemberCache.missing_abstract != null) { return type.MemberCache.missing_abstract; } List list = new List(); List list2 = null; TypeSpec typeSpec = type; while (true) { foreach (KeyValuePair> item2 in typeSpec.MemberCache.member_hash) { foreach (MemberSpec item3 in item2.Value) { if ((item3.Modifiers & Modifiers.ABSTRACT) != 0 && item3 is MethodSpec item) { list.Add(item); } } } TypeSpec baseType = typeSpec.BaseType; if (!baseType.IsAbstract) { break; } if (list2 == null) { list2 = new List(); } list2.Add(typeSpec); typeSpec = baseType; } int num = list.Count; if (num == 0 || list2 == null) { type.MemberCache.missing_abstract = list; return type.MemberCache.missing_abstract; } foreach (TypeSpec item4 in list2) { Dictionary> dictionary = item4.MemberCache.member_hash; if (dictionary.Count == 0) { continue; } for (int i = 0; i < list.Count; i++) { MethodSpec methodSpec = list[i]; if (methodSpec == null || !dictionary.TryGetValue(methodSpec.Name, out var value)) { continue; } MemberFilter memberFilter = new MemberFilter(methodSpec); foreach (MemberSpec item5 in value) { if ((item5.Modifiers & (Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0 || (item5.Modifiers & Modifiers.ABSTRACT) != 0 || !memberFilter.Equals(item5)) { continue; } num--; list[i] = null; break; } } } if (num == list.Count) { type.MemberCache.missing_abstract = list; return type.MemberCache.missing_abstract; } MethodSpec[] array = new MethodSpec[num]; int num2 = 0; foreach (MethodSpec item6 in list) { if (item6 != null) { array[num2++] = item6; } } type.MemberCache.missing_abstract = array; return type.MemberCache.missing_abstract; } private static string GetLookupName(MemberSpec ms) { if (ms.Kind == MemberKind.Indexer) { return IndexerNameAlias; } if (ms.Kind == MemberKind.Constructor) { if (ms.IsStatic) { return Constructor.TypeConstructorName; } return Constructor.ConstructorName; } return ms.Name; } private static string GetLookupName(MemberCore mc) { if (mc is Indexer) { return IndexerNameAlias; } if (mc is Constructor) { return mc.IsStatic ? Constructor.TypeConstructorName : Constructor.ConstructorName; } return mc.MemberName.Name; } public static IList GetUserOperator(TypeSpec container, Operator.OpType op, bool declaredOnly) { IList list = null; bool flag = true; do { MemberCache memberCache = container.MemberCache; if ((((op == Operator.OpType.Implicit || op == Operator.OpType.Explicit) && (memberCache.state & StateFlags.HasConversionOperator) != 0) || (memberCache.state & StateFlags.HasUserOperator) != 0) && memberCache.member_hash.TryGetValue(Operator.GetMetadataName(op), out var value)) { int i; for (i = 0; i < value.Count && value[i].Kind == MemberKind.Operator; i++) { } if (i != value.Count) { for (i = 0; i < value.Count; i++) { if (value[i].Kind != MemberKind.Operator) { continue; } if (list == null) { list = new List(); list.Add(value[i]); continue; } List list2; if (flag) { flag = false; list2 = new List(list.Count + 1); list2.AddRange(list); list = list2; } else { list2 = (List)list; } list2.Add(value[i]); } } else if (list == null) { list = value; flag = true; } else { List list3; if (flag) { flag = false; list3 = new List(list.Count + value.Count); list3.AddRange(list); list = list3; } else { list3 = (List)list; } list3.AddRange(value); } } if (declaredOnly) { break; } container = container.BaseType; } while (container != null); return list; } public void InflateTypes(MemberCache inflated_cache, TypeParameterInflator inflator) { foreach (KeyValuePair> item in member_hash) { IList list = null; for (int i = 0; i < item.Value.Count; i++) { MemberSpec memberSpec = item.Value[i]; if (memberSpec != null && (memberSpec.Kind & MemberKind.NestedMask) != 0 && (memberSpec.Modifiers & Modifiers.COMPILER_GENERATED) == 0) { if (list == null) { list = new MemberSpec[item.Value.Count]; inflated_cache.member_hash.Add(item.Key, list); } list[i] = memberSpec.InflateMember(inflator); } } } } public void InflateMembers(MemberCache cacheToInflate, TypeSpec inflatedType, TypeParameterInflator inflator) { Dictionary> dictionary = cacheToInflate.member_hash; Dictionary dictionary2 = null; List list = null; cacheToInflate.state = state; foreach (KeyValuePair> item in member_hash) { IList value = item.Value; IList list2 = null; for (int i = 0; i < value.Count; i++) { MemberSpec memberSpec = value[i]; if ((memberSpec.Kind & MemberKind.NestedMask) != 0 && (memberSpec.Modifiers & Modifiers.COMPILER_GENERATED) == 0) { if (list2 == null) { list2 = dictionary[item.Key]; } continue; } if (list2 == null) { list2 = new MemberSpec[item.Value.Count]; dictionary.Add(item.Key, list2); } TypeParameterInflator inflator2 = inflator; if (memberSpec.DeclaringType != inflatedType) { if (!memberSpec.DeclaringType.IsGeneric && !memberSpec.DeclaringType.IsNested) { list2[i] = memberSpec; continue; } TypeSpec typeSpec = inflator.Inflate(memberSpec.DeclaringType); if (typeSpec != inflator.TypeInstance) { inflator2 = new TypeParameterInflator(inflator, typeSpec); } } MemberSpec memberSpec2 = (list2[i] = memberSpec.InflateMember(inflator2)); if (memberSpec is PropertySpec || memberSpec is EventSpec) { if (list == null) { list = new List(); } list.Add(memberSpec2); } else if (memberSpec.IsAccessor) { if (dictionary2 == null) { dictionary2 = new Dictionary(); } dictionary2.Add(memberSpec, (MethodSpec)memberSpec2); } } } if (list == null) { return; } foreach (MemberSpec item2 in list) { if (item2 is PropertySpec propertySpec) { if (propertySpec.Get != null) { propertySpec.Get = dictionary2[propertySpec.Get]; } if (propertySpec.Set != null) { propertySpec.Set = dictionary2[propertySpec.Set]; } } else { EventSpec eventSpec = (EventSpec)item2; eventSpec.AccessorAdd = dictionary2[eventSpec.AccessorAdd]; eventSpec.AccessorRemove = dictionary2[eventSpec.AccessorRemove]; } } } public void RemoveHiddenMembers(TypeSpec container) { foreach (KeyValuePair> item in member_hash) { IList value = item.Value; int num = 0; while (value[num].DeclaringType != container && ++num < item.Value.Count) { } if (num == 0 || num == value.Count) { continue; } for (int i = 0; i < num; i++) { MemberSpec memberSpec = value[i]; if (!container.ImplementsInterface(memberSpec.DeclaringType, variantly: false)) { continue; } AParametersCollection b = ((memberSpec is IParametersMember) ? ((IParametersMember)memberSpec).Parameters : ParametersCompiled.EmptyReadOnlyParameters); for (int j = num; j < value.Count; j++) { MemberSpec memberSpec2 = value[j]; if (memberSpec2.Arity == memberSpec.Arity && (!(memberSpec2 is IParametersMember) || TypeSpecComparer.Override.IsEqual(((IParametersMember)memberSpec2).Parameters, b))) { value.RemoveAt(i); num--; j--; i--; } } } } } public void VerifyClsCompliance(TypeSpec container, Report report) { if (locase_members != null) { return; } if (container.BaseType == null) { locase_members = new Dictionary(member_hash.Count); } else { TypeSpec definition = container.BaseType.GetDefinition(); definition.MemberCache.VerifyClsCompliance(definition, report); locase_members = new Dictionary(definition.MemberCache.locase_members); } bool isImported = container.MemberDefinition.IsImported; foreach (KeyValuePair> item in container.MemberCache.member_hash) { for (int i = 0; i < item.Value.Count; i++) { MemberSpec memberSpec = item.Value[i]; if ((memberSpec.Modifiers & (Modifiers.PROTECTED | Modifiers.PUBLIC)) == 0 || (memberSpec.Modifiers & (Modifiers.OVERRIDE | Modifiers.COMPILER_GENERATED)) != 0 || (memberSpec.Kind & MemberKind.MaskType) == 0 || memberSpec.MemberDefinition.CLSAttributeValue == false) { continue; } IParametersMember parametersMember = null; if (!isImported) { parametersMember = memberSpec as IParametersMember; if (parametersMember != null && !memberSpec.IsAccessor) { AParametersCollection parameters = parametersMember.Parameters; for (int j = i + 1; j < item.Value.Count; j++) { MemberSpec memberSpec2 = item.Value[j]; if (memberSpec2 is IParametersMember parametersMember2 && parameters.Count == parametersMember2.Parameters.Count && !memberSpec2.IsAccessor) { int num = ParametersCompiled.IsSameClsSignature(parametersMember.Parameters, parametersMember2.Parameters); if (num != 0) { ReportOverloadedMethodClsDifference(memberSpec, memberSpec2, num, report); } } } } } if (i > 0 || memberSpec.Kind == MemberKind.Constructor || memberSpec.Kind == MemberKind.Indexer) { continue; } string key = memberSpec.Name.ToLowerInvariant(); if (!locase_members.TryGetValue(key, out var value)) { value = new MemberSpec[1] { memberSpec }; locase_members.Add(key, value); continue; } bool flag = true; MemberSpec[] array = value; foreach (MemberSpec memberSpec3 in array) { if (memberSpec3.Name == memberSpec.Name) { if (parametersMember != null && memberSpec3 is IParametersMember parametersMember3 && parametersMember.Parameters.Count == parametersMember3.Parameters.Count && !memberSpec3.IsAccessor) { int num2 = ParametersCompiled.IsSameClsSignature(parametersMember.Parameters, parametersMember3.Parameters); if (num2 != 0) { ReportOverloadedMethodClsDifference(memberSpec3, memberSpec, num2, report); } } continue; } flag = false; if (!isImported) { MemberCore laterDefinedMember = GetLaterDefinedMember(memberSpec3, memberSpec); if (laterDefinedMember == memberSpec3.MemberDefinition) { report.SymbolRelatedToPreviousError(memberSpec); } else { report.SymbolRelatedToPreviousError(memberSpec3); } report.Warning(3005, 1, laterDefinedMember.Location, "Identifier `{0}' differing only in case is not CLS-compliant", laterDefinedMember.GetSignatureForError()); } } if (!flag) { Array.Resize(ref value, value.Length + 1); value[^1] = memberSpec; locase_members[key] = value; } } } } private static MemberCore GetLaterDefinedMember(MemberSpec a, MemberSpec b) { MemberCore memberCore = a.MemberDefinition as MemberCore; MemberCore memberCore2 = b.MemberDefinition as MemberCore; if (memberCore == null) { return memberCore2; } if (memberCore2 == null) { return memberCore; } if (a.DeclaringType.MemberDefinition != b.DeclaringType.MemberDefinition) { return memberCore2; } if (memberCore.Location.File != memberCore2.Location.File) { return memberCore2; } return (memberCore2.Location.Row > memberCore.Location.Row) ? memberCore2 : memberCore; } private static void ReportOverloadedMethodClsDifference(MemberSpec a, MemberSpec b, int res, Report report) { MemberCore laterDefinedMember = GetLaterDefinedMember(a, b); if (laterDefinedMember == a.MemberDefinition) { report.SymbolRelatedToPreviousError(b); } else { report.SymbolRelatedToPreviousError(a); } if ((res & 1) != 0) { report.Warning(3006, 1, laterDefinedMember.Location, "Overloaded method `{0}' differing only in ref or out, or in array rank, is not CLS-compliant", laterDefinedMember.GetSignatureForError()); } if ((res & 2) != 0) { report.Warning(3007, 1, laterDefinedMember.Location, "Overloaded method `{0}' differing only by unnamed array types is not CLS-compliant", laterDefinedMember.GetSignatureForError()); } } public bool CheckExistingMembersOverloads(MemberCore member, AParametersCollection parameters) { string name = GetLookupName(member); if (member is InterfaceMemberBase { IsExplicitImpl: not false } interfaceMemberBase) { name = interfaceMemberBase.GetFullName(name); } return CheckExistingMembersOverloads(member, name, parameters); } public bool CheckExistingMembersOverloads(MemberCore member, string name, AParametersCollection parameters) { if (!member_hash.TryGetValue(name, out var value)) { return false; } Report report = member.Compiler.Report; int count = parameters.Count; for (int num = value.Count - 1; num >= 0; num--) { MemberSpec memberSpec = value[num]; IParametersMember parametersMember = memberSpec as IParametersMember; AParametersCollection aParametersCollection = ((parametersMember == null) ? ParametersCompiled.EmptyReadOnlyParameters : parametersMember.Parameters); if (aParametersCollection.Count != count || memberSpec.Arity != member.MemberName.Arity || member.Parent.PartialContainer != memberSpec.DeclaringType.MemberDefinition) { continue; } TypeSpec[] types = aParametersCollection.Types; if (count > 0) { int num2 = count - 1; TypeSpec a; TypeSpec b; bool flag; bool flag2; do { a = parameters.Types[num2]; b = types[num2]; flag = (aParametersCollection.FixedParameters[num2].ModFlags & Parameter.Modifier.RefOutMask) != 0; flag2 = (parameters.FixedParameters[num2].ModFlags & Parameter.Modifier.RefOutMask) != 0; } while (flag == flag2 && TypeSpecComparer.Override.IsEqual(a, b) && num2-- != 0); if (num2 >= 0 || (member is Operator && memberSpec.Kind == MemberKind.Operator && ((MethodSpec)memberSpec).ReturnType != ((Operator)member).ReturnType)) { continue; } if (aParametersCollection != null && member is MethodCore) { num2 = count; while (num2-- != 0 && (parameters.FixedParameters[num2].ModFlags & Parameter.Modifier.ModifierMask) == (aParametersCollection.FixedParameters[num2].ModFlags & Parameter.Modifier.ModifierMask) && parameters.ExtensionMethodType == aParametersCollection.ExtensionMethodType) { } if (num2 >= 0) { MethodSpec methodSpec = memberSpec as MethodSpec; member.Compiler.Report.SymbolRelatedToPreviousError(memberSpec); if ((member.ModFlags & Modifiers.PARTIAL) != 0 && (methodSpec.Modifiers & Modifiers.PARTIAL) != 0) { if (parameters.HasParams || aParametersCollection.HasParams) { report.Error(758, member.Location, "A partial method declaration and partial method implementation cannot differ on use of `params' modifier"); } else { report.Error(755, member.Location, "A partial method declaration and partial method implementation must be both an extension method or neither"); } } else if (member is Constructor) { report.Error(851, member.Location, "Overloaded contructor `{0}' cannot differ on use of parameter modifiers only", member.GetSignatureForError()); } else { report.Error(663, member.Location, "Overloaded method `{0}' cannot differ on use of parameter modifiers only", member.GetSignatureForError()); } return false; } MethodCore methodCore = (MethodCore)member; if (!NamedTupleSpec.CheckOverrideName(parametersMember, methodCore) || !NamedTupleSpec.CheckOverrideName(parametersMember.MemberType, methodCore.MemberType)) { report.Error(8142, member.Location, "A partial method declaration and partial method implementation must both use the same tuple element names"); } } } if ((memberSpec.Kind & MemberKind.Method) != 0) { Method method = member as Method; Method method2 = memberSpec.MemberDefinition as Method; if (method != null && method2 != null && (method.ModFlags & method2.ModFlags & Modifiers.PARTIAL) != 0) { if (method.IsPartialDefinition == method2.IsPartialImplementation) { if ((method.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)) == (method2.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)) || (method.Parent.IsUnsafe && method2.Parent.IsUnsafe)) { if (method.IsPartialImplementation) { method.SetPartialDefinition(method2); if (value.Count == 1) { member_hash.Remove(name); } else { value.RemoveAt(num); } } else { method2.SetPartialDefinition(method); method.caching_flags |= MemberCore.Flags.PartialDefinitionExists; } continue; } if (method.IsStatic != method2.IsStatic) { report.SymbolRelatedToPreviousError(memberSpec); report.Error(763, member.Location, "A partial method declaration and partial method implementation must be both `static' or neither"); } if ((method.ModFlags & Modifiers.UNSAFE) != (method2.ModFlags & Modifiers.UNSAFE)) { report.SymbolRelatedToPreviousError(memberSpec); report.Error(764, member.Location, "A partial method declaration and partial method implementation must be both `unsafe' or neither"); } return false; } report.SymbolRelatedToPreviousError(memberSpec); if (method.IsPartialDefinition) { report.Error(756, member.Location, "A partial method `{0}' declaration is already defined", member.GetSignatureForError()); } report.Error(757, member.Location, "A partial method `{0}' implementation is already defined", member.GetSignatureForError()); return false; } report.SymbolRelatedToPreviousError(memberSpec); bool flag3 = member is AbstractPropertyEventMethod || member is Operator; bool isReservedMethod = ((MethodSpec)memberSpec).IsReservedMethod; if (flag3 || isReservedMethod) { report.Error(82, member.Location, "A member `{0}' is already reserved", flag3 ? memberSpec.GetSignatureForError() : member.GetSignatureForError()); return false; } } else { report.SymbolRelatedToPreviousError(memberSpec); } if (member is Operator && memberSpec.Kind == MemberKind.Operator) { report.Error(557, member.Location, "Duplicate user-defined conversion in type `{0}'", member.Parent.GetSignatureForError()); return false; } report.Error(111, member.Location, "A member `{0}' is already defined. Rename this member or use different parameter types", member.GetSignatureForError()); return false; } return true; } } internal abstract class MethodCore : InterfaceMemberBase, IParametersMember, IInterfaceMemberSpec { protected ParametersCompiled parameters; protected ToplevelBlock block; protected MethodSpec spec; public override Variance ExpectedMemberTypeVariance => Variance.Covariant; public TypeSpec[] ParameterTypes => parameters.Types; public ParametersCompiled ParameterInfo => parameters; AParametersCollection IParametersMember.Parameters => parameters; public ToplevelBlock Block { get { return block; } set { block = value; } } public CallingConventions CallingConventions { get { CallingConventions callingConventions = parameters.CallingConvention; if (!IsInterface && (base.ModFlags & Modifiers.STATIC) == 0) { callingConventions |= CallingConventions.HasThis; } return callingConventions; } } public override string DocCommentHeader => "M:"; public MethodSpec Spec => spec; protected MethodCore(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs, ParametersCompiled parameters) : base(parent, type, mod, allowed_mod, name, attrs) { this.parameters = parameters; } protected override bool CheckOverrideAgainstBase(MemberSpec base_member) { bool result = base.CheckOverrideAgainstBase(base_member); if (!InterfaceMemberBase.CheckAccessModifiers(this, base_member)) { Error_CannotChangeAccessModifiers(this, base_member); result = false; } return result; } protected override bool CheckBase() { if (!DefineParameters(parameters)) { return false; } return base.CheckBase(); } public override void Emit() { if ((base.ModFlags & Modifiers.COMPILER_GENERATED) == 0) { parameters.CheckConstraints(this); } base.Emit(); } public override bool EnableOverloadChecks(MemberCore overload) { if (overload is MethodCore) { caching_flags |= Flags.MethodOverloadsExist; return true; } if (overload is AbstractPropertyEventMethod) { return true; } return base.EnableOverloadChecks(overload); } public override string GetSignatureForDocumentation() { string text = base.GetSignatureForDocumentation(); if (base.MemberName.Arity > 0) { text = text + "``" + base.MemberName.Arity; } return text + parameters.GetSignatureForDocumentation(); } public override void PrepareEmit() { base.PrepareEmit(); parameters.ResolveDefaultValues(this); } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } if (parameters.HasArglist) { base.Report.Warning(3000, 1, base.Location, "Methods with variable arguments are not CLS-compliant"); } if (member_type != null && !member_type.IsCLSCompliant()) { base.Report.Warning(3002, 1, base.Location, "Return type of `{0}' is not CLS-compliant", GetSignatureForError()); } parameters.VerifyClsCompliance(this); return true; } } internal interface IGenericMethodDefinition : IMethodDefinition, IMemberDefinition { TypeParameterSpec[] TypeParameters { get; } int TypeParametersCount { get; } } internal sealed class MethodSpec : MemberSpec, IParametersMember, IInterfaceMemberSpec { private MethodBase inflatedMetaInfo; private AParametersCollection parameters; private TypeSpec returnType; private TypeSpec[] targs; private TypeParameterSpec[] constraints; public static readonly MethodSpec Excluded = new MethodSpec(MemberKind.Method, InternalType.FakeInternalType, null, null, ParametersCompiled.EmptyReadOnlyParameters, (Modifiers)0); public override int Arity => base.IsGeneric ? GenericDefinition.TypeParametersCount : 0; public TypeParameterSpec[] Constraints { get { if (constraints == null && base.IsGeneric) { constraints = GenericDefinition.TypeParameters; } return constraints; } } public bool IsConstructor => Kind == MemberKind.Constructor; public new IMethodDefinition MemberDefinition => (IMethodDefinition)definition; public IGenericMethodDefinition GenericDefinition => (IGenericMethodDefinition)definition; public bool IsAsync => (base.Modifiers & Modifiers.ASYNC) != 0; public bool IsExtensionMethod => base.IsStatic && parameters.HasExtensionMethodType; public bool IsSealed => (base.Modifiers & Modifiers.SEALED) != 0; public bool IsVirtual => (base.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) != 0; public bool IsReservedMethod => Kind == MemberKind.Operator || base.IsAccessor; TypeSpec IInterfaceMemberSpec.MemberType => returnType; public AParametersCollection Parameters => parameters; public TypeSpec ReturnType => returnType; public TypeSpec[] TypeArguments => targs; public MethodSpec(MemberKind kind, TypeSpec declaringType, IMethodDefinition details, TypeSpec returnType, AParametersCollection parameters, Modifiers modifiers) : base(kind, declaringType, details, modifiers) { this.parameters = parameters; this.returnType = returnType; } public MethodSpec GetGenericMethodDefinition() { if (!base.IsGeneric && !base.DeclaringType.IsGeneric) { return this; } return MemberCache.GetMember(declaringType, this); } public MethodBase GetMetaInfo() { if ((object)inflatedMetaInfo == null) { if ((state & StateFlags.PendingMetaInflate) != 0) { Type metaInfo = base.DeclaringType.GetMetaInfo(); if (base.DeclaringType.IsTypeBuilder) { if (IsConstructor) { inflatedMetaInfo = TypeBuilder.GetConstructor(metaInfo, (ConstructorInfo)MemberDefinition.Metadata); } else { inflatedMetaInfo = TypeBuilder.GetMethod(metaInfo, (MethodInfo)MemberDefinition.Metadata); } } else { inflatedMetaInfo = MethodBase.GetMethodFromHandle(MemberDefinition.Metadata.MethodHandle, metaInfo.TypeHandle); } state &= ~StateFlags.PendingMetaInflate; } else { inflatedMetaInfo = MemberDefinition.Metadata; } } if ((state & StateFlags.PendingMakeMethod) != 0) { Type[] array = new Type[targs.Length]; for (int i = 0; i < array.Length; i++) { array[i] = targs[i].GetMetaInfo(); } inflatedMetaInfo = ((MethodInfo)inflatedMetaInfo).MakeGenericMethod(array); state &= ~StateFlags.PendingMakeMethod; } return inflatedMetaInfo; } public override string GetSignatureForDocumentation() { string text = string.Concat(str2: Kind switch { MemberKind.Constructor => "#ctor", MemberKind.Method => (Arity <= 0) ? Name : (Name + "``" + Arity), _ => Name, }, str0: base.DeclaringType.GetSignatureForDocumentation(), str1: ".", str3: parameters.GetSignatureForDocumentation()); if (Kind == MemberKind.Operator) { Operator.OpType value = Operator.GetType(Name).Value; if (value == Operator.OpType.Explicit || value == Operator.OpType.Implicit) { text = text + "~" + ReturnType.GetSignatureForDocumentation(); } } return text; } public override string GetSignatureForError() { string text; if (IsConstructor) { text = base.DeclaringType.GetSignatureForError() + "." + base.DeclaringType.Name; } else if (Kind == MemberKind.Operator) { Operator.OpType value = Operator.GetType(Name).Value; text = ((value != Operator.OpType.Implicit && value != Operator.OpType.Explicit) ? (base.DeclaringType.GetSignatureForError() + ".operator " + Operator.GetName(value)) : (base.DeclaringType.GetSignatureForError() + "." + Operator.GetName(value) + " operator " + returnType.GetSignatureForError())); } else { if (base.IsAccessor) { int num = Name.IndexOf('_'); text = Name.Substring(num + 1); string text2 = Name.Substring(0, num); if (num == 3) { int count = parameters.Count; if (count > 0 && text2 == "get") { text = "this" + parameters.GetSignatureForError("[", "]", count); } else if (count > 1 && text2 == "set") { text = "this" + parameters.GetSignatureForError("[", "]", count - 1); } } return base.DeclaringType.GetSignatureForError() + "." + text + "." + text2; } text = base.GetSignatureForError(); if (targs != null) { text = text + "<" + TypeManager.CSharpName(targs) + ">"; } else if (base.IsGeneric) { text = text + "<" + TypeManager.CSharpName(GenericDefinition.TypeParameters) + ">"; } } return text + parameters.GetSignatureForError(); } public override MemberSpec InflateMember(TypeParameterInflator inflator) { MethodSpec methodSpec = (MethodSpec)base.InflateMember(inflator); methodSpec.inflatedMetaInfo = null; methodSpec.returnType = inflator.Inflate(returnType); methodSpec.parameters = parameters.Inflate(inflator); if (base.IsGeneric) { methodSpec.constraints = TypeParameterSpec.InflateConstraints(inflator, Constraints); } return methodSpec; } public MethodSpec MakeGenericMethod(IMemberContext context, params TypeSpec[] targs) { if (targs == null) { throw new ArgumentNullException(); } TypeParameterInflator inflator = new TypeParameterInflator(context, base.DeclaringType, GenericDefinition.TypeParameters, targs); MethodSpec methodSpec = (MethodSpec)MemberwiseClone(); methodSpec.declaringType = inflator.TypeInstance; methodSpec.returnType = inflator.Inflate(returnType); methodSpec.parameters = parameters.Inflate(inflator); methodSpec.targs = targs; methodSpec.constraints = TypeParameterSpec.InflateConstraints(inflator, constraints ?? GenericDefinition.TypeParameters); methodSpec.state |= StateFlags.PendingMakeMethod; return methodSpec; } public MethodSpec Mutate(TypeParameterMutator mutator) { TypeSpec[] array = TypeArguments; if (array != null) { array = mutator.Mutate(array); } TypeSpec typeSpec = base.DeclaringType; if (base.DeclaringType.IsGenericOrParentIsGeneric) { typeSpec = mutator.Mutate(typeSpec); } if (array == TypeArguments && typeSpec == base.DeclaringType) { return this; } MethodSpec methodSpec = (MethodSpec)MemberwiseClone(); if (typeSpec != base.DeclaringType) { methodSpec.inflatedMetaInfo = null; methodSpec.declaringType = typeSpec; methodSpec.state |= StateFlags.PendingMetaInflate; } if (array != null) { methodSpec.targs = array; methodSpec.state |= StateFlags.PendingMakeMethod; } return methodSpec; } public override List ResolveMissingDependencies(MemberSpec caller) { List list = returnType.ResolveMissingDependencies(this); TypeSpec[] types = parameters.Types; foreach (TypeSpec typeSpec in types) { List missingDependencies = typeSpec.GetMissingDependencies(this); if (missingDependencies != null) { if (list == null) { list = new List(); } list.AddRange(missingDependencies); } } if (Arity > 0) { TypeParameterSpec[] typeParameters = GenericDefinition.TypeParameters; foreach (TypeParameterSpec typeParameterSpec in typeParameters) { List missingDependencies2 = typeParameterSpec.GetMissingDependencies(this); if (missingDependencies2 != null) { if (list == null) { list = new List(); } list.AddRange(missingDependencies2); } } } return list; } } internal abstract class MethodOrOperator : MethodCore, IMethodData, IMemberContext, IModuleContext, IMethodDefinition, IMemberDefinition { private ReturnParameter return_attributes; private Dictionary declarative_security; protected MethodData MethodData; private static readonly string[] attribute_targets = new string[2] { "method", "return" }; public override AttributeTargets AttributeTargets => AttributeTargets.Method; MethodBase IMethodDefinition.Metadata => MethodData.MethodBuilder; public MethodBuilder MethodBuilder => MethodData.MethodBuilder; public bool IsPartialDefinition => (base.ModFlags & Modifiers.PARTIAL) != 0 && base.Block == null; public bool IsPartialImplementation => (base.ModFlags & Modifiers.PARTIAL) != 0 && base.Block != null; public override string[] ValidAttributeTargets => attribute_targets; bool IMethodData.IsAccessor => false; public TypeSpec ReturnType => base.MemberType; public MemberName MethodName => base.MemberName; protected MethodOrOperator(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs, ParametersCompiled parameters) : base(parent, type, mod, allowed_mod, name, attrs, parameters) { } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.ReturnValue) { CreateReturnBuilder().ApplyAttributeBuilder(a, ctor, cdata, pa); return; } if (a.Type == pa.MethodImpl) { if ((base.ModFlags & Modifiers.ASYNC) != 0 && (a.GetMethodImplOptions() & MethodImplOptions.Synchronized) != 0) { base.Report.Error(4015, a.Location, "`{0}': Async methods cannot use `MethodImplOptions.Synchronized'", GetSignatureForError()); } is_external_implementation = a.IsInternalCall(); } else if (a.Type == pa.DllImport) { if ((base.ModFlags & (Modifiers.STATIC | Modifiers.EXTERN)) != (Modifiers.STATIC | Modifiers.EXTERN)) { base.Report.Error(601, a.Location, "The DllImport attribute must be specified on a method marked `static' and `extern'"); } if (base.MemberName.IsGeneric || Parent.IsGenericOrParentIsGeneric) { base.Report.Error(7042, a.Location, "The DllImport attribute cannot be applied to a method that is generic or contained in a generic type"); } is_external_implementation = true; } if (a.IsValidSecurityAttribute()) { a.ExtractSecurityPermissionSet(ctor, ref declarative_security); } else if ((object)MethodBuilder != null) { MethodBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } } protected override bool CheckForDuplications() { return Parent.MemberCache.CheckExistingMembersOverloads(this, parameters); } public virtual EmitContext CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod) { return new EmitContext(this, ig, base.MemberType, sourceMethod); } private ReturnParameter CreateReturnBuilder() { return return_attributes ?? (return_attributes = new ReturnParameter(this, MethodBuilder, base.Location)); } public override bool Define() { if (!base.Define()) { return false; } if (!CheckBase()) { return false; } MemberKind kind = ((this is Operator) ? MemberKind.Operator : ((!(this is Destructor)) ? MemberKind.Method : MemberKind.Destructor)); string exlicitName; if (IsPartialDefinition) { caching_flags &= ~Flags.Excluded_Undetected; caching_flags |= Flags.Excluded; if ((caching_flags & Flags.PartialDefinitionExists) != 0) { return true; } if (IsExplicitImpl) { return true; } exlicitName = null; } else { MethodData = new MethodData(this, base.ModFlags, flags, this); if (!MethodData.Define(Parent.PartialContainer, GetFullName(base.MemberName))) { return false; } exlicitName = MethodData.MetadataName; } spec = new MethodSpec(kind, Parent.Definition, this, ReturnType, parameters, base.ModFlags); if (base.MemberName.Arity > 0) { spec.IsGeneric = true; } Parent.MemberCache.AddMember(this, exlicitName, spec); return true; } protected override void DoMemberTypeIndependentChecks() { base.DoMemberTypeIndependentChecks(); CheckAbstractAndExtern(block != null); if ((base.ModFlags & Modifiers.PARTIAL) == 0) { return; } for (int i = 0; i < parameters.Count; i++) { IParameterData parameterData = parameters.FixedParameters[i]; if ((parameterData.ModFlags & Parameter.Modifier.OUT) != Parameter.Modifier.NONE) { base.Report.Error(752, base.Location, "`{0}': A partial method parameters cannot use `out' modifier", GetSignatureForError()); } if (parameterData.HasDefaultValue && IsPartialImplementation) { ((Parameter)parameterData).Warning_UselessOptionalParameter(base.Report); } } } protected override void DoMemberTypeDependentChecks() { base.DoMemberTypeDependentChecks(); if (base.MemberType.IsStatic) { Error_StaticReturnType(); } if (base.MemberType.IsSpecialRuntimeType && Compiler.Settings.StdLib) { Error_ReturnTypeCantBeRefAny(base.Location, ReturnType, base.Report); } } public override void Emit() { if ((base.ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) { Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(MethodBuilder); } if ((base.ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) { Module.PredefinedAttributes.DebuggerHidden.EmitAttribute(MethodBuilder); } if ((base.ModFlags & Modifiers.DEBUGGER_STEP_THROUGH) != 0) { Module.PredefinedAttributes.DebuggerStepThrough.EmitAttribute(MethodBuilder); } if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder); } else if (ReturnType.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder, ReturnType, base.Location); } else if (ReturnType is ReadOnlyReferenceContainer) { Module.PredefinedAttributes.IsReadOnly.EmitAttribute(CreateReturnBuilder().Builder); } if (ReturnType.HasNamedTupleElement) { Module.PredefinedAttributes.TupleElementNames.EmitAttribute(CreateReturnBuilder().Builder, ReturnType, base.Location); } if (base.OptAttributes != null) { base.OptAttributes.Emit(); } if (type_expr != null && !base.IsCompilerGenerated) { ConstraintChecker.Check(this, member_type, type_expr.Location); } base.Emit(); if (MethodData != null) { MethodData.Emit(Parent); } if (block != null && block.StateMachine is AsyncTaskStorey) { PredefinedStateMachineAttribute asyncStateMachine = Module.PredefinedAttributes.AsyncStateMachine; asyncStateMachine.EmitAttribute(MethodBuilder, block.StateMachine); } if ((base.ModFlags & Modifiers.PARTIAL) == 0) { base.Block = null; } } protected void Error_ConditionalAttributeIsNotValid() { base.Report.Error(577, base.Location, "Conditional not valid on `{0}' because it is a constructor, destructor, operator or explicit interface implementation", GetSignatureForError()); } public static void Error_ReturnTypeCantBeRefAny(Location loc, TypeSpec t, Report Report) { Report.Error(1599, loc, "The return type of `{0}' is not allowed", t.GetSignatureForError()); } public override string[] ConditionalConditions() { if ((caching_flags & (Flags.Excluded_Undetected | Flags.Excluded)) == 0) { return null; } if ((base.ModFlags & Modifiers.PARTIAL) != 0 && (caching_flags & Flags.Excluded) != 0) { return new string[0]; } caching_flags &= ~Flags.Excluded_Undetected; string[] array2; if (base_method == null) { if (base.OptAttributes == null) { return null; } Attribute[] array = base.OptAttributes.SearchMulti(Module.PredefinedAttributes.Conditional); if (array == null) { return null; } array2 = new string[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i].GetConditionalAttributeValue(); } } else { array2 = base_method.MemberDefinition.ConditionalConditions(); } if (array2 != null) { caching_flags |= Flags.Excluded; } return array2; } public override void PrepareEmit() { base.PrepareEmit(); MethodBuilder methodBuilder = MethodData.DefineMethodBuilder(Parent); if (CurrentTypeParameters != null) { string[] array = new string[CurrentTypeParameters.Count]; for (int i = 0; i < array.Length; i++) { array[i] = CurrentTypeParameters[i].Name; } GenericTypeParameterBuilder[] array2 = MethodBuilder.DefineGenericParameters(array); for (int j = 0; j < CurrentTypeParameters.Count; j++) { TypeParameter typeParameter = CurrentTypeParameters[j]; typeParameter.Define(array2[j]); } } methodBuilder.SetParameters(parameters.GetMetaInfo()); methodBuilder.SetReturnType(ReturnType.GetMetaInfo()); } public override void WriteDebugSymbol(MonoSymbolFile file) { if (MethodData != null && !IsPartialDefinition) { MethodData.WriteDebugSymbol(file); } } } internal class Method : MethodOrOperator, IGenericMethodDefinition, IMethodDefinition, IMemberDefinition { private Method partialMethodImplementation; public override TypeParameters CurrentTypeParameters => base.MemberName.TypeParameters; public TypeParameterSpec[] TypeParameters => CurrentTypeParameters.Types; public int TypeParametersCount => (CurrentTypeParameters != null) ? CurrentTypeParameters.Count : 0; public Method(TypeDefinition parent, FullNamedExpression return_type, Modifiers mod, MemberName name, ParametersCompiled parameters, Attributes attrs) : base(parent, return_type, mod, (parent.PartialContainer.Kind == MemberKind.Interface) ? (Modifiers.NEW | Modifiers.UNSAFE) : ((parent.PartialContainer.Kind == MemberKind.Struct) ? (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.STATIC | Modifiers.OVERRIDE | Modifiers.ASYNC) : (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.VIRTUAL | Modifiers.OVERRIDE | Modifiers.ASYNC)), name, attrs, parameters) { } protected Method(TypeDefinition parent, FullNamedExpression return_type, Modifiers mod, Modifiers amod, MemberName name, ParametersCompiled parameters, Attributes attrs) : base(parent, return_type, mod, amod, name, attrs, parameters) { } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public static Method Create(TypeDefinition parent, FullNamedExpression returnType, Modifiers mod, MemberName name, ParametersCompiled parameters, Attributes attrs) { Method method = new Method(parent, returnType, mod, name, parameters, attrs); if ((mod & Modifiers.PARTIAL) != 0) { if ((mod & (Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.VIRTUAL | Modifiers.OVERRIDE | Modifiers.EXTERN)) != 0) { method.Report.Error(750, method.Location, "A partial method cannot define access modifier or any of abstract, extern, new, override, sealed, or virtual modifiers"); mod &= ~(Modifiers.AccessibilityMask | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.VIRTUAL | Modifiers.OVERRIDE | Modifiers.EXTERN); } if ((parent.ModFlags & Modifiers.PARTIAL) == 0) { method.Report.Error(751, method.Location, "A partial method must be declared within a partial class or partial struct"); } } if ((mod & Modifiers.STATIC) == 0 && parameters.HasExtensionMethodType) { method.Report.Error(1105, method.Location, "`{0}': Extension methods must be declared static", method.GetSignatureForError()); } return method; } public override string GetSignatureForError() { return base.GetSignatureForError() + parameters.GetSignatureForError(); } private void Error_DuplicateEntryPoint(Method b) { base.Report.Error(17, b.Location, "Program `{0}' has more than one entry point defined: `{1}'", b.Module.Builder.ScopeName, b.GetSignatureForError()); } private bool IsEntryPoint() { if (base.ReturnType.Kind != MemberKind.Void && base.ReturnType.BuiltinType != BuiltinTypeSpec.Type.Int) { return false; } if (parameters.IsEmpty) { return true; } if (parameters.Count > 1) { return false; } return parameters.Types[0] is ArrayContainer { Rank: 1 } arrayContainer && arrayContainer.Element.BuiltinType == BuiltinTypeSpec.Type.String && (parameters[0].ModFlags & Parameter.Modifier.RefOutMask) == 0; } public override FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { if (arity == 0) { TypeParameters currentTypeParameters = CurrentTypeParameters; if (currentTypeParameters != null) { TypeParameter typeParameter = currentTypeParameters.Find(name); if (typeParameter != null) { return new TypeParameterExpr(typeParameter, loc); } } } return base.LookupNamespaceOrType(name, arity, mode, loc); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.Conditional) { if (IsExplicitImpl) { Error_ConditionalAttributeIsNotValid(); return; } if ((base.ModFlags & Modifiers.OVERRIDE) != 0) { base.Report.Error(243, base.Location, "Conditional not valid on `{0}' because it is an override method", GetSignatureForError()); return; } if (base.ReturnType.Kind != MemberKind.Void) { base.Report.Error(578, base.Location, "Conditional not valid on `{0}' because its return type is not void", GetSignatureForError()); return; } if (IsInterface) { base.Report.Error(582, base.Location, "Conditional not valid on interface members"); return; } if (MethodData.implementing != null) { base.Report.SymbolRelatedToPreviousError(MethodData.implementing.DeclaringType); base.Report.Error(629, base.Location, "Conditional member `{0}' cannot implement interface member `{1}'", GetSignatureForError(), TypeManager.CSharpSignature(MethodData.implementing)); return; } for (int i = 0; i < parameters.Count; i++) { if ((parameters.FixedParameters[i].ModFlags & Parameter.Modifier.OUT) != Parameter.Modifier.NONE) { base.Report.Error(685, base.Location, "Conditional method `{0}' cannot have an out parameter", GetSignatureForError()); return; } } } if (a.Type == pa.Extension) { a.Error_MisusedExtensionAttribute(); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } private void CreateTypeParameters() { TypeParameters typeParameters = base.MemberName.TypeParameters; TypeParameters typeParametersAll = Parent.TypeParametersAll; for (int i = 0; i < base.MemberName.Arity; i++) { string name = typeParameters[i].MemberName.Name; if (block == null) { int parameterIndexByName = parameters.GetParameterIndexByName(name); if (parameterIndexByName >= 0) { ToplevelBlock toplevelBlock = block; if (toplevelBlock == null) { toplevelBlock = new ToplevelBlock(Compiler, base.Location); } toplevelBlock.Error_AlreadyDeclaredTypeParameter(name, parameters[i].Location); } } else { INamedBlockVariable variable = null; block.GetLocalName(name, block, ref variable); variable?.Block.Error_AlreadyDeclaredTypeParameter(name, variable.Location); } if (typeParametersAll != null) { TypeParameter typeParameter = typeParametersAll.Find(name); if (typeParameter != null) { typeParameters[i].WarningParentNameConflict(typeParameter); } } } typeParameters.Create(null, 0, Parent); } protected virtual void DefineTypeParameters() { TypeParameters currentTypeParameters = CurrentTypeParameters; TypeParameterSpec[] array = null; TypeParameterSpec[] array2 = TypeParameterSpec.EmptyTypes; TypeSpec[] array3 = TypeSpec.EmptyTypes; if ((base.ModFlags & Modifiers.OVERRIDE) != 0 || IsExplicitImpl) { MethodSpec methodSpec = base_method ?? MethodData.implementing; if (methodSpec != null) { array = methodSpec.GenericDefinition.TypeParameters; if (methodSpec.DeclaringType.IsGeneric) { array2 = methodSpec.DeclaringType.MemberDefinition.TypeParameters; if (base_method != null) { TypeSpec typeSpec = CurrentType; while (typeSpec.BaseType != methodSpec.DeclaringType) { typeSpec = typeSpec.BaseType; } array3 = typeSpec.BaseType.TypeArguments; } else { foreach (TypeSpec @interface in Parent.CurrentType.Interfaces) { if (@interface == methodSpec.DeclaringType) { array3 = @interface.TypeArguments; break; } } } } if (methodSpec.IsGeneric) { TypeParameterSpec[] array4 = array; foreach (TypeParameterSpec typeParameterSpec in array4) { typeParameterSpec.BaseType.CheckObsoleteness(this, base.Location); if (typeParameterSpec.InterfacesDefined != null) { TypeSpec[] interfacesDefined = typeParameterSpec.InterfacesDefined; foreach (TypeSpec typeSpec2 in interfacesDefined) { typeSpec2.CheckObsoleteness(this, base.Location); } } } if (array2.Length != 0) { array2 = array2.Concat(array).ToArray(); array3 = array3.Concat(currentTypeParameters.Types).ToArray(); } else { array2 = array; TypeSpec[] types = currentTypeParameters.Types; array3 = types; } } } } for (int k = 0; k < currentTypeParameters.Count; k++) { TypeParameter typeParameter = currentTypeParameters[k]; if (array == null) { typeParameter.ResolveConstraints(this); continue; } TypeParameterSpec typeParameterSpec2 = array[k]; TypeParameterSpec type = typeParameter.Type; type.SpecialConstraint = typeParameterSpec2.SpecialConstraint; TypeParameterInflator inflator = new TypeParameterInflator(this, CurrentType, array2, array3); typeParameterSpec2.InflateConstraints(inflator, type); TypeSpec[] array5 = type.TypeArguments; if (array5 == null) { continue; } for (int l = 0; l < array5.Length; l++) { TypeSpec typeSpec3 = array5[l]; if (!typeSpec3.IsClass && !typeSpec3.IsStruct) { continue; } TypeSpec[] array6 = null; for (int m = l + 1; m < array5.Length; m++) { TypeSpec typeSpec4 = array5[m]; if (TypeSpecComparer.IsEqual(typeSpec3, typeSpec4) || TypeSpec.IsBaseClass(typeSpec3, typeSpec4, dynamicIsObject: false)) { array6 = new TypeSpec[array5.Length - 1]; Array.Copy(array5, 0, array6, 0, m); Array.Copy(array5, m + 1, array6, m, array5.Length - m - 1); } else if (!TypeSpec.IsBaseClass(typeSpec4, typeSpec3, dynamicIsObject: false)) { Constraints.Error_ConflictingConstraints(this, type, typeSpec3, typeSpec4, base.Location); } } if (array6 != null) { array5 = (type.TypeArguments = array6); } else { Constraints.CheckConflictingInheritedConstraint(type, typeSpec3, this, base.Location); } } } if (array == null && MethodData != null && MethodData.implementing != null) { CheckImplementingMethodConstraints(Parent, spec, MethodData.implementing); } } public static bool CheckImplementingMethodConstraints(TypeContainer container, MethodSpec method, MethodSpec baseMethod) { TypeParameterSpec[] constraints = method.Constraints; TypeParameterSpec[] constraints2 = baseMethod.Constraints; for (int i = 0; i < constraints.Length; i++) { if (!constraints[i].HasSameConstraintsImplementation(constraints2[i])) { container.Compiler.Report.SymbolRelatedToPreviousError(method); container.Compiler.Report.SymbolRelatedToPreviousError(baseMethod); MemberCore memberCore = (constraints[i].MemberDefinition as MemberCore) ?? container; container.Compiler.Report.Error(425, memberCore.Location, "The constraints for type parameter `{0}' of method `{1}' must match the constraints for type parameter `{2}' of interface method `{3}'. Consider using an explicit interface implementation instead", constraints[i].GetSignatureForError(), method.GetSignatureForError(), constraints2[i].GetSignatureForError(), baseMethod.GetSignatureForError()); return false; } } return true; } public override bool Define() { if (!base.Define()) { return false; } if (member_type.Kind == MemberKind.Void && parameters.IsEmpty && base.MemberName.Arity == 0 && base.MemberName.Name == Destructor.MetadataName) { base.Report.Warning(465, 1, base.Location, "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?"); } if (CurrentTypeParameters == null) { if (base_method != null && !IsExplicitImpl) { if (parameters.Count == 1 && base.ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && base.MemberName.Name == "Equals") { Parent.PartialContainer.Mark_HasEquals(); } else if (parameters.IsEmpty && base.MemberName.Name == "GetHashCode") { Parent.PartialContainer.Mark_HasGetHashCode(); } } } else { DefineTypeParameters(); } if (block != null) { if (block.IsIterator) { Iterator.CreateIterator(this, Parent.PartialContainer, base.ModFlags); base.ModFlags |= Modifiers.DEBUGGER_HIDDEN; } if ((base.ModFlags & Modifiers.ASYNC) != 0) { if (base.ReturnType.Kind != MemberKind.Void && base.ReturnType != Module.PredefinedTypes.Task.TypeSpec && !base.ReturnType.IsGenericTask && !base.ReturnType.IsCustomTaskType()) { base.Report.Error(1983, base.Location, "The return type of an async method must be void or task type"); } block = (ToplevelBlock)block.ConvertToAsyncTask(this, Parent.PartialContainer, parameters, base.ReturnType, null, base.Location); base.ModFlags |= Modifiers.DEBUGGER_STEP_THROUGH; } if (Compiler.Settings.WriteMetadataOnly) { block = null; } } if ((base.ModFlags & Modifiers.STATIC) == 0) { return true; } if (parameters.HasExtensionMethodType) { if (Parent.PartialContainer.IsStatic && !Parent.IsGenericOrParentIsGeneric) { if (!Parent.IsTopLevel) { base.Report.Error(1109, base.Location, "`{0}': Extension methods cannot be defined in a nested class", GetSignatureForError()); } PredefinedAttribute extension = Module.PredefinedAttributes.Extension; if (!extension.IsDefined) { base.Report.Error(1110, base.Location, "`{0}': Extension methods require `System.Runtime.CompilerServices.ExtensionAttribute' type to be available. Are you missing an assembly reference?", GetSignatureForError()); } base.ModFlags |= Modifiers.METHOD_EXTENSION; Parent.PartialContainer.ModFlags |= Modifiers.METHOD_EXTENSION; base.Spec.DeclaringType.SetExtensionMethodContainer(); Parent.Module.HasExtensionMethod = true; } else { base.Report.Error(1106, base.Location, "`{0}': Extension methods must be defined in a non-generic static class", GetSignatureForError()); } } CompilerSettings settings = Compiler.Settings; if (settings.NeedsEntryPoint && base.MemberName.Name == "Main" && !base.IsPartialDefinition && (settings.MainClass == null || settings.MainClass == Parent.TypeBuilder.FullName)) { if (IsEntryPoint()) { if (Parent.DeclaringAssembly.EntryPoint == null) { if (Parent.IsGenericOrParentIsGeneric || base.MemberName.IsGeneric) { base.Report.Warning(402, 4, base.Location, "`{0}': an entry point cannot be generic or in a generic type", GetSignatureForError()); } else if ((base.ModFlags & Modifiers.ASYNC) != 0) { base.Report.Error(4009, base.Location, "`{0}': an entry point cannot be async method", GetSignatureForError()); } else { SetIsUsed(); Parent.DeclaringAssembly.EntryPoint = this; } } else { Error_DuplicateEntryPoint(Parent.DeclaringAssembly.EntryPoint); Error_DuplicateEntryPoint(this); } } else { base.Report.Warning(28, 4, base.Location, "`{0}' has the wrong signature to be an entry point", GetSignatureForError()); } } return true; } public override void PrepareEmit() { if (base.IsPartialDefinition) { if (partialMethodImplementation != null) { MethodData = partialMethodImplementation.MethodData; } } else { base.PrepareEmit(); } } public override void Emit() { try { if (base.IsPartialDefinition) { if (partialMethodImplementation != null && CurrentTypeParameters != null) { CurrentTypeParameters.CheckPartialConstraints(partialMethodImplementation); TypeParameters currentTypeParameters = partialMethodImplementation.CurrentTypeParameters; for (int i = 0; i < CurrentTypeParameters.Count; i++) { TypeParameter typeParameter = CurrentTypeParameters[i]; typeParameter.Define(currentTypeParameters[i]); } } return; } if ((base.ModFlags & Modifiers.PARTIAL) != 0 && (caching_flags & Flags.PartialDefinitionExists) == 0) { base.Report.Error(759, base.Location, "A partial method `{0}' implementation is missing a partial method declaration", GetSignatureForError()); } if (CurrentTypeParameters != null) { for (int j = 0; j < CurrentTypeParameters.Count; j++) { TypeParameter typeParameter2 = CurrentTypeParameters[j]; typeParameter2.CheckGenericConstraints(obsoleteCheck: false); typeParameter2.Emit(); } } if ((base.ModFlags & Modifiers.METHOD_EXTENSION) != 0) { Module.PredefinedAttributes.Extension.EmitAttribute(base.MethodBuilder); } base.Emit(); } catch (Exception e) { throw new InternalErrorException(this, e); } } public override bool EnableOverloadChecks(MemberCore overload) { if (overload is Indexer) { return false; } return base.EnableOverloadChecks(overload); } protected override bool ResolveMemberType() { if (CurrentTypeParameters != null) { CreateTypeParameters(); } return base.ResolveMemberType(); } public void SetPartialDefinition(Method methodDefinition) { caching_flags |= Flags.PartialDefinitionExists; methodDefinition.partialMethodImplementation = this; for (int i = 0; i < methodDefinition.parameters.Count; i++) { Parameter parameter = methodDefinition.parameters[i]; Parameter parameter2 = parameters[i]; parameter2.Name = parameter.Name; parameter2.DefaultValue = parameter.DefaultValue; if (parameter.OptAttributes != null) { Attributes.AttachFromPartial(parameter2, parameter); } } if (methodDefinition.attributes != null) { if (attributes == null) { attributes = methodDefinition.attributes; } else { attributes.Attrs.AddRange(methodDefinition.attributes.Attrs); } } if (CurrentTypeParameters == null) { return; } for (int j = 0; j < CurrentTypeParameters.Count; j++) { TypeParameter typeParameter = methodDefinition.CurrentTypeParameters[j]; if (typeParameter.OptAttributes != null) { TypeParameter typeParameter2 = CurrentTypeParameters[j]; if (typeParameter2.OptAttributes == null) { typeParameter2.OptAttributes = typeParameter.OptAttributes; } else { typeParameter2.OptAttributes.Attrs.AddRange(typeParameter2.OptAttributes.Attrs); } } } } } internal abstract class ConstructorInitializer : ExpressionStatement { private Arguments argument_list; private MethodSpec base_ctor; public Arguments Arguments => argument_list; protected ConstructorInitializer(Arguments argument_list, Location loc) { this.argument_list = argument_list; base.loc = loc; } public override bool ContainsEmitWithAwait() { throw new NotSupportedException(); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException("ET"); } protected override Expression DoResolve(ResolveContext ec) { eclass = ExprClass.Value; Constructor constructor = (Constructor)ec.MemberContext; using (ec.Set(ResolveContext.Options.BaseInitializer)) { if (argument_list != null) { argument_list.Resolve(ec, out var dynamic); if (dynamic) { ec.Report.Error(1975, loc, "The constructor call cannot be dynamically dispatched within constructor initializer"); return null; } } type = ec.CurrentType; if (this is ConstructorBaseInitializer) { if (ec.CurrentType.BaseType == null) { return this; } type = ec.CurrentType.BaseType; if (ec.CurrentType.IsStruct) { ec.Report.Error(522, loc, "`{0}': Struct constructors cannot call base constructors", constructor.GetSignatureForError()); return this; } } base_ctor = Expression.ConstructorLookup(ec, type, ref argument_list, loc); } if (base_ctor != null && base_ctor.MemberDefinition == constructor.Spec.MemberDefinition) { ec.Report.Error(516, loc, "Constructor `{0}' cannot call itself", constructor.GetSignatureForError()); } return this; } public override void Emit(EmitContext ec) { if (base_ctor == null) { if (type != ec.BuiltinTypes.Object) { ec.Emit(OpCodes.Ldarg_0); ec.Emit(OpCodes.Initobj, type); } } else { CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = new CompilerGeneratedThis(type, loc); callEmitter.EmitPredefined(ec, base_ctor, argument_list); } } public override void EmitStatement(EmitContext ec) { Emit(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { if (argument_list != null) { argument_list.FlowAnalysis(fc); } } } internal class ConstructorBaseInitializer : ConstructorInitializer { public ConstructorBaseInitializer(Arguments argument_list, Location l) : base(argument_list, l) { } } internal class GeneratedBaseInitializer : ConstructorBaseInitializer { public GeneratedBaseInitializer(Location loc, Arguments arguments) : base(arguments, loc) { } } internal class ConstructorThisInitializer : ConstructorInitializer { public ConstructorThisInitializer(Arguments argument_list, Location l) : base(argument_list, l) { } } internal class Constructor : MethodCore, IMethodData, IMemberContext, IModuleContext, IMethodDefinition, IMemberDefinition { public ConstructorBuilder ConstructorBuilder; public ConstructorInitializer Initializer; private Dictionary declarative_security; private bool has_compliant_args; private SourceMethodBuilder debug_builder; public const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.STATIC; private static readonly string[] attribute_targets = new string[1] { "method" }; public static readonly string ConstructorName = ".ctor"; public static readonly string TypeConstructorName = ".cctor"; public bool HasCompliantArgs => has_compliant_args; public override AttributeTargets AttributeTargets => AttributeTargets.Constructor; bool IMethodData.IsAccessor => false; public bool IsPrimaryConstructor { get; set; } MethodBase IMethodDefinition.Metadata => ConstructorBuilder; public override string[] ValidAttributeTargets => attribute_targets; public MemberName MethodName => base.MemberName; public TypeSpec ReturnType => base.MemberType; public Constructor(TypeDefinition parent, string name, Modifiers mod, Attributes attrs, ParametersCompiled args, Location loc) : base(parent, null, mod, Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.STATIC, new MemberName(name, loc), attrs, args) { } public bool IsDefault() { if ((base.ModFlags & Modifiers.STATIC) != 0) { return parameters.IsEmpty; } return parameters.IsEmpty && Initializer is ConstructorBaseInitializer && Initializer.Arguments == null; } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.IsValidSecurityAttribute()) { a.ExtractSecurityPermissionSet(ctor, ref declarative_security); return; } if (a.Type == pa.MethodImpl) { is_external_implementation = a.IsInternalCall(); } ConstructorBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } protected override bool CheckBase() { if ((base.ModFlags & Modifiers.STATIC) != 0) { if ((caching_flags & Flags.MethodOverloadsExist) != 0) { Parent.MemberCache.CheckExistingMembersOverloads(this, parameters); } return true; } if (!DefineParameters(parameters)) { return false; } if ((caching_flags & Flags.MethodOverloadsExist) != 0) { Parent.MemberCache.CheckExistingMembersOverloads(this, parameters); } CheckProtectedModifier(); return true; } public override bool Define() { if ((object)ConstructorBuilder != null) { return true; } if (!CheckAbstractAndExtern(block != null)) { return false; } if (!CheckBase()) { return false; } if (Parent.PrimaryConstructorParameters != null && !IsPrimaryConstructor && !base.IsStatic) { if (Parent.Kind == MemberKind.Struct && Initializer is ConstructorThisInitializer && Initializer.Arguments == null) { base.Report.Error(8043, base.Location, "`{0}': Structs with primary constructor cannot specify default constructor initializer", GetSignatureForError()); } else if (Initializer == null || Initializer is ConstructorBaseInitializer) { base.Report.Error(8037, base.Location, "`{0}': Instance constructor of type with primary constructor must specify `this' constructor initializer", GetSignatureForError()); } } if ((base.ModFlags & Modifiers.EXTERN) != 0 && Initializer != null) { base.Report.Error(8091, base.Location, "`{0}': Contructors cannot be extern and have a constructor initializer", GetSignatureForError()); } MethodAttributes methodAttributes = ModifiersExtensions.MethodAttr(base.ModFlags) | MethodAttributes.RTSpecialName | MethodAttributes.SpecialName; ConstructorBuilder = Parent.TypeBuilder.DefineConstructor(methodAttributes, base.CallingConventions, parameters.GetMetaInfo()); spec = new MethodSpec(MemberKind.Constructor, Parent.Definition, this, Compiler.BuiltinTypes.Void, parameters, base.ModFlags); Parent.MemberCache.AddMember(spec); if (block != null) { if (block.IsIterator) { member_type = Compiler.BuiltinTypes.Void; Iterator.CreateIterator(this, Parent.PartialContainer, base.ModFlags); } if (Compiler.Settings.WriteMetadataOnly) { block = null; } } return true; } public override void Emit() { if (Parent.PartialContainer.IsComImport) { if (!IsDefault()) { base.Report.Error(669, base.Location, "`{0}': A class with the ComImport attribute cannot have a user-defined constructor", Parent.GetSignatureForError()); } ConstructorBuilder.SetImplementationFlags(MethodImplAttributes.InternalCall); block = null; } if ((base.ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) { Module.PredefinedAttributes.DebuggerHidden.EmitAttribute(ConstructorBuilder); } if (base.OptAttributes != null) { base.OptAttributes.Emit(); } base.Emit(); parameters.ApplyAttributes(this, ConstructorBuilder); BlockContext blockContext = new BlockContext(this, block, Compiler.BuiltinTypes.Void); blockContext.Set(ResolveContext.Options.ConstructorScope); if (block != null) { if (!base.IsStatic && Initializer == null && Parent.PartialContainer.Kind == MemberKind.Struct) { block.AddThisVariable(blockContext); } if (!(Initializer is ConstructorThisInitializer)) { int errors = Compiler.Report.Errors; Parent.PartialContainer.ResolveFieldInitializers(blockContext); if (errors != Compiler.Report.Errors) { return; } } if (!base.IsStatic) { if (Initializer == null && Parent.PartialContainer.Kind == MemberKind.Class) { Initializer = new GeneratedBaseInitializer(base.Location, null); } if (Initializer != null) { block.AddScopeStatement(new StatementExpression(Initializer)); } } if (block.Resolve(blockContext, this)) { debug_builder = Parent.CreateMethodSymbolEntry(); EmitContext emitContext = new EmitContext(this, ConstructorBuilder.GetILGenerator(), blockContext.ReturnType, debug_builder); emitContext.With(BuilderContext.Options.ConstructorScope, enable: true); block.Emit(emitContext); } } block = null; } protected override MemberSpec FindBaseMember(out MemberSpec bestCandidate, ref bool overrides) { bestCandidate = null; return null; } public override string GetCallerMemberName() { return base.IsStatic ? TypeConstructorName : ConstructorName; } public override string GetSignatureForDocumentation() { return Parent.GetSignatureForDocumentation() + ".#ctor" + parameters.GetSignatureForDocumentation(); } public override string GetSignatureForError() { return base.GetSignatureForError() + parameters.GetSignatureForError(); } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance() || !IsExposedFromAssembly()) { return false; } if (!parameters.IsEmpty && Parent.Definition.IsAttribute) { TypeSpec[] types = parameters.Types; foreach (TypeSpec typeSpec in types) { if (typeSpec.IsArray) { return true; } } } has_compliant_args = true; return true; } public override void WriteDebugSymbol(MonoSymbolFile file) { if (debug_builder != null) { int metadataToken = ConstructorBuilder.MetadataToken; debug_builder.DefineMethod(file, metadataToken); } } EmitContext IMethodData.CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod) { throw new NotImplementedException(); } } internal interface IMethodData : IMemberContext, IModuleContext { CallingConventions CallingConventions { get; } Location Location { get; } MemberName MethodName { get; } TypeSpec ReturnType { get; } ParametersCompiled ParameterInfo { get; } MethodSpec Spec { get; } bool IsAccessor { get; } Attributes OptAttributes { get; } ToplevelBlock Block { get; set; } EmitContext CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod); } internal class MethodData { public readonly IMethodData method; public MethodSpec implementing; protected InterfaceMemberBase member; protected Modifiers modifiers; protected MethodAttributes flags; protected TypeSpec declaring_type; private SourceMethodBuilder debug_builder; private string full_name; private MethodBuilder builder; public MethodBuilder MethodBuilder => builder; public TypeSpec DeclaringType => declaring_type; public string MetadataName => full_name; public MethodData(InterfaceMemberBase member, Modifiers modifiers, MethodAttributes flags, IMethodData method) { this.member = member; this.modifiers = modifiers; this.flags = flags; this.method = method; } public bool Define(TypeDefinition container, string method_full_name) { PendingImplementation pendingImplementations = container.PendingImplementations; bool optional = false; MethodSpec ambiguousCandidate; if (pendingImplementations != null) { implementing = pendingImplementations.IsInterfaceMethod(method.MethodName, member.InterfaceType, this, out ambiguousCandidate, ref optional); if (member.InterfaceType != null) { if (implementing == null) { if (member is PropertyBase) { container.Compiler.Report.Error(550, method.Location, "`{0}' is an accessor not found in interface member `{1}{2}'", method.GetSignatureForError(), member.InterfaceType.GetSignatureForError(), member.GetSignatureForError().Substring(member.GetSignatureForError().LastIndexOf('.'))); } else { container.Compiler.Report.Error(539, method.Location, "`{0}.{1}' in explicit interface declaration is not a member of interface", member.InterfaceType.GetSignatureForError(), member.ShortName); } return false; } if (implementing.IsAccessor && !method.IsAccessor) { container.Compiler.Report.SymbolRelatedToPreviousError(implementing); container.Compiler.Report.Error(683, method.Location, "`{0}' explicit method implementation cannot implement `{1}' because it is an accessor", member.GetSignatureForError(), implementing.GetSignatureForError()); return false; } } else if (implementing != null && !optional) { if (!method.IsAccessor) { if (implementing.IsAccessor) { container.Compiler.Report.SymbolRelatedToPreviousError(implementing); container.Compiler.Report.Error(470, method.Location, "Method `{0}' cannot implement interface accessor `{1}'", method.GetSignatureForError(), TypeManager.CSharpSignature(implementing)); } } else if (implementing.DeclaringType.IsInterface) { if (!implementing.IsAccessor) { container.Compiler.Report.SymbolRelatedToPreviousError(implementing); container.Compiler.Report.Error(686, method.Location, "Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use an explicit interface implementation", method.GetSignatureForError(), TypeManager.CSharpSignature(implementing), container.GetSignatureForError()); } else if (method is PropertyBase.PropertyMethod { HasCustomAccessModifier: not false } propertyMethod && (propertyMethod.ModFlags & Modifiers.PUBLIC) == 0) { container.Compiler.Report.SymbolRelatedToPreviousError(implementing); container.Compiler.Report.Error(277, method.Location, "Accessor `{0}' must be declared public to implement interface member `{1}'", method.GetSignatureForError(), implementing.GetSignatureForError()); } } if (!NamedTupleSpec.CheckOverrideName(member.MemberType, implementing.ReturnType)) { container.Compiler.Report.Error(8141, method.Location, "The tuple element names in the signature type of member `{0}' must match the tuple element names of interface member `{1}''", member.GetSignatureForError(), implementing.GetSignatureForError()); } IParametersMember parametersMember = method as IParametersMember; IParametersMember parametersMember2 = implementing; if (parametersMember != null && parametersMember2 != null && !NamedTupleSpec.CheckOverrideName(parametersMember, parametersMember2)) { container.Compiler.Report.Error(8141, method.Location, "The tuple element names in the signature type of member `{0}' must match the tuple element names of interface member `{1}''", member.GetSignatureForError(), implementing.GetSignatureForError()); } } } else { ambiguousCandidate = null; } if (implementing != null) { if (member.IsExplicitImpl) { if (method.ParameterInfo.HasParams && !implementing.Parameters.HasParams) { container.Compiler.Report.SymbolRelatedToPreviousError(implementing); container.Compiler.Report.Error(466, method.Location, "`{0}': the explicit interface implementation cannot introduce the params modifier", method.GetSignatureForError()); } if (ambiguousCandidate != null) { container.Compiler.Report.SymbolRelatedToPreviousError(ambiguousCandidate); container.Compiler.Report.SymbolRelatedToPreviousError(implementing); container.Compiler.Report.Warning(473, 2, method.Location, "Explicit interface implementation `{0}' matches more than one interface member. Consider using a non-explicit implementation instead", method.GetSignatureForError()); } } else if (implementing.DeclaringType.IsInterface) { if ((flags & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) { implementing = null; } else if (optional && (container.Interfaces == null || !container.Definition.Interfaces.Contains(implementing.DeclaringType))) { implementing = null; } } else if ((flags & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { implementing = null; } else if ((modifiers & Modifiers.OVERRIDE) == 0) { implementing = null; } if ((modifiers & Modifiers.STATIC) != 0) { implementing = null; } } if (implementing != null) { if ((modifiers & Modifiers.OVERRIDE) == 0 && implementing.DeclaringType.IsInterface) { flags |= MethodAttributes.VtableLayoutMask; } flags |= MethodAttributes.Virtual | MethodAttributes.HideBySig; if ((modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0) { flags |= MethodAttributes.Final; } pendingImplementations.ImplementMethod(method.MethodName, member.InterfaceType, this, member.IsExplicitImpl, out ambiguousCandidate, ref optional); if (!implementing.DeclaringType.IsInterface && !member.IsExplicitImpl && implementing.IsAccessor) { method_full_name = implementing.MemberDefinition.Name; } } full_name = method_full_name; declaring_type = container.Definition; return true; } private void DefineOverride(TypeDefinition container) { if (implementing != null && member.IsExplicitImpl) { container.TypeBuilder.DefineMethodOverride(builder, (MethodInfo)implementing.GetMetaInfo()); } } public MethodBuilder DefineMethodBuilder(TypeDefinition container) { if ((object)builder != null) { throw new InternalErrorException(); } builder = container.TypeBuilder.DefineMethod(full_name, flags, method.CallingConventions); return builder; } public MethodBuilder DefineMethodBuilder(TypeDefinition container, ParametersCompiled param) { DefineMethodBuilder(container); builder.SetReturnType(method.ReturnType.GetMetaInfo()); builder.SetParameters(param.GetMetaInfo()); return builder; } public void Emit(TypeDefinition parent) { DefineOverride(parent); method.ParameterInfo.ApplyAttributes(method, MethodBuilder); ToplevelBlock block = method.Block; if (block != null) { BlockContext bc = new BlockContext(method, block, method.ReturnType); if (block.Resolve(bc, method)) { debug_builder = member.Parent.CreateMethodSymbolEntry(); EmitContext ec = method.CreateEmitContext(MethodBuilder.GetILGenerator(), debug_builder); block.Emit(ec); } } } public void WriteDebugSymbol(MonoSymbolFile file) { if (debug_builder != null) { int metadataToken = builder.MetadataToken; debug_builder.DefineMethod(file, metadataToken); } } } internal class Destructor : MethodOrOperator { private const Modifiers AllowedModifiers = Modifiers.AllowedExplicitImplFlags; private static readonly string[] attribute_targets = new string[1] { "method" }; public static readonly string MetadataName = "Finalize"; public override string[] ValidAttributeTargets => attribute_targets; public Destructor(TypeDefinition parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l) : base(parent, null, mod, Modifiers.AllowedExplicitImplFlags, new MemberName(MetadataName, l), attrs, parameters) { base.ModFlags &= ~Modifiers.PRIVATE; base.ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE; } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.Conditional) { Error_ConditionalAttributeIsNotValid(); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } protected override bool CheckBase() { if ((caching_flags & Flags.MethodOverloadsExist) != 0) { CheckForDuplications(); } return true; } public override bool Define() { base.Define(); if (Compiler.Settings.WriteMetadataOnly) { block = null; } return true; } public override void Emit() { TypeSpec baseType = Parent.PartialContainer.BaseType; if (baseType != null && base.Block != null) { if (!(MemberCache.FindMember(baseType, new MemberFilter(MetadataName, 0, MemberKind.Destructor, null, null), BindingRestriction.InstanceOnly) is MethodSpec best)) { throw new NotImplementedException(); } MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(best, baseType, base.Location); methodGroupExpr.InstanceExpression = new BaseThis(baseType, base.Location); ExplicitBlock explicitBlock = new ExplicitBlock(block, block.StartLocation, block.EndLocation) { IsCompilerGenerated = true }; ExplicitBlock explicitBlock2 = new ExplicitBlock(block, base.Location, base.Location) { IsCompilerGenerated = true }; explicitBlock2.AddStatement(new StatementExpression(new Invocation(methodGroupExpr, new Arguments(0)), Location.Null)); TryFinally tf = new TryFinally(explicitBlock, explicitBlock2, base.Location); block.WrapIntoDestructor(tf, explicitBlock); } base.Emit(); } public override string GetSignatureForError() { return Parent.GetSignatureForError() + ".~" + Parent.MemberName.Name + "()"; } protected override bool ResolveMemberType() { member_type = Compiler.BuiltinTypes.Void; return true; } } internal abstract class AbstractPropertyEventMethod : MemberCore, IMethodData, IMemberContext, IModuleContext, IMethodDefinition, IMemberDefinition { protected MethodData method_data; protected ToplevelBlock block; protected Dictionary declarative_security; protected readonly string prefix; private ReturnParameter return_attributes; public ToplevelBlock Block { get { return block; } set { block = value; } } public CallingConventions CallingConventions => CallingConventions.Standard; public bool IsAccessor => true; public MemberName MethodName => base.MemberName; public TypeSpec[] ParameterTypes => ParameterInfo.Types; MethodBase IMethodDefinition.Metadata => method_data.MethodBuilder; public abstract ParametersCompiled ParameterInfo { get; } public abstract TypeSpec ReturnType { get; } public MethodSpec Spec { get; protected set; } public override string DocCommentHeader { get { throw new InvalidOperationException("Unexpected attempt to get doc comment from " + GetType()?.ToString() + "."); } } protected AbstractPropertyEventMethod(InterfaceMemberBase member, string prefix, Attributes attrs, Location loc) : base(member.Parent, SetupName(prefix, member, loc), attrs) { this.prefix = prefix; } private static MemberName SetupName(string prefix, InterfaceMemberBase member, Location loc) { return new MemberName(member.MemberName.Left, prefix + member.ShortName, member.MemberName.ExplicitInterface, loc); } public void UpdateName(InterfaceMemberBase member) { SetMemberName(SetupName(prefix, member, base.Location)); } public EmitContext CreateEmitContext(ILGenerator ig, SourceMethodBuilder sourceMethod) { return new EmitContext(this, ig, ReturnType, sourceMethod); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.CLSCompliant || a.Type == pa.Obsolete || a.Type == pa.Conditional) { base.Report.Error(1667, a.Location, "Attribute `{0}' is not valid on property or event accessors. It is valid on `{1}' declarations only", a.Type.GetSignatureForError(), a.GetValidTargets()); } else if (a.IsValidSecurityAttribute()) { a.ExtractSecurityPermissionSet(ctor, ref declarative_security); } else if (a.Target == AttributeTargets.Method) { method_data.MethodBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } else if (a.Target == AttributeTargets.ReturnValue) { CreateReturnBuilder(); return_attributes.ApplyAttributeBuilder(a, ctor, cdata, pa); } else { ApplyToExtraTarget(a, ctor, cdata, pa); } } protected virtual void ApplyToExtraTarget(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { throw new NotSupportedException("You forgot to define special attribute target handling"); } public sealed override bool Define() { throw new NotSupportedException(); } private ReturnParameter CreateReturnBuilder() { return return_attributes ?? (return_attributes = new ReturnParameter(this, method_data.MethodBuilder, base.Location)); } public virtual void Emit(TypeDefinition parent) { method_data.Emit(parent); if ((base.ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated) { Module.PredefinedAttributes.CompilerGenerated.EmitAttribute(method_data.MethodBuilder); } if ((base.ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0) { Module.PredefinedAttributes.DebuggerHidden.EmitAttribute(method_data.MethodBuilder); } if (ReturnType.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder); } else if (ReturnType.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder, ReturnType, base.Location); } else if (ReturnType is ReadOnlyReferenceContainer) { Module.PredefinedAttributes.IsReadOnly.EmitAttribute(CreateReturnBuilder().Builder); } if (ReturnType.HasNamedTupleElement) { Module.PredefinedAttributes.TupleElementNames.EmitAttribute(CreateReturnBuilder().Builder, ReturnType, base.Location); } if (base.OptAttributes != null) { base.OptAttributes.Emit(); } block = null; } public override bool EnableOverloadChecks(MemberCore overload) { if (overload is MethodCore) { caching_flags |= Flags.MethodOverloadsExist; return true; } if (overload is AbstractPropertyEventMethod) { return true; } return false; } public override string GetCallerMemberName() { return base.GetCallerMemberName().Substring(prefix.Length); } public override string GetSignatureForDocumentation() { throw new NotSupportedException(); } public override bool IsClsComplianceRequired() { return false; } public void PrepareEmit() { method_data.DefineMethodBuilder(Parent.PartialContainer, ParameterInfo); } public override void WriteDebugSymbol(MonoSymbolFile file) { if (method_data != null) { method_data.WriteDebugSymbol(file); } } } internal class Operator : MethodOrOperator { public enum OpType : byte { LogicalNot, OnesComplement, Increment, Decrement, True, False, Addition, Subtraction, UnaryPlus, UnaryNegation, Multiply, Division, Modulus, BitwiseAnd, BitwiseOr, ExclusiveOr, LeftShift, RightShift, Equality, Inequality, GreaterThan, LessThan, GreaterThanOrEqual, LessThanOrEqual, Implicit, Explicit, Is, TOP } private const Modifiers AllowedModifiers = Modifiers.AllowedExplicitImplFlags | Modifiers.PUBLIC | Modifiers.STATIC; public readonly OpType OperatorType; private static readonly string[][] names; static Operator() { names = new string[27][]; names[0] = new string[2] { "!", "op_LogicalNot" }; names[1] = new string[2] { "~", "op_OnesComplement" }; names[2] = new string[2] { "++", "op_Increment" }; names[3] = new string[2] { "--", "op_Decrement" }; names[4] = new string[2] { "true", "op_True" }; names[5] = new string[2] { "false", "op_False" }; names[6] = new string[2] { "+", "op_Addition" }; names[7] = new string[2] { "-", "op_Subtraction" }; names[8] = new string[2] { "+", "op_UnaryPlus" }; names[9] = new string[2] { "-", "op_UnaryNegation" }; names[10] = new string[2] { "*", "op_Multiply" }; names[11] = new string[2] { "/", "op_Division" }; names[12] = new string[2] { "%", "op_Modulus" }; names[13] = new string[2] { "&", "op_BitwiseAnd" }; names[14] = new string[2] { "|", "op_BitwiseOr" }; names[15] = new string[2] { "^", "op_ExclusiveOr" }; names[16] = new string[2] { "<<", "op_LeftShift" }; names[17] = new string[2] { ">>", "op_RightShift" }; names[18] = new string[2] { "==", "op_Equality" }; names[19] = new string[2] { "!=", "op_Inequality" }; names[20] = new string[2] { ">", "op_GreaterThan" }; names[21] = new string[2] { "<", "op_LessThan" }; names[22] = new string[2] { ">=", "op_GreaterThanOrEqual" }; names[23] = new string[2] { "<=", "op_LessThanOrEqual" }; names[24] = new string[2] { "implicit", "op_Implicit" }; names[25] = new string[2] { "explicit", "op_Explicit" }; names[26] = new string[2] { "is", "op_Is" }; } public Operator(TypeDefinition parent, OpType type, FullNamedExpression ret_type, Modifiers mod_flags, ParametersCompiled parameters, ToplevelBlock block, Attributes attrs, Location loc) : base(parent, ret_type, mod_flags, Modifiers.AllowedExplicitImplFlags | Modifiers.PUBLIC | Modifiers.STATIC, new MemberName(GetMetadataName(type), loc), attrs, parameters) { OperatorType = type; base.Block = block; } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.Conditional) { Error_ConditionalAttributeIsNotValid(); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } public override bool Define() { if ((base.ModFlags & (Modifiers.PUBLIC | Modifiers.STATIC)) != (Modifiers.PUBLIC | Modifiers.STATIC)) { base.Report.Error(558, base.Location, "User-defined operator `{0}' must be declared static and public", GetSignatureForError()); } if (!base.Define()) { return false; } if (block != null) { if (block.IsIterator) { Iterator.CreateIterator(this, Parent.PartialContainer, base.ModFlags); base.ModFlags |= Modifiers.DEBUGGER_HIDDEN; } if (Compiler.Settings.WriteMetadataOnly) { block = null; } } if (OperatorType == OpType.Explicit) { Parent.MemberCache.CheckExistingMembersOverloads(this, GetMetadataName(OpType.Implicit), parameters); } else if (OperatorType == OpType.Implicit) { Parent.MemberCache.CheckExistingMembersOverloads(this, GetMetadataName(OpType.Explicit), parameters); } TypeSpec currentType = Parent.PartialContainer.CurrentType; TypeSpec memberType = base.MemberType; TypeSpec typeSpec = base.ParameterTypes[0]; TypeSpec typeSpec2 = typeSpec; if (typeSpec.IsNullableType) { typeSpec2 = NullableInfo.GetUnderlyingType(typeSpec); } TypeSpec typeSpec3 = memberType; if (memberType.IsNullableType) { typeSpec3 = NullableInfo.GetUnderlyingType(memberType); } if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) { if (typeSpec2 == typeSpec3 && typeSpec2 == currentType) { base.Report.Error(555, base.Location, "User-defined operator cannot take an object of the enclosing type and convert to an object of the enclosing type"); return false; } TypeSpec typeSpec4; if (currentType == memberType || currentType == typeSpec3) { typeSpec4 = typeSpec; } else { if (currentType != typeSpec && currentType != typeSpec2) { base.Report.Error(556, base.Location, "User-defined conversion must convert to or from the enclosing type"); return false; } typeSpec4 = memberType; } if (typeSpec4.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { base.Report.Error(1964, base.Location, "User-defined conversion `{0}' cannot convert to or from the dynamic type", GetSignatureForError()); return false; } if (typeSpec4.IsInterface) { base.Report.Error(552, base.Location, "User-defined conversion `{0}' cannot convert to or from an interface type", GetSignatureForError()); return false; } if (typeSpec4.IsClass) { if (TypeSpec.IsBaseClass(currentType, typeSpec4, dynamicIsObject: true)) { base.Report.Error(553, base.Location, "User-defined conversion `{0}' cannot convert to or from a base class", GetSignatureForError()); return false; } if (TypeSpec.IsBaseClass(typeSpec4, currentType, dynamicIsObject: false)) { base.Report.Error(554, base.Location, "User-defined conversion `{0}' cannot convert to or from a derived class", GetSignatureForError()); return false; } } } else if (OperatorType == OpType.LeftShift || OperatorType == OpType.RightShift) { if (typeSpec != currentType || parameters.Types[1].BuiltinType != BuiltinTypeSpec.Type.Int) { base.Report.Error(564, base.Location, "Overloaded shift operator must have the type of the first operand be the containing type, and the type of the second operand must be int"); return false; } } else if (parameters.Count == 1) { if (OperatorType == OpType.Increment || OperatorType == OpType.Decrement) { if (memberType != currentType && !TypeSpec.IsBaseClass(memberType, currentType, dynamicIsObject: false)) { base.Report.Error(448, base.Location, "The return type for ++ or -- operator must be the containing type or derived from the containing type"); return false; } if (typeSpec != currentType) { base.Report.Error(559, base.Location, "The parameter type for ++ or -- operator must be the containing type"); return false; } } if (typeSpec2 != currentType) { base.Report.Error(562, base.Location, "The parameter type of a unary operator must be the containing type"); return false; } if ((OperatorType == OpType.True || OperatorType == OpType.False) && memberType.BuiltinType != BuiltinTypeSpec.Type.FirstPrimitive) { base.Report.Error(215, base.Location, "The return type of operator True or False must be bool"); return false; } } else if (typeSpec2 != currentType) { TypeSpec typeSpec5 = base.ParameterTypes[1]; if (typeSpec5.IsNullableType) { typeSpec5 = NullableInfo.GetUnderlyingType(typeSpec5); } if (typeSpec5 != currentType) { base.Report.Error(563, base.Location, "One of the parameters of a binary operator must be the containing type"); return false; } } return true; } protected override bool ResolveMemberType() { if (!base.ResolveMemberType()) { return false; } flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName; return true; } protected override MemberSpec FindBaseMember(out MemberSpec bestCandidate, ref bool overrides) { bestCandidate = null; return null; } public static string GetName(OpType ot) { return names[(uint)ot][0]; } public static string GetName(string metadata_name) { for (int i = 0; i < names.Length; i++) { if (names[i][1] == metadata_name) { return names[i][0]; } } return null; } public static string GetMetadataName(OpType ot) { return names[(uint)ot][1]; } public static string GetMetadataName(string name) { for (int i = 0; i < names.Length; i++) { if (names[i][0] == name) { return names[i][1]; } } return null; } public static OpType? GetType(string metadata_name) { for (int i = 0; i < names.Length; i++) { if (names[i][1] == metadata_name) { return (OpType)i; } } return null; } public OpType GetMatchingOperator() { return OperatorType switch { OpType.Equality => OpType.Inequality, OpType.Inequality => OpType.Equality, OpType.True => OpType.False, OpType.False => OpType.True, OpType.GreaterThan => OpType.LessThan, OpType.LessThan => OpType.GreaterThan, OpType.GreaterThanOrEqual => OpType.LessThanOrEqual, OpType.LessThanOrEqual => OpType.GreaterThanOrEqual, _ => OpType.TOP, }; } public override string GetSignatureForDocumentation() { string text = base.GetSignatureForDocumentation(); if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) { text = text + "~" + base.ReturnType.GetSignatureForDocumentation(); } return text; } public override string GetSignatureForError() { StringBuilder stringBuilder = new StringBuilder(); if (OperatorType == OpType.Implicit || OperatorType == OpType.Explicit) { stringBuilder.AppendFormat("{0}.{1} operator {2}", Parent.GetSignatureForError(), GetName(OperatorType), (member_type == null) ? type_expr.GetSignatureForError() : member_type.GetSignatureForError()); } else { stringBuilder.AppendFormat("{0}.operator {1}", Parent.GetSignatureForError(), GetName(OperatorType)); } stringBuilder.Append(parameters.GetSignatureForError()); return stringBuilder.ToString(); } } [Flags] internal enum Modifiers { PROTECTED = 1, PUBLIC = 2, PRIVATE = 4, INTERNAL = 8, NEW = 0x10, ABSTRACT = 0x20, SEALED = 0x40, STATIC = 0x80, READONLY = 0x100, VIRTUAL = 0x200, OVERRIDE = 0x400, EXTERN = 0x800, VOLATILE = 0x1000, UNSAFE = 0x2000, ASYNC = 0x4000, TOP = 0x8000, PROPERTY_CUSTOM = 0x10000, PARTIAL = 0x20000, DEFAULT_ACCESS_MODIFIER = 0x40000, METHOD_EXTENSION = 0x80000, COMPILER_GENERATED = 0x100000, BACKING_FIELD = 0x200000, DEBUGGER_HIDDEN = 0x400000, DEBUGGER_STEP_THROUGH = 0x800000, AutoProperty = 0x1000000, REF = 0x2000000, AccessibilityMask = 0xF, AllowedExplicitImplFlags = 0x2800 } internal static class ModifiersExtensions { public static string AccessibilityName(Modifiers mod) { return (mod & Modifiers.AccessibilityMask) switch { Modifiers.PUBLIC => "public", Modifiers.PROTECTED => "protected", Modifiers.PROTECTED | Modifiers.INTERNAL => "protected internal", Modifiers.INTERNAL => "internal", Modifiers.PRIVATE => "private", Modifiers.PROTECTED | Modifiers.PRIVATE => "private protected", _ => throw new NotImplementedException(mod.ToString()), }; } public static string Name(Modifiers i) { string result = ""; switch (i) { case Modifiers.NEW: result = "new"; break; case Modifiers.PUBLIC: result = "public"; break; case Modifiers.PROTECTED: result = "protected"; break; case Modifiers.INTERNAL: result = "internal"; break; case Modifiers.PRIVATE: result = "private"; break; case Modifiers.ABSTRACT: result = "abstract"; break; case Modifiers.SEALED: result = "sealed"; break; case Modifiers.STATIC: result = "static"; break; case Modifiers.READONLY: result = "readonly"; break; case Modifiers.VIRTUAL: result = "virtual"; break; case Modifiers.OVERRIDE: result = "override"; break; case Modifiers.EXTERN: result = "extern"; break; case Modifiers.VOLATILE: result = "volatile"; break; case Modifiers.UNSAFE: result = "unsafe"; break; case Modifiers.ASYNC: result = "async"; break; } return result; } public static bool IsRestrictedModifier(Modifiers modA, Modifiers modB) { Modifiers modifiers = (Modifiers)0; if ((modB & Modifiers.PUBLIC) != 0) { modifiers = Modifiers.PROTECTED | Modifiers.PRIVATE | Modifiers.INTERNAL; } else if ((modB & Modifiers.PROTECTED) != 0) { if ((modB & Modifiers.INTERNAL) != 0) { modifiers = Modifiers.PROTECTED | Modifiers.PRIVATE | Modifiers.INTERNAL; } else { modA &= ~Modifiers.PROTECTED; modifiers = Modifiers.PRIVATE; } } else if ((modB & Modifiers.INTERNAL) != 0) { modA &= ~Modifiers.PROTECTED; modifiers = Modifiers.PRIVATE; } return modB != modA && (modA & ~modifiers) == 0; } public static TypeAttributes TypeAttr(Modifiers mod_flags, bool is_toplevel) { TypeAttributes typeAttributes = TypeAttributes.NotPublic; if (is_toplevel) { if ((mod_flags & Modifiers.PUBLIC) != 0) { typeAttributes = TypeAttributes.Public; } else if ((mod_flags & Modifiers.PRIVATE) != 0) { typeAttributes = TypeAttributes.NotPublic; } } else if ((mod_flags & Modifiers.PUBLIC) != 0) { typeAttributes = TypeAttributes.NestedPublic; } else if ((mod_flags & (Modifiers.PROTECTED | Modifiers.PRIVATE)) == (Modifiers.PROTECTED | Modifiers.PRIVATE)) { typeAttributes = TypeAttributes.NestedFamANDAssem; } else if ((mod_flags & Modifiers.PRIVATE) != 0) { typeAttributes = TypeAttributes.NestedPrivate; } else if ((mod_flags & (Modifiers.PROTECTED | Modifiers.INTERNAL)) == (Modifiers.PROTECTED | Modifiers.INTERNAL)) { typeAttributes = TypeAttributes.VisibilityMask; } else if ((mod_flags & Modifiers.PROTECTED) != 0) { typeAttributes = TypeAttributes.NestedFamily; } else if ((mod_flags & Modifiers.INTERNAL) != 0) { typeAttributes = TypeAttributes.NestedAssembly; } if ((mod_flags & Modifiers.SEALED) != 0) { typeAttributes |= TypeAttributes.Sealed; } if ((mod_flags & Modifiers.ABSTRACT) != 0) { typeAttributes |= TypeAttributes.Abstract; } return typeAttributes; } public static FieldAttributes FieldAttr(Modifiers mod_flags) { FieldAttributes fieldAttributes = FieldAttributes.PrivateScope; fieldAttributes = (mod_flags & Modifiers.AccessibilityMask) switch { Modifiers.PUBLIC => fieldAttributes | FieldAttributes.Public, Modifiers.PRIVATE => fieldAttributes | FieldAttributes.Private, Modifiers.PROTECTED | Modifiers.INTERNAL => fieldAttributes | FieldAttributes.FamORAssem, Modifiers.PROTECTED => fieldAttributes | FieldAttributes.Family, Modifiers.INTERNAL => fieldAttributes | FieldAttributes.Assembly, Modifiers.PROTECTED | Modifiers.PRIVATE => fieldAttributes | FieldAttributes.FamANDAssem, _ => throw new NotImplementedException(mod_flags.ToString()), }; if ((mod_flags & Modifiers.STATIC) != 0) { fieldAttributes |= FieldAttributes.Static; } if ((mod_flags & Modifiers.READONLY) != 0) { fieldAttributes |= FieldAttributes.InitOnly; } return fieldAttributes; } public static MethodAttributes MethodAttr(Modifiers mod_flags) { MethodAttributes methodAttributes = MethodAttributes.HideBySig; methodAttributes = (mod_flags & Modifiers.AccessibilityMask) switch { Modifiers.PUBLIC => methodAttributes | MethodAttributes.Public, Modifiers.PRIVATE => methodAttributes | MethodAttributes.Private, Modifiers.PROTECTED | Modifiers.INTERNAL => methodAttributes | MethodAttributes.FamORAssem, Modifiers.PROTECTED => methodAttributes | MethodAttributes.Family, Modifiers.INTERNAL => methodAttributes | MethodAttributes.Assembly, Modifiers.PROTECTED | Modifiers.PRIVATE => methodAttributes | MethodAttributes.FamANDAssem, _ => throw new NotImplementedException(mod_flags.ToString()), }; if ((mod_flags & Modifiers.STATIC) != 0) { methodAttributes |= MethodAttributes.Static; } if ((mod_flags & Modifiers.ABSTRACT) != 0) { methodAttributes |= MethodAttributes.Virtual | MethodAttributes.Abstract; } if ((mod_flags & Modifiers.SEALED) != 0) { methodAttributes |= MethodAttributes.Final; } if ((mod_flags & Modifiers.VIRTUAL) != 0) { methodAttributes |= MethodAttributes.Virtual; } if ((mod_flags & Modifiers.OVERRIDE) != 0) { methodAttributes |= MethodAttributes.Virtual; } else if ((methodAttributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope) { methodAttributes |= MethodAttributes.VtableLayoutMask; } return methodAttributes; } public static Modifiers Check(Modifiers allowed, Modifiers mod, Modifiers def_access, Location l, Report Report) { int num = (int)(~allowed & (mod & (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.READONLY | Modifiers.VIRTUAL | Modifiers.OVERRIDE | Modifiers.VOLATILE | Modifiers.ASYNC))); if (num == 0) { if ((mod & Modifiers.AccessibilityMask) == 0) { mod |= def_access; if (def_access != 0) { mod |= Modifiers.DEFAULT_ACCESS_MODIFIER; } return mod; } return mod; } for (int num2 = 1; num2 < 32768; num2 <<= 1) { if ((num2 & num) != 0) { Error_InvalidModifier((Modifiers)num2, l, Report); } } return allowed & mod; } private static void Error_InvalidModifier(Modifiers mod, Location l, Report Report) { Report.Error(106, l, "The modifier `{0}' is not valid for this item", Name(mod)); } } internal sealed class ModuleContainer : TypeContainer { public sealed class PatternMatchingHelper : CompilerGeneratedContainer { public Method NumberMatcher { get; private set; } public PatternMatchingHelper(ModuleContainer module) : base(module, new MemberName("", Location.Null), Modifiers.INTERNAL | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN) { } protected override bool DoDefineMembers() { if (!base.DoDefineMembers()) { return false; } NumberMatcher = GenerateNumberMatcher(); return true; } private Method GenerateNumberMatcher() { Location location = base.Location; Parameter[] parameters = new Parameter[3] { new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, location), "obj", Parameter.Modifier.NONE, null, location), new Parameter(new TypeExpression(Compiler.BuiltinTypes.Object, location), "value", Parameter.Modifier.NONE, null, location), new Parameter(new TypeExpression(Compiler.BuiltinTypes.Bool, location), "enumType", Parameter.Modifier.NONE, null, location) }; TypeSpec[] types = new BuiltinTypeSpec[3] { Compiler.BuiltinTypes.Object, Compiler.BuiltinTypes.Object, Compiler.BuiltinTypes.Bool }; ParametersCompiled parametersCompiled = ParametersCompiled.CreateFullyResolved(parameters, types); Method method = new Method(this, new TypeExpression(Compiler.BuiltinTypes.Bool, location), Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName("NumberMatcher", location), parametersCompiled, null); parametersCompiled[0].Resolve(method, 0); parametersCompiled[1].Resolve(method, 1); parametersCompiled[2].Resolve(method, 2); ToplevelBlock toplevelBlock = (method.Block = new ToplevelBlock(Compiler, parametersCompiled, location)); Arguments arguments = new Arguments(2); arguments.Add(new Argument(toplevelBlock.GetParameterReference(0, location))); arguments.Add(new Argument(toplevelBlock.GetParameterReference(1, location))); If s = new If(toplevelBlock.GetParameterReference(2, location), new Return(new Invocation(new SimpleName("Equals", location), arguments), location), location); toplevelBlock.AddStatement(s); If s2 = new If(new Binary(Binary.Operator.LogicalOr, new Is(toplevelBlock.GetParameterReference(0, location), new TypeExpression(Compiler.BuiltinTypes.Enum, location), location), new Binary(Binary.Operator.Equality, toplevelBlock.GetParameterReference(0, location), new NullLiteral(location))), new Return(new BoolLiteral(Compiler.BuiltinTypes, val: false, location), location), location); toplevelBlock.AddStatement(s2); MemberAccess expr = new MemberAccess(new QualifiedAliasMember("global", "System", location), "Convert", location); ExplicitBlock explicitBlock = new ExplicitBlock(toplevelBlock, location, location); LocalVariable li = LocalVariable.CreateCompilerGenerated(Compiler.BuiltinTypes.Object, toplevelBlock, location); Arguments arguments2 = new Arguments(1); arguments2.Add(new Argument(toplevelBlock.GetParameterReference(1, location))); Invocation expr2 = new Invocation(new MemberAccess(expr, "GetTypeCode", location), arguments2); Arguments arguments3 = new Arguments(1); arguments3.Add(new Argument(toplevelBlock.GetParameterReference(0, location))); arguments3.Add(new Argument(expr2)); Invocation source = new Invocation(new MemberAccess(expr, "ChangeType", location), arguments3); explicitBlock.AddStatement(new StatementExpression(new SimpleAssign(new LocalVariableReference(li, location), source, location))); Arguments arguments4 = new Arguments(1); arguments4.Add(new Argument(toplevelBlock.GetParameterReference(1, location))); Invocation expr3 = new Invocation(new MemberAccess(new LocalVariableReference(li, location), "Equals"), arguments4); explicitBlock.AddStatement(new Return(expr3, location)); ExplicitBlock explicitBlock2 = new ExplicitBlock(toplevelBlock, location, location); explicitBlock2.AddStatement(new Return(new BoolLiteral(Compiler.BuiltinTypes, val: false, location), location)); toplevelBlock.AddStatement(new TryCatch(explicitBlock, new List { new Catch(explicitBlock2, location) }, location, inside_try_finally: false)); method.Define(); method.PrepareEmit(); AddMember(method); return method; } } private PatternMatchingHelper pmh; public CharSet? DefaultCharSet; public TypeAttributes DefaultCharSetType = TypeAttributes.NotPublic; private readonly Dictionary> anonymous_types; private readonly Dictionary array_types; private readonly Dictionary pointer_types; private readonly Dictionary reference_types; private readonly Dictionary readonly_reference_types; private readonly Dictionary attrs_cache; private readonly Dictionary awaiters; private readonly Dictionary type_info_cache; private AssemblyDefinition assembly; private readonly CompilerContext context; private readonly RootNamespace global_ns; private readonly Dictionary alias_ns; private ModuleBuilder builder; private bool has_extenstion_method; private PredefinedAttributes predefined_attributes; private PredefinedTypes predefined_types; private PredefinedMembers predefined_members; public Binary.PredefinedOperator[] OperatorsBinaryEqualityLifted; public Binary.PredefinedOperator[] OperatorsBinaryLifted; private static readonly string[] attribute_targets = new string[2] { "assembly", "module" }; internal Dictionary ArrayTypesCache => array_types; internal Dictionary AttributeConstructorCache => attrs_cache; public override AttributeTargets AttributeTargets => AttributeTargets.Assembly; public ModuleBuilder Builder => builder; public override CompilerContext Compiler => context; public int CounterAnonymousTypes { get; set; } public AssemblyDefinition DeclaringAssembly => assembly; internal DocumentationBuilder DocumentationBuilder { get; set; } public override string DocCommentHeader { get { throw new NotSupportedException(); } } public Evaluator Evaluator { get; set; } public bool HasDefaultCharSet => DefaultCharSet.HasValue; public bool HasExtensionMethod { get { return has_extenstion_method; } set { has_extenstion_method = value; } } public bool HasTypesFullyDefined { get; set; } public RootNamespace GlobalRootNamespace => global_ns; public override ModuleContainer Module => this; internal Dictionary PointerTypesCache => pointer_types; internal PredefinedAttributes PredefinedAttributes => predefined_attributes; internal PredefinedMembers PredefinedMembers => predefined_members; internal PredefinedTypes PredefinedTypes => predefined_types; internal Dictionary ReferenceTypesCache => reference_types; internal Dictionary ReadonlyReferenceTypesCache => readonly_reference_types; internal Dictionary TypeInfoCache => type_info_cache; public override string[] ValidAttributeTargets => attribute_targets; public Dictionary GetResourceStrings { get; private set; } public PatternMatchingHelper CreatePatterMatchingHelper() { if (pmh == null) { pmh = new PatternMatchingHelper(this); pmh.CreateContainer(); pmh.DefineContainer(); pmh.Define(); AddCompilerGeneratedClass(pmh); } return pmh; } public ModuleContainer(CompilerContext context) : base(null, MemberName.Null, null, (MemberKind)0) { this.context = context; caching_flags &= ~(Flags.Obsolete_Undetected | Flags.Excluded_Undetected); containers = new List(); anonymous_types = new Dictionary>(); global_ns = new GlobalRootNamespace(); alias_ns = new Dictionary(); array_types = new Dictionary(); pointer_types = new Dictionary(); reference_types = new Dictionary(); readonly_reference_types = new Dictionary(); attrs_cache = new Dictionary(); awaiters = new Dictionary(); type_info_cache = new Dictionary(); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public void AddAnonymousType(AnonymousTypeClass type) { if (!anonymous_types.TryGetValue(type.Parameters.Count, out var value) && value == null) { value = new List(); anonymous_types.Add(type.Parameters.Count, value); } value.Add(type); } public void AddAttribute(Attribute attr, IMemberContext context) { attr.AttachTo(this, context); if (attributes == null) { attributes = new Attributes(attr); } else { attributes.AddAttribute(attr); } } public void AddAssemblyReferences(List names) { if (names != null) { } } public override void AddTypeContainer(TypeContainer tc) { AddTypeContainerMember(tc); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Assembly) { assembly.ApplyAttributeBuilder(a, ctor, cdata, pa); return; } if (a.Type == pa.DefaultCharset) { switch (a.GetCharSetValue()) { case CharSet.Auto: DefaultCharSet = CharSet.Auto; DefaultCharSetType = TypeAttributes.AutoClass; break; case CharSet.Unicode: DefaultCharSet = CharSet.Unicode; DefaultCharSetType = TypeAttributes.UnicodeClass; break; default: base.Report.Error(1724, a.Location, "Value specified for the argument to `{0}' is not valid", a.GetSignatureForError()); break; case CharSet.None: case CharSet.Ansi: break; } } else if (a.Type == pa.CLSCompliant) { Attribute cLSCompliantAttribute = DeclaringAssembly.CLSCompliantAttribute; if (cLSCompliantAttribute == null) { base.Report.Warning(3012, 1, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking"); } else if (DeclaringAssembly.IsCLSCompliant != a.GetBoolean()) { base.Report.SymbolRelatedToPreviousError(cLSCompliantAttribute.Location, cLSCompliantAttribute.GetSignatureForError()); base.Report.Warning(3017, 1, a.Location, "You cannot specify the CLSCompliant attribute on a module that differs from the CLSCompliant attribute on the assembly"); return; } } builder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } public override void CloseContainer() { if (anonymous_types != null) { foreach (KeyValuePair> anonymous_type in anonymous_types) { foreach (AnonymousTypeClass item in anonymous_type.Value) { item.CloseContainer(); } } } base.CloseContainer(); } public TypeBuilder CreateBuilder(string name, TypeAttributes attr, int typeSize) { return builder.DefineType(name, attr, null, typeSize); } public RootNamespace CreateRootNamespace(string alias) { if (alias == global_ns.Alias) { RootNamespace.Error_GlobalNamespaceRedefined(base.Report, Location.Null); return global_ns; } if (!alias_ns.TryGetValue(alias, out var value)) { value = new RootNamespace(alias); alias_ns.Add(alias, value); } return value; } public void Create(AssemblyDefinition assembly, ModuleBuilder moduleBuilder) { this.assembly = assembly; builder = moduleBuilder; } public override bool Define() { DefineContainer(); ExpandBaseInterfaces(); base.Define(); HasTypesFullyDefined = true; return true; } public override bool DefineContainer() { DefineNamespace(); return base.DefineContainer(); } public void EnableRedefinition() { is_defined = false; } public override void EmitContainer() { if (base.OptAttributes != null) { base.OptAttributes.Emit(); } if (Compiler.Settings.Unsafe && !assembly.IsSatelliteAssembly) { PredefinedAttribute unverifiableCode = PredefinedAttributes.UnverifiableCode; if (unverifiableCode.IsDefined) { unverifiableCode.EmitAttribute(builder); } } foreach (TypeContainer container in containers) { container.PrepareEmit(); } base.EmitContainer(); if (Compiler.Report.Errors == 0 && !Compiler.Settings.WriteMetadataOnly) { VerifyMembers(); } if (anonymous_types == null) { return; } foreach (KeyValuePair> anonymous_type in anonymous_types) { foreach (AnonymousTypeClass item in anonymous_type.Value) { item.EmitContainer(); } } } public AnonymousTypeClass GetAnonymousType(IList parameters) { if (!anonymous_types.TryGetValue(parameters.Count, out var value)) { return null; } foreach (AnonymousTypeClass item in value) { int i; for (i = 0; i < parameters.Count && parameters[i].Equals(item.Parameters[i]); i++) { } if (i == parameters.Count) { return item; } } return null; } public AwaiterDefinition GetAwaiter(TypeSpec type) { if (awaiters.TryGetValue(type, out var value)) { return value; } value = new AwaiterDefinition(); value.IsCompleted = MemberCache.FindMember(type, MemberFilter.Property("IsCompleted", Compiler.BuiltinTypes.Bool), BindingRestriction.InstanceOnly) as PropertySpec; value.GetResult = MemberCache.FindMember(type, MemberFilter.Method("GetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, null), BindingRestriction.InstanceOnly) as MethodSpec; PredefinedType iNotifyCompletion = PredefinedTypes.INotifyCompletion; value.INotifyCompletion = !iNotifyCompletion.Define() || type.ImplementsInterface(iNotifyCompletion.TypeSpec, variantly: false); awaiters.Add(type, value); return value; } public override void GetCompletionStartingWith(string prefix, List results) { string[] varNames = Evaluator.GetVarNames(); results.AddRange(varNames.Where((string l) => l.StartsWith(prefix))); } public RootNamespace GetRootNamespace(string name) { alias_ns.TryGetValue(name, out var value); return value; } public override string GetSignatureForError() { return ""; } public Binary.PredefinedOperator[] GetPredefinedEnumAritmeticOperators(TypeSpec enumType, bool nullable) { Binary.Operator obj = (Binary.Operator)0; TypeSpec typeSpec; if (nullable) { typeSpec = NullableInfo.GetEnumUnderlyingType(this, enumType); obj = Binary.Operator.NullableMask; } else { typeSpec = EnumSpec.GetUnderlyingType(enumType); } return new Binary.PredefinedOperator[3] { new Binary.PredefinedOperator(enumType, typeSpec, obj | Binary.Operator.AdditionMask | Binary.Operator.SubtractionMask | Binary.Operator.DecomposedMask, enumType), new Binary.PredefinedOperator(typeSpec, enumType, obj | Binary.Operator.AdditionMask | Binary.Operator.SubtractionMask | Binary.Operator.DecomposedMask, enumType), new Binary.PredefinedOperator(enumType, obj | Binary.Operator.SubtractionMask, typeSpec) }; } public void InitializePredefinedTypes() { predefined_attributes = new PredefinedAttributes(this); predefined_types = new PredefinedTypes(this); predefined_members = new PredefinedMembers(this); OperatorsBinaryEqualityLifted = Binary.CreateEqualityLiftedOperatorsTable(this); OperatorsBinaryLifted = Binary.CreateStandardLiftedOperatorsTable(this); } public override bool IsClsComplianceRequired() { return DeclaringAssembly.IsCLSCompliant; } public Attribute ResolveAssemblyAttribute(PredefinedAttribute a_type) { Attribute attribute = base.OptAttributes.Search("assembly", a_type); attribute?.Resolve(); return attribute; } public void SetDeclaringAssembly(AssemblyDefinition assembly) { this.assembly = assembly; } public void LoadGetResourceStrings(List fileNames) { foreach (string fileName in fileNames) { if (!File.Exists(fileName)) { base.Report.Error(1566, "Error reading resource file `{0}'", fileName); break; } string[] array = File.ReadAllLines(fileName); foreach (string text in array) { if (GetResourceStrings == null) { GetResourceStrings = new Dictionary(); } string text2 = text.Trim(); if (text2.Length != 0 && text2[0] != '#' && text2[0] != ';') { int num = text2.IndexOf('='); if (num >= 0) { string key = text2.Substring(0, num).Trim(); string value = text2.Substring(num + 1).Trim(); GetResourceStrings[key] = value; } } } } } } internal class RootNamespace : Namespace { private readonly string alias_name; private readonly Dictionary all_namespaces; public string Alias => alias_name; public RootNamespace(string alias_name) { this.alias_name = alias_name; RegisterNamespace(this); all_namespaces = new Dictionary(); all_namespaces.Add("", this); } public static void Error_GlobalNamespaceRedefined(Report report, Location loc) { report.Error(1681, loc, "The global extern alias cannot be redefined"); } public List FindTypeNamespaces(IMemberContext ctx, string name, int arity) { List list = null; foreach (KeyValuePair all_namespace in all_namespaces) { TypeSpec typeSpec = all_namespace.Value.LookupType(ctx, name, arity, LookupMode.IgnoreAccessibility, Location.Null); if (typeSpec != null) { if (list == null) { list = new List(); } list.Add(all_namespace.Key); } } return list; } public List FindExtensionMethodNamespaces(IMemberContext ctx, string name, int arity) { List list = null; foreach (KeyValuePair all_namespace in all_namespaces) { if (all_namespace.Key.Length == 0) { continue; } List list2 = all_namespace.Value.LookupExtensionMethod(ctx, name, arity); if (list2 != null) { if (list == null) { list = new List(); } list.Add(all_namespace.Key); } } return list; } public void RegisterNamespace(Namespace child) { if (child != this) { all_namespaces.Add(child.Name, child); } } public override string GetSignatureForError() { return alias_name + "::"; } } internal sealed class GlobalRootNamespace : RootNamespace { public GlobalRootNamespace() : base("global") { } } internal class Namespace { private readonly Namespace parent; private string fullname; protected Dictionary namespaces; protected Dictionary> types; private List extension_method_types; private Dictionary cached_types; private bool cls_checked; public string Name => fullname; public Namespace Parent => parent; public Namespace(Namespace parent, string name) : this() { if (name == null) { throw new ArgumentNullException("name"); } this.parent = parent; string text = parent?.fullname; if (text == null) { fullname = name; } else { fullname = text + "." + name; } while (parent.parent != null) { parent = parent.parent; } if (!(parent is RootNamespace rootNamespace)) { throw new InternalErrorException("Root namespaces must be created using RootNamespace"); } rootNamespace.RegisterNamespace(this); } protected Namespace() { namespaces = new Dictionary(); cached_types = new Dictionary(); } public Namespace AddNamespace(MemberName name) { Namespace obj = ((name.Left == null) ? this : AddNamespace(name.Left)); return obj.TryAddNamespace(name.Basename); } private Namespace TryAddNamespace(string name) { if (!namespaces.TryGetValue(name, out var value)) { value = new Namespace(this, name); namespaces.Add(name, value); } return value; } public bool TryGetNamespace(string name, out Namespace ns) { return namespaces.TryGetValue(name, out ns); } public Namespace GetNamespace(string name, bool create) { int num = name.IndexOf('.'); string text = ((num < 0) ? name : name.Substring(0, num)); if (!namespaces.TryGetValue(text, out var value)) { if (!create) { return null; } value = new Namespace(this, text); namespaces.Add(text, value); } if (num >= 0) { value = value.GetNamespace(name.Substring(num + 1), create); } return value; } public IList GetAllTypes(string name) { if (types == null || !types.TryGetValue(name, out var value)) { return null; } return value; } public virtual string GetSignatureForError() { return fullname; } public TypeSpec LookupType(IMemberContext ctx, string name, int arity, LookupMode mode, Location loc) { if (types == null) { return null; } TypeSpec value = null; if (arity == 0 && cached_types.TryGetValue(name, out value) && (value != null || (mode & LookupMode.IgnoreAccessibility) == 0)) { return value; } if (!types.TryGetValue(name, out var value2)) { return null; } foreach (TypeSpec item in value2) { if (item.Arity == arity) { if (value == null) { if ((item.Modifiers & Modifiers.INTERNAL) == 0 || item.MemberDefinition.IsInternalAsPublic(ctx.Module.DeclaringAssembly) || (mode & LookupMode.IgnoreAccessibility) != LookupMode.Normal) { value = item; } continue; } if (value.MemberDefinition.IsImported && item.MemberDefinition.IsImported) { if (item.Kind == MemberKind.MissingType) { continue; } if (value.Kind == MemberKind.MissingType) { value = item; continue; } if (mode == LookupMode.Normal) { ctx.Module.Compiler.Report.SymbolRelatedToPreviousError(value); ctx.Module.Compiler.Report.SymbolRelatedToPreviousError(item); ctx.Module.Compiler.Report.Error(433, loc, "The imported type `{0}' is defined multiple times", item.GetSignatureForError()); } break; } if (item.Kind == MemberKind.MissingType) { continue; } if (value.MemberDefinition.IsImported) { value = item; } if (((value.Modifiers & Modifiers.INTERNAL) != 0 && !value.MemberDefinition.IsInternalAsPublic(ctx.Module.DeclaringAssembly)) || mode != LookupMode.Normal) { continue; } if (item.MemberDefinition.IsImported) { ctx.Module.Compiler.Report.SymbolRelatedToPreviousError(value); ctx.Module.Compiler.Report.SymbolRelatedToPreviousError(item); } ctx.Module.Compiler.Report.Warning(436, 2, loc, "The type `{0}' conflicts with the imported type of same name'. Ignoring the imported type definition", value.GetSignatureForError()); } if (arity < 0) { if (value == null) { value = item; } else if (Math.Abs(item.Arity + arity) < Math.Abs(value.Arity + arity)) { value = item; } } } if (arity == 0 && mode == LookupMode.Normal) { cached_types.Add(name, value); } if (value != null) { List missingDependencies = value.GetMissingDependencies(); if (missingDependencies != null) { ImportedTypeDefinition.Error_MissingDependency(ctx, missingDependencies, loc); } } return value; } public FullNamedExpression LookupTypeOrNamespace(IMemberContext ctx, string name, int arity, LookupMode mode, Location loc) { TypeSpec typeSpec = LookupType(ctx, name, arity, mode, loc); if (arity == 0 && namespaces.TryGetValue(name, out var value)) { if (typeSpec == null) { return new NamespaceExpression(value, loc); } if (mode != LookupMode.Probing) { ctx.Module.Compiler.Report.Warning(437, 2, loc, "The type `{0}' conflicts with the imported namespace `{1}'. Using the definition found in the source file", typeSpec.GetSignatureForError(), value.GetSignatureForError()); } if (typeSpec.MemberDefinition.IsImported) { return new NamespaceExpression(value, loc); } } if (typeSpec == null) { return null; } return new TypeExpression(typeSpec, loc); } public IEnumerable CompletionGetTypesStartingWith(string prefix) { if (types == null) { return Enumerable.Empty(); } IEnumerable enumerable = types.Where(delegate(KeyValuePair> item) { KeyValuePair> keyValuePair = item; int result; if (keyValuePair.Key.StartsWith(prefix)) { keyValuePair = item; result = (keyValuePair.Value.Any((TypeSpec l) => (l.Modifiers & Modifiers.PUBLIC) != 0) ? 1 : 0); } else { result = 0; } return (byte)result != 0; }).Select(delegate(KeyValuePair> item) { KeyValuePair> keyValuePair = item; return keyValuePair.Key; }); if (namespaces != null) { enumerable = enumerable.Concat(namespaces.Where(delegate(KeyValuePair item) { KeyValuePair keyValuePair = item; return keyValuePair.Key.StartsWith(prefix); }).Select(delegate(KeyValuePair item) { KeyValuePair keyValuePair = item; return keyValuePair.Key; })); } return enumerable; } public List LookupExtensionMethod(IMemberContext invocationContext, string name, int arity) { if (extension_method_types == null) { return null; } List list = null; for (int i = 0; i < extension_method_types.Count; i++) { TypeSpec typeSpec = extension_method_types[i]; if ((typeSpec.Modifiers & Modifiers.METHOD_EXTENSION) == 0) { if (extension_method_types.Count == 1) { extension_method_types = null; return list; } extension_method_types.RemoveAt(i--); continue; } List list2 = typeSpec.MemberCache.FindExtensionMethods(invocationContext, name, arity); if (list2 != null) { if (list == null) { list = list2; } else { list.AddRange(list2); } } } return list; } public void AddType(ModuleContainer module, TypeSpec ts) { if (types == null) { types = new Dictionary>(64); } if (ts.IsClass && ts.Arity == 0) { bool num; if (!ts.MemberDefinition.IsImported) { if (ts.IsStatic) { goto IL_0074; } num = ts.MemberDefinition.IsPartial; } else { num = (ts.Modifiers & Modifiers.METHOD_EXTENSION) != 0; } if (num) { goto IL_0074; } } goto IL_009e; IL_009e: string name = ts.Name; if (types.TryGetValue(name, out var value)) { if (value.Count == 1) { TypeSpec typeSpec = value[0]; if (ts.Arity == typeSpec.Arity) { TypeSpec typeSpec2 = IsImportedTypeOverride(module, ts, typeSpec); if (typeSpec2 == typeSpec) { return; } if (typeSpec2 != null) { value[0] = typeSpec2; return; } } value = new List(); value.Add(typeSpec); types[name] = value; } else { for (int i = 0; i < value.Count; i++) { TypeSpec typeSpec = value[i]; if (ts.Arity == typeSpec.Arity) { TypeSpec typeSpec2 = IsImportedTypeOverride(module, ts, typeSpec); if (typeSpec2 == typeSpec) { return; } if (typeSpec2 != null) { value.RemoveAt(i); i--; } } } } value.Add(ts); } else { types.Add(name, new TypeSpec[1] { ts }); } return; IL_0074: if (extension_method_types == null) { extension_method_types = new List(); } extension_method_types.Add(ts); goto IL_009e; } public static TypeSpec IsImportedTypeOverride(ModuleContainer module, TypeSpec ts, TypeSpec found) { bool flag = (ts.Modifiers & Modifiers.PUBLIC) != 0 || ts.MemberDefinition.IsInternalAsPublic(module.DeclaringAssembly); bool flag2 = (found.Modifiers & Modifiers.PUBLIC) != 0 || found.MemberDefinition.IsInternalAsPublic(module.DeclaringAssembly); if (flag && !flag2) { return ts; } if (!flag) { return found; } return null; } public void RemoveContainer(TypeContainer tc) { if (types.TryGetValue(tc.MemberName.Name, out var value)) { for (int i = 0; i < value.Count; i++) { if (tc.MemberName.Arity == value[i].Arity) { if (value.Count == 1) { types.Remove(tc.MemberName.Name); } else { value.RemoveAt(i); } break; } } } cached_types.Remove(tc.MemberName.Basename); } public void SetBuiltinType(BuiltinTypeSpec pts) { IList list = types[pts.Name]; cached_types.Remove(pts.Name); if (list.Count == 1) { types[pts.Name][0] = pts; return; } throw new NotImplementedException(); } public void VerifyClsCompliance() { if (types == null || cls_checked) { return; } cls_checked = true; Dictionary> dictionary = new Dictionary>(StringComparer.OrdinalIgnoreCase); foreach (IList value2 in types.Values) { foreach (TypeSpec item in value2) { if ((item.Modifiers & Modifiers.PUBLIC) != 0 && item.IsCLSCompliant()) { if (!dictionary.TryGetValue(item.Name, out var value)) { value = new List(); dictionary.Add(item.Name, value); } value.Add(item); } } } foreach (List value3 in dictionary.Values) { if (value3.Count < 2) { continue; } bool flag = true; foreach (TypeSpec item2 in value3) { flag = item2.Name == value3[0].Name; if (!flag) { break; } } if (flag) { continue; } TypeContainer typeContainer = null; foreach (TypeSpec item3 in value3) { if (!item3.MemberDefinition.IsImported) { typeContainer?.Compiler.Report.SymbolRelatedToPreviousError(typeContainer); typeContainer = item3.MemberDefinition as TypeContainer; } else { typeContainer.Compiler.Report.SymbolRelatedToPreviousError(item3); } } typeContainer.Compiler.Report.Warning(3005, 1, typeContainer.Location, "Identifier `{0}' differing only in case is not CLS-compliant", typeContainer.GetSignatureForError()); } } } internal class CompilationSourceFile : NamespaceContainer { private readonly SourceFile file; private CompileUnitEntry comp_unit; private Dictionary include_files; private Dictionary conditionals; public CompileUnitEntry SymbolUnitEntry => comp_unit; public string FileName => file.Name; public SourceFile SourceFile => file; public CompilationSourceFile(ModuleContainer parent, SourceFile sourceFile) : this(parent) { file = sourceFile; } public CompilationSourceFile(ModuleContainer parent) : base(parent) { } public void AddIncludeFile(SourceFile file) { if (file != this.file) { if (include_files == null) { include_files = new Dictionary(); } if (!include_files.ContainsKey(file.OriginalFullPathName)) { include_files.Add(file.OriginalFullPathName, file); } } } public void AddDefine(string value) { if (conditionals == null) { conditionals = new Dictionary(2); } conditionals[value] = true; } public void AddUndefine(string value) { if (conditionals == null) { conditionals = new Dictionary(2); } conditionals[value] = false; } public override void PrepareEmit() { MonoSymbolFile symbolWriter = Module.DeclaringAssembly.SymbolWriter; if (symbolWriter != null) { CreateUnitSymbolInfo(symbolWriter, Compiler.Settings.PathMap); } base.PrepareEmit(); } private void CreateUnitSymbolInfo(MonoSymbolFile symwriter, List> pathMap) { SourceFileEntry source = file.CreateSymbolInfo(symwriter, pathMap); comp_unit = new CompileUnitEntry(symwriter, source); if (include_files == null) { return; } foreach (SourceFile value in include_files.Values) { source = value.CreateSymbolInfo(symwriter, pathMap); comp_unit.AddFile(source); } } public bool IsConditionalDefined(string value) { if (conditionals != null) { if (conditionals.TryGetValue(value, out var value2)) { return value2; } if (conditionals.ContainsKey(value)) { return false; } } return Compiler.Settings.IsConditionalSymbolDefined(value); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } } internal class NamespaceContainer : TypeContainer, IMemberContext, IModuleContext { private static readonly Namespace[] empty_namespaces = new Namespace[0]; private readonly Namespace ns; public new readonly NamespaceContainer Parent; private List clauses; public bool DeclarationFound; private Namespace[] namespace_using_table; private TypeSpec[] types_using_table; private Dictionary aliases; public override AttributeTargets AttributeTargets { get { throw new NotSupportedException(); } } public override string DocCommentHeader { get { throw new NotSupportedException(); } } public Namespace NS => ns; public List Usings => clauses; public override string[] ValidAttributeTargets { get { throw new NotSupportedException(); } } public NamespaceContainer(MemberName name, NamespaceContainer parent) : base(parent, name, null, MemberKind.Namespace) { Parent = parent; ns = parent.NS.AddNamespace(name); containers = new List(); } protected NamespaceContainer(ModuleContainer parent) : base(parent, null, null, MemberKind.Namespace) { ns = parent.GlobalRootNamespace; containers = new List(2); } public void AddUsing(UsingClause un) { if (DeclarationFound) { Compiler.Report.Error(1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations"); } if (clauses == null) { clauses = new List(); } clauses.Add(un); } public void AddUsing(UsingAliasNamespace un) { if (DeclarationFound) { Compiler.Report.Error(1529, un.Location, "A using clause must precede all other namespace elements except extern alias declarations"); } AddAlias(un); } private void AddAlias(UsingAliasNamespace un) { if (clauses == null) { clauses = new List(); } else { foreach (UsingClause clause in clauses) { if (clause is UsingAliasNamespace usingAliasNamespace && usingAliasNamespace.Alias.Value == un.Alias.Value) { Compiler.Report.SymbolRelatedToPreviousError(usingAliasNamespace.Location, ""); Compiler.Report.Error(1537, un.Location, "The using alias `{0}' appeared previously in this namespace", un.Alias.Value); } } } clauses.Add(un); } public override void AddPartial(TypeDefinition next_part) { TypeSpec typeSpec = ns.LookupType(this, next_part.MemberName.Name, next_part.MemberName.Arity, LookupMode.IgnoreAccessibility, Location.Null); TypeDefinition existing = ((typeSpec != null) ? (typeSpec.MemberDefinition as TypeDefinition) : null); AddPartial(next_part, existing); } public override void AddTypeContainer(TypeContainer tc) { MemberName memberName = tc.MemberName; string key = memberName.Basename; while (memberName.Left != null) { memberName = memberName.Left; key = memberName.Name; } TypeContainer typeContainer = ((Parent == null) ? ((TypeContainer)Module) : ((TypeContainer)this)); if (typeContainer.DefinedNames.TryGetValue(key, out var value)) { if (tc is NamespaceContainer && value is NamespaceContainer) { AddTypeContainerMember(tc); return; } base.Report.SymbolRelatedToPreviousError(value); if ((value.ModFlags & Modifiers.PARTIAL) != 0 && (tc is ClassOrStruct || tc is Interface)) { Error_MissingPartialModifier(tc); } else { base.Report.Error(101, tc.Location, "The namespace `{0}' already contains a definition for `{1}'", GetSignatureForError(), memberName.GetSignatureForError()); } } else { typeContainer.DefinedNames.Add(key, tc); TypeDefinition partialContainer = tc.PartialContainer; if (partialContainer != null) { IList allTypes = ns.GetAllTypes(memberName.Name); if (allTypes != null) { foreach (TypeSpec item in allTypes) { if (item.Arity == memberName.Arity) { value = (MemberCore)item.MemberDefinition; break; } } } if (value != null) { base.Report.SymbolRelatedToPreviousError(value); base.Report.Error(101, tc.Location, "The namespace `{0}' already contains a definition for `{1}'", GetSignatureForError(), memberName.GetSignatureForError()); } else { ns.AddType(Module, partialContainer.Definition); } } } base.AddTypeContainer(tc); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { throw new NotSupportedException(); } public override void EmitContainer() { VerifyClsCompliance(); base.EmitContainer(); } public ExtensionMethodCandidates LookupExtensionMethod(IMemberContext invocationContext, string name, int arity, int position) { NamespaceContainer namespaceContainer = this; do { ExtensionMethodCandidates extensionMethodCandidates = namespaceContainer.LookupExtensionMethodCandidates(invocationContext, name, arity, ref position); if (extensionMethodCandidates != null || namespaceContainer.MemberName == null) { return extensionMethodCandidates; } Namespace parent = namespaceContainer.ns.Parent; MemberName left = namespaceContainer.MemberName.Left; int num = position - 2; while (num-- > 0) { left = left.Left; parent = parent.Parent; } while (left != null) { position++; List list = parent.LookupExtensionMethod(invocationContext, name, arity); if (list != null) { return new ExtensionMethodCandidates(invocationContext, list, namespaceContainer, position); } left = left.Left; parent = parent.Parent; } position = 0; namespaceContainer = namespaceContainer.Parent; } while (namespaceContainer != null); return null; } private ExtensionMethodCandidates LookupExtensionMethodCandidates(IMemberContext invocationContext, string name, int arity, ref int position) { List list = null; if (position == 0) { position++; list = ns.LookupExtensionMethod(invocationContext, name, arity); if (list != null) { return new ExtensionMethodCandidates(invocationContext, list, this, position); } } if (position == 1) { position++; Namespace[] array = namespace_using_table; foreach (Namespace obj in array) { List list2 = obj.LookupExtensionMethod(invocationContext, name, arity); if (list2 != null) { if (list == null) { list = list2; } else { list.AddRange(list2); } } } if (types_using_table != null) { TypeSpec[] array2 = types_using_table; foreach (TypeSpec typeSpec in array2) { List list3 = typeSpec.MemberCache.FindExtensionMethods(invocationContext, name, arity); if (list3 != null) { if (list == null) { list = list3; } else { list.AddRange(list3); } } } } if (list != null) { return new ExtensionMethodCandidates(invocationContext, list, this, position); } } return null; } public override FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { for (NamespaceContainer namespaceContainer = this; namespaceContainer != null; namespaceContainer = namespaceContainer.Parent) { FullNamedExpression fullNamedExpression = namespaceContainer.Lookup(name, arity, mode, loc); if (fullNamedExpression != null || namespaceContainer.MemberName == null) { return fullNamedExpression; } Namespace parent = namespaceContainer.ns.Parent; MemberName left = namespaceContainer.MemberName.Left; while (left != null) { fullNamedExpression = parent.LookupTypeOrNamespace(this, name, arity, mode, loc); if (fullNamedExpression != null) { return fullNamedExpression; } left = left.Left; parent = parent.Parent; } } return null; } public override void GetCompletionStartingWith(string prefix, List results) { if (Usings == null) { return; } foreach (UsingClause @using in Usings) { if (@using.Alias == null) { string name = @using.NamespaceExpression.Name; if (name.StartsWith(prefix)) { results.Add(name); } } } IEnumerable enumerable = Enumerable.Empty(); Namespace[] array = namespace_using_table; foreach (Namespace obj in array) { if (prefix.StartsWith(obj.Name)) { int num = prefix.LastIndexOf('.'); if (num != -1) { string prefix2 = prefix.Substring(num + 1); enumerable = enumerable.Concat(obj.CompletionGetTypesStartingWith(prefix2)); } } enumerable = enumerable.Concat(obj.CompletionGetTypesStartingWith(prefix)); } results.AddRange(enumerable); base.GetCompletionStartingWith(prefix, results); } public FullNamedExpression LookupExternAlias(string name) { if (aliases == null) { return null; } if (aliases.TryGetValue(name, out var value) && value is UsingExternAlias) { return value.ResolvedExpression; } return null; } public override FullNamedExpression LookupNamespaceAlias(string name) { for (NamespaceContainer namespaceContainer = this; namespaceContainer != null; namespaceContainer = namespaceContainer.Parent) { if (namespaceContainer.aliases != null && namespaceContainer.aliases.TryGetValue(name, out var value)) { if (value.ResolvedExpression == null) { value.Define(namespaceContainer); } return value.ResolvedExpression; } } return null; } private FullNamedExpression Lookup(string name, int arity, LookupMode mode, Location loc) { FullNamedExpression fullNamedExpression = ns.LookupTypeOrNamespace(this, name, arity, mode, loc); if (aliases != null && arity == 0 && aliases.TryGetValue(name, out var value)) { if (fullNamedExpression != null && mode != LookupMode.Probing) { Compiler.Report.SymbolRelatedToPreviousError(value.Location, null); Compiler.Report.Error(576, loc, "Namespace `{0}' contains a definition with same name as alias `{1}'", GetSignatureForError(), name); } if (value.ResolvedExpression == null) { value.Define(this); } return value.ResolvedExpression; } if (fullNamedExpression != null) { return fullNamedExpression; } if (namespace_using_table == null) { DoDefineNamespace(); } FullNamedExpression fullNamedExpression2 = null; Namespace[] array = namespace_using_table; foreach (Namespace obj in array) { TypeSpec typeSpec = obj.LookupType(this, name, arity, mode, loc); if (typeSpec == null) { continue; } fullNamedExpression = new TypeExpression(typeSpec, loc); if (fullNamedExpression2 == null) { fullNamedExpression2 = fullNamedExpression; continue; } TypeExpr typeExpr = fullNamedExpression as TypeExpr; TypeExpr typeExpr2 = fullNamedExpression2 as TypeExpr; if (typeExpr != null && typeExpr2 == null) { fullNamedExpression2 = fullNamedExpression; } else { if (typeExpr == null) { continue; } TypeSpec typeSpec2 = Namespace.IsImportedTypeOverride(Module, typeExpr2.Type, typeExpr.Type); if (typeSpec2 == null) { if (mode == LookupMode.Normal) { Error_AmbiguousReference(name, typeExpr2, typeExpr, loc); } return fullNamedExpression2; } if (typeSpec2 == typeExpr.Type) { fullNamedExpression2 = typeExpr; } } } if (types_using_table != null && (mode & LookupMode.IgnoreStaticUsing) == 0) { TypeSpec[] array2 = types_using_table; foreach (TypeSpec container in array2) { TypeSpec typeSpec3 = MemberCache.FindNestedType(container, name, arity, declaredOnlyClass: true); if (typeSpec3 != null) { fullNamedExpression = new TypeExpression(typeSpec3, loc); if (fullNamedExpression2 == null) { fullNamedExpression2 = fullNamedExpression; } else if (mode == LookupMode.Normal) { Error_AmbiguousReference(name, fullNamedExpression2, fullNamedExpression, loc); } } } } return fullNamedExpression2; } private void Error_AmbiguousReference(string name, FullNamedExpression a, FullNamedExpression b, Location loc) { Report report = Compiler.Report; report.SymbolRelatedToPreviousError(a.Type); report.SymbolRelatedToPreviousError(b.Type); report.Error(104, loc, "`{0}' is an ambiguous reference between `{1}' and `{2}'", name, a.GetSignatureForError(), b.GetSignatureForError()); } public static Expression LookupStaticUsings(IMemberContext mc, string name, int arity, Location loc) { for (MemberCore memberCore = mc.CurrentMemberDefinition; memberCore != null; memberCore = memberCore.Parent) { if (memberCore is NamespaceContainer namespaceContainer) { List list = null; if (namespaceContainer.types_using_table != null) { TypeSpec[] array = namespaceContainer.types_using_table; foreach (TypeSpec container in array) { IList list2 = MemberCache.FindMembers(container, name, declaredOnlyClass: true); if (list2 == null) { continue; } foreach (MemberSpec item in list2) { if (((item.Kind & MemberKind.NestedMask) != 0 || ((item.Modifiers & Modifiers.STATIC) != 0 && (item.Modifiers & Modifiers.METHOD_EXTENSION) == 0)) && (arity <= 0 || item.Arity == arity)) { if (list == null) { list = new List(); } list.Add(item); } } } } if (list != null) { Expression expression = Expression.MemberLookupToExpression(mc, list, errorMode: false, null, name, arity, Expression.MemberLookupRestrictions.None, loc); if (expression != null) { return expression; } } } } return null; } protected override void DefineNamespace() { if (namespace_using_table == null) { DoDefineNamespace(); } base.DefineNamespace(); } private void DoDefineNamespace() { namespace_using_table = empty_namespaces; if (clauses == null) { return; } List list = null; List list2 = null; bool flag = false; for (int i = 0; i < clauses.Count; i++) { UsingClause usingClause = clauses[i]; if (usingClause.Alias != null) { if (aliases == null) { aliases = new Dictionary(); } if (usingClause is UsingExternAlias) { usingClause.Define(this); if (usingClause.ResolvedExpression != null) { aliases.Add(usingClause.Alias.Value, (UsingExternAlias)usingClause); } clauses.RemoveAt(i--); } else { flag = true; } continue; } try { usingClause.Define(this); } finally { if (usingClause.ResolvedExpression == null) { clauses.RemoveAt(i--); } } if (usingClause.ResolvedExpression == null) { continue; } if (!(usingClause.ResolvedExpression is NamespaceExpression namespaceExpression)) { TypeSpec type = usingClause.ResolvedExpression.Type; if (list2 == null) { list2 = new List(); } if (list2.Contains(type)) { Warning_DuplicateEntry(usingClause); } else { list2.Add(type); } } else { if (list == null) { list = new List(); } if (list.Contains(namespaceExpression.Namespace)) { clauses.RemoveAt(i--); Warning_DuplicateEntry(usingClause); } else { list.Add(namespaceExpression.Namespace); } } } namespace_using_table = ((list == null) ? new Namespace[0] : list.ToArray()); if (list2 != null) { types_using_table = list2.ToArray(); } if (!flag) { return; } for (int j = 0; j < clauses.Count; j++) { UsingClause usingClause2 = clauses[j]; if (usingClause2.Alias != null) { aliases[usingClause2.Alias.Value] = (UsingAliasNamespace)usingClause2; } } } protected override void DoDefineContainer() { base.DoDefineContainer(); if (clauses == null) { return; } for (int i = 0; i < clauses.Count; i++) { UsingClause usingClause = clauses[i]; if (usingClause.Alias != null && usingClause.ResolvedExpression == null) { usingClause.Define(this); } } } public void EnableRedefinition() { is_defined = false; namespace_using_table = null; } public override string GetSignatureForError() { return (base.MemberName == null) ? "global::" : base.GetSignatureForError(); } public override void RemoveContainer(TypeContainer cont) { base.RemoveContainer(cont); NS.RemoveContainer(cont); } protected override bool VerifyClsCompliance() { if (Module.IsClsComplianceRequired()) { if (base.MemberName != null && base.MemberName.Name[0] == '_') { Warning_IdentifierNotCompliant(); } ns.VerifyClsCompliance(); return true; } return false; } private void Warning_DuplicateEntry(UsingClause entry) { Compiler.Report.Warning(105, 3, entry.Location, "The using directive for `{0}' appeared previously in this namespace", entry.ResolvedExpression.GetSignatureForError()); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } } internal class UsingNamespace : UsingClause { public UsingNamespace(ATypeNameExpression expr, Location loc) : base(expr, loc) { } public override void Define(NamespaceContainer ctx) { base.Define(ctx); NamespaceExpression namespaceExpression = resolved as NamespaceExpression; if (namespaceExpression == null && resolved != null) { CompilerContext compiler = ctx.Module.Compiler; TypeSpec type = resolved.Type; resolved = null; compiler.Report.SymbolRelatedToPreviousError(type); compiler.Report.Error(138, base.Location, "A `using' directive can only be applied to namespaces but `{0}' denotes a type. Consider using a `using static' instead", type.GetSignatureForError()); } } } internal class UsingType : UsingClause { public UsingType(ATypeNameExpression expr, Location loc) : base(expr, loc) { } public override void Define(NamespaceContainer ctx) { base.Define(ctx); if (resolved != null && resolved is NamespaceExpression namespaceExpression) { CompilerContext compiler = ctx.Module.Compiler; compiler.Report.Error(7007, base.Location, "A 'using static' directive can only be applied to types but `{0}' denotes a namespace. Consider using a `using' directive instead", namespaceExpression.GetSignatureForError()); } } } internal class UsingClause { private readonly ATypeNameExpression expr; private readonly Location loc; protected FullNamedExpression resolved; public virtual SimpleMemberName Alias => null; public Location Location => loc; public ATypeNameExpression NamespaceExpression => expr; public FullNamedExpression ResolvedExpression => resolved; public UsingClause(ATypeNameExpression expr, Location loc) { this.expr = expr; this.loc = loc; } public string GetSignatureForError() { return expr.GetSignatureForError(); } public virtual void Define(NamespaceContainer ctx) { resolved = expr.ResolveAsTypeOrNamespace(ctx, allowUnboundTypeArguments: false); } public override string ToString() { return resolved.ToString(); } } internal class UsingExternAlias : UsingAliasNamespace { public UsingExternAlias(SimpleMemberName alias, Location loc) : base(alias, null, loc) { } public override void Define(NamespaceContainer ctx) { RootNamespace rootNamespace = ctx.Module.GetRootNamespace(Alias.Value); if (rootNamespace == null) { ctx.Module.Compiler.Report.Error(430, base.Location, "The extern alias `{0}' was not specified in -reference option", Alias.Value); } else { resolved = new NamespaceExpression(rootNamespace, base.Location); } } } internal class UsingAliasNamespace : UsingNamespace { public struct AliasContext : IMemberContext, IModuleContext { private readonly NamespaceContainer ns; public TypeSpec CurrentType => null; public TypeParameters CurrentTypeParameters => null; public MemberCore CurrentMemberDefinition => null; public bool IsObsolete => false; public bool IsUnsafe { get { throw new NotImplementedException(); } } public bool IsStatic { get { throw new NotImplementedException(); } } public ModuleContainer Module => ns.Module; public AliasContext(NamespaceContainer ns) { this.ns = ns; } public string GetSignatureForError() { throw new NotImplementedException(); } public ExtensionMethodCandidates LookupExtensionMethod(string name, int arity) { return null; } public FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { FullNamedExpression fullNamedExpression = ns.NS.LookupTypeOrNamespace(ns, name, arity, mode, loc); if (fullNamedExpression != null) { return fullNamedExpression; } fullNamedExpression = ns.LookupExternAlias(name); if (fullNamedExpression != null || ns.MemberName == null) { return fullNamedExpression; } Namespace parent = ns.NS.Parent; MemberName left = ns.MemberName.Left; while (left != null) { fullNamedExpression = parent.LookupTypeOrNamespace(this, name, arity, mode, loc); if (fullNamedExpression != null) { return fullNamedExpression; } left = left.Left; parent = parent.Parent; } if (ns.Parent != null) { return ns.Parent.LookupNamespaceOrType(name, arity, mode, loc); } return null; } public FullNamedExpression LookupNamespaceAlias(string name) { return ns.LookupNamespaceAlias(name); } } private readonly SimpleMemberName alias; public override SimpleMemberName Alias => alias; public UsingAliasNamespace(SimpleMemberName alias, ATypeNameExpression expr, Location loc) : base(expr, loc) { this.alias = alias; } public override void Define(NamespaceContainer ctx) { resolved = base.NamespaceExpression.ResolveAsTypeOrNamespace(new AliasContext(ctx), allowUnboundTypeArguments: false) ?? new TypeExpression(InternalType.ErrorType, base.NamespaceExpression.Location); } } internal abstract class ParameterBase : Attributable { protected ParameterBuilder builder; public ParameterBuilder Builder => builder; public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.HasSecurityAttribute) { a.Error_InvalidSecurityParent(); } else if (a.Type == pa.Dynamic) { a.Error_MisusedDynamicAttribute(); } else { builder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } } public override bool IsClsComplianceRequired() { return false; } } internal class ReturnParameter : ParameterBase { private MemberCore method; public override AttributeTargets AttributeTargets => AttributeTargets.ReturnValue; public override string[] ValidAttributeTargets => null; public ReturnParameter(MemberCore method, MethodBuilder mb, Location location) { this.method = method; try { builder = mb.DefineParameter(0, ParameterAttributes.None, ""); } catch (ArgumentOutOfRangeException) { method.Compiler.Report.RuntimeMissingSupport(location, "custom attributes on the return type"); } } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.CLSCompliant) { method.Compiler.Report.Warning(3023, 1, a.Location, "CLSCompliant attribute has no meaning when applied to return types. Try putting it on the method instead"); } if (builder != null) { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } } internal class ImplicitLambdaParameter : Parameter { public ImplicitLambdaParameter(string name, Location loc) : base(null, name, Modifier.NONE, null, loc) { } public override TypeSpec Resolve(IMemberContext ec, int index) { if (parameter_type == null) { throw new InternalErrorException("A type of implicit lambda parameter `{0}' is not set", base.Name); } idx = index; return parameter_type; } public void SetParameterType(TypeSpec type) { parameter_type = type; } } internal class ParamsParameter : Parameter { private bool ParamsAttributeEmit; public ParamsParameter(FullNamedExpression type, string name, Attributes attrs, Location loc) : base(type, name, Modifier.PARAMS, attrs, loc) { } public override TypeSpec Resolve(IMemberContext ec, int index) { if (base.Resolve(ec, index) == null) { return null; } if (!(parameter_type is ArrayContainer { Rank: 1 })) { ec.Module.Compiler.Report.Error(225, base.Location, "The params parameter must be a single dimensional array"); return null; } MemberCore memberCore = ec as MemberCore; ParamsAttributeEmit = memberCore == null || (memberCore.ModFlags & Modifiers.OVERRIDE) == 0; return parameter_type; } public override void ApplyAttributes(MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa) { base.ApplyAttributes(mb, cb, index, pa); if (ParamsAttributeEmit) { pa.ParamArray.EmitAttribute(builder); } } } internal class ArglistParameter : Parameter { public ArglistParameter(Location loc) : base(null, string.Empty, Modifier.NONE, null, loc) { parameter_type = InternalType.Arglist; } public override void ApplyAttributes(MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa) { } public override bool CheckAccessibility(InterfaceMemberBase member) { return true; } public override TypeSpec Resolve(IMemberContext ec, int index) { return parameter_type; } } internal interface IParameterData { Expression DefaultValue { get; } bool HasExtensionMethodModifier { get; } bool HasDefaultValue { get; } Parameter.Modifier ModFlags { get; } string Name { get; } } internal class Parameter : ParameterBase, IParameterData, ILocalVariable { [Flags] public enum Modifier : byte { NONE = 0, PARAMS = 1, REF = 2, OUT = 4, This = 8, ReadOnly = 0x10, CallerMemberName = 0x20, CallerLineNumber = 0x40, CallerFilePath = 0x80, RefOutMask = 6, ModifierMask = 0x1F, CallerMask = 0xE0 } private static readonly string[] attribute_targets = new string[1] { "param" }; private FullNamedExpression texpr; private Modifier modFlags; private string name; private Expression default_expr; protected TypeSpec parameter_type; private readonly Location loc; protected int idx; public bool HasAddressTaken; private TemporaryVariableReference expr_tree_variable; private HoistedParameter hoisted_variant; public Expression DefaultExpression => default_expr; public DefaultParameterValueExpression DefaultValue { get { return default_expr as DefaultParameterValueExpression; } set { default_expr = value; } } Expression IParameterData.DefaultValue => (!(default_expr is DefaultParameterValueExpression defaultParameterValueExpression)) ? default_expr : defaultParameterValueExpression.Child; private bool HasOptionalExpression => default_expr is DefaultParameterValueExpression; public Location Location => loc; public Modifier ParameterModifier => modFlags; public TypeSpec Type { get { return parameter_type; } set { parameter_type = value; } } public FullNamedExpression TypeExpression => texpr; public override string[] ValidAttributeTargets => attribute_targets; public bool HasDefaultValue => default_expr != null; public bool HasExtensionMethodModifier => (modFlags & Modifier.This) != 0; public HoistedParameter HoistedVariant { get { return hoisted_variant; } set { hoisted_variant = value; } } public Modifier ModFlags => modFlags & ~Modifier.This; public string Name { get { return name; } set { name = value; } } public override AttributeTargets AttributeTargets => AttributeTargets.Parameter; public Parameter(FullNamedExpression type, string name, Modifier mod, Attributes attrs, Location loc) { this.name = name; modFlags = mod; this.loc = loc; texpr = type; attributes = attrs; } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.In && ModFlags == Modifier.OUT) { a.Report.Error(36, a.Location, "An out parameter cannot have the `In' attribute"); return; } if (a.Type == pa.ParamArray) { a.Report.Error(674, a.Location, "Do not use `System.ParamArrayAttribute'. Use the `params' keyword instead"); return; } if (a.Type == pa.Out && (ModFlags & Modifier.REF) != Modifier.NONE && !base.OptAttributes.Contains(pa.In)) { a.Report.Error(662, a.Location, "Cannot specify only `Out' attribute on a ref parameter. Use both `In' and `Out' attributes or neither"); return; } if (a.Type == pa.CLSCompliant) { a.Report.Warning(3022, 1, a.Location, "CLSCompliant attribute has no meaning when applied to parameters. Try putting it on the method instead"); } else if (a.Type == pa.DefaultParameterValue || a.Type == pa.OptionalParameter) { if (HasOptionalExpression) { a.Report.Error(1745, a.Location, "Cannot specify `{0}' attribute on optional parameter `{1}'", a.Type.GetSignatureForError().Replace("Attribute", ""), Name); } if (a.Type == pa.DefaultParameterValue) { return; } } else if (a.Type == pa.CallerMemberNameAttribute) { if ((modFlags & Modifier.CallerMemberName) == 0) { a.Report.Error(4022, a.Location, "The CallerMemberName attribute can only be applied to parameters with default value"); } } else if (a.Type == pa.CallerLineNumberAttribute) { if ((modFlags & Modifier.CallerLineNumber) == 0) { a.Report.Error(4020, a.Location, "The CallerLineNumber attribute can only be applied to parameters with default value"); } } else if (a.Type == pa.CallerFilePathAttribute && (modFlags & Modifier.CallerFilePath) == 0) { a.Report.Error(4021, a.Location, "The CallerFilePath attribute can only be applied to parameters with default value"); } base.ApplyAttributeBuilder(a, ctor, cdata, pa); } public virtual bool CheckAccessibility(InterfaceMemberBase member) { if (parameter_type == null) { return true; } return member.IsAccessibleAs(parameter_type); } private bool IsValidCallerContext(MemberCore memberContext) { if (memberContext is Method method) { return !method.IsPartialImplementation; } return true; } public virtual TypeSpec Resolve(IMemberContext rc, int index) { if (parameter_type != null) { return parameter_type; } if (attributes != null) { attributes.AttachTo(this, rc); } parameter_type = texpr.ResolveAsType(rc); if (parameter_type == null) { return null; } idx = index; if ((modFlags & Modifier.RefOutMask) != Modifier.NONE && parameter_type.IsSpecialRuntimeType) { rc.Module.Compiler.Report.Error(1601, Location, "Method or delegate parameter cannot be of type `{0}'", GetSignatureForError()); return null; } VarianceDecl.CheckTypeVariance(parameter_type, ((modFlags & Modifier.RefOutMask) == 0) ? Variance.Contravariant : Variance.None, rc); if (parameter_type.IsStatic) { rc.Module.Compiler.Report.Error(721, Location, "`{0}': static types cannot be used as parameters", texpr.GetSignatureForError()); return parameter_type; } if ((modFlags & Modifier.This) != Modifier.NONE && (parameter_type.IsPointer || parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)) { rc.Module.Compiler.Report.Error(1103, Location, "The extension method cannot be of type `{0}'", parameter_type.GetSignatureForError()); } return parameter_type; } private void ResolveCallerAttributes(ResolveContext rc) { PredefinedAttributes predefinedAttributes = rc.Module.PredefinedAttributes; Attribute attribute = null; Attribute attribute2 = null; foreach (Attribute attr in attributes.Attrs) { TypeSpec typeSpec = attr.ResolveTypeForComparison(); if (typeSpec == null) { continue; } if (typeSpec == predefinedAttributes.CallerMemberNameAttribute) { TypeSpec typeSpec2 = rc.BuiltinTypes.String; if (typeSpec2 != parameter_type && !Convert.ImplicitReferenceConversionExists(typeSpec2, parameter_type)) { rc.Report.Error(4019, attr.Location, "The CallerMemberName attribute cannot be applied because there is no standard conversion from `{0}' to `{1}'", typeSpec2.GetSignatureForError(), parameter_type.GetSignatureForError()); } if (!IsValidCallerContext(rc.CurrentMemberDefinition)) { rc.Report.Warning(4026, 1, attr.Location, "The CallerMemberName applied to parameter `{0}' will have no effect because it applies to a member that is used in context that do not allow optional arguments", name); } modFlags |= Modifier.CallerMemberName; attribute = attr; } else if (typeSpec == predefinedAttributes.CallerLineNumberAttribute) { TypeSpec typeSpec2 = rc.BuiltinTypes.Int; if (typeSpec2 != parameter_type && !Convert.ImplicitStandardConversionExists(new IntConstant(typeSpec2, int.MaxValue, Location.Null), parameter_type)) { rc.Report.Error(4017, attr.Location, "The CallerLineNumberAttribute attribute cannot be applied because there is no standard conversion from `{0}' to `{1}'", typeSpec2.GetSignatureForError(), parameter_type.GetSignatureForError()); } if (!IsValidCallerContext(rc.CurrentMemberDefinition)) { rc.Report.Warning(4024, 1, attr.Location, "The CallerLineNumberAttribute applied to parameter `{0}' will have no effect because it applies to a member that is used in context that do not allow optional arguments", name); } modFlags |= Modifier.CallerLineNumber; } else if (typeSpec == predefinedAttributes.CallerFilePathAttribute) { TypeSpec typeSpec2 = rc.BuiltinTypes.String; if (typeSpec2 != parameter_type && !Convert.ImplicitReferenceConversionExists(typeSpec2, parameter_type)) { rc.Report.Error(4018, attr.Location, "The CallerFilePath attribute cannot be applied because there is no standard conversion from `{0}' to `{1}'", typeSpec2.GetSignatureForError(), parameter_type.GetSignatureForError()); } if (!IsValidCallerContext(rc.CurrentMemberDefinition)) { rc.Report.Warning(4025, 1, attr.Location, "The CallerFilePath applied to parameter `{0}' will have no effect because it applies to a member that is used in context that do not allow optional arguments", name); } modFlags |= Modifier.CallerFilePath; attribute2 = attr; } } if ((modFlags & Modifier.CallerLineNumber) != Modifier.NONE) { if (attribute != null) { rc.Report.Warning(7081, 1, attribute.Location, "The CallerMemberNameAttribute applied to parameter `{0}' will have no effect. It is overridden by the CallerLineNumberAttribute", Name); } if (attribute2 != null) { rc.Report.Warning(7082, 1, attribute2.Location, "The CallerFilePathAttribute applied to parameter `{0}' will have no effect. It is overridden by the CallerLineNumberAttribute", name); } } if ((modFlags & Modifier.CallerMemberName) != Modifier.NONE && attribute2 != null) { rc.Report.Warning(7080, 1, attribute2.Location, "The CallerMemberNameAttribute applied to parameter `{0}' will have no effect. It is overridden by the CallerFilePathAttribute", name); } } public void ResolveDefaultValue(ResolveContext rc) { if (default_expr != null) { ((DefaultParameterValueExpression)default_expr).Resolve(rc, this); if (attributes != null) { ResolveCallerAttributes(rc); } } else { if (attributes == null) { return; } PredefinedAttributes predefinedAttributes = rc.Module.PredefinedAttributes; Attribute attribute = attributes.Search(predefinedAttributes.DefaultParameterValue); if (attribute != null) { if (attribute.Resolve() == null) { return; } Expression parameterDefaultValue = attribute.GetParameterDefaultValue(); if (parameterDefaultValue == null) { return; } ResolveContext resolveContext = attribute.CreateResolveContext(); default_expr = parameterDefaultValue.Resolve(resolveContext); if (default_expr is BoxedCast) { default_expr = ((BoxedCast)default_expr).Child; } if (!(default_expr is Constant)) { if (parameter_type.BuiltinType == BuiltinTypeSpec.Type.Object) { rc.Report.Error(1910, default_expr.Location, "Argument of type `{0}' is not applicable for the DefaultParameterValue attribute", default_expr.Type.GetSignatureForError()); } else { rc.Report.Error(1909, default_expr.Location, "The DefaultParameterValue attribute is not applicable on parameters of type `{0}'", default_expr.Type.GetSignatureForError()); } default_expr = null; } else if (!TypeSpecComparer.IsEqual(default_expr.Type, parameter_type) && (!(default_expr is NullConstant) || !TypeSpec.IsReferenceType(parameter_type) || parameter_type.IsGenericParameter) && parameter_type.BuiltinType != BuiltinTypeSpec.Type.Object && parameter_type.BuiltinType != BuiltinTypeSpec.Type.Dynamic) { Expression expression = Convert.ImplicitUserConversion(resolveContext, default_expr, parameter_type, loc); if (expression == null || !TypeSpecComparer.IsEqual(expression.Type, parameter_type)) { rc.Report.Error(1908, default_expr.Location, "The type of the default value should match the type of the parameter"); } } } else { Attribute attribute2 = attributes.Search(predefinedAttributes.OptionalParameter); if (attribute2 != null) { default_expr = EmptyExpression.MissingValue; } } } } public void Error_DuplicateName(Report r) { r.Error(100, Location, "The parameter name `{0}' is a duplicate", Name); } public virtual string GetSignatureForError() { string text = ((parameter_type == null) ? texpr.GetSignatureForError() : parameter_type.GetSignatureForError()); string modifierSignature = GetModifierSignature(modFlags); if (modifierSignature.Length > 0) { return modifierSignature + " " + text; } return text; } public static string GetModifierSignature(Modifier mod) { return mod switch { Modifier.OUT => "out", Modifier.PARAMS => "params", Modifier.REF => "ref", Modifier.This => "this", _ => "", }; } public void IsClsCompliant(IMemberContext ctx) { if (!parameter_type.IsCLSCompliant()) { ctx.Module.Compiler.Report.Warning(3001, 1, Location, "Argument type `{0}' is not CLS-compliant", parameter_type.GetSignatureForError()); } } public virtual void ApplyAttributes(MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa) { if (builder != null) { throw new InternalErrorException("builder already exists"); } ParameterAttributes parameterAttributes = AParametersCollection.GetParameterAttribute(modFlags); if (HasOptionalExpression) { parameterAttributes |= ParameterAttributes.Optional; } if ((object)mb == null) { builder = cb.DefineParameter(index, parameterAttributes, Name); } else { builder = mb.DefineParameter(index, parameterAttributes, Name); } if (base.OptAttributes != null) { base.OptAttributes.Emit(); } if (HasDefaultValue && default_expr.Type != null) { DefaultParameterValueExpression defaultValue = DefaultValue; Constant constant = ((defaultValue != null) ? (defaultValue.Child as Constant) : (default_expr as Constant)); if (constant != null) { if (constant.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { pa.DecimalConstant.EmitAttribute(builder, (decimal)constant.GetValue(), constant.Location); } else { builder.SetConstant(constant.GetValue()); } } else if (default_expr.Type.IsStruct || default_expr.Type.IsGenericParameter) { builder.SetConstant(null); } } if (parameter_type != null) { if (parameter_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { pa.Dynamic.EmitAttribute(builder); } else if (parameter_type.HasDynamicElement) { pa.Dynamic.EmitAttribute(builder, parameter_type, Location); } if (parameter_type.HasNamedTupleElement) { pa.TupleElementNames.EmitAttribute(builder, parameter_type, Location); } } } public Parameter Clone() { Parameter parameter = (Parameter)MemberwiseClone(); if (attributes != null) { parameter.attributes = attributes.Clone(); } return parameter; } public ExpressionStatement CreateExpressionTreeVariable(BlockContext ec) { if ((modFlags & Modifier.RefOutMask) != Modifier.NONE) { ec.Report.Error(1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier"); } expr_tree_variable = TemporaryVariableReference.Create(ResolveParameterExpressionType(ec, Location).Type, ec.CurrentBlock.ParametersBlock, Location); expr_tree_variable = (TemporaryVariableReference)expr_tree_variable.Resolve(ec); Arguments arguments = new Arguments(2); arguments.Add(new Argument(new TypeOf(parameter_type, Location))); arguments.Add(new Argument(new StringConstant(ec.BuiltinTypes, Name, Location))); return new SimpleAssign(ExpressionTreeVariableReference(), Expression.CreateExpressionFactoryCall(ec, "Parameter", null, arguments, Location)); } public void Emit(EmitContext ec) { ec.EmitArgumentLoad(idx); } public void EmitAssign(EmitContext ec) { ec.EmitArgumentStore(idx); } public void EmitAddressOf(EmitContext ec) { if ((ModFlags & Modifier.RefOutMask) != Modifier.NONE) { ec.EmitArgumentLoad(idx); } else { ec.EmitArgumentAddress(idx); } } public TemporaryVariableReference ExpressionTreeVariableReference() { return expr_tree_variable; } public static TypeExpr ResolveParameterExpressionType(IMemberContext ec, Location location) { TypeSpec t = ec.Module.PredefinedTypes.ParameterExpression.Resolve(); return new TypeExpression(t, location); } public void SetIndex(int index) { idx = index; } public void Warning_UselessOptionalParameter(Report Report) { Report.Warning(1066, 1, Location, "The default value specified for optional parameter `{0}' will never be used", Name); } } internal class ParameterData : IParameterData { private readonly string name; private readonly Parameter.Modifier modifiers; private readonly Expression default_value; public Expression DefaultValue => default_value; public bool HasExtensionMethodModifier => (modifiers & Parameter.Modifier.This) != 0; public bool HasDefaultValue => default_value != null; public Parameter.Modifier ModFlags => modifiers; public string Name => name; public ParameterData(string name, Parameter.Modifier modifiers) { this.name = name; this.modifiers = modifiers; } public ParameterData(string name, Parameter.Modifier modifiers, Expression defaultValue) : this(name, modifiers) { default_value = defaultValue; } } internal abstract class AParametersCollection { protected bool has_arglist; protected bool has_params; protected IParameterData[] parameters; protected TypeSpec[] types; public CallingConventions CallingConvention => (!has_arglist) ? CallingConventions.Standard : CallingConventions.VarArgs; public int Count => parameters.Length; public TypeSpec ExtensionMethodType { get { if (Count == 0) { return null; } return FixedParameters[0].HasExtensionMethodModifier ? types[0] : null; } } public IParameterData[] FixedParameters => parameters; public bool HasArglist => has_arglist; public bool HasExtensionMethodType { get { if (Count == 0) { return false; } return FixedParameters[0].HasExtensionMethodModifier; } } public bool HasParams => has_params; public bool IsEmpty => parameters.Length == 0; public TypeSpec[] Types { get { return types; } set { types = value; } } public static ParameterAttributes GetParameterAttribute(Parameter.Modifier modFlags) { return ((modFlags & Parameter.Modifier.OUT) != Parameter.Modifier.NONE) ? ParameterAttributes.Out : ParameterAttributes.None; } public Type[] GetMetaInfo() { Type[] array; if (has_arglist) { if (Count == 1) { return Type.EmptyTypes; } array = new Type[Count - 1]; } else { if (Count == 0) { return Type.EmptyTypes; } array = new Type[Count]; } for (int i = 0; i < array.Length; i++) { array[i] = Types[i].GetMetaInfo(); if ((FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { array[i] = array[i].MakeByRefType(); } } return array; } public int GetParameterIndexByName(string name) { for (int i = 0; i < Count; i++) { if (parameters[i].Name == name) { return i; } } return -1; } public string GetSignatureForDocumentation() { if (IsEmpty) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder("("); for (int i = 0; i < Count; i++) { if (i != 0) { stringBuilder.Append(","); } stringBuilder.Append(types[i].GetSignatureForDocumentation()); if ((parameters[i].ModFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { stringBuilder.Append("@"); } } stringBuilder.Append(")"); return stringBuilder.ToString(); } public string GetSignatureForError() { return GetSignatureForError("(", ")", Count); } public string GetSignatureForError(string start, string end, int count) { StringBuilder stringBuilder = new StringBuilder(start); for (int i = 0; i < count; i++) { if (i != 0) { stringBuilder.Append(", "); } stringBuilder.Append(ParameterDesc(i)); } stringBuilder.Append(end); return stringBuilder.ToString(); } public static bool HasSameParameterDefaults(AParametersCollection a, AParametersCollection b) { if (a == null) { return b == null; } for (int i = 0; i < a.Count; i++) { if (a.FixedParameters[i].HasDefaultValue != b.FixedParameters[i].HasDefaultValue) { return false; } } return true; } public AParametersCollection Inflate(TypeParameterInflator inflator) { TypeSpec[] array = null; bool flag = false; for (int i = 0; i < Count; i++) { TypeSpec typeSpec = inflator.Inflate(types[i]); if (array == null) { if (typeSpec == types[i]) { continue; } flag |= FixedParameters[i].HasDefaultValue; array = new TypeSpec[types.Length]; Array.Copy(types, array, types.Length); } else { if (typeSpec == types[i]) { continue; } flag |= FixedParameters[i].HasDefaultValue; } array[i] = typeSpec; } if (array == null) { return this; } AParametersCollection aParametersCollection = (AParametersCollection)MemberwiseClone(); aParametersCollection.types = array; if (flag) { aParametersCollection.parameters = new IParameterData[Count]; for (int j = 0; j < Count; j++) { IParameterData parameterData = FixedParameters[j]; aParametersCollection.FixedParameters[j] = parameterData; if (!parameterData.HasDefaultValue) { continue; } Expression expression = parameterData.DefaultValue; if (array[j] != expression.Type) { if (expression is Constant constant) { Constant constant2 = Constant.ExtractConstantFromValue(array[j], constant.GetValue(), expression.Location); expression = ((constant2 != null) ? ((Expression)constant2) : ((Expression)new DefaultValueExpression(new TypeExpression(array[j], expression.Location), expression.Location))); } else if (expression is DefaultValueExpression) { expression = new DefaultValueExpression(new TypeExpression(array[j], expression.Location), expression.Location); } aParametersCollection.FixedParameters[j] = new ParameterData(parameterData.Name, parameterData.ModFlags, expression); } } } return aParametersCollection; } public string ParameterDesc(int pos) { if (types == null || types[pos] == null) { return ((Parameter)FixedParameters[pos]).GetSignatureForError(); } string signatureForError = types[pos].GetSignatureForError(); if (FixedParameters[pos].HasExtensionMethodModifier) { return "this " + signatureForError; } Parameter.Modifier modifier = FixedParameters[pos].ModFlags & Parameter.Modifier.ModifierMask; if (modifier == Parameter.Modifier.NONE) { return signatureForError; } return Parameter.GetModifierSignature(modifier) + " " + signatureForError; } } internal class ParametersImported : AParametersCollection { public ParametersImported(IParameterData[] parameters, TypeSpec[] types, bool hasArglist, bool hasParams) { base.parameters = parameters; base.types = types; has_arglist = hasArglist; has_params = hasParams; } public ParametersImported(IParameterData[] param, TypeSpec[] types, bool hasParams) { parameters = param; base.types = types; has_params = hasParams; } } internal class ParametersCompiled : AParametersCollection { public static readonly ParametersCompiled EmptyReadOnlyParameters = new ParametersCompiled(); public static readonly ParametersCompiled Undefined = new ParametersCompiled(); public Parameter this[int pos] => (Parameter)parameters[pos]; private ParametersCompiled() { IParameterData[] array = new Parameter[0]; parameters = array; types = TypeSpec.EmptyTypes; } private ParametersCompiled(IParameterData[] parameters, TypeSpec[] types) { base.parameters = parameters; base.types = types; } public ParametersCompiled(params Parameter[] parameters) { if (parameters == null || parameters.Length == 0) { throw new ArgumentException("Use EmptyReadOnlyParameters"); } base.parameters = parameters; int num = parameters.Length; for (int i = 0; i < num; i++) { has_params |= (parameters[i].ModFlags & Parameter.Modifier.PARAMS) != 0; } } public ParametersCompiled(Parameter[] parameters, bool has_arglist) : this(parameters) { base.has_arglist = has_arglist; } public static ParametersCompiled CreateFullyResolved(Parameter p, TypeSpec type) { IParameterData[] array = new Parameter[1] { p }; return new ParametersCompiled(array, new TypeSpec[1] { type }); } public static ParametersCompiled CreateFullyResolved(Parameter[] parameters, TypeSpec[] types) { return new ParametersCompiled(parameters, types); } public static ParametersCompiled Prefix(ParametersCompiled parameters, Parameter p, TypeSpec type) { TypeSpec[] array = new TypeSpec[parameters.Count + 1]; array[0] = type; Array.Copy(parameters.Types, 0, array, 1, parameters.Count); Parameter[] array2 = new Parameter[array.Length]; array2[0] = p; for (int i = 0; i < parameters.Count; i++) { (array2[i + 1] = parameters[i]).SetIndex(i + 1); } return CreateFullyResolved(array2, array); } public static AParametersCollection CreateFullyResolved(params TypeSpec[] types) { ParameterData[] array = new ParameterData[types.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new ParameterData(null, Parameter.Modifier.NONE, null); } IParameterData[] array2 = array; return new ParametersCompiled(array2, types); } public static ParametersCompiled CreateImplicitParameter(FullNamedExpression texpr, Location loc) { IParameterData[] array = new Parameter[1] { new Parameter(texpr, "value", Parameter.Modifier.NONE, null, loc) }; return new ParametersCompiled(array, null); } public void CheckConstraints(IMemberContext mc) { IParameterData[] array = parameters; for (int i = 0; i < array.Length; i++) { Parameter parameter = (Parameter)array[i]; if (parameter.TypeExpression != null) { ConstraintChecker.Check(mc, parameter.Type, parameter.TypeExpression.Location); } } } public static int IsSameClsSignature(AParametersCollection a, AParametersCollection b) { int num = 0; for (int i = 0; i < a.Count; i++) { TypeSpec typeSpec = a.Types[i]; TypeSpec typeSpec2 = b.Types[i]; if (TypeSpecComparer.Override.IsEqual(typeSpec, typeSpec2)) { if ((a.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (b.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) { num |= 1; } continue; } if (!(typeSpec is ArrayContainer arrayContainer)) { return 0; } if (!(typeSpec2 is ArrayContainer arrayContainer2)) { return 0; } if (arrayContainer.Element is ArrayContainer || arrayContainer2.Element is ArrayContainer) { num |= 2; continue; } if (arrayContainer.Rank != arrayContainer2.Rank && TypeSpecComparer.Override.IsEqual(arrayContainer.Element, arrayContainer2.Element)) { num |= 1; continue; } return 0; } return num; } public static ParametersCompiled MergeGenerated(CompilerContext ctx, ParametersCompiled userParams, bool checkConflicts, Parameter compilerParams, TypeSpec compilerTypes) { return MergeGenerated(ctx, userParams, checkConflicts, new Parameter[1] { compilerParams }, new TypeSpec[1] { compilerTypes }); } public static ParametersCompiled MergeGenerated(CompilerContext ctx, ParametersCompiled userParams, bool checkConflicts, Parameter[] compilerParams, TypeSpec[] compilerTypes) { Parameter[] array = new Parameter[userParams.Count + compilerParams.Length]; userParams.FixedParameters.CopyTo(array, 0); TypeSpec[] array2; if (userParams.types != null) { array2 = new TypeSpec[array.Length]; userParams.Types.CopyTo(array2, 0); } else { array2 = null; } int num = userParams.Count; int num2 = 0; foreach (Parameter parameter in compilerParams) { for (int j = 0; j < num; j++) { while (parameter.Name == array[j].Name) { if (checkConflicts && j < userParams.Count) { ctx.Report.Error(316, userParams[j].Location, "The parameter name `{0}' conflicts with a compiler generated name", parameter.Name); } parameter.Name = "_" + parameter.Name; } } array[num] = parameter; if (array2 != null) { array2[num] = compilerTypes[num2++]; } num++; } IParameterData[] array3 = array; ParametersCompiled parametersCompiled = new ParametersCompiled(array3, array2); parametersCompiled.has_params = userParams.has_params; return parametersCompiled; } public void CheckParameters(MemberCore member) { for (int i = 0; i < parameters.Length; i++) { string name = parameters[i].Name; for (int j = i + 1; j < parameters.Length; j++) { if (parameters[j].Name == name) { this[j].Error_DuplicateName(member.Compiler.Report); } } } } public bool Resolve(IMemberContext ec) { if (types != null) { return true; } types = new TypeSpec[base.Count]; bool result = true; for (int i = 0; i < base.FixedParameters.Length; i++) { Parameter parameter = this[i]; TypeSpec typeSpec = parameter.Resolve(ec, i); if (typeSpec == null) { result = false; } else { types[i] = typeSpec; } } return result; } public void ResolveDefaultValues(MemberCore m) { ResolveContext resolveContext = null; for (int i = 0; i < parameters.Length; i++) { Parameter parameter = (Parameter)parameters[i]; if (parameter.Type != null) { parameter.Type.CheckObsoleteness(m, parameter.Location); } if (parameter.HasDefaultValue || parameter.OptAttributes != null) { if (resolveContext == null) { resolveContext = new ResolveContext(m); } parameter.ResolveDefaultValue(resolveContext); } } } public void ApplyAttributes(IMemberContext mc, MethodBase builder) { if (base.Count != 0) { MethodBuilder mb = builder as MethodBuilder; ConstructorBuilder cb = builder as ConstructorBuilder; PredefinedAttributes predefinedAttributes = mc.Module.PredefinedAttributes; for (int i = 0; i < base.Count; i++) { this[i].ApplyAttributes(mb, cb, i + 1, predefinedAttributes); } } } public void VerifyClsCompliance(IMemberContext ctx) { IParameterData[] fixedParameters = base.FixedParameters; for (int i = 0; i < fixedParameters.Length; i++) { Parameter parameter = (Parameter)fixedParameters[i]; parameter.IsClsCompliant(ctx); } } public Expression CreateExpressionTree(BlockContext ec, Location loc) { ArrayInitializer arrayInitializer = new ArrayInitializer(base.Count, loc); IParameterData[] fixedParameters = base.FixedParameters; for (int i = 0; i < fixedParameters.Length; i++) { Parameter parameter = (Parameter)fixedParameters[i]; StatementExpression statementExpression = new StatementExpression(parameter.CreateExpressionTreeVariable(ec), Location.Null); if (statementExpression.Resolve(ec)) { ec.CurrentBlock.AddScopeStatement(new TemporaryVariableReference.Declarator(parameter.ExpressionTreeVariableReference())); ec.CurrentBlock.AddScopeStatement(statementExpression); } arrayInitializer.Add(parameter.ExpressionTreeVariableReference()); } return new ArrayCreation(Parameter.ResolveParameterExpressionType(ec, loc), arrayInitializer, loc); } public ParametersCompiled Clone() { ParametersCompiled parametersCompiled = (ParametersCompiled)MemberwiseClone(); parametersCompiled.parameters = new IParameterData[parameters.Length]; for (int i = 0; i < base.Count; i++) { parametersCompiled.parameters[i] = this[i].Clone(); } return parametersCompiled; } } internal class DefaultParameterValueExpression : CompositeExpression { public DefaultParameterValueExpression(Expression expr) : base(expr) { } public void Resolve(ResolveContext rc, Parameter p) { Expression expression = Resolve(rc); if (expression == null) { expr = ErrorExpression.Instance; return; } expression = base.Child; if (!(expression is Constant) && !(expression is DefaultValueExpression) && !(expression is DefaultLiteralExpression) && (!(expression is New) || !((New)expression).IsGeneratedStructConstructor)) { if (!(expression is ErrorExpression)) { rc.Report.Error(1736, base.Location, "The expression being assigned to optional parameter `{0}' must be a constant or default value", p.Name); } return; } TypeSpec typeSpec = p.Type; if (type == typeSpec) { return; } Expression expression2 = Convert.ImplicitConversionStandard(rc, expression, typeSpec, base.Location); if (expression2 != null) { if (typeSpec.IsNullableType && expression2 is Wrap) { Wrap wrap = (Wrap)expression2; expression2 = wrap.Child; if (!(expression2 is Constant)) { rc.Report.Error(1770, base.Location, "The expression being assigned to nullable optional parameter `{0}' must be default value", p.Name); return; } } if (!expression2.IsNull && TypeSpec.IsReferenceType(typeSpec) && typeSpec.BuiltinType != BuiltinTypeSpec.Type.String) { rc.Report.Error(1763, base.Location, "Optional parameter `{0}' of type `{1}' can only be initialized with default value", p.Name, typeSpec.GetSignatureForError()); } else { expr = expression2; } } else { rc.Report.Error(1750, base.Location, "Optional parameter expression of type `{0}' cannot be converted to parameter type `{1}'", type.GetSignatureForError(), typeSpec.GetSignatureForError()); expr = ErrorExpression.Instance; } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal struct TypeAndMethods { public TypeSpec type; public IList methods; public bool optional; public MethodData[] found; public MethodSpec[] need_proxy; } internal struct ProxyMethodContext : IMemberContext, IModuleContext { private readonly TypeContainer container; public TypeSpec CurrentType { get { throw new NotImplementedException(); } } public TypeParameters CurrentTypeParameters { get { throw new NotImplementedException(); } } public MemberCore CurrentMemberDefinition { get { throw new NotImplementedException(); } } public bool IsObsolete => false; public bool IsUnsafe { get { throw new NotImplementedException(); } } public bool IsStatic => false; public ModuleContainer Module => container.Module; public ProxyMethodContext(TypeContainer container) { this.container = container; } public string GetSignatureForError() { throw new NotImplementedException(); } public ExtensionMethodCandidates LookupExtensionMethod(string name, int arity) { throw new NotImplementedException(); } public FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc) { throw new NotImplementedException(); } public FullNamedExpression LookupNamespaceAlias(string name) { throw new NotImplementedException(); } } internal class PendingImplementation { private struct MissingInterfacesInfo { public TypeSpec Type; public bool Optional; public MissingInterfacesInfo(TypeSpec t) { Type = t; Optional = false; } } public enum Operation { Lookup, ClearOne, ClearAll } private readonly TypeDefinition container; private TypeAndMethods[] pending_implementations; private static readonly MissingInterfacesInfo[] EmptyMissingInterfacesInfo = new MissingInterfacesInfo[0]; private Report Report => container.Module.Compiler.Report; private PendingImplementation(TypeDefinition container, MissingInterfacesInfo[] missing_ifaces, MethodSpec[] abstract_methods, int total) { TypeSpec definition = container.Definition; this.container = container; pending_implementations = new TypeAndMethods[total]; int num = 0; if (abstract_methods != null) { int num2 = abstract_methods.Length; pending_implementations[num].need_proxy = new MethodSpec[num2]; pending_implementations[num].methods = abstract_methods; pending_implementations[num].found = new MethodData[num2]; pending_implementations[num].type = definition; num++; } for (int i = 0; i < missing_ifaces.Length; i++) { MissingInterfacesInfo missingInterfacesInfo = missing_ifaces[i]; TypeSpec type = missingInterfacesInfo.Type; List interfaceMethods = MemberCache.GetInterfaceMethods(type); int count = interfaceMethods.Count; pending_implementations[num].type = type; pending_implementations[num].optional = missingInterfacesInfo.Optional; pending_implementations[num].methods = interfaceMethods; pending_implementations[num].found = new MethodData[count]; pending_implementations[num].need_proxy = new MethodSpec[count]; num++; } } private static MissingInterfacesInfo[] GetMissingInterfaces(TypeDefinition container) { IList interfaces = container.Definition.Interfaces; if (interfaces == null || interfaces.Count == 0) { return EmptyMissingInterfacesInfo; } MissingInterfacesInfo[] array = new MissingInterfacesInfo[interfaces.Count]; for (int i = 0; i < array.Length; i++) { array[i] = new MissingInterfacesInfo(interfaces[i]); } if (container.BaseType == null) { return array; } IList interfaces2 = container.BaseType.Interfaces; if (interfaces2 != null) { foreach (TypeSpec item in interfaces2) { for (int j = 0; j < array.Length; j++) { if (item == array[j].Type) { array[j].Optional = true; break; } } } } return array; } public static PendingImplementation GetPendingImplementations(TypeDefinition container) { TypeSpec baseType = container.BaseType; MissingInterfacesInfo[] missingInterfaces = GetMissingInterfaces(container); bool flag = baseType != null && baseType.IsAbstract && (container.ModFlags & Modifiers.ABSTRACT) == 0; MethodSpec[] array = null; if (flag) { IList notImplementedAbstractMethods = MemberCache.GetNotImplementedAbstractMethods(baseType); if (notImplementedAbstractMethods == null) { flag = false; } else { array = new MethodSpec[notImplementedAbstractMethods.Count]; notImplementedAbstractMethods.CopyTo(array, 0); } } int num = missingInterfaces.Length + (flag ? 1 : 0); if (num == 0) { return null; } PendingImplementation pendingImplementation = new PendingImplementation(container, missingInterfaces, array, num); TypeAndMethods[] array2 = pendingImplementation.pending_implementations; for (int i = 0; i < array2.Length; i++) { TypeAndMethods typeAndMethods = array2[i]; if (!typeAndMethods.type.IsGeneric) { continue; } for (int j = 0; j < typeAndMethods.methods.Count; j++) { MethodSpec methodSpec = typeAndMethods.methods[j]; if (methodSpec.Parameters.IsEmpty) { continue; } for (int k = j + 1; k < typeAndMethods.methods.Count; k++) { MethodSpec methodSpec2 = typeAndMethods.methods[k]; if (methodSpec.Name != methodSpec2.Name || typeAndMethods.type != methodSpec2.DeclaringType || !TypeSpecComparer.Override.IsSame(methodSpec.Parameters.Types, methodSpec2.Parameters.Types)) { continue; } bool flag2 = true; bool flag3 = false; IParameterData[] fixedParameters = methodSpec.Parameters.FixedParameters; IParameterData[] fixedParameters2 = methodSpec2.Parameters.FixedParameters; for (int l = 0; l < fixedParameters.Length; l++) { if ((fixedParameters[l].ModFlags & Parameter.Modifier.RefOutMask) != (fixedParameters2[l].ModFlags & Parameter.Modifier.RefOutMask)) { if (((fixedParameters[l].ModFlags | fixedParameters2[l].ModFlags) & Parameter.Modifier.RefOutMask) != Parameter.Modifier.RefOutMask) { flag2 = false; break; } flag3 = true; } } if (flag2 && flag3) { pendingImplementation.Report.SymbolRelatedToPreviousError(methodSpec); pendingImplementation.Report.SymbolRelatedToPreviousError(methodSpec2); pendingImplementation.Report.Error(767, container.Location, "Cannot implement interface `{0}' with the specified type parameters because it causes method `{1}' to differ on parameter modifiers only", typeAndMethods.type.GetDefinition().GetSignatureForError(), methodSpec.GetSignatureForError()); break; } } } } return pendingImplementation; } public MethodSpec IsInterfaceMethod(MemberName name, TypeSpec ifaceType, MethodData method, out MethodSpec ambiguousCandidate, ref bool optional) { return InterfaceMethod(name, ifaceType, method, Operation.Lookup, out ambiguousCandidate, ref optional); } public void ImplementMethod(MemberName name, TypeSpec ifaceType, MethodData method, bool clear_one, out MethodSpec ambiguousCandidate, ref bool optional) { InterfaceMethod(name, ifaceType, method, clear_one ? Operation.ClearOne : Operation.ClearAll, out ambiguousCandidate, ref optional); } public MethodSpec InterfaceMethod(MemberName name, TypeSpec iType, MethodData method, Operation op, out MethodSpec ambiguousCandidate, ref bool optional) { ambiguousCandidate = null; if (pending_implementations == null) { return null; } TypeSpec returnType = method.method.ReturnType; ParametersCompiled parameterInfo = method.method.ParameterInfo; bool flag = method.method is Indexer.SetIndexerMethod || method.method is Indexer.GetIndexerMethod; TypeAndMethods[] array = pending_implementations; MethodSpec methodSpec; for (int i = 0; i < array.Length; i++) { TypeAndMethods typeAndMethods = array[i]; if (iType != null && typeAndMethods.type != iType) { continue; } int count = typeAndMethods.methods.Count; for (int j = 0; j < count; j++) { methodSpec = typeAndMethods.methods[j]; if (methodSpec == null) { continue; } if (flag) { if (!methodSpec.IsAccessor || methodSpec.Parameters.IsEmpty) { continue; } } else if (name.Name != methodSpec.Name || methodSpec.Arity != name.Arity) { continue; } if (!TypeSpecComparer.Override.IsEqual(methodSpec.Parameters, parameterInfo)) { continue; } if (!TypeSpecComparer.Override.IsEqual(methodSpec.ReturnType, returnType)) { typeAndMethods.found[j] = method; continue; } if (op != Operation.Lookup) { if (methodSpec.IsAccessor != method.method.IsAccessor) { continue; } if (methodSpec.DeclaringType.IsInterface && iType == null && name.Name != methodSpec.Name) { typeAndMethods.need_proxy[j] = method.method.Spec; } else { typeAndMethods.methods[j] = null; } } else { typeAndMethods.found[j] = method; optional = typeAndMethods.optional; } if (op == Operation.Lookup && name.ExplicitInterface != null && ambiguousCandidate == null) { ambiguousCandidate = methodSpec; } else if (op != Operation.ClearAll) { return methodSpec; } } if (typeAndMethods.type == iType) { break; } } methodSpec = ambiguousCandidate; ambiguousCandidate = null; return methodSpec; } private void DefineProxy(TypeSpec iface, MethodSpec base_method, MethodSpec iface_method) { string text = iface.MemberDefinition.Namespace; string name = ((!string.IsNullOrEmpty(text)) ? (text + "." + iface.MemberDefinition.Name + "." + iface_method.Name) : (iface.MemberDefinition.Name + "." + iface_method.Name)); AParametersCollection parameters = iface_method.Parameters; MethodBuilder methodBuilder = container.TypeBuilder.DefineMethod(name, MethodAttributes.Private | MethodAttributes.Final | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.CheckAccessOnOverride | MethodAttributes.VtableLayoutMask, CallingConventions.Standard | CallingConventions.HasThis, base_method.ReturnType.GetMetaInfo(), parameters.GetMetaInfo()); if (iface_method.IsGeneric) { string[] names = iface_method.GenericDefinition.TypeParameters.Select((TypeParameterSpec l) => l.Name).ToArray(); methodBuilder.DefineGenericParameters(names); } for (int num = 0; num < parameters.Count; num++) { string name2 = parameters.FixedParameters[num].Name; ParameterAttributes parameterAttribute = AParametersCollection.GetParameterAttribute(parameters.FixedParameters[num].ModFlags); methodBuilder.DefineParameter(num + 1, parameterAttribute, name2); } int count = parameters.Count; EmitContext emitContext = new EmitContext(new ProxyMethodContext(container), methodBuilder.GetILGenerator(), null, null); emitContext.EmitThis(); for (int num2 = 0; num2 < count; num2++) { emitContext.EmitArgumentLoad(num2); } emitContext.Emit(OpCodes.Call, base_method); emitContext.Emit(OpCodes.Ret); container.TypeBuilder.DefineMethodOverride(methodBuilder, (MethodInfo)iface_method.GetMetaInfo()); } private bool BaseImplements(TypeSpec iface_type, MethodSpec mi, out MethodSpec base_method) { base_method = null; bool flag = true; if (mi.IsAccessor && container.Interfaces != null) { bool flag2 = false; TypeSpec[] interfaces = container.Interfaces; foreach (TypeSpec a in interfaces) { if (TypeSpecComparer.IsEqual(a, iface_type)) { flag2 = true; break; } } if (flag2) { bool flag3 = mi.Name[0] == 'g'; MemberFilter filter; if (mi.Parameters.Count > ((!flag3) ? 1 : 0)) { AParametersCollection param = (flag3 ? mi.Parameters : IndexerSpec.CreateParametersFromSetter(mi, mi.Parameters.Count - 1)); TypeSpec type = (flag3 ? mi.ReturnType : mi.Parameters.Types[mi.Parameters.Count - 1]); filter = new MemberFilter(MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, param, type); } else { string name = mi.Name.Substring(4); TypeSpec type2 = (flag3 ? mi.ReturnType : mi.Parameters.Types[0]); filter = MemberFilter.Property(name, type2); } MemberSpec memberSpec = MemberCache.FindMember(container.CurrentType, filter, BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly); if (memberSpec != null && (memberSpec.Modifiers & Modifiers.NEW) != 0) { flag = false; } } } TypeSpec typeSpec; if (flag) { typeSpec = container.BaseType; if (typeSpec.ImplementsInterface(iface_type, variantly: false)) { return true; } } else { typeSpec = container.CurrentType; } AParametersCollection parameters = mi.Parameters; MethodSpec methodSpec = null; while (true) { IList list = MemberCache.FindMembers(typeSpec, mi.Name, !flag); if (list == null) { base_method = methodSpec; return false; } MethodSpec methodSpec2 = null; foreach (MemberSpec item in list) { if (item.Kind != MemberKind.Method || item.Arity != mi.Arity) { continue; } AParametersCollection parameters2 = ((MethodSpec)item).Parameters; if (!TypeSpecComparer.Override.IsEqual(parameters.Types, parameters2.Types)) { continue; } bool flag4 = true; for (int j = 0; j < parameters.Count; j++) { if ((parameters.FixedParameters[j].ModFlags & Parameter.Modifier.RefOutMask) == (parameters2.FixedParameters[j].ModFlags & Parameter.Modifier.RefOutMask)) { continue; } flag4 = false; if ((parameters.FixedParameters[j].ModFlags & Parameter.Modifier.RefOutMask) != (parameters2.FixedParameters[j].ModFlags & Parameter.Modifier.RefOutMask)) { if (methodSpec2 == null) { if (!item.IsPublic || !TypeSpecComparer.Override.IsEqual(mi.ReturnType, ((MethodSpec)item).ReturnType)) { break; } methodSpec2 = (MethodSpec)item; } continue; } methodSpec2 = null; break; } if (!flag4) { continue; } MethodSpec methodSpec3 = (MethodSpec)item; if (!methodSpec3.IsPublic) { if (methodSpec == null) { methodSpec = methodSpec3; } continue; } if (!TypeSpecComparer.Override.IsEqual(mi.ReturnType, methodSpec3.ReturnType)) { if (methodSpec == null) { methodSpec = methodSpec3; } continue; } base_method = methodSpec3; if (!mi.IsGeneric || Method.CheckImplementingMethodConstraints(container, methodSpec3, mi)) { continue; } return true; } if (base_method != null) { if (methodSpec2 != null) { Report.SymbolRelatedToPreviousError(methodSpec2); Report.SymbolRelatedToPreviousError(mi); Report.SymbolRelatedToPreviousError(container); Report.Warning(1956, 1, ((MemberCore)base_method.MemberDefinition).Location, "The interface method `{0}' implementation is ambiguous between following methods: `{1}' and `{2}' in type `{3}'", mi.GetSignatureForError(), base_method.GetSignatureForError(), methodSpec2.GetSignatureForError(), container.GetSignatureForError()); } break; } if (!flag) { return false; } typeSpec = list[0].DeclaringType.BaseType; if (typeSpec == null) { base_method = methodSpec; return false; } } if (!base_method.IsVirtual) { DefineProxy(iface_type, base_method, mi); } return true; } public bool VerifyPendingMethods() { int num = pending_implementations.Length; bool result = false; for (int i = 0; i < num; i++) { TypeSpec type = pending_implementations[i].type; for (int j = 0; j < pending_implementations[i].methods.Count; j++) { MethodSpec methodSpec = pending_implementations[i].methods[j]; if (methodSpec == null) { continue; } if (type.IsInterface) { MethodSpec methodSpec2 = pending_implementations[i].need_proxy[j]; if (methodSpec2 != null) { DefineProxy(type, methodSpec2, methodSpec); continue; } if (BaseImplements(type, methodSpec, out var base_method)) { continue; } if (base_method == null) { MethodData methodData = pending_implementations[i].found[j]; if (methodData != null) { base_method = methodData.method.Spec; } } Report.SymbolRelatedToPreviousError(methodSpec); if (base_method != null) { Report.SymbolRelatedToPreviousError(base_method); if (base_method.IsStatic) { Report.Error(736, container.Location, "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' is static", container.GetSignatureForError(), methodSpec.GetSignatureForError(), base_method.GetSignatureForError()); } else if ((base_method.Modifiers & Modifiers.PUBLIC) == 0) { Report.Error(737, container.Location, "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' is not public", container.GetSignatureForError(), methodSpec.GetSignatureForError(), base_method.GetSignatureForError()); } else if (methodSpec.ReturnType.Kind == MemberKind.ByRef) { Report.Error(8152, container.Location, "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' return type `{3}' does not return by reference", container.GetSignatureForError(), methodSpec.GetSignatureForError(), base_method.GetSignatureForError(), base_method.ReturnType.GetSignatureForError()); } else { Report.Error(738, container.Location, "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' return type `{3}' does not match interface member return type `{4}'", container.GetSignatureForError(), methodSpec.GetSignatureForError(), base_method.GetSignatureForError(), base_method.ReturnType.GetSignatureForError(), methodSpec.ReturnType.GetSignatureForError()); } } else { Report.Error(535, container.Location, "`{0}' does not implement interface member `{1}'", container.GetSignatureForError(), methodSpec.GetSignatureForError()); } } else { Report.SymbolRelatedToPreviousError(methodSpec); Report.Error(534, container.Location, "`{0}' does not implement inherited abstract member `{1}'", container.GetSignatureForError(), methodSpec.GetSignatureForError()); } result = true; } } return result; } } internal abstract class PropertyBasedMember : InterfaceMemberBase { protected PropertyBasedMember(TypeDefinition parent, FullNamedExpression type, Modifiers mod, Modifiers allowed_mod, MemberName name, Attributes attrs) : base(parent, type, mod, allowed_mod, name, attrs) { } protected void CheckReservedNameConflict(string prefix, MethodSpec accessor) { string text; AParametersCollection aParametersCollection; if (accessor != null) { text = accessor.Name; aParametersCollection = accessor.Parameters; } else { text = prefix + base.ShortName; if (IsExplicitImpl) { text = base.MemberName.Left?.ToString() + "." + text; } if (!(this is Indexer)) { aParametersCollection = ((prefix[0] != 's') ? ParametersCompiled.EmptyReadOnlyParameters : ParametersCompiled.CreateFullyResolved(member_type)); } else { aParametersCollection = ((Indexer)this).ParameterInfo; if (prefix[0] == 's') { IParameterData[] array = new IParameterData[aParametersCollection.Count + 1]; Array.Copy(aParametersCollection.FixedParameters, array, array.Length - 1); array[^1] = new ParameterData("value", Parameter.Modifier.NONE); TypeSpec[] array2 = new TypeSpec[array.Length]; Array.Copy(aParametersCollection.Types, array2, array.Length - 1); array2[array.Length - 1] = member_type; aParametersCollection = new ParametersImported(array, array2, hasParams: false); } } } MemberSpec memberSpec = MemberCache.FindMember(Parent.Definition, new MemberFilter(text, 0, MemberKind.Method, aParametersCollection, null), BindingRestriction.DeclaredOnly | BindingRestriction.NoAccessors); if (memberSpec != null) { base.Report.SymbolRelatedToPreviousError(memberSpec); base.Report.Error(82, base.Location, "A member `{0}' is already reserved", memberSpec.GetSignatureForError()); } } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } if (!base.MemberType.IsCLSCompliant()) { base.Report.Warning(3003, 1, base.Location, "Type of `{0}' is not CLS-compliant", GetSignatureForError()); } return true; } } internal class PropertySpec : MemberSpec, IInterfaceMemberSpec { private PropertyInfo info; private TypeSpec memberType; private MethodSpec set; private MethodSpec get; public MethodSpec Get { get { return get; } set { get = value; get.IsAccessor = true; } } public MethodSpec Set { get { return set; } set { set = value; set.IsAccessor = true; } } public bool HasDifferentAccessibility => HasGet && HasSet && (Get.Modifiers & Modifiers.AccessibilityMask) != (Set.Modifiers & Modifiers.AccessibilityMask); public bool HasGet => Get != null; public bool HasSet => Set != null; public PropertyInfo MetaInfo { get { if ((state & StateFlags.PendingMetaInflate) != 0) { throw new NotSupportedException(); } return info; } } public TypeSpec MemberType => memberType; public PropertySpec(MemberKind kind, TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, PropertyInfo info, Modifiers modifiers) : base(kind, declaringType, definition, modifiers) { this.info = info; this.memberType = memberType; } public override MemberSpec InflateMember(TypeParameterInflator inflator) { PropertySpec propertySpec = (PropertySpec)base.InflateMember(inflator); propertySpec.memberType = inflator.Inflate(memberType); return propertySpec; } public override List ResolveMissingDependencies(MemberSpec caller) { return memberType.ResolveMissingDependencies(this); } } internal abstract class PropertyBase : PropertyBasedMember { public class GetMethod : PropertyMethod { private static readonly string[] attribute_targets = new string[2] { "method", "return" }; internal const string Prefix = "get_"; public override TypeSpec ReturnType => method.MemberType; public override ParametersCompiled ParameterInfo => ParametersCompiled.EmptyReadOnlyParameters; public override string[] ValidAttributeTargets => attribute_targets; public GetMethod(PropertyBase method, Modifiers modifiers, Attributes attrs, Location loc) : base(method, "get_", modifiers, attrs, loc) { } public override void Define(TypeContainer parent) { base.Define(parent); base.Spec = new MethodSpec(MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, base.ModFlags); method_data = new MethodData(method, base.ModFlags, flags, this); method_data.Define(parent.PartialContainer, method.GetFullName(base.MemberName)); } } public class SetMethod : PropertyMethod { private static readonly string[] attribute_targets = new string[3] { "method", "param", "return" }; internal const string Prefix = "set_"; protected ParametersCompiled parameters; public override ParametersCompiled ParameterInfo => parameters; public override TypeSpec ReturnType => Parent.Compiler.BuiltinTypes.Void; public override string[] ValidAttributeTargets => attribute_targets; public SetMethod(PropertyBase method, Modifiers modifiers, ParametersCompiled parameters, Attributes attrs, Location loc) : base(method, "set_", modifiers, attrs, loc) { this.parameters = parameters; } protected override void ApplyToExtraTarget(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Parameter) { parameters[parameters.Count - 1].ApplyAttributeBuilder(a, ctor, cdata, pa); } else { base.ApplyToExtraTarget(a, ctor, cdata, pa); } } public override void Define(TypeContainer parent) { parameters.Resolve(this); base.Define(parent); base.Spec = new MethodSpec(MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, base.ModFlags); method_data = new MethodData(method, base.ModFlags, flags, this); method_data.Define(parent.PartialContainer, method.GetFullName(base.MemberName)); } } public abstract class PropertyMethod : AbstractPropertyEventMethod { private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask; protected readonly PropertyBase method; protected MethodAttributes flags; public override AttributeTargets AttributeTargets => AttributeTargets.Method; public bool HasCustomAccessModifier => (base.ModFlags & Modifiers.PROPERTY_CUSTOM) != 0; public PropertyBase Property => method; public PropertyMethod(PropertyBase method, string prefix, Modifiers modifiers, Attributes attrs, Location loc) : base(method, prefix, attrs, loc) { this.method = method; base.ModFlags = ModifiersExtensions.Check(Modifiers.AccessibilityMask, modifiers, (Modifiers)0, loc, base.Report); base.ModFlags |= method.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.MethodImpl) { method.is_external_implementation = a.IsInternalCall(); } base.ApplyAttributeBuilder(a, ctor, cdata, pa); } public override bool IsClsComplianceRequired() { return method.IsClsComplianceRequired(); } public virtual void Define(TypeContainer parent) { TypeDefinition partialContainer = parent.PartialContainer; if ((base.ModFlags & Modifiers.AccessibilityMask) == 0) { base.ModFlags |= method.ModFlags; flags = method.flags; } else { CheckModifiers(base.ModFlags); base.ModFlags |= method.ModFlags & ~Modifiers.AccessibilityMask; base.ModFlags |= Modifiers.PROPERTY_CUSTOM; if (partialContainer.Kind == MemberKind.Interface) { base.Report.Error(275, base.Location, "`{0}': accessibility modifiers may not be used on accessors in an interface", GetSignatureForError()); } else if ((base.ModFlags & Modifiers.PRIVATE) != 0) { if ((method.ModFlags & Modifiers.ABSTRACT) != 0) { base.Report.Error(442, base.Location, "`{0}': abstract properties cannot have private accessors", GetSignatureForError()); } base.ModFlags &= ~Modifiers.VIRTUAL; } flags = ModifiersExtensions.MethodAttr(base.ModFlags) | MethodAttributes.SpecialName; } CheckAbstractAndExtern(block != null); CheckProtectedModifier(); if (block != null) { if (block.IsIterator) { Iterator.CreateIterator(this, Parent.PartialContainer, base.ModFlags); } if (Compiler.Settings.WriteMetadataOnly) { block = null; } } } public override ObsoleteAttribute GetAttributeObsolete() { return method.GetAttributeObsolete(); } public override string GetSignatureForError() { return method.GetSignatureForError() + "." + prefix.Substring(0, 3); } private void CheckModifiers(Modifiers modflags) { if (!ModifiersExtensions.IsRestrictedModifier(modflags & Modifiers.AccessibilityMask, method.ModFlags & Modifiers.AccessibilityMask)) { base.Report.Error(273, base.Location, "The accessibility modifier of the `{0}' accessor must be more restrictive than the modifier of the property or indexer `{1}'", GetSignatureForError(), method.GetSignatureForError()); } } } private static readonly string[] attribute_targets = new string[1] { "property" }; private PropertyMethod get; private PropertyMethod set; private PropertyMethod first; private PropertyBuilder PropertyBuilder; public override AttributeTargets AttributeTargets => AttributeTargets.Property; public PropertyMethod AccessorFirst => first; public PropertyMethod AccessorSecond => (first == get) ? set : get; public override Variance ExpectedMemberTypeVariance => (get == null || set == null) ? ((set == null) ? Variance.Covariant : Variance.Contravariant) : Variance.None; public PropertyMethod Get { get { return get; } set { get = value; if (first == null) { first = value; } Parent.AddNameToContainer(get, get.MemberName.Basename); } } public PropertyMethod Set { get { return set; } set { set = value; if (first == null) { first = value; } Parent.AddNameToContainer(set, set.MemberName.Basename); } } public override string[] ValidAttributeTargets => attribute_targets; public override bool IsUsed { get { if (IsExplicitImpl) { return true; } return Get.IsUsed | Set.IsUsed; } } public override string DocCommentHeader => "P:"; protected PropertyBase(TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, Modifiers allowed_mod, MemberName name, Attributes attrs) : base(parent, type, mod_flags, allowed_mod, name, attrs) { } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.HasSecurityAttribute) { a.Error_InvalidSecurityParent(); } else if (a.Type == pa.Dynamic) { a.Error_MisusedDynamicAttribute(); } else { PropertyBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } } private void CheckMissingAccessor(MemberKind kind, ParametersCompiled parameters, bool get) { if (IsExplicitImpl && MemberCache.FindMember(filter: (kind != MemberKind.Indexer) ? new MemberFilter(base.MemberName.Name, 0, kind, null, null) : new MemberFilter(MemberCache.IndexerNameAlias, 0, kind, parameters, null), container: InterfaceType, restrictions: BindingRestriction.DeclaredOnly) is PropertySpec propertySpec) { MethodSpec methodSpec = (get ? propertySpec.Get : propertySpec.Set); if (methodSpec != null) { base.Report.SymbolRelatedToPreviousError(methodSpec); base.Report.Error(551, base.Location, "Explicit interface implementation `{0}' is missing accessor `{1}'", GetSignatureForError(), methodSpec.GetSignatureForError()); } } } protected override bool CheckOverrideAgainstBase(MemberSpec base_member) { bool flag = base.CheckOverrideAgainstBase(base_member); PropertySpec propertySpec = (PropertySpec)base_member; if (Get == null) { if ((base.ModFlags & Modifiers.SEALED) != 0 && propertySpec.HasGet && !propertySpec.Get.IsAccessible(this)) { base.Report.SymbolRelatedToPreviousError(propertySpec); base.Report.Error(545, base.Location, "`{0}': cannot override because `{1}' does not have accessible get accessor", GetSignatureForError(), propertySpec.GetSignatureForError()); flag = false; } } else if (!propertySpec.HasGet) { if (flag) { base.Report.SymbolRelatedToPreviousError(propertySpec); base.Report.Error(545, Get.Location, "`{0}': cannot override because `{1}' does not have an overridable get accessor", Get.GetSignatureForError(), propertySpec.GetSignatureForError()); flag = false; } } else if (Get.HasCustomAccessModifier || propertySpec.HasDifferentAccessibility) { if (!propertySpec.Get.IsAccessible(this)) { base.Report.Error(115, Get.Location, "`{0}' is marked as an override but no accessible `get' accessor found to override", GetSignatureForError()); flag = false; } else if (!InterfaceMemberBase.CheckAccessModifiers(Get, propertySpec.Get)) { Error_CannotChangeAccessModifiers(Get, propertySpec.Get); flag = false; } } if (Set == null) { if (propertySpec.HasSet) { if ((base.ModFlags & Modifiers.SEALED) != 0 && !propertySpec.Set.IsAccessible(this)) { base.Report.SymbolRelatedToPreviousError(propertySpec); base.Report.Error(546, base.Location, "`{0}': cannot override because `{1}' does not have accessible set accessor", GetSignatureForError(), propertySpec.GetSignatureForError()); flag = false; } if ((base.ModFlags & Modifiers.AutoProperty) != 0) { base.Report.Error(8080, base.Location, "`{0}': Auto-implemented properties must override all accessors of the overridden property", GetSignatureForError()); flag = false; } } } else if (!propertySpec.HasSet) { if (flag) { base.Report.SymbolRelatedToPreviousError(propertySpec); base.Report.Error(546, Set.Location, "`{0}': cannot override because `{1}' does not have an overridable set accessor", Set.GetSignatureForError(), propertySpec.GetSignatureForError()); flag = false; } } else if (Set.HasCustomAccessModifier || propertySpec.HasDifferentAccessibility) { if (!propertySpec.Set.IsAccessible(this)) { base.Report.Error(115, Set.Location, "`{0}' is marked as an override but no accessible `set' accessor found to override", GetSignatureForError()); flag = false; } else if (!InterfaceMemberBase.CheckAccessModifiers(Set, propertySpec.Set)) { Error_CannotChangeAccessModifiers(Set, propertySpec.Set); flag = false; } } if ((Set == null || !Set.HasCustomAccessModifier) && (Get == null || !Get.HasCustomAccessModifier) && !InterfaceMemberBase.CheckAccessModifiers(this, propertySpec)) { Error_CannotChangeAccessModifiers(this, propertySpec); flag = false; } return flag; } protected override void DoMemberTypeDependentChecks() { base.DoMemberTypeDependentChecks(); IsTypePermitted(); if (base.MemberType.IsStatic) { Error_StaticReturnType(); } } protected override void DoMemberTypeIndependentChecks() { base.DoMemberTypeIndependentChecks(); if (AccessorSecond != null) { if ((Get.ModFlags & Modifiers.AccessibilityMask) != 0 && (Set.ModFlags & Modifiers.AccessibilityMask) != 0) { base.Report.Error(274, base.Location, "`{0}': Cannot specify accessibility modifiers for both accessors of the property or indexer", GetSignatureForError()); } } else if ((base.ModFlags & Modifiers.OVERRIDE) == 0 && ((Get == null && (Set.ModFlags & Modifiers.AccessibilityMask) != 0) || (Set == null && (Get.ModFlags & Modifiers.AccessibilityMask) != 0))) { base.Report.Error(276, base.Location, "`{0}': accessibility modifiers on accessors may only be used if the property or indexer has both a get and a set accessor", GetSignatureForError()); } } protected bool DefineAccessors() { first.Define(Parent); if (AccessorSecond != null) { AccessorSecond.Define(Parent); } return true; } protected void DefineBuilders(MemberKind kind, ParametersCompiled parameters) { PropertyBuilder = Parent.TypeBuilder.DefineProperty(GetFullName(base.MemberName), PropertyAttributes.None, base.MemberType.GetMetaInfo(), null, null, parameters.GetMetaInfo(), null, null); PropertySpec propertySpec = ((kind != MemberKind.Indexer) ? new PropertySpec(kind, Parent.Definition, this, base.MemberType, PropertyBuilder, base.ModFlags) : new IndexerSpec(Parent.Definition, this, base.MemberType, parameters, PropertyBuilder, base.ModFlags)); if (Get != null) { propertySpec.Get = Get.Spec; Parent.MemberCache.AddMember(this, Get.Spec.Name, Get.Spec); } else { CheckMissingAccessor(kind, parameters, get: true); } if (Set != null) { propertySpec.Set = Set.Spec; Parent.MemberCache.AddMember(this, Set.Spec.Name, Set.Spec); } else { CheckMissingAccessor(kind, parameters, get: false); } Parent.MemberCache.AddMember(this, PropertyBuilder.Name, propertySpec); } public override void Emit() { CheckReservedNameConflict("get_", (get == null) ? null : get.Spec); CheckReservedNameConflict("set_", (set == null) ? null : set.Spec); if (base.OptAttributes != null) { base.OptAttributes.Emit(); } if (member_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { Module.PredefinedAttributes.Dynamic.EmitAttribute(PropertyBuilder); } else if (member_type.HasDynamicElement) { Module.PredefinedAttributes.Dynamic.EmitAttribute(PropertyBuilder, member_type, base.Location); } if (member_type.HasNamedTupleElement) { Module.PredefinedAttributes.TupleElementNames.EmitAttribute(PropertyBuilder, member_type, base.Location); } ConstraintChecker.Check(this, member_type, type_expr.Location); first.Emit(Parent); if (AccessorSecond != null) { AccessorSecond.Emit(Parent); } base.Emit(); } public override void PrepareEmit() { AccessorFirst.PrepareEmit(); if (AccessorSecond != null) { AccessorSecond.PrepareEmit(); } if (get != null && Get.Spec.GetMetaInfo() is MethodBuilder getMethod) { PropertyBuilder.SetGetMethod(getMethod); } if (set != null && Set.Spec.GetMetaInfo() is MethodBuilder setMethod) { PropertyBuilder.SetSetMethod(setMethod); } } protected override void SetMemberName(MemberName new_name) { base.SetMemberName(new_name); if (Get != null) { Get.UpdateName(this); } if (Set != null) { Set.UpdateName(this); } } public override void WriteDebugSymbol(MonoSymbolFile file) { if (get != null) { get.WriteDebugSymbol(file); } if (set != null) { set.WriteDebugSymbol(file); } } } internal class Property : PropertyBase { public sealed class BackingFieldDeclaration : Field { private readonly Property property; private const Modifiers DefaultModifiers = Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.BACKING_FIELD | Modifiers.DEBUGGER_HIDDEN; public Property OriginalProperty => property; public BackingFieldDeclaration(Property p, bool readOnly) : base(p.Parent, p.type_expr, Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.BACKING_FIELD | Modifiers.DEBUGGER_HIDDEN | (p.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)), new MemberName("<" + p.GetFullName(p.MemberName) + ">k__BackingField", p.Location), null) { property = p; if (readOnly) { base.ModFlags |= Modifiers.READONLY; } } public override string GetSignatureForError() { return property.GetSignatureForError(); } } private static readonly string[] attribute_target_auto = new string[2] { "property", "field" }; public BackingFieldDeclaration BackingField { get; private set; } public Expression Initializer { get; set; } public override string[] ValidAttributeTargets => (base.Get != null && (base.Get.ModFlags & Modifiers.COMPILER_GENERATED) != 0) ? attribute_target_auto : base.ValidAttributeTargets; public Property(TypeDefinition parent, FullNamedExpression type, Modifiers mod, MemberName name, Attributes attrs) : base(parent, type, mod, (parent.PartialContainer.Kind == MemberKind.Interface) ? (Modifiers.NEW | Modifiers.UNSAFE) : ((parent.PartialContainer.Kind == MemberKind.Struct) ? (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.STATIC | Modifiers.OVERRIDE) : (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.VIRTUAL | Modifiers.OVERRIDE)), name, attrs) { } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Field) { BackingField.ApplyAttributeBuilder(a, ctor, cdata, pa); } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } private void CreateAutomaticProperty() { BackingField = new BackingFieldDeclaration(this, Initializer == null && base.Set == null); if (BackingField.Define()) { if (Initializer != null) { BackingField.Initializer = Initializer; Parent.RegisterFieldForInitialization(BackingField, new FieldInitializer(BackingField, Initializer, base.Location)); BackingField.ModFlags |= Modifiers.READONLY; } Parent.PartialContainer.Members.Add(BackingField); FieldExpr fieldExpr = new FieldExpr(BackingField, base.Location); if ((BackingField.ModFlags & Modifiers.STATIC) == 0) { fieldExpr.InstanceExpression = new CompilerGeneratedThis(Parent.CurrentType, base.Location); Parent.PartialContainer.HasInstanceField = true; } base.Get.Block = new ToplevelBlock(Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null); Return s = new Return(fieldExpr, base.Get.Location); base.Get.Block.AddStatement(s); base.Get.ModFlags |= Modifiers.COMPILER_GENERATED; if (base.Set != null) { base.Set.Block = new ToplevelBlock(Compiler, base.Set.ParameterInfo, Location.Null); Assign expr = new SimpleAssign(fieldExpr, new SimpleName("value", Location.Null), Location.Null); base.Set.Block.AddStatement(new StatementExpression(expr, base.Set.Location)); base.Set.ModFlags |= Modifiers.COMPILER_GENERATED; } } } public override bool Define() { if (!base.Define()) { return false; } flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName; bool flag = base.AccessorFirst.Block == null && (base.AccessorSecond == null || base.AccessorSecond.Block == null) && (base.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0; if (Initializer != null) { if (!flag) { base.Report.Error(8050, base.Location, "`{0}': Only auto-implemented properties can have initializers", GetSignatureForError()); } if (IsInterface) { base.Report.Error(8052, base.Location, "`{0}': Properties inside interfaces cannot have initializers", GetSignatureForError()); } if (Compiler.Settings.Version < LanguageVersion.V_6) { base.Report.FeatureIsNotAvailable(Compiler, base.Location, "auto-implemented property initializer"); } } if (flag) { base.ModFlags |= Modifiers.AutoProperty; if (base.Get == null) { base.Report.Error(8051, base.Location, "Auto-implemented property `{0}' must have get accessor", GetSignatureForError()); return false; } if (base.MemberType.Kind == MemberKind.ByRef) { base.Report.Error(8145, base.Location, "Auto-implemented property `{0}' cannot return by reference", GetSignatureForError()); return false; } if ((Parent.PartialContainer.ModFlags & Modifiers.READONLY) != 0 && base.Set != null && !base.IsStatic) { base.Report.Error(8341, base.Location, "Auto-implemented instance property `{0}' in readonly structs must be readonly", GetSignatureForError()); } if (Compiler.Settings.Version < LanguageVersion.V_3 && Initializer == null) { base.Report.FeatureIsNotAvailable(Compiler, base.Location, "auto-implemented properties"); } CreateAutomaticProperty(); } if (!DefineAccessors()) { return false; } if (base.AccessorSecond == null) { PropertyMethod propertyMethod = ((!(base.AccessorFirst is GetMethod)) ? ((PropertyMethod)new GetMethod(this, (Modifiers)0, null, base.Location)) : ((PropertyMethod)new SetMethod(this, (Modifiers)0, ParametersCompiled.EmptyReadOnlyParameters, null, base.Location))); Parent.AddNameToContainer(propertyMethod, propertyMethod.MemberName.Basename); } if (!CheckBase()) { return false; } DefineBuilders(MemberKind.Property, ParametersCompiled.EmptyReadOnlyParameters); return true; } public override void Emit() { if ((base.AccessorFirst.ModFlags & (Modifiers.STATIC | Modifiers.AutoProperty)) == Modifiers.AutoProperty && Parent.PartialContainer.HasExplicitLayout) { base.Report.Error(842, base.Location, "Automatically implemented property `{0}' cannot be used inside a type with an explicit StructLayout attribute", GetSignatureForError()); } base.Emit(); } } internal class EventProperty : Event { public abstract class AEventPropertyAccessor : AEventAccessor { protected AEventPropertyAccessor(EventProperty method, string prefix, Attributes attrs, Location loc) : base(method, prefix, attrs, loc) { } public override void Define(TypeContainer ds) { CheckAbstractAndExtern(block != null); base.Define(ds); } public override string GetSignatureForError() { return method.GetSignatureForError() + "." + prefix.Substring(0, prefix.Length - 1); } } public sealed class AddDelegateMethod : AEventPropertyAccessor { public AddDelegateMethod(EventProperty method, Attributes attrs, Location loc) : base(method, "add_", attrs, loc) { } } public sealed class RemoveDelegateMethod : AEventPropertyAccessor { public RemoveDelegateMethod(EventProperty method, Attributes attrs, Location loc) : base(method, "remove_", attrs, loc) { } } private static readonly string[] attribute_targets = new string[1] { "event" }; public override string[] ValidAttributeTargets => attribute_targets; public EventProperty(TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base(parent, type, mod_flags, name, attrs) { } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override bool Define() { if (!base.Define()) { return false; } SetIsUsed(); return true; } } internal class EventField : Event { private abstract class EventFieldAccessor : AEventAccessor { protected EventFieldAccessor(EventField method, string prefix) : base(method, prefix, null, method.Location) { } protected abstract MethodSpec GetOperation(Location loc); public override void Emit(TypeDefinition parent) { if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0 && !Compiler.Settings.WriteMetadataOnly) { block = new ToplevelBlock(Compiler, ParameterInfo, base.Location) { IsCompilerGenerated = true }; FabricateBodyStatement(); } base.Emit(parent); } private void FabricateBodyStatement() { Field backing_field = ((EventField)method).backing_field; FieldExpr fieldExpr = new FieldExpr(backing_field, base.Location); if (!base.IsStatic) { fieldExpr.InstanceExpression = new CompilerGeneratedThis(Parent.CurrentType, base.Location); } LocalVariable li = LocalVariable.CreateCompilerGenerated(backing_field.MemberType, block, base.Location); LocalVariable li2 = LocalVariable.CreateCompilerGenerated(backing_field.MemberType, block, base.Location); block.AddStatement(new StatementExpression(new SimpleAssign(new LocalVariableReference(li, base.Location), fieldExpr))); BooleanExpression bool_expr = new BooleanExpression(new Binary(Binary.Operator.Inequality, new Cast(new TypeExpression(Module.Compiler.BuiltinTypes.Object, base.Location), new LocalVariableReference(li, base.Location), base.Location), new Cast(new TypeExpression(Module.Compiler.BuiltinTypes.Object, base.Location), new LocalVariableReference(li2, base.Location), base.Location))); ExplicitBlock explicitBlock = new ExplicitBlock(block, base.Location, base.Location); block.AddStatement(new Do(explicitBlock, bool_expr, base.Location, base.Location)); explicitBlock.AddStatement(new StatementExpression(new SimpleAssign(new LocalVariableReference(li2, base.Location), new LocalVariableReference(li, base.Location)))); Arguments arguments = new Arguments(2); arguments.Add(new Argument(new LocalVariableReference(li2, base.Location))); arguments.Add(new Argument(block.GetParameterReference(0, base.Location))); MethodSpec operation = GetOperation(base.Location); Arguments arguments2 = new Arguments(3); arguments2.Add(new Argument(fieldExpr, Argument.AType.Ref)); arguments2.Add(new Argument(new Cast(new TypeExpression(backing_field.MemberType, base.Location), new Invocation(MethodGroupExpr.CreatePredefined(operation, operation.DeclaringType, base.Location), arguments), base.Location))); arguments2.Add(new Argument(new LocalVariableReference(li, base.Location))); MethodSpec methodSpec = Module.PredefinedMembers.InterlockedCompareExchange_T.Get(); if (methodSpec == null) { if (Module.PredefinedMembers.MonitorEnter_v4.Get() != null || Module.PredefinedMembers.MonitorEnter.Get() != null) { explicitBlock.AddStatement(new Lock(block.GetParameterReference(0, base.Location), new StatementExpression(new SimpleAssign(fieldExpr, arguments2[1].Expr, base.Location), base.Location), base.Location)); } else { Module.PredefinedMembers.InterlockedCompareExchange_T.Resolve(base.Location); } } else { explicitBlock.AddStatement(new StatementExpression(new SimpleAssign(new LocalVariableReference(li, base.Location), new Invocation(MethodGroupExpr.CreatePredefined(methodSpec, methodSpec.DeclaringType, base.Location), arguments2)))); } } } private sealed class AddDelegateMethod : EventFieldAccessor { public AddDelegateMethod(EventField method) : base(method, "add_") { } protected override MethodSpec GetOperation(Location loc) { return Module.PredefinedMembers.DelegateCombine.Resolve(loc); } } private sealed class RemoveDelegateMethod : EventFieldAccessor { public RemoveDelegateMethod(EventField method) : base(method, "remove_") { } protected override MethodSpec GetOperation(Location loc) { return Module.PredefinedMembers.DelegateRemove.Resolve(loc); } } private static readonly string[] attribute_targets = new string[3] { "event", "field", "method" }; private static readonly string[] attribute_targets_interface = new string[2] { "event", "method" }; private Expression initializer; private Field backing_field; private List declarators; public List Declarators => declarators; private bool HasBackingField => !IsInterface && (base.ModFlags & Modifiers.ABSTRACT) == 0; public Expression Initializer { get { return initializer; } set { initializer = value; } } public override string[] ValidAttributeTargets => HasBackingField ? attribute_targets : attribute_targets_interface; public EventField(TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base(parent, type, mod_flags, name, attrs) { base.Add = new AddDelegateMethod(this); base.Remove = new RemoveDelegateMethod(this); } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public void AddDeclarator(FieldDeclarator declarator) { if (declarators == null) { declarators = new List(2); } declarators.Add(declarator); Parent.AddNameToContainer(this, declarator.Name.Value); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Field) { backing_field.ApplyAttributeBuilder(a, ctor, cdata, pa); } else if (a.Target == AttributeTargets.Method) { int errors = base.Report.Errors; base.Add.ApplyAttributeBuilder(a, ctor, cdata, pa); if (errors == base.Report.Errors) { base.Remove.ApplyAttributeBuilder(a, ctor, cdata, pa); } } else { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } protected override void DoMemberTypeIndependentChecks() { if ((Parent.PartialContainer.ModFlags & Modifiers.READONLY) != 0 && (base.ModFlags & Modifiers.STATIC) == 0) { base.Report.Error(8342, base.Location, "`{0}': Field-like instance events are not allowed in readonly structs", GetSignatureForError()); } base.DoMemberTypeIndependentChecks(); } public override bool Define() { Modifiers modifiers = base.ModFlags; if (!base.Define()) { return false; } if (declarators != null) { if ((modifiers & Modifiers.DEFAULT_ACCESS_MODIFIER) != 0) { modifiers &= ~(Modifiers.AccessibilityMask | Modifiers.DEFAULT_ACCESS_MODIFIER); } TypeExpression type = new TypeExpression(base.MemberType, base.TypeExpression.Location); foreach (FieldDeclarator declarator in declarators) { EventField eventField = new EventField(Parent, type, modifiers, new MemberName(declarator.Name.Value, declarator.Name.Location), base.OptAttributes); if (declarator.Initializer != null) { eventField.initializer = declarator.Initializer; } eventField.Define(); Parent.PartialContainer.Members.Add(eventField); } } if (!HasBackingField) { SetIsUsed(); return true; } backing_field = new Field(Parent, new TypeExpression(base.MemberType, base.Location), Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.BACKING_FIELD | Modifiers.DEBUGGER_HIDDEN | (base.ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)), base.MemberName, null); Parent.PartialContainer.Members.Add(backing_field); backing_field.Initializer = Initializer; backing_field.Define(); spec.BackingField = backing_field.Spec; return true; } } internal abstract class Event : PropertyBasedMember { public abstract class AEventAccessor : AbstractPropertyEventMethod { protected readonly Event method; private readonly ParametersCompiled parameters; private static readonly string[] attribute_targets = new string[3] { "method", "param", "return" }; public const string AddPrefix = "add_"; public const string RemovePrefix = "remove_"; public bool IsInterfaceImplementation => method_data.implementing != null; public override AttributeTargets AttributeTargets => AttributeTargets.Method; public override TypeSpec ReturnType => Parent.Compiler.BuiltinTypes.Void; public MethodData MethodData => method_data; public override string[] ValidAttributeTargets => attribute_targets; public override ParametersCompiled ParameterInfo => parameters; protected AEventAccessor(Event method, string prefix, Attributes attrs, Location loc) : base(method, prefix, attrs, loc) { this.method = method; base.ModFlags = method.ModFlags; parameters = ParametersCompiled.CreateImplicitParameter(method.TypeExpression, loc); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Type == pa.MethodImpl) { method.is_external_implementation = a.IsInternalCall(); } base.ApplyAttributeBuilder(a, ctor, cdata, pa); } protected override void ApplyToExtraTarget(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.Target == AttributeTargets.Parameter) { parameters[0].ApplyAttributeBuilder(a, ctor, cdata, pa); } else { base.ApplyToExtraTarget(a, ctor, cdata, pa); } } public override bool IsClsComplianceRequired() { return method.IsClsComplianceRequired(); } public virtual void Define(TypeContainer parent) { ((Parameter)parameters.FixedParameters[0]).Type = method.member_type; parameters.Types = new TypeSpec[1] { method.member_type }; method_data = new MethodData(method, method.ModFlags, method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this); if (method_data.Define(parent.PartialContainer, method.GetFullName(base.MemberName))) { if (Compiler.Settings.WriteMetadataOnly) { block = null; } base.Spec = new MethodSpec(MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, ParameterInfo, method.ModFlags); base.Spec.IsAccessor = true; } } public override ObsoleteAttribute GetAttributeObsolete() { return method.GetAttributeObsolete(); } } private AEventAccessor add; private AEventAccessor remove; private EventBuilder EventBuilder; protected EventSpec spec; public override AttributeTargets AttributeTargets => AttributeTargets.Event; public AEventAccessor Add { get { return add; } set { add = value; Parent.AddNameToContainer(value, value.MemberName.Basename); } } public override Variance ExpectedMemberTypeVariance => Variance.Contravariant; public AEventAccessor Remove { get { return remove; } set { remove = value; Parent.AddNameToContainer(value, value.MemberName.Basename); } } public override string DocCommentHeader => "E:"; protected Event(TypeDefinition parent, FullNamedExpression type, Modifiers mod_flags, MemberName name, Attributes attrs) : base(parent, type, mod_flags, (parent.PartialContainer.Kind == MemberKind.Interface) ? (Modifiers.NEW | Modifiers.UNSAFE) : ((parent.PartialContainer.Kind == MemberKind.Struct) ? (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.STATIC | Modifiers.OVERRIDE) : (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.STATIC | Modifiers.VIRTUAL | Modifiers.OVERRIDE)), name, attrs) { } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (a.HasSecurityAttribute) { a.Error_InvalidSecurityParent(); } else { EventBuilder.SetCustomAttribute((ConstructorInfo)ctor.GetMetaInfo(), cdata); } } protected override bool CheckOverrideAgainstBase(MemberSpec base_member) { bool result = base.CheckOverrideAgainstBase(base_member); if (!InterfaceMemberBase.CheckAccessModifiers(this, base_member)) { Error_CannotChangeAccessModifiers(this, base_member); result = false; } return result; } public override bool Define() { if (!base.Define()) { return false; } if (!base.MemberType.IsDelegate) { base.Report.Error(66, base.Location, "`{0}': event must be of a delegate type", GetSignatureForError()); } if (!CheckBase()) { return false; } add.Define(Parent); remove.Define(Parent); EventBuilder = Parent.TypeBuilder.DefineEvent(GetFullName(base.MemberName), EventAttributes.None, base.MemberType.GetMetaInfo()); spec = new EventSpec(Parent.Definition, this, base.MemberType, base.ModFlags, Add.Spec, remove.Spec); Parent.MemberCache.AddMember(this, GetFullName(base.MemberName), spec); Parent.MemberCache.AddMember(this, Add.Spec.Name, Add.Spec); Parent.MemberCache.AddMember(this, Remove.Spec.Name, remove.Spec); return true; } public override void Emit() { CheckReservedNameConflict(null, add.Spec); CheckReservedNameConflict(null, remove.Spec); if (base.OptAttributes != null) { base.OptAttributes.Emit(); } ConstraintChecker.Check(this, member_type, type_expr.Location); Add.Emit(Parent); Remove.Emit(Parent); base.Emit(); } public override void PrepareEmit() { base.PrepareEmit(); add.PrepareEmit(); remove.PrepareEmit(); EventBuilder.SetAddOnMethod(add.MethodData.MethodBuilder); EventBuilder.SetRemoveOnMethod(remove.MethodData.MethodBuilder); } public override void WriteDebugSymbol(MonoSymbolFile file) { add.WriteDebugSymbol(file); remove.WriteDebugSymbol(file); } } internal class EventSpec : MemberSpec, IInterfaceMemberSpec { private MethodSpec add; private MethodSpec remove; private FieldSpec backing_field; public MethodSpec AccessorAdd { get { return add; } set { add = value; } } public MethodSpec AccessorRemove { get { return remove; } set { remove = value; } } public FieldSpec BackingField { get { return backing_field; } set { backing_field = value; } } public TypeSpec MemberType { get; private set; } public EventSpec(TypeSpec declaringType, IMemberDefinition definition, TypeSpec eventType, Modifiers modifiers, MethodSpec add, MethodSpec remove) : base(MemberKind.Event, declaringType, definition, modifiers) { AccessorAdd = add; AccessorRemove = remove; MemberType = eventType; } public override MemberSpec InflateMember(TypeParameterInflator inflator) { EventSpec eventSpec = (EventSpec)base.InflateMember(inflator); eventSpec.MemberType = inflator.Inflate(MemberType); if (backing_field != null) { eventSpec.backing_field = (FieldSpec)backing_field.InflateMember(inflator); } return eventSpec; } public override List ResolveMissingDependencies(MemberSpec caller) { return MemberType.ResolveMissingDependencies(this); } } internal class Indexer : PropertyBase, IParametersMember, IInterfaceMemberSpec { public class GetIndexerMethod : GetMethod, IParametersMember, IInterfaceMemberSpec { private ParametersCompiled parameters; public override ParametersCompiled ParameterInfo => parameters; AParametersCollection IParametersMember.Parameters => parameters; TypeSpec IInterfaceMemberSpec.MemberType => ReturnType; public GetIndexerMethod(PropertyBase property, Modifiers modifiers, ParametersCompiled parameters, Attributes attrs, Location loc) : base(property, modifiers, attrs, loc) { this.parameters = parameters; } public override void Define(TypeContainer parent) { base.Report.DisableReporting(); try { parameters.Resolve(this); } finally { base.Report.EnableReporting(); } base.Define(parent); } } public class SetIndexerMethod : SetMethod, IParametersMember, IInterfaceMemberSpec { AParametersCollection IParametersMember.Parameters => parameters; TypeSpec IInterfaceMemberSpec.MemberType => ReturnType; public SetIndexerMethod(PropertyBase property, Modifiers modifiers, ParametersCompiled parameters, Attributes attrs, Location loc) : base(property, modifiers, parameters, attrs, loc) { } } private const Modifiers AllowedModifiers = Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.VIRTUAL | Modifiers.OVERRIDE; private const Modifiers AllowedInterfaceModifiers = Modifiers.NEW; private readonly ParametersCompiled parameters; AParametersCollection IParametersMember.Parameters => parameters; public ParametersCompiled ParameterInfo => parameters; public Indexer(TypeDefinition parent, FullNamedExpression type, MemberName name, Modifiers mod, ParametersCompiled parameters, Attributes attrs) : base(parent, type, mod, (parent.PartialContainer.Kind == MemberKind.Interface) ? Modifiers.NEW : (Modifiers.AccessibilityMask | Modifiers.AllowedExplicitImplFlags | Modifiers.NEW | Modifiers.ABSTRACT | Modifiers.SEALED | Modifiers.VIRTUAL | Modifiers.OVERRIDE), name, attrs) { this.parameters = parameters; } public override void Accept(StructuralVisitor visitor) { visitor.Visit(this); } public override void ApplyAttributeBuilder(Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa) { if (!(a.Type == pa.IndexerName)) { base.ApplyAttributeBuilder(a, ctor, cdata, pa); } } protected override bool CheckForDuplications() { return Parent.MemberCache.CheckExistingMembersOverloads(this, parameters); } public override bool Define() { if (!base.Define()) { return false; } if (!DefineParameters(parameters)) { return false; } if (base.OptAttributes != null) { Attribute attribute = base.OptAttributes.Search(Module.PredefinedAttributes.IndexerName); if (attribute != null) { if (attribute.Type.MemberDefinition is TypeContainer typeContainer) { typeContainer.Define(); } if (IsExplicitImpl) { base.Report.Error(415, attribute.Location, "The `{0}' attribute is valid only on an indexer that is not an explicit interface member declaration", attribute.Type.GetSignatureForError()); } else if ((base.ModFlags & Modifiers.OVERRIDE) != 0) { base.Report.Error(609, attribute.Location, "Cannot set the `IndexerName' attribute on an indexer marked override"); } else { string indexerAttributeValue = attribute.GetIndexerAttributeValue(); if (!string.IsNullOrEmpty(indexerAttributeValue)) { SetMemberName(new MemberName(base.MemberName.Left, indexerAttributeValue, base.Location)); } } } } if (InterfaceType != null) { string attributeDefaultMember = InterfaceType.MemberDefinition.GetAttributeDefaultMember(); if (attributeDefaultMember != base.ShortName) { SetMemberName(new MemberName(base.MemberName.Left, attributeDefaultMember, new TypeExpression(InterfaceType, base.Location), base.Location)); } } Parent.AddNameToContainer(this, base.MemberName.Basename); flags |= MethodAttributes.HideBySig | MethodAttributes.SpecialName; if (!DefineAccessors()) { return false; } if (!CheckBase()) { return false; } DefineBuilders(MemberKind.Indexer, parameters); return true; } public override bool EnableOverloadChecks(MemberCore overload) { if (overload is Indexer) { caching_flags |= Flags.MethodOverloadsExist; return true; } return base.EnableOverloadChecks(overload); } public override void Emit() { parameters.CheckConstraints(this); base.Emit(); } public override string GetSignatureForError() { StringBuilder stringBuilder = new StringBuilder(Parent.GetSignatureForError()); if (base.MemberName.ExplicitInterface != null) { stringBuilder.Append("."); stringBuilder.Append(base.MemberName.ExplicitInterface.GetSignatureForError()); } stringBuilder.Append(".this"); stringBuilder.Append(parameters.GetSignatureForError("[", "]", parameters.Count)); return stringBuilder.ToString(); } public override string GetSignatureForDocumentation() { return base.GetSignatureForDocumentation() + parameters.GetSignatureForDocumentation(); } public override void PrepareEmit() { base.PrepareEmit(); parameters.ResolveDefaultValues(this); } protected override bool VerifyClsCompliance() { if (!base.VerifyClsCompliance()) { return false; } parameters.VerifyClsCompliance(this); return true; } } internal class IndexerSpec : PropertySpec, IParametersMember, IInterfaceMemberSpec { private AParametersCollection parameters; public AParametersCollection Parameters => parameters; public IndexerSpec(TypeSpec declaringType, IMemberDefinition definition, TypeSpec memberType, AParametersCollection parameters, PropertyInfo info, Modifiers modifiers) : base(MemberKind.Indexer, declaringType, definition, memberType, info, modifiers) { this.parameters = parameters; } public static ParametersImported CreateParametersFromSetter(MethodSpec setter, int set_param_count) { IParameterData[] array = new IParameterData[set_param_count]; TypeSpec[] array2 = new TypeSpec[set_param_count]; Array.Copy(setter.Parameters.FixedParameters, array, set_param_count); Array.Copy(setter.Parameters.Types, array2, set_param_count); return new ParametersImported(array, array2, setter.Parameters.HasParams); } public override string GetSignatureForDocumentation() { return base.GetSignatureForDocumentation() + parameters.GetSignatureForDocumentation(); } public override string GetSignatureForError() { return base.DeclaringType.GetSignatureForError() + ".this" + parameters.GetSignatureForError("[", "]", parameters.Count); } public override MemberSpec InflateMember(TypeParameterInflator inflator) { IndexerSpec indexerSpec = (IndexerSpec)base.InflateMember(inflator); indexerSpec.parameters = parameters.Inflate(inflator); return indexerSpec; } public override List ResolveMissingDependencies(MemberSpec caller) { List list = base.ResolveMissingDependencies(caller); TypeSpec[] types = parameters.Types; foreach (TypeSpec typeSpec in types) { List missingDependencies = typeSpec.GetMissingDependencies(caller); if (missingDependencies != null) { if (list == null) { list = new List(); } list.AddRange(missingDependencies); } } return list; } } internal class ReflectionImporter : MetadataImporter { public ReflectionImporter(ModuleContainer module, BuiltinTypes builtin) : base(module) { base.IgnoreCompilerGeneratedField = false; Initialize(builtin); } public override void AddCompiledType(TypeBuilder builder, TypeSpec spec) { } protected override MemberKind DetermineKindFromBaseType(Type baseType) { if ((object)baseType == typeof(ValueType)) { return MemberKind.Struct; } if ((object)baseType == typeof(System.Enum)) { return MemberKind.Enum; } if ((object)baseType == typeof(MulticastDelegate)) { return MemberKind.Delegate; } return MemberKind.Class; } protected override bool HasVolatileModifier(Type[] modifiers) { foreach (Type type in modifiers) { if ((object)type == typeof(IsVolatile)) { return true; } } return false; } public void ImportAssembly(Assembly assembly, RootNamespace targetNamespace) { GetAssemblyDefinition(assembly); Type[] types; try { types = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } ImportTypes(types, targetNamespace, importExtensionTypes: true); } public ImportedModuleDefinition ImportModule(Module module, RootNamespace targetNamespace) { ImportedModuleDefinition importedModuleDefinition = new ImportedModuleDefinition(module); importedModuleDefinition.ReadAttributes(); Type[] types; try { types = module.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } ImportTypes(types, targetNamespace, importExtensionTypes: false); return importedModuleDefinition; } private void Initialize(BuiltinTypes builtin) { compiled_types.Add(typeof(object), builtin.Object); compiled_types.Add(typeof(ValueType), builtin.ValueType); compiled_types.Add(typeof(System.Attribute), builtin.Attribute); compiled_types.Add(typeof(int), builtin.Int); compiled_types.Add(typeof(long), builtin.Long); compiled_types.Add(typeof(uint), builtin.UInt); compiled_types.Add(typeof(ulong), builtin.ULong); compiled_types.Add(typeof(byte), builtin.Byte); compiled_types.Add(typeof(sbyte), builtin.SByte); compiled_types.Add(typeof(short), builtin.Short); compiled_types.Add(typeof(ushort), builtin.UShort); compiled_types.Add(typeof(IEnumerator), builtin.IEnumerator); compiled_types.Add(typeof(IEnumerable), builtin.IEnumerable); compiled_types.Add(typeof(IDisposable), builtin.IDisposable); compiled_types.Add(typeof(char), builtin.Char); compiled_types.Add(typeof(string), builtin.String); compiled_types.Add(typeof(float), builtin.Float); compiled_types.Add(typeof(double), builtin.Double); compiled_types.Add(typeof(decimal), builtin.Decimal); compiled_types.Add(typeof(bool), builtin.Bool); compiled_types.Add(typeof(IntPtr), builtin.IntPtr); compiled_types.Add(typeof(UIntPtr), builtin.UIntPtr); compiled_types.Add(typeof(MulticastDelegate), builtin.MulticastDelegate); compiled_types.Add(typeof(System.Delegate), builtin.Delegate); compiled_types.Add(typeof(System.Enum), builtin.Enum); compiled_types.Add(typeof(Array), builtin.Array); compiled_types.Add(typeof(void), builtin.Void); compiled_types.Add(typeof(Type), builtin.Type); compiled_types.Add(typeof(Exception), builtin.Exception); compiled_types.Add(typeof(RuntimeFieldHandle), builtin.RuntimeFieldHandle); compiled_types.Add(typeof(RuntimeTypeHandle), builtin.RuntimeTypeHandle); } } [StructLayout(LayoutKind.Explicit)] internal struct SingleConverter { [FieldOffset(0)] private int i; [FieldOffset(0)] private float f; public static int SingleToInt32Bits(float v) { SingleConverter singleConverter = new SingleConverter { f = v }; return singleConverter.i; } } internal class AssemblyDefinitionDynamic : AssemblyDefinition { public AssemblyDefinitionDynamic(ModuleContainer module, string name) : base(module, name) { } public AssemblyDefinitionDynamic(ModuleContainer module, string name, string fileName) : base(module, name, fileName) { } public Module IncludeModule(string moduleFile) { return builder_extra.AddModule(moduleFile); } public override ModuleBuilder CreateModuleBuilder() { if (file_name == null) { return Builder.DefineDynamicModule(base.Name); } return base.CreateModuleBuilder(); } public bool Create(AppDomain domain, AssemblyBuilderAccess access) { ResolveAssemblySecurityAttributes(); AssemblyName assemblyName = CreateAssemblyName(); Builder = (Builder = ((file_name == null) ? domain.DefineDynamicAssembly(assemblyName, access) : domain.DefineDynamicAssembly(assemblyName, access, Dirname(file_name)))); Builder.MarkCorlibInternal(); module.Create(this, CreateModuleBuilder()); builder_extra = new AssemblyBuilderMonoSpecific(Builder, base.Compiler); return true; } private static string Dirname(string name) { int num = name.LastIndexOf('/'); if (num != -1) { return name.Substring(0, num); } num = name.LastIndexOf('\\'); if (num != -1) { return name.Substring(0, num); } return "."; } protected override void SaveModule(PortableExecutableKinds pekind, ImageFileMachine machine) { } } internal class AssemblyBuilderMonoSpecific : AssemblyBuilderExtension { private static MethodInfo adder_method; private static MethodInfo add_permission; private static MethodInfo add_type_forwarder; private static MethodInfo win32_icon_define; private static FieldInfo assembly_version; private static FieldInfo assembly_algorithm; private static FieldInfo assembly_culture; private static FieldInfo assembly_flags; private AssemblyBuilder builder; public AssemblyBuilderMonoSpecific(AssemblyBuilder ab, CompilerContext ctx) : base(ctx) { builder = ab; } public override Module AddModule(string module) { try { if ((object)adder_method == null) { adder_method = typeof(AssemblyBuilder).GetMethod("AddModule", BindingFlags.Instance | BindingFlags.NonPublic); } return (Module)adder_method.Invoke(builder, new object[1] { module }); } catch { return base.AddModule(module); } } public override void AddPermissionRequests(PermissionSet[] permissions) { try { if ((object)add_permission == null) { add_permission = typeof(AssemblyBuilder).GetMethod("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic); } add_permission.Invoke(builder, permissions); } catch { base.AddPermissionRequests(permissions); } } public override void AddTypeForwarder(TypeSpec type, Location loc) { try { if ((object)add_type_forwarder == null) { add_type_forwarder = typeof(AssemblyBuilder).GetMethod("AddTypeForwarder", BindingFlags.Instance | BindingFlags.NonPublic); } add_type_forwarder.Invoke(builder, new object[1] { type.GetMetaInfo() }); } catch { base.AddTypeForwarder(type, loc); } } public override void DefineWin32IconResource(string fileName) { try { if ((object)win32_icon_define == null) { win32_icon_define = typeof(AssemblyBuilder).GetMethod("DefineIconResource", BindingFlags.Instance | BindingFlags.NonPublic); } win32_icon_define.Invoke(builder, new object[1] { fileName }); } catch { base.DefineWin32IconResource(fileName); } } public override void SetAlgorithmId(uint value, Location loc) { try { if ((object)assembly_algorithm == null) { assembly_algorithm = typeof(AssemblyBuilder).GetField("algid", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField); } assembly_algorithm.SetValue(builder, value); } catch { base.SetAlgorithmId(value, loc); } } public override void SetCulture(string culture, Location loc) { try { if ((object)assembly_culture == null) { assembly_culture = typeof(AssemblyBuilder).GetField("culture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField); } assembly_culture.SetValue(builder, culture); } catch { base.SetCulture(culture, loc); } } public override void SetFlags(uint flags, Location loc) { try { if ((object)assembly_flags == null) { assembly_flags = typeof(AssemblyBuilder).GetField("flags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField); } assembly_flags.SetValue(builder, flags); } catch { base.SetFlags(flags, loc); } } public override void SetVersion(Version version, Location loc) { try { if ((object)assembly_version == null) { assembly_version = typeof(AssemblyBuilder).GetField("version", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField); } assembly_version.SetValue(builder, version.ToString(4)); } catch { base.SetVersion(version, loc); } } } internal class DynamicLoader : AssemblyReferencesLoader { public ReflectionImporter importer; public ReflectionImporter Importer => importer; public DynamicLoader(ReflectionImporter importer, CompilerContext compiler) : base(compiler) { paths.Add(GetSystemDir()); this.importer = importer; } public override string[] GetDefaultReferences() { List list = new List(8); list.Add("System"); list.Add("System.Xml"); if (compiler.Settings.Version > LanguageVersion.ISO_2) { list.Add("System.Core"); } if (compiler.Settings.Version > LanguageVersion.V_3) { list.Add("Microsoft.CSharp"); } return list.ToArray(); } private static string GetSystemDir() { return Path.GetDirectoryName(typeof(object).Assembly.Location); } public override Assembly HasObjectType(Assembly assembly) { return ((object)assembly.GetType(compiler.BuiltinTypes.Object.FullName) == null) ? null : assembly; } public override Assembly LoadAssemblyFile(string assembly, bool isImplicitReference) { Assembly result = null; try { try { char[] anyOf = new char[2] { '/', '\\' }; if (assembly.IndexOfAny(anyOf) != -1) { result = Assembly.LoadFrom(assembly); } else { string text = assembly; if (text.EndsWith(".dll") || text.EndsWith(".exe")) { text = assembly.Substring(0, assembly.Length - 4); } result = Assembly.Load(text); } } catch (FileNotFoundException) { bool flag = !isImplicitReference; foreach (string path in paths) { string text2 = Path.Combine(path, assembly); if (!assembly.EndsWith(".dll") && !assembly.EndsWith(".exe")) { text2 += ".dll"; } try { result = Assembly.LoadFrom(text2); flag = false; } catch (FileNotFoundException) { continue; } break; } if (flag) { Error_FileNotFound(assembly); return result; } } } catch (BadImageFormatException) { Error_FileCorrupted(assembly); } return result; } private Module LoadModuleFile(AssemblyDefinitionDynamic assembly, string module) { string text = ""; try { try { return assembly.IncludeModule(module); } catch (FileNotFoundException) { bool flag = true; foreach (string path in paths) { string text2 = Path.Combine(path, module); if (!module.EndsWith(".netmodule")) { text2 += ".netmodule"; } try { return assembly.IncludeModule(text2); } catch (FileNotFoundException ex2) { text += ex2.FusionLog; } } if (flag) { Error_FileNotFound(module); return null; } } } catch (BadImageFormatException) { Error_FileCorrupted(module); } return null; } public void LoadModules(AssemblyDefinitionDynamic assembly, RootNamespace targetNamespace) { foreach (string module3 in compiler.Settings.Modules) { Module module = LoadModuleFile(assembly, module3); if ((object)module != null) { ImportedModuleDefinition module2 = importer.ImportModule(module, targetNamespace); assembly.AddModule(module2); } } } public override void LoadReferences(ModuleContainer module) { LoadReferencesCore(module, out var corlib_assembly, out var loaded); if ((object)corlib_assembly == null) { return; } importer.ImportAssembly(corlib_assembly, module.GlobalRootNamespace); foreach (Tuple item in loaded) { importer.ImportAssembly(item.Item2, item.Item1); } } } internal class Report { public const int RuntimeErrorId = 10000; private Dictionary warning_regions_table; private ReportPrinter printer; private int reporting_disabled; private readonly CompilerSettings settings; private List extra_information = new List(); public static readonly int[] AllWarnings = new int[138] { 28, 67, 78, 105, 108, 109, 114, 162, 164, 168, 169, 183, 184, 197, 219, 251, 252, 253, 278, 282, 402, 414, 419, 420, 429, 436, 437, 440, 458, 464, 465, 467, 469, 472, 473, 612, 618, 626, 628, 642, 649, 652, 657, 658, 659, 660, 661, 665, 672, 675, 693, 728, 809, 824, 1030, 1058, 1060, 1066, 1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 1587, 1589, 1590, 1591, 1592, 1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1697, 1699, 1700, 1701, 1702, 1709, 1711, 1717, 1718, 1720, 1735, 1901, 1956, 1981, 1998, 2002, 2023, 2029, 3000, 3001, 3002, 3003, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018, 3019, 3021, 3022, 3023, 3024, 3026, 3027, 4014, 4024, 4025, 4026, 7035, 7080, 7081, 7082, 7095, 8009, 8094, 8123 }; public int Warnings => printer.WarningsCount; public int Errors => printer.ErrorsCount; public bool IsDisabled => reporting_disabled > 0; public ReportPrinter Printer => printer; public Report(CompilerContext context, ReportPrinter printer) { if (context == null) { throw new ArgumentNullException("context"); } if (printer == null) { throw new ArgumentNullException("printer"); } settings = context.Settings; this.printer = printer; } public void DisableReporting() { reporting_disabled++; } public void EnableReporting() { reporting_disabled--; } public void FeatureIsNotAvailable(CompilerContext compiler, Location loc, string feature) { Error(1644, loc, "Feature `{0}' cannot be used because it is not part of the C# {1} language specification", feature, compiler.Settings.Version switch { LanguageVersion.ISO_1 => "1.0", LanguageVersion.ISO_2 => "2.0", LanguageVersion.V_3 => "3.0", LanguageVersion.V_4 => "4.0", LanguageVersion.V_5 => "5.0", LanguageVersion.V_6 => "6.0", LanguageVersion.V_7 => "7.0", _ => throw new InternalErrorException("Invalid feature version", compiler.Settings.Version), }); } public void FeatureIsNotSupported(Location loc, string feature) { Error(1644, loc, "Feature `{0}' is not supported in Mono mcs1 compiler. Consider using the `gmcs' compiler instead", feature); } public void RuntimeMissingSupport(Location loc, string feature) { Error(-88, loc, "Your .NET Runtime does not support `{0}'. Please use the latest Mono runtime instead.", feature); } public void SymbolRelatedToPreviousError(Location loc, string symbol) { SymbolRelatedToPreviousError(loc.ToString()); } public void SymbolRelatedToPreviousError(MemberSpec ms) { if (reporting_disabled > 0 || !printer.HasRelatedSymbolSupport) { return; } MemberCore memberCore = ms.MemberDefinition as MemberCore; while (ms is ElementTypeSpec) { ms = ((ElementTypeSpec)ms).Element; memberCore = ms.MemberDefinition as MemberCore; } if (memberCore != null) { SymbolRelatedToPreviousError(memberCore); return; } if (ms.DeclaringType != null) { ms = ms.DeclaringType; } if (ms.MemberDefinition is ImportedTypeDefinition importedTypeDefinition) { ImportedAssemblyDefinition importedAssemblyDefinition = importedTypeDefinition.DeclaringAssembly as ImportedAssemblyDefinition; SymbolRelatedToPreviousError(importedAssemblyDefinition.Location); } } public void SymbolRelatedToPreviousError(MemberCore mc) { SymbolRelatedToPreviousError(mc.Location, mc.GetSignatureForError()); } public void SymbolRelatedToPreviousError(string loc) { string item = $"{loc} (Location of the symbol related to previous "; if (!extra_information.Contains(item)) { extra_information.Add(item); } } public void ExtraInformation(Location loc, string msg) { extra_information.Add($"{loc} {msg}"); } public WarningRegions RegisterWarningRegion(Location location) { WarningRegions value; if (warning_regions_table == null) { value = null; warning_regions_table = new Dictionary(); } else { warning_regions_table.TryGetValue(location.File, out value); } if (value == null) { value = new WarningRegions(); warning_regions_table.Add(location.File, value); } return value; } public void Warning(int code, int level, Location loc, string message) { if (reporting_disabled <= 0 && settings.IsWarningEnabled(code, level) && (warning_regions_table == null || loc.IsNull || !warning_regions_table.TryGetValue(loc.File, out var value) || value.IsWarningEnabled(code, loc.Row))) { AbstractMessage msg; if (settings.IsWarningAsError(code)) { message = "Warning as Error: " + message; msg = new ErrorMessage(code, loc, message, extra_information); } else { msg = new WarningMessage(code, loc, message, extra_information); } extra_information.Clear(); printer.Print(msg, settings.ShowFullPaths); } } public void Warning(int code, int level, Location loc, string format, string arg) { Warning(code, level, loc, string.Format(format, arg)); } public void Warning(int code, int level, Location loc, string format, string arg1, string arg2) { Warning(code, level, loc, string.Format(format, arg1, arg2)); } public void Warning(int code, int level, Location loc, string format, params object[] args) { Warning(code, level, loc, string.Format(format, args)); } public void Warning(int code, int level, string message) { Warning(code, level, Location.Null, message); } public void Warning(int code, int level, string format, string arg) { Warning(code, level, Location.Null, format, arg); } public void Warning(int code, int level, string format, string arg1, string arg2) { Warning(code, level, Location.Null, format, arg1, arg2); } public void Warning(int code, int level, string format, params string[] args) { Warning(code, level, Location.Null, string.Format(format, args)); } public void Error(int code, Location loc, string error) { if (reporting_disabled <= 0) { ErrorMessage errorMessage = new ErrorMessage(code, loc, error, extra_information); extra_information.Clear(); printer.Print(errorMessage, settings.ShowFullPaths); if (settings.Stacktrace) { Console.WriteLine(FriendlyStackTrace(new StackTrace(fNeedFileInfo: true))); } if (printer.ErrorsCount == settings.FatalCounter) { throw new FatalException(errorMessage.Text); } } } public void Error(int code, Location loc, string format, string arg) { Error(code, loc, string.Format(format, arg)); } public void Error(int code, Location loc, string format, string arg1, string arg2) { Error(code, loc, string.Format(format, arg1, arg2)); } public void Error(int code, Location loc, string format, params string[] args) { Error(code, loc, string.Format(format, args)); } public void Error(int code, string error) { Error(code, Location.Null, error); } public void Error(int code, string format, string arg) { Error(code, Location.Null, format, arg); } public void Error(int code, string format, string arg1, string arg2) { Error(code, Location.Null, format, arg1, arg2); } public void Error(int code, string format, params string[] args) { Error(code, Location.Null, string.Format(format, args)); } public ReportPrinter SetPrinter(ReportPrinter printer) { ReportPrinter result = this.printer; this.printer = printer; return result; } [Conditional("MCS_DEBUG")] public static void Debug(string message, params object[] args) { } [Conditional("MCS_DEBUG")] public static void Debug(int category, string message, params object[] args) { StringBuilder stringBuilder = new StringBuilder(message); if (args != null && args.Length != 0) { stringBuilder.Append(": "); bool flag = true; foreach (object obj in args) { if (flag) { flag = false; } else { stringBuilder.Append(", "); } if (obj == null) { stringBuilder.Append("null"); } else { stringBuilder.Append(obj); } } } Console.WriteLine(stringBuilder.ToString()); } private static string FriendlyStackTrace(StackTrace t) { StringBuilder stringBuilder = new StringBuilder(); bool flag = false; for (int i = 0; i < t.FrameCount; i++) { StackFrame frame = t.GetFrame(i); MethodBase method = frame.GetMethod(); if (!flag && (object)method.ReflectedType == typeof(Report)) { continue; } flag = true; stringBuilder.Append("\tin "); if (frame.GetFileLineNumber() > 0) { stringBuilder.AppendFormat("(at {0}:{1}) ", frame.GetFileName(), frame.GetFileLineNumber()); } stringBuilder.AppendFormat("{0}.{1} (", method.ReflectedType.Name, method.Name); bool flag2 = true; ParameterInfo[] parameters = method.GetParameters(); foreach (ParameterInfo parameterInfo in parameters) { if (!flag2) { stringBuilder.Append(", "); } flag2 = false; stringBuilder.Append(parameterInfo.ParameterType.FullName); } stringBuilder.Append(")\n"); } return stringBuilder.ToString(); } } internal abstract class AbstractMessage { private readonly string[] extra_info; protected readonly int code; protected readonly Location location; private readonly string message; public int Code => code; public abstract bool IsWarning { get; } public Location Location => location; public abstract string MessageType { get; } public string[] RelatedSymbols => extra_info; public string Text => message; protected AbstractMessage(int code, Location loc, string msg, List extraInfo) { this.code = code; if (code < 0) { this.code = 8000 - code; } location = loc; message = msg; if (extraInfo.Count != 0) { extra_info = extraInfo.ToArray(); } } protected AbstractMessage(AbstractMessage aMsg) { code = aMsg.code; location = aMsg.location; message = aMsg.message; extra_info = aMsg.extra_info; } public override bool Equals(object obj) { if (!(obj is AbstractMessage abstractMessage)) { return false; } return code == abstractMessage.code && location.Equals(abstractMessage.location) && message == abstractMessage.message; } public override int GetHashCode() { int num = code; return num.GetHashCode(); } } internal sealed class WarningMessage : AbstractMessage { public override bool IsWarning => true; public override string MessageType => "warning"; public WarningMessage(int code, Location loc, string message, List extra_info) : base(code, loc, message, extra_info) { } } internal sealed class ErrorMessage : AbstractMessage { public override bool IsWarning => false; public override string MessageType => "error"; public ErrorMessage(int code, Location loc, string message, List extraInfo) : base(code, loc, message, extraInfo) { } public ErrorMessage(AbstractMessage aMsg) : base(aMsg) { } } internal abstract class ReportPrinter { protected HashSet reported_missing_definitions; public int ErrorsCount { get; protected set; } public int WarningsCount { get; private set; } public virtual bool HasRelatedSymbolSupport => false; protected virtual string FormatText(string txt) { return txt; } public virtual void Print(AbstractMessage msg, bool showFullPath) { if (msg.IsWarning) { int warningsCount = WarningsCount + 1; WarningsCount = warningsCount; } else { int warningsCount = ErrorsCount + 1; ErrorsCount = warningsCount; } } protected void Print(AbstractMessage msg, TextWriter output, bool showFullPath) { StringBuilder stringBuilder = new StringBuilder(); if (!msg.Location.IsNull) { if (showFullPath) { stringBuilder.Append(msg.Location.ToStringFullName()); } else { stringBuilder.Append(msg.Location.ToString()); } stringBuilder.Append(" "); } stringBuilder.AppendFormat("{0} CS{1:0000}: {2}", msg.MessageType, msg.Code, msg.Text); if (!msg.IsWarning) { output.WriteLine(FormatText(stringBuilder.ToString())); } else { output.WriteLine(stringBuilder.ToString()); } if (msg.RelatedSymbols != null) { string[] relatedSymbols = msg.RelatedSymbols; foreach (string text in relatedSymbols) { output.WriteLine(text + msg.MessageType + ")"); } } } public bool MissingTypeReported(ITypeDefinition typeDefinition) { if (reported_missing_definitions == null) { reported_missing_definitions = new HashSet(); } if (reported_missing_definitions.Contains(typeDefinition)) { return true; } reported_missing_definitions.Add(typeDefinition); return false; } public void Reset() { int errorsCount = (WarningsCount = 0); ErrorsCount = errorsCount; } } internal sealed class NullReportPrinter : ReportPrinter { } internal class SessionReportPrinter : ReportPrinter { private List session_messages; private List common_messages; private List merged_messages; private bool showFullPaths; public bool IsEmpty => merged_messages == null && common_messages == null; public void ClearSession() { session_messages = null; } public override void Print(AbstractMessage msg, bool showFullPath) { if (session_messages == null) { session_messages = new List(); } session_messages.Add(msg); showFullPaths = showFullPath; base.Print(msg, showFullPath); } public void EndSession() { if (session_messages == null) { return; } if (common_messages == null) { common_messages = new List(session_messages); merged_messages = session_messages; session_messages = null; return; } for (int i = 0; i < common_messages.Count; i++) { AbstractMessage abstractMessage = common_messages[i]; bool flag = false; foreach (AbstractMessage session_message in session_messages) { if (abstractMessage.Equals(session_message)) { flag = true; break; } } if (!flag) { common_messages.RemoveAt(i); } } for (int j = 0; j < session_messages.Count; j++) { AbstractMessage abstractMessage2 = session_messages[j]; bool flag2 = false; for (int k = 0; k < merged_messages.Count; k++) { if (abstractMessage2.Equals(merged_messages[k])) { flag2 = true; break; } } if (!flag2) { merged_messages.Add(abstractMessage2); } } } public bool Merge(ReportPrinter dest) { List list = merged_messages; if (common_messages != null && common_messages.Count > 0) { list = common_messages; } if (list == null) { return false; } bool flag = false; foreach (AbstractMessage item in list) { dest.Print(item, showFullPaths); flag |= !item.IsWarning; } if (reported_missing_definitions != null) { foreach (ITypeDefinition reported_missing_definition in reported_missing_definitions) { dest.MissingTypeReported(reported_missing_definition); } } return flag; } } internal class StreamReportPrinter : ReportPrinter { private readonly TextWriter writer; public StreamReportPrinter(TextWriter writer) { this.writer = writer; } public override void Print(AbstractMessage msg, bool showFullPath) { Print(msg, writer, showFullPath); base.Print(msg, showFullPath); } } internal class ConsoleReportPrinter : StreamReportPrinter { private static readonly string prefix; private static readonly string postfix; static ConsoleReportPrinter() { string environmentVariable = Environment.GetEnvironmentVariable("TERM"); bool flag = false; switch (environmentVariable) { case "xterm": case "rxvt": case "rxvt-unicode": if (Environment.GetEnvironmentVariable("COLORTERM") != null) { flag = true; } break; case "xterm-color": case "xterm-256color": flag = true; break; } if (!flag || !UnixUtils.isatty(1) || !UnixUtils.isatty(2)) { return; } string text = Environment.GetEnvironmentVariable("MCS_COLORS"); if (text == null) { text = "errors=red"; } if (!(text == "disable") && text.StartsWith("errors=")) { text = text.Substring(7); int num = text.IndexOf(","); if (num == -1) { prefix = GetForeground(text); } else { prefix = GetBackground(text.Substring(num + 1)) + GetForeground(text.Substring(0, num)); } postfix = "\u001b[0m"; } } public ConsoleReportPrinter() : base(Console.Error) { } public ConsoleReportPrinter(TextWriter writer) : base(writer) { } private static int NameToCode(string s) { switch (s) { case "black": return 0; case "red": return 1; case "green": return 2; case "yellow": return 3; case "blue": return 4; case "magenta": return 5; case "cyan": return 6; case "grey": case "white": return 7; default: return 7; } } private static string GetForeground(string s) { string text; if (s.StartsWith("bright")) { text = "1;"; s = s.Substring(6); } else { text = ""; } return "\u001b[" + text + (30 + NameToCode(s)) + "m"; } private static string GetBackground(string s) { return "\u001b[" + (40 + NameToCode(s)) + "m"; } protected override string FormatText(string txt) { if (prefix != null) { return prefix + txt + postfix; } return txt; } } internal class TimeReporter { public enum TimerType { ParseTotal, AssemblyBuilderSetup, CreateTypeTotal, ReferencesLoading, ReferencesImporting, PredefinedTypesInit, ModuleDefinitionTotal, EmitTotal, CloseTypes, Resouces, OutputSave, DebugSave } private readonly Stopwatch[] timers; private Stopwatch total; public TimeReporter(bool enabled) { if (enabled) { timers = new Stopwatch[System.Enum.GetValues(typeof(TimerType)).Length]; } } public void Start(TimerType type) { if (timers != null) { Stopwatch stopwatch = new Stopwatch(); timers[(int)type] = stopwatch; stopwatch.Start(); } } public void StartTotal() { total = new Stopwatch(); total.Start(); } public void Stop(TimerType type) { if (timers != null) { timers[(int)type].Stop(); } } public void StopTotal() { total.Stop(); } public void ShowStats() { if (timers != null) { Dictionary dictionary = new Dictionary { { TimerType.ParseTotal, "Parsing source files" }, { TimerType.AssemblyBuilderSetup, "Assembly builder setup" }, { TimerType.CreateTypeTotal, "Compiled types created" }, { TimerType.ReferencesLoading, "Referenced assemblies loading" }, { TimerType.ReferencesImporting, "Referenced assemblies importing" }, { TimerType.PredefinedTypesInit, "Predefined types initialization" }, { TimerType.ModuleDefinitionTotal, "Module definition" }, { TimerType.EmitTotal, "Resolving and emitting members blocks" }, { TimerType.CloseTypes, "Module types closed" }, { TimerType.Resouces, "Embedding resources" }, { TimerType.OutputSave, "Writing output file" }, { TimerType.DebugSave, "Writing debug symbols file" } }; int num = 0; double num2 = (double)total.ElapsedMilliseconds / 100.0; long num3 = total.ElapsedMilliseconds; Stopwatch[] array = timers; foreach (Stopwatch stopwatch in array) { string arg = dictionary[(TimerType)(num++)]; long num4 = stopwatch?.ElapsedMilliseconds ?? 0; Console.WriteLine("{0,4:0.0}% {1,5}ms {2}", (double)num4 / num2, num4, arg); num3 -= num4; } Console.WriteLine("{0,4:0.0}% {1,5}ms Other tasks", (double)num3 / num2, num3); Console.WriteLine(); Console.WriteLine("Total elapsed time: {0}", total.Elapsed); } } } internal class InternalErrorException : Exception { public InternalErrorException(MemberCore mc, Exception e) : base(mc.Location.ToString() + " " + mc.GetSignatureForError(), e) { } public InternalErrorException() : base("Internal error") { } public InternalErrorException(string message) : base(message) { } public InternalErrorException(string message, params object[] args) : base(string.Format(message, args)) { } public InternalErrorException(Exception exception, string message, params object[] args) : base(string.Format(message, args), exception) { } public InternalErrorException(Exception e, Location loc) : base(loc.ToString(), e) { } } internal class FatalException : Exception { public FatalException(string message) : base(message) { } } internal class WarningRegions { private abstract class PragmaCmd { public int Line; protected PragmaCmd(int line) { Line = line; } public abstract bool IsEnabled(int code, bool previous); } private class Disable : PragmaCmd { private int code; public Disable(int line, int code) : base(line) { this.code = code; } public override bool IsEnabled(int code, bool previous) { return this.code != code && previous; } } private class DisableAll : PragmaCmd { public DisableAll(int line) : base(line) { } public override bool IsEnabled(int code, bool previous) { return false; } } private class Enable : PragmaCmd { private int code; public Enable(int line, int code) : base(line) { this.code = code; } public override bool IsEnabled(int code, bool previous) { return this.code == code || previous; } } private class EnableAll : PragmaCmd { public EnableAll(int line) : base(line) { } public override bool IsEnabled(int code, bool previous) { return true; } } private List regions = new List(); public void WarningDisable(int line) { regions.Add(new DisableAll(line)); } public void WarningDisable(Location location, int code, Report Report) { regions.Add(new Disable(location.Row, code)); } public void WarningEnable(int line) { regions.Add(new EnableAll(line)); } public void WarningEnable(Location location, int code, CompilerContext context) { if (context.Settings.IsWarningDisabledGlobally(code)) { context.Report.Warning(1635, 1, location, "Cannot restore warning `CS{0:0000}' because it was disabled globally", code); } regions.Add(new Enable(location.Row, code)); } public bool IsWarningEnabled(int code, int src_line) { bool flag = true; foreach (PragmaCmd region in regions) { if (src_line < region.Line) { break; } flag = region.IsEnabled(code, flag); } return flag; } } internal enum LanguageVersion { ISO_1 = 1, ISO_2 = 2, V_3 = 3, V_4 = 4, V_5 = 5, V_6 = 6, V_7 = 7, V_7_1 = 71, V_7_2 = 72, Experimental = 100, Default = 7, Latest = 72 } internal enum RuntimeVersion { v1, v2, v4 } internal enum Target { Library, Exe, Module, WinExe } internal enum Platform { AnyCPU, AnyCPU32Preferred, Arm, X86, X64, IA64 } internal class CompilerSettings { public Target Target; public Platform Platform; public string TargetExt; public bool VerifyClsCompliance; public bool Optimize; public LanguageVersion Version; public bool EnhancedWarnings; public bool LoadDefaultReferences; public string SdkVersion; public string StrongNameKeyFile; public string StrongNameKeyContainer; public bool StrongNameDelaySign; public int TabSize; public bool WarningsAreErrors; public int WarningLevel; public List AssemblyReferences; public List> AssemblyReferencesAliases; public List> PathMap; public List Modules; public List ReferencesLookupPaths; public Encoding Encoding; public string DocumentationFile; public string MainClass; public string OutputFile; public bool Checked; public bool StatementMode; public bool Unsafe; public string Win32ResourceFile; public string Win32IconFile; public List Resources; public bool GenerateDebugInfo; public bool ParseOnly; public bool TokenizeOnly; public bool Timestamps; public int DebugFlags; public int VerboseParserFlag; public int FatalCounter; public bool Stacktrace; public bool BreakOnInternalError; public List GetResourceStrings; public bool ShowFullPaths; public bool StdLib; public RuntimeVersion StdLibRuntimeVersion; public string RuntimeMetadataVersion; public bool WriteMetadataOnly; private readonly List conditional_symbols; private readonly List source_files; private List warnings_as_error; private List warnings_only; private HashSet warning_ignore_table; public SourceFile FirstSourceFile => (source_files.Count > 0) ? source_files[0] : null; public bool HasKeyFileOrContainer => StrongNameKeyFile != null || StrongNameKeyContainer != null; public bool NeedsEntryPoint => Target == Target.Exe || Target == Target.WinExe; public List SourceFiles => source_files; public CompilerSettings() { StdLib = true; Target = Target.Exe; TargetExt = ".exe"; Platform = Platform.AnyCPU; Version = LanguageVersion.V_7; VerifyClsCompliance = true; Encoding = Encoding.UTF8; LoadDefaultReferences = true; StdLibRuntimeVersion = RuntimeVersion.v4; WarningLevel = 4; TabSize = 1; AssemblyReferences = new List(); AssemblyReferencesAliases = new List>(); Modules = new List(); ReferencesLookupPaths = new List(); conditional_symbols = new List(); conditional_symbols.Add("__MonoCS__"); source_files = new List(); } public void AddConditionalSymbol(string symbol) { if (!conditional_symbols.Contains(symbol)) { conditional_symbols.Add(symbol); } } public void AddWarningAsError(int id) { if (warnings_as_error == null) { warnings_as_error = new List(); } warnings_as_error.Add(id); } public void AddWarningOnly(int id) { if (warnings_only == null) { warnings_only = new List(); } warnings_only.Add(id); } public bool IsConditionalSymbolDefined(string symbol) { return conditional_symbols.Contains(symbol); } public bool IsWarningAsError(int code) { bool flag = WarningsAreErrors; if (warnings_as_error != null) { flag |= warnings_as_error.Contains(code); } if (warnings_only != null && warnings_only.Contains(code)) { flag = false; } return flag; } public bool IsWarningEnabled(int code, int level) { if (WarningLevel < level) { return false; } return !IsWarningDisabledGlobally(code); } public bool IsWarningDisabledGlobally(int code) { return warning_ignore_table != null && warning_ignore_table.Contains(code); } public void SetIgnoreWarning(int code) { if (warning_ignore_table == null) { warning_ignore_table = new HashSet(); } warning_ignore_table.Add(code); } } internal class CommandLineParser { private enum ParseResult { Success, Error, Stop, UnknownOption } private static readonly char[] argument_value_separator = new char[2] { ';', ',' }; private static readonly char[] numeric_value_separator = new char[3] { ';', ',', ' ' }; private readonly TextWriter output; private readonly Report report; private bool stop_argument; private Dictionary source_file_index; private CompilerSettings parser_settings; public bool HasBeenStopped => stop_argument; public event Func UnknownOptionHandler; public CommandLineParser(TextWriter errorOutput) : this(errorOutput, Console.Out) { } public CommandLineParser(TextWriter errorOutput, TextWriter messagesOutput) { StreamReportPrinter streamReportPrinter = new StreamReportPrinter(errorOutput); parser_settings = new CompilerSettings(); report = new Report(new CompilerContext(parser_settings, streamReportPrinter), streamReportPrinter); output = messagesOutput; } private void About() { output.WriteLine("The Turbo C# compiler is Copyright 2001-2011, Novell, Inc. 2011-2016 Xamarin Inc, 2016-2017 Microsoft Corp\n\nThe compiler source code is released under the terms of the \nMIT X11 or GNU GPL licenses\n\nFor more information on Mono, visit the project Web site\n http://www.mono-project.com\n\nThe compiler was written by Miguel de Icaza, Ravi Pratap, Martin Baulig, Marek Safar, Raja R Harinath, Atushi Enomoto"); } public CompilerSettings ParseArguments(string[] args) { CompilerSettings compilerSettings = new CompilerSettings(); if (!ParseArguments(compilerSettings, args)) { return null; } return compilerSettings; } public bool ParseArguments(CompilerSettings settings, string[] args) { if (settings == null) { throw new ArgumentNullException("settings"); } List list = null; bool flag = true; stop_argument = false; source_file_index = new Dictionary(); for (int i = 0; i < args.Length; i++) { string text = args[i]; if (text.Length == 0) { continue; } if (text[0] == '@') { string text2 = text.Substring(1); if (list == null) { list = new List(); } if (list.Contains(text2)) { report.Error(1515, "Response file `{0}' specified multiple times", text2); return false; } list.Add(text2); string[] array = LoadArgs(text2); if (array == null) { report.Error(2011, "Unable to open response file: " + text2); return false; } args = AddArgs(args, array); continue; } if (flag) { if (text == "--") { flag = false; continue; } bool flag2 = text[0] == '-'; bool flag3 = text[0] == '/'; if (flag2) { switch (ParseOptionUnix(text, ref args, ref i, settings)) { case ParseResult.Stop: stop_argument = true; return true; case ParseResult.UnknownOption: if (this.UnknownOptionHandler != null) { int num = this.UnknownOptionHandler(args, i); if (num != -1) { i = num; continue; } } break; case ParseResult.Success: case ParseResult.Error: continue; } } if (flag2 || flag3) { string option = (flag2 ? ("/" + text.Substring(1)) : text); switch (ParseOption(option, ref args, settings)) { case ParseResult.UnknownOption: if (flag3 && text.Length > 3 && text.IndexOf('/', 2) > 0) { break; } if (this.UnknownOptionHandler != null) { int num2 = this.UnknownOptionHandler(args, i); if (num2 != -1) { i = num2; continue; } } Error_WrongOption(text); return false; case ParseResult.Stop: stop_argument = true; return true; case ParseResult.Success: case ParseResult.Error: continue; } } } ProcessSourceFiles(text, recurse: false, settings.SourceFiles); } return report.Errors == 0; } private void ProcessSourceFiles(string spec, bool recurse, List sourceFiles) { SplitPathAndPattern(spec, out var path, out var pattern); if (pattern.IndexOf('*') == -1) { AddSourceFile(spec, sourceFiles); return; } string[] files; try { files = Directory.GetFiles(path, pattern); } catch (DirectoryNotFoundException) { report.Error(2001, "Source file `" + spec + "' could not be found"); return; } catch (IOException) { report.Error(2001, "Source file `" + spec + "' could not be found"); return; } string[] array = files; foreach (string fileName in array) { AddSourceFile(fileName, sourceFiles); } if (recurse) { string[] array2 = null; try { array2 = Directory.GetDirectories(path); } catch { } string[] array3 = array2; foreach (string text in array3) { ProcessSourceFiles(text + "/" + pattern, recurse: true, sourceFiles); } } } private static string[] AddArgs(string[] args, string[] extra_args) { string[] array = new string[extra_args.Length + args.Length]; int num = Array.IndexOf(args, "--"); if (num != -1) { Array.Copy(args, array, num); extra_args.CopyTo(array, num); Array.Copy(args, num, array, num + extra_args.Length, args.Length - num); } else { args.CopyTo(array, 0); extra_args.CopyTo(array, args.Length); } return array; } private void AddAssemblyReference(string alias, string assembly, CompilerSettings settings) { if (assembly.Length == 0) { report.Error(1680, "Invalid reference alias `{0}='. Missing filename", alias); } else if (!IsExternAliasValid(alias)) { report.Error(1679, "Invalid extern alias for -reference. Alias `{0}' is not a valid identifier", alias); } else { settings.AssemblyReferencesAliases.Add(Tuple.Create(alias, assembly)); } } private void AddResource(AssemblyResource res, CompilerSettings settings) { if (settings.Resources == null) { settings.Resources = new List(); settings.Resources.Add(res); } else if (settings.Resources.Contains(res)) { report.Error(1508, "The resource identifier `{0}' has already been used in this assembly", res.Name); } else { settings.Resources.Add(res); } } private void AddSourceFile(string fileName, List sourceFiles) { string fullPath = Path.GetFullPath(fileName); if (source_file_index.TryGetValue(fullPath, out var value)) { string name = sourceFiles[value - 1].Name; if (fileName.Equals(name)) { report.Warning(2002, 1, "Source file `{0}' specified multiple times", name); return; } report.Warning(2002, 1, "Source filenames `{0}' and `{1}' both refer to the same file: {2}", fileName, name, fullPath); } else { SourceFile sourceFile = new SourceFile(fileName, fullPath, sourceFiles.Count + 1); sourceFiles.Add(sourceFile); source_file_index.Add(fullPath, sourceFile.Index); } } public bool ProcessWarningsList(string text, Action action) { string[] array = text.Split(numeric_value_separator, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { string text3 = text2; if (text3.Length == 6 && text3[0] == 'C' && text3[1] == 'S') { text3 = text3.Substring(2); } if (int.TryParse(text3, NumberStyles.AllowLeadingWhite, CultureInfo.InvariantCulture, out var result)) { action(result); } } return true; } private void Error_RequiresArgument(string option) { report.Error(2006, "Missing argument for `{0}' option", option); } private void Error_RequiresFileName(string option) { report.Error(2005, "Missing file specification for `{0}' option", option); } private void Error_WrongOption(string option) { report.Error(2007, "Unrecognized command-line option: `{0}'", option); } private static bool IsExternAliasValid(string identifier) { return Tokenizer.IsValidIdentifier(identifier); } private static string[] LoadArgs(string file) { List list = new List(); StreamReader streamReader; try { streamReader = new StreamReader(file); } catch { return null; } StringBuilder stringBuilder = new StringBuilder(); string text; while ((text = streamReader.ReadLine()) != null) { int length = text.Length; for (int i = 0; i < length; i++) { char c = text[i]; if (c == '"' || c == '\'') { char c2 = c; for (i++; i < length; i++) { c = text[i]; if (c == c2) { break; } stringBuilder.Append(c); } } else if (c == ' ') { if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString()); stringBuilder.Length = 0; } } else { stringBuilder.Append(c); } } if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString()); stringBuilder.Length = 0; } } return list.ToArray(); } private void OtherFlags() { output.WriteLine("Other flags in the compiler\n --fatal[=COUNT] Makes error after COUNT fatal\n --lint Enhanced warnings\n --metadata-only Produced assembly will contain metadata only\n --parse Only parses the source file\n --runtime:VERSION Sets mscorlib.dll metadata version: v1, v2, v4\n --stacktrace Shows stack trace at error location\n --timestamp Displays time stamps of various compiler events\n -v Verbose parsing (for debugging the parser)\n --mcs-debug X Sets MCS debugging level to X\n --break-on-ice Breaks compilation on internal compiler error"); } private ParseResult ParseOption(string option, ref string[] args, CompilerSettings settings) { int num = option.IndexOf(':'); string text; string text2; if (num == -1) { text = option; text2 = ""; } else { text = option.Substring(0, num); text2 = option.Substring(num + 1); } switch (text.ToLowerInvariant()) { case "/nologo": return ParseResult.Success; case "/t": case "/target": switch (text2) { case "exe": settings.Target = Target.Exe; break; case "winexe": settings.Target = Target.WinExe; break; case "library": settings.Target = Target.Library; settings.TargetExt = ".dll"; break; case "module": settings.Target = Target.Module; settings.TargetExt = ".netmodule"; break; default: report.Error(2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'"); return ParseResult.Error; } return ParseResult.Success; case "/out": if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } settings.OutputFile = text2; return ParseResult.Success; case "/o": case "/o+": case "/optimize": case "/optimize+": settings.Optimize = true; return ParseResult.Success; case "/o-": case "/optimize-": settings.Optimize = false; return ParseResult.Success; case "/incremental": case "/incremental+": case "/incremental-": return ParseResult.Success; case "/d": case "/define": { if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } string[] array10 = text2.Split(argument_value_separator); foreach (string text10 in array10) { string text11 = text10.Trim(); if (!Tokenizer.IsValidIdentifier(text11)) { report.Warning(2029, 1, "Invalid conditional define symbol `{0}'", text11); } else { settings.AddConditionalSymbol(text11); } } return ParseResult.Success; } case "/bugreport": output.WriteLine("To file bug reports, please visit: http://www.mono-project.com/Bugs"); return ParseResult.Success; case "/pkg": { if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } string packages = string.Join(" ", text2.Split(';', ',', '\n', '\r')); string packageFlags = Driver.GetPackageFlags(packages, report); if (packageFlags == null) { return ParseResult.Error; } string[] extra_args = packageFlags.Trim(' ', '\n', '\r', '\t').Split(' ', '\t'); args = AddArgs(args, extra_args); return ParseResult.Success; } case "/linkres": case "/linkresource": case "/res": case "/resource": { AssemblyResource assemblyResource = null; string[] array7 = text2.Split(argument_value_separator, StringSplitOptions.RemoveEmptyEntries); switch (array7.Length) { case 1: if (array7[0].Length == 0) { goto default; } assemblyResource = new AssemblyResource(array7[0], Path.GetFileName(array7[0])); break; case 2: assemblyResource = new AssemblyResource(array7[0], array7[1]); break; case 3: if (array7[2] != "public" && array7[2] != "private") { report.Error(1906, "Invalid resource visibility option `{0}'. Use either `public' or `private' instead", array7[2]); return ParseResult.Error; } assemblyResource = new AssemblyResource(array7[0], array7[1], array7[2] == "private"); break; default: report.Error(-2005, "Wrong number of arguments for option `{0}'", option); return ParseResult.Error; } if (assemblyResource != null) { assemblyResource.IsEmbeded = text[1] == 'r' || text[1] == 'R'; AddResource(assemblyResource, settings); } return ParseResult.Success; } case "/recurse": if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } ProcessSourceFiles(text2, recurse: true, settings.SourceFiles); return ParseResult.Success; case "/r": case "/reference": { if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } string[] array3 = text2.Split(argument_value_separator); string[] array4 = array3; foreach (string text6 in array4) { if (text6.Length == 0) { continue; } string text7 = text6; int num2 = text7.IndexOf('='); if (num2 > -1) { string alias = text6.Substring(0, num2); string assembly = text6.Substring(num2 + 1); AddAssemblyReference(alias, assembly, settings); if (array3.Length != 1) { report.Error(2034, "Cannot specify multiple aliases using single /reference option"); return ParseResult.Error; } } else { settings.AssemblyReferences.Add(text7); } } return ParseResult.Success; } case "/addmodule": { if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } string[] array8 = text2.Split(argument_value_separator); string[] array9 = array8; foreach (string item2 in array9) { settings.Modules.Add(item2); } return ParseResult.Success; } case "/win32res": if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } if (settings.Win32IconFile != null) { report.Error(1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time"); } settings.Win32ResourceFile = text2; return ParseResult.Success; case "/win32icon": if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } if (settings.Win32ResourceFile != null) { report.Error(1565, "Cannot specify the `win32res' and the `win32ico' compiler option at the same time"); } settings.Win32IconFile = text2; return ParseResult.Success; case "/doc": if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } settings.DocumentationFile = text2; return ParseResult.Success; case "/lib": { if (text2.Length == 0) { return ParseResult.Error; } string[] array5 = text2.Split(argument_value_separator); string[] array6 = array5; foreach (string item in array6) { settings.ReferencesLookupPaths.Add(item); } return ParseResult.Success; } case "/debug-": settings.GenerateDebugInfo = false; return ParseResult.Success; case "/debug": if (text2.Equals("full", StringComparison.OrdinalIgnoreCase) || text2.Equals("pdbonly", StringComparison.OrdinalIgnoreCase) || text2.Equals("portable", StringComparison.OrdinalIgnoreCase) || num < 0) { settings.GenerateDebugInfo = true; return ParseResult.Success; } if (text2.Length > 0) { report.Error(1902, "Invalid debug option `{0}'. Valid options are `full' or `pdbonly'", text2); } else { Error_RequiresArgument(option); } return ParseResult.Error; case "/debug+": settings.GenerateDebugInfo = true; return ParseResult.Success; case "/checked": case "/checked+": settings.Checked = true; return ParseResult.Success; case "/checked-": settings.Checked = false; return ParseResult.Success; case "/clscheck": case "/clscheck+": settings.VerifyClsCompliance = true; return ParseResult.Success; case "/clscheck-": settings.VerifyClsCompliance = false; return ParseResult.Success; case "/unsafe": case "/unsafe+": settings.Unsafe = true; return ParseResult.Success; case "/unsafe-": settings.Unsafe = false; return ParseResult.Success; case "/warnaserror": case "/warnaserror+": if (text2.Length == 0) { settings.WarningsAreErrors = true; parser_settings.WarningsAreErrors = true; } else if (!ProcessWarningsList(text2, settings.AddWarningAsError)) { return ParseResult.Error; } return ParseResult.Success; case "/warnaserror-": if (text2.Length == 0) { settings.WarningsAreErrors = false; } else if (!ProcessWarningsList(text2, settings.AddWarningOnly)) { return ParseResult.Error; } return ParseResult.Success; case "/warn": case "/w": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } SetWarningLevel(text2, settings); return ParseResult.Success; case "/nowarn": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } if (!ProcessWarningsList(text2, settings.SetIgnoreWarning)) { return ParseResult.Error; } return ParseResult.Success; case "/noconfig": settings.LoadDefaultReferences = false; return ParseResult.Success; case "/platform": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } switch (text2.ToLowerInvariant()) { case "arm": settings.Platform = Platform.Arm; break; case "anycpu": settings.Platform = Platform.AnyCPU; break; case "x86": settings.Platform = Platform.X86; break; case "x64": settings.Platform = Platform.X64; break; case "itanium": settings.Platform = Platform.IA64; break; case "anycpu32bitpreferred": settings.Platform = Platform.AnyCPU32Preferred; break; default: report.Error(1672, "Invalid -platform option `{0}'. Valid options are `anycpu', `anycpu32bitpreferred', `arm', `x86', `x64' or `itanium'", text2); return ParseResult.Error; } return ParseResult.Success; case "/sdk": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } settings.SdkVersion = text2; return ParseResult.Success; case "/errorreport": case "/filealign": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } return ParseResult.Success; case "/helpinternal": OtherFlags(); return ParseResult.Stop; case "/help": case "/?": Usage(); return ParseResult.Stop; case "/main": case "/m": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } settings.MainClass = text2; return ParseResult.Success; case "/nostdlib": case "/nostdlib+": settings.StdLib = false; return ParseResult.Success; case "/nostdlib-": settings.StdLib = true; return ParseResult.Success; case "/fullpaths": settings.ShowFullPaths = true; return ParseResult.Success; case "/keyfile": if (text2.Length == 0) { Error_RequiresFileName(option); return ParseResult.Error; } settings.StrongNameKeyFile = text2; return ParseResult.Success; case "/keycontainer": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } settings.StrongNameKeyContainer = text2; return ParseResult.Success; case "/delaysign+": case "/delaysign": settings.StrongNameDelaySign = true; return ParseResult.Success; case "/delaysign-": settings.StrongNameDelaySign = false; return ParseResult.Success; case "/langversion": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } switch (text2.ToLowerInvariant()) { case "iso-1": case "1": case "1.0": settings.Version = LanguageVersion.ISO_1; return ParseResult.Success; case "default": settings.Version = LanguageVersion.V_7; return ParseResult.Success; case "2": case "2.0": case "iso-2": settings.Version = LanguageVersion.ISO_2; return ParseResult.Success; case "3": case "3.0": settings.Version = LanguageVersion.V_3; return ParseResult.Success; case "4": case "4.0": settings.Version = LanguageVersion.V_4; return ParseResult.Success; case "5": case "5.0": settings.Version = LanguageVersion.V_5; return ParseResult.Success; case "6": case "6.0": settings.Version = LanguageVersion.V_6; return ParseResult.Success; case "7": case "7.0": settings.Version = LanguageVersion.V_7; return ParseResult.Success; case "7.1": settings.Version = LanguageVersion.V_7_1; return ParseResult.Success; case "7.2": settings.Version = LanguageVersion.V_7_2; return ParseResult.Success; case "latest": settings.Version = LanguageVersion.V_7_2; return ParseResult.Success; case "experimental": settings.Version = LanguageVersion.Experimental; return ParseResult.Success; default: if (text2.StartsWith("0", StringComparison.Ordinal)) { report.Error(8303, "Specified language version `{0}' cannot have leading zeroes", text2); } else { report.Error(1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', Default, Latest or value in range 1 to 7.2", text2); } return ParseResult.Error; } case "/codepage": { if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } string text8 = text2; string text9 = text8; if (!(text9 == "utf8")) { if (!(text9 == "reset")) { try { settings.Encoding = Encoding.GetEncoding(int.Parse(text2)); } catch { report.Error(2016, "Code page `{0}' is invalid or not installed", text2); } return ParseResult.Error; } settings.Encoding = Encoding.Default; } else { settings.Encoding = Encoding.UTF8; } return ParseResult.Success; } case "/runtimemetadataversion": if (text2.Length == 0) { Error_RequiresArgument(option); return ParseResult.Error; } settings.RuntimeMetadataVersion = text2; return ParseResult.Success; case "/pathmap": { if (text2.Length == 0) { return ParseResult.Success; } string[] array = text2.Split(new char[1] { ',' }); foreach (string text3 in array) { string[] array2 = text3.Split(new char[1] { '=' }); if (array2.Length != 2) { report.Error(8101, "The pathmap option was incorrectly formatted"); return ParseResult.Error; } if (settings.PathMap == null) { settings.PathMap = new List>(); } string text4 = array2[0].TrimEnd(new char[1] { Path.DirectorySeparatorChar }); string text5 = array2[1].TrimEnd(new char[1] { Path.DirectorySeparatorChar }); if (text4.Length == 0 || text5.Length == 0) { report.Error(8101, "The pathmap option was incorrectly formatted"); } settings.PathMap.Add(new KeyValuePair(text4, text5)); } return ParseResult.Success; } case "/analyzer": case "/appconfig": case "/baseaddress": case "/deterministic": case "/deterministic+": case "/deterministic-": case "/errorendlocation": case "/errorlog": case "/features": case "/highentropyva": case "/highentropyva+": case "/highentropyva-": case "/link": case "/moduleassemblyname": case "/nowin32manifest": case "/pdb": case "/preferreduilang": case "/publicsign": case "/publicsign+": case "/publicsign-": case "/reportanalyzer": case "/ruleset": case "/sqmsessionguid": case "/subsystemversion": case "/utf8output": case "/win32manifest": return ParseResult.Success; default: return ParseResult.UnknownOption; } } private ParseResult ParseOptionUnix(string arg, ref string[] args, ref int i, CompilerSettings settings) { switch (arg) { case "-v": settings.VerboseParserFlag++; return ParseResult.Success; case "--version": Version(); return ParseResult.Stop; case "--parse": settings.ParseOnly = true; return ParseResult.Success; case "--main": case "-m": report.Warning(-29, 1, "Compatibility: Use -main:CLASS instead of --main CLASS or -m CLASS"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } settings.MainClass = args[++i]; return ParseResult.Success; case "--unsafe": report.Warning(-29, 1, "Compatibility: Use -unsafe instead of --unsafe"); settings.Unsafe = true; return ParseResult.Success; case "/?": case "/h": case "/help": case "--help": Usage(); return ParseResult.Stop; case "--define": report.Warning(-29, 1, "Compatibility: Use -d:SYMBOL instead of --define SYMBOL"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } settings.AddConditionalSymbol(args[++i]); return ParseResult.Success; case "--tokenize": settings.TokenizeOnly = true; return ParseResult.Success; case "-o": case "--output": report.Warning(-29, 1, "Compatibility: Use -out:FILE instead of --output FILE or -o FILE"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } settings.OutputFile = args[++i]; return ParseResult.Success; case "--checked": report.Warning(-29, 1, "Compatibility: Use -checked instead of --checked"); settings.Checked = true; return ParseResult.Success; case "--stacktrace": settings.Stacktrace = true; return ParseResult.Success; case "--linkresource": case "--linkres": report.Warning(-29, 1, "Compatibility: Use -linkres:VALUE instead of --linkres VALUE"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } AddResource(new AssemblyResource(args[++i], args[i]), settings); return ParseResult.Success; case "--resource": case "--res": report.Warning(-29, 1, "Compatibility: Use -res:VALUE instead of --res VALUE"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } AddResource(new AssemblyResource(args[++i], args[i], isPrivate: true), settings); return ParseResult.Success; case "--target": report.Warning(-29, 1, "Compatibility: Use -target:KIND instead of --target KIND"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } switch (args[++i]) { case "library": settings.Target = Target.Library; settings.TargetExt = ".dll"; break; case "exe": settings.Target = Target.Exe; break; case "winexe": settings.Target = Target.WinExe; break; case "module": settings.Target = Target.Module; settings.TargetExt = ".dll"; break; default: report.Error(2019, "Invalid target type for -target. Valid options are `exe', `winexe', `library' or `module'"); break; } return ParseResult.Success; case "-r": { report.Warning(-29, 1, "Compatibility: Use -r:LIBRARY instead of -r library"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } string text2 = args[++i]; int num = text2.IndexOf('='); if (num > -1) { string alias = text2.Substring(0, num); string assembly = text2.Substring(num + 1); AddAssemblyReference(alias, assembly, settings); return ParseResult.Success; } settings.AssemblyReferences.Add(text2); return ParseResult.Success; } case "-L": report.Warning(-29, 1, "Compatibility: Use -lib:ARG instead of --L arg"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } settings.ReferencesLookupPaths.Add(args[++i]); return ParseResult.Success; case "--lint": settings.EnhancedWarnings = true; return ParseResult.Success; case "--nostdlib": report.Warning(-29, 1, "Compatibility: Use -nostdlib instead of --nostdlib"); settings.StdLib = false; return ParseResult.Success; case "--nowarn": { report.Warning(-29, 1, "Compatibility: Use -nowarn instead of --nowarn"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } int ignoreWarning = 0; try { ignoreWarning = int.Parse(args[++i]); } catch { Usage(); Environment.Exit(1); } settings.SetIgnoreWarning(ignoreWarning); return ParseResult.Success; } case "--wlevel": report.Warning(-29, 1, "Compatibility: Use -warn:LEVEL instead of --wlevel LEVEL"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } SetWarningLevel(args[++i], settings); return ParseResult.Success; case "--mcs-debug": if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } try { settings.DebugFlags = int.Parse(args[++i]); } catch { Error_RequiresArgument(arg); return ParseResult.Error; } return ParseResult.Success; case "--about": About(); return ParseResult.Stop; case "--recurse": report.Warning(-29, 1, "Compatibility: Use -recurse:PATTERN option instead --recurse PATTERN"); if (i + 1 >= args.Length) { Error_RequiresArgument(arg); return ParseResult.Error; } ProcessSourceFiles(args[++i], recurse: true, settings.SourceFiles); return ParseResult.Success; case "--timestamp": settings.Timestamps = true; return ParseResult.Success; case "--debug": case "-g": report.Warning(-29, 1, "Compatibility: Use -debug option instead of -g or --debug"); settings.GenerateDebugInfo = true; return ParseResult.Success; case "--noconfig": report.Warning(-29, 1, "Compatibility: Use -noconfig option instead of --noconfig"); settings.LoadDefaultReferences = false; return ParseResult.Success; case "--metadata-only": settings.WriteMetadataOnly = true; return ParseResult.Success; case "--break-on-ice": settings.BreakOnInternalError = true; return ParseResult.Success; default: if (arg.StartsWith("--fatal", StringComparison.Ordinal)) { int result = 1; if (arg.StartsWith("--fatal=", StringComparison.Ordinal)) { int.TryParse(arg.Substring(8), out result); } settings.FatalCounter = result; return ParseResult.Success; } if (arg.StartsWith("--runtime:", StringComparison.Ordinal)) { switch (arg.Substring(10)) { case "v1": case "V1": settings.StdLibRuntimeVersion = RuntimeVersion.v1; break; case "v2": case "V2": settings.StdLibRuntimeVersion = RuntimeVersion.v2; break; case "v4": case "V4": settings.StdLibRuntimeVersion = RuntimeVersion.v4; break; } return ParseResult.Success; } if (arg.StartsWith("--getresourcestrings:", StringComparison.Ordinal)) { string text = arg.Substring(21).Trim(); if (text.Length < 1) { Error_RequiresArgument(arg); return ParseResult.Error; } if (settings.GetResourceStrings == null) { settings.GetResourceStrings = new List(); } settings.GetResourceStrings.Add(text); return ParseResult.Success; } return ParseResult.UnknownOption; } } private void SetWarningLevel(string s, CompilerSettings settings) { int num = -1; try { num = int.Parse(s); } catch { } if (num < 0 || num > 4) { report.Error(1900, "Warning level must be in the range 0-4"); } else { settings.WarningLevel = num; } } private static void SplitPathAndPattern(string spec, out string path, out string pattern) { int num = spec.LastIndexOf('/'); switch (num) { case 0: path = "\\"; pattern = spec.Substring(1); break; default: path = spec.Substring(0, num); pattern = spec.Substring(num + 1); break; case -1: num = spec.LastIndexOf('\\'); if (num != -1) { path = spec.Substring(0, num); pattern = spec.Substring(num + 1); } else { path = "."; pattern = spec; } break; } } private void Usage() { output.WriteLine("Turbo C# compiler, Copyright 2001-2011 Novell, Inc., 2011-2016 Xamarin, Inc, 2016-2017 Microsoft Corp\nmcs [options] source-files\n --about About the Mono C# compiler\n -addmodule:M1[,Mn] Adds the module to the generated assembly\n -checked[+|-] Sets default aritmetic overflow context\n -clscheck[+|-] Disables CLS Compliance verifications\n -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n -define:S1[;S2] Defines one or more conditional symbols (short: -d)\n -debug[+|-], -g Generate debugging information\n -delaysign[+|-] Only insert the public key into the assembly (no signing)\n -doc:FILE Process documentation comments to XML file\n -fullpaths Any issued error or warning uses absolute file path\n -help Lists all compiler options (short: -?)\n -keycontainer:NAME The key pair container used to sign the output assembly\n -keyfile:FILE The key file used to strongname the ouput assembly\n -langversion:TEXT Specifies language version: ISO-1, ISO-2, 3, 4, 5, 6, Default or Experimental\n -lib:PATH1[,PATHn] Specifies the location of referenced assemblies\n -main:CLASS Specifies the class with the Main method (short: -m)\n -noconfig Disables implicitly referenced assemblies\n -nostdlib[+|-] Does not reference mscorlib.dll library\n -nowarn:W1[,Wn] Suppress one or more compiler warnings\n -optimize[+|-] Enables advanced compiler optimizations (short: -o)\n -out:FILE Specifies output assembly name\n -pathmap:K=V[,Kn=Vn] Sets a mapping for source path names used in generated output\n -pkg:P1[,Pn] References packages P1..Pn\n -platform:ARCH Specifies the target platform of the output assembly\n ARCH can be one of: anycpu, anycpu32bitpreferred, arm,\n x86, x64 or itanium. The default is anycpu.\n -recurse:SPEC Recursively compiles files according to SPEC pattern\n -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n -sdk:VERSION Specifies SDK version of referenced assemblies\n VERSION can be one of: 2, 4, 4.5 (default) or a custom value\n -target:KIND Specifies the format of the output assembly (short: -t)\n KIND can be one of: exe, winexe, library, module\n -unsafe[+|-] Allows to compile code which uses unsafe keyword\n -warnaserror[+|-] Treats all warnings as errors\n -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors\n -warn:0-4 Sets warning level, the default is 4 (short -w:)\n -helpinternal Shows internal and advanced compiler options\n\nResources:\n -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)\n -resource:FILE[,ID] Embed FILE as a resource (short: -res)\n -win32res:FILE Specifies Win32 resource file (.res)\n -win32icon:FILE Use this icon for the output\n @file Read response file for more options\n\nOptions can be of the form -option or /option"); } private void Version() { string arg = MethodBase.GetCurrentMethod().DeclaringType.Assembly.GetName().Version.ToString(); output.WriteLine("Mono C# compiler version {0}", arg); } } internal class RootContext { private static ModuleContainer root; public static ModuleContainer ToplevelTypes { get { return root; } set { root = value; } } } internal abstract class Statement { public Location loc; protected bool reachable; public bool IsUnreachable => !reachable; public virtual bool Resolve(BlockContext bc) { return true; } protected abstract void DoEmit(EmitContext ec); public virtual void Emit(EmitContext ec) { ec.Mark(loc); DoEmit(ec); if (ec.StatementEpilogue != null) { ec.EmitEpilogue(); } } protected abstract void CloneTo(CloneContext clonectx, Statement target); public Statement Clone(CloneContext clonectx) { Statement statement = (Statement)MemberwiseClone(); CloneTo(clonectx, statement); return statement; } public virtual Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(834, loc, "A lambda expression with statement body cannot be converted to an expresion tree"); return null; } public virtual object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } protected abstract bool DoFlowAnalysis(FlowAnalysisContext fc); public bool FlowAnalysis(FlowAnalysisContext fc) { if (reachable) { fc.UnreachableReported = false; return DoFlowAnalysis(fc); } if (this is Block) { return DoFlowAnalysis(fc); } if (this is EmptyStatement || loc.IsNull) { return true; } if (fc.UnreachableReported) { return true; } fc.Report.Warning(162, 2, loc, "Unreachable code detected"); fc.UnreachableReported = true; return true; } public virtual Reachability MarkReachable(Reachability rc) { if (!rc.IsUnreachable) { reachable = true; } return rc; } protected void CheckExitBoundaries(BlockContext bc, Block scope) { if (bc.CurrentBlock.ParametersBlock.Original != scope.ParametersBlock.Original) { bc.Report.Error(1632, loc, "Control cannot leave the body of an anonymous method"); return; } Block block = bc.CurrentBlock; while (block != null && block != scope) { if (block.IsFinallyBlock) { Error_FinallyClauseExit(bc); break; } block = block.Parent; } } protected void Error_FinallyClauseExit(BlockContext bc) { bc.Report.Error(157, loc, "Control cannot leave the body of a finally clause"); } } internal sealed class EmptyStatement : Statement { public EmptyStatement(Location loc) { base.loc = loc; } public override bool Resolve(BlockContext ec) { return true; } public override void Emit(EmitContext ec) { } protected override void DoEmit(EmitContext ec) { throw new NotSupportedException(); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return false; } protected override void CloneTo(CloneContext clonectx, Statement target) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class If : Statement { private Expression expr; public Statement TrueStatement; public Statement FalseStatement; private bool true_returns; private bool false_returns; public Expression Expr => expr; public If(Expression bool_expr, Statement true_statement, Location l) : this(bool_expr, true_statement, null, l) { } public If(Expression bool_expr, Statement true_statement, Statement false_statement, Location l) { expr = bool_expr; TrueStatement = true_statement; FalseStatement = false_statement; loc = l; } public override bool Resolve(BlockContext ec) { expr = expr.Resolve(ec); bool flag = TrueStatement.Resolve(ec); if (FalseStatement != null) { flag &= FalseStatement.Resolve(ec); } return flag; } protected override void DoEmit(EmitContext ec) { Label label = ec.DefineLabel(); if (expr is Constant constant) { constant.EmitSideEffect(ec); if (!constant.IsDefaultValue) { TrueStatement.Emit(ec); } else if (FalseStatement != null) { FalseStatement.Emit(ec); } return; } expr.EmitBranchable(ec, label, on_true: false); TrueStatement.Emit(ec); if (FalseStatement != null) { bool flag = false; Label label2 = ec.DefineLabel(); if (!true_returns) { ec.Emit(OpCodes.Br, label2); flag = true; } ec.MarkLabel(label); FalseStatement.Emit(ec); if (flag) { ec.MarkLabel(label2); } } else { ec.MarkLabel(label); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignmentBitSet = new DefiniteAssignmentBitSet(fc.DefiniteAssignmentOnFalse); fc.BranchDefiniteAssignment(fc.DefiniteAssignmentOnTrue); Dictionary> labelStack = fc.CopyLabelStack(); bool flag = TrueStatement.FlowAnalysis(fc); fc.SetLabelStack(labelStack); if (FalseStatement == null) { if (expr is Constant { IsDefaultValue: false }) { return true_returns; } if (true_returns) { fc.DefiniteAssignment = definiteAssignmentBitSet; } else { fc.DefiniteAssignment &= definiteAssignmentBitSet; } return false; } if (true_returns) { fc.DefiniteAssignment = definiteAssignmentBitSet; flag = FalseStatement.FlowAnalysis(fc); fc.SetLabelStack(labelStack); return flag; } DefiniteAssignmentBitSet definiteAssignment = fc.DefiniteAssignment; fc.DefiniteAssignment = definiteAssignmentBitSet; flag &= FalseStatement.FlowAnalysis(fc); fc.SetLabelStack(labelStack); if (!TrueStatement.IsUnreachable) { if (false_returns || FalseStatement.IsUnreachable) { fc.DefiniteAssignment = definiteAssignment; } else { fc.DefiniteAssignment &= definiteAssignment; } } return flag; } public override Reachability MarkReachable(Reachability rc) { if (rc.IsUnreachable) { return rc; } base.MarkReachable(rc); if (expr is Constant constant) { if (!constant.IsDefaultValue) { rc = TrueStatement.MarkReachable(rc); } else if (FalseStatement != null) { rc = FalseStatement.MarkReachable(rc); } return rc; } Reachability reachability = TrueStatement.MarkReachable(rc); true_returns = reachability.IsUnreachable; if (FalseStatement == null) { return rc; } Reachability reachability2 = FalseStatement.MarkReachable(rc); false_returns = reachability2.IsUnreachable; return reachability & reachability2; } protected override void CloneTo(CloneContext clonectx, Statement t) { If obj = (If)t; obj.expr = expr.Clone(clonectx); obj.TrueStatement = TrueStatement.Clone(clonectx); if (FalseStatement != null) { obj.FalseStatement = FalseStatement.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Do : LoopStatement { public Expression expr; private bool iterator_reachable; private bool end_reachable; public Location WhileLocation { get; private set; } public Do(Statement statement, BooleanExpression bool_expr, Location doLocation, Location whileLocation) : base(statement) { expr = bool_expr; loc = doLocation; WhileLocation = whileLocation; } public override bool Resolve(BlockContext bc) { bool result = base.Resolve(bc); expr = expr.Resolve(bc); return result; } protected override void DoEmit(EmitContext ec) { Label label = ec.DefineLabel(); Label loopBegin = ec.LoopBegin; Label loopEnd = ec.LoopEnd; ec.LoopBegin = ec.DefineLabel(); ec.LoopEnd = ec.DefineLabel(); ec.MarkLabel(label); base.Statement.Emit(ec); ec.MarkLabel(ec.LoopBegin); ec.Mark(WhileLocation); if (expr is Constant) { bool flag = !((Constant)expr).IsDefaultValue; expr.EmitSideEffect(ec); if (flag) { ec.Emit(OpCodes.Br, label); } } else { expr.EmitBranchable(ec, label, on_true: true); } ec.MarkLabel(ec.LoopEnd); ec.LoopBegin = loopBegin; ec.LoopEnd = loopEnd; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { bool flag = base.Statement.FlowAnalysis(fc); expr.FlowAnalysisConditional(fc); fc.DefiniteAssignment = fc.DefiniteAssignmentOnFalse; if (flag && !iterator_reachable) { return !end_reachable; } if (!end_reachable && expr is Constant { IsDefaultValue: false }) { return true; } return false; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (base.Statement.MarkReachable(rc).IsUnreachable && !iterator_reachable) { expr = new UnreachableExpression(expr); return end_reachable ? rc : Reachability.CreateUnreachable(); } if (!end_reachable && expr is Constant { IsDefaultValue: false }) { return Reachability.CreateUnreachable(); } return rc; } protected override void CloneTo(CloneContext clonectx, Statement t) { Do obj = (Do)t; obj.Statement = base.Statement.Clone(clonectx); obj.expr = expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public override void SetEndReachable() { end_reachable = true; } public override void SetIteratorReachable() { iterator_reachable = true; } } internal class While : LoopStatement { public Expression expr; private bool empty; private bool infinite; private bool end_reachable; private List end_reachable_das; public While(BooleanExpression bool_expr, Statement statement, Location l) : base(statement) { expr = bool_expr; loc = l; } public override bool Resolve(BlockContext bc) { bool flag = true; expr = expr.Resolve(bc); if (expr == null) { flag = false; } if (expr is Constant constant) { empty = constant.IsDefaultValue; infinite = !empty; } return flag & base.Resolve(bc); } protected override void DoEmit(EmitContext ec) { if (empty) { expr.EmitSideEffect(ec); return; } Label loopBegin = ec.LoopBegin; Label loopEnd = ec.LoopEnd; ec.LoopBegin = ec.DefineLabel(); ec.LoopEnd = ec.DefineLabel(); if (expr is Constant) { ec.MarkLabel(ec.LoopBegin); if (ec.EmitAccurateDebugInfo) { ec.Emit(OpCodes.Nop); } expr.EmitSideEffect(ec); base.Statement.Emit(ec); ec.Emit(OpCodes.Br, ec.LoopBegin); ec.MarkLabel(ec.LoopEnd); } else { Label label = ec.DefineLabel(); ec.Emit(OpCodes.Br, ec.LoopBegin); ec.MarkLabel(label); expr.EmitPrepare(ec); base.Statement.Emit(ec); ec.MarkLabel(ec.LoopBegin); ec.Mark(loc); expr.EmitBranchable(ec, label, on_true: true); ec.MarkLabel(ec.LoopEnd); } ec.LoopBegin = loopBegin; ec.LoopEnd = loopEnd; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysisConditional(fc); DefiniteAssignmentBitSet definiteAssignment = new DefiniteAssignmentBitSet(fc.DefiniteAssignmentOnFalse); fc.BranchDefiniteAssignment(fc.DefiniteAssignmentOnTrue); base.Statement.FlowAnalysis(fc); if (end_reachable_das != null) { definiteAssignment = DefiniteAssignmentBitSet.And(end_reachable_das); end_reachable_das = null; } fc.DefiniteAssignment = definiteAssignment; if (infinite && !end_reachable) { return true; } return false; } public override Reachability MarkReachable(Reachability rc) { if (rc.IsUnreachable) { return rc; } base.MarkReachable(rc); if (empty) { base.Statement.MarkReachable(Reachability.CreateUnreachable()); return rc; } base.Statement.MarkReachable(rc); if (infinite && !end_reachable) { return Reachability.CreateUnreachable(); } return rc; } protected override void CloneTo(CloneContext clonectx, Statement t) { While obj = (While)t; obj.expr = expr.Clone(clonectx); obj.Statement = base.Statement.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public override void AddEndDefiniteAssignment(FlowAnalysisContext fc) { if (infinite) { if (end_reachable_das == null) { end_reachable_das = new List(); } end_reachable_das.Add(fc.DefiniteAssignment); } } public override void SetEndReachable() { end_reachable = true; } } internal class For : LoopStatement { private bool infinite; private bool empty; private bool iterator_reachable; private bool end_reachable; private List end_reachable_das; public Statement Initializer { get; set; } public Expression Condition { get; set; } public Statement Iterator { get; set; } public For(Location l) : base(null) { loc = l; } public override bool Resolve(BlockContext bc) { Initializer.Resolve(bc); if (Condition != null) { Condition = Condition.Resolve(bc); if (Condition is Constant constant) { if (constant.IsDefaultValue) { empty = true; } else { infinite = true; } } } else { infinite = true; } return base.Resolve(bc) && Iterator.Resolve(bc); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { Initializer.FlowAnalysis(fc); DefiniteAssignmentBitSet definiteAssignment; if (Condition != null) { Condition.FlowAnalysisConditional(fc); fc.DefiniteAssignment = fc.DefiniteAssignmentOnTrue; definiteAssignment = new DefiniteAssignmentBitSet(fc.DefiniteAssignmentOnFalse); } else { definiteAssignment = fc.BranchDefiniteAssignment(); } base.Statement.FlowAnalysis(fc); Iterator.FlowAnalysis(fc); if (end_reachable_das != null) { definiteAssignment = DefiniteAssignmentBitSet.And(end_reachable_das); end_reachable_das = null; } fc.DefiniteAssignment = definiteAssignment; if (infinite && !end_reachable) { return true; } return false; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); Initializer.MarkReachable(rc); if (!base.Statement.MarkReachable(rc).IsUnreachable || iterator_reachable) { Iterator.MarkReachable(rc); } if (infinite && !end_reachable) { return Reachability.CreateUnreachable(); } return rc; } protected override void DoEmit(EmitContext ec) { if (Initializer != null) { Initializer.Emit(ec); } if (empty) { Condition.EmitSideEffect(ec); return; } Label loopBegin = ec.LoopBegin; Label loopEnd = ec.LoopEnd; Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); ec.LoopBegin = ec.DefineLabel(); ec.LoopEnd = ec.DefineLabel(); ec.Emit(OpCodes.Br, label2); ec.MarkLabel(label); Condition?.EmitPrepare(ec); base.Statement.Emit(ec); ec.MarkLabel(ec.LoopBegin); Iterator.Emit(ec); ec.MarkLabel(label2); if (Condition != null) { ec.Mark(Condition.Location); if (Condition is Constant) { Condition.EmitSideEffect(ec); ec.Emit(OpCodes.Br, label); } else { Condition.EmitBranchable(ec, label, on_true: true); } } else { ec.Emit(OpCodes.Br, label); } ec.MarkLabel(ec.LoopEnd); ec.LoopBegin = loopBegin; ec.LoopEnd = loopEnd; } protected override void CloneTo(CloneContext clonectx, Statement t) { For obj = (For)t; if (Initializer != null) { obj.Initializer = Initializer.Clone(clonectx); } if (Condition != null) { obj.Condition = Condition.Clone(clonectx); } if (Iterator != null) { obj.Iterator = Iterator.Clone(clonectx); } obj.Statement = base.Statement.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public override void AddEndDefiniteAssignment(FlowAnalysisContext fc) { if (infinite) { if (end_reachable_das == null) { end_reachable_das = new List(); } end_reachable_das.Add(fc.DefiniteAssignment); } } public override void SetEndReachable() { end_reachable = true; } public override void SetIteratorReachable() { iterator_reachable = true; } } internal abstract class LoopStatement : Statement { public Statement Statement { get; set; } protected LoopStatement(Statement statement) { Statement = statement; } public override bool Resolve(BlockContext bc) { LoopStatement enclosingLoop = bc.EnclosingLoop; LoopStatement enclosingLoopOrSwitch = bc.EnclosingLoopOrSwitch; LoopStatement enclosingLoopOrSwitch2 = (bc.EnclosingLoop = this); bc.EnclosingLoopOrSwitch = enclosingLoopOrSwitch2; bool result = Statement.Resolve(bc); bc.EnclosingLoopOrSwitch = enclosingLoopOrSwitch; bc.EnclosingLoop = enclosingLoop; return result; } public virtual void AddEndDefiniteAssignment(FlowAnalysisContext fc) { } public virtual void SetEndReachable() { } public virtual void SetIteratorReachable() { } } internal class StatementExpression : Statement { private ExpressionStatement expr; public ExpressionStatement Expr => expr; public StatementExpression(ExpressionStatement expr) { this.expr = expr; loc = expr.StartLocation; } public StatementExpression(ExpressionStatement expr, Location loc) { this.expr = expr; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Statement t) { StatementExpression statementExpression = (StatementExpression)t; statementExpression.expr = (ExpressionStatement)expr.Clone(clonectx); } protected override void DoEmit(EmitContext ec) { expr.EmitStatement(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); return false; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); expr.MarkReachable(rc); return rc; } public override bool Resolve(BlockContext ec) { expr = expr.ResolveStatement(ec); return expr != null; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class StatementErrorExpression : Statement { private Expression expr; public Expression Expr => expr; public StatementErrorExpression(Expression expr) { this.expr = expr; loc = expr.StartLocation; } public override bool Resolve(BlockContext bc) { expr.Error_InvalidExpressionStatement(bc); return true; } protected override void DoEmit(EmitContext ec) { throw new NotSupportedException(); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return false; } protected override void CloneTo(CloneContext clonectx, Statement target) { StatementErrorExpression statementErrorExpression = (StatementErrorExpression)target; statementErrorExpression.expr = expr.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class StatementList : Statement { private List statements; public IList Statements => statements; public StatementList(Statement first, Statement second) { statements = new List { first, second }; } public void Add(Statement statement) { statements.Add(statement); } public override bool Resolve(BlockContext ec) { foreach (Statement statement in statements) { statement.Resolve(ec); } return true; } protected override void DoEmit(EmitContext ec) { foreach (Statement statement in statements) { statement.Emit(ec); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { foreach (Statement statement in statements) { statement.FlowAnalysis(fc); } return false; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); Reachability result = rc; foreach (Statement statement in statements) { result = statement.MarkReachable(rc); } return result; } protected override void CloneTo(CloneContext clonectx, Statement target) { StatementList statementList = (StatementList)target; statementList.statements = new List(statements.Count); foreach (Statement statement in statements) { statementList.statements.Add(statement.Clone(clonectx)); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class ExitStatement : Statement { protected bool unwind_protect; protected abstract bool IsLocalExit { get; } protected abstract bool DoResolve(BlockContext bc); public override bool Resolve(BlockContext bc) { bool result = DoResolve(bc); if (!IsLocalExit && bc.HasSet(ResolveContext.Options.FinallyScope)) { for (Block block = bc.CurrentBlock; block != null; block = block.Parent) { if (block.IsFinallyBlock) { Error_FinallyClauseExit(bc); break; } if (block is ParametersBlock) { break; } } } unwind_protect = bc.HasAny(ResolveContext.Options.CatchScope | ResolveContext.Options.TryScope); return result; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (IsLocalExit) { return true; } if (fc.TryFinally != null) { fc.TryFinally.RegisterForControlExitCheck(new DefiniteAssignmentBitSet(fc.DefiniteAssignment)); } else { fc.ParametersBlock.CheckControlExit(fc); } return true; } } internal class Return : ExitStatement { private Expression expr; private bool expr_returns; public Expression Expr { get { return expr; } protected set { expr = value; } } protected override bool IsLocalExit => false; public Return(Expression expr, Location l) { this.expr = expr; loc = l; } protected override bool DoResolve(BlockContext ec) { TypeSpec typeSpec = ec.ReturnType; if (expr == null) { if (typeSpec.Kind == MemberKind.Void || typeSpec == InternalType.ErrorType) { return true; } if (ec.CurrentAnonymousMethod is AsyncInitializer) { AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)ec.CurrentAnonymousMethod.Storey; TypeSpec returnType = asyncTaskStorey.ReturnType; if (returnType == ec.Module.PredefinedTypes.Task.TypeSpec) { expr = EmptyExpression.Null; return true; } if (returnType.IsGenericTask || (returnType.Arity == 1 && returnType.IsCustomTaskType())) { typeSpec = returnType.TypeArguments[0]; } } if (ec.CurrentIterator != null) { Error_ReturnFromIterator(ec); } else if (typeSpec != InternalType.ErrorType) { ec.Report.Error(126, loc, "An object of a type convertible to `{0}' is required for the return statement", typeSpec.GetSignatureForError()); } return false; } expr = expr.Resolve(ec); AnonymousExpression currentAnonymousMethod = ec.CurrentAnonymousMethod; if (currentAnonymousMethod == null) { if (typeSpec.Kind == MemberKind.Void) { ec.Report.Error(127, loc, "`{0}': A return keyword must not be followed by any expression when method returns void", ec.GetSignatureForError()); return false; } } else { if (currentAnonymousMethod.IsIterator) { Error_ReturnFromIterator(ec); return false; } if (currentAnonymousMethod is AsyncInitializer asyncInitializer) { if (expr != null) { AsyncTaskStorey asyncTaskStorey2 = (AsyncTaskStorey)currentAnonymousMethod.Storey; TypeSpec returnType2 = asyncTaskStorey2.ReturnType; if (returnType2 == null && asyncInitializer.ReturnTypeInference != null) { if (expr.Type.Kind == MemberKind.Void && !(this is ContextualReturn)) { ec.Report.Error(4029, loc, "Cannot return an expression of type `void'"); } else { asyncInitializer.ReturnTypeInference.AddCommonTypeBoundAsync(expr.Type); } return true; } if (returnType2.Kind == MemberKind.Void) { ec.Report.Error(8030, loc, "Anonymous function or lambda expression converted to a void returning delegate cannot return a value"); return false; } if (!returnType2.IsGeneric) { if (this is ContextualReturn) { return true; } if (asyncInitializer.DelegateType != null) { ec.Report.Error(8031, loc, "Async lambda expression or anonymous method converted to a `Task' cannot return a value. Consider returning `Task'"); } else { ec.Report.Error(1997, loc, "`{0}': A return keyword must not be followed by an expression when async method returns `Task'. Consider using `Task' return type", ec.GetSignatureForError()); } return false; } if (expr.Type == returnType2 && returnType2.TypeArguments[0] != ec.Module.PredefinedTypes.Task.TypeSpec) { ec.Report.Error(4016, loc, "`{0}': The return expression type of async method must be `{1}' rather than `Task<{1}>'", ec.GetSignatureForError(), returnType2.TypeArguments[0].GetSignatureForError()); } else { typeSpec = returnType2.TypeArguments[0]; } } } else { if (typeSpec.Kind == MemberKind.Void) { ec.Report.Error(8030, loc, "Anonymous function or lambda expression converted to a void returning delegate cannot return a value"); return false; } if (currentAnonymousMethod is AnonymousMethodBody anonymousMethodBody && expr != null) { if (anonymousMethodBody.ReturnTypeInference != null) { anonymousMethodBody.ReturnTypeInference.AddCommonTypeBound(expr.Type); return true; } if (this is ContextualReturn && !ec.IsInProbingMode && ec.Module.Compiler.Settings.Optimize) { anonymousMethodBody.DirectMethodGroupConversion = expr.CanReduceLambda(anonymousMethodBody); } } } } if (expr == null) { return false; } if (expr is ReferenceExpression && typeSpec.Kind != MemberKind.ByRef) { ec.Report.Error(8149, loc, "By-reference returns can only be used in methods that return by reference"); return false; } if (expr.Type != typeSpec && expr.Type != InternalType.ErrorType) { if (typeSpec.Kind == MemberKind.ByRef) { if (!(Expr is ReferenceExpression)) { ec.Report.Error(8150, loc, "By-reference return is required when method returns by reference"); return false; } ReferenceContainer referenceContainer = (ReferenceContainer)typeSpec; if (expr.Type != referenceContainer.Element) { ec.Report.Error(8151, loc, "The return by reference expression must be of type `{0}' because this method returns by reference", referenceContainer.GetSignatureForError()); return false; } } else { expr = Convert.ImplicitConversionRequired(ec, expr, typeSpec, loc); if (expr == null) { if (currentAnonymousMethod != null && typeSpec == ec.ReturnType) { ec.Report.Error(1662, loc, "Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type", currentAnonymousMethod.ContainerType, currentAnonymousMethod.GetSignatureForError()); } return false; } } } return true; } protected override void DoEmit(EmitContext ec) { if (expr != null) { if (ec.CurrentAnonymousMethod is AsyncInitializer asyncInitializer) { AsyncTaskStorey asyncTaskStorey = (AsyncTaskStorey)asyncInitializer.Storey; Label label = asyncInitializer.BodyEnd; if (asyncTaskStorey.HoistedReturnValue != null) { if (ec.TryFinallyUnwind != null) { label = TryFinally.EmitRedirectedReturn(ec, asyncInitializer, unwind_protect); } IAssignMethod assignMethod = (IAssignMethod)asyncTaskStorey.HoistedReturnValue; assignMethod.EmitAssign(ec, expr, leave_copy: false, isCompound: false); ec.EmitEpilogue(); } else { expr.Emit(ec); if (ec.TryFinallyUnwind != null) { label = TryFinally.EmitRedirectedReturn(ec, asyncInitializer, unwind_protect); } } ec.Emit(OpCodes.Leave, label); return; } expr.Emit(ec); ec.EmitEpilogue(); if (unwind_protect || ec.EmitAccurateDebugInfo) { ec.Emit(OpCodes.Stloc, ec.TemporaryReturn()); } } if (unwind_protect) { ec.Emit(OpCodes.Leave, ec.CreateReturnLabel()); } else if (ec.EmitAccurateDebugInfo) { ec.Emit(OpCodes.Br, ec.CreateReturnLabel()); } else { ec.Emit(OpCodes.Ret); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (expr != null) { expr.FlowAnalysis(fc); } if (!expr_returns) { base.DoFlowAnalysis(fc); } return true; } private void Error_ReturnFromIterator(ResolveContext rc) { rc.Report.Error(1622, loc, "Cannot return a value from iterators. Use the yield return statement to return a value, or yield break to end the iteration"); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (Expr != null) { rc = Expr.MarkReachable(rc); expr_returns = rc.IsUnreachable; } return Reachability.CreateUnreachable(); } protected override void CloneTo(CloneContext clonectx, Statement t) { Return obj = (Return)t; if (expr != null) { obj.expr = expr.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Goto : ExitStatement { private string target; private LabeledStatement label; private TryFinally try_finally; public string Target => target; protected override bool IsLocalExit => true; public Goto(string label, Location l) { loc = l; target = label; } protected override bool DoResolve(BlockContext bc) { label = bc.CurrentBlock.LookupLabel(target); if (label == null) { Error_UnknownLabel(bc, target, loc); return false; } try_finally = bc.CurrentTryBlock as TryFinally; CheckExitBoundaries(bc, label.Block); return true; } public static void Error_UnknownLabel(BlockContext bc, string label, Location loc) { bc.Report.Error(159, loc, "The label `{0}:' could not be found within the scope of the goto statement", label); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (label == null) { return true; } if (fc.AddReachedLabel(label)) { return true; } label.Block.ScanGotoJump(label, fc); return true; } public override Reachability MarkReachable(Reachability rc) { if (rc.IsUnreachable) { return rc; } base.MarkReachable(rc); if (try_finally != null) { if (try_finally.FinallyBlock.HasReachableClosingBrace) { label.AddGotoReference(rc); } else { label = null; } } else { label.AddGotoReference(rc); } return Reachability.CreateUnreachable(); } protected override void CloneTo(CloneContext clonectx, Statement target) { } protected override void DoEmit(EmitContext ec) { if (this.label != null) { Label label = this.label.LabelTarget(ec); if (ec.TryFinallyUnwind != null && IsLeavingFinally(this.label.Block)) { AsyncInitializer initializer = (AsyncInitializer)ec.CurrentAnonymousMethod; label = TryFinally.EmitRedirectedJump(ec, initializer, label, this.label.Block, unwind_protect); } ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, label); } } private bool IsLeavingFinally(Block labelBlock) { for (Block block = try_finally.Statement as Block; block != null; block = block.Parent) { if (block == labelBlock) { return true; } } return false; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class LabeledStatement : Statement { private string name; private bool defined; private bool referenced; private Label label; private Block block; public Block Block => block; public string Name => name; public LabeledStatement(string name, Block block, Location l) { this.name = name; this.block = block; loc = l; } public Label LabelTarget(EmitContext ec) { if (defined) { return label; } label = ec.DefineLabel(); defined = true; return label; } protected override void CloneTo(CloneContext clonectx, Statement target) { LabeledStatement labeledStatement = (LabeledStatement)target; labeledStatement.block = clonectx.RemapBlockCopy(block); } public override bool Resolve(BlockContext bc) { return true; } protected override void DoEmit(EmitContext ec) { LabelTarget(ec); ec.MarkLabel(label); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (!referenced) { fc.Report.Warning(164, 2, loc, "This label has not been referenced"); } return false; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (referenced) { rc = default(Reachability); } return rc; } public void AddGotoReference(Reachability rc) { if (!referenced) { referenced = true; MarkReachable(rc); block.ScanGotoJump(this); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class GotoDefault : SwitchGoto { public GotoDefault(Location l) : base(l) { } public override bool Resolve(BlockContext bc) { if (bc.Switch == null) { Error_GotoCaseRequiresSwitchBlock(bc); return false; } bc.Switch.RegisterGotoCase(null, null); base.Resolve(bc); return true; } protected override void DoEmit(EmitContext ec) { ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, ec.Switch.DefaultLabel.GetILLabel(ec)); } public override Reachability MarkReachable(Reachability rc) { if (!rc.IsUnreachable) { SwitchLabel defaultLabel = switch_statement.DefaultLabel; if (defaultLabel.IsUnreachable) { defaultLabel.MarkReachable(rc); switch_statement.Block.ScanGotoJump(defaultLabel); } } return base.MarkReachable(rc); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class GotoCase : SwitchGoto { private Expression expr; public Expression Expr => expr; public SwitchLabel Label { get; set; } public GotoCase(Expression e, Location l) : base(l) { expr = e; } public override bool Resolve(BlockContext ec) { if (ec.Switch == null) { Error_GotoCaseRequiresSwitchBlock(ec); return false; } Constant constant = expr.ResolveLabelConstant(ec); if (constant == null) { return false; } Constant constant2; if (ec.Switch.IsNullable && constant is NullLiteral) { constant2 = constant; } else { TypeSpec switchType = ec.Switch.SwitchType; constant2 = constant.Reduce(ec, switchType); if (constant2 == null) { constant.Error_ValueCannotBeConverted(ec, switchType, expl: true); return false; } if (!Convert.ImplicitStandardConversionExists(constant, switchType)) { ec.Report.Warning(469, 2, loc, "The `goto case' value is not implicitly convertible to type `{0}'", switchType.GetSignatureForError()); } } ec.Switch.RegisterGotoCase(this, constant2); base.Resolve(ec); expr = constant2; return true; } protected override void DoEmit(EmitContext ec) { ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, Label.GetILLabel(ec)); } protected override void CloneTo(CloneContext clonectx, Statement t) { GotoCase gotoCase = (GotoCase)t; gotoCase.expr = expr.Clone(clonectx); } public override Reachability MarkReachable(Reachability rc) { if (!rc.IsUnreachable) { SwitchLabel switchLabel = switch_statement.FindLabel((Constant)expr); if (switchLabel.IsUnreachable) { switchLabel.MarkReachable(rc); switch_statement.Block.ScanGotoJump(switchLabel); } } return base.MarkReachable(rc); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal abstract class SwitchGoto : Statement { protected bool unwind_protect; protected Switch switch_statement; protected SwitchGoto(Location loc) { base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Statement target) { } public override bool Resolve(BlockContext bc) { CheckExitBoundaries(bc, bc.Switch.Block); unwind_protect = bc.HasAny(ResolveContext.Options.CatchScope | ResolveContext.Options.TryScope); switch_statement = bc.Switch; return true; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return true; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Reachability.CreateUnreachable(); } protected void Error_GotoCaseRequiresSwitchBlock(BlockContext bc) { bc.Report.Error(153, loc, "A goto case is only valid inside a switch statement"); } } internal class Throw : Statement { private Expression expr; public Expression Expr => expr; public Throw(Expression expr, Location l) { this.expr = expr; loc = l; } public static Expression ConvertType(ResolveContext rc, Expression expr) { BuiltinTypeSpec exception = rc.BuiltinTypes.Exception; if (Convert.ImplicitConversionExists(rc, expr, exception)) { expr = Convert.ImplicitConversion(rc, expr, exception, expr.Location); } else { rc.Report.Error(155, expr.Location, "The type caught or thrown must be derived from System.Exception"); expr = EmptyCast.Create(expr, exception); } return expr; } public override bool Resolve(BlockContext ec) { if (expr == null) { if (!ec.HasSet(ResolveContext.Options.CatchScope)) { ec.Report.Error(156, loc, "A throw statement with no arguments is not allowed outside of a catch clause"); } else if (ec.HasSet(ResolveContext.Options.FinallyScope)) { Block block = ec.CurrentBlock; while (block != null && !block.IsCatchBlock) { if (block.IsFinallyBlock) { ec.Report.Error(724, loc, "A throw statement with no arguments is not allowed inside of a finally clause nested inside of the innermost catch clause"); break; } block = block.Parent; } } return true; } expr = expr.Resolve(ec, ResolveFlags.VariableOrValue | ResolveFlags.Type); if (expr == null) { return false; } expr = ConvertType(ec, expr); return true; } protected override void DoEmit(EmitContext ec) { if (expr == null) { LocalVariable asyncThrowVariable = ec.AsyncThrowVariable; if (asyncThrowVariable != null) { if (asyncThrowVariable.HoistedVariant != null) { asyncThrowVariable.HoistedVariant.Emit(ec); } else { asyncThrowVariable.Emit(ec); } ec.Emit(OpCodes.Throw); } else { ec.Emit(OpCodes.Rethrow); } } else { expr.Emit(ec); ec.Emit(OpCodes.Throw); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (expr != null) { expr.FlowAnalysis(fc); } return true; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Reachability.CreateUnreachable(); } protected override void CloneTo(CloneContext clonectx, Statement t) { Throw obj = (Throw)t; if (expr != null) { obj.expr = expr.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Break : LocalExitStatement { public Break(Location l) : base(l) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } protected override void DoEmit(EmitContext ec) { Label label = ec.LoopEnd; if (ec.TryFinallyUnwind != null) { AsyncInitializer initializer = (AsyncInitializer)ec.CurrentAnonymousMethod; label = TryFinally.EmitRedirectedJump(ec, initializer, label, enclosing_loop.Statement as Block, unwind_protect); } ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, label); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { enclosing_loop.AddEndDefiniteAssignment(fc); return true; } protected override bool DoResolve(BlockContext bc) { enclosing_loop = bc.EnclosingLoopOrSwitch; return base.DoResolve(bc); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (!rc.IsUnreachable) { enclosing_loop.SetEndReachable(); } return Reachability.CreateUnreachable(); } } internal class Continue : LocalExitStatement { public Continue(Location l) : base(l) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } protected override void DoEmit(EmitContext ec) { Label label = ec.LoopBegin; if (ec.TryFinallyUnwind != null) { AsyncInitializer initializer = (AsyncInitializer)ec.CurrentAnonymousMethod; label = TryFinally.EmitRedirectedJump(ec, initializer, label, enclosing_loop.Statement as Block, unwind_protect); } ec.Emit(unwind_protect ? OpCodes.Leave : OpCodes.Br, label); } protected override bool DoResolve(BlockContext bc) { enclosing_loop = bc.EnclosingLoop; return base.DoResolve(bc); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (!rc.IsUnreachable) { enclosing_loop.SetIteratorReachable(); } return Reachability.CreateUnreachable(); } } internal abstract class LocalExitStatement : ExitStatement { protected LoopStatement enclosing_loop; protected override bool IsLocalExit => true; protected LocalExitStatement(Location loc) { base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Statement t) { } protected override bool DoResolve(BlockContext bc) { if (enclosing_loop == null) { bc.Report.Error(139, loc, "No enclosing loop out of which to break or continue"); return false; } if (enclosing_loop.Statement is Block scope) { CheckExitBoundaries(bc, scope); } return true; } } internal interface ILocalVariable { void Emit(EmitContext ec); void EmitAssign(EmitContext ec); void EmitAddressOf(EmitContext ec); } internal interface INamedBlockVariable { Block Block { get; } bool IsDeclared { get; } bool IsParameter { get; } Location Location { get; } Expression CreateReferenceExpression(ResolveContext rc, Location loc); } internal class BlockVariableDeclarator { private LocalVariable li; private Expression initializer; public LocalVariable Variable => li; public Expression Initializer { get { return initializer; } set { initializer = value; } } public BlockVariableDeclarator(LocalVariable li, Expression initializer) { if (li.Type != null) { throw new ArgumentException("Expected null variable type"); } this.li = li; this.initializer = initializer; } public virtual BlockVariableDeclarator Clone(CloneContext cloneCtx) { BlockVariableDeclarator blockVariableDeclarator = (BlockVariableDeclarator)MemberwiseClone(); if (initializer != null) { blockVariableDeclarator.initializer = initializer.Clone(cloneCtx); } return blockVariableDeclarator; } } internal class BlockVariable : Statement { private Expression initializer; protected FullNamedExpression type_expr; protected LocalVariable li; protected List declarators; private TypeSpec type; public List Declarators => declarators; public Expression Initializer { get { return initializer; } set { initializer = value; } } public FullNamedExpression TypeExpression => type_expr; public LocalVariable Variable => li; public BlockVariable(FullNamedExpression type, LocalVariable li) { type_expr = type; this.li = li; loc = type_expr.Location; } protected BlockVariable(LocalVariable li) { this.li = li; } public void AddDeclarator(BlockVariableDeclarator decl) { if (declarators == null) { declarators = new List(); } declarators.Add(decl); } private static void CreateEvaluatorVariable(BlockContext bc, LocalVariable li) { if (bc.Report.Errors == 0) { TypeDefinition partialContainer = bc.CurrentMemberDefinition.Parent.PartialContainer; Field field = new Field(partialContainer, new TypeExpression(li.Type, li.Location), Modifiers.PUBLIC | Modifiers.STATIC, new MemberName(li.Name, li.Location), null); partialContainer.AddField(field); field.Define(); li.HoistedVariant = new HoistedEvaluatorVariable(field); li.SetIsUsed(); } } public override bool Resolve(BlockContext bc) { return Resolve(bc, resolveDeclaratorInitializers: true); } public bool Resolve(BlockContext bc, bool resolveDeclaratorInitializers) { if (type == null && !li.IsCompilerGenerated) { if (type_expr is VarExpr varExpr && !varExpr.IsPossibleType(bc)) { if (bc.Module.Compiler.Settings.Version < LanguageVersion.V_3) { bc.Report.FeatureIsNotAvailable(bc.Module.Compiler, loc, "implicitly typed local variable"); } if (li.IsFixed) { bc.Report.Error(821, loc, "A fixed statement cannot use an implicitly typed local variable"); return false; } if (li.IsConstant) { bc.Report.Error(822, loc, "An implicitly typed local variable cannot be a constant"); return false; } if (Initializer == null) { bc.Report.Error(818, loc, "An implicitly typed local variable declarator must include an initializer"); return false; } if (declarators != null) { bc.Report.Error(819, loc, "An implicitly typed local variable declaration cannot include multiple declarators"); declarators = null; } Initializer = Initializer.Resolve(bc); if (Initializer != null) { ((VarExpr)type_expr).InferType(bc, Initializer); type = type_expr.Type; } else { type = InternalType.ErrorType; } } if (type == null) { type = ResolveTypeExpression(bc); if (type == null) { return false; } if (li.IsConstant && !type.IsConstantCompatible) { Const.Error_InvalidConstantType(type, loc, bc.Report); } } if (type.IsStatic) { FieldBase.Error_VariableOfStaticClass(loc, li.Name, type, bc.Report); } li.Type = type; } bool flag = bc.Module.Compiler.Settings.StatementMode && bc.CurrentBlock is ToplevelBlock; if (flag) { CreateEvaluatorVariable(bc, li); } else if (type != InternalType.ErrorType) { li.PrepareAssignmentAnalysis(bc); } if (initializer != null) { if (li.IsByRef) { if (!(initializer is ReferenceExpression)) { bc.Report.Error(8172, loc, "Cannot initialize a by-reference variable `{0}' with a value", li.Name); return false; } if (bc.CurrentAnonymousMethod is AsyncInitializer) { bc.Report.Error(8177, loc, "Async methods cannot use by-reference variables"); } else if (bc.CurrentIterator != null) { bc.Report.Error(8176, loc, "Iterators cannot use by-reference variables"); } } else if (initializer is ReferenceExpression) { bc.Report.Error(8171, loc, "Cannot initialize a by-value variable `{0}' with a reference expression", li.Name); return false; } initializer = ResolveInitializer(bc, li, initializer); } if (declarators != null) { foreach (BlockVariableDeclarator declarator in declarators) { declarator.Variable.Type = li.Type; if (flag) { CreateEvaluatorVariable(bc, declarator.Variable); } else if (type != InternalType.ErrorType) { declarator.Variable.PrepareAssignmentAnalysis(bc); } if (declarator.Initializer != null && resolveDeclaratorInitializers) { declarator.Initializer = ResolveInitializer(bc, declarator.Variable, declarator.Initializer); } } } return true; } protected virtual Expression ResolveInitializer(BlockContext bc, LocalVariable li, Expression initializer) { SimpleAssign simpleAssign = new SimpleAssign(li.CreateReferenceExpression(bc, li.Location), initializer, li.Location); return simpleAssign.ResolveStatement(bc); } protected virtual TypeSpec ResolveTypeExpression(BlockContext bc) { return type_expr.ResolveAsType(bc); } protected override void DoEmit(EmitContext ec) { li.CreateBuilder(ec); if (Initializer != null && !base.IsUnreachable) { ((ExpressionStatement)Initializer).EmitStatement(ec); } if (declarators == null) { return; } foreach (BlockVariableDeclarator declarator in declarators) { declarator.Variable.CreateBuilder(ec); if (declarator.Initializer != null && !base.IsUnreachable) { ec.Mark(declarator.Variable.Location); ((ExpressionStatement)declarator.Initializer).EmitStatement(ec); } } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (Initializer != null) { Initializer.FlowAnalysis(fc); } if (declarators != null) { foreach (BlockVariableDeclarator declarator in declarators) { if (declarator.Initializer != null) { declarator.Initializer.FlowAnalysis(fc); } } } return false; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return (initializer == null) ? rc : initializer.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Statement target) { BlockVariable blockVariable = (BlockVariable)target; if (type_expr != null) { blockVariable.type_expr = (FullNamedExpression)type_expr.Clone(clonectx); } if (initializer != null) { blockVariable.initializer = initializer.Clone(clonectx); } if (declarators == null) { return; } blockVariable.declarators = null; foreach (BlockVariableDeclarator declarator in declarators) { blockVariable.AddDeclarator(declarator.Clone(clonectx)); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class BlockConstant : BlockVariable { public BlockConstant(FullNamedExpression type, LocalVariable li) : base(type, li) { } public override void Emit(EmitContext ec) { if (!base.Variable.IsUsed) { ec.Report.Warning(219, 3, loc, "The constant `{0}' is never used", base.Variable.Name); } } protected override Expression ResolveInitializer(BlockContext bc, LocalVariable li, Expression initializer) { initializer = initializer.Resolve(bc); if (initializer == null) { return null; } Constant constant = ((initializer.Type != InternalType.DefaultType) ? (initializer as Constant) : New.Constantify(li.Type, initializer.Location)); if (constant == null) { initializer.Error_ExpressionMustBeConstant(bc, initializer.Location, li.Name); return null; } constant = constant.ConvertImplicitly(li.Type); if (constant == null) { if (TypeSpec.IsReferenceType(li.Type)) { initializer.Error_ConstantCanBeInitializedWithNullOnly(bc, li.Type, initializer.Location, li.Name); } else { initializer.Error_ValueCannotBeConverted(bc, li.Type, expl: false); } return null; } li.ConstantValue = constant; return initializer; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal sealed class LocalVariable : INamedBlockVariable, ILocalVariable { [Flags] public enum Flags { Used = 1, IsThis = 2, AddressTaken = 4, CompilerGenerated = 8, Constant = 0x10, ForeachVariable = 0x100020, FixedVariable = 0x100040, UsingVariable = 0x100080, IsLocked = 0x100, SymbolFileHidden = 0x200, ByRef = 0x400, ReadonlyMask = 0x100000 } private TypeSpec type; private readonly string name; private readonly Location loc; private readonly Block block; private Flags flags; private Constant const_value; public VariableInfo VariableInfo; private HoistedVariable hoisted_variant; private LocalBuilder builder; public bool AddressTaken => (flags & Flags.AddressTaken) != 0; public Block Block => block; public Constant ConstantValue { get { return const_value; } set { const_value = value; } } public HoistedVariable HoistedVariant { get { return hoisted_variant; } set { hoisted_variant = value; } } public bool Created => builder != null; public bool IsDeclared => type != null; public bool IsByRef => (flags & Flags.ByRef) != 0; public bool IsCompilerGenerated => (flags & Flags.CompilerGenerated) != 0; public bool IsConstant => (flags & Flags.Constant) != 0; public bool IsLocked { get { return (flags & Flags.IsLocked) != 0; } set { flags = (value ? (flags | Flags.IsLocked) : (flags & ~Flags.IsLocked)); } } public bool IsThis => (flags & Flags.IsThis) != 0; public bool IsUsed => (flags & Flags.Used) != 0; public bool IsFixed { get { return (flags & Flags.FixedVariable) == Flags.FixedVariable; } set { flags = (value ? (flags | Flags.FixedVariable) : (flags & ~Flags.FixedVariable)); } } bool INamedBlockVariable.IsParameter => false; public bool IsReadonly => (flags & Flags.ReadonlyMask) != 0; public Location Location => loc; public string Name => name; public TypeSpec Type { get { return type; } set { type = value; } } public LocalVariable(Block block, string name, Location loc) { this.block = block; this.name = name; this.loc = loc; } public LocalVariable(Block block, string name, Flags flags, Location loc) : this(block, name, loc) { this.flags = flags; } public LocalVariable(LocalVariable li, string name, Location loc) : this(li.block, name, li.flags, loc) { } public void CreateBuilder(EmitContext ec) { if ((flags & Flags.Used) == 0) { if (VariableInfo == null) { throw new InternalErrorException("VariableInfo is null and the variable `{0}' is not used", name); } if (VariableInfo.IsEverAssigned) { ec.Report.Warning(219, 3, Location, "The variable `{0}' is assigned but its value is never used", Name); } else { ec.Report.Warning(168, 3, Location, "The variable `{0}' is declared but never used", Name); } } if (HoistedVariant != null) { return; } if (builder != null) { if ((flags & Flags.CompilerGenerated) != 0) { return; } throw new InternalErrorException("Already created variable `{0}'", name); } if (IsByRef) { builder = ec.DeclareLocal(ReferenceContainer.MakeType(ec.Module, Type), IsFixed); } else { builder = ec.DeclareLocal(Type, IsFixed); } if ((flags & Flags.SymbolFileHidden) == 0) { ec.DefineLocalVariable(name, builder); } } public static LocalVariable CreateCompilerGenerated(TypeSpec type, Block block, Location loc, bool writeToSymbolFile = false) { LocalVariable localVariable = new LocalVariable(block, GetCompilerGeneratedName(block), Flags.Used | Flags.CompilerGenerated, loc); if (!writeToSymbolFile) { localVariable.flags |= Flags.SymbolFileHidden; } localVariable.Type = type; return localVariable; } public Expression CreateReferenceExpression(ResolveContext rc, Location loc) { if (IsConstant && const_value != null) { SetIsUsed(); return Constant.CreateConstantFromValue(Type, const_value.GetValue(), loc); } return new LocalVariableReference(this, loc); } public void Emit(EmitContext ec) { if ((flags & Flags.CompilerGenerated) != 0) { CreateBuilder(ec); } ec.Emit(OpCodes.Ldloc, builder); } public void EmitAssign(EmitContext ec) { if ((flags & Flags.CompilerGenerated) != 0) { CreateBuilder(ec); } ec.Emit(OpCodes.Stloc, builder); } public void EmitAddressOf(EmitContext ec) { if ((flags & Flags.CompilerGenerated) != 0) { CreateBuilder(ec); } if (IsByRef) { ec.Emit(OpCodes.Ldloc, builder); } else { ec.Emit(OpCodes.Ldloca, builder); } } public static string GetCompilerGeneratedName(Block block) { return "$locvar" + block.ParametersBlock.TemporaryLocalsCount++.ToString("X"); } public string GetReadOnlyContext() { return (flags & (Flags)1048800) switch { Flags.FixedVariable => "fixed variable", Flags.ForeachVariable => "foreach iteration variable", Flags.UsingVariable => "using variable", _ => throw new InternalErrorException("Variable is not readonly"), }; } public bool IsThisAssigned(FlowAnalysisContext fc, Block block) { if (VariableInfo == null) { throw new Exception(); } if (IsAssigned(fc)) { return true; } return VariableInfo.IsFullyInitialized(fc, block.StartLocation); } public bool IsAssigned(FlowAnalysisContext fc) { return fc.IsDefinitelyAssigned(VariableInfo); } public void PrepareAssignmentAnalysis(BlockContext bc) { if ((flags & (Flags.CompilerGenerated | Flags.Constant | Flags.ReadonlyMask)) == 0) { VariableInfo = VariableInfo.Create(bc, this); } } public void SetIsUsed() { flags |= Flags.Used; } public void SetHasAddressTaken() { flags |= Flags.Used | Flags.AddressTaken; } public override string ToString() { return $"LocalInfo ({name},{type},{VariableInfo},{Location})"; } } internal class Block : Statement { [Flags] public enum Flags { Unchecked = 1, ReachableEnd = 8, Unsafe = 0x10, HasCapturedVariable = 0x40, HasCapturedThis = 0x80, IsExpressionTree = 0x100, CompilerGenerated = 0x200, HasAsyncModifier = 0x400, Resolved = 0x800, YieldBlock = 0x1000, AwaitBlock = 0x2000, FinallyBlock = 0x4000, CatchBlock = 0x8000, HasReferenceToStoreyForInstanceLambdas = 0x10000, Iterator = 0x100000, NoFlowAnalysis = 0x200000, InitializationEmitted = 0x400000 } public Block Parent; public Location StartLocation; public Location EndLocation; public ExplicitBlock Explicit; public ParametersBlock ParametersBlock; protected Flags flags; protected List statements; protected List scope_initializers; private int? resolving_init_idx; private Block original; public Block Original { get { return original; } protected set { original = value; } } public bool IsCompilerGenerated { get { return (flags & Flags.CompilerGenerated) != 0; } set { flags = (value ? (flags | Flags.CompilerGenerated) : (flags & ~Flags.CompilerGenerated)); } } public bool IsCatchBlock => (flags & Flags.CatchBlock) != 0; public bool IsFinallyBlock => (flags & Flags.FinallyBlock) != 0; public bool Unchecked { get { return (flags & Flags.Unchecked) != 0; } set { flags = (value ? (flags | Flags.Unchecked) : (flags & ~Flags.Unchecked)); } } public bool Unsafe { get { return (flags & Flags.Unsafe) != 0; } set { flags |= Flags.Unsafe; } } public List Statements => statements; public Block(Block parent, Location start, Location end) : this(parent, (Flags)0, start, end) { } public Block(Block parent, Flags flags, Location start, Location end) { if (parent != null) { ParametersBlock = parent.ParametersBlock; Explicit = parent.Explicit; } Parent = parent; this.flags = flags; StartLocation = start; EndLocation = end; loc = start; statements = new List(4); original = this; } public void SetEndLocation(Location loc) { EndLocation = loc; } public void AddLabel(LabeledStatement target) { ParametersBlock.TopBlock.AddLabel(target.Name, target); } public void AddLocalName(LocalVariable li) { AddLocalName(li.Name, li); } public virtual void AddLocalName(string name, INamedBlockVariable li, bool canShadowChildrenBlockName = false) { ParametersBlock.TopBlock.AddLocalName(name, li, canShadowChildrenBlockName); } public virtual void Error_AlreadyDeclared(string name, INamedBlockVariable variable, string reason) { if (reason == null) { Error_AlreadyDeclared(name, variable); } else { ParametersBlock.TopBlock.Report.Error(136, variable.Location, "A local variable named `{0}' cannot be declared in this scope because it would give a different meaning to `{0}', which is already used in a `{1}' scope to denote something else", name, reason); } } public virtual void Error_AlreadyDeclared(string name, INamedBlockVariable variable) { if (variable is ParametersBlock.ParameterInfo parameterInfo) { parameterInfo.Parameter.Error_DuplicateName(ParametersBlock.TopBlock.Report); } else { ParametersBlock.TopBlock.Report.Error(128, variable.Location, "A local variable named `{0}' is already defined in this scope", name); } } public virtual void Error_AlreadyDeclaredTypeParameter(string name, Location loc) { ParametersBlock.TopBlock.Report.Error(412, loc, "The type parameter name `{0}' is the same as local variable or parameter name", name); } public void AddScopeStatement(Statement s) { if (scope_initializers == null) { scope_initializers = new List(); } if (resolving_init_idx.HasValue) { scope_initializers.Insert(resolving_init_idx.Value, s); resolving_init_idx++; } else { scope_initializers.Add(s); } } public void InsertStatement(int index, Statement s) { statements.Insert(index, s); } public void AddStatement(Statement s) { statements.Add(s); } public LabeledStatement LookupLabel(string name) { return ParametersBlock.GetLabel(name, this); } public override Reachability MarkReachable(Reachability rc) { if (rc.IsUnreachable) { return rc; } MarkReachableScope(rc); foreach (Statement statement in statements) { rc = statement.MarkReachable(rc); if (rc.IsUnreachable) { if ((flags & Flags.ReachableEnd) != 0) { return default(Reachability); } return rc; } } flags |= Flags.ReachableEnd; return rc; } public void MarkReachableScope(Reachability rc) { base.MarkReachable(rc); if (scope_initializers == null) { return; } foreach (Statement scope_initializer in scope_initializers) { scope_initializer.MarkReachable(rc); } } public override bool Resolve(BlockContext bc) { if ((flags & Flags.Resolved) != 0) { return true; } Block currentBlock = bc.CurrentBlock; bc.CurrentBlock = this; if (scope_initializers != null) { for (resolving_init_idx = 0; resolving_init_idx < scope_initializers.Count; resolving_init_idx++) { scope_initializers[resolving_init_idx.Value].Resolve(bc); } resolving_init_idx = null; } bool result = true; int count = statements.Count; for (int i = 0; i < count; i++) { Statement statement = statements[i]; if (!statement.Resolve(bc)) { result = false; statements[i] = new EmptyStatement(statement.loc); } } bc.CurrentBlock = currentBlock; flags |= Flags.Resolved; return result; } protected override void DoEmit(EmitContext ec) { for (int i = 0; i < statements.Count; i++) { statements[i].Emit(ec); } } public override void Emit(EmitContext ec) { if (scope_initializers != null) { EmitScopeInitializers(ec); } DoEmit(ec); } protected void EmitScopeInitializers(EmitContext ec) { foreach (Statement scope_initializer in scope_initializers) { scope_initializer.Emit(ec); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (scope_initializers != null) { foreach (Statement scope_initializer in scope_initializers) { scope_initializer.FlowAnalysis(fc); } } return DoFlowAnalysis(fc, 0); } private bool DoFlowAnalysis(FlowAnalysisContext fc, int startIndex) { bool flag = !reachable; bool flag2 = startIndex != 0; while (startIndex < statements.Count) { Statement statement = statements[startIndex]; flag = statement.FlowAnalysis(fc); if (statement.IsUnreachable) { statements[startIndex] = RewriteUnreachableStatement(statement); } else if (flag) { bool flag3 = flag2 && statement is GotoCase; if (statement is TryFinally tryFinally && !tryFinally.FinallyBlock.HasReachableClosingBrace) { statements.Insert(startIndex + 1, new SentinelStatement()); } else { for (startIndex++; startIndex < statements.Count; startIndex++) { statement = statements[startIndex]; if (statement is SwitchLabel) { if (!flag3) { statement.FlowAnalysis(fc); } break; } if (statement.IsUnreachable) { statement.FlowAnalysis(fc); statements[startIndex] = RewriteUnreachableStatement(statement); } } } if (flag3) { break; } } else if (statement is LabeledStatement label && fc.AddReachedLabel(label)) { break; } startIndex++; } return !Explicit.HasReachableClosingBrace; } private static Statement RewriteUnreachableStatement(Statement s) { if (s is BlockVariable || s is EmptyStatement || s is SentinelStatement) { return s; } return new EmptyStatement(s.loc); } public void ScanGotoJump(Statement label) { int i; for (i = 0; i < statements.Count && statements[i] != label; i++) { } Reachability rc = default(Reachability); for (i++; i < statements.Count; i++) { Statement statement = statements[i]; rc = statement.MarkReachable(rc); if (rc.IsUnreachable) { return; } } flags |= Flags.ReachableEnd; } public void ScanGotoJump(Statement label, FlowAnalysisContext fc) { int i; for (i = 0; i < statements.Count && statements[i] != label; i++) { } DoFlowAnalysis(fc, ++i); } protected override void CloneTo(CloneContext clonectx, Statement t) { Block block = (Block)t; clonectx.AddBlockMap(this, block); if (original != this) { clonectx.AddBlockMap(original, block); } block.ParametersBlock = (ParametersBlock)((ParametersBlock == this) ? block : clonectx.RemapBlockCopy(ParametersBlock)); block.Explicit = (ExplicitBlock)((Explicit == this) ? block : clonectx.LookupBlock(Explicit)); if (Parent != null) { block.Parent = clonectx.RemapBlockCopy(Parent); } block.statements = new List(statements.Count); foreach (Statement statement in statements) { block.statements.Add(statement.Clone(clonectx)); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ExplicitBlock : Block { protected AnonymousMethodStorey am_storey; private int debug_scope_index; public AnonymousMethodStorey AnonymousMethodStorey => am_storey; public bool HasAwait => (flags & Flags.AwaitBlock) != 0; public bool HasCapturedThis { get { return (flags & Flags.HasCapturedThis) != 0; } set { flags = (value ? (flags | Flags.HasCapturedThis) : (flags & ~Flags.HasCapturedThis)); } } public bool HasCapturedVariable { get { return (flags & Flags.HasCapturedVariable) != 0; } set { flags = (value ? (flags | Flags.HasCapturedVariable) : (flags & ~Flags.HasCapturedVariable)); } } public bool HasReachableClosingBrace { get { return (flags & Flags.ReachableEnd) != 0; } set { flags = (value ? (flags | Flags.ReachableEnd) : (flags & ~Flags.ReachableEnd)); } } public bool HasYield => (flags & Flags.YieldBlock) != 0; public ExplicitBlock(Block parent, Location start, Location end) : this(parent, (Flags)0, start, end) { } public ExplicitBlock(Block parent, Flags flags, Location start, Location end) : base(parent, flags, start, end) { Explicit = this; } public AnonymousMethodStorey CreateAnonymousMethodStorey(ResolveContext ec) { if (ec.CurrentAnonymousMethod is StateMachineInitializer && ParametersBlock.Original == ec.CurrentAnonymousMethod.Block.Original) { return ec.CurrentAnonymousMethod.Storey; } if (am_storey == null) { MemberBase host = ec.MemberContext as MemberBase; am_storey = new AnonymousMethodStorey(this, ec.CurrentMemberDefinition.Parent.PartialContainer, host, ec.CurrentTypeParameters, "AnonStorey", MemberKind.Class); } return am_storey; } public void EmitScopeInitialization(EmitContext ec) { if ((flags & Flags.InitializationEmitted) == 0) { if (am_storey != null) { DefineStoreyContainer(ec, am_storey); am_storey.EmitStoreyInstantiation(ec, this); } if (scope_initializers != null) { EmitScopeInitializers(ec); } flags |= Flags.InitializationEmitted; } } public override void Emit(EmitContext ec) { int debugSymbolScopeIndex = GetDebugSymbolScopeIndex(); if (debugSymbolScopeIndex > 0) { ec.BeginScope(debugSymbolScopeIndex); } EmitScopeInitialization(ec); if (ec.EmitAccurateDebugInfo && !base.IsCompilerGenerated && ec.Mark(StartLocation)) { ec.Emit(OpCodes.Nop); } DoEmit(ec); if (debugSymbolScopeIndex > 0) { ec.EndScope(); } if (ec.EmitAccurateDebugInfo && HasReachableClosingBrace && !(this is ParametersBlock) && !base.IsCompilerGenerated && ec.Mark(EndLocation)) { ec.Emit(OpCodes.Nop); } } protected void DefineStoreyContainer(EmitContext ec, AnonymousMethodStorey storey) { if (ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.Storey != null) { storey.SetNestedStoryParent(ec.CurrentAnonymousMethod.Storey); storey.Mutator = ec.CurrentAnonymousMethod.Storey.Mutator; } storey.CreateContainer(); storey.DefineContainer(); storey.ExpandBaseInterfaces(); if (base.Original.Explicit.HasCapturedThis && base.Original.ParametersBlock.TopBlock.ThisReferencesFromChildrenBlock != null) { for (Block block = base.Original.Explicit; block != null; block = block.Parent) { if (block.Parent != null) { AnonymousMethodStorey anonymousMethodStorey = block.Parent.Explicit.AnonymousMethodStorey; if (anonymousMethodStorey != null) { storey.HoistedThis = anonymousMethodStorey.HoistedThis; break; } } if (block.Explicit == block.Explicit.ParametersBlock && block.Explicit.ParametersBlock.StateMachine != null) { if (storey.HoistedThis == null) { storey.HoistedThis = block.Explicit.ParametersBlock.StateMachine.HoistedThis; } if (storey.HoistedThis != null) { break; } } } if (storey.HoistedThis == null || !(storey.Parent is HoistedStoreyClass)) { foreach (ExplicitBlock item in base.Original.ParametersBlock.TopBlock.ThisReferencesFromChildrenBlock) { Block block2 = item; while (block2 != null && block2 != base.Original) { block2 = block2.Parent; } if (block2 == null) { continue; } if (storey.HoistedThis == null) { storey.AddCapturedThisField(ec, null); } for (ExplicitBlock explicitBlock = item; explicitBlock.AnonymousMethodStorey != storey; explicitBlock = explicitBlock.Parent.Explicit) { AnonymousMethodStorey anonymousMethodStorey2 = explicitBlock.AnonymousMethodStorey; ParametersBlock parametersBlock; if (anonymousMethodStorey2 != null) { if (explicitBlock.ParametersBlock.StateMachine == null) { AnonymousMethodStorey anonymousMethodStorey3 = null; for (Block parent = explicitBlock.AnonymousMethodStorey.OriginalSourceBlock.Parent; parent != null; parent = parent.Parent) { anonymousMethodStorey3 = parent.Explicit.AnonymousMethodStorey; if (anonymousMethodStorey3 != null) { break; } } if (anonymousMethodStorey3 == null) { AnonymousMethodStorey parent2 = ((storey == null || storey.Kind == MemberKind.Struct) ? null : storey); explicitBlock.AnonymousMethodStorey.AddCapturedThisField(ec, parent2); break; } } if (explicitBlock.ParametersBlock == ParametersBlock.Original) { anonymousMethodStorey2.AddParentStoreyReference(ec, storey); break; } explicitBlock = (parametersBlock = explicitBlock.ParametersBlock); } else { parametersBlock = explicitBlock as ParametersBlock; } if (parametersBlock != null && parametersBlock.StateMachine != null) { if (parametersBlock.StateMachine == storey) { break; } ExplicitBlock explicitBlock2 = parametersBlock; while (explicitBlock2.Parent != null) { explicitBlock2 = explicitBlock2.Parent.Explicit; if (explicitBlock2.AnonymousMethodStorey != null) { break; } } if (explicitBlock2.AnonymousMethodStorey == null) { if (parametersBlock.StateMachine.HoistedThis == null) { parametersBlock.StateMachine.AddCapturedThisField(ec, null); explicitBlock.HasCapturedThis = true; } continue; } ParametersBlock parametersBlock2 = parametersBlock; while (parametersBlock2.Parent != null) { parametersBlock2 = parametersBlock2.Parent.ParametersBlock; if (parametersBlock2.StateMachine != null && parametersBlock2.StateMachine.HoistedThis != null) { break; } } parametersBlock.StateMachine.AddParentStoreyReference(ec, parametersBlock2.StateMachine ?? storey); } if (anonymousMethodStorey2 != null) { anonymousMethodStorey2.AddParentStoreyReference(ec, storey); anonymousMethodStorey2.HoistedThis = storey.HoistedThis; } } } } } IList referencesFromChildrenBlock = storey.ReferencesFromChildrenBlock; if (referencesFromChildrenBlock != null) { foreach (ExplicitBlock item2 in referencesFromChildrenBlock) { ExplicitBlock explicitBlock3 = item2; while (explicitBlock3.AnonymousMethodStorey != storey) { if (explicitBlock3.AnonymousMethodStorey != null) { explicitBlock3.AnonymousMethodStorey.AddParentStoreyReference(ec, storey); if (explicitBlock3.ParametersBlock == ParametersBlock.Original) { break; } explicitBlock3 = explicitBlock3.ParametersBlock; } if (explicitBlock3 is ParametersBlock { StateMachine: not null } parametersBlock3) { if (parametersBlock3.StateMachine == storey) { break; } parametersBlock3.StateMachine.AddParentStoreyReference(ec, storey); } explicitBlock3.HasCapturedVariable = true; explicitBlock3 = explicitBlock3.Parent.Explicit; } } } storey.Define(); storey.PrepareEmit(); storey.Parent.PartialContainer.AddCompilerGeneratedClass(storey); } public void DisableDebugScopeIndex() { debug_scope_index = -1; } public virtual int GetDebugSymbolScopeIndex() { if (debug_scope_index == 0) { debug_scope_index = ++ParametersBlock.debug_scope_index; } return debug_scope_index; } public void RegisterAsyncAwait() { ExplicitBlock explicitBlock = this; while ((explicitBlock.flags & Flags.AwaitBlock) == 0) { explicitBlock.flags |= Flags.AwaitBlock; if (explicitBlock is ParametersBlock) { break; } explicitBlock = explicitBlock.Parent.Explicit; } } public void RegisterIteratorYield() { ParametersBlock.TopBlock.IsIterator = true; ExplicitBlock explicitBlock = this; while ((explicitBlock.flags & Flags.YieldBlock) == 0) { explicitBlock.flags |= Flags.YieldBlock; if (explicitBlock.Parent == null) { break; } explicitBlock = explicitBlock.Parent.Explicit; } } public void SetCatchBlock() { flags |= Flags.CatchBlock; } public void SetFinallyBlock() { flags |= Flags.FinallyBlock; } public void WrapIntoDestructor(TryFinally tf, ExplicitBlock tryBlock) { tryBlock.statements = statements; statements = new List(1); statements.Add(tf); } } internal class ParametersBlock : ExplicitBlock { public class ParameterInfo : INamedBlockVariable { private readonly ParametersBlock block; private readonly int index; public VariableInfo VariableInfo; private bool is_locked; public ParametersBlock Block => block; Block INamedBlockVariable.Block => block; public bool IsDeclared => true; public bool IsParameter => true; public bool IsLocked { get { return is_locked; } set { is_locked = value; } } public Location Location => Parameter.Location; public Parameter Parameter => block.Parameters[index]; public TypeSpec ParameterType => Parameter.Type; public ParameterInfo(ParametersBlock block, int index) { this.block = block; this.index = index; } public Expression CreateReferenceExpression(ResolveContext rc, Location loc) { return new ParameterReference(this, loc); } } private sealed class BlockScopeExpression : Expression { private Expression child; private readonly ParametersBlock block; public BlockScopeExpression(Expression child, ParametersBlock block) { this.child = child; this.block = block; } public override bool ContainsEmitWithAwait() { return child.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { throw new NotSupportedException(); } protected override Expression DoResolve(ResolveContext ec) { if (child == null) { return null; } child = child.Resolve(ec); if (child == null) { return null; } eclass = child.eclass; type = child.Type; return this; } public override void Emit(EmitContext ec) { block.EmitScopeInitializers(ec); child.Emit(ec); } } protected ParametersCompiled parameters; protected ParameterInfo[] parameter_info; protected bool resolved; protected ToplevelBlock top_block; protected StateMachine state_machine; protected Dictionary labels; public bool HasReferenceToStoreyForInstanceLambdas { get { return (flags & Flags.HasReferenceToStoreyForInstanceLambdas) != 0; } set { flags = (value ? (flags | Flags.HasReferenceToStoreyForInstanceLambdas) : (flags & ~Flags.HasReferenceToStoreyForInstanceLambdas)); } } public bool IsAsync { get { return (flags & Flags.HasAsyncModifier) != 0; } set { flags = (value ? (flags | Flags.HasAsyncModifier) : (flags & ~Flags.HasAsyncModifier)); } } public bool IsExpressionTree => (flags & Flags.IsExpressionTree) != 0; public ParametersCompiled Parameters => parameters; public StateMachine StateMachine => state_machine; public ToplevelBlock TopBlock { get { return top_block; } set { top_block = value; } } public bool Resolved => (flags & Flags.Resolved) != 0; public int TemporaryLocalsCount { get; set; } public ParametersBlock(Block parent, ParametersCompiled parameters, Location start, Flags flags = (Flags)0) : base(parent, (Flags)0, start, start) { if (parameters == null) { throw new ArgumentNullException("parameters"); } this.parameters = parameters; ParametersBlock = this; base.flags |= flags | (parent.ParametersBlock.flags & (Flags.YieldBlock | Flags.AwaitBlock)); top_block = parent.ParametersBlock.top_block; ProcessParameters(); } protected ParametersBlock(ParametersCompiled parameters, Location start) : base(null, (Flags)0, start, start) { if (parameters == null) { throw new ArgumentNullException("parameters"); } this.parameters = parameters; ParametersBlock = this; } protected ParametersBlock(ParametersBlock source, ParametersCompiled parameters) : base(null, (Flags)0, source.StartLocation, source.EndLocation) { this.parameters = parameters; statements = source.statements; scope_initializers = source.scope_initializers; resolved = true; reachable = source.reachable; am_storey = source.am_storey; state_machine = source.state_machine; flags = source.flags & Flags.ReachableEnd; ParametersBlock = this; base.Original = source.Original; } public void CheckControlExit(FlowAnalysisContext fc) { CheckControlExit(fc, fc.DefiniteAssignment); } public virtual void CheckControlExit(FlowAnalysisContext fc, DefiniteAssignmentBitSet dat) { if (parameter_info == null) { return; } ParameterInfo[] array = parameter_info; foreach (ParameterInfo parameterInfo in array) { if (parameterInfo.VariableInfo != null && !parameterInfo.VariableInfo.IsAssigned(dat)) { fc.Report.Error(177, parameterInfo.Location, "The out parameter `{0}' must be assigned to before control leaves the current method", parameterInfo.Parameter.Name); } } } protected override void CloneTo(CloneContext clonectx, Statement t) { base.CloneTo(clonectx, t); ParametersBlock parametersBlock = (ParametersBlock)t; ParametersBlock parametersBlock2 = this; while (true) { if (parametersBlock2.labels != null) { parametersBlock.labels = new Dictionary(); { foreach (KeyValuePair label in parametersBlock2.labels) { if (label.Value is List list) { List list2 = new List(); foreach (LabeledStatement item in list) { list2.Add(RemapLabeledStatement(item, clonectx.RemapBlockCopy(item.Block))); } parametersBlock.labels.Add(label.Key, list2); } else { LabeledStatement labeledStatement = (LabeledStatement)label.Value; parametersBlock.labels.Add(label.Key, RemapLabeledStatement(labeledStatement, clonectx.RemapBlockCopy(labeledStatement.Block))); } } break; } } if (parametersBlock2.Parent == null) { break; } parametersBlock2 = parametersBlock2.Parent.ParametersBlock; } } public override Expression CreateExpressionTree(ResolveContext ec) { if (statements.Count == 1) { Expression expression = statements[0].CreateExpressionTree(ec); if (scope_initializers != null) { expression = new BlockScopeExpression(expression, this); } return expression; } return base.CreateExpressionTree(ec); } public override void Emit(EmitContext ec) { if (state_machine != null && state_machine.OriginalSourceBlock != this) { DefineStoreyContainer(ec, state_machine); state_machine.EmitStoreyInstantiation(ec, this); } base.Emit(ec); } public void EmitEmbedded(EmitContext ec) { if (state_machine != null && state_machine.OriginalSourceBlock != this) { DefineStoreyContainer(ec, state_machine); state_machine.EmitStoreyInstantiation(ec, this); } base.Emit(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { bool result = base.DoFlowAnalysis(fc); if (base.HasReachableClosingBrace) { CheckControlExit(fc); } return result; } public override int GetDebugSymbolScopeIndex() { return 0; } public LabeledStatement GetLabel(string name, Block block) { if (labels == null) { if (Parent != null) { return Parent.ParametersBlock.GetLabel(name, block); } return null; } if (!labels.TryGetValue(name, out var value)) { return null; } LabeledStatement labeledStatement = value as LabeledStatement; if (labeledStatement != null) { if (IsLabelVisible(labeledStatement, block)) { return labeledStatement; } } else { List list = (List)value; for (int i = 0; i < list.Count; i++) { labeledStatement = list[i]; if (IsLabelVisible(labeledStatement, block)) { return labeledStatement; } } } return null; } private static bool IsLabelVisible(LabeledStatement label, Block b) { do { if (label.Block == b) { return true; } b = b.Parent; } while (b != null); return false; } public ParameterInfo GetParameterInfo(Parameter p) { for (int i = 0; i < parameters.Count; i++) { if (parameters[i] == p) { return parameter_info[i]; } } throw new ArgumentException("Invalid parameter"); } public ParameterReference GetParameterReference(int index, Location loc) { return new ParameterReference(parameter_info[index], loc); } public Statement PerformClone(ref HashSet undeclaredVariables) { undeclaredVariables = TopBlock.GetUndeclaredVariables(); CloneContext clonectx = new CloneContext(); return Clone(clonectx); } protected void ProcessParameters() { if (parameters.Count == 0) { return; } parameter_info = new ParameterInfo[parameters.Count]; for (int i = 0; i < parameter_info.Length; i++) { IParameterData parameterData = parameters.FixedParameters[i]; if (parameterData != null) { parameter_info[i] = new ParameterInfo(this, i); if (parameterData.Name != null) { AddLocalName(parameterData.Name, parameter_info[i]); } } } } private LabeledStatement RemapLabeledStatement(LabeledStatement stmt, Block dst) { Block block = stmt.Block; if (block.ParametersBlock != this) { return stmt; } List list = block.Statements; for (int i = 0; i < list.Count; i++) { if (list[i] == stmt) { return (LabeledStatement)dst.Statements[i]; } } throw new InternalErrorException("Should never be reached"); } public override bool Resolve(BlockContext bc) { if (resolved) { return true; } resolved = true; if (bc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { flags |= Flags.IsExpressionTree; } try { PrepareAssignmentAnalysis(bc); if (!base.Resolve(bc)) { return false; } } catch (Exception ex) { if (ex is CompletionResult || bc.Report.IsDisabled || ex is FatalException || bc.Report.Printer is NullReportPrinter || bc.Module.Compiler.Settings.BreakOnInternalError) { throw; } if (bc.CurrentBlock != null) { bc.Report.Error(584, bc.CurrentBlock.StartLocation, "Internal compiler error: {0}", ex.Message); } else { bc.Report.Error(587, "Internal compiler error: {0}", ex.Message); } } if (IsAsync && bc.CurrentAnonymousMethod is AnonymousMethodBody { ReturnTypeInference: not null } anonymousMethodBody && !anonymousMethodBody.ReturnTypeInference.HasBounds(0)) { anonymousMethodBody.ReturnTypeInference = null; anonymousMethodBody.ReturnType = bc.Module.PredefinedTypes.Task.TypeSpec; return true; } return true; } private void PrepareAssignmentAnalysis(BlockContext bc) { for (int i = 0; i < parameters.Count; i++) { IParameterData parameterData = parameters.FixedParameters[i]; if ((parameterData.ModFlags & Parameter.Modifier.OUT) != Parameter.Modifier.NONE) { parameter_info[i].VariableInfo = VariableInfo.Create(bc, (Parameter)parameterData); } } } public ToplevelBlock ConvertToIterator(IMethodData method, TypeDefinition host, TypeSpec iterator_type, bool is_enumerable) { Iterator iterator = new Iterator(this, method, host, iterator_type, is_enumerable); IteratorStorey stateMachine = (IteratorStorey)(state_machine = new IteratorStorey(iterator)); iterator.SetStateMachine(stateMachine); ToplevelBlock toplevelBlock = new ToplevelBlock(host.Compiler, Parameters, Location.Null, Flags.CompilerGenerated); toplevelBlock.Original = this; toplevelBlock.state_machine = stateMachine; toplevelBlock.AddStatement(new Return(iterator, iterator.Location)); return toplevelBlock; } public ParametersBlock ConvertToAsyncTask(IMemberContext context, TypeDefinition host, ParametersCompiled parameters, TypeSpec returnType, TypeSpec delegateType, Location loc) { for (int i = 0; i < parameters.Count; i++) { Parameter parameter = parameters[i]; Parameter.Modifier modFlags = parameter.ModFlags; if ((modFlags & Parameter.Modifier.RefOutMask) != Parameter.Modifier.NONE) { host.Compiler.Report.Error(1988, parameter.Location, "Async methods cannot have ref or out parameters"); return this; } if (parameter is ArglistParameter) { host.Compiler.Report.Error(4006, parameter.Location, "__arglist is not allowed in parameter list of async methods"); return this; } if (parameters.Types[i].IsPointer) { host.Compiler.Report.Error(4005, parameter.Location, "Async methods cannot have unsafe parameters"); return this; } } if (!base.HasAwait) { host.Compiler.Report.Warning(1998, 1, loc, "Async block lacks `await' operator and will run synchronously"); } BuiltinTypeSpec builtinTypeSpec = host.Module.Compiler.BuiltinTypes.Void; AsyncInitializer asyncInitializer = new AsyncInitializer(this, host, builtinTypeSpec); asyncInitializer.Type = builtinTypeSpec; asyncInitializer.DelegateType = delegateType; AsyncTaskStorey stateMachine = (AsyncTaskStorey)(state_machine = new AsyncTaskStorey(this, context, asyncInitializer, returnType)); asyncInitializer.SetStateMachine(stateMachine); ParametersBlock parametersBlock = ((this is ToplevelBlock) ? new ToplevelBlock(host.Compiler, Parameters, Location.Null, Flags.CompilerGenerated) : new ParametersBlock(Parent, parameters, Location.Null, Flags.CompilerGenerated | Flags.HasAsyncModifier)); parametersBlock.Original = this; parametersBlock.state_machine = stateMachine; parametersBlock.AddStatement(new AsyncInitializerStatement(asyncInitializer)); return parametersBlock; } } internal class ToplevelBlock : ParametersBlock { private LocalVariable this_variable; private CompilerContext compiler; private Dictionary names; private List this_references; public bool IsIterator { get { return (flags & Flags.Iterator) != 0; } set { flags = (value ? (flags | Flags.Iterator) : (flags & ~Flags.Iterator)); } } public Report Report => compiler.Report; public List ThisReferencesFromChildrenBlock => this_references; public LocalVariable ThisVariable => this_variable; public ToplevelBlock(CompilerContext ctx, Location loc) : this(ctx, ParametersCompiled.EmptyReadOnlyParameters, loc) { } public ToplevelBlock(CompilerContext ctx, ParametersCompiled parameters, Location start, Flags flags = (Flags)0) : base(parameters, start) { compiler = ctx; base.flags = flags; top_block = this; ProcessParameters(); } public ToplevelBlock(ParametersBlock source, ParametersCompiled parameters) : base(source, parameters) { compiler = source.TopBlock.compiler; top_block = this; } public override void AddLocalName(string name, INamedBlockVariable li, bool ignoreChildrenBlocks) { if (names == null) { names = new Dictionary(); } if (!names.TryGetValue(name, out var value)) { names.Add(name, li); return; } List list; if (value is INamedBlockVariable item) { list = new List(); list.Add(item); names[name] = list; } else { list = (List)value; } ExplicitBlock explicitBlock = li.Block.Explicit; for (int i = 0; i < list.Count; i++) { INamedBlockVariable namedBlockVariable = list[i]; Block block = namedBlockVariable.Block.Explicit; if (explicitBlock == block) { li.Block.Error_AlreadyDeclared(name, li); break; } Block block2 = explicitBlock; while ((block2 = block2.Parent) != null) { if (block2 == block) { li.Block.Error_AlreadyDeclared(name, li, "parent or current"); i = list.Count; break; } } if (ignoreChildrenBlocks || explicitBlock.Parent == block.Parent) { continue; } while ((block = block.Parent) != null) { if (explicitBlock == block) { li.Block.Error_AlreadyDeclared(name, li, "child"); i = list.Count; break; } } } list.Add(li); } public void AddLabel(string name, LabeledStatement label) { if (labels == null) { labels = new Dictionary(); } if (!labels.TryGetValue(name, out var value)) { labels.Add(name, label); return; } List list; if (value is LabeledStatement item) { list = new List(); list.Add(item); labels[name] = list; } else { list = (List)value; } for (int i = 0; i < list.Count; i++) { LabeledStatement labeledStatement = list[i]; Block block = labeledStatement.Block; if (label.Block == block) { Report.SymbolRelatedToPreviousError(labeledStatement.loc, name); Report.Error(140, label.loc, "The label `{0}' is a duplicate", name); break; } block = label.Block; while ((block = block.Parent) != null) { if (labeledStatement.Block == block) { Report.Error(158, label.loc, "The label `{0}' shadows another label by the same name in a contained scope", name); i = list.Count; break; } } block = labeledStatement.Block; while ((block = block.Parent) != null) { if (label.Block == block) { Report.Error(158, label.loc, "The label `{0}' shadows another label by the same name in a contained scope", name); i = list.Count; break; } } } list.Add(label); } public void AddThisReferenceFromChildrenBlock(ExplicitBlock block) { if (this_references == null) { this_references = new List(); } if (!this_references.Contains(block)) { this_references.Add(block); } } public void RemoveThisReferenceFromChildrenBlock(ExplicitBlock block) { this_references.Remove(block); } public Arguments GetAllParametersArguments() { int count = parameters.Count; Arguments arguments = new Arguments(count); for (int i = 0; i < count; i++) { ParameterInfo parameterInfo = parameter_info[i]; ParameterReference parameterReference = GetParameterReference(i, parameterInfo.Location); arguments.Add(new Argument(parameterReference, (parameterInfo.Parameter.ParameterModifier & Parameter.Modifier.RefOutMask) switch { Parameter.Modifier.REF => Argument.AType.Ref, Parameter.Modifier.OUT => Argument.AType.Out, _ => Argument.AType.None, })); } return arguments; } public bool GetLocalName(string name, Block block, ref INamedBlockVariable variable) { if (names == null) { return false; } if (!names.TryGetValue(name, out var value)) { return false; } variable = value as INamedBlockVariable; Block block2 = block; if (variable != null) { do { if (variable.Block == block2.Original) { return true; } block2 = block2.Parent; } while (block2 != null); block2 = variable.Block; do { if (block == block2) { return false; } block2 = block2.Parent; } while (block2 != null); } else { List list = (List)value; for (int i = 0; i < list.Count; i++) { variable = list[i]; do { if (variable.Block == block2.Original) { return true; } block2 = block2.Parent; } while (block2 != null); block2 = variable.Block; do { if (block == block2) { return false; } block2 = block2.Parent; } while (block2 != null); block2 = block; } } variable = null; return false; } public void IncludeBlock(ParametersBlock pb, ToplevelBlock block) { if (block.names == null) { return; } foreach (KeyValuePair name in block.names) { if (name.Value is INamedBlockVariable namedBlockVariable) { if (namedBlockVariable.Block.ParametersBlock == pb) { AddLocalName(name.Key, namedBlockVariable, ignoreChildrenBlocks: false); } continue; } foreach (INamedBlockVariable item in (List)name.Value) { if (item.Block.ParametersBlock == pb) { AddLocalName(name.Key, item, ignoreChildrenBlocks: false); } } } } public void AddThisVariable(BlockContext bc) { if (this_variable != null) { throw new InternalErrorException(StartLocation.ToString()); } this_variable = new LocalVariable(this, "this", LocalVariable.Flags.Used | LocalVariable.Flags.IsThis, StartLocation); this_variable.Type = bc.CurrentType; this_variable.PrepareAssignmentAnalysis(bc); } public override void CheckControlExit(FlowAnalysisContext fc, DefiniteAssignmentBitSet dat) { if (this_variable != null) { this_variable.IsThisAssigned(fc, this); } base.CheckControlExit(fc, dat); } public HashSet GetUndeclaredVariables() { if (names == null) { return null; } HashSet hashSet = null; foreach (KeyValuePair name in names) { if (name.Value is List list) { foreach (INamedBlockVariable item in list) { if (IsUndeclaredVariable(item)) { if (hashSet == null) { hashSet = new HashSet(); } hashSet.Add((LocalVariable)item); } } } else if (IsUndeclaredVariable((INamedBlockVariable)name.Value)) { if (hashSet == null) { hashSet = new HashSet(); } hashSet.Add((LocalVariable)name.Value); } } return hashSet; } private static bool IsUndeclaredVariable(INamedBlockVariable namedBlockVariable) { return namedBlockVariable is LocalVariable localVariable && !localVariable.IsDeclared; } public void SetUndeclaredVariables(HashSet undeclaredVariables) { if (names == null) { return; } foreach (KeyValuePair name in names) { if (name.Value is List list) { foreach (INamedBlockVariable item in list) { if (item is LocalVariable localVariable && undeclaredVariables.Contains(localVariable)) { localVariable.Type = null; } } } else if (name.Value is LocalVariable localVariable2 && undeclaredVariables.Contains(localVariable2)) { localVariable2.Type = null; } } } public override void Emit(EmitContext ec) { if (Report.Errors > 0) { return; } try { if (base.IsCompilerGenerated) { using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { base.Emit(ec); } } else { base.Emit(ec); } if (ec.HasReturnLabel || base.HasReachableClosingBrace) { if (ec.HasReturnLabel) { ec.MarkLabel(ec.ReturnLabel); } if (ec.EmitAccurateDebugInfo && !base.IsCompilerGenerated) { ec.Mark(EndLocation); } if (ec.ReturnType.Kind != MemberKind.Void) { ec.Emit(OpCodes.Ldloc, ec.TemporaryReturn()); } ec.Emit(OpCodes.Ret); } } catch (Exception e) { throw new InternalErrorException(e, StartLocation); } } public bool Resolve(BlockContext bc, IMethodData md) { if (resolved) { return true; } int errors = bc.Report.Errors; Resolve(bc); if (bc.Report.Errors > errors) { return false; } MarkReachable(default(Reachability)); if (base.HasReachableClosingBrace && bc.ReturnType.Kind != MemberKind.Void) { bc.Report.Error(161, md.Location, "`{0}': not all code paths return a value", md.GetSignatureForError()); } if ((flags & Flags.NoFlowAnalysis) != 0) { return true; } FlowAnalysisContext fc = new FlowAnalysisContext(bc.Module.Compiler, this, bc.AssignmentInfoOffset); try { FlowAnalysis(fc); } catch (Exception e) { throw new InternalErrorException(e, StartLocation); } return true; } } internal class SwitchLabel : Statement { private Constant converted; private Expression label; private Label? il_label; public bool IsDefault => label == null; public Expression Label => label; public Location Location => loc; public Constant Converted { get { return converted; } set { converted = value; } } public bool PatternMatching { get; set; } public bool SectionStart { get; set; } public SwitchLabel(Expression expr, Location l) { label = expr; loc = l; } public Label GetILLabel(EmitContext ec) { if (!il_label.HasValue) { il_label = ec.DefineLabel(); } return il_label.Value; } protected override void DoEmit(EmitContext ec) { ec.MarkLabel(GetILLabel(ec)); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (!SectionStart) { return false; } fc.BranchDefiniteAssignment(fc.SwitchInitialDefinitiveAssignment); return false; } public override bool Resolve(BlockContext bc) { if (ResolveAndReduce(bc)) { bc.Switch.RegisterLabel(bc, this); } return true; } private bool ResolveAndReduce(BlockContext bc) { if (IsDefault) { return true; } Switch obj = bc.Switch; if (PatternMatching) { label = new Is(obj.ExpressionValue, label, loc).Resolve(bc); return label != null; } Constant constant = label.ResolveLabelConstant(bc); if (constant == null) { return false; } if (obj.IsNullable && constant is NullLiteral) { converted = constant; return true; } if (obj.IsPatternMatching) { label = new Is(obj.ExpressionValue, label, loc).Resolve(bc); return true; } converted = constant.ImplicitConversionRequired(bc, obj.SwitchType); return converted != null; } public void Error_AlreadyOccurs(ResolveContext ec, SwitchLabel collision_with) { ec.Report.SymbolRelatedToPreviousError(collision_with.loc, null); ec.Report.Error(152, loc, "The label `{0}' already occurs in this switch statement", GetSignatureForError()); } protected override void CloneTo(CloneContext clonectx, Statement target) { SwitchLabel switchLabel = (SwitchLabel)target; if (label != null) { switchLabel.label = label.Clone(clonectx); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public string GetSignatureForError() { string arg = ((converted != null) ? converted.GetValueAsLiteral() : "default"); return $"case {arg}:"; } } internal class Switch : LoopStatement { private sealed class LabelsRange : IComparable { public readonly long min; public long max; public readonly List label_values; public long Range => max - min + 1; public LabelsRange(long value) { min = (max = value); label_values = new List(); label_values.Add(value); } public LabelsRange(long min, long max, ICollection values) { this.min = min; this.max = max; label_values = new List(values); } public bool AddValue(long value) { long num = value - min + 1; if (num > 2 * (label_values.Count + 1) || num <= 0) { return false; } max = value; label_values.Add(value); return true; } public int CompareTo(LabelsRange other) { int count = label_values.Count; int count2 = other.label_values.Count; if (count2 == count) { return (int)(other.min - min); } return count - count2; } } private sealed class DispatchStatement : Statement { private readonly Switch body; public DispatchStatement(Switch body) { this.body = body; } protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotImplementedException(); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return false; } protected override void DoEmit(EmitContext ec) { body.EmitDispatch(ec); } } private class MissingBreak : Statement { private readonly SwitchLabel label; public bool FallOut { get; set; } public MissingBreak(SwitchLabel sl) { label = sl; loc = sl.loc; } protected override void DoEmit(EmitContext ec) { } protected override void CloneTo(CloneContext clonectx, Statement target) { } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (FallOut) { fc.Report.Error(8070, loc, "Control cannot fall out of switch statement through final case label `{0}'", label.GetSignatureForError()); } else { fc.Report.Error(163, loc, "Control cannot fall through from one case label `{0}' to another", label.GetSignatureForError()); } return true; } } public Expression Expr; private Dictionary labels; private Dictionary string_labels; private List case_labels; private List> goto_cases; private List end_reachable_das; public TypeSpec SwitchType; private Expression new_expr; private SwitchLabel case_null; private SwitchLabel case_default; private Label defaultLabel; private Label nullLabel; private VariableReference value; private ExpressionStatement string_dictionary; private FieldExpr switch_cache_field; private ExplicitBlock block; private bool end_reachable; private Unwrap unwrap; public SwitchLabel ActiveLabel { get; set; } public ExplicitBlock Block => block; public SwitchLabel DefaultLabel => case_default; public bool IsNullable => unwrap != null; public bool IsPatternMatching => new_expr == null && SwitchType != null; public List RegisteredLabels => case_labels; public VariableReference ExpressionValue => value; public Switch(Expression e, ExplicitBlock block, Location l) : base(block) { Expr = e; this.block = block; loc = l; } private static Expression SwitchGoverningType(ResolveContext rc, Expression expr, bool unwrapExpr) { BuiltinTypeSpec.Type builtinType = expr.Type.BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 1) <= 9u || type == BuiltinTypeSpec.Type.String) { return expr; } if (expr.Type.IsEnum) { return expr; } Expression expression = null; TypeSpec[] switchUserTypes = rc.Module.PredefinedTypes.SwitchUserTypes; foreach (TypeSpec typeSpec in switchUserTypes) { if (!unwrapExpr && typeSpec.IsNullableType && expr.Type.IsNullableType) { break; } Convert.UserConversionRestriction userConversionRestriction = Convert.UserConversionRestriction.ImplicitOnly | Convert.UserConversionRestriction.ProbingOnly; if (unwrapExpr) { userConversionRestriction |= Convert.UserConversionRestriction.NullableSourceOnly; } Expression expression2 = Convert.UserDefinedConversion(rc, expr, typeSpec, userConversionRestriction, Location.Null); if (expression2 != null && expression2 is UserCast) { if (expression != null) { return null; } expression = expression2; } } return expression; } public static TypeSpec[] CreateSwitchUserTypes(ModuleContainer module, TypeSpec nullable) { BuiltinTypes builtinTypes = module.Compiler.BuiltinTypes; TypeSpec[] array = new BuiltinTypeSpec[10] { builtinTypes.SByte, builtinTypes.Byte, builtinTypes.Short, builtinTypes.UShort, builtinTypes.Int, builtinTypes.UInt, builtinTypes.Long, builtinTypes.ULong, builtinTypes.Char, builtinTypes.String }; TypeSpec[] array2 = array; if (nullable != null) { Array.Resize(ref array2, array2.Length + 9); for (int i = 0; i < 9; i++) { array2[10 + i] = nullable.MakeGenericType(module, new TypeSpec[1] { array2[i] }); } } return array2; } public void RegisterLabel(BlockContext rc, SwitchLabel sl) { case_labels.Add(sl); if (sl.IsDefault) { if (case_default != null) { sl.Error_AlreadyOccurs(rc, case_default); } else { case_default = sl; } } else { if (sl.Converted == null) { return; } try { if (string_labels != null) { if (!(sl.Converted.GetValue() is string key)) { case_null = sl; } else { string_labels.Add(key, sl); } } else if (sl.Converted.IsNull) { case_null = sl; } else { labels.Add(sl.Converted.GetValueAsLong(), sl); } } catch (ArgumentException) { if (string_labels != null) { sl.Error_AlreadyOccurs(rc, string_labels[(string)sl.Converted.GetValue()]); } else { sl.Error_AlreadyOccurs(rc, labels[sl.Converted.GetValueAsLong()]); } } } } private void EmitTableSwitch(EmitContext ec, Expression val) { if (labels == null || labels.Count <= 0) { return; } List list; if (string_labels != null) { list = new List(1); list.Add(new LabelsRange(0L, labels.Count - 1, labels.Keys)); } else { long[] array = new long[labels.Count]; labels.Keys.CopyTo(array, 0); Array.Sort(array); list = new List(array.Length); LabelsRange labelsRange = new LabelsRange(array[0]); list.Add(labelsRange); for (int i = 1; i < array.Length; i++) { long num = array[i]; if (!labelsRange.AddValue(num)) { labelsRange = new LabelsRange(num); list.Add(labelsRange); } } list.Sort(); } Label label = defaultLabel; TypeSpec typeSpec = (SwitchType.IsEnum ? EnumSpec.GetUnderlyingType(SwitchType) : SwitchType); for (int num2 = list.Count - 1; num2 >= 0; num2--) { LabelsRange labelsRange2 = list[num2]; label = ((num2 == 0) ? defaultLabel : ec.DefineLabel()); if (labelsRange2.Range <= 2) { foreach (long label_value in labelsRange2.label_values) { SwitchLabel switchLabel = labels[label_value]; if (switchLabel != case_default && switchLabel != case_null) { if (switchLabel.Converted.IsZeroInteger) { val.EmitBranchable(ec, switchLabel.GetILLabel(ec), on_true: false); continue; } val.Emit(ec); switchLabel.Converted.Emit(ec); ec.Emit(OpCodes.Beq, switchLabel.GetILLabel(ec)); } } } else { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Long || typeSpec.BuiltinType == BuiltinTypeSpec.Type.ULong) { val.Emit(ec); ec.EmitLong(labelsRange2.min); ec.Emit(OpCodes.Blt, label); val.Emit(ec); ec.EmitLong(labelsRange2.max); ec.Emit(OpCodes.Bgt, label); val.Emit(ec); if (labelsRange2.min != 0) { ec.EmitLong(labelsRange2.min); ec.Emit(OpCodes.Sub); } ec.Emit(OpCodes.Conv_I4); } else { val.Emit(ec); int num3 = (int)labelsRange2.min; if (num3 > 0) { ec.EmitInt(num3); ec.Emit(OpCodes.Sub); } else if (num3 < 0) { ec.EmitInt(-num3); ec.Emit(OpCodes.Add); } } int num4 = 0; long range = labelsRange2.Range; Label[] array2 = new Label[range]; for (int j = 0; j < range; j++) { long num5 = labelsRange2.label_values[num4]; if (num5 == labelsRange2.min + j) { array2[j] = labels[num5].GetILLabel(ec); num4++; } else { array2[j] = label; } } ec.Emit(OpCodes.Switch, array2); } if (num2 != 0) { ec.MarkLabel(label); } } if (list.Count > 0) { ec.Emit(OpCodes.Br, label); } } public SwitchLabel FindLabel(Constant value) { SwitchLabel switchLabel = null; if (string_labels != null) { if (!(value.GetValue() is string key)) { if (case_null != null) { switchLabel = case_null; } else if (case_default != null) { switchLabel = case_default; } } else { string_labels.TryGetValue(key, out switchLabel); } } else if (value is NullLiteral) { switchLabel = case_null; } else { labels.TryGetValue(value.GetValueAsLong(), out switchLabel); } if (switchLabel == null || switchLabel.SectionStart) { return switchLabel; } int num = case_labels.IndexOf(switchLabel); SwitchLabel switchLabel2; while (true) { switchLabel2 = case_labels[num]; if (switchLabel2.SectionStart) { break; } num--; } return switchLabel2; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { Expr.FlowAnalysis(fc); DefiniteAssignmentBitSet switchInitialDefinitiveAssignment = fc.SwitchInitialDefinitiveAssignment; DefiniteAssignmentBitSet definiteAssignment = (fc.SwitchInitialDefinitiveAssignment = fc.DefiniteAssignment); block.FlowAnalysis(fc); fc.SwitchInitialDefinitiveAssignment = switchInitialDefinitiveAssignment; if (end_reachable_das != null) { DefiniteAssignmentBitSet definiteAssignmentBitSet = DefiniteAssignmentBitSet.And(end_reachable_das); definiteAssignment |= definiteAssignmentBitSet; end_reachable_das = null; } fc.DefiniteAssignment = definiteAssignment; return case_default != null && !end_reachable; } public override bool Resolve(BlockContext ec) { Expr = Expr.Resolve(ec); if (Expr == null) { return false; } new_expr = SwitchGoverningType(ec, Expr, unwrapExpr: false); if (new_expr == null && Expr.Type.IsNullableType) { unwrap = Unwrap.Create(Expr, useDefaultValue: false); if (unwrap == null) { return false; } new_expr = SwitchGoverningType(ec, unwrap, unwrapExpr: true); } Expression expr; if (new_expr == null) { if (ec.Module.Compiler.Settings.Version != LanguageVersion.Experimental) { if (Expr.Type != InternalType.ErrorType) { ec.Report.Error(151, loc, "A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type", Expr.Type.GetSignatureForError()); } return false; } expr = Expr; SwitchType = Expr.Type; } else { expr = new_expr; SwitchType = new_expr.Type; if (SwitchType.IsNullableType) { new_expr = (unwrap = Unwrap.Create(new_expr, useDefaultValue: true)); SwitchType = NullableInfo.GetUnderlyingType(SwitchType); } if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive && ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) { ec.Report.FeatureIsNotAvailable(ec.Module.Compiler, loc, "switch expression of boolean type"); return false; } if (block.Statements.Count == 0) { return true; } if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.String) { string_labels = new Dictionary(); } else { labels = new Dictionary(); } } Constant constant = expr as Constant; if (constant == null) { value = expr as VariableReference; if (value == null && !HasOnlyDefaultSection()) { Block currentBlock = ec.CurrentBlock; ec.CurrentBlock = Block; value = TemporaryVariableReference.Create(SwitchType, ec.CurrentBlock, loc); value.Resolve(ec); ec.CurrentBlock = currentBlock; } } case_labels = new List(); Switch obj = ec.Switch; ec.Switch = this; LoopStatement enclosingLoopOrSwitch = ec.EnclosingLoopOrSwitch; ec.EnclosingLoopOrSwitch = this; bool flag = base.Statement.Resolve(ec); ec.EnclosingLoopOrSwitch = enclosingLoopOrSwitch; ec.Switch = obj; if (goto_cases != null) { foreach (Tuple goto_case in goto_cases) { if (goto_case.Item1 == null) { if (DefaultLabel == null) { Goto.Error_UnknownLabel(ec, "default", loc); } continue; } SwitchLabel switchLabel = FindLabel(goto_case.Item2); if (switchLabel == null) { Goto.Error_UnknownLabel(ec, "case " + goto_case.Item2.GetValueAsLiteral(), loc); } else { goto_case.Item1.Label = switchLabel; } } } if (!flag) { return false; } if (constant == null && SwitchType.BuiltinType == BuiltinTypeSpec.Type.String && string_labels.Count > 6) { ResolveStringSwitchMap(ec); } block.InsertStatement(0, new DispatchStatement(this)); return true; } private bool HasOnlyDefaultSection() { for (int i = 0; i < block.Statements.Count; i++) { if (block.Statements[i] is SwitchLabel { IsDefault: false }) { return false; } } return true; } public override Reachability MarkReachable(Reachability rc) { if (rc.IsUnreachable) { return rc; } base.MarkReachable(rc); block.MarkReachableScope(rc); if (block.Statements.Count == 0) { return rc; } SwitchLabel switchLabel = null; if (new_expr is Constant constant) { switchLabel = FindLabel(constant) ?? case_default; if (switchLabel == null) { block.Statements.RemoveAt(0); return rc; } } Reachability rc2 = default(Reachability); SwitchLabel switchLabel2 = null; for (int i = 0; i < block.Statements.Count; i++) { Statement statement = block.Statements[i]; if (statement is SwitchLabel { SectionStart: not false } switchLabel3) { if (!switchLabel3.IsUnreachable) { rc2 = default(Reachability); continue; } if (rc2.IsUnreachable) { rc2 = ((switchLabel != null && switchLabel != switchLabel3) ? Reachability.CreateUnreachable() : default(Reachability)); } else if (switchLabel2 != null) { switchLabel3.SectionStart = false; statement = new MissingBreak(switchLabel2); statement.MarkReachable(rc); block.Statements.Insert(i - 1, statement); i++; } else if (switchLabel != null && switchLabel != switchLabel3) { rc2 = Reachability.CreateUnreachable(); } switchLabel2 = switchLabel3; } rc2 = statement.MarkReachable(rc2); } if (!rc2.IsUnreachable && switchLabel2 != null) { switchLabel2.SectionStart = false; MissingBreak missingBreak = new MissingBreak(switchLabel2) { FallOut = true }; missingBreak.MarkReachable(rc); block.Statements.Add(missingBreak); } if (case_default == null && switchLabel == null) { return rc; } if (end_reachable) { return rc; } return Reachability.CreateUnreachable(); } public void RegisterGotoCase(GotoCase gotoCase, Constant value) { if (goto_cases == null) { goto_cases = new List>(); } goto_cases.Add(Tuple.Create(gotoCase, value)); } private void ResolveStringSwitchMap(ResolveContext ec) { FullNamedExpression fullNamedExpression; if (ec.Module.PredefinedTypes.Dictionary.Define()) { TypeSpec typeSpec = ec.Module.PredefinedTypes.Dictionary.TypeSpec; TypeSpec[] targs = new BuiltinTypeSpec[2] { ec.BuiltinTypes.String, ec.BuiltinTypes.Int }; fullNamedExpression = new TypeExpression(typeSpec.MakeGenericType(ec, targs), loc); } else { if (!ec.Module.PredefinedTypes.Hashtable.Define()) { ec.Module.PredefinedTypes.Dictionary.Resolve(); return; } fullNamedExpression = new TypeExpression(ec.Module.PredefinedTypes.Hashtable.TypeSpec, loc); } TypeDefinition partialContainer = ec.CurrentMemberDefinition.Parent.PartialContainer; Field field = new Field(partialContainer, fullNamedExpression, Modifiers.PRIVATE | Modifiers.STATIC | Modifiers.COMPILER_GENERATED, new MemberName(CompilerGeneratedContainer.MakeName(null, "f", "switch$map", ec.Module.CounterSwitchTypes++), loc), null); if (!field.Define()) { return; } partialContainer.AddField(field); List list = new List(); int num = -1; labels = new Dictionary(string_labels.Count); string text = null; foreach (SwitchLabel case_label in case_labels) { if (case_label.SectionStart) { labels.Add(++num, case_label); } if (case_label != case_default && case_label != case_null) { text = (string)case_label.Converted.GetValue(); List list2 = new List(2); list2.Add(new StringLiteral(ec.BuiltinTypes, text, case_label.Location)); case_label.Converted = new IntConstant(ec.BuiltinTypes, num, loc); list2.Add(case_label.Converted); list.Add(new CollectionElementInitializer(list2, loc)); } } Arguments arguments = new Arguments(1); arguments.Add(new Argument(new IntConstant(ec.BuiltinTypes, list.Count, loc))); Expression expression = new NewInitialize(fullNamedExpression, arguments, new CollectionOrObjectInitializers(list, loc), loc); switch_cache_field = new FieldExpr(field, loc); string_dictionary = new SimpleAssign(switch_cache_field, expression.Resolve(ec)); } private void DoEmitStringSwitch(EmitContext ec) { Label label = ec.DefineLabel(); value.EmitBranchable(ec, nullLabel, on_true: false); switch_cache_field.EmitBranchable(ec, label, on_true: true); using (ec.With(BuilderContext.Options.OmitDebugInfo, enable: true)) { string_dictionary.EmitStatement(ec); } ec.MarkLabel(label); LocalTemporary localTemporary = new LocalTemporary(ec.BuiltinTypes.Int); ResolveContext rc = new ResolveContext(ec.MemberContext); if (switch_cache_field.Type.IsGeneric) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(value)); arguments.Add(new Argument(localTemporary, Argument.AType.Out)); Expression expression = new Invocation(new MemberAccess(switch_cache_field, "TryGetValue", loc), arguments).Resolve(rc); if (expression == null) { return; } expression.EmitBranchable(ec, defaultLabel, on_true: false); } else { Arguments arguments2 = new Arguments(1); arguments2.Add(new Argument(value)); Expression expression2 = new ElementAccess(switch_cache_field, arguments2, loc).Resolve(rc); if (expression2 == null) { return; } LocalTemporary localTemporary2 = new LocalTemporary(ec.BuiltinTypes.Object); localTemporary2.EmitAssign(ec, expression2, leave_copy: true, isCompound: false); ec.Emit(OpCodes.Brfalse, defaultLabel); ExpressionStatement expressionStatement = (ExpressionStatement)new SimpleAssign(localTemporary, new Cast(new TypeExpression(ec.BuiltinTypes.Int, loc), localTemporary2, loc)).Resolve(rc); expressionStatement.EmitStatement(ec); localTemporary2.Release(ec); } EmitTableSwitch(ec, localTemporary); localTemporary.Release(ec); } private void EmitShortSwitch(EmitContext ec) { MethodSpec methodSpec = null; if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.String) { methodSpec = ec.Module.PredefinedMembers.StringEqual.Resolve(loc); } if (methodSpec != null) { value.EmitBranchable(ec, nullLabel, on_true: false); } for (int i = 0; i < case_labels.Count; i++) { SwitchLabel switchLabel = case_labels[i]; if (switchLabel != case_default && switchLabel != case_null) { Constant converted = switchLabel.Converted; if (converted == null) { switchLabel.Label.EmitBranchable(ec, switchLabel.GetILLabel(ec), on_true: true); } else if (methodSpec != null) { value.Emit(ec); converted.Emit(ec); default(CallEmitter).EmitPredefined(ec, methodSpec, new Arguments(0)); ec.Emit(OpCodes.Brtrue, switchLabel.GetILLabel(ec)); } else if (converted.IsZeroInteger && converted.Type.BuiltinType != BuiltinTypeSpec.Type.Long && converted.Type.BuiltinType != BuiltinTypeSpec.Type.ULong) { value.EmitBranchable(ec, switchLabel.GetILLabel(ec), on_true: false); } else { value.Emit(ec); converted.Emit(ec); ec.Emit(OpCodes.Beq, switchLabel.GetILLabel(ec)); } } } ec.Emit(OpCodes.Br, defaultLabel); } private void EmitDispatch(EmitContext ec) { if (IsPatternMatching) { EmitShortSwitch(ec); return; } if (value == null) { int num = 0; { foreach (SwitchLabel case_label in case_labels) { if (case_label.IsUnreachable || num++ <= 0) { continue; } Constant constant = (Constant)new_expr; SwitchLabel switchLabel = FindLabel(constant) ?? case_default; ec.Emit(OpCodes.Br, switchLabel.GetILLabel(ec)); break; } return; } } if (string_dictionary != null) { DoEmitStringSwitch(ec); } else if (case_labels.Count < 4 || string_labels != null) { EmitShortSwitch(ec); } else { EmitTableSwitch(ec, value); } } protected override void DoEmit(EmitContext ec) { Label loopEnd = ec.LoopEnd; Switch obj = ec.Switch; ec.LoopEnd = ec.DefineLabel(); ec.Switch = this; defaultLabel = ((case_default == null) ? ec.LoopEnd : case_default.GetILLabel(ec)); nullLabel = ((case_null == null) ? defaultLabel : case_null.GetILLabel(ec)); if (value != null) { ec.Mark(loc); Expression expression = new_expr ?? Expr; if (IsNullable) { unwrap.EmitCheck(ec); ec.Emit(OpCodes.Brfalse, nullLabel); value.EmitAssign(ec, expression, leave_copy: false, prepare_for_load: false); } else if (expression != value) { value.EmitAssign(ec, expression, leave_copy: false, prepare_for_load: false); } ec.Mark(block.StartLocation); block.IsCompilerGenerated = true; } else { new_expr.EmitSideEffect(ec); } block.Emit(ec); ec.MarkLabel(ec.LoopEnd); ec.LoopEnd = loopEnd; ec.Switch = obj; } protected override void CloneTo(CloneContext clonectx, Statement t) { Switch obj = (Switch)t; obj.Expr = Expr.Clone(clonectx); obj.Statement = (obj.block = (ExplicitBlock)block.Clone(clonectx)); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } public override void AddEndDefiniteAssignment(FlowAnalysisContext fc) { if (case_default != null || new_expr is Constant) { if (end_reachable_das == null) { end_reachable_das = new List(); } end_reachable_das.Add(fc.DefiniteAssignment); } } public override void SetEndReachable() { end_reachable = true; } } internal abstract class ResumableStatement : Statement { private bool prepared; protected Label resume_point; public Label PrepareForEmit(EmitContext ec) { if (!prepared) { prepared = true; resume_point = ec.DefineLabel(); } return resume_point; } public virtual Label PrepareForDispose(EmitContext ec, Label end) { return end; } public virtual void EmitForDispose(EmitContext ec, LocalBuilder pc, Label end, bool have_dispatcher) { } } internal abstract class TryFinallyBlock : ExceptionStatement { protected Statement stmt; private Label dispose_try_block; private bool prepared_for_dispose; private bool emitted_dispose; private Method finally_host; public Statement Statement => stmt; protected TryFinallyBlock(Statement stmt, Location loc) : base(loc) { this.stmt = stmt; } protected abstract void EmitTryBody(EmitContext ec); public abstract void EmitFinallyBody(EmitContext ec); public override Label PrepareForDispose(EmitContext ec, Label end) { if (!prepared_for_dispose) { prepared_for_dispose = true; dispose_try_block = ec.DefineLabel(); } return dispose_try_block; } protected sealed override void DoEmit(EmitContext ec) { EmitTryBodyPrepare(ec); EmitTryBody(ec); bool flag = EmitBeginFinallyBlock(ec); Label label = ec.DefineLabel(); if (resume_points != null && flag) { StateMachineInitializer stateMachineInitializer = (StateMachineInitializer)ec.CurrentAnonymousMethod; ec.Emit(OpCodes.Ldloc, stateMachineInitializer.SkipFinally); ec.Emit(OpCodes.Brfalse_S, label); ec.Emit(OpCodes.Endfinally); } ec.MarkLabel(label); if (finally_host != null) { finally_host.Define(); finally_host.PrepareEmit(); finally_host.Emit(); finally_host.Parent.AddMember(finally_host); CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc); callEmitter.EmitPredefined(ec, finally_host.Spec, new Arguments(0), statement: true); } else { EmitFinallyBody(ec); } if (flag) { ec.EndExceptionBlock(); } } public override void EmitForDispose(EmitContext ec, LocalBuilder pc, Label end, bool have_dispatcher) { if (emitted_dispose) { return; } emitted_dispose = true; Label label = ec.DefineLabel(); if (have_dispatcher) { ec.Emit(OpCodes.Br, end); } ec.BeginExceptionBlock(); ec.MarkLabel(dispose_try_block); Label[] array = null; for (int i = 0; i < resume_points.Count; i++) { ResumableStatement resumableStatement = resume_points[i]; Label label2 = resumableStatement.PrepareForDispose(ec, label); if (label2.Equals(label) && array == null) { continue; } if (array == null) { array = new Label[resume_points.Count]; for (int j = 0; j < i; j++) { array[j] = label; } } array[i] = label2; } if (array != null) { int k; for (k = 1; k < array.Length && array[0].Equals(array[k]); k++) { } bool flag = k < array.Length; if (flag) { ec.Emit(OpCodes.Ldloc, pc); ec.EmitInt(first_resume_pc); ec.Emit(OpCodes.Sub); ec.Emit(OpCodes.Switch, array); } foreach (ResumableStatement resume_point in resume_points) { resume_point.EmitForDispose(ec, pc, label, flag); } } ec.MarkLabel(label); ec.BeginFinallyBlock(); if (finally_host != null) { CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = new CompilerGeneratedThis(ec.CurrentType, loc); callEmitter.EmitPredefined(ec, finally_host.Spec, new Arguments(0), statement: true); } else { EmitFinallyBody(ec); } ec.EndExceptionBlock(); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { bool result = stmt.FlowAnalysis(fc); parent_try_block = null; return result; } protected virtual bool EmitBeginFinallyBlock(EmitContext ec) { ec.BeginFinallyBlock(); return true; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Statement.MarkReachable(rc); } public override bool Resolve(BlockContext bc) { parent_try_block = bc.CurrentTryBlock; bc.CurrentTryBlock = this; bool flag; if (stmt is TryCatch) { flag = stmt.Resolve(bc); } else { using (bc.Set(ResolveContext.Options.TryScope)) { flag = stmt.Resolve(bc); } } bc.CurrentTryBlock = parent_try_block; if (bc.CurrentIterator != null && !bc.IsInProbingMode && stmt is Block block && block.Explicit.HasYield) { finally_host = bc.CurrentIterator.CreateFinallyHost(this); } return base.Resolve(bc) && flag; } } internal abstract class ExceptionStatement : ResumableStatement { protected List resume_points; protected int first_resume_pc; protected ExceptionStatement parent_try_block; protected int first_catch_resume_pc = -1; protected ExceptionStatement(Location loc) { base.loc = loc; } protected virtual void EmitTryBodyPrepare(EmitContext ec) { StateMachineInitializer stateMachineInitializer = null; if (resume_points != null) { stateMachineInitializer = (StateMachineInitializer)ec.CurrentAnonymousMethod; ec.EmitInt(-3); ec.Emit(OpCodes.Stloc, stateMachineInitializer.CurrentPC); } if (IsRewrittenTryCatchFinally()) { ec.BeginExceptionBlock(); if (first_catch_resume_pc >= 0) { ec.MarkLabel(resume_point); ec.Emit(OpCodes.Ldloc, stateMachineInitializer.CurrentPC); ec.EmitInt(first_resume_pc + first_catch_resume_pc); ec.Emit(OpCodes.Sub); Label[] array = new Label[resume_points.Count - first_catch_resume_pc]; for (int i = 0; i < array.Length; i++) { array[i] = resume_points[i + first_catch_resume_pc].PrepareForEmit(ec); } ec.Emit(OpCodes.Switch, array); } } ec.BeginExceptionBlock(); if (resume_points != null && first_catch_resume_pc != 0) { if (first_catch_resume_pc < 0) { ec.MarkLabel(resume_point); } ec.Emit(OpCodes.Ldloc, stateMachineInitializer.CurrentPC); ec.EmitInt(first_resume_pc); ec.Emit(OpCodes.Sub); Label[] array2 = new Label[(first_catch_resume_pc > 0) ? first_catch_resume_pc : resume_points.Count]; for (int j = 0; j < array2.Length; j++) { array2[j] = resume_points[j].PrepareForEmit(ec); } ec.Emit(OpCodes.Switch, array2); } } private bool IsRewrittenTryCatchFinally() { if (!(this is TryFinally tryFinally)) { return false; } if (!(tryFinally.Statement is TryCatch tryCatch)) { return false; } return tryFinally.FinallyBlock.HasAwait || tryCatch.HasClauseWithAwait; } public int AddResumePoint(ResumableStatement stmt, int pc, StateMachineInitializer stateMachine, TryCatch catchBlock) { pc = ((parent_try_block == null) ? stateMachine.AddResumePoint(this) : parent_try_block.AddResumePoint(this, pc, stateMachine, catchBlock)); if (resume_points == null) { resume_points = new List(); first_resume_pc = pc; } if (pc != first_resume_pc + resume_points.Count) { throw new InternalErrorException("missed an intervening AddResumePoint?"); } if (this is TryFinally tryFinally && tryFinally.Statement == catchBlock && first_catch_resume_pc < 0) { first_catch_resume_pc = resume_points.Count; } resume_points.Add(stmt); return pc; } } internal class Lock : TryFinallyBlock { private Expression expr; private TemporaryVariableReference expr_copy; private TemporaryVariableReference lock_taken; public Expression Expr => expr; public Lock(Expression expr, Statement stmt, Location loc) : base(stmt, loc) { this.expr = expr; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); return base.DoFlowAnalysis(fc); } public override bool Resolve(BlockContext ec) { expr = expr.Resolve(ec); if (expr == null) { return false; } if (!TypeSpec.IsReferenceType(expr.Type) && expr.Type != InternalType.ErrorType) { ec.Report.Error(185, loc, "`{0}' is not a reference type as required by the lock statement", expr.Type.GetSignatureForError()); } if (expr.Type.IsGenericParameter) { expr = Convert.ImplicitTypeParameterConversion(expr, (TypeParameterSpec)expr.Type, ec.BuiltinTypes.Object); } VariableReference variableReference = expr as VariableReference; bool isLockedByStatement; if (variableReference != null) { isLockedByStatement = variableReference.IsLockedByStatement; variableReference.IsLockedByStatement = true; } else { variableReference = null; isLockedByStatement = false; } expr_copy = TemporaryVariableReference.Create(ec.BuiltinTypes.Object, ec.CurrentBlock, loc); expr_copy.Resolve(ec); if (ResolvePredefinedMethods(ec) > 1) { lock_taken = TemporaryVariableReference.Create(ec.BuiltinTypes.Bool, ec.CurrentBlock, loc); lock_taken.Resolve(ec); } using (ec.Set(ResolveContext.Options.LockScope)) { base.Resolve(ec); } if (variableReference != null) { variableReference.IsLockedByStatement = isLockedByStatement; } return true; } protected override void EmitTryBodyPrepare(EmitContext ec) { expr_copy.EmitAssign(ec, expr); if (lock_taken != null) { lock_taken.EmitAssign(ec, new BoolLiteral(ec.BuiltinTypes, val: false, loc)); } else { expr_copy.Emit(ec); ec.Emit(OpCodes.Call, ec.Module.PredefinedMembers.MonitorEnter.Get()); } base.EmitTryBodyPrepare(ec); } protected override void EmitTryBody(EmitContext ec) { if (lock_taken != null) { expr_copy.Emit(ec); lock_taken.LocalInfo.CreateBuilder(ec); lock_taken.AddressOf(ec, AddressOp.Load); ec.Emit(OpCodes.Call, ec.Module.PredefinedMembers.MonitorEnter_v4.Get()); } base.Statement.Emit(ec); } public override void EmitFinallyBody(EmitContext ec) { Label label = ec.DefineLabel(); if (lock_taken != null) { lock_taken.Emit(ec); ec.Emit(OpCodes.Brfalse_S, label); } expr_copy.Emit(ec); MethodSpec methodSpec = ec.Module.PredefinedMembers.MonitorExit.Resolve(loc); if (methodSpec != null) { ec.Emit(OpCodes.Call, methodSpec); } ec.MarkLabel(label); } private int ResolvePredefinedMethods(ResolveContext rc) { MethodSpec methodSpec = rc.Module.PredefinedMembers.MonitorEnter_v4.Get(); if (methodSpec != null) { return 4; } methodSpec = rc.Module.PredefinedMembers.MonitorEnter.Get(); if (methodSpec != null) { return 1; } rc.Module.PredefinedMembers.MonitorEnter_v4.Resolve(loc); return 0; } protected override void CloneTo(CloneContext clonectx, Statement t) { Lock obj = (Lock)t; obj.expr = expr.Clone(clonectx); obj.stmt = base.Statement.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Unchecked : Statement { public Block Block; public Unchecked(Block b, Location loc) { Block = b; b.Unchecked = true; base.loc = loc; } public override bool Resolve(BlockContext ec) { using (ec.With(ResolveContext.Options.AllCheckStateFlags, enable: false)) { return Block.Resolve(ec); } } protected override void DoEmit(EmitContext ec) { using (ec.With(BuilderContext.Options.CheckedScope, enable: false)) { Block.Emit(ec); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return Block.FlowAnalysis(fc); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Block.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Statement t) { Unchecked obj = (Unchecked)t; obj.Block = clonectx.LookupBlock(Block); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Checked : Statement { public Block Block; public Checked(Block b, Location loc) { Block = b; b.Unchecked = false; base.loc = loc; } public override bool Resolve(BlockContext ec) { using (ec.With(ResolveContext.Options.AllCheckStateFlags, enable: true)) { return Block.Resolve(ec); } } protected override void DoEmit(EmitContext ec) { using (ec.With(BuilderContext.Options.CheckedScope, enable: true)) { Block.Emit(ec); } } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return Block.FlowAnalysis(fc); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Block.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Statement t) { Checked obj = (Checked)t; obj.Block = clonectx.LookupBlock(Block); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Unsafe : Statement { public Block Block; public Unsafe(Block b, Location loc) { Block = b; Block.Unsafe = true; base.loc = loc; } public override bool Resolve(BlockContext ec) { if (ec.CurrentIterator != null) { Expression.UnsafeInsideIteratorError(ec, loc); } using (ec.Set(ResolveContext.Options.UnsafeScope)) { return Block.Resolve(ec); } } protected override void DoEmit(EmitContext ec) { Block.Emit(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return Block.FlowAnalysis(fc); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); return Block.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Statement t) { Unsafe obj = (Unsafe)t; obj.Block = clonectx.LookupBlock(Block); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Fixed : Statement { private abstract class Emitter : ShimExpression { protected LocalVariable vi; protected Emitter(Expression expr, LocalVariable li) : base(expr) { vi = li; } public abstract void EmitExit(EmitContext ec); public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); } } private sealed class ExpressionEmitter : Emitter { public ExpressionEmitter(Expression converted, LocalVariable li) : base(converted, li) { } protected override Expression DoResolve(ResolveContext rc) { throw new NotImplementedException(); } public override void Emit(EmitContext ec) { expr.Emit(ec); vi.EmitAssign(ec); } public override void EmitExit(EmitContext ec) { ec.EmitInt(0); ec.Emit(OpCodes.Conv_U); vi.EmitAssign(ec); } } private class StringEmitter : Emitter { private LocalVariable pinned_string; public StringEmitter(Expression expr, LocalVariable li) : base(expr, li) { } protected override Expression DoResolve(ResolveContext rc) { pinned_string = new LocalVariable(vi.Block, "$pinned", LocalVariable.Flags.FixedVariable | LocalVariable.Flags.Used | LocalVariable.Flags.CompilerGenerated, vi.Location); pinned_string.Type = rc.BuiltinTypes.String; vi.IsFixed = false; eclass = ExprClass.Variable; type = rc.BuiltinTypes.Int; return this; } public override void Emit(EmitContext ec) { pinned_string.CreateBuilder(ec); expr.Emit(ec); pinned_string.EmitAssign(ec); pinned_string.Emit(ec); ec.Emit(OpCodes.Conv_U); PropertySpec propertySpec = ec.Module.PredefinedMembers.RuntimeHelpersOffsetToStringData.Resolve(loc); if (propertySpec != null) { Label label = ec.DefineLabel(); vi.EmitAssign(ec); vi.Emit(ec); ec.Emit(OpCodes.Brfalse_S, label); vi.Emit(ec); PropertyExpr propertyExpr = new PropertyExpr(propertySpec, pinned_string.Location); propertyExpr.Resolve(new ResolveContext(ec.MemberContext)).Emit(ec); ec.Emit(OpCodes.Add); vi.EmitAssign(ec); ec.MarkLabel(label); } } public override void EmitExit(EmitContext ec) { ec.EmitNull(); pinned_string.EmitAssign(ec); } } public class VariableDeclaration : BlockVariable { public VariableDeclaration(FullNamedExpression type, LocalVariable li) : base(type, li) { } protected override Expression ResolveInitializer(BlockContext bc, LocalVariable li, Expression initializer) { if (!base.Variable.Type.IsPointer && li == base.Variable) { bc.Report.Error(209, base.TypeExpression.Location, "The type of locals declared in a fixed statement must be a pointer type"); return null; } Expression expression = initializer.Resolve(bc); if (expression == null) { return null; } if (expression.Type is ArrayContainer { Element: var element } arrayContainer) { if (!TypeManager.VerifyUnmanaged(bc.Module, element, loc)) { return null; } Expression left; if (ExpressionAnalyzer.IsInexpensiveLoad(expression)) { left = expression; } else { LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(arrayContainer, bc.CurrentBlock, loc); left = new CompilerAssign(localVariable.CreateReferenceExpression(bc, loc), expression, loc); expression = localVariable.CreateReferenceExpression(bc, loc); } ArrayPtr arrayPtr = new ArrayPtr(expression, element, loc); Expression expression2 = Convert.ImplicitConversionRequired(bc, arrayPtr.Resolve(bc), li.Type, loc); if (expression2 == null) { return null; } expression2 = new Conditional(new BooleanExpression(new Binary(Binary.Operator.LogicalOr, new Binary(Binary.Operator.Equality, left, new NullLiteral(loc)), new Binary(Binary.Operator.Equality, new MemberAccess(expression, "Length"), new IntConstant(bc.BuiltinTypes, 0, loc)))), new NullLiteral(loc), expression2, loc); expression2 = expression2.Resolve(bc); return new ExpressionEmitter(expression2, li); } if (expression.Type.BuiltinType == BuiltinTypeSpec.Type.String) { return new StringEmitter(expression, li).Resolve(bc); } if (expression is FixedBufferPtr) { return new ExpressionEmitter(expression, li); } bool flag = true; if (expression is Unary unary) { if (unary.Oper == Unary.Operator.AddressOf && !(unary.Expr is IVariableReference { IsFixed: not false })) { flag = false; } } else if (initializer is Cast) { bc.Report.Error(254, initializer.Location, "The right hand side of a fixed statement assignment may not be a cast expression"); return null; } if (flag) { bc.Report.Error(213, loc, "You cannot use the fixed statement to take the address of an already fixed expression"); } expression = Convert.ImplicitConversionRequired(bc, expression, li.Type, loc); return new ExpressionEmitter(expression, li); } } private VariableDeclaration decl; private Statement statement; private bool has_ret; public Statement Statement => statement; public BlockVariable Variables => decl; public Fixed(VariableDeclaration decl, Statement stmt, Location l) { this.decl = decl; statement = stmt; loc = l; } public override bool Resolve(BlockContext bc) { using (bc.Set(ResolveContext.Options.FixedInitializerScope)) { if (!decl.Resolve(bc)) { return false; } } return statement.Resolve(bc); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { decl.FlowAnalysis(fc); return statement.FlowAnalysis(fc); } protected override void DoEmit(EmitContext ec) { decl.Variable.CreateBuilder(ec); decl.Initializer.Emit(ec); if (decl.Declarators != null) { foreach (BlockVariableDeclarator declarator in decl.Declarators) { declarator.Variable.CreateBuilder(ec); declarator.Initializer.Emit(ec); } } statement.Emit(ec); if (has_ret) { return; } ((Emitter)decl.Initializer).EmitExit(ec); if (decl.Declarators == null) { return; } foreach (BlockVariableDeclarator declarator2 in decl.Declarators) { ((Emitter)declarator2.Initializer).EmitExit(ec); } } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); decl.MarkReachable(rc); rc = statement.MarkReachable(rc); has_ret = rc.IsUnreachable; return rc; } protected override void CloneTo(CloneContext clonectx, Statement t) { Fixed obj = (Fixed)t; obj.decl = (VariableDeclaration)decl.Clone(clonectx); obj.statement = statement.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Catch : Statement { private class CatchVariableStore : Statement { private readonly Catch ctch; public CatchVariableStore(Catch ctch) { this.ctch = ctch; } protected override void CloneTo(CloneContext clonectx, Statement target) { } protected override void DoEmit(EmitContext ec) { ctch.EmitCatchVariableStore(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { return true; } } private class FilterStatement : Statement { private readonly Catch ctch; public FilterStatement(Catch ctch) { this.ctch = ctch; } protected override void CloneTo(CloneContext clonectx, Statement target) { } protected override void DoEmit(EmitContext ec) { if (ctch.li != null) { if (ctch.hoisted_temp != null) { ctch.hoisted_temp.Emit(ec); } else { ctch.li.Emit(ec); } if (!ctch.IsGeneral && ctch.type.Kind == MemberKind.TypeParameter) { ec.Emit(OpCodes.Box, ctch.type); } } Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); ec.Emit(OpCodes.Brtrue_S, label); ec.EmitInt(0); ec.Emit(OpCodes.Br, label2); ec.MarkLabel(label); ctch.Filter.Emit(ec); ec.MarkLabel(label2); ec.Emit(OpCodes.Endfilter); ec.BeginFilterHandler(); ec.Emit(OpCodes.Pop); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { ctch.Filter.FlowAnalysis(fc); return true; } public override bool Resolve(BlockContext bc) { ctch.Filter = ctch.Filter.Resolve(bc); if (ctch.Filter != null) { if (ctch.Filter.ContainsEmitWithAwait()) { bc.Report.Error(7094, ctch.Filter.Location, "The `await' operator cannot be used in the filter expression of a catch clause"); } if (ctch.Filter is Constant { IsDefaultValue: false }) { bc.Report.Warning(7095, 1, ctch.Filter.Location, "Exception filter expression is a constant"); } } return true; } } private ExplicitBlock block; private LocalVariable li; private FullNamedExpression type_expr; private CompilerAssign assign; private TypeSpec type; private LocalTemporary hoisted_temp; public ExplicitBlock Block => block; public TypeSpec CatchType => type; public Expression Filter { get; set; } public bool IsGeneral => type_expr == null; public FullNamedExpression TypeExpression { get { return type_expr; } set { type_expr = value; } } public LocalVariable Variable { get { return li; } set { li = value; } } public Catch(ExplicitBlock block, Location loc) { this.block = block; base.loc = loc; } protected override void DoEmit(EmitContext ec) { if (Filter != null) { ec.BeginExceptionFilterBlock(); ec.Emit(OpCodes.Isinst, IsGeneral ? ec.BuiltinTypes.Object : CatchType); if (Block.HasAwait) { Block.EmitScopeInitialization(ec); } else { Block.Emit(ec); } return; } if (IsGeneral) { ec.BeginCatchBlock(ec.BuiltinTypes.Object); } else { ec.BeginCatchBlock(CatchType); } if (li == null) { ec.Emit(OpCodes.Pop); } if (Block.HasAwait) { if (li != null) { EmitCatchVariableStore(ec); } } else { Block.Emit(ec); } } private void EmitCatchVariableStore(EmitContext ec) { li.CreateBuilder(ec); if (li.HoistedVariant != null) { hoisted_temp = new LocalTemporary(li.Type); hoisted_temp.Store(ec); assign.UpdateSource(hoisted_temp); } } public override bool Resolve(BlockContext bc) { using (bc.Set(ResolveContext.Options.CatchScope)) { if (type_expr == null) { if (CreateExceptionVariable(bc.Module.Compiler.BuiltinTypes.Object)) { if (!block.HasAwait || Filter != null) { block.AddScopeStatement(new CatchVariableStore(this)); } Expression source = new EmptyExpression(li.Type); assign = new CompilerAssign(new LocalVariableReference(li, Location.Null), source, Location.Null); Block.AddScopeStatement(new StatementExpression(assign, Location.Null)); } } else { type = type_expr.ResolveAsType(bc); if (type == null) { return false; } if (li == null) { CreateExceptionVariable(type); } if (type.BuiltinType != BuiltinTypeSpec.Type.Exception && !TypeSpec.IsBaseClass(type, bc.BuiltinTypes.Exception, dynamicIsObject: false)) { bc.Report.Error(155, loc, "The type caught or thrown must be derived from System.Exception"); } else if (li != null) { li.Type = type; li.PrepareAssignmentAnalysis(bc); Expression expression = new EmptyExpression(li.Type); if (li.Type.IsGenericParameter) { expression = new UnboxCast(expression, li.Type); } if (!block.HasAwait || Filter != null) { block.AddScopeStatement(new CatchVariableStore(this)); } assign = new CompilerAssign(new LocalVariableReference(li, Location.Null), expression, Location.Null); Block.AddScopeStatement(new StatementExpression(assign, Location.Null)); } } if (Filter != null) { Block.AddScopeStatement(new FilterStatement(this)); } Block.SetCatchBlock(); return Block.Resolve(bc); } } private bool CreateExceptionVariable(TypeSpec type) { if (!Block.HasAwait) { return false; } li = LocalVariable.CreateCompilerGenerated(type, block, Location.Null); return true; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { if (li != null && !li.IsCompilerGenerated) { fc.SetVariableAssigned(li.VariableInfo, generatedAssignment: true); } return block.FlowAnalysis(fc); } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); if (Filter is Constant { IsDefaultValue: not false }) { return Reachability.CreateUnreachable(); } return block.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Statement t) { Catch obj = (Catch)t; if (type_expr != null) { obj.type_expr = (FullNamedExpression)type_expr.Clone(clonectx); } if (Filter != null) { obj.Filter = Filter.Clone(clonectx); } obj.block = (ExplicitBlock)clonectx.LookupBlock(block); } } internal class TryFinally : TryFinallyBlock { private ExplicitBlock fini; private List try_exit_dat; private List> redirected_jumps; private Label? start_fin_label; public ExplicitBlock FinallyBlock => fini; public TryFinally(Statement stmt, ExplicitBlock fini, Location loc) : base(stmt, loc) { this.fini = fini; } public void RegisterForControlExitCheck(DefiniteAssignmentBitSet vector) { if (try_exit_dat == null) { try_exit_dat = new List(); } try_exit_dat.Add(vector); } public override bool Resolve(BlockContext bc) { bool flag = base.Resolve(bc); fini.SetFinallyBlock(); using (bc.Set(ResolveContext.Options.FinallyScope)) { flag &= fini.Resolve(bc); } return flag; } protected override void EmitTryBody(EmitContext ec) { if (fini.HasAwait) { if (ec.TryFinallyUnwind == null) { ec.TryFinallyUnwind = new List(); } ec.TryFinallyUnwind.Add(this); stmt.Emit(ec); if (first_catch_resume_pc < 0 && stmt is TryCatch) { ec.EndExceptionBlock(); } ec.TryFinallyUnwind.Remove(this); if (start_fin_label.HasValue) { ec.MarkLabel(start_fin_label.Value); } } else { stmt.Emit(ec); } } protected override bool EmitBeginFinallyBlock(EmitContext ec) { if (fini.HasAwait) { return false; } return base.EmitBeginFinallyBlock(ec); } public override void EmitFinallyBody(EmitContext ec) { if (!fini.HasAwait) { fini.Emit(ec); return; } BuiltinTypeSpec builtinTypeSpec = ec.BuiltinTypes.Object; ec.BeginCatchBlock(builtinTypeSpec); LocalBuilder temporaryLocal = ec.GetTemporaryLocal(builtinTypeSpec); ec.Emit(OpCodes.Stloc, temporaryLocal); StackFieldExpr temporaryField = ec.GetTemporaryField(builtinTypeSpec); temporaryField.AutomaticallyReuse = false; ec.EmitThis(); ec.Emit(OpCodes.Ldloc, temporaryLocal); temporaryField.EmitAssignFromStack(ec); ec.EndExceptionBlock(); ec.FreeTemporaryLocal(temporaryLocal, builtinTypeSpec); fini.Emit(ec); temporaryField.Emit(ec); Label label = ec.DefineLabel(); ec.Emit(OpCodes.Brfalse_S, label); temporaryField.Emit(ec); ec.Emit(OpCodes.Throw); ec.MarkLabel(label); temporaryField.PrepareCleanup(ec); EmitUnwindFinallyTable(ec); } private bool IsParentBlock(Block block) { for (Block parent = fini; parent != null; parent = parent.Parent) { if (parent == block) { return true; } } return false; } public static Label EmitRedirectedJump(EmitContext ec, AsyncInitializer initializer, Label label, Block labelBlock, bool unwindProtect) { int i; if (labelBlock != null) { for (i = ec.TryFinallyUnwind.Count; i != 0; i--) { TryFinally tryFinally = ec.TryFinallyUnwind[i - 1]; if (!tryFinally.IsParentBlock(labelBlock)) { break; } } } else { i = 0; } bool setReturnState = true; for (; i < ec.TryFinallyUnwind.Count; i++) { TryFinally tryFinally2 = ec.TryFinallyUnwind[i]; if (labelBlock != null && !tryFinally2.IsParentBlock(labelBlock)) { break; } tryFinally2.EmitRedirectedExit(ec, label, initializer, setReturnState, unwindProtect); setReturnState = false; if (!tryFinally2.start_fin_label.HasValue) { tryFinally2.start_fin_label = ec.DefineLabel(); } label = tryFinally2.start_fin_label.Value; } return label; } public static Label EmitRedirectedReturn(EmitContext ec, AsyncInitializer initializer, bool unwindProtect) { return EmitRedirectedJump(ec, initializer, initializer.BodyEnd, null, unwindProtect); } private void EmitRedirectedExit(EmitContext ec, Label label, AsyncInitializer initializer, bool setReturnState, bool unwindProtect) { if (redirected_jumps == null) { redirected_jumps = new List>(); redirected_jumps.Add(Tuple.Create(ec.DefineLabel(), item2: false)); if (setReturnState) { initializer.HoistedReturnState = ec.GetTemporaryField(ec.Module.Compiler.BuiltinTypes.Int, initializedFieldRequired: true); } } int num = redirected_jumps.FindIndex((Tuple l) => l.Item1 == label); if (num < 0) { redirected_jumps.Add(Tuple.Create(label, unwindProtect)); num = redirected_jumps.Count - 1; } if (setReturnState) { IntConstant source = new IntConstant(initializer.HoistedReturnState.Type, num, Location.Null); initializer.HoistedReturnState.EmitAssign(ec, source, leave_copy: false, isCompound: false); } } private void EmitUnwindFinallyTable(EmitContext ec) { if (redirected_jumps == null) { return; } AsyncInitializer asyncInitializer = (AsyncInitializer)ec.CurrentAnonymousMethod; asyncInitializer.HoistedReturnState.EmitLoad(ec); Label[] array = new Label[redirected_jumps.Count]; List> list = null; for (int i = 0; i < array.Length; i++) { Tuple tuple = redirected_jumps[i]; if (tuple.Item2) { if (list == null) { list = new List>(); } Label label = ec.DefineLabel(); list.Add(Tuple.Create(label, tuple.Item1)); array[i] = label; } else { array[i] = tuple.Item1; } } ec.Emit(OpCodes.Switch, array); if (list != null) { foreach (Tuple item in list) { ec.MarkLabel(item.Item1); ec.Emit(OpCodes.Leave, item.Item2); } } ec.MarkLabel(array[0]); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { DefiniteAssignmentBitSet definiteAssignment = fc.BranchDefiniteAssignment(); TryFinally tryFinally = fc.TryFinally; fc.TryFinally = this; bool flag = base.Statement.FlowAnalysis(fc); fc.TryFinally = tryFinally; DefiniteAssignmentBitSet definiteAssignment2 = fc.DefiniteAssignment; fc.DefiniteAssignment = definiteAssignment; bool flag2 = fini.FlowAnalysis(fc); if (try_exit_dat != null) { foreach (DefiniteAssignmentBitSet item in try_exit_dat) { fc.ParametersBlock.CheckControlExit(fc, fc.DefiniteAssignment | item); } try_exit_dat = null; } fc.DefiniteAssignment |= definiteAssignment2; return flag || flag2; } public override Reachability MarkReachable(Reachability rc) { return fini.MarkReachable(rc) | base.MarkReachable(rc); } protected override void CloneTo(CloneContext clonectx, Statement t) { TryFinally tryFinally = (TryFinally)t; tryFinally.stmt = stmt.Clone(clonectx); if (fini != null) { tryFinally.fini = (ExplicitBlock)clonectx.LookupBlock(fini); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class TryCatch : ExceptionStatement { public Block Block; private List clauses; private readonly bool inside_try_finally; private List catch_sm; public List Clauses => clauses; public bool HasClauseWithAwait => catch_sm != null; public bool IsTryCatchFinally => inside_try_finally; public TryCatch(Block block, List catch_clauses, Location l, bool inside_try_finally) : base(l) { Block = block; clauses = catch_clauses; this.inside_try_finally = inside_try_finally; } public override bool Resolve(BlockContext bc) { bool flag; using (bc.Set(ResolveContext.Options.TryScope)) { parent_try_block = bc.CurrentTryBlock; if (IsTryCatchFinally) { flag = Block.Resolve(bc); } else { using (bc.Set(ResolveContext.Options.TryWithCatchScope)) { bc.CurrentTryBlock = this; flag = Block.Resolve(bc); bc.CurrentTryBlock = parent_try_block; } } } TryCatch currentTryCatch = bc.CurrentTryCatch; bc.CurrentTryCatch = this; for (int i = 0; i < clauses.Count; i++) { Catch obj = clauses[i]; flag &= obj.Resolve(bc); if (obj.Block.HasAwait) { if (catch_sm == null) { catch_sm = new List(); } catch_sm.Add(obj); } if (obj.Filter != null) { continue; } TypeSpec catchType = obj.CatchType; if (catchType == null) { continue; } for (int j = 0; j < clauses.Count; j++) { if (j == i || clauses[j].Filter != null) { continue; } if (clauses[j].IsGeneral) { if (catchType.BuiltinType == BuiltinTypeSpec.Type.Exception && bc.Module.DeclaringAssembly.WrapNonExceptionThrows && bc.Module.PredefinedAttributes.RuntimeCompatibility.IsDefined) { bc.Report.Warning(1058, 1, obj.loc, "A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'"); } } else if (j < i) { TypeSpec catchType2 = clauses[j].CatchType; if (catchType2 != null && (catchType == catchType2 || TypeSpec.IsBaseClass(catchType, catchType2, dynamicIsObject: true))) { bc.Report.Error(160, obj.loc, "A previous catch clause already catches all exceptions of this or a super type `{0}'", catchType2.GetSignatureForError()); flag = false; } } } } bc.CurrentTryCatch = currentTryCatch; return base.Resolve(bc) && flag; } protected sealed override void DoEmit(EmitContext ec) { if (!inside_try_finally) { EmitTryBodyPrepare(ec); } Block.Emit(ec); LocalBuilder localBuilder = null; foreach (Catch clause in clauses) { clause.Emit(ec); if (catch_sm != null) { if (localBuilder == null) { localBuilder = ec.DeclareLocal(ec.Module.Compiler.BuiltinTypes.Int, pinned: false); } int num = catch_sm.IndexOf(clause); if (num >= 0) { ec.EmitInt(num + 1); ec.Emit(OpCodes.Stloc, localBuilder); } } } if (localBuilder == null) { if (!inside_try_finally) { ec.EndExceptionBlock(); } return; } ec.EndExceptionBlock(); ec.Emit(OpCodes.Ldloc, localBuilder); Label[] array = new Label[catch_sm.Count + 1]; for (int i = 0; i < array.Length; i++) { array[i] = ec.DefineLabel(); } Label label = ec.DefineLabel(); ec.Emit(OpCodes.Switch, array); ec.MarkLabel(array[0]); ec.Emit(OpCodes.Br, label); LocalVariable asyncThrowVariable = ec.AsyncThrowVariable; Catch obj = null; for (int j = 0; j < catch_sm.Count; j++) { if (obj != null && obj.Block.HasReachableClosingBrace) { ec.Emit(OpCodes.Br, label); } ec.MarkLabel(array[j + 1]); ec.EmitInt(0); ec.Emit(OpCodes.Stloc, localBuilder); obj = catch_sm[j]; ec.AsyncThrowVariable = obj.Variable; obj.Block.Emit(ec); } ec.AsyncThrowVariable = asyncThrowVariable; ec.MarkLabel(label); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { DefiniteAssignmentBitSet definiteAssignmentBitSet = fc.BranchDefiniteAssignment(); bool flag = Block.FlowAnalysis(fc); DefiniteAssignmentBitSet definiteAssignmentBitSet2 = (flag ? null : fc.DefiniteAssignment); foreach (Catch clause in clauses) { fc.BranchDefiniteAssignment(definiteAssignmentBitSet); if (!clause.FlowAnalysis(fc)) { if (definiteAssignmentBitSet2 == null) { definiteAssignmentBitSet2 = fc.DefiniteAssignment; } else { definiteAssignmentBitSet2 &= fc.DefiniteAssignment; } flag = false; } } fc.DefiniteAssignment = definiteAssignmentBitSet2 ?? definiteAssignmentBitSet; parent_try_block = null; return flag; } public override Reachability MarkReachable(Reachability rc) { if (rc.IsUnreachable) { return rc; } base.MarkReachable(rc); Reachability result = Block.MarkReachable(rc); foreach (Catch clause in clauses) { result &= clause.MarkReachable(rc); } return result; } protected override void CloneTo(CloneContext clonectx, Statement t) { TryCatch tryCatch = (TryCatch)t; tryCatch.Block = clonectx.LookupBlock(Block); if (clauses == null) { return; } tryCatch.clauses = new List(); foreach (Catch clause in clauses) { tryCatch.clauses.Add((Catch)clause.Clone(clonectx)); } } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Using : TryFinallyBlock { public class VariableDeclaration : BlockVariable { private Statement dispose_call; public bool IsNested { get; private set; } public VariableDeclaration(FullNamedExpression type, LocalVariable li) : base(type, li) { } public VariableDeclaration(LocalVariable li, Location loc) : base(li) { reachable = true; base.loc = loc; } public VariableDeclaration(Expression expr) : base(null) { loc = expr.Location; base.Initializer = expr; } public void EmitDispose(EmitContext ec) { dispose_call.Emit(ec); } public override bool Resolve(BlockContext bc) { if (IsNested) { return true; } return Resolve(bc, resolveDeclaratorInitializers: false); } public Expression ResolveExpression(BlockContext bc) { Expression expression = base.Initializer.Resolve(bc); if (expression == null) { return null; } li = LocalVariable.CreateCompilerGenerated(expression.Type, bc.CurrentBlock, loc); base.Initializer = ResolveInitializer(bc, base.Variable, expression); return expression; } protected override Expression ResolveInitializer(BlockContext bc, LocalVariable li, Expression initializer) { if (li.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { initializer = initializer.Resolve(bc); if (initializer == null) { return null; } Arguments arguments = new Arguments(1); arguments.Add(new Argument(initializer)); initializer = new DynamicConversion(bc.BuiltinTypes.IDisposable, CSharpBinderFlags.None, arguments, initializer.Location).Resolve(bc); if (initializer == null) { return null; } LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(initializer.Type, bc.CurrentBlock, loc); dispose_call = CreateDisposeCall(bc, localVariable); dispose_call.Resolve(bc); return base.ResolveInitializer(bc, li, new SimpleAssign(localVariable.CreateReferenceExpression(bc, loc), initializer, loc)); } if (li == base.Variable) { CheckIDiposableConversion(bc, li, initializer); dispose_call = CreateDisposeCall(bc, li); dispose_call.Resolve(bc); } return base.ResolveInitializer(bc, li, initializer); } protected virtual void CheckIDiposableConversion(BlockContext bc, LocalVariable li, Expression initializer) { TypeSpec typeSpec = li.Type; if (typeSpec.BuiltinType != BuiltinTypeSpec.Type.IDisposable && !CanConvertToIDisposable(bc, typeSpec) && !typeSpec.IsNullableType && typeSpec != InternalType.ErrorType) { bc.Report.SymbolRelatedToPreviousError(typeSpec); Location location = ((type_expr == null) ? initializer.Location : type_expr.Location); bc.Report.Error(1674, location, "`{0}': type used in a using statement must be implicitly convertible to `System.IDisposable'", typeSpec.GetSignatureForError()); } } private static bool CanConvertToIDisposable(BlockContext bc, TypeSpec type) { BuiltinTypeSpec iDisposable = bc.BuiltinTypes.IDisposable; if (type is TypeParameterSpec expr_type) { return Convert.ImplicitTypeParameterConversion(null, expr_type, iDisposable) != null; } return type.ImplementsInterface(iDisposable, variantly: false); } protected virtual Statement CreateDisposeCall(BlockContext bc, LocalVariable lv) { Expression expression = lv.CreateReferenceExpression(bc, lv.Location); TypeSpec typeSpec = lv.Type; Location location = lv.Location; BuiltinTypeSpec iDisposable = bc.BuiltinTypes.IDisposable; MethodSpec best = bc.Module.PredefinedMembers.IDisposableDispose.Resolve(location); MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(best, iDisposable, location); methodGroupExpr.InstanceExpression = (typeSpec.IsNullableType ? new Cast(new TypeExpression(iDisposable, location), expression, location).Resolve(bc) : expression); Statement statement = new StatementExpression(new Invocation(methodGroupExpr, null), Location.Null); if (!TypeSpec.IsValueType(typeSpec) || typeSpec.IsNullableType) { statement = new If(new Binary(Binary.Operator.Inequality, expression, new NullLiteral(location)), statement, statement.loc); } return statement; } public void ResolveDeclaratorInitializer(BlockContext bc) { base.Initializer = base.ResolveInitializer(bc, base.Variable, base.Initializer); } public Statement RewriteUsingDeclarators(BlockContext bc, Statement stmt) { for (int num = declarators.Count - 1; num >= 0; num--) { BlockVariableDeclarator blockVariableDeclarator = declarators[num]; VariableDeclaration variableDeclaration = new VariableDeclaration(blockVariableDeclarator.Variable, blockVariableDeclarator.Variable.Location); variableDeclaration.Initializer = blockVariableDeclarator.Initializer; variableDeclaration.IsNested = true; variableDeclaration.dispose_call = CreateDisposeCall(bc, blockVariableDeclarator.Variable); variableDeclaration.dispose_call.Resolve(bc); stmt = new Using(variableDeclaration, stmt, blockVariableDeclarator.Variable.Location); } declarators = null; return stmt; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } private VariableDeclaration decl; public Expression Expr => (decl.Variable == null) ? decl.Initializer : null; public BlockVariable Variables => decl; public Using(VariableDeclaration decl, Statement stmt, Location loc) : base(stmt, loc) { this.decl = decl; } public Using(Expression expr, Statement stmt, Location loc) : base(stmt, loc) { decl = new VariableDeclaration(expr); } public override void Emit(EmitContext ec) { DoEmit(ec); } protected override void EmitTryBodyPrepare(EmitContext ec) { decl.Emit(ec); base.EmitTryBodyPrepare(ec); } protected override void EmitTryBody(EmitContext ec) { stmt.Emit(ec); } public override void EmitFinallyBody(EmitContext ec) { decl.EmitDispose(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { decl.FlowAnalysis(fc); return stmt.FlowAnalysis(fc); } public override Reachability MarkReachable(Reachability rc) { decl.MarkReachable(rc); return base.MarkReachable(rc); } public override bool Resolve(BlockContext ec) { bool isLockedByStatement = false; VariableReference variableReference; using (ec.Set(ResolveContext.Options.UsingInitializerScope)) { if (decl.Variable == null) { variableReference = decl.ResolveExpression(ec) as VariableReference; if (variableReference != null) { isLockedByStatement = variableReference.IsLockedByStatement; variableReference.IsLockedByStatement = true; } } else { if (decl.IsNested) { decl.ResolveDeclaratorInitializer(ec); } else { if (!decl.Resolve(ec)) { return false; } if (decl.Declarators != null) { stmt = decl.RewriteUsingDeclarators(ec, stmt); } } variableReference = null; } } bool result = base.Resolve(ec); if (variableReference != null) { variableReference.IsLockedByStatement = isLockedByStatement; } return result; } protected override void CloneTo(CloneContext clonectx, Statement t) { Using obj = (Using)t; obj.decl = (VariableDeclaration)decl.Clone(clonectx); obj.stmt = stmt.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Foreach : LoopStatement { private abstract class IteratorStatement : Statement { protected readonly Foreach for_each; protected IteratorStatement(Foreach @foreach) { for_each = @foreach; loc = @foreach.expr.Location; } protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotImplementedException(); } public override void Emit(EmitContext ec) { if (ec.EmitAccurateDebugInfo) { ec.Emit(OpCodes.Nop); } base.Emit(ec); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { throw new NotImplementedException(); } } private sealed class ArrayForeach : IteratorStatement { private TemporaryVariableReference[] lengths; private Expression[] length_exprs; private StatementExpression[] counter; private TemporaryVariableReference[] variables; private TemporaryVariableReference copy; public ArrayForeach(Foreach @foreach, int rank) : base(@foreach) { counter = new StatementExpression[rank]; variables = new TemporaryVariableReference[rank]; length_exprs = new Expression[rank]; if (rank > 1) { lengths = new TemporaryVariableReference[rank]; } } public override bool Resolve(BlockContext ec) { Block block = for_each.variable.Block; copy = TemporaryVariableReference.Create(for_each.expr.Type, block, loc); copy.Resolve(ec); int num = length_exprs.Length; Arguments arguments = new Arguments(num); for (int i = 0; i < num; i++) { TemporaryVariableReference temporaryVariableReference = TemporaryVariableReference.Create(ec.BuiltinTypes.Int, block, loc); variables[i] = temporaryVariableReference; counter[i] = new StatementExpression(new UnaryMutator(UnaryMutator.Mode.IsPost, temporaryVariableReference, Location.Null)); counter[i].Resolve(ec); if (num == 1) { length_exprs[i] = new MemberAccess(copy, "Length").Resolve(ec); } else { lengths[i] = TemporaryVariableReference.Create(ec.BuiltinTypes.Int, block, loc); lengths[i].Resolve(ec); Arguments arguments2 = new Arguments(1); arguments2.Add(new Argument(new IntConstant(ec.BuiltinTypes, i, loc))); length_exprs[i] = new Invocation(new MemberAccess(copy, "GetLength"), arguments2).Resolve(ec); } arguments.Add(new Argument(temporaryVariableReference)); } Expression expression = new ElementAccess(copy, arguments, loc).Resolve(ec); if (expression == null) { return false; } TypeSpec typeSpec; if (for_each.type is VarExpr) { typeSpec = expression.Type; } else { typeSpec = for_each.type.ResolveAsType(ec); if (typeSpec == null) { return false; } expression = Convert.ExplicitConversion(ec, expression, typeSpec, loc); if (expression == null) { return false; } } for_each.variable.Type = typeSpec; Block currentBlock = ec.CurrentBlock; ec.CurrentBlock = block; Expression expression2 = new LocalVariableReference(for_each.variable, loc).Resolve(ec); ec.CurrentBlock = currentBlock; if (expression2 == null) { return false; } for_each.body.AddScopeStatement(new StatementExpression(new CompilerAssign(expression2, expression, Location.Null), for_each.type.Location)); return for_each.body.Resolve(ec); } protected override void DoEmit(EmitContext ec) { copy.EmitAssign(ec, for_each.expr); int num = length_exprs.Length; Label[] array = new Label[num]; Label[] array2 = new Label[num]; for (int i = 0; i < num; i++) { array[i] = ec.DefineLabel(); array2[i] = ec.DefineLabel(); if (lengths != null) { lengths[i].EmitAssign(ec, length_exprs[i]); } } IntConstant source = new IntConstant(ec.BuiltinTypes, 0, loc); for (int j = 0; j < num; j++) { variables[j].EmitAssign(ec, source); ec.Emit(OpCodes.Br, array[j]); ec.MarkLabel(array2[j]); } for_each.body.Emit(ec); ec.MarkLabel(ec.LoopBegin); ec.Mark(for_each.expr.Location); for (int num2 = num - 1; num2 >= 0; num2--) { counter[num2].Emit(ec); ec.MarkLabel(array[num2]); variables[num2].Emit(ec); if (lengths != null) { lengths[num2].Emit(ec); } else { length_exprs[num2].Emit(ec); } ec.Emit(OpCodes.Blt, array2[num2]); } ec.MarkLabel(ec.LoopEnd); } } private sealed class CollectionForeach : IteratorStatement, OverloadResolver.IErrorHandler { private class RuntimeDispose : Using.VariableDeclaration { public RuntimeDispose(LocalVariable lv, Location loc) : base(lv, loc) { reachable = true; } protected override void CheckIDiposableConversion(BlockContext bc, LocalVariable li, Expression initializer) { } protected override Statement CreateDisposeCall(BlockContext bc, LocalVariable lv) { BuiltinTypeSpec iDisposable = bc.BuiltinTypes.IDisposable; LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(iDisposable, bc.CurrentBlock, loc); Binary bool_expr = new Binary(Binary.Operator.Inequality, new CompilerAssign(localVariable.CreateReferenceExpression(bc, loc), new As(lv.CreateReferenceExpression(bc, loc), new TypeExpression(localVariable.Type, loc), loc), loc), new NullLiteral(loc)); MethodSpec best = bc.Module.PredefinedMembers.IDisposableDispose.Resolve(loc); MethodGroupExpr methodGroupExpr = MethodGroupExpr.CreatePredefined(best, iDisposable, loc); methodGroupExpr.InstanceExpression = localVariable.CreateReferenceExpression(bc, loc); Statement true_statement = new StatementExpression(new Invocation(methodGroupExpr, null)); return new If(bool_expr, true_statement, loc); } } private LocalVariable variable; private Expression expr; private Statement statement; private ExpressionStatement init; private TemporaryVariableReference enumerator_variable; private bool ambiguous_getenumerator_name; public CollectionForeach(Foreach @foreach, LocalVariable var, Expression expr) : base(@foreach) { variable = var; this.expr = expr; } private void Error_WrongEnumerator(ResolveContext rc, MethodSpec enumerator) { rc.Report.SymbolRelatedToPreviousError(enumerator); rc.Report.Error(202, loc, "foreach statement requires that the return type `{0}' of `{1}' must have a suitable public MoveNext method and public Current property", enumerator.ReturnType.GetSignatureForError(), enumerator.GetSignatureForError()); } private MethodGroupExpr ResolveGetEnumerator(ResolveContext rc) { Expression expression = Expression.MemberLookup(rc, errorMode: false, expr.Type, "GetEnumerator", 0, Expression.MemberLookupRestrictions.ExactArity, loc); MethodGroupExpr methodGroupExpr2; if (expression is MethodGroupExpr methodGroupExpr) { methodGroupExpr.InstanceExpression = expr; Arguments args = new Arguments(0); methodGroupExpr2 = methodGroupExpr.OverloadResolve(rc, ref args, this, OverloadResolver.Restrictions.ProbingOnly | OverloadResolver.Restrictions.GetEnumeratorLookup); if (ambiguous_getenumerator_name) { methodGroupExpr2 = null; } if (methodGroupExpr2 != null && !methodGroupExpr2.BestCandidate.IsStatic && methodGroupExpr2.BestCandidate.IsPublic) { return methodGroupExpr2; } } TypeSpec type = expr.Type; PredefinedMember predefinedMember = null; PredefinedTypes predefinedTypes = rc.Module.PredefinedTypes; PredefinedType predefinedType = predefinedTypes.IEnumerableGeneric; if (!predefinedType.Define()) { predefinedType = null; } IList interfaces = type.Interfaces; if (interfaces != null) { foreach (TypeSpec item in interfaces) { if (predefinedType != null && item.MemberDefinition == predefinedType.TypeSpec.MemberDefinition) { if (predefinedMember != null && predefinedMember != rc.Module.PredefinedMembers.IEnumerableGetEnumerator) { rc.Report.SymbolRelatedToPreviousError(expr.Type); rc.Report.Error(1640, loc, "foreach statement cannot operate on variables of type `{0}' because it contains multiple implementation of `{1}'. Try casting to a specific implementation", expr.Type.GetSignatureForError(), predefinedType.TypeSpec.GetSignatureForError()); return null; } predefinedMember = new PredefinedMember(rc.Module, item, MemberFilter.Method("GetEnumerator", 0, ParametersCompiled.EmptyReadOnlyParameters, null)); } else if (item.BuiltinType == BuiltinTypeSpec.Type.IEnumerable && predefinedMember == null) { predefinedMember = rc.Module.PredefinedMembers.IEnumerableGetEnumerator; } } } if (predefinedMember == null) { if (expr.Type == InternalType.DefaultType) { rc.Report.Error(8312, loc, "Use of default literal is not valid in this context"); } else if (expr.Type != InternalType.ErrorType) { rc.Report.Error(1579, loc, "foreach statement cannot operate on variables of type `{0}' because it does not contain a definition for `{1}' or is inaccessible", expr.Type.GetSignatureForError(), "GetEnumerator"); } return null; } MethodSpec methodSpec = predefinedMember.Resolve(loc); if (methodSpec == null) { return null; } methodGroupExpr2 = MethodGroupExpr.CreatePredefined(methodSpec, expr.Type, loc); methodGroupExpr2.InstanceExpression = expr; return methodGroupExpr2; } private MethodGroupExpr ResolveMoveNext(ResolveContext rc, MethodSpec enumerator) { if (!(MemberCache.FindMember(enumerator.ReturnType, MemberFilter.Method("MoveNext", 0, ParametersCompiled.EmptyReadOnlyParameters, rc.BuiltinTypes.Bool), BindingRestriction.InstanceOnly) is MethodSpec { IsPublic: not false } methodSpec)) { Error_WrongEnumerator(rc, enumerator); return null; } return MethodGroupExpr.CreatePredefined(methodSpec, enumerator.ReturnType, expr.Location); } private PropertySpec ResolveCurrent(ResolveContext rc, MethodSpec enumerator) { if (!(MemberCache.FindMember(enumerator.ReturnType, MemberFilter.Property("Current", null), BindingRestriction.InstanceOnly) is PropertySpec { IsPublic: not false } propertySpec)) { Error_WrongEnumerator(rc, enumerator); return null; } return propertySpec; } public override bool Resolve(BlockContext ec) { bool flag = expr.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; if (flag) { expr = Convert.ImplicitConversionRequired(ec, expr, ec.BuiltinTypes.IEnumerable, loc); } else if (expr.Type.IsNullableType) { expr = new UnwrapCall(expr).Resolve(ec); } MethodGroupExpr methodGroupExpr = ResolveGetEnumerator(ec); if (methodGroupExpr == null) { return false; } MethodSpec bestCandidate = methodGroupExpr.BestCandidate; enumerator_variable = TemporaryVariableReference.Create(bestCandidate.ReturnType, variable.Block, loc); enumerator_variable.Resolve(ec); MethodGroupExpr methodGroupExpr2 = ResolveMoveNext(ec, bestCandidate); if (methodGroupExpr2 == null) { return false; } methodGroupExpr2.InstanceExpression = enumerator_variable; PropertySpec propertySpec = ResolveCurrent(ec, bestCandidate); if (propertySpec == null) { return false; } Expression expression = new PropertyExpr(propertySpec, loc) { InstanceExpression = enumerator_variable }.Resolve(ec); if (expression == null) { return false; } if (for_each.type is VarExpr) { if (flag) { variable.Type = ec.BuiltinTypes.Dynamic; } else { variable.Type = expression.Type; } } else { if (flag) { expression = EmptyCast.Create(expression, ec.BuiltinTypes.Dynamic); } variable.Type = for_each.type.ResolveAsType(ec); if (variable.Type == null) { return false; } expression = Convert.ExplicitConversion(ec, expression, variable.Type, loc); if (expression == null) { return false; } } Block currentBlock = ec.CurrentBlock; ec.CurrentBlock = for_each.variable.Block; Expression expression2 = new LocalVariableReference(variable, loc).Resolve(ec); ec.CurrentBlock = currentBlock; if (expression2 == null) { return false; } for_each.body.AddScopeStatement(new StatementExpression(new CompilerAssign(expression2, expression, Location.Null), for_each.type.Location)); Invocation.Predefined predefined = new Invocation.Predefined(methodGroupExpr, null); statement = new While(new BooleanExpression(new Invocation(methodGroupExpr2, null)), for_each.body, Location.Null); TypeSpec type = enumerator_variable.Type; if (!type.ImplementsInterface(ec.BuiltinTypes.IDisposable, variantly: false)) { if (!type.IsSealed && !TypeSpec.IsValueType(type)) { RuntimeDispose runtimeDispose = new RuntimeDispose(enumerator_variable.LocalInfo, Location.Null); runtimeDispose.Initializer = predefined; statement = new Using(runtimeDispose, statement, Location.Null); } else { init = new SimpleAssign(enumerator_variable, predefined, Location.Null); init.Resolve(ec); } } else { Using.VariableDeclaration variableDeclaration = new Using.VariableDeclaration(enumerator_variable.LocalInfo, Location.Null); variableDeclaration.Initializer = predefined; statement = new Using(variableDeclaration, statement, Location.Null); } return statement.Resolve(ec); } protected override void DoEmit(EmitContext ec) { enumerator_variable.LocalInfo.CreateBuilder(ec); if (init != null) { init.EmitStatement(ec); } statement.Emit(ec); } bool OverloadResolver.IErrorHandler.AmbiguousCandidates(ResolveContext ec, MemberSpec best, MemberSpec ambiguous) { ec.Report.SymbolRelatedToPreviousError(best); ec.Report.Warning(278, 2, expr.Location, "`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is ambiguous with method `{3}'", expr.Type.GetSignatureForError(), "enumerable", best.GetSignatureForError(), ambiguous.GetSignatureForError()); ambiguous_getenumerator_name = true; return true; } bool OverloadResolver.IErrorHandler.ArgumentMismatch(ResolveContext rc, MemberSpec best, Argument arg, int index) { return false; } bool OverloadResolver.IErrorHandler.NoArgumentMatch(ResolveContext rc, MemberSpec best) { return false; } bool OverloadResolver.IErrorHandler.TypeInferenceFailed(ResolveContext rc, MemberSpec best) { return false; } } private Expression type; private LocalVariable variable; private Expression expr; private Block body; public Expression Expr => expr; public Expression TypeExpression => type; public LocalVariable Variable => variable; public Foreach(Expression type, LocalVariable var, Expression expr, Statement stmt, Block body, Location l) : base(stmt) { this.type = type; variable = var; this.expr = expr; this.body = body; loc = l; } public override Reachability MarkReachable(Reachability rc) { base.MarkReachable(rc); body.MarkReachable(rc); return rc; } public override bool Resolve(BlockContext ec) { expr = expr.Resolve(ec); if (expr == null) { return false; } if (expr.IsNull) { ec.Report.Error(186, loc, "Use of null is not valid in this context"); return false; } body.AddStatement(base.Statement); if (expr.Type.BuiltinType == BuiltinTypeSpec.Type.String) { base.Statement = new ArrayForeach(this, 1); } else if (expr.Type is ArrayContainer) { base.Statement = new ArrayForeach(this, ((ArrayContainer)expr.Type).Rank); } else { if (expr.eclass == ExprClass.MethodGroup || expr is AnonymousMethodExpression) { ec.Report.Error(446, expr.Location, "Foreach statement cannot operate on a `{0}'", expr.ExprClassName); return false; } base.Statement = new CollectionForeach(this, variable, expr); } return base.Resolve(ec); } protected override void DoEmit(EmitContext ec) { Label loopBegin = ec.LoopBegin; Label loopEnd = ec.LoopEnd; ec.LoopBegin = ec.DefineLabel(); ec.LoopEnd = ec.DefineLabel(); ec.BeginCompilerScope(variable.Block.Explicit.GetDebugSymbolScopeIndex()); body.Explicit.DisableDebugScopeIndex(); variable.CreateBuilder(ec); base.Statement.Emit(ec); ec.EndScope(); ec.LoopBegin = loopBegin; ec.LoopEnd = loopEnd; } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); DefiniteAssignmentBitSet definiteAssignment = fc.BranchDefiniteAssignment(); body.FlowAnalysis(fc); fc.DefiniteAssignment = definiteAssignment; return false; } protected override void CloneTo(CloneContext clonectx, Statement t) { Foreach obj = (Foreach)t; obj.type = type.Clone(clonectx); obj.expr = expr.Clone(clonectx); obj.body = (Block)body.Clone(clonectx); obj.Statement = base.Statement.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class SentinelStatement : Statement { protected override void CloneTo(CloneContext clonectx, Statement target) { } protected override void DoEmit(EmitContext ec) { Label label = ec.DefineLabel(); ec.MarkLabel(label); ec.Emit(OpCodes.Br_S, label); } protected override bool DoFlowAnalysis(FlowAnalysisContext fc) { throw new NotImplementedException(); } } internal sealed class ReferenceEquality : IEqualityComparer where T : class { public static readonly IEqualityComparer Default = new ReferenceEquality(); private ReferenceEquality() { } public bool Equals(T x, T y) { return x == y; } public int GetHashCode(T obj) { return RuntimeHelpers.GetHashCode(obj); } } internal static class ArrayComparer { public static bool IsEqual(T[] array1, T[] array2) { if (array1 == null || array2 == null) { return array1 == array2; } EqualityComparer equalityComparer = EqualityComparer.Default; for (int i = 0; i < array1.Length; i++) { if (!equalityComparer.Equals(array1[i], array2[i])) { return false; } } return true; } } internal class SeekableStreamReader : IDisposable { public const int DefaultReadAheadSize = 2048; private StreamReader reader; public readonly Stream Stream; private char[] buffer; private int read_ahead_length; private int buffer_start; private int char_count; private int pos; public int Position { get { return buffer_start + pos; } set { if (value < buffer_start) { InitializeStream(read_ahead_length); reader = new StreamReader(Stream, reader.CurrentEncoding, detectEncodingFromByteOrderMarks: true); } while (value > buffer_start + char_count) { pos = char_count; if (!ReadBuffer()) { throw new InternalErrorException("Seek beyond end of file: " + (buffer_start + char_count - value)); } } pos = value - buffer_start; } } public SeekableStreamReader(Stream stream, Encoding encoding, char[] sharedBuffer = null) { Stream = stream; buffer = sharedBuffer; InitializeStream(2048); reader = new StreamReader(stream, encoding, detectEncodingFromByteOrderMarks: true); } public void Dispose() { reader.Dispose(); } private void InitializeStream(int read_length_inc) { read_ahead_length += read_length_inc; int num = read_ahead_length * 2; if (buffer == null || buffer.Length < num) { buffer = new char[num]; } Stream.Position = 0L; buffer_start = (char_count = (pos = 0)); } private bool ReadBuffer() { int num = buffer.Length - char_count; if (num <= read_ahead_length) { int num2 = read_ahead_length - num; Array.Copy(buffer, num2, buffer, 0, char_count - num2); pos -= num2; char_count -= num2; buffer_start += num2; num += num2; } char_count += reader.Read(buffer, char_count, num); return pos < char_count; } public char[] ReadChars(int fromPosition, int toPosition) { char[] array = new char[toPosition - fromPosition]; if (buffer_start <= fromPosition && toPosition <= buffer_start + buffer.Length) { Array.Copy(buffer, fromPosition - buffer_start, array, 0, array.Length); return array; } throw new NotImplementedException(); } public int Peek() { if (pos >= char_count && !ReadBuffer()) { return -1; } return buffer[pos]; } public int Read() { if (pos >= char_count && !ReadBuffer()) { return -1; } return buffer[pos++]; } } internal class UnixUtils { [DllImport("libc", EntryPoint = "isatty")] private static extern int _isatty(int fd); public static bool isatty(int fd) { try { return _isatty(fd) == 1; } catch { return false; } } } internal class CompletionResult : Exception { private string[] result; private string base_text; public string[] Result => result; public string BaseText => base_text; public CompletionResult(string base_text, string[] res) { if (base_text == null) { throw new ArgumentNullException("base_text"); } this.base_text = base_text; result = res; Array.Sort(result); } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct TypeNameParser { internal static string Escape(string name) { if (name == null) { return null; } StringBuilder stringBuilder = null; for (int i = 0; i < name.Length; i++) { char c = name[i]; switch (c) { case '&': case '*': case '+': case ',': case '[': case '\\': case ']': if (stringBuilder == null) { stringBuilder = new StringBuilder(name, 0, i, name.Length + 3); } stringBuilder.Append("\\").Append(c); break; default: stringBuilder?.Append(c); break; } } return (stringBuilder != null) ? stringBuilder.ToString() : name; } } internal class TupleTypeExpr : TypeExpr { private TypeArguments elements; private List names; public TupleTypeExpr(TypeArguments elements, List names, Location loc) { this.elements = elements; this.names = names; base.loc = loc; } public override TypeSpec ResolveAsType(IMemberContext mc, bool allowUnboundTypeArguments = false) { int count = elements.Count; if (count > 7) { throw new NotImplementedException("tuples > 7"); } eclass = ExprClass.Type; TypeSpec typeSpec = mc.Module.PredefinedTypes.Tuples[count - 1].Resolve(); if (typeSpec == null) { return null; } GenericTypeExpr genericTypeExpr = new GenericTypeExpr(typeSpec, elements, loc); type = genericTypeExpr.ResolveAsType(mc); if (names != null && CheckElementNames(mc) && type != null) { type = NamedTupleSpec.MakeType(mc.Module, (InflatedTypeSpec)type, names); } return type; } private bool CheckElementNames(IMemberContext mc) { int num = -1; for (int i = 0; i < names.Count; i++) { string text = names[i]; if (text == null) { continue; } if (IsReservedName(text)) { mc.Module.Compiler.Report.Error(8126, loc, "The tuple element name `{0}' is reserved", text); names[i] = null; continue; } if (text.StartsWith("Item", StringComparison.Ordinal)) { string text2 = text.Substring(4); if (uint.TryParse(text2, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && result != i + 1) { mc.Module.Compiler.Report.Error(8125, loc, "The tuple element name `{0}' can only be used at position {1}", text, text2); names[i] = null; continue; } } if (num < 0) { num = i; continue; } for (int j = num; j < i; j++) { if (text == names[j]) { mc.Module.Compiler.Report.Error(8127, loc, "The tuple element name `{0}' is a duplicate", text); names[i] = null; break; } } } return num >= 0; } private static bool IsReservedName(string name) { switch (name) { case "CompareTo": case "Deconstruct": case "Equals": case "GetHashCode": case "Rest": case "ToString": return true; default: return false; } } public override string GetSignatureForError() { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < elements.Count; i++) { stringBuilder.Append(elements.Arguments[i].GetSignatureForError()); if (names[i] != null) { stringBuilder.Append(" "); stringBuilder.Append(names[i]); } if (i != 0) { stringBuilder.Append(","); } } return stringBuilder.ToString(); } } internal class NamedTupleSpec : TypeSpec { private InflatedTypeSpec tuple; private IList elements; public IList Elements => elements; public override TypeSpec[] TypeArguments => tuple.TypeArguments; private NamedTupleSpec(InflatedTypeSpec tupleDefinition, IList elements) : base(tupleDefinition.Kind, tupleDefinition.DeclaringType, tupleDefinition.MemberDefinition, null, tupleDefinition.Modifiers) { tuple = tupleDefinition; this.elements = elements; state |= StateFlags.HasNamedTupleElement | StateFlags.Tuple; } protected override void InitializeMemberCache(bool onlyTypes) { cache = tuple.MemberCache; } public override Type GetMetaInfo() { return tuple.GetMetaInfo(); } public MemberSpec FindElement(IMemberContext mc, string name, Location loc) { for (int i = 0; i < elements.Count; i++) { string text = elements[i]; if (text != null && !(text != name)) { string elementPropertyName = GetElementPropertyName(i); MemberSpec memberSpec = MemberCache.FindMember(tuple, MemberFilter.Field(elementPropertyName, null), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly); if (memberSpec == null) { mc.Module.Compiler.Report.Error(8128, loc, "Member `{0}' was not found on type '{1}'", elementPropertyName, tuple.GetSignatureForError()); return null; } return memberSpec; } } return null; } public override string GetSignatureForError() { return tuple.GetSignatureForError(); } public string GetSignatureForErrorWithNames() { return tuple.GetSignatureForError(); } public static NamedTupleSpec MakeType(ModuleContainer module, InflatedTypeSpec tupleType, IList names) { return new NamedTupleSpec(tupleType, names); } public static string GetElementPropertyName(int index) { return "Item" + (index + 1).ToString(CultureInfo.InvariantCulture); } public static bool CheckOverrideName(IParametersMember member, IParametersMember baseMember) { TypeSpec[] types = baseMember.Parameters.Types; TypeSpec[] types2 = member.Parameters.Types; for (int i = 0; i < baseMember.Parameters.Count; i++) { if (!CheckOverrideName(types2[i], types[i])) { return false; } } return true; } public static bool CheckOverrideName(TypeSpec type, TypeSpec baseType) { NamedTupleSpec namedTupleSpec = baseType as NamedTupleSpec; NamedTupleSpec namedTupleSpec2 = type as NamedTupleSpec; if (namedTupleSpec == null && namedTupleSpec2 == null) { return true; } if (namedTupleSpec == null || namedTupleSpec2 == null) { return false; } IList list = namedTupleSpec.elements; IList list2 = namedTupleSpec2.elements; for (int i = 0; i < list.Count; i++) { if (list[i] != list2[i]) { return false; } } return true; } } internal class TupleLiteralElement { public string Name { get; private set; } public Expression Expr { get; set; } public Location Location { get; private set; } public TupleLiteralElement(string name, Expression expr, Location loc) { Name = name; Expr = expr; Location = loc; } public TupleLiteralElement(Expression expr) { Expr = expr; Location = expr.Location; } public TupleLiteralElement Clone(CloneContext clonectx) { return new TupleLiteralElement(Name, Expr.Clone(clonectx), Location); } } internal sealed class TupleLiteral : Expression { private List elements; public List Elements => elements; public TupleLiteral(List elements, Location loc) { this.elements = elements; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression t) { List list = new List(elements.Count); foreach (TupleLiteralElement element in elements) { list.Add(element.Clone(clonectx)); } TupleLiteral tupleLiteral = (TupleLiteral)t; tupleLiteral.elements = list; } public static bool ContainsNoTypeElement(TypeSpec type) { TypeSpec[] typeArguments = type.TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (InternalType.HasNoType(typeSpec)) { return true; } if (typeSpec.IsTupleType && ContainsNoTypeElement(typeSpec)) { return true; } } return false; } public override Expression CreateExpressionTree(ResolveContext rc) { rc.Report.Error(8143, loc, "An expression tree cannot contain a tuple literal"); return ErrorExpression.Instance; } protected override Expression DoResolve(ResolveContext rc) { TypeArguments typeArguments = new TypeArguments(); List list = null; for (int i = 0; i < elements.Count; i++) { TupleLiteralElement tupleLiteralElement = elements[i]; Expression expression = tupleLiteralElement.Expr.Resolve(rc); if (expression == null) { tupleLiteralElement.Expr = null; typeArguments = null; continue; } if (expression.Type.Kind == MemberKind.Void) { rc.Report.Error(8210, expression.Location, "A tuple literal cannot not contain a value of type `{0}'", expression.Type.GetSignatureForError()); expression = null; typeArguments = null; continue; } if (tupleLiteralElement.Name != null) { if (list == null) { list = new List(); for (int j = 0; j < i; j++) { list.Add(null); } } list.Add(tupleLiteralElement.Name); } tupleLiteralElement.Expr = expression; typeArguments?.Add(new TypeExpression(expression.Type, expression.Location)); } eclass = ExprClass.Value; if (typeArguments == null) { return null; } TupleTypeExpr tupleTypeExpr = new TupleTypeExpr(typeArguments, list, loc); type = tupleTypeExpr.ResolveAsType(rc) ?? InternalType.ErrorType; return this; } public override void Emit(EmitContext ec) { foreach (TupleLiteralElement element in elements) { element.Expr.Emit(ec); } MethodSpec method = MemberCache.FindMember(type, MemberFilter.Constructor(null), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly) as MethodSpec; ec.Emit(OpCodes.Newobj, method); } public override void Error_ValueCannotBeConverted(ResolveContext rc, TypeSpec target, bool expl) { rc.Report.Error(8135, base.Location, "Tuple literal `{0}' cannot be converted to type `{1}'", type.GetSignatureForError(), target.GetSignatureForError()); } } internal class TupleLiteralConversion : Expression { private List elements; private Expression source; public TupleLiteralConversion(Expression source, TypeSpec type, List elements, Location loc) { this.source = source; base.type = type; this.elements = elements; base.loc = loc; eclass = source.eclass; } public override Expression CreateExpressionTree(ResolveContext rc) { rc.Report.Error(8144, loc, "An expression tree cannot contain a tuple conversion"); return null; } protected override Expression DoResolve(ResolveContext rc) { throw new NotSupportedException(); } public override void Emit(EmitContext ec) { if (!(source is TupleLiteral)) { if (source is CompilerAssign compilerAssign) { compilerAssign.EmitStatement(ec); } else { source.Emit(ec); } } foreach (Expression element in elements) { element.Emit(ec); } MethodSpec method = MemberCache.FindMember(type, MemberFilter.Constructor(null), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly) as MethodSpec; ec.Emit(OpCodes.Newobj, method); } } internal class TupleDeconstruct : ExpressionStatement, IAssignMethod { private Expression source; private List targetExprs; private List variables; private Expression instance; public TupleDeconstruct(List targetExprs, Expression source, Location loc) { this.source = source; this.targetExprs = targetExprs; base.loc = loc; } public TupleDeconstruct(List variables, Expression source, Location loc) { this.source = source; this.variables = variables; base.loc = loc; } public override Expression CreateExpressionTree(ResolveContext ec) { ec.Report.Error(832, loc, "An expression tree cannot contain an assignment operator"); throw new NotImplementedException(); } protected override Expression DoResolve(ResolveContext rc) { Expression expression = source.Resolve(rc); if (expression == null) { return null; } if (InternalType.HasNoType(expression.Type)) { rc.Report.Error(8131, source.Location, "Deconstruct assignment requires an expression with a type on the right-hand-side"); return null; } TypeSpec typeSpec = expression.Type; if (typeSpec.IsTupleType) { int count; if (targetExprs == null) { count = variables.Count; targetExprs = new List(count); } else { count = targetExprs.Count; } if (typeSpec.Arity != count) { rc.Report.Error(8132, loc, "Cannot deconstruct a tuple of `{0}' elements into `{1}' variables", typeSpec.Arity.ToString(CultureInfo.InvariantCulture), count.ToString(CultureInfo.InvariantCulture)); return null; } TupleLiteral tupleLiteral = expression as TupleLiteral; if (tupleLiteral == null && !ExpressionAnalyzer.IsInexpensiveLoad(expression)) { LocalVariable localVariable = LocalVariable.CreateCompilerGenerated(source.Type, rc.CurrentBlock, loc); source = new CompilerAssign(localVariable.CreateReferenceExpression(rc, loc), source, loc); instance = localVariable.CreateReferenceExpression(rc, loc); } for (int i = 0; i < count; i++) { TypeSpec typeSpec2 = typeSpec.TypeArguments[i]; if (variables != null) { LocalVariable variable = variables[i].Variable; if (variable.Type == InternalType.Discard) { variables[i] = null; targetExprs.Add(EmptyExpressionStatement.Instance); continue; } FullNamedExpression typeExpression = variables[i].TypeExpression; targetExprs.Add(new LocalVariableReference(variable, variable.Location)); if (typeExpression is VarExpr) { if (InternalType.HasNoType(typeSpec2)) { rc.Report.Error(8130, base.Location, "Cannot infer the type of implicitly-typed deconstruction variable `{0}'", variable.Name); typeSpec2 = InternalType.ErrorType; } variable.Type = typeSpec2; } else { variable.Type = typeExpression.ResolveAsType(rc); } variable.PrepareAssignmentAnalysis((BlockContext)rc); } Expression expression2 = ((tupleLiteral == null) ? new MemberAccess(instance, NamedTupleSpec.GetElementPropertyName(i)) : tupleLiteral.Elements[i].Expr); targetExprs[i] = new SimpleAssign(targetExprs[i], expression2).Resolve(rc); } eclass = ExprClass.Value; type = expression.Type; return this; } if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { rc.Report.Error(8133, loc, "Cannot deconstruct dynamic objects"); return null; } throw new NotImplementedException("Custom deconstruct"); } public override void Emit(EmitContext ec) { if (instance != null) { ((ExpressionStatement)source).EmitStatement(ec); } foreach (ExpressionStatement targetExpr in targetExprs) { targetExpr.Emit(ec); } MethodSpec method = MemberCache.FindMember(type, MemberFilter.Constructor(null), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly) as MethodSpec; ec.Emit(OpCodes.Newobj, method); } public override void EmitStatement(EmitContext ec) { if (variables != null) { foreach (BlockVariable variable in variables) { variable?.Variable.CreateBuilder(ec); } } if (instance != null) { ((ExpressionStatement)source).EmitStatement(ec); } foreach (ExpressionStatement targetExpr in targetExprs) { targetExpr.EmitStatement(ec); } } public void Emit(EmitContext ec, bool leave_copy) { throw new NotImplementedException(); } public void EmitAssign(EmitContext ec, Expression source, bool leave_copy, bool isCompound) { if (leave_copy) { throw new NotImplementedException(); } EmitStatement(ec); } public override void FlowAnalysis(FlowAnalysisContext fc) { source.FlowAnalysis(fc); foreach (Expression targetExpr in targetExprs) { targetExpr.FlowAnalysis(fc); } } public void SetGeneratedFieldAssigned(FlowAnalysisContext fc) { if (variables == null) { return; } foreach (BlockVariable variable in variables) { fc.SetVariableAssigned(variable.Variable.VariableInfo); } } } internal class BuiltinTypes { public readonly BuiltinTypeSpec Object; public readonly BuiltinTypeSpec ValueType; public readonly BuiltinTypeSpec Attribute; public readonly BuiltinTypeSpec Int; public readonly BuiltinTypeSpec UInt; public readonly BuiltinTypeSpec Long; public readonly BuiltinTypeSpec ULong; public readonly BuiltinTypeSpec Float; public readonly BuiltinTypeSpec Double; public readonly BuiltinTypeSpec Char; public readonly BuiltinTypeSpec Short; public readonly BuiltinTypeSpec Decimal; public readonly BuiltinTypeSpec Bool; public readonly BuiltinTypeSpec SByte; public readonly BuiltinTypeSpec Byte; public readonly BuiltinTypeSpec UShort; public readonly BuiltinTypeSpec String; public readonly BuiltinTypeSpec Enum; public readonly BuiltinTypeSpec Delegate; public readonly BuiltinTypeSpec MulticastDelegate; public readonly BuiltinTypeSpec Void; public readonly BuiltinTypeSpec Array; public readonly BuiltinTypeSpec Type; public readonly BuiltinTypeSpec IEnumerator; public readonly BuiltinTypeSpec IEnumerable; public readonly BuiltinTypeSpec IDisposable; public readonly BuiltinTypeSpec IntPtr; public readonly BuiltinTypeSpec UIntPtr; public readonly BuiltinTypeSpec RuntimeFieldHandle; public readonly BuiltinTypeSpec RuntimeTypeHandle; public readonly BuiltinTypeSpec Exception; public readonly BuiltinTypeSpec Dynamic; public readonly Binary.PredefinedOperator[] OperatorsBinaryStandard; public readonly Binary.PredefinedOperator[] OperatorsBinaryEquality; public readonly Binary.PredefinedOperator[] OperatorsBinaryUnsafe; public readonly TypeSpec[][] OperatorsUnary; public readonly TypeSpec[] OperatorsUnaryMutator; public readonly TypeSpec[] BinaryPromotionsTypes; private readonly BuiltinTypeSpec[] types; public BuiltinTypeSpec[] AllTypes => types; public BuiltinTypes() { Object = new BuiltinTypeSpec(MemberKind.Class, "System", "Object", BuiltinTypeSpec.Type.Object); ValueType = new BuiltinTypeSpec(MemberKind.Class, "System", "ValueType", BuiltinTypeSpec.Type.ValueType); Attribute = new BuiltinTypeSpec(MemberKind.Class, "System", "Attribute", BuiltinTypeSpec.Type.Attribute); Int = new BuiltinTypeSpec(MemberKind.Struct, "System", "Int32", BuiltinTypeSpec.Type.Int); Long = new BuiltinTypeSpec(MemberKind.Struct, "System", "Int64", BuiltinTypeSpec.Type.Long); UInt = new BuiltinTypeSpec(MemberKind.Struct, "System", "UInt32", BuiltinTypeSpec.Type.UInt); ULong = new BuiltinTypeSpec(MemberKind.Struct, "System", "UInt64", BuiltinTypeSpec.Type.ULong); Byte = new BuiltinTypeSpec(MemberKind.Struct, "System", "Byte", BuiltinTypeSpec.Type.Byte); SByte = new BuiltinTypeSpec(MemberKind.Struct, "System", "SByte", BuiltinTypeSpec.Type.SByte); Short = new BuiltinTypeSpec(MemberKind.Struct, "System", "Int16", BuiltinTypeSpec.Type.Short); UShort = new BuiltinTypeSpec(MemberKind.Struct, "System", "UInt16", BuiltinTypeSpec.Type.UShort); IEnumerator = new BuiltinTypeSpec(MemberKind.Interface, "System.Collections", "IEnumerator", BuiltinTypeSpec.Type.IEnumerator); IEnumerable = new BuiltinTypeSpec(MemberKind.Interface, "System.Collections", "IEnumerable", BuiltinTypeSpec.Type.IEnumerable); IDisposable = new BuiltinTypeSpec(MemberKind.Interface, "System", "IDisposable", BuiltinTypeSpec.Type.IDisposable); Char = new BuiltinTypeSpec(MemberKind.Struct, "System", "Char", BuiltinTypeSpec.Type.Char); String = new BuiltinTypeSpec(MemberKind.Class, "System", "String", BuiltinTypeSpec.Type.String); Float = new BuiltinTypeSpec(MemberKind.Struct, "System", "Single", BuiltinTypeSpec.Type.Float); Double = new BuiltinTypeSpec(MemberKind.Struct, "System", "Double", BuiltinTypeSpec.Type.Double); Decimal = new BuiltinTypeSpec(MemberKind.Struct, "System", "Decimal", BuiltinTypeSpec.Type.Decimal); Bool = new BuiltinTypeSpec(MemberKind.Struct, "System", "Boolean", BuiltinTypeSpec.Type.FirstPrimitive); IntPtr = new BuiltinTypeSpec(MemberKind.Struct, "System", "IntPtr", BuiltinTypeSpec.Type.IntPtr); UIntPtr = new BuiltinTypeSpec(MemberKind.Struct, "System", "UIntPtr", BuiltinTypeSpec.Type.UIntPtr); MulticastDelegate = new BuiltinTypeSpec(MemberKind.Class, "System", "MulticastDelegate", BuiltinTypeSpec.Type.MulticastDelegate); Delegate = new BuiltinTypeSpec(MemberKind.Class, "System", "Delegate", BuiltinTypeSpec.Type.Delegate); Enum = new BuiltinTypeSpec(MemberKind.Class, "System", "Enum", BuiltinTypeSpec.Type.Enum); Array = new BuiltinTypeSpec(MemberKind.Class, "System", "Array", BuiltinTypeSpec.Type.Array); Void = new BuiltinTypeSpec(MemberKind.Void, "System", "Void", BuiltinTypeSpec.Type.Other); Type = new BuiltinTypeSpec(MemberKind.Class, "System", "Type", BuiltinTypeSpec.Type.Type); Exception = new BuiltinTypeSpec(MemberKind.Class, "System", "Exception", BuiltinTypeSpec.Type.Exception); RuntimeFieldHandle = new BuiltinTypeSpec(MemberKind.Struct, "System", "RuntimeFieldHandle", BuiltinTypeSpec.Type.Other); RuntimeTypeHandle = new BuiltinTypeSpec(MemberKind.Struct, "System", "RuntimeTypeHandle", BuiltinTypeSpec.Type.Other); Dynamic = new BuiltinTypeSpec("dynamic", BuiltinTypeSpec.Type.Dynamic); OperatorsBinaryStandard = Binary.CreateStandardOperatorsTable(this); OperatorsBinaryEquality = Binary.CreateEqualityOperatorsTable(this); OperatorsBinaryUnsafe = Binary.CreatePointerOperatorsTable(this); OperatorsUnary = Unary.CreatePredefinedOperatorsTable(this); OperatorsUnaryMutator = UnaryMutator.CreatePredefinedOperatorsTable(this); BinaryPromotionsTypes = ConstantFold.CreateBinaryPromotionsTypes(this); types = new BuiltinTypeSpec[31] { Object, ValueType, Attribute, Int, UInt, Long, ULong, Float, Double, Char, Short, Decimal, Bool, SByte, Byte, UShort, String, Enum, Delegate, MulticastDelegate, Void, Array, Type, IEnumerator, IEnumerable, IDisposable, IntPtr, UIntPtr, RuntimeFieldHandle, RuntimeTypeHandle, Exception }; } public bool CheckDefinitions(ModuleContainer module) { CompilerContext compiler = module.Compiler; BuiltinTypeSpec[] array = types; foreach (BuiltinTypeSpec builtinTypeSpec in array) { TypeSpec typeSpec = PredefinedType.Resolve(module, builtinTypeSpec.Kind, builtinTypeSpec.Namespace, builtinTypeSpec.Name, builtinTypeSpec.Arity, required: true, reportErrors: true); if (typeSpec != null && typeSpec != builtinTypeSpec && typeSpec.MemberDefinition is TypeDefinition typeDefinition) { Namespace obj = module.GlobalRootNamespace.GetNamespace(builtinTypeSpec.Namespace, create: false); obj.SetBuiltinType(builtinTypeSpec); typeDefinition.SetPredefinedSpec(builtinTypeSpec); builtinTypeSpec.SetDefinition(typeSpec); } } if (compiler.Report.Errors != 0) { return false; } Dynamic.SetDefinition(Object); return true; } } internal class PredefinedTypes { public readonly PredefinedType ArgIterator; public readonly PredefinedType TypedReference; public readonly PredefinedType MarshalByRefObject; public readonly PredefinedType RuntimeHelpers; public readonly PredefinedType IAsyncResult; public readonly PredefinedType AsyncCallback; public readonly PredefinedType RuntimeArgumentHandle; public readonly PredefinedType CharSet; public readonly PredefinedType IsVolatile; public readonly PredefinedType IEnumeratorGeneric; public readonly PredefinedType IListGeneric; public readonly PredefinedType IReadOnlyListGeneric; public readonly PredefinedType ICollectionGeneric; public readonly PredefinedType IReadOnlyCollectionGeneric; public readonly PredefinedType IEnumerableGeneric; public readonly PredefinedType Nullable; public readonly PredefinedType Activator; public readonly PredefinedType Interlocked; public readonly PredefinedType Monitor; public readonly PredefinedType NotSupportedException; public readonly PredefinedType RuntimeFieldHandle; public readonly PredefinedType RuntimeMethodHandle; public readonly PredefinedType SecurityAction; public readonly PredefinedType Dictionary; public readonly PredefinedType Hashtable; public readonly PredefinedType Array; public readonly TypeSpec[] SwitchUserTypes; public readonly PredefinedType Expression; public readonly PredefinedType ExpressionGeneric; public readonly PredefinedType ParameterExpression; public readonly PredefinedType FieldInfo; public readonly PredefinedType MethodBase; public readonly PredefinedType MethodInfo; public readonly PredefinedType ConstructorInfo; public readonly PredefinedType MemberBinding; public readonly PredefinedType Binder; public readonly PredefinedType CallSite; public readonly PredefinedType CallSiteGeneric; public readonly PredefinedType BinderFlags; public readonly PredefinedType AsyncVoidMethodBuilder; public readonly PredefinedType AsyncTaskMethodBuilder; public readonly PredefinedType AsyncTaskMethodBuilderGeneric; public readonly PredefinedType Action; public readonly PredefinedType Task; public readonly PredefinedType TaskGeneric; public readonly PredefinedType IAsyncStateMachine; public readonly PredefinedType INotifyCompletion; public readonly PredefinedType ICriticalNotifyCompletion; public readonly PredefinedType IFormattable; public readonly PredefinedType FormattableString; public readonly PredefinedType FormattableStringFactory; public readonly PredefinedType[] Tuples; public readonly PredefinedType SpanGeneric; public PredefinedTypes(ModuleContainer module) { TypedReference = new PredefinedType(module, MemberKind.Struct, "System", "TypedReference"); ArgIterator = new PredefinedType(module, MemberKind.Struct, "System", "ArgIterator"); MarshalByRefObject = new PredefinedType(module, MemberKind.Class, "System", "MarshalByRefObject"); RuntimeHelpers = new PredefinedType(module, MemberKind.Class, "System.Runtime.CompilerServices", "RuntimeHelpers"); IAsyncResult = new PredefinedType(module, MemberKind.Interface, "System", "IAsyncResult"); AsyncCallback = new PredefinedType(module, MemberKind.Delegate, "System", "AsyncCallback"); RuntimeArgumentHandle = new PredefinedType(module, MemberKind.Struct, "System", "RuntimeArgumentHandle"); CharSet = new PredefinedType(module, MemberKind.Enum, "System.Runtime.InteropServices", "CharSet"); IsVolatile = new PredefinedType(module, MemberKind.Class, "System.Runtime.CompilerServices", "IsVolatile"); IEnumeratorGeneric = new PredefinedType(module, MemberKind.Interface, "System.Collections.Generic", "IEnumerator", 1); IListGeneric = new PredefinedType(module, MemberKind.Interface, "System.Collections.Generic", "IList", 1); IReadOnlyListGeneric = new PredefinedType(module, MemberKind.Interface, "System.Collections.Generic", "IReadOnlyList", 1); ICollectionGeneric = new PredefinedType(module, MemberKind.Interface, "System.Collections.Generic", "ICollection", 1); IReadOnlyCollectionGeneric = new PredefinedType(module, MemberKind.Interface, "System.Collections.Generic", "IReadOnlyCollection", 1); IEnumerableGeneric = new PredefinedType(module, MemberKind.Interface, "System.Collections.Generic", "IEnumerable", 1); Nullable = new PredefinedType(module, MemberKind.Struct, "System", "Nullable", 1); Activator = new PredefinedType(module, MemberKind.Class, "System", "Activator"); Interlocked = new PredefinedType(module, MemberKind.Class, "System.Threading", "Interlocked"); Monitor = new PredefinedType(module, MemberKind.Class, "System.Threading", "Monitor"); NotSupportedException = new PredefinedType(module, MemberKind.Class, "System", "NotSupportedException"); RuntimeFieldHandle = new PredefinedType(module, MemberKind.Struct, "System", "RuntimeFieldHandle"); RuntimeMethodHandle = new PredefinedType(module, MemberKind.Struct, "System", "RuntimeMethodHandle"); SecurityAction = new PredefinedType(module, MemberKind.Enum, "System.Security.Permissions", "SecurityAction"); Dictionary = new PredefinedType(module, MemberKind.Class, "System.Collections.Generic", "Dictionary", 2); Hashtable = new PredefinedType(module, MemberKind.Class, "System.Collections", "Hashtable"); Array = new PredefinedType(module, MemberKind.Class, "System", "Array"); Expression = new PredefinedType(module, MemberKind.Class, "System.Linq.Expressions", "Expression"); ExpressionGeneric = new PredefinedType(module, MemberKind.Class, "System.Linq.Expressions", "Expression", 1); MemberBinding = new PredefinedType(module, MemberKind.Class, "System.Linq.Expressions", "MemberBinding"); ParameterExpression = new PredefinedType(module, MemberKind.Class, "System.Linq.Expressions", "ParameterExpression"); FieldInfo = new PredefinedType(module, MemberKind.Class, "System.Reflection", "FieldInfo"); MethodBase = new PredefinedType(module, MemberKind.Class, "System.Reflection", "MethodBase"); MethodInfo = new PredefinedType(module, MemberKind.Class, "System.Reflection", "MethodInfo"); ConstructorInfo = new PredefinedType(module, MemberKind.Class, "System.Reflection", "ConstructorInfo"); CallSite = new PredefinedType(module, MemberKind.Class, "System.Runtime.CompilerServices", "CallSite"); CallSiteGeneric = new PredefinedType(module, MemberKind.Class, "System.Runtime.CompilerServices", "CallSite", 1); Binder = new PredefinedType(module, MemberKind.Class, "Microsoft.CSharp.RuntimeBinder", "Binder"); BinderFlags = new PredefinedType(module, MemberKind.Enum, "Microsoft.CSharp.RuntimeBinder", "CSharpBinderFlags"); Action = new PredefinedType(module, MemberKind.Delegate, "System", "Action"); AsyncVoidMethodBuilder = new PredefinedType(module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncVoidMethodBuilder"); AsyncTaskMethodBuilder = new PredefinedType(module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder"); AsyncTaskMethodBuilderGeneric = new PredefinedType(module, MemberKind.Struct, "System.Runtime.CompilerServices", "AsyncTaskMethodBuilder", 1); Task = new PredefinedType(module, MemberKind.Class, "System.Threading.Tasks", "Task"); TaskGeneric = new PredefinedType(module, MemberKind.Class, "System.Threading.Tasks", "Task", 1); IAsyncStateMachine = new PredefinedType(module, MemberKind.Interface, "System.Runtime.CompilerServices", "IAsyncStateMachine"); INotifyCompletion = new PredefinedType(module, MemberKind.Interface, "System.Runtime.CompilerServices", "INotifyCompletion"); ICriticalNotifyCompletion = new PredefinedType(module, MemberKind.Interface, "System.Runtime.CompilerServices", "ICriticalNotifyCompletion"); IFormattable = new PredefinedType(module, MemberKind.Interface, "System", "IFormattable"); FormattableString = new PredefinedType(module, MemberKind.Class, "System", "FormattableString"); FormattableStringFactory = new PredefinedType(module, MemberKind.Class, "System.Runtime.CompilerServices", "FormattableStringFactory"); SpanGeneric = new PredefinedType(module, MemberKind.Struct, "System", "Span", 1); if (TypedReference.Define()) { TypedReference.TypeSpec.IsSpecialRuntimeType = true; } if (ArgIterator.Define()) { ArgIterator.TypeSpec.IsSpecialRuntimeType = true; } if (IEnumerableGeneric.Define()) { IEnumerableGeneric.TypeSpec.IsArrayGenericInterface = true; } if (IListGeneric.Define()) { IListGeneric.TypeSpec.IsArrayGenericInterface = true; } if (IReadOnlyListGeneric.Define()) { IReadOnlyListGeneric.TypeSpec.IsArrayGenericInterface = true; } if (ICollectionGeneric.Define()) { ICollectionGeneric.TypeSpec.IsArrayGenericInterface = true; } if (IReadOnlyCollectionGeneric.Define()) { IReadOnlyCollectionGeneric.TypeSpec.IsArrayGenericInterface = true; } if (Nullable.Define()) { Nullable.TypeSpec.IsNullableType = true; } if (ExpressionGeneric.Define()) { ExpressionGeneric.TypeSpec.IsExpressionTreeType = true; } Task.Define(); if (TaskGeneric.Define()) { TaskGeneric.TypeSpec.IsGenericTask = true; } SwitchUserTypes = Switch.CreateSwitchUserTypes(module, Nullable.TypeSpec); IFormattable.Define(); FormattableString.Define(); Tuples = new PredefinedType[8]; for (int i = 0; i < Tuples.Length; i++) { PredefinedType predefinedType = new PredefinedType(module, MemberKind.Struct, "System", "ValueTuple", i + 1); Tuples[i] = predefinedType; if (predefinedType.Define()) { predefinedType.TypeSpec.IsTupleType = true; } } SpanGeneric.Define(); } } internal class PredefinedMembers { public readonly PredefinedMember ActivatorCreateInstance; public readonly PredefinedMember ArrayEmpty; public readonly PredefinedMember AsyncTaskMethodBuilderCreate; public readonly PredefinedMember AsyncTaskMethodBuilderStart; public readonly PredefinedMember AsyncTaskMethodBuilderSetResult; public readonly PredefinedMember AsyncTaskMethodBuilderSetException; public readonly PredefinedMember AsyncTaskMethodBuilderSetStateMachine; public readonly PredefinedMember AsyncTaskMethodBuilderOnCompleted; public readonly PredefinedMember AsyncTaskMethodBuilderOnCompletedUnsafe; public readonly PredefinedMember AsyncTaskMethodBuilderTask; public readonly PredefinedMember AsyncTaskMethodBuilderGenericCreate; public readonly PredefinedMember AsyncTaskMethodBuilderGenericStart; public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetResult; public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetException; public readonly PredefinedMember AsyncTaskMethodBuilderGenericSetStateMachine; public readonly PredefinedMember AsyncTaskMethodBuilderGenericOnCompleted; public readonly PredefinedMember AsyncTaskMethodBuilderGenericOnCompletedUnsafe; public readonly PredefinedMember AsyncTaskMethodBuilderGenericTask; public readonly PredefinedMember AsyncVoidMethodBuilderCreate; public readonly PredefinedMember AsyncVoidMethodBuilderStart; public readonly PredefinedMember AsyncVoidMethodBuilderSetException; public readonly PredefinedMember AsyncVoidMethodBuilderSetResult; public readonly PredefinedMember AsyncVoidMethodBuilderSetStateMachine; public readonly PredefinedMember AsyncVoidMethodBuilderOnCompleted; public readonly PredefinedMember AsyncVoidMethodBuilderOnCompletedUnsafe; public readonly PredefinedMember AsyncStateMachineAttributeCtor; public readonly PredefinedMember DebuggerBrowsableAttributeCtor; public readonly PredefinedMember DecimalCtor; public readonly PredefinedMember DecimalCtorInt; public readonly PredefinedMember DecimalCtorLong; public readonly PredefinedMember DecimalConstantAttributeCtor; public readonly PredefinedMember DefaultMemberAttributeCtor; public readonly PredefinedMember DelegateCombine; public readonly PredefinedMember DelegateEqual; public readonly PredefinedMember DelegateInequal; public readonly PredefinedMember DelegateRemove; public readonly PredefinedMember DynamicAttributeCtor; public readonly PredefinedMember FieldInfoGetFieldFromHandle; public readonly PredefinedMember FieldInfoGetFieldFromHandle2; public readonly PredefinedMember IDisposableDispose; public readonly PredefinedMember IEnumerableGetEnumerator; public readonly PredefinedMember InterlockedCompareExchange; public readonly PredefinedMember InterlockedCompareExchange_T; public readonly PredefinedMember FixedBufferAttributeCtor; public readonly PredefinedMember MethodInfoGetMethodFromHandle; public readonly PredefinedMember MethodInfoGetMethodFromHandle2; public readonly PredefinedMember MethodInfoCreateDelegate; public readonly PredefinedMember MonitorEnter; public readonly PredefinedMember MonitorEnter_v4; public readonly PredefinedMember MonitorExit; public readonly PredefinedMember RuntimeCompatibilityWrapNonExceptionThrows; public readonly PredefinedMember RuntimeHelpersInitializeArray; public readonly PredefinedMember RuntimeHelpersOffsetToStringData; public readonly PredefinedMember SecurityActionRequestMinimum; public readonly PredefinedMember StringEmpty; public readonly PredefinedMember StringEqual; public readonly PredefinedMember StringInequal; public readonly PredefinedMember StructLayoutAttributeCtor; public readonly PredefinedMember StructLayoutCharSet; public readonly PredefinedMember StructLayoutSize; public readonly PredefinedMember TypeGetTypeFromHandle; public readonly PredefinedMember TupleElementNamesAttributeCtor; public PredefinedMembers(ModuleContainer module) { PredefinedTypes types = module.PredefinedTypes; PredefinedAttributes predefinedAttributes = module.PredefinedAttributes; BuiltinTypes builtinTypes = module.Compiler.BuiltinTypes; TypeParameter definition = new TypeParameter(0, new MemberName("T"), null, null, Variance.None); ActivatorCreateInstance = new PredefinedMember(module, types.Activator, MemberFilter.Method("CreateInstance", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); ArrayEmpty = new PredefinedMember(module, types.Array, MemberFilter.Method("Empty", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); AsyncTaskMethodBuilderCreate = new PredefinedMember(module, types.AsyncTaskMethodBuilder, MemberFilter.Method("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncTaskMethodBuilder.TypeSpec)); AsyncTaskMethodBuilderSetResult = new PredefinedMember(module, types.AsyncTaskMethodBuilder, MemberFilter.Method("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, builtinTypes.Void)); AsyncTaskMethodBuilderSetStateMachine = new PredefinedMember(module, types.AsyncTaskMethodBuilder, "SetStateMachine", MemberKind.Method, () => new TypeSpec[1] { types.IAsyncStateMachine.TypeSpec }, builtinTypes.Void); AsyncTaskMethodBuilderSetException = new PredefinedMember(module, types.AsyncTaskMethodBuilder, MemberFilter.Method("SetException", 0, ParametersCompiled.CreateFullyResolved(builtinTypes.Exception), builtinTypes.Void)); PredefinedType asyncTaskMethodBuilder = types.AsyncTaskMethodBuilder; IParameterData[] array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param = array; TypeSpec[] types2 = new TypeParameterSpec[2] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, definition, SpecialConstraint.None, Variance.None, null) }; AsyncTaskMethodBuilderOnCompleted = new PredefinedMember(module, asyncTaskMethodBuilder, MemberFilter.Method("AwaitOnCompleted", 2, new ParametersImported(param, types2, hasParams: false), builtinTypes.Void)); PredefinedType asyncTaskMethodBuilder2 = types.AsyncTaskMethodBuilder; array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param2 = array; types2 = new TypeParameterSpec[2] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, definition, SpecialConstraint.None, Variance.None, null) }; AsyncTaskMethodBuilderOnCompletedUnsafe = new PredefinedMember(module, asyncTaskMethodBuilder2, MemberFilter.Method("AwaitUnsafeOnCompleted", 2, new ParametersImported(param2, types2, hasParams: false), builtinTypes.Void)); PredefinedType asyncTaskMethodBuilder3 = types.AsyncTaskMethodBuilder; array = new ParameterData[1] { new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param3 = array; types2 = new TypeParameterSpec[1] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null) }; AsyncTaskMethodBuilderStart = new PredefinedMember(module, asyncTaskMethodBuilder3, MemberFilter.Method("Start", 1, new ParametersImported(param3, types2, hasParams: false), builtinTypes.Void)); AsyncTaskMethodBuilderTask = new PredefinedMember(module, types.AsyncTaskMethodBuilder, MemberFilter.Property("Task", null)); AsyncTaskMethodBuilderGenericCreate = new PredefinedMember(module, types.AsyncTaskMethodBuilderGeneric, MemberFilter.Method("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec)); AsyncTaskMethodBuilderGenericSetResult = new PredefinedMember(module, types.AsyncTaskMethodBuilderGeneric, "SetResult", MemberKind.Method, () => new TypeSpec[1] { types.AsyncTaskMethodBuilderGeneric.TypeSpec.MemberDefinition.TypeParameters[0] }, builtinTypes.Void); AsyncTaskMethodBuilderGenericSetStateMachine = new PredefinedMember(module, types.AsyncTaskMethodBuilderGeneric, "SetStateMachine", MemberKind.Method, () => new TypeSpec[1] { types.IAsyncStateMachine.TypeSpec }, builtinTypes.Void); AsyncTaskMethodBuilderGenericSetException = new PredefinedMember(module, types.AsyncTaskMethodBuilderGeneric, MemberFilter.Method("SetException", 0, ParametersCompiled.CreateFullyResolved(builtinTypes.Exception), builtinTypes.Void)); PredefinedType asyncTaskMethodBuilderGeneric = types.AsyncTaskMethodBuilderGeneric; array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param4 = array; types2 = new TypeParameterSpec[2] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, definition, SpecialConstraint.None, Variance.None, null) }; AsyncTaskMethodBuilderGenericOnCompleted = new PredefinedMember(module, asyncTaskMethodBuilderGeneric, MemberFilter.Method("AwaitOnCompleted", 2, new ParametersImported(param4, types2, hasParams: false), builtinTypes.Void)); PredefinedType asyncTaskMethodBuilderGeneric2 = types.AsyncTaskMethodBuilderGeneric; array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param5 = array; types2 = new TypeParameterSpec[2] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, definition, SpecialConstraint.None, Variance.None, null) }; AsyncTaskMethodBuilderGenericOnCompletedUnsafe = new PredefinedMember(module, asyncTaskMethodBuilderGeneric2, MemberFilter.Method("AwaitUnsafeOnCompleted", 2, new ParametersImported(param5, types2, hasParams: false), builtinTypes.Void)); PredefinedType asyncTaskMethodBuilderGeneric3 = types.AsyncTaskMethodBuilderGeneric; array = new ParameterData[1] { new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param6 = array; types2 = new TypeParameterSpec[1] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null) }; AsyncTaskMethodBuilderGenericStart = new PredefinedMember(module, asyncTaskMethodBuilderGeneric3, MemberFilter.Method("Start", 1, new ParametersImported(param6, types2, hasParams: false), builtinTypes.Void)); AsyncTaskMethodBuilderGenericTask = new PredefinedMember(module, types.AsyncTaskMethodBuilderGeneric, MemberFilter.Property("Task", null)); AsyncVoidMethodBuilderCreate = new PredefinedMember(module, types.AsyncVoidMethodBuilder, MemberFilter.Method("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec)); AsyncVoidMethodBuilderSetException = new PredefinedMember(module, types.AsyncVoidMethodBuilder, MemberFilter.Method("SetException", 0, null, builtinTypes.Void)); AsyncVoidMethodBuilderSetResult = new PredefinedMember(module, types.AsyncVoidMethodBuilder, MemberFilter.Method("SetResult", 0, ParametersCompiled.EmptyReadOnlyParameters, builtinTypes.Void)); AsyncVoidMethodBuilderSetStateMachine = new PredefinedMember(module, types.AsyncVoidMethodBuilder, "SetStateMachine", MemberKind.Method, () => new TypeSpec[1] { types.IAsyncStateMachine.TypeSpec }, builtinTypes.Void); PredefinedType asyncVoidMethodBuilder = types.AsyncVoidMethodBuilder; array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param7 = array; types2 = new TypeParameterSpec[2] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, definition, SpecialConstraint.None, Variance.None, null) }; AsyncVoidMethodBuilderOnCompleted = new PredefinedMember(module, asyncVoidMethodBuilder, MemberFilter.Method("AwaitOnCompleted", 2, new ParametersImported(param7, types2, hasParams: false), builtinTypes.Void)); PredefinedType asyncVoidMethodBuilder2 = types.AsyncVoidMethodBuilder; array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param8 = array; types2 = new TypeParameterSpec[2] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(1, definition, SpecialConstraint.None, Variance.None, null) }; AsyncVoidMethodBuilderOnCompletedUnsafe = new PredefinedMember(module, asyncVoidMethodBuilder2, MemberFilter.Method("AwaitUnsafeOnCompleted", 2, new ParametersImported(param8, types2, hasParams: false), builtinTypes.Void)); PredefinedType asyncVoidMethodBuilder3 = types.AsyncVoidMethodBuilder; array = new ParameterData[1] { new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param9 = array; types2 = new TypeParameterSpec[1] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null) }; AsyncVoidMethodBuilderStart = new PredefinedMember(module, asyncVoidMethodBuilder3, MemberFilter.Method("Start", 1, new ParametersImported(param9, types2, hasParams: false), builtinTypes.Void)); AsyncStateMachineAttributeCtor = new PredefinedMember(module, predefinedAttributes.AsyncStateMachine, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Type))); DebuggerBrowsableAttributeCtor = new PredefinedMember(module, predefinedAttributes.DebuggerBrowsable, MemberFilter.Constructor(null)); DecimalCtor = new PredefinedMember(module, builtinTypes.Decimal, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Int, builtinTypes.Int, builtinTypes.Int, builtinTypes.Bool, builtinTypes.Byte))); DecimalCtorInt = new PredefinedMember(module, builtinTypes.Decimal, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Int))); DecimalCtorLong = new PredefinedMember(module, builtinTypes.Decimal, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Long))); DecimalConstantAttributeCtor = new PredefinedMember(module, predefinedAttributes.DecimalConstant, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Byte, builtinTypes.Byte, builtinTypes.UInt, builtinTypes.UInt, builtinTypes.UInt))); DefaultMemberAttributeCtor = new PredefinedMember(module, predefinedAttributes.DefaultMember, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.String))); DelegateCombine = new PredefinedMember(module, builtinTypes.Delegate, "Combine", builtinTypes.Delegate, builtinTypes.Delegate); DelegateRemove = new PredefinedMember(module, builtinTypes.Delegate, "Remove", builtinTypes.Delegate, builtinTypes.Delegate); DelegateEqual = new PredefinedMember(module, builtinTypes.Delegate, new MemberFilter(Operator.GetMetadataName(Operator.OpType.Equality), 0, MemberKind.Operator, null, builtinTypes.Bool)); DelegateInequal = new PredefinedMember(module, builtinTypes.Delegate, new MemberFilter(Operator.GetMetadataName(Operator.OpType.Inequality), 0, MemberKind.Operator, null, builtinTypes.Bool)); DynamicAttributeCtor = new PredefinedMember(module, predefinedAttributes.Dynamic, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(ArrayContainer.MakeType(module, builtinTypes.Bool)))); FieldInfoGetFieldFromHandle = new PredefinedMember(module, types.FieldInfo, "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle); FieldInfoGetFieldFromHandle2 = new PredefinedMember(module, types.FieldInfo, "GetFieldFromHandle", MemberKind.Method, types.RuntimeFieldHandle, new PredefinedType(builtinTypes.RuntimeTypeHandle)); FixedBufferAttributeCtor = new PredefinedMember(module, predefinedAttributes.FixedBuffer, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Type, builtinTypes.Int))); IDisposableDispose = new PredefinedMember(module, builtinTypes.IDisposable, "Dispose", TypeSpec.EmptyTypes); IEnumerableGetEnumerator = new PredefinedMember(module, builtinTypes.IEnumerable, "GetEnumerator", TypeSpec.EmptyTypes); PredefinedType interlocked = types.Interlocked; array = new ParameterData[3] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.NONE), new ParameterData(null, Parameter.Modifier.NONE) }; IParameterData[] param10 = array; types2 = new BuiltinTypeSpec[3] { builtinTypes.Int, builtinTypes.Int, builtinTypes.Int }; InterlockedCompareExchange = new PredefinedMember(module, interlocked, MemberFilter.Method("CompareExchange", 0, new ParametersImported(param10, types2, hasParams: false), builtinTypes.Int)); PredefinedType interlocked2 = types.Interlocked; array = new ParameterData[3] { new ParameterData(null, Parameter.Modifier.REF), new ParameterData(null, Parameter.Modifier.NONE), new ParameterData(null, Parameter.Modifier.NONE) }; IParameterData[] param11 = array; types2 = new TypeParameterSpec[3] { new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null), new TypeParameterSpec(0, definition, SpecialConstraint.None, Variance.None, null) }; InterlockedCompareExchange_T = new PredefinedMember(module, interlocked2, MemberFilter.Method("CompareExchange", 1, new ParametersImported(param11, types2, hasParams: false), null)); MethodInfoGetMethodFromHandle = new PredefinedMember(module, types.MethodBase, "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle); MethodInfoGetMethodFromHandle2 = new PredefinedMember(module, types.MethodBase, "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType(builtinTypes.RuntimeTypeHandle)); MethodInfoCreateDelegate = new PredefinedMember(module, types.MethodInfo, "CreateDelegate", MemberKind.Method, new PredefinedType(builtinTypes.Type), new PredefinedType(builtinTypes.Object)); MonitorEnter = new PredefinedMember(module, types.Monitor, "Enter", builtinTypes.Object); PredefinedType monitor = types.Monitor; array = new ParameterData[2] { new ParameterData(null, Parameter.Modifier.NONE), new ParameterData(null, Parameter.Modifier.REF) }; IParameterData[] param12 = array; types2 = new BuiltinTypeSpec[2] { builtinTypes.Object, builtinTypes.Bool }; MonitorEnter_v4 = new PredefinedMember(module, monitor, MemberFilter.Method("Enter", 0, new ParametersImported(param12, types2, hasParams: false), null)); MonitorExit = new PredefinedMember(module, types.Monitor, "Exit", builtinTypes.Object); RuntimeCompatibilityWrapNonExceptionThrows = new PredefinedMember(module, predefinedAttributes.RuntimeCompatibility, MemberFilter.Property("WrapNonExceptionThrows", builtinTypes.Bool)); RuntimeHelpersInitializeArray = new PredefinedMember(module, types.RuntimeHelpers, "InitializeArray", builtinTypes.Array, builtinTypes.RuntimeFieldHandle); RuntimeHelpersOffsetToStringData = new PredefinedMember(module, types.RuntimeHelpers, MemberFilter.Property("OffsetToStringData", builtinTypes.Int)); SecurityActionRequestMinimum = new PredefinedMember(module, types.SecurityAction, "RequestMinimum", MemberKind.Field, types.SecurityAction); StringEmpty = new PredefinedMember(module, builtinTypes.String, MemberFilter.Field("Empty", builtinTypes.String)); StringEqual = new PredefinedMember(module, builtinTypes.String, new MemberFilter(Operator.GetMetadataName(Operator.OpType.Equality), 0, MemberKind.Operator, null, builtinTypes.Bool)); StringInequal = new PredefinedMember(module, builtinTypes.String, new MemberFilter(Operator.GetMetadataName(Operator.OpType.Inequality), 0, MemberKind.Operator, null, builtinTypes.Bool)); StructLayoutAttributeCtor = new PredefinedMember(module, predefinedAttributes.StructLayout, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(builtinTypes.Short))); StructLayoutCharSet = new PredefinedMember(module, predefinedAttributes.StructLayout, "CharSet", MemberKind.Field, types.CharSet); StructLayoutSize = new PredefinedMember(module, predefinedAttributes.StructLayout, MemberFilter.Field("Size", builtinTypes.Int)); TypeGetTypeFromHandle = new PredefinedMember(module, builtinTypes.Type, "GetTypeFromHandle", builtinTypes.RuntimeTypeHandle); TupleElementNamesAttributeCtor = new PredefinedMember(module, predefinedAttributes.TupleElementNames, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(ArrayContainer.MakeType(module, builtinTypes.String)))); } } internal class PredefinedType { private readonly string name; private readonly string ns; private readonly int arity; private readonly MemberKind kind; protected readonly ModuleContainer module; protected TypeSpec type; private bool defined; public int Arity => arity; public bool IsDefined => type != null; public string Name => name; public string Namespace => ns; public TypeSpec TypeSpec => type; public PredefinedType(ModuleContainer module, MemberKind kind, string ns, string name, int arity) : this(module, kind, ns, name) { this.arity = arity; } public PredefinedType(ModuleContainer module, MemberKind kind, string ns, string name) { this.module = module; this.kind = kind; this.name = name; this.ns = ns; } public PredefinedType(BuiltinTypeSpec type) { kind = type.Kind; name = type.Name; ns = type.Namespace; this.type = type; } public bool Define() { if (type != null) { return true; } if (!defined) { defined = true; type = Resolve(module, kind, ns, name, arity, required: false, reportErrors: false); } return type != null; } public string GetSignatureForError() { return ns + "." + name; } public static TypeSpec Resolve(ModuleContainer module, MemberKind kind, string ns, string name, int arity, bool required, bool reportErrors) { Namespace obj = module.GlobalRootNamespace.GetNamespace(ns, required); IList list = null; if (obj != null) { list = obj.GetAllTypes(name); } if (list == null) { if (reportErrors) { module.Compiler.Report.Error(518, "The predefined type `{0}.{1}' is not defined or imported", ns, name); } return null; } TypeSpec typeSpec = null; foreach (TypeSpec item in list) { if ((item.Kind != kind && (item.Kind != MemberKind.Struct || kind != MemberKind.Void || !(item.MemberDefinition is TypeContainer))) || item.Arity != arity || ((item.Modifiers & Modifiers.INTERNAL) != 0 && !item.MemberDefinition.IsInternalAsPublic(module.DeclaringAssembly))) { continue; } if (typeSpec == null) { typeSpec = item; continue; } TypeSpec ms = typeSpec; if (!typeSpec.MemberDefinition.IsImported && module.Compiler.BuiltinTypes.Object.MemberDefinition.DeclaringAssembly == item.MemberDefinition.DeclaringAssembly) { typeSpec = item; } string fileName; if (typeSpec.MemberDefinition is MemberCore) { fileName = ((MemberCore)typeSpec.MemberDefinition).Location.Name; } else { ImportedAssemblyDefinition importedAssemblyDefinition = (ImportedAssemblyDefinition)typeSpec.MemberDefinition.DeclaringAssembly; fileName = Path.GetFileName(importedAssemblyDefinition.Location); } module.Compiler.Report.SymbolRelatedToPreviousError(ms); module.Compiler.Report.SymbolRelatedToPreviousError(item); module.Compiler.Report.Warning(1685, 1, "The predefined type `{0}.{1}' is defined multiple times. Using definition from `{2}'", ns, name, fileName); break; } if (typeSpec == null && reportErrors) { TypeSpec typeSpec2 = list[0]; if (typeSpec2.Kind == MemberKind.MissingType) { module.Compiler.Report.Error(518, "The predefined type `{0}.{1}' is defined in an assembly that is not referenced.", ns, name); } else { Location loc; if (typeSpec2.MemberDefinition is MemberCore) { loc = ((MemberCore)typeSpec2.MemberDefinition).Location; } else { loc = Location.Null; module.Compiler.Report.SymbolRelatedToPreviousError(typeSpec2); } module.Compiler.Report.Error(520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name); } } return typeSpec; } public TypeSpec Resolve() { if (type == null) { type = Resolve(module, kind, ns, name, arity, required: false, reportErrors: true); } return type; } } internal class PredefinedMember where T : MemberSpec { private readonly ModuleContainer module; private T member; private TypeSpec declaring_type; private readonly PredefinedType declaring_type_predefined; private MemberFilter filter; private readonly Func filter_builder; public PredefinedMember(ModuleContainer module, PredefinedType type, MemberFilter filter) { this.module = module; declaring_type_predefined = type; this.filter = filter; } public PredefinedMember(ModuleContainer module, TypeSpec type, MemberFilter filter) { this.module = module; declaring_type = type; this.filter = filter; } public PredefinedMember(ModuleContainer module, PredefinedType type, string name, params TypeSpec[] types) : this(module, type, MemberFilter.Method(name, 0, ParametersCompiled.CreateFullyResolved(types), null)) { } public PredefinedMember(ModuleContainer module, PredefinedType type, string name, MemberKind kind, params PredefinedType[] types) : this(module, type, new MemberFilter(name, 0, kind, null, null)) { filter_builder = delegate { TypeSpec[] array = new TypeSpec[types.Length]; for (int i = 0; i < array.Length; i++) { PredefinedType predefinedType = types[i]; if (!predefinedType.Define()) { return (TypeSpec[])null; } array[i] = predefinedType.TypeSpec; } return array; }; } public PredefinedMember(ModuleContainer module, PredefinedType type, string name, MemberKind kind, Func typesBuilder, TypeSpec returnType) : this(module, type, new MemberFilter(name, 0, kind, null, returnType)) { filter_builder = typesBuilder; } public PredefinedMember(ModuleContainer module, BuiltinTypeSpec type, string name, params TypeSpec[] types) : this(module, (TypeSpec)type, MemberFilter.Method(name, 0, ParametersCompiled.CreateFullyResolved(types), null)) { } public T Get() { if (member != null) { return member; } if (declaring_type == null) { if (!declaring_type_predefined.Define()) { return null; } declaring_type = declaring_type_predefined.TypeSpec; } if (filter_builder != null) { TypeSpec[] array = filter_builder(); if (filter.Kind == MemberKind.Field) { filter = new MemberFilter(filter.Name, filter.Arity, filter.Kind, null, array[0]); } else { filter = new MemberFilter(filter.Name, filter.Arity, filter.Kind, ParametersCompiled.CreateFullyResolved(array), filter.MemberType); } } member = MemberCache.FindMember(declaring_type, filter, BindingRestriction.DeclaredOnly) as T; if (member == null) { return null; } if (!member.IsAccessible(module)) { return null; } return member; } public T Resolve(Location loc) { if (Get() != null) { return member; } if (declaring_type == null && declaring_type_predefined.Resolve() == null) { return null; } if (filter_builder != null) { filter = new MemberFilter(filter.Name, filter.Arity, filter.Kind, ParametersCompiled.CreateFullyResolved(filter_builder()), filter.MemberType); } string text = null; if (filter.Parameters != null) { text = filter.Parameters.GetSignatureForError(); } module.Compiler.Report.Error(656, loc, "The compiler required member `{0}.{1}{2}' could not be found or is inaccessible", declaring_type.GetSignatureForError(), filter.Name, text); return null; } } internal class AwaiterDefinition { public PropertySpec IsCompleted { get; set; } public MethodSpec GetResult { get; set; } public bool INotifyCompletion { get; set; } public bool IsValidPattern => IsCompleted != null && GetResult != null && IsCompleted.HasGet; } internal class TypeManager { public static string CSharpName(IList types) { if (types.Count == 0) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < types.Count; i++) { if (i > 0) { stringBuilder.Append(","); } stringBuilder.Append(types[i].GetSignatureForError()); } return stringBuilder.ToString(); } public static string GetFullNameSignature(MemberSpec mi) { return mi.GetSignatureForError(); } public static string CSharpSignature(MemberSpec mb) { return mb.GetSignatureForError(); } public static bool IsFamilyAccessible(TypeSpec type, TypeSpec parent) { if (type.Kind == MemberKind.TypeParameter && parent.Kind == MemberKind.TypeParameter) { if (type == parent) { return true; } throw new NotImplementedException("net"); } do { if (IsInstantiationOfSameGenericType(type, parent)) { return true; } type = type.BaseType; } while (type != null); return false; } public static bool IsNestedChildOf(TypeSpec type, ITypeDefinition parent) { if (type == null) { return false; } if (type.MemberDefinition == parent) { return false; } for (type = type.DeclaringType; type != null; type = type.DeclaringType) { if (type.MemberDefinition == parent) { return true; } } return false; } public static TypeSpec GetElementType(TypeSpec t) { return ((ElementTypeSpec)t).Element; } public static bool HasElementType(TypeSpec t) { return t is ElementTypeSpec; } public static bool VerifyUnmanaged(ModuleContainer rc, TypeSpec t, Location loc) { if (t.IsUnmanaged) { return true; } while (t.IsPointer) { t = ((ElementTypeSpec)t).Element; } rc.Compiler.Report.SymbolRelatedToPreviousError(t); rc.Compiler.Report.Error(208, loc, "Cannot take the address of, get the size of, or declare a pointer to a managed type `{0}'", t.GetSignatureForError()); return false; } public static bool IsGenericParameter(TypeSpec type) { return type.IsGenericParameter; } public static bool IsGenericType(TypeSpec type) { return type.IsGeneric; } public static TypeSpec[] GetTypeArguments(TypeSpec t) { return t.TypeArguments; } public static bool IsInstantiationOfSameGenericType(TypeSpec type, TypeSpec parent) { return type == parent || type.MemberDefinition == parent.MemberDefinition; } } internal class TypeSpec : MemberSpec { protected Type info; protected MemberCache cache; protected IList ifaces; private TypeSpec base_type; private Dictionary inflated_instances; public static readonly TypeSpec[] EmptyTypes; private static readonly Type TypeBuilder; private static readonly Type GenericTypeBuilder; public override int Arity => MemberDefinition.TypeParametersCount; public virtual TypeSpec BaseType { get { return base_type; } set { base_type = value; } } public virtual BuiltinTypeSpec.Type BuiltinType => BuiltinTypeSpec.Type.None; public bool HasDynamicElement => (state & StateFlags.HasDynamicElement) != 0; public bool HasNamedTupleElement => (state & StateFlags.HasNamedTupleElement) != 0; public virtual IList Interfaces { get { if ((state & StateFlags.InterfacesImported) == 0) { state |= StateFlags.InterfacesImported; if (MemberDefinition is ImportedTypeDefinition importedTypeDefinition && Kind != MemberKind.MissingType) { importedTypeDefinition.DefineInterfaces(this); } } return ifaces; } set { ifaces = value; } } public bool IsArray => Kind == MemberKind.ArrayType; public bool IsAttribute { get { if (!IsClass) { return false; } TypeSpec typeSpec = this; do { if (typeSpec.BuiltinType == BuiltinTypeSpec.Type.Attribute) { return true; } if (typeSpec.IsGeneric) { return false; } typeSpec = typeSpec.base_type; } while (typeSpec != null); return false; } } public bool IsInterface => Kind == MemberKind.Interface; public bool IsClass => Kind == MemberKind.Class; public bool IsConstantCompatible { get { if ((Kind & (MemberKind.Class | MemberKind.Delegate | MemberKind.Enum | MemberKind.Interface | MemberKind.ArrayType)) != 0) { return true; } BuiltinTypeSpec.Type builtinType = BuiltinType; BuiltinTypeSpec.Type type = builtinType; if ((uint)(type - 1) <= 12u || type == BuiltinTypeSpec.Type.Dynamic) { return true; } return false; } } public bool IsDelegate => Kind == MemberKind.Delegate; public virtual bool IsExpressionTreeType { get { return false; } set { state = (value ? (state | StateFlags.InflatedExpressionType) : (state & ~StateFlags.InflatedExpressionType)); } } public bool IsEnum => Kind == MemberKind.Enum; public virtual bool IsArrayGenericInterface { get { return false; } set { state = (value ? (state | StateFlags.GenericIterateInterface) : (state & ~StateFlags.GenericIterateInterface)); } } public bool IsByRefLike => (modifiers & Modifiers.REF) != 0; public virtual bool IsGenericTask { get { return false; } set { state = (value ? (state | StateFlags.GenericTask) : (state & ~StateFlags.GenericTask)); } } public bool IsReadOnly => (modifiers & Modifiers.READONLY) != 0; public virtual bool IsTupleType { get { return (state & StateFlags.Tuple) != 0; } set { state = (value ? (state | StateFlags.Tuple) : (state & ~StateFlags.Tuple)); } } public bool IsGenericOrParentIsGeneric { get { TypeSpec typeSpec = this; do { if (typeSpec.IsGeneric) { return true; } typeSpec = typeSpec.declaringType; } while (typeSpec != null); return false; } } public bool IsGenericParameter => Kind == MemberKind.TypeParameter; public virtual bool IsNullableType { get { return false; } set { state = (value ? (state | StateFlags.InflatedNullableType) : (state & ~StateFlags.InflatedNullableType)); } } public bool IsNested => declaringType != null && Kind != MemberKind.TypeParameter; public bool IsPointer => Kind == MemberKind.PointerType; public bool IsSealed => (base.Modifiers & Modifiers.SEALED) != 0; public bool IsSpecialRuntimeType { get { return (state & StateFlags.SpecialRuntimeType) != 0; } set { state = (value ? (state | StateFlags.SpecialRuntimeType) : (state & ~StateFlags.SpecialRuntimeType)); } } public bool IsStruct => Kind == MemberKind.Struct; public bool IsStructOrEnum => (Kind & (MemberKind.Struct | MemberKind.Enum)) != 0; public bool IsTypeBuilder { get { Type type = GetMetaInfo().GetType(); return (object)type == TypeBuilder || (object)type == GenericTypeBuilder; } } public bool IsUnmanaged { get { if (IsPointer) { return ((ElementTypeSpec)this).Element.IsUnmanaged; } if (MemberDefinition is TypeDefinition typeDefinition) { return typeDefinition.IsUnmanagedType(); } if (Kind == MemberKind.Void) { return true; } if (Kind == MemberKind.TypeParameter) { return false; } if (IsNested && base.DeclaringType.IsGenericOrParentIsGeneric) { return false; } return IsValueType(this); } } public MemberCache MemberCache { get { if (cache == null || (state & StateFlags.PendingMemberCacheMembers) != 0) { InitializeMemberCache(onlyTypes: false); } return cache; } set { if (cache != null) { throw new InternalErrorException("Membercache reset"); } cache = value; } } public MemberCache MemberCacheTypes { get { if (cache == null) { InitializeMemberCache(onlyTypes: true); } return cache; } } public new ITypeDefinition MemberDefinition => (ITypeDefinition)definition; public virtual TypeSpec[] TypeArguments => EmptyTypes; static TypeSpec() { EmptyTypes = new TypeSpec[0]; Assembly assembly = typeof(object).Assembly; TypeBuilder = assembly.GetType("System.Reflection.Emit.TypeBuilder"); GenericTypeBuilder = assembly.GetType("System.Reflection.MonoGenericClass"); if ((object)GenericTypeBuilder == null) { GenericTypeBuilder = assembly.GetType("System.Reflection.Emit.TypeBuilderInstantiation"); } } public TypeSpec(MemberKind kind, TypeSpec declaringType, ITypeDefinition definition, Type info, Modifiers modifiers) : base(kind, declaringType, definition, modifiers) { base.declaringType = declaringType; this.info = info; if (definition != null && definition.TypeParametersCount > 0) { state |= StateFlags.IsGeneric; } } public virtual bool AddInterface(TypeSpec iface) { if ((state & StateFlags.InterfacesExpanded) != 0) { throw new InternalErrorException("Modifying expanded interface list"); } if (ifaces == null) { ifaces = new List { iface }; return true; } if (!ifaces.Contains(iface)) { ifaces.Add(iface); return true; } return false; } public bool AddInterfaceDefined(TypeSpec iface) { if (!AddInterface(iface)) { return false; } if (inflated_instances != null) { InflatedTypeSpec[] array = inflated_instances.Values.ToArray(); InflatedTypeSpec[] array2 = array; foreach (InflatedTypeSpec inflatedTypeSpec in array2) { inflatedTypeSpec.AddInterface(iface); } } return true; } public static TypeSpec[] GetAllTypeArguments(TypeSpec type) { IList list = EmptyTypes; do { if (type.Arity > 0) { if (list.Count == 0) { list = type.TypeArguments; } else { List list2 = (list as List) ?? new List(list); list2.AddRange(type.TypeArguments); list = list2; } } type = type.declaringType; } while (type != null); return (list as TypeSpec[]) ?? ((List)list).ToArray(); } public AttributeUsageAttribute GetAttributeUsage(PredefinedAttribute pa) { if (Kind != MemberKind.Class) { throw new InternalErrorException(); } if (!pa.IsDefined) { return Attribute.DefaultUsageAttribute; } AttributeUsageAttribute attributeUsageAttribute = null; for (TypeSpec typeSpec = this; typeSpec != null; typeSpec = typeSpec.BaseType) { attributeUsageAttribute = typeSpec.MemberDefinition.GetAttributeUsage(pa); if (attributeUsageAttribute != null) { break; } } return attributeUsageAttribute; } public virtual Type GetMetaInfo() { return info; } public virtual TypeSpec GetDefinition() { return this; } public sealed override string GetSignatureForDocumentation() { return GetSignatureForDocumentation(explicitName: false); } public virtual string GetSignatureForDocumentation(bool explicitName) { StringBuilder stringBuilder = new StringBuilder(); if (IsNested) { stringBuilder.Append(base.DeclaringType.GetSignatureForDocumentation(explicitName)); } else if (MemberDefinition.Namespace != null) { stringBuilder.Append(explicitName ? MemberDefinition.Namespace.Replace('.', '#') : MemberDefinition.Namespace); } if (stringBuilder.Length != 0) { stringBuilder.Append(explicitName ? "#" : "."); } stringBuilder.Append(Name); if (Arity > 0) { if (this is InflatedTypeSpec) { stringBuilder.Append("{"); for (int i = 0; i < Arity; i++) { if (i > 0) { stringBuilder.Append(","); } stringBuilder.Append(TypeArguments[i].GetSignatureForDocumentation(explicitName)); } stringBuilder.Append("}"); } else { stringBuilder.Append("`"); stringBuilder.Append(Arity.ToString()); } } return stringBuilder.ToString(); } public override string GetSignatureForError() { string text; if (IsNested) { text = base.DeclaringType.GetSignatureForError(); } else { if (MemberDefinition is AnonymousTypeClass) { return ((AnonymousTypeClass)MemberDefinition).GetSignatureForError(); } if (IsTupleType) { return FormatTupleSignature(); } text = MemberDefinition.Namespace; } if (!string.IsNullOrEmpty(text)) { text += "."; } return text + Name + GetTypeNameSignature(); } private string FormatTupleSignature() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("("); for (int i = 0; i < TypeArguments.Length; i++) { if (i != 0) { stringBuilder.Append(", "); } stringBuilder.Append(TypeArguments[i].GetSignatureForError()); } stringBuilder.Append(")"); return stringBuilder.ToString(); } public string GetSignatureForErrorIncludingAssemblyName() { string arg = ((MemberDefinition.DeclaringAssembly is ImportedAssemblyDefinition importedAssemblyDefinition) ? Path.GetFullPath(importedAssemblyDefinition.Location) : ((MemberCore)MemberDefinition).Location.NameFullPath); return $"{GetSignatureForError()} [{MemberDefinition.DeclaringAssembly.FullName} -- {arg}]"; } protected virtual string GetTypeNameSignature() { if (!base.IsGeneric) { return null; } return "<" + TypeManager.CSharpName(MemberDefinition.TypeParameters) + ">"; } public bool ImplementsInterface(TypeSpec iface, bool variantly) { IList interfaces = Interfaces; if (interfaces != null) { for (int i = 0; i < interfaces.Count; i++) { if (TypeSpecComparer.IsEqual(interfaces[i], iface)) { return true; } if (variantly && TypeSpecComparer.Variant.IsEqual(interfaces[i], iface)) { return true; } } } return false; } protected virtual void InitializeMemberCache(bool onlyTypes) { try { MemberDefinition.LoadMembers(this, onlyTypes, ref cache); } catch (Exception exception) { throw new InternalErrorException(exception, "Unexpected error when loading type `{0}'", GetSignatureForError()); } if (onlyTypes) { state |= StateFlags.PendingMemberCacheMembers; } else { state &= ~StateFlags.PendingMemberCacheMembers; } } public static bool IsBaseClass(TypeSpec type, TypeSpec baseClass, bool dynamicIsObject) { if (dynamicIsObject && baseClass.IsGeneric) { for (type = type.BaseType; type != null; type = type.BaseType) { if (TypeSpecComparer.IsEqual(type, baseClass)) { return true; } } return false; } while (type != null) { type = type.BaseType; if (type == baseClass) { return true; } } return false; } public static bool IsReferenceType(TypeSpec t) { switch (t.Kind) { case MemberKind.TypeParameter: return ((TypeParameterSpec)t).IsReferenceType; case MemberKind.Struct: case MemberKind.Enum: case MemberKind.PointerType: case MemberKind.Void: return false; case MemberKind.InternalCompilerType: return t == InternalType.NullLiteral || t.BuiltinType == BuiltinTypeSpec.Type.Dynamic; default: return true; } } public static bool IsNonNullableValueType(TypeSpec t) { return t.Kind switch { MemberKind.TypeParameter => ((TypeParameterSpec)t).IsValueType, MemberKind.Struct => !t.IsNullableType, MemberKind.Enum => true, _ => false, }; } public static bool IsValueType(TypeSpec t) { switch (t.Kind) { case MemberKind.TypeParameter: return ((TypeParameterSpec)t).IsValueType; case MemberKind.Struct: case MemberKind.Enum: return true; default: return false; } } public override MemberSpec InflateMember(TypeParameterInflator inflator) { TypeSpec[] array; if (!base.IsGeneric) { array = EmptyTypes; } else { TypeSpec[] typeParameters = MemberDefinition.TypeParameters; array = typeParameters; } TypeSpec[] targs = array; if (base.DeclaringType == inflator.TypeInstance) { return MakeGenericType(inflator.Context, targs); } return new InflatedTypeSpec(inflator.Context, this, inflator.TypeInstance, targs); } public InflatedTypeSpec MakeGenericType(IModuleContext context, TypeSpec[] targs) { if (targs.Length == 0 && !IsNested) { throw new ArgumentException("Empty type arguments for type " + GetSignatureForError()); } InflatedTypeSpec value; if (inflated_instances == null) { inflated_instances = new Dictionary(TypeSpecComparer.Default); if (IsNested) { value = this as InflatedTypeSpec; if (value != null) { inflated_instances.Add(TypeArguments, value); } } } if (!inflated_instances.TryGetValue(targs, out value)) { if (GetDefinition() != this && !IsNested) { throw new InternalErrorException("`{0}' must be type definition or nested non-inflated type to MakeGenericType => " + Environment.StackTrace, GetSignatureForError()); } value = new InflatedTypeSpec(context, this, declaringType, targs); inflated_instances.Add(targs, value); } return value; } public virtual TypeSpec Mutate(TypeParameterMutator mutator) { return this; } public override List ResolveMissingDependencies(MemberSpec caller) { List list = null; if (Kind == MemberKind.MissingType) { list = new List(); list.Add(new MissingTypeSpecReference(this, caller)); return list; } TypeSpec[] typeArguments = TypeArguments; foreach (TypeSpec typeSpec in typeArguments) { if (typeSpec.Kind == MemberKind.MissingType) { if (list == null) { list = new List(); } list.Add(new MissingTypeSpecReference(typeSpec, caller)); } } if (Interfaces != null) { foreach (TypeSpec @interface in Interfaces) { if (@interface.Kind == MemberKind.MissingType) { if (list == null) { list = new List(); } list.Add(new MissingTypeSpecReference(@interface, caller)); } } } if (MemberDefinition.TypeParametersCount > 0) { TypeParameterSpec[] typeParameters = MemberDefinition.TypeParameters; foreach (TypeParameterSpec typeParameterSpec in typeParameters) { List missingDependencies = typeParameterSpec.GetMissingDependencies(this); if (missingDependencies != null) { if (list == null) { list = new List(); } list.AddRange(missingDependencies); } } } if (list != null || BaseType == null) { return list; } return BaseType.ResolveMissingDependencies(this); } public void SetMetaInfo(Type info) { if ((object)this.info != null) { throw new InternalErrorException("MetaInfo reset"); } this.info = info; } public void SetExtensionMethodContainer() { modifiers |= Modifiers.METHOD_EXTENSION; } public void UpdateInflatedInstancesBaseType() { if (inflated_instances == null) { return; } foreach (KeyValuePair inflated_instance in inflated_instances) { inflated_instance.Value.BaseType = base_type; } } } internal sealed class BuiltinTypeSpec : TypeSpec { public enum Type { None = 0, FirstPrimitive = 1, Bool = 1, Byte = 2, SByte = 3, Char = 4, Short = 5, UShort = 6, Int = 7, UInt = 8, Long = 9, ULong = 10, Float = 11, Double = 12, LastPrimitive = 12, Decimal = 13, IntPtr = 14, UIntPtr = 15, Object = 16, Dynamic = 17, String = 18, Type = 19, ValueType = 20, Enum = 21, Delegate = 22, MulticastDelegate = 23, Array = 24, IEnumerator = 25, IEnumerable = 26, IDisposable = 27, Exception = 28, Attribute = 29, Other = 30 } private readonly Type type; private readonly string ns; private readonly string name; public override int Arity => 0; public override Type BuiltinType => type; public string FullName => ns + "." + name; public override string Name => name; public string Namespace => ns; public BuiltinTypeSpec(MemberKind kind, string ns, string name, Type builtinKind) : base(kind, null, null, null, Modifiers.PUBLIC) { type = builtinKind; this.ns = ns; this.name = name; } public BuiltinTypeSpec(string name, Type builtinKind) : this(MemberKind.InternalCompilerType, "", name, builtinKind) { state = (state & ~(StateFlags.Obsolete_Undetected | StateFlags.CLSCompliant_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant; } public static bool IsPrimitiveType(TypeSpec type) { return type.BuiltinType >= Type.FirstPrimitive && type.BuiltinType <= Type.Double; } public static bool IsPrimitiveTypeOrDecimal(TypeSpec type) { return type.BuiltinType >= Type.FirstPrimitive && type.BuiltinType <= Type.Decimal; } public override string GetSignatureForError() { switch (Name) { case "Int32": return "int"; case "Int64": return "long"; case "String": return "string"; case "Boolean": return "bool"; case "Void": return "void"; case "Object": return "object"; case "UInt32": return "uint"; case "Int16": return "short"; case "UInt16": return "ushort"; case "UInt64": return "ulong"; case "Single": return "float"; case "Double": return "double"; case "Decimal": return "decimal"; case "Char": return "char"; case "Byte": return "byte"; case "SByte": return "sbyte"; default: if (ns.Length == 0) { return name; } return FullName; } } public static int GetSize(TypeSpec type) { switch (type.BuiltinType) { case Type.Int: case Type.UInt: case Type.Float: return 4; case Type.Long: case Type.ULong: case Type.Double: return 8; case Type.FirstPrimitive: case Type.Byte: case Type.SByte: return 1; case Type.Char: case Type.Short: case Type.UShort: return 2; case Type.Decimal: return 16; default: return 0; } } public void SetDefinition(ITypeDefinition td, System.Type type, Modifiers mod) { definition = td; info = type; modifiers |= mod & ~Modifiers.AccessibilityMask; } public void SetDefinition(TypeSpec ts) { definition = ts.MemberDefinition; info = ts.GetMetaInfo(); BaseType = ts.BaseType; Interfaces = ts.Interfaces; modifiers = ts.Modifiers; } } internal static class TypeSpecComparer { public class DefaultImpl : IEqualityComparer { bool IEqualityComparer.Equals(TypeSpec[] x, TypeSpec[] y) { if (x == y) { return true; } if (x.Length != y.Length) { return false; } for (int i = 0; i < x.Length; i++) { if (x[i] != y[i]) { return false; } } return true; } int IEqualityComparer.GetHashCode(TypeSpec[] obj) { int num = 0; for (int i = 0; i < obj.Length; i++) { num = (num << 5) - num + obj[i].GetHashCode(); } return num; } } public static class Override { public static bool IsEqual(TypeSpec a, TypeSpec b) { if (a == b) { return true; } if (a is TypeParameterSpec typeParameterSpec) { return b is TypeParameterSpec typeParameterSpec2 && typeParameterSpec.IsMethodOwned == typeParameterSpec2.IsMethodOwned && typeParameterSpec.DeclaredPosition == typeParameterSpec2.DeclaredPosition; } if (a is ArrayContainer arrayContainer) { return b is ArrayContainer arrayContainer2 && arrayContainer.Rank == arrayContainer2.Rank && IsEqual(arrayContainer.Element, arrayContainer2.Element); } if (a.BuiltinType == BuiltinTypeSpec.Type.Dynamic || b.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return b.BuiltinType == BuiltinTypeSpec.Type.Object || a.BuiltinType == BuiltinTypeSpec.Type.Object; } if (a.MemberDefinition != b.MemberDefinition) { return false; } do { for (int i = 0; i < a.TypeArguments.Length; i++) { if (!IsEqual(a.TypeArguments[i], b.TypeArguments[i])) { return false; } } a = a.DeclaringType; b = b.DeclaringType; } while (a != null); return true; } public static bool IsEqual(TypeSpec[] a, TypeSpec[] b) { if (a == b) { return true; } if (a.Length != b.Length) { return false; } for (int i = 0; i < a.Length; i++) { if (!IsEqual(a[i], b[i])) { return false; } } return true; } public static bool IsSame(TypeSpec[] a, TypeSpec[] b) { if (a == b) { return true; } if (a == null || b == null || a.Length != b.Length) { return false; } for (int i = 0; i < a.Length; i++) { bool flag = false; for (int j = 0; j < b.Length; j++) { if (IsEqual(a[i], b[j])) { flag = true; break; } } if (!flag) { return false; } } return true; } public static bool IsEqual(AParametersCollection a, AParametersCollection b) { if (a == b) { return true; } if (a.Count != b.Count) { return false; } for (int i = 0; i < a.Count; i++) { if (!IsEqual(a.Types[i], b.Types[i])) { return false; } if ((a.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask) != (b.FixedParameters[i].ModFlags & Parameter.Modifier.RefOutMask)) { return false; } } return true; } } public static class Variant { public static bool IsEqual(TypeSpec type1, TypeSpec type2) { if (!type1.IsGeneric || !type2.IsGeneric) { return false; } ITypeDefinition memberDefinition = type2.MemberDefinition; if (type1.MemberDefinition != memberDefinition) { return false; } TypeSpec[] typeArguments = type1.TypeArguments; TypeSpec[] typeArguments2 = type2.TypeArguments; TypeParameterSpec[] typeParameters = memberDefinition.TypeParameters; if (!type1.IsInterface && !type1.IsDelegate) { return false; } for (int i = 0; i < typeParameters.Length; i++) { if (TypeSpecComparer.IsEqual(typeArguments[i], typeArguments2[i])) { continue; } switch (typeParameters[i].Variance) { case Variance.None: return false; case Variance.Covariant: if (!Convert.ImplicitReferenceConversionExists(typeArguments[i], typeArguments2[i])) { return false; } break; default: if (!Convert.ImplicitReferenceConversionExists(typeArguments2[i], typeArguments[i])) { return false; } break; } } return true; } } public static class Unify { public static bool IsEqual(TypeSpec a, TypeSpec b) { if (a.MemberDefinition != b.MemberDefinition) { IList interfaces = a.Interfaces; if (interfaces != null) { foreach (TypeSpec item in interfaces) { if (item.Arity > 0 && IsEqual(item, b)) { return true; } } } return false; } TypeSpec[] typeArguments = a.TypeArguments; TypeSpec[] typeArguments2 = b.TypeArguments; for (int i = 0; i < typeArguments.Length; i++) { if (!MayBecomeEqualGenericTypes(typeArguments[i], typeArguments2[i])) { return false; } } if (a.IsNested && b.IsNested) { return IsEqual(a.DeclaringType, b.DeclaringType); } return true; } private static bool ContainsTypeParameter(TypeSpec tparam, TypeSpec type) { TypeSpec[] typeArguments = type.TypeArguments; for (int i = 0; i < typeArguments.Length; i++) { if (tparam == typeArguments[i]) { return true; } if (ContainsTypeParameter(tparam, typeArguments[i])) { return true; } } return false; } private static bool MayBecomeEqualGenericTypes(TypeSpec a, TypeSpec b) { if (a.IsGenericParameter) { if (b.IsArray) { return false; } if (b.IsGenericParameter) { return a != b && a.DeclaringType == b.DeclaringType; } return !ContainsTypeParameter(a, b); } if (b.IsGenericParameter) { return MayBecomeEqualGenericTypes(b, a); } if (TypeManager.IsGenericType(a) || TypeManager.IsGenericType(b)) { return IsEqual(a, b); } if (a is ArrayContainer arrayContainer) { if (!(b is ArrayContainer arrayContainer2) || arrayContainer.Rank != arrayContainer2.Rank) { return false; } return MayBecomeEqualGenericTypes(arrayContainer.Element, arrayContainer2.Element); } return false; } } public static readonly DefaultImpl Default = new DefaultImpl(); public static bool Equals(TypeSpec[] x, TypeSpec[] y) { if (x == y) { return true; } if (x.Length != y.Length) { return false; } for (int i = 0; i < x.Length; i++) { if (!IsEqual(x[i], y[i])) { return false; } } return true; } public static bool IsEqual(TypeSpec a, TypeSpec b) { if (a == b) { return a.Kind != MemberKind.InternalCompilerType || a.BuiltinType == BuiltinTypeSpec.Type.Dynamic; } if (a == null || b == null) { return false; } if (a.IsArray) { ArrayContainer arrayContainer = (ArrayContainer)a; if (!(b is ArrayContainer arrayContainer2)) { return false; } return arrayContainer.Rank == arrayContainer2.Rank && IsEqual(arrayContainer.Element, arrayContainer2.Element); } if (!a.IsGeneric || !b.IsGeneric) { if (a.BuiltinType == BuiltinTypeSpec.Type.Dynamic || b.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { return b.BuiltinType == BuiltinTypeSpec.Type.Object || a.BuiltinType == BuiltinTypeSpec.Type.Object; } return false; } if (a.MemberDefinition != b.MemberDefinition) { return false; } do { if (!Equals(a.TypeArguments, b.TypeArguments)) { return false; } a = a.DeclaringType; b = b.DeclaringType; } while (a != null); return true; } } internal interface ITypeDefinition : IMemberDefinition { IAssemblyDefinition DeclaringAssembly { get; } string Namespace { get; } bool IsPartial { get; } bool IsComImport { get; } bool IsTypeForwarder { get; } bool IsCyclicTypeForwarder { get; } int TypeParametersCount { get; } TypeParameterSpec[] TypeParameters { get; } TypeSpec GetAsyncMethodBuilder(); TypeSpec GetAttributeCoClass(); string GetAttributeDefaultMember(); AttributeUsageAttribute GetAttributeUsage(PredefinedAttribute pa); bool IsInternalAsPublic(IAssemblyDefinition assembly); void LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache); } internal class InternalType : TypeSpec, ITypeDefinition, IMemberDefinition { private sealed class InternalTypeAssembly : IAssemblyDefinition { public static readonly InternalTypeAssembly Instance = new InternalTypeAssembly(); public string FullName { get { throw new NotImplementedException(); } } public bool IsCLSCompliant => false; public bool IsMissing => false; public string Name { get { throw new NotImplementedException(); } } public byte[] GetPublicKeyToken() { throw new NotImplementedException(); } public bool IsFriendAssemblyTo(IAssemblyDefinition assembly) { return false; } } public static readonly InternalType AnonymousMethod = new InternalType("anonymous method"); public static readonly InternalType Arglist = new InternalType("__arglist"); public static readonly InternalType MethodGroup = new InternalType("method group"); public static readonly InternalType NullLiteral = new InternalType("null"); public static readonly InternalType FakeInternalType = new InternalType(""); public static readonly InternalType Namespace = new InternalType(""); public static readonly InternalType ErrorType = new InternalType(""); public static readonly InternalType VarOutType = new InternalType("var out"); public static readonly InternalType ThrowExpr = new InternalType("throw expression"); public static readonly InternalType DefaultType = new InternalType("default"); public static readonly InternalType Discard = new InternalType("discard"); private readonly string name; public override int Arity => 0; IAssemblyDefinition ITypeDefinition.DeclaringAssembly => InternalTypeAssembly.Instance; bool ITypeDefinition.IsComImport => false; bool IMemberDefinition.IsImported => false; bool ITypeDefinition.IsPartial => false; bool ITypeDefinition.IsTypeForwarder => false; bool ITypeDefinition.IsCyclicTypeForwarder => false; public override string Name => name; string ITypeDefinition.Namespace => null; int ITypeDefinition.TypeParametersCount => 0; TypeParameterSpec[] ITypeDefinition.TypeParameters => null; bool? IMemberDefinition.CLSAttributeValue => null; private InternalType(string name) : base(MemberKind.InternalCompilerType, null, null, null, Modifiers.PUBLIC) { this.name = name; definition = this; cache = MemberCache.Empty; state = (state & ~(StateFlags.Obsolete_Undetected | StateFlags.CLSCompliant_Undetected | StateFlags.MissingDependency_Undetected)) | StateFlags.CLSCompliant; } public override string GetSignatureForError() { return name; } TypeSpec ITypeDefinition.GetAsyncMethodBuilder() { return null; } TypeSpec ITypeDefinition.GetAttributeCoClass() { return null; } string ITypeDefinition.GetAttributeDefaultMember() { return null; } AttributeUsageAttribute ITypeDefinition.GetAttributeUsage(PredefinedAttribute pa) { return null; } bool ITypeDefinition.IsInternalAsPublic(IAssemblyDefinition assembly) { throw new NotImplementedException(); } void ITypeDefinition.LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { throw new NotImplementedException(); } string[] IMemberDefinition.ConditionalConditions() { return null; } ObsoleteAttribute IMemberDefinition.GetAttributeObsolete() { return null; } void IMemberDefinition.SetIsAssigned() { } void IMemberDefinition.SetIsUsed() { } public static bool HasNoType(TypeSpec type) { return type == AnonymousMethod || type == MethodGroup || type == NullLiteral || type == ThrowExpr || type == DefaultType; } } internal abstract class ElementTypeSpec : TypeSpec, ITypeDefinition, IMemberDefinition { public TypeSpec Element { get; private set; } public override IList Interfaces { set { throw new NotSupportedException(); } } bool ITypeDefinition.IsComImport => false; bool ITypeDefinition.IsPartial => false; bool ITypeDefinition.IsTypeForwarder => false; bool ITypeDefinition.IsCyclicTypeForwarder => false; public override string Name { get { throw new NotSupportedException(); } } IAssemblyDefinition ITypeDefinition.DeclaringAssembly => Element.MemberDefinition.DeclaringAssembly; public string Namespace { get { throw new NotImplementedException(); } } public int TypeParametersCount => 0; public TypeParameterSpec[] TypeParameters { get { throw new NotSupportedException(); } } public bool IsImported => Element.MemberDefinition.IsImported; bool? IMemberDefinition.CLSAttributeValue => Element.MemberDefinition.CLSAttributeValue; protected ElementTypeSpec(MemberKind kind, TypeSpec element, Type info) : base(kind, element.DeclaringType, null, info, element.Modifiers) { Element = element; state &= ~(StateFlags.Obsolete_Undetected | StateFlags.Obsolete | StateFlags.CLSCompliant_Undetected | StateFlags.CLSCompliant | StateFlags.MissingDependency_Undetected | StateFlags.MissingDependency | StateFlags.HasDynamicElement | StateFlags.HasNamedTupleElement); state |= element.state & (StateFlags.Obsolete_Undetected | StateFlags.Obsolete | StateFlags.CLSCompliant_Undetected | StateFlags.CLSCompliant | StateFlags.MissingDependency_Undetected | StateFlags.MissingDependency | StateFlags.HasDynamicElement | StateFlags.HasNamedTupleElement); if (element.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { state |= StateFlags.HasDynamicElement; } definition = this; cache = MemberCache.Empty; } public override void CheckObsoleteness(IMemberContext mc, Location loc) { Element.CheckObsoleteness(mc, loc); } public override ObsoleteAttribute GetAttributeObsolete() { return Element.GetAttributeObsolete(); } protected virtual string GetPostfixSignature() { return null; } public override string GetSignatureForDocumentation(bool explicitName) { return Element.GetSignatureForDocumentation(explicitName) + GetPostfixSignature(); } public override string GetSignatureForError() { return Element.GetSignatureForError() + GetPostfixSignature(); } public override TypeSpec Mutate(TypeParameterMutator mutator) { TypeSpec typeSpec = Element.Mutate(mutator); if (typeSpec == Element) { return this; } ElementTypeSpec elementTypeSpec = (ElementTypeSpec)MemberwiseClone(); elementTypeSpec.Element = typeSpec; elementTypeSpec.info = null; return elementTypeSpec; } bool ITypeDefinition.IsInternalAsPublic(IAssemblyDefinition assembly) { return Element.MemberDefinition.IsInternalAsPublic(assembly); } public TypeSpec GetAsyncMethodBuilder() { return null; } public TypeSpec GetAttributeCoClass() { return Element.MemberDefinition.GetAttributeCoClass(); } public string GetAttributeDefaultMember() { return Element.MemberDefinition.GetAttributeDefaultMember(); } public void LoadMembers(TypeSpec declaringType, bool onlyTypes, ref MemberCache cache) { Element.MemberDefinition.LoadMembers(declaringType, onlyTypes, ref cache); } public string[] ConditionalConditions() { return Element.MemberDefinition.ConditionalConditions(); } public void SetIsAssigned() { Element.MemberDefinition.SetIsAssigned(); } public void SetIsUsed() { Element.MemberDefinition.SetIsUsed(); } } internal class ArrayContainer : ElementTypeSpec { public struct TypeRankPair : IEquatable { private TypeSpec ts; private int rank; public TypeRankPair(TypeSpec ts, int rank) { this.ts = ts; this.rank = rank; } public override int GetHashCode() { return ts.GetHashCode() ^ rank.GetHashCode(); } public bool Equals(TypeRankPair other) { return other.ts == ts && other.rank == rank; } } private readonly int rank; private readonly ModuleContainer module; public override IList Interfaces => BaseType.Interfaces; public int Rank => rank; private ArrayContainer(ModuleContainer module, TypeSpec element, int rank) : base(MemberKind.ArrayType, element, null) { this.module = module; this.rank = rank; } public MethodInfo GetConstructor() { ModuleBuilder builder = module.Builder; Type[] array = new Type[rank]; for (int i = 0; i < rank; i++) { array[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo(); } return builder.GetArrayMethod(GetMetaInfo(), Constructor.ConstructorName, CallingConventions.HasThis, null, array); } public MethodInfo GetAddressMethod() { ModuleBuilder builder = module.Builder; Type[] array = new Type[rank]; for (int i = 0; i < rank; i++) { array[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo(); } return builder.GetArrayMethod(GetMetaInfo(), "Address", CallingConventions.Standard | CallingConventions.HasThis, ReferenceContainer.MakeType(module, base.Element).GetMetaInfo(), array); } public MethodInfo GetGetMethod() { ModuleBuilder builder = module.Builder; Type[] array = new Type[rank]; for (int i = 0; i < rank; i++) { array[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo(); } return builder.GetArrayMethod(GetMetaInfo(), "Get", CallingConventions.Standard | CallingConventions.HasThis, base.Element.GetMetaInfo(), array); } public MethodInfo GetSetMethod() { ModuleBuilder builder = module.Builder; Type[] array = new Type[rank + 1]; for (int i = 0; i < rank; i++) { array[i] = module.Compiler.BuiltinTypes.Int.GetMetaInfo(); } array[rank] = base.Element.GetMetaInfo(); return builder.GetArrayMethod(GetMetaInfo(), "Set", CallingConventions.Standard | CallingConventions.HasThis, module.Compiler.BuiltinTypes.Void.GetMetaInfo(), array); } public override Type GetMetaInfo() { if ((object)info == null) { if (rank == 1) { info = base.Element.GetMetaInfo().MakeArrayType(); } else { info = base.Element.GetMetaInfo().MakeArrayType(rank); } } return info; } protected override string GetPostfixSignature() { return GetPostfixSignature(rank); } public static string GetPostfixSignature(int rank) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("["); for (int i = 1; i < rank; i++) { stringBuilder.Append(","); } stringBuilder.Append("]"); return stringBuilder.ToString(); } public override string GetSignatureForDocumentation(bool explicitName) { StringBuilder stringBuilder = new StringBuilder(); GetElementSignatureForDocumentation(stringBuilder, explicitName); return stringBuilder.ToString(); } private void GetElementSignatureForDocumentation(StringBuilder sb, bool explicitName) { if (!(base.Element is ArrayContainer arrayContainer)) { sb.Append(base.Element.GetSignatureForDocumentation(explicitName)); } else { arrayContainer.GetElementSignatureForDocumentation(sb, explicitName); } if (explicitName) { sb.Append(GetPostfixSignature(rank)); return; } sb.Append("["); for (int i = 1; i < rank; i++) { if (i == 1) { sb.Append("0:"); } sb.Append(",0:"); } sb.Append("]"); } public static ArrayContainer MakeType(ModuleContainer module, TypeSpec element) { return MakeType(module, element, 1); } public static ArrayContainer MakeType(ModuleContainer module, TypeSpec element, int rank) { TypeRankPair key = new TypeRankPair(element, rank); if (!module.ArrayTypesCache.TryGetValue(key, out var value)) { value = new ArrayContainer(module, element, rank); value.BaseType = module.Compiler.BuiltinTypes.Array; module.ArrayTypesCache.Add(key, value); } return value; } public override List ResolveMissingDependencies(MemberSpec caller) { return base.Element.ResolveMissingDependencies(caller); } } [DebuggerDisplay("{DisplayDebugInfo()}")] internal class ReferenceContainer : ElementTypeSpec { public override IList Interfaces => null; protected ReferenceContainer(TypeSpec element) : base(MemberKind.ByRef, element, null) { cache = null; } private string DisplayDebugInfo() { return "ref " + GetSignatureForError(); } public override Type GetMetaInfo() { if ((object)info == null) { info = base.Element.GetMetaInfo().MakeByRefType(); } return info; } public override string GetSignatureForError() { return base.Element.GetSignatureForError(); } public static ReferenceContainer MakeType(ModuleContainer module, TypeSpec element) { if (element.Kind == MemberKind.ByRef) { throw new ArgumentException(); } if (!module.ReferenceTypesCache.TryGetValue(element, out var value)) { value = new ReferenceContainer(element); module.ReferenceTypesCache.Add(element, value); } return value; } protected override void InitializeMemberCache(bool onlyTypes) { cache = base.Element.MemberCache; } } [DebuggerDisplay("{DisplayDebugInfo()}")] internal class ReadOnlyReferenceContainer : ReferenceContainer { public ReadOnlyReferenceContainer(TypeSpec element) : base(element) { } private string DisplayDebugInfo() { return "ref readonly " + GetSignatureForError(); } public new static ReferenceContainer MakeType(ModuleContainer module, TypeSpec element) { if (element.Kind == MemberKind.ByRef) { throw new ArgumentException(); } if (!module.ReadonlyReferenceTypesCache.TryGetValue(element, out var value)) { value = new ReadOnlyReferenceContainer(element); module.ReadonlyReferenceTypesCache.Add(element, value); } return value; } } internal class PointerContainer : ElementTypeSpec { public override IList Interfaces => null; private PointerContainer(TypeSpec element) : base(MemberKind.PointerType, element, null) { state &= ~StateFlags.CLSCompliant_Undetected; } public override Type GetMetaInfo() { if ((object)info == null) { info = base.Element.GetMetaInfo().MakePointerType(); } return info; } protected override string GetPostfixSignature() { return "*"; } public static PointerContainer MakeType(ModuleContainer module, TypeSpec element) { if (!module.PointerTypesCache.TryGetValue(element, out var value)) { value = new PointerContainer(element); module.PointerTypesCache.Add(element, value); } return value; } } internal class MissingTypeSpecReference { public TypeSpec Type { get; private set; } public MemberSpec Caller { get; private set; } public MissingTypeSpecReference(TypeSpec type, MemberSpec caller) { Type = type; Caller = caller; } } internal static class SkipVisibilityExt { private static readonly bool _IsMono; private static readonly bool _MonoAssemblyNameHasArch; private static readonly FieldInfo dynAssField; private static List generatedAssemblies; static SkipVisibilityExt() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) _IsMono = (object)Type.GetType("Mono.Runtime") != null; _MonoAssemblyNameHasArch = new AssemblyName("Dummy, ProcessorArchitecture=MSIL").ProcessorArchitecture == ProcessorArchitecture.MSIL; dynAssField = typeof(AssemblyBuilder).GetField("dynamic_assembly", BindingFlags.Instance | BindingFlags.NonPublic); generatedAssemblies = new List(); new Hook((MethodBase)typeof(AppDomain).GetMethod("GetAssemblies"), typeof(SkipVisibilityExt).GetMethod("GetAssembliesPatch")).Apply(); } public static Assembly[] GetAssembliesPatch(Func orig, AppDomain self) { List list = new List(orig(self)); list.AddRange(generatedAssemblies); return list.ToArray(); } public unsafe static void MarkCorlibInternal(this AssemblyBuilder asm) { if (_IsMono && (object)dynAssField != null) { UIntPtr uIntPtr = (UIntPtr)dynAssField.GetValue(asm); if (!(uIntPtr == UIntPtr.Zero)) { int num = IntPtr.Size + IntPtr.Size + IntPtr.Size + IntPtr.Size + IntPtr.Size + IntPtr.Size + 20 + 4 + 4 + 4 + (_MonoAssemblyNameHasArch ? ((!(typeof(object).Assembly.GetName().Name == "System.Private.CoreLib")) ? ((IntPtr.Size == 4) ? 12 : 16) : ((IntPtr.Size == 4) ? 20 : 24)) : ((typeof(object).Assembly.GetName().Name == "System.Private.CoreLib") ? 16 : 8)) + IntPtr.Size + IntPtr.Size + 1 + 1 + 1; byte* ptr = (byte*)((ulong)uIntPtr + (ulong)num); *ptr = 1; generatedAssemblies.Add(asm); } } } } internal abstract class StructuralVisitor { public virtual void Visit(MemberCore member) { } private void VisitTypeContainer(TypeContainer tc) { foreach (TypeContainer container in tc.Containers) { container.Accept(this); } } private void VisitTypeContainer(TypeDefinition tc) { foreach (MemberCore member in tc.Members) { member.Accept(this); } } public virtual void Visit(ModuleContainer module) { VisitTypeContainer(module); } public virtual void Visit(UsingNamespace un) { } public virtual void Visit(UsingAliasNamespace uan) { } public virtual void Visit(UsingExternAlias uea) { } public virtual void Visit(NamespaceContainer ns) { VisitTypeContainer(ns); } public virtual void Visit(CompilationSourceFile csf) { VisitTypeContainer(csf); } public virtual void Visit(Class c) { VisitTypeContainer(c); } public virtual void Visit(Struct s) { VisitTypeContainer(s); } public virtual void Visit(Interface i) { VisitTypeContainer(i); } public virtual void Visit(Delegate d) { } public virtual void Visit(Enum e) { VisitTypeContainer(e); } public virtual void Visit(FixedField f) { } public virtual void Visit(Const c) { } public virtual void Visit(Field f) { } public virtual void Visit(Operator o) { } public virtual void Visit(Indexer i) { } public virtual void Visit(Method m) { } public virtual void Visit(Property p) { } public virtual void Visit(Constructor c) { } public virtual void Visit(Destructor d) { } public virtual void Visit(EventField e) { } public virtual void Visit(EventProperty ep) { } public virtual void Visit(EnumMember em) { } public virtual object Visit(Statement stmt) { return null; } public virtual object Visit(BlockVariable blockVariableDeclaration) { return null; } public virtual object Visit(BlockConstant blockConstantDeclaration) { return null; } public virtual object Visit(EmptyStatement emptyStatement) { return null; } public virtual object Visit(EmptyExpressionStatement emptyExpressionStatement) { return null; } public virtual object Visit(EmptyExpression emptyExpression) { return null; } public virtual object Visit(ErrorExpression errorExpression) { return null; } public virtual object Visit(If ifStatement) { return null; } public virtual object Visit(Do doStatement) { return null; } public virtual object Visit(While whileStatement) { return null; } public virtual object Visit(For forStatement) { return null; } public virtual object Visit(StatementExpression statementExpression) { return null; } public virtual object Visit(StatementErrorExpression errorStatement) { return null; } public virtual object Visit(Return returnStatement) { return null; } public virtual object Visit(Goto gotoStatement) { return null; } public virtual object Visit(LabeledStatement labeledStatement) { return null; } public virtual object Visit(SwitchLabel switchLabel) { return null; } public virtual object Visit(GotoDefault gotoDefault) { return null; } public virtual object Visit(GotoCase gotoCase) { return null; } public virtual object Visit(Throw throwStatement) { return null; } public virtual object Visit(Break breakStatement) { return null; } public virtual object Visit(Continue continueStatement) { return null; } public virtual object Visit(Block blockStatement) { return null; } public virtual object Visit(Switch switchStatement) { return null; } public virtual object Visit(StatementList statementList) { return null; } public virtual object Visit(Lock lockStatement) { return null; } public virtual object Visit(Unchecked uncheckedStatement) { return null; } public virtual object Visit(Checked checkedStatement) { return null; } public virtual object Visit(Unsafe unsafeStatement) { return null; } public virtual object Visit(Fixed fixedStatement) { return null; } public virtual object Visit(TryFinally tryFinallyStatement) { return null; } public virtual object Visit(TryCatch tryCatchStatement) { return null; } public virtual object Visit(Using usingStatement) { return null; } public virtual object Visit(Foreach foreachStatement) { return null; } public virtual object Visit(Yield yieldStatement) { return null; } public virtual object Visit(YieldBreak yieldBreakStatement) { return null; } public virtual object Visit(Expression expression) { return null; } public virtual object Visit(MemberAccess memberAccess) { return null; } public virtual object Visit(QualifiedAliasMember qualifiedAliasMember) { return null; } public virtual object Visit(LocalVariableReference localVariableReference) { return null; } public virtual object Visit(Constant constant) { return null; } public virtual object Visit(BooleanExpression booleanExpression) { return null; } public virtual object Visit(SimpleName simpleName) { return null; } public virtual object Visit(ParenthesizedExpression parenthesizedExpression) { return null; } public virtual object Visit(Unary unaryExpression) { return null; } public virtual object Visit(UnaryMutator unaryMutatorExpression) { return null; } public virtual object Visit(Indirection indirectionExpression) { return null; } public virtual object Visit(Is isExpression) { return null; } public virtual object Visit(As asExpression) { return null; } public virtual object Visit(Cast castExpression) { return null; } public virtual object Visit(ComposedCast composedCast) { return null; } public virtual object Visit(DefaultValueExpression defaultValueExpression) { return null; } public virtual object Visit(DefaultParameterValueExpression defaultParameterValueExpression) { return null; } public virtual object Visit(Binary binaryExpression) { return null; } public virtual object Visit(NullCoalescingOperator nullCoalescingOperator) { return null; } public virtual object Visit(Conditional conditionalExpression) { return null; } public virtual object Visit(Invocation invocationExpression) { return null; } public virtual object Visit(New newExpression) { return null; } public virtual object Visit(NewAnonymousType newAnonymousType) { return null; } public virtual object Visit(NewInitialize newInitializeExpression) { return null; } public virtual object Visit(ArrayCreation arrayCreationExpression) { return null; } public virtual object Visit(This thisExpression) { return null; } public virtual object Visit(ArglistAccess argListAccessExpression) { return null; } public virtual object Visit(Arglist argListExpression) { return null; } public virtual object Visit(TypeOf typeOfExpression) { return null; } public virtual object Visit(SizeOf sizeOfExpression) { return null; } public virtual object Visit(CheckedExpr checkedExpression) { return null; } public virtual object Visit(UnCheckedExpr uncheckedExpression) { return null; } public virtual object Visit(ElementAccess elementAccessExpression) { return null; } public virtual object Visit(BaseThis baseAccessExpression) { return null; } public virtual object Visit(StackAlloc stackAllocExpression) { return null; } public virtual object Visit(SimpleAssign simpleAssign) { return null; } public virtual object Visit(CompoundAssign compoundAssign) { return null; } public virtual object Visit(TypeExpression typeExpression) { return null; } public virtual object Visit(AnonymousMethodExpression anonymousMethodExpression) { return null; } public virtual object Visit(LambdaExpression lambdaExpression) { return null; } public virtual object Visit(ConstInitializer constInitializer) { return null; } public virtual object Visit(ArrayInitializer arrayInitializer) { return null; } public virtual object Visit(QueryExpression queryExpression) { return null; } public virtual object Visit(QueryStartClause queryExpression) { return null; } public virtual object Visit(SelectMany selectMany) { return null; } public virtual object Visit(Select select) { return null; } public virtual object Visit(GroupBy groupBy) { return null; } public virtual object Visit(Let let) { return null; } public virtual object Visit(Where where) { return null; } public virtual object Visit(Join join) { return null; } public virtual object Visit(GroupJoin groupJoin) { return null; } public virtual object Visit(OrderByAscending orderByAscending) { return null; } public virtual object Visit(OrderByDescending orderByDescending) { return null; } public virtual object Visit(ThenByAscending thenByAscending) { return null; } public virtual object Visit(ThenByDescending thenByDescending) { return null; } public virtual object Visit(RefValueExpr refValueExpr) { return null; } public virtual object Visit(RefTypeExpr refTypeExpr) { return null; } public virtual object Visit(MakeRefExpr makeRefExpr) { return null; } public virtual object Visit(Await awaitExpr) { return null; } } } namespace Mono.CSharp.Nullable { internal class NullableType : TypeExpr { private readonly TypeSpec underlying; public NullableType(TypeSpec type, Location loc) { underlying = type; base.loc = loc; } public override TypeSpec ResolveAsType(IMemberContext ec, bool allowUnboundTypeArguments = false) { eclass = ExprClass.Type; TypeSpec typeSpec = ec.Module.PredefinedTypes.Nullable.Resolve(); if (typeSpec == null) { return null; } TypeArguments args = new TypeArguments(new TypeExpression(underlying, loc)); GenericTypeExpr genericTypeExpr = new GenericTypeExpr(typeSpec, args, loc); type = genericTypeExpr.ResolveAsType(ec); return type; } } internal static class NullableInfo { public static MethodSpec GetConstructor(TypeSpec nullableType) { return (MethodSpec)MemberCache.FindMember(nullableType, MemberFilter.Constructor(ParametersCompiled.CreateFullyResolved(GetUnderlyingType(nullableType))), BindingRestriction.DeclaredOnly); } public static MethodSpec GetHasValue(TypeSpec nullableType) { return (MethodSpec)MemberCache.FindMember(nullableType, MemberFilter.Method("get_HasValue", 0, ParametersCompiled.EmptyReadOnlyParameters, null), BindingRestriction.None); } public static MethodSpec GetGetValueOrDefault(TypeSpec nullableType) { return (MethodSpec)MemberCache.FindMember(nullableType, MemberFilter.Method("GetValueOrDefault", 0, ParametersCompiled.EmptyReadOnlyParameters, null), BindingRestriction.None); } public static MethodSpec GetValue(TypeSpec nullableType) { return (MethodSpec)MemberCache.FindMember(nullableType, MemberFilter.Method("get_Value", 0, ParametersCompiled.EmptyReadOnlyParameters, null), BindingRestriction.None); } public static TypeSpec GetUnderlyingType(TypeSpec nullableType) { return ((InflatedTypeSpec)nullableType).TypeArguments[0]; } public static TypeSpec GetEnumUnderlyingType(ModuleContainer module, TypeSpec nullableEnum) { return MakeType(module, EnumSpec.GetUnderlyingType(GetUnderlyingType(nullableEnum))); } public static TypeSpec MakeType(ModuleContainer module, TypeSpec underlyingType) { return module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType(module, new TypeSpec[1] { underlyingType }); } } internal class Unwrap : Expression, IMemoryLocation { private Expression expr; private LocalTemporary temp; private Expression temp_field; private readonly bool useDefaultValue; public Expression Original => expr; public override bool IsNull => expr.IsNull; private LocalTemporary LocalVariable { get { if (temp == null && temp_field == null) { temp = new LocalTemporary(expr.Type); } return temp; } } public Unwrap(Expression expr, bool useDefaultValue = true) { this.expr = expr; loc = expr.Location; this.useDefaultValue = useDefaultValue; type = NullableInfo.GetUnderlyingType(expr.Type); eclass = expr.eclass; } public override bool ContainsEmitWithAwait() { return expr.ContainsEmitWithAwait(); } public static Expression Create(Expression expr) { if (!(expr is Wrap { Child: var child })) { return Create(expr, useDefaultValue: false); } return child; } public static Expression CreateUnwrapped(Expression expr) { if (!(expr is Wrap { Child: var child })) { return Create(expr, useDefaultValue: true); } return child; } public static Unwrap Create(Expression expr, bool useDefaultValue) { return new Unwrap(expr, useDefaultValue); } public override Expression CreateExpressionTree(ResolveContext ec) { return expr.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext ec) { return this; } public override Expression DoResolveLValue(ResolveContext ec, Expression right_side) { expr = expr.DoResolveLValue(ec, right_side); return this; } public override void Emit(EmitContext ec) { Store(ec); CallEmitter callEmitter = new CallEmitter { InstanceExpression = this }; if (useDefaultValue) { callEmitter.EmitPredefined(ec, NullableInfo.GetGetValueOrDefault(expr.Type), null); } else { callEmitter.EmitPredefined(ec, NullableInfo.GetValue(expr.Type), null); } } public void EmitCheck(EmitContext ec) { Store(ec); CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = this; callEmitter.EmitPredefined(ec, NullableInfo.GetHasValue(expr.Type), null); } public override void EmitSideEffect(EmitContext ec) { expr.EmitSideEffect(ec); } public override Expression EmitToField(EmitContext ec) { if (temp_field == null) { temp_field = expr.EmitToField(ec); } return this; } public override bool Equals(object obj) { return obj is Unwrap unwrap && expr.Equals(unwrap.expr); } public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); } public override int GetHashCode() { return expr.GetHashCode(); } public void Store(EmitContext ec) { if (temp == null && temp_field == null && !(expr is VariableReference)) { expr.Emit(ec); LocalVariable.Store(ec); } } public void Load(EmitContext ec) { if (temp_field != null) { temp_field.Emit(ec); } else if (expr is VariableReference) { expr.Emit(ec); } else { LocalVariable.Emit(ec); } } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return expr.MakeExpression(ctx); } public void AddressOf(EmitContext ec, AddressOp mode) { IMemoryLocation memoryLocation; if (temp_field != null) { memoryLocation = temp_field as IMemoryLocation; if (memoryLocation == null) { LocalTemporary localTemporary = new LocalTemporary(temp_field.Type); temp_field.Emit(ec); localTemporary.Store(ec); memoryLocation = localTemporary; } } else { memoryLocation = expr as VariableReference; } if (memoryLocation != null) { memoryLocation.AddressOf(ec, mode); } else { LocalVariable.AddressOf(ec, mode); } } } internal class UnwrapCall : CompositeExpression { public UnwrapCall(Expression expr) : base(expr) { } protected override Expression DoResolve(ResolveContext rc) { base.DoResolve(rc); if (type != null) { type = NullableInfo.GetUnderlyingType(type); } return this; } public override void Emit(EmitContext ec) { CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = base.Child; callEmitter.EmitPredefined(ec, NullableInfo.GetValue(base.Child.Type), null); } } internal class Wrap : TypeCast { private Wrap(Expression expr, TypeSpec type) : base(expr, type) { eclass = ExprClass.Value; } public override Expression CreateExpressionTree(ResolveContext ec) { if (child is TypeCast typeCast) { child.Type = type; return typeCast.CreateExpressionTree(ec); } if (child is UserCast userCast) { child.Type = type; return userCast.CreateExpressionTree(ec); } return base.CreateExpressionTree(ec); } public static Expression Create(Expression expr, TypeSpec type) { if (expr is Unwrap unwrap && expr.Type == NullableInfo.GetUnderlyingType(type)) { return unwrap.Original; } return new Wrap(expr, type); } public override void Emit(EmitContext ec) { child.Emit(ec); ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); } } internal class LiftedNull : NullConstant, IMemoryLocation { private LiftedNull(TypeSpec nullable_type, Location loc) : base(nullable_type, loc) { eclass = ExprClass.Value; } public static Constant Create(TypeSpec nullable, Location loc) { return new LiftedNull(nullable, loc); } public static Constant CreateFromExpression(ResolveContext rc, Expression e) { if (!rc.HasSet(ResolveContext.Options.ExpressionTreeConversion)) { rc.Report.Warning(458, 2, e.Location, "The result of the expression is always `null' of type `{0}'", e.Type.GetSignatureForError()); } return ReducedExpression.Create(Create(e.Type, e.Location), e); } public override void Emit(EmitContext ec) { LocalTemporary localTemporary = new LocalTemporary(type); localTemporary.AddressOf(ec, AddressOp.Store); ec.Emit(OpCodes.Initobj, type); localTemporary.Emit(ec); localTemporary.Release(ec); } public void AddressOf(EmitContext ec, AddressOp Mode) { LocalTemporary localTemporary = new LocalTemporary(type); localTemporary.AddressOf(ec, AddressOp.Store); ec.Emit(OpCodes.Initobj, type); localTemporary.AddressOf(ec, Mode); } } internal class LiftedConversion : Expression, IMemoryLocation { private Expression expr; private Expression null_value; private Unwrap unwrap; public override bool IsNull => expr.IsNull; public LiftedConversion(Expression expr, Unwrap unwrap, TypeSpec type) { this.expr = expr; this.unwrap = unwrap; loc = expr.Location; base.type = type; } public LiftedConversion(Expression expr, Expression unwrap, TypeSpec type) : this(expr, unwrap as Unwrap, type) { } public override bool ContainsEmitWithAwait() { return unwrap.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext ec) { return expr.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext ec) { if (unwrap == null) { if (type.IsNullableType) { return Wrap.Create(expr, type); } return expr; } if (type.IsNullableType) { if (!expr.Type.IsNullableType) { expr = Wrap.Create(expr, type); if (expr == null) { return null; } } null_value = LiftedNull.Create(type, loc); } else if (TypeSpec.IsValueType(type)) { null_value = LiftedNull.Create(type, loc); } else { null_value = new NullConstant(type, loc); } eclass = ExprClass.Value; return this; } public override void Emit(EmitContext ec) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); unwrap.EmitCheck(ec); ec.Emit(OpCodes.Brfalse, label); expr.Emit(ec); ec.Emit(OpCodes.Br, label2); ec.MarkLabel(label); null_value.Emit(ec); ec.MarkLabel(label2); } public override void FlowAnalysis(FlowAnalysisContext fc) { expr.FlowAnalysis(fc); } public void AddressOf(EmitContext ec, AddressOp mode) { unwrap.AddressOf(ec, mode); } } internal class LiftedUnaryOperator : Unary, IMemoryLocation { private Unwrap unwrap; private Expression user_operator; public LiftedUnaryOperator(Operator op, Expression expr, Location loc) : base(op, expr, loc) { } public void AddressOf(EmitContext ec, AddressOp mode) { unwrap.AddressOf(ec, mode); } public override Expression CreateExpressionTree(ResolveContext ec) { if (user_operator != null) { return user_operator.CreateExpressionTree(ec); } if (Oper == Operator.UnaryPlus) { return Expr.CreateExpressionTree(ec); } return base.CreateExpressionTree(ec); } protected override Expression DoResolve(ResolveContext ec) { unwrap = Unwrap.Create(Expr, useDefaultValue: false); if (unwrap == null) { return null; } Expression expression = base.ResolveOperator(ec, unwrap); if (expression == null) { Error_OperatorCannotBeApplied(ec, loc, Unary.OperName(Oper), Expr.Type); return null; } if (expression != this) { if (user_operator == null) { return expression; } } else { expression = (Expr = LiftExpression(ec, Expr)); } if (expression == null) { return null; } eclass = ExprClass.Value; type = expression.Type; return this; } public override void Emit(EmitContext ec) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); unwrap.EmitCheck(ec); ec.Emit(OpCodes.Brfalse, label); if (user_operator != null) { user_operator.Emit(ec); } else { EmitOperator(ec, NullableInfo.GetUnderlyingType(type)); } ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); LiftedNull.Create(type, loc).Emit(ec); ec.MarkLabel(label2); } private static Expression LiftExpression(ResolveContext ec, Expression expr) { NullableType nullableType = new NullableType(expr.Type, expr.Location); if (nullableType.ResolveAsType(ec) == null) { return null; } expr.Type = nullableType.Type; return expr; } protected override Expression ResolveEnumOperator(ResolveContext ec, Expression expr, TypeSpec[] predefined) { expr = base.ResolveEnumOperator(ec, expr, predefined); if (expr == null) { return null; } Expr = LiftExpression(ec, Expr); return LiftExpression(ec, expr); } protected override Expression ResolveUserOperator(ResolveContext ec, Expression expr) { expr = base.ResolveUserOperator(ec, expr); if (expr == null) { return null; } if (Expr is Unwrap) { user_operator = LiftExpression(ec, expr); return user_operator; } return expr; } } internal class LiftedBinaryOperator : Expression { public Binary Binary { get; private set; } public Expression Left { get; set; } public Expression Right { get; set; } public Unwrap UnwrapLeft { get; set; } public Unwrap UnwrapRight { get; set; } public MethodSpec UserOperator { get; set; } private bool IsBitwiseBoolean => (Binary.Oper == Binary.Operator.BitwiseAnd || Binary.Oper == Binary.Operator.BitwiseOr) && ((UnwrapLeft != null && UnwrapLeft.Type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive) || (UnwrapRight != null && UnwrapRight.Type.BuiltinType == BuiltinTypeSpec.Type.FirstPrimitive)); public LiftedBinaryOperator(Binary b) { Binary = b; loc = b.Location; } public override bool ContainsEmitWithAwait() { return Left.ContainsEmitWithAwait() || Right.ContainsEmitWithAwait(); } public override Expression CreateExpressionTree(ResolveContext rc) { if (UserOperator != null) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(Binary.Left)); arguments.Add(new Argument(Binary.Right)); UserOperatorCall userOperatorCall = new UserOperatorCall(UserOperator, arguments, Binary.CreateExpressionTree, loc); return userOperatorCall.CreateExpressionTree(rc); } return Binary.CreateExpressionTree(rc); } protected override Expression DoResolve(ResolveContext rc) { if (rc.IsRuntimeBinder) { if (UnwrapLeft == null && !Left.Type.IsNullableType) { Left = LiftOperand(rc, Left); } if (UnwrapRight == null && !Right.Type.IsNullableType) { Right = LiftOperand(rc, Right); } } else { if (UnwrapLeft == null && Left != null && Left.Type.IsNullableType) { Left = Unwrap.CreateUnwrapped(Left); UnwrapLeft = Left as Unwrap; } if (UnwrapRight == null && Right != null && Right.Type.IsNullableType) { Right = Unwrap.CreateUnwrapped(Right); UnwrapRight = Right as Unwrap; } if (Left.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal) { IList userOperator = MemberCache.GetUserOperator(Left.Type, Binary.ConvertBinaryToUserOperator(Binary.Oper), declaredOnly: false); Arguments args = new Arguments(2); args.Add(new Argument(Left)); args.Add(new Argument(Right)); UserOperator = new OverloadResolver(userOperator, OverloadResolver.Restrictions.ProbingOnly | OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded, loc).ResolveOperator(rc, ref args); } } type = Binary.Type; eclass = Binary.eclass; return this; } private Expression LiftOperand(ResolveContext rc, Expression expr) { TypeSpec typeSpec = ((!expr.IsNull) ? expr.Type : (Left.IsNull ? Right.Type : Left.Type)); if (!typeSpec.IsNullableType) { typeSpec = NullableInfo.MakeType(rc.Module, typeSpec); } return Wrap.Create(expr, typeSpec); } public override void Emit(EmitContext ec) { if (IsBitwiseBoolean && UserOperator == null) { EmitBitwiseBoolean(ec); return; } if ((Binary.Oper & Binary.Operator.EqualityMask) != 0) { EmitEquality(ec); return; } Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); if (ec.HasSet(BuilderContext.Options.AsyncBody) && Right.ContainsEmitWithAwait()) { Left = Left.EmitToField(ec); Right = Right.EmitToField(ec); } if (UnwrapLeft != null) { UnwrapLeft.EmitCheck(ec); } if (UnwrapRight != null && !Binary.Left.Equals(Binary.Right)) { UnwrapRight.EmitCheck(ec); if (UnwrapLeft != null) { ec.Emit(OpCodes.And); } } ec.Emit(OpCodes.Brfalse, label); if (UserOperator != null) { Arguments arguments = new Arguments(2); arguments.Add(new Argument(Left)); arguments.Add(new Argument(Right)); default(CallEmitter).EmitPredefined(ec, UserOperator, arguments); } else { Binary.EmitOperator(ec, Left, Right); } if (type.IsNullableType) { ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); } ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); if ((Binary.Oper & Binary.Operator.ComparisonMask) != 0) { ec.EmitInt(0); } else { LiftedNull.Create(type, loc).Emit(ec); } ec.MarkLabel(label2); } private void EmitBitwiseBoolean(EmitContext ec) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); Label label3 = ec.DefineLabel(); Label label4 = ec.DefineLabel(); bool flag = Binary.Oper == Binary.Operator.BitwiseOr; if (UnwrapLeft != null && !Left.IsNull && UnwrapRight != null && !Right.IsNull) { if (ec.HasSet(BuilderContext.Options.AsyncBody) && Binary.Right.ContainsEmitWithAwait()) { Left = Left.EmitToField(ec); Right = Right.EmitToField(ec); } else { UnwrapLeft.Store(ec); UnwrapRight.Store(ec); } Left.Emit(ec); ec.Emit(OpCodes.Brtrue_S, label2); Right.Emit(ec); ec.Emit(OpCodes.Brtrue_S, label); UnwrapLeft.EmitCheck(ec); ec.Emit(OpCodes.Brfalse_S, label2); ec.MarkLabel(label); if (flag) { UnwrapRight.Load(ec); } else { UnwrapLeft.Load(ec); } ec.Emit(OpCodes.Br_S, label3); ec.MarkLabel(label2); if (flag) { UnwrapLeft.Load(ec); } else { UnwrapRight.Load(ec); } ec.MarkLabel(label3); return; } if (UnwrapLeft == null) { if (Left is BoolConstant) { UnwrapRight.Store(ec); ec.EmitInt(flag ? 1 : 0); ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); } else if (Left.IsNull) { UnwrapRight.Emit(ec); ec.Emit(flag ? OpCodes.Brfalse_S : OpCodes.Brtrue_S, label4); UnwrapRight.Load(ec); ec.Emit(OpCodes.Br_S, label3); ec.MarkLabel(label4); LiftedNull.Create(type, loc).Emit(ec); } else { Left.Emit(ec); UnwrapRight.Store(ec); ec.Emit(flag ? OpCodes.Brfalse_S : OpCodes.Brtrue_S, label2); ec.EmitInt(flag ? 1 : 0); ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); ec.Emit(OpCodes.Br_S, label3); ec.MarkLabel(label2); UnwrapRight.Load(ec); } } else { UnwrapLeft.Store(ec); if (Right is BoolConstant) { ec.EmitInt(flag ? 1 : 0); ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); } else if (Right.IsNull) { UnwrapLeft.Emit(ec); ec.Emit(flag ? OpCodes.Brfalse_S : OpCodes.Brtrue_S, label4); UnwrapLeft.Load(ec); ec.Emit(OpCodes.Br_S, label3); ec.MarkLabel(label4); LiftedNull.Create(type, loc).Emit(ec); } else if (Left.IsNull && UnwrapRight != null) { UnwrapRight.Emit(ec); ec.Emit(flag ? OpCodes.Brtrue_S : OpCodes.Brfalse_S, label2); LiftedNull.Create(type, loc).Emit(ec); ec.Emit(OpCodes.Br_S, label3); ec.MarkLabel(label2); UnwrapRight.Load(ec); } else { Right.Emit(ec); ec.Emit(flag ? OpCodes.Brfalse_S : OpCodes.Brtrue_S, label); ec.EmitInt(flag ? 1 : 0); ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); ec.Emit(OpCodes.Br_S, label3); ec.MarkLabel(label); UnwrapLeft.Load(ec); } } ec.MarkLabel(label3); } private void EmitEquality(EmitContext ec) { if (UnwrapLeft != null && Binary.Right.IsNull) { UnwrapLeft.EmitCheck(ec); if (Binary.Oper == Binary.Operator.Equality) { ec.EmitInt(0); ec.Emit(OpCodes.Ceq); } return; } if (UnwrapRight != null && Binary.Left.IsNull) { UnwrapRight.EmitCheck(ec); if (Binary.Oper == Binary.Operator.Equality) { ec.EmitInt(0); ec.Emit(OpCodes.Ceq); } return; } Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); if (UserOperator != null) { Expression expr = Left; if (UnwrapLeft != null) { UnwrapLeft.EmitCheck(ec); } else if (!(Left is VariableReference)) { Left.Emit(ec); LocalTemporary localTemporary = new LocalTemporary(Left.Type); localTemporary.Store(ec); expr = localTemporary; } if (UnwrapRight != null) { UnwrapRight.EmitCheck(ec); if (UnwrapLeft != null) { ec.Emit(OpCodes.Bne_Un, label); Label label3 = ec.DefineLabel(); UnwrapLeft.EmitCheck(ec); ec.Emit(OpCodes.Brtrue, label3); if (Binary.Oper == Binary.Operator.Equality) { ec.EmitInt(1); } else { ec.EmitInt(0); } ec.Emit(OpCodes.Br, label2); ec.MarkLabel(label3); } else { ec.Emit(OpCodes.Brfalse, label); } } else { ec.Emit(OpCodes.Brfalse, label); } Arguments arguments = new Arguments(2); arguments.Add(new Argument(expr)); arguments.Add(new Argument(Right)); default(CallEmitter).EmitPredefined(ec, UserOperator, arguments); } else { if (ec.HasSet(BuilderContext.Options.AsyncBody) && Binary.Right.ContainsEmitWithAwait()) { Left = Left.EmitToField(ec); Right = Right.EmitToField(ec); } Left.Emit(ec); Right.Emit(ec); ec.Emit(OpCodes.Bne_Un_S, label); if (UnwrapLeft != null) { UnwrapLeft.EmitCheck(ec); } if (UnwrapRight != null) { UnwrapRight.EmitCheck(ec); } if (UnwrapLeft != null && UnwrapRight != null) { if (Binary.Oper == Binary.Operator.Inequality) { ec.Emit(OpCodes.Xor); } else { ec.Emit(OpCodes.Ceq); } } else if (Binary.Oper == Binary.Operator.Inequality) { ec.EmitInt(0); ec.Emit(OpCodes.Ceq); } } ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); if (Binary.Oper == Binary.Operator.Inequality) { ec.EmitInt(1); } else { ec.EmitInt(0); } ec.MarkLabel(label2); } public override void FlowAnalysis(FlowAnalysisContext fc) { Binary.FlowAnalysis(fc); } public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx) { return Binary.MakeExpression(ctx, Left, Right); } } internal class NullCoalescingOperator : Expression { private Expression left; private Expression right; private Unwrap unwrap; private bool user_conversion_left; public Expression LeftExpression => left; public Expression RightExpression => right; public NullCoalescingOperator(Expression left, Expression right) { this.left = left; this.right = right; loc = left.Location; } public override Expression CreateExpressionTree(ResolveContext ec) { if (left is NullLiteral) { ec.Report.Error(845, loc, "An expression tree cannot contain a coalescing operator with null left side"); } UserCast userCast = left as UserCast; Expression expression = null; if (userCast != null) { left = userCast.Source; Arguments arguments = new Arguments(2); arguments.Add(new Argument(userCast.CreateExpressionTree(ec))); arguments.Add(new Argument(left.CreateExpressionTree(ec))); expression = CreateExpressionFactoryCall(ec, "Lambda", arguments); } Arguments arguments2 = new Arguments(3); arguments2.Add(new Argument(left.CreateExpressionTree(ec))); arguments2.Add(new Argument(right.CreateExpressionTree(ec))); if (expression != null) { arguments2.Add(new Argument(expression)); } return CreateExpressionFactoryCall(ec, "Coalesce", arguments2); } private Expression ConvertExpression(ResolveContext ec) { if (left.eclass == ExprClass.MethodGroup) { return null; } TypeSpec typeSpec = left.Type; if (typeSpec.IsNullableType) { unwrap = Unwrap.Create(left, useDefaultValue: false); if (unwrap == null) { return null; } if (right.IsNull) { return ReducedExpression.Create(left, this); } if (right.Type.IsNullableType) { Expression expression = ((right.Type == typeSpec) ? right : Convert.ImplicitNulableConversion(ec, right, typeSpec)); if (expression != null) { right = expression; type = typeSpec; return this; } } else { Expression expression = Convert.ImplicitConversion(ec, right, unwrap.Type, loc); if (expression != null) { left = unwrap; typeSpec = left.Type; if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { type = right.Type; left = Convert.ImplicitBoxingConversion(left, typeSpec, type); return this; } right = expression; type = typeSpec; return this; } } } else { if (!TypeSpec.IsReferenceType(typeSpec)) { if (typeSpec == InternalType.ThrowExpr) { return ReducedExpression.Create(right, this, canBeConstant: false).Resolve(ec); } return null; } if (Convert.ImplicitConversionExists(ec, right, typeSpec)) { if (right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { type = right.Type; return this; } Constant constant = left as Constant; if (constant != null && !constant.IsDefaultValue) { return ReducedExpression.Create(constant, this, canBeConstant: false); } if (right.IsNull || constant != null) { if (right is NullLiteral && typeSpec == right.Type) { return null; } return ReducedExpression.Create((constant != null) ? right : left, this, canBeConstant: false); } right = Convert.ImplicitConversion(ec, right, typeSpec, loc); type = typeSpec; return this; } } TypeSpec target_type = right.Type; if (!Convert.ImplicitConversionExists(ec, unwrap ?? left, target_type) || right.eclass == ExprClass.MethodGroup) { return null; } if (left.IsNull) { return ReducedExpression.Create(right, this, canBeConstant: false).Resolve(ec); } left = Convert.ImplicitConversion(ec, unwrap ?? left, target_type, loc); user_conversion_left = left is UserCast; type = target_type; return this; } public override bool ContainsEmitWithAwait() { if (unwrap != null) { return unwrap.ContainsEmitWithAwait() || right.ContainsEmitWithAwait(); } return left.ContainsEmitWithAwait() || right.ContainsEmitWithAwait(); } protected override Expression DoResolve(ResolveContext ec) { left = left.Resolve(ec); right = right.Resolve(ec); if (left == null || right == null) { return null; } eclass = ExprClass.Value; Expression expression = ConvertExpression(ec); if (expression == null) { Binary.Error_OperatorCannotBeApplied(ec, left, right, "??", loc); return null; } return expression; } public override void Emit(EmitContext ec) { Label label = ec.DefineLabel(); if (unwrap != null) { Label label2 = ec.DefineLabel(); unwrap.EmitCheck(ec); ec.Emit(OpCodes.Brfalse, label2); if (type.IsNullableType && TypeSpecComparer.IsEqual(NullableInfo.GetUnderlyingType(type), unwrap.Type)) { unwrap.Load(ec); } else { left.Emit(ec); } ec.Emit(OpCodes.Br, label); ec.MarkLabel(label2); right.Emit(ec); ec.MarkLabel(label); return; } if (user_conversion_left) { UserCast userCast = (UserCast)left; userCast.Source.Emit(ec); LocalTemporary localTemporary; if (!(userCast.Source is VariableReference)) { localTemporary = new LocalTemporary(userCast.Source.Type); localTemporary.Store(ec); localTemporary.Emit(ec); userCast.Source = localTemporary; } else { localTemporary = null; } Label label3 = ec.DefineLabel(); ec.Emit(OpCodes.Brfalse_S, label3); left.Emit(ec); ec.Emit(OpCodes.Br, label); ec.MarkLabel(label3); localTemporary?.Release(ec); } else { left.Emit(ec); ec.Emit(OpCodes.Dup); if (left.Type.IsGenericParameter) { ec.Emit(OpCodes.Box, left.Type); } ec.Emit(OpCodes.Brtrue, label); ec.Emit(OpCodes.Pop); } right.Emit(ec); ec.MarkLabel(label); } public override void FlowAnalysis(FlowAnalysisContext fc) { left.FlowAnalysis(fc); DefiniteAssignmentBitSet definiteAssignment = fc.BranchDefiniteAssignment(); right.FlowAnalysis(fc); fc.DefiniteAssignment = definiteAssignment; } protected override void CloneTo(CloneContext clonectx, Expression t) { NullCoalescingOperator nullCoalescingOperator = (NullCoalescingOperator)t; nullCoalescingOperator.left = left.Clone(clonectx); nullCoalescingOperator.right = right.Clone(clonectx); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class LiftedUnaryMutator : UnaryMutator { public LiftedUnaryMutator(Mode mode, Expression expr, Location loc) : base(mode, expr, loc) { } protected override Expression DoResolve(ResolveContext ec) { Expression expression = expr; expr = Unwrap.Create(expr); Expression result = DoResolveOperation(ec); expr = expression; type = expr.Type; return result; } protected override void EmitOperation(EmitContext ec) { Label label = ec.DefineLabel(); Label label2 = ec.DefineLabel(); LocalTemporary localTemporary = new LocalTemporary(type); localTemporary.Store(ec); CallEmitter callEmitter = default(CallEmitter); callEmitter.InstanceExpression = localTemporary; callEmitter.EmitPredefined(ec, NullableInfo.GetHasValue(expr.Type), null); ec.Emit(OpCodes.Brfalse, label); callEmitter = default(CallEmitter); callEmitter.InstanceExpression = localTemporary; callEmitter.EmitPredefined(ec, NullableInfo.GetGetValueOrDefault(expr.Type), null); localTemporary.Release(ec); base.EmitOperation(ec); ec.Emit(OpCodes.Newobj, NullableInfo.GetConstructor(type)); ec.Emit(OpCodes.Br_S, label2); ec.MarkLabel(label); LiftedNull.Create(type, loc).Emit(ec); ec.MarkLabel(label2); } } } namespace Mono.CSharp.Linq { internal class QueryExpression : AQueryClause { protected override string MethodName { get { throw new NotSupportedException(); } } public QueryExpression(AQueryClause start) : base(null, null, start.Location) { next = start; } public override Expression BuildQueryClause(ResolveContext ec, Expression lSide, Parameter parentParameter) { return next.BuildQueryClause(ec, lSide, parentParameter); } protected override Expression DoResolve(ResolveContext ec) { int counter = QueryBlock.TransparentParameter.Counter; Expression expression = BuildQueryClause(ec, null, null); if (expression != null) { expression = expression.Resolve(ec); } if (ec.IsInProbingMode) { QueryBlock.TransparentParameter.Counter = counter; } return expression; } } internal abstract class AQueryClause : ShimExpression { protected class QueryExpressionAccess : MemberAccess { public QueryExpressionAccess(Expression expr, string methodName, Location loc) : base(expr, methodName, loc) { } public QueryExpressionAccess(Expression expr, string methodName, TypeArguments typeArguments, Location loc) : base(expr, methodName, typeArguments, loc) { } public override void Error_TypeDoesNotContainDefinition(ResolveContext ec, TypeSpec type, string name) { ec.Report.Error(1935, loc, "An implementation of `{0}' query expression pattern could not be found. Are you missing `System.Linq' using directive or `System.Core.dll' assembly reference?", name); } } protected class QueryExpressionInvocation : Invocation, OverloadResolver.IErrorHandler { public QueryExpressionInvocation(QueryExpressionAccess expr, Arguments arguments) : base(expr, arguments) { } protected override MethodGroupExpr DoResolveOverload(ResolveContext rc) { using (rc.Set(ResolveContext.Options.QueryClauseScope)) { return mg.OverloadResolve(rc, ref arguments, this, OverloadResolver.Restrictions.None); } } protected override Expression DoResolveDynamic(ResolveContext ec, Expression memberExpr) { ec.Report.Error(1979, loc, "Query expressions with a source or join sequence of type `dynamic' are not allowed"); return null; } bool OverloadResolver.IErrorHandler.AmbiguousCandidates(ResolveContext ec, MemberSpec best, MemberSpec ambiguous) { Expression expression = ((!(mg is ExtensionMethodGroupExpr extensionMethodGroupExpr)) ? mg.InstanceExpression : extensionMethodGroupExpr.ExtensionExpression); ec.Report.SymbolRelatedToPreviousError(best); ec.Report.SymbolRelatedToPreviousError(ambiguous); ec.Report.Error(1940, loc, "Ambiguous implementation of the query pattern `{0}' for source type `{1}'", best.Name, expression.Type.GetSignatureForError()); return true; } bool OverloadResolver.IErrorHandler.ArgumentMismatch(ResolveContext rc, MemberSpec best, Argument arg, int index) { return false; } bool OverloadResolver.IErrorHandler.NoArgumentMatch(ResolveContext rc, MemberSpec best) { return false; } bool OverloadResolver.IErrorHandler.TypeInferenceFailed(ResolveContext rc, MemberSpec best) { MethodSpec methodSpec = (MethodSpec)best; TypeSpec typeSpec = methodSpec.Parameters.ExtensionMethodType; if (typeSpec != null) { Argument argument = arguments[0]; if (TypeManager.IsGenericType(typeSpec) && InflatedTypeSpec.ContainsTypeParameter(typeSpec)) { TypeInferenceContext typeInferenceContext = new TypeInferenceContext(typeSpec.TypeArguments); typeInferenceContext.OutputTypeInference(rc, argument.Expr, typeSpec); if (typeInferenceContext.FixAllTypes(rc)) { typeSpec = typeSpec.GetDefinition().MakeGenericType(rc, typeInferenceContext.InferredTypeArguments); } } if (!Convert.ImplicitConversionExists(rc, argument.Expr, typeSpec)) { rc.Report.Error(1936, loc, "An implementation of `{0}' query expression pattern for source type `{1}' could not be found", best.Name, argument.Type.GetSignatureForError()); return true; } } if (best.Name == "SelectMany") { rc.Report.Error(1943, loc, "An expression type is incorrect in a subsequent `from' clause in a query expression with source type `{0}'", arguments[0].GetSignatureForError()); } else { rc.Report.Error(1942, loc, "An expression type in `{0}' clause is incorrect. Type inference failed in the call to `{1}'", best.Name.ToLowerInvariant(), best.Name); } return true; } } public AQueryClause next; public QueryBlock block; protected abstract string MethodName { get; } public AQueryClause Next { set { next = value; } } public AQueryClause Tail => (next == null) ? this : next.Tail; protected AQueryClause(QueryBlock block, Expression expr, Location loc) : base(expr) { this.block = block; base.loc = loc; } protected override void CloneTo(CloneContext clonectx, Expression target) { base.CloneTo(clonectx, target); AQueryClause aQueryClause = (AQueryClause)target; if (block != null) { aQueryClause.block = (QueryBlock)clonectx.LookupBlock(block); } if (next != null) { aQueryClause.next = (AQueryClause)next.Clone(clonectx); } } protected override Expression DoResolve(ResolveContext ec) { return expr.Resolve(ec); } public virtual Expression BuildQueryClause(ResolveContext ec, Expression lSide, Parameter parameter) { Arguments args = null; CreateArguments(ec, parameter, ref args); lSide = CreateQueryExpression(lSide, args); if (next != null) { parameter = CreateChildrenParameters(parameter); if (!(next is Select obj) || obj.IsRequired(parameter)) { return next.BuildQueryClause(ec, lSide, parameter); } if (next.next != null) { return next.next.BuildQueryClause(ec, lSide, parameter); } } return lSide; } protected virtual Parameter CreateChildrenParameters(Parameter parameter) { return parameter.Clone(); } protected virtual void CreateArguments(ResolveContext ec, Parameter parameter, ref Arguments args) { args = new Arguments(2); LambdaExpression lambdaExpression = new LambdaExpression(loc); block.SetParameter(parameter); lambdaExpression.Block = block; lambdaExpression.Block.AddStatement(new ContextualReturn(expr)); args.Add(new Argument(lambdaExpression)); } protected Invocation CreateQueryExpression(Expression lSide, Arguments arguments) { return new QueryExpressionInvocation(new QueryExpressionAccess(lSide, MethodName, loc), arguments); } } internal abstract class ARangeVariableQueryClause : AQueryClause { private sealed class RangeAnonymousTypeParameter : AnonymousTypeParameter { public RangeAnonymousTypeParameter(Expression initializer, RangeVariable parameter) : base(initializer, parameter.Name, parameter.Location) { } protected override void Error_InvalidInitializer(ResolveContext ec, string initializer) { ec.Report.Error(1932, loc, "A range variable `{0}' cannot be initialized with `{1}'", Name, initializer); } } private class RangeParameterReference : ParameterReference { private Parameter parameter; public RangeParameterReference(Parameter p) : base(null, p.Location) { parameter = p; } protected override Expression DoResolve(ResolveContext ec) { pi = ec.CurrentBlock.ParametersBlock.GetParameterInfo(parameter); return base.DoResolve(ec); } } protected RangeVariable identifier; public RangeVariable Identifier => identifier; public FullNamedExpression IdentifierType { get; set; } protected ARangeVariableQueryClause(QueryBlock block, RangeVariable identifier, Expression expr, Location loc) : base(block, expr, loc) { this.identifier = identifier; } protected Invocation CreateCastExpression(Expression lSide) { return new QueryExpressionInvocation(new QueryExpressionAccess(lSide, "Cast", new TypeArguments(IdentifierType), loc), null); } protected override Parameter CreateChildrenParameters(Parameter parameter) { return new QueryBlock.TransparentParameter(parameter.Clone(), GetIntoVariable()); } protected static Expression CreateRangeVariableType(ResolveContext rc, Parameter parameter, RangeVariable name, Expression init) { List list = new List(2); list.Add(new AnonymousTypeParameter(new RangeParameterReference(parameter), parameter.Name, parameter.Location)); list.Add(new RangeAnonymousTypeParameter(init, name)); return new NewAnonymousType(list, rc.MemberContext.CurrentMemberDefinition.Parent, name.Location); } protected virtual RangeVariable GetIntoVariable() { return identifier; } } internal sealed class RangeVariable : INamedBlockVariable { private Block block; public Block Block { get { return block; } set { block = value; } } public bool IsDeclared => true; public bool IsParameter => false; public Location Location { get; private set; } public string Name { get; private set; } public RangeVariable(string name, Location loc) { Name = name; Location = loc; } public Expression CreateReferenceExpression(ResolveContext rc, Location loc) { ParametersBlock parametersBlock = rc.CurrentBlock.ParametersBlock; while (true) { if (parametersBlock is QueryBlock) { for (int num = parametersBlock.Parameters.Count - 1; num >= 0; num--) { Parameter parameter = parametersBlock.Parameters[num]; if (parameter.Name == Name) { return parametersBlock.GetParameterReference(num, loc); } Expression expression = null; for (QueryBlock.TransparentParameter transparentParameter = parameter as QueryBlock.TransparentParameter; transparentParameter != null; transparentParameter = transparentParameter.Parent as QueryBlock.TransparentParameter) { expression = ((expression != null) ? ((Expression)new TransparentMemberAccess(expression, transparentParameter.Name)) : ((Expression)parametersBlock.GetParameterReference(num, loc))); if (transparentParameter.Identifier == Name) { return new TransparentMemberAccess(expression, Name); } if (transparentParameter.Parent.Name == Name) { return new TransparentMemberAccess(expression, Name); } } } } if (parametersBlock == block) { break; } parametersBlock = parametersBlock.Parent.ParametersBlock; } return null; } } internal class QueryStartClause : ARangeVariableQueryClause { protected override string MethodName { get { throw new NotSupportedException(); } } public QueryStartClause(QueryBlock block, Expression expr, RangeVariable identifier, Location loc) : base(block, identifier, expr, loc) { block.AddRangeVariable(identifier); } public override Expression BuildQueryClause(ResolveContext ec, Expression lSide, Parameter parameter) { if (base.IdentifierType != null) { expr = CreateCastExpression(expr); } if (parameter == null) { lSide = expr; } return next.BuildQueryClause(ec, lSide, new ImplicitLambdaParameter(identifier.Name, identifier.Location)); } protected override Expression DoResolve(ResolveContext ec) { Expression expression = BuildQueryClause(ec, null, null); return expression.Resolve(ec); } } internal class GroupBy : AQueryClause { private Expression element_selector; private QueryBlock element_block; public Expression SelectorExpression => element_selector; protected override string MethodName => "GroupBy"; public GroupBy(QueryBlock block, Expression elementSelector, QueryBlock elementBlock, Expression keySelector, Location loc) : base(block, keySelector, loc) { if (!elementSelector.Equals(keySelector)) { element_selector = elementSelector; element_block = elementBlock; } } protected override void CreateArguments(ResolveContext ec, Parameter parameter, ref Arguments args) { base.CreateArguments(ec, parameter, ref args); if (element_selector != null) { LambdaExpression lambdaExpression = new LambdaExpression(element_selector.Location); element_block.SetParameter(parameter.Clone()); lambdaExpression.Block = element_block; lambdaExpression.Block.AddStatement(new ContextualReturn(element_selector)); args.Add(new Argument(lambdaExpression)); } } protected override void CloneTo(CloneContext clonectx, Expression target) { GroupBy groupBy = (GroupBy)target; if (element_selector != null) { groupBy.element_selector = element_selector.Clone(clonectx); groupBy.element_block = (QueryBlock)element_block.Clone(clonectx); } base.CloneTo(clonectx, (Expression)groupBy); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Join : SelectMany { private QueryBlock inner_selector; private QueryBlock outer_selector; public QueryBlock InnerSelector => inner_selector; public QueryBlock OuterSelector => outer_selector; protected override string MethodName => "Join"; public Join(QueryBlock block, RangeVariable lt, Expression inner, QueryBlock outerSelector, QueryBlock innerSelector, Location loc) : base(block, lt, inner, loc) { outer_selector = outerSelector; inner_selector = innerSelector; } protected override void CreateArguments(ResolveContext ec, Parameter parameter, ref Arguments args) { args = new Arguments(4); if (base.IdentifierType != null) { expr = CreateCastExpression(expr); } args.Add(new Argument(expr)); outer_selector.SetParameter(parameter.Clone()); LambdaExpression lambdaExpression = new LambdaExpression(outer_selector.StartLocation); lambdaExpression.Block = outer_selector; args.Add(new Argument(lambdaExpression)); inner_selector.SetParameter(new ImplicitLambdaParameter(identifier.Name, identifier.Location)); lambdaExpression = new LambdaExpression(inner_selector.StartLocation); lambdaExpression.Block = inner_selector; args.Add(new Argument(lambdaExpression)); base.CreateArguments(ec, parameter, ref args); } protected override void CloneTo(CloneContext clonectx, Expression target) { Join obj = (Join)target; obj.inner_selector = (QueryBlock)inner_selector.Clone(clonectx); obj.outer_selector = (QueryBlock)outer_selector.Clone(clonectx); base.CloneTo(clonectx, (Expression)obj); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class GroupJoin : Join { private readonly RangeVariable into; protected override string MethodName => "GroupJoin"; public GroupJoin(QueryBlock block, RangeVariable lt, Expression inner, QueryBlock outerSelector, QueryBlock innerSelector, RangeVariable into, Location loc) : base(block, lt, inner, outerSelector, innerSelector, loc) { this.into = into; } protected override RangeVariable GetIntoVariable() { return into; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Let : ARangeVariableQueryClause { protected override string MethodName => "Select"; public Let(QueryBlock block, RangeVariable identifier, Expression expr, Location loc) : base(block, identifier, expr, loc) { } protected override void CreateArguments(ResolveContext ec, Parameter parameter, ref Arguments args) { expr = ARangeVariableQueryClause.CreateRangeVariableType(ec, parameter, identifier, expr); base.CreateArguments(ec, parameter, ref args); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Select : AQueryClause { protected override string MethodName => "Select"; public Select(QueryBlock block, Expression expr, Location loc) : base(block, expr, loc) { } public bool IsRequired(Parameter parameter) { if (!(expr is SimpleName simpleName)) { return true; } return simpleName.Name != parameter.Name; } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class SelectMany : ARangeVariableQueryClause { protected override string MethodName => "SelectMany"; public SelectMany(QueryBlock block, RangeVariable identifier, Expression expr, Location loc) : base(block, identifier, expr, loc) { } protected override void CreateArguments(ResolveContext ec, Parameter parameter, ref Arguments args) { if (args == null) { if (base.IdentifierType != null) { expr = CreateCastExpression(expr); } base.CreateArguments(ec, parameter.Clone(), ref args); } RangeVariable intoVariable = GetIntoVariable(); ImplicitLambdaParameter second = new ImplicitLambdaParameter(intoVariable.Name, intoVariable.Location); Expression expression; QueryBlock queryBlock; if (next is Select) { expression = next.Expr; queryBlock = next.block; queryBlock.SetParameters(parameter, second); next = next.next; } else { expression = ARangeVariableQueryClause.CreateRangeVariableType(ec, parameter, intoVariable, new SimpleName(intoVariable.Name, intoVariable.Location)); queryBlock = new QueryBlock(block.Parent, block.StartLocation); queryBlock.SetParameters(parameter, second); } LambdaExpression lambdaExpression = new LambdaExpression(base.Location); lambdaExpression.Block = queryBlock; lambdaExpression.Block.AddStatement(new ContextualReturn(expression)); args.Add(new Argument(lambdaExpression)); } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class Where : AQueryClause { protected override string MethodName => "Where"; public Where(QueryBlock block, Expression expr, Location loc) : base(block, expr, loc) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class OrderByAscending : AQueryClause { protected override string MethodName => "OrderBy"; public OrderByAscending(QueryBlock block, Expression expr) : base(block, expr, expr.Location) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class OrderByDescending : AQueryClause { protected override string MethodName => "OrderByDescending"; public OrderByDescending(QueryBlock block, Expression expr) : base(block, expr, expr.Location) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ThenByAscending : OrderByAscending { protected override string MethodName => "ThenBy"; public ThenByAscending(QueryBlock block, Expression expr) : base(block, expr) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class ThenByDescending : OrderByDescending { protected override string MethodName => "ThenByDescending"; public ThenByDescending(QueryBlock block, Expression expr) : base(block, expr) { } public override object Accept(StructuralVisitor visitor) { return visitor.Visit(this); } } internal class QueryBlock : ParametersBlock { public sealed class TransparentParameter : ImplicitLambdaParameter { public static int Counter; private const string ParameterNamePrefix = "<>__TranspIdent"; public readonly Parameter Parent; public readonly string Identifier; public TransparentParameter(Parameter parent, RangeVariable identifier) : base("<>__TranspIdent" + Counter++, identifier.Location) { Parent = parent; Identifier = identifier.Name; } public static void Reset() { Counter = 0; } } public QueryBlock(Block parent, Location start) : base(parent, ParametersCompiled.EmptyReadOnlyParameters, start, Flags.CompilerGenerated) { } public void AddRangeVariable(RangeVariable variable) { variable.Block = this; base.TopBlock.AddLocalName(variable.Name, variable, ignoreChildrenBlocks: true); } public override void Error_AlreadyDeclared(string name, INamedBlockVariable variable, string reason) { base.TopBlock.Report.Error(1931, variable.Location, "A range variable `{0}' conflicts with a previous declaration of `{0}'", name); } public override void Error_AlreadyDeclared(string name, INamedBlockVariable variable) { base.TopBlock.Report.Error(1930, variable.Location, "A range variable `{0}' has already been declared in this scope", name); } public override void Error_AlreadyDeclaredTypeParameter(string name, Location loc) { base.TopBlock.Report.Error(1948, loc, "A range variable `{0}' conflicts with a method type parameter", name); } public void SetParameter(Parameter parameter) { parameters = new ParametersCompiled(parameter); parameter_info = new ParameterInfo[1] { new ParameterInfo(this, 0) }; } public void SetParameters(Parameter first, Parameter second) { parameters = new ParametersCompiled(first, second); parameter_info = new ParameterInfo[2] { new ParameterInfo(this, 0), new ParameterInfo(this, 1) }; } } internal sealed class TransparentMemberAccess : MemberAccess { public TransparentMemberAccess(Expression expr, string name) : base(expr, name) { } public override Expression DoResolveLValue(ResolveContext rc, Expression right_side) { rc.Report.Error(1947, loc, "A range variable `{0}' cannot be assigned to. Consider using `let' clause to store the value", base.Name); return null; } } } namespace Mono.CSharp.IL2CPP { internal static class Blacklist { public static HashSet SignatureBlacklist = new HashSet(); public static bool IsBlacklisted(TypeSpec declaringType, MemberInfo member) { Type metaInfo = declaringType.GetMetaInfo(); if ((object)metaInfo != null && !string.IsNullOrEmpty(metaInfo.Namespace)) { string item = metaInfo.Namespace + "." + declaringType.Name + "." + member.Name; if (SignatureBlacklist.Contains(item)) { return true; } } return false; } } } namespace Mono.CSharp.yyParser { internal class yyException : Exception { public yyException(string message) : base(message) { } } internal class yyUnexpectedEof : yyException { public yyUnexpectedEof(string message) : base(message) { } public yyUnexpectedEof() : base("") { } } internal interface yyInput { bool advance(); int token(); object value(); } } namespace Mono.CSharp.yydebug { internal interface yyDebug { void push(int state, object value); void lex(int state, int token, string name, object value); void shift(int from, int to, int errorFlag); void pop(int state); void discard(int state, int token, string name, object value); void reduce(int from, int to, int rule, string text, int len); void shift(int from, int to); void accept(object value); void error(string message); void reject(); } internal class yyDebugSimple : yyDebug { private void println(string s) { Console.Error.WriteLine(s); } public void push(int state, object value) { println("push\tstate " + state + "\tvalue " + value); } public void lex(int state, int token, string name, object value) { println("lex\tstate " + state + "\treading " + name + "\tvalue " + value); } public void shift(int from, int to, int errorFlag) { switch (errorFlag) { default: println("shift\tfrom state " + from + " to " + to); break; case 0: case 1: case 2: println("shift\tfrom state " + from + " to " + to + "\t" + errorFlag + " left to recover"); break; case 3: println("shift\tfrom state " + from + " to " + to + "\ton error"); break; } } public void pop(int state) { println("pop\tstate " + state + "\ton error"); } public void discard(int state, int token, string name, object value) { println("discard\tstate " + state + "\ttoken " + name + "\tvalue " + value); } public void reduce(int from, int to, int rule, string text, int len) { println("reduce\tstate " + from + "\tuncover " + to + "\trule (" + rule + ") " + text); } public void shift(int from, int to) { println("goto\tfrom state " + from + " to " + to); } public void accept(object value) { println("accept\tvalue " + value); } public void error(string message) { println("error\t" + message); } public void reject() { println("reject"); } } } [CompilerGenerated] internal sealed class <6eb9247f-5bfb-4ffa-ba47-d65947ce2ac8> { [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 6)] private struct __StaticArrayInitTypeSize=6 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)] private struct __StaticArrayInitTypeSize=16 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 552)] private struct __StaticArrayInitTypeSize=552 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 1004)] private struct __StaticArrayInitTypeSize=1004 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 2310)] private struct __StaticArrayInitTypeSize=2310 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 3626)] private struct __StaticArrayInitTypeSize=3626 { } [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 44822)] private struct __StaticArrayInitTypeSize=44822 { } internal static readonly long 1417FCAA8455DC8E3C88BF916DD5C75746A2597CC052F212A8E4394C890E012B/* Not supported: data(20 00 0A 00 0D 00 09 00) */; internal static readonly long 1774F4999B28A17AF9398F63C02E9A6B2ACBAC49D80F3085367A3E37A4412BDE/* Not supported: data(00 24 00 00 04 80 00 00) */; internal static readonly __StaticArrayInitTypeSize=1004 2A14553117BC001F20B261AE6D261A62F62359E1D2A6E1BA4C52D311D57043A3/* Not supported: data(07 00 08 00 32 00 09 00 33 00 0A 00 0B 00 34 00 F5 00 40 03 41 03 0C 00 0D 00 35 00 16 00 17 00 CE 00 59 01 F8 00 31 03 01 04 F0 04 81 05 B5 05 FB 06 FE 03 F9 00 FA 00 FB 00 FC 00 FD 00 FE 00 FF 00 00 01 2A 03 F7 01 2B 03 2C 03 83 04 2D 03 2E 03 87 04 FF 03 EB 04 EC 04 ED 04 19 01 B8 02 5F 05 75 00 0F 04 98 04 95 04 6B 03 CA 03 D4 05 D5 05 D6 05 D7 05 D8 05 D9 05 DA 05 DB 05 DC 05 DD 05 DE 05 DF 05 E0 05 E1 05 E2 05 7C 02 FC 05 A5 03 0C 04 0A 02 35 03 33 06 3A 05 F9 04 69 05 8E 05 AD 05 F2 05 41 06 89 05 79 06 60 06 92 06 93 06 94 06 9A 04 90 06 9B 04 74 03 17 06 6B 06 50 06 86 06 41 02 7F 06 65 06 A3 06 63 04 84 06 87 06 88 06 E8 06 A4 06 A5 06 A1 06 E3 05 20 06 00 06 04 04 8B 04 F1 04 34 06 42 03 6D 06 D3 06 4D 06 A7 06 F3 06 0B 02 1A 01 22 06 A9 06 03 06 9C 05 23 06 4D 04 3E 06 43 03 44 03 45 03 46 03 47 03 18 03 95 02 6F 05 19 03 1A 03 15 04 36 06 55 06 B3 06 8B 06 D5 06 0A 07 F9 06 56 06 13 07 0E 07 37 06 71 06 EF 06 D8 06 B4 06 B5 06 07 07 F7 06 F8 06 91 04 38 05 AC 05 EF 05 24 06 F0 05 F1 05 19 06 3B 06 1A 06 5C 01 EB 00 8F 06 1C 06 80 06 7D 06 E4 05 30 06 D0 06 AA 06 D1 06 B9 02 01 07 02 07 2F 06 7C 06 62 06 9C 06 97 06 7A 06 BD 06 C2 06 9A 06 9D 06 9E 06 C3 06 98 06 99 06 FE 06 F0 06 F1 06 8E 04 F6 04 86 05 64 05 A4 05 87 05 88 05 B8 05 35 05 A1 05 C5 05 A2 01 5D 01 77 00 93 01 94 01 78 00 8E 02 F3 01 EE 00 48 06 21 03 22 03 F6 03 05 04 79 00 61 01 D1 01 54 01 62 01 61 02 62 02 8D 03 43 01 8A 05 8B 05 2E 00 7C 00 44 01 7E 00 7F 00 80 00 81 00 82 00 83 00 84 00 85 00 86 00 87 00 88 00 89 00 8A 00 8B 00 8C 00 8D 00 8E 00 8F 00 90 00 91 00 92 00 93 00 94 00 95 00 7A 01 7B 01 74 01 75 01 A1 03 CF 04 0A 01 D2 03 70 03 C0 04 B5 04 64 03 2D 04 65 03 66 03 B6 04 96 00 D1 00 6C 03 BB 02 BC 02 BD 02 CB 03 97 00 14 02 15 02 38 01 BE 04 6E 03 D2 01 3A 01 31 02 32 02 33 02 34 02 37 02 76 03 57 02 16 01 1A 02 98 03 17 01 19 02 98 00 99 00 9A 00 9B 00 DC 02 DD 03 DD 02 DE 02 6C 04 6D 04 25 05 9C 00 9D 00 9E 00 9F 00 A0 00 A1 00 A2 00 A3 00 A4 00 01 03 02 03 A5 00 4E 04 A6 00 9A 01 9B 01 97 02 98 02 99 02 9D 03 9E 03 A7 00 8B 02 75 02 9A 03 95 01 D1 04 71 02 1E 05 A8 00 28 02 3B 05 67 05 6A 05 BC 05 8F 04 37 05 AA 05 1D 06 0C 02 8F 05 90 05 CE 05 CF 05 F7 03 77 01 B0 05 7D 02 7E 02 1B 01 1C 01 1D 01 AB 00 AC 00 AD 00 1E 01 1F 01 20 01 21 01 22 01 23 01 24 01 25 01 26 01 27 01 28 01 29 01 B9 00 2A 01 A4 02 BA 00 BB 00 7D 01 55 01 D7 03 BE 02 67 04 12 04 3C 03 9E 04 78 03 37 04 65 04 68 04 06 05 69 04 9F 04 A0 04 2B 01 BC 00 BD 00 BE 00 15 05 C6 04 16 05 17 05 18 05 19 05 BF 00 C0 00 C1 00 C2 00 4E 03 21 02 4F 03 09 05 B0 04 0A 05 96 05 72 05 48 05 97 05 50 03 AF 04 51 03 99 05 49 05 C3 00 C4 00 C5 00 C6 00 C7 00 C8 00 46 01 51 02 52 02 7F 03 79 05 53 05 3A 04 51 01 AE 04 1C 04 71 05 CB 04 40 04 54 05 C9 00 DF 01 CA 00 E0 01 74 04 DE 04 E1 01 E2 01 13 03 0A 03 0B 03 E3 04 78 04 E3 01 E4 01 E5 01 E6 01 E7 01 79 04 05 03 76 04 59 05 B1 05 F5 05 E0 04 7D 05 C4 05 EB 03 0D 03 EC 03 2D 05 E5 04 2E 05 7E 05 7D 04 11 00 13 00 2F 00 30 00 ED 00 1B 03 FA 03 F1 01 1C 03 1D 03) */; internal static readonly __StaticArrayInitTypeSize=3626 315DE888C83F9C0C86DE56513876A6944529D8D245314F52E01549C919DCD1B4/* Not supported: data(00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 00 00 0B 00 0E 00 00 00 63 04 00 00 00 00 67 04 00 00 00 00 0F 00 11 00 AF 01 B5 01 BC 01 B0 01 B2 01 00 00 B1 01 00 00 B8 01 BA 01 AD 01 00 00 B4 01 B6 01 AE 01 B9 01 BB 01 B7 01 00 00 82 01 79 04 00 00 B3 01 6E 04 00 00 0A 00 01 00 00 00 00 00 00 00 0C 00 00 00 AF 03 00 00 00 00 00 00 00 00 00 00 6D 02 00 00 00 00 00 00 DB 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D9 01 00 00 00 00 00 00 00 00 2E 02 00 00 DA 01 00 00 00 00 00 00 15 04 00 00 00 00 00 00 07 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E2 01 00 00 44 03 00 00 75 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D8 01 00 00 FC 02 00 00 00 00 AE 03 00 00 64 03 00 00 D3 01 7E 03 7C 03 00 00 00 00 00 00 BE 01 BF 01 C0 01 C1 01 C2 01 C3 01 C4 01 C5 01 C6 01 C7 01 C8 01 C9 01 CA 01 CB 01 CC 01 CD 01 CE 01 CF 01 D0 01 D1 01 D2 01 D5 01 D6 01 D7 01 03 03 00 00 78 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 03 02 03 05 03 06 03 54 03 56 03 00 00 52 03 55 03 65 03 67 03 68 03 69 03 6A 03 6B 03 6C 03 6D 03 6E 03 6F 03 70 03 66 03 00 00 00 00 00 00 B0 03 B1 03 C4 03 C5 03 C6 03 C7 03 E9 03 EA 03 EB 03 EC 03 ED 03 EE 03 00 00 00 00 00 00 14 00 16 00 00 00 6B 04 10 00 64 04 00 00 00 00 19 01 2A 01 18 01 15 01 1A 01 1B 01 14 01 27 01 26 01 1F 01 20 01 1C 01 1E 01 1D 01 21 01 16 01 17 01 22 01 23 01 29 01 28 01 24 01 25 01 00 00 7C 04 71 04 00 00 00 00 70 04 00 00 6F 04 03 00 39 00 00 00 00 00 00 00 2E 00 2B 00 2D 00 30 00 31 00 32 00 33 00 34 00 37 00 0D 00 00 00 00 00 00 00 EF 03 60 02 EB 01 EC 01 13 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F1 03 F0 03 00 00 6A 02 64 02 69 02 74 03 AD 03 57 03 72 03 71 03 73 03 58 03 59 03 5A 03 5B 03 5C 03 5D 03 5E 03 5F 03 60 03 61 03 62 03 63 03 00 00 00 00 00 00 CD 03 00 00 00 00 00 00 86 03 85 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F8 03 00 00 00 00 00 00 00 00 00 00 00 00 BD 01 00 00 00 00 00 00 00 00 FC 03 FA 03 00 00 00 00 00 00 62 02 14 04 00 00 00 00 00 00 84 03 A9 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 95 01 75 01 00 00 78 01 96 01 00 00 9F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 02 00 00 77 02 00 00 00 00 F8 02 00 00 00 00 72 02 00 00 00 00 E3 01 73 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 75 02 70 02 7F 02 79 02 80 02 7A 02 74 02 6F 02 84 02 7E 02 83 02 7D 02 81 02 7B 02 82 02 7C 02 F6 02 5C 02 00 00 5B 02 D4 01 7B 01 7C 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 76 03 00 00 74 01 00 00 A7 01 A8 01 00 00 00 00 31 02 32 02 00 00 00 00 00 00 7A 03 7B 03 87 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 66 04 53 03 79 03 00 00 7D 03 AB 03 AC 03 35 04 46 04 00 00 00 00 36 04 38 04 00 00 52 04 27 04 25 04 3F 04 00 00 00 00 3D 04 40 04 41 04 42 04 43 04 28 04 26 04 00 00 00 00 00 00 00 00 00 00 00 00 78 04 00 00 00 00 83 01 00 00 00 00 7A 04 00 00 00 00 2C 00 26 03 2C 03 24 03 00 00 21 03 2B 03 25 03 23 03 22 03 29 03 27 03 28 03 2E 03 2A 03 2D 03 2F 03 00 00 00 00 1F 03 2F 00 38 00 30 02 00 00 2C 02 2D 02 00 00 00 00 2A 02 00 00 89 03 00 00 00 00 00 00 CB 03 00 00 AA 03 A8 03 A9 03 00 00 00 00 00 00 0B 03 00 00 F4 03 F2 03 0C 03 00 00 00 00 49 02 00 00 00 00 3D 02 44 02 00 00 00 00 00 00 3E 02 00 00 00 00 4E 02 50 02 00 00 39 02 00 00 00 00 00 00 00 00 00 00 34 02 00 00 37 02 3B 02 98 01 97 01 00 00 8B 03 A7 03 F7 03 F6 03 F5 03 00 00 00 00 FB 03 F9 03 05 04 00 00 00 00 00 00 06 04 5A 02 00 00 92 01 59 02 00 00 00 00 16 04 00 00 00 00 83 03 00 00 00 00 A5 01 99 01 00 00 00 00 00 00 9D 01 9E 01 00 00 00 00 00 00 9C 01 00 00 00 00 00 00 85 02 00 00 00 00 66 02 00 00 FA 02 97 02 96 02 00 00 00 00 00 00 E7 01 00 00 E1 01 51 03 00 00 00 00 4C 03 4E 03 4F 03 50 03 00 00 EF 01 F0 01 DC 01 00 00 00 00 00 00 7F 03 00 00 00 00 7F 01 80 01 00 00 D4 00 D2 00 D1 00 D3 00 EB 02 00 00 00 00 00 00 00 00 E6 02 00 00 00 00 00 00 E3 02 00 00 00 00 00 00 00 00 FF 03 00 00 00 00 00 00 F7 01 F8 01 00 00 FB 01 00 00 00 00 00 00 00 00 F9 01 00 00 00 00 27 02 00 00 FF 01 00 00 00 00 00 00 00 00 19 02 1C 02 00 00 00 00 14 02 1B 02 1A 02 00 00 D4 02 D5 02 D6 02 D7 02 D8 02 D9 02 DA 02 DB 02 DC 02 DE 02 DD 02 89 02 86 02 8B 02 88 02 8A 02 87 02 94 02 91 02 95 02 00 00 00 00 9F 02 00 00 00 00 00 00 00 00 00 00 98 02 00 00 93 02 A0 02 8F 02 00 00 90 02 00 00 AA 02 00 00 00 00 AB 02 00 00 B1 02 00 00 B2 02 00 00 B3 02 00 00 B4 02 00 00 B8 02 00 00 B9 02 00 00 BC 02 00 00 BF 02 00 00 C2 02 00 00 C5 02 00 00 C8 02 00 00 CA 02 00 00 CB 02 00 00 CC 02 00 00 4D 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 04 33 04 00 00 3E 04 00 00 32 04 00 00 12 00 76 04 77 04 00 00 00 00 CF 00 00 00 00 00 80 04 91 01 00 00 00 00 00 00 8E 01 72 04 74 04 3F 00 41 00 42 00 00 00 00 00 3A 00 00 00 00 00 43 00 45 00 20 00 1E 00 00 00 00 00 00 00 1C 03 00 00 20 03 F5 01 00 00 2F 02 00 00 5F 02 00 00 6C 02 C4 00 DB 00 00 00 00 00 00 00 BA 00 00 00 00 00 00 00 C5 00 65 02 00 00 19 04 D1 03 00 00 E3 03 CE 03 00 00 DA 03 00 00 E5 03 00 00 F3 03 B4 03 00 00 18 04 00 00 00 00 3C 02 00 00 45 02 4F 02 51 02 00 00 00 00 00 00 00 00 0B 02 00 00 00 00 06 02 00 00 00 00 F5 02 F4 02 28 02 00 00 53 02 36 02 00 00 00 00 9E 00 54 02 9C 00 9D 00 56 02 00 00 8D 03 00 00 5E 02 5D 02 B7 03 00 00 11 04 00 00 00 00 03 04 00 00 07 04 58 02 61 02 20 04 00 00 1C 04 C9 03 00 00 00 00 00 00 A4 01 A1 01 00 00 2B 04 00 00 76 01 77 01 29 04 00 00 00 00 09 03 0A 03 00 00 00 00 00 00 F1 02 F0 02 F9 02 00 00 F6 01 00 00 00 00 E4 01 46 03 47 03 45 03 4D 03 E0 01 DF 01 DE 01 DD 01 00 00 00 00 F7 02 00 00 7E 01 E9 02 00 00 00 00 00 00 76 02 71 02 E1 02 00 00 E2 02 00 00 E5 02 00 00 FE 03 FD 03 77 03 FC 01 F4 01 00 00 00 00 FA 01 F1 01 F2 01 63 02 26 02 24 02 23 02 1F 02 1E 02 00 00 1D 02 00 00 18 02 ED 01 EE 01 FD 01 FE 01 00 00 91 03 00 00 00 00 9A 02 9B 02 00 00 00 00 09 04 92 02 00 00 D1 02 00 00 00 00 47 04 2D 04 00 00 48 04 00 00 37 04 39 04 44 04 00 00 53 04 00 00 31 04 61 04 00 00 82 04 D0 00 7D 04 00 00 43 03 42 03 00 00 41 03 00 00 8D 01 00 00 3E 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A1 00 94 01 00 00 16 03 00 00 6F 00 70 00 00 00 00 00 00 00 5A 00 00 00 2B 02 00 00 00 00 00 00 00 00 00 00 C9 00 6B 02 00 00 00 00 00 00 00 00 00 00 DB 03 CF 03 00 00 E6 03 00 00 00 00 17 04 46 02 43 02 00 00 0F 02 00 00 00 00 00 00 6C 04 6D 04 02 02 08 02 00 00 0C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B5 03 00 00 0D 04 00 00 0A 04 04 04 1F 04 00 00 C8 03 A0 01 00 00 79 01 7A 01 2C 04 2A 04 00 00 67 02 00 00 FB 02 F2 02 EF 02 F3 02 E9 01 E8 01 00 00 81 03 81 01 E8 02 E7 02 FD 02 DF 02 E0 02 E4 02 F3 01 25 02 22 02 21 02 00 00 17 02 16 02 15 02 00 00 A1 03 A4 03 90 03 00 00 00 00 00 00 96 03 00 00 00 00 00 00 A2 02 00 00 D2 02 00 00 D3 02 CE 02 D0 02 00 00 2F 04 00 00 4C 04 00 00 00 00 5B 04 5C 04 55 04 00 00 13 00 81 04 90 01 8F 01 00 00 00 00 44 00 3D 00 00 00 46 00 1F 00 18 00 A4 00 00 00 00 00 00 00 5E 01 00 00 FF 00 00 00 71 00 77 00 72 00 55 00 57 00 58 00 54 00 56 00 9B 03 83 00 84 00 00 00 00 00 00 00 9E 03 D9 00 DA 00 00 00 00 00 00 00 00 00 BD 00 C6 00 BE 00 C0 00 CC 03 00 00 00 00 00 00 00 00 00 00 E4 03 00 00 00 00 10 02 11 02 0A 02 0D 02 09 02 00 00 03 02 07 02 00 00 4B 02 00 00 29 02 33 02 01 02 57 02 55 02 00 00 00 00 00 00 00 00 00 00 22 04 00 00 00 00 A2 01 08 03 00 03 00 00 80 03 00 00 20 02 00 00 00 00 88 03 97 03 9E 02 00 00 A1 02 00 00 00 00 CF 02 2E 04 00 00 00 00 00 00 3C 04 00 00 3A 04 45 04 00 00 62 04 75 04 00 00 51 00 00 00 00 00 4B 00 4C 00 4F 00 50 00 00 00 00 00 A3 00 6F 01 64 01 63 01 00 00 17 03 FB 00 00 00 00 00 8A 03 9F 03 CA 00 00 00 D7 00 00 00 00 00 00 00 CA 03 24 04 00 00 00 00 00 00 DF 03 00 00 00 00 E7 03 B3 03 00 00 38 02 35 02 00 00 8C 03 BC 03 00 00 C3 03 00 00 00 00 BA 03 00 00 BE 03 00 00 0B 04 21 04 1D 04 00 00 EA 01 FE 02 00 00 00 00 00 00 A5 02 A4 02 A3 02 A5 03 30 04 49 04 00 00 3B 04 00 00 00 00 57 04 00 00 52 00 49 00 00 00 00 00 A5 00 00 00 5F 01 00 00 00 00 00 00 00 00 0E 03 00 00 00 00 CB 00 00 00 C1 00 BF 00 1A 04 DC 03 D0 03 D8 03 D7 03 D2 03 D4 03 00 00 0E 02 8E 03 00 00 00 00 B6 03 BB 03 00 00 BF 03 12 04 00 00 00 00 01 03 00 00 99 03 A6 02 00 00 4D 04 5E 04 5F 04 58 04 3C 00 00 00 4D 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 11 03 00 00 31 03 00 00 00 00 A0 03 C8 00 00 00 D6 00 00 00 00 00 E8 03 C1 03 C0 03 00 00 0F 04 00 00 0C 04 1E 04 A2 03 00 00 00 00 00 00 53 00 00 00 00 00 70 01 00 00 00 00 6E 01 60 01 00 00 68 01 AC 01 00 00 AA 01 00 00 00 00 18 03 00 00 36 03 FC 00 0F 03 73 00 CC 00 1B 04 D3 03 00 00 00 00 E1 03 C2 03 48 03 0E 04 4A 04 00 00 59 04 00 00 00 00 00 00 5C 01 00 00 00 00 33 03 00 00 14 03 00 00 00 00 37 03 00 00 00 00 D6 03 D5 03 00 00 00 00 4E 04 1D 00 1C 00 19 00 71 01 6D 01 00 00 00 00 69 01 AB 01 00 00 39 03 00 00 00 00 00 00 74 00 00 00 00 00 00 00 00 00 00 00 22 00 61 01 00 00 3E 03 00 00 3F 03 3C 03 00 00 3A 03 6C 00 6D 00 00 00 69 00 00 00 00 00 5D 00 5F 00 60 00 61 00 62 00 63 00 64 00 65 00 66 00 67 00 68 00 6A 00 6B 00 9F 00 00 00 00 00 0C 01 04 01 05 01 06 01 07 01 08 01 09 01 0A 01 0B 01 00 00 00 00 02 01 00 00 49 03 00 00 4B 04 00 00 72 01 6C 01 15 03 00 00 00 00 00 00 00 00 19 03 5E 00 00 00 B5 00 B4 00 31 01 B3 00 00 00 FD 00 03 01 00 00 51 04 4F 04 3D 03 3B 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 01 00 00 00 00 00 00 0D 01 00 00 00 00 13 01 00 00 B7 00 B1 00 A0 00 AF 00 B0 00 00 00 00 00 75 00 6E 00 00 00 00 00 30 01 00 00 00 00 2F 01 00 00 A9 00 00 00 00 00 87 01 00 00 85 01 00 00 00 00 00 00 00 00 00 00 00 00 5D 01 00 00 00 00 1A 03 00 00 00 00 FE 00 00 00 7A 00 78 00 44 01 00 00 84 01 00 00 00 00 00 00 00 00 87 00 00 00 00 00 00 00 00 00 00 00 00 00 AE 00 A6 00 00 00 00 00 00 00 E8 00 00 00 88 01 00 00 0E 01 00 00 00 00 B6 00 76 00 00 00 41 01 00 00 2D 01 89 00 00 00 2B 01 00 00 00 00 00 00 8B 00 00 00 89 01 00 00 00 00 DD 00 E2 00 00 00 00 00 00 00 86 01 11 01 B8 00 82 00 80 00 00 00 00 00 46 01 00 00 00 00 00 00 00 00 00 00 AA 00 00 00 33 01 00 00 00 00 00 00 00 00 8F 00 00 00 00 00 00 00 00 00 8A 01 8B 01 00 00 00 00 00 00 00 00 00 00 7D 00 54 01 00 00 42 01 00 00 00 00 4E 01 00 00 00 00 00 00 4A 01 00 00 9B 00 00 00 00 00 00 00 00 00 96 00 00 00 00 00 B2 00 3E 01 00 00 8C 00 00 00 86 00 90 00 A7 00 AD 00 F1 00 00 00 DE 00 00 00 00 00 E9 00 00 00 81 00 00 00 79 00 7E 00 00 00 00 00 00 00 50 01 00 00 51 01 47 01 00 00 00 00 40 01 4B 01 2E 01 00 00 00 00 88 00 97 00 2C 01 00 00 3C 01 00 00 34 01 36 01 92 00 00 00 00 00 00 00 EE 00 F0 00 00 00 12 01 7F 00 55 01 57 01 43 01 00 00 00 00 4F 01 4E 01 9A 00 98 00 AB 00 3B 01 00 00 00 00 00 00 A8 00 F2 00 F4 00 DF 00 00 00 EC 00 EA 00 00 00 00 00 4D 01 00 00 37 01 39 01 93 00 00 00 00 00 00 00 00 00 59 01 5A 01 5B 01 56 01 58 01 AC 00 00 00 00 00 F9 00 F8 00 F6 00 F7 00 F3 00 F5 00 E4 00 E0 00 EB 00 00 00 00 00 00 00 38 01 3A 01 E6 00 E7 00 00 00 E5 00) */; internal static readonly __StaticArrayInitTypeSize=44822 340015BC936B4A166AF3C2653004727E9BEE4DEF39F72FFF95CF31981FCA2092/* Not supported: data(74 00 40 02 A9 00 AA 00 F6 00 CB 00 12 00 76 00 F7 00 45 01 43 02 24 02 0E 02 EA 01 75 03 12 02 F9 01 36 03 5D 02 E9 01 14 01 4D 03 DE 03 3E 02 2C 01 2D 01 2E 01 80 02 34 01 35 01 6F 03 D8 02 2C 00 33 01 47 01 48 01 ED 01 D9 02 DA 02 6C 02 4D 01 50 01 AB 01 52 01 3C 02 56 01 5F 02 A6 03 CF 01 09 01 67 01 68 01 96 02 5A 01 64 01 30 02 36 04 6D 05 6B 01 42 01 E2 03 BA 02 38 04 4B 01 A6 02 E7 03 E8 03 C5 04 10 01 AD 03 07 03 B1 02 4C 01 C8 04 4F 01 11 01 22 04 A3 01 23 04 AC 01 73 01 AA 01 9F 01 10 01 79 01 69 02 BE 03 6A 04 B8 04 91 05 3C 01 F0 00 93 05 FB 03 F2 00 52 03 D3 03 A5 02 98 01 12 05 06 01 AE 00 55 02 77 05 D3 01 12 01 BD 03 38 02 25 03 D5 03 FD 05 13 05 60 02 2E 04 AD 01 0E 00 7C 01 4E 01 06 01 55 03 5A 04 D6 04 FD 04 E1 04 3F 04 2F 03 93 04 41 04 C9 04 05 06 99 01 AF 00 FF 04 D4 01 5B 06 26 03 31 01 4E 01 AA 02 7D 03 CC 00 8F 01 DB 06 32 03 14 00 B6 05 42 06 33 03 01 06 44 06 07 01 B0 00 10 03 13 05 74 00 F6 00 A9 00 AA 00 4C 02 EB 01 4F 02 76 00 45 05 4A 06 90 01 DE 03 46 05 27 03 B1 00 DE 03 47 05 91 01 01 00 DE 03 60 02 47 00 47 00 9B 05 81 03 47 00 12 02 92 01 B2 00 B3 00 7A 00 10 03 02 06 B4 00 AB 02 D5 01 07 03 B5 00 07 03 B6 00 07 03 DC 06 32 01 F8 01 04 03 08 01 B7 00 EB 01 06 00 31 01 5A 04 A8 06 CD 00 10 05 34 03 5A 04 37 03 5A 04 BD 03 7D 03 5A 04 5A 04 B8 00 5A 04 5A 04 E2 04 D4 03 07 01 10 02 13 02 39 02 50 01 3A 02 7A 00 07 01 AA 01 31 01 13 01 7A 00 DF 03 8F 01 64 00 17 02 2F 04 07 01 07 01 D6 03 56 03 7A 00 11 02 5A 04 70 06 CF 00 77 06 B3 05 16 02 67 03 74 05 07 03 C4 04 64 00 AE 00 0E 02 90 01 07 01 AD 04 6D 03 F9 01 64 02 32 01 91 01 92 03 BD 03 F6 01 7A 00 3D 02 08 01 14 05 96 02 2F 02 43 05 02 00 28 03 08 01 D6 04 45 02 3B 02 F0 01 7A 00 0F 00 4D 02 AF 00 23 02 08 01 08 01 80 02 32 01 27 02 29 02 30 03 2B 00 5C 02 24 04 69 01 91 03 65 02 00 05 46 02 5A 04 79 01 58 05 B0 00 BC 06 08 01 10 01 A3 01 67 02 4B 02 9F 03 14 05 43 06 20 02 4A 05 45 06 10 01 58 02 6B 02 5A 02 B1 00 10 01 96 04 27 02 99 04 59 02 80 02 C2 03 44 02 4B 06 76 02 29 03 D4 06 C5 03 B2 00 B3 00 7A 00 BD 05 4B 04 B4 00 6E 02 6F 02 6A 04 B5 00 DE 06 B6 00 DF 06 03 00 04 00 05 00 06 00 5B 02 B7 00 63 05 2F 01 C7 03 E0 03 6B 05 7F 02 81 02 BF 04 C0 03 30 01 B1 03 CE 06 35 00 C4 03 C6 03 B8 00 9B 03 9C 02 07 05 B4 05 EE 06 75 05 D3 04 78 06 35 00 A9 02 D6 01 9A 01 31 01 AE 02 A3 03 1B 02 C8 05 13 02 13 02 10 00 F5 01 8C 01 85 05 60 02 03 03 A2 02 B8 06 29 06 FD 06 FD 06 D0 00 57 03 A6 05 02 00 59 06 06 07 06 07 11 02 B7 02 79 03 1E 03 7B 03 BF 02 C0 02 C1 02 C2 02 C3 02 C4 02 C5 02 C6 02 C7 02 C8 02 C9 02 D6 01 0C 05 2F 05 DD 04 52 06 DF 04 14 00 60 02 E4 04 D0 00 D0 05 06 03 08 03 E7 05 12 02 0C 03 F1 03 31 00 F6 00 32 01 6A 01 00 03 EB 01 85 03 2A 06 A4 03 1F 03 E9 06 31 01 10 01 20 03 BC 01 AE 03 16 04 85 05 06 00 DB 02 88 03 AB 04 43 02 BE 05 D7 01 95 06 7A 00 07 04 B1 06 D8 01 1C 02 D9 01 0E 03 1D 03 DA 01 DB 01 C8 03 DC 01 DD 01 1D 03 3A 03 7A 00 00 07 1D 03 E7 05 3E 03 3D 06 64 00 2B 00 9A 01 CF 06 BD 01 08 04 40 06 F0 03 35 00 49 03 AF 03 1D 03 1B 03 2A 04 9A 01 5A 06 9A 01 7A 00 9A 01 4A 03 D7 01 53 03 85 03 44 05 32 01 D8 01 03 07 D9 01 C2 04 1B 04 DA 01 DB 01 09 04 DC 01 DD 01 5F 06 58 03 1B 03 1D 03 A7 05 48 03 37 00 F4 00 B1 04 7A 03 28 05 7C 03 2A 05 13 02 2B 05 D6 06 D7 06 16 03 17 03 7A 00 77 03 C2 05 1D 03 23 03 2B 04 7E 03 53 06 9A 01 D1 05 1B 03 F4 00 6A 03 6A 04 B7 02 D7 01 73 03 45 04 4C 03 60 02 D8 01 DE 01 D9 01 0E 02 87 03 DA 01 DB 01 86 03 DC 01 DD 01 3F 03 7D 01 1C 03 73 05 F4 00 BE 01 BF 01 7D 01 D2 00 12 02 80 03 89 03 AC 04 F4 00 7A 05 55 02 F4 00 05 05 7D 01 EC 00 44 04 96 02 7D 01 FA 06 F4 00 8F 03 0E 02 1C 03 1D 02 93 03 1E 06 9C 01 30 02 F4 00 E8 01 7D 01 1E 02 5E 04 5F 02 2C 04 7A 00 5D 04 A0 03 95 05 73 01 05 05 EF 03 9C 03 0D 06 4A 03 7F 02 81 02 B0 03 A7 03 1C 03 0A 04 0B 04 A8 03 A8 03 64 00 1D 03 1D 03 1D 03 BA 03 04 05 69 06 1D 03 7D 01 04 07 9C 03 1D 03 5A 04 AB 01 C1 03 13 02 07 01 8C 01 04 02 B6 03 20 05 9D 01 B8 03 31 01 0F 03 7C 05 1D 03 10 01 1B 03 1B 03 7F 02 81 02 83 02 1F 02 AC 03 11 02 89 06 8A 06 E5 06 86 03 8C 06 23 05 6A 04 C9 03 C9 03 60 02 E6 06 E8 05 6A 04 10 01 AC 01 47 02 9F 06 1D 03 4A 03 A6 06 BB 03 47 02 D3 00 A1 04 4B 03 9E 05 31 01 05 02 DC 03 08 01 5D 04 1D 03 54 04 D0 03 B7 06 5D 04 1D 03 5D 04 02 01 CC 03 5D 04 5D 04 03 01 5D 04 5D 04 7A 00 04 02 A7 02 60 02 12 02 13 02 9E 01 86 03 E9 05 5B 01 65 01 84 02 01 01 CD 06 E8 05 A8 02 55 05 9C 04 EA 05 4D 05 8C 01 1C 03 1C 03 60 04 8C 01 5D 04 E4 03 E7 06 E6 03 05 01 8C 01 20 04 C3 05 97 01 47 02 A3 04 30 04 EE 03 2C 06 1D 03 67 03 AC 02 EB 05 4B 03 6A 03 EC 05 05 02 04 01 D1 03 6A 03 6A 03 F6 05 EA 03 8C 01 AD 02 A0 01 E9 05 8C 01 A6 03 8C 01 8C 01 8C 01 8C 01 65 01 12 02 13 02 EA 05 8C 01 56 04 67 01 21 04 54 04 64 00 86 03 ED 05 C1 04 54 04 13 02 54 04 1D 03 1D 03 54 04 54 04 5D 04 54 04 54 04 EE 05 50 04 2D 06 53 01 EB 05 68 05 7A 00 EC 05 BD 04 1D 04 2B 06 11 02 F8 03 A5 04 8F 01 60 02 93 01 86 03 15 01 7A 00 43 02 86 03 0D 03 86 03 2F 02 42 04 27 02 35 00 D8 02 66 01 86 03 13 02 8C 01 35 00 D9 02 DA 02 ED 05 90 01 B9 01 BA 01 BB 01 7A 00 73 03 EE 01 EF 01 7A 00 F4 00 06 04 EE 05 6A 03 8E 01 B7 02 8C 05 29 03 F9 03 0D 03 53 01 1E 06 60 01 60 01 7A 00 8C 01 93 01 0D 03 C8 01 8C 01 56 04 7D 01 8C 01 10 01 8C 01 56 04 4D 03 56 04 C9 01 8C 01 56 04 56 04 08 05 56 04 56 04 86 03 60 01 54 04 1E 06 50 04 ED 06 3D 04 32 03 3E 04 50 04 D6 01 50 04 29 04 1E 06 50 04 50 04 46 04 50 04 50 04 84 01 47 04 35 03 8F 01 6D 03 C0 01 C1 01 2D 00 30 03 18 02 54 04 4C 04 49 04 64 00 9C 03 EF 04 CA 01 64 04 7B 00 35 01 59 04 32 03 1F 06 64 00 CB 01 32 03 90 01 C9 05 73 04 84 01 CC 01 35 03 C7 05 91 01 46 06 22 02 57 04 5C 04 58 04 13 02 35 03 30 03 CD 01 92 01 8E 01 13 02 35 02 54 06 35 01 10 01 36 02 63 02 6B 04 8E 01 15 03 8E 01 51 04 35 01 80 02 B7 02 4A 02 7B 00 D3 05 E6 05 56 04 B7 02 7B 00 73 03 E6 04 63 02 1F 03 67 06 7E 04 82 01 20 03 D7 01 7B 00 00 03 60 01 60 01 D8 01 82 02 D9 01 50 04 D3 05 DA 01 DB 01 29 03 DC 01 DD 01 4E 02 63 01 63 01 EC 00 6A 01 EF 00 30 05 8F 01 73 02 74 02 6A 01 38 03 7B 00 4F 02 CE 01 38 03 8F 01 6B 01 8F 01 4C 05 E1 00 E6 05 12 03 D3 05 80 02 63 01 7B 00 EC 00 14 03 F1 00 90 01 50 02 6A 03 7A 00 6A 03 7A 00 23 02 91 01 8F 01 90 01 9C 04 90 01 7D 01 8D 02 38 03 7D 01 91 01 92 01 91 01 DC 00 34 03 C7 04 B2 04 38 03 60 01 12 03 92 01 B4 04 92 01 DC 03 B4 04 90 01 A0 01 70 05 CC 03 8C 04 13 03 37 01 91 01 82 01 6A 03 82 01 73 03 82 01 94 04 7D 01 82 01 DB 03 82 01 34 03 60 01 7A 00 7B 00 82 01 7A 00 EC 01 F4 03 D1 02 34 03 A0 01 3D 05 A0 01 42 02 C6 01 C7 01 36 03 53 01 EF 04 F5 03 13 03 82 01 D4 04 3E 05 A0 01 82 01 60 01 7D 01 85 00 FA 01 85 00 A1 01 94 05 63 02 0F 02 85 00 07 03 09 03 82 01 7A 00 AB 06 80 02 63 01 63 01 53 01 A3 03 53 01 A3 03 F4 01 A3 03 DB 04 8F 02 90 01 FB 01 13 02 3F 01 6A 03 3F 01 6A 03 91 01 F2 01 6A 03 3F 01 90 02 60 01 60 01 FC 01 7D 01 8F 01 82 01 91 02 FE 01 71 01 7D 01 EE 04 3F 02 FF 01 FA 04 00 02 01 02 02 02 03 02 92 02 FE 04 7D 01 69 01 04 02 EA 02 7D 01 EA 02 05 02 90 01 8F 02 0D 04 31 06 36 01 25 02 37 01 91 01 60 01 0E 04 7D 01 06 02 E0 06 90 02 07 02 13 04 08 02 63 01 B7 04 0E 02 91 02 F9 01 73 03 26 02 33 04 27 02 80 02 D9 04 F8 05 7D 00 80 05 47 02 92 02 DA 04 C7 00 F7 04 C7 00 F8 04 C7 00 A1 01 09 02 7B 00 7D 01 63 01 C2 01 C3 01 7A 00 6B 04 1A 05 F6 06 48 02 85 02 60 01 86 02 42 02 63 01 7B 00 08 04 C4 01 C5 01 42 02 49 02 98 03 08 04 98 03 9C 03 98 03 89 02 63 01 8A 02 68 02 6A 03 7D 00 6A 03 63 01 6A 03 66 02 7D 00 2C 05 7B 00 60 01 60 01 39 05 8F 03 63 01 8F 03 65 05 7D 00 6A 02 64 04 10 01 43 02 0C 07 0D 07 D5 00 39 03 D5 00 DB 02 D5 00 3A 03 D5 01 32 06 E9 02 EB 02 ED 02 EF 02 63 01 63 01 33 05 48 02 51 06 87 02 D5 01 7D 00 D5 01 48 02 7B 00 72 02 B4 04 5D 03 DC 03 68 03 32 04 5E 03 23 02 36 02 33 04 7D 00 9D 02 51 06 9E 02 7F 02 81 02 D5 01 D5 01 13 02 5B 04 88 02 56 05 73 03 3A 03 63 01 9C 03 B9 04 1B 06 AE 05 63 01 D4 03 72 06 AF 05 73 06 A1 02 1B 06 D5 01 48 00 EE 04 DB 02 9A 02 48 00 E0 03 62 05 D5 01 E2 03 E0 03 D5 01 23 02 E2 03 9B 02 23 02 5E 01 5E 01 AF 02 F6 00 48 02 83 05 9F 02 EB 01 A0 02 84 05 8A 03 D2 04 8B 03 D4 03 7D 00 12 03 63 01 7B 00 7F 02 81 02 31 05 A3 01 32 05 A3 01 5E 01 6A 03 A4 01 AE 01 0D 02 F4 00 DA 03 7F 05 24 03 F6 00 35 00 90 01 35 00 EB 01 07 01 59 03 A5 01 9C 04 3B 03 7A 00 63 01 63 01 38 03 23 02 AF 01 B0 01 B1 01 B2 01 B3 01 B4 01 B5 01 B6 01 B7 01 B8 01 35 00 A6 01 A7 01 6A 03 2C 05 7D 01 7D 01 54 03 7D 01 7D 01 40 00 3D 03 83 05 35 00 5A 03 7F 04 84 05 7F 04 35 00 79 02 7A 02 A8 01 7A 00 35 00 5B 03 35 00 35 00 35 00 35 00 08 01 5C 03 35 00 A9 01 35 00 9A 03 83 03 9A 03 35 00 D2 05 E5 05 77 02 78 02 84 05 20 03 84 03 BB 00 13 02 BB 00 C2 00 35 00 C2 00 C3 00 35 00 C3 00 35 00 6A 03 7F 02 81 02 5E 01 7B 00 D2 05 8C 03 5E 01 5E 01 84 05 23 04 B7 02 23 04 4A 00 8E 03 4A 00 7A 00 90 03 DB 00 6A 03 DB 00 23 02 BC 00 35 00 BC 00 8A 00 7A 00 8A 00 7A 04 7B 04 7D 00 7A 00 E5 05 45 01 D2 05 45 01 20 03 91 00 84 05 91 00 94 03 4C 01 95 03 4C 01 96 03 7D 00 97 03 09 06 5B 05 5C 05 A3 05 F4 00 60 01 BD 03 12 07 AB 03 90 01 F2 01 EA 06 EB 06 B2 03 E5 01 E5 01 E6 01 E6 01 1D 03 1D 03 B3 03 7D 00 E0 02 E2 02 A9 03 AA 03 5E 01 E5 02 E7 02 BC 03 7F 02 81 02 B7 03 7A 00 F1 02 F3 02 CE 03 63 01 3C 04 21 06 7A 00 B9 03 BF 03 CF 03 7A 00 C3 03 42 02 E1 03 E3 03 7B 00 E5 03 E9 03 5E 01 F3 03 96 01 F2 03 FD 03 63 02 7D 00 00 04 FC 03 48 04 7B 00 2B 00 5E 01 17 04 18 04 3F 06 11 04 19 04 1A 04 1F 04 CF 00 7A 00 63 01 1E 04 D4 03 5E 01 34 04 31 04 39 04 35 04 4A 04 5E 01 7B 00 50 04 53 04 4F 04 7B 00 52 04 56 04 66 04 6A 04 5E 01 4C 04 3E 01 6E 04 75 04 21 06 77 04 7C 04 85 04 89 04 7B 00 86 04 8A 04 80 04 8D 04 88 04 90 04 92 04 9D 04 A9 04 AA 04 B3 04 5E 01 5E 01 AD 04 BC 04 C3 04 39 02 CD 04 CE 04 96 06 D5 04 D8 04 D0 04 20 03 D7 02 F3 04 E7 04 FB 04 1F 05 03 05 0B 05 0D 05 7A 00 01 05 63 01 02 05 B2 06 0E 05 11 05 29 05 20 03 1B 05 1D 05 21 05 22 05 36 05 5E 01 27 05 40 05 BE 06 C0 06 5E 01 39 05 20 03 20 03 3C 05 41 05 3F 05 42 05 4E 05 73 03 4B 05 52 05 5A 05 76 05 21 06 5D 05 8D 05 5E 05 60 01 65 05 6E 05 23 02 7B 05 82 05 63 01 9B 05 B2 06 B2 06 92 05 9A 05 20 03 20 03 9D 05 A0 05 A4 04 A2 05 A5 05 A8 05 C8 06 5E 01 A9 05 60 01 B2 05 B7 05 B9 05 BF 05 C0 05 C1 05 C6 05 63 01 C7 05 F3 05 F4 05 F9 05 2E 06 A0 06 FE 05 7A 00 FA 05 06 06 FB 05 F7 05 0B 06 25 06 3A 06 3C 06 60 01 5E 01 5E 01 4F 06 5E 06 57 06 73 03 7D 00 63 06 63 01 61 06 4E 06 58 06 5A 06 1E 06 64 06 66 06 B2 06 6F 06 68 06 45 06 20 03 6C 06 6E 06 75 06 6A 06 76 06 5F 01 5F 01 7E 06 81 06 85 06 5E 01 82 06 83 06 7B 06 8D 06 8E 06 AF 06 91 06 A1 00 9B 06 A2 06 73 03 AC 06 7B 00 AD 06 7B 00 13 02 13 02 B0 06 5F 01 B6 06 BA 06 D2 06 C5 06 C7 06 E2 06 FC 06 FC 06 CC 06 CA 06 D9 06 DD 06 A1 00 05 07 05 07 DC 06 B7 02 B7 02 E4 06 EC 06 E1 06 B9 06 C0 02 DB 06 C4 06 A1 00 F4 06 F5 06 0B 07 11 07 A1 00 09 07 09 00 63 01 F2 04 A1 00 F5 04 A1 00 A1 00 A1 00 A1 00 7B 00 0F 07 10 07 7B 00 A1 00 63 01 7D 00 14 07 A1 00 7B 04 60 01 C9 06 A1 00 00 04 68 02 63 01 40 02 15 00 01 04 7D 00 A1 00 EC 02 73 04 A1 00 DF 01 A1 00 41 02 D9 03 12 02 10 04 40 03 ED 02 1D 03 23 00 3F 02 24 00 DD 03 7B 00 23 00 13 02 63 01 7D 00 62 01 FA 00 63 01 7D 00 24 00 92 03 9C 03 A1 00 5F 01 08 04 93 03 9D 03 5F 01 5F 01 B5 02 94 03 B8 03 95 03 7D 00 5E 01 B9 03 34 03 34 03 C0 02 66 01 4A 03 7D 01 8D 00 C0 02 1D 03 C0 02 C0 02 C0 02 C0 02 C0 02 C0 02 C0 02 C0 02 C0 02 C0 02 C0 02 7B 00 48 01 94 00 8E 00 42 02 7C 00 49 01 95 00 F3 00 C0 02 C0 02 36 00 34 05 15 00 E8 04 5E 01 C0 02 84 04 C0 02 97 04 C0 02 60 05 C0 02 C0 02 C0 02 61 05 08 06 A1 00 FF 05 26 06 6C 05 DA 06 BB 06 C0 02 E3 06 AE 06 CB 06 5F 01 C0 02 03 04 18 06 35 06 04 06 A6 04 14 04 60 01 5D 06 60 01 C0 02 C0 02 A7 04 A8 04 7B 00 A2 04 47 06 5C 06 07 06 B5 02 08 07 63 01 63 01 C0 02 B5 02 5F 01 B5 02 B5 02 B5 02 B5 02 B5 02 B5 02 B5 02 B5 02 B5 02 B5 02 B5 02 5F 01 C6 06 F2 06 C1 06 5E 01 C0 02 BF 06 FF 06 BA 05 B5 02 B5 02 74 06 39 06 5F 01 81 04 56 02 B5 02 43 04 B5 02 5F 01 B5 02 BB 05 B5 02 B5 02 B5 02 BB 04 61 04 CC 04 28 04 5F 01 0F 05 39 01 B5 02 B5 02 70 02 24 05 26 05 B5 02 B5 02 10 04 CD 03 F5 02 25 04 F7 02 FD 02 5E 01 B5 02 B5 02 B5 02 B5 02 A2 03 5F 01 5F 01 F9 02 FE 02 FB 02 72 04 55 04 66 05 AB 05 0C 06 B5 02 63 01 50 05 99 03 7D 00 5E 01 7D 00 D0 01 4F 05 5E 01 57 05 60 01 1C 05 FC 04 51 05 98 05 A3 02 53 02 78 05 B5 02 82 03 CA 04 10 03 11 03 0A 06 5F 01 18 00 7F 04 19 00 9F 05 5F 01 1A 00 82 04 ED 03 28 00 5E 01 1B 00 00 00 00 00 00 00 00 00 1C 00 63 01 00 00 63 01 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 7D 00 00 00 00 00 7D 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 22 00 00 00 00 00 5F 01 00 00 00 00 00 00 00 00 00 00 00 00 8C 02 00 00 24 00 00 00 25 00 CD 05 7B 00 00 00 26 00 18 00 00 00 19 00 00 00 7D 00 1A 00 00 00 27 00 28 00 00 00 1B 00 29 00 5F 01 5F 01 54 02 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 5E 01 00 00 00 00 00 00 00 00 20 00 00 00 00 00 7B 00 00 00 21 00 00 00 00 00 5E 01 22 00 00 00 60 01 5F 01 00 00 00 00 00 00 00 00 00 00 5E 01 00 00 00 00 24 00 57 01 25 00 00 00 00 00 CD 05 26 00 63 01 00 00 00 00 00 00 00 00 00 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 57 00 5E 01 00 00 27 06 28 06 5E 01 00 00 00 00 00 00 00 00 7B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7B 00 00 00 00 00 00 00 00 00 7B 00 00 00 96 01 00 00 7D 00 00 00 49 06 00 00 00 00 4C 06 60 01 00 00 00 00 00 00 57 01 00 00 72 01 00 00 00 00 76 01 00 00 00 00 00 00 7F 01 81 01 83 01 85 01 87 01 89 01 8B 01 8D 01 00 00 00 00 60 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FA 01 7B 00 00 00 00 00 00 00 00 00 00 00 5E 01 7B 00 00 00 00 00 00 00 7B 00 96 01 00 00 00 00 00 00 00 00 00 00 5F 01 00 00 00 00 00 00 00 00 FB 01 00 00 00 00 00 00 00 00 63 01 5E 01 5E 01 00 00 00 00 00 00 00 00 00 00 FC 01 00 00 00 00 00 00 7B 00 FE 01 00 00 00 00 00 00 60 01 FF 01 00 00 00 02 01 02 02 02 03 02 00 00 00 00 00 00 5F 01 04 02 00 00 00 00 28 00 05 02 00 00 00 00 28 00 60 01 60 01 00 00 42 02 00 00 00 00 00 00 00 00 06 02 00 00 28 00 07 02 00 00 08 02 00 00 00 00 28 00 00 00 00 00 00 00 28 00 00 00 00 00 28 00 00 00 00 00 00 00 1A 00 60 01 00 00 63 01 60 01 00 00 00 00 00 00 28 00 28 00 09 02 00 00 7B 00 28 00 28 00 00 00 5E 01 00 00 00 00 28 00 00 00 28 00 28 00 28 00 28 00 00 00 63 01 00 00 5F 01 28 00 7D 00 00 00 00 00 28 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 28 00 28 00 5E 01 28 00 00 00 00 00 00 00 28 00 00 00 00 00 5E 01 00 00 5E 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D7 02 00 00 5F 01 00 00 45 06 00 00 00 00 28 00 00 00 00 00 C9 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 28 00 63 01 7B 00 63 01 5F 01 00 00 00 00 00 00 5F 01 00 00 00 00 63 01 00 00 72 01 00 00 00 00 00 00 00 00 00 00 00 00 63 01 63 01 00 00 63 01 00 00 00 00 00 00 00 00 00 00 00 00 7D 00 00 00 00 00 00 00 5F 01 00 00 00 00 00 00 00 00 00 00 7D 00 00 00 00 00 00 00 00 00 7D 00 00 00 00 00 63 01 00 00 00 00 63 01 6D 02 00 00 00 00 00 00 28 00 28 00 00 00 00 00 00 00 00 00 72 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 01 00 00 C9 02 00 00 00 00 00 00 00 00 C9 02 00 00 C9 02 C9 02 C9 02 C9 02 C9 02 C9 02 C9 02 C9 02 C9 02 C9 02 C9 02 00 00 7D 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 00 C9 02 C9 02 00 00 7D 00 00 00 00 00 00 00 C9 02 5F 01 C9 02 00 00 C9 02 00 00 C9 02 C9 02 C9 02 00 00 00 00 00 00 00 00 00 00 5F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C9 02 00 00 5F 01 7D 00 CB 02 CD 02 CF 02 00 00 00 00 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 6D 02 00 00 00 00 5F 01 00 00 00 00 00 00 5F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 C9 02 4C 02 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 5E 01 00 00 00 00 1A 00 00 00 00 00 00 00 1A 00 7D 00 00 00 1A 00 00 00 CD 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 1A 00 00 00 00 00 00 00 1A 00 1A 00 00 00 00 00 00 00 00 00 1A 00 00 00 1A 00 1A 00 1A 00 1A 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 1A 00 5F 01 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 1A 00 00 00 1A 00 00 00 5E 01 00 00 1A 00 00 00 00 00 5F 01 5F 01 00 00 6D 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 00 00 00 00 00 00 00 1A 00 5E 01 00 00 00 00 00 00 00 00 00 00 00 00 CD 02 00 00 17 00 1A 00 1A 00 CD 02 00 00 CD 02 CD 02 CD 02 CD 02 CD 02 CD 02 CD 02 CD 02 CD 02 CD 02 CD 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CD 02 CD 02 00 00 00 00 00 00 00 00 00 00 CD 02 00 00 CD 02 00 00 CD 02 00 00 CD 02 CD 02 CD 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 01 5E 01 00 00 5E 01 00 00 00 00 00 00 1A 00 1A 00 00 00 00 00 5E 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 5E 01 5E 01 B5 03 5E 01 00 00 00 00 00 00 00 00 00 00 38 06 00 00 00 00 00 00 5F 01 00 00 00 00 00 00 18 00 00 00 19 00 00 00 5F 01 1A 00 5F 01 00 00 CD 02 38 06 1B 00 5E 01 00 00 00 00 5E 01 1C 00 00 00 00 00 00 00 1D 00 00 00 00 00 38 06 00 00 1E 00 00 00 00 00 00 00 7D 01 1F 00 00 00 20 00 00 00 00 00 7D 01 7D 01 21 00 00 00 00 00 00 00 22 00 23 00 D8 03 D9 03 85 03 7D 01 38 06 7D 01 85 03 7D 01 85 03 00 00 24 00 00 00 25 00 4C 02 00 00 85 03 26 00 72 01 4C 02 4C 02 7D 01 00 00 00 00 00 00 27 00 28 00 7D 01 7D 01 29 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 02 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 7D 01 4C 02 4C 02 7D 01 00 00 00 00 4C 02 00 00 00 00 4C 02 5F 01 4C 02 85 03 4C 02 4C 02 4C 02 4C 02 00 00 00 00 00 00 00 00 4C 02 00 00 00 00 00 00 4C 02 00 00 00 00 00 00 4C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 02 00 00 00 00 4C 02 00 00 4C 02 4C 02 00 00 00 00 00 00 4C 02 4C 02 00 00 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 00 00 00 00 2B 00 00 00 00 00 4C 02 4C 02 4C 02 00 00 4C 02 4C 02 00 00 00 00 00 00 00 00 4C 02 4C 02 00 00 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 72 01 4C 02 4C 02 00 00 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 02 04 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 4C 02 00 00 00 00 4C 02 5F 01 4C 02 00 00 4C 02 00 00 00 00 4C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 02 21 00 21 00 00 00 00 00 A6 03 21 00 00 00 00 00 00 00 21 00 00 00 21 00 00 00 00 00 21 00 00 00 21 00 21 00 00 00 21 00 00 00 00 00 21 00 00 00 21 00 00 00 21 00 21 00 21 00 21 00 00 00 00 00 21 00 21 00 00 00 00 00 00 00 00 00 21 00 00 00 21 00 21 00 21 00 00 00 00 00 21 00 21 00 21 00 00 00 21 00 5F 01 00 00 21 00 00 00 21 00 21 00 21 00 21 00 21 00 00 00 00 00 21 00 21 00 21 00 00 00 00 00 21 00 21 00 21 00 00 00 00 00 00 00 00 00 5F 01 00 00 21 00 21 00 00 00 21 00 21 00 00 00 21 00 21 00 21 00 00 00 00 00 00 00 21 00 A6 03 00 00 00 00 00 00 00 00 A6 03 00 00 A6 03 A6 03 A6 03 A6 03 A6 03 A6 03 A6 03 A6 03 A6 03 A6 03 A6 03 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A6 03 A6 03 21 00 21 00 21 00 00 00 21 00 A6 03 00 00 A6 03 00 00 A6 03 21 00 A6 03 A6 03 A6 03 00 00 00 00 B2 03 5F 01 00 00 5F 01 00 00 00 00 00 00 00 00 00 00 00 00 93 01 5F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6D 02 5F 01 5F 01 00 00 5F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 93 01 21 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 21 00 00 00 00 00 00 00 93 01 5F 01 00 00 00 00 5F 01 93 01 A6 03 00 00 10 01 00 00 93 01 00 00 93 01 93 01 93 01 93 01 00 00 00 00 00 00 00 00 93 01 00 00 00 00 00 00 93 01 00 00 00 00 00 00 93 01 00 00 00 00 D7 04 00 00 00 00 02 04 02 04 93 01 DC 04 00 00 93 01 00 00 93 01 02 04 02 04 02 04 02 04 02 04 00 00 02 04 02 04 00 00 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 00 00 00 00 7D 01 00 00 02 04 93 01 02 04 02 04 02 04 02 04 02 04 02 04 00 00 00 00 02 04 00 00 93 01 00 00 02 04 02 04 00 00 02 04 02 04 02 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 04 02 04 00 00 02 04 00 00 02 04 02 04 00 00 00 00 02 04 00 00 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 02 04 00 00 02 04 00 00 00 00 02 04 02 04 00 00 00 00 02 04 02 04 00 00 93 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 04 02 04 02 04 02 04 02 04 00 00 00 00 02 04 02 04 02 04 00 00 00 00 00 00 02 04 02 04 00 00 00 00 02 04 00 00 00 00 00 00 00 00 02 04 02 04 02 04 02 04 02 04 00 00 00 00 00 00 02 04 00 00 02 04 00 00 00 00 00 00 00 00 00 00 02 04 02 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 04 02 04 02 04 02 04 00 00 02 04 00 00 02 04 B2 03 B2 03 00 00 00 00 00 00 7D 01 00 00 02 04 B2 03 B2 03 B2 03 B2 03 B2 03 00 00 B2 03 B2 03 00 00 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 00 00 00 00 00 00 00 00 00 00 B2 03 00 00 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 00 00 00 00 B2 03 00 00 00 00 00 00 B2 03 B2 03 00 00 B2 03 B2 03 B2 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B2 03 B2 03 00 00 B2 03 00 00 B2 03 B2 03 00 00 00 00 B2 03 00 00 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 B2 03 00 00 B2 03 00 00 00 00 B2 03 B2 03 00 00 00 00 B2 03 B2 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B2 03 B2 03 B2 03 B2 03 B2 03 7D 01 00 00 B2 03 B2 03 B2 03 7D 01 7D 01 00 00 B2 03 B2 03 00 00 00 00 B2 03 00 00 00 00 00 00 00 00 B2 03 B2 03 B2 03 B2 03 B2 03 00 00 00 00 00 00 B2 03 00 00 B2 03 00 00 7D 01 00 00 00 00 00 00 B2 03 B2 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 7D 01 82 03 00 00 7D 01 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 B2 03 B2 03 B2 03 B2 03 7D 01 B2 03 00 00 B2 03 7D 01 00 00 00 00 00 00 7D 01 00 00 00 00 B2 03 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 7D 01 7D 01 00 00 00 00 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 7D 01 00 00 7D 01 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 7D 01 7D 01 00 00 00 00 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 7D 01 7D 01 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 82 03 00 00 00 00 00 00 00 00 82 03 82 03 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 7D 01 00 00 7D 01 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 03 7D 01 00 00 A6 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 03 82 03 00 00 00 00 00 00 82 03 00 00 00 00 82 03 00 00 82 03 00 00 82 03 82 03 82 03 82 03 00 00 00 00 00 00 00 00 82 03 00 00 00 00 00 00 82 03 00 00 00 00 00 00 82 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 03 00 00 00 00 82 03 00 00 82 03 82 03 00 00 00 00 00 00 82 03 82 03 00 00 82 03 82 03 82 03 82 03 82 03 82 03 82 03 82 03 82 03 82 03 82 03 00 00 00 00 00 00 00 00 00 00 82 03 82 03 00 00 00 00 82 03 82 03 00 00 00 00 00 00 00 00 82 03 82 03 82 03 82 03 82 03 82 03 00 00 82 03 82 03 82 03 00 00 82 03 82 03 00 00 00 00 82 03 82 03 82 03 82 03 73 01 00 00 00 00 82 03 82 03 73 01 73 01 00 00 82 03 82 03 82 03 82 03 82 03 82 03 82 03 82 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 03 00 00 73 01 82 03 00 00 82 03 00 00 82 03 00 00 00 00 82 03 00 00 00 00 00 00 00 00 73 01 73 01 00 00 00 00 82 03 73 01 9B 01 00 00 73 01 00 00 73 01 00 00 73 01 73 01 73 01 73 01 00 00 00 00 00 00 00 00 73 01 00 00 00 00 00 00 73 01 00 00 00 00 00 00 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 73 01 00 00 00 00 73 01 00 00 73 01 73 01 00 00 00 00 00 00 73 01 73 01 00 00 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 00 00 00 00 00 00 00 00 00 00 73 01 73 01 00 00 00 00 73 01 73 01 00 00 00 00 00 00 00 00 73 01 73 01 73 01 73 01 73 01 73 01 00 00 73 01 73 01 73 01 00 00 73 01 73 01 00 00 00 00 73 01 73 01 73 01 73 01 00 00 00 00 00 00 73 01 73 01 00 00 00 00 00 00 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 A6 01 00 00 00 00 00 00 00 00 A6 01 A6 01 00 00 00 00 00 00 00 00 73 01 00 00 00 00 73 01 00 00 73 01 00 00 73 01 00 00 00 00 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A6 01 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A6 01 A6 01 00 00 00 00 00 00 A6 01 00 00 00 00 27 00 00 00 A6 01 00 00 A6 01 A6 01 A6 01 A6 01 00 00 00 00 00 00 00 00 A6 01 00 00 00 00 00 00 A6 01 00 00 00 00 00 00 A6 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A6 01 00 00 00 00 A6 01 00 00 A6 01 A6 01 00 00 00 00 00 00 A6 01 A6 01 00 00 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 00 00 00 00 00 00 00 00 00 00 A6 01 A6 01 00 00 00 00 A6 01 A6 01 00 00 00 00 00 00 00 00 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 00 00 A6 01 A6 01 A6 01 00 00 A6 01 A6 01 00 00 00 00 A6 01 A6 01 A6 01 A6 01 00 00 26 00 00 00 A6 01 A6 01 00 00 00 00 00 00 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 A6 01 9B 01 00 00 00 00 00 00 00 00 9B 01 9B 01 00 00 00 00 00 00 00 00 A6 01 00 00 00 00 A6 01 00 00 A6 01 00 00 A6 01 00 00 00 00 A6 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9B 01 A6 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9B 01 9B 01 00 00 00 00 00 00 9B 01 00 00 00 00 9B 01 00 00 9B 01 00 00 9B 01 9B 01 9B 01 9B 01 00 00 1B 00 00 00 00 00 9B 01 00 00 00 00 00 00 9B 01 00 00 00 00 00 00 9B 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9B 01 00 00 00 00 9B 01 00 00 9B 01 9B 01 00 00 00 00 00 00 9B 01 9B 01 00 00 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 00 00 00 00 00 00 00 00 00 00 9B 01 9B 01 00 00 00 00 9B 01 9B 01 00 00 00 00 00 00 00 00 9B 01 9B 01 00 00 9B 01 9B 01 9B 01 00 00 9B 01 9B 01 9B 01 00 00 9B 01 9B 01 00 00 00 00 9B 01 9B 01 9B 01 9B 01 00 00 00 00 00 00 9B 01 9B 01 00 00 25 00 00 00 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 9B 01 00 00 00 00 00 00 27 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 9B 01 00 00 00 00 9B 01 00 00 9B 01 00 00 27 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 27 00 00 00 9B 01 27 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 27 00 00 00 00 00 00 00 27 00 27 00 00 00 35 00 00 00 00 00 27 00 00 00 27 00 27 00 27 00 27 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 27 00 00 00 27 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 27 00 00 00 27 00 27 00 00 00 27 00 00 00 00 00 35 00 27 00 26 00 00 00 00 00 35 00 26 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 26 00 00 00 68 04 35 00 27 00 00 00 26 00 35 00 00 00 00 00 26 00 00 00 00 00 26 00 00 00 00 00 27 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 26 00 26 00 00 00 00 00 00 00 26 00 26 00 00 00 00 00 00 00 00 00 26 00 00 00 26 00 26 00 26 00 26 00 00 00 00 00 00 00 00 00 26 00 00 00 35 00 00 00 26 00 00 00 26 00 00 00 00 00 35 00 35 00 00 00 00 00 1B 00 00 00 00 00 26 00 1B 00 00 00 26 00 35 00 26 00 00 00 00 00 00 00 26 00 27 00 27 00 1B 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 1B 00 00 00 00 00 1B 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 1B 00 00 00 26 00 26 00 1B 00 1B 00 00 00 00 00 00 00 00 00 1B 00 00 00 1B 00 1B 00 1B 00 1B 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 1B 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 07 00 1B 00 00 00 1B 00 25 00 00 00 00 00 1B 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 26 00 26 00 00 00 00 00 25 00 00 00 1B 00 00 00 25 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 1B 00 1B 00 00 00 00 00 00 00 69 04 25 00 25 00 00 00 05 00 00 00 25 00 25 00 35 00 00 00 00 00 00 00 25 00 00 00 25 00 25 00 25 00 25 00 00 00 35 00 00 00 00 00 25 00 00 00 00 00 35 00 25 00 00 00 25 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 25 00 00 00 25 00 35 00 35 00 00 00 25 00 00 00 35 00 35 00 00 00 1B 00 1B 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 25 00 00 00 35 00 00 00 35 00 36 00 00 00 00 00 00 00 00 00 00 00 68 04 25 00 00 00 35 00 35 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 25 00 25 00 00 00 00 00 35 00 00 00 00 00 35 00 35 00 00 00 35 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 35 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 36 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 35 00 36 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 36 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 35 00 36 00 36 00 00 00 69 04 00 00 36 00 36 00 35 00 00 00 00 00 00 00 36 00 00 00 36 00 36 00 36 00 36 00 00 00 35 00 00 00 00 00 36 00 00 00 00 00 35 00 36 00 00 00 36 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 36 00 00 00 36 00 35 00 35 00 00 00 36 00 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 36 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 36 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 35 00 36 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 36 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 36 00 36 00 00 00 00 00 00 00 36 00 36 00 00 00 00 00 00 00 00 00 36 00 00 00 36 00 36 00 36 00 36 00 00 00 00 00 36 00 36 00 36 00 00 00 00 00 00 00 36 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 36 00 00 00 36 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 36 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 3A 00 19 00 00 00 00 00 1A 00 3B 00 00 00 3C 00 3D 00 1B 00 3E 00 3F 00 40 00 41 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 43 00 1E 00 44 00 45 00 46 00 47 00 00 00 00 00 20 00 00 00 00 00 00 00 48 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 4C 00 00 00 24 00 00 00 25 00 4D 00 36 00 36 00 26 00 00 00 4E 00 4F 00 50 00 51 00 52 00 53 00 27 00 28 00 54 00 55 00 29 00 56 00 00 00 57 00 00 00 00 00 58 00 59 00 00 00 00 00 5A 00 5B 00 00 00 85 03 00 00 00 00 00 00 00 00 00 00 85 03 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 66 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 85 03 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 70 00 71 00 72 00 00 00 00 00 00 00 73 00 00 00 85 03 00 00 00 00 00 00 00 00 85 03 CF 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 00 00 00 00 00 00 00 00 85 03 85 03 00 00 85 03 85 03 00 00 00 00 00 00 00 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 85 03 85 03 00 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 85 03 00 00 85 03 92 01 85 03 85 03 85 03 85 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 92 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 92 01 00 00 00 00 85 03 00 00 92 01 00 00 00 00 0F 01 00 00 92 01 00 00 92 01 92 01 92 01 92 01 00 00 00 00 00 00 00 00 92 01 00 00 00 00 00 00 92 01 00 00 00 00 00 00 92 01 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 92 01 00 00 00 00 92 01 00 00 92 01 00 00 00 00 85 03 00 00 00 00 00 00 00 00 85 03 00 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 00 00 92 01 00 00 00 00 85 03 85 03 7D 01 85 03 85 03 00 00 00 00 00 00 92 01 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 85 03 85 03 00 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 00 00 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 85 03 7D 01 92 01 00 00 85 03 00 00 85 03 7D 01 00 00 85 03 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 85 03 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 85 03 00 00 00 00 7D 01 7D 01 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 7D 01 7D 01 00 00 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 00 00 00 00 7D 01 35 00 7D 01 7D 01 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 7D 01 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 7D 01 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 7D 01 00 00 35 00 00 00 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 35 00 00 00 7D 01 7D 01 00 00 7D 01 7D 01 00 00 00 00 00 00 00 00 29 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 4E 02 00 00 21 00 7D 01 00 00 7D 01 4E 02 00 00 7D 01 35 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 4E 02 21 00 00 00 00 00 00 00 00 00 21 00 00 00 21 00 21 00 21 00 21 00 00 00 00 00 21 00 00 00 21 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 21 00 00 00 21 00 00 00 00 00 00 00 4E 02 00 00 00 00 00 00 00 00 4E 02 00 00 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 60 04 00 00 21 00 00 00 00 00 00 00 00 00 4E 02 00 00 4E 02 4E 02 00 00 00 00 21 00 21 00 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 00 00 4E 02 4E 02 00 00 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 00 00 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 4E 02 00 00 4A 02 00 00 00 00 00 00 00 00 4E 02 4A 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 02 00 00 00 00 00 00 60 04 00 00 00 00 00 00 00 00 60 04 00 00 60 04 60 04 60 04 60 04 60 04 60 04 60 04 60 04 60 04 60 04 00 00 00 00 00 00 00 00 00 00 4A 02 00 00 00 00 00 00 00 00 60 04 60 04 00 00 00 00 00 00 00 00 00 00 60 04 00 00 60 04 00 00 60 04 00 00 60 04 60 04 60 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 02 00 00 00 00 00 00 00 00 4A 02 00 00 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 02 00 00 4A 02 4A 02 00 00 00 00 00 00 00 00 4A 02 4A 02 60 04 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 00 00 4A 02 4A 02 00 00 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 00 00 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 4A 02 00 00 52 02 00 00 00 00 00 00 35 00 4A 02 52 02 00 00 4A 02 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 4A 02 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 52 02 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 52 02 00 00 35 00 00 00 00 00 52 02 00 00 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 00 00 00 00 00 00 00 00 35 00 00 00 00 00 52 02 00 00 52 02 52 02 00 00 00 00 00 00 00 00 2A 00 52 02 00 00 52 02 52 02 52 02 52 02 52 02 52 02 52 02 00 00 52 02 52 02 00 00 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 00 00 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 52 02 00 00 7D 01 00 00 21 00 00 00 21 00 52 02 7D 01 00 00 52 02 35 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 52 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 7D 01 21 00 00 00 00 00 00 00 00 00 21 00 00 00 21 00 21 00 21 00 21 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 21 00 00 00 21 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 21 00 00 00 00 00 00 00 00 00 7D 01 00 00 7D 01 7D 01 00 00 00 00 21 00 21 00 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 02 00 00 00 00 00 00 35 00 7D 01 00 02 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 02 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 02 00 00 00 00 00 00 00 00 00 02 00 00 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 00 00 00 C6 02 00 00 35 00 00 00 00 00 00 02 00 00 00 02 00 02 35 00 35 00 00 00 00 00 ED 00 00 02 00 00 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 00 00 02 00 02 00 00 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 00 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 00 6E 02 00 00 00 00 00 00 00 00 00 02 6E 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 C6 02 00 00 00 00 00 00 00 00 C6 02 00 00 C6 02 C6 02 C6 02 C6 02 C6 02 C6 02 C6 02 C6 02 C6 02 C6 02 C6 02 00 00 00 00 6E 02 00 00 00 00 00 00 00 00 00 00 00 00 C6 02 C6 02 00 00 00 00 00 00 00 00 00 00 C6 02 00 00 C6 02 00 00 C6 02 00 00 C6 02 C6 02 C6 02 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 C6 02 00 00 85 03 00 00 00 00 6E 02 00 00 00 00 00 00 00 00 6E 02 C6 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 C6 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6E 02 6E 02 00 00 7D 01 00 00 00 00 00 00 6E 02 00 00 6E 02 C6 02 6E 02 00 00 6E 02 6E 02 6E 02 00 00 6E 02 6E 02 85 03 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 00 00 00 00 00 00 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 6E 02 00 00 6E 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 6E 02 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 85 03 7D 01 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 73 01 00 00 00 00 7D 01 35 00 7D 01 73 01 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 73 01 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 BD 01 00 00 00 00 00 00 00 00 00 00 BD 01 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 73 01 00 00 00 00 00 00 00 00 73 01 00 00 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 00 00 00 00 00 00 00 00 35 00 00 00 73 01 BD 01 BD 01 73 01 73 01 35 00 35 00 00 00 00 00 EF 00 73 01 73 01 73 01 BD 01 73 01 BD 01 73 01 73 01 73 01 00 00 73 01 73 01 00 00 00 00 73 01 73 01 73 01 73 01 00 00 00 00 00 00 73 01 73 01 00 00 BD 01 BD 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BD 01 73 01 00 00 00 00 00 00 00 00 73 01 00 00 BD 01 00 00 00 00 BD 01 00 00 73 01 BD 01 00 00 00 00 00 00 00 00 00 00 73 01 00 00 00 00 BD 01 73 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 00 00 BD 01 BD 01 00 00 BD 01 BD 01 BD 01 BD 01 BD 01 00 00 BD 01 BD 01 BD 01 BD 01 00 00 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 BD 01 00 00 99 02 00 00 35 00 73 01 00 00 BD 01 99 02 00 00 BD 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BD 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 99 02 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 99 02 00 00 00 00 00 00 00 00 99 02 00 00 99 02 99 02 99 02 99 02 99 02 99 02 99 02 99 02 99 02 99 02 99 02 00 00 00 00 35 00 00 00 00 00 00 00 00 00 BE 01 9D 02 99 02 99 02 00 00 00 00 52 01 9D 02 00 00 99 02 00 00 99 02 BE 01 99 02 BE 01 99 02 99 02 99 02 00 00 99 02 99 02 00 00 00 00 99 02 99 02 99 02 99 02 00 00 00 00 00 00 99 02 99 02 00 00 BE 01 BE 01 99 02 99 02 99 02 99 02 99 02 99 02 99 02 99 02 00 00 9D 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BE 01 99 02 00 00 00 00 00 00 00 00 00 00 00 00 BE 01 00 00 00 00 BE 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 99 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9D 02 00 00 00 00 00 00 00 00 9D 02 00 00 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C1 01 9C 02 9D 02 9D 02 00 00 00 00 00 00 9C 02 00 00 9D 02 00 00 9D 02 C1 01 9D 02 C1 01 9D 02 9D 02 9D 02 00 00 9D 02 9D 02 00 00 00 00 9D 02 9D 02 9D 02 9D 02 00 00 00 00 00 00 9D 02 9D 02 00 00 C1 01 C1 01 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 9D 02 00 00 9C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C1 01 9D 02 00 00 00 00 00 00 00 00 00 00 00 00 C1 01 00 00 00 00 C1 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9D 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9C 02 00 00 00 00 00 00 00 00 9C 02 00 00 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CB 01 73 01 9C 02 9C 02 00 00 00 00 00 00 73 01 00 00 9C 02 00 00 9C 02 CB 01 9C 02 CB 01 9C 02 9C 02 9C 02 00 00 9C 02 9C 02 00 00 00 00 9C 02 9C 02 9C 02 9C 02 00 00 00 00 00 00 9C 02 9C 02 00 00 CB 01 CB 01 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 9C 02 00 00 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CB 01 9C 02 00 00 00 00 00 00 00 00 00 00 00 00 CB 01 00 00 00 00 CB 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 02 00 00 00 00 00 00 73 01 00 00 85 02 00 00 00 00 73 01 00 00 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 00 00 00 00 00 00 00 00 00 00 00 00 73 01 00 00 00 00 73 01 73 01 00 00 00 00 00 00 00 00 00 00 73 01 73 01 73 01 00 00 73 01 85 02 73 01 73 01 73 01 00 00 73 01 73 01 00 00 00 00 73 01 73 01 73 01 73 01 00 00 00 00 00 00 73 01 73 01 00 00 00 00 00 00 73 01 73 01 73 01 73 01 73 01 73 01 73 01 73 01 00 00 78 03 00 00 00 00 00 00 00 00 00 00 78 03 00 00 00 00 00 00 73 01 85 02 00 00 00 00 00 00 73 01 85 02 00 00 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 73 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 02 85 02 00 00 00 00 00 00 78 03 00 00 85 02 00 00 85 02 00 00 85 02 00 00 85 02 85 02 85 02 00 00 85 02 85 02 00 00 00 00 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 00 00 00 00 00 00 85 02 85 02 85 02 85 02 85 02 85 02 85 02 85 02 00 00 8C 02 00 00 00 00 00 00 78 03 00 00 8C 02 00 00 00 00 78 03 85 02 78 03 78 03 78 03 78 03 78 03 78 03 78 03 78 03 78 03 78 03 78 03 00 00 00 00 00 00 00 00 00 00 00 00 78 03 85 02 00 00 78 03 78 03 00 00 00 00 00 00 00 00 00 00 78 03 00 00 78 03 00 00 78 03 8C 02 78 03 78 03 78 03 00 00 78 03 78 03 00 00 00 00 78 03 78 03 78 03 78 03 00 00 00 00 00 00 78 03 78 03 00 00 00 00 00 00 78 03 78 03 78 03 78 03 78 03 78 03 78 03 78 03 00 00 08 04 00 00 00 00 00 00 00 00 00 00 08 04 00 00 00 00 00 00 78 03 8C 02 00 00 00 00 00 00 78 03 8C 02 00 00 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 78 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8C 02 8C 02 00 00 00 00 00 00 08 04 00 00 8C 02 00 00 8C 02 00 00 8C 02 00 00 8C 02 8C 02 8C 02 00 00 8C 02 8C 02 00 00 00 00 8C 02 8C 02 8C 02 8C 02 00 00 00 00 00 00 8C 02 8C 02 00 00 00 00 00 00 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 8C 02 00 00 8D 02 00 00 00 00 00 00 08 04 00 00 8D 02 00 00 00 00 08 04 8C 02 08 04 08 04 08 04 08 04 08 04 08 04 08 04 08 04 08 04 08 04 08 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8C 02 00 00 08 04 08 04 00 00 00 00 00 00 00 00 00 00 08 04 00 00 08 04 00 00 08 04 8D 02 08 04 08 04 08 04 00 00 08 04 08 04 00 00 00 00 08 04 08 04 08 04 08 04 00 00 00 00 00 00 08 04 08 04 00 00 00 00 00 00 08 04 08 04 08 04 08 04 08 04 08 04 08 04 08 04 00 00 8E 02 00 00 00 00 00 00 00 00 00 00 8E 02 00 00 00 00 00 00 08 04 8D 02 00 00 00 00 00 00 00 00 8D 02 00 00 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 08 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8D 02 8D 02 00 00 00 00 00 00 8E 02 00 00 8D 02 00 00 8D 02 00 00 8D 02 00 00 8D 02 8D 02 8D 02 00 00 8D 02 8D 02 00 00 00 00 8D 02 8D 02 8D 02 8D 02 00 00 00 00 00 00 8D 02 8D 02 00 00 00 00 00 00 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 8D 02 00 00 00 00 00 00 00 00 00 00 8E 02 00 00 00 00 00 00 00 00 8E 02 8D 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8D 02 00 00 8E 02 8E 02 00 00 00 00 00 00 00 00 00 00 8E 02 00 00 8E 02 00 00 8E 02 00 00 8E 02 8E 02 8E 02 00 00 8E 02 8E 02 00 00 00 00 8E 02 8E 02 8E 02 8E 02 00 00 00 00 00 00 8E 02 8E 02 00 00 00 00 00 00 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 8E 02 00 00 2A 02 00 00 A7 02 00 00 00 00 00 00 00 00 00 00 39 00 18 00 8E 02 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 8E 02 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 A7 02 00 00 00 00 00 00 00 00 A7 02 00 00 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 5C 00 5D 00 5E 00 0D 01 2B 02 A8 02 00 00 61 00 62 00 A7 02 A7 02 00 00 00 00 00 00 00 00 00 00 A7 02 40 01 A7 02 00 00 A7 02 00 00 A7 02 A7 02 A7 02 00 00 00 00 00 00 00 00 00 00 A7 02 A7 02 A7 02 A7 02 00 00 00 00 00 00 A7 02 A7 02 00 00 00 00 00 00 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 A7 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A7 02 00 00 6F 00 2C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 02 2E 02 00 00 A7 02 A9 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A8 02 00 00 00 00 00 00 00 00 A8 02 00 00 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A8 02 A8 02 00 00 00 00 00 00 00 00 00 00 A8 02 00 00 A8 02 00 00 A8 02 00 00 A8 02 A8 02 A8 02 00 00 00 00 00 00 00 00 00 00 A8 02 A8 02 A8 02 A8 02 00 00 00 00 00 00 A8 02 A8 02 00 00 00 00 00 00 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 A8 02 AC 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A9 02 00 00 00 00 A8 02 00 00 A9 02 00 00 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 00 00 00 00 00 00 00 00 A8 02 00 00 00 00 00 00 00 00 A9 02 A9 02 00 00 00 00 00 00 00 00 00 00 A9 02 00 00 A9 02 00 00 A9 02 00 00 A9 02 A9 02 A9 02 00 00 00 00 00 00 00 00 00 00 A9 02 A9 02 A9 02 A9 02 00 00 00 00 00 00 A9 02 A9 02 00 00 00 00 00 00 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 A9 02 AD 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AC 02 00 00 00 00 A9 02 00 00 AC 02 00 00 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 00 00 00 00 00 00 00 00 A9 02 00 00 00 00 00 00 00 00 AC 02 AC 02 00 00 00 00 00 00 00 00 00 00 AC 02 00 00 AC 02 00 00 AC 02 00 00 AC 02 AC 02 AC 02 00 00 00 00 00 00 00 00 00 00 AC 02 AC 02 AC 02 AC 02 00 00 00 00 00 00 AC 02 AC 02 00 00 00 00 00 00 00 00 00 00 AC 02 AC 02 AC 02 AC 02 AC 02 AC 02 AE 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AD 02 00 00 00 00 AC 02 00 00 AD 02 00 00 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 00 00 00 00 00 00 00 00 AC 02 00 00 00 00 00 00 00 00 AD 02 AD 02 00 00 00 00 00 00 00 00 00 00 AD 02 00 00 AD 02 00 00 AD 02 00 00 AD 02 AD 02 AD 02 00 00 00 00 00 00 00 00 00 00 AD 02 AD 02 AD 02 AD 02 00 00 00 00 00 00 AD 02 AD 02 00 00 00 00 00 00 00 00 00 00 AD 02 AD 02 AD 02 AD 02 AD 02 AD 02 AF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AE 02 00 00 00 00 AD 02 00 00 AE 02 00 00 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 00 00 00 00 00 00 00 00 AD 02 00 00 00 00 00 00 00 00 AE 02 AE 02 00 00 00 00 00 00 00 00 00 00 AE 02 00 00 AE 02 00 00 AE 02 00 00 AE 02 AE 02 AE 02 00 00 00 00 00 00 00 00 00 00 AE 02 AE 02 AE 02 AE 02 00 00 00 00 00 00 AE 02 AE 02 00 00 00 00 00 00 00 00 00 00 AE 02 AE 02 AE 02 AE 02 AE 02 AE 02 B0 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AF 02 00 00 00 00 AE 02 00 00 AF 02 00 00 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 00 00 00 00 00 00 00 00 AE 02 00 00 00 00 00 00 00 00 AF 02 AF 02 00 00 00 00 00 00 00 00 00 00 AF 02 00 00 AF 02 00 00 AF 02 00 00 AF 02 AF 02 AF 02 00 00 00 00 00 00 00 00 00 00 AF 02 AF 02 AF 02 AF 02 7D 01 00 00 00 00 AF 02 AF 02 00 00 7D 01 00 00 00 00 00 00 AF 02 AF 02 AF 02 AF 02 AF 02 AF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B0 02 00 00 00 00 AF 02 00 00 B0 02 00 00 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 00 00 7D 01 00 00 00 00 AF 02 00 00 00 00 00 00 00 00 B0 02 B0 02 00 00 00 00 00 00 00 00 00 00 B0 02 00 00 B0 02 00 00 B0 02 00 00 B0 02 B0 02 B0 02 00 00 00 00 00 00 00 00 00 00 B0 02 B0 02 B0 02 B0 02 00 00 00 00 00 00 B0 02 B0 02 00 00 00 00 00 00 00 00 00 00 B0 02 B0 02 B0 02 B0 02 B0 02 B0 02 B6 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B0 02 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 B0 02 7D 01 7D 01 00 00 00 00 00 00 7D 01 7D 01 00 00 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 7D 01 00 00 B7 02 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 00 00 B6 02 00 00 00 00 00 00 00 00 B6 02 7D 01 B6 02 B6 02 B6 02 B6 02 B6 02 B6 02 B6 02 B6 02 B6 02 B6 02 B6 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B6 02 B6 02 00 00 00 00 00 00 00 00 00 00 B6 02 00 00 B6 02 00 00 B6 02 00 00 B6 02 B6 02 B6 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B6 02 B6 02 00 00 00 00 00 00 B6 02 B6 02 00 00 00 00 00 00 00 00 00 00 BA 02 00 00 B6 02 B6 02 B6 02 B6 02 00 00 00 00 00 00 00 00 00 00 B7 02 00 00 00 00 00 00 00 00 B7 02 B6 02 B7 02 B7 02 B7 02 B7 02 B7 02 B7 02 B7 02 B7 02 B7 02 B7 02 B7 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B6 02 00 00 B7 02 B7 02 00 00 00 00 00 00 00 00 00 00 B7 02 00 00 B7 02 00 00 B7 02 00 00 B7 02 B7 02 B7 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B7 02 B7 02 00 00 00 00 00 00 B7 02 B7 02 00 00 00 00 00 00 00 00 00 00 BB 02 00 00 B7 02 B7 02 B7 02 B7 02 00 00 00 00 00 00 00 00 00 00 BA 02 00 00 00 00 00 00 00 00 BA 02 B7 02 BA 02 BA 02 BA 02 BA 02 BA 02 BA 02 BA 02 BA 02 BA 02 BA 02 BA 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B7 02 00 00 BA 02 BA 02 00 00 00 00 00 00 00 00 00 00 BA 02 00 00 BA 02 00 00 BA 02 00 00 BA 02 BA 02 BA 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 02 BA 02 00 00 00 00 00 00 BA 02 BA 02 00 00 00 00 00 00 00 00 00 00 BD 02 00 00 00 00 00 00 BA 02 BA 02 00 00 00 00 00 00 00 00 00 00 BB 02 00 00 00 00 00 00 00 00 BB 02 BA 02 BB 02 BB 02 BB 02 BB 02 BB 02 BB 02 BB 02 BB 02 BB 02 BB 02 BB 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 02 00 00 BB 02 BB 02 00 00 00 00 00 00 00 00 00 00 BB 02 00 00 BB 02 00 00 BB 02 00 00 BB 02 BB 02 BB 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BB 02 BB 02 00 00 00 00 00 00 BB 02 BB 02 00 00 00 00 00 00 00 00 00 00 BE 02 00 00 00 00 00 00 BB 02 BB 02 00 00 00 00 00 00 00 00 00 00 BD 02 00 00 00 00 00 00 00 00 BD 02 BB 02 BD 02 BD 02 BD 02 BD 02 BD 02 BD 02 BD 02 BD 02 BD 02 BD 02 BD 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BB 02 00 00 BD 02 BD 02 00 00 00 00 00 00 00 00 00 00 BD 02 00 00 BD 02 00 00 BD 02 00 00 BD 02 BD 02 BD 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BD 02 00 00 00 00 00 00 BD 02 BD 02 00 00 00 00 00 00 00 00 00 00 C1 02 00 00 00 00 00 00 BD 02 BD 02 00 00 00 00 00 00 00 00 00 00 BE 02 00 00 00 00 00 00 00 00 BE 02 BD 02 BE 02 BE 02 BE 02 BE 02 BE 02 BE 02 BE 02 BE 02 BE 02 BE 02 BE 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BD 02 00 00 BE 02 BE 02 00 00 00 00 00 00 00 00 00 00 BE 02 00 00 BE 02 00 00 BE 02 00 00 BE 02 BE 02 BE 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BE 02 00 00 00 00 00 00 BE 02 BE 02 00 00 00 00 00 00 00 00 00 00 C3 02 00 00 00 00 00 00 BE 02 BE 02 00 00 00 00 00 00 00 00 00 00 C1 02 00 00 00 00 00 00 00 00 C1 02 BE 02 C1 02 C1 02 C1 02 C1 02 C1 02 C1 02 C1 02 C1 02 C1 02 C1 02 C1 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BE 02 00 00 C1 02 C1 02 00 00 00 00 00 00 00 00 00 00 C1 02 00 00 C1 02 00 00 C1 02 00 00 C1 02 C1 02 C1 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C1 02 00 00 00 00 00 00 00 00 C1 02 00 00 00 00 00 00 00 00 00 00 C4 02 00 00 00 00 00 00 C1 02 C1 02 00 00 00 00 00 00 00 00 00 00 C3 02 00 00 00 00 00 00 00 00 C3 02 C1 02 C3 02 C3 02 C3 02 C3 02 C3 02 C3 02 C3 02 C3 02 C3 02 C3 02 C3 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C1 02 00 00 C3 02 C3 02 00 00 00 00 00 00 00 00 00 00 C3 02 00 00 C3 02 00 00 C3 02 00 00 C3 02 C3 02 C3 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C3 02 00 00 00 00 00 00 00 00 00 00 C7 02 00 00 00 00 00 00 C3 02 C3 02 00 00 00 00 00 00 00 00 00 00 C4 02 00 00 00 00 00 00 00 00 C4 02 C3 02 C4 02 C4 02 C4 02 C4 02 C4 02 C4 02 C4 02 C4 02 C4 02 C4 02 C4 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C3 02 00 00 C4 02 C4 02 00 00 00 00 00 00 00 00 00 00 C4 02 00 00 C4 02 00 00 C4 02 00 00 C4 02 C4 02 C4 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 02 C4 02 00 00 00 00 00 00 00 00 00 00 C7 02 00 00 00 00 00 00 00 00 C7 02 C4 02 C7 02 C7 02 C7 02 C7 02 C7 02 C7 02 C7 02 C7 02 C7 02 C7 02 C7 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C4 02 00 00 C7 02 C7 02 00 00 00 00 00 00 00 00 00 00 C7 02 00 00 C7 02 00 00 C7 02 00 00 C7 02 C7 02 C7 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E3 00 00 00 C7 02 00 00 00 00 E3 00 00 00 00 00 00 00 E3 00 00 00 E3 00 00 00 C7 02 E3 00 00 00 E3 00 E3 00 00 00 E3 00 00 00 00 00 E3 00 00 00 E3 00 C7 02 E3 00 E3 00 E3 00 E3 00 00 00 00 00 E3 00 E3 00 00 00 D4 00 00 00 00 00 E3 00 00 00 E3 00 E3 00 E3 00 00 00 C7 02 E3 00 00 00 E3 00 D5 00 E3 00 00 00 00 00 E3 00 00 00 E3 00 E3 00 E3 00 E3 00 E3 00 00 00 00 00 E3 00 E3 00 E3 00 7D 01 00 00 E3 00 E3 00 E3 00 00 00 00 00 00 00 00 00 00 00 00 00 E3 00 E3 00 D6 00 E3 00 E3 00 00 00 E3 00 E3 00 E3 00 00 00 00 00 00 00 E3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 E3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E3 00 E3 00 E3 00 00 00 E3 00 00 00 00 00 00 00 00 00 00 00 E3 00 00 00 00 00 00 00 00 00 D7 00 D8 00 D9 00 DA 00 00 00 DB 00 DC 00 DD 00 DE 00 DF 00 E0 00 E1 00 E2 00 00 00 00 00 E3 00 E4 00 E5 00 E6 00 E7 00 E8 00 E9 00 EA 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 E3 00 00 00 00 00 00 00 00 00 00 00 00 00 E3 00 E3 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 00 00 00 00 00 00 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 7D 01 00 00 00 00 7B 02 00 00 7D 01 00 00 7D 01 00 00 00 00 7D 01 39 00 18 00 3A 00 19 00 13 05 00 00 1A 00 3B 00 7D 01 3C 00 3D 00 1B 00 3E 00 3F 00 40 00 41 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 43 00 1E 00 44 00 45 00 46 00 47 00 00 00 00 00 20 00 00 00 00 00 00 00 48 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 4C 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 4E 00 4F 00 50 00 51 00 52 00 53 00 27 00 28 00 54 00 55 00 29 00 56 00 00 00 57 00 00 00 00 00 58 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 66 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 70 00 71 00 72 00 38 00 14 05 00 00 73 00 00 00 00 00 00 00 00 00 39 00 18 00 3A 00 19 00 00 00 00 00 1A 00 3B 00 00 00 3C 00 3D 00 1B 00 3E 00 3F 00 40 00 41 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 43 00 1E 00 44 00 45 00 46 00 47 00 00 00 00 00 20 00 00 00 00 00 00 00 48 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 4C 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 4E 00 4F 00 50 00 51 00 52 00 53 00 27 00 28 00 54 00 55 00 29 00 56 00 00 00 57 00 00 00 00 00 58 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 66 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 70 00 71 00 72 00 18 01 00 00 00 00 73 00 00 00 00 00 00 00 00 00 39 00 18 00 3A 00 19 00 00 00 00 00 1A 00 3B 00 00 00 3C 00 3D 00 1B 00 3E 00 3F 00 40 00 41 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 43 00 1E 00 44 00 45 00 46 00 47 00 00 00 00 00 20 00 00 00 00 00 00 00 48 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 4C 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 4E 00 4F 00 50 00 51 00 52 00 53 00 27 00 28 00 54 00 55 00 29 00 56 00 00 00 57 00 00 00 00 00 58 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 66 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 70 00 71 00 72 00 7B 02 00 00 00 00 73 00 00 00 00 00 00 00 00 00 39 00 18 00 3A 00 19 00 00 00 00 00 1A 00 3B 00 00 00 3C 00 3D 00 1B 00 3E 00 3F 00 40 00 41 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 43 00 1E 00 44 00 45 00 46 00 47 00 00 00 00 00 20 00 00 00 00 00 00 00 48 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 4C 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 4E 00 4F 00 50 00 51 00 52 00 53 00 27 00 28 00 54 00 55 00 29 00 56 00 00 00 57 00 00 00 00 00 58 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 66 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 70 00 71 00 72 00 65 04 00 00 00 00 73 00 00 00 00 00 00 00 00 00 65 04 65 04 65 04 65 04 00 00 00 00 65 04 65 04 00 00 65 04 65 04 65 04 65 04 65 04 65 04 65 04 65 04 00 00 00 00 00 00 00 00 00 00 65 04 00 00 65 04 65 04 65 04 65 04 65 04 65 04 00 00 00 00 65 04 00 00 00 00 00 00 65 04 65 04 00 00 65 04 65 04 65 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 04 65 04 00 00 65 04 00 00 65 04 65 04 00 00 00 00 65 04 00 00 65 04 65 04 65 04 65 04 65 04 65 04 65 04 65 04 65 04 65 04 65 04 65 04 00 00 65 04 00 00 00 00 65 04 65 04 00 00 00 00 65 04 65 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 04 65 04 65 04 65 04 65 04 00 00 00 00 65 04 65 04 65 04 00 00 00 00 00 00 65 04 00 00 00 00 00 00 65 04 00 00 00 00 00 00 00 00 65 04 65 04 65 04 65 04 65 04 00 00 00 00 00 00 65 04 00 00 65 04 00 00 00 00 00 00 00 00 00 00 65 04 65 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B2 02 00 00 00 00 65 04 65 04 65 04 65 04 00 00 39 00 18 00 65 04 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 B3 02 00 00 00 00 00 00 00 00 00 00 00 00 B4 02 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 B5 02 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 B6 02 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 71 03 00 00 00 00 6F 00 70 00 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 01 00 00 00 00 24 00 00 00 25 00 4D 00 62 04 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 3F 02 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 04 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 FF 02 00 00 26 00 00 00 00 00 4F 00 70 04 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 71 04 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 71 03 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 3F 02 72 03 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 04 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 B3 02 00 00 00 00 00 00 00 00 00 00 00 00 B4 02 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 B5 02 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 01 00 00 00 00 6F 00 70 00 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 01 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 01 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 4A 01 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 03 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 71 03 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 3F 02 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 69 03 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 27 04 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 69 03 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B0 02 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 69 03 00 00 00 00 6F 00 70 00 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E9 04 00 00 00 00 6F 00 41 01 71 00 72 00 00 00 39 00 18 00 73 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 6F 00 EA 04 71 00 72 00 00 00 59 00 59 00 73 00 59 00 00 00 00 00 59 00 59 00 00 00 D0 02 00 00 59 00 59 00 59 00 59 00 00 00 59 00 00 00 18 00 00 00 19 00 00 00 59 00 1A 00 00 00 59 00 00 00 00 00 1B 00 00 00 00 00 00 00 59 00 1C 00 00 00 00 00 00 00 59 00 00 00 59 00 59 00 59 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 59 00 21 00 59 00 59 00 00 00 22 00 59 00 00 00 00 00 59 00 00 00 59 00 00 00 59 00 59 00 59 00 59 00 24 00 59 00 25 00 00 00 00 00 00 00 26 00 00 00 59 00 00 00 00 00 59 00 59 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 59 00 59 00 59 00 59 00 59 00 00 00 00 00 59 00 59 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 59 00 59 00 59 00 59 00 00 00 00 00 00 00 59 00 00 00 59 00 00 00 57 01 00 00 00 00 00 00 59 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 59 00 59 00 59 00 59 00 18 00 42 00 19 00 59 00 1E 00 1A 00 00 00 00 00 00 00 00 00 1B 00 20 00 00 00 00 00 96 01 1C 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 24 00 00 00 25 00 4D 00 21 00 00 00 26 00 00 00 22 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 02 04 29 00 00 00 24 00 00 00 25 00 00 00 00 00 59 00 26 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 54 02 00 00 5C 00 5D 00 5E 00 5F 00 5F 03 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 60 03 BA 04 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 57 01 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 61 03 71 00 72 00 00 00 42 00 62 03 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 63 03 20 00 00 00 00 00 00 00 00 00 21 00 96 01 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 5F 03 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 60 03 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 61 03 71 00 72 00 00 00 00 00 62 03 36 00 00 00 36 00 00 00 36 00 00 00 36 00 63 03 00 00 36 00 00 00 36 00 36 00 00 00 36 00 00 00 00 00 36 00 00 00 36 00 00 00 36 00 36 00 36 00 36 00 00 00 00 00 36 00 36 00 00 00 00 00 00 00 00 00 36 00 36 00 36 00 36 00 36 00 00 00 00 00 36 00 00 00 36 00 00 00 36 00 00 00 36 00 36 00 00 00 36 00 36 00 36 00 36 00 36 00 00 00 36 00 36 00 36 00 36 00 00 00 00 00 36 00 36 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 36 00 00 00 36 00 36 00 00 00 36 00 36 00 36 00 00 00 00 00 00 00 36 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 36 00 35 00 00 00 35 00 35 00 35 00 35 00 36 00 36 00 35 00 35 00 00 00 00 00 00 00 36 00 35 00 00 00 35 00 35 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 35 00 35 00 00 00 35 00 35 00 35 00 36 00 00 00 00 00 35 00 00 00 35 00 00 00 36 00 36 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 5B 00 00 00 00 00 35 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 35 00 00 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 35 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 00 00 36 00 00 00 35 00 35 00 36 00 00 00 36 00 00 00 00 00 36 00 00 00 36 00 36 00 00 00 36 00 00 00 00 00 36 00 35 00 36 00 00 00 36 00 36 00 36 00 36 00 00 00 00 00 36 00 36 00 5C 00 00 00 00 00 35 00 36 00 00 00 36 00 36 00 36 00 35 00 00 00 36 00 00 00 36 00 00 00 36 00 00 00 00 00 36 00 00 00 36 00 36 00 36 00 36 00 36 00 00 00 00 00 36 00 36 00 36 00 00 00 00 00 36 00 36 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 36 00 00 00 36 00 36 00 00 00 36 00 36 00 36 00 35 00 00 00 00 00 36 00 00 00 35 00 00 00 35 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 36 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 00 00 00 00 00 00 36 00 35 00 00 00 35 00 35 00 35 00 36 00 00 00 35 00 00 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 35 00 35 00 00 00 35 00 35 00 35 00 36 00 00 00 00 00 35 00 00 00 35 00 00 00 36 00 36 00 35 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 35 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 00 01 00 00 00 00 35 00 35 00 00 00 35 00 35 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 35 00 00 00 00 00 35 00 27 00 35 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 35 00 35 00 27 00 00 00 35 00 35 00 35 00 00 00 27 00 00 00 00 00 00 00 27 00 35 00 35 00 27 00 35 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 35 00 00 00 27 00 27 00 35 00 35 00 00 00 27 00 27 00 00 00 00 00 00 00 00 00 27 00 00 00 27 00 27 00 27 00 27 00 00 00 35 00 00 00 00 00 27 00 00 00 00 00 00 00 27 00 00 00 27 00 00 00 01 01 00 00 00 00 35 00 00 00 00 00 00 00 00 00 27 00 00 00 27 00 27 00 00 00 27 00 00 00 00 00 00 00 27 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 27 00 00 00 25 00 00 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 27 00 27 00 35 00 00 00 00 00 00 00 25 00 25 00 00 00 35 00 35 00 25 00 25 00 00 00 00 00 00 00 00 00 25 00 00 00 25 00 25 00 25 00 25 00 00 00 00 00 00 00 00 00 25 00 00 00 00 00 00 00 25 00 00 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 00 00 00 6C 01 25 00 00 00 25 00 00 00 00 00 6D 01 25 00 39 00 18 00 00 00 19 00 27 00 27 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 25 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 25 00 25 00 20 00 00 00 00 00 6E 01 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 01 00 00 00 00 00 00 00 00 00 00 00 00 25 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 71 01 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 26 04 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 6C 01 00 00 00 00 6D 00 6E 00 00 00 6D 01 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 6E 01 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 71 01 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 6C 01 00 00 00 00 6D 00 6E 00 00 00 6D 01 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 6E 01 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 71 01 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 6C 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 71 01 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 7E 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 80 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 82 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 84 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 86 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 88 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 8A 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 8C 01 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 CA 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 CC 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 CE 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 DF 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 E1 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 E3 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 E6 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 E8 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 EA 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 EC 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 EE 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 F0 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 F2 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 F4 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 F6 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 F8 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 FA 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 FC 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 B4 03 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 D2 02 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 6F 00 0F 01 42 00 72 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 0E 01 00 00 00 00 61 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 1E 03 00 00 1E 03 00 00 1E 03 D3 02 D4 02 1E 03 00 00 1E 03 1E 03 00 00 1E 03 D5 02 00 00 1E 03 00 00 1E 03 00 00 1E 03 1E 03 1E 03 00 00 00 00 00 00 1E 03 1E 03 00 00 00 00 00 00 00 00 1E 03 00 00 1E 03 1E 03 00 00 00 00 00 00 1E 03 00 00 00 00 00 00 1E 03 00 00 6F 00 0F 01 00 00 D6 02 00 00 00 00 00 00 1E 03 00 00 1E 03 1E 03 00 00 1E 03 00 00 00 00 00 00 1E 03 1E 03 00 00 00 00 00 00 00 00 00 00 00 00 1E 03 1E 03 2A 02 00 00 1E 03 00 00 00 00 1E 03 00 00 00 00 39 00 18 00 1E 03 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 1E 03 1E 03 00 00 20 00 00 00 00 00 00 00 1E 03 21 00 00 00 49 00 4A 00 22 00 1E 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 3B 04 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 18 00 29 00 19 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 1E 03 00 00 1C 00 00 00 00 00 00 00 00 00 1E 03 1E 03 00 00 00 00 1E 00 00 00 5C 00 5D 00 5E 00 0D 01 2B 02 20 00 00 00 61 00 62 00 00 00 21 00 00 00 00 00 00 00 22 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 00 00 00 00 00 00 26 00 00 00 F4 04 00 00 00 00 00 00 00 00 00 00 27 00 28 00 00 00 18 00 29 00 19 00 00 00 57 00 1A 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 1C 00 00 00 00 00 00 00 00 00 6F 00 2C 02 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 22 00 00 00 00 00 57 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 28 00 00 00 1D 03 29 00 1D 03 00 00 57 00 1D 03 00 00 1D 03 1D 03 00 00 1D 03 00 00 00 00 1D 03 00 00 1D 03 00 00 1D 03 1D 03 1D 03 00 00 96 01 00 00 1D 03 1D 03 00 00 00 00 00 00 00 00 1D 03 00 00 1D 03 1D 03 00 00 00 00 00 00 1D 03 00 00 00 00 00 00 1D 03 00 00 00 00 57 01 00 00 00 00 00 00 00 00 00 00 1D 03 00 00 00 00 1D 03 00 00 1D 03 00 00 00 00 00 00 1D 03 1D 03 00 00 00 00 00 00 00 00 00 00 00 00 1D 03 1D 03 00 00 00 00 1D 03 00 00 00 00 1D 03 1D 03 00 00 1D 03 00 00 1D 03 1D 03 00 00 1D 03 1D 03 00 00 1D 03 00 00 00 00 1D 03 00 00 1D 03 96 01 1D 03 1D 03 1D 03 00 00 00 00 00 00 1D 03 1D 03 00 00 00 00 00 00 00 00 1D 03 00 00 1D 03 1D 03 00 00 00 00 00 00 1D 03 00 00 1D 03 00 00 1D 03 00 00 00 00 00 00 1D 03 00 00 00 00 00 00 00 00 1D 03 00 00 00 00 1D 03 00 00 1D 03 00 00 00 00 00 00 1D 03 1D 03 00 00 00 00 00 00 00 00 00 00 00 00 1D 03 1D 03 00 00 00 00 1D 03 00 00 00 00 1D 03 00 00 00 00 00 00 00 00 1D 03 00 00 00 00 00 00 00 00 39 00 18 00 1D 03 19 00 00 00 00 00 1A 00 0B 01 00 00 1D 03 1D 03 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 CD 00 42 00 CD 00 00 00 1E 00 CD 00 00 00 00 00 1D 03 00 00 CD 00 20 00 00 00 00 00 00 00 CD 00 21 00 00 00 49 00 4A 00 22 00 00 00 B3 02 00 00 CD 00 00 00 00 00 00 00 00 00 B4 02 00 00 CD 00 24 00 00 00 25 00 4D 00 CD 00 00 00 26 00 00 00 CD 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 CD 00 00 00 CD 00 1D 03 00 00 B5 02 CD 00 00 00 5A 00 5B 00 1D 03 1D 03 00 00 00 00 CD 00 CD 00 00 00 00 00 CD 00 00 00 00 00 CD 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 5D 04 00 00 B6 02 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 7E 04 CD 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 70 00 71 00 72 00 18 00 42 00 19 00 73 00 1E 00 1A 00 00 00 00 00 00 00 00 00 1B 00 20 00 00 00 00 00 00 00 1C 00 21 00 CD 00 49 00 4A 00 22 00 00 00 B3 02 00 00 1E 00 00 00 00 00 00 00 00 00 B4 02 00 00 20 00 24 00 00 00 25 00 4D 00 21 00 00 00 26 00 00 00 22 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 24 00 00 00 25 00 00 00 00 00 B5 02 26 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 57 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 B6 02 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 57 01 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 70 00 71 00 72 00 00 00 42 00 00 00 73 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 96 01 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 01 00 00 00 00 24 00 00 00 25 00 4D 00 FF 02 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 41 01 71 00 72 00 18 00 42 00 19 00 73 00 1E 00 1A 00 00 00 00 00 00 00 00 00 1B 00 20 00 00 00 00 00 00 00 1C 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 24 00 00 00 25 00 4D 00 21 00 00 00 26 00 00 00 22 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 24 00 57 00 25 00 00 00 00 00 59 00 26 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 5E 02 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 57 01 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 78 01 71 00 72 00 3A 02 42 00 3A 02 73 00 1E 00 3A 02 00 00 00 00 00 00 00 00 3A 02 20 00 00 00 00 00 00 00 3A 02 21 00 96 01 49 00 4A 00 22 00 00 00 00 00 00 00 3A 02 00 00 00 00 00 00 00 00 00 00 00 00 3A 02 24 00 00 00 25 00 4D 00 3A 02 00 00 26 00 00 00 3A 02 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 3A 02 57 00 3A 02 00 00 00 00 59 00 3A 02 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 3A 02 3A 02 00 00 00 00 3A 02 00 00 00 00 3A 02 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 3A 02 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 41 01 71 00 72 00 CE 00 42 00 CE 00 73 00 1E 00 CE 00 00 00 00 00 00 00 00 00 CE 00 20 00 00 00 00 00 00 00 CE 00 21 00 3A 02 49 00 4A 00 22 00 00 00 00 00 00 00 CE 00 00 00 00 00 00 00 00 00 3E 01 00 00 CE 00 24 00 00 00 25 00 4D 00 CE 00 00 00 26 00 00 00 CE 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 CE 00 00 00 CE 00 00 00 00 00 59 00 CE 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 CE 00 CE 00 00 00 00 00 CE 00 00 00 00 00 CE 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 CE 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 41 01 71 00 72 00 CD 00 42 00 CD 00 73 00 1E 00 CD 00 00 00 00 00 00 00 00 00 CD 00 20 00 00 00 00 00 00 00 CD 00 21 00 CE 00 49 00 4A 00 22 00 00 00 00 00 00 00 CD 00 00 00 00 00 00 00 00 00 00 00 00 00 CD 00 24 00 00 00 25 00 4D 00 CD 00 00 00 26 00 00 00 CD 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 CD 00 00 00 CD 00 00 00 00 00 59 00 CD 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 CD 00 CD 00 00 00 00 00 CD 00 00 00 00 00 CD 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 3F 02 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 CD 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 41 01 71 00 72 00 A2 00 42 00 A2 00 73 00 1E 00 A2 00 00 00 00 00 00 00 00 00 A2 00 20 00 00 00 00 00 00 00 A2 00 21 00 CD 00 49 00 4A 00 22 00 00 00 00 00 00 00 A2 00 00 00 00 00 00 00 00 00 00 00 00 00 A2 00 24 00 00 00 25 00 4D 00 A2 00 00 00 26 00 00 00 A2 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 A2 00 00 00 A2 00 00 00 00 00 59 00 A2 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 A2 00 A2 00 00 00 00 00 A2 00 00 00 00 00 A2 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 39 02 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 A2 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 EE 02 EE 02 00 00 EE 02 00 00 00 00 EE 02 EE 02 00 00 00 00 00 00 EE 02 EE 02 EE 02 EE 02 00 00 EE 02 6F 00 41 01 71 00 72 00 D8 00 EE 02 D8 00 73 00 EE 02 D8 00 00 00 00 00 00 00 00 00 D8 00 EE 02 00 00 00 00 00 00 D8 00 EE 02 A2 00 EE 02 EE 02 EE 02 00 00 00 00 00 00 D8 00 00 00 00 00 00 00 00 00 EE 02 00 00 D8 00 EE 02 00 00 EE 02 EE 02 D8 00 00 00 EE 02 00 00 D8 00 EE 02 00 00 EE 02 00 00 EE 02 EE 02 EE 02 EE 02 00 00 EE 02 00 00 D8 00 00 00 D8 00 00 00 00 00 EE 02 D8 00 00 00 EE 02 EE 02 00 00 00 00 00 00 00 00 D8 00 D8 00 00 00 00 00 D8 00 00 00 00 00 D8 00 00 00 EE 02 EE 02 EE 02 EE 02 EE 02 00 00 00 00 EE 02 EE 02 EE 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 EE 02 00 00 00 00 00 00 00 00 00 00 EE 02 EE 02 EE 02 EE 02 00 00 00 00 00 00 EE 02 00 00 EE 02 00 00 00 00 00 00 00 00 D8 00 EE 02 EE 02 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 EE 02 EE 02 EE 02 EE 02 00 00 42 00 00 00 EE 02 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 D8 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 41 01 71 00 72 00 00 00 42 00 00 00 73 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 60 00 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 6F 00 70 00 71 00 72 00 00 00 42 00 00 00 73 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 99 00 99 00 00 00 99 00 00 00 00 00 99 00 99 00 00 00 00 00 00 00 99 00 99 00 99 00 99 00 00 00 99 00 6F 00 78 01 71 00 72 00 00 00 99 00 00 00 73 00 99 00 00 00 00 00 00 00 00 00 00 00 00 00 99 00 00 00 00 00 00 00 00 00 99 00 00 00 99 00 99 00 99 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 99 00 00 00 99 00 99 00 00 00 00 00 99 00 00 00 00 00 99 00 00 00 99 00 00 00 99 00 99 00 99 00 99 00 00 00 99 00 00 00 00 00 00 00 00 00 00 00 00 00 99 00 00 00 00 00 99 00 99 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 99 00 99 00 99 00 99 00 99 00 00 00 00 00 99 00 99 00 99 00 7D 01 00 00 00 00 00 00 00 00 00 00 00 00 99 00 00 00 00 00 00 00 00 00 00 00 99 00 99 00 99 00 99 00 00 00 00 00 00 00 99 00 00 00 99 00 00 00 7D 01 00 00 00 00 00 00 99 00 99 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 00 00 00 00 7D 01 00 00 00 00 7D 01 00 00 7D 01 00 00 7D 01 7D 01 7D 01 7D 01 99 00 99 00 99 00 99 00 7D 01 00 00 00 00 99 00 7D 01 00 00 00 00 00 00 7D 01 00 00 00 00 39 00 18 00 00 00 19 00 00 00 7D 01 1A 00 0B 01 7D 01 00 00 7D 01 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 18 00 00 00 19 00 00 00 42 00 1A 00 00 00 1E 00 00 00 00 00 1B 00 7D 01 00 00 00 00 20 00 1C 00 7D 01 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 1E 00 00 00 00 00 7D 01 7D 01 00 00 32 01 20 00 7D 01 00 00 00 00 24 00 21 00 25 00 4D 00 00 00 22 00 26 00 00 00 00 00 4F 00 7D 01 51 00 00 00 53 00 27 00 28 00 0C 01 24 00 29 00 25 00 00 00 00 00 00 00 26 00 00 00 59 00 00 00 00 00 5A 00 5B 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 7D 01 5C 00 5D 00 5E 00 5F 00 3F 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 31 01 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 57 01 00 00 00 00 00 00 6D 00 6E 00 00 00 00 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 6F 00 41 01 71 00 72 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 58 01 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 70 01 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 6F 00 0F 01 1E 00 72 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 E4 02 00 00 00 00 61 00 62 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 01 00 00 00 00 00 00 00 00 00 00 67 00 68 00 69 00 6A 00 00 00 00 00 00 00 6B 00 00 00 6C 00 00 00 00 00 00 00 00 00 00 00 6D 00 6E 00 39 00 18 00 00 00 19 00 00 00 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 6F 00 0F 01 1E 00 72 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 0E 01 00 00 00 00 61 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00 00 00 00 00 00 00 00 00 00 00 00 00 D3 02 D4 02 00 00 00 00 39 00 18 00 00 00 19 00 D5 02 00 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 6F 00 0F 01 21 00 D6 02 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 01 00 00 00 00 00 00 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 0E 01 00 00 00 00 61 00 62 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 65 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 42 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 00 0F 01 24 00 00 00 25 00 4D 00 00 00 00 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 00 00 29 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 0E 01 00 00 00 00 61 00 62 00 00 00 00 00 00 00 39 00 18 00 00 00 19 00 00 00 65 00 1A 00 0B 01 00 00 00 00 00 00 1B 00 3E 00 3F 00 40 00 00 00 1C 00 00 00 CD 00 00 00 CD 00 00 00 42 00 CD 00 00 00 1E 00 00 00 00 00 CD 00 00 00 00 00 00 00 20 00 CD 00 00 00 00 00 00 00 21 00 00 00 49 00 4A 00 22 00 CD 00 00 00 00 00 00 00 00 00 00 00 00 00 CD 00 00 00 6F 00 0F 01 24 00 CD 00 25 00 4D 00 00 00 CD 00 26 00 00 00 00 00 4F 00 00 00 51 00 00 00 53 00 27 00 28 00 0C 01 CD 00 29 00 CD 00 00 00 57 00 00 00 CD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CD 00 CD 00 00 00 00 00 CD 00 00 00 00 00 CD 00 00 00 00 00 00 00 00 00 5C 00 5D 00 5E 00 0D 01 2B 02 00 00 00 00 61 00 62 00 00 00 00 00 00 00 00 00 18 00 00 00 19 00 00 00 65 00 1A 00 00 00 00 00 0E 06 00 00 1B 00 00 00 00 00 32 03 00 00 1C 00 00 00 33 03 0F 06 10 06 00 00 CD 00 7E 04 11 06 1E 00 00 00 00 00 00 00 00 00 12 06 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 22 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 04 6F 00 2C 02 24 00 00 00 25 00 00 00 00 00 00 00 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 28 00 CD 00 00 00 29 00 00 00 00 00 13 06 18 00 00 00 19 00 00 00 14 06 1A 00 00 00 00 00 0E 06 00 00 1B 00 00 00 00 00 32 03 00 00 1C 00 00 00 33 03 0F 06 10 06 00 00 00 00 00 00 11 06 1E 00 00 00 00 00 00 00 00 00 12 06 00 00 20 00 35 00 00 00 35 00 00 00 21 00 35 00 57 01 00 00 22 00 00 00 35 00 00 00 15 06 00 00 00 00 35 00 00 00 02 04 00 00 00 00 24 00 00 00 25 00 00 00 35 00 00 00 26 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 27 00 28 00 35 00 00 00 29 00 00 00 35 00 13 06 35 00 00 00 35 00 00 00 14 06 00 00 00 00 35 00 00 00 00 00 35 00 16 06 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 35 00 00 00 00 00 35 00 35 00 00 00 35 00 00 00 00 00 35 00 57 01 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 35 00 B9 00 35 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 16 06 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 35 00 00 00 00 00 35 00 18 00 00 00 19 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 1B 00 35 00 00 00 00 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 8F 02 20 00 00 00 00 00 00 00 00 00 21 00 B9 00 35 00 00 00 22 00 00 00 90 02 00 00 00 00 00 00 00 00 00 00 00 00 91 02 00 00 00 00 24 00 00 00 25 00 00 00 00 00 00 00 26 00 00 00 00 00 92 02 00 00 00 00 00 00 00 00 27 00 28 00 00 00 00 00 29 00 00 00 00 00 5E 02 36 00 00 00 36 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 36 00 35 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 93 02 00 00 00 00 00 00 00 00 36 00 36 00 00 00 00 00 00 00 00 00 36 00 00 00 57 01 00 00 36 00 00 00 36 00 00 00 36 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 36 00 00 00 36 00 00 00 00 00 00 00 36 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 36 00 36 00 00 00 35 00 36 00 35 00 00 00 36 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 94 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 35 00 36 00 35 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 35 00 35 00 00 00 18 00 35 00 19 00 00 00 35 00 1A 00 00 00 CA 05 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 1C 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 1E 00 00 00 00 00 35 00 00 00 35 00 00 00 20 00 00 00 00 00 00 00 00 00 21 00 00 00 CB 05 00 00 22 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 24 00 00 00 25 00 00 00 00 00 00 00 26 00 CC 05 00 00 00 00 00 00 00 00 35 00 00 00 27 00 28 00 00 00 35 00 29 00 00 00 00 00 57 00 35 00 00 00 35 00 35 00 35 00 35 00 00 00 00 00 00 00 00 00 35 00 FA 01 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 35 00 00 00 35 00 00 00 00 00 00 00 FB 01 00 00 00 00 57 01 00 00 00 00 FA 01 00 00 00 00 00 00 00 00 00 00 00 00 FC 01 00 00 00 00 00 00 FD 01 FE 01 00 00 35 00 00 00 00 00 FF 01 00 00 00 02 01 02 02 02 03 02 00 00 FB 01 53 01 00 00 04 02 00 00 00 00 00 00 05 02 00 00 00 00 00 00 00 00 00 00 FC 01 00 00 00 00 00 00 00 00 FE 01 06 02 96 01 00 00 07 02 FF 01 08 02 00 02 01 02 02 02 03 02 00 00 00 00 00 00 00 00 04 02 00 00 00 00 00 00 05 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 02 06 02 00 00 00 00 07 02 00 00 08 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 02) */; internal static readonly long 3CD85BE4972E1FDD2AC3F0E63CBAB7DB10C42889E5EF517854CEE2D2B36376D3/* Not supported: data(3B 00 2C 00 0A 00 0D 00) */; internal static readonly __StaticArrayInitTypeSize=3626 56D47028B86D2B9DDFA5F294D7B1231939182785A3B1DAA9C22AA1473CDA6A4E/* Not supported: data(56 10 00 00 00 00 48 28 56 10 00 00 00 00 00 00 00 07 00 00 00 00 4A 11 06 08 00 00 00 00 00 00 00 00 00 00 4A 11 00 00 72 05 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 07 00 00 00 00 12 07 00 00 00 00 12 07 00 00 00 00 00 07 75 11 AD 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A2 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6F 4B 00 00 00 00 98 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 94 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 99 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 70 1C 52 19 81 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 1C 59 1D D6 1E D9 1F 41 06 33 22 C5 22 F6 05 A0 23 15 19 74 08 46 09 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 1D 70 1C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BF 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 07 00 00 00 00 88 01 00 00 00 00 00 00 00 00 00 00 00 00 FF 11 68 01 47 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CF 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A3 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 74 15 9D 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 0E 00 00 00 00 D7 00 8C 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BC 0F 00 00 8C 0E 00 00 00 00 00 00 00 00 00 00 A2 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6E 04 00 00 00 00 00 00 F7 00 F6 24 A5 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A4 05 6C 0D 00 00 00 00 00 00 00 00 00 00 00 00 98 05 00 00 CF 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 72 12 BA 12 8B 02 00 00 12 07 12 07 00 00 7B 53 48 00 00 00 12 07 1F 07 00 00 00 00 CA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E4 00 69 47 00 00 00 00 00 00 00 00 CF 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A6 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B9 01 AA 09 00 00 00 00 34 01 7D 03 00 00 00 00 AD 05 46 03 00 00 00 00 00 00 00 00 13 01 00 00 00 00 63 17 AB 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B1 05 00 00 B8 0B 00 00 00 00 B4 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7E 00 00 00 00 00 00 00 CA 03 00 00 00 00 00 00 00 00 00 00 D4 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A4 05 00 00 00 00 00 00 93 4D CF 14 00 00 00 00 00 00 00 00 00 00 00 00 3D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 93 4D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 03 00 00 00 00 AE 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9D 05 00 00 00 00 00 00 00 00 2A 14 00 00 CF 14 00 00 00 00 84 13 00 00 CF 14 08 18 00 00 00 00 00 00 00 00 00 00 46 FF 00 00 00 00 00 00 00 00 53 01 00 00 00 00 00 00 5D 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 1A 26 1B 94 1B 02 1C 00 00 A2 1D 00 00 00 00 00 00 F2 1D 00 00 3B 1E 00 00 00 00 41 1F 00 00 8D 1F 00 00 25 20 00 00 71 20 00 00 BD 20 00 00 09 21 00 00 A1 21 00 00 EA 21 00 00 7C 22 00 00 0E 23 00 00 57 23 00 00 E9 23 00 00 32 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FD 4B 00 00 00 00 00 04 00 00 00 00 7F 05 A9 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F6 03 37 FF 00 00 00 00 B2 05 00 00 00 00 00 00 00 00 27 09 00 00 00 00 00 00 00 00 00 00 00 00 E4 31 00 00 00 00 00 00 0F 04 00 00 00 00 00 00 8B 4C 1E 55 00 00 00 00 1E 04 21 04 24 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AF 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B5 05 00 00 00 00 00 00 00 00 00 00 45 21 00 00 00 00 00 00 40 01 00 00 2B 01 19 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B6 05 00 00 00 00 00 00 00 00 00 00 B9 05 00 00 5D 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8C 0E 00 00 00 00 00 00 D4 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 93 4D 00 00 00 00 00 00 00 00 00 00 70 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CF 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 05 00 00 00 00 00 00 00 00 00 00 00 00 E6 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 78 FF 00 00 BB 01 00 00 00 00 00 00 00 00 00 00 00 00 8B 4C 00 00 00 00 00 00 00 00 48 00 00 00 37 49 00 00 00 00 B4 05 00 00 A8 03 00 00 00 00 19 4D 00 00 00 00 00 00 BE 05 00 00 8C 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BB 05 A7 4D 00 00 00 00 00 00 00 00 63 55 00 00 00 00 00 00 30 04 00 00 00 00 00 00 00 00 00 00 67 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BE 16 00 00 AD 18 C1 05 00 00 5D 03 BA 05 00 00 00 00 00 00 C2 05 00 00 00 00 00 00 30 04 00 00 00 00 CA 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BF 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 05 00 00 00 00 00 00 00 00 00 00 3A 04 3E 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C8 05 5D 03 2F FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 63 17 00 00 00 00 00 00 00 00 00 00 BA 05 00 00 CD 05 00 00 00 00 00 00 C8 05 00 00 00 00 00 00 00 00 00 00 00 00 93 4D 00 00 DE 02 4A 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B2 05 00 00 6D 14 00 00 00 00 00 00 00 00 00 00 7D 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E0 01 00 00 00 00 00 00 00 00 30 03 00 00 6C 03 00 00 00 00 00 00 00 00 CA 05 00 00 BA 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D1 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 93 4D 00 00 00 00 00 00 00 00 49 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 01 0C 02 00 00 00 00 00 00 00 00 00 00 D0 35 00 00 40 54 00 00 44 FF 36 02 40 54 36 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E FF 00 00 00 00 B1 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 73 15 00 00 91 01 00 00 9E 02 D3 05 00 00 D3 05 00 00 00 00 D3 05 00 00 00 00 00 00 00 00 00 00 AF 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 62 17 00 00 00 00 00 00 A5 34 00 00 00 00 D5 05 00 00 00 00 22 02 00 00 CA 02 00 00 00 00 2C 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B2 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F7 10 CB 05 6A 02 00 00 00 00 97 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D6 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E2 0A 00 00 00 00 AB 05 00 00 00 00 FD 33 F9 34 00 00 00 00 1F 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 93 02 00 00 00 00 00 00 85 48 00 00 00 00 51 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CF 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4D 35 00 00 FD 33 00 00 00 00 00 00 1F 02 00 00 00 00 00 00 00 00 00 00 F7 00 E4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6C 0B 2E 01 00 00 38 50 00 00 CF 05 00 00 00 00 28 14 00 00 E2 0A 00 00 00 00 00 00 00 00 00 00 00 00 E2 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CB 02 00 00 2A 02 00 00 98 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E2 0A 00 00 00 00 00 00 AC 02 00 00 E6 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 54 3D 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D2 05 00 00 E6 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D0 05 00 00 40 54 40 54 00 00 00 00 8A 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 DE 05 4C 04 00 00 DF 05 40 54 CB 4F E0 05 40 54 00 00 00 00 00 00 00 00 00 00 00 00 E1 05 00 00 00 00 00 00 82 10 00 00 00 00 00 00 40 54 00 00 00 00 00 00 E3 05 00 00 00 00 B3 01 00 00 23 1B C7 55 00 00 00 00 00 00 E4 05 00 00 00 00 00 00 00 00 00 00 00 00 E5 05 00 00 00 00 40 54 00 00 00 00 3D 02 00 00 49 04 00 00 00 00 00 00 00 00 00 00 6F 04 00 00 AC 18 3D 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ED 05 00 00 49 06 00 00 00 00 00 00 4D 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B6 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 10 00 00 00 00 16 16 05 18 00 00 B6 02 00 00 00 00 00 00 00 00 00 00 BC 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AB 05 AB 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00) */; internal static readonly __StaticArrayInitTypeSize=2310 5B6A63405C09785090DDE02E23949E5BFEFE7B6E6731E3A8C14986623FE10A72/* Not supported: data(FF FF 00 00 04 00 00 00 00 00 01 00 01 00 01 00 01 00 02 00 02 00 0B 00 0B 00 0C 00 0C 00 0D 00 0D 00 0E 00 0F 00 0F 00 0F 00 10 00 10 00 14 00 15 00 12 00 12 00 17 00 17 00 17 00 13 00 13 00 13 00 18 00 18 00 19 00 19 00 07 00 07 00 06 00 06 00 16 00 16 00 08 00 08 00 1A 00 1A 00 1A 00 1B 00 1B 00 1B 00 1B 00 1B 00 09 00 09 00 0A 00 0A 00 23 00 21 00 26 00 22 00 22 00 22 00 22 00 24 00 24 00 24 00 25 00 25 00 2A 00 27 00 28 00 29 00 29 00 2B 00 2B 00 2B 00 2B 00 2B 00 2C 00 2C 00 2C 00 30 00 2D 00 2F 00 2F 00 33 00 34 00 34 00 32 00 32 00 37 00 37 00 38 00 38 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 39 00 47 00 42 00 49 00 49 00 49 00 4E 00 51 00 52 00 53 00 1D 00 1D 00 56 00 3A 00 3A 00 57 00 57 00 58 00 58 00 59 00 5B 00 55 00 55 00 5A 00 5A 00 60 00 3B 00 64 00 3B 00 3B 00 5F 00 67 00 5F 00 61 00 61 00 68 00 68 00 69 00 6A 00 69 00 65 00 65 00 6B 00 6B 00 6C 00 6D 00 63 00 63 00 66 00 66 00 66 00 70 00 3C 00 5E 00 72 00 5E 00 73 00 5E 00 76 00 77 00 6E 00 78 00 79 00 7A 00 6E 00 6E 00 6E 00 6F 00 6F 00 6F 00 7E 00 7F 00 7F 00 81 00 7F 00 83 00 7D 00 75 00 75 00 84 00 84 00 84 00 84 00 84 00 84 00 84 00 84 00 84 00 84 00 85 00 85 00 88 00 88 00 88 00 88 00 8B 00 88 00 89 00 89 00 8C 00 8C 00 8D 00 8D 00 8D 00 8D 00 86 00 86 00 86 00 8E 00 8E 00 8E 00 87 00 90 00 92 00 93 00 95 00 3D 00 96 00 3D 00 94 00 98 00 94 00 97 00 97 00 9A 00 9C 00 3F 00 9B 00 9B 00 91 00 91 00 91 00 91 00 91 00 A0 00 9D 00 A1 00 9E 00 9F 00 9F 00 9F 00 9F 00 A2 00 A3 00 A4 00 A6 00 1E 00 1E 00 A5 00 A5 00 A7 00 A7 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 A8 00 AA 00 40 00 AB 00 AB 00 AE 00 A9 00 A9 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 AD 00 B0 00 AF 00 B1 00 AF 00 AF 00 AF 00 41 00 B3 00 B5 00 B2 00 B4 00 B4 00 B8 00 B6 00 B9 00 B6 00 B6 00 B6 00 BA 00 43 00 BC 00 3E 00 BF 00 C0 00 3E 00 3E 00 BB 00 C2 00 BB 00 BD 00 BD 00 C3 00 C3 00 C4 00 C4 00 C5 00 C1 00 BE 00 BE 00 BE 00 BE 00 BE 00 C9 00 C6 00 CA 00 C7 00 C8 00 C8 00 C8 00 44 00 45 00 CC 00 CE 00 CF 00 1F 00 CB 00 CB 00 CB 00 CD 00 CD 00 CD 00 D0 00 D0 00 D1 00 D2 00 D1 00 D1 00 D1 00 D3 00 D4 00 D5 00 20 00 D6 00 D6 00 11 00 11 00 11 00 D7 00 D7 00 D7 00 DB 00 DB 00 D9 00 D9 00 D9 00 DC 00 DC 00 DE 00 4C 00 8F 00 74 00 74 00 99 00 99 00 DF 00 DF 00 DF 00 DD 00 DD 00 E0 00 E0 00 E1 00 E1 00 E3 00 E3 00 71 00 54 00 54 00 62 00 62 00 8A 00 8A 00 AC 00 AC 00 E5 00 E5 00 E5 00 E5 00 E9 00 E9 00 EB 00 EB 00 EA 00 E4 00 E8 00 E8 00 E8 00 ED 00 ED 00 EE 00 EC 00 EC 00 EC 00 EC 00 EC 00 EC 00 EC 00 EF 00 EF 00 EF 00 EF 00 EF 00 EF 00 EF 00 EF 00 EF 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F0 00 F1 00 F1 00 F1 00 F2 00 F2 00 F2 00 F2 00 08 01 08 01 09 01 0A 01 0A 01 0B 01 0B 01 05 01 05 01 0C 01 0C 01 0D 01 0D 01 0E 01 0D 01 0F 01 0D 01 10 01 10 01 11 01 11 01 F4 00 F4 00 07 01 07 01 07 01 07 01 07 01 07 01 07 01 07 01 07 01 07 01 07 01 07 01 F6 00 F6 00 F6 00 13 01 13 01 14 01 14 01 15 01 15 01 17 01 17 01 17 01 18 01 18 01 18 01 18 01 18 01 18 01 18 01 19 01 19 01 B7 00 B7 00 12 01 12 01 12 01 12 01 12 01 1E 01 1E 01 1D 01 1D 01 1F 01 1F 01 1F 01 1F 01 1F 01 36 00 20 01 F7 00 F7 00 F7 00 F7 00 1C 01 1C 01 22 01 22 01 23 01 23 01 F8 00 F9 00 F9 00 FA 00 FB 00 FC 00 FC 00 F3 00 F3 00 F3 00 F3 00 F3 00 28 01 24 01 FD 00 FD 00 29 01 29 01 2A 01 2A 01 2B 01 2B 01 2B 01 2B 01 2C 01 2C 01 2C 01 2C 01 25 01 25 01 E6 00 E6 00 27 01 27 01 2D 01 2D 01 26 01 26 01 5D 00 5D 00 2E 01 2E 01 FE 00 2F 01 2F 01 DA 00 D8 00 FF 00 FF 00 00 01 00 01 01 01 01 01 02 01 31 01 03 01 32 01 03 01 30 01 30 01 34 01 33 01 F5 00 06 01 35 01 35 01 35 01 35 01 35 01 35 01 35 01 35 01 35 01 35 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 36 01 37 01 37 01 37 01 37 01 37 01 37 01 37 01 38 01 38 01 38 01 38 01 38 01 38 01 38 01 38 01 38 01 38 01 38 01 38 01 39 01 3B 01 3B 01 3B 01 3B 01 3B 01 3B 01 3B 01 3B 01 3C 01 3D 01 3D 01 3E 01 3F 01 3F 01 40 01 40 01 40 01 40 01 40 01 41 01 41 01 41 01 41 01 41 01 41 01 41 01 41 01 41 01 42 01 42 01 42 01 42 01 42 01 43 01 43 01 43 01 44 01 44 01 44 01 45 01 45 01 45 01 46 01 46 01 46 01 47 01 47 01 47 01 48 01 48 01 49 01 49 01 4B 01 4B 01 4B 01 4B 01 4B 01 4B 01 4B 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4D 01 4E 01 4E 01 4F 01 4F 01 4F 01 50 01 50 01 51 01 51 01 51 01 51 01 52 01 52 01 54 01 53 01 53 01 53 01 82 00 82 00 35 00 35 00 56 01 55 01 57 01 55 01 58 01 55 01 59 01 5A 01 55 01 5B 01 5C 01 55 01 2E 00 2E 00 1A 01 1A 01 1A 01 1A 01 04 01 04 01 04 01 5C 00 5E 01 4D 00 4D 00 5F 01 60 01 60 01 60 01 60 01 62 01 60 01 63 01 64 01 65 01 66 01 1C 00 4B 00 4B 00 4A 00 4A 00 7B 00 7B 00 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 67 01 4F 00 4F 00 61 01 61 01 50 00 50 00 68 01 68 01 69 01 69 01 6A 01 6A 01 6B 01 6B 01 6B 01 6B 01 E2 00 E2 00 6C 01 6C 01 6D 01 7C 00 48 00 48 00 6E 01 80 00 46 00 46 00 6F 01 6F 01 70 01 70 01 70 01 70 01 74 01 74 01 75 01 75 01 75 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 72 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 76 01 84 01 84 01 84 01 84 01 77 01 85 01 73 01 21 01 21 01 86 01 86 01 86 01 86 01 86 01 87 01 88 01 88 01 E7 00 E7 00 89 01 31 00 31 00 8B 01 71 01 8E 01 71 01 90 01 71 01 91 01 71 01 8A 01 8A 01 8A 01 8C 01 8C 01 94 01 94 01 93 01 93 01 95 01 95 01 8D 01 8D 01 8F 01 8F 01 96 01 96 01 97 01 92 01 92 01 92 01 92 01 4A 01 4A 01 4C 01 78 01 78 01 78 01 83 01 83 01 98 01 99 01 99 01 79 01 79 01 9A 01 9A 01 9A 01 9D 01 9B 01 9B 01 9C 01 9C 01 9E 01 9E 01 9E 01 9F 01 A0 01 A0 01 A1 01 A1 01 A1 01 A1 01 7A 01 7A 01 7A 01 7A 01 A2 01 A2 01 A3 01 A3 01 A3 01 A7 01 A4 01 AA 01 A6 01 A6 01 AD 01 A9 01 A9 01 AC 01 AC 01 AE 01 AE 01 A8 01 A8 01 B1 01 B0 01 B0 01 AB 01 AB 01 AF 01 AF 01 B3 01 B2 01 B2 01 A5 01 A5 01 B4 01 A5 01 7B 01 7B 01 7B 01 7B 01 7B 01 7B 01 B5 01 B6 01 B6 01 B7 01 B7 01 B7 01 B8 01 B8 01 B8 01 B8 01 B9 01 B9 01 B9 01 B9 01 BA 01 BA 01 BA 01 BB 01 BB 01 7C 01 7C 01 7C 01 7C 01 BC 01 BC 01 3A 01 3A 01 BD 01 C0 01 BD 01 BD 01 BF 01 BF 01 BE 01 C1 01 BE 01 7D 01 7E 01 C2 01 81 01 7F 01 7F 01 C4 01 C5 01 82 01 C7 01 C8 01 80 01 80 01 80 01 C6 01 C6 01 C3 01 C3 01 5D 01 5D 01 5D 01 5D 01 C9 01 C9 01 CB 01 CB 01 CD 01 CC 01 CE 01 CC 01 CA 01 CA 01 CA 01 CA 01 CA 01 D2 01 D0 01 D3 01 D5 01 D0 01 D4 01 D4 01 CF 01 CF 01 D6 01 D6 01 D6 01 D6 01 D6 01 DB 01 D7 01 DC 01 D8 01 DD 01 DE 01 DF 01 D9 01 E1 01 E2 01 E3 01 D9 01 E0 01 E0 01 E5 01 DA 01 E4 01 E8 01 E4 01 E7 01 EA 01 E7 01 E6 01 E6 01 E6 01 E9 01 E9 01 E9 01 D1 01 EB 01 D1 01 03 00 03 00 EC 01 03 00 03 00 ED 01 ED 01 1B 01 1B 01 16 01 16 01 05 00 EE 01 EE 01 EE 01 EE 01 EE 01 F2 01 EE 01 EE 01 EE 01 EE 01 EF 01 EF 01 F0 01 F3 01 F0 01 F1 01 F1 01 F4 01 F4 01 F5 01) */; internal static readonly __StaticArrayInitTypeSize=2310 6020B9A6BDF4F212FB0017703EDC6BD21DA156BDA3C45189A1CC9B013419B039/* Not supported: data(02 00 02 00 00 00 03 00 01 00 02 00 04 00 03 00 01 00 00 00 01 00 01 00 02 00 04 00 02 00 01 00 02 00 01 00 04 00 06 00 02 00 00 00 01 00 00 00 00 00 0B 00 03 00 00 00 01 00 01 00 01 00 03 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 00 01 00 02 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 01 00 02 00 00 00 03 00 00 00 06 00 03 00 02 00 01 00 01 00 01 00 01 00 01 00 03 00 00 00 03 00 01 00 00 00 03 00 00 00 01 00 01 00 03 00 03 00 01 00 01 00 01 00 00 00 04 00 04 00 04 00 01 00 01 00 01 00 00 00 01 00 00 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 04 00 01 00 01 00 02 00 00 00 00 00 00 00 00 00 10 00 05 00 00 00 09 00 05 00 00 00 01 00 01 00 02 00 03 00 00 00 03 00 01 00 01 00 01 00 00 00 08 00 00 00 09 00 06 00 00 00 00 00 03 00 00 00 01 00 01 00 02 00 02 00 00 00 05 00 00 00 01 00 01 00 02 00 03 00 00 00 04 00 02 00 01 00 01 00 01 00 00 00 03 00 01 00 00 00 03 00 00 00 04 00 00 00 00 00 0A 00 00 00 00 00 00 00 0C 00 08 00 05 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 04 00 00 00 04 00 00 00 01 00 01 00 03 00 03 00 03 00 05 00 03 00 05 00 01 00 01 00 01 00 01 00 03 00 04 00 06 00 02 00 04 00 00 00 07 00 00 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 04 00 06 00 04 00 01 00 02 00 02 00 01 00 00 00 00 00 00 00 00 00 0C 00 00 00 06 00 00 00 00 00 04 00 01 00 01 00 00 00 00 00 0A 00 03 00 01 00 01 00 02 00 01 00 02 00 01 00 00 00 05 00 00 00 05 00 01 00 01 00 01 00 01 00 00 00 00 00 00 00 00 00 0F 00 05 00 00 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 05 00 01 00 01 00 00 00 07 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 07 00 00 00 07 00 02 00 02 00 02 00 00 00 00 00 09 00 00 00 01 00 00 00 06 00 00 00 06 00 02 00 01 00 00 00 08 00 00 00 09 00 00 00 00 00 0A 00 05 00 00 00 00 00 03 00 00 00 01 00 01 00 02 00 02 00 04 00 00 00 02 00 02 00 02 00 01 00 01 00 01 00 00 00 05 00 00 00 05 00 01 00 01 00 01 00 02 00 04 00 00 00 00 00 00 00 0C 00 00 00 02 00 02 00 00 00 01 00 02 00 01 00 03 00 02 00 00 00 05 00 03 00 01 00 00 00 00 00 00 00 0D 00 00 00 01 00 01 00 03 00 03 00 01 00 04 00 04 00 02 00 02 00 00 00 03 00 02 00 01 00 03 00 00 00 03 00 01 00 01 00 03 00 01 00 02 00 03 00 04 00 04 00 00 00 03 00 01 00 03 00 03 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 02 00 02 00 02 00 01 00 04 00 02 00 04 00 00 00 01 00 01 00 01 00 02 00 02 00 02 00 01 00 03 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 03 00 03 00 03 00 01 00 03 00 03 00 01 00 01 00 03 00 01 00 03 00 00 00 04 00 00 00 06 00 01 00 01 00 01 00 01 00 03 00 03 00 04 00 04 00 05 00 04 00 04 00 04 00 03 00 03 00 03 00 04 00 03 00 04 00 04 00 04 00 03 00 00 00 01 00 03 00 04 00 00 00 01 00 01 00 03 00 02 00 03 00 03 00 01 00 02 00 03 00 05 00 02 00 01 00 01 00 00 00 01 00 01 00 03 00 03 00 03 00 02 00 01 00 01 00 01 00 01 00 02 00 02 00 02 00 04 00 03 00 02 00 01 00 04 00 05 00 04 00 03 00 01 00 03 00 01 00 03 00 01 00 01 00 01 00 04 00 03 00 02 00 02 00 06 00 03 00 07 00 04 00 03 00 07 00 03 00 00 00 02 00 04 00 03 00 01 00 02 00 00 00 01 00 01 00 03 00 01 00 02 00 03 00 01 00 01 00 01 00 00 00 01 00 01 00 02 00 02 00 03 00 01 00 02 00 00 00 01 00 02 00 04 00 01 00 03 00 04 00 01 00 01 00 01 00 02 00 04 00 04 00 04 00 02 00 04 00 02 00 04 00 00 00 04 00 00 00 05 00 00 00 01 00 00 00 04 00 04 00 01 00 01 00 02 00 02 00 04 00 02 00 02 00 02 00 02 00 04 00 02 00 01 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 01 00 03 00 03 00 03 00 03 00 03 00 03 00 01 00 03 00 03 00 03 00 03 00 03 00 04 00 03 00 03 00 03 00 03 00 03 00 01 00 01 00 02 00 02 00 01 00 01 00 04 00 01 00 01 00 04 00 01 00 03 00 03 00 01 00 02 00 01 00 03 00 03 00 03 00 03 00 01 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 01 00 03 00 03 00 03 00 03 00 01 00 03 00 03 00 01 00 03 00 03 00 01 00 03 00 03 00 01 00 03 00 03 00 01 00 03 00 03 00 01 00 03 00 01 00 01 00 01 00 05 00 06 00 05 00 04 00 05 00 05 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 03 00 05 00 05 00 03 00 03 00 02 00 04 00 03 00 01 00 03 00 03 00 02 00 01 00 01 00 00 00 01 00 00 00 02 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 04 00 00 00 04 00 00 00 05 00 00 00 00 00 07 00 00 00 00 00 08 00 01 00 01 00 01 00 01 00 01 00 01 00 06 00 04 00 04 00 01 00 01 00 00 00 01 00 03 00 00 00 01 00 01 00 02 00 00 00 06 00 00 00 00 00 00 00 00 00 0F 00 00 00 01 00 00 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 01 00 02 00 03 00 00 00 01 00 01 00 02 00 04 00 03 00 01 00 03 00 01 00 03 00 01 00 01 00 00 00 01 00 01 00 01 00 00 00 04 00 01 00 01 00 00 00 04 00 00 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 01 00 00 00 04 00 01 00 02 00 02 00 02 00 01 00 02 00 01 00 03 00 05 00 04 00 01 00 02 00 01 00 01 00 01 00 00 00 06 00 00 00 07 00 00 00 07 00 00 00 08 00 00 00 02 00 01 00 00 00 01 00 00 00 01 00 01 00 02 00 02 00 04 00 00 00 02 00 00 00 01 00 01 00 02 00 04 00 01 00 05 00 02 00 01 00 05 00 02 00 02 00 02 00 02 00 02 00 02 00 02 00 01 00 01 00 01 00 01 00 01 00 05 00 07 00 04 00 00 00 08 00 04 00 00 00 01 00 01 00 02 00 01 00 02 00 01 00 02 00 03 00 03 00 04 00 01 00 01 00 01 00 01 00 01 00 05 00 04 00 07 00 03 00 06 00 00 00 04 00 00 00 05 00 01 00 00 00 04 00 02 00 02 00 02 00 01 00 01 00 00 00 01 00 00 00 05 00 01 00 00 00 01 00 00 00 01 00 01 00 01 00 03 00 04 00 05 00 00 00 09 00 01 00 01 00 01 00 01 00 01 00 01 00 02 00 02 00 02 00 03 00 04 00 03 00 03 00 03 00 03 00 02 00 03 00 02 00 03 00 02 00 04 00 04 00 03 00 00 00 01 00 03 00 04 00 05 00 03 00 01 00 02 00 00 00 01 00 03 00 00 00 07 00 03 00 02 00 01 00 00 00 00 00 05 00 02 00 02 00 00 00 03 00 05 00 04 00 00 00 00 00 0A 00 00 00 00 00 09 00 05 00 04 00 02 00 01 00 00 00 02 00 02 00 02 00 02 00 02 00 04 00 05 00 04 00 05 00 00 00 05 00 00 00 06 00 03 00 02 00 02 00 02 00 01 00 00 00 03 00 00 00 00 00 05 00 02 00 01 00 01 00 02 00 01 00 01 00 01 00 01 00 01 00 00 00 05 00 00 00 03 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 0D 00 00 00 02 00 00 00 03 00 01 00 00 00 04 00 01 00 00 00 04 00 01 00 02 00 02 00 01 00 02 00 02 00 00 00 00 00 04 00 02 00 03 00 00 00 04 00 02 00 02 00 03 00 00 00 01 00 01 00 01 00 02 00 02 00 02 00 02 00 04 00 03 00 00 00 07 00 04 00 04 00 03 00 01 00 03 00 00 00 00 00 04 00 00 00 01 00 01 00 03 00 02 00) */; internal static readonly __StaticArrayInitTypeSize=44822 8B62882CB47FC5A842A8CA072BAF0DAF084FC76A36B5ADDF4CB2F9A949C6788B/* Not supported: data(11 00 39 01 11 00 11 00 34 00 12 00 04 00 11 00 34 00 4C 00 3A 01 2F 01 F7 00 CB 00 3F 02 04 01 F5 00 0B 02 56 01 CA 00 3F 00 21 02 FF 02 38 01 43 00 44 00 45 00 77 01 47 00 48 00 3D 02 BD 01 06 00 46 00 4D 00 4E 00 CE 00 BD 01 BD 01 66 01 53 00 54 00 7D 00 56 00 38 01 58 00 57 01 7D 02 AB 00 3B 00 5D 00 5E 00 95 01 5A 00 5B 00 36 01 76 03 3C 05 5F 00 4C 00 05 03 AA 01 78 03 50 00 9F 01 0A 03 0B 03 38 04 3C 00 8B 02 00 01 A9 01 52 00 3C 04 54 00 3C 00 56 03 7B 00 58 03 7D 00 61 00 7C 00 77 00 4B 00 65 00 61 01 A4 02 00 00 29 04 69 05 4B 00 2D 00 6C 05 00 01 30 00 00 01 00 01 9F 01 73 00 00 01 00 01 11 00 4D 01 00 01 BB 00 00 01 0C 01 00 01 00 01 00 01 D2 05 0C 01 57 01 00 01 97 00 00 01 65 00 00 01 00 01 00 01 00 01 68 04 00 01 00 01 86 03 00 01 00 01 89 03 00 01 E5 05 73 00 11 00 00 01 7E 01 3B 06 1B 01 6C 01 00 01 7B 01 6E 01 00 01 8D 01 07 01 16 01 50 01 A1 05 00 01 1A 01 58 01 00 01 79 01 11 00 54 01 0C 01 AB 00 CB 00 AB 00 AB 00 00 01 CB 00 0D 01 AB 00 76 01 00 01 A4 01 76 01 7A 01 3B 01 11 00 7A 01 7E 01 AB 01 00 01 7E 01 95 01 78 01 79 01 75 01 1F 01 7C 01 A9 01 B5 01 11 00 11 00 11 00 75 01 7E 01 11 00 AD 01 B6 01 78 01 11 00 7A 01 11 00 7C 01 3C 01 A8 01 F5 00 D2 01 AA 01 11 00 F5 00 00 00 6C 01 54 01 82 06 42 01 C4 04 57 01 59 01 10 02 5B 01 76 01 6E 01 5E 01 5F 01 11 00 61 01 62 01 60 01 7C 01 79 01 03 01 04 01 75 01 0C 01 77 01 3C 00 79 01 10 01 6C 01 7E 01 41 00 00 01 8D 01 75 01 11 01 7C 01 79 01 79 01 83 01 7A 01 4B 00 04 01 7C 01 56 06 B6 01 00 01 00 01 0A 01 39 02 00 01 B6 01 37 04 75 01 AB 00 EB 01 A4 01 79 01 83 01 3C 02 EA 01 59 01 A8 01 AB 01 68 02 AC 01 F1 00 65 00 38 01 AA 01 AC 01 71 02 36 01 07 05 67 01 A8 01 AA 01 05 05 3C 01 AD 01 EB 00 73 00 A8 01 7E 01 AB 00 2F 01 AA 01 AA 01 7D 02 A8 01 34 01 35 01 A8 01 A8 01 55 01 59 03 16 01 68 02 59 01 A8 01 3E 01 B6 01 40 01 23 05 AB 00 96 06 AA 01 2C 01 63 01 5B 01 48 01 76 02 AC 01 A8 01 2C 01 0D 05 A8 01 36 01 50 01 65 01 52 01 AB 00 3B 01 0D 04 56 01 0F 04 51 01 A4 02 AB 02 3B 01 A8 01 71 01 F7 01 B2 06 AE 02 AB 00 AB 00 AB 00 00 01 9A 03 AB 00 67 01 68 01 01 01 AB 00 BE 06 AB 00 C0 06 B1 01 B2 01 B3 01 B4 01 52 01 AB 00 35 05 0C 01 00 01 7D 01 39 05 77 01 77 01 33 04 A9 02 14 01 96 02 00 01 27 01 AE 02 AF 02 AB 00 00 01 99 01 AF 04 7E 01 D8 06 7D 01 62 04 83 01 33 01 A1 01 00 01 00 01 6C 01 A5 01 76 01 00 01 B9 05 A9 01 AA 01 01 01 46 01 00 00 64 05 71 02 CE 01 9D 01 90 06 00 01 F0 06 F1 06 15 00 00 01 00 01 67 01 46 01 F7 06 F8 06 A9 01 AA 01 00 01 00 01 00 01 AE 01 AF 01 B0 01 B1 01 B2 01 B3 01 B4 01 B5 01 B6 01 B7 01 B8 01 00 01 B3 04 E8 04 74 04 00 01 76 04 50 01 96 02 79 04 35 00 00 01 D8 01 D9 01 C0 05 AB 02 DC 01 19 03 01 01 EA 01 A8 01 A9 01 CE 01 EA 01 00 01 32 01 B6 01 F2 01 D3 06 6C 01 BD 01 F2 01 06 01 7C 01 00 01 A5 05 01 01 BD 01 00 01 00 01 FF 02 7D 01 54 01 00 01 2C 01 10 01 00 01 59 01 55 01 5B 01 00 01 10 01 5E 01 5F 01 78 01 61 01 62 01 16 01 7C 01 3B 01 F3 06 1A 01 F0 05 00 01 1D 06 75 01 A8 01 6C 01 7D 01 2B 01 29 01 24 06 18 03 A8 01 1C 02 A6 01 29 01 10 01 62 03 78 01 A8 01 7A 01 52 01 7C 01 20 02 54 01 22 02 27 01 09 05 A8 01 59 01 00 01 5B 01 35 04 49 03 5E 01 5F 01 44 01 61 01 62 01 41 06 7A 01 29 01 44 01 7C 01 1A 02 A8 01 77 01 1F 04 7A 01 DE 04 7A 01 E0 04 3D 02 E2 04 B4 06 B5 06 EE 01 EF 01 77 01 44 02 B0 05 57 01 F4 01 76 01 4F 02 79 01 A8 01 75 01 44 01 77 01 3B 02 00 01 3D 02 54 01 3F 02 8E 03 21 02 18 03 59 01 B6 01 5B 01 20 03 5B 02 5E 01 5F 01 7A 01 61 01 62 01 56 01 66 01 10 01 49 05 77 01 80 01 81 01 6C 01 32 01 3A 03 50 02 7A 01 7A 01 77 01 54 05 32 03 77 01 AE 04 77 01 79 01 8E 03 B2 03 7B 01 ED 06 77 01 66 02 41 03 29 01 76 01 6A 02 58 01 0A 01 5B 03 77 01 B6 01 88 01 7E 01 CE 03 8B 03 B6 01 BD 01 00 01 77 02 71 05 79 02 CA 04 14 03 75 02 FC 05 76 01 7D 02 7D 02 95 02 82 02 44 01 AF 01 B0 01 86 02 87 02 75 01 10 01 AF 01 B0 01 A0 02 AD 04 4F 06 16 01 A8 01 7E 01 8B 02 1A 01 C1 03 D7 02 AA 02 AB 02 79 01 00 01 76 01 9B 02 D1 04 3B 01 9E 02 6C 01 B6 01 59 05 29 01 8A 02 AF 01 B0 01 A4 02 A4 02 7A 01 B6 01 8A 02 AB 02 6D 06 6E 06 00 01 0A 01 71 06 D8 04 76 01 B3 02 B4 02 8B 03 08 01 C0 05 7C 01 A0 02 D7 02 76 01 7D 06 44 01 B6 01 80 06 A0 02 7C 01 32 01 13 04 76 01 7D 05 6C 01 76 01 DC 02 AA 01 54 01 07 01 00 01 7A 01 8F 06 59 01 57 01 5B 01 77 01 B3 02 5E 01 5F 01 7B 01 61 01 62 01 21 02 B6 01 A8 01 B2 03 7A 01 7A 01 7D 01 3B 01 C0 05 5A 00 5B 00 B6 01 7E 01 A7 06 F0 05 B5 01 1E 05 11 04 C0 05 13 05 54 01 AF 01 B0 01 D4 03 58 01 7C 01 07 03 46 01 09 03 7E 01 00 01 00 01 B1 05 72 00 B6 01 14 04 67 03 12 03 00 01 3C 01 2F 04 A8 01 C0 05 B6 01 05 03 C0 05 B6 01 AD 01 B6 01 0A 03 0B 03 C4 05 0D 03 75 01 B5 01 66 01 F0 05 79 01 50 05 7B 01 7C 01 7D 01 7E 01 76 01 B6 01 B6 01 F0 05 83 01 00 01 76 01 27 01 54 01 75 01 7D 01 C0 05 34 04 59 01 3A 03 5B 01 AF 01 B0 01 5E 01 5F 01 B6 01 61 01 62 01 C0 05 00 01 32 01 88 01 F0 05 37 05 7D 02 F0 05 32 04 4C 03 11 06 3A 03 7C 01 56 01 8D 01 14 04 7A 01 76 01 79 01 8A 02 62 04 7A 01 54 01 7C 01 5B 03 8A 03 49 03 A8 01 D8 04 79 01 83 01 62 03 58 01 A8 01 D8 04 D8 04 F0 05 A4 01 88 01 89 01 8A 01 A0 02 59 03 D2 00 D3 00 A4 02 77 01 33 03 F0 05 60 03 58 01 62 03 66 05 FD 03 A6 01 75 01 88 01 58 01 5A 00 5B 00 B3 02 75 01 A8 01 7D 01 86 01 79 01 54 01 7B 01 7C 01 5B 03 7E 01 59 01 72 05 5B 01 8B 01 83 01 5E 01 5F 01 B0 04 61 01 62 01 B6 01 72 00 B6 01 58 01 54 01 75 01 7F 03 54 01 81 03 59 01 00 01 5B 01 83 01 58 01 5E 01 5F 01 90 03 61 01 62 01 58 01 94 03 58 01 8D 01 BE 04 90 01 91 01 06 00 54 01 14 01 B1 03 9E 03 98 03 75 01 9A 03 86 04 87 01 D6 03 11 00 58 01 BB 03 75 01 7E 01 75 01 96 01 79 01 A4 01 BC 05 E1 03 75 01 97 01 75 01 7E 01 AB 01 28 06 2E 01 B7 03 CC 03 B9 03 CE 03 7E 01 75 01 A3 01 B5 01 58 01 D4 03 78 01 35 06 75 01 AB 03 7C 01 7B 01 DB 03 58 01 7E 01 58 01 AB 03 7E 01 18 05 CE 03 47 01 3C 00 BF 05 C0 05 B6 01 D4 03 41 00 D6 03 7D 04 7B 01 F8 03 4D 06 7E 01 00 01 F8 03 54 01 4B 00 E0 03 D2 00 D3 00 59 01 7D 01 5B 01 B6 01 D5 05 5E 01 5F 01 83 04 61 01 62 01 00 01 5A 00 5B 00 79 01 76 01 7B 01 83 01 8D 01 6D 01 6E 01 7C 01 54 01 65 00 0D 01 8C 01 58 01 8D 01 83 01 8D 01 13 05 58 01 F0 05 54 01 F2 05 50 05 72 00 73 00 79 01 83 01 7B 01 A4 01 1F 01 0D 04 56 03 0F 04 58 03 11 04 AB 01 8D 01 A4 01 3C 05 A4 01 7B 01 90 01 75 01 7E 01 AB 01 B5 01 AB 01 75 01 58 01 3A 04 21 04 7E 01 14 01 75 01 B5 01 26 04 B5 01 3C 04 29 04 A4 01 66 01 3F 05 0D 04 03 04 54 01 77 01 AB 01 75 01 33 04 58 01 35 04 79 01 0C 04 7B 01 7C 01 75 01 7E 01 75 01 2E 01 86 03 AB 00 83 01 89 03 A8 01 27 01 BC 01 7E 01 66 01 77 01 66 01 3A 01 94 01 95 01 35 06 88 01 32 05 33 01 75 01 75 01 66 04 83 01 66 01 79 01 47 01 7B 01 7C 01 05 01 7E 01 7B 01 6F 05 7B 01 00 01 83 01 D8 01 D9 01 A5 01 AB 03 84 06 B0 05 D2 00 D3 00 88 01 7A 01 88 01 7C 01 A8 01 7E 01 6E 04 27 01 A4 01 1D 01 86 04 7C 01 74 04 7E 01 76 04 AB 01 A5 01 79 04 83 01 33 01 6D 01 6E 01 2A 01 66 01 8D 01 A5 01 3A 01 2F 01 7B 01 6C 01 86 04 75 01 34 01 9D 04 36 01 37 01 38 01 39 01 46 01 A3 04 77 01 16 01 3E 01 7A 01 7B 01 7C 01 42 01 A4 01 27 01 33 01 46 01 75 01 7E 01 77 01 AB 01 90 01 3A 01 88 01 4E 01 C3 06 33 01 51 01 35 01 53 01 14 01 76 01 84 05 3A 01 80 05 AD 04 7E 01 7C 01 B0 04 FC 05 76 01 C6 05 11 00 62 05 00 01 46 01 7C 01 78 01 8F 04 7A 01 91 04 7C 01 7B 01 6B 01 2C 01 A8 01 2E 01 84 01 85 01 0D 04 DA 04 C7 04 E8 06 7E 01 7A 01 BC 01 7C 01 76 01 3A 01 3B 01 76 01 92 01 93 01 7C 01 7E 01 7A 01 7C 01 7C 01 D1 04 7E 01 7A 01 47 01 7C 01 A8 01 DE 04 3C 00 E0 04 4D 01 E2 04 27 01 41 00 E5 04 52 01 D8 01 D9 01 79 01 7C 01 57 01 7E 01 7D 01 4B 00 27 01 22 05 D8 04 11 06 01 07 02 07 78 01 78 01 7A 01 D8 04 7C 01 7C 01 6D 01 A8 01 C2 01 C3 01 C4 01 C5 01 6D 01 6E 01 F0 04 76 01 32 06 7C 01 79 01 65 00 7B 01 7C 01 77 01 58 01 0D 05 78 01 23 05 78 01 78 01 7C 01 13 05 7C 01 7C 01 73 00 7A 01 45 06 7C 01 18 05 18 05 8E 01 8F 01 32 05 78 01 A8 01 21 05 22 05 7C 01 90 01 1E 05 78 01 FD 05 76 01 95 01 7C 01 58 06 7A 01 5A 06 7E 01 05 06 A2 01 78 01 32 05 13 05 7A 01 7C 01 76 01 33 05 AA 01 76 01 7A 01 AD 01 3C 05 7A 01 7C 01 3F 05 5A 00 5B 00 A8 01 62 05 B6 01 64 05 7A 01 62 05 7C 01 64 05 7A 01 7A 01 7C 01 7C 01 AB 00 65 01 BC 01 BD 01 50 05 50 05 7A 01 7A 01 7C 01 7C 01 72 00 59 05 6D 01 83 01 76 01 77 01 D6 02 5F 05 77 01 80 05 05 01 A4 01 07 01 80 05 79 01 83 01 7B 01 90 06 7A 01 B3 04 D8 01 D9 01 7D 01 6F 05 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 1D 01 8E 01 8F 01 7D 05 7E 05 78 01 79 01 7E 01 7B 01 7C 01 7D 01 7A 01 A5 05 2A 01 76 01 78 01 A5 05 7A 01 2F 01 6F 01 70 01 A2 01 D8 04 34 01 7C 01 36 01 37 01 38 01 39 01 AA 01 B6 01 3C 01 AD 01 3E 01 7C 01 7A 01 7E 01 42 01 BF 05 C0 05 7C 01 7D 01 BF 05 C0 05 7A 01 78 01 BC 05 7A 01 78 01 4E 01 7A 01 78 01 51 01 7A 01 53 01 B1 05 B0 05 B0 05 CE 00 21 02 D5 05 A8 01 D2 00 D3 00 D5 05 7A 01 BC 05 7C 01 7A 01 A8 01 7C 01 09 05 27 01 78 01 C4 05 7A 01 C6 05 78 01 6B 01 7A 01 7C 01 13 05 7E 01 63 01 64 01 2C 01 18 05 F0 05 7C 01 F2 05 7E 01 F0 05 7C 01 F2 05 7E 01 27 01 7C 01 7C 01 7E 01 7A 01 3B 01 7A 01 F4 05 63 01 64 01 76 01 77 01 D6 02 7E 01 0E 07 7C 01 A4 01 A5 01 72 01 73 01 7C 01 6F 01 70 01 6F 01 70 01 72 01 73 01 7A 01 52 01 BE 01 BF 01 86 02 87 02 14 01 C0 01 C1 01 00 01 FC 05 FC 05 83 01 49 05 C6 01 C7 01 79 01 71 02 7E 03 00 06 50 05 83 01 B5 01 00 01 54 05 B5 01 FF 02 7D 01 27 01 7D 02 27 01 83 01 2E 01 7C 01 A8 01 7A 01 7C 01 7B 01 77 01 7B 01 7D 01 95 03 8A 02 A8 01 3A 01 7A 01 7C 01 23 06 83 01 7C 01 7C 01 7C 01 B6 01 71 05 96 02 7E 01 7C 01 47 01 7A 01 AD 01 75 01 7C 01 7A 01 4D 01 A0 02 A7 01 AE 03 7D 01 A4 02 A8 01 58 01 7C 01 7A 01 57 01 3E 06 3A 01 AD 01 27 01 3B 06 27 01 7C 01 78 01 75 01 B3 02 79 01 39 01 A8 01 7D 01 A8 01 00 01 44 01 7C 01 00 01 00 01 19 01 6D 01 6E 01 83 01 00 01 76 01 75 01 7A 01 58 01 7A 06 7E 01 2B 01 A8 01 7A 06 BD 01 79 01 78 01 7E 01 A7 01 7E 01 7A 01 83 01 B0 05 7C 01 D6 02 7C 01 8B 06 78 01 7E 01 5C 01 8B 06 7A 01 7A 01 AD 01 83 01 75 01 90 01 78 01 00 01 98 06 99 06 95 01 79 01 98 06 99 06 83 01 00 01 83 01 7A 01 76 01 84 06 7E 01 7A 01 5C 01 A8 01 82 06 7C 01 54 01 78 01 7E 03 7D 01 78 01 90 06 78 01 7A 01 FF 02 75 01 B4 06 B5 06 7A 01 7D 01 B4 06 B5 06 5D 01 76 01 15 04 A8 01 7C 01 79 01 A1 06 BC 01 A8 01 95 03 5D 01 00 01 76 01 75 01 75 01 75 01 83 01 18 03 7E 01 76 01 65 01 7A 01 52 01 00 01 76 01 FC 05 79 01 76 01 7C 01 7E 01 7A 01 76 01 76 01 32 01 AE 03 D8 01 D9 01 79 01 7E 01 77 01 C3 06 21 02 79 01 32 03 75 01 A8 01 A8 01 A8 01 58 01 7E 01 79 01 ED 06 75 01 79 01 A8 01 ED 06 7B 01 79 01 79 01 83 01 7E 01 5A 00 5B 00 77 01 79 01 7C 01 F7 01 7A 01 7A 01 83 01 7B 01 7B 01 7A 01 7C 01 05 01 7C 01 7C 01 E8 06 A8 01 56 03 7E 01 58 03 01 07 02 07 7A 01 72 00 78 01 7E 01 83 01 7E 01 7A 01 78 01 F0 06 F1 06 7A 01 7E 01 7A 01 76 01 1D 01 F7 06 F8 06 3C 01 01 07 02 07 7A 01 76 01 83 01 A8 01 00 01 07 01 A8 01 2A 01 79 01 79 01 76 01 0E 07 2F 01 83 01 00 00 7E 03 8B 04 34 01 8D 04 36 01 37 01 38 01 39 01 86 03 7A 01 7A 01 89 03 3E 01 8B 03 7D 02 7E 01 42 01 00 00 15 04 A8 01 46 01 7E 01 75 01 95 03 76 01 A8 01 7E 01 8A 02 4E 01 7A 01 00 00 51 01 7C 01 53 01 76 01 7E 01 7A 01 75 01 A8 01 7A 01 3C 01 78 01 76 01 78 01 7E 01 AB 03 76 01 7A 01 AE 03 A0 02 75 01 A8 01 B2 03 A4 02 76 01 7E 01 7E 01 6B 01 CE 00 7A 01 7E 01 7E 01 D2 00 D3 00 00 01 7A 01 76 01 7A 01 B3 02 71 02 76 01 75 01 7E 01 54 01 76 01 76 01 7B 01 7E 01 59 01 07 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 7E 01 7E 01 7E 01 7E 01 62 04 7E 01 7E 01 7E 01 33 00 6F 01 70 01 0C 00 F1 04 05 00 83 04 96 02 76 01 FD 03 78 01 0D 04 7A 01 32 05 7C 01 7D 01 7E 01 32 05 F2 05 A8 01 D5 05 0D 06 3A 05 B9 06 93 06 87 01 C9 06 87 06 A4 06 14 01 8C 01 32 03 FD 05 17 06 E4 05 18 04 40 03 8B 04 3E 06 8D 04 96 01 97 01 18 04 18 04 0D 04 13 04 28 06 3C 06 F0 05 54 01 F8 06 14 04 15 04 A3 01 59 01 2E 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 3A 01 9D 06 E1 06 99 06 D6 02 B6 01 98 06 F1 06 A5 05 6F 01 70 01 5A 06 17 06 47 01 F8 03 4D 01 76 01 8B 03 78 01 4D 01 7A 01 A7 05 7C 01 7D 01 7E 01 2F 04 D4 03 43 04 60 03 57 01 BE 04 49 00 86 01 87 01 69 01 D8 04 DA 04 8B 01 8C 01 3A 03 B4 02 C8 01 5B 03 C9 01 CC 01 FF 02 94 01 95 01 96 01 97 01 79 02 6D 01 6E 01 CA 01 CD 01 CB 01 E0 03 B2 03 37 05 8F 05 FB 05 A3 01 62 04 18 05 71 02 56 03 14 03 58 03 AB 00 16 05 18 03 22 05 F1 04 CA 04 9F 04 18 05 72 05 9D 01 00 01 53 05 B6 01 51 02 40 04 E1 01 E1 01 F6 05 90 01 09 01 F3 03 0B 01 7E 05 95 01 0E 01 FA 03 10 03 00 00 32 03 13 01 FF FF FF FF FF FF FF FF 18 01 8B 04 FF FF 8D 04 FF FF FF FF FF FF FF FF FF FF 21 01 FF FF 86 03 FF FF FF FF 89 03 FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF FF FF BC 01 FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF 3D 01 FF FF 3F 01 BE 05 B3 04 FF FF 43 01 09 01 FF FF 0B 01 FF FF AB 03 0E 01 FF FF 4B 01 4C 01 FF FF 13 01 4F 01 D8 01 D9 01 52 01 18 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 21 01 FF FF 7E 03 FF FF FF FF FF FF FF FF 28 01 FF FF FF FF D8 04 FF FF 2D 01 FF FF FF FF 8B 03 31 01 FF FF 65 05 F7 01 FF FF FF FF FF FF FF FF FF FF 95 03 FF FF FF FF 3D 01 79 01 3F 01 FF FF FF FF FB 05 43 01 F1 04 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 AE 03 FF FF 0E 06 0F 06 B2 03 FF FF FF FF FF FF FF FF 09 05 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 13 05 FF FF FF FF FF FF FF FF 18 05 FF FF A8 01 FF FF 0D 04 FF FF 2A 06 FF FF FF FF 2D 06 A7 05 FF FF FF FF FF FF 79 01 FF FF 60 00 FF FF FF FF 63 00 FF FF FF FF FF FF 67 00 68 00 69 00 6A 00 6B 00 6C 00 6D 00 6E 00 FF FF FF FF BE 05 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 05 01 49 05 FF FF FF FF FF FF FF FF FF FF FD 03 50 05 FF FF FF FF FF FF 54 05 A8 01 FF FF FF FF FF FF FF FF FF FF 71 02 FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF 65 05 14 04 15 04 FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF 71 05 2F 01 FF FF FF FF FF FF FB 05 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF 96 02 3E 01 FF FF FF FF 01 01 42 01 FF FF FF FF 05 01 0E 06 0F 06 FF FF 11 06 FF FF FF FF FF FF FF FF 4E 01 FF FF 10 01 51 01 FF FF 53 01 FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF 00 00 2A 06 FF FF A7 05 2D 06 FF FF FF FF FF FF 29 01 2A 01 6B 01 FF FF B0 05 2E 01 2F 01 FF FF 62 04 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF BE 05 FF FF D6 02 3E 01 B3 04 FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF 50 01 51 01 83 04 53 01 FF FF FF FF FF FF 57 01 FF FF FF FF 8B 04 FF FF 8D 04 FF FF FF FF FF FF FF FF FF FF FF FF FF FF D8 04 FF FF FF 02 FF FF A8 01 FF FF FF FF 6B 01 FF FF FF FF 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 76 01 77 01 FB 05 FC 05 FD 05 14 03 FF FF FF FF FF FF 18 03 FF FF FF FF 05 06 FF FF 3F 01 FF FF FF FF FF FF FF FF FF FF FF FF 0E 06 0F 06 FF FF 11 06 FF FF FF FF FF FF FF FF FF FF FF FF 09 05 FF FF FF FF FF FF 32 03 FF FF FF FF FF FF FF FF FF FF 13 05 FF FF FF FF FF FF FF FF 18 05 FF FF FF FF 2A 06 FF FF FF FF 2D 06 66 01 FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF FF FF FF FF 70 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F1 04 FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF 49 05 FF FF FF FF FF FF FF FF FF FF FF FF 50 05 6F 01 70 01 FF FF 54 05 FF FF FF FF FF FF 76 01 7E 03 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 8B 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 8C 01 FF FF 95 03 71 05 B9 01 BA 01 BB 01 FF FF FF FF BE 01 BF 01 C0 01 C1 01 C2 01 C3 01 C4 01 C5 01 C6 01 C7 01 C8 01 C9 01 CA 01 CB 01 CC 01 CD 01 FF FF FF FF AE 03 FF FF FF FF FF FF B2 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 01 01 FF FF B6 01 00 00 05 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 10 01 FF FF FF FF 65 05 FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 B0 05 FF FF 1D 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF FF FF FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FD 03 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF A7 05 FF FF 57 01 FF FF FF FF 14 04 15 04 FF FF 39 02 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FC 05 FF FF FF FF FF FF 6B 01 BE 05 FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF 75 01 76 01 77 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 62 04 FB 05 FF FF FD 05 FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF 05 06 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 0E 06 0F 06 9A 02 11 06 FF FF FF FF FF FF FF FF FF FF 17 06 FF FF FF FF FF FF 83 04 FF FF FF FF FF FF 09 01 FF FF 0B 01 FF FF 8B 04 0E 01 8D 04 FF FF B6 01 28 06 13 01 2A 06 FF FF FF FF 2D 06 18 01 FF FF FF FF FF FF 1C 01 FF FF FF FF 35 06 FF FF 21 01 FF FF FF FF FF FF 66 01 26 01 FF FF 28 01 FF FF FF FF 6C 01 6D 01 2D 01 FF FF FF FF FF FF 31 01 32 01 D3 02 D4 02 76 01 77 01 4D 06 79 01 7A 01 7B 01 7C 01 FF FF 3D 01 FF FF 3F 01 00 01 FF FF 83 01 43 01 E4 02 05 01 06 01 88 01 FF FF FF FF FF FF 4B 01 4C 01 8E 01 8F 01 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF A2 01 FF FF FF FF FF FF FF FF FF FF A8 01 FF FF AA 01 2A 01 2B 01 AD 01 FF FF FF FF 2F 01 FF FF FF FF 32 01 F1 04 34 01 B6 01 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF A8 01 FF FF FF FF 6B 01 6C 01 6D 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 5F 03 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 00 00 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF FF FF A6 01 65 05 A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 00 01 01 01 FF FF FF FF 00 01 05 01 FF FF FF FF FF FF 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 FF FF 28 01 29 01 2A 01 FF FF FF FF 2D 01 2E 01 2F 01 FF FF 31 01 A7 05 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 FF FF FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF BE 05 FF FF 4B 01 4C 01 FF FF 4E 01 4F 01 FF FF 51 01 52 01 53 01 FF FF FF FF FF FF 57 01 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF 6B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 75 01 76 01 77 01 FF FF 79 01 76 01 FF FF 78 01 FF FF 7A 01 7F 01 7C 01 7D 01 7E 01 FF FF FF FF 00 00 FB 05 FF FF FD 05 FF FF FF FF FF FF FF FF FF FF FF FF 05 01 05 06 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2F 04 0E 06 0F 06 FF FF 11 06 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 A8 01 FF FF FF FF FF FF FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF FF FF 2A 01 2A 06 FF FF FF FF 2D 06 2F 01 B6 01 FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF 6A 04 FF FF FF FF 00 01 01 01 4E 01 70 04 FF FF 51 01 FF FF 53 01 08 01 09 01 0A 01 0B 01 0C 01 FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 19 01 FF FF FF FF 00 00 FF FF 1E 01 6B 01 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF 76 01 FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF A8 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF AC 01 FF FF AE 01 00 01 01 01 FF FF FF FF FF FF 00 00 FF FF B6 01 08 01 09 01 0A 01 0B 01 0C 01 FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 00 01 FF FF 6F 01 70 01 71 01 05 01 06 01 FF FF 75 01 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF 1D 01 FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 2B 01 FF FF FF FF FF FF 2F 01 00 00 FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 A7 01 A8 01 A9 01 AA 01 3E 01 AC 01 FF FF AE 01 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 66 01 FF FF FF FF FF FF FF FF 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 88 01 FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF 05 01 06 01 FF FF FF FF FF FF FF FF A3 01 FF FF FF FF A6 01 FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 B6 01 FF FF 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 2B 01 FF FF FF FF FF FF 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 66 01 FF FF FF FF FF FF FF FF 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 88 01 FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF 05 01 06 01 FF FF FF FF FF FF FF FF A3 01 FF FF FF FF A6 01 FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 B6 01 FF FF 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 2B 01 FF FF FF FF FF FF 2F 01 FF FF FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 00 01 FF FF FF FF 8B 01 8C 01 05 01 06 01 FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A3 01 FF FF 1D 01 A6 01 FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF 2A 01 2B 01 FF FF FF FF B6 01 2F 01 00 00 FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF 05 01 06 01 FF FF FF FF FF FF FF FF A3 01 FF FF FF FF A6 01 FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 2B 01 FF FF FF FF FF FF 2F 01 FF FF FF FF 00 00 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF 00 00 FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF 05 01 06 01 FF FF FF FF FF FF FF FF A3 01 FF FF FF FF A6 01 FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 2B 01 FF FF FF FF FF FF 2F 01 FF FF FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF 00 00 FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 54 01 FF FF FF FF FF FF 58 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 FF FF 78 01 79 01 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF 00 00 FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF 01 01 FF FF FF FF FF FF 05 01 FF FF FF FF FF FF A3 01 FF FF FF FF A6 01 FF FF A8 01 FF FF 10 01 FF FF FF FF FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF B6 01 1D 01 FF FF 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF FF FF FF FF 2E 01 2F 01 FF FF 05 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF 4E 01 FF FF 50 01 51 01 FF FF 53 01 FF FF FF FF 2A 01 57 01 01 01 FF FF FF FF 2F 01 05 01 FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF 10 01 FF FF 00 00 3E 01 6B 01 FF FF 16 01 42 01 FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF 77 01 FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 29 01 2A 01 FF FF FF FF FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF 6B 01 FF FF 42 01 FF FF 44 01 FF FF FF FF 72 01 73 01 FF FF FF FF 01 01 FF FF FF FF 4E 01 05 01 FF FF 51 01 00 00 53 01 FF FF FF FF FF FF 57 01 AF 01 B0 01 10 01 FF FF FF FF FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF 6B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF 76 01 77 01 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF 00 00 51 01 FF FF 53 01 01 01 FF FF FF FF 57 01 05 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 10 01 FF FF AF 01 B0 01 FF FF FF FF 16 01 FF FF 6B 01 FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF 76 01 77 01 FF FF FF FF FF FF 00 00 29 01 2A 01 FF FF 01 01 FF FF 2E 01 2F 01 05 01 FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF 10 01 FF FF FF FF 3E 01 FF FF FF FF 16 01 42 01 FF FF 44 01 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 29 01 2A 01 FF FF 57 01 FF FF 2E 01 2F 01 FF FF AF 01 B0 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF 6B 01 FF FF 42 01 FF FF 44 01 00 00 FF FF FF FF FF FF FF FF FF FF 01 01 77 01 FF FF 4E 01 05 01 FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 57 01 FF FF FF FF 10 01 FF FF FF FF FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF 6B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF FF FF FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 AF 01 B0 01 FF FF FF FF 3E 01 FF FF FF FF 01 01 42 01 FF FF 44 01 05 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF 10 01 51 01 FF FF 53 01 FF FF FF FF 16 01 57 01 FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF 29 01 2A 01 6B 01 FF FF FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF 01 01 FF FF FF FF FF FF 05 01 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 57 01 10 01 FF FF FF FF FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF 6B 01 FF FF FF FF FF FF AF 01 B0 01 29 01 2A 01 FF FF 01 01 FF FF 2E 01 2F 01 05 01 FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF 10 01 FF FF FF FF 3E 01 FF FF FF FF 16 01 42 01 FF FF 44 01 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 29 01 2A 01 FF FF 57 01 FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF AF 01 B0 01 3E 01 FF FF 6B 01 FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF 01 01 FF FF FF FF FF FF 05 01 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 57 01 10 01 FF FF FF FF FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF 6B 01 FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF FF FF FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF AF 01 B0 01 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 57 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF 6B 01 FF FF FF FF 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 0A 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 AF 01 B0 01 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 06 01 FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 2B 01 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF FF FF FF FF AE 01 FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 B6 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 66 01 FF FF FF FF FF FF FF FF FF FF 6C 01 6D 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 A4 01 FF FF 00 01 FF FF A8 01 05 01 AA 01 AB 01 06 01 AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF 2B 01 FF FF 2F 01 FF FF FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF FF FF FF FF 06 01 FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 66 01 FF FF FF FF 6B 01 FF FF FF FF 6C 01 6D 01 2B 01 6F 01 70 01 FF FF FF FF FF FF 76 01 75 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 A4 01 00 01 A8 01 FF FF A8 01 FF FF AA 01 06 01 FF FF AD 01 FF FF FF FF 6D 01 FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF 79 01 7A 01 7B 01 7C 01 7D 01 FF FF FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 2B 01 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF FF FF FF FF FF FF FF FF FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 66 01 FF FF FF FF FF FF FF FF FF FF 6C 01 6D 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF FF FF A8 01 05 01 AA 01 06 01 FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF 10 01 FF FF B6 01 FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF 2B 01 FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF 54 01 FF FF 57 01 FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 66 01 FF FF FF FF FF FF 6B 01 FF FF 6C 01 6D 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 76 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF 05 01 A8 01 FF FF AA 01 06 01 FF FF AD 01 AF 01 B0 01 FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF 2B 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF 3C 01 FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 00 01 FF FF 6B 01 FF FF FF FF FF FF FF FF 6D 01 FF FF 6F 01 70 01 FF FF FF FF 76 01 77 01 75 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF FF FF FF FF FF FF AA 01 06 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 FF FF FF FF FF FF FF FF FF FF 2B 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 75 01 76 01 B6 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF FF FF FF FF 05 01 AA 01 06 01 FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF 10 01 FF FF B6 01 FF FF FF FF FF FF 16 01 FF FF FF FF FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 29 01 2A 01 FF FF 2B 01 FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF 54 01 FF FF 57 01 FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF 6B 01 FF FF FF FF 6D 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 76 01 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF 05 01 FF FF 07 01 AA 01 06 01 FF FF AD 01 AF 01 B0 01 FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF 2B 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF 6B 01 FF FF FF FF FF FF FF FF 6D 01 FF FF 6F 01 70 01 FF FF FF FF 76 01 77 01 FF FF 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF FF FF FF FF 05 01 AA 01 06 01 FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF 2B 01 FF FF FF FF 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF 00 01 FF FF 6B 01 FF FF FF FF 6D 01 FF FF 6F 01 70 01 72 01 73 01 FF FF FF FF 76 01 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF FF FF FF FF FF FF AA 01 06 01 FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF 2B 01 FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 06 01 FF FF 8C 01 FF FF 0A 01 FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 97 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 A3 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF 2B 01 FF FF FF FF FF FF 76 01 FF FF 78 01 B6 01 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 3B 01 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 FF FF A3 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 66 01 FF FF FF FF FF FF FF FF FF FF 6C 01 6D 01 FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF FF FF A8 01 05 01 AA 01 06 01 FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF 2B 01 FF FF FF FF 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 06 01 FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF 6B 01 FF FF 6C 01 6D 01 2B 01 6F 01 70 01 72 01 73 01 FF FF FF FF 76 01 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A2 01 A3 01 FF FF FF FF FF FF FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 FF FF 6C 01 6D 01 FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF 76 01 77 01 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 FF FF 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF 00 01 FF FF 05 01 A8 01 FF FF AA 01 06 01 FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF 2B 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF 3C 01 FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF 6B 01 FF FF FF FF FF FF FF FF 6D 01 00 01 6F 01 70 01 FF FF FF FF 76 01 06 01 FF FF 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 2B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A2 01 A3 01 FF FF FF FF FF FF FF FF FF FF FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 01 00 01 6F 01 70 01 FF FF FF FF FF FF 06 01 FF FF 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 2B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A2 01 A3 01 FF FF FF FF FF FF FF FF FF FF FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6D 01 00 01 6F 01 70 01 FF FF FF FF FF FF 06 01 FF FF 76 01 FF FF 78 01 79 01 7A 01 7B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 2B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A2 01 A3 01 FF FF FF FF FF FF FF FF FF FF FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 54 01 FF FF 06 01 FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 77 01 78 01 FF FF 7A 01 2B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 06 01 FF FF FF FF FF FF A3 01 54 01 FF FF FF FF FF FF A8 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF 2B 01 FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 00 01 FF FF FF FF FF FF 54 01 FF FF 06 01 FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF 6C 01 B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 2B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 06 01 FF FF FF FF FF FF A3 01 54 01 FF FF FF FF FF FF A8 01 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF 2B 01 FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 00 01 FF FF FF FF FF FF 54 01 FF FF 06 01 FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 2B 01 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 06 01 FF FF FF FF FF FF A3 01 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 B6 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF 2B 01 FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF 00 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 08 01 09 01 A3 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF B6 01 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 68 01 69 01 6A 01 6B 01 6C 01 00 01 FF FF 6F 01 70 01 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 79 01 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A3 01 FF FF A7 01 A8 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF B5 01 B6 01 FF FF B6 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF A3 01 FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF A3 01 FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF A3 01 FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF A3 01 FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF A3 01 FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 00 01 FF FF FF FF 8B 01 8C 01 FF FF 06 01 FF FF FF FF FF FF 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF A3 01 FF FF 59 01 FF FF 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF 2B 01 FF FF FF FF B6 01 FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF 84 01 85 01 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 92 01 93 01 94 01 95 01 96 01 97 01 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A3 01 FF FF FF FF FF FF FF FF FF FF 6D 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 76 01 FF FF FF FF 79 01 B6 01 7B 01 7C 01 FF FF FF FF FF FF 80 01 81 01 FF FF FF FF 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A2 01 A3 01 FF FF 00 01 FF FF FF FF FF FF FF FF AA 01 FF FF FF FF AD 01 FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 B6 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF 94 01 95 01 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 86 01 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 87 01 FF FF FF FF FF FF 8B 01 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 87 01 FF FF FF FF FF FF FF FF 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 8C 01 FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 8C 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 96 01 97 01 FF FF FF FF FF FF FF FF FF FF 54 01 FF FF FF FF FF FF FF FF 59 01 A3 01 5B 01 5C 01 5D 01 5E 01 5F 01 60 01 61 01 62 01 63 01 64 01 65 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF B6 01 FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF 76 01 FF FF 78 01 FF FF 7A 01 FF FF 7C 01 7D 01 7E 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF 8C 01 FF FF FF FF 05 01 FF FF FF FF FF FF 09 01 FF FF 0B 01 FF FF 97 01 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 A3 01 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 FF FF 1E 01 FF FF FF FF 26 01 FF FF 28 01 29 01 2A 01 FF FF B6 01 2D 01 FF FF 2F 01 2B 01 31 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 06 01 FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 48 01 4E 01 4F 01 FF FF 51 01 52 01 53 01 FF FF FF FF FF FF 57 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2B 01 FF FF FF FF FF FF FF FF FF FF 6B 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 75 01 76 01 77 01 FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 FF FF FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 FF FF FF FF FF FF FF FF FF FF 66 01 FF FF FF FF FF FF FF FF FF FF FF FF 6D 01 A8 01 FF FF FF FF FF FF FF FF FF FF FF FF AF 01 B0 01 77 01 FF FF 79 01 7A 01 7B 01 7C 01 FF FF FF FF FF FF 80 01 81 01 FF FF 83 01 84 01 85 01 86 01 87 01 88 01 89 01 8A 01 8B 01 8C 01 FF FF 8E 01 8F 01 90 01 91 01 92 01 93 01 94 01 95 01 96 01 97 01 98 01 99 01 9A 01 9B 01 9C 01 9D 01 9E 01 9F 01 A0 01 A1 01 A2 01 A3 01 FF FF FF FF 00 01 FF FF A8 01 FF FF AA 01 FF FF FF FF AD 01 08 01 09 01 0A 01 0B 01 0C 01 FF FF 0E 01 0F 01 B6 01 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 00 01 AC 01 FF FF AE 01 FF FF FF FF FF FF FF FF 08 01 09 01 0A 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 00 01 FF FF FF FF AE 01 FF FF FF FF FF FF FF FF 08 01 09 01 0A 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 00 01 FF FF FF FF AE 01 FF FF FF FF FF FF FF FF 08 01 09 01 0A 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 00 01 FF FF FF FF AE 01 FF FF FF FF FF FF FF FF 08 01 09 01 0A 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF 11 01 12 01 13 01 14 01 15 01 16 01 17 01 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF 20 01 21 01 22 01 23 01 24 01 25 01 FF FF FF FF 28 01 FF FF FF FF FF FF 2C 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 3B 01 FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 45 01 46 01 47 01 48 01 49 01 4A 01 4B 01 4C 01 4D 01 4E 01 4F 01 50 01 FF FF 52 01 FF FF FF FF 55 01 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF 33 01 FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF 7C 01 FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 40 01 41 01 FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 41 01 FF FF 43 01 FF FF FF FF 46 01 47 01 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF 33 01 FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 7E 01 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 01 FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF 08 01 09 01 AE 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF 00 01 FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF 09 01 FF FF 0B 01 FF FF 1E 01 0E 01 FF FF 21 01 FF FF FF FF 13 01 FF FF FF FF FF FF 28 01 18 01 FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF 3D 01 2D 01 3F 01 40 01 FF FF 31 01 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 3D 01 4F 01 3F 01 FF FF FF FF FF FF 43 01 FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF 79 01 FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF A8 01 18 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 3A 01 4F 01 FF FF 3D 01 FF FF 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 FF FF 1E 01 AD 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF B5 01 28 01 FF FF FF FF FF FF FF FF 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 A9 01 AA 01 FF FF FF FF AD 01 05 01 FF FF 07 01 FF FF 09 01 FF FF 0B 01 B5 01 FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 27 01 28 01 29 01 2A 01 FF FF FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF 33 01 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF 3C 01 3D 01 3E 01 3F 01 FF FF FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 4E 01 4F 01 FF FF 51 01 52 01 53 01 FF FF FF FF FF FF 57 01 FF FF 05 01 FF FF FF FF FF FF 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 6B 01 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 72 01 73 01 20 01 21 01 FF FF FF FF FF FF 79 01 26 01 FF FF 28 01 29 01 2A 01 FF FF FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 FF FF FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 4E 01 4F 01 FF FF 51 01 52 01 53 01 A8 01 FF FF FF FF 57 01 FF FF 05 01 FF FF AF 01 B0 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 6B 01 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 76 01 FF FF FF FF 79 01 26 01 FF FF 28 01 29 01 2A 01 7F 01 FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 FF FF FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 4E 01 4F 01 FF FF 51 01 52 01 53 01 A8 01 FF FF FF FF 57 01 FF FF 05 01 FF FF AF 01 B0 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 6B 01 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 76 01 FF FF FF FF 79 01 26 01 FF FF 28 01 29 01 2A 01 7F 01 FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 FF FF FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 4E 01 4F 01 FF FF 51 01 52 01 53 01 A8 01 FF FF FF FF 57 01 FF FF 05 01 FF FF AF 01 B0 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 6B 01 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 FF FF FF FF FF FF 79 01 26 01 FF FF 28 01 29 01 2A 01 7F 01 FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 FF FF FF FF 42 01 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 4E 01 4F 01 FF FF 51 01 52 01 53 01 A8 01 FF FF FF FF 57 01 FF FF 05 01 FF FF AF 01 B0 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 6B 01 18 01 FF FF 1A 01 1B 01 1C 01 1D 01 FF FF FF FF 20 01 21 01 76 01 FF FF FF FF 79 01 26 01 FF FF 28 01 29 01 2A 01 FF FF FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF FF FF 34 01 05 01 36 01 37 01 38 01 39 01 3A 01 FF FF FF FF 3D 01 3E 01 3F 01 10 01 FF FF 42 01 43 01 44 01 FF FF 16 01 FF FF FF FF FF FF 1A 01 4B 01 4C 01 1D 01 4E 01 4F 01 FF FF 51 01 52 01 53 01 A8 01 FF FF FF FF 57 01 FF FF 29 01 2A 01 AF 01 B0 01 FF FF 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF 6B 01 FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF 76 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF 4E 01 FF FF 50 01 51 01 FF FF 53 01 FF FF FF FF FF FF 57 01 05 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 10 01 FF FF FF FF FF FF FF FF FF FF 16 01 FF FF 6B 01 FF FF 1A 01 FF FF FF FF 1D 01 FF FF FF FF FF FF FF FF FF FF 76 01 77 01 A8 01 FF FF FF FF FF FF 29 01 2A 01 FF FF AF 01 B0 01 2E 01 2F 01 FF FF FF FF FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF 44 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF 00 01 51 01 FF FF 53 01 FF FF FF FF 06 01 57 01 08 01 09 01 FF FF 0B 01 AF 01 B0 01 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF 6B 01 FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF 76 01 77 01 28 01 FF FF FF FF 2B 01 FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 58 01 FF FF FF FF FF FF FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF 7B 01 FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 83 01 FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF 06 01 FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF 2B 01 FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 58 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF 7B 01 FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF 06 01 FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF 2B 01 FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF 7B 01 FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF 7B 01 FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF 00 01 FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF A7 01 A8 01 1E 01 AA 01 FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF 07 01 FF FF 09 01 FF FF 0B 01 80 01 81 01 0E 01 FF FF 10 01 11 01 FF FF 13 01 88 01 FF FF 16 01 FF FF 18 01 FF FF 1A 01 1B 01 1C 01 FF FF FF FF FF FF 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 FF FF 28 01 29 01 FF FF FF FF FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF A7 01 A8 01 FF FF AA 01 FF FF FF FF FF FF 3A 01 FF FF 3C 01 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 00 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF 08 01 09 01 57 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF 72 01 73 01 FF FF 28 01 FF FF FF FF FF FF 79 01 2D 01 FF FF 2F 01 30 01 31 01 7F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF 00 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 09 01 4F 01 0B 01 FF FF FF FF 0E 01 FF FF FF FF FF FF FF FF 13 01 FF FF FF FF A8 01 FF FF 18 01 FF FF FF FF FF FF FF FF AF 01 B0 01 FF FF FF FF 21 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 28 01 FF FF 6F 01 70 01 FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 FF FF 00 01 FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 09 01 4F 01 0B 01 FF FF 52 01 0E 01 FF FF FF FF FF FF FF FF 13 01 FF FF FF FF FF FF FF FF 18 01 FF FF FF FF FF FF FF FF A7 01 A8 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 09 01 4F 01 0B 01 FF FF 52 01 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 FF FF 1A 01 1B 01 1C 01 FF FF A8 01 FF FF 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 FF FF 28 01 29 01 FF FF FF FF FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 09 01 FF FF 0B 01 FF FF 57 01 0E 01 FF FF 10 01 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 A8 01 1A 01 1B 01 1C 01 FF FF FF FF FF FF 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 FF FF 28 01 29 01 FF FF FF FF FF FF 2D 01 FF FF 79 01 FF FF 31 01 FF FF FF FF FF FF 7F 01 FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 44 01 FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF 57 01 FF FF FF FF FF FF FF FF 08 01 09 01 A8 01 0B 01 FF FF FF FF 0E 01 0F 01 FF FF AF 01 B0 01 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF 09 01 1E 01 0B 01 FF FF 21 01 0E 01 FF FF FF FF 79 01 FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF 33 01 FF FF 21 01 FF FF FF FF FF FF FF FF 3A 01 FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 FF FF 3F 01 A8 01 FF FF 56 01 43 01 FF FF 59 01 5A 01 AF 01 B0 01 FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 7A 01 FF FF 7C 01 FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF 78 01 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 A8 01 2F 01 30 01 31 01 FF FF 33 01 FF FF 21 01 FF FF FF FF FF FF FF FF 3A 01 FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 FF FF 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF 7C 01 FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 FF FF 1E 01 FF FF AE 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 40 01 41 01 FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 52 01 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 52 01 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF 3A 01 FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 FF FF 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 FF FF 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 FF FF 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF 75 01 FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 09 01 1E 01 0B 01 AE 01 21 01 0E 01 FF FF FF FF FF FF FF FF 13 01 28 01 FF FF FF FF FF FF 18 01 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF 3A 01 FF FF 28 01 3D 01 FF FF 3F 01 40 01 2D 01 FF FF 43 01 FF FF 31 01 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF 3D 01 FF FF 3F 01 FF FF FF FF 56 01 43 01 FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF 79 01 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 FF FF 1E 01 FF FF AE 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 A8 01 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 FF FF 1E 01 FF FF AE 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 FF FF 1E 01 FF FF AE 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 A7 01 A8 01 A9 01 AA 01 FF FF 1E 01 FF FF AE 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 05 01 FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF 1D 01 FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF FF FF 2F 01 FF FF FF FF 32 01 FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 A7 01 A8 01 A9 01 AA 01 3E 01 FF FF FF FF AE 01 42 01 FF FF FF FF FF FF 46 01 FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF 4E 01 0E 01 0F 01 51 01 FF FF 53 01 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF 09 01 FF FF 0B 01 FF FF 1E 01 0E 01 FF FF 21 01 FF FF FF FF 13 01 66 01 FF FF FF FF 28 01 18 01 6B 01 FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 21 01 FF FF FF FF 76 01 77 01 FF FF 79 01 28 01 7B 01 FF FF FF FF 3D 01 2D 01 3F 01 40 01 FF FF 31 01 43 01 FF FF FF FF 46 01 88 01 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 3D 01 4F 01 3F 01 FF FF FF FF FF FF 43 01 FF FF 56 01 FF FF FF FF 59 01 5A 01 FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF A8 01 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF 6C 01 FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF 79 01 FF FF FF FF FF FF 8E 01 8F 01 FF FF FF FF FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF A7 01 A8 01 A9 01 AA 01 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF A8 01 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 A7 01 A8 01 21 01 AA 01 FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 71 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF 7F 01 80 01 81 01 82 01 FF FF FF FF FF FF 86 01 FF FF 88 01 FF FF FF FF FF FF FF FF FF FF 8E 01 8F 01 08 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 A7 01 A8 01 21 01 AA 01 FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF FF FF 80 01 81 01 FF FF FF FF 08 01 09 01 FF FF 0B 01 88 01 FF FF 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF A7 01 A8 01 2D 01 AA 01 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 39 01 FF FF FF FF FF FF 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF 79 01 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF FF FF FF FF FF FF FF FF 1E 01 FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF A7 01 A8 01 3D 01 FF FF 3F 01 40 01 FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF 08 01 09 01 FF FF 0B 01 FF FF 79 01 0E 01 0F 01 FF FF FF FF FF FF 13 01 14 01 15 01 16 01 FF FF 18 01 FF FF 09 01 FF FF 0B 01 FF FF 1E 01 0E 01 FF FF 21 01 FF FF FF FF 13 01 FF FF FF FF FF FF 28 01 18 01 FF FF FF FF FF FF 2D 01 FF FF 2F 01 30 01 31 01 21 01 FF FF FF FF FF FF FF FF FF FF FF FF 28 01 FF FF A7 01 A8 01 3D 01 2D 01 3F 01 40 01 FF FF 31 01 43 01 FF FF FF FF 46 01 FF FF 48 01 FF FF 4A 01 4B 01 4C 01 4D 01 3D 01 4F 01 3F 01 FF FF 52 01 FF FF 43 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 FF FF FF FF FF FF FF FF 68 01 69 01 6A 01 6B 01 6C 01 FF FF FF FF 6F 01 70 01 FF FF FF FF FF FF FF FF 09 01 FF FF 0B 01 FF FF 79 01 0E 01 FF FF FF FF 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 FF FF 1A 01 1B 01 1C 01 FF FF 79 01 7A 01 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 A7 01 A8 01 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4B 01 4C 01 A8 01 FF FF 4F 01 FF FF FF FF 52 01 09 01 FF FF 0B 01 FF FF 57 01 0E 01 FF FF FF FF 11 01 FF FF 13 01 FF FF FF FF 16 01 FF FF 18 01 FF FF 1A 01 1B 01 1C 01 FF FF FF FF FF FF 20 01 21 01 FF FF FF FF FF FF FF FF 26 01 FF FF 28 01 09 01 FF FF 0B 01 FF FF 2D 01 0E 01 79 01 FF FF 31 01 FF FF 13 01 FF FF 7F 01 FF FF FF FF 18 01 FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 FF FF 21 01 FF FF 43 01 FF FF FF FF FF FF 27 01 28 01 FF FF FF FF 4B 01 4C 01 2D 01 FF FF 4F 01 FF FF 31 01 52 01 33 01 FF FF 35 01 FF FF 57 01 FF FF FF FF 3A 01 FF FF FF FF 3D 01 A8 01 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 79 01 FF FF FF FF FF FF 13 01 FF FF FF FF FF FF FF FF 18 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF 27 01 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 79 01 7A 01 31 01 FF FF 33 01 FF FF 35 01 FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 A8 01 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF FF FF FF FF FF FF 13 01 A8 01 FF FF FF FF FF FF 18 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF 27 01 28 01 FF FF FF FF FF FF FF FF 2D 01 78 01 79 01 FF FF 31 01 FF FF 33 01 FF FF FF FF FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF FF FF 4F 01 FF FF FF FF 52 01 09 01 FF FF 0B 01 FF FF FF FF 0E 01 FF FF FF FF FF FF FF FF 13 01 A8 01 FF FF FF FF FF FF 18 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 21 01 6C 01 FF FF FF FF FF FF FF FF 27 01 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 79 01 FF FF 31 01 FF FF 33 01 FF FF 35 01 FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 09 01 4F 01 0B 01 FF FF 52 01 0E 01 FF FF FF FF FF FF FF FF 13 01 FF FF FF FF FF FF FF FF 18 01 A8 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 21 01 FF FF FF FF FF FF FF FF FF FF 27 01 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF FF FF FF FF 31 01 FF FF 33 01 79 01 35 01 FF FF FF FF FF FF FF FF 3A 01 FF FF FF FF 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 FF FF FF FF 46 01 FF FF FF FF FF FF FF FF 4B 01 4C 01 FF FF 09 01 4F 01 0B 01 FF FF 52 01 0E 01 FF FF 10 01 FF FF FF FF 13 01 FF FF FF FF FF FF FF FF 18 01 FF FF FF FF FF FF FF FF FF FF A8 01 FF FF FF FF 21 01 FF FF FF FF 05 01 FF FF 07 01 FF FF 28 01 FF FF FF FF FF FF FF FF 2D 01 FF FF 2F 01 FF FF 31 01 FF FF FF FF 79 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 1D 01 3D 01 FF FF 3F 01 FF FF FF FF FF FF 43 01 44 01 FF FF FF FF FF FF FF FF 2A 01 FF FF 4B 01 4C 01 FF FF 2F 01 4F 01 FF FF FF FF 52 01 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 05 01 FF FF FF FF 42 01 FF FF A8 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF 1D 01 FF FF FF FF 79 01 FF FF FF FF 05 01 FF FF FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF 2E 01 2F 01 FF FF 6B 01 FF FF FF FF 34 01 FF FF 36 01 37 01 38 01 39 01 FF FF 1D 01 76 01 FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF FF FF FF FF 2A 01 FF FF FF FF FF FF FF FF 2F 01 4E 01 A8 01 FF FF 51 01 34 01 53 01 36 01 37 01 38 01 39 01 FF FF FF FF FF FF FF FF 3E 01 FF FF FF FF FF FF 42 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B 01 4E 01 FF FF FF FF 51 01 FF FF 53 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6B 01) */; internal static readonly __StaticArrayInitTypeSize=6 92A21616A89A4115BC889A9C086E629BDF6B0636A34253C6AB200472208C8E3F/* Not supported: data(3B 00 2C 00 20 00) */; internal static readonly __StaticArrayInitTypeSize=3626 BFA23A45FAA04ECF7D76D03C1160628AC079B765C70620A354F55D6207FC58EB/* Not supported: data(AC FF 00 00 73 FF 85 00 2D 00 5E 00 EB 09 00 00 B8 00 00 00 00 00 5E 00 2D 00 00 00 00 00 69 00 00 00 47 26 5E 00 00 00 8C FF 40 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 01 00 00 7F 01 00 00 00 00 00 00 C1 24 00 00 00 00 00 00 00 00 00 00 00 00 D6 00 00 00 00 00 66 02 00 00 00 00 7E 02 00 00 00 00 B8 00 DD 00 5E 00 00 00 56 01 00 00 4A 01 67 01 76 FF FE 52 69 FF 00 00 0E 01 B7 01 F2 26 00 00 0E 01 0E 01 0E 01 58 00 0E 01 0E 01 15 03 00 00 92 52 20 2C 0E 01 0E 01 00 00 C4 2C 00 00 9B 01 0E 01 89 FF 00 00 0E 01 CE 01 0E 01 00 00 8A 50 8A 50 C2 01 0E 01 0E 01 13 00 AB 36 21 4E 00 00 06 51 00 00 CD 4A 00 00 4C 38 D7 38 62 39 ED 39 78 3A 03 3B 8E 3B 19 3C 00 00 61 02 00 00 C5 49 5B 4B 00 00 51 01 00 00 1C FF 00 00 00 00 00 00 CF 02 DC 03 99 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C FF 00 00 C7 03 BC 01 C1 00 F7 01 2E 03 A5 02 D8 01 DD 01 0B 02 04 02 09 02 5E 02 00 00 00 00 00 00 00 00 00 00 00 00 28 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A8 02 DD 02 07 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7D 00 A8 00 DD 00 00 00 00 00 89 02 00 00 00 00 00 00 C5 49 C5 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D6 00 00 00 00 00 C2 02 B3 02 00 00 41 00 00 00 00 00 00 00 DD 00 01 56 D5 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4D 03 1C FF AF 4E 00 00 00 00 00 00 00 00 00 00 21 4E 64 FF 75 FF 6A 03 F8 02 00 FF DC 03 1C FF 00 00 00 00 C5 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 00 E2 00 FE 52 00 00 C5 49 21 4E 0D 03 00 00 00 00 1F 03 21 4E 21 4E D4 1E 38 02 6B FF 01 03 C5 49 FE 52 1C FF 00 00 21 4E AB 36 3D 4F 61 02 A5 03 32 03 00 00 3A 03 45 03 C5 49 21 4E 00 00 00 00 9E FF DC 02 F5 06 00 00 00 00 21 4E 9B 01 5B 4B 00 00 00 00 CE 01 21 4E E1 4A E2 02 D1 02 AB 03 1C FF 00 00 00 00 24 03 00 00 00 00 A8 02 00 00 99 01 B7 03 1C FF 79 50 21 4E 21 4E B7 01 00 00 A3 03 00 00 C5 49 C5 49 00 00 C1 37 1C FF 00 00 15 04 0D 04 00 00 00 00 9D 27 56 02 1D 01 3F 03 79 03 67 03 4F 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 07 00 00 00 00 00 00 00 00 D4 54 E2 02 A9 03 B1 03 1C FF 8C 03 BB 03 9F 03 21 4E 00 00 BB 02 00 00 22 01 00 00 00 00 0F FF 49 01 00 00 00 00 89 03 F8 2F EC 28 00 00 00 00 00 00 21 4E 21 4E 21 4E 21 4E 21 4E 21 4E 21 4E 21 4E 21 4E 21 4E 21 4E A4 3C 2F 3D BA 3D F5 31 F5 46 45 3E D0 3E 5B 3F E6 3F 71 40 FC 40 87 41 12 42 9D 42 28 43 B3 43 3E 44 C9 44 54 45 DF 45 8E 51 3F 4A 00 00 00 00 00 00 A8 02 00 00 00 00 00 00 00 00 00 00 8A 50 8A 50 00 00 00 00 1C FF 00 00 00 00 00 00 00 00 D9 00 D9 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 DD 00 D5 03 75 02 3A 02 D6 00 D6 00 00 00 37 03 9B 00 00 00 D6 00 D8 03 00 00 6C FF 01 56 00 00 00 00 00 00 00 00 7D FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 79 FF 1F 56 00 00 00 00 00 00 00 00 AE 03 00 00 00 00 E0 03 6D 03 00 00 DF 03 00 00 FA 03 E6 00 9B 01 00 00 0E 01 00 00 00 00 00 00 1C FF 68 2D 5F FF 00 00 F2 03 00 00 00 00 00 00 77 FF 92 00 00 00 F8 02 00 FF 00 00 00 00 D3 03 00 00 01 04 00 00 05 04 D1 03 00 00 00 00 85 03 00 00 00 33 87 03 9C 30 01 03 B1 49 00 00 D8 2A 00 00 00 00 00 00 00 00 1C FF 00 00 00 00 00 00 00 00 00 00 9A 00 9C 00 00 00 00 00 00 00 1D FF 9B 01 93 FF 00 00 00 00 CE 01 00 00 00 00 12 04 1B 04 00 00 BF 00 1C FF 00 00 CD 00 CE 01 00 00 00 00 BF 03 FE 03 06 04 00 00 00 00 21 4E 8A 04 BB 02 00 00 21 4E A1 04 4E 04 00 00 52 04 54 04 00 00 D4 54 00 00 00 00 00 00 73 00 AE 03 21 4E 00 00 21 4E 00 00 00 00 0B 00 9D 27 00 00 00 00 00 00 00 00 21 4E 00 00 00 00 00 00 3D 4F 3D 4F 5B 04 00 00 FE 52 73 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 E2 02 1C FF E1 4A 60 04 00 00 69 04 6A 46 21 4E 00 00 6C 04 21 4E 75 04 6A 53 00 00 EC 04 57 04 9D 27 00 00 00 00 44 04 00 00 AE 03 1C FF AF 4E 47 04 00 00 BB 02 AE 03 00 00 65 00 00 00 5B 4B 21 4E 7A 04 FA 04 00 00 00 00 42 01 60 FF 00 00 00 00 00 00 6D FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 51 06 51 00 00 C5 49 B4 02 00 00 00 00 00 00 00 00 1C FF 00 00 00 00 00 00 BC 01 00 00 BC 01 00 00 36 37 C1 00 00 00 C1 00 00 00 F7 01 00 00 F7 01 00 00 F7 01 00 00 F7 01 00 00 2E 03 00 00 2E 03 00 00 A5 02 00 00 D8 01 00 00 DD 01 00 00 0B 02 00 00 04 02 00 00 C5 49 00 00 E9 FF 00 00 81 04 00 00 9C 30 D8 04 1C FF DA 04 1C FF 9C 30 9C 30 7F 04 21 4E 00 00 00 00 D9 03 00 00 1C FF 00 00 5D 04 00 00 00 00 00 00 E1 4A 37 03 00 00 8C 04 88 04 00 00 00 00 0B 03 DD 00 AE 01 00 00 00 00 00 00 00 00 00 00 00 00 5D FF 8D 04 00 00 8E 04 8B 04 00 00 00 00 00 00 00 00 8F 04 86 32 66 04 00 00 C4 00 00 00 00 00 55 03 00 00 AF 4E 00 00 90 04 00 00 00 00 00 00 60 03 C9 00 96 04 00 00 95 04 98 04 99 04 00 00 00 00 21 4E 00 00 00 00 1C FF 00 00 00 00 9C 04 00 00 9A 04 00 00 E7 01 00 00 00 00 F2 26 00 00 F2 26 0C 2E 00 00 B6 47 00 00 00 00 00 00 20 36 B0 2E F8 01 B1 49 00 00 AD 00 71 FF 00 00 61 04 71 04 00 00 00 00 00 00 88 03 00 00 00 00 A3 04 9F 04 00 00 00 00 00 00 00 00 00 00 A4 04 00 00 6D FF 00 00 00 00 00 00 AA 04 00 00 FB 47 9B 01 00 00 9B 01 00 00 00 00 00 00 00 00 F2 26 00 00 00 00 F2 26 DD 02 E1 4A 00 00 00 00 BB 02 00 00 21 4E 00 00 00 00 00 00 21 4E C5 49 00 00 00 00 9B 01 A7 04 73 00 00 00 00 00 00 00 E9 4B 00 00 A9 04 7D 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FE 52 80 04 00 00 C5 49 00 00 00 00 1C FF D4 54 D1 04 00 00 00 00 00 00 21 4E 00 00 21 4E 00 00 1C FF 00 00 00 00 00 00 00 00 00 00 AE 03 96 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C FF 00 00 23 49 00 00 00 00 00 00 00 00 00 00 7C 2B 00 00 90 29 AE 04 00 00 00 00 B1 04 1C FF 00 00 00 00 82 04 00 00 34 2A F4 04 00 00 00 00 09 05 00 00 0B 05 00 00 00 00 00 00 59 04 00 00 B7 04 00 00 00 00 4C 02 00 00 00 00 00 00 37 03 00 00 00 00 91 04 00 00 9B 00 00 00 37 03 00 00 00 00 5D 04 BC 04 BE 04 93 04 C0 04 FF 04 66 04 00 00 00 00 BD 04 00 00 3C 05 00 00 00 00 F9 04 7E FF 54 2F 00 00 9C 30 00 00 77 4C C2 04 60 03 E1 4A C5 49 00 00 00 00 D5 01 3F 05 40 05 CE 00 C1 04 00 00 00 00 21 4E 00 00 21 4E 28 05 00 00 00 00 00 00 05 4D 00 00 22 03 05 4D 9D 03 00 00 00 00 00 00 00 00 72 32 00 00 45 05 A8 02 9C 30 D2 04 0C 2E D0 04 6D FF AE 04 00 00 0E 01 00 00 1C FF 00 00 00 00 00 00 80 FF 00 00 00 00 FE 03 00 00 00 00 00 00 00 00 CE 04 00 00 F1 04 00 00 00 00 00 00 00 00 00 00 00 00 A5 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 03 00 00 00 00 00 00 C5 49 00 00 00 00 00 00 1C FF CD 04 AE 04 00 00 06 51 21 05 2B 03 00 00 21 4E 00 00 06 51 00 00 00 00 00 00 9C 30 00 00 9C 30 00 00 7B FF 9C 30 00 00 00 00 00 00 79 02 00 00 00 00 00 00 00 00 D9 04 5D 04 00 00 00 00 40 31 00 00 00 00 00 00 00 00 C5 49 D7 04 40 48 00 00 66 04 00 00 66 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1C FF D4 04 C2 04 00 00 00 00 00 00 7A FF 84 FF DC 04 DE 04 00 00 00 00 00 00 00 00 00 00 D6 04 0C 2E AE 04 6D FF 21 4E 00 00 DB 04 F2 26 00 00 00 00 00 00 00 00 00 00 D3 04 00 00 00 00 E4 04 00 00 01 03 00 00 00 00 00 00 00 00 00 00 AE 04 DF 04 63 FF 21 4E E6 04 00 00 AE 04 E7 04 00 00 00 00 00 00 AC 04 00 00 73 00 00 00 B5 04 E0 04 00 00 00 00 00 00 16 52 00 00 1C FF EE 04 00 00 00 00 9C 30 02 05 9C 30 00 00 9C 30 00 00 00 00 21 4E 00 00 00 00 8B 04 00 00 5F 02 C9 03 00 00 00 00 00 00 00 00 2D 00 C5 49 00 00 00 00 00 00 00 00 EF 04 00 00 00 00 F2 04 EB 04 00 00 00 00 00 00 BF 02 00 00 ED 04 67 05 6F 05 00 00 00 00 AE 04 F7 04 AE 04 00 00 F2 26 2C FF 00 00 00 00 05 4D 00 00 00 00 F6 04 00 00 00 00 5B 4B 00 00 FC 04 8D FF 00 00 9C 25 00 00 FB 04 00 00 00 00 00 00 73 00 00 00 00 00 21 4E 90 29 1C FF 00 00 00 00 00 00 00 00 00 00 00 00 1A 05 00 00 6D 04 FD 04 00 00 03 05 00 00 00 00 40 31 5E 00 00 00 E6 00 00 00 5F 03 00 05 E6 00 00 05 00 00 77 4C 06 05 00 00 21 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F2 26 00 00 00 00 FB FF CF 04 00 00 00 00 9D 27 00 00 00 00 67 FF F2 26 00 00 08 05 00 00 00 00 9C 30 00 00 00 00 00 00 00 00 00 00 21 4E 00 00 00 00 DD 00 07 05 DD 00 C5 49 00 05 26 05 00 00 26 05 00 00 0C 05 26 05 00 00 00 00 21 4E 00 00 F2 26 21 4E 00 00 00 00 00 00 0A 05 00 00 0E 05 00 00 00 00 00 00 2D 05 9C 30 21 4E 00 00 DD 00 15 05 00 00 E5 04 5C 04 00 00 00 00 12 05 00 00 00 00 93 00 00 00 16 05 EA 04 00 00 26 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A1 03 9A 04 00 00 00 00 00 00 00 00 00 00 37 05 00 00 F8 FF 26 05 95 05 00 00 20 05 DD 00 00 00 C5 49 00 00 53 00 22 05 00 00 23 05 24 05 00 00 00 00 9D 27 9C 30 00 00 00 00 00 00 00 00 00 00 00 00 17 05 1E 05 00 00 00 00 B1 49 00 00 A8 55 B2 00 DD 00 00 00 27 05 39 05 9C 30 29 05 21 4E 00 00 00 00 25 05 00 00 2B 05 00 00 00 00 2A 05 00 00 00 00 00 00 1F 56 00 00 2C 05 B2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C FF 1F 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 05 DD 00 00 00 B2 00 00 00 1C FF 00 00 39 05 00 00 00 00 00 00 2E 05 A8 55 9D 27 D6 53 00 00 00 00 1A 02 00 00 00 00 00 00 00 00 20 54 00 00 00 00 33 05 00 00 00 00 00 00 00 00 0B 00 C5 49 C5 49 8E 00 C5 49 EE 01 CE 01 4E 05 00 00 E2 02 43 03 34 05 00 00 79 05 00 00 00 00 1E 05 00 00 00 00 00 00 00 00 00 00 21 4E 1E 05 00 00 00 00 92 FF 95 FF 00 00 C5 49 A3 FF 00 00 C5 49 00 00 0F 05 36 05 00 00 9F 01 00 00 AC 00 C6 07 00 00 3A 05 10 05 4F 00 00 00 1A 02 C1 24 00 00 E9 4B 32 05 00 00 1E 05 00 00 00 00 00 00 9F 01 00 00 41 05 11 05 3B 05 3D 05 00 00 43 05 18 05 46 05 E6 00 42 05 47 05 00 00 00 00 4A 05 49 05 62 05 00 00 AE 03 00 00 34 04 00 00 4B 05 48 05 00 00 00 00 F7 FF 00 00 4C 05 00 00 00 00 52 05 00 00 51 05 53 05 54 05 00 00 4F 05 00 00 E6 00 E6 00 00 00 00 00 E6 00 55 05 56 05 00 00 00 00 00 00 00 00 00 00 57 05 D2 00 00 00 59 05 E6 00 A1 05 5A 05 E6 00 00 00 1A 02 00 00 0C 2E 30 05 5C 05 4F 05 00 00 58 05 64 05 D5 00 68 05 00 00 00 00 E6 00 77 4C 4D 05 63 05 57 05 00 00 00 00 1F 56 00 00 DD 00 DD 00 00 00 50 05 65 05 59 05 00 00 6A 05 00 00 21 4E 6C 05 6B 05 5A 05 00 00 6E 05 E6 00 00 00 00 00 6E 00 00 00 5F 05 00 00 00 00 00 00 00 00 00 00 1F 56 00 00 D5 00 D5 00 00 00 70 05 00 00 F7 FF 00 00 00 00 87 FF 75 05 1F 56 00 00 1F 56 00 00 00 00 0C 2E 71 05 00 00 00 00 00 00 6D 05 52 05 00 00 00 00 00 00 78 05 00 00 9D 01 00 00 00 00 00 00 26 05 68 04 7D 05 00 00 00 00 FF 01 00 00 00 00 00 00 00 00 00 00 B3 05 F0 05 00 00 00 00 00 00 00 00 00 00 00 00 81 05 82 05 0C 2E 00 00 00 00 00 00 00 00 D5 00 00 00 00 00 24 02 24 02 00 00 26 05 00 00 00 00 00 00 02 01 02 01 7C 05 86 05 00 00 00 00 00 00 00 00 00 00 00 00 B1 49 B1 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 05 91 05 77 4C 00 00 00 00 00 00 00 00 92 05 00 00) */; internal static readonly __StaticArrayInitTypeSize=552 C070F17863285FBBB74F2D7991CAC991294C5A28C4C0798349F4E3C8EE130614/* Not supported: data(1C 00 00 00 43 00 00 00 4E 00 00 00 69 00 00 00 6C 00 00 00 6D 00 00 00 72 00 00 00 A2 00 00 00 A4 00 00 00 A8 00 00 00 A9 00 00 00 B7 00 00 00 B8 00 00 00 C5 00 00 00 DB 00 00 00 FB 00 00 00 FC 00 00 00 FD 00 00 00 16 01 00 00 1A 01 00 00 92 01 00 00 9E 01 00 00 A3 01 00 00 A4 01 00 00 AD 01 00 00 B4 01 00 00 B5 01 00 00 B8 01 00 00 CA 01 00 00 D0 01 00 00 D1 01 00 00 D3 01 00 00 D5 01 00 00 D8 01 00 00 D9 01 00 00 64 02 00 00 6A 02 00 00 72 02 00 00 74 02 00 00 82 02 00 00 89 02 00 00 8C 02 00 00 91 02 00 00 92 02 00 00 93 02 00 00 94 02 00 00 95 02 00 00 99 02 00 00 A0 02 00 00 A3 02 00 00 B5 02 00 00 D8 02 00 00 29 03 00 00 38 03 00 00 06 04 00 00 22 04 00 00 24 04 00 00 2A 04 00 00 F2 05 00 00 22 06 00 00 23 06 00 00 24 06 00 00 25 06 00 00 26 06 00 00 2C 06 00 00 2D 06 00 00 30 06 00 00 33 06 00 00 35 06 00 00 36 06 00 00 37 06 00 00 38 06 00 00 47 06 00 00 50 06 00 00 61 06 00 00 62 06 00 00 63 06 00 00 95 06 00 00 9A 06 00 00 9B 06 00 00 9C 06 00 00 9F 06 00 00 A0 06 00 00 A1 06 00 00 A3 06 00 00 A4 06 00 00 A5 06 00 00 A6 06 00 00 AD 06 00 00 AF 06 00 00 B5 06 00 00 B6 06 00 00 B8 06 00 00 C7 06 00 00 6D 07 00 00 A4 07 00 00 BD 07 00 00 CE 07 00 00 D2 07 00 00 E7 07 00 00 ED 07 00 00 B8 0B 00 00 B9 0B 00 00 BA 0B 00 00 BB 0B 00 00 BD 0B 00 00 BE 0B 00 00 BF 0B 00 00 C0 0B 00 00 C1 0B 00 00 C2 0B 00 00 C3 0B 00 00 C4 0B 00 00 C5 0B 00 00 C6 0B 00 00 C7 0B 00 00 C8 0B 00 00 C9 0B 00 00 CA 0B 00 00 CB 0B 00 00 CD 0B 00 00 CE 0B 00 00 CF 0B 00 00 D0 0B 00 00 D2 0B 00 00 D3 0B 00 00 AE 0F 00 00 B8 0F 00 00 B9 0F 00 00 BA 0F 00 00 7B 1B 00 00 A8 1B 00 00 A9 1B 00 00 AA 1B 00 00 B7 1B 00 00 49 1F 00 00 9E 1F 00 00 BB 1F 00 00) */; internal static readonly __StaticArrayInitTypeSize=16 C0769515B3FBF7F25668FDBE1A7CD8FAFF388702C65829AF7E43B30ED4C5E92C/* Not supported: data(60 A6 6E 40 CF 64 82 4C B6 F0 42 D4 81 72 A7 99) */; internal static readonly __StaticArrayInitTypeSize=1004 F9992FD71385F9AEE725C5A1D6F4ABD5605BDAA1E23A5F75077F2DABBA80400B/* Not supported: data(00 00 00 00 31 07 00 00 00 00 00 00 02 00 F3 FF 42 FF D0 FF D4 FF 00 00 5B 07 64 07 7C 01 00 00 00 00 56 FF 00 00 00 00 00 00 00 00 00 00 00 00 CA FB C2 FC 1B FF 01 FE 00 00 00 00 00 00 00 00 00 00 15 FF 00 00 00 00 00 00 E7 02 00 00 70 03 00 00 00 00 00 00 00 00 3F 02 43 02 EF FF 0B FF 00 00 DB FF 00 00 00 00 00 00 37 FD 62 03 84 01 00 00 A3 01 F5 FB E6 FC 10 FD 1A FD 32 FD 35 FD 52 FD 5E FD 00 00 00 00 25 FC 00 00 70 FC 00 00 6C 01 00 00 9C FA 00 00 1A 00 00 00 00 00 40 02 F0 FA 00 00 00 00 00 00 77 02 C2 00 00 00 00 00 00 00 E9 00 FD FA 00 00 DC FE C8 FE 51 04 00 00 00 00 00 00 17 FD B5 00 00 00 00 00 CF FD 00 00 00 00 F8 00 00 00 00 00 DC 00 00 00 00 00 4B FA 00 00 87 01 00 00 00 00 7C FD 2E FC 00 00 00 00 00 00 00 00 00 00 6E 01 F6 FF 9F FA 00 00 00 00 A2 01 00 00 4C 01 00 00 00 00 00 00 6F 03 76 03 77 03 48 04 D7 FE 00 00 00 00 9F FE 7E 03 6A 01 00 00 66 FB 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A4 01 00 00 00 00 00 00 19 FF 57 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E1 FD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C8 00 00 00 00 00 0B 01 00 00 11 01 15 01 BD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 02 00 00 00 00 00 00 00 00 AD FF 00 00 D5 04 C2 FE A1 FE 6D 06 00 00 58 01 00 00 9C 01 00 00 BD 03 00 00 69 06 FE 02 D0 FE F4 FE D2 FF A7 00 00 00 2D 04 7F 03 83 03 00 00 15 02 00 00 08 00 92 04 62 FE 00 00 00 00 68 FE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 69 FE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 FF 00 00 00 00 00 00 61 03 00 00 60 05 00 00 00 00 D5 FF 00 00 93 FE 00 00 DF FE 00 00 00 00 00 00 91 03 2F FC C1 FE 85 FF 63 04 00 00 ED 03 00 00 1B 05 0F 00 9E FE 94 04 00 00 00 00 07 03 7D 07 00 00 00 00 00 00 00 00 76 04 00 00 00 00 00 00 60 06 00 00 00 00 00 00 00 00 00 00 4B 08 27 04 2A 04 C8 FD 0D FC F2 02 00 00 00 00 F1 02 00 00 2A 03 2B 04 08 06 09 06 12 06 13 06 07 06 00 00 10 06 FF 03 00 00 00 00 BD FF 00 00 00 00 00 00 00 00 2E 04 76 05 BA FD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BC FE AA 02 00 00 EC FD 00 00 00 00 00 00 00 00 00 00 06 FE 00 00 53 02 00 00 E8 01 00 00 00 00 00 00 CE 02 B2 FD F1 FF A4 FE F2 FF 00 00 40 07 00 00 54 00 00 00 72 00 86 00 97 00 A5 00 A6 00 AA 00 AE 00 B0 00 B7 00 C7 00 00 00 F6 FC 00 00 00 00 00 00 00 00 00 00 C6 FC 00 00 0B FC 00 00 00 00 00 00 00 00 00 00 CC 02 9F FD 26 03 11 FC 00 00 52 03 F4 FD 00 00 00 00 00 00 00 00 00 00 00 00 D6 02 00 00 DA 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 81 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 06 00 00 A7 05 A3 02 00 00 00 00 00 00 00 00 B9 03 00 00 00 00 00 00 00 00 00 00 00 00 49 FF 00 00 00 00 00 00 00 00 00 00 19 06 F5 04 00 00 00 00 00 00 00 00 1A 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 02 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 0A 04 00 00 00 00 00 00 0C 04) */; internal static uint ComputeStringHash(string s) { uint num = default(uint); if (s != null) { num = 2166136261u; for (int i = 0; i < s.Length; i++) { num = (s[i] ^ num) * 16777619; } } return num; } } namespace Microsoft.CodeAnalysis { [Embedded] [CompilerGenerated] internal sealed class EmbeddedAttribute : System.Attribute { } } namespace System.Runtime.CompilerServices { [Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace Tomlet { internal static class Extensions { private static readonly HashSet IllegalChars = new HashSet { 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 127 }; internal static bool IsWhitespace(this int val) { if (!val.IsNewline()) { return char.IsWhiteSpace((char)val); } return false; } internal static bool IsEquals(this int val) { return val == 61; } internal static bool IsSingleQuote(this int val) { return val == 39; } internal static bool IsDoubleQuote(this int val) { return val == 34; } internal static bool IsHashSign(this int val) { return val == 35; } internal static bool IsNewline(this int val) { if (val != 13) { return val == 10; } return true; } internal static bool IsDigit(this int val) { return char.IsDigit((char)val); } internal static bool IsComma(this int val) { return val == 44; } internal static bool IsPeriod(this int val) { return val == 46; } internal static bool IsEndOfArrayChar(this int val) { return val == 93; } internal static bool IsEndOfInlineObjectChar(this int val) { return val == 125; } internal static bool IsHexDigit(this char c) { if (IsDigit(c)) { return true; } char c2 = char.ToUpperInvariant(c); if (c2 >= 'A') { return c2 <= 'F'; } return false; } internal static bool TryPeek(this TomletStringReader reader, out int nextChar) { nextChar = reader.Peek(); return nextChar != -1; } internal static int SkipWhitespace(this TomletStringReader reader) { return reader.ReadWhile((int c) => c.IsWhitespace()).Length; } internal static void SkipPotentialCarriageReturn(this TomletStringReader reader) { if (reader.TryPeek(out var nextChar) && nextChar == 13) { reader.Read(); } } internal static void SkipAnyComment(this TomletStringReader reader) { if (reader.TryPeek(out var nextChar) && nextChar.IsHashSign()) { reader.ReadWhile((int commentChar) => !commentChar.IsNewline()); } } internal static int SkipAnyNewlineOrWhitespace(this TomletStringReader reader) { return reader.ReadWhile((int c) => c.IsNewline() || c.IsWhitespace()).Count((char c) => c == '\n'); } internal static int SkipAnyCommentNewlineWhitespaceEtc(this TomletStringReader reader) { int num = 0; int nextChar; while (reader.TryPeek(out nextChar) && (nextChar.IsHashSign() || nextChar.IsNewline() || nextChar.IsWhitespace())) { if (nextChar.IsHashSign()) { reader.SkipAnyComment(); } num += reader.SkipAnyNewlineOrWhitespace(); } return num; } internal static int SkipAnyNewline(this TomletStringReader reader) { return reader.ReadWhile((int c) => c.IsNewline()).Count((char c) => c == '\n'); } internal static char[] ReadChars(this TomletStringReader reader, int count) { char[] array = new char[count]; reader.ReadBlock(array, 0, count); return array; } internal static string ReadWhile(this TomletStringReader reader, Predicate predicate) { StringBuilder stringBuilder = new StringBuilder(); int nextChar; while (reader.TryPeek(out nextChar) && predicate(nextChar)) { stringBuilder.Append((char)reader.Read()); } return stringBuilder.ToString(); } internal static bool ExpectAndConsume(this TomletStringReader reader, char expectWhat) { if (!reader.TryPeek(out var nextChar)) { return false; } if (nextChar == expectWhat) { reader.Read(); return true; } return false; } public static void Deconstruct(this KeyValuePair pair, out TKey one, out TValue two) { one = pair.Key; two = pair.Value; } public static bool IsNullOrWhiteSpace(this string s) { if (!string.IsNullOrEmpty(s)) { return string.IsNullOrEmpty(s.Trim()); } return true; } internal static T? GetCustomAttribute(this MemberInfo info) where T : System.Attribute { return (from a in info.GetCustomAttributes(inherit: false) where a is T select a).Cast().FirstOrDefault(); } internal static void EnsureLegalChar(this int c, int currentLineNum) { if (IllegalChars.Contains(c)) { throw new TomlUnescapedUnicodeControlCharException(currentLineNum, c); } } } internal static class TomlCompositeDeserializer { public static TomlSerializationMethods.Deserialize For(Type type) { TomlSerializationMethods.Deserialize deserialize; if (type.IsEnum) { TomlSerializationMethods.Deserialize stringDeserializer = TomlSerializationMethods.GetDeserializer(typeof(string)); deserialize = delegate(TomlValue value) { string text = (string)stringDeserializer(value); try { return System.Enum.Parse(type, text, ignoreCase: true); } catch (Exception) { throw new TomlEnumParseException(text, type); } }; } else { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); fields = fields.Where((FieldInfo f) => !f.IsNotSerialized).ToArray(); if (fields.Length == 0) { return delegate { try { return Activator.CreateInstance(type); } catch (MissingMethodException) { throw new TomlInstantiationException(type); } }; } deserialize = delegate(TomlValue value) { if (!(value is TomlTable tomlTable)) { throw new TomlTypeMismatchException(typeof(TomlTable), value.GetType(), type); } object obj; try { obj = Activator.CreateInstance(type); } catch (MissingMethodException) { throw new TomlInstantiationException(type); } FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { try { string text = fieldInfo.Name; Match match = Regex.Match(fieldInfo.Name, "<(.*)>k__BackingField"); if (match.Success) { text = match.Groups[1].Value; } string name1 = text; PropertyInfo? propertyInfo = type.GetProperties().FirstOrDefault((PropertyInfo p) => p.Name == name1); text = (((object)propertyInfo == null) ? null : propertyInfo.GetCustomAttribute()?.GetMappedString()) ?? text; if (tomlTable.ContainsKey(text)) { TomlValue value2 = tomlTable.GetValue(text); object value3 = TomlSerializationMethods.GetDeserializer(fieldInfo.FieldType)(value2); fieldInfo.SetValue(obj, value3); } } catch (TomlTypeMismatchException cause) { throw new TomlFieldTypeMismatchException(type, fieldInfo, cause); } } return obj; }; } TomlSerializationMethods.Register(type, null, deserialize); return deserialize; } } internal static class TomlCompositeSerializer { public static TomlSerializationMethods.Serialize For(Type type) { TomlSerializationMethods.Serialize serialize; if (type.IsEnum) { TomlSerializationMethods.Serialize stringSerializer = TomlSerializationMethods.GetSerializer(typeof(string)); serialize = (object? o) => stringSerializer(System.Enum.GetName(type, o) ?? throw new ArgumentException($"Tomlet: Cannot serialize {o} as an enum of type {type} because the enum type does not declare a name for that value")); } else { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var fieldAttribs = fields.ToDictionary((FieldInfo f) => f, (FieldInfo f) => new { inline = f.GetCustomAttribute(), preceding = f.GetCustomAttribute() }); PropertyInfo[] props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var propAttribs = props.ToDictionary((PropertyInfo p) => p, (PropertyInfo p) => new { inline = p.GetCustomAttribute(), preceding = p.GetCustomAttribute() }); bool isForcedNoInline = type.GetCustomAttribute() != null; fields = fields.Where((FieldInfo f) => !f.IsNotSerialized).ToArray(); if (fields.Length == 0) { return (object? _) => new TomlTable(); } serialize = delegate(object? instance) { if (instance == null) { throw new ArgumentNullException("instance", "Object being serialized is null. TOML does not support null values."); } TomlTable tomlTable = new TomlTable { ForceNoInline = isForcedNoInline }; FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object value = fieldInfo.GetValue(instance); if (value != null) { TomlValue tomlValue = TomlSerializationMethods.GetSerializer(fieldInfo.FieldType)(value); string name = fieldInfo.Name; var anon = fieldAttribs[fieldInfo]; Match match = Regex.Match(fieldInfo.Name, "<(.*)>k__BackingField"); if (match.Success) { name = match.Groups[1].Value; PropertyInfo key = props.First((PropertyInfo p) => p.Name == name); anon = propAttribs[key]; } string name2 = name; PropertyInfo? propertyInfo = type.GetProperties().FirstOrDefault((PropertyInfo p) => p.Name == name2); name = (((object)propertyInfo == null) ? null : propertyInfo.GetCustomAttribute()?.GetMappedString()) ?? name; if (!tomlTable.ContainsKey(name)) { tomlValue.Comments.InlineComment = anon.inline?.Comment; tomlValue.Comments.PrecedingComment = anon.preceding?.Comment; tomlTable.PutValue(name, tomlValue); } } } return tomlTable; }; } TomlSerializationMethods.Register(type, serialize, null); return serialize; } } internal static class TomlDateTimeUtils { private static readonly Regex DateTimeRegex = new Regex("^(?:(\\d+)-(0[1-9]|1[012])-(0[1-9]|[12]\\d|3[01]))?([\\sTt])?(?:([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d|60)(\\.\\d+)?((?:[Zz])|(?:[\\+|\\-](?:[01]\\d|2[0-3])(?::[0-6][0-9])?(?::[0-6][0-9])?))?)?$", RegexOptions.Compiled); internal static TomlValue? ParseDateString(string input, int lineNumber) { Match match = DateTimeRegex.Match(input); bool flag = !match.Groups[1].Value.IsNullOrWhiteSpace(); bool flag2 = !string.IsNullOrEmpty(match.Groups[4].Value); bool flag3 = !match.Groups[5].Value.IsNullOrWhiteSpace(); bool flag4 = !match.Groups[9].Value.IsNullOrWhiteSpace(); if (flag && flag3 && !flag2) { throw new TomlDateTimeMissingSeparatorException(lineNumber); } if (flag2 && (!flag3 || !flag)) { throw new TomlDateTimeUnnecessarySeparatorException(lineNumber); } if (flag4 && (!flag3 || !flag)) { throw new TimeOffsetOnTomlDateOrTimeException(lineNumber, match.Groups[9].Value); } if (!flag) { return TomlLocalTime.Parse(input); } if (!flag3) { return TomlLocalDate.Parse(input); } if (!flag4) { return TomlLocalDateTime.Parse(input); } return TomlOffsetDateTime.Parse(input); } } internal static class TomletMain { [NoCoverage] public static void RegisterMapper(TomlSerializationMethods.Serialize? serializer, TomlSerializationMethods.Deserialize? deserializer) { TomlSerializationMethods.Register(serializer, deserializer); } public static T To(string tomlString) { return To(new TomlParser().Parse(tomlString)); } public static T To(TomlValue value) { return (T)To(typeof(T), value); } public static object To(Type what, TomlValue value) { return TomlSerializationMethods.GetDeserializer(what)(value); } public static TomlValue ValueFrom(T t) { if (t == null) { throw new ArgumentNullException("t"); } return ValueFrom(t.GetType(), t); } public static TomlValue ValueFrom(Type type, object t) { return TomlSerializationMethods.GetSerializer(type)(t); } public static TomlDocument DocumentFrom(T t) { if (t == null) { throw new ArgumentNullException("t"); } return DocumentFrom(t.GetType(), t); } public static TomlDocument DocumentFrom(Type type, object t) { TomlValue tomlValue = ValueFrom(type, t); if (!(tomlValue is TomlDocument result)) { if (tomlValue is TomlTable tomlTable) { return new TomlDocument(tomlTable); } throw new TomlPrimitiveToDocumentException(type); } return result; } public static string TomlStringFrom(T t) { return DocumentFrom(t).SerializedValue; } public static string TomlStringFrom(Type type, object t) { return DocumentFrom(type, t).SerializedValue; } } internal class TomletStringReader : IDisposable { private string? _s; private int _pos; private int _length; public TomletStringReader(string s) { _s = s; _length = s.Length; } public void Backtrack(int amount) { if (_pos < amount) { throw new Exception("Cannot backtrack past the beginning of the string"); } _pos -= amount; } public void Dispose() { _s = null; _pos = 0; _length = 0; } public int Peek() { if (_pos != _length) { return _s[_pos]; } return -1; } public int Read() { if (_pos != _length) { return _s[_pos++]; } return -1; } public int Read(char[] buffer, int index, int count) { int num = _length - _pos; if (num <= 0) { return num; } if (num > count) { num = count; } _s.CopyTo(_pos, buffer, index, num); _pos += num; return num; } public int ReadBlock(char[] buffer, int index, int count) { int num = 0; int num2; do { num += (num2 = Read(buffer, index + num, count - num)); } while (num2 > 0 && num < count); return num; } } internal static class TomlKeyUtils { internal static void GetTopLevelAndSubKeys(string key, out string ourKeyName, out string restOfKey) { bool flag = (key.StartsWith("\"") && key.EndsWith("\"")) || (key.StartsWith("'") && key.EndsWith("'")); bool flag2 = !flag && (key.StartsWith("\"") || key.StartsWith("'")); if (!key.Contains(".") || flag) { ourKeyName = key; restOfKey = ""; return; } if (!flag2) { string[] array = key.Split(new char[1] { '.' }); ourKeyName = array[0]; } else { ourKeyName = key; string text = ourKeyName.Substring(1); if (ourKeyName.Contains("\"")) { ourKeyName = ourKeyName.Substring(0, 2 + text.IndexOf("\"", StringComparison.Ordinal)); } else { ourKeyName = ourKeyName.Substring(0, 2 + text.IndexOf("'", StringComparison.Ordinal)); } } restOfKey = key.Substring(ourKeyName.Length + 1); ourKeyName = ourKeyName.Trim(); } } internal static class TomlNumberStyle { internal static NumberStyles FloatingPoint = NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent; internal static NumberStyles Integer = NumberStyles.AllowLeadingSign | NumberStyles.AllowThousands; } internal static class TomlNumberUtils { public static long? GetLongValue(string input) { bool flag = input.StartsWith("0o"); bool flag2 = input.StartsWith("0x"); bool flag3 = input.StartsWith("0b"); if (flag3 || flag2 || flag) { input = input.Substring(2); } if (input.Contains("__") || input.Any((char c) => c != '_' && c != '-' && c != '+' && !char.IsDigit(c) && (c < 'a' || c > 'f'))) { return null; } if (input.First() == '_') { return null; } if (input.Last() == '_') { return null; } input = input.Replace("_", ""); try { if (flag3) { return System.Convert.ToInt64(input, 2); } if (flag) { return System.Convert.ToInt64(input, 8); } if (flag2) { return System.Convert.ToInt64(input, 16); } return System.Convert.ToInt64(input, 10); } catch (Exception) { return null; } } public static double? GetDoubleValue(string input) { string text = input.Substring(1); if (input == "nan" || input == "inf" || text == "nan" || text == "inf") { if (input == "nan" || text == "nan") { return double.NaN; } if (input == "inf") { return double.PositiveInfinity; } if (text == "inf") { return input.StartsWith("-") ? double.NegativeInfinity : double.PositiveInfinity; } } if (input.Contains("__") || input.Any((char c) => c != '_' && c != '-' && c != '+' && c != 'e' && c != '.' && !char.IsDigit(c))) { return null; } if (input.First() == '_') { return null; } if (input.Last() == '_') { return null; } input = input.Replace("_", ""); if (input.Contains("e")) { string[] array = input.Split(new char[1] { 'e' }); if (array.Length != 2) { return null; } if (array[0].EndsWith(".")) { return null; } } if (double.TryParse(input, TomlNumberStyle.FloatingPoint, CultureInfo.InvariantCulture, out var result)) { return result; } return null; } } internal class TomlParser { private static readonly char[] TrueChars = new char[4] { 't', 'r', 'u', 'e' }; private static readonly char[] FalseChars = new char[5] { 'f', 'a', 'l', 's', 'e' }; private int _lineNumber = 1; private string[] _tableNames = new string[0]; private TomlTable? _currentTable; [NoCoverage] public static TomlDocument ParseFile(string filePath) { string input = File.ReadAllText(filePath); return new TomlParser().Parse(input); } public TomlDocument Parse(string input) { try { TomlDocument tomlDocument = new TomlDocument(); using TomletStringReader tomletStringReader = new TomletStringReader(input); string text = null; int nextChar; while (tomletStringReader.TryPeek(out nextChar)) { _lineNumber += tomletStringReader.SkipAnyNewlineOrWhitespace(); text = ReadAnyPotentialMultilineComment(tomletStringReader); if (!tomletStringReader.TryPeek(out var nextChar2)) { break; } if (nextChar2 == 91) { tomletStringReader.Read(); if (!tomletStringReader.TryPeek(out var nextChar3)) { throw new TomlEndOfFileException(_lineNumber); } TomlValue tomlValue = ((nextChar3 == 91) ? ((TomlValue)ReadTableArrayStatement(tomletStringReader, tomlDocument)) : ((TomlValue)ReadTableStatement(tomletStringReader, tomlDocument))); tomlValue.Comments.PrecedingComment = text; continue; } ReadKeyValuePair(tomletStringReader, out string key, out TomlValue value); value.Comments.PrecedingComment = text; text = null; if (_currentTable != null) { _currentTable.ParserPutValue(key, value, _lineNumber); } else { tomlDocument.ParserPutValue(key, value, _lineNumber); } tomletStringReader.SkipWhitespace(); tomletStringReader.SkipPotentialCarriageReturn(); if (!tomletStringReader.ExpectAndConsume('\n') && tomletStringReader.TryPeek(out var nextChar4)) { throw new TomlMissingNewlineException(_lineNumber, (char)nextChar4); } _lineNumber++; } tomlDocument.TrailingComment = text; return tomlDocument; } catch (Exception ex) when (!(ex is TomlException)) { throw new TomlInternalException(_lineNumber, ex); } } private void ReadKeyValuePair(TomletStringReader reader, out string key, out TomlValue value) { key = ReadKey(reader); reader.SkipWhitespace(); if (!reader.ExpectAndConsume('=')) { if (reader.TryPeek(out var nextChar)) { throw new TomlMissingEqualsException(_lineNumber, (char)nextChar); } throw new TomlEndOfFileException(_lineNumber); } reader.SkipWhitespace(); value = ReadValue(reader); } private string ReadKey(TomletStringReader reader) { reader.SkipWhitespace(); if (!reader.TryPeek(out var nextChar)) { return ""; } if (nextChar.IsEquals()) { throw new NoTomlKeyException(_lineNumber); } reader.SkipWhitespace(); string text; if (nextChar.IsDoubleQuote()) { reader.Read(); if (reader.TryPeek(out var nextChar2) && nextChar2.IsDoubleQuote()) { reader.Read(); if (reader.TryPeek(out var nextChar3) && nextChar3.IsDoubleQuote()) { throw new TomlTripleQuotedKeyException(_lineNumber); } return string.Empty; } text = "\"" + ReadSingleLineBasicString(reader, consumeClosingQuote: false).StringValue + "\""; if (!reader.ExpectAndConsume('"')) { throw new UnterminatedTomlKeyException(_lineNumber); } } else if (nextChar.IsSingleQuote()) { reader.Read(); text = "'" + ReadSingleLineLiteralString(reader, consumeClosingQuote: false).StringValue + "'"; if (!reader.ExpectAndConsume('\'')) { throw new UnterminatedTomlKeyException(_lineNumber); } } else { text = ReadKeyInternal(reader, (int keyChar) => keyChar.IsEquals() || keyChar.IsHashSign()); } return text.Replace("\\n", "\n").Replace("\\t", "\t"); } private string ReadKeyInternal(TomletStringReader reader, Func charSignalsEndOfKey) { List list = new List(); int nextChar; while (reader.TryPeek(out nextChar)) { if (charSignalsEndOfKey(nextChar)) { return string.Join(".", list.ToArray()); } if (nextChar.IsPeriod()) { throw new TomlDoubleDottedKeyException(_lineNumber); } StringBuilder stringBuilder = new StringBuilder(); while (reader.TryPeek(out nextChar)) { nextChar.EnsureLegalChar(_lineNumber); int num = reader.SkipWhitespace(); reader.TryPeek(out var nextChar2); if (nextChar2.IsPeriod()) { list.Add(stringBuilder.ToString()); reader.ExpectAndConsume('.'); reader.SkipWhitespace(); break; } if (num > 0 && charSignalsEndOfKey(nextChar2)) { list.Add(stringBuilder.ToString()); break; } reader.Backtrack(num); if (charSignalsEndOfKey(nextChar)) { list.Add(stringBuilder.ToString()); break; } if (num > 0) { throw new TomlWhitespaceInKeyException(_lineNumber); } stringBuilder.Append((char)reader.Read()); } } throw new TomlEndOfFileException(_lineNumber); } private TomlValue ReadValue(TomletStringReader reader) { if (!reader.TryPeek(out var nextChar)) { throw new TomlEndOfFileException(_lineNumber); } TomlValue tomlValue; switch (nextChar) { case 91: tomlValue = ReadArray(reader); break; case 123: tomlValue = ReadInlineTable(reader); break; case 34: case 39: { int num = reader.Read(); if (reader.Peek() != num) { tomlValue = (num.IsSingleQuote() ? ReadSingleLineLiteralString(reader) : ReadSingleLineBasicString(reader)); break; } reader.Read(); int num2 = reader.Peek(); if (num2 == num) { reader.Read(); tomlValue = (num.IsSingleQuote() ? ReadMultiLineLiteralString(reader) : ReadMultiLineBasicString(reader)); break; } if (num2.IsWhitespace() || num2.IsNewline() || num2.IsHashSign() || num2.IsComma() || num2.IsEndOfArrayChar() || num2 == -1) { tomlValue = TomlString.Empty; break; } throw new TomlStringException(_lineNumber); } case 43: case 45: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 105: case 110: { string text = reader.ReadWhile((int valueChar) => !valueChar.IsEquals() && !valueChar.IsNewline() && !valueChar.IsHashSign() && !valueChar.IsComma() && !valueChar.IsEndOfArrayChar() && !valueChar.IsEndOfInlineObjectChar()).ToLowerInvariant().Trim(); tomlValue = ((!Enumerable.Contains(text, ':') && !Enumerable.Contains(text, 't') && !Enumerable.Contains(text, ' ') && !Enumerable.Contains(text, 'z')) ? ((!Enumerable.Contains(text, '.') && (!Enumerable.Contains(text, 'e') || text.StartsWith("0x")) && !Enumerable.Contains(text, 'n') && !Enumerable.Contains(text, 'i')) ? (TomlLong.Parse(text) ?? TomlDateTimeUtils.ParseDateString(text, _lineNumber) ?? throw new InvalidTomlNumberException(_lineNumber, text)) : (TomlDouble.Parse(text) ?? TomlDateTimeUtils.ParseDateString(text, _lineNumber) ?? throw new InvalidTomlNumberException(_lineNumber, text))) : (TomlDateTimeUtils.ParseDateString(text, _lineNumber) ?? throw new InvalidTomlDateTimeException(_lineNumber, text))); break; } case 116: { char[] second2 = reader.ReadChars(4); if (!TrueChars.SequenceEqual(second2)) { throw new TomlInvalidValueException(_lineNumber, (char)nextChar); } tomlValue = TomlBoolean.True; break; } case 102: { char[] second = reader.ReadChars(5); if (!FalseChars.SequenceEqual(second)) { throw new TomlInvalidValueException(_lineNumber, (char)nextChar); } tomlValue = TomlBoolean.False; break; } default: throw new TomlInvalidValueException(_lineNumber, (char)nextChar); } reader.SkipWhitespace(); tomlValue.Comments.InlineComment = ReadAnyPotentialInlineComment(reader); return tomlValue; } private TomlValue ReadSingleLineBasicString(TomletStringReader reader, bool consumeClosingQuote = true) { StringBuilder stringBuilder = new StringBuilder(); bool flag = false; bool fourDigitUnicodeMode = false; bool eightDigitUnicodeMode = false; StringBuilder stringBuilder2 = new StringBuilder(); int nextChar; while (reader.TryPeek(out nextChar)) { nextChar.EnsureLegalChar(_lineNumber); if (nextChar == 34 && !flag) { break; } reader.Read(); if (nextChar == 92 && !flag) { flag = true; } else if (flag) { flag = false; char? c = HandleEscapedChar(nextChar, out fourDigitUnicodeMode, out eightDigitUnicodeMode); if (c.HasValue) { stringBuilder.Append(c.Value); } } else if (fourDigitUnicodeMode || eightDigitUnicodeMode) { stringBuilder2.Append((char)nextChar); if ((fourDigitUnicodeMode && stringBuilder2.Length == 4) || (eightDigitUnicodeMode && stringBuilder2.Length == 8)) { string unicodeString = stringBuilder2.ToString(); stringBuilder.Append(DecipherUnicodeEscapeSequence(unicodeString, fourDigitUnicodeMode)); fourDigitUnicodeMode = false; eightDigitUnicodeMode = false; stringBuilder2 = new StringBuilder(); } } else { if (nextChar.IsNewline()) { throw new UnterminatedTomlStringException(_lineNumber); } stringBuilder.Append((char)nextChar); } } if (consumeClosingQuote && !reader.ExpectAndConsume('"')) { throw new UnterminatedTomlStringException(_lineNumber); } return new TomlString(stringBuilder.ToString()); } private string DecipherUnicodeEscapeSequence(string unicodeString, bool fourDigitMode) { if (unicodeString.Any((char c) => !c.IsHexDigit())) { throw new InvalidTomlEscapeException(_lineNumber, $"\\{(fourDigitMode ? 'u' : 'U')}{unicodeString}"); } if (fourDigitMode) { return ((char)short.Parse(unicodeString, NumberStyles.HexNumber)).ToString(); } return char.ConvertFromUtf32(int.Parse(unicodeString, NumberStyles.HexNumber)); } private char? HandleEscapedChar(int escapedChar, out bool fourDigitUnicodeMode, out bool eightDigitUnicodeMode, bool allowNewline = false) { eightDigitUnicodeMode = false; fourDigitUnicodeMode = false; char value; switch (escapedChar) { case 98: value = '\b'; break; case 116: value = '\t'; break; case 110: value = '\n'; break; case 102: value = '\f'; break; case 114: value = '\r'; break; case 34: value = '"'; break; case 92: value = '\\'; break; case 117: fourDigitUnicodeMode = true; return null; case 85: eightDigitUnicodeMode = true; return null; default: if (allowNewline && escapedChar.IsNewline()) { return null; } throw new InvalidTomlEscapeException(_lineNumber, $"\\{escapedChar}"); } return value; } private TomlValue ReadSingleLineLiteralString(TomletStringReader reader, bool consumeClosingQuote = true) { string text = reader.ReadWhile((int valueChar) => !valueChar.IsSingleQuote() && !valueChar.IsNewline()); foreach (int item in ((IEnumerable)text).Select((Func)((char c) => c))) { item.EnsureLegalChar(_lineNumber); } if (!reader.TryPeek(out var nextChar)) { throw new TomlEndOfFileException(_lineNumber); } if (!nextChar.IsSingleQuote()) { throw new UnterminatedTomlStringException(_lineNumber); } if (consumeClosingQuote) { reader.Read(); } return new TomlString(text); } private TomlValue ReadMultiLineLiteralString(TomletStringReader reader) { StringBuilder stringBuilder = new StringBuilder(); _lineNumber += reader.SkipAnyNewline(); int nextChar; while (reader.TryPeek(out nextChar)) { int num = reader.Read(); num.EnsureLegalChar(_lineNumber); if (!num.IsSingleQuote()) { stringBuilder.Append((char)num); if (num == 10) { _lineNumber++; } continue; } if (!reader.TryPeek(out var nextChar2) || !nextChar2.IsSingleQuote()) { stringBuilder.Append('\''); continue; } reader.Read(); if (!reader.TryPeek(out var nextChar3) || !nextChar3.IsSingleQuote()) { stringBuilder.Append('\''); stringBuilder.Append('\''); continue; } reader.Read(); if (!reader.TryPeek(out var nextChar4) || !nextChar4.IsSingleQuote()) { break; } reader.Read(); stringBuilder.Append('\''); if (!reader.TryPeek(out var nextChar5) || !nextChar5.IsSingleQuote()) { break; } reader.Read(); stringBuilder.Append('\''); if (!reader.TryPeek(out var nextChar6) || !nextChar6.IsSingleQuote()) { break; } throw new TripleQuoteInTomlMultilineLiteralException(_lineNumber); } return new TomlString(stringBuilder.ToString()); } private TomlValue ReadMultiLineBasicString(TomletStringReader reader) { StringBuilder stringBuilder = new StringBuilder(); bool flag = false; bool fourDigitUnicodeMode = false; bool eightDigitUnicodeMode = false; StringBuilder stringBuilder2 = new StringBuilder(); _lineNumber += reader.SkipAnyNewline(); int nextChar; while (reader.TryPeek(out nextChar)) { int num = reader.Read(); num.EnsureLegalChar(_lineNumber); if (num == 92 && !flag) { flag = true; continue; } if (flag) { flag = false; char? c = HandleEscapedChar(num, out fourDigitUnicodeMode, out eightDigitUnicodeMode, allowNewline: true); if (c.HasValue) { stringBuilder.Append(c.Value); } else if (num.IsNewline()) { if (num == 13 && !reader.ExpectAndConsume('\n')) { throw new Exception($"Found a CR without an LF on line {_lineNumber}"); } _lineNumber++; reader.SkipAnyNewlineOrWhitespace(); } continue; } if (fourDigitUnicodeMode || eightDigitUnicodeMode) { stringBuilder2.Append((char)num); if ((fourDigitUnicodeMode && stringBuilder2.Length == 4) || (eightDigitUnicodeMode && stringBuilder2.Length == 8)) { string unicodeString = stringBuilder2.ToString(); stringBuilder.Append(DecipherUnicodeEscapeSequence(unicodeString, fourDigitUnicodeMode)); fourDigitUnicodeMode = false; eightDigitUnicodeMode = false; stringBuilder2 = new StringBuilder(); } continue; } if (!num.IsDoubleQuote()) { if (num == 10) { _lineNumber++; } stringBuilder.Append((char)num); continue; } if (!reader.TryPeek(out var nextChar2) || !nextChar2.IsDoubleQuote()) { stringBuilder.Append('"'); continue; } reader.Read(); if (!reader.TryPeek(out var nextChar3) || !nextChar3.IsDoubleQuote()) { stringBuilder.Append('"'); stringBuilder.Append('"'); continue; } reader.Read(); if (!reader.TryPeek(out var nextChar4) || !nextChar4.IsDoubleQuote()) { break; } reader.Read(); stringBuilder.Append('"'); if (!reader.TryPeek(out var nextChar5) || !nextChar5.IsDoubleQuote()) { break; } reader.Read(); stringBuilder.Append('"'); if (!reader.TryPeek(out var nextChar6) || !nextChar6.IsDoubleQuote()) { break; } throw new TripleQuoteInTomlMultilineSimpleStringException(_lineNumber); } return new TomlString(stringBuilder.ToString()); } private TomlArray ReadArray(TomletStringReader reader) { if (!reader.ExpectAndConsume('[')) { throw new ArgumentException("Internal Tomlet Bug: ReadArray called and first char is not a ["); } _lineNumber += reader.SkipAnyCommentNewlineWhitespaceEtc(); TomlArray tomlArray = new TomlArray(); int nextChar; while (reader.TryPeek(out nextChar)) { _lineNumber += reader.SkipAnyCommentNewlineWhitespaceEtc(); if (!reader.TryPeek(out var nextChar2)) { throw new TomlEndOfFileException(_lineNumber); } if (nextChar2.IsEndOfArrayChar()) { break; } tomlArray.ArrayValues.Add(ReadValue(reader)); _lineNumber += reader.SkipAnyNewlineOrWhitespace(); if (!reader.TryPeek(out var nextChar3)) { throw new TomlEndOfFileException(_lineNumber); } if (nextChar3.IsEndOfArrayChar()) { break; } if (!nextChar3.IsComma()) { throw new TomlArraySyntaxException(_lineNumber, (char)nextChar3); } reader.ExpectAndConsume(','); } reader.ExpectAndConsume(']'); return tomlArray; } private TomlTable ReadInlineTable(TomletStringReader reader) { if (!reader.ExpectAndConsume('{')) { throw new ArgumentException("Internal Tomlet Bug: ReadInlineTable called and first char is not a {"); } _lineNumber += reader.SkipAnyCommentNewlineWhitespaceEtc(); TomlTable tomlTable = new TomlTable { Defined = true }; int nextChar; while (reader.TryPeek(out nextChar)) { reader.SkipWhitespace(); if (!reader.TryPeek(out var nextChar2)) { throw new TomlEndOfFileException(_lineNumber); } if (nextChar2.IsEndOfInlineObjectChar()) { break; } if (nextChar2.IsNewline()) { throw new NewLineInTomlInlineTableException(_lineNumber); } try { ReadKeyValuePair(reader, out string key, out TomlValue value); tomlTable.ParserPutValue(key, value, _lineNumber); } catch (TomlException ex) when (ex is TomlMissingEqualsException || ex is NoTomlKeyException || ex is TomlWhitespaceInKeyException) { throw new InvalidTomlInlineTableException(_lineNumber, ex); } if (!reader.TryPeek(out var nextChar3)) { throw new TomlEndOfFileException(_lineNumber); } if (!reader.ExpectAndConsume(',')) { reader.SkipWhitespace(); if (!reader.TryPeek(out nextChar3)) { throw new TomlEndOfFileException(_lineNumber); } if (nextChar3.IsEndOfInlineObjectChar()) { break; } throw new TomlInlineTableSeparatorException(_lineNumber, (char)nextChar3); } } reader.ExpectAndConsume('}'); tomlTable.Locked = true; return tomlTable; } private TomlTable ReadTableStatement(TomletStringReader reader, TomlDocument document) { string text = reader.ReadWhile((int c) => !c.IsEndOfArrayChar() && !c.IsNewline()); TomlTable parent = document; string relativeName = text; FindParentAndRelativeKey(ref parent, ref relativeName); TomlTable tomlTable; try { if (parent.ContainsKey(relativeName)) { try { tomlTable = (TomlTable)parent.GetValue(relativeName); if (tomlTable.Defined) { throw new TomlTableRedefinitionException(_lineNumber, text); } } catch (InvalidCastException) { throw new TomlKeyRedefinitionException(_lineNumber, text); } } else { tomlTable = new TomlTable { Defined = true }; parent.ParserPutValue(relativeName, tomlTable, _lineNumber); } } catch (TomlContainsDottedKeyNonTableException ex2) { throw new TomlDottedKeyParserException(_lineNumber, ex2.Key); } if (!reader.TryPeek(out var _)) { throw new TomlEndOfFileException(_lineNumber); } if (!reader.ExpectAndConsume(']')) { throw new UnterminatedTomlTableNameException(_lineNumber); } reader.SkipWhitespace(); tomlTable.Comments.InlineComment = ReadAnyPotentialInlineComment(reader); reader.SkipPotentialCarriageReturn(); if (!reader.TryPeek(out var nextChar2)) { throw new TomlEndOfFileException(_lineNumber); } if (!nextChar2.IsNewline()) { throw new TomlMissingNewlineException(_lineNumber, (char)nextChar2); } _currentTable = tomlTable; _tableNames = text.Split(new char[1] { '.' }); return tomlTable; } private TomlArray ReadTableArrayStatement(TomletStringReader reader, TomlDocument document) { if (!reader.ExpectAndConsume('[')) { throw new ArgumentException("Internal Tomlet Bug: ReadTableArrayStatement called and first char is not a ["); } string text = reader.ReadWhile((int c) => !c.IsEndOfArrayChar() && !c.IsNewline()); if (!reader.ExpectAndConsume(']') || !reader.ExpectAndConsume(']')) { throw new UnterminatedTomlTableArrayException(_lineNumber); } TomlTable parent = document; string relativeName = text; FindParentAndRelativeKey(ref parent, ref relativeName); if (parent == document && Enumerable.Contains(relativeName, '.')) { throw new MissingIntermediateInTomlTableArraySpecException(_lineNumber, relativeName); } TomlArray tomlArray2; if (parent.ContainsKey(relativeName)) { if (!(parent.GetValue(relativeName) is TomlArray tomlArray)) { throw new TomlTableArrayAlreadyExistsAsNonArrayException(_lineNumber, text); } tomlArray2 = tomlArray; if (!tomlArray2.IsLockedToBeTableArray) { throw new TomlNonTableArrayUsedAsTableArrayException(_lineNumber, text); } } else { tomlArray2 = new TomlArray { IsLockedToBeTableArray = true }; parent.ParserPutValue(relativeName, tomlArray2, _lineNumber); } _currentTable = new TomlTable { Defined = true }; tomlArray2.ArrayValues.Add(_currentTable); _tableNames = text.Split(new char[1] { '.' }); return tomlArray2; } private void FindParentAndRelativeKey(ref TomlTable parent, ref string relativeName) { for (int i = 0; i < _tableNames.Length; i++) { string text = _tableNames[i]; if (!relativeName.StartsWith(text + ".")) { break; } TomlValue value = parent.GetValue(text); if (value is TomlTable tomlTable) { parent = tomlTable; } else { if (!(value is TomlArray source)) { throw new TomlTypeMismatchException(typeof(TomlArray), value.GetType(), typeof(TomlArray)); } parent = (TomlTable)source.Last(); } relativeName = relativeName.Substring(text.Length + 1); } } private string? ReadAnyPotentialInlineComment(TomletStringReader reader) { if (!reader.ExpectAndConsume('#')) { return null; } string text = reader.ReadWhile((int c) => !c.IsNewline()).Trim(); if (text.Length < 1) { return null; } if (text[0] == ' ') { text = text.Substring(1); } foreach (int item in ((IEnumerable)text).Select((Func)((char c) => c))) { item.EnsureLegalChar(_lineNumber); } return text; } private string? ReadAnyPotentialMultilineComment(TomletStringReader reader) { StringBuilder stringBuilder = new StringBuilder(); while (reader.ExpectAndConsume('#')) { string text = reader.ReadWhile((int c) => !c.IsNewline()); if (text[0] == ' ') { text = text.Substring(1); } foreach (int item in ((IEnumerable)text).Select((Func)((char c) => c))) { item.EnsureLegalChar(_lineNumber); } stringBuilder.Append(text); _lineNumber += reader.SkipAnyNewlineOrWhitespace(); } if (stringBuilder.Length == 0) { return null; } return stringBuilder.ToString(); } } internal static class TomlSerializationMethods { public delegate T Deserialize(TomlValue value); public delegate TomlValue Serialize(T? t); private static readonly Dictionary Deserializers; private static readonly Dictionary Serializers; [NoCoverage] static TomlSerializationMethods() { Deserializers = new Dictionary(); Serializers = new Dictionary(); Register((string? s) => new TomlString(s), (TomlValue value) => (value as TomlString)?.Value ?? value.StringValue); Register(TomlBoolean.ValueOf, (TomlValue value) => ((value as TomlBoolean) ?? throw new TomlTypeMismatchException(typeof(TomlBoolean), value.GetType(), typeof(bool))).Value); Register((byte i) => new TomlLong(i), (TomlValue value) => (byte)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(byte))).Value); Register((sbyte i) => new TomlLong(i), (TomlValue value) => (sbyte)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(sbyte))).Value); Register((ushort i) => new TomlLong(i), (TomlValue value) => (ushort)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(ushort))).Value); Register((short i) => new TomlLong(i), (TomlValue value) => (short)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(short))).Value); Register((uint i) => new TomlLong(i), (TomlValue value) => (uint)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(uint))).Value); Register((int i) => new TomlLong(i), (TomlValue value) => (int)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(int))).Value); Register((ulong l) => new TomlLong((long)l), (TomlValue value) => (ulong)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(ulong))).Value); Register((long l) => new TomlLong(l), (TomlValue value) => ((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(long))).Value); Register((double d) => new TomlDouble(d), (TomlValue value) => (value as TomlDouble)?.Value ?? ((double)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlDouble), value.GetType(), typeof(double))).Value)); Register((float f) => new TomlDouble(f), (TomlValue value) => (float)((value as TomlDouble)?.Value ?? ((double)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlDouble), value.GetType(), typeof(float))).Value))); Register((DateTime dt) => (!(dt.TimeOfDay == TimeSpan.Zero)) ? ((TomlValue)new TomlLocalDateTime(dt)) : ((TomlValue)new TomlLocalDate(dt)), (TomlValue value) => ((value as ITomlValueWithDateTime) ?? throw new TomlTypeMismatchException(typeof(ITomlValueWithDateTime), value.GetType(), typeof(DateTime))).Value); Register((DateTimeOffset odt) => new TomlOffsetDateTime(odt), (TomlValue value) => ((value as TomlOffsetDateTime) ?? throw new TomlTypeMismatchException(typeof(TomlOffsetDateTime), value.GetType(), typeof(DateTimeOffset))).Value); Register((TimeSpan lt) => new TomlLocalTime(lt), (TomlValue value) => ((value as TomlLocalTime) ?? throw new TomlTypeMismatchException(typeof(TomlLocalTime), value.GetType(), typeof(TimeSpan))).Value); } internal static Serialize GetSerializer(Type t) { if (Serializers.TryGetValue(t, out System.Delegate value)) { return (Serialize)value; } if (t.IsArray || (t.Namespace == "System.Collections.Generic" && t.Name == "List`1")) { Serialize serialize = GenericEnumerableSerializer(); Serializers[t] = serialize; return serialize; } return TomlCompositeSerializer.For(t); } internal static Deserialize GetDeserializer(Type t) { if (Deserializers.TryGetValue(t, out System.Delegate value)) { return (Deserialize)value; } if (t.IsArray) { Deserialize deserialize = ArrayDeserializerFor(t.GetElementType()); Deserializers[t] = deserialize; return deserialize; } if (t.Namespace == "System.Collections.Generic" && t.Name == "List`1") { Deserialize deserialize2 = ListDeserializerFor(t.GetGenericArguments()[0]); Deserializers[t] = deserialize2; return deserialize2; } return TomlCompositeDeserializer.For(t); } private static Serialize GenericEnumerableSerializer() { return delegate(object? o) { IEnumerable obj = (o as IEnumerable) ?? throw new Exception("How did ArraySerializer end up getting a non-array?"); TomlArray tomlArray = new TomlArray(); foreach (object item in obj) { tomlArray.Add(item); } return tomlArray; }; } private static Deserialize ArrayDeserializerFor(Type elementType) { return delegate(TomlValue value) { if (!(value is TomlArray tomlArray)) { throw new TomlTypeMismatchException(typeof(TomlArray), value.GetType(), elementType.MakeArrayType()); } Array array = Array.CreateInstance(elementType, tomlArray.Count); Deserialize deserializer = GetDeserializer(elementType); for (int i = 0; i < tomlArray.ArrayValues.Count; i++) { TomlValue value2 = tomlArray.ArrayValues[i]; array.SetValue(deserializer(value2), i); } return array; }; } private static Deserialize ListDeserializerFor(Type elementType) { Type listType = typeof(List<>).MakeGenericType(elementType); MethodInfo relevantAddMethod = listType.GetMethod("Add"); return delegate(TomlValue value) { TomlArray obj = (value as TomlArray) ?? throw new TomlTypeMismatchException(typeof(TomlArray), value.GetType(), listType); object obj2 = Activator.CreateInstance(listType); Deserialize deserializer = GetDeserializer(elementType); foreach (TomlValue arrayValue in obj.ArrayValues) { relevantAddMethod.Invoke(obj2, new object[1] { deserializer(arrayValue) }); } return obj2; }; } internal static void Register(Serialize? serializer, Deserialize? deserializer) { if (serializer != null) { RegisterSerializer(serializer); RegisterDictionarySerializer(serializer); } if (deserializer != null) { RegisterDeserializer(deserializer); RegisterDictionaryDeserializer(deserializer); } } internal static void Register(Type t, Serialize? serializer, Deserialize? deserializer) { if (serializer != null) { RegisterSerializer(serializer); } if (deserializer != null) { RegisterDeserializer(deserializer); } } private static void RegisterDeserializer(Deserialize deserializer) { Deserializers[typeof(T)] = new Deserialize(BoxedDeserializer); object BoxedDeserializer(TomlValue value) { T val = deserializer(value); if (val == null) { throw new Exception("TOML Deserializer returned null for type T"); } return val; } } private static void RegisterSerializer(Serialize serializer) { Serializers[typeof(T)] = new Serialize(ObjectAcceptingSerializer); TomlValue ObjectAcceptingSerializer(object value) { return serializer((T)value); } } private static void RegisterDictionarySerializer(Serialize serializer) { RegisterSerializer(delegate(Dictionary? dict) { TomlTable tomlTable = new TomlTable(); if (dict == null) { return tomlTable; } List list = dict.Keys.ToList(); List list2 = dict.Values.Select(serializer.Invoke).ToList(); for (int i = 0; i < list.Count; i++) { tomlTable.PutValue(list[i], list2[i], quote: true); } return tomlTable; }); } private static void RegisterDictionaryDeserializer(Deserialize deserializer) { RegisterDeserializer((TomlValue value) => ((value as TomlTable) ?? throw new TomlTypeMismatchException(typeof(TomlTable), value.GetType(), typeof(Dictionary))).Entries.Select, KeyValuePair>((KeyValuePair kvp) => new KeyValuePair(kvp.Key, deserializer(kvp.Value))).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value)); } } internal static class TomlUtils { public static string EscapeStringValue(string key) { return key.Replace("\\", "\\\\").Replace("\n", "\\n").Replace("\r", ""); } public static string AddCorrectQuotes(string key) { if (key.Contains("'") && key.Contains("\"")) { throw new InvalidTomlKeyException(key); } if (key.Contains("\"")) { return "'" + key + "'"; } return "\"" + key + "\""; } } } namespace Tomlet.Models { internal class TomlArray : TomlValue, IEnumerable, IEnumerable { public readonly List ArrayValues = new List(); internal bool IsLockedToBeTableArray; public override string StringValue => $"Toml Array ({ArrayValues.Count} values)"; public bool IsTableArray { get { if (!IsLockedToBeTableArray) { return ArrayValues.All((TomlValue t) => t is TomlTable); } return true; } } public bool CanBeSerializedInline { get { if (IsTableArray) { if (ArrayValues.All((TomlValue o) => o is TomlTable tomlTable && tomlTable.ShouldBeSerializedInline)) { return ArrayValues.Count <= 5; } return false; } return true; } } public bool IsSimpleArray { get { if (!IsLockedToBeTableArray) { return !ArrayValues.Any((TomlValue o) => o is TomlArray || o is TomlTable || !o.Comments.ThereAreNoComments); } return false; } } public TomlValue this[int index] => ArrayValues[index]; public int Count => ArrayValues.Count; public override string SerializedValue => SerializeInline(!IsSimpleArray); public void Add(T t) where T : new() { TomlValue item = ((t is TomlValue tomlValue) ? tomlValue : TomletMain.ValueFrom(t)); ArrayValues.Add(item); } public string SerializeInline(bool multiline) { if (!CanBeSerializedInline) { throw new Exception("Complex Toml Tables cannot be serialized into a TomlArray if the TomlArray is not a Table Array. This means that the TOML array cannot contain anything other than tables. If you are manually accessing SerializedValue on the TomlArray, you should probably be calling SerializeTableArray here. (Check the CanBeSerializedInline property and call that method if it is false)"); } StringBuilder stringBuilder = new StringBuilder("["); char value = (multiline ? '\n' : ' '); using (IEnumerator enumerator = GetEnumerator()) { while (enumerator.MoveNext()) { TomlValue current = enumerator.Current; stringBuilder.Append(value); if (current.Comments.PrecedingComment != null) { stringBuilder.Append(current.Comments.FormatPrecedingComment(1)).Append('\n'); } if (multiline) { stringBuilder.Append('\t'); } stringBuilder.Append(current.SerializedValue); stringBuilder.Append(','); if (current.Comments.InlineComment != null) { stringBuilder.Append(" # ").Append(current.Comments.InlineComment); } } } stringBuilder.Append(value); stringBuilder.Append(']'); return stringBuilder.ToString(); } public string SerializeTableArray(string key) { if (!IsTableArray) { throw new Exception("Cannot serialize normal arrays using this method. Use the normal TomlValue.SerializedValue property."); } StringBuilder stringBuilder = new StringBuilder(); if (base.Comments.InlineComment != null) { throw new Exception("Sorry, but inline comments aren't supported on table-arrays themselves. See https://github.com/SamboyCoding/Tomlet/blob/master/docs/InlineCommentsOnTableArrays.md for my rationale on this."); } bool flag = true; using (IEnumerator enumerator = GetEnumerator()) { while (enumerator.MoveNext()) { TomlValue current = enumerator.Current; if (!(current is TomlTable tomlTable)) { throw new Exception($"Toml Table-Array contains non-table entry? Value is {current}"); } if (current.Comments.PrecedingComment != null) { if (flag && base.Comments.PrecedingComment != null) { stringBuilder.Append('\n'); } stringBuilder.Append(current.Comments.FormatPrecedingComment()).Append('\n'); } flag = false; stringBuilder.Append("[[").Append(key).Append("]]"); if (current.Comments.InlineComment != null) { stringBuilder.Append(" # ").Append(current.Comments.InlineComment); } stringBuilder.Append('\n'); stringBuilder.Append(tomlTable.SerializeNonInlineTable(key, includeHeader: false)).Append('\n'); } } return stringBuilder.ToString(); } public IEnumerator GetEnumerator() { return ArrayValues.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return ArrayValues.GetEnumerator(); } } internal class TomlBoolean : TomlValue { private bool _value; public static TomlBoolean True => new TomlBoolean(value: true); public static TomlBoolean False => new TomlBoolean(value: false); public bool Value => _value; public override string StringValue { get { if (!Value) { return bool.FalseString.ToLowerInvariant(); } return bool.TrueString.ToLowerInvariant(); } } public override string SerializedValue => StringValue; private TomlBoolean(bool value) { _value = value; } public static TomlBoolean ValueOf(bool b) { if (!b) { return False; } return True; } } internal class TomlCommentData { private string? _inlineComment; public string? PrecedingComment { get; set; } public string? InlineComment { get { return _inlineComment; } set { if (value == null) { _inlineComment = null; return; } if (value.Contains("\n") || value.Contains("\r")) { throw new TomlNewlineInInlineCommentException(); } _inlineComment = value; } } public bool ThereAreNoComments { get { if (InlineComment == null) { return PrecedingComment == null; } return false; } } internal string FormatPrecedingComment(int indentCount = 0) { if (PrecedingComment == null) { throw new Exception("Preceding comment is null"); } StringBuilder stringBuilder = new StringBuilder(); string[] array = PrecedingComment.Split(new char[1] { '\n' }); bool flag = true; string[] array2 = array; foreach (string value in array2) { if (!flag) { stringBuilder.Append('\n'); } flag = false; string value2 = new string('\t', indentCount); stringBuilder.Append(value2).Append("# ").Append(value); } return stringBuilder.ToString(); } } internal class TomlDocument : TomlTable { public string? TrailingComment { get; set; } public override string SerializedValue => SerializeDocument(); public override string StringValue => $"Toml root document ({Entries.Count} entries)"; public static TomlDocument CreateEmpty() { return new TomlDocument(); } internal TomlDocument() { } internal TomlDocument(TomlTable from) { foreach (string key in from.Keys) { PutValue(key, from.GetValue(key)); } } private string SerializeDocument() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(SerializeNonInlineTable(null, includeHeader: false)); if (TrailingComment != null) { TomlCommentData tomlCommentData = new TomlCommentData { PrecedingComment = TrailingComment }; stringBuilder.Append('\n'); stringBuilder.Append(tomlCommentData.FormatPrecedingComment()); } return stringBuilder.ToString(); } } internal class TomlDouble : TomlValue { private double _value; public bool HasDecimal => Value != (double)(int)Value; public double Value => _value; public bool IsNaN => double.IsNaN(Value); public bool IsInfinity => double.IsInfinity(Value); public override string StringValue { get { if (this != null) { if (IsInfinity) { return double.IsPositiveInfinity(Value) ? "inf" : "-inf"; } if (IsNaN) { return "nan"; } if (HasDecimal) { return Value.ToString(CultureInfo.InvariantCulture); } } return $"{Value:F1}"; } } public override string SerializedValue => StringValue; public TomlDouble(double value) { _value = value; } internal static TomlDouble? Parse(string valueInToml) { double? doubleValue = TomlNumberUtils.GetDoubleValue(valueInToml); if (!doubleValue.HasValue) { return null; } return new TomlDouble(doubleValue.Value); } } internal class TomlLocalDate : TomlValue, ITomlValueWithDateTime { private readonly DateTime _value; public DateTime Value => _value; public override string StringValue => XmlConvert.ToString(Value, (XmlDateTimeSerializationMode)2); public override string SerializedValue => StringValue; public TomlLocalDate(DateTime value) { _value = value; } public static TomlLocalDate? Parse(string input) { if (!DateTime.TryParse(input, out var result)) { return null; } return new TomlLocalDate(result); } } internal class TomlLocalDateTime : TomlValue, ITomlValueWithDateTime { private readonly DateTime _value; public DateTime Value => _value; public override string StringValue => XmlConvert.ToString(Value, (XmlDateTimeSerializationMode)2); public override string SerializedValue => StringValue; public TomlLocalDateTime(DateTime value) { _value = value; } public static TomlLocalDateTime? Parse(string input) { if (!DateTime.TryParse(input, out var result)) { return null; } return new TomlLocalDateTime(result); } } internal class TomlLocalTime : TomlValue { private readonly TimeSpan _value; public TimeSpan Value => _value; public override string StringValue => Value.ToString(); public override string SerializedValue => StringValue; public TomlLocalTime(TimeSpan value) { _value = value; } public static TomlLocalTime? Parse(string input) { if (!TimeSpan.TryParse(input, out var result)) { return null; } return new TomlLocalTime(result); } } internal class TomlLong : TomlValue { private long _value; public long Value => _value; public override string StringValue => Value.ToString(); public override string SerializedValue => StringValue; public TomlLong(long value) { _value = value; } internal static TomlLong? Parse(string valueInToml) { long? longValue = TomlNumberUtils.GetLongValue(valueInToml); if (!longValue.HasValue) { return null; } return new TomlLong(longValue.Value); } } internal class TomlOffsetDateTime : TomlValue { private readonly DateTimeOffset _value; public DateTimeOffset Value => _value; public override string StringValue => Value.ToString("O"); public override string SerializedValue => StringValue; public TomlOffsetDateTime(DateTimeOffset value) { _value = value; } public static TomlOffsetDateTime? Parse(string input) { if (!DateTimeOffset.TryParse(input, out var result)) { return null; } return new TomlOffsetDateTime(result); } } internal class TomlString : TomlValue { private readonly string _value; public static TomlString Empty => new TomlString(""); public string Value => _value; public override string StringValue => Value; public override string SerializedValue { get { if (Value.Contains("'") && !Value.Contains("\"")) { return "\"" + TomlUtils.EscapeStringValue(Value) + "\""; } if (Value.Contains("\"") && !Value.Contains("'") && !Value.Contains("\n")) { return "'" + Value + "'"; } if (Value.Contains("\"") && !Value.Contains("'")) { return "'''\n" + Value + "'''"; } return "\"" + TomlUtils.EscapeStringValue(Value) + "\""; } } public TomlString(string? value) { _value = value ?? throw new ArgumentNullException("value", "TomlString's value cannot be null"); } } internal class TomlTable : TomlValue { public readonly Dictionary Entries = new Dictionary(); internal bool Locked; internal bool Defined; public bool ForceNoInline { get; set; } public override string StringValue => $"Table ({Entries.Count} entries)"; public HashSet Keys => new HashSet(Entries.Keys); public bool ShouldBeSerializedInline { get { if (!ForceNoInline && Entries.Count < 4) { return Entries.All>((KeyValuePair e) => !e.Key.Contains(" ") && e.Value.Comments.ThereAreNoComments && ((!(e.Value is TomlArray tomlArray)) ? (!(e.Value is TomlTable)) : tomlArray.IsSimpleArray)); } return false; } } public override string SerializedValue { get { if (!ShouldBeSerializedInline) { throw new Exception("Cannot use SerializeValue to serialize non-inline tables. Use SerializeNonInlineTable(keyName)."); } StringBuilder stringBuilder = new StringBuilder("{ "); stringBuilder.Append(string.Join(", ", Entries.Select, string>((KeyValuePair o) => o.Key + " = " + o.Value.SerializedValue).ToArray())); stringBuilder.Append(" }"); return stringBuilder.ToString(); } } public string SerializeNonInlineTable(string? keyName, bool includeHeader = true) { StringBuilder stringBuilder = new StringBuilder(); if (includeHeader) { stringBuilder.Append('[').Append(keyName).Append("]"); if (base.Comments.InlineComment != null) { stringBuilder.Append(" # ").Append(base.Comments.InlineComment); } stringBuilder.Append('\n'); } string one; TomlValue two; foreach (KeyValuePair entry in Entries) { Extensions.Deconstruct(entry, out one, out two); string subKey = one; TomlValue tomlValue = two; if (tomlValue is TomlTable tomlTable) { if (!tomlTable.ShouldBeSerializedInline) { goto IL_00a4; } } else if (tomlValue is TomlArray { CanBeSerializedInline: false }) { goto IL_00a4; } bool flag = false; goto IL_00ac; IL_00a4: flag = true; goto IL_00ac; IL_00ac: if (!flag) { WriteValueToStringBuilder(keyName, subKey, stringBuilder); } } foreach (KeyValuePair entry2 in Entries) { Extensions.Deconstruct(entry2, out one, out two); string subKey2 = one; if (two is TomlTable { ShouldBeSerializedInline: false }) { WriteValueToStringBuilder(keyName, subKey2, stringBuilder); } } foreach (KeyValuePair entry3 in Entries) { Extensions.Deconstruct(entry3, out one, out two); string subKey3 = one; if (two is TomlArray { CanBeSerializedInline: false }) { WriteValueToStringBuilder(keyName, subKey3, stringBuilder); } } return stringBuilder.ToString(); } private void WriteValueToStringBuilder(string? keyName, string subKey, StringBuilder builder) { TomlValue value = GetValue(subKey); subKey = EscapeKeyIfNeeded(subKey); if (keyName != null) { keyName = EscapeKeyIfNeeded(keyName); } string text = ((keyName == null) ? subKey : (keyName + "." + subKey)); if (value.Comments.PrecedingComment != null) { builder.Append(value.Comments.FormatPrecedingComment()).Append('\n'); } if (value is TomlArray tomlArray) { if (!tomlArray.CanBeSerializedInline) { builder.Append(tomlArray.SerializeTableArray(text)); return; } TomlArray tomlArray2 = tomlArray; builder.Append(subKey).Append(" = ").Append(tomlArray2.SerializedValue); } else if (value is TomlTable tomlTable) { if (!tomlTable.ShouldBeSerializedInline) { TomlTable tomlTable2 = tomlTable; builder.Append(tomlTable2.SerializeNonInlineTable(text)).Append('\n'); return; } builder.Append(subKey).Append(" = ").Append(tomlTable.SerializedValue); } else { builder.Append(subKey).Append(" = ").Append(value.SerializedValue); } if (value.Comments.InlineComment != null) { builder.Append(" # ").Append(value.Comments.InlineComment); } builder.Append('\n'); } private string EscapeKeyIfNeeded(string key) { bool flag = false; if (key.StartsWith("\"") && key.EndsWith("\"") && key.Count((char c) => c == '"') == 2) { return key; } if (key.StartsWith("'") && key.EndsWith("'") && key.Count((char c) => c == '\'') == 2) { return key; } if (key.Contains("\"") || key.Contains("'")) { key = TomlUtils.AddCorrectQuotes(key); flag = true; } string text = TomlUtils.EscapeStringValue(key); if (text.Contains(" ") || (text.Contains("\\") && !flag)) { text = TomlUtils.AddCorrectQuotes(text); } return text; } internal void ParserPutValue(string key, TomlValue value, int lineNumber) { if (Locked) { throw new TomlTableLockedException(lineNumber, key); } InternalPutValue(key, value, lineNumber, callParserForm: true); } public void PutValue(string key, TomlValue value, bool quote = false) { if (key == null) { throw new ArgumentNullException("key"); } if (value == null) { throw new ArgumentNullException("value"); } if (quote) { key = TomlUtils.AddCorrectQuotes(key); } InternalPutValue(key, value, null, callParserForm: false); } public void Put(string key, T t, bool quote = false) { if (t is TomlValue value) { PutValue(key, value, quote); } else { PutValue(key, TomletMain.ValueFrom(t), quote); } } public string DeQuoteKey(string key) { if ((key.StartsWith("\"") && key.EndsWith("\"")) || (key.StartsWith("'") && key.EndsWith("'"))) { return key.Substring(1, key.Length - 2); } return key; } private void InternalPutValue(string key, TomlValue value, int? lineNumber, bool callParserForm) { key = key.Trim(); TomlKeyUtils.GetTopLevelAndSubKeys(key, out string ourKeyName, out string restOfKey); if (!string.IsNullOrEmpty(restOfKey)) { if (!Entries.TryGetValue(DeQuoteKey(ourKeyName), out TomlValue value2)) { TomlTable tomlTable = new TomlTable(); if (callParserForm) { ParserPutValue(ourKeyName, tomlTable, lineNumber.Value); } else { PutValue(ourKeyName, tomlTable); } if (callParserForm) { tomlTable.ParserPutValue(restOfKey, value, lineNumber.Value); } else { tomlTable.PutValue(restOfKey, value); } return; } if (!(value2 is TomlTable tomlTable2)) { if (lineNumber.HasValue) { throw new TomlDottedKeyParserException(lineNumber.Value, ourKeyName); } throw new TomlDottedKeyException(ourKeyName); } if (callParserForm) { tomlTable2.ParserPutValue(restOfKey, value, lineNumber.Value); } else { tomlTable2.PutValue(restOfKey, value); } } else { key = DeQuoteKey(key); if (Entries.ContainsKey(key) && lineNumber.HasValue) { throw new TomlKeyRedefinitionException(lineNumber.Value, key); } Entries[key] = value; } } public bool ContainsKey(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlKeyUtils.GetTopLevelAndSubKeys(key, out string ourKeyName, out string restOfKey); if (string.IsNullOrEmpty(restOfKey)) { return Entries.ContainsKey(DeQuoteKey(key)); } if (!Entries.TryGetValue(ourKeyName, out TomlValue value)) { return false; } if (value is TomlTable tomlTable) { return tomlTable.ContainsKey(restOfKey); } throw new TomlContainsDottedKeyNonTableException(key); } public TomlValue GetValue(string key) { if (key == null) { throw new ArgumentNullException("key"); } if (!ContainsKey(key)) { throw new TomlNoSuchValueException(key); } TomlKeyUtils.GetTopLevelAndSubKeys(key, out string ourKeyName, out string restOfKey); if (string.IsNullOrEmpty(restOfKey)) { return Entries[DeQuoteKey(key)]; } if (!Entries.TryGetValue(ourKeyName, out TomlValue value)) { throw new TomlNoSuchValueException(key); } if (value is TomlTable tomlTable) { return tomlTable.GetValue(restOfKey); } throw new Exception("Tomlet Internal bug - existing key is not a table in TomlTable GetValue, but we didn't throw in ContainsKey?"); } public string GetString(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return ((value as TomlString) ?? throw new TomlTypeMismatchException(typeof(TomlString), value.GetType(), typeof(string))).Value; } public int GetInteger(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return (int)((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(int))).Value; } public long GetLong(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return ((value as TomlLong) ?? throw new TomlTypeMismatchException(typeof(TomlLong), value.GetType(), typeof(int))).Value; } public float GetFloat(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return (float)((value as TomlDouble) ?? throw new TomlTypeMismatchException(typeof(TomlDouble), value.GetType(), typeof(float))).Value; } public bool GetBoolean(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return ((value as TomlBoolean) ?? throw new TomlTypeMismatchException(typeof(TomlBoolean), value.GetType(), typeof(bool))).Value; } public TomlArray GetArray(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return (value as TomlArray) ?? throw new TomlTypeMismatchException(typeof(TomlArray), value.GetType(), typeof(TomlArray)); } public TomlTable GetSubTable(string key) { if (key == null) { throw new ArgumentNullException("key"); } TomlValue value = GetValue(TomlUtils.AddCorrectQuotes(key)); return (value as TomlTable) ?? throw new TomlTypeMismatchException(typeof(TomlTable), value.GetType(), typeof(TomlTable)); } } internal abstract class TomlValue { public TomlCommentData Comments { get; } = new TomlCommentData(); public abstract string StringValue { get; } public abstract string SerializedValue { get; } } internal interface ITomlValueWithDateTime { DateTime Value { get; } } } namespace Tomlet.Exceptions { internal class InvalidTomlDateTimeException : TomlExceptionWithLine { private readonly string _inputString; public override string Message => $"Found an invalid TOML date/time string '{_inputString}' on line {LineNumber}"; public InvalidTomlDateTimeException(int lineNumber, string inputString) : base(lineNumber) { _inputString = inputString; } } internal class InvalidTomlEscapeException : TomlExceptionWithLine { private readonly string _escapeSequence; public override string Message => $"Found an invalid escape sequence '\\{_escapeSequence}' on line {LineNumber}"; public InvalidTomlEscapeException(int lineNumber, string escapeSequence) : base(lineNumber) { _escapeSequence = escapeSequence; } } internal class InvalidTomlInlineTableException : TomlExceptionWithLine { public override string Message => $"Found an invalid inline TOML table on line {LineNumber}. See further down for cause."; public InvalidTomlInlineTableException(int lineNumber, TomlException cause) : base(lineNumber, cause) { } } internal class InvalidTomlKeyException : TomlException { private readonly string _key; public override string Message => "The string |" + _key + "| (between the two bars) contains at least one of both a double quote and a single quote, so it cannot be used for a TOML key."; public InvalidTomlKeyException(string key) { _key = key; } } internal class InvalidTomlNumberException : TomlExceptionWithLine { private readonly string _input; public override string Message => $"While reading input line {LineNumber}, found an invalid number literal '{_input}'"; public InvalidTomlNumberException(int lineNumber, string input) : base(lineNumber) { _input = input; } } internal class MissingIntermediateInTomlTableArraySpecException : TomlExceptionWithLine { private readonly string _missing; public override string Message => $"Missing intermediate definition for {_missing} in table-array specification on line {LineNumber}. This is undefined behavior, and I chose to define it as an error."; public MissingIntermediateInTomlTableArraySpecException(int lineNumber, string missing) : base(lineNumber) { _missing = missing; } } internal class NewLineInTomlInlineTableException : TomlExceptionWithLine { public override string Message => "Found a new-line character within a TOML inline table. This is not allowed."; public NewLineInTomlInlineTableException(int lineNumber) : base(lineNumber) { } } internal class NoTomlKeyException : TomlExceptionWithLine { public override string Message => $"Expected a TOML key on line {LineNumber}, but found an equals sign ('=')."; public NoTomlKeyException(int lineNumber) : base(lineNumber) { } } internal class TimeOffsetOnTomlDateOrTimeException : TomlExceptionWithLine { private readonly string _tzString; public override string Message => $"Found a time offset string {_tzString} in a partial datetime on line {LineNumber}. This is not allowed - either specify both the date and the time, or remove the offset specifier."; public TimeOffsetOnTomlDateOrTimeException(int lineNumber, string tzString) : base(lineNumber) { _tzString = tzString; } } internal class TomlArraySyntaxException : TomlExceptionWithLine { private readonly char _charFound; public override string Message => $"Expecting ',' or ']' after value in array on line {LineNumber}, found '{_charFound}'"; public TomlArraySyntaxException(int lineNumber, char charFound) : base(lineNumber) { _charFound = charFound; } } internal class TomlContainsDottedKeyNonTableException : TomlException { internal readonly string Key; public override string Message => "A call was made on a TOML table which attempted to access a sub-key of " + Key + ", but the value it refers to is not a table"; public TomlContainsDottedKeyNonTableException(string key) { Key = key; } } internal class TomlDateTimeMissingSeparatorException : TomlExceptionWithLine { public override string Message => $"Found a date-time on line {LineNumber} which is missing a separator (T, t, or a space) between the date and time."; public TomlDateTimeMissingSeparatorException(int lineNumber) : base(lineNumber) { } } internal class TomlDateTimeUnnecessarySeparatorException : TomlExceptionWithLine { public override string Message => $"Found an unnecessary date-time separator (T, t, or a space) in a date or time on line {LineNumber}"; public TomlDateTimeUnnecessarySeparatorException(int lineNumber) : base(lineNumber) { } } internal class TomlDottedKeyException : TomlException { private readonly string _key; public override string Message => "Tried to redefine key " + _key + " as a table (by way of a dotted key) when it's already defined as not being a table."; public TomlDottedKeyException(string key) { _key = key; } } internal class TomlDottedKeyParserException : TomlExceptionWithLine { private readonly string _key; public override string Message => $"Tried to redefine key {_key} as a table (by way of a dotted key on line {LineNumber}) when it's already defined as not being a table."; public TomlDottedKeyParserException(int lineNumber, string key) : base(lineNumber) { _key = key; } } internal class TomlDoubleDottedKeyException : TomlExceptionWithLine { public override string Message => "Found two consecutive dots, or a leading dot, in a key on line " + LineNumber; public TomlDoubleDottedKeyException(int lineNumber) : base(lineNumber) { } } internal class TomlEndOfFileException : TomlExceptionWithLine { public override string Message => $"Found unexpected EOF on line {LineNumber} when parsing TOML file"; public TomlEndOfFileException(int lineNumber) : base(lineNumber) { } } internal class TomlEnumParseException : TomlException { private string _valueName; private Type _enumType; public override string Message => $"Could not find enum value by name \"{_valueName}\" in enum class {_enumType} while deserializing."; public TomlEnumParseException(string valueName, Type enumType) { _valueName = valueName; _enumType = enumType; } } internal abstract class TomlException : Exception { protected TomlException() { } protected TomlException(Exception cause) : base("", cause) { } } internal abstract class TomlExceptionWithLine : TomlException { protected int LineNumber; protected TomlExceptionWithLine(int lineNumber) { LineNumber = lineNumber; } protected TomlExceptionWithLine(int lineNumber, Exception cause) : base(cause) { LineNumber = lineNumber; } } internal class TomlFieldTypeMismatchException : TomlTypeMismatchException { private readonly Type _typeBeingInstantiated; private readonly FieldInfo _fieldBeingDeserialized; public override string Message => $"While deserializing an object of type {_typeBeingInstantiated}, found field {_fieldBeingDeserialized.Name} expecting a type of {ExpectedTypeName}, but value in TOML was of type {ActualTypeName}"; public TomlFieldTypeMismatchException(Type typeBeingInstantiated, FieldInfo fieldBeingDeserialized, TomlTypeMismatchException cause) : base(cause.ExpectedType, cause.ActualType, fieldBeingDeserialized.FieldType) { _typeBeingInstantiated = typeBeingInstantiated; _fieldBeingDeserialized = fieldBeingDeserialized; } } internal class TomlInlineTableSeparatorException : TomlExceptionWithLine { private readonly char _found; public override string Message => $"Expected '}}' or ',' after key-value pair in TOML inline table, found '{_found}'"; public TomlInlineTableSeparatorException(int lineNumber, char found) : base(lineNumber) { _found = found; } } internal class TomlInstantiationException : TomlException { private readonly Type _type; public override string Message => "Could not find a no-argument constructor for type " + _type.FullName; public TomlInstantiationException(Type type) { _type = type; } } internal class TomlInternalException : TomlExceptionWithLine { public override string Message => $"An internal exception occured while parsing line {LineNumber} of the TOML document"; public TomlInternalException(int lineNumber, Exception cause) : base(lineNumber, cause) { } } internal class TomlInvalidValueException : TomlExceptionWithLine { private readonly char _found; public override string Message => $"Expected the start of a number, string literal, boolean, array, or table on line {LineNumber}, found '{_found}'"; public TomlInvalidValueException(int lineNumber, char found) : base(lineNumber) { _found = found; } } internal class TomlKeyRedefinitionException : TomlExceptionWithLine { private readonly string _key; public override string Message => $"TOML document attempts to re-define key '{_key}' on line {LineNumber}"; public TomlKeyRedefinitionException(int lineNumber, string key) : base(lineNumber) { _key = key; } } internal class TomlMissingEqualsException : TomlExceptionWithLine { private readonly char _found; public override string Message => $"Expecting an equals sign ('=') on line {LineNumber}, but found '{_found}'"; public TomlMissingEqualsException(int lineNumber, char found) : base(lineNumber) { _found = found; } } internal class TomlMissingNewlineException : TomlExceptionWithLine { private readonly char _found; public override string Message => $"Expecting a newline character at the end of a statement on line {LineNumber}, but found an unexpected '{_found}'"; public TomlMissingNewlineException(int lineNumber, char found) : base(lineNumber) { _found = found; } } internal class TomlNewlineInInlineCommentException : TomlException { public override string Message => "An attempt was made to set an inline comment which contains a newline. This obviously cannot be done, as inline comments must fit on one line."; } internal class TomlNonTableArrayUsedAsTableArrayException : TomlExceptionWithLine { private readonly string _arrayName; public override string Message => $"{_arrayName} is used as a table-array on line {LineNumber} when it has previously been defined as a static array. This is not allowed."; public TomlNonTableArrayUsedAsTableArrayException(int lineNumber, string arrayName) : base(lineNumber) { _arrayName = arrayName; } } internal class TomlNoSuchValueException : TomlException { private readonly string _key; public override string Message => "Attempted to get the value for key " + _key + " but no value is associated with that key"; public TomlNoSuchValueException(string key) { _key = key; } } internal class TomlPrimitiveToDocumentException : TomlException { private Type primitiveType; public override string Message => "Tried to create a TOML document from a primitive value of type " + primitiveType.Name + ". Documents can only be created from objects."; public TomlPrimitiveToDocumentException(Type primitiveType) { this.primitiveType = primitiveType; } } internal class TomlStringException : TomlExceptionWithLine { public override string Message => $"Found an invalid TOML string on line {LineNumber}"; public TomlStringException(int lineNumber) : base(lineNumber) { } } internal class TomlTableArrayAlreadyExistsAsNonArrayException : TomlExceptionWithLine { private readonly string _arrayName; public override string Message => $"{_arrayName} is defined as a table-array (double-bracketed section) on line {LineNumber} but it has previously been used as a non-array type."; public TomlTableArrayAlreadyExistsAsNonArrayException(int lineNumber, string arrayName) : base(lineNumber) { _arrayName = arrayName; } } internal class TomlTableLockedException : TomlExceptionWithLine { private readonly string _key; public override string Message => $"TOML table is locked (e.g. defined inline), cannot add or update key {_key} to it on line {LineNumber}"; public TomlTableLockedException(int lineNumber, string key) : base(lineNumber) { _key = key; } } internal class TomlTableRedefinitionException : TomlExceptionWithLine { private readonly string _key; public override string Message => $"TOML document attempts to re-define table '{_key}' on line {LineNumber}"; public TomlTableRedefinitionException(int lineNumber, string key) : base(lineNumber) { _key = key; } } internal class TomlTripleQuotedKeyException : TomlExceptionWithLine { public override string Message => $"Found a triple-quoted key on line {LineNumber}. This is not allowed."; public TomlTripleQuotedKeyException(int lineNumber) : base(lineNumber) { } } internal class TomlTypeMismatchException : TomlException { protected readonly string ExpectedTypeName; protected readonly string ActualTypeName; protected internal readonly Type ExpectedType; protected internal readonly Type ActualType; private readonly Type _context; public override string Message => $"While trying to convert to type {_context}, a TOML value of type {ExpectedTypeName} was required but a value of type {ActualTypeName} was found"; public TomlTypeMismatchException(Type expected, Type actual, Type context) { ExpectedTypeName = (typeof(TomlValue).IsAssignableFrom(expected) ? expected.Name.Replace("Toml", "") : expected.Name); ActualTypeName = (typeof(TomlValue).IsAssignableFrom(actual) ? actual.Name.Replace("Toml", "") : actual.Name); ExpectedType = expected; ActualType = actual; _context = context; } } internal class TomlUnescapedUnicodeControlCharException : TomlExceptionWithLine { private readonly int _theChar; public override string Message => $"Found an unescaped unicode control character U+{_theChar:0000} on line {LineNumber}. Control character other than tab (U+0009) are not allowed in TOML unless they are escaped."; public TomlUnescapedUnicodeControlCharException(int lineNumber, int theChar) : base(lineNumber) { _theChar = theChar; } } internal class TomlWhitespaceInKeyException : TomlExceptionWithLine { public override string Message => "Found whitespace in an unquoted TOML key at line " + LineNumber; public TomlWhitespaceInKeyException(int lineNumber) : base(lineNumber) { } } internal class TripleQuoteInTomlMultilineLiteralException : TomlExceptionWithLine { public override string Message => $"Found a triple-single-quote (''') inside a multiline string literal on line {LineNumber}. This is not allowed."; public TripleQuoteInTomlMultilineLiteralException(int lineNumber) : base(lineNumber) { } } internal class TripleQuoteInTomlMultilineSimpleStringException : TomlExceptionWithLine { public override string Message => $"Found a triple-double-quote (\"\"\") inside a multiline simple string on line {LineNumber}. This is not allowed."; public TripleQuoteInTomlMultilineSimpleStringException(int lineNumber) : base(lineNumber) { } } internal class UnterminatedTomlKeyException : TomlExceptionWithLine { public override string Message => $"Found an unterminated quoted key on line {LineNumber}"; public UnterminatedTomlKeyException(int lineNumber) : base(lineNumber) { } } internal class UnterminatedTomlStringException : TomlExceptionWithLine { public override string Message => $"Found an unterminated TOML string on line {LineNumber}"; public UnterminatedTomlStringException(int lineNumber) : base(lineNumber) { } } internal class UnterminatedTomlTableArrayException : TomlExceptionWithLine { public override string Message => $"Found an unterminated table-array (expecting two ]s to close it) on line {LineNumber}"; public UnterminatedTomlTableArrayException(int lineNumber) : base(lineNumber) { } } internal class UnterminatedTomlTableNameException : TomlExceptionWithLine { public override string Message => $"Found an unterminated table name on line {LineNumber}"; public UnterminatedTomlTableNameException(int lineNumber) : base(lineNumber) { } } } namespace Tomlet.Attributes { internal class NoCoverageAttribute : System.Attribute { } [AttributeUsage(AttributeTargets.Class)] internal class TomlDoNotInlineObjectAttribute : System.Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] internal class TomlInlineCommentAttribute : System.Attribute { internal string Comment { get; } public TomlInlineCommentAttribute(string comment) { Comment = comment; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] internal class TomlPrecedingCommentAttribute : System.Attribute { internal string Comment { get; } public TomlPrecedingCommentAttribute(string comment) { Comment = comment; } } [AttributeUsage(AttributeTargets.Property)] internal class TomlPropertyAttribute : System.Attribute { private readonly string _mapFrom; public TomlPropertyAttribute(string mapFrom) { _mapFrom = mapFrom; } public string GetMappedString() { return _mapFrom; } } }