OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 library dart2js.kernel.closed_world_test; | |
6 | |
7 import 'package:async_helper/async_helper.dart'; | |
8 import 'package:compiler/src/commandline_options.dart'; | |
9 import 'package:compiler/src/common.dart'; | |
10 import 'package:compiler/src/common/names.dart'; | |
11 import 'package:compiler/src/common/resolution.dart'; | |
12 import 'package:compiler/src/compiler.dart'; | |
13 import 'package:compiler/src/constants/expressions.dart'; | |
14 import 'package:compiler/src/dart_types.dart'; | |
15 import 'package:compiler/src/elements/elements.dart'; | |
16 import 'package:compiler/src/enqueue.dart'; | |
17 import 'package:compiler/src/js_backend/backend.dart'; | |
18 import 'package:compiler/src/js_backend/type_variable_handler.dart'; | |
19 import 'package:compiler/src/resolution/registry.dart'; | |
20 import 'package:compiler/src/resolution/tree_elements.dart'; | |
21 import 'package:compiler/src/ssa/kernel_impact.dart'; | |
22 import 'package:compiler/src/serialization/equivalence.dart'; | |
23 import 'package:compiler/src/universe/call_structure.dart'; | |
24 import 'package:compiler/src/universe/feature.dart'; | |
25 import 'package:compiler/src/universe/world_impact.dart'; | |
26 import 'package:compiler/src/world.dart'; | |
27 import 'package:expect/expect.dart'; | |
28 import 'impact_test.dart'; | |
29 import '../memory_compiler.dart'; | |
30 import '../serialization/helper.dart'; | |
31 import '../serialization/model_test_helper.dart'; | |
32 | |
33 const SOURCE = const { | |
34 'main.dart': ''' | |
35 main() { | |
36 print('Hello World!'); | |
37 } | |
38 ''' | |
39 }; | |
40 | |
41 main(List<String> args) { | |
Harry Terkelsen
2016/11/11 18:41:59
Can you write a comment explaining what exactly th
Johnni Winther
2016/11/14 10:05:26
That is exactly what I'm doing :) Added a library
| |
42 Arguments arguments = new Arguments.from(args); | |
43 Uri entryPoint; | |
44 Map<String, String> memorySourceFiles; | |
45 if (arguments.uri != null) { | |
46 entryPoint = arguments.uri; | |
47 memorySourceFiles = const <String, String>{}; | |
48 } else { | |
49 entryPoint = Uri.parse('memory:main.dart'); | |
50 memorySourceFiles = SOURCE; | |
51 } | |
52 | |
53 asyncTest(() async { | |
54 enableDebugMode(); | |
55 Compiler compiler = compilerFor( | |
56 entryPoint: entryPoint, | |
57 memorySourceFiles: memorySourceFiles, | |
58 options: [ | |
59 Flags.analyzeOnly, | |
60 Flags.useKernel, | |
61 Flags.enableAssertMessage | |
62 ]); | |
63 compiler.resolution.retainCachesForTesting = true; | |
64 await compiler.run(entryPoint); | |
65 compiler.openWorld.closeWorld(compiler.reporter); | |
66 | |
67 JavaScriptBackend backend = compiler.backend; | |
68 ResolutionEnqueuer enqueuer = new ResolutionEnqueuer( | |
69 compiler.enqueuer, | |
70 compiler.options, | |
71 compiler.resolution, | |
72 compiler.enqueuerFilter, | |
73 const TreeShakingEnqueuerStrategy(), | |
74 compiler.globalDependencies, | |
75 backend, | |
76 compiler.commonElements, | |
77 compiler.cacheStrategy); | |
78 // TODO(johnniwinther): Store backend info separately. This replacement is | |
79 // made to reset a field in [TypeVariableHandler] the prevents it from | |
Harry Terkelsen
2016/11/11 18:41:59
the prevents -> that prevents
Johnni Winther
2016/11/14 10:05:26
Done.
| |
80 // enqueuing twice. | |
81 backend.typeVariableHandler = new TypeVariableHandler(compiler); | |
82 | |
83 backend.enqueueHelpers(enqueuer); | |
84 enqueuer.addToWorkList(compiler.mainFunction); | |
85 enqueuer.forEach((work) { | |
86 AstElement element = work.element; | |
87 ResolutionImpact resolutionImpact = build(compiler, element.resolvedAst); | |
88 WorldImpact worldImpact = compiler.backend.impactTransformer | |
89 .transformResolutionImpact(enqueuer, resolutionImpact); | |
90 enqueuer.registerProcessedElement(element); | |
91 enqueuer.applyImpact(compiler.impactStrategy, worldImpact, | |
92 impactSource: element); | |
93 }); | |
94 ClosedWorld closedWorld = | |
95 enqueuer.universe.openWorld.closeWorld(compiler.reporter); | |
96 | |
97 checkResolutionEnqueuers(compiler.enqueuer.resolution, enqueuer, | |
98 typeEquivalence: (DartType a, DartType b) { | |
99 return areTypesEquivalent(unalias(a), unalias(b)); | |
100 }, elementFilter: (Element element) { | |
101 if (element is ConstructorElement && element.isRedirectingFactory) { | |
102 // Redirecting factory constructors are skipped in kernel. | |
103 return false; | |
104 } | |
105 return true; | |
106 }, verbose: arguments.verbose); | |
107 checkClosedWorlds(compiler.closedWorld, closedWorld, | |
108 verbose: arguments.verbose); | |
109 }); | |
110 } | |
OLD | NEW |