Beispiel #1
0
        public override void Dump(ISimpleOutput tw, ParserOptions options)
        {
            if (options.XmlFormat)
            {
                base.Dump(tw, options);
                return;
            }

            if (options.Header)
            {
                tw.WriteLine("Program \"" + Name + "\" (length " + Length.ToString() + ") by \"" + Author + "\"");
                tw.WriteLine("");
            }
            if (options.Metainfo)
            {
                tw.WriteLine(";redcode");
                if (Name != null)
                    tw.WriteLine(";name " + Name);
                if (Author != null)
                    tw.WriteLine(";author " + Author);
                if (Date != null)
                    tw.WriteLine(";date " + Date);
                tw.WriteLine("");
            }
            if (options.Instructions)
            {
                if (options.Offset)
                {
                    tw.Write("   ");
                }
                if (options.Labels && Length > 0)
                {
                    tw.WriteLine("             ORG      " + this[StartOffset].Label);
                }
                else
                {
                    tw.WriteLine("       ORG      START");
                }
                for (int a = 0; a < Instructions.Count; a++)
                {
                    tw.WriteLine(this[a].GetLine(options, a == StartOffset));
                }
                tw.WriteLine("");
            }
        }
        public override string GetLine(ParserOptions options, bool start)
        {
            StringBuilder sb = new StringBuilder();
            if (options.Offset)
            {
                sb.Append(Address.ToString("00 "));
            }

            if (options.Labels)
            {
                if (Label != null)
                {
                    sb.Append(Label.PadRight(13));
                }
                else
                {
                    sb.Append("             ");
                }
            }
            else
            {
                if (start)
                {
                    sb.Append("START  ");
                }
                else
                {
                    sb.Append("       ");
                }
            }

            //operation and modifier
            sb.Append(Operation);
            sb.Append(".");
            sb.Append(Modifier.ToString().PadRight(3));

            //A
            sb.Append(ModeHelper.ToString(ModeA));
            if (options.Expressions)
            {
                if (ExpressionA != null)
                {
                    sb.Append(ExpressionA.PadLeft(12));
                }
                else
                {
                    sb.Append(ValueA.ToString().PadLeft(12));
                }
            }
            else
            {
                sb.Append(ValueA.ToString().PadLeft(6));
            }

            //B
            sb.Append(", ");
            sb.Append(ModeHelper.ToString(ModeB));
            if (options.Expressions)
            {
                if (ExpressionB != null)
                {
                    sb.Append(ExpressionB.PadLeft(12));
                }
                else
                {
                    sb.Append(ValueB.ToString().PadLeft(12));
                }
            }
            else
            {
                sb.Append(ValueB.ToString().PadLeft(6));
            }

            //comment
            if (options.Comments && Comment !=null && Comment.Length > 0)
            {
                int c = 35;
                if (options.Labels)
                    c += 6;
                if (options.Expressions)
                    c += 19;
                if (sb.Length < c)
                    sb.Append(' ', c);
                sb.Append(";");
                sb.Append(Comment);
            }
            return sb.ToString();
        }
Beispiel #3
0
 public virtual void Dump(string fileName, ParserOptions options)
 {
     StreamWriter sw = new StreamWriter(fileName);
     Dump(new WrappedTextWriter(sw), options);
     sw.Close();
 }
Beispiel #4
0
 public virtual void Dump(ISimpleOutput output, ParserOptions options)
 {
     if (options.XmlFormat)
     {
         StringWriter sw=new StringWriter();
         XmlSerializer serializer = new XmlSerializer(GetType());
         serializer.Serialize(sw, this);
         sw.Close();
         output.Write(sw.GetStringBuilder().ToString());
     }
     else
     {
         if (options.Header)
         {
             output.WriteLine("Program \"" + Name + "\" (length " + Length.ToString() + ") by \"" + Author + "\"");
             output.WriteLine("");
         }
         if (options.Instructions)
         {
             output.WriteLine("       ORG      START");
             for (int a = 0; a < Instructions.Count; a++)
             {
                 output.WriteLine(Instructions[a].GetLine(options, a == StartOffset));
             }
         }
     }
     output.WriteLine("");
 }
Beispiel #5
0
 public string GetLine(ParserOptions options, bool start)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 private static void DumpWarrior(IWarrior w, ParserOptions opt)
 {
     StreamWriter sw = new StreamWriter(w.FileName);
     WrappedTextWriter wr=new WrappedTextWriter(sw);
     w.Dump(wr, opt);
     sw.Close();
 }
Beispiel #7
0
        public virtual string GetLine(ParserOptions options, bool start)
        {
            StringBuilder sb = new StringBuilder();

            if (options.Offset)
                sb.Append("   ");
            if (start)
            {
                sb.Append("START  ");
            }
            else
            {
                sb.Append("       ");
            }
            if (options.Labels)
                sb.Append("      ");
            sb.Append(ToString());
            return sb.ToString();
        }