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

Side by Side Diff: runtime/vm/unibrow.h

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed Ivan's comments. Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/symbols.h ('k') | runtime/vm/unibrow.cc » ('j') | 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 (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_UNIBROW_H_
6 #define VM_UNIBROW_H_
7
8 #include <sys/types.h>
9
10 #include "vm/globals.h"
11
12 /**
13 * \file
14 * Definitions and convenience functions for working with unicode.
15 */
16
17 namespace unibrow {
18
19 // A cache used in case conversion. It caches the value for characters
20 // that either have no mapping or map to a single character independent
21 // of context. Characters that map to more than one character or that
22 // map differently depending on context are always looked up.
23 template <class T, intptr_t size = 256>
24 class Mapping {
25 public:
26 inline Mapping() { }
27 inline intptr_t get(int32_t c, int32_t n, int32_t* result);
28 private:
29 friend class Test;
30 intptr_t CalculateValue(int32_t c, int32_t n, int32_t* result);
31 struct CacheEntry {
32 inline CacheEntry() : code_point_(kNoChar), offset_(0) { }
33 inline CacheEntry(int32_t code_point, signed offset)
34 : code_point_(code_point),
35 offset_(offset) { }
36 int32_t code_point_;
37 signed offset_;
38 static const intptr_t kNoChar = (1 << 21) - 1;
39 };
40 static const intptr_t kSize = size;
41 static const intptr_t kMask = kSize - 1;
42 CacheEntry entries_[kSize];
43 };
44
45 struct Letter {
46 static bool Is(int32_t c);
47 };
48 struct Ecma262Canonicalize {
49 static const intptr_t kMaxWidth = 1;
50 static intptr_t Convert(int32_t c,
51 int32_t n,
52 int32_t* result,
53 bool* allow_caching_ptr);
54 };
55 struct Ecma262UnCanonicalize {
56 static const intptr_t kMaxWidth = 4;
57 static intptr_t Convert(int32_t c,
58 int32_t n,
59 int32_t* result,
60 bool* allow_caching_ptr);
61 };
62 struct CanonicalizationRange {
63 static const intptr_t kMaxWidth = 1;
64 static intptr_t Convert(int32_t c,
65 int32_t n,
66 int32_t* result,
67 bool* allow_caching_ptr);
68 };
69
70 } // namespace unibrow
71
72 #endif // VM_UNIBROW_H_
OLDNEW
« no previous file with comments | « runtime/vm/symbols.h ('k') | runtime/vm/unibrow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698