| 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 #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 9423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9434 message = ParseExpr(kAllowConst, kConsumeCascades); | 9434 message = ParseExpr(kAllowConst, kConsumeCascades); |
| 9435 if (is_const && !message->IsPotentiallyConst()) { | 9435 if (is_const && !message->IsPotentiallyConst()) { |
| 9436 ReportError( | 9436 ReportError( |
| 9437 message_pos, | 9437 message_pos, |
| 9438 "initializer assert expression must be compile time constant."); | 9438 "initializer assert expression must be compile time constant."); |
| 9439 } | 9439 } |
| 9440 } | 9440 } |
| 9441 ExpectToken(Token::kRPAREN); | 9441 ExpectToken(Token::kRPAREN); |
| 9442 | 9442 |
| 9443 if (!is_const) { | 9443 if (!is_const) { |
| 9444 if (condition->IsClosureNode()) { | 9444 // Check for assertion condition being a function if not const. |
| 9445 // We always have to invoke a closure node. | 9445 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); |
| 9446 InstanceCallNode* invoke_condition = | 9446 arguments->Add(condition); |
| 9447 new (Z) InstanceCallNode(condition_pos, condition, Symbols::Call(), | 9447 condition = MakeStaticCall( |
| 9448 new (Z) ArgumentListNode(condition_pos)); | 9448 Symbols::AssertionError(), |
| 9449 condition = invoke_condition; | 9449 Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments); |
| 9450 } else if (condition->IsComparisonNode() || condition->IsUnaryOpNode()) { | |
| 9451 // Cannot be a function, skip type test and invocation. | |
| 9452 } else { | |
| 9453 // Check for assertion condition being a function if not const. | |
| 9454 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); | |
| 9455 arguments->Add(condition); | |
| 9456 condition = MakeStaticCall( | |
| 9457 Symbols::AssertionError(), | |
| 9458 Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments); | |
| 9459 } | |
| 9460 } | 9450 } |
| 9461 | |
| 9462 AstNode* not_condition = | 9451 AstNode* not_condition = |
| 9463 new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition); | 9452 new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition); |
| 9464 | 9453 |
| 9465 // Build call to _AsertionError._throwNew(start, end, message) | 9454 // Build call to _AsertionError._throwNew(start, end, message) |
| 9466 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); | 9455 ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); |
| 9467 arguments->Add(new (Z) LiteralNode( | 9456 arguments->Add(new (Z) LiteralNode( |
| 9468 condition_pos, | 9457 condition_pos, |
| 9469 Integer::ZoneHandle(Z, Integer::New(condition_pos.Pos())))); | 9458 Integer::ZoneHandle(Z, Integer::New(condition_pos.Pos())))); |
| 9470 arguments->Add(new (Z) LiteralNode( | 9459 arguments->Add(new (Z) LiteralNode( |
| 9471 condition_end, | 9460 condition_end, |
| (...skipping 5575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15047 const ArgumentListNode& function_args, | 15036 const ArgumentListNode& function_args, |
| 15048 const LocalVariable* temp_for_last_arg, | 15037 const LocalVariable* temp_for_last_arg, |
| 15049 bool is_super_invocation) { | 15038 bool is_super_invocation) { |
| 15050 UNREACHABLE(); | 15039 UNREACHABLE(); |
| 15051 return NULL; | 15040 return NULL; |
| 15052 } | 15041 } |
| 15053 | 15042 |
| 15054 } // namespace dart | 15043 } // namespace dart |
| 15055 | 15044 |
| 15056 #endif // DART_PRECOMPILED_RUNTIME | 15045 #endif // DART_PRECOMPILED_RUNTIME |
| OLD | NEW |