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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1161683002: dart2js cps: 'is' checks on types with type arguments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 ir.Primitive receiver = visit(expression); 870 ir.Primitive receiver = visit(expression);
871 return irBuilder.buildTypeOperator(receiver, type, isTypeTest: false); 871 return irBuilder.buildTypeOperator(receiver, type, isTypeTest: false);
872 } 872 }
873 873
874 @override 874 @override
875 ir.Primitive visitIs( 875 ir.Primitive visitIs(
876 ast.Send node, 876 ast.Send node,
877 ast.Node expression, 877 ast.Node expression,
878 DartType type, 878 DartType type,
879 _) { 879 _) {
880 ir.Primitive receiver = visit(expression); 880 ir.Primitive value = visit(expression);
881 return irBuilder.buildTypeOperator( 881 return irBuilder.buildTypeOperator(value, type, isTypeTest: true);
882 receiver, type,
883 isTypeTest: true,
884 isNotCheck: false);
885 } 882 }
886 883
887 @override 884 @override
888 ir.Primitive visitIsNot(ast.Send node, 885 ir.Primitive visitIsNot(ast.Send node,
889 ast.Node expression, DartType type, _) { 886 ast.Node expression, DartType type, _) {
890 ir.Primitive receiver = visit(expression); 887 ir.Primitive value = visit(expression);
891 return irBuilder.buildTypeOperator( 888 ir.Primitive check = irBuilder.buildTypeOperator(
892 receiver, type, 889 value, type, isTypeTest: true);
893 isTypeTest: true, 890 return irBuilder.buildNegation(check);
894 isNotCheck: true);
895 } 891 }
896 892
897 ir.Primitive translateBinary(ast.Node left, 893 ir.Primitive translateBinary(ast.Node left,
898 op.BinaryOperator operator, 894 op.BinaryOperator operator,
899 ast.Node right) { 895 ast.Node right) {
900 Selector selector = new Selector.binaryOperator(operator.selectorName); 896 Selector selector = new Selector.binaryOperator(operator.selectorName);
901 ir.Primitive receiver = visit(left); 897 ir.Primitive receiver = visit(left);
902 List<ir.Primitive> arguments = <ir.Primitive>[visit(right)]; 898 List<ir.Primitive> arguments = <ir.Primitive>[visit(right)];
903 arguments = normalizeDynamicArguments(selector.callStructure, arguments); 899 arguments = normalizeDynamicArguments(selector.callStructure, arguments);
904 return irBuilder.buildDynamicInvocation(receiver, selector, arguments); 900 return irBuilder.buildDynamicInvocation(receiver, selector, arguments);
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 JavaScriptBackend get _backend => _compiler.backend; 2296 JavaScriptBackend get _backend => _compiler.backend;
2301 2297
2302 GlobalProgramInformation(this._compiler); 2298 GlobalProgramInformation(this._compiler);
2303 2299
2304 /// Returns [true], if the analysis could not determine that the type 2300 /// Returns [true], if the analysis could not determine that the type
2305 /// arguments for the class [cls] are never used in the program. 2301 /// arguments for the class [cls] are never used in the program.
2306 bool requiresRuntimeTypesFor(ClassElement cls) { 2302 bool requiresRuntimeTypesFor(ClassElement cls) {
2307 return cls.typeVariables.isNotEmpty && _backend.classNeedsRti(cls); 2303 return cls.typeVariables.isNotEmpty && _backend.classNeedsRti(cls);
2308 } 2304 }
2309 2305
2310 Set<ClassElement> get interceptedClasses => _backend.interceptedClasses; 2306 ClassElement get nullClass => _compiler.nullClass;
2311 } 2307 }
2312 2308
2313 /// IR builder specific to the JavaScript backend, coupled to the [JsIrBuilder]. 2309 /// IR builder specific to the JavaScript backend, coupled to the [JsIrBuilder].
2314 class JsIrBuilderVisitor extends IrBuilderVisitor { 2310 class JsIrBuilderVisitor extends IrBuilderVisitor {
2315 /// Promote the type of [irBuilder] to [JsIrBuilder]. 2311 /// Promote the type of [irBuilder] to [JsIrBuilder].
2316 JsIrBuilder get irBuilder => super.irBuilder; 2312 JsIrBuilder get irBuilder => super.irBuilder;
2317 2313
2318 JavaScriptBackend get backend => compiler.backend; 2314 JavaScriptBackend get backend => compiler.backend;
2319 2315
2320 /// Result of closure conversion for the current body of code. 2316 /// Result of closure conversion for the current body of code.
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 node.body = replacementFor(node.body); 3075 node.body = replacementFor(node.body);
3080 } 3076 }
3081 } 3077 }
3082 3078
3083 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 3079 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
3084 class RemovalVisitor extends ir.RecursiveVisitor { 3080 class RemovalVisitor extends ir.RecursiveVisitor {
3085 processReference(ir.Reference reference) { 3081 processReference(ir.Reference reference) {
3086 reference.unlink(); 3082 reference.unlink();
3087 } 3083 }
3088 } 3084 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698