| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 : super(compiler), | 49 : super(compiler), |
| 50 this.namer = namer, | 50 this.namer = namer, |
| 51 this.typeTestRegistry = new TypeTestRegistry(compiler) { | 51 this.typeTestRegistry = new TypeTestRegistry(compiler) { |
| 52 oldEmitter = new OldEmitter(compiler, namer, generateSourceMap, this); | 52 oldEmitter = new OldEmitter(compiler, namer, generateSourceMap, this); |
| 53 emitter = USE_NEW_EMITTER | 53 emitter = USE_NEW_EMITTER |
| 54 ? new new_js_emitter.Emitter(compiler, namer) | 54 ? new new_js_emitter.Emitter(compiler, namer) |
| 55 : oldEmitter; | 55 : oldEmitter; |
| 56 nativeEmitter = new NativeEmitter(this); | 56 nativeEmitter = new NativeEmitter(this); |
| 57 } | 57 } |
| 58 | 58 |
| 59 | 59 jsAst.Expression isolateStaticClosureAccess(Element element) { |
| 60 return emitter.isolateStaticClosureAccess(element); |
| 61 } |
| 62 |
| 63 jsAst.Expression isolateLazyInitializerAccess(Element element) { |
| 64 return emitter.isolateLazyInitializerAccess(element); |
| 65 } |
| 66 |
| 60 jsAst.Expression generateEmbeddedGlobalAccess(String global) { | 67 jsAst.Expression generateEmbeddedGlobalAccess(String global) { |
| 61 return emitter.generateEmbeddedGlobalAccess(global); | 68 return emitter.generateEmbeddedGlobalAccess(global); |
| 62 } | 69 } |
| 63 | 70 |
| 64 jsAst.Expression constantReference(ConstantValue value) { | 71 jsAst.Expression constantReference(ConstantValue value) { |
| 65 return emitter.constantReference(value); | 72 return emitter.constantReference(value); |
| 66 } | 73 } |
| 67 | 74 |
| 68 jsAst.Expression staticFieldAccess(Element e) { | 75 jsAst.Expression staticFieldAccess(Element e) { |
| 69 return emitter.staticFunctionAccess(e); | 76 return emitter.staticFunctionAccess(e); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 program = new ProgramBuilder(compiler, namer, this).buildProgram(); | 368 program = new ProgramBuilder(compiler, namer, this).buildProgram(); |
| 362 } | 369 } |
| 363 emitter.emitProgram(program); | 370 emitter.emitProgram(program); |
| 364 }); | 371 }); |
| 365 } | 372 } |
| 366 } | 373 } |
| 367 | 374 |
| 368 abstract class Emitter { | 375 abstract class Emitter { |
| 369 void emitProgram(Program program); | 376 void emitProgram(Program program); |
| 370 | 377 |
| 378 jsAst.Expression isolateLazyInitializerAccess(Element element); |
| 379 jsAst.Expression isolateStaticClosureAccess(Element element); |
| 371 jsAst.Expression generateEmbeddedGlobalAccess(String global); | 380 jsAst.Expression generateEmbeddedGlobalAccess(String global); |
| 372 jsAst.Expression constantReference(ConstantValue value); | 381 jsAst.Expression constantReference(ConstantValue value); |
| 373 jsAst.PropertyAccess staticFunctionAccess(Element element); | 382 jsAst.PropertyAccess staticFunctionAccess(Element element); |
| 374 | 383 |
| 375 // TODO(zarah): Split into more fine-grained accesses. | 384 // TODO(zarah): Split into more fine-grained accesses. |
| 376 /// Generates access to the js constructor of the class represented by | 385 /// Generates access to the js constructor of the class represented by |
| 377 /// [element] | 386 /// [element] |
| 378 jsAst.PropertyAccess classAccess(Element element); | 387 jsAst.PropertyAccess classAccess(Element element); |
| 379 jsAst.PropertyAccess typedefAccess(Element element); | 388 jsAst.PropertyAccess typedefAccess(Element element); |
| 380 jsAst.PropertyAccess staticFieldAccess(Element element); | 389 jsAst.PropertyAccess staticFieldAccess(Element element); |
| 381 | 390 |
| 382 | 391 |
| 383 int compareConstants(ConstantValue a, ConstantValue b); | 392 int compareConstants(ConstantValue a, ConstantValue b); |
| 384 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 393 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 385 | 394 |
| 386 void invalidateCaches(); | 395 void invalidateCaches(); |
| 387 } | 396 } |
| OLD | NEW |