Debian Codegraph @

cmd/signature-fuzzer/internal/fuzz-generator/stringparm.go

raw symbols SCIP
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package generator
6
7 import (
8 "bytes"
9 )
10
11 // stringparm describes a parameter of string type; it implements the
12 // "parm" interface
13 type stringparm struct {
14 tag string
15 isBlank
16 addrTakenHow
17 isGenValFunc
18 skipCompare
19 }
20
21 func (p stringparm) Declare(b *bytes.Buffer, prefix string, suffix string, caller bool) {
22 b.WriteString(prefix + " string" + suffix)
23 }
24
25 func (p stringparm) GenElemRef(elidx int, path string) (string, parm) {
26 return path, &p
27 }
28
29 var letters = []rune("�꿦3򂨃f6ꂅ8ˋ<􂊇񊶿(z̽|ϣᇊ񁗇򟄼q񧲥筁{ЂƜĽ")
30
31 func (p stringparm) GenValue(s *genstate, f *funcdef, value int, caller bool) (string, int) {
32 ns := len(letters) - 9
33 nel := int(s.wr.Intn(8))
34 st := int(s.wr.Intn(int64(ns)))
35 en := min(st+nel, ns)
36 return "\"" + string(letters[st:en]) + "\"", value + 1
37 }
38
39 func (p stringparm) IsControl() bool {
40 return false
41 }
42
43 func (p stringparm) NumElements() int {
44 return 1
45 }
46
47 func (p stringparm) String() string {
48 return "string"
49 }
50
51 func (p stringparm) TypeName() string {
52 return "string"
53 }
54
55 func (p stringparm) QualName() string {
56 return "string"
57 }
58
59 func (p stringparm) HasPointer() bool {
60 return false
61 }