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

Method evaluateMethod

src/core/evaluateMethod.go:10–32  ·  view source on GitHub ↗

evaluateMethod converts a method expression to an SSA value.

(leftValue ssa.Value, left *expression.Expression, right *expression.Expression, expr *expression.Expression)

Source from the content-addressed store, hash-verified

8
9// evaluateMethod converts a method expression to an SSA value.
10func (f *Function) evaluateMethod(leftValue ssa.Value, left *expression.Expression, right *expression.Expression, expr *expression.Expression) (ssa.Value, error) {
11 methodName := right.Token.StringFrom(f.File.Bytes)
12 leftUnwrapped := types.Unwrap(leftValue.Type())
13 pointer, isPointer := leftUnwrapped.(*types.Pointer)
14
15 if isPointer {
16 leftUnwrapped = pointer.To
17 }
18
19 call := expr.Parent
20 call.Children = append(call.Children, nil)
21 copy(call.Children[2:], call.Children[1:])
22 call.Children[1] = left
23
24 pkg := f.File.Package
25 structure, isStructPointer := leftUnwrapped.(*types.Struct)
26
27 if isStructPointer && structure.Package != "" {
28 pkg = structure.Package
29 }
30
31 return f.evaluatePackageMember(f.Env.Packages[pkg], methodName, expr)
32}

Callers 1

evaluateDotMethod · 0.95

Calls 4

evaluatePackageMemberMethod · 0.95
UnwrapFunction · 0.92
StringFromMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected