Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: runtime/vm/parser.cc

Issue 10392016: Fix issue 2939, revert previous change that accepted null as excpetion objects: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 5154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5165 // Now create a label for the end of catch block processing so that we can 5165 // Now create a label for the end of catch block processing so that we can
5166 // jump over the catch block code after executing the try block. 5166 // jump over the catch block code after executing the try block.
5167 SourceLabel* end_catch_label = 5167 SourceLabel* end_catch_label =
5168 SourceLabel::New(token_index_, NULL, SourceLabel::kCatch); 5168 SourceLabel::New(token_index_, NULL, SourceLabel::kCatch);
5169 5169
5170 // Now parse the 'catch' blocks if any and merge all of them into 5170 // Now parse the 'catch' blocks if any and merge all of them into
5171 // an if-then sequence of the different types specified using the 'is' 5171 // an if-then sequence of the different types specified using the 'is'
5172 // operator. 5172 // operator.
5173 bool catch_seen = false; 5173 bool catch_seen = false;
5174 bool generic_catch_seen = false; 5174 bool generic_catch_seen = false;
5175 intptr_t catch_clause_count = 0;
5176 SequenceNode* catch_handler_list = NULL; 5175 SequenceNode* catch_handler_list = NULL;
5177 const intptr_t handler_pos = token_index_; 5176 const intptr_t handler_pos = token_index_;
5178 OpenBlock(); // Start the catch block sequence. 5177 OpenBlock(); // Start the catch block sequence.
5179 current_block_->scope->AddLabel(end_catch_label); 5178 current_block_->scope->AddLabel(end_catch_label);
5180 while (CurrentToken() == Token::kCATCH) { 5179 while (CurrentToken() == Token::kCATCH) {
5181 catch_clause_count++;
5182 catch_seen = true; 5180 catch_seen = true;
5183 const intptr_t catch_pos = token_index_; 5181 const intptr_t catch_pos = token_index_;
5184 ConsumeToken(); // Consume the 'catch'. 5182 ConsumeToken(); // Consume the 'catch'.
5185 ExpectToken(Token::kLPAREN); 5183 ExpectToken(Token::kLPAREN);
5186 CatchParamDesc exception_param; 5184 CatchParamDesc exception_param;
5187 CatchParamDesc stack_trace_param; 5185 CatchParamDesc stack_trace_param;
5188 ParseCatchParameter(&exception_param); 5186 ParseCatchParameter(&exception_param);
5189 if (CurrentToken() == Token::kCOMMA) { 5187 if (CurrentToken() == Token::kCOMMA) {
5190 ConsumeToken(); 5188 ConsumeToken();
5191 ParseCatchParameter(&stack_trace_param); 5189 ParseCatchParameter(&stack_trace_param);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5244 // the catch specifier. 5242 // the catch specifier.
5245 if (!exception_param.type->IsInstantiated() && 5243 if (!exception_param.type->IsInstantiated() &&
5246 (current_block_->scope->function_level() > 0)) { 5244 (current_block_->scope->function_level() > 0)) {
5247 // Make sure that the instantiator is captured. 5245 // Make sure that the instantiator is captured.
5248 CaptureReceiver(); 5246 CaptureReceiver();
5249 } 5247 }
5250 AstNode* exception_type = new TypeNode(catch_pos, *exception_param.type); 5248 AstNode* exception_type = new TypeNode(catch_pos, *exception_param.type);
5251 AstNode* exception_var = new LoadLocalNode(catch_pos, *catch_excp_var); 5249 AstNode* exception_var = new LoadLocalNode(catch_pos, *catch_excp_var);
5252 AstNode* type_cond_expr = new ComparisonNode( 5250 AstNode* type_cond_expr = new ComparisonNode(
5253 catch_pos, Token::kIS, exception_var, exception_type); 5251 catch_pos, Token::kIS, exception_var, exception_type);
5254 if (catch_clause_count == 1) { 5252 current_block_->statements->Add(
5255 // Null is also allowed, but check only in the first clause. 5253 new IfNode(catch_pos, type_cond_expr, catch_handler, NULL));
5256 AstNode* null_literal =
5257 new LiteralNode(catch_pos, Instance::ZoneHandle(Instance::null()));
5258 AstNode* null_cond_expr = new ComparisonNode(
5259 catch_pos, Token::kEQ_STRICT, exception_var, null_literal);
5260 AstNode* or_node = new BinaryOpNode(
5261 catch_pos, Token::kOR, null_cond_expr, type_cond_expr);
5262 current_block_->statements->Add(
5263 new IfNode(catch_pos, or_node, catch_handler, NULL));
5264 } else {
5265 current_block_->statements->Add(
5266 new IfNode(catch_pos, type_cond_expr, catch_handler, NULL));
5267 }
5268 } else { 5254 } else {
5269 // No exception type exists in the catch specifier so execute the 5255 // No exception type exists in the catch specifier so execute the
5270 // catch handler code unconditionally. 5256 // catch handler code unconditionally.
5271 current_block_->statements->Add(catch_handler); 5257 current_block_->statements->Add(catch_handler);
5272 generic_catch_seen = true; 5258 generic_catch_seen = true;
5273 } 5259 }
5274 catch_clause = CloseBlock(); 5260 catch_clause = CloseBlock();
5275 5261
5276 // Add this individual catch handler to the catch handlers list. 5262 // Add this individual catch handler to the catch handlers list.
5277 current_block_->statements->Add(catch_clause); 5263 current_block_->statements->Add(catch_clause);
(...skipping 3156 matching lines...) Expand 10 before | Expand all | Expand 10 after
8434 void Parser::SkipQualIdent() { 8420 void Parser::SkipQualIdent() {
8435 ASSERT(IsIdentifier()); 8421 ASSERT(IsIdentifier());
8436 ConsumeToken(); 8422 ConsumeToken();
8437 if (CurrentToken() == Token::kPERIOD) { 8423 if (CurrentToken() == Token::kPERIOD) {
8438 ConsumeToken(); // Consume the kPERIOD token. 8424 ConsumeToken(); // Consume the kPERIOD token.
8439 ExpectIdentifier("identifier expected after '.'"); 8425 ExpectIdentifier("identifier expected after '.'");
8440 } 8426 }
8441 } 8427 }
8442 8428
8443 } // namespace dart 8429 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698