| 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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 | 1292 |
| 1293 | 1293 |
| 1294 // Lookup class in the corelib implementation which contains various VM | 1294 // Lookup class in the corelib implementation which contains various VM |
| 1295 // helper methods and classes. | 1295 // helper methods and classes. |
| 1296 static RawClass* LookupImplClass(const String& class_name) { | 1296 static RawClass* LookupImplClass(const String& class_name) { |
| 1297 Library& coreimpl = Library::Handle(Library::CoreImplLibrary()); | 1297 Library& coreimpl = Library::Handle(Library::CoreImplLibrary()); |
| 1298 return coreimpl.LookupClassAllowPrivate(class_name); | 1298 return coreimpl.LookupClassAllowPrivate(class_name); |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 | 1301 |
| 1302 // Lookup class in the coreimpl lib which also contains various VM | 1302 // Lookup class in the core lib which also contains various VM |
| 1303 // helper methods and classes. Allow look up of private classes. | 1303 // helper methods and classes. Allow look up of private classes. |
| 1304 static RawClass* LookupCoreImplClass(const String& class_name) { | 1304 static RawClass* LookupCoreClass(const String& class_name) { |
| 1305 const Library& coreimpl_lib = Library::Handle(Library::CoreImplLibrary()); | 1305 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 1306 String& name = String::Handle(class_name.raw()); | 1306 String& name = String::Handle(class_name.raw()); |
| 1307 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { | 1307 if (class_name.CharAt(0) == Scanner::kPrivateIdentifierStart) { |
| 1308 // Private identifiers are mangled on a per script basis. | 1308 // Private identifiers are mangled on a per script basis. |
| 1309 name = String::Concat(name, String::Handle(coreimpl_lib.private_key())); | 1309 name = String::Concat(name, String::Handle(core_lib.private_key())); |
| 1310 name = Symbols::New(name); | 1310 name = Symbols::New(name); |
| 1311 } | 1311 } |
| 1312 return coreimpl_lib.LookupClass(name); | 1312 return core_lib.LookupClass(name); |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 | 1315 |
| 1316 ArgumentListNode* Parser::BuildNoSuchMethodArguments( | 1316 ArgumentListNode* Parser::BuildNoSuchMethodArguments( |
| 1317 const String& function_name, | 1317 const String& function_name, |
| 1318 const ArgumentListNode& function_args) { | 1318 const ArgumentListNode& function_args) { |
| 1319 ASSERT(function_args.length() >= 1); // The receiver is the first argument. | 1319 ASSERT(function_args.length() >= 1); // The receiver is the first argument. |
| 1320 const intptr_t args_pos = function_args.token_pos(); | 1320 const intptr_t args_pos = function_args.token_pos(); |
| 1321 ArgumentListNode* arguments = new ArgumentListNode(args_pos); | 1321 ArgumentListNode* arguments = new ArgumentListNode(args_pos); |
| 1322 arguments->Add(function_args.NodeAt(0)); | 1322 arguments->Add(function_args.NodeAt(0)); |
| (...skipping 7311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8634 const_list.SetAt(i, elem->AsLiteralNode()->literal()); | 8634 const_list.SetAt(i, elem->AsLiteralNode()->literal()); |
| 8635 } | 8635 } |
| 8636 const_list ^= const_list.Canonicalize(); | 8636 const_list ^= const_list.Canonicalize(); |
| 8637 const_list.MakeImmutable(); | 8637 const_list.MakeImmutable(); |
| 8638 return new LiteralNode(literal_pos, const_list); | 8638 return new LiteralNode(literal_pos, const_list); |
| 8639 } else { | 8639 } else { |
| 8640 // Factory call at runtime. | 8640 // Factory call at runtime. |
| 8641 String& list_literal_factory_class_name = String::Handle( | 8641 String& list_literal_factory_class_name = String::Handle( |
| 8642 Symbols::ListLiteralFactoryClass()); | 8642 Symbols::ListLiteralFactoryClass()); |
| 8643 const Class& list_literal_factory_class = | 8643 const Class& list_literal_factory_class = |
| 8644 Class::Handle(LookupCoreImplClass(list_literal_factory_class_name)); | 8644 Class::Handle(LookupCoreClass(list_literal_factory_class_name)); |
| 8645 ASSERT(!list_literal_factory_class.IsNull()); | 8645 ASSERT(!list_literal_factory_class.IsNull()); |
| 8646 const String& list_literal_factory_name = | 8646 const String& list_literal_factory_name = |
| 8647 String::Handle(Symbols::ListLiteralFactory()); | 8647 String::Handle(Symbols::ListLiteralFactory()); |
| 8648 const Function& list_literal_factory = Function::ZoneHandle( | 8648 const Function& list_literal_factory = Function::ZoneHandle( |
| 8649 list_literal_factory_class.LookupFactory(list_literal_factory_name)); | 8649 list_literal_factory_class.LookupFactory(list_literal_factory_name)); |
| 8650 ASSERT(!list_literal_factory.IsNull()); | 8650 ASSERT(!list_literal_factory.IsNull()); |
| 8651 if (!type_arguments.IsNull() && | 8651 if (!type_arguments.IsNull() && |
| 8652 !type_arguments.IsInstantiated() && | 8652 !type_arguments.IsInstantiated() && |
| 8653 (current_block_->scope->function_level() > 0)) { | 8653 (current_block_->scope->function_level() > 0)) { |
| 8654 // Make sure that the instantiator is captured. | 8654 // Make sure that the instantiator is captured. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8859 } else { | 8859 } else { |
| 8860 const Instance& const_instance = Instance::Cast(constructor_result); | 8860 const Instance& const_instance = Instance::Cast(constructor_result); |
| 8861 return new LiteralNode(literal_pos, | 8861 return new LiteralNode(literal_pos, |
| 8862 Instance::ZoneHandle(const_instance.raw())); | 8862 Instance::ZoneHandle(const_instance.raw())); |
| 8863 } | 8863 } |
| 8864 } else { | 8864 } else { |
| 8865 // Factory call at runtime. | 8865 // Factory call at runtime. |
| 8866 String& map_literal_factory_class_name = String::Handle( | 8866 String& map_literal_factory_class_name = String::Handle( |
| 8867 Symbols::MapLiteralFactoryClass()); | 8867 Symbols::MapLiteralFactoryClass()); |
| 8868 const Class& map_literal_factory_class = | 8868 const Class& map_literal_factory_class = |
| 8869 Class::Handle(LookupCoreImplClass(map_literal_factory_class_name)); | 8869 Class::Handle(LookupCoreClass(map_literal_factory_class_name)); |
| 8870 ASSERT(!map_literal_factory_class.IsNull()); | 8870 ASSERT(!map_literal_factory_class.IsNull()); |
| 8871 const String& map_literal_factory_name = | 8871 const String& map_literal_factory_name = |
| 8872 String::Handle(Symbols::MapLiteralFactory()); | 8872 String::Handle(Symbols::MapLiteralFactory()); |
| 8873 const Function& map_literal_factory = Function::ZoneHandle( | 8873 const Function& map_literal_factory = Function::ZoneHandle( |
| 8874 map_literal_factory_class.LookupFactory(map_literal_factory_name)); | 8874 map_literal_factory_class.LookupFactory(map_literal_factory_name)); |
| 8875 ASSERT(!map_literal_factory.IsNull()); | 8875 ASSERT(!map_literal_factory.IsNull()); |
| 8876 if (!map_type_arguments.IsNull() && | 8876 if (!map_type_arguments.IsNull() && |
| 8877 !map_type_arguments.IsInstantiated() && | 8877 !map_type_arguments.IsInstantiated() && |
| 8878 (current_block_->scope->function_level() > 0)) { | 8878 (current_block_->scope->function_level() > 0)) { |
| 8879 // Make sure that the instantiator is captured. | 8879 // Make sure that the instantiator is captured. |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9840 void Parser::SkipQualIdent() { | 9840 void Parser::SkipQualIdent() { |
| 9841 ASSERT(IsIdentifier()); | 9841 ASSERT(IsIdentifier()); |
| 9842 ConsumeToken(); | 9842 ConsumeToken(); |
| 9843 if (CurrentToken() == Token::kPERIOD) { | 9843 if (CurrentToken() == Token::kPERIOD) { |
| 9844 ConsumeToken(); // Consume the kPERIOD token. | 9844 ConsumeToken(); // Consume the kPERIOD token. |
| 9845 ExpectIdentifier("identifier expected after '.'"); | 9845 ExpectIdentifier("identifier expected after '.'"); |
| 9846 } | 9846 } |
| 9847 } | 9847 } |
| 9848 | 9848 |
| 9849 } // namespace dart | 9849 } // namespace dart |
| OLD | NEW |