| 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 10 matching lines...) Expand all Loading... |
| 21 #include "vm/native_arguments.h" | 21 #include "vm/native_arguments.h" |
| 22 #include "vm/native_entry.h" | 22 #include "vm/native_entry.h" |
| 23 #include "vm/object.h" | 23 #include "vm/object.h" |
| 24 #include "vm/object_store.h" | 24 #include "vm/object_store.h" |
| 25 #include "vm/os.h" | 25 #include "vm/os.h" |
| 26 #include "vm/resolver.h" | 26 #include "vm/resolver.h" |
| 27 #include "vm/scanner.h" | 27 #include "vm/scanner.h" |
| 28 #include "vm/scopes.h" | 28 #include "vm/scopes.h" |
| 29 #include "vm/stack_frame.h" | 29 #include "vm/stack_frame.h" |
| 30 #include "vm/symbols.h" | 30 #include "vm/symbols.h" |
| 31 #include "vm/tags.h" |
| 31 #include "vm/timer.h" | 32 #include "vm/timer.h" |
| 32 #include "vm/zone.h" | 33 #include "vm/zone.h" |
| 33 | 34 |
| 34 namespace dart { | 35 namespace dart { |
| 35 | 36 |
| 36 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); | 37 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); |
| 37 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); | 38 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); |
| 38 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 39 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| 39 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); | 40 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); |
| 40 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); | 41 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (position < TokenPos() && position != 0) { | 347 if (position < TokenPos() && position != 0) { |
| 347 CompilerStats::num_tokens_rewind += (TokenPos() - position); | 348 CompilerStats::num_tokens_rewind += (TokenPos() - position); |
| 348 } | 349 } |
| 349 tokens_iterator_.SetCurrentPosition(position); | 350 tokens_iterator_.SetCurrentPosition(position); |
| 350 token_kind_ = Token::kILLEGAL; | 351 token_kind_ = Token::kILLEGAL; |
| 351 } | 352 } |
| 352 | 353 |
| 353 | 354 |
| 354 void Parser::ParseCompilationUnit(const Library& library, | 355 void Parser::ParseCompilationUnit(const Library& library, |
| 355 const Script& script) { | 356 const Script& script) { |
| 356 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); | 357 Isolate* isolate = Isolate::Current(); |
| 358 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 357 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 359 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
| 360 VMTagScope tagScope(isolate, VMTag::kCompileTagId); |
| 358 Parser parser(script, library, 0); | 361 Parser parser(script, library, 0); |
| 359 parser.ParseTopLevel(); | 362 parser.ParseTopLevel(); |
| 360 } | 363 } |
| 361 | 364 |
| 362 | 365 |
| 363 Token::Kind Parser::CurrentToken() { | 366 Token::Kind Parser::CurrentToken() { |
| 364 if (token_kind_ == Token::kILLEGAL) { | 367 if (token_kind_ == Token::kILLEGAL) { |
| 365 token_kind_ = tokens_iterator_.CurrentTokenKind(); | 368 token_kind_ = tokens_iterator_.CurrentTokenKind(); |
| 366 if (token_kind_ == Token::kERROR) { | 369 if (token_kind_ == Token::kERROR) { |
| 367 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString()); | 370 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())) { | 698 (seq->NodeAt(seq->length() - 1)->IsSequenceNode())) { |
| 696 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); | 699 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); |
| 697 } else { | 700 } else { |
| 698 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); | 701 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); |
| 699 } | 702 } |
| 700 } | 703 } |
| 701 | 704 |
| 702 | 705 |
| 703 void Parser::ParseClass(const Class& cls) { | 706 void Parser::ParseClass(const Class& cls) { |
| 704 if (!cls.is_synthesized_class()) { | 707 if (!cls.is_synthesized_class()) { |
| 708 Isolate* isolate = Isolate::Current(); |
| 709 VMTagScope tagScope(isolate, VMTag::kCompileTagId); |
| 705 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 710 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
| 706 Isolate* isolate = Isolate::Current(); | |
| 707 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 711 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 708 const Script& script = Script::Handle(isolate, cls.script()); | 712 const Script& script = Script::Handle(isolate, cls.script()); |
| 709 const Library& lib = Library::Handle(isolate, cls.library()); | 713 const Library& lib = Library::Handle(isolate, cls.library()); |
| 710 Parser parser(script, lib, cls.token_pos()); | 714 Parser parser(script, lib, cls.token_pos()); |
| 711 parser.ParseClassDefinition(cls); | 715 parser.ParseClassDefinition(cls); |
| 712 } | 716 } |
| 713 } | 717 } |
| 714 | 718 |
| 715 | 719 |
| 716 RawObject* Parser::ParseFunctionParameters(const Function& func) { | 720 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(); | 757 error = isolate->object_store()->sticky_error(); |
| 754 isolate->object_store()->clear_sticky_error(); | 758 isolate->object_store()->clear_sticky_error(); |
| 755 return error.raw(); | 759 return error.raw(); |
| 756 } | 760 } |
| 757 UNREACHABLE(); | 761 UNREACHABLE(); |
| 758 return Object::null(); | 762 return Object::null(); |
| 759 } | 763 } |
| 760 | 764 |
| 761 | 765 |
| 762 void Parser::ParseFunction(ParsedFunction* parsed_function) { | 766 void Parser::ParseFunction(ParsedFunction* parsed_function) { |
| 767 Isolate* isolate = Isolate::Current(); |
| 768 VMTagScope tagScope(isolate, VMTag::kCompileTagId); |
| 763 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 769 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
| 764 CompilerStats::num_functions_compiled++; | 770 CompilerStats::num_functions_compiled++; |
| 765 Isolate* isolate = Isolate::Current(); | |
| 766 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 771 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
| 767 ASSERT(parsed_function != NULL); | 772 ASSERT(parsed_function != NULL); |
| 768 const Function& func = parsed_function->function(); | 773 const Function& func = parsed_function->function(); |
| 769 const Script& script = Script::Handle(isolate, func.script()); | 774 const Script& script = Script::Handle(isolate, func.script()); |
| 770 Parser parser(script, parsed_function, func.token_pos()); | 775 Parser parser(script, parsed_function, func.token_pos()); |
| 771 SequenceNode* node_sequence = NULL; | 776 SequenceNode* node_sequence = NULL; |
| 772 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); | 777 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); |
| 773 switch (func.kind()) { | 778 switch (func.kind()) { |
| 774 case RawFunction::kRegularFunction: | 779 case RawFunction::kRegularFunction: |
| 775 case RawFunction::kClosureFunction: | 780 case RawFunction::kClosureFunction: |
| (...skipping 10012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10788 void Parser::SkipQualIdent() { | 10793 void Parser::SkipQualIdent() { |
| 10789 ASSERT(IsIdentifier()); | 10794 ASSERT(IsIdentifier()); |
| 10790 ConsumeToken(); | 10795 ConsumeToken(); |
| 10791 if (CurrentToken() == Token::kPERIOD) { | 10796 if (CurrentToken() == Token::kPERIOD) { |
| 10792 ConsumeToken(); // Consume the kPERIOD token. | 10797 ConsumeToken(); // Consume the kPERIOD token. |
| 10793 ExpectIdentifier("identifier expected after '.'"); | 10798 ExpectIdentifier("identifier expected after '.'"); |
| 10794 } | 10799 } |
| 10795 } | 10800 } |
| 10796 | 10801 |
| 10797 } // namespace dart | 10802 } // namespace dart |
| OLD | NEW |