| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 computeNeededStaticNonFinalFields(); | 408 computeNeededStaticNonFinalFields(); |
| 409 computeNeededLibraries(); | 409 computeNeededLibraries(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 int assembleProgram() { | 412 int assembleProgram() { |
| 413 return measure(() { | 413 return measure(() { |
| 414 emitter.invalidateCaches(); | 414 emitter.invalidateCaches(); |
| 415 | 415 |
| 416 computeAllNeededEntities(); | 416 computeAllNeededEntities(); |
| 417 | 417 |
| 418 Program program; | 418 Program program = |
| 419 if (USE_NEW_EMITTER) { | 419 new ProgramBuilder(compiler, namer, this).buildProgram(); |
| 420 program = new ProgramBuilder(compiler, namer, this).buildProgram(); | |
| 421 } | |
| 422 return emitter.emitProgram(program); | 420 return emitter.emitProgram(program); |
| 423 }); | 421 }); |
| 424 } | 422 } |
| 425 } | 423 } |
| 426 | 424 |
| 427 abstract class Emitter { | 425 abstract class Emitter { |
| 428 /// Emits [program] and returns the size of the generated output. | 426 /// Emits [program] and returns the size of the generated output. |
| 429 int emitProgram(Program program); | 427 int emitProgram(Program program); |
| 430 | 428 |
| 431 /// Returns the JS function that must be invoked to get the value of the | 429 /// Returns the JS function that must be invoked to get the value of the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 jsAst.Expression typeAccess(Element e); | 461 jsAst.Expression typeAccess(Element e); |
| 464 | 462 |
| 465 /// Returns the JS constructor for the given closure class [e]. | 463 /// Returns the JS constructor for the given closure class [e]. |
| 466 jsAst.Expression closureClassConstructorAccess(ClosureClassElement e); | 464 jsAst.Expression closureClassConstructorAccess(ClosureClassElement e); |
| 467 | 465 |
| 468 int compareConstants(ConstantValue a, ConstantValue b); | 466 int compareConstants(ConstantValue a, ConstantValue b); |
| 469 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 467 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 470 | 468 |
| 471 void invalidateCaches(); | 469 void invalidateCaches(); |
| 472 } | 470 } |
| OLD | NEW |