diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-29 03:30:16 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-29 03:30:38 +0800 |
commit | 368ebe63a95c870a90dba8635d3a5c3863c43330 (patch) | |
tree | a70dc5f0554c91f9f4ec027ae913d1390881ec18 /core/vm/analysis.go | |
parent | 3b7e4173ce00fb82ee2f186350dd2aca528ea60d (diff) | |
download | go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.tar go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.gz go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.bz2 go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.lz go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.xz go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.zst go-tangerine-368ebe63a95c870a90dba8635d3a5c3863c43330.zip |
Cleanup VM.
* CALLDATA use getData
* removed old context get range value
* removed casting big => int for some cases
* pc now big int #457
Diffstat (limited to 'core/vm/analysis.go')
-rw-r--r-- | core/vm/analysis.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/core/vm/analysis.go b/core/vm/analysis.go index 411df5686..264d55cb9 100644 --- a/core/vm/analysis.go +++ b/core/vm/analysis.go @@ -1,9 +1,25 @@ package vm -import "gopkg.in/fatih/set.v0" +import ( + "math/big" -func analyseJumpDests(code []byte) (dests *set.Set) { - dests = set.New() + "gopkg.in/fatih/set.v0" +) + +type destinations struct { + set *set.Set +} + +func (d *destinations) Has(dest *big.Int) bool { + return d.set.Has(string(dest.Bytes())) +} + +func (d *destinations) Add(dest *big.Int) { + d.set.Add(string(dest.Bytes())) +} + +func analyseJumpDests(code []byte) (dests *destinations) { + dests = &destinations{set.New()} for pc := uint64(0); pc < uint64(len(code)); pc++ { var op OpCode = OpCode(code[pc]) @@ -13,7 +29,7 @@ func analyseJumpDests(code []byte) (dests *set.Set) { pc += a case JUMPDEST: - dests.Add(pc) + dests.Add(big.NewInt(int64(pc))) } } return |