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

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

Issue 23445012: Mark exception handlers if they have a stacktrace specified. Do not build a stacktrace if the handl… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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
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 "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 6536 matching lines...) Expand 10 before | Expand all | Expand 10 after
6547 // an if-then sequence of the different types specified using the 'is' 6547 // an if-then sequence of the different types specified using the 'is'
6548 // operator. 6548 // operator.
6549 bool catch_seen = false; 6549 bool catch_seen = false;
6550 bool generic_catch_seen = false; 6550 bool generic_catch_seen = false;
6551 SequenceNode* catch_handler_list = NULL; 6551 SequenceNode* catch_handler_list = NULL;
6552 const intptr_t handler_pos = TokenPos(); 6552 const intptr_t handler_pos = TokenPos();
6553 OpenBlock(); // Start the catch block sequence. 6553 OpenBlock(); // Start the catch block sequence.
6554 current_block_->scope->AddLabel(end_catch_label); 6554 current_block_->scope->AddLabel(end_catch_label);
6555 const GrowableObjectArray& handler_types = 6555 const GrowableObjectArray& handler_types =
6556 GrowableObjectArray::Handle(GrowableObjectArray::New()); 6556 GrowableObjectArray::Handle(GrowableObjectArray::New());
6557 bool needs_stacktrace = false;
6557 while ((CurrentToken() == Token::kCATCH) || IsLiteral("on")) { 6558 while ((CurrentToken() == Token::kCATCH) || IsLiteral("on")) {
6558 const intptr_t catch_pos = TokenPos(); 6559 const intptr_t catch_pos = TokenPos();
6559 CatchParamDesc exception_param; 6560 CatchParamDesc exception_param;
6560 CatchParamDesc stack_trace_param; 6561 CatchParamDesc stack_trace_param;
6561 catch_seen = true; 6562 catch_seen = true;
6562 if (IsLiteral("on")) { 6563 if (IsLiteral("on")) {
6563 ConsumeToken(); 6564 ConsumeToken();
6564 exception_param.type = &AbstractType::ZoneHandle( 6565 exception_param.type = &AbstractType::ZoneHandle(
6565 ParseType(ClassFinalizer::kCanonicalize)); 6566 ParseType(ClassFinalizer::kCanonicalize));
6566 } else { 6567 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6607 ASSERT(var != NULL); 6608 ASSERT(var != NULL);
6608 ASSERT(catch_excp_var != NULL); 6609 ASSERT(catch_excp_var != NULL);
6609 current_block_->statements->Add( 6610 current_block_->statements->Add(
6610 new StoreLocalNode(catch_pos, var, 6611 new StoreLocalNode(catch_pos, var,
6611 new LoadLocalNode(catch_pos, catch_excp_var))); 6612 new LoadLocalNode(catch_pos, catch_excp_var)));
6612 } 6613 }
6613 if (stack_trace_param.var != NULL) { 6614 if (stack_trace_param.var != NULL) {
6614 // A stack trace variable is specified in this block, so generate code 6615 // A stack trace variable is specified in this block, so generate code
6615 // to load the stack trace object (:stacktrace_var) into the stack trace 6616 // to load the stack trace object (:stacktrace_var) into the stack trace
6616 // variable specified in this block. 6617 // variable specified in this block.
6618 needs_stacktrace = true;
6617 ArgumentListNode* no_args = new ArgumentListNode(catch_pos); 6619 ArgumentListNode* no_args = new ArgumentListNode(catch_pos);
6618 LocalVariable* trace = LookupLocalScope(*stack_trace_param.var); 6620 LocalVariable* trace = LookupLocalScope(*stack_trace_param.var);
6619 ASSERT(catch_trace_var != NULL); 6621 ASSERT(catch_trace_var != NULL);
6620 current_block_->statements->Add( 6622 current_block_->statements->Add(
6621 new StoreLocalNode(catch_pos, trace, 6623 new StoreLocalNode(catch_pos, trace,
6622 new LoadLocalNode(catch_pos, catch_trace_var))); 6624 new LoadLocalNode(catch_pos, catch_trace_var)));
6623 current_block_->statements->Add( 6625 current_block_->statements->Add(
6624 new InstanceCallNode( 6626 new InstanceCallNode(
6625 catch_pos, 6627 catch_pos,
6626 new LoadLocalNode(catch_pos, trace), 6628 new LoadLocalNode(catch_pos, trace),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6723 } 6725 }
6724 CatchClauseNode* catch_block = 6726 CatchClauseNode* catch_block =
6725 new CatchClauseNode(handler_pos, 6727 new CatchClauseNode(handler_pos,
6726 catch_handler_list, 6728 catch_handler_list,
6727 Array::ZoneHandle(Array::MakeArray(handler_types)), 6729 Array::ZoneHandle(Array::MakeArray(handler_types)),
6728 context_var, 6730 context_var,
6729 catch_excp_var, 6731 catch_excp_var,
6730 catch_trace_var, 6732 catch_trace_var,
6731 (finally_block != NULL) 6733 (finally_block != NULL)
6732 ? AllocateTryIndex() 6734 ? AllocateTryIndex()
6733 : CatchClauseNode::kInvalidTryIndex); 6735 : CatchClauseNode::kInvalidTryIndex,
6736 needs_stacktrace);
6734 6737
6735 // Now create the try/catch ast node and return it. If there is a label 6738 // Now create the try/catch ast node and return it. If there is a label
6736 // on the try/catch, close the block that's embedding the try statement 6739 // on the try/catch, close the block that's embedding the try statement
6737 // and attach the label to it. 6740 // and attach the label to it.
6738 AstNode* try_catch_node = 6741 AstNode* try_catch_node =
6739 new TryCatchNode(try_pos, try_block, end_catch_label, 6742 new TryCatchNode(try_pos, try_block, end_catch_label,
6740 context_var, catch_block, finally_block, try_index); 6743 context_var, catch_block, finally_block, try_index);
6741 6744
6742 if (try_label != NULL) { 6745 if (try_label != NULL) {
6743 current_block_->statements->Add(try_catch_node); 6746 current_block_->statements->Add(try_catch_node);
(...skipping 3722 matching lines...) Expand 10 before | Expand all | Expand 10 after
10466 void Parser::SkipQualIdent() { 10469 void Parser::SkipQualIdent() {
10467 ASSERT(IsIdentifier()); 10470 ASSERT(IsIdentifier());
10468 ConsumeToken(); 10471 ConsumeToken();
10469 if (CurrentToken() == Token::kPERIOD) { 10472 if (CurrentToken() == Token::kPERIOD) {
10470 ConsumeToken(); // Consume the kPERIOD token. 10473 ConsumeToken(); // Consume the kPERIOD token.
10471 ExpectIdentifier("identifier expected after '.'"); 10474 ExpectIdentifier("identifier expected after '.'");
10472 } 10475 }
10473 } 10476 }
10474 10477
10475 } // namespace dart 10478 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698