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

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

Issue 2655803007: Expand _AssertionError._evaluateAssertion in the frontend (Closed)
Patch Set: special cases + old slow path 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 if (condition->IsClosureNode()) {
9253 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); 9253 // We always have to invoke a closure node.
9254 arguments->Add(condition); 9254 InstanceCallNode* invoke_condition =
9255 condition = MakeStaticCall( 9255 new (Z) InstanceCallNode(condition_pos, condition, Symbols::Call(),
9256 Symbols::AssertionError(), 9256 new (Z) ArgumentListNode(condition_pos));
9257 Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments); 9257 condition = invoke_condition;
9258 } else if (condition->IsComparisonNode() || condition->IsUnaryOpNode()) {
9259 // Cannot be a function, skip type test and invocation.
9260 } else {
9261 // Check for assertion condition being a function if not const.
9262 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos);
9263 arguments->Add(condition);
9264 condition = MakeStaticCall(
9265 Symbols::AssertionError(),
9266 Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments);
9267 }
9258 } 9268 }
9269
9259 AstNode* not_condition = 9270 AstNode* not_condition =
9260 new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition); 9271 new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition);
9261 9272
9262 // Build call to _AsertionError._throwNew(start, end, message) 9273 // Build call to _AsertionError._throwNew(start, end, message)
9263 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); 9274 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos);
9264 arguments->Add(new (Z) LiteralNode( 9275 arguments->Add(new (Z) LiteralNode(
9265 condition_pos, 9276 condition_pos,
9266 Integer::ZoneHandle(Z, Integer::New(condition_pos.Pos())))); 9277 Integer::ZoneHandle(Z, Integer::New(condition_pos.Pos()))));
9267 arguments->Add(new (Z) LiteralNode( 9278 arguments->Add(new (Z) LiteralNode(
9268 condition_end, 9279 condition_end,
(...skipping 5413 matching lines...) Expand 10 before | Expand all | Expand 10 after
14682 const ArgumentListNode& function_args, 14693 const ArgumentListNode& function_args,
14683 const LocalVariable* temp_for_last_arg, 14694 const LocalVariable* temp_for_last_arg,
14684 bool is_super_invocation) { 14695 bool is_super_invocation) {
14685 UNREACHABLE(); 14696 UNREACHABLE();
14686 return NULL; 14697 return NULL;
14687 } 14698 }
14688 14699
14689 } // namespace dart 14700 } // namespace dart
14690 14701
14691 #endif // DART_PRECOMPILED_RUNTIME 14702 #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