MCPcopy Create free account
hub / github.com/decomp/decomp / constCharArray

Method constCharArray

cmd/ll2go/constant.go:100–114  ·  view source on GitHub ↗

constCharArray converts the given LLVM IR character array constant to a corresponding Go expression.

(c *constant.Array)

Source from the content-addressed store, hash-verified

98// constCharArray converts the given LLVM IR character array constant to a
99// corresponding Go expression.
100func (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.

Callers 1

constArrayMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected