OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:front_end/src/base/flat_buffers.dart' as fb; | 5 import 'package:front_end/src/base/flat_buffers.dart' as fb; |
6 | 6 |
7 /// Unlinked information about a `show` or `hide` combinator in an import or | 7 /// Unlinked information about a `show` or `hide` combinator in an import or |
8 /// export directive. | 8 /// export directive. |
9 abstract class UnlinkedCombinator { | 9 abstract class UnlinkedCombinator { |
10 factory UnlinkedCombinator(List<int> bytes) { | 10 factory UnlinkedCombinator(List<int> bytes) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 return const _UnlinkedUnitReader().read(rootRef, 0); | 117 return const _UnlinkedUnitReader().read(rootRef, 0); |
118 } | 118 } |
119 | 119 |
120 /// API signature of the unit. | 120 /// API signature of the unit. |
121 /// It depends on all non-comment tokens outside the block bodies. | 121 /// It depends on all non-comment tokens outside the block bodies. |
122 List<int> get apiSignature; | 122 List<int> get apiSignature; |
123 | 123 |
124 /// Export directives in the compilation unit. | 124 /// Export directives in the compilation unit. |
125 List<UnlinkedNamespaceDirective> get exports; | 125 List<UnlinkedNamespaceDirective> get exports; |
126 | 126 |
| 127 /// Whether the unit has a mixin application. |
| 128 bool get hasMixinApplication; |
| 129 |
127 /// Import directives in the compilation unit. | 130 /// Import directives in the compilation unit. |
128 List<UnlinkedNamespaceDirective> get imports; | 131 List<UnlinkedNamespaceDirective> get imports; |
129 | 132 |
130 /// Part directives in the compilation unit. | 133 /// Part directives in the compilation unit. |
131 List<UnlinkedNamespaceDirective> get parts; | 134 List<UnlinkedNamespaceDirective> get parts; |
132 } | 135 } |
133 | 136 |
134 /// Builder of [UnlinkedUnit]s. | 137 /// Builder of [UnlinkedUnit]s. |
135 class UnlinkedUnitBuilder { | 138 class UnlinkedUnitBuilder { |
136 List<int> _apiSignature; | 139 List<int> _apiSignature; |
137 List<UnlinkedNamespaceDirectiveBuilder> _imports; | 140 List<UnlinkedNamespaceDirectiveBuilder> _imports; |
138 List<UnlinkedNamespaceDirectiveBuilder> _exports; | 141 List<UnlinkedNamespaceDirectiveBuilder> _exports; |
139 List<UnlinkedNamespaceDirectiveBuilder> _parts; | 142 List<UnlinkedNamespaceDirectiveBuilder> _parts; |
| 143 bool _hasMixinApplication; |
140 | 144 |
141 UnlinkedUnitBuilder( | 145 UnlinkedUnitBuilder( |
142 {List<int> apiSignature, | 146 {List<int> apiSignature, |
143 List<UnlinkedNamespaceDirectiveBuilder> imports, | 147 List<UnlinkedNamespaceDirectiveBuilder> imports, |
144 List<UnlinkedNamespaceDirectiveBuilder> exports, | 148 List<UnlinkedNamespaceDirectiveBuilder> exports, |
145 List<UnlinkedNamespaceDirectiveBuilder> parts}) | 149 List<UnlinkedNamespaceDirectiveBuilder> parts, |
| 150 bool hasMixinApplication}) |
146 : _apiSignature = apiSignature, | 151 : _apiSignature = apiSignature, |
147 _imports = imports, | 152 _imports = imports, |
148 _exports = exports, | 153 _exports = exports, |
149 _parts = parts; | 154 _parts = parts, |
| 155 _hasMixinApplication = hasMixinApplication; |
150 | 156 |
151 void set exports(List<UnlinkedNamespaceDirectiveBuilder> value) { | 157 void set exports(List<UnlinkedNamespaceDirectiveBuilder> value) { |
152 this._exports = value; | 158 this._exports = value; |
153 } | 159 } |
154 | 160 |
| 161 void set hasMixinApplication(bool value) { |
| 162 this._hasMixinApplication = value; |
| 163 } |
| 164 |
155 void set imports(List<UnlinkedNamespaceDirectiveBuilder> value) { | 165 void set imports(List<UnlinkedNamespaceDirectiveBuilder> value) { |
156 this._imports = value; | 166 this._imports = value; |
157 } | 167 } |
158 | 168 |
159 void set parts(List<UnlinkedNamespaceDirectiveBuilder> value) { | 169 void set parts(List<UnlinkedNamespaceDirectiveBuilder> value) { |
160 this._parts = value; | 170 this._parts = value; |
161 } | 171 } |
162 | 172 |
163 /// Finish building, and store into the [fbBuilder]. | 173 /// Finish building, and store into the [fbBuilder]. |
164 fb.Offset finish(fb.Builder fbBuilder) { | 174 fb.Offset finish(fb.Builder fbBuilder) { |
(...skipping 22 matching lines...) Expand all Loading... |
187 } | 197 } |
188 if (offset_imports != null) { | 198 if (offset_imports != null) { |
189 fbBuilder.addOffset(1, offset_imports); | 199 fbBuilder.addOffset(1, offset_imports); |
190 } | 200 } |
191 if (offset_exports != null) { | 201 if (offset_exports != null) { |
192 fbBuilder.addOffset(2, offset_exports); | 202 fbBuilder.addOffset(2, offset_exports); |
193 } | 203 } |
194 if (offset_parts != null) { | 204 if (offset_parts != null) { |
195 fbBuilder.addOffset(3, offset_parts); | 205 fbBuilder.addOffset(3, offset_parts); |
196 } | 206 } |
| 207 if (_hasMixinApplication == true) { |
| 208 fbBuilder.addBool(4, _hasMixinApplication); |
| 209 } |
197 return fbBuilder.endTable(); | 210 return fbBuilder.endTable(); |
198 } | 211 } |
199 } | 212 } |
200 | 213 |
201 class _UnlinkedCombinatorImpl implements UnlinkedCombinator { | 214 class _UnlinkedCombinatorImpl implements UnlinkedCombinator { |
202 final fb.BufferContext _bc; | 215 final fb.BufferContext _bc; |
203 final int _bcOffset; | 216 final int _bcOffset; |
204 | 217 |
205 List<String> _shows; | 218 List<String> _shows; |
206 List<String> _hides; | 219 List<String> _hides; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 279 } |
267 | 280 |
268 class _UnlinkedUnitImpl implements UnlinkedUnit { | 281 class _UnlinkedUnitImpl implements UnlinkedUnit { |
269 final fb.BufferContext _bc; | 282 final fb.BufferContext _bc; |
270 final int _bcOffset; | 283 final int _bcOffset; |
271 | 284 |
272 List<int> _apiSignature; | 285 List<int> _apiSignature; |
273 List<UnlinkedNamespaceDirective> _imports; | 286 List<UnlinkedNamespaceDirective> _imports; |
274 List<UnlinkedNamespaceDirective> _exports; | 287 List<UnlinkedNamespaceDirective> _exports; |
275 List<UnlinkedNamespaceDirective> _parts; | 288 List<UnlinkedNamespaceDirective> _parts; |
| 289 bool _hasMixinApplication; |
276 | 290 |
277 _UnlinkedUnitImpl(this._bc, this._bcOffset); | 291 _UnlinkedUnitImpl(this._bc, this._bcOffset); |
278 | 292 |
279 @override | 293 @override |
280 List<int> get apiSignature { | 294 List<int> get apiSignature { |
281 _apiSignature ??= | 295 _apiSignature ??= |
282 const fb.Uint8ListReader().vTableGet(_bc, _bcOffset, 0, const <int>[]); | 296 const fb.Uint8ListReader().vTableGet(_bc, _bcOffset, 0, const <int>[]); |
283 return _apiSignature; | 297 return _apiSignature; |
284 } | 298 } |
285 | 299 |
286 @override | 300 @override |
287 List<UnlinkedNamespaceDirective> get exports { | 301 List<UnlinkedNamespaceDirective> get exports { |
288 _exports ??= const fb.ListReader<UnlinkedNamespaceDirective>( | 302 _exports ??= const fb.ListReader<UnlinkedNamespaceDirective>( |
289 const _UnlinkedNamespaceDirectiveReader()) | 303 const _UnlinkedNamespaceDirectiveReader()) |
290 .vTableGet(_bc, _bcOffset, 2, const <UnlinkedNamespaceDirective>[]); | 304 .vTableGet(_bc, _bcOffset, 2, const <UnlinkedNamespaceDirective>[]); |
291 return _exports; | 305 return _exports; |
292 } | 306 } |
293 | 307 |
294 @override | 308 @override |
| 309 bool get hasMixinApplication { |
| 310 _hasMixinApplication ??= |
| 311 const fb.BoolReader().vTableGet(_bc, _bcOffset, 4, false); |
| 312 return _hasMixinApplication; |
| 313 } |
| 314 |
| 315 @override |
295 List<UnlinkedNamespaceDirective> get imports { | 316 List<UnlinkedNamespaceDirective> get imports { |
296 _imports ??= const fb.ListReader<UnlinkedNamespaceDirective>( | 317 _imports ??= const fb.ListReader<UnlinkedNamespaceDirective>( |
297 const _UnlinkedNamespaceDirectiveReader()) | 318 const _UnlinkedNamespaceDirectiveReader()) |
298 .vTableGet(_bc, _bcOffset, 1, const <UnlinkedNamespaceDirective>[]); | 319 .vTableGet(_bc, _bcOffset, 1, const <UnlinkedNamespaceDirective>[]); |
299 return _imports; | 320 return _imports; |
300 } | 321 } |
301 | 322 |
302 @override | 323 @override |
303 List<UnlinkedNamespaceDirective> get parts { | 324 List<UnlinkedNamespaceDirective> get parts { |
304 _parts ??= const fb.ListReader<UnlinkedNamespaceDirective>( | 325 _parts ??= const fb.ListReader<UnlinkedNamespaceDirective>( |
305 const _UnlinkedNamespaceDirectiveReader()) | 326 const _UnlinkedNamespaceDirectiveReader()) |
306 .vTableGet(_bc, _bcOffset, 3, const <UnlinkedNamespaceDirective>[]); | 327 .vTableGet(_bc, _bcOffset, 3, const <UnlinkedNamespaceDirective>[]); |
307 return _parts; | 328 return _parts; |
308 } | 329 } |
309 } | 330 } |
310 | 331 |
311 class _UnlinkedUnitReader extends fb.TableReader<UnlinkedUnit> { | 332 class _UnlinkedUnitReader extends fb.TableReader<UnlinkedUnit> { |
312 const _UnlinkedUnitReader(); | 333 const _UnlinkedUnitReader(); |
313 | 334 |
314 @override | 335 @override |
315 _UnlinkedUnitImpl createObject(fb.BufferContext bc, int offset) => | 336 _UnlinkedUnitImpl createObject(fb.BufferContext bc, int offset) => |
316 new _UnlinkedUnitImpl(bc, offset); | 337 new _UnlinkedUnitImpl(bc, offset); |
317 } | 338 } |
OLD | NEW |