Merge branch 'develop' into conversion

This commit is contained in:
obscuren
2015-03-19 14:31:41 +01:00
408 changed files with 33298 additions and 2270 deletions

View File

@@ -73,9 +73,9 @@ func toValue(val *big.Int) interface{} {
return val
}
func getCode(code []byte, start, size uint64) []byte {
x := uint64(math.Min(float64(start), float64(len(code))))
y := uint64(math.Min(float64(x+size), float64(len(code))))
func getData(data []byte, start, size uint64) []byte {
x := uint64(math.Min(float64(start), float64(len(data))))
y := uint64(math.Min(float64(x+size), float64(len(data))))
return common.RightPadBytes(code[x:y], int(size))
return common.RightPadBytes(data[x:y], int(size))
}

View File

@@ -65,7 +65,7 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
}
func (c *Context) GetCode(x, size uint64) []byte {
return getCode(c.Code, x, size)
return getData(c.Code, x, size)
}
func (c *Context) Return(ret []byte) []byte {

View File

@@ -441,24 +441,15 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self.Printf(" => %d", l)
case CALLDATACOPY:
var (
size = uint64(len(callData))
mOff = stack.pop().Uint64()
cOff = stack.pop().Uint64()
l = stack.pop().Uint64()
)
data := getData(callData, cOff, l)
if cOff > size {
cOff = 0
l = 0
} else if cOff+l > size {
l = 0
}
mem.Set(mOff, l, data)
code := callData[cOff : cOff+l]
mem.Set(mOff, l, code)
self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, callData[cOff:cOff+l])
self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, data)
case CODESIZE, EXTCODESIZE:
var code []byte
if op == EXTCODESIZE {
@@ -486,7 +477,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
cOff = stack.pop().Uint64()
l = stack.pop().Uint64()
)
codeCopy := getCode(code, cOff, l)
codeCopy := getData(code, cOff, l)
mem.Set(mOff, l, codeCopy)