forked from cerc-io/plugeth
New mutan implementation
This commit is contained in:
parent
6d32bef65a
commit
b0dc50c2a0
@ -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) {
|
|||||||
|
|
||||||
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) {
|
|||||||
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
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user