Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: test/cctest/unicode-helpers.h

Issue 2683573002: [parser/test] Move cctest/PreParserScopeAnalysis into a new file. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« test/cctest/test-preparser.cc ('K') | « test/cctest/test-preparser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_CCTEST_UNICODE_HELPERS_H_
6 #define V8_CCTEST_UNICODE_HELPERS_H_
7
8 #include "src/unicode.h"
9
10 static int Ucs2CharLength(unibrow::uchar c) {
11 if (c == unibrow::Utf8::kIncomplete || c == unibrow::Utf8::kBufferEmpty) {
12 return 0;
13 } else if (c < 0xffff) {
14 return 1;
15 } else {
16 return 2;
17 }
18 }
19
20 static int Utf8LengthHelper(const char* s) {
21 unibrow::Utf8::Utf8IncrementalBuffer buffer(unibrow::Utf8::kBufferEmpty);
22 int length = 0;
23 for (; *s != '\0'; s++) {
24 unibrow::uchar tmp = unibrow::Utf8::ValueOfIncremental(*s, &buffer);
25 length += Ucs2CharLength(tmp);
26 }
27 unibrow::uchar tmp = unibrow::Utf8::ValueOfIncrementalFinish(&buffer);
28 length += Ucs2CharLength(tmp);
29 return length;
30 }
31
32 #endif // V8_CCTEST_UNICODE_HELPERS_H_
OLDNEW
« test/cctest/test-preparser.cc ('K') | « test/cctest/test-preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698