MCPcopy Create free account
hub / github.com/google/gapid / Extract

Method Extract

core/codegen/value.go:224–239  ·  view source on GitHub ↗

Extract returns the field at extracted from the struct or array v.

(at IndexOrName)

Source from the content-addressed store, hash-verified

222
223// Extract returns the field at extracted from the struct or array v.
224func (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.
242func (v *Value) IsNull() *Value {

Callers 15

EqualMethod · 0.80
NotEqualMethod · 0.80
PrintfSpecifierMethod · 0.80
copyMethod · 0.80
sliceAssignMethod · 0.80
doCastMethod · 0.80
cloneMethod · 0.80
lengthMethod · 0.80
memberMethod · 0.80
sliceIndexMethod · 0.80
sliceRangeMethod · 0.80
buildRefRelsMethod · 0.80

Calls 4

fieldFunction · 0.70
failFunction · 0.70
TypeNameMethod · 0.65
valMethod · 0.45

Tested by

no test coverage detected