structField returns the memory for the struct field.
(leftValue ssa.Value, field *types.Field)
| 8 | |
| 9 | // structField returns the memory for the struct field. |
| 10 | func (f *Function) structField(leftValue ssa.Value, field *types.Field) *ssa.Memory { |
| 11 | memory, isMemory := leftValue.(*ssa.Memory) |
| 12 | |
| 13 | if isMemory { |
| 14 | copy := *memory |
| 15 | memory = © |
| 16 | |
| 17 | if memory.Scale { |
| 18 | memorySize := f.Append(&ssa.Int{Int: memory.Typ.Size()}) |
| 19 | memory.Index = f.Append(&ssa.BinaryOp{Op: token.Mul, Left: memory.Index, Right: memorySize}) |
| 20 | memory.Scale = false |
| 21 | } |
| 22 | |
| 23 | if field.Offset != 0 { |
| 24 | offset := f.Append(&ssa.Int{Int: int(field.Offset)}) |
| 25 | memory.Index = f.Append(&ssa.BinaryOp{Op: token.Add, Left: memory.Index, Right: offset}) |
| 26 | } |
| 27 | |
| 28 | memory.Typ = field.Type |
| 29 | } else { |
| 30 | offset := f.Append(&ssa.Int{Int: int(field.Offset)}) |
| 31 | |
| 32 | memory = &ssa.Memory{ |
| 33 | Address: leftValue, |
| 34 | Index: offset, |
| 35 | Scale: false, |
| 36 | Typ: field.Type, |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return memory |
| 41 | } |
no test coverage detected