Extract returns the field at extracted from the struct or array v.
(at IndexOrName)
| 222 | |
| 223 | // Extract returns the field at extracted from the struct or array v. |
| 224 | func (v *Value) Extract(at IndexOrName) *Value { |
| 225 | switch ty := v.ty.(type) { |
| 226 | case *Struct: |
| 227 | f, idx := field(ty, at) |
| 228 | return v.b.val(f.Type, v.b.llvm.CreateExtractValue(v.llvm, idx, f.Name)) |
| 229 | case *Array: |
| 230 | idx, ok := at.(int) |
| 231 | if !ok { |
| 232 | fail("Extract parameter at must be int for arrays values. Got %T", at) |
| 233 | } |
| 234 | return v.b.val(ty.Element, v.b.llvm.CreateExtractValue(v.llvm, idx, fmt.Sprintf("%v[%d]", v.name, idx))) |
| 235 | default: |
| 236 | fail("Attempted to extract on non-struct and non-array type %v", v.ty.TypeName()) |
| 237 | return nil |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | // IsNull returns true if the pointer value v is null. |
| 242 | func (v *Value) IsNull() *Value { |
no test coverage detected