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

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

Issue 2655803007: Expand _AssertionError._evaluateAssertion in the frontend (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 9231 matching lines...) Expand 10 before | Expand all | Expand 10 after
9242 message = ParseExpr(kAllowConst, kConsumeCascades); 9242 message = ParseExpr(kAllowConst, kConsumeCascades);
9243 if (is_const && !message->IsPotentiallyConst()) { 9243 if (is_const && !message->IsPotentiallyConst()) {
9244 ReportError( 9244 ReportError(
9245 message_pos, 9245 message_pos,
9246 "initializer assert expression must be compile time constant."); 9246 "initializer assert expression must be compile time constant.");
9247 } 9247 }
9248 } 9248 }
9249 ExpectToken(Token::kRPAREN); 9249 ExpectToken(Token::kRPAREN);
9250 9250
9251 if (!is_const) { 9251 if (!is_const) {
9252 // Check for assertion condition being a function if not const. 9252 LetNode* condition_or_condition_after_invoke =
hausner 2017/01/26 20:41:13 Maybe add a comment here to document the code that
Cutch 2017/02/01 17:15:35 Done.
9253 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); 9253 new (Z) LetNode(condition_pos);
9254 arguments->Add(condition); 9254 LocalVariable* assert_temp_var =
9255 condition = MakeStaticCall( 9255 condition_or_condition_after_invoke->AddInitializer(condition);
9256 Symbols::AssertionError(), 9256
9257 Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments); 9257 // Function type.
hausner 2017/01/26 20:41:13 The EvaluateAssertion function is now probably dea
Cutch 2017/02/01 17:15:35 I've changed the code to not always inline the cod
9258 const Instance& function_type =
9259 Instance::ZoneHandle(Z, Type::DartFunctionType());
9260 ASSERT(!function_type.IsNull());
9261 ASSERT(AbstractType::Cast(function_type).IsDartFunctionType());
9262
9263 // condition is Function.
9264 ComparisonNode* function_comparison_node = new (Z) ComparisonNode(
9265 condition_pos, Token::kIS,
9266 new (Z) LoadLocalNode(condition_pos, assert_temp_var),
9267 new (Z) TypeNode(condition_pos, AbstractType::Cast(function_type)));
9268
9269 // condition()
9270 InstanceCallNode* invoke_condition = new (Z) InstanceCallNode(
9271 condition_pos, new (Z) LoadLocalNode(condition_pos, assert_temp_var),
9272 Symbols::Call(), new (Z) ArgumentListNode(condition_pos));
9273
9274 ConditionalExprNode* conditional_condition = new (Z) ConditionalExprNode(
9275 condition_pos, function_comparison_node, invoke_condition,
9276 new (Z) LoadLocalNode(condition_pos, assert_temp_var));
9277 condition_or_condition_after_invoke->AddNode(conditional_condition);
9278
9279 condition = condition_or_condition_after_invoke;
9258 } 9280 }
9281
9259 AstNode* not_condition = 9282 AstNode* not_condition =
9260 new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition); 9283 new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition);
9261 9284
9262 // Build call to _AsertionError._throwNew(start, end, message) 9285 // Build call to _AsertionError._throwNew(start, end, message)
9263 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); 9286 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos);
9264 arguments->Add(new (Z) LiteralNode( 9287 arguments->Add(new (Z) LiteralNode(
9265 condition_pos, 9288 condition_pos,
9266 Integer::ZoneHandle(Z, Integer::New(condition_pos.Pos())))); 9289 Integer::ZoneHandle(Z, Integer::New(condition_pos.Pos()))));
9267 arguments->Add(new (Z) LiteralNode( 9290 arguments->Add(new (Z) LiteralNode(
9268 condition_end, 9291 condition_end,
(...skipping 5413 matching lines...) Expand 10 before | Expand all | Expand 10 after
14682 const ArgumentListNode& function_args, 14705 const ArgumentListNode& function_args,
14683 const LocalVariable* temp_for_last_arg, 14706 const LocalVariable* temp_for_last_arg,
14684 bool is_super_invocation) { 14707 bool is_super_invocation) {
14685 UNREACHABLE(); 14708 UNREACHABLE();
14686 return NULL; 14709 return NULL;
14687 } 14710 }
14688 14711
14689 } // namespace dart 14712 } // namespace dart
14690 14713
14691 #endif // DART_PRECOMPILED_RUNTIME 14714 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698