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 9157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9168 const Function& func = Function::ZoneHandle(Z, | 9168 const Function& func = Function::ZoneHandle(Z, |
9169 Resolver::ResolveStatic(cls, | 9169 Resolver::ResolveStatic(cls, |
9170 func_name, | 9170 func_name, |
9171 arguments->length(), | 9171 arguments->length(), |
9172 arguments->names())); | 9172 arguments->names())); |
9173 ASSERT(!func.IsNull()); | 9173 ASSERT(!func.IsNull()); |
9174 return new(Z) StaticCallNode(arguments->token_pos(), func, arguments); | 9174 return new(Z) StaticCallNode(arguments->token_pos(), func, arguments); |
9175 } | 9175 } |
9176 | 9176 |
9177 | 9177 |
9178 AstNode* Parser::MakeAssertCall(TokenPosition begin, TokenPosition end) { | |
9179 ArgumentListNode* arguments = new(Z) ArgumentListNode(begin); | |
9180 arguments->Add(new(Z) LiteralNode(begin, | |
9181 Integer::ZoneHandle(Z, Integer::New(begin.value(), Heap::kOld)))); | |
9182 arguments->Add(new(Z) LiteralNode(end, | |
9183 Integer::ZoneHandle(Z, Integer::New(end.value(), Heap::kOld)))); | |
9184 return MakeStaticCall(Symbols::AssertionError(), | |
9185 Library::PrivateCoreLibName(Symbols::ThrowNew()), | |
9186 arguments); | |
9187 } | |
9188 | |
9189 | |
9190 AstNode* Parser::HandleAssertCondition(AstNode* condition) { | |
9191 const TokenPosition pos = condition->token_pos(); | |
9192 ArgumentListNode* arguments = new(Z) ArgumentListNode(pos); | |
9193 arguments->Add(condition); | |
9194 return MakeStaticCall(Symbols::AssertionError(), | |
9195 Library::PrivateCoreLibName(Symbols::HandleCondition()), | |
9196 arguments); | |
9197 } | |
9198 | |
9199 | |
9200 AstNode* Parser::ParseAssertStatement() { | 9178 AstNode* Parser::ParseAssertStatement() { |
9201 TRACE_PARSER("ParseAssertStatement"); | 9179 TRACE_PARSER("ParseAssertStatement"); |
9202 ConsumeToken(); // Consume assert keyword. | 9180 ConsumeToken(); // Consume assert keyword. |
9203 ExpectToken(Token::kLPAREN); | 9181 ExpectToken(Token::kLPAREN); |
9204 const TokenPosition condition_pos = TokenPos(); | 9182 const TokenPosition condition_pos = TokenPos(); |
9205 if (!I->asserts()) { | 9183 if (!I->asserts()) { |
9206 SkipExpr(); | 9184 SkipExpr(); |
9207 ExpectToken(Token::kRPAREN); | 9185 ExpectToken(Token::kRPAREN); |
9208 return NULL; | 9186 return NULL; |
9209 } | 9187 } |
9210 AstNode* condition = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); | 9188 AstNode* condition = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
9211 const TokenPosition condition_end = TokenPos(); | 9189 const TokenPosition condition_end = TokenPos(); |
9212 ExpectToken(Token::kRPAREN); | 9190 ExpectToken(Token::kRPAREN); |
9213 condition = HandleAssertCondition(condition); | 9191 |
9214 condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition); | 9192 ArgumentListNode* arguments = new(Z) ArgumentListNode(condition_pos); |
9215 AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); | 9193 arguments->Add(condition); |
9216 return new(Z) IfNode( | 9194 arguments->Add(new(Z) LiteralNode(condition_pos, |
9217 condition_pos, | 9195 Integer::ZoneHandle(Z, Integer::New(condition_pos.value(), Heap::kOld)))); |
9218 condition, | 9196 arguments->Add(new(Z) LiteralNode(condition_end, |
9219 NodeAsSequenceNode(condition_pos, assert_throw, NULL), | 9197 Integer::ZoneHandle(Z, Integer::New(condition_end.value(), Heap::kOld)))); |
9220 NULL); | 9198 return MakeStaticCall(Symbols::AssertionError(), |
| 9199 Library::PrivateCoreLibName(Symbols::CheckAssertion()), |
| 9200 arguments); |
9221 } | 9201 } |
9222 | 9202 |
9223 | 9203 |
9224 // Populate local scope of the catch block with the catch parameters. | 9204 // Populate local scope of the catch block with the catch parameters. |
9225 void Parser::AddCatchParamsToScope(CatchParamDesc* exception_param, | 9205 void Parser::AddCatchParamsToScope(CatchParamDesc* exception_param, |
9226 CatchParamDesc* stack_trace_param, | 9206 CatchParamDesc* stack_trace_param, |
9227 LocalScope* scope) { | 9207 LocalScope* scope) { |
9228 if (exception_param->name != NULL) { | 9208 if (exception_param->name != NULL) { |
9229 LocalVariable* var = new(Z) LocalVariable( | 9209 LocalVariable* var = new(Z) LocalVariable( |
9230 exception_param->token_pos, | 9210 exception_param->token_pos, |
(...skipping 5391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14622 const ArgumentListNode& function_args, | 14602 const ArgumentListNode& function_args, |
14623 const LocalVariable* temp_for_last_arg, | 14603 const LocalVariable* temp_for_last_arg, |
14624 bool is_super_invocation) { | 14604 bool is_super_invocation) { |
14625 UNREACHABLE(); | 14605 UNREACHABLE(); |
14626 return NULL; | 14606 return NULL; |
14627 } | 14607 } |
14628 | 14608 |
14629 } // namespace dart | 14609 } // namespace dart |
14630 | 14610 |
14631 #endif // DART_PRECOMPILED_RUNTIME | 14611 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |