New mutan implementation

This commit is contained in:
obscuren 2014-06-25 17:26:34 +02:00
parent 6d32bef65a
commit b0dc50c2a0
1 changed files with 4 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package ethutil
import (
"fmt"
"github.com/obscuren/mutan"
"github.com/obscuren/mutan/backends"
"github.com/obscuren/serpent-go"
"strings"
)
@ -19,7 +20,9 @@ func Compile(script string) (ret []byte, err error) {
return byteCode, nil
} 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 {
var errs string
for _, er := range errors {
@ -33,21 +36,3 @@ func Compile(script string) (ret []byte, err error) {
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
}