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

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

Issue 1214123003: dart2js cps: Ensure JSArray is emitted when we see a type cast. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update output in test Created 5 years, 5 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) 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 js.Expression elementAccess = glue.staticFunctionAccess(target); 198 js.Expression elementAccess = glue.staticFunctionAccess(target);
199 return new js.Call(elementAccess, arguments, 199 return new js.Call(elementAccess, arguments,
200 sourceInformation: sourceInformation); 200 sourceInformation: sourceInformation);
201 } 201 }
202 202
203 @override 203 @override
204 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { 204 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
205 if (node.constant != null) return giveup(node); 205 if (node.constant != null) return giveup(node);
206 206
207 registry.registerInstantiatedType(node.type); 207 registry.registerInstantiatedType(node.type);
208 Selector selector = node.selector;
209 FunctionElement target = node.target; 208 FunctionElement target = node.target;
210 List<js.Expression> arguments = visitExpressionList(node.arguments); 209 List<js.Expression> arguments = visitExpressionList(node.arguments);
211 return buildStaticInvoke(target, arguments); 210 return buildStaticInvoke(target, arguments);
212 } 211 }
213 212
214 void registerMethodInvoke(tree_ir.InvokeMethod node) { 213 void registerMethodInvoke(tree_ir.InvokeMethod node) {
215 Selector selector = node.selector; 214 Selector selector = node.selector;
216 TypeMask mask = node.mask; 215 TypeMask mask = node.mask;
217 if (selector.isGetter) { 216 if (selector.isGetter) {
218 registry.registerDynamicGetter(new UniverseSelector(selector, mask)); 217 registry.registerDynamicGetter(new UniverseSelector(selector, mask));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ClassElement clazz = type.element; 318 ClassElement clazz = type.element;
320 319
321 // Handle some special checks against classes that exist only in 320 // Handle some special checks against classes that exist only in
322 // the compile-time class hierarchy, not at runtime. 321 // the compile-time class hierarchy, not at runtime.
323 if (clazz == glue.jsExtendableArrayClass) { 322 if (clazz == glue.jsExtendableArrayClass) {
324 return js.js(r'!#.fixed$length', <js.Expression>[value]); 323 return js.js(r'!#.fixed$length', <js.Expression>[value]);
325 } else if (clazz == glue.jsMutableArrayClass) { 324 } else if (clazz == glue.jsMutableArrayClass) {
326 return js.js(r'!#.immutable$list', <js.Expression>[value]); 325 return js.js(r'!#.immutable$list', <js.Expression>[value]);
327 } 326 }
328 327
328 // The helper we use needs the JSArray class to exist, but for some
329 // reason the helper does not cause this dependency to be registered.
330 // TODO(asgerf): Most programs need List anyway, but we should fix this.
331 registry.registerInstantiatedClass(glue.listClass);
332
329 // We use one of the two helpers: 333 // We use one of the two helpers:
330 // 334 //
331 // checkSubtype(value, $isT, typeArgs, $asT) 335 // checkSubtype(value, $isT, typeArgs, $asT)
332 // subtypeCast(value, $isT, typeArgs, $asT) 336 // subtypeCast(value, $isT, typeArgs, $asT)
333 // 337 //
334 // Any of the last two arguments may be null if there are no type 338 // Any of the last two arguments may be null if there are no type
335 // arguments, and/or if no substitution is required. 339 // arguments, and/or if no substitution is required.
336 Element function = node.isTypeTest 340 Element function = node.isTypeTest
337 ? glue.getCheckSubtype() 341 ? glue.getCheckSubtype()
338 : glue.getSubtypeCast(); 342 : glue.getSubtypeCast();
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return js.js("typeof # === 'number' && Math.floor(#) === #", args); 766 return js.js("typeof # === 'number' && Math.floor(#) === #", args);
763 } 767 }
764 } 768 }
765 769
766 visitFunctionExpression(tree_ir.FunctionExpression node) { 770 visitFunctionExpression(tree_ir.FunctionExpression node) {
767 // FunctionExpressions are currently unused. 771 // FunctionExpressions are currently unused.
768 // We might need them if we want to emit raw JS nested functions. 772 // We might need them if we want to emit raw JS nested functions.
769 throw 'FunctionExpressions should not be used'; 773 throw 'FunctionExpressions should not be used';
770 } 774 }
771 } 775 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | tests/compiler/dart2js/js_backend_cps_ir_control_flow_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698