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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 String& name = String::Handle(class_name.raw()); | 1326 String& name = String::Handle(class_name.raw()); |
1327 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { | 1327 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { |
1328 // Private identifiers are mangled on a per script basis. | 1328 // Private identifiers are mangled on a per script basis. |
1329 name = String::Concat(name, String::Handle(core_lib.private_key())); | 1329 name = String::Concat(name, String::Handle(core_lib.private_key())); |
1330 name = Symbols::New(name); | 1330 name = Symbols::New(name); |
1331 } | 1331 } |
1332 return core_lib.LookupClass(name); | 1332 return core_lib.LookupClass(name); |
1333 } | 1333 } |
1334 | 1334 |
1335 | 1335 |
| 1336 static const String& PrivateCoreLibName(const String& str) { |
| 1337 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 1338 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str)); |
| 1339 return private_name; |
| 1340 } |
| 1341 |
| 1342 |
1336 StaticCallNode* Parser::BuildInvocationMirrorAllocation( | 1343 StaticCallNode* Parser::BuildInvocationMirrorAllocation( |
1337 intptr_t call_pos, | 1344 intptr_t call_pos, |
1338 const String& function_name, | 1345 const String& function_name, |
1339 const ArgumentListNode& function_args) { | 1346 const ArgumentListNode& function_args) { |
1340 const intptr_t args_pos = function_args.token_pos(); | 1347 const intptr_t args_pos = function_args.token_pos(); |
1341 // Build arguments to the call to the static | 1348 // Build arguments to the call to the static |
1342 // InvocationMirror._allocateInvocationMirror method. | 1349 // InvocationMirror._allocateInvocationMirror method. |
1343 ArgumentListNode* arguments = new ArgumentListNode(args_pos); | 1350 ArgumentListNode* arguments = new ArgumentListNode(args_pos); |
1344 // The first argument is the original function name. | 1351 // The first argument is the original function name. |
1345 arguments->Add(new LiteralNode(args_pos, function_name)); | 1352 arguments->Add(new LiteralNode(args_pos, function_name)); |
1346 // The second argument is the arguments descriptor of the original function. | 1353 // The second argument is the arguments descriptor of the original function. |
1347 const Array& args_descriptor = | 1354 const Array& args_descriptor = |
1348 Array::ZoneHandle(ArgumentsDescriptor::New(function_args.length(), | 1355 Array::ZoneHandle(ArgumentsDescriptor::New(function_args.length(), |
1349 function_args.names())); | 1356 function_args.names())); |
1350 arguments->Add(new LiteralNode(args_pos, args_descriptor)); | 1357 arguments->Add(new LiteralNode(args_pos, args_descriptor)); |
1351 // The third argument is an array containing the original function arguments, | 1358 // The third argument is an array containing the original function arguments, |
1352 // including the receiver. | 1359 // including the receiver. |
1353 ArrayNode* args_array = new ArrayNode( | 1360 ArrayNode* args_array = new ArrayNode( |
1354 args_pos, Type::ZoneHandle(Type::ArrayType())); | 1361 args_pos, Type::ZoneHandle(Type::ArrayType())); |
1355 for (intptr_t i = 0; i < function_args.length(); i++) { | 1362 for (intptr_t i = 0; i < function_args.length(); i++) { |
1356 args_array->AddElement(function_args.NodeAt(i)); | 1363 args_array->AddElement(function_args.NodeAt(i)); |
1357 } | 1364 } |
1358 arguments->Add(args_array); | 1365 arguments->Add(args_array); |
1359 // Lookup the static InvocationMirror._allocateInvocationMirror method. | 1366 // Lookup the static InvocationMirror._allocateInvocationMirror method. |
1360 const Class& mirror_class = | 1367 const Class& mirror_class = |
1361 Class::Handle(LookupCoreClass(Symbols::InvocationMirror())); | 1368 Class::Handle(LookupCoreClass(Symbols::InvocationMirror())); |
1362 ASSERT(!mirror_class.IsNull()); | 1369 ASSERT(!mirror_class.IsNull()); |
1363 const Function& allocation_function = Function::ZoneHandle( | 1370 const Function& allocation_function = Function::ZoneHandle( |
1364 mirror_class.LookupStaticFunction(Symbols::AllocateInvocationMirror())); | 1371 mirror_class.LookupStaticFunction( |
| 1372 PrivateCoreLibName(Symbols::AllocateInvocationMirror()))); |
1365 ASSERT(!allocation_function.IsNull()); | 1373 ASSERT(!allocation_function.IsNull()); |
1366 return new StaticCallNode(call_pos, allocation_function, arguments); | 1374 return new StaticCallNode(call_pos, allocation_function, arguments); |
1367 } | 1375 } |
1368 | 1376 |
1369 | 1377 |
1370 ArgumentListNode* Parser::BuildNoSuchMethodArguments( | 1378 ArgumentListNode* Parser::BuildNoSuchMethodArguments( |
1371 intptr_t call_pos, | 1379 intptr_t call_pos, |
1372 const String& function_name, | 1380 const String& function_name, |
1373 const ArgumentListNode& function_args) { | 1381 const ArgumentListNode& function_args) { |
1374 ASSERT(function_args.length() >= 1); // The receiver is the first argument. | 1382 ASSERT(function_args.length() >= 1); // The receiver is the first argument. |
(...skipping 4026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5401 } | 5409 } |
5402 if ((next_token == Token::kCASE) || (next_token == Token::kDEFAULT)) { | 5410 if ((next_token == Token::kCASE) || (next_token == Token::kDEFAULT)) { |
5403 // End of this case clause. If there is a possible fall-through to | 5411 // End of this case clause. If there is a possible fall-through to |
5404 // the next case clause, throw an implicit FallThroughError. | 5412 // the next case clause, throw an implicit FallThroughError. |
5405 if (!abrupt_completing_seen) { | 5413 if (!abrupt_completing_seen) { |
5406 ArgumentListNode* arguments = new ArgumentListNode(TokenPos()); | 5414 ArgumentListNode* arguments = new ArgumentListNode(TokenPos()); |
5407 arguments->Add(new LiteralNode( | 5415 arguments->Add(new LiteralNode( |
5408 TokenPos(), Integer::ZoneHandle(Integer::New(TokenPos())))); | 5416 TokenPos(), Integer::ZoneHandle(Integer::New(TokenPos())))); |
5409 current_block_->statements->Add( | 5417 current_block_->statements->Add( |
5410 MakeStaticCall(Symbols::FallThroughError(), | 5418 MakeStaticCall(Symbols::FallThroughError(), |
5411 Symbols::ThrowNew(), | 5419 PrivateCoreLibName(Symbols::ThrowNew()), |
5412 arguments)); | 5420 arguments)); |
5413 } | 5421 } |
5414 break; | 5422 break; |
5415 } | 5423 } |
5416 // The next statement still belongs to this case. | 5424 // The next statement still belongs to this case. |
5417 AstNode* statement = ParseStatement(); | 5425 AstNode* statement = ParseStatement(); |
5418 if (statement != NULL) { | 5426 if (statement != NULL) { |
5419 current_block_->statements->Add(statement); | 5427 current_block_->statements->Add(statement); |
5420 abrupt_completing_seen |= IsAbruptCompleting(statement); | 5428 abrupt_completing_seen |= IsAbruptCompleting(statement); |
5421 } | 5429 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5745 } | 5753 } |
5746 | 5754 |
5747 | 5755 |
5748 AstNode* Parser::MakeAssertCall(intptr_t begin, intptr_t end) { | 5756 AstNode* Parser::MakeAssertCall(intptr_t begin, intptr_t end) { |
5749 ArgumentListNode* arguments = new ArgumentListNode(begin); | 5757 ArgumentListNode* arguments = new ArgumentListNode(begin); |
5750 arguments->Add(new LiteralNode(begin, | 5758 arguments->Add(new LiteralNode(begin, |
5751 Integer::ZoneHandle(Integer::New(begin)))); | 5759 Integer::ZoneHandle(Integer::New(begin)))); |
5752 arguments->Add(new LiteralNode(end, | 5760 arguments->Add(new LiteralNode(end, |
5753 Integer::ZoneHandle(Integer::New(end)))); | 5761 Integer::ZoneHandle(Integer::New(end)))); |
5754 return MakeStaticCall(Symbols::AssertionError(), | 5762 return MakeStaticCall(Symbols::AssertionError(), |
5755 Symbols::ThrowNew(), | 5763 PrivateCoreLibName(Symbols::ThrowNew()), |
5756 arguments); | 5764 arguments); |
5757 } | 5765 } |
5758 | 5766 |
5759 | 5767 |
5760 AstNode* Parser::InsertClosureCallNodes(AstNode* condition) { | 5768 AstNode* Parser::InsertClosureCallNodes(AstNode* condition) { |
5761 if (condition->IsClosureNode() || | 5769 if (condition->IsClosureNode() || |
5762 (condition->IsStoreLocalNode() && | 5770 (condition->IsStoreLocalNode() && |
5763 condition->AsStoreLocalNode()->value()->IsClosureNode())) { | 5771 condition->AsStoreLocalNode()->value()->IsClosureNode())) { |
5764 EnsureExpressionTemp(); | 5772 EnsureExpressionTemp(); |
5765 // Function literal in assert implies a call. | 5773 // Function literal in assert implies a call. |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6592 // Src value argument. | 6600 // Src value argument. |
6593 arguments->Add(new LiteralNode(type_pos, Instance::ZoneHandle())); | 6601 arguments->Add(new LiteralNode(type_pos, Instance::ZoneHandle())); |
6594 // Dst type name argument. | 6602 // Dst type name argument. |
6595 arguments->Add(new LiteralNode(type_pos, Symbols::Malformed())); | 6603 arguments->Add(new LiteralNode(type_pos, Symbols::Malformed())); |
6596 // Dst name argument. | 6604 // Dst name argument. |
6597 arguments->Add(new LiteralNode(type_pos, Symbols::Empty())); | 6605 arguments->Add(new LiteralNode(type_pos, Symbols::Empty())); |
6598 // Malformed type error. | 6606 // Malformed type error. |
6599 const Error& error = Error::Handle(type.malformed_error()); | 6607 const Error& error = Error::Handle(type.malformed_error()); |
6600 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( | 6608 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
6601 Symbols::New(error.ToErrorCString())))); | 6609 Symbols::New(error.ToErrorCString())))); |
6602 return MakeStaticCall(Symbols::TypeError(), Symbols::ThrowNew(), arguments); | 6610 return MakeStaticCall(Symbols::TypeError(), |
| 6611 PrivateCoreLibName(Symbols::ThrowNew()), |
| 6612 arguments); |
6603 } | 6613 } |
6604 | 6614 |
6605 | 6615 |
6606 // TODO(regis): Providing the argument values is not always feasible, since | 6616 // TODO(regis): Providing the argument values is not always feasible, since |
6607 // evaluating them could throw an error. | 6617 // evaluating them could throw an error. |
6608 // Should NoSuchMethodError reflect the argument count and names instead of | 6618 // Should NoSuchMethodError reflect the argument count and names instead of |
6609 // argument values? Or should the spec specify a different evaluation order? | 6619 // argument values? Or should the spec specify a different evaluation order? |
6610 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, | 6620 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, |
6611 const Class& cls, | 6621 const Class& cls, |
6612 const String& function_name) { | 6622 const String& function_name) { |
6613 ArgumentListNode* arguments = new ArgumentListNode(call_pos); | 6623 ArgumentListNode* arguments = new ArgumentListNode(call_pos); |
6614 // Object receiver. | 6624 // Object receiver. |
6615 // TODO(regis): For now, we pass a class literal of the unresolved | 6625 // TODO(regis): For now, we pass a class literal of the unresolved |
6616 // method's owner, but this is not specified and will probably change. | 6626 // method's owner, but this is not specified and will probably change. |
6617 Type& type = Type::ZoneHandle( | 6627 Type& type = Type::ZoneHandle( |
6618 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); | 6628 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); |
6619 type ^= ClassFinalizer::FinalizeType( | 6629 type ^= ClassFinalizer::FinalizeType( |
6620 current_class(), type, ClassFinalizer::kCanonicalize); | 6630 current_class(), type, ClassFinalizer::kCanonicalize); |
6621 arguments->Add(new LiteralNode(call_pos, type)); | 6631 arguments->Add(new LiteralNode(call_pos, type)); |
6622 // String memberName. | 6632 // String memberName. |
6623 arguments->Add(new LiteralNode( | 6633 arguments->Add(new LiteralNode( |
6624 call_pos, String::ZoneHandle(Symbols::New(function_name)))); | 6634 call_pos, String::ZoneHandle(Symbols::New(function_name)))); |
6625 // List arguments. | 6635 // List arguments. |
6626 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6636 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
6627 // List argumentNames. | 6637 // List argumentNames. |
6628 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6638 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
6629 // List existingArgumentNames. | 6639 // List existingArgumentNames. |
6630 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6640 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
6631 return MakeStaticCall(Symbols::NoSuchMethodError(), | 6641 return MakeStaticCall(Symbols::NoSuchMethodError(), |
6632 Symbols::ThrowNew(), | 6642 PrivateCoreLibName(Symbols::ThrowNew()), |
6633 arguments); | 6643 arguments); |
6634 } | 6644 } |
6635 | 6645 |
6636 | 6646 |
6637 AstNode* Parser::ParseBinaryExpr(int min_preced) { | 6647 AstNode* Parser::ParseBinaryExpr(int min_preced) { |
6638 TRACE_PARSER("ParseBinaryExpr"); | 6648 TRACE_PARSER("ParseBinaryExpr"); |
6639 ASSERT(min_preced >= 4); | 6649 ASSERT(min_preced >= 4); |
6640 AstNode* left_operand = ParseUnaryExpr(); | 6650 AstNode* left_operand = ParseUnaryExpr(); |
6641 if (left_operand->IsPrimaryNode() && | 6651 if (left_operand->IsPrimaryNode() && |
6642 (left_operand->AsPrimaryNode()->IsSuper())) { | 6652 (left_operand->AsPrimaryNode()->IsSuper())) { |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8591 } | 8601 } |
8592 const_list ^= const_list.Canonicalize(); | 8602 const_list ^= const_list.Canonicalize(); |
8593 const_list.MakeImmutable(); | 8603 const_list.MakeImmutable(); |
8594 return new LiteralNode(literal_pos, const_list); | 8604 return new LiteralNode(literal_pos, const_list); |
8595 } else { | 8605 } else { |
8596 // Factory call at runtime. | 8606 // Factory call at runtime. |
8597 const Class& factory_class = | 8607 const Class& factory_class = |
8598 Class::Handle(LookupCoreClass(Symbols::List())); | 8608 Class::Handle(LookupCoreClass(Symbols::List())); |
8599 ASSERT(!factory_class.IsNull()); | 8609 ASSERT(!factory_class.IsNull()); |
8600 const Function& factory_method = Function::ZoneHandle( | 8610 const Function& factory_method = Function::ZoneHandle( |
8601 factory_class.LookupFactory(Symbols::ListLiteralFactory())); | 8611 factory_class.LookupFactory( |
| 8612 PrivateCoreLibName(Symbols::ListLiteralFactory()))); |
8602 ASSERT(!factory_method.IsNull()); | 8613 ASSERT(!factory_method.IsNull()); |
8603 if (!type_arguments.IsNull() && | 8614 if (!type_arguments.IsNull() && |
8604 !type_arguments.IsInstantiated() && | 8615 !type_arguments.IsInstantiated() && |
8605 (current_block_->scope->function_level() > 0)) { | 8616 (current_block_->scope->function_level() > 0)) { |
8606 // Make sure that the instantiator is captured. | 8617 // Make sure that the instantiator is captured. |
8607 CaptureInstantiator(); | 8618 CaptureInstantiator(); |
8608 } | 8619 } |
8609 AbstractTypeArguments& factory_type_args = | 8620 AbstractTypeArguments& factory_type_args = |
8610 AbstractTypeArguments::ZoneHandle(type_arguments.raw()); | 8621 AbstractTypeArguments::ZoneHandle(type_arguments.raw()); |
8611 // If the factory class extends other parameterized classes, adjust the | 8622 // If the factory class extends other parameterized classes, adjust the |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8803 const Class& immutable_map_class = | 8814 const Class& immutable_map_class = |
8804 Class::Handle(LookupCoreClass(Symbols::ImmutableMap())); | 8815 Class::Handle(LookupCoreClass(Symbols::ImmutableMap())); |
8805 ASSERT(!immutable_map_class.IsNull()); | 8816 ASSERT(!immutable_map_class.IsNull()); |
8806 // If the immutable map class extends other parameterized classes, we need | 8817 // If the immutable map class extends other parameterized classes, we need |
8807 // to adjust the type argument vector. This is currently not the case. | 8818 // to adjust the type argument vector. This is currently not the case. |
8808 ASSERT(immutable_map_class.NumTypeArguments() == 2); | 8819 ASSERT(immutable_map_class.NumTypeArguments() == 2); |
8809 ArgumentListNode* constr_args = new ArgumentListNode(TokenPos()); | 8820 ArgumentListNode* constr_args = new ArgumentListNode(TokenPos()); |
8810 constr_args->Add(new LiteralNode(literal_pos, key_value_array)); | 8821 constr_args->Add(new LiteralNode(literal_pos, key_value_array)); |
8811 const Function& map_constr = | 8822 const Function& map_constr = |
8812 Function::ZoneHandle(immutable_map_class.LookupConstructor( | 8823 Function::ZoneHandle(immutable_map_class.LookupConstructor( |
8813 Symbols::ImmutableMapConstructor())); | 8824 PrivateCoreLibName(Symbols::ImmutableMapConstructor()))); |
8814 ASSERT(!map_constr.IsNull()); | 8825 ASSERT(!map_constr.IsNull()); |
8815 const Object& constructor_result = Object::Handle( | 8826 const Object& constructor_result = Object::Handle( |
8816 EvaluateConstConstructorCall(immutable_map_class, | 8827 EvaluateConstConstructorCall(immutable_map_class, |
8817 map_type_arguments, | 8828 map_type_arguments, |
8818 map_constr, | 8829 map_constr, |
8819 constr_args)); | 8830 constr_args)); |
8820 if (constructor_result.IsUnhandledException()) { | 8831 if (constructor_result.IsUnhandledException()) { |
8821 return GenerateRethrow(literal_pos, constructor_result); | 8832 return GenerateRethrow(literal_pos, constructor_result); |
8822 } else { | 8833 } else { |
8823 const Instance& const_instance = Instance::Cast(constructor_result); | 8834 const Instance& const_instance = Instance::Cast(constructor_result); |
8824 return new LiteralNode(literal_pos, | 8835 return new LiteralNode(literal_pos, |
8825 Instance::ZoneHandle(const_instance.raw())); | 8836 Instance::ZoneHandle(const_instance.raw())); |
8826 } | 8837 } |
8827 } else { | 8838 } else { |
8828 // Factory call at runtime. | 8839 // Factory call at runtime. |
8829 const Class& factory_class = | 8840 const Class& factory_class = |
8830 Class::Handle(LookupCoreClass(Symbols::Map())); | 8841 Class::Handle(LookupCoreClass(Symbols::Map())); |
8831 ASSERT(!factory_class.IsNull()); | 8842 ASSERT(!factory_class.IsNull()); |
8832 const Function& factory_method = Function::ZoneHandle( | 8843 const Function& factory_method = Function::ZoneHandle( |
8833 factory_class.LookupFactory(Symbols::MapLiteralFactory())); | 8844 factory_class.LookupFactory( |
| 8845 PrivateCoreLibName(Symbols::MapLiteralFactory()))); |
8834 ASSERT(!factory_method.IsNull()); | 8846 ASSERT(!factory_method.IsNull()); |
8835 if (!map_type_arguments.IsNull() && | 8847 if (!map_type_arguments.IsNull() && |
8836 !map_type_arguments.IsInstantiated() && | 8848 !map_type_arguments.IsInstantiated() && |
8837 (current_block_->scope->function_level() > 0)) { | 8849 (current_block_->scope->function_level() > 0)) { |
8838 // Make sure that the instantiator is captured. | 8850 // Make sure that the instantiator is captured. |
8839 CaptureInstantiator(); | 8851 CaptureInstantiator(); |
8840 } | 8852 } |
8841 AbstractTypeArguments& factory_type_args = | 8853 AbstractTypeArguments& factory_type_args = |
8842 AbstractTypeArguments::ZoneHandle(map_type_arguments.raw()); | 8854 AbstractTypeArguments::ZoneHandle(map_type_arguments.raw()); |
8843 // If the factory class extends other parameterized classes, adjust the | 8855 // If the factory class extends other parameterized classes, adjust the |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9036 // It is ok to call a factory method of an abstract class, but it is | 9048 // It is ok to call a factory method of an abstract class, but it is |
9037 // a dynamic error to instantiate an abstract class. | 9049 // a dynamic error to instantiate an abstract class. |
9038 ASSERT(!constructor.IsNull()); | 9050 ASSERT(!constructor.IsNull()); |
9039 if (type_class.is_abstract() && !constructor.IsFactory()) { | 9051 if (type_class.is_abstract() && !constructor.IsFactory()) { |
9040 ArgumentListNode* arguments = new ArgumentListNode(type_pos); | 9052 ArgumentListNode* arguments = new ArgumentListNode(type_pos); |
9041 arguments->Add(new LiteralNode( | 9053 arguments->Add(new LiteralNode( |
9042 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); | 9054 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); |
9043 arguments->Add(new LiteralNode( | 9055 arguments->Add(new LiteralNode( |
9044 TokenPos(), String::ZoneHandle(type_class_name.raw()))); | 9056 TokenPos(), String::ZoneHandle(type_class_name.raw()))); |
9045 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), | 9057 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), |
9046 Symbols::ThrowNew(), | 9058 PrivateCoreLibName(Symbols::ThrowNew()), |
9047 arguments); | 9059 arguments); |
9048 } | 9060 } |
9049 String& error_message = String::Handle(); | 9061 String& error_message = String::Handle(); |
9050 if (!constructor.AreValidArguments(arguments_length, | 9062 if (!constructor.AreValidArguments(arguments_length, |
9051 arguments->names(), | 9063 arguments->names(), |
9052 &error_message)) { | 9064 &error_message)) { |
9053 const String& external_constructor_name = | 9065 const String& external_constructor_name = |
9054 (named_constructor ? constructor_name : type_class_name); | 9066 (named_constructor ? constructor_name : type_class_name); |
9055 if (is_const) { | 9067 if (is_const) { |
9056 ErrorMsg(call_pos, | 9068 ErrorMsg(call_pos, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9131 Symbols::FactoryResult()); | 9143 Symbols::FactoryResult()); |
9132 } | 9144 } |
9133 return new_object; | 9145 return new_object; |
9134 } | 9146 } |
9135 | 9147 |
9136 | 9148 |
9137 String& Parser::Interpolate(ArrayNode* values) { | 9149 String& Parser::Interpolate(ArrayNode* values) { |
9138 const Class& cls = Class::Handle(LookupCoreClass(Symbols::StringBase())); | 9150 const Class& cls = Class::Handle(LookupCoreClass(Symbols::StringBase())); |
9139 ASSERT(!cls.IsNull()); | 9151 ASSERT(!cls.IsNull()); |
9140 const Function& func = | 9152 const Function& func = |
9141 Function::Handle(cls.LookupStaticFunction(Symbols::Interpolate())); | 9153 Function::Handle(cls.LookupStaticFunction( |
| 9154 PrivateCoreLibName(Symbols::Interpolate()))); |
9142 ASSERT(!func.IsNull()); | 9155 ASSERT(!func.IsNull()); |
9143 | 9156 |
9144 // Build the array of literal values to interpolate. | 9157 // Build the array of literal values to interpolate. |
9145 const Array& value_arr = Array::Handle(Array::New(values->length())); | 9158 const Array& value_arr = Array::Handle(Array::New(values->length())); |
9146 for (int i = 0; i < values->length(); i++) { | 9159 for (int i = 0; i < values->length(); i++) { |
9147 ASSERT(values->ElementAt(i)->IsLiteralNode()); | 9160 ASSERT(values->ElementAt(i)->IsLiteralNode()); |
9148 value_arr.SetAt(i, values->ElementAt(i)->AsLiteralNode()->literal()); | 9161 value_arr.SetAt(i, values->ElementAt(i)->AsLiteralNode()->literal()); |
9149 } | 9162 } |
9150 | 9163 |
9151 // Build argument array to pass to the interpolation function. | 9164 // Build argument array to pass to the interpolation function. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9223 values->AddElement(expr); | 9236 values->AddElement(expr); |
9224 } | 9237 } |
9225 } | 9238 } |
9226 if (is_compiletime_const) { | 9239 if (is_compiletime_const) { |
9227 primary = new LiteralNode(literal_start, Interpolate(values)); | 9240 primary = new LiteralNode(literal_start, Interpolate(values)); |
9228 } else { | 9241 } else { |
9229 ArgumentListNode* interpolate_arg = | 9242 ArgumentListNode* interpolate_arg = |
9230 new ArgumentListNode(values->token_pos()); | 9243 new ArgumentListNode(values->token_pos()); |
9231 interpolate_arg->Add(values); | 9244 interpolate_arg->Add(values); |
9232 primary = MakeStaticCall(Symbols::StringBase(), | 9245 primary = MakeStaticCall(Symbols::StringBase(), |
9233 Symbols::Interpolate(), | 9246 PrivateCoreLibName(Symbols::Interpolate()), |
9234 interpolate_arg); | 9247 interpolate_arg); |
9235 } | 9248 } |
9236 return primary; | 9249 return primary; |
9237 } | 9250 } |
9238 | 9251 |
9239 | 9252 |
9240 AstNode* Parser::ParseArgumentDefinitionTest() { | 9253 AstNode* Parser::ParseArgumentDefinitionTest() { |
9241 const intptr_t test_pos = TokenPos(); | 9254 const intptr_t test_pos = TokenPos(); |
9242 ConsumeToken(); | 9255 ConsumeToken(); |
9243 const intptr_t ident_pos = TokenPos(); | 9256 const intptr_t ident_pos = TokenPos(); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9725 void Parser::SkipQualIdent() { | 9738 void Parser::SkipQualIdent() { |
9726 ASSERT(IsIdentifier()); | 9739 ASSERT(IsIdentifier()); |
9727 ConsumeToken(); | 9740 ConsumeToken(); |
9728 if (CurrentToken() == Token::kPERIOD) { | 9741 if (CurrentToken() == Token::kPERIOD) { |
9729 ConsumeToken(); // Consume the kPERIOD token. | 9742 ConsumeToken(); // Consume the kPERIOD token. |
9730 ExpectIdentifier("identifier expected after '.'"); | 9743 ExpectIdentifier("identifier expected after '.'"); |
9731 } | 9744 } |
9732 } | 9745 } |
9733 | 9746 |
9734 } // namespace dart | 9747 } // namespace dart |
OLD | NEW |