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 "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 4902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4913 if (!exception_param.type->IsDynamicType()) { // Has a type specification. | 4913 if (!exception_param.type->IsDynamicType()) { // Has a type specification. |
| 4914 // Now form an 'if type check' as an exception type exists in | 4914 // Now form an 'if type check' as an exception type exists in |
| 4915 // the catch specifier. | 4915 // the catch specifier. |
| 4916 if (!exception_param.type->IsInstantiated() && | 4916 if (!exception_param.type->IsInstantiated() && |
| 4917 (current_block_->scope->function_level() > 0)) { | 4917 (current_block_->scope->function_level() > 0)) { |
| 4918 // Make sure that the instantiator is captured. | 4918 // Make sure that the instantiator is captured. |
| 4919 CaptureReceiver(); | 4919 CaptureReceiver(); |
| 4920 } | 4920 } |
| 4921 AstNode* exception_type = new TypeNode(catch_pos, *exception_param.type); | 4921 AstNode* exception_type = new TypeNode(catch_pos, *exception_param.type); |
| 4922 AstNode* exception_var = new LoadLocalNode(catch_pos, *catch_excp_var); | 4922 AstNode* exception_var = new LoadLocalNode(catch_pos, *catch_excp_var); |
| 4923 AstNode* cond_expr = new ComparisonNode( | 4923 // Null is also allowed. |
| 4924 AstNode* null_literal = | |
| 4925 new LiteralNode(catch_pos, Instance::ZoneHandle(Instance::null())); | |
| 4926 AstNode* null_cond_expr = new ComparisonNode( | |
| 4927 catch_pos, Token::kEQ_STRICT, exception_var, null_literal); | |
| 4928 AstNode* type_cond_expr = new ComparisonNode( | |
| 4924 catch_pos, Token::kIS, exception_var, exception_type); | 4929 catch_pos, Token::kIS, exception_var, exception_type); |
| 4930 AstNode* or_node = new BinaryOpNode( | |
| 4931 catch_pos, Token::kOR, null_cond_expr, type_cond_expr); | |
|
hausner
2012/02/21 21:46:41
As discussed offline, this compare has to be done
srdjan
2012/02/21 21:53:52
Done.
| |
| 4925 current_block_->statements->Add( | 4932 current_block_->statements->Add( |
| 4926 new IfNode(catch_pos, cond_expr, catch_handler, NULL)); | 4933 new IfNode(catch_pos, or_node, catch_handler, NULL)); |
| 4927 } else { | 4934 } else { |
| 4928 // No exception type exists in the catch specifier so execute the | 4935 // No exception type exists in the catch specifier so execute the |
| 4929 // catch handler code unconditionally. | 4936 // catch handler code unconditionally. |
| 4930 current_block_->statements->Add(catch_handler); | 4937 current_block_->statements->Add(catch_handler); |
| 4931 generic_catch_seen = true; | 4938 generic_catch_seen = true; |
| 4932 } | 4939 } |
| 4933 catch_clause = CloseBlock(); | 4940 catch_clause = CloseBlock(); |
| 4934 | 4941 |
| 4935 // Add this individual catch handler to the catch handlers list. | 4942 // Add this individual catch handler to the catch handlers list. |
| 4936 current_block_->statements->Add(catch_clause); | 4943 current_block_->statements->Add(catch_clause); |
| (...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7847 void Parser::SkipQualIdent() { | 7854 void Parser::SkipQualIdent() { |
| 7848 ASSERT(IsIdentifier()); | 7855 ASSERT(IsIdentifier()); |
| 7849 ConsumeToken(); | 7856 ConsumeToken(); |
| 7850 if (CurrentToken() == Token::kPERIOD) { | 7857 if (CurrentToken() == Token::kPERIOD) { |
| 7851 ConsumeToken(); // Consume the kPERIOD token. | 7858 ConsumeToken(); // Consume the kPERIOD token. |
| 7852 ExpectIdentifier("identifier expected after '.'"); | 7859 ExpectIdentifier("identifier expected after '.'"); |
| 7853 } | 7860 } |
| 7854 } | 7861 } |
| 7855 | 7862 |
| 7856 } // namespace dart | 7863 } // namespace dart |
| OLD | NEW |