constant converts the given LLVM IR constant to a corresponding Go expression.
(c constant.Constant)
| 12 | // constant converts the given LLVM IR constant to a corresponding Go |
| 13 | // expression. |
| 14 | func (d *decompiler) constant(c constant.Constant) ast.Expr { |
| 15 | switch c := c.(type) { |
| 16 | // Simple constants |
| 17 | case *constant.Int: |
| 18 | return d.constInt(c) |
| 19 | case *constant.Float: |
| 20 | return d.constFloat(c) |
| 21 | case *constant.Null: |
| 22 | return d.constNull(c) |
| 23 | // Complex constants |
| 24 | case *constant.Vector: |
| 25 | return d.constVector(c) |
| 26 | case *constant.Array: |
| 27 | return d.constArray(c) |
| 28 | case *constant.Struct: |
| 29 | return d.constStruct(c) |
| 30 | case *constant.ZeroInitializer: |
| 31 | return d.constZeroInitializer(c) |
| 32 | // Global variable and function addresses |
| 33 | case *ir.Global: |
| 34 | return d.globalIdent(c.Name) |
| 35 | case *ir.Function: |
| 36 | return d.globalIdent(c.Name) |
| 37 | // Constant expressions |
| 38 | case constant.Expr: |
| 39 | return d.expr(c) |
| 40 | default: |
| 41 | panic(fmt.Sprintf("support for constant value %T not yet implemented", c)) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // constInt converts the given LLVM IR integer constant to a corresponding Go |
| 46 | // expression. |
no test coverage detected