Ejemplo n.º 1
0
        static Mneumonic()
        {
            if (MnuemonicList == null)
            {
                MnuemonicList = new Dictionary <string, Mneumonic>();

                Type[] types = (
                    from domainAssembly in AppDomain.CurrentDomain.GetAssemblies() // Get the referenced assemblies
                    from assemblyType in domainAssembly.GetTypes()                 // Get all types in assembly
                    where typeof(Mneumonic).IsAssignableFrom(assemblyType)         // Check to see if the type is a game rule
                    where assemblyType.GetConstructor(Type.EmptyTypes) != null     // Make sure there is an empty constructor
                    select assemblyType).ToArray();                                // Convert IEnumerable to array

                // Iterate over them
                for (int index = 0; index < types.Length; index++)
                {
                    try
                    {
                        Mneumonic instance = (Mneumonic)Activator.CreateInstance(types[index]);

                        if (!MnuemonicList.ContainsKey(instance.Name))
                        {
                            MnuemonicList.Add(instance.Name, instance);
                        }
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("Failed to init Mneumonic:");
                        System.Diagnostics.Debug.Write(e);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void ReadMneumonic(BinaryWriter output, bool isLabelScan)
        {
            string mneumonic = "";

            while (!char.IsWhiteSpace(mySourceCrawler.Peek()))
            {
                mneumonic = mneumonic + mySourceCrawler.Get();
            }

            mneumonic = mneumonic.ToUpper();

            // Special case for the END mneumonic
            if (mneumonic == "END")
            {
                isEnd = true;
                DoEnd(output, isLabelScan);
                mySourceCrawler.EatWhitespace();
                myExecutionAddress = (uint)myLabelLookup[mySourceCrawler.GetLabelName()];
                return;
            }
            else
            {
                Mneumonic mneumonicInstance = Mneumonic.GetFromName(mneumonic);
                mneumonicInstance.Interpret(mySourceCrawler, output, isLabelScan);
            }

            mySourceCrawler.ReadToLineEnd();
        }