Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DFAState.h
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKSL_DFASTATE
9#define SKSL_DFASTATE
10
12
13#include <vector>
14#include <string>
15
16struct DFAState {
17 struct Label {
18 std::vector<int> fStates;
19
20 Label(std::vector<int> states)
21 : fStates(std::move(states)) {}
22
23 bool operator==(const Label& other) const {
24 return fStates == other.fStates;
25 }
26
27 bool operator!=(const Label& other) const {
28 return !(*this == other);
29 }
30
31#ifdef SK_DEBUG
32 std::string description() const {
33 std::string result = "<";
34 const char* separator = "";
35 for (int s : fStates) {
36 result += separator;
37 result += std::to_string(s);
38 separator = ", ";
39 }
40 result += ">";
41 return result;
42 }
43#endif
44 };
45
47 : fId(INVALID)
48 , fLabel({}) {}
49
50 DFAState(int id, Label label)
51 : fId(id)
52 , fLabel(std::move(label)) {}
53
54 DFAState(const DFAState& other) = delete;
55
56 int fId;
57
59
60 bool fIsScanned = false;
61};
62
63namespace std {
64 template<> struct hash<DFAState::Label> {
65 size_t operator()(const DFAState::Label& s) const {
66 size_t result = 0;
67 for (int i : s.fStates) {
68 result = result * 101 + i;
69 }
70 return result;
71 }
72 };
73} // namespace
74
75#endif
#define INVALID
Definition LexUtil.h:13
static uint32_t hash(const SkShaderBase::GradientInfo &v)
struct MyStruct s
GAsyncResult * result
Definition ref_ptr.h:256
bool operator!=(const Label &other) const
Definition DFAState.h:27
std::vector< int > fStates
Definition DFAState.h:18
bool operator==(const Label &other) const
Definition DFAState.h:23
Label(std::vector< int > states)
Definition DFAState.h:20
DFAState(const DFAState &other)=delete
Label fLabel
Definition DFAState.h:58
bool fIsScanned
Definition DFAState.h:60
DFAState()
Definition DFAState.h:46
int fId
Definition DFAState.h:56
DFAState(int id, Label label)
Definition DFAState.h:50
size_t operator()(const DFAState::Label &s) const
Definition DFAState.h:65
const uintptr_t id