aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/context.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-29 03:30:16 +0800
committerobscuren <geffobscura@gmail.com>2015-03-29 03:30:38 +0800
commit368ebe63a95c870a90dba8635d3a5c3863c43330 (patch)
treea70dc5f0554c91f9f4ec027ae913d1390881ec18 /core/vm/context.go
parent3b7e4173ce00fb82ee2f186350dd2aca528ea60d (diff)
downloaddexon-368ebe63a95c870a90dba8635d3a5c3863c43330.tar
dexon-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.gz
dexon-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.bz2
dexon-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.lz
dexon-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.xz
dexon-368ebe63a95c870a90dba8635d3a5c3863c43330.tar.zst
dexon-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/context.go')
-rw-r--r--core/vm/context.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/core/vm/context.go b/core/vm/context.go
index e4b94b600..29bb9f74e 100644
--- a/core/vm/context.go
+++ b/core/vm/context.go
@@ -1,7 +1,6 @@
package vm
import (
- "math"
"math/big"
"github.com/ethereum/go-ethereum/common"
@@ -41,29 +40,18 @@ func NewContext(caller ContextRef, object ContextRef, value, gas, price *big.Int
return c
}
-func (c *Context) GetOp(n uint64) OpCode {
+func (c *Context) GetOp(n *big.Int) OpCode {
return OpCode(c.GetByte(n))
}
-func (c *Context) GetByte(n uint64) byte {
- if n < uint64(len(c.Code)) {
- return c.Code[n]
+func (c *Context) GetByte(n *big.Int) byte {
+ if n.Cmp(big.NewInt(int64(len(c.Code)))) < 0 {
+ return c.Code[n.Int64()]
}
return 0
}
-func (c *Context) GetBytes(x, y int) []byte {
- return c.GetRangeValue(uint64(x), uint64(y))
-}
-
-func (c *Context) GetRangeValue(x, size uint64) []byte {
- x = uint64(math.Min(float64(x), float64(len(c.Code))))
- y := uint64(math.Min(float64(x+size), float64(len(c.Code))))
-
- return common.RightPadBytes(c.Code[x:y], int(size))
-}
-
func (c *Context) Return(ret []byte) []byte {
// Return the remaining gas to the caller
c.caller.ReturnGas(c.Gas, c.Price)