| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 | 63 |
| 64 // Quick access to the current isolate and zone. | 64 // Quick access to the current isolate and zone. |
| 65 #define I (thread()->isolate()) | 65 #define I (thread()->isolate()) |
| 66 #define Z (zone()) | 66 #define Z (zone()) |
| 67 | 67 |
| 68 | 68 |
| 69 #if defined(DEBUG) | 69 #if defined(DEBUG) |
| 70 class TraceParser : public ValueObject { | 70 class TraceParser : public ValueObject { |
| 71 public: | 71 public: |
| 72 TraceParser(intptr_t token_pos, const Script& script, const char* msg) { | 72 TraceParser(intptr_t token_pos, |
| 73 const Script& script, |
| 74 intptr_t* trace_indent, |
| 75 const char* msg) { |
| 76 indent_ = trace_indent; |
| 73 if (FLAG_trace_parser) { | 77 if (FLAG_trace_parser) { |
| 74 // Skips tracing of bootstrap libraries. | 78 // Skips tracing of bootstrap libraries. |
| 75 if (script.HasSource()) { | 79 if (script.HasSource()) { |
| 76 intptr_t line, column; | 80 intptr_t line, column; |
| 77 script.GetTokenLocation(token_pos, &line, &column); | 81 script.GetTokenLocation(token_pos, &line, &column); |
| 78 PrintIndent(); | 82 PrintIndent(); |
| 79 OS::Print("%s (line %" Pd ", col %" Pd ", token %" Pd ")\n", | 83 OS::Print("%s (line %" Pd ", col %" Pd ", token %" Pd ")\n", |
| 80 msg, line, column, token_pos); | 84 msg, line, column, token_pos); |
| 81 } | 85 } |
| 82 indent_++; | 86 (*indent_)++; |
| 83 } | 87 } |
| 84 } | 88 } |
| 85 ~TraceParser() { indent_--; } | 89 ~TraceParser() { |
| 90 if (FLAG_trace_parser) { |
| 91 (*indent_)--; |
| 92 ASSERT(*indent_ >= 0); |
| 93 } |
| 94 } |
| 95 |
| 86 private: | 96 private: |
| 87 void PrintIndent() { | 97 void PrintIndent() { |
| 88 for (int i = 0; i < indent_; i++) { OS::Print(". "); } | 98 for (intptr_t i = 0; i < *indent_; i++) { OS::Print(". "); } |
| 89 } | 99 } |
| 90 static int indent_; | 100 intptr_t* indent_; |
| 91 }; | 101 }; |
| 92 | 102 |
| 93 int TraceParser::indent_ = 0; | |
| 94 | 103 |
| 95 #define TRACE_PARSER(s) \ | 104 #define TRACE_PARSER(s) \ |
| 96 TraceParser __p__(this->TokenPos(), this->script_, s) | 105 TraceParser __p__(this->TokenPos(), this->script_, &this->trace_indent_, s) |
| 97 | 106 |
| 98 #else // not DEBUG | 107 #else // not DEBUG |
| 99 #define TRACE_PARSER(s) | 108 #define TRACE_PARSER(s) |
| 100 #endif // DEBUG | 109 #endif // DEBUG |
| 101 | 110 |
| 102 | 111 |
| 103 class BoolScope : public ValueObject { | 112 class BoolScope : public ValueObject { |
| 104 public: | 113 public: |
| 105 BoolScope(bool* addr, bool new_value) : _addr(addr), _saved_value(*addr) { | 114 BoolScope(bool* addr, bool new_value) : _addr(addr), _saved_value(*addr) { |
| 106 *_addr = new_value; | 115 *_addr = new_value; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 current_member_(NULL), | 328 current_member_(NULL), |
| 320 allow_function_literals_(true), | 329 allow_function_literals_(true), |
| 321 parsed_function_(NULL), | 330 parsed_function_(NULL), |
| 322 innermost_function_(Function::Handle(zone())), | 331 innermost_function_(Function::Handle(zone())), |
| 323 literal_token_(LiteralToken::Handle(zone())), | 332 literal_token_(LiteralToken::Handle(zone())), |
| 324 current_class_(Class::Handle(zone())), | 333 current_class_(Class::Handle(zone())), |
| 325 library_(Library::Handle(zone(), library.raw())), | 334 library_(Library::Handle(zone(), library.raw())), |
| 326 try_blocks_list_(NULL), | 335 try_blocks_list_(NULL), |
| 327 last_used_try_index_(0), | 336 last_used_try_index_(0), |
| 328 unregister_pending_function_(false), | 337 unregister_pending_function_(false), |
| 329 async_temp_scope_(NULL) { | 338 async_temp_scope_(NULL), |
| 339 trace_indent_(0) { |
| 330 ASSERT(tokens_iterator_.IsValid()); | 340 ASSERT(tokens_iterator_.IsValid()); |
| 331 ASSERT(!library.IsNull()); | 341 ASSERT(!library.IsNull()); |
| 332 } | 342 } |
| 333 | 343 |
| 334 | 344 |
| 335 // For parsing a function. | 345 // For parsing a function. |
| 336 Parser::Parser(const Script& script, | 346 Parser::Parser(const Script& script, |
| 337 ParsedFunction* parsed_function, | 347 ParsedFunction* parsed_function, |
| 338 intptr_t token_position) | 348 intptr_t token_position) |
| 339 : thread_(Thread::Current()), | 349 : thread_(Thread::Current()), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 351 parsed_function->function().raw())), | 361 parsed_function->function().raw())), |
| 352 literal_token_(LiteralToken::Handle(zone())), | 362 literal_token_(LiteralToken::Handle(zone())), |
| 353 current_class_(Class::Handle(zone(), | 363 current_class_(Class::Handle(zone(), |
| 354 parsed_function->function().Owner())), | 364 parsed_function->function().Owner())), |
| 355 library_(Library::Handle(zone(), Class::Handle( | 365 library_(Library::Handle(zone(), Class::Handle( |
| 356 zone(), | 366 zone(), |
| 357 parsed_function->function().origin()).library())), | 367 parsed_function->function().origin()).library())), |
| 358 try_blocks_list_(NULL), | 368 try_blocks_list_(NULL), |
| 359 last_used_try_index_(0), | 369 last_used_try_index_(0), |
| 360 unregister_pending_function_(false), | 370 unregister_pending_function_(false), |
| 361 async_temp_scope_(NULL) { | 371 async_temp_scope_(NULL), |
| 372 trace_indent_(0) { |
| 362 ASSERT(tokens_iterator_.IsValid()); | 373 ASSERT(tokens_iterator_.IsValid()); |
| 363 ASSERT(!current_function().IsNull()); | 374 ASSERT(!current_function().IsNull()); |
| 364 EnsureExpressionTemp(); | 375 EnsureExpressionTemp(); |
| 365 } | 376 } |
| 366 | 377 |
| 367 | 378 |
| 368 Parser::~Parser() { | 379 Parser::~Parser() { |
| 369 if (unregister_pending_function_) { | 380 if (unregister_pending_function_) { |
| 370 const GrowableObjectArray& pending_functions = | 381 const GrowableObjectArray& pending_functions = |
| 371 GrowableObjectArray::Handle(I->object_store()->pending_functions()); | 382 GrowableObjectArray::Handle(I->object_store()->pending_functions()); |
| (...skipping 12185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12557 void Parser::SkipQualIdent() { | 12568 void Parser::SkipQualIdent() { |
| 12558 ASSERT(IsIdentifier()); | 12569 ASSERT(IsIdentifier()); |
| 12559 ConsumeToken(); | 12570 ConsumeToken(); |
| 12560 if (CurrentToken() == Token::kPERIOD) { | 12571 if (CurrentToken() == Token::kPERIOD) { |
| 12561 ConsumeToken(); // Consume the kPERIOD token. | 12572 ConsumeToken(); // Consume the kPERIOD token. |
| 12562 ExpectIdentifier("identifier expected after '.'"); | 12573 ExpectIdentifier("identifier expected after '.'"); |
| 12563 } | 12574 } |
| 12564 } | 12575 } |
| 12565 | 12576 |
| 12566 } // namespace dart | 12577 } // namespace dart |
| OLD | NEW |