| 
									
										
										
										
											2016-04-14 18:18:24 +02:00
										 |  |  | // Copyright 2015 The go-ethereum Authors | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | // This file is part of the go-ethereum library. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // The go-ethereum library is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  | // it under the terms of the GNU Lesser General Public License as published by | 
					
						
							|  |  |  | // the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  | // (at your option) any later version. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // The go-ethereum library is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
					
						
							|  |  |  | // GNU Lesser General Public License for more details. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // You should have received a copy of the GNU Lesser General Public License | 
					
						
							|  |  |  | // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | 
					
						
							| 
									
										
										
										
											2015-08-02 02:20:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | package vm | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2015-10-06 18:16:03 +02:00
										 |  |  | 	"fmt" | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	"math/big" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/ethereum/go-ethereum/common" | 
					
						
							| 
									
										
										
										
											2016-11-02 12:43:15 +01:00
										 |  |  | 	"github.com/ethereum/go-ethereum/common/math" | 
					
						
							| 
									
										
										
										
											2017-01-05 14:03:50 +01:00
										 |  |  | 	"github.com/ethereum/go-ethereum/core/types" | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	"github.com/ethereum/go-ethereum/crypto" | 
					
						
							|  |  |  | 	"github.com/ethereum/go-ethereum/params" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opAdd(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(U256(x.Add(x, y))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSub(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(U256(x.Sub(x, y))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMul(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(U256(x.Mul(x, y))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opDiv(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if y.Cmp(common.Big0) != 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(U256(x.Div(x, y))) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSdiv(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := S256(stack.pop()), S256(stack.pop()) | 
					
						
							|  |  |  | 	if y.Cmp(common.Big0) == 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 		return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		n := new(big.Int) | 
					
						
							|  |  |  | 		if new(big.Int).Mul(x, y).Cmp(common.Big0) < 0 { | 
					
						
							|  |  |  | 			n.SetInt64(-1) | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			n.SetInt64(1) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		res := x.Div(x.Abs(x), y.Abs(y)) | 
					
						
							|  |  |  | 		res.Mul(res, n) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(U256(res)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMod(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if y.Cmp(common.Big0) == 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(U256(x.Mod(x, y))) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSmod(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := S256(stack.pop()), S256(stack.pop()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if y.Cmp(common.Big0) == 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		n := new(big.Int) | 
					
						
							|  |  |  | 		if x.Cmp(common.Big0) < 0 { | 
					
						
							|  |  |  | 			n.SetInt64(-1) | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			n.SetInt64(1) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		res := x.Mod(x.Abs(x), y.Abs(y)) | 
					
						
							|  |  |  | 		res.Mul(res, n) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(U256(res)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opExp(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-11-02 12:43:15 +01:00
										 |  |  | 	base, exponent := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	stack.push(math.Exp(base, exponent)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSignExtend(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	back := stack.pop() | 
					
						
							|  |  |  | 	if back.Cmp(big.NewInt(31)) < 0 { | 
					
						
							|  |  |  | 		bit := uint(back.Uint64()*8 + 7) | 
					
						
							|  |  |  | 		num := stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		mask := back.Lsh(common.Big1, bit) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 		mask.Sub(mask, common.Big1) | 
					
						
							|  |  |  | 		if common.BitTest(num, int(bit)) { | 
					
						
							|  |  |  | 			num.Or(num, mask.Not(mask)) | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			num.And(num, mask) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(U256(num)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opNot(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	x := stack.pop() | 
					
						
							|  |  |  | 	stack.push(U256(x.Not(x))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opLt(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if x.Cmp(y) < 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opGt(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if x.Cmp(y) > 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSlt(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := S256(stack.pop()), S256(stack.pop()) | 
					
						
							|  |  |  | 	if x.Cmp(S256(y)) < 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSgt(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := S256(stack.pop()), S256(stack.pop()) | 
					
						
							|  |  |  | 	if x.Cmp(y) > 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opEq(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if x.Cmp(y) == 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opIszero(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x := stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	if x.Cmp(common.Big0) > 0 { | 
					
						
							|  |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opAnd(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(x.And(x, y)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opOr(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(x.Or(x, y)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opXor(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	x, y := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(x.Xor(x, y)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opByte(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	th, val := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if th.Cmp(big.NewInt(32)) < 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		byte := big.NewInt(int64(common.LeftPadBytes(val.Bytes(), 32)[th.Int64()])) | 
					
						
							|  |  |  | 		stack.push(byte) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opAddmod(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	x, y, z := stack.pop(), stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	if z.Cmp(Zero) > 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		add := x.Add(x, y) | 
					
						
							|  |  |  | 		add.Mod(add, z) | 
					
						
							|  |  |  | 		stack.push(U256(add)) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMulmod(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	x, y, z := stack.pop(), stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	if z.Cmp(Zero) > 0 { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		mul := x.Mul(x, y) | 
					
						
							|  |  |  | 		mul.Mod(mul, z) | 
					
						
							|  |  |  | 		stack.push(U256(mul)) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSha3(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	offset, size := stack.pop(), stack.pop() | 
					
						
							| 
									
										
										
										
											2016-02-21 18:40:27 +00:00
										 |  |  | 	hash := crypto.Keccak256(memory.Get(offset.Int64(), size.Int64())) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 	stack.push(common.BytesToBig(hash)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opAddress(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	stack.push(common.Bytes2Big(contract.Address().Bytes())) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opBalance(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	addr := common.BigToAddress(stack.pop()) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	balance := env.StateDB.GetBalance(addr) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	stack.push(new(big.Int).Set(balance)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opOrigin(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(env.Origin.Big()) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCaller(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-01-19 23:50:00 +01:00
										 |  |  | 	stack.push(contract.Caller().Big()) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCallValue(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	stack.push(new(big.Int).Set(contract.value)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCalldataLoad(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	stack.push(common.Bytes2Big(getData(contract.Input, stack.pop(), common.Big32))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCalldataSize(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	stack.push(big.NewInt(int64(len(contract.Input)))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCalldataCopy(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	var ( | 
					
						
							|  |  |  | 		mOff = stack.pop() | 
					
						
							|  |  |  | 		cOff = stack.pop() | 
					
						
							|  |  |  | 		l    = stack.pop() | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	memory.Set(mOff.Uint64(), l.Uint64(), getData(contract.Input, cOff, l)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opExtCodeSize(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	addr := common.BigToAddress(stack.pop()) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	l := big.NewInt(int64(env.StateDB.GetCodeSize(addr))) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	stack.push(l) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCodeSize(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	l := big.NewInt(int64(len(contract.Code))) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	stack.push(l) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCodeCopy(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	var ( | 
					
						
							|  |  |  | 		mOff = stack.pop() | 
					
						
							|  |  |  | 		cOff = stack.pop() | 
					
						
							|  |  |  | 		l    = stack.pop() | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	codeCopy := getData(contract.Code, cOff, l) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	memory.Set(mOff.Uint64(), l.Uint64(), codeCopy) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opExtCodeCopy(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	var ( | 
					
						
							|  |  |  | 		addr = common.BigToAddress(stack.pop()) | 
					
						
							|  |  |  | 		mOff = stack.pop() | 
					
						
							|  |  |  | 		cOff = stack.pop() | 
					
						
							|  |  |  | 		l    = stack.pop() | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	codeCopy := getData(env.StateDB.GetCode(addr), cOff, l) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	memory.Set(mOff.Uint64(), l.Uint64(), codeCopy) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opGasprice(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(new(big.Int).Set(env.GasPrice)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opBlockhash(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	num := stack.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	n := new(big.Int).Sub(env.BlockNumber, common.Big257) | 
					
						
							|  |  |  | 	if num.Cmp(n) > 0 && num.Cmp(env.BlockNumber) < 0 { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 		stack.push(env.GetHash(num.Uint64()).Big()) | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCoinbase(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(env.Coinbase.Big()) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opTimestamp(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(U256(new(big.Int).Set(env.Time))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opNumber(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(U256(new(big.Int).Set(env.BlockNumber))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opDifficulty(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(U256(new(big.Int).Set(env.Difficulty))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opGasLimit(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	stack.push(U256(new(big.Int).Set(env.GasLimit))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opPop(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	stack.pop() | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMload(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	offset := stack.pop() | 
					
						
							|  |  |  | 	val := common.BigD(memory.Get(offset.Int64(), 32)) | 
					
						
							|  |  |  | 	stack.push(val) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMstore(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	// pop value of the stack | 
					
						
							|  |  |  | 	mStart, val := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	memory.Set(mStart.Uint64(), 32, common.BigToBytes(val, 256)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMstore8(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	off, val := stack.pop().Int64(), stack.pop().Int64() | 
					
						
							|  |  |  | 	memory.store[off] = byte(val & 0xff) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSload(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	loc := common.BigToHash(stack.pop()) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	val := env.StateDB.GetState(contract.Address(), loc).Big() | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	stack.push(val) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSstore(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	loc := common.BigToHash(stack.pop()) | 
					
						
							|  |  |  | 	val := stack.pop() | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	env.StateDB.SetState(contract.Address(), loc, common.BigToHash(val)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opJump(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	pos := stack.pop() | 
					
						
							|  |  |  | 	if !contract.jumpdests.has(contract.CodeHash, contract.Code, pos) { | 
					
						
							|  |  |  | 		nop := contract.GetOp(pos.Uint64()) | 
					
						
							|  |  |  | 		return nil, fmt.Errorf("invalid jump destination (%v) %v", nop, pos) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	*pc = pos.Uint64() | 
					
						
							|  |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opJumpi(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	pos, cond := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	if cond.Cmp(common.BigTrue) >= 0 { | 
					
						
							|  |  |  | 		if !contract.jumpdests.has(contract.CodeHash, contract.Code, pos) { | 
					
						
							|  |  |  | 			nop := contract.GetOp(pos.Uint64()) | 
					
						
							|  |  |  | 			return nil, fmt.Errorf("invalid jump destination (%v) %v", nop, pos) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		*pc = pos.Uint64() | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		*pc++ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opJumpdest(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opPc(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	stack.push(new(big.Int).SetUint64(*pc)) | 
					
						
							|  |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opMsize(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	stack.push(big.NewInt(int64(memory.Len()))) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opGas(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	stack.push(new(big.Int).Set(contract.Gas)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCreate(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-01-19 23:50:00 +01:00
										 |  |  | 	var ( | 
					
						
							|  |  |  | 		value        = stack.pop() | 
					
						
							|  |  |  | 		offset, size = stack.pop(), stack.pop() | 
					
						
							|  |  |  | 		input        = memory.Get(offset.Int64(), size.Int64()) | 
					
						
							|  |  |  | 		gas          = new(big.Int).Set(contract.Gas) | 
					
						
							|  |  |  | 	) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	if env.ChainConfig().IsEIP150(env.BlockNumber) { | 
					
						
							| 
									
										
										
										
											2016-10-08 00:23:45 +02:00
										 |  |  | 		gas.Div(gas, n64) | 
					
						
							|  |  |  | 		gas = gas.Sub(contract.Gas, gas) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	contract.UseGas(gas) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	_, addr, suberr := env.Create(contract, input, gas, value) | 
					
						
							| 
									
										
										
										
											2016-01-19 23:50:00 +01:00
										 |  |  | 	// Push item on the stack based on the returned error. If the ruleset is | 
					
						
							|  |  |  | 	// homestead we must check for CodeStoreOutOfGasError (homestead only | 
					
						
							|  |  |  | 	// rule) and treat as an error, if the ruleset is frontier we must | 
					
						
							|  |  |  | 	// ignore this error and pretend the operation was successful. | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	if env.ChainConfig().IsHomestead(env.BlockNumber) && suberr == ErrCodeStoreOutOfGas { | 
					
						
							| 
									
										
										
										
											2016-01-19 23:50:00 +01:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	} else if suberr != nil && suberr != ErrCodeStoreOutOfGas { | 
					
						
							| 
									
										
										
										
											2016-01-19 23:50:00 +01:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		stack.push(addr.Big()) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCall(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	gas := stack.pop() | 
					
						
							|  |  |  | 	// pop gas and value of the stack. | 
					
						
							|  |  |  | 	addr, value := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	value = U256(value) | 
					
						
							|  |  |  | 	// pop input size and offset | 
					
						
							|  |  |  | 	inOffset, inSize := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	// pop return size and offset | 
					
						
							|  |  |  | 	retOffset, retSize := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	address := common.BigToAddress(addr) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Get the arguments from the memory | 
					
						
							|  |  |  | 	args := memory.Get(inOffset.Int64(), inSize.Int64()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(value.Bytes()) > 0 { | 
					
						
							|  |  |  | 		gas.Add(gas, params.CallStipend) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	ret, err := env.Call(contract, address, args, gas, value) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opCallCode(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 	gas := stack.pop() | 
					
						
							|  |  |  | 	// pop gas and value of the stack. | 
					
						
							|  |  |  | 	addr, value := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	value = U256(value) | 
					
						
							|  |  |  | 	// pop input size and offset | 
					
						
							|  |  |  | 	inOffset, inSize := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	// pop return size and offset | 
					
						
							|  |  |  | 	retOffset, retSize := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	address := common.BigToAddress(addr) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Get the arguments from the memory | 
					
						
							|  |  |  | 	args := memory.Get(inOffset.Int64(), inSize.Int64()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(value.Bytes()) > 0 { | 
					
						
							|  |  |  | 		gas.Add(gas, params.CallStipend) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	ret, err := env.CallCode(contract, address, args, gas, value) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(new(big.Int)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-08-06 23:06:47 +02:00
										 |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		memory.Set(retOffset.Uint64(), retSize.Uint64(), ret) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opDelegateCall(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	// if not homestead return an error. DELEGATECALL is not supported | 
					
						
							|  |  |  | 	// during pre-homestead. | 
					
						
							|  |  |  | 	if !env.ChainConfig().IsHomestead(env.BlockNumber) { | 
					
						
							|  |  |  | 		return nil, fmt.Errorf("invalid opcode %x", DELEGATECALL) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-27 15:40:29 +01:00
										 |  |  | 	gas, to, inOffset, inSize, outOffset, outSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	toAddr := common.BigToAddress(to) | 
					
						
							|  |  |  | 	args := memory.Get(inOffset.Int64(), inSize.Int64()) | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	ret, err := env.DelegateCall(contract, toAddr, args, gas) | 
					
						
							| 
									
										
										
										
											2015-11-27 15:40:29 +01:00
										 |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		stack.push(new(big.Int)) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		stack.push(big.NewInt(1)) | 
					
						
							|  |  |  | 		memory.Set(outOffset.Uint64(), outSize.Uint64(), ret) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-11-27 15:40:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opReturn(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	offset, size := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 	ret := memory.GetPtr(offset.Int64(), size.Int64()) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | func opStop(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							|  |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func opSuicide(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	balance := env.StateDB.GetBalance(contract.Address()) | 
					
						
							|  |  |  | 	env.StateDB.AddBalance(common.BigToAddress(stack.pop()), balance) | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-06 02:16:03 +01:00
										 |  |  | 	env.StateDB.Suicide(contract.Address()) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // following functions are used by the instruction jump  table | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // make log instruction function | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func makeLog(size int) executionFunc { | 
					
						
							|  |  |  | 	return func(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 		topics := make([]common.Hash, size) | 
					
						
							|  |  |  | 		mStart, mSize := stack.pop(), stack.pop() | 
					
						
							|  |  |  | 		for i := 0; i < size; i++ { | 
					
						
							|  |  |  | 			topics[i] = common.BigToHash(stack.pop()) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		d := memory.Get(mStart.Int64(), mSize.Int64()) | 
					
						
							| 
									
										
										
										
											2017-01-05 14:03:50 +01:00
										 |  |  | 		env.StateDB.AddLog(&types.Log{ | 
					
						
							|  |  |  | 			Address: contract.Address(), | 
					
						
							|  |  |  | 			Topics:  topics, | 
					
						
							|  |  |  | 			Data:    d, | 
					
						
							|  |  |  | 			// This is a non-consensus field, but assigned here because | 
					
						
							|  |  |  | 			// core/state doesn't know the current block number. | 
					
						
							|  |  |  | 			BlockNumber: env.BlockNumber.Uint64(), | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 		return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | // make push instruction function | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func makePush(size uint64, bsize *big.Int) executionFunc { | 
					
						
							|  |  |  | 	return func(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 		byts := getData(contract.Code, new(big.Int).SetUint64(*pc+1), bsize) | 
					
						
							|  |  |  | 		stack.push(common.Bytes2Big(byts)) | 
					
						
							|  |  |  | 		*pc += size | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 		return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | // make push instruction function | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func makeDup(size int64) executionFunc { | 
					
						
							|  |  |  | 	return func(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 		stack.dup(int(size)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 		return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | // make swap instruction function | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | func makeSwap(size int64) executionFunc { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	// switch n + 1 otherwise n would be swapped with n | 
					
						
							|  |  |  | 	size += 1 | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 	return func(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 		stack.swap(int(size)) | 
					
						
							| 
									
										
										
										
											2017-01-05 11:52:10 +01:00
										 |  |  | 		return nil, nil | 
					
						
							| 
									
										
										
										
											2015-08-30 10:19:10 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-17 23:09:36 +02:00
										 |  |  | } |