constCharArray converts the given LLVM IR character array constant to a corresponding Go expression.
(c *constant.Array)
| 98 | // constCharArray converts the given LLVM IR character array constant to a |
| 99 | // corresponding Go expression. |
| 100 | func (d *decompiler) constCharArray(c *constant.Array) ast.Expr { |
| 101 | var buf []byte |
| 102 | for _, e := range c.Elems { |
| 103 | elem, ok := e.(*constant.Int) |
| 104 | if !ok { |
| 105 | panic(fmt.Sprintf("invalid constant type; expected *constant.Int, got %T", e)) |
| 106 | } |
| 107 | b := byte(elem.Int64()) |
| 108 | buf = append(buf, b) |
| 109 | } |
| 110 | return &ast.BasicLit{ |
| 111 | Kind: token.STRING, |
| 112 | Value: fmt.Sprintf("%q", string(buf)), |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // constStruct converts the given LLVM IR struct constant to a corresponding Go |
| 117 | // expression. |