Commit d5bcc01e authored by obscuren's avatar obscuren

Fixed shebang check. Previously it would hang on an unknown shebang

parent 633027d9
...@@ -10,28 +10,36 @@ import ( ...@@ -10,28 +10,36 @@ import (
// General compile function // General compile function
func Compile(script string) (ret []byte, err error) { func Compile(script string) (ret []byte, err error) {
c := strings.Split(script, "\n")[0] if len(script) > 2 {
line := strings.Split(script, "\n")[0]
if c == "#!serpent" { if line[0:2] == "#!" {
byteCode, err := serpent.Compile(script) switch line {
if err != nil { case "#!serpent":
return nil, err byteCode, err := serpent.Compile(script)
} if err != nil {
return nil, err
}
return byteCode, nil
}
} else {
return byteCode, nil compiler := mutan.NewCompiler(backend.NewEthereumBackend())
} else { byteCode, errors := compiler.Compile(strings.NewReader(script))
compiler := mutan.NewCompiler(backend.NewEthereumBackend()) if len(errors) > 0 {
byteCode, errors := compiler.Compile(strings.NewReader(script)) var errs string
if len(errors) > 0 { for _, er := range errors {
var errs string if er != nil {
for _, er := range errors { errs += er.Error()
if er != nil { }
errs += er.Error()
} }
return nil, fmt.Errorf("%v", errs)
} }
return nil, fmt.Errorf("%v", errs)
}
return byteCode, nil return byteCode, nil
}
} }
return nil, 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