summaryrefslogtreecommitdiffstats
path: root/js/src/irregexp/imported/special-case.cc
blob: f5a9928b3a766a4118069f4c62c6f56e9dc11f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.

// Automatically generated by regexp/gen-regexp-special-case.cc

// The following functions are used to build UnicodeSets
// for special cases where the case-folding algorithm used by
// UnicodeSet::closeOver(USET_CASE_INSENSITIVE) does not match
// the algorithm defined in ECMAScript 2020 21.2.2.8.2 (Runtime
// Semantics: Canonicalize) step 3.

#ifdef V8_INTL_SUPPORT
#include "irregexp/imported/special-case.h"

#include "unicode/uniset.h"
namespace v8 {
namespace internal {

icu::UnicodeSet BuildIgnoreSet() {
  icu::UnicodeSet set;
  set.add(0xdf);
  set.add(0x17f);
  set.add(0x390);
  set.add(0x3b0);
  set.add(0x3f4);
  set.add(0x1e9e);
  set.add(0x1f80, 0x1faf);
  set.add(0x1fb3);
  set.add(0x1fbc);
  set.add(0x1fc3);
  set.add(0x1fcc);
  set.add(0x1fd3);
  set.add(0x1fe3);
  set.add(0x1ff3);
  set.add(0x1ffc);
  set.add(0x2126);
  set.add(0x212a, 0x212b);
  set.add(0xfb05, 0xfb06);
  set.freeze();
  return set;
}

struct IgnoreSetData {
  IgnoreSetData() : set(BuildIgnoreSet()) {}
  const icu::UnicodeSet set;
};

//static
const icu::UnicodeSet& RegExpCaseFolding::IgnoreSet() {
  static base::LazyInstance<IgnoreSetData>::type set =
      LAZY_INSTANCE_INITIALIZER;
  return set.Pointer()->set;
}

icu::UnicodeSet BuildSpecialAddSet() {
  icu::UnicodeSet set;
  set.add(0x4b);
  set.add(0x53);
  set.add(0x6b);
  set.add(0x73);
  set.add(0xc5);
  set.add(0xe5);
  set.add(0x398);
  set.add(0x3a9);
  set.add(0x3b8);
  set.add(0x3c9);
  set.add(0x3d1);
  set.freeze();
  return set;
}

struct SpecialAddSetData {
  SpecialAddSetData() : set(BuildSpecialAddSet()) {}
  const icu::UnicodeSet set;
};

//static
const icu::UnicodeSet& RegExpCaseFolding::SpecialAddSet() {
  static base::LazyInstance<SpecialAddSetData>::type set =
      LAZY_INSTANCE_INITIALIZER;
  return set.Pointer()->set;
}

icu::UnicodeSet BuildUnicodeNonSimpleCloseOverSet() {
  icu::UnicodeSet set;
  set.add(0x390);
  set.add(0x3b0);
  set.add(0x1fd3);
  set.add(0x1fe3);
  set.add(0xfb05, 0xfb06);
  set.freeze();
  return set;
}

struct UnicodeNonSimpleCloseOverSetData {
  UnicodeNonSimpleCloseOverSetData() : set(BuildUnicodeNonSimpleCloseOverSet()) {}
  const icu::UnicodeSet set;
};

//static
const icu::UnicodeSet& RegExpCaseFolding::UnicodeNonSimpleCloseOverSet() {
  static base::LazyInstance<UnicodeNonSimpleCloseOverSetData>::type set =
      LAZY_INSTANCE_INITIALIZER;
  return set.Pointer()->set;
}


}  // namespace internal
}  // namespace v8
#endif  // V8_INTL_SUPPORT