| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.new_js_emitter.model; | 5 library dart2js.new_js_emitter.model; |
| 6 | 6 |
| 7 import '../js/js.dart' as js show Expression; | 7 import '../js/js.dart' as js show Expression; |
| 8 import '../constants/values.dart' show ConstantValue; | 8 import '../constants/values.dart' show ConstantValue; |
| 9 | 9 |
| 10 class Program { | 10 class Program { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 /** | 28 /** |
| 29 * This class represents one output file. | 29 * This class represents one output file. |
| 30 * | 30 * |
| 31 * If no library is deferred, there is only one [Output] of type [MainOutput]. | 31 * If no library is deferred, there is only one [Output] of type [MainOutput]. |
| 32 */ | 32 */ |
| 33 abstract class Output { | 33 abstract class Output { |
| 34 bool get isMainOutput => mainOutput == this; | 34 bool get isMainOutput => mainOutput == this; |
| 35 MainOutput get mainOutput; | 35 MainOutput get mainOutput; |
| 36 final List<Library> libraries; | 36 final List<Library> libraries; |
| 37 final List<Constant> constants; | 37 final List<Constant> constants; |
| 38 // TODO(floitsch): should we move static fields into libraries or classes? |
| 39 final List<StaticField> staticNonFinalFields; |
| 38 | 40 |
| 39 /// Output file name without extension. | 41 /// Output file name without extension. |
| 40 final String outputFileName; | 42 final String outputFileName; |
| 41 | 43 |
| 42 Output(this.outputFileName, | 44 Output(this.outputFileName, |
| 43 this.libraries, | 45 this.libraries, |
| 46 this.staticNonFinalFields, |
| 44 this.constants); | 47 this.constants); |
| 45 } | 48 } |
| 46 | 49 |
| 47 /** | 50 /** |
| 48 * The main output file. | 51 * The main output file. |
| 49 * | 52 * |
| 50 * This code emitted from this [Output] must be loaded first. It can then load | 53 * This code emitted from this [Output] must be loaded first. It can then load |
| 51 * other [DeferredOutput]s. | 54 * other [DeferredOutput]s. |
| 52 */ | 55 */ |
| 53 class MainOutput extends Output { | 56 class MainOutput extends Output { |
| 54 final js.Expression main; | 57 final js.Expression main; |
| 55 final List<Holder> holders; | 58 final List<Holder> holders; |
| 56 | 59 |
| 57 MainOutput(String outputFileName, | 60 MainOutput(String outputFileName, |
| 58 this.main, | 61 this.main, |
| 59 List<Library> libraries, | 62 List<Library> libraries, |
| 63 List<StaticField> staticNonFinalFields, |
| 60 List<Constant> constants, | 64 List<Constant> constants, |
| 61 this.holders) | 65 this.holders) |
| 62 : super(outputFileName, libraries, constants); | 66 : super(outputFileName, libraries, staticNonFinalFields, constants); |
| 63 | 67 |
| 64 MainOutput get mainOutput => this; | 68 MainOutput get mainOutput => this; |
| 65 } | 69 } |
| 66 | 70 |
| 67 /** | 71 /** |
| 68 * An output (file) for deferred code. | 72 * An output (file) for deferred code. |
| 69 */ | 73 */ |
| 70 class DeferredOutput extends Output { | 74 class DeferredOutput extends Output { |
| 71 final MainOutput mainOutput; | 75 final MainOutput mainOutput; |
| 72 final String name; | 76 final String name; |
| 73 | 77 |
| 74 List<Holder> get holders => mainOutput.holders; | 78 List<Holder> get holders => mainOutput.holders; |
| 75 | 79 |
| 76 DeferredOutput(String outputFileName, | 80 DeferredOutput(String outputFileName, |
| 77 this.name, | 81 this.name, |
| 78 this.mainOutput, | 82 this.mainOutput, |
| 79 List<Library> libraries, | 83 List<Library> libraries, |
| 84 List<StaticField> staticNonFinalFields, |
| 80 List<Constant> constants) | 85 List<Constant> constants) |
| 81 : super(outputFileName, libraries, constants); | 86 : super(outputFileName, libraries, staticNonFinalFields, constants); |
| 82 } | 87 } |
| 83 | 88 |
| 84 class Constant { | 89 class Constant { |
| 85 final String name; | 90 final String name; |
| 86 final Holder holder; | 91 final Holder holder; |
| 87 final ConstantValue value; | 92 final ConstantValue value; |
| 88 | 93 |
| 89 Constant(this.name, this.holder, this.value); | 94 Constant(this.name, this.holder, this.value); |
| 90 } | 95 } |
| 91 | 96 |
| 92 class Library { | 97 class Library { |
| 93 final String uri; | 98 final String uri; |
| 94 final List<StaticMethod> statics; | 99 final List<StaticMethod> statics; |
| 95 final List<Class> classes; | 100 final List<Class> classes; |
| 96 Library(this.uri, this.statics, this.classes); | 101 Library(this.uri, this.statics, this.classes); |
| 97 } | 102 } |
| 98 | 103 |
| 104 class StaticField { |
| 105 final String name; |
| 106 // TODO(floitsch): the holder for static fields is the isolate object. We |
| 107 // could remove this field and use the isolate object directly. |
| 108 final Holder holder; |
| 109 final js.Expression code; |
| 110 final bool isFinal; |
| 111 final bool isLazy; |
| 112 |
| 113 StaticField(this.name, this.holder, this.code, |
| 114 this.isFinal, this.isLazy); |
| 115 } |
| 116 |
| 99 class Class { | 117 class Class { |
| 100 final String name; | 118 final String name; |
| 101 final Holder holder; | 119 final Holder holder; |
| 102 Class superclass; | 120 Class superclass; |
| 103 final List<Method> methods; | 121 final List<Method> methods; |
| 104 Class(this.name, this.holder, this.methods); | 122 Class(this.name, this.holder, this.methods); |
| 105 | 123 |
| 106 void setSuperclass(Class superclass) { | 124 void setSuperclass(Class superclass) { |
| 107 this.superclass = superclass; | 125 this.superclass = superclass; |
| 108 } | 126 } |
| 109 | 127 |
| 110 String get superclassName | 128 String get superclassName |
| 111 => (superclass == null) ? "" : superclass.name; | 129 => (superclass == null) ? "" : superclass.name; |
| 112 int get superclassHolderIndex | 130 int get superclassHolderIndex |
| 113 => (superclass == null) ? 0 : superclass.holder.index; | 131 => (superclass == null) ? 0 : superclass.holder.index; |
| 114 } | 132 } |
| 115 | 133 |
| 116 class Method { | 134 class Method { |
| 117 final String name; | 135 final String name; |
| 118 final js.Expression code; | 136 final js.Expression code; |
| 119 Method(this.name, this.code); | 137 Method(this.name, this.code); |
| 120 } | 138 } |
| 121 | 139 |
| 122 class StaticMethod extends Method { | 140 class StaticMethod extends Method { |
| 123 final Holder holder; | 141 final Holder holder; |
| 124 StaticMethod(String name, this.holder, js.Expression code) | 142 StaticMethod(String name, this.holder, js.Expression code) |
| 125 : super(name, code); | 143 : super(name, code); |
| 126 } | 144 } |
| OLD | NEW |