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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 tokens_iterator_.SetCurrentPosition(position); | 374 tokens_iterator_.SetCurrentPosition(position); |
375 token_kind_ = Token::kILLEGAL; | 375 token_kind_ = Token::kILLEGAL; |
376 } | 376 } |
377 | 377 |
378 | 378 |
379 void Parser::ParseCompilationUnit(const Library& library, | 379 void Parser::ParseCompilationUnit(const Library& library, |
380 const Script& script) { | 380 const Script& script) { |
381 Isolate* isolate = Isolate::Current(); | 381 Isolate* isolate = Isolate::Current(); |
382 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 382 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
383 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 383 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
384 VMTagScope tagScope(isolate, VMTag::kCompileTagId); | 384 VMTagScope tagScope(isolate, VMTag::kCompileTopLevelTagId); |
385 Parser parser(script, library, 0); | 385 Parser parser(script, library, 0); |
386 parser.ParseTopLevel(); | 386 parser.ParseTopLevel(); |
387 } | 387 } |
388 | 388 |
389 | 389 |
390 Token::Kind Parser::CurrentToken() { | 390 Token::Kind Parser::CurrentToken() { |
391 if (token_kind_ == Token::kILLEGAL) { | 391 if (token_kind_ == Token::kILLEGAL) { |
392 token_kind_ = tokens_iterator_.CurrentTokenKind(); | 392 token_kind_ = tokens_iterator_.CurrentTokenKind(); |
393 if (token_kind_ == Token::kERROR) { | 393 if (token_kind_ == Token::kERROR) { |
394 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString()); | 394 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString()); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); | 723 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); |
724 } else { | 724 } else { |
725 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); | 725 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); |
726 } | 726 } |
727 } | 727 } |
728 | 728 |
729 | 729 |
730 void Parser::ParseClass(const Class& cls) { | 730 void Parser::ParseClass(const Class& cls) { |
731 if (!cls.is_synthesized_class()) { | 731 if (!cls.is_synthesized_class()) { |
732 Isolate* isolate = Isolate::Current(); | 732 Isolate* isolate = Isolate::Current(); |
733 VMTagScope tagScope(isolate, VMTag::kCompileTagId); | 733 VMTagScope tagScope(isolate, VMTag::kCompileTopLevelTagId); |
734 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 734 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
735 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 735 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
736 const Script& script = Script::Handle(isolate, cls.script()); | 736 const Script& script = Script::Handle(isolate, cls.script()); |
737 const Library& lib = Library::Handle(isolate, cls.library()); | 737 const Library& lib = Library::Handle(isolate, cls.library()); |
738 Parser parser(script, lib, cls.token_pos()); | 738 Parser parser(script, lib, cls.token_pos()); |
739 parser.ParseClassDefinition(cls); | 739 parser.ParseClassDefinition(cls); |
740 } | 740 } |
741 } | 741 } |
742 | 742 |
743 | 743 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 isolate->object_store()->clear_sticky_error(); | 782 isolate->object_store()->clear_sticky_error(); |
783 return error.raw(); | 783 return error.raw(); |
784 } | 784 } |
785 UNREACHABLE(); | 785 UNREACHABLE(); |
786 return Object::null(); | 786 return Object::null(); |
787 } | 787 } |
788 | 788 |
789 | 789 |
790 void Parser::ParseFunction(ParsedFunction* parsed_function) { | 790 void Parser::ParseFunction(ParsedFunction* parsed_function) { |
791 Isolate* isolate = Isolate::Current(); | 791 Isolate* isolate = Isolate::Current(); |
792 VMTagScope tagScope(isolate, VMTag::kCompileTagId); | 792 VMTagScope tagScope(isolate, VMTag::kCompileTopLevelTagId); |
793 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 793 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
794 CompilerStats::num_functions_compiled++; | 794 CompilerStats::num_functions_compiled++; |
795 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 795 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
796 ASSERT(parsed_function != NULL); | 796 ASSERT(parsed_function != NULL); |
797 const Function& func = parsed_function->function(); | 797 const Function& func = parsed_function->function(); |
798 const Script& script = Script::Handle(isolate, func.script()); | 798 const Script& script = Script::Handle(isolate, func.script()); |
799 Parser parser(script, parsed_function, func.token_pos()); | 799 Parser parser(script, parsed_function, func.token_pos()); |
800 SequenceNode* node_sequence = NULL; | 800 SequenceNode* node_sequence = NULL; |
801 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); | 801 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); |
802 switch (func.kind()) { | 802 switch (func.kind()) { |
(...skipping 10146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10949 void Parser::SkipQualIdent() { | 10949 void Parser::SkipQualIdent() { |
10950 ASSERT(IsIdentifier()); | 10950 ASSERT(IsIdentifier()); |
10951 ConsumeToken(); | 10951 ConsumeToken(); |
10952 if (CurrentToken() == Token::kPERIOD) { | 10952 if (CurrentToken() == Token::kPERIOD) { |
10953 ConsumeToken(); // Consume the kPERIOD token. | 10953 ConsumeToken(); // Consume the kPERIOD token. |
10954 ExpectIdentifier("identifier expected after '.'"); | 10954 ExpectIdentifier("identifier expected after '.'"); |
10955 } | 10955 } |
10956 } | 10956 } |
10957 | 10957 |
10958 } // namespace dart | 10958 } // namespace dart |
OLD | NEW |