@ -27,14 +27,14 @@ import (
type programInstruction interface {
// executes the program instruction and allows the instruction to modify the state of the program
do ( program * Program , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) ( [ ] byte , error )
do ( program * Program , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) ( [ ] byte , error )
// returns whether the program instruction halts the execution of the JIT
halts ( ) bool
// Returns the current op code (debugging purposes)
Op ( ) OpCode
}
type instrFn func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack)
type instrFn func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack)
type instruction struct {
op OpCode
@ -58,7 +58,7 @@ func jump(mapping map[uint64]uint64, destinations map[uint64]struct{}, contract
return mapping [ to . Uint64 ( ) ] , nil
}
func ( instr instruction ) do ( program * Program , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) ( [ ] byte , error ) {
func ( instr instruction ) do ( program * Program , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) ( [ ] byte , error ) {
// calculate the new memory size and gas price for the current executing opcode
newMemSize , cost , err := jitCalculateGasAndSize ( env , contract , instr , env . Db ( ) , memory , stack )
if err != nil {
@ -114,26 +114,26 @@ func (instr instruction) Op() OpCode {
return instr . op
}
func opStaticJump ( instr instruction , pc * uint64 , ret * big . Int , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opStaticJump ( instr instruction , pc * uint64 , ret * big . Int , env Environment , contract * Contract , memory * Memory , stack * S tack) {
ret . Set ( instr . data )
}
func opAdd ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opAdd ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( U256 ( x . Add ( x , y ) ) )
}
func opSub ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSub ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( U256 ( x . Sub ( x , y ) ) )
}
func opMul ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMul ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( U256 ( x . Mul ( x , y ) ) )
}
func opDiv ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opDiv ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
if y . Cmp ( common . Big0 ) != 0 {
stack . push ( U256 ( x . Div ( x , y ) ) )
@ -142,7 +142,7 @@ func opDiv(instr instruction, pc *uint64, env Environment, contract *Contract, m
}
}
func opSdiv ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSdiv ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := S256 ( stack . pop ( ) ) , S256 ( stack . pop ( ) )
if y . Cmp ( common . Big0 ) == 0 {
stack . push ( new ( big . Int ) )
@ -162,7 +162,7 @@ func opSdiv(instr instruction, pc *uint64, env Environment, contract *Contract,
}
}
func opMod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
if y . Cmp ( common . Big0 ) == 0 {
stack . push ( new ( big . Int ) )
@ -171,7 +171,7 @@ func opMod(instr instruction, pc *uint64, env Environment, contract *Contract, m
}
}
func opSmod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSmod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := S256 ( stack . pop ( ) ) , S256 ( stack . pop ( ) )
if y . Cmp ( common . Big0 ) == 0 {
@ -191,12 +191,12 @@ func opSmod(instr instruction, pc *uint64, env Environment, contract *Contract,
}
}
func opExp ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opExp ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( U256 ( x . Exp ( x , y , Pow256 ) ) )
}
func opSignExtend ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSignExtend ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
back := stack . pop ( )
if back . Cmp ( big . NewInt ( 31 ) ) < 0 {
bit := uint ( back . Uint64 ( ) * 8 + 7 )
@ -213,12 +213,12 @@ func opSignExtend(instr instruction, pc *uint64, env Environment, contract *Cont
}
}
func opNot ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opNot ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x := stack . pop ( )
stack . push ( U256 ( x . Not ( x ) ) )
}
func opLt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opLt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
if x . Cmp ( y ) < 0 {
stack . push ( big . NewInt ( 1 ) )
@ -227,7 +227,7 @@ func opLt(instr instruction, pc *uint64, env Environment, contract *Contract, me
}
}
func opGt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opGt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
if x . Cmp ( y ) > 0 {
stack . push ( big . NewInt ( 1 ) )
@ -236,7 +236,7 @@ func opGt(instr instruction, pc *uint64, env Environment, contract *Contract, me
}
}
func opSlt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSlt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := S256 ( stack . pop ( ) ) , S256 ( stack . pop ( ) )
if x . Cmp ( S256 ( y ) ) < 0 {
stack . push ( big . NewInt ( 1 ) )
@ -245,7 +245,7 @@ func opSlt(instr instruction, pc *uint64, env Environment, contract *Contract, m
}
}
func opSgt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSgt ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := S256 ( stack . pop ( ) ) , S256 ( stack . pop ( ) )
if x . Cmp ( y ) > 0 {
stack . push ( big . NewInt ( 1 ) )
@ -254,7 +254,7 @@ func opSgt(instr instruction, pc *uint64, env Environment, contract *Contract, m
}
}
func opEq ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opEq ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
if x . Cmp ( y ) == 0 {
stack . push ( big . NewInt ( 1 ) )
@ -263,7 +263,7 @@ func opEq(instr instruction, pc *uint64, env Environment, contract *Contract, me
}
}
func opIszero ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opIszero ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x := stack . pop ( )
if x . Cmp ( common . Big0 ) > 0 {
stack . push ( new ( big . Int ) )
@ -272,19 +272,19 @@ func opIszero(instr instruction, pc *uint64, env Environment, contract *Contract
}
}
func opAnd ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opAnd ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( x . And ( x , y ) )
}
func opOr ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opOr ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( x . Or ( x , y ) )
}
func opXor ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opXor ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y := stack . pop ( ) , stack . pop ( )
stack . push ( x . Xor ( x , y ) )
}
func opByte ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opByte ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
th , val := stack . pop ( ) , stack . pop ( )
if th . Cmp ( big . NewInt ( 32 ) ) < 0 {
byte := big . NewInt ( int64 ( common . LeftPadBytes ( val . Bytes ( ) , 32 ) [ th . Int64 ( ) ] ) )
@ -293,7 +293,7 @@ func opByte(instr instruction, pc *uint64, env Environment, contract *Contract,
stack . push ( new ( big . Int ) )
}
}
func opAddmod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opAddmod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y , z := stack . pop ( ) , stack . pop ( ) , stack . pop ( )
if z . Cmp ( Zero ) > 0 {
add := x . Add ( x , y )
@ -303,7 +303,7 @@ func opAddmod(instr instruction, pc *uint64, env Environment, contract *Contract
stack . push ( new ( big . Int ) )
}
}
func opMulmod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMulmod ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
x , y , z := stack . pop ( ) , stack . pop ( ) , stack . pop ( )
if z . Cmp ( Zero ) > 0 {
mul := x . Mul ( x , y )
@ -314,45 +314,45 @@ func opMulmod(instr instruction, pc *uint64, env Environment, contract *Contract
}
}
func opSha3 ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSha3 ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
offset , size := stack . pop ( ) , stack . pop ( )
hash := crypto . Keccak256 ( memory . Get ( offset . Int64 ( ) , size . Int64 ( ) ) )
stack . push ( common . BytesToBig ( hash ) )
}
func opAddress ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opAddress ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( common . Bytes2Big ( contract . Address ( ) . Bytes ( ) ) )
}
func opBalance ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opBalance ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
addr := common . BigToAddress ( stack . pop ( ) )
balance := env . Db ( ) . GetBalance ( addr )
stack . push ( new ( big . Int ) . Set ( balance ) )
}
func opOrigin ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opOrigin ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( env . Origin ( ) . Big ( ) )
}
func opCaller ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCaller ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( contract . Caller ( ) . Big ( ) )
}
func opCallValue ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCallValue ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( new ( big . Int ) . Set ( contract . value ) )
}
func opCalldataLoad ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCalldataLoad ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( common . Bytes2Big ( getData ( contract . Input , stack . pop ( ) , common . Big32 ) ) )
}
func opCalldataSize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCalldataSize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( big . NewInt ( int64 ( len ( contract . Input ) ) ) )
}
func opCalldataCopy ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCalldataCopy ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
var (
mOff = stack . pop ( )
cOff = stack . pop ( )
@ -361,18 +361,18 @@ func opCalldataCopy(instr instruction, pc *uint64, env Environment, contract *Co
memory . Set ( mOff . Uint64 ( ) , l . Uint64 ( ) , getData ( contract . Input , cOff , l ) )
}
func opExtCodeSize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opExtCodeSize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
addr := common . BigToAddress ( stack . pop ( ) )
l := big . NewInt ( int64 ( len ( env . Db ( ) . GetCode ( addr ) ) ) )
stack . push ( l )
}
func opCodeSize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCodeSize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
l := big . NewInt ( int64 ( len ( contract . Code ) ) )
stack . push ( l )
}
func opCodeCopy ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCodeCopy ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
var (
mOff = stack . pop ( )
cOff = stack . pop ( )
@ -383,7 +383,7 @@ func opCodeCopy(instr instruction, pc *uint64, env Environment, contract *Contra
memory . Set ( mOff . Uint64 ( ) , l . Uint64 ( ) , codeCopy )
}
func opExtCodeCopy ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opExtCodeCopy ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
var (
addr = common . BigToAddress ( stack . pop ( ) )
mOff = stack . pop ( )
@ -395,11 +395,11 @@ func opExtCodeCopy(instr instruction, pc *uint64, env Environment, contract *Con
memory . Set ( mOff . Uint64 ( ) , l . Uint64 ( ) , codeCopy )
}
func opGasprice ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opGasprice ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( new ( big . Int ) . Set ( contract . Price ) )
}
func opBlockhash ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opBlockhash ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
num := stack . pop ( )
n := new ( big . Int ) . Sub ( env . BlockNumber ( ) , common . Big257 )
@ -410,43 +410,43 @@ func opBlockhash(instr instruction, pc *uint64, env Environment, contract *Contr
}
}
func opCoinbase ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCoinbase ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( env . Coinbase ( ) . Big ( ) )
}
func opTimestamp ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opTimestamp ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( U256 ( new ( big . Int ) . Set ( env . Time ( ) ) ) )
}
func opNumber ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opNumber ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( U256 ( new ( big . Int ) . Set ( env . BlockNumber ( ) ) ) )
}
func opDifficulty ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opDifficulty ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( U256 ( new ( big . Int ) . Set ( env . Difficulty ( ) ) ) )
}
func opGasLimit ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opGasLimit ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( U256 ( new ( big . Int ) . Set ( env . GasLimit ( ) ) ) )
}
func opPop ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opPop ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . pop ( )
}
func opPush ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opPush ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( new ( big . Int ) . Set ( instr . data ) )
}
func opDup ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opDup ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . dup ( int ( instr . data . Int64 ( ) ) )
}
func opSwap ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSwap ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . swap ( int ( instr . data . Int64 ( ) ) )
}
func opLog ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opLog ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
n := int ( instr . data . Int64 ( ) )
topics := make ( [ ] common . Hash , n )
mStart , mSize := stack . pop ( ) , stack . pop ( )
@ -459,55 +459,55 @@ func opLog(instr instruction, pc *uint64, env Environment, contract *Contract, m
env . AddLog ( log )
}
func opMload ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMload ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
offset := stack . pop ( )
val := common . BigD ( memory . Get ( offset . Int64 ( ) , 32 ) )
stack . push ( val )
}
func opMstore ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMstore ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
// pop value of the stack
mStart , val := stack . pop ( ) , stack . pop ( )
memory . Set ( mStart . Uint64 ( ) , 32 , common . BigToBytes ( val , 256 ) )
}
func opMstore8 ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMstore8 ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
off , val := stack . pop ( ) . Int64 ( ) , stack . pop ( ) . Int64 ( )
memory . store [ off ] = byte ( val & 0xff )
}
func opSload ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSload ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
loc := common . BigToHash ( stack . pop ( ) )
val := env . Db ( ) . GetState ( contract . Address ( ) , loc ) . Big ( )
stack . push ( val )
}
func opSstore ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSstore ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
loc := common . BigToHash ( stack . pop ( ) )
val := stack . pop ( )
env . Db ( ) . SetState ( contract . Address ( ) , loc , common . BigToHash ( val ) )
}
func opJump ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opJump ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
}
func opJumpi ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opJumpi ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
}
func opJumpdest ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opJumpdest ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
}
func opPc ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opPc ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( new ( big . Int ) . Set ( instr . data ) )
}
func opMsize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opMsize ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( big . NewInt ( int64 ( memory . Len ( ) ) ) )
}
func opGas ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opGas ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . push ( new ( big . Int ) . Set ( contract . Gas ) )
}
func opCreate ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCreate ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
var (
value = stack . pop ( )
offset , size = stack . pop ( ) , stack . pop ( )
@ -529,7 +529,7 @@ func opCreate(instr instruction, pc *uint64, env Environment, contract *Contract
}
}
func opCall ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCall ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
gas := stack . pop ( )
// pop gas and value of the stack.
addr , value := stack . pop ( ) , stack . pop ( )
@ -560,7 +560,7 @@ func opCall(instr instruction, pc *uint64, env Environment, contract *Contract,
}
}
func opCallCode ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opCallCode ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
gas := stack . pop ( )
// pop gas and value of the stack.
addr , value := stack . pop ( ) , stack . pop ( )
@ -591,7 +591,7 @@ func opCallCode(instr instruction, pc *uint64, env Environment, contract *Contra
}
}
func opDelegateCall ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opDelegateCall ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
gas , to , inOffset , inSize , outOffset , outSize := stack . pop ( ) , stack . pop ( ) , stack . pop ( ) , stack . pop ( ) , stack . pop ( ) , stack . pop ( )
toAddr := common . BigToAddress ( to )
@ -605,12 +605,12 @@ func opDelegateCall(instr instruction, pc *uint64, env Environment, contract *Co
}
}
func opReturn ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opReturn ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
}
func opStop ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opStop ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
}
func opSuicide ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
func opSuicide ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
balance := env . Db ( ) . GetBalance ( contract . Address ( ) )
env . Db ( ) . AddBalance ( common . BigToAddress ( stack . pop ( ) ) , balance )
@ -621,7 +621,7 @@ func opSuicide(instr instruction, pc *uint64, env Environment, contract *Contrac
// make log instruction function
func makeLog ( size int ) instrFn {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
topics := make ( [ ] common . Hash , size )
mStart , mSize := stack . pop ( ) , stack . pop ( )
for i := 0 ; i < size ; i ++ {
@ -636,7 +636,7 @@ func makeLog(size int) instrFn {
// make push instruction function
func makePush ( size uint64 , bsize * big . Int ) instrFn {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
byts := getData ( contract . Code , new ( big . Int ) . SetUint64 ( * pc + 1 ) , bsize )
stack . push ( common . Bytes2Big ( byts ) )
* pc += size
@ -645,7 +645,7 @@ func makePush(size uint64, bsize *big.Int) instrFn {
// make push instruction function
func makeDup ( size int64 ) instrFn {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . dup ( int ( size ) )
}
}
@ -654,7 +654,7 @@ func makeDup(size int64) instrFn {
func makeSwap ( size int64 ) instrFn {
// switch n + 1 otherwise n would be swapped with n
size += 1
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * s tack) {
return func ( instr instruction , pc * uint64 , env Environment , contract * Contract , memory * Memory , stack * S tack) {
stack . swap ( int ( size ) )
}
}