mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:44:27 +00:00
[dart2js] dart format --fix in common/
and native
Purely mechanical except for moving a comment in one typedef. Change-Id: I460d14aabb6081c92dd37bdfe835f7c3ad59c0f3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212025 Reviewed-by: Mayank Patke <fishythefish@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
ef2784b4a8
commit
6e372971d6
7 changed files with 184 additions and 191 deletions
|
@ -43,7 +43,7 @@ class CodegenImpact extends WorldImpact {
|
|||
_CodegenImpact.readFromDataSource;
|
||||
|
||||
void writeToDataSink(DataSink sink) {
|
||||
throw new UnsupportedError('CodegenImpact.writeToDataSink');
|
||||
throw UnsupportedError('CodegenImpact.writeToDataSink');
|
||||
}
|
||||
|
||||
Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks {
|
||||
|
@ -123,7 +123,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
|||
?.toSet();
|
||||
Set<Pair<DartType, DartType>> typeVariableBoundsSubtypeChecks =
|
||||
source.readList(() {
|
||||
return new Pair(source.readDartType(), source.readDartType());
|
||||
return Pair(source.readDartType(), source.readDartType());
|
||||
}, emptyAsNull: true)?.toSet();
|
||||
Set<String> constSymbols = source.readStrings(emptyAsNull: true)?.toSet();
|
||||
List<Set<ClassEntity>> specializedGetInterceptors = source.readList(() {
|
||||
|
@ -131,9 +131,8 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
|||
}, emptyAsNull: true);
|
||||
bool usesInterceptor = source.readBool();
|
||||
int asyncMarkersValue = source.readIntOrNull();
|
||||
EnumSet<AsyncMarker> asyncMarkers = asyncMarkersValue != null
|
||||
? new EnumSet.fromValue(asyncMarkersValue)
|
||||
: null;
|
||||
EnumSet<AsyncMarker> asyncMarkers =
|
||||
asyncMarkersValue != null ? EnumSet.fromValue(asyncMarkersValue) : null;
|
||||
Set<GenericInstantiation> genericInstantiations = source
|
||||
.readList(() => GenericInstantiation.readFromDataSource(source),
|
||||
emptyAsNull: true)
|
||||
|
@ -147,7 +146,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
|||
.readList(() => Selector.readFromDataSource(source), emptyAsNull: true)
|
||||
?.toSet();
|
||||
source.end(tag);
|
||||
return new _CodegenImpact.internal(
|
||||
return _CodegenImpact.internal(
|
||||
member,
|
||||
dynamicUses,
|
||||
staticUses,
|
||||
|
@ -214,7 +213,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
|||
DartType subtype, DartType supertype) {
|
||||
_typeVariableBoundsSubtypeChecks ??= {};
|
||||
_typeVariableBoundsSubtypeChecks
|
||||
.add(new Pair<DartType, DartType>(subtype, supertype));
|
||||
.add(Pair<DartType, DartType>(subtype, supertype));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -254,7 +253,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
|||
bool get usesInterceptor => _usesInterceptor;
|
||||
|
||||
void registerAsyncMarker(AsyncMarker asyncMarker) {
|
||||
_asyncMarkers ??= new EnumSet<AsyncMarker>();
|
||||
_asyncMarkers ??= EnumSet<AsyncMarker>();
|
||||
_asyncMarkers.add(asyncMarker);
|
||||
}
|
||||
|
||||
|
@ -307,7 +306,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('CodegenImpact:');
|
||||
WorldImpact.printOn(sb, this);
|
||||
|
||||
|
@ -344,7 +343,7 @@ class CodegenRegistry {
|
|||
List<ModularExpression> _expressions;
|
||||
|
||||
CodegenRegistry(this._elementEnvironment, this._currentElement)
|
||||
: this._worldImpact = new _CodegenImpact(_currentElement);
|
||||
: this._worldImpact = _CodegenImpact(_currentElement);
|
||||
|
||||
@override
|
||||
String toString() => 'CodegenRegistry for $_currentElement';
|
||||
|
@ -376,7 +375,7 @@ class CodegenRegistry {
|
|||
}
|
||||
|
||||
void registerInstantiatedClosure(FunctionEntity element) {
|
||||
_worldImpact.registerStaticUse(new StaticUse.callMethod(element));
|
||||
_worldImpact.registerStaticUse(StaticUse.callMethod(element));
|
||||
}
|
||||
|
||||
void registerConstSymbol(String name) {
|
||||
|
@ -396,7 +395,7 @@ class CodegenRegistry {
|
|||
}
|
||||
|
||||
void registerInstantiation(InterfaceType type) {
|
||||
registerTypeUse(new TypeUse.instantiation(type));
|
||||
registerTypeUse(TypeUse.instantiation(type));
|
||||
}
|
||||
|
||||
void registerAsyncMarker(AsyncMarker asyncMarker) {
|
||||
|
@ -426,7 +425,7 @@ class CodegenRegistry {
|
|||
}
|
||||
|
||||
CodegenResult close(js.Fun code) {
|
||||
return new CodegenResult(
|
||||
return CodegenResult(
|
||||
code, _worldImpact, _names ?? const [], _expressions ?? const []);
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +597,7 @@ class CodegenResult {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('CodegenResult(code=');
|
||||
sb.write(code != null ? js.DebugPrint(code) : '<null>,');
|
||||
sb.write('impact=$impact,');
|
||||
|
@ -678,7 +677,7 @@ class ModularName extends js.Name implements js.AstContainer {
|
|||
break;
|
||||
}
|
||||
source.end(tag);
|
||||
return new ModularName(kind, data: data, set: set);
|
||||
return ModularName(kind, data: data, set: set);
|
||||
}
|
||||
|
||||
void writeToDataSink(DataSink sink) {
|
||||
|
@ -805,7 +804,7 @@ class ModularExpression extends js.DeferredExpression
|
|||
break;
|
||||
}
|
||||
source.end(tag);
|
||||
return new ModularExpression(kind, data);
|
||||
return ModularExpression(kind, data);
|
||||
}
|
||||
|
||||
void writeToDataSink(DataSink sink) {
|
||||
|
@ -857,7 +856,7 @@ class ModularExpression extends js.DeferredExpression
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('ModularExpression(kind=$kind,data=');
|
||||
if (data is ConstantValue) {
|
||||
sb.write((data as ConstantValue).toStructuredText(null));
|
||||
|
@ -1009,12 +1008,12 @@ class JsNodeSerializer implements js.NodeVisitor<void> {
|
|||
|
||||
static void writeToDataSink(DataSink sink, js.Node node) {
|
||||
sink.begin(JsNodeTags.tag);
|
||||
JsNodeSerializer serializer = new JsNodeSerializer._(sink);
|
||||
JsNodeSerializer serializer = JsNodeSerializer._(sink);
|
||||
serializer.visit(node);
|
||||
sink.end(JsNodeTags.tag);
|
||||
}
|
||||
|
||||
void visit(js.Node node, {bool allowNull: false}) {
|
||||
void visit(js.Node node, {bool allowNull = false}) {
|
||||
if (allowNull) {
|
||||
sink.writeBool(node != null);
|
||||
if (node != null) {
|
||||
|
@ -1038,32 +1037,32 @@ class JsNodeSerializer implements js.NodeVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitInterpolatedDeclaration(js.InterpolatedDeclaration node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitInterpolatedDeclaration');
|
||||
throw UnsupportedError('JsNodeSerializer.visitInterpolatedDeclaration');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterpolatedStatement(js.InterpolatedStatement node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitInterpolatedStatement');
|
||||
throw UnsupportedError('JsNodeSerializer.visitInterpolatedStatement');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterpolatedSelector(js.InterpolatedSelector node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitInterpolatedDeclaration');
|
||||
throw UnsupportedError('JsNodeSerializer.visitInterpolatedDeclaration');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterpolatedParameter(js.InterpolatedParameter node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitInterpolatedParameter');
|
||||
throw UnsupportedError('JsNodeSerializer.visitInterpolatedParameter');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterpolatedLiteral(js.InterpolatedLiteral node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitInterpolatedLiteral');
|
||||
throw UnsupportedError('JsNodeSerializer.visitInterpolatedLiteral');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterpolatedExpression(js.InterpolatedExpression node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitInterpolatedExpression');
|
||||
throw UnsupportedError('JsNodeSerializer.visitInterpolatedExpression');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1171,7 +1170,7 @@ class JsNodeSerializer implements js.NodeVisitor<void> {
|
|||
sink.end(JsNodeTags.stringBackedName);
|
||||
_writeInfo(node);
|
||||
} else {
|
||||
throw new UnsupportedError(
|
||||
throw UnsupportedError(
|
||||
'Unexpected deferred expression: ${node.runtimeType}.');
|
||||
}
|
||||
}
|
||||
|
@ -1229,17 +1228,17 @@ class JsNodeSerializer implements js.NodeVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitDeferredString(js.DeferredString node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitDeferredString');
|
||||
throw UnsupportedError('JsNodeSerializer.visitDeferredString');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitDeferredStatement(js.DeferredStatement node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitDeferredStatement');
|
||||
throw UnsupportedError('JsNodeSerializer.visitDeferredStatement');
|
||||
}
|
||||
|
||||
@override
|
||||
void visitDeferredNumber(js.DeferredNumber node) {
|
||||
throw new UnsupportedError('JsNodeSerializer.visitDeferredNumber');
|
||||
throw UnsupportedError('JsNodeSerializer.visitDeferredNumber');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1269,7 +1268,7 @@ class JsNodeSerializer implements js.NodeVisitor<void> {
|
|||
sink.end(JsNodeTags.deferredHolderExpression);
|
||||
_writeInfo(node);
|
||||
} else {
|
||||
throw new UnsupportedError(
|
||||
throw UnsupportedError(
|
||||
'Unexpected deferred expression: ${node.runtimeType}.');
|
||||
}
|
||||
}
|
||||
|
@ -1686,13 +1685,13 @@ class JsNodeDeserializer {
|
|||
List<ModularExpression> modularExpressions) {
|
||||
source.begin(JsNodeTags.tag);
|
||||
JsNodeDeserializer deserializer =
|
||||
new JsNodeDeserializer._(source, modularNames, modularExpressions);
|
||||
JsNodeDeserializer._(source, modularNames, modularExpressions);
|
||||
js.Node node = deserializer.read();
|
||||
source.end(JsNodeTags.tag);
|
||||
return node;
|
||||
}
|
||||
|
||||
T read<T extends js.Node>({bool allowNull: false}) {
|
||||
T read<T extends js.Node>({bool allowNull = false}) {
|
||||
if (allowNull) {
|
||||
bool hasValue = source.readBool();
|
||||
if (!hasValue) return null;
|
||||
|
@ -1702,54 +1701,54 @@ class JsNodeDeserializer {
|
|||
switch (kind) {
|
||||
case JsNodeKind.comment:
|
||||
source.begin(JsNodeTags.comment);
|
||||
node = new js.Comment(source.readString());
|
||||
node = js.Comment(source.readString());
|
||||
source.end(JsNodeTags.comment);
|
||||
break;
|
||||
case JsNodeKind.await:
|
||||
source.begin(JsNodeTags.await);
|
||||
node = new js.Await(read());
|
||||
node = js.Await(read());
|
||||
source.end(JsNodeTags.await);
|
||||
break;
|
||||
case JsNodeKind.regExpLiteral:
|
||||
source.begin(JsNodeTags.regExpLiteral);
|
||||
node = new js.RegExpLiteral(source.readString());
|
||||
node = js.RegExpLiteral(source.readString());
|
||||
source.end(JsNodeTags.regExpLiteral);
|
||||
break;
|
||||
case JsNodeKind.property:
|
||||
source.begin(JsNodeTags.property);
|
||||
js.Expression name = read();
|
||||
js.Expression value = read();
|
||||
node = new js.Property(name, value);
|
||||
node = js.Property(name, value);
|
||||
source.end(JsNodeTags.property);
|
||||
break;
|
||||
case JsNodeKind.methodDefinition:
|
||||
source.begin(JsNodeTags.methodDefinition);
|
||||
js.Expression name = read();
|
||||
js.Expression function = read();
|
||||
node = new js.MethodDefinition(name, function);
|
||||
node = js.MethodDefinition(name, function);
|
||||
source.end(JsNodeTags.methodDefinition);
|
||||
break;
|
||||
case JsNodeKind.objectInitializer:
|
||||
source.begin(JsNodeTags.objectInitializer);
|
||||
List<js.Property> properties = readList();
|
||||
bool isOneLiner = source.readBool();
|
||||
node = new js.ObjectInitializer(properties, isOneLiner: isOneLiner);
|
||||
node = js.ObjectInitializer(properties, isOneLiner: isOneLiner);
|
||||
source.end(JsNodeTags.objectInitializer);
|
||||
break;
|
||||
case JsNodeKind.arrayHole:
|
||||
source.begin(JsNodeTags.arrayHole);
|
||||
node = new js.ArrayHole();
|
||||
node = js.ArrayHole();
|
||||
source.end(JsNodeTags.arrayHole);
|
||||
break;
|
||||
case JsNodeKind.arrayInitializer:
|
||||
source.begin(JsNodeTags.arrayInitializer);
|
||||
List<js.Expression> elements = readList();
|
||||
node = new js.ArrayInitializer(elements);
|
||||
node = js.ArrayInitializer(elements);
|
||||
source.end(JsNodeTags.arrayInitializer);
|
||||
break;
|
||||
case JsNodeKind.parentheses:
|
||||
source.begin(JsNodeTags.parentheses);
|
||||
node = new js.Parentheses(read());
|
||||
node = js.Parentheses(read());
|
||||
source.end(JsNodeTags.parentheses);
|
||||
break;
|
||||
case JsNodeKind.modularName:
|
||||
|
@ -1763,44 +1762,44 @@ class JsNodeDeserializer {
|
|||
source.begin(JsNodeTags.asyncName);
|
||||
js.Name prefix = read();
|
||||
js.Name base = read();
|
||||
node = new AsyncName(prefix, base);
|
||||
node = AsyncName(prefix, base);
|
||||
source.end(JsNodeTags.asyncName);
|
||||
break;
|
||||
case JsNodeKind.stringBackedName:
|
||||
source.begin(JsNodeTags.stringBackedName);
|
||||
node = new StringBackedName(source.readString());
|
||||
node = StringBackedName(source.readString());
|
||||
source.end(JsNodeTags.stringBackedName);
|
||||
break;
|
||||
case JsNodeKind.stringConcatenation:
|
||||
source.begin(JsNodeTags.stringConcatenation);
|
||||
List<js.Literal> parts = readList();
|
||||
node = new js.StringConcatenation(parts);
|
||||
node = js.StringConcatenation(parts);
|
||||
source.end(JsNodeTags.stringConcatenation);
|
||||
break;
|
||||
case JsNodeKind.literalNull:
|
||||
source.begin(JsNodeTags.literalNull);
|
||||
node = new js.LiteralNull();
|
||||
node = js.LiteralNull();
|
||||
source.end(JsNodeTags.literalNull);
|
||||
break;
|
||||
case JsNodeKind.literalNumber:
|
||||
source.begin(JsNodeTags.literalNumber);
|
||||
node = new js.LiteralNumber(source.readString());
|
||||
node = js.LiteralNumber(source.readString());
|
||||
source.end(JsNodeTags.literalNumber);
|
||||
break;
|
||||
case JsNodeKind.literalString:
|
||||
source.begin(JsNodeTags.literalString);
|
||||
node = new js.LiteralString(source.readString());
|
||||
node = js.LiteralString(source.readString());
|
||||
source.end(JsNodeTags.literalString);
|
||||
break;
|
||||
case JsNodeKind.literalStringFromName:
|
||||
source.begin(JsNodeTags.literalStringFromName);
|
||||
js.Name name = read();
|
||||
node = new js.LiteralStringFromName(name);
|
||||
node = js.LiteralStringFromName(name);
|
||||
source.end(JsNodeTags.literalStringFromName);
|
||||
break;
|
||||
case JsNodeKind.literalBool:
|
||||
source.begin(JsNodeTags.literalBool);
|
||||
node = new js.LiteralBool(source.readBool());
|
||||
node = js.LiteralBool(source.readBool());
|
||||
source.end(JsNodeTags.literalBool);
|
||||
break;
|
||||
case JsNodeKind.modularExpression:
|
||||
|
@ -1817,7 +1816,7 @@ class JsNodeDeserializer {
|
|||
js.Block body = read();
|
||||
js.AsyncModifier asyncModifier =
|
||||
source.readEnum(js.AsyncModifier.values);
|
||||
node = new js.Fun(params, body, asyncModifier: asyncModifier);
|
||||
node = js.Fun(params, body, asyncModifier: asyncModifier);
|
||||
source.end(JsNodeTags.function);
|
||||
break;
|
||||
case JsNodeKind.arrowFunction:
|
||||
|
@ -1826,57 +1825,57 @@ class JsNodeDeserializer {
|
|||
js.Block body = read();
|
||||
js.AsyncModifier asyncModifier =
|
||||
source.readEnum(js.AsyncModifier.values);
|
||||
node = new js.ArrowFunction(params, body, asyncModifier: asyncModifier);
|
||||
node = js.ArrowFunction(params, body, asyncModifier: asyncModifier);
|
||||
source.end(JsNodeTags.arrowFunction);
|
||||
break;
|
||||
case JsNodeKind.namedFunction:
|
||||
source.begin(JsNodeTags.namedFunction);
|
||||
js.Declaration name = read();
|
||||
js.Fun function = read();
|
||||
node = new js.NamedFunction(name, function);
|
||||
node = js.NamedFunction(name, function);
|
||||
source.end(JsNodeTags.namedFunction);
|
||||
break;
|
||||
case JsNodeKind.access:
|
||||
source.begin(JsNodeTags.access);
|
||||
js.Expression receiver = read();
|
||||
js.Expression selector = read();
|
||||
node = new js.PropertyAccess(receiver, selector);
|
||||
node = js.PropertyAccess(receiver, selector);
|
||||
source.end(JsNodeTags.access);
|
||||
break;
|
||||
case JsNodeKind.parameter:
|
||||
source.begin(JsNodeTags.parameter);
|
||||
node = new js.Parameter(source.readString());
|
||||
node = js.Parameter(source.readString());
|
||||
source.end(JsNodeTags.parameter);
|
||||
break;
|
||||
case JsNodeKind.variableDeclaration:
|
||||
source.begin(JsNodeTags.variableDeclaration);
|
||||
String name = source.readString();
|
||||
bool allowRename = source.readBool();
|
||||
node = new js.VariableDeclaration(name, allowRename: allowRename);
|
||||
node = js.VariableDeclaration(name, allowRename: allowRename);
|
||||
source.end(JsNodeTags.variableDeclaration);
|
||||
break;
|
||||
case JsNodeKind.thisExpression:
|
||||
source.begin(JsNodeTags.thisExpression);
|
||||
node = new js.This();
|
||||
node = js.This();
|
||||
source.end(JsNodeTags.thisExpression);
|
||||
break;
|
||||
case JsNodeKind.variableUse:
|
||||
source.begin(JsNodeTags.variableUse);
|
||||
node = new js.VariableUse(source.readString());
|
||||
node = js.VariableUse(source.readString());
|
||||
source.end(JsNodeTags.variableUse);
|
||||
break;
|
||||
case JsNodeKind.postfix:
|
||||
source.begin(JsNodeTags.postfix);
|
||||
String op = source.readString();
|
||||
js.Expression argument = read();
|
||||
node = new js.Postfix(op, argument);
|
||||
node = js.Postfix(op, argument);
|
||||
source.end(JsNodeTags.postfix);
|
||||
break;
|
||||
case JsNodeKind.prefix:
|
||||
source.begin(JsNodeTags.prefix);
|
||||
String op = source.readString();
|
||||
js.Expression argument = read();
|
||||
node = new js.Prefix(op, argument);
|
||||
node = js.Prefix(op, argument);
|
||||
source.end(JsNodeTags.prefix);
|
||||
break;
|
||||
case JsNodeKind.binary:
|
||||
|
@ -1884,21 +1883,21 @@ class JsNodeDeserializer {
|
|||
String op = source.readString();
|
||||
js.Expression left = read();
|
||||
js.Expression right = read();
|
||||
node = new js.Binary(op, left, right);
|
||||
node = js.Binary(op, left, right);
|
||||
source.end(JsNodeTags.binary);
|
||||
break;
|
||||
case JsNodeKind.callExpression:
|
||||
source.begin(JsNodeTags.callExpression);
|
||||
js.Expression target = read();
|
||||
List<js.Expression> arguments = readList();
|
||||
node = new js.Call(target, arguments);
|
||||
node = js.Call(target, arguments);
|
||||
source.end(JsNodeTags.callExpression);
|
||||
break;
|
||||
case JsNodeKind.newExpression:
|
||||
source.begin(JsNodeTags.newExpression);
|
||||
js.Expression cls = read();
|
||||
List<js.Expression> arguments = readList();
|
||||
node = new js.New(cls, arguments);
|
||||
node = js.New(cls, arguments);
|
||||
source.end(JsNodeTags.newExpression);
|
||||
break;
|
||||
case JsNodeKind.conditional:
|
||||
|
@ -1906,14 +1905,14 @@ class JsNodeDeserializer {
|
|||
js.Expression condition = read();
|
||||
js.Expression then = read();
|
||||
js.Expression otherwise = read();
|
||||
node = new js.Conditional(condition, then, otherwise);
|
||||
node = js.Conditional(condition, then, otherwise);
|
||||
source.end(JsNodeTags.conditional);
|
||||
break;
|
||||
case JsNodeKind.variableInitialization:
|
||||
source.begin(JsNodeTags.variableInitialization);
|
||||
js.Declaration declaration = read();
|
||||
js.Expression value = source.readValueOrNull(read);
|
||||
node = new js.VariableInitialization(declaration, value);
|
||||
node = js.VariableInitialization(declaration, value);
|
||||
source.end(JsNodeTags.variableInitialization);
|
||||
break;
|
||||
case JsNodeKind.assignment:
|
||||
|
@ -1921,73 +1920,73 @@ class JsNodeDeserializer {
|
|||
js.Expression leftHandSide = read();
|
||||
String op = source.readStringOrNull();
|
||||
js.Expression value = read();
|
||||
node = new js.Assignment.compound(leftHandSide, op, value);
|
||||
node = js.Assignment.compound(leftHandSide, op, value);
|
||||
source.end(JsNodeTags.assignment);
|
||||
break;
|
||||
case JsNodeKind.variableDeclarationList:
|
||||
source.begin(JsNodeTags.variableDeclarationList);
|
||||
List<js.VariableInitialization> declarations = readList();
|
||||
bool indentSplits = source.readBool();
|
||||
node = new js.VariableDeclarationList(declarations,
|
||||
node = js.VariableDeclarationList(declarations,
|
||||
indentSplits: indentSplits);
|
||||
source.end(JsNodeTags.variableDeclarationList);
|
||||
break;
|
||||
case JsNodeKind.literalExpression:
|
||||
source.begin(JsNodeTags.literalExpression);
|
||||
node = new js.LiteralExpression(source.readString());
|
||||
node = js.LiteralExpression(source.readString());
|
||||
source.end(JsNodeTags.literalExpression);
|
||||
break;
|
||||
case JsNodeKind.dartYield:
|
||||
source.begin(JsNodeTags.dartYield);
|
||||
js.Expression expression = read();
|
||||
bool hasStar = source.readBool();
|
||||
node = new js.DartYield(expression, hasStar);
|
||||
node = js.DartYield(expression, hasStar);
|
||||
source.end(JsNodeTags.dartYield);
|
||||
break;
|
||||
case JsNodeKind.literalStatement:
|
||||
source.begin(JsNodeTags.literalStatement);
|
||||
node = new js.LiteralStatement(source.readString());
|
||||
node = js.LiteralStatement(source.readString());
|
||||
source.end(JsNodeTags.literalStatement);
|
||||
break;
|
||||
case JsNodeKind.labeledStatement:
|
||||
source.begin(JsNodeTags.labeledStatement);
|
||||
String label = source.readString();
|
||||
js.Statement body = read();
|
||||
node = new js.LabeledStatement(label, body);
|
||||
node = js.LabeledStatement(label, body);
|
||||
source.end(JsNodeTags.labeledStatement);
|
||||
break;
|
||||
case JsNodeKind.functionDeclaration:
|
||||
source.begin(JsNodeTags.functionDeclaration);
|
||||
js.Declaration name = read();
|
||||
js.Fun function = read();
|
||||
node = new js.FunctionDeclaration(name, function);
|
||||
node = js.FunctionDeclaration(name, function);
|
||||
source.end(JsNodeTags.functionDeclaration);
|
||||
break;
|
||||
case JsNodeKind.switchDefault:
|
||||
source.begin(JsNodeTags.switchDefault);
|
||||
js.Block body = read();
|
||||
node = new js.Default(body);
|
||||
node = js.Default(body);
|
||||
source.end(JsNodeTags.switchDefault);
|
||||
break;
|
||||
case JsNodeKind.switchCase:
|
||||
source.begin(JsNodeTags.switchCase);
|
||||
js.Expression expression = read();
|
||||
js.Block body = read();
|
||||
node = new js.Case(expression, body);
|
||||
node = js.Case(expression, body);
|
||||
source.end(JsNodeTags.switchCase);
|
||||
break;
|
||||
case JsNodeKind.switchStatement:
|
||||
source.begin(JsNodeTags.switchStatement);
|
||||
js.Expression key = read();
|
||||
List<js.SwitchClause> cases = readList();
|
||||
node = new js.Switch(key, cases);
|
||||
node = js.Switch(key, cases);
|
||||
source.end(JsNodeTags.switchStatement);
|
||||
break;
|
||||
case JsNodeKind.catchClause:
|
||||
source.begin(JsNodeTags.catchClause);
|
||||
js.Declaration declaration = read();
|
||||
js.Block body = read();
|
||||
node = new js.Catch(declaration, body);
|
||||
node = js.Catch(declaration, body);
|
||||
source.end(JsNodeTags.catchClause);
|
||||
break;
|
||||
case JsNodeKind.tryStatement:
|
||||
|
@ -1995,45 +1994,45 @@ class JsNodeDeserializer {
|
|||
js.Block body = read();
|
||||
js.Catch catchPart = source.readValueOrNull(read);
|
||||
js.Block finallyPart = source.readValueOrNull(read);
|
||||
node = new js.Try(body, catchPart, finallyPart);
|
||||
node = js.Try(body, catchPart, finallyPart);
|
||||
source.end(JsNodeTags.tryStatement);
|
||||
break;
|
||||
case JsNodeKind.throwStatement:
|
||||
source.begin(JsNodeTags.throwStatement);
|
||||
js.Expression expression = read();
|
||||
node = new js.Throw(expression);
|
||||
node = js.Throw(expression);
|
||||
source.end(JsNodeTags.throwStatement);
|
||||
break;
|
||||
case JsNodeKind.returnStatement:
|
||||
source.begin(JsNodeTags.returnStatement);
|
||||
js.Expression value = source.readValueOrNull(read);
|
||||
node = new js.Return(value);
|
||||
node = js.Return(value);
|
||||
source.end(JsNodeTags.returnStatement);
|
||||
break;
|
||||
case JsNodeKind.breakStatement:
|
||||
source.begin(JsNodeTags.breakStatement);
|
||||
String targetLabel = source.readStringOrNull();
|
||||
node = new js.Break(targetLabel);
|
||||
node = js.Break(targetLabel);
|
||||
source.end(JsNodeTags.breakStatement);
|
||||
break;
|
||||
case JsNodeKind.continueStatement:
|
||||
source.begin(JsNodeTags.continueStatement);
|
||||
String targetLabel = source.readStringOrNull();
|
||||
node = new js.Continue(targetLabel);
|
||||
node = js.Continue(targetLabel);
|
||||
source.end(JsNodeTags.continueStatement);
|
||||
break;
|
||||
case JsNodeKind.doStatement:
|
||||
source.begin(JsNodeTags.doStatement);
|
||||
js.Statement body = read();
|
||||
js.Expression condition = read();
|
||||
node = new js.Do(body, condition);
|
||||
node = js.Do(body, condition);
|
||||
source.end(JsNodeTags.doStatement);
|
||||
break;
|
||||
case JsNodeKind.whileStatement:
|
||||
source.begin(JsNodeTags.whileStatement);
|
||||
js.Expression condition = read();
|
||||
js.Statement body = read();
|
||||
node = new js.While(condition, body);
|
||||
node = js.While(condition, body);
|
||||
source.end(JsNodeTags.whileStatement);
|
||||
break;
|
||||
case JsNodeKind.forInStatement:
|
||||
|
@ -2041,7 +2040,7 @@ class JsNodeDeserializer {
|
|||
js.Expression leftHandSide = read();
|
||||
js.Expression object = read();
|
||||
js.Statement body = read();
|
||||
node = new js.ForIn(leftHandSide, object, body);
|
||||
node = js.ForIn(leftHandSide, object, body);
|
||||
source.end(JsNodeTags.forInStatement);
|
||||
break;
|
||||
case JsNodeKind.forStatement:
|
||||
|
@ -2050,7 +2049,7 @@ class JsNodeDeserializer {
|
|||
js.Expression condition = read(allowNull: true);
|
||||
js.Expression update = read(allowNull: true);
|
||||
js.Statement body = read();
|
||||
node = new js.For(init, condition, update, body);
|
||||
node = js.For(init, condition, update, body);
|
||||
source.end(JsNodeTags.forStatement);
|
||||
break;
|
||||
case JsNodeKind.ifStatement:
|
||||
|
@ -2058,29 +2057,29 @@ class JsNodeDeserializer {
|
|||
js.Expression condition = read();
|
||||
js.Statement then = read();
|
||||
js.Statement otherwise = read();
|
||||
node = new js.If(condition, then, otherwise);
|
||||
node = js.If(condition, then, otherwise);
|
||||
source.end(JsNodeTags.ifStatement);
|
||||
break;
|
||||
case JsNodeKind.emptyStatement:
|
||||
source.begin(JsNodeTags.emptyStatement);
|
||||
node = new js.EmptyStatement();
|
||||
node = js.EmptyStatement();
|
||||
source.end(JsNodeTags.emptyStatement);
|
||||
break;
|
||||
case JsNodeKind.expressionStatement:
|
||||
source.begin(JsNodeTags.expressionStatement);
|
||||
node = new js.ExpressionStatement(read());
|
||||
node = js.ExpressionStatement(read());
|
||||
source.end(JsNodeTags.expressionStatement);
|
||||
break;
|
||||
case JsNodeKind.block:
|
||||
source.begin(JsNodeTags.block);
|
||||
List<js.Statement> statements = readList();
|
||||
node = new js.Block(statements);
|
||||
node = js.Block(statements);
|
||||
source.end(JsNodeTags.block);
|
||||
break;
|
||||
case JsNodeKind.program:
|
||||
source.begin(JsNodeTags.program);
|
||||
List<js.Statement> body = readList();
|
||||
node = new js.Program(body);
|
||||
node = js.Program(body);
|
||||
source.end(JsNodeTags.program);
|
||||
break;
|
||||
case JsNodeKind.stringReference:
|
||||
|
@ -2109,7 +2108,7 @@ class JsNodeDeserializer {
|
|||
return node;
|
||||
}
|
||||
|
||||
List<T> readList<T extends js.Node>({bool emptyAsNull: false}) {
|
||||
List<T> readList<T extends js.Node>({bool emptyAsNull = false}) {
|
||||
return source.readList(read, emptyAsNull: emptyAsNull);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,89 +69,89 @@ class Identifiers {
|
|||
/// [Name]s commonly used.
|
||||
class Names {
|
||||
/// The name of the call operator.
|
||||
static const Name call = const PublicName(Identifiers.call);
|
||||
static const Name call = PublicName(Identifiers.call);
|
||||
|
||||
/// The name of the current element property used on iterators in for-each
|
||||
/// loops.
|
||||
static const Name current = const PublicName(Identifiers.current);
|
||||
static const Name current = PublicName(Identifiers.current);
|
||||
|
||||
/// The name of the dynamic type.
|
||||
static const Name dynamic_ = const PublicName('dynamic');
|
||||
static const Name dynamic_ = PublicName('dynamic');
|
||||
|
||||
/// The name of the iterator property used in for-each loops.
|
||||
static const Name iterator = const PublicName(Identifiers.iterator);
|
||||
static const Name iterator = PublicName(Identifiers.iterator);
|
||||
|
||||
/// The name of the move next method used on iterators in for-each loops.
|
||||
static const Name moveNext = const PublicName('moveNext');
|
||||
static const Name moveNext = PublicName('moveNext');
|
||||
|
||||
/// The name of the no such method handler on 'Object'.
|
||||
static const Name noSuchMethod_ = const PublicName(Identifiers.noSuchMethod_);
|
||||
static const Name noSuchMethod_ = PublicName(Identifiers.noSuchMethod_);
|
||||
|
||||
/// The name of the to-string method on 'Object'.
|
||||
static const Name toString_ = const PublicName('toString');
|
||||
static const Name toString_ = PublicName('toString');
|
||||
|
||||
static const Name INDEX_NAME = const PublicName("[]");
|
||||
static const Name INDEX_SET_NAME = const PublicName("[]=");
|
||||
static const Name INDEX_NAME = PublicName("[]");
|
||||
static const Name INDEX_SET_NAME = PublicName("[]=");
|
||||
static const Name CALL_NAME = Names.call;
|
||||
|
||||
static const Name length = const PublicName(Identifiers.length);
|
||||
static const Name length = PublicName(Identifiers.length);
|
||||
|
||||
static const Name runtimeType_ = const PublicName(Identifiers.runtimeType_);
|
||||
static const Name runtimeType_ = PublicName(Identifiers.runtimeType_);
|
||||
|
||||
static const Name genericInstantiation = const PublicName('instantiate');
|
||||
static const Name genericInstantiation = PublicName('instantiate');
|
||||
|
||||
/// The name of the signature function in closure classes.
|
||||
static const Name signature = const PublicName(Identifiers.signature);
|
||||
static const Name signature = PublicName(Identifiers.signature);
|
||||
}
|
||||
|
||||
/// [Selector]s commonly used.
|
||||
class Selectors {
|
||||
/// The selector for calling the cancel method on 'StreamIterator'.
|
||||
static final Selector cancel =
|
||||
new Selector.call(const PublicName('cancel'), CallStructure.NO_ARGS);
|
||||
Selector.call(const PublicName('cancel'), CallStructure.NO_ARGS);
|
||||
|
||||
/// The selector for getting the current element property used in for-each
|
||||
/// loops.
|
||||
static final Selector current = new Selector.getter(Names.current);
|
||||
static final Selector current = Selector.getter(Names.current);
|
||||
|
||||
/// The selector for getting the iterator property used in for-each loops.
|
||||
static final Selector iterator = new Selector.getter(Names.iterator);
|
||||
static final Selector iterator = Selector.getter(Names.iterator);
|
||||
|
||||
/// The selector for calling the move next method used in for-each loops.
|
||||
static final Selector moveNext =
|
||||
new Selector.call(Names.moveNext, CallStructure.NO_ARGS);
|
||||
Selector.call(Names.moveNext, CallStructure.NO_ARGS);
|
||||
|
||||
/// The selector for calling the no such method handler on 'Object'.
|
||||
static final Selector noSuchMethod_ =
|
||||
new Selector.call(Names.noSuchMethod_, CallStructure.ONE_ARG);
|
||||
Selector.call(Names.noSuchMethod_, CallStructure.ONE_ARG);
|
||||
|
||||
/// The selector for tearing off noSuchMethod.
|
||||
static final Selector noSuchMethodGetter =
|
||||
new Selector.getter(Names.noSuchMethod_);
|
||||
Selector.getter(Names.noSuchMethod_);
|
||||
|
||||
/// The selector for calling the to-string method on 'Object'.
|
||||
static final Selector toString_ =
|
||||
new Selector.call(Names.toString_, CallStructure.NO_ARGS);
|
||||
Selector.call(Names.toString_, CallStructure.NO_ARGS);
|
||||
|
||||
/// The selector for tearing off toString.
|
||||
static final Selector toStringGetter = new Selector.getter(Names.toString_);
|
||||
static final Selector toStringGetter = Selector.getter(Names.toString_);
|
||||
|
||||
static final Selector hashCode_ =
|
||||
new Selector.getter(const PublicName('hashCode'));
|
||||
Selector.getter(const PublicName('hashCode'));
|
||||
|
||||
static final Selector compareTo =
|
||||
new Selector.call(const PublicName("compareTo"), CallStructure.ONE_ARG);
|
||||
Selector.call(const PublicName("compareTo"), CallStructure.ONE_ARG);
|
||||
|
||||
static final Selector equals = new Selector.binaryOperator('==');
|
||||
static final Selector equals = Selector.binaryOperator('==');
|
||||
|
||||
static final Selector length = new Selector.getter(Names.length);
|
||||
static final Selector length = Selector.getter(Names.length);
|
||||
|
||||
static final Selector codeUnitAt =
|
||||
new Selector.call(const PublicName('codeUnitAt'), CallStructure.ONE_ARG);
|
||||
Selector.call(const PublicName('codeUnitAt'), CallStructure.ONE_ARG);
|
||||
|
||||
static final Selector index = new Selector.index();
|
||||
static final Selector index = Selector.index();
|
||||
|
||||
static final Selector runtimeType_ = new Selector.getter(Names.runtimeType_);
|
||||
static final Selector runtimeType_ = Selector.getter(Names.runtimeType_);
|
||||
|
||||
/// List of all the selectors held in static fields.
|
||||
///
|
||||
|
@ -179,89 +179,84 @@ class Selectors {
|
|||
/// [Uri]s commonly used.
|
||||
class Uris {
|
||||
/// The URI for 'dart:async'.
|
||||
static final Uri dart_async = new Uri(scheme: 'dart', path: 'async');
|
||||
static final Uri dart_async = Uri(scheme: 'dart', path: 'async');
|
||||
|
||||
/// The URI for 'dart:collection'.
|
||||
static final Uri dart_collection =
|
||||
new Uri(scheme: 'dart', path: 'collection');
|
||||
static final Uri dart_collection = Uri(scheme: 'dart', path: 'collection');
|
||||
|
||||
/// The URI for 'dart:core'.
|
||||
static final Uri dart_core = new Uri(scheme: 'dart', path: 'core');
|
||||
static final Uri dart_core = Uri(scheme: 'dart', path: 'core');
|
||||
|
||||
/// The URI for 'dart:html'.
|
||||
static final Uri dart_html = new Uri(scheme: 'dart', path: 'html');
|
||||
static final Uri dart_html = Uri(scheme: 'dart', path: 'html');
|
||||
|
||||
/// The URI for 'dart:html_common'.
|
||||
static final Uri dart_html_common =
|
||||
new Uri(scheme: 'dart', path: 'html_common');
|
||||
static final Uri dart_html_common = Uri(scheme: 'dart', path: 'html_common');
|
||||
|
||||
/// The URI for 'dart:indexed_db'.
|
||||
static final Uri dart_indexed_db =
|
||||
new Uri(scheme: 'dart', path: 'indexed_db');
|
||||
static final Uri dart_indexed_db = Uri(scheme: 'dart', path: 'indexed_db');
|
||||
|
||||
/// The URI for 'dart:isolate'.
|
||||
static final Uri dart_isolate = new Uri(scheme: 'dart', path: 'isolate');
|
||||
static final Uri dart_isolate = Uri(scheme: 'dart', path: 'isolate');
|
||||
|
||||
/// The URI for 'dart:math'.
|
||||
static final Uri dart_math = new Uri(scheme: 'dart', path: 'math');
|
||||
static final Uri dart_math = Uri(scheme: 'dart', path: 'math');
|
||||
|
||||
/// The URI for 'dart:mirrors'.
|
||||
static final Uri dart_mirrors = new Uri(scheme: 'dart', path: 'mirrors');
|
||||
static final Uri dart_mirrors = Uri(scheme: 'dart', path: 'mirrors');
|
||||
|
||||
/// The URI for 'dart:_internal'.
|
||||
static final Uri dart__internal = new Uri(scheme: 'dart', path: '_internal');
|
||||
static final Uri dart__internal = Uri(scheme: 'dart', path: '_internal');
|
||||
|
||||
/// The URI for 'dart:_native_typed_data'.
|
||||
static final Uri dart__native_typed_data =
|
||||
new Uri(scheme: 'dart', path: '_native_typed_data');
|
||||
Uri(scheme: 'dart', path: '_native_typed_data');
|
||||
|
||||
/// The URI for 'dart:typed_data'.
|
||||
static final Uri dart_typed_data =
|
||||
new Uri(scheme: 'dart', path: 'typed_data');
|
||||
static final Uri dart_typed_data = Uri(scheme: 'dart', path: 'typed_data');
|
||||
|
||||
/// The URI for 'dart:svg'.
|
||||
static final Uri dart_svg = new Uri(scheme: 'dart', path: 'svg');
|
||||
static final Uri dart_svg = Uri(scheme: 'dart', path: 'svg');
|
||||
|
||||
/// The URI for 'dart:web_audio'.
|
||||
static final Uri dart_web_audio = new Uri(scheme: 'dart', path: 'web_audio');
|
||||
static final Uri dart_web_audio = Uri(scheme: 'dart', path: 'web_audio');
|
||||
|
||||
/// The URI for 'dart:web_gl'.
|
||||
static final Uri dart_web_gl = new Uri(scheme: 'dart', path: 'web_gl');
|
||||
static final Uri dart_web_gl = Uri(scheme: 'dart', path: 'web_gl');
|
||||
|
||||
/// The URI for 'dart:web_sql'.
|
||||
static final Uri dart_web_sql = new Uri(scheme: 'dart', path: 'web_sql');
|
||||
static final Uri dart_web_sql = Uri(scheme: 'dart', path: 'web_sql');
|
||||
|
||||
/// The URI for 'dart:_js_helper'.
|
||||
static final Uri dart__js_helper =
|
||||
new Uri(scheme: 'dart', path: '_js_helper');
|
||||
static final Uri dart__js_helper = Uri(scheme: 'dart', path: '_js_helper');
|
||||
|
||||
/// The URI for 'dart:_late_helper'.
|
||||
static final Uri dart__late_helper =
|
||||
Uri(scheme: 'dart', path: '_late_helper');
|
||||
|
||||
/// The URI for 'dart:_rti'.
|
||||
static final Uri dart__rti = new Uri(scheme: 'dart', path: '_rti');
|
||||
static final Uri dart__rti = Uri(scheme: 'dart', path: '_rti');
|
||||
|
||||
/// The URI for 'dart:_interceptors'.
|
||||
static final Uri dart__interceptors =
|
||||
new Uri(scheme: 'dart', path: '_interceptors');
|
||||
Uri(scheme: 'dart', path: '_interceptors');
|
||||
|
||||
/// The URI for 'dart:_foreign_helper'.
|
||||
static final Uri dart__foreign_helper =
|
||||
new Uri(scheme: 'dart', path: '_foreign_helper');
|
||||
Uri(scheme: 'dart', path: '_foreign_helper');
|
||||
|
||||
/// The URI for 'dart:_js_names'.
|
||||
static final Uri dart__js_names = new Uri(scheme: 'dart', path: '_js_names');
|
||||
static final Uri dart__js_names = Uri(scheme: 'dart', path: '_js_names');
|
||||
|
||||
/// The URI for 'dart:_js_embedded_names'.
|
||||
static final Uri dart__js_embedded_names =
|
||||
new Uri(scheme: 'dart', path: '_js_embedded_names');
|
||||
Uri(scheme: 'dart', path: '_js_embedded_names');
|
||||
|
||||
/// The URI for 'dart:js'.
|
||||
static final Uri dart_js = Uri(scheme: 'dart', path: 'js');
|
||||
|
||||
/// The URI for 'package:js'.
|
||||
static final Uri package_js = new Uri(scheme: 'package', path: 'js/js.dart');
|
||||
static final Uri package_js = Uri(scheme: 'package', path: 'js/js.dart');
|
||||
|
||||
/// The URI for 'dart:_js_annotations'.
|
||||
static final Uri dart__js_annotations =
|
||||
|
@ -269,5 +264,5 @@ class Uris {
|
|||
|
||||
/// The URI for 'package:meta/dart2js.dart'.
|
||||
static final Uri package_meta_dart2js =
|
||||
new Uri(scheme: 'package', path: 'meta/dart2js.dart');
|
||||
Uri(scheme: 'package', path: 'meta/dart2js.dart');
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ abstract class CompilerTask {
|
|||
Map _zoneValues;
|
||||
|
||||
CompilerTask(this._measurer)
|
||||
: _watch = _measurer.enableTaskMeasurements ? new Stopwatch() : null;
|
||||
: _watch = _measurer.enableTaskMeasurements ? Stopwatch() : null;
|
||||
|
||||
/// Whether measurement is disabled. The functions [measure] and [measureIo]
|
||||
/// only measure time if measurements are enabled.
|
||||
|
@ -107,7 +107,7 @@ abstract class CompilerTask {
|
|||
|
||||
return runZoned(action,
|
||||
zoneValues: _zoneValues ??= {_measurer: this},
|
||||
zoneSpecification: _zoneSpecification ??= new ZoneSpecification(
|
||||
zoneSpecification: _zoneSpecification ??= ZoneSpecification(
|
||||
run: _run, runUnary: _runUnary, runBinary: _runBinary));
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ abstract class CompilerTask {
|
|||
// Use a nested CompilerTask for the measurement to ensure nested [measure]
|
||||
// calls work correctly. The subtasks will never themselves have nested
|
||||
// subtasks because they are not accessible outside.
|
||||
GenericTask subtask = _subtasks[name] ??= new GenericTask(name, _measurer);
|
||||
GenericTask subtask = _subtasks[name] ??= GenericTask(name, _measurer);
|
||||
return subtask.measure(action);
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ abstract class CompilerTask {
|
|||
// Use a nested CompilerTask for the measurement to ensure nested [measure]
|
||||
// calls work correctly. The subtasks will never themselves have nested
|
||||
// subtasks because they are not accessible outside.
|
||||
GenericTask subtask = _subtasks[name] ??= new GenericTask(name, _measurer);
|
||||
GenericTask subtask = _subtasks[name] ??= GenericTask(name, _measurer);
|
||||
return subtask.measureIo(action);
|
||||
}
|
||||
|
||||
|
@ -225,12 +225,12 @@ class Measurer {
|
|||
///
|
||||
/// Note: MUST be the first field of this class to ensure [wallclock] is
|
||||
/// started before other computations.
|
||||
final Stopwatch _wallClock = new Stopwatch()..start();
|
||||
final Stopwatch _wallClock = Stopwatch()..start();
|
||||
|
||||
Duration get elapsedWallClock => _wallClock.elapsed;
|
||||
|
||||
/// Measures gaps between zoned closures due to asynchronicity.
|
||||
final Stopwatch _asyncWallClock = new Stopwatch();
|
||||
final Stopwatch _asyncWallClock = Stopwatch();
|
||||
|
||||
Duration get elapsedAsyncWallClock => _asyncWallClock.elapsed;
|
||||
|
||||
|
@ -241,7 +241,7 @@ class Measurer {
|
|||
@override
|
||||
final int hashCode = _hashCodeGenerator++;
|
||||
|
||||
Measurer({this.enableTaskMeasurements: false});
|
||||
Measurer({this.enableTaskMeasurements = false});
|
||||
|
||||
/// The currently running task, that is, the task whose [Stopwatch] is
|
||||
/// currently running.
|
||||
|
|
|
@ -14,8 +14,8 @@ import '../serialization/serialization.dart';
|
|||
import '../universe/side_effects.dart' show SideEffects;
|
||||
import 'js.dart';
|
||||
|
||||
typedef dynamic /*DartType|SpecialType*/ TypeLookup(String typeString,
|
||||
{bool required});
|
||||
typedef TypeLookup = dynamic /*DartType|SpecialType*/
|
||||
Function(String typeString, {bool required});
|
||||
|
||||
/// This class is a temporary work-around until we get a more powerful DartType.
|
||||
class SpecialType {
|
||||
|
@ -23,7 +23,7 @@ class SpecialType {
|
|||
const SpecialType._(this.name);
|
||||
|
||||
/// The type Object, but no subtypes:
|
||||
static const JsObject = const SpecialType._('=Object');
|
||||
static const JsObject = SpecialType._('=Object');
|
||||
|
||||
@override
|
||||
int get hashCode => name.hashCode;
|
||||
|
@ -35,7 +35,7 @@ class SpecialType {
|
|||
if (name == '=Object') {
|
||||
return JsObject;
|
||||
} else {
|
||||
throw new UnsupportedError("Unknown SpecialType '$name'.");
|
||||
throw UnsupportedError("Unknown SpecialType '$name'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class NativeBehavior {
|
|||
static NativeBehavior get CHANGES_OTHER => NativeBehavior._makeChangesOther();
|
||||
static NativeBehavior get DEPENDS_OTHER => NativeBehavior._makeDependsOther();
|
||||
|
||||
NativeBehavior() : sideEffects = new SideEffects.empty();
|
||||
NativeBehavior() : sideEffects = SideEffects.empty();
|
||||
|
||||
NativeBehavior.internal(this.sideEffects);
|
||||
|
||||
|
@ -211,13 +211,13 @@ class NativeBehavior {
|
|||
List typesReturned = readTypes();
|
||||
List typesInstantiated = readTypes();
|
||||
String codeTemplateText = source.readStringOrNull();
|
||||
SideEffects sideEffects = new SideEffects.readFromDataSource(source);
|
||||
SideEffects sideEffects = SideEffects.readFromDataSource(source);
|
||||
int throwBehavior = source.readInt();
|
||||
bool isAllocation = source.readBool();
|
||||
bool useGvn = source.readBool();
|
||||
source.end(tag);
|
||||
|
||||
NativeBehavior behavior = new NativeBehavior.internal(sideEffects);
|
||||
NativeBehavior behavior = NativeBehavior.internal(sideEffects);
|
||||
behavior.typesReturned.addAll(typesReturned);
|
||||
behavior.typesInstantiated.addAll(typesInstantiated);
|
||||
if (codeTemplateText != null) {
|
||||
|
@ -274,8 +274,8 @@ class NativeBehavior {
|
|||
')';
|
||||
}
|
||||
|
||||
static NativeBehavior _makePure({bool isAllocation: false}) {
|
||||
NativeBehavior behavior = new NativeBehavior();
|
||||
static NativeBehavior _makePure({bool isAllocation = false}) {
|
||||
NativeBehavior behavior = NativeBehavior();
|
||||
behavior.sideEffects.clearAllDependencies();
|
||||
behavior.sideEffects.clearAllSideEffects();
|
||||
behavior.throwBehavior = NativeThrowBehavior.NEVER;
|
||||
|
@ -384,7 +384,7 @@ class NativeBehavior {
|
|||
spannable, MessageKind.GENERIC, {'text': message});
|
||||
}
|
||||
|
||||
const List<String> knownTags = const [
|
||||
const List<String> knownTags = [
|
||||
'creates',
|
||||
'returns',
|
||||
'depends',
|
||||
|
@ -538,7 +538,7 @@ class NativeBehavior {
|
|||
return null;
|
||||
}
|
||||
|
||||
SideEffects sideEffects = new SideEffects();
|
||||
SideEffects sideEffects = SideEffects();
|
||||
if (effects == "none") {
|
||||
sideEffects.clearAllSideEffects();
|
||||
} else if (effects == "all") {
|
||||
|
@ -609,7 +609,7 @@ class NativeBehavior {
|
|||
// 'Type1|Type2'. A union type.
|
||||
// '=Object'. A JavaScript Object, no subtype.
|
||||
|
||||
NativeBehavior behavior = new NativeBehavior();
|
||||
NativeBehavior behavior = NativeBehavior();
|
||||
|
||||
behavior.codeTemplateText = codeString;
|
||||
behavior.codeTemplate = js.js.parseForeignJS(behavior.codeTemplateText);
|
||||
|
@ -647,12 +647,11 @@ class NativeBehavior {
|
|||
nullType: commonElements.nullType);
|
||||
|
||||
if (!sideEffectsAreEncodedInSpecString) {
|
||||
new SideEffectsVisitor(behavior.sideEffects)
|
||||
.visit(behavior.codeTemplate.ast);
|
||||
SideEffectsVisitor(behavior.sideEffects).visit(behavior.codeTemplate.ast);
|
||||
}
|
||||
if (!throwBehaviorFromSpecString) {
|
||||
behavior.throwBehavior =
|
||||
new ThrowBehaviorVisitor().analyze(behavior.codeTemplate.ast);
|
||||
ThrowBehaviorVisitor().analyze(behavior.codeTemplate.ast);
|
||||
}
|
||||
|
||||
return behavior;
|
||||
|
@ -686,8 +685,8 @@ class NativeBehavior {
|
|||
Spannable spannable,
|
||||
DiagnosticReporter reporter,
|
||||
CommonElements commonElements) {
|
||||
NativeBehavior behavior = new NativeBehavior();
|
||||
behavior.sideEffects.setTo(new SideEffects());
|
||||
NativeBehavior behavior = NativeBehavior();
|
||||
behavior.sideEffects.setTo(SideEffects());
|
||||
_fillNativeBehaviorOfBuiltinOrEmbeddedGlobal(
|
||||
behavior, spannable, specString, lookupType, reporter, commonElements);
|
||||
return behavior;
|
||||
|
@ -699,11 +698,11 @@ class NativeBehavior {
|
|||
Spannable spannable,
|
||||
DiagnosticReporter reporter,
|
||||
CommonElements commonElements) {
|
||||
NativeBehavior behavior = new NativeBehavior();
|
||||
NativeBehavior behavior = NativeBehavior();
|
||||
// TODO(sra): Allow the use site to override these defaults.
|
||||
// Embedded globals are usually pre-computed data structures or JavaScript
|
||||
// functions that never change.
|
||||
behavior.sideEffects.setTo(new SideEffects.empty());
|
||||
behavior.sideEffects.setTo(SideEffects.empty());
|
||||
behavior.throwBehavior = NativeThrowBehavior.NEVER;
|
||||
_fillNativeBehaviorOfBuiltinOrEmbeddedGlobal(
|
||||
behavior, spannable, specString, lookupType, reporter, commonElements,
|
||||
|
@ -857,7 +856,7 @@ abstract class BehaviorBuilder {
|
|||
Iterable<String> returnsAnnotations,
|
||||
TypeLookup lookupType,
|
||||
{bool isJsInterop}) {
|
||||
_behavior = new NativeBehavior();
|
||||
_behavior = NativeBehavior();
|
||||
// TODO(sigmund,sra): consider doing something better for numeric types.
|
||||
_addReturnType(!isJsInterop ? type : commonElements.dynamicType);
|
||||
_capture(type, isJsInterop);
|
||||
|
@ -868,7 +867,7 @@ abstract class BehaviorBuilder {
|
|||
}
|
||||
|
||||
NativeBehavior buildFieldStoreBehavior(DartType type) {
|
||||
_behavior = new NativeBehavior();
|
||||
_behavior = NativeBehavior();
|
||||
_escape(type, false);
|
||||
// We don't override the default behaviour - the annotations apply to
|
||||
// loading the field.
|
||||
|
@ -882,7 +881,7 @@ abstract class BehaviorBuilder {
|
|||
Iterable<String> returnsAnnotations,
|
||||
TypeLookup lookupType,
|
||||
{bool isJsInterop}) {
|
||||
_behavior = new NativeBehavior();
|
||||
_behavior = NativeBehavior();
|
||||
DartType returnType = type.returnType;
|
||||
// Note: For dart:html and other internal libraries we maintain, we can
|
||||
// trust the return type and use it to limit what we enqueue. We have to
|
||||
|
|
|
@ -37,8 +37,8 @@ class NativeEnqueuer {
|
|||
}
|
||||
|
||||
abstract class NativeEnqueuerBase implements NativeEnqueuer {
|
||||
final Set<ClassEntity> _registeredClasses = new Set<ClassEntity>();
|
||||
final Set<ClassEntity> _unusedClasses = new Set<ClassEntity>();
|
||||
final Set<ClassEntity> _registeredClasses = Set<ClassEntity>();
|
||||
final Set<ClassEntity> _unusedClasses = Set<ClassEntity>();
|
||||
|
||||
@override
|
||||
bool get hasInstantiatedNativeClasses => !_registeredClasses.isEmpty;
|
||||
|
@ -75,7 +75,7 @@ abstract class NativeEnqueuerBase implements NativeEnqueuer {
|
|||
continue;
|
||||
}
|
||||
impactBuilder.registerTypeUse(
|
||||
new TypeUse.nativeInstantiation(_elementEnvironment.getRawType(cls)));
|
||||
TypeUse.nativeInstantiation(_elementEnvironment.getRawType(cls)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,11 +88,11 @@ abstract class NativeEnqueuerBase implements NativeEnqueuer {
|
|||
void _processNativeBehavior(
|
||||
WorldImpactBuilder impactBuilder, NativeBehavior behavior, cause) {
|
||||
void registerInstantiation(InterfaceType type) {
|
||||
impactBuilder.registerTypeUse(new TypeUse.nativeInstantiation(type));
|
||||
impactBuilder.registerTypeUse(TypeUse.nativeInstantiation(type));
|
||||
}
|
||||
|
||||
int unusedBefore = _unusedClasses.length;
|
||||
Set<ClassEntity> matchingClasses = new Set<ClassEntity>();
|
||||
Set<ClassEntity> matchingClasses = Set<ClassEntity>();
|
||||
for (var type in behavior.typesInstantiated) {
|
||||
if (type is SpecialType) {
|
||||
if (type == SpecialType.JsObject) {
|
||||
|
@ -182,7 +182,7 @@ class NativeResolutionEnqueuer extends NativeEnqueuerBase {
|
|||
|
||||
/// The set of all native classes. Each native class is in [nativeClasses]
|
||||
/// and exactly one of [unusedClasses] and [registeredClasses].
|
||||
final Set<ClassEntity> _nativeClasses = new Set<ClassEntity>();
|
||||
final Set<ClassEntity> _nativeClasses = Set<ClassEntity>();
|
||||
|
||||
NativeResolutionEnqueuer(
|
||||
CompilerOptions options,
|
||||
|
@ -200,7 +200,7 @@ class NativeResolutionEnqueuer extends NativeEnqueuerBase {
|
|||
|
||||
@override
|
||||
WorldImpact processNativeClasses(Iterable<Uri> libraries) {
|
||||
WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl();
|
||||
WorldImpactBuilderImpl impactBuilder = WorldImpactBuilderImpl();
|
||||
Iterable<ClassEntity> nativeClasses =
|
||||
_nativeClassFinder.computeNativeClasses(libraries);
|
||||
_nativeClasses.addAll(nativeClasses);
|
||||
|
@ -224,7 +224,7 @@ class NativeCodegenEnqueuer extends NativeEnqueuerBase {
|
|||
final Iterable<ClassEntity> _nativeClasses;
|
||||
final NativeData _nativeData;
|
||||
|
||||
final Set<ClassEntity> _doneAddSubtypes = new Set<ClassEntity>();
|
||||
final Set<ClassEntity> _doneAddSubtypes = Set<ClassEntity>();
|
||||
|
||||
NativeCodegenEnqueuer(
|
||||
CompilerOptions options,
|
||||
|
@ -238,7 +238,7 @@ class NativeCodegenEnqueuer extends NativeEnqueuerBase {
|
|||
|
||||
@override
|
||||
WorldImpact processNativeClasses(Iterable<Uri> libraries) {
|
||||
WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl();
|
||||
WorldImpactBuilderImpl impactBuilder = WorldImpactBuilderImpl();
|
||||
_unusedClasses.addAll(_nativeClasses);
|
||||
|
||||
if (!enableLiveTypeAnalysis) {
|
||||
|
@ -246,7 +246,7 @@ class NativeCodegenEnqueuer extends NativeEnqueuerBase {
|
|||
}
|
||||
|
||||
// HACK HACK - add all the resolved classes.
|
||||
Set<ClassEntity> matchingClasses = new Set<ClassEntity>();
|
||||
Set<ClassEntity> matchingClasses = Set<ClassEntity>();
|
||||
for (ClassEntity classElement in _nativeClasses) {
|
||||
if (_unusedClasses.contains(classElement)) {
|
||||
matchingClasses.add(classElement);
|
||||
|
|
|
@ -10,7 +10,7 @@ class HasCapturedPlaceholders extends js.BaseVisitor {
|
|||
HasCapturedPlaceholders._();
|
||||
|
||||
static bool check(js.Node node) {
|
||||
HasCapturedPlaceholders visitor = new HasCapturedPlaceholders._();
|
||||
HasCapturedPlaceholders visitor = HasCapturedPlaceholders._();
|
||||
node.accept(visitor);
|
||||
return visitor.found;
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ class BaseNativeClassFinder implements NativeClassFinder {
|
|||
final KElementEnvironment _elementEnvironment;
|
||||
final NativeBasicData _nativeBasicData;
|
||||
|
||||
Map<String, ClassEntity> _tagOwner = new Map<String, ClassEntity>();
|
||||
Map<String, ClassEntity> _tagOwner = Map<String, ClassEntity>();
|
||||
|
||||
BaseNativeClassFinder(this._elementEnvironment, this._nativeBasicData);
|
||||
|
||||
@override
|
||||
Iterable<ClassEntity> computeNativeClasses(Iterable<Uri> libraries) {
|
||||
Set<ClassEntity> nativeClasses = new Set<ClassEntity>();
|
||||
Set<ClassEntity> nativeClasses = Set<ClassEntity>();
|
||||
libraries.forEach((uri) => _processNativeClassesInLibrary(
|
||||
_elementEnvironment.lookupLibrary(uri), nativeClasses));
|
||||
_processSubclassesOfNativeClasses(libraries, nativeClasses);
|
||||
|
@ -84,7 +84,7 @@ class BaseNativeClassFinder implements NativeClassFinder {
|
|||
/// [nativeClasses].
|
||||
void _processSubclassesOfNativeClasses(
|
||||
Iterable<Uri> libraries, Set<ClassEntity> nativeClasses) {
|
||||
Set<ClassEntity> nativeClassesAndSubclasses = new Set<ClassEntity>();
|
||||
Set<ClassEntity> nativeClassesAndSubclasses = Set<ClassEntity>();
|
||||
// Collect potential subclasses, e.g.
|
||||
//
|
||||
// class B extends foo.A {}
|
||||
|
@ -100,7 +100,7 @@ class BaseNativeClassFinder implements NativeClassFinder {
|
|||
String extendsName = _findExtendsNameOfClass(cls);
|
||||
if (extendsName != null) {
|
||||
Set<ClassEntity> potentialSubclasses = potentialExtends.putIfAbsent(
|
||||
extendsName, () => new Set<ClassEntity>());
|
||||
extendsName, () => Set<ClassEntity>());
|
||||
potentialSubclasses.add(cls);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue