aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2014-06-23 20:07:43 +0800
committerzelig <viktor.tron@gmail.com>2014-06-23 20:07:43 +0800
commitf58c7ac5a6f5d77649c1c07dce94bf6d5c146c31 (patch)
tree31e286974108e02b29ed5eff0a73646f605998c2 /ethutil
parent63157c798d613f1ca638597515bb89768e2c1aad (diff)
parentd890258af6de8c5ef9701826fb4ee7c353788ad5 (diff)
downloadgo-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.gz
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.tar.zst
go-tangerine-f58c7ac5a6f5d77649c1c07dce94bf6d5c146c31.zip
merge upstream
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) {