Cleanup VM.

* CALLDATA use getData
* removed old context get range value
* removed casting big => int for some cases
* pc now big int #457
This commit is contained in:
obscuren
2015-03-28 20:30:16 +01:00
parent 3b7e4173ce
commit 368ebe63a9
4 changed files with 44 additions and 55 deletions

View File

@ -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