diff --git a/src/Neo.Compiler.CSharp/MethodConvert/Statement/ReturnStatement.cs b/src/Neo.Compiler.CSharp/MethodConvert/Statement/ReturnStatement.cs index 740119e47..dc08c7f26 100644 --- a/src/Neo.Compiler.CSharp/MethodConvert/Statement/ReturnStatement.cs +++ b/src/Neo.Compiler.CSharp/MethodConvert/Statement/ReturnStatement.cs @@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Neo.VM; +using System.Collections.Generic; namespace Neo.Compiler { @@ -44,10 +45,28 @@ private void ConvertReturnStatement(SemanticModel model, ReturnStatementSyntax s { if (syntax.Expression is not null) ConvertExpression(model, syntax.Expression); - if (_tryStack.Count > 0) - Jump(OpCode.ENDTRY_L, _returnTarget); - else - Jump(OpCode.JMP_L, _returnTarget); + + // The following case is not considered: + // Method -> try (with finally) -> function in method -> return from function in method + JumpTarget? returnTarget = _returnTarget; + List visitedTry = []; // from shallow to deep + foreach (StatementContext sc in _generalStatementStack) + {// start from the deepest context + // stage the try stacks on the way + if (sc.StatementSyntax is TryStatementSyntax) + visitedTry.Add(sc); + } + + foreach (StatementContext sc in visitedTry) + // start from the most external try + // internal try should ENDTRY, targeting the correct external return target + returnTarget = sc.AddEndTry(returnTarget); + + Jump(OpCode.JMP_L, returnTarget); + // We could use ENDTRY if current statement calling `return` is a try statement, + // but this job can be done by the optimizer + // Note that, do not Jump(OpCode.ENDTRY_L, returnTarget) here, + // because the returnTarget here is already an ENDTRY_L for current try stack. } } } diff --git a/src/Neo.Compiler.CSharp/Optimizer/Strategies/JumpCompresser.cs b/src/Neo.Compiler.CSharp/Optimizer/Strategies/JumpCompresser.cs index c85bc939b..542f7769f 100644 --- a/src/Neo.Compiler.CSharp/Optimizer/Strategies/JumpCompresser.cs +++ b/src/Neo.Compiler.CSharp/Optimizer/Strategies/JumpCompresser.cs @@ -365,6 +365,7 @@ public static (NefFile, ContractManifest, JObject?) ReplaceJumpWithRet(NefFile n /// /// If an unconditional jump targets an unconditional jump, re-target the first unconditional jump to its final destination + /// If an unconditional jump targets an ENDTRY, replace the unconditional jump with ENDTRY /// If a conditional jump targets an unconditional jump, re-target the conditional jump to its final destination /// If an unconditional jump targets a conditional jump, DO NOT replace the unconditional jump with a conditional jump to its final destination. THIS IS WRONG. /// This should be executed very early, before @@ -415,6 +416,28 @@ public static (NefFile, ContractManifest, JObject?) FoldJump(NefFile nef, Contra jumpTargetToSources[finalTarget].Add(i); continue; } + if ((target.OpCode == OpCode.ENDTRY || target.OpCode == OpCode.ENDTRY_L) + && unconditionalJump.Contains(i.OpCode)) + {// replace this JMP with ENDTRY + modified = true; + Instruction finalTarget = jumpSourceToTargets[target]; + oldSequencePointAddressToNew.Add(a, newAddr); + // handle the reference of the deleted JMP + jumpSourceToTargets.Remove(i); + jumpTargetToSources[target].Remove(i); + // handle the reference of the added RET + Instruction newEndTry = new Script(new byte[] { (byte)OpCode.ENDTRY_L }.Concat(BitConverter.GetBytes(0)).ToArray()).GetInstruction(0); + // above is a workaround of new Instruction(OpCode.ENDTRY_L) + OptimizedScriptBuilder.RetargetJump(i, newEndTry, + jumpSourceToTargets, trySourceToTargets, jumpTargetToSources); + jumpSourceToTargets[newEndTry] = finalTarget; + jumpTargetToSources[finalTarget].Remove(i); + jumpTargetToSources[finalTarget].Add(newEndTry); + + simplifiedInstructionsToAddress.Add(newEndTry, newAddr); + newAddr += newEndTry.Size; + continue; + } } simplifiedInstructionsToAddress.Add(i, newAddr); newAddr += i.Size; diff --git a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Returns.cs b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Returns.cs index 4769756bd..067b25e65 100644 --- a/tests/Neo.Compiler.CSharp.TestContracts/Contract_Returns.cs +++ b/tests/Neo.Compiler.CSharp.TestContracts/Contract_Returns.cs @@ -10,6 +10,7 @@ // modifications are permitted. using Neo.SmartContract.Framework; +using Neo.SmartContract.Framework.Services; namespace Neo.Compiler.CSharp.TestContracts { @@ -56,5 +57,61 @@ public static ByteString ByteStringAdd(ByteString a, ByteString b) { return a + b; } + + private static int TryReturnInternal(bool exception) + { + int a = 0; + Storage.Put("\x00", "\x00"); + try + { + try + { + if (exception) + throw new System.Exception(); + else + return ++a; + } + catch { return ++a; } + finally + { + ExecutionEngine.Assert(Storage.Get("\x00")! == "\x00"); + Storage.Put("\x00", "\x01"); + a++; + if (exception) + throw new System.Exception(); + } + } + finally + { + ExecutionEngine.Assert(Storage.Get("\x00")! == "\x01"); + Storage.Put("\x00", "\x02"); + ++a; + } +#pragma warning disable CS0162 // Unreachable code detected + Storage.Put("\x00", "\x03"); +#pragma warning restore CS0162 // Unreachable code detected + } + + public static int TryReturn() + { + int a = 0; + // The following is an extremely dangerous case. + // catch { return ++a; } pushes an `a` into the evaluation stack + // but there is exception in finally, and the pushed `a` is never popped + // and its value is kept into current evaluation stack in TryReturn. + // No idea about the fix. + //try { a = TryReturnInternal(true); } + //catch + //{ + // ExecutionEngine.Assert(a == 0); + // a += 1; + //} + //finally { ExecutionEngine.Assert(Storage.Get("\x00")! == "\x02"); } + //ExecutionEngine.Assert(a == 1); + a = TryReturnInternal(false); + ExecutionEngine.Assert(a == 1); + ExecutionEngine.Assert(Storage.Get("\x00")! == "\x02"); + return ++a; + } } } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Break.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Break.cs index 12f7f5881..a6f80facc 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Break.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Break.cs @@ -16,7 +16,7 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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chBzaxO1RWsQlzk7DhMMAQMMAv8ANEdqOnQ9Aj00DAL/ADRaDAEDlzkMAQIMAv8ANCw/DAL/ADRFDAEClzkMAQMMAv8ANBc/aEGcCO2cJJEMAv8ANCgMAQOXOUBXAAJ5eEGb9mfOQeY/GIRAVwACeXhB9rRr4kHfMLiaQFcAAXhB9rRr4kGSXegxQI9uWGA=").AsSerializable(); #endregion @@ -26,14 +26,14 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// Unsafe method /// /// - /// Script: VwYBDAEADAL/ADVXAQAAEAwB/zVeAQAAcCIbaEHzVL8dcTsABT0XDAEBDAL/ADUzAQAAP2hBnAjtnCThDAL/ADVBAQAADAEBlzkQDAH/NSMBAABwImxoQfNUvx1xOxoxEHIiDgwJZXhjZXB0aW9uOmoTtSTxPUtyOwAHIhE9SwwBAAwC/wA12wAAAD898QwC/wA17wAAAAwBAJc5EhEQE8BKcspzEHQiFGpsznUMAQIMAv8ANa0AAAAiBmxrMOw/aEGcCO2cJJAMAv8ANbUAAAAMAQKXORAMAf81lwAAAHAibWhB81S/HXE7Gk8QcmoTtUV4Jg4MCWV4Y2VwdGlvbjo9THIQc2sTtUVrEJc5Ow4TDAEDDAL/ADRJajp0Ihk9NgwC/wA0XAwBA5c5DAECDAL/ADQuPz3pDAL/ADRFDAEClzkMAQMMAv8ANBc/aEGcCO2cJI8MAv8ANCgMAQOXOUA= + /// Script: VwYBDAEADAL/ADVTAQAAEAwB/zVaAQAAcCIbaEHzVL8dcTsABT0XDAEBDAL/ADUvAQAAP2hBnAjtnCThDAL/ADU9AQAADAEBlzkQDAH/NR8BAABwImpoQfNUvx1xOxovEHIiDgwJZXhjZXB0aW9uOmoTtSTxPUlyOwAHPQI9SQwBAAwC/wA11wAAAD8MAv8ANe0AAAAMAQCXORIREBPASnLKcxB0IhRqbM51DAECDAL/ADWrAAAAIgZsazDsP2hBnAjtnCSSDAL/ADWzAAAADAEClzkQDAH/NZUAAABwImtoQfNUvx1xOxpNEHJqE7VFeCYODAlleGNlcHRpb246PUpyEHNrE7VFaxCXOTsOEwwBAwwC/wA0R2o6dD0CPTQMAv8ANFoMAQOXOQwBAgwC/wA0LD8MAv8ANEUMAQKXOQwBAwwC/wA0Fz9oQZwI7ZwkkQwC/wA0KAwBA5c5QA== /// INITSLOT 0601 [64 datoshi] /// PUSHDATA1 00 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 57010000 [512 datoshi] + /// CALL_L 53010000 [512 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L 5E010000 [512 datoshi] + /// CALL_L 5A010000 [512 datoshi] /// STLOC0 [2 datoshi] /// JMP 1B [2 datoshi] /// LDLOC0 [2 datoshi] @@ -43,25 +43,25 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// ENDTRY 17 [4 datoshi] /// PUSHDATA1 01 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 33010000 [512 datoshi] + /// CALL_L 2F010000 [512 datoshi] /// ENDFINALLY [4 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] /// JMPIF E1 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 41010000 [512 datoshi] + /// CALL_L 3D010000 [512 datoshi] /// PUSHDATA1 01 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L 23010000 [512 datoshi] + /// CALL_L 1F010000 [512 datoshi] /// STLOC0 [2 datoshi] - /// JMP 6C [2 datoshi] + /// JMP 6A [2 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC1 [2 datoshi] - /// TRY 1A31 [4 datoshi] + /// TRY 1A2F [4 datoshi] /// PUSH0 [1 datoshi] /// STLOC2 [2 datoshi] /// JMP 0E [2 datoshi] @@ -71,18 +71,17 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// PUSH3 [1 datoshi] /// LT [8 datoshi] /// JMPIF F1 [2 datoshi] - /// ENDTRY 4B [4 datoshi] + /// ENDTRY 49 [4 datoshi] /// STLOC2 [2 datoshi] /// TRY 0007 [4 datoshi] - /// JMP 11 [2 datoshi] - /// ENDTRY 4B [4 datoshi] + /// ENDTRY 02 [4 datoshi] + /// ENDTRY 49 [4 datoshi] /// PUSHDATA1 00 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L DB000000 [512 datoshi] + /// CALL_L D7000000 [512 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY F1 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L EF000000 [512 datoshi] + /// CALL_L ED000000 [512 datoshi] /// PUSHDATA1 00 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] @@ -104,7 +103,7 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// STLOC5 [2 datoshi] /// PUSHDATA1 02 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L AD000000 [512 datoshi] + /// CALL_L AB000000 [512 datoshi] /// JMP 06 [2 datoshi] /// LDLOC4 [2 datoshi] /// LDLOC3 [2 datoshi] @@ -112,21 +111,21 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// ENDFINALLY [4 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF 90 [2 datoshi] + /// JMPIF 92 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L B5000000 [512 datoshi] + /// CALL_L B3000000 [512 datoshi] /// PUSHDATA1 02 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L 97000000 [512 datoshi] + /// CALL_L 95000000 [512 datoshi] /// STLOC0 [2 datoshi] - /// JMP 6D [2 datoshi] + /// JMP 6B [2 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC1 [2 datoshi] - /// TRY 1A4F [4 datoshi] + /// TRY 1A4D [4 datoshi] /// PUSH0 [1 datoshi] /// STLOC2 [2 datoshi] /// LDLOC2 [2 datoshi] @@ -137,7 +136,7 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// JMPIFNOT 0E [2 datoshi] /// PUSHDATA1 657863657074696F6E 'exception' [8 datoshi] /// THROW [512 datoshi] - /// ENDTRY 4C [4 datoshi] + /// ENDTRY 4A [4 datoshi] /// STLOC2 [2 datoshi] /// PUSH0 [1 datoshi] /// STLOC3 [2 datoshi] @@ -152,22 +151,21 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// TRY 0E13 [4 datoshi] /// PUSHDATA1 03 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 49 [512 datoshi] + /// CALL 47 [512 datoshi] /// LDLOC2 [2 datoshi] /// THROW [512 datoshi] /// STLOC4 [2 datoshi] - /// JMP 19 [2 datoshi] - /// ENDTRY 36 [4 datoshi] + /// ENDTRY 02 [4 datoshi] + /// ENDTRY 34 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 5C [512 datoshi] + /// CALL 5A [512 datoshi] /// PUSHDATA1 03 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSHDATA1 02 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 2E [512 datoshi] + /// CALL 2C [512 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY E9 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] /// CALL 45 [512 datoshi] /// PUSHDATA1 02 [8 datoshi] @@ -179,7 +177,7 @@ public abstract class Contract_Break(Neo.SmartContract.Testing.SmartContractInit /// ENDFINALLY [4 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF 8F [2 datoshi] + /// JMPIF 91 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] /// CALL 28 [512 datoshi] /// PUSHDATA1 03 [8 datoshi] diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Continue.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Continue.cs index ea1ab3d10..17a2fa16f 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Continue.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Continue.cs @@ -16,7 +16,7 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0TAlcGAQwBAAwC/wA12gEAABAMAf814QEAAHAiG2hB81S/HXE7AAU9DwwBAQwC/wA1tgEAAD9oQZwI7Zwk4QwC/wA1xAEAAAwBAZc5EAwB/zWmAQAAcCJ3aEHzVL8dcTsaNBByIg4MCWV4Y2VwdGlvbjpqE7Uk8T1Wcgkk/zsAByIRPUsMAQAMAv8ANVsBAAA/PfEMAv8ANW8BAAAMAQCXORIREBPASnLKcxB0IhxqbM51bRK1JgQiDgwBAgwC/wA1JgEAAGycdGxrMOQ/aEGcCO2cJIUMAv8ANS0BAAAMAQKXORAMAf81DwEAAHAj4gAAAGhB81S/HXE8VwAAAMEAAAAQciIzapxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcmoTtSTMeCYODAlleGNlcHRpb246PoQAAAByEHNr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5eEH2tGviQd8wuJpAVwABeEH2tGviQZJd6DFAWIz11w==").AsSerializable(); #endregion @@ -26,14 +26,14 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// Unsafe method /// /// - /// Script: VwYBDAEADAL/ADXaAQAAEAwB/zXhAQAAcCIbaEHzVL8dcTsABT0PDAEBDAL/ADW2AQAAP2hBnAjtnCThDAL/ADXEAQAADAEBlzkQDAH/NaYBAABwIndoQfNUvx1xOxo0EHIiDgwJZXhjZXB0aW9uOmoTtSTxPVZyCST/OwAHIhE9SwwBAAwC/wA1WwEAAD898QwC/wA1bwEAAAwBAJc5EhEQE8BKcspzEHQiHGpsznVtErUmBCIODAECDAL/ADUmAQAAbJx0bGsw5D9oQZwI7ZwkhQwC/wA1LQEAAAwBApc5EAwB/zUPAQAAcCPiAAAAaEHzVL8dcTxXAAAAwQAAABByIjNqnEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9yahO1JMx4Jg4MCWV4Y2VwdGlvbjo+hAAAAHIQc2sTtSY2axGeSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3MiyWsTlzk7DhMMAQMMAv8ANExqOnQiGT0uDAL/ADRfDAEDlzkMAQIMAv8ANDE/PekMAv8ANEgMAQKXOQwBAwwC/wA0Gj9oQZwI7ZwlHf///wwC/wA0KAwBA5c5QA== + /// Script: VwYBDAEADAL/ADXTAQAAEAwB/zXaAQAAcCIbaEHzVL8dcTsABT0PDAEBDAL/ADWvAQAAP2hBnAjtnCThDAL/ADW9AQAADAEBlzkQDAH/NZ8BAABwInVoQfNUvx1xOxoyEHIiDgwJZXhjZXB0aW9uOmoTtSTxPVRyCST/OwAHPQI9SQwBAAwC/wA1VAEAAD8MAv8ANWoBAAAMAQCXORIREBPASnLKcxB0IhxqbM51bRK1JgQiDgwBAgwC/wA1IQEAAGycdGxrMOQ/aEGcCO2cJIcMAv8ANSgBAAAMAQKXORAMAf81CgEAAHAj3QAAAGhB81S/HXE8VAAAALwAAAAQciIzapxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcmoTtSTMeCYODAlleGNlcHRpb246PX9yEHNrE7UmNmsRnkoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9zIslrE5c5Ow4TDAEDDAL/ADRKajp0PQI9LAwC/wA0XQwBA5c5DAECDAL/ADQvPwwC/wA0SAwBApc5DAEDDAL/ADQaP2hBnAjtnCUi////DAL/ADQoDAEDlzlA /// INITSLOT 0601 [64 datoshi] /// PUSHDATA1 00 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L DA010000 [512 datoshi] + /// CALL_L D3010000 [512 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L E1010000 [512 datoshi] + /// CALL_L DA010000 [512 datoshi] /// STLOC0 [2 datoshi] /// JMP 1B [2 datoshi] /// LDLOC0 [2 datoshi] @@ -43,25 +43,25 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// ENDTRY 0F [4 datoshi] /// PUSHDATA1 01 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L B6010000 [512 datoshi] + /// CALL_L AF010000 [512 datoshi] /// ENDFINALLY [4 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] /// JMPIF E1 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L C4010000 [512 datoshi] + /// CALL_L BD010000 [512 datoshi] /// PUSHDATA1 01 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L A6010000 [512 datoshi] + /// CALL_L 9F010000 [512 datoshi] /// STLOC0 [2 datoshi] - /// JMP 77 [2 datoshi] + /// JMP 75 [2 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC1 [2 datoshi] - /// TRY 1A34 [4 datoshi] + /// TRY 1A32 [4 datoshi] /// PUSH0 [1 datoshi] /// STLOC2 [2 datoshi] /// JMP 0E [2 datoshi] @@ -71,20 +71,19 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// PUSH3 [1 datoshi] /// LT [8 datoshi] /// JMPIF F1 [2 datoshi] - /// ENDTRY 56 [4 datoshi] + /// ENDTRY 54 [4 datoshi] /// STLOC2 [2 datoshi] /// PUSHF [1 datoshi] /// JMPIF FF [2 datoshi] /// TRY 0007 [4 datoshi] - /// JMP 11 [2 datoshi] - /// ENDTRY 4B [4 datoshi] + /// ENDTRY 02 [4 datoshi] + /// ENDTRY 49 [4 datoshi] /// PUSHDATA1 00 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 5B010000 [512 datoshi] + /// CALL_L 54010000 [512 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY F1 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 6F010000 [512 datoshi] + /// CALL_L 6A010000 [512 datoshi] /// PUSHDATA1 00 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] @@ -111,7 +110,7 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// JMP 0E [2 datoshi] /// PUSHDATA1 02 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 26010000 [512 datoshi] + /// CALL_L 21010000 [512 datoshi] /// LDLOC4 [2 datoshi] /// INC [4 datoshi] /// STLOC4 [2 datoshi] @@ -121,21 +120,21 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// ENDFINALLY [4 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF 85 [2 datoshi] + /// JMPIF 87 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 2D010000 [512 datoshi] + /// CALL_L 28010000 [512 datoshi] /// PUSHDATA1 02 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L 0F010000 [512 datoshi] + /// CALL_L 0A010000 [512 datoshi] /// STLOC0 [2 datoshi] - /// JMP_L E2000000 [2 datoshi] + /// JMP_L DD000000 [2 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC1 [2 datoshi] - /// TRY_L 57000000C1000000 [4 datoshi] + /// TRY_L 54000000BC000000 [4 datoshi] /// PUSH0 [1 datoshi] /// STLOC2 [2 datoshi] /// JMP 33 [2 datoshi] @@ -164,7 +163,7 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// JMPIFNOT 0E [2 datoshi] /// PUSHDATA1 657863657074696F6E 'exception' [8 datoshi] /// THROW [512 datoshi] - /// ENDTRY_L 84000000 [4 datoshi] + /// ENDTRY 7F [4 datoshi] /// STLOC2 [2 datoshi] /// PUSH0 [1 datoshi] /// STLOC3 [2 datoshi] @@ -198,22 +197,21 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// TRY 0E13 [4 datoshi] /// PUSHDATA1 03 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 4C [512 datoshi] + /// CALL 4A [512 datoshi] /// LDLOC2 [2 datoshi] /// THROW [512 datoshi] /// STLOC4 [2 datoshi] - /// JMP 19 [2 datoshi] - /// ENDTRY 2E [4 datoshi] + /// ENDTRY 02 [4 datoshi] + /// ENDTRY 2C [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 5F [512 datoshi] + /// CALL 5D [512 datoshi] /// PUSHDATA1 03 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSHDATA1 02 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 31 [512 datoshi] + /// CALL 2F [512 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY E9 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] /// CALL 48 [512 datoshi] /// PUSHDATA1 02 [8 datoshi] @@ -225,7 +223,7 @@ public abstract class Contract_Continue(Neo.SmartContract.Testing.SmartContractI /// ENDFINALLY [4 datoshi] /// LDLOC0 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF_L 1DFFFFFF [2 datoshi] + /// JMPIF_L 22FFFFFF [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] /// CALL 28 [512 datoshi] /// PUSHDATA1 03 [8 datoshi] diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Foreach.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Foreach.cs index 445595614..761655abf 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Foreach.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Foreach.cs @@ -16,7 +16,7 @@ public abstract class Contract_Foreach(Neo.SmartContract.Testing.SmartContractIn /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHA7znO4OTpJcbCoGp54UQN2G/OrARpdG9hAQABDwAA/WMFVwYAFBMSERTAcBBxaEpyynMQdCI7amzOdWltnkoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9xbJx0bGswxWlAVwYADANoaWoMA2RlZgwDYWJjE8BwDABxaEpyynMQdCIPamzOdWlti9socWycdGxrMPFpQFcBAAwAcGjKQFcGAAw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kUoC////fzIMAwAAAAABAAAAn3FsnHRsazC8PQVyPQJpQFcDABQTEhEUwHAQcRByImlpaGrOnkoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9xakqcSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3JFamjKtSSVaUBXAwATQZv2Z84TEYhOEFHQUBLAwUVB3zC4mnBocSIRaUHzVL8dcmrbKEHP50eWaUGcCO2cJOtAEr8SvxLAQFcFADT2SnDKcRByIh5oas7BRXN0azcAAAwCOiCLbIvbKEHP50eWapxyamkw4kBXAQAQcGg3AABBz+dHlmhKnEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9wRWgVtSTBQFcBABBwaBW1JkBoNwAAQc/nR5ZoSpxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcEUiv0ASHSgz").AsSerializable(); + public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHA7znO4OTpJcbCoGp54UQN2G/OrARpdG9hAQABDwAA/WMFVwYAFBMSERTAcBBxaEpyynMQdCI7amzOdWltnkoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9xbJx0bGswxWlAVwYADANoaWoMA2RlZgwDYWJjE8BwDABxaEpyynMQdCIPamzOdWlti9socWycdGxrMPFpQFcBAAwAcGjKQFcGAAwADAAMA2hpagwDZGVmDANhYmMVwHAMAHFoSnLKcxB0Ig9qbM51aW2L2yhxbJx0bGsw8WlAVwgAEAsSv3AMBXRlc3QxSmgQUdBFEUpoEVHQRRALEr9xDAV0ZXN0MkppEFHQRRJKaRFR0EVpaBLAcshzakp0ynUQdiIXbG7OdwdvBxHOS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AAAn3JFamjKtSSVaUBXAwATQZv2Z84TEYhOEFHQUBLAwUVB3zC4mnBocSIRaUHzVL8dcmrbKEHP50eWaUGcCO2cJOtAEr8SvxLAQFcFADT2SnDKcRByIh5oas7BRXN0azcAAAwCOiCLbIvbKEHP50eWapxyamkw4kBXAQAQcGg3AABBz+dHlmhKnEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9wRWgVtSTBQFcBABBwaBW1JkBoNwAAQc/nR5ZoSpxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcEUiv0CEj7kK").AsSerializable(); #endregion @@ -281,7 +281,7 @@ public abstract class Contract_Foreach(Neo.SmartContract.Testing.SmartContractIn /// Unsafe method /// /// - /// Script: VwYBFBMSERTAcBBxPIkAAAAAAAAAaEpyynMQdCJzamzOdXhKnUoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ+AELYmBCI7aW2eSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3FsnHRsazCNPQVyPQJpQA== + /// Script: VwYBFBMSERTAcBBxPIkAAAAAAAAAaEpyynMQdCJzamzOdXhKnUoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ+AELYmBD1AaW2eSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3FsnHRsazCNPQVyPQJpQA== /// INITSLOT 0601 [64 datoshi] /// PUSH4 [1 datoshi] /// PUSH3 [1 datoshi] @@ -326,7 +326,7 @@ public abstract class Contract_Foreach(Neo.SmartContract.Testing.SmartContractIn /// PUSH0 [1 datoshi] /// LE [8 datoshi] /// JMPIFNOT 04 [2 datoshi] - /// JMP 3B [2 datoshi] + /// ENDTRY 40 [4 datoshi] /// LDLOC1 [2 datoshi] /// LDLOC5 [2 datoshi] /// ADD [8 datoshi] diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_GoTo.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_GoTo.cs index 8cffe6122..bafd724a9 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_GoTo.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_GoTo.cs @@ -16,7 +16,7 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP1vAlcBABFwaEqcSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3BFaBOXJspoQFcCABFwO0AAaEqcSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn3BFaBOXJgVoPQk9BXE9AiK9QFcJAQwBAAwC/wA1rAEAAAhwEAwB/zWxAQAAcWlyIl1qQfNUvx1zOwAtaHRsCJckC2zYJAdsCZckGDsAByIVPdMMAv8ANZIBAAAMAQCXOT89Mz3taHRsCJckDWzYJA1sCZckDCIKC3AiEglwIg4MAQEMAv8ANUIBAAA/akGcCO2cJJ9oCZc5DAL/ADVMAQAADAEBlzkQDAH/NS4BAAByInxqQfNUvx1zOw8mDAlleGNlcHRpb246dDsAByIRPWYMAQAMAv8ANfEAAAA/PfEMAv8ANQUBAAAMAQCXORIREA8UwEp0ynUQdiIubG7OdwdvB3cIbwgQlyQcbwgRlyQWbwgSlyQEIg4MAQIMAv8ANakAAABunHZubTDSP2pBnAjtnCSADAL/ADWwAAAADAEClzkQDAH/NZIAAAByImhqQfNUvx1zOx9KeHRsCZckFWwIlyQEIg4MCWV4Y2VwdGlvbjo9QnQ7DhMMAQMMAv8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5c5QFcAAnl4QZv2Z85B5j8YhEBXAAJ5eEH2tGviQd8wuJpAVwABeEH2tGviQZJd6DFAsc9hzg==").AsSerializable(); #endregion @@ -106,24 +106,24 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// Unsafe method /// /// - /// Script: VwkBDAEADAL/ADWsAQAACHAQDAH/NbEBAABxaXIiXWpB81S/HXM7AC1odGwIlyQLbNgkB2wJlyQYOwAHIhU90wwC/wA1kgEAAAwBAJc5Pz0zPe1odGwIlyQNbNgkDWwJlyQMIgoLcCISCXAiDgwBAQwC/wA1QgEAAD9qQZwI7Zwkn2gJlzkMAv8ANUwBAAAMAQGXORAMAf81LgEAAHIifGpB81S/HXM7DyYMCWV4Y2VwdGlvbjp0OwAHIhE9ZgwBAAwC/wA18QAAAD898QwC/wA1BQEAAAwBAJc5EhEQDxTASnTKdRB2Ii5sbs53B28HdwhvCBCXJBxvCBGXJBZvCBKXJAQiDgwBAgwC/wA1qQAAAG6cdm5tMNI/akGcCO2cJIAMAv8ANbAAAAAMAQKXORAMAf81kgAAAHIiaGpB81S/HXM7H0p4dGwJlyQVbAiXJAQiDgwJZXhjZXB0aW9uOj1CdDsOEwwBAwwC/wA0SWw6dSIZPTYMAv8ANFwMAQOXOQwBAgwC/wA0Lj896QwC/wA0RQwBApc5DAEDDAL/ADQXP2pBnAjtnCSUDAL/ADQoDAEDlzlA + /// Script: VwkBDAEADAL/ADWmAQAACHAQDAH/NasBAABxaXIiW2pB81S/HXM7ACtodGwIlyQLbNgkB2wJlyQYOwAHPQI90wwC/wA1jAEAAAwBAJc5Pz0xaHRsCJckDWzYJA1sCZckDCIKC3AiEglwIg4MAQEMAv8ANT4BAAA/akGcCO2cJKFoCZc5DAL/ADVIAQAADAEBlzkQDAH/NSoBAAByInpqQfNUvx1zOw8kDAlleGNlcHRpb246dDsABz0CPWQMAQAMAv8ANe0AAAA/DAL/ADUDAQAADAEAlzkSERAPFMBKdMp1EHYiLmxuzncHbwd3CG8IEJckHG8IEZckFm8IEpckBCIODAECDAL/ADWnAAAAbpx2bm0w0j9qQZwI7ZwkggwC/wA1rgAAAAwBApc5EAwB/zWQAAAAciJmakHzVL8dczsfSHh0bAmXJBVsCJckBD1ODAlleGNlcHRpb246PUB0Ow4TDAEDDAL/ADRHbDp1PQI9NAwC/wA0WgwBA5c5DAECDAL/ADQsPwwC/wA0RQwBApc5DAEDDAL/ADQXP2pBnAjtnCSWDAL/ADQoDAEDlzlA /// INITSLOT 0901 [64 datoshi] /// PUSHDATA1 00 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L AC010000 [512 datoshi] + /// CALL_L A6010000 [512 datoshi] /// PUSHT [1 datoshi] /// STLOC0 [2 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L B1010000 [512 datoshi] + /// CALL_L AB010000 [512 datoshi] /// STLOC1 [2 datoshi] /// LDLOC1 [2 datoshi] /// STLOC2 [2 datoshi] - /// JMP 5D [2 datoshi] + /// JMP 5B [2 datoshi] /// LDLOC2 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC3 [2 datoshi] - /// TRY 002D [4 datoshi] + /// TRY 002B [4 datoshi] /// LDLOC0 [2 datoshi] /// STLOC4 [2 datoshi] /// LDLOC4 [2 datoshi] @@ -138,16 +138,15 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// EQUAL [32 datoshi] /// JMPIF 18 [2 datoshi] /// TRY 0007 [4 datoshi] - /// JMP 15 [2 datoshi] + /// ENDTRY 02 [4 datoshi] /// ENDTRY D3 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 92010000 [512 datoshi] + /// CALL_L 8C010000 [512 datoshi] /// PUSHDATA1 00 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY 33 [4 datoshi] - /// ENDTRY ED [4 datoshi] + /// ENDTRY 31 [4 datoshi] /// LDLOC0 [2 datoshi] /// STLOC4 [2 datoshi] /// LDLOC4 [2 datoshi] @@ -170,42 +169,41 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// JMP 0E [2 datoshi] /// PUSHDATA1 01 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 42010000 [512 datoshi] + /// CALL_L 3E010000 [512 datoshi] /// ENDFINALLY [4 datoshi] /// LDLOC2 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF 9F [2 datoshi] + /// JMPIF A1 [2 datoshi] /// LDLOC0 [2 datoshi] /// PUSHF [1 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 4C010000 [512 datoshi] + /// CALL_L 48010000 [512 datoshi] /// PUSHDATA1 01 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L 2E010000 [512 datoshi] + /// CALL_L 2A010000 [512 datoshi] /// STLOC2 [2 datoshi] - /// JMP 7C [2 datoshi] + /// JMP 7A [2 datoshi] /// LDLOC2 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC3 [2 datoshi] - /// TRY 0F26 [4 datoshi] + /// TRY 0F24 [4 datoshi] /// PUSHDATA1 657863657074696F6E 'exception' [8 datoshi] /// THROW [512 datoshi] /// STLOC4 [2 datoshi] /// TRY 0007 [4 datoshi] - /// JMP 11 [2 datoshi] - /// ENDTRY 66 [4 datoshi] + /// ENDTRY 02 [4 datoshi] + /// ENDTRY 64 [4 datoshi] /// PUSHDATA1 00 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L F1000000 [512 datoshi] + /// CALL_L ED000000 [512 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY F1 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L 05010000 [512 datoshi] + /// CALL_L 03010000 [512 datoshi] /// PUSHDATA1 00 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] @@ -243,7 +241,7 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// JMP 0E [2 datoshi] /// PUSHDATA1 02 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L A9000000 [512 datoshi] + /// CALL_L A7000000 [512 datoshi] /// LDLOC6 [2 datoshi] /// INC [4 datoshi] /// STLOC6 [2 datoshi] @@ -253,21 +251,21 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// ENDFINALLY [4 datoshi] /// LDLOC2 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF 80 [2 datoshi] + /// JMPIF 82 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL_L B0000000 [512 datoshi] + /// CALL_L AE000000 [512 datoshi] /// PUSHDATA1 02 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSH0 [1 datoshi] /// PUSHDATA1 FF '?' [8 datoshi] - /// CALL_L 92000000 [512 datoshi] + /// CALL_L 90000000 [512 datoshi] /// STLOC2 [2 datoshi] - /// JMP 68 [2 datoshi] + /// JMP 66 [2 datoshi] /// LDLOC2 [2 datoshi] /// SYSCALL F354BF1D 'System.Iterator.Value' [16 datoshi] /// STLOC3 [2 datoshi] - /// TRY 1F4A [4 datoshi] + /// TRY 1F48 [4 datoshi] /// LDARG0 [2 datoshi] /// STLOC4 [2 datoshi] /// LDLOC4 [2 datoshi] @@ -278,30 +276,29 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// PUSHT [1 datoshi] /// EQUAL [32 datoshi] /// JMPIF 04 [2 datoshi] - /// JMP 0E [2 datoshi] + /// ENDTRY 4E [4 datoshi] /// PUSHDATA1 657863657074696F6E 'exception' [8 datoshi] /// THROW [512 datoshi] - /// ENDTRY 42 [4 datoshi] + /// ENDTRY 40 [4 datoshi] /// STLOC4 [2 datoshi] /// TRY 0E13 [4 datoshi] /// PUSHDATA1 03 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 49 [512 datoshi] + /// CALL 47 [512 datoshi] /// LDLOC4 [2 datoshi] /// THROW [512 datoshi] /// STLOC5 [2 datoshi] - /// JMP 19 [2 datoshi] - /// ENDTRY 36 [4 datoshi] + /// ENDTRY 02 [4 datoshi] + /// ENDTRY 34 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 5C [512 datoshi] + /// CALL 5A [512 datoshi] /// PUSHDATA1 03 [8 datoshi] /// EQUAL [32 datoshi] /// ASSERT [1 datoshi] /// PUSHDATA1 02 [8 datoshi] /// PUSHDATA1 FF00 [8 datoshi] - /// CALL 2E [512 datoshi] + /// CALL 2C [512 datoshi] /// ENDFINALLY [4 datoshi] - /// ENDTRY E9 [4 datoshi] /// PUSHDATA1 FF00 [8 datoshi] /// CALL 45 [512 datoshi] /// PUSHDATA1 02 [8 datoshi] @@ -313,7 +310,7 @@ public abstract class Contract_GoTo(Neo.SmartContract.Testing.SmartContractIniti /// ENDFINALLY [4 datoshi] /// LDLOC2 [2 datoshi] /// SYSCALL 9C08ED9C 'System.Iterator.Next' [32768 datoshi] - /// JMPIF 94 [2 datoshi] + /// JMPIF 96 [2 datoshi] /// PUSHDATA1 FF00 [8 datoshi] /// CALL 28 [512 datoshi] /// PUSHDATA1 03 [8 datoshi] diff --git a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Returns.cs b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Returns.cs index b64f66482..c56a2b60f 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Returns.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/TestingArtifacts/Contract_Returns.cs @@ -11,12 +11,12 @@ public abstract class Contract_Returns(Neo.SmartContract.Testing.SmartContractIn { #region Compiled data - public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_Returns"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""sum"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Integer"",""offset"":0,""safe"":false},{""name"":""subtract"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Integer"",""offset"":53,""safe"":false},{""name"":""div"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Array"",""offset"":106,""safe"":false},{""name"":""mix"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Integer"",""offset"":118,""safe"":false},{""name"":""byteStringAdd"",""parameters"":[{""name"":""a"",""type"":""ByteArray""},{""name"":""b"",""type"":""ByteArray""}],""returntype"":""ByteArray"",""offset"":136,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}"); + public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_Returns"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""sum"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Integer"",""offset"":0,""safe"":false},{""name"":""subtract"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Integer"",""offset"":53,""safe"":false},{""name"":""div"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Array"",""offset"":106,""safe"":false},{""name"":""mix"",""parameters"":[{""name"":""a"",""type"":""Integer""},{""name"":""b"",""type"":""Integer""}],""returntype"":""Integer"",""offset"":118,""safe"":false},{""name"":""byteStringAdd"",""parameters"":[{""name"":""a"",""type"":""ByteArray""},{""name"":""b"",""type"":""ByteArray""}],""returntype"":""ByteArray"",""offset"":136,""safe"":false},{""name"":""tryReturn"",""parameters"":[],""returntype"":""Integer"",""offset"":495,""safe"":false}],""events"":[]},""permissions"":[],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}"); /// /// Optimization: "All" /// - public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJFXAAJ4eZ5KAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfQFcAAnh5n0oCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9AVwACeHmieHmhEr9AVwICeXg070rBRXBxRWloNLBAVwACeHmL2yhAbONrzw==").AsSerializable(); + public static Neo.SmartContract.NefFile Nef => Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP08AlcAAnh5nkoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9AVwACeHmfSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn0BXAAJ4eaJ4eaESv0BXAgJ5eDTvSsFFcHFFaWg0sEBXAAJ4eYvbKEBXAgEQcAwBAAwBADU0AQAAPAAAAADqAAAAPEwAAACGAAAAeCYODAlleGNlcHRpb246aJxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfSnA9N3FonEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9KcD0CPqQAAAAMAQA1rQAAAAwBAJc5DAEBDAEANY0AAABoSpxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcEV4Jg4MCWV4Y2VwdGlvbjo/DAEANFIMAQGXOQwBAgwBADQ1aJxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfcD9AVwACeXhBm/ZnzkHmPxiEQFcAAXhB9rRr4kGSXegxQFcBABBwCTWc/v//cGgRlzkMAQA03gwBApc5aJxKAgAAAIAuBCIKSgL///9/Mh4D/////wAAAACRSgL///9/MgwDAAAAAAEAAACfSnBA/p4r7A==").AsSerializable(); #endregion @@ -135,5 +135,48 @@ public abstract class Contract_Returns(Neo.SmartContract.Testing.SmartContractIn [DisplayName("sum")] public abstract BigInteger? Sum(BigInteger? a, BigInteger? b); + /// + /// Unsafe method + /// + /// + /// Script: VwEAEHAJNZz+//9waBGXOQwBADTeDAEClzlonEoCAAAAgC4EIgpKAv///38yHgP/////AAAAAJFKAv///38yDAMAAAAAAQAAAJ9KcEA= + /// INITSLOT 0100 [64 datoshi] + /// PUSH0 [1 datoshi] + /// STLOC0 [2 datoshi] + /// PUSHF [1 datoshi] + /// CALL_L 9CFEFFFF [512 datoshi] + /// STLOC0 [2 datoshi] + /// LDLOC0 [2 datoshi] + /// PUSH1 [1 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// PUSHDATA1 00 [8 datoshi] + /// CALL DE [512 datoshi] + /// PUSHDATA1 02 [8 datoshi] + /// EQUAL [32 datoshi] + /// ASSERT [1 datoshi] + /// LDLOC0 [2 datoshi] + /// INC [4 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 00000080 [1 datoshi] + /// JMPGE 04 [2 datoshi] + /// JMP 0A [2 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 1E [2 datoshi] + /// PUSHINT64 FFFFFFFF00000000 [1 datoshi] + /// AND [8 datoshi] + /// DUP [2 datoshi] + /// PUSHINT32 FFFFFF7F [1 datoshi] + /// JMPLE 0C [2 datoshi] + /// PUSHINT64 0000000001000000 [1 datoshi] + /// SUB [8 datoshi] + /// DUP [2 datoshi] + /// STLOC0 [2 datoshi] + /// RET [0 datoshi] + /// + [DisplayName("tryReturn")] + public abstract BigInteger? TryReturn(); + #endregion } diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Foreach.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Foreach.cs index 7b47fa73e..c2c41d1e9 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Foreach.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Foreach.cs @@ -27,7 +27,7 @@ public void IntForeachTest() Assert.AreEqual(10, Contract.IntForeach()); AssertGasConsumed(1061400); Assert.AreEqual(6, Contract.IntForeachBreak(3)); - AssertGasConsumed(1125300); + AssertGasConsumed(1125240); } [TestMethod] @@ -36,7 +36,7 @@ public void IntForloopTest() Assert.AreEqual(10, Contract.IntForloop()); AssertGasConsumed(1064040); Assert.AreEqual(6, Contract.IntForeachBreak(3)); - AssertGasConsumed(1125300); + AssertGasConsumed(1125240); } [TestMethod] diff --git a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Returns.cs b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Returns.cs index 4ac157351..640547960 100644 --- a/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Returns.cs +++ b/tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Returns.cs @@ -56,5 +56,11 @@ public void Test_ByteStringAdd() { Assert.AreEqual("helloworld", Encoding.ASCII.GetString(Contract.ByteStringAdd(Encoding.ASCII.GetBytes("hello"), Encoding.ASCII.GetBytes("world"))!)); } + + [TestMethod] + public void Test_TryReturn() + { + Assert.AreEqual(2, Contract.TryReturn()); + } } }