mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:47:36 +00:00
[dart2js] dart format --fix in js_emitter/
Change-Id: Ib4ba65b922ef687adc355c41b3ae23d337659f30 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213863 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
45bfa70348
commit
427af76e0b
|
@ -79,7 +79,7 @@ class ClassStubGenerator {
|
|||
// Two selectors may match but differ only in type. To avoid generating
|
||||
// identical stubs for each we track untyped selectors which already have
|
||||
// stubs.
|
||||
Set<Selector> generatedSelectors = new Set<Selector>();
|
||||
Set<Selector> generatedSelectors = Set<Selector>();
|
||||
for (Selector selector in selectors.keys) {
|
||||
if (generatedSelectors.contains(selector)) continue;
|
||||
if (!selector.appliesUnnamed(member)) continue;
|
||||
|
@ -88,13 +88,13 @@ class ClassStubGenerator {
|
|||
generatedSelectors.add(selector);
|
||||
|
||||
jsAst.Name invocationName = _namer.invocationName(selector);
|
||||
Selector callSelector = new Selector.callClosureFrom(selector);
|
||||
Selector callSelector = Selector.callClosureFrom(selector);
|
||||
jsAst.Name closureCallName = _namer.invocationName(callSelector);
|
||||
|
||||
List<jsAst.Parameter> parameters = <jsAst.Parameter>[];
|
||||
List<jsAst.Expression> arguments = <jsAst.Expression>[];
|
||||
if (isInterceptedMethod) {
|
||||
parameters.add(new jsAst.Parameter(receiverArgumentName));
|
||||
parameters.add(jsAst.Parameter(receiverArgumentName));
|
||||
}
|
||||
|
||||
for (int i = 0; i < selector.argumentCount; i++) {
|
||||
|
@ -158,8 +158,8 @@ class ClassStubGenerator {
|
|||
// Values match JSInvocationMirror in js-helper library.
|
||||
int type = selector.invocationMirrorKind;
|
||||
List<String> parameterNames =
|
||||
new List.generate(selector.argumentCount, (i) => '\$$i') +
|
||||
new List.generate(selector.typeArgumentCount, (i) => '\$T${i + 1}');
|
||||
List.generate(selector.argumentCount, (i) => '\$$i') +
|
||||
List.generate(selector.typeArgumentCount, (i) => '\$T${i + 1}');
|
||||
|
||||
List<jsAst.Expression> argNames = selector.callStructure
|
||||
.getOrderedNamedArguments()
|
||||
|
@ -186,9 +186,9 @@ class ClassStubGenerator {
|
|||
js.quoteName(enableMinification ? internalName : methodName),
|
||||
'internalName': js.quoteName(internalName),
|
||||
'type': js.number(type),
|
||||
'arguments': new jsAst.ArrayInitializer(
|
||||
'arguments': jsAst.ArrayInitializer(
|
||||
parameterNames.map<jsAst.Expression>(js).toList()),
|
||||
'namedArguments': new jsAst.ArrayInitializer(argNames),
|
||||
'namedArguments': jsAst.ArrayInitializer(argNames),
|
||||
'typeArgumentCount': js.number(selector.typeArgumentCount)
|
||||
});
|
||||
|
||||
|
@ -199,7 +199,7 @@ class ClassStubGenerator {
|
|||
} else {
|
||||
function = js(r'function(#) { return # }', [parameterNames, expression]);
|
||||
}
|
||||
return new StubMethod(name, function);
|
||||
return StubMethod(name, function);
|
||||
}
|
||||
|
||||
/// Generates a getter for the given [field].
|
||||
|
|
|
@ -15,8 +15,7 @@ import '../js/js.dart' as jsAst;
|
|||
import '../js_backend/backend.dart' show CodegenInputs;
|
||||
import '../js_backend/inferred_data.dart';
|
||||
import '../js_backend/namer.dart' show Namer;
|
||||
import '../js_backend/runtime_types.dart'
|
||||
show RuntimeTypesChecks;
|
||||
import '../js_backend/runtime_types.dart' show RuntimeTypesChecks;
|
||||
import '../js_model/js_strategy.dart';
|
||||
import '../options.dart';
|
||||
import '../universe/codegen_world_builder.dart';
|
||||
|
@ -78,16 +77,17 @@ class CodeEmitterTask extends CompilerTask {
|
|||
void _finalizeRti(CodegenInputs codegen, CodegenWorld codegenWorld) {
|
||||
// Compute the required type checks to know which classes need a
|
||||
// 'is$' method.
|
||||
_rtiChecks = _backendStrategy.rtiChecksBuilder.computeRequiredChecks(codegenWorld, options);
|
||||
_rtiChecks = _backendStrategy.rtiChecksBuilder
|
||||
.computeRequiredChecks(codegenWorld, options);
|
||||
}
|
||||
|
||||
/// Creates the [Emitter] for this task.
|
||||
void createEmitter(
|
||||
Namer namer, CodegenInputs codegen, JClosedWorld closedWorld) {
|
||||
measure(() {
|
||||
_nativeEmitter = new NativeEmitter(
|
||||
_nativeEmitter = NativeEmitter(
|
||||
this, closedWorld, _backendStrategy.nativeCodegenEnqueuer);
|
||||
_emitter = new startup_js_emitter.EmitterImpl(
|
||||
_emitter = startup_js_emitter.EmitterImpl(
|
||||
_compiler.options,
|
||||
_compiler.reporter,
|
||||
_compiler.outputProvider,
|
||||
|
@ -99,7 +99,7 @@ class CodeEmitterTask extends CompilerTask {
|
|||
_backendStrategy.sourceInformationStrategy,
|
||||
this,
|
||||
_generateSourceMap);
|
||||
metadataCollector = new MetadataCollector(
|
||||
metadataCollector = MetadataCollector(
|
||||
_compiler.reporter, _emitter, codegen.rtiRecipeEncoder);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class _ConstantOrdering
|
|||
final Sorter _sorter;
|
||||
_DartTypeOrdering _dartTypeOrdering;
|
||||
_ConstantOrdering(this._sorter) {
|
||||
_dartTypeOrdering = new _DartTypeOrdering(this);
|
||||
_dartTypeOrdering = _DartTypeOrdering(this);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -269,13 +269,13 @@ class _DartTypeOrdering extends DartTypeVisitor<int, DartType> {
|
|||
|
||||
@override
|
||||
int visitVoidType(covariant VoidType type, covariant VoidType other) {
|
||||
throw new UnsupportedError('Unreachable');
|
||||
throw UnsupportedError('Unreachable');
|
||||
}
|
||||
|
||||
@override
|
||||
int visitTypeVariableType(
|
||||
covariant TypeVariableType type, covariant TypeVariableType other) {
|
||||
throw new UnsupportedError(
|
||||
throw UnsupportedError(
|
||||
"Type variables are not expected in constants: '$type' in '$_root'");
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ class _DartTypeOrdering extends DartTypeVisitor<int, DartType> {
|
|||
@override
|
||||
int visitDynamicType(
|
||||
covariant DynamicType type, covariant DynamicType other) {
|
||||
throw new UnsupportedError('Unreachable');
|
||||
throw UnsupportedError('Unreachable');
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -6,7 +6,7 @@ library dart2js.js_emitter.headers;
|
|||
|
||||
import '../options.dart';
|
||||
|
||||
String generatedBy(CompilerOptions options, {String flavor: ""}) {
|
||||
String generatedBy(CompilerOptions options, {String flavor = ""}) {
|
||||
String suffix = '';
|
||||
if (options.hasBuildId) {
|
||||
suffix = ' version: ${options.buildId}';
|
||||
|
|
|
@ -75,7 +75,7 @@ class InstantiationStubGenerator {
|
|||
for (int i = 0; i < callSelector.argumentCount; i++) {
|
||||
String jsName = 'a$i';
|
||||
arguments.add(js('#', jsName));
|
||||
parameters.add(new jsAst.Parameter(jsName));
|
||||
parameters.add(jsAst.Parameter(jsName));
|
||||
}
|
||||
|
||||
for (int i = 0; i < targetSelector.typeArgumentCount; i++) {
|
||||
|
@ -95,7 +95,7 @@ class InstantiationStubGenerator {
|
|||
// TODO(sra): .withSourceInformation(sourceInformation);
|
||||
|
||||
jsAst.Name name = _namer.invocationName(callSelector);
|
||||
return new ParameterStubMethod(name, null, function);
|
||||
return ParameterStubMethod(name, null, function);
|
||||
}
|
||||
|
||||
/// Generates a stub for a 'signature' selector. The stub calls the underlying
|
||||
|
@ -118,7 +118,7 @@ class InstantiationStubGenerator {
|
|||
// TODO(sra): Generate source information for stub that has no member.
|
||||
// TODO(sra): .withSourceInformation(sourceInformation);
|
||||
|
||||
return new ParameterStubMethod(operatorSignature, null, function);
|
||||
return ParameterStubMethod(operatorSignature, null, function);
|
||||
}
|
||||
|
||||
jsAst.Fun _generateSignatureNewRti(FieldEntity functionField) =>
|
||||
|
@ -156,8 +156,7 @@ class InstantiationStubGenerator {
|
|||
_codegenWorld.invocationsByName(call);
|
||||
|
||||
Set<ParameterStructure> computeLiveParameterStructures() {
|
||||
Set<ParameterStructure> parameterStructures =
|
||||
new Set<ParameterStructure>();
|
||||
Set<ParameterStructure> parameterStructures = Set<ParameterStructure>();
|
||||
|
||||
void process(FunctionEntity function) {
|
||||
if (function.parameterStructure.typeParameters == typeArgumentCount) {
|
||||
|
@ -188,7 +187,7 @@ class InstantiationStubGenerator {
|
|||
for (ParameterStructure parameterStructure in parameterStructures) {
|
||||
if (genericCallStructure.signatureApplies(parameterStructure)) {
|
||||
Selector genericSelector =
|
||||
new Selector.call(selector.memberName, genericCallStructure);
|
||||
Selector.call(selector.memberName, genericCallStructure);
|
||||
stubs.add(_generateStub(
|
||||
instantiationClass, functionField, selector, genericSelector));
|
||||
break;
|
||||
|
|
|
@ -206,7 +206,7 @@ class InterceptorStubGenerator {
|
|||
statements.add(js.statement('return receiver'));
|
||||
}
|
||||
|
||||
return js('''function(receiver) { #; }''', new jsAst.Block(statements));
|
||||
return js('''function(receiver) { #; }''', jsAst.Block(statements));
|
||||
}
|
||||
|
||||
jsAst.Call _generateIsJsIndexableCall(
|
||||
|
@ -218,13 +218,12 @@ class InterceptorStubGenerator {
|
|||
// We pass the dispatch property record to the isJsIndexable
|
||||
// helper rather than reading it inside the helper to increase the
|
||||
// chance of making the dispatch record access monomorphic.
|
||||
jsAst.PropertyAccess record =
|
||||
new jsAst.PropertyAccess(use2, dispatchProperty);
|
||||
jsAst.PropertyAccess record = jsAst.PropertyAccess(use2, dispatchProperty);
|
||||
|
||||
List<jsAst.Expression> arguments = <jsAst.Expression>[use1, record];
|
||||
FunctionEntity helper = _commonElements.isJsIndexable;
|
||||
jsAst.Expression helperExpression = _emitter.staticFunctionAccess(helper);
|
||||
return new jsAst.Call(helperExpression, arguments);
|
||||
return jsAst.Call(helperExpression, arguments);
|
||||
}
|
||||
|
||||
// Returns a statement that takes care of performance critical
|
||||
|
@ -449,15 +448,15 @@ class InterceptorStubGenerator {
|
|||
// We expect most of the time the map will be a singleton.
|
||||
var properties = <jsAst.Property>[];
|
||||
for (ConstructorEntity member in analysis.constructors(classElement)) {
|
||||
properties.add(new jsAst.Property(
|
||||
properties.add(jsAst.Property(
|
||||
js.string(member.name), _emitter.staticFunctionAccess(member)));
|
||||
}
|
||||
|
||||
var map = new jsAst.ObjectInitializer(properties);
|
||||
var map = jsAst.ObjectInitializer(properties);
|
||||
elements.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
return new jsAst.ArrayInitializer(elements);
|
||||
return jsAst.ArrayInitializer(elements);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class MetadataCollector implements jsAst.TokenFinalizer {
|
|||
MetadataCollector(this.reporter, this._emitter, this._rtiRecipeEncoder);
|
||||
|
||||
jsAst.Expression getTypesForOutputUnit(OutputUnit outputUnit) {
|
||||
return _typesTokens.putIfAbsent(outputUnit, () => new _MetadataList());
|
||||
return _typesTokens.putIfAbsent(outputUnit, () => _MetadataList());
|
||||
}
|
||||
|
||||
void mergeOutputUnitMetadata(OutputUnit target, OutputUnit source) {
|
||||
|
@ -170,7 +170,7 @@ class MetadataCollector implements jsAst.TokenFinalizer {
|
|||
@override
|
||||
void finalizeTokens() {
|
||||
void countTokensInTypes(Iterable<BoundMetadataEntry> entries) {
|
||||
jsAst.TokenCounter counter = new jsAst.TokenCounter();
|
||||
jsAst.TokenCounter counter = jsAst.TokenCounter();
|
||||
entries
|
||||
.where((BoundMetadataEntry e) => e._rc > 0)
|
||||
.map((BoundMetadataEntry e) => e.entry)
|
||||
|
@ -196,7 +196,7 @@ class MetadataCollector implements jsAst.TokenFinalizer {
|
|||
List<jsAst.Node> values =
|
||||
entries.map((BoundMetadataEntry e) => e.entry).toList();
|
||||
|
||||
return new jsAst.ArrayInitializer(values);
|
||||
return jsAst.ArrayInitializer(values);
|
||||
}
|
||||
|
||||
_typesTokens.forEach((OutputUnit outputUnit, _MetadataList token) {
|
||||
|
@ -205,7 +205,7 @@ class MetadataCollector implements jsAst.TokenFinalizer {
|
|||
typesMap.values.forEach(countTokensInTypes);
|
||||
token.setExpression(finalizeMap(typesMap));
|
||||
} else {
|
||||
token.setExpression(new jsAst.ArrayInitializer([]));
|
||||
token.setExpression(jsAst.ArrayInitializer([]));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -187,8 +187,8 @@ class StaticField {
|
|||
StaticField(this.element, this.name, this.getterName, this.code,
|
||||
{this.isFinal,
|
||||
this.isLazy,
|
||||
this.isInitializedByConstant: false,
|
||||
this.usesNonNullableInitialization: false});
|
||||
this.isInitializedByConstant = false,
|
||||
this.usesNonNullableInitialization = false});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
|
|
@ -35,7 +35,7 @@ class NativeEmitter {
|
|||
<ClassEntity, List<ClassEntity>>{};
|
||||
|
||||
// Caches the methods that have a native body.
|
||||
Set<FunctionEntity> nativeMethods = new Set<FunctionEntity>();
|
||||
Set<FunctionEntity> nativeMethods = Set<FunctionEntity>();
|
||||
|
||||
// Type metadata redirections, where the key is the class type data being
|
||||
// redirected to and the value is the list of class type data being
|
||||
|
@ -92,7 +92,7 @@ class NativeEmitter {
|
|||
// post-order traversal but it is easier to compute the pre-order and use it
|
||||
// in reverse.
|
||||
List<Class> preOrder = <Class>[];
|
||||
Set<Class> seen = new Set<Class>();
|
||||
Set<Class> seen = Set<Class>();
|
||||
|
||||
Class objectClass = null;
|
||||
Class jsInterceptorClass = null;
|
||||
|
@ -119,8 +119,8 @@ class NativeEmitter {
|
|||
// needed class.
|
||||
// We may still need to include type metadata for some unneeded classes.
|
||||
|
||||
Set<Class> neededClasses = new Set<Class>();
|
||||
Set<Class> nonLeafClasses = new Set<Class>();
|
||||
Set<Class> neededClasses = Set<Class>();
|
||||
Set<Class> nonLeafClasses = Set<Class>();
|
||||
|
||||
Map<Class, List<Class>> extensionPoints = computeExtensionPoints(preOrder);
|
||||
|
||||
|
@ -177,8 +177,8 @@ class NativeEmitter {
|
|||
|
||||
// Collect all the tags that map to each native class.
|
||||
|
||||
Map<Class, Set<String>> leafTags = new Map<Class, Set<String>>();
|
||||
Map<Class, Set<String>> nonleafTags = new Map<Class, Set<String>>();
|
||||
Map<Class, Set<String>> leafTags = Map<Class, Set<String>>();
|
||||
Map<Class, Set<String>> nonleafTags = Map<Class, Set<String>>();
|
||||
|
||||
for (Class cls in classes) {
|
||||
if (!cls.isNative) continue;
|
||||
|
@ -187,9 +187,7 @@ class NativeEmitter {
|
|||
List<String> nativeTags = _nativeData.getNativeTagsOfClass(cls.element);
|
||||
|
||||
if (nonLeafClasses.contains(cls) || extensionPoints.containsKey(cls)) {
|
||||
nonleafTags
|
||||
.putIfAbsent(cls, () => new Set<String>())
|
||||
.addAll(nativeTags);
|
||||
nonleafTags.putIfAbsent(cls, () => Set<String>()).addAll(nativeTags);
|
||||
} else {
|
||||
Class sufficingInterceptor = cls;
|
||||
while (!neededClasses.contains(sufficingInterceptor)) {
|
||||
|
@ -199,7 +197,7 @@ class NativeEmitter {
|
|||
sufficingInterceptor = jsInterceptorClass;
|
||||
}
|
||||
leafTags
|
||||
.putIfAbsent(sufficingInterceptor, () => new Set<String>())
|
||||
.putIfAbsent(sufficingInterceptor, () => Set<String>())
|
||||
.addAll(nativeTags);
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +250,7 @@ class NativeEmitter {
|
|||
return nativeSuperclassOf(cls.superclass);
|
||||
}
|
||||
|
||||
Map<Class, List<Class>> map = new Map<Class, List<Class>>();
|
||||
Map<Class, List<Class>> map = Map<Class, List<Class>>();
|
||||
|
||||
for (Class cls in classes) {
|
||||
if (cls.isNative) continue;
|
||||
|
|
|
@ -28,7 +28,7 @@ import 'code_emitter_task.dart' show Emitter;
|
|||
import 'native_emitter.dart';
|
||||
|
||||
class ParameterStubGenerator {
|
||||
static final Set<Selector> emptySelectorSet = new Set<Selector>();
|
||||
static final Set<Selector> emptySelectorSet = Set<Selector>();
|
||||
|
||||
final Emitter _emitter;
|
||||
final NativeEmitter _nativeEmitter;
|
||||
|
@ -112,13 +112,13 @@ class ParameterStubGenerator {
|
|||
String receiverArgumentName = r'$receiver';
|
||||
|
||||
// The parameters that this stub takes.
|
||||
List<jsAst.Parameter> stubParameters = new List<jsAst.Parameter>.filled(
|
||||
List<jsAst.Parameter> stubParameters = List<jsAst.Parameter>.filled(
|
||||
extraArgumentCount +
|
||||
selector.argumentCount +
|
||||
selector.typeArgumentCount,
|
||||
null);
|
||||
// The arguments that will be passed to the real method.
|
||||
List<jsAst.Expression> targetArguments = new List<jsAst.Expression>.filled(
|
||||
List<jsAst.Expression> targetArguments = List<jsAst.Expression>.filled(
|
||||
extraArgumentCount +
|
||||
parameterStructure.totalParameters +
|
||||
parameterStructure.typeParameters,
|
||||
|
@ -127,7 +127,7 @@ class ParameterStubGenerator {
|
|||
int count = 0;
|
||||
if (isInterceptedMethod) {
|
||||
count++;
|
||||
stubParameters[0] = new jsAst.Parameter(receiverArgumentName);
|
||||
stubParameters[0] = jsAst.Parameter(receiverArgumentName);
|
||||
targetArguments[0] = js('#', receiverArgumentName);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class ParameterStubGenerator {
|
|||
String jsName = _namer.safeVariableName(name);
|
||||
assert(jsName != receiverArgumentName);
|
||||
if (count < optionalParameterStart) {
|
||||
stubParameters[count] = new jsAst.Parameter(jsName);
|
||||
stubParameters[count] = jsAst.Parameter(jsName);
|
||||
targetArguments[count] = js('#', jsName);
|
||||
} else {
|
||||
int index = names.indexOf(name);
|
||||
|
@ -150,11 +150,11 @@ class ParameterStubGenerator {
|
|||
// one in the real method (which is in Dart source order).
|
||||
targetArguments[count] = js('#', jsName);
|
||||
stubParameters[optionalParameterStart + index] =
|
||||
new jsAst.Parameter(jsName);
|
||||
jsAst.Parameter(jsName);
|
||||
} else {
|
||||
if (value == null) {
|
||||
targetArguments[count] =
|
||||
_emitter.constantReference(new NullConstantValue());
|
||||
_emitter.constantReference(NullConstantValue());
|
||||
} else {
|
||||
if (!value.isNull) {
|
||||
// If the value is the null constant, we should not pass it
|
||||
|
@ -181,7 +181,7 @@ class ParameterStubGenerator {
|
|||
TypeReference(TypeExpressionRecipe(defaultType));
|
||||
} else {
|
||||
String jsName = '\$${typeVariable.element.name}';
|
||||
stubParameters[parameterIndex++] = new jsAst.Parameter(jsName);
|
||||
stubParameters[parameterIndex++] = jsAst.Parameter(jsName);
|
||||
targetArguments[count++] = js('#', jsName);
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class ParameterStubGenerator {
|
|||
jsAst.Name name = member.isStatic ? null : _namer.invocationName(selector);
|
||||
jsAst.Name callName =
|
||||
(callSelector != null) ? _namer.invocationName(callSelector) : null;
|
||||
return new ParameterStubMethod(name, callName, function, element: member);
|
||||
return ParameterStubMethod(name, callName, function, element: member);
|
||||
}
|
||||
|
||||
DartType _eraseTypeVariablesToAny(DartType type) {
|
||||
|
@ -318,9 +318,9 @@ class ParameterStubGenerator {
|
|||
//
|
||||
// For example, for the call-selector `call(x, y)` the renamed selector
|
||||
// for member `foo` would be `foo(x, y)`.
|
||||
Set<Selector> renamedCallSelectors = new Set<Selector>();
|
||||
Set<Selector> renamedCallSelectors = Set<Selector>();
|
||||
|
||||
Set<Selector> stubSelectors = new Set<Selector>();
|
||||
Set<Selector> stubSelectors = Set<Selector>();
|
||||
|
||||
// Start with closure-call selectors, since since they imply the generation
|
||||
// of the non-call version.
|
||||
|
@ -341,7 +341,7 @@ class ParameterStubGenerator {
|
|||
|
||||
for (Selector selector in callSelectors.keys) {
|
||||
Selector renamedSelector =
|
||||
new Selector.call(member.memberName, selector.callStructure);
|
||||
Selector.call(member.memberName, selector.callStructure);
|
||||
renamedCallSelectors.add(renamedSelector);
|
||||
|
||||
if (!renamedSelector.appliesUnnamed(member)) {
|
||||
|
@ -364,7 +364,7 @@ class ParameterStubGenerator {
|
|||
// This is basically the same logic as above, but with type arguments.
|
||||
if (selector.callStructure.typeArgumentCount == 0) {
|
||||
if (memberTypeParameters > 0) {
|
||||
Selector renamedSelectorWithTypeArguments = new Selector.call(
|
||||
Selector renamedSelectorWithTypeArguments = Selector.call(
|
||||
member.memberName,
|
||||
selector.callStructure
|
||||
.withTypeArgumentCount(memberTypeParameters));
|
||||
|
@ -372,7 +372,7 @@ class ParameterStubGenerator {
|
|||
|
||||
if (stubSelectors.add(renamedSelectorWithTypeArguments)) {
|
||||
Selector closureSelector =
|
||||
new Selector.callClosureFrom(renamedSelectorWithTypeArguments);
|
||||
Selector.callClosureFrom(renamedSelectorWithTypeArguments);
|
||||
ParameterStubMethod stub = generateParameterStub(
|
||||
member, renamedSelectorWithTypeArguments, closureSelector);
|
||||
if (stub != null) {
|
||||
|
|
|
@ -16,8 +16,8 @@ part of dart2js.js_emitter.program_builder;
|
|||
/// [needsCheckedSetter] indicates that a checked getter is needed, and in this
|
||||
/// case, [needsSetter] is always false. [needsCheckedSetter] is only true when
|
||||
/// type assertions are enabled (checked mode).
|
||||
typedef void AcceptField(FieldEntity member, js.Name name, bool needsGetter,
|
||||
bool needsSetter, bool needsCheckedSetter);
|
||||
typedef AcceptField = void Function(FieldEntity member, js.Name name,
|
||||
bool needsGetter, bool needsSetter, bool needsCheckedSetter);
|
||||
|
||||
class FieldVisitor {
|
||||
final JElementEnvironment _elementEnvironment;
|
||||
|
|
|
@ -130,7 +130,7 @@ class ProgramBuilder {
|
|||
this._sorter,
|
||||
this._rtiNeededClasses,
|
||||
this._mainFunction)
|
||||
: this.collector = new Collector(
|
||||
: this.collector = Collector(
|
||||
_commonElements,
|
||||
_elementEnvironment,
|
||||
_outputUnitData,
|
||||
|
@ -143,7 +143,7 @@ class ProgramBuilder {
|
|||
_rtiNeededClasses,
|
||||
_generatedCode,
|
||||
_sorter),
|
||||
this._registry = new Registry(_outputUnitData.mainOutputUnit, _sorter);
|
||||
this._registry = Registry(_outputUnitData.mainOutputUnit, _sorter);
|
||||
|
||||
/// Mapping from [ClassEntity] to constructed [Class]. We need this to
|
||||
/// update the superclass in the [Class].
|
||||
|
@ -168,7 +168,7 @@ class ProgramBuilder {
|
|||
List<StubMethod> _jsInteropIsChecks = [];
|
||||
final Set<TypeCheck> _jsInteropTypeChecks = {};
|
||||
|
||||
Program buildProgram({bool storeFunctionTypesInMetadata: false}) {
|
||||
Program buildProgram({bool storeFunctionTypesInMetadata = false}) {
|
||||
collector.collect();
|
||||
|
||||
this._storeFunctionTypesInMetadata = storeFunctionTypesInMetadata;
|
||||
|
@ -237,7 +237,7 @@ class ProgramBuilder {
|
|||
_registry.deferredLibrariesMap.map(_buildDeferredFragment);
|
||||
|
||||
List<Fragment> fragments =
|
||||
new List<Fragment>.filled(_registry.librariesMapCount, null);
|
||||
List<Fragment>.filled(_registry.librariesMapCount, null);
|
||||
fragments[0] = mainFragment;
|
||||
fragments.setAll(1, deferredFragments);
|
||||
|
||||
|
@ -257,7 +257,7 @@ class ProgramBuilder {
|
|||
finalizers.add(namingFinalizer as js.TokenFinalizer);
|
||||
}
|
||||
|
||||
return new Program(fragments, _buildTypeToInterceptorMap(),
|
||||
return Program(fragments, _buildTypeToInterceptorMap(),
|
||||
_task.metadataCollector, finalizers,
|
||||
needsNativeSupport: needsNativeSupport,
|
||||
outputContainsConstantList: collector.outputContainsConstantList);
|
||||
|
@ -268,7 +268,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
js.Expression _buildTypeToInterceptorMap() {
|
||||
InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator(
|
||||
InterceptorStubGenerator stubGenerator = InterceptorStubGenerator(
|
||||
_commonElements,
|
||||
_task.emitter,
|
||||
_nativeCodegenEnqueuer,
|
||||
|
@ -281,7 +281,7 @@ class ProgramBuilder {
|
|||
|
||||
MainFragment _buildMainFragment(LibrariesMap librariesMap) {
|
||||
// Construct the main output from the libraries and the registered holders.
|
||||
MainFragment result = new MainFragment(
|
||||
MainFragment result = MainFragment(
|
||||
librariesMap.outputUnit,
|
||||
"", // The empty string is the name for the main output file.
|
||||
_buildInvokeMain(),
|
||||
|
@ -299,7 +299,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
DeferredFragment _buildDeferredFragment(LibrariesMap librariesMap) {
|
||||
DeferredFragment result = new DeferredFragment(
|
||||
DeferredFragment result = DeferredFragment(
|
||||
librariesMap.outputUnit,
|
||||
deferredPartFileName(_options, librariesMap.name, addExtension: false),
|
||||
librariesMap.name,
|
||||
|
@ -344,7 +344,7 @@ class ProgramBuilder {
|
|||
// building a static field. (Note that the static-state holder was
|
||||
// already registered earlier, and that we just call the register to get
|
||||
// the holder-instance.
|
||||
return new StaticField(element, name, null, code,
|
||||
return StaticField(element, name, null, code,
|
||||
isFinal: false,
|
||||
isLazy: false,
|
||||
isInitializedByConstant: initialValue != null,
|
||||
|
@ -375,15 +375,14 @@ class ProgramBuilder {
|
|||
// building a static field. (Note that the static-state holder was
|
||||
// already registered earlier, and that we just call the register to get
|
||||
// the holder-instance.
|
||||
return new StaticField(element, name, getterName, code,
|
||||
return StaticField(element, name, getterName, code,
|
||||
isFinal: !element.isAssignable,
|
||||
isLazy: true,
|
||||
usesNonNullableInitialization: element.library.isNonNullableByDefault);
|
||||
}
|
||||
|
||||
List<Library> _buildLibraries(LibrariesMap librariesMap) {
|
||||
List<Library> libraries =
|
||||
new List<Library>.filled(librariesMap.length, null);
|
||||
List<Library> libraries = List<Library>.filled(librariesMap.length, null);
|
||||
int count = 0;
|
||||
librariesMap.forEach((LibraryEntity library, List<ClassEntity> classes,
|
||||
List<MemberEntity> members, List<ClassEntity> classTypeElements) {
|
||||
|
@ -399,7 +398,7 @@ class ProgramBuilder {
|
|||
// TODO(jacobr): register toString as used so that it is always accessible
|
||||
// from JavaScript.
|
||||
_classes[_commonElements.objectClass].callStubs.add(_buildStubMethod(
|
||||
new StringBackedName("toString"),
|
||||
StringBackedName("toString"),
|
||||
js.js('function() { return this.#(this) }', toStringInvocation)));
|
||||
}
|
||||
|
||||
|
@ -491,7 +490,7 @@ class ProgramBuilder {
|
|||
var stubName = _namer.invocationName(selector);
|
||||
if (!stubNames.add(stubName.key)) continue;
|
||||
var parameters =
|
||||
new List<String>.generate(argumentCount, (i) => 'p$i');
|
||||
List<String>.generate(argumentCount, (i) => 'p$i');
|
||||
|
||||
// We intentionally generate the same stub method for direct
|
||||
// calls and call-throughs of getters so that calling a
|
||||
|
@ -573,10 +572,10 @@ class ProgramBuilder {
|
|||
List<Method> methods = [];
|
||||
List<StubMethod> callStubs = [];
|
||||
|
||||
ClassStubGenerator classStubGenerator = new ClassStubGenerator(
|
||||
ClassStubGenerator classStubGenerator = ClassStubGenerator(
|
||||
_task.emitter, _commonElements, _namer, _codegenWorld, _closedWorld,
|
||||
enableMinification: _options.enableMinification);
|
||||
RuntimeTypeGenerator runtimeTypeGenerator = new RuntimeTypeGenerator(
|
||||
RuntimeTypeGenerator runtimeTypeGenerator = RuntimeTypeGenerator(
|
||||
_commonElements, _outputUnitData, _task, _namer, _rtiChecks);
|
||||
|
||||
void visitInstanceMember(MemberEntity member) {
|
||||
|
@ -794,7 +793,7 @@ class ProgramBuilder {
|
|||
var /* Map | List */ optionalParameterDefaultValues;
|
||||
ParameterStructure parameterStructure = method.parameterStructure;
|
||||
if (parameterStructure.namedParameters.isNotEmpty) {
|
||||
optionalParameterDefaultValues = new Map<String, ConstantValue>();
|
||||
optionalParameterDefaultValues = Map<String, ConstantValue>();
|
||||
_elementEnvironment.forEachParameter(method,
|
||||
(DartType type, String name, ConstantValue defaultValue) {
|
||||
if (parameterStructure.namedParameters.contains(name)) {
|
||||
|
@ -874,8 +873,7 @@ class ProgramBuilder {
|
|||
|
||||
js.Name callName = null;
|
||||
if (canTearOff) {
|
||||
Selector callSelector =
|
||||
new Selector.fromElement(element).toCallSelector();
|
||||
Selector callSelector = Selector.fromElement(element).toCallSelector();
|
||||
callName = _namer.invocationName(callSelector);
|
||||
}
|
||||
|
||||
|
@ -900,7 +898,7 @@ class ProgramBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
return new InstanceMethod(element, name, code,
|
||||
return InstanceMethod(element, name, code,
|
||||
_generateParameterStubs(element, canTearOff, canBeApplied), callName,
|
||||
needsTearOff: canTearOff,
|
||||
tearOffName: tearOffName,
|
||||
|
@ -966,7 +964,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
List<StubMethod> _generateInstantiationStubs(ClassEntity instantiationClass) {
|
||||
InstantiationStubGenerator generator = new InstantiationStubGenerator(
|
||||
InstantiationStubGenerator generator = InstantiationStubGenerator(
|
||||
_task, _namer, _closedWorld, _codegenWorld, _sourceInformationStrategy);
|
||||
return generator.generateStubs(instantiationClass, null);
|
||||
}
|
||||
|
@ -977,7 +975,7 @@ class ProgramBuilder {
|
|||
/// attribution.
|
||||
Method _buildStubMethod(js.Name name, js.Expression code,
|
||||
{MemberEntity element}) {
|
||||
return new StubMethod(name, code, element: element);
|
||||
return StubMethod(name, code, element: element);
|
||||
}
|
||||
|
||||
// The getInterceptor methods directly access the prototype of classes.
|
||||
|
@ -995,7 +993,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
Iterable<StaticStubMethod> _generateGetInterceptorMethods() {
|
||||
InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator(
|
||||
InterceptorStubGenerator stubGenerator = InterceptorStubGenerator(
|
||||
_commonElements,
|
||||
_task.emitter,
|
||||
_nativeCodegenEnqueuer,
|
||||
|
@ -1021,13 +1019,12 @@ class ProgramBuilder {
|
|||
SpecializedGetInterceptor interceptor = interceptorMap[name];
|
||||
js.Expression code =
|
||||
stubGenerator.generateGetInterceptorMethod(interceptor);
|
||||
return new StaticStubMethod(
|
||||
_commonElements.interceptorsLibrary, name, code);
|
||||
return StaticStubMethod(_commonElements.interceptorsLibrary, name, code);
|
||||
});
|
||||
}
|
||||
|
||||
List<Field> _buildFields(
|
||||
{bool isHolderInterceptedClass: false, ClassEntity cls}) {
|
||||
{bool isHolderInterceptedClass = false, ClassEntity cls}) {
|
||||
List<Field> fields = <Field>[];
|
||||
|
||||
void visitField(FieldEntity field, js.Name name, bool needsGetter,
|
||||
|
@ -1091,7 +1088,7 @@ class ProgramBuilder {
|
|||
}
|
||||
|
||||
Iterable<StaticStubMethod> _generateOneShotInterceptors() {
|
||||
InterceptorStubGenerator stubGenerator = new InterceptorStubGenerator(
|
||||
InterceptorStubGenerator stubGenerator = InterceptorStubGenerator(
|
||||
_commonElements,
|
||||
_task.emitter,
|
||||
_nativeCodegenEnqueuer,
|
||||
|
@ -1118,8 +1115,7 @@ class ProgramBuilder {
|
|||
OneShotInterceptor interceptor = interceptorMap[name];
|
||||
js.Expression code =
|
||||
stubGenerator.generateOneShotInterceptor(interceptor);
|
||||
return new StaticStubMethod(
|
||||
_commonElements.interceptorsLibrary, name, code);
|
||||
return StaticStubMethod(_commonElements.interceptorsLibrary, name, code);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1139,8 +1135,7 @@ class ProgramBuilder {
|
|||
|
||||
js.Name callName = null;
|
||||
if (needsTearOff) {
|
||||
Selector callSelector =
|
||||
new Selector.fromElement(element).toCallSelector();
|
||||
Selector callSelector = Selector.fromElement(element).toCallSelector();
|
||||
callName = _namer.invocationName(callSelector);
|
||||
}
|
||||
js.Expression functionType;
|
||||
|
@ -1163,7 +1158,7 @@ class ProgramBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
return new StaticDartMethod(element, name, code,
|
||||
return StaticDartMethod(element, name, code,
|
||||
_generateParameterStubs(element, needsTearOff, canBeApplied), callName,
|
||||
needsTearOff: needsTearOff,
|
||||
tearOffName: tearOffName,
|
||||
|
@ -1182,7 +1177,7 @@ class ProgramBuilder {
|
|||
_registry.registerConstant(outputUnit, constantValue);
|
||||
assert(!_constants.containsKey(constantValue));
|
||||
js.Name name = _namer.constantName(constantValue);
|
||||
Constant constant = new Constant(name, constantValue);
|
||||
Constant constant = Constant(name, constantValue);
|
||||
_constants[constantValue] = constant;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class LibrariesMap {
|
|||
LibraryContents _getMapping(LibraryEntity library) {
|
||||
if (_lastLibrary != library) {
|
||||
_lastLibrary = library;
|
||||
_lastMapping = _mapping.putIfAbsent(library, () => new LibraryContents());
|
||||
_lastMapping = _mapping.putIfAbsent(library, () => LibraryContents());
|
||||
}
|
||||
return _lastMapping;
|
||||
}
|
||||
|
@ -111,12 +111,12 @@ class Registry {
|
|||
void registerOutputUnit(OutputUnit outputUnit) {
|
||||
if (outputUnit == _mainOutputUnit) {
|
||||
assert(mainLibrariesMap == null);
|
||||
mainLibrariesMap = new LibrariesMap.main(_mainOutputUnit);
|
||||
mainLibrariesMap = LibrariesMap.main(_mainOutputUnit);
|
||||
} else {
|
||||
assert(!_deferredLibrariesMap.containsKey(outputUnit));
|
||||
String name = outputUnit.name;
|
||||
_deferredLibrariesMap[outputUnit] =
|
||||
new LibrariesMap.deferred(outputUnit, name);
|
||||
LibrariesMap.deferred(outputUnit, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ import '../util/util.dart' show Setlet;
|
|||
import 'code_emitter_task.dart' show CodeEmitterTask;
|
||||
|
||||
// Function signatures used in the generation of runtime type information.
|
||||
typedef void FunctionTypeSignatureEmitter(ClassFunctionType classFunctionType);
|
||||
typedef FunctionTypeSignatureEmitter = void Function(
|
||||
ClassFunctionType classFunctionType);
|
||||
|
||||
class TypeTest {
|
||||
final jsAst.Name name;
|
||||
|
@ -51,19 +52,19 @@ class TypeTestProperties {
|
|||
final Map<ClassEntity, TypeTests> _properties = <ClassEntity, TypeTests>{};
|
||||
|
||||
void addIsTest(ClassEntity cls, jsAst.Name name, jsAst.Node expression) {
|
||||
TypeTests typeTests = _properties.putIfAbsent(cls, () => new TypeTests());
|
||||
typeTests.isTest = new TypeTest(name, expression);
|
||||
TypeTests typeTests = _properties.putIfAbsent(cls, () => TypeTests());
|
||||
typeTests.isTest = TypeTest(name, expression);
|
||||
}
|
||||
|
||||
void addSubstitution(
|
||||
ClassEntity cls, jsAst.Name name, jsAst.Node expression) {
|
||||
TypeTests typeTests = _properties.putIfAbsent(cls, () => new TypeTests());
|
||||
typeTests.substitution = new TypeTest(name, expression);
|
||||
TypeTests typeTests = _properties.putIfAbsent(cls, () => TypeTests());
|
||||
typeTests.substitution = TypeTest(name, expression);
|
||||
}
|
||||
|
||||
void addSignature(ClassEntity cls, jsAst.Name name, jsAst.Node expression) {
|
||||
TypeTests typeTests = _properties.putIfAbsent(cls, () => new TypeTests());
|
||||
typeTests.signature = new TypeTest(name, expression);
|
||||
TypeTests typeTests = _properties.putIfAbsent(cls, () => TypeTests());
|
||||
typeTests.signature = TypeTest(name, expression);
|
||||
}
|
||||
|
||||
void forEachProperty(
|
||||
|
@ -91,8 +92,8 @@ class RuntimeTypeGenerator {
|
|||
|
||||
RuntimeTypeGenerator(CommonElements _commonElements, this._outputUnitData,
|
||||
this.emitterTask, this._namer, this._rtiChecks)
|
||||
: _outputUnitVisitor = new _TypeContainedInOutputUnitVisitor(
|
||||
_commonElements, _outputUnitData);
|
||||
: _outputUnitVisitor =
|
||||
_TypeContainedInOutputUnitVisitor(_commonElements, _outputUnitData);
|
||||
|
||||
/// Generate "is tests" for [cls] itself, and the "is tests" for the
|
||||
/// classes it implements and type argument substitution functions for these
|
||||
|
@ -112,8 +113,8 @@ class RuntimeTypeGenerator {
|
|||
/// type variables.
|
||||
TypeTestProperties generateIsTests(ClassEntity classElement,
|
||||
Map<MemberEntity, jsAst.Expression> generatedCode,
|
||||
{bool storeFunctionTypeInMetadata: true}) {
|
||||
TypeTestProperties result = new TypeTestProperties();
|
||||
{bool storeFunctionTypeInMetadata = true}) {
|
||||
TypeTestProperties result = TypeTestProperties();
|
||||
|
||||
// TODO(johnniwinther): Include function signatures in [ClassChecks].
|
||||
void generateFunctionTypeSignature(ClassFunctionType classFunctionType) {
|
||||
|
@ -154,10 +155,8 @@ class RuntimeTypeGenerator {
|
|||
if (isDeferred) {
|
||||
// The function type index must be offset by the number of types
|
||||
// already loaded.
|
||||
encoding = new jsAst.Binary(
|
||||
'+',
|
||||
new jsAst.VariableUse(_namer.typesOffsetName),
|
||||
functionTypeIndex);
|
||||
encoding = jsAst.Binary('+',
|
||||
jsAst.VariableUse(_namer.typesOffsetName), functionTypeIndex);
|
||||
} else {
|
||||
encoding = functionTypeIndex;
|
||||
}
|
||||
|
@ -188,7 +187,7 @@ class RuntimeTypeGenerator {
|
|||
ClassEntity cls,
|
||||
FunctionTypeSignatureEmitter generateFunctionTypeSignature,
|
||||
void emitTypeCheck(TypeCheck check)) {
|
||||
Setlet<ClassEntity> generated = new Setlet<ClassEntity>();
|
||||
Setlet<ClassEntity> generated = Setlet<ClassEntity>();
|
||||
|
||||
// Precomputed is checks.
|
||||
ClassChecks classChecks = _rtiChecks.requiredChecks[cls];
|
||||
|
|
|
@ -34,14 +34,14 @@ abstract class ModularEmitterBase implements ModularEmitter {
|
|||
js.PropertyAccess globalPropertyAccessForClass(ClassEntity element) {
|
||||
js.Name name = _namer.globalPropertyNameForClass(element);
|
||||
js.PropertyAccess pa =
|
||||
new js.PropertyAccess(_namer.readGlobalObjectForClass(element), name);
|
||||
js.PropertyAccess(_namer.readGlobalObjectForClass(element), name);
|
||||
return pa;
|
||||
}
|
||||
|
||||
js.PropertyAccess globalPropertyAccessForMember(MemberEntity element) {
|
||||
js.Name name = _namer.globalPropertyNameForMember(element);
|
||||
js.PropertyAccess pa =
|
||||
new js.PropertyAccess(_namer.readGlobalObjectForMember(element), name);
|
||||
js.PropertyAccess(_namer.readGlobalObjectForMember(element), name);
|
||||
return pa;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ abstract class ModularEmitterBase implements ModularEmitter {
|
|||
|
||||
@override
|
||||
js.Expression isolateLazyInitializerAccess(FieldEntity element) {
|
||||
return new js.PropertyAccess(_namer.readGlobalObjectForMember(element),
|
||||
return js.PropertyAccess(_namer.readGlobalObjectForMember(element),
|
||||
_namer.lazyInitializerName(element));
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,8 @@ abstract class ModularEmitterBase implements ModularEmitter {
|
|||
|
||||
@override
|
||||
js.Expression staticClosureAccess(FunctionEntity element) {
|
||||
return new js.Call(
|
||||
new js.PropertyAccess(_namer.readGlobalObjectForMember(element),
|
||||
return js.Call(
|
||||
js.PropertyAccess(_namer.readGlobalObjectForMember(element),
|
||||
_namer.staticClosureName(element)),
|
||||
const []);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class ModularEmitterImpl extends ModularEmitterBase {
|
|||
|
||||
ModularEmitterImpl(
|
||||
ModularNamer namer, this._registry, CompilerOptions options)
|
||||
: _constantEmitter = new ModularConstantEmitter(options, namer),
|
||||
: _constantEmitter = ModularConstantEmitter(options, namer),
|
||||
super(namer);
|
||||
|
||||
@override
|
||||
|
@ -116,16 +116,15 @@ class ModularEmitterImpl extends ModularEmitterBase {
|
|||
if (expression != null) {
|
||||
return expression;
|
||||
}
|
||||
expression =
|
||||
new ModularExpression(ModularExpressionKind.constant, constant);
|
||||
expression = ModularExpression(ModularExpressionKind.constant, constant);
|
||||
_registry.registerModularExpression(expression);
|
||||
return expression;
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression generateEmbeddedGlobalAccess(String global) {
|
||||
js.Expression expression = new ModularExpression(
|
||||
ModularExpressionKind.embeddedGlobalAccess, global);
|
||||
js.Expression expression =
|
||||
ModularExpression(ModularExpressionKind.embeddedGlobalAccess, global);
|
||||
_registry.registerModularExpression(expression);
|
||||
return expression;
|
||||
}
|
||||
|
@ -167,7 +166,7 @@ class EmitterImpl extends ModularEmitterBase implements Emitter {
|
|||
this._task,
|
||||
bool shouldGenerateSourceMap)
|
||||
: super(namer) {
|
||||
_emitter = new ModelEmitter(
|
||||
_emitter = ModelEmitter(
|
||||
options,
|
||||
_reporter,
|
||||
outputProvider,
|
||||
|
|
|
@ -719,7 +719,7 @@ class FragmentEmitter {
|
|||
'throwLateFieldADI': _emitter
|
||||
.staticFunctionAccess(_closedWorld.commonElements.throwLateFieldADI),
|
||||
'operatorIsPrefix': js.string(_namer.fixedNames.operatorIsPrefix),
|
||||
'tearOffCode': new js.Block(
|
||||
'tearOffCode': js.Block(
|
||||
buildTearOffCode(_options, _emitter, _closedWorld.commonElements)),
|
||||
'embeddedTypes': generateEmbeddedGlobalAccess(TYPES),
|
||||
'embeddedInterceptorTags':
|
||||
|
@ -772,7 +772,7 @@ class FragmentEmitter {
|
|||
'nativeSupport': emitNativeSupport(fragment),
|
||||
'jsInteropSupport': jsInteropAnalysis.buildJsInteropBootstrap(
|
||||
_codegenWorld, _closedWorld.nativeData, _namer) ??
|
||||
new js.EmptyStatement(),
|
||||
js.EmptyStatement(),
|
||||
'invokeMain': fragment.invokeMain,
|
||||
|
||||
'call0selector': js.quoteName(call0Name),
|
||||
|
@ -808,7 +808,7 @@ class FragmentEmitter {
|
|||
holderCode);
|
||||
js.Expression code = js.js(_deferredBoilerplate, {
|
||||
// TODO(floitsch): don't just reference 'init'.
|
||||
'embeddedGlobalsObject': new js.Parameter('init'),
|
||||
'embeddedGlobalsObject': js.Parameter('init'),
|
||||
'staticState': DeferredHolderParameter(),
|
||||
'updateHolders': updateHolders,
|
||||
'prototypes': fragment.classPrototypes,
|
||||
|
@ -850,7 +850,7 @@ class FragmentEmitter {
|
|||
/// Finalizing holders must be the last step of the emitter.
|
||||
void finalizeCode(String resourceName, js.Node code,
|
||||
Map<Entity, List<js.Property>> holderCode,
|
||||
{bool finalizeHolders: false}) {
|
||||
{bool finalizeHolders = false}) {
|
||||
StringReferenceFinalizer stringFinalizer =
|
||||
StringReferenceFinalizerImpl(_options.enableMinification);
|
||||
addCodeToFinalizer(stringFinalizer.addCode, code, holderCode);
|
||||
|
@ -904,7 +904,7 @@ class FragmentEmitter {
|
|||
}
|
||||
for (Class cls in library.classes) {
|
||||
js.Expression constructor = emitConstructor(cls);
|
||||
var property = new js.Property(js.quoteName(cls.name), constructor);
|
||||
var property = js.Property(js.quoteName(cls.name), constructor);
|
||||
(holderCode[cls.element] ??= []).add(property);
|
||||
registerEntityAst(cls.element, property, library: library.element);
|
||||
}
|
||||
|
@ -961,7 +961,7 @@ class FragmentEmitter {
|
|||
// Parameters are named t0, t1, etc, so '_' will not conflict. Forcing '_'
|
||||
// in minified mode works because no parameter or local also minifies to
|
||||
// '_' (the minifier doesn't know '_' is available).
|
||||
js.Name underscore = new StringBackedName('_');
|
||||
js.Name underscore = StringBackedName('_');
|
||||
statements.add(js.js.statement('var # = this;', underscore));
|
||||
thisRef = underscore;
|
||||
} else {
|
||||
|
@ -1000,7 +1000,7 @@ class FragmentEmitter {
|
|||
previousConstant = constant;
|
||||
} else {
|
||||
flushAssignment();
|
||||
js.Parameter parameter = new js.Parameter('t${parameters.length}');
|
||||
js.Parameter parameter = js.Parameter('t${parameters.length}');
|
||||
parameters.add(parameter);
|
||||
statements.add(
|
||||
js.js.statement('#.# = #', [thisRef, field.name, parameter.name]));
|
||||
|
@ -1009,7 +1009,7 @@ class FragmentEmitter {
|
|||
flushAssignment();
|
||||
|
||||
if (cls.hasRtiField) {
|
||||
js.Parameter parameter = new js.Parameter('t${parameters.length}');
|
||||
js.Parameter parameter = js.Parameter('t${parameters.length}');
|
||||
parameters.add(parameter);
|
||||
statements.add(js.js.statement(
|
||||
'#.# = #', [thisRef, _namer.rtiFieldJsName, parameter.name]));
|
||||
|
@ -1044,7 +1044,7 @@ class FragmentEmitter {
|
|||
return proto;
|
||||
}).toList(growable: false);
|
||||
|
||||
return new js.Block(assignments);
|
||||
return js.Block(assignments);
|
||||
}
|
||||
|
||||
/// Emits the prototype of the given class [cls].
|
||||
|
@ -1125,7 +1125,7 @@ class FragmentEmitter {
|
|||
js.string(_namer.fixedNames.defaultValuesField), js.LiteralNull()));
|
||||
}
|
||||
|
||||
return new js.ObjectInitializer(properties);
|
||||
return js.ObjectInitializer(properties);
|
||||
}
|
||||
|
||||
/// Emits the given instance [method].
|
||||
|
@ -1223,9 +1223,8 @@ class FragmentEmitter {
|
|||
|
||||
for (Class superclass in subclasses.keys) {
|
||||
List<Class> list = subclasses[superclass];
|
||||
js.Expression superclassReference = (superclass == null)
|
||||
? new js.LiteralNull()
|
||||
: classReference(superclass);
|
||||
js.Expression superclassReference =
|
||||
(superclass == null) ? js.LiteralNull() : classReference(superclass);
|
||||
if (list.length == 1) {
|
||||
Class cls = list.single;
|
||||
var statement = js.js.statement('#(#, #)', [
|
||||
|
@ -1305,12 +1304,12 @@ class FragmentEmitter {
|
|||
if (method.optionalParameterDefaultValues is List) {
|
||||
List<ConstantValue> defaultValues = method.optionalParameterDefaultValues;
|
||||
if (defaultValues.isEmpty) {
|
||||
return new js.LiteralNull();
|
||||
return js.LiteralNull();
|
||||
}
|
||||
Iterable<js.Expression> elements =
|
||||
defaultValues.map(generateConstantReference);
|
||||
return js.js('function() { return #; }',
|
||||
new js.ArrayInitializer(elements.toList()));
|
||||
return js.js(
|
||||
'function() { return #; }', js.ArrayInitializer(elements.toList()));
|
||||
} else {
|
||||
Map<String, ConstantValue> defaultValues =
|
||||
method.optionalParameterDefaultValues;
|
||||
|
@ -1323,10 +1322,10 @@ class FragmentEmitter {
|
|||
for (String name in names) {
|
||||
ConstantValue value = defaultValues[name];
|
||||
properties.add(
|
||||
new js.Property(js.string(name), generateConstantReference(value)));
|
||||
js.Property(js.string(name), generateConstantReference(value)));
|
||||
}
|
||||
return js.js(
|
||||
'function() { return #; }', new js.ObjectInitializer(properties));
|
||||
'function() { return #; }', js.ObjectInitializer(properties));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1334,7 +1333,7 @@ class FragmentEmitter {
|
|||
/// profiles.
|
||||
// TODO(sra): Should this be conditional?
|
||||
js.Statement wrapPhase(String name, List<js.Statement> statements) {
|
||||
js.Block block = new js.Block(statements);
|
||||
js.Block block = js.Block(statements);
|
||||
if (statements.isEmpty) return block;
|
||||
return js.js.statement('(function #(){#})();', [name, block]);
|
||||
}
|
||||
|
@ -1668,21 +1667,20 @@ class FragmentEmitter {
|
|||
DeferredLoadingState deferredLoadingState) {
|
||||
List<js.Property> globals = [];
|
||||
|
||||
globals.add(new js.Property(
|
||||
globals.add(js.Property(
|
||||
js.string(DEFERRED_INITIALIZED), js.js("Object.create(null)")));
|
||||
|
||||
String deferredGlobal = ModelEmitter.deferredInitializersGlobal;
|
||||
js.Expression isHunkLoadedFunction =
|
||||
js.js("function(hash) { return !!$deferredGlobal[hash]; }");
|
||||
globals
|
||||
.add(new js.Property(js.string(IS_HUNK_LOADED), isHunkLoadedFunction));
|
||||
globals.add(js.Property(js.string(IS_HUNK_LOADED), isHunkLoadedFunction));
|
||||
|
||||
js.Expression isHunkInitializedFunction = js.js(
|
||||
"function(hash) { return !!#deferredInitialized[hash]; }", {
|
||||
'deferredInitialized': generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
|
||||
});
|
||||
globals.add(new js.Property(
|
||||
js.string(IS_HUNK_INITIALIZED), isHunkInitializedFunction));
|
||||
globals.add(
|
||||
js.Property(js.string(IS_HUNK_INITIALIZED), isHunkInitializedFunction));
|
||||
|
||||
/// See [finalizeDeferredLoadingData] for the format of the deferred hunk.
|
||||
js.Expression initializeLoadedHunkFunction = js.js("""
|
||||
|
@ -1698,14 +1696,14 @@ class FragmentEmitter {
|
|||
'deferredInitialized': generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
|
||||
});
|
||||
|
||||
globals.add(new js.Property(
|
||||
globals.add(js.Property(
|
||||
js.string(INITIALIZE_LOADED_HUNK), initializeLoadedHunkFunction));
|
||||
|
||||
globals.add(new js.Property(js.string(DEFERRED_LIBRARY_PARTS),
|
||||
globals.add(js.Property(js.string(DEFERRED_LIBRARY_PARTS),
|
||||
deferredLoadingState.deferredLibraryParts));
|
||||
globals.add(new js.Property(
|
||||
globals.add(js.Property(
|
||||
js.string(DEFERRED_PART_URIS), deferredLoadingState.deferredPartUris));
|
||||
globals.add(new js.Property(js.string(DEFERRED_PART_HASHES),
|
||||
globals.add(js.Property(js.string(DEFERRED_PART_HASHES),
|
||||
deferredLoadingState.deferredPartHashes));
|
||||
|
||||
return globals;
|
||||
|
@ -1783,12 +1781,12 @@ class FragmentEmitter {
|
|||
];
|
||||
// TODO(floitsch): this should probably be on a per-fragment basis.
|
||||
nativeClassesNeedingUnmangledName.forEach((element) {
|
||||
names.add(new js.Property(
|
||||
names.add(js.Property(
|
||||
js.quoteName(_namer.className(element)), js.string(element.name)));
|
||||
});
|
||||
|
||||
return new js.Property(
|
||||
js.string(MANGLED_GLOBAL_NAMES), new js.ObjectInitializer(names));
|
||||
return js.Property(
|
||||
js.string(MANGLED_GLOBAL_NAMES), js.ObjectInitializer(names));
|
||||
}
|
||||
|
||||
/// Emits the [METADATA] embedded global.
|
||||
|
@ -1799,7 +1797,7 @@ class FragmentEmitter {
|
|||
List<js.Property> metadataGlobals = [];
|
||||
|
||||
js.Property createGlobal(js.Expression metadata, String global) {
|
||||
return new js.Property(js.string(global), metadata);
|
||||
return js.Property(js.string(global), metadata);
|
||||
}
|
||||
|
||||
var mainUnit = program.mainFragment.outputUnit;
|
||||
|
@ -2045,13 +2043,13 @@ class FragmentEmitter {
|
|||
if (cls.nativeLeafTags != null) {
|
||||
for (String tag in cls.nativeLeafTags) {
|
||||
interceptorsByTag[tag] = classReference(cls);
|
||||
leafTags[tag] = new js.LiteralBool(true);
|
||||
leafTags[tag] = js.LiteralBool(true);
|
||||
}
|
||||
}
|
||||
if (cls.nativeNonLeafTags != null) {
|
||||
for (String tag in cls.nativeNonLeafTags) {
|
||||
interceptorsByTag[tag] = classReference(cls);
|
||||
leafTags[tag] = new js.LiteralBool(false);
|
||||
leafTags[tag] = js.LiteralBool(false);
|
||||
}
|
||||
if (cls.nativeExtensions != null) {
|
||||
List<Class> subclasses = cls.nativeExtensions;
|
||||
|
@ -2110,9 +2108,9 @@ class LocalAliases {
|
|||
}
|
||||
|
||||
class DeferredLoadingState {
|
||||
final deferredLibraryParts = new DeferredPrimaryExpression();
|
||||
final deferredPartUris = new DeferredPrimaryExpression();
|
||||
final deferredPartHashes = new DeferredPrimaryExpression();
|
||||
final deferredLibraryParts = DeferredPrimaryExpression();
|
||||
final deferredPartUris = DeferredPrimaryExpression();
|
||||
final deferredPartHashes = DeferredPrimaryExpression();
|
||||
}
|
||||
|
||||
class DeferredPrimaryExpression extends js.DeferredExpression {
|
||||
|
|
|
@ -157,10 +157,10 @@ class ModelEmitter {
|
|||
this._sourceInformationStrategy,
|
||||
RecipeEncoder rtiRecipeEncoder,
|
||||
this._shouldGenerateSourceMap)
|
||||
: _constantOrdering = new ConstantOrdering(_closedWorld.sorter),
|
||||
: _constantOrdering = ConstantOrdering(_closedWorld.sorter),
|
||||
fragmentMerger = FragmentMerger(_options,
|
||||
_closedWorld.elementEnvironment, _closedWorld.outputUnitData) {
|
||||
this.constantEmitter = new ConstantEmitter(
|
||||
this.constantEmitter = ConstantEmitter(
|
||||
_options,
|
||||
_namer,
|
||||
_closedWorld.commonElements,
|
||||
|
@ -229,9 +229,9 @@ class ModelEmitter {
|
|||
int emitProgram(Program program, CodegenWorld codegenWorld) {
|
||||
MainFragment mainFragment = program.fragments.first;
|
||||
List<DeferredFragment> deferredFragments =
|
||||
new List<DeferredFragment>.from(program.deferredFragments);
|
||||
List<DeferredFragment>.from(program.deferredFragments);
|
||||
|
||||
FragmentEmitter fragmentEmitter = new FragmentEmitter(
|
||||
FragmentEmitter fragmentEmitter = FragmentEmitter(
|
||||
_options,
|
||||
_dumpInfoTask,
|
||||
_namer,
|
||||
|
@ -305,12 +305,12 @@ class ModelEmitter {
|
|||
finalizedFragmentsToLoad);
|
||||
|
||||
// Emit main Fragment.
|
||||
var deferredLoadingState = new DeferredLoadingState();
|
||||
var deferredLoadingState = DeferredLoadingState();
|
||||
js.Statement mainCode = fragmentEmitter.emitMainFragment(
|
||||
program, finalizedFragmentsToLoad, deferredLoadingState);
|
||||
|
||||
// Count tokens and run finalizers.
|
||||
js.TokenCounter counter = new js.TokenCounter();
|
||||
js.TokenCounter counter = js.TokenCounter();
|
||||
for (var emittedFragments in deferredFragmentsCode.values) {
|
||||
for (var emittedFragment in emittedFragments) {
|
||||
counter.countTokens(emittedFragment.code);
|
||||
|
@ -481,7 +481,7 @@ var ${startupMetricsGlobal} =
|
|||
LocationCollector locationCollector;
|
||||
if (_shouldGenerateSourceMap) {
|
||||
_task.measureSubtask('source-maps', () {
|
||||
locationCollector = new LocationCollector();
|
||||
locationCollector = LocationCollector();
|
||||
outputListeners.add(locationCollector);
|
||||
});
|
||||
}
|
||||
|
@ -556,13 +556,13 @@ var ${startupMetricsGlobal} =
|
|||
// deferredInitializer.current = <pretty-printed code>;
|
||||
// deferredInitializer[<hash>] = deferredInitializer.current;
|
||||
|
||||
js.Program program = new js.Program([
|
||||
js.Program program = js.Program([
|
||||
if (isFirst) buildGeneratedBy(),
|
||||
if (isFirst) buildDeferredInitializerGlobal(),
|
||||
js.js.statement('$deferredInitializersGlobal.current = #', code)
|
||||
]);
|
||||
|
||||
Hasher hasher = new Hasher();
|
||||
Hasher hasher = Hasher();
|
||||
CodeBuffer buffer = js.createCodeBuffer(
|
||||
program, _options, _sourceInformationStrategy,
|
||||
monitor: _dumpInfoTask, listeners: [hasher]);
|
||||
|
|
Loading…
Reference in a new issue