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

Unified Diff: runtime/vm/unibrow.h

Issue 683433003: Integrate the Irregexp Regular Expression Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase, enable tests, remove *CodeUnitsAt 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/unibrow.h
diff --git a/runtime/vm/unibrow.h b/runtime/vm/unibrow.h
new file mode 100644
index 0000000000000000000000000000000000000000..37a44effb104f6e3d60de75e2c9f5f4510eb8c33
--- /dev/null
+++ b/runtime/vm/unibrow.h
@@ -0,0 +1,72 @@
+// Copyright 2011 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.
+
+#ifndef VM_UNIBROW_H_
+#define VM_UNIBROW_H_
+
+#include <sys/types.h>
+
+#include "vm/globals.h"
+
+/**
+ * \file
+ * Definitions and convenience functions for working with unicode.
+ */
+
+namespace unibrow {
+
+// A cache used in case conversion. It caches the value for characters
+// that either have no mapping or map to a single character independent
+// of context. Characters that map to more than one character or that
+// map differently depending on context are always looked up.
+template <class T, intptr_t size = 256>
+class Mapping {
+ public:
+ inline Mapping() { }
+ inline intptr_t get(int32_t c, int32_t n, int32_t* result);
+ private:
+ friend class Test;
+ intptr_t CalculateValue(int32_t c, int32_t n, int32_t* result);
+ struct CacheEntry {
+ inline CacheEntry() : code_point_(kNoChar), offset_(0) { }
+ inline CacheEntry(int32_t code_point, signed offset)
+ : code_point_(code_point),
+ offset_(offset) { }
+ int32_t code_point_;
+ signed offset_;
+ static const intptr_t kNoChar = (1 << 21) - 1;
+ };
+ static const intptr_t kSize = size;
+ static const intptr_t kMask = kSize - 1;
+ CacheEntry entries_[kSize];
+};
+
+struct Letter {
+ static bool Is(int32_t c);
+};
+struct Ecma262Canonicalize {
+ static const intptr_t kMaxWidth = 1;
+ static intptr_t Convert(int32_t c,
+ int32_t n,
+ int32_t* result,
+ bool* allow_caching_ptr);
+};
+struct Ecma262UnCanonicalize {
+ static const intptr_t kMaxWidth = 4;
+ static intptr_t Convert(int32_t c,
+ int32_t n,
+ int32_t* result,
+ bool* allow_caching_ptr);
+};
+struct CanonicalizationRange {
+ static const intptr_t kMaxWidth = 1;
+ static intptr_t Convert(int32_t c,
+ int32_t n,
+ int32_t* result,
+ bool* allow_caching_ptr);
+};
+
+} // namespace unibrow
+
+#endif // VM_UNIBROW_H_
« runtime/vm/object.cc ('K') | « runtime/vm/symbols.h ('k') | runtime/vm/unibrow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698