Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart

Issue 1394213002: Split RuntimesTypes into RuntimeTypes and RuntimeTypesEncoder (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 233835ba470d450609192b1a22dcf853c772e6f8..8ca7b0e4274a640052c4c0523268d4c958e73ca7 100644
--- a/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart
@@ -94,8 +94,9 @@ class RuntimeTypeGenerator {
result.functionTypeIndex =
emitterTask.metadataCollector.reifyType(type);
} else {
- RuntimeTypes rti = backend.rti;
- jsAst.Expression encoding = rti.getSignatureEncoding(type, thisAccess);
+ RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
+ jsAst.Expression encoding =
+ rtiEncoder.getSignatureEncoding(type, thisAccess);
jsAst.Name operatorSignature =
namer.asName(namer.operatorSignature);
result.properties[operatorSignature] = encoding;
@@ -105,10 +106,14 @@ class RuntimeTypeGenerator {
void generateSubstitution(ClassElement cls, {bool emitNull: false}) {
if (cls.typeVariables.isEmpty) return;
RuntimeTypes rti = backend.rti;
+ RuntimeTypesEncoder rtiEncoder = backend.rtiEncoder;
jsAst.Expression expression;
bool needsNativeCheck =
emitterTask.nativeEmitter.requiresNativeIsCheck(cls);
- expression = rti.getSupertypeSubstitution(classElement, cls);
+ Substitution substitution = rti.getSubstitution(classElement, cls);
+ if (substitution != null) {
+ expression = rtiEncoder.getSubstitutionCode(substitution);
+ }
if (expression == null && (emitNull || needsNativeCheck)) {
expression = new jsAst.LiteralNull();
}
@@ -122,7 +127,8 @@ class RuntimeTypeGenerator {
generateIsTest(checkedClass);
Substitution substitution = check.substitution;
if (substitution != null) {
- jsAst.Expression body = substitution.getCode(backend.rti);
+ jsAst.Expression body =
+ backend.rtiEncoder.getSubstitutionCode(substitution);
result.properties[namer.substitutionName(checkedClass)] = body;
}
}
@@ -291,16 +297,16 @@ class RuntimeTypeGenerator {
StubMethod _generateTypeVariableReader(ClassElement cls,
TypeVariableElement element) {
jsAst.Name name = namer.nameForReadTypeVariable(element);
- int index = RuntimeTypes.getTypeVariableIndex(element);
+ int index = element.index;
jsAst.Expression computeTypeVariable;
Substitution substitution =
- backend.rti.computeSubstitution(
- cls, element.typeDeclaration, alwaysGenerateFunction: true);
+ backend.rti.getSubstitution(cls, element.typeDeclaration);
if (substitution != null) {
computeTypeVariable =
js(r'#.apply(null, this.$builtinTypeInfo)',
- substitution.getCodeForVariable(index, backend.rti));
+ backend.rtiEncoder.getSubstitutionCodeForVariable(
+ substitution, index));
} else {
// TODO(ahe): These can be generated dynamically.
computeTypeVariable =

Powered by Google App Engine
This is Rietveld 408576698