| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/globals.h" | 6 #include "vm/globals.h" |
| 7 #include "vm/ast.h" | 7 #include "vm/ast.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 " static fly() { return 5; }\n" | 286 " static fly() { return 5; }\n" |
| 287 "}\n"; | 287 "}\n"; |
| 288 | 288 |
| 289 String& url = String::Handle(String::New("dart-test:CompileScript")); | 289 String& url = String::Handle(String::New("dart-test:CompileScript")); |
| 290 String& source = String::Handle(String::New(kScriptChars)); | 290 String& source = String::Handle(String::New(kScriptChars)); |
| 291 Script& script = Script::Handle(Script::New(url, | 291 Script& script = Script::Handle(Script::New(url, |
| 292 source, | 292 source, |
| 293 RawScript::kScriptTag)); | 293 RawScript::kScriptTag)); |
| 294 Library& lib = MakeTestLibrary("TestLib"); | 294 Library& lib = MakeTestLibrary("TestLib"); |
| 295 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 295 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 296 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 296 EXPECT(ClassFinalizer::FinalizePendingClassInterfaces()); |
| 297 Class& cls = Class::Handle(LookupClass(lib, "A")); | 297 Class& cls = Class::Handle(LookupClass(lib, "A")); |
| 298 EXPECT(!cls.IsNull()); | 298 EXPECT(!cls.IsNull()); |
| 299 | 299 |
| 300 // 'bar' will not be compiled. | 300 // 'bar' will not be compiled. |
| 301 String& function_bar_name = String::Handle(String::New("bar")); | 301 String& function_bar_name = String::Handle(String::New("bar")); |
| 302 Function& function_bar = | 302 Function& function_bar = |
| 303 Function::ZoneHandle(cls.LookupStaticFunction(function_bar_name)); | 303 Function::ZoneHandle(cls.LookupStaticFunction(function_bar_name)); |
| 304 EXPECT(!function_bar.IsNull()); | 304 EXPECT(!function_bar.IsNull()); |
| 305 EXPECT(!function_bar.HasCode()); | 305 EXPECT(!function_bar.HasCode()); |
| 306 | 306 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 333 " int bar() { return 42; }\n" | 333 " int bar() { return 42; }\n" |
| 334 "}\n"; | 334 "}\n"; |
| 335 | 335 |
| 336 String& url = String::Handle(String::New("dart-test:CompileScript")); | 336 String& url = String::Handle(String::New("dart-test:CompileScript")); |
| 337 String& source = String::Handle(String::New(kScriptChars)); | 337 String& source = String::Handle(String::New(kScriptChars)); |
| 338 Script& script = Script::Handle(Script::New(url, | 338 Script& script = Script::Handle(Script::New(url, |
| 339 source, | 339 source, |
| 340 RawScript::kScriptTag)); | 340 RawScript::kScriptTag)); |
| 341 Library& lib = MakeTestLibrary("TestLib"); | 341 Library& lib = MakeTestLibrary("TestLib"); |
| 342 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 342 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 343 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 343 EXPECT(ClassFinalizer::FinalizePendingClassInterfaces()); |
| 344 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 344 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
| 345 EXPECT(!cls.IsNull()); | 345 EXPECT(!cls.IsNull()); |
| 346 | 346 |
| 347 String& constructor_name = String::Handle(String::New("A.")); | 347 String& constructor_name = String::Handle(String::New("A.")); |
| 348 Function& constructor = | 348 Function& constructor = |
| 349 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 349 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
| 350 EXPECT(!constructor.IsNull()); | 350 EXPECT(!constructor.IsNull()); |
| 351 | 351 |
| 352 // The unit test creates an instance of class A and calls function 'bar'. | 352 // The unit test creates an instance of class A and calls function 'bar'. |
| 353 String& function_bar_name = String::ZoneHandle(Symbols::New("bar")); | 353 String& function_bar_name = String::ZoneHandle(Symbols::New("bar")); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 " static bar() { return 42; }\n" | 525 " static bar() { return 42; }\n" |
| 526 "}\n"; | 526 "}\n"; |
| 527 | 527 |
| 528 String& url = String::Handle(String::New("dart-test:CompileScript")); | 528 String& url = String::Handle(String::New("dart-test:CompileScript")); |
| 529 String& source = String::Handle(String::New(kScriptChars)); | 529 String& source = String::Handle(String::New(kScriptChars)); |
| 530 Script& script = Script::Handle(Script::New(url, | 530 Script& script = Script::Handle(Script::New(url, |
| 531 source, | 531 source, |
| 532 RawScript::kScriptTag)); | 532 RawScript::kScriptTag)); |
| 533 Library& lib = MakeTestLibrary("TestLib"); | 533 Library& lib = MakeTestLibrary("TestLib"); |
| 534 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 534 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 535 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 535 EXPECT(ClassFinalizer::FinalizePendingClassInterfaces()); |
| 536 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 536 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
| 537 EXPECT(!cls.IsNull()); | 537 EXPECT(!cls.IsNull()); |
| 538 | 538 |
| 539 String& constructor_name = String::Handle(String::New("A.")); | 539 String& constructor_name = String::Handle(String::New("A.")); |
| 540 Function& constructor = | 540 Function& constructor = |
| 541 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 541 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
| 542 EXPECT(!constructor.IsNull()); | 542 EXPECT(!constructor.IsNull()); |
| 543 | 543 |
| 544 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); | 544 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); |
| 545 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); | 545 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 559 intptr_t num_libs = libs.Length(); | 559 intptr_t num_libs = libs.Length(); |
| 560 Library& app_lib = Library::Handle(); | 560 Library& app_lib = Library::Handle(); |
| 561 app_lib ^= libs.At(num_libs - 1); | 561 app_lib ^= libs.At(num_libs - 1); |
| 562 ASSERT(!app_lib.IsNull()); | 562 ASSERT(!app_lib.IsNull()); |
| 563 const Class& cls = Class::Handle( | 563 const Class& cls = Class::Handle( |
| 564 app_lib.LookupClass(String::Handle(Symbols::New("A")))); | 564 app_lib.LookupClass(String::Handle(Symbols::New("A")))); |
| 565 EXPECT_EQ(cls.raw(), result.clazz()); | 565 EXPECT_EQ(cls.raw(), result.clazz()); |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace dart | 568 } // namespace dart |
| OLD | NEW |