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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1689783002: Don't allow to iterate over strings. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | tests/language/for_in3_test.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) 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 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 7517 matching lines...) Expand 10 before | Expand all | Expand 10 after
7528 // This scheme recognizes for-in on direct lists. It does not recognize all 7528 // This scheme recognizes for-in on direct lists. It does not recognize all
7529 // uses of ArrayIterator. They still occur when the receiver is an Iterable 7529 // uses of ArrayIterator. They still occur when the receiver is an Iterable
7530 // with a `get iterator` method that delegate to another Iterable and the 7530 // with a `get iterator` method that delegate to another Iterable and the
7531 // method is inlined. We would require full scalar replacement in that 7531 // method is inlined. We would require full scalar replacement in that
7532 // case. 7532 // case.
7533 7533
7534 Selector selector = Selectors.iterator; 7534 Selector selector = Selectors.iterator;
7535 TypeMask mask = elements.getIteratorTypeMask(node); 7535 TypeMask mask = elements.getIteratorTypeMask(node);
7536 7536
7537 ClassWorld classWorld = compiler.world; 7537 ClassWorld classWorld = compiler.world;
7538 if (mask != null && mask.satisfies(helpers.jsIndexableClass, classWorld)) { 7538 if (mask != null &&
7539 mask.satisfies(helpers.jsIndexableClass, classWorld) &&
7540 // String is indexable but not iterable.
7541 !mask.satisfies(helpers.jsStringClass, classWorld)) {
7539 return buildSyncForInIndexable(node, mask); 7542 return buildSyncForInIndexable(node, mask);
7540 } 7543 }
7541 buildSyncForInIterator(node); 7544 buildSyncForInIterator(node);
7542 } 7545 }
7543 7546
7544 buildSyncForInIterator(ast.SyncForIn node) { 7547 buildSyncForInIterator(ast.SyncForIn node) {
7545 // Generate a structure equivalent to: 7548 // Generate a structure equivalent to:
7546 // Iterator<E> $iter = <iterable>.iterator; 7549 // Iterator<E> $iter = <iterable>.iterator;
7547 // while ($iter.moveNext()) { 7550 // while ($iter.moveNext()) {
7548 // <declaredIdentifier> = $iter.current; 7551 // <declaredIdentifier> = $iter.current;
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
9236 if (unaliased is TypedefType) throw 'unable to unalias $type'; 9239 if (unaliased is TypedefType) throw 'unable to unalias $type';
9237 unaliased.accept(this, builder); 9240 unaliased.accept(this, builder);
9238 } 9241 }
9239 9242
9240 void visitDynamicType(DynamicType type, SsaBuilder builder) { 9243 void visitDynamicType(DynamicType type, SsaBuilder builder) {
9241 JavaScriptBackend backend = builder.compiler.backend; 9244 JavaScriptBackend backend = builder.compiler.backend;
9242 ClassElement cls = backend.helpers.DynamicRuntimeType; 9245 ClassElement cls = backend.helpers.DynamicRuntimeType;
9243 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 9246 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
9244 } 9247 }
9245 } 9248 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/for_in3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698