| 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 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\"."); | 40 DEFINE_FLAG(bool, enable_debug_break, false, "Allow use of break \"message\"."); |
| 41 DEFINE_FLAG(bool, load_deferred_eagerly, false, | 41 DEFINE_FLAG(bool, load_deferred_eagerly, false, |
| 42 "Load deferred libraries eagerly."); | 42 "Load deferred libraries eagerly."); |
| 43 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 43 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| 44 DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef."); | 44 DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef."); |
| 45 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); | 45 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); |
| 46 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | 46 DECLARE_FLAG(bool, warn_on_javascript_compatibility); |
| 47 DEFINE_FLAG(bool, enable_mirrors, true, | 47 DEFINE_FLAG(bool, enable_mirrors, true, |
| 48 "Disable to make importing dart:mirrors an error."); | 48 "Disable to make importing dart:mirrors an error."); |
| 49 DECLARE_FLAG(bool, lazy_dispatchers); |
| 49 | 50 |
| 50 // Quick access to the current isolate and zone. | 51 // Quick access to the current isolate and zone. |
| 51 #define I (isolate()) | 52 #define I (isolate()) |
| 52 #define Z (zone()) | 53 #define Z (zone()) |
| 53 | 54 |
| 54 | 55 |
| 55 #if defined(DEBUG) | 56 #if defined(DEBUG) |
| 56 class TraceParser : public ValueObject { | 57 class TraceParser : public ValueObject { |
| 57 public: | 58 public: |
| 58 TraceParser(intptr_t token_pos, | 59 TraceParser(intptr_t token_pos, |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 } | 1324 } |
| 1324 StaticCallNode* call = new StaticCallNode(token_pos, parent, func_args); | 1325 StaticCallNode* call = new StaticCallNode(token_pos, parent, func_args); |
| 1325 ReturnNode* return_node = new ReturnNode(token_pos, call); | 1326 ReturnNode* return_node = new ReturnNode(token_pos, call); |
| 1326 current_block_->statements->Add(return_node); | 1327 current_block_->statements->Add(return_node); |
| 1327 return CloseBlock(); | 1328 return CloseBlock(); |
| 1328 } | 1329 } |
| 1329 | 1330 |
| 1330 | 1331 |
| 1331 SequenceNode* Parser::ParseMethodExtractor(const Function& func) { | 1332 SequenceNode* Parser::ParseMethodExtractor(const Function& func) { |
| 1332 TRACE_PARSER("ParseMethodExtractor"); | 1333 TRACE_PARSER("ParseMethodExtractor"); |
| 1334 ASSERT(FLAG_lazy_dispatchers); |
| 1335 |
| 1333 ParamList params; | 1336 ParamList params; |
| 1334 | 1337 |
| 1335 const intptr_t ident_pos = func.token_pos(); | 1338 const intptr_t ident_pos = func.token_pos(); |
| 1336 ASSERT(func.token_pos() == 0); | 1339 ASSERT(func.token_pos() == 0); |
| 1337 ASSERT(current_class().raw() == func.Owner()); | 1340 ASSERT(current_class().raw() == func.Owner()); |
| 1338 params.AddReceiver(ReceiverType(current_class()), ident_pos); | 1341 params.AddReceiver(ReceiverType(current_class()), ident_pos); |
| 1339 ASSERT(func.num_fixed_parameters() == 1); // Receiver. | 1342 ASSERT(func.num_fixed_parameters() == 1); // Receiver. |
| 1340 ASSERT(!func.HasOptionalParameters()); | 1343 ASSERT(!func.HasOptionalParameters()); |
| 1341 | 1344 |
| 1342 // Build local scope for function and populate with the formal parameters. | 1345 // Build local scope for function and populate with the formal parameters. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 SetupDefaultsForOptionalParams(¶ms, default_values); | 1398 SetupDefaultsForOptionalParams(¶ms, default_values); |
| 1396 | 1399 |
| 1397 // Build local scope for function and populate with the formal parameters. | 1400 // Build local scope for function and populate with the formal parameters. |
| 1398 OpenFunctionBlock(func); | 1401 OpenFunctionBlock(func); |
| 1399 AddFormalParamsToScope(¶ms, current_block_->scope); | 1402 AddFormalParamsToScope(¶ms, current_block_->scope); |
| 1400 } | 1403 } |
| 1401 | 1404 |
| 1402 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func, | 1405 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func, |
| 1403 Array* default_values) { | 1406 Array* default_values) { |
| 1404 TRACE_PARSER("ParseNoSuchMethodDispatcher"); | 1407 TRACE_PARSER("ParseNoSuchMethodDispatcher"); |
| 1408 ASSERT(FLAG_lazy_dispatchers); |
| 1405 | 1409 |
| 1406 ASSERT(func.IsNoSuchMethodDispatcher()); | 1410 ASSERT(func.IsNoSuchMethodDispatcher()); |
| 1407 intptr_t token_pos = func.token_pos(); | 1411 intptr_t token_pos = func.token_pos(); |
| 1408 ASSERT(func.token_pos() == 0); | 1412 ASSERT(func.token_pos() == 0); |
| 1409 ASSERT(current_class().raw() == func.Owner()); | 1413 ASSERT(current_class().raw() == func.Owner()); |
| 1410 | 1414 |
| 1411 ArgumentsDescriptor desc(Array::Handle(Z, func.saved_args_desc())); | 1415 ArgumentsDescriptor desc(Array::Handle(Z, func.saved_args_desc())); |
| 1412 ASSERT(desc.Count() > 0); | 1416 ASSERT(desc.Count() > 0); |
| 1413 | 1417 |
| 1414 // Set up scope for this function. | 1418 // Set up scope for this function. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 | 1456 |
| 1453 ReturnNode* return_node = new ReturnNode(token_pos, call); | 1457 ReturnNode* return_node = new ReturnNode(token_pos, call); |
| 1454 current_block_->statements->Add(return_node); | 1458 current_block_->statements->Add(return_node); |
| 1455 return CloseBlock(); | 1459 return CloseBlock(); |
| 1456 } | 1460 } |
| 1457 | 1461 |
| 1458 | 1462 |
| 1459 SequenceNode* Parser::ParseInvokeFieldDispatcher(const Function& func, | 1463 SequenceNode* Parser::ParseInvokeFieldDispatcher(const Function& func, |
| 1460 Array* default_values) { | 1464 Array* default_values) { |
| 1461 TRACE_PARSER("ParseInvokeFieldDispatcher"); | 1465 TRACE_PARSER("ParseInvokeFieldDispatcher"); |
| 1466 ASSERT(FLAG_lazy_dispatchers); |
| 1462 | 1467 |
| 1463 ASSERT(func.IsInvokeFieldDispatcher()); | 1468 ASSERT(func.IsInvokeFieldDispatcher()); |
| 1464 intptr_t token_pos = func.token_pos(); | 1469 intptr_t token_pos = func.token_pos(); |
| 1465 ASSERT(func.token_pos() == 0); | 1470 ASSERT(func.token_pos() == 0); |
| 1466 ASSERT(current_class().raw() == func.Owner()); | 1471 ASSERT(current_class().raw() == func.Owner()); |
| 1467 | 1472 |
| 1468 const Array& args_desc = Array::Handle(Z, func.saved_args_desc()); | 1473 const Array& args_desc = Array::Handle(Z, func.saved_args_desc()); |
| 1469 ArgumentsDescriptor desc(args_desc); | 1474 ArgumentsDescriptor desc(args_desc); |
| 1470 ASSERT(desc.Count() > 0); | 1475 ASSERT(desc.Count() > 0); |
| 1471 | 1476 |
| (...skipping 12054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13526 void Parser::SkipQualIdent() { | 13531 void Parser::SkipQualIdent() { |
| 13527 ASSERT(IsIdentifier()); | 13532 ASSERT(IsIdentifier()); |
| 13528 ConsumeToken(); | 13533 ConsumeToken(); |
| 13529 if (CurrentToken() == Token::kPERIOD) { | 13534 if (CurrentToken() == Token::kPERIOD) { |
| 13530 ConsumeToken(); // Consume the kPERIOD token. | 13535 ConsumeToken(); // Consume the kPERIOD token. |
| 13531 ExpectIdentifier("identifier expected after '.'"); | 13536 ExpectIdentifier("identifier expected after '.'"); |
| 13532 } | 13537 } |
| 13533 } | 13538 } |
| 13534 | 13539 |
| 13535 } // namespace dart | 13540 } // namespace dart |
| OLD | NEW |