| 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 9231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |