Chromium Code Reviews| 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 | 848 |
| 849 | 849 |
| 850 RawObject* Parser::ParseMetadata(const Class& cls, intptr_t token_pos) { | 850 RawObject* Parser::ParseMetadata(const Class& cls, intptr_t token_pos) { |
| 851 Isolate* isolate = Isolate::Current(); | 851 Isolate* isolate = Isolate::Current(); |
| 852 StackZone zone(isolate); | 852 StackZone zone(isolate); |
| 853 LongJump* base = isolate->long_jump_base(); | 853 LongJump* base = isolate->long_jump_base(); |
| 854 LongJump jump; | 854 LongJump jump; |
| 855 isolate->set_long_jump_base(&jump); | 855 isolate->set_long_jump_base(&jump); |
| 856 if (setjmp(*jump.Set()) == 0) { | 856 if (setjmp(*jump.Set()) == 0) { |
| 857 const Script& script = Script::Handle(cls.script()); | 857 const Script& script = Script::Handle(cls.script()); |
| 858 const Library& lib = Library::Handle(cls.library()); | 858 const Function& func = Function::ZoneHandle(Function::New( |
| 859 Parser parser(script, lib, token_pos); | 859 Symbols::Empty(), |
| 860 parser.set_current_class(cls); | 860 RawFunction::kRegularFunction, |
| 861 true, // is_static | |
| 862 false, // is_const | |
| 863 false, // is_abstract | |
| 864 false, // is_external | |
| 865 cls, | |
| 866 token_pos)); | |
| 867 ParsedFunction* parsed_function = new ParsedFunction(func); | |
| 868 Parser parser(script, parsed_function, token_pos); | |
| 861 return parser.EvaluateMetadata(); | 869 return parser.EvaluateMetadata(); |
| 862 } else { | 870 } else { |
| 863 Error& error = Error::Handle(); | 871 Error& error = Error::Handle(); |
| 864 error = isolate->object_store()->sticky_error(); | 872 error = isolate->object_store()->sticky_error(); |
| 865 isolate->object_store()->clear_sticky_error(); | 873 isolate->object_store()->clear_sticky_error(); |
| 866 isolate->set_long_jump_base(base); | 874 isolate->set_long_jump_base(base); |
| 867 return error.raw(); | 875 return error.raw(); |
| 868 } | 876 } |
| 869 UNREACHABLE(); | 877 UNREACHABLE(); |
| 870 return Object::null(); | 878 return Object::null(); |
| 871 } | 879 } |
| 872 | 880 |
| 873 | 881 // ZED |
| 874 RawArray* Parser::EvaluateMetadata() { | 882 RawArray* Parser::EvaluateMetadata() { |
| 875 if (CurrentToken() != Token::kAT) { | 883 if (CurrentToken() != Token::kAT) { |
| 876 ErrorMsg("Metadata character '@' expected"); | 884 ErrorMsg("Metadata character '@' expected"); |
| 877 } | 885 } |
| 878 GrowableObjectArray& meta_values = | 886 GrowableObjectArray& meta_values = |
| 879 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 887 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 880 while (CurrentToken() == Token::kAT) { | 888 while (CurrentToken() == Token::kAT) { |
| 881 ConsumeToken(); | 889 ConsumeToken(); |
| 882 intptr_t expr_pos = TokenPos(); | 890 intptr_t expr_pos = TokenPos(); |
| 883 if (!IsIdentifier()) { | 891 if (!IsIdentifier()) { |
| 884 ExpectIdentifier("identifier expected"); | 892 ExpectIdentifier("identifier expected"); |
| 885 } | 893 } |
| 886 AstNode* expr = NULL; | 894 AstNode* expr = NULL; |
| 887 if ((LookaheadToken(1) == Token::kLPAREN) || | 895 if ((LookaheadToken(1) == Token::kLPAREN) || |
| 888 ((LookaheadToken(1) == Token::kPERIOD) && | 896 ((LookaheadToken(1) == Token::kPERIOD) && |
| 889 (LookaheadToken(3) == Token::kLPAREN)) || | 897 (LookaheadToken(3) == Token::kLPAREN)) || |
| 890 ((LookaheadToken(1) == Token::kPERIOD) && | 898 ((LookaheadToken(1) == Token::kPERIOD) && |
| 891 (LookaheadToken(3) == Token::kPERIOD) && | 899 (LookaheadToken(3) == Token::kPERIOD) && |
| 892 (LookaheadToken(5) == Token::kLPAREN))) { | 900 (LookaheadToken(5) == Token::kLPAREN))) { |
| 893 expr = ParseNewOperator(Token::kCONST); | 901 expr = ParseNewOperator(Token::kCONST); |
| 894 } else { | 902 } else { |
| 895 expr = ParsePrimary(); | 903 expr = ParsePrimary(); |
| 904 expr = ParseSelectors(expr, false); | |
|
rmacnak
2013/10/24 18:45:03
Expects a valid current_function.
hausner
2013/10/24 18:54:05
You can't use this function here, or you'd accept
| |
| 896 } | 905 } |
| 897 if (expr->EvalConstExpr() == NULL) { | 906 if (expr->EvalConstExpr() == NULL) { |
| 898 ErrorMsg(expr_pos, "expression must be a compile-time constant"); | 907 ErrorMsg(expr_pos, "expression must be a compile-time constant"); |
| 899 } | 908 } |
| 900 const Instance& val = EvaluateConstExpr(expr); | 909 const Instance& val = EvaluateConstExpr(expr); |
| 901 meta_values.Add(val); | 910 meta_values.Add(val); |
| 902 } | 911 } |
| 903 return Array::MakeArray(meta_values); | 912 return Array::MakeArray(meta_values); |
| 904 } | 913 } |
| 905 | 914 |
| (...skipping 9705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10611 void Parser::SkipQualIdent() { | 10620 void Parser::SkipQualIdent() { |
| 10612 ASSERT(IsIdentifier()); | 10621 ASSERT(IsIdentifier()); |
| 10613 ConsumeToken(); | 10622 ConsumeToken(); |
| 10614 if (CurrentToken() == Token::kPERIOD) { | 10623 if (CurrentToken() == Token::kPERIOD) { |
| 10615 ConsumeToken(); // Consume the kPERIOD token. | 10624 ConsumeToken(); // Consume the kPERIOD token. |
| 10616 ExpectIdentifier("identifier expected after '.'"); | 10625 ExpectIdentifier("identifier expected after '.'"); |
| 10617 } | 10626 } |
| 10618 } | 10627 } |
| 10619 | 10628 |
| 10620 } // namespace dart | 10629 } // namespace dart |
| OLD | NEW |