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 library compiler_helper; | 5 library compiler_helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 | 9 |
10 import 'package:compiler/src/elements/elements.dart' | 10 import 'package:compiler/src/elements/elements.dart' |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, | 73 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, |
74 outputProvider: outputCollector); | 74 outputProvider: outputCollector); |
75 await compiler.init(); | 75 await compiler.init(); |
76 compiler.parseScript(code); | 76 compiler.parseScript(code); |
77 lego.Element element = compiler.mainApp.find(entry); | 77 lego.Element element = compiler.mainApp.find(entry); |
78 if (element == null) return null; | 78 if (element == null) return null; |
79 compiler.phase = Compiler.PHASE_RESOLVING; | 79 compiler.phase = Compiler.PHASE_RESOLVING; |
80 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution, | 80 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution, |
81 compiler.globalDependencies); | 81 compiler.globalDependencies); |
82 compiler.processQueue(compiler.enqueuer.resolution, element); | 82 compiler.processQueue(compiler.enqueuer.resolution, element); |
83 compiler.world.populate(); | 83 compiler.openWorld.populate(); |
84 compiler.backend.onResolutionComplete(); | 84 compiler.backend.onResolutionComplete(); |
85 ResolutionWorkItem resolutionWork = new ResolutionWorkItem(element); | 85 ResolutionWorkItem resolutionWork = new ResolutionWorkItem(element); |
86 resolutionWork.run(compiler, compiler.enqueuer.resolution); | 86 resolutionWork.run(compiler, compiler.enqueuer.resolution); |
87 CodegenWorkItem work = new CodegenWorkItem(compiler, element); | 87 CodegenWorkItem work = new CodegenWorkItem(compiler, element); |
88 compiler.phase = Compiler.PHASE_COMPILING; | 88 compiler.phase = Compiler.PHASE_COMPILING; |
89 work.run(compiler, compiler.enqueuer.codegen); | 89 work.run(compiler, compiler.enqueuer.codegen); |
90 js.JavaScriptBackend backend = compiler.backend; | 90 js.JavaScriptBackend backend = compiler.backend; |
91 String generated = backend.getGeneratedCode(element); | 91 String generated = backend.getGeneratedCode(element); |
92 if (check != null) { | 92 if (check != null) { |
93 check(generated); | 93 check(generated); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 var element = compiler.mainApp.find(sourceName); | 208 var element = compiler.mainApp.find(sourceName); |
209 if (element == null) { | 209 if (element == null) { |
210 element = compiler.backend.helpers.interceptorsLibrary.find(sourceName); | 210 element = compiler.backend.helpers.interceptorsLibrary.find(sourceName); |
211 } | 211 } |
212 if (element == null) { | 212 if (element == null) { |
213 element = compiler.commonElements.coreLibrary.find(sourceName); | 213 element = compiler.commonElements.coreLibrary.find(sourceName); |
214 } | 214 } |
215 Expect.isNotNull(element, 'Could not locate $name'); | 215 Expect.isNotNull(element, 'Could not locate $name'); |
216 switch (how) { | 216 switch (how) { |
217 case 'exact': | 217 case 'exact': |
218 return new types.TypeMask.exact(element, compiler.world); | 218 return new types.TypeMask.exact(element, compiler.closedWorld); |
219 case 'nonNullExact': | 219 case 'nonNullExact': |
220 return new types.TypeMask.nonNullExact(element, compiler.world); | 220 return new types.TypeMask.nonNullExact(element, compiler.closedWorld); |
221 case 'subclass': | 221 case 'subclass': |
222 return new types.TypeMask.subclass(element, compiler.world); | 222 return new types.TypeMask.subclass(element, compiler.closedWorld); |
223 case 'nonNullSubclass': | 223 case 'nonNullSubclass': |
224 return new types.TypeMask.nonNullSubclass(element, compiler.world); | 224 return new types.TypeMask.nonNullSubclass(element, compiler.closedWorld); |
225 case 'subtype': | 225 case 'subtype': |
226 return new types.TypeMask.subtype(element, compiler.world); | 226 return new types.TypeMask.subtype(element, compiler.closedWorld); |
227 case 'nonNullSubtype': | 227 case 'nonNullSubtype': |
228 return new types.TypeMask.nonNullSubtype(element, compiler.world); | 228 return new types.TypeMask.nonNullSubtype(element, compiler.closedWorld); |
229 } | 229 } |
230 Expect.fail('Unknown TypeMask constructor $how'); | 230 Expect.fail('Unknown TypeMask constructor $how'); |
231 return null; | 231 return null; |
232 } | 232 } |
233 | 233 |
234 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; | 234 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; |
235 | 235 |
236 String getIntTypeCheck(String variable) { | 236 String getIntTypeCheck(String variable) { |
237 return "\\($variable ?!== ?\\($variable ?\\| ?0\\)|" | 237 return "\\($variable ?!== ?\\($variable ?\\| ?0\\)|" |
238 "\\($variable ?>>> ?0 ?!== ?$variable"; | 238 "\\($variable ?>>> ?0 ?!== ?$variable"; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 287 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
288 final spaceRe = new RegExp('\\s+'); | 288 final spaceRe = new RegExp('\\s+'); |
289 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 289 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
290 if (shouldMatch) { | 290 if (shouldMatch) { |
291 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 291 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
292 } else { | 292 } else { |
293 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 293 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
294 } | 294 } |
295 }); | 295 }); |
296 } | 296 } |
OLD | NEW |