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

Method evaluateString

src/core/evaluateString.go:10–29  ·  view source on GitHub ↗

evaluateString converts a string expression to an SSA value.

(expr *expression.Expression)

Source from the content-addressed store, hash-verified

8
9// evaluateString converts a string expression to an SSA value.
10func (f *Function) evaluateString(expr *expression.Expression) (ssa.Value, error) {
11 data, err := unescape(expr.Token, f.File)
12
13 if err != nil {
14 return nil, err
15 }
16
17 length := f.Append(&ssa.Int{
18 Int: len(data),
19 Source: expr.Source(),
20 })
21
22 pointer := f.Append(&ssa.Bytes{
23 Bytes: data,
24 Source: expr.Source(),
25 })
26
27 v := f.makeStruct(types.String, []ssa.Value{pointer, length}, expr.Source())
28 return v, nil
29}

Callers 1

evaluateLeafMethod · 0.95

Calls 4

makeStructMethod · 0.95
unescapeFunction · 0.85
AppendMethod · 0.45
SourceMethod · 0.45

Tested by

no test coverage detected