| 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 #include "vm/flags.h" | 6 #include "vm/flags.h" |
| 7 | 7 |
| 8 #ifndef DART_PRECOMPILED | 8 #ifndef DART_PRECOMPILED |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 Parser parser(script, lib, cls.token_pos()); | 821 Parser parser(script, lib, cls.token_pos()); |
| 822 parser.ParseEnumDefinition(cls); | 822 parser.ParseEnumDefinition(cls); |
| 823 } | 823 } |
| 824 const int64_t num_tokes_after = STAT_VALUE(thread, num_tokens_consumed); | 824 const int64_t num_tokes_after = STAT_VALUE(thread, num_tokens_consumed); |
| 825 INC_STAT(thread, num_class_tokens, num_tokes_after - num_tokes_before); | 825 INC_STAT(thread, num_class_tokens, num_tokes_after - num_tokes_before); |
| 826 } | 826 } |
| 827 | 827 |
| 828 | 828 |
| 829 RawObject* Parser::ParseFunctionParameters(const Function& func) { | 829 RawObject* Parser::ParseFunctionParameters(const Function& func) { |
| 830 ASSERT(!func.IsNull()); | 830 ASSERT(!func.IsNull()); |
| 831 Thread* thread = Thread::Current(); | |
| 832 Isolate* isolate = thread->isolate(); | |
| 833 StackZone stack_zone(thread); | |
| 834 Zone* zone = stack_zone.GetZone(); | |
| 835 LongJumpScope jump; | 831 LongJumpScope jump; |
| 836 if (setjmp(*jump.Set()) == 0) { | 832 if (setjmp(*jump.Set()) == 0) { |
| 833 Thread* thread = Thread::Current(); |
| 834 StackZone stack_zone(thread); |
| 835 Zone* zone = stack_zone.GetZone(); |
| 837 const Script& script = Script::Handle(zone, func.script()); | 836 const Script& script = Script::Handle(zone, func.script()); |
| 838 const Class& owner = Class::Handle(zone, func.Owner()); | 837 const Class& owner = Class::Handle(zone, func.Owner()); |
| 839 ASSERT(!owner.IsNull()); | 838 ASSERT(!owner.IsNull()); |
| 840 ParsedFunction* parsed_function = new ParsedFunction( | 839 ParsedFunction* parsed_function = new ParsedFunction( |
| 841 thread, Function::ZoneHandle(zone, func.raw())); | 840 thread, Function::ZoneHandle(zone, func.raw())); |
| 842 Parser parser(script, parsed_function, func.token_pos()); | 841 Parser parser(script, parsed_function, func.token_pos()); |
| 843 parser.SkipFunctionPreamble(); | 842 parser.SkipFunctionPreamble(); |
| 844 ParamList params; | 843 ParamList params; |
| 845 parser.ParseFormalParameterList(true, true, ¶ms); | 844 parser.ParseFormalParameterList(true, true, ¶ms); |
| 846 ParamDesc* param = params.parameters->data(); | 845 ParamDesc* param = params.parameters->data(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 857 const Object* metadata = param[i].metadata; | 856 const Object* metadata = param[i].metadata; |
| 858 if ((metadata != NULL) && (*metadata).IsError()) { | 857 if ((metadata != NULL) && (*metadata).IsError()) { |
| 859 return metadata->raw(); // Error evaluating the metadata. | 858 return metadata->raw(); // Error evaluating the metadata. |
| 860 } | 859 } |
| 861 param_descriptor.SetAt(j + kParameterMetadataOffset, | 860 param_descriptor.SetAt(j + kParameterMetadataOffset, |
| 862 (param[i].metadata == NULL) ? Object::null_instance() : | 861 (param[i].metadata == NULL) ? Object::null_instance() : |
| 863 *(param[i].metadata)); | 862 *(param[i].metadata)); |
| 864 } | 863 } |
| 865 return param_descriptor.raw(); | 864 return param_descriptor.raw(); |
| 866 } else { | 865 } else { |
| 866 Thread* thread = Thread::Current(); |
| 867 Isolate* isolate = thread->isolate(); |
| 867 Error& error = Error::Handle(); | 868 Error& error = Error::Handle(); |
| 868 error = isolate->object_store()->sticky_error(); | 869 error = isolate->object_store()->sticky_error(); |
| 869 isolate->object_store()->clear_sticky_error(); | 870 isolate->object_store()->clear_sticky_error(); |
| 870 return error.raw(); | 871 return error.raw(); |
| 871 } | 872 } |
| 872 UNREACHABLE(); | 873 UNREACHABLE(); |
| 873 return Object::null(); | 874 return Object::null(); |
| 874 } | 875 } |
| 875 | 876 |
| 876 | 877 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 } | 1002 } |
| 1002 if (!parser.current_function().IsLocalFunction() || | 1003 if (!parser.current_function().IsLocalFunction() || |
| 1003 ((instantiator != NULL) && instantiator->is_captured())) { | 1004 ((instantiator != NULL) && instantiator->is_captured())) { |
| 1004 parsed_function->set_instantiator(instantiator); | 1005 parsed_function->set_instantiator(instantiator); |
| 1005 } | 1006 } |
| 1006 } | 1007 } |
| 1007 } | 1008 } |
| 1008 | 1009 |
| 1009 | 1010 |
| 1010 RawObject* Parser::ParseMetadata(const Class& cls, intptr_t token_pos) { | 1011 RawObject* Parser::ParseMetadata(const Class& cls, intptr_t token_pos) { |
| 1011 Thread* thread = Thread::Current(); | |
| 1012 Isolate* isolate = thread->isolate(); | |
| 1013 StackZone stack_zone(thread); | |
| 1014 Zone* zone = stack_zone.GetZone(); | |
| 1015 LongJumpScope jump; | 1012 LongJumpScope jump; |
| 1016 if (setjmp(*jump.Set()) == 0) { | 1013 if (setjmp(*jump.Set()) == 0) { |
| 1014 Thread* thread = Thread::Current(); |
| 1015 StackZone stack_zone(thread); |
| 1016 Zone* zone = stack_zone.GetZone(); |
| 1017 const Script& script = Script::Handle(zone, cls.script()); | 1017 const Script& script = Script::Handle(zone, cls.script()); |
| 1018 // Parsing metadata can involve following paths in the parser that are | 1018 // Parsing metadata can involve following paths in the parser that are |
| 1019 // normally used for expressions and assume current_function is non-null, | 1019 // normally used for expressions and assume current_function is non-null, |
| 1020 // so we create a fake function to use as the current_function rather than | 1020 // so we create a fake function to use as the current_function rather than |
| 1021 // scattering special cases throughout the parser. | 1021 // scattering special cases throughout the parser. |
| 1022 const Function& fake_function = Function::ZoneHandle(zone, Function::New( | 1022 const Function& fake_function = Function::ZoneHandle(zone, Function::New( |
| 1023 Symbols::At(), | 1023 Symbols::At(), |
| 1024 RawFunction::kRegularFunction, | 1024 RawFunction::kRegularFunction, |
| 1025 true, // is_static | 1025 true, // is_static |
| 1026 false, // is_const | 1026 false, // is_const |
| 1027 false, // is_abstract | 1027 false, // is_abstract |
| 1028 false, // is_external | 1028 false, // is_external |
| 1029 false, // is_native | 1029 false, // is_native |
| 1030 cls, | 1030 cls, |
| 1031 token_pos)); | 1031 token_pos)); |
| 1032 fake_function.set_is_debuggable(false); | 1032 fake_function.set_is_debuggable(false); |
| 1033 ParsedFunction* parsed_function = | 1033 ParsedFunction* parsed_function = |
| 1034 new ParsedFunction(thread, fake_function); | 1034 new ParsedFunction(thread, fake_function); |
| 1035 Parser parser(script, parsed_function, token_pos); | 1035 Parser parser(script, parsed_function, token_pos); |
| 1036 parser.set_current_class(cls); | 1036 parser.set_current_class(cls); |
| 1037 | 1037 |
| 1038 RawObject* metadata = parser.EvaluateMetadata(); | 1038 RawObject* metadata = parser.EvaluateMetadata(); |
| 1039 return metadata; | 1039 return metadata; |
| 1040 } else { | 1040 } else { |
| 1041 Thread* thread = Thread::Current(); |
| 1042 Isolate* isolate = thread->isolate(); |
| 1043 StackZone stack_zone(thread); |
| 1044 Zone* zone = stack_zone.GetZone(); |
| 1041 Error& error = Error::Handle(zone); | 1045 Error& error = Error::Handle(zone); |
| 1042 error = isolate->object_store()->sticky_error(); | 1046 error = isolate->object_store()->sticky_error(); |
| 1043 isolate->object_store()->clear_sticky_error(); | 1047 isolate->object_store()->clear_sticky_error(); |
| 1044 return error.raw(); | 1048 return error.raw(); |
| 1045 } | 1049 } |
| 1046 UNREACHABLE(); | 1050 UNREACHABLE(); |
| 1047 return Object::null(); | 1051 return Object::null(); |
| 1048 } | 1052 } |
| 1049 | 1053 |
| 1050 | 1054 |
| (...skipping 13370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14421 const ArgumentListNode& function_args, | 14425 const ArgumentListNode& function_args, |
| 14422 const LocalVariable* temp_for_last_arg, | 14426 const LocalVariable* temp_for_last_arg, |
| 14423 bool is_super_invocation) { | 14427 bool is_super_invocation) { |
| 14424 UNREACHABLE(); | 14428 UNREACHABLE(); |
| 14425 return NULL; | 14429 return NULL; |
| 14426 } | 14430 } |
| 14427 | 14431 |
| 14428 } // namespace dart | 14432 } // namespace dart |
| 14429 | 14433 |
| 14430 #endif // DART_PRECOMPILED | 14434 #endif // DART_PRECOMPILED |
| OLD | NEW |