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

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

Issue 1518473002: dart2js: Fix an issue with erroneous for-in. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix a silly typo in the comment. Created 5 years 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; 5 library dart2js.ir_builder;
6 6
7 import '../closure.dart' hide ClosureScope; 7 import '../closure.dart' hide ClosureScope;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show 9 import '../common/names.dart' show
10 Names, 10 Names,
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 ir.Primitive _buildInvokeCall(ir.Primitive target, 695 ir.Primitive _buildInvokeCall(ir.Primitive target,
696 CallStructure callStructure, 696 CallStructure callStructure,
697 TypeMask mask, 697 TypeMask mask,
698 List<ir.Definition> arguments, 698 List<ir.Definition> arguments,
699 {SourceInformation sourceInformation}) { 699 {SourceInformation sourceInformation}) {
700 Selector selector = callStructure.callSelector; 700 Selector selector = callStructure.callSelector;
701 return _buildInvokeDynamic( 701 return _buildInvokeDynamic(
702 target, selector, mask, arguments, sourceInformation); 702 target, selector, mask, arguments, sourceInformation);
703 } 703 }
704 704
705 ir.Primitive buildStaticNoSuchMethod(Selector selector,
706 List<ir.Primitive> arguments) {
707 Element thrower = program.throwNoSuchMethod;
708 ir.Primitive receiver = buildStringConstant('');
709 ir.Primitive name = buildStringConstant(selector.name);
710 ir.Primitive argumentList = buildListLiteral(null, arguments);
711 ir.Primitive expectedArgumentNames = buildNullConstant();
712 return buildStaticFunctionInvocation(
713 thrower,
714 new CallStructure.unnamed(4),
715 [receiver, name, argumentList, expectedArgumentNames]);
716 }
717
705 718
706 /// Create a [ir.Constant] from [value] and add it to the CPS term. 719 /// Create a [ir.Constant] from [value] and add it to the CPS term.
707 ir.Constant buildConstant(ConstantValue value, 720 ir.Constant buildConstant(ConstantValue value,
708 {SourceInformation sourceInformation}) { 721 {SourceInformation sourceInformation}) {
709 assert(isOpen); 722 assert(isOpen);
710 return addPrimitive( 723 return addPrimitive(
711 new ir.Constant(value, sourceInformation: sourceInformation)); 724 new ir.Constant(value, sourceInformation: sourceInformation));
712 } 725 }
713 726
714 /// Create an integer constant and add it to the CPS term. 727 /// Create an integer constant and add it to the CPS term.
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 new ir.InvokeMethod( 1439 new ir.InvokeMethod(
1427 iterator, 1440 iterator,
1428 Selectors.current, 1441 Selectors.current,
1429 currentMask, 1442 currentMask,
1430 emptyArguments)); 1443 emptyArguments));
1431 // TODO(sra): Does this cover all cases? The general setter case include 1444 // TODO(sra): Does this cover all cases? The general setter case include
1432 // super. 1445 // super.
1433 // TODO(johnniwinther): Extract this as a provided strategy. 1446 // TODO(johnniwinther): Extract this as a provided strategy.
1434 if (Elements.isLocal(variableElement)) { 1447 if (Elements.isLocal(variableElement)) {
1435 bodyBuilder.buildLocalVariableSet(variableElement, currentValue); 1448 bodyBuilder.buildLocalVariableSet(variableElement, currentValue);
1436 } else if (Elements.isMalformed(variableElement)) { 1449 } else if (Elements.isError(variableElement) ||
1437 bodyBuilder.buildErroneousInvocation(variableElement, 1450 Elements.isMalformed(variableElement)) {
1438 new Selector.setter( 1451 Selector selector = new Selector.setter(
1439 new Name(variableElement.name, variableElement.library)), 1452 new Name(variableElement.name, variableElement.library));
1440 <ir.Primitive>[currentValue]); 1453 List<ir.Primitive> value = <ir.Primitive>[currentValue];
1454 // Note the order of the comparisons below. It can be the case that an
1455 // element isError and isMalformed.
1456 if (Elements.isError(variableElement)) {
1457 bodyBuilder.buildStaticNoSuchMethod(selector, value);
1458 } else {
1459 bodyBuilder.buildErroneousInvocation(variableElement, selector, value);
1460 }
1441 } else if (Elements.isStaticOrTopLevel(variableElement)) { 1461 } else if (Elements.isStaticOrTopLevel(variableElement)) {
1442 if (variableElement.isField) { 1462 if (variableElement.isField) {
1443 bodyBuilder.buildStaticFieldSet(variableElement, currentValue); 1463 bodyBuilder.buildStaticFieldSet(variableElement, currentValue);
1444 } else { 1464 } else {
1445 bodyBuilder.buildStaticSetterSet(variableElement, currentValue); 1465 bodyBuilder.buildStaticSetterSet(variableElement, currentValue);
1446 } 1466 }
1447 } else { 1467 } else {
1448 ir.Primitive receiver = bodyBuilder.buildThis(); 1468 ir.Primitive receiver = bodyBuilder.buildThis();
1449 assert(receiver != null); 1469 assert(receiver != null);
1450 bodyBuilder.buildDynamicSet( 1470 bodyBuilder.buildDynamicSet(
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 } 2924 }
2905 2925
2906 class SwitchCaseInfo { 2926 class SwitchCaseInfo {
2907 final List<ir.Primitive> constants = <ir.Primitive>[]; 2927 final List<ir.Primitive> constants = <ir.Primitive>[];
2908 final SubbuildFunction buildBody; 2928 final SubbuildFunction buildBody;
2909 2929
2910 SwitchCaseInfo(this.buildBody); 2930 SwitchCaseInfo(this.buildBody);
2911 2931
2912 void addConstant(ir.Primitive constant) => constants.add(constant); 2932 void addConstant(ir.Primitive constant) => constants.add(constant);
2913 } 2933 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | tests/co19/co19-dart2js.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698