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

Unified Diff: frog/leg/util/characters.dart

Issue 9271037: Inserted string validation as separate task in compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 8 years, 11 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: frog/leg/util/characters.dart
diff --git a/frog/leg/util/characters.dart b/frog/leg/util/characters.dart
index 910dae2efc9bf064564bcb785c3b4c417e60d572..bd466aa1100472ebf8ea8c6a022adab4ab6fd6e4 100644
--- a/frog/leg/util/characters.dart
+++ b/frog/leg/util/characters.dart
@@ -106,4 +106,26 @@ final int $CLOSE_CURLY_BRACKET = 125;
final int $TILDE = 126;
final int $DEL = 127;
final int $LS = 0x2028;
-final int $PS = 0x2029;
+final int $PS = 0x2029;
+
+final int $FIRST_SURROGATE = 0xd800;
+final int $LAST_SURROGATE = 0xdfff;
+final int $LAST_CODE_POINT = 0x10ffff;
+
+bool isHexDigit(int characterCode) {
+ if (characterCode <= $9) return $0 <= characterCode;
+ characterCode |= $a ^ $A;
+ return ($a <= characterCode && characterCode <= $f);
+}
+
+int hexDigitValue(int hexDigit) {
+ assert(isHexDigit(hexDigit));
+ // hexDigit is one of '0'..'9', 'A'..'F' and 'a'..'f'.
+ if (hexDigit <= $9) return hexDigit - $0;
+ return (hexDigit | ($a ^ $A)) - ($a - 10);
+}
+
+bool isUnicodeScalarValue(int value) {
+ return value < $FIRST_SURROGATE ||
+ (value > $LAST_SURROGATE && value <= $LAST_CODE_POINT);
+}

Powered by Google App Engine
This is Rietveld 408576698