github.com/chenzhuoyu/iasm@v0.9.1/repl/iasm_amd64.go (about) 1 package repl 2 3 import ( 4 `errors` 5 6 `github.com/chenzhuoyu/iasm/x86_64` 7 ) 8 9 type _IASMArchSpecific struct { 10 ps x86_64.Parser 11 } 12 13 func (self *_IASMArchSpecific) doasm(addr uintptr, line string) ([]byte, error) { 14 var err error 15 var asm x86_64.Assembler 16 var ast *x86_64.ParsedLine 17 18 /* parse the line */ 19 if ast, err = self.ps.Feed(line); err != nil { 20 return nil, err 21 } 22 23 /* interactive shell does not support labels */ 24 if ast.Kind == x86_64.LineLabel { 25 return nil, errors.New("interactive shell does not support labels") 26 } 27 28 /* assemble the line */ 29 if err = asm.WithBase(addr).Assemble(line); err != nil { 30 return nil, err 31 } else { 32 return asm.Code(), nil 33 } 34 }