aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-21 08:40:25 +0800
committerobscuren <geffobscura@gmail.com>2014-06-21 08:40:25 +0800
commit299b50a0d4e1ec0d7c6e5820c4f68da4e424f382 (patch)
tree939f6fa53df9d6b81ebbbdd537b57d9e554d0696 /ethutil
parent931ae0f116ca65c3758524160bf21e28f06db50e (diff)
downloadgo-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.tar
go-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.tar.gz
go-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.tar.bz2
go-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.tar.lz
go-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.tar.xz
go-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.tar.zst
go-tangerine-299b50a0d4e1ec0d7c6e5820c4f68da4e424f382.zip
Support serpent lang
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/script.go32
1 files changed, 22 insertions, 10 deletions
diff --git a/ethutil/script.go b/ethutil/script.go
index 94e401406..c8b1da51c 100644
--- a/ethutil/script.go
+++ b/ethutil/script.go
@@ -3,23 +3,35 @@ package ethutil
import (
"fmt"
"github.com/obscuren/mutan"
+ "github.com/obscuren/serpent-go"
"strings"
)
// General compile function
-func Compile(script string) ([]byte, error) {
- byteCode, errors := mutan.Compile(strings.NewReader(script), false)
- if len(errors) > 0 {
- var errs string
- for _, er := range errors {
- if er != nil {
- errs += er.Error()
+func Compile(script string) (ret []byte, err error) {
+ c := strings.Split(script, "\n")[0]
+
+ if c == "#!serpent" {
+ byteCode, err := serpent.Compile(script)
+ if err != nil {
+ return nil, err
+ }
+
+ return byteCode, nil
+ } else {
+ byteCode, errors := mutan.Compile(strings.NewReader(script), false)
+ if len(errors) > 0 {
+ var errs string
+ for _, er := range errors {
+ if er != nil {
+ errs += er.Error()
+ }
}
+ return nil, fmt.Errorf("%v", errs)
}
- return nil, fmt.Errorf("%v", errs)
- }
- return byteCode, nil
+ return byteCode, nil
+ }
}
func CompileScript(script string) ([]byte, []byte, error) {