| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // Compute the required type checks to know which classes need a | 383 // Compute the required type checks to know which classes need a |
| 384 // 'is$' method. | 384 // 'is$' method. |
| 385 typeTestRegistry.computeRequiredTypeChecks(); | 385 typeTestRegistry.computeRequiredTypeChecks(); |
| 386 | 386 |
| 387 computeNeededDeclarations(); | 387 computeNeededDeclarations(); |
| 388 computeNeededConstants(); | 388 computeNeededConstants(); |
| 389 computeNeededStatics(); | 389 computeNeededStatics(); |
| 390 computeNeededLibraries(); | 390 computeNeededLibraries(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 int assembleProgram() { | 393 void assembleProgram() { |
| 394 return measure(() { | 394 measure(() { |
| 395 emitter.invalidateCaches(); | 395 emitter.invalidateCaches(); |
| 396 | 396 |
| 397 computeAllNeededEntities(); | 397 computeAllNeededEntities(); |
| 398 | 398 |
| 399 Program program; | 399 Program program; |
| 400 if (USE_NEW_EMITTER) { | 400 if (USE_NEW_EMITTER) { |
| 401 program = new ProgramBuilder(compiler, namer, this).buildProgram(); | 401 program = new ProgramBuilder(compiler, namer, this).buildProgram(); |
| 402 } | 402 } |
| 403 return emitter.emitProgram(program); | 403 emitter.emitProgram(program); |
| 404 }); | 404 }); |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 | 407 |
| 408 abstract class Emitter { | 408 abstract class Emitter { |
| 409 /// Emits [program] and returns the size of the generated output. | 409 void emitProgram(Program program); |
| 410 int emitProgram(Program program); | |
| 411 | 410 |
| 412 /// Returns the JS function that must be invoked to get the value of the | 411 /// Returns the JS function that must be invoked to get the value of the |
| 413 /// lazily initialized static. | 412 /// lazily initialized static. |
| 414 jsAst.Expression isolateLazyInitializerAccess(FieldElement element); | 413 jsAst.Expression isolateLazyInitializerAccess(FieldElement element); |
| 415 | 414 |
| 416 /// Returns the closure expression of a static function. | 415 /// Returns the closure expression of a static function. |
| 417 jsAst.Expression isolateStaticClosureAccess(FunctionElement element); | 416 jsAst.Expression isolateStaticClosureAccess(FunctionElement element); |
| 418 | 417 |
| 419 /// Returns the JS code for accessing the embedded [global]. | 418 /// Returns the JS code for accessing the embedded [global]. |
| 420 jsAst.Expression generateEmbeddedGlobalAccess(String global); | 419 jsAst.Expression generateEmbeddedGlobalAccess(String global); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 436 | 435 |
| 437 /// Returns the JS prototype of the given class [e]. | 436 /// Returns the JS prototype of the given class [e]. |
| 438 jsAst.Expression prototypeAccess(ClassElement e, bool hasBeenInstantiated); | 437 jsAst.Expression prototypeAccess(ClassElement e, bool hasBeenInstantiated); |
| 439 | 438 |
| 440 /// Returns the JS constructor of the given interceptor class [e]. | 439 /// Returns the JS constructor of the given interceptor class [e]. |
| 441 jsAst.Expression interceptorClassAccess(ClassElement e); | 440 jsAst.Expression interceptorClassAccess(ClassElement e); |
| 442 | 441 |
| 443 /// Returns the JS expression representing the type [e]. | 442 /// Returns the JS expression representing the type [e]. |
| 444 jsAst.Expression typeAccess(Element e); | 443 jsAst.Expression typeAccess(Element e); |
| 445 | 444 |
| 445 |
| 446 int compareConstants(ConstantValue a, ConstantValue b); | 446 int compareConstants(ConstantValue a, ConstantValue b); |
| 447 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 447 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 448 | 448 |
| 449 void invalidateCaches(); | 449 void invalidateCaches(); |
| 450 } | 450 } |
| OLD | NEW |