aboutsummaryrefslogtreecommitdiffstats
path: root/vm/context.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-13 20:44:15 +0800
committerobscuren <geffobscura@gmail.com>2015-03-13 20:44:15 +0800
commitf76cc6699ecd995d78cfd980b229473101191137 (patch)
treed91ea0c1725b080062cb6eb2b294e61af02cacc2 /vm/context.go
parent80592f244da3f7323b7fa3e75a17c8e37c97fe8d (diff)
downloaddexon-f76cc6699ecd995d78cfd980b229473101191137.tar.gz
dexon-f76cc6699ecd995d78cfd980b229473101191137.tar.zst
dexon-f76cc6699ecd995d78cfd980b229473101191137.zip
Changed context and ADDMOD, MULMOD
* Cleaned up VM execution. VM run now takes a context * ADDMOD/MULMOD - removed incorrect cast
Diffstat (limited to 'vm/context.go')
-rw-r--r--vm/context.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/vm/context.go b/vm/context.go
index 9ce07bc4a..78712f561 100644
--- a/vm/context.go
+++ b/vm/context.go
@@ -15,21 +15,24 @@ type ContextRef interface {
type Context struct {
caller ContextRef
- object ContextRef
- Code []byte
+ self ContextRef
- Gas, UsedGas, Price *big.Int
+ Code []byte
+ CodeAddr []byte
+
+ value, Gas, UsedGas, Price *big.Int
Args []byte
}
// Create a new context for the given data items
-func NewContext(caller ContextRef, object ContextRef, code []byte, gas, price *big.Int) *Context {
- c := &Context{caller: caller, object: object, Code: code, Args: nil}
+func NewContext(caller ContextRef, object ContextRef, value, gas, price *big.Int) *Context {
+ c := &Context{caller: caller, self: object, Args: nil}
// Gas should be a pointer so it can safely be reduced through the run
// This pointer will be off the state transition
c.Gas = gas //new(big.Int).Set(gas)
+ c.value = new(big.Int).Set(value)
// In most cases price and value are pointers to transaction objects
// and we don't want the transaction's values to change.
c.Price = new(big.Int).Set(price)
@@ -62,10 +65,7 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
}
func (c *Context) GetCode(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 ethutil.RightPadBytes(c.Code[x:y], int(size))
+ return getCode(c.Code, x, size)
}
func (c *Context) Return(ret []byte) []byte {
@@ -101,9 +101,14 @@ func (c *Context) ReturnGas(gas, price *big.Int) {
* Set / Get
*/
func (c *Context) Address() []byte {
- return c.object.Address()
+ return c.self.Address()
}
func (self *Context) SetCode(code []byte) {
self.Code = code
}
+
+func (self *Context) SetCallCode(addr, code []byte) {
+ self.Code = code
+ self.CodeAddr = addr
+}