github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/cmd/evm/internal/compiler/compiler.go (about) 1 2 //<developer> 3 // <name>linapex 曹一峰</name> 4 // <email>linapex@163.com</email> 5 // <wx>superexc</wx> 6 // <qqgroup>128148617</qqgroup> 7 // <url>https://jsq.ink</url> 8 // <role>pku engineer</role> 9 // <date>2019-03-16 12:09:27</date> 10 //</624342589893513216> 11 12 13 package compiler 14 15 import ( 16 "errors" 17 "fmt" 18 19 "github.com/ethereum/go-ethereum/core/asm" 20 ) 21 22 func Compile(fn string, src []byte, debug bool) (string, error) { 23 compiler := asm.NewCompiler(debug) 24 compiler.Feed(asm.Lex(fn, src, debug)) 25 26 bin, compileErrors := compiler.Compile() 27 if len(compileErrors) > 0 { 28 //报告错误 29 for _, err := range compileErrors { 30 fmt.Printf("%s:%v\n", fn, err) 31 } 32 return "", errors.New("compiling failed") 33 } 34 return bin, nil 35 } 36