Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/ds/Tokenizer.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "Tokenizer.h"
8
9
#include "nsUnicharUtils.h"
10
#include <algorithm>
11
12
namespace mozilla {
13
14
template<>
15
char const TokenizerBase<char>::sWhitespaces[] = { ' ', '\t', 0 };
16
template<>
17
char16_t const TokenizerBase<char16_t>::sWhitespaces[3] = { ' ', '\t', 0 };
18
19
template<typename TChar>
20
static bool
21
contains(TChar const* const list, TChar const needle)
22
8.06M
{
23
32.2M
  for (TChar const *c = list; *c; ++c) {
24
24.1M
    if (needle == *c) {
25
0
      return true;
26
0
    }
27
24.1M
  }
28
8.06M
  return false;
29
8.06M
}
Unified_cpp_xpcom_ds0.cpp:bool mozilla::contains<char>(char const*, char)
Line
Count
Source
22
8.06M
{
23
32.2M
  for (TChar const *c = list; *c; ++c) {
24
24.1M
    if (needle == *c) {
25
0
      return true;
26
0
    }
27
24.1M
  }
28
8.06M
  return false;
29
8.06M
}
Unexecuted instantiation: Unified_cpp_xpcom_ds0.cpp:bool mozilla::contains<char16_t>(char16_t const*, char16_t)
30
31
template<typename TChar>
32
TTokenizer<TChar>::TTokenizer(const typename base::TAString& aSource,
33
                              const TChar* aWhitespaces,
34
                              const TChar* aAdditionalWordChars)
35
  : TokenizerBase<TChar>(aWhitespaces, aAdditionalWordChars)
36
6.09M
{
37
6.09M
  base::mInputFinished = true;
38
6.09M
  aSource.BeginReading(base::mCursor);
39
6.09M
  mRecord = mRollback = base::mCursor;
40
6.09M
  aSource.EndReading(base::mEnd);
41
6.09M
}
mozilla::TTokenizer<char>::TTokenizer(nsTSubstring<char> const&, char const*, char const*)
Line
Count
Source
36
6.09M
{
37
6.09M
  base::mInputFinished = true;
38
6.09M
  aSource.BeginReading(base::mCursor);
39
6.09M
  mRecord = mRollback = base::mCursor;
40
6.09M
  aSource.EndReading(base::mEnd);
41
6.09M
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::TTokenizer(nsTSubstring<char16_t> const&, char16_t const*, char16_t const*)
42
43
template<typename TChar>
44
TTokenizer<TChar>::TTokenizer(const TChar* aSource,
45
                              const TChar* aWhitespaces,
46
                              const TChar* aAdditionalWordChars)
47
  : TTokenizer(typename base::TDependentString(aSource), aWhitespaces, aAdditionalWordChars)
48
12
{
49
12
}
mozilla::TTokenizer<char>::TTokenizer(char const*, char const*, char const*)
Line
Count
Source
48
12
{
49
12
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::TTokenizer(char16_t const*, char16_t const*, char16_t const*)
50
51
template<typename TChar>
52
bool
53
TTokenizer<TChar>::Next(typename base::Token& aToken)
54
0
{
55
0
  if (!base::HasInput()) {
56
0
    base::mHasFailed = true;
57
0
    return false;
58
0
  }
59
0
60
0
  mRollback = base::mCursor;
61
0
  base::mCursor = base::Parse(aToken);
62
0
63
0
  base::AssignFragment(aToken, mRollback, base::mCursor);
64
0
65
0
  base::mPastEof = aToken.Type() == base::TOKEN_EOF;
66
0
  base::mHasFailed = false;
67
0
  return true;
68
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::Next(mozilla::TokenizerBase<char>::Token&)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Next(mozilla::TokenizerBase<char16_t>::Token&)
69
70
template<typename TChar>
71
bool
72
TTokenizer<TChar>::Check(const typename base::TokenType aTokenType, typename base::Token& aResult)
73
0
{
74
0
  if (!base::HasInput()) {
75
0
    base::mHasFailed = true;
76
0
    return false;
77
0
  }
78
0
79
0
  typename base::TAString::const_char_iterator next = base::Parse(aResult);
80
0
  if (aTokenType != aResult.Type()) {
81
0
    base::mHasFailed = true;
82
0
    return false;
83
0
  }
84
0
85
0
  mRollback = base::mCursor;
86
0
  base::mCursor = next;
87
0
88
0
  base::AssignFragment(aResult, mRollback, base::mCursor);
89
0
90
0
  base::mPastEof = aResult.Type() == base::TOKEN_EOF;
91
0
  base::mHasFailed = false;
92
0
  return true;
93
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::Check(mozilla::TokenizerBase<char>::TokenType, mozilla::TokenizerBase<char>::Token&)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Check(mozilla::TokenizerBase<char16_t>::TokenType, mozilla::TokenizerBase<char16_t>::Token&)
94
95
template<typename TChar>
96
bool
97
TTokenizer<TChar>::Check(const typename base::Token& aToken)
98
9.33M
{
99
9.33M
  if (!base::HasInput()) {
100
0
    base::mHasFailed = true;
101
0
    return false;
102
0
  }
103
9.33M
104
9.33M
  typename base::Token parsed;
105
9.33M
  typename base::TAString::const_char_iterator next = base::Parse(parsed);
106
9.33M
  if (!aToken.Equals(parsed)) {
107
5.33M
    base::mHasFailed = true;
108
5.33M
    return false;
109
5.33M
  }
110
3.99M
111
3.99M
  mRollback = base::mCursor;
112
3.99M
  base::mCursor = next;
113
3.99M
  base::mPastEof = parsed.Type() == base::TOKEN_EOF;
114
3.99M
  base::mHasFailed = false;
115
3.99M
  return true;
116
3.99M
}
mozilla::TTokenizer<char>::Check(mozilla::TokenizerBase<char>::Token const&)
Line
Count
Source
98
9.33M
{
99
9.33M
  if (!base::HasInput()) {
100
0
    base::mHasFailed = true;
101
0
    return false;
102
0
  }
103
9.33M
104
9.33M
  typename base::Token parsed;
105
9.33M
  typename base::TAString::const_char_iterator next = base::Parse(parsed);
106
9.33M
  if (!aToken.Equals(parsed)) {
107
5.33M
    base::mHasFailed = true;
108
5.33M
    return false;
109
5.33M
  }
110
3.99M
111
3.99M
  mRollback = base::mCursor;
112
3.99M
  base::mCursor = next;
113
3.99M
  base::mPastEof = parsed.Type() == base::TOKEN_EOF;
114
3.99M
  base::mHasFailed = false;
115
3.99M
  return true;
116
3.99M
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Check(mozilla::TokenizerBase<char16_t>::Token const&)
117
118
template<typename TChar>
119
void
120
TTokenizer<TChar>::SkipWhites(WhiteSkipping aIncludeNewLines)
121
79.4k
{
122
79.4k
  if (!CheckWhite() && (aIncludeNewLines == DONT_INCLUDE_NEW_LINE || !CheckEOL())) {
123
79.4k
    return;
124
79.4k
  }
125
0
126
0
  typename base::TAString::const_char_iterator rollback = mRollback;
127
0
  while (CheckWhite() || (aIncludeNewLines == INCLUDE_NEW_LINE && CheckEOL())) {
128
0
  }
129
0
130
0
  base::mHasFailed = false;
131
0
  mRollback = rollback;
132
0
}
mozilla::TTokenizer<char>::SkipWhites(mozilla::TTokenizer<char>::WhiteSkipping)
Line
Count
Source
121
79.4k
{
122
79.4k
  if (!CheckWhite() && (aIncludeNewLines == DONT_INCLUDE_NEW_LINE || !CheckEOL())) {
123
79.4k
    return;
124
79.4k
  }
125
0
126
0
  typename base::TAString::const_char_iterator rollback = mRollback;
127
0
  while (CheckWhite() || (aIncludeNewLines == INCLUDE_NEW_LINE && CheckEOL())) {
128
0
  }
129
0
130
0
  base::mHasFailed = false;
131
0
  mRollback = rollback;
132
0
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::SkipWhites(mozilla::TTokenizer<char16_t>::WhiteSkipping)
133
134
template<typename TChar>
135
void
136
TTokenizer<TChar>::SkipUntil(typename base::Token const& aToken)
137
0
{
138
0
  typename base::TAString::const_char_iterator rollback = base::mCursor;
139
0
  const typename base::Token eof = base::Token::EndOfFile();
140
0
141
0
  typename base::Token t;
142
0
  while (Next(t)) {
143
0
    if (aToken.Equals(t) || eof.Equals(t)) {
144
0
      Rollback();
145
0
      break;
146
0
    }
147
0
  }
148
0
149
0
  mRollback = rollback;
150
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::SkipUntil(mozilla::TokenizerBase<char>::Token const&)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::SkipUntil(mozilla::TokenizerBase<char16_t>::Token const&)
151
152
template<typename TChar>
153
bool
154
TTokenizer<TChar>::CheckChar(bool (*aClassifier)(const TChar aChar))
155
25.6M
{
156
25.6M
  if (!aClassifier) {
157
0
    MOZ_ASSERT(false);
158
0
    return false;
159
0
  }
160
25.6M
161
25.6M
  if (!base::HasInput() || base::mCursor == base::mEnd) {
162
598k
    base::mHasFailed = true;
163
598k
    return false;
164
598k
  }
165
25.0M
166
25.0M
  if (!aClassifier(*base::mCursor)) {
167
5.49M
    base::mHasFailed = true;
168
5.49M
    return false;
169
5.49M
  }
170
19.5M
171
19.5M
  mRollback = base::mCursor;
172
19.5M
  ++base::mCursor;
173
19.5M
  base::mHasFailed = false;
174
19.5M
  return true;
175
19.5M
}
mozilla::TTokenizer<char>::CheckChar(bool (*)(char))
Line
Count
Source
155
25.6M
{
156
25.6M
  if (!aClassifier) {
157
0
    MOZ_ASSERT(false);
158
0
    return false;
159
0
  }
160
25.6M
161
25.6M
  if (!base::HasInput() || base::mCursor == base::mEnd) {
162
598k
    base::mHasFailed = true;
163
598k
    return false;
164
598k
  }
165
25.0M
166
25.0M
  if (!aClassifier(*base::mCursor)) {
167
5.49M
    base::mHasFailed = true;
168
5.49M
    return false;
169
5.49M
  }
170
19.5M
171
19.5M
  mRollback = base::mCursor;
172
19.5M
  ++base::mCursor;
173
19.5M
  base::mHasFailed = false;
174
19.5M
  return true;
175
19.5M
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::CheckChar(bool (*)(char16_t))
176
177
template<typename TChar>
178
bool
179
TTokenizer<TChar>::ReadChar(TChar* aValue)
180
0
{
181
0
  MOZ_RELEASE_ASSERT(aValue);
182
0
183
0
  typename base::Token t;
184
0
  if (!Check(base::TOKEN_CHAR, t)) {
185
0
    return false;
186
0
  }
187
0
188
0
  *aValue = t.AsChar();
189
0
  return true;
190
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::ReadChar(char*)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::ReadChar(char16_t*)
191
192
template<typename TChar>
193
bool
194
TTokenizer<TChar>::ReadChar(bool (*aClassifier)(const TChar aChar), TChar* aValue)
195
0
{
196
0
  MOZ_RELEASE_ASSERT(aValue);
197
0
198
0
  if (!CheckChar(aClassifier)) {
199
0
    return false;
200
0
  }
201
0
202
0
  *aValue = *mRollback;
203
0
  return true;
204
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::ReadChar(bool (*)(char), char*)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::ReadChar(bool (*)(char16_t), char16_t*)
205
206
template<typename TChar>
207
bool
208
TTokenizer<TChar>::ReadWord(typename base::TAString& aValue)
209
0
{
210
0
  typename base::Token t;
211
0
  if (!Check(base::TOKEN_WORD, t)) {
212
0
    return false;
213
0
  }
214
0
215
0
  aValue.Assign(t.AsString());
216
0
  return true;
217
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::ReadWord(nsTSubstring<char>&)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::ReadWord(nsTSubstring<char16_t>&)
218
219
template<typename TChar>
220
bool
221
TTokenizer<TChar>::ReadWord(typename base::TDependentSubstring& aValue)
222
0
{
223
0
  typename base::Token t;
224
0
  if (!Check(base::TOKEN_WORD, t)) {
225
0
    return false;
226
0
  }
227
0
228
0
  aValue.Rebind(t.AsString().BeginReading(), t.AsString().Length());
229
0
  return true;
230
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::ReadWord(nsTDependentSubstring<char>&)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::ReadWord(nsTDependentSubstring<char16_t>&)
231
232
template<typename TChar>
233
bool
234
TTokenizer<TChar>::ReadUntil(typename base::Token const& aToken, typename base::TAString& aResult, ClaimInclusion aInclude)
235
0
{
236
0
  typename base::TDependentSubstring substring;
237
0
  bool rv = ReadUntil(aToken, substring, aInclude);
238
0
  aResult.Assign(substring);
239
0
  return rv;
240
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::ReadUntil(mozilla::TokenizerBase<char>::Token const&, nsTSubstring<char>&, mozilla::TTokenizer<char>::ClaimInclusion)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::ReadUntil(mozilla::TokenizerBase<char16_t>::Token const&, nsTSubstring<char16_t>&, mozilla::TTokenizer<char16_t>::ClaimInclusion)
241
242
template<typename TChar>
243
bool
244
TTokenizer<TChar>::ReadUntil(typename base::Token const& aToken, typename base::TDependentSubstring& aResult, ClaimInclusion aInclude)
245
0
{
246
0
  typename base::TAString::const_char_iterator record = mRecord;
247
0
  Record();
248
0
  typename base::TAString::const_char_iterator rollback = mRollback = base::mCursor;
249
0
250
0
  bool found = false;
251
0
  typename base::Token t;
252
0
  while (Next(t)) {
253
0
    if (aToken.Equals(t)) {
254
0
      found = true;
255
0
      break;
256
0
    }
257
0
    if (t.Equals(base::Token::EndOfFile())) {
258
0
      // We don't want to eat it.
259
0
      Rollback();
260
0
      break;
261
0
    }
262
0
  }
263
0
264
0
  Claim(aResult, aInclude);
265
0
  mRollback = rollback;
266
0
  mRecord = record;
267
0
  return found;
268
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::ReadUntil(mozilla::TokenizerBase<char>::Token const&, nsTDependentSubstring<char>&, mozilla::TTokenizer<char>::ClaimInclusion)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::ReadUntil(mozilla::TokenizerBase<char16_t>::Token const&, nsTDependentSubstring<char16_t>&, mozilla::TTokenizer<char16_t>::ClaimInclusion)
269
270
template<typename TChar>
271
void
272
TTokenizer<TChar>::Rollback()
273
0
{
274
0
  MOZ_ASSERT(base::mCursor > mRollback || base::mPastEof, "TODO!!!");
275
0
276
0
  base::mPastEof = false;
277
0
  base::mHasFailed = false;
278
0
  base::mCursor = mRollback;
279
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::Rollback()
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Rollback()
280
281
template<typename TChar>
282
void
283
TTokenizer<TChar>::Record(ClaimInclusion aInclude)
284
4.97M
{
285
4.97M
  mRecord = aInclude == INCLUDE_LAST
286
4.97M
    ? mRollback
287
4.97M
    : base::mCursor;
288
4.97M
}
mozilla::TTokenizer<char>::Record(mozilla::TTokenizer<char>::ClaimInclusion)
Line
Count
Source
284
4.97M
{
285
4.97M
  mRecord = aInclude == INCLUDE_LAST
286
4.97M
    ? mRollback
287
4.97M
    : base::mCursor;
288
4.97M
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Record(mozilla::TTokenizer<char16_t>::ClaimInclusion)
289
290
template<typename TChar>
291
void
292
TTokenizer<TChar>::Claim(typename base::TAString& aResult, ClaimInclusion aInclusion)
293
3.91M
{
294
3.91M
  typename base::TAString::const_char_iterator close = aInclusion == EXCLUDE_LAST
295
3.91M
    ? mRollback
296
3.91M
    : base::mCursor;
297
3.91M
  aResult.Assign(Substring(mRecord, close));
298
3.91M
}
mozilla::TTokenizer<char>::Claim(nsTSubstring<char>&, mozilla::TTokenizer<char>::ClaimInclusion)
Line
Count
Source
293
3.91M
{
294
3.91M
  typename base::TAString::const_char_iterator close = aInclusion == EXCLUDE_LAST
295
3.91M
    ? mRollback
296
3.91M
    : base::mCursor;
297
3.91M
  aResult.Assign(Substring(mRecord, close));
298
3.91M
}
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Claim(nsTSubstring<char16_t>&, mozilla::TTokenizer<char16_t>::ClaimInclusion)
299
300
template<typename TChar>
301
void
302
TTokenizer<TChar>::Claim(typename base::TDependentSubstring& aResult, ClaimInclusion aInclusion)
303
0
{
304
0
  typename base::TAString::const_char_iterator close = aInclusion == EXCLUDE_LAST
305
0
    ? mRollback
306
0
    : base::mCursor;
307
0
308
0
  MOZ_RELEASE_ASSERT(close >= mRecord, "Overflow!");
309
0
  aResult.Rebind(mRecord, close - mRecord);
310
0
}
Unexecuted instantiation: mozilla::TTokenizer<char>::Claim(nsTDependentSubstring<char>&, mozilla::TTokenizer<char>::ClaimInclusion)
Unexecuted instantiation: mozilla::TTokenizer<char16_t>::Claim(nsTDependentSubstring<char16_t>&, mozilla::TTokenizer<char16_t>::ClaimInclusion)
311
312
// TokenizerBase
313
314
template<typename TChar>
315
TokenizerBase<TChar>::TokenizerBase(const TChar* aWhitespaces,
316
                                    const TChar* aAdditionalWordChars)
317
  : mPastEof(false)
318
  , mHasFailed(false)
319
  , mInputFinished(true)
320
  , mMode(Mode::FULL)
321
  , mMinRawDelivery(1024)
322
  , mWhitespaces(aWhitespaces ? aWhitespaces : sWhitespaces)
323
  , mAdditionalWordChars(aAdditionalWordChars)
324
  , mCursor(nullptr)
325
  , mEnd(nullptr)
326
  , mNextCustomTokenID(TOKEN_CUSTOM0)
327
6.09M
{
328
6.09M
}
mozilla::TokenizerBase<char>::TokenizerBase(char const*, char const*)
Line
Count
Source
327
6.09M
{
328
6.09M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::TokenizerBase(char16_t const*, char16_t const*)
329
330
template<typename TChar>
331
auto
332
TokenizerBase<TChar>::AddCustomToken(const TAString & aValue,
333
                                     ECaseSensitivity aCaseInsensitivity, bool aEnabled)
334
  -> Token
335
0
{
336
0
  MOZ_ASSERT(!aValue.IsEmpty());
337
0
338
0
  UniquePtr<Token>& t = *mCustomTokens.AppendElement();
339
0
  t = MakeUnique<Token>();
340
0
341
0
  t->mType = static_cast<TokenType>(++mNextCustomTokenID);
342
0
  t->mCustomCaseInsensitivity = aCaseInsensitivity;
343
0
  t->mCustomEnabled = aEnabled;
344
0
  t->mCustom.Assign(aValue);
345
0
  return *t;
346
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::AddCustomToken(nsTSubstring<char> const&, mozilla::TokenizerBase<char>::ECaseSensitivity, bool)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::AddCustomToken(nsTSubstring<char16_t> const&, mozilla::TokenizerBase<char16_t>::ECaseSensitivity, bool)
347
348
template<typename TChar>
349
void
350
TokenizerBase<TChar>::RemoveCustomToken(Token& aToken)
351
0
{
352
0
  if (aToken.mType == TOKEN_UNKNOWN) {
353
0
    // Already removed
354
0
    return;
355
0
  }
356
0
357
0
  for (UniquePtr<Token> const& custom : mCustomTokens) {
358
0
    if (custom->mType == aToken.mType) {
359
0
      mCustomTokens.RemoveElement(custom);
360
0
      aToken.mType = TOKEN_UNKNOWN;
361
0
      return;
362
0
    }
363
0
  }
364
0
365
0
  MOZ_ASSERT(false, "Token to remove not found");
366
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::RemoveCustomToken(mozilla::TokenizerBase<char>::Token&)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::RemoveCustomToken(mozilla::TokenizerBase<char16_t>::Token&)
367
368
template<typename TChar>
369
void
370
TokenizerBase<TChar>::EnableCustomToken(Token const& aToken, bool aEnabled)
371
0
{
372
0
  if (aToken.mType == TOKEN_UNKNOWN) {
373
0
    // Already removed
374
0
    return;
375
0
  }
376
0
377
0
  for (UniquePtr<Token> const& custom : mCustomTokens) {
378
0
    if (custom->Type() == aToken.Type()) {
379
0
      // This effectively destroys the token instance.
380
0
      custom->mCustomEnabled = aEnabled;
381
0
      return;
382
0
    }
383
0
  }
384
0
385
0
  MOZ_ASSERT(false, "Token to change not found");
386
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::EnableCustomToken(mozilla::TokenizerBase<char>::Token const&, bool)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::EnableCustomToken(mozilla::TokenizerBase<char16_t>::Token const&, bool)
387
388
template<typename TChar>
389
void
390
TokenizerBase<TChar>::SetTokenizingMode(Mode aMode)
391
0
{
392
0
  mMode = aMode;
393
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::SetTokenizingMode(mozilla::TokenizerBase<char>::Mode)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::SetTokenizingMode(mozilla::TokenizerBase<char16_t>::Mode)
394
395
template<typename TChar>
396
bool
397
TokenizerBase<TChar>::HasFailed() const
398
0
{
399
0
  return mHasFailed;
400
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::HasFailed() const
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::HasFailed() const
401
402
template<typename TChar>
403
bool
404
TokenizerBase<TChar>::HasInput() const
405
34.9M
{
406
34.9M
  return !mPastEof;
407
34.9M
}
mozilla::TokenizerBase<char>::HasInput() const
Line
Count
Source
405
34.9M
{
406
34.9M
  return !mPastEof;
407
34.9M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::HasInput() const
408
409
template<typename TChar>
410
auto
411
TokenizerBase<TChar>::Parse(Token& aToken) const
412
  -> typename TAString::const_char_iterator
413
9.33M
{
414
9.33M
  if (mCursor == mEnd) {
415
1.19M
    if (!mInputFinished) {
416
0
      return mCursor;
417
0
    }
418
1.19M
419
1.19M
    aToken = Token::EndOfFile();
420
1.19M
    return mEnd;
421
1.19M
  }
422
8.13M
423
8.13M
  MOZ_RELEASE_ASSERT(mEnd >= mCursor, "Overflow!");
424
8.13M
  typename TAString::size_type available = mEnd - mCursor;
425
8.13M
426
8.13M
  uint32_t longestCustom = 0;
427
8.13M
  for (UniquePtr<Token> const& custom : mCustomTokens) {
428
0
    if (IsCustom(mCursor, *custom, &longestCustom)) {
429
0
      aToken = *custom;
430
0
      return mCursor + custom->mCustom.Length();
431
0
    }
432
0
  }
433
8.13M
434
8.13M
  if (!mInputFinished && available < longestCustom) {
435
0
    // Not enough data to deterministically decide.
436
0
    return mCursor;
437
0
  }
438
8.13M
439
8.13M
  typename TAString::const_char_iterator next = mCursor;
440
8.13M
441
8.13M
  if (mMode == Mode::CUSTOM_ONLY) {
442
0
    // We have to do a brute-force search for all of the enabled custom
443
0
    // tokens.
444
0
    while (next < mEnd) {
445
0
      ++next;
446
0
      for (UniquePtr<Token> const& custom : mCustomTokens) {
447
0
        if (IsCustom(next, *custom)) {
448
0
          aToken = Token::Raw();
449
0
          return next;
450
0
        }
451
0
      }
452
0
    }
453
0
454
0
    if (mInputFinished) {
455
0
      // End of the data reached.
456
0
      aToken = Token::Raw();
457
0
      return next;
458
0
    }
459
0
460
0
    if (longestCustom < available && available > mMinRawDelivery) {
461
0
      // We can return some data w/o waiting for either a custom token
462
0
      // or call to FinishData() when we leave the tail where all the
463
0
      // custom tokens potentially fit, so we can't lose only partially
464
0
      // delivered tokens.  This preserves reasonable granularity.
465
0
      aToken = Token::Raw();
466
0
      return mEnd - longestCustom + 1;
467
0
    }
468
0
469
0
    // Not enough data to deterministically decide.
470
0
    return mCursor;
471
0
  }
472
8.13M
473
8.13M
  enum State {
474
8.13M
    PARSE_INTEGER,
475
8.13M
    PARSE_WORD,
476
8.13M
    PARSE_CRLF,
477
8.13M
    PARSE_LF,
478
8.13M
    PARSE_WS,
479
8.13M
    PARSE_CHAR,
480
8.13M
  } state;
481
8.13M
482
8.13M
  if (IsWordFirst(*next)) {
483
50.7k
    state = PARSE_WORD;
484
8.08M
  } else if (IsNumber(*next)) {
485
20.6k
    state = PARSE_INTEGER;
486
8.06M
  } else if (contains(mWhitespaces, *next)) { // not UTF-8 friendly?
487
0
    state = PARSE_WS;
488
8.06M
  } else if (*next == '\r') {
489
0
    state = PARSE_CRLF;
490
8.06M
  } else if (*next == '\n') {
491
0
    state = PARSE_LF;
492
8.06M
  } else {
493
8.06M
    state = PARSE_CHAR;
494
8.06M
  }
495
8.13M
496
8.13M
  mozilla::CheckedUint64 resultingNumber = 0;
497
8.13M
498
8.18M
  while (next < mEnd) {
499
8.18M
    switch (state) {
500
8.18M
    case PARSE_INTEGER:
501
46.1k
      // Keep it simple for now
502
46.1k
      resultingNumber *= 10;
503
46.1k
      resultingNumber += static_cast<uint64_t>(*next - '0');
504
46.1k
505
46.1k
      ++next;
506
46.1k
      if (IsPending(next)) {
507
0
        break;
508
0
      }
509
46.1k
      if (IsEnd(next) || !IsNumber(*next)) {
510
20.6k
        if (!resultingNumber.isValid()) {
511
118
          aToken = Token::Error();
512
20.5k
        } else {
513
20.5k
          aToken = Token::Number(resultingNumber.value());
514
20.5k
        }
515
20.6k
        return next;
516
20.6k
      }
517
25.4k
      break;
518
25.4k
519
72.2k
    case PARSE_WORD:
520
72.2k
      ++next;
521
72.2k
      if (IsPending(next)) {
522
0
        break;
523
0
      }
524
72.2k
      if (IsEnd(next) || !IsWord(*next)) {
525
50.7k
        aToken = Token::Word(Substring(mCursor, next));
526
50.7k
        return next;
527
50.7k
      }
528
21.4k
      break;
529
21.4k
530
21.4k
    case PARSE_CRLF:
531
0
      ++next;
532
0
      if (IsPending(next)) {
533
0
        break;
534
0
      }
535
0
      if (!IsEnd(next) && *next == '\n') { // LF is optional
536
0
        ++next;
537
0
      }
538
0
      aToken = Token::NewLine();
539
0
      return next;
540
0
541
0
    case PARSE_LF:
542
0
      ++next;
543
0
      aToken = Token::NewLine();
544
0
      return next;
545
0
546
0
    case PARSE_WS:
547
0
      ++next;
548
0
      aToken = Token::Whitespace();
549
0
      return next;
550
0
551
8.06M
    case PARSE_CHAR:
552
8.06M
      ++next;
553
8.06M
      aToken = Token::Char(*mCursor);
554
8.06M
      return next;
555
8.18M
    } // switch (state)
556
8.18M
  } // while (next < end)
557
8.13M
558
8.13M
  MOZ_ASSERT(!mInputFinished);
559
0
  return mCursor;
560
8.13M
}
mozilla::TokenizerBase<char>::Parse(mozilla::TokenizerBase<char>::Token&) const
Line
Count
Source
413
9.33M
{
414
9.33M
  if (mCursor == mEnd) {
415
1.19M
    if (!mInputFinished) {
416
0
      return mCursor;
417
0
    }
418
1.19M
419
1.19M
    aToken = Token::EndOfFile();
420
1.19M
    return mEnd;
421
1.19M
  }
422
8.13M
423
8.13M
  MOZ_RELEASE_ASSERT(mEnd >= mCursor, "Overflow!");
424
8.13M
  typename TAString::size_type available = mEnd - mCursor;
425
8.13M
426
8.13M
  uint32_t longestCustom = 0;
427
8.13M
  for (UniquePtr<Token> const& custom : mCustomTokens) {
428
0
    if (IsCustom(mCursor, *custom, &longestCustom)) {
429
0
      aToken = *custom;
430
0
      return mCursor + custom->mCustom.Length();
431
0
    }
432
0
  }
433
8.13M
434
8.13M
  if (!mInputFinished && available < longestCustom) {
435
0
    // Not enough data to deterministically decide.
436
0
    return mCursor;
437
0
  }
438
8.13M
439
8.13M
  typename TAString::const_char_iterator next = mCursor;
440
8.13M
441
8.13M
  if (mMode == Mode::CUSTOM_ONLY) {
442
0
    // We have to do a brute-force search for all of the enabled custom
443
0
    // tokens.
444
0
    while (next < mEnd) {
445
0
      ++next;
446
0
      for (UniquePtr<Token> const& custom : mCustomTokens) {
447
0
        if (IsCustom(next, *custom)) {
448
0
          aToken = Token::Raw();
449
0
          return next;
450
0
        }
451
0
      }
452
0
    }
453
0
454
0
    if (mInputFinished) {
455
0
      // End of the data reached.
456
0
      aToken = Token::Raw();
457
0
      return next;
458
0
    }
459
0
460
0
    if (longestCustom < available && available > mMinRawDelivery) {
461
0
      // We can return some data w/o waiting for either a custom token
462
0
      // or call to FinishData() when we leave the tail where all the
463
0
      // custom tokens potentially fit, so we can't lose only partially
464
0
      // delivered tokens.  This preserves reasonable granularity.
465
0
      aToken = Token::Raw();
466
0
      return mEnd - longestCustom + 1;
467
0
    }
468
0
469
0
    // Not enough data to deterministically decide.
470
0
    return mCursor;
471
0
  }
472
8.13M
473
8.13M
  enum State {
474
8.13M
    PARSE_INTEGER,
475
8.13M
    PARSE_WORD,
476
8.13M
    PARSE_CRLF,
477
8.13M
    PARSE_LF,
478
8.13M
    PARSE_WS,
479
8.13M
    PARSE_CHAR,
480
8.13M
  } state;
481
8.13M
482
8.13M
  if (IsWordFirst(*next)) {
483
50.7k
    state = PARSE_WORD;
484
8.08M
  } else if (IsNumber(*next)) {
485
20.6k
    state = PARSE_INTEGER;
486
8.06M
  } else if (contains(mWhitespaces, *next)) { // not UTF-8 friendly?
487
0
    state = PARSE_WS;
488
8.06M
  } else if (*next == '\r') {
489
0
    state = PARSE_CRLF;
490
8.06M
  } else if (*next == '\n') {
491
0
    state = PARSE_LF;
492
8.06M
  } else {
493
8.06M
    state = PARSE_CHAR;
494
8.06M
  }
495
8.13M
496
8.13M
  mozilla::CheckedUint64 resultingNumber = 0;
497
8.13M
498
8.18M
  while (next < mEnd) {
499
8.18M
    switch (state) {
500
8.18M
    case PARSE_INTEGER:
501
46.1k
      // Keep it simple for now
502
46.1k
      resultingNumber *= 10;
503
46.1k
      resultingNumber += static_cast<uint64_t>(*next - '0');
504
46.1k
505
46.1k
      ++next;
506
46.1k
      if (IsPending(next)) {
507
0
        break;
508
0
      }
509
46.1k
      if (IsEnd(next) || !IsNumber(*next)) {
510
20.6k
        if (!resultingNumber.isValid()) {
511
118
          aToken = Token::Error();
512
20.5k
        } else {
513
20.5k
          aToken = Token::Number(resultingNumber.value());
514
20.5k
        }
515
20.6k
        return next;
516
20.6k
      }
517
25.4k
      break;
518
25.4k
519
72.2k
    case PARSE_WORD:
520
72.2k
      ++next;
521
72.2k
      if (IsPending(next)) {
522
0
        break;
523
0
      }
524
72.2k
      if (IsEnd(next) || !IsWord(*next)) {
525
50.7k
        aToken = Token::Word(Substring(mCursor, next));
526
50.7k
        return next;
527
50.7k
      }
528
21.4k
      break;
529
21.4k
530
21.4k
    case PARSE_CRLF:
531
0
      ++next;
532
0
      if (IsPending(next)) {
533
0
        break;
534
0
      }
535
0
      if (!IsEnd(next) && *next == '\n') { // LF is optional
536
0
        ++next;
537
0
      }
538
0
      aToken = Token::NewLine();
539
0
      return next;
540
0
541
0
    case PARSE_LF:
542
0
      ++next;
543
0
      aToken = Token::NewLine();
544
0
      return next;
545
0
546
0
    case PARSE_WS:
547
0
      ++next;
548
0
      aToken = Token::Whitespace();
549
0
      return next;
550
0
551
8.06M
    case PARSE_CHAR:
552
8.06M
      ++next;
553
8.06M
      aToken = Token::Char(*mCursor);
554
8.06M
      return next;
555
8.18M
    } // switch (state)
556
8.18M
  } // while (next < end)
557
8.13M
558
8.13M
  MOZ_ASSERT(!mInputFinished);
559
0
  return mCursor;
560
8.13M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Parse(mozilla::TokenizerBase<char16_t>::Token&) const
561
562
template<typename TChar>
563
bool
564
TokenizerBase<TChar>::IsEnd(const typename TAString::const_char_iterator& caret) const
565
236k
{
566
236k
  return caret == mEnd;
567
236k
}
mozilla::TokenizerBase<char>::IsEnd(char const* const&) const
Line
Count
Source
565
236k
{
566
236k
  return caret == mEnd;
567
236k
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::IsEnd(char16_t const* const&) const
568
569
template<typename TChar>
570
bool
571
TokenizerBase<TChar>::IsPending(const typename TAString::const_char_iterator& caret) const
572
118k
{
573
118k
  return IsEnd(caret) && !mInputFinished;
574
118k
}
mozilla::TokenizerBase<char>::IsPending(char const* const&) const
Line
Count
Source
572
118k
{
573
118k
  return IsEnd(caret) && !mInputFinished;
574
118k
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::IsPending(char16_t const* const&) const
575
576
template<typename TChar>
577
bool
578
TokenizerBase<TChar>::IsWordFirst(const TChar aInput) const
579
8.20M
{
580
8.20M
  // TODO: make this fully work with unicode
581
8.20M
  return (ToLowerCase(static_cast<uint32_t>(aInput)) !=
582
8.20M
          ToUpperCase(static_cast<uint32_t>(aInput))) ||
583
8.20M
          '_' == aInput ||
584
8.20M
          (mAdditionalWordChars ? contains(mAdditionalWordChars, aInput) : false);
585
8.20M
}
mozilla::TokenizerBase<char>::IsWordFirst(char) const
Line
Count
Source
579
8.20M
{
580
8.20M
  // TODO: make this fully work with unicode
581
8.20M
  return (ToLowerCase(static_cast<uint32_t>(aInput)) !=
582
8.20M
          ToUpperCase(static_cast<uint32_t>(aInput))) ||
583
8.20M
          '_' == aInput ||
584
8.20M
          (mAdditionalWordChars ? contains(mAdditionalWordChars, aInput) : false);
585
8.20M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::IsWordFirst(char16_t) const
586
587
template<typename TChar>
588
bool
589
TokenizerBase<TChar>::IsWord(const TChar aInput) const
590
67.4k
{
591
67.4k
  return IsWordFirst(aInput) || IsNumber(aInput);
592
67.4k
}
mozilla::TokenizerBase<char>::IsWord(char) const
Line
Count
Source
590
67.4k
{
591
67.4k
  return IsWordFirst(aInput) || IsNumber(aInput);
592
67.4k
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::IsWord(char16_t) const
593
594
template<typename TChar>
595
bool
596
TokenizerBase<TChar>::IsNumber(const TChar aInput) const
597
8.17M
{
598
8.17M
  // TODO: are there unicode numbers?
599
8.17M
  return aInput >= '0' && aInput <= '9';
600
8.17M
}
mozilla::TokenizerBase<char>::IsNumber(char) const
Line
Count
Source
597
8.17M
{
598
8.17M
  // TODO: are there unicode numbers?
599
8.17M
  return aInput >= '0' && aInput <= '9';
600
8.17M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::IsNumber(char16_t) const
601
602
namespace {
603
604
template<typename TChar> class TCharComparator;
605
template<> class TCharComparator<char> final : public nsCaseInsensitiveUTF8StringComparator {};
606
template<> class TCharComparator<char16_t> final : public nsCaseInsensitiveStringComparator {};
607
608
}
609
610
template<typename TChar>
611
bool
612
TokenizerBase<TChar>::IsCustom(const typename TAString::const_char_iterator & caret,
613
                               const Token & aCustomToken,
614
                               uint32_t * aLongest) const
615
0
{
616
0
  MOZ_ASSERT(aCustomToken.mType > TOKEN_CUSTOM0);
617
0
  if (!aCustomToken.mCustomEnabled) {
618
0
    return false;
619
0
  }
620
0
621
0
  if (aLongest) {
622
0
    *aLongest = std::max(*aLongest, aCustomToken.mCustom.Length());
623
0
  }
624
0
625
0
  // This is not very likely to happen according to how we call this method
626
0
  // and since it's on a hot path, it's just a diagnostic assert,
627
0
  // not a release assert.
628
0
  MOZ_DIAGNOSTIC_ASSERT(mEnd >= caret, "Overflow?");
629
0
  uint32_t inputLength = mEnd - caret;
630
0
  if (aCustomToken.mCustom.Length() > inputLength) {
631
0
    return false;
632
0
  }
633
0
634
0
  TDependentSubstring inputFragment(caret, aCustomToken.mCustom.Length());
635
0
  if (aCustomToken.mCustomCaseInsensitivity == CASE_INSENSITIVE) {
636
0
    return inputFragment.Equals(aCustomToken.mCustom, TCharComparator<TChar>());
637
0
  }
638
0
  return inputFragment.Equals(aCustomToken.mCustom);
639
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::IsCustom(char const* const&, mozilla::TokenizerBase<char>::Token const&, unsigned int*) const
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::IsCustom(char16_t const* const&, mozilla::TokenizerBase<char16_t>::Token const&, unsigned int*) const
640
641
template<typename TChar>
642
void
643
TokenizerBase<TChar>::AssignFragment(Token& aToken,
644
                                     typename TAString::const_char_iterator begin,
645
                                     typename TAString::const_char_iterator end)
646
0
{
647
0
  aToken.AssignFragment(begin, end);
648
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::AssignFragment(mozilla::TokenizerBase<char>::Token&, char const*, char const*)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::AssignFragment(mozilla::TokenizerBase<char16_t>::Token&, char16_t const*, char16_t const*)
649
650
// TokenizerBase::Token
651
652
template<typename TChar>
653
TokenizerBase<TChar>::Token::Token()
654
  : mType(TOKEN_UNKNOWN)
655
  , mChar(0)
656
  , mInteger(0)
657
  , mCustomCaseInsensitivity(CASE_SENSITIVE)
658
  , mCustomEnabled(false)
659
28.0M
{
660
28.0M
}
mozilla::TokenizerBase<char>::Token::Token()
Line
Count
Source
659
28.0M
{
660
28.0M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Token()
661
662
template<typename TChar>
663
TokenizerBase<TChar>::Token::Token(const Token& aOther)
664
  : mType(aOther.mType)
665
  , mCustom(aOther.mCustom)
666
  , mChar(aOther.mChar)
667
  , mInteger(aOther.mInteger)
668
  , mCustomCaseInsensitivity(aOther.mCustomCaseInsensitivity)
669
  , mCustomEnabled(aOther.mCustomEnabled)
670
0
{
671
0
  if (mType == TOKEN_WORD || mType > TOKEN_CUSTOM0) {
672
0
    mWord.Rebind(aOther.mWord.BeginReading(), aOther.mWord.Length());
673
0
  }
674
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::Token::Token(mozilla::TokenizerBase<char>::Token const&)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Token(mozilla::TokenizerBase<char16_t>::Token const&)
675
676
template<typename TChar>
677
auto
678
TokenizerBase<TChar>::Token::operator=(const Token& aOther)
679
  -> Token&
680
9.33M
{
681
9.33M
  mType = aOther.mType;
682
9.33M
  mCustom = aOther.mCustom;
683
9.33M
  mChar = aOther.mChar;
684
9.33M
  mWord.Rebind(aOther.mWord.BeginReading(), aOther.mWord.Length());
685
9.33M
  mInteger = aOther.mInteger;
686
9.33M
  mCustomCaseInsensitivity = aOther.mCustomCaseInsensitivity;
687
9.33M
  mCustomEnabled = aOther.mCustomEnabled;
688
9.33M
  return *this;
689
9.33M
}
mozilla::TokenizerBase<char>::Token::operator=(mozilla::TokenizerBase<char>::Token const&)
Line
Count
Source
680
9.33M
{
681
9.33M
  mType = aOther.mType;
682
9.33M
  mCustom = aOther.mCustom;
683
9.33M
  mChar = aOther.mChar;
684
9.33M
  mWord.Rebind(aOther.mWord.BeginReading(), aOther.mWord.Length());
685
9.33M
  mInteger = aOther.mInteger;
686
9.33M
  mCustomCaseInsensitivity = aOther.mCustomCaseInsensitivity;
687
9.33M
  mCustomEnabled = aOther.mCustomEnabled;
688
9.33M
  return *this;
689
9.33M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::operator=(mozilla::TokenizerBase<char16_t>::Token const&)
690
691
template<typename TChar>
692
void
693
TokenizerBase<TChar>::Token::AssignFragment(typename TAString::const_char_iterator begin,
694
                                     typename TAString::const_char_iterator end)
695
0
{
696
0
  MOZ_RELEASE_ASSERT(end >= begin, "Overflow!");
697
0
  mFragment.Rebind(begin, end - begin);
698
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::Token::AssignFragment(char const*, char const*)
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::AssignFragment(char16_t const*, char16_t const*)
699
700
// static
701
template<typename TChar>
702
auto
703
TokenizerBase<TChar>::Token::Raw() -> Token
704
0
{
705
0
  Token t;
706
0
  t.mType = TOKEN_RAW;
707
0
  return t;
708
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::Token::Raw()
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Raw()
709
710
// static
711
template<typename TChar>
712
auto
713
TokenizerBase<TChar>::Token::Word(TAString const& aValue) -> Token
714
50.7k
{
715
50.7k
  Token t;
716
50.7k
  t.mType = TOKEN_WORD;
717
50.7k
  t.mWord.Rebind(aValue.BeginReading(), aValue.Length());
718
50.7k
  return t;
719
50.7k
}
mozilla::TokenizerBase<char>::Token::Word(nsTSubstring<char> const&)
Line
Count
Source
714
50.7k
{
715
50.7k
  Token t;
716
50.7k
  t.mType = TOKEN_WORD;
717
50.7k
  t.mWord.Rebind(aValue.BeginReading(), aValue.Length());
718
50.7k
  return t;
719
50.7k
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Word(nsTSubstring<char16_t> const&)
720
721
// static
722
template<typename TChar>
723
auto
724
TokenizerBase<TChar>::Token::Char(TChar const aValue) -> Token
725
12.7M
{
726
12.7M
  Token t;
727
12.7M
  t.mType = TOKEN_CHAR;
728
12.7M
  t.mChar = aValue;
729
12.7M
  return t;
730
12.7M
}
mozilla::TokenizerBase<char>::Token::Char(char)
Line
Count
Source
725
12.7M
{
726
12.7M
  Token t;
727
12.7M
  t.mType = TOKEN_CHAR;
728
12.7M
  t.mChar = aValue;
729
12.7M
  return t;
730
12.7M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Char(char16_t)
731
732
// static
733
template<typename TChar>
734
auto
735
TokenizerBase<TChar>::Token::Number(uint64_t const aValue) -> Token
736
20.5k
{
737
20.5k
  Token t;
738
20.5k
  t.mType = TOKEN_INTEGER;
739
20.5k
  t.mInteger = aValue;
740
20.5k
  return t;
741
20.5k
}
mozilla::TokenizerBase<char>::Token::Number(unsigned long)
Line
Count
Source
736
20.5k
{
737
20.5k
  Token t;
738
20.5k
  t.mType = TOKEN_INTEGER;
739
20.5k
  t.mInteger = aValue;
740
20.5k
  return t;
741
20.5k
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Number(unsigned long)
742
743
// static
744
template<typename TChar>
745
auto
746
TokenizerBase<TChar>::Token::Whitespace() -> Token
747
4.66M
{
748
4.66M
  Token t;
749
4.66M
  t.mType = TOKEN_WS;
750
4.66M
  t.mChar = '\0';
751
4.66M
  return t;
752
4.66M
}
mozilla::TokenizerBase<char>::Token::Whitespace()
Line
Count
Source
747
4.66M
{
748
4.66M
  Token t;
749
4.66M
  t.mType = TOKEN_WS;
750
4.66M
  t.mChar = '\0';
751
4.66M
  return t;
752
4.66M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Whitespace()
753
754
// static
755
template<typename TChar>
756
auto
757
TokenizerBase<TChar>::Token::NewLine() -> Token
758
0
{
759
0
  Token t;
760
0
  t.mType = TOKEN_EOL;
761
0
  return t;
762
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::Token::NewLine()
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::NewLine()
763
764
// static
765
template<typename TChar>
766
auto
767
TokenizerBase<TChar>::Token::EndOfFile() -> Token
768
1.19M
{
769
1.19M
  Token t;
770
1.19M
  t.mType = TOKEN_EOF;
771
1.19M
  return t;
772
1.19M
}
mozilla::TokenizerBase<char>::Token::EndOfFile()
Line
Count
Source
768
1.19M
{
769
1.19M
  Token t;
770
1.19M
  t.mType = TOKEN_EOF;
771
1.19M
  return t;
772
1.19M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::EndOfFile()
773
774
// static
775
template<typename TChar>
776
auto
777
TokenizerBase<TChar>::Token::Error() -> Token
778
118
{
779
118
  Token t;
780
118
  t.mType = TOKEN_ERROR;
781
118
  return t;
782
118
}
mozilla::TokenizerBase<char>::Token::Error()
Line
Count
Source
778
118
{
779
118
  Token t;
780
118
  t.mType = TOKEN_ERROR;
781
118
  return t;
782
118
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Error()
783
784
template<typename TChar>
785
bool
786
TokenizerBase<TChar>::Token::Equals(const Token& aOther) const
787
9.33M
{
788
9.33M
  if (mType != aOther.mType) {
789
5.30M
    return false;
790
5.30M
  }
791
4.03M
792
4.03M
  switch (mType) {
793
4.03M
  case TOKEN_INTEGER:
794
0
    return AsInteger() == aOther.AsInteger();
795
4.03M
  case TOKEN_WORD:
796
18
    return AsString() == aOther.AsString();
797
4.03M
  case TOKEN_CHAR:
798
4.03M
    return AsChar() == aOther.AsChar();
799
4.03M
  default:
800
0
    return true;
801
4.03M
  }
802
4.03M
}
mozilla::TokenizerBase<char>::Token::Equals(mozilla::TokenizerBase<char>::Token const&) const
Line
Count
Source
787
9.33M
{
788
9.33M
  if (mType != aOther.mType) {
789
5.30M
    return false;
790
5.30M
  }
791
4.03M
792
4.03M
  switch (mType) {
793
4.03M
  case TOKEN_INTEGER:
794
0
    return AsInteger() == aOther.AsInteger();
795
4.03M
  case TOKEN_WORD:
796
18
    return AsString() == aOther.AsString();
797
4.03M
  case TOKEN_CHAR:
798
4.03M
    return AsChar() == aOther.AsChar();
799
4.03M
  default:
800
0
    return true;
801
4.03M
  }
802
4.03M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::Equals(mozilla::TokenizerBase<char16_t>::Token const&) const
803
804
template<typename TChar>
805
TChar
806
TokenizerBase<TChar>::Token::AsChar() const
807
8.06M
{
808
8.06M
  MOZ_ASSERT(mType == TOKEN_CHAR || mType == TOKEN_WS);
809
8.06M
  return mChar;
810
8.06M
}
mozilla::TokenizerBase<char>::Token::AsChar() const
Line
Count
Source
807
8.06M
{
808
8.06M
  MOZ_ASSERT(mType == TOKEN_CHAR || mType == TOKEN_WS);
809
8.06M
  return mChar;
810
8.06M
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::AsChar() const
811
812
template<typename TChar>
813
auto
814
TokenizerBase<TChar>::Token::AsString() const -> TDependentSubstring
815
36
{
816
36
  MOZ_ASSERT(mType == TOKEN_WORD);
817
36
  return mWord;
818
36
}
mozilla::TokenizerBase<char>::Token::AsString() const
Line
Count
Source
815
36
{
816
36
  MOZ_ASSERT(mType == TOKEN_WORD);
817
36
  return mWord;
818
36
}
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::AsString() const
819
820
template<typename TChar>
821
uint64_t
822
TokenizerBase<TChar>::Token::AsInteger() const
823
0
{
824
0
  MOZ_ASSERT(mType == TOKEN_INTEGER);
825
0
  return mInteger;
826
0
}
Unexecuted instantiation: mozilla::TokenizerBase<char>::Token::AsInteger() const
Unexecuted instantiation: mozilla::TokenizerBase<char16_t>::Token::AsInteger() const
827
828
template class TokenizerBase<char>;
829
template class TokenizerBase<char16_t>;
830
831
template class TTokenizer<char>;
832
template class TTokenizer<char16_t>;
833
834
} // mozilla