Commit b0dc50c2 authored by obscuren's avatar obscuren

New mutan implementation

parent 6d32bef6
...@@ -3,6 +3,7 @@ package ethutil ...@@ -3,6 +3,7 @@ package ethutil
import ( import (
"fmt" "fmt"
"github.com/obscuren/mutan" "github.com/obscuren/mutan"
"github.com/obscuren/mutan/backends"
"github.com/obscuren/serpent-go" "github.com/obscuren/serpent-go"
"strings" "strings"
) )
...@@ -19,7 +20,9 @@ func Compile(script string) (ret []byte, err error) { ...@@ -19,7 +20,9 @@ func Compile(script string) (ret []byte, err error) {
return byteCode, nil return byteCode, nil
} else { } else {
byteCode, errors := mutan.Compile(strings.NewReader(script), false) compiler := mutan.NewCompiler(backend.NewEthereumBackend())
byteCode, errors := compiler.Compile(strings.NewReader(script))
//byteCode, errors := mutan.Compile(strings.NewReader(script), false)
if len(errors) > 0 { if len(errors) > 0 {
var errs string var errs string
for _, er := range errors { for _, er := range errors {
...@@ -33,21 +36,3 @@ func Compile(script string) (ret []byte, err error) { ...@@ -33,21 +36,3 @@ func Compile(script string) (ret []byte, err error) {
return byteCode, nil return byteCode, nil
} }
} }
func CompileScript(script string) ([]byte, []byte, error) {
// Preprocess
mainInput, initInput := mutan.PreParse(script)
// Compile main script
mainScript, err := Compile(mainInput)
if err != nil {
return nil, nil, err
}
// Compile init script
initScript, err := Compile(initInput)
if err != nil {
return nil, nil, err
}
return mainScript, initScript, nil
}
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