ConstStruct returns a constant struct with the value v.
(ty *Struct, fields map[string]interface{})
| 467 | |
| 468 | // ConstStruct returns a constant struct with the value v. |
| 469 | func (m *Module) ConstStruct(ty *Struct, fields map[string]interface{}) Const { |
| 470 | vals := make([]llvm.Value, len(ty.Fields())) |
| 471 | for i, f := range ty.Fields() { |
| 472 | if v := fields[f.Name]; v == nil { |
| 473 | vals[i] = llvm.ConstNull(f.Type.llvmTy()) |
| 474 | } else { |
| 475 | vals[i] = m.ScalarOfType(v, f.Type).llvm |
| 476 | } |
| 477 | } |
| 478 | val := llvm.ConstNamedStruct(ty.llvm, vals) |
| 479 | return Const{ty, val} |
| 480 | } |
| 481 | |
| 482 | // Zero returns a constant zero value of type ty. |
| 483 | func (m *Module) Zero(ty Type) Const { |
no test coverage detected