aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/stack_table.go
diff options
context:
space:
mode:
authorjm <jm.huang@cobinhood.com>2019-01-15 00:48:13 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-05-06 10:44:03 +0800
commit266068a53cdf9e06acacf982d63653c03133a634 (patch)
treeaf2d74e6adb309adfe39bafaa2f540fe0bcd1a31 /core/vm/stack_table.go
parentd41cb421d755b8f0bca87b7476f26aa4b879b9d9 (diff)
downloaddexon-266068a53cdf9e06acacf982d63653c03133a634.tar
dexon-266068a53cdf9e06acacf982d63653c03133a634.tar.gz
dexon-266068a53cdf9e06acacf982d63653c03133a634.tar.bz2
dexon-266068a53cdf9e06acacf982d63653c03133a634.tar.lz
dexon-266068a53cdf9e06acacf982d63653c03133a634.tar.xz
dexon-266068a53cdf9e06acacf982d63653c03133a634.tar.zst
dexon-266068a53cdf9e06acacf982d63653c03133a634.zip
core: vm: refactor file structure
For support other vm types, this pr modified the core/vm file structures.
Diffstat (limited to 'core/vm/stack_table.go')
-rw-r--r--core/vm/stack_table.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/vm/stack_table.go b/core/vm/stack_table.go
index df544aef8..187d8fa1f 100644
--- a/core/vm/stack_table.go
+++ b/core/vm/stack_table.go
@@ -22,23 +22,27 @@ import (
"github.com/dexon-foundation/dexon/params"
)
-func makeStackFunc(pop, push int) stackValidationFunc {
+type (
+ StackValidationFunc func(*Stack) error
+)
+
+func MakeStackFunc(pop, push int) StackValidationFunc {
return func(stack *Stack) error {
- if err := stack.require(pop); err != nil {
+ if err := stack.Require(pop); err != nil {
return err
}
- if stack.len()+push-pop > int(params.StackLimit) {
- return fmt.Errorf("stack limit reached %d (%d)", stack.len(), params.StackLimit)
+ if stack.Len()+push-pop > int(params.StackLimit) {
+ return fmt.Errorf("stack limit reached %d (%d)", stack.Len(), params.StackLimit)
}
return nil
}
}
-func makeDupStackFunc(n int) stackValidationFunc {
- return makeStackFunc(n, n+1)
+func MakeDupStackFunc(n int) StackValidationFunc {
+ return MakeStackFunc(n, n+1)
}
-func makeSwapStackFunc(n int) stackValidationFunc {
- return makeStackFunc(n, n)
+func MakeSwapStackFunc(n int) StackValidationFunc {
+ return MakeStackFunc(n, n)
}