コード例 #1
0
        /// <summary>
        /// Creates a populated AssemblerConfig from the app settings for the specified ID.
        /// If the assembler hasn't been configured yet, the default configuration object
        /// will be returned.
        /// </summary>
        /// <param name="settings">Settings object to pull the values from.</param>
        /// <param name="id">Assembler ID.</param>
        /// <returns>The AssemblerConfig.</returns>
        public static AssemblerConfig GetConfig(AppSettings settings, AssemblerInfo.Id id)
        {
            string cereal = settings.GetString(GetSettingName(id), null);

            if (string.IsNullOrEmpty(cereal))
            {
                IAssembler asm = AssemblerInfo.GetAssembler(id);
                return(asm.GetDefaultConfig());
            }

            JavaScriptSerializer ser = new JavaScriptSerializer();

            try {
                AssemblerConfig config = ser.Deserialize <AssemblerConfig>(cereal);
                if (config.ColumnWidths == null || config.ColumnWidths.Length != NUM_COLUMNS)
                {
                    throw new Exception("Bad column widths");
                }
                if (config.ExecutablePath == null)
                {
                    throw new Exception("Missing exe path");
                }
                return(config);
            } catch (Exception ex) {
                Debug.WriteLine("AssemblerConfig deserialization failed: " + ex.Message);
                return(null);
            }
        }
コード例 #2
0
ファイル: GenTest.cs プロジェクト: dmarlowe69/6502bench
            }                                                   // may be null

            public GenTestResults(string pathName, AssemblerInfo.Id asmId)
            {
                PathName = pathName;
                AsmId    = asmId;

                FileName = Path.GetFileName(pathName);
            }
コード例 #3
0
        /// <summary>
        /// Queries the versions from all known assemblers, replacing any previously held data.
        /// </summary>
        public static void QueryVersions()
        {
            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();

            while (iter.MoveNext())
            {
                AssemblerInfo.Id id = iter.Current.AssemblerId;
                if (id == AssemblerInfo.Id.Unknown)
                {
                    continue;
                }

                AssemblerVersion vers = null;
                IAssembler       asm  = AssemblerInfo.GetAssembler(id);
                if (asm != null)
                {
                    vers = asm.QueryVersion();
                }

                Debug.WriteLine("Asm version query: " + id + "=" + vers);
                sVersions[id] = vers;
            }

            sQueried = true;
        }
コード例 #4
0
        /// <summary>
        /// Updates the assembler settings for the specified ID.
        /// </summary>
        /// <param name="settings">Settings object to update.</param>
        /// <param name="id">Assembler ID.</param>
        /// <param name="config">Asm configuration.</param>
        public static void SetConfig(AppSettings settings, AssemblerInfo.Id id,
                                     AssemblerConfig config)
        {
            JavaScriptSerializer ser = new JavaScriptSerializer();
            string cereal            = ser.Serialize(config);

            settings.SetString(GetSettingName(id), cereal);
        }
コード例 #5
0
        public static AssemblerVersion GetVersion(AssemblerInfo.Id id)
        {
            IAssembler asm = AssemblerInfo.GetAssembler(id);

            if (asm == null)
            {
                Debug.WriteLine("Assembler " + id + " not configured");
                return(null);
            }
            return(asm.QueryVersion());
        }
コード例 #6
0
ファイル: GenTest.cs プロジェクト: theotherside/6502bench
        /// <summary>
        /// Gets a copy of the AppSettings with a standard set of formatting options (e.g. lower
        /// case for everything).
        /// </summary>
        /// <returns>New app settings object.</returns>
        private AppSettings CreateNormalizedSettings()
        {
            AppSettings settings = AppSettings.Global.GetCopy();

            // Override all asm formatting options.  We can ignore ShiftBeforeAdjust and the
            // pseudo-op names because those are set by the generators.
            settings.SetBool(AppSettings.FMT_UPPER_HEX_DIGITS, false);
            settings.SetBool(AppSettings.FMT_UPPER_OP_MNEMONIC, false);
            settings.SetBool(AppSettings.FMT_UPPER_PSEUDO_OP_MNEMONIC, false);
            settings.SetBool(AppSettings.FMT_UPPER_OPERAND_A, true);
            settings.SetBool(AppSettings.FMT_UPPER_OPERAND_S, true);
            settings.SetBool(AppSettings.FMT_UPPER_OPERAND_XY, false);
            settings.SetBool(AppSettings.FMT_ADD_SPACE_FULL_COMMENT, false);

            // Don't show the assembler ident line.  You can make a case for this being
            // mandatory, since the generated code is only guaranteed to work with the
            // assembler for which it was targeted, but I expect we'll quickly get to a
            // place where we don't have to work around assembler bugs, and this will just
            // become a nuisance.
            settings.SetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false);

            // Don't break lines with long labels.  That way we can redefine "long"
            // without breaking our tests.  (This is purely cosmetic.)
            settings.SetBool(AppSettings.SRCGEN_LONG_LABEL_NEW_LINE, false);

            // This could be on or off.  Off seems less distracting.
            settings.SetBool(AppSettings.SRCGEN_SHOW_CYCLE_COUNTS, false);

            // Disable label localization.  We want to be able to play with this a bit
            // without disrupting all the other tests.  Use a test-only feature to enable
            // it for the localization test.
            settings.SetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, true);

            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();

            while (iter.MoveNext())
            {
                AssemblerInfo.Id asmId     = iter.Current.AssemblerId;
                AssemblerConfig  curConfig =
                    AssemblerConfig.GetConfig(settings, asmId);
                AssemblerConfig defConfig =
                    AssemblerInfo.GetAssembler(asmId).GetDefaultConfig();

                // Merge the two together.  We want the default assembler config for most
                // things, but the executable path from the current config.
                defConfig.ExecutablePath = curConfig.ExecutablePath;

                // Write it into the test settings.
                AssemblerConfig.SetConfig(settings, asmId, defConfig);
            }

            return(settings);
        }
コード例 #7
0
ファイル: GenAndAsm.cs プロジェクト: theotherside/6502bench
        private void assemblerComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            AsmComboItem sel = (AsmComboItem)assemblerComboBox.SelectedItem;

            if (mSelectedAssemblerId != sel.AssemblerId)
            {
                // Selection changed, discard window contents.
                mSelectedAssemblerId = sel.AssemblerId;
                AppSettings.Global.SetString(AppSettings.SRCGEN_DEFAULT_ASM,
                                             mSelectedAssemblerId.ToString());
                ResetElements();
            }
        }
コード例 #8
0
        /// <summary>
        /// Assembler factory method.
        /// </summary>
        /// <param name="id">ID of assembler to return assembler object for.</param>
        /// <returns>New assembler interface object.</returns>
        public static IAssembler GetAssembler(AssemblerInfo.Id id)
        {
            switch (id)
            {
            case Id.Cc65:
                return(new AsmCc65());

            case Id.Merlin32:
                return(new AsmMerlin32());

            default:
                return(null);
            }
        }
コード例 #9
0
        /// <summary>
        /// Generator factory method.
        /// </summary>
        /// <param name="id">ID of assembler to return generator object for.</param>
        /// <returns>New source generator object.</returns>
        public static IGenerator GetGenerator(AssemblerInfo.Id id)
        {
            switch (id)
            {
            case Id.Cc65:
                return(new GenCc65());

            case Id.Merlin32:
                return(new GenMerlin32());

            default:
                return(null);
            }
        }
コード例 #10
0
 /// <summary>
 /// Returns the version information, or null if the query failed for this assembler.
 /// </summary>
 /// <param name="id">Assembler identifier.</param>
 /// <returns>Version info.</returns>
 public static AssemblerVersion GetVersion(AssemblerInfo.Id id)
 {
     if (!sQueried)
     {
         QueryVersions();
     }
     if (sVersions.TryGetValue(id, out AssemblerVersion vers))
     {
         return(vers);
     }
     else
     {
         return(null);
     }
 }
コード例 #11
0
ファイル: GenAndAsm.xaml.cs プロジェクト: retroric/6502bench
        /// <summary>
        /// Updates the selected assembler as the combo box selection changes.  This is
        /// expected to be called during the window load event, to initialize the field.
        /// </summary>
        private void AssemblerComboBox_SelectionChanged(object sender,
                                                        SelectionChangedEventArgs e)
        {
            AsmComboItem sel = (AsmComboItem)assemblerComboBox.SelectedItem;

            if (sel == null)
            {
                // this happens on Items.Clear()
                return;
            }
            if (mSelectedAssemblerId != sel.AssemblerId)
            {
                // Selection changed, discard window contents.
                mSelectedAssemblerId = sel.AssemblerId;
                AppSettings.Global.SetString(AppSettings.SRCGEN_DEFAULT_ASM,
                                             mSelectedAssemblerId.ToString());
                ResetElements();
            }
        }
コード例 #12
0
 private static string GetSettingName(AssemblerInfo.Id id)
 {
     return(AppSettings.ASM_CONFIG_PREFIX + id.ToString());
 }