Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: dart/runtime/vm/parser.cc

Issue 119673004: Version 1.1.0-dev.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/runtime/vm/pages.cc ('k') | dart/runtime/vm/parser_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 Parser parser(script, lib, cls.token_pos()); 710 Parser parser(script, lib, cls.token_pos());
711 parser.ParseClassDefinition(cls); 711 parser.ParseClassDefinition(cls);
712 } 712 }
713 } 713 }
714 714
715 715
716 RawObject* Parser::ParseFunctionParameters(const Function& func) { 716 RawObject* Parser::ParseFunctionParameters(const Function& func) {
717 ASSERT(!func.IsNull()); 717 ASSERT(!func.IsNull());
718 Isolate* isolate = Isolate::Current(); 718 Isolate* isolate = Isolate::Current();
719 StackZone zone(isolate); 719 StackZone zone(isolate);
720 LongJump* base = isolate->long_jump_base(); 720 LongJumpScope jump;
721 LongJump jump;
722 isolate->set_long_jump_base(&jump);
723 if (setjmp(*jump.Set()) == 0) { 721 if (setjmp(*jump.Set()) == 0) {
724 const Script& script = Script::Handle(isolate, func.script()); 722 const Script& script = Script::Handle(isolate, func.script());
725 const Class& owner = Class::Handle(isolate, func.Owner()); 723 const Class& owner = Class::Handle(isolate, func.Owner());
726 ASSERT(!owner.IsNull()); 724 ASSERT(!owner.IsNull());
727 ParsedFunction* parsed_function = new ParsedFunction( 725 ParsedFunction* parsed_function = new ParsedFunction(
728 Function::ZoneHandle(func.raw())); 726 Function::ZoneHandle(func.raw()));
729 Parser parser(script, parsed_function, func.token_pos()); 727 Parser parser(script, parsed_function, func.token_pos());
730 parser.SkipFunctionPreamble(); 728 parser.SkipFunctionPreamble();
731 ParamList params; 729 ParamList params;
732 parser.ParseFormalParameterList(true, true, &params); 730 parser.ParseFormalParameterList(true, true, &params);
733 ParamDesc* param = params.parameters->data(); 731 ParamDesc* param = params.parameters->data();
734 const int param_cnt = params.num_fixed_parameters + 732 const int param_cnt = params.num_fixed_parameters +
735 params.num_optional_parameters; 733 params.num_optional_parameters;
736 const Array& param_descriptor = 734 const Array& param_descriptor =
737 Array::Handle(Array::New(param_cnt * kParameterEntrySize)); 735 Array::Handle(Array::New(param_cnt * kParameterEntrySize));
738 for (int i = 0, j = 0; i < param_cnt; i++, j += kParameterEntrySize) { 736 for (int i = 0, j = 0; i < param_cnt; i++, j += kParameterEntrySize) {
739 param_descriptor.SetAt(j + kParameterIsFinalOffset, 737 param_descriptor.SetAt(j + kParameterIsFinalOffset,
740 param[i].is_final ? Bool::True() : Bool::False()); 738 param[i].is_final ? Bool::True() : Bool::False());
741 param_descriptor.SetAt(j + kParameterDefaultValueOffset, 739 param_descriptor.SetAt(j + kParameterDefaultValueOffset,
742 (param[i].default_value == NULL) ? Object::null_instance() : 740 (param[i].default_value == NULL) ? Object::null_instance() :
743 *(param[i].default_value)); 741 *(param[i].default_value));
744 const Object* metadata = param[i].metadata; 742 const Object* metadata = param[i].metadata;
745 if ((metadata != NULL) && (*metadata).IsError()) { 743 if ((metadata != NULL) && (*metadata).IsError()) {
746 isolate->set_long_jump_base(base);
747 return metadata->raw(); // Error evaluating the metadata. 744 return metadata->raw(); // Error evaluating the metadata.
748 } 745 }
749 param_descriptor.SetAt(j + kParameterMetadataOffset, 746 param_descriptor.SetAt(j + kParameterMetadataOffset,
750 (param[i].metadata == NULL) ? Object::null_instance() : 747 (param[i].metadata == NULL) ? Object::null_instance() :
751 *(param[i].metadata)); 748 *(param[i].metadata));
752 } 749 }
753 isolate->set_long_jump_base(base);
754 return param_descriptor.raw(); 750 return param_descriptor.raw();
755 } else { 751 } else {
756 Error& error = Error::Handle(); 752 Error& error = Error::Handle();
757 error = isolate->object_store()->sticky_error(); 753 error = isolate->object_store()->sticky_error();
758 isolate->object_store()->clear_sticky_error(); 754 isolate->object_store()->clear_sticky_error();
759 isolate->set_long_jump_base(base);
760 return error.raw(); 755 return error.raw();
761 } 756 }
762 UNREACHABLE(); 757 UNREACHABLE();
763 return Object::null(); 758 return Object::null();
764 } 759 }
765 760
766 761
767 void Parser::ParseFunction(ParsedFunction* parsed_function) { 762 void Parser::ParseFunction(ParsedFunction* parsed_function) {
768 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 763 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
769 Isolate* isolate = Isolate::Current(); 764 Isolate* isolate = Isolate::Current();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } 844 }
850 } 845 }
851 846
852 parsed_function->set_default_parameter_values(default_parameter_values); 847 parsed_function->set_default_parameter_values(default_parameter_values);
853 } 848 }
854 849
855 850
856 RawObject* Parser::ParseMetadata(const Class& cls, intptr_t token_pos) { 851 RawObject* Parser::ParseMetadata(const Class& cls, intptr_t token_pos) {
857 Isolate* isolate = Isolate::Current(); 852 Isolate* isolate = Isolate::Current();
858 StackZone zone(isolate); 853 StackZone zone(isolate);
859 LongJump* base = isolate->long_jump_base(); 854 LongJumpScope jump;
860 LongJump jump;
861 isolate->set_long_jump_base(&jump);
862 if (setjmp(*jump.Set()) == 0) { 855 if (setjmp(*jump.Set()) == 0) {
863 const Script& script = Script::Handle(cls.script()); 856 const Script& script = Script::Handle(cls.script());
864 const Library& lib = Library::Handle(cls.library()); 857 const Library& lib = Library::Handle(cls.library());
865 Parser parser(script, lib, token_pos); 858 Parser parser(script, lib, token_pos);
866 parser.set_current_class(cls); 859 parser.set_current_class(cls);
867 parser.set_parsing_metadata(true); 860 parser.set_parsing_metadata(true);
868 861
869 RawObject* metadata = parser.EvaluateMetadata(); 862 RawObject* metadata = parser.EvaluateMetadata();
870 isolate->set_long_jump_base(base);
871 return metadata; 863 return metadata;
872 } else { 864 } else {
873 Error& error = Error::Handle(); 865 Error& error = Error::Handle();
874 error = isolate->object_store()->sticky_error(); 866 error = isolate->object_store()->sticky_error();
875 isolate->object_store()->clear_sticky_error(); 867 isolate->object_store()->clear_sticky_error();
876 isolate->set_long_jump_base(base);
877 return error.raw(); 868 return error.raw();
878 } 869 }
879 UNREACHABLE(); 870 UNREACHABLE();
880 return Object::null(); 871 return Object::null();
881 } 872 }
882 873
883 874
884 RawArray* Parser::EvaluateMetadata() { 875 RawArray* Parser::EvaluateMetadata() {
885 CheckToken(Token::kAT, "Metadata character '@' expected"); 876 CheckToken(Token::kAT, "Metadata character '@' expected");
886 GrowableObjectArray& meta_values = 877 GrowableObjectArray& meta_values =
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 "class '%s' may not extend 'dynamic'", 3898 "class '%s' may not extend 'dynamic'",
3908 class_name.ToCString()); 3899 class_name.ToCString());
3909 } 3900 }
3910 if (super_type.IsTypeParameter()) { 3901 if (super_type.IsTypeParameter()) {
3911 ErrorMsg(type_pos, 3902 ErrorMsg(type_pos,
3912 "class '%s' may not extend type parameter '%s'", 3903 "class '%s' may not extend type parameter '%s'",
3913 class_name.ToCString(), 3904 class_name.ToCString(),
3914 String::Handle(super_type.UserVisibleName()).ToCString()); 3905 String::Handle(super_type.UserVisibleName()).ToCString());
3915 } 3906 }
3916 // The class finalizer will check whether the super type is malbounded. 3907 // The class finalizer will check whether the super type is malbounded.
3908 if (is_mixin_declaration) {
3909 if (CurrentToken() != Token::kWITH) {
3910 ErrorMsg("mixin application clause 'with type' expected");
3911 }
3912 cls.set_is_mixin_app_alias();
3913 cls.set_is_synthesized_class();
3914 }
3917 if (CurrentToken() == Token::kWITH) { 3915 if (CurrentToken() == Token::kWITH) {
3918 super_type = ParseMixins(super_type); 3916 super_type = ParseMixins(super_type);
3919 } 3917 }
3920 if (is_mixin_declaration) {
3921 cls.set_is_mixin_app_alias();
3922 cls.set_is_synthesized_class();
3923 }
3924 } else { 3918 } else {
3925 // No extends clause: implicitly extend Object, unless Object itself. 3919 // No extends clause: implicitly extend Object, unless Object itself.
3926 if (!cls.IsObjectClass()) { 3920 if (!cls.IsObjectClass()) {
3927 super_type = Type::ObjectType(); 3921 super_type = Type::ObjectType();
3928 } 3922 }
3929 } 3923 }
3930 ASSERT(!super_type.IsNull() || cls.IsObjectClass()); 3924 ASSERT(!super_type.IsNull() || cls.IsObjectClass());
3931 cls.set_super_type(super_type); 3925 cls.set_super_type(super_type);
3932 3926
3933 if (CurrentToken() == Token::kIMPLEMENTS) { 3927 if (CurrentToken() == Token::kIMPLEMENTS) {
(...skipping 6823 matching lines...) Expand 10 before | Expand all | Expand 10 after
10757 void Parser::SkipQualIdent() { 10751 void Parser::SkipQualIdent() {
10758 ASSERT(IsIdentifier()); 10752 ASSERT(IsIdentifier());
10759 ConsumeToken(); 10753 ConsumeToken();
10760 if (CurrentToken() == Token::kPERIOD) { 10754 if (CurrentToken() == Token::kPERIOD) {
10761 ConsumeToken(); // Consume the kPERIOD token. 10755 ConsumeToken(); // Consume the kPERIOD token.
10762 ExpectIdentifier("identifier expected after '.'"); 10756 ExpectIdentifier("identifier expected after '.'");
10763 } 10757 }
10764 } 10758 }
10765 10759
10766 } // namespace dart 10760 } // namespace dart
OLDNEW
« no previous file with comments | « dart/runtime/vm/pages.cc ('k') | dart/runtime/vm/parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698