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

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

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