merge upstream

This commit is contained in:
zelig
2014-06-23 13:07:43 +01:00
8 changed files with 119 additions and 62 deletions

View File

@ -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()
}
}
return nil, fmt.Errorf("%v", errs)
}
func Compile(script string) (ret []byte, err error) {
c := strings.Split(script, "\n")[0]
return byteCode, nil
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 byteCode, nil
}
}
func CompileScript(script string) ([]byte, []byte, error) {