makeStructFromTuple creates a struct from elements in a tuple.
(tuple ssa.Value, typ types.Type, structType *types.Struct, name string, source ssa.Source)
| 7 | |
| 8 | // makeStructFromTuple creates a struct from elements in a tuple. |
| 9 | func (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 | } |
no test coverage detected