aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/stack.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-03-21 18:54:36 +0800
committerobscuren <geffobscura@gmail.com>2014-03-21 18:54:36 +0800
commitfa1db8d2dcbc12fd9b343e6572c541d92fe7cb55 (patch)
tree828c67cd8ce30868a2dd57a25bd5d3d412fff335 /ethchain/stack.go
parent9cf8ce9ef82bfb37fea92bbea6a8d326af00adc8 (diff)
downloadgo-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.tar
go-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.tar.gz
go-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.tar.bz2
go-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.tar.lz
go-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.tar.xz
go-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.tar.zst
go-tangerine-fa1db8d2dcbc12fd9b343e6572c541d92fe7cb55.zip
Implemented closure arguments
Diffstat (limited to 'ethchain/stack.go')
-rw-r--r--ethchain/stack.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/ethchain/stack.go b/ethchain/stack.go
index 429c31d08..c75d02dda 100644
--- a/ethchain/stack.go
+++ b/ethchain/stack.go
@@ -68,12 +68,16 @@ const (
oJUMP = 0x59
oJUMPI = 0x5a
oPC = 0x5b
- oMEMSIZE = 0x5c
+ oMSIZE = 0x5c
// 0x60 range - closures
oCREATE = 0x60
oCALL = 0x61
oRETURN = 0x62
+
+ // 0x70 range - other
+ oLOG = 0x70 // XXX Unofficial
+ oSUICIDE = 0x7f
)
// Since the opcodes aren't all in order we can't use a regular slice
@@ -136,12 +140,16 @@ var opCodeToString = map[OpCode]string{
oJUMP: "JUMP",
oJUMPI: "JUMPI",
oPC: "PC",
- oMEMSIZE: "MEMSIZE",
+ oMSIZE: "MSIZE",
// 0x60 range - closures
oCREATE: "CREATE",
oCALL: "CALL",
oRETURN: "RETURN",
+
+ // 0x70 range - other
+ oLOG: "LOG",
+ oSUICIDE: "SUICIDE",
}
func (o OpCode) String() string {
@@ -215,20 +223,30 @@ type Memory struct {
func (m *Memory) Set(offset, size int64, value []byte) {
totSize := offset + size
- lenSize := int64(len(m.store))
+ lenSize := int64(len(m.store) - 1)
if totSize > lenSize {
// Calculate the diff between the sizes
diff := totSize - lenSize
if diff > 0 {
// Create a new empty slice and append it
- newSlice := make([]byte, diff+1)
+ newSlice := make([]byte, diff-1)
// Resize slice
m.store = append(m.store, newSlice...)
}
}
- copy(m.store[offset:offset+size+1], value)
+ copy(m.store[offset:offset+size], value)
}
func (m *Memory) Get(offset, size int64) []byte {
return m.store[offset : offset+size]
}
+
+func (m *Memory) Print() {
+ fmt.Println("### MEM ###")
+ if len(m.store) > 0 {
+ fmt.Println(m.store)
+ } else {
+ fmt.Println("-- empty --")
+ }
+ fmt.Println("###########")
+}