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

Side by Side Diff: pkg/barback/lib/src/transform_node.dart

Issue 191223004: Add BaseTransform.consumePrimary to barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 barback.transform_node; 5 library barback.transform_node;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'asset.dart'; 9 import 'asset.dart';
10 import 'asset_id.dart'; 10 import 'asset_id.dart';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 /// Whether [this] is dirty and still has more processing to do. 49 /// Whether [this] is dirty and still has more processing to do.
50 bool get isDirty => _pendingIsPrimary || _isApplying; 50 bool get isDirty => _pendingIsPrimary || _isApplying;
51 51
52 /// Whether any input has become dirty since [_apply] last started running. 52 /// Whether any input has become dirty since [_apply] last started running.
53 var _hasBecomeDirty = false; 53 var _hasBecomeDirty = false;
54 54
55 /// Whether [_apply] is currently running. 55 /// Whether [_apply] is currently running.
56 var _isApplying = false; 56 var _isApplying = false;
57 57
58 /// Whether the most recent run of this transform has declared that it
59 /// consumes the primary input.
60 ///
61 /// Defaults to `false`.
62 bool get consumePrimary => _consumePrimary;
63 bool _consumePrimary = false;
64
58 /// Whether [transformer] is lazy and this transform has yet to be forced. 65 /// Whether [transformer] is lazy and this transform has yet to be forced.
59 bool _isLazy; 66 bool _isLazy;
60 67
61 /// The subscriptions to each input's [AssetNode.onStateChange] stream. 68 /// The subscriptions to each input's [AssetNode.onStateChange] stream.
62 var _inputSubscriptions = new Map<AssetId, StreamSubscription>(); 69 var _inputSubscriptions = new Map<AssetId, StreamSubscription>();
63 70
64 /// The controllers for the asset nodes emitted by this node. 71 /// The controllers for the asset nodes emitted by this node.
65 var _outputControllers = new Map<AssetId, AssetNodeController>(); 72 var _outputControllers = new Map<AssetId, AssetNodeController>();
66 73
67 // TODO(nweiz): It's weird that this is different than the [onDone] stream the 74 // TODO(nweiz): It's weird that this is different than the [onDone] stream the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 /// outputs. 246 /// outputs.
240 Future _applyImmediate() { 247 Future _applyImmediate() {
241 var transformController = new TransformController(this); 248 var transformController = new TransformController(this);
242 _onLogPool.add(transformController.onLog); 249 _onLogPool.add(transformController.onLog);
243 250
244 return syncFuture(() { 251 return syncFuture(() {
245 return transformer.apply(transformController.transform); 252 return transformer.apply(transformController.transform);
246 }).then((_) { 253 }).then((_) {
247 if (_hasBecomeDirty || _onAssetController.isClosed) return; 254 if (_hasBecomeDirty || _onAssetController.isClosed) return;
248 255
256 _consumePrimary = transformController.consumePrimary;
257
249 var newOutputs = transformController.outputs; 258 var newOutputs = transformController.outputs;
250 // Any ids that are for a different package are invalid. 259 // Any ids that are for a different package are invalid.
251 var invalidIds = newOutputs 260 var invalidIds = newOutputs
252 .map((asset) => asset.id) 261 .map((asset) => asset.id)
253 .where((id) => id.package != phase.cascade.package) 262 .where((id) => id.package != phase.cascade.package)
254 .toSet(); 263 .toSet();
255 for (var id in invalidIds) { 264 for (var id in invalidIds) {
256 newOutputs.removeId(id); 265 newOutputs.removeId(id);
257 // TODO(nweiz): report this as a warning rather than a failing error. 266 // TODO(nweiz): report this as a warning rather than a failing error.
258 phase.cascade.reportError(new InvalidOutputException(info, id)); 267 phase.cascade.reportError(new InvalidOutputException(info, id));
(...skipping 23 matching lines...) Expand all
282 /// outputs. 291 /// outputs.
283 Future _declareLazy() { 292 Future _declareLazy() {
284 var transformController = new DeclaringTransformController(this); 293 var transformController = new DeclaringTransformController(this);
285 294
286 return syncFuture(() { 295 return syncFuture(() {
287 return (transformer as LazyTransformer) 296 return (transformer as LazyTransformer)
288 .declareOutputs(transformController.transform); 297 .declareOutputs(transformController.transform);
289 }).then((_) { 298 }).then((_) {
290 if (_hasBecomeDirty || _onAssetController.isClosed) return; 299 if (_hasBecomeDirty || _onAssetController.isClosed) return;
291 300
301 _consumePrimary = transformController.consumePrimary;
302
292 var newIds = transformController.outputIds; 303 var newIds = transformController.outputIds;
293 var invalidIds = 304 var invalidIds =
294 newIds.where((id) => id.package != phase.cascade.package).toSet(); 305 newIds.where((id) => id.package != phase.cascade.package).toSet();
295 for (var id in invalidIds) { 306 for (var id in invalidIds) {
296 newIds.remove(id); 307 newIds.remove(id);
297 // TODO(nweiz): report this as a warning rather than a failing error. 308 // TODO(nweiz): report this as a warning rather than a failing error.
298 phase.cascade.reportError(new InvalidOutputException(info, id)); 309 phase.cascade.reportError(new InvalidOutputException(info, id));
299 } 310 }
300 311
301 // Remove outputs that used to exist but don't anymore. 312 // Remove outputs that used to exist but don't anymore.
(...skipping 11 matching lines...) Expand all
313 _outputControllers[id] = controller; 324 _outputControllers[id] = controller;
314 _onAssetController.add(controller.node); 325 _onAssetController.add(controller.node);
315 } 326 }
316 } 327 }
317 }); 328 });
318 } 329 }
319 330
320 String toString() => 331 String toString() =>
321 "transform node in $_location for $transformer on $primary"; 332 "transform node in $_location for $transformer on $primary";
322 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698