Skip to content

Commit

Permalink
[dartdevc] Remove redundant parameters from helper methods
Browse files Browse the repository at this point in the history
These were added to unify code paths between SetLiteral, MapLiteral and
SetOrMapLiteral visitors. SetLiteral and MapLiteral nodes have been removed
so elements can be accessed safely through the node parameter.

Change-Id: Ib42cc85d2a2307115618601359e573a15a3d3f1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97944
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
  • Loading branch information
nshahan authored and commit-bot@chromium.org committed Mar 27, 2019
1 parent 1bbd282 commit a9ee080
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions pkg/dev_compiler/lib/src/analyzer/code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5628,15 +5628,13 @@ class CodeGenerator extends Object
return _emitConstList(elementType, elements);
}

// TODO(nshahan) Cleanup after control flow collections experiments are removed.
JS.Expression _emitSetLiteral(
Iterable<CollectionElement> elements, SetOrMapLiteral node) {
JS.Expression _emitSetLiteral(SetOrMapLiteral node) {
var type = node.staticType as InterfaceType;
var elementType = type.typeArguments[0];
var jsElements = _visitCollectionElementList(elements, elementType);
var jsElements = _visitCollectionElementList(node.elements, elementType);
if (!node.isConst) {
var setType = _emitType(type);
if (elements.isEmpty) {
if (node.elements.isEmpty) {
return js.call('#.new()', [setType]);
}
return js.call('#.from([#])', [setType, jsElements]);
Expand Down Expand Up @@ -5666,14 +5664,13 @@ class CodeGenerator extends Object
return js.call('#.of(#)', [_emitType(arrayType), list]);
}

JS.Expression _emitMapLiteral(
Iterable<CollectionElement> elements, SetOrMapLiteral node) {
JS.Expression _emitMapLiteral(SetOrMapLiteral node) {
var type = node.staticType as InterfaceType;
var elementType = type.typeArguments[0];
var jsElements = _visitCollectionElementList(elements, elementType);
var jsElements = _visitCollectionElementList(node.elements, elementType);
if (!node.isConst) {
var mapType = _emitMapImplType(type);
if (elements.isEmpty) {
if (node.elements.isEmpty) {
return js.call('new #.new()', [mapType]);
}
return js.call('new #.from([#])', [mapType, jsElements]);
Expand Down Expand Up @@ -6519,9 +6516,8 @@ class CodeGenerator extends Object
}

@override
visitSetOrMapLiteral(SetOrMapLiteral node) => node.isSet
? _emitSetLiteral(node.elements, node)
: _emitMapLiteral(node.elements, node);
visitSetOrMapLiteral(SetOrMapLiteral node) =>
node.isSet ? _emitSetLiteral(node) : _emitMapLiteral(node);

@override
JS.Statement visitSpreadElement(SpreadElement node) {
Expand Down

0 comments on commit a9ee080

Please sign in to comment.