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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 17413013: Revert "Support runtime check of function types." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 abstract class HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBailoutTarget(HBailoutTarget node); 9 R visitBailoutTarget(HBailoutTarget node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 HInstruction current = this.next; 1103 HInstruction current = this.next;
1104 while (current != null) { 1104 while (current != null) {
1105 if (current == other) return true; 1105 if (current == other) return true;
1106 current = current.next; 1106 current = current.next;
1107 } 1107 }
1108 return false; 1108 return false;
1109 } 1109 }
1110 1110
1111 HInstruction convertType(Compiler compiler, DartType type, int kind) { 1111 HInstruction convertType(Compiler compiler, DartType type, int kind) {
1112 if (type == null) return this; 1112 if (type == null) return this;
1113 type = type.unalias(compiler);
1114 // Only the builder knows how to create [HTypeConversion] 1113 // Only the builder knows how to create [HTypeConversion]
1115 // instructions with generics. It has the generic type context 1114 // instructions with generics. It has the generic type context
1116 // available. 1115 // available.
1117 assert(type.kind != TypeKind.TYPE_VARIABLE); 1116 assert(type.kind != TypeKind.TYPE_VARIABLE);
1117 // TODO(5022): Generic typedefs should not be handled here.
1118 assert(type.isRaw 1118 assert(type.isRaw
1119 || type.isMalformed 1119 || type.isMalformed
1120 || type.kind == TypeKind.TYPEDEF
1120 || type.kind == TypeKind.FUNCTION); 1121 || type.kind == TypeKind.FUNCTION);
1121 if (identical(type.element, compiler.dynamicClass)) return this; 1122 if (identical(type.element, compiler.dynamicClass)) return this;
1122 if (identical(type.element, compiler.objectClass)) return this; 1123 if (identical(type.element, compiler.objectClass)) return this;
1123 if (type.isMalformed || type.kind != TypeKind.INTERFACE) { 1124 if (type.isMalformed || type.kind != TypeKind.INTERFACE) {
1124 return new HTypeConversion(type, kind, HType.UNKNOWN, this); 1125 return new HTypeConversion(type, kind, HType.UNKNOWN, this);
1125 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { 1126 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) {
1126 // Boolean conversion checks work on non-nullable booleans. 1127 // Boolean conversion checks work on non-nullable booleans.
1127 return new HTypeConversion(type, kind, HType.BOOLEAN, this); 1128 return new HTypeConversion(type, kind, HType.BOOLEAN, this);
1128 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) { 1129 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) {
1129 throw 'creating compound check to $type (this = ${this})'; 1130 throw 'creating compound check to $type (this = ${this})';
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 return typeExpression == other.typeExpression 2244 return typeExpression == other.typeExpression
2244 && nullOk == other.nullOk 2245 && nullOk == other.nullOk
2245 && kind == other.kind; 2246 && kind == other.kind;
2246 } 2247 }
2247 } 2248 }
2248 2249
2249 class HTypeConversion extends HCheck { 2250 class HTypeConversion extends HCheck {
2250 final DartType typeExpression; 2251 final DartType typeExpression;
2251 final int kind; 2252 final int kind;
2252 final Selector receiverTypeCheckSelector; 2253 final Selector receiverTypeCheckSelector;
2253 final bool contextIsTypeArguments;
2254 2254
2255 static const int NO_CHECK = 0; 2255 static const int NO_CHECK = 0;
2256 static const int CHECKED_MODE_CHECK = 1; 2256 static const int CHECKED_MODE_CHECK = 1;
2257 static const int ARGUMENT_TYPE_CHECK = 2; 2257 static const int ARGUMENT_TYPE_CHECK = 2;
2258 static const int CAST_TYPE_CHECK = 3; 2258 static const int CAST_TYPE_CHECK = 3;
2259 static const int BOOLEAN_CONVERSION_CHECK = 4; 2259 static const int BOOLEAN_CONVERSION_CHECK = 4;
2260 static const int RECEIVER_TYPE_CHECK = 5; 2260 static const int RECEIVER_TYPE_CHECK = 5;
2261 2261
2262 HTypeConversion(this.typeExpression, this.kind, 2262 HTypeConversion(this.typeExpression, this.kind,
2263 HType type, HInstruction input, 2263 HType type, HInstruction input,
2264 [this.receiverTypeCheckSelector]) 2264 [this.receiverTypeCheckSelector])
2265 : contextIsTypeArguments = false, 2265 : super(<HInstruction>[input]) {
2266 super(<HInstruction>[input]) {
2267 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); 2266 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null);
2268 assert(typeExpression == null ||
2269 typeExpression.kind != TypeKind.TYPEDEF);
2270 sourceElement = input.sourceElement; 2267 sourceElement = input.sourceElement;
2271 instructionType = type; 2268 instructionType = type;
2272 } 2269 }
2273 2270
2274 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind, 2271 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind,
2275 HType type, HInstruction input, 2272 HType type, HInstruction input,
2276 HInstruction typeRepresentation) 2273 HInstruction typeRepresentation)
2277 : contextIsTypeArguments = false, 2274 : super(<HInstruction>[input, typeRepresentation]),
2278 super(<HInstruction>[input, typeRepresentation]),
2279 receiverTypeCheckSelector = null { 2275 receiverTypeCheckSelector = null {
2280 assert(typeExpression.kind != TypeKind.TYPEDEF);
2281 sourceElement = input.sourceElement; 2276 sourceElement = input.sourceElement;
2282 instructionType = type; 2277 instructionType = type;
2283 } 2278 }
2284 2279
2285 HTypeConversion.withContext(this.typeExpression, this.kind, 2280 bool get hasTypeRepresentation => inputs.length > 1;
2286 HType type, HInstruction input,
2287 HInstruction context,
2288 {bool this.contextIsTypeArguments})
2289 : super(<HInstruction>[input, context]),
2290 receiverTypeCheckSelector = null {
2291 assert(typeExpression.kind != TypeKind.TYPEDEF);
2292 sourceElement = input.sourceElement;
2293 instructionType = type;
2294 }
2295
2296 bool get hasTypeRepresentation {
2297 return typeExpression.kind == TypeKind.INTERFACE && inputs.length > 1;
2298 }
2299 HInstruction get typeRepresentation => inputs[1]; 2281 HInstruction get typeRepresentation => inputs[1];
2300 2282
2301 bool get hasContext {
2302 return typeExpression.kind == TypeKind.FUNCTION && inputs.length > 1;
2303 }
2304 HInstruction get context => inputs[1];
2305
2306 HInstruction convertType(Compiler compiler, DartType type, int kind) { 2283 HInstruction convertType(Compiler compiler, DartType type, int kind) {
2307 if (typeExpression == type) return this; 2284 if (typeExpression == type) return this;
2308 return super.convertType(compiler, type, kind); 2285 return super.convertType(compiler, type, kind);
2309 } 2286 }
2310 2287
2311 bool get isChecked => kind != NO_CHECK; 2288 bool get isChecked => kind != NO_CHECK;
2312 bool get isCheckedModeCheck { 2289 bool get isCheckedModeCheck {
2313 return kind == CHECKED_MODE_CHECK 2290 return kind == CHECKED_MODE_CHECK
2314 || kind == BOOLEAN_CONVERSION_CHECK; 2291 || kind == BOOLEAN_CONVERSION_CHECK;
2315 } 2292 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 HBasicBlock get start => expression.start; 2689 HBasicBlock get start => expression.start;
2713 HBasicBlock get end { 2690 HBasicBlock get end {
2714 // We don't create a switch block if there are no cases. 2691 // We don't create a switch block if there are no cases.
2715 assert(!statements.isEmpty); 2692 assert(!statements.isEmpty);
2716 return statements.last.end; 2693 return statements.last.end;
2717 } 2694 }
2718 2695
2719 bool accept(HStatementInformationVisitor visitor) => 2696 bool accept(HStatementInformationVisitor visitor) =>
2720 visitor.visitSwitchInfo(this); 2697 visitor.visitSwitchInfo(this);
2721 } 2698 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698