diff --git a/src/Neo.Compiler.MSIL/MSIL/Conv_Multi.cs b/src/Neo.Compiler.MSIL/MSIL/Conv_Multi.cs index a6cdcb608..87b28811a 100644 --- a/src/Neo.Compiler.MSIL/MSIL/Conv_Multi.cs +++ b/src/Neo.Compiler.MSIL/MSIL/Conv_Multi.cs @@ -764,6 +764,21 @@ private int ConvertCall(OpCode src, NeoMethod to, List methodTokens Insert1(VM.OpCode.SYSCALL, "", to, BitConverter.GetBytes(ApplicationEngine.System_Binary_Atoi)); return 0; } + else if (src.tokenMethod == "System.Numerics.BigInteger System.Numerics.BigInteger::get_One()") + { + ConvertPushNumber(1, null, to); + return 0; + } + else if (src.tokenMethod == "System.Numerics.BigInteger System.Numerics.BigInteger::get_MinusOne()") + { + ConvertPushNumber(-1, null, to); + return 0; + } + else if (src.tokenMethod == "System.Numerics.BigInteger System.Numerics.BigInteger::get_Zero()") + { + ConvertPushNumber(0, null, to); + return 0; + } } if (calltype == 0) diff --git a/tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types_BigInteger.cs b/tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types_BigInteger.cs new file mode 100644 index 000000000..957183209 --- /dev/null +++ b/tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_Types_BigInteger.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Numerics; +using System.Runtime.CompilerServices; + +namespace Neo.Compiler.MSIL.UnitTests.TestClasses +{ + class Contract_Types_BigInteger : SmartContract.Framework.SmartContract + { + public static BigInteger Zero() { return BigInteger.Zero; } + public static BigInteger One() { return BigInteger.One; } + public static BigInteger MinusOne() { return BigInteger.MinusOne; } + public static BigInteger Parse(string value) { return BigInteger.Parse(value); } + } +} diff --git a/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Types.cs b/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Types.cs index 7422b020a..d33183b78 100644 --- a/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Types.cs +++ b/tests/Neo.Compiler.MSIL.UnitTests/UnitTest_Types.cs @@ -78,6 +78,41 @@ public void bool_Test() Assert.AreEqual(0, ((Integer)item).GetInteger()); } + [TestMethod] + public void bigInteer_Test() + { + var testengine = new TestEngine(); + testengine.AddEntryScript("./TestClasses/Contract_Types_BigInteger.cs"); + + // static vars + + var result = testengine.ExecuteTestCaseStandard("zero"); + var item = result.Pop(); + + Assert.IsInstanceOfType(item, typeof(Integer)); + Assert.AreEqual(BigInteger.Zero, ((Integer)item).GetInteger()); + + testengine.Reset(); + result = testengine.ExecuteTestCaseStandard("one"); + item = result.Pop(); + Assert.IsInstanceOfType(item, typeof(Integer)); + Assert.AreEqual(BigInteger.One, ((Integer)item).GetInteger()); + + testengine.Reset(); + result = testengine.ExecuteTestCaseStandard("minusOne"); + item = result.Pop(); + Assert.IsInstanceOfType(item, typeof(Integer)); + Assert.AreEqual(BigInteger.MinusOne, ((Integer)item).GetInteger()); + + // Parse + + testengine.Reset(); + result = testengine.ExecuteTestCaseStandard("parse", "456"); + item = result.Pop(); + Assert.IsInstanceOfType(item, typeof(Integer)); + Assert.AreEqual(456, item.GetInteger()); + } + [TestMethod] public void sbyte_Test() {