aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/stack.go
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-04-01 20:20:55 +0800
committerMaran <maran.hidskes@gmail.com>2014-04-01 20:20:55 +0800
commit0a8801082676d64f904cbb5b62c1159e0bbd7788 (patch)
tree05e9c4ea80d5e01cca53d583318f43606418a19e /ethchain/stack.go
parent5f49a659c36dbfb8c330ddc3d4565c19a9a936b5 (diff)
parent7277c420479239fbea78417e42c43ee0162c2728 (diff)
downloadgo-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.tar.gz
go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.tar.zst
go-tangerine-0a8801082676d64f904cbb5b62c1159e0bbd7788.zip
Merge conflicts
Diffstat (limited to 'ethchain/stack.go')
-rw-r--r--ethchain/stack.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/ethchain/stack.go b/ethchain/stack.go
index 3c2899e62..e3fc4b684 100644
--- a/ethchain/stack.go
+++ b/ethchain/stack.go
@@ -173,21 +173,25 @@ func NewStack() *Stack {
}
func (st *Stack) Pop() *big.Int {
- str := st.data[0]
- st.data = st.data[1:]
+ str := st.data[len(st.data)-1]
+
+ copy(st.data[:len(st.data)-1], st.data[:len(st.data)-1])
+ st.data = st.data[:len(st.data)-1]
return str
}
func (st *Stack) Popn() (*big.Int, *big.Int) {
- ints := st.data[:2]
- st.data = st.data[2:]
+ ints := st.data[len(st.data)-2:]
+
+ copy(st.data[:len(st.data)-2], st.data[:len(st.data)-2])
+ st.data = st.data[:len(st.data)-2]
return ints[0], ints[1]
}
func (st *Stack) Peek() *big.Int {
- str := st.data[0]
+ str := st.data[len(st.data)-1]
return str
}
@@ -202,7 +206,7 @@ func (st *Stack) Push(d *big.Int) {
st.data = append(st.data, d)
}
func (st *Stack) Print() {
- fmt.Println("### STACK ###")
+ fmt.Println("### stack ###")
if len(st.data) > 0 {
for i, val := range st.data {
fmt.Printf("%-3d %v\n", i, val)
@@ -242,15 +246,15 @@ func (m *Memory) Len() int {
}
func (m *Memory) Print() {
- fmt.Println("### MEM ###")
+ fmt.Printf("### mem %d bytes ###\n", len(m.store))
if len(m.store) > 0 {
addr := 0
- for i := 0; i+32 < len(m.store); i += 32 {
+ for i := 0; i+32 <= len(m.store); i += 32 {
fmt.Printf("%03d %v\n", addr, m.store[i:i+32])
addr++
}
} else {
fmt.Println("-- empty --")
}
- fmt.Println("###########")
+ fmt.Println("####################")
}