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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 1206873003: dart2js cps: Handle checks against mutable and extendable lists. (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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir;
10 import '../../tree_ir/tree_ir_nodes.dart' show BuiltinOperator; 10 import '../../tree_ir/tree_ir_nodes.dart' show BuiltinOperator;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 @override 331 @override
332 js.Expression visitTypeOperator(tree_ir.TypeOperator node) { 332 js.Expression visitTypeOperator(tree_ir.TypeOperator node) {
333 js.Expression value = visitExpression(node.value); 333 js.Expression value = visitExpression(node.value);
334 List<js.Expression> typeArguments = visitExpressionList(node.typeArguments); 334 List<js.Expression> typeArguments = visitExpressionList(node.typeArguments);
335 DartType type = node.type; 335 DartType type = node.type;
336 if (type is InterfaceType) { 336 if (type is InterfaceType) {
337 glue.registerIsCheck(type, registry); 337 glue.registerIsCheck(type, registry);
338 ClassElement clazz = type.element; 338 ClassElement clazz = type.element;
339 339
340 // Handle some special checks against classes that exist only in
341 // the compile-time class hierarchy, not at runtime.
342 if (clazz == glue.jsExtendableArrayClass) {
343 return js.js(r'!#.fixed$length', <js.Expression>[value]);
344 } else if (clazz == glue.jsMutableArrayClass) {
345 return js.js(r'!#.immutable$list', <js.Expression>[value]);
346 }
347
340 // We use one of the two helpers: 348 // We use one of the two helpers:
341 // 349 //
342 // checkSubtype(value, $isT, typeArgs, $asT) 350 // checkSubtype(value, $isT, typeArgs, $asT)
343 // subtypeCast(value, $isT, typeArgs, $asT) 351 // subtypeCast(value, $isT, typeArgs, $asT)
344 // 352 //
345 // Any of the last two arguments may be null if there are no type 353 // Any of the last two arguments may be null if there are no type
346 // arguments, and/or if no substitution is required. 354 // arguments, and/or if no substitution is required.
347 Element function = node.isTypeTest 355 Element function = node.isTypeTest
348 ? glue.getCheckSubtype() 356 ? glue.getCheckSubtype()
349 : glue.getSubtypeCast(); 357 : glue.getSubtypeCast();
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 return js.js("typeof # === 'number' && Math.floor(#) === #", args); 758 return js.js("typeof # === 'number' && Math.floor(#) === #", args);
751 } 759 }
752 } 760 }
753 761
754 visitFunctionExpression(tree_ir.FunctionExpression node) { 762 visitFunctionExpression(tree_ir.FunctionExpression node) {
755 // FunctionExpressions are currently unused. 763 // FunctionExpressions are currently unused.
756 // We might need them if we want to emit raw JS nested functions. 764 // We might need them if we want to emit raw JS nested functions.
757 throw 'FunctionExpressions should not be used'; 765 throw 'FunctionExpressions should not be used';
758 } 766 }
759 } 767 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698