Conversation
|
|
||
|
|
||
| [OpCode(SmartContract.Framework.OpCode.CONVERT, "0x21")] | ||
| public extern static BigInteger ConvertToInteger(byte[] from); |
There was a problem hiding this comment.
Could we still use the AsByteArray as the function name?
There was a problem hiding this comment.
Maybe we should move these to SmartContract.Framework
There was a problem hiding this comment.
if we do not care about old contract code,we can direct change AsByteArray.
There was a problem hiding this comment.
Just ignore the old contract, as the previous version could not invoke contract successful. 😂
There was a problem hiding this comment.
ok,let us add more convert code in framework and compiler
因爲現在會返回integer類型了,不再是DataArray 2.修改了TypeConvert 應該現在 new byte[0] 直接是ByteArray類型了
…ect/neo-devpack-dotnet into Branch_lights_utconvert
|
I had do some fix now const value will got right type without convert. |
2.Use Helper.AsBigInteger() to convert to BigInteger 3.fix unittest
|
Helper.AsByteArray() fixed. |
|
I'll review it today. |
| /// </summary> | ||
| [Script] | ||
| [OpCode(OpCode.CONVERT, StackItemType_ByteArray)] | ||
| public extern static byte[] AsByteArray(this BigInteger source); |
There was a problem hiding this comment.
Maybe we need to update the comments later.
| var int3 = bts3.AsBigInteger(); | ||
|
|
||
| var arrobj = new object[8]; | ||
| arrobj[0] = int0; |
There was a problem hiding this comment.
I think we should add a test case for _ConvertPushBoolean.
There was a problem hiding this comment.
That's hard,in IL sometimes bool is int too.
| /// </summary> | ||
| [Script] | ||
| [OpCode(OpCode.CONVERT, StackItemType_ByteArray)] | ||
| public extern static byte[] AsByteArray(this byte source); |
There was a problem hiding this comment.
If we use CONVERT, we should rename the methods from As*** to To***. Because "As" implies the meaning of not performing the actual type conversion.
#196 because Insert a Opcode Convert but newarr still get last opcode for a PushNumber 2.add some unittest for it.
#196 because Insert a Opcode Convert but newarr still get last opcode for a PushNumber 2.add some unittest for it.
* this unittest for #195 * Clean code * 區分push pushNumber pushBoolean pushDataArray 過去合約中所有的數值是統一的Push 小於等於16的數字 和 byte[0] 和 true false 是Integer >16的數字 和 byte[n>0] 是 ByteArray 現在在合約中使用數值將直接得到正確的類型 new byte[0] 是ByteArray true 是Boolean 17 是Integer * 1.修改了unittest null 因爲現在會返回integer類型了,不再是DataArray 2.修改了TypeConvert 應該現在 new byte[0] 直接是ByteArray類型了 * 1.Use Helper.AsByteArray() to convert to ByteArray 2.Use Helper.AsBigInteger() to convert to BigInteger 3.fix unittest * fix one small fault. * add value equal test * Clean code * Clean code * fix format Co-authored-by: Shargon <shargon@gmail.com>
#196 because Insert a Opcode Convert but newarr still get last opcode for a PushNumber 2.add some unittest for it.
* this unittest for #195 * Clean code * 區分push pushNumber pushBoolean pushDataArray 過去合約中所有的數值是統一的Push 小於等於16的數字 和 byte[0] 和 true false 是Integer >16的數字 和 byte[n>0] 是 ByteArray 現在在合約中使用數值將直接得到正確的類型 new byte[0] 是ByteArray true 是Boolean 17 是Integer * 1.修改了unittest null 因爲現在會返回integer類型了,不再是DataArray 2.修改了TypeConvert 應該現在 new byte[0] 直接是ByteArray類型了 * 1.Use Helper.AsByteArray() to convert to ByteArray 2.Use Helper.AsBigInteger() to convert to BigInteger 3.fix unittest * fix one small fault. * add value equal test * Clean code * Clean code * fix format Co-authored-by: Shargon <shargon@gmail.com>
#196 because Insert a Opcode Convert but newarr still get last opcode for a PushNumber 2.add some unittest for it.
fixed #195