Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index e75d86d82291669b6fd6f85271c8a1f9288e38b4..5455712afe83d1513e4dc25bcaad1724c240f5b6 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -9249,13 +9249,36 @@ AstNode* Parser::ParseAssertStatement(bool is_const) { |
| ExpectToken(Token::kRPAREN); |
| if (!is_const) { |
| - // Check for assertion condition being a function if not const. |
| - ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos); |
| - arguments->Add(condition); |
| - condition = MakeStaticCall( |
| - Symbols::AssertionError(), |
| - Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments); |
|
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
|
| + 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.
|
| + new (Z) LetNode(condition_pos); |
| + LocalVariable* assert_temp_var = |
| + condition_or_condition_after_invoke->AddInitializer(condition); |
| + |
| + // Function type. |
| + const Instance& function_type = |
| + Instance::ZoneHandle(Z, Type::DartFunctionType()); |
| + ASSERT(!function_type.IsNull()); |
| + ASSERT(AbstractType::Cast(function_type).IsDartFunctionType()); |
| + |
| + // condition is Function. |
| + ComparisonNode* function_comparison_node = new (Z) ComparisonNode( |
| + condition_pos, Token::kIS, |
| + new (Z) LoadLocalNode(condition_pos, assert_temp_var), |
| + new (Z) TypeNode(condition_pos, AbstractType::Cast(function_type))); |
| + |
| + // condition() |
| + InstanceCallNode* invoke_condition = new (Z) InstanceCallNode( |
| + condition_pos, new (Z) LoadLocalNode(condition_pos, assert_temp_var), |
| + Symbols::Call(), new (Z) ArgumentListNode(condition_pos)); |
| + |
| + ConditionalExprNode* conditional_condition = new (Z) ConditionalExprNode( |
| + condition_pos, function_comparison_node, invoke_condition, |
| + new (Z) LoadLocalNode(condition_pos, assert_temp_var)); |
| + condition_or_condition_after_invoke->AddNode(conditional_condition); |
| + |
| + condition = condition_or_condition_after_invoke; |
| } |
| + |
| AstNode* not_condition = |
| new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition); |