Chromium Code Reviews| 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 "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1709 Resolver::ResolveDynamicAnyArgs(super_class, Symbols::NoSuchMethod()); | 1709 Resolver::ResolveDynamicAnyArgs(super_class, Symbols::NoSuchMethod()); |
| 1710 ASSERT(!super_func.IsNull()); | 1710 ASSERT(!super_func.IsNull()); |
| 1711 *is_no_such_method = true; | 1711 *is_no_such_method = true; |
| 1712 } else { | 1712 } else { |
| 1713 *is_no_such_method = false; | 1713 *is_no_such_method = false; |
| 1714 } | 1714 } |
| 1715 return super_func.raw(); | 1715 return super_func.raw(); |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 | 1718 |
| 1719 // Lookup class in the core lib which also contains various VM | |
| 1720 // helper methods and classes. Allow look up of private classes. | |
| 1721 static RawClass* LookupCoreClass(const String& class_name) { | |
| 1722 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 1723 String& name = String::Handle(class_name.raw()); | |
| 1724 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { | |
| 1725 // Private identifiers are mangled on a per script basis. | |
| 1726 name = String::Concat(name, String::Handle(core_lib.private_key())); | |
| 1727 name = Symbols::New(name); | |
| 1728 } | |
| 1729 return core_lib.LookupClass(name); | |
| 1730 } | |
| 1731 | |
| 1732 | |
| 1733 static const String& PrivateCoreLibName(const String& str) { | |
| 1734 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 1735 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str)); | |
| 1736 return private_name; | |
| 1737 } | |
| 1738 | |
| 1739 | |
| 1740 StaticCallNode* Parser::BuildInvocationMirrorAllocation( | 1719 StaticCallNode* Parser::BuildInvocationMirrorAllocation( |
| 1741 intptr_t call_pos, | 1720 intptr_t call_pos, |
| 1742 const String& function_name, | 1721 const String& function_name, |
| 1743 const ArgumentListNode& function_args, | 1722 const ArgumentListNode& function_args, |
| 1744 const LocalVariable* temp_for_last_arg) { | 1723 const LocalVariable* temp_for_last_arg) { |
| 1745 const intptr_t args_pos = function_args.token_pos(); | 1724 const intptr_t args_pos = function_args.token_pos(); |
| 1746 // Build arguments to the call to the static | 1725 // Build arguments to the call to the static |
| 1747 // InvocationMirror._allocateInvocationMirror method. | 1726 // InvocationMirror._allocateInvocationMirror method. |
| 1748 ArgumentListNode* arguments = new ArgumentListNode(args_pos); | 1727 ArgumentListNode* arguments = new ArgumentListNode(args_pos); |
| 1749 // The first argument is the original function name. | 1728 // The first argument is the original function name. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1767 store_arg->AddNode(new LoadLocalNode(arg->token_pos(), | 1746 store_arg->AddNode(new LoadLocalNode(arg->token_pos(), |
| 1768 temp_for_last_arg)); | 1747 temp_for_last_arg)); |
| 1769 args_array->AddElement(store_arg); | 1748 args_array->AddElement(store_arg); |
| 1770 } else { | 1749 } else { |
| 1771 args_array->AddElement(arg); | 1750 args_array->AddElement(arg); |
| 1772 } | 1751 } |
| 1773 } | 1752 } |
| 1774 arguments->Add(args_array); | 1753 arguments->Add(args_array); |
| 1775 // Lookup the static InvocationMirror._allocateInvocationMirror method. | 1754 // Lookup the static InvocationMirror._allocateInvocationMirror method. |
| 1776 const Class& mirror_class = | 1755 const Class& mirror_class = |
| 1777 Class::Handle(LookupCoreClass(Symbols::InvocationMirror())); | 1756 Class::Handle(Library::LookupCoreClass(Symbols::InvocationMirror())); |
| 1778 ASSERT(!mirror_class.IsNull()); | 1757 ASSERT(!mirror_class.IsNull()); |
| 1779 const Function& allocation_function = Function::ZoneHandle( | 1758 const Function& allocation_function = Function::ZoneHandle( |
| 1780 mirror_class.LookupStaticFunction( | 1759 mirror_class.LookupStaticFunction( |
| 1781 PrivateCoreLibName(Symbols::AllocateInvocationMirror()))); | 1760 Library::PrivateCoreLibName(Symbols::AllocateInvocationMirror()))); |
| 1782 ASSERT(!allocation_function.IsNull()); | 1761 ASSERT(!allocation_function.IsNull()); |
| 1783 return new StaticCallNode(call_pos, allocation_function, arguments); | 1762 return new StaticCallNode(call_pos, allocation_function, arguments); |
| 1784 } | 1763 } |
| 1785 | 1764 |
| 1786 | 1765 |
| 1787 ArgumentListNode* Parser::BuildNoSuchMethodArguments( | 1766 ArgumentListNode* Parser::BuildNoSuchMethodArguments( |
| 1788 intptr_t call_pos, | 1767 intptr_t call_pos, |
| 1789 const String& function_name, | 1768 const String& function_name, |
| 1790 const ArgumentListNode& function_args, | 1769 const ArgumentListNode& function_args, |
| 1791 const LocalVariable* temp_for_last_arg) { | 1770 const LocalVariable* temp_for_last_arg) { |
| (...skipping 4392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6184 } | 6163 } |
| 6185 if ((next_token == Token::kCASE) || (next_token == Token::kDEFAULT)) { | 6164 if ((next_token == Token::kCASE) || (next_token == Token::kDEFAULT)) { |
| 6186 // End of this case clause. If there is a possible fall-through to | 6165 // End of this case clause. If there is a possible fall-through to |
| 6187 // the next case clause, throw an implicit FallThroughError. | 6166 // the next case clause, throw an implicit FallThroughError. |
| 6188 if (!abrupt_completing_seen) { | 6167 if (!abrupt_completing_seen) { |
| 6189 ArgumentListNode* arguments = new ArgumentListNode(TokenPos()); | 6168 ArgumentListNode* arguments = new ArgumentListNode(TokenPos()); |
| 6190 arguments->Add(new LiteralNode( | 6169 arguments->Add(new LiteralNode( |
| 6191 TokenPos(), Integer::ZoneHandle(Integer::New(TokenPos())))); | 6170 TokenPos(), Integer::ZoneHandle(Integer::New(TokenPos())))); |
| 6192 current_block_->statements->Add( | 6171 current_block_->statements->Add( |
| 6193 MakeStaticCall(Symbols::FallThroughError(), | 6172 MakeStaticCall(Symbols::FallThroughError(), |
| 6194 PrivateCoreLibName(Symbols::ThrowNew()), | 6173 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 6195 arguments)); | 6174 arguments)); |
| 6196 } | 6175 } |
| 6197 break; | 6176 break; |
| 6198 } | 6177 } |
| 6199 // The next statement still belongs to this case. | 6178 // The next statement still belongs to this case. |
| 6200 AstNode* statement = ParseStatement(); | 6179 AstNode* statement = ParseStatement(); |
| 6201 if (statement != NULL) { | 6180 if (statement != NULL) { |
| 6202 current_block_->statements->Add(statement); | 6181 current_block_->statements->Add(statement); |
| 6203 abrupt_completing_seen |= IsAbruptCompleting(statement); | 6182 abrupt_completing_seen |= IsAbruptCompleting(statement); |
| 6204 } | 6183 } |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6502 body); | 6481 body); |
| 6503 current_block_->statements->Add(for_node); | 6482 current_block_->statements->Add(for_node); |
| 6504 return CloseBlock(); | 6483 return CloseBlock(); |
| 6505 } | 6484 } |
| 6506 | 6485 |
| 6507 | 6486 |
| 6508 // Calling VM-internal helpers, uses implementation core library. | 6487 // Calling VM-internal helpers, uses implementation core library. |
| 6509 AstNode* Parser::MakeStaticCall(const String& cls_name, | 6488 AstNode* Parser::MakeStaticCall(const String& cls_name, |
| 6510 const String& func_name, | 6489 const String& func_name, |
| 6511 ArgumentListNode* arguments) { | 6490 ArgumentListNode* arguments) { |
| 6512 const Class& cls = Class::Handle(LookupCoreClass(cls_name)); | 6491 const Class& cls = Class::Handle(Library::LookupCoreClass(cls_name)); |
| 6513 ASSERT(!cls.IsNull()); | 6492 ASSERT(!cls.IsNull()); |
| 6514 const Function& func = Function::ZoneHandle( | 6493 const Function& func = Function::ZoneHandle( |
| 6515 Resolver::ResolveStatic(cls, | 6494 Resolver::ResolveStatic(cls, |
| 6516 func_name, | 6495 func_name, |
| 6517 arguments->length(), | 6496 arguments->length(), |
| 6518 arguments->names(), | 6497 arguments->names(), |
| 6519 Resolver::kIsQualified)); | 6498 Resolver::kIsQualified)); |
| 6520 ASSERT(!func.IsNull()); | 6499 ASSERT(!func.IsNull()); |
| 6521 return new StaticCallNode(arguments->token_pos(), func, arguments); | 6500 return new StaticCallNode(arguments->token_pos(), func, arguments); |
| 6522 } | 6501 } |
| 6523 | 6502 |
| 6524 | 6503 |
| 6525 AstNode* Parser::MakeAssertCall(intptr_t begin, intptr_t end) { | 6504 AstNode* Parser::MakeAssertCall(intptr_t begin, intptr_t end) { |
| 6526 ArgumentListNode* arguments = new ArgumentListNode(begin); | 6505 ArgumentListNode* arguments = new ArgumentListNode(begin); |
| 6527 arguments->Add(new LiteralNode(begin, | 6506 arguments->Add(new LiteralNode(begin, |
| 6528 Integer::ZoneHandle(Integer::New(begin)))); | 6507 Integer::ZoneHandle(Integer::New(begin)))); |
| 6529 arguments->Add(new LiteralNode(end, | 6508 arguments->Add(new LiteralNode(end, |
| 6530 Integer::ZoneHandle(Integer::New(end)))); | 6509 Integer::ZoneHandle(Integer::New(end)))); |
| 6531 return MakeStaticCall(Symbols::AssertionError(), | 6510 return MakeStaticCall(Symbols::AssertionError(), |
| 6532 PrivateCoreLibName(Symbols::ThrowNew()), | 6511 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 6533 arguments); | 6512 arguments); |
| 6534 } | 6513 } |
| 6535 | 6514 |
| 6536 | 6515 |
| 6537 AstNode* Parser::InsertClosureCallNodes(AstNode* condition) { | 6516 AstNode* Parser::InsertClosureCallNodes(AstNode* condition) { |
| 6538 if (condition->IsClosureNode() || | 6517 if (condition->IsClosureNode() || |
| 6539 (condition->IsStoreLocalNode() && | 6518 (condition->IsStoreLocalNode() && |
| 6540 condition->AsStoreLocalNode()->value()->IsClosureNode())) { | 6519 condition->AsStoreLocalNode()->value()->IsClosureNode())) { |
| 6541 EnsureSavedCurrentContext(); | 6520 EnsureSavedCurrentContext(); |
| 6542 // Function literal in assert implies a call. | 6521 // Function literal in assert implies a call. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6815 ArgumentListNode* no_args = new ArgumentListNode(catch_pos); | 6794 ArgumentListNode* no_args = new ArgumentListNode(catch_pos); |
| 6816 LocalVariable* trace = LookupLocalScope(*stack_trace_param.var); | 6795 LocalVariable* trace = LookupLocalScope(*stack_trace_param.var); |
| 6817 ASSERT(catch_trace_var != NULL); | 6796 ASSERT(catch_trace_var != NULL); |
| 6818 current_block_->statements->Add( | 6797 current_block_->statements->Add( |
| 6819 new StoreLocalNode(catch_pos, trace, | 6798 new StoreLocalNode(catch_pos, trace, |
| 6820 new LoadLocalNode(catch_pos, catch_trace_var))); | 6799 new LoadLocalNode(catch_pos, catch_trace_var))); |
| 6821 current_block_->statements->Add( | 6800 current_block_->statements->Add( |
| 6822 new InstanceCallNode( | 6801 new InstanceCallNode( |
| 6823 catch_pos, | 6802 catch_pos, |
| 6824 new LoadLocalNode(catch_pos, trace), | 6803 new LoadLocalNode(catch_pos, trace), |
| 6825 PrivateCoreLibName(Symbols::_setupFullStackTrace()), | 6804 Library::PrivateCoreLibName(Symbols::_setupFullStackTrace()), |
| 6826 no_args)); | 6805 no_args)); |
| 6827 } | 6806 } |
| 6828 | 6807 |
| 6829 ParseStatementSequence(); // Parse the catch handler code. | 6808 ParseStatementSequence(); // Parse the catch handler code. |
| 6830 current_block_->statements->Add( | 6809 current_block_->statements->Add( |
| 6831 new JumpNode(catch_pos, Token::kCONTINUE, end_catch_label)); | 6810 new JumpNode(catch_pos, Token::kCONTINUE, end_catch_label)); |
| 6832 SequenceNode* catch_handler = CloseBlock(); | 6811 SequenceNode* catch_handler = CloseBlock(); |
| 6833 ExpectToken(Token::kRBRACE); | 6812 ExpectToken(Token::kRBRACE); |
| 6834 | 6813 |
| 6835 if (!exception_param.type->IsDynamicType()) { // Has a type specification. | 6814 if (!exception_param.type->IsDynamicType()) { // Has a type specification. |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7383 Error& error = Error::Handle(); | 7362 Error& error = Error::Handle(); |
| 7384 if (type.IsMalformed()) { | 7363 if (type.IsMalformed()) { |
| 7385 error = type.malformed_error(); | 7364 error = type.malformed_error(); |
| 7386 } else { | 7365 } else { |
| 7387 const bool is_malbounded = type.IsMalboundedWithError(&error); | 7366 const bool is_malbounded = type.IsMalboundedWithError(&error); |
| 7388 ASSERT(is_malbounded); | 7367 ASSERT(is_malbounded); |
| 7389 } | 7368 } |
| 7390 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( | 7369 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
| 7391 Symbols::New(error.ToErrorCString())))); | 7370 Symbols::New(error.ToErrorCString())))); |
| 7392 return MakeStaticCall(Symbols::TypeError(), | 7371 return MakeStaticCall(Symbols::TypeError(), |
| 7393 PrivateCoreLibName(Symbols::ThrowNew()), | 7372 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 7394 arguments); | 7373 arguments); |
| 7395 } | 7374 } |
| 7396 | 7375 |
| 7397 | 7376 |
| 7398 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, | 7377 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, |
| 7399 const Class& cls, | 7378 const Class& cls, |
| 7400 const String& function_name, | 7379 const String& function_name, |
| 7401 ArgumentListNode* function_arguments, | 7380 ArgumentListNode* function_arguments, |
| 7402 InvocationMirror::Call im_call, | 7381 InvocationMirror::Call im_call, |
| 7403 InvocationMirror::Type im_type, | 7382 InvocationMirror::Type im_type, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7462 // "existingArgumentNames" array of the NoSuchMethodError constructor. | 7441 // "existingArgumentNames" array of the NoSuchMethodError constructor. |
| 7463 // TODO(13471): Separate the implementations of NoSuchMethodError | 7442 // TODO(13471): Separate the implementations of NoSuchMethodError |
| 7464 // between dart2js and VM. Update the constructor to accept a string | 7443 // between dart2js and VM. Update the constructor to accept a string |
| 7465 // describing the formal parameters of an incompatible call target. | 7444 // describing the formal parameters of an incompatible call target. |
| 7466 array = Array::New(1, Heap::kOld); | 7445 array = Array::New(1, Heap::kOld); |
| 7467 array.SetAt(0, String::Handle(function.UserVisibleFormalParameters())); | 7446 array.SetAt(0, String::Handle(function.UserVisibleFormalParameters())); |
| 7468 } | 7447 } |
| 7469 arguments->Add(new LiteralNode(call_pos, array)); | 7448 arguments->Add(new LiteralNode(call_pos, array)); |
| 7470 | 7449 |
| 7471 return MakeStaticCall(Symbols::NoSuchMethodError(), | 7450 return MakeStaticCall(Symbols::NoSuchMethodError(), |
| 7472 PrivateCoreLibName(Symbols::ThrowNew()), | 7451 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 7473 arguments); | 7452 arguments); |
| 7474 } | 7453 } |
| 7475 | 7454 |
| 7476 | 7455 |
| 7477 AstNode* Parser::ParseBinaryExpr(int min_preced) { | 7456 AstNode* Parser::ParseBinaryExpr(int min_preced) { |
| 7478 TRACE_PARSER("ParseBinaryExpr"); | 7457 TRACE_PARSER("ParseBinaryExpr"); |
| 7479 ASSERT(min_preced >= Token::Precedence(Token::kOR)); | 7458 ASSERT(min_preced >= Token::Precedence(Token::kOR)); |
| 7480 AstNode* left_operand = ParseUnaryExpr(); | 7459 AstNode* left_operand = ParseUnaryExpr(); |
| 7481 if (left_operand->IsPrimaryNode() && | 7460 if (left_operand->IsPrimaryNode() && |
| 7482 (left_operand->AsPrimaryNode()->IsSuper())) { | 7461 (left_operand->AsPrimaryNode()->IsSuper())) { |
| (...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9347 } | 9326 } |
| 9348 } | 9327 } |
| 9349 const_list.SetAt(i, elem->AsLiteralNode()->literal()); | 9328 const_list.SetAt(i, elem->AsLiteralNode()->literal()); |
| 9350 } | 9329 } |
| 9351 const_list ^= TryCanonicalize(const_list, literal_pos); | 9330 const_list ^= TryCanonicalize(const_list, literal_pos); |
| 9352 const_list.MakeImmutable(); | 9331 const_list.MakeImmutable(); |
| 9353 return new LiteralNode(literal_pos, const_list); | 9332 return new LiteralNode(literal_pos, const_list); |
| 9354 } else { | 9333 } else { |
| 9355 // Factory call at runtime. | 9334 // Factory call at runtime. |
| 9356 const Class& factory_class = | 9335 const Class& factory_class = |
| 9357 Class::Handle(LookupCoreClass(Symbols::List())); | 9336 Class::Handle(Library::LookupCoreClass(Symbols::List())); |
| 9358 ASSERT(!factory_class.IsNull()); | 9337 ASSERT(!factory_class.IsNull()); |
| 9359 const Function& factory_method = Function::ZoneHandle( | 9338 const Function& factory_method = Function::ZoneHandle( |
| 9360 factory_class.LookupFactory( | 9339 factory_class.LookupFactory( |
| 9361 PrivateCoreLibName(Symbols::ListLiteralFactory()))); | 9340 Library::PrivateCoreLibName(Symbols::ListLiteralFactory()))); |
| 9362 ASSERT(!factory_method.IsNull()); | 9341 ASSERT(!factory_method.IsNull()); |
| 9363 if (!list_type_arguments.IsNull() && | 9342 if (!list_type_arguments.IsNull() && |
| 9364 !list_type_arguments.IsInstantiated() && | 9343 !list_type_arguments.IsInstantiated() && |
| 9365 (current_block_->scope->function_level() > 0)) { | 9344 (current_block_->scope->function_level() > 0)) { |
| 9366 // Make sure that the instantiator is captured. | 9345 // Make sure that the instantiator is captured. |
| 9367 CaptureInstantiator(); | 9346 CaptureInstantiator(); |
| 9368 } | 9347 } |
| 9369 AbstractTypeArguments& factory_type_args = | 9348 AbstractTypeArguments& factory_type_args = |
| 9370 AbstractTypeArguments::ZoneHandle(list_type_arguments.raw()); | 9349 AbstractTypeArguments::ZoneHandle(list_type_arguments.raw()); |
| 9371 // If the factory class extends other parameterized classes, adjust the | 9350 // If the factory class extends other parameterized classes, adjust the |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9590 } | 9569 } |
| 9591 } | 9570 } |
| 9592 } | 9571 } |
| 9593 key_value_array.SetAt(i, arg->AsLiteralNode()->literal()); | 9572 key_value_array.SetAt(i, arg->AsLiteralNode()->literal()); |
| 9594 } | 9573 } |
| 9595 key_value_array ^= TryCanonicalize(key_value_array, TokenPos()); | 9574 key_value_array ^= TryCanonicalize(key_value_array, TokenPos()); |
| 9596 key_value_array.MakeImmutable(); | 9575 key_value_array.MakeImmutable(); |
| 9597 | 9576 |
| 9598 // Construct the map object. | 9577 // Construct the map object. |
| 9599 const Class& immutable_map_class = | 9578 const Class& immutable_map_class = |
| 9600 Class::Handle(LookupCoreClass(Symbols::ImmutableMap())); | 9579 Class::Handle(Library::LookupCoreClass(Symbols::ImmutableMap())); |
| 9601 ASSERT(!immutable_map_class.IsNull()); | 9580 ASSERT(!immutable_map_class.IsNull()); |
| 9602 // If the immutable map class extends other parameterized classes, we need | 9581 // If the immutable map class extends other parameterized classes, we need |
| 9603 // to adjust the type argument vector. This is currently not the case. | 9582 // to adjust the type argument vector. This is currently not the case. |
| 9604 ASSERT(immutable_map_class.NumTypeArguments() == 2); | 9583 ASSERT(immutable_map_class.NumTypeArguments() == 2); |
| 9605 ArgumentListNode* constr_args = new ArgumentListNode(TokenPos()); | 9584 ArgumentListNode* constr_args = new ArgumentListNode(TokenPos()); |
| 9606 constr_args->Add(new LiteralNode(literal_pos, key_value_array)); | 9585 constr_args->Add(new LiteralNode(literal_pos, key_value_array)); |
| 9607 const Function& map_constr = | 9586 const Function& map_constr = |
| 9608 Function::ZoneHandle(immutable_map_class.LookupConstructor( | 9587 Function::ZoneHandle(immutable_map_class.LookupConstructor( |
| 9609 PrivateCoreLibName(Symbols::ImmutableMapConstructor()))); | 9588 Library::PrivateCoreLibName(Symbols::ImmutableMapConstructor()))); |
| 9610 ASSERT(!map_constr.IsNull()); | 9589 ASSERT(!map_constr.IsNull()); |
| 9611 const Object& constructor_result = Object::Handle( | 9590 const Object& constructor_result = Object::Handle( |
| 9612 EvaluateConstConstructorCall(immutable_map_class, | 9591 EvaluateConstConstructorCall(immutable_map_class, |
| 9613 map_type_arguments, | 9592 map_type_arguments, |
| 9614 map_constr, | 9593 map_constr, |
| 9615 constr_args)); | 9594 constr_args)); |
| 9616 if (constructor_result.IsUnhandledException()) { | 9595 if (constructor_result.IsUnhandledException()) { |
| 9617 return GenerateRethrow(literal_pos, constructor_result); | 9596 return GenerateRethrow(literal_pos, constructor_result); |
| 9618 } else { | 9597 } else { |
| 9619 const Instance& const_instance = Instance::Cast(constructor_result); | 9598 const Instance& const_instance = Instance::Cast(constructor_result); |
| 9620 return new LiteralNode(literal_pos, | 9599 return new LiteralNode(literal_pos, |
| 9621 Instance::ZoneHandle(const_instance.raw())); | 9600 Instance::ZoneHandle(const_instance.raw())); |
| 9622 } | 9601 } |
| 9623 } else { | 9602 } else { |
| 9624 // Factory call at runtime. | 9603 // Factory call at runtime. |
| 9625 const Class& factory_class = | 9604 const Class& factory_class = |
| 9626 Class::Handle(LookupCoreClass(Symbols::Map())); | 9605 Class::Handle(Library::LookupCoreClass(Symbols::Map())); |
| 9627 ASSERT(!factory_class.IsNull()); | 9606 ASSERT(!factory_class.IsNull()); |
| 9628 const Function& factory_method = Function::ZoneHandle( | 9607 const Function& factory_method = Function::ZoneHandle( |
| 9629 factory_class.LookupFactory( | 9608 factory_class.LookupFactory( |
| 9630 PrivateCoreLibName(Symbols::MapLiteralFactory()))); | 9609 Library::PrivateCoreLibName(Symbols::MapLiteralFactory()))); |
| 9631 ASSERT(!factory_method.IsNull()); | 9610 ASSERT(!factory_method.IsNull()); |
| 9632 if (!map_type_arguments.IsNull() && | 9611 if (!map_type_arguments.IsNull() && |
| 9633 !map_type_arguments.IsInstantiated() && | 9612 !map_type_arguments.IsInstantiated() && |
| 9634 (current_block_->scope->function_level() > 0)) { | 9613 (current_block_->scope->function_level() > 0)) { |
| 9635 // Make sure that the instantiator is captured. | 9614 // Make sure that the instantiator is captured. |
| 9636 CaptureInstantiator(); | 9615 CaptureInstantiator(); |
| 9637 } | 9616 } |
| 9638 AbstractTypeArguments& factory_type_args = | 9617 AbstractTypeArguments& factory_type_args = |
| 9639 AbstractTypeArguments::ZoneHandle(map_type_arguments.raw()); | 9618 AbstractTypeArguments::ZoneHandle(map_type_arguments.raw()); |
| 9640 // If the factory class extends other parameterized classes, adjust the | 9619 // If the factory class extends other parameterized classes, adjust the |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9897 // It is ok to call a factory method of an abstract class, but it is | 9876 // It is ok to call a factory method of an abstract class, but it is |
| 9898 // a dynamic error to instantiate an abstract class. | 9877 // a dynamic error to instantiate an abstract class. |
| 9899 ASSERT(!constructor.IsNull()); | 9878 ASSERT(!constructor.IsNull()); |
| 9900 if (type_class.is_abstract() && !constructor.IsFactory()) { | 9879 if (type_class.is_abstract() && !constructor.IsFactory()) { |
| 9901 ArgumentListNode* arguments = new ArgumentListNode(type_pos); | 9880 ArgumentListNode* arguments = new ArgumentListNode(type_pos); |
| 9902 arguments->Add(new LiteralNode( | 9881 arguments->Add(new LiteralNode( |
| 9903 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); | 9882 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); |
| 9904 arguments->Add(new LiteralNode( | 9883 arguments->Add(new LiteralNode( |
| 9905 TokenPos(), String::ZoneHandle(type_class_name.raw()))); | 9884 TokenPos(), String::ZoneHandle(type_class_name.raw()))); |
| 9906 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), | 9885 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), |
| 9907 PrivateCoreLibName(Symbols::ThrowNew()), | 9886 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 9908 arguments); | 9887 arguments); |
| 9909 } | 9888 } |
| 9910 String& error_message = String::Handle(); | 9889 String& error_message = String::Handle(); |
| 9911 if (!constructor.AreValidArguments(arguments_length, | 9890 if (!constructor.AreValidArguments(arguments_length, |
| 9912 arguments->names(), | 9891 arguments->names(), |
| 9913 &error_message)) { | 9892 &error_message)) { |
| 9914 const String& external_constructor_name = | 9893 const String& external_constructor_name = |
| 9915 (named_constructor ? constructor_name : type_class_name); | 9894 (named_constructor ? constructor_name : type_class_name); |
| 9916 if (is_const) { | 9895 if (is_const) { |
| 9917 ErrorMsg(call_pos, | 9896 ErrorMsg(call_pos, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9996 new_object = new AssignableNode(new_pos, | 9975 new_object = new AssignableNode(new_pos, |
| 9997 new_object, | 9976 new_object, |
| 9998 type_bound, | 9977 type_bound, |
| 9999 Symbols::FactoryResult()); | 9978 Symbols::FactoryResult()); |
| 10000 } | 9979 } |
| 10001 return new_object; | 9980 return new_object; |
| 10002 } | 9981 } |
| 10003 | 9982 |
| 10004 | 9983 |
| 10005 String& Parser::Interpolate(const GrowableArray<AstNode*>& values) { | 9984 String& Parser::Interpolate(const GrowableArray<AstNode*>& values) { |
| 10006 const Class& cls = Class::Handle(LookupCoreClass(Symbols::StringBase())); | 9985 const Class& cls = Class::Handle( |
|
hausner
2013/10/14 23:11:14
Class::Handle( on next line?
srdjan
2013/10/14 23:19:42
Done.
| |
| 9986 Library::LookupCoreClass(Symbols::StringBase())); | |
| 10007 ASSERT(!cls.IsNull()); | 9987 ASSERT(!cls.IsNull()); |
| 10008 const Function& func = | 9988 const Function& func = |
| 10009 Function::Handle(cls.LookupStaticFunction( | 9989 Function::Handle(cls.LookupStaticFunction( |
| 10010 PrivateCoreLibName(Symbols::Interpolate()))); | 9990 Library::PrivateCoreLibName(Symbols::Interpolate()))); |
| 10011 ASSERT(!func.IsNull()); | 9991 ASSERT(!func.IsNull()); |
| 10012 | 9992 |
| 10013 // Build the array of literal values to interpolate. | 9993 // Build the array of literal values to interpolate. |
| 10014 const Array& value_arr = Array::Handle(Array::New(values.length())); | 9994 const Array& value_arr = Array::Handle(Array::New(values.length())); |
| 10015 for (int i = 0; i < values.length(); i++) { | 9995 for (int i = 0; i < values.length(); i++) { |
| 10016 ASSERT(values[i]->IsLiteralNode()); | 9996 ASSERT(values[i]->IsLiteralNode()); |
| 10017 value_arr.SetAt(i, values[i]->AsLiteralNode()->literal()); | 9997 value_arr.SetAt(i, values[i]->AsLiteralNode()->literal()); |
| 10018 } | 9998 } |
| 10019 | 9999 |
| 10020 // Build argument array to pass to the interpolation function. | 10000 // Build argument array to pass to the interpolation function. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10097 } | 10077 } |
| 10098 if (is_compiletime_const) { | 10078 if (is_compiletime_const) { |
| 10099 primary = new LiteralNode(literal_start, Interpolate(values_list)); | 10079 primary = new LiteralNode(literal_start, Interpolate(values_list)); |
| 10100 } else { | 10080 } else { |
| 10101 ArgumentListNode* interpolate_arg = new ArgumentListNode(TokenPos()); | 10081 ArgumentListNode* interpolate_arg = new ArgumentListNode(TokenPos()); |
| 10102 ArrayNode* values = new ArrayNode( | 10082 ArrayNode* values = new ArrayNode( |
| 10103 TokenPos(), | 10083 TokenPos(), |
| 10104 Type::ZoneHandle(Type::ArrayType()), | 10084 Type::ZoneHandle(Type::ArrayType()), |
| 10105 values_list); | 10085 values_list); |
| 10106 interpolate_arg->Add(values); | 10086 interpolate_arg->Add(values); |
| 10107 primary = MakeStaticCall(Symbols::StringBase(), | 10087 primary = |
| 10108 PrivateCoreLibName(Symbols::Interpolate()), | 10088 MakeStaticCall(Symbols::StringBase(), |
| 10109 interpolate_arg); | 10089 Library::PrivateCoreLibName(Symbols::Interpolate()), |
| 10090 interpolate_arg); | |
| 10110 } | 10091 } |
| 10111 return primary; | 10092 return primary; |
| 10112 } | 10093 } |
| 10113 | 10094 |
| 10114 | 10095 |
| 10115 AstNode* Parser::ParsePrimary() { | 10096 AstNode* Parser::ParsePrimary() { |
| 10116 TRACE_PARSER("ParsePrimary"); | 10097 TRACE_PARSER("ParsePrimary"); |
| 10117 ASSERT(!is_top_level_); | 10098 ASSERT(!is_top_level_); |
| 10118 AstNode* primary = NULL; | 10099 AstNode* primary = NULL; |
| 10119 if (IsFunctionLiteral()) { | 10100 if (IsFunctionLiteral()) { |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10630 void Parser::SkipQualIdent() { | 10611 void Parser::SkipQualIdent() { |
| 10631 ASSERT(IsIdentifier()); | 10612 ASSERT(IsIdentifier()); |
| 10632 ConsumeToken(); | 10613 ConsumeToken(); |
| 10633 if (CurrentToken() == Token::kPERIOD) { | 10614 if (CurrentToken() == Token::kPERIOD) { |
| 10634 ConsumeToken(); // Consume the kPERIOD token. | 10615 ConsumeToken(); // Consume the kPERIOD token. |
| 10635 ExpectIdentifier("identifier expected after '.'"); | 10616 ExpectIdentifier("identifier expected after '.'"); |
| 10636 } | 10617 } |
| 10637 } | 10618 } |
| 10638 | 10619 |
| 10639 } // namespace dart | 10620 } // namespace dart |
| OLD | NEW |