MCPcopy Create free account
hub / github.com/akyoto/q / makeStructFromTuple

Method makeStructFromTuple

src/core/makeStructFromTuple.go:9–25  ·  view source on GitHub ↗

makeStructFromTuple creates a struct from elements in a tuple.

(tuple ssa.Value, typ types.Type, structType *types.Struct, name string, source ssa.Source)

Source from the content-addressed store, hash-verified

7
8// makeStructFromTuple creates a struct from elements in a tuple.
9func (f *Function) makeStructFromTuple(tuple ssa.Value, typ types.Type, structType *types.Struct, name string, source ssa.Source) *ssa.Struct {
10 fields := make([]ssa.Value, len(structType.Fields))
11
12 for i, field := range structType.Fields {
13 fieldValue := &ssa.Field{
14 Tuple: tuple,
15 Index: i,
16 Source: source,
17 }
18
19 f.Block().Append(fieldValue)
20 f.Block().Identify(name+"."+field.Name, fieldValue)
21 fields[i] = fieldValue
22 }
23
24 return f.makeStruct(typ, fields, source)
25}

Callers 2

defineMultiMethod · 0.95
defineMethod · 0.95

Calls 4

makeStructMethod · 0.95
BlockMethod · 0.80
IdentifyMethod · 0.80
AppendMethod · 0.45

Tested by

no test coverage detected