Commit 299b50a0 authored by obscuren's avatar obscuren

Support serpent lang

parent 931ae0f1
...@@ -3,11 +3,22 @@ package ethutil ...@@ -3,11 +3,22 @@ package ethutil
import ( import (
"fmt" "fmt"
"github.com/obscuren/mutan" "github.com/obscuren/mutan"
"github.com/obscuren/serpent-go"
"strings" "strings"
) )
// General compile function // 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) byteCode, errors := mutan.Compile(strings.NewReader(script), false)
if len(errors) > 0 { if len(errors) > 0 {
var errs string var errs string
...@@ -20,6 +31,7 @@ func Compile(script string) ([]byte, error) { ...@@ -20,6 +31,7 @@ func Compile(script string) ([]byte, error) {
} }
return byteCode, nil return byteCode, nil
}
} }
func CompileScript(script string) ([]byte, []byte, error) { func CompileScript(script string) ([]byte, []byte, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment