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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6573 // Src value argument. | 6581 // Src value argument. |
6574 arguments->Add(new LiteralNode(type_pos, Instance::ZoneHandle())); | 6582 arguments->Add(new LiteralNode(type_pos, Instance::ZoneHandle())); |
6575 // Dst type name argument. | 6583 // Dst type name argument. |
6576 arguments->Add(new LiteralNode(type_pos, Symbols::Malformed())); | 6584 arguments->Add(new LiteralNode(type_pos, Symbols::Malformed())); |
6577 // Dst name argument. | 6585 // Dst name argument. |
6578 arguments->Add(new LiteralNode(type_pos, Symbols::Empty())); | 6586 arguments->Add(new LiteralNode(type_pos, Symbols::Empty())); |
6579 // Malformed type error. | 6587 // Malformed type error. |
6580 const Error& error = Error::Handle(type.malformed_error()); | 6588 const Error& error = Error::Handle(type.malformed_error()); |
6581 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( | 6589 arguments->Add(new LiteralNode(type_pos, String::ZoneHandle( |
6582 Symbols::New(error.ToErrorCString())))); | 6590 Symbols::New(error.ToErrorCString())))); |
6583 return MakeStaticCall(Symbols::TypeError(), Symbols::ThrowNew(), arguments); | 6591 return MakeStaticCall(Symbols::TypeError(), |
| 6592 PrivateCoreLibName(Symbols::ThrowNew()), |
| 6593 arguments); |
6584 } | 6594 } |
6585 | 6595 |
6586 | 6596 |
6587 // TODO(regis): Providing the argument values is not always feasible, since | 6597 // TODO(regis): Providing the argument values is not always feasible, since |
6588 // evaluating them could throw an error. | 6598 // evaluating them could throw an error. |
6589 // Should NoSuchMethodError reflect the argument count and names instead of | 6599 // Should NoSuchMethodError reflect the argument count and names instead of |
6590 // argument values? Or should the spec specify a different evaluation order? | 6600 // argument values? Or should the spec specify a different evaluation order? |
6591 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, | 6601 AstNode* Parser::ThrowNoSuchMethodError(intptr_t call_pos, |
6592 const Class& cls, | 6602 const Class& cls, |
6593 const String& function_name) { | 6603 const String& function_name) { |
6594 ArgumentListNode* arguments = new ArgumentListNode(call_pos); | 6604 ArgumentListNode* arguments = new ArgumentListNode(call_pos); |
6595 // Object receiver. | 6605 // Object receiver. |
6596 // TODO(regis): For now, we pass a class literal of the unresolved | 6606 // TODO(regis): For now, we pass a class literal of the unresolved |
6597 // method's owner, but this is not specified and will probably change. | 6607 // method's owner, but this is not specified and will probably change. |
6598 Type& type = Type::ZoneHandle( | 6608 Type& type = Type::ZoneHandle( |
6599 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); | 6609 Type::New(cls, TypeArguments::Handle(), call_pos, Heap::kOld)); |
6600 type ^= ClassFinalizer::FinalizeType( | 6610 type ^= ClassFinalizer::FinalizeType( |
6601 current_class(), type, ClassFinalizer::kCanonicalize); | 6611 current_class(), type, ClassFinalizer::kCanonicalize); |
6602 arguments->Add(new LiteralNode(call_pos, type)); | 6612 arguments->Add(new LiteralNode(call_pos, type)); |
6603 // String memberName. | 6613 // String memberName. |
6604 arguments->Add(new LiteralNode( | 6614 arguments->Add(new LiteralNode( |
6605 call_pos, String::ZoneHandle(Symbols::New(function_name)))); | 6615 call_pos, String::ZoneHandle(Symbols::New(function_name)))); |
6606 // List arguments. | 6616 // List arguments. |
6607 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6617 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
6608 // List argumentNames. | 6618 // List argumentNames. |
6609 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6619 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
6610 // List existingArgumentNames. | 6620 // List existingArgumentNames. |
6611 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); | 6621 arguments->Add(new LiteralNode(call_pos, Array::ZoneHandle())); |
6612 return MakeStaticCall(Symbols::NoSuchMethodError(), | 6622 return MakeStaticCall(Symbols::NoSuchMethodError(), |
6613 Symbols::ThrowNew(), | 6623 PrivateCoreLibName(Symbols::ThrowNew()), |
6614 arguments); | 6624 arguments); |
6615 } | 6625 } |
6616 | 6626 |
6617 | 6627 |
6618 AstNode* Parser::ParseBinaryExpr(int min_preced) { | 6628 AstNode* Parser::ParseBinaryExpr(int min_preced) { |
6619 TRACE_PARSER("ParseBinaryExpr"); | 6629 TRACE_PARSER("ParseBinaryExpr"); |
6620 ASSERT(min_preced >= 4); | 6630 ASSERT(min_preced >= 4); |
6621 AstNode* left_operand = ParseUnaryExpr(); | 6631 AstNode* left_operand = ParseUnaryExpr(); |
6622 if (left_operand->IsPrimaryNode() && | 6632 if (left_operand->IsPrimaryNode() && |
6623 (left_operand->AsPrimaryNode()->IsSuper())) { | 6633 (left_operand->AsPrimaryNode()->IsSuper())) { |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8572 } | 8582 } |
8573 const_list ^= const_list.Canonicalize(); | 8583 const_list ^= const_list.Canonicalize(); |
8574 const_list.MakeImmutable(); | 8584 const_list.MakeImmutable(); |
8575 return new LiteralNode(literal_pos, const_list); | 8585 return new LiteralNode(literal_pos, const_list); |
8576 } else { | 8586 } else { |
8577 // Factory call at runtime. | 8587 // Factory call at runtime. |
8578 const Class& factory_class = | 8588 const Class& factory_class = |
8579 Class::Handle(LookupCoreClass(Symbols::List())); | 8589 Class::Handle(LookupCoreClass(Symbols::List())); |
8580 ASSERT(!factory_class.IsNull()); | 8590 ASSERT(!factory_class.IsNull()); |
8581 const Function& factory_method = Function::ZoneHandle( | 8591 const Function& factory_method = Function::ZoneHandle( |
8582 factory_class.LookupFactory(Symbols::ListLiteralFactory())); | 8592 factory_class.LookupFactory( |
| 8593 PrivateCoreLibName(Symbols::ListLiteralFactory()))); |
8583 ASSERT(!factory_method.IsNull()); | 8594 ASSERT(!factory_method.IsNull()); |
8584 if (!type_arguments.IsNull() && | 8595 if (!type_arguments.IsNull() && |
8585 !type_arguments.IsInstantiated() && | 8596 !type_arguments.IsInstantiated() && |
8586 (current_block_->scope->function_level() > 0)) { | 8597 (current_block_->scope->function_level() > 0)) { |
8587 // Make sure that the instantiator is captured. | 8598 // Make sure that the instantiator is captured. |
8588 CaptureInstantiator(); | 8599 CaptureInstantiator(); |
8589 } | 8600 } |
8590 AbstractTypeArguments& factory_type_args = | 8601 AbstractTypeArguments& factory_type_args = |
8591 AbstractTypeArguments::ZoneHandle(type_arguments.raw()); | 8602 AbstractTypeArguments::ZoneHandle(type_arguments.raw()); |
8592 // If the factory class extends other parameterized classes, adjust the | 8603 // If the factory class extends other parameterized classes, adjust the |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8784 const Class& immutable_map_class = | 8795 const Class& immutable_map_class = |
8785 Class::Handle(LookupCoreClass(Symbols::ImmutableMap())); | 8796 Class::Handle(LookupCoreClass(Symbols::ImmutableMap())); |
8786 ASSERT(!immutable_map_class.IsNull()); | 8797 ASSERT(!immutable_map_class.IsNull()); |
8787 // If the immutable map class extends other parameterized classes, we need | 8798 // If the immutable map class extends other parameterized classes, we need |
8788 // to adjust the type argument vector. This is currently not the case. | 8799 // to adjust the type argument vector. This is currently not the case. |
8789 ASSERT(immutable_map_class.NumTypeArguments() == 2); | 8800 ASSERT(immutable_map_class.NumTypeArguments() == 2); |
8790 ArgumentListNode* constr_args = new ArgumentListNode(TokenPos()); | 8801 ArgumentListNode* constr_args = new ArgumentListNode(TokenPos()); |
8791 constr_args->Add(new LiteralNode(literal_pos, key_value_array)); | 8802 constr_args->Add(new LiteralNode(literal_pos, key_value_array)); |
8792 const Function& map_constr = | 8803 const Function& map_constr = |
8793 Function::ZoneHandle(immutable_map_class.LookupConstructor( | 8804 Function::ZoneHandle(immutable_map_class.LookupConstructor( |
8794 Symbols::ImmutableMapConstructor())); | 8805 PrivateCoreLibName(Symbols::ImmutableMapConstructor()))); |
8795 ASSERT(!map_constr.IsNull()); | 8806 ASSERT(!map_constr.IsNull()); |
8796 const Object& constructor_result = Object::Handle( | 8807 const Object& constructor_result = Object::Handle( |
8797 EvaluateConstConstructorCall(immutable_map_class, | 8808 EvaluateConstConstructorCall(immutable_map_class, |
8798 map_type_arguments, | 8809 map_type_arguments, |
8799 map_constr, | 8810 map_constr, |
8800 constr_args)); | 8811 constr_args)); |
8801 if (constructor_result.IsUnhandledException()) { | 8812 if (constructor_result.IsUnhandledException()) { |
8802 return GenerateRethrow(literal_pos, constructor_result); | 8813 return GenerateRethrow(literal_pos, constructor_result); |
8803 } else { | 8814 } else { |
8804 const Instance& const_instance = Instance::Cast(constructor_result); | 8815 const Instance& const_instance = Instance::Cast(constructor_result); |
8805 return new LiteralNode(literal_pos, | 8816 return new LiteralNode(literal_pos, |
8806 Instance::ZoneHandle(const_instance.raw())); | 8817 Instance::ZoneHandle(const_instance.raw())); |
8807 } | 8818 } |
8808 } else { | 8819 } else { |
8809 // Factory call at runtime. | 8820 // Factory call at runtime. |
8810 const Class& factory_class = | 8821 const Class& factory_class = |
8811 Class::Handle(LookupCoreClass(Symbols::Map())); | 8822 Class::Handle(LookupCoreClass(Symbols::Map())); |
8812 ASSERT(!factory_class.IsNull()); | 8823 ASSERT(!factory_class.IsNull()); |
8813 const Function& factory_method = Function::ZoneHandle( | 8824 const Function& factory_method = Function::ZoneHandle( |
8814 factory_class.LookupFactory(Symbols::MapLiteralFactory())); | 8825 factory_class.LookupFactory( |
| 8826 PrivateCoreLibName(Symbols::MapLiteralFactory()))); |
8815 ASSERT(!factory_method.IsNull()); | 8827 ASSERT(!factory_method.IsNull()); |
8816 if (!map_type_arguments.IsNull() && | 8828 if (!map_type_arguments.IsNull() && |
8817 !map_type_arguments.IsInstantiated() && | 8829 !map_type_arguments.IsInstantiated() && |
8818 (current_block_->scope->function_level() > 0)) { | 8830 (current_block_->scope->function_level() > 0)) { |
8819 // Make sure that the instantiator is captured. | 8831 // Make sure that the instantiator is captured. |
8820 CaptureInstantiator(); | 8832 CaptureInstantiator(); |
8821 } | 8833 } |
8822 AbstractTypeArguments& factory_type_args = | 8834 AbstractTypeArguments& factory_type_args = |
8823 AbstractTypeArguments::ZoneHandle(map_type_arguments.raw()); | 8835 AbstractTypeArguments::ZoneHandle(map_type_arguments.raw()); |
8824 // If the factory class extends other parameterized classes, adjust the | 8836 // If the factory class extends other parameterized classes, adjust the |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9017 // It is ok to call a factory method of an abstract class, but it is | 9029 // It is ok to call a factory method of an abstract class, but it is |
9018 // a dynamic error to instantiate an abstract class. | 9030 // a dynamic error to instantiate an abstract class. |
9019 ASSERT(!constructor.IsNull()); | 9031 ASSERT(!constructor.IsNull()); |
9020 if (type_class.is_abstract() && !constructor.IsFactory()) { | 9032 if (type_class.is_abstract() && !constructor.IsFactory()) { |
9021 ArgumentListNode* arguments = new ArgumentListNode(type_pos); | 9033 ArgumentListNode* arguments = new ArgumentListNode(type_pos); |
9022 arguments->Add(new LiteralNode( | 9034 arguments->Add(new LiteralNode( |
9023 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); | 9035 TokenPos(), Integer::ZoneHandle(Integer::New(type_pos)))); |
9024 arguments->Add(new LiteralNode( | 9036 arguments->Add(new LiteralNode( |
9025 TokenPos(), String::ZoneHandle(type_class_name.raw()))); | 9037 TokenPos(), String::ZoneHandle(type_class_name.raw()))); |
9026 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), | 9038 return MakeStaticCall(Symbols::AbstractClassInstantiationError(), |
9027 Symbols::ThrowNew(), | 9039 PrivateCoreLibName(Symbols::ThrowNew()), |
9028 arguments); | 9040 arguments); |
9029 } | 9041 } |
9030 String& error_message = String::Handle(); | 9042 String& error_message = String::Handle(); |
9031 if (!constructor.AreValidArguments(arguments_length, | 9043 if (!constructor.AreValidArguments(arguments_length, |
9032 arguments->names(), | 9044 arguments->names(), |
9033 &error_message)) { | 9045 &error_message)) { |
9034 const String& external_constructor_name = | 9046 const String& external_constructor_name = |
9035 (named_constructor ? constructor_name : type_class_name); | 9047 (named_constructor ? constructor_name : type_class_name); |
9036 if (is_const) { | 9048 if (is_const) { |
9037 ErrorMsg(call_pos, | 9049 ErrorMsg(call_pos, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9112 Symbols::FactoryResult()); | 9124 Symbols::FactoryResult()); |
9113 } | 9125 } |
9114 return new_object; | 9126 return new_object; |
9115 } | 9127 } |
9116 | 9128 |
9117 | 9129 |
9118 String& Parser::Interpolate(ArrayNode* values) { | 9130 String& Parser::Interpolate(ArrayNode* values) { |
9119 const Class& cls = Class::Handle(LookupCoreClass(Symbols::StringBase())); | 9131 const Class& cls = Class::Handle(LookupCoreClass(Symbols::StringBase())); |
9120 ASSERT(!cls.IsNull()); | 9132 ASSERT(!cls.IsNull()); |
9121 const Function& func = | 9133 const Function& func = |
9122 Function::Handle(cls.LookupStaticFunction(Symbols::Interpolate())); | 9134 Function::Handle(cls.LookupStaticFunction( |
| 9135 PrivateCoreLibName(Symbols::Interpolate()))); |
9123 ASSERT(!func.IsNull()); | 9136 ASSERT(!func.IsNull()); |
9124 | 9137 |
9125 // Build the array of literal values to interpolate. | 9138 // Build the array of literal values to interpolate. |
9126 const Array& value_arr = Array::Handle(Array::New(values->length())); | 9139 const Array& value_arr = Array::Handle(Array::New(values->length())); |
9127 for (int i = 0; i < values->length(); i++) { | 9140 for (int i = 0; i < values->length(); i++) { |
9128 ASSERT(values->ElementAt(i)->IsLiteralNode()); | 9141 ASSERT(values->ElementAt(i)->IsLiteralNode()); |
9129 value_arr.SetAt(i, values->ElementAt(i)->AsLiteralNode()->literal()); | 9142 value_arr.SetAt(i, values->ElementAt(i)->AsLiteralNode()->literal()); |
9130 } | 9143 } |
9131 | 9144 |
9132 // Build argument array to pass to the interpolation function. | 9145 // Build argument array to pass to the interpolation function. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9204 values->AddElement(expr); | 9217 values->AddElement(expr); |
9205 } | 9218 } |
9206 } | 9219 } |
9207 if (is_compiletime_const) { | 9220 if (is_compiletime_const) { |
9208 primary = new LiteralNode(literal_start, Interpolate(values)); | 9221 primary = new LiteralNode(literal_start, Interpolate(values)); |
9209 } else { | 9222 } else { |
9210 ArgumentListNode* interpolate_arg = | 9223 ArgumentListNode* interpolate_arg = |
9211 new ArgumentListNode(values->token_pos()); | 9224 new ArgumentListNode(values->token_pos()); |
9212 interpolate_arg->Add(values); | 9225 interpolate_arg->Add(values); |
9213 primary = MakeStaticCall(Symbols::StringBase(), | 9226 primary = MakeStaticCall(Symbols::StringBase(), |
9214 Symbols::Interpolate(), | 9227 PrivateCoreLibName(Symbols::Interpolate()), |
9215 interpolate_arg); | 9228 interpolate_arg); |
9216 } | 9229 } |
9217 return primary; | 9230 return primary; |
9218 } | 9231 } |
9219 | 9232 |
9220 | 9233 |
9221 AstNode* Parser::ParseArgumentDefinitionTest() { | 9234 AstNode* Parser::ParseArgumentDefinitionTest() { |
9222 const intptr_t test_pos = TokenPos(); | 9235 const intptr_t test_pos = TokenPos(); |
9223 ConsumeToken(); | 9236 ConsumeToken(); |
9224 const intptr_t ident_pos = TokenPos(); | 9237 const intptr_t ident_pos = TokenPos(); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9706 void Parser::SkipQualIdent() { | 9719 void Parser::SkipQualIdent() { |
9707 ASSERT(IsIdentifier()); | 9720 ASSERT(IsIdentifier()); |
9708 ConsumeToken(); | 9721 ConsumeToken(); |
9709 if (CurrentToken() == Token::kPERIOD) { | 9722 if (CurrentToken() == Token::kPERIOD) { |
9710 ConsumeToken(); // Consume the kPERIOD token. | 9723 ConsumeToken(); // Consume the kPERIOD token. |
9711 ExpectIdentifier("identifier expected after '.'"); | 9724 ExpectIdentifier("identifier expected after '.'"); |
9712 } | 9725 } |
9713 } | 9726 } |
9714 | 9727 |
9715 } // namespace dart | 9728 } // namespace dart |
OLD | NEW |