Renames for chain, updated VM, moved methods

* Renamed a couple more chain => core
* Updated VM `pc` to be uint64 rather than big int
* XEth interface cleanup
This commit is contained in:
obscuren
2014-12-04 10:53:49 +01:00
parent 9008b155d3
commit 83663ed4b0
9 changed files with 94 additions and 102 deletions

View File

@ -41,16 +41,16 @@ func NewClosure(msg *state.Message, caller ClosureRef, object ClosureRef, code [
return c
}
func (c *Closure) GetValue(x *big.Int) *ethutil.Value {
return c.GetRangeValue(x, big.NewInt(1))
func (c *Closure) GetValue(x uint64) *ethutil.Value {
return c.GetRangeValue(x, 1)
}
func (c *Closure) GetOp(x int) OpCode {
func (c *Closure) GetOp(x uint64) OpCode {
return OpCode(c.GetByte(x))
}
func (c *Closure) GetByte(x int) byte {
if x > -1 && x < len(c.Code) {
func (c *Closure) GetByte(x uint64) byte {
if x < uint64(len(c.Code)) {
return c.Code[x]
}
@ -65,12 +65,12 @@ func (c *Closure) GetBytes(x, y int) []byte {
return c.Code[x : x+y]
}
func (c *Closure) GetRangeValue(x, y *big.Int) *ethutil.Value {
if x.Int64() >= int64(len(c.Code)) || y.Int64() >= int64(len(c.Code)) {
func (c *Closure) GetRangeValue(x, y uint64) *ethutil.Value {
if x >= uint64(len(c.Code)) || y >= uint64(len(c.Code)) {
return ethutil.NewValue(0)
}
partial := c.Code[x.Int64() : x.Int64()+y.Int64()]
partial := c.Code[x : x+y]
return ethutil.NewValue(partial)
}