-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add abi offset #219
Merged
Merged
Add abi offset #219
Changes from 21 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
d353ee9
add abi offset
c90cb3e
fix
fcb7dc2
clean optimizer
lightszero 4af85aa
Clean code
shargon 132a190
Update NefOptimizeTool.cs
shargon 5e7e947
fix GetAddrConvertTable bug,return all offsets now
lightszero 432605c
format
1fd03cd
format
1de60d1
Merge branch 'master' into add-abi-offset
erikzhang e8aee62
Clean code
shargon 0fd7964
add abi-offset-unitTest
e27f299
Merge branch 'add-abi-offset' of https://github.com/ShawnYun/neo-devp…
739f653
Rename Contract_AbiOffset.cs to Contract_ABIOffset.cs
ShawnYun 1c74e62
fix
d469495
Clean code
shargon a524038
Optimize
shargon 4262ba4
Fix
shargon b162242
fix NDEBUG
shargon 1b0ce50
Fix NDEBUG
shargon 1331c73
Merge branch 'master' into add-abi-offset
lightszero f770a97
Merge branch 'master' into add-abi-offset
shargon 57b94ac
modify abi offset uintTest
71869a9
Merge branch 'master' into add-abi-offset
shargon 24fec80
Merge branch 'master' into add-abi-offset
lightszero d933683
Merge branch 'master' of https://github.com/neo-project/neo-devpack-d…
c9453a6
Merge branch 'master' into add-abi-offset
lightszero 93f292a
add initializing static variables
4b46326
Merge branch 'add-abi-offset' of https://github.com/ShawnYun/neo-devp…
9af0429
format
1faaebd
format
8d767bb
modify UTs
bcaa2e4
fix and rename
a7dcd5f
modify ContractTest
2d23cbc
fix conflicts
e7b114f
format
9c6243e
fix
bfde89a
fix TestEngine and modify _initialize
ab99dc3
fix
3165a34
fix conflicts
3b5b466
format
b3cd688
fix void return
a424b24
Update Opcodes
shargon 806f988
resolve review issues
f70aa8d
Merge branch 'add-abi-offset' of https://github.com/ShawnYun/neo-devp…
9140bbb
fix
54ad1b0
fix
5c01853
fix
575c3d7
resolve conflicts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/Neo.Compiler.MSIL.UnitTests/TestClasses/Contract_ABIOffset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Neo.Compiler.MSIL.UnitTests.TestClasses | ||
{ | ||
public class Contract_ABIOffset : SmartContract.Framework.SmartContract | ||
{ | ||
public static void Main(string method, object[] args) | ||
{ | ||
UnitTest_001(); | ||
UnitTest_002(); | ||
UnitTest_003(); | ||
UnitTest_004(); | ||
} | ||
public static byte[] UnitTest_001() | ||
{ | ||
var nb = new byte[] { 1, 2, 3, 4 }; | ||
return nb; | ||
} | ||
public static byte[] UnitTest_002() | ||
{ | ||
var nb = new byte[] { 1, 2, 3, 4 }; | ||
return nb; | ||
} | ||
public static byte[] UnitTest_003() | ||
{ | ||
var nb = new byte[] { 1, 2, 3, 4 }; | ||
return nb; | ||
} | ||
public static byte[] UnitTest_004() | ||
{ | ||
var nb = new byte[] { 1, 2, 3, 4 }; | ||
return nb; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.Compiler.MSIL.UnitTests.Utils; | ||
using Neo.VM.Types; | ||
using System; | ||
|
||
namespace Neo.Compiler.MSIL.UnitTests | ||
{ | ||
[TestClass] | ||
public class UnitTest_ABI_Offset | ||
{ | ||
[TestMethod] | ||
public void UnitTest_TestABIOffsetWithoutOptimizer() | ||
{ | ||
var testengine = new TestEngine(); | ||
testengine.AddEntryScript("./TestClasses/Contract_ABIOffset.cs", true, false); | ||
var abi = testengine.ScriptEntry.finialABI; | ||
|
||
var methodsABI = abi["methods"].AsList(); | ||
Assert.AreEqual("0", methodsABI[0].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("32", methodsABI[1].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("39", methodsABI[2].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("46", methodsABI[3].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("53", methodsABI[4].GetDictItem("offset").ToString()); | ||
} | ||
|
||
[TestMethod] | ||
public void UnitTest_TestABIOffsetWithOptimizer() | ||
{ | ||
var testengine = new TestEngine(); | ||
testengine.AddEntryScript("./TestClasses/Contract_ABIOffset.cs", true, true); | ||
var abi = testengine.ScriptEntry.finialABI; | ||
|
||
var methodsABI = abi["methods"].AsList(); | ||
Assert.AreEqual("0", methodsABI[0].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("16", methodsABI[1].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("23", methodsABI[2].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("30", methodsABI[3].GetDictItem("offset").ToString()); | ||
Assert.AreEqual("37", methodsABI[4].GetDictItem("offset").ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. it would be good to have a method with different size in order to emphasize that the offset is dynamic, right
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this sense, we could have a non-linear relation with the optimizer as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been modified.