Index returns a new pointer to the array or field element found by following the list of indices as specified by path.
(path ...ValueIndexOrName)
| 192 | // Index returns a new pointer to the array or field element found by following |
| 193 | // the list of indices as specified by path. |
| 194 | func (v *Value) Index(path ...ValueIndexOrName) *Value { |
| 195 | if !IsPointer(v.ty) { |
| 196 | fail("Index only works with pointer value types. Got %v", v.Type().TypeName()) |
| 197 | } |
| 198 | indices, name, target := v.b.path(v.Type(), v.Name(), path...) |
| 199 | return v.b.val(v.b.m.Types.Pointer(target), v.b.llvm.CreateGEP(v.llvm, indices, "")).SetName(name) |
| 200 | } |
| 201 | |
| 202 | // Insert creates a copy of the struct or array v with the field/element at |
| 203 | // changed to val. |