OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "vm/scanner.h" | 5 #include "vm/scanner.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 } | 167 } |
168 for (int i = 1; i < str.Length(); i++) { | 168 for (int i = 1; i < str.Length(); i++) { |
169 if (!IsIdentChar(str.CharAt(i))) { | 169 if (!IsIdentChar(str.CharAt(i))) { |
170 return false; | 170 return false; |
171 } | 171 } |
172 } | 172 } |
173 return true; | 173 return true; |
174 } | 174 } |
175 | 175 |
176 | 176 |
177 // TODO(srdjan): Investigate for performance hit; the integer and double parsing | |
178 // may not be efficient as we need to generate two extra growable arrays. | |
siva
2012/11/16 01:34:26
This comment here does not seem to make sense?
Ivan Posva
2012/11/16 19:26:43
Adjusted comment explaining what this method is fo
| |
179 bool Scanner::IsValidLiteral(const Scanner::GrowableTokenStream& tokens, | |
180 Token::Kind literal_kind, | |
Mads Ager (google)
2012/11/16 05:46:21
Indentation is slightly off.
Ivan Posva
2012/11/16 19:26:43
Done.
| |
181 bool* is_positive, | |
182 String** value) { | |
183 if ((tokens.length() == 2) && | |
184 (tokens[0].kind == literal_kind) && | |
185 (tokens[1].kind == Token::kEOS)) { | |
186 *is_positive = true; | |
187 *value = tokens[0].literal; | |
188 return true; | |
189 } | |
190 if ((tokens.length() == 3) && | |
191 ((tokens[0].kind == Token::kTIGHTADD) || | |
192 (tokens[0].kind == Token::kSUB)) && | |
Mads Ager (google)
2012/11/16 05:46:21
Indentation sligthly off.
Ivan Posva
2012/11/16 19:26:43
Done.
| |
193 (tokens[1].kind == literal_kind) && | |
194 (tokens[2].kind == Token::kEOS)) { | |
195 // Check there is no space between "+/-" and number. | |
196 if ((tokens[0].offset + 1) != tokens[1].offset) { | |
197 return false; | |
198 } | |
199 *is_positive = tokens[0].kind == Token::kTIGHTADD; | |
200 *value = tokens[1].literal; | |
201 return true; | |
202 } | |
203 return false; | |
204 } | |
205 | |
206 | |
177 void Scanner::ReadChar() { | 207 void Scanner::ReadChar() { |
178 if (lookahead_pos_ < source_length_) { | 208 if (lookahead_pos_ < source_length_) { |
179 if (c0_ == '\n') { | 209 if (c0_ == '\n') { |
180 newline_seen_ = true; | 210 newline_seen_ = true; |
181 c0_pos_.line++; | 211 c0_pos_.line++; |
182 c0_pos_.column = 0; | 212 c0_pos_.column = 0; |
183 if (source_.CharAt(lookahead_pos_) == '\r') { | 213 if (source_.CharAt(lookahead_pos_) == '\r') { |
184 // Replace a sequence of '\r' '\n' with a single '\n'. | 214 // Replace a sequence of '\r' '\n' with a single '\n'. |
185 if (LookaheadChar(1) == '\n') { | 215 if (LookaheadChar(1) == '\n') { |
186 lookahead_pos_++; | 216 lookahead_pos_++; |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
952 "%c%#"Px"", kPrivateKeySeparator, key_value); | 982 "%c%#"Px"", kPrivateKeySeparator, key_value); |
953 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | 983 const String& result = String::Handle(String::New(private_key, Heap::kOld)); |
954 return result.raw(); | 984 return result.raw(); |
955 } | 985 } |
956 | 986 |
957 | 987 |
958 void Scanner::InitOnce() { | 988 void Scanner::InitOnce() { |
959 } | 989 } |
960 | 990 |
961 } // namespace dart | 991 } // namespace dart |
OLD | NEW |