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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 const Class& cls = Class::Handle(func.Owner()); | 768 const Class& cls = Class::Handle(func.Owner()); |
769 const Library& library = Library::Handle(cls.library()); | 769 const Library& library = Library::Handle(cls.library()); |
770 if (library.raw() == Library::CoreLibrary()) return true; | 770 if (library.raw() == Library::CoreLibrary()) return true; |
771 if (library.raw() == Library::CollectionLibrary()) return true; | 771 if (library.raw() == Library::CollectionLibrary()) return true; |
772 if (library.raw() == Library::TypedDataLibrary()) return true; | 772 if (library.raw() == Library::TypedDataLibrary()) return true; |
773 if (library.raw() == Library::MathLibrary()) return true; | 773 if (library.raw() == Library::MathLibrary()) return true; |
774 return false; | 774 return false; |
775 } | 775 } |
776 | 776 |
777 | 777 |
| 778 RawObject* Parser::ParseFunctionParameters(const Function& func) { |
| 779 ASSERT(!func.IsNull()); |
| 780 Isolate* isolate = Isolate::Current(); |
| 781 StackZone zone(isolate); |
| 782 LongJump* base = isolate->long_jump_base(); |
| 783 LongJump jump; |
| 784 isolate->set_long_jump_base(&jump); |
| 785 if (setjmp(*jump.Set()) == 0) { |
| 786 const Script& script = Script::Handle(isolate, func.script()); |
| 787 const Class& owner = Class::Handle(isolate, func.Owner()); |
| 788 ASSERT(!owner.IsNull()); |
| 789 const Library& lib = Library::Handle(isolate, owner.library()); |
| 790 Parser parser(script, lib, func.token_pos()); |
| 791 parser.set_current_class(owner); |
| 792 parser.SkipFunctionPreamble(); |
| 793 ParamList params; |
| 794 parser.ParseFormalParameterList(true, ¶ms); |
| 795 ParamDesc* param = params.parameters->data(); |
| 796 const int param_cnt = params.num_fixed_parameters + |
| 797 params.num_optional_parameters; |
| 798 Array& param_descriptor = Array::Handle(isolate, Array::New(param_cnt * 2)); |
| 799 for (int i = 0, j = 0; i < param_cnt; i++, j += 2) { |
| 800 param_descriptor.SetAt(j, param[i].is_final ? Bool::True() : |
| 801 Bool::False()); |
| 802 param_descriptor.SetAt(j + 1, |
| 803 (param[i].default_value == NULL) ? Object::null_instance() : |
| 804 *(param[i].default_value)); |
| 805 } |
| 806 isolate->set_long_jump_base(base); |
| 807 return param_descriptor.raw(); |
| 808 } else { |
| 809 Error& error = Error::Handle(); |
| 810 error = isolate->object_store()->sticky_error(); |
| 811 isolate->object_store()->clear_sticky_error(); |
| 812 isolate->set_long_jump_base(base); |
| 813 return error.raw(); |
| 814 } |
| 815 UNREACHABLE(); |
| 816 return Object::null(); |
| 817 } |
| 818 |
| 819 |
778 void Parser::ParseFunction(ParsedFunction* parsed_function) { | 820 void Parser::ParseFunction(ParsedFunction* parsed_function) { |
779 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); | 821 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); |
780 Isolate* isolate = Isolate::Current(); | 822 Isolate* isolate = Isolate::Current(); |
781 ASSERT(isolate->long_jump_base()->IsSafeToJump()); | 823 ASSERT(isolate->long_jump_base()->IsSafeToJump()); |
782 ASSERT(parsed_function != NULL); | 824 ASSERT(parsed_function != NULL); |
783 const Function& func = parsed_function->function(); | 825 const Function& func = parsed_function->function(); |
784 // Mark private core library functions as invisible by default. | 826 // Mark private core library functions as invisible by default. |
785 if (IsInvisible(func)) func.set_is_visible(false); | 827 if (IsInvisible(func)) func.set_is_visible(false); |
786 const Script& script = Script::Handle(isolate, func.script()); | 828 const Script& script = Script::Handle(isolate, func.script()); |
787 Parser parser(script, parsed_function, func.token_pos()); | 829 Parser parser(script, parsed_function, func.token_pos()); |
(...skipping 9611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10399 void Parser::SkipQualIdent() { | 10441 void Parser::SkipQualIdent() { |
10400 ASSERT(IsIdentifier()); | 10442 ASSERT(IsIdentifier()); |
10401 ConsumeToken(); | 10443 ConsumeToken(); |
10402 if (CurrentToken() == Token::kPERIOD) { | 10444 if (CurrentToken() == Token::kPERIOD) { |
10403 ConsumeToken(); // Consume the kPERIOD token. | 10445 ConsumeToken(); // Consume the kPERIOD token. |
10404 ExpectIdentifier("identifier expected after '.'"); | 10446 ExpectIdentifier("identifier expected after '.'"); |
10405 } | 10447 } |
10406 } | 10448 } |
10407 | 10449 |
10408 } // namespace dart | 10450 } // namespace dart |
OLD | NEW |