Пример #1
0
        // IGenerator
        public List <string> GenerateSource(BackgroundWorker worker)
        {
            List <string> pathNames = new List <string>(1);

            string fileName = mFileNameBase + ASM_FILE_SUFFIX;
            string pathName = Path.Combine(mWorkDirectory, fileName);

            pathNames.Add(pathName);

            Formatter.FormatConfig config = new Formatter.FormatConfig();
            GenCommon.ConfigureFormatterFromSettings(Settings, ref config);
            config.mForceAbsOpcodeSuffix         = string.Empty;
            config.mForceLongOpcodeSuffix        = string.Empty;
            config.mForceAbsOperandPrefix        = "a:"; // absolute
            config.mForceLongOperandPrefix       = "f:"; // far
            config.mEndOfLineCommentDelimiter    = ";";
            config.mFullLineCommentDelimiterBase = ";";
            config.mBoxLineCommentDelimiter      = ";";
            config.mAllowHighAsciiCharConst      = false;
            config.mExpressionMode = Formatter.FormatConfig.ExpressionMode.Simple;
            SourceFormatter        = new Formatter(config);

            string msg = string.Format(Properties.Resources.PROGRESS_GENERATING_FMT, pathName);

            worker.ReportProgress(0, msg);

            mLocalizer = new LabelLocalizer(Project);
            if (!Settings.GetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, false))
            {
                mLocalizer.LocalPrefix = "@";
                mLocalizer.Analyze();
            }

            // Use UTF-8 encoding, without a byte-order mark.
            using (StreamWriter sw = new StreamWriter(pathName, false, new UTF8Encoding(false))) {
                mOutStream = sw;

                if (Settings.GetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false))
                {
                    if (mAsmVersion.IsValid && mAsmVersion <= V2_17)
                    {
                        OutputLine(SourceFormatter.FullLineCommentDelimiter +
                                   string.Format(Properties.Resources.GENERATED_FOR_VERSION,
                                                 "cc65", mAsmVersion.ToString()));
                    }
                    else
                    {
                        OutputLine(SourceFormatter.FullLineCommentDelimiter +
                                   string.Format(Properties.Resources.GENERATED_FOR_LATEST, "cc65"));
                    }
                }

                GenCommon.Generate(this, sw, worker);
            }
            mOutStream = null;

            return(pathNames);
        }