| 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/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 case RawFunction::kImplicitSetter: | 795 case RawFunction::kImplicitSetter: |
| 796 ASSERT(!func.is_static()); | 796 ASSERT(!func.is_static()); |
| 797 node_sequence = parser.ParseInstanceSetter(func); | 797 node_sequence = parser.ParseInstanceSetter(func); |
| 798 break; | 798 break; |
| 799 case RawFunction::kConstImplicitGetter: | 799 case RawFunction::kConstImplicitGetter: |
| 800 node_sequence = parser.ParseStaticConstGetter(func); | 800 node_sequence = parser.ParseStaticConstGetter(func); |
| 801 break; | 801 break; |
| 802 case RawFunction::kMethodExtractor: | 802 case RawFunction::kMethodExtractor: |
| 803 node_sequence = parser.ParseMethodExtractor(func); | 803 node_sequence = parser.ParseMethodExtractor(func); |
| 804 break; | 804 break; |
| 805 case RawFunction::kNoSuchMethodDispatcher: | |
| 806 node_sequence = parser.ParseNoSuchMethodDispatcher(func); | |
| 807 break; | |
| 808 default: | 805 default: |
| 809 UNREACHABLE(); | 806 UNREACHABLE(); |
| 810 } | 807 } |
| 811 | 808 |
| 812 if (!HasReturnNode(node_sequence)) { | 809 if (!HasReturnNode(node_sequence)) { |
| 813 // Add implicit return node. | 810 // Add implicit return node. |
| 814 node_sequence->Add(new ReturnNode(func.end_token_pos())); | 811 node_sequence->Add(new ReturnNode(func.end_token_pos())); |
| 815 } | 812 } |
| 816 if (parsed_function->has_expression_temp_var()) { | 813 if (parsed_function->has_expression_temp_var()) { |
| 817 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); | 814 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 Function::ZoneHandle(func.extracted_method_closure()), | 1127 Function::ZoneHandle(func.extracted_method_closure()), |
| 1131 load_receiver, | 1128 load_receiver, |
| 1132 NULL); | 1129 NULL); |
| 1133 | 1130 |
| 1134 ReturnNode* return_node = new ReturnNode(ident_pos, closure); | 1131 ReturnNode* return_node = new ReturnNode(ident_pos, closure); |
| 1135 current_block_->statements->Add(return_node); | 1132 current_block_->statements->Add(return_node); |
| 1136 return CloseBlock(); | 1133 return CloseBlock(); |
| 1137 } | 1134 } |
| 1138 | 1135 |
| 1139 | 1136 |
| 1140 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func) { | |
| 1141 TRACE_PARSER("ParseNoSuchMethodDispatcher"); | |
| 1142 ParamList params; | |
| 1143 | |
| 1144 ASSERT(func.IsNoSuchMethodDispatcher()); | |
| 1145 intptr_t token_pos = func.token_pos(); | |
| 1146 ASSERT(func.token_pos() == 0); | |
| 1147 ASSERT(current_class().raw() == func.Owner()); | |
| 1148 params.AddReceiver(ReceiverType(token_pos)); | |
| 1149 ASSERT(func.num_fixed_parameters() == 1); // Receiver. | |
| 1150 ASSERT(!func.HasOptionalParameters()); | |
| 1151 | |
| 1152 // Build local scope for function and populate with the formal parameters. | |
| 1153 OpenFunctionBlock(func); | |
| 1154 LocalScope* scope = current_block_->scope; | |
| 1155 AddFormalParamsToScope(¶ms, scope); | |
| 1156 | |
| 1157 // Receiver is local 0. | |
| 1158 LocalVariable* receiver = scope->VariableAt(0); | |
| 1159 LoadLocalNode* load_receiver = new LoadLocalNode(token_pos, receiver); | |
| 1160 | |
| 1161 ArgumentListNode* func_args = new ArgumentListNode(token_pos); | |
| 1162 func_args->Add(load_receiver); | |
| 1163 const String& func_name = String::ZoneHandle(func.name()); | |
| 1164 ArgumentListNode* arguments = BuildNoSuchMethodArguments(token_pos, | |
| 1165 func_name, | |
| 1166 *func_args); | |
| 1167 const Function& no_such_method = Function::ZoneHandle( | |
| 1168 Resolver::ResolveDynamicAnyArgs(Class::Handle(func.Owner()), | |
| 1169 Symbols::NoSuchMethod())); | |
| 1170 StaticCallNode* call = | |
| 1171 new StaticCallNode(token_pos, no_such_method, arguments); | |
| 1172 | |
| 1173 | |
| 1174 ReturnNode* return_node = new ReturnNode(token_pos, call); | |
| 1175 current_block_->statements->Add(return_node); | |
| 1176 return CloseBlock(); | |
| 1177 } | |
| 1178 | |
| 1179 | |
| 1180 void Parser::SkipBlock() { | 1137 void Parser::SkipBlock() { |
| 1181 ASSERT(CurrentToken() == Token::kLBRACE); | 1138 ASSERT(CurrentToken() == Token::kLBRACE); |
| 1182 GrowableArray<Token::Kind> token_stack(8); | 1139 GrowableArray<Token::Kind> token_stack(8); |
| 1183 const intptr_t block_start_pos = TokenPos(); | 1140 const intptr_t block_start_pos = TokenPos(); |
| 1184 bool is_match = true; | 1141 bool is_match = true; |
| 1185 bool unexpected_token_found = false; | 1142 bool unexpected_token_found = false; |
| 1186 Token::Kind token; | 1143 Token::Kind token; |
| 1187 intptr_t token_pos; | 1144 intptr_t token_pos; |
| 1188 do { | 1145 do { |
| 1189 token = CurrentToken(); | 1146 token = CurrentToken(); |
| (...skipping 8962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10152 void Parser::SkipQualIdent() { | 10109 void Parser::SkipQualIdent() { |
| 10153 ASSERT(IsIdentifier()); | 10110 ASSERT(IsIdentifier()); |
| 10154 ConsumeToken(); | 10111 ConsumeToken(); |
| 10155 if (CurrentToken() == Token::kPERIOD) { | 10112 if (CurrentToken() == Token::kPERIOD) { |
| 10156 ConsumeToken(); // Consume the kPERIOD token. | 10113 ConsumeToken(); // Consume the kPERIOD token. |
| 10157 ExpectIdentifier("identifier expected after '.'"); | 10114 ExpectIdentifier("identifier expected after '.'"); |
| 10158 } | 10115 } |
| 10159 } | 10116 } |
| 10160 | 10117 |
| 10161 } // namespace dart | 10118 } // namespace dart |
| OLD | NEW |