Skip to content

Commit

Permalink
Version 0.6.19.0 .
Browse files Browse the repository at this point in the history
svn merge -r 26167:26292 https://dart.googlecode.com/svn/branches/bleeding_edge trunk

git-svn-id: http://dart.googlecode.com/svn/trunk@26296 260f80e4-7a28-3924-810f-c04153c831b5
  • Loading branch information
dgrove committed May 27, 2015
2 parents a23944b + bdc173d commit 0b2b0fe
Show file tree
Hide file tree
Showing 266 changed files with 11,034 additions and 5,636 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ pubspec.lock
# Generated files.
tools/out
tools/xcodebuild
pkg/shadow_dom/tool/node_modules



3 changes: 2 additions & 1 deletion PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ def CheckChangeOnCommit(input_api, output_api):
input_api,
output_api,
json_url='http://dart-status.appspot.com/current?format=json')
results.extend(status_check)
# TODO(ricow): reenable when status page is back in shape
# results.extend(status_check)
return results
19 changes: 19 additions & 0 deletions WATCHLISTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

# Watchlist Rules
# Refer: http://dev.chromium.org/developers/contributing-code/watchlists

{
'WATCHLIST_DEFINITIONS': {
'runtime': {
'filepath': 'runtime/',
},
},

'WATCHLISTS': {
'runtime': ['vm-dev@dartlang.org'],
},
}

9 changes: 1 addition & 8 deletions pkg/analyzer_experimental/lib/analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:path/path.dart' as pathos;
import 'src/error.dart';
import 'src/generated/ast.dart';
import 'src/generated/error.dart';
import 'src/generated/java_io.dart';
import 'src/generated/parser.dart';
import 'src/generated/scanner.dart';
import 'src/generated/source_io.dart';
Expand Down Expand Up @@ -49,13 +48,7 @@ CompilationUnit parseDartFile(String path) {

/// Converts an AST node representing a string literal into a [String].
String stringLiteralToString(StringLiteral literal) {
if (literal is AdjacentStrings) {
return literal.strings.map(stringLiteralToString).join();
} else if (literal is SimpleStringLiteral) {
return literal.value;
} else {
throw new ArgumentError("Can't convert $literal to a Dart string.");
}
return literal.stringValue;
}

/// A simple error listener that collects errors into an [AnalysisErrorGroup].
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer_experimental/lib/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
library options;

import 'package:args/args.dart';
import 'package:path/path.dart';

import 'dart:io';

Expand Down Expand Up @@ -153,9 +154,8 @@ class CommandLineOptions {

static String _getVersion() {
try {
Path path = new Path(Platform.script);
Path versionPath = path.directoryPath.append('..').append('version');
File versionFile = new File.fromPath(versionPath);
String versionPath = join(dirname(Platform.script), '..', 'version');;
File versionFile = new File(versionPath);
return versionFile.readAsStringSync().trim();
} catch (_) {
// This happens when the script is not running in the context of an SDK.
Expand Down
30 changes: 6 additions & 24 deletions pkg/barback/lib/src/asset_cascade.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ class AssetCascade {
/// Gets the asset identified by [id].
///
/// If [id] is for a generated or transformed asset, this will wait until it
/// has been created and return it. If the asset cannot be found, returns
/// null.
/// has been created and return it. This means that the returned asset will
/// always be [AssetState.AVAILABLE].
///
/// If the asset cannot be found, returns null.
Future<AssetNode> getAssetNode(AssetId id) {
assert(id.package == package);

Expand All @@ -126,11 +128,9 @@ class AssetCascade {
// * If [id] has never been generated and all active transformers provide
// metadata about the file names of assets it can emit, we can prove that
// none of them can emit [id] and fail early.
return newFuture(() {
var node = _getAssetNode(id);

return _phases.last.getInput(id).then((node) {
// If the requested asset is available, we can just return it.
if (node != null) return node;
if (node != null && node.state.isAvailable) return node;

// If there's a build running, that build might generate the asset, so we
// wait for it to complete and then try again.
Expand All @@ -144,24 +144,6 @@ class AssetCascade {
});
}

// Returns the post-transformation asset node for [id], if one is available.
//
// This will only return a node that has an asset available, and only if that
// node is guaranteed not to be consumed by any transforms. If the phase is
// still working to figure out if a node will be consumed by a transformer,
// that node won't be returned.
AssetNode _getAssetNode(AssetId id) {
// Each phase's inputs are the outputs of the previous phase. Find the last
// phase that contains the asset. Since the last phase has no transformers,
// this will find the latest output for that id.
for (var i = _phases.length - 1; i >= 0; i--) {
var node = _phases[i].getUnconsumedInput(id);
if (node != null) return node;
}

return null;
}

/// Adds [sources] to the graph's known set of source assets.
///
/// Begins applying any transforms that can consume any of the sources. If a
Expand Down
2 changes: 1 addition & 1 deletion pkg/barback/lib/src/barback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Barback {
Future<Asset> getAssetById(AssetId id) {
return _graph.getAssetNode(id).then((node) {
if (node == null) throw new AssetNotFoundException(id);
return node.whenAvailable;
return node.asset;
});
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/barback/lib/src/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ abstract class BarbackException implements Exception {}
/// Error thrown when two or more transformers both output an asset with [id].
class AssetCollisionException implements BarbackException {
/// All the transforms that output an asset with [id].
///
/// If this only contains a single transform, that indicates that a
/// transformer produced an output that collides with a source asset or an
/// asset from a previous phase.
final Set<TransformInfo> transforms;
final AssetId id;

Expand Down
6 changes: 4 additions & 2 deletions pkg/barback/lib/src/package_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ class PackageGraph {
/// Gets the asset node identified by [id].
///
/// If [id] is for a generated or transformed asset, this will wait until it
/// has been created and return it. If the asset cannot be found, returns
/// null.
/// has been created and return it. This means that the returned asset will
/// always be [AssetState.AVAILABLE].
///
/// If the asset cannot be found, returns null.
Future<AssetNode> getAssetNode(AssetId id) {
var cascade = _cascades[id.package];
if (cascade != null) return cascade.getAssetNode(id);
Expand Down
113 changes: 81 additions & 32 deletions pkg/barback/lib/src/phase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class Phase {
/// is a transformer. "dart2js on web/main.dart" is a transform.
final _transforms = new Map<AssetId, Set<TransformNode>>();

/// Controllers for assets that aren't consumed by transforms in this phase.
///
/// These assets are passed to the next phase unmodified. They need
/// intervening controllers to ensure that the outputs can be marked dirty
/// when determining whether transforms apply, and removed if they do.
final _passThroughControllers = new Map<AssetId, AssetNodeController>();

/// Futures that will complete once the transformers that can consume a given
/// asset are determined.
///
Expand All @@ -73,10 +80,10 @@ class Phase {
/// transforms that produced those asset nodes.
///
/// Usually there's only one node for a given output id. However, it's
/// possible for multiple transformers in this phase to output an asset with
/// the same id. In that case, the chronologically first output emitted is
/// passed forward. We keep track of the other nodes so that if that output is
/// removed, we know which asset to replace it with.
/// possible for multiple transformers to output an asset with the same id. In
/// that case, the chronologically first output emitted is passed forward. We
/// keep track of the other nodes so that if that output is removed, we know
/// which asset to replace it with.
final _outputs = new Map<AssetId, Queue<AssetNode>>();

/// A stream that emits an event whenever this phase becomes dirty and needs
Expand Down Expand Up @@ -163,36 +170,11 @@ class Phase {
});
}

/// Returns the input for this phase with the given [id], but only if that
/// input is known not to be consumed as a transformer's primary input.
///
/// If the input is unavailable, or if the phase hasn't determined whether or
/// not any transformers will consume it as a primary input, null will be
/// returned instead. This means that the return value is guaranteed to always
/// be [AssetState.AVAILABLE].
AssetNode getUnconsumedInput(AssetId id) {
if (!_inputs.containsKey(id)) return null;

// If the asset has transforms, it's not unconsumed.
if (!_transforms[id].isEmpty) return null;

// If we're working on figuring out if the asset has transforms, we can't
// prove that it's unconsumed.
if (_adjustTransformersFutures.containsKey(id)) return null;

// The asset should be available. If it were removed, it wouldn't be in
// _inputs, and if it were dirty, it'd be in _adjustTransformersFutures.
assert(_inputs[id].state.isAvailable);
return _inputs[id];
}

/// Gets the asset node for an input [id].
///
/// If an input with that ID cannot be found, returns null.
Future<AssetNode> getInput(AssetId id) {
return newFuture(() {
// TODO(rnystrom): Need to handle passthrough where an asset from a
// previous phase can be found.
if (id.package == cascade.package) return _inputs[id];
return cascade.graph.getAssetNode(id);
});
Expand All @@ -210,6 +192,11 @@ class Phase {
// kick off a build, even if that build does nothing.
_onDirtyController.add(null);

// If there's a pass-through for this node, mark it dirty while we figure
// out whether we need to add any transforms for it.
var controller = _passThroughControllers[node.id];
if (controller != null) controller.setDirty();

// Once the input is available, hook up transformers for it. If it changes
// while that's happening, try again.
_adjustTransformersFutures[node.id] = node.tryUntilStable((asset) {
Expand All @@ -219,13 +206,17 @@ class Phase {
return _removeStaleTransforms(asset)
.then((_) => _addFreshTransforms(node, oldTransformers));
}).then((_) {
_adjustPassThrough(node);

// Now all the transforms are set up correctly and the asset is available
// for the time being. Set up handlers for when the asset changes in the
// future.
node.onStateChange.first.then((state) {
if (state.isRemoved) {
_onDirtyController.add(null);
_transforms.remove(node.id);
var passThrough = _passThroughControllers.remove(node.id);
if (passThrough != null) passThrough.setRemoved();
} else {
_adjustTransformers(node);
}
Expand All @@ -237,8 +228,10 @@ class Phase {

// If the asset is removed, [tryUntilStable] will throw an
// [AssetNotFoundException]. In that case, just remove all transforms for
// the node.
// the node, and its pass-through.
_transforms.remove(node.id);
var passThrough = _passThroughControllers.remove(node.id);
if (passThrough != null) passThrough.setRemoved();
}).whenComplete(() {
_adjustTransformersFutures.remove(node.id);
});
Expand Down Expand Up @@ -291,6 +284,28 @@ class Phase {
}));
}

/// Adjust whether [node] is passed through the phase unmodified, based on
/// whether it's consumed by other transforms in this phase.
///
/// If [node] was already passed-through, this will update the passed-through
/// value.
void _adjustPassThrough(AssetNode node) {
assert(node.state.isAvailable);

if (_transforms[node.id].isEmpty) {
var controller = _passThroughControllers[node.id];
if (controller != null) {
controller.setAvailable(node.asset);
} else {
_passThroughControllers[node.id] =
new AssetNodeController.available(node.asset, node.transform);
}
} else {
var controller = _passThroughControllers.remove(node.id);
if (controller != null) controller.setRemoved();
}
}

/// Processes this phase.
///
/// Returns a future that completes when processing is done. If there is
Expand All @@ -308,14 +323,24 @@ class Phase {

/// Applies all currently wired up and dirty transforms.
Future _processTransforms() {
if (_next == null) return;

var newPassThroughs = _passThroughControllers.values
.map((controller) => controller.node)
.where((output) {
return !_outputs.containsKey(output.id) ||
!_outputs[output.id].contains(output);
}).toSet();

// Convert this to a list so we can safely modify _transforms while
// iterating over it.
var dirtyTransforms =
flatten(_transforms.values.map((transforms) => transforms.toList()))
.where((transform) => transform.isDirty).toList();
if (dirtyTransforms.isEmpty) return null;

var collisions = new Set<AssetId>();
if (dirtyTransforms.isEmpty && newPassThroughs.isEmpty) return null;

var collisions = _passAssetsThrough(newPassThroughs);
return Future.wait(dirtyTransforms.map((transform) {
return transform.apply().then((outputs) {
for (var output in outputs) {
Expand Down Expand Up @@ -346,6 +371,30 @@ class Phase {
});
}

/// Pass all new assets that aren't consumed by transforms through to the next
/// phase.
///
/// Returns a set of asset ids that have collisions between new passed-through
/// assets and pre-existing transform outputs.
Set<AssetId> _passAssetsThrough(Set<AssetId> newPassThroughs) {
var collisions = new Set<AssetId>();
for (var output in newPassThroughs) {
if (_outputs.containsKey(output.id)) {
// There shouldn't be another pass-through asset with the same id.
assert(!_outputs[output.id].any((asset) => asset.transform == null));

_outputs[output.id].add(output);
collisions.add(output.id);
} else {
_outputs[output.id] = new Queue<AssetNode>.from([output]);
_next.addInput(output);
}

_handleOutputRemoval(output);
}
return collisions;
}

/// Properly resolve collisions when [output] is removed.
void _handleOutputRemoval(AssetNode output) {
output.whenRemoved.then((_) {
Expand Down
Loading

0 comments on commit 0b2b0fe

Please sign in to comment.