Index: pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart |
diff --git a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart |
index 9c48f4d82a2186b94feffa6dd68e115bb35724fa..f2997aa76738c6b71108c105a4d2ed6d9314d649 100644 |
--- a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart |
+++ b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart |
@@ -5,8 +5,8 @@ |
part of dart2js.js_emitter; |
// Function signatures used in the generation of runtime type information. |
-typedef void FunctionTypeSignatureEmitter(Element method, |
- FunctionType methodType); |
+typedef void FunctionTypeSignatureEmitter( |
+ Element method, FunctionType methodType); |
typedef void SubstitutionEmitter(Element element, {bool emitNull}); |
@@ -37,8 +37,7 @@ class RuntimeTypeGenerator { |
TypeTestRegistry get typeTestRegistry => emitterTask.typeTestRegistry; |
CoreClasses get coreClasses => compiler.coreClasses; |
- Set<ClassElement> get checkedClasses => |
- typeTestRegistry.checkedClasses; |
+ Set<ClassElement> get checkedClasses => typeTestRegistry.checkedClasses; |
Iterable<ClassElement> get classesUsingTypeVariableTests => |
typeTestRegistry.classesUsingTypeVariableTests; |
@@ -56,9 +55,8 @@ class RuntimeTypeGenerator { |
/// type (if class has one) in the metadata object and stores its index in |
/// the result. This is only possible for function types that do not contain |
/// type variables. |
- TypeTestProperties generateIsTests( |
- ClassElement classElement, |
- { bool storeFunctionTypeInMetadata: true}) { |
+ TypeTestProperties generateIsTests(ClassElement classElement, |
+ {bool storeFunctionTypeInMetadata: true}) { |
assert(invariant(classElement, classElement.isDeclaration)); |
TypeTestProperties result = new TypeTestProperties(); |
@@ -69,14 +67,13 @@ class RuntimeTypeGenerator { |
/// native classes. |
/// TODO(herhut): Generate tests for native classes dynamically, as well. |
void generateIsTest(Element other) { |
- if (backend.isNative(classElement) || |
- !classElement.isSubclassOf(other)) { |
+ if (backend.isNative(classElement) || !classElement.isSubclassOf(other)) { |
result.properties[namer.operatorIs(other)] = js('1'); |
} |
} |
- void generateFunctionTypeSignature(FunctionElement method, |
- FunctionType type) { |
+ void generateFunctionTypeSignature( |
+ FunctionElement method, FunctionType type) { |
assert(method.isImplementation); |
jsAst.Expression thisAccess = new jsAst.This(); |
ClosureClassMap closureData = |
@@ -97,8 +94,7 @@ class RuntimeTypeGenerator { |
RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder; |
jsAst.Expression encoding = |
rtiEncoder.getSignatureEncoding(type, thisAccess); |
- jsAst.Name operatorSignature = |
- namer.asName(namer.operatorSignature); |
+ jsAst.Name operatorSignature = namer.asName(namer.operatorSignature); |
result.properties[operatorSignature] = encoding; |
} |
} |
@@ -134,9 +130,7 @@ class RuntimeTypeGenerator { |
} |
_generateIsTestsOn(classElement, generateIsTest, |
- generateFunctionTypeSignature, |
- generateSubstitution, |
- generateTypeCheck); |
+ generateFunctionTypeSignature, generateSubstitution, generateTypeCheck); |
return result; |
} |
@@ -211,7 +205,8 @@ class RuntimeTypeGenerator { |
} |
} |
- void emitNothing(_, {emitNull}) {}; |
+ void emitNothing(_, {emitNull}) {} |
+ ; |
generateSubstitution = emitNothing; |
} |
@@ -230,10 +225,8 @@ class RuntimeTypeGenerator { |
// A superclass might already implement the Function interface. In such |
// a case, we can avoid emiting the is test here. |
if (!cls.superclass.implementsFunction(coreClasses)) { |
- _generateInterfacesIsTests(coreClasses.functionClass, |
- generateIsTest, |
- generateSubstitution, |
- generated); |
+ _generateInterfacesIsTests(coreClasses.functionClass, generateIsTest, |
+ generateSubstitution, generated); |
} |
FunctionType callType = callFunction.computeType(compiler.resolution); |
generateFunctionTypeSignature(callFunction, callType); |
@@ -242,40 +235,42 @@ class RuntimeTypeGenerator { |
for (DartType interfaceType in cls.interfaces) { |
_generateInterfacesIsTests(interfaceType.element, generateIsTest, |
- generateSubstitution, generated); |
+ generateSubstitution, generated); |
} |
} |
/** |
* Generate "is tests" where [cls] is being implemented. |
*/ |
- void _generateInterfacesIsTests(ClassElement cls, |
- void generateIsTest(ClassElement element), |
- SubstitutionEmitter generateSubstitution, |
- Set<Element> alreadyGenerated) { |
+ void _generateInterfacesIsTests( |
+ ClassElement cls, |
+ void generateIsTest(ClassElement element), |
+ SubstitutionEmitter generateSubstitution, |
+ Set<Element> alreadyGenerated) { |
void tryEmitTest(ClassElement check) { |
if (!alreadyGenerated.contains(check) && checkedClasses.contains(check)) { |
alreadyGenerated.add(check); |
generateIsTest(check); |
generateSubstitution(check); |
} |
- }; |
+ } |
+ ; |
tryEmitTest(cls); |
for (DartType interfaceType in cls.interfaces) { |
Element element = interfaceType.element; |
tryEmitTest(element); |
- _generateInterfacesIsTests(element, generateIsTest, generateSubstitution, |
- alreadyGenerated); |
+ _generateInterfacesIsTests( |
+ element, generateIsTest, generateSubstitution, alreadyGenerated); |
} |
// We need to also emit "is checks" for the superclass and its supertypes. |
ClassElement superclass = cls.superclass; |
if (superclass != null) { |
tryEmitTest(superclass); |
- _generateInterfacesIsTests(superclass, generateIsTest, |
- generateSubstitution, alreadyGenerated); |
+ _generateInterfacesIsTests( |
+ superclass, generateIsTest, generateSubstitution, alreadyGenerated); |
} |
} |
@@ -283,20 +278,20 @@ class RuntimeTypeGenerator { |
List<StubMethod> stubs = <StubMethod>[]; |
ClassElement superclass = classElement; |
while (superclass != null) { |
- for (TypeVariableType parameter in superclass.typeVariables) { |
- if (backend.emitter.readTypeVariables.contains(parameter.element)) { |
- stubs.add( |
- _generateTypeVariableReader(classElement, parameter.element)); |
- } |
+ for (TypeVariableType parameter in superclass.typeVariables) { |
+ if (backend.emitter.readTypeVariables.contains(parameter.element)) { |
+ stubs.add( |
+ _generateTypeVariableReader(classElement, parameter.element)); |
} |
- superclass = superclass.superclass; |
} |
+ superclass = superclass.superclass; |
+ } |
return stubs; |
} |
- StubMethod _generateTypeVariableReader(ClassElement cls, |
- TypeVariableElement element) { |
+ StubMethod _generateTypeVariableReader( |
+ ClassElement cls, TypeVariableElement element) { |
jsAst.Name name = namer.nameForReadTypeVariable(element); |
int index = element.index; |
jsAst.Expression computeTypeVariable; |
@@ -304,21 +299,22 @@ class RuntimeTypeGenerator { |
Substitution substitution = |
backend.rti.getSubstitution(cls, element.typeDeclaration); |
if (substitution != null) { |
- computeTypeVariable = |
- js(r'#.apply(null, this.$builtinTypeInfo)', |
- backend.rtiEncoder.getSubstitutionCodeForVariable( |
- substitution, index)); |
+ computeTypeVariable = js( |
+ r'#.apply(null, this.$builtinTypeInfo)', |
+ backend.rtiEncoder |
+ .getSubstitutionCodeForVariable(substitution, index)); |
} else { |
// TODO(ahe): These can be generated dynamically. |
- computeTypeVariable = |
- js(r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', |
- js.number(index)); |
+ computeTypeVariable = js( |
+ r'this.$builtinTypeInfo && this.$builtinTypeInfo[#]', |
+ js.number(index)); |
} |
jsAst.Expression convertRtiToRuntimeType = backend.emitter |
- .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType); |
+ .staticFunctionAccess(backend.helpers.convertRtiToRuntimeType); |
- return new StubMethod(name, |
- js('function () { return #(#) }', |
- [convertRtiToRuntimeType, computeTypeVariable])); |
+ return new StubMethod( |
+ name, |
+ js('function () { return #(#) }', |
+ [convertRtiToRuntimeType, computeTypeVariable])); |
} |
} |