1 /**
2 Copyright: Copyright (c) 2017, Joakim Brännström. All rights reserved.
3 License: MPL-2
4 Author: Joakim Brännström (joakim.brannstrom@gmx.com)
5 
6 This Source Code Form is subject to the terms of the Mozilla Public License,
7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain
8 one at http://mozilla.org/MPL/2.0/.
9 */
10 module dextool.plugin.fuzzer.type;
11 
12 public import cpptooling.data.symbol.types : FullyQualifiedNameType;
13 public import dextool.type : Path;
14 
15 struct SequenceId {
16     bool isValid;
17     ulong payload;
18     alias payload this;
19 }
20 
21 /// Symbol with parameter data.
22 @safe struct Symbol {
23     enum FilterKind {
24         keep,
25         exclude
26     }
27 
28     FullyQualifiedNameType fullyQualifiedName;
29     Param[] limits;
30 
31     FilterKind filter;
32 
33     Fuzz fuzz;
34 
35     SequenceId sequenceId;
36 
37     bool hasFuzz() {
38         return fuzz.use.length != 0;
39     }
40 
41     bool hasInclude() {
42         return fuzz.include.length != 0;
43     }
44 }
45 
46 /// Fuzzer function to use.
47 struct Fuzz {
48     FullyQualifiedNameType use;
49 
50     /// File the function exist in.
51     Path include;
52 
53     /// Parameters used when calling the custom fuzzer
54     string param;
55 }
56 
57 /// Data for a parameter such as limits.
58 @safe struct Param {
59     static struct Check {
60         string payload;
61         alias payload this;
62     }
63 
64     static struct Condition {
65         string payload;
66         alias payload this;
67     }
68 
69     static struct Identifier {
70         string payload;
71         alias payload this;
72     }
73 
74     Check check;
75     Fuzz fuzz;
76     Condition condition;
77     Identifier identifier;
78 
79     bool hasCheck() {
80         return check.length != 0 && condition.length != 0;
81     }
82 
83     bool hasFuzz() {
84         return fuzz.use.length != 0;
85     }
86 }