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

Method structField

src/core/structField.go:10–41  ·  view source on GitHub ↗

structField returns the memory for the struct field.

(leftValue ssa.Value, field *types.Field)

Source from the content-addressed store, hash-verified

8
9// structField returns the memory for the struct field.
10func (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 = &copy
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}

Callers 5

loadFieldsMethod · 0.95
compileStoreFieldMethod · 0.95
storeFieldsMethod · 0.95
evaluateNewStructMethod · 0.95
fieldFromMemoryMethod · 0.95

Calls 2

SizeMethod · 0.65
AppendMethod · 0.45

Tested by

no test coverage detected