예제 #1
0
        public override void FormatFunctStart(TextWriter writer, Context ctx, FunctChunk funct)
        {
            writer.Write("[ ZR_{0:x5}", funct.PC);
            bool foundDefaults = false;

            for (int i = 0; i < funct.Locals.Length; i++)
            {
                writer.Write(" L{0:00}", i + 1);
                if (ctx.ZVersion < 5 && funct.Locals[i] != 0)
                {
                    foundDefaults = true;
                }
            }
            writer.Write(';');

            if (foundDefaults)
            {
                writer.WriteLine();
                writer.Write(INDENT);
                int count = 0;
                for (int i = 0; i < funct.Locals.Length; i++)
                {
                    if (funct.Locals[i] != 0)
                    {
                        if (++count > 0)
                        {
                            writer.Write(' ');
                        }
                        writer.Write("L{0:00}={1};", i + 1, funct.Locals[i]);
                    }
                }
            }

            writer.WriteLine();
        }
예제 #2
0
 public override void FormatFunctStart(TextWriter writer, Context ctx, FunctChunk funct)
 {
     writer.Write(INDENT + ".FUNCT ZR${0:X5}", funct.PC);
     for (int i = 0; i < funct.Locals.Length; i++)
     {
         writer.Write(',');
         writer.Write(FormatVariable((ushort)(i + 1)));
         if (ctx.ZVersion < 5)
         {
             if (funct.Locals[i] != 0)
             {
                 writer.Write("={0}", funct.Locals[i]);
             }
         }
     }
     writer.WriteLine();
 }
예제 #3
0
        static void ComposeFunc(Context ctx, Stream stream, BinaryReader rdr, RangeList <Chunk> ranges, int address)
        {
            stream.Seek(address, SeekOrigin.Begin);

            int locals    = rdr.ReadByte();
            var codeStart = address + 1;

            var localDefaults = new ushort[locals];

            if (ctx.ZVersion < 5)
            {
                codeStart += locals * 2;
                for (var i = 0; i < locals; i++)
                {
                    localDefaults[i] = rdr.ReadZWord();
                }
            }

            MeasureExtents(ctx, ranges, address, out _, out int maxExtent);

            var funct = new FunctChunk(address, codeStart - address)
            {
                Locals = localDefaults
            };

            ranges.AddRange(address, codeStart - address, funct);
            ranges.Coalesce(address, maxExtent,
                            (int s1, int l1, Chunk v1, int s2, int l2, Chunk v2, out Chunk nv) =>
            {
                if (v1 is FunctChunk fc)
                {
                    fc.Add(v2);
                    nv = fc;
                    return(true);
                }

                nv = null;
                return(false);
            });
        }
예제 #4
0
 public override void FormatFunctEnd(TextWriter writer, Context ctx, FunctChunk funct)
 {
     writer.WriteLine("\n];");
 }
예제 #5
0
 public abstract void FormatFunctEnd(TextWriter writer, Context ctx, FunctChunk funct);
예제 #6
0
 public override void FormatFunctEnd(TextWriter writer, Context ctx, FunctChunk funct)
 {
     // nada
 }