From c556939972d886d346c9e332f9e85d1de52943e5 Mon Sep 17 00:00:00 2001 From: arookas Date: Tue, 8 Mar 2016 16:20:13 -0500 Subject: [PATCH] Added conditional attribute to instruction tracing. This uses a lot less directive spam at the cost of the function still being compiled into the IL in release. --- ssc/binary.cs | 81 +-------------------------------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/ssc/binary.cs b/ssc/binary.cs index c1a5536..3939b9d 100644 --- a/ssc/binary.cs +++ b/ssc/binary.cs @@ -138,198 +138,138 @@ namespace arookas { case 0: WriteINT0(); return; case 1: WriteINT1(); return; } -#if DEBUG TraceInstruction("int {0} # ${0:X}", value); -#endif mText.Writer.Write8(0x00); mText.Writer.WriteS32(value); } public override void WriteFLT(float value) { -#if DEBUG TraceInstruction("flt {0}", value); -#endif mText.Writer.Write8(0x01); mText.Writer.WriteF32(value); } public override void WriteSTR(int index) { -#if DEBUG TraceInstruction("str {0}", index); -#endif mText.Writer.Write8(0x02); mText.Writer.WriteS32(index); } public override void WriteADR(uint value) { -#if DEBUG TraceInstruction("adr ${0:X8}", value); -#endif mText.Writer.Write8(0x03); mText.Writer.Write32(value); } public override void WriteVAR(int display, int index) { -#if DEBUG TraceInstruction("var {0} {1}", display, index); -#endif mText.Writer.Write8(0x04); mText.Writer.WriteS32(display); mText.Writer.WriteS32(index); } public override void WriteNOP() { -#if DEBUG TraceInstruction("nop"); -#endif mText.Writer.Write8(0x05); } public override void WriteINC(int display, int index) { -#if DEBUG TraceInstruction("inc {0} {1}", display, index); -#endif mText.Writer.Write8(0x06); mText.Writer.WriteS32(display); mText.Writer.WriteS32(index); } public override void WriteDEC(int display, int index) { -#if DEBUG TraceInstruction("dec {0} {1}", display, index); -#endif mText.Writer.Write8(0x07); mText.Writer.WriteS32(display); mText.Writer.WriteS32(index); } public override void WriteADD() { -#if DEBUG TraceInstruction("add"); -#endif mText.Writer.Write8(0x08); } public override void WriteSUB() { -#if DEBUG TraceInstruction("sub"); -#endif mText.Writer.Write8(0x09); } public override void WriteMUL() { -#if DEBUG TraceInstruction("mul"); -#endif mText.Writer.Write8(0x0A); } public override void WriteDIV() { -#if DEBUG TraceInstruction("div"); -#endif mText.Writer.Write8(0x0B); } public override void WriteMOD() { -#if DEBUG TraceInstruction("mod"); -#endif mText.Writer.Write8(0x0C); } public override void WriteASS(int display, int index) { -#if DEBUG TraceInstruction("ass {0} {1}", display, index); -#endif mText.Writer.Write8(0x0D); mText.Writer.Write8(0x04); // unused (skipped over by TSpcInterp) mText.Writer.WriteS32(display); mText.Writer.WriteS32(index); } public override void WriteEQ() { -#if DEBUG TraceInstruction("eq"); -#endif mText.Writer.Write8(0x0E); } public override void WriteNE() { -#if DEBUG TraceInstruction("ne"); -#endif mText.Writer.Write8(0x0F); } public override void WriteGT() { -#if DEBUG TraceInstruction("gt"); -#endif mText.Writer.Write8(0x10); } public override void WriteLT() { -#if DEBUG TraceInstruction("lt"); -#endif mText.Writer.Write8(0x11); } public override void WriteGE() { -#if DEBUG TraceInstruction("ge"); -#endif mText.Writer.Write8(0x12); } public override void WriteLE() { -#if DEBUG TraceInstruction("le"); -#endif mText.Writer.Write8(0x13); } public override void WriteNEG() { -#if DEBUG TraceInstruction("neg"); -#endif mText.Writer.Write8(0x14); } public override void WriteNOT() { -#if DEBUG TraceInstruction("not"); -#endif mText.Writer.Write8(0x15); } public override void WriteAND() { -#if DEBUG TraceInstruction("and"); -#endif mText.Writer.Write8(0x16); } public override void WriteOR() { -#if DEBUG TraceInstruction("or"); -#endif mText.Writer.Write8(0x17); } public override void WriteBAND() { -#if DEBUG TraceInstruction("band"); -#endif mText.Writer.Write8(0x18); } public override void WriteBOR() { -#if DEBUG TraceInstruction("bor"); -#endif mText.Writer.Write8(0x19); } public override void WriteSHL() { -#if DEBUG TraceInstruction("shl"); -#endif mText.Writer.Write8(0x1A); } public override void WriteSHR() { -#if DEBUG TraceInstruction("shr"); -#endif mText.Writer.Write8(0x1B); } public override void WriteCALL(uint offset, int count) { -#if DEBUG TraceInstruction("call ${0:X8} {1}", offset, count); -#endif mText.Writer.Write8(0x1C); mText.Writer.Write32(offset); mText.Writer.WriteS32(count); } public override void WriteFUNC(int index, int count) { -#if DEBUG TraceInstruction("func {0} {1}", index, count); -#endif mText.Writer.Write8(0x1D); mText.Writer.WriteS32(index); mText.Writer.WriteS32(count); @@ -342,69 +282,50 @@ namespace arookas { mText.Writer.WriteS32(count); } public override void WriteMKDS(int display) { -#if DEBUG TraceInstruction("mkds {0}", display); -#endif mText.Writer.Write8(0x1F); mText.Writer.WriteS32(display); } public override void WriteRET() { -#if DEBUG TraceInstruction("ret"); -#endif mText.Writer.Write8(0x20); } public override void WriteRET0() { -#if DEBUG TraceInstruction("ret0"); -#endif mText.Writer.Write8(0x21); } public override void WriteJNE(uint offset) { -#if DEBUG TraceInstruction("jne ${0:X8}", offset); -#endif mText.Writer.Write8(0x22); mText.Writer.Write32(offset); } public override void WriteJMP(uint offset) { -#if DEBUG TraceInstruction("jmp ${0:X8}", offset); -#endif mText.Writer.Write8(0x23); mText.Writer.Write32(offset); } public override void WritePOP() { -#if DEBUG TraceInstruction("pop"); -#endif mText.Writer.Write8(0x24); } public override void WriteINT0() { -#if DEBUG TraceInstruction("int0"); -#endif mText.Writer.Write8(0x25); } public override void WriteINT1() { -#if DEBUG TraceInstruction("int1"); -#endif mText.Writer.Write8(0x26); } public override void WriteEND() { -#if DEBUG TraceInstruction("end"); -#endif mText.Writer.Write8(0x27); } -#if DEBUG + [Conditional("DEBUG")] void TraceInstruction(string format, params object[] args) { var instruction = String.Format(format, args); Debug.WriteLine("{0:X8} {1}", mText.Size, instruction); } -#endif // data public override void WriteData(string data) {