Chromium Code Reviews| 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/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3303 const Array& import_map) { | 3303 const Array& import_map) { |
| 3304 Dart_LibraryTagHandler handler = Isolate::Current()->library_tag_handler(); | 3304 Dart_LibraryTagHandler handler = Isolate::Current()->library_tag_handler(); |
| 3305 if (handler == NULL) { | 3305 if (handler == NULL) { |
| 3306 ErrorMsg(token_pos, "no library handler registered"); | 3306 ErrorMsg(token_pos, "no library handler registered"); |
| 3307 } | 3307 } |
| 3308 Dart_Handle result = handler(tag, | 3308 Dart_Handle result = handler(tag, |
| 3309 Api::NewLocalHandle(library_), | 3309 Api::NewLocalHandle(library_), |
| 3310 Api::NewLocalHandle(url), | 3310 Api::NewLocalHandle(url), |
| 3311 Api::NewLocalHandle(import_map)); | 3311 Api::NewLocalHandle(import_map)); |
| 3312 if (Dart_IsError(result)) { | 3312 if (Dart_IsError(result)) { |
| 3313 ErrorMsg(token_pos, "library handler failed: %s", Dart_GetError(result)); | 3313 Error& prev_error = Error::Handle(); |
| 3314 prev_error ^= Api::UnwrapHandle(result); | |
| 3315 AppendErrorMsg(prev_error, token_pos, "library handler failed"); | |
| 3314 } | 3316 } |
| 3315 return result; | 3317 return result; |
| 3316 } | 3318 } |
| 3317 | 3319 |
| 3318 | 3320 |
| 3319 void Parser::ParseLibraryImport() { | 3321 void Parser::ParseLibraryImport() { |
| 3320 TRACE_PARSER("ParseLibraryImport"); | 3322 TRACE_PARSER("ParseLibraryImport"); |
| 3321 while (CurrentToken() == Token::kIMPORT) { | 3323 while (CurrentToken() == Token::kIMPORT) { |
| 3322 const intptr_t import_pos = token_index_; | 3324 const intptr_t import_pos = token_index_; |
| 3323 ConsumeToken(); | 3325 ConsumeToken(); |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5247 new LoadLocalNode(statement_pos, *trace_var)); | 5249 new LoadLocalNode(statement_pos, *trace_var)); |
| 5248 } | 5250 } |
| 5249 } else { | 5251 } else { |
| 5250 statement = ParseExpr(kAllowConst); | 5252 statement = ParseExpr(kAllowConst); |
| 5251 ExpectSemicolon(); | 5253 ExpectSemicolon(); |
| 5252 } | 5254 } |
| 5253 return statement; | 5255 return statement; |
| 5254 } | 5256 } |
| 5255 | 5257 |
| 5256 | 5258 |
| 5259 RawError* Parser::FormatErrorWithAppend(const Error& prev_error, | |
| 5260 const Script& script, | |
| 5261 intptr_t token_index, | |
| 5262 const char* message_header, | |
| 5263 const char* format, | |
| 5264 va_list args) { | |
| 5265 const intptr_t kMessageBufferSize = 512; | |
| 5266 char message_buffer[kMessageBufferSize]; | |
| 5267 FormatMessage(script, token_index, message_header, | |
| 5268 message_buffer, kMessageBufferSize, | |
| 5269 format, args); | |
| 5270 const String& msg1 = String::Handle(String::New(prev_error.ToErrorCString())); | |
|
hausner
2012/03/01 00:10:16
Why not use prev_error.message()? There is still a
srdjan
2012/03/01 00:17:34
There is no Error::message(). Some subclasses impl
turnidge
2012/03/07 00:41:21
You should be able to use ToErrorCString on any re
| |
| 5271 const String& msg2 = String::Handle(String::New(message_buffer)); | |
| 5272 return LanguageError::New(String::Handle(String::Concat(msg1, msg2))); | |
| 5273 } | |
| 5274 | |
| 5275 | |
| 5257 RawError* Parser::FormatError(const Script& script, | 5276 RawError* Parser::FormatError(const Script& script, |
| 5258 intptr_t token_index, | 5277 intptr_t token_index, |
| 5259 const char* message_header, | 5278 const char* message_header, |
| 5260 const char* format, | 5279 const char* format, |
| 5261 va_list args) { | 5280 va_list args) { |
| 5262 const intptr_t kMessageBufferSize = 512; | 5281 const intptr_t kMessageBufferSize = 512; |
| 5263 char message_buffer[kMessageBufferSize]; | 5282 char message_buffer[kMessageBufferSize]; |
| 5264 FormatMessage(script, token_index, message_header, | 5283 FormatMessage(script, token_index, message_header, |
| 5265 message_buffer, kMessageBufferSize, | 5284 message_buffer, kMessageBufferSize, |
| 5266 format, args); | 5285 format, args); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5347 va_list args; | 5366 va_list args; |
| 5348 va_start(args, format); | 5367 va_start(args, format); |
| 5349 const Error& error = Error::Handle( | 5368 const Error& error = Error::Handle( |
| 5350 FormatError(script_, token_index_, "Error", format, args)); | 5369 FormatError(script_, token_index_, "Error", format, args)); |
| 5351 va_end(args); | 5370 va_end(args); |
| 5352 Isolate::Current()->long_jump_base()->Jump(1, error); | 5371 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 5353 UNREACHABLE(); | 5372 UNREACHABLE(); |
| 5354 } | 5373 } |
| 5355 | 5374 |
| 5356 | 5375 |
| 5376 void Parser::AppendErrorMsg( | |
| 5377 const Error& prev_error, intptr_t token_index, const char* format, ...) { | |
| 5378 va_list args; | |
| 5379 va_start(args, format); | |
| 5380 const Error& error = Error::Handle(FormatErrorWithAppend( | |
| 5381 prev_error, script_, token_index, "Error", format, args)); | |
| 5382 va_end(args); | |
| 5383 Isolate::Current()->long_jump_base()->Jump(1, error); | |
| 5384 UNREACHABLE(); | |
| 5385 } | |
| 5386 | |
| 5387 | |
| 5357 void Parser::Warning(intptr_t token_index, const char* format, ...) { | 5388 void Parser::Warning(intptr_t token_index, const char* format, ...) { |
| 5358 if (FLAG_silent_warnings) return; | 5389 if (FLAG_silent_warnings) return; |
| 5359 va_list args; | 5390 va_list args; |
| 5360 va_start(args, format); | 5391 va_start(args, format); |
| 5361 const Error& error = Error::Handle( | 5392 const Error& error = Error::Handle( |
| 5362 FormatError(script_, token_index, "Warning", format, args)); | 5393 FormatError(script_, token_index, "Warning", format, args)); |
| 5363 va_end(args); | 5394 va_end(args); |
| 5364 if (FLAG_warning_as_error) { | 5395 if (FLAG_warning_as_error) { |
| 5365 Isolate::Current()->long_jump_base()->Jump(1, error); | 5396 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 5366 UNREACHABLE(); | 5397 UNREACHABLE(); |
| (...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7976 void Parser::SkipQualIdent() { | 8007 void Parser::SkipQualIdent() { |
| 7977 ASSERT(IsIdentifier()); | 8008 ASSERT(IsIdentifier()); |
| 7978 ConsumeToken(); | 8009 ConsumeToken(); |
| 7979 if (CurrentToken() == Token::kPERIOD) { | 8010 if (CurrentToken() == Token::kPERIOD) { |
| 7980 ConsumeToken(); // Consume the kPERIOD token. | 8011 ConsumeToken(); // Consume the kPERIOD token. |
| 7981 ExpectIdentifier("identifier expected after '.'"); | 8012 ExpectIdentifier("identifier expected after '.'"); |
| 7982 } | 8013 } |
| 7983 } | 8014 } |
| 7984 | 8015 |
| 7985 } // namespace dart | 8016 } // namespace dart |
| OLD | NEW |