...

Source file src/github.com/cloudwego/iasm/repl/iasm_amd64.go

Documentation: github.com/cloudwego/iasm/repl

     1  //
     2  // Copyright 2024 CloudWeGo Authors
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package repl
    18  
    19  import (
    20      `errors`
    21  
    22      `github.com/cloudwego/iasm/x86_64`
    23  )
    24  
    25  type _IASMArchSpecific struct {
    26      ps x86_64.Parser
    27  }
    28  
    29  func (self *_IASMArchSpecific) doasm(addr uintptr, line string) ([]byte, error) {
    30      var err error
    31      var asm x86_64.Assembler
    32      var ast *x86_64.ParsedLine
    33  
    34      /* parse the line */
    35      if ast, err = self.ps.Feed(line); err != nil {
    36          return nil, err
    37      }
    38  
    39      /* interactive shell does not support labels */
    40      if ast.Kind == x86_64.LineLabel {
    41          return nil, errors.New("interactive shell does not support labels")
    42      }
    43  
    44      /* assemble the line */
    45      if err = asm.WithBase(addr).Assemble(line); err != nil {
    46          return nil, err
    47      } else {
    48          return asm.Code(), nil
    49      }
    50  }
    51  

View as plain text