Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/model.dart

Issue 694353007: Move dart2js from sdk/lib/_internal/compiler to pkg/compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart2js.new_js_emitter.model;
6
7 import '../js/js.dart' as js show Expression;
8 import '../constants/values.dart' show ConstantValue;
9
10 class Program {
11 final List<Output> outputs;
12 final bool outputContainsConstantList;
13 /// A map from load id to the list of outputs that need to be loaded.
14 final Map<String, List<Output>> loadMap;
15
16 Program(this.outputs, this.outputContainsConstantList, this.loadMap);
17 }
18
19 /**
20 * This class represents a JavaScript object that contains static state, like
21 * classes or functions.
22 */
23 class Holder {
24 final String name;
25 final int index;
26 Holder(this.name, this.index);
27 }
28
29 /**
30 * This class represents one output file.
31 *
32 * If no library is deferred, there is only one [Output] of type [MainOutput].
33 */
34 abstract class Output {
35 bool get isMainOutput => mainOutput == this;
36 MainOutput get mainOutput;
37 final List<Library> libraries;
38 final List<Constant> constants;
39 // TODO(floitsch): should we move static fields into libraries or classes?
40 final List<StaticField> staticNonFinalFields;
41 // TODO(floitsch): lazy fields should be in their library or even class.
42 final List<StaticField> staticLazilyInitializedFields;
43
44 /// Output file name without extension.
45 final String outputFileName;
46
47 Output(this.outputFileName,
48 this.libraries,
49 this.staticNonFinalFields,
50 this.staticLazilyInitializedFields,
51 this.constants);
52 }
53
54 /**
55 * The main output file.
56 *
57 * This code emitted from this [Output] must be loaded first. It can then load
58 * other [DeferredOutput]s.
59 */
60 class MainOutput extends Output {
61 final js.Expression main;
62 final List<Holder> holders;
63
64 MainOutput(String outputFileName,
65 this.main,
66 List<Library> libraries,
67 List<StaticField> staticNonFinalFields,
68 List<StaticField> staticLazilyInitializedFields,
69 List<Constant> constants,
70 this.holders)
71 : super(outputFileName,
72 libraries,
73 staticNonFinalFields,
74 staticLazilyInitializedFields,
75 constants);
76
77 MainOutput get mainOutput => this;
78 }
79
80 /**
81 * An output (file) for deferred code.
82 */
83 class DeferredOutput extends Output {
84 final MainOutput mainOutput;
85 final String name;
86
87 List<Holder> get holders => mainOutput.holders;
88
89 DeferredOutput(String outputFileName,
90 this.name,
91 this.mainOutput,
92 List<Library> libraries,
93 List<StaticField> staticNonFinalFields,
94 List<StaticField> staticLazilyInitializedFields,
95 List<Constant> constants)
96 : super(outputFileName,
97 libraries,
98 staticNonFinalFields,
99 staticLazilyInitializedFields,
100 constants);
101 }
102
103 class Constant {
104 final String name;
105 final Holder holder;
106 final ConstantValue value;
107
108 Constant(this.name, this.holder, this.value);
109 }
110
111 class Library {
112 final String uri;
113 final List<StaticMethod> statics;
114 final List<Class> classes;
115
116 Library(this.uri, this.statics, this.classes);
117 }
118
119 class StaticField {
120 final String name;
121 // TODO(floitsch): the holder for static fields is the isolate object. We
122 // could remove this field and use the isolate object directly.
123 final Holder holder;
124 final js.Expression code;
125 final bool isFinal;
126 final bool isLazy;
127
128 StaticField(this.name, this.holder, this.code,
129 this.isFinal, this.isLazy);
130 }
131
132 class Class {
133 final String name;
134 final Holder holder;
135 Class superclass;
136 final List<Method> methods;
137 final List<InstanceField> fields;
138
139 /// Whether the class must be evaluated eagerly.
140 bool isEager = false;
141
142 Class(this.name, this.holder, this.methods, this.fields,
143 { this.isEager: false });
144
145 void setSuperclass(Class superclass) {
146 this.superclass = superclass;
147 }
148
149 String get superclassName
150 => (superclass == null) ? "" : superclass.name;
151 int get superclassHolderIndex
152 => (superclass == null) ? 0 : superclass.holder.index;
153 }
154
155 class InstanceField {
156 final String name;
157
158 /// 00: Does not need any getter.
159 /// 01: function() { return this.field; }
160 /// 10: function(receiver) { return receiver.field; }
161 /// 11: function(receiver) { return this.field; }
162 final int getterFlags;
163
164 /// 00: Does not need any setter.
165 /// 01: function(value) { this.field = value; }
166 /// 10: function(receiver, value) { receiver.field = value; }
167 /// 11: function(receiver, value) { this.field = value; }
168 final int setterFlags;
169
170 // TODO(floitsch): support renamed fields.
171 InstanceField(this.name, this.getterFlags, this.setterFlags);
172
173 bool get needsGetter => getterFlags != 0;
174 bool get needsSetter => setterFlags != 0;
175 }
176
177 class Method {
178 final String name;
179 final js.Expression code;
180 Method(this.name, this.code);
181 }
182
183 class StaticMethod extends Method {
184 final Holder holder;
185 StaticMethod(String name, this.holder, js.Expression code)
186 : super(name, code);
187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698