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

Side by Side Diff: src/dateparser.h

Issue 2831016: [Isolates] Static mutable data of Scanner class moved to ScannerCharacterClasses / Isolate. (Closed)
Patch Set: . Created 10 years, 6 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
« no previous file with comments | « src/conversions.cc ('k') | src/heap.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Indicates a missing value. 62 // Indicates a missing value.
63 static const int kNone = kMaxInt; 63 static const int kNone = kMaxInt;
64 64
65 // InputReader provides basic string parsing and character classification. 65 // InputReader provides basic string parsing and character classification.
66 template <typename Char> 66 template <typename Char>
67 class InputReader BASE_EMBEDDED { 67 class InputReader BASE_EMBEDDED {
68 public: 68 public:
69 explicit InputReader(Vector<Char> s) 69 explicit InputReader(Vector<Char> s)
70 : index_(0), 70 : index_(0),
71 buffer_(s), 71 buffer_(s),
72 has_read_number_(false) { 72 has_read_number_(false),
73 character_classes_(Isolate::Current()->scanner_character_classes()) {
73 Next(); 74 Next();
74 } 75 }
75 76
76 // Advance to the next character of the string. 77 // Advance to the next character of the string.
77 void Next() { ch_ = (index_ < buffer_.length()) ? buffer_[index_++] : 0; } 78 void Next() { ch_ = (index_ < buffer_.length()) ? buffer_[index_++] : 0; }
78 79
79 // Read a string of digits as an unsigned number (cap just below kMaxInt). 80 // Read a string of digits as an unsigned number (cap just below kMaxInt).
80 int ReadUnsignedNumber() { 81 int ReadUnsignedNumber() {
81 has_read_number_ = true; 82 has_read_number_ = true;
82 int n; 83 int n;
(...skipping 12 matching lines...) Expand all
95 if (len < prefix_size) prefix[len] = GetAsciiAlphaLower(); 96 if (len < prefix_size) prefix[len] = GetAsciiAlphaLower();
96 } 97 }
97 for (int i = len; i < prefix_size; i++) prefix[i] = 0; 98 for (int i = len; i < prefix_size; i++) prefix[i] = 0;
98 return len; 99 return len;
99 } 100 }
100 101
101 // The skip methods return whether they actually skipped something. 102 // The skip methods return whether they actually skipped something.
102 bool Skip(uint32_t c) { return ch_ == c ? (Next(), true) : false; } 103 bool Skip(uint32_t c) { return ch_ == c ? (Next(), true) : false; }
103 104
104 bool SkipWhiteSpace() { 105 bool SkipWhiteSpace() {
105 return Scanner::kIsWhiteSpace.get(ch_) ? (Next(), true) : false; 106 return character_classes_->IsWhiteSpace(ch_) ? (Next(), true) : false;
106 } 107 }
107 108
108 bool SkipParentheses() { 109 bool SkipParentheses() {
109 if (ch_ != '(') return false; 110 if (ch_ != '(') return false;
110 int balance = 0; 111 int balance = 0;
111 do { 112 do {
112 if (ch_ == ')') --balance; 113 if (ch_ == ')') --balance;
113 else if (ch_ == '(') ++balance; 114 else if (ch_ == '(') ++balance;
114 Next(); 115 Next();
115 } while (balance > 0 && ch_); 116 } while (balance > 0 && ch_);
(...skipping 15 matching lines...) Expand all
131 132
132 private: 133 private:
133 // If current character is in 'A'-'Z' or 'a'-'z', return its lower-case. 134 // If current character is in 'A'-'Z' or 'a'-'z', return its lower-case.
134 // Else, return something outside of 'A'-'Z' and 'a'-'z'. 135 // Else, return something outside of 'A'-'Z' and 'a'-'z'.
135 uint32_t GetAsciiAlphaLower() const { return ch_ | 32; } 136 uint32_t GetAsciiAlphaLower() const { return ch_ | 32; }
136 137
137 int index_; 138 int index_;
138 Vector<Char> buffer_; 139 Vector<Char> buffer_;
139 bool has_read_number_; 140 bool has_read_number_;
140 uint32_t ch_; 141 uint32_t ch_;
142 ScannerCharacterClasses* character_classes_;
141 }; 143 };
142 144
143 enum KeywordType { INVALID, MONTH_NAME, TIME_ZONE_NAME, AM_PM }; 145 enum KeywordType { INVALID, MONTH_NAME, TIME_ZONE_NAME, AM_PM };
144 146
145 // KeywordTable maps names of months, time zones, am/pm to numbers. 147 // KeywordTable maps names of months, time zones, am/pm to numbers.
146 class KeywordTable : public AllStatic { 148 class KeywordTable : public AllStatic {
147 public: 149 public:
148 // Look up a word in the keyword table and return an index. 150 // Look up a word in the keyword table and return an index.
149 // 'pre' contains a prefix of the word, zero-padded to size kPrefixLength 151 // 'pre' contains a prefix of the word, zero-padded to size kPrefixLength
150 // and 'len' is the word length. 152 // and 'len' is the word length.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 int comp_[kSize]; 237 int comp_[kSize];
236 int index_; 238 int index_;
237 int named_month_; 239 int named_month_;
238 }; 240 };
239 }; 241 };
240 242
241 243
242 } } // namespace v8::internal 244 } } // namespace v8::internal
243 245
244 #endif // V8_DATEPARSER_H_ 246 #endif // V8_DATEPARSER_H_
OLDNEW
« no previous file with comments | « src/conversions.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698