| 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 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 8 | 8 |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 CODEGEN_TEST_GENERATE(StaticCallCodegen, test) { | 280 CODEGEN_TEST_GENERATE(StaticCallCodegen, test) { |
| 281 const char* kScriptChars = | 281 const char* kScriptChars = |
| 282 "class A {\n" | 282 "class A {\n" |
| 283 " static bar() { return 42; }\n" | 283 " static bar() { return 42; }\n" |
| 284 " static fly() { return 5; }\n" | 284 " static fly() { return 5; }\n" |
| 285 "}\n"; | 285 "}\n"; |
| 286 | 286 |
| 287 String& url = String::Handle(String::New("dart-test:CompileScript")); | 287 String& url = String::Handle(String::New("dart-test:CompileScript")); |
| 288 String& source = String::Handle(String::New(kScriptChars)); | 288 String& source = String::Handle(String::New(kScriptChars)); |
| 289 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); | 289 Script& script = Script::Handle(Script::New(url, |
| 290 source, |
| 291 RawScript::kSourceTag)); |
| 290 Library& lib = MakeTestLibrary("TestLib"); | 292 Library& lib = MakeTestLibrary("TestLib"); |
| 291 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 293 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 292 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 294 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
| 293 Class& cls = Class::Handle(LookupClass(lib, "A")); | 295 Class& cls = Class::Handle(LookupClass(lib, "A")); |
| 294 EXPECT(!cls.IsNull()); | 296 EXPECT(!cls.IsNull()); |
| 295 | 297 |
| 296 // 'bar' will not be compiled. | 298 // 'bar' will not be compiled. |
| 297 String& function_bar_name = String::Handle(String::New("bar")); | 299 String& function_bar_name = String::Handle(String::New("bar")); |
| 298 Function& function_bar = | 300 Function& function_bar = |
| 299 Function::ZoneHandle(cls.LookupStaticFunction(function_bar_name)); | 301 Function::ZoneHandle(cls.LookupStaticFunction(function_bar_name)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 324 | 326 |
| 325 CODEGEN_TEST_GENERATE(InstanceCallCodegen, test) { | 327 CODEGEN_TEST_GENERATE(InstanceCallCodegen, test) { |
| 326 const char* kScriptChars = | 328 const char* kScriptChars = |
| 327 "class A {\n" | 329 "class A {\n" |
| 328 " A() {}\n" | 330 " A() {}\n" |
| 329 " int bar() { return 42; }\n" | 331 " int bar() { return 42; }\n" |
| 330 "}\n"; | 332 "}\n"; |
| 331 | 333 |
| 332 String& url = String::Handle(String::New("dart-test:CompileScript")); | 334 String& url = String::Handle(String::New("dart-test:CompileScript")); |
| 333 String& source = String::Handle(String::New(kScriptChars)); | 335 String& source = String::Handle(String::New(kScriptChars)); |
| 334 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); | 336 Script& script = Script::Handle(Script::New(url, |
| 337 source, |
| 338 RawScript::kSourceTag)); |
| 335 Library& lib = MakeTestLibrary("TestLib"); | 339 Library& lib = MakeTestLibrary("TestLib"); |
| 336 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 340 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 337 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 341 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
| 338 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 342 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
| 339 EXPECT(!cls.IsNull()); | 343 EXPECT(!cls.IsNull()); |
| 340 | 344 |
| 341 String& constructor_name = String::Handle(String::New("A.")); | 345 String& constructor_name = String::Handle(String::New("A.")); |
| 342 Function& constructor = | 346 Function& constructor = |
| 343 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 347 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
| 344 EXPECT(!constructor.IsNull()); | 348 EXPECT(!constructor.IsNull()); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 // Test allocation of dart objects. | 466 // Test allocation of dart objects. |
| 463 CODEGEN_TEST_GENERATE(AllocateNewObjectCodegen, test) { | 467 CODEGEN_TEST_GENERATE(AllocateNewObjectCodegen, test) { |
| 464 const char* kScriptChars = | 468 const char* kScriptChars = |
| 465 "class A {\n" | 469 "class A {\n" |
| 466 " A() {}\n" | 470 " A() {}\n" |
| 467 " static bar() { return 42; }\n" | 471 " static bar() { return 42; }\n" |
| 468 "}\n"; | 472 "}\n"; |
| 469 | 473 |
| 470 String& url = String::Handle(String::New("dart-test:CompileScript")); | 474 String& url = String::Handle(String::New("dart-test:CompileScript")); |
| 471 String& source = String::Handle(String::New(kScriptChars)); | 475 String& source = String::Handle(String::New(kScriptChars)); |
| 472 Script& script = Script::Handle(Script::New(url, source, RawScript::kSource)); | 476 Script& script = Script::Handle(Script::New(url, |
| 477 source, |
| 478 RawScript::kSourceTag)); |
| 473 Library& lib = MakeTestLibrary("TestLib"); | 479 Library& lib = MakeTestLibrary("TestLib"); |
| 474 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 480 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
| 475 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 481 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
| 476 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 482 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
| 477 EXPECT(!cls.IsNull()); | 483 EXPECT(!cls.IsNull()); |
| 478 | 484 |
| 479 String& constructor_name = String::Handle(String::New("A.")); | 485 String& constructor_name = String::Handle(String::New("A.")); |
| 480 Function& constructor = | 486 Function& constructor = |
| 481 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 487 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
| 482 EXPECT(!constructor.IsNull()); | 488 EXPECT(!constructor.IsNull()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 504 app_lib ^= libs.At(num_libs - 1); | 510 app_lib ^= libs.At(num_libs - 1); |
| 505 ASSERT(!app_lib.IsNull()); | 511 ASSERT(!app_lib.IsNull()); |
| 506 const Class& cls = Class::Handle( | 512 const Class& cls = Class::Handle( |
| 507 app_lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 513 app_lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
| 508 EXPECT_EQ(cls.raw(), result.clazz()); | 514 EXPECT_EQ(cls.raw(), result.clazz()); |
| 509 } | 515 } |
| 510 | 516 |
| 511 } // namespace dart | 517 } // namespace dart |
| 512 | 518 |
| 513 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) | 519 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) |
| OLD | NEW |