Chromium Code Reviews| 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 | 9 |
| 9 class Program { | 10 class Program { |
| 10 final List<Output> outputs; | 11 final List<Output> outputs; |
| 11 /// A map from load id to the list of outputs that need to be loaded. | 12 /// A map from load id to the list of outputs that need to be loaded. |
| 12 final Map<String, List<Output>> loadMap; | 13 final Map<String, List<Output>> loadMap; |
| 13 | 14 |
| 14 Program(this.outputs, this.loadMap); | 15 Program(this.outputs, this.loadMap); |
| 15 } | 16 } |
| 16 | 17 |
| 18 /** | |
| 19 * This class represents a JavaScript object that containts static state, like | |
|
kasperl
2014/10/16 07:01:56
containts -> contains
floitsch
2014/10/16 12:59:54
Done.
| |
| 20 * classes or functions. | |
| 21 */ | |
| 17 class Holder { | 22 class Holder { |
| 18 final String name; | 23 final String name; |
| 19 final int index; | 24 final int index; |
| 20 Holder(this.name, this.index); | 25 Holder(this.name, this.index); |
| 21 } | 26 } |
| 22 | 27 |
| 28 /** | |
| 29 * This class represents one output file. | |
| 30 * | |
| 31 * If no library is deferred, there is only one [Output] of type [MainOutput]. | |
| 32 */ | |
| 23 abstract class Output { | 33 abstract class Output { |
| 24 bool get isMainOutput => mainOutput == this; | 34 bool get isMainOutput => mainOutput == this; |
| 25 MainOutput get mainOutput; | 35 MainOutput get mainOutput; |
| 26 final List<Library> libraries; | 36 final List<Library> libraries; |
| 37 final List<Constant> constants; | |
| 27 | 38 |
| 28 /// Output file name without extension. | 39 /// Output file name without extension. |
| 29 final String outputFileName; | 40 final String outputFileName; |
| 30 | 41 |
| 31 Output(this.outputFileName, this.libraries); | 42 Output(this.outputFileName, |
| 43 this.libraries, | |
| 44 this.constants); | |
| 32 } | 45 } |
| 33 | 46 |
| 47 /** | |
| 48 * The main output file. | |
| 49 * | |
| 50 * This code emitted from this [Output] must be loaded first. It can then load | |
| 51 * other [DeferredOutput]s. | |
| 52 */ | |
| 34 class MainOutput extends Output { | 53 class MainOutput extends Output { |
| 35 final js.Expression main; | 54 final js.Expression main; |
| 36 final List<Holder> holders; | 55 final List<Holder> holders; |
| 37 | 56 |
| 38 MainOutput( | 57 MainOutput(String outputFileName, |
| 39 String outputFileName, this.main, List<Library> libraries, this.holders) | 58 this.main, |
| 40 : super(outputFileName, libraries); | 59 List<Library> libraries, |
| 60 List<Constant> constants, | |
| 61 this.holders) | |
| 62 : super(outputFileName, libraries, constants); | |
| 41 | 63 |
| 42 MainOutput get mainOutput => this; | 64 MainOutput get mainOutput => this; |
| 43 } | 65 } |
| 44 | 66 |
| 67 /** | |
| 68 * An output (file) for deferred code. | |
| 69 */ | |
| 45 class DeferredOutput extends Output { | 70 class DeferredOutput extends Output { |
| 46 final MainOutput mainOutput; | 71 final MainOutput mainOutput; |
| 47 final String name; | 72 final String name; |
| 48 | 73 |
| 49 List<Holder> get holders => mainOutput.holders; | 74 List<Holder> get holders => mainOutput.holders; |
| 50 | 75 |
| 51 DeferredOutput(String outputFileName, this.name, | 76 DeferredOutput(String outputFileName, |
| 52 this.mainOutput, List<Library> libraries) | 77 this.name, |
| 53 : super(outputFileName, libraries); | 78 this.mainOutput, |
| 79 List<Library> libraries, | |
| 80 List<Constant> constants) | |
| 81 : super(outputFileName, libraries, constants); | |
| 82 } | |
| 83 | |
| 84 class Constant { | |
| 85 final String name; | |
| 86 final Holder holder; | |
| 87 final ConstantValue value; | |
| 88 | |
| 89 Constant(this.name, this.holder, this.value); | |
| 54 } | 90 } |
| 55 | 91 |
| 56 class Library { | 92 class Library { |
| 57 final String uri; | 93 final String uri; |
| 58 final List<StaticMethod> statics; | 94 final List<StaticMethod> statics; |
| 59 final List<Class> classes; | 95 final List<Class> classes; |
| 60 Library(this.uri, this.statics, this.classes); | 96 Library(this.uri, this.statics, this.classes); |
| 61 } | 97 } |
| 62 | 98 |
| 63 class Class { | 99 class Class { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 81 final String name; | 117 final String name; |
| 82 final js.Expression code; | 118 final js.Expression code; |
| 83 Method(this.name, this.code); | 119 Method(this.name, this.code); |
| 84 } | 120 } |
| 85 | 121 |
| 86 class StaticMethod extends Method { | 122 class StaticMethod extends Method { |
| 87 final Holder holder; | 123 final Holder holder; |
| 88 StaticMethod(String name, this.holder, js.Expression code) | 124 StaticMethod(String name, this.holder, js.Expression code) |
| 89 : super(name, code); | 125 : super(name, code); |
| 90 } | 126 } |
| OLD | NEW |