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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 " static fly() { return 5; }\n" | 285 " static fly() { return 5; }\n" |
286 "}\n"; | 286 "}\n"; |
287 | 287 |
288 String& url = String::Handle(String::New("dart-test:CompileScript")); | 288 String& url = String::Handle(String::New("dart-test:CompileScript")); |
289 String& source = String::Handle(String::New(kScriptChars)); | 289 String& source = String::Handle(String::New(kScriptChars)); |
290 Script& script = Script::Handle(Script::New(url, | 290 Script& script = Script::Handle(Script::New(url, |
291 source, | 291 source, |
292 RawScript::kSourceTag)); | 292 RawScript::kSourceTag)); |
293 Library& lib = MakeTestLibrary("TestLib"); | 293 Library& lib = MakeTestLibrary("TestLib"); |
294 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 294 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
295 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 295 EXPECT(ClassFinalizer::FinalizeAllClasses()); |
296 Class& cls = Class::Handle(LookupClass(lib, "A")); | 296 Class& cls = Class::Handle(LookupClass(lib, "A")); |
297 EXPECT(!cls.IsNull()); | 297 EXPECT(!cls.IsNull()); |
298 | 298 |
299 // 'bar' will not be compiled. | 299 // 'bar' will not be compiled. |
300 String& function_bar_name = String::Handle(String::New("bar")); | 300 String& function_bar_name = String::Handle(String::New("bar")); |
301 Function& function_bar = | 301 Function& function_bar = |
302 Function::ZoneHandle(cls.LookupStaticFunction(function_bar_name)); | 302 Function::ZoneHandle(cls.LookupStaticFunction(function_bar_name)); |
303 EXPECT(!function_bar.IsNull()); | 303 EXPECT(!function_bar.IsNull()); |
304 EXPECT(!function_bar.HasCode()); | 304 EXPECT(!function_bar.HasCode()); |
305 | 305 |
(...skipping 26 matching lines...) Expand all Loading... |
332 " int bar() { return 42; }\n" | 332 " int bar() { return 42; }\n" |
333 "}\n"; | 333 "}\n"; |
334 | 334 |
335 String& url = String::Handle(String::New("dart-test:CompileScript")); | 335 String& url = String::Handle(String::New("dart-test:CompileScript")); |
336 String& source = String::Handle(String::New(kScriptChars)); | 336 String& source = String::Handle(String::New(kScriptChars)); |
337 Script& script = Script::Handle(Script::New(url, | 337 Script& script = Script::Handle(Script::New(url, |
338 source, | 338 source, |
339 RawScript::kSourceTag)); | 339 RawScript::kSourceTag)); |
340 Library& lib = MakeTestLibrary("TestLib"); | 340 Library& lib = MakeTestLibrary("TestLib"); |
341 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 341 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
342 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 342 EXPECT(ClassFinalizer::FinalizeAllClasses()); |
343 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 343 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
344 EXPECT(!cls.IsNull()); | 344 EXPECT(!cls.IsNull()); |
345 | 345 |
346 String& constructor_name = String::Handle(String::New("A.")); | 346 String& constructor_name = String::Handle(String::New("A.")); |
347 Function& constructor = | 347 Function& constructor = |
348 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 348 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
349 EXPECT(!constructor.IsNull()); | 349 EXPECT(!constructor.IsNull()); |
350 | 350 |
351 // The unit test creates an instance of class A and calls function 'bar'. | 351 // The unit test creates an instance of class A and calls function 'bar'. |
352 String& function_bar_name = String::ZoneHandle(Symbols::New("bar")); | 352 String& function_bar_name = String::ZoneHandle(Symbols::New("bar")); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 " static bar() { return 42; }\n" | 472 " static bar() { return 42; }\n" |
473 "}\n"; | 473 "}\n"; |
474 | 474 |
475 String& url = String::Handle(String::New("dart-test:CompileScript")); | 475 String& url = String::Handle(String::New("dart-test:CompileScript")); |
476 String& source = String::Handle(String::New(kScriptChars)); | 476 String& source = String::Handle(String::New(kScriptChars)); |
477 Script& script = Script::Handle(Script::New(url, | 477 Script& script = Script::Handle(Script::New(url, |
478 source, | 478 source, |
479 RawScript::kSourceTag)); | 479 RawScript::kSourceTag)); |
480 Library& lib = MakeTestLibrary("TestLib"); | 480 Library& lib = MakeTestLibrary("TestLib"); |
481 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 481 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
482 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 482 EXPECT(ClassFinalizer::FinalizeAllClasses()); |
483 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 483 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
484 EXPECT(!cls.IsNull()); | 484 EXPECT(!cls.IsNull()); |
485 | 485 |
486 String& constructor_name = String::Handle(String::New("A.")); | 486 String& constructor_name = String::Handle(String::New("A.")); |
487 Function& constructor = | 487 Function& constructor = |
488 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 488 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
489 EXPECT(!constructor.IsNull()); | 489 EXPECT(!constructor.IsNull()); |
490 | 490 |
491 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); | 491 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); |
492 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); | 492 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); |
(...skipping 18 matching lines...) Expand all Loading... |
511 app_lib ^= libs.At(num_libs - 1); | 511 app_lib ^= libs.At(num_libs - 1); |
512 ASSERT(!app_lib.IsNull()); | 512 ASSERT(!app_lib.IsNull()); |
513 const Class& cls = Class::Handle( | 513 const Class& cls = Class::Handle( |
514 app_lib.LookupClass(String::Handle(Symbols::New("A")))); | 514 app_lib.LookupClass(String::Handle(Symbols::New("A")))); |
515 EXPECT_EQ(cls.raw(), result.clazz()); | 515 EXPECT_EQ(cls.raw(), result.clazz()); |
516 } | 516 } |
517 | 517 |
518 } // namespace dart | 518 } // namespace dart |
519 | 519 |
520 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) | 520 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) |
OLD | NEW |