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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
6 | 6 |
7 const USE_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); | 7 const USE_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); |
8 | 8 |
9 /** | 9 /** |
10 * Generates the code for all used classes in the program. Static fields (even | 10 * Generates the code for all used classes in the program. Static fields (even |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 void computeNeededLibraries() { | 314 void computeNeededLibraries() { |
315 void addSurroundingLibraryToSet(Element element) { | 315 void addSurroundingLibraryToSet(Element element) { |
316 OutputUnit unit = compiler.deferredLoadTask.outputUnitForElement(element); | 316 OutputUnit unit = compiler.deferredLoadTask.outputUnitForElement(element); |
317 LibraryElement library = element.library; | 317 LibraryElement library = element.library; |
318 outputLibraryLists.putIfAbsent(unit, () => new Set<LibraryElement>()) | 318 outputLibraryLists.putIfAbsent(unit, () => new Set<LibraryElement>()) |
319 .add(library); | 319 .add(library); |
320 } | 320 } |
321 | 321 |
322 backend.generatedCode.keys.forEach(addSurroundingLibraryToSet); | 322 backend.generatedCode.keys.forEach(addSurroundingLibraryToSet); |
323 neededClasses.forEach(addSurroundingLibraryToSet); | 323 neededClasses.forEach(addSurroundingLibraryToSet); |
324 } | 324 } |
325 | |
326 void computeNeeds() { | |
karlklose
2014/12/01 10:13:31
Perhaps you can find a better name than "needs". H
ahe
2014/12/01 10:28:35
Since most of the methods are called "computedNeed
ahe
2014/12/01 13:58:52
Discussed offline: I've renamed the method to comp
| |
327 // Compute the required type checks to know which classes need a | |
328 // 'is$' method. | |
329 typeTestEmitter.computeRequiredTypeChecks(); | |
330 | |
331 computeNeededDeclarations(); | |
332 computeNeededConstants(); | |
333 computeNeededStatics(); | |
334 computeNeededLibraries(); | |
335 } | |
325 | 336 |
326 void assembleProgram() { | 337 void assembleProgram() { |
327 measure(() { | 338 measure(() { |
328 emitter.invalidateCaches(); | 339 emitter.invalidateCaches(); |
329 | 340 |
330 // Compute the required type checks to know which classes need a | 341 computeNeeds(); |
331 // 'is$' method. | |
332 typeTestEmitter.computeRequiredTypeChecks(); | |
333 | |
334 computeNeededDeclarations(); | |
335 computeNeededConstants(); | |
336 computeNeededStatics(); | |
337 computeNeededLibraries(); | |
338 | |
339 | 342 |
340 Program program; | 343 Program program; |
341 if (USE_NEW_EMITTER) { | 344 if (USE_NEW_EMITTER) { |
342 program = new ProgramBuilder(compiler, namer, this).buildProgram(); | 345 program = new ProgramBuilder(compiler, namer, this).buildProgram(); |
343 } | 346 } |
344 emitter.emitProgram(program); | 347 emitter.emitProgram(program); |
345 }); | 348 }); |
346 } | 349 } |
347 } | 350 } |
348 | 351 |
349 abstract class Emitter { | 352 abstract class Emitter { |
350 void emitProgram(Program program); | 353 void emitProgram(Program program); |
351 | 354 |
352 jsAst.Expression generateEmbeddedGlobalAccess(String global); | 355 jsAst.Expression generateEmbeddedGlobalAccess(String global); |
353 jsAst.Expression constantReference(ConstantValue value); | 356 jsAst.Expression constantReference(ConstantValue value); |
354 | 357 |
355 int compareConstants(ConstantValue a, ConstantValue b); | 358 int compareConstants(ConstantValue a, ConstantValue b); |
356 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 359 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
357 | 360 |
358 void invalidateCaches(); | 361 void invalidateCaches(); |
359 } | 362 } |
OLD | NEW |