| 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/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (position < TokenPos() && position != 0) { | 346 if (position < TokenPos() && position != 0) { |
| 347 CompilerStats::num_tokens_rewind += (TokenPos() - position); | 347 CompilerStats::num_tokens_rewind += (TokenPos() - position); |
| 348 } | 348 } |
| 349 tokens_iterator_.SetCurrentPosition(position); | 349 tokens_iterator_.SetCurrentPosition(position); |
| 350 token_kind_ = Token::kILLEGAL; | 350 token_kind_ = Token::kILLEGAL; |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 |
| 354 void Parser::ParseCompilationUnit(const Library& library, | 354 void Parser::ParseCompilationUnit(const Library& library, |
| 355 const Script& script) { | 355 const Script& script) { |
| 356 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); | 356 Isolate* isolate = Isolate::Current(); |
| 357 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 357 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 358 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer, isolate); |
| 358 Parser parser(script, library, 0); | 359 Parser parser(script, library, 0); |
| 359 parser.ParseTopLevel(); | 360 parser.ParseTopLevel(); |
| 360 } | 361 } |
| 361 | 362 |
| 362 | 363 |
| 363 Token::Kind Parser::CurrentToken() { | 364 Token::Kind Parser::CurrentToken() { |
| 364 if (token_kind_ == Token::kILLEGAL) { | 365 if (token_kind_ == Token::kILLEGAL) { |
| 365 token_kind_ = tokens_iterator_.CurrentTokenKind(); | 366 token_kind_ = tokens_iterator_.CurrentTokenKind(); |
| 366 if (token_kind_ == Token::kERROR) { | 367 if (token_kind_ == Token::kERROR) { |
| 367 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString()); | 368 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString()); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 (seq->NodeAt(seq->length() - 1)->IsSequenceNode())) { | 696 (seq->NodeAt(seq->length() - 1)->IsSequenceNode())) { |
| 696 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); | 697 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); |
| 697 } else { | 698 } else { |
| 698 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); | 699 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); |
| 699 } | 700 } |
| 700 } | 701 } |
| 701 | 702 |
| 702 | 703 |
| 703 void Parser::ParseClass(const Class& cls) { | 704 void Parser::ParseClass(const Class& cls) { |
| 704 if (!cls.is_synthesized_class()) { | 705 if (!cls.is_synthesized_class()) { |
| 705 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | |
| 706 Isolate* isolate = Isolate::Current(); | 706 Isolate* isolate = Isolate::Current(); |
| 707 TimerScope timer(FLAG_compiler_stats, |
| 708 &CompilerStats::parser_timer, |
| 709 isolate); |
| 707 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 710 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 708 const Script& script = Script::Handle(isolate, cls.script()); | 711 const Script& script = Script::Handle(isolate, cls.script()); |
| 709 const Library& lib = Library::Handle(isolate, cls.library()); | 712 const Library& lib = Library::Handle(isolate, cls.library()); |
| 710 Parser parser(script, lib, cls.token_pos()); | 713 Parser parser(script, lib, cls.token_pos()); |
| 711 parser.ParseClassDefinition(cls); | 714 parser.ParseClassDefinition(cls); |
| 712 } | 715 } |
| 713 } | 716 } |
| 714 | 717 |
| 715 | 718 |
| 716 RawObject* Parser::ParseFunctionParameters(const Function& func) { | 719 RawObject* Parser::ParseFunctionParameters(const Function& func) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 error = isolate->object_store()->sticky_error(); | 756 error = isolate->object_store()->sticky_error(); |
| 754 isolate->object_store()->clear_sticky_error(); | 757 isolate->object_store()->clear_sticky_error(); |
| 755 return error.raw(); | 758 return error.raw(); |
| 756 } | 759 } |
| 757 UNREACHABLE(); | 760 UNREACHABLE(); |
| 758 return Object::null(); | 761 return Object::null(); |
| 759 } | 762 } |
| 760 | 763 |
| 761 | 764 |
| 762 void Parser::ParseFunction(ParsedFunction* parsed_function) { | 765 void Parser::ParseFunction(ParsedFunction* parsed_function) { |
| 763 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | |
| 764 Isolate* isolate = Isolate::Current(); | 766 Isolate* isolate = Isolate::Current(); |
| 767 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer, isolate); |
| 765 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 768 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 766 ASSERT(parsed_function != NULL); | 769 ASSERT(parsed_function != NULL); |
| 767 const Function& func = parsed_function->function(); | 770 const Function& func = parsed_function->function(); |
| 768 const Script& script = Script::Handle(isolate, func.script()); | 771 const Script& script = Script::Handle(isolate, func.script()); |
| 769 Parser parser(script, parsed_function, func.token_pos()); | 772 Parser parser(script, parsed_function, func.token_pos()); |
| 770 SequenceNode* node_sequence = NULL; | 773 SequenceNode* node_sequence = NULL; |
| 771 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); | 774 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); |
| 772 switch (func.kind()) { | 775 switch (func.kind()) { |
| 773 case RawFunction::kRegularFunction: | 776 case RawFunction::kRegularFunction: |
| 774 case RawFunction::kClosureFunction: | 777 case RawFunction::kClosureFunction: |
| (...skipping 4102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4877 if (url.StartsWith(Symbols::DartScheme())) { | 4880 if (url.StartsWith(Symbols::DartScheme())) { |
| 4878 if (tag == Dart_kCanonicalizeUrl) { | 4881 if (tag == Dart_kCanonicalizeUrl) { |
| 4879 return url.raw(); | 4882 return url.raw(); |
| 4880 } | 4883 } |
| 4881 return Object::null(); | 4884 return Object::null(); |
| 4882 } | 4885 } |
| 4883 ErrorMsg(token_pos, "no library handler registered"); | 4886 ErrorMsg(token_pos, "no library handler registered"); |
| 4884 } | 4887 } |
| 4885 // Block class finalization attempts when calling into the library | 4888 // Block class finalization attempts when calling into the library |
| 4886 // tag handler. | 4889 // tag handler. |
| 4890 VmToNativeTimerScope timer(isolate()); |
| 4887 isolate()->BlockClassFinalization(); | 4891 isolate()->BlockClassFinalization(); |
| 4888 DartApiScope api_scope(isolate()); | 4892 DartApiScope api_scope(isolate()); |
| 4889 Dart_Handle result = handler(tag, | 4893 Dart_Handle result = handler(tag, |
| 4890 Api::NewHandle(isolate(), library_.raw()), | 4894 Api::NewHandle(isolate(), library_.raw()), |
| 4891 Api::NewHandle(isolate(), url.raw())); | 4895 Api::NewHandle(isolate(), url.raw())); |
| 4892 isolate()->UnblockClassFinalization(); | 4896 isolate()->UnblockClassFinalization(); |
| 4893 if (Dart_IsError(result)) { | 4897 if (Dart_IsError(result)) { |
| 4894 // In case of an error we append an explanatory error message to the | 4898 // In case of an error we append an explanatory error message to the |
| 4895 // error obtained from the library tag handler. | 4899 // error obtained from the library tag handler. |
| 4896 Error& prev_error = Error::Handle(); | 4900 Error& prev_error = Error::Handle(); |
| (...skipping 5878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10775 void Parser::SkipQualIdent() { | 10779 void Parser::SkipQualIdent() { |
| 10776 ASSERT(IsIdentifier()); | 10780 ASSERT(IsIdentifier()); |
| 10777 ConsumeToken(); | 10781 ConsumeToken(); |
| 10778 if (CurrentToken() == Token::kPERIOD) { | 10782 if (CurrentToken() == Token::kPERIOD) { |
| 10779 ConsumeToken(); // Consume the kPERIOD token. | 10783 ConsumeToken(); // Consume the kPERIOD token. |
| 10780 ExpectIdentifier("identifier expected after '.'"); | 10784 ExpectIdentifier("identifier expected after '.'"); |
| 10781 } | 10785 } |
| 10782 } | 10786 } |
| 10783 | 10787 |
| 10784 } // namespace dart | 10788 } // namespace dart |
| OLD | NEW |