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; |
805 default: | 808 default: |
806 UNREACHABLE(); | 809 UNREACHABLE(); |
807 } | 810 } |
808 | 811 |
809 if (!HasReturnNode(node_sequence)) { | 812 if (!HasReturnNode(node_sequence)) { |
810 // Add implicit return node. | 813 // Add implicit return node. |
811 node_sequence->Add(new ReturnNode(func.end_token_pos())); | 814 node_sequence->Add(new ReturnNode(func.end_token_pos())); |
812 } | 815 } |
813 if (parsed_function->has_expression_temp_var()) { | 816 if (parsed_function->has_expression_temp_var()) { |
814 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); | 817 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 Function::ZoneHandle(func.extracted_method_closure()), | 1130 Function::ZoneHandle(func.extracted_method_closure()), |
1128 load_receiver, | 1131 load_receiver, |
1129 NULL); | 1132 NULL); |
1130 | 1133 |
1131 ReturnNode* return_node = new ReturnNode(ident_pos, closure); | 1134 ReturnNode* return_node = new ReturnNode(ident_pos, closure); |
1132 current_block_->statements->Add(return_node); | 1135 current_block_->statements->Add(return_node); |
1133 return CloseBlock(); | 1136 return CloseBlock(); |
1134 } | 1137 } |
1135 | 1138 |
1136 | 1139 |
| 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 |
1137 void Parser::SkipBlock() { | 1180 void Parser::SkipBlock() { |
1138 ASSERT(CurrentToken() == Token::kLBRACE); | 1181 ASSERT(CurrentToken() == Token::kLBRACE); |
1139 GrowableArray<Token::Kind> token_stack(8); | 1182 GrowableArray<Token::Kind> token_stack(8); |
1140 const intptr_t block_start_pos = TokenPos(); | 1183 const intptr_t block_start_pos = TokenPos(); |
1141 bool is_match = true; | 1184 bool is_match = true; |
1142 bool unexpected_token_found = false; | 1185 bool unexpected_token_found = false; |
1143 Token::Kind token; | 1186 Token::Kind token; |
1144 intptr_t token_pos; | 1187 intptr_t token_pos; |
1145 do { | 1188 do { |
1146 token = CurrentToken(); | 1189 token = CurrentToken(); |
(...skipping 8962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10109 void Parser::SkipQualIdent() { | 10152 void Parser::SkipQualIdent() { |
10110 ASSERT(IsIdentifier()); | 10153 ASSERT(IsIdentifier()); |
10111 ConsumeToken(); | 10154 ConsumeToken(); |
10112 if (CurrentToken() == Token::kPERIOD) { | 10155 if (CurrentToken() == Token::kPERIOD) { |
10113 ConsumeToken(); // Consume the kPERIOD token. | 10156 ConsumeToken(); // Consume the kPERIOD token. |
10114 ExpectIdentifier("identifier expected after '.'"); | 10157 ExpectIdentifier("identifier expected after '.'"); |
10115 } | 10158 } |
10116 } | 10159 } |
10117 | 10160 |
10118 } // namespace dart | 10161 } // namespace dart |
OLD | NEW |