Chromium Code Reviews| 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 #import('dart:uri'); | 5 #import('dart:uri'); |
| 6 #import('parser_helper.dart'); | 6 #import('parser_helper.dart'); |
| 7 #import('mock_compiler.dart'); | 7 #import('mock_compiler.dart'); |
| 8 #import("../../../lib/compiler/compiler.dart"); | 8 #import("../../../lib/compiler/compiler.dart"); |
| 9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg'); | 9 #import("../../../lib/compiler/implementation/leg.dart", prefix:'leg'); |
| 10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); | 10 #import("../../../lib/compiler/implementation/dart_backend/dart_backend.dart"); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 'set p_topgetset(arg){}' | 467 'set p_topgetset(arg){}' |
| 468 'main(){p_topgetset;p_topgetset=6;topgetset;topgetset=5;}'; | 468 'main(){p_topgetset;p_topgetset=6;topgetset;topgetset=5;}'; |
| 469 testDart2DartWithLibrary(mainSrc, librarySrc, | 469 testDart2DartWithLibrary(mainSrc, librarySrc, |
| 470 (String result) { Expect.equals(expectedResult, result); }); | 470 (String result) { Expect.equals(expectedResult, result); }); |
| 471 } | 471 } |
| 472 | 472 |
| 473 testFieldTypeOutput() { | 473 testFieldTypeOutput() { |
| 474 testDart2Dart('main(){new A().field;}class B{}class A{B field;}'); | 474 testDart2Dart('main(){new A().field;}class B{}class A{B field;}'); |
| 475 } | 475 } |
| 476 | 476 |
| 477 class DynoMap implements Map<Element, ElementAst> { | |
|
Roman
2012/09/07 08:10:56
I don't understand "DynoMap" name, what does it me
Anton Muhin
2012/09/07 12:26:07
Name is horrible, sorry. I meant that there is no
| |
| 478 final compiler; | |
| 479 DynoMap(this.compiler); | |
| 480 | |
| 481 get resolvedElements => compiler.enqueuer.resolution.resolvedElements; | |
| 482 ElementAst operator[](Element element) => | |
| 483 new ElementAst(element.parseNode(compiler), resolvedElements[element]); | |
| 484 } | |
| 485 | |
| 486 PlaceholderCollector collectPlaceholders(compiler, element) => | |
| 487 new PlaceholderCollector(compiler, new Set<String>(), new DynoMap(compiler)) | |
| 488 ..collect(element); | |
| 489 | |
| 477 testLocalFunctionPlaceholder() { | 490 testLocalFunctionPlaceholder() { |
| 478 var src = ''' | 491 var src = ''' |
| 479 main() { | 492 main() { |
| 480 function localfoo() {} | 493 function localfoo() {} |
| 481 localfoo(); | 494 localfoo(); |
| 482 } | 495 } |
| 483 '''; | 496 '''; |
| 484 MockCompiler compiler = new MockCompiler(); | 497 MockCompiler compiler = new MockCompiler(); |
| 485 compiler.parseScript(src); | 498 compiler.parseScript(src); |
| 486 FunctionElement mainElement = compiler.mainApp.find(leg.Compiler.MAIN); | 499 FunctionElement mainElement = compiler.mainApp.find(leg.Compiler.MAIN); |
| 487 compiler.processQueue(compiler.enqueuer.resolution, mainElement); | 500 compiler.processQueue(compiler.enqueuer.resolution, mainElement); |
| 488 PlaceholderCollector collector = | 501 PlaceholderCollector collector = collectPlaceholders(compiler, mainElement); |
| 489 new PlaceholderCollector(compiler, new Set<String>()); | |
| 490 collector.collect(mainElement, | |
| 491 compiler.enqueuer.resolution.resolvedElements[mainElement]); | |
| 492 FunctionExpression mainNode = mainElement.parseNode(compiler); | 502 FunctionExpression mainNode = mainElement.parseNode(compiler); |
| 493 FunctionExpression fooNode = mainNode.body.statements.nodes.head.function; | 503 FunctionExpression fooNode = mainNode.body.statements.nodes.head.function; |
| 494 LocalPlaceholder fooPlaceholder = | 504 LocalPlaceholder fooPlaceholder = |
| 495 collector.functionScopes[mainElement].localPlaceholders.iterator().next(); | 505 collector.functionScopes[mainElement].localPlaceholders.iterator().next(); |
| 496 Expect.isTrue(fooPlaceholder.nodes.contains(fooNode.name)); | 506 Expect.isTrue(fooPlaceholder.nodes.contains(fooNode.name)); |
| 497 } | 507 } |
| 498 | 508 |
| 499 testDefaultClassNamePlaceholder() { | 509 testDefaultClassNamePlaceholder() { |
| 500 var src = ''' | 510 var src = ''' |
| 501 interface I default C{ | 511 interface I default C{ |
| 502 I(); | 512 I(); |
| 503 } | 513 } |
| 504 | 514 |
| 505 class C { | 515 class C { |
| 506 I() {} | 516 I() {} |
| 507 } | 517 } |
| 508 | 518 |
| 509 main() { | 519 main() { |
| 510 new I(); | 520 new I(); |
| 511 } | 521 } |
| 512 '''; | 522 '''; |
| 513 MockCompiler compiler = new MockCompiler(); | 523 MockCompiler compiler = new MockCompiler(); |
| 514 compiler.parseScript(src); | 524 compiler.parseScript(src); |
| 515 ClassElement interfaceElement = compiler.mainApp.find(buildSourceString('I')); | 525 ClassElement interfaceElement = compiler.mainApp.find(buildSourceString('I')); |
| 516 interfaceElement.ensureResolved(compiler); | 526 interfaceElement.ensureResolved(compiler); |
| 517 PlaceholderCollector collector = | 527 PlaceholderCollector collector = |
| 518 new PlaceholderCollector(compiler, new Set<String>()); | 528 collectPlaceholders(compiler, interfaceElement); |
| 519 collector.collect(interfaceElement, | |
| 520 compiler.enqueuer.resolution.resolvedElements[interfaceElement]); | |
| 521 ClassNode interfaceNode = interfaceElement.parseNode(compiler); | 529 ClassNode interfaceNode = interfaceElement.parseNode(compiler); |
| 522 Node defaultTypeNode = interfaceNode.defaultClause.typeName; | 530 Node defaultTypeNode = interfaceNode.defaultClause.typeName; |
| 523 ClassElement classElement = compiler.mainApp.find(buildSourceString('C')); | 531 ClassElement classElement = compiler.mainApp.find(buildSourceString('C')); |
| 524 // Check that 'C' in default clause of I gets into placeholders. | 532 // Check that 'C' in default clause of I gets into placeholders. |
| 525 Expect.isTrue(collector.elementNodes[classElement].contains(defaultTypeNode)); | 533 Expect.isTrue(collector.elementNodes[classElement].contains(defaultTypeNode)); |
| 526 } | 534 } |
| 527 | 535 |
| 528 testFactoryRename() { | 536 testFactoryRename() { |
| 529 var librarySrc = ''' | 537 var librarySrc = ''' |
| 530 #library('mylib'); | 538 #library('mylib'); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 850 testDoubleMains(); | 858 testDoubleMains(); |
| 851 testInterfaceDefaultAnotherLib(); | 859 testInterfaceDefaultAnotherLib(); |
| 852 testStaticAccessIoLib(); | 860 testStaticAccessIoLib(); |
| 853 testLocalFunctionPlaceholder(); | 861 testLocalFunctionPlaceholder(); |
| 854 testMinification(); | 862 testMinification(); |
| 855 testClosureLocalsMinified(); | 863 testClosureLocalsMinified(); |
| 856 testParametersMinified(); | 864 testParametersMinified(); |
| 857 testTypeVariablesInDifferentLibraries(); | 865 testTypeVariablesInDifferentLibraries(); |
| 858 testDeclarationTypePlaceholders(); | 866 testDeclarationTypePlaceholders(); |
| 859 } | 867 } |
| OLD | NEW |