Support serpent lang

This commit is contained in:
obscuren 2014-06-21 02:40:25 +02:00
parent 931ae0f116
commit 299b50a0d4

View File

@ -3,11 +3,22 @@ package ethutil
import (
"fmt"
"github.com/obscuren/mutan"
"github.com/obscuren/serpent-go"
"strings"
)
// General compile function
func Compile(script string) ([]byte, 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
@ -21,6 +32,7 @@ func Compile(script string) ([]byte, error) {
return byteCode, nil
}
}
func CompileScript(script string) ([]byte, []byte, error) {
// Preprocess